diff --git a/games/masterplan/assets/index-vv2o-AJ0.js b/games/masterplan/assets/index-Bshv4Z66.js similarity index 88% rename from games/masterplan/assets/index-vv2o-AJ0.js rename to games/masterplan/assets/index-Bshv4Z66.js index 0bb18b5c..df2fadf8 100644 --- a/games/masterplan/assets/index-vv2o-AJ0.js +++ b/games/masterplan/assets/index-Bshv4Z66.js @@ -1,4 +1,4 @@ -var KD=Object.defineProperty;var XD=(t,e,n)=>e in t?KD(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var ee=(t,e,n)=>XD(t,typeof e!="symbol"?e+"":e,n);function qD(t,e){for(var n=0;ns[r]})}}}return Object.freeze(Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}))}(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))s(r);new MutationObserver(r=>{for(const o of r)if(o.type==="childList")for(const i of o.addedNodes)i.tagName==="LINK"&&i.rel==="modulepreload"&&s(i)}).observe(document,{childList:!0,subtree:!0});function n(r){const o={};return r.integrity&&(o.integrity=r.integrity),r.referrerPolicy&&(o.referrerPolicy=r.referrerPolicy),r.crossOrigin==="use-credentials"?o.credentials="include":r.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function s(r){if(r.ep)return;r.ep=!0;const o=n(r);fetch(r.href,o)}})();var Ui=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function oS(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function YD(t){if(t.__esModule)return t;var e=t.default;if(typeof e=="function"){var n=function s(){return this instanceof s?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};n.prototype=e.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(t).forEach(function(s){var r=Object.getOwnPropertyDescriptor(t,s);Object.defineProperty(n,s,r.get?r:{enumerable:!0,get:function(){return t[s]}})}),n}var iS={exports:{}},jf={},aS={exports:{}},_e={};/** +var jD=Object.defineProperty;var KD=(t,e,n)=>e in t?jD(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var ee=(t,e,n)=>KD(t,typeof e!="symbol"?e+"":e,n);function XD(t,e){for(var n=0;ns[r]})}}}return Object.freeze(Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}))}(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))s(r);new MutationObserver(r=>{for(const o of r)if(o.type==="childList")for(const i of o.addedNodes)i.tagName==="LINK"&&i.rel==="modulepreload"&&s(i)}).observe(document,{childList:!0,subtree:!0});function n(r){const o={};return r.integrity&&(o.integrity=r.integrity),r.referrerPolicy&&(o.referrerPolicy=r.referrerPolicy),r.crossOrigin==="use-credentials"?o.credentials="include":r.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function s(r){if(r.ep)return;r.ep=!0;const o=n(r);fetch(r.href,o)}})();var Ui=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function oS(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function qD(t){if(t.__esModule)return t;var e=t.default;if(typeof e=="function"){var n=function s(){return this instanceof s?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};n.prototype=e.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(t).forEach(function(s){var r=Object.getOwnPropertyDescriptor(t,s);Object.defineProperty(n,s,r.get?r:{enumerable:!0,get:function(){return t[s]}})}),n}var iS={exports:{}},Hf={},aS={exports:{}},_e={};/** * @license React * react.production.min.js * @@ -6,7 +6,7 @@ var KD=Object.defineProperty;var XD=(t,e,n)=>e in t?KD(t,e,{enumerable:!0,config * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */var iu=Symbol.for("react.element"),QD=Symbol.for("react.portal"),ZD=Symbol.for("react.fragment"),JD=Symbol.for("react.strict_mode"),e_=Symbol.for("react.profiler"),t_=Symbol.for("react.provider"),n_=Symbol.for("react.context"),s_=Symbol.for("react.forward_ref"),r_=Symbol.for("react.suspense"),o_=Symbol.for("react.memo"),i_=Symbol.for("react.lazy"),Dv=Symbol.iterator;function a_(t){return t===null||typeof t!="object"?null:(t=Dv&&t[Dv]||t["@@iterator"],typeof t=="function"?t:null)}var lS={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},cS=Object.assign,uS={};function ml(t,e,n){this.props=t,this.context=e,this.refs=uS,this.updater=n||lS}ml.prototype.isReactComponent={};ml.prototype.setState=function(t,e){if(typeof t!="object"&&typeof t!="function"&&t!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,t,e,"setState")};ml.prototype.forceUpdate=function(t){this.updater.enqueueForceUpdate(this,t,"forceUpdate")};function hS(){}hS.prototype=ml.prototype;function z1(t,e,n){this.props=t,this.context=e,this.refs=uS,this.updater=n||lS}var O1=z1.prototype=new hS;O1.constructor=z1;cS(O1,ml.prototype);O1.isPureReactComponent=!0;var _v=Array.isArray,dS=Object.prototype.hasOwnProperty,M1={current:null},fS={key:!0,ref:!0,__self:!0,__source:!0};function pS(t,e,n){var s,r={},o=null,i=null;if(e!=null)for(s in e.ref!==void 0&&(i=e.ref),e.key!==void 0&&(o=""+e.key),e)dS.call(e,s)&&!fS.hasOwnProperty(s)&&(r[s]=e[s]);var a=arguments.length-2;if(a===1)r.children=n;else if(1e in t?KD(t,e,{enumerable:!0,config * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */var d_=ye,f_=Symbol.for("react.element"),p_=Symbol.for("react.fragment"),m_=Object.prototype.hasOwnProperty,g_=d_.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,x_={key:!0,ref:!0,__self:!0,__source:!0};function gS(t,e,n){var s,r={},o=null,i=null;n!==void 0&&(o=""+n),e.key!==void 0&&(o=""+e.key),e.ref!==void 0&&(i=e.ref);for(s in e)m_.call(e,s)&&!x_.hasOwnProperty(s)&&(r[s]=e[s]);if(t&&t.defaultProps)for(s in e=t.defaultProps,e)r[s]===void 0&&(r[s]=e[s]);return{$$typeof:f_,type:t,key:o,ref:i,props:r,_owner:g_.current}}jf.Fragment=p_;jf.jsx=gS;jf.jsxs=gS;iS.exports=jf;var De=iS.exports,Gg={},xS={exports:{}},ls={},yS={exports:{}},wS={};/** + */var h_=ye,d_=Symbol.for("react.element"),f_=Symbol.for("react.fragment"),p_=Object.prototype.hasOwnProperty,m_=h_.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,g_={key:!0,ref:!0,__self:!0,__source:!0};function gS(t,e,n){var s,r={},o=null,i=null;n!==void 0&&(o=""+n),e.key!==void 0&&(o=""+e.key),e.ref!==void 0&&(i=e.ref);for(s in e)p_.call(e,s)&&!g_.hasOwnProperty(s)&&(r[s]=e[s]);if(t&&t.defaultProps)for(s in e=t.defaultProps,e)r[s]===void 0&&(r[s]=e[s]);return{$$typeof:d_,type:t,key:o,ref:i,props:r,_owner:m_.current}}Hf.Fragment=f_;Hf.jsx=gS;Hf.jsxs=gS;iS.exports=Hf;var De=iS.exports,Gg={},xS={exports:{}},ls={},yS={exports:{}},wS={};/** * @license React * scheduler.production.min.js * @@ -22,7 +22,7 @@ var KD=Object.defineProperty;var XD=(t,e,n)=>e in t?KD(t,e,{enumerable:!0,config * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */(function(t){function e(R,O){var G=R.length;R.push(O);e:for(;0>>1,q=R[X];if(0>>1;Xr(Z,G))ser(ie,Z)?(R[X]=ie,R[se]=G,X=se):(R[X]=Z,R[te]=G,X=te);else if(ser(ie,G))R[X]=ie,R[se]=G,X=se;else break e}}return O}function r(R,O){var G=R.sortIndex-O.sortIndex;return G!==0?G:R.id-O.id}if(typeof performance=="object"&&typeof performance.now=="function"){var o=performance;t.unstable_now=function(){return o.now()}}else{var i=Date,a=i.now();t.unstable_now=function(){return i.now()-a}}var l=[],c=[],u=1,h=null,d=3,f=!1,p=!1,g=!1,x=typeof setTimeout=="function"?setTimeout:null,m=typeof clearTimeout=="function"?clearTimeout:null,y=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function w(R){for(var O=n(c);O!==null;){if(O.callback===null)s(c);else if(O.startTime<=R)s(c),O.sortIndex=O.expirationTime,e(l,O);else break;O=n(c)}}function v(R){if(g=!1,w(R),!p)if(n(l)!==null)p=!0,U(b);else{var O=n(c);O!==null&&K(v,O.startTime-R)}}function b(R,O){p=!1,g&&(g=!1,m(S),S=-1),f=!0;var G=d;try{for(w(O),h=n(l);h!==null&&(!(h.expirationTime>O)||R&&!A());){var X=h.callback;if(typeof X=="function"){h.callback=null,d=h.priorityLevel;var q=X(h.expirationTime<=O);O=t.unstable_now(),typeof q=="function"?h.callback=q:h===n(l)&&s(l),w(O)}else s(l);h=n(l)}if(h!==null)var Q=!0;else{var te=n(c);te!==null&&K(v,te.startTime-O),Q=!1}return Q}finally{h=null,d=G,f=!1}}var C=!1,k=null,S=-1,$=5,N=-1;function A(){return!(t.unstable_now()-N<$)}function M(){if(k!==null){var R=t.unstable_now();N=R;var O=!0;try{O=k(!0,R)}finally{O?L():(C=!1,k=null)}}else C=!1}var L;if(typeof y=="function")L=function(){y(M)};else if(typeof MessageChannel<"u"){var V=new MessageChannel,B=V.port2;V.port1.onmessage=M,L=function(){B.postMessage(null)}}else L=function(){x(M,0)};function U(R){k=R,C||(C=!0,L())}function K(R,O){S=x(function(){R(t.unstable_now())},O)}t.unstable_IdlePriority=5,t.unstable_ImmediatePriority=1,t.unstable_LowPriority=4,t.unstable_NormalPriority=3,t.unstable_Profiling=null,t.unstable_UserBlockingPriority=2,t.unstable_cancelCallback=function(R){R.callback=null},t.unstable_continueExecution=function(){p||f||(p=!0,U(b))},t.unstable_forceFrameRate=function(R){0>R||125X?(R.sortIndex=G,e(c,R),n(l)===null&&R===n(c)&&(g?(m(S),S=-1):g=!0,K(v,G-X))):(R.sortIndex=q,e(l,R),p||f||(p=!0,U(b))),R},t.unstable_shouldYield=A,t.unstable_wrapCallback=function(R){var O=d;return function(){var G=d;d=O;try{return R.apply(this,arguments)}finally{d=G}}}})(wS);yS.exports=wS;var y_=yS.exports;/** + */(function(t){function e(R,O){var G=R.length;R.push(O);e:for(;0>>1,q=R[X];if(0>>1;Xr(Z,G))ser(ie,Z)?(R[X]=ie,R[se]=G,X=se):(R[X]=Z,R[te]=G,X=te);else if(ser(ie,G))R[X]=ie,R[se]=G,X=se;else break e}}return O}function r(R,O){var G=R.sortIndex-O.sortIndex;return G!==0?G:R.id-O.id}if(typeof performance=="object"&&typeof performance.now=="function"){var o=performance;t.unstable_now=function(){return o.now()}}else{var i=Date,a=i.now();t.unstable_now=function(){return i.now()-a}}var l=[],c=[],u=1,h=null,d=3,f=!1,p=!1,g=!1,x=typeof setTimeout=="function"?setTimeout:null,m=typeof clearTimeout=="function"?clearTimeout:null,y=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function w(R){for(var O=n(c);O!==null;){if(O.callback===null)s(c);else if(O.startTime<=R)s(c),O.sortIndex=O.expirationTime,e(l,O);else break;O=n(c)}}function v(R){if(g=!1,w(R),!p)if(n(l)!==null)p=!0,U(b);else{var O=n(c);O!==null&&K(v,O.startTime-R)}}function b(R,O){p=!1,g&&(g=!1,m(S),S=-1),f=!0;var G=d;try{for(w(O),h=n(l);h!==null&&(!(h.expirationTime>O)||R&&!A());){var X=h.callback;if(typeof X=="function"){h.callback=null,d=h.priorityLevel;var q=X(h.expirationTime<=O);O=t.unstable_now(),typeof q=="function"?h.callback=q:h===n(l)&&s(l),w(O)}else s(l);h=n(l)}if(h!==null)var Q=!0;else{var te=n(c);te!==null&&K(v,te.startTime-O),Q=!1}return Q}finally{h=null,d=G,f=!1}}var C=!1,k=null,S=-1,$=5,N=-1;function A(){return!(t.unstable_now()-N<$)}function M(){if(k!==null){var R=t.unstable_now();N=R;var O=!0;try{O=k(!0,R)}finally{O?L():(C=!1,k=null)}}else C=!1}var L;if(typeof y=="function")L=function(){y(M)};else if(typeof MessageChannel<"u"){var V=new MessageChannel,B=V.port2;V.port1.onmessage=M,L=function(){B.postMessage(null)}}else L=function(){x(M,0)};function U(R){k=R,C||(C=!0,L())}function K(R,O){S=x(function(){R(t.unstable_now())},O)}t.unstable_IdlePriority=5,t.unstable_ImmediatePriority=1,t.unstable_LowPriority=4,t.unstable_NormalPriority=3,t.unstable_Profiling=null,t.unstable_UserBlockingPriority=2,t.unstable_cancelCallback=function(R){R.callback=null},t.unstable_continueExecution=function(){p||f||(p=!0,U(b))},t.unstable_forceFrameRate=function(R){0>R||125X?(R.sortIndex=G,e(c,R),n(l)===null&&R===n(c)&&(g?(m(S),S=-1):g=!0,K(v,G-X))):(R.sortIndex=q,e(l,R),p||f||(p=!0,U(b))),R},t.unstable_shouldYield=A,t.unstable_wrapCallback=function(R){var O=d;return function(){var G=d;d=O;try{return R.apply(this,arguments)}finally{d=G}}}})(wS);yS.exports=wS;var x_=yS.exports;/** * @license React * react-dom.production.min.js * @@ -30,15 +30,15 @@ var KD=Object.defineProperty;var XD=(t,e,n)=>e in t?KD(t,e,{enumerable:!0,config * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */var w_=ye,os=y_;function ne(t){for(var e="https://reactjs.org/docs/error-decoder.html?invariant="+t,n=1;n"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Hg=Object.prototype.hasOwnProperty,v_=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,zv={},Ov={};function b_(t){return Hg.call(Ov,t)?!0:Hg.call(zv,t)?!1:v_.test(t)?Ov[t]=!0:(zv[t]=!0,!1)}function C_(t,e,n,s){if(n!==null&&n.type===0)return!1;switch(typeof e){case"function":case"symbol":return!0;case"boolean":return s?!1:n!==null?!n.acceptsBooleans:(t=t.toLowerCase().slice(0,5),t!=="data-"&&t!=="aria-");default:return!1}}function k_(t,e,n,s){if(e===null||typeof e>"u"||C_(t,e,n,s))return!0;if(s)return!1;if(n!==null)switch(n.type){case 3:return!e;case 4:return e===!1;case 5:return isNaN(e);case 6:return isNaN(e)||1>e}return!1}function On(t,e,n,s,r,o,i){this.acceptsBooleans=e===2||e===3||e===4,this.attributeName=s,this.attributeNamespace=r,this.mustUseProperty=n,this.propertyName=t,this.type=e,this.sanitizeURL=o,this.removeEmptyString=i}var ln={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(t){ln[t]=new On(t,0,!1,t,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(t){var e=t[0];ln[e]=new On(e,1,!1,t[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(t){ln[t]=new On(t,2,!1,t.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(t){ln[t]=new On(t,2,!1,t,null,!1,!1)});"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(t){ln[t]=new On(t,3,!1,t.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(t){ln[t]=new On(t,3,!0,t,null,!1,!1)});["capture","download"].forEach(function(t){ln[t]=new On(t,4,!1,t,null,!1,!1)});["cols","rows","size","span"].forEach(function(t){ln[t]=new On(t,6,!1,t,null,!1,!1)});["rowSpan","start"].forEach(function(t){ln[t]=new On(t,5,!1,t.toLowerCase(),null,!1,!1)});var L1=/[\-:]([a-z])/g;function B1(t){return t[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(t){var e=t.replace(L1,B1);ln[e]=new On(e,1,!1,t,null,!1,!1)});"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(t){var e=t.replace(L1,B1);ln[e]=new On(e,1,!1,t,"http://www.w3.org/1999/xlink",!1,!1)});["xml:base","xml:lang","xml:space"].forEach(function(t){var e=t.replace(L1,B1);ln[e]=new On(e,1,!1,t,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(t){ln[t]=new On(t,1,!1,t.toLowerCase(),null,!1,!1)});ln.xlinkHref=new On("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(t){ln[t]=new On(t,1,!1,t.toLowerCase(),null,!0,!0)});function V1(t,e,n,s){var r=ln.hasOwnProperty(e)?ln[e]:null;(r!==null?r.type!==0:s||!(2"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Hg=Object.prototype.hasOwnProperty,w_=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,zv={},Ov={};function v_(t){return Hg.call(Ov,t)?!0:Hg.call(zv,t)?!1:w_.test(t)?Ov[t]=!0:(zv[t]=!0,!1)}function b_(t,e,n,s){if(n!==null&&n.type===0)return!1;switch(typeof e){case"function":case"symbol":return!0;case"boolean":return s?!1:n!==null?!n.acceptsBooleans:(t=t.toLowerCase().slice(0,5),t!=="data-"&&t!=="aria-");default:return!1}}function C_(t,e,n,s){if(e===null||typeof e>"u"||b_(t,e,n,s))return!0;if(s)return!1;if(n!==null)switch(n.type){case 3:return!e;case 4:return e===!1;case 5:return isNaN(e);case 6:return isNaN(e)||1>e}return!1}function On(t,e,n,s,r,o,i){this.acceptsBooleans=e===2||e===3||e===4,this.attributeName=s,this.attributeNamespace=r,this.mustUseProperty=n,this.propertyName=t,this.type=e,this.sanitizeURL=o,this.removeEmptyString=i}var ln={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(t){ln[t]=new On(t,0,!1,t,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(t){var e=t[0];ln[e]=new On(e,1,!1,t[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(t){ln[t]=new On(t,2,!1,t.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(t){ln[t]=new On(t,2,!1,t,null,!1,!1)});"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(t){ln[t]=new On(t,3,!1,t.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(t){ln[t]=new On(t,3,!0,t,null,!1,!1)});["capture","download"].forEach(function(t){ln[t]=new On(t,4,!1,t,null,!1,!1)});["cols","rows","size","span"].forEach(function(t){ln[t]=new On(t,6,!1,t,null,!1,!1)});["rowSpan","start"].forEach(function(t){ln[t]=new On(t,5,!1,t.toLowerCase(),null,!1,!1)});var L1=/[\-:]([a-z])/g;function B1(t){return t[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(t){var e=t.replace(L1,B1);ln[e]=new On(e,1,!1,t,null,!1,!1)});"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(t){var e=t.replace(L1,B1);ln[e]=new On(e,1,!1,t,"http://www.w3.org/1999/xlink",!1,!1)});["xml:base","xml:lang","xml:space"].forEach(function(t){var e=t.replace(L1,B1);ln[e]=new On(e,1,!1,t,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(t){ln[t]=new On(t,1,!1,t.toLowerCase(),null,!1,!1)});ln.xlinkHref=new On("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(t){ln[t]=new On(t,1,!1,t.toLowerCase(),null,!0,!0)});function V1(t,e,n,s){var r=ln.hasOwnProperty(e)?ln[e]:null;(r!==null?r.type!==0:s||!(2a||r[i]!==o[a]){var l=` -`+r[i].replace(" at new "," at ");return t.displayName&&l.includes("")&&(l=l.replace("",t.displayName)),l}while(1<=i&&0<=a);break}}}finally{jm=!1,Error.prepareStackTrace=n}return(t=t?t.displayName||t.name:"")?Yl(t):""}function S_(t){switch(t.tag){case 5:return Yl(t.type);case 16:return Yl("Lazy");case 13:return Yl("Suspense");case 19:return Yl("SuspenseList");case 0:case 2:case 15:return t=Km(t.type,!1),t;case 11:return t=Km(t.type.render,!1),t;case 1:return t=Km(t.type,!0),t;default:return""}}function qg(t){if(t==null)return null;if(typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t;switch(t){case ga:return"Fragment";case ma:return"Portal";case jg:return"Profiler";case W1:return"StrictMode";case Kg:return"Suspense";case Xg:return"SuspenseList"}if(typeof t=="object")switch(t.$$typeof){case CS:return(t.displayName||"Context")+".Consumer";case bS:return(t._context.displayName||"Context")+".Provider";case U1:var e=t.render;return t=t.displayName,t||(t=e.displayName||e.name||"",t=t!==""?"ForwardRef("+t+")":"ForwardRef"),t;case G1:return e=t.displayName||null,e!==null?e:qg(t.type)||"Memo";case ro:e=t._payload,t=t._init;try{return qg(t(e))}catch{}}return null}function I_(t){var e=t.type;switch(t.tag){case 24:return"Cache";case 9:return(e.displayName||"Context")+".Consumer";case 10:return(e._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return t=e.render,t=t.displayName||t.name||"",e.displayName||(t!==""?"ForwardRef("+t+")":"ForwardRef");case 7:return"Fragment";case 5:return e;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return qg(e);case 8:return e===W1?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e}return null}function Ro(t){switch(typeof t){case"boolean":case"number":case"string":case"undefined":return t;case"object":return t;default:return""}}function SS(t){var e=t.type;return(t=t.nodeName)&&t.toLowerCase()==="input"&&(e==="checkbox"||e==="radio")}function $_(t){var e=SS(t)?"checked":"value",n=Object.getOwnPropertyDescriptor(t.constructor.prototype,e),s=""+t[e];if(!t.hasOwnProperty(e)&&typeof n<"u"&&typeof n.get=="function"&&typeof n.set=="function"){var r=n.get,o=n.set;return Object.defineProperty(t,e,{configurable:!0,get:function(){return r.call(this)},set:function(i){s=""+i,o.call(this,i)}}),Object.defineProperty(t,e,{enumerable:n.enumerable}),{getValue:function(){return s},setValue:function(i){s=""+i},stopTracking:function(){t._valueTracker=null,delete t[e]}}}}function Oh(t){t._valueTracker||(t._valueTracker=$_(t))}function IS(t){if(!t)return!1;var e=t._valueTracker;if(!e)return!0;var n=e.getValue(),s="";return t&&(s=SS(t)?t.checked?"true":"false":t.value),t=s,t!==n?(e.setValue(t),!0):!1}function Od(t){if(t=t||(typeof document<"u"?document:void 0),typeof t>"u")return null;try{return t.activeElement||t.body}catch{return t.body}}function Yg(t,e){var n=e.checked;return bt({},e,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??t._wrapperState.initialChecked})}function Pv(t,e){var n=e.defaultValue==null?"":e.defaultValue,s=e.checked!=null?e.checked:e.defaultChecked;n=Ro(e.value!=null?e.value:n),t._wrapperState={initialChecked:s,initialValue:n,controlled:e.type==="checkbox"||e.type==="radio"?e.checked!=null:e.value!=null}}function $S(t,e){e=e.checked,e!=null&&V1(t,"checked",e,!1)}function Qg(t,e){$S(t,e);var n=Ro(e.value),s=e.type;if(n!=null)s==="number"?(n===0&&t.value===""||t.value!=n)&&(t.value=""+n):t.value!==""+n&&(t.value=""+n);else if(s==="submit"||s==="reset"){t.removeAttribute("value");return}e.hasOwnProperty("value")?Zg(t,e.type,n):e.hasOwnProperty("defaultValue")&&Zg(t,e.type,Ro(e.defaultValue)),e.checked==null&&e.defaultChecked!=null&&(t.defaultChecked=!!e.defaultChecked)}function Lv(t,e,n){if(e.hasOwnProperty("value")||e.hasOwnProperty("defaultValue")){var s=e.type;if(!(s!=="submit"&&s!=="reset"||e.value!==void 0&&e.value!==null))return;e=""+t._wrapperState.initialValue,n||e===t.value||(t.value=e),t.defaultValue=e}n=t.name,n!==""&&(t.name=""),t.defaultChecked=!!t._wrapperState.initialChecked,n!==""&&(t.name=n)}function Zg(t,e,n){(e!=="number"||Od(t.ownerDocument)!==t)&&(n==null?t.defaultValue=""+t._wrapperState.initialValue:t.defaultValue!==""+n&&(t.defaultValue=""+n))}var Ql=Array.isArray;function Ea(t,e,n,s){if(t=t.options,e){e={};for(var r=0;r"+e.valueOf().toString()+"",e=Mh.firstChild;t.firstChild;)t.removeChild(t.firstChild);for(;e.firstChild;)t.appendChild(e.firstChild)}});function Nc(t,e){if(e){var n=t.firstChild;if(n&&n===t.lastChild&&n.nodeType===3){n.nodeValue=e;return}}t.textContent=e}var hc={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},N_=["Webkit","ms","Moz","O"];Object.keys(hc).forEach(function(t){N_.forEach(function(e){e=e+t.charAt(0).toUpperCase()+t.substring(1),hc[e]=hc[t]})});function RS(t,e,n){return e==null||typeof e=="boolean"||e===""?"":n||typeof e!="number"||e===0||hc.hasOwnProperty(t)&&hc[t]?(""+e).trim():e+"px"}function AS(t,e){t=t.style;for(var n in e)if(e.hasOwnProperty(n)){var s=n.indexOf("--")===0,r=RS(n,e[n],s);n==="float"&&(n="cssFloat"),s?t.setProperty(n,r):t[n]=r}}var T_=bt({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function t0(t,e){if(e){if(T_[t]&&(e.children!=null||e.dangerouslySetInnerHTML!=null))throw Error(ne(137,t));if(e.dangerouslySetInnerHTML!=null){if(e.children!=null)throw Error(ne(60));if(typeof e.dangerouslySetInnerHTML!="object"||!("__html"in e.dangerouslySetInnerHTML))throw Error(ne(61))}if(e.style!=null&&typeof e.style!="object")throw Error(ne(62))}}function n0(t,e){if(t.indexOf("-")===-1)return typeof e.is=="string";switch(t){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var s0=null;function H1(t){return t=t.target||t.srcElement||window,t.correspondingUseElement&&(t=t.correspondingUseElement),t.nodeType===3?t.parentNode:t}var r0=null,Ra=null,Aa=null;function Wv(t){if(t=cu(t)){if(typeof r0!="function")throw Error(ne(280));var e=t.stateNode;e&&(e=Qf(e),r0(t.stateNode,t.type,e))}}function DS(t){Ra?Aa?Aa.push(t):Aa=[t]:Ra=t}function _S(){if(Ra){var t=Ra,e=Aa;if(Aa=Ra=null,Wv(t),e)for(t=0;t>>=0,t===0?32:31-(L_(t)/B_|0)|0}var Ph=64,Lh=4194304;function Zl(t){switch(t&-t){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return t&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return t}}function Bd(t,e){var n=t.pendingLanes;if(n===0)return 0;var s=0,r=t.suspendedLanes,o=t.pingedLanes,i=n&268435455;if(i!==0){var a=i&~r;a!==0?s=Zl(a):(o&=i,o!==0&&(s=Zl(o)))}else i=n&~r,i!==0?s=Zl(i):o!==0&&(s=Zl(o));if(s===0)return 0;if(e!==0&&e!==s&&!(e&r)&&(r=s&-s,o=e&-e,r>=o||r===16&&(o&4194240)!==0))return e;if(s&4&&(s|=n&16),e=t.entangledLanes,e!==0)for(t=t.entanglements,e&=s;0n;n++)e.push(t);return e}function au(t,e,n){t.pendingLanes|=e,e!==536870912&&(t.suspendedLanes=0,t.pingedLanes=0),t=t.eventTimes,e=31-js(e),t[e]=n}function G_(t,e){var n=t.pendingLanes&~e;t.pendingLanes=e,t.suspendedLanes=0,t.pingedLanes=0,t.expiredLanes&=e,t.mutableReadLanes&=e,t.entangledLanes&=e,e=t.entanglements;var s=t.eventTimes;for(t=t.expirationTimes;0=fc),Qv=" ",Zv=!1;function JS(t,e){switch(t){case"keyup":return yF.indexOf(e.keyCode)!==-1;case"keydown":return e.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function e2(t){return t=t.detail,typeof t=="object"&&"data"in t?t.data:null}var xa=!1;function vF(t,e){switch(t){case"compositionend":return e2(e);case"keypress":return e.which!==32?null:(Zv=!0,Qv);case"textInput":return t=e.data,t===Qv&&Zv?null:t;default:return null}}function bF(t,e){if(xa)return t==="compositionend"||!J1&&JS(t,e)?(t=QS(),gd=Y1=co=null,xa=!1,t):null;switch(t){case"paste":return null;case"keypress":if(!(e.ctrlKey||e.altKey||e.metaKey)||e.ctrlKey&&e.altKey){if(e.char&&1=e)return{node:n,offset:e-t};t=s}e:{for(;n;){if(n.nextSibling){n=n.nextSibling;break e}n=n.parentNode}n=void 0}n=nb(n)}}function r2(t,e){return t&&e?t===e?!0:t&&t.nodeType===3?!1:e&&e.nodeType===3?r2(t,e.parentNode):"contains"in t?t.contains(e):t.compareDocumentPosition?!!(t.compareDocumentPosition(e)&16):!1:!1}function o2(){for(var t=window,e=Od();e instanceof t.HTMLIFrameElement;){try{var n=typeof e.contentWindow.location.href=="string"}catch{n=!1}if(n)t=e.contentWindow;else break;e=Od(t.document)}return e}function ex(t){var e=t&&t.nodeName&&t.nodeName.toLowerCase();return e&&(e==="input"&&(t.type==="text"||t.type==="search"||t.type==="tel"||t.type==="url"||t.type==="password")||e==="textarea"||t.contentEditable==="true")}function RF(t){var e=o2(),n=t.focusedElem,s=t.selectionRange;if(e!==n&&n&&n.ownerDocument&&r2(n.ownerDocument.documentElement,n)){if(s!==null&&ex(n)){if(e=s.start,t=s.end,t===void 0&&(t=e),"selectionStart"in n)n.selectionStart=e,n.selectionEnd=Math.min(t,n.value.length);else if(t=(e=n.ownerDocument||document)&&e.defaultView||window,t.getSelection){t=t.getSelection();var r=n.textContent.length,o=Math.min(s.start,r);s=s.end===void 0?o:Math.min(s.end,r),!t.extend&&o>s&&(r=s,s=o,o=r),r=sb(n,o);var i=sb(n,s);r&&i&&(t.rangeCount!==1||t.anchorNode!==r.node||t.anchorOffset!==r.offset||t.focusNode!==i.node||t.focusOffset!==i.offset)&&(e=e.createRange(),e.setStart(r.node,r.offset),t.removeAllRanges(),o>s?(t.addRange(e),t.extend(i.node,i.offset)):(e.setEnd(i.node,i.offset),t.addRange(e)))}}for(e=[],t=n;t=t.parentNode;)t.nodeType===1&&e.push({element:t,left:t.scrollLeft,top:t.scrollTop});for(typeof n.focus=="function"&&n.focus(),n=0;n=document.documentMode,ya=null,u0=null,mc=null,h0=!1;function rb(t,e,n){var s=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;h0||ya==null||ya!==Od(s)||(s=ya,"selectionStart"in s&&ex(s)?s={start:s.selectionStart,end:s.selectionEnd}:(s=(s.ownerDocument&&s.ownerDocument.defaultView||window).getSelection(),s={anchorNode:s.anchorNode,anchorOffset:s.anchorOffset,focusNode:s.focusNode,focusOffset:s.focusOffset}),mc&&_c(mc,s)||(mc=s,s=Ud(u0,"onSelect"),0ba||(t.current=x0[ba],x0[ba]=null,ba--)}function rt(t,e){ba++,x0[ba]=t.current,t.current=e}var Ao={},kn=Lo(Ao),Hn=Lo(!1),ki=Ao;function Ua(t,e){var n=t.type.contextTypes;if(!n)return Ao;var s=t.stateNode;if(s&&s.__reactInternalMemoizedUnmaskedChildContext===e)return s.__reactInternalMemoizedMaskedChildContext;var r={},o;for(o in n)r[o]=e[o];return s&&(t=t.stateNode,t.__reactInternalMemoizedUnmaskedChildContext=e,t.__reactInternalMemoizedMaskedChildContext=r),r}function jn(t){return t=t.childContextTypes,t!=null}function Hd(){dt(Hn),dt(kn)}function hb(t,e,n){if(kn.current!==Ao)throw Error(ne(168));rt(kn,e),rt(Hn,n)}function p2(t,e,n){var s=t.stateNode;if(e=e.childContextTypes,typeof s.getChildContext!="function")return n;s=s.getChildContext();for(var r in s)if(!(r in e))throw Error(ne(108,I_(t)||"Unknown",r));return bt({},n,s)}function jd(t){return t=(t=t.stateNode)&&t.__reactInternalMemoizedMergedChildContext||Ao,ki=kn.current,rt(kn,t),rt(Hn,Hn.current),!0}function db(t,e,n){var s=t.stateNode;if(!s)throw Error(ne(169));n?(t=p2(t,e,ki),s.__reactInternalMemoizedMergedChildContext=t,dt(Hn),dt(kn),rt(kn,t)):dt(Hn),rt(Hn,n)}var Dr=null,Zf=!1,ag=!1;function m2(t){Dr===null?Dr=[t]:Dr.push(t)}function WF(t){Zf=!0,m2(t)}function Bo(){if(!ag&&Dr!==null){ag=!0;var t=0,e=Ye;try{var n=Dr;for(Ye=1;t>=i,r-=i,zr=1<<32-js(e)+r|n<S?($=k,k=null):$=k.sibling;var N=d(m,k,w[S],v);if(N===null){k===null&&(k=$);break}t&&k&&N.alternate===null&&e(m,k),y=o(N,y,S),C===null?b=N:C.sibling=N,C=N,k=$}if(S===w.length)return n(m,k),gt&&ni(m,S),b;if(k===null){for(;SS?($=k,k=null):$=k.sibling;var A=d(m,k,N.value,v);if(A===null){k===null&&(k=$);break}t&&k&&A.alternate===null&&e(m,k),y=o(A,y,S),C===null?b=A:C.sibling=A,C=A,k=$}if(N.done)return n(m,k),gt&&ni(m,S),b;if(k===null){for(;!N.done;S++,N=w.next())N=h(m,N.value,v),N!==null&&(y=o(N,y,S),C===null?b=N:C.sibling=N,C=N);return gt&&ni(m,S),b}for(k=s(m,k);!N.done;S++,N=w.next())N=f(k,m,S,N.value,v),N!==null&&(t&&N.alternate!==null&&k.delete(N.key===null?S:N.key),y=o(N,y,S),C===null?b=N:C.sibling=N,C=N);return t&&k.forEach(function(M){return e(m,M)}),gt&&ni(m,S),b}function x(m,y,w,v){if(typeof w=="object"&&w!==null&&w.type===ga&&w.key===null&&(w=w.props.children),typeof w=="object"&&w!==null){switch(w.$$typeof){case zh:e:{for(var b=w.key,C=y;C!==null;){if(C.key===b){if(b=w.type,b===ga){if(C.tag===7){n(m,C.sibling),y=r(C,w.props.children),y.return=m,m=y;break e}}else if(C.elementType===b||typeof b=="object"&&b!==null&&b.$$typeof===ro&&mb(b)===C.type){n(m,C.sibling),y=r(C,w.props),y.ref=Vl(m,C,w),y.return=m,m=y;break e}n(m,C);break}else e(m,C);C=C.sibling}w.type===ga?(y=gi(w.props.children,m.mode,v,w.key),y.return=m,m=y):(v=Sd(w.type,w.key,w.props,null,m.mode,v),v.ref=Vl(m,y,w),v.return=m,m=v)}return i(m);case ma:e:{for(C=w.key;y!==null;){if(y.key===C)if(y.tag===4&&y.stateNode.containerInfo===w.containerInfo&&y.stateNode.implementation===w.implementation){n(m,y.sibling),y=r(y,w.children||[]),y.return=m,m=y;break e}else{n(m,y);break}else e(m,y);y=y.sibling}y=mg(w,m.mode,v),y.return=m,m=y}return i(m);case ro:return C=w._init,x(m,y,C(w._payload),v)}if(Ql(w))return p(m,y,w,v);if(Ol(w))return g(m,y,w,v);jh(m,w)}return typeof w=="string"&&w!==""||typeof w=="number"?(w=""+w,y!==null&&y.tag===6?(n(m,y.sibling),y=r(y,w),y.return=m,m=y):(n(m,y),y=pg(w,m.mode,v),y.return=m,m=y),i(m)):n(m,y)}return x}var Ha=w2(!0),v2=w2(!1),qd=Lo(null),Yd=null,Sa=null,rx=null;function ox(){rx=Sa=Yd=null}function ix(t){var e=qd.current;dt(qd),t._currentValue=e}function v0(t,e,n){for(;t!==null;){var s=t.alternate;if((t.childLanes&e)!==e?(t.childLanes|=e,s!==null&&(s.childLanes|=e)):s!==null&&(s.childLanes&e)!==e&&(s.childLanes|=e),t===n)break;t=t.return}}function _a(t,e){Yd=t,rx=Sa=null,t=t.dependencies,t!==null&&t.firstContext!==null&&(t.lanes&e&&(Wn=!0),t.firstContext=null)}function $s(t){var e=t._currentValue;if(rx!==t)if(t={context:t,memoizedValue:e,next:null},Sa===null){if(Yd===null)throw Error(ne(308));Sa=t,Yd.dependencies={lanes:0,firstContext:t}}else Sa=Sa.next=t;return e}var ci=null;function ax(t){ci===null?ci=[t]:ci.push(t)}function b2(t,e,n,s){var r=e.interleaved;return r===null?(n.next=n,ax(e)):(n.next=r.next,r.next=n),e.interleaved=n,Vr(t,s)}function Vr(t,e){t.lanes|=e;var n=t.alternate;for(n!==null&&(n.lanes|=e),n=t,t=t.return;t!==null;)t.childLanes|=e,n=t.alternate,n!==null&&(n.childLanes|=e),n=t,t=t.return;return n.tag===3?n.stateNode:null}var oo=!1;function lx(t){t.updateQueue={baseState:t.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function C2(t,e){t=t.updateQueue,e.updateQueue===t&&(e.updateQueue={baseState:t.baseState,firstBaseUpdate:t.firstBaseUpdate,lastBaseUpdate:t.lastBaseUpdate,shared:t.shared,effects:t.effects})}function Pr(t,e){return{eventTime:t,lane:e,tag:0,payload:null,callback:null,next:null}}function wo(t,e,n){var s=t.updateQueue;if(s===null)return null;if(s=s.shared,Le&2){var r=s.pending;return r===null?e.next=e:(e.next=r.next,r.next=e),s.pending=e,Vr(t,n)}return r=s.interleaved,r===null?(e.next=e,ax(s)):(e.next=r.next,r.next=e),s.interleaved=e,Vr(t,n)}function yd(t,e,n){if(e=e.updateQueue,e!==null&&(e=e.shared,(n&4194240)!==0)){var s=e.lanes;s&=t.pendingLanes,n|=s,e.lanes=n,K1(t,n)}}function gb(t,e){var n=t.updateQueue,s=t.alternate;if(s!==null&&(s=s.updateQueue,n===s)){var r=null,o=null;if(n=n.firstBaseUpdate,n!==null){do{var i={eventTime:n.eventTime,lane:n.lane,tag:n.tag,payload:n.payload,callback:n.callback,next:null};o===null?r=o=i:o=o.next=i,n=n.next}while(n!==null);o===null?r=o=e:o=o.next=e}else r=o=e;n={baseState:s.baseState,firstBaseUpdate:r,lastBaseUpdate:o,shared:s.shared,effects:s.effects},t.updateQueue=n;return}t=n.lastBaseUpdate,t===null?n.firstBaseUpdate=e:t.next=e,n.lastBaseUpdate=e}function Qd(t,e,n,s){var r=t.updateQueue;oo=!1;var o=r.firstBaseUpdate,i=r.lastBaseUpdate,a=r.shared.pending;if(a!==null){r.shared.pending=null;var l=a,c=l.next;l.next=null,i===null?o=c:i.next=c,i=l;var u=t.alternate;u!==null&&(u=u.updateQueue,a=u.lastBaseUpdate,a!==i&&(a===null?u.firstBaseUpdate=c:a.next=c,u.lastBaseUpdate=l))}if(o!==null){var h=r.baseState;i=0,u=c=l=null,a=o;do{var d=a.lane,f=a.eventTime;if((s&d)===d){u!==null&&(u=u.next={eventTime:f,lane:0,tag:a.tag,payload:a.payload,callback:a.callback,next:null});e:{var p=t,g=a;switch(d=e,f=n,g.tag){case 1:if(p=g.payload,typeof p=="function"){h=p.call(f,h,d);break e}h=p;break e;case 3:p.flags=p.flags&-65537|128;case 0:if(p=g.payload,d=typeof p=="function"?p.call(f,h,d):p,d==null)break e;h=bt({},h,d);break e;case 2:oo=!0}}a.callback!==null&&a.lane!==0&&(t.flags|=64,d=r.effects,d===null?r.effects=[a]:d.push(a))}else f={eventTime:f,lane:d,tag:a.tag,payload:a.payload,callback:a.callback,next:null},u===null?(c=u=f,l=h):u=u.next=f,i|=d;if(a=a.next,a===null){if(a=r.shared.pending,a===null)break;d=a,a=d.next,d.next=null,r.lastBaseUpdate=d,r.shared.pending=null}}while(!0);if(u===null&&(l=h),r.baseState=l,r.firstBaseUpdate=c,r.lastBaseUpdate=u,e=r.shared.interleaved,e!==null){r=e;do i|=r.lane,r=r.next;while(r!==e)}else o===null&&(r.shared.lanes=0);$i|=i,t.lanes=i,t.memoizedState=h}}function xb(t,e,n){if(t=e.effects,e.effects=null,t!==null)for(e=0;en?n:4,t(!0);var s=cg.transition;cg.transition={};try{t(!1),e()}finally{Ye=n,cg.transition=s}}function L2(){return Ns().memoizedState}function jF(t,e,n){var s=bo(t);if(n={lane:s,action:n,hasEagerState:!1,eagerState:null,next:null},B2(t))V2(e,n);else if(n=b2(t,e,n,s),n!==null){var r=An();Ks(n,t,s,r),W2(n,e,s)}}function KF(t,e,n){var s=bo(t),r={lane:s,action:n,hasEagerState:!1,eagerState:null,next:null};if(B2(t))V2(e,r);else{var o=t.alternate;if(t.lanes===0&&(o===null||o.lanes===0)&&(o=e.lastRenderedReducer,o!==null))try{var i=e.lastRenderedState,a=o(i,n);if(r.hasEagerState=!0,r.eagerState=a,Zs(a,i)){var l=e.interleaved;l===null?(r.next=r,ax(e)):(r.next=l.next,l.next=r),e.interleaved=r;return}}catch{}finally{}n=b2(t,e,r,s),n!==null&&(r=An(),Ks(n,t,s,r),W2(n,e,s))}}function B2(t){var e=t.alternate;return t===vt||e!==null&&e===vt}function V2(t,e){gc=Jd=!0;var n=t.pending;n===null?e.next=e:(e.next=n.next,n.next=e),t.pending=e}function W2(t,e,n){if(n&4194240){var s=e.lanes;s&=t.pendingLanes,n|=s,e.lanes=n,K1(t,n)}}var ef={readContext:$s,useCallback:mn,useContext:mn,useEffect:mn,useImperativeHandle:mn,useInsertionEffect:mn,useLayoutEffect:mn,useMemo:mn,useReducer:mn,useRef:mn,useState:mn,useDebugValue:mn,useDeferredValue:mn,useTransition:mn,useMutableSource:mn,useSyncExternalStore:mn,useId:mn,unstable_isNewReconciler:!1},XF={readContext:$s,useCallback:function(t,e){return or().memoizedState=[t,e===void 0?null:e],t},useContext:$s,useEffect:wb,useImperativeHandle:function(t,e,n){return n=n!=null?n.concat([t]):null,vd(4194308,4,F2.bind(null,e,t),n)},useLayoutEffect:function(t,e){return vd(4194308,4,t,e)},useInsertionEffect:function(t,e){return vd(4,2,t,e)},useMemo:function(t,e){var n=or();return e=e===void 0?null:e,t=t(),n.memoizedState=[t,e],t},useReducer:function(t,e,n){var s=or();return e=n!==void 0?n(e):e,s.memoizedState=s.baseState=e,t={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:t,lastRenderedState:e},s.queue=t,t=t.dispatch=jF.bind(null,vt,t),[s.memoizedState,t]},useRef:function(t){var e=or();return t={current:t},e.memoizedState=t},useState:yb,useDebugValue:gx,useDeferredValue:function(t){return or().memoizedState=t},useTransition:function(){var t=yb(!1),e=t[0];return t=HF.bind(null,t[1]),or().memoizedState=t,[e,t]},useMutableSource:function(){},useSyncExternalStore:function(t,e,n){var s=vt,r=or();if(gt){if(n===void 0)throw Error(ne(407));n=n()}else{if(n=e(),en===null)throw Error(ne(349));Ii&30||$2(s,e,n)}r.memoizedState=n;var o={value:n,getSnapshot:e};return r.queue=o,wb(T2.bind(null,s,o,t),[t]),s.flags|=2048,Vc(9,N2.bind(null,s,o,n,e),void 0,null),n},useId:function(){var t=or(),e=en.identifierPrefix;if(gt){var n=Or,s=zr;n=(s&~(1<<32-js(s)-1)).toString(32)+n,e=":"+e+"R"+n,n=Lc++,0")&&(l=l.replace("",t.displayName)),l}while(1<=i&&0<=a);break}}}finally{jm=!1,Error.prepareStackTrace=n}return(t=t?t.displayName||t.name:"")?Yl(t):""}function k_(t){switch(t.tag){case 5:return Yl(t.type);case 16:return Yl("Lazy");case 13:return Yl("Suspense");case 19:return Yl("SuspenseList");case 0:case 2:case 15:return t=Km(t.type,!1),t;case 11:return t=Km(t.type.render,!1),t;case 1:return t=Km(t.type,!0),t;default:return""}}function qg(t){if(t==null)return null;if(typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t;switch(t){case ga:return"Fragment";case ma:return"Portal";case jg:return"Profiler";case W1:return"StrictMode";case Kg:return"Suspense";case Xg:return"SuspenseList"}if(typeof t=="object")switch(t.$$typeof){case CS:return(t.displayName||"Context")+".Consumer";case bS:return(t._context.displayName||"Context")+".Provider";case U1:var e=t.render;return t=t.displayName,t||(t=e.displayName||e.name||"",t=t!==""?"ForwardRef("+t+")":"ForwardRef"),t;case G1:return e=t.displayName||null,e!==null?e:qg(t.type)||"Memo";case ro:e=t._payload,t=t._init;try{return qg(t(e))}catch{}}return null}function S_(t){var e=t.type;switch(t.tag){case 24:return"Cache";case 9:return(e.displayName||"Context")+".Consumer";case 10:return(e._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return t=e.render,t=t.displayName||t.name||"",e.displayName||(t!==""?"ForwardRef("+t+")":"ForwardRef");case 7:return"Fragment";case 5:return e;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return qg(e);case 8:return e===W1?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e}return null}function Ro(t){switch(typeof t){case"boolean":case"number":case"string":case"undefined":return t;case"object":return t;default:return""}}function SS(t){var e=t.type;return(t=t.nodeName)&&t.toLowerCase()==="input"&&(e==="checkbox"||e==="radio")}function I_(t){var e=SS(t)?"checked":"value",n=Object.getOwnPropertyDescriptor(t.constructor.prototype,e),s=""+t[e];if(!t.hasOwnProperty(e)&&typeof n<"u"&&typeof n.get=="function"&&typeof n.set=="function"){var r=n.get,o=n.set;return Object.defineProperty(t,e,{configurable:!0,get:function(){return r.call(this)},set:function(i){s=""+i,o.call(this,i)}}),Object.defineProperty(t,e,{enumerable:n.enumerable}),{getValue:function(){return s},setValue:function(i){s=""+i},stopTracking:function(){t._valueTracker=null,delete t[e]}}}}function zh(t){t._valueTracker||(t._valueTracker=I_(t))}function IS(t){if(!t)return!1;var e=t._valueTracker;if(!e)return!0;var n=e.getValue(),s="";return t&&(s=SS(t)?t.checked?"true":"false":t.value),t=s,t!==n?(e.setValue(t),!0):!1}function zd(t){if(t=t||(typeof document<"u"?document:void 0),typeof t>"u")return null;try{return t.activeElement||t.body}catch{return t.body}}function Yg(t,e){var n=e.checked;return bt({},e,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??t._wrapperState.initialChecked})}function Pv(t,e){var n=e.defaultValue==null?"":e.defaultValue,s=e.checked!=null?e.checked:e.defaultChecked;n=Ro(e.value!=null?e.value:n),t._wrapperState={initialChecked:s,initialValue:n,controlled:e.type==="checkbox"||e.type==="radio"?e.checked!=null:e.value!=null}}function $S(t,e){e=e.checked,e!=null&&V1(t,"checked",e,!1)}function Qg(t,e){$S(t,e);var n=Ro(e.value),s=e.type;if(n!=null)s==="number"?(n===0&&t.value===""||t.value!=n)&&(t.value=""+n):t.value!==""+n&&(t.value=""+n);else if(s==="submit"||s==="reset"){t.removeAttribute("value");return}e.hasOwnProperty("value")?Zg(t,e.type,n):e.hasOwnProperty("defaultValue")&&Zg(t,e.type,Ro(e.defaultValue)),e.checked==null&&e.defaultChecked!=null&&(t.defaultChecked=!!e.defaultChecked)}function Lv(t,e,n){if(e.hasOwnProperty("value")||e.hasOwnProperty("defaultValue")){var s=e.type;if(!(s!=="submit"&&s!=="reset"||e.value!==void 0&&e.value!==null))return;e=""+t._wrapperState.initialValue,n||e===t.value||(t.value=e),t.defaultValue=e}n=t.name,n!==""&&(t.name=""),t.defaultChecked=!!t._wrapperState.initialChecked,n!==""&&(t.name=n)}function Zg(t,e,n){(e!=="number"||zd(t.ownerDocument)!==t)&&(n==null?t.defaultValue=""+t._wrapperState.initialValue:t.defaultValue!==""+n&&(t.defaultValue=""+n))}var Ql=Array.isArray;function Ea(t,e,n,s){if(t=t.options,e){e={};for(var r=0;r"+e.valueOf().toString()+"",e=Oh.firstChild;t.firstChild;)t.removeChild(t.firstChild);for(;e.firstChild;)t.appendChild(e.firstChild)}});function Nc(t,e){if(e){var n=t.firstChild;if(n&&n===t.lastChild&&n.nodeType===3){n.nodeValue=e;return}}t.textContent=e}var hc={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},$_=["Webkit","ms","Moz","O"];Object.keys(hc).forEach(function(t){$_.forEach(function(e){e=e+t.charAt(0).toUpperCase()+t.substring(1),hc[e]=hc[t]})});function RS(t,e,n){return e==null||typeof e=="boolean"||e===""?"":n||typeof e!="number"||e===0||hc.hasOwnProperty(t)&&hc[t]?(""+e).trim():e+"px"}function AS(t,e){t=t.style;for(var n in e)if(e.hasOwnProperty(n)){var s=n.indexOf("--")===0,r=RS(n,e[n],s);n==="float"&&(n="cssFloat"),s?t.setProperty(n,r):t[n]=r}}var N_=bt({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function t0(t,e){if(e){if(N_[t]&&(e.children!=null||e.dangerouslySetInnerHTML!=null))throw Error(ne(137,t));if(e.dangerouslySetInnerHTML!=null){if(e.children!=null)throw Error(ne(60));if(typeof e.dangerouslySetInnerHTML!="object"||!("__html"in e.dangerouslySetInnerHTML))throw Error(ne(61))}if(e.style!=null&&typeof e.style!="object")throw Error(ne(62))}}function n0(t,e){if(t.indexOf("-")===-1)return typeof e.is=="string";switch(t){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var s0=null;function H1(t){return t=t.target||t.srcElement||window,t.correspondingUseElement&&(t=t.correspondingUseElement),t.nodeType===3?t.parentNode:t}var r0=null,Ra=null,Aa=null;function Wv(t){if(t=cu(t)){if(typeof r0!="function")throw Error(ne(280));var e=t.stateNode;e&&(e=Yf(e),r0(t.stateNode,t.type,e))}}function DS(t){Ra?Aa?Aa.push(t):Aa=[t]:Ra=t}function _S(){if(Ra){var t=Ra,e=Aa;if(Aa=Ra=null,Wv(t),e)for(t=0;t>>=0,t===0?32:31-(P_(t)/L_|0)|0}var Mh=64,Ph=4194304;function Zl(t){switch(t&-t){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return t&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return t}}function Ld(t,e){var n=t.pendingLanes;if(n===0)return 0;var s=0,r=t.suspendedLanes,o=t.pingedLanes,i=n&268435455;if(i!==0){var a=i&~r;a!==0?s=Zl(a):(o&=i,o!==0&&(s=Zl(o)))}else i=n&~r,i!==0?s=Zl(i):o!==0&&(s=Zl(o));if(s===0)return 0;if(e!==0&&e!==s&&!(e&r)&&(r=s&-s,o=e&-e,r>=o||r===16&&(o&4194240)!==0))return e;if(s&4&&(s|=n&16),e=t.entangledLanes,e!==0)for(t=t.entanglements,e&=s;0n;n++)e.push(t);return e}function au(t,e,n){t.pendingLanes|=e,e!==536870912&&(t.suspendedLanes=0,t.pingedLanes=0),t=t.eventTimes,e=31-js(e),t[e]=n}function U_(t,e){var n=t.pendingLanes&~e;t.pendingLanes=e,t.suspendedLanes=0,t.pingedLanes=0,t.expiredLanes&=e,t.mutableReadLanes&=e,t.entangledLanes&=e,e=t.entanglements;var s=t.eventTimes;for(t=t.expirationTimes;0=fc),Qv=" ",Zv=!1;function JS(t,e){switch(t){case"keyup":return xF.indexOf(e.keyCode)!==-1;case"keydown":return e.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function e2(t){return t=t.detail,typeof t=="object"&&"data"in t?t.data:null}var xa=!1;function wF(t,e){switch(t){case"compositionend":return e2(e);case"keypress":return e.which!==32?null:(Zv=!0,Qv);case"textInput":return t=e.data,t===Qv&&Zv?null:t;default:return null}}function vF(t,e){if(xa)return t==="compositionend"||!J1&&JS(t,e)?(t=QS(),md=Y1=co=null,xa=!1,t):null;switch(t){case"paste":return null;case"keypress":if(!(e.ctrlKey||e.altKey||e.metaKey)||e.ctrlKey&&e.altKey){if(e.char&&1=e)return{node:n,offset:e-t};t=s}e:{for(;n;){if(n.nextSibling){n=n.nextSibling;break e}n=n.parentNode}n=void 0}n=nb(n)}}function r2(t,e){return t&&e?t===e?!0:t&&t.nodeType===3?!1:e&&e.nodeType===3?r2(t,e.parentNode):"contains"in t?t.contains(e):t.compareDocumentPosition?!!(t.compareDocumentPosition(e)&16):!1:!1}function o2(){for(var t=window,e=zd();e instanceof t.HTMLIFrameElement;){try{var n=typeof e.contentWindow.location.href=="string"}catch{n=!1}if(n)t=e.contentWindow;else break;e=zd(t.document)}return e}function ex(t){var e=t&&t.nodeName&&t.nodeName.toLowerCase();return e&&(e==="input"&&(t.type==="text"||t.type==="search"||t.type==="tel"||t.type==="url"||t.type==="password")||e==="textarea"||t.contentEditable==="true")}function EF(t){var e=o2(),n=t.focusedElem,s=t.selectionRange;if(e!==n&&n&&n.ownerDocument&&r2(n.ownerDocument.documentElement,n)){if(s!==null&&ex(n)){if(e=s.start,t=s.end,t===void 0&&(t=e),"selectionStart"in n)n.selectionStart=e,n.selectionEnd=Math.min(t,n.value.length);else if(t=(e=n.ownerDocument||document)&&e.defaultView||window,t.getSelection){t=t.getSelection();var r=n.textContent.length,o=Math.min(s.start,r);s=s.end===void 0?o:Math.min(s.end,r),!t.extend&&o>s&&(r=s,s=o,o=r),r=sb(n,o);var i=sb(n,s);r&&i&&(t.rangeCount!==1||t.anchorNode!==r.node||t.anchorOffset!==r.offset||t.focusNode!==i.node||t.focusOffset!==i.offset)&&(e=e.createRange(),e.setStart(r.node,r.offset),t.removeAllRanges(),o>s?(t.addRange(e),t.extend(i.node,i.offset)):(e.setEnd(i.node,i.offset),t.addRange(e)))}}for(e=[],t=n;t=t.parentNode;)t.nodeType===1&&e.push({element:t,left:t.scrollLeft,top:t.scrollTop});for(typeof n.focus=="function"&&n.focus(),n=0;n=document.documentMode,ya=null,u0=null,mc=null,h0=!1;function rb(t,e,n){var s=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;h0||ya==null||ya!==zd(s)||(s=ya,"selectionStart"in s&&ex(s)?s={start:s.selectionStart,end:s.selectionEnd}:(s=(s.ownerDocument&&s.ownerDocument.defaultView||window).getSelection(),s={anchorNode:s.anchorNode,anchorOffset:s.anchorOffset,focusNode:s.focusNode,focusOffset:s.focusOffset}),mc&&_c(mc,s)||(mc=s,s=Wd(u0,"onSelect"),0ba||(t.current=x0[ba],x0[ba]=null,ba--)}function rt(t,e){ba++,x0[ba]=t.current,t.current=e}var Ao={},kn=Lo(Ao),Hn=Lo(!1),ki=Ao;function Ua(t,e){var n=t.type.contextTypes;if(!n)return Ao;var s=t.stateNode;if(s&&s.__reactInternalMemoizedUnmaskedChildContext===e)return s.__reactInternalMemoizedMaskedChildContext;var r={},o;for(o in n)r[o]=e[o];return s&&(t=t.stateNode,t.__reactInternalMemoizedUnmaskedChildContext=e,t.__reactInternalMemoizedMaskedChildContext=r),r}function jn(t){return t=t.childContextTypes,t!=null}function Gd(){dt(Hn),dt(kn)}function hb(t,e,n){if(kn.current!==Ao)throw Error(ne(168));rt(kn,e),rt(Hn,n)}function p2(t,e,n){var s=t.stateNode;if(e=e.childContextTypes,typeof s.getChildContext!="function")return n;s=s.getChildContext();for(var r in s)if(!(r in e))throw Error(ne(108,S_(t)||"Unknown",r));return bt({},n,s)}function Hd(t){return t=(t=t.stateNode)&&t.__reactInternalMemoizedMergedChildContext||Ao,ki=kn.current,rt(kn,t),rt(Hn,Hn.current),!0}function db(t,e,n){var s=t.stateNode;if(!s)throw Error(ne(169));n?(t=p2(t,e,ki),s.__reactInternalMemoizedMergedChildContext=t,dt(Hn),dt(kn),rt(kn,t)):dt(Hn),rt(Hn,n)}var Dr=null,Qf=!1,ag=!1;function m2(t){Dr===null?Dr=[t]:Dr.push(t)}function VF(t){Qf=!0,m2(t)}function Bo(){if(!ag&&Dr!==null){ag=!0;var t=0,e=Ye;try{var n=Dr;for(Ye=1;t>=i,r-=i,zr=1<<32-js(e)+r|n<S?($=k,k=null):$=k.sibling;var N=d(m,k,w[S],v);if(N===null){k===null&&(k=$);break}t&&k&&N.alternate===null&&e(m,k),y=o(N,y,S),C===null?b=N:C.sibling=N,C=N,k=$}if(S===w.length)return n(m,k),gt&&ni(m,S),b;if(k===null){for(;SS?($=k,k=null):$=k.sibling;var A=d(m,k,N.value,v);if(A===null){k===null&&(k=$);break}t&&k&&A.alternate===null&&e(m,k),y=o(A,y,S),C===null?b=A:C.sibling=A,C=A,k=$}if(N.done)return n(m,k),gt&&ni(m,S),b;if(k===null){for(;!N.done;S++,N=w.next())N=h(m,N.value,v),N!==null&&(y=o(N,y,S),C===null?b=N:C.sibling=N,C=N);return gt&&ni(m,S),b}for(k=s(m,k);!N.done;S++,N=w.next())N=f(k,m,S,N.value,v),N!==null&&(t&&N.alternate!==null&&k.delete(N.key===null?S:N.key),y=o(N,y,S),C===null?b=N:C.sibling=N,C=N);return t&&k.forEach(function(M){return e(m,M)}),gt&&ni(m,S),b}function x(m,y,w,v){if(typeof w=="object"&&w!==null&&w.type===ga&&w.key===null&&(w=w.props.children),typeof w=="object"&&w!==null){switch(w.$$typeof){case Fh:e:{for(var b=w.key,C=y;C!==null;){if(C.key===b){if(b=w.type,b===ga){if(C.tag===7){n(m,C.sibling),y=r(C,w.props.children),y.return=m,m=y;break e}}else if(C.elementType===b||typeof b=="object"&&b!==null&&b.$$typeof===ro&&mb(b)===C.type){n(m,C.sibling),y=r(C,w.props),y.ref=Vl(m,C,w),y.return=m,m=y;break e}n(m,C);break}else e(m,C);C=C.sibling}w.type===ga?(y=gi(w.props.children,m.mode,v,w.key),y.return=m,m=y):(v=kd(w.type,w.key,w.props,null,m.mode,v),v.ref=Vl(m,y,w),v.return=m,m=v)}return i(m);case ma:e:{for(C=w.key;y!==null;){if(y.key===C)if(y.tag===4&&y.stateNode.containerInfo===w.containerInfo&&y.stateNode.implementation===w.implementation){n(m,y.sibling),y=r(y,w.children||[]),y.return=m,m=y;break e}else{n(m,y);break}else e(m,y);y=y.sibling}y=mg(w,m.mode,v),y.return=m,m=y}return i(m);case ro:return C=w._init,x(m,y,C(w._payload),v)}if(Ql(w))return p(m,y,w,v);if(Ol(w))return g(m,y,w,v);Hh(m,w)}return typeof w=="string"&&w!==""||typeof w=="number"?(w=""+w,y!==null&&y.tag===6?(n(m,y.sibling),y=r(y,w),y.return=m,m=y):(n(m,y),y=pg(w,m.mode,v),y.return=m,m=y),i(m)):n(m,y)}return x}var Ha=w2(!0),v2=w2(!1),Xd=Lo(null),qd=null,Sa=null,rx=null;function ox(){rx=Sa=qd=null}function ix(t){var e=Xd.current;dt(Xd),t._currentValue=e}function v0(t,e,n){for(;t!==null;){var s=t.alternate;if((t.childLanes&e)!==e?(t.childLanes|=e,s!==null&&(s.childLanes|=e)):s!==null&&(s.childLanes&e)!==e&&(s.childLanes|=e),t===n)break;t=t.return}}function _a(t,e){qd=t,rx=Sa=null,t=t.dependencies,t!==null&&t.firstContext!==null&&(t.lanes&e&&(Wn=!0),t.firstContext=null)}function $s(t){var e=t._currentValue;if(rx!==t)if(t={context:t,memoizedValue:e,next:null},Sa===null){if(qd===null)throw Error(ne(308));Sa=t,qd.dependencies={lanes:0,firstContext:t}}else Sa=Sa.next=t;return e}var ci=null;function ax(t){ci===null?ci=[t]:ci.push(t)}function b2(t,e,n,s){var r=e.interleaved;return r===null?(n.next=n,ax(e)):(n.next=r.next,r.next=n),e.interleaved=n,Vr(t,s)}function Vr(t,e){t.lanes|=e;var n=t.alternate;for(n!==null&&(n.lanes|=e),n=t,t=t.return;t!==null;)t.childLanes|=e,n=t.alternate,n!==null&&(n.childLanes|=e),n=t,t=t.return;return n.tag===3?n.stateNode:null}var oo=!1;function lx(t){t.updateQueue={baseState:t.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function C2(t,e){t=t.updateQueue,e.updateQueue===t&&(e.updateQueue={baseState:t.baseState,firstBaseUpdate:t.firstBaseUpdate,lastBaseUpdate:t.lastBaseUpdate,shared:t.shared,effects:t.effects})}function Pr(t,e){return{eventTime:t,lane:e,tag:0,payload:null,callback:null,next:null}}function wo(t,e,n){var s=t.updateQueue;if(s===null)return null;if(s=s.shared,Le&2){var r=s.pending;return r===null?e.next=e:(e.next=r.next,r.next=e),s.pending=e,Vr(t,n)}return r=s.interleaved,r===null?(e.next=e,ax(s)):(e.next=r.next,r.next=e),s.interleaved=e,Vr(t,n)}function xd(t,e,n){if(e=e.updateQueue,e!==null&&(e=e.shared,(n&4194240)!==0)){var s=e.lanes;s&=t.pendingLanes,n|=s,e.lanes=n,K1(t,n)}}function gb(t,e){var n=t.updateQueue,s=t.alternate;if(s!==null&&(s=s.updateQueue,n===s)){var r=null,o=null;if(n=n.firstBaseUpdate,n!==null){do{var i={eventTime:n.eventTime,lane:n.lane,tag:n.tag,payload:n.payload,callback:n.callback,next:null};o===null?r=o=i:o=o.next=i,n=n.next}while(n!==null);o===null?r=o=e:o=o.next=e}else r=o=e;n={baseState:s.baseState,firstBaseUpdate:r,lastBaseUpdate:o,shared:s.shared,effects:s.effects},t.updateQueue=n;return}t=n.lastBaseUpdate,t===null?n.firstBaseUpdate=e:t.next=e,n.lastBaseUpdate=e}function Yd(t,e,n,s){var r=t.updateQueue;oo=!1;var o=r.firstBaseUpdate,i=r.lastBaseUpdate,a=r.shared.pending;if(a!==null){r.shared.pending=null;var l=a,c=l.next;l.next=null,i===null?o=c:i.next=c,i=l;var u=t.alternate;u!==null&&(u=u.updateQueue,a=u.lastBaseUpdate,a!==i&&(a===null?u.firstBaseUpdate=c:a.next=c,u.lastBaseUpdate=l))}if(o!==null){var h=r.baseState;i=0,u=c=l=null,a=o;do{var d=a.lane,f=a.eventTime;if((s&d)===d){u!==null&&(u=u.next={eventTime:f,lane:0,tag:a.tag,payload:a.payload,callback:a.callback,next:null});e:{var p=t,g=a;switch(d=e,f=n,g.tag){case 1:if(p=g.payload,typeof p=="function"){h=p.call(f,h,d);break e}h=p;break e;case 3:p.flags=p.flags&-65537|128;case 0:if(p=g.payload,d=typeof p=="function"?p.call(f,h,d):p,d==null)break e;h=bt({},h,d);break e;case 2:oo=!0}}a.callback!==null&&a.lane!==0&&(t.flags|=64,d=r.effects,d===null?r.effects=[a]:d.push(a))}else f={eventTime:f,lane:d,tag:a.tag,payload:a.payload,callback:a.callback,next:null},u===null?(c=u=f,l=h):u=u.next=f,i|=d;if(a=a.next,a===null){if(a=r.shared.pending,a===null)break;d=a,a=d.next,d.next=null,r.lastBaseUpdate=d,r.shared.pending=null}}while(!0);if(u===null&&(l=h),r.baseState=l,r.firstBaseUpdate=c,r.lastBaseUpdate=u,e=r.shared.interleaved,e!==null){r=e;do i|=r.lane,r=r.next;while(r!==e)}else o===null&&(r.shared.lanes=0);$i|=i,t.lanes=i,t.memoizedState=h}}function xb(t,e,n){if(t=e.effects,e.effects=null,t!==null)for(e=0;en?n:4,t(!0);var s=cg.transition;cg.transition={};try{t(!1),e()}finally{Ye=n,cg.transition=s}}function L2(){return Ns().memoizedState}function HF(t,e,n){var s=bo(t);if(n={lane:s,action:n,hasEagerState:!1,eagerState:null,next:null},B2(t))V2(e,n);else if(n=b2(t,e,n,s),n!==null){var r=An();Ks(n,t,s,r),W2(n,e,s)}}function jF(t,e,n){var s=bo(t),r={lane:s,action:n,hasEagerState:!1,eagerState:null,next:null};if(B2(t))V2(e,r);else{var o=t.alternate;if(t.lanes===0&&(o===null||o.lanes===0)&&(o=e.lastRenderedReducer,o!==null))try{var i=e.lastRenderedState,a=o(i,n);if(r.hasEagerState=!0,r.eagerState=a,Zs(a,i)){var l=e.interleaved;l===null?(r.next=r,ax(e)):(r.next=l.next,l.next=r),e.interleaved=r;return}}catch{}finally{}n=b2(t,e,r,s),n!==null&&(r=An(),Ks(n,t,s,r),W2(n,e,s))}}function B2(t){var e=t.alternate;return t===vt||e!==null&&e===vt}function V2(t,e){gc=Zd=!0;var n=t.pending;n===null?e.next=e:(e.next=n.next,n.next=e),t.pending=e}function W2(t,e,n){if(n&4194240){var s=e.lanes;s&=t.pendingLanes,n|=s,e.lanes=n,K1(t,n)}}var Jd={readContext:$s,useCallback:mn,useContext:mn,useEffect:mn,useImperativeHandle:mn,useInsertionEffect:mn,useLayoutEffect:mn,useMemo:mn,useReducer:mn,useRef:mn,useState:mn,useDebugValue:mn,useDeferredValue:mn,useTransition:mn,useMutableSource:mn,useSyncExternalStore:mn,useId:mn,unstable_isNewReconciler:!1},KF={readContext:$s,useCallback:function(t,e){return or().memoizedState=[t,e===void 0?null:e],t},useContext:$s,useEffect:wb,useImperativeHandle:function(t,e,n){return n=n!=null?n.concat([t]):null,wd(4194308,4,F2.bind(null,e,t),n)},useLayoutEffect:function(t,e){return wd(4194308,4,t,e)},useInsertionEffect:function(t,e){return wd(4,2,t,e)},useMemo:function(t,e){var n=or();return e=e===void 0?null:e,t=t(),n.memoizedState=[t,e],t},useReducer:function(t,e,n){var s=or();return e=n!==void 0?n(e):e,s.memoizedState=s.baseState=e,t={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:t,lastRenderedState:e},s.queue=t,t=t.dispatch=HF.bind(null,vt,t),[s.memoizedState,t]},useRef:function(t){var e=or();return t={current:t},e.memoizedState=t},useState:yb,useDebugValue:gx,useDeferredValue:function(t){return or().memoizedState=t},useTransition:function(){var t=yb(!1),e=t[0];return t=GF.bind(null,t[1]),or().memoizedState=t,[e,t]},useMutableSource:function(){},useSyncExternalStore:function(t,e,n){var s=vt,r=or();if(gt){if(n===void 0)throw Error(ne(407));n=n()}else{if(n=e(),en===null)throw Error(ne(349));Ii&30||$2(s,e,n)}r.memoizedState=n;var o={value:n,getSnapshot:e};return r.queue=o,wb(T2.bind(null,s,o,t),[t]),s.flags|=2048,Vc(9,N2.bind(null,s,o,n,e),void 0,null),n},useId:function(){var t=or(),e=en.identifierPrefix;if(gt){var n=Or,s=zr;n=(s&~(1<<32-js(s)-1)).toString(32)+n,e=":"+e+"R"+n,n=Lc++,0<\/script>",t=t.removeChild(t.firstChild)):typeof s.is=="string"?t=i.createElement(n,{is:s.is}):(t=i.createElement(n),n==="select"&&(i=t,s.multiple?i.multiple=!0:s.size&&(i.size=s.size))):t=i.createElementNS(t,n),t[fr]=e,t[Oc]=s,Z2(t,e,!1,!1),e.stateNode=t;e:{switch(i=n0(n,s),n){case"dialog":ct("cancel",t),ct("close",t),r=s;break;case"iframe":case"object":case"embed":ct("load",t),r=s;break;case"video":case"audio":for(r=0;rXa&&(e.flags|=128,s=!0,Wl(o,!1),e.lanes=4194304)}else{if(!s)if(t=Zd(i),t!==null){if(e.flags|=128,s=!0,n=t.updateQueue,n!==null&&(e.updateQueue=n,e.flags|=4),Wl(o,!0),o.tail===null&&o.tailMode==="hidden"&&!i.alternate&&!gt)return gn(e),null}else 2*Et()-o.renderingStartTime>Xa&&n!==1073741824&&(e.flags|=128,s=!0,Wl(o,!1),e.lanes=4194304);o.isBackwards?(i.sibling=e.child,e.child=i):(n=o.last,n!==null?n.sibling=i:e.child=i,o.last=i)}return o.tail!==null?(e=o.tail,o.rendering=e,o.tail=e.sibling,o.renderingStartTime=Et(),e.sibling=null,n=wt.current,rt(wt,s?n&1|2:n&1),e):(gn(e),null);case 22:case 23:return Cx(),s=e.memoizedState!==null,t!==null&&t.memoizedState!==null!==s&&(e.flags|=8192),s&&e.mode&1?Jn&1073741824&&(gn(e),e.subtreeFlags&6&&(e.flags|=8192)):gn(e),null;case 24:return null;case 25:return null}throw Error(ne(156,e.tag))}function nz(t,e){switch(nx(e),e.tag){case 1:return jn(e.type)&&Hd(),t=e.flags,t&65536?(e.flags=t&-65537|128,e):null;case 3:return ja(),dt(Hn),dt(kn),hx(),t=e.flags,t&65536&&!(t&128)?(e.flags=t&-65537|128,e):null;case 5:return ux(e),null;case 13:if(dt(wt),t=e.memoizedState,t!==null&&t.dehydrated!==null){if(e.alternate===null)throw Error(ne(340));Ga()}return t=e.flags,t&65536?(e.flags=t&-65537|128,e):null;case 19:return dt(wt),null;case 4:return ja(),null;case 10:return ix(e.type._context),null;case 22:case 23:return Cx(),null;case 24:return null;default:return null}}var Xh=!1,yn=!1,sz=typeof WeakSet=="function"?WeakSet:Set,he=null;function Ia(t,e){var n=t.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(s){Ct(t,e,s)}else n.current=null}function E0(t,e,n){try{n()}catch(s){Ct(t,e,s)}}var Rb=!1;function rz(t,e){if(d0=Vd,t=o2(),ex(t)){if("selectionStart"in t)var n={start:t.selectionStart,end:t.selectionEnd};else e:{n=(n=t.ownerDocument)&&n.defaultView||window;var s=n.getSelection&&n.getSelection();if(s&&s.rangeCount!==0){n=s.anchorNode;var r=s.anchorOffset,o=s.focusNode;s=s.focusOffset;try{n.nodeType,o.nodeType}catch{n=null;break e}var i=0,a=-1,l=-1,c=0,u=0,h=t,d=null;t:for(;;){for(var f;h!==n||r!==0&&h.nodeType!==3||(a=i+r),h!==o||s!==0&&h.nodeType!==3||(l=i+s),h.nodeType===3&&(i+=h.nodeValue.length),(f=h.firstChild)!==null;)d=h,h=f;for(;;){if(h===t)break t;if(d===n&&++c===r&&(a=i),d===o&&++u===s&&(l=i),(f=h.nextSibling)!==null)break;h=d,d=h.parentNode}h=f}n=a===-1||l===-1?null:{start:a,end:l}}else n=null}n=n||{start:0,end:0}}else n=null;for(f0={focusedElem:t,selectionRange:n},Vd=!1,he=e;he!==null;)if(e=he,t=e.child,(e.subtreeFlags&1028)!==0&&t!==null)t.return=e,he=t;else for(;he!==null;){e=he;try{var p=e.alternate;if(e.flags&1024)switch(e.tag){case 0:case 11:case 15:break;case 1:if(p!==null){var g=p.memoizedProps,x=p.memoizedState,m=e.stateNode,y=m.getSnapshotBeforeUpdate(e.elementType===e.type?g:Ls(e.type,g),x);m.__reactInternalSnapshotBeforeUpdate=y}break;case 3:var w=e.stateNode.containerInfo;w.nodeType===1?w.textContent="":w.nodeType===9&&w.documentElement&&w.removeChild(w.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(ne(163))}}catch(v){Ct(e,e.return,v)}if(t=e.sibling,t!==null){t.return=e.return,he=t;break}he=e.return}return p=Rb,Rb=!1,p}function xc(t,e,n){var s=e.updateQueue;if(s=s!==null?s.lastEffect:null,s!==null){var r=s=s.next;do{if((r.tag&t)===t){var o=r.destroy;r.destroy=void 0,o!==void 0&&E0(e,n,o)}r=r.next}while(r!==s)}}function tp(t,e){if(e=e.updateQueue,e=e!==null?e.lastEffect:null,e!==null){var n=e=e.next;do{if((n.tag&t)===t){var s=n.create;n.destroy=s()}n=n.next}while(n!==e)}}function R0(t){var e=t.ref;if(e!==null){var n=t.stateNode;switch(t.tag){case 5:t=n;break;default:t=n}typeof e=="function"?e(t):e.current=t}}function tI(t){var e=t.alternate;e!==null&&(t.alternate=null,tI(e)),t.child=null,t.deletions=null,t.sibling=null,t.tag===5&&(e=t.stateNode,e!==null&&(delete e[fr],delete e[Oc],delete e[g0],delete e[BF],delete e[VF])),t.stateNode=null,t.return=null,t.dependencies=null,t.memoizedProps=null,t.memoizedState=null,t.pendingProps=null,t.stateNode=null,t.updateQueue=null}function nI(t){return t.tag===5||t.tag===3||t.tag===4}function Ab(t){e:for(;;){for(;t.sibling===null;){if(t.return===null||nI(t.return))return null;t=t.return}for(t.sibling.return=t.return,t=t.sibling;t.tag!==5&&t.tag!==6&&t.tag!==18;){if(t.flags&2||t.child===null||t.tag===4)continue e;t.child.return=t,t=t.child}if(!(t.flags&2))return t.stateNode}}function A0(t,e,n){var s=t.tag;if(s===5||s===6)t=t.stateNode,e?n.nodeType===8?n.parentNode.insertBefore(t,e):n.insertBefore(t,e):(n.nodeType===8?(e=n.parentNode,e.insertBefore(t,n)):(e=n,e.appendChild(t)),n=n._reactRootContainer,n!=null||e.onclick!==null||(e.onclick=Gd));else if(s!==4&&(t=t.child,t!==null))for(A0(t,e,n),t=t.sibling;t!==null;)A0(t,e,n),t=t.sibling}function D0(t,e,n){var s=t.tag;if(s===5||s===6)t=t.stateNode,e?n.insertBefore(t,e):n.appendChild(t);else if(s!==4&&(t=t.child,t!==null))for(D0(t,e,n),t=t.sibling;t!==null;)D0(t,e,n),t=t.sibling}var on=null,Bs=!1;function no(t,e,n){for(n=n.child;n!==null;)sI(t,e,n),n=n.sibling}function sI(t,e,n){if(mr&&typeof mr.onCommitFiberUnmount=="function")try{mr.onCommitFiberUnmount(Kf,n)}catch{}switch(n.tag){case 5:yn||Ia(n,e);case 6:var s=on,r=Bs;on=null,no(t,e,n),on=s,Bs=r,on!==null&&(Bs?(t=on,n=n.stateNode,t.nodeType===8?t.parentNode.removeChild(n):t.removeChild(n)):on.removeChild(n.stateNode));break;case 18:on!==null&&(Bs?(t=on,n=n.stateNode,t.nodeType===8?ig(t.parentNode,n):t.nodeType===1&&ig(t,n),Ac(t)):ig(on,n.stateNode));break;case 4:s=on,r=Bs,on=n.stateNode.containerInfo,Bs=!0,no(t,e,n),on=s,Bs=r;break;case 0:case 11:case 14:case 15:if(!yn&&(s=n.updateQueue,s!==null&&(s=s.lastEffect,s!==null))){r=s=s.next;do{var o=r,i=o.destroy;o=o.tag,i!==void 0&&(o&2||o&4)&&E0(n,e,i),r=r.next}while(r!==s)}no(t,e,n);break;case 1:if(!yn&&(Ia(n,e),s=n.stateNode,typeof s.componentWillUnmount=="function"))try{s.props=n.memoizedProps,s.state=n.memoizedState,s.componentWillUnmount()}catch(a){Ct(n,e,a)}no(t,e,n);break;case 21:no(t,e,n);break;case 22:n.mode&1?(yn=(s=yn)||n.memoizedState!==null,no(t,e,n),yn=s):no(t,e,n);break;default:no(t,e,n)}}function Db(t){var e=t.updateQueue;if(e!==null){t.updateQueue=null;var n=t.stateNode;n===null&&(n=t.stateNode=new sz),e.forEach(function(s){var r=fz.bind(null,t,s);n.has(s)||(n.add(s),s.then(r,r))})}}function Os(t,e){var n=e.deletions;if(n!==null)for(var s=0;sr&&(r=i),s&=~o}if(s=r,s=Et()-s,s=(120>s?120:480>s?480:1080>s?1080:1920>s?1920:3e3>s?3e3:4320>s?4320:1960*iz(s/1960))-s,10t?16:t,uo===null)var s=!1;else{if(t=uo,uo=null,sf=0,Le&6)throw Error(ne(331));var r=Le;for(Le|=4,he=t.current;he!==null;){var o=he,i=o.child;if(he.flags&16){var a=o.deletions;if(a!==null){for(var l=0;lEt()-vx?mi(t,0):wx|=n),Kn(t,e)}function hI(t,e){e===0&&(t.mode&1?(e=Lh,Lh<<=1,!(Lh&130023424)&&(Lh=4194304)):e=1);var n=An();t=Vr(t,e),t!==null&&(au(t,e,n),Kn(t,n))}function dz(t){var e=t.memoizedState,n=0;e!==null&&(n=e.retryLane),hI(t,n)}function fz(t,e){var n=0;switch(t.tag){case 13:var s=t.stateNode,r=t.memoizedState;r!==null&&(n=r.retryLane);break;case 19:s=t.stateNode;break;default:throw Error(ne(314))}s!==null&&s.delete(e),hI(t,n)}var dI;dI=function(t,e,n){if(t!==null)if(t.memoizedProps!==e.pendingProps||Hn.current)Wn=!0;else{if(!(t.lanes&n)&&!(e.flags&128))return Wn=!1,ez(t,e,n);Wn=!!(t.flags&131072)}else Wn=!1,gt&&e.flags&1048576&&g2(e,Xd,e.index);switch(e.lanes=0,e.tag){case 2:var s=e.type;bd(t,e),t=e.pendingProps;var r=Ua(e,kn.current);_a(e,n),r=fx(null,e,s,t,r,n);var o=px();return e.flags|=1,typeof r=="object"&&r!==null&&typeof r.render=="function"&&r.$$typeof===void 0?(e.tag=1,e.memoizedState=null,e.updateQueue=null,jn(s)?(o=!0,jd(e)):o=!1,e.memoizedState=r.state!==null&&r.state!==void 0?r.state:null,lx(e),r.updater=ep,e.stateNode=r,r._reactInternals=e,C0(e,s,t,n),e=I0(null,e,s,!0,o,n)):(e.tag=0,gt&&o&&tx(e),Nn(null,e,r,n),e=e.child),e;case 16:s=e.elementType;e:{switch(bd(t,e),t=e.pendingProps,r=s._init,s=r(s._payload),e.type=s,r=e.tag=mz(s),t=Ls(s,t),r){case 0:e=S0(null,e,s,t,n);break e;case 1:e=Nb(null,e,s,t,n);break e;case 11:e=Ib(null,e,s,t,n);break e;case 14:e=$b(null,e,s,Ls(s.type,t),n);break e}throw Error(ne(306,s,""))}return e;case 0:return s=e.type,r=e.pendingProps,r=e.elementType===s?r:Ls(s,r),S0(t,e,s,r,n);case 1:return s=e.type,r=e.pendingProps,r=e.elementType===s?r:Ls(s,r),Nb(t,e,s,r,n);case 3:e:{if(q2(e),t===null)throw Error(ne(387));s=e.pendingProps,o=e.memoizedState,r=o.element,C2(t,e),Qd(e,s,null,n);var i=e.memoizedState;if(s=i.element,o.isDehydrated)if(o={element:s,isDehydrated:!1,cache:i.cache,pendingSuspenseBoundaries:i.pendingSuspenseBoundaries,transitions:i.transitions},e.updateQueue.baseState=o,e.memoizedState=o,e.flags&256){r=Ka(Error(ne(423)),e),e=Tb(t,e,s,n,r);break e}else if(s!==r){r=Ka(Error(ne(424)),e),e=Tb(t,e,s,n,r);break e}else for(ts=yo(e.stateNode.containerInfo.firstChild),ss=e,gt=!0,Vs=null,n=v2(e,null,s,n),e.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(Ga(),s===r){e=Wr(t,e,n);break e}Nn(t,e,s,n)}e=e.child}return e;case 5:return k2(e),t===null&&w0(e),s=e.type,r=e.pendingProps,o=t!==null?t.memoizedProps:null,i=r.children,p0(s,r)?i=null:o!==null&&p0(s,o)&&(e.flags|=32),X2(t,e),Nn(t,e,i,n),e.child;case 6:return t===null&&w0(e),null;case 13:return Y2(t,e,n);case 4:return cx(e,e.stateNode.containerInfo),s=e.pendingProps,t===null?e.child=Ha(e,null,s,n):Nn(t,e,s,n),e.child;case 11:return s=e.type,r=e.pendingProps,r=e.elementType===s?r:Ls(s,r),Ib(t,e,s,r,n);case 7:return Nn(t,e,e.pendingProps,n),e.child;case 8:return Nn(t,e,e.pendingProps.children,n),e.child;case 12:return Nn(t,e,e.pendingProps.children,n),e.child;case 10:e:{if(s=e.type._context,r=e.pendingProps,o=e.memoizedProps,i=r.value,rt(qd,s._currentValue),s._currentValue=i,o!==null)if(Zs(o.value,i)){if(o.children===r.children&&!Hn.current){e=Wr(t,e,n);break e}}else for(o=e.child,o!==null&&(o.return=e);o!==null;){var a=o.dependencies;if(a!==null){i=o.child;for(var l=a.firstContext;l!==null;){if(l.context===s){if(o.tag===1){l=Pr(-1,n&-n),l.tag=2;var c=o.updateQueue;if(c!==null){c=c.shared;var u=c.pending;u===null?l.next=l:(l.next=u.next,u.next=l),c.pending=l}}o.lanes|=n,l=o.alternate,l!==null&&(l.lanes|=n),v0(o.return,n,e),a.lanes|=n;break}l=l.next}}else if(o.tag===10)i=o.type===e.type?null:o.child;else if(o.tag===18){if(i=o.return,i===null)throw Error(ne(341));i.lanes|=n,a=i.alternate,a!==null&&(a.lanes|=n),v0(i,n,e),i=o.sibling}else i=o.child;if(i!==null)i.return=o;else for(i=o;i!==null;){if(i===e){i=null;break}if(o=i.sibling,o!==null){o.return=i.return,i=o;break}i=i.return}o=i}Nn(t,e,r.children,n),e=e.child}return e;case 9:return r=e.type,s=e.pendingProps.children,_a(e,n),r=$s(r),s=s(r),e.flags|=1,Nn(t,e,s,n),e.child;case 14:return s=e.type,r=Ls(s,e.pendingProps),r=Ls(s.type,r),$b(t,e,s,r,n);case 15:return j2(t,e,e.type,e.pendingProps,n);case 17:return s=e.type,r=e.pendingProps,r=e.elementType===s?r:Ls(s,r),bd(t,e),e.tag=1,jn(s)?(t=!0,jd(e)):t=!1,_a(e,n),U2(e,s,r),C0(e,s,r,n),I0(null,e,s,!0,t,n);case 19:return Q2(t,e,n);case 22:return K2(t,e,n)}throw Error(ne(156,e.tag))};function fI(t,e){return BS(t,e)}function pz(t,e,n,s){this.tag=t,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=e,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=s,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function ys(t,e,n,s){return new pz(t,e,n,s)}function Sx(t){return t=t.prototype,!(!t||!t.isReactComponent)}function mz(t){if(typeof t=="function")return Sx(t)?1:0;if(t!=null){if(t=t.$$typeof,t===U1)return 11;if(t===G1)return 14}return 2}function Co(t,e){var n=t.alternate;return n===null?(n=ys(t.tag,e,t.key,t.mode),n.elementType=t.elementType,n.type=t.type,n.stateNode=t.stateNode,n.alternate=t,t.alternate=n):(n.pendingProps=e,n.type=t.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=t.flags&14680064,n.childLanes=t.childLanes,n.lanes=t.lanes,n.child=t.child,n.memoizedProps=t.memoizedProps,n.memoizedState=t.memoizedState,n.updateQueue=t.updateQueue,e=t.dependencies,n.dependencies=e===null?null:{lanes:e.lanes,firstContext:e.firstContext},n.sibling=t.sibling,n.index=t.index,n.ref=t.ref,n}function Sd(t,e,n,s,r,o){var i=2;if(s=t,typeof t=="function")Sx(t)&&(i=1);else if(typeof t=="string")i=5;else e:switch(t){case ga:return gi(n.children,r,o,e);case W1:i=8,r|=8;break;case jg:return t=ys(12,n,e,r|2),t.elementType=jg,t.lanes=o,t;case Kg:return t=ys(13,n,e,r),t.elementType=Kg,t.lanes=o,t;case Xg:return t=ys(19,n,e,r),t.elementType=Xg,t.lanes=o,t;case kS:return sp(n,r,o,e);default:if(typeof t=="object"&&t!==null)switch(t.$$typeof){case bS:i=10;break e;case CS:i=9;break e;case U1:i=11;break e;case G1:i=14;break e;case ro:i=16,s=null;break e}throw Error(ne(130,t==null?t:typeof t,""))}return e=ys(i,n,e,r),e.elementType=t,e.type=s,e.lanes=o,e}function gi(t,e,n,s){return t=ys(7,t,s,e),t.lanes=n,t}function sp(t,e,n,s){return t=ys(22,t,s,e),t.elementType=kS,t.lanes=n,t.stateNode={isHidden:!1},t}function pg(t,e,n){return t=ys(6,t,null,e),t.lanes=n,t}function mg(t,e,n){return e=ys(4,t.children!==null?t.children:[],t.key,e),e.lanes=n,e.stateNode={containerInfo:t.containerInfo,pendingChildren:null,implementation:t.implementation},e}function gz(t,e,n,s,r){this.tag=e,this.containerInfo=t,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=qm(0),this.expirationTimes=qm(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=qm(0),this.identifierPrefix=s,this.onRecoverableError=r,this.mutableSourceEagerHydrationData=null}function Ix(t,e,n,s,r,o,i,a,l){return t=new gz(t,e,n,a,l),e===1?(e=1,o===!0&&(e|=8)):e=0,o=ys(3,null,null,e),t.current=o,o.stateNode=t,o.memoizedState={element:s,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},lx(o),t}function xz(t,e,n){var s=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(xI)}catch(t){console.error(t)}}xI(),xS.exports=ls;var Cz=xS.exports,Bb=Cz;Gg.createRoot=Bb.createRoot,Gg.hydrateRoot=Bb.hydrateRoot;var bn=function(){return bn=Object.assign||function(e){for(var n,s=1,r=arguments.length;s0?Zt(yl,--Ts):0,Ya--,Ft===10&&(Ya=1,cp--),Ft}function Xs(){return Ft=Ts2||P0(Ft)>3?"":" "}function Dz(t,e){for(;--e&&Xs()&&!(Ft<48||Ft>102||Ft>57&&Ft<65||Ft>70&&Ft<97););return hp(t,$d()+(e<6&&xi()==32&&Xs()==32))}function L0(t){for(;Xs();)switch(Ft){case t:return Ts;case 34:case 39:t!==34&&t!==39&&L0(Ft);break;case 40:t===41&&L0(t);break;case 92:Xs();break}return Ts}function _z(t,e){for(;Xs()&&t+Ft!==57;)if(t+Ft===84&&xi()===47)break;return"/*"+hp(e,Ts-1)+"*"+Rx(t===47?t:Xs())}function Fz(t){for(;!P0(xi());)Xs();return hp(t,Ts)}function zz(t){return Rz(Nd("",null,null,null,[""],t=Ez(t),0,[0],t))}function Nd(t,e,n,s,r,o,i,a,l){for(var c=0,u=0,h=i,d=0,f=0,p=0,g=1,x=1,m=1,y=0,w="",v=r,b=o,C=s,k=w;x;)switch(p=y,y=Xs()){case 40:if(p!=108&&Zt(k,h-1)==58){Id(k+=Te(gg(y),"&","&\f"),"&\f",vI(c?a[c-1]:0))!=-1&&(m=-1);break}case 34:case 39:case 91:k+=gg(y);break;case 9:case 10:case 13:case 32:k+=Az(p);break;case 92:k+=Dz($d()-1,7);continue;case 47:switch(xi()){case 42:case 47:ec(Oz(_z(Xs(),$d()),e,n,l),l);break;default:k+="/"}break;case 123*g:a[c++]=cr(k)*m;case 125*g:case 59:case 0:switch(y){case 0:case 125:x=0;case 59+u:m==-1&&(k=Te(k,/\f/g,"")),f>0&&cr(k)-h&&ec(f>32?Ub(k+";",s,n,h-1,l):Ub(Te(k," ","")+";",s,n,h-2,l),l);break;case 59:k+=";";default:if(ec(C=Wb(k,e,n,c,u,r,a,w,v=[],b=[],h,o),o),y===123)if(u===0)Nd(k,e,C,C,v,o,h,a,b);else switch(d===99&&Zt(k,3)===110?100:d){case 100:case 108:case 109:case 115:Nd(t,C,C,s&&ec(Wb(t,C,C,0,0,r,a,w,r,v=[],h,b),b),r,b,h,a,s?v:b);break;default:Nd(k,C,C,C,[""],b,0,a,b)}}c=u=f=0,g=m=1,w=k="",h=i;break;case 58:h=1+cr(k),f=p;default:if(g<1){if(y==123)--g;else if(y==125&&g++==0&&Tz()==125)continue}switch(k+=Rx(y),y*g){case 38:m=u>0?1:(k+="\f",-1);break;case 44:a[c++]=(cr(k)-1)*m,m=1;break;case 64:xi()===45&&(k+=gg(Xs())),d=xi(),u=h=cr(w=k+=Fz($d())),y++;break;case 45:p===45&&cr(k)==2&&(g=0)}}return o}function Wb(t,e,n,s,r,o,i,a,l,c,u,h){for(var d=r-1,f=r===0?o:[""],p=CI(f),g=0,x=0,m=0;g0?f[y]+" "+w:Te(w,/&\f/g,f[y])))&&(l[m++]=v);return up(t,e,n,r===0?lp:a,l,c,u,h)}function Oz(t,e,n,s){return up(t,e,n,yI,Rx(Nz()),qa(t,2,-2),0,s)}function Ub(t,e,n,s,r){return up(t,e,n,Ex,qa(t,0,s),qa(t,s+1,-1),s,r)}function SI(t,e,n){switch(Iz(t,e)){case 5103:return je+"print-"+t+t;case 5737:case 4201:case 3177:case 3433:case 1641:case 4457:case 2921:case 5572:case 6356:case 5844:case 3191:case 6645:case 3005:case 6391:case 5879:case 5623:case 6135:case 4599:case 4855:case 4215:case 6389:case 5109:case 5365:case 5621:case 3829:return je+t+t;case 4789:return vc+t+t;case 5349:case 4246:case 4810:case 6968:case 2756:return je+t+vc+t+ut+t+t;case 5936:switch(Zt(t,e+11)){case 114:return je+t+ut+Te(t,/[svh]\w+-[tblr]{2}/,"tb")+t;case 108:return je+t+ut+Te(t,/[svh]\w+-[tblr]{2}/,"tb-rl")+t;case 45:return je+t+ut+Te(t,/[svh]\w+-[tblr]{2}/,"lr")+t}case 6828:case 4268:case 2903:return je+t+ut+t+t;case 6165:return je+t+ut+"flex-"+t+t;case 5187:return je+t+Te(t,/(\w+).+(:[^]+)/,je+"box-$1$2"+ut+"flex-$1$2")+t;case 5443:return je+t+ut+"flex-item-"+Te(t,/flex-|-self/g,"")+(Ar(t,/flex-|baseline/)?"":ut+"grid-row-"+Te(t,/flex-|-self/g,""))+t;case 4675:return je+t+ut+"flex-line-pack"+Te(t,/align-content|flex-|-self/g,"")+t;case 5548:return je+t+ut+Te(t,"shrink","negative")+t;case 5292:return je+t+ut+Te(t,"basis","preferred-size")+t;case 6060:return je+"box-"+Te(t,"-grow","")+je+t+ut+Te(t,"grow","positive")+t;case 4554:return je+Te(t,/([^-])(transform)/g,"$1"+je+"$2")+t;case 6187:return Te(Te(Te(t,/(zoom-|grab)/,je+"$1"),/(image-set)/,je+"$1"),t,"")+t;case 5495:case 3959:return Te(t,/(image-set\([^]*)/,je+"$1$`$1");case 4968:return Te(Te(t,/(.+:)(flex-)?(.*)/,je+"box-pack:$3"+ut+"flex-pack:$3"),/s.+-b[^;]+/,"justify")+je+t+t;case 4200:if(!Ar(t,/flex-|baseline/))return ut+"grid-column-align"+qa(t,e)+t;break;case 2592:case 3360:return ut+Te(t,"template-","")+t;case 4384:case 3616:return n&&n.some(function(s,r){return e=r,Ar(s.props,/grid-\w+-end/)})?~Id(t+(n=n[e].value),"span",0)?t:ut+Te(t,"-start","")+t+ut+"grid-row-span:"+(~Id(n,"span",0)?Ar(n,/\d+/):+Ar(n,/\d+/)-+Ar(t,/\d+/))+";":ut+Te(t,"-start","")+t;case 4896:case 4128:return n&&n.some(function(s){return Ar(s.props,/grid-\w+-start/)})?t:ut+Te(Te(t,"-end","-span"),"span ","")+t;case 4095:case 3583:case 4068:case 2532:return Te(t,/(.+)-inline(.+)/,je+"$1$2")+t;case 8116:case 7059:case 5753:case 5535:case 5445:case 5701:case 4933:case 4677:case 5533:case 5789:case 5021:case 4765:if(cr(t)-1-e>6)switch(Zt(t,e+1)){case 109:if(Zt(t,e+4)!==45)break;case 102:return Te(t,/(.+:)(.+)-([^]+)/,"$1"+je+"$2-$3$1"+vc+(Zt(t,e+3)==108?"$3":"$2-$3"))+t;case 115:return~Id(t,"stretch",0)?SI(Te(t,"stretch","fill-available"),e,n)+t:t}break;case 5152:case 5920:return Te(t,/(.+?):(\d+)(\s*\/\s*(span)?\s*(\d+))?(.*)/,function(s,r,o,i,a,l,c){return ut+r+":"+o+c+(i?ut+r+"-span:"+(a?l:+l-+o)+c:"")+t});case 4949:if(Zt(t,e+6)===121)return Te(t,":",":"+je)+t;break;case 6444:switch(Zt(t,Zt(t,14)===45?18:11)){case 120:return Te(t,/(.+:)([^;\s!]+)(;|(\s+)?!.+)?/,"$1"+je+(Zt(t,14)===45?"inline-":"")+"box$3$1"+je+"$2$3$1"+ut+"$2box$3")+t;case 100:return Te(t,":",":"+ut)+t}break;case 5719:case 2647:case 2135:case 3927:case 2391:return Te(t,"scroll-","scroll-snap-")+t}return t}function af(t,e){for(var n="",s=0;s-1&&!t.return)switch(t.type){case Ex:t.return=SI(t.value,t.length,n);return;case wI:return af([so(t,{value:Te(t.value,"@","@"+je)})],s);case lp:if(t.length)return $z(n=t.props,function(r){switch(Ar(r,s=/(::plac\w+|:read-\w+)/)){case":read-only":case":read-write":oa(so(t,{props:[Te(r,/:(read-\w+)/,":"+vc+"$1")]})),oa(so(t,{props:[r]})),M0(t,{props:Vb(n,s)});break;case"::placeholder":oa(so(t,{props:[Te(r,/:(plac\w+)/,":"+je+"input-$1")]})),oa(so(t,{props:[Te(r,/:(plac\w+)/,":"+vc+"$1")]})),oa(so(t,{props:[Te(r,/:(plac\w+)/,ut+"input-$1")]})),oa(so(t,{props:[r]})),M0(t,{props:Vb(n,s)});break}return""})}}var Vz={animationIterationCount:1,aspectRatio:1,borderImageOutset:1,borderImageSlice:1,borderImageWidth:1,boxFlex:1,boxFlexGroup:1,boxOrdinalGroup:1,columnCount:1,columns:1,flex:1,flexGrow:1,flexPositive:1,flexShrink:1,flexNegative:1,flexOrder:1,gridRow:1,gridRowEnd:1,gridRowSpan:1,gridRowStart:1,gridColumn:1,gridColumnEnd:1,gridColumnSpan:1,gridColumnStart:1,msGridRow:1,msGridRowSpan:1,msGridColumn:1,msGridColumnSpan:1,fontWeight:1,lineHeight:1,opacity:1,order:1,orphans:1,tabSize:1,widows:1,zIndex:1,zoom:1,WebkitLineClamp:1,fillOpacity:1,floodOpacity:1,stopOpacity:1,strokeDasharray:1,strokeDashoffset:1,strokeMiterlimit:1,strokeOpacity:1,strokeWidth:1},Zn={},Qa=typeof process<"u"&&Zn!==void 0&&(Zn.REACT_APP_SC_ATTR||Zn.SC_ATTR)||"data-styled",II="active",$I="data-styled-version",dp="6.1.13",Ax=`/*!sc*/ -`,lf=typeof window<"u"&&"HTMLElement"in window,Wz=!!(typeof SC_DISABLE_SPEEDY=="boolean"?SC_DISABLE_SPEEDY:typeof process<"u"&&Zn!==void 0&&Zn.REACT_APP_SC_DISABLE_SPEEDY!==void 0&&Zn.REACT_APP_SC_DISABLE_SPEEDY!==""?Zn.REACT_APP_SC_DISABLE_SPEEDY!=="false"&&Zn.REACT_APP_SC_DISABLE_SPEEDY:typeof process<"u"&&Zn!==void 0&&Zn.SC_DISABLE_SPEEDY!==void 0&&Zn.SC_DISABLE_SPEEDY!==""&&Zn.SC_DISABLE_SPEEDY!=="false"&&Zn.SC_DISABLE_SPEEDY),Uz={},fp=Object.freeze([]),Za=Object.freeze({});function NI(t,e,n){return n===void 0&&(n=Za),t.theme!==n.theme&&t.theme||e||n.theme}var TI=new Set(["a","abbr","address","area","article","aside","audio","b","base","bdi","bdo","big","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","hr","html","i","iframe","img","input","ins","kbd","keygen","label","legend","li","link","main","map","mark","menu","menuitem","meta","meter","nav","noscript","object","ol","optgroup","option","output","p","param","picture","pre","progress","q","rp","rt","ruby","s","samp","script","section","select","small","source","span","strong","style","sub","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","tr","track","u","ul","use","var","video","wbr","circle","clipPath","defs","ellipse","foreignObject","g","image","line","linearGradient","marker","mask","path","pattern","polygon","polyline","radialGradient","rect","stop","svg","text","tspan"]),Gz=/[!"#$%&'()*+,./:;<=>?@[\\\]^`{|}~-]+/g,Hz=/(^-|-$)/g;function Gb(t){return t.replace(Gz,"-").replace(Hz,"")}var jz=/(a)(d)/gi,Qh=52,Hb=function(t){return String.fromCharCode(t+(t>25?39:97))};function B0(t){var e,n="";for(e=Math.abs(t);e>Qh;e=e/Qh|0)n=Hb(e%Qh)+n;return(Hb(e%Qh)+n).replace(jz,"$1-$2")}var xg,EI=5381,Na=function(t,e){for(var n=e.length;n;)t=33*t^e.charCodeAt(--n);return t},RI=function(t){return Na(EI,t)};function AI(t){return B0(RI(t)>>>0)}function Kz(t){return t.displayName||t.name||"Component"}function yg(t){return typeof t=="string"&&!0}var DI=typeof Symbol=="function"&&Symbol.for,_I=DI?Symbol.for("react.memo"):60115,Xz=DI?Symbol.for("react.forward_ref"):60112,qz={childContextTypes:!0,contextType:!0,contextTypes:!0,defaultProps:!0,displayName:!0,getDefaultProps:!0,getDerivedStateFromError:!0,getDerivedStateFromProps:!0,mixins:!0,propTypes:!0,type:!0},Yz={name:!0,length:!0,prototype:!0,caller:!0,callee:!0,arguments:!0,arity:!0},FI={$$typeof:!0,compare:!0,defaultProps:!0,displayName:!0,propTypes:!0,type:!0},Qz=((xg={})[Xz]={$$typeof:!0,render:!0,defaultProps:!0,displayName:!0,propTypes:!0},xg[_I]=FI,xg);function jb(t){return("type"in(e=t)&&e.type.$$typeof)===_I?FI:"$$typeof"in t?Qz[t.$$typeof]:qz;var e}var Zz=Object.defineProperty,Jz=Object.getOwnPropertyNames,Kb=Object.getOwnPropertySymbols,eO=Object.getOwnPropertyDescriptor,tO=Object.getPrototypeOf,Xb=Object.prototype;function zI(t,e,n){if(typeof e!="string"){if(Xb){var s=tO(e);s&&s!==Xb&&zI(t,s,n)}var r=Jz(e);Kb&&(r=r.concat(Kb(e)));for(var o=jb(t),i=jb(e),a=0;a0?" Args: ".concat(e.join(", ")):""))}var nO=function(){function t(e){this.groupSizes=new Uint32Array(512),this.length=512,this.tag=e}return t.prototype.indexOfGroup=function(e){for(var n=0,s=0;s=this.groupSizes.length){for(var s=this.groupSizes,r=s.length,o=r;e>=o;)if((o<<=1)<0)throw hu(16,"".concat(e));this.groupSizes=new Uint32Array(o),this.groupSizes.set(s),this.length=o;for(var i=r;i=this.length||this.groupSizes[e]===0)return n;for(var s=this.groupSizes[e],r=this.indexOfGroup(e),o=r+s,i=r;i=0){var s=document.createTextNode(n);return this.element.insertBefore(s,this.nodes[e]||null),this.length++,!0}return!1},t.prototype.deleteRule=function(e){this.element.removeChild(this.nodes[e]),this.length--},t.prototype.getRule=function(e){return e0&&(x+="".concat(m,","))}),l+="".concat(p).concat(g,'{content:"').concat(x,'"}').concat(Ax)},u=0;u0?".".concat(e):d},u=l.slice();u.push(function(d){d.type===lp&&d.value.includes("&")&&(d.props[0]=d.props[0].replace(fO,n).replace(s,c))}),i.prefix&&u.push(Bz),u.push(Mz);var h=function(d,f,p,g){f===void 0&&(f=""),p===void 0&&(p=""),g===void 0&&(g="&"),e=g,n=f,s=new RegExp("\\".concat(n,"\\b"),"g");var x=d.replace(pO,""),m=zz(p||f?"".concat(p," ").concat(f," { ").concat(x," }"):x);i.namespace&&(m=MI(m,i.namespace));var y=[];return af(m,Pz(u.concat(Lz(function(w){return y.push(w)})))),y};return h.hash=l.length?l.reduce(function(d,f){return f.name||hu(15),Na(d,f.name)},EI).toString():"",h}var gO=new uf,U0=mO(),PI=Gs.createContext({shouldForwardProp:void 0,styleSheet:gO,stylis:U0});PI.Consumer;Gs.createContext(void 0);function G0(){return ye.useContext(PI)}var xO=function(){function t(e,n){var s=this;this.inject=function(r,o){o===void 0&&(o=U0);var i=s.name+o.hash;r.hasNameForId(s.id,i)||r.insertRules(s.id,i,o(s.rules,i,"@keyframes"))},this.name=e,this.id="sc-keyframes-".concat(e),this.rules=n,_x(this,function(){throw hu(12,String(s.name))})}return t.prototype.getName=function(e){return e===void 0&&(e=U0),this.name+e.hash},t}(),yO=function(t){return t>="A"&&t<="Z"};function Qb(t){for(var e="",n=0;n>>0);if(!n.hasNameForId(this.componentId,i)){var a=s(o,".".concat(i),void 0,this.componentId);n.insertRules(this.componentId,i,a)}r=hi(r,i),this.staticRulesId=i}else{for(var l=Na(this.baseHash,s.hash),c="",u=0;u>>0);n.hasNameForId(this.componentId,f)||n.insertRules(this.componentId,f,s(c,".".concat(f),void 0,this.componentId)),r=hi(r,f)}}return r},t}(),Fx=Gs.createContext(void 0);Fx.Consumer;var wg={};function bO(t,e,n){var s=Dx(t),r=t,o=!yg(t),i=e.attrs,a=i===void 0?fp:i,l=e.componentId,c=l===void 0?function(v,b){var C=typeof v!="string"?"sc":Gb(v);wg[C]=(wg[C]||0)+1;var k="".concat(C,"-").concat(AI(dp+C+wg[C]));return b?"".concat(b,"-").concat(k):k}(e.displayName,e.parentComponentId):l,u=e.displayName,h=u===void 0?function(v){return yg(v)?"styled.".concat(v):"Styled(".concat(Kz(v),")")}(t):u,d=e.displayName&&e.componentId?"".concat(Gb(e.displayName),"-").concat(e.componentId):e.componentId||c,f=s&&r.attrs?r.attrs.concat(a).filter(Boolean):a,p=e.shouldForwardProp;if(s&&r.shouldForwardProp){var g=r.shouldForwardProp;if(e.shouldForwardProp){var x=e.shouldForwardProp;p=function(v,b){return g(v,b)&&x(v,b)}}else p=g}var m=new vO(n,d,s?r.componentStyle:void 0);function y(v,b){return function(C,k,S){var $=C.attrs,N=C.componentStyle,A=C.defaultProps,M=C.foldedComponentIds,L=C.styledComponentId,V=C.target,B=Gs.useContext(Fx),U=G0(),K=C.shouldForwardProp||U.shouldForwardProp,R=NI(k,B,A)||Za,O=function(Z,se,ie){for(var ce,ue=bn(bn({},se),{className:void 0,theme:ie}),xe=0;xe2&&uf.registerId(this.componentId+e),this.removeStyles(e,s),this.createStyles(e,n,s,r)},t}();function GI(t){for(var e=[],n=1;n<\/script>",t=t.removeChild(t.firstChild)):typeof s.is=="string"?t=i.createElement(n,{is:s.is}):(t=i.createElement(n),n==="select"&&(i=t,s.multiple?i.multiple=!0:s.size&&(i.size=s.size))):t=i.createElementNS(t,n),t[fr]=e,t[Oc]=s,Z2(t,e,!1,!1),e.stateNode=t;e:{switch(i=n0(n,s),n){case"dialog":ct("cancel",t),ct("close",t),r=s;break;case"iframe":case"object":case"embed":ct("load",t),r=s;break;case"video":case"audio":for(r=0;rXa&&(e.flags|=128,s=!0,Wl(o,!1),e.lanes=4194304)}else{if(!s)if(t=Qd(i),t!==null){if(e.flags|=128,s=!0,n=t.updateQueue,n!==null&&(e.updateQueue=n,e.flags|=4),Wl(o,!0),o.tail===null&&o.tailMode==="hidden"&&!i.alternate&&!gt)return gn(e),null}else 2*Et()-o.renderingStartTime>Xa&&n!==1073741824&&(e.flags|=128,s=!0,Wl(o,!1),e.lanes=4194304);o.isBackwards?(i.sibling=e.child,e.child=i):(n=o.last,n!==null?n.sibling=i:e.child=i,o.last=i)}return o.tail!==null?(e=o.tail,o.rendering=e,o.tail=e.sibling,o.renderingStartTime=Et(),e.sibling=null,n=wt.current,rt(wt,s?n&1|2:n&1),e):(gn(e),null);case 22:case 23:return Cx(),s=e.memoizedState!==null,t!==null&&t.memoizedState!==null!==s&&(e.flags|=8192),s&&e.mode&1?Jn&1073741824&&(gn(e),e.subtreeFlags&6&&(e.flags|=8192)):gn(e),null;case 24:return null;case 25:return null}throw Error(ne(156,e.tag))}function tz(t,e){switch(nx(e),e.tag){case 1:return jn(e.type)&&Gd(),t=e.flags,t&65536?(e.flags=t&-65537|128,e):null;case 3:return ja(),dt(Hn),dt(kn),hx(),t=e.flags,t&65536&&!(t&128)?(e.flags=t&-65537|128,e):null;case 5:return ux(e),null;case 13:if(dt(wt),t=e.memoizedState,t!==null&&t.dehydrated!==null){if(e.alternate===null)throw Error(ne(340));Ga()}return t=e.flags,t&65536?(e.flags=t&-65537|128,e):null;case 19:return dt(wt),null;case 4:return ja(),null;case 10:return ix(e.type._context),null;case 22:case 23:return Cx(),null;case 24:return null;default:return null}}var Kh=!1,yn=!1,nz=typeof WeakSet=="function"?WeakSet:Set,he=null;function Ia(t,e){var n=t.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(s){Ct(t,e,s)}else n.current=null}function E0(t,e,n){try{n()}catch(s){Ct(t,e,s)}}var Rb=!1;function sz(t,e){if(d0=Bd,t=o2(),ex(t)){if("selectionStart"in t)var n={start:t.selectionStart,end:t.selectionEnd};else e:{n=(n=t.ownerDocument)&&n.defaultView||window;var s=n.getSelection&&n.getSelection();if(s&&s.rangeCount!==0){n=s.anchorNode;var r=s.anchorOffset,o=s.focusNode;s=s.focusOffset;try{n.nodeType,o.nodeType}catch{n=null;break e}var i=0,a=-1,l=-1,c=0,u=0,h=t,d=null;t:for(;;){for(var f;h!==n||r!==0&&h.nodeType!==3||(a=i+r),h!==o||s!==0&&h.nodeType!==3||(l=i+s),h.nodeType===3&&(i+=h.nodeValue.length),(f=h.firstChild)!==null;)d=h,h=f;for(;;){if(h===t)break t;if(d===n&&++c===r&&(a=i),d===o&&++u===s&&(l=i),(f=h.nextSibling)!==null)break;h=d,d=h.parentNode}h=f}n=a===-1||l===-1?null:{start:a,end:l}}else n=null}n=n||{start:0,end:0}}else n=null;for(f0={focusedElem:t,selectionRange:n},Bd=!1,he=e;he!==null;)if(e=he,t=e.child,(e.subtreeFlags&1028)!==0&&t!==null)t.return=e,he=t;else for(;he!==null;){e=he;try{var p=e.alternate;if(e.flags&1024)switch(e.tag){case 0:case 11:case 15:break;case 1:if(p!==null){var g=p.memoizedProps,x=p.memoizedState,m=e.stateNode,y=m.getSnapshotBeforeUpdate(e.elementType===e.type?g:Ls(e.type,g),x);m.__reactInternalSnapshotBeforeUpdate=y}break;case 3:var w=e.stateNode.containerInfo;w.nodeType===1?w.textContent="":w.nodeType===9&&w.documentElement&&w.removeChild(w.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(ne(163))}}catch(v){Ct(e,e.return,v)}if(t=e.sibling,t!==null){t.return=e.return,he=t;break}he=e.return}return p=Rb,Rb=!1,p}function xc(t,e,n){var s=e.updateQueue;if(s=s!==null?s.lastEffect:null,s!==null){var r=s=s.next;do{if((r.tag&t)===t){var o=r.destroy;r.destroy=void 0,o!==void 0&&E0(e,n,o)}r=r.next}while(r!==s)}}function ep(t,e){if(e=e.updateQueue,e=e!==null?e.lastEffect:null,e!==null){var n=e=e.next;do{if((n.tag&t)===t){var s=n.create;n.destroy=s()}n=n.next}while(n!==e)}}function R0(t){var e=t.ref;if(e!==null){var n=t.stateNode;switch(t.tag){case 5:t=n;break;default:t=n}typeof e=="function"?e(t):e.current=t}}function tI(t){var e=t.alternate;e!==null&&(t.alternate=null,tI(e)),t.child=null,t.deletions=null,t.sibling=null,t.tag===5&&(e=t.stateNode,e!==null&&(delete e[fr],delete e[Oc],delete e[g0],delete e[LF],delete e[BF])),t.stateNode=null,t.return=null,t.dependencies=null,t.memoizedProps=null,t.memoizedState=null,t.pendingProps=null,t.stateNode=null,t.updateQueue=null}function nI(t){return t.tag===5||t.tag===3||t.tag===4}function Ab(t){e:for(;;){for(;t.sibling===null;){if(t.return===null||nI(t.return))return null;t=t.return}for(t.sibling.return=t.return,t=t.sibling;t.tag!==5&&t.tag!==6&&t.tag!==18;){if(t.flags&2||t.child===null||t.tag===4)continue e;t.child.return=t,t=t.child}if(!(t.flags&2))return t.stateNode}}function A0(t,e,n){var s=t.tag;if(s===5||s===6)t=t.stateNode,e?n.nodeType===8?n.parentNode.insertBefore(t,e):n.insertBefore(t,e):(n.nodeType===8?(e=n.parentNode,e.insertBefore(t,n)):(e=n,e.appendChild(t)),n=n._reactRootContainer,n!=null||e.onclick!==null||(e.onclick=Ud));else if(s!==4&&(t=t.child,t!==null))for(A0(t,e,n),t=t.sibling;t!==null;)A0(t,e,n),t=t.sibling}function D0(t,e,n){var s=t.tag;if(s===5||s===6)t=t.stateNode,e?n.insertBefore(t,e):n.appendChild(t);else if(s!==4&&(t=t.child,t!==null))for(D0(t,e,n),t=t.sibling;t!==null;)D0(t,e,n),t=t.sibling}var on=null,Bs=!1;function no(t,e,n){for(n=n.child;n!==null;)sI(t,e,n),n=n.sibling}function sI(t,e,n){if(mr&&typeof mr.onCommitFiberUnmount=="function")try{mr.onCommitFiberUnmount(jf,n)}catch{}switch(n.tag){case 5:yn||Ia(n,e);case 6:var s=on,r=Bs;on=null,no(t,e,n),on=s,Bs=r,on!==null&&(Bs?(t=on,n=n.stateNode,t.nodeType===8?t.parentNode.removeChild(n):t.removeChild(n)):on.removeChild(n.stateNode));break;case 18:on!==null&&(Bs?(t=on,n=n.stateNode,t.nodeType===8?ig(t.parentNode,n):t.nodeType===1&&ig(t,n),Ac(t)):ig(on,n.stateNode));break;case 4:s=on,r=Bs,on=n.stateNode.containerInfo,Bs=!0,no(t,e,n),on=s,Bs=r;break;case 0:case 11:case 14:case 15:if(!yn&&(s=n.updateQueue,s!==null&&(s=s.lastEffect,s!==null))){r=s=s.next;do{var o=r,i=o.destroy;o=o.tag,i!==void 0&&(o&2||o&4)&&E0(n,e,i),r=r.next}while(r!==s)}no(t,e,n);break;case 1:if(!yn&&(Ia(n,e),s=n.stateNode,typeof s.componentWillUnmount=="function"))try{s.props=n.memoizedProps,s.state=n.memoizedState,s.componentWillUnmount()}catch(a){Ct(n,e,a)}no(t,e,n);break;case 21:no(t,e,n);break;case 22:n.mode&1?(yn=(s=yn)||n.memoizedState!==null,no(t,e,n),yn=s):no(t,e,n);break;default:no(t,e,n)}}function Db(t){var e=t.updateQueue;if(e!==null){t.updateQueue=null;var n=t.stateNode;n===null&&(n=t.stateNode=new nz),e.forEach(function(s){var r=dz.bind(null,t,s);n.has(s)||(n.add(s),s.then(r,r))})}}function Os(t,e){var n=e.deletions;if(n!==null)for(var s=0;sr&&(r=i),s&=~o}if(s=r,s=Et()-s,s=(120>s?120:480>s?480:1080>s?1080:1920>s?1920:3e3>s?3e3:4320>s?4320:1960*oz(s/1960))-s,10t?16:t,uo===null)var s=!1;else{if(t=uo,uo=null,nf=0,Le&6)throw Error(ne(331));var r=Le;for(Le|=4,he=t.current;he!==null;){var o=he,i=o.child;if(he.flags&16){var a=o.deletions;if(a!==null){for(var l=0;lEt()-vx?mi(t,0):wx|=n),Kn(t,e)}function hI(t,e){e===0&&(t.mode&1?(e=Ph,Ph<<=1,!(Ph&130023424)&&(Ph=4194304)):e=1);var n=An();t=Vr(t,e),t!==null&&(au(t,e,n),Kn(t,n))}function hz(t){var e=t.memoizedState,n=0;e!==null&&(n=e.retryLane),hI(t,n)}function dz(t,e){var n=0;switch(t.tag){case 13:var s=t.stateNode,r=t.memoizedState;r!==null&&(n=r.retryLane);break;case 19:s=t.stateNode;break;default:throw Error(ne(314))}s!==null&&s.delete(e),hI(t,n)}var dI;dI=function(t,e,n){if(t!==null)if(t.memoizedProps!==e.pendingProps||Hn.current)Wn=!0;else{if(!(t.lanes&n)&&!(e.flags&128))return Wn=!1,JF(t,e,n);Wn=!!(t.flags&131072)}else Wn=!1,gt&&e.flags&1048576&&g2(e,Kd,e.index);switch(e.lanes=0,e.tag){case 2:var s=e.type;vd(t,e),t=e.pendingProps;var r=Ua(e,kn.current);_a(e,n),r=fx(null,e,s,t,r,n);var o=px();return e.flags|=1,typeof r=="object"&&r!==null&&typeof r.render=="function"&&r.$$typeof===void 0?(e.tag=1,e.memoizedState=null,e.updateQueue=null,jn(s)?(o=!0,Hd(e)):o=!1,e.memoizedState=r.state!==null&&r.state!==void 0?r.state:null,lx(e),r.updater=Jf,e.stateNode=r,r._reactInternals=e,C0(e,s,t,n),e=I0(null,e,s,!0,o,n)):(e.tag=0,gt&&o&&tx(e),Nn(null,e,r,n),e=e.child),e;case 16:s=e.elementType;e:{switch(vd(t,e),t=e.pendingProps,r=s._init,s=r(s._payload),e.type=s,r=e.tag=pz(s),t=Ls(s,t),r){case 0:e=S0(null,e,s,t,n);break e;case 1:e=Nb(null,e,s,t,n);break e;case 11:e=Ib(null,e,s,t,n);break e;case 14:e=$b(null,e,s,Ls(s.type,t),n);break e}throw Error(ne(306,s,""))}return e;case 0:return s=e.type,r=e.pendingProps,r=e.elementType===s?r:Ls(s,r),S0(t,e,s,r,n);case 1:return s=e.type,r=e.pendingProps,r=e.elementType===s?r:Ls(s,r),Nb(t,e,s,r,n);case 3:e:{if(q2(e),t===null)throw Error(ne(387));s=e.pendingProps,o=e.memoizedState,r=o.element,C2(t,e),Yd(e,s,null,n);var i=e.memoizedState;if(s=i.element,o.isDehydrated)if(o={element:s,isDehydrated:!1,cache:i.cache,pendingSuspenseBoundaries:i.pendingSuspenseBoundaries,transitions:i.transitions},e.updateQueue.baseState=o,e.memoizedState=o,e.flags&256){r=Ka(Error(ne(423)),e),e=Tb(t,e,s,n,r);break e}else if(s!==r){r=Ka(Error(ne(424)),e),e=Tb(t,e,s,n,r);break e}else for(ts=yo(e.stateNode.containerInfo.firstChild),ss=e,gt=!0,Vs=null,n=v2(e,null,s,n),e.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(Ga(),s===r){e=Wr(t,e,n);break e}Nn(t,e,s,n)}e=e.child}return e;case 5:return k2(e),t===null&&w0(e),s=e.type,r=e.pendingProps,o=t!==null?t.memoizedProps:null,i=r.children,p0(s,r)?i=null:o!==null&&p0(s,o)&&(e.flags|=32),X2(t,e),Nn(t,e,i,n),e.child;case 6:return t===null&&w0(e),null;case 13:return Y2(t,e,n);case 4:return cx(e,e.stateNode.containerInfo),s=e.pendingProps,t===null?e.child=Ha(e,null,s,n):Nn(t,e,s,n),e.child;case 11:return s=e.type,r=e.pendingProps,r=e.elementType===s?r:Ls(s,r),Ib(t,e,s,r,n);case 7:return Nn(t,e,e.pendingProps,n),e.child;case 8:return Nn(t,e,e.pendingProps.children,n),e.child;case 12:return Nn(t,e,e.pendingProps.children,n),e.child;case 10:e:{if(s=e.type._context,r=e.pendingProps,o=e.memoizedProps,i=r.value,rt(Xd,s._currentValue),s._currentValue=i,o!==null)if(Zs(o.value,i)){if(o.children===r.children&&!Hn.current){e=Wr(t,e,n);break e}}else for(o=e.child,o!==null&&(o.return=e);o!==null;){var a=o.dependencies;if(a!==null){i=o.child;for(var l=a.firstContext;l!==null;){if(l.context===s){if(o.tag===1){l=Pr(-1,n&-n),l.tag=2;var c=o.updateQueue;if(c!==null){c=c.shared;var u=c.pending;u===null?l.next=l:(l.next=u.next,u.next=l),c.pending=l}}o.lanes|=n,l=o.alternate,l!==null&&(l.lanes|=n),v0(o.return,n,e),a.lanes|=n;break}l=l.next}}else if(o.tag===10)i=o.type===e.type?null:o.child;else if(o.tag===18){if(i=o.return,i===null)throw Error(ne(341));i.lanes|=n,a=i.alternate,a!==null&&(a.lanes|=n),v0(i,n,e),i=o.sibling}else i=o.child;if(i!==null)i.return=o;else for(i=o;i!==null;){if(i===e){i=null;break}if(o=i.sibling,o!==null){o.return=i.return,i=o;break}i=i.return}o=i}Nn(t,e,r.children,n),e=e.child}return e;case 9:return r=e.type,s=e.pendingProps.children,_a(e,n),r=$s(r),s=s(r),e.flags|=1,Nn(t,e,s,n),e.child;case 14:return s=e.type,r=Ls(s,e.pendingProps),r=Ls(s.type,r),$b(t,e,s,r,n);case 15:return j2(t,e,e.type,e.pendingProps,n);case 17:return s=e.type,r=e.pendingProps,r=e.elementType===s?r:Ls(s,r),vd(t,e),e.tag=1,jn(s)?(t=!0,Hd(e)):t=!1,_a(e,n),U2(e,s,r),C0(e,s,r,n),I0(null,e,s,!0,t,n);case 19:return Q2(t,e,n);case 22:return K2(t,e,n)}throw Error(ne(156,e.tag))};function fI(t,e){return BS(t,e)}function fz(t,e,n,s){this.tag=t,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=e,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=s,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function ys(t,e,n,s){return new fz(t,e,n,s)}function Sx(t){return t=t.prototype,!(!t||!t.isReactComponent)}function pz(t){if(typeof t=="function")return Sx(t)?1:0;if(t!=null){if(t=t.$$typeof,t===U1)return 11;if(t===G1)return 14}return 2}function Co(t,e){var n=t.alternate;return n===null?(n=ys(t.tag,e,t.key,t.mode),n.elementType=t.elementType,n.type=t.type,n.stateNode=t.stateNode,n.alternate=t,t.alternate=n):(n.pendingProps=e,n.type=t.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=t.flags&14680064,n.childLanes=t.childLanes,n.lanes=t.lanes,n.child=t.child,n.memoizedProps=t.memoizedProps,n.memoizedState=t.memoizedState,n.updateQueue=t.updateQueue,e=t.dependencies,n.dependencies=e===null?null:{lanes:e.lanes,firstContext:e.firstContext},n.sibling=t.sibling,n.index=t.index,n.ref=t.ref,n}function kd(t,e,n,s,r,o){var i=2;if(s=t,typeof t=="function")Sx(t)&&(i=1);else if(typeof t=="string")i=5;else e:switch(t){case ga:return gi(n.children,r,o,e);case W1:i=8,r|=8;break;case jg:return t=ys(12,n,e,r|2),t.elementType=jg,t.lanes=o,t;case Kg:return t=ys(13,n,e,r),t.elementType=Kg,t.lanes=o,t;case Xg:return t=ys(19,n,e,r),t.elementType=Xg,t.lanes=o,t;case kS:return np(n,r,o,e);default:if(typeof t=="object"&&t!==null)switch(t.$$typeof){case bS:i=10;break e;case CS:i=9;break e;case U1:i=11;break e;case G1:i=14;break e;case ro:i=16,s=null;break e}throw Error(ne(130,t==null?t:typeof t,""))}return e=ys(i,n,e,r),e.elementType=t,e.type=s,e.lanes=o,e}function gi(t,e,n,s){return t=ys(7,t,s,e),t.lanes=n,t}function np(t,e,n,s){return t=ys(22,t,s,e),t.elementType=kS,t.lanes=n,t.stateNode={isHidden:!1},t}function pg(t,e,n){return t=ys(6,t,null,e),t.lanes=n,t}function mg(t,e,n){return e=ys(4,t.children!==null?t.children:[],t.key,e),e.lanes=n,e.stateNode={containerInfo:t.containerInfo,pendingChildren:null,implementation:t.implementation},e}function mz(t,e,n,s,r){this.tag=e,this.containerInfo=t,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=qm(0),this.expirationTimes=qm(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=qm(0),this.identifierPrefix=s,this.onRecoverableError=r,this.mutableSourceEagerHydrationData=null}function Ix(t,e,n,s,r,o,i,a,l){return t=new mz(t,e,n,a,l),e===1?(e=1,o===!0&&(e|=8)):e=0,o=ys(3,null,null,e),t.current=o,o.stateNode=t,o.memoizedState={element:s,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},lx(o),t}function gz(t,e,n){var s=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(xI)}catch(t){console.error(t)}}xI(),xS.exports=ls;var bz=xS.exports,Bb=bz;Gg.createRoot=Bb.createRoot,Gg.hydrateRoot=Bb.hydrateRoot;var bn=function(){return bn=Object.assign||function(e){for(var n,s=1,r=arguments.length;s0?Zt(yl,--Ts):0,Ya--,Ft===10&&(Ya=1,lp--),Ft}function Xs(){return Ft=Ts2||P0(Ft)>3?"":" "}function Az(t,e){for(;--e&&Xs()&&!(Ft<48||Ft>102||Ft>57&&Ft<65||Ft>70&&Ft<97););return up(t,Id()+(e<6&&xi()==32&&Xs()==32))}function L0(t){for(;Xs();)switch(Ft){case t:return Ts;case 34:case 39:t!==34&&t!==39&&L0(Ft);break;case 40:t===41&&L0(t);break;case 92:Xs();break}return Ts}function Dz(t,e){for(;Xs()&&t+Ft!==57;)if(t+Ft===84&&xi()===47)break;return"/*"+up(e,Ts-1)+"*"+Rx(t===47?t:Xs())}function _z(t){for(;!P0(xi());)Xs();return up(t,Ts)}function Fz(t){return Ez($d("",null,null,null,[""],t=Tz(t),0,[0],t))}function $d(t,e,n,s,r,o,i,a,l){for(var c=0,u=0,h=i,d=0,f=0,p=0,g=1,x=1,m=1,y=0,w="",v=r,b=o,C=s,k=w;x;)switch(p=y,y=Xs()){case 40:if(p!=108&&Zt(k,h-1)==58){Sd(k+=Te(gg(y),"&","&\f"),"&\f",vI(c?a[c-1]:0))!=-1&&(m=-1);break}case 34:case 39:case 91:k+=gg(y);break;case 9:case 10:case 13:case 32:k+=Rz(p);break;case 92:k+=Az(Id()-1,7);continue;case 47:switch(xi()){case 42:case 47:ec(zz(Dz(Xs(),Id()),e,n,l),l);break;default:k+="/"}break;case 123*g:a[c++]=cr(k)*m;case 125*g:case 59:case 0:switch(y){case 0:case 125:x=0;case 59+u:m==-1&&(k=Te(k,/\f/g,"")),f>0&&cr(k)-h&&ec(f>32?Ub(k+";",s,n,h-1,l):Ub(Te(k," ","")+";",s,n,h-2,l),l);break;case 59:k+=";";default:if(ec(C=Wb(k,e,n,c,u,r,a,w,v=[],b=[],h,o),o),y===123)if(u===0)$d(k,e,C,C,v,o,h,a,b);else switch(d===99&&Zt(k,3)===110?100:d){case 100:case 108:case 109:case 115:$d(t,C,C,s&&ec(Wb(t,C,C,0,0,r,a,w,r,v=[],h,b),b),r,b,h,a,s?v:b);break;default:$d(k,C,C,C,[""],b,0,a,b)}}c=u=f=0,g=m=1,w=k="",h=i;break;case 58:h=1+cr(k),f=p;default:if(g<1){if(y==123)--g;else if(y==125&&g++==0&&Nz()==125)continue}switch(k+=Rx(y),y*g){case 38:m=u>0?1:(k+="\f",-1);break;case 44:a[c++]=(cr(k)-1)*m,m=1;break;case 64:xi()===45&&(k+=gg(Xs())),d=xi(),u=h=cr(w=k+=_z(Id())),y++;break;case 45:p===45&&cr(k)==2&&(g=0)}}return o}function Wb(t,e,n,s,r,o,i,a,l,c,u,h){for(var d=r-1,f=r===0?o:[""],p=CI(f),g=0,x=0,m=0;g0?f[y]+" "+w:Te(w,/&\f/g,f[y])))&&(l[m++]=v);return cp(t,e,n,r===0?ap:a,l,c,u,h)}function zz(t,e,n,s){return cp(t,e,n,yI,Rx($z()),qa(t,2,-2),0,s)}function Ub(t,e,n,s,r){return cp(t,e,n,Ex,qa(t,0,s),qa(t,s+1,-1),s,r)}function SI(t,e,n){switch(Sz(t,e)){case 5103:return je+"print-"+t+t;case 5737:case 4201:case 3177:case 3433:case 1641:case 4457:case 2921:case 5572:case 6356:case 5844:case 3191:case 6645:case 3005:case 6391:case 5879:case 5623:case 6135:case 4599:case 4855:case 4215:case 6389:case 5109:case 5365:case 5621:case 3829:return je+t+t;case 4789:return vc+t+t;case 5349:case 4246:case 4810:case 6968:case 2756:return je+t+vc+t+ut+t+t;case 5936:switch(Zt(t,e+11)){case 114:return je+t+ut+Te(t,/[svh]\w+-[tblr]{2}/,"tb")+t;case 108:return je+t+ut+Te(t,/[svh]\w+-[tblr]{2}/,"tb-rl")+t;case 45:return je+t+ut+Te(t,/[svh]\w+-[tblr]{2}/,"lr")+t}case 6828:case 4268:case 2903:return je+t+ut+t+t;case 6165:return je+t+ut+"flex-"+t+t;case 5187:return je+t+Te(t,/(\w+).+(:[^]+)/,je+"box-$1$2"+ut+"flex-$1$2")+t;case 5443:return je+t+ut+"flex-item-"+Te(t,/flex-|-self/g,"")+(Ar(t,/flex-|baseline/)?"":ut+"grid-row-"+Te(t,/flex-|-self/g,""))+t;case 4675:return je+t+ut+"flex-line-pack"+Te(t,/align-content|flex-|-self/g,"")+t;case 5548:return je+t+ut+Te(t,"shrink","negative")+t;case 5292:return je+t+ut+Te(t,"basis","preferred-size")+t;case 6060:return je+"box-"+Te(t,"-grow","")+je+t+ut+Te(t,"grow","positive")+t;case 4554:return je+Te(t,/([^-])(transform)/g,"$1"+je+"$2")+t;case 6187:return Te(Te(Te(t,/(zoom-|grab)/,je+"$1"),/(image-set)/,je+"$1"),t,"")+t;case 5495:case 3959:return Te(t,/(image-set\([^]*)/,je+"$1$`$1");case 4968:return Te(Te(t,/(.+:)(flex-)?(.*)/,je+"box-pack:$3"+ut+"flex-pack:$3"),/s.+-b[^;]+/,"justify")+je+t+t;case 4200:if(!Ar(t,/flex-|baseline/))return ut+"grid-column-align"+qa(t,e)+t;break;case 2592:case 3360:return ut+Te(t,"template-","")+t;case 4384:case 3616:return n&&n.some(function(s,r){return e=r,Ar(s.props,/grid-\w+-end/)})?~Sd(t+(n=n[e].value),"span",0)?t:ut+Te(t,"-start","")+t+ut+"grid-row-span:"+(~Sd(n,"span",0)?Ar(n,/\d+/):+Ar(n,/\d+/)-+Ar(t,/\d+/))+";":ut+Te(t,"-start","")+t;case 4896:case 4128:return n&&n.some(function(s){return Ar(s.props,/grid-\w+-start/)})?t:ut+Te(Te(t,"-end","-span"),"span ","")+t;case 4095:case 3583:case 4068:case 2532:return Te(t,/(.+)-inline(.+)/,je+"$1$2")+t;case 8116:case 7059:case 5753:case 5535:case 5445:case 5701:case 4933:case 4677:case 5533:case 5789:case 5021:case 4765:if(cr(t)-1-e>6)switch(Zt(t,e+1)){case 109:if(Zt(t,e+4)!==45)break;case 102:return Te(t,/(.+:)(.+)-([^]+)/,"$1"+je+"$2-$3$1"+vc+(Zt(t,e+3)==108?"$3":"$2-$3"))+t;case 115:return~Sd(t,"stretch",0)?SI(Te(t,"stretch","fill-available"),e,n)+t:t}break;case 5152:case 5920:return Te(t,/(.+?):(\d+)(\s*\/\s*(span)?\s*(\d+))?(.*)/,function(s,r,o,i,a,l,c){return ut+r+":"+o+c+(i?ut+r+"-span:"+(a?l:+l-+o)+c:"")+t});case 4949:if(Zt(t,e+6)===121)return Te(t,":",":"+je)+t;break;case 6444:switch(Zt(t,Zt(t,14)===45?18:11)){case 120:return Te(t,/(.+:)([^;\s!]+)(;|(\s+)?!.+)?/,"$1"+je+(Zt(t,14)===45?"inline-":"")+"box$3$1"+je+"$2$3$1"+ut+"$2box$3")+t;case 100:return Te(t,":",":"+ut)+t}break;case 5719:case 2647:case 2135:case 3927:case 2391:return Te(t,"scroll-","scroll-snap-")+t}return t}function of(t,e){for(var n="",s=0;s-1&&!t.return)switch(t.type){case Ex:t.return=SI(t.value,t.length,n);return;case wI:return of([so(t,{value:Te(t.value,"@","@"+je)})],s);case ap:if(t.length)return Iz(n=t.props,function(r){switch(Ar(r,s=/(::plac\w+|:read-\w+)/)){case":read-only":case":read-write":oa(so(t,{props:[Te(r,/:(read-\w+)/,":"+vc+"$1")]})),oa(so(t,{props:[r]})),M0(t,{props:Vb(n,s)});break;case"::placeholder":oa(so(t,{props:[Te(r,/:(plac\w+)/,":"+je+"input-$1")]})),oa(so(t,{props:[Te(r,/:(plac\w+)/,":"+vc+"$1")]})),oa(so(t,{props:[Te(r,/:(plac\w+)/,ut+"input-$1")]})),oa(so(t,{props:[r]})),M0(t,{props:Vb(n,s)});break}return""})}}var Bz={animationIterationCount:1,aspectRatio:1,borderImageOutset:1,borderImageSlice:1,borderImageWidth:1,boxFlex:1,boxFlexGroup:1,boxOrdinalGroup:1,columnCount:1,columns:1,flex:1,flexGrow:1,flexPositive:1,flexShrink:1,flexNegative:1,flexOrder:1,gridRow:1,gridRowEnd:1,gridRowSpan:1,gridRowStart:1,gridColumn:1,gridColumnEnd:1,gridColumnSpan:1,gridColumnStart:1,msGridRow:1,msGridRowSpan:1,msGridColumn:1,msGridColumnSpan:1,fontWeight:1,lineHeight:1,opacity:1,order:1,orphans:1,tabSize:1,widows:1,zIndex:1,zoom:1,WebkitLineClamp:1,fillOpacity:1,floodOpacity:1,stopOpacity:1,strokeDasharray:1,strokeDashoffset:1,strokeMiterlimit:1,strokeOpacity:1,strokeWidth:1},Zn={},Qa=typeof process<"u"&&Zn!==void 0&&(Zn.REACT_APP_SC_ATTR||Zn.SC_ATTR)||"data-styled",II="active",$I="data-styled-version",hp="6.1.13",Ax=`/*!sc*/ +`,af=typeof window<"u"&&"HTMLElement"in window,Vz=!!(typeof SC_DISABLE_SPEEDY=="boolean"?SC_DISABLE_SPEEDY:typeof process<"u"&&Zn!==void 0&&Zn.REACT_APP_SC_DISABLE_SPEEDY!==void 0&&Zn.REACT_APP_SC_DISABLE_SPEEDY!==""?Zn.REACT_APP_SC_DISABLE_SPEEDY!=="false"&&Zn.REACT_APP_SC_DISABLE_SPEEDY:typeof process<"u"&&Zn!==void 0&&Zn.SC_DISABLE_SPEEDY!==void 0&&Zn.SC_DISABLE_SPEEDY!==""&&Zn.SC_DISABLE_SPEEDY!=="false"&&Zn.SC_DISABLE_SPEEDY),Wz={},dp=Object.freeze([]),Za=Object.freeze({});function NI(t,e,n){return n===void 0&&(n=Za),t.theme!==n.theme&&t.theme||e||n.theme}var TI=new Set(["a","abbr","address","area","article","aside","audio","b","base","bdi","bdo","big","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","hr","html","i","iframe","img","input","ins","kbd","keygen","label","legend","li","link","main","map","mark","menu","menuitem","meta","meter","nav","noscript","object","ol","optgroup","option","output","p","param","picture","pre","progress","q","rp","rt","ruby","s","samp","script","section","select","small","source","span","strong","style","sub","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","tr","track","u","ul","use","var","video","wbr","circle","clipPath","defs","ellipse","foreignObject","g","image","line","linearGradient","marker","mask","path","pattern","polygon","polyline","radialGradient","rect","stop","svg","text","tspan"]),Uz=/[!"#$%&'()*+,./:;<=>?@[\\\]^`{|}~-]+/g,Gz=/(^-|-$)/g;function Gb(t){return t.replace(Uz,"-").replace(Gz,"")}var Hz=/(a)(d)/gi,Yh=52,Hb=function(t){return String.fromCharCode(t+(t>25?39:97))};function B0(t){var e,n="";for(e=Math.abs(t);e>Yh;e=e/Yh|0)n=Hb(e%Yh)+n;return(Hb(e%Yh)+n).replace(Hz,"$1-$2")}var xg,EI=5381,Na=function(t,e){for(var n=e.length;n;)t=33*t^e.charCodeAt(--n);return t},RI=function(t){return Na(EI,t)};function AI(t){return B0(RI(t)>>>0)}function jz(t){return t.displayName||t.name||"Component"}function yg(t){return typeof t=="string"&&!0}var DI=typeof Symbol=="function"&&Symbol.for,_I=DI?Symbol.for("react.memo"):60115,Kz=DI?Symbol.for("react.forward_ref"):60112,Xz={childContextTypes:!0,contextType:!0,contextTypes:!0,defaultProps:!0,displayName:!0,getDefaultProps:!0,getDerivedStateFromError:!0,getDerivedStateFromProps:!0,mixins:!0,propTypes:!0,type:!0},qz={name:!0,length:!0,prototype:!0,caller:!0,callee:!0,arguments:!0,arity:!0},FI={$$typeof:!0,compare:!0,defaultProps:!0,displayName:!0,propTypes:!0,type:!0},Yz=((xg={})[Kz]={$$typeof:!0,render:!0,defaultProps:!0,displayName:!0,propTypes:!0},xg[_I]=FI,xg);function jb(t){return("type"in(e=t)&&e.type.$$typeof)===_I?FI:"$$typeof"in t?Yz[t.$$typeof]:Xz;var e}var Qz=Object.defineProperty,Zz=Object.getOwnPropertyNames,Kb=Object.getOwnPropertySymbols,Jz=Object.getOwnPropertyDescriptor,eO=Object.getPrototypeOf,Xb=Object.prototype;function zI(t,e,n){if(typeof e!="string"){if(Xb){var s=eO(e);s&&s!==Xb&&zI(t,s,n)}var r=Zz(e);Kb&&(r=r.concat(Kb(e)));for(var o=jb(t),i=jb(e),a=0;a0?" Args: ".concat(e.join(", ")):""))}var tO=function(){function t(e){this.groupSizes=new Uint32Array(512),this.length=512,this.tag=e}return t.prototype.indexOfGroup=function(e){for(var n=0,s=0;s=this.groupSizes.length){for(var s=this.groupSizes,r=s.length,o=r;e>=o;)if((o<<=1)<0)throw hu(16,"".concat(e));this.groupSizes=new Uint32Array(o),this.groupSizes.set(s),this.length=o;for(var i=r;i=this.length||this.groupSizes[e]===0)return n;for(var s=this.groupSizes[e],r=this.indexOfGroup(e),o=r+s,i=r;i=0){var s=document.createTextNode(n);return this.element.insertBefore(s,this.nodes[e]||null),this.length++,!0}return!1},t.prototype.deleteRule=function(e){this.element.removeChild(this.nodes[e]),this.length--},t.prototype.getRule=function(e){return e0&&(x+="".concat(m,","))}),l+="".concat(p).concat(g,'{content:"').concat(x,'"}').concat(Ax)},u=0;u0?".".concat(e):d},u=l.slice();u.push(function(d){d.type===ap&&d.value.includes("&")&&(d.props[0]=d.props[0].replace(dO,n).replace(s,c))}),i.prefix&&u.push(Lz),u.push(Oz);var h=function(d,f,p,g){f===void 0&&(f=""),p===void 0&&(p=""),g===void 0&&(g="&"),e=g,n=f,s=new RegExp("\\".concat(n,"\\b"),"g");var x=d.replace(fO,""),m=Fz(p||f?"".concat(p," ").concat(f," { ").concat(x," }"):x);i.namespace&&(m=MI(m,i.namespace));var y=[];return of(m,Mz(u.concat(Pz(function(w){return y.push(w)})))),y};return h.hash=l.length?l.reduce(function(d,f){return f.name||hu(15),Na(d,f.name)},EI).toString():"",h}var mO=new cf,U0=pO(),PI=Gs.createContext({shouldForwardProp:void 0,styleSheet:mO,stylis:U0});PI.Consumer;Gs.createContext(void 0);function G0(){return ye.useContext(PI)}var gO=function(){function t(e,n){var s=this;this.inject=function(r,o){o===void 0&&(o=U0);var i=s.name+o.hash;r.hasNameForId(s.id,i)||r.insertRules(s.id,i,o(s.rules,i,"@keyframes"))},this.name=e,this.id="sc-keyframes-".concat(e),this.rules=n,_x(this,function(){throw hu(12,String(s.name))})}return t.prototype.getName=function(e){return e===void 0&&(e=U0),this.name+e.hash},t}(),xO=function(t){return t>="A"&&t<="Z"};function Qb(t){for(var e="",n=0;n>>0);if(!n.hasNameForId(this.componentId,i)){var a=s(o,".".concat(i),void 0,this.componentId);n.insertRules(this.componentId,i,a)}r=hi(r,i),this.staticRulesId=i}else{for(var l=Na(this.baseHash,s.hash),c="",u=0;u>>0);n.hasNameForId(this.componentId,f)||n.insertRules(this.componentId,f,s(c,".".concat(f),void 0,this.componentId)),r=hi(r,f)}}return r},t}(),Fx=Gs.createContext(void 0);Fx.Consumer;var wg={};function vO(t,e,n){var s=Dx(t),r=t,o=!yg(t),i=e.attrs,a=i===void 0?dp:i,l=e.componentId,c=l===void 0?function(v,b){var C=typeof v!="string"?"sc":Gb(v);wg[C]=(wg[C]||0)+1;var k="".concat(C,"-").concat(AI(hp+C+wg[C]));return b?"".concat(b,"-").concat(k):k}(e.displayName,e.parentComponentId):l,u=e.displayName,h=u===void 0?function(v){return yg(v)?"styled.".concat(v):"Styled(".concat(jz(v),")")}(t):u,d=e.displayName&&e.componentId?"".concat(Gb(e.displayName),"-").concat(e.componentId):e.componentId||c,f=s&&r.attrs?r.attrs.concat(a).filter(Boolean):a,p=e.shouldForwardProp;if(s&&r.shouldForwardProp){var g=r.shouldForwardProp;if(e.shouldForwardProp){var x=e.shouldForwardProp;p=function(v,b){return g(v,b)&&x(v,b)}}else p=g}var m=new wO(n,d,s?r.componentStyle:void 0);function y(v,b){return function(C,k,S){var $=C.attrs,N=C.componentStyle,A=C.defaultProps,M=C.foldedComponentIds,L=C.styledComponentId,V=C.target,B=Gs.useContext(Fx),U=G0(),K=C.shouldForwardProp||U.shouldForwardProp,R=NI(k,B,A)||Za,O=function(Z,se,ie){for(var ce,ue=bn(bn({},se),{className:void 0,theme:ie}),xe=0;xe2&&cf.registerId(this.componentId+e),this.removeStyles(e,s),this.createStyles(e,n,s,r)},t}();function GI(t){for(var e=[],n=1;nDe.jsxs(SO,{children:[De.jsx(IO,{children:"MasterPlan"}),De.jsx($O,{onClick:t,"aria-label":"Start the game",children:"Play"})]});function TO(t,e){var n=ye.useRef(!1),s=ye.useRef(),r=ye.useRef(t),o=ye.useCallback(function(){return n.current},[]),i=ye.useCallback(function(){n.current=!1,s.current&&clearTimeout(s.current),s.current=setTimeout(function(){n.current=!0,r.current()},e)},[e]),a=ye.useCallback(function(){n.current=null,s.current&&clearTimeout(s.current)},[]);return ye.useEffect(function(){r.current=t},[t]),ye.useEffect(function(){return i(),a},[e]),[o,a,i]}function EO(t,e,n){n===void 0&&(n=[]);var s=TO(t,e),r=s[0],o=s[1],i=s[2];return ye.useEffect(i,n),[r,o]}function RO(t,e){e===void 0&&(e=!0);var n=ye.useRef(null),s=ye.useRef(!1),r=ye.useRef(t);r.current=t;var o=ye.useCallback(function(a){s.current&&(r.current(a),n.current=requestAnimationFrame(o))},[]),i=ye.useMemo(function(){return[function(){s.current&&(s.current=!1,n.current&&cancelAnimationFrame(n.current))},function(){s.current||(s.current=!0,n.current=requestAnimationFrame(o))},function(){return s.current}]},[]);return ye.useEffect(function(){return e&&i[1](),i[0]},[]),i}const AO=10,eC=100,du="layer-default",ws=800,hf=100,is=32,Ur=32,yi=1600,wi=800,So=yi/is,Io=wi/Ur,DO=10,j0=is+DO,tC=600,_O=250,nC=300,sC=500,FO=is*5,rC=1e3,oC=is/3,za=is*4,HI=1500,zO=1e3,el=Math.floor(So/2),tl=Math.floor(Io/2),OO="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH4gkDEigyAtVVggAAABl0RVh0Q29tbWVudABDcmVhdGVkIHdpdGggR0lNUFeBDhcAAAB4SURBVFjD7VfLDsAgCIOF///l7rSTizp5aJZyMxFtoMUqsjnUmQ/vudfuChBAVKDDh7MroAsMD73bgqSKhb1UAQHIQ0J8II2yBRktqBzXzboSgL4NLcsgFklIAJUyRI/hv/aEIw847RHNWfLjXS8ow4xXrOzTUhI3cssYNHqG9WQAAAAASUVORK5CYII=",MO="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH4gkDEigk9gHg0wAAABl0RVh0Q29tbWVudABDcmVhdGVkIHdpdGggR0lNUFeBDhcAAACySURBVFjD1VZbDsAgCLPE+1+5+13cIqI8Nn7JpNAW1lpx4PB7brzLe16SG34AloLiqADAjAJUir/mJQHYVOjdeZS0uqw7WXcU2DLnUjH2SACm4hEAzJtVkjzOKABURKlORw461vheoqNvcMxFsTFSAzDm4bkJYaAJnraZFaeHJU9vAKMWx+zA8LRrOEwCFs49bPipGLk3a0HaT0PrdHkSu79k+FrH2/egXAPyF8FV0JcTF5HDMyNBbtWDAAAAAElFTkSuQmCC",PO="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH4gkJDBsdJGpj9QAAABl0RVh0Q29tbWVudABDcmVhdGVkIHdpdGggR0lNUFeBDhcAAACjSURBVFjD7VbREoAgCHMe///L6zW9wgLErpOnNLkNnACKzfjwHEYHallsHgLwRP6LDISYOHx5SjW71LNEqXT2K0AAiMcgCUDQMDJEyFkitOiMuw5sAqsJoP+WRHBerWVB9E3f2CLcBMTxjLRGkzITsgOEZZaoL9iaACJSikHkWnYw+idKsbAAa4Oru4wyyK/Zqy/Fll4HosBvrw8WJ2cXRPmSHSqNI0GjWZKJAAAAAElFTkSuQmCC",LO="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgAQMAAABJtOi3AAAABlBMVEUAAAAAAAClZ7nPAAAAAXRSTlMAQObYZgAAAAFiS0dEAIgFHUgAAAAJcEhZcwAACxMAAAsTAQCanBgAAAAHdElNRQfiCQwTIjRI+GJcAAAAGXRFWHRDb21tZW50AENyZWF0ZWQgd2l0aCBHSU1QV4EOFwAAAGtJREFUCNdjYCAHJICIG0DMeAJIMD8BEux/QMQPIMH/gYHxg/wDBiYP+wMMrCH1DAwsT/4B5f4CVbD8/9/AwBr+yYGByf/VAgbG//8VGBjk9z9gYNinDmTVaC1gYLAQcmBgEOBvYGDgYGAAAKEvGyWBDTuGAAAAAElFTkSuQmCC",K0={warrior:OO,archer:MO,tank:PO,artillery:LO},BO=t=>new Promise((e,n)=>{const s=new Image;s.onload=()=>e(s),s.onerror=n,s.src=t}),zx=Gs.memo(({width:t,height:e,cellWidth:n,cellHeight:s,units:r,selectedUnitId:o,onMouseDown:i,onMouseMove:a,onMouseUp:l,onTouchStart:c,onTouchMove:u,onTouchEnd:h,onCellClick:d,isPlayerArea:f})=>{const p=ye.useRef(null),[g,x]=ye.useState({});ye.useEffect(()=>{(async()=>{const b={};for(const[C,k]of Object.entries(K0))try{b[C]=await BO(k)}catch(S){console.error(`Failed to load image for ${C}:`,S)}x(b)})()},[]);const m=ye.useCallback(v=>{v.strokeStyle="#ccc",v.lineWidth=1;for(let b=0;b<=t;b+=n)v.beginPath(),v.moveTo(b,0),v.lineTo(b,e),v.stroke();for(let b=0;b<=e;b+=s)v.beginPath(),v.moveTo(0,b),v.lineTo(t,b),v.stroke()},[t,e,n,s]),y=ye.useCallback(v=>{r.forEach(b=>{const C=(b.col+el)*n,k=(b.row+tl)*s,S=b.sizeCol*n,$=b.sizeRow*s;if(g[b.type])for(let N=0;N{const v=p.current;if(!v)return;const b=v.getContext("2d");b&&(b.clearRect(0,0,t,e),m(b),y(b))},[t,e,n,s,r,o,g,m,y]);const w=ye.useCallback(v=>{if(!f)return;const b=p.current;if(!b)return;const C=b.getBoundingClientRect(),k=(v.clientX-C.left)*(b.width/C.width),S=(v.clientY-C.top)*(b.height/C.height),$=Math.floor(k/n)-el,N=Math.floor(S/s)-tl;d($,N)},[n,s,d,f]);return De.jsx(VO,{ref:p,"data-is-player-area":f,width:t,height:e,onClick:w,onMouseDown:i,onMouseMove:a,onMouseUp:l,onTouchStart:c,onTouchMove:u,onTouchEnd:h})});zx.displayName="CanvasGrid";const VO=In.canvas` +`,$O=({onPlayClick:t})=>De.jsxs(kO,{children:[De.jsx(SO,{children:"MasterPlan"}),De.jsx(IO,{onClick:t,"aria-label":"Start the game",children:"Play"})]});function NO(t,e){var n=ye.useRef(!1),s=ye.useRef(),r=ye.useRef(t),o=ye.useCallback(function(){return n.current},[]),i=ye.useCallback(function(){n.current=!1,s.current&&clearTimeout(s.current),s.current=setTimeout(function(){n.current=!0,r.current()},e)},[e]),a=ye.useCallback(function(){n.current=null,s.current&&clearTimeout(s.current)},[]);return ye.useEffect(function(){r.current=t},[t]),ye.useEffect(function(){return i(),a},[e]),[o,a,i]}function TO(t,e,n){n===void 0&&(n=[]);var s=NO(t,e),r=s[0],o=s[1],i=s[2];return ye.useEffect(i,n),[r,o]}function EO(t,e){e===void 0&&(e=!0);var n=ye.useRef(null),s=ye.useRef(!1),r=ye.useRef(t);r.current=t;var o=ye.useCallback(function(a){s.current&&(r.current(a),n.current=requestAnimationFrame(o))},[]),i=ye.useMemo(function(){return[function(){s.current&&(s.current=!1,n.current&&cancelAnimationFrame(n.current))},function(){s.current||(s.current=!0,n.current=requestAnimationFrame(o))},function(){return s.current}]},[]);return ye.useEffect(function(){return e&&i[1](),i[0]},[]),i}const RO=10,eC=100,fp="layer-default",ws=800,uf=100,is=32,Ur=32,yi=1600,wi=800,So=yi/is,Io=wi/Ur,AO=10,j0=is+AO,tC=600,DO=250,nC=300,sC=500,_O=is*5,rC=1e3,oC=is/3,za=is*4,HI=1500,FO=1e3,el=Math.floor(So/2),tl=Math.floor(Io/2),zO="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH4gkDEigyAtVVggAAABl0RVh0Q29tbWVudABDcmVhdGVkIHdpdGggR0lNUFeBDhcAAAB4SURBVFjD7VfLDsAgCIOF///l7rSTizp5aJZyMxFtoMUqsjnUmQ/vudfuChBAVKDDh7MroAsMD73bgqSKhb1UAQHIQ0J8II2yBRktqBzXzboSgL4NLcsgFklIAJUyRI/hv/aEIw847RHNWfLjXS8ow4xXrOzTUhI3cssYNHqG9WQAAAAASUVORK5CYII=",OO="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH4gkDEigk9gHg0wAAABl0RVh0Q29tbWVudABDcmVhdGVkIHdpdGggR0lNUFeBDhcAAACySURBVFjD1VZbDsAgCLPE+1+5+13cIqI8Nn7JpNAW1lpx4PB7brzLe16SG34AloLiqADAjAJUir/mJQHYVOjdeZS0uqw7WXcU2DLnUjH2SACm4hEAzJtVkjzOKABURKlORw461vheoqNvcMxFsTFSAzDm4bkJYaAJnraZFaeHJU9vAKMWx+zA8LRrOEwCFs49bPipGLk3a0HaT0PrdHkSu79k+FrH2/egXAPyF8FV0JcTF5HDMyNBbtWDAAAAAElFTkSuQmCC",MO="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH4gkJDBsdJGpj9QAAABl0RVh0Q29tbWVudABDcmVhdGVkIHdpdGggR0lNUFeBDhcAAACjSURBVFjD7VbREoAgCHMe///L6zW9wgLErpOnNLkNnACKzfjwHEYHallsHgLwRP6LDISYOHx5SjW71LNEqXT2K0AAiMcgCUDQMDJEyFkitOiMuw5sAqsJoP+WRHBerWVB9E3f2CLcBMTxjLRGkzITsgOEZZaoL9iaACJSikHkWnYw+idKsbAAa4Oru4wyyK/Zqy/Fll4HosBvrw8WJ2cXRPmSHSqNI0GjWZKJAAAAAElFTkSuQmCC",PO="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgAQMAAABJtOi3AAAABlBMVEUAAAAAAAClZ7nPAAAAAXRSTlMAQObYZgAAAAFiS0dEAIgFHUgAAAAJcEhZcwAACxMAAAsTAQCanBgAAAAHdElNRQfiCQwTIjRI+GJcAAAAGXRFWHRDb21tZW50AENyZWF0ZWQgd2l0aCBHSU1QV4EOFwAAAGtJREFUCNdjYCAHJICIG0DMeAJIMD8BEux/QMQPIMH/gYHxg/wDBiYP+wMMrCH1DAwsT/4B5f4CVbD8/9/AwBr+yYGByf/VAgbG//8VGBjk9z9gYNinDmTVaC1gYLAQcmBgEOBvYGDgYGAAAKEvGyWBDTuGAAAAAElFTkSuQmCC",K0={warrior:zO,archer:OO,tank:MO,artillery:PO},LO=t=>new Promise((e,n)=>{const s=new Image;s.onload=()=>e(s),s.onerror=n,s.src=t}),zx=Gs.memo(({width:t,height:e,cellWidth:n,cellHeight:s,units:r,selectedUnitId:o,onMouseDown:i,onMouseMove:a,onMouseUp:l,onTouchStart:c,onTouchMove:u,onTouchEnd:h,onCellClick:d,isPlayerArea:f})=>{const p=ye.useRef(null),[g,x]=ye.useState({});ye.useEffect(()=>{(async()=>{const b={};for(const[C,k]of Object.entries(K0))try{b[C]=await LO(k)}catch(S){console.error(`Failed to load image for ${C}:`,S)}x(b)})()},[]);const m=ye.useCallback(v=>{v.strokeStyle="#ccc",v.lineWidth=1;for(let b=0;b<=t;b+=n)v.beginPath(),v.moveTo(b,0),v.lineTo(b,e),v.stroke();for(let b=0;b<=e;b+=s)v.beginPath(),v.moveTo(0,b),v.lineTo(t,b),v.stroke()},[t,e,n,s]),y=ye.useCallback(v=>{r.forEach(b=>{const C=(b.col+el)*n,k=(b.row+tl)*s,S=b.sizeCol*n,$=b.sizeRow*s;if(g[b.type])for(let N=0;N{const v=p.current;if(!v)return;const b=v.getContext("2d");b&&(b.clearRect(0,0,t,e),m(b),y(b))},[t,e,n,s,r,o,g,m,y]);const w=ye.useCallback(v=>{if(!f)return;const b=p.current;if(!b)return;const C=b.getBoundingClientRect(),k=(v.clientX-C.left)*(b.width/C.width),S=(v.clientY-C.top)*(b.height/C.height),$=Math.floor(k/n)-el,N=Math.floor(S/s)-tl;d($,N)},[n,s,d,f]);return De.jsx(BO,{ref:p,"data-is-player-area":f,width:t,height:e,onClick:w,onMouseDown:i,onMouseMove:a,onMouseUp:l,onTouchStart:c,onTouchMove:u,onTouchEnd:h})});zx.displayName="CanvasGrid";const BO=In.canvas` position: absolute; transform: translate(-50%, -50%); left: 50%; top: 50%; max-width: 90vw; max-height: 50vh; -`,iC=(t,e)=>({x:(t+el)*is,y:(e+tl)*Ur}),aC=(t,e)=>({col:Math.floor(t/is)-el,row:Math.floor(e/Ur)-tl}),WO=(t,e)=>{const[n,s]=ye.useState({isDragging:!1,draggedUnit:null,dragOffset:{x:0,y:0}}),r=ye.useCallback(l=>"touches"in l?{clientX:l.touches[0].clientX,clientY:l.touches[0].clientY}:{clientX:l.clientX,clientY:l.clientY},[]),o=ye.useCallback(l=>{const c=l.currentTarget,u=c.getBoundingClientRect(),{clientX:h,clientY:d}=r(l),{col:f,row:p}=aC((h-u.left)*(c.width/u.width),(d-u.top)*(c.height/u.height)),g=t.find(x=>f>=x.col&&f=x.row&&p{if(n.isDragging&&n.draggedUnit){const c=l.currentTarget,u=c.getBoundingClientRect(),{clientX:h,clientY:d}=r(l),{col:f,row:p}=aC((h-u.left)*(c.width/u.width)-n.dragOffset.x,(d-u.top)*(c.height/u.height)-n.dragOffset.y);e(g=>g.map(x=>x.id===n.draggedUnit.id?{...x,col:Math.max(-el,Math.min(f,So-el-x.sizeCol)),row:Math.max(-tl,Math.min(p,Io-tl-x.sizeRow))}:x))}},[n,e,r]),a=ye.useCallback(()=>{s({isDragging:!1,draggedUnit:null,dragOffset:{x:0,y:0}})},[]);return{isDragging:n.isDragging,handleDragStart:o,handleDragMove:i,handleDragEnd:a}},UO=t=>{const[e,n]=ye.useState(null),s=ye.useCallback((o,i)=>{const a=t.find(l=>o>=l.col&&o=l.row&&i{n(null)},[]);return{selectedUnit:e,handleUnitSelect:s,setSelectedUnit:n,clearSelection:r}};function lC(t,e){if(e.length===0)throw new Error("No AI plans available for selection");const n=e.map(r=>({plan:r,score:r.probabilityScore(t)}));n.sort((r,o)=>o.score-r.score);const s=n[0].plan;return console.log("Selected plan:",s.name,"with score:",n[0].score),console.log("All plan scores:"),n.forEach(({plan:r,score:o})=>{console.log(`${r.name}: ${o}`)}),s.units}function Qe(t){return t.reduce((e,n)=>(e[n.type]=(e[n.type]||0)+1,e),{tank:0,warrior:0,archer:0,artillery:0})}function nt(t){const e={left:0,center:0,right:0,front:0};t.forEach(s=>{s.col<-5?e.left++:s.col>5?e.right++:e.center++,s.row>-5&&e.front++});const n=t.length;return{left:e.left/n,center:e.center/n,right:e.right/n,front:e.front/n}}function lt(t){return t.length===0?0:t.reduce((n,s)=>n+s.sizeCol*s.sizeRow,0)/(t.length*16)}function At(t){const e=t.map(i=>({x:i.col,y:i.row})),n=e.reduce((i,a)=>i+a.x,0)/e.length,s=e.reduce((i,a)=>i+a.y,0)/e.length,r=Math.sqrt(32*32+18*18);return e.reduce((i,a)=>{const l=a.x-n,c=a.y-s;return i+Math.sqrt(l*l+c*c)},0)/e.length/r}const Ox=[{id:201,col:-12,row:0,sizeCol:8,sizeRow:2,type:"warrior",command:"advance-wait"},{id:202,col:0,row:0,sizeCol:8,sizeRow:2,type:"warrior",command:"advance-wait"},{id:203,col:12,row:0,sizeCol:8,sizeRow:2,type:"warrior",command:"advance-wait"},{id:204,col:-8,row:-4,sizeCol:4,sizeRow:4,type:"tank",command:"advance"},{id:205,col:8,row:-4,sizeCol:4,sizeRow:4,type:"tank",command:"advance"},{id:206,col:-16,row:-8,sizeCol:4,sizeRow:2,type:"archer",command:"wait-advance"},{id:207,col:16,row:-8,sizeCol:4,sizeRow:2,type:"archer",command:"wait-advance"},{id:208,col:2,row:-8,sizeCol:8,sizeRow:1,type:"artillery",command:"wait-advance"}],GO="Balanced Assault",HO=t=>{const e=Qe(t),n=nt(t),s=1-Math.abs(.25-e.warrior/t.length)-Math.abs(.25-e.archer/t.length)-Math.abs(.25-e.tank/t.length)-Math.abs(.25-e.artillery/t.length),r=(n.left+n.right+n.center)/3,o=1-Math.abs(.5-lt(t));return(s*.5+r*.3+o*.2)*100},jO=Object.freeze(Object.defineProperty({__proto__:null,name:GO,probabilityScore:HO,units:Ox},Symbol.toStringTag,{value:"Module"})),KO=[{id:301,col:-16,row:0,sizeCol:4,sizeRow:2,type:"archer",command:"wait-advance"},{id:302,col:16,row:0,sizeCol:4,sizeRow:2,type:"archer",command:"wait-advance"},{id:303,col:0,row:-4,sizeCol:8,sizeRow:3,type:"artillery",command:"advance-wait"},{id:304,col:-12,row:-2,sizeCol:6,sizeRow:2,type:"warrior",command:"advance"},{id:305,col:12,row:-2,sizeCol:6,sizeRow:2,type:"warrior",command:"advance"},{id:306,col:-8,row:-6,sizeCol:4,sizeRow:3,type:"tank",command:"advance"},{id:307,col:8,row:-6,sizeCol:4,sizeRow:3,type:"tank",command:"advance"}],XO="Anti-Tank Defense",qO=t=>{const e=Qe(t),n=nt(t),s=e.tank/t.length,r=Math.min(s*2,1),o=n.center,i=lt(t.filter(a=>a.type==="tank"));return(r*.5+o*.3+i*.2)*100},YO=Object.freeze(Object.defineProperty({__proto__:null,name:XO,probabilityScore:qO,units:KO},Symbol.toStringTag,{value:"Module"})),QO=[{id:401,col:-12,row:-2,sizeCol:4,sizeRow:2,type:"tank",command:"flank-left"},{id:402,col:12,row:-2,sizeCol:4,sizeRow:2,type:"tank",command:"flank-right"},{id:403,col:0,row:-6,sizeCol:6,sizeRow:3,type:"artillery",command:"wait-advance"},{id:404,col:-16,row:0,sizeCol:6,sizeRow:2,type:"warrior",command:"advance"},{id:405,col:16,row:0,sizeCol:6,sizeRow:2,type:"warrior",command:"advance"},{id:406,col:-8,row:-10,sizeCol:4,sizeRow:3,type:"tank",command:"advance"},{id:407,col:8,row:-10,sizeCol:4,sizeRow:3,type:"tank",command:"advance"},{id:408,col:-4,row:-4,sizeCol:4,sizeRow:2,type:"warrior",command:"advance"},{id:409,col:4,row:-4,sizeCol:4,sizeRow:2,type:"warrior",command:"advance"}],ZO="Archer Counter",JO=t=>{const e=Qe(t),n=nt(t),s=e.archer/t.length,r=Math.min(s*2,1),o=Math.max(n.left,n.right),i=1-lt(t.filter(a=>a.type==="archer"));return(r*.5+o*.3+i*.2)*100},e3=Object.freeze(Object.defineProperty({__proto__:null,name:ZO,probabilityScore:JO,units:QO},Symbol.toStringTag,{value:"Module"})),t3=[{id:501,col:-12,row:0,sizeCol:6,sizeRow:2,type:"warrior",command:"advance"},{id:502,col:12,row:0,sizeCol:6,sizeRow:2,type:"warrior",command:"advance"},{id:503,col:-8,row:-4,sizeCol:4,sizeRow:2,type:"archer",command:"flank-left"},{id:504,col:8,row:-4,sizeCol:4,sizeRow:2,type:"archer",command:"flank-right"},{id:505,col:-16,row:-2,sizeCol:6,sizeRow:2,type:"warrior",command:"advance"},{id:506,col:16,row:-2,sizeCol:6,sizeRow:2,type:"warrior",command:"advance"},{id:507,col:0,row:-6,sizeCol:6,sizeRow:3,type:"artillery",command:"wait-advance"},{id:508,col:-4,row:-2,sizeCol:4,sizeRow:2,type:"warrior",command:"advance"},{id:509,col:4,row:-2,sizeCol:4,sizeRow:2,type:"warrior",command:"advance"}],n3="Warrior Blitz",s3=t=>{const e=Qe(t),n=nt(t),s=e.tank/t.length,r=(e.warrior+e.archer)/t.length,o=(1-s)*.5+r*.5,i=n.center,a=1-lt(t);return(o*.4+i*.4+a*.2)*100},r3=Object.freeze(Object.defineProperty({__proto__:null,name:n3,probabilityScore:s3,units:t3},Symbol.toStringTag,{value:"Module"})),o3=[{id:601,col:-12,row:-4,sizeCol:4,sizeRow:4,type:"tank",command:"advance-wait"},{id:602,col:12,row:-4,sizeCol:4,sizeRow:4,type:"tank",command:"advance-wait"},{id:603,col:-16,row:0,sizeCol:8,sizeRow:2,type:"warrior",command:"advance"},{id:604,col:16,row:0,sizeCol:8,sizeRow:2,type:"warrior",command:"advance"},{id:605,col:0,row:-8,sizeCol:8,sizeRow:2,type:"artillery",command:"wait-advance"},{id:606,col:-8,row:-10,sizeCol:4,sizeRow:2,type:"archer",command:"wait-advance"},{id:607,col:8,row:-10,sizeCol:4,sizeRow:2,type:"archer",command:"wait-advance"},{id:608,col:0,row:-12,sizeCol:8,sizeRow:2,type:"artillery",command:"wait-advance"},{id:609,col:0,row:-2,sizeCol:8,sizeRow:2,type:"warrior",command:"advance"}],i3="Tank Formation",a3=t=>{const e=Qe(t),n=nt(t),s=(e.warrior+e.archer)/t.length,r=Math.min(s*1.5,1),o=1-n.center,i=1-lt(t);return(r*.4+o*.4+i*.2)*100},l3=Object.freeze(Object.defineProperty({__proto__:null,name:i3,probabilityScore:a3,units:o3},Symbol.toStringTag,{value:"Module"})),c3=[{id:701,col:-16,row:-4,sizeCol:6,sizeRow:3,type:"artillery",command:"advance"},{id:702,col:16,row:-4,sizeCol:6,sizeRow:3,type:"artillery",command:"advance"},{id:703,col:0,row:0,sizeCol:6,sizeRow:3,type:"tank",command:"advance-wait"},{id:704,col:-8,row:-10,sizeCol:4,sizeRow:2,type:"archer",command:"wait-advance"},{id:705,col:8,row:-10,sizeCol:4,sizeRow:2,type:"archer",command:"wait-advance"},{id:706,col:-12,row:-12,sizeCol:4,sizeRow:3,type:"tank",command:"advance"},{id:707,col:12,row:-12,sizeCol:4,sizeRow:3,type:"tank",command:"advance"},{id:708,col:0,row:-6,sizeCol:6,sizeRow:2,type:"warrior",command:"advance"}],u3="Artillery Strike",h3=t=>{const e=Qe(t),n=nt(t),s=(e.tank+e.artillery)/t.length,r=Math.min(s*2,1),o=Math.max(n.left,n.center,n.right),i=lt(t);return(r*.4+o*.4+i*.2)*100},d3=Object.freeze(Object.defineProperty({__proto__:null,name:u3,probabilityScore:h3,units:c3},Symbol.toStringTag,{value:"Module"})),f3=[{id:801,col:-16,row:-4,sizeCol:4,sizeRow:2,type:"archer",command:"wait-advance"},{id:802,col:-8,row:-4,sizeCol:4,sizeRow:2,type:"archer",command:"wait-advance"},{id:803,col:0,row:-4,sizeCol:4,sizeRow:2,type:"archer",command:"wait-advance"},{id:804,col:8,row:-4,sizeCol:4,sizeRow:2,type:"archer",command:"wait-advance"},{id:805,col:16,row:-4,sizeCol:4,sizeRow:2,type:"archer",command:"wait-advance"},{id:806,col:-12,row:-10,sizeCol:4,sizeRow:4,type:"tank",command:"advance"},{id:807,col:12,row:-10,sizeCol:4,sizeRow:4,type:"tank",command:"advance"},{id:808,col:0,row:-14,sizeCol:8,sizeRow:2,type:"artillery",command:"wait-advance"},{id:809,col:-20,row:-6,sizeCol:4,sizeRow:2,type:"archer",command:"wait-advance"},{id:810,col:20,row:-6,sizeCol:4,sizeRow:2,type:"archer",command:"wait-advance"},{id:811,col:-4,row:-8,sizeCol:4,sizeRow:2,type:"warrior",command:"advance"},{id:812,col:4,row:-8,sizeCol:4,sizeRow:2,type:"warrior",command:"advance"}],p3="Archer Ambush",m3=t=>{const e=Qe(t),n=nt(t),s=(e.warrior+e.tank)/t.length,r=Math.min(s*1.5,1),o=n.center+n.front*.5,i=lt(t);return(r*.4+o*.4+i*.2)*100},g3=Object.freeze(Object.defineProperty({__proto__:null,name:p3,probabilityScore:m3,units:f3},Symbol.toStringTag,{value:"Module"})),x3=[{id:301,col:-16,row:-8,sizeCol:4,sizeRow:2,type:"archer",command:"wait-advance"},{id:302,col:-8,row:-8,sizeCol:4,sizeRow:2,type:"archer",command:"wait-advance"},{id:303,col:8,row:-8,sizeCol:4,sizeRow:2,type:"archer",command:"wait-advance"},{id:304,col:16,row:-8,sizeCol:4,sizeRow:2,type:"archer",command:"wait-advance"},{id:305,col:-12,row:-4,sizeCol:8,sizeRow:2,type:"artillery",command:"wait-advance"},{id:306,col:12,row:-4,sizeCol:8,sizeRow:2,type:"artillery",command:"wait-advance"},{id:307,col:-8,row:0,sizeCol:4,sizeRow:4,type:"tank",command:"wait-advance"},{id:308,col:8,row:0,sizeCol:4,sizeRow:4,type:"tank",command:"wait-advance"},{id:309,col:0,row:-2,sizeCol:6,sizeRow:2,type:"warrior",command:"advance"},{id:310,col:-16,row:-2,sizeCol:4,sizeRow:2,type:"warrior",command:"flank-left"},{id:311,col:16,row:-2,sizeCol:4,sizeRow:2,type:"warrior",command:"flank-right"}],y3="Warrior Counter",w3=t=>{const e=Qe(t),n=t.length,s=(e.warrior||0)/n,r=At(t),o=Math.min(s*2,1),i=1-r,a=1-lt(t.filter(l=>l.type==="warrior"));return(o*.5+i*.3+a*.2)*100},v3=Object.freeze(Object.defineProperty({__proto__:null,name:y3,probabilityScore:w3,units:x3},Symbol.toStringTag,{value:"Module"})),b3=[{id:301,col:-6,row:0,sizeCol:4,sizeRow:4,type:"tank",command:"advance"},{id:302,col:6,row:0,sizeCol:4,sizeRow:4,type:"tank",command:"advance"},{id:303,col:-10,row:-4,sizeCol:3,sizeRow:2,type:"warrior",command:"advance"},{id:304,col:-5,row:-4,sizeCol:3,sizeRow:2,type:"warrior",command:"advance"},{id:305,col:0,row:-4,sizeCol:3,sizeRow:2,type:"warrior",command:"advance"},{id:306,col:5,row:-4,sizeCol:3,sizeRow:2,type:"warrior",command:"advance"},{id:307,col:10,row:-4,sizeCol:3,sizeRow:2,type:"warrior",command:"advance"},{id:308,col:-12,row:-8,sizeCol:4,sizeRow:2,type:"archer",command:"wait-advance"},{id:309,col:0,row:-8,sizeCol:4,sizeRow:2,type:"archer",command:"wait-advance"},{id:310,col:12,row:-8,sizeCol:4,sizeRow:2,type:"archer",command:"wait-advance"},{id:311,col:-12,row:-12,sizeCol:8,sizeRow:2,type:"artillery",command:"wait-advance"},{id:312,col:12,row:-12,sizeCol:8,sizeRow:2,type:"artillery",command:"wait-advance"}],C3="Artillery Counter",k3=t=>{const e=Qe(t),n=nt(t),s=Math.min(e.artillery/t.length,.5)*2,r=n.center,o=lt(t);return(s*.6+r*.2+o*.2)*100},S3=Object.freeze(Object.defineProperty({__proto__:null,name:C3,probabilityScore:k3,units:b3},Symbol.toStringTag,{value:"Module"})),Rd=[...[...Array(10)].map((t,e)=>({id:e,type:"warrior",col:-2+e%5,row:-4+Math.floor(e/5),sizeCol:2,sizeRow:2,command:"advance"})),...[...Array(5)].map((t,e)=>({id:e+10,type:"archer",col:-2+e,row:-2,sizeCol:2,sizeRow:2,command:"advance"})),...[...Array(3)].map((t,e)=>({id:e+15,type:"artillery",col:-3+e*3,row:0,sizeCol:3,sizeRow:2,command:"advance"})),...[...Array(4)].map((t,e)=>({id:e+18,type:"warrior",col:e<2?-4:4,row:-5+e%2*2,sizeCol:2,sizeRow:2,command:"advance"})),...[...Array(4)].map((t,e)=>({id:e+22,type:"archer",col:e<2?-5:5,row:-4+e%2*2,sizeCol:2,sizeRow:2,command:"advance"}))],I3="Phalanx Formation";function $3(t){const e=Qe(Rd),n=Qe(t),s=nt(Rd),r=nt(t),o=At(Rd),i=At(t);let a=.5;return a+=(e.warrior-n.warrior)*.02,a+=(n.tank-e.tank)*.03,a+=(s.center-r.center)*.1,a+=(i-o)*.1,a-=Math.max(0,n.archer-e.archer)*.01,a-=Math.max(0,n.artillery-e.artillery)*.01,Math.max(0,Math.min(1,a))}const N3=Object.freeze(Object.defineProperty({__proto__:null,name:I3,probabilityScore:$3,units:Rd},Symbol.toStringTag,{value:"Module"})),tc=[...[...Array(5)].map((t,e)=>({id:e,type:"tank",col:Math.floor(e/2)-1,row:-6+e%2+Math.floor(e/2),sizeCol:3,sizeRow:3,command:"advance"})),...[...Array(3)].map((t,e)=>({id:e+5,type:"tank",col:(e-1)*2,row:-2,sizeCol:3,sizeRow:3,command:"advance"})),...[...Array(2)].map((t,e)=>({id:e+8,type:"artillery",col:e*4-2,row:2,sizeCol:3,sizeRow:2,command:"advance"})),...[...Array(4)].map((t,e)=>({id:e+10,type:"warrior",col:e<2?-6:6,row:-4+e%2*2,sizeCol:2,sizeRow:2,command:"advance"}))],T3="Cavalry Charge";function E3(t){const e=Qe(tc),n=Qe(t),s=nt(tc),r=nt(t),o=lt(tc),i=lt(t),a=At(tc),l=At(t);let c=.5;return c+=(e.tank-n.tank)*.03,c-=(n.warrior+n.artillery)*.02,c+=(s.front-r.front)*.1,c+=(l-a)*.1,c+=(o-i)*.2,c+=Math.max(0,n.archer-e.archer)*.01,Math.max(0,Math.min(1,c))}const R3=Object.freeze(Object.defineProperty({__proto__:null,name:T3,probabilityScore:E3,units:tc},Symbol.toStringTag,{value:"Module"})),nc=[...[...Array(7)].map((t,e)=>({id:e,type:"artillery",col:e*3-9,row:2,sizeCol:3,sizeRow:2,command:"advance"})),...[...Array(4)].map((t,e)=>({id:e+7,type:"artillery",col:e*4-6,row:0,sizeCol:3,sizeRow:2,command:"advance"})),...[...Array(3)].map((t,e)=>({id:e+11,type:"tank",col:e*6-6,row:-4,sizeCol:4,sizeRow:3,command:"wait-advance"})),...[...Array(5)].map((t,e)=>({id:e+14,type:"warrior",col:e*4-8,row:-6,sizeCol:3,sizeRow:2,command:"wait-advance"}))],A3="Artillery Barrage";function D3(t){const e=Qe(nc),n=Qe(t),s=nt(nc),r=nt(t),o=lt(nc),i=lt(t),a=At(nc),l=At(t);let c=.5;return c+=(e.artillery-n.artillery)*.04,c-=(n.tank+n.warrior)*.02,c+=(l-a)*.15,c+=(r.front-s.front)*.1,c+=(i-o)*.1,c+=Math.max(0,n.archer-e.archer)*.02,c-=Math.max(0,n.tank-e.tank)*.03,Math.max(0,Math.min(1,c))}const _3=Object.freeze(Object.defineProperty({__proto__:null,name:A3,probabilityScore:D3,units:nc},Symbol.toStringTag,{value:"Module"})),Jo=(t,e,n)=>[{id:t,type:"warrior",col:e-1,row:n-1,sizeCol:2,sizeRow:2,command:"advance"},{id:t+1,type:"archer",col:e,row:n,sizeCol:2,sizeRow:2,command:"advance"},{id:t+2,type:"tank",col:e+1,row:n+1,sizeCol:3,sizeRow:3,command:"advance"}],Ad=[...Jo(0,-10,-5),...Jo(3,0,-6),...Jo(6,10,-5),...Jo(9,-8,0),...Jo(12,8,0),...Jo(15,-5,5),...Jo(18,5,5),...[...Array(2)].map((t,e)=>({id:21+e,type:"artillery",col:e*10-5,row:8,sizeCol:3,sizeRow:2,command:"advance"}))],F3="Guerrilla Tactics";function z3(t){const e=Qe(Ad),n=Qe(t),s=nt(t),r=lt(Ad),o=lt(t),i=At(Ad),a=At(t);let l=.5;l+=(i-a)*.2,l+=(Math.abs(s.front-.5)+Math.abs(s.center-.5))*.15,l+=(o-r)*.15;const c=Math.min(e.warrior,e.archer,e.tank,e.artillery)/Math.max(e.warrior,e.archer,e.tank,e.artillery);l+=c*.1;const u=Math.max(n.warrior-e.warrior,n.archer-e.archer,n.tank-e.tank,n.artillery-e.artillery);return l-=Math.max(0,u)*.02,Math.max(0,Math.min(1,l))}const O3=Object.freeze(Object.defineProperty({__proto__:null,name:F3,probabilityScore:z3,units:Ad},Symbol.toStringTag,{value:"Module"})),sc=[...[...Array(12)].map((t,e)=>({id:e,type:"warrior",col:e<3?-6:e<6?e-7.5:e<9?6:7.5-e,row:e<3?e-7.5:e<6?-6:e<9?7.5-e:6,sizeCol:2,sizeRow:2,command:"advance"})),...[...Array(3)].map((t,e)=>({id:e+12,type:"tank",col:e===0?-3:e===1?3:0,row:e===0?-3:e===1?3:-3,sizeCol:3,sizeRow:3,command:"wait-advance"})),...[...Array(6)].map((t,e)=>({id:e+15,type:"archer",col:e<3?-2:2,row:e%3-1,sizeCol:2,sizeRow:2,command:"advance"})),...[...Array(2)].map((t,e)=>({id:e+21,type:"artillery",col:e*2-1,row:-1,sizeCol:2,sizeRow:2,command:"advance"})),...[...Array(3)].map((t,e)=>({id:e+23,type:"warrior",col:(e-1)*2,row:-5,sizeCol:2,sizeRow:2,command:"wait-advance"}))],M3="Fortress Defense";function P3(t){const e=Qe(sc),n=Qe(t),s=nt(sc),r=nt(t),o=lt(sc),i=lt(t),a=At(sc),l=At(t);let c=.5;c+=(l-a)*.2,c+=(e.warrior+e.tank-n.warrior-n.tank)*.02,c+=(e.artillery-n.artillery)*.03,c+=(r.front-s.front)*.15,c+=(s.center-r.center)*.1;const u=e.archer+e.artillery,h=n.archer+n.artillery;return c-=Math.max(0,h-u)*.02,c+=(i-o)*.1,Math.max(0,Math.min(1,c))}const L3=Object.freeze(Object.defineProperty({__proto__:null,name:M3,probabilityScore:P3,units:sc},Symbol.toStringTag,{value:"Module"})),B3=[{id:301,col:-14,row:-2,sizeCol:4,sizeRow:3,type:"tank",command:"flank-left"},{id:302,col:-18,row:-6,sizeCol:4,sizeRow:2,type:"archer",command:"flank-left"},{id:303,col:-16,row:2,sizeCol:6,sizeRow:2,type:"warrior",command:"flank-left"},{id:304,col:-4,row:0,sizeCol:6,sizeRow:2,type:"warrior",command:"advance"},{id:305,col:4,row:0,sizeCol:6,sizeRow:2,type:"warrior",command:"advance"},{id:306,col:0,row:-6,sizeCol:6,sizeRow:2,type:"artillery",command:"advance"},{id:307,col:14,row:-2,sizeCol:4,sizeRow:3,type:"tank",command:"flank-right"},{id:308,col:18,row:-6,sizeCol:4,sizeRow:2,type:"archer",command:"flank-right"},{id:309,col:16,row:2,sizeCol:6,sizeRow:2,type:"warrior",command:"flank-right"}],V3="Pincer Attack",W3=t=>{const e=Qe(t),n=nt(t),s=At(t),r=1-(n.left+n.right)/2,o=1-Math.max(Math.abs(e.warrior-e.archer),Math.abs(e.warrior-e.tank),Math.abs(e.warrior-e.artillery),Math.abs(e.archer-e.tank),Math.abs(e.archer-e.artillery),Math.abs(e.tank-e.artillery))/t.length,i=1-s;return(r*.4+o*.3+i*.3)*100},U3=Object.freeze(Object.defineProperty({__proto__:null,name:V3,probabilityScore:W3,units:B3},Symbol.toStringTag,{value:"Module"})),G3=[{id:401,col:-16,row:0,sizeCol:8,sizeRow:2,type:"warrior",command:"wait-advance"},{id:402,col:0,row:0,sizeCol:8,sizeRow:2,type:"warrior",command:"wait-advance"},{id:403,col:16,row:0,sizeCol:8,sizeRow:2,type:"warrior",command:"wait-advance"},{id:404,col:-12,row:-4,sizeCol:4,sizeRow:2,type:"archer",command:"advance"},{id:405,col:0,row:-4,sizeCol:4,sizeRow:2,type:"archer",command:"advance"},{id:406,col:12,row:-4,sizeCol:4,sizeRow:2,type:"archer",command:"advance"},{id:407,col:0,row:-8,sizeCol:8,sizeRow:2,type:"artillery",command:"advance"},{id:408,col:-16,row:-6,sizeCol:4,sizeRow:4,type:"tank",command:"wait-advance"},{id:409,col:16,row:-6,sizeCol:4,sizeRow:4,type:"tank",command:"wait-advance"}],H3="Shield Wall",j3=t=>{const e=Qe(t),n=nt(t),s=At(t),r=lt(t),o=(e.warrior+e.tank)/t.length,i=n.front,a=s,l=r;return(o*.35+i*.25+a*.2+l*.2)*100},K3=Object.freeze(Object.defineProperty({__proto__:null,name:H3,probabilityScore:j3,units:G3},Symbol.toStringTag,{value:"Module"})),X3=[{id:501,col:-4,row:2,sizeCol:4,sizeRow:4,type:"tank",command:"advance"},{id:502,col:4,row:2,sizeCol:4,sizeRow:4,type:"tank",command:"advance"},{id:503,col:0,row:0,sizeCol:4,sizeRow:4,type:"tank",command:"advance"},{id:504,col:-10,row:-2,sizeCol:6,sizeRow:2,type:"warrior",command:"advance"},{id:505,col:10,row:-2,sizeCol:6,sizeRow:2,type:"warrior",command:"advance"},{id:506,col:0,row:-6,sizeCol:8,sizeRow:2,type:"artillery",command:"advance"},{id:507,col:-16,row:-8,sizeCol:4,sizeRow:2,type:"archer",command:"advance"},{id:508,col:16,row:-8,sizeCol:4,sizeRow:2,type:"archer",command:"advance"}],q3="Blitzkrieg",Y3=t=>{const e=Qe(t),n=nt(t),s=At(t),r=lt(t),o=1-e.tank/t.length,i=1-(n.left+n.right)/2,a=1-s,l=1-r,c=n.front;return(o*.25+i*.2+a*.2+l*.15+c*.2)*100},Q3=Object.freeze(Object.defineProperty({__proto__:null,name:q3,probabilityScore:Y3,units:X3},Symbol.toStringTag,{value:"Module"})),Z3=[{id:601,col:-16,row:-8,sizeCol:6,sizeRow:2,type:"artillery",command:"advance"},{id:602,col:0,row:-8,sizeCol:6,sizeRow:2,type:"artillery",command:"advance"},{id:603,col:16,row:-8,sizeCol:6,sizeRow:2,type:"artillery",command:"advance"},{id:604,col:-12,row:-4,sizeCol:4,sizeRow:2,type:"archer",command:"advance"},{id:605,col:0,row:-4,sizeCol:4,sizeRow:2,type:"archer",command:"advance"},{id:606,col:12,row:-4,sizeCol:4,sizeRow:2,type:"archer",command:"advance"},{id:607,col:-16,row:0,sizeCol:6,sizeRow:2,type:"warrior",command:"wait-advance"},{id:608,col:0,row:0,sizeCol:6,sizeRow:2,type:"warrior",command:"wait-advance"},{id:609,col:16,row:0,sizeCol:6,sizeRow:2,type:"warrior",command:"wait-advance"},{id:610,col:-10,row:-6,sizeCol:4,sizeRow:4,type:"tank",command:"wait-advance"},{id:611,col:10,row:-6,sizeCol:4,sizeRow:4,type:"tank",command:"wait-advance"}],J3="Scorched Earth",eM=t=>{const e=Qe(t),n=nt(t),s=At(t),r=lt(t),o=1-(e.artillery+e.archer)/t.length,i=s,a=n.front,l=r,c=(e.warrior+e.tank)/t.length;return(o*.25+i*.2+a*.2+l*.15+c*.2)*100},tM=Object.freeze(Object.defineProperty({__proto__:null,name:J3,probabilityScore:eM,units:Z3},Symbol.toStringTag,{value:"Module"})),nM=[{id:701,col:-8,row:0,sizeCol:8,sizeRow:2,type:"warrior",command:"advance"},{id:702,col:8,row:0,sizeCol:8,sizeRow:2,type:"warrior",command:"advance"},{id:703,col:-8,row:-4,sizeCol:4,sizeRow:4,type:"tank",command:"wait-advance"},{id:704,col:0,row:-4,sizeCol:4,sizeRow:4,type:"tank",command:"wait-advance"},{id:705,col:8,row:-4,sizeCol:4,sizeRow:4,type:"tank",command:"wait-advance"},{id:706,col:-12,row:-8,sizeCol:6,sizeRow:2,type:"artillery",command:"advance-wait"},{id:707,col:12,row:-8,sizeCol:6,sizeRow:2,type:"artillery",command:"advance-wait"},{id:708,col:-16,row:-6,sizeCol:4,sizeRow:2,type:"archer",command:"wait-advance"},{id:709,col:0,row:-6,sizeCol:4,sizeRow:2,type:"archer",command:"wait-advance"},{id:710,col:16,row:-6,sizeCol:4,sizeRow:2,type:"archer",command:"wait-advance"}],sM="Trojan Horse",rM=t=>{const e=Qe(t),n=nt(t),s=At(t),r=lt(t),o=(e.warrior+e.tank)/t.length,i=n.front,a=1-s,l=1-(e.artillery+e.archer)/t.length,c=r;return(o*.3+i*.25+a*.15+l*.2+c*.1)*100},oM=Object.freeze(Object.defineProperty({__proto__:null,name:sM,probabilityScore:rM,units:nM},Symbol.toStringTag,{value:"Module"})),iM=[{id:801,col:0,row:2,sizeCol:4,sizeRow:4,type:"tank",command:"advance"},{id:802,col:-4,row:0,sizeCol:4,sizeRow:4,type:"tank",command:"advance"},{id:803,col:-8,row:-2,sizeCol:6,sizeRow:2,type:"warrior",command:"advance"},{id:804,col:-12,row:-4,sizeCol:4,sizeRow:2,type:"archer",command:"wait-advance"},{id:805,col:-16,row:-6,sizeCol:6,sizeRow:2,type:"artillery",command:"advance"},{id:806,col:4,row:0,sizeCol:4,sizeRow:4,type:"tank",command:"advance"},{id:807,col:8,row:-2,sizeCol:6,sizeRow:2,type:"warrior",command:"advance"},{id:808,col:12,row:-4,sizeCol:4,sizeRow:2,type:"archer",command:"wait-advance"},{id:809,col:16,row:-6,sizeCol:6,sizeRow:2,type:"artillery",command:"advance"},{id:810,col:0,row:-4,sizeCol:6,sizeRow:2,type:"warrior",command:"advance"}],aM="Flying V",lM=t=>{const e=Qe(t),n=nt(t),s=At(t),r=lt(t),o=1-(n.left+n.right)/2,i=1-Math.max(Math.abs(e.warrior-e.archer),Math.abs(e.warrior-e.tank),Math.abs(e.warrior-e.artillery),Math.abs(e.archer-e.tank),Math.abs(e.archer-e.artillery),Math.abs(e.tank-e.artillery))/t.length,a=s,l=n.front,c=1-r;return(o*.3+i*.2+a*.15+l*.25+c*.1)*100},cM=Object.freeze(Object.defineProperty({__proto__:null,name:aM,probabilityScore:lM,units:iM},Symbol.toStringTag,{value:"Module"})),uM=[{id:901,col:-8,row:0,sizeCol:8,sizeRow:2,type:"warrior",command:"wait-advance"},{id:902,col:8,row:0,sizeCol:8,sizeRow:2,type:"warrior",command:"wait-advance"},{id:903,col:-4,row:-2,sizeCol:4,sizeRow:4,type:"tank",command:"wait-advance"},{id:904,col:4,row:-2,sizeCol:4,sizeRow:4,type:"tank",command:"wait-advance"},{id:905,col:-16,row:-4,sizeCol:4,sizeRow:4,type:"tank",command:"advance"},{id:906,col:-20,row:-6,sizeCol:6,sizeRow:2,type:"warrior",command:"advance"},{id:907,col:16,row:-4,sizeCol:4,sizeRow:4,type:"tank",command:"advance"},{id:908,col:20,row:-6,sizeCol:6,sizeRow:2,type:"warrior",command:"advance"},{id:909,col:-12,row:-6,sizeCol:4,sizeRow:2,type:"archer",command:"wait-advance"},{id:910,col:12,row:-6,sizeCol:4,sizeRow:2,type:"archer",command:"wait-advance"},{id:911,col:0,row:-8,sizeCol:6,sizeRow:2,type:"artillery",command:"wait-advance"}],hM="Hammer and Anvil",dM=t=>{const e=Qe(t),n=nt(t),s=At(t),r=lt(t),o=1-(n.left+n.right)/2,i=(e.warrior+e.tank)/t.length,a=1-s,l=n.front,c=r,u=1-(e.artillery+e.archer)/t.length;return(o*.25+i*.2+a*.15+l*.2+c*.1+u*.1)*100},fM=Object.freeze(Object.defineProperty({__proto__:null,name:hM,probabilityScore:dM,units:uM},Symbol.toStringTag,{value:"Module"})),pM=[{id:1001,col:12,row:2,sizeCol:4,sizeRow:4,type:"tank",command:"advance"},{id:1002,col:8,row:0,sizeCol:6,sizeRow:2,type:"warrior",command:"advance"},{id:1003,col:4,row:-2,sizeCol:4,sizeRow:4,type:"tank",command:"advance"},{id:1004,col:0,row:-4,sizeCol:6,sizeRow:2,type:"warrior",command:"advance"},{id:1005,col:-4,row:-6,sizeCol:4,sizeRow:4,type:"tank",command:"advance"},{id:1006,col:-8,row:-8,sizeCol:6,sizeRow:2,type:"warrior",command:"advance"},{id:1007,col:12,row:-4,sizeCol:4,sizeRow:2,type:"archer",command:"wait-advance"},{id:1008,col:0,row:-8,sizeCol:4,sizeRow:2,type:"archer",command:"wait-advance"},{id:1009,col:-16,row:-12,sizeCol:6,sizeRow:2,type:"artillery",command:"advance"}],mM="Echelon Formation",gM=t=>{const e=Qe(t),n=nt(t),s=At(t),r=lt(t),o=Math.abs(n.left-n.right),i=1-Math.max(Math.abs(e.warrior-e.archer),Math.abs(e.warrior-e.tank),Math.abs(e.warrior-e.artillery),Math.abs(e.archer-e.tank),Math.abs(e.archer-e.artillery),Math.abs(e.tank-e.artillery))/t.length,a=s,l=1-e.artillery/t.length,c=1-r;return(o*.25+i*.2+a*.2+l*.25+c*.1)*100},xM=Object.freeze(Object.defineProperty({__proto__:null,name:mM,probabilityScore:gM,units:pM},Symbol.toStringTag,{value:"Module"})),yM=[{id:1101,col:-6,row:2,sizeCol:6,sizeRow:2,type:"warrior",command:"advance"},{id:1102,col:6,row:2,sizeCol:6,sizeRow:2,type:"warrior",command:"advance"},{id:1103,col:-8,row:-2,sizeCol:6,sizeRow:2,type:"warrior",command:"advance"},{id:1104,col:8,row:-2,sizeCol:6,sizeRow:2,type:"warrior",command:"advance"},{id:1105,col:-6,row:-6,sizeCol:6,sizeRow:2,type:"warrior",command:"advance"},{id:1106,col:6,row:-6,sizeCol:6,sizeRow:2,type:"warrior",command:"advance"},{id:1107,col:-3,row:-2,sizeCol:3,sizeRow:3,type:"tank",command:"advance"},{id:1108,col:3,row:-2,sizeCol:3,sizeRow:3,type:"tank",command:"advance"},{id:1109,col:-4,row:-4,sizeCol:3,sizeRow:2,type:"archer",command:"advance"},{id:1110,col:4,row:-4,sizeCol:3,sizeRow:2,type:"archer",command:"advance"},{id:1111,col:0,row:-4,sizeCol:4,sizeRow:2,type:"artillery",command:"advance"}],wM="Turtle Formation",vM=t=>{const e=Qe(t),n=nt(t),s=At(t),r=lt(t),o=(e.warrior+e.tank)/t.length,i=1-s,a=r,l=1-e.artillery/t.length,c=1-(e.artillery+e.archer)/t.length,u=n.front;return(o*.25+i*.2+a*.15+l*.2+c*.1+u*.1)*100},bM=Object.freeze(Object.defineProperty({__proto__:null,name:wM,probabilityScore:vM,units:yM},Symbol.toStringTag,{value:"Module"})),CM=[{id:1201,col:-12,row:2,sizeCol:3,sizeRow:2,type:"archer",command:"wait-advance"},{id:1202,col:-4,row:2,sizeCol:3,sizeRow:2,type:"archer",command:"wait-advance"},{id:1203,col:4,row:2,sizeCol:3,sizeRow:2,type:"archer",command:"wait-advance"},{id:1204,col:12,row:2,sizeCol:3,sizeRow:2,type:"archer",command:"wait-advance"},{id:1205,col:-8,row:-2,sizeCol:6,sizeRow:2,type:"warrior",command:"advance"},{id:1206,col:8,row:-2,sizeCol:6,sizeRow:2,type:"warrior",command:"advance"},{id:1207,col:-6,row:-6,sizeCol:4,sizeRow:4,type:"tank",command:"advance"},{id:1208,col:6,row:-6,sizeCol:4,sizeRow:4,type:"tank",command:"advance"},{id:1209,col:-8,row:-10,sizeCol:6,sizeRow:2,type:"artillery",command:"advance"},{id:1210,col:8,row:-10,sizeCol:6,sizeRow:2,type:"artillery",command:"advance"}],kM="Skirmisher Screen",SM=t=>{const e=Qe(t),n=nt(t),s=At(t),r=lt(t),o=(e.tank+e.artillery)/t.length,i=s,a=r,l=1-e.archer/t.length,c=n.front,u=1-e.warrior/t.length;return(o*.25+i*.2+a*.15+l*.15+c*.15+u*.1)*100},IM=Object.freeze(Object.defineProperty({__proto__:null,name:kM,probabilityScore:SM,units:CM},Symbol.toStringTag,{value:"Module"})),cC=[jO,YO,e3,r3,l3,d3,g3,v3,S3,N3,R3,_3,O3,L3,U3,K3,Q3,tM,oM,cM,fM,xM,bM,IM];/** +`,iC=(t,e)=>({x:(t+el)*is,y:(e+tl)*Ur}),aC=(t,e)=>({col:Math.floor(t/is)-el,row:Math.floor(e/Ur)-tl}),VO=(t,e)=>{const[n,s]=ye.useState({isDragging:!1,draggedUnit:null,dragOffset:{x:0,y:0}}),r=ye.useCallback(l=>"touches"in l?{clientX:l.touches[0].clientX,clientY:l.touches[0].clientY}:{clientX:l.clientX,clientY:l.clientY},[]),o=ye.useCallback(l=>{const c=l.currentTarget,u=c.getBoundingClientRect(),{clientX:h,clientY:d}=r(l),{col:f,row:p}=aC((h-u.left)*(c.width/u.width),(d-u.top)*(c.height/u.height)),g=t.find(x=>f>=x.col&&f=x.row&&p{if(n.isDragging&&n.draggedUnit){const c=l.currentTarget,u=c.getBoundingClientRect(),{clientX:h,clientY:d}=r(l),{col:f,row:p}=aC((h-u.left)*(c.width/u.width)-n.dragOffset.x,(d-u.top)*(c.height/u.height)-n.dragOffset.y);e(g=>g.map(x=>x.id===n.draggedUnit.id?{...x,col:Math.max(-el,Math.min(f,So-el-x.sizeCol)),row:Math.max(-tl,Math.min(p,Io-tl-x.sizeRow))}:x))}},[n,e,r]),a=ye.useCallback(()=>{s({isDragging:!1,draggedUnit:null,dragOffset:{x:0,y:0}})},[]);return{isDragging:n.isDragging,handleDragStart:o,handleDragMove:i,handleDragEnd:a}},WO=t=>{const[e,n]=ye.useState(null),s=ye.useCallback((o,i)=>{const a=t.find(l=>o>=l.col&&o=l.row&&i{n(null)},[]);return{selectedUnit:e,handleUnitSelect:s,setSelectedUnit:n,clearSelection:r}};function lC(t,e){if(e.length===0)throw new Error("No AI plans available for selection");const n=e.map(r=>({plan:r,score:r.probabilityScore(t)}));n.sort((r,o)=>o.score-r.score);const s=n[0].plan;return console.log("Selected plan:",s.name,"with score:",n[0].score),console.log("All plan scores:"),n.forEach(({plan:r,score:o})=>{console.log(`${r.name}: ${o}`)}),s.units}function Qe(t){return t.reduce((e,n)=>(e[n.type]=(e[n.type]||0)+1,e),{tank:0,warrior:0,archer:0,artillery:0})}function nt(t){const e={left:0,center:0,right:0,front:0};t.forEach(s=>{s.col<-5?e.left++:s.col>5?e.right++:e.center++,s.row>-5&&e.front++});const n=t.length;return{left:e.left/n,center:e.center/n,right:e.right/n,front:e.front/n}}function lt(t){return t.length===0?0:t.reduce((n,s)=>n+s.sizeCol*s.sizeRow,0)/(t.length*16)}function At(t){const e=t.map(i=>({x:i.col,y:i.row})),n=e.reduce((i,a)=>i+a.x,0)/e.length,s=e.reduce((i,a)=>i+a.y,0)/e.length,r=Math.sqrt(32*32+18*18);return e.reduce((i,a)=>{const l=a.x-n,c=a.y-s;return i+Math.sqrt(l*l+c*c)},0)/e.length/r}const Ox=[{id:201,col:-12,row:0,sizeCol:8,sizeRow:2,type:"warrior",command:"advance-wait"},{id:202,col:0,row:0,sizeCol:8,sizeRow:2,type:"warrior",command:"advance-wait"},{id:203,col:12,row:0,sizeCol:8,sizeRow:2,type:"warrior",command:"advance-wait"},{id:204,col:-8,row:-4,sizeCol:4,sizeRow:4,type:"tank",command:"advance"},{id:205,col:8,row:-4,sizeCol:4,sizeRow:4,type:"tank",command:"advance"},{id:206,col:-16,row:-8,sizeCol:4,sizeRow:2,type:"archer",command:"wait-advance"},{id:207,col:16,row:-8,sizeCol:4,sizeRow:2,type:"archer",command:"wait-advance"},{id:208,col:2,row:-8,sizeCol:8,sizeRow:1,type:"artillery",command:"wait-advance"}],UO="Balanced Assault",GO=t=>{const e=Qe(t),n=nt(t),s=1-Math.abs(.25-e.warrior/t.length)-Math.abs(.25-e.archer/t.length)-Math.abs(.25-e.tank/t.length)-Math.abs(.25-e.artillery/t.length),r=(n.left+n.right+n.center)/3,o=1-Math.abs(.5-lt(t));return(s*.5+r*.3+o*.2)*100},HO=Object.freeze(Object.defineProperty({__proto__:null,name:UO,probabilityScore:GO,units:Ox},Symbol.toStringTag,{value:"Module"})),jO=[{id:301,col:-16,row:0,sizeCol:4,sizeRow:2,type:"archer",command:"wait-advance"},{id:302,col:16,row:0,sizeCol:4,sizeRow:2,type:"archer",command:"wait-advance"},{id:303,col:0,row:-4,sizeCol:8,sizeRow:3,type:"artillery",command:"advance-wait"},{id:304,col:-12,row:-2,sizeCol:6,sizeRow:2,type:"warrior",command:"advance"},{id:305,col:12,row:-2,sizeCol:6,sizeRow:2,type:"warrior",command:"advance"},{id:306,col:-8,row:-6,sizeCol:4,sizeRow:3,type:"tank",command:"advance"},{id:307,col:8,row:-6,sizeCol:4,sizeRow:3,type:"tank",command:"advance"}],KO="Anti-Tank Defense",XO=t=>{const e=Qe(t),n=nt(t),s=e.tank/t.length,r=Math.min(s*2,1),o=n.center,i=lt(t.filter(a=>a.type==="tank"));return(r*.5+o*.3+i*.2)*100},qO=Object.freeze(Object.defineProperty({__proto__:null,name:KO,probabilityScore:XO,units:jO},Symbol.toStringTag,{value:"Module"})),YO=[{id:401,col:-12,row:-2,sizeCol:4,sizeRow:2,type:"tank",command:"flank-left"},{id:402,col:12,row:-2,sizeCol:4,sizeRow:2,type:"tank",command:"flank-right"},{id:403,col:0,row:-6,sizeCol:6,sizeRow:3,type:"artillery",command:"wait-advance"},{id:404,col:-16,row:0,sizeCol:6,sizeRow:2,type:"warrior",command:"advance"},{id:405,col:16,row:0,sizeCol:6,sizeRow:2,type:"warrior",command:"advance"},{id:406,col:-8,row:-10,sizeCol:4,sizeRow:3,type:"tank",command:"advance"},{id:407,col:8,row:-10,sizeCol:4,sizeRow:3,type:"tank",command:"advance"},{id:408,col:-4,row:-4,sizeCol:4,sizeRow:2,type:"warrior",command:"advance"},{id:409,col:4,row:-4,sizeCol:4,sizeRow:2,type:"warrior",command:"advance"}],QO="Archer Counter",ZO=t=>{const e=Qe(t),n=nt(t),s=e.archer/t.length,r=Math.min(s*2,1),o=Math.max(n.left,n.right),i=1-lt(t.filter(a=>a.type==="archer"));return(r*.5+o*.3+i*.2)*100},JO=Object.freeze(Object.defineProperty({__proto__:null,name:QO,probabilityScore:ZO,units:YO},Symbol.toStringTag,{value:"Module"})),e3=[{id:501,col:-12,row:0,sizeCol:6,sizeRow:2,type:"warrior",command:"advance"},{id:502,col:12,row:0,sizeCol:6,sizeRow:2,type:"warrior",command:"advance"},{id:503,col:-8,row:-4,sizeCol:4,sizeRow:2,type:"archer",command:"flank-left"},{id:504,col:8,row:-4,sizeCol:4,sizeRow:2,type:"archer",command:"flank-right"},{id:505,col:-16,row:-2,sizeCol:6,sizeRow:2,type:"warrior",command:"advance"},{id:506,col:16,row:-2,sizeCol:6,sizeRow:2,type:"warrior",command:"advance"},{id:507,col:0,row:-6,sizeCol:6,sizeRow:3,type:"artillery",command:"wait-advance"},{id:508,col:-4,row:-2,sizeCol:4,sizeRow:2,type:"warrior",command:"advance"},{id:509,col:4,row:-2,sizeCol:4,sizeRow:2,type:"warrior",command:"advance"}],t3="Warrior Blitz",n3=t=>{const e=Qe(t),n=nt(t),s=e.tank/t.length,r=(e.warrior+e.archer)/t.length,o=(1-s)*.5+r*.5,i=n.center,a=1-lt(t);return(o*.4+i*.4+a*.2)*100},s3=Object.freeze(Object.defineProperty({__proto__:null,name:t3,probabilityScore:n3,units:e3},Symbol.toStringTag,{value:"Module"})),r3=[{id:601,col:-12,row:-4,sizeCol:4,sizeRow:4,type:"tank",command:"advance-wait"},{id:602,col:12,row:-4,sizeCol:4,sizeRow:4,type:"tank",command:"advance-wait"},{id:603,col:-16,row:0,sizeCol:8,sizeRow:2,type:"warrior",command:"advance"},{id:604,col:16,row:0,sizeCol:8,sizeRow:2,type:"warrior",command:"advance"},{id:605,col:0,row:-8,sizeCol:8,sizeRow:2,type:"artillery",command:"wait-advance"},{id:606,col:-8,row:-10,sizeCol:4,sizeRow:2,type:"archer",command:"wait-advance"},{id:607,col:8,row:-10,sizeCol:4,sizeRow:2,type:"archer",command:"wait-advance"},{id:608,col:0,row:-12,sizeCol:8,sizeRow:2,type:"artillery",command:"wait-advance"},{id:609,col:0,row:-2,sizeCol:8,sizeRow:2,type:"warrior",command:"advance"}],o3="Tank Formation",i3=t=>{const e=Qe(t),n=nt(t),s=(e.warrior+e.archer)/t.length,r=Math.min(s*1.5,1),o=1-n.center,i=1-lt(t);return(r*.4+o*.4+i*.2)*100},a3=Object.freeze(Object.defineProperty({__proto__:null,name:o3,probabilityScore:i3,units:r3},Symbol.toStringTag,{value:"Module"})),l3=[{id:701,col:-16,row:-4,sizeCol:6,sizeRow:3,type:"artillery",command:"advance"},{id:702,col:16,row:-4,sizeCol:6,sizeRow:3,type:"artillery",command:"advance"},{id:703,col:0,row:0,sizeCol:6,sizeRow:3,type:"tank",command:"advance-wait"},{id:704,col:-8,row:-10,sizeCol:4,sizeRow:2,type:"archer",command:"wait-advance"},{id:705,col:8,row:-10,sizeCol:4,sizeRow:2,type:"archer",command:"wait-advance"},{id:706,col:-12,row:-12,sizeCol:4,sizeRow:3,type:"tank",command:"advance"},{id:707,col:12,row:-12,sizeCol:4,sizeRow:3,type:"tank",command:"advance"},{id:708,col:0,row:-6,sizeCol:6,sizeRow:2,type:"warrior",command:"advance"}],c3="Artillery Strike",u3=t=>{const e=Qe(t),n=nt(t),s=(e.tank+e.artillery)/t.length,r=Math.min(s*2,1),o=Math.max(n.left,n.center,n.right),i=lt(t);return(r*.4+o*.4+i*.2)*100},h3=Object.freeze(Object.defineProperty({__proto__:null,name:c3,probabilityScore:u3,units:l3},Symbol.toStringTag,{value:"Module"})),d3=[{id:801,col:-16,row:-4,sizeCol:4,sizeRow:2,type:"archer",command:"wait-advance"},{id:802,col:-8,row:-4,sizeCol:4,sizeRow:2,type:"archer",command:"wait-advance"},{id:803,col:0,row:-4,sizeCol:4,sizeRow:2,type:"archer",command:"wait-advance"},{id:804,col:8,row:-4,sizeCol:4,sizeRow:2,type:"archer",command:"wait-advance"},{id:805,col:16,row:-4,sizeCol:4,sizeRow:2,type:"archer",command:"wait-advance"},{id:806,col:-12,row:-10,sizeCol:4,sizeRow:4,type:"tank",command:"advance"},{id:807,col:12,row:-10,sizeCol:4,sizeRow:4,type:"tank",command:"advance"},{id:808,col:0,row:-14,sizeCol:8,sizeRow:2,type:"artillery",command:"wait-advance"},{id:809,col:-20,row:-6,sizeCol:4,sizeRow:2,type:"archer",command:"wait-advance"},{id:810,col:20,row:-6,sizeCol:4,sizeRow:2,type:"archer",command:"wait-advance"},{id:811,col:-4,row:-8,sizeCol:4,sizeRow:2,type:"warrior",command:"advance"},{id:812,col:4,row:-8,sizeCol:4,sizeRow:2,type:"warrior",command:"advance"}],f3="Archer Ambush",p3=t=>{const e=Qe(t),n=nt(t),s=(e.warrior+e.tank)/t.length,r=Math.min(s*1.5,1),o=n.center+n.front*.5,i=lt(t);return(r*.4+o*.4+i*.2)*100},m3=Object.freeze(Object.defineProperty({__proto__:null,name:f3,probabilityScore:p3,units:d3},Symbol.toStringTag,{value:"Module"})),g3=[{id:301,col:-16,row:-8,sizeCol:4,sizeRow:2,type:"archer",command:"wait-advance"},{id:302,col:-8,row:-8,sizeCol:4,sizeRow:2,type:"archer",command:"wait-advance"},{id:303,col:8,row:-8,sizeCol:4,sizeRow:2,type:"archer",command:"wait-advance"},{id:304,col:16,row:-8,sizeCol:4,sizeRow:2,type:"archer",command:"wait-advance"},{id:305,col:-12,row:-4,sizeCol:8,sizeRow:2,type:"artillery",command:"wait-advance"},{id:306,col:12,row:-4,sizeCol:8,sizeRow:2,type:"artillery",command:"wait-advance"},{id:307,col:-8,row:0,sizeCol:4,sizeRow:4,type:"tank",command:"wait-advance"},{id:308,col:8,row:0,sizeCol:4,sizeRow:4,type:"tank",command:"wait-advance"},{id:309,col:0,row:-2,sizeCol:6,sizeRow:2,type:"warrior",command:"advance"},{id:310,col:-16,row:-2,sizeCol:4,sizeRow:2,type:"warrior",command:"flank-left"},{id:311,col:16,row:-2,sizeCol:4,sizeRow:2,type:"warrior",command:"flank-right"}],x3="Warrior Counter",y3=t=>{const e=Qe(t),n=t.length,s=(e.warrior||0)/n,r=At(t),o=Math.min(s*2,1),i=1-r,a=1-lt(t.filter(l=>l.type==="warrior"));return(o*.5+i*.3+a*.2)*100},w3=Object.freeze(Object.defineProperty({__proto__:null,name:x3,probabilityScore:y3,units:g3},Symbol.toStringTag,{value:"Module"})),v3=[{id:301,col:-6,row:0,sizeCol:4,sizeRow:4,type:"tank",command:"advance"},{id:302,col:6,row:0,sizeCol:4,sizeRow:4,type:"tank",command:"advance"},{id:303,col:-10,row:-4,sizeCol:3,sizeRow:2,type:"warrior",command:"advance"},{id:304,col:-5,row:-4,sizeCol:3,sizeRow:2,type:"warrior",command:"advance"},{id:305,col:0,row:-4,sizeCol:3,sizeRow:2,type:"warrior",command:"advance"},{id:306,col:5,row:-4,sizeCol:3,sizeRow:2,type:"warrior",command:"advance"},{id:307,col:10,row:-4,sizeCol:3,sizeRow:2,type:"warrior",command:"advance"},{id:308,col:-12,row:-8,sizeCol:4,sizeRow:2,type:"archer",command:"wait-advance"},{id:309,col:0,row:-8,sizeCol:4,sizeRow:2,type:"archer",command:"wait-advance"},{id:310,col:12,row:-8,sizeCol:4,sizeRow:2,type:"archer",command:"wait-advance"},{id:311,col:-12,row:-12,sizeCol:8,sizeRow:2,type:"artillery",command:"wait-advance"},{id:312,col:12,row:-12,sizeCol:8,sizeRow:2,type:"artillery",command:"wait-advance"}],b3="Artillery Counter",C3=t=>{const e=Qe(t),n=nt(t),s=Math.min(e.artillery/t.length,.5)*2,r=n.center,o=lt(t);return(s*.6+r*.2+o*.2)*100},k3=Object.freeze(Object.defineProperty({__proto__:null,name:b3,probabilityScore:C3,units:v3},Symbol.toStringTag,{value:"Module"})),Ed=[...[...Array(10)].map((t,e)=>({id:e,type:"warrior",col:-2+e%5,row:-4+Math.floor(e/5),sizeCol:2,sizeRow:2,command:"advance"})),...[...Array(5)].map((t,e)=>({id:e+10,type:"archer",col:-2+e,row:-2,sizeCol:2,sizeRow:2,command:"advance"})),...[...Array(3)].map((t,e)=>({id:e+15,type:"artillery",col:-3+e*3,row:0,sizeCol:3,sizeRow:2,command:"advance"})),...[...Array(4)].map((t,e)=>({id:e+18,type:"warrior",col:e<2?-4:4,row:-5+e%2*2,sizeCol:2,sizeRow:2,command:"advance"})),...[...Array(4)].map((t,e)=>({id:e+22,type:"archer",col:e<2?-5:5,row:-4+e%2*2,sizeCol:2,sizeRow:2,command:"advance"}))],S3="Phalanx Formation";function I3(t){const e=Qe(Ed),n=Qe(t),s=nt(Ed),r=nt(t),o=At(Ed),i=At(t);let a=.5;return a+=(e.warrior-n.warrior)*.02,a+=(n.tank-e.tank)*.03,a+=(s.center-r.center)*.1,a+=(i-o)*.1,a-=Math.max(0,n.archer-e.archer)*.01,a-=Math.max(0,n.artillery-e.artillery)*.01,Math.max(0,Math.min(1,a))}const $3=Object.freeze(Object.defineProperty({__proto__:null,name:S3,probabilityScore:I3,units:Ed},Symbol.toStringTag,{value:"Module"})),tc=[...[...Array(5)].map((t,e)=>({id:e,type:"tank",col:Math.floor(e/2)-1,row:-6+e%2+Math.floor(e/2),sizeCol:3,sizeRow:3,command:"advance"})),...[...Array(3)].map((t,e)=>({id:e+5,type:"tank",col:(e-1)*2,row:-2,sizeCol:3,sizeRow:3,command:"advance"})),...[...Array(2)].map((t,e)=>({id:e+8,type:"artillery",col:e*4-2,row:2,sizeCol:3,sizeRow:2,command:"advance"})),...[...Array(4)].map((t,e)=>({id:e+10,type:"warrior",col:e<2?-6:6,row:-4+e%2*2,sizeCol:2,sizeRow:2,command:"advance"}))],N3="Cavalry Charge";function T3(t){const e=Qe(tc),n=Qe(t),s=nt(tc),r=nt(t),o=lt(tc),i=lt(t),a=At(tc),l=At(t);let c=.5;return c+=(e.tank-n.tank)*.03,c-=(n.warrior+n.artillery)*.02,c+=(s.front-r.front)*.1,c+=(l-a)*.1,c+=(o-i)*.2,c+=Math.max(0,n.archer-e.archer)*.01,Math.max(0,Math.min(1,c))}const E3=Object.freeze(Object.defineProperty({__proto__:null,name:N3,probabilityScore:T3,units:tc},Symbol.toStringTag,{value:"Module"})),nc=[...[...Array(7)].map((t,e)=>({id:e,type:"artillery",col:e*3-9,row:2,sizeCol:3,sizeRow:2,command:"advance"})),...[...Array(4)].map((t,e)=>({id:e+7,type:"artillery",col:e*4-6,row:0,sizeCol:3,sizeRow:2,command:"advance"})),...[...Array(3)].map((t,e)=>({id:e+11,type:"tank",col:e*6-6,row:-4,sizeCol:4,sizeRow:3,command:"wait-advance"})),...[...Array(5)].map((t,e)=>({id:e+14,type:"warrior",col:e*4-8,row:-6,sizeCol:3,sizeRow:2,command:"wait-advance"}))],R3="Artillery Barrage";function A3(t){const e=Qe(nc),n=Qe(t),s=nt(nc),r=nt(t),o=lt(nc),i=lt(t),a=At(nc),l=At(t);let c=.5;return c+=(e.artillery-n.artillery)*.04,c-=(n.tank+n.warrior)*.02,c+=(l-a)*.15,c+=(r.front-s.front)*.1,c+=(i-o)*.1,c+=Math.max(0,n.archer-e.archer)*.02,c-=Math.max(0,n.tank-e.tank)*.03,Math.max(0,Math.min(1,c))}const D3=Object.freeze(Object.defineProperty({__proto__:null,name:R3,probabilityScore:A3,units:nc},Symbol.toStringTag,{value:"Module"})),Jo=(t,e,n)=>[{id:t,type:"warrior",col:e-1,row:n-1,sizeCol:2,sizeRow:2,command:"advance"},{id:t+1,type:"archer",col:e,row:n,sizeCol:2,sizeRow:2,command:"advance"},{id:t+2,type:"tank",col:e+1,row:n+1,sizeCol:3,sizeRow:3,command:"advance"}],Rd=[...Jo(0,-10,-5),...Jo(3,0,-6),...Jo(6,10,-5),...Jo(9,-8,0),...Jo(12,8,0),...Jo(15,-5,5),...Jo(18,5,5),...[...Array(2)].map((t,e)=>({id:21+e,type:"artillery",col:e*10-5,row:8,sizeCol:3,sizeRow:2,command:"advance"}))],_3="Guerrilla Tactics";function F3(t){const e=Qe(Rd),n=Qe(t),s=nt(t),r=lt(Rd),o=lt(t),i=At(Rd),a=At(t);let l=.5;l+=(i-a)*.2,l+=(Math.abs(s.front-.5)+Math.abs(s.center-.5))*.15,l+=(o-r)*.15;const c=Math.min(e.warrior,e.archer,e.tank,e.artillery)/Math.max(e.warrior,e.archer,e.tank,e.artillery);l+=c*.1;const u=Math.max(n.warrior-e.warrior,n.archer-e.archer,n.tank-e.tank,n.artillery-e.artillery);return l-=Math.max(0,u)*.02,Math.max(0,Math.min(1,l))}const z3=Object.freeze(Object.defineProperty({__proto__:null,name:_3,probabilityScore:F3,units:Rd},Symbol.toStringTag,{value:"Module"})),sc=[...[...Array(12)].map((t,e)=>({id:e,type:"warrior",col:e<3?-6:e<6?e-7.5:e<9?6:7.5-e,row:e<3?e-7.5:e<6?-6:e<9?7.5-e:6,sizeCol:2,sizeRow:2,command:"advance"})),...[...Array(3)].map((t,e)=>({id:e+12,type:"tank",col:e===0?-3:e===1?3:0,row:e===0?-3:e===1?3:-3,sizeCol:3,sizeRow:3,command:"wait-advance"})),...[...Array(6)].map((t,e)=>({id:e+15,type:"archer",col:e<3?-2:2,row:e%3-1,sizeCol:2,sizeRow:2,command:"advance"})),...[...Array(2)].map((t,e)=>({id:e+21,type:"artillery",col:e*2-1,row:-1,sizeCol:2,sizeRow:2,command:"advance"})),...[...Array(3)].map((t,e)=>({id:e+23,type:"warrior",col:(e-1)*2,row:-5,sizeCol:2,sizeRow:2,command:"wait-advance"}))],O3="Fortress Defense";function M3(t){const e=Qe(sc),n=Qe(t),s=nt(sc),r=nt(t),o=lt(sc),i=lt(t),a=At(sc),l=At(t);let c=.5;c+=(l-a)*.2,c+=(e.warrior+e.tank-n.warrior-n.tank)*.02,c+=(e.artillery-n.artillery)*.03,c+=(r.front-s.front)*.15,c+=(s.center-r.center)*.1;const u=e.archer+e.artillery,h=n.archer+n.artillery;return c-=Math.max(0,h-u)*.02,c+=(i-o)*.1,Math.max(0,Math.min(1,c))}const P3=Object.freeze(Object.defineProperty({__proto__:null,name:O3,probabilityScore:M3,units:sc},Symbol.toStringTag,{value:"Module"})),L3=[{id:301,col:-14,row:-2,sizeCol:4,sizeRow:3,type:"tank",command:"flank-left"},{id:302,col:-18,row:-6,sizeCol:4,sizeRow:2,type:"archer",command:"flank-left"},{id:303,col:-16,row:2,sizeCol:6,sizeRow:2,type:"warrior",command:"flank-left"},{id:304,col:-4,row:0,sizeCol:6,sizeRow:2,type:"warrior",command:"advance"},{id:305,col:4,row:0,sizeCol:6,sizeRow:2,type:"warrior",command:"advance"},{id:306,col:0,row:-6,sizeCol:6,sizeRow:2,type:"artillery",command:"advance"},{id:307,col:14,row:-2,sizeCol:4,sizeRow:3,type:"tank",command:"flank-right"},{id:308,col:18,row:-6,sizeCol:4,sizeRow:2,type:"archer",command:"flank-right"},{id:309,col:16,row:2,sizeCol:6,sizeRow:2,type:"warrior",command:"flank-right"}],B3="Pincer Attack",V3=t=>{const e=Qe(t),n=nt(t),s=At(t),r=1-(n.left+n.right)/2,o=1-Math.max(Math.abs(e.warrior-e.archer),Math.abs(e.warrior-e.tank),Math.abs(e.warrior-e.artillery),Math.abs(e.archer-e.tank),Math.abs(e.archer-e.artillery),Math.abs(e.tank-e.artillery))/t.length,i=1-s;return(r*.4+o*.3+i*.3)*100},W3=Object.freeze(Object.defineProperty({__proto__:null,name:B3,probabilityScore:V3,units:L3},Symbol.toStringTag,{value:"Module"})),U3=[{id:401,col:-16,row:0,sizeCol:8,sizeRow:2,type:"warrior",command:"wait-advance"},{id:402,col:0,row:0,sizeCol:8,sizeRow:2,type:"warrior",command:"wait-advance"},{id:403,col:16,row:0,sizeCol:8,sizeRow:2,type:"warrior",command:"wait-advance"},{id:404,col:-12,row:-4,sizeCol:4,sizeRow:2,type:"archer",command:"advance"},{id:405,col:0,row:-4,sizeCol:4,sizeRow:2,type:"archer",command:"advance"},{id:406,col:12,row:-4,sizeCol:4,sizeRow:2,type:"archer",command:"advance"},{id:407,col:0,row:-8,sizeCol:8,sizeRow:2,type:"artillery",command:"advance"},{id:408,col:-16,row:-6,sizeCol:4,sizeRow:4,type:"tank",command:"wait-advance"},{id:409,col:16,row:-6,sizeCol:4,sizeRow:4,type:"tank",command:"wait-advance"}],G3="Shield Wall",H3=t=>{const e=Qe(t),n=nt(t),s=At(t),r=lt(t),o=(e.warrior+e.tank)/t.length,i=n.front,a=s,l=r;return(o*.35+i*.25+a*.2+l*.2)*100},j3=Object.freeze(Object.defineProperty({__proto__:null,name:G3,probabilityScore:H3,units:U3},Symbol.toStringTag,{value:"Module"})),K3=[{id:501,col:-4,row:2,sizeCol:4,sizeRow:4,type:"tank",command:"advance"},{id:502,col:4,row:2,sizeCol:4,sizeRow:4,type:"tank",command:"advance"},{id:503,col:0,row:0,sizeCol:4,sizeRow:4,type:"tank",command:"advance"},{id:504,col:-10,row:-2,sizeCol:6,sizeRow:2,type:"warrior",command:"advance"},{id:505,col:10,row:-2,sizeCol:6,sizeRow:2,type:"warrior",command:"advance"},{id:506,col:0,row:-6,sizeCol:8,sizeRow:2,type:"artillery",command:"advance"},{id:507,col:-16,row:-8,sizeCol:4,sizeRow:2,type:"archer",command:"advance"},{id:508,col:16,row:-8,sizeCol:4,sizeRow:2,type:"archer",command:"advance"}],X3="Blitzkrieg",q3=t=>{const e=Qe(t),n=nt(t),s=At(t),r=lt(t),o=1-e.tank/t.length,i=1-(n.left+n.right)/2,a=1-s,l=1-r,c=n.front;return(o*.25+i*.2+a*.2+l*.15+c*.2)*100},Y3=Object.freeze(Object.defineProperty({__proto__:null,name:X3,probabilityScore:q3,units:K3},Symbol.toStringTag,{value:"Module"})),Q3=[{id:601,col:-16,row:-8,sizeCol:6,sizeRow:2,type:"artillery",command:"advance"},{id:602,col:0,row:-8,sizeCol:6,sizeRow:2,type:"artillery",command:"advance"},{id:603,col:16,row:-8,sizeCol:6,sizeRow:2,type:"artillery",command:"advance"},{id:604,col:-12,row:-4,sizeCol:4,sizeRow:2,type:"archer",command:"advance"},{id:605,col:0,row:-4,sizeCol:4,sizeRow:2,type:"archer",command:"advance"},{id:606,col:12,row:-4,sizeCol:4,sizeRow:2,type:"archer",command:"advance"},{id:607,col:-16,row:0,sizeCol:6,sizeRow:2,type:"warrior",command:"wait-advance"},{id:608,col:0,row:0,sizeCol:6,sizeRow:2,type:"warrior",command:"wait-advance"},{id:609,col:16,row:0,sizeCol:6,sizeRow:2,type:"warrior",command:"wait-advance"},{id:610,col:-10,row:-6,sizeCol:4,sizeRow:4,type:"tank",command:"wait-advance"},{id:611,col:10,row:-6,sizeCol:4,sizeRow:4,type:"tank",command:"wait-advance"}],Z3="Scorched Earth",J3=t=>{const e=Qe(t),n=nt(t),s=At(t),r=lt(t),o=1-(e.artillery+e.archer)/t.length,i=s,a=n.front,l=r,c=(e.warrior+e.tank)/t.length;return(o*.25+i*.2+a*.2+l*.15+c*.2)*100},eM=Object.freeze(Object.defineProperty({__proto__:null,name:Z3,probabilityScore:J3,units:Q3},Symbol.toStringTag,{value:"Module"})),tM=[{id:701,col:-8,row:0,sizeCol:8,sizeRow:2,type:"warrior",command:"advance"},{id:702,col:8,row:0,sizeCol:8,sizeRow:2,type:"warrior",command:"advance"},{id:703,col:-8,row:-4,sizeCol:4,sizeRow:4,type:"tank",command:"wait-advance"},{id:704,col:0,row:-4,sizeCol:4,sizeRow:4,type:"tank",command:"wait-advance"},{id:705,col:8,row:-4,sizeCol:4,sizeRow:4,type:"tank",command:"wait-advance"},{id:706,col:-12,row:-8,sizeCol:6,sizeRow:2,type:"artillery",command:"advance-wait"},{id:707,col:12,row:-8,sizeCol:6,sizeRow:2,type:"artillery",command:"advance-wait"},{id:708,col:-16,row:-6,sizeCol:4,sizeRow:2,type:"archer",command:"wait-advance"},{id:709,col:0,row:-6,sizeCol:4,sizeRow:2,type:"archer",command:"wait-advance"},{id:710,col:16,row:-6,sizeCol:4,sizeRow:2,type:"archer",command:"wait-advance"}],nM="Trojan Horse",sM=t=>{const e=Qe(t),n=nt(t),s=At(t),r=lt(t),o=(e.warrior+e.tank)/t.length,i=n.front,a=1-s,l=1-(e.artillery+e.archer)/t.length,c=r;return(o*.3+i*.25+a*.15+l*.2+c*.1)*100},rM=Object.freeze(Object.defineProperty({__proto__:null,name:nM,probabilityScore:sM,units:tM},Symbol.toStringTag,{value:"Module"})),oM=[{id:801,col:0,row:2,sizeCol:4,sizeRow:4,type:"tank",command:"advance"},{id:802,col:-4,row:0,sizeCol:4,sizeRow:4,type:"tank",command:"advance"},{id:803,col:-8,row:-2,sizeCol:6,sizeRow:2,type:"warrior",command:"advance"},{id:804,col:-12,row:-4,sizeCol:4,sizeRow:2,type:"archer",command:"wait-advance"},{id:805,col:-16,row:-6,sizeCol:6,sizeRow:2,type:"artillery",command:"advance"},{id:806,col:4,row:0,sizeCol:4,sizeRow:4,type:"tank",command:"advance"},{id:807,col:8,row:-2,sizeCol:6,sizeRow:2,type:"warrior",command:"advance"},{id:808,col:12,row:-4,sizeCol:4,sizeRow:2,type:"archer",command:"wait-advance"},{id:809,col:16,row:-6,sizeCol:6,sizeRow:2,type:"artillery",command:"advance"},{id:810,col:0,row:-4,sizeCol:6,sizeRow:2,type:"warrior",command:"advance"}],iM="Flying V",aM=t=>{const e=Qe(t),n=nt(t),s=At(t),r=lt(t),o=1-(n.left+n.right)/2,i=1-Math.max(Math.abs(e.warrior-e.archer),Math.abs(e.warrior-e.tank),Math.abs(e.warrior-e.artillery),Math.abs(e.archer-e.tank),Math.abs(e.archer-e.artillery),Math.abs(e.tank-e.artillery))/t.length,a=s,l=n.front,c=1-r;return(o*.3+i*.2+a*.15+l*.25+c*.1)*100},lM=Object.freeze(Object.defineProperty({__proto__:null,name:iM,probabilityScore:aM,units:oM},Symbol.toStringTag,{value:"Module"})),cM=[{id:901,col:-8,row:0,sizeCol:8,sizeRow:2,type:"warrior",command:"wait-advance"},{id:902,col:8,row:0,sizeCol:8,sizeRow:2,type:"warrior",command:"wait-advance"},{id:903,col:-4,row:-2,sizeCol:4,sizeRow:4,type:"tank",command:"wait-advance"},{id:904,col:4,row:-2,sizeCol:4,sizeRow:4,type:"tank",command:"wait-advance"},{id:905,col:-16,row:-4,sizeCol:4,sizeRow:4,type:"tank",command:"advance"},{id:906,col:-20,row:-6,sizeCol:6,sizeRow:2,type:"warrior",command:"advance"},{id:907,col:16,row:-4,sizeCol:4,sizeRow:4,type:"tank",command:"advance"},{id:908,col:20,row:-6,sizeCol:6,sizeRow:2,type:"warrior",command:"advance"},{id:909,col:-12,row:-6,sizeCol:4,sizeRow:2,type:"archer",command:"wait-advance"},{id:910,col:12,row:-6,sizeCol:4,sizeRow:2,type:"archer",command:"wait-advance"},{id:911,col:0,row:-8,sizeCol:6,sizeRow:2,type:"artillery",command:"wait-advance"}],uM="Hammer and Anvil",hM=t=>{const e=Qe(t),n=nt(t),s=At(t),r=lt(t),o=1-(n.left+n.right)/2,i=(e.warrior+e.tank)/t.length,a=1-s,l=n.front,c=r,u=1-(e.artillery+e.archer)/t.length;return(o*.25+i*.2+a*.15+l*.2+c*.1+u*.1)*100},dM=Object.freeze(Object.defineProperty({__proto__:null,name:uM,probabilityScore:hM,units:cM},Symbol.toStringTag,{value:"Module"})),fM=[{id:1001,col:12,row:2,sizeCol:4,sizeRow:4,type:"tank",command:"advance"},{id:1002,col:8,row:0,sizeCol:6,sizeRow:2,type:"warrior",command:"advance"},{id:1003,col:4,row:-2,sizeCol:4,sizeRow:4,type:"tank",command:"advance"},{id:1004,col:0,row:-4,sizeCol:6,sizeRow:2,type:"warrior",command:"advance"},{id:1005,col:-4,row:-6,sizeCol:4,sizeRow:4,type:"tank",command:"advance"},{id:1006,col:-8,row:-8,sizeCol:6,sizeRow:2,type:"warrior",command:"advance"},{id:1007,col:12,row:-4,sizeCol:4,sizeRow:2,type:"archer",command:"wait-advance"},{id:1008,col:0,row:-8,sizeCol:4,sizeRow:2,type:"archer",command:"wait-advance"},{id:1009,col:-16,row:-12,sizeCol:6,sizeRow:2,type:"artillery",command:"advance"}],pM="Echelon Formation",mM=t=>{const e=Qe(t),n=nt(t),s=At(t),r=lt(t),o=Math.abs(n.left-n.right),i=1-Math.max(Math.abs(e.warrior-e.archer),Math.abs(e.warrior-e.tank),Math.abs(e.warrior-e.artillery),Math.abs(e.archer-e.tank),Math.abs(e.archer-e.artillery),Math.abs(e.tank-e.artillery))/t.length,a=s,l=1-e.artillery/t.length,c=1-r;return(o*.25+i*.2+a*.2+l*.25+c*.1)*100},gM=Object.freeze(Object.defineProperty({__proto__:null,name:pM,probabilityScore:mM,units:fM},Symbol.toStringTag,{value:"Module"})),xM=[{id:1101,col:-6,row:2,sizeCol:6,sizeRow:2,type:"warrior",command:"advance"},{id:1102,col:6,row:2,sizeCol:6,sizeRow:2,type:"warrior",command:"advance"},{id:1103,col:-8,row:-2,sizeCol:6,sizeRow:2,type:"warrior",command:"advance"},{id:1104,col:8,row:-2,sizeCol:6,sizeRow:2,type:"warrior",command:"advance"},{id:1105,col:-6,row:-6,sizeCol:6,sizeRow:2,type:"warrior",command:"advance"},{id:1106,col:6,row:-6,sizeCol:6,sizeRow:2,type:"warrior",command:"advance"},{id:1107,col:-3,row:-2,sizeCol:3,sizeRow:3,type:"tank",command:"advance"},{id:1108,col:3,row:-2,sizeCol:3,sizeRow:3,type:"tank",command:"advance"},{id:1109,col:-4,row:-4,sizeCol:3,sizeRow:2,type:"archer",command:"advance"},{id:1110,col:4,row:-4,sizeCol:3,sizeRow:2,type:"archer",command:"advance"},{id:1111,col:0,row:-4,sizeCol:4,sizeRow:2,type:"artillery",command:"advance"}],yM="Turtle Formation",wM=t=>{const e=Qe(t),n=nt(t),s=At(t),r=lt(t),o=(e.warrior+e.tank)/t.length,i=1-s,a=r,l=1-e.artillery/t.length,c=1-(e.artillery+e.archer)/t.length,u=n.front;return(o*.25+i*.2+a*.15+l*.2+c*.1+u*.1)*100},vM=Object.freeze(Object.defineProperty({__proto__:null,name:yM,probabilityScore:wM,units:xM},Symbol.toStringTag,{value:"Module"})),bM=[{id:1201,col:-12,row:2,sizeCol:3,sizeRow:2,type:"archer",command:"wait-advance"},{id:1202,col:-4,row:2,sizeCol:3,sizeRow:2,type:"archer",command:"wait-advance"},{id:1203,col:4,row:2,sizeCol:3,sizeRow:2,type:"archer",command:"wait-advance"},{id:1204,col:12,row:2,sizeCol:3,sizeRow:2,type:"archer",command:"wait-advance"},{id:1205,col:-8,row:-2,sizeCol:6,sizeRow:2,type:"warrior",command:"advance"},{id:1206,col:8,row:-2,sizeCol:6,sizeRow:2,type:"warrior",command:"advance"},{id:1207,col:-6,row:-6,sizeCol:4,sizeRow:4,type:"tank",command:"advance"},{id:1208,col:6,row:-6,sizeCol:4,sizeRow:4,type:"tank",command:"advance"},{id:1209,col:-8,row:-10,sizeCol:6,sizeRow:2,type:"artillery",command:"advance"},{id:1210,col:8,row:-10,sizeCol:6,sizeRow:2,type:"artillery",command:"advance"}],CM="Skirmisher Screen",kM=t=>{const e=Qe(t),n=nt(t),s=At(t),r=lt(t),o=(e.tank+e.artillery)/t.length,i=s,a=r,l=1-e.archer/t.length,c=n.front,u=1-e.warrior/t.length;return(o*.25+i*.2+a*.15+l*.15+c*.15+u*.1)*100},SM=Object.freeze(Object.defineProperty({__proto__:null,name:CM,probabilityScore:kM,units:bM},Symbol.toStringTag,{value:"Module"})),cC=[HO,qO,JO,s3,a3,h3,m3,w3,k3,$3,E3,D3,z3,P3,W3,j3,Y3,eM,rM,lM,dM,gM,vM,SM];/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -118,7 +118,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const $M=1e-7,NM=1e-4;class jI{constructor(e,n){this.backend=e,this.dataMover=n,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,n){this.dataIdsCount++,this.data.set(e,n)}has(e){return this.data.has(e)}delete(e){return this.dataIdsCount--,this.data.delete(e)}numDataIds(){return this.dataIdsCount}}class Mx{refCount(e){return Ln("refCount")}incRef(e){return Ln("incRef")}timerAvailable(){return!0}time(e){return Ln("time")}read(e){return Ln("read")}readSync(e){return Ln("readSync")}readToGPU(e,n){return Ln("readToGPU")}numDataIds(){return Ln("numDataIds")}disposeData(e,n){return Ln("disposeData")}write(e,n,s){return Ln("write")}move(e,n,s,r,o){return Ln("move")}createTensorFromGPUData(e,n,s){return Ln("createTensorFromGPUData")}memory(){return Ln("memory")}floatPrecision(){return Ln("floatPrecision")}epsilon(){return this.floatPrecision()===32?$M:NM}dispose(){return Ln("dispose")}}function Ln(t){throw new Error(`'${t}' not yet implemented or not found in the registry. This kernel may not be supported by the tfjs backend you have chosen`)}/** + */const IM=1e-7,$M=1e-4;class jI{constructor(e,n){this.backend=e,this.dataMover=n,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,n){this.dataIdsCount++,this.data.set(e,n)}has(e){return this.data.has(e)}delete(e){return this.dataIdsCount--,this.data.delete(e)}numDataIds(){return this.dataIdsCount}}class Mx{refCount(e){return Ln("refCount")}incRef(e){return Ln("incRef")}timerAvailable(){return!0}time(e){return Ln("time")}read(e){return Ln("read")}readSync(e){return Ln("readSync")}readToGPU(e,n){return Ln("readToGPU")}numDataIds(){return Ln("numDataIds")}disposeData(e,n){return Ln("disposeData")}write(e,n,s){return Ln("write")}move(e,n,s,r,o){return Ln("move")}createTensorFromGPUData(e,n,s){return Ln("createTensorFromGPUData")}memory(){return Ln("memory")}floatPrecision(){return Ln("floatPrecision")}epsilon(){return this.floatPrecision()===32?IM:$M}dispose(){return Ln("dispose")}}function Ln(t){throw new Error(`'${t}' not yet implemented or not found in the registry. This kernel may not be supported by the tfjs backend you have chosen`)}/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -133,7 +133,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function TM(t){let e=t.length,n=0;for(;e>0;)n=Math.random()*e|0,e--,da(t,e,n)}function Ti(t,e,n){return Math.max(t,Math.min(e,n))}function Px(t){return t%2===0?t:t+1}function da(t,e,n){const s=t[e];t[e]=t[n],t[n]=s}function EM(t){let e=0;for(let n=0;nn+` Shapes ${t} and ${e} must match`)}function Bx(t){I(t!=null,()=>"The input to the tensor constructor must be a non-null value.")}function j(t){if(t.length===0)return 1;let e=t[0];for(let n=1;n0,n,s){return new Promise((r,o)=>{let i=0;const a=()=>{if(t()){r();return}i++;const l=e(i);if(n!=null&&i>=n){o();return}s!=null?s(a,l):setTimeout(a,l)};a()})}function KI(t,e){let n=1,s=-1;for(let o=0;o=0)n*=t[o];else if(t[o]===-1){if(s!==-1)throw Error(`Shapes can only have 1 implicit size. Found -1 at dim ${s} and dim ${o}`);s=o}else if(t[o]<0)throw Error(`Shapes can not be < 0. Found ${t[o]} at dim ${o}`);if(s===-1){if(e>0&&e!==n)throw Error(`Size(${e}) must match the product of shape ${t}`);return t}if(n===0)throw Error(`Cannot infer the missing size in [${t}] when there are 0 elements`);if(e%n!==0)throw Error(`The implicit shape can't be a fractional number. Got ${e} / ${n}`);const r=t.slice();return r[s]=e/n,r}function Re(t,e){const n=e.length;return t=t==null?e.map((s,r)=>r):[].concat(t),I(t.every(s=>s>=-n&&s`All values in axis param must be in range [-${n}, ${n}) but got axis ${t}`),I(t.every(s=>nl(s)),()=>`All values in axis param must be integers but got axis ${t}`),t.map(s=>s<0?n+s:s)}function Vo(t,e){const n=[],s=[],r=e!=null&&Array.isArray(e)&&e.length===0,o=e==null||r?null:Re(e,t).sort();let i=0;for(let a=0;aa)&&t[a]===1&&(n.push(t[a]),s.push(a)),o[i]<=a&&i++}t[a]!==1&&(n.push(t[a]),s.push(a))}return{newShape:n,keptDims:s}}function cn(t,e){return kt(t,e)}function kt(t,e){let n=null;if(t==null||t==="float32")n=new Float32Array(e);else if(t==="int32")n=new Int32Array(e);else if(t==="bool")n=new Uint8Array(e);else if(t==="string")n=new Array(e);else throw new Error(`Unknown data type ${t}`);return n}function RM(t,e){for(let n=0;ne+=n.length),e}function fu(t){return typeof t=="string"||t instanceof String}function _M(t){return typeof t=="boolean"}function q0(t){return typeof t=="number"}function wl(t){return Array.isArray(t)?wl(t[0]):t instanceof Float32Array?"float32":t instanceof Int32Array||t instanceof Uint8Array||t instanceof Uint8ClampedArray?"int32":q0(t)?"float32":fu(t)?"string":_M(t)?"bool":"float32"}function Y0(t){return!!(t&&t.constructor&&t.call&&t.apply)}function Q0(t,e){for(let n=e;n=0;--s)n[s]=n[s+1]*t[s+1];return n}function qI(t,e,n,s=!1){const r=new Array;if(e.length===1){const o=e[0]*(s?2:1);for(let i=0;il*c)*(s?2:1);for(let l=0;lr*o)*(n?2:1);if(s===0)return[];if(s!==e.length)throw new Error(`[${t}] does not match the input size ${e.length}${n?" for a complex tensor":""}.`);return qI(0,t,e,n)}function FM(t,e){if(Array.isArray(t))return t;if(e==="float32")return t instanceof Float32Array?t:new Float32Array(t);if(e==="int32")return t instanceof Int32Array?t:new Int32Array(t);if(e==="bool"||e==="string")return Uint8Array.from(new Int32Array(t));throw new Error(`Unknown dtype ${e}`)}function Vx(t,e){const n=un(t,e);for(let s=0;ss*r,1);if(e==null||e==="float32")return qs(t,new Float32Array(n));if(e==="int32")return qs(t,new Int32Array(n));if(e==="bool")return qs(t,new Uint8Array(n));throw new Error(`Unknown data type ${e}`)}function qr(t){t.forEach(e=>{I(Number.isInteger(e)&&e>=0,()=>`Tensor must have a shape comprised of positive integers but got shape [${t}].`)})}function xr(t,e,n){if(e===0)return 0;if(e===1)return t[0];let s=t[t.length-1];for(let r=0;r0;)n=Math.random()*e|0,e--,da(t,e,n)}function Ti(t,e,n){return Math.max(t,Math.min(e,n))}function Px(t){return t%2===0?t:t+1}function da(t,e,n){const s=t[e];t[e]=t[n],t[n]=s}function TM(t){let e=0;for(let n=0;nn+` Shapes ${t} and ${e} must match`)}function Bx(t){I(t!=null,()=>"The input to the tensor constructor must be a non-null value.")}function j(t){if(t.length===0)return 1;let e=t[0];for(let n=1;n0,n,s){return new Promise((r,o)=>{let i=0;const a=()=>{if(t()){r();return}i++;const l=e(i);if(n!=null&&i>=n){o();return}s!=null?s(a,l):setTimeout(a,l)};a()})}function KI(t,e){let n=1,s=-1;for(let o=0;o=0)n*=t[o];else if(t[o]===-1){if(s!==-1)throw Error(`Shapes can only have 1 implicit size. Found -1 at dim ${s} and dim ${o}`);s=o}else if(t[o]<0)throw Error(`Shapes can not be < 0. Found ${t[o]} at dim ${o}`);if(s===-1){if(e>0&&e!==n)throw Error(`Size(${e}) must match the product of shape ${t}`);return t}if(n===0)throw Error(`Cannot infer the missing size in [${t}] when there are 0 elements`);if(e%n!==0)throw Error(`The implicit shape can't be a fractional number. Got ${e} / ${n}`);const r=t.slice();return r[s]=e/n,r}function Re(t,e){const n=e.length;return t=t==null?e.map((s,r)=>r):[].concat(t),I(t.every(s=>s>=-n&&s`All values in axis param must be in range [-${n}, ${n}) but got axis ${t}`),I(t.every(s=>nl(s)),()=>`All values in axis param must be integers but got axis ${t}`),t.map(s=>s<0?n+s:s)}function Vo(t,e){const n=[],s=[],r=e!=null&&Array.isArray(e)&&e.length===0,o=e==null||r?null:Re(e,t).sort();let i=0;for(let a=0;aa)&&t[a]===1&&(n.push(t[a]),s.push(a)),o[i]<=a&&i++}t[a]!==1&&(n.push(t[a]),s.push(a))}return{newShape:n,keptDims:s}}function cn(t,e){return kt(t,e)}function kt(t,e){let n=null;if(t==null||t==="float32")n=new Float32Array(e);else if(t==="int32")n=new Int32Array(e);else if(t==="bool")n=new Uint8Array(e);else if(t==="string")n=new Array(e);else throw new Error(`Unknown data type ${t}`);return n}function EM(t,e){for(let n=0;ne+=n.length),e}function du(t){return typeof t=="string"||t instanceof String}function DM(t){return typeof t=="boolean"}function q0(t){return typeof t=="number"}function wl(t){return Array.isArray(t)?wl(t[0]):t instanceof Float32Array?"float32":t instanceof Int32Array||t instanceof Uint8Array||t instanceof Uint8ClampedArray?"int32":q0(t)?"float32":du(t)?"string":DM(t)?"bool":"float32"}function Y0(t){return!!(t&&t.constructor&&t.call&&t.apply)}function Q0(t,e){for(let n=e;n=0;--s)n[s]=n[s+1]*t[s+1];return n}function qI(t,e,n,s=!1){const r=new Array;if(e.length===1){const o=e[0]*(s?2:1);for(let i=0;il*c)*(s?2:1);for(let l=0;lr*o)*(n?2:1);if(s===0)return[];if(s!==e.length)throw new Error(`[${t}] does not match the input size ${e.length}${n?" for a complex tensor":""}.`);return qI(0,t,e,n)}function _M(t,e){if(Array.isArray(t))return t;if(e==="float32")return t instanceof Float32Array?t:new Float32Array(t);if(e==="int32")return t instanceof Int32Array?t:new Int32Array(t);if(e==="bool"||e==="string")return Uint8Array.from(new Int32Array(t));throw new Error(`Unknown dtype ${e}`)}function Vx(t,e){const n=un(t,e);for(let s=0;ss*r,1);if(e==null||e==="float32")return qs(t,new Float32Array(n));if(e==="int32")return qs(t,new Int32Array(n));if(e==="bool")return qs(t,new Uint8Array(n));throw new Error(`Unknown data type ${e}`)}function qr(t){t.forEach(e=>{I(Number.isInteger(e)&&e>=0,()=>`Tensor must have a shape comprised of positive integers but got shape [${t}].`)})}function xr(t,e,n){if(e===0)return 0;if(e===1)return t[0];let s=t[t.length-1];for(let r=0;r"u"||typeof this.global.location>"u"||typeof this.global.location.search>"u")return;const e=this.getQueryParams(this.global.location.search);hC in e&&e[hC].split(",").forEach(s=>{const[r,o]=s.split(":");this.urlFlags[r]=PM(r,o)})}}function OM(t){const e={};return t.replace(/[?&]([^=?&]+)(?:=([^&]*))?/g,(n,...s)=>(MM(e,s[0],s[1]),s.join("="))),e}function MM(t,e,n){t[decodeURIComponent(e)]=decodeURIComponent(n||"")}function PM(t,e){const n=e.toLowerCase();return n==="true"||n==="false"?n==="true":`${+n}`===n?+n:e}function W(){return QI}let QI=null;function LM(t){QI=t}/** + */const hC="tfjsflags";class FM{constructor(e){this.global=e,this.flags={},this.flagRegistry={},this.urlFlags={},this.getQueryParams=zM,this.populateURLFlags()}setPlatform(e,n){this.platform!=null&&(W().getBool("IS_TEST")||W().getBool("PROD")||console.warn(`Platform ${this.platformName} has already been set. Overwriting the platform with ${e}.`)),this.platformName=e,this.platform=n}registerFlag(e,n,s){if(this.flagRegistry[e]={evaluationFn:n,setHook:s},this.urlFlags[e]!=null){const r=this.urlFlags[e];W().getBool("IS_TEST")||W().getBool("PROD")||console.warn(`Setting feature override from URL ${e}: ${r}.`),this.set(e,r)}}async getAsync(e){return e in this.flags?this.flags[e]:(this.flags[e]=await this.evaluateFlag(e),this.flags[e])}get(e){if(e in this.flags)return this.flags[e];const n=this.evaluateFlag(e);if(Wx(n))throw new Error(`Flag ${e} cannot be synchronously evaluated. Please use getAsync() instead.`);return this.flags[e]=n,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,n){if(this.flagRegistry[e]==null)throw new Error(`Cannot set flag ${e} as it has not been registered.`);this.flags[e]=n,this.flagRegistry[e].setHook!=null&&this.flagRegistry[e].setHook(n)}evaluateFlag(e){if(this.flagRegistry[e]==null)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(typeof this.global>"u"||typeof this.global.location>"u"||typeof this.global.location.search>"u")return;const e=this.getQueryParams(this.global.location.search);hC in e&&e[hC].split(",").forEach(s=>{const[r,o]=s.split(":");this.urlFlags[r]=MM(r,o)})}}function zM(t){const e={};return t.replace(/[?&]([^=?&]+)(?:=([^&]*))?/g,(n,...s)=>(OM(e,s[0],s[1]),s.join("="))),e}function OM(t,e,n){t[decodeURIComponent(e)]=decodeURIComponent(n||"")}function MM(t,e){const n=e.toLowerCase();return n==="true"||n==="false"?n==="true":`${+n}`===n?+n:e}function W(){return QI}let QI=null;function PM(t){QI=t}/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -163,7 +163,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */let vg;function ZI(){if(vg==null){let t;if(typeof window<"u")t=window;else if(typeof global<"u")t=global;else if(typeof process<"u")t=process;else if(typeof self<"u")t=self;else throw new Error("Could not find a global object");vg=t}return vg}function BM(){const t=ZI();return t._tfGlobals==null&&(t._tfGlobals=new Map),t._tfGlobals}function Ux(t,e){const n=BM();if(n.has(t))return n.get(t);{const s=e();return n.set(t,s),n.get(t)}}const pp="Abs",pu="Acos",mu="Acosh",bl="Add",Gx="AddN",Hx="All",jx="Any",mp="ArgMax",gp="ArgMin",gu="Asin",xu="Asinh",yu="Atan",wu="Atanh",vu="Atan2",xp="AvgPool",Kx="AvgPoolGrad",yp="AvgPool3D",Xx="AvgPool3DGrad",wp="BatchMatMul",vp="BatchToSpaceND",qx="Bincount",Yx="BitwiseAnd",VM="BroadcastTo",JI="BroadcastArgs",bu="Cast",Cu="Ceil",ku="ClipByValue",Qx="Complex",bp="ComplexAbs",Cp="Concat",kp="Conv2D",Zx="Conv2DBackpropFilter",Sp="Conv2DBackpropInput",Ip="Conv3D",Jx="Conv3DBackpropFilterV2",ey="Conv3DBackpropInputV2",Su="Cos",Iu="Cosh",ty="Cumprod",$p="Cumsum",ny="CropAndResize",sy="DenseBincount",ry="DepthToSpace",Np="DepthwiseConv2dNative",oy="DepthwiseConv2dNativeBackpropFilter",iy="DepthwiseConv2dNativeBackpropInput",e$="Diag",Tp="Dilation2D",Z0="Dilation2DBackpropInput",J0="Dilation2DBackpropFilter",WM="Draw",$u="RealDiv",ay="Einsum",Nu="Elu",ly="EluGrad",Tu="Erf",Ep="Equal",Eu="Exp",Rp="ExpandDims",Ru="Expm1",cy="FFT",uy="Fill",hy="FlipLeftRight",Au="Floor",Du="FloorDiv",Ap="FusedBatchNorm",Dp="GatherV2",t$="GatherNd",_p="Greater",_u="GreaterEqual",Fu="Identity",dy="IFFT",fy="Imag",zu="IsFinite",Ou="IsInf",Mu="IsNan",Fp="LeakyRelu",zp="Less",Op="LessEqual",n$="LinSpace",Pu="Log",Lu="Log1p",Mp="LogicalAnd",Pp="LogicalNot",Lp="LogicalOr",UM="LogSoftmax",Bp="LRN",py="LRNGrad",Vp="Max",Bu="Maximum",Wp="MaxPool",my="MaxPoolGrad",Up="MaxPool3D",gy="MaxPool3DGrad",s$="MaxPoolWithArgmax",Gp="Mean",Hp="Min",Vu="Minimum",jp="MirrorPad",Wu="Mod",r$="Multinomial",Uu="Multiply",Kp="Neg",Xp="NotEqual",xy="NonMaxSuppressionV3",yy="NonMaxSuppressionV4",wy="NonMaxSuppressionV5",qp="OnesLike",Yp="OneHot",Qp="Pack",Zp="PadV2",Gu="Pow",Jp="Prelu",em="Prod",o$="RaggedGather",i$="RaggedRange",a$="RaggedTensorToTensor",vy="Range",by="Real",Hu="Reciprocal",ju="Relu",tm="Reshape",nm="ResizeNearestNeighbor",Cy="ResizeNearestNeighborGrad",sm="ResizeBilinear",ky="ResizeBilinearGrad",Ku="Relu6",rm="Reverse",Xu="Round",qu="Rsqrt",l$="ScatterNd",c$="TensorScatterUpdate",u$="SearchSorted",om="Select",Yu="Selu",im="Slice",Qu="Sin",Zu="Sinh",Ju="Sign",eh="Sigmoid",th="Softplus",nh="Sqrt",am="Sum",lm="SpaceToBatchND",cm="SplitV",um="Softmax",h$="SparseFillEmptyRows",d$="SparseReshape",f$="SparseSegmentMean",p$="SparseSegmentSum",m$="SparseToDense",sh="SquaredDifference",Sy="Square",Iy="StaticRegexReplace",$y="StridedSlice",g$="StringNGrams",x$="StringSplit",y$="StringToHashBucketFast",rh="Sub",oh="Tan",ih="Tanh",ah="Tile",Ny="TopK",Ty="Transform",Ma="Transpose",Ey="Unique",hm="Unpack",dm="UnsortedSegmentSum",fm="ZerosLike",lh="Step",GM="FromPixels",Ry="RotateWithOffset",ff="_FusedMatMul",pf="FusedConv2D",w$="FusedDepthwiseConv2D";/** + */let vg;function ZI(){if(vg==null){let t;if(typeof window<"u")t=window;else if(typeof global<"u")t=global;else if(typeof process<"u")t=process;else if(typeof self<"u")t=self;else throw new Error("Could not find a global object");vg=t}return vg}function LM(){const t=ZI();return t._tfGlobals==null&&(t._tfGlobals=new Map),t._tfGlobals}function Ux(t,e){const n=LM();if(n.has(t))return n.get(t);{const s=e();return n.set(t,s),n.get(t)}}const pp="Abs",fu="Acos",pu="Acosh",bl="Add",Gx="AddN",Hx="All",jx="Any",mp="ArgMax",gp="ArgMin",mu="Asin",gu="Asinh",xu="Atan",yu="Atanh",wu="Atan2",xp="AvgPool",Kx="AvgPoolGrad",yp="AvgPool3D",Xx="AvgPool3DGrad",wp="BatchMatMul",vp="BatchToSpaceND",qx="Bincount",Yx="BitwiseAnd",BM="BroadcastTo",JI="BroadcastArgs",vu="Cast",bu="Ceil",Cu="ClipByValue",Qx="Complex",bp="ComplexAbs",Cp="Concat",kp="Conv2D",Zx="Conv2DBackpropFilter",Sp="Conv2DBackpropInput",Ip="Conv3D",Jx="Conv3DBackpropFilterV2",ey="Conv3DBackpropInputV2",ku="Cos",Su="Cosh",ty="Cumprod",$p="Cumsum",ny="CropAndResize",sy="DenseBincount",ry="DepthToSpace",Np="DepthwiseConv2dNative",oy="DepthwiseConv2dNativeBackpropFilter",iy="DepthwiseConv2dNativeBackpropInput",e$="Diag",Tp="Dilation2D",Z0="Dilation2DBackpropInput",J0="Dilation2DBackpropFilter",VM="Draw",Iu="RealDiv",ay="Einsum",$u="Elu",ly="EluGrad",Nu="Erf",Ep="Equal",Tu="Exp",Rp="ExpandDims",Eu="Expm1",cy="FFT",uy="Fill",hy="FlipLeftRight",Ru="Floor",Au="FloorDiv",Ap="FusedBatchNorm",Dp="GatherV2",t$="GatherNd",_p="Greater",Du="GreaterEqual",_u="Identity",dy="IFFT",fy="Imag",Fu="IsFinite",zu="IsInf",Ou="IsNan",Fp="LeakyRelu",zp="Less",Op="LessEqual",n$="LinSpace",Mu="Log",Pu="Log1p",Mp="LogicalAnd",Pp="LogicalNot",Lp="LogicalOr",WM="LogSoftmax",Bp="LRN",py="LRNGrad",Vp="Max",Lu="Maximum",Wp="MaxPool",my="MaxPoolGrad",Up="MaxPool3D",gy="MaxPool3DGrad",s$="MaxPoolWithArgmax",Gp="Mean",Hp="Min",Bu="Minimum",jp="MirrorPad",Vu="Mod",r$="Multinomial",Wu="Multiply",Kp="Neg",Xp="NotEqual",xy="NonMaxSuppressionV3",yy="NonMaxSuppressionV4",wy="NonMaxSuppressionV5",qp="OnesLike",Yp="OneHot",Qp="Pack",Zp="PadV2",Uu="Pow",Jp="Prelu",em="Prod",o$="RaggedGather",i$="RaggedRange",a$="RaggedTensorToTensor",vy="Range",by="Real",Gu="Reciprocal",Hu="Relu",tm="Reshape",nm="ResizeNearestNeighbor",Cy="ResizeNearestNeighborGrad",sm="ResizeBilinear",ky="ResizeBilinearGrad",ju="Relu6",rm="Reverse",Ku="Round",Xu="Rsqrt",l$="ScatterNd",c$="TensorScatterUpdate",u$="SearchSorted",om="Select",qu="Selu",im="Slice",Yu="Sin",Qu="Sinh",Zu="Sign",Ju="Sigmoid",eh="Softplus",th="Sqrt",am="Sum",lm="SpaceToBatchND",cm="SplitV",um="Softmax",h$="SparseFillEmptyRows",d$="SparseReshape",f$="SparseSegmentMean",p$="SparseSegmentSum",m$="SparseToDense",nh="SquaredDifference",Sy="Square",Iy="StaticRegexReplace",$y="StridedSlice",g$="StringNGrams",x$="StringSplit",y$="StringToHashBucketFast",sh="Sub",rh="Tan",oh="Tanh",ih="Tile",Ny="TopK",Ty="Transform",Ma="Transpose",Ey="Unique",hm="Unpack",dm="UnsortedSegmentSum",fm="ZerosLike",ah="Step",UM="FromPixels",Ry="RotateWithOffset",df="_FusedMatMul",ff="FusedConv2D",w$="FusedDepthwiseConv2D";/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -178,7 +178,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function es(...t){W().getBool("IS_TEST")||W().getBool("PROD")||console.warn(...t)}function HM(...t){W().getBool("IS_TEST")||W().getBool("PROD")||console.log(...t)}/** + */function es(...t){W().getBool("IS_TEST")||W().getBool("PROD")||console.warn(...t)}function GM(...t){W().getBool("IS_TEST")||W().getBool("PROD")||console.log(...t)}/** * @license * Copyright 2019 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -193,7 +193,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const mf=Ux("kernelRegistry",()=>new Map),e1=Ux("gradRegistry",()=>new Map);function dC(t,e){const n=b$(t,e);return mf.get(n)}function fC(t){return e1.get(t)}function pC(t){const e=mf.entries(),n=[];for(;;){const{done:s,value:r}=e.next();if(s)break;const[o,i]=r,[a]=o.split("_");a===t&&n.push(i)}return n}function v$(t){const{kernelName:e,backendName:n}=t,s=b$(e,n);mf.has(s)&&es(`The kernel '${e}' for backend '${n}' is already registered`),mf.set(s,t)}function jM(t){const{kernelName:e}=t;e1.has(e)&&W().getBool("DEBUG")&&es(`Overriding the gradient for '${e}'`),e1.set(e,t)}function b$(t,e){return`${e}_${t}`}/** + */const pf=Ux("kernelRegistry",()=>new Map),e1=Ux("gradRegistry",()=>new Map);function dC(t,e){const n=b$(t,e);return pf.get(n)}function fC(t){return e1.get(t)}function pC(t){const e=pf.entries(),n=[];for(;;){const{done:s,value:r}=e.next();if(s)break;const[o,i]=r,[a]=o.split("_");a===t&&n.push(i)}return n}function v$(t){const{kernelName:e,backendName:n}=t,s=b$(e,n);pf.has(s)&&es(`The kernel '${e}' for backend '${n}' is already registered`),pf.set(s,t)}function HM(t){const{kernelName:e}=t;e1.has(e)&&W().getBool("DEBUG")&&es(`Overriding the gradient for '${e}'`),e1.set(e,t)}function b$(t,e){return`${e}_${t}`}/** * @license * Copyright 2023 Google LLC. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -208,7 +208,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function C$(t){return t instanceof Float32Array||t instanceof Int32Array||t instanceof Uint8Array||t instanceof Uint8ClampedArray}var k$=it,vs=null;try{vs=new WebAssembly.Instance(new WebAssembly.Module(new Uint8Array([0,97,115,109,1,0,0,0,1,13,2,96,0,1,127,96,4,127,127,127,127,1,127,3,7,6,0,1,1,1,1,1,6,6,1,127,1,65,0,11,7,50,6,3,109,117,108,0,1,5,100,105,118,95,115,0,2,5,100,105,118,95,117,0,3,5,114,101,109,95,115,0,4,5,114,101,109,95,117,0,5,8,103,101,116,95,104,105,103,104,0,0,10,191,1,6,4,0,35,0,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,126,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,127,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,128,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,129,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,130,34,4,66,32,135,167,36,0,32,4,167,11])),{}).exports}catch{}function it(t,e,n){this.low=t|0,this.high=e|0,this.unsigned=!!n}it.prototype.__isLong__;Object.defineProperty(it.prototype,"__isLong__",{value:!0});function Qn(t){return(t&&t.__isLong__)===!0}it.isLong=Qn;var mC={},gC={};function ji(t,e){var n,s,r;return e?(t>>>=0,(r=0<=t&&t<256)&&(s=gC[t],s)?s:(n=at(t,(t|0)<0?-1:0,!0),r&&(gC[t]=n),n)):(t|=0,(r=-128<=t&&t<128)&&(s=mC[t],s)?s:(n=at(t,t<0?-1:0,!1),r&&(mC[t]=n),n))}it.fromInt=ji;function bs(t,e){if(isNaN(t))return e?di:Cs;if(e){if(t<0)return di;if(t>=S$)return N$}else{if(t<=-yC)return Un;if(t+1>=yC)return $$}return t<0?bs(-t,e).neg():at(t%sl|0,t/sl|0,e)}it.fromNumber=bs;function at(t,e,n){return new it(t,e,n)}it.fromBits=at;var gf=Math.pow;function Ay(t,e,n){if(t.length===0)throw Error("empty string");if(t==="NaN"||t==="Infinity"||t==="+Infinity"||t==="-Infinity")return Cs;if(typeof e=="number"?(n=e,e=!1):e=!!e,n=n||10,n<2||360)throw Error("interior hyphen");if(s===0)return Ay(t.substring(1),e,n).neg();for(var r=bs(gf(n,8)),o=Cs,i=0;i>>0:this.low};oe.toNumber=function(){return this.unsigned?(this.high>>>0)*sl+(this.low>>>0):this.high*sl+(this.low>>>0)};oe.toString=function(e){if(e=e||10,e<2||36>>0,u=c.toString(e);if(i=l,i.isZero())return u+a;for(;u.length<6;)u="0"+u;a=""+u+a}};oe.getHighBits=function(){return this.high};oe.getHighBitsUnsigned=function(){return this.high>>>0};oe.getLowBits=function(){return this.low};oe.getLowBitsUnsigned=function(){return this.low>>>0};oe.getNumBitsAbs=function(){if(this.isNegative())return this.eq(Un)?64:this.neg().getNumBitsAbs();for(var e=this.high!=0?this.high:this.low,n=31;n>0&&!(e&1<=0};oe.isOdd=function(){return(this.low&1)===1};oe.isEven=function(){return(this.low&1)===0};oe.equals=function(e){return Qn(e)||(e=nr(e)),this.unsigned!==e.unsigned&&this.high>>>31===1&&e.high>>>31===1?!1:this.high===e.high&&this.low===e.low};oe.eq=oe.equals;oe.notEquals=function(e){return!this.eq(e)};oe.neq=oe.notEquals;oe.ne=oe.notEquals;oe.lessThan=function(e){return this.comp(e)<0};oe.lt=oe.lessThan;oe.lessThanOrEqual=function(e){return this.comp(e)<=0};oe.lte=oe.lessThanOrEqual;oe.le=oe.lessThanOrEqual;oe.greaterThan=function(e){return this.comp(e)>0};oe.gt=oe.greaterThan;oe.greaterThanOrEqual=function(e){return this.comp(e)>=0};oe.gte=oe.greaterThanOrEqual;oe.ge=oe.greaterThanOrEqual;oe.compare=function(e){if(Qn(e)||(e=nr(e)),this.eq(e))return 0;var n=this.isNegative(),s=e.isNegative();return n&&!s?-1:!n&&s?1:this.unsigned?e.high>>>0>this.high>>>0||e.high===this.high&&e.low>>>0>this.low>>>0?-1:1:this.sub(e).isNegative()?-1:1};oe.comp=oe.compare;oe.negate=function(){return!this.unsigned&&this.eq(Un)?Un:this.not().add(Ta)};oe.neg=oe.negate;oe.add=function(e){Qn(e)||(e=nr(e));var n=this.high>>>16,s=this.high&65535,r=this.low>>>16,o=this.low&65535,i=e.high>>>16,a=e.high&65535,l=e.low>>>16,c=e.low&65535,u=0,h=0,d=0,f=0;return f+=o+c,d+=f>>>16,f&=65535,d+=r+l,h+=d>>>16,d&=65535,h+=s+a,u+=h>>>16,h&=65535,u+=n+i,u&=65535,at(d<<16|f,u<<16|h,this.unsigned)};oe.subtract=function(e){return Qn(e)||(e=nr(e)),this.add(e.neg())};oe.sub=oe.subtract;oe.multiply=function(e){if(this.isZero())return Cs;if(Qn(e)||(e=nr(e)),vs){var n=vs.mul(this.low,this.high,e.low,e.high);return at(n,vs.get_high(),this.unsigned)}if(e.isZero())return Cs;if(this.eq(Un))return e.isOdd()?Un:Cs;if(e.eq(Un))return this.isOdd()?Un:Cs;if(this.isNegative())return e.isNegative()?this.neg().mul(e.neg()):this.neg().mul(e).neg();if(e.isNegative())return this.mul(e.neg()).neg();if(this.lt(wC)&&e.lt(wC))return bs(this.toNumber()*e.toNumber(),this.unsigned);var s=this.high>>>16,r=this.high&65535,o=this.low>>>16,i=this.low&65535,a=e.high>>>16,l=e.high&65535,c=e.low>>>16,u=e.low&65535,h=0,d=0,f=0,p=0;return p+=i*u,f+=p>>>16,p&=65535,f+=o*u,d+=f>>>16,f&=65535,f+=i*c,d+=f>>>16,f&=65535,d+=r*u,h+=d>>>16,d&=65535,d+=o*c,h+=d>>>16,d&=65535,d+=i*l,h+=d>>>16,d&=65535,h+=s*u+r*c+o*l+i*a,h&=65535,at(f<<16|p,h<<16|d,this.unsigned)};oe.mul=oe.multiply;oe.divide=function(e){if(Qn(e)||(e=nr(e)),e.isZero())throw Error("division by zero");if(vs){if(!this.unsigned&&this.high===-2147483648&&e.low===-1&&e.high===-1)return this;var n=(this.unsigned?vs.div_u:vs.div_s)(this.low,this.high,e.low,e.high);return at(n,vs.get_high(),this.unsigned)}if(this.isZero())return this.unsigned?di:Cs;var s,r,o;if(this.unsigned){if(e.unsigned||(e=e.toUnsigned()),e.gt(this))return di;if(e.gt(this.shru(1)))return I$;o=di}else{if(this.eq(Un)){if(e.eq(Ta)||e.eq(t1))return Un;if(e.eq(Un))return Ta;var i=this.shr(1);return s=i.div(e).shl(1),s.eq(Cs)?e.isNegative()?Ta:t1:(r=this.sub(e.mul(s)),o=s.add(r.div(e)),o)}else if(e.eq(Un))return this.unsigned?di:Cs;if(this.isNegative())return e.isNegative()?this.neg().div(e.neg()):this.neg().div(e).neg();if(e.isNegative())return this.div(e.neg()).neg();o=Cs}for(r=this;r.gte(e);){s=Math.max(1,Math.floor(r.toNumber()/e.toNumber()));for(var a=Math.ceil(Math.log(s)/Math.LN2),l=a<=48?1:gf(2,a-48),c=bs(s),u=c.mul(e);u.isNegative()||u.gt(r);)s-=l,c=bs(s,this.unsigned),u=c.mul(e);c.isZero()&&(c=Ta),o=o.add(c),r=r.sub(u)}return o};oe.div=oe.divide;oe.modulo=function(e){if(Qn(e)||(e=nr(e)),vs){var n=(this.unsigned?vs.rem_u:vs.rem_s)(this.low,this.high,e.low,e.high);return at(n,vs.get_high(),this.unsigned)}return this.sub(this.div(e).mul(e))};oe.mod=oe.modulo;oe.rem=oe.modulo;oe.not=function(){return at(~this.low,~this.high,this.unsigned)};oe.and=function(e){return Qn(e)||(e=nr(e)),at(this.low&e.low,this.high&e.high,this.unsigned)};oe.or=function(e){return Qn(e)||(e=nr(e)),at(this.low|e.low,this.high|e.high,this.unsigned)};oe.xor=function(e){return Qn(e)||(e=nr(e)),at(this.low^e.low,this.high^e.high,this.unsigned)};oe.shiftLeft=function(e){return Qn(e)&&(e=e.toInt()),(e&=63)===0?this:e<32?at(this.low<>>32-e,this.unsigned):at(0,this.low<>>e|this.high<<32-e,this.high>>e,this.unsigned):at(this.high>>e-32,this.high>=0?0:-1,this.unsigned)};oe.shr=oe.shiftRight;oe.shiftRightUnsigned=function(e){if(Qn(e)&&(e=e.toInt()),e&=63,e===0)return this;var n=this.high;if(e<32){var s=this.low;return at(s>>>e|n<<32-e,n>>>e,this.unsigned)}else return e===32?at(n,0,this.unsigned):at(n>>>e-32,0,this.unsigned)};oe.shru=oe.shiftRightUnsigned;oe.shr_u=oe.shiftRightUnsigned;oe.toSigned=function(){return this.unsigned?at(this.low,this.high,!1):this};oe.toUnsigned=function(){return this.unsigned?this:at(this.low,this.high,!0)};oe.toBytes=function(e){return e?this.toBytesLE():this.toBytesBE()};oe.toBytesLE=function(){var e=this.high,n=this.low;return[n&255,n>>>8&255,n>>>16&255,n>>>24,e&255,e>>>8&255,e>>>16&255,e>>>24]};oe.toBytesBE=function(){var e=this.high,n=this.low;return[e>>>24,e>>>16&255,e>>>8&255,e&255,n>>>24,n>>>16&255,n>>>8&255,n&255]};it.fromBytes=function(e,n,s){return s?it.fromBytesLE(e,n):it.fromBytesBE(e,n)};it.fromBytesLE=function(e,n){return new it(e[0]|e[1]<<8|e[2]<<16|e[3]<<24,e[4]|e[5]<<8|e[6]<<16|e[7]<<24,n)};it.fromBytesBE=function(e,n){return new it(e[4]<<24|e[5]<<16|e[6]<<8|e[7],e[0]<<24|e[1]<<16|e[2]<<8|e[3],n)};const T$=oS(k$),XM=qD({__proto__:null,default:T$},[k$]);/** + */function C$(t){return t instanceof Float32Array||t instanceof Int32Array||t instanceof Uint8Array||t instanceof Uint8ClampedArray}var k$=it,vs=null;try{vs=new WebAssembly.Instance(new WebAssembly.Module(new Uint8Array([0,97,115,109,1,0,0,0,1,13,2,96,0,1,127,96,4,127,127,127,127,1,127,3,7,6,0,1,1,1,1,1,6,6,1,127,1,65,0,11,7,50,6,3,109,117,108,0,1,5,100,105,118,95,115,0,2,5,100,105,118,95,117,0,3,5,114,101,109,95,115,0,4,5,114,101,109,95,117,0,5,8,103,101,116,95,104,105,103,104,0,0,10,191,1,6,4,0,35,0,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,126,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,127,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,128,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,129,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,130,34,4,66,32,135,167,36,0,32,4,167,11])),{}).exports}catch{}function it(t,e,n){this.low=t|0,this.high=e|0,this.unsigned=!!n}it.prototype.__isLong__;Object.defineProperty(it.prototype,"__isLong__",{value:!0});function Qn(t){return(t&&t.__isLong__)===!0}it.isLong=Qn;var mC={},gC={};function ji(t,e){var n,s,r;return e?(t>>>=0,(r=0<=t&&t<256)&&(s=gC[t],s)?s:(n=at(t,(t|0)<0?-1:0,!0),r&&(gC[t]=n),n)):(t|=0,(r=-128<=t&&t<128)&&(s=mC[t],s)?s:(n=at(t,t<0?-1:0,!1),r&&(mC[t]=n),n))}it.fromInt=ji;function bs(t,e){if(isNaN(t))return e?di:Cs;if(e){if(t<0)return di;if(t>=S$)return N$}else{if(t<=-yC)return Un;if(t+1>=yC)return $$}return t<0?bs(-t,e).neg():at(t%sl|0,t/sl|0,e)}it.fromNumber=bs;function at(t,e,n){return new it(t,e,n)}it.fromBits=at;var mf=Math.pow;function Ay(t,e,n){if(t.length===0)throw Error("empty string");if(t==="NaN"||t==="Infinity"||t==="+Infinity"||t==="-Infinity")return Cs;if(typeof e=="number"?(n=e,e=!1):e=!!e,n=n||10,n<2||360)throw Error("interior hyphen");if(s===0)return Ay(t.substring(1),e,n).neg();for(var r=bs(mf(n,8)),o=Cs,i=0;i>>0:this.low};oe.toNumber=function(){return this.unsigned?(this.high>>>0)*sl+(this.low>>>0):this.high*sl+(this.low>>>0)};oe.toString=function(e){if(e=e||10,e<2||36>>0,u=c.toString(e);if(i=l,i.isZero())return u+a;for(;u.length<6;)u="0"+u;a=""+u+a}};oe.getHighBits=function(){return this.high};oe.getHighBitsUnsigned=function(){return this.high>>>0};oe.getLowBits=function(){return this.low};oe.getLowBitsUnsigned=function(){return this.low>>>0};oe.getNumBitsAbs=function(){if(this.isNegative())return this.eq(Un)?64:this.neg().getNumBitsAbs();for(var e=this.high!=0?this.high:this.low,n=31;n>0&&!(e&1<=0};oe.isOdd=function(){return(this.low&1)===1};oe.isEven=function(){return(this.low&1)===0};oe.equals=function(e){return Qn(e)||(e=nr(e)),this.unsigned!==e.unsigned&&this.high>>>31===1&&e.high>>>31===1?!1:this.high===e.high&&this.low===e.low};oe.eq=oe.equals;oe.notEquals=function(e){return!this.eq(e)};oe.neq=oe.notEquals;oe.ne=oe.notEquals;oe.lessThan=function(e){return this.comp(e)<0};oe.lt=oe.lessThan;oe.lessThanOrEqual=function(e){return this.comp(e)<=0};oe.lte=oe.lessThanOrEqual;oe.le=oe.lessThanOrEqual;oe.greaterThan=function(e){return this.comp(e)>0};oe.gt=oe.greaterThan;oe.greaterThanOrEqual=function(e){return this.comp(e)>=0};oe.gte=oe.greaterThanOrEqual;oe.ge=oe.greaterThanOrEqual;oe.compare=function(e){if(Qn(e)||(e=nr(e)),this.eq(e))return 0;var n=this.isNegative(),s=e.isNegative();return n&&!s?-1:!n&&s?1:this.unsigned?e.high>>>0>this.high>>>0||e.high===this.high&&e.low>>>0>this.low>>>0?-1:1:this.sub(e).isNegative()?-1:1};oe.comp=oe.compare;oe.negate=function(){return!this.unsigned&&this.eq(Un)?Un:this.not().add(Ta)};oe.neg=oe.negate;oe.add=function(e){Qn(e)||(e=nr(e));var n=this.high>>>16,s=this.high&65535,r=this.low>>>16,o=this.low&65535,i=e.high>>>16,a=e.high&65535,l=e.low>>>16,c=e.low&65535,u=0,h=0,d=0,f=0;return f+=o+c,d+=f>>>16,f&=65535,d+=r+l,h+=d>>>16,d&=65535,h+=s+a,u+=h>>>16,h&=65535,u+=n+i,u&=65535,at(d<<16|f,u<<16|h,this.unsigned)};oe.subtract=function(e){return Qn(e)||(e=nr(e)),this.add(e.neg())};oe.sub=oe.subtract;oe.multiply=function(e){if(this.isZero())return Cs;if(Qn(e)||(e=nr(e)),vs){var n=vs.mul(this.low,this.high,e.low,e.high);return at(n,vs.get_high(),this.unsigned)}if(e.isZero())return Cs;if(this.eq(Un))return e.isOdd()?Un:Cs;if(e.eq(Un))return this.isOdd()?Un:Cs;if(this.isNegative())return e.isNegative()?this.neg().mul(e.neg()):this.neg().mul(e).neg();if(e.isNegative())return this.mul(e.neg()).neg();if(this.lt(wC)&&e.lt(wC))return bs(this.toNumber()*e.toNumber(),this.unsigned);var s=this.high>>>16,r=this.high&65535,o=this.low>>>16,i=this.low&65535,a=e.high>>>16,l=e.high&65535,c=e.low>>>16,u=e.low&65535,h=0,d=0,f=0,p=0;return p+=i*u,f+=p>>>16,p&=65535,f+=o*u,d+=f>>>16,f&=65535,f+=i*c,d+=f>>>16,f&=65535,d+=r*u,h+=d>>>16,d&=65535,d+=o*c,h+=d>>>16,d&=65535,d+=i*l,h+=d>>>16,d&=65535,h+=s*u+r*c+o*l+i*a,h&=65535,at(f<<16|p,h<<16|d,this.unsigned)};oe.mul=oe.multiply;oe.divide=function(e){if(Qn(e)||(e=nr(e)),e.isZero())throw Error("division by zero");if(vs){if(!this.unsigned&&this.high===-2147483648&&e.low===-1&&e.high===-1)return this;var n=(this.unsigned?vs.div_u:vs.div_s)(this.low,this.high,e.low,e.high);return at(n,vs.get_high(),this.unsigned)}if(this.isZero())return this.unsigned?di:Cs;var s,r,o;if(this.unsigned){if(e.unsigned||(e=e.toUnsigned()),e.gt(this))return di;if(e.gt(this.shru(1)))return I$;o=di}else{if(this.eq(Un)){if(e.eq(Ta)||e.eq(t1))return Un;if(e.eq(Un))return Ta;var i=this.shr(1);return s=i.div(e).shl(1),s.eq(Cs)?e.isNegative()?Ta:t1:(r=this.sub(e.mul(s)),o=s.add(r.div(e)),o)}else if(e.eq(Un))return this.unsigned?di:Cs;if(this.isNegative())return e.isNegative()?this.neg().div(e.neg()):this.neg().div(e).neg();if(e.isNegative())return this.div(e.neg()).neg();o=Cs}for(r=this;r.gte(e);){s=Math.max(1,Math.floor(r.toNumber()/e.toNumber()));for(var a=Math.ceil(Math.log(s)/Math.LN2),l=a<=48?1:mf(2,a-48),c=bs(s),u=c.mul(e);u.isNegative()||u.gt(r);)s-=l,c=bs(s,this.unsigned),u=c.mul(e);c.isZero()&&(c=Ta),o=o.add(c),r=r.sub(u)}return o};oe.div=oe.divide;oe.modulo=function(e){if(Qn(e)||(e=nr(e)),vs){var n=(this.unsigned?vs.rem_u:vs.rem_s)(this.low,this.high,e.low,e.high);return at(n,vs.get_high(),this.unsigned)}return this.sub(this.div(e).mul(e))};oe.mod=oe.modulo;oe.rem=oe.modulo;oe.not=function(){return at(~this.low,~this.high,this.unsigned)};oe.and=function(e){return Qn(e)||(e=nr(e)),at(this.low&e.low,this.high&e.high,this.unsigned)};oe.or=function(e){return Qn(e)||(e=nr(e)),at(this.low|e.low,this.high|e.high,this.unsigned)};oe.xor=function(e){return Qn(e)||(e=nr(e)),at(this.low^e.low,this.high^e.high,this.unsigned)};oe.shiftLeft=function(e){return Qn(e)&&(e=e.toInt()),(e&=63)===0?this:e<32?at(this.low<>>32-e,this.unsigned):at(0,this.low<>>e|this.high<<32-e,this.high>>e,this.unsigned):at(this.high>>e-32,this.high>=0?0:-1,this.unsigned)};oe.shr=oe.shiftRight;oe.shiftRightUnsigned=function(e){if(Qn(e)&&(e=e.toInt()),e&=63,e===0)return this;var n=this.high;if(e<32){var s=this.low;return at(s>>>e|n<<32-e,n>>>e,this.unsigned)}else return e===32?at(n,0,this.unsigned):at(n>>>e-32,0,this.unsigned)};oe.shru=oe.shiftRightUnsigned;oe.shr_u=oe.shiftRightUnsigned;oe.toSigned=function(){return this.unsigned?at(this.low,this.high,!1):this};oe.toUnsigned=function(){return this.unsigned?this:at(this.low,this.high,!0)};oe.toBytes=function(e){return e?this.toBytesLE():this.toBytesBE()};oe.toBytesLE=function(){var e=this.high,n=this.low;return[n&255,n>>>8&255,n>>>16&255,n>>>24,e&255,e>>>8&255,e>>>16&255,e>>>24]};oe.toBytesBE=function(){var e=this.high,n=this.low;return[e>>>24,e>>>16&255,e>>>8&255,e&255,n>>>24,n>>>16&255,n>>>8&255,n&255]};it.fromBytes=function(e,n,s){return s?it.fromBytesLE(e,n):it.fromBytesBE(e,n)};it.fromBytesLE=function(e,n){return new it(e[0]|e[1]<<8|e[2]<<16|e[3]<<24,e[4]|e[5]<<8|e[6]<<16|e[7]<<24,n)};it.fromBytesBE=function(e,n){return new it(e[4]<<24|e[5]<<16|e[6]<<8|e[7],e[0]<<24|e[1]<<16|e[2]<<8|e[3],n)};const T$=oS(k$),KM=XD({__proto__:null,default:T$},[k$]);/** * @license * Copyright 2021 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -223,7 +223,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const oi=T$||XM;function pm(t){return oi.fromString(t,!0,16)}const E$=pm("c3a5c85c97cb3127"),ri=pm("b492b66fbe98f273"),wn=pm("9ae16a3b2f90404f");function n1(t){return t.xor(t.shru(47))}function R$(t,e,n){const s=t.slice(e,e+n);return oi.fromBytes(Array.from(s),!0,!0)}function et(t,e){return R$(t,e,8)}function vC(t,e){return R$(t,e,4)}function jt(t,e){return e===0?t:t.shru(e).or(t.shl(64-e))}function $o(t,e,n=pm("9ddfea08eb382d69")){let s=t.xor(e).mul(n);s=s.xor(s.shru(47));let r=e.xor(s).mul(n);return r=r.xor(r.shru(47)),r=r.mul(n),r}function qM(t,e,n,s,r,o){r=r.add(t),o=jt(o.add(r).add(s),21);const i=r;return r=r.add(e),r=r.add(n),o=o.add(jt(r,44)),[r.add(s),o.add(i)]}function Jh(t,e,n,s){return qM(et(t,e),et(t,e+8),et(t,e+16),et(t,e+24),n,s)}function YM(t,e=t.length){if(e>=8){const n=wn.add(e*2),s=et(t,0).add(wn),r=et(t,e-8),o=jt(r,37).mul(n).add(s),i=jt(s,25).add(r).mul(n);return $o(o,i,n)}if(e>=4){const n=wn.add(e*2),s=vC(t,0);return $o(s.shl(3).add(e),vC(t,e-4),n)}if(e>0){const n=t[0],s=t[e>>1],r=t[e-1],o=n+(s<<8),i=e+(r<<2);return n1(wn.mul(o).xor(E$.mul(i))).mul(wn)}return wn}function QM(t,e=t.length){const n=wn.add(e*2),s=et(t,0).mul(ri),r=et(t,8),o=et(t,e-8).mul(n),i=et(t,e-16).mul(wn);return $o(jt(s.add(r),43).add(jt(o,30)).add(i),s.add(jt(r.add(wn),18)).add(o),n)}function ZM(t,e=t.length){const n=wn.add(e*2),s=et(t,0).mul(wn),r=et(t,8),o=et(t,e-8).mul(n),i=et(t,e-16).mul(wn),a=jt(s.add(r),43).add(jt(o,30)).add(i),l=$o(a,s.add(jt(r.add(wn),18)).add(o),n),c=et(t,16).mul(n),u=et(t,24),h=a.add(et(t,e-32)).mul(n),d=l.add(et(t,e-24)).mul(n);return $o(jt(c.add(u),43).add(jt(h,30)).add(d),c.add(jt(u.add(s),18)).add(h),n)}function JM(t,e=t.length){const n=oi.fromNumber(81,!0);if(e<=32)return e<=16?YM(t,e):QM(t,e);if(e<=64)return ZM(t,e);let s=n,r=n.mul(ri).add(113),o=n1(r.mul(wn).add(113)).mul(wn),i=[oi.UZERO,oi.UZERO],a=[oi.UZERO,oi.UZERO];s=s.mul(wn).add(et(t,0));let l=0;const c=(e-1>>6)*64,u=c+(e-1&63)-63;do s=jt(s.add(r).add(i[0]).add(et(t,l+8)),37).mul(ri),r=jt(r.add(i[1]).add(et(t,l+48)),42).mul(ri),s=s.xor(a[1]),r=r.add(i[0]).add(et(t,l+40)),o=jt(o.add(a[0]),33).mul(ri),i=Jh(t,l,i[1].mul(ri),s.add(a[0])),a=Jh(t,l+32,o.add(a[1]),r.add(et(t,l+16))),[o,s]=[s,o],l+=64;while(l!==c);const h=ri.add(o.and(255).shl(1));return l=u,a[0]=a[0].add(e-1&63),i[0]=i[0].add(a[0]),a[0]=a[0].add(i[0]),s=jt(s.add(r).add(i[0]).add(et(t,l+8)),37).mul(h),r=jt(r.add(i[1]).add(et(t,l+48)),42).mul(h),s=s.xor(a[1].mul(9)),r=r.add(i[0].mul(9).add(et(t,l+40))),o=jt(o.add(a[0]),33).mul(h),i=Jh(t,l,i[1].mul(h),s.add(a[0])),a=Jh(t,l+32,o.add(a[1]),r.add(et(t,l+16))),[o,s]=[s,o],$o($o(i[0],a[0],h).add(n1(r).mul(E$)).add(o),$o(i[1],a[1],h).add(s),h)}/** + */const oi=T$||KM;function pm(t){return oi.fromString(t,!0,16)}const E$=pm("c3a5c85c97cb3127"),ri=pm("b492b66fbe98f273"),wn=pm("9ae16a3b2f90404f");function n1(t){return t.xor(t.shru(47))}function R$(t,e,n){const s=t.slice(e,e+n);return oi.fromBytes(Array.from(s),!0,!0)}function et(t,e){return R$(t,e,8)}function vC(t,e){return R$(t,e,4)}function jt(t,e){return e===0?t:t.shru(e).or(t.shl(64-e))}function $o(t,e,n=pm("9ddfea08eb382d69")){let s=t.xor(e).mul(n);s=s.xor(s.shru(47));let r=e.xor(s).mul(n);return r=r.xor(r.shru(47)),r=r.mul(n),r}function XM(t,e,n,s,r,o){r=r.add(t),o=jt(o.add(r).add(s),21);const i=r;return r=r.add(e),r=r.add(n),o=o.add(jt(r,44)),[r.add(s),o.add(i)]}function Zh(t,e,n,s){return XM(et(t,e),et(t,e+8),et(t,e+16),et(t,e+24),n,s)}function qM(t,e=t.length){if(e>=8){const n=wn.add(e*2),s=et(t,0).add(wn),r=et(t,e-8),o=jt(r,37).mul(n).add(s),i=jt(s,25).add(r).mul(n);return $o(o,i,n)}if(e>=4){const n=wn.add(e*2),s=vC(t,0);return $o(s.shl(3).add(e),vC(t,e-4),n)}if(e>0){const n=t[0],s=t[e>>1],r=t[e-1],o=n+(s<<8),i=e+(r<<2);return n1(wn.mul(o).xor(E$.mul(i))).mul(wn)}return wn}function YM(t,e=t.length){const n=wn.add(e*2),s=et(t,0).mul(ri),r=et(t,8),o=et(t,e-8).mul(n),i=et(t,e-16).mul(wn);return $o(jt(s.add(r),43).add(jt(o,30)).add(i),s.add(jt(r.add(wn),18)).add(o),n)}function QM(t,e=t.length){const n=wn.add(e*2),s=et(t,0).mul(wn),r=et(t,8),o=et(t,e-8).mul(n),i=et(t,e-16).mul(wn),a=jt(s.add(r),43).add(jt(o,30)).add(i),l=$o(a,s.add(jt(r.add(wn),18)).add(o),n),c=et(t,16).mul(n),u=et(t,24),h=a.add(et(t,e-32)).mul(n),d=l.add(et(t,e-24)).mul(n);return $o(jt(c.add(u),43).add(jt(h,30)).add(d),c.add(jt(u.add(s),18)).add(h),n)}function ZM(t,e=t.length){const n=oi.fromNumber(81,!0);if(e<=32)return e<=16?qM(t,e):YM(t,e);if(e<=64)return QM(t,e);let s=n,r=n.mul(ri).add(113),o=n1(r.mul(wn).add(113)).mul(wn),i=[oi.UZERO,oi.UZERO],a=[oi.UZERO,oi.UZERO];s=s.mul(wn).add(et(t,0));let l=0;const c=(e-1>>6)*64,u=c+(e-1&63)-63;do s=jt(s.add(r).add(i[0]).add(et(t,l+8)),37).mul(ri),r=jt(r.add(i[1]).add(et(t,l+48)),42).mul(ri),s=s.xor(a[1]),r=r.add(i[0]).add(et(t,l+40)),o=jt(o.add(a[0]),33).mul(ri),i=Zh(t,l,i[1].mul(ri),s.add(a[0])),a=Zh(t,l+32,o.add(a[1]),r.add(et(t,l+16))),[o,s]=[s,o],l+=64;while(l!==c);const h=ri.add(o.and(255).shl(1));return l=u,a[0]=a[0].add(e-1&63),i[0]=i[0].add(a[0]),a[0]=a[0].add(i[0]),s=jt(s.add(r).add(i[0]).add(et(t,l+8)),37).mul(h),r=jt(r.add(i[1]).add(et(t,l+48)),42).mul(h),s=s.xor(a[1].mul(9)),r=r.add(i[0].mul(9).add(et(t,l+40))),o=jt(o.add(a[0]),33).mul(h),i=Zh(t,l,i[1].mul(h),s.add(a[0])),a=Zh(t,l+32,o.add(a[1]),r.add(et(t,l+16))),[o,s]=[s,o],$o($o(i[0],a[0],h).add(n1(r).mul(E$)).add(o),$o(i[1],a[1],h).add(s),h)}/** * @license * Copyright 2017 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -238,7 +238,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function Wo(t,e){return e==="string"?No(t):Ki([t],e)}function eP(t,e){return t instanceof Float32Array&&e==="float32"||t instanceof Int32Array&&e==="int32"||t instanceof Uint8Array&&e==="bool"}function Ki(t,e){if(e==="string")throw new Error("Cannot convert a string[] to a TypedArray");if(Array.isArray(t)&&(t=Ei(t)),W().getBool("DEBUG")&&RM(t,e),eP(t,e))return t;if(e==null||e==="float32"||e==="complex64")return new Float32Array(t);if(e==="int32")return new Int32Array(t);if(e==="bool"){const n=new Uint8Array(t.length);for(let s=0;s{r=s()};let i;const a=Tn();if(this.backendTimer.timerAvailable())i=this.backendTimer.time(o);else{o();for(const c of r)c.dataSync();i=Promise.resolve({kernelMs:Tn()-a})}if(W().getBool("CHECK_COMPUTATION_FOR_ERRORS"))for(let c=0;c{nP(h,u.dtype,e)})}return{kernelName:e,outputs:r,inputs:n,timeMs:i.then(c=>c.kernelMs),extraInfo:i.then(c=>c.getExtraProfileInfo!=null?c.getExtraProfileInfo():"")}}logKernelProfile(e){const{kernelName:n,outputs:s,timeMs:r,inputs:o,extraInfo:i}=e;s.forEach(a=>{Promise.all([a.data(),r,i]).then(l=>{this.logger.logKernelProfile(n,a,l[0],l[1],o,l[2])})})}}function nP(t,e,n){if(e!=="float32")return!1;for(let s=0;s0?g:""} `}}console.log(`%c${l} %c${a} %c${c}D ${h} %c${u} %c${d} %c${i}`,"font-weight:bold","color:red","color:blue","color: orange","color: green","color: steelblue")}}/** + */class eP{constructor(e,n){this.backendTimer=e,this.logger=n,n==null&&(this.logger=new nP)}profileKernel(e,n,s){let r;const o=()=>{r=s()};let i;const a=Tn();if(this.backendTimer.timerAvailable())i=this.backendTimer.time(o);else{o();for(const c of r)c.dataSync();i=Promise.resolve({kernelMs:Tn()-a})}if(W().getBool("CHECK_COMPUTATION_FOR_ERRORS"))for(let c=0;c{tP(h,u.dtype,e)})}return{kernelName:e,outputs:r,inputs:n,timeMs:i.then(c=>c.kernelMs),extraInfo:i.then(c=>c.getExtraProfileInfo!=null?c.getExtraProfileInfo():"")}}logKernelProfile(e){const{kernelName:n,outputs:s,timeMs:r,inputs:o,extraInfo:i}=e;s.forEach(a=>{Promise.all([a.data(),r,i]).then(l=>{this.logger.logKernelProfile(n,a,l[0],l[1],o,l[2])})})}}function tP(t,e,n){if(e!=="float32")return!1;for(let s=0;s0?g:""} `}}console.log(`%c${l} %c${a} %c${c}D ${h} %c${u} %c${d} %c${i}`,"font-weight:bold","color:red","color:blue","color: orange","color: green","color: steelblue")}}/** * @license * Copyright 2017 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -268,7 +268,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function rP(t,e,n){const s={},r={};for(let l=0;ls[g.id]=!0),f=!0,r[c.id]=!0;break}if(f)break}}const o={};o[n.id]=!0;const i={};for(let l=t.length-1;l>=0;l--){const c=t[l],u=c.inputs;for(let h=0;h=0;r--){const o=e[r],i=[];if(o.outputs.forEach(l=>{const c=t[l.id];c!=null?i.push(c):i.push(null)}),o.gradient==null)throw new Error(`Cannot compute gradient: gradient function not found for ${o.kernelName}.`);const a=o.gradient(i);for(const l in o.inputs){if(!(l in a))throw new Error(`Cannot backprop through input ${l}. Available gradients found: ${Object.keys(a)}.`);const c=n(()=>a[l]());if(c.dtype!=="float32")throw new Error(`Error in gradient for op ${o.kernelName}. The gradient of input ${l} must have 'float32' dtype, but has '${c.dtype}'`);const u=o.inputs[l];if(!Ue(c.shape,u.shape))throw new Error(`Error in gradient for op ${o.kernelName}. The gradient of input '${l}' has shape '${c.shape}', which does not match the shape of the input '${u.shape}'`);if(t[u.id]==null)t[u.id]=c;else{const h=t[u.id];t[u.id]=s(h,c),h.dispose()}}}}/** + */function sP(t,e,n){const s={},r={};for(let l=0;ls[g.id]=!0),f=!0,r[c.id]=!0;break}if(f)break}}const o={};o[n.id]=!0;const i={};for(let l=t.length-1;l>=0;l--){const c=t[l],u=c.inputs;for(let h=0;h=0;r--){const o=e[r],i=[];if(o.outputs.forEach(l=>{const c=t[l.id];c!=null?i.push(c):i.push(null)}),o.gradient==null)throw new Error(`Cannot compute gradient: gradient function not found for ${o.kernelName}.`);const a=o.gradient(i);for(const l in o.inputs){if(!(l in a))throw new Error(`Cannot backprop through input ${l}. Available gradients found: ${Object.keys(a)}.`);const c=n(()=>a[l]());if(c.dtype!=="float32")throw new Error(`Error in gradient for op ${o.kernelName}. The gradient of input ${l} must have 'float32' dtype, but has '${c.dtype}'`);const u=o.inputs[l];if(!Ue(c.shape,u.shape))throw new Error(`Error in gradient for op ${o.kernelName}. The gradient of input '${l}' has shape '${c.shape}', which does not match the shape of the input '${u.shape}'`);if(t[u.id]==null)t[u.id]=c;else{const h=t[u.id];t[u.id]=s(h,c),h.dispose()}}}}/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -283,9 +283,9 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const bC=20,Gl=3,bg=7;function iP(t,e,n,s){const r=pe(e),o=aP(t,e,n,r),i=e.length,a=Dd(t,e,n,r,o),l=["Tensor"];return s&&(l.push(` dtype: ${n}`),l.push(` rank: ${i}`),l.push(` shape: [${e}]`),l.push(" values:")),l.push(a.map(c=>" "+c).join(` + */const bC=20,Gl=3,bg=7;function oP(t,e,n,s){const r=pe(e),o=iP(t,e,n,r),i=e.length,a=Ad(t,e,n,r,o),l=["Tensor"];return s&&(l.push(` dtype: ${n}`),l.push(` rank: ${i}`),l.push(` shape: [${e}]`),l.push(" values:")),l.push(a.map(c=>" "+c).join(` `)),l.join(` -`)}function aP(t,e,n,s){const r=j(e),o=s[s.length-1],i=new Array(o).fill(0),a=e.length,l=n==="complex64"?oc(t):t;if(a>1)for(let c=0;cbC){const x=Gl*i;let m=Array.from(t.slice(0,x)),y=Array.from(t.slice((a-Gl)*i,a*i));return n==="complex64"&&(m=oc(m),y=oc(y)),["["+m.map((w,v)=>rc(w,r[v],n)).join(", ")+", ..., "+y.map((w,v)=>rc(w,r[a-Gl+v],n)).join(", ")+"]"]}return["["+(n==="complex64"?oc(t):Array.from(t)).map((x,m)=>rc(x,r[m],n)).join(", ")+"]"]}const c=e.slice(1),u=s.slice(1),h=s[0]*i,d=[];if(a>bC){for(let g=0;g0?d[0]+f:"");for(let g=1;g1)for(let c=0;cbC){const x=Gl*i;let m=Array.from(t.slice(0,x)),y=Array.from(t.slice((a-Gl)*i,a*i));return n==="complex64"&&(m=oc(m),y=oc(y)),["["+m.map((w,v)=>rc(w,r[v],n)).join(", ")+", ..., "+y.map((w,v)=>rc(w,r[a-Gl+v],n)).join(", ")+"]"]}return["["+(n==="complex64"?oc(t):Array.from(t)).map((x,m)=>rc(x,r[m],n)).join(", ")+"]"]}const c=e.slice(1),u=s.slice(1),h=s[0]*i,d=[];if(a>bC){for(let g=0;g0?d[0]+f:"");for(let g=1;g`Length of values '${r}' does not match the size inferred by the shape '${this.size}'.`)}if(n==="complex64")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=s||kt(n,this.size),this.strides=pe(e)}set(e,...n){n.length===0&&(n=[0]),I(n.length===this.rank,()=>`The number of provided coordinates (${n.length}) must match the rank (${this.rank})`);const s=this.locToIndex(n);this.values[s]=e}get(...e){e.length===0&&(e=[0]);let n=0;for(const r of e){if(r<0||r>=this.shape[n]){const o=`Requested out of range element at ${e}. Buffer shape=${this.shape}`;throw new Error(o)}n++}let s=e[e.length-1];for(let r=0;rDo(s))}catch{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(),Ws().readToGPU(this.dataId,e)}dataSync(){this.throwIfDisposed();const e=Ws().readSync(this.dataId);if(this.dtype==="string")try{return e.map(n=>Do(n))}catch{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 Ws().read(this.dataId);return this.dtype==="string"?e:new Uint8Array(e.buffer)}dispose(){this.isDisposed||(this.kerasMask&&this.kerasMask.dispose(),Ws().disposeTensor(this),this.isDisposedInternal=!0)}get isDisposed(){return this.isDisposedInternal}throwIfDisposed(){if(this.isDisposed)throw new Error("Tensor is disposed.")}print(e=!1){return fa.print(this,e)}clone(){return this.throwIfDisposed(),fa.clone(this)}toString(e=!1){const n=this.dataSync();return iP(n,this.shape,this.dtype,e)}cast(e){return this.throwIfDisposed(),fa.cast(this,e)}variable(e=!0,n,s){return this.throwIfDisposed(),Ws().makeVariable(this,e,n,s)}}Object.defineProperty(zt,Symbol.hasInstance,{value:t=>!!t&&t.data!=null&&t.dataSync!=null&&t.throwIfDisposed!=null});function H(){return Ux("Tensor",()=>zt)}H();class xf extends zt{constructor(e,n,s,r){super(e.shape,e.dtype,e.dataId,r),this.trainable=n,this.name=s}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(!Ue(e.shape,this.shape))throw new Error(`shape of the new value (${e.shape}) and previous value (${this.shape}) must match`);Ws().disposeTensor(this),this.dataId=e.dataId,Ws().incRef(this,null)}dispose(){Ws().disposeVariable(this),this.isDisposedInternal=!0}}Object.defineProperty(xf,Symbol.hasInstance,{value:t=>t instanceof zt&&t.assign!=null&&t.assign instanceof Function});/** + */class tn{constructor(e,n,s){if(this.dtype=n,this.shape=e.slice(),this.size=j(e),s!=null){const r=s.length;I(r===this.size,()=>`Length of values '${r}' does not match the size inferred by the shape '${this.size}'.`)}if(n==="complex64")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=s||kt(n,this.size),this.strides=pe(e)}set(e,...n){n.length===0&&(n=[0]),I(n.length===this.rank,()=>`The number of provided coordinates (${n.length}) must match the rank (${this.rank})`);const s=this.locToIndex(n);this.values[s]=e}get(...e){e.length===0&&(e=[0]);let n=0;for(const r of e){if(r<0||r>=this.shape[n]){const o=`Requested out of range element at ${e}. Buffer shape=${this.shape}`;throw new Error(o)}n++}let s=e[e.length-1];for(let r=0;rDo(s))}catch{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(),Ws().readToGPU(this.dataId,e)}dataSync(){this.throwIfDisposed();const e=Ws().readSync(this.dataId);if(this.dtype==="string")try{return e.map(n=>Do(n))}catch{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 Ws().read(this.dataId);return this.dtype==="string"?e:new Uint8Array(e.buffer)}dispose(){this.isDisposed||(this.kerasMask&&this.kerasMask.dispose(),Ws().disposeTensor(this),this.isDisposedInternal=!0)}get isDisposed(){return this.isDisposedInternal}throwIfDisposed(){if(this.isDisposed)throw new Error("Tensor is disposed.")}print(e=!1){return fa.print(this,e)}clone(){return this.throwIfDisposed(),fa.clone(this)}toString(e=!1){const n=this.dataSync();return oP(n,this.shape,this.dtype,e)}cast(e){return this.throwIfDisposed(),fa.cast(this,e)}variable(e=!0,n,s){return this.throwIfDisposed(),Ws().makeVariable(this,e,n,s)}}Object.defineProperty(zt,Symbol.hasInstance,{value:t=>!!t&&t.data!=null&&t.dataSync!=null&&t.throwIfDisposed!=null});function H(){return Ux("Tensor",()=>zt)}H();class gf extends zt{constructor(e,n,s,r){super(e.shape,e.dtype,e.dataId,r),this.trainable=n,this.name=s}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(!Ue(e.shape,this.shape))throw new Error(`shape of the new value (${e.shape}) and previous value (${this.shape}) must match`);Ws().disposeTensor(this),this.dataId=e.dataId,Ws().incRef(this,null)}dispose(){Ws().disposeVariable(this),this.isDisposedInternal=!0}}Object.defineProperty(gf,Symbol.hasInstance,{value:t=>t instanceof zt&&t.assign!=null&&t.assign instanceof Function});/** * @license * Copyright 2017 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -317,7 +317,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */var CC;(function(t){t.R0="R0",t.R1="R1",t.R2="R2",t.R3="R3",t.R4="R4",t.R5="R5",t.R6="R6"})(CC||(CC={}));var s1;(function(t){t.float32="float32",t.int32="int32",t.bool="int32",t.complex64="complex64"})(s1||(s1={}));var r1;(function(t){t.float32="float32",t.int32="int32",t.bool="bool",t.complex64="complex64"})(r1||(r1={}));var o1;(function(t){t.float32="float32",t.int32="float32",t.bool="float32",t.complex64="complex64"})(o1||(o1={}));var i1;(function(t){t.float32="complex64",t.int32="complex64",t.bool="complex64",t.complex64="complex64"})(i1||(i1={}));const uP={float32:o1,int32:s1,bool:r1,complex64:i1};function Xn(t,e){if(t==="string"||e==="string"){if(t==="string"&&e==="string")return"string";throw new Error(`Can not upcast ${t} with ${e}`)}return uP[t][e]}function Dy(t){return Xn(t,"int32")}function D$(t){return t!=null&&typeof t=="object"&&"texture"in t&&t.texture instanceof WebGLTexture}function _$(t){return typeof GPUBuffer<"u"&&t!=null&&typeof t=="object"&&"buffer"in t&&t.buffer instanceof GPUBuffer}/** + */var CC;(function(t){t.R0="R0",t.R1="R1",t.R2="R2",t.R3="R3",t.R4="R4",t.R5="R5",t.R6="R6"})(CC||(CC={}));var s1;(function(t){t.float32="float32",t.int32="int32",t.bool="int32",t.complex64="complex64"})(s1||(s1={}));var r1;(function(t){t.float32="float32",t.int32="int32",t.bool="bool",t.complex64="complex64"})(r1||(r1={}));var o1;(function(t){t.float32="float32",t.int32="float32",t.bool="float32",t.complex64="complex64"})(o1||(o1={}));var i1;(function(t){t.float32="complex64",t.int32="complex64",t.bool="complex64",t.complex64="complex64"})(i1||(i1={}));const cP={float32:o1,int32:s1,bool:r1,complex64:i1};function Xn(t,e){if(t==="string"||e==="string"){if(t==="string"&&e==="string")return"string";throw new Error(`Can not upcast ${t} with ${e}`)}return cP[t][e]}function Dy(t){return Xn(t,"int32")}function D$(t){return t!=null&&typeof t=="object"&&"texture"in t&&t.texture instanceof WebGLTexture}function _$(t){return typeof GPUBuffer<"u"&&t!=null&&typeof t=="object"&&"buffer"in t&&t.buffer instanceof GPUBuffer}/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -332,7 +332,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function It(t,e){if(t.dtype===e.dtype)return[t,e];const n=Xn(t.dtype,e.dtype);return[t.cast(n),e.cast(n)]}function F$(t){const e=[];return z$(t,e,new Set),e}function z$(t,e,n){if(t==null)return;if(t instanceof zt){e.push(t);return}if(!hP(t))return;const s=t;for(const r in s){const o=s[r];n.has(o)||(n.add(o),z$(o,e,n))}}function hP(t){return Array.isArray(t)||typeof t=="object"}/** + */function It(t,e){if(t.dtype===e.dtype)return[t,e];const n=Xn(t.dtype,e.dtype);return[t.cast(n),e.cast(n)]}function F$(t){const e=[];return z$(t,e,new Set),e}function z$(t,e,n){if(t==null)return;if(t instanceof zt){e.push(t);return}if(!uP(t))return;const s=t;for(const r in s){const o=s[r];n.has(o)||(n.add(o),z$(o,e,n))}}function uP(t){return Array.isArray(t)||typeof t=="object"}/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -347,7 +347,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function Cg(t){return t.kernelName!=null}class kC{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 rl{constructor(e){this.ENV=e,this.registry={},this.registryFactory={},this.pendingBackendInitId=0,this.state=new kC}async ready(){if(this.pendingBackendInit!=null)return this.pendingBackendInit.then(()=>{});if(this.backendInstance!=null)return;const e=this.getSortedBackends();for(let n=0;n{n.setupFunc!=null&&n.setupFunc(this.backendInstance)})}disposeRegisteredKernels(e){pC(e).forEach(s=>{s.disposeFunc!=null&&s.disposeFunc(this.registry[e])})}initializeBackend(e){const n=this.registryFactory[e];if(n==null)throw new Error(`Cannot initialize backend ${e}, no registration found.`);try{const s=n.factory();if(s&&!(s instanceof Mx)&&typeof s.then=="function"){const r=++this.pendingBackendInitId,o=s.then(i=>r(rthis.registryFactory[n].priority-this.registryFactory[e].priority)}initializeBackendsAndReturnBest(){const e=this.getSortedBackends();for(let n=0;nthis.startScope(s),()=>this.endScope(r),()=>(r=n(),r instanceof Promise&&console.error("Cannot return a Promise inside of tidy."),r))}scopedRun(e,n,s){e();try{const r=s();return n(),r}catch(r){throw n(),r}}nextTensorId(){return rl.nextTensorId++}nextVariableId(){return rl.nextVariableId++}clone(e){const n=_.runKernel(Fu,{x:e}),s={x:e},r=i=>({x:()=>{const a="float32",l={x:i},c={dtype:a};return _.runKernel(bu,l,c)}}),o=[];return this.addTapeNode(this.state.activeScope.name,s,[n],r,o,{}),n}runKernel(e,n,s){if(this.backendName==null&&this.backend,!(dC(e,this.backendName)!=null))throw new Error(`Kernel '${e}' not registered for backend '${this.backendName}'`);return this.runKernelFunc({kernelName:e,inputs:n,attrs:s})}shouldCheckForMemLeaks(){return this.ENV.getBool("IS_TEST")}checkKernelForMemLeak(e,n,s){const r=this.backend.numDataIds();let o=0;s.forEach(l=>{o+=l.dtype==="complex64"?3:1});const i=this.state.numDataMovesStack[this.state.numDataMovesStack.length-1],a=r-n-o-i;if(a>0)throw new Error(`Backend '${this.backendName}' has an internal memory leak (${a} data ids) after running '${e}'`)}runKernelFunc(e){let n,s=[];const r=this.isTapeOn(),o=this.state.numBytes,i=this.state.numTensors;this.shouldCheckForMemLeaks()&&this.state.numDataMovesStack.push(0);let a;this.backendName==null&&this.backend;let l;const c=Cg(e)?e.kernelName:this.state.activeScope!=null?this.state.activeScope.name:"";if(Cg(e)){const{kernelName:p,inputs:g,attrs:x}=e;this.backendName==null&&this.backend;const m=dC(p,this.backendName);I(m!=null,()=>`Cannot find registered kernel '${p}' for backend '${this.backendName}'`),a=()=>{const y=this.backend.numDataIds();l=m.kernelFunc({inputs:g,attrs:x,backend:this.backend});const w=Array.isArray(l)?l:[l];this.shouldCheckForMemLeaks()&&this.checkKernelForMemLeak(p,y,w);const v=w.map(b=>b.rank!=null?b:this.makeTensorFromTensorInfo(b));if(r){const b=this.getTensorsForGradient(p,g,v);s=this.saveTensorsForBackwardMode(b)}return v}}else{const{forwardFunc:p}=e,g=x=>{r&&(s=x.map(m=>this.keep(this.clone(m))))};a=()=>{const x=this.backend.numDataIds();l=this.tidy(()=>p(this.backend,g));const m=Array.isArray(l)?l:[l];return this.shouldCheckForMemLeaks()&&this.checkKernelForMemLeak(c,x,m),m}}const{inputs:u,attrs:h}=e,d=Cg(e)?null:e.backwardsFunc;let f;return this.scopedRun(()=>this.state.kernelDepth++,()=>this.state.kernelDepth--,()=>{!this.ENV.getBool("DEBUG")&&!this.state.profiling?n=a():(f=this.profiler.profileKernel(c,u,()=>a()),this.ENV.getBool("DEBUG")&&this.profiler.logKernelProfile(f),n=f.outputs)}),r&&this.addTapeNode(c,u,n,d,s,h),this.state.profiling&&this.state.activeProfile.kernels.push({name:c,bytesAdded:this.state.numBytes-o,totalBytesSnapshot:this.state.numBytes,tensorsAdded:this.state.numTensors-i,totalTensorsSnapshot:this.state.numTensors,inputShapes:Object.keys(u).map(p=>u[p]!=null?u[p].shape:null),outputShapes:n.map(p=>p.shape),kernelTimeMs:f.timeMs,extraInfo:f.extraInfo}),Array.isArray(l)?n:n[0]}saveTensorsForBackwardMode(e){return e.map(s=>this.keep(this.clone(s)))}getTensorsForGradient(e,n,s){const r=fC(e);if(r!=null){const o=r.inputsToSave||[],i=r.outputsToSave||[];let a;r.saveAllInputs?(I(Array.isArray(n),()=>"saveAllInputs is true, expected inputs to be an array."),a=Object.keys(n).map(c=>n[c])):a=o.map(c=>n[c]);const l=s.filter((c,u)=>i[u]);return a.concat(l)}return[]}makeTensor(e,n,s,r){if(e==null)throw new Error("Values passed to engine.makeTensor() are null");s=s||"float32",r=r||this.backend;let o=e;s==="string"&&fu(e[0])&&(o=e.map(l=>No(l)));const i=r.write(o,n,s),a=new zt(n,s,i,this.nextTensorId());if(this.trackTensor(a,r),s==="string"){const l=this.state.tensorInfo.get(i),c=DM(o);this.state.numBytes+=c-l.bytes,l.bytes=c}return a}makeTensorFromDataId(e,n,s,r){s=s||"float32";const o={dataId:e,shape:n,dtype:s};return this.makeTensorFromTensorInfo(o,r)}makeTensorFromTensorInfo(e,n){const{dataId:s,shape:r,dtype:o}=e,i=new zt(r,o,s,this.nextTensorId());return this.trackTensor(i,n),i}makeVariable(e,n=!0,s,r){s=s||this.nextVariableId().toString(),r!=null&&r!==e.dtype&&(e=e.cast(r));const o=new xf(e,n,s,this.nextTensorId());if(this.state.registeredVariables[o.name]!=null)throw new Error(`Variable with name ${o.name} was already registered`);return this.state.registeredVariables[o.name]=o,this.incRef(o,this.backend),o}trackTensor(e,n){this.state.numTensors++,e.dtype==="string"&&this.state.numStringTensors++;let s=0;e.dtype!=="complex64"&&e.dtype!=="string"&&(s=e.size*df(e.dtype)),this.state.numBytes+=s,this.state.tensorInfo.has(e.dataId)||(this.state.numDataBuffers++,this.state.tensorInfo.set(e.dataId,{backend:n||this.backend,dtype:e.dtype,shape:e.shape,bytes:s})),e instanceof xf||this.track(e)}incRef(e,n){this.trackTensor(e,n),this.backend.incRef(e.dataId)}removeDataId(e,n){this.state.tensorInfo.has(e)&&this.state.tensorInfo.get(e).backend===n&&(this.state.tensorInfo.delete(e),this.state.numDataBuffers--)}disposeTensor(e){if(!this.state.tensorInfo.has(e.dataId))return;const n=this.state.tensorInfo.get(e.dataId);if(this.state.numTensors--,e.dtype==="string"&&(this.state.numStringTensors--,this.state.numBytes-=n.bytes),e.dtype!=="complex64"&&e.dtype!=="string"){const s=e.size*df(e.dtype);this.state.numBytes-=s}n.backend.disposeData(e.dataId)&&this.removeDataId(e.dataId,n.backend)}disposeVariables(){for(const e in this.state.registeredVariables){const n=this.state.registeredVariables[e];this.disposeVariable(n)}}disposeVariable(e){this.disposeTensor(e),this.state.registeredVariables[e.name]!=null&&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,e.reasons==null&&(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 n=this.state.numBytes,s=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(r=>r.totalBytesSnapshot)),this.state.activeProfile.newBytes=this.state.numBytes-n,this.state.activeProfile.newTensors=this.state.numTensors-s;for(const r of this.state.activeProfile.kernels)r.kernelTimeMs=await r.kernelTimeMs,r.extraInfo=await r.extraInfo;return this.state.activeProfile}isTapeOn(){return this.state.gradientDepth>0&&this.state.kernelDepth===0}addTapeNode(e,n,s,r,o,i){const a={id:this.state.nextTapeNodeId++,kernelName:e,inputs:n,outputs:s,saved:o},l=fC(e);l!=null&&(r=l.gradFunc),r!=null&&(a.gradient=c=>(c=c.map((u,h)=>{if(u==null){const d=s[h],f=un(d.size,d.dtype);return this.makeTensor(f,d.shape,d.dtype)}return u}),r(c.length>1?c:c[0],o,i))),this.state.activeTape.push(a)}keep(e){return e.kept=!0,e}startTape(){this.state.gradientDepth===0&&(this.state.activeTape=[]),this.state.gradientDepth++}endTape(){this.state.gradientDepth--}startScope(e){const n={track:[],name:"unnamed scope",id:this.state.nextScopeId++};e&&(n.name=e),this.state.scopeStack.push(n),this.state.activeScope=n}endScope(e){const n=F$(e),s=new Set(n.map(o=>o.id));for(let o=0;o{!o.kept&&o.scopeId===r.id&&this.track(o)})}gradients(e,n,s,r=!1){if(I(n.length>0,()=>"gradients() received an empty list of xs."),s!=null&&s.dtype!=="float32")throw new Error(`dy must have 'float32' dtype, but has '${s.dtype}'`);const o=this.scopedRun(()=>this.startTape(),()=>this.endTape(),()=>this.tidy("forward",e));I(o instanceof zt,()=>"The result y returned by f() must be a tensor.");const i=rP(this.state.activeTape,n,o);if(!r&&i.length===0&&n.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 a={};a[o.id]=s??dP(o.shape),oP(a,i,c=>this.tidy(c),fP);const l=n.map(c=>a[c.id]);return this.state.gradientDepth===0&&(this.state.activeTape.forEach(c=>{for(const u of c.saved)u.dispose()}),this.state.activeTape=null),{value:o,grads:l}})}customGrad(e){return I(Y0(e),()=>"The f passed in customGrad(f) must be a function."),(...n)=>{I(n.every(a=>a instanceof zt),()=>"The args passed in customGrad(f)(x1, x2,...) must all be tensors");let s;const r={};n.forEach((a,l)=>{r[l]=a});const o=(a,l)=>(s=e(...n,l),I(s.value instanceof zt,()=>"The function f passed in customGrad(f) must return an object where `obj.value` is a tensor"),I(Y0(s.gradFunc),()=>"The function f passed in customGrad(f) must return an object where `obj.gradFunc` is a function."),s.value),i=(a,l)=>{const c=s.gradFunc(a,l),u=Array.isArray(c)?c:[c];I(u.length===n.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(...)."),I(u.every(d=>d instanceof zt),()=>"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 h={};return u.forEach((d,f)=>{h[f]=()=>d}),h};return this.runKernelFunc({forwardFunc:o,backwardsFunc:i,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,n){return this.state.tensorInfo.get(e).backend.readToGPU(e,n)}async time(e){const n=Tn(),s=await this.backend.time(e);return s.wallMs=Tn()-n,s}track(e){return this.state.activeScope!=null&&(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 kC;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}}rl.nextTensorId=0;rl.nextVariableId=0;function dP(t){const e=Vx(j(t),"float32");return _.makeTensor(e,t,"float32")}function O$(){const t=ZI();if(t._tfengine==null){const e=new zM(t);t._tfengine=new rl(e)}return LM(t._tfengine.ENV),lP(()=>t._tfengine),t._tfengine}const _=O$();function fP(t,e){const n={a:t,b:e};return _.runKernel(bl,n)}/** + */function Cg(t){return t.kernelName!=null}class kC{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 rl{constructor(e){this.ENV=e,this.registry={},this.registryFactory={},this.pendingBackendInitId=0,this.state=new kC}async ready(){if(this.pendingBackendInit!=null)return this.pendingBackendInit.then(()=>{});if(this.backendInstance!=null)return;const e=this.getSortedBackends();for(let n=0;n{n.setupFunc!=null&&n.setupFunc(this.backendInstance)})}disposeRegisteredKernels(e){pC(e).forEach(s=>{s.disposeFunc!=null&&s.disposeFunc(this.registry[e])})}initializeBackend(e){const n=this.registryFactory[e];if(n==null)throw new Error(`Cannot initialize backend ${e}, no registration found.`);try{const s=n.factory();if(s&&!(s instanceof Mx)&&typeof s.then=="function"){const r=++this.pendingBackendInitId,o=s.then(i=>r(rthis.registryFactory[n].priority-this.registryFactory[e].priority)}initializeBackendsAndReturnBest(){const e=this.getSortedBackends();for(let n=0;nthis.startScope(s),()=>this.endScope(r),()=>(r=n(),r instanceof Promise&&console.error("Cannot return a Promise inside of tidy."),r))}scopedRun(e,n,s){e();try{const r=s();return n(),r}catch(r){throw n(),r}}nextTensorId(){return rl.nextTensorId++}nextVariableId(){return rl.nextVariableId++}clone(e){const n=_.runKernel(_u,{x:e}),s={x:e},r=i=>({x:()=>{const a="float32",l={x:i},c={dtype:a};return _.runKernel(vu,l,c)}}),o=[];return this.addTapeNode(this.state.activeScope.name,s,[n],r,o,{}),n}runKernel(e,n,s){if(this.backendName==null&&this.backend,!(dC(e,this.backendName)!=null))throw new Error(`Kernel '${e}' not registered for backend '${this.backendName}'`);return this.runKernelFunc({kernelName:e,inputs:n,attrs:s})}shouldCheckForMemLeaks(){return this.ENV.getBool("IS_TEST")}checkKernelForMemLeak(e,n,s){const r=this.backend.numDataIds();let o=0;s.forEach(l=>{o+=l.dtype==="complex64"?3:1});const i=this.state.numDataMovesStack[this.state.numDataMovesStack.length-1],a=r-n-o-i;if(a>0)throw new Error(`Backend '${this.backendName}' has an internal memory leak (${a} data ids) after running '${e}'`)}runKernelFunc(e){let n,s=[];const r=this.isTapeOn(),o=this.state.numBytes,i=this.state.numTensors;this.shouldCheckForMemLeaks()&&this.state.numDataMovesStack.push(0);let a;this.backendName==null&&this.backend;let l;const c=Cg(e)?e.kernelName:this.state.activeScope!=null?this.state.activeScope.name:"";if(Cg(e)){const{kernelName:p,inputs:g,attrs:x}=e;this.backendName==null&&this.backend;const m=dC(p,this.backendName);I(m!=null,()=>`Cannot find registered kernel '${p}' for backend '${this.backendName}'`),a=()=>{const y=this.backend.numDataIds();l=m.kernelFunc({inputs:g,attrs:x,backend:this.backend});const w=Array.isArray(l)?l:[l];this.shouldCheckForMemLeaks()&&this.checkKernelForMemLeak(p,y,w);const v=w.map(b=>b.rank!=null?b:this.makeTensorFromTensorInfo(b));if(r){const b=this.getTensorsForGradient(p,g,v);s=this.saveTensorsForBackwardMode(b)}return v}}else{const{forwardFunc:p}=e,g=x=>{r&&(s=x.map(m=>this.keep(this.clone(m))))};a=()=>{const x=this.backend.numDataIds();l=this.tidy(()=>p(this.backend,g));const m=Array.isArray(l)?l:[l];return this.shouldCheckForMemLeaks()&&this.checkKernelForMemLeak(c,x,m),m}}const{inputs:u,attrs:h}=e,d=Cg(e)?null:e.backwardsFunc;let f;return this.scopedRun(()=>this.state.kernelDepth++,()=>this.state.kernelDepth--,()=>{!this.ENV.getBool("DEBUG")&&!this.state.profiling?n=a():(f=this.profiler.profileKernel(c,u,()=>a()),this.ENV.getBool("DEBUG")&&this.profiler.logKernelProfile(f),n=f.outputs)}),r&&this.addTapeNode(c,u,n,d,s,h),this.state.profiling&&this.state.activeProfile.kernels.push({name:c,bytesAdded:this.state.numBytes-o,totalBytesSnapshot:this.state.numBytes,tensorsAdded:this.state.numTensors-i,totalTensorsSnapshot:this.state.numTensors,inputShapes:Object.keys(u).map(p=>u[p]!=null?u[p].shape:null),outputShapes:n.map(p=>p.shape),kernelTimeMs:f.timeMs,extraInfo:f.extraInfo}),Array.isArray(l)?n:n[0]}saveTensorsForBackwardMode(e){return e.map(s=>this.keep(this.clone(s)))}getTensorsForGradient(e,n,s){const r=fC(e);if(r!=null){const o=r.inputsToSave||[],i=r.outputsToSave||[];let a;r.saveAllInputs?(I(Array.isArray(n),()=>"saveAllInputs is true, expected inputs to be an array."),a=Object.keys(n).map(c=>n[c])):a=o.map(c=>n[c]);const l=s.filter((c,u)=>i[u]);return a.concat(l)}return[]}makeTensor(e,n,s,r){if(e==null)throw new Error("Values passed to engine.makeTensor() are null");s=s||"float32",r=r||this.backend;let o=e;s==="string"&&du(e[0])&&(o=e.map(l=>No(l)));const i=r.write(o,n,s),a=new zt(n,s,i,this.nextTensorId());if(this.trackTensor(a,r),s==="string"){const l=this.state.tensorInfo.get(i),c=AM(o);this.state.numBytes+=c-l.bytes,l.bytes=c}return a}makeTensorFromDataId(e,n,s,r){s=s||"float32";const o={dataId:e,shape:n,dtype:s};return this.makeTensorFromTensorInfo(o,r)}makeTensorFromTensorInfo(e,n){const{dataId:s,shape:r,dtype:o}=e,i=new zt(r,o,s,this.nextTensorId());return this.trackTensor(i,n),i}makeVariable(e,n=!0,s,r){s=s||this.nextVariableId().toString(),r!=null&&r!==e.dtype&&(e=e.cast(r));const o=new gf(e,n,s,this.nextTensorId());if(this.state.registeredVariables[o.name]!=null)throw new Error(`Variable with name ${o.name} was already registered`);return this.state.registeredVariables[o.name]=o,this.incRef(o,this.backend),o}trackTensor(e,n){this.state.numTensors++,e.dtype==="string"&&this.state.numStringTensors++;let s=0;e.dtype!=="complex64"&&e.dtype!=="string"&&(s=e.size*hf(e.dtype)),this.state.numBytes+=s,this.state.tensorInfo.has(e.dataId)||(this.state.numDataBuffers++,this.state.tensorInfo.set(e.dataId,{backend:n||this.backend,dtype:e.dtype,shape:e.shape,bytes:s})),e instanceof gf||this.track(e)}incRef(e,n){this.trackTensor(e,n),this.backend.incRef(e.dataId)}removeDataId(e,n){this.state.tensorInfo.has(e)&&this.state.tensorInfo.get(e).backend===n&&(this.state.tensorInfo.delete(e),this.state.numDataBuffers--)}disposeTensor(e){if(!this.state.tensorInfo.has(e.dataId))return;const n=this.state.tensorInfo.get(e.dataId);if(this.state.numTensors--,e.dtype==="string"&&(this.state.numStringTensors--,this.state.numBytes-=n.bytes),e.dtype!=="complex64"&&e.dtype!=="string"){const s=e.size*hf(e.dtype);this.state.numBytes-=s}n.backend.disposeData(e.dataId)&&this.removeDataId(e.dataId,n.backend)}disposeVariables(){for(const e in this.state.registeredVariables){const n=this.state.registeredVariables[e];this.disposeVariable(n)}}disposeVariable(e){this.disposeTensor(e),this.state.registeredVariables[e.name]!=null&&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,e.reasons==null&&(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 n=this.state.numBytes,s=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(r=>r.totalBytesSnapshot)),this.state.activeProfile.newBytes=this.state.numBytes-n,this.state.activeProfile.newTensors=this.state.numTensors-s;for(const r of this.state.activeProfile.kernels)r.kernelTimeMs=await r.kernelTimeMs,r.extraInfo=await r.extraInfo;return this.state.activeProfile}isTapeOn(){return this.state.gradientDepth>0&&this.state.kernelDepth===0}addTapeNode(e,n,s,r,o,i){const a={id:this.state.nextTapeNodeId++,kernelName:e,inputs:n,outputs:s,saved:o},l=fC(e);l!=null&&(r=l.gradFunc),r!=null&&(a.gradient=c=>(c=c.map((u,h)=>{if(u==null){const d=s[h],f=un(d.size,d.dtype);return this.makeTensor(f,d.shape,d.dtype)}return u}),r(c.length>1?c:c[0],o,i))),this.state.activeTape.push(a)}keep(e){return e.kept=!0,e}startTape(){this.state.gradientDepth===0&&(this.state.activeTape=[]),this.state.gradientDepth++}endTape(){this.state.gradientDepth--}startScope(e){const n={track:[],name:"unnamed scope",id:this.state.nextScopeId++};e&&(n.name=e),this.state.scopeStack.push(n),this.state.activeScope=n}endScope(e){const n=F$(e),s=new Set(n.map(o=>o.id));for(let o=0;o{!o.kept&&o.scopeId===r.id&&this.track(o)})}gradients(e,n,s,r=!1){if(I(n.length>0,()=>"gradients() received an empty list of xs."),s!=null&&s.dtype!=="float32")throw new Error(`dy must have 'float32' dtype, but has '${s.dtype}'`);const o=this.scopedRun(()=>this.startTape(),()=>this.endTape(),()=>this.tidy("forward",e));I(o instanceof zt,()=>"The result y returned by f() must be a tensor.");const i=sP(this.state.activeTape,n,o);if(!r&&i.length===0&&n.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 a={};a[o.id]=s??hP(o.shape),rP(a,i,c=>this.tidy(c),dP);const l=n.map(c=>a[c.id]);return this.state.gradientDepth===0&&(this.state.activeTape.forEach(c=>{for(const u of c.saved)u.dispose()}),this.state.activeTape=null),{value:o,grads:l}})}customGrad(e){return I(Y0(e),()=>"The f passed in customGrad(f) must be a function."),(...n)=>{I(n.every(a=>a instanceof zt),()=>"The args passed in customGrad(f)(x1, x2,...) must all be tensors");let s;const r={};n.forEach((a,l)=>{r[l]=a});const o=(a,l)=>(s=e(...n,l),I(s.value instanceof zt,()=>"The function f passed in customGrad(f) must return an object where `obj.value` is a tensor"),I(Y0(s.gradFunc),()=>"The function f passed in customGrad(f) must return an object where `obj.gradFunc` is a function."),s.value),i=(a,l)=>{const c=s.gradFunc(a,l),u=Array.isArray(c)?c:[c];I(u.length===n.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(...)."),I(u.every(d=>d instanceof zt),()=>"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 h={};return u.forEach((d,f)=>{h[f]=()=>d}),h};return this.runKernelFunc({forwardFunc:o,backwardsFunc:i,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,n){return this.state.tensorInfo.get(e).backend.readToGPU(e,n)}async time(e){const n=Tn(),s=await this.backend.time(e);return s.wallMs=Tn()-n,s}track(e){return this.state.activeScope!=null&&(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 kC;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}}rl.nextTensorId=0;rl.nextVariableId=0;function hP(t){const e=Vx(j(t),"float32");return _.makeTensor(e,t,"float32")}function O$(){const t=ZI();if(t._tfengine==null){const e=new FM(t);t._tfengine=new rl(e)}return PM(t._tfengine.ENV),aP(()=>t._tfengine),t._tfengine}const _=O$();function dP(t,e){const n={a:t,b:e};return _.runKernel(bl,n)}/** * @license * Copyright 2017 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -362,7 +362,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function pP(){return typeof navigator<"u"&&navigator!=null}function M$(t){if(t||pP()){if(t||(t=navigator),t.product==="ReactNative")return!0;const e=t.userAgent||t.vendor||(typeof window<"u"?window.opera:"");if(!e){const n=t;return n.userAgentData&&n.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(e)||/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(e.substr(0,4))}return!1}function P$(){return typeof window<"u"&&window.document!=null||typeof WorkerGlobalScope<"u"}/** + */function fP(){return typeof navigator<"u"&&navigator!=null}function M$(t){if(t||fP()){if(t||(t=navigator),t.product==="ReactNative")return!0;const e=t.userAgent||t.vendor||(typeof window<"u"?window.opera:"");if(!e){const n=t;return n.userAgentData&&n.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(e)||/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(e.substr(0,4))}return!1}function P$(){return typeof window<"u"&&window.document!=null||typeof WorkerGlobalScope<"u"}/** * @license * Copyright 2019 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -392,7 +392,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function ch(t,e){let n=t;if(Es(t))return e==="string"?[]:[t.length];if(D$(t)){const r=t.channels||"RGBA";return[t.height,t.width*r.length]}else if(_$(t))return[t.buffer.size/(e==null?4:df(e))];if(!Array.isArray(t))return[];const s=[];for(;Array.isArray(n)||Es(n)&&e!=="string";)s.push(n.length),n=n[0];return Array.isArray(t)&&W().getBool("TENSORLIKE_CHECK_SHAPE_CONSISTENCY")&&L$(t,s,[]),s}function L$(t,e,n){if(n=n||[],!Array.isArray(t)&&!Es(t)){I(e.length===0,()=>`Element arr[${n.join("][")}] is a primitive, but should be an array/TypedArray of ${e[0]} elements`);return}I(e.length>0,()=>`Element arr[${n.join("][")}] should be a primitive, but is an array of ${t.length} elements`),I(t.length===e[0],()=>`Element arr[${n.join("][")}] should have ${e[0]} elements, but has ${t.length} elements`);const s=e.slice(1);for(let r=0;r=0&&(r=s),SC(s,r,e,n),t==null||!Es(t)&&!Array.isArray(t)&&typeof t!="number"&&typeof t!="boolean"&&typeof t!="string"){const l=t==null?"null":t.constructor.name;throw new Error(`Argument '${e}' passed to '${n}' must be a Tensor or TensorLike, but got '${l}'`)}const o=ch(t,r);!Es(t)&&!Array.isArray(t)&&(t=[t]);const a=r!=="string"?Ki(t,r):Ei(t,[],!0);return _.makeTensor(a,o,r)}function B$(t,e,n,s="numeric"){if(!Array.isArray(t))throw new Error(`Argument ${e} passed to ${n} must be a \`Tensor[]\` or \`TensorLike[]\``);return t.map((o,i)=>T(o,`${e}[${i}]`,n,s))}/** + */function lh(t,e){let n=t;if(Es(t))return e==="string"?[]:[t.length];if(D$(t)){const r=t.channels||"RGBA";return[t.height,t.width*r.length]}else if(_$(t))return[t.buffer.size/(e==null?4:hf(e))];if(!Array.isArray(t))return[];const s=[];for(;Array.isArray(n)||Es(n)&&e!=="string";)s.push(n.length),n=n[0];return Array.isArray(t)&&W().getBool("TENSORLIKE_CHECK_SHAPE_CONSISTENCY")&&L$(t,s,[]),s}function L$(t,e,n){if(n=n||[],!Array.isArray(t)&&!Es(t)){I(e.length===0,()=>`Element arr[${n.join("][")}] is a primitive, but should be an array/TypedArray of ${e[0]} elements`);return}I(e.length>0,()=>`Element arr[${n.join("][")}] should be a primitive, but is an array of ${t.length} elements`),I(t.length===e[0],()=>`Element arr[${n.join("][")}] should have ${e[0]} elements, but has ${t.length} elements`);const s=e.slice(1);for(let r=0;r=0&&(r=s),SC(s,r,e,n),t==null||!Es(t)&&!Array.isArray(t)&&typeof t!="number"&&typeof t!="boolean"&&typeof t!="string"){const l=t==null?"null":t.constructor.name;throw new Error(`Argument '${e}' passed to '${n}' must be a Tensor or TensorLike, but got '${l}'`)}const o=lh(t,r);!Es(t)&&!Array.isArray(t)&&(t=[t]);const a=r!=="string"?Ki(t,r):Ei(t,[],!0);return _.makeTensor(a,o,r)}function B$(t,e,n,s="numeric"){if(!Array.isArray(t))throw new Error(`Argument ${e} passed to ${n} must be a \`Tensor[]\` or \`TensorLike[]\``);return t.map((o,i)=>T(o,`${e}[${i}]`,n,s))}/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -407,7 +407,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const mP="__op";function z(t){const e=Object.keys(t);if(e.length!==1)throw new Error(`Please provide an object with a single key (operation name) mapping to a function. Got an object with ${e.length} keys.`);let n=e[0];const s=t[n];n.endsWith("_")&&(n=n.substring(0,n.length-1)),n=n+mP;const r=(...o)=>{_.startScope(n);try{const i=s(...o);return Wx(i)&&console.error("Cannot return a Promise inside of tidy."),_.endScope(i),i}catch(i){throw _.endScope(null),i}};return Object.defineProperty(r,"name",{value:n,configurable:!0}),r}/** + */const pP="__op";function z(t){const e=Object.keys(t);if(e.length!==1)throw new Error(`Please provide an object with a single key (operation name) mapping to a function. Got an object with ${e.length} keys.`);let n=e[0];const s=t[n];n.endsWith("_")&&(n=n.substring(0,n.length-1)),n=n+pP;const r=(...o)=>{_.startScope(n);try{const i=s(...o);return Wx(i)&&console.error("Cannot return a Promise inside of tidy."),_.endScope(i),i}catch(i){throw _.endScope(null),i}};return Object.defineProperty(r,"name",{value:n,configurable:!0}),r}/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -422,7 +422,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function gP(t,e){const n=T(t,"real","complex"),s=T(e,"imag","complex");Lx(n.shape,s.shape,`real and imag shapes, ${n.shape} and ${s.shape}, must match in call to tf.complex().`);const r={real:n,imag:s};return _.runKernel(Qx,r)}const Ri=z({complex_:gP});/** + */function mP(t,e){const n=T(t,"real","complex"),s=T(e,"imag","complex");Lx(n.shape,s.shape,`real and imag shapes, ${n.shape} and ${s.shape}, must match in call to tf.complex().`);const r={real:n,imag:s};return _.runKernel(Qx,r)}const Ri=z({complex_:mP});/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -437,7 +437,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function uh(t,e,n,s){if(s==null)s=wl(t);else if(s==="complex64")throw new Error("Cannot construct a complex64 tensor directly. Please use tf.complex(real, imag).");if(_$(t)||D$(t)){if(s!=="float32"&&s!=="int32")throw new Error(`Creating tensor from GPU data only supports 'float32'|'int32' dtype, while the dtype is ${s}.`);return _.backend.createTensorFromGPUData(t,e||n,s)}if(!Es(t)&&!Array.isArray(t)&&typeof t!="number"&&typeof t!="boolean"&&typeof t!="string")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(e!=null){qr(e);const r=j(e),o=j(n);I(r===o,()=>`Based on the provided shape, [${e}], the tensor should have ${r} values but has ${o}`);for(let i=0;i`Error creating a new Tensor. Inferred shape (${n}) does not match the provided shape (${e}). `)}}return!Es(t)&&!Array.isArray(t)&&(t=[t]),e=e||n,t=s!=="string"?Ki(t,s):Ei(t,[],!0),_.makeTensor(t,e,s)}/** + */function ch(t,e,n,s){if(s==null)s=wl(t);else if(s==="complex64")throw new Error("Cannot construct a complex64 tensor directly. Please use tf.complex(real, imag).");if(_$(t)||D$(t)){if(s!=="float32"&&s!=="int32")throw new Error(`Creating tensor from GPU data only supports 'float32'|'int32' dtype, while the dtype is ${s}.`);return _.backend.createTensorFromGPUData(t,e||n,s)}if(!Es(t)&&!Array.isArray(t)&&typeof t!="number"&&typeof t!="boolean"&&typeof t!="string")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(e!=null){qr(e);const r=j(e),o=j(n);I(r===o,()=>`Based on the provided shape, [${e}], the tensor should have ${r} values but has ${o}`);for(let i=0;i`Error creating a new Tensor. Inferred shape (${n}) does not match the provided shape (${e}). `)}}return!Es(t)&&!Array.isArray(t)&&(t=[t]),e=e||n,t=s!=="string"?Ki(t,s):Ei(t,[],!0),_.makeTensor(t,e,s)}/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -452,7 +452,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function bc(t,e,n){const s=ch(t,n);return uh(t,e,s,n)}/** + */function bc(t,e,n){const s=lh(t,n);return ch(t,e,s,n)}/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -467,7 +467,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const yf={float32:4,float16:2,int32:4,uint16:2,uint8:1,bool:1,complex64:8};class Uo{static join(e){return new Uo(e).slice()}constructor(e){if(this.shards=[],this.previousShardIndex=0,e==null||(e instanceof Array||(e=[e]),e=e.map(s=>Es(s)?s.buffer:s),e.length===0))return;this.bufferUniformSize=e[0].byteLength;let n=0;for(let s=0;s=this.byteLength)return-1;if(this.bufferUniformSize!=null)return this.previousShardIndex=Math.floor(e/this.bufferUniformSize),this.previousShardIndex;function n(r){return e=r.end?1:0}if(n(this.shards[this.previousShardIndex])===0)return this.previousShardIndex;const s=xP(this.shards,n);return s===-1?-1:(this.previousShardIndex=s,this.previousShardIndex)}}function xP(t,e){let n=0,s=t.length;for(;n<=s;){const r=Math.floor((s-n)/2)+n,o=e(t[r]);if(o===0)return r;o<0?s=r:n=r+1}return-1}/** + */const xf={float32:4,float16:2,int32:4,uint16:2,uint8:1,bool:1,complex64:8};class Uo{static join(e){return new Uo(e).slice()}constructor(e){if(this.shards=[],this.previousShardIndex=0,e==null||(e instanceof Array||(e=[e]),e=e.map(s=>Es(s)?s.buffer:s),e.length===0))return;this.bufferUniformSize=e[0].byteLength;let n=0;for(let s=0;s=this.byteLength)return-1;if(this.bufferUniformSize!=null)return this.previousShardIndex=Math.floor(e/this.bufferUniformSize),this.previousShardIndex;function n(r){return e=r.end?1:0}if(n(this.shards[this.previousShardIndex])===0)return this.previousShardIndex;const s=gP(this.shards,n);return s===-1?-1:(this.previousShardIndex=s,this.previousShardIndex)}}function gP(t,e){let n=0,s=t.length;for(;n<=s;){const r=Math.floor((s-n)/2)+n,o=e(t[r]);if(o===0)return r;o<0?s=r:n=r+1}return-1}/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -482,7 +482,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function ir(){return _}function IC(){return _.memory()}function P(t,e){return _.tidy(t,e)}function $e(t){F$(t).forEach(n=>n.dispose())}function yr(t){return _.keep(t)}function V$(t,e,n=1){return _.registerBackend(t,e,n)}function yP(){return _.backend}/** + */function ir(){return _}function IC(){return _.memory()}function P(t,e){return _.tidy(t,e)}function $e(t){F$(t).forEach(n=>n.dispose())}function yr(t){return _.keep(t)}function V$(t,e,n=1){return _.registerBackend(t,e,n)}function xP(){return _.backend}/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -497,7 +497,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const ol=4;async function $C(t,e){const n=[],s=[],r=Array.isArray(t)?t.map(i=>i.name):Object.keys(t);for(let i=0;i{const d=await l.bytes(),f=d.reduce((x,m)=>x+m.length,0)+ol*d.length,p=new Uint8Array(f);let g=0;for(let x=0;xn.slice(r+a,r+l));s[o.name]=bP(o,n.slice(r,r+i)),r+=i}return s}function vP(t,e){const n=j(t.shape);let s;if("quantization"in t){const r=t.quantization;s=yf[r.dtype]}else if(t.dtype==="string"){let r=0;for(let o=0;o{if(e+=o.byteLength,n.push(o.byteLength===o.buffer.byteLength?o:new o.constructor(o)),!(o instanceof Float32Array||o instanceof Int32Array||o instanceof Uint8Array))throw new Error(`Unsupported TypedArray subtype: ${o.constructor.name}`)});const s=new Uint8Array(e);let r=0;return n.forEach(o=>{s.set(new Uint8Array(o.buffer),r),r+=o.byteLength}),s.buffer}const _y=typeof Buffer<"u"&&(typeof Blob>"u"||typeof atob>"u"||typeof btoa>"u");function NC(t){return _y?Buffer.byteLength(t,"utf8"):new Blob([t]).size}function kP(t){if(_y)return Buffer.from(t).toString("base64");const e=new Uint8Array(t);let n="";for(let s=0,r=e.length;s{let s=n<<13,r=0;for(;!(s&8388608);)r-=8388608,s<<=1;return s&=-8388609,r+=947912704,s|r},e=new Uint32Array(2048);e[0]=0;for(let n=1;n<1024;n++)e[n]=t(n);for(let n=1024;n<2048;n++)e[n]=939524096+(n-1024<<13);return e}function RP(){const t=new Uint32Array(64);t[0]=0,t[31]=1199570944,t[32]=2147483648,t[63]=3347054592;for(let e=1;e<31;e++)t[e]=e<<23;for(let e=33;e<63;e++)t[e]=2147483648+(e-32<<23);return t}function AP(){const t=new Uint32Array(64);for(let e=0;e<64;e++)t[e]=1024;return t[0]=t[32]=0,t}function DP(){const t=EP(),e=RP(),n=AP();return s=>{const r=new ArrayBuffer(4*s.length),o=new Uint32Array(r);for(let i=0;i>10]+(a&1023)]+e[a>>10];o[i]=l}return new Float32Array(r)}}/** + */const ol=4;async function $C(t,e){const n=[],s=[],r=Array.isArray(t)?t.map(i=>i.name):Object.keys(t);for(let i=0;i{const d=await l.bytes(),f=d.reduce((x,m)=>x+m.length,0)+ol*d.length,p=new Uint8Array(f);let g=0;for(let x=0;xn.slice(r+a,r+l));s[o.name]=vP(o,n.slice(r,r+i)),r+=i}return s}function wP(t,e){const n=j(t.shape);let s;if("quantization"in t){const r=t.quantization;s=xf[r.dtype]}else if(t.dtype==="string"){let r=0;for(let o=0;o{if(e+=o.byteLength,n.push(o.byteLength===o.buffer.byteLength?o:new o.constructor(o)),!(o instanceof Float32Array||o instanceof Int32Array||o instanceof Uint8Array))throw new Error(`Unsupported TypedArray subtype: ${o.constructor.name}`)});const s=new Uint8Array(e);let r=0;return n.forEach(o=>{s.set(new Uint8Array(o.buffer),r),r+=o.byteLength}),s.buffer}const _y=typeof Buffer<"u"&&(typeof Blob>"u"||typeof atob>"u"||typeof btoa>"u");function NC(t){return _y?Buffer.byteLength(t,"utf8"):new Blob([t]).size}function CP(t){if(_y)return Buffer.from(t).toString("base64");const e=new Uint8Array(t);let n="";for(let s=0,r=e.length;s{let s=n<<13,r=0;for(;!(s&8388608);)r-=8388608,s<<=1;return s&=-8388609,r+=947912704,s|r},e=new Uint32Array(2048);e[0]=0;for(let n=1;n<1024;n++)e[n]=t(n);for(let n=1024;n<2048;n++)e[n]=939524096+(n-1024<<13);return e}function EP(){const t=new Uint32Array(64);t[0]=0,t[31]=1199570944,t[32]=2147483648,t[63]=3347054592;for(let e=1;e<31;e++)t[e]=e<<23;for(let e=33;e<63;e++)t[e]=2147483648+(e-32<<23);return t}function RP(){const t=new Uint32Array(64);for(let e=0;e<64;e++)t[e]=1024;return t[0]=t[32]=0,t}function AP(){const t=TP(),e=EP(),n=RP();return s=>{const r=new ArrayBuffer(4*s.length),o=new Uint32Array(r);for(let i=0;i>10]+(a&1023)]+e[a>>10];o[i]=l}return new Float32Array(r)}}/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -512,7 +512,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */class Gt{constructor(){this.saveRouters=[],this.loadRouters=[]}static getInstance(){return Gt.instance==null&&(Gt.instance=new Gt),Gt.instance}static registerSaveRouter(e){Gt.getInstance().saveRouters.push(e)}static registerLoadRouter(e){Gt.getInstance().loadRouters.push(e)}static getSaveHandlers(e){return Gt.getHandlers(e,"save")}static getLoadHandlers(e,n){return Gt.getHandlers(e,"load",n)}static getHandlers(e,n,s){const r=[];return(n==="load"?Gt.getInstance().loadRouters:Gt.getInstance().saveRouters).forEach(i=>{const a=i(e,s);a!==null&&r.push(a)}),r}}const _P=t=>Gt.getSaveHandlers(t),FP=(t,e)=>Gt.getLoadHandlers(t,e);/** + */class Gt{constructor(){this.saveRouters=[],this.loadRouters=[]}static getInstance(){return Gt.instance==null&&(Gt.instance=new Gt),Gt.instance}static registerSaveRouter(e){Gt.getInstance().saveRouters.push(e)}static registerLoadRouter(e){Gt.getInstance().loadRouters.push(e)}static getSaveHandlers(e){return Gt.getHandlers(e,"save")}static getLoadHandlers(e,n){return Gt.getHandlers(e,"load",n)}static getHandlers(e,n,s){const r=[];return(n==="load"?Gt.getInstance().loadRouters:Gt.getInstance().saveRouters).forEach(i=>{const a=i(e,s);a!==null&&r.push(a)}),r}}const DP=t=>Gt.getSaveHandlers(t),_P=(t,e)=>Gt.getLoadHandlers(t,e);/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -527,7 +527,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const a1="tensorflowjs",l1=1,fi="models_store",ho="model_info_store";function W$(){if(!W().getBool("IS_BROWSER"))throw new Error("Failed to obtain IndexedDB factory because the current environmentis not a web browser.");const t=typeof window>"u"?self:window,e=t.indexedDB||t.mozIndexedDB||t.webkitIndexedDB||t.msIndexedDB||t.shimIndexedDB;if(e==null)throw new Error("The current browser does not appear to support IndexedDB.");return e}function c1(t){const e=t.result;e.createObjectStore(fi,{keyPath:"modelPath"}),e.createObjectStore(ho,{keyPath:"modelPath"})}class Ai{constructor(e){if(this.indexedDB=W$(),e==null||!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,n){return new Promise((s,r)=>{const o=this.indexedDB.open(a1,l1);o.onupgradeneeded=()=>c1(o),o.onsuccess=()=>{const i=o.result;if(n==null){const a=i.transaction(fi,"readonly"),c=a.objectStore(fi).get(this.modelPath);c.onsuccess=()=>{if(c.result==null)return i.close(),r(new Error(`Cannot find model with path '${this.modelPath}' in IndexedDB.`));s(c.result.modelArtifacts)},c.onerror=u=>(i.close(),r(c.error)),a.oncomplete=()=>i.close()}else{n.weightData=Uo.join(n.weightData);const a=Fy(n),l=i.transaction(ho,"readwrite");let c=l.objectStore(ho),u;try{u=c.put({modelPath:this.modelPath,modelArtifactsInfo:a})}catch(d){return r(d)}let h;u.onsuccess=()=>{h=i.transaction(fi,"readwrite");const d=h.objectStore(fi);let f;try{f=d.put({modelPath:this.modelPath,modelArtifacts:n,modelArtifactsInfo:a})}catch(p){return r(p)}f.onsuccess=()=>s({modelArtifactsInfo:a}),f.onerror=p=>{c=l.objectStore(ho);const g=c.delete(this.modelPath);g.onsuccess=()=>(i.close(),r(f.error)),g.onerror=x=>(i.close(),r(f.error))}},u.onerror=d=>(i.close(),r(u.error)),l.oncomplete=()=>{h==null?i.close():h.oncomplete=()=>i.close()}}},o.onerror=i=>r(o.error)})}}Ai.URL_SCHEME="indexeddb://";const U$=t=>W().getBool("IS_BROWSER")&&!Array.isArray(t)&&t.startsWith(Ai.URL_SCHEME)?zP(t.slice(Ai.URL_SCHEME.length)):null;Gt.registerSaveRouter(U$);Gt.registerLoadRouter(U$);function zP(t){return new Ai(t)}function OP(t){return t.startsWith(Ai.URL_SCHEME)?t.slice(Ai.URL_SCHEME.length):t}class MP{constructor(){this.indexedDB=W$()}async listModels(){return new Promise((e,n)=>{const s=this.indexedDB.open(a1,l1);s.onupgradeneeded=()=>c1(s),s.onsuccess=()=>{const r=s.result,o=r.transaction(ho,"readonly"),a=o.objectStore(ho).getAll();a.onsuccess=()=>{const l={};for(const c of a.result)l[c.modelPath]=c.modelArtifactsInfo;e(l)},a.onerror=l=>(r.close(),n(a.error)),o.oncomplete=()=>r.close()},s.onerror=r=>n(s.error)})}async removeModel(e){return e=OP(e),new Promise((n,s)=>{const r=this.indexedDB.open(a1,l1);r.onupgradeneeded=()=>c1(r),r.onsuccess=()=>{const o=r.result,i=o.transaction(ho,"readwrite"),a=i.objectStore(ho),l=a.get(e);let c;l.onsuccess=()=>{if(l.result==null)return o.close(),s(new Error(`Cannot find model with path '${e}' in IndexedDB.`));{const u=a.delete(e),h=()=>{c=o.transaction(fi,"readwrite");const f=c.objectStore(fi).delete(e);f.onsuccess=()=>n(l.result.modelArtifactsInfo),f.onerror=p=>s(l.error)};u.onsuccess=h,u.onerror=d=>(h(),o.close(),s(l.error))}},l.onerror=u=>(o.close(),s(l.error)),i.oncomplete=()=>{c==null?o.close():c.oncomplete=()=>o.close()}},r.onerror=o=>s(r.error)})}}/** + */const a1="tensorflowjs",l1=1,fi="models_store",ho="model_info_store";function W$(){if(!W().getBool("IS_BROWSER"))throw new Error("Failed to obtain IndexedDB factory because the current environmentis not a web browser.");const t=typeof window>"u"?self:window,e=t.indexedDB||t.mozIndexedDB||t.webkitIndexedDB||t.msIndexedDB||t.shimIndexedDB;if(e==null)throw new Error("The current browser does not appear to support IndexedDB.");return e}function c1(t){const e=t.result;e.createObjectStore(fi,{keyPath:"modelPath"}),e.createObjectStore(ho,{keyPath:"modelPath"})}class Ai{constructor(e){if(this.indexedDB=W$(),e==null||!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,n){return new Promise((s,r)=>{const o=this.indexedDB.open(a1,l1);o.onupgradeneeded=()=>c1(o),o.onsuccess=()=>{const i=o.result;if(n==null){const a=i.transaction(fi,"readonly"),c=a.objectStore(fi).get(this.modelPath);c.onsuccess=()=>{if(c.result==null)return i.close(),r(new Error(`Cannot find model with path '${this.modelPath}' in IndexedDB.`));s(c.result.modelArtifacts)},c.onerror=u=>(i.close(),r(c.error)),a.oncomplete=()=>i.close()}else{n.weightData=Uo.join(n.weightData);const a=Fy(n),l=i.transaction(ho,"readwrite");let c=l.objectStore(ho),u;try{u=c.put({modelPath:this.modelPath,modelArtifactsInfo:a})}catch(d){return r(d)}let h;u.onsuccess=()=>{h=i.transaction(fi,"readwrite");const d=h.objectStore(fi);let f;try{f=d.put({modelPath:this.modelPath,modelArtifacts:n,modelArtifactsInfo:a})}catch(p){return r(p)}f.onsuccess=()=>s({modelArtifactsInfo:a}),f.onerror=p=>{c=l.objectStore(ho);const g=c.delete(this.modelPath);g.onsuccess=()=>(i.close(),r(f.error)),g.onerror=x=>(i.close(),r(f.error))}},u.onerror=d=>(i.close(),r(u.error)),l.oncomplete=()=>{h==null?i.close():h.oncomplete=()=>i.close()}}},o.onerror=i=>r(o.error)})}}Ai.URL_SCHEME="indexeddb://";const U$=t=>W().getBool("IS_BROWSER")&&!Array.isArray(t)&&t.startsWith(Ai.URL_SCHEME)?FP(t.slice(Ai.URL_SCHEME.length)):null;Gt.registerSaveRouter(U$);Gt.registerLoadRouter(U$);function FP(t){return new Ai(t)}function zP(t){return t.startsWith(Ai.URL_SCHEME)?t.slice(Ai.URL_SCHEME.length):t}class OP{constructor(){this.indexedDB=W$()}async listModels(){return new Promise((e,n)=>{const s=this.indexedDB.open(a1,l1);s.onupgradeneeded=()=>c1(s),s.onsuccess=()=>{const r=s.result,o=r.transaction(ho,"readonly"),a=o.objectStore(ho).getAll();a.onsuccess=()=>{const l={};for(const c of a.result)l[c.modelPath]=c.modelArtifactsInfo;e(l)},a.onerror=l=>(r.close(),n(a.error)),o.oncomplete=()=>r.close()},s.onerror=r=>n(s.error)})}async removeModel(e){return e=zP(e),new Promise((n,s)=>{const r=this.indexedDB.open(a1,l1);r.onupgradeneeded=()=>c1(r),r.onsuccess=()=>{const o=r.result,i=o.transaction(ho,"readwrite"),a=i.objectStore(ho),l=a.get(e);let c;l.onsuccess=()=>{if(l.result==null)return o.close(),s(new Error(`Cannot find model with path '${e}' in IndexedDB.`));{const u=a.delete(e),h=()=>{c=o.transaction(fi,"readwrite");const f=c.objectStore(fi).delete(e);f.onsuccess=()=>n(l.result.modelArtifactsInfo),f.onerror=p=>s(l.error)};u.onsuccess=h,u.onerror=d=>(h(),o.close(),s(l.error))}},l.onerror=u=>(o.close(),s(l.error)),i.oncomplete=()=>{c==null?o.close():c.oncomplete=()=>o.close()}},r.onerror=o=>s(r.error)})}}/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -542,7 +542,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const Fr="/",pa="tensorflowjs_models",G$="info",PP="model_topology",LP="weight_specs",BP="weight_data",VP="model_metadata";function H$(t){return{info:[pa,t,G$].join(Fr),topology:[pa,t,PP].join(Fr),weightSpecs:[pa,t,LP].join(Fr),weightData:[pa,t,BP].join(Fr),modelMetadata:[pa,t,VP].join(Fr)}}function j$(t){for(const e of Object.values(t))window.localStorage.removeItem(e)}function WP(t){const e=t.split(Fr);if(e.length<3)throw new Error(`Invalid key format: ${t}`);return e.slice(1,e.length-1).join(Fr)}function UP(t){return t.startsWith(Di.URL_SCHEME)?t.slice(Di.URL_SCHEME.length):t}class Di{constructor(e){if(!W().getBool("IS_BROWSER")||typeof window>"u"||typeof window.localStorage>"u")throw new Error("The current environment does not support local storage.");if(this.LS=window.localStorage,e==null||!e)throw new Error("For local storage, modelPath must not be null, undefined or empty.");this.modelPath=e,this.keys=H$(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 n=JSON.stringify(e.modelTopology),s=JSON.stringify(e.weightSpecs),r=Fy(e),o=Uo.join(e.weightData);try{this.LS.setItem(this.keys.info,JSON.stringify(r)),this.LS.setItem(this.keys.topology,n),this.LS.setItem(this.keys.weightSpecs,s),this.LS.setItem(this.keys.weightData,kP(o));const i={format:e.format,generatedBy:e.generatedBy,convertedBy:e.convertedBy,signature:e.signature!=null?e.signature:void 0,userDefinedMetadata:e.userDefinedMetadata!=null?e.userDefinedMetadata:void 0,modelInitializer:e.modelInitializer!=null?e.modelInitializer:void 0,initializerSignature:e.initializerSignature!=null?e.initializerSignature:void 0,trainingConfig:e.trainingConfig!=null?e.trainingConfig:void 0};return this.LS.setItem(this.keys.modelMetadata,JSON.stringify(i)),{modelArtifactsInfo:r}}catch{throw j$(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(e==null)throw new Error(`In local storage, there is no model with name '${this.modelPath}'`);if(e.modelTopologyType!=="JSON")throw new Error("BrowserLocalStorage does not support loading non-JSON model topology yet.");const n={},s=JSON.parse(this.LS.getItem(this.keys.topology));if(s==null)throw new Error(`In local storage, the topology of model '${this.modelPath}' is missing.`);n.modelTopology=s;const r=JSON.parse(this.LS.getItem(this.keys.weightSpecs));if(r==null)throw new Error(`In local storage, the weight specs of model '${this.modelPath}' are missing.`);n.weightSpecs=r;const o=this.LS.getItem(this.keys.modelMetadata);if(o!=null){const a=JSON.parse(o);n.format=a.format,n.generatedBy=a.generatedBy,n.convertedBy=a.convertedBy,a.signature!=null&&(n.signature=a.signature),a.userDefinedMetadata!=null&&(n.userDefinedMetadata=a.userDefinedMetadata),a.modelInitializer!=null&&(n.modelInitializer=a.modelInitializer),a.initializerSignature!=null&&(n.initializerSignature=a.initializerSignature),a.trainingConfig!=null&&(n.trainingConfig=a.trainingConfig)}const i=this.LS.getItem(this.keys.weightData);if(i==null)throw new Error(`In local storage, the binary weight values of model '${this.modelPath}' are missing.`);return n.weightData=SP(i),n}}Di.URL_SCHEME="localstorage://";const K$=t=>W().getBool("IS_BROWSER")&&!Array.isArray(t)&&t.startsWith(Di.URL_SCHEME)?GP(t.slice(Di.URL_SCHEME.length)):null;Gt.registerSaveRouter(K$);Gt.registerLoadRouter(K$);function GP(t){return new Di(t)}class HP{constructor(){I(W().getBool("IS_BROWSER"),()=>"Current environment is not a web browser"),I(typeof window>"u"||typeof window.localStorage<"u",()=>"Current browser does not appear to support localStorage"),this.LS=window.localStorage}async listModels(){const e={},n=pa+Fr,s=Fr+G$;for(let r=0;r"u"||typeof window.localStorage>"u")throw new Error("The current environment does not support local storage.");if(this.LS=window.localStorage,e==null||!e)throw new Error("For local storage, modelPath must not be null, undefined or empty.");this.modelPath=e,this.keys=H$(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 n=JSON.stringify(e.modelTopology),s=JSON.stringify(e.weightSpecs),r=Fy(e),o=Uo.join(e.weightData);try{this.LS.setItem(this.keys.info,JSON.stringify(r)),this.LS.setItem(this.keys.topology,n),this.LS.setItem(this.keys.weightSpecs,s),this.LS.setItem(this.keys.weightData,CP(o));const i={format:e.format,generatedBy:e.generatedBy,convertedBy:e.convertedBy,signature:e.signature!=null?e.signature:void 0,userDefinedMetadata:e.userDefinedMetadata!=null?e.userDefinedMetadata:void 0,modelInitializer:e.modelInitializer!=null?e.modelInitializer:void 0,initializerSignature:e.initializerSignature!=null?e.initializerSignature:void 0,trainingConfig:e.trainingConfig!=null?e.trainingConfig:void 0};return this.LS.setItem(this.keys.modelMetadata,JSON.stringify(i)),{modelArtifactsInfo:r}}catch{throw j$(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(e==null)throw new Error(`In local storage, there is no model with name '${this.modelPath}'`);if(e.modelTopologyType!=="JSON")throw new Error("BrowserLocalStorage does not support loading non-JSON model topology yet.");const n={},s=JSON.parse(this.LS.getItem(this.keys.topology));if(s==null)throw new Error(`In local storage, the topology of model '${this.modelPath}' is missing.`);n.modelTopology=s;const r=JSON.parse(this.LS.getItem(this.keys.weightSpecs));if(r==null)throw new Error(`In local storage, the weight specs of model '${this.modelPath}' are missing.`);n.weightSpecs=r;const o=this.LS.getItem(this.keys.modelMetadata);if(o!=null){const a=JSON.parse(o);n.format=a.format,n.generatedBy=a.generatedBy,n.convertedBy=a.convertedBy,a.signature!=null&&(n.signature=a.signature),a.userDefinedMetadata!=null&&(n.userDefinedMetadata=a.userDefinedMetadata),a.modelInitializer!=null&&(n.modelInitializer=a.modelInitializer),a.initializerSignature!=null&&(n.initializerSignature=a.initializerSignature),a.trainingConfig!=null&&(n.trainingConfig=a.trainingConfig)}const i=this.LS.getItem(this.keys.weightData);if(i==null)throw new Error(`In local storage, the binary weight values of model '${this.modelPath}' are missing.`);return n.weightData=kP(i),n}}Di.URL_SCHEME="localstorage://";const K$=t=>W().getBool("IS_BROWSER")&&!Array.isArray(t)&&t.startsWith(Di.URL_SCHEME)?UP(t.slice(Di.URL_SCHEME.length)):null;Gt.registerSaveRouter(K$);Gt.registerLoadRouter(K$);function UP(t){return new Di(t)}class GP{constructor(){I(W().getBool("IS_BROWSER"),()=>"Current environment is not a web browser"),I(typeof window>"u"||typeof window.localStorage<"u",()=>"Current browser does not appear to support localStorage"),this.LS=window.localStorage}async listModels(){const e={},n=pa+Fr,s=Fr+G$;for(let r=0;r"u"||!W().getBool("USE_SETTIMEOUTCUSTOM")){setTimeout(e,n);return}this.functionRefs.push(e),setTimeout(()=>{window.postMessage({name:this.messageName,index:this.functionRefs.length-1},"*")},n),this.hasEventListener||(this.hasEventListener=!0,window.addEventListener("message",s=>{if(s.source===window&&s.data.name===this.messageName){s.stopPropagation();const r=this.functionRefs[s.data.index];r(),this.handledMessageCount++,this.handledMessageCount===this.functionRefs.length&&(this.functionRefs=[],this.handledMessageCount=0)}},!0))}isTypedArray(e){return C$(e)}}if(W().get("IS_BROWSER")){W().setPlatform("browser",new jP);try{ar.registerManager(Di.URL_SCHEME,new HP)}catch{}try{ar.registerManager(Ai.URL_SCHEME,new MP)}catch{}}/** + */class HP{constructor(){this.messageName="setTimeoutCustom",this.functionRefs=[],this.handledMessageCount=0,this.hasEventListener=!1}fetch(e,n){return fetch(e,n)}now(){return performance.now()}encode(e,n){if(n!=="utf-8"&&n!=="utf8")throw new Error(`Browser's encoder only supports utf-8, but got ${n}`);return this.textEncoder==null&&(this.textEncoder=new TextEncoder),this.textEncoder.encode(e)}decode(e,n){return new TextDecoder(n).decode(e)}setTimeoutCustom(e,n){if(typeof window>"u"||!W().getBool("USE_SETTIMEOUTCUSTOM")){setTimeout(e,n);return}this.functionRefs.push(e),setTimeout(()=>{window.postMessage({name:this.messageName,index:this.functionRefs.length-1},"*")},n),this.hasEventListener||(this.hasEventListener=!0,window.addEventListener("message",s=>{if(s.source===window&&s.data.name===this.messageName){s.stopPropagation();const r=this.functionRefs[s.data.index];r(),this.handledMessageCount++,this.handledMessageCount===this.functionRefs.length&&(this.functionRefs=[],this.handledMessageCount=0)}},!0))}isTypedArray(e){return C$(e)}}if(W().get("IS_BROWSER")){W().setPlatform("browser",new HP);try{ar.registerManager(Di.URL_SCHEME,new GP)}catch{}try{ar.registerManager(Ai.URL_SCHEME,new OP)}catch{}}/** * @license * Copyright 2019 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -587,7 +587,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const KP={importFetch:()=>require("node-fetch")};let kg;class XP{constructor(){this.util=require("util"),this.textEncoder=new this.util.TextEncoder}fetch(e,n){return W().global.fetch!=null?W().global.fetch(e,n):(kg==null&&(kg=KP.importFetch()),kg(e,n))}now(){const e=process.hrtime();return e[0]*1e3+e[1]/1e6}encode(e,n){if(n!=="utf-8"&&n!=="utf8")throw new Error(`Node built-in encoder only supports utf-8, but got ${n}`);return this.textEncoder.encode(e)}decode(e,n){return e.length===0?"":new this.util.TextDecoder(n).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)}}W().get("IS_NODE")&&!W().get("IS_BROWSER")&&W().setPlatform("node",new XP);/** + */const jP={importFetch:()=>require("node-fetch")};let kg;class KP{constructor(){this.util=require("util"),this.textEncoder=new this.util.TextEncoder}fetch(e,n){return W().global.fetch!=null?W().global.fetch(e,n):(kg==null&&(kg=jP.importFetch()),kg(e,n))}now(){const e=process.hrtime();return e[0]*1e3+e[1]/1e6}encode(e,n){if(n!=="utf-8"&&n!=="utf8")throw new Error(`Node built-in encoder only supports utf-8, but got ${n}`);return this.textEncoder.encode(e)}decode(e,n){return e.length===0?"":new this.util.TextDecoder(n).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)}}W().get("IS_NODE")&&!W().get("IS_BROWSER")&&W().setPlatform("node",new KP);/** * @license * Copyright 2020 Google Inc. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -617,7 +617,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function qP(t,e){const n=T(t,"x","cast");if(!AM(e))throw new Error(`Failed to cast to unknown dtype ${e}`);if(e==="string"&&n.dtype!=="string"||e!=="string"&&n.dtype==="string")throw new Error("Only strings can be casted to strings");const s={x:n},r={dtype:e};return _.runKernel(bu,s,r)}const le=z({cast_:qP});/** + */function XP(t,e){const n=T(t,"x","cast");if(!RM(e))throw new Error(`Failed to cast to unknown dtype ${e}`);if(e==="string"&&n.dtype!=="string"||e!=="string"&&n.dtype==="string")throw new Error("Only strings can be casted to strings");const s={x:n},r={dtype:e};return _.runKernel(vu,s,r)}const le=z({cast_:XP});/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -632,7 +632,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function YP(t){const n={x:T(t,"x","clone","string_or_numeric")};return _.runKernel(Fu,n)}const vi=z({clone_:YP});/** + */function qP(t){const n={x:T(t,"x","clone","string_or_numeric")};return _.runKernel(_u,n)}const vi=z({clone_:qP});/** * @license * Copyright 2020 Google Inc. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -647,7 +647,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function QP(t,e=!1){console.log(t.toString(e))}/** + */function YP(t,e=!1){console.log(t.toString(e))}/** * @license * Copyright 2020 Google Inc. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -662,7 +662,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */O$();const ZP={buffer:Ee,cast:le,clone:vi,print:QP};cP(ZP);/** + */O$();const QP={buffer:Ee,cast:le,clone:vi,print:YP};lP(QP);/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -677,7 +677,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function JP(t,e){let n=T(t,"a","add"),s=T(e,"b","add");[n,s]=It(n,s);const r={a:n,b:s};return _.runKernel(bl,r)}const J=z({add_:JP});/** + */function ZP(t,e){let n=T(t,"a","add"),s=T(e,"b","add");[n,s]=It(n,s);const r={a:n,b:s};return _.runKernel(bl,r)}const J=z({add_:ZP});/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -692,7 +692,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function eL(t,e){let n=T(t,"a","floorDiv"),s=T(e,"b","floorDiv");[n,s]=It(n,s);const r={a:n,b:s};return _.runKernel(Du,r)}const X$=z({floorDiv_:eL});/** + */function JP(t,e){let n=T(t,"a","floorDiv"),s=T(e,"b","floorDiv");[n,s]=It(n,s);const r={a:n,b:s};return _.runKernel(Au,r)}const X$=z({floorDiv_:JP});/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -707,7 +707,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function tL(t,e){let n=T(t,"a","div"),s=T(e,"b","div");if([n,s]=It(n,s),n.dtype==="int32"&&s.dtype==="int32")return X$(n,s);const r={a:n,b:s},o={};return _.runKernel($u,r,o)}const ge=z({div_:tL});/** + */function eL(t,e){let n=T(t,"a","div"),s=T(e,"b","div");if([n,s]=It(n,s),n.dtype==="int32"&&s.dtype==="int32")return X$(n,s);const r={a:n,b:s},o={};return _.runKernel(Iu,r,o)}const ge=z({div_:eL});/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -722,7 +722,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function nL(t,e){let n=T(t,"a","mul"),s=T(e,"b","mul");[n,s]=It(n,s);const r={a:n,b:s};return _.runKernel(Uu,r)}const D=z({mul_:nL});/** + */function tL(t,e){let n=T(t,"a","mul"),s=T(e,"b","mul");[n,s]=It(n,s);const r={a:n,b:s};return _.runKernel(Wu,r)}const D=z({mul_:tL});/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -737,7 +737,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function sL(t){const e=T(t,"x","abs");if(e.dtype==="complex64"){const n={x:e};return _.runKernel(bp,n)}else{const n={x:e};return _.runKernel(pp,n)}}const xn=z({abs_:sL});/** + */function nL(t){const e=T(t,"x","abs");if(e.dtype==="complex64"){const n={x:e};return _.runKernel(bp,n)}else{const n={x:e};return _.runKernel(pp,n)}}const xn=z({abs_:nL});/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -752,7 +752,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function rL(t){const n={x:T(t,"x","acos")};return _.runKernel(pu,n)}const oL=z({acos_:rL});/** + */function sL(t){const n={x:T(t,"x","acos")};return _.runKernel(fu,n)}const rL=z({acos_:sL});/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -767,7 +767,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function iL(t){const n={x:T(t,"x","acosh")};return _.runKernel(mu,n)}const aL=z({acosh_:iL});/** + */function oL(t){const n={x:T(t,"x","acosh")};return _.runKernel(pu,n)}const iL=z({acosh_:oL});/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -782,7 +782,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function lL(t,e=null,n=!1){const r={x:T(t,"x","all","bool")},o={axis:e,keepDims:n};return _.runKernel(Hx,r,o)}const q$=z({all_:lL});/** + */function aL(t,e=null,n=!1){const r={x:T(t,"x","all","bool")},o={axis:e,keepDims:n};return _.runKernel(Hx,r,o)}const q$=z({all_:aL});/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -797,7 +797,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function cL(t,e=null,n=!1){const r={x:T(t,"x","any","bool")},o={axis:e,keepDims:n};return _.runKernel(jx,r,o)}const u1=z({any_:cL});/** + */function lL(t,e=null,n=!1){const r={x:T(t,"x","any","bool")},o={axis:e,keepDims:n};return _.runKernel(jx,r,o)}const u1=z({any_:lL});/** * @license * Copyright 2020 Google Inc. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -812,7 +812,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function uL(t,e=0){const s={x:T(t,"x","argMax")},r={axis:e};return _.runKernel(mp,s,r)}const Hc=z({argMax_:uL});/** + */function cL(t,e=0){const s={x:T(t,"x","argMax")},r={axis:e};return _.runKernel(mp,s,r)}const Hc=z({argMax_:cL});/** * @license * Copyright 2020 Google Inc. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -827,7 +827,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function hL(t,e=0){const s={x:T(t,"x","argMin")},r={axis:e};return _.runKernel(gp,s,r)}const dL=z({argMin_:hL});/** + */function uL(t,e=0){const s={x:T(t,"x","argMin")},r={axis:e};return _.runKernel(gp,s,r)}const hL=z({argMin_:uL});/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -842,7 +842,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function fL(t){const n={x:T(t,"x","asin")};return _.runKernel(gu,n)}const pL=z({asin_:fL});/** + */function dL(t){const n={x:T(t,"x","asin")};return _.runKernel(mu,n)}const fL=z({asin_:dL});/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -857,7 +857,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function mL(t){const n={x:T(t,"x","asinh")};return _.runKernel(xu,n)}const gL=z({asinh_:mL});/** + */function pL(t){const n={x:T(t,"x","asinh")};return _.runKernel(gu,n)}const mL=z({asinh_:pL});/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -872,7 +872,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function xL(t){const n={x:T(t,"x","atan")};return _.runKernel(yu,n)}const yL=z({atan_:xL});/** + */function gL(t){const n={x:T(t,"x","atan")};return _.runKernel(xu,n)}const xL=z({atan_:gL});/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -887,7 +887,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function wL(t,e){let n=T(t,"a","atan2"),s=T(e,"b","atan2");[n,s]=It(n,s);const r={a:n,b:s};return _.runKernel(vu,r)}const vL=z({atan2_:wL});/** + */function yL(t,e){let n=T(t,"a","atan2"),s=T(e,"b","atan2");[n,s]=It(n,s);const r={a:n,b:s};return _.runKernel(wu,r)}const wL=z({atan2_:yL});/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -902,7 +902,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function bL(t){const n={x:T(t,"x","atanh")};return _.runKernel(wu,n)}const CL=z({atanh_:bL});/** + */function vL(t){const n={x:T(t,"x","atanh")};return _.runKernel(yu,n)}const bL=z({atanh_:vL});/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -917,7 +917,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function hh(t,e,n,s,r="NHWC",o){const i=t[3],a=[...e,i],l=Qr(r);return nn(t,a,n,o,s,null,null,l)}function As(t,e,n,s,r,o,i="channelsLast"){const[a,l]=jc(e);let c;if(i==="channelsLast")c=[a,l,t[3],t[3]];else if(i==="channelsFirst")c=[a,l,t[1],t[1]];else throw new Error(`Unknown dataFormat ${i}`);return nn(t,c,n,s,r,o,!1,i)}function Yr(t,e,n,s,r,o,i="NDHWC"){const[a,l,c]=h1(e);let u,h;if(i==="NDHWC")h="channelsLast",u=[a,l,c,t[4],t[4]];else if(i==="NCDHW")h="channelsFirst",u=[a,l,c,t[1],t[1]];else throw new Error(`Unknown dataFormat ${i}`);return Go(t,u,n,s,r,!1,h,o)}function nn(t,e,n,s,r,o,i=!1,a="channelsLast"){let[l,c,u,h]=[-1,-1,-1,-1];if(a==="channelsLast")[l,c,u,h]=t;else if(a==="channelsFirst")[l,h,c,u]=t;else throw new Error(`Unknown dataFormat ${a}`);const[d,f,,p]=e,[g,x]=jc(n),[m,y]=jc(s),w=Pa(d,m),v=Pa(f,y),{padInfo:b,outHeight:C,outWidth:k}=IL(r,c,u,g,x,w,v,o,a),S=i?p*h:p;let $;return a==="channelsFirst"?$=[l,S,C,k]:a==="channelsLast"&&($=[l,C,k,S]),{batchSize:l,dataFormat:a,inHeight:c,inWidth:u,inChannels:h,outHeight:C,outWidth:k,outChannels:S,padInfo:b,strideHeight:g,strideWidth:x,filterHeight:d,filterWidth:f,effectiveFilterHeight:w,effectiveFilterWidth:v,dilationHeight:m,dilationWidth:y,inShape:t,outShape:$,filterShape:e}}function Go(t,e,n,s,r,o=!1,i="channelsLast",a){let[l,c,u,h,d]=[-1,-1,-1,-1,-1];if(i==="channelsLast")[l,c,u,h,d]=t;else if(i==="channelsFirst")[l,d,c,u,h]=t;else throw new Error(`Unknown dataFormat ${i}`);const[f,p,g,,x]=e,[m,y,w]=h1(n),[v,b,C]=h1(s),k=Pa(f,v),S=Pa(p,b),$=Pa(g,C),{padInfo:N,outDepth:A,outHeight:M,outWidth:L}=$L(r,c,u,h,m,y,w,k,S,$,a),V=o?x*d:x;let B;return i==="channelsFirst"?B=[l,V,A,M,L]:i==="channelsLast"&&(B=[l,A,M,L,V]),{batchSize:l,dataFormat:i,inDepth:c,inHeight:u,inWidth:h,inChannels:d,outDepth:A,outHeight:M,outWidth:L,outChannels:V,padInfo:N,strideDepth:m,strideHeight:y,strideWidth:w,filterDepth:f,filterHeight:p,filterWidth:g,effectiveFilterDepth:k,effectiveFilterHeight:S,effectiveFilterWidth:$,dilationDepth:v,dilationHeight:b,dilationWidth:C,inShape:t,outShape:B,filterShape:e}}function kL(t,e,n,s,r){s==null&&(s=zy(t,e,n));const o=t[0],i=t[1],a=Kc((o-e+2*s)/n+1,r),l=Kc((i-e+2*s)/n+1,r);return[a,l]}function SL(t,e,n,s,r,o){r==null&&(r=zy(t,e[0],s[0]));const i=[0,0,0,n];for(let a=0;a<3;a++)t[a]+2*r>=e[a]&&(i[a]=Kc((t[a]-e[a]+2*r)/s[a]+1,o));return i}function zy(t,e,n,s=1){const r=Pa(e,s);return Math.floor((t[0]*(n-1)-n+r)/2)}function jc(t){return typeof t=="number"?[t,t,t]:t.length===2?[t[0],t[1],1]:t}function h1(t){return typeof t=="number"?[t,t,t]:t}function Pa(t,e){return e<=1?t:t+(t-1)*(e-1)}function IL(t,e,n,s,r,o,i,a,l){let c,u,h;if(typeof t=="number"){c={top:t,bottom:t,left:t,right:t,type:t===0?"VALID":"NUMBER"};const f=kL([e,n],o,s,t,a);u=f[0],h=f[1]}else if(t==="same"){u=Math.ceil(e/s),h=Math.ceil(n/r);const d=Math.max(0,(u-1)*s+o-e),f=Math.max(0,(h-1)*r+i-n),p=Math.floor(d/2),g=d-p,x=Math.floor(f/2),m=f-x;c={top:p,bottom:g,left:x,right:m,type:"SAME"}}else if(t==="valid")c={top:0,bottom:0,left:0,right:0,type:"VALID"},u=Math.ceil((e-o+1)/s),h=Math.ceil((n-i+1)/r);else if(typeof t=="object"){const d=l==="channelsLast"?t[1][0]:t[2][0],f=l==="channelsLast"?t[1][1]:t[2][1],p=l==="channelsLast"?t[2][0]:t[3][0],g=l==="channelsLast"?t[2][1]:t[3][1];c={top:d,bottom:f,left:p,right:g,type:d===0&&f===0&&p===0&&g===0?"VALID":"EXPLICIT"},u=Kc((e-o+d+f)/s+1,a),h=Kc((n-i+p+g)/r+1,a)}else throw Error(`Unknown padding parameter: ${t}`);return{padInfo:c,outHeight:u,outWidth:h}}function $L(t,e,n,s,r,o,i,a,l,c,u){let h,d,f,p;if(t==="valid"&&(t=0),typeof t=="number"){h={top:t,bottom:t,left:t,right:t,front:t,back:t,type:t===0?"VALID":"NUMBER"};const x=SL([e,n,s,1],[a,l,c],1,[r,o,i],t,u);d=x[0],f=x[1],p=x[2]}else if(t==="same"){d=Math.ceil(e/r),f=Math.ceil(n/o),p=Math.ceil(s/i);const g=(d-1)*r+a-e,x=(f-1)*o+l-n,m=(p-1)*i+c-s,y=Math.floor(g/2),w=g-y,v=Math.floor(x/2),b=x-v,C=Math.floor(m/2),k=m-C;h={top:v,bottom:b,left:C,right:k,front:y,back:w,type:"SAME"}}else throw Error(`Unknown padding parameter: ${t}`);return{padInfo:h,outDepth:d,outHeight:f,outWidth:p}}function Kc(t,e){if(!e)return Math.trunc(t);switch(e){case"round":return Math.round(t);case"ceil":return Math.ceil(t);case"floor":return Math.floor(t);default:throw new Error(`Unknown roundingMode ${e}`)}}function _i(t){const[e,n,s]=jc(t);return e===1&&n===1&&s===1}function dn(t,e){return _i(t)||_i(e)}function Fi(t){return jc(t).every(e=>e>0)}function Qr(t){if(t==="NHWC")return"channelsLast";if(t==="NCHW")return"channelsFirst";throw new Error(`Unknown dataFormat ${t}`)}function Mn(t,e,n){if(n!=null){if(typeof e=="string")throw Error(`Error in ${t}: pad must be an integer when using dimRoundingMode ${n} but got pad ${e}.`);if(typeof e=="number")I(nl(e),()=>`Error in ${t}: pad must be an integer when using dimRoundingMode ${n} but got pad ${e}.`);else if(typeof e=="object")e.forEach(s=>{s.forEach(r=>{I(nl(r),()=>`Error in ${t}: pad must be an integer when using dimRoundingMode ${n} but got pad ${r}.`)})});else throw Error(`Error in ${t}: Unknown padding parameter: ${e}`)}}/** + */function uh(t,e,n,s,r="NHWC",o){const i=t[3],a=[...e,i],l=Qr(r);return nn(t,a,n,o,s,null,null,l)}function As(t,e,n,s,r,o,i="channelsLast"){const[a,l]=jc(e);let c;if(i==="channelsLast")c=[a,l,t[3],t[3]];else if(i==="channelsFirst")c=[a,l,t[1],t[1]];else throw new Error(`Unknown dataFormat ${i}`);return nn(t,c,n,s,r,o,!1,i)}function Yr(t,e,n,s,r,o,i="NDHWC"){const[a,l,c]=h1(e);let u,h;if(i==="NDHWC")h="channelsLast",u=[a,l,c,t[4],t[4]];else if(i==="NCDHW")h="channelsFirst",u=[a,l,c,t[1],t[1]];else throw new Error(`Unknown dataFormat ${i}`);return Go(t,u,n,s,r,!1,h,o)}function nn(t,e,n,s,r,o,i=!1,a="channelsLast"){let[l,c,u,h]=[-1,-1,-1,-1];if(a==="channelsLast")[l,c,u,h]=t;else if(a==="channelsFirst")[l,h,c,u]=t;else throw new Error(`Unknown dataFormat ${a}`);const[d,f,,p]=e,[g,x]=jc(n),[m,y]=jc(s),w=Pa(d,m),v=Pa(f,y),{padInfo:b,outHeight:C,outWidth:k}=SL(r,c,u,g,x,w,v,o,a),S=i?p*h:p;let $;return a==="channelsFirst"?$=[l,S,C,k]:a==="channelsLast"&&($=[l,C,k,S]),{batchSize:l,dataFormat:a,inHeight:c,inWidth:u,inChannels:h,outHeight:C,outWidth:k,outChannels:S,padInfo:b,strideHeight:g,strideWidth:x,filterHeight:d,filterWidth:f,effectiveFilterHeight:w,effectiveFilterWidth:v,dilationHeight:m,dilationWidth:y,inShape:t,outShape:$,filterShape:e}}function Go(t,e,n,s,r,o=!1,i="channelsLast",a){let[l,c,u,h,d]=[-1,-1,-1,-1,-1];if(i==="channelsLast")[l,c,u,h,d]=t;else if(i==="channelsFirst")[l,d,c,u,h]=t;else throw new Error(`Unknown dataFormat ${i}`);const[f,p,g,,x]=e,[m,y,w]=h1(n),[v,b,C]=h1(s),k=Pa(f,v),S=Pa(p,b),$=Pa(g,C),{padInfo:N,outDepth:A,outHeight:M,outWidth:L}=IL(r,c,u,h,m,y,w,k,S,$,a),V=o?x*d:x;let B;return i==="channelsFirst"?B=[l,V,A,M,L]:i==="channelsLast"&&(B=[l,A,M,L,V]),{batchSize:l,dataFormat:i,inDepth:c,inHeight:u,inWidth:h,inChannels:d,outDepth:A,outHeight:M,outWidth:L,outChannels:V,padInfo:N,strideDepth:m,strideHeight:y,strideWidth:w,filterDepth:f,filterHeight:p,filterWidth:g,effectiveFilterDepth:k,effectiveFilterHeight:S,effectiveFilterWidth:$,dilationDepth:v,dilationHeight:b,dilationWidth:C,inShape:t,outShape:B,filterShape:e}}function CL(t,e,n,s,r){s==null&&(s=zy(t,e,n));const o=t[0],i=t[1],a=Kc((o-e+2*s)/n+1,r),l=Kc((i-e+2*s)/n+1,r);return[a,l]}function kL(t,e,n,s,r,o){r==null&&(r=zy(t,e[0],s[0]));const i=[0,0,0,n];for(let a=0;a<3;a++)t[a]+2*r>=e[a]&&(i[a]=Kc((t[a]-e[a]+2*r)/s[a]+1,o));return i}function zy(t,e,n,s=1){const r=Pa(e,s);return Math.floor((t[0]*(n-1)-n+r)/2)}function jc(t){return typeof t=="number"?[t,t,t]:t.length===2?[t[0],t[1],1]:t}function h1(t){return typeof t=="number"?[t,t,t]:t}function Pa(t,e){return e<=1?t:t+(t-1)*(e-1)}function SL(t,e,n,s,r,o,i,a,l){let c,u,h;if(typeof t=="number"){c={top:t,bottom:t,left:t,right:t,type:t===0?"VALID":"NUMBER"};const f=CL([e,n],o,s,t,a);u=f[0],h=f[1]}else if(t==="same"){u=Math.ceil(e/s),h=Math.ceil(n/r);const d=Math.max(0,(u-1)*s+o-e),f=Math.max(0,(h-1)*r+i-n),p=Math.floor(d/2),g=d-p,x=Math.floor(f/2),m=f-x;c={top:p,bottom:g,left:x,right:m,type:"SAME"}}else if(t==="valid")c={top:0,bottom:0,left:0,right:0,type:"VALID"},u=Math.ceil((e-o+1)/s),h=Math.ceil((n-i+1)/r);else if(typeof t=="object"){const d=l==="channelsLast"?t[1][0]:t[2][0],f=l==="channelsLast"?t[1][1]:t[2][1],p=l==="channelsLast"?t[2][0]:t[3][0],g=l==="channelsLast"?t[2][1]:t[3][1];c={top:d,bottom:f,left:p,right:g,type:d===0&&f===0&&p===0&&g===0?"VALID":"EXPLICIT"},u=Kc((e-o+d+f)/s+1,a),h=Kc((n-i+p+g)/r+1,a)}else throw Error(`Unknown padding parameter: ${t}`);return{padInfo:c,outHeight:u,outWidth:h}}function IL(t,e,n,s,r,o,i,a,l,c,u){let h,d,f,p;if(t==="valid"&&(t=0),typeof t=="number"){h={top:t,bottom:t,left:t,right:t,front:t,back:t,type:t===0?"VALID":"NUMBER"};const x=kL([e,n,s,1],[a,l,c],1,[r,o,i],t,u);d=x[0],f=x[1],p=x[2]}else if(t==="same"){d=Math.ceil(e/r),f=Math.ceil(n/o),p=Math.ceil(s/i);const g=(d-1)*r+a-e,x=(f-1)*o+l-n,m=(p-1)*i+c-s,y=Math.floor(g/2),w=g-y,v=Math.floor(x/2),b=x-v,C=Math.floor(m/2),k=m-C;h={top:v,bottom:b,left:C,right:k,front:y,back:w,type:"SAME"}}else throw Error(`Unknown padding parameter: ${t}`);return{padInfo:h,outDepth:d,outHeight:f,outWidth:p}}function Kc(t,e){if(!e)return Math.trunc(t);switch(e){case"round":return Math.round(t);case"ceil":return Math.ceil(t);case"floor":return Math.floor(t);default:throw new Error(`Unknown roundingMode ${e}`)}}function _i(t){const[e,n,s]=jc(t);return e===1&&n===1&&s===1}function dn(t,e){return _i(t)||_i(e)}function Fi(t){return jc(t).every(e=>e>0)}function Qr(t){if(t==="NHWC")return"channelsLast";if(t==="NCHW")return"channelsFirst";throw new Error(`Unknown dataFormat ${t}`)}function Mn(t,e,n){if(n!=null){if(typeof e=="string")throw Error(`Error in ${t}: pad must be an integer when using dimRoundingMode ${n} but got pad ${e}.`);if(typeof e=="number")I(nl(e),()=>`Error in ${t}: pad must be an integer when using dimRoundingMode ${n} but got pad ${e}.`);else if(typeof e=="object")e.forEach(s=>{s.forEach(r=>{I(nl(r),()=>`Error in ${t}: pad must be an integer when using dimRoundingMode ${n} but got pad ${r}.`)})});else throw Error(`Error in ${t}: Unknown padding parameter: ${e}`)}}/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -932,7 +932,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function NL(t,e){const s={x:T(t,"x","reshape","string_or_numeric")},r={shape:e};return _.runKernel(tm,s,r)}const F=z({reshape_:NL});/** + */function $L(t,e){const s={x:T(t,"x","reshape","string_or_numeric")},r={shape:e};return _.runKernel(tm,s,r)}const F=z({reshape_:$L});/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -947,7 +947,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function TL(t,e,n,s,r){const o=T(t,"x","avgPool","float32"),i=1;I(dn(n,i),()=>`Error in avgPool: Either strides or dilations must be 1. Got strides ${n} and dilations '${i}'`);let a=o,l=!1;o.rank===3&&(l=!0,a=F(o,[1,o.shape[0],o.shape[1],o.shape[2]])),I(a.rank===4,()=>`Error in avgPool: x must be rank 4 but got rank ${a.rank}.`),Mn("avgPool",s,r);const c={x:a},u={filterSize:e,strides:n,pad:s,dimRoundingMode:r};let h=_.runKernel(xp,c,u);return h=le(h,o.dtype),l?F(h,[h.shape[1],h.shape[2],h.shape[3]]):h}const Oy=z({avgPool_:TL});/** + */function NL(t,e,n,s,r){const o=T(t,"x","avgPool","float32"),i=1;I(dn(n,i),()=>`Error in avgPool: Either strides or dilations must be 1. Got strides ${n} and dilations '${i}'`);let a=o,l=!1;o.rank===3&&(l=!0,a=F(o,[1,o.shape[0],o.shape[1],o.shape[2]])),I(a.rank===4,()=>`Error in avgPool: x must be rank 4 but got rank ${a.rank}.`),Mn("avgPool",s,r);const c={x:a},u={filterSize:e,strides:n,pad:s,dimRoundingMode:r};let h=_.runKernel(xp,c,u);return h=le(h,o.dtype),l?F(h,[h.shape[1],h.shape[2],h.shape[3]]):h}const Oy=z({avgPool_:NL});/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -962,7 +962,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function EL(t,e,n,s,r,o="NDHWC"){const i=T(t,"x","avgPool3d","float32");let a=i,l=!1;i.rank===4&&(l=!0,a=F(i,[1,i.shape[0],i.shape[1],i.shape[2],i.shape[3]])),I(a.rank===5,()=>`Error in avgPool3d: x must be rank 5 but got rank ${a.rank}.`),I(o==="NDHWC",()=>`Error in avgPool3d: Only NDHWC is currently supported, but got dataFormat of ${o}`),I(typeof n=="number"&&n>0||Array.isArray(n)&&n[0]>0&&n[1]>0&&n[2]>0,()=>`Error in avgPool3d: Stride must be > 0, but got '${n}'`),Mn("avgPool3d",s,r);const c={x:a},u={filterSize:e,strides:n,pad:s,dimRoundingMode:r,dataFormat:o};let h=_.runKernel(yp,c,u);return h=le(h,a.dtype),l?F(h,[h.shape[1],h.shape[2],h.shape[3],h.shape[4]]):h}const RL=z({avgPool3d_:EL});/** + */function TL(t,e,n,s,r,o="NDHWC"){const i=T(t,"x","avgPool3d","float32");let a=i,l=!1;i.rank===4&&(l=!0,a=F(i,[1,i.shape[0],i.shape[1],i.shape[2],i.shape[3]])),I(a.rank===5,()=>`Error in avgPool3d: x must be rank 5 but got rank ${a.rank}.`),I(o==="NDHWC",()=>`Error in avgPool3d: Only NDHWC is currently supported, but got dataFormat of ${o}`),I(typeof n=="number"&&n>0||Array.isArray(n)&&n[0]>0&&n[1]>0&&n[2]>0,()=>`Error in avgPool3d: Stride must be > 0, but got '${n}'`),Mn("avgPool3d",s,r);const c={x:a},u={filterSize:e,strides:n,pad:s,dimRoundingMode:r,dataFormat:o};let h=_.runKernel(yp,c,u);return h=le(h,a.dtype),l?F(h,[h.shape[1],h.shape[2],h.shape[3],h.shape[4]]):h}const EL=z({avgPool3d_:TL});/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -977,8 +977,8 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function AL(t,e=0){I(t.length>=1,()=>"Pass at least one tensor to concat");const n=B$(t,"tensors","concat","string_or_numeric");if(n[0].dtype==="complex64"&&n.forEach(o=>{if(o.dtype!=="complex64")throw new Error(`Cannot concatenate complex64 tensors with a tensor - with dtype ${o.dtype}. `)}),n.length===1)return vi(n[0]);const s=n,r={axis:e};return _.runKernel(Cp,s,r)}const Dn=z({concat_:AL});/** + */function RL(t,e=0){I(t.length>=1,()=>"Pass at least one tensor to concat");const n=B$(t,"tensors","concat","string_or_numeric");if(n[0].dtype==="complex64"&&n.forEach(o=>{if(o.dtype!=="complex64")throw new Error(`Cannot concatenate complex64 tensors with a tensor + with dtype ${o.dtype}. `)}),n.length===1)return vi(n[0]);const s=n,r={axis:e};return _.runKernel(Cp,s,r)}const Dn=z({concat_:RL});/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -993,7 +993,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function DL(t,e,n=!1,s=!1){let r=T(t,"a","matMul"),o=T(e,"b","matMul");[r,o]=It(r,o);const i={a:r,b:o},a={transposeA:n,transposeB:s};return _.runKernel(wp,i,a)}const Ve=z({matMul_:DL});/** + */function AL(t,e,n=!1,s=!1){let r=T(t,"a","matMul"),o=T(e,"b","matMul");[r,o]=It(r,o);const i={a:r,b:o},a={transposeA:n,transposeB:s};return _.runKernel(wp,i,a)}const Ve=z({matMul_:AL});/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -1008,7 +1008,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function _L(t){const n={x:T(t,"x","sigmoid","float32")};return _.runKernel(eh,n)}const Cl=z({sigmoid_:_L});/** + */function DL(t){const n={x:T(t,"x","sigmoid","float32")};return _.runKernel(Ju,n)}const Cl=z({sigmoid_:DL});/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -1023,7 +1023,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function FL(t,e,n){const s=T(t,"x","slice","string_or_numeric");if(s.rank===0)throw new Error("Slicing scalar is not possible");const r={x:s},o={begin:e,size:n};return _.runKernel(im,r,o)}const tt=z({slice_:FL});/** + */function _L(t,e,n){const s=T(t,"x","slice","string_or_numeric");if(s.rank===0)throw new Error("Slicing scalar is not possible");const r={x:s},o={begin:e,size:n};return _.runKernel(im,r,o)}const tt=z({slice_:_L});/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -1038,7 +1038,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function zL(t){const n={x:T(t,"x","tanh","float32")};return _.runKernel(ih,n)}const mm=z({tanh_:zL});/** + */function FL(t){const n={x:T(t,"x","tanh","float32")};return _.runKernel(oh,n)}const mm=z({tanh_:FL});/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -1053,7 +1053,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function OL(t,e,n){const s=T(t,"x","batchToSpaceND"),r=e.reduce((a,l)=>a*l);I(s.rank>=1+e.length,()=>`input rank is ${s.rank} but should be > than blockShape.length ${e.length}`),I(n.length===e.length,()=>`crops.length is ${n.length} but should be equal to blockShape.length ${e.length}`),I(s.shape[0]%r===0,()=>`input tensor batch is ${s.shape[0]} but is not divisible by the product of the elements of blockShape ${e.join(" * ")} === ${r}`);const o={x:s},i={blockShape:e,crops:n};return _.runKernel(vp,o,i)}const My=z({batchToSpaceND_:OL});function ML(t){let e;return t.rank===0||t.rank===1?e=F(t,[1,1,1,t.size]):t.rank===2?e=F(t,[1,1,t.shape[0],t.shape[1]]):t.rank===3?e=F(t,[1,t.shape[0],t.shape[1],t.shape[2]]):e=t,e}/** + */function zL(t,e,n){const s=T(t,"x","batchToSpaceND"),r=e.reduce((a,l)=>a*l);I(s.rank>=1+e.length,()=>`input rank is ${s.rank} but should be > than blockShape.length ${e.length}`),I(n.length===e.length,()=>`crops.length is ${n.length} but should be equal to blockShape.length ${e.length}`),I(s.shape[0]%r===0,()=>`input tensor batch is ${s.shape[0]} but is not divisible by the product of the elements of blockShape ${e.join(" * ")} === ${r}`);const o={x:s},i={blockShape:e,crops:n};return _.runKernel(vp,o,i)}const My=z({batchToSpaceND_:zL});function OL(t){let e;return t.rank===0||t.rank===1?e=F(t,[1,1,1,t.size]):t.rank===2?e=F(t,[1,1,t.shape[0],t.shape[1]]):t.rank===3?e=F(t,[1,t.shape[0],t.shape[1],t.shape[2]]):e=t,e}/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -1068,7 +1068,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function PL(t,e,n,s,r,o){o==null&&(o=.001);const i=T(t,"x","batchNorm"),a=T(e,"mean","batchNorm"),l=T(n,"variance","batchNorm");let c;r!=null&&(c=T(r,"scale","batchNorm"));let u;s!=null&&(u=T(s,"offset","batchNorm")),I(a.rank===l.rank,()=>"Batch normalization gradient requires mean and variance to have equal ranks."),I(u==null||a.rank===u.rank,()=>"Batch normalization gradient requires mean and offset to have equal ranks."),I(c==null||a.rank===c.rank,()=>"Batch normalization gradient requires mean and scale to have equal ranks.");const d={x:ML(i),scale:c,offset:u,mean:a,variance:l},f={varianceEpsilon:o},p=_.runKernel(Ap,d,f);return F(p,i.shape)}const gm=z({batchNorm_:PL});function LL(t,e,n,s,r,o){const i=T(t,"x","batchNorm"),a=T(e,"mean","batchNorm"),l=T(n,"variance","batchNorm");let c;r!=null&&(c=T(r,"scale","batchNorm"));let u;return s!=null&&(u=T(s,"offset","batchNorm")),I(i.rank===2,()=>`Error in batchNorm2D: x must be rank 2 but got rank ${i.rank}.`),I(a.rank===2||a.rank===1,()=>`Error in batchNorm2D: mean must be rank 2 or rank 1 but got rank ${a.rank}.`),I(l.rank===2||l.rank===1,()=>`Error in batchNorm2D: variance must be rank 2 or rank 1 but got rank ${l.rank}.`),c!=null&&I(c.rank===2||c.rank===1,()=>`Error in batchNorm2D: scale must be rank 2 or rank 1 but got rank ${c.rank}.`),u!=null&&I(u.rank===2||u.rank===1,()=>`Error in batchNorm2D: offset must be rank 2 or rank 1 but got rank ${u.rank}.`),gm(i,a,l,u,c,o)}const BL=z({batchNorm2d_:LL});function VL(t,e,n,s,r,o){const i=T(t,"x","batchNorm"),a=T(e,"mean","batchNorm"),l=T(n,"variance","batchNorm");let c;r!=null&&(c=T(r,"scale","batchNorm"));let u;return s!=null&&(u=T(s,"offset","batchNorm")),I(i.rank===3,()=>`Error in batchNorm3D: x must be rank 3 but got rank ${i.rank}.`),I(a.rank===3||a.rank===1,()=>`Error in batchNorm3D: mean must be rank 3 or rank 1 but got rank ${a.rank}.`),I(l.rank===3||l.rank===1,()=>`Error in batchNorm3D: variance must be rank 3 or rank 1 but got rank ${l.rank}.`),c!=null&&I(c.rank===3||c.rank===1,()=>`Error in batchNorm3D: scale must be rank 3 or rank 1 but got rank ${c.rank}.`),u!=null&&I(u.rank===3||u.rank===1,()=>`Error in batchNorm3D: offset must be rank 3 or rank 1 but got rank ${u.rank}.`),gm(i,a,l,u,c,o)}const WL=z({batchNorm3d_:VL});function UL(t,e,n,s,r,o){const i=T(t,"x","batchNorm"),a=T(e,"mean","batchNorm"),l=T(n,"variance","batchNorm");let c;r!=null&&(c=T(r,"scale","batchNorm"));let u;return s!=null&&(u=T(s,"offset","batchNorm")),I(i.rank===4,()=>`Error in batchNorm4D: x must be rank 4 but got rank ${i.rank}.`),I(a.rank===4||a.rank===1,()=>`Error in batchNorm4D: mean must be rank 4 or rank 1 but got rank ${a.rank}.`),I(l.rank===4||l.rank===1,()=>`Error in batchNorm4D: variance must be rank 4 or rank 1 but got rank ${l.rank}.`),c!=null&&I(c.rank===4||c.rank===1,()=>`Error in batchNorm4D: scale must be rank 4 or rank 1 but got rank ${c.rank}.`),u!=null&&I(u.rank===4||u.rank===1,()=>`Error in batchNorm4D: offset must be rank 4 or rank 1 but got rank ${u.rank}.`),gm(i,a,l,u,c,o)}const GL=z({batchNorm4d_:UL});/** + */function ML(t,e,n,s,r,o){o==null&&(o=.001);const i=T(t,"x","batchNorm"),a=T(e,"mean","batchNorm"),l=T(n,"variance","batchNorm");let c;r!=null&&(c=T(r,"scale","batchNorm"));let u;s!=null&&(u=T(s,"offset","batchNorm")),I(a.rank===l.rank,()=>"Batch normalization gradient requires mean and variance to have equal ranks."),I(u==null||a.rank===u.rank,()=>"Batch normalization gradient requires mean and offset to have equal ranks."),I(c==null||a.rank===c.rank,()=>"Batch normalization gradient requires mean and scale to have equal ranks.");const d={x:OL(i),scale:c,offset:u,mean:a,variance:l},f={varianceEpsilon:o},p=_.runKernel(Ap,d,f);return F(p,i.shape)}const gm=z({batchNorm_:ML});function PL(t,e,n,s,r,o){const i=T(t,"x","batchNorm"),a=T(e,"mean","batchNorm"),l=T(n,"variance","batchNorm");let c;r!=null&&(c=T(r,"scale","batchNorm"));let u;return s!=null&&(u=T(s,"offset","batchNorm")),I(i.rank===2,()=>`Error in batchNorm2D: x must be rank 2 but got rank ${i.rank}.`),I(a.rank===2||a.rank===1,()=>`Error in batchNorm2D: mean must be rank 2 or rank 1 but got rank ${a.rank}.`),I(l.rank===2||l.rank===1,()=>`Error in batchNorm2D: variance must be rank 2 or rank 1 but got rank ${l.rank}.`),c!=null&&I(c.rank===2||c.rank===1,()=>`Error in batchNorm2D: scale must be rank 2 or rank 1 but got rank ${c.rank}.`),u!=null&&I(u.rank===2||u.rank===1,()=>`Error in batchNorm2D: offset must be rank 2 or rank 1 but got rank ${u.rank}.`),gm(i,a,l,u,c,o)}const LL=z({batchNorm2d_:PL});function BL(t,e,n,s,r,o){const i=T(t,"x","batchNorm"),a=T(e,"mean","batchNorm"),l=T(n,"variance","batchNorm");let c;r!=null&&(c=T(r,"scale","batchNorm"));let u;return s!=null&&(u=T(s,"offset","batchNorm")),I(i.rank===3,()=>`Error in batchNorm3D: x must be rank 3 but got rank ${i.rank}.`),I(a.rank===3||a.rank===1,()=>`Error in batchNorm3D: mean must be rank 3 or rank 1 but got rank ${a.rank}.`),I(l.rank===3||l.rank===1,()=>`Error in batchNorm3D: variance must be rank 3 or rank 1 but got rank ${l.rank}.`),c!=null&&I(c.rank===3||c.rank===1,()=>`Error in batchNorm3D: scale must be rank 3 or rank 1 but got rank ${c.rank}.`),u!=null&&I(u.rank===3||u.rank===1,()=>`Error in batchNorm3D: offset must be rank 3 or rank 1 but got rank ${u.rank}.`),gm(i,a,l,u,c,o)}const VL=z({batchNorm3d_:BL});function WL(t,e,n,s,r,o){const i=T(t,"x","batchNorm"),a=T(e,"mean","batchNorm"),l=T(n,"variance","batchNorm");let c;r!=null&&(c=T(r,"scale","batchNorm"));let u;return s!=null&&(u=T(s,"offset","batchNorm")),I(i.rank===4,()=>`Error in batchNorm4D: x must be rank 4 but got rank ${i.rank}.`),I(a.rank===4||a.rank===1,()=>`Error in batchNorm4D: mean must be rank 4 or rank 1 but got rank ${a.rank}.`),I(l.rank===4||l.rank===1,()=>`Error in batchNorm4D: variance must be rank 4 or rank 1 but got rank ${l.rank}.`),c!=null&&I(c.rank===4||c.rank===1,()=>`Error in batchNorm4D: scale must be rank 4 or rank 1 but got rank ${c.rank}.`),u!=null&&I(u.rank===4||u.rank===1,()=>`Error in batchNorm4D: offset must be rank 4 or rank 1 but got rank ${u.rank}.`),gm(i,a,l,u,c,o)}const UL=z({batchNorm4d_:WL});/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -1083,7 +1083,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function HL(t,e,n){const s=T(t,"x","bincount"),r=T(e,"weights","bincount");I(s.dtype==="int32",()=>`Error in bincount: input dtype must be int32, but got ${s.dtype}`),I(n>=0,()=>`size must be non-negative, but got ${n}.`),I(r.size===s.size||r.size===0,()=>`Error in bincount: weights must have the same size as input or0-length, but got input shape: ${s.shape}, weights shape: ${r.shape}.`);const o={x:s,weights:r},i={size:n};return _.runKernel(qx,o,i)}const jL=z({bincount_:HL});/** + */function GL(t,e,n){const s=T(t,"x","bincount"),r=T(e,"weights","bincount");I(s.dtype==="int32",()=>`Error in bincount: input dtype must be int32, but got ${s.dtype}`),I(n>=0,()=>`size must be non-negative, but got ${n}.`),I(r.size===s.size||r.size===0,()=>`Error in bincount: weights must have the same size as input or0-length, but got input shape: ${s.shape}, weights shape: ${r.shape}.`);const o={x:s,weights:r},i={size:n};return _.runKernel(qx,o,i)}const HL=z({bincount_:GL});/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -1098,7 +1098,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function KL(t,e){let n=T(t,"broadcastTo","x");const s=n.shape;if(qr(e),e.lengthn.rank){const c=n.shape.slice();for(;c.length=0;c--)if(r[c]===e[c])o[c]=1;else if(n.shape[c]!==1)throw new Error(`broadcastTo(): [${s}] cannot be broadcast to [${e}].`);if(o.map((c,u)=>c>1?u:-1).filter(c=>c>=0).length===0)return vi(n);const a={x:n},l={reps:o};return _.runKernel(ah,a,l)}const Cc=z({broadcastTo_:KL});/** + */function jL(t,e){let n=T(t,"broadcastTo","x");const s=n.shape;if(qr(e),e.lengthn.rank){const c=n.shape.slice();for(;c.length=0;c--)if(r[c]===e[c])o[c]=1;else if(n.shape[c]!==1)throw new Error(`broadcastTo(): [${s}] cannot be broadcast to [${e}].`);if(o.map((c,u)=>c>1?u:-1).filter(c=>c>=0).length===0)return vi(n);const a={x:n},l={reps:o};return _.runKernel(ih,a,l)}const Cc=z({broadcastTo_:jL});/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -1113,7 +1113,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function XL(t){const n={x:T(t,"x","ceil","float32")};return _.runKernel(Cu,n)}const qL=z({ceil_:XL});/** + */function KL(t){const n={x:T(t,"x","ceil","float32")};return _.runKernel(bu,n)}const XL=z({ceil_:KL});/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -1143,7 +1143,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function YL(t,e,n){const s=T(t,"x","clipByValue");if(I(e<=n,()=>`Error in clip: min (${e}) must be less than or equal to max (${n}).`),e===n)return xm(s.shape,e,s.dtype);const r={x:s},o={clipValueMin:e,clipValueMax:n};return _.runKernel(ku,r,o)}const as=z({clipByValue_:YL});function QL(t){return Dn(t,0)}const ZL=z({concat1d_:QL});function JL(t,e){return Dn(t,e)}const e4=z({concat2d_:JL});function t4(t,e){return Dn(t,e)}const n4=z({concat3d_:t4});function s4(t,e){return Dn(t,e)}const r4=z({concat4d_:s4});/** + */function qL(t,e,n){const s=T(t,"x","clipByValue");if(I(e<=n,()=>`Error in clip: min (${e}) must be less than or equal to max (${n}).`),e===n)return xm(s.shape,e,s.dtype);const r={x:s},o={clipValueMin:e,clipValueMax:n};return _.runKernel(Cu,r,o)}const as=z({clipByValue_:qL});function YL(t){return Dn(t,0)}const QL=z({concat1d_:YL});function ZL(t,e){return Dn(t,e)}const JL=z({concat2d_:ZL});function e4(t,e){return Dn(t,e)}const t4=z({concat3d_:e4});function n4(t,e){return Dn(t,e)}const s4=z({concat4d_:n4});/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -1158,7 +1158,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function o4(t,e,n,s,r="NHWC",o=[1,1],i){const a=T(t,"x","conv2d","float32"),l=T(e,"filter","conv2d","float32");let c=a,u=!1;a.rank===3&&(u=!0,c=F(a,[1,a.shape[0],a.shape[1],a.shape[2]])),I(c.rank===4,()=>`Error in conv2d: input must be rank 4, but got rank ${c.rank}.`),I(l.rank===4,()=>`Error in conv2d: filter must be rank 4, but got rank ${l.rank}.`),Mn("conv2d",s,i);const h=r==="NHWC"?c.shape[3]:c.shape[1];I(h===l.shape[2],()=>`Error in conv2d: depth of input (${h}) must match input depth for filter ${l.shape[2]}.`),I(dn(n,o),()=>`Error in conv2D: Either strides or dilations must be 1. Got strides ${n} and dilations '${o}'`),I(Fi(o),()=>"Error in conv2D: Dilated rates should be larger than 0."),I(Fi(n),()=>"Error in conv2D: Strides should be larger than 0.");const d={x:c,filter:l},f={strides:n,pad:s,dataFormat:r,dilations:o,dimRoundingMode:i},p=_.runKernel(kp,d,f);return u?F(p,[p.shape[1],p.shape[2],p.shape[3]]):p}const zi=z({conv2d_:o4});function i4(t,e,n,s,r="NWC",o=1,i){const a=T(t,"x","conv1d"),l=T(e,"filter","conv1d");let c=a,u=!1;a.rank===2&&(u=!0,c=F(a,[1,a.shape[0],a.shape[1]])),I(c.rank===3,()=>`Error in conv1d: input must be rank 3, but got rank ${c.rank}.`),I(l.rank===3,()=>`Error in conv1d: filter must be rank 3, but got rank ${l.rank}.`),Mn("conv1d",s,i),I(c.shape[2]===l.shape[1],()=>`Error in conv1d: depth of input (${c.shape[2]}) must match input depth for filter ${l.shape[1]}.`),I(dn(n,o),()=>`Error in conv1D: Either stride or dilation must be 1. Got stride ${n} and dilation '${o}'`),I(Fi(o),()=>"Error in conv1D: Dilated rates should be larger than 0."),I(Fi(n),()=>"Error in conv1D: Stride should be larger than 0."),I(r==="NWC",()=>`Error in conv1d: got dataFormat of ${r} but only NWC is currently supported.`);const h=F(l,[1,l.shape[0],l.shape[1],l.shape[2]]),d=F(c,[c.shape[0],1,c.shape[1],c.shape[2]]),x=zi(d,h,[1,n],s,"NHWC",[1,o],i);return u?F(x,[x.shape[2],x.shape[3]]):F(x,[x.shape[0],x.shape[2],x.shape[3]])}const Y$=z({conv1d_:i4});/** + */function r4(t,e,n,s,r="NHWC",o=[1,1],i){const a=T(t,"x","conv2d","float32"),l=T(e,"filter","conv2d","float32");let c=a,u=!1;a.rank===3&&(u=!0,c=F(a,[1,a.shape[0],a.shape[1],a.shape[2]])),I(c.rank===4,()=>`Error in conv2d: input must be rank 4, but got rank ${c.rank}.`),I(l.rank===4,()=>`Error in conv2d: filter must be rank 4, but got rank ${l.rank}.`),Mn("conv2d",s,i);const h=r==="NHWC"?c.shape[3]:c.shape[1];I(h===l.shape[2],()=>`Error in conv2d: depth of input (${h}) must match input depth for filter ${l.shape[2]}.`),I(dn(n,o),()=>`Error in conv2D: Either strides or dilations must be 1. Got strides ${n} and dilations '${o}'`),I(Fi(o),()=>"Error in conv2D: Dilated rates should be larger than 0."),I(Fi(n),()=>"Error in conv2D: Strides should be larger than 0.");const d={x:c,filter:l},f={strides:n,pad:s,dataFormat:r,dilations:o,dimRoundingMode:i},p=_.runKernel(kp,d,f);return u?F(p,[p.shape[1],p.shape[2],p.shape[3]]):p}const zi=z({conv2d_:r4});function o4(t,e,n,s,r="NWC",o=1,i){const a=T(t,"x","conv1d"),l=T(e,"filter","conv1d");let c=a,u=!1;a.rank===2&&(u=!0,c=F(a,[1,a.shape[0],a.shape[1]])),I(c.rank===3,()=>`Error in conv1d: input must be rank 3, but got rank ${c.rank}.`),I(l.rank===3,()=>`Error in conv1d: filter must be rank 3, but got rank ${l.rank}.`),Mn("conv1d",s,i),I(c.shape[2]===l.shape[1],()=>`Error in conv1d: depth of input (${c.shape[2]}) must match input depth for filter ${l.shape[1]}.`),I(dn(n,o),()=>`Error in conv1D: Either stride or dilation must be 1. Got stride ${n} and dilation '${o}'`),I(Fi(o),()=>"Error in conv1D: Dilated rates should be larger than 0."),I(Fi(n),()=>"Error in conv1D: Stride should be larger than 0."),I(r==="NWC",()=>`Error in conv1d: got dataFormat of ${r} but only NWC is currently supported.`);const h=F(l,[1,l.shape[0],l.shape[1],l.shape[2]]),d=F(c,[c.shape[0],1,c.shape[1],c.shape[2]]),x=zi(d,h,[1,n],s,"NHWC",[1,o],i);return u?F(x,[x.shape[2],x.shape[3]]):F(x,[x.shape[0],x.shape[2],x.shape[3]])}const Y$=z({conv1d_:o4});/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -1173,7 +1173,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function a4(t,e,n,s,r,o="NHWC",i){I(t.length===e.rank,()=>`Length of inShape (${t.length}) and rank of dy (${e.rank}) must match`);let a=t,l=e,c=!1;e.rank===3&&(c=!0,l=F(e,[1,e.shape[0],e.shape[1],e.shape[2]]),a=[1,t[0],t[1],t[2]]),I(a.length===4,()=>`Error in conv2dDerInput: inShape must be length 4, but got length ${a.length}.`),I(l.rank===4,()=>`Error in conv2dDerInput: dy must be rank 4, but got rank ${l.rank}`),I(n.rank===4,()=>`Error in conv2dDerInput: filter must be rank 4, but got rank ${n.rank}`);const u=o==="NHWC"?a[3]:a[1],h=o==="NHWC"?l.shape[3]:l.shape[1];I(u===n.shape[2],()=>`Error in conv2dDerInput: depth of input (${u}) must match input depth for filter ${n.shape[2]}.`),I(h===n.shape[3],()=>`Error in conv2dDerInput: depth of output (${h}) must match output depth for filter ${n.shape[3]}.`),Mn("conv2dDerInput",r,i);const d={dy:l,filter:n},f={strides:s,pad:r,dataFormat:o,dimRoundingMode:i,inputShape:a},p=_.runKernel(Sp,d,f);return c?F(p,[p.shape[1],p.shape[2],p.shape[3]]):p}const Py=z({conv2DBackpropInput_:a4});function l4(t,e,n,s,r,o){const i=T(t,"x","conv2dTranspose"),a=T(e,"filter","conv2dTranspose");return Py(n,i,a,s,r,"NHWC",o)}const Q$=z({conv2dTranspose_:l4});/** + */function i4(t,e,n,s,r,o="NHWC",i){I(t.length===e.rank,()=>`Length of inShape (${t.length}) and rank of dy (${e.rank}) must match`);let a=t,l=e,c=!1;e.rank===3&&(c=!0,l=F(e,[1,e.shape[0],e.shape[1],e.shape[2]]),a=[1,t[0],t[1],t[2]]),I(a.length===4,()=>`Error in conv2dDerInput: inShape must be length 4, but got length ${a.length}.`),I(l.rank===4,()=>`Error in conv2dDerInput: dy must be rank 4, but got rank ${l.rank}`),I(n.rank===4,()=>`Error in conv2dDerInput: filter must be rank 4, but got rank ${n.rank}`);const u=o==="NHWC"?a[3]:a[1],h=o==="NHWC"?l.shape[3]:l.shape[1];I(u===n.shape[2],()=>`Error in conv2dDerInput: depth of input (${u}) must match input depth for filter ${n.shape[2]}.`),I(h===n.shape[3],()=>`Error in conv2dDerInput: depth of output (${h}) must match output depth for filter ${n.shape[3]}.`),Mn("conv2dDerInput",r,i);const d={dy:l,filter:n},f={strides:s,pad:r,dataFormat:o,dimRoundingMode:i,inputShape:a},p=_.runKernel(Sp,d,f);return c?F(p,[p.shape[1],p.shape[2],p.shape[3]]):p}const Py=z({conv2DBackpropInput_:i4});function a4(t,e,n,s,r,o){const i=T(t,"x","conv2dTranspose"),a=T(e,"filter","conv2dTranspose");return Py(n,i,a,s,r,"NHWC",o)}const Q$=z({conv2dTranspose_:a4});/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -1188,7 +1188,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function c4(t,e,n,s,r="NDHWC",o=[1,1,1]){const i=T(t,"x","conv3d"),a=T(e,"filter","conv3d");let l=i,c=!1;i.rank===4&&(c=!0,l=F(i,[1,i.shape[0],i.shape[1],i.shape[2],i.shape[3]])),I(l.rank===5,()=>`Error in conv3d: input must be rank 5, but got rank ${l.rank}.`),I(a.rank===5,()=>`Error in conv3d: filter must be rank 5, but got rank ${a.rank}.`),I(l.shape[4]===a.shape[3],()=>`Error in conv3d: depth of input (${l.shape[4]}) must match input depth for filter ${a.shape[3]}.`),I(dn(n,o),()=>`Error in conv3D: Either strides or dilations must be 1. Got strides ${n} and dilations '${o}'`),I(r==="NDHWC",()=>`Error in conv3d: got dataFormat of ${r} but only NDHWC is currently supported.`),I(Fi(o),()=>"Error in conv3D: Dilated rates should be larger than 0."),I(Fi(n),()=>"Error in conv3D: Strides should be larger than 0.");const u={x:l,filter:a},h={strides:n,pad:s,dataFormat:r,dilations:o},d=_.runKernel(Ip,u,h);return c?F(d,[d.shape[1],d.shape[2],d.shape[3],d.shape[4]]):d}const u4=z({conv3d_:c4});/** + */function l4(t,e,n,s,r="NDHWC",o=[1,1,1]){const i=T(t,"x","conv3d"),a=T(e,"filter","conv3d");let l=i,c=!1;i.rank===4&&(c=!0,l=F(i,[1,i.shape[0],i.shape[1],i.shape[2],i.shape[3]])),I(l.rank===5,()=>`Error in conv3d: input must be rank 5, but got rank ${l.rank}.`),I(a.rank===5,()=>`Error in conv3d: filter must be rank 5, but got rank ${a.rank}.`),I(l.shape[4]===a.shape[3],()=>`Error in conv3d: depth of input (${l.shape[4]}) must match input depth for filter ${a.shape[3]}.`),I(dn(n,o),()=>`Error in conv3D: Either strides or dilations must be 1. Got strides ${n} and dilations '${o}'`),I(r==="NDHWC",()=>`Error in conv3d: got dataFormat of ${r} but only NDHWC is currently supported.`),I(Fi(o),()=>"Error in conv3D: Dilated rates should be larger than 0."),I(Fi(n),()=>"Error in conv3D: Strides should be larger than 0.");const u={x:l,filter:a},h={strides:n,pad:s,dataFormat:r,dilations:o},d=_.runKernel(Ip,u,h);return c?F(d,[d.shape[1],d.shape[2],d.shape[3],d.shape[4]]):d}const c4=z({conv3d_:l4});/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -1203,7 +1203,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function h4(t,e,n,s,r){I(t.length===e.rank,()=>`Length of inShape (${t.length}) and rank of dy (${e.rank}) must match`);let o=t,i=e,a=!1;e.rank===4&&(a=!0,i=F(e,[1,e.shape[0],e.shape[1],e.shape[2],e.shape[3]]),o=[1,t[0],t[1],t[2],t[3]]);const l=o[4],c=i.shape[4];I(o.length===5,()=>`Error in conv3dDerInput: inShape must be length 5, but got length ${o.length}.`),I(i.rank===5,()=>`Error in conv3dDerInput: dy must be rank 5, but got rank ${i.rank}`),I(n.rank===5,()=>`Error in conv3dDerInput: filter must be rank 5, but got rank ${n.rank}`),I(l===n.shape[3],()=>`Error in conv3dDerInput: depth of input (${l}) must match input depth for filter ${n.shape[3]}.`),I(c===n.shape[4],()=>`Error in conv3dDerInput: depth of output (${c}) must match output depth for filter ${n.shape[4]}.`);const u={dy:i,filter:n},h={pad:r,strides:s,inputShape:o},d=_.runKernel(ey,u,h);return a?F(d,[d.shape[1],d.shape[2],d.shape[3],d.shape[4]]):d}const Z$=z({conv3DBackpropInput_:h4});function d4(t,e,n,s,r){const o=T(t,"x","conv3dTranspose"),i=T(e,"filter","conv3dTranspose");return Z$(n,o,i,s,r)}const f4=z({conv3dTranspose_:d4});/** + */function u4(t,e,n,s,r){I(t.length===e.rank,()=>`Length of inShape (${t.length}) and rank of dy (${e.rank}) must match`);let o=t,i=e,a=!1;e.rank===4&&(a=!0,i=F(e,[1,e.shape[0],e.shape[1],e.shape[2],e.shape[3]]),o=[1,t[0],t[1],t[2],t[3]]);const l=o[4],c=i.shape[4];I(o.length===5,()=>`Error in conv3dDerInput: inShape must be length 5, but got length ${o.length}.`),I(i.rank===5,()=>`Error in conv3dDerInput: dy must be rank 5, but got rank ${i.rank}`),I(n.rank===5,()=>`Error in conv3dDerInput: filter must be rank 5, but got rank ${n.rank}`),I(l===n.shape[3],()=>`Error in conv3dDerInput: depth of input (${l}) must match input depth for filter ${n.shape[3]}.`),I(c===n.shape[4],()=>`Error in conv3dDerInput: depth of output (${c}) must match output depth for filter ${n.shape[4]}.`);const u={dy:i,filter:n},h={pad:r,strides:s,inputShape:o},d=_.runKernel(ey,u,h);return a?F(d,[d.shape[1],d.shape[2],d.shape[3],d.shape[4]]):d}const Z$=z({conv3DBackpropInput_:u4});function h4(t,e,n,s,r){const o=T(t,"x","conv3dTranspose"),i=T(e,"filter","conv3dTranspose");return Z$(n,o,i,s,r)}const d4=z({conv3dTranspose_:h4});/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -1218,7 +1218,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function p4(t){const n={x:T(t,"x","cos","float32")};return _.runKernel(Su,n)}const Ly=z({cos_:p4});/** + */function f4(t){const n={x:T(t,"x","cos","float32")};return _.runKernel(ku,n)}const Ly=z({cos_:f4});/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -1233,7 +1233,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function m4(t){const n={x:T(t,"x","cosh","float32")};return _.runKernel(Iu,n)}const J$=z({cosh_:m4});/** + */function p4(t){const n={x:T(t,"x","cosh","float32")};return _.runKernel(Su,n)}const J$=z({cosh_:p4});/** * @license * Copyright 2022 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the 'License'); @@ -1248,7 +1248,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function g4(t,e=0,n=!1,s=!1){const o={x:T(t,"x","cumprod")},i={axis:e,exclusive:n,reverse:s};return _.runKernel(ty,o,i)}const d1=z({cumprod_:g4});/** + */function m4(t,e=0,n=!1,s=!1){const o={x:T(t,"x","cumprod")},i={axis:e,exclusive:n,reverse:s};return _.runKernel(ty,o,i)}const d1=z({cumprod_:m4});/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -1263,7 +1263,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function x4(t,e=0,n=!1,s=!1){const o={x:T(t,"x","cumsum")},i={axis:e,exclusive:n,reverse:s};return _.runKernel($p,o,i)}const eN=z({cumsum_:x4});/** + */function g4(t,e=0,n=!1,s=!1){const o={x:T(t,"x","cumsum")},i={axis:e,exclusive:n,reverse:s};return _.runKernel($p,o,i)}const eN=z({cumsum_:g4});/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -1278,7 +1278,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function y4(t,e,n,s=!1){const r=T(t,"x","denseBincount"),o=T(e,"weights","denseBincount");I(r.dtype==="int32",()=>`Error in denseBincount: input dtype must be int32, but got ${r.dtype}`),I(r.rank<=2,()=>`Error in denseBincount: input must be at most rank 2, but got rank ${r.rank}.`),I(n>=0,()=>`size must be non-negative, but got ${n}.`),I(o.size===r.size||o.size===0,()=>`Error in denseBincount: weights must have the same shape as x or 0-length, but got x shape: ${r.shape}, weights shape: ${o.shape}.`);const i={x:r,weights:o},a={size:n,binaryOutput:s};return _.runKernel(sy,i,a)}const RC=z({denseBincount_:y4});/** + */function x4(t,e,n,s=!1){const r=T(t,"x","denseBincount"),o=T(e,"weights","denseBincount");I(r.dtype==="int32",()=>`Error in denseBincount: input dtype must be int32, but got ${r.dtype}`),I(r.rank<=2,()=>`Error in denseBincount: input must be at most rank 2, but got rank ${r.rank}.`),I(n>=0,()=>`size must be non-negative, but got ${n}.`),I(o.size===r.size||o.size===0,()=>`Error in denseBincount: weights must have the same shape as x or 0-length, but got x shape: ${r.shape}, weights shape: ${o.shape}.`);const i={x:r,weights:o},a={size:n,binaryOutput:s};return _.runKernel(sy,i,a)}const RC=z({denseBincount_:x4});/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -1293,11 +1293,11 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function w4(t,e,n="NHWC"){const s=T(t,"x","depthToSpace","float32"),r=n==="NHWC"?s.shape[1]:s.shape[2],o=n==="NHWC"?s.shape[2]:s.shape[3],i=n==="NHWC"?s.shape[3]:s.shape[1];I(e>1,()=>`blockSize should be > 1 for depthToSpace, but was: ${e}`),I(r*e>=0,()=>`Negative dimension size caused by overflow when multiplying + */function y4(t,e,n="NHWC"){const s=T(t,"x","depthToSpace","float32"),r=n==="NHWC"?s.shape[1]:s.shape[2],o=n==="NHWC"?s.shape[2]:s.shape[3],i=n==="NHWC"?s.shape[3]:s.shape[1];I(e>1,()=>`blockSize should be > 1 for depthToSpace, but was: ${e}`),I(r*e>=0,()=>`Negative dimension size caused by overflow when multiplying ${r} and ${e} for depthToSpace with input shape ${s.shape}`),I(o*e>=0,()=>`Negative dimension size caused by overflow when multiplying ${o} and ${e} for depthToSpace with input shape - ${s.shape}`),I(i%(e*e)===0,()=>`Dimension size must be evenly divisible by ${e*e} but is ${i} for depthToSpace with input shape ${s.shape}`);const a={x:s},l={blockSize:e,dataFormat:n};return _.runKernel(ry,a,l)}const v4=z({depthToSpace_:w4});/** + ${s.shape}`),I(i%(e*e)===0,()=>`Dimension size must be evenly divisible by ${e*e} but is ${i} for depthToSpace with input shape ${s.shape}`);const a={x:s},l={blockSize:e,dataFormat:n};return _.runKernel(ry,a,l)}const w4=z({depthToSpace_:y4});/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -1312,7 +1312,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function b4(t,e,n,s,r="NHWC",o=[1,1],i){const a=T(t,"x","depthwiseConv2d","float32"),l=T(e,"filter","depthwiseConv2d","float32");let c=a,u=!1;a.rank===3&&(u=!0,c=F(a,[1,a.shape[0],a.shape[1],a.shape[2]])),I(c.rank===4,()=>`Error in depthwiseConv2d: input must be rank 4, but got rank ${c.rank}.`),I(l.rank===4,()=>`Error in depthwiseConv2d: filter must be rank 4, but got rank ${l.rank}.`);const h=r==="NHWC"?c.shape[3]:c.shape[1];I(h===l.shape[2],()=>`Error in depthwiseConv2d: number of input channels (${h}) must match the inChannels dimension in filter ${l.shape[2]}.`),Mn("depthwiseConv2d",s,i);const d={x:c,filter:l},f={strides:n,pad:s,dataFormat:r,dilations:o,dimRoundingMode:i},p=_.runKernel(Np,d,f);return u?F(p,[p.shape[1],p.shape[2],p.shape[3]]):p}const By=z({depthwiseConv2d_:b4});/** + */function v4(t,e,n,s,r="NHWC",o=[1,1],i){const a=T(t,"x","depthwiseConv2d","float32"),l=T(e,"filter","depthwiseConv2d","float32");let c=a,u=!1;a.rank===3&&(u=!0,c=F(a,[1,a.shape[0],a.shape[1],a.shape[2]])),I(c.rank===4,()=>`Error in depthwiseConv2d: input must be rank 4, but got rank ${c.rank}.`),I(l.rank===4,()=>`Error in depthwiseConv2d: filter must be rank 4, but got rank ${l.rank}.`);const h=r==="NHWC"?c.shape[3]:c.shape[1];I(h===l.shape[2],()=>`Error in depthwiseConv2d: number of input channels (${h}) must match the inChannels dimension in filter ${l.shape[2]}.`),Mn("depthwiseConv2d",s,i);const d={x:c,filter:l},f={strides:n,pad:s,dataFormat:r,dilations:o,dimRoundingMode:i},p=_.runKernel(Np,d,f);return u?F(p,[p.shape[1],p.shape[2],p.shape[3]]):p}const By=z({depthwiseConv2d_:v4});/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -1327,7 +1327,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function C4(t,e,n,s,r=[1,1],o="NHWC"){const i=T(t,"x","dilation2d"),a=T(e,"filter","dilation2d");I(i.rank===3||i.rank===4,()=>`Error in dilation2d: input must be rank 3 or 4, but got rank ${i.rank}.`),I(a.rank===3,()=>`Error in dilation2d: filter must be rank 3, but got rank ${a.rank}.`),I(o==="NHWC",()=>`Error in dilation2d: Only NHWC is currently supported, but got dataFormat of ${o}`);let l=i,c=!1;i.rank===3&&(l=F(i,[1,i.shape[0],i.shape[1],i.shape[2]]),c=!0),I(l.shape[3]===a.shape[2],()=>`Error in dilation2d: input and filter must have the same depth: ${l.shape[3]} vs ${a.shape[2]}`);const u={x:l,filter:a},h={strides:n,pad:s,dilations:r},d=_.runKernel(Tp,u,h);return c?F(d,[d.shape[1],d.shape[2],d.shape[3]]):d}const k4=z({dilation2d_:C4});/** + */function b4(t,e,n,s,r=[1,1],o="NHWC"){const i=T(t,"x","dilation2d"),a=T(e,"filter","dilation2d");I(i.rank===3||i.rank===4,()=>`Error in dilation2d: input must be rank 3 or 4, but got rank ${i.rank}.`),I(a.rank===3,()=>`Error in dilation2d: filter must be rank 3, but got rank ${a.rank}.`),I(o==="NHWC",()=>`Error in dilation2d: Only NHWC is currently supported, but got dataFormat of ${o}`);let l=i,c=!1;i.rank===3&&(l=F(i,[1,i.shape[0],i.shape[1],i.shape[2]]),c=!0),I(l.shape[3]===a.shape[2],()=>`Error in dilation2d: input and filter must have the same depth: ${l.shape[3]} vs ${a.shape[2]}`);const u={x:l,filter:a},h={strides:n,pad:s,dilations:r},d=_.runKernel(Tp,u,h);return c?F(d,[d.shape[1],d.shape[2],d.shape[3]]):d}const C4=z({dilation2d_:b4});/** * @license * Copyright 2017 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -1357,7 +1357,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function S4(t,e){let n=T(t,"a","equal","string_or_numeric"),s=T(e,"b","equal","string_or_numeric");[n,s]=It(n,s),Se(n.shape,s.shape);const r={a:n,b:s};return _.runKernel(Ep,r)}const kr=z({equal_:S4});/** + */function k4(t,e){let n=T(t,"a","equal","string_or_numeric"),s=T(e,"b","equal","string_or_numeric");[n,s]=It(n,s),Se(n.shape,s.shape);const r={a:n,b:s};return _.runKernel(Ep,r)}const kr=z({equal_:k4});/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -1372,7 +1372,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function I4(t,e,n){const s=T(e,"a","where"),r=T(n,"b","where"),o=T(t,"condition","where","bool"),i=Se(Se(o.shape,s.shape),r.shape),a=Cc(o,i),l=Cc(s,i),c=Cc(r,i),u={condition:a,t:l,e:c};return _.runKernel(om,u)}const Cn=z({where_:I4});/** + */function S4(t,e,n){const s=T(e,"a","where"),r=T(n,"b","where"),o=T(t,"condition","where","bool"),i=Se(Se(o.shape,s.shape),r.shape),a=Cc(o,i),l=Cc(s,i),c=Cc(r,i),u={condition:a,t:l,e:c};return _.runKernel(om,u)}const Cn=z({where_:S4});/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -1387,7 +1387,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function $4(t){const n={x:T(t,"x","zerosLike")};return _.runKernel(fm,n)}const ze=z({zerosLike_:$4});/** + */function I4(t){const n={x:T(t,"x","zerosLike")};return _.runKernel(fm,n)}const ze=z({zerosLike_:I4});/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -1402,7 +1402,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function N4(t,e){let n=T(t,"a","div"),s=T(e,"b","div");[n,s]=It(n,s);const r=ge(n,s),o=ze(r),i=kr(s,o);return Cn(i,o,r)}const T4=z({divNoNan_:N4});/** + */function $4(t,e){let n=T(t,"a","div"),s=T(e,"b","div");[n,s]=It(n,s);const r=ge(n,s),o=ze(r),i=kr(s,o);return Cn(i,o,r)}const N4=z({divNoNan_:$4});/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -1417,7 +1417,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function E4(t,e){const n=T(t,"t1","dot"),s=T(e,"t2","dot");I((n.rank===1||n.rank===2)&&(s.rank===1||s.rank===2),()=>`Error in dot: inputs must all be rank 1 or 2, but got ranks ${n.rank} and ${s.rank}.`);const r=n.rank===1?n.size:n.shape[1],o=s.rank===1?s.size:s.shape[0];if(I(r===o,()=>`Error in dot: inner dimensions of inputs must match, but got ${r} and ${o}.`),n.rank===1&&s.rank===1){const i=F(n,[1,-1]),a=F(s,[-1,1]),l=Ve(i,a);return F(l,[])}else if(n.rank===1&&s.rank===2){const i=F(n,[1,-1]),a=F(s,[s.shape[0],s.shape[1]]),l=Ve(i,a);return F(l,[l.size])}else if(n.rank===2&&s.rank===1){const i=F(s,[-1,1]),a=Ve(n,i);return F(a,[a.size])}else{const i=F(s,[s.shape[0],s.shape[1]]);return Ve(n,i)}}const R4=z({dot_:E4});/** + */function T4(t,e){const n=T(t,"t1","dot"),s=T(e,"t2","dot");I((n.rank===1||n.rank===2)&&(s.rank===1||s.rank===2),()=>`Error in dot: inputs must all be rank 1 or 2, but got ranks ${n.rank} and ${s.rank}.`);const r=n.rank===1?n.size:n.shape[1],o=s.rank===1?s.size:s.shape[0];if(I(r===o,()=>`Error in dot: inner dimensions of inputs must match, but got ${r} and ${o}.`),n.rank===1&&s.rank===1){const i=F(n,[1,-1]),a=F(s,[-1,1]),l=Ve(i,a);return F(l,[])}else if(n.rank===1&&s.rank===2){const i=F(n,[1,-1]),a=F(s,[s.shape[0],s.shape[1]]),l=Ve(i,a);return F(l,[l.size])}else if(n.rank===2&&s.rank===1){const i=F(s,[-1,1]),a=Ve(n,i);return F(a,[a.size])}else{const i=F(s,[s.shape[0],s.shape[1]]);return Ve(n,i)}}const E4=z({dot_:T4});/** * @license * Copyright 2021 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -1432,7 +1432,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function A4(t,...e){const n=e.map((r,o)=>T(r,`tensors${o}`,"einsum")),s={equation:t};return _.runKernel(ay,n,s)}const Hl=z({einsum_:A4});/** + */function R4(t,...e){const n=e.map((r,o)=>T(r,`tensors${o}`,"einsum")),s={equation:t};return _.runKernel(ay,n,s)}const Hl=z({einsum_:R4});/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -1447,7 +1447,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function D4(t){const n={x:T(t,"x","elu","float32")};return _.runKernel(Nu,n)}const ym=z({elu_:D4});/** + */function A4(t){const n={x:T(t,"x","elu","float32")};return _.runKernel($u,n)}const ym=z({elu_:A4});/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -1462,7 +1462,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function _4(t){let e=T(t,"x","erf");I(e.dtype==="int32"||e.dtype==="float32",()=>"Input dtype must be `int32` or `float32`."),e.dtype==="int32"&&(e=le(e,"float32"));const n={x:e};return _.runKernel(Tu,n)}const tN=z({erf_:_4});/** + */function D4(t){let e=T(t,"x","erf");I(e.dtype==="int32"||e.dtype==="float32",()=>"Input dtype must be `int32` or `float32`."),e.dtype==="int32"&&(e=le(e,"float32"));const n={x:e};return _.runKernel(Nu,n)}const tN=z({erf_:D4});/** * @license * Copyright 2017 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -1492,7 +1492,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function F4(t,e=null,n=!1){const r={x:T(t,"x","max")},o={reductionIndices:e,keepDims:n};return _.runKernel(Vp,r,o)}const Ys=z({max_:F4});/** + */function _4(t,e=null,n=!1){const r={x:T(t,"x","max")},o={reductionIndices:e,keepDims:n};return _.runKernel(Vp,r,o)}const Ys=z({max_:_4});/** * @license * Copyright 2020 Google Inc. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -1507,7 +1507,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function z4(t,e=null,n=!1){const r={x:T(t,"x","min")},o={axis:e,keepDims:n};return _.runKernel(Hp,r,o)}const wf=z({min_:z4});/** + */function F4(t,e=null,n=!1){const r={x:T(t,"x","min")},o={axis:e,keepDims:n};return _.runKernel(Hp,r,o)}const yf=z({min_:F4});/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -1522,7 +1522,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function O4(t,e){let n=T(t,"base","pow"),s=T(e,"exp","pow");[n,s]=It(n,s);const r={a:n,b:s};return _.runKernel(Gu,r)}const Oi=z({pow_:O4});/** + */function z4(t,e){let n=T(t,"base","pow"),s=T(e,"exp","pow");[n,s]=It(n,s);const r={a:n,b:s};return _.runKernel(Uu,r)}const Oi=z({pow_:z4});/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -1537,7 +1537,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function We(t,e){if((Es(t)&&e!=="string"||Array.isArray(t))&&e!=="complex64")throw new Error("Error creating a new Scalar: value must be a primitive (number|boolean|string)");if(e==="string"&&Es(t)&&!(t instanceof Uint8Array))throw new Error("When making a scalar from encoded string, the value must be `Uint8Array`.");return uh(t,[],[],e)}/** + */function We(t,e){if((Es(t)&&e!=="string"||Array.isArray(t))&&e!=="complex64")throw new Error("Error creating a new Scalar: value must be a primitive (number|boolean|string)");if(e==="string"&&Es(t)&&!(t instanceof Uint8Array))throw new Error("When making a scalar from encoded string, the value must be `Uint8Array`.");return ch(t,[],[],e)}/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -1552,7 +1552,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function M4(t){const n={x:T(t,"x","sqrt","float32")};return _.runKernel(nh,n)}const hn=z({sqrt_:M4});/** + */function O4(t){const n={x:T(t,"x","sqrt","float32")};return _.runKernel(th,n)}const hn=z({sqrt_:O4});/** * @license * Copyright 2019 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -1567,7 +1567,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function P4(t){const e=T(t,"x","square"),n={};return _.runKernel("Square",{x:e},n)}const ot=z({square_:P4});/** + */function M4(t){const e=T(t,"x","square"),n={};return _.runKernel("Square",{x:e},n)}const ot=z({square_:M4});/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -1582,7 +1582,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function L4(t,e=null,n=!1){let s=T(t,"x","sum");s.dtype==="bool"&&(s=le(s,"int32"));const r={x:s},o={axis:e,keepDims:n};return _.runKernel(am,r,o)}const me=z({sum_:L4});/** + */function P4(t,e=null,n=!1){let s=T(t,"x","sum");s.dtype==="bool"&&(s=le(s,"int32"));const r={x:s},o={axis:e,keepDims:n};return _.runKernel(am,r,o)}const me=z({sum_:P4});/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -1597,7 +1597,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function B4(t,e="euclidean",n=null,s=!1){t=T(t,"x","norm");const r=sN(t,e,n);let o=r.shape;if(s){const i=Re(n,t.shape);o=Dt(r.shape,i)}return F(r,o)}function sN(t,e,n=null){if(t.rank===0)return xn(t);if(t.rank!==1&&n===null)return sN(F(t,[-1]),e,n);if(t.rank===1||typeof n=="number"||Array.isArray(n)&&n.length===1){if(e===1)return me(xn(t),n);if(e===1/0)return Ys(xn(t),n);if(e===-1/0)return wf(xn(t),n);if(e==="euclidean"||e===2)return hn(me(Oi(xn(t),We(2,"int32")),n));throw new Error(`Error in norm: invalid ord value: ${e}`)}if(Array.isArray(n)&&n.length===2){if(e===1)return Ys(me(xn(t),n[0]),n[1]-1);if(e===1/0)return Ys(me(xn(t),n[1]),n[0]);if(e===-1/0)return wf(me(xn(t),n[1]),n[0]);if(e==="fro"||e==="euclidean")return hn(me(ot(t),n));throw new Error(`Error in norm: invalid ord value: ${e}`)}throw new Error(`Error in norm: invalid axis: ${n}`)}const wm=z({norm_:B4});/** + */function L4(t,e="euclidean",n=null,s=!1){t=T(t,"x","norm");const r=sN(t,e,n);let o=r.shape;if(s){const i=Re(n,t.shape);o=Dt(r.shape,i)}return F(r,o)}function sN(t,e,n=null){if(t.rank===0)return xn(t);if(t.rank!==1&&n===null)return sN(F(t,[-1]),e,n);if(t.rank===1||typeof n=="number"||Array.isArray(n)&&n.length===1){if(e===1)return me(xn(t),n);if(e===1/0)return Ys(xn(t),n);if(e===-1/0)return yf(xn(t),n);if(e==="euclidean"||e===2)return hn(me(Oi(xn(t),We(2,"int32")),n));throw new Error(`Error in norm: invalid ord value: ${e}`)}if(Array.isArray(n)&&n.length===2){if(e===1)return Ys(me(xn(t),n[0]),n[1]-1);if(e===1/0)return Ys(me(xn(t),n[1]),n[0]);if(e===-1/0)return yf(me(xn(t),n[1]),n[0]);if(e==="fro"||e==="euclidean")return hn(me(ot(t),n));throw new Error(`Error in norm: invalid ord value: ${e}`)}throw new Error(`Error in norm: invalid axis: ${n}`)}const wm=z({norm_:L4});/** * @license * Copyright 2022 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -1612,7 +1612,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function V4(t,e=null,n=!1){return wm(t,"euclidean",e,n)}const W4=z({euclideanNorm_:V4});/** + */function B4(t,e=null,n=!1){return wm(t,"euclidean",e,n)}const V4=z({euclideanNorm_:B4});/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -1627,7 +1627,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function U4(t){const n={x:T(t,"x","exp")};return _.runKernel(Eu,n)}const Sr=z({exp_:U4});/** + */function W4(t){const n={x:T(t,"x","exp")};return _.runKernel(Tu,n)}const Sr=z({exp_:W4});/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -1642,7 +1642,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function G4(t,e=0){const n=T(t,"x","expandDims","string_or_numeric");I(e<=n.rank,()=>"Axis must be <= rank of the tensor");const s={input:n},r={dim:e};return _.runKernel(Rp,s,r)}const En=z({expandDims_:G4});/** + */function U4(t,e=0){const n=T(t,"x","expandDims","string_or_numeric");I(e<=n.rank,()=>"Axis must be <= rank of the tensor");const s={input:n},r={dim:e};return _.runKernel(Rp,s,r)}const En=z({expandDims_:U4});/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -1657,7 +1657,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function H4(t){const n={x:T(t,"x","expm1")};return _.runKernel(Ru,n)}const j4=z({expm1_:H4});/** + */function G4(t){const n={x:T(t,"x","expm1")};return _.runKernel(Eu,n)}const H4=z({expm1_:G4});/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -1672,7 +1672,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function K4(t,e){const n=T(t,"x","tile","string_or_numeric");I(n.rank===e.length,()=>`Error in transpose: rank of input ${n.rank} must match length of reps ${e}.`);const s={x:n},r={reps:e};return _.runKernel(ah,s,r)}const Hs=z({tile_:K4});/** + */function j4(t,e){const n=T(t,"x","tile","string_or_numeric");I(n.rank===e.length,()=>`Error in transpose: rank of input ${n.rank} must match length of reps ${e}.`);const s={x:n},r={reps:e};return _.runKernel(ih,s,r)}const Hs=z({tile_:j4});/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -1687,7 +1687,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function X4(t,e,n,s="float32"){e==null&&(e=t);const r=Ee([t,e],s),o=t<=e?t:e;for(let a=0;a`Error in localResponseNormalization: x must be rank 3 or 4 but got - rank ${o.rank}.`),I(nl(e),()=>`Error in localResponseNormalization: depthRadius must be an integer but got depthRadius ${e}.`);let i=o,a=!1;o.rank===3&&(a=!0,i=F(o,[1,o.shape[0],o.shape[1],o.shape[2]]));const l={x:i},c={depthRadius:e,bias:n,alpha:s,beta:r},u=_.runKernel(Bp,l,c);return a?F(u,[u.shape[1],u.shape[2],u.shape[3]]):u}const uB=z({localResponseNormalization_:cB});/** + */function lB(t,e=5,n=1,s=1,r=.5){const o=T(t,"x","localResponseNormalization");I(o.rank===4||o.rank===3,()=>`Error in localResponseNormalization: x must be rank 3 or 4 but got + rank ${o.rank}.`),I(nl(e),()=>`Error in localResponseNormalization: depthRadius must be an integer but got depthRadius ${e}.`);let i=o,a=!1;o.rank===3&&(a=!0,i=F(o,[1,o.shape[0],o.shape[1],o.shape[2]]));const l={x:i},c={depthRadius:e,bias:n,alpha:s,beta:r},u=_.runKernel(Bp,l,c);return a?F(u,[u.shape[1],u.shape[2],u.shape[3]]):u}const cB=z({localResponseNormalization_:lB});/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -1883,7 +1883,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function hB(t){const n={x:T(t,"x","log","float32")};return _.runKernel(Pu,n)}const Ir=z({log_:hB});/** + */function uB(t){const n={x:T(t,"x","log","float32")};return _.runKernel(Mu,n)}const Ir=z({log_:uB});/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -1898,7 +1898,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function dB(t){const n={x:T(t,"x","log1p")};return _.runKernel(Lu,n)}const oN=z({log1p_:dB});/** + */function hB(t){const n={x:T(t,"x","log1p")};return _.runKernel(Pu,n)}const oN=z({log1p_:hB});/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -1913,7 +1913,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function fB(t,e){I(Y0(t),()=>"The f passed in variableGrads(f) must be a function"),I(e==null||Array.isArray(e)&&e.every(c=>c instanceof xf),()=>"The varList passed in variableGrads(f, varList) must be an array of variables");const n=e!=null;if(!n){e=[];for(const c in _.registeredVariables)e.push(_.registeredVariables[c])}const s=n?e.filter(c=>!c.trainable):null,r=e.length;e=e.filter(c=>c.trainable),I(e.length>0,()=>`variableGrads() expects at least one of the input variables to be trainable, but none of the ${r} variables is trainable.`);const o=!0,{value:i,grads:a}=_.gradients(t,e,null,o);I(a.some(c=>c!=null),()=>"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()."),I(i.rank===0,()=>`The f passed in variableGrads(f) must return a scalar, but it returned a rank-${i.rank} tensor`);const l={};return e.forEach((c,u)=>{a[u]!=null&&(l[c.name]=a[u])}),s!=null&&s.forEach(c=>l[c.name]=null),{value:i,grads:l}}function al(t){return _.customGrad(t)}/** + */function dB(t,e){I(Y0(t),()=>"The f passed in variableGrads(f) must be a function"),I(e==null||Array.isArray(e)&&e.every(c=>c instanceof gf),()=>"The varList passed in variableGrads(f, varList) must be an array of variables");const n=e!=null;if(!n){e=[];for(const c in _.registeredVariables)e.push(_.registeredVariables[c])}const s=n?e.filter(c=>!c.trainable):null,r=e.length;e=e.filter(c=>c.trainable),I(e.length>0,()=>`variableGrads() expects at least one of the input variables to be trainable, but none of the ${r} variables is trainable.`);const o=!0,{value:i,grads:a}=_.gradients(t,e,null,o);I(a.some(c=>c!=null),()=>"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()."),I(i.rank===0,()=>`The f passed in variableGrads(f) must return a scalar, but it returned a rank-${i.rank} tensor`);const l={};return e.forEach((c,u)=>{a[u]!=null&&(l[c.name]=a[u])}),s!=null&&s.forEach(c=>l[c.name]=null),{value:i,grads:l}}function al(t){return _.customGrad(t)}/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -1928,7 +1928,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function pB(t){const n={x:T(t,"x","neg")};return _.runKernel(Kp,n)}const St=z({neg_:pB});/** + */function fB(t){const n={x:T(t,"x","neg")};return _.runKernel(Kp,n)}const St=z({neg_:fB});/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -1943,7 +1943,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function mB(t){const n={x:T(t,"x","softplus")};return _.runKernel(th,n)}const dh=z({softplus_:mB});/** + */function pB(t){const n={x:T(t,"x","softplus")};return _.runKernel(eh,n)}const hh=z({softplus_:pB});/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -1958,7 +1958,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function gB(t){const e=T(t,"x","logSigmoid");return al(s=>({value:St(dh(St(s))),gradFunc:i=>D(i,Cl(St(s)))}))(e)}const xB=z({logSigmoid_:gB});/** + */function mB(t){const e=T(t,"x","logSigmoid");return al(s=>({value:St(hh(St(s))),gradFunc:i=>D(i,Cl(St(s)))}))(e)}const gB=z({logSigmoid_:mB});/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -1973,7 +1973,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function yB(t,e){let n=T(t,"a","sub"),s=T(e,"b","sub");[n,s]=It(n,s);const r={a:n,b:s};return _.runKernel(rh,r)}const ve=z({sub_:yB});/** + */function xB(t,e){let n=T(t,"a","sub"),s=T(e,"b","sub");[n,s]=It(n,s);const r={a:n,b:s};return _.runKernel(sh,r)}const ve=z({sub_:xB});/** * @license * Copyright 2020 Google Inc. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -1988,7 +1988,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function wB(t,e=-1){const n=T(t,"logits","logSoftmax");if(e===-1&&(e=n.rank-1),e!==n.rank-1)throw Error(`Log Softmax along a non-last dimension is not yet supported. Logits was rank ${n.rank} and axis was ${e}`);return al((r,o)=>{const a=Ys(r,e,!0),l=ve(r,a),c=ve(le(l,"float32"),Ir(me(Sr(l),e,!0)));return o([c]),{value:c,gradFunc:(h,d)=>{const[f]=d,p=!0,g=Sr(f);return ve(h,D(me(h,e,p),g))}}})(n)}const iN=z({logSoftmax_:wB});/** + */function yB(t,e=-1){const n=T(t,"logits","logSoftmax");if(e===-1&&(e=n.rank-1),e!==n.rank-1)throw Error(`Log Softmax along a non-last dimension is not yet supported. Logits was rank ${n.rank} and axis was ${e}`);return al((r,o)=>{const a=Ys(r,e,!0),l=ve(r,a),c=ve(le(l,"float32"),Ir(me(Sr(l),e,!0)));return o([c]),{value:c,gradFunc:(h,d)=>{const[f]=d,p=!0,g=Sr(f);return ve(h,D(me(h,e,p),g))}}})(n)}const iN=z({logSoftmax_:yB});/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -2003,7 +2003,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function vB(t,e=null,n=!1){const s=T(t,"x","logSumExp"),r=Re(e,s.shape),o=Ys(s,r,!0),i=ve(s,o),a=Sr(i),l=me(a,r),c=Ir(l),u=J(F(o,c.shape),c);if(n){const h=Dt(u.shape,r);return F(u,h)}return u}const aN=z({logSumExp_:vB});/** + */function wB(t,e=null,n=!1){const s=T(t,"x","logSumExp"),r=Re(e,s.shape),o=Ys(s,r,!0),i=ve(s,o),a=Sr(i),l=me(a,r),c=Ir(l),u=J(F(o,c.shape),c);if(n){const h=Dt(u.shape,r);return F(u,h)}return u}const aN=z({logSumExp_:wB});/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -2018,7 +2018,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function bB(t,e){const n=T(t,"a","logicalAnd","bool"),s=T(e,"b","logicalAnd","bool");Se(n.shape,s.shape);const r={a:n,b:s};return _.runKernel(Mp,r)}const Gr=z({logicalAnd_:bB});/** + */function vB(t,e){const n=T(t,"a","logicalAnd","bool"),s=T(e,"b","logicalAnd","bool");Se(n.shape,s.shape);const r={a:n,b:s};return _.runKernel(Mp,r)}const Gr=z({logicalAnd_:vB});/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -2033,7 +2033,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function CB(t){const n={x:T(t,"x","logicalNot","bool")};return _.runKernel(Pp,n)}const Hy=z({logicalNot_:CB});/** + */function bB(t){const n={x:T(t,"x","logicalNot","bool")};return _.runKernel(Pp,n)}const Hy=z({logicalNot_:bB});/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -2048,7 +2048,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function kB(t,e){const n=T(t,"a","logicalOr","bool"),s=T(e,"b","logicalOr","bool");Se(n.shape,s.shape);const r={a:n,b:s};return _.runKernel(Lp,r)}const lN=z({logicalOr_:kB});/** + */function CB(t,e){const n=T(t,"a","logicalOr","bool"),s=T(e,"b","logicalOr","bool");Se(n.shape,s.shape);const r={a:n,b:s};return _.runKernel(Lp,r)}const lN=z({logicalOr_:CB});/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -2063,7 +2063,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function SB(t,e){const n=T(t,"a","logicalXor","bool"),s=T(e,"b","logicalXor","bool");return Se(n.shape,s.shape),Gr(lN(t,e),Hy(Gr(t,e)))}const IB=z({logicalXor_:SB});/** + */function kB(t,e){const n=T(t,"a","logicalXor","bool"),s=T(e,"b","logicalXor","bool");return Se(n.shape,s.shape),Gr(lN(t,e),Hy(Gr(t,e)))}const SB=z({logicalXor_:kB});/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -2078,7 +2078,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function $B(t,e,n,s,r){const o=T(t,"x","maxPool"),i=1;let a=o,l=!1;o.rank===3&&(l=!0,a=F(o,[1,o.shape[0],o.shape[1],o.shape[2]])),I(a.rank===4,()=>`Error in maxPool: input must be rank 4 but got rank ${a.rank}.`),I(dn(n,i),()=>`Error in maxPool: Either strides or dilations must be 1. Got strides ${n} and dilations '${i}'`),Mn("maxPool",s,r);const c={x:a},u={filterSize:e,strides:n,pad:s,dimRoundingMode:r},h=_.runKernel(Wp,c,u);return l?F(h,[h.shape[1],h.shape[2],h.shape[3]]):h}const jy=z({maxPool_:$B});/** + */function IB(t,e,n,s,r){const o=T(t,"x","maxPool"),i=1;let a=o,l=!1;o.rank===3&&(l=!0,a=F(o,[1,o.shape[0],o.shape[1],o.shape[2]])),I(a.rank===4,()=>`Error in maxPool: input must be rank 4 but got rank ${a.rank}.`),I(dn(n,i),()=>`Error in maxPool: Either strides or dilations must be 1. Got strides ${n} and dilations '${i}'`),Mn("maxPool",s,r);const c={x:a},u={filterSize:e,strides:n,pad:s,dimRoundingMode:r},h=_.runKernel(Wp,c,u);return l?F(h,[h.shape[1],h.shape[2],h.shape[3]]):h}const jy=z({maxPool_:IB});/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -2093,7 +2093,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function NB(t,e=[1,1,1],n,s,r,o="NDHWC"){const i=T(t,"x","maxPool3d");let a=i,l=!1;i.rank===4&&(l=!0,a=F(i,[1,i.shape[0],i.shape[1],i.shape[2],i.shape[3]])),I(a.rank===5,()=>`Error in maxPool3d: x must be rank 5 but got rank ${a.rank}.`),I(o==="NDHWC",()=>`Error in maxPool3d: Only NDHWC is currently supported, but got dataFormat of ${o}`),Mn("maxPool3d",s,r);const c={x:a},u={filterSize:e,strides:n,pad:s,dimRoundingMode:r,dataFormat:o},h=_.runKernel(Up,c,u);return l?F(h,[h.shape[1],h.shape[2],h.shape[3],h.shape[4]]):h}const TB=z({maxPool3d_:NB});/** + */function $B(t,e=[1,1,1],n,s,r,o="NDHWC"){const i=T(t,"x","maxPool3d");let a=i,l=!1;i.rank===4&&(l=!0,a=F(i,[1,i.shape[0],i.shape[1],i.shape[2],i.shape[3]])),I(a.rank===5,()=>`Error in maxPool3d: x must be rank 5 but got rank ${a.rank}.`),I(o==="NDHWC",()=>`Error in maxPool3d: Only NDHWC is currently supported, but got dataFormat of ${o}`),Mn("maxPool3d",s,r);const c={x:a},u={filterSize:e,strides:n,pad:s,dimRoundingMode:r,dataFormat:o},h=_.runKernel(Up,c,u);return l?F(h,[h.shape[1],h.shape[2],h.shape[3],h.shape[4]]):h}const NB=z({maxPool3d_:$B});/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -2108,7 +2108,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function EB(t,e){let n=T(t,"a","maximum"),s=T(e,"b","maximum");[n,s]=It(n,s),n.dtype==="bool"&&(n=le(n,"int32"),s=le(s,"int32")),Se(n.shape,s.shape);const r={a:n,b:s};return _.runKernel(Bu,r)}const jo=z({maximum_:EB});/** + */function TB(t,e){let n=T(t,"a","maximum"),s=T(e,"b","maximum");[n,s]=It(n,s),n.dtype==="bool"&&(n=le(n,"int32"),s=le(s,"int32")),Se(n.shape,s.shape);const r={a:n,b:s};return _.runKernel(Lu,r)}const jo=z({maximum_:TB});/** * @license * Copyright 2020 Google Inc. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -2123,7 +2123,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function RB(t,e=null,n=!1){const r={x:T(t,"x","mean")},o={axis:e,keepDims:n};return _.runKernel(Gp,r,o)}const Rt=z({mean_:RB});/** + */function EB(t,e=null,n=!1){const r={x:T(t,"x","mean")},o={axis:e,keepDims:n};return _.runKernel(Gp,r,o)}const Rt=z({mean_:EB});/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -2168,7 +2168,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function AB(t,e){let n=T(t,"a","minimum"),s=T(e,"b","minimum");[n,s]=It(n,s),n.dtype==="bool"&&(n=le(n,"int32"),s=le(s,"int32")),Se(n.shape,s.shape);const r={a:n,b:s};return _.runKernel(Vu,r)}const Xc=z({minimum_:AB});/** + */function RB(t,e){let n=T(t,"a","minimum"),s=T(e,"b","minimum");[n,s]=It(n,s),n.dtype==="bool"&&(n=le(n,"int32"),s=le(s,"int32")),Se(n.shape,s.shape);const r={a:n,b:s};return _.runKernel(Bu,r)}const Xc=z({minimum_:RB});/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -2183,7 +2183,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function DB(t,e,n){I(n==="reflect"||n==="symmetric",()=>`Invalid mode. Mode must be either reflect or symmetric. Got ${n}.`);const s=T(t,"x","mirrorPad");if(s.rank===0)throw new Error("mirrorPad(scalar) is not defined. Pass non-scalar to mirrorPad");I(e.length===s.rank,()=>`Padding doesn't match input. Must be ${s.rank}. Got ${e.length}.`);const r=n==="reflect"?1:0;for(let a=0;a"Invalid number of paddings. Must be length of 2 each."),I(e[a][0]>=0&&e[a][0]<=s.shape[a]-r&&e[a][1]>=0&&e[a][1]<=s.shape[a]-r,()=>`Padding in dimension ${a} cannot be greater than or equal to ${s.shape[a]-r} or less than 0 for input of shape ${s.shape}`);const o={paddings:e,mode:n},i={x:s};return _.runKernel(jp,i,o)}const _B=z({mirrorPad_:DB});/** + */function AB(t,e,n){I(n==="reflect"||n==="symmetric",()=>`Invalid mode. Mode must be either reflect or symmetric. Got ${n}.`);const s=T(t,"x","mirrorPad");if(s.rank===0)throw new Error("mirrorPad(scalar) is not defined. Pass non-scalar to mirrorPad");I(e.length===s.rank,()=>`Padding doesn't match input. Must be ${s.rank}. Got ${e.length}.`);const r=n==="reflect"?1:0;for(let a=0;a"Invalid number of paddings. Must be length of 2 each."),I(e[a][0]>=0&&e[a][0]<=s.shape[a]-r&&e[a][1]>=0&&e[a][1]<=s.shape[a]-r,()=>`Padding in dimension ${a} cannot be greater than or equal to ${s.shape[a]-r} or less than 0 for input of shape ${s.shape}`);const o={paddings:e,mode:n},i={x:s};return _.runKernel(jp,i,o)}const DB=z({mirrorPad_:AB});/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -2198,7 +2198,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function FB(t,e){let n=T(t,"a","mod"),s=T(e,"b","mod");[n,s]=It(n,s);const r={a:n,b:s};return _.runKernel(Wu,r)}const zB=z({mod_:FB});/** + */function _B(t,e){let n=T(t,"a","mod"),s=T(e,"b","mod");[n,s]=It(n,s);const r={a:n,b:s};return _.runKernel(Vu,r)}const FB=z({mod_:_B});/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -2213,7 +2213,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function OB(t,e=null,n=!1){t=T(t,"x","moments");const s=Re(e,t.shape),r=Rt(t,s,n);let o=r.shape;n||(o=Dt(r.shape,s));const i=ot(ve(le(t,"float32"),F(r,o))),a=Rt(i,s,n);return{mean:r,variance:a}}const Ky=z({moments_:OB});/** + */function zB(t,e=null,n=!1){t=T(t,"x","moments");const s=Re(e,t.shape),r=Rt(t,s,n);let o=r.shape;n||(o=Dt(r.shape,s));const i=ot(ve(le(t,"float32"),F(r,o))),a=Rt(i,s,n);return{mean:r,variance:a}}const Ky=z({moments_:zB});/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -2228,7 +2228,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function MB(t,e){let n=T(t,"a","notEqual","string_or_numeric"),s=T(e,"b","notEqual","string_or_numeric");[n,s]=It(n,s),Se(n.shape,s.shape);const r={a:n,b:s};return _.runKernel(Xp,r)}const bf=z({notEqual_:MB});/** + */function OB(t,e){let n=T(t,"a","notEqual","string_or_numeric"),s=T(e,"b","notEqual","string_or_numeric");[n,s]=It(n,s),Se(n.shape,s.shape);const r={a:n,b:s};return _.runKernel(Xp,r)}const vf=z({notEqual_:OB});/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -2243,7 +2243,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function PB(t,e,n=1,s=0,r="int32"){if(e<2)throw new Error(`Error in oneHot: depth must be >=2, but it is ${e}`);const i={indices:T(t,"indices","oneHot","int32")},a={dtype:r,depth:e,onValue:n,offValue:s};return _.runKernel(Yp,i,a)}const cN=z({oneHot_:PB});/** + */function MB(t,e,n=1,s=0,r="int32"){if(e<2)throw new Error(`Error in oneHot: depth must be >=2, but it is ${e}`);const i={indices:T(t,"indices","oneHot","int32")},a={dtype:r,depth:e,onValue:n,offValue:s};return _.runKernel(Yp,i,a)}const cN=z({oneHot_:MB});/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -2258,7 +2258,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function LB(t){const n={x:T(t,"x","onesLike")};return _.runKernel(qp,n)}const Rs=z({onesLike_:LB});/** + */function PB(t){const n={x:T(t,"x","onesLike")};return _.runKernel(qp,n)}const Rs=z({onesLike_:PB});/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -2273,7 +2273,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function BB(t,e,n=0){const s=T(t,"x","pad");if(s.rank===0)throw new Error("pad(scalar) is not defined. Pass non-scalar to pad");const r={paddings:e,constantValue:n},o={x:s};return _.runKernel(Zp,o,r)}const Xy=z({pad_:BB});/** + */function LB(t,e,n=0){const s=T(t,"x","pad");if(s.rank===0)throw new Error("pad(scalar) is not defined. Pass non-scalar to pad");const r={paddings:e,constantValue:n},o={x:s};return _.runKernel(Zp,o,r)}const Xy=z({pad_:LB});/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -2288,7 +2288,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function VB(t,e,n){const s=T(t,"x","spaceToBatchND");I(s.rank>=1+e.length,()=>`input rank ${s.rank} should be > than [blockShape] ${e.length}`),I(n.length===e.length,()=>`paddings.shape[0] ${n.length} must be equal to [blockShape] ${e.length}`),I(s.shape.reduce((i,a,l)=>l>0&&l<=e.length?i&&(a+n[l-1][0]+n[l-1][1])%e[l-1]===0:i,!0),()=>`input spatial dimensions ${s.shape.slice(1)} with paddings ${n.toString()} must be divisible by blockShapes ${e.toString()}`);const r={x:s},o={blockShape:e,paddings:n};return _.runKernel(lm,r,o)}const qy=z({spaceToBatchND_:VB});/** + */function BB(t,e,n){const s=T(t,"x","spaceToBatchND");I(s.rank>=1+e.length,()=>`input rank ${s.rank} should be > than [blockShape] ${e.length}`),I(n.length===e.length,()=>`paddings.shape[0] ${n.length} must be equal to [blockShape] ${e.length}`),I(s.shape.reduce((i,a,l)=>l>0&&l<=e.length?i&&(a+n[l-1][0]+n[l-1][1])%e[l-1]===0:i,!0),()=>`input spatial dimensions ${s.shape.slice(1)} with paddings ${n.toString()} must be divisible by blockShapes ${e.toString()}`);const r={x:s},o={blockShape:e,paddings:n};return _.runKernel(lm,r,o)}const qy=z({spaceToBatchND_:BB});/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -2303,7 +2303,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function WB(t,e,n,s,r,o,i){r==null&&(r=[1,1]),o==null&&(o=1),s===0&&(s="valid");const a=T(t,"x","maxPool");let l=a,c=!1;a.rank===3&&(c=!0,l=F(a,[1,a.shape[0],a.shape[1],a.shape[2]])),I(dn(o,r),()=>`Error in pool: Either strides or dilations must be 1. Got strides ${o} and dilations '${r}'`);const u=As(l.shape,e,o,r,s),h=[u.dilationHeight,u.dilationWidth];let d;s==="same"?d=GB([u.filterHeight,u.filterWidth],h):d=[[0,0],[0,0]];const f=h[0]===1&&h[1]===1,[p,g]=UB([u.inHeight,u.inWidth],h,d),x=f?s:"valid",m=f?l:qy(l,h,p),w=(n==="avg"?()=>Oy(m,e,o,x,i):()=>jy(m,e,o,x,i))(),v=f?w:My(w,h,g);return c?F(v,[v.shape[1],v.shape[2],v.shape[3]]):v}function UB(t,e,n){const s=n.map(u=>u[0]),r=n.map(u=>u[1]),o=t.concat(s,r),i=e.map((u,h)=>(u-o[h]%u)%u),a=r.map((u,h)=>u+i[h]),l=e.map((u,h)=>[s[h],a[h]]),c=e.map((u,h)=>[0,i[h]]);return[l,c]}function GB(t,e){const s=t.map((i,a)=>i+(i-1)*(e[a]-1)).map(i=>i-1),r=s.map(i=>Math.floor(i/2)),o=s.map((i,a)=>i-r[a]);return s.map((i,a)=>[r[a],o[a]])}const HB=z({pool_:WB});/** + */function VB(t,e,n,s,r,o,i){r==null&&(r=[1,1]),o==null&&(o=1),s===0&&(s="valid");const a=T(t,"x","maxPool");let l=a,c=!1;a.rank===3&&(c=!0,l=F(a,[1,a.shape[0],a.shape[1],a.shape[2]])),I(dn(o,r),()=>`Error in pool: Either strides or dilations must be 1. Got strides ${o} and dilations '${r}'`);const u=As(l.shape,e,o,r,s),h=[u.dilationHeight,u.dilationWidth];let d;s==="same"?d=UB([u.filterHeight,u.filterWidth],h):d=[[0,0],[0,0]];const f=h[0]===1&&h[1]===1,[p,g]=WB([u.inHeight,u.inWidth],h,d),x=f?s:"valid",m=f?l:qy(l,h,p),w=(n==="avg"?()=>Oy(m,e,o,x,i):()=>jy(m,e,o,x,i))(),v=f?w:My(w,h,g);return c?F(v,[v.shape[1],v.shape[2],v.shape[3]]):v}function WB(t,e,n){const s=n.map(u=>u[0]),r=n.map(u=>u[1]),o=t.concat(s,r),i=e.map((u,h)=>(u-o[h]%u)%u),a=r.map((u,h)=>u+i[h]),l=e.map((u,h)=>[s[h],a[h]]),c=e.map((u,h)=>[0,i[h]]);return[l,c]}function UB(t,e){const s=t.map((i,a)=>i+(i-1)*(e[a]-1)).map(i=>i-1),r=s.map(i=>Math.floor(i/2)),o=s.map((i,a)=>i-r[a]);return s.map((i,a)=>[r[a],o[a]])}const GB=z({pool_:VB});/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -2318,7 +2318,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function jB(t,e){const n=T(t,"x","prelu"),s=T(e,"alpha","prelu"),r={x:n,alpha:s};return _.runKernel(Jp,r)}const Yy=z({prelu_:jB});/** + */function HB(t,e){const n=T(t,"x","prelu"),s=T(e,"alpha","prelu"),r={x:n,alpha:s};return _.runKernel(Jp,r)}const Yy=z({prelu_:HB});/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -2333,7 +2333,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function KB(t,e=null,n=!1){let s=T(t,"x","prod");s.dtype==="bool"&&(s=le(s,"int32"));const r={x:s},o={axis:e,keepDims:n};return _.runKernel(em,r,o)}const XB=z({prod_:KB});var Qy={exports:{}};Qy.exports;(function(t){(function(e,n,s){function r(l){var c=this,u=a();c.next=function(){var h=2091639*c.s0+c.c*23283064365386963e-26;return c.s0=c.s1,c.s1=c.s2,c.s2=h-(c.c=h|0)},c.c=1,c.s0=u(" "),c.s1=u(" "),c.s2=u(" "),c.s0-=u(l),c.s0<0&&(c.s0+=1),c.s1-=u(l),c.s1<0&&(c.s1+=1),c.s2-=u(l),c.s2<0&&(c.s2+=1),u=null}function o(l,c){return c.c=l.c,c.s0=l.s0,c.s1=l.s1,c.s2=l.s2,c}function i(l,c){var u=new r(l),h=c&&c.state,d=u.next;return d.int32=function(){return u.next()*4294967296|0},d.double=function(){return d()+(d()*2097152|0)*11102230246251565e-32},d.quick=d,h&&(typeof h=="object"&&o(h,u),d.state=function(){return o(u,{})}),d}function a(){var l=4022871197,c=function(u){u=String(u);for(var h=0;h>>0,d-=l,d*=l,l=d>>>0,d-=l,l+=d*4294967296}return(l>>>0)*23283064365386963e-26};return c}n&&n.exports?n.exports=i:this.alea=i})(Ui,t)})(Qy);var qB=Qy.exports,Zy={exports:{}};Zy.exports;(function(t){(function(e,n,s){function r(a){var l=this,c="";l.x=0,l.y=0,l.z=0,l.w=0,l.next=function(){var h=l.x^l.x<<11;return l.x=l.y,l.y=l.z,l.z=l.w,l.w^=l.w>>>19^h^h>>>8},a===(a|0)?l.x=a:c+=a;for(var u=0;u>>0)/4294967296};return h.double=function(){do var d=c.next()>>>11,f=(c.next()>>>0)/4294967296,p=(d+f)/(1<<21);while(p===0);return p},h.int32=c.next,h.quick=h,u&&(typeof u=="object"&&o(u,c),h.state=function(){return o(c,{})}),h}n&&n.exports?n.exports=i:this.xor128=i})(Ui,t)})(Zy);var YB=Zy.exports,Jy={exports:{}};Jy.exports;(function(t){(function(e,n,s){function r(a){var l=this,c="";l.next=function(){var h=l.x^l.x>>>2;return l.x=l.y,l.y=l.z,l.z=l.w,l.w=l.v,(l.d=l.d+362437|0)+(l.v=l.v^l.v<<4^(h^h<<1))|0},l.x=0,l.y=0,l.z=0,l.w=0,l.v=0,a===(a|0)?l.x=a:c+=a;for(var u=0;u>>4),l.next()}function o(a,l){return l.x=a.x,l.y=a.y,l.z=a.z,l.w=a.w,l.v=a.v,l.d=a.d,l}function i(a,l){var c=new r(a),u=l&&l.state,h=function(){return(c.next()>>>0)/4294967296};return h.double=function(){do var d=c.next()>>>11,f=(c.next()>>>0)/4294967296,p=(d+f)/(1<<21);while(p===0);return p},h.int32=c.next,h.quick=h,u&&(typeof u=="object"&&o(u,c),h.state=function(){return o(c,{})}),h}n&&n.exports?n.exports=i:this.xorwow=i})(Ui,t)})(Jy);var QB=Jy.exports,ew={exports:{}};ew.exports;(function(t){(function(e,n,s){function r(a){var l=this;l.next=function(){var u=l.x,h=l.i,d,f;return d=u[h],d^=d>>>7,f=d^d<<24,d=u[h+1&7],f^=d^d>>>10,d=u[h+3&7],f^=d^d>>>3,d=u[h+4&7],f^=d^d<<7,d=u[h+7&7],d=d^d<<13,f^=d^d<<9,u[h]=f,l.i=h+1&7,f};function c(u,h){var d,f=[];if(h===(h|0))f[0]=h;else for(h=""+h,d=0;d0;--d)u.next()}c(l,a)}function o(a,l){return l.x=a.x.slice(),l.i=a.i,l}function i(a,l){a==null&&(a=+new Date);var c=new r(a),u=l&&l.state,h=function(){return(c.next()>>>0)/4294967296};return h.double=function(){do var d=c.next()>>>11,f=(c.next()>>>0)/4294967296,p=(d+f)/(1<<21);while(p===0);return p},h.int32=c.next,h.quick=h,u&&(u.x&&o(u,c),h.state=function(){return o(c,{})}),h}n&&n.exports?n.exports=i:this.xorshift7=i})(Ui,t)})(ew);var ZB=ew.exports,tw={exports:{}};tw.exports;(function(t){(function(e,n,s){function r(a){var l=this;l.next=function(){var u=l.w,h=l.X,d=l.i,f,p;return l.w=u=u+1640531527|0,p=h[d+34&127],f=h[d=d+1&127],p^=p<<13,f^=f<<17,p^=p>>>15,f^=f>>>12,p=h[d]=p^f,l.i=d,p+(u^u>>>16)|0};function c(u,h){var d,f,p,g,x,m=[],y=128;for(h===(h|0)?(f=h,h=null):(h=h+"\0",f=0,y=Math.max(y,h.length)),p=0,g=-32;g>>15,f^=f<<4,f^=f>>>13,g>=0&&(x=x+1640531527|0,d=m[g&127]^=f+x,p=d==0?p+1:0);for(p>=128&&(m[(h&&h.length||0)&127]=-1),p=127,g=4*128;g>0;--g)f=m[p+34&127],d=m[p=p+1&127],f^=f<<13,d^=d<<17,f^=f>>>15,d^=d>>>12,m[p]=f^d;u.w=x,u.X=m,u.i=p}c(l,a)}function o(a,l){return l.i=a.i,l.w=a.w,l.X=a.X.slice(),l}function i(a,l){a==null&&(a=+new Date);var c=new r(a),u=l&&l.state,h=function(){return(c.next()>>>0)/4294967296};return h.double=function(){do var d=c.next()>>>11,f=(c.next()>>>0)/4294967296,p=(d+f)/(1<<21);while(p===0);return p},h.int32=c.next,h.quick=h,u&&(u.X&&o(u,c),h.state=function(){return o(c,{})}),h}n&&n.exports?n.exports=i:this.xor4096=i})(Ui,t)})(tw);var JB=tw.exports,nw={exports:{}};nw.exports;(function(t){(function(e,n,s){function r(a){var l=this,c="";l.next=function(){var h=l.b,d=l.c,f=l.d,p=l.a;return h=h<<25^h>>>7^d,d=d-f|0,f=f<<24^f>>>8^p,p=p-h|0,l.b=h=h<<20^h>>>12^d,l.c=d=d-f|0,l.d=f<<16^d>>>16^p,l.a=p-h|0},l.a=0,l.b=0,l.c=-1640531527,l.d=1367130551,a===Math.floor(a)?(l.a=a/4294967296|0,l.b=a|0):c+=a;for(var u=0;u>>0)/4294967296};return h.double=function(){do var d=c.next()>>>11,f=(c.next()>>>0)/4294967296,p=(d+f)/(1<<21);while(p===0);return p},h.int32=c.next,h.quick=h,u&&(typeof u=="object"&&o(u,c),h.state=function(){return o(c,{})}),h}n&&n.exports?n.exports=i:this.tychei=i})(Ui,t)})(nw);var eV=nw.exports,uN={exports:{}};const tV={},nV=Object.freeze(Object.defineProperty({__proto__:null,default:tV},Symbol.toStringTag,{value:"Module"})),sV=YD(nV);(function(t){(function(e,n,s){var r=256,o=6,i=52,a="random",l=s.pow(r,o),c=s.pow(2,i),u=c*2,h=r-1,d;function f(v,b,C){var k=[];b=b==!0?{entropy:!0}:b||{};var S=m(x(b.entropy?[v,w(n)]:v??y(),3),k),$=new p(k),N=function(){for(var A=$.g(o),M=l,L=0;A=u;)A/=2,M/=2,L>>>=1;return(A+L)/M};return N.int32=function(){return $.g(4)|0},N.quick=function(){return $.g(4)/4294967296},N.double=N,m(w($.S),n),(b.pass||C||function(A,M,L,V){return V&&(V.S&&g(V,$),A.state=function(){return g($,{})}),L?(s[a]=A,M):A})(N,S,"global"in b?b.global:this==s,b.state)}function p(v){var b,C=v.length,k=this,S=0,$=k.i=k.j=0,N=k.S=[];for(C||(v=[C++]);S>>0,d-=l,d*=l,l=d>>>0,d-=l,l+=d*4294967296}return(l>>>0)*23283064365386963e-26};return c}n&&n.exports?n.exports=i:this.alea=i})(Ui,t)})(Qy);var XB=Qy.exports,Zy={exports:{}};Zy.exports;(function(t){(function(e,n,s){function r(a){var l=this,c="";l.x=0,l.y=0,l.z=0,l.w=0,l.next=function(){var h=l.x^l.x<<11;return l.x=l.y,l.y=l.z,l.z=l.w,l.w^=l.w>>>19^h^h>>>8},a===(a|0)?l.x=a:c+=a;for(var u=0;u>>0)/4294967296};return h.double=function(){do var d=c.next()>>>11,f=(c.next()>>>0)/4294967296,p=(d+f)/(1<<21);while(p===0);return p},h.int32=c.next,h.quick=h,u&&(typeof u=="object"&&o(u,c),h.state=function(){return o(c,{})}),h}n&&n.exports?n.exports=i:this.xor128=i})(Ui,t)})(Zy);var qB=Zy.exports,Jy={exports:{}};Jy.exports;(function(t){(function(e,n,s){function r(a){var l=this,c="";l.next=function(){var h=l.x^l.x>>>2;return l.x=l.y,l.y=l.z,l.z=l.w,l.w=l.v,(l.d=l.d+362437|0)+(l.v=l.v^l.v<<4^(h^h<<1))|0},l.x=0,l.y=0,l.z=0,l.w=0,l.v=0,a===(a|0)?l.x=a:c+=a;for(var u=0;u>>4),l.next()}function o(a,l){return l.x=a.x,l.y=a.y,l.z=a.z,l.w=a.w,l.v=a.v,l.d=a.d,l}function i(a,l){var c=new r(a),u=l&&l.state,h=function(){return(c.next()>>>0)/4294967296};return h.double=function(){do var d=c.next()>>>11,f=(c.next()>>>0)/4294967296,p=(d+f)/(1<<21);while(p===0);return p},h.int32=c.next,h.quick=h,u&&(typeof u=="object"&&o(u,c),h.state=function(){return o(c,{})}),h}n&&n.exports?n.exports=i:this.xorwow=i})(Ui,t)})(Jy);var YB=Jy.exports,ew={exports:{}};ew.exports;(function(t){(function(e,n,s){function r(a){var l=this;l.next=function(){var u=l.x,h=l.i,d,f;return d=u[h],d^=d>>>7,f=d^d<<24,d=u[h+1&7],f^=d^d>>>10,d=u[h+3&7],f^=d^d>>>3,d=u[h+4&7],f^=d^d<<7,d=u[h+7&7],d=d^d<<13,f^=d^d<<9,u[h]=f,l.i=h+1&7,f};function c(u,h){var d,f=[];if(h===(h|0))f[0]=h;else for(h=""+h,d=0;d0;--d)u.next()}c(l,a)}function o(a,l){return l.x=a.x.slice(),l.i=a.i,l}function i(a,l){a==null&&(a=+new Date);var c=new r(a),u=l&&l.state,h=function(){return(c.next()>>>0)/4294967296};return h.double=function(){do var d=c.next()>>>11,f=(c.next()>>>0)/4294967296,p=(d+f)/(1<<21);while(p===0);return p},h.int32=c.next,h.quick=h,u&&(u.x&&o(u,c),h.state=function(){return o(c,{})}),h}n&&n.exports?n.exports=i:this.xorshift7=i})(Ui,t)})(ew);var QB=ew.exports,tw={exports:{}};tw.exports;(function(t){(function(e,n,s){function r(a){var l=this;l.next=function(){var u=l.w,h=l.X,d=l.i,f,p;return l.w=u=u+1640531527|0,p=h[d+34&127],f=h[d=d+1&127],p^=p<<13,f^=f<<17,p^=p>>>15,f^=f>>>12,p=h[d]=p^f,l.i=d,p+(u^u>>>16)|0};function c(u,h){var d,f,p,g,x,m=[],y=128;for(h===(h|0)?(f=h,h=null):(h=h+"\0",f=0,y=Math.max(y,h.length)),p=0,g=-32;g>>15,f^=f<<4,f^=f>>>13,g>=0&&(x=x+1640531527|0,d=m[g&127]^=f+x,p=d==0?p+1:0);for(p>=128&&(m[(h&&h.length||0)&127]=-1),p=127,g=4*128;g>0;--g)f=m[p+34&127],d=m[p=p+1&127],f^=f<<13,d^=d<<17,f^=f>>>15,d^=d>>>12,m[p]=f^d;u.w=x,u.X=m,u.i=p}c(l,a)}function o(a,l){return l.i=a.i,l.w=a.w,l.X=a.X.slice(),l}function i(a,l){a==null&&(a=+new Date);var c=new r(a),u=l&&l.state,h=function(){return(c.next()>>>0)/4294967296};return h.double=function(){do var d=c.next()>>>11,f=(c.next()>>>0)/4294967296,p=(d+f)/(1<<21);while(p===0);return p},h.int32=c.next,h.quick=h,u&&(u.X&&o(u,c),h.state=function(){return o(c,{})}),h}n&&n.exports?n.exports=i:this.xor4096=i})(Ui,t)})(tw);var ZB=tw.exports,nw={exports:{}};nw.exports;(function(t){(function(e,n,s){function r(a){var l=this,c="";l.next=function(){var h=l.b,d=l.c,f=l.d,p=l.a;return h=h<<25^h>>>7^d,d=d-f|0,f=f<<24^f>>>8^p,p=p-h|0,l.b=h=h<<20^h>>>12^d,l.c=d=d-f|0,l.d=f<<16^d>>>16^p,l.a=p-h|0},l.a=0,l.b=0,l.c=-1640531527,l.d=1367130551,a===Math.floor(a)?(l.a=a/4294967296|0,l.b=a|0):c+=a;for(var u=0;u>>0)/4294967296};return h.double=function(){do var d=c.next()>>>11,f=(c.next()>>>0)/4294967296,p=(d+f)/(1<<21);while(p===0);return p},h.int32=c.next,h.quick=h,u&&(typeof u=="object"&&o(u,c),h.state=function(){return o(c,{})}),h}n&&n.exports?n.exports=i:this.tychei=i})(Ui,t)})(nw);var JB=nw.exports,uN={exports:{}};const eV={},tV=Object.freeze(Object.defineProperty({__proto__:null,default:eV},Symbol.toStringTag,{value:"Module"})),nV=qD(tV);(function(t){(function(e,n,s){var r=256,o=6,i=52,a="random",l=s.pow(r,o),c=s.pow(2,i),u=c*2,h=r-1,d;function f(v,b,C){var k=[];b=b==!0?{entropy:!0}:b||{};var S=m(x(b.entropy?[v,w(n)]:v??y(),3),k),$=new p(k),N=function(){for(var A=$.g(o),M=l,L=0;A=u;)A/=2,M/=2,L>>>=1;return(A+L)/M};return N.int32=function(){return $.g(4)|0},N.quick=function(){return $.g(4)/4294967296},N.double=N,m(w($.S),n),(b.pass||C||function(A,M,L,V){return V&&(V.S&&g(V,$),A.state=function(){return g($,{})}),L?(s[a]=A,M):A})(N,S,"global"in b?b.global:this==s,b.state)}function p(v){var b,C=v.length,k=this,S=0,$=k.i=k.j=0,N=k.S=[];for(C||(v=[C++]);S=1||i===0);const a=Math.sqrt(-2*Math.log(i)/i);e=this.mean+this.stdDev*r*a,n=this.mean+this.stdDev*o*a,(!this.truncated||this.isValidTruncated(e))&&(s=!0)}return(!this.truncated||this.isValidTruncated(n))&&(this.nextVal=this.convertValue(n)),this.convertValue(e)}convertValue(e){return this.dtype==null||this.dtype==="float32"?e:Math.round(e)}isValidTruncated(e){return e<=this.upper&&e>=this.lower}}class hV{constructor(e=0,n=1,s,r){if(this.canReturnFloat=()=>this.dtype==null||this.dtype==="float32",this.min=e,this.range=n-e,this.dtype=s,r==null&&(r=Math.random()),typeof r=="number"&&(r=r.toString()),!this.canReturnFloat()&&this.range<=1)throw new Error(`The difference between ${e} - ${n} <= 1 and dtype is not float`);this.random=sw.alea(r)}convertValue(e){return this.canReturnFloat()?e:Math.round(e)}nextValue(){return this.convertValue(this.min+this.range*this.random())}}/** + */class hN{constructor(e,n,s,r,o){this.mean=e,this.stdDev=n,this.dtype=s,this.nextVal=NaN,this.truncated=r,this.truncated&&(this.upper=this.mean+this.stdDev*2,this.lower=this.mean-this.stdDev*2);const i=o||Math.random();this.random=sw.alea(i.toString())}nextValue(){if(!isNaN(this.nextVal)){const r=this.nextVal;return this.nextVal=NaN,r}let e,n,s=!1;for(;!s;){let r,o,i;do r=2*this.random()-1,o=2*this.random()-1,i=r*r+o*o;while(i>=1||i===0);const a=Math.sqrt(-2*Math.log(i)/i);e=this.mean+this.stdDev*r*a,n=this.mean+this.stdDev*o*a,(!this.truncated||this.isValidTruncated(e))&&(s=!0)}return(!this.truncated||this.isValidTruncated(n))&&(this.nextVal=this.convertValue(n)),this.convertValue(e)}convertValue(e){return this.dtype==null||this.dtype==="float32"?e:Math.round(e)}isValidTruncated(e){return e<=this.upper&&e>=this.lower}}class uV{constructor(e=0,n=1,s,r){if(this.canReturnFloat=()=>this.dtype==null||this.dtype==="float32",this.min=e,this.range=n-e,this.dtype=s,r==null&&(r=Math.random()),typeof r=="number"&&(r=r.toString()),!this.canReturnFloat()&&this.range<=1)throw new Error(`The difference between ${e} - ${n} <= 1 and dtype is not float`);this.random=sw.alea(r)}convertValue(e){return this.canReturnFloat()?e:Math.round(e)}nextValue(){return this.convertValue(this.min+this.range*this.random())}}/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -2363,7 +2363,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function dV(t,e=0,n=1,s,r){if(qr(t),s!=null&&s==="bool")throw new Error(`Unsupported data type ${s}`);const o=new hN(e,n,s,!1,r),i=Ee(t,s);for(let a=0;a`Error in separableConv2d: input must be rank 4, but got rank ${u.rank}.`),I(l.rank===4,()=>`Error in separableConv2d: depthwise filter must be rank 4, but got rank ${l.rank}.`),I(c.rank===4,()=>`Error in separableConv2d: pointwise filter must be rank 4, but got rank ${l.rank}.`),I(c.shape[0]===1,()=>`Error in separableConv2d: the first dimension of pointwise filter must be 1, but got ${c.shape[0]}.`),I(c.shape[1]===1,()=>`Error in separableConv2d: the second dimension of pointwise filter must be 1, but got ${c.shape[1]}.`);const d=l.shape[2],f=l.shape[3];I(c.shape[2]===d*f,()=>`Error in separableConv2d: the third dimension of pointwise filter must be ${d*f}, but got ${c.shape[2]}.`);const p=By(u,l,s,r,i,o),x=zi(p,c,1,"valid",i);return h?F(x,[x.shape[1],x.shape[2],x.shape[3]]):x}const gN=z({separableConv2d_:SV});/** + */function CV(t){const n={x:T(t,"x","selu")};return _.runKernel(qu,n)}const mN=z({selu_:CV});function kV(t,e,n,s,r,o=[1,1],i="NHWC"){const a=T(t,"x","separableConv2d"),l=T(e,"depthwiseFilter","separableConv2d"),c=T(n,"pointwiseFilter","separableConv2d");let u=a,h=!1;if(a.rank===3&&(h=!0,u=F(a,[1,a.shape[0],a.shape[1],a.shape[2]])),i==="NCHW")throw new Error("separableConv2d currently does not support dataFormat NCHW; only NHWC is supported");I(u.rank===4,()=>`Error in separableConv2d: input must be rank 4, but got rank ${u.rank}.`),I(l.rank===4,()=>`Error in separableConv2d: depthwise filter must be rank 4, but got rank ${l.rank}.`),I(c.rank===4,()=>`Error in separableConv2d: pointwise filter must be rank 4, but got rank ${l.rank}.`),I(c.shape[0]===1,()=>`Error in separableConv2d: the first dimension of pointwise filter must be 1, but got ${c.shape[0]}.`),I(c.shape[1]===1,()=>`Error in separableConv2d: the second dimension of pointwise filter must be 1, but got ${c.shape[1]}.`);const d=l.shape[2],f=l.shape[3];I(c.shape[2]===d*f,()=>`Error in separableConv2d: the third dimension of pointwise filter must be ${d*f}, but got ${c.shape[2]}.`);const p=By(u,l,s,r,i,o),x=zi(p,c,1,"valid",i);return h?F(x,[x.shape[1],x.shape[2],x.shape[3]]):x}const gN=z({separableConv2d_:kV});/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -2528,7 +2528,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function IV(t){const n={x:T(t,"x","sign")};return _.runKernel(Ju,n)}const $V=z({sign_:IV});/** + */function SV(t){const n={x:T(t,"x","sign")};return _.runKernel(Zu,n)}const IV=z({sign_:SV});/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -2543,7 +2543,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function NV(t){const n={x:T(t,"x","sin","float32")};return _.runKernel(Qu,n)}const xN=z({sin_:NV});/** + */function $V(t){const n={x:T(t,"x","sin","float32")};return _.runKernel(Yu,n)}const xN=z({sin_:$V});/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -2558,7 +2558,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function TV(t){const n={x:T(t,"x","sinh")};return _.runKernel(Zu,n)}const yN=z({sinh_:TV});/** + */function NV(t){const n={x:T(t,"x","sinh")};return _.runKernel(Qu,n)}const yN=z({sinh_:NV});/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -2573,7 +2573,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function EV(t,e,n){const s=T(t,"x","slice1d");return I(s.rank===1,()=>`slice1d expects a rank-1 tensor, but got a rank-${s.rank} tensor`),tt(s,[e],[n])}const rw=z({slice1d_:EV});/** + */function TV(t,e,n){const s=T(t,"x","slice1d");return I(s.rank===1,()=>`slice1d expects a rank-1 tensor, but got a rank-${s.rank} tensor`),tt(s,[e],[n])}const rw=z({slice1d_:TV});/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -2588,7 +2588,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function RV(t,e,n){const s=T(t,"x","slice2d");return I(s.rank===2,()=>`slice2d expects a rank-2 tensor, but got a rank-${s.rank} tensor`),tt(s,e,n)}const wN=z({slice2d_:RV});/** + */function EV(t,e,n){const s=T(t,"x","slice2d");return I(s.rank===2,()=>`slice2d expects a rank-2 tensor, but got a rank-${s.rank} tensor`),tt(s,e,n)}const wN=z({slice2d_:EV});/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -2603,7 +2603,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function AV(t,e,n){const s=T(t,"x","slice3d");return I(s.rank===3,()=>`slice3d expects a rank-3 tensor, but got a rank-${s.rank} tensor`),tt(s,e,n)}const ow=z({slice3d_:AV});/** + */function RV(t,e,n){const s=T(t,"x","slice3d");return I(s.rank===3,()=>`slice3d expects a rank-3 tensor, but got a rank-${s.rank} tensor`),tt(s,e,n)}const ow=z({slice3d_:RV});/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -2618,7 +2618,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function DV(t,e,n){const s=T(t,"x","slice4d");return I(s.rank===4,()=>`slice4d expects a rank-4 tensor, but got a rank-${s.rank} tensor`),tt(s,e,n)}const kf=z({slice4d_:DV});/** + */function AV(t,e,n){const s=T(t,"x","slice4d");return I(s.rank===4,()=>`slice4d expects a rank-4 tensor, but got a rank-${s.rank} tensor`),tt(s,e,n)}const Cf=z({slice4d_:AV});/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -2633,7 +2633,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function _V(t,e=-1){const n=T(t,"logits","softmax","float32");if(e===-1&&(e=n.rank-1),e!==n.rank-1)throw Error(`Softmax along a non-last dimension is not yet supported. Logits was rank ${n.rank} and dim was ${e}`);const s={logits:n},r={dim:e};return _.runKernel(um,s,r)}const iw=z({softmax_:_V});/** + */function DV(t,e=-1){const n=T(t,"logits","softmax","float32");if(e===-1&&(e=n.rank-1),e!==n.rank-1)throw Error(`Softmax along a non-last dimension is not yet supported. Logits was rank ${n.rank} and dim was ${e}`);const s={logits:n},r={dim:e};return _.runKernel(um,s,r)}const iw=z({softmax_:DV});/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -2648,7 +2648,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function FV(t){I(t.dtype==="complex64",()=>`The dtype for tf.spectral.fft() must be complex64 but got ${t.dtype}.`);const e={input:t};return _.runKernel(cy,e)}const vN=z({fft_:FV});/** + */function _V(t){I(t.dtype==="complex64",()=>`The dtype for tf.spectral.fft() must be complex64 but got ${t.dtype}.`);const e={input:t};return _.runKernel(cy,e)}const vN=z({fft_:_V});/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -2663,7 +2663,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function zV(t){I(t.dtype==="complex64",()=>`The dtype for tf.spectral.ifft() must be complex64 but got ${t.dtype}.`);const e={input:t};return _.runKernel(dy,e)}const f1=z({ifft_:zV});/** + */function FV(t){I(t.dtype==="complex64",()=>`The dtype for tf.spectral.ifft() must be complex64 but got ${t.dtype}.`);const e={input:t};return _.runKernel(dy,e)}const f1=z({ifft_:FV});/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -2678,7 +2678,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function OV(t){const e=t.shape[t.shape.length-1],n=t.size/e;let s;if(e<=2){const r=F(t,[n,e]);s=f1(r)}else{const r=[n,2*(e-1)],o=F(Cf(t),[n,e]),i=F(Uy(t),[n,e]),a=Mi(tt(o,[0,1],[n,e-2]),1),l=D(Mi(tt(i,[0,1],[n,e-2]),1),We(-1)),c=Dn([o,a],1),u=Dn([i,l],1),h=F(Ri(c,u),[r[0],r[1]]);s=f1(h)}if(s=Cf(s),t.rank===3&&t.shape[0]!==0){const r=s,o=t.shape[0];s=F(s,[o,s.shape[0]/o,s.shape[1]]),r.dispose()}return s}const MV=z({irfft_:OV});/** + */function zV(t){const e=t.shape[t.shape.length-1],n=t.size/e;let s;if(e<=2){const r=F(t,[n,e]);s=f1(r)}else{const r=[n,2*(e-1)],o=F(bf(t),[n,e]),i=F(Uy(t),[n,e]),a=Mi(tt(o,[0,1],[n,e-2]),1),l=D(Mi(tt(i,[0,1],[n,e-2]),1),We(-1)),c=Dn([o,a],1),u=Dn([i,l],1),h=F(Ri(c,u),[r[0],r[1]]);s=f1(h)}if(s=bf(s),t.rank===3&&t.shape[0]!==0){const r=s,o=t.shape[0];s=F(s,[o,s.shape[0]/o,s.shape[1]]),r.dispose()}return s}const OV=z({irfft_:zV});/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -2693,7 +2693,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function PV(t,e,n=0){const r={x:T(t,"x","split")},o={numOrSizeSplits:e,axis:n};return _.runKernel(cm,r,o)}const rs=z({split_:PV});/** + */function MV(t,e,n=0){const r={x:T(t,"x","split")},o={numOrSizeSplits:e,axis:n};return _.runKernel(cm,r,o)}const rs=z({split_:MV});/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -2708,7 +2708,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function LV(t,e){I(t.dtype==="float32",()=>`The dtype for rfft() must be real value but got ${t.dtype}`);let n=t.shape[t.shape.length-1];const s=t.size/n;let r;if(e!=null&&e0),g=t.shape.map(x=>x);g[t.shape.length-1]=e,r=tt(t,p,g),n=e}else if(e!=null&&e>n){const p=t.shape.map(g=>g);p[t.shape.length-1]=e-n,r=Dn([t,Kt(p)],t.shape.length-1),n=e}else r=t;const o=ze(r),i=F(Ri(r,o),[s,n]),a=vN(i),l=Math.floor(n/2)+1,c=Cf(a),u=Uy(a),h=rs(c,[l,n-l],c.shape.length-1),d=rs(u,[l,n-l],u.shape.length-1),f=r.shape.slice();return f[r.shape.length-1]=l,F(Ri(h[0],d[0]),f)}const BV=z({rfft_:LV});/** + */function PV(t,e){I(t.dtype==="float32",()=>`The dtype for rfft() must be real value but got ${t.dtype}`);let n=t.shape[t.shape.length-1];const s=t.size/n;let r;if(e!=null&&e0),g=t.shape.map(x=>x);g[t.shape.length-1]=e,r=tt(t,p,g),n=e}else if(e!=null&&e>n){const p=t.shape.map(g=>g);p[t.shape.length-1]=e-n,r=Dn([t,Kt(p)],t.shape.length-1),n=e}else r=t;const o=ze(r),i=F(Ri(r,o),[s,n]),a=vN(i),l=Math.floor(n/2)+1,c=bf(a),u=Uy(a),h=rs(c,[l,n-l],c.shape.length-1),d=rs(u,[l,n-l],u.shape.length-1),f=r.shape.slice();return f[r.shape.length-1]=l,F(Ri(h[0],d[0]),f)}const LV=z({rfft_:PV});/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -2723,7 +2723,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function VV(t,e){let n=T(t,"a","squaredDifference"),s=T(e,"b","squaredDifference");[n,s]=It(n,s),Se(n.shape,s.shape);const r={a:n,b:s},o={};return _.runKernel(sh,r,o)}const WV=z({squaredDifference_:VV});/** + */function BV(t,e){let n=T(t,"a","squaredDifference"),s=T(e,"b","squaredDifference");[n,s]=It(n,s),Se(n.shape,s.shape);const r={a:n,b:s},o={};return _.runKernel(nh,r,o)}const VV=z({squaredDifference_:BV});/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -2738,7 +2738,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function UV(t,e){const n=T(t,"x","squeeze","string_or_numeric");return F(n,Vo(n.shape,e).newShape)}const ph=z({squeeze_:UV});/** + */function WV(t,e){const n=T(t,"x","squeeze","string_or_numeric");return F(n,Vo(n.shape,e).newShape)}const fh=z({squeeze_:WV});/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -2753,7 +2753,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function GV(t,e=0){const n=B$(t,"tensors","stack","string_or_numeric");I(n.length>=1,()=>"Pass at least one tensor to tf.stack"),n.length>0&&I(e<=n[0].rank,()=>"Axis must be <= rank of the tensor");const s=n,r={axis:e};return _.runKernel(Qp,s,r)}const Hr=z({stack_:GV});/** + */function UV(t,e=0){const n=B$(t,"tensors","stack","string_or_numeric");I(n.length>=1,()=>"Pass at least one tensor to tf.stack"),n.length>0&&I(e<=n[0].rank,()=>"Axis must be <= rank of the tensor");const s=n,r={axis:e};return _.runKernel(Qp,s,r)}const Hr=z({stack_:UV});/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -2768,7 +2768,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function HV(t,e=0){const s={x:T(t,"x","step")},r={alpha:e};return _.runKernel(lh,s,r)}const mh=z({step_:HV});/** + */function GV(t,e=0){const s={x:T(t,"x","step")},r={alpha:e};return _.runKernel(ah,s,r)}const ph=z({step_:GV});/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -2783,7 +2783,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function jV(t,e,n,s,r=0,o=0,i=0,a=0,l=0){const u={x:T(t,"x","stridedSlice","string_or_numeric")},h={begin:e,end:n,strides:s,beginMask:r,endMask:o,ellipsisMask:i,newAxisMask:a,shrinkAxisMask:l};return _.runKernel($y,u,h)}const KV=z({stridedSlice_:jV});/** + */function HV(t,e,n,s,r=0,o=0,i=0,a=0,l=0){const u={x:T(t,"x","stridedSlice","string_or_numeric")},h={begin:e,end:n,strides:s,beginMask:r,endMask:o,ellipsisMask:i,newAxisMask:a,shrinkAxisMask:l};return _.runKernel($y,u,h)}const jV=z({stridedSlice_:HV});/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -2798,7 +2798,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function XV(t){const n={x:T(t,"x","tan","float32")};return _.runKernel(oh,n)}const qV=z({tan_:XV});/** + */function KV(t){const n={x:T(t,"x","tan","float32")};return _.runKernel(rh,n)}const XV=z({tan_:KV});/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -2813,7 +2813,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function Gn(t,e){Bx(t);const n=ch(t,e);if(n.length!==1)throw new Error("tensor1d() requires values to be a flat/TypedArray");return uh(t,null,n,e)}/** + */function Gn(t,e){Bx(t);const n=lh(t,e);if(n.length!==1)throw new Error("tensor1d() requires values to be a flat/TypedArray");return ch(t,null,n,e)}/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -2828,7 +2828,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function Sg(t,e,n){if(Bx(t),e!=null&&e.length!==2)throw new Error("tensor2d() requires shape to have two numbers");const s=ch(t,n);if(s.length!==2&&s.length!==1)throw new Error("tensor2d() requires values to be number[][] or flat/TypedArray");if(s.length===1&&e==null)throw new Error("tensor2d() requires shape to be provided when `values` are a flat/TypedArray");return uh(t,e,s,n)}/** + */function Sg(t,e,n){if(Bx(t),e!=null&&e.length!==2)throw new Error("tensor2d() requires shape to have two numbers");const s=lh(t,n);if(s.length!==2&&s.length!==1)throw new Error("tensor2d() requires values to be number[][] or flat/TypedArray");if(s.length===1&&e==null)throw new Error("tensor2d() requires shape to be provided when `values` are a flat/TypedArray");return ch(t,e,s,n)}/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -2843,7 +2843,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function YV(t,e,n){Bx(t);const s=ch(t,n);if(s.length!==3&&s.length!==1)throw new Error("tensor3d() requires values to be number[][][] or flat/TypedArray");if(s.length===1&&e==null)throw new Error("tensor3d() requires shape to be provided when `values` are a flat array");return uh(t,e,s,n)}function bN(t,e,n){const s=e.rank>1?e.shape[e.rank-1]:1,r=e.rank>1?e.rank-1:1,o=`Must have updates.shape = indices.shape[:batchDim] + shape[sliceDim:], got updates.shape: ${n.shape}, indices.shape: ${e.shape}, shape: ${t}, sliceDim: ${s}, and batchDim: ${r}.`;if(n.rank1?e.shape[s-1]:1,o=n.length;let i=1;for(let h=r;h1?e.shape[e.rank-1]:1,r=e.rank>1?e.rank-1:1,o=`Must have updates.shape = indices.shape[:batchDim] + shape[sliceDim:], got updates.shape: ${n.shape}, indices.shape: ${e.shape}, shape: ${t}, sliceDim: ${s}, and batchDim: ${r}.`;if(n.rank1?e.shape[s-1]:1,o=n.length;let i=1;for(let h=r;h= 0 but got ${e}`);if(e>r)throw new Error(`'k' passed to topk() must be <= the last dimension (${r}) but got ${e}`);const o={x:s},i={k:e,sorted:n},[a,l]=_.runKernel(Ny,o,i);return{values:a,indices:l}}const JV=z({topk_:ZV});/** + */function QV(t,e=1,n=!0){const s=T(t,"x","topk");if(s.rank===0)throw new Error("topk() expects the input to be of rank 1 or higher");const r=s.shape[s.shape.length-1];if(e<0)throw new Error(`'k' passed to topk() must be >= 0 but got ${e}`);if(e>r)throw new Error(`'k' passed to topk() must be <= the last dimension (${r}) but got ${e}`);const o={x:s},i={k:e,sorted:n},[a,l]=_.runKernel(Ny,o,i);return{values:a,indices:l}}const ZV=z({topk_:QV});/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -2873,7 +2873,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function eW(t,e=0,n=1,s,r){if(qr(t),s!=null&&s==="bool")throw new Error("Unsupported data type $ { dtype }");const o=new hN(e,n,s,!0,r),i=Ee(t,s);for(let a=0;a0,()=>"The input tensor must be at least 1D");const s={x:n},r={axis:e},[o,i]=_.runKernel(Ey,s,r);return{values:o,indices:i}}const nW=z({unique_:tW});/** + */function eW(t,e=0){const n=T(t,"x","unique","string_or_numeric");I(n.rank>0,()=>"The input tensor must be at least 1D");const s={x:n},r={axis:e},[o,i]=_.runKernel(Ey,s,r);return{values:o,indices:i}}const tW=z({unique_:eW});/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -2903,7 +2903,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function sW(t,e,n){const s=T(t,"x","unsortedSegmentSum"),r=T(e,"segmentIds","unsortedSegmentSum","int32");I(nl(n),()=>"numSegments must be of dtype int");const o={x:s,segmentIds:r},i={numSegments:n};return _.runKernel(dm,o,i)}const kN=z({unsortedSegmentSum_:sW});/** + */function nW(t,e,n){const s=T(t,"x","unsortedSegmentSum"),r=T(e,"segmentIds","unsortedSegmentSum","int32");I(nl(n),()=>"numSegments must be of dtype int");const o={x:s,segmentIds:r},i={numSegments:n};return _.runKernel(dm,o,i)}const kN=z({unsortedSegmentSum_:nW});/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -2918,7 +2918,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function rW(t,e=0){const n=T(t,"x","unstack","string_or_numeric");I(e>=-n.shape.length&&e`Axis = ${e} is not in [-${n.shape.length}, ${n.shape.length})`);const s={value:n},r={axis:e};return _.runKernel(hm,s,r)}const Pi=z({unstack_:rW});/** + */function sW(t,e=0){const n=T(t,"x","unstack","string_or_numeric");I(e>=-n.shape.length&&e`Axis = ${e} is not in [-${n.shape.length}, ${n.shape.length})`);const s={value:n},r={axis:e};return _.runKernel(hm,s,r)}const Pi=z({unstack_:sW});/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -2933,7 +2933,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function oW(t,e=!0,n,s){return _.makeVariable(t,e,n,s)}/** + */function rW(t,e=!0,n,s){return _.makeVariable(t,e,n,s)}/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -2963,7 +2963,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function iW(t,e,n){const s=T(t,"x","transpose");if(e==null&&(e=s.shape.map((i,a)=>a).reverse()),I(s.rank===e.length,()=>`Error in transpose: rank of input ${s.rank} must match length of perm ${e}.`),e.forEach(i=>{I(i>=0&&i`All entries in 'perm' must be between 0 and ${s.rank-1} but got ${e}`)}),s.rank<=1)return s.clone();const r={x:s},o={perm:e};return s.dtype==="complex64"?P(()=>{let i=Cf(s),a=Uy(s);return i=_.runKernel(Ma,{x:i},o),a=_.runKernel(Ma,{x:a},o),n&&(a=St(a)),Ri(i,a)}):_.runKernel(Ma,r,o)}const Fe=z({transpose_:iW});/** + */function oW(t,e,n){const s=T(t,"x","transpose");if(e==null&&(e=s.shape.map((i,a)=>a).reverse()),I(s.rank===e.length,()=>`Error in transpose: rank of input ${s.rank} must match length of perm ${e}.`),e.forEach(i=>{I(i>=0&&i`All entries in 'perm' must be between 0 and ${s.rank-1} but got ${e}`)}),s.rank<=1)return s.clone();const r={x:s},o={perm:e};return s.dtype==="complex64"?P(()=>{let i=bf(s),a=Uy(s);return i=_.runKernel(Ma,{x:i},o),a=_.runKernel(Ma,{x:a},o),n&&(a=St(a)),Ri(i,a)}):_.runKernel(Ma,r,o)}const Fe=z({transpose_:oW});/** * @license * Copyright 2019 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -2978,7 +2978,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function aW(t,e){if(e==null)return t.shape.slice();if(Ue(t.shape,e))return e;if(t.shape.length===e.length){const n=[];for(let s=0;s`x has to be a floating point tensor since it's going to be scaled, but got a ${r.dtype} tensor instead.`),I(e>=0&&e<1,()=>`rate must be a float in the range [0, 1), but got ${e}.`),e===0)return t instanceof zt?r.clone():r;const o=aW(r,n),i=1-e,a=ge(vm(J(fh(o,0,1,"float32",s),i)),i);return D(r,a)}const cW=z({dropout_:lW});/** + */function aW(t,e,n,s){const r=T(t,"x","dropout");if(I(r.dtype==="float32",()=>`x has to be a floating point tensor since it's going to be scaled, but got a ${r.dtype} tensor instead.`),I(e>=0&&e<1,()=>`rate must be a float in the range [0, 1), but got ${e}.`),e===0)return t instanceof zt?r.clone():r;const o=iW(r,n),i=1-e,a=ge(vm(J(dh(o,0,1,"float32",s),i)),i);return D(r,a)}const lW=z({dropout_:aW});/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -3008,7 +3008,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function uW(t,e,n,s,r,o="NHWC",i){let a=t;t.rank===3&&(a=F(t,[1,t.shape[0],t.shape[1],t.shape[2]]));let l=e;l.rank===3&&(l=F(e,[1,e.shape[0],e.shape[1],e.shape[2]])),I(a.rank===4,()=>`Error in conv2dDerFilter: input must be rank 4, but got shape ${a.shape}.`),I(l.rank===4,()=>`Error in conv2dDerFilter: dy must be rank 4, but got shape ${l.shape}.`),I(n.length===4,()=>`Error in conv2dDerFilter: filterShape must be length 4, but got ${n}.`);const c=o==="NHWC"?a.shape[3]:a.shape[1],u=o==="NHWC"?l.shape[3]:l.shape[1];I(c===n[2],()=>`Error in conv2dDerFilter: depth of input ${c}) must match input depth in filter (${n[2]}.`),I(u===n[3],()=>`Error in conv2dDerFilter: depth of dy (${u}) must match output depth for filter (${n[3]}).`),Mn("conv2dDerFilter",r,i);const h={x:a,dy:l},d={strides:s,pad:r,dataFormat:o,dimRoundingMode:i,filterShape:n};return _.runKernel(Zx,h,d)}const aw=z({conv2DBackpropFilter_:uW});/** + */function cW(t,e,n,s,r,o="NHWC",i){let a=t;t.rank===3&&(a=F(t,[1,t.shape[0],t.shape[1],t.shape[2]]));let l=e;l.rank===3&&(l=F(e,[1,e.shape[0],e.shape[1],e.shape[2]])),I(a.rank===4,()=>`Error in conv2dDerFilter: input must be rank 4, but got shape ${a.shape}.`),I(l.rank===4,()=>`Error in conv2dDerFilter: dy must be rank 4, but got shape ${l.shape}.`),I(n.length===4,()=>`Error in conv2dDerFilter: filterShape must be length 4, but got ${n}.`);const c=o==="NHWC"?a.shape[3]:a.shape[1],u=o==="NHWC"?l.shape[3]:l.shape[1];I(c===n[2],()=>`Error in conv2dDerFilter: depth of input ${c}) must match input depth in filter (${n[2]}.`),I(u===n[3],()=>`Error in conv2dDerFilter: depth of dy (${u}) must match output depth for filter (${n[3]}).`),Mn("conv2dDerFilter",r,i);const h={x:a,dy:l},d={strides:s,pad:r,dataFormat:o,dimRoundingMode:i,filterShape:n};return _.runKernel(Zx,h,d)}const aw=z({conv2DBackpropFilter_:cW});/** * @license * Copyright 2019 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -3023,7 +3023,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function lw(t,e,n){if(n==null||n==="linear")return t;if(n==="relu")return D(t,mh(e));throw new Error(`Cannot compute gradient for fused activation ${n}.`)}function cw(t,e){let n=e;const s=Vt(t.shape,e.shape);return s.length>0&&(n=me(n,s)),F(n,t.shape)}function uw(t,e,n,s){if(e==="linear")return t;if(e==="relu")return Yi(t);if(e==="elu")return ym(t);if(e==="relu6")return dN(t);if(e==="prelu")return Yy(t,n);if(e==="leakyrelu")return Gy(t,s);if(e==="sigmoid")return Cl(t);throw new Error(`Unknown fused activation ${e}.`)}const hw=(t,e)=>!(t>0)||e==="linear";/** + */function lw(t,e,n){if(n==null||n==="linear")return t;if(n==="relu")return D(t,ph(e));throw new Error(`Cannot compute gradient for fused activation ${n}.`)}function cw(t,e){let n=e;const s=Vt(t.shape,e.shape);return s.length>0&&(n=me(n,s)),F(n,t.shape)}function uw(t,e,n,s){if(e==="linear")return t;if(e==="relu")return Yi(t);if(e==="elu")return ym(t);if(e==="relu6")return dN(t);if(e==="prelu")return Yy(t,n);if(e==="leakyrelu")return Gy(t,s);if(e==="sigmoid")return Cl(t);throw new Error(`Unknown fused activation ${e}.`)}const hw=(t,e)=>!(t>0)||e==="linear";/** * @license * Copyright 2019 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -3038,7 +3038,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function hW({x:t,filter:e,strides:n,pad:s,dataFormat:r="NHWC",dilations:o=[1,1],dimRoundingMode:i,bias:a,activation:l="linear",preluActivationWeights:c,leakyreluAlpha:u}){if(l=l||"linear",hw(_.state.gradientDepth,l)===!1){I(r==="NHWC",()=>`Error in fused conv2d: got dataFormat of ${r} but only NHWC is currently supported for the case of gradient depth is 0 and the activation is not linear.`);let C=zi(t,e,n,s,r,o,i);return a!=null&&(C=J(C,a)),uw(C,l,c,u)}const h=T(t,"x","conv2d","float32"),d=T(e,"filter","conv2d","float32");let f=h,p=!1;h.rank===3&&(p=!0,f=F(h,[1,h.shape[0],h.shape[1],h.shape[2]])),I(f.rank===4,()=>`Error in fused conv2d: input must be rank 4, but got rank ${f.rank}.`),I(d.rank===4,()=>`Error in fused conv2d: filter must be rank 4, but got rank ${d.rank}.`),Mn("fused conv2d",s,i);const g=r==="NHWC"?f.shape[3]:f.shape[1];I(d.shape[2]===g,()=>`Error in conv2d: depth of input (${g}) must match input depth for filter ${d.shape[2]}.`),I(dn(n,o),()=>`Error in conv2D: Either strides or dilations must be 1. Got strides ${n} and dilations '${o}'`);const x=nn(f.shape,d.shape,n,o,s,i);let m;a!=null&&(m=T(a,"bias","fused conv2d"),[m]=It(m,h),r==="NHWC"?Se(x.outShape,m.shape):(I(m.shape.length<=1,()=>`Error in fused conv2d: only supports scalar or 1-D Tensor bias for NCHW format but got the bias of rank-${m.shape.length}.`),I(m.shape.length===0||m.shape[0]===x.outChannels||m.shape[0]===1,()=>`Error in fused conv2d: bias shape (${m.shape}) is not compatible with the number of output channels (${x.outChannels})`)));let y;if(c!=null){const C=c.shape;if(I(C.length<=1||C.length===3,()=>`Error in fused conv2d: only supports scalar, 1-D Tensor or 3-D Tensor PReLU activation weights but got a tensor of rank-${C.length}.`),C.length===1)I(C[0]===1||C[0]===x.outChannels,()=>`Error in fused conv2d: PReLU activation weights (${C}) is not compatible with the number of output channels (${x.outChannels}).`);else if(C.length===3)try{Se(C,x.outShape)}catch{const S=`Error in fused conv2d: PReLU activation weights (${C}) is not compatible with the output shape of the conv2d (${x.outShape}).`;throw Error(S)}y=T(c,"prelu weights","fused conv2d")}const w=(C,k)=>{I(r==="NHWC",()=>`Error in gradient of fused conv2D: got dataFormat of ${r} but only NHWC is currently supported.`);const[S,$,N,A]=k,M=lw(C,N,l);I(_i(o),()=>`Error in gradient of fused conv2D: dilation rates greater than 1 are not yet supported in gradients. Got dilations '${o}'`);const L=Py($.shape,M,S,n,s),V=aw($,M,S.shape,n,s),B=[L,V];if(A!=null){const U=cw(A,M);B.push(U)}return B},v={x:f,filter:d,bias:m,preluActivationWeights:y},b={strides:n,pad:s,dataFormat:r,dilations:o,dimRoundingMode:i,activation:l,leakyreluAlpha:u};return a==null?al((k,S,$)=>{let N=_.runKernel(pf,v,b);return $([S,k,N]),p&&(N=F(N,[N.shape[1],N.shape[2],N.shape[3]])),{value:N,gradFunc:w}})(f,d):al((k,S,$,N)=>{let A=_.runKernel(pf,v,b);return N([S,k,A,$]),p&&(A=F(A,[A.shape[1],A.shape[2],A.shape[3]])),{value:A,gradFunc:w}})(f,d,m)}const dW=z({fusedConv2d_:hW});/** + */function uW({x:t,filter:e,strides:n,pad:s,dataFormat:r="NHWC",dilations:o=[1,1],dimRoundingMode:i,bias:a,activation:l="linear",preluActivationWeights:c,leakyreluAlpha:u}){if(l=l||"linear",hw(_.state.gradientDepth,l)===!1){I(r==="NHWC",()=>`Error in fused conv2d: got dataFormat of ${r} but only NHWC is currently supported for the case of gradient depth is 0 and the activation is not linear.`);let C=zi(t,e,n,s,r,o,i);return a!=null&&(C=J(C,a)),uw(C,l,c,u)}const h=T(t,"x","conv2d","float32"),d=T(e,"filter","conv2d","float32");let f=h,p=!1;h.rank===3&&(p=!0,f=F(h,[1,h.shape[0],h.shape[1],h.shape[2]])),I(f.rank===4,()=>`Error in fused conv2d: input must be rank 4, but got rank ${f.rank}.`),I(d.rank===4,()=>`Error in fused conv2d: filter must be rank 4, but got rank ${d.rank}.`),Mn("fused conv2d",s,i);const g=r==="NHWC"?f.shape[3]:f.shape[1];I(d.shape[2]===g,()=>`Error in conv2d: depth of input (${g}) must match input depth for filter ${d.shape[2]}.`),I(dn(n,o),()=>`Error in conv2D: Either strides or dilations must be 1. Got strides ${n} and dilations '${o}'`);const x=nn(f.shape,d.shape,n,o,s,i);let m;a!=null&&(m=T(a,"bias","fused conv2d"),[m]=It(m,h),r==="NHWC"?Se(x.outShape,m.shape):(I(m.shape.length<=1,()=>`Error in fused conv2d: only supports scalar or 1-D Tensor bias for NCHW format but got the bias of rank-${m.shape.length}.`),I(m.shape.length===0||m.shape[0]===x.outChannels||m.shape[0]===1,()=>`Error in fused conv2d: bias shape (${m.shape}) is not compatible with the number of output channels (${x.outChannels})`)));let y;if(c!=null){const C=c.shape;if(I(C.length<=1||C.length===3,()=>`Error in fused conv2d: only supports scalar, 1-D Tensor or 3-D Tensor PReLU activation weights but got a tensor of rank-${C.length}.`),C.length===1)I(C[0]===1||C[0]===x.outChannels,()=>`Error in fused conv2d: PReLU activation weights (${C}) is not compatible with the number of output channels (${x.outChannels}).`);else if(C.length===3)try{Se(C,x.outShape)}catch{const S=`Error in fused conv2d: PReLU activation weights (${C}) is not compatible with the output shape of the conv2d (${x.outShape}).`;throw Error(S)}y=T(c,"prelu weights","fused conv2d")}const w=(C,k)=>{I(r==="NHWC",()=>`Error in gradient of fused conv2D: got dataFormat of ${r} but only NHWC is currently supported.`);const[S,$,N,A]=k,M=lw(C,N,l);I(_i(o),()=>`Error in gradient of fused conv2D: dilation rates greater than 1 are not yet supported in gradients. Got dilations '${o}'`);const L=Py($.shape,M,S,n,s),V=aw($,M,S.shape,n,s),B=[L,V];if(A!=null){const U=cw(A,M);B.push(U)}return B},v={x:f,filter:d,bias:m,preluActivationWeights:y},b={strides:n,pad:s,dataFormat:r,dilations:o,dimRoundingMode:i,activation:l,leakyreluAlpha:u};return a==null?al((k,S,$)=>{let N=_.runKernel(ff,v,b);return $([S,k,N]),p&&(N=F(N,[N.shape[1],N.shape[2],N.shape[3]])),{value:N,gradFunc:w}})(f,d):al((k,S,$,N)=>{let A=_.runKernel(ff,v,b);return N([S,k,A,$]),p&&(A=F(A,[A.shape[1],A.shape[2],A.shape[3]])),{value:A,gradFunc:w}})(f,d,m)}const hW=z({fusedConv2d_:uW});/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -3053,7 +3053,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function fW(t,e,n,s,r,o=[1,1],i){let a=t;t.rank===3&&(a=F(t,[1,t.shape[0],t.shape[1],t.shape[2]]));let l=e;l.rank===3&&(l=F(e,[1,e.shape[0],e.shape[1],e.shape[2]]));const c={x:a,dy:l},u={strides:s,pad:r,dimRoundingMode:i,dilations:o,filterShape:n};return _.runKernel(oy,c,u)}const pW=z({depthwiseConv2dNativeBackpropFilter_:fW});/** + */function dW(t,e,n,s,r,o=[1,1],i){let a=t;t.rank===3&&(a=F(t,[1,t.shape[0],t.shape[1],t.shape[2]]));let l=e;l.rank===3&&(l=F(e,[1,e.shape[0],e.shape[1],e.shape[2]]));const c={x:a,dy:l},u={strides:s,pad:r,dimRoundingMode:i,dilations:o,filterShape:n};return _.runKernel(oy,c,u)}const fW=z({depthwiseConv2dNativeBackpropFilter_:dW});/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -3068,7 +3068,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function mW(t,e,n,s,r,o=[1,1],i){let a=e,l=!1;e.rank===3&&(l=!0,a=F(e,[1,e.shape[0],e.shape[1],e.shape[2]]));const c={dy:a,filter:n},u={strides:s,pad:r,dimRoundingMode:i,dilations:o,inputShape:t},h=_.runKernel(iy,c,u);return l?F(h,[h.shape[1],h.shape[2],h.shape[3]]):h}const gW=z({depthwiseConv2dNativeBackpropInput_:mW});/** + */function pW(t,e,n,s,r,o=[1,1],i){let a=e,l=!1;e.rank===3&&(l=!0,a=F(e,[1,e.shape[0],e.shape[1],e.shape[2]]));const c={dy:a,filter:n},u={strides:s,pad:r,dimRoundingMode:i,dilations:o,inputShape:t},h=_.runKernel(iy,c,u);return l?F(h,[h.shape[1],h.shape[2],h.shape[3]]):h}const mW=z({depthwiseConv2dNativeBackpropInput_:pW});/** * @license * Copyright 2019 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -3083,7 +3083,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function xW({a:t,b:e,transposeA:n=!1,transposeB:s=!1,bias:r,activation:o="linear",preluActivationWeights:i,leakyreluAlpha:a=.2}){if(hw(_.state.gradientDepth,o)===!1){let A=Ve(t,e,n,s);return r!=null&&(A=J(A,r)),uw(A,o,i,a)}let l=T(t,"a","fused matMul"),c=T(e,"b","fused matMul");[l,c]=It(l,c);const u=n?l.shape[l.rank-2]:l.shape[l.rank-1],h=s?c.shape[c.rank-1]:c.shape[c.rank-2],d=n?l.shape[l.rank-1]:l.shape[l.rank-2],f=s?c.shape[c.rank-2]:c.shape[c.rank-1],p=l.shape.slice(0,-2),g=c.shape.slice(0,-2),x=j(p),m=j(g);I(u===h,()=>`Error in fused matMul: inner shapes (${u}) and (${h}) of Tensors with shapes ${l.shape} and ${c.shape} and transposeA=${n} and transposeB=${s} must match.`);const w=Se(l.shape.slice(0,-2),c.shape.slice(0,-2)).concat([d,f]),v=n?F(l,[x,u,d]):F(l,[x,d,u]),b=s?F(c,[m,f,h]):F(c,[m,h,f]);let C;r!=null&&(C=T(r,"bias","fused matMul"),[C]=It(C,l),Se(w,C.shape));let k;i!=null&&(k=T(i,"prelu weights","fused matMul"));const S=(A,M)=>{const[L,V,B,U]=M,K=lw(F(A,B.shape),B,o);let R,O;if(!n&&!s?(R=Ve(K,V,!1,!0),O=Ve(L,K,!0,!1)):!n&&s?(R=Ve(K,V,!1,!1),O=Ve(K,L,!0,!1)):n&&!s?(R=Ve(V,K,!1,!0),O=Ve(L,K,!1,!1)):(R=Ve(V,K,!0,!0),O=Ve(K,L,!0,!0)),r!=null){const G=cw(U,K);return[R,O,G]}else return[R,O]},$={a:v,b,bias:C,preluActivationWeights:k},N={transposeA:n,transposeB:s,activation:o,leakyreluAlpha:a};return r==null?al((M,L,V)=>{const B=_.runKernel(ff,$,N);return V([M,L,B]),{value:F(B,w),gradFunc:S}})(v,b):al((M,L,V,B)=>{const U=_.runKernel(ff,$,N);return B([M,L,U,V]),{value:F(U,w),gradFunc:S}})(v,b,C)}const AC=z({fusedMatMul_:xW});/** + */function gW({a:t,b:e,transposeA:n=!1,transposeB:s=!1,bias:r,activation:o="linear",preluActivationWeights:i,leakyreluAlpha:a=.2}){if(hw(_.state.gradientDepth,o)===!1){let A=Ve(t,e,n,s);return r!=null&&(A=J(A,r)),uw(A,o,i,a)}let l=T(t,"a","fused matMul"),c=T(e,"b","fused matMul");[l,c]=It(l,c);const u=n?l.shape[l.rank-2]:l.shape[l.rank-1],h=s?c.shape[c.rank-1]:c.shape[c.rank-2],d=n?l.shape[l.rank-1]:l.shape[l.rank-2],f=s?c.shape[c.rank-2]:c.shape[c.rank-1],p=l.shape.slice(0,-2),g=c.shape.slice(0,-2),x=j(p),m=j(g);I(u===h,()=>`Error in fused matMul: inner shapes (${u}) and (${h}) of Tensors with shapes ${l.shape} and ${c.shape} and transposeA=${n} and transposeB=${s} must match.`);const w=Se(l.shape.slice(0,-2),c.shape.slice(0,-2)).concat([d,f]),v=n?F(l,[x,u,d]):F(l,[x,d,u]),b=s?F(c,[m,f,h]):F(c,[m,h,f]);let C;r!=null&&(C=T(r,"bias","fused matMul"),[C]=It(C,l),Se(w,C.shape));let k;i!=null&&(k=T(i,"prelu weights","fused matMul"));const S=(A,M)=>{const[L,V,B,U]=M,K=lw(F(A,B.shape),B,o);let R,O;if(!n&&!s?(R=Ve(K,V,!1,!0),O=Ve(L,K,!0,!1)):!n&&s?(R=Ve(K,V,!1,!1),O=Ve(K,L,!0,!1)):n&&!s?(R=Ve(V,K,!1,!0),O=Ve(L,K,!1,!1)):(R=Ve(V,K,!0,!0),O=Ve(K,L,!0,!0)),r!=null){const G=cw(U,K);return[R,O,G]}else return[R,O]},$={a:v,b,bias:C,preluActivationWeights:k},N={transposeA:n,transposeB:s,activation:o,leakyreluAlpha:a};return r==null?al((M,L,V)=>{const B=_.runKernel(df,$,N);return V([M,L,B]),{value:F(B,w),gradFunc:S}})(v,b):al((M,L,V,B)=>{const U=_.runKernel(df,$,N);return B([M,L,U,V]),{value:F(U,w),gradFunc:S}})(v,b,C)}const AC=z({fusedMatMul_:gW});/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -3098,7 +3098,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function yW(t,e,n,s,r="bilinear",o=0){const i=T(t,"image","cropAndResize"),a=T(e,"boxes","cropAndResize","float32"),l=T(n,"boxInd","cropAndResize","int32"),c=a.shape[0];I(i.rank===4,()=>`Error in cropAndResize: image must be rank 4,but got rank ${i.rank}.`),I(a.rank===2&&a.shape[1]===4,()=>`Error in cropAndResize: boxes must be have size [${c},4] but had shape ${a.shape}.`),I(l.rank===1&&l.shape[0]===c,()=>`Error in cropAndResize: boxInd must be have size [${c}] but had shape ${a.shape}.`),I(s.length===2,()=>`Error in cropAndResize: cropSize must be of length 2, but got length ${s.length}.`),I(s[0]>=1&&s[1]>=1,()=>`cropSize must be atleast [1,1], but was ${s}`),I(r==="bilinear"||r==="nearest",()=>`method must be bilinear or nearest, but was ${r}`);const u={image:i,boxes:a,boxInd:l},h={method:r,extrapolationValue:o,cropSize:s};return _.runKernel(ny,u,h)}const wW=z({cropAndResize_:yW});/** + */function xW(t,e,n,s,r="bilinear",o=0){const i=T(t,"image","cropAndResize"),a=T(e,"boxes","cropAndResize","float32"),l=T(n,"boxInd","cropAndResize","int32"),c=a.shape[0];I(i.rank===4,()=>`Error in cropAndResize: image must be rank 4,but got rank ${i.rank}.`),I(a.rank===2&&a.shape[1]===4,()=>`Error in cropAndResize: boxes must be have size [${c},4] but had shape ${a.shape}.`),I(l.rank===1&&l.shape[0]===c,()=>`Error in cropAndResize: boxInd must be have size [${c}] but had shape ${a.shape}.`),I(s.length===2,()=>`Error in cropAndResize: cropSize must be of length 2, but got length ${s.length}.`),I(s[0]>=1&&s[1]>=1,()=>`cropSize must be atleast [1,1], but was ${s}`),I(r==="bilinear"||r==="nearest",()=>`method must be bilinear or nearest, but was ${r}`);const u={image:i,boxes:a,boxInd:l},h={method:r,extrapolationValue:o,cropSize:s};return _.runKernel(ny,u,h)}const yW=z({cropAndResize_:xW});/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -3113,7 +3113,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function vW(t){const e=T(t,"image","flipLeftRight","float32");I(e.rank===4,()=>`Error in flipLeftRight: image must be rank 4,but got rank ${e.rank}.`);const n={image:e};return _.runKernel(hy,n,{})}const bW=z({flipLeftRight_:vW});/** + */function wW(t){const e=T(t,"image","flipLeftRight","float32");I(e.rank===4,()=>`Error in flipLeftRight: image must be rank 4,but got rank ${e.rank}.`);const n={image:e};return _.runKernel(hy,n,{})}const vW=z({flipLeftRight_:wW});/** * @license * Copyright 2021 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -3128,7 +3128,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function CW(t){const e=T(t,"image","grayscaleToRGB"),n=e.rank-1,s=e.shape[n];I(e.rank>=2,()=>`Error in grayscaleToRGB: images must be at least rank 2, but got rank ${e.rank}.`),I(s===1,()=>`Error in grayscaleToRGB: last dimension of a grayscale image should be size 1, but got size ${s}.`);const r=new Array(e.rank);return r.fill(1,0,n),r[n]=3,Hs(e,r)}const kW=z({grayscaleToRGB_:CW});/** + */function bW(t){const e=T(t,"image","grayscaleToRGB"),n=e.rank-1,s=e.shape[n];I(e.rank>=2,()=>`Error in grayscaleToRGB: images must be at least rank 2, but got rank ${e.rank}.`),I(s===1,()=>`Error in grayscaleToRGB: last dimension of a grayscale image should be size 1, but got size ${s}.`);const r=new Array(e.rank);return r.fill(1,0,n),r[n]=3,Hs(e,r)}const CW=z({grayscaleToRGB_:bW});/** * @license * Copyright 2023 Google LLC. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -3143,7 +3143,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function SW(t){const e=T(t,"image","RGBToGrayscale"),n=e.rank-1,s=e.shape[n];I(e.rank>=2,()=>`Error in RGBToGrayscale: images must be at least rank 2, but got rank ${e.rank}.`),I(s===3,()=>`Error in RGBToGrayscale: last dimension of an RGB image should be size 3, but got size ${s}.`);const r=e.dtype,o=le(e,"float32"),i=Gn([.2989,.587,.114]);let a;switch(e.rank){case 2:a=Hl("ij,j->i",o,i);break;case 3:a=Hl("ijk,k->ij",o,i);break;case 4:a=Hl("ijkl,l->ijk",o,i);break;case 5:a=Hl("ijklm,m->ijkl",o,i);break;case 6:a=Hl("ijklmn,n->ijklm",o,i);break;default:throw new Error("Not a valid tensor rank.")}return a=En(a,-1),le(a,r)}const IW=z({rgbToGrayscale_:SW});/** + */function kW(t){const e=T(t,"image","RGBToGrayscale"),n=e.rank-1,s=e.shape[n];I(e.rank>=2,()=>`Error in RGBToGrayscale: images must be at least rank 2, but got rank ${e.rank}.`),I(s===3,()=>`Error in RGBToGrayscale: last dimension of an RGB image should be size 3, but got size ${s}.`);const r=e.dtype,o=le(e,"float32"),i=Gn([.2989,.587,.114]);let a;switch(e.rank){case 2:a=Hl("ij,j->i",o,i);break;case 3:a=Hl("ijk,k->ij",o,i);break;case 4:a=Hl("ijkl,l->ijk",o,i);break;case 5:a=Hl("ijklm,m->ijkl",o,i);break;case 6:a=Hl("ijklmn,n->ijklm",o,i);break;default:throw new Error("Not a valid tensor rank.")}return a=En(a,-1),le(a,r)}const SW=z({rgbToGrayscale_:kW});/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -3158,7 +3158,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function $W(t,e,n=0,s=.5){const r=T(t,"image","rotateWithOffset","float32");I(r.rank===4,()=>`Error in rotateWithOffset: image must be rank 4,but got rank ${r.rank}.`);const o={image:r},i={radians:e,fillValue:n,center:s};return _.runKernel(Ry,o,i)}const NW=z({rotateWithOffset_:$W});/** + */function IW(t,e,n=0,s=.5){const r=T(t,"image","rotateWithOffset","float32");I(r.rank===4,()=>`Error in rotateWithOffset: image must be rank 4,but got rank ${r.rank}.`);const o={image:r},i={radians:e,fillValue:n,center:s};return _.runKernel(Ry,o,i)}const $W=z({rotateWithOffset_:IW});/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -3188,7 +3188,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function TW(t,e,n,s=.5,r=Number.NEGATIVE_INFINITY){const o=T(t,"boxes","nonMaxSuppression","float32"),i=T(e,"scores","nonMaxSuppression","float32"),a=Sl(o,i,n,s,r);n=a.maxOutputSize,s=a.iouThreshold,r=a.scoreThreshold;const l={maxOutputSize:n,iouThreshold:s,scoreThreshold:r};return _.runKernel(xy,{boxes:o,scores:i},l)}const EW=z({nonMaxSuppression_:TW});/** + */function NW(t,e,n,s=.5,r=Number.NEGATIVE_INFINITY){const o=T(t,"boxes","nonMaxSuppression","float32"),i=T(e,"scores","nonMaxSuppression","float32"),a=Sl(o,i,n,s,r);n=a.maxOutputSize,s=a.iouThreshold,r=a.scoreThreshold;const l={maxOutputSize:n,iouThreshold:s,scoreThreshold:r};return _.runKernel(xy,{boxes:o,scores:i},l)}const TW=z({nonMaxSuppression_:NW});/** * @license * Copyright 2019 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -3203,7 +3203,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function RW(t,e,n){const s=AW(t,e,n),r=s<0?-(s+1):s;t.splice(r,0,e)}function AW(t,e,n){return _W(t,e,n||DW)}function DW(t,e){return t>e?1:t>>1);const a=n(e,t[o]);a>0?s=o+1:(r=o,i=!a)}return i?s:-s-1}/** + */function EW(t,e,n){const s=RW(t,e,n),r=s<0?-(s+1):s;t.splice(r,0,e)}function RW(t,e,n){return DW(t,e,n||AW)}function AW(t,e){return t>e?1:t>>1);const a=n(e,t[o]);a>0?s=o+1:(r=o,i=!a)}return i?s:-s-1}/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -3218,7 +3218,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function dw(t,e,n,s,r){return mw(t,e,n,s,r,0)}function fw(t,e,n,s,r,o){return mw(t,e,n,s,r,0,!1,o,!0)}function pw(t,e,n,s,r,o){return mw(t,e,n,s,r,o,!0)}function mw(t,e,n,s,r,o,i=!1,a=!1,l=!1){const c=[];for(let x=0;xr&&c.push({score:e[x],boxIndex:x,suppressBeginIndex:0});c.sort(DC);const u=o>0?-.5/o:0,h=[],d=[];for(;h.length0;){const x=c.pop(),{score:m,boxIndex:y,suppressBeginIndex:w}=x;if(m=w;--b){const C=FW(t,y,h[b]);if(C>=s){v=!0;break}if(x.score=x.score*zW(s,u,C),x.score<=r)break}x.suppressBeginIndex=h.length,v||(x.score===m?(h.push(y),d.push(x.score)):x.score>r&&RW(c,x,DC))}const f=h.length,p=n-f;a&&p>0&&(h.push(...new Array(p).fill(0)),d.push(...new Array(p).fill(0)));const g={selectedIndices:h};return i&&(g.selectedScores=d),l&&(g.validOutputs=f),g}function FW(t,e,n){const s=t.subarray(e*4,e*4+4),r=t.subarray(n*4,n*4+4),o=Math.min(s[0],s[2]),i=Math.min(s[1],s[3]),a=Math.max(s[0],s[2]),l=Math.max(s[1],s[3]),c=Math.min(r[0],r[2]),u=Math.min(r[1],r[3]),h=Math.max(r[0],r[2]),d=Math.max(r[1],r[3]),f=(a-o)*(l-i),p=(h-c)*(d-u);if(f<=0||p<=0)return 0;const g=Math.max(o,c),x=Math.max(i,u),m=Math.min(a,h),y=Math.min(l,d),w=Math.max(m-g,0)*Math.max(y-x,0);return w/(f+p-w)}function zW(t,e,n){const s=Math.exp(e*n*n);return n<=t?s:0}function DC(t,e){return t.score-e.score||t.score===e.score&&e.boxIndex-t.boxIndex}/** + */function dw(t,e,n,s,r){return mw(t,e,n,s,r,0)}function fw(t,e,n,s,r,o){return mw(t,e,n,s,r,0,!1,o,!0)}function pw(t,e,n,s,r,o){return mw(t,e,n,s,r,o,!0)}function mw(t,e,n,s,r,o,i=!1,a=!1,l=!1){const c=[];for(let x=0;xr&&c.push({score:e[x],boxIndex:x,suppressBeginIndex:0});c.sort(DC);const u=o>0?-.5/o:0,h=[],d=[];for(;h.length0;){const x=c.pop(),{score:m,boxIndex:y,suppressBeginIndex:w}=x;if(m=w;--b){const C=_W(t,y,h[b]);if(C>=s){v=!0;break}if(x.score=x.score*FW(s,u,C),x.score<=r)break}x.suppressBeginIndex=h.length,v||(x.score===m?(h.push(y),d.push(x.score)):x.score>r&&EW(c,x,DC))}const f=h.length,p=n-f;a&&p>0&&(h.push(...new Array(p).fill(0)),d.push(...new Array(p).fill(0)));const g={selectedIndices:h};return i&&(g.selectedScores=d),l&&(g.validOutputs=f),g}function _W(t,e,n){const s=t.subarray(e*4,e*4+4),r=t.subarray(n*4,n*4+4),o=Math.min(s[0],s[2]),i=Math.min(s[1],s[3]),a=Math.max(s[0],s[2]),l=Math.max(s[1],s[3]),c=Math.min(r[0],r[2]),u=Math.min(r[1],r[3]),h=Math.max(r[0],r[2]),d=Math.max(r[1],r[3]),f=(a-o)*(l-i),p=(h-c)*(d-u);if(f<=0||p<=0)return 0;const g=Math.max(o,c),x=Math.max(i,u),m=Math.min(a,h),y=Math.min(l,d),w=Math.max(m-g,0)*Math.max(y-x,0);return w/(f+p-w)}function FW(t,e,n){const s=Math.exp(e*n*n);return n<=t?s:0}function DC(t,e){return t.score-e.score||t.score===e.score&&e.boxIndex-t.boxIndex}/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -3233,7 +3233,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */async function OW(t,e,n,s=.5,r=Number.NEGATIVE_INFINITY){const o=T(t,"boxes","nonMaxSuppressionAsync"),i=T(e,"scores","nonMaxSuppressionAsync"),a=Sl(o,i,n,s,r);n=a.maxOutputSize,s=a.iouThreshold,r=a.scoreThreshold;const l=await Promise.all([o.data(),i.data()]),c=l[0],u=l[1],{selectedIndices:h}=dw(c,u,n,s,r);return o!==t&&o.dispose(),i!==e&&i.dispose(),Gn(h,"int32")}const MW=OW;/** + */async function zW(t,e,n,s=.5,r=Number.NEGATIVE_INFINITY){const o=T(t,"boxes","nonMaxSuppressionAsync"),i=T(e,"scores","nonMaxSuppressionAsync"),a=Sl(o,i,n,s,r);n=a.maxOutputSize,s=a.iouThreshold,r=a.scoreThreshold;const l=await Promise.all([o.data(),i.data()]),c=l[0],u=l[1],{selectedIndices:h}=dw(c,u,n,s,r);return o!==t&&o.dispose(),i!==e&&i.dispose(),Gn(h,"int32")}const OW=zW;/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -3248,7 +3248,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function PW(t,e,n,s=.5,r=Number.NEGATIVE_INFINITY,o=0){const i=T(t,"boxes","nonMaxSuppression"),a=T(e,"scores","nonMaxSuppression"),l=Sl(i,a,n,s,r,o);n=l.maxOutputSize,s=l.iouThreshold,r=l.scoreThreshold,o=l.softNmsSigma;const c={boxes:i,scores:a},u={maxOutputSize:n,iouThreshold:s,scoreThreshold:r,softNmsSigma:o},h=_.runKernel(wy,c,u);return{selectedIndices:h[0],selectedScores:h[1]}}const LW=z({nonMaxSuppressionWithScore_:PW});/** + */function MW(t,e,n,s=.5,r=Number.NEGATIVE_INFINITY,o=0){const i=T(t,"boxes","nonMaxSuppression"),a=T(e,"scores","nonMaxSuppression"),l=Sl(i,a,n,s,r,o);n=l.maxOutputSize,s=l.iouThreshold,r=l.scoreThreshold,o=l.softNmsSigma;const c={boxes:i,scores:a},u={maxOutputSize:n,iouThreshold:s,scoreThreshold:r,softNmsSigma:o},h=_.runKernel(wy,c,u);return{selectedIndices:h[0],selectedScores:h[1]}}const PW=z({nonMaxSuppressionWithScore_:MW});/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -3263,7 +3263,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */async function BW(t,e,n,s=.5,r=Number.NEGATIVE_INFINITY,o=0){const i=T(t,"boxes","nonMaxSuppressionAsync"),a=T(e,"scores","nonMaxSuppressionAsync"),l=Sl(i,a,n,s,r,o);n=l.maxOutputSize,s=l.iouThreshold,r=l.scoreThreshold,o=l.softNmsSigma;const c=await Promise.all([i.data(),a.data()]),u=c[0],h=c[1],{selectedIndices:d,selectedScores:f}=pw(u,h,n,s,r,o);return i!==t&&i.dispose(),a!==e&&a.dispose(),{selectedIndices:Gn(d,"int32"),selectedScores:Gn(f)}}const VW=BW;/** + */async function LW(t,e,n,s=.5,r=Number.NEGATIVE_INFINITY,o=0){const i=T(t,"boxes","nonMaxSuppressionAsync"),a=T(e,"scores","nonMaxSuppressionAsync"),l=Sl(i,a,n,s,r,o);n=l.maxOutputSize,s=l.iouThreshold,r=l.scoreThreshold,o=l.softNmsSigma;const c=await Promise.all([i.data(),a.data()]),u=c[0],h=c[1],{selectedIndices:d,selectedScores:f}=pw(u,h,n,s,r,o);return i!==t&&i.dispose(),a!==e&&a.dispose(),{selectedIndices:Gn(d,"int32"),selectedScores:Gn(f)}}const BW=LW;/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -3278,7 +3278,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function WW(t,e,n,s=.5,r=Number.NEGATIVE_INFINITY,o=!1){const i=T(t,"boxes","nonMaxSuppression"),a=T(e,"scores","nonMaxSuppression"),l=Sl(i,a,n,s,r,null),c=l.maxOutputSize,u=l.iouThreshold,h=l.scoreThreshold,d={boxes:i,scores:a},f={maxOutputSize:c,iouThreshold:u,scoreThreshold:h,padToMaxOutputSize:o},p=_.runKernel(yy,d,f);return{selectedIndices:p[0],validOutputs:p[1]}}const UW=z({nonMaxSuppressionPadded_:WW});/** + */function VW(t,e,n,s=.5,r=Number.NEGATIVE_INFINITY,o=!1){const i=T(t,"boxes","nonMaxSuppression"),a=T(e,"scores","nonMaxSuppression"),l=Sl(i,a,n,s,r,null),c=l.maxOutputSize,u=l.iouThreshold,h=l.scoreThreshold,d={boxes:i,scores:a},f={maxOutputSize:c,iouThreshold:u,scoreThreshold:h,padToMaxOutputSize:o},p=_.runKernel(yy,d,f);return{selectedIndices:p[0],validOutputs:p[1]}}const WW=z({nonMaxSuppressionPadded_:VW});/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -3293,7 +3293,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */async function GW(t,e,n,s=.5,r=Number.NEGATIVE_INFINITY,o=!1){const i=T(t,"boxes","nonMaxSuppressionAsync"),a=T(e,"scores","nonMaxSuppressionAsync"),l=Sl(i,a,n,s,r,null),c=l.maxOutputSize,u=l.iouThreshold,h=l.scoreThreshold,[d,f]=await Promise.all([i.data(),a.data()]),{selectedIndices:p,validOutputs:g}=fw(d,f,c,u,h,o);return i!==t&&i.dispose(),a!==e&&a.dispose(),{selectedIndices:Gn(p,"int32"),validOutputs:We(g,"int32")}}const HW=GW;/** + */async function UW(t,e,n,s=.5,r=Number.NEGATIVE_INFINITY,o=!1){const i=T(t,"boxes","nonMaxSuppressionAsync"),a=T(e,"scores","nonMaxSuppressionAsync"),l=Sl(i,a,n,s,r,null),c=l.maxOutputSize,u=l.iouThreshold,h=l.scoreThreshold,[d,f]=await Promise.all([i.data(),a.data()]),{selectedIndices:p,validOutputs:g}=fw(d,f,c,u,h,o);return i!==t&&i.dispose(),a!==e&&a.dispose(),{selectedIndices:Gn(p,"int32"),validOutputs:We(g,"int32")}}const GW=UW;/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -3308,7 +3308,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function jW(t,e,n=!1,s=!1){const r=T(t,"images","resizeBilinear");I(r.rank===3||r.rank===4,()=>`Error in resizeBilinear: x must be rank 3 or 4, but got rank ${r.rank}.`),I(e.length===2,()=>`Error in resizeBilinear: new shape must 2D, but got shape ${e}.`),I(s===!1||n===!1,()=>"Error in resizeBilinear: If halfPixelCenters is true, alignCorners must be false.");let o=r,i=!1;r.rank===3&&(i=!0,o=F(r,[1,r.shape[0],r.shape[1],r.shape[2]]));const a={images:o},l={alignCorners:n,halfPixelCenters:s,size:e},c=_.runKernel(sm,a,l);return i?F(c,[c.shape[1],c.shape[2],c.shape[3]]):c}const IN=z({resizeBilinear_:jW});/** + */function HW(t,e,n=!1,s=!1){const r=T(t,"images","resizeBilinear");I(r.rank===3||r.rank===4,()=>`Error in resizeBilinear: x must be rank 3 or 4, but got rank ${r.rank}.`),I(e.length===2,()=>`Error in resizeBilinear: new shape must 2D, but got shape ${e}.`),I(s===!1||n===!1,()=>"Error in resizeBilinear: If halfPixelCenters is true, alignCorners must be false.");let o=r,i=!1;r.rank===3&&(i=!0,o=F(r,[1,r.shape[0],r.shape[1],r.shape[2]]));const a={images:o},l={alignCorners:n,halfPixelCenters:s,size:e},c=_.runKernel(sm,a,l);return i?F(c,[c.shape[1],c.shape[2],c.shape[3]]):c}const IN=z({resizeBilinear_:HW});/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -3323,7 +3323,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function KW(t,e,n=!1,s=!1){const r=T(t,"images","resizeNearestNeighbor");I(r.rank===3||r.rank===4,()=>`Error in resizeNearestNeighbor: x must be rank 3 or 4, but got rank ${r.rank}.`),I(e.length===2,()=>`Error in resizeNearestNeighbor: new shape must 2D, but got shape ${e}.`),I(r.dtype==="float32"||r.dtype==="int32",()=>"`images` must have `int32` or `float32` as dtype"),I(s===!1||n===!1,()=>"Error in resizeNearestNeighbor: If halfPixelCenters is true, alignCorners must be false.");let o=r,i=!1;r.rank===3&&(i=!0,o=F(r,[1,r.shape[0],r.shape[1],r.shape[2]]));const a={images:o},l={alignCorners:n,halfPixelCenters:s,size:e},c=_.runKernel(nm,a,l);return i?F(c,[c.shape[1],c.shape[2],c.shape[3]]):c}const $N=z({resizeNearestNeighbor_:KW});/** + */function jW(t,e,n=!1,s=!1){const r=T(t,"images","resizeNearestNeighbor");I(r.rank===3||r.rank===4,()=>`Error in resizeNearestNeighbor: x must be rank 3 or 4, but got rank ${r.rank}.`),I(e.length===2,()=>`Error in resizeNearestNeighbor: new shape must 2D, but got shape ${e}.`),I(r.dtype==="float32"||r.dtype==="int32",()=>"`images` must have `int32` or `float32` as dtype"),I(s===!1||n===!1,()=>"Error in resizeNearestNeighbor: If halfPixelCenters is true, alignCorners must be false.");let o=r,i=!1;r.rank===3&&(i=!0,o=F(r,[1,r.shape[0],r.shape[1],r.shape[2]]));const a={images:o},l={alignCorners:n,halfPixelCenters:s,size:e},c=_.runKernel(nm,a,l);return i?F(c,[c.shape[1],c.shape[2],c.shape[3]]):c}const $N=z({resizeNearestNeighbor_:jW});/** * @license * Copyright 2021 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -3338,7 +3338,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function XW(t,e="binary",n=!1,s=.5){const r=T(t,"image","threshold"),o=.2989,i=.587,a=.114,l=r.shape[0]*r.shape[1];let c=D(Gn([s]),255),u,h,d,f;if(I(r.rank===3,()=>`Error in threshold: image must be rank 3,but got rank ${r.rank}.`),I(r.shape[2]===3||r.shape[2]===1,()=>`Error in threshold: image color channel must be equal to 3 or 1but got ${r.shape[2]}.`),I(r.dtype==="int32"||r.dtype==="float32",()=>`Error in dtype: image dtype must be int32 or float32,but got dtype ${r.dtype}.`),I(e==="otsu"||e==="binary",()=>`Method must be binary or otsu, but was ${e}`),r.shape[2]===3){[u,h,d]=rs(r,[1,1,1],-1);const x=D(u,o),m=D(h,i),y=D(d,a);f=J(J(x,m),y)}else f=t;if(e==="otsu"){const x=jL(le(fN(f),"int32"),bc([]),256);c=qW(x,l)}const p=n?kl(f,c):us(f,c);return le(D(p,255),"int32")}function qW(t,e){let n=Gn([-1]),s=Gn([0]),r=Gn([0]),o,i,a,l,c,u;for(let h=0;h`Error in threshold: image must be rank 3,but got rank ${r.rank}.`),I(r.shape[2]===3||r.shape[2]===1,()=>`Error in threshold: image color channel must be equal to 3 or 1but got ${r.shape[2]}.`),I(r.dtype==="int32"||r.dtype==="float32",()=>`Error in dtype: image dtype must be int32 or float32,but got dtype ${r.dtype}.`),I(e==="otsu"||e==="binary",()=>`Method must be binary or otsu, but was ${e}`),r.shape[2]===3){[u,h,d]=rs(r,[1,1,1],-1);const x=D(u,o),m=D(h,i),y=D(d,a);f=J(J(x,m),y)}else f=t;if(e==="otsu"){const x=HL(le(fN(f),"int32"),bc([]),256);c=XW(x,l)}const p=n?kl(f,c):us(f,c);return le(D(p,255),"int32")}function XW(t,e){let n=Gn([-1]),s=Gn([0]),r=Gn([0]),o,i,a,l,c,u;for(let h=0;h`Error in transform: image must be rank 4,but got rank ${i.rank}.`),I(a.rank===2&&(a.shape[0]===i.shape[0]||a.shape[0]===1)&&a.shape[1]===8,()=>"Error in transform: Input transform should be batch x 8 or 1 x 8"),I(o==null||o.length===2,()=>`Error in transform: outputShape must be [height, width] or null, but got ${o}.`);const l={image:i,transforms:a},c={interpolation:n,fillMode:s,fillValue:r,outputShape:o};return _.runKernel(Ty,l,c)}const ZW=z({transform_:QW});/** + */function YW(t,e,n="nearest",s="constant",r=0,o){const i=T(t,"image","transform","float32"),a=T(e,"transforms","transform","float32");I(i.rank===4,()=>`Error in transform: image must be rank 4,but got rank ${i.rank}.`),I(a.rank===2&&(a.shape[0]===i.shape[0]||a.shape[0]===1)&&a.shape[1]===8,()=>"Error in transform: Input transform should be batch x 8 or 1 x 8"),I(o==null||o.length===2,()=>`Error in transform: outputShape must be [height, width] or null, but got ${o}.`);const l={image:i,transforms:a},c={interpolation:n,fillMode:s,fillValue:r,outputShape:o};return _.runKernel(Ty,l,c)}const QW=z({transform_:YW});/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -3368,7 +3368,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function JW(t,e,n){const s=T(t,"a","bandPart");I(s.rank>=2,()=>`bandPart(): Rank must be at least 2, got ${s.rank}.`);const r=s.shape,[o,i]=s.shape.slice(-2);let a,l;typeof e=="number"?(I(e%1===0,()=>`bandPart(): numLower must be an integer, got ${e}.`),I(e<=o,()=>`bandPart(): numLower (${e}) must not be greater than the number of rows (${o}).`),a=T(e<0?o:e,"numLower","bandPart")):(I(e.dtype==="int32",()=>"bandPart(): numLower's dtype must be an int32."),a=Cn(vf(e,0),o,Xc(e,o))),typeof n=="number"?(I(n%1===0,()=>`bandPart(): numUpper must be an integer, got ${n}.`),I(n<=i,()=>`bandPart(): numUpper (${n}) must not be greater than the number of columns (${i}).`),l=T(n<0?i:n,"numUpper","bandPart")):(I(n.dtype==="int32",()=>"bandPart(): numUpper's dtype must be an int32."),l=Cn(vf(n,0),i,Xc(n,i)));const c=F(qc(0,o,1,"int32"),[-1,1]),u=qc(0,i,1,"int32"),h=ve(c,u),d=Gr(kl(h,a),Xi(h,St(l))),f=Kt([o,i],s.dtype);return F(Hr(Pi(F(s,[-1,o,i])).map(p=>Cn(d,p,f))),r)}const eU=z({bandPart_:JW});/** + */function ZW(t,e,n){const s=T(t,"a","bandPart");I(s.rank>=2,()=>`bandPart(): Rank must be at least 2, got ${s.rank}.`);const r=s.shape,[o,i]=s.shape.slice(-2);let a,l;typeof e=="number"?(I(e%1===0,()=>`bandPart(): numLower must be an integer, got ${e}.`),I(e<=o,()=>`bandPart(): numLower (${e}) must not be greater than the number of rows (${o}).`),a=T(e<0?o:e,"numLower","bandPart")):(I(e.dtype==="int32",()=>"bandPart(): numLower's dtype must be an int32."),a=Cn(wf(e,0),o,Xc(e,o))),typeof n=="number"?(I(n%1===0,()=>`bandPart(): numUpper must be an integer, got ${n}.`),I(n<=i,()=>`bandPart(): numUpper (${n}) must not be greater than the number of columns (${i}).`),l=T(n<0?i:n,"numUpper","bandPart")):(I(n.dtype==="int32",()=>"bandPart(): numUpper's dtype must be an int32."),l=Cn(wf(n,0),i,Xc(n,i)));const c=F(qc(0,o,1,"int32"),[-1,1]),u=qc(0,i,1,"int32"),h=ve(c,u),d=Gr(kl(h,a),Xi(h,St(l))),f=Kt([o,i],s.dtype);return F(Hr(Pi(F(s,[-1,o,i])).map(p=>Cn(d,p,f))),r)}const JW=z({bandPart_:ZW});/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -3383,7 +3383,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function tU(t){let e;if(Array.isArray(t)){e=!1,I(t!=null&&t.length>0,()=>"Gram-Schmidt process: input must not be null, undefined, or empty");const r=t[0].shape[0];for(let o=1;o`Gram-Schmidt: Non-unique lengths found in the input vectors: (${t[o].shape[0]} vs. ${r})`)}else e=!0,t=rs(t,t.shape[0],0).map(r=>ph(r,[0]));I(t.length<=t[0].shape[0],()=>`Gram-Schmidt: Number of vectors (${t.length}) exceeds number of dimensions (${t[0].shape[0]}).`);const n=[],s=t;for(let r=0;r{let o=s[r];if(r>0)for(let i=0;i0,()=>"Gram-Schmidt process: input must not be null, undefined, or empty");const r=t[0].shape[0];for(let o=1;o`Gram-Schmidt: Non-unique lengths found in the input vectors: (${t[o].shape[0]} vs. ${r})`)}else e=!0,t=rs(t,t.shape[0],0).map(r=>fh(r,[0]));I(t.length<=t[0].shape[0],()=>`Gram-Schmidt: Number of vectors (${t.length}) exceeds number of dimensions (${t[0].shape[0]}).`);const n=[],s=t;for(let r=0;r{let o=s[r];if(r>0)for(let i=0;i=2,()=>`qr() requires input tensor to have a rank >= 2, but got rank ${t.rank}`),t.rank===2)return _C(t,e);{const n=t.shape.slice(0,t.shape.length-2).reduce((l,c)=>l*c),s=Pi(F(t,[n,t.shape[t.shape.length-2],t.shape[t.shape.length-1]]),0),r=[],o=[];s.forEach(l=>{const[c,u]=_C(l,e);r.push(c),o.push(u)});const i=F(Hr(r,0),t.shape),a=F(Hr(o,0),t.shape);return[i,a]}}function _C(t,e=!1){return _.tidy(()=>{I(t.shape.length===2,()=>`qr2d() requires a 2D Tensor, but got a ${t.shape.length}D Tensor.`);const n=t.shape[0],s=t.shape[1];let r=rN(n),o=vi(t);const i=Sg([[1]],[1,1]);let a=vi(i);const l=n>=s?s:n;for(let c=0;c{const f=tt(o,[c,c],[n-c,1]),p=wm(f),g=tt(o,[c,c],[1,1]),x=Cn(us(g,0),Sg([[-1]]),Sg([[1]])),m=ve(g,D(x,p)),y=ge(f,m);y.shape[0]===1?a=vi(i):a=Dn([i,tt(y,[1,0],[y.shape[0]-1,y.shape[1]])],0);const w=St(ge(Ve(x,m),p)),v=tt(o,[c,0],[n-c,s]),b=D(w,a),C=Fe(a);if(c===0)o=ve(v,Ve(b,Ve(C,v)));else{const $=ve(v,Ve(b,Ve(C,v)));o=Dn([tt(o,[0,0],[c,s]),$],0)}const k=Fe(b),S=tt(r,[0,c],[n,r.shape[1]-c]);if(c===0)r=ve(S,Ve(Ve(S,a),k));else{const $=ve(S,Ve(Ve(S,a),k));r=Dn([tt(r,[0,0],[n,c]),$],1)}return[a,o,r]}),$e([u,h,d])}return!e&&n>s&&(r=tt(r,[0,0],[n,s]),o=tt(o,[0,0],[s,s])),[r,o]})}const rU=z({qr_:sU});/** + */function nU(t,e=!1){if(I(t.rank>=2,()=>`qr() requires input tensor to have a rank >= 2, but got rank ${t.rank}`),t.rank===2)return _C(t,e);{const n=t.shape.slice(0,t.shape.length-2).reduce((l,c)=>l*c),s=Pi(F(t,[n,t.shape[t.shape.length-2],t.shape[t.shape.length-1]]),0),r=[],o=[];s.forEach(l=>{const[c,u]=_C(l,e);r.push(c),o.push(u)});const i=F(Hr(r,0),t.shape),a=F(Hr(o,0),t.shape);return[i,a]}}function _C(t,e=!1){return _.tidy(()=>{I(t.shape.length===2,()=>`qr2d() requires a 2D Tensor, but got a ${t.shape.length}D Tensor.`);const n=t.shape[0],s=t.shape[1];let r=rN(n),o=vi(t);const i=Sg([[1]],[1,1]);let a=vi(i);const l=n>=s?s:n;for(let c=0;c{const f=tt(o,[c,c],[n-c,1]),p=wm(f),g=tt(o,[c,c],[1,1]),x=Cn(us(g,0),Sg([[-1]]),Sg([[1]])),m=ve(g,D(x,p)),y=ge(f,m);y.shape[0]===1?a=vi(i):a=Dn([i,tt(y,[1,0],[y.shape[0]-1,y.shape[1]])],0);const w=St(ge(Ve(x,m),p)),v=tt(o,[c,0],[n-c,s]),b=D(w,a),C=Fe(a);if(c===0)o=ve(v,Ve(b,Ve(C,v)));else{const $=ve(v,Ve(b,Ve(C,v)));o=Dn([tt(o,[0,0],[c,s]),$],0)}const k=Fe(b),S=tt(r,[0,c],[n,r.shape[1]-c]);if(c===0)r=ve(S,Ve(Ve(S,a),k));else{const $=ve(S,Ve(Ve(S,a),k));r=Dn([tt(r,[0,0],[n,c]),$],1)}return[a,o,r]}),$e([u,h,d])}return!e&&n>s&&(r=tt(r,[0,0],[n,s]),o=tt(o,[0,0],[s,s])),[r,o]})}const sU=z({qr_:nU});/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -3413,7 +3413,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const Mr={flipLeftRight:bW,grayscaleToRGB:kW,resizeNearestNeighbor:$N,resizeBilinear:IN,rgbToGrayscale:IW,rotateWithOffset:NW,cropAndResize:wW,nonMaxSuppression:EW,nonMaxSuppressionAsync:MW,nonMaxSuppressionWithScore:LW,nonMaxSuppressionWithScoreAsync:VW,nonMaxSuppressionPadded:UW,nonMaxSuppressionPaddedAsync:HW,threshold:YW,transform:ZW},oU={bandPart:eU,gramSchmidt:nU,qr:rU};/** + */const Mr={flipLeftRight:vW,grayscaleToRGB:CW,resizeNearestNeighbor:$N,resizeBilinear:IN,rgbToGrayscale:SW,rotateWithOffset:$W,cropAndResize:yW,nonMaxSuppression:TW,nonMaxSuppressionAsync:OW,nonMaxSuppressionWithScore:PW,nonMaxSuppressionWithScoreAsync:BW,nonMaxSuppressionPadded:WW,nonMaxSuppressionPaddedAsync:GW,threshold:qW,transform:QW},rU={bandPart:JW,gramSchmidt:tU,qr:sU};/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -3428,7 +3428,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const iU=new Map,aU=new Map;class Il{getClassName(){return this.constructor.className}static fromConfig(e,n){return new e(n)}}class xs{constructor(){this.classNameMap={}}static getMap(){return xs.instance==null&&(xs.instance=new xs),xs.instance}static register(e){xs.getMap().classNameMap[e.className]=[e,e.fromConfig]}}function Y(t,e,n){I(t.className!=null,()=>"Class being registered does not have the static className property defined."),I(typeof t.className=="string",()=>"className is required to be a string, but got type "+typeof t.className),I(t.className.length>0,()=>"Class being registered has an empty-string as its className, which is disallowed."),typeof e>"u"&&(e="Custom"),typeof n>"u"&&(n=t.className);const s=n,r=e+">"+s;return xs.register(t),iU.set(r,t),aU.set(t,r),t}/** + */const oU=new Map,iU=new Map;class Il{getClassName(){return this.constructor.className}static fromConfig(e,n){return new e(n)}}class xs{constructor(){this.classNameMap={}}static getMap(){return xs.instance==null&&(xs.instance=new xs),xs.instance}static register(e){xs.getMap().classNameMap[e.className]=[e,e.fromConfig]}}function Y(t,e,n){I(t.className!=null,()=>"Class being registered does not have the static className property defined."),I(typeof t.className=="string",()=>"className is required to be a string, but got type "+typeof t.className),I(t.className.length>0,()=>"Class being registered has an empty-string as its className, which is disallowed."),typeof e>"u"&&(e="Custom"),typeof n>"u"&&(n=t.className);const s=n,r=e+">"+s;return xs.register(t),oU.set(r,t),iU.set(t,r),t}/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -3443,7 +3443,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */class Xo extends Il{minimize(e,n=!1,s){const{value:r,grads:o}=this.computeGradients(e,s);if(s!=null){const i=s.map(a=>({name:a.name,tensor:o[a.name]}));this.applyGradients(i)}else this.applyGradients(o);return $e(o),n?r:(r.dispose(),null)}get iterations(){return this.iterations_==null&&(this.iterations_=0),this.iterations_}incrementIterations(){this.iterations_=this.iterations+1}computeGradients(e,n){return fB(e,n)}dispose(){this.iterations_!=null&&$e(this.iterations_)}async saveIterations(){return this.iterations_==null&&(this.iterations_=0),{name:"iter",tensor:We(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(Xo,Symbol.hasInstance,{value:t=>t.minimize!=null&&t.computeGradients!=null&&t.applyGradients!=null});/** + */class Xo extends Il{minimize(e,n=!1,s){const{value:r,grads:o}=this.computeGradients(e,s);if(s!=null){const i=s.map(a=>({name:a.name,tensor:o[a.name]}));this.applyGradients(i)}else this.applyGradients(o);return $e(o),n?r:(r.dispose(),null)}get iterations(){return this.iterations_==null&&(this.iterations_=0),this.iterations_}incrementIterations(){this.iterations_=this.iterations+1}computeGradients(e,n){return dB(e,n)}dispose(){this.iterations_!=null&&$e(this.iterations_)}async saveIterations(){return this.iterations_==null&&(this.iterations_=0),{name:"iter",tensor:We(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(Xo,Symbol.hasInstance,{value:t=>t.minimize!=null&&t.computeGradients!=null&&t.applyGradients!=null});/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -3563,7 +3563,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const lU=[NN,TN,EN,RN,AN,DN,gw];function cU(){for(const t of lU)Y(t)}/** + */const aU=[NN,TN,EN,RN,AN,DN,gw];function lU(){for(const t of aU)Y(t)}/** * @license * Copyright 2019 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -3593,7 +3593,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */async function uU(t,e){e==null&&(e={});const n=e.fetchFunc==null?W().platform.fetch:e.fetchFunc,s=t.map(h=>n(h,e.requestInit,{isBinary:!0})),a=(e.onProgress==null?await Promise.all(s):await FC(s,e.onProgress,0,.5)).map(h=>h.arrayBuffer());return e.onProgress==null?await Promise.all(a):await FC(a,e.onProgress,.5,1)}function hU(t,e){var n;const s=e.fetchFunc==null?W().platform.fetch:e.fetchFunc;let r=0,o;return(n=e.onProgress)===null||n===void 0||n.call(e,0),new ReadableStream({pull:async i=>{for(var a;rn(h,e.requestInit,{isBinary:!0})),a=(e.onProgress==null?await Promise.all(s):await FC(s,e.onProgress,0,.5)).map(h=>h.arrayBuffer());return e.onProgress==null?await Promise.all(a):await FC(a,e.onProgress,.5,1)}function uU(t,e){var n;const s=e.fetchFunc==null?W().platform.fetch:e.fetchFunc;let r=0,o;return(n=e.onProgress)===null||n===void 0||n.call(e,0),new ReadableStream({pull:async i=>{for(var a;r"Must pass a function that matches the signature of `fetch` (see https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API)"),this.fetch=n.fetchFunc):this.fetch=W().platform.fetch,I(e!=null&&e.length>0,()=>"URL path for http must not be null, undefined or empty."),Array.isArray(e)&&I(e.length===2,()=>`URL paths for http must have a length of 2, (actual length is ${e.length}).`),this.path=e,n.requestInit!=null&&n.requestInit.body!=null)throw new Error("requestInit is expected to have no pre-existing body, but has one.");this.requestInit=n.requestInit||{},this.loadOptions=n}async save(e){if(e.modelTopology instanceof ArrayBuffer)throw new Error("BrowserHTTPRequest.save() does not support saving model topology in binary formats yet.");const n=Object.assign({method:this.DEFAULT_METHOD},this.requestInit);n.body=new FormData;const s=[{paths:["./model.weights.bin"],weights:e.weightSpecs}],r=$P(e,s);if(n.body.append("model.json",new Blob([JSON.stringify(r)],{type:fU}),"model.json"),e.weightData!=null){const i=Uo.join(e.weightData);n.body.append("model.weights.bin",new Blob([i],{type:dU}),"model.weights.bin")}const o=await this.fetch(this.path,n);if(o.ok)return{modelArtifactsInfo:Fy(e),responses:[o]};throw new Error(`BrowserHTTPRequest.save() failed due to HTTP response status ${o.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 n;try{n=await e.json()}catch{let i=`Failed to parse model JSON of response from ${this.path}.`;throw this.path.endsWith(".pb")?i+=" 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.":i+=" Please make sure the server is serving valid JSON for this request.",new Error(i)}const s=n.modelTopology,r=n.weightsManifest;if(s==null&&r==null)throw new Error(`The JSON from HTTP path ${this.path} contains neither model topology or manifest for weights.`);return n}async load(){if(this.loadOptions.streamWeights)return this.loadStream();const e=await this.loadModelJSON();return TP(e,n=>this.loadWeights(n))}async loadStream(){const e=await this.loadModelJSON(),n=await this.getWeightUrls(e.weightsManifest),s=TC(e.weightsManifest),r=()=>hU(n,this.loadOptions);return Object.assign(Object.assign({},e),{weightSpecs:s,getWeightStream:r})}async getWeightUrls(e){const n=Array.isArray(this.path)?this.path[1]:this.path,[s,r]=pU(n),o=this.weightPathPrefix||s,i=[],a=[];for(const l of e)for(const c of l.paths)this.weightUrlConverter!=null?a.push(this.weightUrlConverter(c)):i.push(o+c+r);return this.weightUrlConverter&&i.push(...await Promise.all(a)),i}async loadWeights(e){const n=await this.getWeightUrls(e),s=TC(e),r=await uU(n,this.loadOptions);return[s,r]}}xw.URL_SCHEME_REGEX=/^https?:\/\//;function pU(t){const e=t.lastIndexOf("/"),n=t.lastIndexOf("?"),s=t.substring(0,e),r=n>e?t.substring(n):"";return[s+"/",r]}function zC(t){return t.match(xw.URL_SCHEME_REGEX)!=null}const _N=(t,e)=>{if(typeof fetch>"u"&&(e==null||e.fetchFunc==null))return null;{let n=!0;if(Array.isArray(t)?n=t.every(s=>zC(s)):n=zC(t),n)return FN(t,e)}return null};Gt.registerSaveRouter(_N);Gt.registerLoadRouter(_N);function FN(t,e){return new xw(t,e)}function mU(t,e){return FN(t,e)}function yw(t,e){const n=t.shape.length,s=e.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(s<1)throw new Error(`tf.gatherND() expects the indices to be rank 1 or higher, but the rank was ${s}.`);if(e.dtype!=="int32")throw new Error(`tf.gatherND() expects the indices to be int32 type, but the dtype was ${e.dtype}.`);if(e.shape[s-1]>n)throw new Error(`index innermost dimension length must be <= tensor rank; saw: ${e.shape[s-1]} vs. ${n}`);if(j(t.shape)===0)throw new Error(`Requested more than 0 entries, but input is empty. Input shape: ${t.shape}.`);const r=e.shape,o=r[r.length-1];let i=1;for(let h=0;hh/c),1].slice(0,o);return[l,i,c,u]}/** + */const hU="application/octet-stream",dU="application/json";class xw{constructor(e,n){if(this.DEFAULT_METHOD="POST",n==null&&(n={}),this.weightPathPrefix=n.weightPathPrefix,this.weightUrlConverter=n.weightUrlConverter,n.fetchFunc!=null?(I(typeof n.fetchFunc=="function",()=>"Must pass a function that matches the signature of `fetch` (see https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API)"),this.fetch=n.fetchFunc):this.fetch=W().platform.fetch,I(e!=null&&e.length>0,()=>"URL path for http must not be null, undefined or empty."),Array.isArray(e)&&I(e.length===2,()=>`URL paths for http must have a length of 2, (actual length is ${e.length}).`),this.path=e,n.requestInit!=null&&n.requestInit.body!=null)throw new Error("requestInit is expected to have no pre-existing body, but has one.");this.requestInit=n.requestInit||{},this.loadOptions=n}async save(e){if(e.modelTopology instanceof ArrayBuffer)throw new Error("BrowserHTTPRequest.save() does not support saving model topology in binary formats yet.");const n=Object.assign({method:this.DEFAULT_METHOD},this.requestInit);n.body=new FormData;const s=[{paths:["./model.weights.bin"],weights:e.weightSpecs}],r=IP(e,s);if(n.body.append("model.json",new Blob([JSON.stringify(r)],{type:dU}),"model.json"),e.weightData!=null){const i=Uo.join(e.weightData);n.body.append("model.weights.bin",new Blob([i],{type:hU}),"model.weights.bin")}const o=await this.fetch(this.path,n);if(o.ok)return{modelArtifactsInfo:Fy(e),responses:[o]};throw new Error(`BrowserHTTPRequest.save() failed due to HTTP response status ${o.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 n;try{n=await e.json()}catch{let i=`Failed to parse model JSON of response from ${this.path}.`;throw this.path.endsWith(".pb")?i+=" 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.":i+=" Please make sure the server is serving valid JSON for this request.",new Error(i)}const s=n.modelTopology,r=n.weightsManifest;if(s==null&&r==null)throw new Error(`The JSON from HTTP path ${this.path} contains neither model topology or manifest for weights.`);return n}async load(){if(this.loadOptions.streamWeights)return this.loadStream();const e=await this.loadModelJSON();return NP(e,n=>this.loadWeights(n))}async loadStream(){const e=await this.loadModelJSON(),n=await this.getWeightUrls(e.weightsManifest),s=TC(e.weightsManifest),r=()=>uU(n,this.loadOptions);return Object.assign(Object.assign({},e),{weightSpecs:s,getWeightStream:r})}async getWeightUrls(e){const n=Array.isArray(this.path)?this.path[1]:this.path,[s,r]=fU(n),o=this.weightPathPrefix||s,i=[],a=[];for(const l of e)for(const c of l.paths)this.weightUrlConverter!=null?a.push(this.weightUrlConverter(c)):i.push(o+c+r);return this.weightUrlConverter&&i.push(...await Promise.all(a)),i}async loadWeights(e){const n=await this.getWeightUrls(e),s=TC(e),r=await cU(n,this.loadOptions);return[s,r]}}xw.URL_SCHEME_REGEX=/^https?:\/\//;function fU(t){const e=t.lastIndexOf("/"),n=t.lastIndexOf("?"),s=t.substring(0,e),r=n>e?t.substring(n):"";return[s+"/",r]}function zC(t){return t.match(xw.URL_SCHEME_REGEX)!=null}const _N=(t,e)=>{if(typeof fetch>"u"&&(e==null||e.fetchFunc==null))return null;{let n=!0;if(Array.isArray(t)?n=t.every(s=>zC(s)):n=zC(t),n)return FN(t,e)}return null};Gt.registerSaveRouter(_N);Gt.registerLoadRouter(_N);function FN(t,e){return new xw(t,e)}function pU(t,e){return FN(t,e)}function yw(t,e){const n=t.shape.length,s=e.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(s<1)throw new Error(`tf.gatherND() expects the indices to be rank 1 or higher, but the rank was ${s}.`);if(e.dtype!=="int32")throw new Error(`tf.gatherND() expects the indices to be int32 type, but the dtype was ${e.dtype}.`);if(e.shape[s-1]>n)throw new Error(`index innermost dimension length must be <= tensor rank; saw: ${e.shape[s-1]} vs. ${n}`);if(j(t.shape)===0)throw new Error(`Requested more than 0 entries, but input is empty. Input shape: ${t.shape}.`);const r=e.shape,o=r[r.length-1];let i=1;for(let h=0;hh/c),1].slice(0,o);return[l,i,c,u]}/** * @license * Copyright 2021 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -3623,7 +3623,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const p1=-2,gU=-1;function ww(t,e,n){const s=t.shape.length;I(s===e.length,()=>`Error in slice${s}D: Length of begin ${e} must match the rank of the array (${s}).`),I(s===n.length,()=>`Error in slice${s}D: Length of size ${n} must match the rank of the array (${s}).`);for(let r=0;r`Error in slice${s}D: begin[${r}] + size[${r}] (${e[r]+n[r]}) would overflow input.shape[${r}] (${t.shape[r]})`)}function xU(t){const e=[];let n=0;for(;t>0;)t&1&&e.push(n),t/=2,n++;return e}function vw(t,e,n){const s=[];for(let r=0;r0){const f=e[0],p=n+1;u=PN(i,f,p,s,t),h=LN(a,f,p,r,t),d=zN(o,f,p,t)}else for(let f=0;f-1)o[a]=0;else{const l=ON(e,n,a);let c=s[l];t&1<-1)o[a]=Number.MAX_SAFE_INTEGER;else{const l=ON(e,n,a);let c=s[l];t&1<0?i=Number.MIN_SAFE_INTEGER:i=Number.MAX_SAFE_INTEGER);const l=s[r];return i<0&&(i+=l),i=Ti(0,i,l-1),i}function WN(t,e,n,s,r,o){let i=e[r];const a=n[r]||1;(t&1<0?i=Number.MAX_SAFE_INTEGER:i=Number.MIN_SAFE_INTEGER);const l=s[r];return i<0&&(i+=l),a>0?i=Ti(0,i,l):i=Ti(-1,i,l-1),i}function bw(t,e,n){let s=n.length;for(let r=0;r1){s=r;break}for(let r=s+1;r0||n[r]!==t[r])return!1;return!0}function Cw(t,e){let n=t.length>0?t[t.length-1]:1;for(let s=0;s{I(i!==-1,()=>"slice() does not support negative begin indexing.")});let o;return n==null?o=new Array(r).fill(-1):typeof n=="number"?o=[n,...new Array(r-1).fill(-1)]:n.lengthi>=0?i:(I(i===-1,()=>`Negative size values should be exactly -1 but got ${i} for the slice() size at index ${a}.`),t.shape[a]-s[a])),[s,o]}function kw(t,e,n,s,r,o,i,a,l){let c;if(s==null?(c=new Array(e.length),c.fill(1)):c=s,i!=null&&i&i-1)throw new Error("Multiple ellipses in slice is not allowed.");let u=!1;const h={dims:c.length,numAddAxisAfterEllipsis:0,begin:e.slice(),end:n.slice(),strides:c.slice(),beginMask:r,endMask:o,ellipsisMask:i,newAxisMask:a,shrinkAxisMask:l};for(let w=0;w0?0:-1,d.strides[w]>0?b:b-1];if(v&&d.strides[w]<=0)throw Error("only stride 1 allowed on non-range indexing.");g=g&&d.strides[w]===1;const S=!!(d.beginMask&1<=b)throw Error(`slice index ${d.begin[w]} of dimension ${w} out of bounds.`)}else d.begin[w]=OC(d.begin[w],0,d.strides[w],b,C,k),d.end[w]=OC(d.end[w],1,d.strides[w],b,C,k);const A=d.strides[w]===1&&d.begin[w]===0&&d.end[w]===b;f=f&&A,p=p&&(w===0&&d.strides[w]===1||A)}else f=f&&d.strides[w]===1&&S,p=p&&(w===0&&d.strides[w]===1||S);let $,N=!1;if(d.beginValid&&d.endValid?($=d.end[w]-d.begin[w],N=!0):v?($=1,N=!0):S&&b>=0&&(d.strides[w]<0?$=-b:$=b,N=!0),N){let A;$===0||$<0!=d.strides[w]<0?A=0:A=Math.trunc($/d.strides[w])+($%d.strides[w]!==0?1:0),x.push(A)}else x.push(-1)}for(let w=0;w=0?m.push(x[v]):v===p1&&m.push(1)}return{finalShapeSparse:m.filter((w,v)=>d.finalShapeGatherIndices[v]!==p1),finalShape:m,isIdentity:f,sliceDim0:p,isSimpleSlice:g,begin:d.begin,end:d.end,strides:d.strides}}function wU(t,e){e.beginMask=0,e.endMask=0,e.shrinkAxisMask=0;let n=0;e.beginValid=t.begin!=null,e.endValid=t.end!=null,e.begin=new Array(e.dims),e.end=new Array(e.dims),e.strides=new Array(e.dims),e.finalShapeGatherIndices=[],e.finalShapeGatherIndicesSparse=[],e.inputShapeGatherIndicesSparse=new Array(e.dims);for(let s=0;s0?o[e]:o[e+1&1];{const i=t<0?s+t:t;return io[1]?o[1]:i}}const vU=Object.freeze(Object.defineProperty({__proto__:null,assertParamsValid:ww,computeFlatOffset:Cw,computeOutShape:vw,getNormalizedAxes:yU,isSliceContinous:bw,maskToAxes:xU,parseSliceParams:bm,sliceInfo:kw,startForAxis:VN,startIndicesWithElidedDims:PN,stopForAxis:WN,stopIndicesWithElidedDims:LN,stridesForAxis:BN,stridesWithElidedDims:zN},Symbol.toStringTag,{value:"Module"}));/** + */const p1=-2,mU=-1;function ww(t,e,n){const s=t.shape.length;I(s===e.length,()=>`Error in slice${s}D: Length of begin ${e} must match the rank of the array (${s}).`),I(s===n.length,()=>`Error in slice${s}D: Length of size ${n} must match the rank of the array (${s}).`);for(let r=0;r`Error in slice${s}D: begin[${r}] + size[${r}] (${e[r]+n[r]}) would overflow input.shape[${r}] (${t.shape[r]})`)}function gU(t){const e=[];let n=0;for(;t>0;)t&1&&e.push(n),t/=2,n++;return e}function vw(t,e,n){const s=[];for(let r=0;r0){const f=e[0],p=n+1;u=PN(i,f,p,s,t),h=LN(a,f,p,r,t),d=zN(o,f,p,t)}else for(let f=0;f-1)o[a]=0;else{const l=ON(e,n,a);let c=s[l];t&1<-1)o[a]=Number.MAX_SAFE_INTEGER;else{const l=ON(e,n,a);let c=s[l];t&1<0?i=Number.MIN_SAFE_INTEGER:i=Number.MAX_SAFE_INTEGER);const l=s[r];return i<0&&(i+=l),i=Ti(0,i,l-1),i}function WN(t,e,n,s,r,o){let i=e[r];const a=n[r]||1;(t&1<0?i=Number.MAX_SAFE_INTEGER:i=Number.MIN_SAFE_INTEGER);const l=s[r];return i<0&&(i+=l),a>0?i=Ti(0,i,l):i=Ti(-1,i,l-1),i}function bw(t,e,n){let s=n.length;for(let r=0;r1){s=r;break}for(let r=s+1;r0||n[r]!==t[r])return!1;return!0}function Cw(t,e){let n=t.length>0?t[t.length-1]:1;for(let s=0;s{I(i!==-1,()=>"slice() does not support negative begin indexing.")});let o;return n==null?o=new Array(r).fill(-1):typeof n=="number"?o=[n,...new Array(r-1).fill(-1)]:n.lengthi>=0?i:(I(i===-1,()=>`Negative size values should be exactly -1 but got ${i} for the slice() size at index ${a}.`),t.shape[a]-s[a])),[s,o]}function kw(t,e,n,s,r,o,i,a,l){let c;if(s==null?(c=new Array(e.length),c.fill(1)):c=s,i!=null&&i&i-1)throw new Error("Multiple ellipses in slice is not allowed.");let u=!1;const h={dims:c.length,numAddAxisAfterEllipsis:0,begin:e.slice(),end:n.slice(),strides:c.slice(),beginMask:r,endMask:o,ellipsisMask:i,newAxisMask:a,shrinkAxisMask:l};for(let w=0;w0?0:-1,d.strides[w]>0?b:b-1];if(v&&d.strides[w]<=0)throw Error("only stride 1 allowed on non-range indexing.");g=g&&d.strides[w]===1;const S=!!(d.beginMask&1<=b)throw Error(`slice index ${d.begin[w]} of dimension ${w} out of bounds.`)}else d.begin[w]=OC(d.begin[w],0,d.strides[w],b,C,k),d.end[w]=OC(d.end[w],1,d.strides[w],b,C,k);const A=d.strides[w]===1&&d.begin[w]===0&&d.end[w]===b;f=f&&A,p=p&&(w===0&&d.strides[w]===1||A)}else f=f&&d.strides[w]===1&&S,p=p&&(w===0&&d.strides[w]===1||S);let $,N=!1;if(d.beginValid&&d.endValid?($=d.end[w]-d.begin[w],N=!0):v?($=1,N=!0):S&&b>=0&&(d.strides[w]<0?$=-b:$=b,N=!0),N){let A;$===0||$<0!=d.strides[w]<0?A=0:A=Math.trunc($/d.strides[w])+($%d.strides[w]!==0?1:0),x.push(A)}else x.push(-1)}for(let w=0;w=0?m.push(x[v]):v===p1&&m.push(1)}return{finalShapeSparse:m.filter((w,v)=>d.finalShapeGatherIndices[v]!==p1),finalShape:m,isIdentity:f,sliceDim0:p,isSimpleSlice:g,begin:d.begin,end:d.end,strides:d.strides}}function yU(t,e){e.beginMask=0,e.endMask=0,e.shrinkAxisMask=0;let n=0;e.beginValid=t.begin!=null,e.endValid=t.end!=null,e.begin=new Array(e.dims),e.end=new Array(e.dims),e.strides=new Array(e.dims),e.finalShapeGatherIndices=[],e.finalShapeGatherIndicesSparse=[],e.inputShapeGatherIndicesSparse=new Array(e.dims);for(let s=0;s0?o[e]:o[e+1&1];{const i=t<0?s+t:t;return io[1]?o[1]:i}}const wU=Object.freeze(Object.defineProperty({__proto__:null,assertParamsValid:ww,computeFlatOffset:Cw,computeOutShape:vw,getNormalizedAxes:xU,isSliceContinous:bw,maskToAxes:gU,parseSliceParams:bm,sliceInfo:kw,startForAxis:VN,startIndicesWithElidedDims:PN,stopForAxis:WN,stopIndicesWithElidedDims:LN,stridesForAxis:BN,stridesWithElidedDims:zN},Symbol.toStringTag,{value:"Module"}));/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -3638,7 +3638,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */class bU{static sgd(e){return new gw(e)}static momentum(e,n,s=!1){return new AN(e,n,s)}static rmsprop(e,n=.9,s=0,r=null,o=!1){return new DN(e,n,s,r,o)}static adam(e=.001,n=.9,s=.999,r=null){return new EN(e,n,s,r)}static adadelta(e=.001,n=.95,s=null){return new NN(e,n,s)}static adamax(e=.002,n=.9,s=.999,r=null,o=0){return new RN(e,n,s,r,o)}static adagrad(e,n=.1){return new TN(e,n)}}/** + */class vU{static sgd(e){return new gw(e)}static momentum(e,n,s=!1){return new AN(e,n,s)}static rmsprop(e,n=.9,s=0,r=null,o=!1){return new DN(e,n,s,r,o)}static adam(e=.001,n=.9,s=.999,r=null){return new EN(e,n,s,r)}static adadelta(e=.001,n=.95,s=null){return new NN(e,n,s)}static adamax(e=.002,n=.9,s=.999,r=null,o=0){return new RN(e,n,s,r,o)}static adagrad(e,n=.1){return new TN(e,n)}}/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -3653,7 +3653,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const ia=bU;/** + */const ia=vU;/** * @license * Copyright 2017 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -3668,7 +3668,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const CU=typeof requestAnimationFrame<"u"?requestAnimationFrame:typeof setImmediate<"u"?setImmediate:t=>t();function UN(){return new Promise(t=>CU(()=>t()))}/** + */const bU=typeof requestAnimationFrame<"u"?requestAnimationFrame:typeof setImmediate<"u"?setImmediate:t=>t();function UN(){return new Promise(t=>bU(()=>t()))}/** * @license * Copyright 2017 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -3743,7 +3743,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function gh(t,e,n,s=!0){let r=[];if(s)r=r.concat(e.slice(0)),r.push(t[0]/n),r=r.concat(t.slice(1));else{r=r.concat(t[0]);const o=e.length;for(let i=0;i=e*2+1||i%2===1?o.push(i):r.push(i);s.push(...r),s.push(0),s.push(...o)}return s}function yh(t,e,n,s=!0){const r=[];s?r.push(t[0]/n):r.push(t[0]*n);for(let o=1;o=e*2+1||i%2===1?o.push(i):r.push(i);s.push(...r),s.push(0),s.push(...o)}return s}function xh(t,e,n,s=!0){const r=[];s?r.push(t[0]/n):r.push(t[0]*n);for(let o=1;o/g,MC=",",PC="...";function Ow(t,e){t=t.replace(/\s/g,"");const n=(t.length-t.replace(kU,"").length)/Ig.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 ("${Ig}").`);const[s,r]=t.split(Ig);I(s.indexOf(PC)===-1,()=>`The ellipsis notation ("${PC}") is not supported yet.`);const o=s.split(MC),i=o.length;if(e!==i)throw new Error(`Expected ${i} input tensors, received ${e}`);if(i>2)throw new Error("Support for more than 2 input tensors is not implemented yet.");const a=[];for(let d=0;dp.indexOf(f)!==-1))throw new Error(`Output subscripts contain the label ${f} not present in the input subscripts.`);a.indexOf(f)===-1&&a.push(f)}for(let d=0;dr!==-1),{permutationIndices:n,expandDims:s}}function Pw(t,e,n){const s=new Array(t);for(let r=0;r`Expected dimension ${s[e[r][i]]} at axis ${i} of input shaped ${JSON.stringify(o)}, but got dimension ${o[i]}`)}}function Lw(t,e){const n=t,s=[];let r=0;t.length===0&&n.push(-1),r=t.length+1;for(let i=0;ie===n)}function SU(t,e){const n=[];for(let s=0;s"Number of splits must evenly divide the axis."),s=new Array(e).fill(t.shape[n]/e);else{const r=e.reduce((i,a)=>(a===-1&&(i+=1),i),0);I(r<=1,()=>"There should be only one negative value in split array.");const o=e.indexOf(-1);if(o!==-1){const i=e.reduce((a,l)=>l>0?a+l:a);e[o]=t.shape[n]-i}I(t.shape[n]===e.reduce((i,a)=>i+a),()=>"The sum of sizes must match the size of the axis dimension."),s=e}return s}/** + */const Ig="->",CU=/->/g,MC=",",PC="...";function Ow(t,e){t=t.replace(/\s/g,"");const n=(t.length-t.replace(CU,"").length)/Ig.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 ("${Ig}").`);const[s,r]=t.split(Ig);I(s.indexOf(PC)===-1,()=>`The ellipsis notation ("${PC}") is not supported yet.`);const o=s.split(MC),i=o.length;if(e!==i)throw new Error(`Expected ${i} input tensors, received ${e}`);if(i>2)throw new Error("Support for more than 2 input tensors is not implemented yet.");const a=[];for(let d=0;dp.indexOf(f)!==-1))throw new Error(`Output subscripts contain the label ${f} not present in the input subscripts.`);a.indexOf(f)===-1&&a.push(f)}for(let d=0;dr!==-1),{permutationIndices:n,expandDims:s}}function Pw(t,e,n){const s=new Array(t);for(let r=0;r`Expected dimension ${s[e[r][i]]} at axis ${i} of input shaped ${JSON.stringify(o)}, but got dimension ${o[i]}`)}}function Lw(t,e){const n=t,s=[];let r=0;t.length===0&&n.push(-1),r=t.length+1;for(let i=0;ie===n)}function kU(t,e){const n=[];for(let s=0;s"Number of splits must evenly divide the axis."),s=new Array(e).fill(t.shape[n]/e);else{const r=e.reduce((i,a)=>(a===-1&&(i+=1),i),0);I(r<=1,()=>"There should be only one negative value in split array.");const o=e.indexOf(-1);if(o!==-1){const i=e.reduce((a,l)=>l>0?a+l:a);e[o]=t.shape[n]-i}I(t.shape[n]===e.reduce((i,a)=>i+a),()=>"The sum of sizes must match the size of the axis dimension."),s=e}return s}/** * @license * Copyright 2021 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -3866,7 +3866,7 @@ body { * limitations under the License. * ============================================================================= */function hT(t,e){let n=!1,s;for(t<=Iw?(s=t,n=!0):s=Q0(t,Math.floor(Math.sqrt(t)));!n;)s>e||s===t?n=!0:s=Q0(t,s+1);return s}function dT(t,e,n){const s=[],r=t.length;for(let o=0;or))throw new Error(`Expect batchDims in the range of [-${r}, ${r}], but got ${s}`);if(s<0&&(s+=r),s>o)throw new Error(`batchDims (${s}) must be less than rank(x) ( - ${o}).`);if(nDo(e))}catch(e){throw new Error(`Failed to decode encoded string bytes into utf-8, error: ${e}`)}}function fT(t){return t.map(e=>No(e))}const $U=Object.freeze(Object.defineProperty({__proto__:null,ERF_A1:Rw,ERF_A2:Aw,ERF_A3:Dw,ERF_A4:_w,ERF_A5:Fw,ERF_P:Ew,PARALLELIZE_THRESHOLD:Iw,get RowPartitionType(){return Us},SELU_SCALE:Sm,SELU_SCALEALPHA:km,applyActivation:uw,assertAndGetBroadcastShape:Se,assertAxesAreInnerMostDims:sn,assertParamsConsistent:Sw,assignToTypedArray:QN,axesAreInnerMostDims:Vy,calculateShapes:Qi,checkEinsumDimSizes:Pw,checkPadOnDimRoundingMode:Mn,combineLocations:nN,combineRaggedTensorToTensorShapes:GN,complexWithEvenIndex:qN,complexWithOddIndex:YN,computeConv2DInfo:nn,computeConv3DInfo:Go,computeDefaultPad:zy,computeDilation2DInfo:hh,computeOptimalWindowSize:Cm,computeOutAndReduceShapes:Yt,computeOutShape:wr,computePool2DInfo:As,computePool3DInfo:Yr,convertConv2DDataFormat:Qr,decodeEinsumEquation:Ow,eitherStridesOrDilationsAreOne:dn,expandShapeToKeepDim:Dt,exponent:JN,exponents:ZN,fromStringArrayToUint8:fT,fromUint8ToStringArray:Kr,getAxesPermutation:yt,getBroadcastDims:il,getComplexWithIndex:zw,getEinsumComputePath:Lw,getEinsumPermutation:Mw,getFusedBiasGradient:cw,getFusedDyActivation:lw,getImageCenter:$w,getInnerMostAxes:$t,getPermuted:xh,getRaggedRank:jN,getReductionAxes:Vt,getReshaped:gh,getReshapedPermuted:yh,getRowPartitionTypesHelper:HN,getSliceBeginCoords:Nw,getSliceSize:Tw,getSparseFillEmptyRowsIndicesDenseShapeMismatch:eT,getSparseFillEmptyRowsNegativeIndexErrorMessage:tT,getSparseFillEmptyRowsOutOfRangeIndexErrorMessage:nT,getSparseReshapeEmptyTensorZeroOutputDimErrorMessage:oT,getSparseReshapeInputOutputMismatchErrorMessage:aT,getSparseReshapeInputOutputMultipleErrorMessage:iT,getSparseReshapeMultipleNegativeOneOutputDimErrorMessage:sT,getSparseReshapeNegativeOutputDimErrorMessage:rT,getSparseSegmentReductionIndicesOutOfRangeErrorMessage:uT,getSparseSegmentReductionNegativeSegmentIdsErrorMessage:m1,getSparseSegmentReductionNonIncreasingSegmentIdsErrorMessage:lT,getSparseSegmentReductionSegmentIdOutOfRangeErrorMessage:cT,getUndoAxesPermutation:Ho,isIdentityPermutation:Bw,log:HM,mergeRealAndImagArrays:jr,prepareAndValidate:yw,prepareSplitSize:Vw,segment_util:IU,shouldFuse:hw,slice_util:vU,splitRealAndImagArrays:XN,stridesOrDilationsArePositive:Fi,tupleValuesAreOne:_i,upcastType:Xn,validateDefaultValueShape:KN,validateInput:QV,validateUpdateShape:bN,warn:es},Symbol.toStringTag,{value:"Module"}));/** + */function Kr(t){try{return t.map(e=>Do(e))}catch(e){throw new Error(`Failed to decode encoded string bytes into utf-8, error: ${e}`)}}function fT(t){return t.map(e=>No(e))}const IU=Object.freeze(Object.defineProperty({__proto__:null,ERF_A1:Rw,ERF_A2:Aw,ERF_A3:Dw,ERF_A4:_w,ERF_A5:Fw,ERF_P:Ew,PARALLELIZE_THRESHOLD:Iw,get RowPartitionType(){return Us},SELU_SCALE:Sm,SELU_SCALEALPHA:km,applyActivation:uw,assertAndGetBroadcastShape:Se,assertAxesAreInnerMostDims:sn,assertParamsConsistent:Sw,assignToTypedArray:QN,axesAreInnerMostDims:Vy,calculateShapes:Qi,checkEinsumDimSizes:Pw,checkPadOnDimRoundingMode:Mn,combineLocations:nN,combineRaggedTensorToTensorShapes:GN,complexWithEvenIndex:qN,complexWithOddIndex:YN,computeConv2DInfo:nn,computeConv3DInfo:Go,computeDefaultPad:zy,computeDilation2DInfo:uh,computeOptimalWindowSize:Cm,computeOutAndReduceShapes:Yt,computeOutShape:wr,computePool2DInfo:As,computePool3DInfo:Yr,convertConv2DDataFormat:Qr,decodeEinsumEquation:Ow,eitherStridesOrDilationsAreOne:dn,expandShapeToKeepDim:Dt,exponent:JN,exponents:ZN,fromStringArrayToUint8:fT,fromUint8ToStringArray:Kr,getAxesPermutation:yt,getBroadcastDims:il,getComplexWithIndex:zw,getEinsumComputePath:Lw,getEinsumPermutation:Mw,getFusedBiasGradient:cw,getFusedDyActivation:lw,getImageCenter:$w,getInnerMostAxes:$t,getPermuted:gh,getRaggedRank:jN,getReductionAxes:Vt,getReshaped:mh,getReshapedPermuted:xh,getRowPartitionTypesHelper:HN,getSliceBeginCoords:Nw,getSliceSize:Tw,getSparseFillEmptyRowsIndicesDenseShapeMismatch:eT,getSparseFillEmptyRowsNegativeIndexErrorMessage:tT,getSparseFillEmptyRowsOutOfRangeIndexErrorMessage:nT,getSparseReshapeEmptyTensorZeroOutputDimErrorMessage:oT,getSparseReshapeInputOutputMismatchErrorMessage:aT,getSparseReshapeInputOutputMultipleErrorMessage:iT,getSparseReshapeMultipleNegativeOneOutputDimErrorMessage:sT,getSparseReshapeNegativeOutputDimErrorMessage:rT,getSparseSegmentReductionIndicesOutOfRangeErrorMessage:uT,getSparseSegmentReductionNegativeSegmentIdsErrorMessage:m1,getSparseSegmentReductionNonIncreasingSegmentIdsErrorMessage:lT,getSparseSegmentReductionSegmentIdOutOfRangeErrorMessage:cT,getUndoAxesPermutation:Ho,isIdentityPermutation:Bw,log:GM,mergeRealAndImagArrays:jr,prepareAndValidate:yw,prepareSplitSize:Vw,segment_util:SU,shouldFuse:hw,slice_util:wU,splitRealAndImagArrays:XN,stridesOrDilationsArePositive:Fi,tupleValuesAreOne:_i,upcastType:Xn,validateDefaultValueShape:KN,validateInput:YV,validateUpdateShape:bN,warn:es},Symbol.toStringTag,{value:"Module"}));/** * @license * Copyright 2017 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -3896,7 +3896,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */cU();/** + */lU();/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -3911,7 +3911,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const pT={kernelName:pp,inputsToSave:["x"],gradFunc:(t,e)=>{const[n]=e;return{x:()=>D(t,mh(le(n,"float32"),-1))}}};/** + */const pT={kernelName:pp,inputsToSave:["x"],gradFunc:(t,e)=>{const[n]=e;return{x:()=>D(t,ph(le(n,"float32"),-1))}}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -3926,7 +3926,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const NU={kernelName:pu,inputsToSave:["x"],gradFunc:(t,e)=>{const[n]=e;return{x:()=>{const s=ot(le(n,"float32")),r=hn(ve(We(1),s));return St(ge(t,r))}}}};/** + */const $U={kernelName:fu,inputsToSave:["x"],gradFunc:(t,e)=>{const[n]=e;return{x:()=>{const s=ot(le(n,"float32")),r=hn(ve(We(1),s));return St(ge(t,r))}}}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -3941,7 +3941,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const TU={kernelName:mu,inputsToSave:["x"],gradFunc:(t,e)=>{const[n]=e;return{x:()=>{const s=hn(ve(ot(le(n,"float32")),1));return ge(t,s)}}}};/** + */const NU={kernelName:pu,inputsToSave:["x"],gradFunc:(t,e)=>{const[n]=e;return{x:()=>{const s=hn(ve(ot(le(n,"float32")),1));return ge(t,s)}}}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -3956,7 +3956,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const EU={kernelName:bl,inputsToSave:["a","b"],gradFunc:(t,e)=>{const[n,s]=e,r=Se(n.shape,s.shape);return{a:()=>{let a=t;const l=Vt(n.shape,r);return l.length>0&&(a=me(a,l)),F(a,n.shape)},b:()=>{let a=t;const l=Vt(s.shape,r);return l.length>0&&(a=me(a,l)),F(a,s.shape)}}}};/** + */const TU={kernelName:bl,inputsToSave:["a","b"],gradFunc:(t,e)=>{const[n,s]=e,r=Se(n.shape,s.shape);return{a:()=>{let a=t;const l=Vt(n.shape,r);return l.length>0&&(a=me(a,l)),F(a,n.shape)},b:()=>{let a=t;const l=Vt(s.shape,r);return l.length>0&&(a=me(a,l)),F(a,s.shape)}}}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -3971,7 +3971,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const RU={kernelName:Gx,saveAllInputs:!0,gradFunc:(t,e)=>{const n={};return e.forEach((s,r)=>{n[r]=()=>t.clone()}),n}};/** + */const EU={kernelName:Gx,saveAllInputs:!0,gradFunc:(t,e)=>{const n={};return e.forEach((s,r)=>{n[r]=()=>t.clone()}),n}};/** * @license * Copyright 2020 Google Inc. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -3986,7 +3986,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const AU={kernelName:mp,inputsToSave:["x"],gradFunc:(t,e)=>{const[n]=e;return{x:()=>ze(n)}}};/** + */const RU={kernelName:mp,inputsToSave:["x"],gradFunc:(t,e)=>{const[n]=e;return{x:()=>ze(n)}}};/** * @license * Copyright 2020 Google Inc. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -4001,7 +4001,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const DU={kernelName:gp,inputsToSave:["x"],gradFunc:(t,e)=>{const[n]=e;return{x:()=>ze(n)}}};/** + */const AU={kernelName:gp,inputsToSave:["x"],gradFunc:(t,e)=>{const[n]=e;return{x:()=>ze(n)}}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -4016,7 +4016,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const _U={kernelName:gu,inputsToSave:["x"],gradFunc:(t,e)=>{const[n]=e;return{x:()=>ge(t,hn(ve(We(1),ot(le(n,"float32")))))}}};/** + */const DU={kernelName:mu,inputsToSave:["x"],gradFunc:(t,e)=>{const[n]=e;return{x:()=>ge(t,hn(ve(We(1),ot(le(n,"float32")))))}}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -4031,7 +4031,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const FU={kernelName:xu,inputsToSave:["x"],gradFunc:(t,e)=>{const[n]=e;return{x:()=>{const s=hn(J(We(1),ot(le(n,"float32"))));return ge(t,s)}}}};/** + */const _U={kernelName:gu,inputsToSave:["x"],gradFunc:(t,e)=>{const[n]=e;return{x:()=>{const s=hn(J(We(1),ot(le(n,"float32"))));return ge(t,s)}}}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -4046,7 +4046,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const zU={kernelName:vu,inputsToSave:["a","b"],gradFunc:(t,e)=>{const[n,s]=e,r=Se(n.shape,s.shape);return{a:()=>{const a=J(ot(n),ot(s));let l=D(t,ge(s,a));const c=Vt(n.shape,r);return c.length>0&&(l=me(l,c)),F(l,n.shape)},b:()=>{const a=J(ot(n),ot(s));let l=St(D(t,ge(n,a)));const c=Vt(s.shape,r);return c.length>0&&(l=me(l,c)),F(l,s.shape)}}}};/** + */const FU={kernelName:wu,inputsToSave:["a","b"],gradFunc:(t,e)=>{const[n,s]=e,r=Se(n.shape,s.shape);return{a:()=>{const a=J(ot(n),ot(s));let l=D(t,ge(s,a));const c=Vt(n.shape,r);return c.length>0&&(l=me(l,c)),F(l,n.shape)},b:()=>{const a=J(ot(n),ot(s));let l=St(D(t,ge(n,a)));const c=Vt(s.shape,r);return c.length>0&&(l=me(l,c)),F(l,s.shape)}}}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -4061,7 +4061,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const OU={kernelName:yu,inputsToSave:["x"],gradFunc:(t,e)=>{const[n]=e;return{x:()=>ge(t,J(ot(le(n,"float32")),1))}}};/** + */const zU={kernelName:xu,inputsToSave:["x"],gradFunc:(t,e)=>{const[n]=e;return{x:()=>ge(t,J(ot(le(n,"float32")),1))}}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -4076,7 +4076,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const MU={kernelName:wu,inputsToSave:["x"],gradFunc:(t,e)=>{const[n]=e;return{x:()=>ge(t,ve(We(1),ot(le(n,"float32"))))}}};/** + */const OU={kernelName:yu,inputsToSave:["x"],gradFunc:(t,e)=>{const[n]=e;return{x:()=>ge(t,ve(We(1),ot(le(n,"float32"))))}}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -4091,7 +4091,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function PU(t,e,n,s,r,o){const i=T(t,"dy","avgPool3dGrad"),a=T(e,"input","avgPool3dGrad");let l=i,c=a,u=!1;a.rank===4&&(u=!0,l=F(i,[1,i.shape[0],i.shape[1],i.shape[2],i.shape[3]]),c=F(a,[1,a.shape[0],a.shape[1],a.shape[2],a.shape[3]])),I(l.rank===5,()=>`Error in avgPool3dGrad: dy must be rank 5 but got rank ${l.rank}.`),I(c.rank===5,()=>`Error in avgPool3dGrad: input must be rank 5 but got rank ${c.rank}.`),Mn("avgPool3dGrad",r,o);const h={dy:l,input:c},d={filterSize:n,strides:s,pad:r,dimRoundingMode:o},f=_.runKernel(Xx,h,d);return u?F(f,[f.shape[1],f.shape[2],f.shape[3],f.shape[4]]):f}const LU=z({avgPool3dGrad_:PU});/** + */function MU(t,e,n,s,r,o){const i=T(t,"dy","avgPool3dGrad"),a=T(e,"input","avgPool3dGrad");let l=i,c=a,u=!1;a.rank===4&&(u=!0,l=F(i,[1,i.shape[0],i.shape[1],i.shape[2],i.shape[3]]),c=F(a,[1,a.shape[0],a.shape[1],a.shape[2],a.shape[3]])),I(l.rank===5,()=>`Error in avgPool3dGrad: dy must be rank 5 but got rank ${l.rank}.`),I(c.rank===5,()=>`Error in avgPool3dGrad: input must be rank 5 but got rank ${c.rank}.`),Mn("avgPool3dGrad",r,o);const h={dy:l,input:c},d={filterSize:n,strides:s,pad:r,dimRoundingMode:o},f=_.runKernel(Xx,h,d);return u?F(f,[f.shape[1],f.shape[2],f.shape[3],f.shape[4]]):f}const PU=z({avgPool3dGrad_:MU});/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -4106,7 +4106,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const BU={kernelName:yp,inputsToSave:["x"],gradFunc:(t,e,n)=>{const[s]=e,{filterSize:r,strides:o,pad:i,dimRoundingMode:a}=n;return{x:()=>LU(t,s,r,o,i,a)}}};/** + */const LU={kernelName:yp,inputsToSave:["x"],gradFunc:(t,e,n)=>{const[s]=e,{filterSize:r,strides:o,pad:i,dimRoundingMode:a}=n;return{x:()=>PU(t,s,r,o,i,a)}}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -4121,7 +4121,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function VU(t,e,n,s,r){const o=T(t,"dy","avgPoolGrad"),i=T(e,"input","avgPoolGrad");I(i.rank===o.rank,()=>`Rank of input (${i.rank}) does not match rank of dy (${o.rank})`);let a=i,l=o,c=!1;i.rank===3&&(c=!0,a=F(i,[1,i.shape[0],i.shape[1],i.shape[2]]),l=F(o,[1,o.shape[0],o.shape[1],o.shape[2]])),I(l.rank===4,()=>`Error in avgPoolGrad: dy must be rank 4 but got rank ${l.rank}.`),I(a.rank===4,()=>`Error in avgPoolGrad: input must be rank 4 but got rank ${a.rank}.`);const u={dy:l,input:a},h={filterSize:n,strides:s,pad:r},d=_.runKernel(Kx,u,h);return c?F(d,[d.shape[1],d.shape[2],d.shape[3]]):d}const WU=z({avgPoolGrad_:VU});/** + */function BU(t,e,n,s,r){const o=T(t,"dy","avgPoolGrad"),i=T(e,"input","avgPoolGrad");I(i.rank===o.rank,()=>`Rank of input (${i.rank}) does not match rank of dy (${o.rank})`);let a=i,l=o,c=!1;i.rank===3&&(c=!0,a=F(i,[1,i.shape[0],i.shape[1],i.shape[2]]),l=F(o,[1,o.shape[0],o.shape[1],o.shape[2]])),I(l.rank===4,()=>`Error in avgPoolGrad: dy must be rank 4 but got rank ${l.rank}.`),I(a.rank===4,()=>`Error in avgPoolGrad: input must be rank 4 but got rank ${a.rank}.`);const u={dy:l,input:a},h={filterSize:n,strides:s,pad:r},d=_.runKernel(Kx,u,h);return c?F(d,[d.shape[1],d.shape[2],d.shape[3]]):d}const VU=z({avgPoolGrad_:BU});/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -4136,7 +4136,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const UU={kernelName:xp,inputsToSave:["x"],gradFunc:(t,e,n)=>{const[s]=e,{filterSize:r,strides:o,pad:i}=n;return{x:()=>WU(t,s,r,o,i)}}};/** + */const WU={kernelName:xp,inputsToSave:["x"],gradFunc:(t,e,n)=>{const[s]=e,{filterSize:r,strides:o,pad:i}=n;return{x:()=>VU(t,s,r,o,i)}}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -4151,7 +4151,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const GU={kernelName:wp,inputsToSave:["a","b"],gradFunc:(t,e,n)=>{const[s,r]=e,{transposeA:o,transposeB:i}=n;return!o&&!i?{a:()=>Ve(t,r,!1,!0),b:()=>Ve(s,t,!0,!1)}:!o&&i?{a:()=>Ve(t,r,!1,!1),b:()=>Ve(t,s,!0,!1)}:o&&!i?{a:()=>Ve(r,t,!1,!0),b:()=>Ve(s,t,!1,!1)}:{a:()=>Ve(r,t,!0,!0),b:()=>Ve(t,s,!0,!0)}}};/** + */const UU={kernelName:wp,inputsToSave:["a","b"],gradFunc:(t,e,n)=>{const[s,r]=e,{transposeA:o,transposeB:i}=n;return!o&&!i?{a:()=>Ve(t,r,!1,!0),b:()=>Ve(s,t,!0,!1)}:!o&&i?{a:()=>Ve(t,r,!1,!1),b:()=>Ve(t,s,!0,!1)}:o&&!i?{a:()=>Ve(r,t,!1,!0),b:()=>Ve(s,t,!1,!1)}:{a:()=>Ve(r,t,!0,!0),b:()=>Ve(t,s,!0,!0)}}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -4166,7 +4166,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const HU={kernelName:vp,gradFunc:(t,e,n)=>{const{blockShape:s,crops:r}=n;return{x:()=>qy(t,s,r)}}};/** + */const GU={kernelName:vp,gradFunc:(t,e,n)=>{const{blockShape:s,crops:r}=n;return{x:()=>qy(t,s,r)}}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -4181,7 +4181,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const jU={kernelName:VM,gradFunc:(t,e,n)=>{const s=n,r=s.inputShape,o=s.shape,i=Array.from(o);for(let l=r.length-1;l>=0;l--)if(r[l]===o[l])i[l]=1;else if(r[l]!==1)throw new Error(`broadcastTo(): [${r}] cannot be broadcast to [${o}].`);const a=[];for(let l=0;l1&&a.push(l);return{x:()=>me(t,a,!0)}}};/** + */const HU={kernelName:BM,gradFunc:(t,e,n)=>{const s=n,r=s.inputShape,o=s.shape,i=Array.from(o);for(let l=r.length-1;l>=0;l--)if(r[l]===o[l])i[l]=1;else if(r[l]!==1)throw new Error(`broadcastTo(): [${r}] cannot be broadcast to [${o}].`);const a=[];for(let l=0;l1&&a.push(l);return{x:()=>me(t,a,!0)}}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -4196,7 +4196,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const KU={kernelName:bu,gradFunc:t=>({x:()=>t.clone()})};/** + */const jU={kernelName:vu,gradFunc:t=>({x:()=>t.clone()})};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -4211,7 +4211,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const XU={kernelName:Cu,gradFunc:t=>({x:()=>ze(t)})};/** + */const KU={kernelName:bu,gradFunc:t=>({x:()=>ze(t)})};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -4226,7 +4226,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const qU={kernelName:ku,inputsToSave:["x"],gradFunc:(t,e,n)=>{const[s]=e,{clipValueMin:r,clipValueMax:o}=n;return{x:()=>Cn(Gr(Xi(s,r),kl(s,o)),t,ze(t))}}};/** + */const XU={kernelName:Cu,inputsToSave:["x"],gradFunc:(t,e,n)=>{const[s]=e,{clipValueMin:r,clipValueMax:o}=n;return{x:()=>Cn(Gr(Xi(s,r),kl(s,o)),t,ze(t))}}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -4241,7 +4241,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const YU={kernelName:bp,inputsToSave:["x"],gradFunc:pT.gradFunc};/** + */const qU={kernelName:bp,inputsToSave:["x"],gradFunc:pT.gradFunc};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -4256,7 +4256,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const QU={kernelName:Cp,saveAllInputs:!0,gradFunc:(t,e,n)=>{const s=e.map(l=>l.shape),{axis:r}=n,o=Re(r,e[0].shape)[0],i=s.map(l=>l[o]);return rs(t,i,o).map(l=>()=>l)}};/** + */const YU={kernelName:Cp,saveAllInputs:!0,gradFunc:(t,e,n)=>{const s=e.map(l=>l.shape),{axis:r}=n,o=Re(r,e[0].shape)[0],i=s.map(l=>l[o]);return rs(t,i,o).map(l=>()=>l)}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -4271,7 +4271,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const ZU={kernelName:kp,inputsToSave:["x","filter"],gradFunc:(t,e,n)=>{const[s,r]=e,{dilations:o,strides:i,pad:a,dataFormat:l}=n;return I(_i(o),()=>`Error in gradient of conv2D: dilation rates greater than 1 are not yet supported in gradients. Got dilations '${o}'`),{x:()=>Py(s.shape,t,r,i,a,l),filter:()=>aw(s,t,r.shape,i,a,l)}}};/** + */const QU={kernelName:kp,inputsToSave:["x","filter"],gradFunc:(t,e,n)=>{const[s,r]=e,{dilations:o,strides:i,pad:a,dataFormat:l}=n;return I(_i(o),()=>`Error in gradient of conv2D: dilation rates greater than 1 are not yet supported in gradients. Got dilations '${o}'`),{x:()=>Py(s.shape,t,r,i,a,l),filter:()=>aw(s,t,r.shape,i,a,l)}}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -4286,7 +4286,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const JU={kernelName:Sp,inputsToSave:["dy","filter"],gradFunc:(t,e,n)=>{const[s,r]=e,{strides:o,pad:i,dataFormat:a,dimRoundingMode:l}=n;return{dy:()=>zi(t,r,o,i,a,1,l),filter:()=>aw(t,s,r.shape,o,i,a,l)}}};/** + */const ZU={kernelName:Sp,inputsToSave:["dy","filter"],gradFunc:(t,e,n)=>{const[s,r]=e,{strides:o,pad:i,dataFormat:a,dimRoundingMode:l}=n;return{dy:()=>zi(t,r,o,i,a,1,l),filter:()=>aw(t,s,r.shape,o,i,a,l)}}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -4301,7 +4301,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function eG(t,e,n,s,r){let o=t;t.rank===4&&(o=F(t,[1,t.shape[0],t.shape[1],t.shape[2],t.shape[3]]));let i=e;i.rank===4&&(i=F(e,[1,e.shape[0],e.shape[1],e.shape[2],e.shape[3]])),I(o.rank===5,()=>`Error in conv3dDerFilter: input must be rank 5, but got shape ${o.shape}.`),I(i.rank===5,()=>`Error in conv3dDerFilter: dy must be rank 5, but got shape ${i.shape}.`),I(n.length===5,()=>`Error in conv3dDerFilter: filterShape must be length 5, but got ${n}.`),I(o.shape[4]===n[3],()=>`Error in conv3dDerFilter: depth of input ${o.shape[4]}) must match input depth in filter (${n[3]}.`),I(i.shape[4]===n[4],()=>`Error in conv3dDerFilter: depth of dy (${i.shape[4]}) must match output depth for filter (${n[4]}).`);const a={x:o,dy:i},l={strides:s,pad:r,filterShape:n};return _.runKernel(Jx,a,l)}const tG=z({conv3DBackpropFilter_:eG});/** + */function JU(t,e,n,s,r){let o=t;t.rank===4&&(o=F(t,[1,t.shape[0],t.shape[1],t.shape[2],t.shape[3]]));let i=e;i.rank===4&&(i=F(e,[1,e.shape[0],e.shape[1],e.shape[2],e.shape[3]])),I(o.rank===5,()=>`Error in conv3dDerFilter: input must be rank 5, but got shape ${o.shape}.`),I(i.rank===5,()=>`Error in conv3dDerFilter: dy must be rank 5, but got shape ${i.shape}.`),I(n.length===5,()=>`Error in conv3dDerFilter: filterShape must be length 5, but got ${n}.`),I(o.shape[4]===n[3],()=>`Error in conv3dDerFilter: depth of input ${o.shape[4]}) must match input depth in filter (${n[3]}.`),I(i.shape[4]===n[4],()=>`Error in conv3dDerFilter: depth of dy (${i.shape[4]}) must match output depth for filter (${n[4]}).`);const a={x:o,dy:i},l={strides:s,pad:r,filterShape:n};return _.runKernel(Jx,a,l)}const eG=z({conv3DBackpropFilter_:JU});/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -4316,7 +4316,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const nG={kernelName:Ip,inputsToSave:["x","filter"],gradFunc:(t,e,n)=>{const{dilations:s,strides:r,pad:o}=n;I(_i(s),()=>`Error in gradient of conv3D: dilation rates greater than 1 are not yet supported in gradients. Got dilations '${s}'`);const[i,a]=e;return{x:()=>Z$(i.shape,t,a,r,o),filter:()=>tG(i,t,a.shape,r,o)}}};/** + */const tG={kernelName:Ip,inputsToSave:["x","filter"],gradFunc:(t,e,n)=>{const{dilations:s,strides:r,pad:o}=n;I(_i(s),()=>`Error in gradient of conv3D: dilation rates greater than 1 are not yet supported in gradients. Got dilations '${s}'`);const[i,a]=e;return{x:()=>Z$(i.shape,t,a,r,o),filter:()=>eG(i,t,a.shape,r,o)}}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -4331,7 +4331,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const sG={kernelName:Su,inputsToSave:["x"],gradFunc:(t,e)=>{const[n]=e;return{x:()=>D(St(xN(le(n,"float32"))),t)}}};/** + */const nG={kernelName:ku,inputsToSave:["x"],gradFunc:(t,e)=>{const[n]=e;return{x:()=>D(St(xN(le(n,"float32"))),t)}}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -4346,7 +4346,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const rG={kernelName:Iu,inputsToSave:["x"],gradFunc:(t,e)=>{const[n]=e;return{x:()=>D(yN(le(n,"float32")),t)}}};/** + */const sG={kernelName:Su,inputsToSave:["x"],gradFunc:(t,e)=>{const[n]=e;return{x:()=>D(yN(le(n,"float32")),t)}}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -4361,7 +4361,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const oG={kernelName:$p,inputsToSave:["x"],gradFunc:(t,e,n)=>{const[s]=e,{axis:r,exclusive:o,reverse:i}=n;return{x:()=>{const a=yt([r],s.rank);let l=eN(t,r,o,!i);return a!=null&&(l=Fe(l,a)),l}}}};/** + */const rG={kernelName:$p,inputsToSave:["x"],gradFunc:(t,e,n)=>{const[s]=e,{axis:r,exclusive:o,reverse:i}=n;return{x:()=>{const a=yt([r],s.rank);let l=eN(t,r,o,!i);return a!=null&&(l=Fe(l,a)),l}}}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -4376,7 +4376,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const iG={kernelName:Np,inputsToSave:["x","filter"],gradFunc:(t,e,n)=>{const{dilations:s,strides:r,pad:o,dimRoundingMode:i}=n,a=s??[1,1];I(_i(a),()=>`Error in gradient of depthwiseConv2dNative: dilation rates greater than 1 are not yet supported. Got dilations '${a}'`);const[l,c]=e;return I(l.rank===4,()=>`Error in gradient of depthwiseConv2dNative: input must be rank 4, but got rank ${l.rank}.`),I(c.rank===4,()=>`Error in gradient of depthwiseConv2dNative: filter must be rank 4, but got rank ${c.rank}.`),I(l.shape[3]===c.shape[2],()=>`Error in gradient of depthwiseConv2d: number of input channels (${l.shape[3]}) must match the inChannels dimension in filter ${c.shape[2]}.`),I(dn(r,a),()=>`Error in gradient of depthwiseConv2d: Either strides or dilations must be 1. Got strides ${r} and dilations '${a}'.`),Mn("depthwiseConv2d",o,i),{x:()=>gW(l.shape,t,c,r,o,a,i),filter:()=>pW(l,t,c.shape,r,o,a,i)}}};/** + */const oG={kernelName:Np,inputsToSave:["x","filter"],gradFunc:(t,e,n)=>{const{dilations:s,strides:r,pad:o,dimRoundingMode:i}=n,a=s??[1,1];I(_i(a),()=>`Error in gradient of depthwiseConv2dNative: dilation rates greater than 1 are not yet supported. Got dilations '${a}'`);const[l,c]=e;return I(l.rank===4,()=>`Error in gradient of depthwiseConv2dNative: input must be rank 4, but got rank ${l.rank}.`),I(c.rank===4,()=>`Error in gradient of depthwiseConv2dNative: filter must be rank 4, but got rank ${c.rank}.`),I(l.shape[3]===c.shape[2],()=>`Error in gradient of depthwiseConv2d: number of input channels (${l.shape[3]}) must match the inChannels dimension in filter ${c.shape[2]}.`),I(dn(r,a),()=>`Error in gradient of depthwiseConv2d: Either strides or dilations must be 1. Got strides ${r} and dilations '${a}'.`),Mn("depthwiseConv2d",o,i),{x:()=>mW(l.shape,t,c,r,o,a,i),filter:()=>fW(l,t,c.shape,r,o,a,i)}}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -4391,7 +4391,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const aG={kernelName:Tp,inputsToSave:["x","filter"],gradFunc:(t,e,n)=>{const[s,r]=e,o={x:s,filter:r,dy:t},i={x:s,filter:r,dy:t};return{x:()=>_.runKernel(Z0,o,n),filter:()=>_.runKernel(J0,i,n)}}};/** + */const iG={kernelName:Tp,inputsToSave:["x","filter"],gradFunc:(t,e,n)=>{const[s,r]=e,o={x:s,filter:r,dy:t},i={x:s,filter:r,dy:t};return{x:()=>_.runKernel(Z0,o,n),filter:()=>_.runKernel(J0,i,n)}}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -4406,7 +4406,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const lG={kernelName:Nu,outputsToSave:[!0],gradFunc:(t,e)=>{const[n]=e,s={dy:t,y:n};return{x:()=>_.runKernel(ly,s)}}};/** + */const aG={kernelName:$u,outputsToSave:[!0],gradFunc:(t,e)=>{const[n]=e,s={dy:t,y:n};return{x:()=>_.runKernel(ly,s)}}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -4421,7 +4421,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const cG={kernelName:Tu,inputsToSave:["x"],gradFunc:(t,e)=>{const[n]=e,s=D(Sr(St(ot(n))),2/Math.sqrt(Math.PI));return{x:()=>D(t,s)}}};/** + */const lG={kernelName:Nu,inputsToSave:["x"],gradFunc:(t,e)=>{const[n]=e,s=D(Sr(St(ot(n))),2/Math.sqrt(Math.PI));return{x:()=>D(t,s)}}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -4436,7 +4436,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const uG={kernelName:Eu,outputsToSave:[!0],gradFunc:(t,e)=>{const[n]=e;return{x:()=>D(t,n)}}};/** + */const cG={kernelName:Tu,outputsToSave:[!0],gradFunc:(t,e)=>{const[n]=e;return{x:()=>D(t,n)}}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -4451,7 +4451,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const hG={kernelName:Rp,inputsToSave:["input"],gradFunc:(t,e)=>{const[n]=e;return{input:()=>F(t,n.shape)}}};/** + */const uG={kernelName:Rp,inputsToSave:["input"],gradFunc:(t,e)=>{const[n]=e;return{input:()=>F(t,n.shape)}}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -4466,7 +4466,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const dG={kernelName:Ru,inputsToSave:["x"],gradFunc:(t,e)=>{const[n]=e;return{x:()=>D(t,Sr(n))}}};/** + */const hG={kernelName:Eu,inputsToSave:["x"],gradFunc:(t,e)=>{const[n]=e;return{x:()=>D(t,Sr(n))}}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -4481,7 +4481,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const fG={kernelName:Au,gradFunc:t=>({x:()=>ze(t)})};/** + */const dG={kernelName:Ru,gradFunc:t=>({x:()=>ze(t)})};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -4496,7 +4496,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const pG={kernelName:Du,inputsToSave:["a","b"],gradFunc:(t,e)=>{const[n,s]=e,r=Se(n.shape,s.shape);return{a:()=>{const a=ge(t,le(s,"float32")),l=Vt(n.shape,r);return l.length>0?F(me(a,l),n.shape):a},b:()=>{let a=D(t,le(n,"float32"));const l=Vt(s.shape,r);l.length>0&&(a=F(me(a,l),s.shape));const c=ot(s);return St(ge(a,le(c,"float32")))}}}};/** + */const fG={kernelName:Au,inputsToSave:["a","b"],gradFunc:(t,e)=>{const[n,s]=e,r=Se(n.shape,s.shape);return{a:()=>{const a=ge(t,le(s,"float32")),l=Vt(n.shape,r);return l.length>0?F(me(a,l),n.shape):a},b:()=>{let a=D(t,le(n,"float32"));const l=Vt(s.shape,r);l.length>0&&(a=F(me(a,l),s.shape));const c=ot(s);return St(ge(a,le(c,"float32")))}}}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -4511,7 +4511,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const mG={kernelName:Ap,inputsToSave:["x","mean","variance","scale"],gradFunc:(t,e,n)=>{const{varianceEpsilon:s}=n,[r,o,i,a]=e,l=a??We(1),c=Vt(o.shape,r.shape),u=[];if(o.rank===1){for(let v=0;vo.rank===1?F(D(D(t,Hs(F(f,[1,1,1,o.shape[0]]),u)),l),r.shape):F(D(D(t,f),l),r.shape),mean:()=>{let v=D(D(f,We(-1)),d);return o.rank===1&&(v=me(v,c)),F(v,o.shape)},variance:()=>{let v=D(D(p,h),d);return o.rank===1&&(v=me(v,c)),F(v,o.shape)},scale:()=>{const v=D(h,f);let b=D(t,v);return o.rank===1&&(b=me(b,c)),F(b,o.shape)},offset:()=>{let v=t;return o.rank===1&&(v=me(v,c)),F(v,o.shape)}}}};/** + */const pG={kernelName:Ap,inputsToSave:["x","mean","variance","scale"],gradFunc:(t,e,n)=>{const{varianceEpsilon:s}=n,[r,o,i,a]=e,l=a??We(1),c=Vt(o.shape,r.shape),u=[];if(o.rank===1){for(let v=0;vo.rank===1?F(D(D(t,Hs(F(f,[1,1,1,o.shape[0]]),u)),l),r.shape):F(D(D(t,f),l),r.shape),mean:()=>{let v=D(D(f,We(-1)),d);return o.rank===1&&(v=me(v,c)),F(v,o.shape)},variance:()=>{let v=D(D(p,h),d);return o.rank===1&&(v=me(v,c)),F(v,o.shape)},scale:()=>{const v=D(h,f);let b=D(t,v);return o.rank===1&&(b=me(b,c)),F(b,o.shape)},offset:()=>{let v=t;return o.rank===1&&(v=me(v,c)),F(v,o.shape)}}}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -4526,7 +4526,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const gG={kernelName:Dp,inputsToSave:["x","indices"],gradFunc:(t,e,n)=>{const[s,r]=e,{axis:o,batchDims:i}=n,a=Re(o,s.shape)[0],l=(c,u,h)=>()=>{const d=c.shape,f=u.size,p=d.slice(0,a),g=p.length,x=d.slice(o,d.length).slice(1),m=x.length,y=LC(0,g),w=LC(g+1,g+1+m),v=BC([p,[f],x]),b=F(h,v),C=F(u,[f]),k=BC([[g],y,w]),S=Fe(b,k);let $=kN(S,C,c.shape[a]);const N=Ho(k);return $=Fe($,N),$};if(i===1){const c=s.shape[0],u=s.split(c,0);return{x:()=>Hr(u.map((f,p)=>l(f,r.slice(p,1),t.slice(p,1))())).reshape(s.shape),indices:()=>r}}else return{x:l(s,r,t),indices:()=>r}}};function LC(t,e){const n=[];for(let s=t;s{const[s,r]=e,{axis:o,batchDims:i}=n,a=Re(o,s.shape)[0],l=(c,u,h)=>()=>{const d=c.shape,f=u.size,p=d.slice(0,a),g=p.length,x=d.slice(o,d.length).slice(1),m=x.length,y=LC(0,g),w=LC(g+1,g+1+m),v=BC([p,[f],x]),b=F(h,v),C=F(u,[f]),k=BC([[g],y,w]),S=Fe(b,k);let $=kN(S,C,c.shape[a]);const N=Ho(k);return $=Fe($,N),$};if(i===1){const c=s.shape[0],u=s.split(c,0);return{x:()=>Hr(u.map((f,p)=>l(f,r.slice(p,1),t.slice(p,1))())).reshape(s.shape),indices:()=>r}}else return{x:l(s,r,t),indices:()=>r}}};function LC(t,e){const n=[];for(let s=t;s{const[n,s]=e;return{a:()=>ze(n),b:()=>ze(s)}}};/** + */const gG={kernelName:Du,inputsToSave:["a","b"],gradFunc:(t,e)=>{const[n,s]=e;return{a:()=>ze(n),b:()=>ze(s)}}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -4556,7 +4556,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const yG={kernelName:Fu,gradFunc:t=>({x:()=>le(t,"float32")})};/** + */const xG={kernelName:_u,gradFunc:t=>({x:()=>le(t,"float32")})};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -4571,7 +4571,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const wG={kernelName:zu,gradFunc:t=>({x:()=>ze(t)})};/** + */const yG={kernelName:Fu,gradFunc:t=>({x:()=>ze(t)})};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -4586,7 +4586,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const vG={kernelName:Ou,gradFunc:t=>({x:()=>ze(t)})};/** + */const wG={kernelName:zu,gradFunc:t=>({x:()=>ze(t)})};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -4601,7 +4601,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const bG={kernelName:Mu,gradFunc:t=>({x:()=>ze(t)})};/** + */const vG={kernelName:Ou,gradFunc:t=>({x:()=>ze(t)})};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -4616,7 +4616,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const CG={kernelName:Fp,inputsToSave:["x"],gradFunc:(t,e,n)=>{const[s]=e,{alpha:r}=n,o=us(s,0);return{x:()=>Cn(o,t,D(t,r))}}};/** + */const bG={kernelName:Fp,inputsToSave:["x"],gradFunc:(t,e,n)=>{const[s]=e,{alpha:r}=n,o=us(s,0);return{x:()=>Cn(o,t,D(t,r))}}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -4631,7 +4631,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const kG={kernelName:Lu,inputsToSave:["x"],gradFunc:(t,e)=>{const[n]=e;return{x:()=>ge(t,J(n,1))}}};/** + */const CG={kernelName:Pu,inputsToSave:["x"],gradFunc:(t,e)=>{const[n]=e;return{x:()=>ge(t,J(n,1))}}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -4646,7 +4646,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const SG={kernelName:Pu,inputsToSave:["x"],gradFunc:(t,e)=>{const[n]=e;return{x:()=>ge(t,le(n,"float32"))}}};/** + */const kG={kernelName:Mu,inputsToSave:["x"],gradFunc:(t,e)=>{const[n]=e;return{x:()=>ge(t,le(n,"float32"))}}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -4661,7 +4661,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const IG={kernelName:UM,inputsToSave:[],outputsToSave:[!0],gradFunc:(t,e,n)=>{const[s]=e,{axis:r}=n;return{logits:()=>{const i=Sr(s);return ve(t,D(me(t,r,!0),i))}}}};/** + */const SG={kernelName:WM,inputsToSave:[],outputsToSave:[!0],gradFunc:(t,e,n)=>{const[s]=e,{axis:r}=n;return{logits:()=>{const i=Sr(s);return ve(t,D(me(t,r,!0),i))}}}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -4676,7 +4676,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function $G(t,e,n,s=5,r=1,o=1,i=.5){const a={x:t,y:e,dy:n},l={depthRadius:s,bias:r,alpha:o,beta:i};return _.runKernel(py,a,l)}const NG=z({localResponseNormalizationBackprop_:$G});/** + */function IG(t,e,n,s=5,r=1,o=1,i=.5){const a={x:t,y:e,dy:n},l={depthRadius:s,bias:r,alpha:o,beta:i};return _.runKernel(py,a,l)}const $G=z({localResponseNormalizationBackprop_:IG});/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -4691,7 +4691,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const TG={kernelName:Bp,inputsToSave:["x"],outputsToSave:[!0],gradFunc:(t,e,n)=>{const[s,r]=e,{depthRadius:o,bias:i,alpha:a,beta:l}=n;return{x:()=>NG(s,r,t,o,i,a,l)}}};/** + */const NG={kernelName:Bp,inputsToSave:["x"],outputsToSave:[!0],gradFunc:(t,e,n)=>{const[s,r]=e,{depthRadius:o,bias:i,alpha:a,beta:l}=n;return{x:()=>$G(s,r,t,o,i,a,l)}}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -4736,7 +4736,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const EG={kernelName:Bu,inputsToSave:["a","b"],gradFunc:(t,e)=>{const[n,s]=e;return{a:()=>D(t,le(Xi(n,s),"float32")),b:()=>D(t,le(vf(n,s),"float32"))}}};/** + */const TG={kernelName:Lu,inputsToSave:["a","b"],gradFunc:(t,e)=>{const[n,s]=e;return{a:()=>D(t,le(Xi(n,s),"float32")),b:()=>D(t,le(wf(n,s),"float32"))}}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -4751,7 +4751,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function RG(t,e,n,s,r,o,i){const a=T(t,"dy","maxPool3dGrad"),l=T(e,"input","maxPool3dGrad"),c=T(n,"output","maxPool3dGrad");let u=a,h=l,d=c,f=!1;l.rank===4&&(f=!0,u=F(a,[1,a.shape[0],a.shape[1],a.shape[2],a.shape[3]]),h=F(l,[1,l.shape[0],l.shape[1],l.shape[2],l.shape[3]]),d=F(c,[1,c.shape[0],c.shape[1],c.shape[2],c.shape[3]])),I(u.rank===5,()=>`Error in maxPool3dGrad: dy must be rank 5 but got rank ${u.rank}.`),I(h.rank===5,()=>`Error in maxPool3dGrad: input must be rank 5 but got rank ${h.rank}.`),I(d.rank===5,()=>`Error in maxPool3dGrad: output must be rank 5 but got rank ${d.rank}.`),Mn("maxPool3dGrad",o,i);const p={dy:u,input:h,output:d},g={filterSize:s,strides:r,pad:o,dimRoundingMode:i},x=_.runKernel(gy,p,g);return f?F(x,[x.shape[1],x.shape[2],x.shape[3],x.shape[4]]):x}const AG=z({maxPool3dGrad_:RG});/** + */function EG(t,e,n,s,r,o,i){const a=T(t,"dy","maxPool3dGrad"),l=T(e,"input","maxPool3dGrad"),c=T(n,"output","maxPool3dGrad");let u=a,h=l,d=c,f=!1;l.rank===4&&(f=!0,u=F(a,[1,a.shape[0],a.shape[1],a.shape[2],a.shape[3]]),h=F(l,[1,l.shape[0],l.shape[1],l.shape[2],l.shape[3]]),d=F(c,[1,c.shape[0],c.shape[1],c.shape[2],c.shape[3]])),I(u.rank===5,()=>`Error in maxPool3dGrad: dy must be rank 5 but got rank ${u.rank}.`),I(h.rank===5,()=>`Error in maxPool3dGrad: input must be rank 5 but got rank ${h.rank}.`),I(d.rank===5,()=>`Error in maxPool3dGrad: output must be rank 5 but got rank ${d.rank}.`),Mn("maxPool3dGrad",o,i);const p={dy:u,input:h,output:d},g={filterSize:s,strides:r,pad:o,dimRoundingMode:i},x=_.runKernel(gy,p,g);return f?F(x,[x.shape[1],x.shape[2],x.shape[3],x.shape[4]]):x}const RG=z({maxPool3dGrad_:EG});/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -4766,7 +4766,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const DG={kernelName:Up,inputsToSave:["x"],outputsToSave:[!0],gradFunc:(t,e,n)=>{const[s,r]=e,{filterSize:o,strides:i,pad:a,dimRoundingMode:l}=n;return{x:()=>AG(t,s,r,o,i,a,l)}}};/** + */const AG={kernelName:Up,inputsToSave:["x"],outputsToSave:[!0],gradFunc:(t,e,n)=>{const[s,r]=e,{filterSize:o,strides:i,pad:a,dimRoundingMode:l}=n;return{x:()=>RG(t,s,r,o,i,a,l)}}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -4781,7 +4781,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function _G(t,e,n,s,r,o,i){const a=T(t,"dy","maxPoolGrad"),l=T(e,"input","maxPoolGrad"),c=T(n,"output","maxPoolGrad");I(l.rank===a.rank,()=>`Rank of input (${l.rank}) does not match rank of dy (${a.rank})`),I(a.rank===4,()=>`Error in maxPoolGrad: dy must be rank 4 but got rank ${a.rank}.`),I(l.rank===4,()=>`Error in maxPoolGrad: input must be rank 4 but got rank ${l.rank}.`),Mn("maxPoolGrad",o,i);const u={dy:a,input:l,output:c},h={filterSize:s,strides:r,pad:o,dimRoundingMode:i};return _.runKernel(my,u,h)}const FG=z({maxPoolGrad_:_G});/** + */function DG(t,e,n,s,r,o,i){const a=T(t,"dy","maxPoolGrad"),l=T(e,"input","maxPoolGrad"),c=T(n,"output","maxPoolGrad");I(l.rank===a.rank,()=>`Rank of input (${l.rank}) does not match rank of dy (${a.rank})`),I(a.rank===4,()=>`Error in maxPoolGrad: dy must be rank 4 but got rank ${a.rank}.`),I(l.rank===4,()=>`Error in maxPoolGrad: input must be rank 4 but got rank ${l.rank}.`),Mn("maxPoolGrad",o,i);const u={dy:a,input:l,output:c},h={filterSize:s,strides:r,pad:o,dimRoundingMode:i};return _.runKernel(my,u,h)}const _G=z({maxPoolGrad_:DG});/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -4796,7 +4796,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const zG={kernelName:Wp,inputsToSave:["x"],outputsToSave:[!0],gradFunc:(t,e,n)=>{const[s,r]=e,{filterSize:o,strides:i,pad:a}=n;return{x:()=>FG(t,s,r,o,i,a)}}};/** + */const FG={kernelName:Wp,inputsToSave:["x"],outputsToSave:[!0],gradFunc:(t,e,n)=>{const[s,r]=e,{filterSize:o,strides:i,pad:a}=n;return{x:()=>_G(t,s,r,o,i,a)}}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -4811,7 +4811,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const OG={kernelName:Gp,inputsToSave:["x"],gradFunc:(t,e,n)=>{const[s]=e,{axis:r}=n,o=Re(r,s.shape),a=Yt(s.shape,o)[1],l=j(a);return{x:()=>{const u=s.shape.slice();o.forEach(f=>{u[f]=1});const h=F(t,u);return ge(D(h,Ko(s.shape,"float32")),l)}}}};/** + */const zG={kernelName:Gp,inputsToSave:["x"],gradFunc:(t,e,n)=>{const[s]=e,{axis:r}=n,o=Re(r,s.shape),a=Yt(s.shape,o)[1],l=j(a);return{x:()=>{const u=s.shape.slice();o.forEach(f=>{u[f]=1});const h=F(t,u);return ge(D(h,Ko(s.shape,"float32")),l)}}}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -4826,7 +4826,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const MG={kernelName:Hp,inputsToSave:["x"],outputsToSave:[!0],gradFunc:(t,e,n)=>{const s=n,{axis:r}=s,[o,i]=e,a=Re(r,o.shape),l=mT(t,i,o,a);return{x:()=>l.x()}}};/** + */const OG={kernelName:Hp,inputsToSave:["x"],outputsToSave:[!0],gradFunc:(t,e,n)=>{const s=n,{axis:r}=s,[o,i]=e,a=Re(r,o.shape),l=mT(t,i,o,a);return{x:()=>l.x()}}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -4841,7 +4841,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const PG={kernelName:Vu,inputsToSave:["a","b"],gradFunc:(t,e)=>{const[n,s]=e;return{a:()=>D(t,le(kl(n,s),"float32")),b:()=>D(t,le(us(n,s),"float32"))}}};/** + */const MG={kernelName:Bu,inputsToSave:["a","b"],gradFunc:(t,e)=>{const[n,s]=e;return{a:()=>D(t,le(kl(n,s),"float32")),b:()=>D(t,le(us(n,s),"float32"))}}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -4856,7 +4856,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const LG={kernelName:jp,inputsToSave:["x"],gradFunc:(t,e,n)=>{const s=e[0],{paddings:r}=n,o=r.map(i=>i[0]);return{x:()=>tt(t,o,s.shape)}}};/** + */const PG={kernelName:jp,inputsToSave:["x"],gradFunc:(t,e,n)=>{const s=e[0],{paddings:r}=n,o=r.map(i=>i[0]);return{x:()=>tt(t,o,s.shape)}}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -4871,7 +4871,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const BG={kernelName:Wu,inputsToSave:["a","b"],gradFunc:(t,e)=>{const[n,s]=e,r=Se(n.shape,s.shape);return{a:()=>{const a=Vt(n.shape,r);return a.length>0?F(me(t,a),n.shape):t},b:()=>{const a=D(t,St(vm(ge(n,s)))),l=Vt(s.shape,r);return l.length>0?F(me(a,l),s.shape):a}}}};/** + */const LG={kernelName:Vu,inputsToSave:["a","b"],gradFunc:(t,e)=>{const[n,s]=e,r=Se(n.shape,s.shape);return{a:()=>{const a=Vt(n.shape,r);return a.length>0?F(me(t,a),n.shape):t},b:()=>{const a=D(t,St(vm(ge(n,s)))),l=Vt(s.shape,r);return l.length>0?F(me(a,l),s.shape):a}}}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -4886,7 +4886,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const VG={kernelName:Uu,inputsToSave:["a","b"],gradFunc:(t,e)=>{const[n,s]=e,r=Se(n.shape,s.shape);return{a:()=>{const a=D(t,le(s,"float32")),l=Vt(n.shape,r);return l.length>0?F(me(a,l),n.shape):a},b:()=>{const a=D(t,le(n,"float32")),l=Vt(s.shape,r);return l.length>0?F(me(a,l),s.shape):a}}}};/** + */const BG={kernelName:Wu,inputsToSave:["a","b"],gradFunc:(t,e)=>{const[n,s]=e,r=Se(n.shape,s.shape);return{a:()=>{const a=D(t,le(s,"float32")),l=Vt(n.shape,r);return l.length>0?F(me(a,l),n.shape):a},b:()=>{const a=D(t,le(n,"float32")),l=Vt(s.shape,r);return l.length>0?F(me(a,l),s.shape):a}}}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -4901,7 +4901,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const WG={kernelName:Kp,gradFunc:t=>({x:()=>St(t)})};/** + */const VG={kernelName:Kp,gradFunc:t=>({x:()=>St(t)})};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -4916,7 +4916,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const UG={kernelName:Yp,inputsToSave:["indices"],gradFunc:(t,e)=>{const n=e[0];return{indices:()=>Kt(n.shape,"float32")}}};/** + */const WG={kernelName:Yp,inputsToSave:["indices"],gradFunc:(t,e)=>{const n=e[0];return{indices:()=>Kt(n.shape,"float32")}}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -4931,7 +4931,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const GG={kernelName:qp,gradFunc:t=>({x:()=>ze(t)})};/** + */const UG={kernelName:qp,gradFunc:t=>({x:()=>ze(t)})};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -4946,7 +4946,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const HG={kernelName:Qp,saveAllInputs:!0,gradFunc:(t,e,n)=>{const{axis:s}=n;return Pi(t,s).map(o=>()=>o)}};/** + */const GG={kernelName:Qp,saveAllInputs:!0,gradFunc:(t,e,n)=>{const{axis:s}=n;return Pi(t,s).map(o=>()=>o)}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -4976,7 +4976,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const jG={kernelName:Gu,inputsToSave:["a","b"],outputsToSave:[!0],gradFunc:(t,e)=>{const[n,s,r]=e,o=n,i=s,a=Se(o.shape,i.shape);return{a:()=>{const u=le(i,"float32");let h=D(t,D(u,Oi(o,ve(u,We(1)))));const d=Vt(o.shape,a);return d.length>0&&(h=me(h,d)),F(h,o.shape)},b:()=>{const u=us(o,0),h=Cn(u,Ir(o),ze(o));let d=D(t,D(r,h));const f=Vt(i.shape,a);return f.length>0&&(d=me(d,f)),F(d,i.shape)}}}};/** + */const HG={kernelName:Uu,inputsToSave:["a","b"],outputsToSave:[!0],gradFunc:(t,e)=>{const[n,s,r]=e,o=n,i=s,a=Se(o.shape,i.shape);return{a:()=>{const u=le(i,"float32");let h=D(t,D(u,Oi(o,ve(u,We(1)))));const d=Vt(o.shape,a);return d.length>0&&(h=me(h,d)),F(h,o.shape)},b:()=>{const u=us(o,0),h=Cn(u,Ir(o),ze(o));let d=D(t,D(r,h));const f=Vt(i.shape,a);return f.length>0&&(d=me(d,f)),F(d,i.shape)}}}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -4991,7 +4991,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const KG={kernelName:Jp,inputsToSave:["x","alpha"],gradFunc:(t,e)=>{const[n,s]=e,r=us(n,0);return{x:()=>Cn(r,t,D(t,s)),alpha:()=>{let o=Cn(r,ze(t),D(t,n));const i=Vt(s.shape,t.shape);return i.length>0&&(o=me(o,i)),F(o,s.shape)}}}};/** + */const jG={kernelName:Jp,inputsToSave:["x","alpha"],gradFunc:(t,e)=>{const[n,s]=e,r=us(n,0);return{x:()=>Cn(r,t,D(t,s)),alpha:()=>{let o=Cn(r,ze(t),D(t,n));const i=Vt(s.shape,t.shape);return i.length>0&&(o=me(o,i)),F(o,s.shape)}}}};/** * @license * Copyright 2022 Google Inc. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -5006,7 +5006,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function XG(t,e,n){const s=t.shape.slice();s[n]=1;const r=F(e,s),o=d1(t,n,!0,!1),i=d1(t,n,!0,!0),a=D(o,i);return D(r,a)}function qG(t,e,n){const s=t.shape.length,r=s-n.length,o=yt(n,s);let i=t;o!=null&&(i=Fe(t,o));const a=i.shape.slice(),c=a.splice(s-n.length,n.length).reduce((d,f)=>d*f,1);a.push(c);const u=i.reshape(a);let h=XG(u,e,r);if(h=h.reshape(i.shape),o!=null){const d=Ho(o);h=Fe(h,d)}return h}const YG={kernelName:em,inputsToSave:["x"],gradFunc:(t,e,n)=>{const[s]=e,{axis:r}=n;let o=[];return r==null?o=s.shape.map((i,a)=>a):typeof r=="number"?o=[r]:o=r,{x:()=>qG(s,t,o)}}};/** + */function KG(t,e,n){const s=t.shape.slice();s[n]=1;const r=F(e,s),o=d1(t,n,!0,!1),i=d1(t,n,!0,!0),a=D(o,i);return D(r,a)}function XG(t,e,n){const s=t.shape.length,r=s-n.length,o=yt(n,s);let i=t;o!=null&&(i=Fe(t,o));const a=i.shape.slice(),c=a.splice(s-n.length,n.length).reduce((d,f)=>d*f,1);a.push(c);const u=i.reshape(a);let h=KG(u,e,r);if(h=h.reshape(i.shape),o!=null){const d=Ho(o);h=Fe(h,d)}return h}const qG={kernelName:em,inputsToSave:["x"],gradFunc:(t,e,n)=>{const[s]=e,{axis:r}=n;let o=[];return r==null?o=s.shape.map((i,a)=>a):typeof r=="number"?o=[r]:o=r,{x:()=>XG(s,t,o)}}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -5021,7 +5021,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const QG={kernelName:$u,inputsToSave:["a","b"],gradFunc:(t,e)=>{const[n,s]=e,r=Se(n.shape,s.shape);return{a:()=>{const a=ge(t,le(s,"float32")),l=Vt(n.shape,r);return l.length>0?F(me(a,l),n.shape):a},b:()=>{let a=D(t,le(n,"float32"));const l=Vt(s.shape,r);l.length>0&&(a=F(me(a,l),s.shape));const c=ot(s);return St(ge(a,le(c,"float32")))}}}};/** + */const YG={kernelName:Iu,inputsToSave:["a","b"],gradFunc:(t,e)=>{const[n,s]=e,r=Se(n.shape,s.shape);return{a:()=>{const a=ge(t,le(s,"float32")),l=Vt(n.shape,r);return l.length>0?F(me(a,l),n.shape):a},b:()=>{let a=D(t,le(n,"float32"));const l=Vt(s.shape,r);l.length>0&&(a=F(me(a,l),s.shape));const c=ot(s);return St(ge(a,le(c,"float32")))}}}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -5036,7 +5036,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const ZG={kernelName:Hu,inputsToSave:["x"],gradFunc:(t,e)=>{const[n]=e;return{x:()=>ge(t,St(ot(n)))}}};/** + */const QG={kernelName:Gu,inputsToSave:["x"],gradFunc:(t,e)=>{const[n]=e;return{x:()=>ge(t,St(ot(n)))}}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -5051,7 +5051,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const JG={kernelName:Ku,inputsToSave:["x"],gradFunc:(t,e)=>{const[n]=e,s=D(kl(n,6),mh(n));return{x:()=>D(t,le(s,"float32"))}}};/** + */const ZG={kernelName:ju,inputsToSave:["x"],gradFunc:(t,e)=>{const[n]=e,s=D(kl(n,6),ph(n));return{x:()=>D(t,le(s,"float32"))}}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -5066,7 +5066,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const e6={kernelName:ju,inputsToSave:["x"],gradFunc:(t,e)=>{const[n]=e;return{x:()=>D(t,le(mh(n),"float32"))}}};/** + */const JG={kernelName:Hu,inputsToSave:["x"],gradFunc:(t,e)=>{const[n]=e;return{x:()=>D(t,le(ph(n),"float32"))}}};/** * @license * Copyright 2020 Google Inc. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -5081,7 +5081,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const t6={kernelName:tm,inputsToSave:["x"],gradFunc:(t,e)=>{const[n]=e;return{x:()=>F(t,n.shape)}}};/** + */const e6={kernelName:tm,inputsToSave:["x"],gradFunc:(t,e)=>{const[n]=e;return{x:()=>F(t,n.shape)}}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -5096,7 +5096,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const n6={kernelName:sm,inputsToSave:["images"],gradFunc:(t,e,n)=>{const[s]=e,r={dy:t,images:s};return{images:()=>_.runKernel(ky,r,n)}}};/** + */const t6={kernelName:sm,inputsToSave:["images"],gradFunc:(t,e,n)=>{const[s]=e,r={dy:t,images:s};return{images:()=>_.runKernel(ky,r,n)}}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -5111,7 +5111,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const s6={kernelName:nm,inputsToSave:["images"],gradFunc:(t,e,n)=>{const[s]=e,r={dy:t,images:s};return{images:()=>_.runKernel(Cy,r,n)}}};/** + */const n6={kernelName:nm,inputsToSave:["images"],gradFunc:(t,e,n)=>{const[s]=e,r={dy:t,images:s};return{images:()=>_.runKernel(Cy,r,n)}}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -5126,7 +5126,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const r6={kernelName:rm,gradFunc:(t,e,n)=>{const{dims:s}=n,r=Re(s,t.shape);return{x:()=>Mi(t,r)}}};/** + */const s6={kernelName:rm,gradFunc:(t,e,n)=>{const{dims:s}=n,r=Re(s,t.shape);return{x:()=>Mi(t,r)}}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -5141,7 +5141,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const o6={kernelName:Xu,gradFunc:t=>({x:()=>ze(t)})};/** + */const r6={kernelName:Ku,gradFunc:t=>({x:()=>ze(t)})};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -5156,7 +5156,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const i6={kernelName:qu,inputsToSave:["x"],gradFunc:(t,e)=>{const[n]=e;return{x:()=>St(ge(t,D(Oi(n,1.5),2)))}}};/** + */const o6={kernelName:Xu,inputsToSave:["x"],gradFunc:(t,e)=>{const[n]=e;return{x:()=>St(ge(t,D(Oi(n,1.5),2)))}}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -5171,7 +5171,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const a6={kernelName:om,inputsToSave:["condition"],gradFunc:(t,e)=>{const[n]=e;return{condition:()=>le(ze(n),"float32"),t:()=>D(t,le(n,t.dtype)),e:()=>D(t,le(Hy(n),t.dtype))}}};/** + */const i6={kernelName:om,inputsToSave:["condition"],gradFunc:(t,e)=>{const[n]=e;return{condition:()=>le(ze(n),"float32"),t:()=>D(t,le(n,t.dtype)),e:()=>D(t,le(Hy(n),t.dtype))}}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -5186,7 +5186,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const l6={kernelName:Yu,inputsToSave:["x"],gradFunc:(t,e)=>{const[n]=e;return{x:()=>{const s=us(n,We(0)),r=We(km),o=We(Sm),i=D(t,o),a=D(D(t,r),Sr(le(n,"float32")));return Cn(s,i,a)}}}};/** + */const a6={kernelName:qu,inputsToSave:["x"],gradFunc:(t,e)=>{const[n]=e;return{x:()=>{const s=us(n,We(0)),r=We(km),o=We(Sm),i=D(t,o),a=D(D(t,r),Sr(le(n,"float32")));return Cn(s,i,a)}}}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -5201,7 +5201,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const c6={kernelName:eh,outputsToSave:[!0],gradFunc:(t,e)=>{const[n]=e;return{x:()=>D(t,D(n,ve(We(1),n)))}}};/** + */const l6={kernelName:Ju,outputsToSave:[!0],gradFunc:(t,e)=>{const[n]=e;return{x:()=>D(t,D(n,ve(We(1),n)))}}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -5216,7 +5216,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const u6={kernelName:Ju,gradFunc:t=>({x:()=>ze(t)})};/** + */const c6={kernelName:Zu,gradFunc:t=>({x:()=>ze(t)})};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -5231,7 +5231,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const h6={kernelName:Qu,inputsToSave:["x"],gradFunc:(t,e)=>{const[n]=e;return{x:()=>D(Ly(le(n,"float32")),t)}}};/** + */const u6={kernelName:Yu,inputsToSave:["x"],gradFunc:(t,e)=>{const[n]=e;return{x:()=>D(Ly(le(n,"float32")),t)}}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -5246,7 +5246,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const d6={kernelName:Zu,inputsToSave:["x"],gradFunc:(t,e)=>{const[n]=e;return{x:()=>D(J$(le(n,"float32")),t)}}};/** + */const h6={kernelName:Qu,inputsToSave:["x"],gradFunc:(t,e)=>{const[n]=e;return{x:()=>D(J$(le(n,"float32")),t)}}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -5261,7 +5261,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const f6={kernelName:im,inputsToSave:["x"],gradFunc:(t,e,n)=>{const[s]=e,{begin:r,size:o}=n,i=s.shape,[a,l]=bm(s,r,o),c=[];for(let u=0;uXy(t,c)}}};/** + */const d6={kernelName:im,inputsToSave:["x"],gradFunc:(t,e,n)=>{const[s]=e,{begin:r,size:o}=n,i=s.shape,[a,l]=bm(s,r,o),c=[];for(let u=0;uXy(t,c)}}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -5276,7 +5276,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const p6={kernelName:um,outputsToSave:[!0],gradFunc:(t,e,n)=>{const[s]=e,{dim:r}=n,o=!0,i=D(t,s);return{logits:()=>ve(i,D(me(i,[r],o),s))}}};/** + */const f6={kernelName:um,outputsToSave:[!0],gradFunc:(t,e,n)=>{const[s]=e,{dim:r}=n,o=!0,i=D(t,s);return{logits:()=>ve(i,D(me(i,[r],o),s))}}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -5291,7 +5291,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const m6={kernelName:th,inputsToSave:["x"],gradFunc:(t,e)=>{const[n]=e;return{x:()=>D(t,Cl(n))}}};/** + */const p6={kernelName:eh,inputsToSave:["x"],gradFunc:(t,e)=>{const[n]=e;return{x:()=>D(t,Cl(n))}}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -5336,7 +5336,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const g6={kernelName:nh,inputsToSave:["x"],gradFunc:(t,e)=>{const[n]=e;return{x:()=>ge(t,D(hn(le(n,"float32")),2))}}};/** + */const m6={kernelName:th,inputsToSave:["x"],gradFunc:(t,e)=>{const[n]=e;return{x:()=>ge(t,D(hn(le(n,"float32")),2))}}};/** * @license * Copyright 2019 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -5351,7 +5351,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const x6={kernelName:Sy,inputsToSave:["x"],gradFunc:(t,e)=>{const[n]=e;return{x:()=>D(t,D(le(n,"float32"),2))}}};/** + */const g6={kernelName:Sy,inputsToSave:["x"],gradFunc:(t,e)=>{const[n]=e;return{x:()=>D(t,D(le(n,"float32"),2))}}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -5366,7 +5366,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const y6={kernelName:sh,inputsToSave:["a","b"],gradFunc:(t,e)=>{const[n,s]=e,r=We(2);return{a:()=>D(t,D(r,ve(n,s))),b:()=>D(t,D(r,ve(s,n)))}}};/** + */const x6={kernelName:nh,inputsToSave:["a","b"],gradFunc:(t,e)=>{const[n,s]=e,r=We(2);return{a:()=>D(t,D(r,ve(n,s))),b:()=>D(t,D(r,ve(s,n)))}}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -5381,7 +5381,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const w6={kernelName:lh,gradFunc:t=>({x:()=>ze(t)})};/** + */const y6={kernelName:ah,gradFunc:t=>({x:()=>ze(t)})};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -5396,7 +5396,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const v6={kernelName:rh,inputsToSave:["a","b"],gradFunc:(t,e)=>{const[n,s]=e,r=Se(n.shape,s.shape);return{a:()=>{let a=t;const l=Vt(n.shape,r);return l.length>0&&(a=me(a,l)),F(a,n.shape)},b:()=>{let a=t;const l=Vt(s.shape,r);return l.length>0&&(a=me(a,l)),F(St(a),s.shape)}}}};/** + */const w6={kernelName:sh,inputsToSave:["a","b"],gradFunc:(t,e)=>{const[n,s]=e,r=Se(n.shape,s.shape);return{a:()=>{let a=t;const l=Vt(n.shape,r);return l.length>0&&(a=me(a,l)),F(a,n.shape)},b:()=>{let a=t;const l=Vt(s.shape,r);return l.length>0&&(a=me(a,l)),F(St(a),s.shape)}}}};/** * @license * Copyright 2020 Google Inc. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -5411,7 +5411,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const b6={kernelName:am,inputsToSave:["x"],gradFunc:(t,e,n)=>{const[s]=e,r=s.shape.slice(),{axis:o}=n;Re(o,s.shape).forEach(c=>{r[c]=1});const a=F(t,r),l=D(a,Ko(s.shape,"float32"));return{x:()=>l}}};/** + */const v6={kernelName:am,inputsToSave:["x"],gradFunc:(t,e,n)=>{const[s]=e,r=s.shape.slice(),{axis:o}=n;Re(o,s.shape).forEach(c=>{r[c]=1});const a=F(t,r),l=D(a,Ko(s.shape,"float32"));return{x:()=>l}}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -5426,7 +5426,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const C6={kernelName:oh,inputsToSave:["x"],gradFunc:(t,e)=>{const[n]=e;return{x:()=>ge(t,ot(Ly(n)))}}};/** + */const b6={kernelName:rh,inputsToSave:["x"],gradFunc:(t,e)=>{const[n]=e;return{x:()=>ge(t,ot(Ly(n)))}}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -5441,7 +5441,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const k6={kernelName:ih,outputsToSave:[!0],gradFunc:(t,e)=>{const[n]=e;return{x:()=>D(ve(We(1),ot(n)),t)}}};/** + */const C6={kernelName:oh,outputsToSave:[!0],gradFunc:(t,e)=>{const[n]=e;return{x:()=>D(ve(We(1),ot(n)),t)}}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -5456,7 +5456,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const S6={kernelName:ah,inputsToSave:["x"],gradFunc:(t,e,n)=>{const[s]=e,{reps:r}=n;return{x:()=>{let i=ze(s);if(s.rank===1)for(let a=0;a{const[s]=e,{reps:r}=n;return{x:()=>{let i=ze(s);if(s.rank===1)for(let a=0;a{const s=n,{perm:r}=s,o=Ho(r);return{x:()=>Fe(t,o)}}};/** + */const S6={kernelName:Ma,gradFunc:(t,e,n)=>{const s=n,{perm:r}=s,o=Ho(r);return{x:()=>Fe(t,o)}}};/** * @license * Copyright 2020 Google Inc. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -5486,7 +5486,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const $6={kernelName:hm,gradFunc:(t,e,n)=>{const s=n,{axis:r}=s;return{value:()=>Hr(t,r)}}};/** + */const I6={kernelName:hm,gradFunc:(t,e,n)=>{const s=n,{axis:r}=s;return{value:()=>Hr(t,r)}}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -5501,7 +5501,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const N6={kernelName:dm,inputsToSave:["segmentIds"],gradFunc:(t,e)=>{const[n]=e;return{x:()=>T6(t,n)}}};function T6(t,e){const n=jo(e,ze(e)),s=Wy(t,n);let r=Xi(e,We(0,"int32"));const o=s.rank-r.rank;for(let a=0;a{const[n]=e;return{x:()=>N6(t,n)}}};function N6(t,e){const n=jo(e,ze(e)),s=Wy(t,n);let r=Xi(e,We(0,"int32"));const o=s.rank-r.rank;for(let a=0;a({x:()=>ze(t)})};/** + */const T6={kernelName:fm,gradFunc:t=>({x:()=>ze(t)})};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -5531,7 +5531,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const R6=[pT,NU,TU,EU,RU,AU,DU,_U,FU,zU,OU,MU,BU,UU,GU,HU,jU,KU,XU,qU,YU,QU,JU,ZU,nG,sG,rG,oG,iG,aG,QG,lG,cG,uG,hG,dG,pG,fG,mG,gG,xG,yG,wG,vG,bG,CG,kG,SG,IG,TG,VC,VC,EG,DG,zG,OG,MG,PG,LG,BG,VG,WG,UG,GG,HG,WC,WC,jG,KG,YG,ZG,JG,e6,t6,n6,s6,r6,o6,i6,a6,l6,c6,u6,h6,d6,f6,p6,m6,UC,UC,GC,GC,g6,y6,x6,w6,v6,b6,C6,k6,S6,I6,$6,N6,E6];for(const t of R6)jM(t);/** + */const E6=[pT,$U,NU,TU,EU,RU,AU,DU,_U,FU,zU,OU,LU,WU,UU,GU,HU,jU,KU,XU,qU,YU,ZU,QU,tG,nG,sG,rG,oG,iG,YG,aG,lG,cG,uG,hG,fG,dG,pG,mG,gG,xG,yG,wG,vG,bG,CG,kG,SG,NG,VC,VC,TG,AG,FG,zG,OG,MG,PG,LG,BG,VG,WG,UG,GG,WC,WC,HG,jG,qG,QG,ZG,JG,e6,t6,n6,s6,r6,o6,i6,a6,l6,c6,u6,h6,d6,f6,p6,UC,UC,GC,GC,m6,x6,g6,y6,w6,v6,b6,C6,k6,S6,I6,$6,T6];for(const t of E6)HM(t);/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -5561,7 +5561,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */H().prototype.acos=function(){return this.throwIfDisposed(),oL(this)};/** + */H().prototype.acos=function(){return this.throwIfDisposed(),rL(this)};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -5576,7 +5576,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */H().prototype.acosh=function(){return this.throwIfDisposed(),aL(this)};/** + */H().prototype.acosh=function(){return this.throwIfDisposed(),iL(this)};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -5651,7 +5651,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */H().prototype.argMin=function(t){return this.throwIfDisposed(),dL(this,t)};/** + */H().prototype.argMin=function(t){return this.throwIfDisposed(),hL(this,t)};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -5771,7 +5771,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */H().prototype.asin=function(){return this.throwIfDisposed(),pL(this)};/** + */H().prototype.asin=function(){return this.throwIfDisposed(),fL(this)};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -5786,7 +5786,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */H().prototype.asinh=function(){return this.throwIfDisposed(),gL(this)};/** + */H().prototype.asinh=function(){return this.throwIfDisposed(),mL(this)};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -5801,7 +5801,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */H().prototype.atan=function(){return this.throwIfDisposed(),yL(this)};/** + */H().prototype.atan=function(){return this.throwIfDisposed(),xL(this)};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -5816,7 +5816,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */H().prototype.atan2=function(t){return this.throwIfDisposed(),vL(this,t)};/** + */H().prototype.atan2=function(t){return this.throwIfDisposed(),wL(this,t)};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -5831,7 +5831,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */H().prototype.atanh=function(){return this.throwIfDisposed(),CL(this)};H().prototype.avgPool=function(t,e,n,s){return this.throwIfDisposed(),Oy(this,t,e,n,s)};/** + */H().prototype.atanh=function(){return this.throwIfDisposed(),bL(this)};H().prototype.avgPool=function(t,e,n,s){return this.throwIfDisposed(),Oy(this,t,e,n,s)};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -5906,7 +5906,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */H().prototype.ceil=function(){return this.throwIfDisposed(),qL(this)};/** + */H().prototype.ceil=function(){return this.throwIfDisposed(),XL(this)};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -6056,7 +6056,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */H().prototype.depthToSpace=function(t,e){return this.throwIfDisposed(),v4(this,t,e)};/** + */H().prototype.depthToSpace=function(t,e){return this.throwIfDisposed(),w4(this,t,e)};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -6086,7 +6086,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */H().prototype.dilation2d=function(t,e,n,s,r){return this.throwIfDisposed(),k4(this,t,e,n,s,r)};/** + */H().prototype.dilation2d=function(t,e,n,s,r){return this.throwIfDisposed(),C4(this,t,e,n,s,r)};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -6101,7 +6101,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */H().prototype.divNoNan=function(t){return this.throwIfDisposed(),T4(this,t)};/** + */H().prototype.divNoNan=function(t){return this.throwIfDisposed(),N4(this,t)};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -6131,7 +6131,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */H().prototype.dot=function(t){return this.throwIfDisposed(),R4(this,t)};/** + */H().prototype.dot=function(t){return this.throwIfDisposed(),E4(this,t)};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -6191,7 +6191,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */H().prototype.euclideanNorm=function(t,e){return this.throwIfDisposed(),W4(this,t,e)};/** + */H().prototype.euclideanNorm=function(t,e){return this.throwIfDisposed(),V4(this,t,e)};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -6236,7 +6236,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */H().prototype.expm1=function(){return this.throwIfDisposed(),j4(this)};/** + */H().prototype.expm1=function(){return this.throwIfDisposed(),H4(this)};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -6371,7 +6371,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */H().prototype.irfft=function(){return this.throwIfDisposed(),MV(this)};/** + */H().prototype.irfft=function(){return this.throwIfDisposed(),OV(this)};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -6386,7 +6386,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */H().prototype.isFinite=function(){return this.throwIfDisposed(),tB(this)};/** + */H().prototype.isFinite=function(){return this.throwIfDisposed(),eB(this)};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -6401,7 +6401,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */H().prototype.isInf=function(){return this.throwIfDisposed(),sB(this)};/** + */H().prototype.isInf=function(){return this.throwIfDisposed(),nB(this)};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -6416,7 +6416,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */H().prototype.isNaN=function(){return this.throwIfDisposed(),oB(this)};/** + */H().prototype.isNaN=function(){return this.throwIfDisposed(),rB(this)};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -6461,7 +6461,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */H().prototype.less=function(t){return this.throwIfDisposed(),vf(this,t)};/** + */H().prototype.less=function(t){return this.throwIfDisposed(),wf(this,t)};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -6476,7 +6476,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */H().prototype.localResponseNormalization=function(t,e,n,s){return this.throwIfDisposed(),uB(this,t,e,n,s)};/** + */H().prototype.localResponseNormalization=function(t,e,n,s){return this.throwIfDisposed(),cB(this,t,e,n,s)};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -6491,7 +6491,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */H().prototype.logSigmoid=function(){return this.throwIfDisposed(),xB(this)};/** + */H().prototype.logSigmoid=function(){return this.throwIfDisposed(),gB(this)};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -6611,7 +6611,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */H().prototype.logicalXor=function(t){return this.throwIfDisposed(),IB(this,t)};/** + */H().prototype.logicalXor=function(t){return this.throwIfDisposed(),SB(this,t)};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -6686,7 +6686,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */H().prototype.min=function(t,e){return this.throwIfDisposed(),wf(this,t,e)};/** + */H().prototype.min=function(t,e){return this.throwIfDisposed(),yf(this,t,e)};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -6716,7 +6716,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */H().prototype.mirrorPad=function(t,e){return this.throwIfDisposed(),_B(this,t,e)};/** + */H().prototype.mirrorPad=function(t,e){return this.throwIfDisposed(),DB(this,t,e)};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -6731,7 +6731,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */H().prototype.mod=function(t){return this.throwIfDisposed(),zB(this,t)};/** + */H().prototype.mod=function(t){return this.throwIfDisposed(),FB(this,t)};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -6791,7 +6791,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */H().prototype.notEqual=function(t){return this.throwIfDisposed(),bf(this,t)};/** + */H().prototype.notEqual=function(t){return this.throwIfDisposed(),vf(this,t)};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -6836,7 +6836,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */H().prototype.pad=function(t,e){return this.throwIfDisposed(),Xy(this,t,e)};H().prototype.pool=function(t,e,n,s,r,o){return this.throwIfDisposed(),HB(this,t,e,n,s,r,o)};/** + */H().prototype.pad=function(t,e){return this.throwIfDisposed(),Xy(this,t,e)};H().prototype.pool=function(t,e,n,s,r,o){return this.throwIfDisposed(),GB(this,t,e,n,s,r,o)};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -6881,7 +6881,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */H().prototype.prod=function(t,e){return this.throwIfDisposed(),XB(this,t,e)};/** + */H().prototype.prod=function(t,e){return this.throwIfDisposed(),KB(this,t,e)};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -6896,7 +6896,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */H().prototype.reciprocal=function(){return this.throwIfDisposed(),xV(this)};/** + */H().prototype.reciprocal=function(){return this.throwIfDisposed(),gV(this)};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -7016,7 +7016,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */H().prototype.rfft=function(){return this.throwIfDisposed(),BV(this)};/** + */H().prototype.rfft=function(){return this.throwIfDisposed(),LV(this)};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -7106,7 +7106,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */H().prototype.sign=function(){return this.throwIfDisposed(),$V(this)};/** + */H().prototype.sign=function(){return this.throwIfDisposed(),IV(this)};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -7181,7 +7181,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */H().prototype.softplus=function(){return this.throwIfDisposed(),dh(this)};/** + */H().prototype.softplus=function(){return this.throwIfDisposed(),hh(this)};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -7256,7 +7256,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */H().prototype.squaredDifference=function(t){return this.throwIfDisposed(),WV(this,t)};/** + */H().prototype.squaredDifference=function(t){return this.throwIfDisposed(),VV(this,t)};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -7271,7 +7271,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */H().prototype.squeeze=function(t){return this.throwIfDisposed(),ph(this,t)};/** + */H().prototype.squeeze=function(t){return this.throwIfDisposed(),fh(this,t)};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -7301,7 +7301,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */H().prototype.step=function(t){return this.throwIfDisposed(),mh(this,t)};/** + */H().prototype.step=function(t){return this.throwIfDisposed(),ph(this,t)};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -7316,7 +7316,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */H().prototype.stridedSlice=function(t,e,n,s,r,o,i,a){return this.throwIfDisposed(),KV(this,t,e,n,s,r,o,i,a)};/** + */H().prototype.stridedSlice=function(t,e,n,s,r,o,i,a){return this.throwIfDisposed(),jV(this,t,e,n,s,r,o,i,a)};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -7361,7 +7361,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */H().prototype.tan=function(){return this.throwIfDisposed(),qV(this)};/** + */H().prototype.tan=function(){return this.throwIfDisposed(),XV(this)};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -7451,7 +7451,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */H().prototype.topk=function(t,e){return this.throwIfDisposed(),JV(this,t,e)};/** + */H().prototype.topk=function(t,e){return this.throwIfDisposed(),ZV(this,t,e)};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -7481,7 +7481,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */H().prototype.unique=function(t){return this.throwIfDisposed(),nW(this,t)};/** + */H().prototype.unique=function(t){return this.throwIfDisposed(),tW(this,t)};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -7565,12 +7565,12 @@ body { * license that can be found in the LICENSE file or at * https://opensource.org/licenses/MIT. * ============================================================================= - */function Li(t,e){if(Array.isArray(t)){let n=[];for(let s=0;sn.toUpperCase())}let ds={};function Gw(t){if(t==null)return null;const e={};return e.className=t.getClassName(),e.config=t.getConfig(),e}function g1(t){if(!(t==null||typeof t!="object"))if(Array.isArray(t))t.forEach(e=>g1(e));else{const e=Object.keys(t);for(const n of e){const s=t[n];s!=null&&typeof s=="object"&&(!Array.isArray(s)&&s.type==="ndarray"&&typeof s.value=="number"?t[n]=s.value:g1(s))}}}function wh(t,e={},n={},s="object",r=!1){if(typeof t=="string"){const o=t;let i;if(o in n)i=n[o];else if(o in ds)i=ds[o];else if(i=e[o],i==null)throw new E(`Unknown ${s}: ${t}. This may be due to one of the following reasons: + */function Li(t,e){if(Array.isArray(t)){let n=[];for(let s=0;sn.toUpperCase())}let ds={};function Gw(t){if(t==null)return null;const e={};return e.className=t.getClassName(),e.config=t.getConfig(),e}function g1(t){if(!(t==null||typeof t!="object"))if(Array.isArray(t))t.forEach(e=>g1(e));else{const e=Object.keys(t);for(const n of e){const s=t[n];s!=null&&typeof s=="object"&&(!Array.isArray(s)&&s.type==="ndarray"&&typeof s.value=="number"?t[n]=s.value:g1(s))}}}function yh(t,e={},n={},s="object",r=!1){if(typeof t=="string"){const o=t;let i;if(o in n)i=n[o];else if(o in ds)i=ds[o];else if(i=e[o],i==null)throw new E(`Unknown ${s}: ${t}. This may be due to one of the following reasons: 1. The ${s} is defined in Python, in which case it needs to be ported to TensorFlow.js or your JavaScript code. 2. The custom ${s} is defined in JavaScript, but is not registered properly with tf.serialization.registerClass().`);return i}else{const o=t;if(o.className==null||o.config==null)throw new E(`${s}: Improper config format: ${JSON.stringify(o)}. 'className' and 'config' must set.`);const i=o.className;let a,l;if(i in n?[a,l]=n[i]:i in ds?[a,l]=ds.className:i in e&&([a,l]=e[i]),a==null)throw new E(`Unknown ${s}: ${i}. This may be due to one of the following reasons: 1. The ${s} is defined in Python, in which case it needs to be ported to TensorFlow.js or your JavaScript code. -2. The custom ${s} is defined in JavaScript, but is not registered properly with tf.serialization.registerClass().`);if(l!=null){const c={};for(const f of Object.keys(ds))c[f]=ds[f];for(const f of Object.keys(n))c[f]=n[f];const u=o.config;u.customObjects=c;const h=Object.assign({},ds);for(const f of Object.keys(n))ds[f]=n[f];g1(o.config);const d=l(a,o.config,n,r);return ds=Object.assign({},h),d}else{const c=Object.assign({},ds);for(const h of Object.keys(n))ds[h]=n[h];const u=new a(o.config);return ds=Object.assign({},c),u}}}function A6(t,e){return te?1:0}function ed(t,e){return-1*A6(t,e)}function To(t){if(t==null)return t;const e=[];for(const n of t)e.indexOf(n)===-1&&e.push(n);return e}function D6(t){if(t==null)throw new E(`Invalid value in obj: ${JSON.stringify(t)}`);for(const e in t)if(t.hasOwnProperty(e))return!1;return!0}function Zi(t,e,n){if(n!=null&&t.indexOf(n)<0)throw new E(`${n} is not a valid ${e}. Valid values are ${t} or null/undefined.`)}function Hw(t,e,n=0,s=1/0){return hr(n>=0),hr(s>=n),Array.isArray(t)&&t.length>=n&&t.length<=s&&t.every(r=>typeof r===e)}function qt(t,e){Array.isArray(t)?(I(t.length>0,()=>`${e} is unexpectedly an empty array.`),t.forEach((n,s)=>qt(n,`element ${s+1} of ${e}`))):I(Number.isInteger(t)&&t>0,()=>`Expected ${e} to be a positive integer, but got ${xT(t)}.`)}function xT(t){return t===null?"null":Array.isArray(t)?"["+t.map(e=>xT(e)).join(",")+"]":typeof t=="string"?`"${t}"`:`${t}`}function _6(t,e,n){let s=n!=null?n():Tn(),r;return(...i)=>{const a=n!=null?n():Tn();return a-se?1:0}function Jh(t,e){return-1*R6(t,e)}function To(t){if(t==null)return t;const e=[];for(const n of t)e.indexOf(n)===-1&&e.push(n);return e}function A6(t){if(t==null)throw new E(`Invalid value in obj: ${JSON.stringify(t)}`);for(const e in t)if(t.hasOwnProperty(e))return!1;return!0}function Zi(t,e,n){if(n!=null&&t.indexOf(n)<0)throw new E(`${n} is not a valid ${e}. Valid values are ${t} or null/undefined.`)}function Hw(t,e,n=0,s=1/0){return hr(n>=0),hr(s>=n),Array.isArray(t)&&t.length>=n&&t.length<=s&&t.every(r=>typeof r===e)}function qt(t,e){Array.isArray(t)?(I(t.length>0,()=>`${e} is unexpectedly an empty array.`),t.forEach((n,s)=>qt(n,`element ${s+1} of ${e}`))):I(Number.isInteger(t)&&t>0,()=>`Expected ${e} to be a positive integer, but got ${xT(t)}.`)}function xT(t){return t===null?"null":Array.isArray(t)?"["+t.map(e=>xT(e)).join(",")+"]":typeof t=="string"?`"${t}"`:`${t}`}function D6(t,e,n){let s=n!=null?n():Tn(),r;return(...i)=>{const a=n!=null?n():Tn();return a-s0){const n=`${t}_${e}`;return aa.set(n,1),n}else return t}const W6=new RegExp(/^[A-Za-z0-9][-A-Za-z0-9\._\/]*$/);function kT(t){return!!t.match(W6)}/** + */const aa=new Map;function Nt(t){Zi(F6,"DataFormat",t)}function L6(t){Zi(z6,"InterpolationFormat",t)}function hs(t){Zi(O6,"PaddingMode",t)}function vT(t){Zi(M6,"PoolMode",t)}const kc=[],jC="/";function bi(t,e){kc.push(t);try{const n=e();return kc.pop(),n}catch(n){throw kc.pop(),n}}function B6(){return kc.length===0?"":kc.join(jC)+jC}function bT(t){if(!kT(t))throw new Error("Not a valid tensor name: '"+t+"'");return B6()+t}function CT(t){if(!kT(t))throw new Error("Not a valid tensor name: '"+t+"'");aa.has(t)||aa.set(t,0);const e=aa.get(t);if(aa.set(t,aa.get(t)+1),e>0){const n=`${t}_${e}`;return aa.set(n,1),n}else return t}const V6=new RegExp(/^[A-Za-z0-9][-A-Za-z0-9\._\/]*$/);function kT(t){return!!t.match(V6)}/** * @license * Copyright 2018 Google LLC * @@ -7602,7 +7602,7 @@ body { * license that can be found in the LICENSE file or at * https://opensource.org/licenses/MIT. * ============================================================================= - */function U6(t){return t===parseInt(t.toString(),10)}function Eo(t,e,n){e==null&&(e=0),n==null&&(n=t.length);let s=1;for(let r=e;re&&(e=s)}return e}function Js(t,e){if(ee&&(e=s)}return e}function Js(t,e){if(e{if(t.shape.length!==2)throw new E(`repeat() expects a rank-2 tensor, but received a rank-${t.shape.length} tensor.`);const n=vh(t,1);return x1(n,[1,e,1])})}function H6(t){const e=[Eo(t.shape)];return F(t,e)}function j6(t){if(t.rank<=1)throw new E(`batchFlatten requires a minimum rank of 2. Got rank: ${t.rank}.`);const e=[t.shape[0],Eo(t.shape,1)];return F(t,e)}function Ci(t,e,n){return P(()=>{switch(t.rank){case 1:return rw(t,e,n);case 2:return wN(t,[e,0],[n,t.shape[1]]);case 3:return ow(t,[e,0,0],[n,t.shape[1],t.shape[2]]);case 4:return kf(t,[e,0,0,0],[n,t.shape[1],t.shape[2],t.shape[3]]);case 5:return tt(t,[e,0,0,0,0],[n,t.shape[1],t.shape[2],t.shape[3],t.shape[4]]);case 6:return tt(t,[e,0,0,0,0,0],[n,t.shape[1],t.shape[2],t.shape[3],t.shape[4],t.shape[5]]);default:throw new E(`sliceAlongFirstAxis() received an unsupported tensor rank: ${t.rank}`)}})}function Ng(t,e,n){return P(()=>{switch(t.rank){case 1:return rw(t,e,n);case 2:return wN(t,[0,e],[t.shape[0],n]);case 3:return ow(t,[0,0,e],[t.shape[0],t.shape[1],n]);case 4:return kf(t,[0,0,0,e],[t.shape[0],t.shape[1],t.shape[2],n]);default:throw new E(`sliceAlongLastAxis() received an unsupported tensor rank: ${t.rank}`)}})}function nd(t,e,n,s){return P(()=>{switch(t.rank){case 1:return rw(t,e,n);case 2:switch(s){case 1:return Ci(t,e,n);case 2:return Ng(t,e,n);default:throw new E(`The axis is not within the rank of the tensor ${s}`)}case 3:switch(s){case 1:return Ci(t,e,n);case 2:return ow(t,[0,e,0],[t.shape[0],n,t.shape[2]]);case 3:return Ng(t,e,n);default:throw new E(`The axis is not within the rank of the tensor ${s}`)}case 4:switch(s){case 1:return Ci(t,e,n);case 2:return kf(t,[0,e,0,0],[t.shape[0],n,t.shape[2],t.shape[3]]);case 3:return kf(t,[0,0,e,0],[t.shape[0],t.shape[1],n,t.shape[3]]);case 4:return Ng(t,e,n);default:throw new E(`The axis is not within the rank of the tensor ${s}`)}default:throw new E(`sliceAlongLastAxis() received an unsupported tensor rank: ${t.rank}`)}})}function jw(t,e=-1){let n;return e<0&&(n=t[0].rank,n!==0?e=n:e=0),e===t[0].rank&&(e=-1),Dn(t,e)}function KC(t,e){switch(t.rank){case 1:return ZL([t,e]);case 2:return e4([t,e],0);case 3:return n4([t,e],0);case 4:return r4([t,e],0);default:throw new E(`concatAlongFirstAxis() received an unsupported tensor rank: ${t.rank}`)}}function x1(t,e){if(Array.isArray(e)||(e=[e]),t.rank!==e.length)throw new E(`The length of input n (${e.length}) does not match the number of dimensions in input x (${t.rank})`);return Hs(t,e)}function $m(t,e=0,n=1,s,r){return fV(t,e,n,s,r)}function br(t,e,n,s){if(t.rank<2||e.rank<2)throw new Ie(`dot requires both inputs to be rank >= 2 but got x shape = ${t.shape} and y shape = ${e.shape}`);if(e.rank>=3){const r=t.shape.slice(-1)[0],o=e.shape.slice(-2)[0];if(r!==o)throw new Ie(`If rank y >= 3, then the second last dim of y must equal the last dim of x but got x shape = ${t.shape} and y shape = ${e.shape}`)}if(t.rank===2&&e.rank===2)return AC({a:t,b:e,transposeA:!1,transposeB:!1,bias:s?y1(t.rank,s,er()):null,activation:n});{const r=t.shape.slice(),o=r.pop();t=F(t,[-1,o]);const i=e.shape.slice(),a=i.pop(),l=i.pop(),c=[...i,a],u=Array.from({length:e.rank},(p,g)=>g===0?e.rank-2:g<=e.rank-2?g-1:g);e=F(Fe(e,u),[l,-1]);const h=[...r,...c];return F(AC({a:t,b:e,transposeA:!1,transposeB:!1,bias:s?y1(t.rank,s,er()):null,activation:n}),h)}}function ST(t,e,n){return P(()=>(Array.isArray(e)?e=Gn(e,"int32"):e=le(e,"int32"),Wy(t,e,n)))}function bh(t){return D(t,t)}function y1(t,e,n){const s=e.shape;if(e.rank!==1&&e.rank!==t)throw new E(`Unexpected bias dimensions: ${e.rank}; expected it to be 1 or ${t}`);if(t===5){if(n==="channelsFirst")return s.length===1?F(e,[1,s[0],1,1,1]):F(e,[1,s[3],s[0],s[1],s[2]]);if(n==="channelsLast")return s.length===1?F(e,[1,1,1,1,s[0]]):F(e,[1].concat(s))}else if(t===4){if(n==="channelsFirst")return s.length===1?F(e,[1,s[0],1,1]):F(e,[1,s[2],s[0],s[1]]);if(n==="channelsLast")return s.length===1?F(e,[1,1,1,s[0]]):F(e,[1].concat(s))}else if(t===3){if(n==="channelsFirst")return s.length===1?F(e,[1,s[0],1]):F(e,[1,s[1],s[0]]);if(n==="channelsLast")return s.length===1?F(e,[1,1,s[0]]):F(e,[1].concat(s))}else if(t<3)return e;throw new E(`Unsupported input rank by biasAdd: ${e.rank}`)}function sr(t,e,n){return P(()=>(n==null&&(n=er()),Nt(n),J(t,y1(t.rank,e,n))))}function K6(t,e=1){if(e!==1)throw new Ie(`Support for alpha values other than 1 (${e}) is not implemented yet.`);return ym(t)}function X6(t){return P(()=>ge(t,J(xn(t),1)))}function IT(t,e,n,s){return P(()=>cW(t,e,n,s))}function q6(t){return P(()=>{const e=J(.5,D(.2,t));return as(e,0,1)})}function Ch(t,e,n=!1){return n?t():e()}/** + */function vr(t,e){return le(t,e)}function wh(t,e=-1){const n=t.shape.slice();return e<0&&(e=n.length+e+1),n.splice(e,0,1),F(t,n)}function U6(t,e){return P(()=>{if(t.shape.length!==2)throw new E(`repeat() expects a rank-2 tensor, but received a rank-${t.shape.length} tensor.`);const n=wh(t,1);return x1(n,[1,e,1])})}function G6(t){const e=[Eo(t.shape)];return F(t,e)}function H6(t){if(t.rank<=1)throw new E(`batchFlatten requires a minimum rank of 2. Got rank: ${t.rank}.`);const e=[t.shape[0],Eo(t.shape,1)];return F(t,e)}function Ci(t,e,n){return P(()=>{switch(t.rank){case 1:return rw(t,e,n);case 2:return wN(t,[e,0],[n,t.shape[1]]);case 3:return ow(t,[e,0,0],[n,t.shape[1],t.shape[2]]);case 4:return Cf(t,[e,0,0,0],[n,t.shape[1],t.shape[2],t.shape[3]]);case 5:return tt(t,[e,0,0,0,0],[n,t.shape[1],t.shape[2],t.shape[3],t.shape[4]]);case 6:return tt(t,[e,0,0,0,0,0],[n,t.shape[1],t.shape[2],t.shape[3],t.shape[4],t.shape[5]]);default:throw new E(`sliceAlongFirstAxis() received an unsupported tensor rank: ${t.rank}`)}})}function Ng(t,e,n){return P(()=>{switch(t.rank){case 1:return rw(t,e,n);case 2:return wN(t,[0,e],[t.shape[0],n]);case 3:return ow(t,[0,0,e],[t.shape[0],t.shape[1],n]);case 4:return Cf(t,[0,0,0,e],[t.shape[0],t.shape[1],t.shape[2],n]);default:throw new E(`sliceAlongLastAxis() received an unsupported tensor rank: ${t.rank}`)}})}function td(t,e,n,s){return P(()=>{switch(t.rank){case 1:return rw(t,e,n);case 2:switch(s){case 1:return Ci(t,e,n);case 2:return Ng(t,e,n);default:throw new E(`The axis is not within the rank of the tensor ${s}`)}case 3:switch(s){case 1:return Ci(t,e,n);case 2:return ow(t,[0,e,0],[t.shape[0],n,t.shape[2]]);case 3:return Ng(t,e,n);default:throw new E(`The axis is not within the rank of the tensor ${s}`)}case 4:switch(s){case 1:return Ci(t,e,n);case 2:return Cf(t,[0,e,0,0],[t.shape[0],n,t.shape[2],t.shape[3]]);case 3:return Cf(t,[0,0,e,0],[t.shape[0],t.shape[1],n,t.shape[3]]);case 4:return Ng(t,e,n);default:throw new E(`The axis is not within the rank of the tensor ${s}`)}default:throw new E(`sliceAlongLastAxis() received an unsupported tensor rank: ${t.rank}`)}})}function jw(t,e=-1){let n;return e<0&&(n=t[0].rank,n!==0?e=n:e=0),e===t[0].rank&&(e=-1),Dn(t,e)}function KC(t,e){switch(t.rank){case 1:return QL([t,e]);case 2:return JL([t,e],0);case 3:return t4([t,e],0);case 4:return s4([t,e],0);default:throw new E(`concatAlongFirstAxis() received an unsupported tensor rank: ${t.rank}`)}}function x1(t,e){if(Array.isArray(e)||(e=[e]),t.rank!==e.length)throw new E(`The length of input n (${e.length}) does not match the number of dimensions in input x (${t.rank})`);return Hs(t,e)}function $m(t,e=0,n=1,s,r){return dV(t,e,n,s,r)}function br(t,e,n,s){if(t.rank<2||e.rank<2)throw new Ie(`dot requires both inputs to be rank >= 2 but got x shape = ${t.shape} and y shape = ${e.shape}`);if(e.rank>=3){const r=t.shape.slice(-1)[0],o=e.shape.slice(-2)[0];if(r!==o)throw new Ie(`If rank y >= 3, then the second last dim of y must equal the last dim of x but got x shape = ${t.shape} and y shape = ${e.shape}`)}if(t.rank===2&&e.rank===2)return AC({a:t,b:e,transposeA:!1,transposeB:!1,bias:s?y1(t.rank,s,er()):null,activation:n});{const r=t.shape.slice(),o=r.pop();t=F(t,[-1,o]);const i=e.shape.slice(),a=i.pop(),l=i.pop(),c=[...i,a],u=Array.from({length:e.rank},(p,g)=>g===0?e.rank-2:g<=e.rank-2?g-1:g);e=F(Fe(e,u),[l,-1]);const h=[...r,...c];return F(AC({a:t,b:e,transposeA:!1,transposeB:!1,bias:s?y1(t.rank,s,er()):null,activation:n}),h)}}function ST(t,e,n){return P(()=>(Array.isArray(e)?e=Gn(e,"int32"):e=le(e,"int32"),Wy(t,e,n)))}function vh(t){return D(t,t)}function y1(t,e,n){const s=e.shape;if(e.rank!==1&&e.rank!==t)throw new E(`Unexpected bias dimensions: ${e.rank}; expected it to be 1 or ${t}`);if(t===5){if(n==="channelsFirst")return s.length===1?F(e,[1,s[0],1,1,1]):F(e,[1,s[3],s[0],s[1],s[2]]);if(n==="channelsLast")return s.length===1?F(e,[1,1,1,1,s[0]]):F(e,[1].concat(s))}else if(t===4){if(n==="channelsFirst")return s.length===1?F(e,[1,s[0],1,1]):F(e,[1,s[2],s[0],s[1]]);if(n==="channelsLast")return s.length===1?F(e,[1,1,1,s[0]]):F(e,[1].concat(s))}else if(t===3){if(n==="channelsFirst")return s.length===1?F(e,[1,s[0],1]):F(e,[1,s[1],s[0]]);if(n==="channelsLast")return s.length===1?F(e,[1,1,s[0]]):F(e,[1].concat(s))}else if(t<3)return e;throw new E(`Unsupported input rank by biasAdd: ${e.rank}`)}function sr(t,e,n){return P(()=>(n==null&&(n=er()),Nt(n),J(t,y1(t.rank,e,n))))}function j6(t,e=1){if(e!==1)throw new Ie(`Support for alpha values other than 1 (${e}) is not implemented yet.`);return ym(t)}function K6(t){return P(()=>ge(t,J(xn(t),1)))}function IT(t,e,n,s){return P(()=>lW(t,e,n,s))}function X6(t){return P(()=>{const e=J(.5,D(.2,t));return as(e,0,1)})}function bh(t,e,n=!1){return n?t():e()}/** * @license * Copyright 2018 Google LLC * @@ -7626,7 +7626,7 @@ body { * license that can be found in the LICENSE file or at * https://opensource.org/licenses/MIT. * ============================================================================= - */const Y6=["fanIn","fanOut","fanAvg"],Q6=["normal","uniform","truncatedNormal"];/** + */const q6=["fanIn","fanOut","fanAvg"],Y6=["normal","uniform","truncatedNormal"];/** * @license * Copyright 2018 Google LLC * @@ -7634,7 +7634,7 @@ body { * license that can be found in the LICENSE file or at * https://opensource.org/licenses/MIT. * ============================================================================= - */function Z6(t){Zi(Y6,"FanMode",t)}function J6(t){Zi(Q6,"Distribution",t)}class Ds extends Il{fromConfigUsesCustomObjects(){return!1}getConfig(){return{}}}class $T extends Ds{apply(e,n){return Kt(e,n)}}$T.className="Zeros";Y($T);class Kw extends Ds{apply(e,n){return Ko(e,n)}}Kw.className="Ones";Y(Kw);class NT extends Ds{constructor(e){if(super(),typeof e!="object")throw new E(`Expected argument of type ConstantConfig but got ${e}`);if(e.value===void 0)throw new E(`config must have value set but got ${e}`);this.value=e.value}apply(e,n){return P(()=>D(We(this.value),Ko(e,n)))}getConfig(){return{value:this.value}}}NT.className="Constant";Y(NT);class TT extends Ds{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,n){return fh(e,this.minval,this.maxval,n,this.seed)}getConfig(){return{minval:this.minval,maxval:this.maxval,seed:this.seed}}}TT.className="RandomUniform";Y(TT);class ET extends Ds{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,n){if(n=n||"float32",n!=="float32"&&n!=="int32")throw new Ie(`randomNormal does not support dType ${n}.`);return $m(e,this.mean,this.stddev,n,this.seed)}getConfig(){return{mean:this.mean,stddev:this.stddev,seed:this.seed}}}ET.className="RandomNormal";Y(ET);class RT extends Ds{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,n){if(n=n||"float32",n!=="float32"&&n!=="int32")throw new Ie(`truncatedNormal does not support dType ${n}.`);return CN(e,this.mean,this.stddev,n,this.seed)}getConfig(){return{mean:this.mean,stddev:this.stddev,seed:this.seed}}}RT.className="TruncatedNormal";Y(RT);class AT extends Ds{constructor(e){super(),this.gain=e.gain!=null?e.gain:1}apply(e,n){return P(()=>{if(e.length!==2||e[0]!==e[1])throw new E("Identity matrix initializer can only be used for 2D square matrices.");return D(this.gain,rN(e[0]))})}getConfig(){return{gain:this.gain}}}AT.className="Identity";Y(AT);function e5(t,e="channelsLast"){let n,s;if(Nt(e),t.length===2)n=t[0],s=t[1];else if([3,4,5].indexOf(t.length)!==-1){if(e==="channelsFirst"){const r=Eo(t,2);n=t[1]*r,s=t[0]*r}else if(e==="channelsLast"){const r=Eo(t,0,t.length-2);n=t[t.length-2]*r,s=t[t.length-1]*r}}else{const r=Eo(t);n=Math.sqrt(r),s=Math.sqrt(r)}return[n,s]}class qn extends Ds{constructor(e){if(super(),e.scale<0)throw new E(`scale must be a positive float. Got: ${e.scale}`);this.scale=e.scale==null?1:e.scale,this.mode=e.mode==null?"fanIn":e.mode,Z6(this.mode),this.distribution=e.distribution==null?"normal":e.distribution,J6(this.distribution),this.seed=e.seed}apply(e,n){const s=e5(e),r=s[0],o=s[1];let i=this.scale;if(this.mode==="fanIn"?i/=Math.max(1,r):this.mode==="fanOut"?i/=Math.max(1,o):i/=Math.max(1,(r+o)/2),this.distribution==="normal"){const a=Math.sqrt(i);if(n=n||"float32",n!=="float32"&&n!=="int32")throw new Ie(`${this.getClassName()} does not support dType ${n}.`);return CN(e,0,a,n,this.seed)}else{const a=Math.sqrt(3*i);return fh(e,-a,a,n,this.seed)}}getConfig(){return{scale:this.scale,mode:this.mode,distribution:this.distribution,seed:this.seed}}}qn.className="VarianceScaling";Y(qn);class Xw extends qn{constructor(e){super({scale:1,mode:"fanAvg",distribution:"uniform",seed:e==null?null:e.seed})}getClassName(){return qn.className}}Xw.className="GlorotUniform";Y(Xw);class qw extends qn{constructor(e){super({scale:1,mode:"fanAvg",distribution:"normal",seed:e==null?null:e.seed})}getClassName(){return qn.className}}qw.className="GlorotNormal";Y(qw);class Yw extends qn{constructor(e){super({scale:2,mode:"fanIn",distribution:"normal",seed:e==null?null:e.seed})}getClassName(){return qn.className}}Yw.className="HeNormal";Y(Yw);class Qw extends qn{constructor(e){super({scale:2,mode:"fanIn",distribution:"uniform",seed:e==null?null:e.seed})}getClassName(){return qn.className}}Qw.className="HeUniform";Y(Qw);class Zw extends qn{constructor(e){super({scale:1,mode:"fanIn",distribution:"normal",seed:e==null?null:e.seed})}getClassName(){return qn.className}}Zw.className="LeCunNormal";Y(Zw);class Jw extends qn{constructor(e){super({scale:1,mode:"fanIn",distribution:"uniform",seed:e==null?null:e.seed})}getClassName(){return qn.className}}Jw.className="LeCunUniform";Y(Jw);class DT extends Ds{constructor(e){super(),this.DEFAULT_GAIN=1,this.ELEMENTS_WARN_SLOW=2e3,this.gain=e.gain==null?this.DEFAULT_GAIN:e.gain,this.seed=e.seed}apply(e,n){return P(()=>{if(e.length<2)throw new Ie("Shape must be at least 2D.");if(n!=="int32"&&n!=="float32"&&n!==void 0)throw new TypeError(`Unsupported data type ${n}.`);n=n;const s=j(e.slice(0,-1)),r=e[e.length-1],o=s*r;o>this.ELEMENTS_WARN_SLOW&&console.warn(`Orthogonal initializer is being called on a matrix with more than ${this.ELEMENTS_WARN_SLOW} (${o}) elements: Slowness may result.`);const i=[Math.max(r,s),Math.min(r,s)],a=$m(i,0,1,n,this.seed),l=oU.qr(a,!1);let c=l[0];const h=l[1].flatten().stridedSlice([0],[Math.min(r,s)*Math.min(r,s)],[Math.min(r,s)+1]);return c=D(c,h.sign()),sD(We(this.value),Ko(e,n)))}getConfig(){return{value:this.value}}}NT.className="Constant";Y(NT);class TT extends Ds{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,n){return dh(e,this.minval,this.maxval,n,this.seed)}getConfig(){return{minval:this.minval,maxval:this.maxval,seed:this.seed}}}TT.className="RandomUniform";Y(TT);class ET extends Ds{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,n){if(n=n||"float32",n!=="float32"&&n!=="int32")throw new Ie(`randomNormal does not support dType ${n}.`);return $m(e,this.mean,this.stddev,n,this.seed)}getConfig(){return{mean:this.mean,stddev:this.stddev,seed:this.seed}}}ET.className="RandomNormal";Y(ET);class RT extends Ds{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,n){if(n=n||"float32",n!=="float32"&&n!=="int32")throw new Ie(`truncatedNormal does not support dType ${n}.`);return CN(e,this.mean,this.stddev,n,this.seed)}getConfig(){return{mean:this.mean,stddev:this.stddev,seed:this.seed}}}RT.className="TruncatedNormal";Y(RT);class AT extends Ds{constructor(e){super(),this.gain=e.gain!=null?e.gain:1}apply(e,n){return P(()=>{if(e.length!==2||e[0]!==e[1])throw new E("Identity matrix initializer can only be used for 2D square matrices.");return D(this.gain,rN(e[0]))})}getConfig(){return{gain:this.gain}}}AT.className="Identity";Y(AT);function J6(t,e="channelsLast"){let n,s;if(Nt(e),t.length===2)n=t[0],s=t[1];else if([3,4,5].indexOf(t.length)!==-1){if(e==="channelsFirst"){const r=Eo(t,2);n=t[1]*r,s=t[0]*r}else if(e==="channelsLast"){const r=Eo(t,0,t.length-2);n=t[t.length-2]*r,s=t[t.length-1]*r}}else{const r=Eo(t);n=Math.sqrt(r),s=Math.sqrt(r)}return[n,s]}class qn extends Ds{constructor(e){if(super(),e.scale<0)throw new E(`scale must be a positive float. Got: ${e.scale}`);this.scale=e.scale==null?1:e.scale,this.mode=e.mode==null?"fanIn":e.mode,Q6(this.mode),this.distribution=e.distribution==null?"normal":e.distribution,Z6(this.distribution),this.seed=e.seed}apply(e,n){const s=J6(e),r=s[0],o=s[1];let i=this.scale;if(this.mode==="fanIn"?i/=Math.max(1,r):this.mode==="fanOut"?i/=Math.max(1,o):i/=Math.max(1,(r+o)/2),this.distribution==="normal"){const a=Math.sqrt(i);if(n=n||"float32",n!=="float32"&&n!=="int32")throw new Ie(`${this.getClassName()} does not support dType ${n}.`);return CN(e,0,a,n,this.seed)}else{const a=Math.sqrt(3*i);return dh(e,-a,a,n,this.seed)}}getConfig(){return{scale:this.scale,mode:this.mode,distribution:this.distribution,seed:this.seed}}}qn.className="VarianceScaling";Y(qn);class Xw extends qn{constructor(e){super({scale:1,mode:"fanAvg",distribution:"uniform",seed:e==null?null:e.seed})}getClassName(){return qn.className}}Xw.className="GlorotUniform";Y(Xw);class qw extends qn{constructor(e){super({scale:1,mode:"fanAvg",distribution:"normal",seed:e==null?null:e.seed})}getClassName(){return qn.className}}qw.className="GlorotNormal";Y(qw);class Yw extends qn{constructor(e){super({scale:2,mode:"fanIn",distribution:"normal",seed:e==null?null:e.seed})}getClassName(){return qn.className}}Yw.className="HeNormal";Y(Yw);class Qw extends qn{constructor(e){super({scale:2,mode:"fanIn",distribution:"uniform",seed:e==null?null:e.seed})}getClassName(){return qn.className}}Qw.className="HeUniform";Y(Qw);class Zw extends qn{constructor(e){super({scale:1,mode:"fanIn",distribution:"normal",seed:e==null?null:e.seed})}getClassName(){return qn.className}}Zw.className="LeCunNormal";Y(Zw);class Jw extends qn{constructor(e){super({scale:1,mode:"fanIn",distribution:"uniform",seed:e==null?null:e.seed})}getClassName(){return qn.className}}Jw.className="LeCunUniform";Y(Jw);class DT extends Ds{constructor(e){super(),this.DEFAULT_GAIN=1,this.ELEMENTS_WARN_SLOW=2e3,this.gain=e.gain==null?this.DEFAULT_GAIN:e.gain,this.seed=e.seed}apply(e,n){return P(()=>{if(e.length<2)throw new Ie("Shape must be at least 2D.");if(n!=="int32"&&n!=="float32"&&n!==void 0)throw new TypeError(`Unsupported data type ${n}.`);n=n;const s=j(e.slice(0,-1)),r=e[e.length-1],o=s*r;o>this.ELEMENTS_WARN_SLOW&&console.warn(`Orthogonal initializer is being called on a matrix with more than ${this.ELEMENTS_WARN_SLOW} (${o}) elements: Slowness may result.`);const i=[Math.max(r,s),Math.min(r,s)],a=$m(i,0,1,n,this.seed),l=rU.qr(a,!1);let c=l[0];const h=l[1].flatten().stridedSlice([0],[Math.min(r,s)*Math.min(r,s)],[Math.min(r,s)+1]);return c=D(c,h.sign()),ss*r);return e}/** + */function Sf(t){let e=0;for(const n of t)n.shape.length===0?e+=1:e+=n.shape.reduce((s,r)=>s*r);return e}/** * @license * Copyright 2018 Google LLC * @@ -7658,7 +7658,7 @@ body { * license that can be found in the LICENSE file or at * https://opensource.org/licenses/MIT. * ============================================================================= - */const YC="Variable";class t5{constructor(e,n="float32",s=YC,r=!0,o=null){this.dtype=n??"float32",this.shape=e.shape,this.id=wT(),s=s??YC,this.originalName=bT(s),this.name=CT(this.originalName),this.trainable_=r,this.constraint=o,this.val=oW(e,this.trainable_,this.name,this.dtype)}read(){return this.assertNotDisposed(),this.val}write(e){return this.assertNotDisposed(),n5(this.val,e),this.val.id!==e.id&&(this.val.assign(e),this.constraint!=null&&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 n5(t,e){if(t.shape.toString()!==e.shape.toString())throw new Error("Shape mismatch: "+JSON.stringify(t.shape)+" vs. "+JSON.stringify(e.shape))}function v1(t){return t.map(e=>e.read())}function ev(t){t.forEach(e=>{e[0].write(e[1])})}/** + */const YC="Variable";class e5{constructor(e,n="float32",s=YC,r=!0,o=null){this.dtype=n??"float32",this.shape=e.shape,this.id=wT(),s=s??YC,this.originalName=bT(s),this.name=CT(this.originalName),this.trainable_=r,this.constraint=o,this.val=rW(e,this.trainable_,this.name,this.dtype)}read(){return this.assertNotDisposed(),this.val}write(e){return this.assertNotDisposed(),t5(this.val,e),this.val.id!==e.id&&(this.val.assign(e),this.constraint!=null&&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 t5(t,e){if(t.shape.toString()!==e.shape.toString())throw new Error("Shape mismatch: "+JSON.stringify(t.shape)+" vs. "+JSON.stringify(e.shape))}function v1(t){return t.map(e=>e.read())}function ev(t){t.forEach(e=>{e[0].write(e[1])})}/** * @license * Copyright 2018 Google LLC * @@ -7666,7 +7666,7 @@ body { * license that can be found in the LICENSE file or at * https://opensource.org/licenses/MIT. * ============================================================================= - */class Pt{constructor(e){this.dtype=e.dtype,this.shape=e.shape,e.shape!=null?this.ndim=e.shape.length:this.ndim=e.ndim,this.maxNDim=e.maxNDim,this.minNDim=e.minNDim,this.axes=e.axes||{}}}class $r{constructor(e,n,s,r,o,i,a){this.dtype=e,this.shape=n,this.sourceLayer=s,this.inputs=r,this.callArgs=o,this.outputTensorIndex=a,this.id=wT(),i!=null&&(this.originalName=bT(i),this.name=CT(this.originalName)),this.rank=n.length}}let s5=0;class Nm{constructor(e,n){this.callArgs=n,this.id=s5++,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 s of e.inboundLayers)s!=null&&s.outboundNodes.push(this);e.outboundLayer.inboundNodes.push(this)}getConfig(){const e=[];for(const n of this.inboundLayers)n!=null?e.push(n.name):e.push(null);return{outboundLayer:this.outboundLayer?this.outboundLayer.name:null,inboundLayers:e,nodeIndices:this.nodeIndices,tensorIndices:this.tensorIndices}}}let r5=0;class Ae extends Il{constructor(e={}){super(),this._callHook=null,this._addedWeightNames=[],this._stateful=!1,this.id=r5++,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 n=e.name;if(!n){const s=this.getClassName();n=_r(s)+"_"+Im(s)}if(this.name=n,this.trainable_=e.trainable==null?!0:e.trainable,e.inputShape!=null||e.batchInputShape!=null){let s;if(e.batchInputShape!=null)s=e.batchInputShape;else if(e.inputShape!=null){let o=null;e.batchSize!=null&&(o=e.batchSize),s=[o].concat(e.inputShape)}this.batchInputShape=s;let r=e.dtype;r==null&&(r=e.inputDType),r==null&&(r="float32"),this.dtype=r}e.weights!=null?this.initialWeights=e.weights:this.initialWeights=null,this._refCount=null,this.fastWeightInitDuringBuild=!1}static nodeKey(e,n){return e.name+"_ib-"+n.toString()}getNodeAtIndex(e,n){if(this.inboundNodes.length===0)throw new ks(`The layer has never been called and thus has no defined ${n}.`);if(this.inboundNodes.length<=e)throw new E(`Asked to get ${n} at node ${e}, but the layer has only ${this.inboundNodes.length} inbound nodes.`);return this.inboundNodes[e]}getInputAt(e){return Rn(this.getNodeAtIndex(e,"input").inputTensors)}getOutputAt(e){return Rn(this.getNodeAtIndex(e,"output").outputTensors)}get input(){if(this.inboundNodes.length>1)throw new ur(`Layer ${this.name} has multiple inbound nodes, hence the notion of "layer input" is ill-defined. Use \`getInputAt(nodeIndex)\` instead.`);if(this.inboundNodes.length===0)throw new ur(`Layer ${this.name} is not connected, no input to return.`);return Rn(this.getNodeAtIndex(0,"input").inputTensors)}get output(){if(this.inboundNodes.length===0)throw new ur(`Layer ${this.name} has no inbound nodes.`);if(this.inboundNodes.length>1)throw new ur(`Layer ${this.name} has multiple inbound nodes, hence the notion of "layer output" is ill-defined. Use \`getOutputAt(nodeIndex)\` instead.`);return Rn(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(n=>n.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 n=Ke(e);if(this.inputSpec==null||this.inputSpec.length===0)return;const s=Ke(this.inputSpec);if(n.length!==s.length)throw new E(`Layer ${this.name} expects ${s.length} inputs, but it received ${n.length} input tensors. Input received: ${e}`);for(let r=0;ri.maxNDim)throw new E(`Input ${r} is incompatible with layer ${this.name}: expected max_ndim=${i.maxNDim}, found ndim=${a}`);if(i.minNDim!=null&&a=0?l[u]:l[l.length+u];if(h!=null&&[h,null].indexOf(d)===-1)throw new E(`Input ${r} is incompatible with layer ${this.name}: expected axis ${u} of input shape to have value ${h} but got shape ${l}.`)}}if(i.shape!=null)for(let l=0;l{if(!this.built){this.assertInputCompatibility(e);const i=[];for(const a of Ke(e))i.push(a.shape);this.build(Rn(i)),this.built=!0,this.initialWeights&&this.setWeights(this.initialWeights),this._refCount===null&&o&&(this._refCount=1)}if(this.assertInputCompatibility(e),o){let i=this.call(e,n);this.supportsMasking&&this.setMaskMetadata(e,i);const a=Ke(i),l=[];for(let c of a)s.indexOf(c)!==-1&&(c=c.clone()),l.push(c);if(i=Rn(l),this.activityRegularizer!=null)throw new Ie("Layer invocation in the presence of activity regularizer(s) is not supported yet.");return i}else{const i=o5(e),a=this.computeOutputShape(i);let l;const c=i5(e);if(this.warnOnIncompatibleInputShape(Array.isArray(e)?i[0]:i),a!=null&&a.length>0&&Array.isArray(a[0])?l=a.map((u,h)=>new $r(c,u,this,Ke(e),n,this.name,h)):l=new $r(c,a,this,Ke(e),n,this.name),this.addInboundNode(e,l,null,null,i,a,n),this._refCount++,this.activityRegularizer!=null)throw new Ie("Layer invocation in the presence of activity regularizer(s) is not supported yet.");return l}})}warnOnIncompatibleInputShape(e){if(this.batchInputShape!=null)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 n=!1;this.batchInputShape.forEach((s,r)=>{s!=null&&e[r]!=null&&e[r]!==s&&(n=!0)}),n&&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(this.inboundNodes==null||this.inboundNodes.length===0)throw new ur(`The layer ${this.name} has never been called and thus has no defined output shape.`);const e=[];for(const n of this.inboundNodes){const s=JSON.stringify(n.outputShapes);e.indexOf(s)===-1&&e.push(s)}if(e.length===1){const n=this.inboundNodes[0].outputShapes;return Array.isArray(n)&&Array.isArray(n[0])&&n.length===1?n[0]:n}else throw new ur(`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 ks(`You tried to call countParams() on ${this.name}, but the layer is not built yet. Build it first by calling build(batchInputShape).`);return If(this.weights)}build(e){this.built=!0}getWeights(e=!1){return v1(e?this.trainableWeights:this.weights)}setWeights(e){P(()=>{const n=this.weights;if(n.length!==e.length)throw new E(`You called setWeights(weights) on layer "${this.name}" with a weight list of length ${e.length}, but the layer was expecting ${n.length} weights. Provided weights: ${e}...`);if(n.length===0)return;const s=[],r=v1(n);for(let o=0;oo.apply(u.read())),i==null&&(i=!0),i?this._trainableWeights.push(u):this._nonTrainableWeights.push(u),u}setFastWeightInitDuringBuild(e){this.fastWeightInitDuringBuild=e}addLoss(e){e==null||Array.isArray(e)&&e.length===0||(e=Ke(e),this._losses!==void 0&&this._losses!==null&&this.losses.push(...e))}computeOutputShape(e){return e}computeMask(e,n){if(!this.supportsMasking){if(n!=null)if(Array.isArray(n))n.forEach(s=>{if(s!=null)throw new TypeError(`Layer ${this.name} does not support masking, but was passed an inputMask.`)});else throw new TypeError(`Layer ${this.name} does not support masking, but was passed an inputMask.`);return null}return n}setMaskMetadata(e,n,s){if(!this.supportsMasking)return;const r=this.computeMask(e,s),o=Ke(n),i=Ke(r);if(o.length!==i.length)throw new Error(`${this.name} outputs ${o.length} tensors but ${o.length} masks for those tensors`);for(let a=0;ae.dispose()),this.weights.length}assertNotDisposed(){if(this._refCount===0)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(this._refCount===null)throw new Error(`Cannot dispose Layer ${this.name} because it has not been used yet.`);this.assertNotDisposed();let e=0;return--this._refCount===0&&(e=this.disposeWeights()),{refCountAfterDispose:this._refCount,numDisposedVariables:e}}}function o5(t){t=Ke(t);const e=[];for(const n of t)e.push(n.shape);return Rn(e)}function i5(t){return"float32"}function _T(t,e,n){if((e==null||n!=null&&n>0)&&(e=t.sourceLayer,n=t.nodeIndex),e.inboundNodes.length===0)return[t];{const s=e.inboundNodes[n];if(s.inboundLayers.length===0)return s.inputTensors;{const r=[];for(let o=0;o1)throw new ur(`Layer ${this.name} has multiple inbound nodes, hence the notion of "layer input" is ill-defined. Use \`getInputAt(nodeIndex)\` instead.`);if(this.inboundNodes.length===0)throw new ur(`Layer ${this.name} is not connected, no input to return.`);return Rn(this.getNodeAtIndex(0,"input").inputTensors)}get output(){if(this.inboundNodes.length===0)throw new ur(`Layer ${this.name} has no inbound nodes.`);if(this.inboundNodes.length>1)throw new ur(`Layer ${this.name} has multiple inbound nodes, hence the notion of "layer output" is ill-defined. Use \`getOutputAt(nodeIndex)\` instead.`);return Rn(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(n=>n.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 n=Ke(e);if(this.inputSpec==null||this.inputSpec.length===0)return;const s=Ke(this.inputSpec);if(n.length!==s.length)throw new E(`Layer ${this.name} expects ${s.length} inputs, but it received ${n.length} input tensors. Input received: ${e}`);for(let r=0;ri.maxNDim)throw new E(`Input ${r} is incompatible with layer ${this.name}: expected max_ndim=${i.maxNDim}, found ndim=${a}`);if(i.minNDim!=null&&a=0?l[u]:l[l.length+u];if(h!=null&&[h,null].indexOf(d)===-1)throw new E(`Input ${r} is incompatible with layer ${this.name}: expected axis ${u} of input shape to have value ${h} but got shape ${l}.`)}}if(i.shape!=null)for(let l=0;l{if(!this.built){this.assertInputCompatibility(e);const i=[];for(const a of Ke(e))i.push(a.shape);this.build(Rn(i)),this.built=!0,this.initialWeights&&this.setWeights(this.initialWeights),this._refCount===null&&o&&(this._refCount=1)}if(this.assertInputCompatibility(e),o){let i=this.call(e,n);this.supportsMasking&&this.setMaskMetadata(e,i);const a=Ke(i),l=[];for(let c of a)s.indexOf(c)!==-1&&(c=c.clone()),l.push(c);if(i=Rn(l),this.activityRegularizer!=null)throw new Ie("Layer invocation in the presence of activity regularizer(s) is not supported yet.");return i}else{const i=r5(e),a=this.computeOutputShape(i);let l;const c=o5(e);if(this.warnOnIncompatibleInputShape(Array.isArray(e)?i[0]:i),a!=null&&a.length>0&&Array.isArray(a[0])?l=a.map((u,h)=>new $r(c,u,this,Ke(e),n,this.name,h)):l=new $r(c,a,this,Ke(e),n,this.name),this.addInboundNode(e,l,null,null,i,a,n),this._refCount++,this.activityRegularizer!=null)throw new Ie("Layer invocation in the presence of activity regularizer(s) is not supported yet.");return l}})}warnOnIncompatibleInputShape(e){if(this.batchInputShape!=null)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 n=!1;this.batchInputShape.forEach((s,r)=>{s!=null&&e[r]!=null&&e[r]!==s&&(n=!0)}),n&&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(this.inboundNodes==null||this.inboundNodes.length===0)throw new ur(`The layer ${this.name} has never been called and thus has no defined output shape.`);const e=[];for(const n of this.inboundNodes){const s=JSON.stringify(n.outputShapes);e.indexOf(s)===-1&&e.push(s)}if(e.length===1){const n=this.inboundNodes[0].outputShapes;return Array.isArray(n)&&Array.isArray(n[0])&&n.length===1?n[0]:n}else throw new ur(`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 ks(`You tried to call countParams() on ${this.name}, but the layer is not built yet. Build it first by calling build(batchInputShape).`);return Sf(this.weights)}build(e){this.built=!0}getWeights(e=!1){return v1(e?this.trainableWeights:this.weights)}setWeights(e){P(()=>{const n=this.weights;if(n.length!==e.length)throw new E(`You called setWeights(weights) on layer "${this.name}" with a weight list of length ${e.length}, but the layer was expecting ${n.length} weights. Provided weights: ${e}...`);if(n.length===0)return;const s=[],r=v1(n);for(let o=0;oo.apply(u.read())),i==null&&(i=!0),i?this._trainableWeights.push(u):this._nonTrainableWeights.push(u),u}setFastWeightInitDuringBuild(e){this.fastWeightInitDuringBuild=e}addLoss(e){e==null||Array.isArray(e)&&e.length===0||(e=Ke(e),this._losses!==void 0&&this._losses!==null&&this.losses.push(...e))}computeOutputShape(e){return e}computeMask(e,n){if(!this.supportsMasking){if(n!=null)if(Array.isArray(n))n.forEach(s=>{if(s!=null)throw new TypeError(`Layer ${this.name} does not support masking, but was passed an inputMask.`)});else throw new TypeError(`Layer ${this.name} does not support masking, but was passed an inputMask.`);return null}return n}setMaskMetadata(e,n,s){if(!this.supportsMasking)return;const r=this.computeMask(e,s),o=Ke(n),i=Ke(r);if(o.length!==i.length)throw new Error(`${this.name} outputs ${o.length} tensors but ${o.length} masks for those tensors`);for(let a=0;ae.dispose()),this.weights.length}assertNotDisposed(){if(this._refCount===0)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(this._refCount===null)throw new Error(`Cannot dispose Layer ${this.name} because it has not been used yet.`);this.assertNotDisposed();let e=0;return--this._refCount===0&&(e=this.disposeWeights()),{refCountAfterDispose:this._refCount,numDisposedVariables:e}}}function r5(t){t=Ke(t);const e=[];for(const n of t)e.push(n.shape);return Rn(e)}function o5(t){return"float32"}function _T(t,e,n){if((e==null||n!=null&&n>0)&&(e=t.sourceLayer,n=t.nodeIndex),e.inboundNodes.length===0)return[t];{const s=e.inboundNodes[n];if(s.inboundLayers.length===0)return s.inputTensors;{const r=[];for(let o=0;op.name),l=[],c=e.names();for(const p of a)c.indexOf(p)!==-1?l.push(e.getValue(p)):l.push(null);const u=a.join(",")+"|"+e.names().sort().join(",");let h=$f.get(u),d;if(h==null){const p=d5(i,e);h=p.sorted,d=p.recipientCounts,$f.put(u,h),Nf.put(u,d)}d={},r||Object.assign(d,Nf.get(u));const f=new fo(e);for(let p=0;p0,()=>"Expected at least one fetch, got none");let n=[],s={};if(t.length===1){const r=QC(t[0],e);n=r.sorted,s=r.recipientMap}else{const r=new Set;for(const o of t){const{sorted:i,recipientMap:a}=QC(o,e);for(const l of i)r.has(l.name)||(n.push(l),r.add(l.name));for(const l in a)s[l]==null&&(s[l]=new Set),a[l].forEach(c=>s[l].add(c))}}return{sorted:n,recipientCounts:f5(s)}}function f5(t){const e={};for(const n in t)e[n]=t[n].size;return e}function QC(t,e){const n=new Set,s=[],r={};for(const a of e.names())n.add(a);const o=[],i=[];for(o.push(t);o.length>0;){const a=o[o.length-1];if(n.has(a.name)){o.pop();continue}const l=i[i.length-1]===o.length-1;if(a.inputs.length===0||l)o.pop(),s.push(a),n.add(a.name),l&&i.pop();else{i.push(o.length-1);for(const c of a.inputs)r[c.name]==null&&(r[c.name]=new Set),r[c.name].add(a.name),!n.has(c.name)&&o.push(c)}}return{sorted:s,recipientMap:r}}function p5(t){let e;if(t.sourceLayer.inboundNodes.length===1)e=t.sourceLayer.output;else{let n=null;for(let s=0;sp.name),l=[],c=e.names();for(const p of a)c.indexOf(p)!==-1?l.push(e.getValue(p)):l.push(null);const u=a.join(",")+"|"+e.names().sort().join(",");let h=If.get(u),d;if(h==null){const p=h5(i,e);h=p.sorted,d=p.recipientCounts,If.put(u,h),$f.put(u,d)}d={},r||Object.assign(d,$f.get(u));const f=new fo(e);for(let p=0;p0,()=>"Expected at least one fetch, got none");let n=[],s={};if(t.length===1){const r=QC(t[0],e);n=r.sorted,s=r.recipientMap}else{const r=new Set;for(const o of t){const{sorted:i,recipientMap:a}=QC(o,e);for(const l of i)r.has(l.name)||(n.push(l),r.add(l.name));for(const l in a)s[l]==null&&(s[l]=new Set),a[l].forEach(c=>s[l].add(c))}}return{sorted:n,recipientCounts:d5(s)}}function d5(t){const e={};for(const n in t)e[n]=t[n].size;return e}function QC(t,e){const n=new Set,s=[],r={};for(const a of e.names())n.add(a);const o=[],i=[];for(o.push(t);o.length>0;){const a=o[o.length-1];if(n.has(a.name)){o.pop();continue}const l=i[i.length-1]===o.length-1;if(a.inputs.length===0||l)o.pop(),s.push(a),n.add(a.name),l&&i.pop();else{i.push(o.length-1);for(const c of a.inputs)r[c.name]==null&&(r[c.name]=new Set),r[c.name].add(a.name),!n.has(c.name)&&o.push(c)}}return{sorted:s,recipientMap:r}}function f5(t){let e;if(t.sourceLayer.inboundNodes.length===1)e=t.sourceLayer.output;else{let n=null;for(let s=0;s100,h5);/** + */const p5=W();p5.registerFlag("TOPOLOGICAL_SORT_CACHE_MAX_ENTRIES",()=>100,u5);/** * @license * Copyright 2018 Google LLC * @@ -7705,7 +7705,7 @@ body { * license that can be found in the LICENSE file or at * https://opensource.org/licenses/MIT. * ============================================================================= - */function tv(t,e){return P(()=>hn(me(D(t,t),e,!0)))}class Sh extends Il{getConfig(){return{}}}class FT extends Sh{constructor(e){super(),this.defaultMaxValue=2,this.defaultAxis=0,this.maxValue=e.maxValue!=null?e.maxValue:this.defaultMaxValue,this.axis=e.axis!=null?e.axis:this.defaultAxis}apply(e){return P(()=>{const n=tv(e,this.axis),s=as(n,0,this.maxValue);return D(e,ge(s,J(Mt(),n)))})}getConfig(){return{maxValue:this.maxValue,axis:this.axis}}}FT.className="MaxNorm";Y(FT);class zT extends Sh{constructor(e){super(),this.defaultAxis=0,this.axis=e.axis!=null?e.axis:this.defaultAxis}apply(e){return P(()=>ge(e,J(Mt(),tv(e,this.axis))))}getConfig(){return{axis:this.axis}}}zT.className="UnitNorm";Y(zT);class OT extends Sh{apply(e){return Yi(e)}}OT.className="NonNeg";Y(OT);class MT extends Sh{constructor(e){super(),this.defaultMinValue=0,this.defaultMaxValue=1,this.defaultRate=1,this.defaultAxis=0,this.minValue=e.minValue!=null?e.minValue:this.defaultMinValue,this.maxValue=e.maxValue!=null?e.maxValue:this.defaultMaxValue,this.rate=e.rate!=null?e.rate:this.defaultRate,this.axis=e.axis!=null?e.axis:this.defaultAxis}apply(e){return P(()=>{const n=tv(e,this.axis),s=J(D(this.rate,as(n,this.minValue,this.maxValue)),D(1-this.rate,n));return D(e,ge(s,J(Mt(),n)))})}getConfig(){return{minValue:this.minValue,maxValue:this.maxValue,rate:this.rate,axis:this.axis}}}MT.className="MinMaxNorm";Y(MT);const ZC={maxNorm:"MaxNorm",minMaxNorm:"MinMaxNorm",nonNeg:"NonNeg",unitNorm:"UnitNorm"};function Lt(t){return Gw(t)}function JC(t,e={}){return wh(t,xs.getMap().classNameMap,e,"constraint")}function Bt(t){if(t==null)return null;if(typeof t=="string"){const n={className:t in ZC?ZC[t]:t,config:{}};return JC(n)}else return t instanceof Sh?t:JC(t)}/** + */function tv(t,e){return P(()=>hn(me(D(t,t),e,!0)))}class kh extends Il{getConfig(){return{}}}class FT extends kh{constructor(e){super(),this.defaultMaxValue=2,this.defaultAxis=0,this.maxValue=e.maxValue!=null?e.maxValue:this.defaultMaxValue,this.axis=e.axis!=null?e.axis:this.defaultAxis}apply(e){return P(()=>{const n=tv(e,this.axis),s=as(n,0,this.maxValue);return D(e,ge(s,J(Mt(),n)))})}getConfig(){return{maxValue:this.maxValue,axis:this.axis}}}FT.className="MaxNorm";Y(FT);class zT extends kh{constructor(e){super(),this.defaultAxis=0,this.axis=e.axis!=null?e.axis:this.defaultAxis}apply(e){return P(()=>ge(e,J(Mt(),tv(e,this.axis))))}getConfig(){return{axis:this.axis}}}zT.className="UnitNorm";Y(zT);class OT extends kh{apply(e){return Yi(e)}}OT.className="NonNeg";Y(OT);class MT extends kh{constructor(e){super(),this.defaultMinValue=0,this.defaultMaxValue=1,this.defaultRate=1,this.defaultAxis=0,this.minValue=e.minValue!=null?e.minValue:this.defaultMinValue,this.maxValue=e.maxValue!=null?e.maxValue:this.defaultMaxValue,this.rate=e.rate!=null?e.rate:this.defaultRate,this.axis=e.axis!=null?e.axis:this.defaultAxis}apply(e){return P(()=>{const n=tv(e,this.axis),s=J(D(this.rate,as(n,this.minValue,this.maxValue)),D(1-this.rate,n));return D(e,ge(s,J(Mt(),n)))})}getConfig(){return{minValue:this.minValue,maxValue:this.maxValue,rate:this.rate,axis:this.axis}}}MT.className="MinMaxNorm";Y(MT);const ZC={maxNorm:"MaxNorm",minMaxNorm:"MinMaxNorm",nonNeg:"NonNeg",unitNorm:"UnitNorm"};function Lt(t){return Gw(t)}function JC(t,e={}){return yh(t,xs.getMap().classNameMap,e,"constraint")}function Bt(t){if(t==null)return null;if(typeof t=="string"){const n={className:t in ZC?ZC[t]:t,config:{}};return JC(n)}else return t instanceof kh?t:JC(t)}/** * @license * Copyright 2018 Google LLC * @@ -7721,7 +7721,7 @@ body { * license that can be found in the LICENSE file or at * https://opensource.org/licenses/MIT. * ============================================================================= - */var ek;(function(t){t[t.SILENT=0]="SILENT",t[t.VERBOSE=1]="VERBOSE"})(ek||(ek={}));const g5=125;class Yc{constructor(){this.validationData=null}setParams(e){this.params=e}async onEpochBegin(e,n){}async onEpochEnd(e,n){}async onBatchBegin(e,n){}async onBatchEnd(e,n){}async onTrainBegin(e){}async onTrainEnd(e){}setModel(e){}}class x5{constructor(e,n=10){e==null&&(e=[]),this.callbacks=e,this.queueLength=n}append(e){this.callbacks.push(e)}setParams(e){for(const n of this.callbacks)n.setParams(e)}setModel(e){for(const n of this.callbacks)n.setModel(e)}async onEpochBegin(e,n){n==null&&(n={});for(const s of this.callbacks)await s.onEpochBegin(e,n)}async onEpochEnd(e,n){n==null&&(n={});for(const s of this.callbacks)await s.onEpochEnd(e,n)}async onBatchBegin(e,n){n==null&&(n={});for(const s of this.callbacks)await s.onBatchBegin(e,n)}async onBatchEnd(e,n){n==null&&(n={});for(const s of this.callbacks)await s.onBatchEnd(e,n)}async onTrainBegin(e){e==null&&(e={});for(const n of this.callbacks)await n.onTrainBegin(e)}async onTrainEnd(e){e==null&&(e={});for(const n of this.callbacks)await n.onTrainEnd(e)}}class y5 extends Yc{constructor(){super()}async onEpochBegin(e){this.seen=0,this.totals={}}async onBatchEnd(e,n){n==null&&(n={});const s=n.size==null?0:n.size;this.seen+=s;for(const r in n){const o=n[r];if(typeof o=="number")this.totals.hasOwnProperty(r)||(this.totals[r]=0),this.totals[r]=this.totals[r]+o*s;else{let i;r in this.totals?i=this.totals[r]:this.totals[r]=0;const a=P(()=>J(this.totals[r],D(o,s)));this.totals[r]=a,i!=null&&i.dispose()}}}async onEpochEnd(e,n){if(n!=null)for(const s of this.params.metrics)this.totals[s]!=null&&(typeof this.totals[s]=="number"?n[s]=this.totals[s]/this.seen:P(()=>{const r=D(ge(1,this.seen),this.totals[s]);n[s]=r,this.totals[s].dispose(),yr(n[s])}))}}class w5 extends Yc{async onTrainBegin(e){this.epoch=[],this.history={}}async onEpochEnd(e,n){n==null&&(n={}),this.epoch.push(e);for(const s in n)this.history[s]==null&&(this.history[s]=[]),this.history[s].push(n[s])}async syncData(){const e=[],n=[],s=[];for(const o in this.history){const i=this.history[o];for(let a=0;anew v5(s,e))}class ps{constructor(){}static registerCallbackConstructor(e,n){I(e>=0&&Number.isInteger(e),()=>`Verbosity level is expected to be an integer >= 0, but got ${e}`),ps.checkForDuplicate(n),ps.constructors[e]==null&&(ps.constructors[e]=[]),ps.constructors[e].push(n)}static checkForDuplicate(e){for(const n in ps.constructors)ps.constructors[+n].forEach(r=>{if(r===e)throw new E("Duplicate callback constructor.")})}static clear(){ps.constructors={}}static createCallbacks(e){const n=[];for(const s in ps.constructors){const r=+s;e>=r&&n.push(...ps.constructors[r])}return n.map(s=>new s)}}ps.constructors={};function BT(t,e,n,s,r,o,i,a,l){const c=new w5,u=[new y5,...ps.createCallbacks(e)];t!=null&&u.push(...t),u.push(c);const h=new x5(u);return h.setParams({epochs:n,initialEpoch:s,samples:r,steps:o,batchSize:i,verbose:e,doValidation:a,metrics:l}),{callbackList:h,history:c}}/** + */var ek;(function(t){t[t.SILENT=0]="SILENT",t[t.VERBOSE=1]="VERBOSE"})(ek||(ek={}));const m5=125;class Yc{constructor(){this.validationData=null}setParams(e){this.params=e}async onEpochBegin(e,n){}async onEpochEnd(e,n){}async onBatchBegin(e,n){}async onBatchEnd(e,n){}async onTrainBegin(e){}async onTrainEnd(e){}setModel(e){}}class g5{constructor(e,n=10){e==null&&(e=[]),this.callbacks=e,this.queueLength=n}append(e){this.callbacks.push(e)}setParams(e){for(const n of this.callbacks)n.setParams(e)}setModel(e){for(const n of this.callbacks)n.setModel(e)}async onEpochBegin(e,n){n==null&&(n={});for(const s of this.callbacks)await s.onEpochBegin(e,n)}async onEpochEnd(e,n){n==null&&(n={});for(const s of this.callbacks)await s.onEpochEnd(e,n)}async onBatchBegin(e,n){n==null&&(n={});for(const s of this.callbacks)await s.onBatchBegin(e,n)}async onBatchEnd(e,n){n==null&&(n={});for(const s of this.callbacks)await s.onBatchEnd(e,n)}async onTrainBegin(e){e==null&&(e={});for(const n of this.callbacks)await n.onTrainBegin(e)}async onTrainEnd(e){e==null&&(e={});for(const n of this.callbacks)await n.onTrainEnd(e)}}class x5 extends Yc{constructor(){super()}async onEpochBegin(e){this.seen=0,this.totals={}}async onBatchEnd(e,n){n==null&&(n={});const s=n.size==null?0:n.size;this.seen+=s;for(const r in n){const o=n[r];if(typeof o=="number")this.totals.hasOwnProperty(r)||(this.totals[r]=0),this.totals[r]=this.totals[r]+o*s;else{let i;r in this.totals?i=this.totals[r]:this.totals[r]=0;const a=P(()=>J(this.totals[r],D(o,s)));this.totals[r]=a,i!=null&&i.dispose()}}}async onEpochEnd(e,n){if(n!=null)for(const s of this.params.metrics)this.totals[s]!=null&&(typeof this.totals[s]=="number"?n[s]=this.totals[s]/this.seen:P(()=>{const r=D(ge(1,this.seen),this.totals[s]);n[s]=r,this.totals[s].dispose(),yr(n[s])}))}}class y5 extends Yc{async onTrainBegin(e){this.epoch=[],this.history={}}async onEpochEnd(e,n){n==null&&(n={}),this.epoch.push(e);for(const s in n)this.history[s]==null&&(this.history[s]=[]),this.history[s].push(n[s])}async syncData(){const e=[],n=[],s=[];for(const o in this.history){const i=this.history[o];for(let a=0;anew w5(s,e))}class ps{constructor(){}static registerCallbackConstructor(e,n){I(e>=0&&Number.isInteger(e),()=>`Verbosity level is expected to be an integer >= 0, but got ${e}`),ps.checkForDuplicate(n),ps.constructors[e]==null&&(ps.constructors[e]=[]),ps.constructors[e].push(n)}static checkForDuplicate(e){for(const n in ps.constructors)ps.constructors[+n].forEach(r=>{if(r===e)throw new E("Duplicate callback constructor.")})}static clear(){ps.constructors={}}static createCallbacks(e){const n=[];for(const s in ps.constructors){const r=+s;e>=r&&n.push(...ps.constructors[r])}return n.map(s=>new s)}}ps.constructors={};function BT(t,e,n,s,r,o,i,a,l){const c=new y5,u=[new x5,...ps.createCallbacks(e)];t!=null&&u.push(...t),u.push(c);const h=new g5(u);return h.setParams({epochs:n,initialEpoch:s,samples:r,steps:o,batchSize:i,verbose:e,doValidation:a,metrics:l}),{callbackList:h,history:c}}/** * @license * Copyright 2018 Google LLC * @@ -7729,7 +7729,7 @@ body { * license that can be found in the LICENSE file or at * https://opensource.org/licenses/MIT. * ============================================================================= - */function Cr(t,e={},n=!1){return wh(t,xs.getMap().classNameMap,e,"layer",n)}/** + */function Cr(t,e={},n=!1){return yh(t,xs.getMap().classNameMap,e,"layer",n)}/** * @license * Copyright 2018 Google LLC * @@ -7737,7 +7737,7 @@ body { * license that can be found in the LICENSE file or at * https://opensource.org/licenses/MIT. * ============================================================================= - */function Tf(t,e){return P(()=>{t.dtype!=="float32"&&(t=le(t,"float32"));const n=me(bh(t),e,!0),s=xm(n.shape,Mt()),r=hn(jo(n,s));return ge(t,r)})}function Tm(t,e){return P(()=>Rt(bh(ve(e,t)),-1))}function nv(t,e){return P(()=>Rt(xn(ve(e,t)),-1))}function sv(t,e){return P(()=>{const n=ve(t,e),s=as(xn(t),Mt(),Number.MAX_VALUE),r=xn(ge(n,s));return D(100,Rt(r,-1))})}function b5(t,e){return P(()=>{const n=as(e,Mt(),Number.MAX_VALUE),s=Ir(J(1,n)),r=as(t,Mt(),Number.MAX_VALUE),o=Ir(J(1,r));return Rt(bh(ve(s,o)),-1)})}function C5(t,e){return P(()=>{const n=jo(0,ve(1,D(t,e)));return Rt(bh(n),-1)})}function k5(t,e){return P(()=>{const n=jo(0,ve(1,D(t,e)));return Rt(n,-1)})}function S5(t,e){return P(()=>{const n=me(D(t,e),-1),s=Ys(D(ve(1,t),e),-1);return jo(0,J(1,ve(s,n)))})}function I5(t,e){return P(()=>{const n=Math.log(2),s=ve(e,t),r=ve(J(s,dh(D(-2,s))),n);return Rt(r,-1)})}function Qc(t,e,n=!1){return P(()=>{if(n)e=iw(e);else{const s=me(e,e.shape.length-1,!0);e=ge(e,s)}return e=as(e,Mt(),1-Mt()),St(me(D(le(t,"float32"),Ir(e)),e.shape.length-1))})}function Ef(t,e,n=!1){return P(()=>{const s=le(vm(H6(t)),"int32");e=as(e,Mt(),1-Mt());const r=e.shape,o=F(cN(s,r[r.length-1]),r);return Qc(o,e,n)})}function $5(t,e){if(!Ue(t.shape,e.shape))throw new E(`logits and labels must have the same shape, but got shapes ${JSON.stringify(t.shape)} and ${JSON.stringify(e.shape)}`);return P(()=>{const n=Yi(e),s=St(xn(e));return J(ve(n,D(e,t)),oN(Sr(s)))})}function Em(t,e){return P(()=>{let n;return n=as(e,Mt(),1-Mt()),n=Ir(ge(n,ve(1,n))),Rt($5(t,n),-1)})}function N5(t,e){return P(()=>{const n=as(t,Mt(),1),s=as(e,Mt(),1);return me(D(t,Ir(ge(n,s))),-1)})}function T5(t,e){return P(()=>{const n=Ir(J(Mt(),e));return Rt(ve(e,D(t,n)),-1)})}function VT(t,e){return P(()=>{const n=Tf(t,-1),s=Tf(e,-1),r=D(n,s);return St(me(r,-1))})}const Rf={meanSquaredError:Tm,meanAbsoluteError:nv,meanAbsolutePercentageError:sv,meanSquaredLogarithmicError:b5,squaredHinge:C5,hinge:k5,categoricalHinge:S5,logcosh:I5,categoricalCrossentropy:Qc,sparseCategoricalCrossentropy:Ef,binaryCrossentropy:Em,kullbackLeiblerDivergence:N5,poisson:T5,cosineProximity:VT};function Tg(t){if(typeof t=="string"){if(t in Rf)return Rf[t];let e=`Unknown loss ${t}`;throw t.toLowerCase().includes("softmaxcrossentropy")&&(e=`Unknown loss ${t}. Use "categoricalCrossentropy" as the string name for tf.losses.softmaxCrossEntropy`),new E(e)}else return t}/** + */function Nf(t,e){return P(()=>{t.dtype!=="float32"&&(t=le(t,"float32"));const n=me(vh(t),e,!0),s=xm(n.shape,Mt()),r=hn(jo(n,s));return ge(t,r)})}function Tm(t,e){return P(()=>Rt(vh(ve(e,t)),-1))}function nv(t,e){return P(()=>Rt(xn(ve(e,t)),-1))}function sv(t,e){return P(()=>{const n=ve(t,e),s=as(xn(t),Mt(),Number.MAX_VALUE),r=xn(ge(n,s));return D(100,Rt(r,-1))})}function v5(t,e){return P(()=>{const n=as(e,Mt(),Number.MAX_VALUE),s=Ir(J(1,n)),r=as(t,Mt(),Number.MAX_VALUE),o=Ir(J(1,r));return Rt(vh(ve(s,o)),-1)})}function b5(t,e){return P(()=>{const n=jo(0,ve(1,D(t,e)));return Rt(vh(n),-1)})}function C5(t,e){return P(()=>{const n=jo(0,ve(1,D(t,e)));return Rt(n,-1)})}function k5(t,e){return P(()=>{const n=me(D(t,e),-1),s=Ys(D(ve(1,t),e),-1);return jo(0,J(1,ve(s,n)))})}function S5(t,e){return P(()=>{const n=Math.log(2),s=ve(e,t),r=ve(J(s,hh(D(-2,s))),n);return Rt(r,-1)})}function Qc(t,e,n=!1){return P(()=>{if(n)e=iw(e);else{const s=me(e,e.shape.length-1,!0);e=ge(e,s)}return e=as(e,Mt(),1-Mt()),St(me(D(le(t,"float32"),Ir(e)),e.shape.length-1))})}function Tf(t,e,n=!1){return P(()=>{const s=le(vm(G6(t)),"int32");e=as(e,Mt(),1-Mt());const r=e.shape,o=F(cN(s,r[r.length-1]),r);return Qc(o,e,n)})}function I5(t,e){if(!Ue(t.shape,e.shape))throw new E(`logits and labels must have the same shape, but got shapes ${JSON.stringify(t.shape)} and ${JSON.stringify(e.shape)}`);return P(()=>{const n=Yi(e),s=St(xn(e));return J(ve(n,D(e,t)),oN(Sr(s)))})}function Em(t,e){return P(()=>{let n;return n=as(e,Mt(),1-Mt()),n=Ir(ge(n,ve(1,n))),Rt(I5(t,n),-1)})}function $5(t,e){return P(()=>{const n=as(t,Mt(),1),s=as(e,Mt(),1);return me(D(t,Ir(ge(n,s))),-1)})}function N5(t,e){return P(()=>{const n=Ir(J(Mt(),e));return Rt(ve(e,D(t,n)),-1)})}function VT(t,e){return P(()=>{const n=Nf(t,-1),s=Nf(e,-1),r=D(n,s);return St(me(r,-1))})}const Ef={meanSquaredError:Tm,meanAbsoluteError:nv,meanAbsolutePercentageError:sv,meanSquaredLogarithmicError:v5,squaredHinge:b5,hinge:C5,categoricalHinge:k5,logcosh:S5,categoricalCrossentropy:Qc,sparseCategoricalCrossentropy:Tf,binaryCrossentropy:Em,kullbackLeiblerDivergence:$5,poisson:N5,cosineProximity:VT};function Tg(t){if(typeof t=="string"){if(t in Ef)return Ef[t];let e=`Unknown loss ${t}`;throw t.toLowerCase().includes("softmaxcrossentropy")&&(e=`Unknown loss ${t}. Use "categoricalCrossentropy" as the string name for tf.losses.softmaxCrossEntropy`),new E(e)}else return t}/** * @license * Copyright 2018 Google LLC * @@ -7745,7 +7745,7 @@ body { * license that can be found in the LICENSE file or at * https://opensource.org/licenses/MIT. * ============================================================================= - */function WT(t,e){return P(()=>{const n=D(.5,Rs(e)),s=vr(us(e,n),t.dtype);return Rt(kr(t,s),-1)})}function UT(t,e){return P(()=>vr(kr(Hc(t,-1),Hc(e,-1)),"float32"))}function E5(t,e){return P(()=>le(me(Gr(kr(t,1),kr(e,1))),"float32"))}function R5(t,e){return P(()=>le(me(Gr(kr(t,0),kr(e,1))),"float32"))}function A5(t,e){return P(()=>{const n=E5(t,e),s=R5(t,e),r=J(n,s);return le(Cn(us(r,0),ge(n,r),0),"float32")})}function D5(t,e){return Em(t,e)}function _5(t,e){return t.rank===e.rank&&(t=ph(t,[t.rank-1])),e=Hc(e,-1),e.dtype!==t.dtype&&(e=le(e,t.dtype)),le(kr(t,e),"float32")}const F5=Tm,z5=Tm,O5=nv,M5=nv,P5=sv,L5=sv,GT=Qc,B5=VT,HT=Ef,Af={binaryAccuracy:WT,categoricalAccuracy:UT,precision:A5,categoricalCrossentropy:GT,sparseCategoricalCrossentropy:HT,mse:F5,MSE:z5,mae:O5,MAE:M5,mape:P5,MAPE:L5,cosine:B5};function V5(t){if(typeof t=="string"&&t in Af)return Af[t];if(typeof t!="string"&&t!=null)return t;throw new E(`Unknown metric ${t}`)}function sd(t){if(hr(t!==null,`Unknown LossOrMetricFn ${t}`),typeof t=="string")return t;{let e;for(const n of Object.keys(Rf))if(Rf[n]===t){e=n;break}if(e!==void 0)return e;for(const n of Object.keys(Af))if(Af[n]===t){e=n;break}return e!==void 0?e:t.name}}/** + */function WT(t,e){return P(()=>{const n=D(.5,Rs(e)),s=vr(us(e,n),t.dtype);return Rt(kr(t,s),-1)})}function UT(t,e){return P(()=>vr(kr(Hc(t,-1),Hc(e,-1)),"float32"))}function T5(t,e){return P(()=>le(me(Gr(kr(t,1),kr(e,1))),"float32"))}function E5(t,e){return P(()=>le(me(Gr(kr(t,0),kr(e,1))),"float32"))}function R5(t,e){return P(()=>{const n=T5(t,e),s=E5(t,e),r=J(n,s);return le(Cn(us(r,0),ge(n,r),0),"float32")})}function A5(t,e){return Em(t,e)}function D5(t,e){return t.rank===e.rank&&(t=fh(t,[t.rank-1])),e=Hc(e,-1),e.dtype!==t.dtype&&(e=le(e,t.dtype)),le(kr(t,e),"float32")}const _5=Tm,F5=Tm,z5=nv,O5=nv,M5=sv,P5=sv,GT=Qc,L5=VT,HT=Tf,Rf={binaryAccuracy:WT,categoricalAccuracy:UT,precision:R5,categoricalCrossentropy:GT,sparseCategoricalCrossentropy:HT,mse:_5,MSE:F5,mae:z5,MAE:O5,mape:M5,MAPE:P5,cosine:L5};function B5(t){if(typeof t=="string"&&t in Rf)return Rf[t];if(typeof t!="string"&&t!=null)return t;throw new E(`Unknown metric ${t}`)}function nd(t){if(hr(t!==null,`Unknown LossOrMetricFn ${t}`),typeof t=="string")return t;{let e;for(const n of Object.keys(Ef))if(Ef[n]===t){e=n;break}if(e!==void 0)return e;for(const n of Object.keys(Rf))if(Rf[n]===t){e=n;break}return e!==void 0?e:t.name}}/** * @license * Copyright 2018 Google LLC * @@ -7753,7 +7753,7 @@ body { * license that can be found in the LICENSE file or at * https://opensource.org/licenses/MIT. * ============================================================================= - */function W5(t){const e={Adagrad:()=>ia.adagrad(.01),Adadelta:()=>ia.adadelta(1,.95,Mt()),Adam:()=>ia.adam(.001,.9,.999,Mt()),Adamax:()=>ia.adamax(.002,.9,.999,Mt(),0),RMSProp:()=>ia.rmsprop(.001,.9,0,Mt()),SGD:()=>ia.sgd(.01)};if(e.adagrad=e.Adagrad,e.adadelta=e.Adadelta,e.adam=e.Adam,e.adamax=e.Adamax,e.rmsprop=e.RMSProp,e.sgd=e.SGD,t in e)return e[t]();throw new E(`Unknown Optimizer ${t}`)}/** + */function V5(t){const e={Adagrad:()=>ia.adagrad(.01),Adadelta:()=>ia.adadelta(1,.95,Mt()),Adam:()=>ia.adam(.001,.9,.999,Mt()),Adamax:()=>ia.adamax(.002,.9,.999,Mt(),0),RMSProp:()=>ia.rmsprop(.001,.9,0,Mt()),SGD:()=>ia.sgd(.01)};if(e.adagrad=e.Adagrad,e.adadelta=e.Adadelta,e.adam=e.Adam,e.adamax=e.Adamax,e.rmsprop=e.RMSProp,e.sgd=e.SGD,t in e)return e[t]();throw new E(`Unknown Optimizer ${t}`)}/** * @license * Copyright 2019 Google LLC * @@ -7769,7 +7769,7 @@ body { * license that can be found in the LICENSE file or at * https://opensource.org/licenses/MIT. * ============================================================================= - */function U5(t,e,n,s=console.log){const r=H5(t),o=["Layer (type)","Input Shape","Output shape","Param #"];r?(e=e||90,n=n||[.32,.61,.89,1]):(e=e||115,n=n||[.24,.48,.7,.8,1]),n[n.length-1]<=1&&(n=n.map(u=>Math.floor(e*u)));let i;if(!r){o.push("Receives inputs"),i=[];for(const u in t.nodesByDepth)i.push(...t.nodesByDepth[u])}s("_".repeat(e)),Df(o,n,s),s("=".repeat(e));const a=t.layers;for(let u=0;u1||r.length===1&&r[0].inboundLayers.length>1){e=!1;break}s.push(...r)}if(e)for(const r of t.layers){let o=!1;for(const i of r.inboundNodes)if(s.indexOf(i)!==-1)if(o){e=!1;break}else o=!0;if(!e)break}return e}function Df(t,e,n=console.log){let s="";for(let r=0;r0&&(s=s.slice(0,s.length-1)+" "),s+=t[r],s=s.slice(0,e[r]),s+=" ".repeat(e[r]-s.length);n(s)}function j5(t,e,n){let s,r;try{r=t.inboundNodes.map(l=>JSON.stringify(l.inputShapes)).join(",")}catch{r="multiple"}try{s=JSON.stringify(t.outputShape)}catch{s="multiple"}const o=t.name,i=t.getClassName(),a=[`${o} (${i})`,r,s,t.countParams().toString()];Df(a,e,n)}function K5(t,e,n,s){let r,o;try{o=t.inboundNodes.map(h=>JSON.stringify(h.inputShapes)).join(",")}catch{o="multiple"}try{r=JSON.stringify(t.outputShape)}catch{r="multiple"}const i=[];for(const h of t.inboundNodes)if(!(n!=null&&n.length>0&&n.indexOf(h)===-1))for(let d=0;dMath.floor(e*u)));let i;if(!r){o.push("Receives inputs"),i=[];for(const u in t.nodesByDepth)i.push(...t.nodesByDepth[u])}s("_".repeat(e)),Af(o,n,s),s("=".repeat(e));const a=t.layers;for(let u=0;u1||r.length===1&&r[0].inboundLayers.length>1){e=!1;break}s.push(...r)}if(e)for(const r of t.layers){let o=!1;for(const i of r.inboundNodes)if(s.indexOf(i)!==-1)if(o){e=!1;break}else o=!0;if(!e)break}return e}function Af(t,e,n=console.log){let s="";for(let r=0;r0&&(s=s.slice(0,s.length-1)+" "),s+=t[r],s=s.slice(0,e[r]),s+=" ".repeat(e[r]-s.length);n(s)}function H5(t,e,n){let s,r;try{r=t.inboundNodes.map(l=>JSON.stringify(l.inputShapes)).join(",")}catch{r="multiple"}try{s=JSON.stringify(t.outputShape)}catch{s="multiple"}const o=t.name,i=t.getClassName(),a=[`${o} (${i})`,r,s,t.countParams().toString()];Af(a,e,n)}function j5(t,e,n,s){let r,o;try{o=t.inboundNodes.map(h=>JSON.stringify(h.inputShapes)).join(",")}catch{o="multiple"}try{r=JSON.stringify(t.outputShape)}catch{r="multiple"}const i=[];for(const h of t.inboundNodes)if(!(n!=null&&n.length>0&&n.indexOf(h)===-1))for(let d=0;d{const e=Object.keys(t);if(e.length===0)return!1;const n=e[0].split("/");return!isNaN(parseInt(n[n.length-1],10))};class Ps extends Ae{constructor(e){if(super({}),this.containerNodes=new Set,this.name=e.name,this.name==null){const y=this.getClassName().toLowerCase();this.name=Im(y)}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],To(this.inputs).length!==this.inputs.length)throw new E(`The list of inputs passed to the model is redundant. All inputs should only appear once. Found: ${this.inputs.map(y=>y.name)}`);To(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(y=>y.name)}`),this.inputLayers=[],this.inputLayersNodeIndices=[],this.inputLayersTensorIndices=[],this.outputLayers=[],this.outputLayersNodeIndices=[],this.outputLayersTensorIndices=[],this.layers=[],this.internalContainerRefs=[];for(const y of this.outputs){const w=y.sourceLayer,v=y.nodeIndex,b=y.tensorIndex;this.outputLayers.push(w),this.outputLayersNodeIndices.push(v),this.outputLayersTensorIndices.push(b)}for(const y of this.inputs){const w=y.sourceLayer,v=y.nodeIndex,b=y.tensorIndex;hr(v===0,"input layer has >1 nodes"),hr(b===0,"input layer has >1 tensors"),this.inputLayers.push(w),this.inputLayersNodeIndices.push(v),this.inputLayersTensorIndices.push(b)}this.inputNames=[],this.outputNames=[],this.feedInputShapes=[],this.feedInputNames=[],this.feedOutputNames=[];for(let y=0;yy.shape),this.internalOutputShapes=this.outputs.map(y=>y.shape);const n={},s={},r={},o={},i={},a=[],l=(y,w,v,b,C,k)=>{(b==null||C==null||k==null)&&(b=y.sourceLayer,C=y.nodeIndex,k=y.tensorIndex);const S=b.inboundNodes[C];if(v.indexOf(S)!==-1)throw new ks(`The tensor ${y.name} at layer "${b.name}" is part of a cycle.`);if(w.indexOf(S)!==-1)return;this.containerNodes.add(Ps.nodeKey(b,C)),b.id in i||(i[b.id]=Object.keys(i).length),v.indexOf(S)===-1&&v.push(S);const $=S.inboundLayers.length;for(let N=0;N<$;N++){const A=S.inputTensors[N],M=S.inboundLayers[N],L=S.nodeIndices[N],V=S.tensorIndices[N];l(A,w,v,M,L,V)}for(w.push(S);v.indexOf(S)>=0;)v.splice(v.indexOf(S),1);a.push(S)},c=[],u=[];for(const y of this.outputs)l(y,c,u);const h=a.slice().reverse();for(const y of h){s[y.id]=y,y.id in n||(n[y.id]=0);let w=n[y.id];const v=r[y.outboundLayer.id]==null?0:r[y.outboundLayer.id];w=Math.max(w,v),r[y.outboundLayer.id]=w,o[y.outboundLayer.id]=y.outboundLayer,n[y.id]=w;for(let b=0;bparseInt(y,10)).sort(ed);this.layers=[];for(const y of p){const w=f[y];w.sort((v,b)=>{const C=i[v.id],k=i[b.id];return Ck?1:0});for(const v of w)v instanceof Ps&&this.internalContainerRefs.push(v),this.layers.push(v)}this.layersByDepth=f,p=Object.keys(d).map(y=>parseInt(y,10)).sort(ed);const g=this.inputs.slice(),x=[];for(const y of p)for(const w of d[y]){const v=w.outboundLayer;if(v!=null){for(const b of w.inputTensors)if(g.indexOf(b)===-1)throw new ks(`Graph disconnected: cannot obtain value for tensor ${b} at layer "${v.name}". The following previous layers were accessed without issue: ${x}`);for(const b of w.outputTensors)g.push(b);x.push(v.name)}}this.nodesByDepth=d;const m=this.layers.map(y=>y.name);for(const y of m){const w=m.filter(v=>v===y).length;if(w!==1)throw new ks(`The name "${y}" is used ${w} times in the model. All layer names should be unique. Layer names: `+JSON.stringify(m))}this.outboundNodes=[],this.inboundNodes=[],new Nm({outboundLayer:this,inboundLayers:[],nodeIndices:[],tensorIndices:[],inputTensors:this.inputs,outputTensors:this.outputs,inputMasks:this.inputs.map(y=>null),outputMasks:this.outputs.map(y=>null),inputShapes:this.inputs.map(y=>y.shape),outputShapes:this.outputs.map(y=>y.shape)}),this.built=!0,this._refCount=1}assertNotDisposed(){if(this._refCount===0)throw new Error(`Container '${this.name}' is already disposed.`)}dispose(){this.assertNotDisposed();const e={refCountAfterDispose:null,numDisposedVariables:0};if(--this._refCount===0){for(const n of this.layers)e.numDisposedVariables+=n.dispose().numDisposedVariables;for(const n of this.internalContainerRefs)e.numDisposedVariables+=n.dispose().numDisposedVariables}return e.refCountAfterDispose=this._refCount,e}get trainable(){return this.trainable_}set trainable(e){this.layers.forEach(n=>{n._trainableWeights.forEach(s=>s.trainable=e)}),this.trainable_=e}get trainableWeights(){if(this._trainableWeights.length>0)throw new E("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 n of this.layers)e=e.concat(n.trainableWeights);return e}get nonTrainableWeights(){const e=[];for(const n of this.layers)e.push(...n.nonTrainableWeights);if(!this.trainable){const n=[];for(const s of this.layers)n.push(...s.trainableWeights);return n.concat(e)}return e}get weights(){return this.trainableWeights.concat(this.nonTrainableWeights)}loadWeights(e,n=!0){const s={};let r=0;const o=X5(e);o&&this.parseWeights(e);for(const a of this.layers)for(const[l,c]of a.weights.entries()){const u=o?`${c.name.split("/").slice(0,-1).join("/")+"/"}${l}`:c.originalName;if(s[u]!=null)throw new E(`Duplicate weight name: ${u}`);s[u]=c,r++}const i=[];for(const a in e){let l=a;if(s[a]==null){const c=a.split("/");l=c.slice(0,-2).concat([c[c.length-1]]).join("/")}if(s[l]!=null)i.push([s[l],e[a]]);else if(n)throw new E(`Provided weight data has no target variable: ${a}`);delete s[l]}if(n){const a=[];for(const l in s)a.push(l);if(a.length>0)throw new E(`${a.length} of ${r} weights are not set: ${a}`)}ev(i)}parseWeights(e){for(const n in Object.keys(e)){const s=n.split("/"),r=["vars","layer_checkpoint_dependencies"],o=s.map(i=>i.startsWith("_")?i.slice(1):i).filter(i=>!r.includes(i)).join("/");o!==n&&(e[o]=e[n],delete e[n])}}updatedConfig(){const e=this.getConfig(),n={};return n.className=this.getClassName(),n.config=e,n.kerasVersion=`tfjs-layers ${KT}`,n.backend="TensorFlow.js",n}toJSON(e,n=!0){const s=C1(this.updatedConfig());return n?JSON.stringify(s):s}call(e,n){return P(()=>{e=Ke(e);const s=new fo;for(let r=0;r{e=Ke(e);let s;return n==null?s=Li(null,e.length):s=Ke(n),this.runInternalGraph(e,s)[1]})}computeOutputShape(e){const n=Sf(e);if(n.length!==this.inputLayers.length)throw new E(`Invalid inputShape argument ${e}: model has ${this.inputLayers.length} tensor inputs.`);const s={};for(let a=0;aparseInt(a,10)).sort(ed);if(r.length>1)for(const a of r){const l=this.nodesByDepth[a];for(const c of l){const u=c.outboundLayer;if(this.inputLayers.map(g=>g.id).indexOf(u.id)!==-1)continue;const h=[];for(let g=0;gparseInt(l,10)).sort(ed);for(const l of r){const c=this.nodesByDepth[l];for(const u of c){const h=u.outboundLayer,d=u.inputTensors,f=u.outputTensors,p=new Array;for(const g of d)g.id in s&&p.push(s[g.id]);if(p.length===d.length){let g={},x,m,y,w;if(u.callArgs!=null&&(g=u.callArgs),p.length===1){const[v,b]=p[0];g.mask==null&&(g.mask=b),y=Ke(h.call(v,g)),w=Ke(h.computeMask(v,b)),x=[v],m=[b]}else x=p.map(v=>v[0]),m=p.map(v=>v[1]),g.mask==null&&(g.mask=m),y=Ke(h.call(x,g)),w=Ke(h.computeMask(x,m));if(h.activityRegularizer)throw new Ie("LayersModel invocation with concrete Tensor value(s) in the presence of activity regularizer(s) is not supported yet.");for(let v=0;v{const e=[];for(const n of this.layers)for(let s=0;s0){const g=[];for(let x=0;x0&&x.apply(Rn(y),w)}function c(x){const m=x.name,y=Cr(x,n.customObjects!=null?n.customObjects:{});y.setFastWeightInitDuringBuild(r),o[m]=y,x.inboundNodes.forEach(v=>{if(!(v instanceof Array))throw new E(`Corrupted configuration, expected array for nodeData: ${v}`);a(y,v)})}const u=n.name,h=n.layers;for(const x of h)c(x);for(;!D6(i);)for(const x of h){const m=o[x.name];if(m.name in i){const y=i[m.name];delete i[m.name];for(const w of y)l(m,w)}}const d=[],f=[],p=n.inputLayers;for(const x of p){const m=x[0],y=x[1],w=x[2];hr(m in o);const b=o[m].inboundNodes[y].outputTensors;d.push(b[w])}const g=n.outputLayers;for(const x of g){const m=x[0],y=x[1],w=x[2];hr(m in o);const b=o[m].inboundNodes[y].outputTensors;f.push(b[w])}return new e({inputs:d,outputs:f,name:u})}get stateful(){if(this._stateful)throw new E("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(){P(()=>{this.layers.forEach(e=>{e.stateful&&e.resetStates()})})}}/** + */const K5=t=>{const e=Object.keys(t);if(e.length===0)return!1;const n=e[0].split("/");return!isNaN(parseInt(n[n.length-1],10))};class Ps extends Ae{constructor(e){if(super({}),this.containerNodes=new Set,this.name=e.name,this.name==null){const y=this.getClassName().toLowerCase();this.name=Im(y)}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],To(this.inputs).length!==this.inputs.length)throw new E(`The list of inputs passed to the model is redundant. All inputs should only appear once. Found: ${this.inputs.map(y=>y.name)}`);To(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(y=>y.name)}`),this.inputLayers=[],this.inputLayersNodeIndices=[],this.inputLayersTensorIndices=[],this.outputLayers=[],this.outputLayersNodeIndices=[],this.outputLayersTensorIndices=[],this.layers=[],this.internalContainerRefs=[];for(const y of this.outputs){const w=y.sourceLayer,v=y.nodeIndex,b=y.tensorIndex;this.outputLayers.push(w),this.outputLayersNodeIndices.push(v),this.outputLayersTensorIndices.push(b)}for(const y of this.inputs){const w=y.sourceLayer,v=y.nodeIndex,b=y.tensorIndex;hr(v===0,"input layer has >1 nodes"),hr(b===0,"input layer has >1 tensors"),this.inputLayers.push(w),this.inputLayersNodeIndices.push(v),this.inputLayersTensorIndices.push(b)}this.inputNames=[],this.outputNames=[],this.feedInputShapes=[],this.feedInputNames=[],this.feedOutputNames=[];for(let y=0;yy.shape),this.internalOutputShapes=this.outputs.map(y=>y.shape);const n={},s={},r={},o={},i={},a=[],l=(y,w,v,b,C,k)=>{(b==null||C==null||k==null)&&(b=y.sourceLayer,C=y.nodeIndex,k=y.tensorIndex);const S=b.inboundNodes[C];if(v.indexOf(S)!==-1)throw new ks(`The tensor ${y.name} at layer "${b.name}" is part of a cycle.`);if(w.indexOf(S)!==-1)return;this.containerNodes.add(Ps.nodeKey(b,C)),b.id in i||(i[b.id]=Object.keys(i).length),v.indexOf(S)===-1&&v.push(S);const $=S.inboundLayers.length;for(let N=0;N<$;N++){const A=S.inputTensors[N],M=S.inboundLayers[N],L=S.nodeIndices[N],V=S.tensorIndices[N];l(A,w,v,M,L,V)}for(w.push(S);v.indexOf(S)>=0;)v.splice(v.indexOf(S),1);a.push(S)},c=[],u=[];for(const y of this.outputs)l(y,c,u);const h=a.slice().reverse();for(const y of h){s[y.id]=y,y.id in n||(n[y.id]=0);let w=n[y.id];const v=r[y.outboundLayer.id]==null?0:r[y.outboundLayer.id];w=Math.max(w,v),r[y.outboundLayer.id]=w,o[y.outboundLayer.id]=y.outboundLayer,n[y.id]=w;for(let b=0;bparseInt(y,10)).sort(Jh);this.layers=[];for(const y of p){const w=f[y];w.sort((v,b)=>{const C=i[v.id],k=i[b.id];return Ck?1:0});for(const v of w)v instanceof Ps&&this.internalContainerRefs.push(v),this.layers.push(v)}this.layersByDepth=f,p=Object.keys(d).map(y=>parseInt(y,10)).sort(Jh);const g=this.inputs.slice(),x=[];for(const y of p)for(const w of d[y]){const v=w.outboundLayer;if(v!=null){for(const b of w.inputTensors)if(g.indexOf(b)===-1)throw new ks(`Graph disconnected: cannot obtain value for tensor ${b} at layer "${v.name}". The following previous layers were accessed without issue: ${x}`);for(const b of w.outputTensors)g.push(b);x.push(v.name)}}this.nodesByDepth=d;const m=this.layers.map(y=>y.name);for(const y of m){const w=m.filter(v=>v===y).length;if(w!==1)throw new ks(`The name "${y}" is used ${w} times in the model. All layer names should be unique. Layer names: `+JSON.stringify(m))}this.outboundNodes=[],this.inboundNodes=[],new Nm({outboundLayer:this,inboundLayers:[],nodeIndices:[],tensorIndices:[],inputTensors:this.inputs,outputTensors:this.outputs,inputMasks:this.inputs.map(y=>null),outputMasks:this.outputs.map(y=>null),inputShapes:this.inputs.map(y=>y.shape),outputShapes:this.outputs.map(y=>y.shape)}),this.built=!0,this._refCount=1}assertNotDisposed(){if(this._refCount===0)throw new Error(`Container '${this.name}' is already disposed.`)}dispose(){this.assertNotDisposed();const e={refCountAfterDispose:null,numDisposedVariables:0};if(--this._refCount===0){for(const n of this.layers)e.numDisposedVariables+=n.dispose().numDisposedVariables;for(const n of this.internalContainerRefs)e.numDisposedVariables+=n.dispose().numDisposedVariables}return e.refCountAfterDispose=this._refCount,e}get trainable(){return this.trainable_}set trainable(e){this.layers.forEach(n=>{n._trainableWeights.forEach(s=>s.trainable=e)}),this.trainable_=e}get trainableWeights(){if(this._trainableWeights.length>0)throw new E("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 n of this.layers)e=e.concat(n.trainableWeights);return e}get nonTrainableWeights(){const e=[];for(const n of this.layers)e.push(...n.nonTrainableWeights);if(!this.trainable){const n=[];for(const s of this.layers)n.push(...s.trainableWeights);return n.concat(e)}return e}get weights(){return this.trainableWeights.concat(this.nonTrainableWeights)}loadWeights(e,n=!0){const s={};let r=0;const o=K5(e);o&&this.parseWeights(e);for(const a of this.layers)for(const[l,c]of a.weights.entries()){const u=o?`${c.name.split("/").slice(0,-1).join("/")+"/"}${l}`:c.originalName;if(s[u]!=null)throw new E(`Duplicate weight name: ${u}`);s[u]=c,r++}const i=[];for(const a in e){let l=a;if(s[a]==null){const c=a.split("/");l=c.slice(0,-2).concat([c[c.length-1]]).join("/")}if(s[l]!=null)i.push([s[l],e[a]]);else if(n)throw new E(`Provided weight data has no target variable: ${a}`);delete s[l]}if(n){const a=[];for(const l in s)a.push(l);if(a.length>0)throw new E(`${a.length} of ${r} weights are not set: ${a}`)}ev(i)}parseWeights(e){for(const n in Object.keys(e)){const s=n.split("/"),r=["vars","layer_checkpoint_dependencies"],o=s.map(i=>i.startsWith("_")?i.slice(1):i).filter(i=>!r.includes(i)).join("/");o!==n&&(e[o]=e[n],delete e[n])}}updatedConfig(){const e=this.getConfig(),n={};return n.className=this.getClassName(),n.config=e,n.kerasVersion=`tfjs-layers ${KT}`,n.backend="TensorFlow.js",n}toJSON(e,n=!0){const s=C1(this.updatedConfig());return n?JSON.stringify(s):s}call(e,n){return P(()=>{e=Ke(e);const s=new fo;for(let r=0;r{e=Ke(e);let s;return n==null?s=Li(null,e.length):s=Ke(n),this.runInternalGraph(e,s)[1]})}computeOutputShape(e){const n=kf(e);if(n.length!==this.inputLayers.length)throw new E(`Invalid inputShape argument ${e}: model has ${this.inputLayers.length} tensor inputs.`);const s={};for(let a=0;aparseInt(a,10)).sort(Jh);if(r.length>1)for(const a of r){const l=this.nodesByDepth[a];for(const c of l){const u=c.outboundLayer;if(this.inputLayers.map(g=>g.id).indexOf(u.id)!==-1)continue;const h=[];for(let g=0;gparseInt(l,10)).sort(Jh);for(const l of r){const c=this.nodesByDepth[l];for(const u of c){const h=u.outboundLayer,d=u.inputTensors,f=u.outputTensors,p=new Array;for(const g of d)g.id in s&&p.push(s[g.id]);if(p.length===d.length){let g={},x,m,y,w;if(u.callArgs!=null&&(g=u.callArgs),p.length===1){const[v,b]=p[0];g.mask==null&&(g.mask=b),y=Ke(h.call(v,g)),w=Ke(h.computeMask(v,b)),x=[v],m=[b]}else x=p.map(v=>v[0]),m=p.map(v=>v[1]),g.mask==null&&(g.mask=m),y=Ke(h.call(x,g)),w=Ke(h.computeMask(x,m));if(h.activityRegularizer)throw new Ie("LayersModel invocation with concrete Tensor value(s) in the presence of activity regularizer(s) is not supported yet.");for(let v=0;v{const e=[];for(const n of this.layers)for(let s=0;s0){const g=[];for(let x=0;x0&&x.apply(Rn(y),w)}function c(x){const m=x.name,y=Cr(x,n.customObjects!=null?n.customObjects:{});y.setFastWeightInitDuringBuild(r),o[m]=y,x.inboundNodes.forEach(v=>{if(!(v instanceof Array))throw new E(`Corrupted configuration, expected array for nodeData: ${v}`);a(y,v)})}const u=n.name,h=n.layers;for(const x of h)c(x);for(;!A6(i);)for(const x of h){const m=o[x.name];if(m.name in i){const y=i[m.name];delete i[m.name];for(const w of y)l(m,w)}}const d=[],f=[],p=n.inputLayers;for(const x of p){const m=x[0],y=x[1],w=x[2];hr(m in o);const b=o[m].inboundNodes[y].outputTensors;d.push(b[w])}const g=n.outputLayers;for(const x of g){const m=x[0],y=x[1],w=x[2];hr(m in o);const b=o[m].inboundNodes[y].outputTensors;f.push(b[w])}return new e({inputs:d,outputs:f,name:u})}get stateful(){if(this._stateful)throw new E("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(){P(()=>{this.layers.forEach(e=>{e.stateful&&e.resetStates()})})}}/** * @license * Copyright 2018 Google LLC * @@ -7793,7 +7793,7 @@ body { * license that can be found in the LICENSE file or at * https://opensource.org/licenses/MIT. * ============================================================================= - */function q5(t,e,n){const s=e.length;if(t==null||Array.isArray(t)&&t.length===0)return e.map(r=>null);if(s===1)return Array.isArray(t)&&t.length===1?t:typeof t=="object"&&e[0]in t?[t[e[0]]]:[t];if(Array.isArray(t)){if(t.length!==s)throw new Error(`Provided ${n} is an array of ${t.length} element(s), but the model has ${s} outputs. Make sure a set of weights is provided for each model output.`);return t}else if(typeof t=="object"&&Object.keys(t).length>0&&typeof t[Object.keys(t)[0]]=="object"){const r=[];return e.forEach(o=>{o in t?r.push(t[o]):r.push(null)}),r}else throw new Error(`The model has multiple (${s}) outputs, so ${n} must be either an array with ${s} elements or an object with ${e} keys. Provided ${n} not understood: ${JSON.stringify(t)}`)}function XT(t,e){return q5(t,e,"classWeight")}async function qT(t,e,n,s){if(n!=null){const r=P(()=>{if(t.shape.length===1)return vi(t);if(t.shape.length===2){if(t.shape[1]>1)return Hc(t,1);if(t.shape[1]===1)return F(t,[t.shape[0]]);throw new Error(`Encountered unexpected last-dimension size (${t.shape[1]}) during handling of class weights. The size is expected to be >= 1.`)}else throw new Error(`Unexpected rank of target (y) tensor (${t.rank}) during handling of class weights. The rank is expected to be 1 or 2.`)}),o=Array.from(await r.data());$e(r);const i=[];return o.forEach(a=>{if(n[a]==null)throw new Error(`classWeight must contain all classes in the training data. The class ${a} exists in the data but not in classWeight`);i.push(n[a])}),Gn(i,"float32")}else return null}function Y5(t,e){return D(t,e)}/** + */function X5(t,e,n){const s=e.length;if(t==null||Array.isArray(t)&&t.length===0)return e.map(r=>null);if(s===1)return Array.isArray(t)&&t.length===1?t:typeof t=="object"&&e[0]in t?[t[e[0]]]:[t];if(Array.isArray(t)){if(t.length!==s)throw new Error(`Provided ${n} is an array of ${t.length} element(s), but the model has ${s} outputs. Make sure a set of weights is provided for each model output.`);return t}else if(typeof t=="object"&&Object.keys(t).length>0&&typeof t[Object.keys(t)[0]]=="object"){const r=[];return e.forEach(o=>{o in t?r.push(t[o]):r.push(null)}),r}else throw new Error(`The model has multiple (${s}) outputs, so ${n} must be either an array with ${s} elements or an object with ${e} keys. Provided ${n} not understood: ${JSON.stringify(t)}`)}function XT(t,e){return X5(t,e,"classWeight")}async function qT(t,e,n,s){if(n!=null){const r=P(()=>{if(t.shape.length===1)return vi(t);if(t.shape.length===2){if(t.shape[1]>1)return Hc(t,1);if(t.shape[1]===1)return F(t,[t.shape[0]]);throw new Error(`Encountered unexpected last-dimension size (${t.shape[1]}) during handling of class weights. The size is expected to be >= 1.`)}else throw new Error(`Unexpected rank of target (y) tensor (${t.rank}) during handling of class weights. The rank is expected to be 1 or 2.`)}),o=Array.from(await r.data());$e(r);const i=[];return o.forEach(a=>{if(n[a]==null)throw new Error(`classWeight must contain all classes in the training data. The class ${a} exists in the data but not in classWeight`);i.push(n[a])}),Gn(i,"float32")}else return null}function q5(t,e){return D(t,e)}/** * @license * Copyright 2018 Google LLC * @@ -7801,7 +7801,7 @@ body { * license that can be found in the LICENSE file or at * https://opensource.org/licenses/MIT. * ============================================================================= - */const Q5=32;function YT(t,e){let n,s;const r=e;n=r.xs,s=r.ys,I(n!=null&&s!=null,()=>`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 ${e}`);const o=sk("input",t.inputNames,n),i=sk("output",t.outputNames,s),a=o[0].shape[0];I(o.length===t.inputs.length,()=>`LayersModel has ${t.inputs.length} inputs, but the dataset provides ${o.length} inputs. (Expected input keys: ${JSON.stringify(t.inputNames)})`),I(i.length===t.outputs.length,()=>`LayersModel has ${t.outputs.length} outputs, but the dataset provides ${i.length} outputs. (Expected output keys: ${JSON.stringify(t.outputNames)})`);for(let l=0;l`Batch size mismatch: input ${t.inputNames[l]} has ${o[l].shape[0]}; expected ${a} based on input ${t.inputNames[0]}.`);for(let l=0;l`Batch size mismatch: output ${t.outputNames[l]} has ${i[l].shape[0]}; expected ${a} based on input ${t.inputNames[0]}.`);return{xs:o,ys:i}}function sk(t,e,n){if(n instanceof zt)return[n];if(Array.isArray(n))return I(n.length===e.length,()=>`Received an array of ${n.length} Tensors, but expected ${e.length} to match the ${t} keys ${e}.`),n;{const s=[];for(const r of e){if(n[r]==null)throw new E(`The feature data generated by the dataset lacks the required ${t} key '${r}'.`);s.push(n[r])}return s}}function Z5(t){if(t.length===3)throw new Ie("Validation with sample weights is not implemented yet.");return{xs:t[0],ys:t[1]}}async function J5(t,e,n){const s=n.batchesPerEpoch!=null;if(I(t.optimizer!=null,()=>"You must compile a model before training/testing. Use LayersModel.compile(modelCompileConfig)."),I(n!=null,()=>"For fitDataset(), the 2nd argument (config) is required, but it is not provided in this call."),I(n.epochs!=null&&n.epochs>0&&Number.isInteger(n.epochs),()=>`For fitDataset(), config.epochs is expected to be a positive integer, but got ${n.epochs}`),I(!s||n.batchesPerEpoch>0&&Number.isInteger(n.batchesPerEpoch),()=>`For fitDataset(), config.batchesPerEpoch is expected to be a positive integer if specified, but got ${n.batchesPerEpoch}`),I(n.validationSplit==null,()=>"`validationSplit` is not supported by `fitDataset()`. Use validationData instead."),t.isTraining)throw new Error("Cannot start training because another fit() call is ongoing.");t.isTraining=!0;try{const r=n.validationData!=null;let o,i;if(r)if(rk(n.validationData))I(n.validationBatches==null||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 x=Z5(n.validationData);o=x.xs,i=x.ys}const a=t.makeTrainFunction(),l=t.getDedupedMetricsNames();let c;r?c=l.slice().concat(l.map(x=>"val_"+x)):c=l.slice();const u=LT(n.callbacks,n.yieldEvery),h=n.verbose==null?1:n.verbose,{callbackList:d,history:f}=BT(u,h,n.epochs,null,null,eH(e,n),null,r,c);d.setModel(t),t.history=f,await d.onTrainBegin(),t.stopTraining_=!1;let p=n.initialEpoch==null?0:n.initialEpoch,g=await e.iterator();for(;p=n.batchesPerEpoch:w.done){if(r){let v;rk(n.validationData)?v=Ke(await t.evaluateDataset(n.validationData,{batches:n.validationBatches})):v=Ke(t.evaluate(o,i,{batchSize:n.validationBatchSize==null?Q5:n.validationBatchSize,verbose:0}));for(let b=0;b0)throw new Ie("Verbose mode is not implemented yet.");I(!s||n.batches>0&&Number.isInteger(n.batches),()=>`Test loop expects \`batches\` to be a positive integer, but received ${JSON.stringify(n.batches)}`);const i=tH(e)?e:await e.iterator();let a=0,l=0;for(;!s||l{if(c.value){const{xs:u,ys:h}=YT(t,c.value),d=u.concat(h),f=P(()=>r(d));if($e(d),l===0)for(let g=0;gJ(o[g],D(p,x))),l>0&&$e(m)}$e(f),a+=p,++l}return o}),c.done){s&&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 c=0;c`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 ${e}`);const o=sk("input",t.inputNames,n),i=sk("output",t.outputNames,s),a=o[0].shape[0];I(o.length===t.inputs.length,()=>`LayersModel has ${t.inputs.length} inputs, but the dataset provides ${o.length} inputs. (Expected input keys: ${JSON.stringify(t.inputNames)})`),I(i.length===t.outputs.length,()=>`LayersModel has ${t.outputs.length} outputs, but the dataset provides ${i.length} outputs. (Expected output keys: ${JSON.stringify(t.outputNames)})`);for(let l=0;l`Batch size mismatch: input ${t.inputNames[l]} has ${o[l].shape[0]}; expected ${a} based on input ${t.inputNames[0]}.`);for(let l=0;l`Batch size mismatch: output ${t.outputNames[l]} has ${i[l].shape[0]}; expected ${a} based on input ${t.inputNames[0]}.`);return{xs:o,ys:i}}function sk(t,e,n){if(n instanceof zt)return[n];if(Array.isArray(n))return I(n.length===e.length,()=>`Received an array of ${n.length} Tensors, but expected ${e.length} to match the ${t} keys ${e}.`),n;{const s=[];for(const r of e){if(n[r]==null)throw new E(`The feature data generated by the dataset lacks the required ${t} key '${r}'.`);s.push(n[r])}return s}}function Q5(t){if(t.length===3)throw new Ie("Validation with sample weights is not implemented yet.");return{xs:t[0],ys:t[1]}}async function Z5(t,e,n){const s=n.batchesPerEpoch!=null;if(I(t.optimizer!=null,()=>"You must compile a model before training/testing. Use LayersModel.compile(modelCompileConfig)."),I(n!=null,()=>"For fitDataset(), the 2nd argument (config) is required, but it is not provided in this call."),I(n.epochs!=null&&n.epochs>0&&Number.isInteger(n.epochs),()=>`For fitDataset(), config.epochs is expected to be a positive integer, but got ${n.epochs}`),I(!s||n.batchesPerEpoch>0&&Number.isInteger(n.batchesPerEpoch),()=>`For fitDataset(), config.batchesPerEpoch is expected to be a positive integer if specified, but got ${n.batchesPerEpoch}`),I(n.validationSplit==null,()=>"`validationSplit` is not supported by `fitDataset()`. Use validationData instead."),t.isTraining)throw new Error("Cannot start training because another fit() call is ongoing.");t.isTraining=!0;try{const r=n.validationData!=null;let o,i;if(r)if(rk(n.validationData))I(n.validationBatches==null||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 x=Q5(n.validationData);o=x.xs,i=x.ys}const a=t.makeTrainFunction(),l=t.getDedupedMetricsNames();let c;r?c=l.slice().concat(l.map(x=>"val_"+x)):c=l.slice();const u=LT(n.callbacks,n.yieldEvery),h=n.verbose==null?1:n.verbose,{callbackList:d,history:f}=BT(u,h,n.epochs,null,null,J5(e,n),null,r,c);d.setModel(t),t.history=f,await d.onTrainBegin(),t.stopTraining_=!1;let p=n.initialEpoch==null?0:n.initialEpoch,g=await e.iterator();for(;p=n.batchesPerEpoch:w.done){if(r){let v;rk(n.validationData)?v=Ke(await t.evaluateDataset(n.validationData,{batches:n.validationBatches})):v=Ke(t.evaluate(o,i,{batchSize:n.validationBatchSize==null?Y5:n.validationBatchSize,verbose:0}));for(let b=0;b0)throw new Ie("Verbose mode is not implemented yet.");I(!s||n.batches>0&&Number.isInteger(n.batches),()=>`Test loop expects \`batches\` to be a positive integer, but received ${JSON.stringify(n.batches)}`);const i=eH(e)?e:await e.iterator();let a=0,l=0;for(;!s||l{if(c.value){const{xs:u,ys:h}=YT(t,c.value),d=u.concat(h),f=P(()=>r(d));if($e(d),l===0)for(let g=0;gJ(o[g],D(p,x))),l>0&&$e(m)}$e(f),a+=p,++l}return o}),c.done){s&&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 c=0;c0&&Number.isInteger(t),()=>`batchSize is required to be a positive integer, but got ${t}`)}function jl(t,e,n){return t==null?[null]:Array.isArray(t)?t.map(s=>Ci(s,e,n-e)):Ci(t,e,n-e)}function k1(t,e){return P(()=>t==null?null:Array.isArray(t)?t.map(n=>k1(n,e)):ST(t,e.dtype==="int32"?e:le(e,"int32")))}function Rg(t,e){const n=[];let s=0,r=null;for(;s=t&&(r=t),n.push([s,r]),s=r;return n}function QT(t){const e=[];t instanceof zt&&(t=[t]);for(let n=0;nn.push(r.id));else if(e!=null)for(const r in e){const o=e[r];n.push(o.id)}const s=[];if(t instanceof zt)n.indexOf(t.id)===-1&&s.push(t);else if(Array.isArray(t))t.forEach(r=>{n.indexOf(r.id)===-1&&s.push(r)});else if(t!=null)for(const r in t){const o=t[r];n.indexOf(o.id)===-1&&s.push(o)}s.forEach(r=>{r.isDisposed||r.dispose()})}/** + */function Eg(t){I(t>0&&Number.isInteger(t),()=>`batchSize is required to be a positive integer, but got ${t}`)}function jl(t,e,n){return t==null?[null]:Array.isArray(t)?t.map(s=>Ci(s,e,n-e)):Ci(t,e,n-e)}function k1(t,e){return P(()=>t==null?null:Array.isArray(t)?t.map(n=>k1(n,e)):ST(t,e.dtype==="int32"?e:le(e,"int32")))}function Rg(t,e){const n=[];let s=0,r=null;for(;s=t&&(r=t),n.push([s,r]),s=r;return n}function QT(t){const e=[];t instanceof zt&&(t=[t]);for(let n=0;nn.push(r.id));else if(e!=null)for(const r in e){const o=e[r];n.push(o.id)}const s=[];if(t instanceof zt)n.indexOf(t.id)===-1&&s.push(t);else if(Array.isArray(t))t.forEach(r=>{n.indexOf(r.id)===-1&&s.push(r)});else if(t!=null)for(const r in t){const o=t[r];n.indexOf(o.id)===-1&&s.push(o)}s.forEach(r=>{r.isDisposed||r.dispose()})}/** * @license * Copyright 2018 Google LLC * @@ -7817,7 +7817,7 @@ body { * license that can be found in the LICENSE file or at * https://opensource.org/licenses/MIT. * ============================================================================= - */function sH(t){return t instanceof zt}function S1(t){return Array.isArray(t)}function ok(t){return!sH(t)&&!S1(t)}function ik(t,e,n,s=!0,r=""){if(e==null||e.length===0){if(t!=null){let i=!1;if(S1(t)&&t.length>0)i=!0;else if(ok(t)){for(const a in t)if(t.hasOwnProperty(a)){i=!0;break}}else i=!0;if(i)throw new E(`Error when checking model ${r} expected no data, but got ${t}`)}return[]}if(t==null)return e.map(i=>null);let o;if(ok(t)){t=t,o=[];for(const i of e){if(t[i]==null)throw new E(`No data provided for "${i}". Need data for each key in: ${e}`);o.push(t[i])}}else if(S1(t)){if(t=t,t.length!==e.length)throw new E(`Error when checking model ${r}: the Array of Tensors that you are passing to your model is not the size the model expected. Expected to see ${e.length} Tensor(s), but instead got the following list of Tensor(s): ${t}`);o=t}else{if(t=t,e.length>1)throw new E(`The model ${r} expects ${e.length} Tensor(s), but only received one Tensor. Found: Tensor with shape ${t.shape}`);o=[t]}if(o=QT(o),n!=null)for(let i=0;i=0&&c!==u)throw new E(`${r} expected a batch of elements where each example has shape [${n[i].slice(1,n[i].length)}] (i.e.,tensor shape [*,${n[i].slice(1,n[i].length)}]) but the ${r} received an input with ${a.shape[0]} examples, each with shape [${a.shape.slice(1,a.shape.length)}] (tensor shape [${a.shape}])`)}}return o}function rH(t,e,n){const s=To(t.map(o=>o.shape[0]));s.sort();const r=To(e.map(o=>o.shape[0]));if(r.sort(),s.length>1)throw new E(`All input Tensors (x) should have the same number of samples. Got array shapes: ${JSON.stringify(t.map(o=>o.shape))}`);if(r.length>1)throw new E(`All target Tensors (y) should have the same number of samples. Got array shapes: ${JSON.stringify(e.map(o=>o.shape))}`);if(s.length>0&&r.length>0&&!Ue(s,r))throw new E(`Input Tensors should have the same number of samples as target Tensors. Found ${s[0]} input sample(s) and ${r[0]} target sample(s).`)}function oH(t,e,n){const s=[Tm,Em,Qc];for(let r=0;r1)throw new E(`The model expects ${e.length} ${r} Tensors, but only received one Tensor. Found: array with shape ${JSON.stringify(t.shape)}.`);o=[t]}if(n!=null)for(let i=0;i[]);let n;if(typeof t=="string"||typeof t=="function")n=[t];else if(Array.isArray(t)||typeof t=="object")n=t;else throw new TypeError(`Type of metrics argument not understood. Expected an string,function, Array, or Object, found: ${t}`);if(Array.isArray(n))return e.map(s=>n);{const s=[];for(const r of e){let o=n.hasOwnProperty(r)?n[r]:[];Array.isArray(o)||(o=[o]),s.push(o)}return s}}const aH="layers-model";class La extends Ps{constructor(e){super(e),this.isTraining=!1}summary(e,n,s=console.log){if(!this.built)throw new E("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).");U5(this,e,n,s)}compile(e){if(e.loss==null&&(e.loss=[]),this.loss=e.loss,typeof e.optimizer=="string")this.optimizer_=W5(e.optimizer),this.isOptimizerOwned=!0;else{if(!(e.optimizer instanceof Xo))throw new E("User-defined optimizer must be an instance of tf.Optimizer.");this.optimizer_=e.optimizer,this.isOptimizerOwned=!1}let n=[];if(!Array.isArray(e.loss)&&typeof e.loss!="string"&&typeof e.loss!="function"){e.loss=e.loss;for(const i in e.loss)if(this.outputNames.indexOf(i)===-1)throw new E(`Unknown entry in loss dictionary: "${i}". Only expected the following keys: ${this.outputNames}`);for(const i of this.outputNames)e.loss[i]==null&&console.warn(`Output "${i}" is missing from loss dictionary. We assume this was done on purpose, and we will not be expecting data to be passed to ${i} during training`),n.push(Tg(e.loss[i]))}else if(Array.isArray(e.loss)){if(e.loss.length!==this.outputs.length)throw new E(`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}.`);n=e.loss.map(a=>Tg(a))}else{const i=Tg(e.loss);this.outputs.forEach(a=>{n.push(i)})}this.lossFunctions=n,this.feedOutputNames=[],this.feedOutputShapes=[],this.feedLossFns=[];for(let i=0;i{for(let i=0;i1&&(this.metricsTensors.push([a,i]),this.metricsNames.push(this.outputNames[i]+"_loss"))}});const r=iH(e.metrics,this.outputNames),o=(i,a,l)=>{this.outputNames.length>1&&(a=this.outputNames[i]+"_"+a),this.metricsNames.push(a),this.metricsTensors.push([l,i])};bi("metric",()=>{for(let i=0;i{const u="";let h,d,f;for(const p of c){if(typeof p=="string"&&["accuracy","acc","crossentropy","ce"].indexOf(p)!==-1){const x=this.internalOutputShapes[i];x[x.length-1]===1||this.lossFunctions[i]===Em?["accuracy","acc"].indexOf(p)!==-1?d=WT:["crossentropy","ce"].indexOf(p)!==-1&&(d=D5):this.lossFunctions[i]===Ef?["accuracy","acc"].indexOf(p)!==-1?d=_5:["crossentropy","ce"].indexOf(p)!==-1&&(d=HT):["accuracy","acc"].indexOf(p)!==-1?d=UT:["crossentropy","ce"].indexOf(p)!==-1&&(d=GT);let m;["accuracy","acc"].indexOf(p)!==-1?m="acc":["crossentropy","ce"].indexOf(p)!==-1&&(m="ce"),f=d,h=u+m}else f=V5(p),h=u+sd(p);let g;bi(h,()=>{g=f}),o(i,h,g)}})(a)}}),this.collectedTrainableWeights=this.trainableWeights}checkTrainableWeightsConsistency(){this.collectedTrainableWeights!=null&&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,n,s={}){const r=s.batchSize==null?32:s.batchSize;Eg(r);const i=this.standardizeUserDataXY(e,n,!0,r);try{const a=i[0].concat(i[1]);this.makeTestFunction();const l=this.testFunction,c=this.testLoop(l,a,r,s.verbose,s.steps);return Rn(c)}finally{Ms(i[0],e),Ms(i[1],n)}}async evaluateDataset(e,n){return this.makeTestFunction(),nH(this,e,n)}checkNumSamples(e,n,s,r="steps"){let o;if(s!=null){if(o=null,n!=null)throw new E(`If ${r} is set, batchSize must be null or undefined.Got batchSize = ${n}`)}else if(e!=null)Array.isArray(e)?o=e[0].shape[0]:o=e.shape[0];else throw new E(`Either the input data should have a defined shape, or ${r} shoud be specified.`);return o}execute(e,n){if(Array.isArray(n)&&n.length===0)throw new E("`outputs` is an empty Array, which is not allowed.");const s=Array.isArray(n),r=s?n:[n],o=this.retrieveSymbolicTensors(r),i=new fo;if(e instanceof zt&&(e=[e]),Array.isArray(e)){if(e.length!==this.inputs.length)throw new E(`The number of inputs provided (${e.length}) does not match the number of inputs of this model (${this.inputs.length}).`);for(let l=0;la.name);for(let a=0;a0){const r=[];throw n.forEach((o,i)=>{o==null&&r.push(e[i])}),new E(`Cannot find SymbolicTensors for output name(s): ${JSON.stringify(r)}`)}return n}predictLoop(e,n=32,s=!1){return P(()=>{const r=this.checkNumSamples(e);if(s)throw new Ie("Verbose predictLoop() is not implemented yet.");const o=Rg(r,n),i=this.outputs.map(a=>[]);for(let a=0;a{const c=o[a][0],u=o[a][1],h=jl(e,c,u),d=[];if(Array.isArray(h))for(let p=0;pi[u].push(c));return Rn(i.map(a=>Dn(a,0)))})}predict(e,n={}){const s=QT(e);ak(s,this.inputNames,this.feedInputShapes,!1);try{const r=n.batchSize==null?32:n.batchSize;return Eg(r),this.predictLoop(s,r)}finally{Ms(s,e)}}predictOnBatch(e){ak(e,this.inputNames,this.feedInputShapes,!0);const n=(Array.isArray(e)?e[0]:e).shape[0];return this.predictLoop(e,n)}standardizeUserDataXY(e,n,s=!0,r){if(this.optimizer_==null)throw new ks("You must compile a model before training/testing. Use LayersModel.compile(modelCompileArgs).");const o=[];for(let i=0;i0&&e[0].shape[0]%r!==0)throw new E(`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,n]}async standardizeUserData(e,n,s,r,o=!0,i){const[a,l]=this.standardizeUserDataXY(e,n,o,i);if(s!=null)throw new Error("sample weight is not supported yet.");let c=null;if(r!=null){const u=XT(r,this.outputNames);c=[];for(let h=0;h{const i=this.checkNumSamples(n,s,o,"steps"),a=[];if(r>0)throw new Ie("Verbose mode is not implemented yet.");if(o!=null)throw new Ie("steps mode in testLoop() is not implemented yet");{const l=Rg(i,s),c=Gn(Js(0,i));for(let u=0;u1){const i=HC(e.slice(0,s),r);o+=`_${i}`}n.push(o)}return n}makeTrainFunction(){return e=>{const n=[],s=e.slice(0,this.inputs.length),r=e.slice(this.inputs.length,this.inputs.length+this.outputs.length),o=e.slice(this.inputs.length+this.outputs.length,this.inputs.length+this.outputs.length*2),i=[],a=()=>{const h=[];for(let g=0;g1&&g{p=J(p,g)}),p},l=this.collectedTrainableWeights.map(h=>h.read());return[this.optimizer_.minimize(a,!0,l)].concat(i)}}makeTestFunction(){this.testFunction=e=>P(()=>{const n=[];let s;const r=e.slice(0,this.inputs.length),o=e.slice(this.inputs.length,this.inputs.length+this.outputs.length),i=[];for(let c=0;c0){if(x=!0,s.validationData.length===2)l=s.validationData[0],c=s.validationData[1];else throw s.validationData.length===3?new Ie("validationData including sample weights is not supported yet."):new E(`When passing validation data, it must contain 2 (valX, valY) or 3 (valX, valY, valSampleWeight) items; ${s.validationData} is invalid.`);const N=await this.standardizeUserData(l,c,null,null,!0,f);u=N[0],h=N[1],m=u.concat(h)}else if(s.validationSplit!=null&&s.validationSplit>0&&s.validationSplit<1){x=!0;const $=Math.floor(r[0].shape[0]*(1-s.validationSplit)),N=r[0].shape[0];u=jl(r,$,N),i=r,r=jl(r,0,$),h=jl(o,$,N),a=o,o=jl(o,0,$),m=u.concat(h)}else s.validationSteps!=null&&(x=!0);const y=r.concat(o).concat(d);this.checkTrainableWeightsConsistency();const w=this.makeTrainFunction(),v=this.getDedupedMetricsNames();let b,C;x?(this.makeTestFunction(),b=this.testFunction,C=v.slice().concat(v.map($=>"val_"+$))):(b=null,m=[],C=v.slice());const k=LT(s.callbacks,s.yieldEvery);return await this.fitLoop(w,y,v,f,s.epochs,s.verbose,k,b,m,s.shuffle,C,s.initialEpoch,null,null)}finally{this.isTraining=!1,Ms(r,e),Ms(o,n),Ms(i,e),Ms(a,n),Ms(u,l),Ms(h,c),d!=null&&$e(d)}}async fitLoop(e,n,s,r,o,i,a,l,c,u,h,d,f,p){r==null&&(r=32),o==null&&(o=1),u==null&&(u=!0),d==null&&(d=0);let g=!1;if(l!=null&&c!=null&&(g=!0),p!=null&&(g=!0,f==null))throw new E("Can only use `validationSteps` when doing step-wise training, i.e., `stepsPerEpoch` must be set.");const x=this.checkNumSamples(n,r,f,"steps_per_epoch");let m;x!=null&&(m=Js(0,x)),i==null&&(i=1);const{callbackList:y,history:w}=BT(a,i,o,d,x,f,r,g,h);y.setModel(this),this.history=w,await y.onTrainBegin(),this.stopTraining_=!1;for(let v=d;v{const N=k[S][0],A=k[S][1],M=Ci(C,N,A-N);$.batch=S,$.size=A-N;const L=k1(n,M),V=e(L);for(let B=0;B_r(n))}else{const n=Object.keys(this.loss);e={};const s=this.loss;for(const r of n)if(typeof s[r]=="string")e[r]=_r(s[r]);else throw new Error("Serialization of non-string loss is not supported.")}return e}getMetricIdentifiers(){if(typeof this.metrics=="string"||typeof this.metrics=="function")return[_r(sd(this.metrics))];if(Array.isArray(this.metrics))return this.metrics.map(e=>_r(sd(e)));{const e={};for(const n in this.metrics)e[n]=_r(sd(this.metrics[n]));return e}}getTrainingConfig(){return{loss:this.getLossIdentifiers(),metrics:this.getMetricIdentifiers(),optimizer_config:{class_name:this.optimizer.getClassName(),config:this.optimizer.getConfig()}}}loadTrainingConfig(e){if(e.weighted_metrics!=null)throw new Error("Loading weight_metrics is not supported yet.");if(e.loss_weights!=null)throw new Error("Loading loss_weights is not supported yet.");if(e.sample_weight_mode!=null)throw new Error("Loading sample_weight_mode is not supported yet.");const n=_f(e.optimizer_config),s=Cr(n);let r;if(typeof e.loss=="string")r=ii(e.loss);else if(Array.isArray(e.loss))r=e.loss.map(i=>ii(i));else if(e.loss!=null){r={};for(const i in e.loss)r[i]=ii(e.loss[i])}let o;if(Array.isArray(e.metrics))o=e.metrics.map(i=>ii(i));else if(e.metrics!=null){o={};for(const i in e.metrics)o[i]=ii(e.metrics[i])}this.compile({loss:r,metrics:o,optimizer:s})}async save(e,n){if(typeof e=="string"){const c=_P(e);if(c.length===0)throw new E(`Cannot find any save handlers for URL '${e}'`);if(c.length>1)throw new E(`Found more than one (${c.length}) save handlers for URL '${e}'`);e=c[0]}if(e.save==null)throw new E("LayersModel.save() cannot proceed because the IOHandler provided does not have the `save` attribute defined.");const s=await $C(this.getNamedWeights(n)),a={modelTopology:this.toJSON(null,!1),format:aH,generatedBy:`TensorFlow.js tfjs-layers v${KT}`,convertedBy:null};if((n==null?!1:n.includeOptimizer)&&this.optimizer!=null){a.trainingConfig=this.getTrainingConfig();const c="optimizer",{data:u,specs:h}=await $C(await this.optimizer.getWeights(),c);s.specs.push(...h),s.data=IP([s.data,u])}return this.userDefinedMetadata!=null&&(nk(this.userDefinedMetadata,this.name,!0),a.userDefinedMetadata=this.userDefinedMetadata),a.weightData=s.data,a.weightSpecs=s.specs,e.save(a)}setUserDefinedMetadata(e){nk(e,this.name),this.userDefinedMetadata=e}getUserDefinedMetadata(){return this.userDefinedMetadata}}La.className="Model";Y(La);class ZT extends La{}ZT.className="Functional";Y(ZT);/** + */function nH(t){return t instanceof zt}function S1(t){return Array.isArray(t)}function ok(t){return!nH(t)&&!S1(t)}function ik(t,e,n,s=!0,r=""){if(e==null||e.length===0){if(t!=null){let i=!1;if(S1(t)&&t.length>0)i=!0;else if(ok(t)){for(const a in t)if(t.hasOwnProperty(a)){i=!0;break}}else i=!0;if(i)throw new E(`Error when checking model ${r} expected no data, but got ${t}`)}return[]}if(t==null)return e.map(i=>null);let o;if(ok(t)){t=t,o=[];for(const i of e){if(t[i]==null)throw new E(`No data provided for "${i}". Need data for each key in: ${e}`);o.push(t[i])}}else if(S1(t)){if(t=t,t.length!==e.length)throw new E(`Error when checking model ${r}: the Array of Tensors that you are passing to your model is not the size the model expected. Expected to see ${e.length} Tensor(s), but instead got the following list of Tensor(s): ${t}`);o=t}else{if(t=t,e.length>1)throw new E(`The model ${r} expects ${e.length} Tensor(s), but only received one Tensor. Found: Tensor with shape ${t.shape}`);o=[t]}if(o=QT(o),n!=null)for(let i=0;i=0&&c!==u)throw new E(`${r} expected a batch of elements where each example has shape [${n[i].slice(1,n[i].length)}] (i.e.,tensor shape [*,${n[i].slice(1,n[i].length)}]) but the ${r} received an input with ${a.shape[0]} examples, each with shape [${a.shape.slice(1,a.shape.length)}] (tensor shape [${a.shape}])`)}}return o}function sH(t,e,n){const s=To(t.map(o=>o.shape[0]));s.sort();const r=To(e.map(o=>o.shape[0]));if(r.sort(),s.length>1)throw new E(`All input Tensors (x) should have the same number of samples. Got array shapes: ${JSON.stringify(t.map(o=>o.shape))}`);if(r.length>1)throw new E(`All target Tensors (y) should have the same number of samples. Got array shapes: ${JSON.stringify(e.map(o=>o.shape))}`);if(s.length>0&&r.length>0&&!Ue(s,r))throw new E(`Input Tensors should have the same number of samples as target Tensors. Found ${s[0]} input sample(s) and ${r[0]} target sample(s).`)}function rH(t,e,n){const s=[Tm,Em,Qc];for(let r=0;r1)throw new E(`The model expects ${e.length} ${r} Tensors, but only received one Tensor. Found: array with shape ${JSON.stringify(t.shape)}.`);o=[t]}if(n!=null)for(let i=0;i[]);let n;if(typeof t=="string"||typeof t=="function")n=[t];else if(Array.isArray(t)||typeof t=="object")n=t;else throw new TypeError(`Type of metrics argument not understood. Expected an string,function, Array, or Object, found: ${t}`);if(Array.isArray(n))return e.map(s=>n);{const s=[];for(const r of e){let o=n.hasOwnProperty(r)?n[r]:[];Array.isArray(o)||(o=[o]),s.push(o)}return s}}const iH="layers-model";class La extends Ps{constructor(e){super(e),this.isTraining=!1}summary(e,n,s=console.log){if(!this.built)throw new E("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).");W5(this,e,n,s)}compile(e){if(e.loss==null&&(e.loss=[]),this.loss=e.loss,typeof e.optimizer=="string")this.optimizer_=V5(e.optimizer),this.isOptimizerOwned=!0;else{if(!(e.optimizer instanceof Xo))throw new E("User-defined optimizer must be an instance of tf.Optimizer.");this.optimizer_=e.optimizer,this.isOptimizerOwned=!1}let n=[];if(!Array.isArray(e.loss)&&typeof e.loss!="string"&&typeof e.loss!="function"){e.loss=e.loss;for(const i in e.loss)if(this.outputNames.indexOf(i)===-1)throw new E(`Unknown entry in loss dictionary: "${i}". Only expected the following keys: ${this.outputNames}`);for(const i of this.outputNames)e.loss[i]==null&&console.warn(`Output "${i}" is missing from loss dictionary. We assume this was done on purpose, and we will not be expecting data to be passed to ${i} during training`),n.push(Tg(e.loss[i]))}else if(Array.isArray(e.loss)){if(e.loss.length!==this.outputs.length)throw new E(`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}.`);n=e.loss.map(a=>Tg(a))}else{const i=Tg(e.loss);this.outputs.forEach(a=>{n.push(i)})}this.lossFunctions=n,this.feedOutputNames=[],this.feedOutputShapes=[],this.feedLossFns=[];for(let i=0;i{for(let i=0;i1&&(this.metricsTensors.push([a,i]),this.metricsNames.push(this.outputNames[i]+"_loss"))}});const r=oH(e.metrics,this.outputNames),o=(i,a,l)=>{this.outputNames.length>1&&(a=this.outputNames[i]+"_"+a),this.metricsNames.push(a),this.metricsTensors.push([l,i])};bi("metric",()=>{for(let i=0;i{const u="";let h,d,f;for(const p of c){if(typeof p=="string"&&["accuracy","acc","crossentropy","ce"].indexOf(p)!==-1){const x=this.internalOutputShapes[i];x[x.length-1]===1||this.lossFunctions[i]===Em?["accuracy","acc"].indexOf(p)!==-1?d=WT:["crossentropy","ce"].indexOf(p)!==-1&&(d=A5):this.lossFunctions[i]===Tf?["accuracy","acc"].indexOf(p)!==-1?d=D5:["crossentropy","ce"].indexOf(p)!==-1&&(d=HT):["accuracy","acc"].indexOf(p)!==-1?d=UT:["crossentropy","ce"].indexOf(p)!==-1&&(d=GT);let m;["accuracy","acc"].indexOf(p)!==-1?m="acc":["crossentropy","ce"].indexOf(p)!==-1&&(m="ce"),f=d,h=u+m}else f=B5(p),h=u+nd(p);let g;bi(h,()=>{g=f}),o(i,h,g)}})(a)}}),this.collectedTrainableWeights=this.trainableWeights}checkTrainableWeightsConsistency(){this.collectedTrainableWeights!=null&&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,n,s={}){const r=s.batchSize==null?32:s.batchSize;Eg(r);const i=this.standardizeUserDataXY(e,n,!0,r);try{const a=i[0].concat(i[1]);this.makeTestFunction();const l=this.testFunction,c=this.testLoop(l,a,r,s.verbose,s.steps);return Rn(c)}finally{Ms(i[0],e),Ms(i[1],n)}}async evaluateDataset(e,n){return this.makeTestFunction(),tH(this,e,n)}checkNumSamples(e,n,s,r="steps"){let o;if(s!=null){if(o=null,n!=null)throw new E(`If ${r} is set, batchSize must be null or undefined.Got batchSize = ${n}`)}else if(e!=null)Array.isArray(e)?o=e[0].shape[0]:o=e.shape[0];else throw new E(`Either the input data should have a defined shape, or ${r} shoud be specified.`);return o}execute(e,n){if(Array.isArray(n)&&n.length===0)throw new E("`outputs` is an empty Array, which is not allowed.");const s=Array.isArray(n),r=s?n:[n],o=this.retrieveSymbolicTensors(r),i=new fo;if(e instanceof zt&&(e=[e]),Array.isArray(e)){if(e.length!==this.inputs.length)throw new E(`The number of inputs provided (${e.length}) does not match the number of inputs of this model (${this.inputs.length}).`);for(let l=0;la.name);for(let a=0;a0){const r=[];throw n.forEach((o,i)=>{o==null&&r.push(e[i])}),new E(`Cannot find SymbolicTensors for output name(s): ${JSON.stringify(r)}`)}return n}predictLoop(e,n=32,s=!1){return P(()=>{const r=this.checkNumSamples(e);if(s)throw new Ie("Verbose predictLoop() is not implemented yet.");const o=Rg(r,n),i=this.outputs.map(a=>[]);for(let a=0;a{const c=o[a][0],u=o[a][1],h=jl(e,c,u),d=[];if(Array.isArray(h))for(let p=0;pi[u].push(c));return Rn(i.map(a=>Dn(a,0)))})}predict(e,n={}){const s=QT(e);ak(s,this.inputNames,this.feedInputShapes,!1);try{const r=n.batchSize==null?32:n.batchSize;return Eg(r),this.predictLoop(s,r)}finally{Ms(s,e)}}predictOnBatch(e){ak(e,this.inputNames,this.feedInputShapes,!0);const n=(Array.isArray(e)?e[0]:e).shape[0];return this.predictLoop(e,n)}standardizeUserDataXY(e,n,s=!0,r){if(this.optimizer_==null)throw new ks("You must compile a model before training/testing. Use LayersModel.compile(modelCompileArgs).");const o=[];for(let i=0;i0&&e[0].shape[0]%r!==0)throw new E(`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,n]}async standardizeUserData(e,n,s,r,o=!0,i){const[a,l]=this.standardizeUserDataXY(e,n,o,i);if(s!=null)throw new Error("sample weight is not supported yet.");let c=null;if(r!=null){const u=XT(r,this.outputNames);c=[];for(let h=0;h{const i=this.checkNumSamples(n,s,o,"steps"),a=[];if(r>0)throw new Ie("Verbose mode is not implemented yet.");if(o!=null)throw new Ie("steps mode in testLoop() is not implemented yet");{const l=Rg(i,s),c=Gn(Js(0,i));for(let u=0;u1){const i=HC(e.slice(0,s),r);o+=`_${i}`}n.push(o)}return n}makeTrainFunction(){return e=>{const n=[],s=e.slice(0,this.inputs.length),r=e.slice(this.inputs.length,this.inputs.length+this.outputs.length),o=e.slice(this.inputs.length+this.outputs.length,this.inputs.length+this.outputs.length*2),i=[],a=()=>{const h=[];for(let g=0;g1&&g{p=J(p,g)}),p},l=this.collectedTrainableWeights.map(h=>h.read());return[this.optimizer_.minimize(a,!0,l)].concat(i)}}makeTestFunction(){this.testFunction=e=>P(()=>{const n=[];let s;const r=e.slice(0,this.inputs.length),o=e.slice(this.inputs.length,this.inputs.length+this.outputs.length),i=[];for(let c=0;c0){if(x=!0,s.validationData.length===2)l=s.validationData[0],c=s.validationData[1];else throw s.validationData.length===3?new Ie("validationData including sample weights is not supported yet."):new E(`When passing validation data, it must contain 2 (valX, valY) or 3 (valX, valY, valSampleWeight) items; ${s.validationData} is invalid.`);const N=await this.standardizeUserData(l,c,null,null,!0,f);u=N[0],h=N[1],m=u.concat(h)}else if(s.validationSplit!=null&&s.validationSplit>0&&s.validationSplit<1){x=!0;const $=Math.floor(r[0].shape[0]*(1-s.validationSplit)),N=r[0].shape[0];u=jl(r,$,N),i=r,r=jl(r,0,$),h=jl(o,$,N),a=o,o=jl(o,0,$),m=u.concat(h)}else s.validationSteps!=null&&(x=!0);const y=r.concat(o).concat(d);this.checkTrainableWeightsConsistency();const w=this.makeTrainFunction(),v=this.getDedupedMetricsNames();let b,C;x?(this.makeTestFunction(),b=this.testFunction,C=v.slice().concat(v.map($=>"val_"+$))):(b=null,m=[],C=v.slice());const k=LT(s.callbacks,s.yieldEvery);return await this.fitLoop(w,y,v,f,s.epochs,s.verbose,k,b,m,s.shuffle,C,s.initialEpoch,null,null)}finally{this.isTraining=!1,Ms(r,e),Ms(o,n),Ms(i,e),Ms(a,n),Ms(u,l),Ms(h,c),d!=null&&$e(d)}}async fitLoop(e,n,s,r,o,i,a,l,c,u,h,d,f,p){r==null&&(r=32),o==null&&(o=1),u==null&&(u=!0),d==null&&(d=0);let g=!1;if(l!=null&&c!=null&&(g=!0),p!=null&&(g=!0,f==null))throw new E("Can only use `validationSteps` when doing step-wise training, i.e., `stepsPerEpoch` must be set.");const x=this.checkNumSamples(n,r,f,"steps_per_epoch");let m;x!=null&&(m=Js(0,x)),i==null&&(i=1);const{callbackList:y,history:w}=BT(a,i,o,d,x,f,r,g,h);y.setModel(this),this.history=w,await y.onTrainBegin(),this.stopTraining_=!1;for(let v=d;v{const N=k[S][0],A=k[S][1],M=Ci(C,N,A-N);$.batch=S,$.size=A-N;const L=k1(n,M),V=e(L);for(let B=0;B_r(n))}else{const n=Object.keys(this.loss);e={};const s=this.loss;for(const r of n)if(typeof s[r]=="string")e[r]=_r(s[r]);else throw new Error("Serialization of non-string loss is not supported.")}return e}getMetricIdentifiers(){if(typeof this.metrics=="string"||typeof this.metrics=="function")return[_r(nd(this.metrics))];if(Array.isArray(this.metrics))return this.metrics.map(e=>_r(nd(e)));{const e={};for(const n in this.metrics)e[n]=_r(nd(this.metrics[n]));return e}}getTrainingConfig(){return{loss:this.getLossIdentifiers(),metrics:this.getMetricIdentifiers(),optimizer_config:{class_name:this.optimizer.getClassName(),config:this.optimizer.getConfig()}}}loadTrainingConfig(e){if(e.weighted_metrics!=null)throw new Error("Loading weight_metrics is not supported yet.");if(e.loss_weights!=null)throw new Error("Loading loss_weights is not supported yet.");if(e.sample_weight_mode!=null)throw new Error("Loading sample_weight_mode is not supported yet.");const n=Df(e.optimizer_config),s=Cr(n);let r;if(typeof e.loss=="string")r=ii(e.loss);else if(Array.isArray(e.loss))r=e.loss.map(i=>ii(i));else if(e.loss!=null){r={};for(const i in e.loss)r[i]=ii(e.loss[i])}let o;if(Array.isArray(e.metrics))o=e.metrics.map(i=>ii(i));else if(e.metrics!=null){o={};for(const i in e.metrics)o[i]=ii(e.metrics[i])}this.compile({loss:r,metrics:o,optimizer:s})}async save(e,n){if(typeof e=="string"){const c=DP(e);if(c.length===0)throw new E(`Cannot find any save handlers for URL '${e}'`);if(c.length>1)throw new E(`Found more than one (${c.length}) save handlers for URL '${e}'`);e=c[0]}if(e.save==null)throw new E("LayersModel.save() cannot proceed because the IOHandler provided does not have the `save` attribute defined.");const s=await $C(this.getNamedWeights(n)),a={modelTopology:this.toJSON(null,!1),format:iH,generatedBy:`TensorFlow.js tfjs-layers v${KT}`,convertedBy:null};if((n==null?!1:n.includeOptimizer)&&this.optimizer!=null){a.trainingConfig=this.getTrainingConfig();const c="optimizer",{data:u,specs:h}=await $C(await this.optimizer.getWeights(),c);s.specs.push(...h),s.data=SP([s.data,u])}return this.userDefinedMetadata!=null&&(nk(this.userDefinedMetadata,this.name,!0),a.userDefinedMetadata=this.userDefinedMetadata),a.weightData=s.data,a.weightSpecs=s.specs,e.save(a)}setUserDefinedMetadata(e){nk(e,this.name),this.userDefinedMetadata=e}getUserDefinedMetadata(){return this.userDefinedMetadata}}La.className="Model";Y(La);class ZT extends La{}ZT.className="Functional";Y(ZT);/** * @license * Copyright 2018 Google LLC * @@ -7825,7 +7825,7 @@ body { * license that can be found in the LICENSE file or at * https://opensource.org/licenses/MIT. * ============================================================================= - */async function lH(t,e){if(e==null&&(e={}),typeof t=="string"){const n=FP(t,e);if(n.length===0)n.push(mU(t,e));else if(n.length>1)throw new E(`Found more than one (${n.length}) load handlers for URL '${t}'`);t=n[0]}return cH(t,void 0,e)}async function cH(t,e,n){if(n==null&&(n={}),t.load==null)throw new E("Cannot proceed with model loading because the IOHandler provided does not have the `load` method implemented.");const s=await t.load();let r=s.modelTopology;r.model_config!=null&&(r=r.model_config);const o=n.strict==null?!0:n.strict,i=s.weightData!=null&&s.weightSpecs!=null&&o,a=Cr(_f(r),e,i),l=s.trainingConfig;if(l!=null&&a.loadTrainingConfig(l),s.userDefinedMetadata!=null&&a.setUserDefinedMetadata(s.userDefinedMetadata),s.weightData!=null){if(s.weightSpecs==null)throw new E("LayersModel artifacts contains weight data, but not weight specs. Therefore loading of weights cannot proceed.");const{modelWeights:c,optimizerWeights:u}=uH(s.weightData,s.weightSpecs);a.loadWeights(c,o),a.optimizer!=null&&u.length>0&&await a.optimizer.setWeights(u),$e(c),$e(u.map(h=>h.tensor))}return a}function uH(t,e){const n=wP(t,e),s={},r=[];return e.forEach(o=>{o.group==="optimizer"?r.push({name:o.name,tensor:n[o.name]}):s[o.name]=n[o.name]}),{modelWeights:s,optimizerWeights:r}}class Zc extends La{constructor(e){if(super({inputs:[],outputs:[]}),e=e||{},this.trainable=!0,this.built=!1,this.name=e.name!=null?e.name:Im("sequential_"),e.layers!=null)for(const n of e.layers)this.add(n)}checkShape(e){if(e.inboundNodes[0].outputTensors[0].shape.some(s=>s<0))throw new E(`Negative dimension size caused by adding layer ${e.name} with input shape [${e.inboundNodes[0].inputTensors[0].shape}]`)}add(e){const n=e instanceof Zc||e instanceof La;let s;if(n){if(s=e,s.outputs.length!==1)throw new E("All layers in a Sequential model should have a single output tensor. For multi-output layers, use the functional API.");if(s.inputs.length!==1)throw new E("All layers in a Sequential model should have a single input tensor. For multi-input layers, use the functional API.")}if(this.outputs.length===0){if(e.inboundNodes.length===0){if(e.batchInputShape==null)throw new E("The first layer in a Sequential model must get an `inputShape` or `batchInputShape` argument.");const r=c5({batchShape:e.batchInputShape,dtype:e.dtype,name:e.name+"_input"});e.apply(r)}if(n)this.outputs=s.outputs,this.inputs=s.inputs;else{if(e.inboundNodes.length!==1)throw new E(`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(e.inboundNodes[0].outputTensors.length!==1)throw new E("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=_T(this.outputs[0])}this.inboundNodes=[],new Nm({outboundLayer:this,inboundLayers:[],nodeIndices:[],tensorIndices:[],inputTensors:this.inputs,outputTensors:this.outputs,inputMasks:Li(null,this.inputs.length),outputMasks:[null],inputShapes:this.inputs.map(r=>r.shape),outputShapes:this.outputs[0].shape})}else{const r=e.apply(this.outputs[0]);if(Array.isArray(r))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=[r],this.inboundNodes[0].outputTensors=this.outputs,this.inboundNodes[0].outputShapes=[this.outputs[0].shape]}this.layers.push(e),this.built=!1}pop(){if(this.layers.length===0)throw new TypeError("There are no layers in the model.");if(this.layers.pop(),this.layers.length===0)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,n){return this.model==null&&this.build(),this.model.call(e,n)}build(e){if(Pe(e),this.inputs.length===0||this.outputs.length===0)throw new TypeError("Sequential model cannot be built: model is empty. Add some layers first.");this.model=new La({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,n,s=console.log){this.built||this.build(),super.summary(e,n,s)}setWeights(e){this.model==null&&this.build(),this.model.setWeights(e)}evaluate(e,n,s={}){if(!this.built)throw new ks("The model needs to be compiled before being used.");return this.model.evaluate(e,n,s)}async evaluateDataset(e,n){if(!this.built)throw new ks("The model needs to be compiled before being used.");return this.model.evaluateDataset(e,n)}predict(e,n={}){return this.model==null&&this.build(),this.model.predict(e,n)}predictOnBatch(e){return this.model==null&&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 this.model==null?void 0:this.model.optimizer}set optimizer(e){this.model.optimizer=e}async fit(e,n,s={}){if(!this.built)throw new ks("The model needs to be compiled before being used.");return this.model.fit(e,n,s)}async fitDataset(e,n){if(!this.built)throw new ks("The model needs to be compiled before being used.");return this.model.fitDataset(e,n)}async trainOnBatch(e,n){return this.model.trainOnBatch(e,n)}static fromConfig(e,n,s={},r=!1){let o,i={};if(n instanceof Array){if(n[0].className==null||n[0].className==="Merge")throw new E("Legacy serialization format not supported yet.");o=n}else I(n.layers!=null,()=>"When the config data for a Sequential model is not an Array, it must be an Object that contains the 'layers' field."),o=n.layers,delete n.layers,i=n;const a=new e(i);if(!(a instanceof Zc))throw new Ie(`Sequential.fromConfig called on non-Sequential input: ${a}`);for(const l of o){const u=Cr(l,void 0,r);r&&u.setFastWeightInitDuringBuild(!0),a.add(u)}return a}set stopTraining(e){if(this.model==null)throw new E("Cannot set the stopTraining property of a sequential model before it is compiled.");this.model.stopTraining=e}get stopTraining(){if(this.model==null)throw new E("Cannot get the stopTraining property of a sequential model before it is compiled.");return this.model.stopTraining}getConfig(){const e=[];for(const n of this.layers){const s={};s.className=n.getClassName(),s.config=n.getConfig(),e.push(s)}return{name:this.name,layers:e}}}Zc.className="Sequential";Y(Zc);/** + */async function aH(t,e){if(e==null&&(e={}),typeof t=="string"){const n=_P(t,e);if(n.length===0)n.push(pU(t,e));else if(n.length>1)throw new E(`Found more than one (${n.length}) load handlers for URL '${t}'`);t=n[0]}return lH(t,void 0,e)}async function lH(t,e,n){if(n==null&&(n={}),t.load==null)throw new E("Cannot proceed with model loading because the IOHandler provided does not have the `load` method implemented.");const s=await t.load();let r=s.modelTopology;r.model_config!=null&&(r=r.model_config);const o=n.strict==null?!0:n.strict,i=s.weightData!=null&&s.weightSpecs!=null&&o,a=Cr(Df(r),e,i),l=s.trainingConfig;if(l!=null&&a.loadTrainingConfig(l),s.userDefinedMetadata!=null&&a.setUserDefinedMetadata(s.userDefinedMetadata),s.weightData!=null){if(s.weightSpecs==null)throw new E("LayersModel artifacts contains weight data, but not weight specs. Therefore loading of weights cannot proceed.");const{modelWeights:c,optimizerWeights:u}=cH(s.weightData,s.weightSpecs);a.loadWeights(c,o),a.optimizer!=null&&u.length>0&&await a.optimizer.setWeights(u),$e(c),$e(u.map(h=>h.tensor))}return a}function cH(t,e){const n=yP(t,e),s={},r=[];return e.forEach(o=>{o.group==="optimizer"?r.push({name:o.name,tensor:n[o.name]}):s[o.name]=n[o.name]}),{modelWeights:s,optimizerWeights:r}}class Zc extends La{constructor(e){if(super({inputs:[],outputs:[]}),e=e||{},this.trainable=!0,this.built=!1,this.name=e.name!=null?e.name:Im("sequential_"),e.layers!=null)for(const n of e.layers)this.add(n)}checkShape(e){if(e.inboundNodes[0].outputTensors[0].shape.some(s=>s<0))throw new E(`Negative dimension size caused by adding layer ${e.name} with input shape [${e.inboundNodes[0].inputTensors[0].shape}]`)}add(e){const n=e instanceof Zc||e instanceof La;let s;if(n){if(s=e,s.outputs.length!==1)throw new E("All layers in a Sequential model should have a single output tensor. For multi-output layers, use the functional API.");if(s.inputs.length!==1)throw new E("All layers in a Sequential model should have a single input tensor. For multi-input layers, use the functional API.")}if(this.outputs.length===0){if(e.inboundNodes.length===0){if(e.batchInputShape==null)throw new E("The first layer in a Sequential model must get an `inputShape` or `batchInputShape` argument.");const r=l5({batchShape:e.batchInputShape,dtype:e.dtype,name:e.name+"_input"});e.apply(r)}if(n)this.outputs=s.outputs,this.inputs=s.inputs;else{if(e.inboundNodes.length!==1)throw new E(`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(e.inboundNodes[0].outputTensors.length!==1)throw new E("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=_T(this.outputs[0])}this.inboundNodes=[],new Nm({outboundLayer:this,inboundLayers:[],nodeIndices:[],tensorIndices:[],inputTensors:this.inputs,outputTensors:this.outputs,inputMasks:Li(null,this.inputs.length),outputMasks:[null],inputShapes:this.inputs.map(r=>r.shape),outputShapes:this.outputs[0].shape})}else{const r=e.apply(this.outputs[0]);if(Array.isArray(r))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=[r],this.inboundNodes[0].outputTensors=this.outputs,this.inboundNodes[0].outputShapes=[this.outputs[0].shape]}this.layers.push(e),this.built=!1}pop(){if(this.layers.length===0)throw new TypeError("There are no layers in the model.");if(this.layers.pop(),this.layers.length===0)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,n){return this.model==null&&this.build(),this.model.call(e,n)}build(e){if(Pe(e),this.inputs.length===0||this.outputs.length===0)throw new TypeError("Sequential model cannot be built: model is empty. Add some layers first.");this.model=new La({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,n,s=console.log){this.built||this.build(),super.summary(e,n,s)}setWeights(e){this.model==null&&this.build(),this.model.setWeights(e)}evaluate(e,n,s={}){if(!this.built)throw new ks("The model needs to be compiled before being used.");return this.model.evaluate(e,n,s)}async evaluateDataset(e,n){if(!this.built)throw new ks("The model needs to be compiled before being used.");return this.model.evaluateDataset(e,n)}predict(e,n={}){return this.model==null&&this.build(),this.model.predict(e,n)}predictOnBatch(e){return this.model==null&&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 this.model==null?void 0:this.model.optimizer}set optimizer(e){this.model.optimizer=e}async fit(e,n,s={}){if(!this.built)throw new ks("The model needs to be compiled before being used.");return this.model.fit(e,n,s)}async fitDataset(e,n){if(!this.built)throw new ks("The model needs to be compiled before being used.");return this.model.fitDataset(e,n)}async trainOnBatch(e,n){return this.model.trainOnBatch(e,n)}static fromConfig(e,n,s={},r=!1){let o,i={};if(n instanceof Array){if(n[0].className==null||n[0].className==="Merge")throw new E("Legacy serialization format not supported yet.");o=n}else I(n.layers!=null,()=>"When the config data for a Sequential model is not an Array, it must be an Object that contains the 'layers' field."),o=n.layers,delete n.layers,i=n;const a=new e(i);if(!(a instanceof Zc))throw new Ie(`Sequential.fromConfig called on non-Sequential input: ${a}`);for(const l of o){const u=Cr(l,void 0,r);r&&u.setFastWeightInitDuringBuild(!0),a.add(u)}return a}set stopTraining(e){if(this.model==null)throw new E("Cannot set the stopTraining property of a sequential model before it is compiled.");this.model.stopTraining=e}get stopTraining(){if(this.model==null)throw new E("Cannot get the stopTraining property of a sequential model before it is compiled.");return this.model.stopTraining}getConfig(){const e=[];for(const n of this.layers){const s={};s.className=n.getClassName(),s.config=n.getConfig(),e.push(s)}return{name:this.name,layers:e}}}Zc.className="Sequential";Y(Zc);/** * @license * Copyright 2018 Google LLC * @@ -7833,7 +7833,7 @@ body { * license that can be found in the LICENSE file or at * https://opensource.org/licenses/MIT. * ============================================================================= - */let fn=class extends Il{getConfig(){return{}}};class JT extends fn{apply(e,n=1){return K6(e,n)}}JT.className="elu";Y(JT);class eE extends fn{apply(e){return mN(e)}}eE.className="selu";Y(eE);class tE extends fn{apply(e){return Yi(e)}}tE.className="relu";Y(tE);class nE extends fn{apply(e){return P(()=>Xc(6,Yi(e)))}}nE.className="relu6";Y(nE);class sE extends fn{apply(e){return e}}sE.className="linear";Y(sE);class rE extends fn{apply(e){return Cl(e)}}rE.className="sigmoid";Y(rE);class oE extends fn{apply(e){return q6(e)}}oE.className="hardSigmoid";Y(oE);class iE extends fn{apply(e){return dh(e)}}iE.className="softplus";Y(iE);class aE extends fn{apply(e){return X6(e)}}aE.className="softsign";Y(aE);class lE extends fn{apply(e){return mm(e)}}lE.className="tanh";Y(lE);let rv=class extends fn{apply(e,n=-1){return iw(e,n)}};rv.className="softmax";Y(rv);class cE extends fn{apply(e,n=-1){return iN(e,n)}}cE.className="logSoftmax";Y(cE);class uE extends fn{apply(e){return P(()=>P(()=>{const n=Math.sqrt(2),s=D(.5,J(1,tN(ge(e,n))));return D(e,s)}))}}uE.className="gelu";Y(uE);class hE extends fn{apply(e){return P(()=>D(.5,D(e,J(1,mm(D(hn(ge(2,Math.PI)),J(e,D(.044715,Oi(e,3)))))))))}}hE.className="gelu_new";Y(hE);class dE extends fn{apply(e){return P(()=>D(e,mm(dh(e))))}}dE.className="mish";Y(dE);class fE extends fn{apply(e,n=1){return P(()=>D(Cl(D(e,n)),e))}}fE.className="swish";Y(fE);function Fo(t){return t.getClassName()}function Ag(t,e={}){return wh(t,xs.getMap().classNameMap,e,"activation")}function zo(t){if(t==null){const e={};return e.className="linear",e.config={},Ag(e)}if(typeof t=="string"){const e={};return e.className=t,e.config={},Ag(e)}else return t instanceof fn?t:Ag(t)}/** + */let fn=class extends Il{getConfig(){return{}}};class JT extends fn{apply(e,n=1){return j6(e,n)}}JT.className="elu";Y(JT);class eE extends fn{apply(e){return mN(e)}}eE.className="selu";Y(eE);class tE extends fn{apply(e){return Yi(e)}}tE.className="relu";Y(tE);class nE extends fn{apply(e){return P(()=>Xc(6,Yi(e)))}}nE.className="relu6";Y(nE);class sE extends fn{apply(e){return e}}sE.className="linear";Y(sE);class rE extends fn{apply(e){return Cl(e)}}rE.className="sigmoid";Y(rE);class oE extends fn{apply(e){return X6(e)}}oE.className="hardSigmoid";Y(oE);class iE extends fn{apply(e){return hh(e)}}iE.className="softplus";Y(iE);class aE extends fn{apply(e){return K6(e)}}aE.className="softsign";Y(aE);class lE extends fn{apply(e){return mm(e)}}lE.className="tanh";Y(lE);let rv=class extends fn{apply(e,n=-1){return iw(e,n)}};rv.className="softmax";Y(rv);class cE extends fn{apply(e,n=-1){return iN(e,n)}}cE.className="logSoftmax";Y(cE);class uE extends fn{apply(e){return P(()=>P(()=>{const n=Math.sqrt(2),s=D(.5,J(1,tN(ge(e,n))));return D(e,s)}))}}uE.className="gelu";Y(uE);class hE extends fn{apply(e){return P(()=>D(.5,D(e,J(1,mm(D(hn(ge(2,Math.PI)),J(e,D(.044715,Oi(e,3)))))))))}}hE.className="gelu_new";Y(hE);class dE extends fn{apply(e){return P(()=>D(e,mm(hh(e))))}}dE.className="mish";Y(dE);class fE extends fn{apply(e,n=1){return P(()=>D(Cl(D(e,n)),e))}}fE.className="swish";Y(fE);function Fo(t){return t.getClassName()}function Ag(t,e={}){return yh(t,xs.getMap().classNameMap,e,"activation")}function zo(t){if(t==null){const e={};return e.className="linear",e.config={},Ag(e)}if(typeof t=="string"){const e={};return e.className=t,e.config={},Ag(e)}else return t instanceof fn?t:Ag(t)}/** * @license * Copyright 2018 Google LLC * @@ -7841,7 +7841,7 @@ body { * license that can be found in the LICENSE file or at * https://opensource.org/licenses/MIT. * ============================================================================= - */function hH(t){if(t!=null&&typeof t!="object")throw new Error(`Argument to L1L2 regularizer's constructor is expected to be an object, but received: ${t}`)}class pE extends Il{}class mE extends pE{constructor(e){super(),hH(e),this.l1=e==null||e.l1==null?.01:e.l1,this.l2=e==null||e.l2==null?.01:e.l2,this.hasL1=this.l1!==0,this.hasL2=this.l2!==0}apply(e){return P(()=>{let n=Kt([1]);return this.hasL1&&(n=J(n,me(D(this.l1,xn(e))))),this.hasL2&&(n=J(n,me(D(this.l2,bh(e))))),F(n,[])})}getConfig(){return{l1:this.l1,l2:this.l2}}static fromConfig(e,n){return new e({l1:n.l1,l2:n.l2})}}mE.className="L1L2";Y(mE);const lk={l1l2:"L1L2"};function Je(t){return Gw(t)}function ck(t,e={}){return wh(t,xs.getMap().classNameMap,e,"regularizer")}function pt(t){if(t==null)return null;if(typeof t=="string"){const n={className:t in lk?lk[t]:t,config:{}};return ck(n)}else return t instanceof pE?t:ck(t)}/** + */function uH(t){if(t!=null&&typeof t!="object")throw new Error(`Argument to L1L2 regularizer's constructor is expected to be an object, but received: ${t}`)}class pE extends Il{}class mE extends pE{constructor(e){super(),uH(e),this.l1=e==null||e.l1==null?.01:e.l1,this.l2=e==null||e.l2==null?.01:e.l2,this.hasL1=this.l1!==0,this.hasL2=this.l2!==0}apply(e){return P(()=>{let n=Kt([1]);return this.hasL1&&(n=J(n,me(D(this.l1,xn(e))))),this.hasL2&&(n=J(n,me(D(this.l2,vh(e))))),F(n,[])})}getConfig(){return{l1:this.l1,l2:this.l2}}static fromConfig(e,n){return new e({l1:n.l1,l2:n.l2})}}mE.className="L1L2";Y(mE);const lk={l1l2:"L1L2"};function Je(t){return Gw(t)}function ck(t,e={}){return yh(t,xs.getMap().classNameMap,e,"regularizer")}function pt(t){if(t==null)return null;if(typeof t=="string"){const n={className:t in lk?lk[t]:t,config:{}};return ck(n)}else return t instanceof pE?t:ck(t)}/** * @license * Copyright 2018 Google LLC * @@ -7857,7 +7857,7 @@ body { * license that can be found in the LICENSE file or at * https://opensource.org/licenses/MIT. * ============================================================================= - */function Ba(t,e,n){if(typeof t=="number")return Li(t,e);if(t.length!==e)throw new E(`The ${n} argument must be an integer or tuple of ${e} integers. Received: ${t.length} elements.`);for(let s=0;s(Nt(e),e==="channelsFirst"?Fe(t,[0,2,3,1]):t))}function CE(t,e){return P(()=>(Nt(e),e==="channelsFirst"?Fe(t,[0,2,3,4,1]):t))}function dH(t,e,n,s=1,r="valid",o,i=1){return P(()=>{if(o==null&&(o=er()),Nt(o),t.shape.length!==3)throw new E(`The input of a conv1dWithBias operation should be 3, but is ${t.shape.length} instead.`);if(e.shape.length!==3)throw new E(`The kernel for a conv1dWithBias operation should be 3, but is ${e.shape.length} instead`);if(n!=null&&n.shape.length!==1)throw new E(`The bias for a conv1dWithBias operation should be 1, but is ${n.shape.length} instead`);if(o==="channelsFirst"&&(t=Fe(t,[0,2,1])),r==="causal")throw new Ie("The support for CAUSAL padding mode in conv1dWithBias is not implemented yet.");let a=Y$(t,e,s,r==="same"?"same":"valid","NWC",i);return n!=null&&(a=sr(a,n)),a})}function uk(t,e,n,s=[1,1],r="valid",o,i,a=null){return P(()=>{if(o==null&&(o=er()),Nt(o),t.rank!==3&&t.rank!==4)throw new E(`conv2dWithBiasActivation expects input to be of rank 3 or 4, but received ${t.rank}.`);if(e.rank!==3&&e.rank!==4)throw new E(`conv2dWithBiasActivation expects kernel to be of rank 3 or 4, but received ${t.rank}.`);let l=ov(t,o);if(r==="causal")throw new Ie("The support for CAUSAL padding mode in conv1dWithBias is not implemented yet.");return l=dW({x:l,filter:e,strides:s,pad:r==="same"?"same":"valid",dilations:i,dataFormat:"NHWC",bias:n,activation:a}),o==="channelsFirst"&&(l=Fe(l,[0,3,1,2])),l})}function fH(t,e,n,s=[1,1,1],r="valid",o,i){return P(()=>{if(o==null&&(o=er()),Nt(o),t.rank!==4&&t.rank!==5)throw new E(`conv3dWithBias expects input to be of rank 4 or 5, but received ${t.rank}.`);if(e.rank!==4&&e.rank!==5)throw new E(`conv3dWithBias expects kernel to be of rank 4 or 5, but received ${t.rank}.`);let a=CE(t,o);if(r==="causal")throw new Ie("The support for CAUSAL padding mode in conv3dWithBias is not implemented yet.");return a=u4(a,e,s,r==="same"?"same":"valid","NDHWC",i),n!=null&&(a=sr(a,n)),o==="channelsFirst"&&(a=Fe(a,[0,4,1,2,3])),a})}class Rm extends Ae{constructor(e,n){if(super(n),this.bias=null,this.DEFAULT_KERNEL_INITIALIZER="glorotNormal",this.DEFAULT_BIAS_INITIALIZER="zeros",Rm.verifyArgs(n),this.rank=e,qt(this.rank,"rank"),this.rank!==1&&this.rank!==2&&this.rank!==3)throw new Ie(`Convolution layer for rank other than 1, 2, or 3 (${this.rank}) is not implemented yet.`);if(this.kernelSize=Ba(n.kernelSize,e,"kernelSize"),this.strides=Ba(n.strides==null?1:n.strides,e,"strides"),this.padding=n.padding==null?"valid":n.padding,hs(this.padding),this.dataFormat=n.dataFormat==null?"channelsLast":n.dataFormat,Nt(this.dataFormat),this.activation=zo(n.activation),this.useBias=n.useBias==null?!0:n.useBias,this.biasInitializer=ft(n.biasInitializer||this.DEFAULT_BIAS_INITIALIZER),this.biasConstraint=Bt(n.biasConstraint),this.biasRegularizer=pt(n.biasRegularizer),this.activityRegularizer=pt(n.activityRegularizer),this.dilationRate=Ba(n.dilationRate==null?1:n.dilationRate,e,"dilationRate"),this.rank===1&&Array.isArray(this.dilationRate)&&this.dilationRate.length!==1)throw new E(`dilationRate must be a number or an array of a single number for 1D convolution, but received ${JSON.stringify(this.dilationRate)}`);if(this.rank===2){if(typeof this.dilationRate=="number")this.dilationRate=[this.dilationRate,this.dilationRate];else if(this.dilationRate.length!==2)throw new E(`dilationRate must be a number or array of two numbers for 2D convolution, but received ${JSON.stringify(this.dilationRate)}`)}else if(this.rank===3){if(typeof this.dilationRate=="number")this.dilationRate=[this.dilationRate,this.dilationRate,this.dilationRate];else if(this.dilationRate.length!==3)throw new E(`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"),typeof e.kernelSize!="number"&&!Hw(e.kernelSize,"number",1,3))throw new E(`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:Fo(this.activation),useBias:this.useBias,biasInitializer:xt(this.biasInitializer),biasRegularizer:Je(this.biasRegularizer),activityRegularizer:Je(this.activityRegularizer),biasConstraint:Lt(this.biasConstraint)},n=super.getConfig();return Object.assign(e,n),e}}class $l extends Rm{constructor(e,n){super(e,n),this.kernel=null,$l.verifyArgs(n),this.filters=n.filters,qt(this.filters,"filters"),this.kernelInitializer=ft(n.kernelInitializer||this.DEFAULT_KERNEL_INITIALIZER),this.kernelConstraint=Bt(n.kernelConstraint),this.kernelRegularizer=pt(n.kernelRegularizer)}build(e){e=Pe(e);const n=this.dataFormat==="channelsFirst"?1:e.length-1;if(e[n]==null)throw new E(`The channel dimension of the input should be defined. Found ${e[n]}`);const s=e[n],r=this.kernelSize.concat([s,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:{[n]:s}}],this.built=!0}call(e,n){return P(()=>{e=Ce(e);let s;const r=this.bias==null?null:this.bias.read(),o=yT(this.activation.getClassName());if(o!=null&&this.rank===2)s=uk(e,this.kernel.read(),r,this.strides,this.padding,this.dataFormat,this.dilationRate,o);else{if(this.rank===1)s=dH(e,this.kernel.read(),r,this.strides[0],this.padding,this.dataFormat,this.dilationRate[0]);else if(this.rank===2)s=uk(e,this.kernel.read(),r,this.strides,this.padding,this.dataFormat,this.dilationRate);else if(this.rank===3)s=fH(e,this.kernel.read(),r,this.strides,this.padding,this.dataFormat,this.dilationRate);else throw new Ie("convolutions greater than 3D are not implemented yet.");this.activation!=null&&(s=this.activation.apply(s))}return s})}computeOutputShape(e){e=Pe(e);const n=[],s=this.dataFormat==="channelsLast"?e.slice(1,e.length-1):e.slice(2);for(let o=0;o 0 but got ${JSON.stringify(e.filters)}`)}}class Ih extends $l{constructor(e){super(2,e),Ih.verifyArgs(e)}getConfig(){const e=super.getConfig();return delete e.rank,e}static verifyArgs(e){if(typeof e.kernelSize!="number"&&!Hw(e.kernelSize,"number",1,2))throw new E(`Conv2D expects config.kernelSize to be number or number[] with length 1 or 2, but received ${JSON.stringify(e.kernelSize)}.`)}}Ih.className="Conv2D";Y(Ih);class $h extends $l{constructor(e){super(3,e),$h.verifyArgs(e)}getConfig(){const e=super.getConfig();return delete e.rank,e}static verifyArgs(e){if(typeof e.kernelSize!="number"&&!(Array.isArray(e.kernelSize)&&(e.kernelSize.length===1||e.kernelSize.length===3)))throw new E(`Conv3D expects config.kernelSize to be number or [number, number, number], but received ${JSON.stringify(e.kernelSize)}.`)}}$h.className="Conv3D";Y($h);class kE extends Ih{constructor(e){if(super(e),this.inputSpec=[new Pt({ndim:4})],this.padding!=="same"&&this.padding!=="valid")throw new E(`Conv2DTranspose currently supports only padding modes 'same' and 'valid', but received padding mode ${this.padding}`)}build(e){if(e=Pe(e),e.length!==4)throw new E("Input should have rank 4; Received input shape: "+JSON.stringify(e));const n=this.dataFormat==="channelsFirst"?1:e.length-1;if(e[n]==null)throw new E("The channel dimension of the inputs should be defined. Found `None`.");const s=e[n],r=this.kernelSize.concat([this.filters,s]);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 Pt({ndim:4,axes:{[n]:s}})],this.built=!0}call(e,n){return P(()=>{let s=Ce(e);if(s.shape.length!==4)throw new E(`Conv2DTranspose.call() expects input tensor to be rank-4, but received a tensor of rank-${s.shape.length}`);const r=s.shape,o=r[0];let i,a;this.dataFormat==="channelsFirst"?(i=2,a=3):(i=1,a=2);const l=r[i],c=r[a],u=this.kernelSize[0],h=this.kernelSize[1],d=this.strides[0],f=this.strides[1],p=dr(l,d,u,this.padding),g=dr(c,f,h,this.padding),x=[o,p,g,this.filters];this.dataFormat!=="channelsLast"&&(s=Fe(s,[0,2,3,1]));let m=Q$(s,this.kernel.read(),x,this.strides,this.padding);return this.dataFormat!=="channelsLast"&&(m=Fe(m,[0,3,1,2])),this.bias!=null&&(m=sr(m,this.bias.read(),this.dataFormat)),this.activation!=null&&(m=this.activation.apply(m)),m})}computeOutputShape(e){e=Pe(e);const n=e.slice();let s,r,o;this.dataFormat==="channelsFirst"?(s=1,r=2,o=3):(s=3,r=1,o=2);const i=this.kernelSize[0],a=this.kernelSize[1],l=this.strides[0],c=this.strides[1];return n[s]=this.filters,n[r]=dr(n[r],l,i,this.padding),n[o]=dr(n[o],c,a,this.padding),n}getConfig(){const e=super.getConfig();return delete e.dilationRate,e}}kE.className="Conv2DTranspose";Y(kE);class SE extends $h{constructor(e){if(super(e),this.inputSpec=[new Pt({ndim:5})],this.padding!=="same"&&this.padding!=="valid")throw new E(`Conv3DTranspose currently supports only padding modes 'same' and 'valid', but received padding mode ${this.padding}`)}build(e){if(e=Pe(e),e.length!==5)throw new E("Input should have rank 5; Received input shape: "+JSON.stringify(e));const n=this.dataFormat==="channelsFirst"?1:e.length-1;if(e[n]==null)throw new E("The channel dimension of the inputs should be defined. Found `None`.");const s=e[n],r=this.kernelSize.concat([this.filters,s]);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 Pt({ndim:5,axes:{[n]:s}})],this.built=!0}call(e,n){return P(()=>{let s=Ce(e);if(s.shape.length!==5)throw new E(`Conv3DTranspose.call() expects input tensor to be rank-4, but received a tensor of rank-${s.shape.length}`);const r=s.shape,o=r[0];let i,a,l;this.dataFormat==="channelsFirst"?(l=2,i=3,a=4):(l=1,i=2,a=3);const c=r[l],u=r[i],h=r[a],d=this.kernelSize[0],f=this.kernelSize[1],p=this.kernelSize[2],g=this.strides[0],x=this.strides[1],m=this.strides[2],y=dr(c,g,d,this.padding),w=dr(u,x,f,this.padding),v=dr(h,m,p,this.padding),b=[o,y,w,v,this.filters];this.dataFormat!=="channelsLast"&&(s=Fe(s,[0,2,3,4,1]));let C=f4(s,this.kernel.read(),b,this.strides,this.padding);return this.dataFormat!=="channelsLast"&&(C=Fe(C,[0,4,1,2,3])),this.bias!==null&&(C=sr(C,this.bias.read(),this.dataFormat)),this.activation!==null&&(C=this.activation.apply(C)),C})}computeOutputShape(e){e=Pe(e);const n=e.slice();let s,r,o,i;this.dataFormat==="channelsFirst"?(s=1,r=2,o=3,i=4):(s=4,r=1,o=2,i=3);const a=this.kernelSize[0],l=this.kernelSize[1],c=this.kernelSize[2],u=this.strides[0],h=this.strides[1],d=this.strides[2];return n[s]=this.filters,n[r]=dr(n[r],u,a,this.padding),n[o]=dr(n[o],h,l,this.padding),n[i]=dr(n[i],d,c,this.padding),n}getConfig(){const e=super.getConfig();return delete e.dilationRate,e}}SE.className="Conv3DTranspose";Y(SE);class IE extends $l{constructor(e,n){if(super(e,n),this.DEFAULT_DEPTHWISE_INITIALIZER="glorotUniform",this.DEFAULT_POINTWISE_INITIALIZER="glorotUniform",this.depthwiseKernel=null,this.pointwiseKernel=null,n.filters==null)throw new E("The `filters` configuration field is required by SeparableConv, but is unspecified.");if(n.kernelInitializer!=null||n.kernelRegularizer!=null||n.kernelConstraint!=null)throw new E("Fields kernelInitializer, kernelRegularizer and kernelConstraint are invalid for SeparableConv2D. Use depthwiseInitializer, depthwiseRegularizer, depthwiseConstraint, pointwiseInitializer, pointwiseRegularizer and pointwiseConstraint instead.");if(n.padding!=null&&n.padding!=="same"&&n.padding!=="valid")throw new E(`SeparableConv${this.rank}D supports only padding modes: 'same' and 'valid', but received ${JSON.stringify(n.padding)}`);this.depthMultiplier=n.depthMultiplier==null?1:n.depthMultiplier,this.depthwiseInitializer=ft(n.depthwiseInitializer||this.DEFAULT_DEPTHWISE_INITIALIZER),this.depthwiseRegularizer=pt(n.depthwiseRegularizer),this.depthwiseConstraint=Bt(n.depthwiseConstraint),this.pointwiseInitializer=ft(n.depthwiseInitializer||this.DEFAULT_POINTWISE_INITIALIZER),this.pointwiseRegularizer=pt(n.pointwiseRegularizer),this.pointwiseConstraint=Bt(n.pointwiseConstraint)}build(e){if(e=Pe(e),e.length{e=Ce(e);let s;if(this.rank===1)throw new Ie("1D separable convolution is not implemented yet.");return this.rank===2&&(this.dataFormat==="channelsFirst"&&(e=Fe(e,[0,2,3,1])),s=gN(e,this.depthwiseKernel.read(),this.pointwiseKernel.read(),this.strides,this.padding,this.dilationRate,"NHWC")),this.useBias&&(s=sr(s,this.bias.read(),this.dataFormat)),this.activation!=null&&(s=this.activation.apply(s)),this.dataFormat==="channelsFirst"&&(s=Fe(s,[0,3,1,2])),s})}getConfig(){const e=super.getConfig();return delete e.rank,delete e.kernelInitializer,delete e.kernelRegularizer,delete e.kernelConstraint,e.depthwiseInitializer=xt(this.depthwiseInitializer),e.pointwiseInitializer=xt(this.pointwiseInitializer),e.depthwiseRegularizer=Je(this.depthwiseRegularizer),e.pointwiseRegularizer=Je(this.pointwiseRegularizer),e.depthwiseConstraint=Lt(this.depthwiseConstraint),e.pointwiseConstraint=Lt(this.pointwiseConstraint),e}}IE.className="SeparableConv";class $E extends IE{constructor(e){super(2,e)}}$E.className="SeparableConv2D";Y($E);class Am extends $l{constructor(e){super(1,e),Am.verifyArgs(e),this.inputSpec=[{ndim:3}]}getConfig(){const e=super.getConfig();return delete e.rank,delete e.dataFormat,e}static verifyArgs(e){if(typeof e.kernelSize!="number"&&!Hw(e.kernelSize,"number",1,1))throw new E(`Conv1D expects config.kernelSize to be number or number[] with length 1, but received ${JSON.stringify(e.kernelSize)}.`)}}Am.className="Conv1D";Y(Am);class NE extends Ae{constructor(e){super(e),typeof e.cropping=="number"?this.cropping=[[e.cropping,e.cropping],[e.cropping,e.cropping]]:typeof e.cropping[0]=="number"?this.cropping=[[e.cropping[0],e.cropping[0]],[e.cropping[1],e.cropping[1]]]:this.cropping=e.cropping,this.dataFormat=e.dataFormat===void 0?"channelsLast":e.dataFormat,this.inputSpec=[{ndim:4}]}computeOutputShape(e){return this.dataFormat==="channelsFirst"?[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,n){return P(()=>{if(e=Ce(e),this.dataFormat==="channelsLast"){const s=nd(e,this.cropping[0][0],e.shape[1]-this.cropping[0][0]-this.cropping[0][1],2);return nd(s,this.cropping[1][0],e.shape[2]-this.cropping[1][1]-this.cropping[1][0],3)}else{const s=nd(e,this.cropping[0][0],e.shape[2]-this.cropping[0][0]-this.cropping[0][1],3);return nd(s,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},n=super.getConfig();return Object.assign(e,n),e}}NE.className="Cropping2D";Y(NE);class TE extends Ae{constructor(e){super(e),this.DEFAULT_SIZE=[2,2],this.inputSpec=[{ndim:4}],this.size=e.size==null?this.DEFAULT_SIZE:e.size,this.dataFormat=e.dataFormat==null?"channelsLast":e.dataFormat,Nt(this.dataFormat),this.interpolation=e.interpolation==null?"nearest":e.interpolation,B6(this.interpolation)}computeOutputShape(e){if(this.dataFormat==="channelsFirst"){const n=e[2]==null?null:this.size[0]*e[2],s=e[3]==null?null:this.size[1]*e[3];return[e[0],e[1],n,s]}else{const n=e[1]==null?null:this.size[0]*e[1],s=e[2]==null?null:this.size[1]*e[2];return[e[0],n,s,e[3]]}}call(e,n){return P(()=>{let s=Ce(e);const r=s.shape;if(this.dataFormat==="channelsFirst"){s=Fe(s,[0,2,3,1]);const o=this.size[0]*r[2],i=this.size[1]*r[3],a=this.interpolation==="nearest"?Mr.resizeNearestNeighbor(s,[o,i]):Mr.resizeBilinear(s,[o,i]);return Fe(a,[0,3,1,2])}else{const o=this.size[0]*r[1],i=this.size[1]*r[2];return this.interpolation==="nearest"?Mr.resizeNearestNeighbor(s,[o,i]):Mr.resizeBilinear(s,[o,i])}})}getConfig(){const e={size:this.size,dataFormat:this.dataFormat,interpolation:this.interpolation},n=super.getConfig();return Object.assign(e,n),e}}TE.className="UpSampling2D";Y(TE);/** + */function ov(t,e){return P(()=>(Nt(e),e==="channelsFirst"?Fe(t,[0,2,3,1]):t))}function CE(t,e){return P(()=>(Nt(e),e==="channelsFirst"?Fe(t,[0,2,3,4,1]):t))}function hH(t,e,n,s=1,r="valid",o,i=1){return P(()=>{if(o==null&&(o=er()),Nt(o),t.shape.length!==3)throw new E(`The input of a conv1dWithBias operation should be 3, but is ${t.shape.length} instead.`);if(e.shape.length!==3)throw new E(`The kernel for a conv1dWithBias operation should be 3, but is ${e.shape.length} instead`);if(n!=null&&n.shape.length!==1)throw new E(`The bias for a conv1dWithBias operation should be 1, but is ${n.shape.length} instead`);if(o==="channelsFirst"&&(t=Fe(t,[0,2,1])),r==="causal")throw new Ie("The support for CAUSAL padding mode in conv1dWithBias is not implemented yet.");let a=Y$(t,e,s,r==="same"?"same":"valid","NWC",i);return n!=null&&(a=sr(a,n)),a})}function uk(t,e,n,s=[1,1],r="valid",o,i,a=null){return P(()=>{if(o==null&&(o=er()),Nt(o),t.rank!==3&&t.rank!==4)throw new E(`conv2dWithBiasActivation expects input to be of rank 3 or 4, but received ${t.rank}.`);if(e.rank!==3&&e.rank!==4)throw new E(`conv2dWithBiasActivation expects kernel to be of rank 3 or 4, but received ${t.rank}.`);let l=ov(t,o);if(r==="causal")throw new Ie("The support for CAUSAL padding mode in conv1dWithBias is not implemented yet.");return l=hW({x:l,filter:e,strides:s,pad:r==="same"?"same":"valid",dilations:i,dataFormat:"NHWC",bias:n,activation:a}),o==="channelsFirst"&&(l=Fe(l,[0,3,1,2])),l})}function dH(t,e,n,s=[1,1,1],r="valid",o,i){return P(()=>{if(o==null&&(o=er()),Nt(o),t.rank!==4&&t.rank!==5)throw new E(`conv3dWithBias expects input to be of rank 4 or 5, but received ${t.rank}.`);if(e.rank!==4&&e.rank!==5)throw new E(`conv3dWithBias expects kernel to be of rank 4 or 5, but received ${t.rank}.`);let a=CE(t,o);if(r==="causal")throw new Ie("The support for CAUSAL padding mode in conv3dWithBias is not implemented yet.");return a=c4(a,e,s,r==="same"?"same":"valid","NDHWC",i),n!=null&&(a=sr(a,n)),o==="channelsFirst"&&(a=Fe(a,[0,4,1,2,3])),a})}class Rm extends Ae{constructor(e,n){if(super(n),this.bias=null,this.DEFAULT_KERNEL_INITIALIZER="glorotNormal",this.DEFAULT_BIAS_INITIALIZER="zeros",Rm.verifyArgs(n),this.rank=e,qt(this.rank,"rank"),this.rank!==1&&this.rank!==2&&this.rank!==3)throw new Ie(`Convolution layer for rank other than 1, 2, or 3 (${this.rank}) is not implemented yet.`);if(this.kernelSize=Ba(n.kernelSize,e,"kernelSize"),this.strides=Ba(n.strides==null?1:n.strides,e,"strides"),this.padding=n.padding==null?"valid":n.padding,hs(this.padding),this.dataFormat=n.dataFormat==null?"channelsLast":n.dataFormat,Nt(this.dataFormat),this.activation=zo(n.activation),this.useBias=n.useBias==null?!0:n.useBias,this.biasInitializer=ft(n.biasInitializer||this.DEFAULT_BIAS_INITIALIZER),this.biasConstraint=Bt(n.biasConstraint),this.biasRegularizer=pt(n.biasRegularizer),this.activityRegularizer=pt(n.activityRegularizer),this.dilationRate=Ba(n.dilationRate==null?1:n.dilationRate,e,"dilationRate"),this.rank===1&&Array.isArray(this.dilationRate)&&this.dilationRate.length!==1)throw new E(`dilationRate must be a number or an array of a single number for 1D convolution, but received ${JSON.stringify(this.dilationRate)}`);if(this.rank===2){if(typeof this.dilationRate=="number")this.dilationRate=[this.dilationRate,this.dilationRate];else if(this.dilationRate.length!==2)throw new E(`dilationRate must be a number or array of two numbers for 2D convolution, but received ${JSON.stringify(this.dilationRate)}`)}else if(this.rank===3){if(typeof this.dilationRate=="number")this.dilationRate=[this.dilationRate,this.dilationRate,this.dilationRate];else if(this.dilationRate.length!==3)throw new E(`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"),typeof e.kernelSize!="number"&&!Hw(e.kernelSize,"number",1,3))throw new E(`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:Fo(this.activation),useBias:this.useBias,biasInitializer:xt(this.biasInitializer),biasRegularizer:Je(this.biasRegularizer),activityRegularizer:Je(this.activityRegularizer),biasConstraint:Lt(this.biasConstraint)},n=super.getConfig();return Object.assign(e,n),e}}class $l extends Rm{constructor(e,n){super(e,n),this.kernel=null,$l.verifyArgs(n),this.filters=n.filters,qt(this.filters,"filters"),this.kernelInitializer=ft(n.kernelInitializer||this.DEFAULT_KERNEL_INITIALIZER),this.kernelConstraint=Bt(n.kernelConstraint),this.kernelRegularizer=pt(n.kernelRegularizer)}build(e){e=Pe(e);const n=this.dataFormat==="channelsFirst"?1:e.length-1;if(e[n]==null)throw new E(`The channel dimension of the input should be defined. Found ${e[n]}`);const s=e[n],r=this.kernelSize.concat([s,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:{[n]:s}}],this.built=!0}call(e,n){return P(()=>{e=Ce(e);let s;const r=this.bias==null?null:this.bias.read(),o=yT(this.activation.getClassName());if(o!=null&&this.rank===2)s=uk(e,this.kernel.read(),r,this.strides,this.padding,this.dataFormat,this.dilationRate,o);else{if(this.rank===1)s=hH(e,this.kernel.read(),r,this.strides[0],this.padding,this.dataFormat,this.dilationRate[0]);else if(this.rank===2)s=uk(e,this.kernel.read(),r,this.strides,this.padding,this.dataFormat,this.dilationRate);else if(this.rank===3)s=dH(e,this.kernel.read(),r,this.strides,this.padding,this.dataFormat,this.dilationRate);else throw new Ie("convolutions greater than 3D are not implemented yet.");this.activation!=null&&(s=this.activation.apply(s))}return s})}computeOutputShape(e){e=Pe(e);const n=[],s=this.dataFormat==="channelsLast"?e.slice(1,e.length-1):e.slice(2);for(let o=0;o 0 but got ${JSON.stringify(e.filters)}`)}}class Sh extends $l{constructor(e){super(2,e),Sh.verifyArgs(e)}getConfig(){const e=super.getConfig();return delete e.rank,e}static verifyArgs(e){if(typeof e.kernelSize!="number"&&!Hw(e.kernelSize,"number",1,2))throw new E(`Conv2D expects config.kernelSize to be number or number[] with length 1 or 2, but received ${JSON.stringify(e.kernelSize)}.`)}}Sh.className="Conv2D";Y(Sh);class Ih extends $l{constructor(e){super(3,e),Ih.verifyArgs(e)}getConfig(){const e=super.getConfig();return delete e.rank,e}static verifyArgs(e){if(typeof e.kernelSize!="number"&&!(Array.isArray(e.kernelSize)&&(e.kernelSize.length===1||e.kernelSize.length===3)))throw new E(`Conv3D expects config.kernelSize to be number or [number, number, number], but received ${JSON.stringify(e.kernelSize)}.`)}}Ih.className="Conv3D";Y(Ih);class kE extends Sh{constructor(e){if(super(e),this.inputSpec=[new Pt({ndim:4})],this.padding!=="same"&&this.padding!=="valid")throw new E(`Conv2DTranspose currently supports only padding modes 'same' and 'valid', but received padding mode ${this.padding}`)}build(e){if(e=Pe(e),e.length!==4)throw new E("Input should have rank 4; Received input shape: "+JSON.stringify(e));const n=this.dataFormat==="channelsFirst"?1:e.length-1;if(e[n]==null)throw new E("The channel dimension of the inputs should be defined. Found `None`.");const s=e[n],r=this.kernelSize.concat([this.filters,s]);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 Pt({ndim:4,axes:{[n]:s}})],this.built=!0}call(e,n){return P(()=>{let s=Ce(e);if(s.shape.length!==4)throw new E(`Conv2DTranspose.call() expects input tensor to be rank-4, but received a tensor of rank-${s.shape.length}`);const r=s.shape,o=r[0];let i,a;this.dataFormat==="channelsFirst"?(i=2,a=3):(i=1,a=2);const l=r[i],c=r[a],u=this.kernelSize[0],h=this.kernelSize[1],d=this.strides[0],f=this.strides[1],p=dr(l,d,u,this.padding),g=dr(c,f,h,this.padding),x=[o,p,g,this.filters];this.dataFormat!=="channelsLast"&&(s=Fe(s,[0,2,3,1]));let m=Q$(s,this.kernel.read(),x,this.strides,this.padding);return this.dataFormat!=="channelsLast"&&(m=Fe(m,[0,3,1,2])),this.bias!=null&&(m=sr(m,this.bias.read(),this.dataFormat)),this.activation!=null&&(m=this.activation.apply(m)),m})}computeOutputShape(e){e=Pe(e);const n=e.slice();let s,r,o;this.dataFormat==="channelsFirst"?(s=1,r=2,o=3):(s=3,r=1,o=2);const i=this.kernelSize[0],a=this.kernelSize[1],l=this.strides[0],c=this.strides[1];return n[s]=this.filters,n[r]=dr(n[r],l,i,this.padding),n[o]=dr(n[o],c,a,this.padding),n}getConfig(){const e=super.getConfig();return delete e.dilationRate,e}}kE.className="Conv2DTranspose";Y(kE);class SE extends Ih{constructor(e){if(super(e),this.inputSpec=[new Pt({ndim:5})],this.padding!=="same"&&this.padding!=="valid")throw new E(`Conv3DTranspose currently supports only padding modes 'same' and 'valid', but received padding mode ${this.padding}`)}build(e){if(e=Pe(e),e.length!==5)throw new E("Input should have rank 5; Received input shape: "+JSON.stringify(e));const n=this.dataFormat==="channelsFirst"?1:e.length-1;if(e[n]==null)throw new E("The channel dimension of the inputs should be defined. Found `None`.");const s=e[n],r=this.kernelSize.concat([this.filters,s]);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 Pt({ndim:5,axes:{[n]:s}})],this.built=!0}call(e,n){return P(()=>{let s=Ce(e);if(s.shape.length!==5)throw new E(`Conv3DTranspose.call() expects input tensor to be rank-4, but received a tensor of rank-${s.shape.length}`);const r=s.shape,o=r[0];let i,a,l;this.dataFormat==="channelsFirst"?(l=2,i=3,a=4):(l=1,i=2,a=3);const c=r[l],u=r[i],h=r[a],d=this.kernelSize[0],f=this.kernelSize[1],p=this.kernelSize[2],g=this.strides[0],x=this.strides[1],m=this.strides[2],y=dr(c,g,d,this.padding),w=dr(u,x,f,this.padding),v=dr(h,m,p,this.padding),b=[o,y,w,v,this.filters];this.dataFormat!=="channelsLast"&&(s=Fe(s,[0,2,3,4,1]));let C=d4(s,this.kernel.read(),b,this.strides,this.padding);return this.dataFormat!=="channelsLast"&&(C=Fe(C,[0,4,1,2,3])),this.bias!==null&&(C=sr(C,this.bias.read(),this.dataFormat)),this.activation!==null&&(C=this.activation.apply(C)),C})}computeOutputShape(e){e=Pe(e);const n=e.slice();let s,r,o,i;this.dataFormat==="channelsFirst"?(s=1,r=2,o=3,i=4):(s=4,r=1,o=2,i=3);const a=this.kernelSize[0],l=this.kernelSize[1],c=this.kernelSize[2],u=this.strides[0],h=this.strides[1],d=this.strides[2];return n[s]=this.filters,n[r]=dr(n[r],u,a,this.padding),n[o]=dr(n[o],h,l,this.padding),n[i]=dr(n[i],d,c,this.padding),n}getConfig(){const e=super.getConfig();return delete e.dilationRate,e}}SE.className="Conv3DTranspose";Y(SE);class IE extends $l{constructor(e,n){if(super(e,n),this.DEFAULT_DEPTHWISE_INITIALIZER="glorotUniform",this.DEFAULT_POINTWISE_INITIALIZER="glorotUniform",this.depthwiseKernel=null,this.pointwiseKernel=null,n.filters==null)throw new E("The `filters` configuration field is required by SeparableConv, but is unspecified.");if(n.kernelInitializer!=null||n.kernelRegularizer!=null||n.kernelConstraint!=null)throw new E("Fields kernelInitializer, kernelRegularizer and kernelConstraint are invalid for SeparableConv2D. Use depthwiseInitializer, depthwiseRegularizer, depthwiseConstraint, pointwiseInitializer, pointwiseRegularizer and pointwiseConstraint instead.");if(n.padding!=null&&n.padding!=="same"&&n.padding!=="valid")throw new E(`SeparableConv${this.rank}D supports only padding modes: 'same' and 'valid', but received ${JSON.stringify(n.padding)}`);this.depthMultiplier=n.depthMultiplier==null?1:n.depthMultiplier,this.depthwiseInitializer=ft(n.depthwiseInitializer||this.DEFAULT_DEPTHWISE_INITIALIZER),this.depthwiseRegularizer=pt(n.depthwiseRegularizer),this.depthwiseConstraint=Bt(n.depthwiseConstraint),this.pointwiseInitializer=ft(n.depthwiseInitializer||this.DEFAULT_POINTWISE_INITIALIZER),this.pointwiseRegularizer=pt(n.pointwiseRegularizer),this.pointwiseConstraint=Bt(n.pointwiseConstraint)}build(e){if(e=Pe(e),e.length{e=Ce(e);let s;if(this.rank===1)throw new Ie("1D separable convolution is not implemented yet.");return this.rank===2&&(this.dataFormat==="channelsFirst"&&(e=Fe(e,[0,2,3,1])),s=gN(e,this.depthwiseKernel.read(),this.pointwiseKernel.read(),this.strides,this.padding,this.dilationRate,"NHWC")),this.useBias&&(s=sr(s,this.bias.read(),this.dataFormat)),this.activation!=null&&(s=this.activation.apply(s)),this.dataFormat==="channelsFirst"&&(s=Fe(s,[0,3,1,2])),s})}getConfig(){const e=super.getConfig();return delete e.rank,delete e.kernelInitializer,delete e.kernelRegularizer,delete e.kernelConstraint,e.depthwiseInitializer=xt(this.depthwiseInitializer),e.pointwiseInitializer=xt(this.pointwiseInitializer),e.depthwiseRegularizer=Je(this.depthwiseRegularizer),e.pointwiseRegularizer=Je(this.pointwiseRegularizer),e.depthwiseConstraint=Lt(this.depthwiseConstraint),e.pointwiseConstraint=Lt(this.pointwiseConstraint),e}}IE.className="SeparableConv";class $E extends IE{constructor(e){super(2,e)}}$E.className="SeparableConv2D";Y($E);class Am extends $l{constructor(e){super(1,e),Am.verifyArgs(e),this.inputSpec=[{ndim:3}]}getConfig(){const e=super.getConfig();return delete e.rank,delete e.dataFormat,e}static verifyArgs(e){if(typeof e.kernelSize!="number"&&!Hw(e.kernelSize,"number",1,1))throw new E(`Conv1D expects config.kernelSize to be number or number[] with length 1, but received ${JSON.stringify(e.kernelSize)}.`)}}Am.className="Conv1D";Y(Am);class NE extends Ae{constructor(e){super(e),typeof e.cropping=="number"?this.cropping=[[e.cropping,e.cropping],[e.cropping,e.cropping]]:typeof e.cropping[0]=="number"?this.cropping=[[e.cropping[0],e.cropping[0]],[e.cropping[1],e.cropping[1]]]:this.cropping=e.cropping,this.dataFormat=e.dataFormat===void 0?"channelsLast":e.dataFormat,this.inputSpec=[{ndim:4}]}computeOutputShape(e){return this.dataFormat==="channelsFirst"?[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,n){return P(()=>{if(e=Ce(e),this.dataFormat==="channelsLast"){const s=td(e,this.cropping[0][0],e.shape[1]-this.cropping[0][0]-this.cropping[0][1],2);return td(s,this.cropping[1][0],e.shape[2]-this.cropping[1][1]-this.cropping[1][0],3)}else{const s=td(e,this.cropping[0][0],e.shape[2]-this.cropping[0][0]-this.cropping[0][1],3);return td(s,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},n=super.getConfig();return Object.assign(e,n),e}}NE.className="Cropping2D";Y(NE);class TE extends Ae{constructor(e){super(e),this.DEFAULT_SIZE=[2,2],this.inputSpec=[{ndim:4}],this.size=e.size==null?this.DEFAULT_SIZE:e.size,this.dataFormat=e.dataFormat==null?"channelsLast":e.dataFormat,Nt(this.dataFormat),this.interpolation=e.interpolation==null?"nearest":e.interpolation,L6(this.interpolation)}computeOutputShape(e){if(this.dataFormat==="channelsFirst"){const n=e[2]==null?null:this.size[0]*e[2],s=e[3]==null?null:this.size[1]*e[3];return[e[0],e[1],n,s]}else{const n=e[1]==null?null:this.size[0]*e[1],s=e[2]==null?null:this.size[1]*e[2];return[e[0],n,s,e[3]]}}call(e,n){return P(()=>{let s=Ce(e);const r=s.shape;if(this.dataFormat==="channelsFirst"){s=Fe(s,[0,2,3,1]);const o=this.size[0]*r[2],i=this.size[1]*r[3],a=this.interpolation==="nearest"?Mr.resizeNearestNeighbor(s,[o,i]):Mr.resizeBilinear(s,[o,i]);return Fe(a,[0,3,1,2])}else{const o=this.size[0]*r[1],i=this.size[1]*r[2];return this.interpolation==="nearest"?Mr.resizeNearestNeighbor(s,[o,i]):Mr.resizeBilinear(s,[o,i])}})}getConfig(){const e={size:this.size,dataFormat:this.dataFormat,interpolation:this.interpolation},n=super.getConfig();return Object.assign(e,n),e}}TE.className="UpSampling2D";Y(TE);/** * @license * Copyright 2018 Google LLC * @@ -7873,7 +7873,7 @@ body { * license that can be found in the LICENSE file or at * https://opensource.org/licenses/MIT. * ============================================================================= - */function pH(t,e,n=[1,1],s="valid",r,o){return P(()=>{r==null&&(r=er()),Nt(r);let i=ov(t,r);if(t.rank!==4)throw new E(`Input for depthwiseConv2d is required to be 4-D, but is instead ${t.rank}-D`);if(e.rank!==4)throw new E(`depthwiseKernel is required to be 4-D, but is instead ${e.rank}-D`);return i=By(i,e,n,s==="same"?"same":"valid","NHWC",o),r==="channelsFirst"&&(i=Fe(i,[0,3,1,2])),i})}class EE extends Rm{constructor(e){super(2,e),this.depthwiseKernel=null,this.depthMultiplier=e.depthMultiplier==null?1:e.depthMultiplier,this.depthwiseInitializer=ft(e.depthwiseInitializer||this.DEFAULT_KERNEL_INITIALIZER),this.depthwiseConstraint=Bt(e.depthwiseConstraint),this.depthwiseRegularizer=pt(e.depthwiseRegularizer)}build(e){if(e=Pe(e),e.length<4)throw new E(`Inputs to DepthwiseConv2D should have rank 4. Received input shape: ${JSON.stringify(e)}.`);const n=this.dataFormat==="channelsFirst"?1:3;if(e[n]==null||e[n]<0)throw new E(`The channel dimension of the inputs to DepthwiseConv2D should be defined, but is not (${e[n]}).`);const s=e[n],r=[this.kernelSize[0],this.kernelSize[1],s,this.depthMultiplier];this.depthwiseKernel=this.addWeight("depthwise_kernel",r,null,this.depthwiseInitializer,this.depthwiseRegularizer,!0,this.depthwiseConstraint),this.useBias?this.bias=this.addWeight("bias",[s*this.depthMultiplier],null,this.biasInitializer,this.biasRegularizer,!0,this.biasConstraint):this.bias=null,this.built=!0}call(e,n){return P(()=>{e=Ce(e);let s=pH(e,this.depthwiseKernel.read(),this.strides,this.padding,this.dataFormat,null);return this.useBias&&(s=sr(s,this.bias.read(),this.dataFormat)),this.activation!=null&&(s=this.activation.apply(s)),s})}computeOutputShape(e){e=Pe(e);const n=this.dataFormat==="channelsFirst"?e[2]:e[1],s=this.dataFormat==="channelsFirst"?e[3]:e[2],r=this.dataFormat==="channelsFirst"?e[1]*this.depthMultiplier:e[3]*this.depthMultiplier,o=Qs(n,this.kernelSize[0],this.padding,this.strides[0]),i=Qs(s,this.kernelSize[1],this.padding,this.strides[1]);return this.dataFormat==="channelsFirst"?[e[0],r,o,i]:[e[0],o,i,r]}getConfig(){const e=super.getConfig();return e.depthMultiplier=this.depthMultiplier,e.depthwiseInitializer=xt(this.depthwiseInitializer),e.depthwiseRegularizer=Je(this.depthwiseRegularizer),e.depthwiseConstraint=Lt(this.depthwiseRegularizer),e}}EE.className="DepthwiseConv2D";Y(EE);/** + */function fH(t,e,n=[1,1],s="valid",r,o){return P(()=>{r==null&&(r=er()),Nt(r);let i=ov(t,r);if(t.rank!==4)throw new E(`Input for depthwiseConv2d is required to be 4-D, but is instead ${t.rank}-D`);if(e.rank!==4)throw new E(`depthwiseKernel is required to be 4-D, but is instead ${e.rank}-D`);return i=By(i,e,n,s==="same"?"same":"valid","NHWC",o),r==="channelsFirst"&&(i=Fe(i,[0,3,1,2])),i})}class EE extends Rm{constructor(e){super(2,e),this.depthwiseKernel=null,this.depthMultiplier=e.depthMultiplier==null?1:e.depthMultiplier,this.depthwiseInitializer=ft(e.depthwiseInitializer||this.DEFAULT_KERNEL_INITIALIZER),this.depthwiseConstraint=Bt(e.depthwiseConstraint),this.depthwiseRegularizer=pt(e.depthwiseRegularizer)}build(e){if(e=Pe(e),e.length<4)throw new E(`Inputs to DepthwiseConv2D should have rank 4. Received input shape: ${JSON.stringify(e)}.`);const n=this.dataFormat==="channelsFirst"?1:3;if(e[n]==null||e[n]<0)throw new E(`The channel dimension of the inputs to DepthwiseConv2D should be defined, but is not (${e[n]}).`);const s=e[n],r=[this.kernelSize[0],this.kernelSize[1],s,this.depthMultiplier];this.depthwiseKernel=this.addWeight("depthwise_kernel",r,null,this.depthwiseInitializer,this.depthwiseRegularizer,!0,this.depthwiseConstraint),this.useBias?this.bias=this.addWeight("bias",[s*this.depthMultiplier],null,this.biasInitializer,this.biasRegularizer,!0,this.biasConstraint):this.bias=null,this.built=!0}call(e,n){return P(()=>{e=Ce(e);let s=fH(e,this.depthwiseKernel.read(),this.strides,this.padding,this.dataFormat,null);return this.useBias&&(s=sr(s,this.bias.read(),this.dataFormat)),this.activation!=null&&(s=this.activation.apply(s)),s})}computeOutputShape(e){e=Pe(e);const n=this.dataFormat==="channelsFirst"?e[2]:e[1],s=this.dataFormat==="channelsFirst"?e[3]:e[2],r=this.dataFormat==="channelsFirst"?e[1]*this.depthMultiplier:e[3]*this.depthMultiplier,o=Qs(n,this.kernelSize[0],this.padding,this.strides[0]),i=Qs(s,this.kernelSize[1],this.padding,this.strides[1]);return this.dataFormat==="channelsFirst"?[e[0],r,o,i]:[e[0],o,i,r]}getConfig(){const e=super.getConfig();return e.depthMultiplier=this.depthMultiplier,e.depthwiseInitializer=xt(this.depthwiseInitializer),e.depthwiseRegularizer=Je(this.depthwiseRegularizer),e.depthwiseConstraint=Lt(this.depthwiseRegularizer),e}}EE.className="DepthwiseConv2D";Y(EE);/** * @license * Copyright 2018 Google LLC * @@ -7881,7 +7881,7 @@ body { * license that can be found in the LICENSE file or at * https://opensource.org/licenses/MIT. * ============================================================================= - */function RE(t,e,n,s){if(Array.isArray(t)){if(e!=null||n!=null)throw new E("When inputs is an array, neither initialState or constants should be provided");s!=null&&(n=t.slice(t.length-s,t.length),t=t.slice(0,t.length-s)),t.length>1&&(e=t.slice(1,t.length)),t=t[0]}function r(o){return o==null||Array.isArray(o)?o:[o]}return e=r(e),n=r(n),{inputs:t,initialState:e,constants:n}}function AE(t,e,n,s=!1,r,o,i=!1,a=!1){return P(()=>{const l=e.shape.length;if(l<3)throw new E(`Input should be at least 3D, but is ${l}D.`);const c=[1,0].concat(Js(2,l));e=Fe(e,c),i&&console.warn("Backend rnn(): the unroll = true option is not applicable to the imperative deeplearn.js backend."),r!=null&&(r=le(le(r,"bool"),"float32"),r.rank===l-1&&(r=En(r,-1)),r=Fe(r,c)),s&&(e=Mi(e,0),r!=null&&(r=Mi(r,0)));const u=[];let h,d=n;const f=e.shape[0],p=Pi(e);let g;r!=null&&(g=Pi(r));for(let m=0;mt(y,d));if(r==null)h=w[0],d=w[1];else{const v=P(()=>{const b=g[m],C=ve(Rs(b),b),k=J(D(w[0],b),D(d[0],C)),S=d.map(($,N)=>J(D(w[1][N],b),D($,C)));return{output:k,newStates:S}});h=v.output,d=v.newStates}a&&u.push(h)}let x;return a&&(x=Hr(u,1)),[h,x,d]})}class qo extends Ae{constructor(e){super(e);let n;if(e.cell==null)throw new E("cell property is missing for the constructor of RNN.");if(Array.isArray(e.cell)?n=new lv({cells:e.cell}):n=e.cell,n.stateSize==null)throw new E("The RNN cell should have an attribute `stateSize` (tuple of integers, one integer per RNN state).");this.cell=n,this.returnSequences=e.returnSequences==null?!1:e.returnSequences,this.returnState=e.returnState==null?!1:e.returnState,this.goBackwards=e.goBackwards==null?!1:e.goBackwards,this._stateful=e.stateful==null?!1:e.stateful,this.unroll=e.unroll==null?!1:e.unroll,this.supportsMasking=!0,this.inputSpec=[new Pt({ndim:3})],this.stateSpec=null,this.states_=null,this.numConstants=null,this.keptStates=[]}getStates(){if(this.states_==null){const e=Array.isArray(this.cell.stateSize)?this.cell.stateSize.length:1;return Js(0,e).map(n=>null)}else return this.states_}setStates(e){this.states_=e}computeOutputShape(e){w1(e)&&(e=e[0]),e=e;let n=this.cell.stateSize;Array.isArray(n)||(n=[n]);const s=n[0];let r;if(this.returnSequences?r=[e[0],e[1],s]:r=[e[0],s],this.returnState){const o=[];for(const i of n)o.push([e[0],i]);return[r].concat(o)}else return r}computeMask(e,n){return P(()=>{Array.isArray(n)&&(n=n[0]);const s=this.returnSequences?n:null;if(this.returnState){const r=this.states.map(o=>null);return[s].concat(r)}else return s})}get states(){if(this.states_==null){const e=Array.isArray(this.cell.stateSize)?this.cell.stateSize.length:1,n=[];for(let s=0;si.shape[i.shape.length-1]),o))throw new E(`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=o.map(i=>new Pt({shape:[null,i]}));this.stateful&&this.resetStates()}resetStates(e,n=!1){P(()=>{if(!this.stateful)throw new ur("Cannot call resetStates() on an RNN Layer that is not stateful.");const s=this.inputSpec[0].shape[0];if(s==null)throw new E("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(this.states_==null)Array.isArray(this.cell.stateSize)?this.states_=this.cell.stateSize.map(r=>Kt([s,r])):this.states_=[Kt([s,this.cell.stateSize])];else if(e==null)$e(this.states_),this.keptStates!=null&&($e(this.keptStates),this.keptStates=[]),Array.isArray(this.cell.stateSize)?this.states_=this.cell.stateSize.map(r=>Kt([s,r])):this.states_[0]=Kt([s,this.cell.stateSize]);else{if(Array.isArray(e)||(e=[e]),e.length!==this.states_.length)throw new E(`Layer ${this.name} expects ${this.states_.length} state(s), but it received ${e.length} state value(s). Input received: ${e}`);n===!0?this.keptStates.push(this.states_.slice()):$e(this.states_);for(let r=0;ryr(r.clone()))})}apply(e,n){let s=n==null?null:n.initialState,r=n==null?null:n.constants;n==null&&(n={});const o=RE(e,s,r,this.numConstants);e=o.inputs,s=o.initialState,r=o.constants;let i=[],a=[];if(s!=null){n.initialState=s,i=i.concat(s),this.stateSpec=[];for(const c of s)this.stateSpec.push(new Pt({shape:c.shape}));a=a.concat(this.stateSpec)}if(r!=null&&(n.constants=r,i=i.concat(r),this.numConstants=r.length),i[0]instanceof $r){const c=[e].concat(i),u=this.inputSpec.concat(a),h=this.inputSpec;this.inputSpec=u;const d=super.apply(c,n);return this.inputSpec=h,d}else return super.apply(e,n)}call(e,n){return P(()=>{const s=n==null?null:n.mask,r=n==null?null:n.training;let o=n==null?null:n.initialState;e=Ce(e),o==null&&(this.stateful?o=this.states_:o=this.getInitialState(e));const i=Array.isArray(this.cell.stateSize)?this.cell.stateSize.length:1;if(o.length!==i)throw new E(`RNN Layer has ${i} state(s) but was passed ${o.length} initial state(s).`);this.unroll&&console.warn("Ignoring unroll = true for RNN layer, due to imperative backend.");const a={training:r},c=AE((p,g)=>{const x=this.cell.call([p].concat(g),a);return[x[0],x.slice(1)]},e,o,this.goBackwards,s,null,this.unroll,this.returnSequences),u=c[0],h=c[1],d=c[2];this.stateful&&this.resetStates(d,r);const f=this.returnSequences?h:u;return this.returnState?[f].concat(d):f})}getInitialState(e){return P(()=>{let n=Kt(e.shape);return n=me(n,[1,2]),n=vh(n),Array.isArray(this.cell.stateSize)?this.cell.stateSize.map(s=>s>1?x1(n,[1,s]):n):this.cell.stateSize>1?[x1(n,[1,this.cell.stateSize])]:[n]})}get trainableWeights(){return this.trainable?this.cell.trainableWeights:[]}get nonTrainableWeights(){return this.trainable?this.cell.nonTrainableWeights:this.cell.weights}setFastWeightInitDuringBuild(e){super.setFastWeightInitDuringBuild(e),this.cell!=null&&this.cell.setFastWeightInitDuringBuild(e)}getConfig(){const e=super.getConfig(),n={returnSequences:this.returnSequences,returnState:this.returnState,goBackwards:this.goBackwards,stateful:this.stateful,unroll:this.unroll};this.numConstants!=null&&(n.numConstants=this.numConstants);const s=this.cell.getConfig();return this.getClassName()===qo.className&&(n.cell={className:this.cell.getClassName(),config:s}),Object.assign(Object.assign(Object.assign({},s),e),n)}static fromConfig(e,n,s={}){const r=n.cell,o=Cr(r,s);return new e(Object.assign(n,{cell:o}))}}qo.className="RNN";Y(qo);class Dm extends Ae{}class iv extends Dm{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,qt(this.units,"units"),this.activation=zo(e.activation==null?this.DEFAULT_ACTIVATION:e.activation),this.useBias=e.useBias==null?!0:e.useBias,this.kernelInitializer=ft(e.kernelInitializer||this.DEFAULT_KERNEL_INITIALIZER),this.recurrentInitializer=ft(e.recurrentInitializer||this.DEFAULT_RECURRENT_INITIALIZER),this.biasInitializer=ft(e.biasInitializer||this.DEFAULT_BIAS_INITIALIZER),this.kernelRegularizer=pt(e.kernelRegularizer),this.recurrentRegularizer=pt(e.recurrentRegularizer),this.biasRegularizer=pt(e.biasRegularizer),this.kernelConstraint=Bt(e.kernelConstraint),this.recurrentConstraint=Bt(e.recurrentConstraint),this.biasConstraint=Bt(e.biasConstraint),this.dropout=ll([1,_o([0,e.dropout==null?0:e.dropout])]),this.recurrentDropout=ll([1,_o([0,e.recurrentDropout==null?0:e.recurrentDropout])]),this.dropoutFunc=e.dropoutFunc,this.stateSize=this.units,this.dropoutMask=null,this.recurrentDropoutMask=null}build(e){e=Pe(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,n){return P(()=>{if(e=e,e.length!==2)throw new E(`SimpleRNNCell expects 2 input Tensors, got ${e.length}.`);let s=e[1];e=e[0];const r=n.training==null?!1:n.training;0Rs(e),rate:this.dropout,training:r,dropoutFunc:this.dropoutFunc})),0Rs(s),rate:this.recurrentDropout,training:r,dropoutFunc:this.dropoutFunc}));let o;const i=this.dropoutMask,a=this.recurrentDropoutMask;i!=null?o=br(D(e,i),this.kernel.read()):o=br(e,this.kernel.read()),this.bias!=null&&(o=sr(o,this.bias.read())),a!=null&&(s=D(s,a));let l=J(o,br(s,this.recurrentKernel.read()));return this.activation!=null&&(l=this.activation.apply(l)),[l,l]})}getConfig(){const e=super.getConfig(),n={units:this.units,activation:Fo(this.activation),useBias:this.useBias,kernelInitializer:xt(this.kernelInitializer),recurrentInitializer:xt(this.recurrentInitializer),biasInitializer:xt(this.biasInitializer),kernelRegularizer:Je(this.kernelRegularizer),recurrentRegularizer:Je(this.recurrentRegularizer),biasRegularizer:Je(this.biasRegularizer),activityRegularizer:Je(this.activityRegularizer),kernelConstraint:Lt(this.kernelConstraint),recurrentConstraint:Lt(this.recurrentConstraint),biasConstraint:Lt(this.biasConstraint),dropout:this.dropout,recurrentDropout:this.recurrentDropout};return Object.assign(Object.assign({},e),n)}}iv.className="SimpleRNNCell";Y(iv);class DE extends qo{constructor(e){e.cell=new iv(e),super(e)}call(e,n){return P(()=>{this.cell.dropoutMask!=null&&($e(this.cell.dropoutMask),this.cell.dropoutMask=null),this.cell.recurrentDropoutMask!=null&&($e(this.cell.recurrentDropoutMask),this.cell.recurrentDropoutMask=null);const s=n==null?null:n.mask,r=n==null?null:n.training,o=n==null?null:n.initialState;return super.call(e,{mask:s,training:r,initialState:o})})}static fromConfig(e,n){return new e(n)}}DE.className="SimpleRNN";Y(DE);class av extends Dm{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 E("GRUCell does not support reset_after parameter set to true.");this.units=e.units,qt(this.units,"units"),this.activation=zo(e.activation===void 0?this.DEFAULT_ACTIVATION:e.activation),this.recurrentActivation=zo(e.recurrentActivation===void 0?this.DEFAULT_RECURRENT_ACTIVATION:e.recurrentActivation),this.useBias=e.useBias==null?!0:e.useBias,this.kernelInitializer=ft(e.kernelInitializer||this.DEFAULT_KERNEL_INITIALIZER),this.recurrentInitializer=ft(e.recurrentInitializer||this.DEFAULT_RECURRENT_INITIALIZER),this.biasInitializer=ft(e.biasInitializer||this.DEFAULT_BIAS_INITIALIZER),this.kernelRegularizer=pt(e.kernelRegularizer),this.recurrentRegularizer=pt(e.recurrentRegularizer),this.biasRegularizer=pt(e.biasRegularizer),this.kernelConstraint=Bt(e.kernelConstraint),this.recurrentConstraint=Bt(e.recurrentConstraint),this.biasConstraint=Bt(e.biasConstraint),this.dropout=ll([1,_o([0,e.dropout==null?0:e.dropout])]),this.recurrentDropout=ll([1,_o([0,e.recurrentDropout==null?0:e.recurrentDropout])]),this.dropoutFunc=e.dropoutFunc,this.implementation=e.implementation,this.stateSize=this.units,this.dropoutMask=null,this.recurrentDropoutMask=null}build(e){e=Pe(e);const n=e[e.length-1];this.kernel=this.addWeight("kernel",[n,this.units*3],null,this.kernelInitializer,this.kernelRegularizer,!0,this.kernelConstraint),this.recurrentKernel=this.addWeight("recurrent_kernel",[this.units,this.units*3],null,this.recurrentInitializer,this.recurrentRegularizer,!0,this.recurrentConstraint),this.useBias?this.bias=this.addWeight("bias",[this.units*3],null,this.biasInitializer,this.biasRegularizer,!0,this.biasConstraint):this.bias=null,this.built=!0}call(e,n){return P(()=>{if(e=e,e.length!==2)throw new E(`GRUCell expects 2 input Tensors (inputs, h, c), got ${e.length}.`);const s=n.training==null?!1:n.training;let r=e[1];e=e[0],0Rs(e),rate:this.dropout,training:s,count:3,dropoutFunc:this.dropoutFunc})),0Rs(r),rate:this.recurrentDropout,training:s,count:3,dropoutFunc:this.dropoutFunc}));const o=this.dropoutMask,i=this.recurrentDropoutMask;let a,l,c;0{this.cell.dropoutMask!=null&&($e(this.cell.dropoutMask),this.cell.dropoutMask=null),this.cell.recurrentDropoutMask!=null&&($e(this.cell.recurrentDropoutMask),this.cell.recurrentDropoutMask=null);const s=n==null?null:n.mask,r=n==null?null:n.training,o=n==null?null:n.initialState;return super.call(e,{mask:s,training:r,initialState:o})})}static fromConfig(e,n){return n.implmentation===0&&(n.implementation=1),new e(n)}}_E.className="GRU";Y(_E);class _m extends Dm{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,qt(this.units,"units"),this.activation=zo(e.activation===void 0?this.DEFAULT_ACTIVATION:e.activation),this.recurrentActivation=zo(e.recurrentActivation===void 0?this.DEFAULT_RECURRENT_ACTIVATION:e.recurrentActivation),this.useBias=e.useBias==null?!0:e.useBias,this.kernelInitializer=ft(e.kernelInitializer||this.DEFAULT_KERNEL_INITIALIZER),this.recurrentInitializer=ft(e.recurrentInitializer||this.DEFAULT_RECURRENT_INITIALIZER),this.biasInitializer=ft(e.biasInitializer||this.DEFAULT_BIAS_INITIALIZER),this.unitForgetBias=e.unitForgetBias,this.kernelRegularizer=pt(e.kernelRegularizer),this.recurrentRegularizer=pt(e.recurrentRegularizer),this.biasRegularizer=pt(e.biasRegularizer),this.kernelConstraint=Bt(e.kernelConstraint),this.recurrentConstraint=Bt(e.recurrentConstraint),this.biasConstraint=Bt(e.biasConstraint),this.dropout=ll([1,_o([0,e.dropout==null?0:e.dropout])]),this.recurrentDropout=ll([1,_o([0,e.recurrentDropout==null?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 n;e=Pe(e);const s=e[e.length-1];this.kernel=this.addWeight("kernel",[s,this.units*4],null,this.kernelInitializer,this.kernelRegularizer,!0,this.kernelConstraint),this.recurrentKernel=this.addWeight("recurrent_kernel",[this.units,this.units*4],null,this.recurrentInitializer,this.recurrentRegularizer,!0,this.recurrentConstraint);let r;if(this.useBias){if(this.unitForgetBias){const o=this.biasInitializer,i=this.units;r=new(n=class extends Ds{apply(l,c){const u=o.apply([i]),h=new Kw().apply([i]),d=o.apply([i*2]);return KC(KC(u,h),d)}},n.className="CustomInit",n)}else r=this.biasInitializer;this.bias=this.addWeight("bias",[this.units*4],null,r,this.biasRegularizer,!0,this.biasConstraint)}else this.bias=null;this.built=!0}call(e,n){return P(()=>{const s=n.training==null?!1:n.training;if(e=e,e.length!==3)throw new E(`LSTMCell expects 3 input Tensors (inputs, h, c), got ${e.length}.`);let r=e[1];const o=e[2];e=e[0],0Rs(e),rate:this.dropout,training:s,count:4,dropoutFunc:this.dropoutFunc})),0Rs(r),rate:this.recurrentDropout,training:s,count:4,dropoutFunc:this.dropoutFunc}));const i=this.dropoutMask,a=this.recurrentDropoutMask;let l,c,u,h;0{this.cell.dropoutMask!=null&&($e(this.cell.dropoutMask),this.cell.dropoutMask=null),this.cell.recurrentDropoutMask!=null&&($e(this.cell.recurrentDropoutMask),this.cell.recurrentDropoutMask=null);const s=n==null?null:n.mask,r=n==null?null:n.training,o=n==null?null:n.initialState;return super.call(e,{mask:s,training:r,initialState:o})})}static fromConfig(e,n){return n.implmentation===0&&(n.implementation=1),new e(n)}}FE.className="LSTM";Y(FE);class lv extends Dm{constructor(e){super(e),this.cells=e.cells}get stateSize(){const e=[];for(const n of this.cells.slice().reverse())Array.isArray(n.stateSize)?e.push(...n.stateSize):e.push(n.stateSize);return e}call(e,n){return P(()=>{e=e;let s=e.slice(1);const r=[];for(const a of this.cells.slice().reverse())Array.isArray(a.stateSize)?r.push(s.splice(0,a.stateSize.length)):r.push(s.splice(0,1));r.reverse();const o=[];let i;for(let a=0;a{bi(`RNNCell_${r}`,()=>{s.build(e),Array.isArray(s.stateSize)?n=s.stateSize[0]:n=s.stateSize,e=[e[0],n]})}),this.built=!0}getConfig(){const e=super.getConfig(),n=o=>({className:o.getClassName(),config:o.getConfig()}),r={cells:this.cells.map(n)};return Object.assign(Object.assign({},e),r)}static fromConfig(e,n,s={}){const r=[];for(const o of n.cells)r.push(Cr(o,s));return new e({cells:r})}get trainableWeights(){if(!this.trainable)return[];const e=[];for(const n of this.cells)e.push(...n.trainableWeights);return e}get nonTrainableWeights(){const e=[];for(const n of this.cells)e.push(...n.nonTrainableWeights);if(!this.trainable){const n=[];for(const s of this.cells)n.push(...s.trainableWeights);return n.concat(e)}return e}getWeights(){const e=[];for(const n of this.cells)e.push(...n.weights);return v1(e)}setWeights(e){const n=[];for(const s of this.cells){const r=s.weights.length,o=e.splice(r);for(let i=0;io!=null?o(e(),n):IT(e(),n),a=()=>Ch(i,e,s);return!r||r<=1?yr(a().clone()):Array(r).fill(void 0).map(a).map(c=>yr(c.clone()))}/** + */function RE(t,e,n,s){if(Array.isArray(t)){if(e!=null||n!=null)throw new E("When inputs is an array, neither initialState or constants should be provided");s!=null&&(n=t.slice(t.length-s,t.length),t=t.slice(0,t.length-s)),t.length>1&&(e=t.slice(1,t.length)),t=t[0]}function r(o){return o==null||Array.isArray(o)?o:[o]}return e=r(e),n=r(n),{inputs:t,initialState:e,constants:n}}function AE(t,e,n,s=!1,r,o,i=!1,a=!1){return P(()=>{const l=e.shape.length;if(l<3)throw new E(`Input should be at least 3D, but is ${l}D.`);const c=[1,0].concat(Js(2,l));e=Fe(e,c),i&&console.warn("Backend rnn(): the unroll = true option is not applicable to the imperative deeplearn.js backend."),r!=null&&(r=le(le(r,"bool"),"float32"),r.rank===l-1&&(r=En(r,-1)),r=Fe(r,c)),s&&(e=Mi(e,0),r!=null&&(r=Mi(r,0)));const u=[];let h,d=n;const f=e.shape[0],p=Pi(e);let g;r!=null&&(g=Pi(r));for(let m=0;mt(y,d));if(r==null)h=w[0],d=w[1];else{const v=P(()=>{const b=g[m],C=ve(Rs(b),b),k=J(D(w[0],b),D(d[0],C)),S=d.map(($,N)=>J(D(w[1][N],b),D($,C)));return{output:k,newStates:S}});h=v.output,d=v.newStates}a&&u.push(h)}let x;return a&&(x=Hr(u,1)),[h,x,d]})}class qo extends Ae{constructor(e){super(e);let n;if(e.cell==null)throw new E("cell property is missing for the constructor of RNN.");if(Array.isArray(e.cell)?n=new lv({cells:e.cell}):n=e.cell,n.stateSize==null)throw new E("The RNN cell should have an attribute `stateSize` (tuple of integers, one integer per RNN state).");this.cell=n,this.returnSequences=e.returnSequences==null?!1:e.returnSequences,this.returnState=e.returnState==null?!1:e.returnState,this.goBackwards=e.goBackwards==null?!1:e.goBackwards,this._stateful=e.stateful==null?!1:e.stateful,this.unroll=e.unroll==null?!1:e.unroll,this.supportsMasking=!0,this.inputSpec=[new Pt({ndim:3})],this.stateSpec=null,this.states_=null,this.numConstants=null,this.keptStates=[]}getStates(){if(this.states_==null){const e=Array.isArray(this.cell.stateSize)?this.cell.stateSize.length:1;return Js(0,e).map(n=>null)}else return this.states_}setStates(e){this.states_=e}computeOutputShape(e){w1(e)&&(e=e[0]),e=e;let n=this.cell.stateSize;Array.isArray(n)||(n=[n]);const s=n[0];let r;if(this.returnSequences?r=[e[0],e[1],s]:r=[e[0],s],this.returnState){const o=[];for(const i of n)o.push([e[0],i]);return[r].concat(o)}else return r}computeMask(e,n){return P(()=>{Array.isArray(n)&&(n=n[0]);const s=this.returnSequences?n:null;if(this.returnState){const r=this.states.map(o=>null);return[s].concat(r)}else return s})}get states(){if(this.states_==null){const e=Array.isArray(this.cell.stateSize)?this.cell.stateSize.length:1,n=[];for(let s=0;si.shape[i.shape.length-1]),o))throw new E(`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=o.map(i=>new Pt({shape:[null,i]}));this.stateful&&this.resetStates()}resetStates(e,n=!1){P(()=>{if(!this.stateful)throw new ur("Cannot call resetStates() on an RNN Layer that is not stateful.");const s=this.inputSpec[0].shape[0];if(s==null)throw new E("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(this.states_==null)Array.isArray(this.cell.stateSize)?this.states_=this.cell.stateSize.map(r=>Kt([s,r])):this.states_=[Kt([s,this.cell.stateSize])];else if(e==null)$e(this.states_),this.keptStates!=null&&($e(this.keptStates),this.keptStates=[]),Array.isArray(this.cell.stateSize)?this.states_=this.cell.stateSize.map(r=>Kt([s,r])):this.states_[0]=Kt([s,this.cell.stateSize]);else{if(Array.isArray(e)||(e=[e]),e.length!==this.states_.length)throw new E(`Layer ${this.name} expects ${this.states_.length} state(s), but it received ${e.length} state value(s). Input received: ${e}`);n===!0?this.keptStates.push(this.states_.slice()):$e(this.states_);for(let r=0;ryr(r.clone()))})}apply(e,n){let s=n==null?null:n.initialState,r=n==null?null:n.constants;n==null&&(n={});const o=RE(e,s,r,this.numConstants);e=o.inputs,s=o.initialState,r=o.constants;let i=[],a=[];if(s!=null){n.initialState=s,i=i.concat(s),this.stateSpec=[];for(const c of s)this.stateSpec.push(new Pt({shape:c.shape}));a=a.concat(this.stateSpec)}if(r!=null&&(n.constants=r,i=i.concat(r),this.numConstants=r.length),i[0]instanceof $r){const c=[e].concat(i),u=this.inputSpec.concat(a),h=this.inputSpec;this.inputSpec=u;const d=super.apply(c,n);return this.inputSpec=h,d}else return super.apply(e,n)}call(e,n){return P(()=>{const s=n==null?null:n.mask,r=n==null?null:n.training;let o=n==null?null:n.initialState;e=Ce(e),o==null&&(this.stateful?o=this.states_:o=this.getInitialState(e));const i=Array.isArray(this.cell.stateSize)?this.cell.stateSize.length:1;if(o.length!==i)throw new E(`RNN Layer has ${i} state(s) but was passed ${o.length} initial state(s).`);this.unroll&&console.warn("Ignoring unroll = true for RNN layer, due to imperative backend.");const a={training:r},c=AE((p,g)=>{const x=this.cell.call([p].concat(g),a);return[x[0],x.slice(1)]},e,o,this.goBackwards,s,null,this.unroll,this.returnSequences),u=c[0],h=c[1],d=c[2];this.stateful&&this.resetStates(d,r);const f=this.returnSequences?h:u;return this.returnState?[f].concat(d):f})}getInitialState(e){return P(()=>{let n=Kt(e.shape);return n=me(n,[1,2]),n=wh(n),Array.isArray(this.cell.stateSize)?this.cell.stateSize.map(s=>s>1?x1(n,[1,s]):n):this.cell.stateSize>1?[x1(n,[1,this.cell.stateSize])]:[n]})}get trainableWeights(){return this.trainable?this.cell.trainableWeights:[]}get nonTrainableWeights(){return this.trainable?this.cell.nonTrainableWeights:this.cell.weights}setFastWeightInitDuringBuild(e){super.setFastWeightInitDuringBuild(e),this.cell!=null&&this.cell.setFastWeightInitDuringBuild(e)}getConfig(){const e=super.getConfig(),n={returnSequences:this.returnSequences,returnState:this.returnState,goBackwards:this.goBackwards,stateful:this.stateful,unroll:this.unroll};this.numConstants!=null&&(n.numConstants=this.numConstants);const s=this.cell.getConfig();return this.getClassName()===qo.className&&(n.cell={className:this.cell.getClassName(),config:s}),Object.assign(Object.assign(Object.assign({},s),e),n)}static fromConfig(e,n,s={}){const r=n.cell,o=Cr(r,s);return new e(Object.assign(n,{cell:o}))}}qo.className="RNN";Y(qo);class Dm extends Ae{}class iv extends Dm{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,qt(this.units,"units"),this.activation=zo(e.activation==null?this.DEFAULT_ACTIVATION:e.activation),this.useBias=e.useBias==null?!0:e.useBias,this.kernelInitializer=ft(e.kernelInitializer||this.DEFAULT_KERNEL_INITIALIZER),this.recurrentInitializer=ft(e.recurrentInitializer||this.DEFAULT_RECURRENT_INITIALIZER),this.biasInitializer=ft(e.biasInitializer||this.DEFAULT_BIAS_INITIALIZER),this.kernelRegularizer=pt(e.kernelRegularizer),this.recurrentRegularizer=pt(e.recurrentRegularizer),this.biasRegularizer=pt(e.biasRegularizer),this.kernelConstraint=Bt(e.kernelConstraint),this.recurrentConstraint=Bt(e.recurrentConstraint),this.biasConstraint=Bt(e.biasConstraint),this.dropout=ll([1,_o([0,e.dropout==null?0:e.dropout])]),this.recurrentDropout=ll([1,_o([0,e.recurrentDropout==null?0:e.recurrentDropout])]),this.dropoutFunc=e.dropoutFunc,this.stateSize=this.units,this.dropoutMask=null,this.recurrentDropoutMask=null}build(e){e=Pe(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,n){return P(()=>{if(e=e,e.length!==2)throw new E(`SimpleRNNCell expects 2 input Tensors, got ${e.length}.`);let s=e[1];e=e[0];const r=n.training==null?!1:n.training;0Rs(e),rate:this.dropout,training:r,dropoutFunc:this.dropoutFunc})),0Rs(s),rate:this.recurrentDropout,training:r,dropoutFunc:this.dropoutFunc}));let o;const i=this.dropoutMask,a=this.recurrentDropoutMask;i!=null?o=br(D(e,i),this.kernel.read()):o=br(e,this.kernel.read()),this.bias!=null&&(o=sr(o,this.bias.read())),a!=null&&(s=D(s,a));let l=J(o,br(s,this.recurrentKernel.read()));return this.activation!=null&&(l=this.activation.apply(l)),[l,l]})}getConfig(){const e=super.getConfig(),n={units:this.units,activation:Fo(this.activation),useBias:this.useBias,kernelInitializer:xt(this.kernelInitializer),recurrentInitializer:xt(this.recurrentInitializer),biasInitializer:xt(this.biasInitializer),kernelRegularizer:Je(this.kernelRegularizer),recurrentRegularizer:Je(this.recurrentRegularizer),biasRegularizer:Je(this.biasRegularizer),activityRegularizer:Je(this.activityRegularizer),kernelConstraint:Lt(this.kernelConstraint),recurrentConstraint:Lt(this.recurrentConstraint),biasConstraint:Lt(this.biasConstraint),dropout:this.dropout,recurrentDropout:this.recurrentDropout};return Object.assign(Object.assign({},e),n)}}iv.className="SimpleRNNCell";Y(iv);class DE extends qo{constructor(e){e.cell=new iv(e),super(e)}call(e,n){return P(()=>{this.cell.dropoutMask!=null&&($e(this.cell.dropoutMask),this.cell.dropoutMask=null),this.cell.recurrentDropoutMask!=null&&($e(this.cell.recurrentDropoutMask),this.cell.recurrentDropoutMask=null);const s=n==null?null:n.mask,r=n==null?null:n.training,o=n==null?null:n.initialState;return super.call(e,{mask:s,training:r,initialState:o})})}static fromConfig(e,n){return new e(n)}}DE.className="SimpleRNN";Y(DE);class av extends Dm{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 E("GRUCell does not support reset_after parameter set to true.");this.units=e.units,qt(this.units,"units"),this.activation=zo(e.activation===void 0?this.DEFAULT_ACTIVATION:e.activation),this.recurrentActivation=zo(e.recurrentActivation===void 0?this.DEFAULT_RECURRENT_ACTIVATION:e.recurrentActivation),this.useBias=e.useBias==null?!0:e.useBias,this.kernelInitializer=ft(e.kernelInitializer||this.DEFAULT_KERNEL_INITIALIZER),this.recurrentInitializer=ft(e.recurrentInitializer||this.DEFAULT_RECURRENT_INITIALIZER),this.biasInitializer=ft(e.biasInitializer||this.DEFAULT_BIAS_INITIALIZER),this.kernelRegularizer=pt(e.kernelRegularizer),this.recurrentRegularizer=pt(e.recurrentRegularizer),this.biasRegularizer=pt(e.biasRegularizer),this.kernelConstraint=Bt(e.kernelConstraint),this.recurrentConstraint=Bt(e.recurrentConstraint),this.biasConstraint=Bt(e.biasConstraint),this.dropout=ll([1,_o([0,e.dropout==null?0:e.dropout])]),this.recurrentDropout=ll([1,_o([0,e.recurrentDropout==null?0:e.recurrentDropout])]),this.dropoutFunc=e.dropoutFunc,this.implementation=e.implementation,this.stateSize=this.units,this.dropoutMask=null,this.recurrentDropoutMask=null}build(e){e=Pe(e);const n=e[e.length-1];this.kernel=this.addWeight("kernel",[n,this.units*3],null,this.kernelInitializer,this.kernelRegularizer,!0,this.kernelConstraint),this.recurrentKernel=this.addWeight("recurrent_kernel",[this.units,this.units*3],null,this.recurrentInitializer,this.recurrentRegularizer,!0,this.recurrentConstraint),this.useBias?this.bias=this.addWeight("bias",[this.units*3],null,this.biasInitializer,this.biasRegularizer,!0,this.biasConstraint):this.bias=null,this.built=!0}call(e,n){return P(()=>{if(e=e,e.length!==2)throw new E(`GRUCell expects 2 input Tensors (inputs, h, c), got ${e.length}.`);const s=n.training==null?!1:n.training;let r=e[1];e=e[0],0Rs(e),rate:this.dropout,training:s,count:3,dropoutFunc:this.dropoutFunc})),0Rs(r),rate:this.recurrentDropout,training:s,count:3,dropoutFunc:this.dropoutFunc}));const o=this.dropoutMask,i=this.recurrentDropoutMask;let a,l,c;0{this.cell.dropoutMask!=null&&($e(this.cell.dropoutMask),this.cell.dropoutMask=null),this.cell.recurrentDropoutMask!=null&&($e(this.cell.recurrentDropoutMask),this.cell.recurrentDropoutMask=null);const s=n==null?null:n.mask,r=n==null?null:n.training,o=n==null?null:n.initialState;return super.call(e,{mask:s,training:r,initialState:o})})}static fromConfig(e,n){return n.implmentation===0&&(n.implementation=1),new e(n)}}_E.className="GRU";Y(_E);class _m extends Dm{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,qt(this.units,"units"),this.activation=zo(e.activation===void 0?this.DEFAULT_ACTIVATION:e.activation),this.recurrentActivation=zo(e.recurrentActivation===void 0?this.DEFAULT_RECURRENT_ACTIVATION:e.recurrentActivation),this.useBias=e.useBias==null?!0:e.useBias,this.kernelInitializer=ft(e.kernelInitializer||this.DEFAULT_KERNEL_INITIALIZER),this.recurrentInitializer=ft(e.recurrentInitializer||this.DEFAULT_RECURRENT_INITIALIZER),this.biasInitializer=ft(e.biasInitializer||this.DEFAULT_BIAS_INITIALIZER),this.unitForgetBias=e.unitForgetBias,this.kernelRegularizer=pt(e.kernelRegularizer),this.recurrentRegularizer=pt(e.recurrentRegularizer),this.biasRegularizer=pt(e.biasRegularizer),this.kernelConstraint=Bt(e.kernelConstraint),this.recurrentConstraint=Bt(e.recurrentConstraint),this.biasConstraint=Bt(e.biasConstraint),this.dropout=ll([1,_o([0,e.dropout==null?0:e.dropout])]),this.recurrentDropout=ll([1,_o([0,e.recurrentDropout==null?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 n;e=Pe(e);const s=e[e.length-1];this.kernel=this.addWeight("kernel",[s,this.units*4],null,this.kernelInitializer,this.kernelRegularizer,!0,this.kernelConstraint),this.recurrentKernel=this.addWeight("recurrent_kernel",[this.units,this.units*4],null,this.recurrentInitializer,this.recurrentRegularizer,!0,this.recurrentConstraint);let r;if(this.useBias){if(this.unitForgetBias){const o=this.biasInitializer,i=this.units;r=new(n=class extends Ds{apply(l,c){const u=o.apply([i]),h=new Kw().apply([i]),d=o.apply([i*2]);return KC(KC(u,h),d)}},n.className="CustomInit",n)}else r=this.biasInitializer;this.bias=this.addWeight("bias",[this.units*4],null,r,this.biasRegularizer,!0,this.biasConstraint)}else this.bias=null;this.built=!0}call(e,n){return P(()=>{const s=n.training==null?!1:n.training;if(e=e,e.length!==3)throw new E(`LSTMCell expects 3 input Tensors (inputs, h, c), got ${e.length}.`);let r=e[1];const o=e[2];e=e[0],0Rs(e),rate:this.dropout,training:s,count:4,dropoutFunc:this.dropoutFunc})),0Rs(r),rate:this.recurrentDropout,training:s,count:4,dropoutFunc:this.dropoutFunc}));const i=this.dropoutMask,a=this.recurrentDropoutMask;let l,c,u,h;0{this.cell.dropoutMask!=null&&($e(this.cell.dropoutMask),this.cell.dropoutMask=null),this.cell.recurrentDropoutMask!=null&&($e(this.cell.recurrentDropoutMask),this.cell.recurrentDropoutMask=null);const s=n==null?null:n.mask,r=n==null?null:n.training,o=n==null?null:n.initialState;return super.call(e,{mask:s,training:r,initialState:o})})}static fromConfig(e,n){return n.implmentation===0&&(n.implementation=1),new e(n)}}FE.className="LSTM";Y(FE);class lv extends Dm{constructor(e){super(e),this.cells=e.cells}get stateSize(){const e=[];for(const n of this.cells.slice().reverse())Array.isArray(n.stateSize)?e.push(...n.stateSize):e.push(n.stateSize);return e}call(e,n){return P(()=>{e=e;let s=e.slice(1);const r=[];for(const a of this.cells.slice().reverse())Array.isArray(a.stateSize)?r.push(s.splice(0,a.stateSize.length)):r.push(s.splice(0,1));r.reverse();const o=[];let i;for(let a=0;a{bi(`RNNCell_${r}`,()=>{s.build(e),Array.isArray(s.stateSize)?n=s.stateSize[0]:n=s.stateSize,e=[e[0],n]})}),this.built=!0}getConfig(){const e=super.getConfig(),n=o=>({className:o.getClassName(),config:o.getConfig()}),r={cells:this.cells.map(n)};return Object.assign(Object.assign({},e),r)}static fromConfig(e,n,s={}){const r=[];for(const o of n.cells)r.push(Cr(o,s));return new e({cells:r})}get trainableWeights(){if(!this.trainable)return[];const e=[];for(const n of this.cells)e.push(...n.trainableWeights);return e}get nonTrainableWeights(){const e=[];for(const n of this.cells)e.push(...n.nonTrainableWeights);if(!this.trainable){const n=[];for(const s of this.cells)n.push(...s.trainableWeights);return n.concat(e)}return e}getWeights(){const e=[];for(const n of this.cells)e.push(...n.weights);return v1(e)}setWeights(e){const n=[];for(const s of this.cells){const r=s.weights.length,o=e.splice(r);for(let i=0;io!=null?o(e(),n):IT(e(),n),a=()=>bh(i,e,s);return!r||r<=1?yr(a().clone()):Array(r).fill(void 0).map(a).map(c=>yr(c.clone()))}/** * @license * Copyright 2020 Google LLC * @@ -7889,7 +7889,7 @@ body { * license that can be found in the LICENSE file or at * https://opensource.org/licenses/MIT. * ============================================================================= - */var mH=function(t,e){var n={};for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&e.indexOf(s)<0&&(n[s]=t[s]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,s=Object.getOwnPropertySymbols(t);r{if(this.cell.dropoutMask!=null&&($e(this.cell.dropoutMask),this.cell.dropoutMask=null),this.cell.recurrentDropoutMask!=null&&($e(this.cell.recurrentDropoutMask),this.cell.recurrentDropoutMask=null),n&&n.constants)throw new E("ConvRNN2D cell does not support constants");const s=n==null?null:n.mask,r=n==null?null:n.training,o=n==null?null:n.initialState;return super.call(e,{mask:s,training:r,initialState:o})})}computeOutputShape(e){let n=this.computeSingleOutputShape(e);return this.returnSequences||(n=[n[0],...n.slice(2)]),this.returnState&&(n=[n,...Array(2).fill([e[0],...n.slice(-3)])]),n}getInitialState(e){return P(()=>{const{stateSize:n}=this.cell,s=e.shape,r=this.computeSingleOutputShape(s),o=[r[0],...r.slice(2)],i=Kt(o);return Array.isArray(n)?Array(n.length).fill(i):[i]})}resetStates(e,n=!1){P(()=>{if(!this.stateful)throw new ur("Cannot call resetStates() on an RNN Layer that is not stateful.");const s=this.inputSpec[0].shape,r=this.computeSingleOutputShape(s),o=[r[0],...r.slice(2)];if(s[0]==null)throw new E("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(this.getStates()==null)Array.isArray(this.cell.stateSize)?this.states_=this.cell.stateSize.map(()=>Kt(o)):this.states_=[Kt(o)];else if(e==null)$e(this.states_),this.keptStates!=null&&($e(this.keptStates),this.keptStates=[]),Array.isArray(this.cell.stateSize)?this.states_=this.cell.stateSize.map(()=>Kt(o)):this.states_[0]=Kt(o);else{if(Array.isArray(e)||(e=[e]),e.length!==this.states_.length)throw new E(`Layer ${this.name} expects ${this.states_.length} state(s), but it received ${e.length} state value(s). Input received: ${e}`);n?this.keptStates.push(this.states_.slice()):$e(this.states_);for(let a=0;ayr(a.clone()))})}computeSingleOutputShape(e){const{dataFormat:n,filters:s,kernelSize:r,padding:o,strides:i,dilationRate:a}=this.cell,l=n==="channelsFirst",c=e[l?3:2],u=e[l?4:3],h=Qs(c,r[0],o,i[0],a[0]),d=Qs(u,r[1],o,i[1],a[1]);return[...e.slice(0,2),...l?[s,h,d]:[h,d,s]]}}zE.className="ConvRNN2D";class cv extends _m{constructor(e){const{filters:n,kernelSize:s,strides:r,padding:o,dataFormat:i,dilationRate:a}=e;super(Object.assign(Object.assign({},e),{units:n})),this.filters=n,qt(this.filters,"filters"),this.kernelSize=Ba(s,2,"kernelSize"),this.kernelSize.forEach(l=>qt(l,"kernelSize")),this.strides=Ba(r||1,2,"strides"),this.strides.forEach(l=>qt(l,"strides")),this.padding=o||"valid",hs(this.padding),this.dataFormat=i||"channelsLast",Nt(this.dataFormat),this.dilationRate=Ba(a||1,2,"dilationRate"),this.dilationRate.forEach(l=>qt(l,"dilationRate"))}build(e){var n;e=Pe(e);const s=this.dataFormat==="channelsFirst"?1:e.length-1;if(e[s]==null)throw new E(`The channel dimension of the input should be defined. Found ${e[s]}`);const r=e[s],o=4,i=this.kernelSize.concat([r,this.filters*o]);this.kernel=this.addWeight("kernel",i,null,this.kernelInitializer,this.kernelRegularizer,!0,this.kernelConstraint);const a=this.kernelSize.concat([this.filters,this.filters*o]);if(this.recurrentKernel=this.addWeight("recurrent_kernel",a,null,this.recurrentInitializer,this.recurrentRegularizer,!0,this.recurrentConstraint),this.useBias){let l;if(this.unitForgetBias){const c=this.biasInitializer,u=this.filters;l=new(n=class extends Ds{apply(d,f){const p=c.apply([u]),g=Ko([u]),x=c.apply([u*2]);return jw([p,g,x])}},n.className="CustomInit",n)}else l=this.biasInitializer;this.bias=this.addWeight("bias",[this.filters*o],null,l,this.biasRegularizer,!0,this.biasConstraint)}this.built=!0}call(e,n){return P(()=>{if(e.length!==3)throw new E(`ConvLSTM2DCell expects 3 input Tensors (inputs, h, c), got ${e.length}.`);const s=n.training||!1,r=e[0],o=e[1],i=e[2],a=4;0Rs(r),rate:this.dropout,training:s,count:a,dropoutFunc:this.dropoutFunc}));const l=this.dropoutMask,c=(G,X,q)=>!X||!X[q]?G:D(X[q],G);let u=c(r,l,0),h=c(r,l,1),d=c(r,l,2),f=c(r,l,3);0Rs(o),rate:this.recurrentDropout,training:s,count:a,dropoutFunc:this.dropoutFunc}));const p=this.recurrentDropoutMask;let g=c(o,p,0),x=c(o,p,1),m=c(o,p,2),y=c(o,p,3);const w=3,[v,b,C,k]=rs(this.kernel.read(),a,w),[S,$,N,A]=this.useBias?rs(this.bias.read(),a):[null,null,null,null];u=this.inputConv(u,v,S,this.padding),h=this.inputConv(h,b,$,this.padding),d=this.inputConv(d,C,N,this.padding),f=this.inputConv(f,k,A,this.padding);const[M,L,V,B]=rs(this.recurrentKernel.read(),a,w);g=this.recurrentConv(g,M),x=this.recurrentConv(x,L),m=this.recurrentConv(m,V),y=this.recurrentConv(y,B);const U=this.recurrentActivation.apply(J(u,g)),K=this.recurrentActivation.apply(J(h,x)),R=J(D(K,i),D(U,this.activation.apply(J(d,m)))),O=D(this.recurrentActivation.apply(J(f,y)),this.activation.apply(R));return[O,O,R]})}getConfig(){const e=super.getConfig(),n=mH(e,["units"]),s={filters:this.filters,kernelSize:this.kernelSize,padding:this.padding,dataFormat:this.dataFormat,dilationRate:this.dilationRate,strides:this.strides};return Object.assign(Object.assign({},n),s)}inputConv(e,n,s,r){const o=zi(e,n,this.strides,r||"valid",this.dataFormat==="channelsFirst"?"NCHW":"NHWC",this.dilationRate);return s?sr(o,s,this.dataFormat):o}recurrentConv(e,n){return zi(e,n,1,"same",this.dataFormat==="channelsFirst"?"NCHW":"NHWC")}}cv.className="ConvLSTM2DCell";Y(cv);class OE extends zE{constructor(e){const n=new cv(e);super(Object.assign(Object.assign({},e),{cell:n}))}static fromConfig(e,n){return new e(n)}}OE.className="ConvLSTM2D";Y(OE);/** + */var pH=function(t,e){var n={};for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&e.indexOf(s)<0&&(n[s]=t[s]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,s=Object.getOwnPropertySymbols(t);r{if(this.cell.dropoutMask!=null&&($e(this.cell.dropoutMask),this.cell.dropoutMask=null),this.cell.recurrentDropoutMask!=null&&($e(this.cell.recurrentDropoutMask),this.cell.recurrentDropoutMask=null),n&&n.constants)throw new E("ConvRNN2D cell does not support constants");const s=n==null?null:n.mask,r=n==null?null:n.training,o=n==null?null:n.initialState;return super.call(e,{mask:s,training:r,initialState:o})})}computeOutputShape(e){let n=this.computeSingleOutputShape(e);return this.returnSequences||(n=[n[0],...n.slice(2)]),this.returnState&&(n=[n,...Array(2).fill([e[0],...n.slice(-3)])]),n}getInitialState(e){return P(()=>{const{stateSize:n}=this.cell,s=e.shape,r=this.computeSingleOutputShape(s),o=[r[0],...r.slice(2)],i=Kt(o);return Array.isArray(n)?Array(n.length).fill(i):[i]})}resetStates(e,n=!1){P(()=>{if(!this.stateful)throw new ur("Cannot call resetStates() on an RNN Layer that is not stateful.");const s=this.inputSpec[0].shape,r=this.computeSingleOutputShape(s),o=[r[0],...r.slice(2)];if(s[0]==null)throw new E("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(this.getStates()==null)Array.isArray(this.cell.stateSize)?this.states_=this.cell.stateSize.map(()=>Kt(o)):this.states_=[Kt(o)];else if(e==null)$e(this.states_),this.keptStates!=null&&($e(this.keptStates),this.keptStates=[]),Array.isArray(this.cell.stateSize)?this.states_=this.cell.stateSize.map(()=>Kt(o)):this.states_[0]=Kt(o);else{if(Array.isArray(e)||(e=[e]),e.length!==this.states_.length)throw new E(`Layer ${this.name} expects ${this.states_.length} state(s), but it received ${e.length} state value(s). Input received: ${e}`);n?this.keptStates.push(this.states_.slice()):$e(this.states_);for(let a=0;ayr(a.clone()))})}computeSingleOutputShape(e){const{dataFormat:n,filters:s,kernelSize:r,padding:o,strides:i,dilationRate:a}=this.cell,l=n==="channelsFirst",c=e[l?3:2],u=e[l?4:3],h=Qs(c,r[0],o,i[0],a[0]),d=Qs(u,r[1],o,i[1],a[1]);return[...e.slice(0,2),...l?[s,h,d]:[h,d,s]]}}zE.className="ConvRNN2D";class cv extends _m{constructor(e){const{filters:n,kernelSize:s,strides:r,padding:o,dataFormat:i,dilationRate:a}=e;super(Object.assign(Object.assign({},e),{units:n})),this.filters=n,qt(this.filters,"filters"),this.kernelSize=Ba(s,2,"kernelSize"),this.kernelSize.forEach(l=>qt(l,"kernelSize")),this.strides=Ba(r||1,2,"strides"),this.strides.forEach(l=>qt(l,"strides")),this.padding=o||"valid",hs(this.padding),this.dataFormat=i||"channelsLast",Nt(this.dataFormat),this.dilationRate=Ba(a||1,2,"dilationRate"),this.dilationRate.forEach(l=>qt(l,"dilationRate"))}build(e){var n;e=Pe(e);const s=this.dataFormat==="channelsFirst"?1:e.length-1;if(e[s]==null)throw new E(`The channel dimension of the input should be defined. Found ${e[s]}`);const r=e[s],o=4,i=this.kernelSize.concat([r,this.filters*o]);this.kernel=this.addWeight("kernel",i,null,this.kernelInitializer,this.kernelRegularizer,!0,this.kernelConstraint);const a=this.kernelSize.concat([this.filters,this.filters*o]);if(this.recurrentKernel=this.addWeight("recurrent_kernel",a,null,this.recurrentInitializer,this.recurrentRegularizer,!0,this.recurrentConstraint),this.useBias){let l;if(this.unitForgetBias){const c=this.biasInitializer,u=this.filters;l=new(n=class extends Ds{apply(d,f){const p=c.apply([u]),g=Ko([u]),x=c.apply([u*2]);return jw([p,g,x])}},n.className="CustomInit",n)}else l=this.biasInitializer;this.bias=this.addWeight("bias",[this.filters*o],null,l,this.biasRegularizer,!0,this.biasConstraint)}this.built=!0}call(e,n){return P(()=>{if(e.length!==3)throw new E(`ConvLSTM2DCell expects 3 input Tensors (inputs, h, c), got ${e.length}.`);const s=n.training||!1,r=e[0],o=e[1],i=e[2],a=4;0Rs(r),rate:this.dropout,training:s,count:a,dropoutFunc:this.dropoutFunc}));const l=this.dropoutMask,c=(G,X,q)=>!X||!X[q]?G:D(X[q],G);let u=c(r,l,0),h=c(r,l,1),d=c(r,l,2),f=c(r,l,3);0Rs(o),rate:this.recurrentDropout,training:s,count:a,dropoutFunc:this.dropoutFunc}));const p=this.recurrentDropoutMask;let g=c(o,p,0),x=c(o,p,1),m=c(o,p,2),y=c(o,p,3);const w=3,[v,b,C,k]=rs(this.kernel.read(),a,w),[S,$,N,A]=this.useBias?rs(this.bias.read(),a):[null,null,null,null];u=this.inputConv(u,v,S,this.padding),h=this.inputConv(h,b,$,this.padding),d=this.inputConv(d,C,N,this.padding),f=this.inputConv(f,k,A,this.padding);const[M,L,V,B]=rs(this.recurrentKernel.read(),a,w);g=this.recurrentConv(g,M),x=this.recurrentConv(x,L),m=this.recurrentConv(m,V),y=this.recurrentConv(y,B);const U=this.recurrentActivation.apply(J(u,g)),K=this.recurrentActivation.apply(J(h,x)),R=J(D(K,i),D(U,this.activation.apply(J(d,m)))),O=D(this.recurrentActivation.apply(J(f,y)),this.activation.apply(R));return[O,O,R]})}getConfig(){const e=super.getConfig(),n=pH(e,["units"]),s={filters:this.filters,kernelSize:this.kernelSize,padding:this.padding,dataFormat:this.dataFormat,dilationRate:this.dilationRate,strides:this.strides};return Object.assign(Object.assign({},n),s)}inputConv(e,n,s,r){const o=zi(e,n,this.strides,r||"valid",this.dataFormat==="channelsFirst"?"NCHW":"NHWC",this.dilationRate);return s?sr(o,s,this.dataFormat):o}recurrentConv(e,n){return zi(e,n,1,"same",this.dataFormat==="channelsFirst"?"NCHW":"NHWC")}}cv.className="ConvLSTM2DCell";Y(cv);class OE extends zE{constructor(e){const n=new cv(e);super(Object.assign(Object.assign({},e),{cell:n}))}static fromConfig(e,n){return new e(n)}}OE.className="ConvLSTM2D";Y(OE);/** * @license * Copyright 2018 Google LLC * @@ -7897,7 +7897,7 @@ body { * license that can be found in the LICENSE file or at * https://opensource.org/licenses/MIT. * ============================================================================= - */class uv extends Ae{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(this.noiseShape==null)return this.noiseShape;const n=e.shape,s=[];for(let r=0;r{this.invokeCallHook(e,n);const s=Ce(e);if(0IT(s,this.rate,o,this.seed),()=>s,r)}return e})}getConfig(){const e={rate:this.rate,noiseShape:this.noiseShape,seed:this.seed},n=super.getConfig();return Object.assign(e,n),e}dispose(){return super.dispose()}}uv.className="Dropout";Y(uv);class ME extends uv{constructor(e){super(e),this.inputSpec=[{ndim:3}]}getNoiseShape(e){const n=e.shape;return[n[0],1,n[2]]}}ME.className="SpatialDropout1D";Y(ME);class PE extends Ae{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",e.batchInputShape==null&&e.inputShape==null&&e.inputDim!=null){let n=null;e.batchSize!=null&&(n=e.batchSize),this.batchInputShape=[n,e.inputDim]}this.units=e.units,qt(this.units,"units"),this.activation=zo(e.activation),e.useBias!=null&&(this.useBias=e.useBias),this.kernelInitializer=ft(e.kernelInitializer||this.DEFAULT_KERNEL_INITIALIZER),this.biasInitializer=ft(e.biasInitializer||this.DEFAULT_BIAS_INITIALIZER),this.kernelConstraint=Bt(e.kernelConstraint),this.biasConstraint=Bt(e.biasConstraint),this.kernelRegularizer=pt(e.kernelRegularizer),this.biasRegularizer=pt(e.biasRegularizer),this.activityRegularizer=pt(e.activityRegularizer),this.supportsMasking=!0,this.inputSpec=[{minNDim:2}]}build(e){e=Pe(e);const n=e[e.length-1];this.kernel==null&&(this.kernel=this.addWeight("kernel",[n,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]:n}}],this.built=!0}computeOutputShape(e){e=Pe(e);const n=e.slice();return n[n.length-1]=this.units,n}call(e,n){return P(()=>{this.invokeCallHook(e,n);const s=Ce(e),r=yT(this.activation.getClassName());let o;return r!=null?o=br(s,this.kernel.read(),r,this.bias?this.bias.read():null):(o=br(s,this.kernel.read()),this.bias!=null&&(o=sr(o,this.bias.read())),this.activation!=null&&(o=this.activation.apply(o))),o})}getConfig(){const e={units:this.units,activation:Fo(this.activation),useBias:this.useBias,kernelInitializer:xt(this.kernelInitializer),biasInitializer:xt(this.biasInitializer),kernelRegularizer:Je(this.kernelRegularizer),biasRegularizer:Je(this.biasRegularizer),activityRegularizer:Je(this.activityRegularizer),kernelConstraint:Lt(this.kernelConstraint),biasConstraint:Lt(this.biasConstraint)},n=super.getConfig();return Object.assign(e,n),e}}PE.className="Dense";Y(PE);class LE extends Ae{constructor(e){e=e||{},super(e),this.inputSpec=[{minNDim:3}],this.dataFormat=e.dataFormat}computeOutputShape(e){e=Pe(e);for(const n of e.slice(1))if(n==null)throw new E(`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],Eo(e,1)]}call(e,n){return P(()=>{this.invokeCallHook(e,n);let s=Ce(e);if(this.dataFormat==="channelsFirst"&&s.rank>1){const r=[0];for(let o=2;o{this.invokeCallHook(e,n);const s=Ce(e);return this.activation.apply(s)})}getConfig(){const e={activation:Fo(this.activation)},n=super.getConfig();return Object.assign(e,n),e}}BE.className="Activation";Y(BE);class VE extends Ae{constructor(e){super(e),this.n=e.n,this.inputSpec=[{ndim:2}]}computeOutputShape(e){return[e[0],this.n,e[1]]}call(e,n){return P(()=>(e=Ce(e),G6(e,this.n)))}getConfig(){const e={n:this.n},n=super.getConfig();return Object.assign(e,n),e}}VE.className="RepeatVector";Y(VE);class WE extends Ae{constructor(e){super(e),this.targetShape=e.targetShape;for(let n=0;n{this.invokeCallHook(e,n);const s=Ce(e),r=s.shape,o=r.slice(0,1).concat(this.fixUnknownDimension(r.slice(1),this.targetShape));return F(s,o)})}getConfig(){const e={targetShape:this.targetShape},n=super.getConfig();return Object.assign(e,n),e}}WE.className="Reshape";Y(WE);class UE extends Ae{constructor(e){if(super(e),e.dims==null)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 n=Js(1,e.dims.length+1);if(!Ue(e.dims.slice().sort(),n))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 Pt({ndim:this.dims.length+1})]}computeOutputShape(e){e=Pe(e);const n=e.slice();return this.dims.forEach((s,r)=>{n[r+1]=e[s]}),n}call(e,n){return Fe(Ce(e),this.dimsIncludingBatch)}getConfig(){const e={dims:this.dims},n=super.getConfig();return Object.assign(e,n),e}}UE.className="Permute";Y(UE);class GE extends Ae{constructor(e){super(e??{}),this.supportsMasking=!0,e!=null?this.maskValue=e.maskValue==null?0:e.maskValue:this.maskValue=0}computeOutputShape(e){return e}getConfig(){const e=super.getConfig(),n={maskValue:this.maskValue};return Object.assign(n,e),n}computeMask(e,n){const s=Ce(e);return u1(bf(s,this.maskValue),-1)}call(e,n){return P(()=>{this.invokeCallHook(e,n);const s=Ce(e),i=u1(bf(s,this.maskValue),-1,!0);return D(s,le(i,s.dtype))})}}GE.className="Masking";Y(GE);/** + */class uv extends Ae{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(this.noiseShape==null)return this.noiseShape;const n=e.shape,s=[];for(let r=0;r{this.invokeCallHook(e,n);const s=Ce(e);if(0IT(s,this.rate,o,this.seed),()=>s,r)}return e})}getConfig(){const e={rate:this.rate,noiseShape:this.noiseShape,seed:this.seed},n=super.getConfig();return Object.assign(e,n),e}dispose(){return super.dispose()}}uv.className="Dropout";Y(uv);class ME extends uv{constructor(e){super(e),this.inputSpec=[{ndim:3}]}getNoiseShape(e){const n=e.shape;return[n[0],1,n[2]]}}ME.className="SpatialDropout1D";Y(ME);class PE extends Ae{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",e.batchInputShape==null&&e.inputShape==null&&e.inputDim!=null){let n=null;e.batchSize!=null&&(n=e.batchSize),this.batchInputShape=[n,e.inputDim]}this.units=e.units,qt(this.units,"units"),this.activation=zo(e.activation),e.useBias!=null&&(this.useBias=e.useBias),this.kernelInitializer=ft(e.kernelInitializer||this.DEFAULT_KERNEL_INITIALIZER),this.biasInitializer=ft(e.biasInitializer||this.DEFAULT_BIAS_INITIALIZER),this.kernelConstraint=Bt(e.kernelConstraint),this.biasConstraint=Bt(e.biasConstraint),this.kernelRegularizer=pt(e.kernelRegularizer),this.biasRegularizer=pt(e.biasRegularizer),this.activityRegularizer=pt(e.activityRegularizer),this.supportsMasking=!0,this.inputSpec=[{minNDim:2}]}build(e){e=Pe(e);const n=e[e.length-1];this.kernel==null&&(this.kernel=this.addWeight("kernel",[n,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]:n}}],this.built=!0}computeOutputShape(e){e=Pe(e);const n=e.slice();return n[n.length-1]=this.units,n}call(e,n){return P(()=>{this.invokeCallHook(e,n);const s=Ce(e),r=yT(this.activation.getClassName());let o;return r!=null?o=br(s,this.kernel.read(),r,this.bias?this.bias.read():null):(o=br(s,this.kernel.read()),this.bias!=null&&(o=sr(o,this.bias.read())),this.activation!=null&&(o=this.activation.apply(o))),o})}getConfig(){const e={units:this.units,activation:Fo(this.activation),useBias:this.useBias,kernelInitializer:xt(this.kernelInitializer),biasInitializer:xt(this.biasInitializer),kernelRegularizer:Je(this.kernelRegularizer),biasRegularizer:Je(this.biasRegularizer),activityRegularizer:Je(this.activityRegularizer),kernelConstraint:Lt(this.kernelConstraint),biasConstraint:Lt(this.biasConstraint)},n=super.getConfig();return Object.assign(e,n),e}}PE.className="Dense";Y(PE);class LE extends Ae{constructor(e){e=e||{},super(e),this.inputSpec=[{minNDim:3}],this.dataFormat=e.dataFormat}computeOutputShape(e){e=Pe(e);for(const n of e.slice(1))if(n==null)throw new E(`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],Eo(e,1)]}call(e,n){return P(()=>{this.invokeCallHook(e,n);let s=Ce(e);if(this.dataFormat==="channelsFirst"&&s.rank>1){const r=[0];for(let o=2;o{this.invokeCallHook(e,n);const s=Ce(e);return this.activation.apply(s)})}getConfig(){const e={activation:Fo(this.activation)},n=super.getConfig();return Object.assign(e,n),e}}BE.className="Activation";Y(BE);class VE extends Ae{constructor(e){super(e),this.n=e.n,this.inputSpec=[{ndim:2}]}computeOutputShape(e){return[e[0],this.n,e[1]]}call(e,n){return P(()=>(e=Ce(e),U6(e,this.n)))}getConfig(){const e={n:this.n},n=super.getConfig();return Object.assign(e,n),e}}VE.className="RepeatVector";Y(VE);class WE extends Ae{constructor(e){super(e),this.targetShape=e.targetShape;for(let n=0;n{this.invokeCallHook(e,n);const s=Ce(e),r=s.shape,o=r.slice(0,1).concat(this.fixUnknownDimension(r.slice(1),this.targetShape));return F(s,o)})}getConfig(){const e={targetShape:this.targetShape},n=super.getConfig();return Object.assign(e,n),e}}WE.className="Reshape";Y(WE);class UE extends Ae{constructor(e){if(super(e),e.dims==null)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 n=Js(1,e.dims.length+1);if(!Ue(e.dims.slice().sort(),n))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 Pt({ndim:this.dims.length+1})]}computeOutputShape(e){e=Pe(e);const n=e.slice();return this.dims.forEach((s,r)=>{n[r+1]=e[s]}),n}call(e,n){return Fe(Ce(e),this.dimsIncludingBatch)}getConfig(){const e={dims:this.dims},n=super.getConfig();return Object.assign(e,n),e}}UE.className="Permute";Y(UE);class GE extends Ae{constructor(e){super(e??{}),this.supportsMasking=!0,e!=null?this.maskValue=e.maskValue==null?0:e.maskValue:this.maskValue=0}computeOutputShape(e){return e}getConfig(){const e=super.getConfig(),n={maskValue:this.maskValue};return Object.assign(n,e),n}computeMask(e,n){const s=Ce(e);return u1(vf(s,this.maskValue),-1)}call(e,n){return P(()=>{this.invokeCallHook(e,n);const s=Ce(e),i=u1(vf(s,this.maskValue),-1,!0);return D(s,le(i,s.dtype))})}}GE.className="Masking";Y(GE);/** * @license * Copyright 2018 Google LLC * @@ -7905,7 +7905,7 @@ body { * license that can be found in the LICENSE file or at * https://opensource.org/licenses/MIT. * ============================================================================= - */class HE extends Ae{constructor(e){if(super(e),this.embeddings=null,this.DEFAULT_EMBEDDINGS_INITIALIZER="randomUniform",e.batchInputShape==null&&e.inputShape==null){let n=null;e.batchSize!=null&&(n=e.batchSize),e.inputLength==null?this.batchInputShape=[n,null]:this.batchInputShape=[n].concat(Ke(e.inputLength))}this.inputDim=e.inputDim,qt(this.inputDim,"inputDim"),this.outputDim=e.outputDim,qt(this.outputDim,"outputDim"),this.embeddingsInitializer=ft(e.embeddingsInitializer||this.DEFAULT_EMBEDDINGS_INITIALIZER),this.embeddingsRegularizer=pt(e.embeddingsRegularizer),this.activityRegularizer=pt(e.activityRegularizer),this.embeddingsConstraint=Bt(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,n){return P(()=>this.maskZero?(e=Ce(e),bf(e,ze(e))):null)}computeOutputShape(e){if(e=Pe(e),this.inputLength==null)return[...e,this.outputDim];const n=Ke(this.inputLength);if(n.length!==e.length-1)throw new E(`"inputLength" is ${this.inputLength}, but received input shape has shape ${e}`);{let s=0;for(let r=0;r{this.invokeCallHook(e,n);let s=Ce(e);s.dtype!=="int32"&&(s=vr(s,"int32"));const r=ST(this.embeddings.read(),F(s,[s.size]));return F(r,Pe(this.computeOutputShape(s.shape)))})}getConfig(){const e={inputDim:this.inputDim,outputDim:this.outputDim,embeddingsInitializer:xt(this.embeddingsInitializer),embeddingsRegularizer:Je(this.embeddingsRegularizer),activityRegularizer:Je(this.activityRegularizer),embeddingsConstraint:Lt(this.embeddingsConstraint),maskZero:this.maskZero,inputLength:this.inputLength},n=super.getConfig();return Object.assign(e,n),e}}HE.className="Embedding";Y(HE);/** + */class HE extends Ae{constructor(e){if(super(e),this.embeddings=null,this.DEFAULT_EMBEDDINGS_INITIALIZER="randomUniform",e.batchInputShape==null&&e.inputShape==null){let n=null;e.batchSize!=null&&(n=e.batchSize),e.inputLength==null?this.batchInputShape=[n,null]:this.batchInputShape=[n].concat(Ke(e.inputLength))}this.inputDim=e.inputDim,qt(this.inputDim,"inputDim"),this.outputDim=e.outputDim,qt(this.outputDim,"outputDim"),this.embeddingsInitializer=ft(e.embeddingsInitializer||this.DEFAULT_EMBEDDINGS_INITIALIZER),this.embeddingsRegularizer=pt(e.embeddingsRegularizer),this.activityRegularizer=pt(e.activityRegularizer),this.embeddingsConstraint=Bt(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,n){return P(()=>this.maskZero?(e=Ce(e),vf(e,ze(e))):null)}computeOutputShape(e){if(e=Pe(e),this.inputLength==null)return[...e,this.outputDim];const n=Ke(this.inputLength);if(n.length!==e.length-1)throw new E(`"inputLength" is ${this.inputLength}, but received input shape has shape ${e}`);{let s=0;for(let r=0;r{this.invokeCallHook(e,n);let s=Ce(e);s.dtype!=="int32"&&(s=vr(s,"int32"));const r=ST(this.embeddings.read(),F(s,[s.size]));return F(r,Pe(this.computeOutputShape(s.shape)))})}getConfig(){const e={inputDim:this.inputDim,outputDim:this.outputDim,embeddingsInitializer:xt(this.embeddingsInitializer),embeddingsRegularizer:Je(this.embeddingsRegularizer),activityRegularizer:Je(this.activityRegularizer),embeddingsConstraint:Lt(this.embeddingsConstraint),maskZero:this.maskZero,inputLength:this.inputLength},n=super.getConfig();return Object.assign(e,n),e}}HE.className="Embedding";Y(HE);/** * @license * Copyright 2018 Google LLC * @@ -7913,7 +7913,7 @@ body { * license that can be found in the LICENSE file or at * https://opensource.org/licenses/MIT. * ============================================================================= - */class Ji extends Ae{constructor(e){super(e||{}),this.supportsMasking=!0}mergeFunction(e){throw new Ie}computeElementwiseOpOutputShape(e,n){if(e==null||n==null)return null;if(e.length1)throw new E(`Can not merge tensors with different batch sizes. Got tensors with shapes: ${JSON.stringify(e)}.`);let s=e[0]==null?null:e[0].slice(1);for(let o=1;oo.length);e.indexOf(null)===-1&&To(r).length===1?this.reshapeRequired=!1:this.reshapeRequired=!0}call(e,n){return P(()=>{if(e=e,this.reshapeRequired){const s=[],r=e.map(o=>o.rank);if(r.indexOf(null)===-1){const o=_o(r);for(let i of e){const a=i.rank;for(let l=0;l1){const u=Js(1,c).concat([0]);s.push(Fe(l,u)),o=!0}else s.push(l)}let i=this.mergeFunction(s);const a=i.rank;if(o){if(a==null){const l=i.shape,c=l.length,u=l[c-1],h=[u].concat(l.slice(0,l.length-1));i=F(Fe(F(i,[-1,u]),[1,0]),h)}else if(a>1){const l=[a-1].concat(Js(0,a-1));i=Fe(i,l)}}return i}}else return this.mergeFunction(e)})}computeOutputShape(e){e=e;let n;e[0]==null?n=null:n=e[0].slice(1);for(let r=1;r{if(n==null)return null;if(!Array.isArray(n))throw new E("`mask` should be an Array");if(!Array.isArray(e))throw new E("`inputs` should be an Array");if(n.length!==e.length)throw new E(`The Array 'inputs' and 'mask' are expected to have the same length, but have different lengths (${e.length} vs ${n.length})`);if(n.every(r=>r==null))return null;n=n.map(r=>r==null?r:En(r,0));let s=n[0];for(let r=1;r{let n=e[0].clone();for(let s=1;s{let n=e[0].clone();for(let s=1;s{let n=e[0].clone();for(let s=1;s{let n=e[0];for(let s=1;s{let n=e[0];for(let s=1;s1)throw new E("A `Concatenate` layer requires inputs with matching shapes except for the concat axis. Got input shapes: "+JSON.stringify(e))}mergeFunction(e){return P(()=>jw(e,this.axis))}computeOutputShape(e){if(!(Array.isArray(e)&&Array.isArray(e[0])))throw new E("A `Concatenate` layer should be called on a list of inputs.");const n=e,s=n[0].slice(),r=this.axis<0?s.length+this.axis:this.axis;for(const o of n.slice(1)){if(s[r]==null||o[r]==null){s[r]=null;break}s[r]+=o[r]}return s}computeMask(e,n){if(n==null)return null;if(!Array.isArray(n))throw new E("`mask` should be an array for Concatenate");if(!Array.isArray(e))throw new E("`inputs` should be an array for Concatenate");if(n.length!==e.length)throw new E(`Mismatch in the length of mask (${n.length}) and the legnth of inputs (${e.length})`);return P(()=>{let s=!0;if(n.forEach(i=>{if(i!=null){s=!1;return}}),s)return null;const r=[];for(let i=0;i3||e.shape.length>3)throw new Ie("batchDot is not implemented for tensors of 4D or higher rank yet");if(I(t.shape.length>=2,()=>`batchDot requires the rank of x to be >= 2, but got ${t.shape.length}`),I(t.shape.length>=2,()=>`batchDot requires the rank of y to be >= 2, but got ${e.shape.length}`),typeof n=="number"&&(n=[n,n]),t.dtype==="complex64"||e.dtype==="complex64")throw new Ie("batchDot is not implemented for complex64-type Tensors yet.");const s=t.shape.length,r=e.shape.length;n==null&&(n=[s-1,r-2]);const o=n;return P(()=>{let i;if(s>r){i=s-r;const l=[];for(let c=0;cs){i=r-s;const l=[];for(let c=0;c0){let l;s>r?l=s+r-3:l=s-1;const c=[];for(let u=l;u"A `Dot` layer should be called on a list of exactly 2 inputs.");const n=e[0],s=e[1];if(n.length>3||s.length>3)throw new Ie("Dot layer does not support tensors of 4D or higher rank yet.");const r=this.interpretAxes(n,s);if(n[r[0]]!==s[r[1]])throw new E(`Dimension incompatibility: ${n[r[0]]} !== ${s[r[1]]}`)}mergeFunction(e){if(e.length!==2)throw new E(`A \`Dot\` layer must be called on exactly 2 inputs, but received ${e.length} input(s).`);let n=e[0],s=e[1],r;return Array.isArray(this.axes)?r=this.axes.map((o,i)=>Kl(o,e[i].shape.length)):r=[Kl(this.axes,n.shape.length),Kl(this.axes,s.shape.length)],this.normalize&&(n=Tf(n,r[0]),s=Tf(s,r[1])),gH(n,s,r)}interpretAxes(e,n){let s;return Array.isArray(this.axes)?s=this.axes:s=[Kl(this.axes,e.length),Kl(this.axes,n.length)],s}computeOutputShape(e){I(Array.isArray(e)&&e.length===2&&Array.isArray(e[0])&&Array.isArray(e[1]),()=>"A `Dot` layer should be called on a list of exactly 2 inputs.");const n=e[0].slice(),s=e[1].slice();if(n.length>3||s.length>3)throw new Ie("Dot layer does not support tensors of 4D or higher rank yet.");const r=this.interpretAxes(n,s);n.splice(r[0],1),s.splice(r[1],1),s.splice(0,1);const o=n.concat(s);return o.length===1&&o.push(1),o}computeMask(e,n){return null}getConfig(){const e={axes:this.axes,normalize:this.normalize},n=super.getConfig();return Object.assign(e,n),e}}ZE.className="Dot";Y(ZE);/** + */class Ji extends Ae{constructor(e){super(e||{}),this.supportsMasking=!0}mergeFunction(e){throw new Ie}computeElementwiseOpOutputShape(e,n){if(e==null||n==null)return null;if(e.length1)throw new E(`Can not merge tensors with different batch sizes. Got tensors with shapes: ${JSON.stringify(e)}.`);let s=e[0]==null?null:e[0].slice(1);for(let o=1;oo.length);e.indexOf(null)===-1&&To(r).length===1?this.reshapeRequired=!1:this.reshapeRequired=!0}call(e,n){return P(()=>{if(e=e,this.reshapeRequired){const s=[],r=e.map(o=>o.rank);if(r.indexOf(null)===-1){const o=_o(r);for(let i of e){const a=i.rank;for(let l=0;l1){const u=Js(1,c).concat([0]);s.push(Fe(l,u)),o=!0}else s.push(l)}let i=this.mergeFunction(s);const a=i.rank;if(o){if(a==null){const l=i.shape,c=l.length,u=l[c-1],h=[u].concat(l.slice(0,l.length-1));i=F(Fe(F(i,[-1,u]),[1,0]),h)}else if(a>1){const l=[a-1].concat(Js(0,a-1));i=Fe(i,l)}}return i}}else return this.mergeFunction(e)})}computeOutputShape(e){e=e;let n;e[0]==null?n=null:n=e[0].slice(1);for(let r=1;r{if(n==null)return null;if(!Array.isArray(n))throw new E("`mask` should be an Array");if(!Array.isArray(e))throw new E("`inputs` should be an Array");if(n.length!==e.length)throw new E(`The Array 'inputs' and 'mask' are expected to have the same length, but have different lengths (${e.length} vs ${n.length})`);if(n.every(r=>r==null))return null;n=n.map(r=>r==null?r:En(r,0));let s=n[0];for(let r=1;r{let n=e[0].clone();for(let s=1;s{let n=e[0].clone();for(let s=1;s{let n=e[0].clone();for(let s=1;s{let n=e[0];for(let s=1;s{let n=e[0];for(let s=1;s1)throw new E("A `Concatenate` layer requires inputs with matching shapes except for the concat axis. Got input shapes: "+JSON.stringify(e))}mergeFunction(e){return P(()=>jw(e,this.axis))}computeOutputShape(e){if(!(Array.isArray(e)&&Array.isArray(e[0])))throw new E("A `Concatenate` layer should be called on a list of inputs.");const n=e,s=n[0].slice(),r=this.axis<0?s.length+this.axis:this.axis;for(const o of n.slice(1)){if(s[r]==null||o[r]==null){s[r]=null;break}s[r]+=o[r]}return s}computeMask(e,n){if(n==null)return null;if(!Array.isArray(n))throw new E("`mask` should be an array for Concatenate");if(!Array.isArray(e))throw new E("`inputs` should be an array for Concatenate");if(n.length!==e.length)throw new E(`Mismatch in the length of mask (${n.length}) and the legnth of inputs (${e.length})`);return P(()=>{let s=!0;if(n.forEach(i=>{if(i!=null){s=!1;return}}),s)return null;const r=[];for(let i=0;i3||e.shape.length>3)throw new Ie("batchDot is not implemented for tensors of 4D or higher rank yet");if(I(t.shape.length>=2,()=>`batchDot requires the rank of x to be >= 2, but got ${t.shape.length}`),I(t.shape.length>=2,()=>`batchDot requires the rank of y to be >= 2, but got ${e.shape.length}`),typeof n=="number"&&(n=[n,n]),t.dtype==="complex64"||e.dtype==="complex64")throw new Ie("batchDot is not implemented for complex64-type Tensors yet.");const s=t.shape.length,r=e.shape.length;n==null&&(n=[s-1,r-2]);const o=n;return P(()=>{let i;if(s>r){i=s-r;const l=[];for(let c=0;cs){i=r-s;const l=[];for(let c=0;c0){let l;s>r?l=s+r-3:l=s-1;const c=[];for(let u=l;u"A `Dot` layer should be called on a list of exactly 2 inputs.");const n=e[0],s=e[1];if(n.length>3||s.length>3)throw new Ie("Dot layer does not support tensors of 4D or higher rank yet.");const r=this.interpretAxes(n,s);if(n[r[0]]!==s[r[1]])throw new E(`Dimension incompatibility: ${n[r[0]]} !== ${s[r[1]]}`)}mergeFunction(e){if(e.length!==2)throw new E(`A \`Dot\` layer must be called on exactly 2 inputs, but received ${e.length} input(s).`);let n=e[0],s=e[1],r;return Array.isArray(this.axes)?r=this.axes.map((o,i)=>Kl(o,e[i].shape.length)):r=[Kl(this.axes,n.shape.length),Kl(this.axes,s.shape.length)],this.normalize&&(n=Nf(n,r[0]),s=Nf(s,r[1])),mH(n,s,r)}interpretAxes(e,n){let s;return Array.isArray(this.axes)?s=this.axes:s=[Kl(this.axes,e.length),Kl(this.axes,n.length)],s}computeOutputShape(e){I(Array.isArray(e)&&e.length===2&&Array.isArray(e[0])&&Array.isArray(e[1]),()=>"A `Dot` layer should be called on a list of exactly 2 inputs.");const n=e[0].slice(),s=e[1].slice();if(n.length>3||s.length>3)throw new Ie("Dot layer does not support tensors of 4D or higher rank yet.");const r=this.interpretAxes(n,s);n.splice(r[0],1),s.splice(r[1],1),s.splice(0,1);const o=n.concat(s);return o.length===1&&o.push(1),o}computeMask(e,n){return null}getConfig(){const e={axes:this.axes,normalize:this.normalize},n=super.getConfig();return Object.assign(e,n),e}}ZE.className="Dot";Y(ZE);/** * @license * Copyright 2018 Google LLC * @@ -7921,7 +7921,7 @@ body { * license that can be found in the LICENSE file or at * https://opensource.org/licenses/MIT. * ============================================================================= - */class JE extends Ae{constructor(e){super(e),this.supportsMasking=!0,this.stddev=e.stddev}computeOutputShape(e){return e}getConfig(){const e=super.getConfig(),n={stddev:this.stddev};return Object.assign(n,e),n}call(e,n){return P(()=>{this.invokeCallHook(e,n);const s=Ce(e);return Ch(()=>J($m(s.shape,0,this.stddev),s),()=>s,n.training||!1)})}}JE.className="GaussianNoise";Y(JE);class eR extends Ae{constructor(e){super(e),this.supportsMasking=!0,this.rate=e.rate}computeOutputShape(e){return e}getConfig(){const e=super.getConfig(),n={rate:this.rate};return Object.assign(n,e),n}call(e,n){return P(()=>{this.invokeCallHook(e,n);const s=Ce(e);return this.rate>0&&this.rate<1?Ch(()=>{const o=Math.sqrt(this.rate/(1-this.rate));return D(s,$m(s.shape,1,o))},()=>s,n.training||!1):s})}}eR.className="GaussianDropout";Y(eR);class tR extends Ae{constructor(e){super(e),this.supportsMasking=!0,this.rate=e.rate,this.noiseShape=e.noiseShape}_getNoiseShape(e){return this.noiseShape||Ce(e).shape}computeOutputShape(e){return e}getConfig(){const e=super.getConfig(),n={rate:this.rate};return Object.assign(n,e),n}call(e,n){return P(()=>{if(this.rate<1&&this.rate>0){const s=this._getNoiseShape(e);return Ch(()=>{const o=Ce(e),l=-1.6732632423543772*1.0507009873554805;let c=Xi(fh(s),this.rate);c=vr(c,"float32");const u=((1-this.rate)*(1+this.rate*l**2))**-.5,h=-u*l*this.rate,d=J(D(o,c),D(J(c,-1),l));return J(D(d,u),h)},()=>Ce(e),n.training||!1)}return e})}}tR.className="AlphaDropout";Y(tR);/** + */class JE extends Ae{constructor(e){super(e),this.supportsMasking=!0,this.stddev=e.stddev}computeOutputShape(e){return e}getConfig(){const e=super.getConfig(),n={stddev:this.stddev};return Object.assign(n,e),n}call(e,n){return P(()=>{this.invokeCallHook(e,n);const s=Ce(e);return bh(()=>J($m(s.shape,0,this.stddev),s),()=>s,n.training||!1)})}}JE.className="GaussianNoise";Y(JE);class eR extends Ae{constructor(e){super(e),this.supportsMasking=!0,this.rate=e.rate}computeOutputShape(e){return e}getConfig(){const e=super.getConfig(),n={rate:this.rate};return Object.assign(n,e),n}call(e,n){return P(()=>{this.invokeCallHook(e,n);const s=Ce(e);return this.rate>0&&this.rate<1?bh(()=>{const o=Math.sqrt(this.rate/(1-this.rate));return D(s,$m(s.shape,1,o))},()=>s,n.training||!1):s})}}eR.className="GaussianDropout";Y(eR);class tR extends Ae{constructor(e){super(e),this.supportsMasking=!0,this.rate=e.rate,this.noiseShape=e.noiseShape}_getNoiseShape(e){return this.noiseShape||Ce(e).shape}computeOutputShape(e){return e}getConfig(){const e=super.getConfig(),n={rate:this.rate};return Object.assign(n,e),n}call(e,n){return P(()=>{if(this.rate<1&&this.rate>0){const s=this._getNoiseShape(e);return bh(()=>{const o=Ce(e),l=-1.6732632423543772*1.0507009873554805;let c=Xi(dh(s),this.rate);c=vr(c,"float32");const u=((1-this.rate)*(1+this.rate*l**2))**-.5,h=-u*l*this.rate,d=J(D(o,c),D(J(c,-1),l));return J(D(d,u),h)},()=>Ce(e),n.training||!1)}return e})}}tR.className="AlphaDropout";Y(tR);/** * @license * Copyright 2018 Google LLC * @@ -7929,7 +7929,7 @@ body { * license that can be found in the LICENSE file or at * https://opensource.org/licenses/MIT. * ============================================================================= - */function Jc(t,e,n,s,r,o=.001){let i;if(t.rank===2)i=BL(t,e,n,s,r,o);else if(t.rank===3)i=WL(t,e,n,s,r,o);else if(t.rank===4)i=GL(t,e,n,s,r,o);else throw new Ie(`batchNormalization is not implemented for array of rank ${t.rank} yet`);return i}function xH(t,e,n,s,r=.001){return P(()=>{const o=Ky(t,s),i=o.mean,a=o.variance;return[Jc(t,i,a,n,e,r),i,a]})}function yH(t,e,n,s,r=.001){return P(()=>{const o=Ky(t,s),i=o.mean,a=o.variance,l=[];for(const p of Js(0,t.rank))s.indexOf(p)!==-1?l.push(1):l.push(t.shape[p]);const c=F(i,l),u=F(a,l),h=e==null?null:F(e,l),d=n==null?null:F(n,l);return[Jc(t,c,u,d,h,r),i,a]})}function wH(t,e,n,s,r=.001){return Ue(s.slice().sort(),Js(0,t.rank-1))?xH(t,e,n,s,r):yH(t,e,n,s,r)}class nR extends Ae{constructor(e){e==null&&(e={}),super(e),this.supportsMasking=!0,this.axis=e.axis==null?-1:e.axis,this.momentum=e.momentum==null?.99:e.momentum,this.epsilon=e.epsilon==null?.001:e.epsilon,this.center=e.center==null?!0:e.center,this.scale=e.scale==null?!0:e.scale,this.betaInitializer=ft(e.betaInitializer||"zeros"),this.gammaInitializer=ft(e.gammaInitializer||"ones"),this.movingMeanInitializer=ft(e.movingMeanInitializer||"zeros"),this.movingVarianceInitializer=ft(e.movingVarianceInitializer||"ones"),this.betaConstraint=Bt(e.betaConstraint),this.gammaConstraint=Bt(e.gammaConstraint),this.betaRegularizer=pt(e.betaRegularizer),this.gammaRegularizer=pt(e.gammaRegularizer)}build(e){e=Pe(e);const n=this.axis>=0?this.axis:this.axis+e.length,s=e[n];if(s==null)throw new E(`Axis ${n} of input tensor should have a defined dimension but the layer received an input with shape ${JSON.stringify(e)}.`);this.inputSpec=[new Pt({ndim:e.length,axes:{[n]:s}})];const r=[s];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,n){return P(()=>{const s=n.training==null?!1:n.training,r=Ce(e),o=r.shape,i=o.length,a=Js(0,i),l=this.axis>=0?this.axis:this.axis+i;a.splice(l,1);const c=Li(1,i);c[l]=o[l];const u=a.slice();u.sort();const h=!Ue(u,Js(0,i).slice(0,i-1)),d=()=>{if(h){const y=F(this.movingMean.read(),c),w=F(this.movingVariance.read(),c),v=this.center?F(this.beta.read(),c):null,b=this.scale?F(this.gamma.read(),c):null;return Jc(r,y,w,v,b,this.epsilon)}else return Jc(r,this.movingMean.read(),this.movingVariance.read(),this.beta==null?null:this.beta.read(),this.gamma==null?null:this.gamma.read(),this.epsilon)};if(!s)return d();const[f,p,g]=wH(r,this.gamma.read(),this.beta.read(),a,this.epsilon),x=(y,w,v)=>{P(()=>{const b=1-v,C=y.read(),k=D(ve(C,w),b);y.write(ve(C,k))})};return(()=>{x(this.movingMean,p,this.momentum),x(this.movingVariance,g,this.momentum)})(),f})}getConfig(){const e={axis:this.axis,momentum:this.momentum,epsilon:this.epsilon,center:this.center,scale:this.scale,betaInitializer:xt(this.betaInitializer),gammaInitializer:xt(this.gammaInitializer),movingMeanInitializer:xt(this.movingMeanInitializer),movingVarianceInitializer:xt(this.movingVarianceInitializer),betaRegularizer:Je(this.betaRegularizer),gammaRegularizer:Je(this.gammaRegularizer),betaConstraint:Lt(this.betaConstraint),gammaConstraint:Lt(this.gammaConstraint)},n=super.getConfig();return Object.assign(e,n),e}}nR.className="BatchNormalization";Y(nR);class sR extends Ae{constructor(e){if(e==null&&(e={}),super(e),this.axis=e.axis==null?-1:e.axis,typeof this.axis=="number"){if(!Number.isInteger(this.axis))throw new Error(`Expected axis to be an integer, but received ${this.axis}`)}else if(Array.isArray(this.axis)){for(const n of this.axis)if(!Number.isInteger(n))throw new Error(`Expected axis to be an array of integers, but received ${JSON.stringify(this.axis)}`)}else throw new Error(`Expected axis to be an integer or an array of integers, but received ${JSON.stringify(this.axis)}`);this.epsilon=e.epsilon==null?.001:e.epsilon,this.center=e.center==null?!0:e.center,this.scale=e.scale==null?!0:e.scale,this.betaInitializer=ft(e.betaInitializer||"zeros"),this.gammaInitializer=ft(e.gammaInitializer||"ones"),this.betaRegularizer=pt(e.betaRegularizer),this.gammaRegularizer=pt(e.gammaRegularizer),this.supportsMasking=!0}build(e){e=Pe(e);const n=e.length;typeof this.axis=="number"&&(this.axis=[this.axis]);for(let o=0;o=n)throw new Error(`Invalid axis: ${o}`);if(this.axis.length!==To(this.axis).length)throw new Error(`Found duplicate axes in: ${this.axis}`);const s=this.axis.map(o=>e[o]),r=!0;this.scale?this.gamma=this.addWeight("gamma",s,"float32",this.gammaInitializer,this.gammaRegularizer,r):this.gamma=null,this.center?this.beta=this.addWeight("beta",s,"float32",this.betaInitializer,this.betaRegularizer,r):this.beta=null,this.built=!0}call(e,n){const s=Ce(e),r=s.shape,o=r.length;return P(()=>{let{mean:a,variance:l}=Ky(s,this.axis,!0);const c=Li(1,o);for(const g of this.axis)c[g]=r[g];const u=g=>g!=null&&g.shape.length!==o?F(g,c):g;let h=this.scale?u(this.gamma.read()):null,d=this.center?u(this.beta.read()):null;const f=[],p=[];for(let g=0;g{const o=Ky(t,s),i=o.mean,a=o.variance;return[Jc(t,i,a,n,e,r),i,a]})}function xH(t,e,n,s,r=.001){return P(()=>{const o=Ky(t,s),i=o.mean,a=o.variance,l=[];for(const p of Js(0,t.rank))s.indexOf(p)!==-1?l.push(1):l.push(t.shape[p]);const c=F(i,l),u=F(a,l),h=e==null?null:F(e,l),d=n==null?null:F(n,l);return[Jc(t,c,u,d,h,r),i,a]})}function yH(t,e,n,s,r=.001){return Ue(s.slice().sort(),Js(0,t.rank-1))?gH(t,e,n,s,r):xH(t,e,n,s,r)}class nR extends Ae{constructor(e){e==null&&(e={}),super(e),this.supportsMasking=!0,this.axis=e.axis==null?-1:e.axis,this.momentum=e.momentum==null?.99:e.momentum,this.epsilon=e.epsilon==null?.001:e.epsilon,this.center=e.center==null?!0:e.center,this.scale=e.scale==null?!0:e.scale,this.betaInitializer=ft(e.betaInitializer||"zeros"),this.gammaInitializer=ft(e.gammaInitializer||"ones"),this.movingMeanInitializer=ft(e.movingMeanInitializer||"zeros"),this.movingVarianceInitializer=ft(e.movingVarianceInitializer||"ones"),this.betaConstraint=Bt(e.betaConstraint),this.gammaConstraint=Bt(e.gammaConstraint),this.betaRegularizer=pt(e.betaRegularizer),this.gammaRegularizer=pt(e.gammaRegularizer)}build(e){e=Pe(e);const n=this.axis>=0?this.axis:this.axis+e.length,s=e[n];if(s==null)throw new E(`Axis ${n} of input tensor should have a defined dimension but the layer received an input with shape ${JSON.stringify(e)}.`);this.inputSpec=[new Pt({ndim:e.length,axes:{[n]:s}})];const r=[s];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,n){return P(()=>{const s=n.training==null?!1:n.training,r=Ce(e),o=r.shape,i=o.length,a=Js(0,i),l=this.axis>=0?this.axis:this.axis+i;a.splice(l,1);const c=Li(1,i);c[l]=o[l];const u=a.slice();u.sort();const h=!Ue(u,Js(0,i).slice(0,i-1)),d=()=>{if(h){const y=F(this.movingMean.read(),c),w=F(this.movingVariance.read(),c),v=this.center?F(this.beta.read(),c):null,b=this.scale?F(this.gamma.read(),c):null;return Jc(r,y,w,v,b,this.epsilon)}else return Jc(r,this.movingMean.read(),this.movingVariance.read(),this.beta==null?null:this.beta.read(),this.gamma==null?null:this.gamma.read(),this.epsilon)};if(!s)return d();const[f,p,g]=yH(r,this.gamma.read(),this.beta.read(),a,this.epsilon),x=(y,w,v)=>{P(()=>{const b=1-v,C=y.read(),k=D(ve(C,w),b);y.write(ve(C,k))})};return(()=>{x(this.movingMean,p,this.momentum),x(this.movingVariance,g,this.momentum)})(),f})}getConfig(){const e={axis:this.axis,momentum:this.momentum,epsilon:this.epsilon,center:this.center,scale:this.scale,betaInitializer:xt(this.betaInitializer),gammaInitializer:xt(this.gammaInitializer),movingMeanInitializer:xt(this.movingMeanInitializer),movingVarianceInitializer:xt(this.movingVarianceInitializer),betaRegularizer:Je(this.betaRegularizer),gammaRegularizer:Je(this.gammaRegularizer),betaConstraint:Lt(this.betaConstraint),gammaConstraint:Lt(this.gammaConstraint)},n=super.getConfig();return Object.assign(e,n),e}}nR.className="BatchNormalization";Y(nR);class sR extends Ae{constructor(e){if(e==null&&(e={}),super(e),this.axis=e.axis==null?-1:e.axis,typeof this.axis=="number"){if(!Number.isInteger(this.axis))throw new Error(`Expected axis to be an integer, but received ${this.axis}`)}else if(Array.isArray(this.axis)){for(const n of this.axis)if(!Number.isInteger(n))throw new Error(`Expected axis to be an array of integers, but received ${JSON.stringify(this.axis)}`)}else throw new Error(`Expected axis to be an integer or an array of integers, but received ${JSON.stringify(this.axis)}`);this.epsilon=e.epsilon==null?.001:e.epsilon,this.center=e.center==null?!0:e.center,this.scale=e.scale==null?!0:e.scale,this.betaInitializer=ft(e.betaInitializer||"zeros"),this.gammaInitializer=ft(e.gammaInitializer||"ones"),this.betaRegularizer=pt(e.betaRegularizer),this.gammaRegularizer=pt(e.gammaRegularizer),this.supportsMasking=!0}build(e){e=Pe(e);const n=e.length;typeof this.axis=="number"&&(this.axis=[this.axis]);for(let o=0;o=n)throw new Error(`Invalid axis: ${o}`);if(this.axis.length!==To(this.axis).length)throw new Error(`Found duplicate axes in: ${this.axis}`);const s=this.axis.map(o=>e[o]),r=!0;this.scale?this.gamma=this.addWeight("gamma",s,"float32",this.gammaInitializer,this.gammaRegularizer,r):this.gamma=null,this.center?this.beta=this.addWeight("beta",s,"float32",this.betaInitializer,this.betaRegularizer,r):this.beta=null,this.built=!0}call(e,n){const s=Ce(e),r=s.shape,o=r.length;return P(()=>{let{mean:a,variance:l}=Ky(s,this.axis,!0);const c=Li(1,o);for(const g of this.axis)c[g]=r[g];const u=g=>g!=null&&g.shape.length!==o?F(g,c):g;let h=this.scale?u(this.gamma.read()):null,d=this.center?u(this.beta.read()):null;const f=[],p=[];for(let g=0;g{if(t.rank!==4)throw new E(`temporalPadding expects input tensor to be 4-D, but received a ${t.rank}-D tensor.`);if(e==null&&(e=[[1,1],[1,1]]),e.length!==2||e[0].length!==2||e[1].length!==2)throw new E("spatial2dPadding expects `padding` to be an Array of two Arrays, each of which is an Array of two integers.");if(n==null&&(n=er()),n!=="channelsLast"&&n!=="channelsFirst")throw new E(`Unknown data format: ${n}. Supported data formats are 'channelsLast' and 'channelsFirst.`);let s;return n==="channelsFirst"?s=[[0,0],[0,0],e[0],e[1]]:s=[[0,0],e[0],e[1],[0,0]],Xy(t,s)})}class rR extends Ae{constructor(e){if(e==null&&(e={}),super(e),this.dataFormat=e.dataFormat==null?er():e.dataFormat,e.padding==null)this.padding=[[1,1],[1,1]];else if(typeof e.padding=="number")this.padding=[[e.padding,e.padding],[e.padding,e.padding]];else{if(e.padding=e.padding,e.padding.length!==2)throw new E(`ZeroPadding2D expects padding to be a length-2 array, but received a length-${e.padding.length} array.`);let n,s;if(typeof e.padding[0]=="number")n=[e.padding[0],e.padding[0]],s=[e.padding[1],e.padding[1]];else{if(e.padding=e.padding,e.padding[0].length!==2)throw new E(`ZeroPadding2D expects height padding to be a length-2 array, but received a length-${e.padding[0].length} array.`);if(n=e.padding[0],e.padding[1].length!==2)throw new E(`ZeroPadding2D expects width padding to be a length-2 array, but received a length-${e.padding[1].length} array.`);s=e.padding[1]}this.padding=[n,s]}this.inputSpec=[new Pt({ndim:4})]}computeOutputShape(e){e=Pe(e);let n,s;return this.dataFormat==="channelsFirst"?(e[2]!=null&&e[2]>=0?n=e[2]+this.padding[0][0]+this.padding[0][1]:n=null,e[3]!=null&&e[3]>=0?s=e[3]+this.padding[1][0]+this.padding[1][1]:s=null,[e[0],e[1],n,s]):(e[1]!=null&&e[1]>=0?n=e[1]+this.padding[0][0]+this.padding[0][1]:n=null,e[2]!=null&&e[2]>=0?s=e[2]+this.padding[1][0]+this.padding[1][1]:s=null,[e[0],n,s,e[3]])}call(e,n){return P(()=>vH(Ce(e),this.padding,this.dataFormat))}getConfig(){const e={padding:this.padding,dataFormat:this.dataFormat},n=super.getConfig();return Object.assign(e,n),e}}rR.className="ZeroPadding2D";Y(rR);/** + */function wH(t,e,n){return P(()=>{if(t.rank!==4)throw new E(`temporalPadding expects input tensor to be 4-D, but received a ${t.rank}-D tensor.`);if(e==null&&(e=[[1,1],[1,1]]),e.length!==2||e[0].length!==2||e[1].length!==2)throw new E("spatial2dPadding expects `padding` to be an Array of two Arrays, each of which is an Array of two integers.");if(n==null&&(n=er()),n!=="channelsLast"&&n!=="channelsFirst")throw new E(`Unknown data format: ${n}. Supported data formats are 'channelsLast' and 'channelsFirst.`);let s;return n==="channelsFirst"?s=[[0,0],[0,0],e[0],e[1]]:s=[[0,0],e[0],e[1],[0,0]],Xy(t,s)})}class rR extends Ae{constructor(e){if(e==null&&(e={}),super(e),this.dataFormat=e.dataFormat==null?er():e.dataFormat,e.padding==null)this.padding=[[1,1],[1,1]];else if(typeof e.padding=="number")this.padding=[[e.padding,e.padding],[e.padding,e.padding]];else{if(e.padding=e.padding,e.padding.length!==2)throw new E(`ZeroPadding2D expects padding to be a length-2 array, but received a length-${e.padding.length} array.`);let n,s;if(typeof e.padding[0]=="number")n=[e.padding[0],e.padding[0]],s=[e.padding[1],e.padding[1]];else{if(e.padding=e.padding,e.padding[0].length!==2)throw new E(`ZeroPadding2D expects height padding to be a length-2 array, but received a length-${e.padding[0].length} array.`);if(n=e.padding[0],e.padding[1].length!==2)throw new E(`ZeroPadding2D expects width padding to be a length-2 array, but received a length-${e.padding[1].length} array.`);s=e.padding[1]}this.padding=[n,s]}this.inputSpec=[new Pt({ndim:4})]}computeOutputShape(e){e=Pe(e);let n,s;return this.dataFormat==="channelsFirst"?(e[2]!=null&&e[2]>=0?n=e[2]+this.padding[0][0]+this.padding[0][1]:n=null,e[3]!=null&&e[3]>=0?s=e[3]+this.padding[1][0]+this.padding[1][1]:s=null,[e[0],e[1],n,s]):(e[1]!=null&&e[1]>=0?n=e[1]+this.padding[0][0]+this.padding[0][1]:n=null,e[2]!=null&&e[2]>=0?s=e[2]+this.padding[1][0]+this.padding[1][1]:s=null,[e[0],n,s,e[3]])}call(e,n){return P(()=>wH(Ce(e),this.padding,this.dataFormat))}getConfig(){const e={padding:this.padding,dataFormat:this.dataFormat},n=super.getConfig();return Object.assign(e,n),e}}rR.className="ZeroPadding2D";Y(rR);/** * @license * Copyright 2018 Google LLC * @@ -7945,7 +7945,7 @@ body { * license that can be found in the LICENSE file or at * https://opensource.org/licenses/MIT. * ============================================================================= - */function Fm(t,e,n,s,r,o){return P(()=>{Nt(r),vT(o),hs(s),n==null&&(n=[1,1]),s==null&&(s="valid"),r==null&&(r=er()),o==null&&(o="max"),t=ov(t,r);let i;const a=s==="same"?"same":"valid";return o==="max"?i=jy(t,e,n,a):i=Oy(t,e,n,a),r==="channelsFirst"&&(i=Fe(i,[0,3,1,2])),i})}function oR(t,e,n,s,r,o){return P(()=>{Nt(r),vT(o),hs(s),n==null&&(n=[1,1,1]),s==null&&(s="valid"),r==null&&(r=er()),o==null&&(o="max"),t=CE(t,r);let i;const a=s==="same"?"same":"valid";return o==="max"?i=TB(t,e,n,a):i=RL(t,e,n,a),r==="channelsFirst"&&(i=Fe(i,[0,4,1,2,3])),i})}class iR extends Ae{constructor(e){if(e.poolSize==null&&(e.poolSize=2),super(e),typeof e.poolSize=="number")this.poolSize=[e.poolSize];else if(Array.isArray(e.poolSize)&&e.poolSize.length===1&&typeof e.poolSize[0]=="number")this.poolSize=e.poolSize;else throw new E(`poolSize for 1D convolutional layer must be a number or an Array of a single number, but received ${JSON.stringify(e.poolSize)}`);if(qt(this.poolSize,"poolSize"),e.strides==null)this.strides=this.poolSize;else if(typeof e.strides=="number")this.strides=[e.strides];else if(Array.isArray(e.strides)&&e.strides.length===1&&typeof e.strides[0]=="number")this.strides=e.strides;else throw new E(`strides for 1D convolutional layer must be a number or an Array of a single number, but received ${JSON.stringify(e.strides)}`);qt(this.strides,"strides"),this.padding=e.padding==null?"valid":e.padding,hs(this.padding),this.inputSpec=[new Pt({ndim:3})]}computeOutputShape(e){e=Pe(e);const n=Qs(e[1],this.poolSize[0],this.padding,this.strides[0]);return[e[0],n,e[2]]}call(e,n){return P(()=>{this.invokeCallHook(e,n),e=vh(Ce(e),2);const s=this.poolingFunction(Ce(e),[this.poolSize[0],1],[this.strides[0],1],this.padding,"channelsLast");return ph(s,[2])})}getConfig(){const e={poolSize:this.poolSize,padding:this.padding,strides:this.strides},n=super.getConfig();return Object.assign(e,n),e}}class aR extends iR{constructor(e){super(e)}poolingFunction(e,n,s,r,o){return Nt(o),hs(r),Fm(e,n,s,r,o,"max")}}aR.className="MaxPooling1D";Y(aR);class lR extends iR{constructor(e){super(e)}poolingFunction(e,n,s,r,o){return Nt(o),hs(r),Fm(e,n,s,r,o,"avg")}}lR.className="AveragePooling1D";Y(lR);class cR extends Ae{constructor(e){if(e.poolSize==null&&(e.poolSize=[2,2]),super(e),this.poolSize=Array.isArray(e.poolSize)?e.poolSize:[e.poolSize,e.poolSize],e.strides==null)this.strides=this.poolSize;else if(Array.isArray(e.strides)){if(e.strides.length!==2)throw new E(`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];qt(this.poolSize,"poolSize"),qt(this.strides,"strides"),this.padding=e.padding==null?"valid":e.padding,this.dataFormat=e.dataFormat==null?"channelsLast":e.dataFormat,Nt(this.dataFormat),hs(this.padding),this.inputSpec=[new Pt({ndim:4})]}computeOutputShape(e){e=Pe(e);let n=this.dataFormat==="channelsFirst"?e[2]:e[1],s=this.dataFormat==="channelsFirst"?e[3]:e[2];return n=Qs(n,this.poolSize[0],this.padding,this.strides[0]),s=Qs(s,this.poolSize[1],this.padding,this.strides[1]),this.dataFormat==="channelsFirst"?[e[0],e[1],n,s]:[e[0],n,s,e[3]]}call(e,n){return P(()=>(this.invokeCallHook(e,n),this.poolingFunction(Ce(e),this.poolSize,this.strides,this.padding,this.dataFormat)))}getConfig(){const e={poolSize:this.poolSize,padding:this.padding,strides:this.strides,dataFormat:this.dataFormat},n=super.getConfig();return Object.assign(e,n),e}}class uR extends cR{constructor(e){super(e)}poolingFunction(e,n,s,r,o){return Nt(o),hs(r),Fm(e,n,s,r,o,"max")}}uR.className="MaxPooling2D";Y(uR);class hR extends cR{constructor(e){super(e)}poolingFunction(e,n,s,r,o){return Nt(o),hs(r),Fm(e,n,s,r,o,"avg")}}hR.className="AveragePooling2D";Y(hR);class dR extends Ae{constructor(e){if(e.poolSize==null&&(e.poolSize=[2,2,2]),super(e),this.poolSize=Array.isArray(e.poolSize)?e.poolSize:[e.poolSize,e.poolSize,e.poolSize],e.strides==null)this.strides=this.poolSize;else if(Array.isArray(e.strides)){if(e.strides.length!==3)throw new E(`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];qt(this.poolSize,"poolSize"),qt(this.strides,"strides"),this.padding=e.padding==null?"valid":e.padding,this.dataFormat=e.dataFormat==null?"channelsLast":e.dataFormat,Nt(this.dataFormat),hs(this.padding),this.inputSpec=[new Pt({ndim:5})]}computeOutputShape(e){e=Pe(e);let n=this.dataFormat==="channelsFirst"?e[2]:e[1],s=this.dataFormat==="channelsFirst"?e[3]:e[2],r=this.dataFormat==="channelsFirst"?e[4]:e[3];return n=Qs(n,this.poolSize[0],this.padding,this.strides[0]),s=Qs(s,this.poolSize[1],this.padding,this.strides[1]),r=Qs(r,this.poolSize[2],this.padding,this.strides[2]),this.dataFormat==="channelsFirst"?[e[0],e[1],n,s,r]:[e[0],n,s,r,e[4]]}call(e,n){return P(()=>(this.invokeCallHook(e,n),this.poolingFunction(Ce(e),this.poolSize,this.strides,this.padding,this.dataFormat)))}getConfig(){const e={poolSize:this.poolSize,padding:this.padding,strides:this.strides,dataFormat:this.dataFormat},n=super.getConfig();return Object.assign(e,n),e}}class fR extends dR{constructor(e){super(e)}poolingFunction(e,n,s,r,o){return Nt(o),hs(r),oR(e,n,s,r,o,"max")}}fR.className="MaxPooling3D";Y(fR);class pR extends dR{constructor(e){super(e)}poolingFunction(e,n,s,r,o){return Nt(o),hs(r),oR(e,n,s,r,o,"avg")}}pR.className="AveragePooling3D";Y(pR);class mR extends Ae{constructor(e){super(e),this.inputSpec=[new Pt({ndim:3})]}computeOutputShape(e){return[e[0],e[2]]}call(e,n){throw new Ie}}class gR extends mR{constructor(e){super(e||{})}call(e,n){return P(()=>{const s=Ce(e);return Rt(s,1)})}}gR.className="GlobalAveragePooling1D";Y(gR);class xR extends mR{constructor(e){super(e||{})}call(e,n){return P(()=>{const s=Ce(e);return Ys(s,1)})}}xR.className="GlobalMaxPooling1D";Y(xR);class yR extends Ae{constructor(e){super(e),this.dataFormat=e.dataFormat==null?"channelsLast":e.dataFormat,Nt(this.dataFormat),this.inputSpec=[new Pt({ndim:4})]}computeOutputShape(e){return e=e,this.dataFormat==="channelsLast"?[e[0],e[3]]:[e[0],e[1]]}call(e,n){throw new Ie}getConfig(){const e={dataFormat:this.dataFormat},n=super.getConfig();return Object.assign(e,n),e}}class wR extends yR{call(e,n){return P(()=>{const s=Ce(e);return this.dataFormat==="channelsLast"?Rt(s,[1,2]):Rt(s,[2,3])})}}wR.className="GlobalAveragePooling2D";Y(wR);class vR extends yR{call(e,n){return P(()=>{const s=Ce(e);return this.dataFormat==="channelsLast"?Ys(s,[1,2]):Ys(s,[2,3])})}}vR.className="GlobalMaxPooling2D";Y(vR);/** + */function Fm(t,e,n,s,r,o){return P(()=>{Nt(r),vT(o),hs(s),n==null&&(n=[1,1]),s==null&&(s="valid"),r==null&&(r=er()),o==null&&(o="max"),t=ov(t,r);let i;const a=s==="same"?"same":"valid";return o==="max"?i=jy(t,e,n,a):i=Oy(t,e,n,a),r==="channelsFirst"&&(i=Fe(i,[0,3,1,2])),i})}function oR(t,e,n,s,r,o){return P(()=>{Nt(r),vT(o),hs(s),n==null&&(n=[1,1,1]),s==null&&(s="valid"),r==null&&(r=er()),o==null&&(o="max"),t=CE(t,r);let i;const a=s==="same"?"same":"valid";return o==="max"?i=NB(t,e,n,a):i=EL(t,e,n,a),r==="channelsFirst"&&(i=Fe(i,[0,4,1,2,3])),i})}class iR extends Ae{constructor(e){if(e.poolSize==null&&(e.poolSize=2),super(e),typeof e.poolSize=="number")this.poolSize=[e.poolSize];else if(Array.isArray(e.poolSize)&&e.poolSize.length===1&&typeof e.poolSize[0]=="number")this.poolSize=e.poolSize;else throw new E(`poolSize for 1D convolutional layer must be a number or an Array of a single number, but received ${JSON.stringify(e.poolSize)}`);if(qt(this.poolSize,"poolSize"),e.strides==null)this.strides=this.poolSize;else if(typeof e.strides=="number")this.strides=[e.strides];else if(Array.isArray(e.strides)&&e.strides.length===1&&typeof e.strides[0]=="number")this.strides=e.strides;else throw new E(`strides for 1D convolutional layer must be a number or an Array of a single number, but received ${JSON.stringify(e.strides)}`);qt(this.strides,"strides"),this.padding=e.padding==null?"valid":e.padding,hs(this.padding),this.inputSpec=[new Pt({ndim:3})]}computeOutputShape(e){e=Pe(e);const n=Qs(e[1],this.poolSize[0],this.padding,this.strides[0]);return[e[0],n,e[2]]}call(e,n){return P(()=>{this.invokeCallHook(e,n),e=wh(Ce(e),2);const s=this.poolingFunction(Ce(e),[this.poolSize[0],1],[this.strides[0],1],this.padding,"channelsLast");return fh(s,[2])})}getConfig(){const e={poolSize:this.poolSize,padding:this.padding,strides:this.strides},n=super.getConfig();return Object.assign(e,n),e}}class aR extends iR{constructor(e){super(e)}poolingFunction(e,n,s,r,o){return Nt(o),hs(r),Fm(e,n,s,r,o,"max")}}aR.className="MaxPooling1D";Y(aR);class lR extends iR{constructor(e){super(e)}poolingFunction(e,n,s,r,o){return Nt(o),hs(r),Fm(e,n,s,r,o,"avg")}}lR.className="AveragePooling1D";Y(lR);class cR extends Ae{constructor(e){if(e.poolSize==null&&(e.poolSize=[2,2]),super(e),this.poolSize=Array.isArray(e.poolSize)?e.poolSize:[e.poolSize,e.poolSize],e.strides==null)this.strides=this.poolSize;else if(Array.isArray(e.strides)){if(e.strides.length!==2)throw new E(`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];qt(this.poolSize,"poolSize"),qt(this.strides,"strides"),this.padding=e.padding==null?"valid":e.padding,this.dataFormat=e.dataFormat==null?"channelsLast":e.dataFormat,Nt(this.dataFormat),hs(this.padding),this.inputSpec=[new Pt({ndim:4})]}computeOutputShape(e){e=Pe(e);let n=this.dataFormat==="channelsFirst"?e[2]:e[1],s=this.dataFormat==="channelsFirst"?e[3]:e[2];return n=Qs(n,this.poolSize[0],this.padding,this.strides[0]),s=Qs(s,this.poolSize[1],this.padding,this.strides[1]),this.dataFormat==="channelsFirst"?[e[0],e[1],n,s]:[e[0],n,s,e[3]]}call(e,n){return P(()=>(this.invokeCallHook(e,n),this.poolingFunction(Ce(e),this.poolSize,this.strides,this.padding,this.dataFormat)))}getConfig(){const e={poolSize:this.poolSize,padding:this.padding,strides:this.strides,dataFormat:this.dataFormat},n=super.getConfig();return Object.assign(e,n),e}}class uR extends cR{constructor(e){super(e)}poolingFunction(e,n,s,r,o){return Nt(o),hs(r),Fm(e,n,s,r,o,"max")}}uR.className="MaxPooling2D";Y(uR);class hR extends cR{constructor(e){super(e)}poolingFunction(e,n,s,r,o){return Nt(o),hs(r),Fm(e,n,s,r,o,"avg")}}hR.className="AveragePooling2D";Y(hR);class dR extends Ae{constructor(e){if(e.poolSize==null&&(e.poolSize=[2,2,2]),super(e),this.poolSize=Array.isArray(e.poolSize)?e.poolSize:[e.poolSize,e.poolSize,e.poolSize],e.strides==null)this.strides=this.poolSize;else if(Array.isArray(e.strides)){if(e.strides.length!==3)throw new E(`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];qt(this.poolSize,"poolSize"),qt(this.strides,"strides"),this.padding=e.padding==null?"valid":e.padding,this.dataFormat=e.dataFormat==null?"channelsLast":e.dataFormat,Nt(this.dataFormat),hs(this.padding),this.inputSpec=[new Pt({ndim:5})]}computeOutputShape(e){e=Pe(e);let n=this.dataFormat==="channelsFirst"?e[2]:e[1],s=this.dataFormat==="channelsFirst"?e[3]:e[2],r=this.dataFormat==="channelsFirst"?e[4]:e[3];return n=Qs(n,this.poolSize[0],this.padding,this.strides[0]),s=Qs(s,this.poolSize[1],this.padding,this.strides[1]),r=Qs(r,this.poolSize[2],this.padding,this.strides[2]),this.dataFormat==="channelsFirst"?[e[0],e[1],n,s,r]:[e[0],n,s,r,e[4]]}call(e,n){return P(()=>(this.invokeCallHook(e,n),this.poolingFunction(Ce(e),this.poolSize,this.strides,this.padding,this.dataFormat)))}getConfig(){const e={poolSize:this.poolSize,padding:this.padding,strides:this.strides,dataFormat:this.dataFormat},n=super.getConfig();return Object.assign(e,n),e}}class fR extends dR{constructor(e){super(e)}poolingFunction(e,n,s,r,o){return Nt(o),hs(r),oR(e,n,s,r,o,"max")}}fR.className="MaxPooling3D";Y(fR);class pR extends dR{constructor(e){super(e)}poolingFunction(e,n,s,r,o){return Nt(o),hs(r),oR(e,n,s,r,o,"avg")}}pR.className="AveragePooling3D";Y(pR);class mR extends Ae{constructor(e){super(e),this.inputSpec=[new Pt({ndim:3})]}computeOutputShape(e){return[e[0],e[2]]}call(e,n){throw new Ie}}class gR extends mR{constructor(e){super(e||{})}call(e,n){return P(()=>{const s=Ce(e);return Rt(s,1)})}}gR.className="GlobalAveragePooling1D";Y(gR);class xR extends mR{constructor(e){super(e||{})}call(e,n){return P(()=>{const s=Ce(e);return Ys(s,1)})}}xR.className="GlobalMaxPooling1D";Y(xR);class yR extends Ae{constructor(e){super(e),this.dataFormat=e.dataFormat==null?"channelsLast":e.dataFormat,Nt(this.dataFormat),this.inputSpec=[new Pt({ndim:4})]}computeOutputShape(e){return e=e,this.dataFormat==="channelsLast"?[e[0],e[3]]:[e[0],e[1]]}call(e,n){throw new Ie}getConfig(){const e={dataFormat:this.dataFormat},n=super.getConfig();return Object.assign(e,n),e}}class wR extends yR{call(e,n){return P(()=>{const s=Ce(e);return this.dataFormat==="channelsLast"?Rt(s,[1,2]):Rt(s,[2,3])})}}wR.className="GlobalAveragePooling2D";Y(wR);class vR extends yR{call(e,n){return P(()=>{const s=Ce(e);return this.dataFormat==="channelsLast"?Ys(s,[1,2]):Ys(s,[2,3])})}}vR.className="GlobalMaxPooling2D";Y(vR);/** * @license * Copyright 2018 Google LLC * @@ -7953,7 +7953,7 @@ body { * license that can be found in the LICENSE file or at * https://opensource.org/licenses/MIT. * ============================================================================= - */class bR extends Ae{constructor(e){super(e),this.layer=e.layer}build(e){this.built=!0}get trainable(){return this.layer!=null?this.layer.trainable:!1}set trainable(e){this.layer!=null&&(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()}},n=super.getConfig();return Object.assign(e,n),e}setFastWeightInitDuringBuild(e){super.setFastWeightInitDuringBuild(e),this.layer!=null&&this.layer.setFastWeightInitDuringBuild(e)}static fromConfig(e,n,s={}){const r=n.layer,o=Cr(r,s);delete n.layer;const i={layer:o};return Object.assign(i,n),new e(i)}}class CR extends bR{constructor(e){super(e),this.supportsMasking=!0}build(e){if(e=Pe(e),e.length<3)throw new E(`TimeDistributed layer expects an input shape >= 3D, but received input shape ${JSON.stringify(e)}`);this.inputSpec=[{shape:e}];const n=[e[0]].concat(e.slice(2));this.layer.built||(this.layer.build(n),this.layer.built=!0),super.build(e)}computeOutputShape(e){e=Pe(e);const n=[e[0]].concat(e.slice(2)),s=this.layer.computeOutputShape(n),r=e[1];return[s[0],r].concat(s.slice(1))}call(e,n){return P(()=>(e=Ce(e),AE((i,a)=>[Ce(this.layer.call(i,n)),[]],e,[],!1,null,null,!1,!0)[1]))}}CR.className="TimeDistributed";Y(CR);function bH(t){Zi(L6,"BidirectionalMergeMode",t)}const CH="concat";class kR extends bR{constructor(e){super(e);const n=e.layer.getConfig(),s={};s.className=e.layer.getClassName(),s.config=n,this.forwardLayer=Cr(s),n.goBackwards=n.goBackwards!==!0;const r={};if(r.className=e.layer.getClassName(),r.config=n,this.backwardLayer=Cr(r),this.forwardLayer.name="forward_"+this.forwardLayer.name,this.backwardLayer.name="backward_"+this.backwardLayer.name,this.mergeMode=e.mergeMode===void 0?CH:e.mergeMode,bH(this.mergeMode),e.weights)throw new Ie("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,this.forwardLayer!=null&&(this.forwardLayer.trainable=e),this.backwardLayer!=null&&(this.backwardLayer.trainable=e)}getWeights(){return this.forwardLayer.getWeights().concat(this.backwardLayer.getWeights())}setWeights(e){const n=e.length,s=Math.floor(n/2);this.forwardLayer.setWeights(e.slice(0,s)),this.backwardLayer.setWeights(e.slice(s))}computeOutputShape(e){let n=this.forwardLayer.computeOutputShape(e);Array.isArray(n)&&Array.isArray(n[0])||(n=[n]),n=n;let s,r,o;return this.returnState&&(o=n.slice(1)),s=n[0],s=s,this.mergeMode==="concat"?(s[s.length-1]*=2,r=[s]):this.mergeMode==null?r=[s,s.slice()]:r=[s],this.returnState?this.mergeMode==null?r.concat(o).concat(o.slice()):[s].concat(o).concat(o.slice()):Rn(r)}apply(e,n){let s=n==null?null:n.initialState,r=n==null?null:n.constants;n==null&&(n={});const o=RE(e,s,r,this.numConstants);if(e=o.inputs,s=o.initialState,r=o.constants,Array.isArray(e)&&(s=e.slice(1),e=e[0]),(s==null||s.length===0)&&r==null)return super.apply(e,n);const i=[],a=[];if(s!=null){const c=s.length;if(c%2>0)throw new E("When passing `initialState` to a Bidrectional RNN, the state should be an Array containing the states of the underlying RNNs.");n.initialState=s,i.push(...s);const u=s.map(h=>new Pt({shape:h.shape}));this.forwardLayer.stateSpec=u.slice(0,c/2),this.backwardLayer.stateSpec=u.slice(c/2),a.push(...u)}if(r!=null)throw new Ie("Support for constants in Bidirectional layers is not implemented yet.");const l=i[0]instanceof $r;for(const c of i)if(c instanceof $r!==l)throw new E("The initial state of a Bidirectional layer cannot be specified as a mix of symbolic and non-symbolic tensors");if(l){const c=[e].concat(i),u=this.inputSpec.concat(a),h=this.inputSpec;this.inputSpec=u;const d=super.apply(c,n);return this.inputSpec=h,d}else return super.apply(e,n)}call(e,n){return P(()=>{const s=n.initialState;let r,o;if(s==null)r=this.forwardLayer.call(e,n),o=this.backwardLayer.call(e,n);else{const l=s.slice(0,s.length/2),c=s.slice(s.length/2);r=this.forwardLayer.call(e,Object.assign(n,{initialState:l})),o=this.backwardLayer.call(e,Object.assign(n,{initialState:c}))}let i;this.returnState&&(Array.isArray(r)&&(i=r.slice(1).concat(o.slice(1))),r=r[0],o=o[0]),this.returnSequences&&(o=Mi(o,1));let a;return this.mergeMode==="concat"?a=jw([r,o]):this.mergeMode==="sum"?a=J(r,o):this.mergeMode==="ave"?a=D(.5,J(r,o)):this.mergeMode==="mul"?a=D(r,o):this.mergeMode==null&&(a=[r,o]),this.returnState?this.mergeMode==null?a.concat(i):[a].concat(i):a})}resetStates(e){this.forwardLayer.resetStates(),this.backwardLayer.resetStates()}build(e){bi(this.forwardLayer.name,()=>{this.forwardLayer.build(e)}),bi(this.backwardLayer.name,()=>{this.backwardLayer.build(e)}),this.built=!0}computeMask(e,n){Array.isArray(n)&&(n=n[0]);let s;if(this.returnSequences?this.mergeMode==null?s=[n,n]:s=n:this.mergeMode==null?s=[null,null]:s=null,this.returnState){const o=this.forwardLayer.states.map(i=>null);return Array.isArray(s)?s.concat(o).concat(o):[s].concat(o).concat(o)}else return s}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),this.forwardLayer!=null&&this.forwardLayer.setFastWeightInitDuringBuild(e),this.backwardLayer!=null&&this.backwardLayer.setFastWeightInitDuringBuild(e)}getConfig(){const e={mergeMode:this.mergeMode},n=super.getConfig();return Object.assign(e,n),e}static fromConfig(e,n){const s=Cr(n.layer);if(delete n.layer,n.numConstants!=null)throw new Ie("Deserialization of a Bidirectional layer with numConstants present is not supported yet.");const r=n;return r.layer=s,new e(r)}}kR.className="Bidirectional";Y(kR);/** + */class bR extends Ae{constructor(e){super(e),this.layer=e.layer}build(e){this.built=!0}get trainable(){return this.layer!=null?this.layer.trainable:!1}set trainable(e){this.layer!=null&&(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()}},n=super.getConfig();return Object.assign(e,n),e}setFastWeightInitDuringBuild(e){super.setFastWeightInitDuringBuild(e),this.layer!=null&&this.layer.setFastWeightInitDuringBuild(e)}static fromConfig(e,n,s={}){const r=n.layer,o=Cr(r,s);delete n.layer;const i={layer:o};return Object.assign(i,n),new e(i)}}class CR extends bR{constructor(e){super(e),this.supportsMasking=!0}build(e){if(e=Pe(e),e.length<3)throw new E(`TimeDistributed layer expects an input shape >= 3D, but received input shape ${JSON.stringify(e)}`);this.inputSpec=[{shape:e}];const n=[e[0]].concat(e.slice(2));this.layer.built||(this.layer.build(n),this.layer.built=!0),super.build(e)}computeOutputShape(e){e=Pe(e);const n=[e[0]].concat(e.slice(2)),s=this.layer.computeOutputShape(n),r=e[1];return[s[0],r].concat(s.slice(1))}call(e,n){return P(()=>(e=Ce(e),AE((i,a)=>[Ce(this.layer.call(i,n)),[]],e,[],!1,null,null,!1,!0)[1]))}}CR.className="TimeDistributed";Y(CR);function vH(t){Zi(P6,"BidirectionalMergeMode",t)}const bH="concat";class kR extends bR{constructor(e){super(e);const n=e.layer.getConfig(),s={};s.className=e.layer.getClassName(),s.config=n,this.forwardLayer=Cr(s),n.goBackwards=n.goBackwards!==!0;const r={};if(r.className=e.layer.getClassName(),r.config=n,this.backwardLayer=Cr(r),this.forwardLayer.name="forward_"+this.forwardLayer.name,this.backwardLayer.name="backward_"+this.backwardLayer.name,this.mergeMode=e.mergeMode===void 0?bH:e.mergeMode,vH(this.mergeMode),e.weights)throw new Ie("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,this.forwardLayer!=null&&(this.forwardLayer.trainable=e),this.backwardLayer!=null&&(this.backwardLayer.trainable=e)}getWeights(){return this.forwardLayer.getWeights().concat(this.backwardLayer.getWeights())}setWeights(e){const n=e.length,s=Math.floor(n/2);this.forwardLayer.setWeights(e.slice(0,s)),this.backwardLayer.setWeights(e.slice(s))}computeOutputShape(e){let n=this.forwardLayer.computeOutputShape(e);Array.isArray(n)&&Array.isArray(n[0])||(n=[n]),n=n;let s,r,o;return this.returnState&&(o=n.slice(1)),s=n[0],s=s,this.mergeMode==="concat"?(s[s.length-1]*=2,r=[s]):this.mergeMode==null?r=[s,s.slice()]:r=[s],this.returnState?this.mergeMode==null?r.concat(o).concat(o.slice()):[s].concat(o).concat(o.slice()):Rn(r)}apply(e,n){let s=n==null?null:n.initialState,r=n==null?null:n.constants;n==null&&(n={});const o=RE(e,s,r,this.numConstants);if(e=o.inputs,s=o.initialState,r=o.constants,Array.isArray(e)&&(s=e.slice(1),e=e[0]),(s==null||s.length===0)&&r==null)return super.apply(e,n);const i=[],a=[];if(s!=null){const c=s.length;if(c%2>0)throw new E("When passing `initialState` to a Bidrectional RNN, the state should be an Array containing the states of the underlying RNNs.");n.initialState=s,i.push(...s);const u=s.map(h=>new Pt({shape:h.shape}));this.forwardLayer.stateSpec=u.slice(0,c/2),this.backwardLayer.stateSpec=u.slice(c/2),a.push(...u)}if(r!=null)throw new Ie("Support for constants in Bidirectional layers is not implemented yet.");const l=i[0]instanceof $r;for(const c of i)if(c instanceof $r!==l)throw new E("The initial state of a Bidirectional layer cannot be specified as a mix of symbolic and non-symbolic tensors");if(l){const c=[e].concat(i),u=this.inputSpec.concat(a),h=this.inputSpec;this.inputSpec=u;const d=super.apply(c,n);return this.inputSpec=h,d}else return super.apply(e,n)}call(e,n){return P(()=>{const s=n.initialState;let r,o;if(s==null)r=this.forwardLayer.call(e,n),o=this.backwardLayer.call(e,n);else{const l=s.slice(0,s.length/2),c=s.slice(s.length/2);r=this.forwardLayer.call(e,Object.assign(n,{initialState:l})),o=this.backwardLayer.call(e,Object.assign(n,{initialState:c}))}let i;this.returnState&&(Array.isArray(r)&&(i=r.slice(1).concat(o.slice(1))),r=r[0],o=o[0]),this.returnSequences&&(o=Mi(o,1));let a;return this.mergeMode==="concat"?a=jw([r,o]):this.mergeMode==="sum"?a=J(r,o):this.mergeMode==="ave"?a=D(.5,J(r,o)):this.mergeMode==="mul"?a=D(r,o):this.mergeMode==null&&(a=[r,o]),this.returnState?this.mergeMode==null?a.concat(i):[a].concat(i):a})}resetStates(e){this.forwardLayer.resetStates(),this.backwardLayer.resetStates()}build(e){bi(this.forwardLayer.name,()=>{this.forwardLayer.build(e)}),bi(this.backwardLayer.name,()=>{this.backwardLayer.build(e)}),this.built=!0}computeMask(e,n){Array.isArray(n)&&(n=n[0]);let s;if(this.returnSequences?this.mergeMode==null?s=[n,n]:s=n:this.mergeMode==null?s=[null,null]:s=null,this.returnState){const o=this.forwardLayer.states.map(i=>null);return Array.isArray(s)?s.concat(o).concat(o):[s].concat(o).concat(o)}else return s}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),this.forwardLayer!=null&&this.forwardLayer.setFastWeightInitDuringBuild(e),this.backwardLayer!=null&&this.backwardLayer.setFastWeightInitDuringBuild(e)}getConfig(){const e={mergeMode:this.mergeMode},n=super.getConfig();return Object.assign(e,n),e}static fromConfig(e,n){const s=Cr(n.layer);if(delete n.layer,n.numConstants!=null)throw new Ie("Deserialization of a Bidirectional layer with numConstants present is not supported yet.");const r=n;return r.layer=s,new e(r)}}kR.className="Bidirectional";Y(kR);/** * @license * Copyright 2022 CodeSmith LLC * @@ -7969,7 +7969,7 @@ body { * license that can be found in the LICENSE file or at * https://opensource.org/licenses/MIT. * ============================================================================= - */const{resizeBilinear:kH,cropAndResize:SH}=Mr;class IR extends Ae{constructor(e){super(e),this.height=e.height,this.width=e.width}centerCrop(e,n,s,r,o,i,a,l){return P(()=>{let c,u=!1;const h=n/i,d=s/a,f=(r+n)/i,p=(o+s)/a,g=[h,d,f,p],x=[];e.rank===3?(u=!0,c=Hr([e])):c=e;for(let b=0;b{const o=kH(e,[n,s]);return vr(o,r)})}call(e,n){return P(()=>{const s=Ce(e),r=s.dtype,o=s.shape,i=o[o.length-3],a=o[o.length-2];let l=0;i!==this.height&&(l=Math.floor((i-this.height)/2));let c=0;return a!==this.width&&(c=Math.floor((a-this.width)/2),c===0&&(c=1)),l>=0&&c>=0?this.centerCrop(s,l,c,this.height,this.width,i,a,r):this.upsize(e,this.height,this.width,r)})}getConfig(){const e={height:this.height,width:this.width},n=super.getConfig();return Object.assign(e,n),e}computeOutputShape(e){e=Pe(e);const n=e.length-3,s=e.length-2;return e[n]=this.height,e[s]=this.width,e}}IR.className="CenterCrop";Y(IR);/** + */const{resizeBilinear:CH,cropAndResize:kH}=Mr;class IR extends Ae{constructor(e){super(e),this.height=e.height,this.width=e.width}centerCrop(e,n,s,r,o,i,a,l){return P(()=>{let c,u=!1;const h=n/i,d=s/a,f=(r+n)/i,p=(o+s)/a,g=[h,d,f,p],x=[];e.rank===3?(u=!0,c=Hr([e])):c=e;for(let b=0;b{const o=CH(e,[n,s]);return vr(o,r)})}call(e,n){return P(()=>{const s=Ce(e),r=s.dtype,o=s.shape,i=o[o.length-3],a=o[o.length-2];let l=0;i!==this.height&&(l=Math.floor((i-this.height)/2));let c=0;return a!==this.width&&(c=Math.floor((a-this.width)/2),c===0&&(c=1)),l>=0&&c>=0?this.centerCrop(s,l,c,this.height,this.width,i,a,r):this.upsize(e,this.height,this.width,r)})}getConfig(){const e={height:this.height,width:this.width},n=super.getConfig();return Object.assign(e,n),e}computeOutputShape(e){e=Pe(e);const n=e.length-3,s=e.length-2;return e[n]=this.height,e[s]=this.width,e}}IR.className="CenterCrop";Y(IR);/** * @license * Copyright 2022 CodeSmith LLC * @@ -7977,7 +7977,7 @@ body { * license that can be found in the LICENSE file or at * https://opensource.org/licenses/MIT. * ============================================================================= - */function IH(t,e,n,s){let r=Ce(t);if(r.dtype!=="int32"&&(r=vr(r,"int32")),e==="int")return r;const o=r.shape;if(r.rank===0&&(r=En(r,-1)),e==="oneHot"&&r.shape[r.shape.length-1]!==1&&(r=En(r,-1)),r.rank>2)throw new E(`When outputMode is not int, maximum output rank is 2 Received outputMode ${e} and input shape ${o} which would result in output rank ${r.rank}.`);const i=["multiHot","oneHot"].includes(e),a=r;let l;if(typeof s<"u"&&e==="count"?l=RC(a,s,n,i):l=RC(a,[],n,i),e!=="tfIdf")return l;if(s)return D(l,s);throw new E("When outputMode is 'tfIdf', weights must be provided.")}/** + */function SH(t,e,n,s){let r=Ce(t);if(r.dtype!=="int32"&&(r=vr(r,"int32")),e==="int")return r;const o=r.shape;if(r.rank===0&&(r=En(r,-1)),e==="oneHot"&&r.shape[r.shape.length-1]!==1&&(r=En(r,-1)),r.rank>2)throw new E(`When outputMode is not int, maximum output rank is 2 Received outputMode ${e} and input shape ${o} which would result in output rank ${r.rank}.`);const i=["multiHot","oneHot"].includes(e),a=r;let l;if(typeof s<"u"&&e==="count"?l=RC(a,s,n,i):l=RC(a,[],n,i),e!=="tfIdf")return l;if(s)return D(l,s);throw new E("When outputMode is 'tfIdf', weights must be provided.")}/** * @license * Copyright 2022 CodeSmith LLC * @@ -7986,7 +7986,7 @@ body { * https://opensource.org/licenses/MIT. * ============================================================================= */class $R extends Ae{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},n=super.getConfig();return Object.assign(e,n),e}computeOutputShape(e){return e=Pe(e),e==null?[this.numTokens]:this.outputMode==="oneHot"&&e[e.length-1]!==1?(e.push(this.numTokens),e):(e[e.length-1]=this.numTokens,e)}call(e,n){return P(()=>{e=Ce(e),e.dtype!=="int32"&&(e=vr(e,"int32"));let s;if(typeof n.countWeights<"u"){if(this.outputMode!=="count")throw new E(`countWeights is not used when outputMode !== count. - Received countWeights=${n.countWeights}`);s=Ce(n.countWeights)}const r=Ys(e),o=wf(e),i=us(this.numTokens,r).bufferSync().get(0),a=Xi(o,0).bufferSync().get(0);if(!(i&&a))throw new E(`Input values must be between 0 < values <= numTokens with numTokens=${this.numTokens}`);return IH(e,this.outputMode,this.numTokens,s)})}}$R.className="CategoryEncoding";Y($R);/** + Received countWeights=${n.countWeights}`);s=Ce(n.countWeights)}const r=Ys(e),o=yf(e),i=us(this.numTokens,r).bufferSync().get(0),a=Xi(o,0).bufferSync().get(0);if(!(i&&a))throw new E(`Input values must be between 0 < values <= numTokens with numTokens=${this.numTokens}`);return SH(e,this.outputMode,this.numTokens,s)})}}$R.className="CategoryEncoding";Y($R);/** * @license * Copyright 2022 CodeSmith LLC * @@ -7994,7 +7994,7 @@ body { * license that can be found in the LICENSE file or at * https://opensource.org/licenses/MIT. * ============================================================================= - */const $H=["bilinear","nearest"],hk=new Set($H);class NR extends Ae{constructor(e){if(super(e),this.height=e.height,this.width=e.width,e.interpolation)if(hk.has(e.interpolation))this.interpolation=e.interpolation;else throw new E(`Invalid interpolation parameter: ${e.interpolation} is not implemented`);else this.interpolation="bilinear";this.cropToAspectRatio=!!e.cropToAspectRatio}computeOutputShape(e){e=Pe(e);const n=e[2];return[this.height,this.width,n]}getConfig(){const e={height:this.height,width:this.width,interpolation:this.interpolation,cropToAspectRatio:this.cropToAspectRatio},n=super.getConfig();return Object.assign(e,n),e}call(e,n){return P(()=>{const s=[this.height,this.width];if(this.interpolation==="bilinear")return Mr.resizeBilinear(e,s,!this.cropToAspectRatio);if(this.interpolation==="nearest")return Mr.resizeNearestNeighbor(e,s,!this.cropToAspectRatio);throw new Error(`Interpolation is ${this.interpolation} but only ${[...hk]} are supported`)})}}NR.className="Resizing";Y(NR);/** + */const IH=["bilinear","nearest"],hk=new Set(IH);class NR extends Ae{constructor(e){if(super(e),this.height=e.height,this.width=e.width,e.interpolation)if(hk.has(e.interpolation))this.interpolation=e.interpolation;else throw new E(`Invalid interpolation parameter: ${e.interpolation} is not implemented`);else this.interpolation="bilinear";this.cropToAspectRatio=!!e.cropToAspectRatio}computeOutputShape(e){e=Pe(e);const n=e[2];return[this.height,this.width,n]}getConfig(){const e={height:this.height,width:this.width,interpolation:this.interpolation,cropToAspectRatio:this.cropToAspectRatio},n=super.getConfig();return Object.assign(e,n),e}call(e,n){return P(()=>{const s=[this.height,this.width];if(this.interpolation==="bilinear")return Mr.resizeBilinear(e,s,!this.cropToAspectRatio);if(this.interpolation==="nearest")return Mr.resizeNearestNeighbor(e,s,!this.cropToAspectRatio);throw new Error(`Interpolation is ${this.interpolation} but only ${[...hk]} are supported`)})}}NR.className="Resizing";Y(NR);/** * @license * Copyright 2023 CodeSmith LLC * @@ -8018,10 +8018,10 @@ body { * license that can be found in the LICENSE file or at * https://opensource.org/licenses/MIT. * ============================================================================= - */const NH=["bilinear","nearest"],dk=new Set(NH);class RR extends ER{constructor(e){super(e);const{factor:n,interpolation:s="bilinear"}=e;if(this.factor=n,Array.isArray(this.factor)&&this.factor.length===2)this.widthLower=this.factor[0],this.widthUpper=this.factor[1];else if(!Array.isArray(this.factor)&&this.factor>0)this.widthLower=-this.factor,this.widthUpper=this.factor;else throw new E(`Invalid factor: ${this.factor}. Must be positive number or tuple of 2 numbers`);if(this.widthLower<-1||this.widthUpper<-1)throw new E(`factor must have values larger than -1. Got: ${this.factor}`);if(this.widthUpper0)this.widthLower=-this.factor,this.widthUpper=this.factor;else throw new E(`Invalid factor: ${this.factor}. Must be positive number or tuple of 2 numbers`);if(this.widthLower<-1||this.widthUpper<-1)throw new E(`factor must have values larger than -1. Got: ${this.factor}`);if(this.widthUpper{const s=Ce(e);this.imgHeight=s.shape[s.shape.length-3];const r=s.shape[s.shape.length-2];this.widthFactor=fh([1],1+this.widthLower,1+this.widthUpper,"float32",this.randomGenerator.next());let o=this.widthFactor.dataSync()[0]*r;o=Math.round(o);const i=[this.imgHeight,o];switch(this.interpolation){case"bilinear":return Mr.resizeBilinear(e,i);case"nearest":return Mr.resizeNearestNeighbor(e,i);default:throw new Error(`Interpolation is ${this.interpolation} + `);if(s)if(dk.has(s))this.interpolation=s;else throw new E(`Invalid interpolation parameter: ${s} is not implemented`)}getConfig(){const e={factor:this.factor,interpolation:this.interpolation},n=super.getConfig();return Object.assign(e,n),e}computeOutputShape(e){e=Pe(e);const n=e[2];return[this.imgHeight,-1,n]}call(e,n){return P(()=>{const s=Ce(e);this.imgHeight=s.shape[s.shape.length-3];const r=s.shape[s.shape.length-2];this.widthFactor=dh([1],1+this.widthLower,1+this.widthUpper,"float32",this.randomGenerator.next());let o=this.widthFactor.dataSync()[0]*r;o=Math.round(o);const i=[this.imgHeight,o];switch(this.interpolation){case"bilinear":return Mr.resizeBilinear(e,i);case"nearest":return Mr.resizeNearestNeighbor(e,i);default:throw new Error(`Interpolation is ${this.interpolation} but only ${[...dk]} are supported`)}})}}RR.className="RandomWidth";Y(RR);/** * @license * Copyright 2021 Google LLC. All Rights Reserved. @@ -8037,7 +8037,7 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const TH=W();TH.registerFlag("KEEP_INTERMEDIATE_TENSORS",()=>!1,t=>{t&&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.")});/** + */const NH=W();NH.registerFlag("KEEP_INTERMEDIATE_TENSORS",()=>!1,t=>{t&&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.")});/** * @license * Copyright 2019 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -8099,10 +8099,10 @@ body { * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const EH=SN;class zm extends Mx{nextDataId(){return zm.nextDataId++}constructor(){super(),this.blockSize=48,this.firstUse=!0,this.data=new jI(this,ir())}write(e,n,s){this.firstUse&&(this.firstUse=!1,W().get("IS_NODE")&&es(` + */const TH=SN;class zm extends Mx{nextDataId(){return zm.nextDataId++}constructor(){super(),this.blockSize=48,this.firstUse=!0,this.data=new jI(this,ir())}write(e,n,s){this.firstUse&&(this.firstUse=!1,W().get("IS_NODE")&&es(` ============================ Hi, 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. -============================`));const r={id:this.nextDataId()};return this.data.set(r,{values:e,dtype:s,refCount:1}),r}makeTensorInfo(e,n,s){let r;if(n==="string"&&s!=null&&s.length>0&&fu(s[0])){const o=s.map(i=>No(i));r=this.write(o,e,n)}else r=this.write(s,e,n);return{dataId:r,shape:e,dtype:n}}refCount(e){return this.data.has(e)?this.data.get(e).refCount:0}incRef(e){const n=this.data.get(e);n.refCount++}decRef(e){if(this.data.has(e)){const n=this.data.get(e);n.refCount--}}move(e,n,s,r,o){this.data.set(e,{values:n,dtype:r,refCount:o})}numDataIds(){return this.data.numDataIds()}async read(e){return this.readSync(e)}readSync(e){const{dtype:n,complexTensorInfos:s}=this.data.get(e);if(n==="complex64"){const r=this.readSync(s.real.dataId),o=this.readSync(s.imag.dataId);return jr(r,o)}return FM(this.data.get(e).values,n)}bufferSync(e){const n=this.readSync(e.dataId);if(e.dtype==="string")try{const s=n.map(r=>Do(r));return Ee(e.shape,e.dtype,s)}catch{throw new Error("Failed to decode encoded string bytes into utf-8")}return Ee(e.shape,e.dtype,n)}makeOutput(e,n,s){return ir().makeTensorFromTensorInfo(this.makeTensorInfo(n,s,e),this)}disposeData(e,n=!1){if(this.data.has(e)){if(this.data.get(e).refCount--,!n&&this.data.get(e).refCount>0)return!1;const{complexTensorInfos:s}=this.data.get(e);s!=null&&(this.disposeData(s.real.dataId,!0),this.disposeData(s.imag.dataId,!0)),this.data.delete(e)}return!0}disposeIntermediateTensorInfo(e){this.disposeData(e.dataId)}async time(e){const n=Tn();return e(),{kernelMs:Tn()-n}}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){de([e],"where");const n=this.readSync(e.dataId);return EH(e.shape,n)}dispose(){}floatPrecision(){return 32}epsilon(){return super.epsilon()}}zm.nextDataId=0;/** +============================`));const r={id:this.nextDataId()};return this.data.set(r,{values:e,dtype:s,refCount:1}),r}makeTensorInfo(e,n,s){let r;if(n==="string"&&s!=null&&s.length>0&&du(s[0])){const o=s.map(i=>No(i));r=this.write(o,e,n)}else r=this.write(s,e,n);return{dataId:r,shape:e,dtype:n}}refCount(e){return this.data.has(e)?this.data.get(e).refCount:0}incRef(e){const n=this.data.get(e);n.refCount++}decRef(e){if(this.data.has(e)){const n=this.data.get(e);n.refCount--}}move(e,n,s,r,o){this.data.set(e,{values:n,dtype:r,refCount:o})}numDataIds(){return this.data.numDataIds()}async read(e){return this.readSync(e)}readSync(e){const{dtype:n,complexTensorInfos:s}=this.data.get(e);if(n==="complex64"){const r=this.readSync(s.real.dataId),o=this.readSync(s.imag.dataId);return jr(r,o)}return _M(this.data.get(e).values,n)}bufferSync(e){const n=this.readSync(e.dataId);if(e.dtype==="string")try{const s=n.map(r=>Do(r));return Ee(e.shape,e.dtype,s)}catch{throw new Error("Failed to decode encoded string bytes into utf-8")}return Ee(e.shape,e.dtype,n)}makeOutput(e,n,s){return ir().makeTensorFromTensorInfo(this.makeTensorInfo(n,s,e),this)}disposeData(e,n=!1){if(this.data.has(e)){if(this.data.get(e).refCount--,!n&&this.data.get(e).refCount>0)return!1;const{complexTensorInfos:s}=this.data.get(e);s!=null&&(this.disposeData(s.real.dataId,!0),this.disposeData(s.imag.dataId,!0)),this.data.delete(e)}return!0}disposeIntermediateTensorInfo(e){this.disposeData(e.dataId)}async time(e){const n=Tn();return e(),{kernelMs:Tn()-n}}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){de([e],"where");const n=this.readSync(e.dataId);return TH(e.shape,n)}dispose(){}floatPrecision(){return 32}epsilon(){return super.epsilon()}}zm.nextDataId=0;/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the License); @@ -8117,7 +8117,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function AR(t){const e=new Float32Array(t.length);for(let n=0;n{const{x:e}=t.inputs,n=t.backend;de(e,"abs");let s=new Float32Array(j(e.shape));const r=n.data.get(e.dataId).values;return s=AR(r),n.makeOutput(s,e.shape,e.dtype)},AH={kernelName:pp,backendName:"cpu",kernelFunc:RH};/** + */function AR(t){const e=new Float32Array(t.length);for(let n=0;n{const{x:e}=t.inputs,n=t.backend;de(e,"abs");let s=new Float32Array(j(e.shape));const r=n.data.get(e.dataId).values;return s=AR(r),n.makeOutput(s,e.shape,e.dtype)},RH={kernelName:pp,backendName:"cpu",kernelFunc:EH};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -8147,7 +8147,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function Vn(t){const{inputs:e,backend:n}=t,{real:s,imag:r}=e,o=n.data.get(s.dataId).values,i=n.data.get(r.dataId).values,a=n.makeTensorInfo(s.shape,"complex64"),l=n.data.get(a.dataId);return l.complexTensorInfos={real:n.makeTensorInfo(s.shape,"float32",o),imag:n.makeTensorInfo(r.shape,"float32",i)},a}const DH={kernelName:Qx,backendName:"cpu",kernelFunc:Vn};/** + */function Vn(t){const{inputs:e,backend:n}=t,{real:s,imag:r}=e,o=n.data.get(s.dataId).values,i=n.data.get(r.dataId).values,a=n.makeTensorInfo(s.shape,"complex64"),l=n.data.get(a.dataId);return l.complexTensorInfos={real:n.makeTensorInfo(s.shape,"float32",o),imag:n.makeTensorInfo(r.shape,"float32",i)},a}const AH={kernelName:Qx,backendName:"cpu",kernelFunc:Vn};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -8162,7 +8162,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function Ff(t,e,n="float32"){if(n==="complex64"){const r=Ff(t,e,"float32"),o=Ff(t,e,"float32");return Vn({inputs:{real:r,imag:o},backend:t})}const s=un(j(e),n);return t.makeTensorInfo(e,n,s)}/** + */function _f(t,e,n="float32"){if(n==="complex64"){const r=_f(t,e,"float32"),o=_f(t,e,"float32");return Vn({inputs:{real:r,imag:o},backend:t})}const s=un(j(e),n);return t.makeTensorInfo(e,n,s)}/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -8177,7 +8177,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function Nr(t){const{inputs:e,backend:n}=t,{x:s}=e;return n.incRef(s.dataId),{dataId:s.dataId,shape:s.shape,dtype:s.dtype}}const _H={kernelName:Fu,backendName:"cpu",kernelFunc:Nr};/** + */function Nr(t){const{inputs:e,backend:n}=t,{x:s}=e;return n.incRef(s.dataId),{dataId:s.dataId,shape:s.shape,dtype:s.dtype}}const DH={kernelName:_u,backendName:"cpu",kernelFunc:Nr};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -8192,7 +8192,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function Bi(t){const{inputs:e,backend:n}=t,{input:s}=e,r=n.data.get(s.dataId).complexTensorInfos.real,o=n.data.get(r.dataId).values;return n.makeTensorInfo(r.shape,r.dtype,o)}const FH={kernelName:by,backendName:"cpu",kernelFunc:Bi};/** + */function Bi(t){const{inputs:e,backend:n}=t,{input:s}=e,r=n.data.get(s.dataId).complexTensorInfos.real,o=n.data.get(r.dataId).values;return n.makeTensorInfo(r.shape,r.dtype,o)}const _H={kernelName:by,backendName:"cpu",kernelFunc:Bi};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -8207,7 +8207,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function DR(t,e,n,s){if(s==="int32"){const r=Int32Array.from(t);return[e,"int32",r]}if(s==="bool"){const r=Ki([0],n),[o,i]=Tt((a,l)=>a!==l?1:0)(e,[],t,r,"bool");return[i,"bool",o]}throw new Error(`Error in Cast: failed to cast ${n} to ${s}`)}function Mo(t){const{inputs:e,backend:n,attrs:s}=t,{x:r}=e,{dtype:o}=s;if(o==="complex64"){if(r.dtype==="complex64")return Nr({inputs:{x:r},backend:n});const u=Ff(n,r.shape,r.dtype),h=Mo({inputs:{x:r},backend:n,attrs:{dtype:"float32"}}),d=Vn({inputs:{real:h,imag:u},backend:n});return n.disposeIntermediateTensorInfo(u),n.disposeIntermediateTensorInfo(h),d}if(r.dtype==="complex64"){const u=Bi({inputs:{input:r},backend:n}),h=Mo({inputs:{x:u},backend:n,attrs:{dtype:o}});return n.disposeIntermediateTensorInfo(u),h}if(!XI(r.dtype,o)){const u=Nr({inputs:{x:r},backend:n});return{dataId:u.dataId,shape:u.shape,dtype:o}}const i=n.data.get(r.dataId).values,[a,l,c]=DR(i,r.shape,r.dtype,o);return n.makeTensorInfo(a,l,c)}const zH={kernelName:bu,backendName:"cpu",kernelFunc:Mo};/** + */function DR(t,e,n,s){if(s==="int32"){const r=Int32Array.from(t);return[e,"int32",r]}if(s==="bool"){const r=Ki([0],n),[o,i]=Tt((a,l)=>a!==l?1:0)(e,[],t,r,"bool");return[i,"bool",o]}throw new Error(`Error in Cast: failed to cast ${n} to ${s}`)}function Mo(t){const{inputs:e,backend:n,attrs:s}=t,{x:r}=e,{dtype:o}=s;if(o==="complex64"){if(r.dtype==="complex64")return Nr({inputs:{x:r},backend:n});const u=_f(n,r.shape,r.dtype),h=Mo({inputs:{x:r},backend:n,attrs:{dtype:"float32"}}),d=Vn({inputs:{real:h,imag:u},backend:n});return n.disposeIntermediateTensorInfo(u),n.disposeIntermediateTensorInfo(h),d}if(r.dtype==="complex64"){const u=Bi({inputs:{input:r},backend:n}),h=Mo({inputs:{x:u},backend:n,attrs:{dtype:o}});return n.disposeIntermediateTensorInfo(u),h}if(!XI(r.dtype,o)){const u=Nr({inputs:{x:r},backend:n});return{dataId:u.dataId,shape:u.shape,dtype:o}}const i=n.data.get(r.dataId).values,[a,l,c]=DR(i,r.shape,r.dtype,o);return n.makeTensorInfo(a,l,c)}const FH={kernelName:vu,backendName:"cpu",kernelFunc:Mo};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -8237,7 +8237,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const _R=Tt((t,e)=>t+e),OH=hv((t,e,n,s)=>({real:t+n,imag:e+s})),cl=Wt(bl,_R,OH),MH={kernelName:bl,backendName:"cpu",kernelFunc:cl};/** + */const _R=Tt((t,e)=>t+e),zH=hv((t,e,n,s)=>({real:t+n,imag:e+s})),cl=Wt(bl,_R,zH),OH={kernelName:bl,backendName:"cpu",kernelFunc:cl};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -8267,7 +8267,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const zR=Tt((t,e)=>t&e),PH=Wt(Yx,zR),LH={kernelName:Yx,backendName:"cpu",kernelFunc:PH};/** + */const zR=Tt((t,e)=>t&e),MH=Wt(Yx,zR),PH={kernelName:Yx,backendName:"cpu",kernelFunc:MH};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -8312,7 +8312,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const OR=Tr(t=>Math.ceil(t)),BH=Yo(Cu,OR),VH={kernelName:Cu,backendName:"cpu",kernelFunc:BH};/** + */const OR=Tr(t=>Math.ceil(t)),LH=Yo(bu,OR),BH={kernelName:bu,backendName:"cpu",kernelFunc:LH};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -8342,7 +8342,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const PR=Tt((t,e)=>t===e?1:0),LR=Wt(Ep,PR,null,"bool"),WH={kernelName:Ep,backendName:"cpu",kernelFunc:LR};/** + */const PR=Tt((t,e)=>t===e?1:0),LR=Wt(Ep,PR,null,"bool"),VH={kernelName:Ep,backendName:"cpu",kernelFunc:LR};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the License); @@ -8357,7 +8357,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const BR=Tr(t=>Math.exp(t)),VR=Yo(Eu,BR,"float32"),UH={kernelName:Eu,backendName:"cpu",kernelFunc:VR};/** + */const BR=Tr(t=>Math.exp(t)),VR=Yo(Tu,BR,"float32"),WH={kernelName:Tu,backendName:"cpu",kernelFunc:VR};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the License); @@ -8372,7 +8372,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const WR=Tr(t=>Math.expm1(t)),GH=Yo(Ru,WR),HH={kernelName:Ru,backendName:"cpu",kernelFunc:GH};/** + */const WR=Tr(t=>Math.expm1(t)),UH=Yo(Eu,WR),GH={kernelName:Eu,backendName:"cpu",kernelFunc:UH};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the License); @@ -8387,7 +8387,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const UR=Tr(t=>Math.floor(t)),jH=Yo(Au,UR),KH={kernelName:Au,backendName:"cpu",kernelFunc:jH};/** + */const UR=Tr(t=>Math.floor(t)),HH=Yo(Ru,UR),jH={kernelName:Ru,backendName:"cpu",kernelFunc:HH};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -8402,7 +8402,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const GR=Tt((t,e)=>Math.floor(t/e)),XH=Wt(Du,GR,null,"int32"),qH={kernelName:Du,backendName:"cpu",kernelFunc:XH};/** + */const GR=Tt((t,e)=>Math.floor(t/e)),KH=Wt(Au,GR,null,"int32"),XH={kernelName:Au,backendName:"cpu",kernelFunc:KH};/** * @license * Copyright 2021 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -8447,7 +8447,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const KR=Tt((t,e)=>t>e?1:0),YH=Wt(_p,KR,null,"bool"),QH={kernelName:_p,backendName:"cpu",kernelFunc:YH};/** + */const KR=Tt((t,e)=>t>e?1:0),qH=Wt(_p,KR,null,"bool"),YH={kernelName:_p,backendName:"cpu",kernelFunc:qH};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -8462,7 +8462,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const XR=Tt((t,e)=>t>=e?1:0),ZH=Wt(_u,XR,null,"bool"),JH={kernelName:_u,backendName:"cpu",kernelFunc:ZH};/** + */const XR=Tt((t,e)=>t>=e?1:0),QH=Wt(Du,XR,null,"bool"),ZH={kernelName:Du,backendName:"cpu",kernelFunc:QH};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -8477,7 +8477,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const qR=Tt((t,e)=>ttt<=e?1:0),nj=Wt(Op,YR,null,"bool"),sj={kernelName:Op,backendName:"cpu",kernelFunc:nj};/** + */const YR=Tt((t,e)=>t<=e?1:0),tj=Wt(Op,YR,null,"bool"),nj={kernelName:Op,backendName:"cpu",kernelFunc:tj};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -8522,7 +8522,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const ZR=Tr(t=>Math.log(t)),rj=Yo(Pu,ZR),oj={kernelName:Pu,backendName:"cpu",kernelFunc:rj};/** + */const ZR=Tr(t=>Math.log(t)),sj=Yo(Mu,ZR),rj={kernelName:Mu,backendName:"cpu",kernelFunc:sj};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -8552,7 +8552,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const eA=Tt((t,e)=>Math.max(t,e)),ij=Wt(Bu,eA),aj={kernelName:Bu,backendName:"cpu",kernelFunc:ij};/** + */const eA=Tt((t,e)=>Math.max(t,e)),oj=Wt(Lu,eA),ij={kernelName:Lu,backendName:"cpu",kernelFunc:oj};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -8567,7 +8567,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const tA=Tt((t,e)=>Math.min(t,e)),lj=Wt(Vu,tA),cj={kernelName:Vu,backendName:"cpu",kernelFunc:lj};/** + */const tA=Tt((t,e)=>Math.min(t,e)),aj=Wt(Bu,tA),lj={kernelName:Bu,backendName:"cpu",kernelFunc:aj};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -8582,7 +8582,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const fv=Tt((t,e)=>t*e),uj=hv((t,e,n,s)=>({real:t*n-e*s,imag:t*s+e*n})),Om=Wt(Uu,fv,uj),hj={kernelName:Uu,backendName:"cpu",kernelFunc:Om};/** + */const fv=Tt((t,e)=>t*e),cj=hv((t,e,n,s)=>({real:t*n-e*s,imag:t*s+e*n})),Om=Wt(Wu,fv,cj),uj={kernelName:Wu,backendName:"cpu",kernelFunc:Om};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -8597,7 +8597,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function nA(t,e,n){const s=Wo(-1,n);return fv([],e,s,t,n)}function dj(t){const{inputs:e,backend:n}=t,{x:s}=e;de(s,"neg");const r=n.data.get(s.dataId).values,[o,i]=nA(r,s.shape,s.dtype);return n.makeTensorInfo(i,s.dtype,o)}const fj={kernelName:Kp,backendName:"cpu",kernelFunc:dj};/** + */function nA(t,e,n){const s=Wo(-1,n);return fv([],e,s,t,n)}function hj(t){const{inputs:e,backend:n}=t,{x:s}=e;de(s,"neg");const r=n.data.get(s.dataId).values,[o,i]=nA(r,s.shape,s.dtype);return n.makeTensorInfo(i,s.dtype,o)}const dj={kernelName:Kp,backendName:"cpu",kernelFunc:hj};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -8612,7 +8612,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const sA=Tt((t,e)=>t!==e?1:0),pj=Wt(Xp,sA,null,"bool"),mj={kernelName:Xp,backendName:"cpu",kernelFunc:pj};/** + */const sA=Tt((t,e)=>t!==e?1:0),fj=Wt(Xp,sA,null,"bool"),pj={kernelName:Xp,backendName:"cpu",kernelFunc:fj};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -8642,7 +8642,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function Fn(t){const{inputs:e,attrs:n,backend:s}=t,{x:r}=e,{perm:o}=n;de(r,"transpose");const i=r.shape.length,a=new Array(i);for(let h=0;hn.disposeIntermediateTensorInfo(y)),n.makeTensorInfo(m,x,p)}const yj={kernelName:em,backendName:"cpu",kernelFunc:xj};/** + */function rA(t,e,n,s){const[r,o]=Yt(t,s),i=Xn(e,"int32"),a=un(j(r),i),l=j(o);for(let c=0;cn.disposeIntermediateTensorInfo(y)),n.makeTensorInfo(m,x,p)}const xj={kernelName:em,backendName:"cpu",kernelFunc:gj};/** * @license * Copyright 2022 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -8672,7 +8672,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function wj(t,e,n){t.forEach((s,r)=>{if(s<0||s>=n){const o=vl(r,e.length,pe(e)).join(",");throw new Error(`indices[${o}] = ${s} is not in [0, ${n})`)}})}function vj(t,e){for(let n=0;nr)throw new Error("Ragged splits must not point past values");for(let o=1;os[o])throw new Error("Ragged splits must be sorted in ascending order")}}function bj(t,e,n,s){const r=[];let o=0;const i=e.length-1+n.length,a=new Array(i).fill(null).map(()=>[0]);vj(n,s);let l=1;for(let c=0;c=0){const g=a[p],x=g[g.length-1]-f[u];for(let m=u;mr[i]=o)}return e}function gk(t,e){const n=t.slice(0,e);for(;n.length{if(s<0||s>=n){const o=vl(r,e.length,pe(e)).join(",");throw new Error(`indices[${o}] = ${s} is not in [0, ${n})`)}})}function wj(t,e){for(let n=0;nr)throw new Error("Ragged splits must not point past values");for(let o=1;os[o])throw new Error("Ragged splits must be sorted in ascending order")}}function vj(t,e,n,s){const r=[];let o=0;const i=e.length-1+n.length,a=new Array(i).fill(null).map(()=>[0]);wj(n,s);let l=1;for(let c=0;c=0){const g=a[p],x=g[g.length-1]-f[u];for(let m=u;mr[i]=o)}return e}function gk(t,e){const n=t.slice(0,e);for(;n.lengths&&(s=o)}return s}static getMaxWidthValueRowID(e){const n=e.length;if(n===0)return 0;let s=0,r=e[0],o=0;for(let i=1;i"Final length of result must be equal to firstDimension."),o}calculateOutputIndexRowSplit(e,n,s,r){const o=e.length,i=[];for(let a=0;a0&&i.length!==e[o-1])throw new Error("Invalid row split size.");return i}calculateOutputIndexValueRowID(e,n,s,r){const o=e.length,i=[];if(o===0)return[];let a=0,l=e[0];if(l>=n.length)throw new Error(`Got currentValueRowId=${l}, which is not less than ${n.length}`);let c=n[l];i.push(c);for(let u=1;u=0&&(++a,a=n.length)throw new Error(`Got nextValueRowId=${h} which is not less than ${n.length}`);c=n[h]}i.push(c)}if(i.length!==e.length)throw new Error("Invalid row ids.");return i}calculateOutputIndex(e,n,s,r){const o=this.getRowPartitionTensor(e),i=this.getRowPartitionTypeByDimension(e);switch(i){case fs.VALUE_ROWIDS:return this.calculateOutputIndexValueRowID(o,n,s,r);case fs.ROW_SPLITS:if(o.length-1>n.length)throw new Error(`Row partition size is greater than output size: ${o.length-1} > ${n.length}`);return this.calculateOutputIndexRowSplit(o,n,s,r);default:throw new Error(`Unsupported partition type: ${fs[i]}`)}}getFirstDimensionSize(){const e=this.rowPartitionValues[0];if(this.rowPartitionTypes.length===0)throw new Error("No row_partition_types given.");const n=this.rowPartitionTypes[0];switch(n){case fs.FIRST_DIM_SIZE:return e[0];case fs.VALUE_ROWIDS:throw new Error("Cannot handle VALUE_ROWIDS in first dimension.");case fs.ROW_SPLITS:return this.rowPartitionValuesShapes[0][0]-1;default:throw new Error(`Cannot handle type ${fs[n]}`)}}compute(){if(this.rowPartitionValues[0].length<=0)throw new Error("Invalid first partition input. Tensor requires at least one element.");const n=this.getFirstDimensionSize(),s=this.calculateOutputSize(n),r=new Array(this.raggedRank+1);r[r.length-1]=1;for(let l=r.length-2;l>=0;--l)r[l]=r[l+1]*s[l+1];const o=wk(s,!1),i=kt(this.valuesDType,j(o));if(r[0]*s[0]>0){let l=this.calculateFirstParentOutputIndex(n,r[0],s[0]);for(let c=1;c<=this.raggedRank;++c)l=this.calculateOutputIndex(c-1,l,r[c],s[c]);this.setOutput(this.raggedRank,l,i,o)}return[o,i]}setOutput(e,n,s,r){if(s.length===0)return;const o=this.values,i=s;let a=r.slice();a=a.slice(e+1);const l=j(a),c=n.length;let u=this.defaultValue;if(u.length!==l&&u.length!==1){const p=this.defaultValueShape;P(()=>{const g=F(u,p);u=Cc(g,a).dataSync()})}let h=0,d=0,f=0;for(let p=0;p<=c;++p){let g=p=c){const x=s.length;g=Math.floor(x/l)}if(g>f)if(this.defaultValue.length===1)i.subarray(f*l,g*l).fill(this.defaultValue[0]),f=g;else for(;g>f;){const x=i.slice(f*l);yk(x,u,l),++f}g<0?(h=p+1,d=f):(h=p,d=f,f=d+1)}}}function yk(t,e,n){for(let s=0;s= 0`);if(s<-1)throw new Error(`Dimension ${s} must be >= -1`);s=-1}n.push(s)}return n}function aA(t,e,n,s,r,o,i,a,l,c){return new zf(t,e,n,s,r,o,i,a,l,c).compute()}/** + */var fs=Us;class Ff{constructor(e,n,s,r,o,i,a,l,c,u){this.shape=e,this.shapeShape=n,this.values=s,this.valuesShape=r,this.valuesDType=o,this.defaultValue=i,this.defaultValueShape=a,this.rowPartitionValues=l,this.rowPartitionValuesShapes=c,this.rowPartitionTypes=HN(u),this.raggedRank=jN(this.rowPartitionTypes)}getRowPartitionTypeByDimension(e){return this.rowPartitionTypes[0]===fs.FIRST_DIM_SIZE?this.rowPartitionTypes[e+1]:this.rowPartitionTypes[e]}getRowPartitionTensor(e){return this.rowPartitionTypes[0]===fs.FIRST_DIM_SIZE?this.rowPartitionValues[e+1]:this.rowPartitionValues[e]}getMaxWidth(e){const n=this.getRowPartitionTensor(e-1);switch(this.getRowPartitionTypeByDimension(e-1)){case fs.VALUE_ROWIDS:return Ff.getMaxWidthValueRowID(n);case fs.ROW_SPLITS:return Ff.getMaxWidthRowSplit(n);default:throw new Error(`Cannot handle partition type ${fs[this.getRowPartitionTypeByDimension(e-1)]}`)}}static getMaxWidthRowSplit(e){const n=e.length;if(n===0||n===1)return 0;let s=0;for(let r=0;rs&&(s=o)}return s}static getMaxWidthValueRowID(e){const n=e.length;if(n===0)return 0;let s=0,r=e[0],o=0;for(let i=1;i"Final length of result must be equal to firstDimension."),o}calculateOutputIndexRowSplit(e,n,s,r){const o=e.length,i=[];for(let a=0;a0&&i.length!==e[o-1])throw new Error("Invalid row split size.");return i}calculateOutputIndexValueRowID(e,n,s,r){const o=e.length,i=[];if(o===0)return[];let a=0,l=e[0];if(l>=n.length)throw new Error(`Got currentValueRowId=${l}, which is not less than ${n.length}`);let c=n[l];i.push(c);for(let u=1;u=0&&(++a,a=n.length)throw new Error(`Got nextValueRowId=${h} which is not less than ${n.length}`);c=n[h]}i.push(c)}if(i.length!==e.length)throw new Error("Invalid row ids.");return i}calculateOutputIndex(e,n,s,r){const o=this.getRowPartitionTensor(e),i=this.getRowPartitionTypeByDimension(e);switch(i){case fs.VALUE_ROWIDS:return this.calculateOutputIndexValueRowID(o,n,s,r);case fs.ROW_SPLITS:if(o.length-1>n.length)throw new Error(`Row partition size is greater than output size: ${o.length-1} > ${n.length}`);return this.calculateOutputIndexRowSplit(o,n,s,r);default:throw new Error(`Unsupported partition type: ${fs[i]}`)}}getFirstDimensionSize(){const e=this.rowPartitionValues[0];if(this.rowPartitionTypes.length===0)throw new Error("No row_partition_types given.");const n=this.rowPartitionTypes[0];switch(n){case fs.FIRST_DIM_SIZE:return e[0];case fs.VALUE_ROWIDS:throw new Error("Cannot handle VALUE_ROWIDS in first dimension.");case fs.ROW_SPLITS:return this.rowPartitionValuesShapes[0][0]-1;default:throw new Error(`Cannot handle type ${fs[n]}`)}}compute(){if(this.rowPartitionValues[0].length<=0)throw new Error("Invalid first partition input. Tensor requires at least one element.");const n=this.getFirstDimensionSize(),s=this.calculateOutputSize(n),r=new Array(this.raggedRank+1);r[r.length-1]=1;for(let l=r.length-2;l>=0;--l)r[l]=r[l+1]*s[l+1];const o=wk(s,!1),i=kt(this.valuesDType,j(o));if(r[0]*s[0]>0){let l=this.calculateFirstParentOutputIndex(n,r[0],s[0]);for(let c=1;c<=this.raggedRank;++c)l=this.calculateOutputIndex(c-1,l,r[c],s[c]);this.setOutput(this.raggedRank,l,i,o)}return[o,i]}setOutput(e,n,s,r){if(s.length===0)return;const o=this.values,i=s;let a=r.slice();a=a.slice(e+1);const l=j(a),c=n.length;let u=this.defaultValue;if(u.length!==l&&u.length!==1){const p=this.defaultValueShape;P(()=>{const g=F(u,p);u=Cc(g,a).dataSync()})}let h=0,d=0,f=0;for(let p=0;p<=c;++p){let g=p=c){const x=s.length;g=Math.floor(x/l)}if(g>f)if(this.defaultValue.length===1)i.subarray(f*l,g*l).fill(this.defaultValue[0]),f=g;else for(;g>f;){const x=i.slice(f*l);yk(x,u,l),++f}g<0?(h=p+1,d=f):(h=p,d=f,f=d+1)}}}function yk(t,e,n){for(let s=0;s= 0`);if(s<-1)throw new Error(`Dimension ${s} must be >= -1`);s=-1}n.push(s)}return n}function aA(t,e,n,s,r,o,i,a,l,c){return new Ff(t,e,n,s,r,o,i,a,l,c).compute()}/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -8732,7 +8732,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const cA=Tr(t=>1/Math.sqrt(t)),Ij=Yo(qu,cA),$j={kernelName:qu,backendName:"cpu",kernelFunc:Ij};/** + */const cA=Tr(t=>1/Math.sqrt(t)),Sj=Yo(Xu,cA),Ij={kernelName:Xu,backendName:"cpu",kernelFunc:Sj};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -8762,7 +8762,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const Nj=Tr(t=>1/(1+Math.exp(-t))),uA=Xe(eh,t=>1/(1+Math.exp(-t))),Tj={kernelName:eh,backendName:"cpu",kernelFunc:uA};/** + */const $j=Tr(t=>1/(1+Math.exp(-t))),uA=Xe(Ju,t=>1/(1+Math.exp(-t))),Nj={kernelName:Ju,backendName:"cpu",kernelFunc:uA};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -8777,7 +8777,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function hA(t,e,n,s,r){const o=bw(s,e,n),i=j(n),a=pe(s);if(o){const h=Cw(e,a);return r==="string"?t.slice(h,h+i):t.subarray(h,h+i)}const l=r==="string"?Kr(t):t,c=Ee(s,r,l),u=Ee(n,r);for(let h=0;hp+e[g]);u.set(c.get(...f),...d)}return r==="string"?fT(u.values):u.values}function Vi(t){const{inputs:e,backend:n,attrs:s}=t,{x:r}=e,{begin:o,size:i}=s;de(r,"slice");const[a,l]=bm(r,o,i);ww(r,a,l);const c=n.data.get(r.dataId).values,u=hA(c,a,l,r.shape,r.dtype);return n.makeTensorInfo(l,r.dtype,u)}const Ej={kernelName:im,backendName:"cpu",kernelFunc:Vi};/** + */function hA(t,e,n,s,r){const o=bw(s,e,n),i=j(n),a=pe(s);if(o){const h=Cw(e,a);return r==="string"?t.slice(h,h+i):t.subarray(h,h+i)}const l=r==="string"?Kr(t):t,c=Ee(s,r,l),u=Ee(n,r);for(let h=0;hp+e[g]);u.set(c.get(...f),...d)}return r==="string"?fT(u.values):u.values}function Vi(t){const{inputs:e,backend:n,attrs:s}=t,{x:r}=e,{begin:o,size:i}=s;de(r,"slice");const[a,l]=bm(r,o,i);ww(r,a,l);const c=n.data.get(r.dataId).values,u=hA(c,a,l,r.shape,r.dtype);return n.makeTensorInfo(l,r.dtype,u)}const Tj={kernelName:im,backendName:"cpu",kernelFunc:Vi};/** * @license * Copyright 2021 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -8837,7 +8837,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const Rj=Tr(t=>Math.sqrt(t)),Aj=Xe(nh,t=>Math.sqrt(t)),Dj={kernelName:nh,backendName:"cpu",kernelFunc:Aj};/** + */const Ej=Tr(t=>Math.sqrt(t)),Rj=Xe(th,t=>Math.sqrt(t)),Aj={kernelName:th,backendName:"cpu",kernelFunc:Rj};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -8852,7 +8852,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const pA=Tt((t,e)=>{const n=t-e;return n*n}),_j=Wt(sh,pA),Fj={kernelName:sh,backendName:"cpu",kernelFunc:_j};/** + */const pA=Tt((t,e)=>{const n=t-e;return n*n}),Dj=Wt(nh,pA),_j={kernelName:nh,backendName:"cpu",kernelFunc:Dj};/** * @license * Copyright 2023 Google LLC. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -8867,7 +8867,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const mA=Tr((t,e)=>{const{pattern:n,replaceGlobal:s,rewrite:r}=e;return t.replace(new RegExp(n,s?"g":""),r)}),zj=Yo(Iy,mA),Oj={kernelName:Iy,backendName:"cpu",kernelFunc:zj};/** + */const mA=Tr((t,e)=>{const{pattern:n,replaceGlobal:s,rewrite:r}=e;return t.replace(new RegExp(n,s?"g":""),r)}),Fj=Yo(Iy,mA),zj={kernelName:Iy,backendName:"cpu",kernelFunc:Fj};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -8897,7 +8897,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */class Mj{constructor(e,n,s,r,o,i){this.separator=No(e),this.nGramWidths=n,this.leftPad=No(s),this.rightPad=No(r),this.padWidth=o,this.preserveShort=i}getPadWidth(e){return Math.min(this.padWidth<0?e-1:this.padWidth,e-1)}getNumNGrams(e,n){const s=this.getPadWidth(n);return Math.max(0,e+2*s-n+1)}createNGrams(e,n,s,r,o,i){for(let a=0;a0?0:a-l);let f=0;f+=c*this.leftPad.length;for(let y=0;yy.forEach(w=>g[x++]=w);for(let y=0;y0){m(e[d+h-1]);for(let y=0;y0){let l=n[0];if(l!==0)throw new Error(`First split value must be 0, got ${l}`);for(let c=1;c=l;if(u=u&&n[c]<=s,!u)throw new Error(`Invalid split value ${n[c]}, must be in [${l}, ${s}]`);l=n[c]}if(l!==s)throw new Error(`Last split value must be data size. Expected ${s}, got ${l}`)}const o=r-1,i=kt("int32",r);if(s===0||r===0){const l=new Array(s);for(let c=0;c<=o;++c)i[c]=0;return[l,i]}i[0]=0;for(let l=1;l<=o;++l){const c=n[l]-n[l-1];let u=0;this.nGramWidths.forEach(h=>{u+=this.getNumNGrams(c,h)}),this.preserveShort&&c>0&&u===0&&(u=1),i[l]=i[l-1]+u}const a=new Array(i[o]);for(let l=0;l{const d=n[l+1]-n[l],f=this.getNumNGrams(d,h);this.createNGrams(e,c,a,u,f,h),u+=f}),this.preserveShort&&u===i[l]){const h=n[l+1]-n[l];if(h===0)continue;const d=h+2*this.padWidth;this.createNGrams(e,c,a,u,1,d)}}return[a,i]}}function xA(t,e,n,s,r,o,i,a){return new Mj(n,s,r,o,i,a).compute(t,e)}/** + */class Oj{constructor(e,n,s,r,o,i){this.separator=No(e),this.nGramWidths=n,this.leftPad=No(s),this.rightPad=No(r),this.padWidth=o,this.preserveShort=i}getPadWidth(e){return Math.min(this.padWidth<0?e-1:this.padWidth,e-1)}getNumNGrams(e,n){const s=this.getPadWidth(n);return Math.max(0,e+2*s-n+1)}createNGrams(e,n,s,r,o,i){for(let a=0;a0?0:a-l);let f=0;f+=c*this.leftPad.length;for(let y=0;yy.forEach(w=>g[x++]=w);for(let y=0;y0){m(e[d+h-1]);for(let y=0;y0){let l=n[0];if(l!==0)throw new Error(`First split value must be 0, got ${l}`);for(let c=1;c=l;if(u=u&&n[c]<=s,!u)throw new Error(`Invalid split value ${n[c]}, must be in [${l}, ${s}]`);l=n[c]}if(l!==s)throw new Error(`Last split value must be data size. Expected ${s}, got ${l}`)}const o=r-1,i=kt("int32",r);if(s===0||r===0){const l=new Array(s);for(let c=0;c<=o;++c)i[c]=0;return[l,i]}i[0]=0;for(let l=1;l<=o;++l){const c=n[l]-n[l-1];let u=0;this.nGramWidths.forEach(h=>{u+=this.getNumNGrams(c,h)}),this.preserveShort&&c>0&&u===0&&(u=1),i[l]=i[l-1]+u}const a=new Array(i[o]);for(let l=0;l{const d=n[l+1]-n[l],f=this.getNumNGrams(d,h);this.createNGrams(e,c,a,u,f,h),u+=f}),this.preserveShort&&u===i[l]){const h=n[l+1]-n[l];if(h===0)continue;const d=h+2*this.padWidth;this.createNGrams(e,c,a,u,1,d)}}return[a,i]}}function xA(t,e,n,s,r,o,i,a){return new Oj(n,s,r,o,i,a).compute(t,e)}/** * @license * Copyright 2021 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -8912,7 +8912,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function Pj(t,e,n,s){if(!t.length)return;if(e.length===0){for(let o=0;ot-e),Lj=hv((t,e,n,s)=>({real:t-n,imag:e-s})),gv=Wt(rh,vA,Lj),Bj={kernelName:rh,backendName:"cpu",kernelFunc:gv};/** + */const vA=Tt((t,e)=>t-e),Pj=hv((t,e,n,s)=>({real:t-n,imag:e-s})),gv=Wt(sh,vA,Pj),Lj={kernelName:sh,backendName:"cpu",kernelFunc:gv};/** * @license * Copyright 2019 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9002,7 +9002,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const Vj=Object.freeze(Object.defineProperty({__proto__:null,addImpl:_R,bincountImpl:dv,bincountReduceImpl:FR,bitwiseAndImpl:zR,castImpl:DR,ceilImpl:OR,concatImpl:MR,equalImpl:PR,expImpl:BR,expm1Impl:WR,floorDivImpl:GR,floorImpl:UR,gatherNdImpl:HR,gatherV2Impl:jR,greaterEqualImpl:XR,greaterImpl:KR,lessEqualImpl:YR,lessImpl:qR,linSpaceImpl:QR,logImpl:ZR,maxImpl:JR,maximumImpl:eA,minimumImpl:tA,multiplyImpl:fv,negImpl:nA,notEqualImpl:sA,prodImpl:rA,raggedGatherImpl:oA,raggedRangeImpl:iA,raggedTensorToTensorImpl:aA,rangeImpl:lA,rsqrtImpl:cA,scatterImpl:pi,sigmoidImpl:Nj,simpleAbsImpl:AR,sliceImpl:hA,sparseFillEmptyRowsImpl:dA,sparseReshapeImpl:fA,sparseSegmentReductionImpl:mv,sqrtImpl:Rj,squaredDifferenceImpl:pA,staticRegexReplaceImpl:mA,stridedSliceImpl:gA,stringNGramsImpl:xA,stringSplitImpl:yA,stringToHashBucketFastImpl:wA,subImpl:vA,tileImpl:bA,topKImpl:kA,transposeImpl:pv,uniqueImpl:SA},Symbol.toStringTag,{value:"Module"}));/** + */const Bj=Object.freeze(Object.defineProperty({__proto__:null,addImpl:_R,bincountImpl:dv,bincountReduceImpl:FR,bitwiseAndImpl:zR,castImpl:DR,ceilImpl:OR,concatImpl:MR,equalImpl:PR,expImpl:BR,expm1Impl:WR,floorDivImpl:GR,floorImpl:UR,gatherNdImpl:HR,gatherV2Impl:jR,greaterEqualImpl:XR,greaterImpl:KR,lessEqualImpl:YR,lessImpl:qR,linSpaceImpl:QR,logImpl:ZR,maxImpl:JR,maximumImpl:eA,minimumImpl:tA,multiplyImpl:fv,negImpl:nA,notEqualImpl:sA,prodImpl:rA,raggedGatherImpl:oA,raggedRangeImpl:iA,raggedTensorToTensorImpl:aA,rangeImpl:lA,rsqrtImpl:cA,scatterImpl:pi,sigmoidImpl:$j,simpleAbsImpl:AR,sliceImpl:hA,sparseFillEmptyRowsImpl:dA,sparseReshapeImpl:fA,sparseSegmentReductionImpl:mv,sqrtImpl:Ej,squaredDifferenceImpl:pA,staticRegexReplaceImpl:mA,stridedSliceImpl:gA,stringNGramsImpl:xA,stringSplitImpl:yA,stringToHashBucketFastImpl:wA,subImpl:vA,tileImpl:bA,topKImpl:kA,transposeImpl:pv,uniqueImpl:SA},Symbol.toStringTag,{value:"Module"}));/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9032,7 +9032,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const IA=Xe(Nu,t=>t>=0?t:Math.exp(t)-1),Wj={kernelName:Nu,backendName:"cpu",kernelFunc:IA};/** + */const IA=Xe($u,t=>t>=0?t:Math.exp(t)-1),Vj={kernelName:$u,backendName:"cpu",kernelFunc:IA};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9047,7 +9047,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function $A(t){const{inputs:e,backend:n,attrs:s}=t,{x:r}=e,{alpha:o}=s;de([r],"leakyRelu");const i=j(r.shape),a=n.data.get(r.dataId).values,l=cn("float32",i);for(let c=0;ct<0?e*t:t);function NA(t){const{inputs:e,backend:n}=t,{x:s,alpha:r}=e;de([s,r],"prelu");const o=n.data.get(s.dataId).values,i=n.data.get(r.dataId).values,[a,l]=Gj(s.shape,r.shape,o,i,"float32");return n.makeTensorInfo(l,"float32",a)}const Hj={kernelName:Jp,backendName:"cpu",kernelFunc:NA};/** + */const Uj=Tt((t,e)=>t<0?e*t:t);function NA(t){const{inputs:e,backend:n}=t,{x:s,alpha:r}=e;de([s,r],"prelu");const o=n.data.get(s.dataId).values,i=n.data.get(r.dataId).values,[a,l]=Uj(s.shape,r.shape,o,i,"float32");return n.makeTensorInfo(l,"float32",a)}const Gj={kernelName:Jp,backendName:"cpu",kernelFunc:NA};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the License); @@ -9077,7 +9077,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const TA=Xe(ju,t=>Math.max(0,t)),jj={kernelName:ju,backendName:"cpu",kernelFunc:TA};/** + */const TA=Xe(Hu,t=>Math.max(0,t)),Hj={kernelName:Hu,backendName:"cpu",kernelFunc:TA};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the License); @@ -9092,7 +9092,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const EA=Xe(Ku,t=>Math.min(Math.max(0,t),6)),Kj={kernelName:Ku,backendName:"cpu",kernelFunc:EA};/** + */const EA=Xe(ju,t=>Math.min(Math.max(0,t),6)),jj={kernelName:ju,backendName:"cpu",kernelFunc:EA};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9107,7 +9107,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function Of(t,e,n,s,r){if(n==="linear")return Nr({inputs:{x:e},backend:t});if(n==="relu")return TA({inputs:{x:e},backend:t});if(n==="elu")return IA({inputs:{x:e},backend:t});if(n==="relu6")return EA({inputs:{x:e},backend:t});if(n==="prelu")return NA({inputs:{x:e,alpha:s},backend:t});if(n==="leakyrelu")return $A({inputs:{x:e},backend:t,attrs:{alpha:r}});if(n==="sigmoid")return uA({inputs:{x:e},backend:t});throw new Error(`Activation ${n} has not been implemented for the CPU backend.`)}/** + */function zf(t,e,n,s,r){if(n==="linear")return Nr({inputs:{x:e},backend:t});if(n==="relu")return TA({inputs:{x:e},backend:t});if(n==="elu")return IA({inputs:{x:e},backend:t});if(n==="relu6")return EA({inputs:{x:e},backend:t});if(n==="prelu")return NA({inputs:{x:e,alpha:s},backend:t});if(n==="leakyrelu")return $A({inputs:{x:e},backend:t,attrs:{alpha:r}});if(n==="sigmoid")return uA({inputs:{x:e},backend:t});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"); @@ -9122,7 +9122,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function st(t){const{inputs:e,backend:n,attrs:s}=t,{x:r}=e,{shape:o}=s,i=j(r.shape),a=KI(o,i),l=j(a);I(i===l,()=>`The new shape (${a}) has ${l} elements and the old shape (${r.shape}) has ${i} elements. The new shape and old shape must have the same number of elements.`),n.incRef(r.dataId);const c=n.data.get(r.dataId);if(c.complexTensorInfos!=null){const u=c.complexTensorInfos.real,h=c.complexTensorInfos.imag;u.shape=a,h.shape=a}return{dataId:r.dataId,shape:a,dtype:r.dtype}}const Xj={kernelName:tm,backendName:"cpu",kernelFunc:st};/** + */function st(t){const{inputs:e,backend:n,attrs:s}=t,{x:r}=e,{shape:o}=s,i=j(r.shape),a=KI(o,i),l=j(a);I(i===l,()=>`The new shape (${a}) has ${l} elements and the old shape (${r.shape}) has ${i} elements. The new shape and old shape must have the same number of elements.`),n.incRef(r.dataId);const c=n.data.get(r.dataId);if(c.complexTensorInfos!=null){const u=c.complexTensorInfos.real,h=c.complexTensorInfos.imag;u.shape=a,h.shape=a}return{dataId:r.dataId,shape:a,dtype:r.dtype}}const Kj={kernelName:tm,backendName:"cpu",kernelFunc:st};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the License); @@ -9137,7 +9137,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function RA(t){const{inputs:e,backend:n,attrs:s}=t,{a:r,b:o}=e,{transposeA:i,transposeB:a}=s;de([r,o],"matMul");const l=r.shape.length,c=o.shape.length,u=i?r.shape[l-2]:r.shape[l-1],h=a?o.shape[c-1]:o.shape[c-2],d=i?r.shape[l-1]:r.shape[l-2],f=a?o.shape[c-2]:o.shape[c-1],p=r.shape.slice(0,-2),g=o.shape.slice(0,-2),x=j(p),m=j(g),w=Se(r.shape.slice(0,-2),o.shape.slice(0,-2)).concat([d,f]);I(u===h,()=>`Error in matMul: inner shapes (${u}) and (${h}) of Tensors with shapes ${r.shape} and ${o.shape} and transposeA=${i} and transposeB=${a} must match.`);const v=i?[x,u,d]:[x,d,u],b=a?[m,f,h]:[m,h,f],C=st({inputs:{x:r},backend:n,attrs:{shape:v}}),k=st({inputs:{x:o},backend:n,attrs:{shape:b}}),S=i?C.shape[1]:C.shape[2],$=i?C.shape[2]:C.shape[1],N=a?k.shape[1]:k.shape[2],A=Math.max(x,m),M=n.data.get(C.dataId).values,L=n.data.get(k.dataId).values,V=pe(C.shape),B=pe(k.shape),[U,K,R]=i?[V[0],1,V[1]]:[V[0],V[1],1],[O,G,X]=a?[1,B[1],B[0]]:[B[1],1,B[0]],q=$*N,Q=Ee([A,$,N],C.dtype),te=Q.values,Z=n.blockSize;for(let se=0;se`Error in matMul: inner shapes (${u}) and (${h}) of Tensors with shapes ${r.shape} and ${o.shape} and transposeA=${i} and transposeB=${a} must match.`);const v=i?[x,u,d]:[x,d,u],b=a?[m,f,h]:[m,h,f],C=st({inputs:{x:r},backend:n,attrs:{shape:v}}),k=st({inputs:{x:o},backend:n,attrs:{shape:b}}),S=i?C.shape[1]:C.shape[2],$=i?C.shape[2]:C.shape[1],N=a?k.shape[1]:k.shape[2],A=Math.max(x,m),M=n.data.get(C.dataId).values,L=n.data.get(k.dataId).values,V=pe(C.shape),B=pe(k.shape),[U,K,R]=i?[V[0],1,V[1]]:[V[0],V[1],1],[O,G,X]=a?[1,B[1],B[0]]:[B[1],1,B[0]],q=$*N,Q=Ee([A,$,N],C.dtype),te=Q.values,Z=n.blockSize;for(let se=0;seMath.acos(t)),Jj={kernelName:pu,backendName:"cpu",kernelFunc:Zj};/** + */const Qj=Xe(fu,t=>Math.acos(t)),Zj={kernelName:fu,backendName:"cpu",kernelFunc:Qj};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the License); @@ -9182,7 +9182,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const e8=Xe(mu,t=>Math.acosh(t)),t8={kernelName:mu,backendName:"cpu",kernelFunc:e8};/** + */const Jj=Xe(pu,t=>Math.acosh(t)),e8={kernelName:pu,backendName:"cpu",kernelFunc:Jj};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9197,7 +9197,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function n8(t){const{inputs:e,backend:n}=t,s=e;de(e,"addN");const r=s.map(a=>n.data.get(a.dataId).values),o=Ee(s[0].shape,s[0].dtype),i=o.values;for(let a=0;an.data.get(a.dataId).values),o=Ee(s[0].shape,s[0].dtype),i=o.values;for(let a=0;ay&&(y=b,w=v)}f[x]=w}return c.forEach(x=>n.disposeIntermediateTensorInfo(x)),n.makeTensorInfo(u,"int32",f)}const c8={kernelName:mp,backendName:"cpu",kernelFunc:l8};/** + */function a8(t){const{inputs:e,backend:n,attrs:s}=t,{x:r}=e,{axis:o}=s;de(r,"argMax");let i=Re(o,r.shape);const a=yt(i,r.shape.length);let l=r;const c=[];a!=null&&(l=Fn({inputs:{x:r},backend:n,attrs:{perm:a}}),c.push(l),i=$t(i.length,l.shape.length)),i=[i[0]],sn("argMax",i,l.shape.length);const[u,h]=Yt(l.shape,i),d=j(u),f=un(d,"int32"),p=j(h),g=n.data.get(l.dataId).values;for(let x=0;xy&&(y=b,w=v)}f[x]=w}return c.forEach(x=>n.disposeIntermediateTensorInfo(x)),n.makeTensorInfo(u,"int32",f)}const l8={kernelName:mp,backendName:"cpu",kernelFunc:a8};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9257,7 +9257,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function u8(t){const{inputs:e,backend:n,attrs:s}=t,{x:r}=e,{axis:o}=s;de(r,"argMin");let i=Re(o,r.shape);const a=yt(i,r.shape.length);let l=r;const c=[];a!=null&&(l=Fn({inputs:{x:r},backend:n,attrs:{perm:a}}),c.push(l),i=$t(i.length,l.shape.length)),i=[i[0]],sn("argMin",i,l.shape.length);const[u,h]=Yt(l.shape,i),d=j(u),f=un(d,"int32"),p=j(h),g=n.data.get(l.dataId).values;for(let x=0;xn.disposeIntermediateTensorInfo(x)),n.makeTensorInfo(u,"int32",f)}const h8={kernelName:gp,backendName:"cpu",kernelFunc:u8};/** + */function c8(t){const{inputs:e,backend:n,attrs:s}=t,{x:r}=e,{axis:o}=s;de(r,"argMin");let i=Re(o,r.shape);const a=yt(i,r.shape.length);let l=r;const c=[];a!=null&&(l=Fn({inputs:{x:r},backend:n,attrs:{perm:a}}),c.push(l),i=$t(i.length,l.shape.length)),i=[i[0]],sn("argMin",i,l.shape.length);const[u,h]=Yt(l.shape,i),d=j(u),f=un(d,"int32"),p=j(h),g=n.data.get(l.dataId).values;for(let x=0;xn.disposeIntermediateTensorInfo(x)),n.makeTensorInfo(u,"int32",f)}const u8={kernelName:gp,backendName:"cpu",kernelFunc:c8};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the License); @@ -9272,7 +9272,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const d8=Xe(gu,t=>Math.asin(t)),f8={kernelName:gu,backendName:"cpu",kernelFunc:d8};/** + */const h8=Xe(mu,t=>Math.asin(t)),d8={kernelName:mu,backendName:"cpu",kernelFunc:h8};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the License); @@ -9287,7 +9287,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const p8=Xe(xu,t=>Math.asinh(t)),m8={kernelName:xu,backendName:"cpu",kernelFunc:p8};/** + */const f8=Xe(gu,t=>Math.asinh(t)),p8={kernelName:gu,backendName:"cpu",kernelFunc:f8};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the License); @@ -9302,7 +9302,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const g8=Xe(yu,t=>Math.atan(t)),x8={kernelName:yu,backendName:"cpu",kernelFunc:g8};/** + */const m8=Xe(xu,t=>Math.atan(t)),g8={kernelName:xu,backendName:"cpu",kernelFunc:m8};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the License); @@ -9317,7 +9317,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const y8=Tt((t,e)=>Math.atan2(t,e)),w8=Wt(vu,y8),v8={kernelName:vu,backendName:"cpu",kernelFunc:w8};/** + */const x8=Tt((t,e)=>Math.atan2(t,e)),y8=Wt(wu,x8),w8={kernelName:wu,backendName:"cpu",kernelFunc:y8};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the License); @@ -9332,7 +9332,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const b8=Xe(wu,t=>Math.atanh(t)),C8={kernelName:wu,backendName:"cpu",kernelFunc:b8};/** + */const v8=Xe(yu,t=>Math.atanh(t)),b8={kernelName:yu,backendName:"cpu",kernelFunc:v8};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9347,7 +9347,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function xv(t,e,n,s,r,o){const i=r.strideHeight,a=r.strideWidth,l=r.dilationHeight,c=r.dilationWidth,u=r.effectiveFilterHeight,h=r.effectiveFilterWidth,d=r.padInfo.top,f=r.padInfo.left,p=o==="max"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,g=Ee(r.outShape,n),x=g.values,m=r.outShape[1]*r.outShape[2]*r.outShape[3],y=r.outShape[2]*r.outShape[3],w=r.outShape[3];for(let v=0;vK?K=Z:o==="avg"&&(R+=Z,O++)}if(isNaN(K))break}const G=M+L*w+k;x[G]=o==="avg"?R/O:K}}}return g}function AA(t,e,n,s,r=!1,o=!1){const i=Ee(s.outShape,"int32"),a=s.strideHeight,l=s.strideWidth,c=s.dilationHeight,u=s.dilationWidth,h=s.effectiveFilterHeight,d=s.effectiveFilterWidth,f=s.padInfo.top,p=s.padInfo.left,g=Ee(e,n,t);for(let x=0;xN&&(N=U,r?A=o?((x*s.inHeight+M)*s.inWidth+V)*s.inChannels+m:(M*s.inWidth+V)*s.inChannels+m:A=L*d+B)}}i.set(A,x,y,C,m)}}return i}function DA(t,e,n,s,r,o){const i=r.strideDepth,a=r.strideHeight,l=r.strideWidth,c=r.dilationDepth,u=r.dilationHeight,h=r.dilationWidth,d=r.effectiveFilterDepth,f=r.effectiveFilterHeight,p=r.effectiveFilterWidth,g=r.padInfo.front,x=r.padInfo.top,m=r.padInfo.left,y=o==="max"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,w=Ee(r.outShape,n),v=w.values,b=r.outShape[1]*r.outShape[2]*r.outShape[3]*r.outShape[4],C=r.outShape[2]*r.outShape[3]*r.outShape[4],k=r.outShape[3]*r.outShape[4],S=r.outShape[4];for(let $=0;$ce?ce=Ge:o==="avg"&&(ue+=Ge,xe++),isNaN(ce))break}if(isNaN(ce))break}if(isNaN(ce))break}const be=ie+M;v[be]=o==="avg"?ue/Math.max(xe,1):ce}}}}return w}function k8(t,e){const n=Ee(e.outShape,"int32"),s=e.strideDepth,r=e.strideHeight,o=e.strideWidth,i=e.dilationDepth,a=e.dilationHeight,l=e.dilationWidth,c=e.effectiveFilterDepth,u=e.effectiveFilterHeight,h=e.effectiveFilterWidth,d=e.padInfo.front,f=e.padInfo.top,p=e.padInfo.left;for(let g=0;g=L&&(L=X,V=U*u*h+R*u+G)}}}n.set(V,g,m,b,$,x)}}}return n}/** + */function xv(t,e,n,s,r,o){const i=r.strideHeight,a=r.strideWidth,l=r.dilationHeight,c=r.dilationWidth,u=r.effectiveFilterHeight,h=r.effectiveFilterWidth,d=r.padInfo.top,f=r.padInfo.left,p=o==="max"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,g=Ee(r.outShape,n),x=g.values,m=r.outShape[1]*r.outShape[2]*r.outShape[3],y=r.outShape[2]*r.outShape[3],w=r.outShape[3];for(let v=0;vK?K=Z:o==="avg"&&(R+=Z,O++)}if(isNaN(K))break}const G=M+L*w+k;x[G]=o==="avg"?R/O:K}}}return g}function AA(t,e,n,s,r=!1,o=!1){const i=Ee(s.outShape,"int32"),a=s.strideHeight,l=s.strideWidth,c=s.dilationHeight,u=s.dilationWidth,h=s.effectiveFilterHeight,d=s.effectiveFilterWidth,f=s.padInfo.top,p=s.padInfo.left,g=Ee(e,n,t);for(let x=0;xN&&(N=U,r?A=o?((x*s.inHeight+M)*s.inWidth+V)*s.inChannels+m:(M*s.inWidth+V)*s.inChannels+m:A=L*d+B)}}i.set(A,x,y,C,m)}}return i}function DA(t,e,n,s,r,o){const i=r.strideDepth,a=r.strideHeight,l=r.strideWidth,c=r.dilationDepth,u=r.dilationHeight,h=r.dilationWidth,d=r.effectiveFilterDepth,f=r.effectiveFilterHeight,p=r.effectiveFilterWidth,g=r.padInfo.front,x=r.padInfo.top,m=r.padInfo.left,y=o==="max"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,w=Ee(r.outShape,n),v=w.values,b=r.outShape[1]*r.outShape[2]*r.outShape[3]*r.outShape[4],C=r.outShape[2]*r.outShape[3]*r.outShape[4],k=r.outShape[3]*r.outShape[4],S=r.outShape[4];for(let $=0;$ce?ce=Ge:o==="avg"&&(ue+=Ge,xe++),isNaN(ce))break}if(isNaN(ce))break}if(isNaN(ce))break}const be=ie+M;v[be]=o==="avg"?ue/Math.max(xe,1):ce}}}}return w}function C8(t,e){const n=Ee(e.outShape,"int32"),s=e.strideDepth,r=e.strideHeight,o=e.strideWidth,i=e.dilationDepth,a=e.dilationHeight,l=e.dilationWidth,c=e.effectiveFilterDepth,u=e.effectiveFilterHeight,h=e.effectiveFilterWidth,d=e.padInfo.front,f=e.padInfo.top,p=e.padInfo.left;for(let g=0;g=L&&(L=X,V=U*u*h+R*u+G)}}}n.set(V,g,m,b,$,x)}}}return n}/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9362,7 +9362,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function S8(t){const{inputs:e,backend:n,attrs:s}=t,{x:r}=e;de(r,"avgPool");const{filterSize:o,strides:i,pad:a,dimRoundingMode:l}=s,c=1;I(dn(i,c),()=>`Error in avgPool: Either strides or dilations must be 1. Got strides ${i} and dilations '${c}'`);const u=As(r.shape,o,i,c,a,l);let h;if(u.filterWidth===1&&u.filterHeight===1&&Ue(u.inShape,u.outShape))h=Nr({inputs:{x:r},backend:n});else{const d=n.data.get(r.dataId).values,f=pe(r.shape),p=xv(d,r.shape,r.dtype,f,u,"avg");h=n.makeTensorInfo(u.outShape,r.dtype,p.values)}return h}const I8={kernelName:xp,backendName:"cpu",kernelFunc:S8};/** + */function k8(t){const{inputs:e,backend:n,attrs:s}=t,{x:r}=e;de(r,"avgPool");const{filterSize:o,strides:i,pad:a,dimRoundingMode:l}=s,c=1;I(dn(i,c),()=>`Error in avgPool: Either strides or dilations must be 1. Got strides ${i} and dilations '${c}'`);const u=As(r.shape,o,i,c,a,l);let h;if(u.filterWidth===1&&u.filterHeight===1&&Ue(u.inShape,u.outShape))h=Nr({inputs:{x:r},backend:n});else{const d=n.data.get(r.dataId).values,f=pe(r.shape),p=xv(d,r.shape,r.dtype,f,u,"avg");h=n.makeTensorInfo(u.outShape,r.dtype,p.values)}return h}const S8={kernelName:xp,backendName:"cpu",kernelFunc:k8};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9377,7 +9377,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function $8(t){const{inputs:e,backend:n,attrs:s}=t,{x:r}=e,{filterSize:o,strides:i,pad:a,dimRoundingMode:l,dataFormat:c}=s;de(r,"avgPool3d");const u=Yr(r.shape,o,i,1,a,l,c),h=n.data.get(r.dataId).values,d=DA(h,r.shape,r.dtype,pe(r.shape),u,"avg");return n.makeTensorInfo(d.shape,"float32",d.values)}const N8={kernelName:yp,backendName:"cpu",kernelFunc:$8};/** + */function I8(t){const{inputs:e,backend:n,attrs:s}=t,{x:r}=e,{filterSize:o,strides:i,pad:a,dimRoundingMode:l,dataFormat:c}=s;de(r,"avgPool3d");const u=Yr(r.shape,o,i,1,a,l,c),h=n.data.get(r.dataId).values,d=DA(h,r.shape,r.dtype,pe(r.shape),u,"avg");return n.makeTensorInfo(d.shape,"float32",d.values)}const $8={kernelName:yp,backendName:"cpu",kernelFunc:I8};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9392,7 +9392,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function T8(t){const{inputs:e,backend:n,attrs:s}=t,{dy:r,input:o}=e,{filterSize:i,strides:a,pad:l,dimRoundingMode:c}=s;de([r,o],"avgPool3DGrad");const u=Yr(o.shape,i,a,1,l,c),h=u.strideDepth,d=u.strideHeight,f=u.strideWidth,p=u.filterDepth,g=u.filterHeight,x=u.filterWidth,m=u.dilationDepth,y=u.dilationHeight,w=u.dilationWidth,v=u.effectiveFilterDepth,b=u.effectiveFilterHeight,C=u.effectiveFilterWidth,k=v-1-u.padInfo.front,S=C-1-u.padInfo.left,$=b-1-u.padInfo.top,N=Ee(o.shape,"float32"),A=1/(p*g*x),M=n.bufferSync(r);for(let L=0;L=u.outDepth||Math.floor(Q)!==Q))for(let te=0;te=u.outHeight||Math.floor(Z)!==Z))for(let se=0;se=u.outWidth||Math.floor(ie)!==ie)continue;const ce=M.get(L,Q,Z,ie,V);X+=ce}}}N.set(X*A,L,B,U,K,V)}return n.makeTensorInfo(N.shape,N.dtype,N.values)}const E8={kernelName:Xx,backendName:"cpu",kernelFunc:T8};/** + */function N8(t){const{inputs:e,backend:n,attrs:s}=t,{dy:r,input:o}=e,{filterSize:i,strides:a,pad:l,dimRoundingMode:c}=s;de([r,o],"avgPool3DGrad");const u=Yr(o.shape,i,a,1,l,c),h=u.strideDepth,d=u.strideHeight,f=u.strideWidth,p=u.filterDepth,g=u.filterHeight,x=u.filterWidth,m=u.dilationDepth,y=u.dilationHeight,w=u.dilationWidth,v=u.effectiveFilterDepth,b=u.effectiveFilterHeight,C=u.effectiveFilterWidth,k=v-1-u.padInfo.front,S=C-1-u.padInfo.left,$=b-1-u.padInfo.top,N=Ee(o.shape,"float32"),A=1/(p*g*x),M=n.bufferSync(r);for(let L=0;L=u.outDepth||Math.floor(Q)!==Q))for(let te=0;te=u.outHeight||Math.floor(Z)!==Z))for(let se=0;se=u.outWidth||Math.floor(ie)!==ie)continue;const ce=M.get(L,Q,Z,ie,V);X+=ce}}}N.set(X*A,L,B,U,K,V)}return n.makeTensorInfo(N.shape,N.dtype,N.values)}const T8={kernelName:Xx,backendName:"cpu",kernelFunc:N8};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9407,7 +9407,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function R8(t){const{inputs:e,backend:n,attrs:s}=t,{dy:r,input:o}=e,i=o;de([r,o],"avgPoolGrad");const{filterSize:a,strides:l,pad:c}=s,u=As(i.shape,a,l,1,c),h=u.strideHeight,d=u.strideWidth,f=u.filterHeight,p=u.filterWidth,g=u.dilationHeight,x=u.dilationWidth,m=u.effectiveFilterHeight,y=u.effectiveFilterWidth,w=y-1-u.padInfo.left,v=m-1-u.padInfo.top,b=Ee(i.shape,"float32"),C=1/(f*p),k=n.data.get(r.dataId).values,S=Ee(r.shape,"float32",k);for(let $=0;$=u.outHeight||Math.floor(K)!==K))for(let R=0;R=u.outWidth||Math.floor(O)!==O)continue;const G=S.get($,K,O,N);B+=G}}b.set(B*C,$,A,M,N)}return n.makeTensorInfo(b.shape,b.dtype,b.values)}const A8={kernelName:Kx,backendName:"cpu",kernelFunc:R8};/** + */function E8(t){const{inputs:e,backend:n,attrs:s}=t,{dy:r,input:o}=e,i=o;de([r,o],"avgPoolGrad");const{filterSize:a,strides:l,pad:c}=s,u=As(i.shape,a,l,1,c),h=u.strideHeight,d=u.strideWidth,f=u.filterHeight,p=u.filterWidth,g=u.dilationHeight,x=u.dilationWidth,m=u.effectiveFilterHeight,y=u.effectiveFilterWidth,w=y-1-u.padInfo.left,v=m-1-u.padInfo.top,b=Ee(i.shape,"float32"),C=1/(f*p),k=n.data.get(r.dataId).values,S=Ee(r.shape,"float32",k);for(let $=0;$=u.outHeight||Math.floor(K)!==K))for(let R=0;R=u.outWidth||Math.floor(O)!==O)continue;const G=S.get($,K,O,N);B+=G}}b.set(B*C,$,A,M,N)}return n.makeTensorInfo(b.shape,b.dtype,b.values)}const R8={kernelName:Kx,backendName:"cpu",kernelFunc:E8};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9422,7 +9422,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function D8(t){const{inputs:e,backend:n,attrs:s}=t,{x:r,scale:o,offset:i,mean:a,variance:l}=e;I(a.shape.length===l.shape.length,()=>"Batch normalization gradient requires mean and variance to have equal ranks."),I(i==null||a.shape.length===i.shape.length,()=>"Batch normalization gradient requires mean and offset to have equal ranks."),I(o==null||a.shape.length===o.shape.length,()=>"Batch normalization gradient requires mean and scale to have equal ranks."),de([r,a,l,o,i],"batchNorm");let{varianceEpsilon:c}=s;c==null&&(c=.001);const u=n.data.get(r.dataId).values,h=n.data.get(a.dataId).values,d=n.data.get(l.dataId).values,f=o?n.data.get(o.dataId).values:new Float32Array([1]),p=i?n.data.get(i.dataId).values:new Float32Array([0]),g=new Float32Array(u.length),x=p.length,m=f.length,y=d.length,w=h.length;let v=0,b=0,C=0,k=0;for(let S=0;S=x&&(v=0),b>=w&&(b=0),C>=m&&(C=0),k>=y&&(k=0);return n.makeTensorInfo(r.shape,r.dtype,g)}const _8={kernelName:Ap,backendName:"cpu",kernelFunc:D8};/** + */function A8(t){const{inputs:e,backend:n,attrs:s}=t,{x:r,scale:o,offset:i,mean:a,variance:l}=e;I(a.shape.length===l.shape.length,()=>"Batch normalization gradient requires mean and variance to have equal ranks."),I(i==null||a.shape.length===i.shape.length,()=>"Batch normalization gradient requires mean and offset to have equal ranks."),I(o==null||a.shape.length===o.shape.length,()=>"Batch normalization gradient requires mean and scale to have equal ranks."),de([r,a,l,o,i],"batchNorm");let{varianceEpsilon:c}=s;c==null&&(c=.001);const u=n.data.get(r.dataId).values,h=n.data.get(a.dataId).values,d=n.data.get(l.dataId).values,f=o?n.data.get(o.dataId).values:new Float32Array([1]),p=i?n.data.get(i.dataId).values:new Float32Array([0]),g=new Float32Array(u.length),x=p.length,m=f.length,y=d.length,w=h.length;let v=0,b=0,C=0,k=0;for(let S=0;S=x&&(v=0),b>=w&&(b=0),C>=m&&(C=0),k>=y&&(k=0);return n.makeTensorInfo(r.shape,r.dtype,g)}const D8={kernelName:Ap,backendName:"cpu",kernelFunc:A8};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9437,7 +9437,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function F8(t){const{inputs:e,backend:n,attrs:s}=t,{x:r}=e,{blockShape:o,crops:i}=s;de([r],"batchToSpaceND");const a=o.reduce((m,y)=>m*y),l=gh(r.shape,o,a),c=xh(l.length,o.length),u=yh(r.shape,o,a),h=Nw(i,o.length),d=Tw(u,i,o.length),f=st({inputs:{x:r},backend:n,attrs:{shape:l}}),p=Fn({inputs:{x:f},backend:n,attrs:{perm:c}}),g=st({inputs:{x:p},backend:n,attrs:{shape:u}}),x=Vi({inputs:{x:g},backend:n,attrs:{begin:h,size:d}});return n.disposeIntermediateTensorInfo(f),n.disposeIntermediateTensorInfo(p),n.disposeIntermediateTensorInfo(g),x}const z8={kernelName:vp,backendName:"cpu",kernelFunc:F8};/** + */function _8(t){const{inputs:e,backend:n,attrs:s}=t,{x:r}=e,{blockShape:o,crops:i}=s;de([r],"batchToSpaceND");const a=o.reduce((m,y)=>m*y),l=mh(r.shape,o,a),c=gh(l.length,o.length),u=xh(r.shape,o,a),h=Nw(i,o.length),d=Tw(u,i,o.length),f=st({inputs:{x:r},backend:n,attrs:{shape:l}}),p=Fn({inputs:{x:f},backend:n,attrs:{perm:c}}),g=st({inputs:{x:p},backend:n,attrs:{shape:u}}),x=Vi({inputs:{x:g},backend:n,attrs:{begin:h,size:d}});return n.disposeIntermediateTensorInfo(f),n.disposeIntermediateTensorInfo(p),n.disposeIntermediateTensorInfo(g),x}const F8={kernelName:vp,backendName:"cpu",kernelFunc:_8};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9452,7 +9452,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function O8(t){const{inputs:e,backend:n,attrs:s}=t,{x:r,weights:o}=e,{size:i}=s,a=n.data.get(r.dataId).values,l=n.data.get(o.dataId).values,c=dv(a,l,o.dtype,o.shape,i);return n.makeTensorInfo([i],o.dtype,c)}const M8={kernelName:qx,backendName:"cpu",kernelFunc:O8};/** + */function z8(t){const{inputs:e,backend:n,attrs:s}=t,{x:r,weights:o}=e,{size:i}=s,a=n.data.get(r.dataId).values,l=n.data.get(o.dataId).values,c=dv(a,l,o.dtype,o.shape,i);return n.makeTensorInfo([i],o.dtype,c)}const O8={kernelName:qx,backendName:"cpu",kernelFunc:z8};/** * @license * Copyright 2021 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9467,7 +9467,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function P8(t){const{inputs:e,backend:n}=t,{s0:s,s1:r}=e,o=n.data.get(s.dataId).values,i=n.data.get(r.dataId).values,a=Se(Array.from(o),Array.from(i));return n.makeTensorInfo([a.length],"int32",Int32Array.from(a))}const L8={kernelName:JI,backendName:"cpu",kernelFunc:P8};/** + */function M8(t){const{inputs:e,backend:n}=t,{s0:s,s1:r}=e,o=n.data.get(s.dataId).values,i=n.data.get(r.dataId).values,a=Se(Array.from(o),Array.from(i));return n.makeTensorInfo([a.length],"int32",Int32Array.from(a))}const P8={kernelName:JI,backendName:"cpu",kernelFunc:M8};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the License); @@ -9482,7 +9482,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const B8=Xe(ku,(t,e)=>{const n=e;return t>n.clipValueMax?n.clipValueMax:t{const n=e;return t>n.clipValueMax?n.clipValueMax:t{const{x:e}=t.inputs,n=t.backend,s=new Float32Array(j(e.shape)),r=n.data.get(e.dataId),o=r.complexTensorInfos.real,i=r.complexTensorInfos.imag,a=n.data.get(o.dataId).values,l=n.data.get(i.dataId).values;for(let c=0;c{const{x:e}=t.inputs,n=t.backend,s=new Float32Array(j(e.shape)),r=n.data.get(e.dataId),o=r.complexTensorInfos.real,i=r.complexTensorInfos.imag,a=n.data.get(o.dataId).values,l=n.data.get(i.dataId).values;for(let c=0;cg.shape);Sw(i,o);let a=wr(e.map(g=>g.shape),o);if(j(a)===0)return n.makeTensorInfo(a,e[0].dtype,[]);const l=e.filter(g=>j(g.shape)>0);if(l.length===1)return Nr({inputs:{x:l[0]},backend:n});if(l[0].dtype==="complex64"){const g=l.map(v=>Bi({inputs:{input:v},backend:n})),x=l.map(v=>ul({inputs:{input:v},backend:n})),m=hl({inputs:g,backend:n,attrs:{axis:o}}),y=hl({inputs:x,backend:n,attrs:{axis:o}}),w=Vn({inputs:{real:m,imag:y},backend:n});return g.forEach(v=>n.disposeIntermediateTensorInfo(v)),x.forEach(v=>n.disposeIntermediateTensorInfo(v)),n.disposeIntermediateTensorInfo(m),n.disposeIntermediateTensorInfo(y),w}const c=l.map(g=>{const m=[-1,j(g.shape.slice(o))];return st({inputs:{x:g},backend:n,attrs:{shape:m}})}),u=c.map(g=>({vals:n.data.get(g.dataId).values,shape:g.shape}));a=wr(c.map(g=>g.shape),1);const h=c[0].shape[0]===1,d=MR(u,a,e[0].dtype,h),f=wr(l.map(g=>g.shape),o),p=n.makeTensorInfo(f,e[0].dtype,d);return c.forEach(g=>n.disposeIntermediateTensorInfo(g)),p}const H8={kernelName:Cp,backendName:"cpu",kernelFunc:hl};/** + */function hl(t){const{inputs:e,backend:n,attrs:s}=t,{axis:r}=s,o=Re(r,e[0].shape)[0],i=e.map(g=>g.shape);Sw(i,o);let a=wr(e.map(g=>g.shape),o);if(j(a)===0)return n.makeTensorInfo(a,e[0].dtype,[]);const l=e.filter(g=>j(g.shape)>0);if(l.length===1)return Nr({inputs:{x:l[0]},backend:n});if(l[0].dtype==="complex64"){const g=l.map(v=>Bi({inputs:{input:v},backend:n})),x=l.map(v=>ul({inputs:{input:v},backend:n})),m=hl({inputs:g,backend:n,attrs:{axis:o}}),y=hl({inputs:x,backend:n,attrs:{axis:o}}),w=Vn({inputs:{real:m,imag:y},backend:n});return g.forEach(v=>n.disposeIntermediateTensorInfo(v)),x.forEach(v=>n.disposeIntermediateTensorInfo(v)),n.disposeIntermediateTensorInfo(m),n.disposeIntermediateTensorInfo(y),w}const c=l.map(g=>{const m=[-1,j(g.shape.slice(o))];return st({inputs:{x:g},backend:n,attrs:{shape:m}})}),u=c.map(g=>({vals:n.data.get(g.dataId).values,shape:g.shape}));a=wr(c.map(g=>g.shape),1);const h=c[0].shape[0]===1,d=MR(u,a,e[0].dtype,h),f=wr(l.map(g=>g.shape),o),p=n.makeTensorInfo(f,e[0].dtype,d);return c.forEach(g=>n.disposeIntermediateTensorInfo(g)),p}const G8={kernelName:Cp,backendName:"cpu",kernelFunc:hl};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9542,7 +9542,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function _A(t){const{inputs:e,backend:n,attrs:s}=t,{x:r,filter:o}=e,{strides:i,pad:a,dataFormat:l,dilations:c,dimRoundingMode:u}=s;de([r,o],"conv2d");const h=Qr(l),d=nn(r.shape,o.shape,i,c,a,u,!1,h),f=d.filterHeight,p=d.filterWidth,g=d.dilationHeight,x=d.dilationWidth,m=d.padInfo.left,y=d.padInfo.top,w=d.dataFormat==="channelsLast",v=new tn(d.outShape,r.dtype),b=pe(r.shape),C=pe(o.shape),k=b[0],S=w?b[1]:b[2],$=w?b[2]:1,N=w?1:b[1],A=v.strides[0],M=w?v.strides[1]:v.strides[2],L=w?v.strides[2]:1,V=w?1:v.strides[1],B=n.data.get(r.dataId).values,U=n.data.get(o.dataId).values,K=v.values;for(let R=0;R=d.inHeight)continue;const se=te*C[0],ie=O+Z*S;for(let ce=0;ce=d.inWidth)continue;const He=se+be*C[1],Ne=ie+ke*$;let Me=He;for(let Be=0;Be=d.inHeight)continue;const se=te*C[0],ie=O+Z*S;for(let ce=0;ce=d.inWidth)continue;const He=se+be*C[1],Ne=ie+ke*$;let Me=He;for(let Be=0;Be=c.inDepth)continue;const R=U*$[0],O=A+K*S[1];for(let G=0;G=c.inHeight)continue;const Z=R+Q*$[1],se=O+te*S[2];for(let ie=0;ie=c.inWidth)continue;const ke=Z+xe*$[2],He=se+be*c.inChannels;let Ne=ke;for(let Me=0;Me=c.inDepth)continue;const R=U*$[0],O=A+K*S[1];for(let G=0;G=c.inHeight)continue;const Z=R+Q*$[1],se=O+te*S[2];for(let ie=0;ie=c.inWidth)continue;const ke=Z+xe*$[2],He=se+be*c.inChannels;let Ne=ke;for(let Me=0;MeMath.cos(t)),rK={kernelName:Su,backendName:"cpu",kernelFunc:sK};/** + */const nK=Xe(ku,t=>Math.cos(t)),sK={kernelName:ku,backendName:"cpu",kernelFunc:nK};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the License); @@ -9647,7 +9647,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const oK=Xe(Iu,t=>Math.cosh(t)),iK={kernelName:Iu,backendName:"cpu",kernelFunc:oK};/** + */const rK=Xe(Su,t=>Math.cosh(t)),oK={kernelName:Su,backendName:"cpu",kernelFunc:rK};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9662,7 +9662,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function aK(t){const{inputs:e,backend:n,attrs:s}=t,{image:r,boxes:o,boxInd:i}=e,{cropSize:a,method:l,extrapolationValue:c}=s,[u,h,d,f]=r.shape,p=o.shape[0],[g,x]=a,m=Ee([p,g,x,f],"float32"),y=n.data.get(o.dataId).values,w=n.data.get(i.dataId).values,v=n.data.get(r.dataId).values,b=pe(r.shape),C=pe(m.shape);for(let k=0;k=u)continue;const V=g>1?(A-$)*(h-1)/(g-1):0,B=x>1?(M-N)*(d-1)/(x-1):0;for(let U=0;U1?$*(h-1)+U*V:.5*($+A)*(h-1);if(K<0||K>h-1){for(let R=0;R1?N*(d-1)+X*B:.5*(N+M)*(d-1);if(q<0||q>d-1){for(let se=0;se1?N*(d-1)+R*B:.5*(N+M)*(d-1);if(O<0||O>d-1){for(let q=0;q=u)continue;const V=g>1?(A-$)*(h-1)/(g-1):0,B=x>1?(M-N)*(d-1)/(x-1):0;for(let U=0;U1?$*(h-1)+U*V:.5*($+A)*(h-1);if(K<0||K>h-1){for(let R=0;R1?N*(d-1)+X*B:.5*(N+M)*(d-1);if(q<0||q>d-1){for(let se=0;se1?N*(d-1)+R*B:.5*(N+M)*(d-1);if(O<0||O>d-1){for(let q=0;qm+p-y-1:(m,y)=>m+y;for(let m=0;mm+p-y-1:(m,y)=>m+y;for(let m=0;mm+p-y-1:(m,y)=>m+y;for(let m=0;mm+p-y-1:(m,y)=>m+y;for(let m=0;m`Only NHWC dataFormat supported on CPU for depthToSpace. Got ${i}`);const a=r.shape[0],l=r.shape[1],c=r.shape[2],u=r.shape[3],h=l*o,d=c*o,f=u/(o*o),p=n.data.get(r.dataId).values,g=new Float32Array(a*h*d*f);let x=0;for(let m=0;m`Only NHWC dataFormat supported on CPU for depthToSpace. Got ${i}`);const a=r.shape[0],l=r.shape[1],c=r.shape[2],u=r.shape[3],h=l*o,d=c*o,f=u/(o*o),p=n.data.get(r.dataId).values,g=new Float32Array(a*h*d*f);let x=0;for(let m=0;m`Error in depthwiseConv2d: Either strides or dilations must be 1. Got strides ${i} and dilations '${d}'`);const f=nn(r.shape,o.shape,i,d,a,c,!0),{filterHeight:p,filterWidth:g,dilationHeight:x,dilationWidth:m,padInfo:y}=f,w=y.left,v=y.top,b=f.outChannels/f.inChannels,C=new tn(f.outShape,r.dtype),k=n.data.get(r.dataId).values,S=n.data.get(o.dataId).values,$=C.values;for(let N=0;N=f.inHeight)continue;const R=U*h[0],O=A+K*u[1];for(let G=0;G=f.inWidth)continue;const Z=R+Q*h[1],se=O+te*f.inChannels;let ie=X,ce=Z;for(let ue=0;ue`Error in depthwiseConv2d: Either strides or dilations must be 1. Got strides ${i} and dilations '${d}'`);const f=nn(r.shape,o.shape,i,d,a,c,!0),{filterHeight:p,filterWidth:g,dilationHeight:x,dilationWidth:m,padInfo:y}=f,w=y.left,v=y.top,b=f.outChannels/f.inChannels,C=new tn(f.outShape,r.dtype),k=n.data.get(r.dataId).values,S=n.data.get(o.dataId).values,$=C.values;for(let N=0;N=f.inHeight)continue;const R=U*h[0],O=A+K*u[1];for(let G=0;G=f.inWidth)continue;const Z=R+Q*h[1],se=O+te*f.inChannels;let ie=X,ce=Z;for(let ue=0;ue{const{x:s,filter:r}=t,{strides:o,pad:i,dilations:a}=n,l=e,c=l.data.get(s.dataId).values,u=s.shape.length,h=l.data.get(r.dataId).values,d=r.shape.length,{batchSize:f,inHeight:p,inWidth:g,inChannels:x,outHeight:m,outWidth:y,padInfo:w,strideHeight:v,strideWidth:b,filterHeight:C,filterWidth:k,dilationHeight:S,dilationWidth:$,outShape:N}=hh(s.shape,r.shape,o,i,"NHWC",a),A=j(N),M=N.length,L=kt(s.dtype,A);for(let B=0;B=0&&te=0&&seX&&(X=ue)}}}const q=xr([B,U,R,G],M,pe(N));L[q]=X}}}return{dataId:l.write(Ki(L,s.dtype),N,s.dtype),shape:N,dtype:s.dtype}}};/** + */const kK={kernelName:Tp,backendName:"cpu",kernelFunc:({inputs:t,backend:e,attrs:n})=>{const{x:s,filter:r}=t,{strides:o,pad:i,dilations:a}=n,l=e,c=l.data.get(s.dataId).values,u=s.shape.length,h=l.data.get(r.dataId).values,d=r.shape.length,{batchSize:f,inHeight:p,inWidth:g,inChannels:x,outHeight:m,outWidth:y,padInfo:w,strideHeight:v,strideWidth:b,filterHeight:C,filterWidth:k,dilationHeight:S,dilationWidth:$,outShape:N}=uh(s.shape,r.shape,o,i,"NHWC",a),A=j(N),M=N.length,L=kt(s.dtype,A);for(let B=0;B=0&&te=0&&seX&&(X=ue)}}}const q=xr([B,U,R,G],M,pe(N));L[q]=X}}}return{dataId:l.write(Ki(L,s.dtype),N,s.dtype),shape:N,dtype:s.dtype}}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9812,7 +9812,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const IK={kernelName:J0,backendName:"cpu",kernelFunc:({inputs:t,backend:e,attrs:n})=>{const{x:s,filter:r,dy:o}=t,{strides:i,pad:a,dilations:l}=n,c=e,u=qs(s.shape,c.data.get(s.dataId).values),h=qs(r.shape,c.data.get(r.dataId).values),{batchSize:d,inHeight:f,inWidth:p,inChannels:g,outHeight:x,outWidth:m,padInfo:y,strideHeight:w,strideWidth:v,filterHeight:b,filterWidth:C,dilationHeight:k,dilationWidth:S,outShape:$}=hh(s.shape,r.shape,i,a,"NHWC",l);I(o.rank===$.length,()=>`Error in ${J0}, dy must have the same rank as output ${$.length}, but got ${o.rank}`);const N=qs($,c.data.get(o.dataId).values),A=YI(r.shape,r.dtype);for(let L=0;L=0&&Q=0&&ZO&&(O=se,G=q,X=te)}}}A[G][X][R]+=N[L][V][U][R]}}}return{dataId:c.write(Ki(A,s.dtype),r.shape,r.dtype),shape:r.shape,dtype:r.dtype}}};/** + */const SK={kernelName:J0,backendName:"cpu",kernelFunc:({inputs:t,backend:e,attrs:n})=>{const{x:s,filter:r,dy:o}=t,{strides:i,pad:a,dilations:l}=n,c=e,u=qs(s.shape,c.data.get(s.dataId).values),h=qs(r.shape,c.data.get(r.dataId).values),{batchSize:d,inHeight:f,inWidth:p,inChannels:g,outHeight:x,outWidth:m,padInfo:y,strideHeight:w,strideWidth:v,filterHeight:b,filterWidth:C,dilationHeight:k,dilationWidth:S,outShape:$}=uh(s.shape,r.shape,i,a,"NHWC",l);I(o.rank===$.length,()=>`Error in ${J0}, dy must have the same rank as output ${$.length}, but got ${o.rank}`);const N=qs($,c.data.get(o.dataId).values),A=YI(r.shape,r.dtype);for(let L=0;L=0&&Q=0&&ZO&&(O=se,G=q,X=te)}}}A[G][X][R]+=N[L][V][U][R]}}}return{dataId:c.write(Ki(A,s.dtype),r.shape,r.dtype),shape:r.shape,dtype:r.dtype}}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9827,7 +9827,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const $K={kernelName:Z0,backendName:"cpu",kernelFunc:({inputs:t,backend:e,attrs:n})=>{const{x:s,filter:r,dy:o}=t,{strides:i,pad:a,dilations:l}=n,c=e,u=qs(s.shape,c.data.get(s.dataId).values),h=qs(r.shape,c.data.get(r.dataId).values),{batchSize:d,inHeight:f,inWidth:p,inChannels:g,outHeight:x,outWidth:m,padInfo:y,strideHeight:w,strideWidth:v,filterHeight:b,filterWidth:C,dilationHeight:k,dilationWidth:S,outShape:$}=hh(s.shape,r.shape,i,a,"NHWC",l);I(o.rank===$.length,()=>`Error in ${Z0}, dy must have the same rank as output ${$.length}, but got ${o.rank}`);const N=qs($,c.data.get(o.dataId).values),A=YI(s.shape,s.dtype);for(let L=0;L=0&&Q=0&&ZO&&(O=se,G=Q,X=Z)}}}A[L][G][X][R]+=N[L][V][U][R]}}}return{dataId:c.write(Ki(A,s.dtype),s.shape,s.dtype),shape:s.shape,dtype:s.dtype}}};/** + */const IK={kernelName:Z0,backendName:"cpu",kernelFunc:({inputs:t,backend:e,attrs:n})=>{const{x:s,filter:r,dy:o}=t,{strides:i,pad:a,dilations:l}=n,c=e,u=qs(s.shape,c.data.get(s.dataId).values),h=qs(r.shape,c.data.get(r.dataId).values),{batchSize:d,inHeight:f,inWidth:p,inChannels:g,outHeight:x,outWidth:m,padInfo:y,strideHeight:w,strideWidth:v,filterHeight:b,filterWidth:C,dilationHeight:k,dilationWidth:S,outShape:$}=uh(s.shape,r.shape,i,a,"NHWC",l);I(o.rank===$.length,()=>`Error in ${Z0}, dy must have the same rank as output ${$.length}, but got ${o.rank}`);const N=qs($,c.data.get(o.dataId).values),A=YI(s.shape,s.dtype);for(let L=0;L=0&&Q=0&&ZO&&(O=se,G=Q,X=Z)}}}A[L][G][X][R]+=N[L][V][U][R]}}}return{dataId:c.write(Ki(A,s.dtype),s.shape,s.dtype),shape:s.shape,dtype:s.dtype}}};/** * @license * Copyright 2023 Google LLC. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9842,7 +9842,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function NK(t){const{inputs:e,backend:n,attrs:s}=t,{image:r}=e,{canvas:o,options:i}=s,{contextOptions:a,imageOptions:l}=i||{},c=(l==null?void 0:l.alpha)||1,u=(a==null?void 0:a.contextType)||"2d";if(u!=="2d")throw new Error(`Context type ${a.contextType} is not supported by the CPU backend.`);const h=o.getContext(u,(a==null?void 0:a.contextAttributes)||{});if(h==null)throw new Error(`Could not get the context with ${u} type.`);const[d,f]=r.shape.slice(0,2),p=r.shape.length===2?1:r.shape[2],g=n.data.get(r.dataId).values,x=r.dtype==="float32"?255:1,m=new Uint8ClampedArray(f*d*4);for(let w=0;w1)throw new Error(`Tensor values for a float32 Tensor must be in the range [0 - 1] but encountered ${k}.`)}else if(r.dtype==="int32"&&(k<0||k>255))throw new Error(`Tensor values for a int32 Tensor must be in the range [0 - 255] but encountered ${k}.`);p===1?(v[0]=k*x,v[1]=k*x,v[2]=k*x):v[C]=k*x}const b=w*4;m[b+0]=Math.round(v[0]),m[b+1]=Math.round(v[1]),m[b+2]=Math.round(v[2]),m[b+3]=Math.round(v[3])}o.width=f,o.height=d;const y=new ImageData(m,f,d);return h.putImageData(y,0,0),r}const TK={kernelName:WM,backendName:"cpu",kernelFunc:NK};/** + */function $K(t){const{inputs:e,backend:n,attrs:s}=t,{image:r}=e,{canvas:o,options:i}=s,{contextOptions:a,imageOptions:l}=i||{},c=(l==null?void 0:l.alpha)||1,u=(a==null?void 0:a.contextType)||"2d";if(u!=="2d")throw new Error(`Context type ${a.contextType} is not supported by the CPU backend.`);const h=o.getContext(u,(a==null?void 0:a.contextAttributes)||{});if(h==null)throw new Error(`Could not get the context with ${u} type.`);const[d,f]=r.shape.slice(0,2),p=r.shape.length===2?1:r.shape[2],g=n.data.get(r.dataId).values,x=r.dtype==="float32"?255:1,m=new Uint8ClampedArray(f*d*4);for(let w=0;w1)throw new Error(`Tensor values for a float32 Tensor must be in the range [0 - 1] but encountered ${k}.`)}else if(r.dtype==="int32"&&(k<0||k>255))throw new Error(`Tensor values for a int32 Tensor must be in the range [0 - 255] but encountered ${k}.`);p===1?(v[0]=k*x,v[1]=k*x,v[2]=k*x):v[C]=k*x}const b=w*4;m[b+0]=Math.round(v[0]),m[b+1]=Math.round(v[1]),m[b+2]=Math.round(v[2]),m[b+3]=Math.round(v[3])}o.width=f,o.height=d;const y=new ImageData(m,f,d);return h.putImageData(y,0,0),r}const NK={kernelName:VM,backendName:"cpu",kernelFunc:$K};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9857,7 +9857,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function Nh(t){const{inputs:e,backend:n,attrs:s}=t,{x:r}=e,{axis:o,keepDims:i}=s;de(r,"sum");let a;r.dtype==="bool"?a=Mo({inputs:{x:r},backend:n,attrs:{dtype:"int32"}}):a=Nr({inputs:{x:r},backend:n});const l=a.shape.length,c=Re(o,a.shape),u=yt(c,l);let h=c,d=a;u!=null&&(d=Fn({inputs:{x:a},backend:n,attrs:{perm:u}}),h=$t(h.length,l)),sn("sum",h,d.shape.length);const[f,p]=Yt(d.shape,h),g=Xn(d.dtype,"int32");let x=Ff(n,f,g);const m=j(p),y=n.data.get(x.dataId).values,w=n.data.get(d.dataId).values;for(let v=0;v=0&&(d=Nh({inputs:{x:d},backend:n,attrs:{axis:c[g]-(i.length-f),keepDims:!1}}),p.push(d)),f--)}for(const g of p)g!==d&&n.disposeIntermediateTensorInfo(g);return d}const AK={kernelName:ay,backendName:"cpu",kernelFunc:RK};/** + */function EK(t){const{inputs:e,backend:n,attrs:s}=t,{equation:r}=s,o=e,{allDims:i,summedDims:a,idDims:l}=Ow(r,o.length);Pw(i.length,l,o);const{path:c,steps:u}=Lw(a,l),h=u.length;let d=null,f=i.length;const p=[];for(let g=0;g=0&&(d=$h({inputs:{x:d},backend:n,attrs:{axis:c[g]-(i.length-f),keepDims:!1}}),p.push(d)),f--)}for(const g of p)g!==d&&n.disposeIntermediateTensorInfo(g);return d}const RK={kernelName:ay,backendName:"cpu",kernelFunc:EK};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9887,7 +9887,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function DK(t){const{inputs:e,backend:n}=t,{dy:s,y:r}=e;de([s,r],"eluGrad");const o=new Float32Array(j(r.shape)),i=n.data.get(r.dataId).values,a=n.data.get(s.dataId).values;for(let l=0;l=0?o[l]=a[l]:o[l]=a[l]*(c+1)}return n.makeTensorInfo(r.shape,"float32",o)}const _K={kernelName:ly,backendName:"cpu",kernelFunc:DK};/** + */function AK(t){const{inputs:e,backend:n}=t,{dy:s,y:r}=e;de([s,r],"eluGrad");const o=new Float32Array(j(r.shape)),i=n.data.get(r.dataId).values,a=n.data.get(s.dataId).values;for(let l=0;l=0?o[l]=a[l]:o[l]=a[l]*(c+1)}return n.makeTensorInfo(r.shape,"float32",o)}const DK={kernelName:ly,backendName:"cpu",kernelFunc:AK};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the License); @@ -9902,7 +9902,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const FK=Ew,zK=Rw,OK=Aw,MK=Dw,PK=_w,LK=Fw,BK=Xe(Tu,t=>{const e=Math.sign(t),n=Math.abs(t),s=1/(1+FK*n);return e*(1-((((LK*s+PK)*s+MK)*s+OK)*s+zK)*s*Math.exp(-n*n))}),VK={kernelName:Tu,backendName:"cpu",kernelFunc:BK};/** + */const _K=Ew,FK=Rw,zK=Aw,OK=Dw,MK=_w,PK=Fw,LK=Xe(Nu,t=>{const e=Math.sign(t),n=Math.abs(t),s=1/(1+_K*n);return e*(1-((((PK*s+MK)*s+OK)*s+zK)*s+FK)*s*Math.exp(-n*n))}),BK={kernelName:Nu,backendName:"cpu",kernelFunc:LK};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9917,7 +9917,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function Mf(t){const{inputs:e,backend:n,attrs:s}=t,{input:r}=e,{dim:o}=s,i=r.shape.length,a=r.shape.slice();let l=o;return o<0&&(I(-(i+1)<=o,()=>`Axis must be in the interval [${-(i+1)}, ${i}]`),l=i+o+1),a.splice(l,0,1),st({inputs:{x:r},backend:n,attrs:{shape:a}})}const WK={kernelName:Rp,backendName:"cpu",kernelFunc:Mf};/** + */function Of(t){const{inputs:e,backend:n,attrs:s}=t,{input:r}=e,{dim:o}=s,i=r.shape.length,a=r.shape.slice();let l=o;return o<0&&(I(-(i+1)<=o,()=>`Axis must be in the interval [${-(i+1)}, ${i}]`),l=i+o+1),a.splice(l,0,1),st({inputs:{x:r},backend:n,attrs:{shape:a}})}const VK={kernelName:Rp,backendName:"cpu",kernelFunc:Of};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9932,7 +9932,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const UK=Tt((t,e)=>t/e),yv=Wt($u,UK),I1={kernelName:$u,backendName:"cpu",kernelFunc:yv};/** + */const WK=Tt((t,e)=>t/e),yv=Wt(Iu,WK),I1={kernelName:Iu,backendName:"cpu",kernelFunc:yv};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9947,7 +9947,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function zA(t,e,n){const s=t.shape,r=s[0],o=s[1],i=n.data.get(t.dataId),a=i.complexTensorInfos.real,l=i.complexTensorInfos.imag,c=[r,o],u=j(c),h=cn("float32",u),d=cn("float32",u);for(let x=0;x{const{image:s}=t,r=n,o=cn(s.dtype,j(s.shape)),[i,a,l,c]=s.shape,u=r.data.get(s.dataId).values;for(let d=0;d=0&&w{const{image:s}=t,r=n,o=cn(s.dtype,j(s.shape)),[i,a,l,c]=s.shape,u=r.data.get(s.dataId).values;for(let d=0;d=0&&w=0,()=>`GatherV2: the index value ${b} is not in [0, ${u-1}]`)}let h=a;a==null&&(h=0);const d=j(o.shape),f=Ww(r,o,l,h),p=st({inputs:{x:r},backend:n,attrs:{shape:[f.batchSize,f.outerSize,f.dimSize,f.sliceSize]}}),g=st({inputs:{x:o},backend:n,attrs:{shape:[f.batchSize,d/f.batchSize]}}),x=[f.batchSize,f.outerSize,d/f.batchSize,f.sliceSize],m=n.bufferSync(g),y=n.bufferSync(p),w=jR(y,m,x);return n.disposeIntermediateTensorInfo(p),n.disposeIntermediateTensorInfo(g),n.makeTensorInfo(f.outputShape,w.dtype,w.values)}const oX={kernelName:Dp,backendName:"cpu",kernelFunc:rX};/** + */function sX(t){const{inputs:e,backend:n,attrs:s}=t,{x:r,indices:o}=e,{axis:i,batchDims:a}=s;de([r,o],"gatherV2");const l=Re(i,r.shape)[0],c=n.data.get(o.dataId).values,u=r.shape[l];for(let v=0;v=0,()=>`GatherV2: the index value ${b} is not in [0, ${u-1}]`)}let h=a;a==null&&(h=0);const d=j(o.shape),f=Ww(r,o,l,h),p=st({inputs:{x:r},backend:n,attrs:{shape:[f.batchSize,f.outerSize,f.dimSize,f.sliceSize]}}),g=st({inputs:{x:o},backend:n,attrs:{shape:[f.batchSize,d/f.batchSize]}}),x=[f.batchSize,f.outerSize,d/f.batchSize,f.sliceSize],m=n.bufferSync(g),y=n.bufferSync(p),w=jR(y,m,x);return n.disposeIntermediateTensorInfo(p),n.disposeIntermediateTensorInfo(g),n.makeTensorInfo(f.outputShape,w.dtype,w.values)}const rX={kernelName:Dp,backendName:"cpu",kernelFunc:sX};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -10067,7 +10067,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function iX(t){const{inputs:e,backend:n}=t,{input:s}=e,r=j(s.shape),o=s.shape[s.shape.length-1],i=r/o,a=st({inputs:{x:s},backend:n,attrs:{shape:[i,o]}}),l=zA(a,!0,n),c=st({inputs:{x:l},backend:n,attrs:{shape:s.shape}});return n.disposeIntermediateTensorInfo(a),n.disposeIntermediateTensorInfo(l),c}const aX={kernelName:dy,backendName:"cpu",kernelFunc:iX};/** + */function oX(t){const{inputs:e,backend:n}=t,{input:s}=e,r=j(s.shape),o=s.shape[s.shape.length-1],i=r/o,a=st({inputs:{x:s},backend:n,attrs:{shape:[i,o]}}),l=zA(a,!0,n),c=st({inputs:{x:l},backend:n,attrs:{shape:s.shape}});return n.disposeIntermediateTensorInfo(a),n.disposeIntermediateTensorInfo(l),c}const iX={kernelName:dy,backendName:"cpu",kernelFunc:oX};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the License); @@ -10082,7 +10082,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const lX=Xe(zu,t=>Number.isFinite(t)?1:0,"bool"),cX={kernelName:zu,backendName:"cpu",kernelFunc:lX};/** + */const aX=Xe(Fu,t=>Number.isFinite(t)?1:0,"bool"),lX={kernelName:Fu,backendName:"cpu",kernelFunc:aX};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the License); @@ -10097,7 +10097,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const uX=Xe(Ou,t=>Math.abs(t)===1/0?1:0,"bool"),hX={kernelName:Ou,backendName:"cpu",kernelFunc:uX};/** + */const cX=Xe(zu,t=>Math.abs(t)===1/0?1:0,"bool"),uX={kernelName:zu,backendName:"cpu",kernelFunc:cX};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the License); @@ -10112,7 +10112,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const dX=Xe(Mu,t=>Number.isNaN(t)?1:0,"bool"),fX={kernelName:Mu,backendName:"cpu",kernelFunc:dX};/** + */const hX=Xe(Ou,t=>Number.isNaN(t)?1:0,"bool"),dX={kernelName:Ou,backendName:"cpu",kernelFunc:hX};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -10127,7 +10127,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function pX(t){const{backend:e,attrs:n}=t,{start:s,stop:r,num:o}=n,i=QR(s,r,o);return e.makeTensorInfo([i.length],"float32",i)}const mX={kernelName:n$,backendName:"cpu",kernelFunc:pX};/** + */function fX(t){const{backend:e,attrs:n}=t,{start:s,stop:r,num:o}=n,i=QR(s,r,o);return e.makeTensorInfo([i.length],"float32",i)}const pX={kernelName:n$,backendName:"cpu",kernelFunc:fX};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the License); @@ -10142,7 +10142,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const gX=Xe(Lu,t=>Math.log1p(t)),xX={kernelName:Lu,backendName:"cpu",kernelFunc:gX};/** + */const mX=Xe(Pu,t=>Math.log1p(t)),gX={kernelName:Pu,backendName:"cpu",kernelFunc:mX};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -10157,7 +10157,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const yX=Tt((t,e)=>t&&e),wX=Wt(Mp,yX,null,"bool"),vX={kernelName:Mp,backendName:"cpu",kernelFunc:wX};/** + */const xX=Tt((t,e)=>t&&e),yX=Wt(Mp,xX,null,"bool"),wX={kernelName:Mp,backendName:"cpu",kernelFunc:yX};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the License); @@ -10172,7 +10172,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const bX=Xe(Pp,t=>t?0:1,"bool"),CX={kernelName:Pp,backendName:"cpu",kernelFunc:bX};/** + */const vX=Xe(Pp,t=>t?0:1,"bool"),bX={kernelName:Pp,backendName:"cpu",kernelFunc:vX};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -10187,7 +10187,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const kX=Tt((t,e)=>t||e),SX=Wt(Lp,kX,null,"bool"),IX={kernelName:Lp,backendName:"cpu",kernelFunc:SX};/** + */const CX=Tt((t,e)=>t||e),kX=Wt(Lp,CX,null,"bool"),SX={kernelName:Lp,backendName:"cpu",kernelFunc:kX};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -10202,7 +10202,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function $X(t){const{inputs:e,backend:n,attrs:s}=t,{x:r}=e,{depthRadius:o,bias:i,alpha:a,beta:l}=s;de(r,"LRN");const c=r.shape[3],u=c-1,h=n.data.get(r.dataId).values,d=j(r.shape),f=new Float32Array(d);function p(g){const x=g%c;let m=g-x+Math.max(0,x-o);const y=g-x+Math.min(x+o,u);let w=0;for(;m<=y;m++){const v=h[m];w+=v*v}return w}for(let g=0;g`Error in maxPool: Either strides or dilations must be 1. Got strides ${i} and dilations '${c}'`);const u=As(r.shape,o,i,c,a,l);let h;if(u.filterWidth===1&&u.filterHeight===1&&Ue(u.inShape,u.outShape))h=Nr({inputs:{x:r},backend:n});else{const d=n.data.get(r.dataId).values,f=pe(r.shape),p=xv(d,r.shape,r.dtype,f,u,"max");h=n.makeTensorInfo(u.outShape,r.dtype,p.values)}return h}const DX={kernelName:Wp,backendName:"cpu",kernelFunc:AX};/** + */function RX(t){const{inputs:e,backend:n,attrs:s}=t,{x:r}=e;de(r,"maxPool");const{filterSize:o,strides:i,pad:a,dimRoundingMode:l}=s,c=1;I(dn(i,c),()=>`Error in maxPool: Either strides or dilations must be 1. Got strides ${i} and dilations '${c}'`);const u=As(r.shape,o,i,c,a,l);let h;if(u.filterWidth===1&&u.filterHeight===1&&Ue(u.inShape,u.outShape))h=Nr({inputs:{x:r},backend:n});else{const d=n.data.get(r.dataId).values,f=pe(r.shape),p=xv(d,r.shape,r.dtype,f,u,"max");h=n.makeTensorInfo(u.outShape,r.dtype,p.values)}return h}const AX={kernelName:Wp,backendName:"cpu",kernelFunc:RX};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -10262,7 +10262,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function _X(t){const{inputs:e,backend:n,attrs:s}=t,{x:r}=e,{filterSize:o,strides:i,pad:a,dimRoundingMode:l,dataFormat:c}=s;de(r,"maxPool3d");const u=Yr(r.shape,o,i,1,a,l,c),h=n.data.get(r.dataId).values,d=DA(h,r.shape,r.dtype,pe(r.shape),u,"max");return n.makeTensorInfo(d.shape,"float32",d.values)}const FX={kernelName:Up,backendName:"cpu",kernelFunc:_X};/** + */function DX(t){const{inputs:e,backend:n,attrs:s}=t,{x:r}=e,{filterSize:o,strides:i,pad:a,dimRoundingMode:l,dataFormat:c}=s;de(r,"maxPool3d");const u=Yr(r.shape,o,i,1,a,l,c),h=n.data.get(r.dataId).values,d=DA(h,r.shape,r.dtype,pe(r.shape),u,"max");return n.makeTensorInfo(d.shape,"float32",d.values)}const _X={kernelName:Up,backendName:"cpu",kernelFunc:DX};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -10277,7 +10277,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function zX(t){const{inputs:e,backend:n,attrs:s}=t,{dy:r,input:o}=e,{filterSize:i,strides:a,pad:l,dimRoundingMode:c}=s;de([r,o],"maxPool3DGrad");const u=Yr(o.shape,i,a,1,l,c),h=n.bufferSync(o),d=k8(h,u),f=u.strideDepth,p=u.strideHeight,g=u.strideWidth,x=u.dilationDepth,m=u.dilationHeight,y=u.dilationWidth,w=u.effectiveFilterDepth,v=u.effectiveFilterHeight,b=u.effectiveFilterWidth,C=w-1-u.padInfo.front,k=b-1-u.padInfo.left,S=v-1-u.padInfo.top,$=Ee(o.shape,"float32"),N=n.bufferSync(r);for(let A=0;A=u.outDepth||Math.floor(X)!==X))for(let q=0;q=u.outHeight||Math.floor(Q)!==Q))for(let te=0;te=u.outWidth||Math.floor(Z)!==Z)continue;const se=w*v*b-1-d.get(A,X,Q,Z,M),ie=G*v*b+q*b+te,ce=se===ie?1:0;if(ce===0)continue;const ue=N.get(A,X,Q,Z,M);O+=ue*ce}}}$.set(O,A,L,V,B,M)}return n.makeTensorInfo($.shape,$.dtype,$.values)}const OX={kernelName:gy,backendName:"cpu",kernelFunc:zX};/** + */function FX(t){const{inputs:e,backend:n,attrs:s}=t,{dy:r,input:o}=e,{filterSize:i,strides:a,pad:l,dimRoundingMode:c}=s;de([r,o],"maxPool3DGrad");const u=Yr(o.shape,i,a,1,l,c),h=n.bufferSync(o),d=C8(h,u),f=u.strideDepth,p=u.strideHeight,g=u.strideWidth,x=u.dilationDepth,m=u.dilationHeight,y=u.dilationWidth,w=u.effectiveFilterDepth,v=u.effectiveFilterHeight,b=u.effectiveFilterWidth,C=w-1-u.padInfo.front,k=b-1-u.padInfo.left,S=v-1-u.padInfo.top,$=Ee(o.shape,"float32"),N=n.bufferSync(r);for(let A=0;A=u.outDepth||Math.floor(X)!==X))for(let q=0;q=u.outHeight||Math.floor(Q)!==Q))for(let te=0;te=u.outWidth||Math.floor(Z)!==Z)continue;const se=w*v*b-1-d.get(A,X,Q,Z,M),ie=G*v*b+q*b+te,ce=se===ie?1:0;if(ce===0)continue;const ue=N.get(A,X,Q,Z,M);O+=ue*ce}}}$.set(O,A,L,V,B,M)}return n.makeTensorInfo($.shape,$.dtype,$.values)}const zX={kernelName:gy,backendName:"cpu",kernelFunc:FX};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -10292,7 +10292,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function MX(t){const{inputs:e,backend:n,attrs:s}=t,{dy:r,input:o,output:i}=e,a=o;de([o,i],"maxPoolGrad");const{filterSize:l,strides:c,pad:u,dimRoundingMode:h}=s,d=As(a.shape,l,c,1,u,h),f=n.data.get(a.dataId).values,p=Ee(d.outShape,a.dtype,AA(f,a.shape,a.dtype,d).values),g=d.strideHeight,x=d.strideWidth,m=d.dilationHeight,y=d.dilationWidth,w=d.effectiveFilterHeight,v=d.effectiveFilterWidth,b=v-1-d.padInfo.left,C=w-1-d.padInfo.top,k=Ee(a.shape,"float32"),S=n.data.get(r.dataId).values,$=Ee(r.shape,"float32",S);for(let N=0;N=d.outHeight||Math.floor(R)!==R))for(let O=0;O=d.outWidth||Math.floor(G)!==G)continue;const X=w*v-1-p.get(N,R,G,A),q=K*v+O,Q=X===q?1:0;if(Q===0)continue;const te=$.get(N,R,G,A);U+=te*Q}}k.set(U,N,M,L,A)}return n.makeTensorInfo(k.shape,k.dtype,k.values)}const PX={kernelName:my,backendName:"cpu",kernelFunc:MX};/** + */function OX(t){const{inputs:e,backend:n,attrs:s}=t,{dy:r,input:o,output:i}=e,a=o;de([o,i],"maxPoolGrad");const{filterSize:l,strides:c,pad:u,dimRoundingMode:h}=s,d=As(a.shape,l,c,1,u,h),f=n.data.get(a.dataId).values,p=Ee(d.outShape,a.dtype,AA(f,a.shape,a.dtype,d).values),g=d.strideHeight,x=d.strideWidth,m=d.dilationHeight,y=d.dilationWidth,w=d.effectiveFilterHeight,v=d.effectiveFilterWidth,b=v-1-d.padInfo.left,C=w-1-d.padInfo.top,k=Ee(a.shape,"float32"),S=n.data.get(r.dataId).values,$=Ee(r.shape,"float32",S);for(let N=0;N=d.outHeight||Math.floor(R)!==R))for(let O=0;O=d.outWidth||Math.floor(G)!==G)continue;const X=w*v-1-p.get(N,R,G,A),q=K*v+O,Q=X===q?1:0;if(Q===0)continue;const te=$.get(N,R,G,A);U+=te*Q}}k.set(U,N,M,L,A)}return n.makeTensorInfo(k.shape,k.dtype,k.values)}const MX={kernelName:my,backendName:"cpu",kernelFunc:OX};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -10307,7 +10307,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function LX(t,e,n,s,r){const o=pe(e),i=xv(t,e,n,o,r,"max"),a=AA(t,e,n,r,!0,s);return[i.values,a.values]}/** + */function PX(t,e,n,s,r){const o=pe(e),i=xv(t,e,n,o,r,"max"),a=AA(t,e,n,r,!0,s);return[i.values,a.values]}/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -10322,7 +10322,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const BX={kernelName:s$,backendName:"cpu",kernelFunc:({inputs:t,attrs:e,backend:n})=>{const{x:s}=t,{filterSize:r,strides:o,pad:i,includeBatchInIndex:a}=e,l=n;de(s,"MaxPoolWithArgmax");const c=l.data.get(s.dataId).values,u=As(s.shape,r,o,[1,1],i),[h,d]=LX(c,s.shape,s.dtype,a,u),f=l.write(h,u.outShape,s.dtype),p=l.write(d,u.outShape,s.dtype);return[{dataId:f,shape:u.outShape,dtype:s.dtype},{dataId:p,shape:u.outShape,dtype:"int32"}]}};/** + */const LX={kernelName:s$,backendName:"cpu",kernelFunc:({inputs:t,attrs:e,backend:n})=>{const{x:s}=t,{filterSize:r,strides:o,pad:i,includeBatchInIndex:a}=e,l=n;de(s,"MaxPoolWithArgmax");const c=l.data.get(s.dataId).values,u=As(s.shape,r,o,[1,1],i),[h,d]=PX(c,s.shape,s.dtype,a,u),f=l.write(h,u.outShape,s.dtype),p=l.write(d,u.outShape,s.dtype);return[{dataId:f,shape:u.outShape,dtype:s.dtype},{dataId:p,shape:u.outShape,dtype:"int32"}]}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -10337,7 +10337,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function VX(t){const{inputs:e,backend:n,attrs:s}=t,{x:r}=e,{axis:o,keepDims:i}=s,a=Re(o,r.shape),c=Yt(r.shape,a)[1],u=j(c),h=[],d=n.makeTensorInfo([],"float32",new Float32Array([u]));h.push(d);const f=Mo({inputs:{x:r},backend:n,attrs:{dtype:"float32"}});h.push(f);const p=yv({inputs:{a:f,b:d},backend:n});h.push(p);const g=Nh({inputs:{x:p},backend:n,attrs:{axis:o,keepDims:i}});return h.forEach(x=>n.disposeIntermediateTensorInfo(x)),g}const WX={kernelName:Gp,backendName:"cpu",kernelFunc:VX};/** + */function BX(t){const{inputs:e,backend:n,attrs:s}=t,{x:r}=e,{axis:o,keepDims:i}=s,a=Re(o,r.shape),c=Yt(r.shape,a)[1],u=j(c),h=[],d=n.makeTensorInfo([],"float32",new Float32Array([u]));h.push(d);const f=Mo({inputs:{x:r},backend:n,attrs:{dtype:"float32"}});h.push(f);const p=yv({inputs:{a:f,b:d},backend:n});h.push(p);const g=$h({inputs:{x:p},backend:n,attrs:{axis:o,keepDims:i}});return h.forEach(x=>n.disposeIntermediateTensorInfo(x)),g}const VX={kernelName:Gp,backendName:"cpu",kernelFunc:BX};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -10352,7 +10352,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function UX(t){const{inputs:e,backend:n,attrs:s}=t,{x:r}=e,{axis:o,keepDims:i}=s;de(r,"min");const a=Re(o,r.shape);let l=a;const c=yt(l,r.shape.length);let u=r;c!=null&&(u=Fn({inputs:{x:r},backend:n,attrs:{perm:c}}),l=$t(l.length,r.shape.length)),sn("min",l,u.shape.length);const[h,d]=Yt(u.shape,l),f=j(d),p=un(j(h),u.dtype),g=n.data.get(u.dataId).values;for(let m=0;mw[0]+r.shape[v]+w[1]),l=o.map(w=>w[0]),c=o.map((w,v)=>w[0]+r.shape[v]),u=i==="reflect"?0:1,h=n.data.get(r.dataId).values,d=r.shape.length,f=pe(r.shape),p=j(a),g=a.length,x=pe(a),m=cn(r.dtype,p);for(let w=0;w=c[C]&&(v[C]=(c[C]-1)*2-v[C]+u);v=v.map((C,k)=>C-l[k]);const b=xr(v,d,f);m[w]=h[b]}return{dataId:n.write(m,a,r.dtype),shape:a,dtype:r.dtype}}const jX={kernelName:jp,backendName:"cpu",kernelFunc:HX};/** + */function GX(t){const{inputs:e,backend:n,attrs:s}=t,{x:r}=e,{paddings:o,mode:i}=s;de(r,"mirrorPad");const a=o.map((w,v)=>w[0]+r.shape[v]+w[1]),l=o.map(w=>w[0]),c=o.map((w,v)=>w[0]+r.shape[v]),u=i==="reflect"?0:1,h=n.data.get(r.dataId).values,d=r.shape.length,f=pe(r.shape),p=j(a),g=a.length,x=pe(a),m=cn(r.dtype,p);for(let w=0;w=c[C]&&(v[C]=(c[C]-1)*2-v[C]+u);v=v.map((C,k)=>C-l[k]);const b=xr(v,d,f);m[w]=h[b]}return{dataId:n.write(m,a,r.dtype),shape:a,dtype:r.dtype}}const HX={kernelName:jp,backendName:"cpu",kernelFunc:GX};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -10382,7 +10382,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const KX=Tt((t,e)=>{const n=t%e;return t<0&&e<0||t>=0&&e>=0?n:(n+e)%e}),XX=Wt(Wu,KX),qX={kernelName:Wu,backendName:"cpu",kernelFunc:XX};/** + */const jX=Tt((t,e)=>{const n=t%e;return t<0&&e<0||t>=0&&e>=0?n:(n+e)%e}),KX=Wt(Vu,jX),XX={kernelName:Vu,backendName:"cpu",kernelFunc:KX};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -10397,7 +10397,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function MA(t){const{inputs:e,backend:n,attrs:s}=t,{logits:r}=e,{dim:o}=s,i=r.shape.length;let a=o;if(a===-1&&(a=i-1),a!==i-1)throw Error(`Softmax along a non-last dimension is not yet supported. Logits was rank ${i} and dim was ${a}`);const l=Re([a],r.shape),c=OA({inputs:{x:r},backend:n,attrs:{reductionIndices:l,keepDims:!1}}),u=Dt(c.shape,l),h=st({inputs:{x:c},backend:n,attrs:{shape:u}}),d=gv({inputs:{a:r,b:h},backend:n}),f=VR({inputs:{x:d},backend:n}),p=Nh({inputs:{x:f},backend:n,attrs:{axis:l,keepDims:!1}}),g=st({inputs:{x:p},backend:n,attrs:{shape:u}}),x=yv({inputs:{a:f,b:g},backend:n});return n.disposeIntermediateTensorInfo(c),n.disposeIntermediateTensorInfo(h),n.disposeIntermediateTensorInfo(d),n.disposeIntermediateTensorInfo(f),n.disposeIntermediateTensorInfo(p),n.disposeIntermediateTensorInfo(g),x}const YX={kernelName:um,backendName:"cpu",kernelFunc:MA};/** + */function MA(t){const{inputs:e,backend:n,attrs:s}=t,{logits:r}=e,{dim:o}=s,i=r.shape.length;let a=o;if(a===-1&&(a=i-1),a!==i-1)throw Error(`Softmax along a non-last dimension is not yet supported. Logits was rank ${i} and dim was ${a}`);const l=Re([a],r.shape),c=OA({inputs:{x:r},backend:n,attrs:{reductionIndices:l,keepDims:!1}}),u=Dt(c.shape,l),h=st({inputs:{x:c},backend:n,attrs:{shape:u}}),d=gv({inputs:{a:r,b:h},backend:n}),f=VR({inputs:{x:d},backend:n}),p=$h({inputs:{x:f},backend:n,attrs:{axis:l,keepDims:!1}}),g=st({inputs:{x:p},backend:n,attrs:{shape:u}}),x=yv({inputs:{a:f,b:g},backend:n});return n.disposeIntermediateTensorInfo(c),n.disposeIntermediateTensorInfo(h),n.disposeIntermediateTensorInfo(d),n.disposeIntermediateTensorInfo(f),n.disposeIntermediateTensorInfo(p),n.disposeIntermediateTensorInfo(g),x}const qX={kernelName:um,backendName:"cpu",kernelFunc:MA};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -10412,7 +10412,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function QX(t){const{inputs:e,backend:n,attrs:s}=t,{logits:r}=e,{numSamples:o,seed:i,normalized:a}=s;de(r,"multinomial");const l=a?r:MA({inputs:{logits:r},backend:n,attrs:{dim:-1}}),c=l.shape[0],u=l.shape[1],h=n.data.get(l.dataId).values,d=[c,o],f=un(j(d),"int32");for(let p=0;p=0&&h[d]=0&&h[d]{Lx(o,u.shape,"All tensors passed to stack must have matching shapes"),I(i===u.dtype,()=>"All tensors passed to stack must have matching dtypes")});const a=[],l=e.map(u=>{const h=Mf({inputs:{input:u},backend:n,attrs:{dim:r}});return a.push(h),h}),c=hl({inputs:l,backend:n,attrs:{axis:r}});return a.forEach(u=>n.disposeIntermediateTensorInfo(u)),c}const dq={kernelName:Qp,backendName:"cpu",kernelFunc:LA};/** + */function LA(t){const{inputs:e,backend:n,attrs:s}=t,{axis:r}=s;if(e.length===1)return Of({inputs:{input:e[0]},backend:n,attrs:{dim:r}});const o=e[0].shape,i=e[0].dtype;e.forEach(u=>{Lx(o,u.shape,"All tensors passed to stack must have matching shapes"),I(i===u.dtype,()=>"All tensors passed to stack must have matching dtypes")});const a=[],l=e.map(u=>{const h=Of({inputs:{input:u},backend:n,attrs:{dim:r}});return a.push(h),h}),c=hl({inputs:l,backend:n,attrs:{axis:r}});return a.forEach(u=>n.disposeIntermediateTensorInfo(u)),c}const hq={kernelName:Qp,backendName:"cpu",kernelFunc:LA};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -10532,7 +10532,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function fq(t){const{inputs:e,backend:n,attrs:s}=t,{x:r}=e,{paddings:o,constantValue:i}=s;de(r,"pad");const a=o.map((y,w)=>y[0]+r.shape[w]+y[1]),l=o.map(y=>y[0]),c=n.data.get(r.dataId).values,u=j(r.shape),h=r.shape.length,d=pe(r.shape),f=j(a),p=a.length,g=pe(a),x=cn(r.dtype,f);i!==0&&x.fill(i);for(let y=0;yC+l[k]),b=xr(v,p,g);x[b]=c[y]}return{dataId:n.write(x,a,r.dtype),shape:a,dtype:r.dtype}}const BA={kernelName:Zp,backendName:"cpu",kernelFunc:fq};/** + */function dq(t){const{inputs:e,backend:n,attrs:s}=t,{x:r}=e,{paddings:o,constantValue:i}=s;de(r,"pad");const a=o.map((y,w)=>y[0]+r.shape[w]+y[1]),l=o.map(y=>y[0]),c=n.data.get(r.dataId).values,u=j(r.shape),h=r.shape.length,d=pe(r.shape),f=j(a),p=a.length,g=pe(a),x=cn(r.dtype,f);i!==0&&x.fill(i);for(let y=0;yC+l[k]),b=xr(v,p,g);x[b]=c[y]}return{dataId:n.write(x,a,r.dtype),shape:a,dtype:r.dtype}}const BA={kernelName:Zp,backendName:"cpu",kernelFunc:dq};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -10547,7 +10547,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const pq=Tt((t,e)=>Math.pow(t,e)),mq=Wt(Gu,pq),gq={kernelName:Gu,backendName:"cpu",kernelFunc:mq};/** + */const fq=Tt((t,e)=>Math.pow(t,e)),pq=Wt(Uu,fq),mq={kernelName:Uu,backendName:"cpu",kernelFunc:pq};/** * @license * Copyright 2022 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -10562,7 +10562,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function xq(t){const{inputs:e,backend:n,attrs:s}=t,{paramsNestedSplits:r,paramsDenseValues:o,indices:i}=e,a=r.map(x=>n.data.get(x.dataId).values),l=r.map(x=>x.shape),c=n.data.get(o.dataId).values,u=n.data.get(i.dataId).values,[h,d,f]=oA(a,l,c,o.shape,o.dtype,u,i.shape),p=h.map(x=>n.makeTensorInfo([x.length],"int32",x)),g=n.makeTensorInfo(f,o.dtype,d);return p.concat([g])}const yq={kernelName:o$,backendName:"cpu",kernelFunc:xq};/** + */function gq(t){const{inputs:e,backend:n,attrs:s}=t,{paramsNestedSplits:r,paramsDenseValues:o,indices:i}=e,a=r.map(x=>n.data.get(x.dataId).values),l=r.map(x=>x.shape),c=n.data.get(o.dataId).values,u=n.data.get(i.dataId).values,[h,d,f]=oA(a,l,c,o.shape,o.dtype,u,i.shape),p=h.map(x=>n.makeTensorInfo([x.length],"int32",x)),g=n.makeTensorInfo(f,o.dtype,d);return p.concat([g])}const xq={kernelName:o$,backendName:"cpu",kernelFunc:gq};/** * @license * Copyright 2022 Google LLC. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -10577,7 +10577,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function wq(t){const{inputs:e,backend:n}=t,{starts:s,limits:r,deltas:o}=e,i=n.data.get(s.dataId).values,a=n.data.get(r.dataId).values,l=n.data.get(o.dataId).values,[c,u]=iA(i,s.shape,s.dtype,a,r.shape,l,o.shape),h=n.makeTensorInfo([c.length],"int32",c),d=n.makeTensorInfo([u.length],s.dtype,u);return[h,d]}const vq={kernelName:i$,backendName:"cpu",kernelFunc:wq};/** + */function yq(t){const{inputs:e,backend:n}=t,{starts:s,limits:r,deltas:o}=e,i=n.data.get(s.dataId).values,a=n.data.get(r.dataId).values,l=n.data.get(o.dataId).values,[c,u]=iA(i,s.shape,s.dtype,a,r.shape,l,o.shape),h=n.makeTensorInfo([c.length],"int32",c),d=n.makeTensorInfo([u.length],s.dtype,u);return[h,d]}const wq={kernelName:i$,backendName:"cpu",kernelFunc:yq};/** * @license * Copyright 2022 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -10592,7 +10592,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function bq(t){const{inputs:e,backend:n,attrs:s}=t,{shape:r,values:o,defaultValue:i,rowPartitionTensors:a}=e,{rowPartitionTypes:l}=s,c=n.data.get(r.dataId).values,u=n.data.get(o.dataId).values,h=n.data.get(i.dataId).values,d=a.map(x=>n.data.get(x.dataId).values),f=a.map(x=>x.shape),[p,g]=aA(c,r.shape,u,o.shape,o.dtype,h,i.shape,d,f,l);return n.makeTensorInfo(p,o.dtype,g)}const Cq={kernelName:a$,backendName:"cpu",kernelFunc:bq};/** + */function vq(t){const{inputs:e,backend:n,attrs:s}=t,{shape:r,values:o,defaultValue:i,rowPartitionTensors:a}=e,{rowPartitionTypes:l}=s,c=n.data.get(r.dataId).values,u=n.data.get(o.dataId).values,h=n.data.get(i.dataId).values,d=a.map(x=>n.data.get(x.dataId).values),f=a.map(x=>x.shape),[p,g]=aA(c,r.shape,u,o.shape,o.dtype,h,i.shape,d,f,l);return n.makeTensorInfo(p,o.dtype,g)}const bq={kernelName:a$,backendName:"cpu",kernelFunc:vq};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -10607,7 +10607,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function kq(t){const{backend:e,attrs:n}=t,{start:s,stop:r,dtype:o,step:i}=n,a=lA(s,r,i,o);return e.makeTensorInfo([a.length],o,a)}const Sq={kernelName:vy,backendName:"cpu",kernelFunc:kq};/** + */function Cq(t){const{backend:e,attrs:n}=t,{start:s,stop:r,dtype:o,step:i}=n,a=lA(s,r,i,o);return e.makeTensorInfo([a.length],o,a)}const kq={kernelName:vy,backendName:"cpu",kernelFunc:Cq};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the License); @@ -10622,7 +10622,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const Iq=Xe(Hu,t=>1/t),$q={kernelName:Hu,backendName:"cpu",kernelFunc:Iq};/** + */const Sq=Xe(Gu,t=>1/t),Iq={kernelName:Gu,backendName:"cpu",kernelFunc:Sq};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -10637,7 +10637,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function Nq(t){const{inputs:e,backend:n,attrs:s}=t,{images:r}=e,{alignCorners:o,halfPixelCenters:i,size:a}=s;de(r,"resizeBilinear");const l=pe(r.shape),[c,u]=a,[h,d,f,p]=r.shape,g=n.data.get(r.dataId).values,x=new Float32Array(j([h,c,u,p])),m=[o&&c>1?d-1:d,o&&u>1?f-1:f],y=[o&&c>1?c-1:c,o&&u>1?u-1:u];let w=0;const v=m[0]/y[0],b=m[1]/y[1];for(let C=0;C1?d-1:d,o&&u>1?f-1:f],y=[o&&c>1?c-1:c,o&&u>1?u-1:u];let w=0;const v=m[0]/y[0],b=m[1]/y[1];for(let C=0;C1?c-1:c,i&&f>1?u-1:u],x=[i&&d>1?d-1:d,i&&f>1?f-1:f],m=g[0]/x[0],y=g[1]/x[1],w=n.data.get(o.dataId).values;let v=0;for(let b=0;b1?c-1:c,i&&f>1?u-1:u],x=[i&&d>1?d-1:d,i&&f>1?f-1:f],m=g[0]/x[0],y=g[1]/x[1],w=n.data.get(o.dataId).values;let v=0;for(let b=0;b1?d-1:d,o&&u>1?f-1:f],y=[o&&c>1?c-1:c,o&&u>1?u-1:u],w=m[0]/y[0],v=m[1]/y[1];let b=0;for(let C=0;C1?d-1:d,o&&u>1?f-1:f],y=[o&&c>1?c-1:c,o&&u>1?u-1:u],w=m[0]/y[0],v=m[1]/y[1];let b=0;for(let C=0;C1?u-1:u,i&&p>1?h-1:h],y=[i&&f>1?f-1:f,i&&p>1?p-1:p],w=m[0]/y[0],v=m[1]/y[1],b=1/w,C=1/v,k=Math.ceil(b)*2+2,S=Math.ceil(C)*2+2;for(let $=0;$=f)continue;const Q=N+q*l[1],te=q*w,Z=Math.min(u-1,i?Math.round(te):Math.floor(te));if(A===Z)for(let se=0;se=p)continue;const ce=Q+ie*l[2],ue=ie*v,xe=Math.min(h-1,i?Math.round(ue):Math.floor(ue));B===xe&&(G+=x[ce+O])}}g[U+O]=G}}}}return n.makeTensorInfo(r.shape,r.dtype,g)}const Fq={kernelName:Cy,backendName:"cpu",kernelFunc:_q};/** + */function Dq(t){const{inputs:e,backend:n,attrs:s}=t,{images:r,dy:o}=e,{alignCorners:i}=s;de([o,r],"resizeNearestNeighborGrad");const a=pe(r.shape),l=pe(o.shape),[c,u,h,d]=r.shape,[,f,p]=o.shape,g=new Float32Array(c*u*h*d),x=n.data.get(o.dataId).values,m=[i&&f>1?u-1:u,i&&p>1?h-1:h],y=[i&&f>1?f-1:f,i&&p>1?p-1:p],w=m[0]/y[0],v=m[1]/y[1],b=1/w,C=1/v,k=Math.ceil(b)*2+2,S=Math.ceil(C)*2+2;for(let $=0;$=f)continue;const Q=N+q*l[1],te=q*w,Z=Math.min(u-1,i?Math.round(te):Math.floor(te));if(A===Z)for(let se=0;se=p)continue;const ce=Q+ie*l[2],ue=ie*v,xe=Math.min(h-1,i?Math.round(ue):Math.floor(ue));B===xe&&(G+=x[ce+O])}}g[U+O]=G}}}}return n.makeTensorInfo(r.shape,r.dtype,g)}const _q={kernelName:Cy,backendName:"cpu",kernelFunc:Dq};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -10697,7 +10697,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function zq(t){const{inputs:e,backend:n,attrs:s}=t,{x:r}=e,{dims:o}=s;de(r,"reverse");const i=r.shape.length,a=Re(o,r.shape);if(i===0)return Nr({inputs:{x:r},backend:n});const l=new tn(r.shape,r.dtype),c=n.bufferSync(r);for(let u=0;ud[f]=r.shape[f]-1-d[f]),l.set(c.get(...d),...h)}return n.makeTensorInfo(l.shape,l.dtype,l.values)}const Oq={kernelName:rm,backendName:"cpu",kernelFunc:zq};/** + */function Fq(t){const{inputs:e,backend:n,attrs:s}=t,{x:r}=e,{dims:o}=s;de(r,"reverse");const i=r.shape.length,a=Re(o,r.shape);if(i===0)return Nr({inputs:{x:r},backend:n});const l=new tn(r.shape,r.dtype),c=n.bufferSync(r);for(let u=0;ud[f]=r.shape[f]-1-d[f]),l.set(c.get(...d),...h)}return n.makeTensorInfo(l.shape,l.dtype,l.values)}const zq={kernelName:rm,backendName:"cpu",kernelFunc:Fq};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -10712,7 +10712,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const Mq={kernelName:Ry,backendName:"cpu",kernelFunc:({inputs:t,attrs:e,backend:n})=>{const{image:s}=t,{radians:r,fillValue:o,center:i}=e,a=n,l=cn(s.dtype,j(s.shape)),[c,u,h,d]=s.shape,[f,p]=$w(i,u,h),g=255,x=Math.sin(r),m=Math.cos(r),y=a.data.get(s.dataId).values;for(let v=0;v=0&&V=0&&B{const{image:s}=t,{radians:r,fillValue:o,center:i}=e,a=n,l=cn(s.dtype,j(s.shape)),[c,u,h,d]=s.shape,[f,p]=$w(i,u,h),g=255,x=Math.sin(r),m=Math.cos(r),y=a.data.get(s.dataId).values;for(let v=0;v=0&&V=0&&B{const e=Math.floor(t);return t-e<.5?Math.floor(t):t-e>.5?Math.ceil(t):e%2===0?e:e+1}),Lq={kernelName:Xu,backendName:"cpu",kernelFunc:Pq};/** + */const Mq=Xe(Ku,t=>{const e=Math.floor(t);return t-e<.5?Math.floor(t):t-e>.5?Math.ceil(t):e%2===0?e:e+1}),Pq={kernelName:Ku,backendName:"cpu",kernelFunc:Mq};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -10742,7 +10742,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function Bq(t){const{inputs:e,backend:n,attrs:s}=t,{indices:r,updates:o}=e,{shape:i}=s,{sliceRank:a,numUpdates:l,sliceSize:c,strides:u,outputSize:h}=Qi(o,r,i),d=!0,f=n.bufferSync(r),p=n.bufferSync(o),g=pi(f,p,i,h,c,l,a,u,0,d);return n.makeTensorInfo(i,g.dtype,g.values)}const Vq={kernelName:l$,backendName:"cpu",kernelFunc:Bq};/** + */function Lq(t){const{inputs:e,backend:n,attrs:s}=t,{indices:r,updates:o}=e,{shape:i}=s,{sliceRank:a,numUpdates:l,sliceSize:c,strides:u,outputSize:h}=Qi(o,r,i),d=!0,f=n.bufferSync(r),p=n.bufferSync(o),g=pi(f,p,i,h,c,l,a,u,0,d);return n.makeTensorInfo(i,g.dtype,g.values)}const Bq={kernelName:l$,backendName:"cpu",kernelFunc:Lq};/** * @license * Copyright 2022 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -10757,7 +10757,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function Wq(t,e){let n=0,s=t.length,r=0;for(;n1||r.shape.length===1?1:j(r.shape.slice(1));for(let p=0;p1||r.shape.length===1?1:j(r.shape.slice(1));for(let p=0;pt>=0?Yq*t:qq*(Math.exp(t)-1)),Zq={kernelName:Yu,backendName:"cpu",kernelFunc:Qq};/** + */const Xq=km,qq=Sm,Yq=Xe(qu,t=>t>=0?qq*t:Xq*(Math.exp(t)-1)),Qq={kernelName:qu,backendName:"cpu",kernelFunc:Yq};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the License); @@ -10817,7 +10817,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const Jq=Xe(Ju,t=>t<0?-1:t>0?1:0),e7={kernelName:Ju,backendName:"cpu",kernelFunc:Jq};/** + */const Zq=Xe(Zu,t=>t<0?-1:t>0?1:0),Jq={kernelName:Zu,backendName:"cpu",kernelFunc:Zq};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the License); @@ -10832,7 +10832,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const t7=Xe(Qu,t=>Math.sin(t)),n7={kernelName:Qu,backendName:"cpu",kernelFunc:t7};/** + */const e7=Xe(Yu,t=>Math.sin(t)),t7={kernelName:Yu,backendName:"cpu",kernelFunc:e7};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the License); @@ -10847,7 +10847,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const s7=Xe(Zu,t=>Math.sinh(t)),r7={kernelName:Zu,backendName:"cpu",kernelFunc:s7};/** + */const n7=Xe(Qu,t=>Math.sinh(t)),s7={kernelName:Qu,backendName:"cpu",kernelFunc:n7};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the License); @@ -10862,7 +10862,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const o7=11920928955078125e-23,vk=Math.log(o7)+2,i7=Xe(th,t=>{const e=t>-vk,n=t{const e=t>-vk,n=tNumber(x)))),n.makeTensorInfo([g.length],s.dtype,new Int32Array(g))]}const h7={kernelName:h$,backendName:"cpu",kernelFunc:u7};/** + ${i.shape}`);const a=n.data.get(s.dataId).values,l=n.data.get(r.dataId).values,c=n.data.get(o.dataId).values,u=n.data.get(i.dataId).values[0],[h,d,f,p,g]=dA(a,s.shape,s.dtype,l,r.dtype,c,u);return[n.makeTensorInfo(d,s.dtype,h),n.makeTensorInfo([d[0]],r.dtype,f),n.makeTensorInfo([p.length],"bool",new Uint8Array(p.map(x=>Number(x)))),n.makeTensorInfo([g.length],s.dtype,new Int32Array(g))]}const u7={kernelName:h$,backendName:"cpu",kernelFunc:c7};/** * @license * Copyright 2021 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -10911,9 +10911,9 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function d7(t){const{inputs:e,backend:n}=t,{inputIndices:s,inputShape:r,newShape:o}=e;if(s.shape.length!==2)throw new Error(`Input indices should be a matrix but received shape + */function h7(t){const{inputs:e,backend:n}=t,{inputIndices:s,inputShape:r,newShape:o}=e;if(s.shape.length!==2)throw new Error(`Input indices should be a matrix but received shape ${s.shape}`);if(r.shape.length!==1)throw new Error(`Input shape should be a vector but received shape - ${r.shape}`);if(o.shape.length!==1)throw new Error(`Target shape should be a vector but received shape ${o.shape}`);const i=Array.from(n.data.get(r.dataId).values),a=n.data.get(s.dataId).values,l=Array.from(n.data.get(o.dataId).values),[c,u,h]=fA(a,s.shape,s.dtype,i,l);return[n.makeTensorInfo(u,s.dtype,c),n.makeTensorInfo([h.length],o.dtype,new Int32Array(h))]}const f7={kernelName:d$,backendName:"cpu",kernelFunc:d7};/** + ${r.shape}`);if(o.shape.length!==1)throw new Error(`Target shape should be a vector but received shape ${o.shape}`);const i=Array.from(n.data.get(r.dataId).values),a=n.data.get(s.dataId).values,l=Array.from(n.data.get(o.dataId).values),[c,u,h]=fA(a,s.shape,s.dtype,i,l);return[n.makeTensorInfo(u,s.dtype,c),n.makeTensorInfo([h.length],o.dtype,new Int32Array(h))]}const d7={kernelName:d$,backendName:"cpu",kernelFunc:h7};/** * @license * Copyright 2021 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -10928,9 +10928,9 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function p7(t){const{inputs:e,backend:n}=t,{data:s,indices:r,segmentIds:o}=e;if(s.shape.length<1)throw new Error("Data should be at least 1 dimensional but received scalar");if(r.shape.length!==1)throw new Error(`Indices should be a vector but received shape + */function f7(t){const{inputs:e,backend:n}=t,{data:s,indices:r,segmentIds:o}=e;if(s.shape.length<1)throw new Error("Data should be at least 1 dimensional but received scalar");if(r.shape.length!==1)throw new Error(`Indices should be a vector but received shape ${r.shape}`);if(o.shape.length!==1)throw new Error(`Segment ids should be a vector but received shape - ${o.shape}`);if(r.shape[0]!==o.shape[0])throw new Error("segmentIds and indices should have same size.");const i=n.data.get(s.dataId).values,a=n.data.get(r.dataId).values,l=n.data.get(o.dataId).values,[c,u]=mv(i,s.shape,s.dtype,a,l,!0);return n.makeTensorInfo(u,s.dtype,c)}const m7={kernelName:f$,backendName:"cpu",kernelFunc:p7};/** + ${o.shape}`);if(r.shape[0]!==o.shape[0])throw new Error("segmentIds and indices should have same size.");const i=n.data.get(s.dataId).values,a=n.data.get(r.dataId).values,l=n.data.get(o.dataId).values,[c,u]=mv(i,s.shape,s.dtype,a,l,!0);return n.makeTensorInfo(u,s.dtype,c)}const p7={kernelName:f$,backendName:"cpu",kernelFunc:f7};/** * @license * Copyright 2021 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -10945,9 +10945,9 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function g7(t){const{inputs:e,backend:n}=t,{data:s,indices:r,segmentIds:o}=e;if(s.shape.length<1)throw new Error("Data should be at least 1 dimensional but received scalar");if(r.shape.length!==1)throw new Error(`Indices should be a vector but received shape + */function m7(t){const{inputs:e,backend:n}=t,{data:s,indices:r,segmentIds:o}=e;if(s.shape.length<1)throw new Error("Data should be at least 1 dimensional but received scalar");if(r.shape.length!==1)throw new Error(`Indices should be a vector but received shape ${r.shape}`);if(o.shape.length!==1)throw new Error(`Segment ids should be a vector but received shape - ${o.shape}`);if(r.shape[0]!==o.shape[0])throw new Error("segmentIds and indices should have same size.");const i=n.data.get(s.dataId).values,a=n.data.get(r.dataId).values,l=n.data.get(o.dataId).values,[c,u]=mv(i,s.shape,s.dtype,a,l);return n.makeTensorInfo(u,s.dtype,c)}const x7={kernelName:p$,backendName:"cpu",kernelFunc:g7};/** + ${o.shape}`);if(r.shape[0]!==o.shape[0])throw new Error("segmentIds and indices should have same size.");const i=n.data.get(s.dataId).values,a=n.data.get(r.dataId).values,l=n.data.get(o.dataId).values,[c,u]=mv(i,s.shape,s.dtype,a,l);return n.makeTensorInfo(u,s.dtype,c)}const g7={kernelName:p$,backendName:"cpu",kernelFunc:m7};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -10962,7 +10962,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function y7(t){const{inputs:e,backend:n,attrs:s}=t,{sparseIndices:r,sparseValues:o,defaultValue:i}=e,{outputShape:a}=s,{sliceRank:l,numUpdates:c,sliceSize:u,strides:h,outputSize:d}=Qi(o,r,a),f=!1,p=n.bufferSync(r);let g;switch(o.dtype){case"bool":{const x=n.bufferSync(o),m=!!n.data.get(i.dataId).values[0];g=pi(p,x,a,d,u,c,l,h,m,f);break}case"float32":{const x=n.bufferSync(o),m=n.data.get(i.dataId).values[0];g=pi(p,x,a,d,u,c,l,h,m,f);break}case"int32":{const x=n.bufferSync(o),m=n.data.get(i.dataId).values[0];g=pi(p,x,a,d,u,c,l,h,m,f);break}case"string":{const x=n.bufferSync(o),m=Do(n.data.get(i.dataId).values[0]);g=pi(p,x,a,d,u,c,l,h,m,f);break}default:throw new Error(`Unsupported type ${o.dtype}`)}return n.makeTensorInfo(a,g.dtype,g.values)}const w7={kernelName:m$,backendName:"cpu",kernelFunc:y7};/** + */function x7(t){const{inputs:e,backend:n,attrs:s}=t,{sparseIndices:r,sparseValues:o,defaultValue:i}=e,{outputShape:a}=s,{sliceRank:l,numUpdates:c,sliceSize:u,strides:h,outputSize:d}=Qi(o,r,a),f=!1,p=n.bufferSync(r);let g;switch(o.dtype){case"bool":{const x=n.bufferSync(o),m=!!n.data.get(i.dataId).values[0];g=pi(p,x,a,d,u,c,l,h,m,f);break}case"float32":{const x=n.bufferSync(o),m=n.data.get(i.dataId).values[0];g=pi(p,x,a,d,u,c,l,h,m,f);break}case"int32":{const x=n.bufferSync(o),m=n.data.get(i.dataId).values[0];g=pi(p,x,a,d,u,c,l,h,m,f);break}case"string":{const x=n.bufferSync(o),m=Do(n.data.get(i.dataId).values[0]);g=pi(p,x,a,d,u,c,l,h,m,f);break}default:throw new Error(`Unsupported type ${o.dtype}`)}return n.makeTensorInfo(a,g.dtype,g.values)}const y7={kernelName:m$,backendName:"cpu",kernelFunc:x7};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -10977,7 +10977,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function v7(t){const{inputs:e,backend:n,attrs:s}=t,{x:r}=e,{numOrSizeSplits:o,axis:i}=s,a=Re(i,r.shape)[0],l=Vw(r,o,a),c=new Array(r.shape.length).fill(0),u=r.shape.slice();return l.map(h=>{const d=[...u];d[a]=h;const f=Vi({inputs:{x:r},backend:n,attrs:{begin:c,size:d}});return c[a]+=h,f})}const b7={kernelName:cm,backendName:"cpu",kernelFunc:v7};/** + */function w7(t){const{inputs:e,backend:n,attrs:s}=t,{x:r}=e,{numOrSizeSplits:o,axis:i}=s,a=Re(i,r.shape)[0],l=Vw(r,o,a),c=new Array(r.shape.length).fill(0),u=r.shape.slice();return l.map(h=>{const d=[...u];d[a]=h;const f=Vi({inputs:{x:r},backend:n,attrs:{begin:c,size:d}});return c[a]+=h,f})}const v7={kernelName:cm,backendName:"cpu",kernelFunc:w7};/** * @license * Copyright 2019 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -10992,7 +10992,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const C7={kernelName:Sy,backendName:"cpu",kernelFunc:({inputs:t,backend:e})=>{const{x:n}=t,s=e;de(n,"square");const r=s.data.get(n.dataId).values,o=new Float32Array(r.length);for(let a=0;a{const{x:n}=t,s=e;de(n,"square");const r=s.data.get(n.dataId).values,o=new Float32Array(r.length);for(let a=0;a{const n=e;return isNaN(t)?NaN:t>0?1:n.alpha}),S7={kernelName:lh,backendName:"cpu",kernelFunc:k7};/** + */const C7=Xe(ah,(t,e)=>{const n=e;return isNaN(t)?NaN:t>0?1:n.alpha}),k7={kernelName:ah,backendName:"cpu",kernelFunc:C7};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -11022,7 +11022,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function I7(t){const{inputs:e,backend:n,attrs:s}=t,{x:r}=e,{begin:o,end:i,strides:a,beginMask:l,endMask:c,ellipsisMask:u,newAxisMask:h,shrinkAxisMask:d}=s;de(r,"stridedSlice");const{finalShapeSparse:f,finalShape:p,isIdentity:g,sliceDim0:x,isSimpleSlice:m,begin:y,end:w,strides:v}=kw(r.shape,o,i,a,l,c,u,h,d);let b;if(g)b=st({inputs:{x:r},backend:n,attrs:{shape:p}});else if(x||m){I(r.shape.length>=1,()=>`Input must have rank at least 1, got: ${r.shape.length}`);const C=vw(y,w,v),k=Vi({inputs:{x:r},backend:n,attrs:{begin:y,size:C}});b=st({inputs:{x:k},backend:n,attrs:{shape:p}}),n.disposeIntermediateTensorInfo(k)}else{const C=n.bufferSync(r),k=gA(f,C,v,y);b=n.makeTensorInfo(p,k.dtype,k.values)}return b}const $7={kernelName:$y,backendName:"cpu",kernelFunc:I7};/** + */function S7(t){const{inputs:e,backend:n,attrs:s}=t,{x:r}=e,{begin:o,end:i,strides:a,beginMask:l,endMask:c,ellipsisMask:u,newAxisMask:h,shrinkAxisMask:d}=s;de(r,"stridedSlice");const{finalShapeSparse:f,finalShape:p,isIdentity:g,sliceDim0:x,isSimpleSlice:m,begin:y,end:w,strides:v}=kw(r.shape,o,i,a,l,c,u,h,d);let b;if(g)b=st({inputs:{x:r},backend:n,attrs:{shape:p}});else if(x||m){I(r.shape.length>=1,()=>`Input must have rank at least 1, got: ${r.shape.length}`);const C=vw(y,w,v),k=Vi({inputs:{x:r},backend:n,attrs:{begin:y,size:C}});b=st({inputs:{x:k},backend:n,attrs:{shape:p}}),n.disposeIntermediateTensorInfo(k)}else{const C=n.bufferSync(r),k=gA(f,C,v,y);b=n.makeTensorInfo(p,k.dtype,k.values)}return b}const I7={kernelName:$y,backendName:"cpu",kernelFunc:S7};/** * @license * Copyright 2021 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -11037,7 +11037,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function N7(t){const{inputs:e,backend:n,attrs:s}=t,{separator:r,nGramWidths:o,leftPad:i,rightPad:a,padWidth:l,preserveShortSequences:c}=s,{data:u,dataSplits:h}=e,d=n.data.get(u.dataId).values,f=n.data.get(h.dataId).values,[p,g]=xA(d,f,r,o,i,a,l,c);return[n.makeTensorInfo([p.length],"string",p),n.makeTensorInfo(h.shape,"int32",g)]}const T7={kernelName:g$,backendName:"cpu",kernelFunc:N7};/** + */function $7(t){const{inputs:e,backend:n,attrs:s}=t,{separator:r,nGramWidths:o,leftPad:i,rightPad:a,padWidth:l,preserveShortSequences:c}=s,{data:u,dataSplits:h}=e,d=n.data.get(u.dataId).values,f=n.data.get(h.dataId).values,[p,g]=xA(d,f,r,o,i,a,l,c);return[n.makeTensorInfo([p.length],"string",p),n.makeTensorInfo(h.shape,"int32",g)]}const N7={kernelName:g$,backendName:"cpu",kernelFunc:$7};/** * @license * Copyright 2021 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -11052,7 +11052,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function E7(t){const{inputs:e,backend:n,attrs:s}=t,{skipEmpty:r}=s,{input:o,delimiter:i}=e;if(o.dtype!=="string")throw new Error("Input must be of datatype string");if(o.shape.length!==1)throw new Error(`Input must be a vector, got shape: ${o.shape}`);if(i.shape.length!==0)throw new Error(`Delimiter must be a scalar, got shape: ${i.shape}`);const a=n.data.get(o.dataId).values,l=n.data.get(i.dataId).values[0],[c,u,h]=yA(a,l,r),d=u.length;return[n.makeTensorInfo([d,2],"int32",c),n.makeTensorInfo([d],"string",u),n.makeTensorInfo([2],"int32",new Int32Array(h))]}const R7={kernelName:x$,backendName:"cpu",kernelFunc:E7};/** + */function T7(t){const{inputs:e,backend:n,attrs:s}=t,{skipEmpty:r}=s,{input:o,delimiter:i}=e;if(o.dtype!=="string")throw new Error("Input must be of datatype string");if(o.shape.length!==1)throw new Error(`Input must be a vector, got shape: ${o.shape}`);if(i.shape.length!==0)throw new Error(`Delimiter must be a scalar, got shape: ${i.shape}`);const a=n.data.get(o.dataId).values,l=n.data.get(i.dataId).values[0],[c,u,h]=yA(a,l,r),d=u.length;return[n.makeTensorInfo([d,2],"int32",c),n.makeTensorInfo([d],"string",u),n.makeTensorInfo([2],"int32",new Int32Array(h))]}const E7={kernelName:x$,backendName:"cpu",kernelFunc:T7};/** * @license * Copyright 2021 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -11067,7 +11067,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function A7(t){const{inputs:e,backend:n,attrs:s}=t,{numBuckets:r}=s,{input:o}=e;if(o.dtype!=="string")throw new Error("Input must be of datatype string");if(r<=0)throw new Error("Number of buckets must be at least 1");const i=n.data.get(o.dataId).values,a=wA(i,r);return n.makeTensorInfo(o.shape,"int32",a)}const D7={kernelName:y$,backendName:"cpu",kernelFunc:A7};/** + */function R7(t){const{inputs:e,backend:n,attrs:s}=t,{numBuckets:r}=s,{input:o}=e;if(o.dtype!=="string")throw new Error("Input must be of datatype string");if(r<=0)throw new Error("Number of buckets must be at least 1");const i=n.data.get(o.dataId).values,a=wA(i,r);return n.makeTensorInfo(o.shape,"int32",a)}const A7={kernelName:y$,backendName:"cpu",kernelFunc:R7};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the License); @@ -11082,7 +11082,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const _7=Xe(oh,t=>Math.tan(t)),F7={kernelName:oh,backendName:"cpu",kernelFunc:_7};/** + */const D7=Xe(rh,t=>Math.tan(t)),_7={kernelName:rh,backendName:"cpu",kernelFunc:D7};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the License); @@ -11097,7 +11097,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const z7=Xe(ih,t=>Math.tanh(t)),O7={kernelName:ih,backendName:"cpu",kernelFunc:z7};/** + */const F7=Xe(oh,t=>Math.tanh(t)),z7={kernelName:oh,backendName:"cpu",kernelFunc:F7};/** * @license * Copyright 2022 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -11112,7 +11112,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function M7(t){const{inputs:e,backend:n}=t,{tensor:s,indices:r,updates:o}=e,{sliceRank:i,numUpdates:a,sliceSize:l,strides:c,outputSize:u}=Qi(o,r,s.shape),h=!1,d=n.bufferSync(r),f=n.bufferSync(o),p=n.bufferSync(s),g=pi(d,f,s.shape,u,l,a,i,c,p,h);return n.makeTensorInfo(s.shape,g.dtype,g.values)}const P7={kernelName:c$,backendName:"cpu",kernelFunc:M7};/** + */function O7(t){const{inputs:e,backend:n}=t,{tensor:s,indices:r,updates:o}=e,{sliceRank:i,numUpdates:a,sliceSize:l,strides:c,outputSize:u}=Qi(o,r,s.shape),h=!1,d=n.bufferSync(r),f=n.bufferSync(o),p=n.bufferSync(s),g=pi(d,f,s.shape,u,l,a,i,c,p,h);return n.makeTensorInfo(s.shape,g.dtype,g.values)}const M7={kernelName:c$,backendName:"cpu",kernelFunc:O7};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -11127,7 +11127,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function L7(t){const{inputs:e,backend:n,attrs:s}=t,{x:r}=e,{reps:o}=s;de(r,"tile");const i=bA(n.bufferSync(r),o);return n.makeTensorInfo(i.shape,i.dtype,i.values)}const B7={kernelName:ah,backendName:"cpu",kernelFunc:L7};/** + */function P7(t){const{inputs:e,backend:n,attrs:s}=t,{x:r}=e,{reps:o}=s;de(r,"tile");const i=bA(n.bufferSync(r),o);return n.makeTensorInfo(i.shape,i.dtype,i.values)}const L7={kernelName:ih,backendName:"cpu",kernelFunc:P7};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -11142,7 +11142,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function V7(t){const{inputs:e,backend:n,attrs:s}=t,{x:r}=e,{k:o,sorted:i}=s;de(r,"topk");const a=n.data.get(r.dataId).values,[l,c]=kA(a,r.shape,r.dtype,o,i);return[n.makeTensorInfo(l.shape,l.dtype,l.values),n.makeTensorInfo(c.shape,c.dtype,c.values)]}const W7={kernelName:Ny,backendName:"cpu",kernelFunc:V7};/** + */function B7(t){const{inputs:e,backend:n,attrs:s}=t,{x:r}=e,{k:o,sorted:i}=s;de(r,"topk");const a=n.data.get(r.dataId).values,[l,c]=kA(a,r.shape,r.dtype,o,i);return[n.makeTensorInfo(l.shape,l.dtype,l.values),n.makeTensorInfo(c.shape,c.dtype,c.values)]}const V7={kernelName:Ny,backendName:"cpu",kernelFunc:B7};/** * @license * Copyright 2021 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -11157,7 +11157,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function U7(t){const{inputs:e,attrs:n,backend:s}=t,{image:r,transforms:o}=e,{interpolation:i,fillMode:a,fillValue:l,outputShape:c}=n,[u,h,d,f]=r.shape,[p,g]=c??[h,d],x=[u,p,g,f],m=pe(r.shape),y=m[0],w=m[1],v=m[2],b=pe(x),C=b[0],k=b[1],S=b[2],$=cn(r.dtype,j(x));$.fill(l);const N=s.data.get(r.dataId).values,A=s.data.get(o.dataId).values;for(let L=0;Le-1)if(e<=1)n=0;else{const s=2*e;n-=s*Math.trunc(n/s),n>=e&&(n=s-n-1)}return Ti(0,n,e-1)}function j7(t,e){let n=t;if(n<0)if(e<=1)n=0;else{const s=e-1;n+=e*(Math.trunc(-n/s)+1)}else if(n>e-1)if(e<=1)n=0;else{const s=e-1;n-=e*Math.trunc(n/s)}return Ti(0,n,e-1)}function K7(t,e){return t}function X7(t,e){return Ti(0,t,e-1)}function lc(t,e,n,s,r,o,i,a,l,c,u){const h=i*s+a*r+l*o+c;return 0<=a&&ae-1)if(e<=1)n=0;else{const s=2*e;n-=s*Math.trunc(n/s),n>=e&&(n=s-n-1)}return Ti(0,n,e-1)}function H7(t,e){let n=t;if(n<0)if(e<=1)n=0;else{const s=e-1;n+=e*(Math.trunc(-n/s)+1)}else if(n>e-1)if(e<=1)n=0;else{const s=e-1;n-=e*Math.trunc(n/s)}return Ti(0,n,e-1)}function j7(t,e){return t}function K7(t,e){return Ti(0,t,e-1)}function lc(t,e,n,s,r,o,i,a,l,c,u){const h=i*s+a*r+l*o+c;return 0<=a&&an.disposeIntermediateTensorInfo(p)),f}const n9={kernelName:dm,backendName:"cpu",kernelFunc:t9};/** + */function e9(t){const{inputs:e,backend:n,attrs:s}=t,{x:r,segmentIds:o}=e,{numSegments:i}=s;de(r,"unsortedSegmentSum");const a=r.shape.length,l=o.shape.length,c=[],u=[],h=a-l;let d=o;for(let p=0;pn.disposeIntermediateTensorInfo(p)),f}const t9={kernelName:dm,backendName:"cpu",kernelFunc:e9};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -11217,7 +11217,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const s9=[Qj,AH,Jj,t8,MH,s8,o8,a8,c8,h8,f8,m8,x8,v8,C8,I8,N8,E8,A8,qj,_8,z8,M8,LH,L8,zH,VH,V8,DH,U8,H8,j8,X8,Y8,Z8,eK,nK,rK,iK,lK,uK,dK,pK,gK,xK,wK,bK,kK,SK,IK,$K,TK,AK,Wj,_K,WH,VK,UH,WK,HH,XK,qK,QK,KH,qH,JK,tX,sX,oX,QH,JH,_H,aX,G8,cX,hX,fX,Uj,tj,sj,mX,oj,xX,vX,CX,IX,NX,EX,RX,aj,DX,FX,OX,PX,BX,WX,GX,cj,jX,qX,ZX,hj,fj,tq,rq,aq,mj,cq,hq,dq,BA,gq,Hj,yj,yq,vq,Cq,Sq,FH,I1,$q,jj,Kj,Xj,Tq,Rq,Dq,Fq,Oq,Mq,Lq,$j,Vq,jq,Xq,Zq,Tj,e7,n7,r7,Ej,YX,a7,c7,h7,f7,m7,x7,w7,b7,Dj,C7,Fj,Oj,S7,$7,T7,R7,D7,Bj,EK,F7,O7,P7,B7,W7,G7,gj,Z7,e9,n9,uq];for(const t of s9)v$(t);/** + */const n9=[Yj,RH,Zj,e8,OH,n8,r8,i8,l8,u8,d8,p8,g8,w8,b8,S8,$8,T8,R8,Xj,D8,F8,O8,PH,P8,FH,BH,B8,AH,W8,G8,H8,K8,q8,Q8,J8,tK,sK,oK,aK,cK,hK,fK,mK,gK,yK,vK,CK,kK,SK,IK,NK,RK,Vj,DK,VH,BK,WH,VK,GH,KK,XK,YK,jH,XH,ZK,eX,nX,rX,YH,ZH,DH,iX,U8,lX,uX,dX,Wj,ej,nj,pX,rj,gX,wX,bX,SX,$X,TX,EX,ij,AX,_X,zX,MX,LX,VX,UX,lj,HX,XX,QX,uj,dj,eq,sq,iq,pj,lq,uq,hq,BA,mq,Gj,xj,xq,wq,bq,kq,_H,I1,Iq,Hj,jj,Kj,Nq,Eq,Aq,_q,zq,Oq,Pq,Ij,Bq,Hq,Kq,Qq,Nj,Jq,t7,s7,Tj,qX,i7,l7,u7,d7,p7,g7,y7,v7,Aj,b7,_j,zj,k7,I7,N7,E7,A7,Lj,TK,_7,z7,M7,L7,V7,U7,mj,Q7,J7,t9,cq];for(const t of n9)v$(t);/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -11232,7 +11232,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const ai={},rd={alpha:!1,antialias:!1,premultipliedAlpha:!1,preserveDrawingBuffer:!1,depth:!1,stencil:!1,failIfMajorPerformanceCaveat:!0};function r9(t,e){ai[t]=e}function tr(t,e){if(!(t in ai)||e!=null){const s=i9(t,e);if(s!==null)ai[t]=s;else return console.log("Could not get context for WebGL version",t),null}const n=ai[t];return n==null||n.isContextLost()?(delete ai[t],tr(t)):(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),ai[t])}function o9(t){if(!W().getBool("IS_SAFARI")&&typeof OffscreenCanvas<"u"&&t===2)return new OffscreenCanvas(300,150);if(typeof document<"u")return document.createElement("canvas");throw new Error("Cannot create a canvas in this context")}function i9(t,e){if(t!==1&&t!==2)throw new Error("Cannot get WebGL rendering context, WebGL is disabled.");const n=e??o9(t);return n.addEventListener("webglcontextlost",s=>{s.preventDefault(),delete ai[t]},!1),W().getBool("SOFTWARE_WEBGL_ENABLED")&&(rd.failIfMajorPerformanceCaveat=!1),t===1?n.getContext("webgl",rd)||n.getContext("experimental-webgl",rd):n.getContext("webgl2",rd)}/** + */const ai={},sd={alpha:!1,antialias:!1,premultipliedAlpha:!1,preserveDrawingBuffer:!1,depth:!1,stencil:!1,failIfMajorPerformanceCaveat:!0};function s9(t,e){ai[t]=e}function tr(t,e){if(!(t in ai)||e!=null){const s=o9(t,e);if(s!==null)ai[t]=s;else return console.log("Could not get context for WebGL version",t),null}const n=ai[t];return n==null||n.isContextLost()?(delete ai[t],tr(t)):(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),ai[t])}function r9(t){if(!W().getBool("IS_SAFARI")&&typeof OffscreenCanvas<"u"&&t===2)return new OffscreenCanvas(300,150);if(typeof document<"u")return document.createElement("canvas");throw new Error("Cannot create a canvas in this context")}function o9(t,e){if(t!==1&&t!==2)throw new Error("Cannot get WebGL rendering context, WebGL is disabled.");const n=e??r9(t);return n.addEventListener("webglcontextlost",s=>{s.preventDefault(),delete ai[t]},!1),W().getBool("SOFTWARE_WEBGL_ENABLED")&&(sd.failIfMajorPerformanceCaveat=!1),t===1?n.getContext("webgl",sd)||n.getContext("experimental-webgl",sd):n.getContext("webgl2",sd)}/** * @license * Copyright 2017 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -11247,7 +11247,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */var eu;(function(t){t[t.DENSE=0]="DENSE",t[t.SHARED_BATCH=1]="SHARED_BATCH"})(eu||(eu={}));var ns;(function(t){t[t.RENDER=0]="RENDER",t[t.UPLOAD=1]="UPLOAD",t[t.PIXELS=2]="PIXELS",t[t.DOWNLOAD=3]="DOWNLOAD"})(ns||(ns={}));var Jt;(function(t){t[t.UNPACKED_FLOAT16=0]="UNPACKED_FLOAT16",t[t.UNPACKED_FLOAT32=1]="UNPACKED_FLOAT32",t[t.PACKED_4X1_UNSIGNED_BYTE=2]="PACKED_4X1_UNSIGNED_BYTE",t[t.PACKED_2X2_FLOAT32=3]="PACKED_2X2_FLOAT32",t[t.PACKED_2X2_FLOAT16=4]="PACKED_2X2_FLOAT16"})(Jt||(Jt={}));function Th(t,e){return[e,t]}function a9(t,e){return t*e}function od(t){const e=j(t),n=Math.ceil(e/4);return X0(n)}function Nl(t,e){return[Math.max(1,Math.ceil(e/2)),Math.max(1,Math.ceil(t/2))]}function l9(t,e){const[n,s]=Nl(t,e);return n*s*4}function vv(t,e){const n=t;let s,r,o,i,a,l,c,u,h,d;return W().getNumber("WEBGL_VERSION")===2?(s=n.R32F,r=n.R16F,o=n.RGBA16F,i=n.RGBA32F,a=n.RED,c=4,u=1,h=n.HALF_FLOAT,d=n.FLOAT,l=n.RGBA8):(s=t.RGBA,r=t.RGBA,o=t.RGBA,i=n.RGBA,a=t.RGBA,c=4,u=4,h=e!=null?e.HALF_FLOAT_OES:null,d=t.FLOAT,l=t.RGBA),{internalFormatFloat:s,internalFormatHalfFloat:r,internalFormatPackedHalfFloat:o,internalFormatPackedFloat:i,textureFormatFloat:a,downloadTextureFormat:l,downloadUnpackNumChannels:c,defaultNumChannels:u,textureTypeHalfFloat:h,textureTypeFloat:d}}/** + */var eu;(function(t){t[t.DENSE=0]="DENSE",t[t.SHARED_BATCH=1]="SHARED_BATCH"})(eu||(eu={}));var ns;(function(t){t[t.RENDER=0]="RENDER",t[t.UPLOAD=1]="UPLOAD",t[t.PIXELS=2]="PIXELS",t[t.DOWNLOAD=3]="DOWNLOAD"})(ns||(ns={}));var Jt;(function(t){t[t.UNPACKED_FLOAT16=0]="UNPACKED_FLOAT16",t[t.UNPACKED_FLOAT32=1]="UNPACKED_FLOAT32",t[t.PACKED_4X1_UNSIGNED_BYTE=2]="PACKED_4X1_UNSIGNED_BYTE",t[t.PACKED_2X2_FLOAT32=3]="PACKED_2X2_FLOAT32",t[t.PACKED_2X2_FLOAT16=4]="PACKED_2X2_FLOAT16"})(Jt||(Jt={}));function Nh(t,e){return[e,t]}function i9(t,e){return t*e}function rd(t){const e=j(t),n=Math.ceil(e/4);return X0(n)}function Nl(t,e){return[Math.max(1,Math.ceil(e/2)),Math.max(1,Math.ceil(t/2))]}function a9(t,e){const[n,s]=Nl(t,e);return n*s*4}function vv(t,e){const n=t;let s,r,o,i,a,l,c,u,h,d;return W().getNumber("WEBGL_VERSION")===2?(s=n.R32F,r=n.R16F,o=n.RGBA16F,i=n.RGBA32F,a=n.RED,c=4,u=1,h=n.HALF_FLOAT,d=n.FLOAT,l=n.RGBA8):(s=t.RGBA,r=t.RGBA,o=t.RGBA,i=n.RGBA,a=t.RGBA,c=4,u=4,h=e!=null?e.HALF_FLOAT_OES:null,d=t.FLOAT,l=t.RGBA),{internalFormatFloat:s,internalFormatHalfFloat:r,internalFormatPackedHalfFloat:o,internalFormatPackedFloat:i,textureFormatFloat:a,downloadTextureFormat:l,downloadUnpackNumChannels:c,defaultNumChannels:u,textureTypeHalfFloat:h,textureTypeFloat:d}}/** * @license * Copyright 2017 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -11262,11 +11262,11 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function ae(t,e){const n=e();return W().getBool("DEBUG")&&c9(t),n}function c9(t){const e=t.getError();if(e!==t.NO_ERROR)throw new Error("WebGL Error: "+f9(t,e))}const u9=596e-10,h9=65504;function d9(t){return!!(W().getBool("WEBGL_RENDER_FLOAT32_ENABLED")||t===0||u9t.getExtension(e),'Extension "'+e+'" not supported on this browser.')}function p9(t,e){const n=Zr(t,()=>t.createShader(t.VERTEX_SHADER),"Unable to create vertex WebGLShader.");if(ae(t,()=>t.shaderSource(n,e)),ae(t,()=>t.compileShader(n)),t.getShaderParameter(n,t.COMPILE_STATUS)===!1)throw console.log(t.getShaderInfoLog(n)),new Error("Failed to compile vertex shader.");return n}function m9(t,e){const n=Zr(t,()=>t.createShader(t.FRAGMENT_SHADER),"Unable to create fragment WebGLShader.");if(ae(t,()=>t.shaderSource(n,e)),ae(t,()=>t.compileShader(n)),W().get("ENGINE_COMPILE_ONLY"))return n;if(t.getShaderParameter(n,t.COMPILE_STATUS)===!1)throw VA(e,t.getShaderInfoLog(n)),new Error("Failed to compile fragment shader.");return n}const g9=/ERROR: [0-9]+:([0-9]+):/g;function VA(t,e){const n=g9.exec(e);if(n==null){console.log(`Couldn't parse line number in error: ${e}`),console.log(t);return}const s=+n[1],r=t.split(` + */function ae(t,e){const n=e();return W().getBool("DEBUG")&&l9(t),n}function l9(t){const e=t.getError();if(e!==t.NO_ERROR)throw new Error("WebGL Error: "+d9(t,e))}const c9=596e-10,u9=65504;function h9(t){return!!(W().getBool("WEBGL_RENDER_FLOAT32_ENABLED")||t===0||c9t.getExtension(e),'Extension "'+e+'" not supported on this browser.')}function f9(t,e){const n=Zr(t,()=>t.createShader(t.VERTEX_SHADER),"Unable to create vertex WebGLShader.");if(ae(t,()=>t.shaderSource(n,e)),ae(t,()=>t.compileShader(n)),t.getShaderParameter(n,t.COMPILE_STATUS)===!1)throw console.log(t.getShaderInfoLog(n)),new Error("Failed to compile vertex shader.");return n}function p9(t,e){const n=Zr(t,()=>t.createShader(t.FRAGMENT_SHADER),"Unable to create fragment WebGLShader.");if(ae(t,()=>t.shaderSource(n,e)),ae(t,()=>t.compileShader(n)),W().get("ENGINE_COMPILE_ONLY"))return n;if(t.getShaderParameter(n,t.COMPILE_STATUS)===!1)throw VA(e,t.getShaderInfoLog(n)),new Error("Failed to compile fragment shader.");return n}const m9=/ERROR: [0-9]+:([0-9]+):/g;function VA(t,e){const n=m9.exec(e);if(n==null){console.log(`Couldn't parse line number in error: ${e}`),console.log(t);return}const s=+n[1],r=t.split(` `),o=r.length.toString().length+2,i=r.map((h,d)=>Oa((d+1).toString(),o)+h);let a=0;for(let h=0;ht.createProgram(),"Unable to create WebGLProgram.")}function y9(t,e){if(ae(t,()=>t.linkProgram(e)),!W().get("ENGINE_COMPILE_ONLY")&&t.getProgramParameter(e,t.LINK_STATUS)===!1)throw console.log(t.getProgramInfoLog(e)),new Error("Failed to link vertex and fragment shaders.")}function Dg(t,e){if(ae(t,()=>t.validateProgram(e)),t.getProgramParameter(e,t.VALIDATE_STATUS)===!1)throw console.log(t.getProgramInfoLog(e)),new Error("Shader program validation failed.")}function w9(t,e){const n=Zr(t,()=>t.createBuffer(),"Unable to create WebGLBuffer");return ae(t,()=>t.bindBuffer(t.ARRAY_BUFFER,n)),ae(t,()=>t.bufferData(t.ARRAY_BUFFER,e,t.STATIC_DRAW)),n}function v9(t,e){const n=Zr(t,()=>t.createBuffer(),"Unable to create WebGLBuffer");return ae(t,()=>t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,n)),ae(t,()=>t.bufferData(t.ELEMENT_ARRAY_BUFFER,e,t.STATIC_DRAW)),n}function b9(t){return Zr(t,()=>t.createTexture(),"Unable to create WebGLTexture.")}function C9(t,e){const n=W().getNumber("WEBGL_MAX_TEXTURE_SIZE");if(t<=0||e<=0){const s=`[${t}x${e}]`;throw new Error("Requested texture size "+s+" is invalid.")}if(t>n||e>n){const s=`[${t}x${e}]`,r=`[${n}x${n}]`;throw new Error("Requested texture size "+s+" greater than WebGL maximum on this browser / GPU "+r+".")}}function k9(t){return Zr(t,()=>t.createFramebuffer(),"Unable to create WebGLFramebuffer.")}function Ck(t,e,n,s,r,o,i){const a=t.getAttribLocation(e,n);return a===-1?!1:(ae(t,()=>t.bindBuffer(t.ARRAY_BUFFER,s)),ae(t,()=>t.vertexAttribPointer(a,r,t.FLOAT,!1,o,i)),ae(t,()=>t.enableVertexAttribArray(a)),!0)}function S9(t,e,n){E9(t,n),ae(t,()=>t.activeTexture(t.TEXTURE0+n)),ae(t,()=>t.bindTexture(t.TEXTURE_2D,e))}function I9(t,e,n){return Zr(t,()=>t.getUniformLocation(e,n),'uniform "'+n+'" not present in program.')}function $9(t,e,n){return t.getUniformLocation(e,n)}function N9(t,e,n,s){ae(t,()=>S9(t,e,s)),ae(t,()=>t.uniform1i(n,s))}function _g(t,e,n){ae(t,()=>t.bindFramebuffer(t.FRAMEBUFFER,n)),ae(t,()=>t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,e,0))}function kk(t,e){ae(t,()=>t.bindFramebuffer(t.FRAMEBUFFER,e)),ae(t,()=>t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,null,0))}function ad(t){const e=t.checkFramebufferStatus(t.FRAMEBUFFER);if(e!==t.FRAMEBUFFER_COMPLETE)throw new Error("Error binding framebuffer: "+T9(t,e))}function T9(t,e){switch(e){case t.FRAMEBUFFER_INCOMPLETE_ATTACHMENT:return"FRAMEBUFFER_INCOMPLETE_ATTACHMENT";case t.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT:return"FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT";case t.FRAMEBUFFER_INCOMPLETE_DIMENSIONS:return"FRAMEBUFFER_INCOMPLETE_DIMENSIONS";case t.FRAMEBUFFER_UNSUPPORTED:return"FRAMEBUFFER_UNSUPPORTED";default:return`unknown error ${e}`}}function Zr(t,e,n){const s=ae(t,()=>e());if(s==null)throw new Error(n);return s}function E9(t,e){const n=t.MAX_COMBINED_TEXTURE_IMAGE_UNITS-1,s=e+t.TEXTURE0;if(sn){const r=`[gl.TEXTURE0, gl.TEXTURE${n}]`;throw new Error(`textureUnit must be in ${r}.`)}}function dl(t,e=2){return j(t.slice(0,t.length-e))}function fl(t){if(t.length===0)throw Error("Cannot get rows and columns of an empty shape array.");return[t.length>1?t[t.length-2]:1,t[t.length-1]]}function ld(t){let e=[1,1,1];return t.length===0||t.length===1&&t[0]===1||(e=[dl(t),...fl(t)]),e}function R9(t,e=!1){let n=W().getNumber("WEBGL_MAX_TEXTURE_SIZE"),s=W().getNumber("WEBGL_MAX_SIZE_FOR_NARROW_TEXTURE");s===1/0&&W().getBool("WEBGL_AUTO_SQUARIFY_NARROW_TEXTURE_SHAPE")&&(s=n/2),e&&(n=n*2,s=s*2,t=t.map((a,l)=>l>=t.length-2?Px(t[l]):t[l]),t.length===1&&(t=[2,t[0]])),t.length!==2&&(t=Vo(t).newShape);let r=j(t),o=null;t.length<=1&&r<=n?o=[1,r]:t.length===2&&t[0]<=n&&t[1]<=n?o=t:t.length===3&&t[0]*t[1]<=n&&t[2]<=n?o=[t[0]*t[1],t[2]]:t.length===3&&t[0]<=n&&t[1]*t[2]<=n?o=[t[0],t[1]*t[2]]:t.length===4&&t[0]*t[1]*t[2]<=n&&t[3]<=n?o=[t[0]*t[1]*t[2],t[3]]:t.length===4&&t[0]<=n&&t[1]*t[2]*t[3]<=n&&(o=[t[0],t[1]*t[2]*t[3]]);const i=o!=null&&Math.max(...o)>s&&Math.min(...o)<=(e?2:1)&&Math.min(...o)>0;if(o==null||i)if(e){const a=dl(t);let l=2,c=2;t.length&&([l,c]=fl(t)),r=a*(l/2)*(c/2),o=X0(r).map(u=>u*2)}else o=X0(r);return o}function cd(t){return t%2===0}function Lf(t,e){if(t=t.slice(-2),e=e.slice(-2),Ue(t,e)||!t.length||!e.length||t[0]===0||t[1]===0||e[0]===0||e[1]===0)return!0;if(t.length!==e.length){const n=t[t.length-1],s=e[e.length-1];if(n===s||cd(n)&&cd(s)&&(t[0]===1||e[0]===1))return!0}return t[1]===e[1]&&cd(t[0])&&cd(e[0])}let Fg,zg;function A9(t){if(Fg==null){const e=tr(t);Fg=e.getParameter(e.MAX_TEXTURE_SIZE)}return Fg}function D9(t){if(zg==null){const e=tr(t);zg=e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS)}return Math.min(16,zg)}function _9(t){if(t===0)return 0;let e;const n=tr(t);return Ss(n,"EXT_disjoint_timer_query_webgl2")&&t===2?e=2:Ss(n,"EXT_disjoint_timer_query")?e=1:e=0,e}function Ss(t,e){return t.getExtension(e)!=null}function Sk(t){try{if(tr(t)!=null)return!0}catch(e){return console.log("Error when getting WebGL context: ",e),!1}return!1}function F9(t){if(t===0)return!1;const e=tr(t);if(t===1){if(!Ss(e,"OES_texture_float"))return!1}else if(!Ss(e,"EXT_color_buffer_float"))return!1;return N1(e)}function z9(t){if(t===0)return!1;const e=tr(t);if(t===1){if(!Ss(e,"OES_texture_float")||!Ss(e,"WEBGL_color_buffer_float"))return!1}else{if(Ss(e,"EXT_color_buffer_float"))return N1(e);const s="EXT_color_buffer_half_float";if(Ss(e,s)){const r=e.getExtension(s);return O9(e,r)}return!1}return N1(e)}function N1(t){const e=vv(t),n=t.createTexture();t.bindTexture(t.TEXTURE_2D,n),t.texImage2D(t.TEXTURE_2D,0,e.internalFormatFloat,1,1,0,e.textureFormatFloat,e.textureTypeFloat,null);const o=t.createFramebuffer();t.bindFramebuffer(t.FRAMEBUFFER,o),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,n,0);const i=t.checkFramebufferStatus(t.FRAMEBUFFER)===t.FRAMEBUFFER_COMPLETE;return t.bindTexture(t.TEXTURE_2D,null),t.bindFramebuffer(t.FRAMEBUFFER,null),t.deleteTexture(n),t.deleteFramebuffer(o),i}function O9(t,e){const n=vv(t,e),s=t.createTexture();t.bindTexture(t.TEXTURE_2D,s),t.texImage2D(t.TEXTURE_2D,0,n.internalFormatHalfFloat,1,1,0,n.textureFormatFloat,n.textureTypeHalfFloat,null);const i=t.createFramebuffer();t.bindFramebuffer(t.FRAMEBUFFER,i),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,s,0);const a=t.checkFramebufferStatus(t.FRAMEBUFFER)===t.FRAMEBUFFER_COMPLETE;return t.bindTexture(t.TEXTURE_2D,null),t.bindFramebuffer(t.FRAMEBUFFER,null),t.deleteTexture(s),t.deleteFramebuffer(i),a}function M9(t){return t!==2?!1:tr(t).fenceSync!=null}function Eh(t,e){Array.isArray(t)||(t=[t]),t.forEach(n=>{n!=null&&I(n.dtype!=="complex64",()=>`${e} does not support complex64 tensors in the WebGL backend.`)})}/** +`))}function g9(t){return Zr(t,()=>t.createProgram(),"Unable to create WebGLProgram.")}function x9(t,e){if(ae(t,()=>t.linkProgram(e)),!W().get("ENGINE_COMPILE_ONLY")&&t.getProgramParameter(e,t.LINK_STATUS)===!1)throw console.log(t.getProgramInfoLog(e)),new Error("Failed to link vertex and fragment shaders.")}function Dg(t,e){if(ae(t,()=>t.validateProgram(e)),t.getProgramParameter(e,t.VALIDATE_STATUS)===!1)throw console.log(t.getProgramInfoLog(e)),new Error("Shader program validation failed.")}function y9(t,e){const n=Zr(t,()=>t.createBuffer(),"Unable to create WebGLBuffer");return ae(t,()=>t.bindBuffer(t.ARRAY_BUFFER,n)),ae(t,()=>t.bufferData(t.ARRAY_BUFFER,e,t.STATIC_DRAW)),n}function w9(t,e){const n=Zr(t,()=>t.createBuffer(),"Unable to create WebGLBuffer");return ae(t,()=>t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,n)),ae(t,()=>t.bufferData(t.ELEMENT_ARRAY_BUFFER,e,t.STATIC_DRAW)),n}function v9(t){return Zr(t,()=>t.createTexture(),"Unable to create WebGLTexture.")}function b9(t,e){const n=W().getNumber("WEBGL_MAX_TEXTURE_SIZE");if(t<=0||e<=0){const s=`[${t}x${e}]`;throw new Error("Requested texture size "+s+" is invalid.")}if(t>n||e>n){const s=`[${t}x${e}]`,r=`[${n}x${n}]`;throw new Error("Requested texture size "+s+" greater than WebGL maximum on this browser / GPU "+r+".")}}function C9(t){return Zr(t,()=>t.createFramebuffer(),"Unable to create WebGLFramebuffer.")}function Ck(t,e,n,s,r,o,i){const a=t.getAttribLocation(e,n);return a===-1?!1:(ae(t,()=>t.bindBuffer(t.ARRAY_BUFFER,s)),ae(t,()=>t.vertexAttribPointer(a,r,t.FLOAT,!1,o,i)),ae(t,()=>t.enableVertexAttribArray(a)),!0)}function k9(t,e,n){T9(t,n),ae(t,()=>t.activeTexture(t.TEXTURE0+n)),ae(t,()=>t.bindTexture(t.TEXTURE_2D,e))}function S9(t,e,n){return Zr(t,()=>t.getUniformLocation(e,n),'uniform "'+n+'" not present in program.')}function I9(t,e,n){return t.getUniformLocation(e,n)}function $9(t,e,n,s){ae(t,()=>k9(t,e,s)),ae(t,()=>t.uniform1i(n,s))}function _g(t,e,n){ae(t,()=>t.bindFramebuffer(t.FRAMEBUFFER,n)),ae(t,()=>t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,e,0))}function kk(t,e){ae(t,()=>t.bindFramebuffer(t.FRAMEBUFFER,e)),ae(t,()=>t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,null,0))}function id(t){const e=t.checkFramebufferStatus(t.FRAMEBUFFER);if(e!==t.FRAMEBUFFER_COMPLETE)throw new Error("Error binding framebuffer: "+N9(t,e))}function N9(t,e){switch(e){case t.FRAMEBUFFER_INCOMPLETE_ATTACHMENT:return"FRAMEBUFFER_INCOMPLETE_ATTACHMENT";case t.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT:return"FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT";case t.FRAMEBUFFER_INCOMPLETE_DIMENSIONS:return"FRAMEBUFFER_INCOMPLETE_DIMENSIONS";case t.FRAMEBUFFER_UNSUPPORTED:return"FRAMEBUFFER_UNSUPPORTED";default:return`unknown error ${e}`}}function Zr(t,e,n){const s=ae(t,()=>e());if(s==null)throw new Error(n);return s}function T9(t,e){const n=t.MAX_COMBINED_TEXTURE_IMAGE_UNITS-1,s=e+t.TEXTURE0;if(sn){const r=`[gl.TEXTURE0, gl.TEXTURE${n}]`;throw new Error(`textureUnit must be in ${r}.`)}}function dl(t,e=2){return j(t.slice(0,t.length-e))}function fl(t){if(t.length===0)throw Error("Cannot get rows and columns of an empty shape array.");return[t.length>1?t[t.length-2]:1,t[t.length-1]]}function ad(t){let e=[1,1,1];return t.length===0||t.length===1&&t[0]===1||(e=[dl(t),...fl(t)]),e}function E9(t,e=!1){let n=W().getNumber("WEBGL_MAX_TEXTURE_SIZE"),s=W().getNumber("WEBGL_MAX_SIZE_FOR_NARROW_TEXTURE");s===1/0&&W().getBool("WEBGL_AUTO_SQUARIFY_NARROW_TEXTURE_SHAPE")&&(s=n/2),e&&(n=n*2,s=s*2,t=t.map((a,l)=>l>=t.length-2?Px(t[l]):t[l]),t.length===1&&(t=[2,t[0]])),t.length!==2&&(t=Vo(t).newShape);let r=j(t),o=null;t.length<=1&&r<=n?o=[1,r]:t.length===2&&t[0]<=n&&t[1]<=n?o=t:t.length===3&&t[0]*t[1]<=n&&t[2]<=n?o=[t[0]*t[1],t[2]]:t.length===3&&t[0]<=n&&t[1]*t[2]<=n?o=[t[0],t[1]*t[2]]:t.length===4&&t[0]*t[1]*t[2]<=n&&t[3]<=n?o=[t[0]*t[1]*t[2],t[3]]:t.length===4&&t[0]<=n&&t[1]*t[2]*t[3]<=n&&(o=[t[0],t[1]*t[2]*t[3]]);const i=o!=null&&Math.max(...o)>s&&Math.min(...o)<=(e?2:1)&&Math.min(...o)>0;if(o==null||i)if(e){const a=dl(t);let l=2,c=2;t.length&&([l,c]=fl(t)),r=a*(l/2)*(c/2),o=X0(r).map(u=>u*2)}else o=X0(r);return o}function ld(t){return t%2===0}function Pf(t,e){if(t=t.slice(-2),e=e.slice(-2),Ue(t,e)||!t.length||!e.length||t[0]===0||t[1]===0||e[0]===0||e[1]===0)return!0;if(t.length!==e.length){const n=t[t.length-1],s=e[e.length-1];if(n===s||ld(n)&&ld(s)&&(t[0]===1||e[0]===1))return!0}return t[1]===e[1]&&ld(t[0])&&ld(e[0])}let Fg,zg;function R9(t){if(Fg==null){const e=tr(t);Fg=e.getParameter(e.MAX_TEXTURE_SIZE)}return Fg}function A9(t){if(zg==null){const e=tr(t);zg=e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS)}return Math.min(16,zg)}function D9(t){if(t===0)return 0;let e;const n=tr(t);return Ss(n,"EXT_disjoint_timer_query_webgl2")&&t===2?e=2:Ss(n,"EXT_disjoint_timer_query")?e=1:e=0,e}function Ss(t,e){return t.getExtension(e)!=null}function Sk(t){try{if(tr(t)!=null)return!0}catch(e){return console.log("Error when getting WebGL context: ",e),!1}return!1}function _9(t){if(t===0)return!1;const e=tr(t);if(t===1){if(!Ss(e,"OES_texture_float"))return!1}else if(!Ss(e,"EXT_color_buffer_float"))return!1;return N1(e)}function F9(t){if(t===0)return!1;const e=tr(t);if(t===1){if(!Ss(e,"OES_texture_float")||!Ss(e,"WEBGL_color_buffer_float"))return!1}else{if(Ss(e,"EXT_color_buffer_float"))return N1(e);const s="EXT_color_buffer_half_float";if(Ss(e,s)){const r=e.getExtension(s);return z9(e,r)}return!1}return N1(e)}function N1(t){const e=vv(t),n=t.createTexture();t.bindTexture(t.TEXTURE_2D,n),t.texImage2D(t.TEXTURE_2D,0,e.internalFormatFloat,1,1,0,e.textureFormatFloat,e.textureTypeFloat,null);const o=t.createFramebuffer();t.bindFramebuffer(t.FRAMEBUFFER,o),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,n,0);const i=t.checkFramebufferStatus(t.FRAMEBUFFER)===t.FRAMEBUFFER_COMPLETE;return t.bindTexture(t.TEXTURE_2D,null),t.bindFramebuffer(t.FRAMEBUFFER,null),t.deleteTexture(n),t.deleteFramebuffer(o),i}function z9(t,e){const n=vv(t,e),s=t.createTexture();t.bindTexture(t.TEXTURE_2D,s),t.texImage2D(t.TEXTURE_2D,0,n.internalFormatHalfFloat,1,1,0,n.textureFormatFloat,n.textureTypeHalfFloat,null);const i=t.createFramebuffer();t.bindFramebuffer(t.FRAMEBUFFER,i),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,s,0);const a=t.checkFramebufferStatus(t.FRAMEBUFFER)===t.FRAMEBUFFER_COMPLETE;return t.bindTexture(t.TEXTURE_2D,null),t.bindFramebuffer(t.FRAMEBUFFER,null),t.deleteTexture(s),t.deleteFramebuffer(i),a}function O9(t){return t!==2?!1:tr(t).fenceSync!=null}function Th(t,e){Array.isArray(t)||(t=[t]),t.forEach(n=>{n!=null&&I(n.dtype!=="complex64",()=>`${e} 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"); @@ -11281,7 +11281,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const fe=W();fe.registerFlag("HAS_WEBGL",()=>fe.getNumber("WEBGL_VERSION")>0);fe.registerFlag("WEBGL_VERSION",()=>Sk(2)?2:Sk(1)?1:0);fe.registerFlag("WEBGL_CHECK_NUMERICAL_PROBLEMS",()=>!1);fe.registerFlag("WEBGL_BUFFER_SUPPORTED",()=>fe.get("WEBGL_VERSION")===2);fe.registerFlag("WEBGL_CPU_FORWARD",()=>!0);fe.registerFlag("WEBGL_FORCE_F16_TEXTURES",()=>!1);fe.registerFlag("WEBGL_PACK",()=>fe.getBool("HAS_WEBGL"));fe.registerFlag("WEBGL_PACK_NORMALIZATION",()=>fe.getBool("WEBGL_PACK"));fe.registerFlag("WEBGL_PACK_CLIP",()=>fe.getBool("WEBGL_PACK"));fe.registerFlag("WEBGL_PACK_DEPTHWISECONV",()=>fe.getBool("WEBGL_PACK"));fe.registerFlag("WEBGL_PACK_BINARY_OPERATIONS",()=>fe.getBool("WEBGL_PACK"));fe.registerFlag("WEBGL_PACK_UNARY_OPERATIONS",()=>fe.getBool("WEBGL_PACK"));fe.registerFlag("WEBGL_PACK_ARRAY_OPERATIONS",()=>fe.getBool("WEBGL_PACK"));fe.registerFlag("WEBGL_PACK_IMAGE_OPERATIONS",()=>fe.getBool("WEBGL_PACK"));fe.registerFlag("WEBGL_PACK_REDUCE",()=>fe.getBool("WEBGL_PACK"));fe.registerFlag("WEBGL_LAZILY_UNPACK",()=>fe.getBool("WEBGL_PACK"));fe.registerFlag("WEBGL_CONV_IM2COL",()=>fe.getBool("WEBGL_PACK"));fe.registerFlag("WEBGL_PACK_CONV2DTRANSPOSE",()=>fe.getBool("WEBGL_PACK"));fe.registerFlag("WEBGL_MAX_TEXTURE_SIZE",()=>A9(fe.getNumber("WEBGL_VERSION")));fe.registerFlag("WEBGL_MAX_TEXTURES_IN_SHADER",()=>D9(fe.getNumber("WEBGL_VERSION")));fe.registerFlag("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION",()=>{const t=fe.getNumber("WEBGL_VERSION");return t===0?0:_9(t)});fe.registerFlag("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE",()=>fe.getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")>0&&!M$());fe.registerFlag("WEBGL_RENDER_FLOAT32_CAPABLE",()=>F9(fe.getNumber("WEBGL_VERSION")));fe.registerFlag("WEBGL_RENDER_FLOAT32_ENABLED",()=>fe.getBool("WEBGL_FORCE_F16_TEXTURES")?!1:fe.getBool("WEBGL_RENDER_FLOAT32_CAPABLE"));fe.registerFlag("WEBGL_DOWNLOAD_FLOAT_ENABLED",()=>z9(fe.getNumber("WEBGL_VERSION")));fe.registerFlag("WEBGL_FENCE_API_ENABLED",()=>M9(fe.getNumber("WEBGL_VERSION")));fe.registerFlag("WEBGL_SIZE_UPLOAD_UNIFORM",()=>fe.getBool("WEBGL_RENDER_FLOAT32_ENABLED")?4:0);fe.registerFlag("WEBGL_DELETE_TEXTURE_THRESHOLD",()=>-1,t=>{if(typeof t!="number")throw new Error(`WEBGL_DELETE_TEXTURE_THRESHOLD must be a number but got ${t}.`);if(t<0&&t!==-1)throw new Error(`WEBGL_DELETE_TEXTURE_THRESHOLD must be -1 (indicating never delete) or at least 0, but got ${t}.`)});fe.registerFlag("WEBGL_FLUSH_THRESHOLD",()=>M$()?1:-1,t=>{if(typeof t!="number")throw new Error(`WEBGL_FLUSH_THRESHOLD must be a number but got ${t}.`);if(t<0&&t!==-1)throw new Error(`WEBGL_FLUSH_THRESHOLD must be -1 (indicating never manual flush) or at least 0, but got ${t}.`)});fe.registerFlag("CPU_HANDOFF_SIZE_THRESHOLD",()=>128);fe.registerFlag("WEBGL_USE_SHAPES_UNIFORMS",()=>!1);fe.registerFlag("TOPK_LAST_DIM_CPU_HANDOFF_SIZE_THRESHOLD",()=>1e5);fe.registerFlag("TOPK_K_CPU_HANDOFF_THRESHOLD",()=>128);fe.registerFlag("WEBGL_EXP_CONV",()=>!1);fe.registerFlag("SOFTWARE_WEBGL_ENABLED",()=>fe.getBool("IS_TEST"));fe.registerFlag("WEBGL_MAX_SIZE_FOR_NARROW_TEXTURE",()=>1/0);fe.registerFlag("WEBGL_AUTO_SQUARIFY_NARROW_TEXTURE_SHAPE",()=>!1);fe.registerFlag("WEBGL2_ISNAN_CUSTOM",()=>!1);fe.registerFlag("ENGINE_COMPILE_ONLY",()=>!1);/** + */const fe=W();fe.registerFlag("HAS_WEBGL",()=>fe.getNumber("WEBGL_VERSION")>0);fe.registerFlag("WEBGL_VERSION",()=>Sk(2)?2:Sk(1)?1:0);fe.registerFlag("WEBGL_CHECK_NUMERICAL_PROBLEMS",()=>!1);fe.registerFlag("WEBGL_BUFFER_SUPPORTED",()=>fe.get("WEBGL_VERSION")===2);fe.registerFlag("WEBGL_CPU_FORWARD",()=>!0);fe.registerFlag("WEBGL_FORCE_F16_TEXTURES",()=>!1);fe.registerFlag("WEBGL_PACK",()=>fe.getBool("HAS_WEBGL"));fe.registerFlag("WEBGL_PACK_NORMALIZATION",()=>fe.getBool("WEBGL_PACK"));fe.registerFlag("WEBGL_PACK_CLIP",()=>fe.getBool("WEBGL_PACK"));fe.registerFlag("WEBGL_PACK_DEPTHWISECONV",()=>fe.getBool("WEBGL_PACK"));fe.registerFlag("WEBGL_PACK_BINARY_OPERATIONS",()=>fe.getBool("WEBGL_PACK"));fe.registerFlag("WEBGL_PACK_UNARY_OPERATIONS",()=>fe.getBool("WEBGL_PACK"));fe.registerFlag("WEBGL_PACK_ARRAY_OPERATIONS",()=>fe.getBool("WEBGL_PACK"));fe.registerFlag("WEBGL_PACK_IMAGE_OPERATIONS",()=>fe.getBool("WEBGL_PACK"));fe.registerFlag("WEBGL_PACK_REDUCE",()=>fe.getBool("WEBGL_PACK"));fe.registerFlag("WEBGL_LAZILY_UNPACK",()=>fe.getBool("WEBGL_PACK"));fe.registerFlag("WEBGL_CONV_IM2COL",()=>fe.getBool("WEBGL_PACK"));fe.registerFlag("WEBGL_PACK_CONV2DTRANSPOSE",()=>fe.getBool("WEBGL_PACK"));fe.registerFlag("WEBGL_MAX_TEXTURE_SIZE",()=>R9(fe.getNumber("WEBGL_VERSION")));fe.registerFlag("WEBGL_MAX_TEXTURES_IN_SHADER",()=>A9(fe.getNumber("WEBGL_VERSION")));fe.registerFlag("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION",()=>{const t=fe.getNumber("WEBGL_VERSION");return t===0?0:D9(t)});fe.registerFlag("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE",()=>fe.getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")>0&&!M$());fe.registerFlag("WEBGL_RENDER_FLOAT32_CAPABLE",()=>_9(fe.getNumber("WEBGL_VERSION")));fe.registerFlag("WEBGL_RENDER_FLOAT32_ENABLED",()=>fe.getBool("WEBGL_FORCE_F16_TEXTURES")?!1:fe.getBool("WEBGL_RENDER_FLOAT32_CAPABLE"));fe.registerFlag("WEBGL_DOWNLOAD_FLOAT_ENABLED",()=>F9(fe.getNumber("WEBGL_VERSION")));fe.registerFlag("WEBGL_FENCE_API_ENABLED",()=>O9(fe.getNumber("WEBGL_VERSION")));fe.registerFlag("WEBGL_SIZE_UPLOAD_UNIFORM",()=>fe.getBool("WEBGL_RENDER_FLOAT32_ENABLED")?4:0);fe.registerFlag("WEBGL_DELETE_TEXTURE_THRESHOLD",()=>-1,t=>{if(typeof t!="number")throw new Error(`WEBGL_DELETE_TEXTURE_THRESHOLD must be a number but got ${t}.`);if(t<0&&t!==-1)throw new Error(`WEBGL_DELETE_TEXTURE_THRESHOLD must be -1 (indicating never delete) or at least 0, but got ${t}.`)});fe.registerFlag("WEBGL_FLUSH_THRESHOLD",()=>M$()?1:-1,t=>{if(typeof t!="number")throw new Error(`WEBGL_FLUSH_THRESHOLD must be a number but got ${t}.`);if(t<0&&t!==-1)throw new Error(`WEBGL_FLUSH_THRESHOLD must be -1 (indicating never manual flush) or at least 0, but got ${t}.`)});fe.registerFlag("CPU_HANDOFF_SIZE_THRESHOLD",()=>128);fe.registerFlag("WEBGL_USE_SHAPES_UNIFORMS",()=>!1);fe.registerFlag("TOPK_LAST_DIM_CPU_HANDOFF_SIZE_THRESHOLD",()=>1e5);fe.registerFlag("TOPK_K_CPU_HANDOFF_THRESHOLD",()=>128);fe.registerFlag("WEBGL_EXP_CONV",()=>!1);fe.registerFlag("SOFTWARE_WEBGL_ENABLED",()=>fe.getBool("IS_TEST"));fe.registerFlag("WEBGL_MAX_SIZE_FOR_NARROW_TEXTURE",()=>1/0);fe.registerFlag("WEBGL_AUTO_SQUARIFY_NARROW_TEXTURE_SHAPE",()=>!1);fe.registerFlag("WEBGL2_ISNAN_CUSTOM",()=>!1);fe.registerFlag("ENGINE_COMPILE_ONLY",()=>!1);/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -11357,7 +11357,7 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function ea(t,e,n="index"){const s=pe(e);return s.map((r,o)=>{const i=`int ${t[o]} = ${n} / ${r}`,a=o===s.length-1?`int ${t[o+1]} = ${n} - ${t[o]} * ${r}`:`index -= ${t[o]} * ${r}`;return`${i}; ${a};`}).join("")}function Mm(t,e,n="index"){const s=pe(e);return s.map((r,o)=>{const i=`int ${t[o]} = ${n} / outShapeStrides[${o}]`,a=o===s.length-1?`int ${t[o+1]} = ${n} - ${t[o]} * outShapeStrides[${o}]`:`index -= ${t[o]} * outShapeStrides[${o}]`;return`${i}; ${a};`}).join("")}function P9(t,e){const n=t.length,s=t.map(o=>`${e}[${o}]`),r=new Array(n-1);r[n-2]=s[n-1];for(let o=n-3;o>=0;--o)r[o]=`(${r[o+1]} * ${s[o+1]})`;return r}function L9(t,e,n="index"){const s=t.map((o,i)=>i),r=P9(s,e);return r.map((o,i)=>{const a=`int ${t[i]} = ${n} / ${r[i]}`,l=i===r.length-1?`int ${t[i+1]} = ${n} - ${t[i]} * ${r[i]}`:`index -= ${t[i]} * ${r[i]}`;return`${a}; ${l};`}).join("")}function bv(t){const e=pe(t).map(n=>n.toString());return` + */function ea(t,e,n="index"){const s=pe(e);return s.map((r,o)=>{const i=`int ${t[o]} = ${n} / ${r}`,a=o===s.length-1?`int ${t[o+1]} = ${n} - ${t[o]} * ${r}`:`index -= ${t[o]} * ${r}`;return`${i}; ${a};`}).join("")}function Mm(t,e,n="index"){const s=pe(e);return s.map((r,o)=>{const i=`int ${t[o]} = ${n} / outShapeStrides[${o}]`,a=o===s.length-1?`int ${t[o+1]} = ${n} - ${t[o]} * outShapeStrides[${o}]`:`index -= ${t[o]} * outShapeStrides[${o}]`;return`${i}; ${a};`}).join("")}function M9(t,e){const n=t.length,s=t.map(o=>`${e}[${o}]`),r=new Array(n-1);r[n-2]=s[n-1];for(let o=n-3;o>=0;--o)r[o]=`(${r[o+1]} * ${s[o+1]})`;return r}function P9(t,e,n="index"){const s=t.map((o,i)=>i),r=M9(s,e);return r.map((o,i)=>{const a=`int ${t[i]} = ${n} / ${r[i]}`,l=i===r.length-1?`int ${t[i+1]} = ${n} - ${t[i]} * ${r[i]}`:`index -= ${t[i]} * ${r[i]}`;return`${a}; ${l};`}).join("")}function bv(t){const e=pe(t).map(n=>n.toString());return` int getFlatIndex(ivec3 coords) { return coords.x * ${e[0]} + coords.y * ${e[1]} + coords.z; } @@ -11419,22 +11419,22 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const{getBroadcastDims:UA}=$U;function B9(t,e,n){const s=[];if(t.forEach(f=>{const p=j(f.shapeInfo.logicalShape);if(f.shapeInfo.isUniform?s.push(`uniform float ${f.name}${p>1?`[${p}]`:""};`):(s.push(`uniform sampler2D ${f.name};`),s.push(`uniform int offset${f.name};`)),n.enableShapeUniforms){const{uniformShape:g}=kv(n.packedInputs,f.shapeInfo.logicalShape,f.shapeInfo.texShape);switch(g.length){case 1:s.push(`uniform int ${f.name}Shape;`);break;case 2:s.push(`uniform ivec2 ${f.name}Shape;`);break;case 3:s.push(`uniform ivec3 ${f.name}Shape;`);break;case 4:s.push(`uniform ivec4 ${f.name}Shape;`);break}s.push(`uniform ivec2 ${f.name}TexShape;`)}}),n.enableShapeUniforms){switch(e.logicalShape.length){case 1:s.push("uniform int outShape;");break;case 2:s.push("uniform ivec2 outShape;"),s.push("uniform int outShapeStrides;");break;case 3:s.push("uniform ivec3 outShape;"),s.push("uniform ivec2 outShapeStrides;");break;case 4:s.push("uniform ivec4 outShape;"),s.push("uniform ivec3 outShapeStrides;");break}s.push("uniform ivec2 outTexShape;")}n.customUniforms&&n.customUniforms.forEach(f=>{s.push(`uniform ${f.type} ${f.name}${f.arrayIndex?`[${f.arrayIndex}]`:""};`)});const r=s.join(` -`),o=t.map(f=>V9(f,e,n.packedInputs,n.enableShapeUniforms)).join(` -`),i=e.texShape,a=$n(),l=G9(a);let c,u,h=K9(a);return e.isPacked?(c=W9(e.logicalShape,i,n.enableShapeUniforms),u=j9(a)):(c=U9(e.logicalShape,i,n.enableShapeUniforms),u=H9(a)),n.packedInputs&&(h+=Q9),[h,l,u,r,c,o,n.userCode].join(` -`)}function Tl(t,e=!1){const n=t.shapeInfo.logicalShape;switch(n.length){case 0:return cY(t,e);case 1:return hY(t,e);case 2:return fY(t,e);case 3:return mY(t,e);case 4:return xY(t,e);case 5:return yY(t);case 6:return wY(t);default:throw new Error(`${n.length}-D input sampling is not yet supported`)}}function GA(t,e){switch(t.shapeInfo.logicalShape.length){case 0:return lY(t);case 1:return uY(t,e);case 2:return dY(t,e);case 3:return pY(t,e);default:return gY(t,e)}}function V9(t,e,n=!1,s){let r="";n?r+=GA(t,s):r+=Tl(t,s);const o=t.shapeInfo.logicalShape,i=e.logicalShape;return o.length<=i.length&&(n?r+=vY(t,e):r+=bY(t,e)),r}function W9(t,e,n){switch(t.length){case 0:return HA();case 1:return Z9(t,e,n);case 2:return iY(t,e,n);case 3:return eY(t,e,n);default:return nY(t,e,n)}}function U9(t,e,n){switch(t.length){case 0:return HA();case 1:return J9(t,e,n);case 2:return aY(t,e,n);case 3:return tY(t,e,n);case 4:return sY(t,e,n);case 5:return rY(t,e);case 6:return oY(t,e);default:throw new Error(`${t.length}-D output sampling is not yet supported`)}}function G9(t){return` + */const{getBroadcastDims:UA}=IU;function L9(t,e,n){const s=[];if(t.forEach(f=>{const p=j(f.shapeInfo.logicalShape);if(f.shapeInfo.isUniform?s.push(`uniform float ${f.name}${p>1?`[${p}]`:""};`):(s.push(`uniform sampler2D ${f.name};`),s.push(`uniform int offset${f.name};`)),n.enableShapeUniforms){const{uniformShape:g}=kv(n.packedInputs,f.shapeInfo.logicalShape,f.shapeInfo.texShape);switch(g.length){case 1:s.push(`uniform int ${f.name}Shape;`);break;case 2:s.push(`uniform ivec2 ${f.name}Shape;`);break;case 3:s.push(`uniform ivec3 ${f.name}Shape;`);break;case 4:s.push(`uniform ivec4 ${f.name}Shape;`);break}s.push(`uniform ivec2 ${f.name}TexShape;`)}}),n.enableShapeUniforms){switch(e.logicalShape.length){case 1:s.push("uniform int outShape;");break;case 2:s.push("uniform ivec2 outShape;"),s.push("uniform int outShapeStrides;");break;case 3:s.push("uniform ivec3 outShape;"),s.push("uniform ivec2 outShapeStrides;");break;case 4:s.push("uniform ivec4 outShape;"),s.push("uniform ivec3 outShapeStrides;");break}s.push("uniform ivec2 outTexShape;")}n.customUniforms&&n.customUniforms.forEach(f=>{s.push(`uniform ${f.type} ${f.name}${f.arrayIndex?`[${f.arrayIndex}]`:""};`)});const r=s.join(` +`),o=t.map(f=>B9(f,e,n.packedInputs,n.enableShapeUniforms)).join(` +`),i=e.texShape,a=$n(),l=U9(a);let c,u,h=j9(a);return e.isPacked?(c=V9(e.logicalShape,i,n.enableShapeUniforms),u=H9(a)):(c=W9(e.logicalShape,i,n.enableShapeUniforms),u=G9(a)),n.packedInputs&&(h+=Y9),[h,l,u,r,c,o,n.userCode].join(` +`)}function Tl(t,e=!1){const n=t.shapeInfo.logicalShape;switch(n.length){case 0:return lY(t,e);case 1:return uY(t,e);case 2:return dY(t,e);case 3:return pY(t,e);case 4:return gY(t,e);case 5:return xY(t);case 6:return yY(t);default:throw new Error(`${n.length}-D input sampling is not yet supported`)}}function GA(t,e){switch(t.shapeInfo.logicalShape.length){case 0:return aY(t);case 1:return cY(t,e);case 2:return hY(t,e);case 3:return fY(t,e);default:return mY(t,e)}}function B9(t,e,n=!1,s){let r="";n?r+=GA(t,s):r+=Tl(t,s);const o=t.shapeInfo.logicalShape,i=e.logicalShape;return o.length<=i.length&&(n?r+=wY(t,e):r+=vY(t,e)),r}function V9(t,e,n){switch(t.length){case 0:return HA();case 1:return Q9(t,e,n);case 2:return oY(t,e,n);case 3:return J9(t,e,n);default:return tY(t,e,n)}}function W9(t,e,n){switch(t.length){case 0:return HA();case 1:return Z9(t,e,n);case 2:return iY(t,e,n);case 3:return eY(t,e,n);case 4:return nY(t,e,n);case 5:return sY(t,e);case 6:return rY(t,e);default:throw new Error(`${t.length}-D output sampling is not yet supported`)}}function U9(t){return` float sampleTexture(sampler2D textureSampler, vec2 uv) { return ${t.texture2D}(textureSampler, uv).r; } - `}function H9(t){return` + `}function G9(t){return` void setOutput(float val) { ${t.output} = vec4(val, 0, 0, 0); } - `}function j9(t){return` + `}function H9(t){return` void setOutput(vec4 val) { ${t.output} = val; } - `}function K9(t){return`${t.version} + `}function j9(t){return`${t.version} precision highp float; precision highp int; precision highp sampler2D; @@ -11489,10 +11489,10 @@ Hi, looks like you are running TensorFlow.js in Node.js. To speed things up dram return fract((p3.x + p3.y) * p3.z); } + ${K9} ${X9} ${q9} - ${Y9} - `}const X9=` + `}const K9=` vec2 uvFromFlat(int texNumR, int texNumC, int index) { int texR = index / texNumC; int texC = index - texR * texNumC; @@ -11504,7 +11504,7 @@ vec2 packedUVfrom1D(int texNumR, int texNumC, int index) { int texC = texelIndex - texR * texNumC; return (vec2(texC, texR) + halfCR) / vec2(texNumC, texNumR); } -`,q9=` +`,X9=` vec2 packedUVfrom2D(int texelsInLogicalRow, int texNumR, int texNumC, int row, int col) { int texelIndex = (row / 2) * texelsInLogicalRow + (col / 2); @@ -11512,7 +11512,7 @@ vec2 packedUVfrom2D(int texelsInLogicalRow, int texNumR, int texC = texelIndex - texR * texNumC; return (vec2(texC, texR) + halfCR) / vec2(texNumC, texNumR); } -`,Y9=` +`,q9=` vec2 packedUVfrom3D(int texNumR, int texNumC, int texelsInBatch, int texelsInLogicalRow, int b, int row, int col) { @@ -11521,7 +11521,7 @@ vec2 packedUVfrom3D(int texNumR, int texNumC, int texC = index - texR * texNumC; return (vec2(texC, texR) + halfCR) / vec2(texNumC, texNumR); } -`,Q9=` +`,Y9=` float getChannel(vec4 frag, vec2 innerDims) { vec2 modCoord = mod(innerDims, 2.); return modCoord.x == 0. ? @@ -11536,7 +11536,7 @@ vec2 packedUVfrom3D(int texNumR, int texNumC, int getOutputCoords() { return 0; } - `}function Z9(t,e,n){const s=[Math.ceil(e[0]/2),Math.ceil(e[1]/2)];return s[0]===1?n?` + `}function Q9(t,e,n){const s=[Math.ceil(e[0]/2),Math.ceil(e[1]/2)];return s[0]===1?n?` int getOutputCoords() { return 2 * int(resultUV.x * ceil(float(outTexShape[1]) / 2.0)); } @@ -11565,7 +11565,7 @@ vec2 packedUVfrom3D(int texNumR, int texNumC, vec2(${s[0]}, ${s[1]})); return 2 * (resTexRC.x * ${s[1]} + resTexRC.y); } - `}function J9(t,e,n){return e[0]===1?n?` + `}function Z9(t,e,n){return e[0]===1?n?` int getOutputCoords() { return int(resultUV.x * float(outTexShape[1])); } @@ -11593,7 +11593,7 @@ vec2 packedUVfrom3D(int texNumR, int texNumC, vec2(${e[0]}, ${e[1]})); return resTexRC.x * ${e[1]} + resTexRC.y; } - `}function eY(t,e,n){if(n)return` + `}function J9(t,e,n){if(n)return` ivec3 getOutputCoords() { ivec2 packedTexShape = ivec2(ceil(float(outTexShape[0]) / 2.0), ceil(float(outTexShape[1]) / 2.0)); int texelsInLogicalRow = int(ceil(float(outShape[2]) / 2.0)); @@ -11624,7 +11624,7 @@ vec2 packedUVfrom3D(int texNumR, int texNumC, return ivec3(b, r, c); } - `}function tY(t,e,n){if(n)return` + `}function eY(t,e,n){if(n)return` ivec3 getOutputCoords() { ivec2 resTexRC = ivec2(resultUV.yx * vec2(outTexShape[0], outTexShape[1])); @@ -11640,7 +11640,7 @@ vec2 packedUVfrom3D(int texNumR, int texNumC, ${s} return ivec3(r, c, d); } - `}function nY(t,e,n){if(n)return` + `}function tY(t,e,n){if(n)return` ivec4 getOutputCoords() { ivec2 packedTexShape = ivec2(ceil(float(outTexShape[0]) / 2.0), ceil(float(outTexShape[1]) / 2.0)); ivec2 resTexRC = ivec2(resultUV.yx * @@ -11681,7 +11681,7 @@ vec2 packedUVfrom3D(int texNumR, int texNumC, return ivec${t.length}(${l}); } - `}function sY(t,e,n){if(n)return` + `}function nY(t,e,n){if(n)return` ivec4 getOutputCoords() { ivec2 resTexRC = ivec2(resultUV.yx * vec2(outTexShape[0], outTexShape[1])); @@ -11697,7 +11697,7 @@ vec2 packedUVfrom3D(int texNumR, int texNumC, ${s} return ivec4(r, c, d, d2); } - `}function rY(t,e){const n=ea(["r","c","d","d2","d3"],t);return` + `}function sY(t,e){const n=ea(["r","c","d","d2","d3"],t);return` ivec5 getOutputCoords() { ivec2 resTexRC = ivec2(resultUV.yx * vec2(${e[0]}, ${e[1]})); @@ -11709,7 +11709,7 @@ vec2 packedUVfrom3D(int texNumR, int texNumC, ivec5 outShape = ivec5(r, c, d, d2, d3); return outShape; } - `}function oY(t,e){const n=ea(["r","c","d","d2","d3","d4"],t);return` + `}function rY(t,e){const n=ea(["r","c","d","d2","d3","d4"],t);return` ivec6 getOutputCoords() { ivec2 resTexRC = ivec2(resultUV.yx * vec2(${e[0]}, ${e[1]})); @@ -11720,7 +11720,7 @@ vec2 packedUVfrom3D(int texNumR, int texNumC, ivec6 result = ivec6(r, c, d, d2, d3, d4); return result; } - `}function iY(t,e,n){const s=[Math.ceil(e[0]/2),Math.ceil(e[1]/2)];if(Ue(t,e))return n?` + `}function oY(t,e,n){const s=[Math.ceil(e[0]/2),Math.ceil(e[1]/2)];if(Ue(t,e))return n?` ivec2 getOutputCoords() { ivec2 packedTexShape = ivec2(ceil(float(outTexShape[0]) / 2.0), ceil(float(outTexShape[1]) / 2.0)); return 2 * ivec2(resultUV.yx * vec2(packedTexShape[0], packedTexShape[1])); @@ -11753,7 +11753,7 @@ vec2 packedUVfrom3D(int texNumR, int texNumC, return ivec2(r, c); } - `}function aY(t,e,n){return Ue(t,e)?n?` + `}function iY(t,e,n){return Ue(t,e)?n?` ivec2 getOutputCoords() { return ivec2(resultUV.yx * vec2(outTexShape[0], outTexShape[1])); } @@ -11807,11 +11807,11 @@ vec2 packedUVfrom3D(int texNumR, int texNumC, int c = index - r * ${t[1]}; return ivec2(r, c); } - `}function ta(t){return`offset${t}`}function lY(t){const e=t.name,n="get"+e.charAt(0).toUpperCase()+e.slice(1),s=$n();return` + `}function ta(t){return`offset${t}`}function aY(t){const e=t.name,n="get"+e.charAt(0).toUpperCase()+e.slice(1),s=$n();return` vec4 ${n}() { return ${s.texture2D}(${e}, halfCR); } - `}function cY(t,e){const n=t.name,s="get"+n.charAt(0).toUpperCase()+n.slice(1);if(t.shapeInfo.isUniform)return`float ${s}() {return ${n};}`;const[r,o]=t.shapeInfo.texShape;if(r===1&&o===1)return` + `}function lY(t,e){const n=t.name,s="get"+n.charAt(0).toUpperCase()+n.slice(1);if(t.shapeInfo.isUniform)return`float ${s}() {return ${n};}`;const[r,o]=t.shapeInfo.texShape;if(r===1&&o===1)return` float ${s}() { return sampleTexture(${n}, halfCR); } @@ -11825,7 +11825,7 @@ vec2 packedUVfrom3D(int texNumR, int texNumC, vec2 uv = uvFromFlat(${a}, ${l}, ${i}); return sampleTexture(${n}, uv); } - `}function uY(t,e){const n=t.name,s="get"+n.charAt(0).toUpperCase()+n.slice(1),r=t.shapeInfo.texShape,o=$n();if(e)return` + `}function cY(t,e){const n=t.name,s="get"+n.charAt(0).toUpperCase()+n.slice(1),r=t.shapeInfo.texShape,o=$n();if(e)return` vec4 ${s}(int index) { ivec2 packedTexShape = ivec2(ceil(float(${n}TexShape[0]) / 2.0), ceil(float(${n}TexShape[1]) / 2.0)); vec2 uv = packedUVfrom1D( @@ -11838,7 +11838,7 @@ vec2 packedUVfrom3D(int texNumR, int texNumC, ${i[0]}, ${i[1]}, index); return ${o.texture2D}(${n}, uv); } - `}function hY(t,e){const n=t.name,s="get"+n.charAt(0).toUpperCase()+n.slice(1);if(t.shapeInfo.isUniform)return` + `}function uY(t,e){const n=t.name,s="get"+n.charAt(0).toUpperCase()+n.slice(1);if(t.shapeInfo.isUniform)return` float ${s}(int index) { ${El(t)} } @@ -11876,7 +11876,7 @@ vec2 packedUVfrom3D(int texNumR, int texNumC, vec2 uv = uvFromFlat(${o}, ${i}, index + ${a}); return sampleTexture(${n}, uv); } - `}function dY(t,e){const n=t.shapeInfo.logicalShape,s=t.name,r="get"+s.charAt(0).toUpperCase()+s.slice(1),o=t.shapeInfo.texShape,i=o[0],a=o[1],l=$n();if(o!=null&&Ue(n,o))return e?` + `}function hY(t,e){const n=t.shapeInfo.logicalShape,s=t.name,r="get"+s.charAt(0).toUpperCase()+s.slice(1),o=t.shapeInfo.texShape,i=o[0],a=o[1],l=$n();if(o!=null&&Ue(n,o))return e?` vec4 ${r}(int row, int col) { vec2 uv = (vec2(col, row) + halfCR) / vec2(${s}TexShape[1], ${s}TexShape[0]); @@ -11900,7 +11900,7 @@ vec2 packedUVfrom3D(int texNumR, int texNumC, vec2 uv = packedUVfrom2D(${u}, ${c[0]}, ${c[1]}, row, col); return ${l.texture2D}(${s}, uv); } - `}function fY(t,e){const n=t.shapeInfo.logicalShape,s=t.name,r="get"+s.charAt(0).toUpperCase()+s.slice(1),o=t.shapeInfo.texShape;if(o!=null&&Ue(n,o)){if(e)return` + `}function dY(t,e){const n=t.shapeInfo.logicalShape,s=t.name,r="get"+s.charAt(0).toUpperCase()+s.slice(1),o=t.shapeInfo.texShape;if(o!=null&&Ue(n,o)){if(e)return` float ${r}(int row, int col) { vec2 uv = (vec2(col, row) + halfCR) / vec2(${s}TexShape[1], ${s}TexShape[0]); return sampleTexture(${s}, uv); @@ -11958,7 +11958,7 @@ vec2 packedUVfrom3D(int texNumR, int texNumC, vec2 uv = uvFromFlat(${c}, ${u}, index); return sampleTexture(${s}, uv); } -`}function pY(t,e){const n=t.shapeInfo.logicalShape,s=t.name,r="get"+s.charAt(0).toUpperCase()+s.slice(1),o=t.shapeInfo.texShape,i=[Math.ceil(o[0]/2),Math.ceil(o[1]/2)];if(n[0]===1){const d=n.slice(1),f=[1,2],p=Rl(t,d),g=["b","row","col"];return` +`}function fY(t,e){const n=t.shapeInfo.logicalShape,s=t.name,r="get"+s.charAt(0).toUpperCase()+s.slice(1),o=t.shapeInfo.texShape,i=[Math.ceil(o[0]/2),Math.ceil(o[1]/2)];if(n[0]===1){const d=n.slice(1),f=[1,2],p=Rl(t,d),g=["b","row","col"];return` ${GA(p,e)} vec4 ${r}(int b, int row, int col) { return ${r}(${Al(g,f)}); @@ -11978,7 +11978,7 @@ vec2 packedUVfrom3D(int texNumR, int texNumC, ${l}, ${c}, ${h}, ${u}, b, row, col); return ${a.texture2D}(${s}, uv); } - `}function mY(t,e){const n=t.shapeInfo.logicalShape,s=t.name,r="get"+s.charAt(0).toUpperCase()+s.slice(1),o=n[1]*n[2],i=n[2],{newShape:a,keptDims:l}=Vo(n),c=a;if(c.length=1?u="coords = 0;":u=a.map(y=>`coords.${h[y+c]} = 0;`).join(` + `}function wY(t,e){const n=t.name,s=n.charAt(0).toUpperCase()+n.slice(1),r="get"+s+"AtOutCoords",o=t.shapeInfo.logicalShape.length,i=e.logicalShape.length,a=UA(t.shapeInfo.logicalShape,e.logicalShape),l=Ze(i),c=i-o;let u;const h=["x","y","z","w","u","v"];o===0?u="":i<2&&a.length>=1?u="coords = 0;":u=a.map(y=>`coords.${h[y+c]} = 0;`).join(` `);let d="";i<2&&o>0?d="coords":d=t.shapeInfo.logicalShape.map((y,w)=>`coords.${h[w+c]}`).join(", ");let f="return outputValue;";const g=j(t.shapeInfo.logicalShape)===1,m=j(e.logicalShape)===1;if(o===1&&!g&&!m)f=` return vec4(outputValue.xy, outputValue.xy); `;else if(g&&!m)i===1?f=` @@ -12237,7 +12237,7 @@ vec2 packedUVfrom3D(int texNumR, int texNumC, vec4 outputValue = get${s}(${d}); ${f} } - `}function bY(t,e){const n=t.name,s=n.charAt(0).toUpperCase()+n.slice(1),r="get"+s+"AtOutCoords",o=e.texShape,i=t.shapeInfo.texShape,a=t.shapeInfo.logicalShape.length,l=e.logicalShape.length;if(!t.shapeInfo.isUniform&&a===l&&t.shapeInfo.flatOffset==null&&Ue(i,o))return` + `}function vY(t,e){const n=t.name,s=n.charAt(0).toUpperCase()+n.slice(1),r="get"+s+"AtOutCoords",o=e.texShape,i=t.shapeInfo.texShape,a=t.shapeInfo.logicalShape.length,l=e.logicalShape.length;if(!t.shapeInfo.isUniform&&a===l&&t.shapeInfo.flatOffset==null&&Ue(i,o))return` float ${r}() { return sampleTexture(${n}, resultUV); } @@ -12263,7 +12263,7 @@ vec2 packedUVfrom3D(int texNumR, int texNumC, * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function CY(t,e,n,s){const r=n.map((u,h)=>{const d={logicalShape:u.shape,texShape:u.isUniform?null:u.texData.texShape,isUniform:u.isUniform,isPacked:u.isUniform?!1:u.texData.isPacked,flatOffset:null};return u.texData!=null&&u.texData.slice!=null&&u.texData.slice.flatOffset>0&&(d.flatOffset=u.texData.slice.flatOffset),{name:e.variableNames[h],shapeInfo:d}}),o=r.map(u=>u.shapeInfo),i={logicalShape:s.shape,texShape:s.texData.texShape,isUniform:!1,isPacked:s.texData.isPacked,flatOffset:null},a=B9(r,i,e),l=m9(t.gl,a),c=t.createProgram(l);return W().get("ENGINE_COMPILE_ONLY")?{program:e,fragmentShader:l,source:a,webGLProgram:c,inShapeInfos:o,outShapeInfo:i,variablesLocations:null,customUniformLocations:null,infLoc:null,nanLoc:null,outShapeLocation:null,outShapeStridesLocation:null,outTexShapeLocation:null}:(t.buildVao(c),Object.assign({program:e,fragmentShader:l,source:a,webGLProgram:c,inShapeInfos:o,outShapeInfo:i},jA(t,e,c)))}function jA(t,e,n){const s=[],r=[];let o,i,a,l=null,c=null;c=t.getUniformLocation(n,"NAN",!1),W().getNumber("WEBGL_VERSION")===1&&(l=t.getUniformLocation(n,"INFINITY",!1));const u=!1;for(const h of e.variableNames){const d={name:h,uniform:t.getUniformLocation(n,h,u),offset:t.getUniformLocation(n,`offset${h}`,u)};e.enableShapeUniforms&&(d.shape=t.getUniformLocation(n,`${h}Shape`,u),d.texShape=t.getUniformLocation(n,`${h}TexShape`,u)),s.push(d)}if(e.enableShapeUniforms&&(o=t.getUniformLocation(n,"outShape",u),a=t.getUniformLocation(n,"outShapeStrides",u),i=t.getUniformLocation(n,"outTexShape",u)),e.customUniforms)for(const h of e.customUniforms)r.push(t.getUniformLocation(n,h.name,u));return{variablesLocations:s,customUniformLocations:r,infLoc:l,nanLoc:c,outShapeLocation:o,outShapeStridesLocation:a,outTexShapeLocation:i}}function Ik(t,e){if(t.length!==e.length)throw Error(`Binary was compiled with ${t.length} inputs, but was executed with ${e.length} inputs`);t.forEach((n,s)=>{const r=n.logicalShape,o=e[s],i=o.shape;if(!Ue(r,i))throw Error(`Binary was compiled with different shapes than the current args. Shapes ${r} and ${i} must match`);if(n.isUniform&&o.isUniform)return;const a=n.texShape,l=o.isUniform?null:o.texData.texShape;if(!Ue(a,l))throw Error(`Binary was compiled with different texture shapes than the current args. Shape ${a} and ${l} must match`)})}function kY(t,e,n,s,r){e.program.enableShapeUniforms||(Ik(e.inShapeInfos,n),Ik([e.outShapeInfo],[s]));const o=s.texData.texture,i=s.texData.texShape;s.texData.isPacked?t.setOutputPackedMatrixTexture(o.texture,i[0],i[1]):t.setOutputMatrixTexture(o.texture,i[0],i[1]),t.setProgram(e.webGLProgram),t.bindVertexArray(e.webGLProgram.vao),W().getNumber("WEBGL_VERSION")===1&&e.infLoc!==null&&t.gl.uniform1f(e.infLoc,1/0),e.nanLoc!==null&&t.gl.uniform1f(e.nanLoc,NaN);for(let l=0;l{const a=i.texData!=null&&i.texData.slice!=null&&i.texData.slice.flatOffset>0;if(t.enableShapeUniforms&&!i.isUniform){const l=i.texData.texShape,{useSqueezeShape:c,uniformShape:u,keptDims:h}=kv(t.packedInputs,i.shape,l);let d="",f="",p="";if(u.length===1&&t.packedInputs){const b=[Math.ceil(l[0]/2),Math.ceil(l[1]/2)];d=`${b[0]>1}_${b[1]>1}`}else if(u.length===2&&!t.packedInputs)f=`${u[0]>1}_${u[1]>1}`;else if(u.length>2&&!t.packedInputs){const b=pe(u);p=`${b[0]===l[1]}_${b[b.length-1]===l[1]}`}const g=i.shape.length,x=u.length===2&&Ue(i.shape,l),m=j(i.shape)===1,y=il(i.shape,n.shape),w=!t.packedInputs&&g===n.shape.length&&Ue(l,n.texData.texShape),v=t.packedInputs||u.length>2?"":`${l[0]>1}_${l[1]>1}`;s+=`${g}_${w}_${c?h:""}_${u.length}_${m}_${y}_${x}_${d}_${f}_${p}_${v}_${a}`}else{const l=i.isUniform?"uniform":i.texData.texShape;s+=`${i.shape}_${l}_${a}`}});const r=t.userCode;let o=t.constructor.name;return o+="_"+s+"_"+r+`${W().getNumber("WEBGL_VERSION")}`,o}function pn(t){return W().getBool("WEBGL_USE_SHAPES_UNIFORMS")&&t<=4}/** + */function bY(t,e,n,s){const r=n.map((u,h)=>{const d={logicalShape:u.shape,texShape:u.isUniform?null:u.texData.texShape,isUniform:u.isUniform,isPacked:u.isUniform?!1:u.texData.isPacked,flatOffset:null};return u.texData!=null&&u.texData.slice!=null&&u.texData.slice.flatOffset>0&&(d.flatOffset=u.texData.slice.flatOffset),{name:e.variableNames[h],shapeInfo:d}}),o=r.map(u=>u.shapeInfo),i={logicalShape:s.shape,texShape:s.texData.texShape,isUniform:!1,isPacked:s.texData.isPacked,flatOffset:null},a=L9(r,i,e),l=p9(t.gl,a),c=t.createProgram(l);return W().get("ENGINE_COMPILE_ONLY")?{program:e,fragmentShader:l,source:a,webGLProgram:c,inShapeInfos:o,outShapeInfo:i,variablesLocations:null,customUniformLocations:null,infLoc:null,nanLoc:null,outShapeLocation:null,outShapeStridesLocation:null,outTexShapeLocation:null}:(t.buildVao(c),Object.assign({program:e,fragmentShader:l,source:a,webGLProgram:c,inShapeInfos:o,outShapeInfo:i},jA(t,e,c)))}function jA(t,e,n){const s=[],r=[];let o,i,a,l=null,c=null;c=t.getUniformLocation(n,"NAN",!1),W().getNumber("WEBGL_VERSION")===1&&(l=t.getUniformLocation(n,"INFINITY",!1));const u=!1;for(const h of e.variableNames){const d={name:h,uniform:t.getUniformLocation(n,h,u),offset:t.getUniformLocation(n,`offset${h}`,u)};e.enableShapeUniforms&&(d.shape=t.getUniformLocation(n,`${h}Shape`,u),d.texShape=t.getUniformLocation(n,`${h}TexShape`,u)),s.push(d)}if(e.enableShapeUniforms&&(o=t.getUniformLocation(n,"outShape",u),a=t.getUniformLocation(n,"outShapeStrides",u),i=t.getUniformLocation(n,"outTexShape",u)),e.customUniforms)for(const h of e.customUniforms)r.push(t.getUniformLocation(n,h.name,u));return{variablesLocations:s,customUniformLocations:r,infLoc:l,nanLoc:c,outShapeLocation:o,outShapeStridesLocation:a,outTexShapeLocation:i}}function Ik(t,e){if(t.length!==e.length)throw Error(`Binary was compiled with ${t.length} inputs, but was executed with ${e.length} inputs`);t.forEach((n,s)=>{const r=n.logicalShape,o=e[s],i=o.shape;if(!Ue(r,i))throw Error(`Binary was compiled with different shapes than the current args. Shapes ${r} and ${i} must match`);if(n.isUniform&&o.isUniform)return;const a=n.texShape,l=o.isUniform?null:o.texData.texShape;if(!Ue(a,l))throw Error(`Binary was compiled with different texture shapes than the current args. Shape ${a} and ${l} must match`)})}function CY(t,e,n,s,r){e.program.enableShapeUniforms||(Ik(e.inShapeInfos,n),Ik([e.outShapeInfo],[s]));const o=s.texData.texture,i=s.texData.texShape;s.texData.isPacked?t.setOutputPackedMatrixTexture(o.texture,i[0],i[1]):t.setOutputMatrixTexture(o.texture,i[0],i[1]),t.setProgram(e.webGLProgram),t.bindVertexArray(e.webGLProgram.vao),W().getNumber("WEBGL_VERSION")===1&&e.infLoc!==null&&t.gl.uniform1f(e.infLoc,1/0),e.nanLoc!==null&&t.gl.uniform1f(e.nanLoc,NaN);for(let l=0;l{const a=i.texData!=null&&i.texData.slice!=null&&i.texData.slice.flatOffset>0;if(t.enableShapeUniforms&&!i.isUniform){const l=i.texData.texShape,{useSqueezeShape:c,uniformShape:u,keptDims:h}=kv(t.packedInputs,i.shape,l);let d="",f="",p="";if(u.length===1&&t.packedInputs){const b=[Math.ceil(l[0]/2),Math.ceil(l[1]/2)];d=`${b[0]>1}_${b[1]>1}`}else if(u.length===2&&!t.packedInputs)f=`${u[0]>1}_${u[1]>1}`;else if(u.length>2&&!t.packedInputs){const b=pe(u);p=`${b[0]===l[1]}_${b[b.length-1]===l[1]}`}const g=i.shape.length,x=u.length===2&&Ue(i.shape,l),m=j(i.shape)===1,y=il(i.shape,n.shape),w=!t.packedInputs&&g===n.shape.length&&Ue(l,n.texData.texShape),v=t.packedInputs||u.length>2?"":`${l[0]>1}_${l[1]>1}`;s+=`${g}_${w}_${c?h:""}_${u.length}_${m}_${y}_${x}_${d}_${f}_${p}_${v}_${a}`}else{const l=i.isUniform?"uniform":i.texData.texShape;s+=`${i.shape}_${l}_${a}`}});const r=t.userCode;let o=t.constructor.name;return o+="_"+s+"_"+r+`${W().getNumber("WEBGL_VERSION")}`,o}function pn(t){return W().getBool("WEBGL_USE_SHAPES_UNIFORMS")&&t<=4}/** * @license * Copyright 2019 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -12278,7 +12278,7 @@ vec2 packedUVfrom3D(int texNumR, int texNumC, * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */class IY{constructor(e){this.variableNames=["A"],this.packedInputs=!1,this.packedOutput=!0,this.outPackingScheme=eu.DENSE,this.customUniforms=[{name:"texShape",type:"ivec2"}];const n=$n();this.outputShape=e,this.enableShapeUniforms=pn(this.outputShape.length),this.userCode=` + */class SY{constructor(e){this.variableNames=["A"],this.packedInputs=!1,this.packedOutput=!0,this.outPackingScheme=eu.DENSE,this.customUniforms=[{name:"texShape",type:"ivec2"}];const n=$n();this.outputShape=e,this.enableShapeUniforms=pn(this.outputShape.length),this.userCode=` ivec3 outCoordsFromFlatIndex(int index) { ${this.enableShapeUniforms?Mm(["r","c","d"],e):ea(["r","c","d"],e)} return ivec3(r, c, d); @@ -12313,7 +12313,7 @@ vec2 packedUVfrom3D(int texNumR, int texNumC, * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */class $Y{constructor(e){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outPackingScheme=eu.DENSE,this.customUniforms=[{name:"texShape",type:"ivec2"}];const n=$n();this.outputShape=e,this.enableShapeUniforms=pn(this.outputShape.length),this.userCode=` + */class IY{constructor(e){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outPackingScheme=eu.DENSE,this.customUniforms=[{name:"texShape",type:"ivec2"}];const n=$n();this.outputShape=e,this.enableShapeUniforms=pn(this.outputShape.length),this.userCode=` ivec3 outCoordsFromFlatIndex(int index) { ${this.enableShapeUniforms?Mm(["r","c","d"],e):ea(["r","c","d"],e)} return ivec3(r, c, d); @@ -12348,7 +12348,7 @@ vec2 packedUVfrom3D(int texNumR, int texNumC, * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */class NY{constructor(e){this.variableNames=["A"],this.outTexUsage=ns.DOWNLOAD;const n=$n();this.outputShape=e,this.userCode=` + */class $Y{constructor(e){this.variableNames=["A"],this.outTexUsage=ns.DOWNLOAD;const n=$n();this.outputShape=e,this.userCode=` ${WA} void main() { @@ -12370,7 +12370,7 @@ vec2 packedUVfrom3D(int texNumR, int texNumC, * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */class TY{constructor(e){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!1,this.outTexUsage=ns.DOWNLOAD;const n=$n();this.outputShape=e,this.userCode=` + */class NY{constructor(e){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!1,this.outTexUsage=ns.DOWNLOAD;const n=$n();this.outputShape=e,this.userCode=` ${WA} void main() { @@ -12393,9 +12393,9 @@ vec2 packedUVfrom3D(int texNumR, int texNumC, * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const EY={R:0,G:1,B:2,A:3};class $k{constructor(e,n=!1,s="RGBA"){this.variableNames=["A"],this.customUniforms=[{name:"texShape",type:"ivec2"}];const r=$n();this.outputShape=e,this.enableShapeUniforms=pn(this.outputShape.length);let o="result";n&&(o="floor(result * 255. + 0.5)");let i="";for(let a=0;at.bindTexture(a,i)),ae(t,()=>t.texParameteri(a,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE)),ae(t,()=>t.texParameteri(a,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE)),ae(t,()=>t.texParameteri(a,t.TEXTURE_MIN_FILTER,t.NEAREST)),ae(t,()=>t.texParameteri(a,t.TEXTURE_MAG_FILTER,t.NEAREST)),W().getNumber("WEBGL_VERSION")===1?ae(t,()=>t.texImage2D(a,0,s,e,n,0,r,o,null)):ae(t,()=>t.texStorage2D(a,1,s,e,n)),ae(t,()=>t.bindTexture(t.TEXTURE_2D,null)),{texture:i,texShape:[n,e]}}function KA(t){return t.internalFormatFloat}function FY(t,e,n,s){const[r,o]=Th(e,n);return Rh(t,r,o,KA(s),s.textureFormatFloat,t.FLOAT)}function XA(t){return t.internalFormatHalfFloat}function zY(t,e,n,s){const[r,o]=Th(e,n);return Rh(t,r,o,XA(s),s.textureFormatFloat,s.textureTypeHalfFloat)}function qA(t){return t.downloadTextureFormat}function OY(t,e,n,s){const[r,o]=Th(e,n);return Rh(t,r,o,qA(s),t.RGBA,t.UNSIGNED_BYTE)}function YA(t){return t.internalFormatPackedFloat}function MY(t,e,n,s){const[r,o]=Nl(e,n);return Rh(t,r,o,YA(s),t.RGBA,t.FLOAT)}function QA(t){return t.internalFormatPackedHalfFloat}function PY(t,e,n,s){const[r,o]=Nl(e,n);return Rh(t,r,o,QA(s),t.RGBA,s.textureTypeHalfFloat)}function LY(t,e,n){return ae(t,()=>t.bindBuffer(t.ARRAY_BUFFER,n)),Ck(t,e,"clipSpacePos",n,3,20,0)&&Ck(t,e,"uv",n,2,20,12)}function BY(t,e,n,s,r,o){ae(t,()=>t.bindTexture(t.TEXTURE_2D,e));let i,a,l;r instanceof Uint8Array?(i=new Uint8Array(n*s*4),a=t.UNSIGNED_BYTE,l=t.RGBA):(i=new Float32Array(n*s*4),a=t.FLOAT,l=o.internalFormatPackedFloat),i.set(r),W().getNumber("WEBGL_VERSION")===2?ae(t,()=>t.texSubImage2D(t.TEXTURE_2D,0,0,0,n,s,t.RGBA,a,i)):ae(t,()=>t.texImage2D(t.TEXTURE_2D,0,l,n,s,0,t.RGBA,a,i)),ae(t,()=>t.bindTexture(t.TEXTURE_2D,null))}function VY(t,e,n){ae(t,()=>t.bindTexture(t.TEXTURE_2D,e)),n.data instanceof Uint8Array?W().getNumber("WEBGL_VERSION")===2?ae(t,()=>t.texSubImage2D(t.TEXTURE_2D,0,0,0,n.width,n.height,t.RGBA,t.UNSIGNED_BYTE,n.data)):ae(t,()=>t.texImage2D(t.TEXTURE_2D,0,t.RGBA,n.width,n.height,0,t.RGBA,t.UNSIGNED_BYTE,n.data)):W().getNumber("WEBGL_VERSION")===2?ae(t,()=>t.texSubImage2D(t.TEXTURE_2D,0,0,0,t.RGBA,t.UNSIGNED_BYTE,n)):ae(t,()=>t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,n)),ae(t,()=>t.bindTexture(t.TEXTURE_2D,null))}function WY(t,e,n,s){const r=t.createBuffer();ae(t,()=>t.bindBuffer(t.PIXEL_PACK_BUFFER,r));const a=4*4*e*n;return ae(t,()=>t.bufferData(t.PIXEL_PACK_BUFFER,a,t.STREAM_READ)),ae(t,()=>t.readPixels(0,0,n,e,t.RGBA,t.FLOAT,0)),ae(t,()=>t.bindBuffer(t.PIXEL_PACK_BUFFER,null)),r}function UY(t,e,n){const s=t,r=new Float32Array(n);return s.bindBuffer(s.PIXEL_PACK_BUFFER,e),s.getBufferSubData(s.PIXEL_PACK_BUFFER,0,r),s.bindBuffer(s.PIXEL_PACK_BUFFER,null),r}function GY(t,e,n,s){const[r,o]=Th(e,n),i=4,a=new Uint8Array(a9(e*n,i));return ae(t,()=>t.readPixels(0,0,r,o,s.downloadTextureFormat,t.UNSIGNED_BYTE,a)),new Float32Array(a.buffer)}function HY(t,e,n,s,r,o,i,a){const l=t,c=new Float32Array(l9(o,i));return l.bindBuffer(l.PIXEL_PACK_BUFFER,e),l.getBufferSubData(l.PIXEL_PACK_BUFFER,0,c),l.bindBuffer(l.PIXEL_PACK_BUFFER,null),c}function jY(t,e,n){const s=new Float32Array(e*n*4);return ae(t,()=>t.readPixels(0,0,n,e,t.RGBA,t.FLOAT,s)),s}/** + }`;return f9(t,n)}function AY(t){const e=new Float32Array([-1,1,0,0,1,-1,-1,0,0,0,1,1,0,1,1,1,-1,0,1,0]);return y9(t,e)}function DY(t){const e=new Uint16Array([0,1,2,2,1,3]);return w9(t,e)}function Eh(t,e,n,s,r,o){b9(e,n);const i=v9(t),a=t.TEXTURE_2D;return ae(t,()=>t.bindTexture(a,i)),ae(t,()=>t.texParameteri(a,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE)),ae(t,()=>t.texParameteri(a,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE)),ae(t,()=>t.texParameteri(a,t.TEXTURE_MIN_FILTER,t.NEAREST)),ae(t,()=>t.texParameteri(a,t.TEXTURE_MAG_FILTER,t.NEAREST)),W().getNumber("WEBGL_VERSION")===1?ae(t,()=>t.texImage2D(a,0,s,e,n,0,r,o,null)):ae(t,()=>t.texStorage2D(a,1,s,e,n)),ae(t,()=>t.bindTexture(t.TEXTURE_2D,null)),{texture:i,texShape:[n,e]}}function KA(t){return t.internalFormatFloat}function _Y(t,e,n,s){const[r,o]=Nh(e,n);return Eh(t,r,o,KA(s),s.textureFormatFloat,t.FLOAT)}function XA(t){return t.internalFormatHalfFloat}function FY(t,e,n,s){const[r,o]=Nh(e,n);return Eh(t,r,o,XA(s),s.textureFormatFloat,s.textureTypeHalfFloat)}function qA(t){return t.downloadTextureFormat}function zY(t,e,n,s){const[r,o]=Nh(e,n);return Eh(t,r,o,qA(s),t.RGBA,t.UNSIGNED_BYTE)}function YA(t){return t.internalFormatPackedFloat}function OY(t,e,n,s){const[r,o]=Nl(e,n);return Eh(t,r,o,YA(s),t.RGBA,t.FLOAT)}function QA(t){return t.internalFormatPackedHalfFloat}function MY(t,e,n,s){const[r,o]=Nl(e,n);return Eh(t,r,o,QA(s),t.RGBA,s.textureTypeHalfFloat)}function PY(t,e,n){return ae(t,()=>t.bindBuffer(t.ARRAY_BUFFER,n)),Ck(t,e,"clipSpacePos",n,3,20,0)&&Ck(t,e,"uv",n,2,20,12)}function LY(t,e,n,s,r,o){ae(t,()=>t.bindTexture(t.TEXTURE_2D,e));let i,a,l;r instanceof Uint8Array?(i=new Uint8Array(n*s*4),a=t.UNSIGNED_BYTE,l=t.RGBA):(i=new Float32Array(n*s*4),a=t.FLOAT,l=o.internalFormatPackedFloat),i.set(r),W().getNumber("WEBGL_VERSION")===2?ae(t,()=>t.texSubImage2D(t.TEXTURE_2D,0,0,0,n,s,t.RGBA,a,i)):ae(t,()=>t.texImage2D(t.TEXTURE_2D,0,l,n,s,0,t.RGBA,a,i)),ae(t,()=>t.bindTexture(t.TEXTURE_2D,null))}function BY(t,e,n){ae(t,()=>t.bindTexture(t.TEXTURE_2D,e)),n.data instanceof Uint8Array?W().getNumber("WEBGL_VERSION")===2?ae(t,()=>t.texSubImage2D(t.TEXTURE_2D,0,0,0,n.width,n.height,t.RGBA,t.UNSIGNED_BYTE,n.data)):ae(t,()=>t.texImage2D(t.TEXTURE_2D,0,t.RGBA,n.width,n.height,0,t.RGBA,t.UNSIGNED_BYTE,n.data)):W().getNumber("WEBGL_VERSION")===2?ae(t,()=>t.texSubImage2D(t.TEXTURE_2D,0,0,0,t.RGBA,t.UNSIGNED_BYTE,n)):ae(t,()=>t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,n)),ae(t,()=>t.bindTexture(t.TEXTURE_2D,null))}function VY(t,e,n,s){const r=t.createBuffer();ae(t,()=>t.bindBuffer(t.PIXEL_PACK_BUFFER,r));const a=4*4*e*n;return ae(t,()=>t.bufferData(t.PIXEL_PACK_BUFFER,a,t.STREAM_READ)),ae(t,()=>t.readPixels(0,0,n,e,t.RGBA,t.FLOAT,0)),ae(t,()=>t.bindBuffer(t.PIXEL_PACK_BUFFER,null)),r}function WY(t,e,n){const s=t,r=new Float32Array(n);return s.bindBuffer(s.PIXEL_PACK_BUFFER,e),s.getBufferSubData(s.PIXEL_PACK_BUFFER,0,r),s.bindBuffer(s.PIXEL_PACK_BUFFER,null),r}function UY(t,e,n,s){const[r,o]=Nh(e,n),i=4,a=new Uint8Array(i9(e*n,i));return ae(t,()=>t.readPixels(0,0,r,o,s.downloadTextureFormat,t.UNSIGNED_BYTE,a)),new Float32Array(a.buffer)}function GY(t,e,n,s,r,o,i,a){const l=t,c=new Float32Array(a9(o,i));return l.bindBuffer(l.PIXEL_PACK_BUFFER,e),l.getBufferSubData(l.PIXEL_PACK_BUFFER,0,c),l.bindBuffer(l.PIXEL_PACK_BUFFER,null),c}function HY(t,e,n){const s=new Float32Array(e*n*4);return ae(t,()=>t.readPixels(0,0,n,e,t.RGBA,t.FLOAT,s)),s}/** * @license * Copyright 2017 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -12514,7 +12514,7 @@ vec2 packedUVfrom3D(int texNumR, int texNumC, * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */class Og{constructor(e){this.outputTexture=null,this.program=null,this.disposed=!1,this.itemsToPoll=[];const n=W().getNumber("WEBGL_VERSION");if(e!=null?(this.gl=e,r9(n,e)):this.gl=tr(n),e=this.gl,W().getNumber("WEBGL_VERSION")===2){const o=e;this.createVertexArray=()=>ae(o,()=>o.createVertexArray()),this.bindVertexArray=i=>ae(o,()=>o.bindVertexArray(i)),this.deleteVertexArray=i=>ae(o,()=>o.deleteVertexArray(i)),this.getVertexArray=()=>ae(o,()=>o.getParameter(o.VERTEX_ARRAY_BINDING))}else if(e!=null){const o=e.getExtension("OES_vertex_array_object");if(o==null)throw new Error("All WebGL1 implementations are expected to offer OES_vertex_array_object.");this.createVertexArray=()=>ae(e,()=>o.createVertexArrayOES()),this.bindVertexArray=i=>ae(e,()=>o.bindVertexArrayOES(i)),this.deleteVertexArray=i=>ae(e,()=>o.deleteVertexArrayOES(i)),this.getVertexArray=()=>ae(e,()=>e.getParameter(o.VERTEX_ARRAY_BINDING_OES))}let s="WEBGL_color_buffer_float";const r="EXT_color_buffer_half_float";if(this.parallelCompilationExtension=this.gl.getExtension("KHR_parallel_shader_compile"),W().getNumber("WEBGL_VERSION")===1){const o="OES_texture_float",i="OES_texture_half_float";if(this.textureFloatExtension=id(this.gl,o),Ss(this.gl,i))this.textureHalfFloatExtension=id(this.gl,i);else if(W().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(s),Ss(this.gl,r))this.colorBufferHalfFloatExtension=id(this.gl,r);else if(W().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(s="EXT_color_buffer_float",Ss(this.gl,s))this.colorBufferFloatExtension=this.gl.getExtension(s);else if(Ss(this.gl,r))this.colorBufferHalfFloatExtension=this.gl.getExtension(r);else throw new Error("GL context does not support color renderable floats");this.vertexBuffer=DY(this.gl),this.indexBuffer=_Y(this.gl),this.framebuffer=k9(this.gl),this.textureConfig=vv(this.gl,this.textureHalfFloatExtension)}get debug(){return W().getBool("DEBUG")}dispose(){if(this.disposed)return;this.program!=null&&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."),this.outputTexture!=null&&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;ae(e,()=>e.finish()),ae(e,()=>e.bindFramebuffer(e.FRAMEBUFFER,null)),ae(e,()=>e.deleteFramebuffer(this.framebuffer)),ae(e,()=>e.bindBuffer(e.ARRAY_BUFFER,null)),ae(e,()=>e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,null)),ae(e,()=>e.deleteBuffer(this.indexBuffer)),this.disposed=!0}createFloat32MatrixTexture(e,n){return this.throwIfDisposed(),FY(this.gl,e,n,this.textureConfig)}createFloat16MatrixTexture(e,n){return this.throwIfDisposed(),zY(this.gl,e,n,this.textureConfig)}createUnsignedBytesMatrixTexture(e,n){return this.throwIfDisposed(),OY(this.gl,e,n,this.textureConfig)}uploadPixelDataToTexture(e,n){this.throwIfDisposed(),VY(this.gl,e,n)}uploadDenseMatrixToTexture(e,n,s,r){this.throwIfDisposed(),BY(this.gl,e,n,s,r,this.textureConfig)}createFloat16PackedMatrixTexture(e,n){return this.throwIfDisposed(),PY(this.gl,e,n,this.textureConfig)}createPackedMatrixTexture(e,n){return this.throwIfDisposed(),MY(this.gl,e,n,this.textureConfig)}deleteMatrixTexture(e){this.throwIfDisposed(),this.outputTexture===e&&(kk(this.gl,this.framebuffer),this.outputTexture=null),ae(this.gl,()=>this.gl.deleteTexture(e))}downloadByteEncodedFloatMatrixFromOutputTexture(e,n,s){return this.downloadMatrixDriver(e,()=>GY(this.gl,n,s,this.textureConfig))}downloadPackedMatrixFromBuffer(e,n,s,r,o,i){return HY(this.gl,e,n,s,r,o,i,this.textureConfig)}downloadFloat32MatrixFromBuffer(e,n){return UY(this.gl,e,n)}createBufferFromTexture(e,n,s){this.bindTextureToFrameBuffer(e);const r=WY(this.gl,n,s,this.textureConfig);return this.unbindTextureToFrameBuffer(),r}createAndWaitForFence(){const e=this.createFence(this.gl);return this.pollFence(e)}createFence(e){let n,s;if(W().getBool("WEBGL_FENCE_API_ENABLED")){const r=e,o=r.fenceSync(r.SYNC_GPU_COMMANDS_COMPLETE,0);e.flush(),s=()=>{const i=r.clientWaitSync(o,0,0);return i===r.ALREADY_SIGNALED||i===r.CONDITION_SATISFIED},n=o}else W().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")>0?(n=this.beginQuery(),this.endQuery(),s=()=>this.isQueryAvailable(n,W().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION"))):s=()=>!0;return{query:n,isFencePassed:s}}downloadMatrixFromPackedTexture(e,n,s){return this.downloadMatrixDriver(e,()=>jY(this.gl,n,s))}createProgram(e){this.throwIfDisposed();const n=this.gl;this.vertexShader==null&&(this.vertexShader=AY(n));const s=x9(n);ae(n,()=>n.attachShader(s,this.vertexShader)),ae(n,()=>n.attachShader(s,e)),y9(n,s);const r=Object.assign(s,{vao:this.createVertexArray()});return this.debug&&Dg(n,r),r}buildVao(e){this.setProgram(e),this.bindVertexArray(e.vao);const n=this.gl;ae(n,()=>n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,this.indexBuffer)),LY(n,e,this.vertexBuffer)}deleteProgram(e){this.throwIfDisposed(),e===this.program&&(this.program=null),e!=null&&(ae(this.gl,()=>this.gl.deleteProgram(e)),this.deleteVertexArray(e.vao))}setProgram(e){this.throwIfDisposed(),this.program=e,this.program!=null&&this.debug&&Dg(this.gl,this.program),ae(this.gl,()=>this.gl.useProgram(e))}getUniformLocation(e,n,s=!0){return this.throwIfDisposed(),s?I9(this.gl,e,n):$9(this.gl,e,n)}getAttributeLocation(e,n){return this.throwIfDisposed(),ae(this.gl,()=>this.gl.getAttribLocation(e,n))}getUniformLocationNoThrow(e,n){return this.throwIfDisposed(),this.gl.getUniformLocation(e,n)}setInputMatrixTexture(e,n,s){this.throwIfDisposed(),this.throwIfNoProgram(),N9(this.gl,e,n,s)}setOutputMatrixTexture(e,n,s){this.setOutputMatrixTextureDriver(e,s,n)}setOutputPackedMatrixTexture(e,n,s){this.throwIfDisposed();const[r,o]=Nl(n,s);this.setOutputMatrixTextureDriver(e,r,o)}setOutputMatrixWriteRegion(e,n,s,r){this.setOutputMatrixWriteRegionDriver(s,e,r,n)}setOutputPackedMatrixWriteRegion(e,n,s,r){throw new Error("setOutputPackedMatrixWriteRegion not implemented.")}debugValidate(){this.program!=null&&Dg(this.gl,this.program),ad(this.gl)}executeProgram(){this.throwIfDisposed(),this.throwIfNoProgram();const e=this.gl;if(this.debug){const n=this.getVertexArray();console.assert(n===this.program.vao,"VAO changed between setProgram and executeProgram!"),this.debugValidate()}ae(e,()=>e.drawElements(e.TRIANGLES,6,e.UNSIGNED_SHORT,0))}blockUntilAllProgramsCompleted(){this.throwIfDisposed(),ae(this.gl,()=>this.gl.finish())}getQueryTimerExtension(){return this.disjointQueryTimerExtension==null&&(this.disjointQueryTimerExtension=id(this.gl,W().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")===2?"EXT_disjoint_timer_query_webgl2":"EXT_disjoint_timer_query")),this.disjointQueryTimerExtension}getQueryTimerExtensionWebGL2(){return this.getQueryTimerExtension()}getQueryTimerExtensionWebGL1(){return this.getQueryTimerExtension()}beginQuery(){if(W().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")===2){const s=this.gl,r=this.getQueryTimerExtensionWebGL2(),o=s.createQuery();return s.beginQuery(r.TIME_ELAPSED_EXT,o),o}const e=this.getQueryTimerExtensionWebGL1(),n=e.createQueryEXT();return e.beginQueryEXT(e.TIME_ELAPSED_EXT,n),n}endQuery(){if(W().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")===2){const n=this.gl,s=this.getQueryTimerExtensionWebGL2();n.endQuery(s.TIME_ELAPSED_EXT);return}const e=this.getQueryTimerExtensionWebGL1();e.endQueryEXT(e.TIME_ELAPSED_EXT)}async waitForQueryAndGetTime(e){return await uC(()=>this.disposed||this.isQueryAvailable(e,W().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION"))),this.getQueryTime(e,W().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION"))}getQueryTime(e,n){if(n===0)return null;if(n===2){const s=this.gl;return s.getQueryParameter(e,s.QUERY_RESULT)/1e6}else{const s=this.getQueryTimerExtensionWebGL1();return s.getQueryObjectEXT(e,s.QUERY_RESULT_EXT)/1e6}}isQueryAvailable(e,n){if(n===0)return!0;if(n===2){const s=this.gl,r=this.getQueryTimerExtensionWebGL2(),o=s.getQueryParameter(e,s.QUERY_RESULT_AVAILABLE);return this.disjoint==null&&(this.disjoint=this.gl.getParameter(r.GPU_DISJOINT_EXT)),o&&!this.disjoint}else{const s=this.getQueryTimerExtensionWebGL1(),r=s.getQueryObjectEXT(e,s.QUERY_RESULT_AVAILABLE_EXT);return this.disjoint==null&&(this.disjoint=this.gl.getParameter(s.GPU_DISJOINT_EXT)),r&&!this.disjoint}}pollFence(e){return new Promise(n=>{this.addItemToPoll(()=>e.isFencePassed(),()=>n())})}pollItems(){const e=KY(this.itemsToPoll.map(n=>n.isDoneFn));for(let n=0;n<=e;++n){const{resolveFn:s}=this.itemsToPoll[n];s()}this.itemsToPoll=this.itemsToPoll.slice(e+1)}addItemToPoll(e,n){if(this.itemsToPoll.push({isDoneFn:e,resolveFn:n}),this.itemsToPoll.length>1)return;let s;"setTimeoutCustom"in W().platform&&(s=W().platform.setTimeoutCustom.bind(W().platform)),uC(()=>(this.pollItems(),this.itemsToPoll.length===0),()=>0,null,s)}bindTextureToFrameBuffer(e){this.throwIfDisposed(),_g(this.gl,e,this.framebuffer),this.debug&&ad(this.gl)}unbindTextureToFrameBuffer(){this.outputTexture!=null?(_g(this.gl,this.outputTexture,this.framebuffer),this.debug&&ad(this.gl)):kk(this.gl,this.framebuffer)}downloadMatrixDriver(e,n){this.bindTextureToFrameBuffer(e);const s=n();return this.unbindTextureToFrameBuffer(),s}setOutputMatrixTextureDriver(e,n,s){this.throwIfDisposed();const r=this.gl;_g(r,e,this.framebuffer),this.debug&&ad(r),this.outputTexture=e,ae(r,()=>r.viewport(0,0,n,s)),ae(r,()=>r.scissor(0,0,n,s))}setOutputMatrixWriteRegionDriver(e,n,s,r){this.throwIfDisposed(),ae(this.gl,()=>this.gl.scissor(e,n,s,r))}throwIfDisposed(){if(this.disposed)throw new Error("Attempted to use disposed GPGPUContext.")}throwIfNoProgram(){if(this.program==null)throw new Error("No GPU program is currently set.")}}function KY(t){let e=0;for(;eae(o,()=>o.createVertexArray()),this.bindVertexArray=i=>ae(o,()=>o.bindVertexArray(i)),this.deleteVertexArray=i=>ae(o,()=>o.deleteVertexArray(i)),this.getVertexArray=()=>ae(o,()=>o.getParameter(o.VERTEX_ARRAY_BINDING))}else if(e!=null){const o=e.getExtension("OES_vertex_array_object");if(o==null)throw new Error("All WebGL1 implementations are expected to offer OES_vertex_array_object.");this.createVertexArray=()=>ae(e,()=>o.createVertexArrayOES()),this.bindVertexArray=i=>ae(e,()=>o.bindVertexArrayOES(i)),this.deleteVertexArray=i=>ae(e,()=>o.deleteVertexArrayOES(i)),this.getVertexArray=()=>ae(e,()=>e.getParameter(o.VERTEX_ARRAY_BINDING_OES))}let s="WEBGL_color_buffer_float";const r="EXT_color_buffer_half_float";if(this.parallelCompilationExtension=this.gl.getExtension("KHR_parallel_shader_compile"),W().getNumber("WEBGL_VERSION")===1){const o="OES_texture_float",i="OES_texture_half_float";if(this.textureFloatExtension=od(this.gl,o),Ss(this.gl,i))this.textureHalfFloatExtension=od(this.gl,i);else if(W().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(s),Ss(this.gl,r))this.colorBufferHalfFloatExtension=od(this.gl,r);else if(W().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(s="EXT_color_buffer_float",Ss(this.gl,s))this.colorBufferFloatExtension=this.gl.getExtension(s);else if(Ss(this.gl,r))this.colorBufferHalfFloatExtension=this.gl.getExtension(r);else throw new Error("GL context does not support color renderable floats");this.vertexBuffer=AY(this.gl),this.indexBuffer=DY(this.gl),this.framebuffer=C9(this.gl),this.textureConfig=vv(this.gl,this.textureHalfFloatExtension)}get debug(){return W().getBool("DEBUG")}dispose(){if(this.disposed)return;this.program!=null&&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."),this.outputTexture!=null&&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;ae(e,()=>e.finish()),ae(e,()=>e.bindFramebuffer(e.FRAMEBUFFER,null)),ae(e,()=>e.deleteFramebuffer(this.framebuffer)),ae(e,()=>e.bindBuffer(e.ARRAY_BUFFER,null)),ae(e,()=>e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,null)),ae(e,()=>e.deleteBuffer(this.indexBuffer)),this.disposed=!0}createFloat32MatrixTexture(e,n){return this.throwIfDisposed(),_Y(this.gl,e,n,this.textureConfig)}createFloat16MatrixTexture(e,n){return this.throwIfDisposed(),FY(this.gl,e,n,this.textureConfig)}createUnsignedBytesMatrixTexture(e,n){return this.throwIfDisposed(),zY(this.gl,e,n,this.textureConfig)}uploadPixelDataToTexture(e,n){this.throwIfDisposed(),BY(this.gl,e,n)}uploadDenseMatrixToTexture(e,n,s,r){this.throwIfDisposed(),LY(this.gl,e,n,s,r,this.textureConfig)}createFloat16PackedMatrixTexture(e,n){return this.throwIfDisposed(),MY(this.gl,e,n,this.textureConfig)}createPackedMatrixTexture(e,n){return this.throwIfDisposed(),OY(this.gl,e,n,this.textureConfig)}deleteMatrixTexture(e){this.throwIfDisposed(),this.outputTexture===e&&(kk(this.gl,this.framebuffer),this.outputTexture=null),ae(this.gl,()=>this.gl.deleteTexture(e))}downloadByteEncodedFloatMatrixFromOutputTexture(e,n,s){return this.downloadMatrixDriver(e,()=>UY(this.gl,n,s,this.textureConfig))}downloadPackedMatrixFromBuffer(e,n,s,r,o,i){return GY(this.gl,e,n,s,r,o,i,this.textureConfig)}downloadFloat32MatrixFromBuffer(e,n){return WY(this.gl,e,n)}createBufferFromTexture(e,n,s){this.bindTextureToFrameBuffer(e);const r=VY(this.gl,n,s,this.textureConfig);return this.unbindTextureToFrameBuffer(),r}createAndWaitForFence(){const e=this.createFence(this.gl);return this.pollFence(e)}createFence(e){let n,s;if(W().getBool("WEBGL_FENCE_API_ENABLED")){const r=e,o=r.fenceSync(r.SYNC_GPU_COMMANDS_COMPLETE,0);e.flush(),s=()=>{const i=r.clientWaitSync(o,0,0);return i===r.ALREADY_SIGNALED||i===r.CONDITION_SATISFIED},n=o}else W().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")>0?(n=this.beginQuery(),this.endQuery(),s=()=>this.isQueryAvailable(n,W().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION"))):s=()=>!0;return{query:n,isFencePassed:s}}downloadMatrixFromPackedTexture(e,n,s){return this.downloadMatrixDriver(e,()=>HY(this.gl,n,s))}createProgram(e){this.throwIfDisposed();const n=this.gl;this.vertexShader==null&&(this.vertexShader=RY(n));const s=g9(n);ae(n,()=>n.attachShader(s,this.vertexShader)),ae(n,()=>n.attachShader(s,e)),x9(n,s);const r=Object.assign(s,{vao:this.createVertexArray()});return this.debug&&Dg(n,r),r}buildVao(e){this.setProgram(e),this.bindVertexArray(e.vao);const n=this.gl;ae(n,()=>n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,this.indexBuffer)),PY(n,e,this.vertexBuffer)}deleteProgram(e){this.throwIfDisposed(),e===this.program&&(this.program=null),e!=null&&(ae(this.gl,()=>this.gl.deleteProgram(e)),this.deleteVertexArray(e.vao))}setProgram(e){this.throwIfDisposed(),this.program=e,this.program!=null&&this.debug&&Dg(this.gl,this.program),ae(this.gl,()=>this.gl.useProgram(e))}getUniformLocation(e,n,s=!0){return this.throwIfDisposed(),s?S9(this.gl,e,n):I9(this.gl,e,n)}getAttributeLocation(e,n){return this.throwIfDisposed(),ae(this.gl,()=>this.gl.getAttribLocation(e,n))}getUniformLocationNoThrow(e,n){return this.throwIfDisposed(),this.gl.getUniformLocation(e,n)}setInputMatrixTexture(e,n,s){this.throwIfDisposed(),this.throwIfNoProgram(),$9(this.gl,e,n,s)}setOutputMatrixTexture(e,n,s){this.setOutputMatrixTextureDriver(e,s,n)}setOutputPackedMatrixTexture(e,n,s){this.throwIfDisposed();const[r,o]=Nl(n,s);this.setOutputMatrixTextureDriver(e,r,o)}setOutputMatrixWriteRegion(e,n,s,r){this.setOutputMatrixWriteRegionDriver(s,e,r,n)}setOutputPackedMatrixWriteRegion(e,n,s,r){throw new Error("setOutputPackedMatrixWriteRegion not implemented.")}debugValidate(){this.program!=null&&Dg(this.gl,this.program),id(this.gl)}executeProgram(){this.throwIfDisposed(),this.throwIfNoProgram();const e=this.gl;if(this.debug){const n=this.getVertexArray();console.assert(n===this.program.vao,"VAO changed between setProgram and executeProgram!"),this.debugValidate()}ae(e,()=>e.drawElements(e.TRIANGLES,6,e.UNSIGNED_SHORT,0))}blockUntilAllProgramsCompleted(){this.throwIfDisposed(),ae(this.gl,()=>this.gl.finish())}getQueryTimerExtension(){return this.disjointQueryTimerExtension==null&&(this.disjointQueryTimerExtension=od(this.gl,W().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")===2?"EXT_disjoint_timer_query_webgl2":"EXT_disjoint_timer_query")),this.disjointQueryTimerExtension}getQueryTimerExtensionWebGL2(){return this.getQueryTimerExtension()}getQueryTimerExtensionWebGL1(){return this.getQueryTimerExtension()}beginQuery(){if(W().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")===2){const s=this.gl,r=this.getQueryTimerExtensionWebGL2(),o=s.createQuery();return s.beginQuery(r.TIME_ELAPSED_EXT,o),o}const e=this.getQueryTimerExtensionWebGL1(),n=e.createQueryEXT();return e.beginQueryEXT(e.TIME_ELAPSED_EXT,n),n}endQuery(){if(W().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")===2){const n=this.gl,s=this.getQueryTimerExtensionWebGL2();n.endQuery(s.TIME_ELAPSED_EXT);return}const e=this.getQueryTimerExtensionWebGL1();e.endQueryEXT(e.TIME_ELAPSED_EXT)}async waitForQueryAndGetTime(e){return await uC(()=>this.disposed||this.isQueryAvailable(e,W().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION"))),this.getQueryTime(e,W().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION"))}getQueryTime(e,n){if(n===0)return null;if(n===2){const s=this.gl;return s.getQueryParameter(e,s.QUERY_RESULT)/1e6}else{const s=this.getQueryTimerExtensionWebGL1();return s.getQueryObjectEXT(e,s.QUERY_RESULT_EXT)/1e6}}isQueryAvailable(e,n){if(n===0)return!0;if(n===2){const s=this.gl,r=this.getQueryTimerExtensionWebGL2(),o=s.getQueryParameter(e,s.QUERY_RESULT_AVAILABLE);return this.disjoint==null&&(this.disjoint=this.gl.getParameter(r.GPU_DISJOINT_EXT)),o&&!this.disjoint}else{const s=this.getQueryTimerExtensionWebGL1(),r=s.getQueryObjectEXT(e,s.QUERY_RESULT_AVAILABLE_EXT);return this.disjoint==null&&(this.disjoint=this.gl.getParameter(s.GPU_DISJOINT_EXT)),r&&!this.disjoint}}pollFence(e){return new Promise(n=>{this.addItemToPoll(()=>e.isFencePassed(),()=>n())})}pollItems(){const e=jY(this.itemsToPoll.map(n=>n.isDoneFn));for(let n=0;n<=e;++n){const{resolveFn:s}=this.itemsToPoll[n];s()}this.itemsToPoll=this.itemsToPoll.slice(e+1)}addItemToPoll(e,n){if(this.itemsToPoll.push({isDoneFn:e,resolveFn:n}),this.itemsToPoll.length>1)return;let s;"setTimeoutCustom"in W().platform&&(s=W().platform.setTimeoutCustom.bind(W().platform)),uC(()=>(this.pollItems(),this.itemsToPoll.length===0),()=>0,null,s)}bindTextureToFrameBuffer(e){this.throwIfDisposed(),_g(this.gl,e,this.framebuffer),this.debug&&id(this.gl)}unbindTextureToFrameBuffer(){this.outputTexture!=null?(_g(this.gl,this.outputTexture,this.framebuffer),this.debug&&id(this.gl)):kk(this.gl,this.framebuffer)}downloadMatrixDriver(e,n){this.bindTextureToFrameBuffer(e);const s=n();return this.unbindTextureToFrameBuffer(),s}setOutputMatrixTextureDriver(e,n,s){this.throwIfDisposed();const r=this.gl;_g(r,e,this.framebuffer),this.debug&&id(r),this.outputTexture=e,ae(r,()=>r.viewport(0,0,n,s)),ae(r,()=>r.scissor(0,0,n,s))}setOutputMatrixWriteRegionDriver(e,n,s,r){this.throwIfDisposed(),ae(this.gl,()=>this.gl.scissor(e,n,s,r))}throwIfDisposed(){if(this.disposed)throw new Error("Attempted to use disposed GPGPUContext.")}throwIfNoProgram(){if(this.program==null)throw new Error("No GPU program is currently set.")}}function jY(t){let e=0;for(;e`${t}.${n}`)}function vn(t,e){return e===1?[t]:tD(t,e)}function LQ(t,e){if(t===1)return"rc";let n="";for(let s=0;s`${t}.${n}`)}function vn(t,e){return e===1?[t]:tD(t,e)}function PQ(t,e){if(t===1)return"rc";let n="";for(let s=0;s0?"}":""} `}this.userCode=` - ${VQ(n,this.enableShapeUniforms)} + ${BQ(n,this.enableShapeUniforms)} ${this.enableShapeUniforms?Cv():bv(e)} void main() { @@ -12629,9 +12629,9 @@ vec2 packedUVfrom3D(int texNumR, int texNumC, setOutput(result); } - `}}function VQ(t,e){return` + `}}function BQ(t,e){return` ivec3 inputCoordsFromReshapedOutCoords(int index) { - ${e?L9(["r","c","d"],"inputShape"):ea(["r","c","d"],t)} + ${e?P9(["r","c","d"],"inputShape"):ea(["r","c","d"],t)} return ivec3(r, c, d); } `}/** @@ -12649,7 +12649,7 @@ vec2 packedUVfrom3D(int texNumR, int texNumC, * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */class WQ{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,n,s){const r=Tk(n,s),o=Ek(e,r,s);o in this.freeTextures||(this.freeTextures[o]=[]),o in this.usedTextures||(this.usedTextures[o]=[]);const i=Nk(e,r,this.gpgpu.gl,this.gpgpu.textureConfig,s);if(this.freeTextures[o].length>0){this.numFreeTextures--,this.numUsedTextures++,this._numBytesFree-=i,this.log();const l=this.freeTextures[o].pop();return this.usedTextures[o].push(l),l}let a;return r===Jt.PACKED_2X2_FLOAT32?a=this.gpgpu.createPackedMatrixTexture(e[0],e[1]):r===Jt.PACKED_2X2_FLOAT16?a=this.gpgpu.createFloat16PackedMatrixTexture(e[0],e[1]):r===Jt.UNPACKED_FLOAT32?a=this.gpgpu.createFloat32MatrixTexture(e[0],e[1]):r===Jt.UNPACKED_FLOAT16?a=this.gpgpu.createFloat16MatrixTexture(e[0],e[1]):r===Jt.PACKED_4X1_UNSIGNED_BYTE&&(a=this.gpgpu.createUnsignedBytesMatrixTexture(e[0],e[1])),this.usedTextures[o].push(a),this.numUsedTextures++,this._numBytesAllocated+=i,this.log(),a}releaseTexture(e,n,s,r){if(this.freeTextures==null)return;const o=Tk(s,r),i=Ek(n,o,r);i in this.freeTextures||(this.freeTextures[i]=[]);const a=Nk(n,o,this.gpgpu.gl,this.gpgpu.textureConfig,r),l=W().getNumber("WEBGL_DELETE_TEXTURE_THRESHOLD");l!==-1&&this._numBytesAllocated>l?(this.gpgpu.deleteMatrixTexture(e.texture),this._numBytesAllocated-=a):(this.freeTextures[i].push(e),this.numFreeTextures++,this._numBytesFree+=a),this.numUsedTextures--;const c=this.usedTextures[i],u=c&&c.indexOf(e);if(u==null||u<0)throw new Error("Cannot release a texture that was never provided by this texture manager");c[u]=c[c.length-1],c.pop(),this.log()}log(){if(!this.logEnabled)return;const e=this.numFreeTextures+this.numUsedTextures;console.log("Free/Used",`${this.numFreeTextures} / ${this.numUsedTextures}`,`(${e})`);const n=this._numBytesFree/this._numBytesAllocated;console.log(`Bytes allocated: ${this._numBytesAllocated}`),console.log(`Bytes unused: ${this._numBytesFree} (${Math.round(100*n)}%)`)}get numBytesAllocated(){return this._numBytesAllocated}get numBytesFree(){return this._numBytesFree}getNumUsedTextures(){return this.numUsedTextures}getNumFreeTextures(){return this.numFreeTextures}dispose(){if(this.freeTextures!=null){for(const e in this.freeTextures)this.freeTextures[e].forEach(n=>{this.gpgpu.deleteMatrixTexture(n.texture)});for(const e in this.usedTextures)this.usedTextures[e].forEach(n=>{this.gpgpu.deleteMatrixTexture(n.texture)});this.freeTextures=null,this.usedTextures=null,this.numUsedTextures=0,this.numFreeTextures=0,this._numBytesAllocated=0,this._numBytesFree=0}}}function UQ(t,e){const n=t;if(e===n.R32F)return 4;if(e===n.R16F)return 2;if(e===n.RGBA32F)return 16;if(e===t.RGBA)return 16;if(e===n.RGBA16F)return 8;if(e===n.RGBA8)return 4;throw new Error(`Unknown internal format ${e}`)}function Nk(t,e,n,s,r){const o=GQ(e,s);let i;if(r){const[l,c]=Nl(t[0],t[1]);i=l*c}else{const[l,c]=Th(t[0],t[1]);i=l*c}const a=UQ(n,o);return i*a}function GQ(t,e){switch(t){case Jt.PACKED_2X2_FLOAT32:return YA(e);case Jt.PACKED_2X2_FLOAT16:return QA(e);case Jt.UNPACKED_FLOAT32:return KA(e);case Jt.UNPACKED_FLOAT16:return XA(e);case Jt.PACKED_4X1_UNSIGNED_BYTE:return qA(e);default:throw new Error(`Unknown physical texture type ${t}`)}}function HQ(t){return W().getBool("WEBGL_RENDER_FLOAT32_ENABLED")?t?Jt.PACKED_2X2_FLOAT32:Jt.UNPACKED_FLOAT32:t?Jt.PACKED_2X2_FLOAT16:Jt.UNPACKED_FLOAT16}function Tk(t,e){if(t===ns.UPLOAD)return Jt.PACKED_2X2_FLOAT32;if(t===ns.RENDER||t==null)return HQ(e);if(t===ns.DOWNLOAD||t===ns.PIXELS)return Jt.PACKED_4X1_UNSIGNED_BYTE;throw new Error(`Unknown logical texture type ${t}`)}function Ek(t,e,n){return`${t[0]}_${t[1]}_${e}_${n}`}/** + */class VQ{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,n,s){const r=Tk(n,s),o=Ek(e,r,s);o in this.freeTextures||(this.freeTextures[o]=[]),o in this.usedTextures||(this.usedTextures[o]=[]);const i=Nk(e,r,this.gpgpu.gl,this.gpgpu.textureConfig,s);if(this.freeTextures[o].length>0){this.numFreeTextures--,this.numUsedTextures++,this._numBytesFree-=i,this.log();const l=this.freeTextures[o].pop();return this.usedTextures[o].push(l),l}let a;return r===Jt.PACKED_2X2_FLOAT32?a=this.gpgpu.createPackedMatrixTexture(e[0],e[1]):r===Jt.PACKED_2X2_FLOAT16?a=this.gpgpu.createFloat16PackedMatrixTexture(e[0],e[1]):r===Jt.UNPACKED_FLOAT32?a=this.gpgpu.createFloat32MatrixTexture(e[0],e[1]):r===Jt.UNPACKED_FLOAT16?a=this.gpgpu.createFloat16MatrixTexture(e[0],e[1]):r===Jt.PACKED_4X1_UNSIGNED_BYTE&&(a=this.gpgpu.createUnsignedBytesMatrixTexture(e[0],e[1])),this.usedTextures[o].push(a),this.numUsedTextures++,this._numBytesAllocated+=i,this.log(),a}releaseTexture(e,n,s,r){if(this.freeTextures==null)return;const o=Tk(s,r),i=Ek(n,o,r);i in this.freeTextures||(this.freeTextures[i]=[]);const a=Nk(n,o,this.gpgpu.gl,this.gpgpu.textureConfig,r),l=W().getNumber("WEBGL_DELETE_TEXTURE_THRESHOLD");l!==-1&&this._numBytesAllocated>l?(this.gpgpu.deleteMatrixTexture(e.texture),this._numBytesAllocated-=a):(this.freeTextures[i].push(e),this.numFreeTextures++,this._numBytesFree+=a),this.numUsedTextures--;const c=this.usedTextures[i],u=c&&c.indexOf(e);if(u==null||u<0)throw new Error("Cannot release a texture that was never provided by this texture manager");c[u]=c[c.length-1],c.pop(),this.log()}log(){if(!this.logEnabled)return;const e=this.numFreeTextures+this.numUsedTextures;console.log("Free/Used",`${this.numFreeTextures} / ${this.numUsedTextures}`,`(${e})`);const n=this._numBytesFree/this._numBytesAllocated;console.log(`Bytes allocated: ${this._numBytesAllocated}`),console.log(`Bytes unused: ${this._numBytesFree} (${Math.round(100*n)}%)`)}get numBytesAllocated(){return this._numBytesAllocated}get numBytesFree(){return this._numBytesFree}getNumUsedTextures(){return this.numUsedTextures}getNumFreeTextures(){return this.numFreeTextures}dispose(){if(this.freeTextures!=null){for(const e in this.freeTextures)this.freeTextures[e].forEach(n=>{this.gpgpu.deleteMatrixTexture(n.texture)});for(const e in this.usedTextures)this.usedTextures[e].forEach(n=>{this.gpgpu.deleteMatrixTexture(n.texture)});this.freeTextures=null,this.usedTextures=null,this.numUsedTextures=0,this.numFreeTextures=0,this._numBytesAllocated=0,this._numBytesFree=0}}}function WQ(t,e){const n=t;if(e===n.R32F)return 4;if(e===n.R16F)return 2;if(e===n.RGBA32F)return 16;if(e===t.RGBA)return 16;if(e===n.RGBA16F)return 8;if(e===n.RGBA8)return 4;throw new Error(`Unknown internal format ${e}`)}function Nk(t,e,n,s,r){const o=UQ(e,s);let i;if(r){const[l,c]=Nl(t[0],t[1]);i=l*c}else{const[l,c]=Nh(t[0],t[1]);i=l*c}const a=WQ(n,o);return i*a}function UQ(t,e){switch(t){case Jt.PACKED_2X2_FLOAT32:return YA(e);case Jt.PACKED_2X2_FLOAT16:return QA(e);case Jt.UNPACKED_FLOAT32:return KA(e);case Jt.UNPACKED_FLOAT16:return XA(e);case Jt.PACKED_4X1_UNSIGNED_BYTE:return qA(e);default:throw new Error(`Unknown physical texture type ${t}`)}}function GQ(t){return W().getBool("WEBGL_RENDER_FLOAT32_ENABLED")?t?Jt.PACKED_2X2_FLOAT32:Jt.UNPACKED_FLOAT32:t?Jt.PACKED_2X2_FLOAT16:Jt.UNPACKED_FLOAT16}function Tk(t,e){if(t===ns.UPLOAD)return Jt.PACKED_2X2_FLOAT32;if(t===ns.RENDER||t==null)return GQ(e);if(t===ns.DOWNLOAD||t===ns.PIXELS)return Jt.PACKED_4X1_UNSIGNED_BYTE;throw new Error(`Unknown logical texture type ${t}`)}function Ek(t,e,n){return`${t[0]}_${t[1]}_${e}_${n}`}/** * @license * Copyright 2017 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -12675,11 +12675,11 @@ vec2 packedUVfrom3D(int texNumR, int texNumC, setOutput(y); } - `}}const _s="if (isnan(x)) return x;",jQ="return x;",Rk="return abs(x);",KQ="return (x >= 0.0) ? x : (exp(x) - 1.0);",XQ=_s+` + `}}const _s="if (isnan(x)) return x;",HQ="return x;",Rk="return abs(x);",jQ="return (x >= 0.0) ? x : (exp(x) - 1.0);",KQ=_s+` return (x < 0.0) ? 0.0 : x; -`,qQ=_s+` +`,XQ=_s+` return (x < 0.0) ? 0.0 : min(6.0, x); -`,io="return x;",YQ="return 1.0 / (1.0 + exp(-1.0 * x));";/** +`,io="return x;",qQ="return 1.0 / (1.0 + exp(-1.0 * x));";/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -12694,7 +12694,7 @@ vec2 packedUVfrom3D(int texNumR, int texNumC, * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const QQ="return x;",ZQ=` + */const YQ="return x;",QQ=` vec4 result; result.r = (x.r >= 0.0) ? x.r : (exp(x.r) - 1.0); @@ -12703,7 +12703,7 @@ vec2 packedUVfrom3D(int texNumR, int texNumC, result.a = (x.a >= 0.0) ? x.a : (exp(x.a) - 1.0); return result; -`,JQ=` +`,ZQ=` vec4 result = x * vec4(greaterThanEqual(x, vec4(0.0))); bvec4 isNaN = isnan(x); @@ -12713,7 +12713,7 @@ vec2 packedUVfrom3D(int texNumR, int texNumC, result.a = isNaN.a ? x.a : result.a; return result; -`,eZ=` +`,JQ=` vec4 result = min(x, vec4(6.)) * vec4(greaterThanEqual(x, vec4(0.0))); bvec4 isNaN = isnan(x); @@ -12723,7 +12723,7 @@ vec2 packedUVfrom3D(int texNumR, int texNumC, result.a = isNaN.a ? x.a : result.a; return result; -`,tZ="return 1.0 / (1.0 + exp(-1.0 * x));";class po{constructor(e,n){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=e,this.enableShapeUniforms=pn(this.outputShape.length),this.userCode=` +`,eZ="return 1.0 / (1.0 + exp(-1.0 * x));";class po{constructor(e,n){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=e,this.enableShapeUniforms=pn(this.outputShape.length),this.userCode=` vec4 unaryOperation(vec4 x) { ${n} } @@ -12749,7 +12749,7 @@ vec2 packedUVfrom3D(int texNumR, int texNumC, * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */class nZ{constructor(e){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!1,this.outputShape=e,this.enableShapeUniforms=pn(this.outputShape.length);const n=e.length,s=vn("rc",n),r=Ze(n),o=LQ(n,s),i=s.slice(-2),a=n<=1?"rc":`vec2(${i.join(",")})`;this.userCode=` + */class tZ{constructor(e){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!1,this.outputShape=e,this.enableShapeUniforms=pn(this.outputShape.length);const n=e.length,s=vn("rc",n),r=Ze(n),o=PQ(n,s),i=s.slice(-2),a=n<=1?"rc":`vec2(${i.join(",")})`;this.userCode=` void main() { ${r} rc = getOutputCoords(); vec4 packedInput = getA(${o}); @@ -12771,7 +12771,7 @@ vec2 packedUVfrom3D(int texNumR, int texNumC, * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const sZ=SN,rZ=1e-7,oZ=1e-4,ud={};function iZ(t){return t in ud||(ud[t]={}),ud[t]}const aZ=W().getNumber("CPU_HANDOFF_SIZE_THRESHOLD"),lZ=600;function cZ(){return W().global.screen==null?1024:W().global.screen.height*W().global.screen.width*window.devicePixelRatio*lZ/1024/1024}class Pm extends Mx{nextDataId(){return Pm.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,!W().getBool("HAS_WEBGL"))throw new Error("WebGL is not supported on this device");let n;if(e!=null){if(e instanceof Og)n=e;else{const s=tr(W().getNumber("WEBGL_VERSION"),e);n=new Og(s)}this.binaryCache={},this.gpgpuCreatedLocally=!1}else{const s=tr(W().getNumber("WEBGL_VERSION"));n=new Og(s),this.binaryCache=iZ(W().getNumber("WEBGL_VERSION")),this.gpgpuCreatedLocally=!0}this.gpgpu=n,this.canvas=this.gpgpu.gl.canvas,this.textureManager=new WQ(this.gpgpu),this.numMBBeforeWarning=cZ(),this.texData=new jI(this,ir())}numDataIds(){return this.texData.numDataIds()-this.pendingDeletes}writeTexture(e,n,s,r,o,i){const a=this.makeTensorInfo(n,s),l=this.texData.get(a.dataId);l.isPacked=!1,l.texture={texture:e,texShape:[r,o]},l.texShape=[r,o];const c=ld(n),u=new $k(c,!1,i),h=this.runWebGLProgram(u,[a],s,[[r,o]]);return h.shape=n,l.texture=null,this.disposeIntermediateTensorInfo(a),h.dataId}write(e,n,s){if((W().getBool("WEBGL_CHECK_NUMERICAL_PROBLEMS")||W().getBool("DEBUG"))&&this.checkNumericalProblems(e),s==="complex64"&&e!=null)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:n,dtype:s,values:e,usage:ns.UPLOAD,refCount:1}),r}refCount(e){return this.texData.has(e)?this.texData.get(e).refCount:0}incRef(e){const n=this.texData.get(e);n.refCount++}decRef(e){if(this.texData.has(e)){const n=this.texData.get(e);n.refCount--}}move(e,n,s,r,o){if(W().getBool("DEBUG")&&this.checkNumericalProblems(n),r==="complex64")throw new Error("Cannot write to a complex64 dtype. Please use tf.complex(real, imag).");this.texData.set(e,{shape:s,dtype:r,values:n,usage:ns.UPLOAD,refCount:o})}disposeIntermediateTensorInfo(e){this.disposeData(e.dataId)}readSync(e){const n=this.texData.get(e),{values:s,dtype:r,complexTensorInfos:o,slice:i,shape:a,isPacked:l}=n;if(i!=null){let d;l?d=new po(a,io):d=new pr(a,io);const f=this.runWebGLProgram(d,[{dataId:e,shape:a,dtype:r}],r),p=this.readSync(f.dataId);return this.disposeIntermediateTensorInfo(f),p}if(s!=null)return this.convertAndCacheOnCPU(e);if(r==="string")return s;const c=this.activeTimers!=null;let u;c&&(u=Tn());let h;if(r==="complex64"){const d=this.readSync(o.real.dataId),f=this.readSync(o.imag.dataId);h=jr(d,f)}else h=this.getValuesFromTexture(e);return c&&(this.downloadWaitMs+=Tn()-u),this.convertAndCacheOnCPU(e,h)}async read(e){if(this.pendingRead.has(e)){const p=this.pendingRead.get(e);return new Promise(g=>p.push(g))}const n=this.texData.get(e),{values:s,shape:r,slice:o,dtype:i,complexTensorInfos:a,isPacked:l}=n;if(o!=null){let p;l?p=new po(r,io):p=new pr(r,io);const g=this.runWebGLProgram(p,[{dataId:e,shape:r,dtype:i}],i),x=this.read(g.dataId);return this.disposeIntermediateTensorInfo(g),x}if(s!=null)return this.convertAndCacheOnCPU(e);if(W().getBool("DEBUG")&&!W().getBool("WEBGL_DOWNLOAD_FLOAT_ENABLED")&&W().getNumber("WEBGL_VERSION")===2)throw new Error("tensor.data() with WEBGL_DOWNLOAD_FLOAT_ENABLED=false and WEBGL_VERSION=2 not yet supported.");let c=null,u;if(i!=="complex64"&&W().get("WEBGL_BUFFER_SUPPORTED")){u=this.decode(e);const p=this.texData.get(u.dataId);c=this.gpgpu.createBufferFromTexture(p.texture.texture,...od(r))}this.pendingRead.set(e,[]),i!=="complex64"&&await this.gpgpu.createAndWaitForFence();let h;if(i==="complex64"){const p=await Promise.all([this.read(a.real.dataId),this.read(a.imag.dataId)]),g=p[0],x=p[1];h=jr(g,x)}else if(c==null)h=this.getValuesFromTexture(e);else{const p=j(r);h=this.gpgpu.downloadFloat32MatrixFromBuffer(c,p)}if(u!=null&&this.disposeIntermediateTensorInfo(u),c!=null){const p=this.gpgpu.gl;ae(p,()=>p.deleteBuffer(c))}const d=this.convertAndCacheOnCPU(e,h),f=this.pendingRead.get(e);return this.pendingRead.delete(e),f.forEach(p=>p(d)),this.pendingDisposal.has(e)&&(this.pendingDisposal.delete(e),this.disposeData(e)&&ir().removeDataId(e,this),this.pendingDeletes--),d}readToGPU(e,n={}){const s=this.texData.get(e),{values:r,shape:o,slice:i,dtype:a,isPacked:l,texture:c}=s;if(a==="complex64")throw new Error("Does not support reading texture for complex64 dtype.");if(i!=null){let f;l?f=new po(o,io):f=new pr(o,io);const p=this.runWebGLProgram(f,[{dataId:e,shape:o,dtype:a}],a),g=this.readToGPU(p,n);return this.disposeIntermediateTensorInfo(p),g}if(c==null)throw r!=null?new Error("Data is not on GPU but on CPU."):new Error("There is no data on GPU or CPU.");const u=this.decode(e,n.customTexShape),h=ir().makeTensorFromTensorInfo(u),d=this.texData.get(u.dataId);return Object.assign({tensorRef:h},d.texture)}bufferSync(e){const n=this.readSync(e.dataId);if(e.dtype==="string")try{const s=n.map(r=>Do(r));return Ee(e.shape,e.dtype,s)}catch{throw new Error("Failed to decode encoded string bytes into utf-8")}return Ee(e.shape,e.dtype,n)}checkNumericalProblems(e){if(e!=null)for(let n=0;n0}time(e){const n=this.activeTimers,s=[];let r=!1;this.programTimersStack==null?(this.programTimersStack=s,r=!0):this.activeTimers.push(s),this.activeTimers=s,e();const o=Ei(this.activeTimers.map(l=>l.query)).filter(l=>l!=null),i=Ei(this.activeTimers.map(l=>l.name)).filter(l=>l!=null);this.activeTimers=n,r&&(this.programTimersStack=null);const a={uploadWaitMs:this.uploadWaitMs,downloadWaitMs:this.downloadWaitMs,kernelMs:null,wallMs:null};return(async()=>{if(W().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE")>0){const l=await Promise.all(o);a.kernelMs=EM(l),a.getExtraProfileInfo=()=>l.map((c,u)=>({name:i[u],ms:c})).map(c=>`${c.name}: ${c.ms}`).join(", ")}else a.kernelMs={error:"WebGL query timers are not supported in this environment."};return this.uploadWaitMs=0,this.downloadWaitMs=0,a})()}memory(){return{unreliable:!1,numBytesInGPU:this.numBytesInGPU,numBytesInGPUAllocated:this.textureManager.numBytesAllocated,numBytesInGPUFree:this.textureManager.numBytesFree}}startTimer(){return W().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE")>0?this.gpgpu.beginQuery():{startMs:Tn(),endMs:null}}endTimer(e){return W().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE")>0?(this.gpgpu.endQuery(),e):(e.endMs=Tn(),e)}async getQueryTime(e){if(W().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE")>0)return this.gpgpu.waitForQueryAndGetTime(e);const n=e;return n.endMs-n.startMs}disposeData(e,n=!1){if(this.pendingDisposal.has(e))return!1;if(!this.texData.has(e))return!0;if(n?this.texData.get(e).refCount=0:this.texData.get(e).refCount--,!n&&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:s}=this.texData.get(e);return s!=null&&(this.disposeData(s.real.dataId,n),this.disposeData(s.imag.dataId,n)),this.texData.delete(e),!0}releaseGPUData(e){const{texture:n,dtype:s,texShape:r,usage:o,isPacked:i,slice:a}=this.texData.get(e),l=a&&a.origDataId||e,c=this.dataRefCount.get(l);c>1?this.dataRefCount.set(l,c-1):(this.dataRefCount.delete(l),n!=null&&(this.numBytesInGPU-=this.computeBytes(r,s),this.textureManager.releaseTexture(n,r,o,i)));const u=this.texData.get(e);u.texture=null,u.texShape=null,u.isPacked=!1,u.slice=null}getTexture(e){return this.uploadToGPU(e),this.texData.get(e).texture.texture}getDataInfo(e){return this.texData.get(e)}shouldExecuteOnCPU(e,n=aZ){return W().getBool("WEBGL_CPU_FORWARD")&&e.every(s=>this.texData.get(s.dataId).texture==null&&j(s.shape)0&&fu(s[0])){const o=s.map(i=>No(i));r=this.write(o,e,n)}else r=this.write(s,e,n);return this.texData.get(r).usage=null,{dataId:r,shape:e,dtype:n}}makeOutput(e,n,s){return ir().makeTensorFromTensorInfo(this.makeTensorInfo(e,n,s),this)}unpackTensor(e){const n=new nZ(e.shape);return this.runWebGLProgram(n,[e],e.dtype)}packTensor(e){const n=new BQ(e.shape);return this.runWebGLProgram(n,[e],e.dtype,null,!0)}packedReshape(e,n){const s=[dl(e.shape),...fl(e.shape)],r={dtype:e.dtype,shape:s,dataId:e.dataId},o=[dl(n),...fl(n)],i=new nD(o,s),a=!0,l=[s],c=this.runWebGLProgram(i,[r],e.dtype,l,a);return{dataId:c.dataId,shape:n,dtype:c.dtype}}decode(e,n){const s=this.texData.get(e),{isPacked:r,shape:o,dtype:i}=s;if(n!=null){const d=j(o),f=n[0]*n[1]*4;I(d<=f,()=>"customTexShape is too small. Row * Column * 4 should be equal or larger than the size of the tensor data.")}const a=ld(o);let l;r?l=new $Y(a):l=new IY(a);const c=!0,u=[n??od(a)],h=this.runWebGLProgram(l,[{shape:a,dtype:i,dataId:e}],i,u,c,n);return{dtype:i,shape:o,dataId:h.dataId}}runWebGLProgram(e,n,s,r,o=!1,i){const a=this.makeTensorInfo(e.outputShape,s),l=this.texData.get(a.dataId);if(e.packedOutput&&(l.isPacked=!0),e.outPackingScheme===eu.DENSE){const m=i??od(e.outputShape);l.texShape=m.map(y=>y*2)}if(e.outTexUsage!=null&&(l.usage=e.outTexUsage),j(a.shape)===0)return l.values=cn(a.dtype,0),a;const c=[],u=n.map(m=>{if(m.dtype==="complex64")throw new Error("GPGPUProgram does not support complex64 input. For complex64 dtypes, please separate the program into real and imaginary parts.");let y=this.texData.get(m.dataId);if(y.texture==null){if(!e.packedInputs&&j(m.shape)<=W().getNumber("WEBGL_SIZE_UPLOAD_UNIFORM"))return{shape:m.shape,texData:null,isUniform:!0,uniformValues:y.values};e.packedInputs&&(y.isPacked=!0,y.shape=m.shape)}if(this.uploadToGPU(m.dataId),!!y.isPacked!=!!e.packedInputs)m=y.isPacked?this.unpackTensor(m):this.packTensor(m),c.push(m),y=this.texData.get(m.dataId);else if(y.isPacked&&!Lf(y.shape,m.shape)){const w=m,v=m.shape;m.shape=y.shape,m=this.packedReshape(m,v),c.push(m),y=this.texData.get(m.dataId),w.shape=v}return{shape:m.shape,texData:y,isUniform:!1}});this.uploadToGPU(a.dataId);const h={shape:a.shape,texData:l,isUniform:!1},d=SY(e,u,h),f=this.getAndSaveBinary(d,()=>CY(this.gpgpu,e,u,h)),p=this.activeTimers!=null;let g;p&&(g=this.startTimer()),W().get("ENGINE_COMPILE_ONLY")||kY(this.gpgpu,f,u,h,r),c.forEach(m=>this.disposeIntermediateTensorInfo(m)),p&&(g=this.endTimer(g),this.activeTimers.push({name:e.constructor.name,query:this.getQueryTime(g)}));const x=W().getNumber("WEBGL_FLUSH_THRESHOLD");if(x>0){const m=Tn();m-this.lastGlFlushTime>x&&(this.gpgpu.gl.flush(),this.lastGlFlushTime=m)}if(!W().getBool("WEBGL_LAZILY_UNPACK")&&l.isPacked&&o===!1){const m=this.unpackTensor(a);return this.disposeIntermediateTensorInfo(a),m}return a}compileAndRun(e,n,s,r,o=!1){return s=s||n[0].dtype,this.runWebGLProgram(e,n,s,r,o)}getAndSaveBinary(e,n){return e in this.binaryCache||(this.binaryCache[e]=n()),this.binaryCache[e]}getTextureManager(){return this.textureManager}dispose(){this.disposed||(W().getBool("IS_TEST")||Object.keys(this.binaryCache).forEach(n=>{this.gpgpu.deleteProgram(this.binaryCache[n].webGLProgram),delete this.binaryCache[n]}),this.textureManager.dispose(),this.canvas!=null&&typeof HTMLCanvasElement<"u"&&this.canvas instanceof HTMLCanvasElement?this.canvas.remove():this.canvas=null,this.gpgpuCreatedLocally&&(this.gpgpu.program=null,this.gpgpu.dispose()),this.disposed=!0)}floatPrecision(){return this.floatPrecisionValue==null&&(this.floatPrecisionValue=P(()=>{if(!W().get("WEBGL_RENDER_FLOAT32_ENABLED")){const e=W().getBool("DEBUG");W().set("DEBUG",!1);const n=this.abs(We(1e-8)).dataSync()[0];if(W().set("DEBUG",e),n>0)return 32}return 16})),this.floatPrecisionValue}epsilon(){return this.floatPrecision()===32?rZ:oZ}uploadToGPU(e){const n=this.texData.get(e),{shape:s,dtype:r,values:o,texture:i,usage:a,isPacked:l}=n;if(i!=null)return;const c=this.activeTimers!=null;let u;c&&(u=Tn());let h=n.texShape;if(h==null&&(h=R9(s,l),n.texShape=h),o!=null){const d=ld(s);let f,p=h[1],g=h[0];const x=o instanceof Uint8Array||o instanceof Uint8ClampedArray;(l||!x)&&([p,g]=Nl(h[0],h[1])),l?f=new RY(d,x):f=new $k(d,x);const m=x?[g,p]:h,y=this.makeTensorInfo(m,r),w=this.texData.get(y.dataId);x?w.usage=ns.PIXELS:w.usage=ns.UPLOAD,w.texShape=m,this.gpgpu.uploadDenseMatrixToTexture(this.getTexture(y.dataId),p,g,o);const v=[[g,p]],C=this.runWebGLProgram(f,[y],r,v,!0),k=this.texData.get(C.dataId);n.texShape=k.texShape,n.isPacked=k.isPacked,n.usage=k.usage,W().get("ENGINE_COMPILE_ONLY")?this.disposeData(C.dataId):(n.texture=k.texture,n.values=null,this.texData.delete(C.dataId)),this.disposeIntermediateTensorInfo(y),c&&(this.uploadWaitMs+=Tn()-u)}else{const d=this.acquireTexture(h,a,r,l);n.texture=d}}convertAndCacheOnCPU(e,n){const s=this.texData.get(e),{dtype:r}=s;return n!=null&&(s.values=uZ(n,r)),s.values}acquireTexture(e,n,s,r){if(this.numBytesInGPU+=this.computeBytes(e,s),!this.warnedAboutMemory&&this.numBytesInGPU>this.numMBBeforeWarning*1024*1024){const o=(this.numBytesInGPU/1024/1024).toFixed(2);this.warnedAboutMemory=!0,console.warn(`High memory usage in GPU: ${o} MB, most likely due to a memory leak`)}return this.textureManager.acquireTexture(e,n,r)}computeBytes(e,n){return e[0]*e[1]*df(n)}checkCompileCompletion(){for(const[,e]of Object.entries(this.binaryCache))this.checkCompletion_(e)}async checkCompileCompletionAsync(){const e=[];if(this.gpgpu.parallelCompilationExtension){for(const[,n]of Object.entries(this.binaryCache))e.push(this.checkCompletionAsync_(n));return Promise.all(e)}else{for(const[,n]of Object.entries(this.binaryCache)){const s=new Promise(r=>{try{this.checkCompletion_(n),r(!0)}catch(o){throw o}});e.push(s)}return Promise.all(e)}}async checkCompletionAsync_(e){return this.gpgpu.gl.getProgramParameter(e.webGLProgram,this.gpgpu.parallelCompilationExtension.COMPLETION_STATUS_KHR)?this.checkCompletion_(e):(await UN(),this.checkCompletionAsync_(e))}checkCompletion_(e){if(this.gpgpu.gl.getProgramParameter(e.webGLProgram,this.gpgpu.gl.LINK_STATUS)===!1)throw console.log(this.gpgpu.gl.getProgramInfoLog(e.webGLProgram)),this.gpgpu.gl.getShaderParameter(e.fragmentShader,this.gpgpu.gl.COMPILE_STATUS)===!1?(VA(e.source,this.gpgpu.gl.getShaderInfoLog(e.fragmentShader)),new Error("Failed to compile fragment shader.")):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:n,customUniformLocations:s,infLoc:r,nanLoc:o,outShapeLocation:i,outShapeStridesLocation:a,outTexShapeLocation:l}=jA(this.gpgpu,e.program,e.webGLProgram);e.variablesLocations=n,e.customUniformLocations=s,e.infLoc=r,e.nanLoc=o,e.outShapeLocation=i,e.outShapeStridesLocation=a,e.outTexShapeLocation=l}}createTensorFromGPUData(e,n,s){e.channels=e.channels||"RGBA";const{texture:r,height:o,width:i,channels:a}=e,l=ir().backend;if(!l.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 c=l.writeTexture(r,n,s,o,i,a);return ir().makeTensorFromDataId(c,n,s,l)}}Pm.nextDataId=0;function uZ(t,e){if(e==="float32"||e==="complex64")return t;if(e==="int32"||e==="bool"){const n=e==="int32"?new Int32Array(t.length):new Uint8Array(t.length);for(let s=0;sp.push(g))}const n=this.texData.get(e),{values:s,shape:r,slice:o,dtype:i,complexTensorInfos:a,isPacked:l}=n;if(o!=null){let p;l?p=new po(r,io):p=new pr(r,io);const g=this.runWebGLProgram(p,[{dataId:e,shape:r,dtype:i}],i),x=this.read(g.dataId);return this.disposeIntermediateTensorInfo(g),x}if(s!=null)return this.convertAndCacheOnCPU(e);if(W().getBool("DEBUG")&&!W().getBool("WEBGL_DOWNLOAD_FLOAT_ENABLED")&&W().getNumber("WEBGL_VERSION")===2)throw new Error("tensor.data() with WEBGL_DOWNLOAD_FLOAT_ENABLED=false and WEBGL_VERSION=2 not yet supported.");let c=null,u;if(i!=="complex64"&&W().get("WEBGL_BUFFER_SUPPORTED")){u=this.decode(e);const p=this.texData.get(u.dataId);c=this.gpgpu.createBufferFromTexture(p.texture.texture,...rd(r))}this.pendingRead.set(e,[]),i!=="complex64"&&await this.gpgpu.createAndWaitForFence();let h;if(i==="complex64"){const p=await Promise.all([this.read(a.real.dataId),this.read(a.imag.dataId)]),g=p[0],x=p[1];h=jr(g,x)}else if(c==null)h=this.getValuesFromTexture(e);else{const p=j(r);h=this.gpgpu.downloadFloat32MatrixFromBuffer(c,p)}if(u!=null&&this.disposeIntermediateTensorInfo(u),c!=null){const p=this.gpgpu.gl;ae(p,()=>p.deleteBuffer(c))}const d=this.convertAndCacheOnCPU(e,h),f=this.pendingRead.get(e);return this.pendingRead.delete(e),f.forEach(p=>p(d)),this.pendingDisposal.has(e)&&(this.pendingDisposal.delete(e),this.disposeData(e)&&ir().removeDataId(e,this),this.pendingDeletes--),d}readToGPU(e,n={}){const s=this.texData.get(e),{values:r,shape:o,slice:i,dtype:a,isPacked:l,texture:c}=s;if(a==="complex64")throw new Error("Does not support reading texture for complex64 dtype.");if(i!=null){let f;l?f=new po(o,io):f=new pr(o,io);const p=this.runWebGLProgram(f,[{dataId:e,shape:o,dtype:a}],a),g=this.readToGPU(p,n);return this.disposeIntermediateTensorInfo(p),g}if(c==null)throw r!=null?new Error("Data is not on GPU but on CPU."):new Error("There is no data on GPU or CPU.");const u=this.decode(e,n.customTexShape),h=ir().makeTensorFromTensorInfo(u),d=this.texData.get(u.dataId);return Object.assign({tensorRef:h},d.texture)}bufferSync(e){const n=this.readSync(e.dataId);if(e.dtype==="string")try{const s=n.map(r=>Do(r));return Ee(e.shape,e.dtype,s)}catch{throw new Error("Failed to decode encoded string bytes into utf-8")}return Ee(e.shape,e.dtype,n)}checkNumericalProblems(e){if(e!=null)for(let n=0;n0}time(e){const n=this.activeTimers,s=[];let r=!1;this.programTimersStack==null?(this.programTimersStack=s,r=!0):this.activeTimers.push(s),this.activeTimers=s,e();const o=Ei(this.activeTimers.map(l=>l.query)).filter(l=>l!=null),i=Ei(this.activeTimers.map(l=>l.name)).filter(l=>l!=null);this.activeTimers=n,r&&(this.programTimersStack=null);const a={uploadWaitMs:this.uploadWaitMs,downloadWaitMs:this.downloadWaitMs,kernelMs:null,wallMs:null};return(async()=>{if(W().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE")>0){const l=await Promise.all(o);a.kernelMs=TM(l),a.getExtraProfileInfo=()=>l.map((c,u)=>({name:i[u],ms:c})).map(c=>`${c.name}: ${c.ms}`).join(", ")}else a.kernelMs={error:"WebGL query timers are not supported in this environment."};return this.uploadWaitMs=0,this.downloadWaitMs=0,a})()}memory(){return{unreliable:!1,numBytesInGPU:this.numBytesInGPU,numBytesInGPUAllocated:this.textureManager.numBytesAllocated,numBytesInGPUFree:this.textureManager.numBytesFree}}startTimer(){return W().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE")>0?this.gpgpu.beginQuery():{startMs:Tn(),endMs:null}}endTimer(e){return W().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE")>0?(this.gpgpu.endQuery(),e):(e.endMs=Tn(),e)}async getQueryTime(e){if(W().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE")>0)return this.gpgpu.waitForQueryAndGetTime(e);const n=e;return n.endMs-n.startMs}disposeData(e,n=!1){if(this.pendingDisposal.has(e))return!1;if(!this.texData.has(e))return!0;if(n?this.texData.get(e).refCount=0:this.texData.get(e).refCount--,!n&&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:s}=this.texData.get(e);return s!=null&&(this.disposeData(s.real.dataId,n),this.disposeData(s.imag.dataId,n)),this.texData.delete(e),!0}releaseGPUData(e){const{texture:n,dtype:s,texShape:r,usage:o,isPacked:i,slice:a}=this.texData.get(e),l=a&&a.origDataId||e,c=this.dataRefCount.get(l);c>1?this.dataRefCount.set(l,c-1):(this.dataRefCount.delete(l),n!=null&&(this.numBytesInGPU-=this.computeBytes(r,s),this.textureManager.releaseTexture(n,r,o,i)));const u=this.texData.get(e);u.texture=null,u.texShape=null,u.isPacked=!1,u.slice=null}getTexture(e){return this.uploadToGPU(e),this.texData.get(e).texture.texture}getDataInfo(e){return this.texData.get(e)}shouldExecuteOnCPU(e,n=iZ){return W().getBool("WEBGL_CPU_FORWARD")&&e.every(s=>this.texData.get(s.dataId).texture==null&&j(s.shape)0&&du(s[0])){const o=s.map(i=>No(i));r=this.write(o,e,n)}else r=this.write(s,e,n);return this.texData.get(r).usage=null,{dataId:r,shape:e,dtype:n}}makeOutput(e,n,s){return ir().makeTensorFromTensorInfo(this.makeTensorInfo(e,n,s),this)}unpackTensor(e){const n=new tZ(e.shape);return this.runWebGLProgram(n,[e],e.dtype)}packTensor(e){const n=new LQ(e.shape);return this.runWebGLProgram(n,[e],e.dtype,null,!0)}packedReshape(e,n){const s=[dl(e.shape),...fl(e.shape)],r={dtype:e.dtype,shape:s,dataId:e.dataId},o=[dl(n),...fl(n)],i=new nD(o,s),a=!0,l=[s],c=this.runWebGLProgram(i,[r],e.dtype,l,a);return{dataId:c.dataId,shape:n,dtype:c.dtype}}decode(e,n){const s=this.texData.get(e),{isPacked:r,shape:o,dtype:i}=s;if(n!=null){const d=j(o),f=n[0]*n[1]*4;I(d<=f,()=>"customTexShape is too small. Row * Column * 4 should be equal or larger than the size of the tensor data.")}const a=ad(o);let l;r?l=new IY(a):l=new SY(a);const c=!0,u=[n??rd(a)],h=this.runWebGLProgram(l,[{shape:a,dtype:i,dataId:e}],i,u,c,n);return{dtype:i,shape:o,dataId:h.dataId}}runWebGLProgram(e,n,s,r,o=!1,i){const a=this.makeTensorInfo(e.outputShape,s),l=this.texData.get(a.dataId);if(e.packedOutput&&(l.isPacked=!0),e.outPackingScheme===eu.DENSE){const m=i??rd(e.outputShape);l.texShape=m.map(y=>y*2)}if(e.outTexUsage!=null&&(l.usage=e.outTexUsage),j(a.shape)===0)return l.values=cn(a.dtype,0),a;const c=[],u=n.map(m=>{if(m.dtype==="complex64")throw new Error("GPGPUProgram does not support complex64 input. For complex64 dtypes, please separate the program into real and imaginary parts.");let y=this.texData.get(m.dataId);if(y.texture==null){if(!e.packedInputs&&j(m.shape)<=W().getNumber("WEBGL_SIZE_UPLOAD_UNIFORM"))return{shape:m.shape,texData:null,isUniform:!0,uniformValues:y.values};e.packedInputs&&(y.isPacked=!0,y.shape=m.shape)}if(this.uploadToGPU(m.dataId),!!y.isPacked!=!!e.packedInputs)m=y.isPacked?this.unpackTensor(m):this.packTensor(m),c.push(m),y=this.texData.get(m.dataId);else if(y.isPacked&&!Pf(y.shape,m.shape)){const w=m,v=m.shape;m.shape=y.shape,m=this.packedReshape(m,v),c.push(m),y=this.texData.get(m.dataId),w.shape=v}return{shape:m.shape,texData:y,isUniform:!1}});this.uploadToGPU(a.dataId);const h={shape:a.shape,texData:l,isUniform:!1},d=kY(e,u,h),f=this.getAndSaveBinary(d,()=>bY(this.gpgpu,e,u,h)),p=this.activeTimers!=null;let g;p&&(g=this.startTimer()),W().get("ENGINE_COMPILE_ONLY")||CY(this.gpgpu,f,u,h,r),c.forEach(m=>this.disposeIntermediateTensorInfo(m)),p&&(g=this.endTimer(g),this.activeTimers.push({name:e.constructor.name,query:this.getQueryTime(g)}));const x=W().getNumber("WEBGL_FLUSH_THRESHOLD");if(x>0){const m=Tn();m-this.lastGlFlushTime>x&&(this.gpgpu.gl.flush(),this.lastGlFlushTime=m)}if(!W().getBool("WEBGL_LAZILY_UNPACK")&&l.isPacked&&o===!1){const m=this.unpackTensor(a);return this.disposeIntermediateTensorInfo(a),m}return a}compileAndRun(e,n,s,r,o=!1){return s=s||n[0].dtype,this.runWebGLProgram(e,n,s,r,o)}getAndSaveBinary(e,n){return e in this.binaryCache||(this.binaryCache[e]=n()),this.binaryCache[e]}getTextureManager(){return this.textureManager}dispose(){this.disposed||(W().getBool("IS_TEST")||Object.keys(this.binaryCache).forEach(n=>{this.gpgpu.deleteProgram(this.binaryCache[n].webGLProgram),delete this.binaryCache[n]}),this.textureManager.dispose(),this.canvas!=null&&typeof HTMLCanvasElement<"u"&&this.canvas instanceof HTMLCanvasElement?this.canvas.remove():this.canvas=null,this.gpgpuCreatedLocally&&(this.gpgpu.program=null,this.gpgpu.dispose()),this.disposed=!0)}floatPrecision(){return this.floatPrecisionValue==null&&(this.floatPrecisionValue=P(()=>{if(!W().get("WEBGL_RENDER_FLOAT32_ENABLED")){const e=W().getBool("DEBUG");W().set("DEBUG",!1);const n=this.abs(We(1e-8)).dataSync()[0];if(W().set("DEBUG",e),n>0)return 32}return 16})),this.floatPrecisionValue}epsilon(){return this.floatPrecision()===32?sZ:rZ}uploadToGPU(e){const n=this.texData.get(e),{shape:s,dtype:r,values:o,texture:i,usage:a,isPacked:l}=n;if(i!=null)return;const c=this.activeTimers!=null;let u;c&&(u=Tn());let h=n.texShape;if(h==null&&(h=E9(s,l),n.texShape=h),o!=null){const d=ad(s);let f,p=h[1],g=h[0];const x=o instanceof Uint8Array||o instanceof Uint8ClampedArray;(l||!x)&&([p,g]=Nl(h[0],h[1])),l?f=new EY(d,x):f=new $k(d,x);const m=x?[g,p]:h,y=this.makeTensorInfo(m,r),w=this.texData.get(y.dataId);x?w.usage=ns.PIXELS:w.usage=ns.UPLOAD,w.texShape=m,this.gpgpu.uploadDenseMatrixToTexture(this.getTexture(y.dataId),p,g,o);const v=[[g,p]],C=this.runWebGLProgram(f,[y],r,v,!0),k=this.texData.get(C.dataId);n.texShape=k.texShape,n.isPacked=k.isPacked,n.usage=k.usage,W().get("ENGINE_COMPILE_ONLY")?this.disposeData(C.dataId):(n.texture=k.texture,n.values=null,this.texData.delete(C.dataId)),this.disposeIntermediateTensorInfo(y),c&&(this.uploadWaitMs+=Tn()-u)}else{const d=this.acquireTexture(h,a,r,l);n.texture=d}}convertAndCacheOnCPU(e,n){const s=this.texData.get(e),{dtype:r}=s;return n!=null&&(s.values=cZ(n,r)),s.values}acquireTexture(e,n,s,r){if(this.numBytesInGPU+=this.computeBytes(e,s),!this.warnedAboutMemory&&this.numBytesInGPU>this.numMBBeforeWarning*1024*1024){const o=(this.numBytesInGPU/1024/1024).toFixed(2);this.warnedAboutMemory=!0,console.warn(`High memory usage in GPU: ${o} MB, most likely due to a memory leak`)}return this.textureManager.acquireTexture(e,n,r)}computeBytes(e,n){return e[0]*e[1]*hf(n)}checkCompileCompletion(){for(const[,e]of Object.entries(this.binaryCache))this.checkCompletion_(e)}async checkCompileCompletionAsync(){const e=[];if(this.gpgpu.parallelCompilationExtension){for(const[,n]of Object.entries(this.binaryCache))e.push(this.checkCompletionAsync_(n));return Promise.all(e)}else{for(const[,n]of Object.entries(this.binaryCache)){const s=new Promise(r=>{try{this.checkCompletion_(n),r(!0)}catch(o){throw o}});e.push(s)}return Promise.all(e)}}async checkCompletionAsync_(e){return this.gpgpu.gl.getProgramParameter(e.webGLProgram,this.gpgpu.parallelCompilationExtension.COMPLETION_STATUS_KHR)?this.checkCompletion_(e):(await UN(),this.checkCompletionAsync_(e))}checkCompletion_(e){if(this.gpgpu.gl.getProgramParameter(e.webGLProgram,this.gpgpu.gl.LINK_STATUS)===!1)throw console.log(this.gpgpu.gl.getProgramInfoLog(e.webGLProgram)),this.gpgpu.gl.getShaderParameter(e.fragmentShader,this.gpgpu.gl.COMPILE_STATUS)===!1?(VA(e.source,this.gpgpu.gl.getShaderInfoLog(e.fragmentShader)),new Error("Failed to compile fragment shader.")):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:n,customUniformLocations:s,infLoc:r,nanLoc:o,outShapeLocation:i,outShapeStridesLocation:a,outTexShapeLocation:l}=jA(this.gpgpu,e.program,e.webGLProgram);e.variablesLocations=n,e.customUniformLocations=s,e.infLoc=r,e.nanLoc=o,e.outShapeLocation=i,e.outShapeStridesLocation=a,e.outTexShapeLocation=l}}createTensorFromGPUData(e,n,s){e.channels=e.channels||"RGBA";const{texture:r,height:o,width:i,channels:a}=e,l=ir().backend;if(!l.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 c=l.writeTexture(r,n,s,o,i,a);return ir().makeTensorFromDataId(c,n,s,l)}}Pm.nextDataId=0;function cZ(t,e){if(e==="float32"||e==="complex64")return t;if(e==="int32"||e==="bool"){const n=e==="int32"?new Int32Array(t.length):new Uint8Array(t.length);for(let s=0;s{const{x:i}=r,a=o,l=s||i.dtype;if(a.shouldExecuteOnCPU([i])&&n!=null){const h=a.texData.get(i.dataId),d=n(h.values,l);return a.makeTensorInfo(i.shape,l,d)}const c=W().getBool("WEBGL_PACK_UNARY_OPERATIONS")&&e!=null;let u;return c?u=new po(i.shape,e):u=new pr(i.shape,t),a.runWebGLProgram(u,[i],l)}}function rn({opSnippet:t,packedOpSnippet:e,checkOutOfBounds:n=!1,supportsComplex:s=!1,cpuKernelImpl:r,dtype:o}){return({inputs:i,backend:a})=>{const{a:l,b:c}=i,u=a;if(s&&l.dtype==="complex64"){const p=u.texData.get(l.dataId),g=u.texData.get(c.dataId),[x,m]=[[p.complexTensorInfos.real,g.complexTensorInfos.real],[p.complexTensorInfos.imag,g.complexTensorInfos.imag]].map(w=>{const[v,b]=w,C={dataId:v.dataId,dtype:v.dtype,shape:l.shape},k={dataId:b.dataId,dtype:b.dtype,shape:c.shape},S=new Wi(t,l.shape,c.shape);return u.runWebGLProgram(S,[C,k],Xn(v.dtype,b.dtype))}),y=Qo({inputs:{real:x,imag:m},backend:u});return u.disposeIntermediateTensorInfo(x),u.disposeIntermediateTensorInfo(m),y}const h=o||Xn(l.dtype,c.dtype);if((l.dtype==="string"||c.dtype==="string"||u.shouldExecuteOnCPU([l,c]))&&r!=null){const p=u.texData.get(l.dataId).values,g=u.texData.get(c.dataId).values,x=l.dtype==="string"?Kr(p):p,m=l.dtype==="string"?Kr(g):g,[y,w]=r(l.shape,c.shape,x,m,h),v=u.makeTensorInfo(w,h),b=u.texData.get(v.dataId);return b.values=y,v}const d=W().getBool("WEBGL_PACK_BINARY_OPERATIONS")&&e!=null;let f;return d?f=new Dl(e,l.shape,c.shape,n):f=new Wi(t,l.shape,c.shape),u.runWebGLProgram(f,[l,c],h)}}function tu(t,e=!1){if(t==="linear")return e?QQ:jQ;if(t==="relu")return e?JQ:XQ;if(t==="elu")return e?ZQ:KQ;if(t==="relu6")return e?eZ:qQ;if(t==="prelu")return e?iD:oD;if(t==="leakyrelu")return e?rD:sD;if(t==="sigmoid")return e?tZ:YQ;throw new Error(`Activation ${t} has not been implemented for the WebGL backend.`)}/** + */const _l="if (isnan(x)) return x;";function Oe({opSnippet:t,packedOpSnippet:e,cpuKernelImpl:n,dtype:s}){return({inputs:r,backend:o})=>{const{x:i}=r,a=o,l=s||i.dtype;if(a.shouldExecuteOnCPU([i])&&n!=null){const h=a.texData.get(i.dataId),d=n(h.values,l);return a.makeTensorInfo(i.shape,l,d)}const c=W().getBool("WEBGL_PACK_UNARY_OPERATIONS")&&e!=null;let u;return c?u=new po(i.shape,e):u=new pr(i.shape,t),a.runWebGLProgram(u,[i],l)}}function rn({opSnippet:t,packedOpSnippet:e,checkOutOfBounds:n=!1,supportsComplex:s=!1,cpuKernelImpl:r,dtype:o}){return({inputs:i,backend:a})=>{const{a:l,b:c}=i,u=a;if(s&&l.dtype==="complex64"){const p=u.texData.get(l.dataId),g=u.texData.get(c.dataId),[x,m]=[[p.complexTensorInfos.real,g.complexTensorInfos.real],[p.complexTensorInfos.imag,g.complexTensorInfos.imag]].map(w=>{const[v,b]=w,C={dataId:v.dataId,dtype:v.dtype,shape:l.shape},k={dataId:b.dataId,dtype:b.dtype,shape:c.shape},S=new Wi(t,l.shape,c.shape);return u.runWebGLProgram(S,[C,k],Xn(v.dtype,b.dtype))}),y=Qo({inputs:{real:x,imag:m},backend:u});return u.disposeIntermediateTensorInfo(x),u.disposeIntermediateTensorInfo(m),y}const h=o||Xn(l.dtype,c.dtype);if((l.dtype==="string"||c.dtype==="string"||u.shouldExecuteOnCPU([l,c]))&&r!=null){const p=u.texData.get(l.dataId).values,g=u.texData.get(c.dataId).values,x=l.dtype==="string"?Kr(p):p,m=l.dtype==="string"?Kr(g):g,[y,w]=r(l.shape,c.shape,x,m,h),v=u.makeTensorInfo(w,h),b=u.texData.get(v.dataId);return b.values=y,v}const d=W().getBool("WEBGL_PACK_BINARY_OPERATIONS")&&e!=null;let f;return d?f=new Dl(e,l.shape,c.shape,n):f=new Wi(t,l.shape,c.shape),u.runWebGLProgram(f,[l,c],h)}}function tu(t,e=!1){if(t==="linear")return e?YQ:HQ;if(t==="relu")return e?ZQ:KQ;if(t==="elu")return e?QQ:jQ;if(t==="relu6")return e?JQ:XQ;if(t==="prelu")return e?iD:oD;if(t==="leakyrelu")return e?rD:sD;if(t==="sigmoid")return e?eZ:qQ;throw new Error(`Activation ${t} 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"); @@ -13056,7 +13056,7 @@ vec2 packedUVfrom3D(int texNumR, int texNumC, * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const _k="return a * b;";function $v(t){const{inputs:e,backend:n}=t,{a:s,b:r}=e,o=Xn(s.dtype,r.dtype);if(s.dtype==="complex64"){const a=n.texData.get(s.dataId),l=n.texData.get(r.dataId),c=new Dk(Ak.REAL,s.shape,r.shape),u=new Dk(Ak.IMAG,s.shape,r.shape),h=[{dataId:a.complexTensorInfos.real.dataId,dtype:a.complexTensorInfos.real.dtype,shape:s.shape},{dataId:a.complexTensorInfos.imag.dataId,dtype:a.complexTensorInfos.imag.dtype,shape:s.shape},{dataId:l.complexTensorInfos.real.dataId,dtype:l.complexTensorInfos.real.dtype,shape:r.shape},{dataId:l.complexTensorInfos.imag.dataId,dtype:l.complexTensorInfos.imag.dtype,shape:r.shape}],d=n.runWebGLProgram(c,h,"float32"),f=n.runWebGLProgram(u,h,"float32"),p=Qo({inputs:{real:d,imag:f},backend:n});return n.disposeIntermediateTensorInfo(d),n.disposeIntermediateTensorInfo(f),p}if(n.shouldExecuteOnCPU([s,r])){const a=n.texData.get(s.dataId),l=n.texData.get(r.dataId),[c,u]=mQ(s.shape,r.shape,a.values,l.values,o),h=n.makeTensorInfo(u,o),d=n.texData.get(h.dataId);return d.values=c,h}let i;return W().getBool("WEBGL_PACK_BINARY_OPERATIONS")?i=new Dl(_k,s.shape,r.shape):i=new Wi(_k,s.shape,r.shape),n.runWebGLProgram(i,[s,r],o)}const xZ={kernelName:Uu,backendName:"webgl",kernelFunc:$v};/** + */const _k="return a * b;";function $v(t){const{inputs:e,backend:n}=t,{a:s,b:r}=e,o=Xn(s.dtype,r.dtype);if(s.dtype==="complex64"){const a=n.texData.get(s.dataId),l=n.texData.get(r.dataId),c=new Dk(Ak.REAL,s.shape,r.shape),u=new Dk(Ak.IMAG,s.shape,r.shape),h=[{dataId:a.complexTensorInfos.real.dataId,dtype:a.complexTensorInfos.real.dtype,shape:s.shape},{dataId:a.complexTensorInfos.imag.dataId,dtype:a.complexTensorInfos.imag.dtype,shape:s.shape},{dataId:l.complexTensorInfos.real.dataId,dtype:l.complexTensorInfos.real.dtype,shape:r.shape},{dataId:l.complexTensorInfos.imag.dataId,dtype:l.complexTensorInfos.imag.dtype,shape:r.shape}],d=n.runWebGLProgram(c,h,"float32"),f=n.runWebGLProgram(u,h,"float32"),p=Qo({inputs:{real:d,imag:f},backend:n});return n.disposeIntermediateTensorInfo(d),n.disposeIntermediateTensorInfo(f),p}if(n.shouldExecuteOnCPU([s,r])){const a=n.texData.get(s.dataId),l=n.texData.get(r.dataId),[c,u]=pQ(s.shape,r.shape,a.values,l.values,o),h=n.makeTensorInfo(u,o),d=n.texData.get(h.dataId);return d.values=c,h}let i;return W().getBool("WEBGL_PACK_BINARY_OPERATIONS")?i=new Dl(_k,s.shape,r.shape):i=new Wi(_k,s.shape,r.shape),n.runWebGLProgram(i,[s,r],o)}const gZ={kernelName:Wu,backendName:"webgl",kernelFunc:$v};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -13071,7 +13071,7 @@ vec2 packedUVfrom3D(int texNumR, int texNumC, * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function yZ(t,e,n){const s=[dl(t.shape),...fl(t.shape)],r={dtype:t.dtype,shape:s,dataId:t.dataId},o=[dl(e),...fl(e)],i=new nD(o,s),a=!0,l=[s],c=n.runWebGLProgram(i,[r],t.dtype,l,a);return{dataId:c.dataId,shape:e,dtype:c.dtype}}/** + */function xZ(t,e,n){const s=[dl(t.shape),...fl(t.shape)],r={dtype:t.dtype,shape:s,dataId:t.dataId},o=[dl(e),...fl(e)],i=new nD(o,s),a=!0,l=[s],c=n.runWebGLProgram(i,[r],t.dtype,l,a);return{dataId:c.dataId,shape:e,dtype:c.dtype}}/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -13086,7 +13086,7 @@ vec2 packedUVfrom3D(int texNumR, int texNumC, * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function re(t){const{inputs:e,backend:n,attrs:s}=t,{x:r}=e,{shape:o}=s,i=n,a=j(r.shape),l=KI(o,a),c=j(l);I(a===c,()=>`The new shape (${l}) has ${c} elements and the old shape (${r.shape}) has ${a} elements. The new shape and old shape must have the same number of elements.`);const u=i.texData.get(r.dataId);return u.isPacked&&!Lf(r.shape,l)&&!(u.texture!==null&&Lf(u.shape,l))?yZ(r,l,i):(i.incRef(r.dataId),{dataId:r.dataId,shape:l,dtype:r.dtype})}const wZ={kernelName:tm,backendName:"webgl",kernelFunc:re};/** + */function re(t){const{inputs:e,backend:n,attrs:s}=t,{x:r}=e,{shape:o}=s,i=n,a=j(r.shape),l=KI(o,a),c=j(l);I(a===c,()=>`The new shape (${l}) has ${c} elements and the old shape (${r.shape}) has ${a} elements. The new shape and old shape must have the same number of elements.`);const u=i.texData.get(r.dataId);return u.isPacked&&!Pf(r.shape,l)&&!(u.texture!==null&&Pf(u.shape,l))?xZ(r,l,i):(i.incRef(r.dataId),{dataId:r.dataId,shape:l,dtype:r.dtype})}const yZ={kernelName:tm,backendName:"webgl",kernelFunc:re};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -13169,7 +13169,7 @@ vec2 packedUVfrom3D(int texNumR, int texNumC, * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */class vZ{constructor(e,n){this.variableNames=["x"];const{windowSize:s,batchSize:r,inSize:o,outSize:i}=e;this.outputShape=[r,i];let a="0.0",l="";n==="prod"?a="1.0":n==="min"?(a="1.0 / 1e-20",l="min"):n==="max"&&(a="-1.0 / 1e-20",l="max");let c=`${n}(${n}(${n}(minMaxValue[0], minMaxValue[1]), minMaxValue[2]), minMaxValue[3])`;n==="sum"?c="sumValue":n==="prod"?c="prodValue":n==="all"?c="allValue":n==="any"&&(c="anyValue");const u=Math.floor(s/4)*4,h=s%4;let d=` + */class wZ{constructor(e,n){this.variableNames=["x"];const{windowSize:s,batchSize:r,inSize:o,outSize:i}=e;this.outputShape=[r,i];let a="0.0",l="";n==="prod"?a="1.0":n==="min"?(a="1.0 / 1e-20",l="min"):n==="max"&&(a="-1.0 / 1e-20",l="max");let c=`${n}(${n}(${n}(minMaxValue[0], minMaxValue[1]), minMaxValue[2]), minMaxValue[3])`;n==="sum"?c="sumValue":n==="prod"?c="prodValue":n==="all"?c="allValue":n==="any"&&(c="anyValue");const u=Math.floor(s/4)*4,h=s%4;let d=` if (${n==="sum"}) { sumValue += dot(values, ones); } else if (${n==="prod"}) { @@ -13276,7 +13276,7 @@ vec2 packedUVfrom3D(int texNumR, int texNumC, * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function bZ(t){const e=[];for(;e.length===0||e[e.length-1].outSize!==1;){const n=e.length?e[e.length-1].outSize:t[1],s=Cm(n);e.push({inSize:n,windowSize:s,outSize:Math.ceil(n/s)})}return e}function sa(t,e,n,s){const r=bZ(t.shape);let o=t;for(let i=0;i6)throw Error(`Transpose for rank ${e} is not yet supported`);const n=["resRC.x","resRC.y","resRC.z","resRC.w","resRC.u","resRC.v"],s=new Array(e);for(let r=0;r6)throw Error(`Transpose for rank ${e} is not yet supported`);const n=["resRC.x","resRC.y","resRC.z","resRC.w","resRC.u","resRC.v"],s=new Array(e);for(let r=0;r6)throw Error(`Packed transpose for rank ${this.rank} is not yet supported.`);const r=Ze(this.rank),o=tD("rc",this.rank),i=new Array(this.rank);for(let u=0;u6)throw Error(`Packed transpose for rank ${this.rank} is not yet supported.`);const r=Ze(this.rank),o=tD("rc",this.rank),i=new Array(this.rank);for(let u=0;u`Error in matMul: inner shapes (${h}) and (${d}) of Tensors with shapes ${t.shape} and ${e.shape} and transposeA=${n} and transposeB=${s} must match.`);const b=n?[m,h,f]:[m,f,h],C=s?[y,p,d]:[y,d,p],k=re({inputs:{x:t},backend:r,attrs:{shape:b}}),S=re({inputs:{x:e},backend:r,attrs:{shape:C}}),$=[k,S],N=Math.max(m,y),A=n?k.shape[1]:k.shape[2],M=o!=null,L=i!=null,V=l==="leakyrelu",B=l!=null?tu(l,!0):null,U=M||L||V||B!=null;let K;if((f===1||p===1)&&A>lD&&U===!1){let O=k,G=S;n&&(O=Sn({inputs:{x:k},backend:r,attrs:{perm:[0,2,1]}}),$.push(O)),s&&(G=Sn({inputs:{x:S},backend:r,attrs:{perm:[0,2,1]}}),$.push(G));const X=p!==1,q=p===1;let Q=O;X&&(Q=re({inputs:{x:O},backend:r,attrs:{shape:[N,A,1]}}),$.push(Q));const te=p===1?2:1;let Z=G;q&&(Z=re({inputs:{x:G},backend:r,attrs:{shape:[N,1,A]}}),$.push(Z));const se=$v({inputs:{a:Q,b:Z},backend:r});K=Bm({inputs:{x:se},backend:r,attrs:{axis:te,keepDims:!0}}),$.push(se)}else{const O=Xn(t.dtype,e.dtype),G=new aD(b,C,[N,f,p],n,s,M,B,L,V),X=[k,S];if(o!=null&&X.push(o),L&&X.push(i),V){const q=r.makeTensorInfo([],"float32",Wo(a,"float32"));X.push(q),$.push(q)}K=r.runWebGLProgram(G,X,O)}const R=re({inputs:{x:K},backend:r,attrs:{shape:v}});$.push(K);for(const O of $)r.disposeIntermediateTensorInfo(O);return R}/** + */const lD=1e3;function Lf({a:t,b:e,transposeA:n,transposeB:s,backend:r,bias:o=null,preluActivationWeights:i=null,leakyreluAlpha:a=0,activation:l=null}){const c=t.shape.length,u=e.shape.length,h=n?t.shape[c-2]:t.shape[c-1],d=s?e.shape[u-1]:e.shape[u-2],f=n?t.shape[c-1]:t.shape[c-2],p=s?e.shape[u-2]:e.shape[u-1],g=t.shape.slice(0,-2),x=e.shape.slice(0,-2),m=j(g),y=j(x),v=Se(t.shape.slice(0,-2),e.shape.slice(0,-2)).concat([f,p]);I(h===d,()=>`Error in matMul: inner shapes (${h}) and (${d}) of Tensors with shapes ${t.shape} and ${e.shape} and transposeA=${n} and transposeB=${s} must match.`);const b=n?[m,h,f]:[m,f,h],C=s?[y,p,d]:[y,d,p],k=re({inputs:{x:t},backend:r,attrs:{shape:b}}),S=re({inputs:{x:e},backend:r,attrs:{shape:C}}),$=[k,S],N=Math.max(m,y),A=n?k.shape[1]:k.shape[2],M=o!=null,L=i!=null,V=l==="leakyrelu",B=l!=null?tu(l,!0):null,U=M||L||V||B!=null;let K;if((f===1||p===1)&&A>lD&&U===!1){let O=k,G=S;n&&(O=Sn({inputs:{x:k},backend:r,attrs:{perm:[0,2,1]}}),$.push(O)),s&&(G=Sn({inputs:{x:S},backend:r,attrs:{perm:[0,2,1]}}),$.push(G));const X=p!==1,q=p===1;let Q=O;X&&(Q=re({inputs:{x:O},backend:r,attrs:{shape:[N,A,1]}}),$.push(Q));const te=p===1?2:1;let Z=G;q&&(Z=re({inputs:{x:G},backend:r,attrs:{shape:[N,1,A]}}),$.push(Z));const se=$v({inputs:{a:Q,b:Z},backend:r});K=Bm({inputs:{x:se},backend:r,attrs:{axis:te,keepDims:!0}}),$.push(se)}else{const O=Xn(t.dtype,e.dtype),G=new aD(b,C,[N,f,p],n,s,M,B,L,V),X=[k,S];if(o!=null&&X.push(o),L&&X.push(i),V){const q=r.makeTensorInfo([],"float32",Wo(a,"float32"));X.push(q),$.push(q)}K=r.runWebGLProgram(G,X,O)}const R=re({inputs:{x:K},backend:r,attrs:{shape:v}});$.push(K);for(const O of $)r.disposeIntermediateTensorInfo(O);return R}/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the License); @@ -13418,7 +13418,7 @@ vec2 packedUVfrom3D(int texNumR, int texNumC, * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function TZ(t){const{inputs:e,backend:n,attrs:s}=t,{a:r,b:o,bias:i,preluActivationWeights:a}=e,{transposeA:l,transposeB:c,activation:u,leakyreluAlpha:h}=s;return Bf({a:r,b:o,transposeA:l,transposeB:c,backend:n,bias:i,preluActivationWeights:a,leakyreluAlpha:h,activation:u})}const EZ={kernelName:ff,backendName:"webgl",kernelFunc:TZ};/** + */function NZ(t){const{inputs:e,backend:n,attrs:s}=t,{a:r,b:o,bias:i,preluActivationWeights:a}=e,{transposeA:l,transposeB:c,activation:u,leakyreluAlpha:h}=s;return Lf({a:r,b:o,transposeA:l,transposeB:c,backend:n,bias:i,preluActivationWeights:a,leakyreluAlpha:h,activation:u})}const TZ={kernelName:df,backendName:"webgl",kernelFunc:NZ};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -13433,7 +13433,7 @@ vec2 packedUVfrom3D(int texNumR, int texNumC, * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const zk="return abs(x);";function RZ(t){const{inputs:e,backend:n}=t,{x:s}=e;if(n.shouldExecuteOnCPU([s])&&s.dtype!=="complex64"){const o=n.texData.get(s.dataId),i=JA(o.values);return n.makeTensorInfo(s.shape,s.dtype,i)}let r;return W().getBool("WEBGL_PACK_UNARY_OPERATIONS")?r=new po(s.shape,zk):r=new pr(s.shape,zk),n.runWebGLProgram(r,[s],s.dtype)}const AZ={kernelName:pp,backendName:"webgl",kernelFunc:RZ};/** + */const zk="return abs(x);";function EZ(t){const{inputs:e,backend:n}=t,{x:s}=e;if(n.shouldExecuteOnCPU([s])&&s.dtype!=="complex64"){const o=n.texData.get(s.dataId),i=JA(o.values);return n.makeTensorInfo(s.shape,s.dtype,i)}let r;return W().getBool("WEBGL_PACK_UNARY_OPERATIONS")?r=new po(s.shape,zk):r=new pr(s.shape,zk),n.runWebGLProgram(r,[s],s.dtype)}const RZ={kernelName:pp,backendName:"webgl",kernelFunc:EZ};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -13448,12 +13448,12 @@ vec2 packedUVfrom3D(int texNumR, int texNumC, * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const DZ=_s+` + */const AZ=_s+` if (abs(x) > 1.) { return NAN; } return acos(x); -`,_Z=Oe({opSnippet:DZ}),FZ={kernelName:pu,backendName:"webgl",kernelFunc:_Z};/** +`,DZ=Oe({opSnippet:AZ}),_Z={kernelName:fu,backendName:"webgl",kernelFunc:DZ};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -13468,9 +13468,9 @@ vec2 packedUVfrom3D(int texNumR, int texNumC, * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const zZ=_s+` + */const FZ=_s+` if (x < 1.0) return NAN; -return log(x + sqrt(x * x - 1.0));`,OZ=Oe({opSnippet:zZ}),MZ={kernelName:mu,backendName:"webgl",kernelFunc:OZ};/** +return log(x + sqrt(x * x - 1.0));`,zZ=Oe({opSnippet:FZ}),OZ={kernelName:pu,backendName:"webgl",kernelFunc:zZ};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -13485,7 +13485,7 @@ return log(x + sqrt(x * x - 1.0));`,OZ=Oe({opSnippet:zZ}),MZ={kernelName:mu,back * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const Ok="return a + b;",PZ=rn({opSnippet:Ok,packedOpSnippet:Ok,supportsComplex:!0,cpuKernelImpl:XY}),LZ={kernelName:bl,backendName:"webgl",kernelFunc:PZ};/** + */const Ok="return a + b;",MZ=rn({opSnippet:Ok,packedOpSnippet:Ok,supportsComplex:!0,cpuKernelImpl:KY}),PZ={kernelName:bl,backendName:"webgl",kernelFunc:MZ};/** * @license * Copyright 2019 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -13500,7 +13500,7 @@ return log(x + sqrt(x * x - 1.0));`,OZ=Oe({opSnippet:zZ}),MZ={kernelName:mu,back * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */class BZ{constructor(e,n){this.outputShape=[],this.outputShape=e,this.variableNames=n.map((o,i)=>`T${i}`);const s=[];this.variableNames.forEach(o=>{s.push(`float v${o} = get${o}AtOutCoords();`)});const r=this.variableNames.map(o=>`v${o}`).join(" + ");this.userCode=` + */class LZ{constructor(e,n){this.outputShape=[],this.outputShape=e,this.variableNames=n.map((o,i)=>`T${i}`);const s=[];this.variableNames.forEach(o=>{s.push(`float v${o} = get${o}AtOutCoords();`)});const r=this.variableNames.map(o=>`v${o}`).join(" + ");this.userCode=` void main() { ${s.join(` `)} @@ -13523,7 +13523,7 @@ return log(x + sqrt(x * x - 1.0));`,OZ=Oe({opSnippet:zZ}),MZ={kernelName:mu,back * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */class VZ{constructor(e,n){this.outputShape=[],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=e,this.variableNames=n.map((o,i)=>`T${i}`);const s=[];this.variableNames.forEach(o=>{s.push(`vec4 v${o} = get${o}AtOutCoords();`)});const r=this.variableNames.map(o=>`v${o}`).join(" + ");this.userCode=` + */class BZ{constructor(e,n){this.outputShape=[],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=e,this.variableNames=n.map((o,i)=>`T${i}`);const s=[];this.variableNames.forEach(o=>{s.push(`vec4 v${o} = get${o}AtOutCoords();`)});const r=this.variableNames.map(o=>`v${o}`).join(" + ");this.userCode=` void main() { ${s.join(` `)} @@ -13546,7 +13546,7 @@ return log(x + sqrt(x * x - 1.0));`,OZ=Oe({opSnippet:zZ}),MZ={kernelName:mu,back * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function _d(t){const{inputs:e,backend:n}=t,s=e;if(s.length===1)return Yn({inputs:{x:s[0]},backend:n});if(s.length>W().getNumber("WEBGL_MAX_TEXTURES_IN_SHADER")){const l=Math.floor(s.length/2),c=_d({inputs:s.slice(0,l),backend:n}),u=_d({inputs:s.slice(l),backend:n});return _d({inputs:[c,u],backend:n})}const r=s.map(l=>l.dtype).reduce((l,c)=>Xn(l,c)),o=s.map(l=>l.shape),a=W().getBool("WEBGL_PACK")?new VZ(s[0].shape,o):new BZ(s[0].shape,o);return n.runWebGLProgram(a,s,r)}const WZ={kernelName:Gx,backendName:"webgl",kernelFunc:_d};/** + */function Dd(t){const{inputs:e,backend:n}=t,s=e;if(s.length===1)return Yn({inputs:{x:s[0]},backend:n});if(s.length>W().getNumber("WEBGL_MAX_TEXTURES_IN_SHADER")){const l=Math.floor(s.length/2),c=Dd({inputs:s.slice(0,l),backend:n}),u=Dd({inputs:s.slice(l),backend:n});return Dd({inputs:[c,u],backend:n})}const r=s.map(l=>l.dtype).reduce((l,c)=>Xn(l,c)),o=s.map(l=>l.shape),a=W().getBool("WEBGL_PACK")?new BZ(s[0].shape,o):new LZ(s[0].shape,o);return n.runWebGLProgram(a,s,r)}const VZ={kernelName:Gx,backendName:"webgl",kernelFunc:Dd};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -13561,7 +13561,7 @@ return log(x + sqrt(x * x - 1.0));`,OZ=Oe({opSnippet:zZ}),MZ={kernelName:mu,back * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function UZ(t){const{inputs:e,backend:n,attrs:s}=t,{x:r}=e,{axis:o,keepDims:i}=s,a=r.shape.length,l=Re(o,r.shape);let c=l;const u=yt(c,a);let h=r;u!=null&&(h=Sn({inputs:{x:r},backend:n,attrs:{perm:u}}),c=$t(c.length,a)),sn("all",c,a);const[d,f]=Yt(h.shape,c),p=j(f),g=re({inputs:{x:h},backend:n,attrs:{shape:[-1,p]}}),x=sa(g,g.dtype,"all",n);let m;if(i){const y=Dt(d,l);m=re({inputs:{x},backend:n,attrs:{shape:y}})}else m=re({inputs:{x},backend:n,attrs:{shape:d}});return n.disposeIntermediateTensorInfo(g),n.disposeIntermediateTensorInfo(x),u!=null&&n.disposeIntermediateTensorInfo(h),m}const GZ={kernelName:Hx,backendName:"webgl",kernelFunc:UZ};/** + */function WZ(t){const{inputs:e,backend:n,attrs:s}=t,{x:r}=e,{axis:o,keepDims:i}=s,a=r.shape.length,l=Re(o,r.shape);let c=l;const u=yt(c,a);let h=r;u!=null&&(h=Sn({inputs:{x:r},backend:n,attrs:{perm:u}}),c=$t(c.length,a)),sn("all",c,a);const[d,f]=Yt(h.shape,c),p=j(f),g=re({inputs:{x:h},backend:n,attrs:{shape:[-1,p]}}),x=sa(g,g.dtype,"all",n);let m;if(i){const y=Dt(d,l);m=re({inputs:{x},backend:n,attrs:{shape:y}})}else m=re({inputs:{x},backend:n,attrs:{shape:d}});return n.disposeIntermediateTensorInfo(g),n.disposeIntermediateTensorInfo(x),u!=null&&n.disposeIntermediateTensorInfo(h),m}const UZ={kernelName:Hx,backendName:"webgl",kernelFunc:WZ};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -13576,7 +13576,7 @@ return log(x + sqrt(x * x - 1.0));`,OZ=Oe({opSnippet:zZ}),MZ={kernelName:mu,back * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function HZ(t){const{inputs:e,backend:n,attrs:s}=t,{x:r}=e,{axis:o,keepDims:i}=s,a=r.shape.length,l=Re(o,r.shape);let c=l;const u=yt(c,a);let h=r;u!=null&&(h=Sn({inputs:{x:r},backend:n,attrs:{perm:u}}),c=$t(c.length,a)),sn("any",c,a);const[d,f]=Yt(h.shape,c),p=j(f),g=re({inputs:{x:h},backend:n,attrs:{shape:[-1,p]}}),x=sa(g,g.dtype,"any",n);let m;if(i){const y=Dt(d,l);m=re({inputs:{x},backend:n,attrs:{shape:y}})}else m=re({inputs:{x},backend:n,attrs:{shape:d}});return n.disposeIntermediateTensorInfo(g),n.disposeIntermediateTensorInfo(x),u!=null&&n.disposeIntermediateTensorInfo(h),m}const jZ={kernelName:jx,backendName:"webgl",kernelFunc:HZ};/** + */function GZ(t){const{inputs:e,backend:n,attrs:s}=t,{x:r}=e,{axis:o,keepDims:i}=s,a=r.shape.length,l=Re(o,r.shape);let c=l;const u=yt(c,a);let h=r;u!=null&&(h=Sn({inputs:{x:r},backend:n,attrs:{perm:u}}),c=$t(c.length,a)),sn("any",c,a);const[d,f]=Yt(h.shape,c),p=j(f),g=re({inputs:{x:h},backend:n,attrs:{shape:[-1,p]}}),x=sa(g,g.dtype,"any",n);let m;if(i){const y=Dt(d,l);m=re({inputs:{x},backend:n,attrs:{shape:y}})}else m=re({inputs:{x},backend:n,attrs:{shape:d}});return n.disposeIntermediateTensorInfo(g),n.disposeIntermediateTensorInfo(x),u!=null&&n.disposeIntermediateTensorInfo(h),m}const HZ={kernelName:jx,backendName:"webgl",kernelFunc:GZ};/** * @license * Copyright 2017 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -13591,7 +13591,7 @@ return log(x + sqrt(x * x - 1.0));`,OZ=Oe({opSnippet:zZ}),MZ={kernelName:mu,back * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */class KZ{constructor(e,n,s){this.variableNames=["A"];const{windowSize:r,batchSize:o,outSize:i}=e;s||this.variableNames.push("bestIndicesA"),this.outputShape=[o,i];const a=n==="max"?">":"<",l=s?"inOffset + i;":"round(getBestIndicesA(batch, inOffset + i));";this.userCode=` + */class jZ{constructor(e,n,s){this.variableNames=["A"];const{windowSize:r,batchSize:o,outSize:i}=e;s||this.variableNames.push("bestIndicesA"),this.outputShape=[o,i];const a=n==="max"?">":"<",l=s?"inOffset + i;":"round(getBestIndicesA(batch, inOffset + i));";this.userCode=` void main() { ivec2 coords = getOutputCoords(); int batch = coords[0]; @@ -13626,7 +13626,7 @@ return log(x + sqrt(x * x - 1.0));`,OZ=Oe({opSnippet:zZ}),MZ={kernelName:mu,back * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */class XZ{constructor(e,n,s,r){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,I(e.length>2,()=>`Packed arg${s.charAt(0).toUpperCase()+s.slice(1)} supports only inputs with rank above 2.`);const o=e[e.length-1],i=Math.ceil(o/n);this.outputShape=e.slice(0,-1),i>1&&this.outputShape.push(i),r||this.variableNames.push("bestIndicesA");const a=this.outputShape,l=a.length,c=Ze(l),u=vn("coords",l);let h,d;if(i===1){d=l+1;const S=Ze(d);h=` + */class KZ{constructor(e,n,s,r){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,I(e.length>2,()=>`Packed arg${s.charAt(0).toUpperCase()+s.slice(1)} supports only inputs with rank above 2.`);const o=e[e.length-1],i=Math.ceil(o/n);this.outputShape=e.slice(0,-1),i>1&&this.outputShape.push(i),r||this.variableNames.push("bestIndicesA");const a=this.outputShape,l=a.length,c=Ze(l),u=vn("coords",l);let h,d;if(i===1){d=l+1;const S=Ze(d);h=` ${S} sourceLocR = ${S}(${u.join()}, 0); ++${u[l-1]}; ${S} sourceLocG = ${S}(${u.join()}, 0); @@ -13703,7 +13703,7 @@ return log(x + sqrt(x * x - 1.0));`,OZ=Oe({opSnippet:zZ}),MZ={kernelName:mu,back * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function cD(t,e,n,s=null){let r=e.shape[0],o=e.shape[1];s!=null&&(r=s.shape[0],o=s.shape[1]);const i=Cm(o),a={windowSize:i,inSize:o,batchSize:r,outSize:Math.ceil(o/i)},l=new KZ(a,n,s==null),c=[e];s!=null&&c.push(s);const u=t.runWebGLProgram(l,c,"int32");if(u.shape[1]===1)return u;const h=cD(t,e,n,u);return t.disposeIntermediateTensorInfo(u),h}function uD(t,e,n,s=null){const r=s!=null?s.shape:e.shape,o=r[r.length-1],i=Cm(o),a=new XZ(r,i,n,s==null),l=s==null?[e]:[e,s],c=t.runWebGLProgram(a,l,"int32");if(c.shape.length===e.shape.length){const u=uD(t,e,n,c);return t.disposeIntermediateTensorInfo(c),u}return c}function hD(t,e,n,s){const r=[n];if(sn("arg"+s.charAt(0).toUpperCase()+s.slice(1),r,e.shape.length),!W().getBool("WEBGL_PACK_REDUCE")||e.shape.length<=2){const o=[],i=t.texData.get(e.dataId),a=i!==null&&i.isPacked;let l=e;a&&(l=t.unpackTensor(e),o.push(l));const[c,u]=Yt(l.shape,r),h=j(u),d=re({inputs:{x:l},backend:t,attrs:{shape:[-1,h]}});o.push(d);const f=cD(t,d,s);o.push(f);const p=re({inputs:{x:f},backend:t,attrs:{shape:c}});return o.forEach(g=>t.disposeIntermediateTensorInfo(g)),p}return uD(t,e,s)}/** + */function cD(t,e,n,s=null){let r=e.shape[0],o=e.shape[1];s!=null&&(r=s.shape[0],o=s.shape[1]);const i=Cm(o),a={windowSize:i,inSize:o,batchSize:r,outSize:Math.ceil(o/i)},l=new jZ(a,n,s==null),c=[e];s!=null&&c.push(s);const u=t.runWebGLProgram(l,c,"int32");if(u.shape[1]===1)return u;const h=cD(t,e,n,u);return t.disposeIntermediateTensorInfo(u),h}function uD(t,e,n,s=null){const r=s!=null?s.shape:e.shape,o=r[r.length-1],i=Cm(o),a=new KZ(r,i,n,s==null),l=s==null?[e]:[e,s],c=t.runWebGLProgram(a,l,"int32");if(c.shape.length===e.shape.length){const u=uD(t,e,n,c);return t.disposeIntermediateTensorInfo(c),u}return c}function hD(t,e,n,s){const r=[n];if(sn("arg"+s.charAt(0).toUpperCase()+s.slice(1),r,e.shape.length),!W().getBool("WEBGL_PACK_REDUCE")||e.shape.length<=2){const o=[],i=t.texData.get(e.dataId),a=i!==null&&i.isPacked;let l=e;a&&(l=t.unpackTensor(e),o.push(l));const[c,u]=Yt(l.shape,r),h=j(u),d=re({inputs:{x:l},backend:t,attrs:{shape:[-1,h]}});o.push(d);const f=cD(t,d,s);o.push(f);const p=re({inputs:{x:f},backend:t,attrs:{shape:c}});return o.forEach(g=>t.disposeIntermediateTensorInfo(g)),p}return uD(t,e,s)}/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -13718,7 +13718,7 @@ return log(x + sqrt(x * x - 1.0));`,OZ=Oe({opSnippet:zZ}),MZ={kernelName:mu,back * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function qZ(t){const{inputs:e,backend:n,attrs:s}=t,{x:r}=e,{axis:o}=s;let i=Re(o,r.shape);const a=yt(i,r.shape.length);let l=r;const c=[];a!=null&&(l=Sn({inputs:{x:r},backend:n,attrs:{perm:a}}),c.push(l),i=$t(i.length,l.shape.length)),sn("argMax",[i[0]],l.shape.length);const u=hD(n,l,i[0],"max");return c.forEach(h=>n.disposeIntermediateTensorInfo(h)),u}const YZ={kernelName:mp,backendName:"webgl",kernelFunc:qZ};/** + */function XZ(t){const{inputs:e,backend:n,attrs:s}=t,{x:r}=e,{axis:o}=s;let i=Re(o,r.shape);const a=yt(i,r.shape.length);let l=r;const c=[];a!=null&&(l=Sn({inputs:{x:r},backend:n,attrs:{perm:a}}),c.push(l),i=$t(i.length,l.shape.length)),sn("argMax",[i[0]],l.shape.length);const u=hD(n,l,i[0],"max");return c.forEach(h=>n.disposeIntermediateTensorInfo(h)),u}const qZ={kernelName:mp,backendName:"webgl",kernelFunc:XZ};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -13733,7 +13733,7 @@ return log(x + sqrt(x * x - 1.0));`,OZ=Oe({opSnippet:zZ}),MZ={kernelName:mu,back * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function QZ(t){const{inputs:e,backend:n,attrs:s}=t,{x:r}=e,{axis:o}=s;let i=Re(o,r.shape);const a=yt(i,r.shape.length);let l=r;const c=[];a!=null&&(l=Sn({inputs:{x:r},backend:n,attrs:{perm:a}}),c.push(l),i=$t(i.length,l.shape.length)),sn("argMin",[i[0]],l.shape.length);const u=hD(n,l,i[0],"min");return c.forEach(h=>n.disposeIntermediateTensorInfo(h)),u}const ZZ={kernelName:gp,backendName:"webgl",kernelFunc:QZ};/** + */function YZ(t){const{inputs:e,backend:n,attrs:s}=t,{x:r}=e,{axis:o}=s;let i=Re(o,r.shape);const a=yt(i,r.shape.length);let l=r;const c=[];a!=null&&(l=Sn({inputs:{x:r},backend:n,attrs:{perm:a}}),c.push(l),i=$t(i.length,l.shape.length)),sn("argMin",[i[0]],l.shape.length);const u=hD(n,l,i[0],"min");return c.forEach(h=>n.disposeIntermediateTensorInfo(h)),u}const QZ={kernelName:gp,backendName:"webgl",kernelFunc:YZ};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -13748,12 +13748,12 @@ return log(x + sqrt(x * x - 1.0));`,OZ=Oe({opSnippet:zZ}),MZ={kernelName:mu,back * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const JZ=_s+` + */const ZZ=_s+` if (abs(x) > 1.) { return NAN; } return asin(x); -`,eJ=Oe({opSnippet:JZ}),tJ={kernelName:gu,backendName:"webgl",kernelFunc:eJ};/** +`,JZ=Oe({opSnippet:ZZ}),eJ={kernelName:mu,backendName:"webgl",kernelFunc:JZ};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -13768,7 +13768,7 @@ return log(x + sqrt(x * x - 1.0));`,OZ=Oe({opSnippet:zZ}),MZ={kernelName:mu,back * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const nJ=_s+"return log(x + sqrt(x * x + 1.0));",sJ=Oe({opSnippet:nJ}),rJ={kernelName:xu,backendName:"webgl",kernelFunc:sJ};/** + */const tJ=_s+"return log(x + sqrt(x * x + 1.0));",nJ=Oe({opSnippet:tJ}),sJ={kernelName:gu,backendName:"webgl",kernelFunc:nJ};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -13783,9 +13783,9 @@ return log(x + sqrt(x * x - 1.0));`,OZ=Oe({opSnippet:zZ}),MZ={kernelName:mu,back * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const oJ=_s+` + */const rJ=_s+` return atan(x); -`,iJ=Oe({opSnippet:oJ}),aJ={kernelName:yu,backendName:"webgl",kernelFunc:iJ};/** +`,oJ=Oe({opSnippet:rJ}),iJ={kernelName:xu,backendName:"webgl",kernelFunc:oJ};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -13800,16 +13800,16 @@ return log(x + sqrt(x * x - 1.0));`,OZ=Oe({opSnippet:zZ}),MZ={kernelName:mu,back * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const lJ=Iv+` + */const aJ=Iv+` return atan(a, b); -`,cJ=` +`,lJ=` vec4 result = atan(a, b); bvec4 isNaNA = isnan(a); bvec4 isNaNB = isnan(b); bvec4 isNaN = bvec4(isNaNA.x || isNaNB.x, isNaNA.y || isNaNB.y, isNaNA.z || isNaNB.z, isNaNA.w || isNaNB.w); `+na+` return result; -`,uJ=rn({opSnippet:lJ,packedOpSnippet:cJ}),hJ={kernelName:vu,backendName:"webgl",kernelFunc:uJ};/** +`,cJ=rn({opSnippet:aJ,packedOpSnippet:lJ}),uJ={kernelName:wu,backendName:"webgl",kernelFunc:cJ};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -13824,9 +13824,9 @@ return log(x + sqrt(x * x - 1.0));`,OZ=Oe({opSnippet:zZ}),MZ={kernelName:mu,back * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const dJ=_s+` + */const hJ=_s+` if ((x < -1.0) || (x > 1.0)) return NAN; -return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,fJ=Oe({opSnippet:dJ}),pJ={kernelName:wu,backendName:"webgl",kernelFunc:fJ};/** +return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,dJ=Oe({opSnippet:hJ}),fJ={kernelName:yu,backendName:"webgl",kernelFunc:dJ};/** * @license * Copyright 2017 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -14160,7 +14160,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,fJ=Oe({opSnippet:dJ}),pJ={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function mJ(t){const{inputs:e,backend:n,attrs:s}=t,{x:r}=e;Eh(r,"avgPool");const{filterSize:o,strides:i,pad:a,dimRoundingMode:l}=s,c=1;I(dn(i,c),()=>`Error in avgPool: Either strides or dilations must be 1. Got strides ${i} and dilations '${c}'`);const u=As(r.shape,o,i,c,a,l);if(u.filterWidth===1&&u.filterHeight===1&&Ue(u.inShape,u.outShape))return Yn({inputs:{x:r},backend:n});const h=new nu(u,"avg",!1);return n.runWebGLProgram(h,[r],"float32")}const gJ={kernelName:xp,backendName:"webgl",kernelFunc:mJ};/** + */function pJ(t){const{inputs:e,backend:n,attrs:s}=t,{x:r}=e;Th(r,"avgPool");const{filterSize:o,strides:i,pad:a,dimRoundingMode:l}=s,c=1;I(dn(i,c),()=>`Error in avgPool: Either strides or dilations must be 1. Got strides ${i} and dilations '${c}'`);const u=As(r.shape,o,i,c,a,l);if(u.filterWidth===1&&u.filterHeight===1&&Ue(u.inShape,u.outShape))return Yn({inputs:{x:r},backend:n});const h=new nu(u,"avg",!1);return n.runWebGLProgram(h,[r],"float32")}const mJ={kernelName:xp,backendName:"webgl",kernelFunc:pJ};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -14175,7 +14175,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,fJ=Oe({opSnippet:dJ}),pJ={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function xJ(t){const{inputs:e,backend:n,attrs:s}=t,{x:r}=e,{filterSize:o,strides:i,pad:a,dimRoundingMode:l,dataFormat:c}=s,u=[1,1,1],h=Yr(r.shape,o,i,u,a,l,c),d=new Nv(h,"avg",!1);return n.runWebGLProgram(d,[r],"float32")}const yJ={kernelName:yp,backendName:"webgl",kernelFunc:xJ};/** + */function gJ(t){const{inputs:e,backend:n,attrs:s}=t,{x:r}=e,{filterSize:o,strides:i,pad:a,dimRoundingMode:l,dataFormat:c}=s,u=[1,1,1],h=Yr(r.shape,o,i,u,a,l,c),d=new Nv(h,"avg",!1);return n.runWebGLProgram(d,[r],"float32")}const xJ={kernelName:yp,backendName:"webgl",kernelFunc:gJ};/** * @license * Copyright 2017 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -14190,7 +14190,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,fJ=Oe({opSnippet:dJ}),pJ={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */class wJ{constructor(e){this.variableNames=["dy"],this.outputShape=e.inShape;const n=e.filterHeight,s=e.filterWidth,r=e.strideHeight,o=e.strideWidth,i=e.dilationHeight,a=e.dilationWidth,l=e.effectiveFilterHeight,c=e.effectiveFilterWidth,u=l-1-e.padInfo.top,h=c-1-e.padInfo.left,d=1/(n*s);this.userCode=` + */class yJ{constructor(e){this.variableNames=["dy"],this.outputShape=e.inShape;const n=e.filterHeight,s=e.filterWidth,r=e.strideHeight,o=e.strideWidth,i=e.dilationHeight,a=e.dilationWidth,l=e.effectiveFilterHeight,c=e.effectiveFilterWidth,u=l-1-e.padInfo.top,h=c-1-e.padInfo.left,d=1/(n*s);this.userCode=` const ivec2 pads = ivec2(${u}, ${h}); const float avgMultiplier = float(${d}); @@ -14232,7 +14232,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,fJ=Oe({opSnippet:dJ}),pJ={kernelNam } setOutput(dotProd); } - `}}class vJ{constructor(e){this.variableNames=["dy"],this.outputShape=e.inShape;const n=e.filterDepth,s=e.filterHeight,r=e.filterWidth,o=e.strideDepth,i=e.strideHeight,a=e.strideWidth,l=e.dilationDepth,c=e.dilationHeight,u=e.dilationWidth,h=e.effectiveFilterDepth,d=e.effectiveFilterHeight,f=e.effectiveFilterWidth,p=h-1-e.padInfo.front,g=d-1-e.padInfo.top,x=f-1-e.padInfo.left,m=1/(n*s*r);this.userCode=` + `}}class wJ{constructor(e){this.variableNames=["dy"],this.outputShape=e.inShape;const n=e.filterDepth,s=e.filterHeight,r=e.filterWidth,o=e.strideDepth,i=e.strideHeight,a=e.strideWidth,l=e.dilationDepth,c=e.dilationHeight,u=e.dilationWidth,h=e.effectiveFilterDepth,d=e.effectiveFilterHeight,f=e.effectiveFilterWidth,p=h-1-e.padInfo.front,g=d-1-e.padInfo.top,x=f-1-e.padInfo.left,m=1/(n*s*r);this.userCode=` const ivec3 pads = ivec3(${p}, ${g}, ${x}); const float avgMultiplier = float(${m}); @@ -14303,7 +14303,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,fJ=Oe({opSnippet:dJ}),pJ={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function bJ(t){const{inputs:e,backend:n,attrs:s}=t,{dy:r,input:o}=e,i=o,{filterSize:a,strides:l,pad:c,dimRoundingMode:u}=s,h=[1,1,1],d=Yr(i.shape,a,l,h,c,u),f=new vJ(d);return n.runWebGLProgram(f,[r],i.dtype)}const CJ={kernelName:Xx,backendName:"webgl",kernelFunc:bJ};/** + */function vJ(t){const{inputs:e,backend:n,attrs:s}=t,{dy:r,input:o}=e,i=o,{filterSize:a,strides:l,pad:c,dimRoundingMode:u}=s,h=[1,1,1],d=Yr(i.shape,a,l,h,c,u),f=new wJ(d);return n.runWebGLProgram(f,[r],i.dtype)}const bJ={kernelName:Xx,backendName:"webgl",kernelFunc:vJ};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -14318,7 +14318,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,fJ=Oe({opSnippet:dJ}),pJ={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function kJ(t){const{inputs:e,backend:n,attrs:s}=t,{dy:r,input:o}=e,i=o;Eh([r,o],"avgPoolGrad");const{filterSize:a,strides:l,pad:c}=s,u=As(i.shape,a,l,1,c),h=new wJ(u);return n.runWebGLProgram(h,[r],i.dtype)}const SJ={kernelName:Kx,backendName:"webgl",kernelFunc:kJ};/** + */function CJ(t){const{inputs:e,backend:n,attrs:s}=t,{dy:r,input:o}=e,i=o;Th([r,o],"avgPoolGrad");const{filterSize:a,strides:l,pad:c}=s,u=As(i.shape,a,l,1,c),h=new yJ(u);return n.runWebGLProgram(h,[r],i.dtype)}const kJ={kernelName:Kx,backendName:"webgl",kernelFunc:CJ};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -14333,7 +14333,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,fJ=Oe({opSnippet:dJ}),pJ={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function IJ(t){const{inputs:e,backend:n,attrs:s}=t,{a:r,b:o}=e,{transposeA:i,transposeB:a}=s;return Bf({a:r,b:o,transposeA:i,transposeB:a,backend:n})}const $J={kernelName:wp,backendName:"webgl",kernelFunc:IJ};/** + */function SJ(t){const{inputs:e,backend:n,attrs:s}=t,{a:r,b:o}=e,{transposeA:i,transposeB:a}=s;return Lf({a:r,b:o,transposeA:i,transposeB:a,backend:n})}const IJ={kernelName:wp,backendName:"webgl",kernelFunc:SJ};/** * @license * Copyright 2017 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -14348,7 +14348,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,fJ=Oe({opSnippet:dJ}),pJ={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */class NJ{constructor(e,n,s,r,o,i){this.outputShape=[],this.variableNames=["x","mean","variance"],Se(e,n),Se(e,s);let a="0.0";r!=null&&(Se(e,r),this.variableNames.push("offset"),a="getOffsetAtOutCoords()");let l="1.0";o!=null&&(Se(e,o),this.variableNames.push("scale"),l="getScaleAtOutCoords()"),this.outputShape=e,this.userCode=` + */class $J{constructor(e,n,s,r,o,i){this.outputShape=[],this.variableNames=["x","mean","variance"],Se(e,n),Se(e,s);let a="0.0";r!=null&&(Se(e,r),this.variableNames.push("offset"),a="getOffsetAtOutCoords()");let l="1.0";o!=null&&(Se(e,o),this.variableNames.push("scale"),l="getScaleAtOutCoords()"),this.outputShape=e,this.userCode=` void main() { float x = getXAtOutCoords(); float mean = getMeanAtOutCoords(); @@ -14373,7 +14373,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,fJ=Oe({opSnippet:dJ}),pJ={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */class TJ{constructor(e,n,s,r,o,i){this.packedInputs=!0,this.packedOutput=!0,this.variableNames=["x","mean","variance"],Se(e,n),Se(e,s);let a="vec4(0.0)";r!=null&&(Se(e,r),this.variableNames.push("offset"),a="getOffsetAtOutCoords()");let l="vec4(1.0)";o!=null&&(Se(e,o),this.variableNames.push("scale"),l="getScaleAtOutCoords()"),this.outputShape=e,this.userCode=` + */class NJ{constructor(e,n,s,r,o,i){this.packedInputs=!0,this.packedOutput=!0,this.variableNames=["x","mean","variance"],Se(e,n),Se(e,s);let a="vec4(0.0)";r!=null&&(Se(e,r),this.variableNames.push("offset"),a="getOffsetAtOutCoords()");let l="vec4(1.0)";o!=null&&(Se(e,o),this.variableNames.push("scale"),l="getScaleAtOutCoords()"),this.outputShape=e,this.userCode=` void main() { vec4 offset = ${a}; vec4 scale = ${l}; @@ -14401,7 +14401,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,fJ=Oe({opSnippet:dJ}),pJ={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const EJ=({inputs:t,backend:e,attrs:n})=>{const{x:s,mean:r,variance:o,offset:i,scale:a}=t;I(r.shape.length===o.shape.length,()=>"Batch normalization gradient requires mean and variance to have equal ranks."),I(i==null||r.shape.length===i.shape.length,()=>"Batch normalization gradient requires mean and offset to have equal ranks."),I(a==null||r.shape.length===a.shape.length,()=>"Batch normalization gradient requires mean and scale to have equal ranks.");let{varianceEpsilon:l}=n;l==null&&(l=.001);const c=[s,r,o];let u=null;i!=null&&(u=i.shape,c.push(i));let h=null;a!=null&&(h=a.shape,c.push(a));const d=W().getBool("WEBGL_PACK_NORMALIZATION")?new TJ(s.shape,r.shape,o.shape,u,h,l):new NJ(s.shape,r.shape,o.shape,u,h,l);return e.runWebGLProgram(d,c,c[0].dtype)},RJ={kernelName:Ap,backendName:"webgl",kernelFunc:EJ};/** + */const TJ=({inputs:t,backend:e,attrs:n})=>{const{x:s,mean:r,variance:o,offset:i,scale:a}=t;I(r.shape.length===o.shape.length,()=>"Batch normalization gradient requires mean and variance to have equal ranks."),I(i==null||r.shape.length===i.shape.length,()=>"Batch normalization gradient requires mean and offset to have equal ranks."),I(a==null||r.shape.length===a.shape.length,()=>"Batch normalization gradient requires mean and scale to have equal ranks.");let{varianceEpsilon:l}=n;l==null&&(l=.001);const c=[s,r,o];let u=null;i!=null&&(u=i.shape,c.push(i));let h=null;a!=null&&(h=a.shape,c.push(a));const d=W().getBool("WEBGL_PACK_NORMALIZATION")?new NJ(s.shape,r.shape,o.shape,u,h,l):new $J(s.shape,r.shape,o.shape,u,h,l);return e.runWebGLProgram(d,c,c[0].dtype)},EJ={kernelName:Ap,backendName:"webgl",kernelFunc:TJ};/** * @license * Copyright 2017 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -14416,7 +14416,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,fJ=Oe({opSnippet:dJ}),pJ={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */class AJ{constructor(e){this.variableNames=["source"],this.outputShape=e,this.rank=e.length;const n=Ze(this.rank);this.customUniforms=[{name:"start",arrayIndex:this.rank,type:"int"}];const s=DJ(this.rank);let r;const o=e.map((i,a)=>`sourceLoc.${T1[a]} = start[${a}] + coords.${T1[a]};`);r=` + */class RJ{constructor(e){this.variableNames=["source"],this.outputShape=e,this.rank=e.length;const n=Ze(this.rank);this.customUniforms=[{name:"start",arrayIndex:this.rank,type:"int"}];const s=AJ(this.rank);let r;const o=e.map((i,a)=>`sourceLoc.${T1[a]} = start[${a}] + coords.${T1[a]};`);r=` ${n} sourceLoc; ${n} coords = getOutputCoords(); ${o.join(` @@ -14426,7 +14426,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,fJ=Oe({opSnippet:dJ}),pJ={kernelNam ${r} setOutput(getSource(${s})); } - `}}const T1=["x","y","z","w","u","v"];function DJ(t){if(t===1)return"sourceLoc";if(t<=6)return T1.slice(0,t).map(e=>"sourceLoc."+e).join(",");throw Error(`Slicing for rank ${t} is not yet supported`)}/** + `}}const T1=["x","y","z","w","u","v"];function AJ(t){if(t===1)return"sourceLoc";if(t<=6)return T1.slice(0,t).map(e=>"sourceLoc."+e).join(",");throw Error(`Slicing for rank ${t} is not yet supported`)}/** * @license * Copyright 2019 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -14441,7 +14441,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,fJ=Oe({opSnippet:dJ}),pJ={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */class _J{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 n=Ze(this.rank),s=vn("coords",this.rank),r=vn("sourceLoc",this.rank),o=this.rank===1?"sourceLoc":`vec2(${r.slice(-2).join()})`,i=`getChannel(getSource(${r.join()}), ${o})`,a=` + */class DJ{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 n=Ze(this.rank),s=vn("coords",this.rank),r=vn("sourceLoc",this.rank),o=this.rank===1?"sourceLoc":`vec2(${r.slice(-2).join()})`,i=`getChannel(getSource(${r.join()}), ${o})`,a=` result.x = ${i}; if (++${s[this.rank-1]} < ${e[this.rank-1]}) { ++${r[this.rank-1]}; @@ -14485,7 +14485,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,fJ=Oe({opSnippet:dJ}),pJ={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function FJ(t,e,n,s){const r=s.texData.get(t.dataId),o=s.makeTensorInfo(n,t.dtype),i=s.texData.get(o.dataId);Object.assign(i,r),i.refCount=1,i.shape=n,i.dtype=t.dtype;let a=Cw(e,pe(t.shape));r.slice&&(a+=r.slice.flatOffset),i.slice={flatOffset:a,origDataId:r.slice&&r.slice.origDataId||t.dataId};const l=s.dataRefCount.get(i.slice.origDataId)||1;return s.dataRefCount.set(i.slice.origDataId,l+1),o}function Fl(t){const{inputs:e,backend:n,attrs:s}=t,{x:r}=e,{begin:o,size:i}=s,[a,l]=bm(r,o,i);if(ww(r,a,l),j(l)===0)return n.makeTensorInfo(l,r.dtype,[]);if(n.shouldExecuteOnCPU([r])||r.dtype==="string"){const h=n.texData.get(r.dataId),d=$Q(h.values,a,l,r.shape,r.dtype);return n.makeTensorInfo(l,r.dtype,d)}const{isPacked:c}=n.texData.get(r.dataId),u=bw(r.shape,a,l);if(c||!u){const h=W().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new _J(l):new AJ(l),d=[a];return n.runWebGLProgram(h,[r],r.dtype,d)}return n.uploadToGPU(r.dataId),FJ(r,a,l,n)}const zJ={kernelName:im,backendName:"webgl",kernelFunc:Fl};/** + */function _J(t,e,n,s){const r=s.texData.get(t.dataId),o=s.makeTensorInfo(n,t.dtype),i=s.texData.get(o.dataId);Object.assign(i,r),i.refCount=1,i.shape=n,i.dtype=t.dtype;let a=Cw(e,pe(t.shape));r.slice&&(a+=r.slice.flatOffset),i.slice={flatOffset:a,origDataId:r.slice&&r.slice.origDataId||t.dataId};const l=s.dataRefCount.get(i.slice.origDataId)||1;return s.dataRefCount.set(i.slice.origDataId,l+1),o}function Fl(t){const{inputs:e,backend:n,attrs:s}=t,{x:r}=e,{begin:o,size:i}=s,[a,l]=bm(r,o,i);if(ww(r,a,l),j(l)===0)return n.makeTensorInfo(l,r.dtype,[]);if(n.shouldExecuteOnCPU([r])||r.dtype==="string"){const h=n.texData.get(r.dataId),d=IQ(h.values,a,l,r.shape,r.dtype);return n.makeTensorInfo(l,r.dtype,d)}const{isPacked:c}=n.texData.get(r.dataId),u=bw(r.shape,a,l);if(c||!u){const h=W().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new DJ(l):new RJ(l),d=[a];return n.runWebGLProgram(h,[r],r.dtype,d)}return n.uploadToGPU(r.dataId),_J(r,a,l,n)}const FJ={kernelName:im,backendName:"webgl",kernelFunc:Fl};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -14500,7 +14500,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,fJ=Oe({opSnippet:dJ}),pJ={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const OJ=t=>{const{inputs:e,backend:n,attrs:s}=t,{x:r}=e,{blockShape:o,crops:i}=s;I(r.shape.length<=4,()=>"batchToSpaceND for rank > 4 with a WebGL backend not implemented yet");const a=o.reduce((y,w)=>y*w),l=gh(r.shape,o,a),c=xh(l.length,o.length),u=yh(r.shape,o,a),h=Nw(i,o.length),d=Tw(u,i,o.length),f=[],p=re({inputs:{x:r},backend:n,attrs:{shape:l}}),g=Sn({inputs:{x:p},backend:n,attrs:{perm:c}}),x=re({inputs:{x:g},backend:n,attrs:{shape:u}}),m=Fl({inputs:{x},backend:n,attrs:{begin:h,size:d}});return f.push(p),f.push(g),f.push(x),f.forEach(y=>n.disposeIntermediateTensorInfo(y)),m},MJ={kernelName:vp,backendName:"webgl",kernelFunc:OJ};/** + */const zJ=t=>{const{inputs:e,backend:n,attrs:s}=t,{x:r}=e,{blockShape:o,crops:i}=s;I(r.shape.length<=4,()=>"batchToSpaceND for rank > 4 with a WebGL backend not implemented yet");const a=o.reduce((y,w)=>y*w),l=mh(r.shape,o,a),c=gh(l.length,o.length),u=xh(r.shape,o,a),h=Nw(i,o.length),d=Tw(u,i,o.length),f=[],p=re({inputs:{x:r},backend:n,attrs:{shape:l}}),g=Sn({inputs:{x:p},backend:n,attrs:{perm:c}}),x=re({inputs:{x:g},backend:n,attrs:{shape:u}}),m=Fl({inputs:{x},backend:n,attrs:{begin:h,size:d}});return f.push(p),f.push(g),f.push(x),f.forEach(y=>n.disposeIntermediateTensorInfo(y)),m},OJ={kernelName:vp,backendName:"webgl",kernelFunc:zJ};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -14515,7 +14515,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,fJ=Oe({opSnippet:dJ}),pJ={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function PJ(t){const{inputs:e,backend:n,attrs:s}=t,{x:r,weights:o}=e,{size:i}=s,a=n.readSync(r.dataId),l=n.readSync(o.dataId),c=ZA(a,l,o.dtype,o.shape,i);return n.makeTensorInfo([i],o.dtype,c)}const LJ={kernelName:qx,backendName:"webgl",kernelFunc:PJ};/** + */function MJ(t){const{inputs:e,backend:n,attrs:s}=t,{x:r,weights:o}=e,{size:i}=s,a=n.readSync(r.dataId),l=n.readSync(o.dataId),c=ZA(a,l,o.dtype,o.shape,i);return n.makeTensorInfo([i],o.dtype,c)}const PJ={kernelName:qx,backendName:"webgl",kernelFunc:MJ};/** * @license * Copyright 2023 Google LLC. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -14530,15 +14530,15 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,fJ=Oe({opSnippet:dJ}),pJ={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const BJ=` + */const LJ=` int r = int(a.r) & int(b.r); int g = int(a.g) & int(b.g); int rb = int(a.b) & int(b.b); int ra = int(a.a) & int(b.a); return vec4(r, g, rb, ra); -`,VJ=` +`,BJ=` return float(int(a.r) & int(b.r)); -`;function WJ(t){const{inputs:e,backend:n}=t,{a:s,b:r}=e,o=W().getBool("WEBGL_PACK_BINARY_OPERATIONS"),i=W().getNumber("WEBGL_VERSION");if(n.shouldExecuteOnCPU([s,r])||i===1){const l=n.texData.get(s.dataId).values,c=n.texData.get(r.dataId).values,[u,h]=YY(s.shape,r.shape,l,c,s.dtype),d=n.makeTensorInfo(h,s.dtype),f=n.texData.get(d.dataId);return f.values=u,d}let a;return o?a=new Dl(BJ,s.shape,r.shape,!1):a=new Wi(VJ,s.shape,r.shape),n.runWebGLProgram(a,[s,r],s.dtype)}const UJ={kernelName:Yx,backendName:"webgl",kernelFunc:WJ};/** +`;function VJ(t){const{inputs:e,backend:n}=t,{a:s,b:r}=e,o=W().getBool("WEBGL_PACK_BINARY_OPERATIONS"),i=W().getNumber("WEBGL_VERSION");if(n.shouldExecuteOnCPU([s,r])||i===1){const l=n.texData.get(s.dataId).values,c=n.texData.get(r.dataId).values,[u,h]=qY(s.shape,r.shape,l,c,s.dtype),d=n.makeTensorInfo(h,s.dtype),f=n.texData.get(d.dataId);return f.values=u,d}let a;return o?a=new Dl(LJ,s.shape,r.shape,!1):a=new Wi(BJ,s.shape,r.shape),n.runWebGLProgram(a,[s,r],s.dtype)}const WJ={kernelName:Yx,backendName:"webgl",kernelFunc:VJ};/** * @license * Copyright 2021 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -14553,7 +14553,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,fJ=Oe({opSnippet:dJ}),pJ={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function GJ(t){const{inputs:e,backend:n}=t,{s0:s,s1:r}=e,o=n.readSync(s.dataId),i=n.readSync(r.dataId),a=Se(Array.from(o),Array.from(i));return n.makeTensorInfo([a.length],"int32",Int32Array.from(a))}const HJ={kernelName:JI,backendName:"webgl",kernelFunc:GJ};/** + */function UJ(t){const{inputs:e,backend:n}=t,{s0:s,s1:r}=e,o=n.readSync(s.dataId),i=n.readSync(r.dataId),a=Se(Array.from(o),Array.from(i));return n.makeTensorInfo([a.length],"int32",Int32Array.from(a))}const GJ={kernelName:JI,backendName:"webgl",kernelFunc:UJ};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -14568,7 +14568,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,fJ=Oe({opSnippet:dJ}),pJ={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const jJ="return float(a != b);",dD=rn({opSnippet:jJ,cpuKernelImpl:xQ,dtype:"bool"}),KJ={kernelName:Xp,backendName:"webgl",kernelFunc:dD};/** + */const HJ="return float(a != b);",dD=rn({opSnippet:HJ,cpuKernelImpl:gQ,dtype:"bool"}),jJ={kernelName:Xp,backendName:"webgl",kernelFunc:dD};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -14583,7 +14583,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,fJ=Oe({opSnippet:dJ}),pJ={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function Ah(t){const{inputs:e,backend:n}=t,{input:s}=e,r=n.texData.get(s.dataId);return Yn({inputs:{x:r.complexTensorInfos.real},backend:n})}const XJ={kernelName:by,backendName:"webgl",kernelFunc:Ah};/** + */function Rh(t){const{inputs:e,backend:n}=t,{input:s}=e,r=n.texData.get(s.dataId);return Yn({inputs:{x:r.complexTensorInfos.real},backend:n})}const KJ={kernelName:by,backendName:"webgl",kernelFunc:Rh};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -14598,7 +14598,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,fJ=Oe({opSnippet:dJ}),pJ={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const qJ="return float(int(x));";function YJ(t,e){const n=new pr(t.shape,qJ),s=e.runWebGLProgram(n,[t],"int32");return{dataId:s.dataId,shape:s.shape,dtype:s.dtype}}/** + */const XJ="return float(int(x));";function qJ(t,e){const n=new pr(t.shape,XJ),s=e.runWebGLProgram(n,[t],"int32");return{dataId:s.dataId,shape:s.shape,dtype:s.dtype}}/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -14613,7 +14613,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,fJ=Oe({opSnippet:dJ}),pJ={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function E1(t){const{inputs:e,backend:n,attrs:s}=t,{x:r}=e,{dtype:o}=s;if(o==="complex64"){if(r.dtype==="complex64")return Yn({inputs:{x:r},backend:n});const i=Kt(r.shape),a=E1({inputs:{x:r},backend:n,attrs:{dtype:"float32"}}),l=Qo({inputs:{real:a,imag:i},backend:n});return i.dispose(),n.disposeIntermediateTensorInfo(a),l}if(r.dtype==="complex64"){const i=Ah({inputs:{input:r},backend:n}),a=E1({inputs:{x:i},backend:n,attrs:{dtype:o}});return n.disposeIntermediateTensorInfo(i),a}if(!XI(r.dtype,o)){const i=Yn({inputs:{x:r},backend:n});return{dataId:i.dataId,shape:i.shape,dtype:o}}if(n.shouldExecuteOnCPU([r])){const i=n.texData.get(r.dataId).values,[a,l,c]=QY(i,r.shape,r.dtype,o);return n.makeTensorInfo(a,l,c)}if(o==="int32")return YJ(r,n);if(o==="bool"){const i=n.makeTensorInfo([],"bool",cn("bool",1)),l=dD({inputs:{a:r,b:i},backend:n});return n.disposeIntermediateTensorInfo(i),l}throw new Error(`Error in Cast: failed to cast ${r.dtype} to ${o}`)}const QJ={kernelName:bu,backendName:"webgl",kernelFunc:E1};/** + */function E1(t){const{inputs:e,backend:n,attrs:s}=t,{x:r}=e,{dtype:o}=s;if(o==="complex64"){if(r.dtype==="complex64")return Yn({inputs:{x:r},backend:n});const i=Kt(r.shape),a=E1({inputs:{x:r},backend:n,attrs:{dtype:"float32"}}),l=Qo({inputs:{real:a,imag:i},backend:n});return i.dispose(),n.disposeIntermediateTensorInfo(a),l}if(r.dtype==="complex64"){const i=Rh({inputs:{input:r},backend:n}),a=E1({inputs:{x:i},backend:n,attrs:{dtype:o}});return n.disposeIntermediateTensorInfo(i),a}if(!XI(r.dtype,o)){const i=Yn({inputs:{x:r},backend:n});return{dataId:i.dataId,shape:i.shape,dtype:o}}if(n.shouldExecuteOnCPU([r])){const i=n.texData.get(r.dataId).values,[a,l,c]=YY(i,r.shape,r.dtype,o);return n.makeTensorInfo(a,l,c)}if(o==="int32")return qJ(r,n);if(o==="bool"){const i=n.makeTensorInfo([],"bool",cn("bool",1)),l=dD({inputs:{a:r,b:i},backend:n});return n.disposeIntermediateTensorInfo(i),l}throw new Error(`Error in Cast: failed to cast ${r.dtype} to ${o}`)}const YJ={kernelName:vu,backendName:"webgl",kernelFunc:E1};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -14628,7 +14628,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,fJ=Oe({opSnippet:dJ}),pJ={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const Mk="return ceil(x);",ZJ=Oe({opSnippet:Mk,packedOpSnippet:Mk,cpuKernelImpl:ZY}),JJ={kernelName:Cu,backendName:"webgl",kernelFunc:ZJ};/** + */const Mk="return ceil(x);",QJ=Oe({opSnippet:Mk,packedOpSnippet:Mk,cpuKernelImpl:QY}),ZJ={kernelName:bu,backendName:"webgl",kernelFunc:QJ};/** * @license * Copyright 2017 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -14643,7 +14643,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,fJ=Oe({opSnippet:dJ}),pJ={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */class eee{constructor(e){this.variableNames=["A"],this.customUniforms=[{name:"minVal",type:"float"},{name:"maxVal",type:"float"}],this.outputShape=e,this.userCode=` + */class JJ{constructor(e){this.variableNames=["A"],this.customUniforms=[{name:"minVal",type:"float"},{name:"maxVal",type:"float"}],this.outputShape=e,this.userCode=` void main() { float value = getAAtOutCoords(); @@ -14669,7 +14669,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,fJ=Oe({opSnippet:dJ}),pJ={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */class tee{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=` + */class eee{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=` void main() { vec4 value = getAAtOutCoords(); @@ -14695,7 +14695,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,fJ=Oe({opSnippet:dJ}),pJ={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function nee(t){const{inputs:e,backend:n,attrs:s}=t,{x:r}=e,{clipValueMin:o,clipValueMax:i}=s;let a;W().getBool("WEBGL_PACK_CLIP")?a=new tee(r.shape):a=new eee(r.shape);const l=[[o],[i]];return n.runWebGLProgram(a,[r],r.dtype,l)}const see={kernelName:ku,backendName:"webgl",kernelFunc:nee};/** + */function tee(t){const{inputs:e,backend:n,attrs:s}=t,{x:r}=e,{clipValueMin:o,clipValueMax:i}=s;let a;W().getBool("WEBGL_PACK_CLIP")?a=new eee(r.shape):a=new JJ(r.shape);const l=[[o],[i]];return n.runWebGLProgram(a,[r],r.dtype,l)}const nee={kernelName:Cu,backendName:"webgl",kernelFunc:tee};/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -14710,7 +14710,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,fJ=Oe({opSnippet:dJ}),pJ={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */class ree{constructor(e){this.variableNames=["real","imag"],this.outputShape=e,this.userCode=` + */class see{constructor(e){this.variableNames=["real","imag"],this.outputShape=e,this.userCode=` void main() { float re = abs(getRealAtOutCoords()); float im = abs(getImagAtOutCoords()); @@ -14738,7 +14738,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,fJ=Oe({opSnippet:dJ}),pJ={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function Pk(t,e){return{dataId:e.dataId,dtype:e.dtype,shape:t.shape}}function oee(t){const{inputs:e,backend:n}=t,{x:s}=e,r=n.texData.get(s.dataId),o=new ree(s.shape),i=[Pk(s,r.complexTensorInfos.real),Pk(s,r.complexTensorInfos.imag)];return n.runWebGLProgram(o,i,i[0].dtype)}const iee={kernelName:bp,backendName:"webgl",kernelFunc:oee};/** + */function Pk(t,e){return{dataId:e.dataId,dtype:e.dtype,shape:t.shape}}function ree(t){const{inputs:e,backend:n}=t,{x:s}=e,r=n.texData.get(s.dataId),o=new see(s.shape),i=[Pk(s,r.complexTensorInfos.real),Pk(s,r.complexTensorInfos.imag)];return n.runWebGLProgram(o,i,i[0].dtype)}const oee={kernelName:bp,backendName:"webgl",kernelFunc:ree};/** * @license * Copyright 2017 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -14753,7 +14753,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,fJ=Oe({opSnippet:dJ}),pJ={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */class aee{constructor(e){this.outputShape=[],this.outputShape=wr(e,1),this.variableNames=e.map((i,a)=>`T${a}`);const n=new Array(e.length-1);n[0]=e[0][1];for(let i=1;i`T${a}`);const n=new Array(e.length-1);n[0]=e[0][1];for(let i=1;i`T${x}`);const l=new Array(e.length-1);l[0]=e[0][n];for(let g=1;g`T${x}`);const l=new Array(e.length-1);l[0]=e[0][n];for(let g=1;g= ${l[g-1]}) { return getChannel( - getT${g}(${hd(a,c,x)}), - vec2(${hd(u,c,x)})); + getT${g}(${ud(a,c,x)}), + vec2(${ud(u,c,x)})); }`}const f=l.length,p=l[l.length-1];d+=` return getChannel( - getT${f}(${hd(a,c,p)}), - vec2(${hd(u,c,p)}));`,this.userCode=` + getT${f}(${ud(a,c,p)}), + vec2(${ud(u,c,p)}));`,this.userCode=` float getValue(${a.map(g=>"int "+g)}) { ${d} } @@ -14814,7 +14814,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,fJ=Oe({opSnippet:dJ}),pJ={kernelNam } setOutput(result); } - `}}function hd(t,e,n){const s=t.indexOf(e);return t.map((o,i)=>i===s?`${o} - ${n}`:o).join()}/** + `}}function ud(t,e,n){const s=t.indexOf(e);return t.map((o,i)=>i===s?`${o} - ${n}`:o).join()}/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -14829,7 +14829,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,fJ=Oe({opSnippet:dJ}),pJ={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function Vm(t){const{inputs:e,backend:n}=t,{input:s}=e,r=n.texData.get(s.dataId);return Yn({inputs:{x:r.complexTensorInfos.imag},backend:n})}const cee={kernelName:fy,backendName:"webgl",kernelFunc:Vm};/** + */function Vm(t){const{inputs:e,backend:n}=t,{input:s}=e,r=n.texData.get(s.dataId);return Yn({inputs:{x:r.complexTensorInfos.imag},backend:n})}const lee={kernelName:fy,backendName:"webgl",kernelFunc:Vm};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -14844,7 +14844,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,fJ=Oe({opSnippet:dJ}),pJ={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function cc(t,e,n){const s=t[0].dtype;if(s==="complex64"){const f=t.map(y=>Ah({inputs:{input:y},backend:n})),p=t.map(y=>Vm({inputs:{input:y},backend:n})),g=cc(f,e,n),x=cc(p,e,n),m=Qo({inputs:{real:g,imag:x},backend:n});return f.forEach(y=>n.disposeIntermediateTensorInfo(y)),p.forEach(y=>n.disposeIntermediateTensorInfo(y)),n.disposeIntermediateTensorInfo(g),n.disposeIntermediateTensorInfo(x),m}let r=n.shouldExecuteOnCPU(t);if(s==="string"&&(r=!0),r){const f=t.map(v=>{const C=[-1,j(v.shape.slice(e))];return re({inputs:{x:v},backend:n,attrs:{shape:C}})}),p=f.map(v=>({vals:n.readSync(v.dataId),shape:v.shape})),g=wr(f.map(v=>v.shape),1),x=f[0].shape[0]===1,m=JY(p,g,s,x),y=wr(t.map(v=>v.shape),e),w=n.makeTensorInfo(y,s,m);return f.forEach(v=>n.disposeIntermediateTensorInfo(v)),w}const o=t.filter(f=>j(f.shape)>0),i=W().getBool("WEBGL_PACK_ARRAY_OPERATIONS")&&o[0].shape.length>1;if(o.length===1){const f=i?new pr(t[0].shape,io):new po(t[0].shape,io);return n.runWebGLProgram(f,t,s)}const a=W().getNumber("WEBGL_MAX_TEXTURES_IN_SHADER");if(o.length>a){const f=[];for(let g=0;gp.shape),e);return n.runWebGLProgram(f,o,s)}const{tensors2D:l,outShape:c}=uee(o,e,n),u=new aee(l.map(f=>f.shape)),h=n.runWebGLProgram(u,l,s);l.forEach(f=>n.disposeIntermediateTensorInfo(f));const d=re({inputs:{x:h},attrs:{shape:c},backend:n});return n.disposeIntermediateTensorInfo(h),d}function uee(t,e,n){const s=wr(t.map(o=>o.shape),e);return{tensors2D:t.map(o=>re({inputs:{x:o},attrs:{shape:[-1,j(o.shape.slice(e))]},backend:n})),outShape:s}}/** + */function cc(t,e,n){const s=t[0].dtype;if(s==="complex64"){const f=t.map(y=>Rh({inputs:{input:y},backend:n})),p=t.map(y=>Vm({inputs:{input:y},backend:n})),g=cc(f,e,n),x=cc(p,e,n),m=Qo({inputs:{real:g,imag:x},backend:n});return f.forEach(y=>n.disposeIntermediateTensorInfo(y)),p.forEach(y=>n.disposeIntermediateTensorInfo(y)),n.disposeIntermediateTensorInfo(g),n.disposeIntermediateTensorInfo(x),m}let r=n.shouldExecuteOnCPU(t);if(s==="string"&&(r=!0),r){const f=t.map(v=>{const C=[-1,j(v.shape.slice(e))];return re({inputs:{x:v},backend:n,attrs:{shape:C}})}),p=f.map(v=>({vals:n.readSync(v.dataId),shape:v.shape})),g=wr(f.map(v=>v.shape),1),x=f[0].shape[0]===1,m=ZY(p,g,s,x),y=wr(t.map(v=>v.shape),e),w=n.makeTensorInfo(y,s,m);return f.forEach(v=>n.disposeIntermediateTensorInfo(v)),w}const o=t.filter(f=>j(f.shape)>0),i=W().getBool("WEBGL_PACK_ARRAY_OPERATIONS")&&o[0].shape.length>1;if(o.length===1){const f=i?new pr(t[0].shape,io):new po(t[0].shape,io);return n.runWebGLProgram(f,t,s)}const a=W().getNumber("WEBGL_MAX_TEXTURES_IN_SHADER");if(o.length>a){const f=[];for(let g=0;gp.shape),e);return n.runWebGLProgram(f,o,s)}const{tensors2D:l,outShape:c}=cee(o,e,n),u=new iee(l.map(f=>f.shape)),h=n.runWebGLProgram(u,l,s);l.forEach(f=>n.disposeIntermediateTensorInfo(f));const d=re({inputs:{x:h},attrs:{shape:c},backend:n});return n.disposeIntermediateTensorInfo(h),d}function cee(t,e,n){const s=wr(t.map(o=>o.shape),e);return{tensors2D:t.map(o=>re({inputs:{x:o},attrs:{shape:[-1,j(o.shape.slice(e))]},backend:n})),outShape:s}}/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -14859,7 +14859,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,fJ=Oe({opSnippet:dJ}),pJ={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function fD(t){const{inputs:e,backend:n,attrs:s}=t,{axis:r}=s,o=Re(r,e[0].shape)[0],i=e.map(c=>c.shape);Sw(i,o);const a=wr(e.map(c=>c.shape),o);if(j(a)===0)return n.makeTensorInfo(a,e[0].dtype,[]);const l=e.filter(c=>j(c.shape)>0);return l.length===1?Yn({inputs:{x:l[0]},backend:n}):cc(l,o,n)}const hee={kernelName:Cp,backendName:"webgl",kernelFunc:fD};/** + */function fD(t){const{inputs:e,backend:n,attrs:s}=t,{axis:r}=s,o=Re(r,e[0].shape)[0],i=e.map(c=>c.shape);Sw(i,o);const a=wr(e.map(c=>c.shape),o);if(j(a)===0)return n.makeTensorInfo(a,e[0].dtype,[]);const l=e.filter(c=>j(c.shape)>0);return l.length===1?Yn({inputs:{x:l[0]},backend:n}):cc(l,o,n)}const uee={kernelName:Cp,backendName:"webgl",kernelFunc:fD};/** * @license * Copyright 2017 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -15008,7 +15008,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,fJ=Oe({opSnippet:dJ}),pJ={kernelNam ${b} setOutput(result); } - `}}class dee{constructor(e){this.variableNames=["x","W"],this.outputShape=e.outShape;const n=e.padInfo.front,s=e.padInfo.top,r=e.padInfo.left,o=e.strideDepth,i=e.strideHeight,a=e.strideWidth,l=e.dilationDepth,c=e.dilationHeight,u=e.dilationWidth,h=e.filterDepth,d=e.filterHeight,f=e.filterWidth,p=Math.floor(e.inChannels/4)*4,g=e.inChannels%4;this.userCode=` + `}}class hee{constructor(e){this.variableNames=["x","W"],this.outputShape=e.outShape;const n=e.padInfo.front,s=e.padInfo.top,r=e.padInfo.left,o=e.strideDepth,i=e.strideHeight,a=e.strideWidth,l=e.dilationDepth,c=e.dilationHeight,u=e.dilationWidth,h=e.filterDepth,d=e.filterHeight,f=e.filterWidth,p=Math.floor(e.inChannels/4)*4,g=e.inChannels%4;this.userCode=` const ivec3 strides = ivec3(${o}, ${i}, ${a}); const ivec3 pads = ivec3(${n}, ${s}, ${r}); @@ -15322,7 +15322,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,fJ=Oe({opSnippet:dJ}),pJ={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */class fee{constructor(e,n){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=pn(this.outputShape.length);const{dataFormat:s}=n,r=$n(),o=s==="channelsLast",i=o?1:2,a=o?2:3,l=this.enableShapeUniforms?"if(blockIndex < outShape[2] && pos < outShape[1]) {":`if(blockIndex < ${e[2]} && pos < ${e[1]}) {`;let c="";for(let u=0;u<=1;u++)for(let h=0;h<=1;h++)c+=` + */class dee{constructor(e,n){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=pn(this.outputShape.length);const{dataFormat:s}=n,r=$n(),o=s==="channelsLast",i=o?1:2,a=o?2:3,l=this.enableShapeUniforms?"if(blockIndex < outShape[2] && pos < outShape[1]) {":`if(blockIndex < ${e[2]} && pos < ${e[1]}) {`;let c="";for(let u=0;u<=1;u++)for(let h=0;h<=1;h++)c+=` blockIndex = rc.z + ${h}; pos = rc.y + ${u}; @@ -15384,7 +15384,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,fJ=Oe({opSnippet:dJ}),pJ={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function Vf(t,e){const n=t.length;return n>=3?e?[...t.slice(0,-3),t[n-3]*t[n-2],t[n-1]]:[...t.slice(0,-3),t[n-3],t[n-2]*t[n-1]]:!e&&n===1&&t[0]>1?[t[0],1]:null}function gD({x:t,filter:e,convInfo:n,backend:s,bias:r=null,preluActivationWeights:o=null,leakyreluAlpha:i=0,activation:a=null}){const l=t.shape,c=s.texData.get(t.dataId),u=n.inChannels,h=l[0]*l[1]*l[2],d=n.outChannels,f=n.dataFormat==="channelsLast",p=!1,g=!1;let x;const m=[];if(o!=null){const v=Vf(o.shape,f);v!=null&&(o=re({inputs:{x:o},backend:s,attrs:{shape:v}}),m.push(o))}if(r!=null){const v=Vf(r.shape,f);v!=null&&(r=re({inputs:{x:r},backend:s,attrs:{shape:v}}),m.push(r))}if(!((h===1||d===1)&&u>lD)&&c.isPacked&&f&&c.texture!=null&&l[2]%2!==0&&Ue(c.shape.slice(-3),l.slice(-3))){const v=l[0]*l[1]*(l[2]+1),b={dataId:t.dataId,shape:[1,v,n.inChannels],dtype:t.dtype},C=c.shape;c.shape=c.shape.slice(),c.shape[c.shape.length-2]++,I(Lf(c.shape,b.shape),()=>`packed reshape ${c.shape} to ${b.shape} isn't free`);const k=re({inputs:{x:e},backend:s,attrs:{shape:[1,n.inChannels,n.outChannels]}});m.push(k);const S=Bf({a:b,b:k,backend:s,transposeA:p,transposeB:g,bias:r,activation:a,preluActivationWeights:o,leakyreluAlpha:i}),$=s.texData.get(S.dataId);I($.isPacked,()=>"batchMatMul result is expected to be packed"),c.shape=C,$.shape=n.outShape,x=Yn({inputs:{x:S},backend:s}),x.shape=n.outShape,m.push(S)}else{const v=n.outHeight*n.outWidth,b=re({inputs:{x:t},backend:s,attrs:{shape:f?[n.batchSize,v,n.inChannels]:[n.batchSize,n.inChannels,v]}}),C=re({inputs:{x:e},backend:s,attrs:{shape:[1,n.inChannels,n.outChannels]}}),k=Bf({a:f?b:C,b:f?C:b,transposeA:!f,transposeB:g,backend:s,bias:r,activation:a,preluActivationWeights:o,leakyreluAlpha:i});x=re({inputs:{x:k},backend:s,attrs:{shape:n.outShape}}),m.push(b),m.push(C),m.push(k)}for(const v of m)s.disposeIntermediateTensorInfo(v);return x}function xD({x:t,filter:e,convInfo:n,backend:s,bias:r=null,preluActivationWeights:o=null,leakyreluAlpha:i=0,activation:a=null}){const{filterWidth:l,filterHeight:c,inChannels:u,outWidth:h,outHeight:d,dataFormat:f}=n,p=f==="channelsLast",g=l*c*u,x=d*h,m=[n.batchSize,g,x],y=!0,w=!1,v=[];if(o!=null){const R=Vf(o.shape,p);R!=null&&(o=re({inputs:{x:o},backend:s,attrs:{shape:R}}),v.push(o))}if(r!=null){const R=Vf(r.shape,p);R!=null&&(r=re({inputs:{x:r},backend:s,attrs:{shape:R}}),v.push(r))}const b=re({inputs:{x:e},backend:s,attrs:{shape:[1,g,j(e.shape)/g]}});v.push(b);const C=new fee(m,n),k=[t.shape,[n.padInfo.top,n.padInfo.left],[n.strideHeight,n.strideWidth],[n.dilationHeight,n.dilationWidth],[n.inChannels],[n.filterWidth*n.inChannels],[n.outWidth]],S=s.runWebGLProgram(C,[t],"float32",k),$=re({inputs:{x:S},backend:s,attrs:{shape:m}});v.push(S),v.push($);const N=r!=null,A=o!=null,M=a==="leakyrelu",L=a?tu(a,!0):null,V=new aD(p?$.shape:b.shape,p?b.shape:$.shape,p?[n.batchSize,x,n.outChannels]:[n.batchSize,n.outChannels,x],y,w,N,L,A,M),B=p?[$,b]:[b,$];if(r&&B.push(r),A&&B.push(o),M){const R=s.makeTensorInfo([],"float32",Wo(i,"float32"));B.push(R),v.push(R)}const U=s.runWebGLProgram(V,B,"float32"),K=re({inputs:{x:U},backend:s,attrs:{shape:n.outShape}});v.push(U);for(const R of v)s.disposeIntermediateTensorInfo(R);return K}/** + */function Bf(t,e){const n=t.length;return n>=3?e?[...t.slice(0,-3),t[n-3]*t[n-2],t[n-1]]:[...t.slice(0,-3),t[n-3],t[n-2]*t[n-1]]:!e&&n===1&&t[0]>1?[t[0],1]:null}function gD({x:t,filter:e,convInfo:n,backend:s,bias:r=null,preluActivationWeights:o=null,leakyreluAlpha:i=0,activation:a=null}){const l=t.shape,c=s.texData.get(t.dataId),u=n.inChannels,h=l[0]*l[1]*l[2],d=n.outChannels,f=n.dataFormat==="channelsLast",p=!1,g=!1;let x;const m=[];if(o!=null){const v=Bf(o.shape,f);v!=null&&(o=re({inputs:{x:o},backend:s,attrs:{shape:v}}),m.push(o))}if(r!=null){const v=Bf(r.shape,f);v!=null&&(r=re({inputs:{x:r},backend:s,attrs:{shape:v}}),m.push(r))}if(!((h===1||d===1)&&u>lD)&&c.isPacked&&f&&c.texture!=null&&l[2]%2!==0&&Ue(c.shape.slice(-3),l.slice(-3))){const v=l[0]*l[1]*(l[2]+1),b={dataId:t.dataId,shape:[1,v,n.inChannels],dtype:t.dtype},C=c.shape;c.shape=c.shape.slice(),c.shape[c.shape.length-2]++,I(Pf(c.shape,b.shape),()=>`packed reshape ${c.shape} to ${b.shape} isn't free`);const k=re({inputs:{x:e},backend:s,attrs:{shape:[1,n.inChannels,n.outChannels]}});m.push(k);const S=Lf({a:b,b:k,backend:s,transposeA:p,transposeB:g,bias:r,activation:a,preluActivationWeights:o,leakyreluAlpha:i}),$=s.texData.get(S.dataId);I($.isPacked,()=>"batchMatMul result is expected to be packed"),c.shape=C,$.shape=n.outShape,x=Yn({inputs:{x:S},backend:s}),x.shape=n.outShape,m.push(S)}else{const v=n.outHeight*n.outWidth,b=re({inputs:{x:t},backend:s,attrs:{shape:f?[n.batchSize,v,n.inChannels]:[n.batchSize,n.inChannels,v]}}),C=re({inputs:{x:e},backend:s,attrs:{shape:[1,n.inChannels,n.outChannels]}}),k=Lf({a:f?b:C,b:f?C:b,transposeA:!f,transposeB:g,backend:s,bias:r,activation:a,preluActivationWeights:o,leakyreluAlpha:i});x=re({inputs:{x:k},backend:s,attrs:{shape:n.outShape}}),m.push(b),m.push(C),m.push(k)}for(const v of m)s.disposeIntermediateTensorInfo(v);return x}function xD({x:t,filter:e,convInfo:n,backend:s,bias:r=null,preluActivationWeights:o=null,leakyreluAlpha:i=0,activation:a=null}){const{filterWidth:l,filterHeight:c,inChannels:u,outWidth:h,outHeight:d,dataFormat:f}=n,p=f==="channelsLast",g=l*c*u,x=d*h,m=[n.batchSize,g,x],y=!0,w=!1,v=[];if(o!=null){const R=Bf(o.shape,p);R!=null&&(o=re({inputs:{x:o},backend:s,attrs:{shape:R}}),v.push(o))}if(r!=null){const R=Bf(r.shape,p);R!=null&&(r=re({inputs:{x:r},backend:s,attrs:{shape:R}}),v.push(r))}const b=re({inputs:{x:e},backend:s,attrs:{shape:[1,g,j(e.shape)/g]}});v.push(b);const C=new dee(m,n),k=[t.shape,[n.padInfo.top,n.padInfo.left],[n.strideHeight,n.strideWidth],[n.dilationHeight,n.dilationWidth],[n.inChannels],[n.filterWidth*n.inChannels],[n.outWidth]],S=s.runWebGLProgram(C,[t],"float32",k),$=re({inputs:{x:S},backend:s,attrs:{shape:m}});v.push(S),v.push($);const N=r!=null,A=o!=null,M=a==="leakyrelu",L=a?tu(a,!0):null,V=new aD(p?$.shape:b.shape,p?b.shape:$.shape,p?[n.batchSize,x,n.outChannels]:[n.batchSize,n.outChannels,x],y,w,N,L,A,M),B=p?[$,b]:[b,$];if(r&&B.push(r),A&&B.push(o),M){const R=s.makeTensorInfo([],"float32",Wo(i,"float32"));B.push(R),v.push(R)}const U=s.runWebGLProgram(V,B,"float32"),K=re({inputs:{x:U},backend:s,attrs:{shape:n.outShape}});v.push(U);for(const R of v)s.disposeIntermediateTensorInfo(R);return K}/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -15399,7 +15399,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,fJ=Oe({opSnippet:dJ}),pJ={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function pee(t){const{inputs:e,backend:n,attrs:s}=t,{x:r,filter:o}=e,{strides:i,pad:a,dataFormat:l,dilations:c,dimRoundingMode:u}=s,h=Qr(l),d=nn(r.shape,o.shape,i,c,a,u,!1,h);let f;if(d.filterHeight===1&&d.filterWidth===1&&d.dilationHeight===1&&d.dilationWidth===1&&d.strideHeight===1&&d.strideWidth===1&&(d.padInfo.type==="SAME"||d.padInfo.type==="VALID"))f=gD({x:r,filter:o,convInfo:d,backend:n});else if(d.strideWidth<=2&&h==="channelsLast"&&W().getBool("WEBGL_EXP_CONV")){const g=new mD(d),x=[[d.padInfo.top,d.padInfo.left],[d.strideHeight,d.strideWidth],[d.dilationHeight,d.dilationWidth],[d.inHeight,d.inWidth]];f=n.runWebGLProgram(g,[r,o],"float32",x)}else if(W().getBool("WEBGL_CONV_IM2COL"))f=xD({x:r,filter:o,convInfo:d,backend:n});else{const g=new pD(d);f=n.runWebGLProgram(g,[r,o],"float32")}const p=re({inputs:{x:f},backend:n,attrs:{shape:d.outShape}});return n.disposeIntermediateTensorInfo(f),p}const mee={kernelName:kp,backendName:"webgl",kernelFunc:pee};/** + */function fee(t){const{inputs:e,backend:n,attrs:s}=t,{x:r,filter:o}=e,{strides:i,pad:a,dataFormat:l,dilations:c,dimRoundingMode:u}=s,h=Qr(l),d=nn(r.shape,o.shape,i,c,a,u,!1,h);let f;if(d.filterHeight===1&&d.filterWidth===1&&d.dilationHeight===1&&d.dilationWidth===1&&d.strideHeight===1&&d.strideWidth===1&&(d.padInfo.type==="SAME"||d.padInfo.type==="VALID"))f=gD({x:r,filter:o,convInfo:d,backend:n});else if(d.strideWidth<=2&&h==="channelsLast"&&W().getBool("WEBGL_EXP_CONV")){const g=new mD(d),x=[[d.padInfo.top,d.padInfo.left],[d.strideHeight,d.strideWidth],[d.dilationHeight,d.dilationWidth],[d.inHeight,d.inWidth]];f=n.runWebGLProgram(g,[r,o],"float32",x)}else if(W().getBool("WEBGL_CONV_IM2COL"))f=xD({x:r,filter:o,convInfo:d,backend:n});else{const g=new pD(d);f=n.runWebGLProgram(g,[r,o],"float32")}const p=re({inputs:{x:f},backend:n,attrs:{shape:d.outShape}});return n.disposeIntermediateTensorInfo(f),p}const pee={kernelName:kp,backendName:"webgl",kernelFunc:fee};/** * @license * Copyright 2017 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -15414,7 +15414,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,fJ=Oe({opSnippet:dJ}),pJ={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */class gee{constructor(e){this.variableNames=["x","dy"],this.outputShape=e.filterShape;const n=e.strideHeight,s=e.strideWidth,r=e.padInfo.top,o=e.padInfo.left,i=e.dataFormat==="channelsLast";this.userCode=` + */class mee{constructor(e){this.variableNames=["x","dy"],this.outputShape=e.filterShape;const n=e.strideHeight,s=e.strideWidth,r=e.padInfo.top,o=e.padInfo.left,i=e.dataFormat==="channelsLast";this.userCode=` void main() { ivec4 coords = getOutputCoords(); int wR = coords.x; @@ -15451,7 +15451,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,fJ=Oe({opSnippet:dJ}),pJ={kernelNam } setOutput(dotProd); } - `}}class xee{constructor(e){this.variableNames=["dy","W"],this.outputShape=e.inShape;const n=e.filterHeight,s=e.filterWidth,r=e.strideHeight,o=e.strideWidth,i=e.dataFormat==="channelsLast",a=n-1-e.padInfo.top,l=s-1-e.padInfo.left,c=i?1:2,u=i?2:3,h=i?3:1;this.userCode=` + `}}class gee{constructor(e){this.variableNames=["dy","W"],this.outputShape=e.inShape;const n=e.filterHeight,s=e.filterWidth,r=e.strideHeight,o=e.strideWidth,i=e.dataFormat==="channelsLast",a=n-1-e.padInfo.top,l=s-1-e.padInfo.left,c=i?1:2,u=i?2:3,h=i?3:1;this.userCode=` const ivec2 pads = ivec2(${a}, ${l}); void main() { @@ -15504,7 +15504,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,fJ=Oe({opSnippet:dJ}),pJ={kernelNam } setOutput(dotProd); } - `}}class yee{constructor(e){this.variableNames=["x","dy"],this.outputShape=e.filterShape;const n=e.strideDepth,s=e.strideHeight,r=e.strideWidth,o=e.padInfo.front,i=e.padInfo.top,a=e.padInfo.left;this.userCode=` + `}}class xee{constructor(e){this.variableNames=["x","dy"],this.outputShape=e.filterShape;const n=e.strideDepth,s=e.strideHeight,r=e.strideWidth,o=e.padInfo.front,i=e.padInfo.top,a=e.padInfo.left;this.userCode=` void main() { ivec5 coords = getOutputCoords(); int wF = coords.x; @@ -15546,7 +15546,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,fJ=Oe({opSnippet:dJ}),pJ={kernelNam } setOutput(dotProd); } - `}}class wee{constructor(e){this.variableNames=["dy","W"],this.outputShape=e.inShape;const n=e.filterDepth,s=e.filterHeight,r=e.filterWidth,o=e.strideDepth,i=e.strideHeight,a=e.strideWidth,l=n-1-e.padInfo.front,c=s-1-e.padInfo.top,u=r-1-e.padInfo.left;this.userCode=` + `}}class yee{constructor(e){this.variableNames=["dy","W"],this.outputShape=e.inShape;const n=e.filterDepth,s=e.filterHeight,r=e.filterWidth,o=e.strideDepth,i=e.strideHeight,a=e.strideWidth,l=n-1-e.padInfo.front,c=s-1-e.padInfo.top,u=r-1-e.padInfo.left;this.userCode=` const ivec3 pads = ivec3(${l}, ${c}, ${u}); void main() { @@ -15618,7 +15618,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,fJ=Oe({opSnippet:dJ}),pJ={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function vee(t){const{inputs:e,backend:n,attrs:s}=t,{x:r,dy:o}=e,{strides:i,pad:a,dataFormat:l,dimRoundingMode:c,filterShape:u}=s,h=Qr(l),d=nn(r.shape,u,i,1,a,c,!1,h),f=new gee(d);return n.runWebGLProgram(f,[r,o],"float32")}const bee={kernelName:Zx,backendName:"webgl",kernelFunc:vee};/** + */function wee(t){const{inputs:e,backend:n,attrs:s}=t,{x:r,dy:o}=e,{strides:i,pad:a,dataFormat:l,dimRoundingMode:c,filterShape:u}=s,h=Qr(l),d=nn(r.shape,u,i,1,a,c,!1,h),f=new mee(d);return n.runWebGLProgram(f,[r,o],"float32")}const vee={kernelName:Zx,backendName:"webgl",kernelFunc:wee};/** * @license * Copyright 2023 Google LLC. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -15633,7 +15633,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,fJ=Oe({opSnippet:dJ}),pJ={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */class Cee{constructor(e){this.variableNames=["dy","W"],this.packedInputs=!0,this.packedOutput=!0,this.customUniforms=[{name:"strides",type:"vec2"}],this.outputShape=e.inShape,this.enableShapeUniforms=pn(this.outputShape.length);const n=e.filterHeight,s=e.filterWidth,r=n-1-e.padInfo.top,o=s-1-e.padInfo.left;this.userCode=` + */class bee{constructor(e){this.variableNames=["dy","W"],this.packedInputs=!0,this.packedOutput=!0,this.customUniforms=[{name:"strides",type:"vec2"}],this.outputShape=e.inShape,this.enableShapeUniforms=pn(this.outputShape.length);const n=e.filterHeight,s=e.filterWidth,r=n-1-e.padInfo.top,o=s-1-e.padInfo.left;this.userCode=` const ivec2 pads = ivec2(${r}, ${o}); void main() { @@ -15722,7 +15722,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,fJ=Oe({opSnippet:dJ}),pJ={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function kee(t){const{inputs:e,backend:n,attrs:s}=t,{dy:r,filter:o}=e,{inputShape:i,strides:a,pad:l,dataFormat:c,dimRoundingMode:u}=s,h=Qr(c),d=nn(i,o.shape,a,1,l,u,!1,h);if(W().getBool("WEBGL_PACK_CONV2DTRANSPOSE")&&h==="channelsLast"){const f=[[d.strideHeight,d.strideWidth]],p=new Cee(d);return n.runWebGLProgram(p,[r,o],"float32",f)}else{const f=new xee(d);return n.runWebGLProgram(f,[r,o],"float32")}}const See={kernelName:Sp,backendName:"webgl",kernelFunc:kee};/** + */function Cee(t){const{inputs:e,backend:n,attrs:s}=t,{dy:r,filter:o}=e,{inputShape:i,strides:a,pad:l,dataFormat:c,dimRoundingMode:u}=s,h=Qr(c),d=nn(i,o.shape,a,1,l,u,!1,h);if(W().getBool("WEBGL_PACK_CONV2DTRANSPOSE")&&h==="channelsLast"){const f=[[d.strideHeight,d.strideWidth]],p=new bee(d);return n.runWebGLProgram(p,[r,o],"float32",f)}else{const f=new gee(d);return n.runWebGLProgram(f,[r,o],"float32")}}const kee={kernelName:Sp,backendName:"webgl",kernelFunc:Cee};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -15737,7 +15737,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,fJ=Oe({opSnippet:dJ}),pJ={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function Iee(t){const{inputs:e,backend:n,attrs:s}=t,{x:r,filter:o}=e,{strides:i,pad:a,dilations:l}=s,c=Go(r.shape,o.shape,i,l,a),u=new dee(c);return n.runWebGLProgram(u,[r,o],"float32")}const $ee={kernelName:Ip,backendName:"webgl",kernelFunc:Iee};/** + */function See(t){const{inputs:e,backend:n,attrs:s}=t,{x:r,filter:o}=e,{strides:i,pad:a,dilations:l}=s,c=Go(r.shape,o.shape,i,l,a),u=new hee(c);return n.runWebGLProgram(u,[r,o],"float32")}const Iee={kernelName:Ip,backendName:"webgl",kernelFunc:See};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -15752,7 +15752,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,fJ=Oe({opSnippet:dJ}),pJ={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function Nee(t){const{inputs:e,backend:n,attrs:s}=t,{x:r,dy:o}=e,{strides:i,pad:a,filterShape:l}=s,c=Go(r.shape,l,i,1,a),u=new yee(c);return n.runWebGLProgram(u,[r,o],"float32")}const Tee={kernelName:Jx,backendName:"webgl",kernelFunc:Nee};/** + */function $ee(t){const{inputs:e,backend:n,attrs:s}=t,{x:r,dy:o}=e,{strides:i,pad:a,filterShape:l}=s,c=Go(r.shape,l,i,1,a),u=new xee(c);return n.runWebGLProgram(u,[r,o],"float32")}const Nee={kernelName:Jx,backendName:"webgl",kernelFunc:$ee};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -15767,7 +15767,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,fJ=Oe({opSnippet:dJ}),pJ={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function Eee(t){const{inputs:e,backend:n,attrs:s}=t,{dy:r,filter:o}=e,{pad:i,strides:a,inputShape:l}=s,c=Go(l,o.shape,a,1,i),u=new wee(c);return n.runWebGLProgram(u,[r,o],"float32")}const Ree={kernelName:ey,backendName:"webgl",kernelFunc:Eee};/** + */function Tee(t){const{inputs:e,backend:n,attrs:s}=t,{dy:r,filter:o}=e,{pad:i,strides:a,inputShape:l}=s,c=Go(l,o.shape,a,1,i),u=new yee(c);return n.runWebGLProgram(u,[r,o],"float32")}const Eee={kernelName:ey,backendName:"webgl",kernelFunc:Tee};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -15782,14 +15782,14 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,fJ=Oe({opSnippet:dJ}),pJ={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const Aee=_l+` + */const Ree=_l+` return cos(x); -`,Dee=` +`,Aee=` vec4 result = cos(x); bvec4 isNaN = isnan(x); ${na} return result; -`,_ee=Oe({opSnippet:Aee,packedOpSnippet:Dee}),Fee={kernelName:Su,backendName:"webgl",kernelFunc:_ee};/** +`,Dee=Oe({opSnippet:Ree,packedOpSnippet:Aee}),_ee={kernelName:ku,backendName:"webgl",kernelFunc:Dee};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -15804,10 +15804,10 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,fJ=Oe({opSnippet:dJ}),pJ={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const zee=` + */const Fee=` float e2x = exp(-x); return (e2x + 1.0 / e2x) / 2.0; -`,Oee=Oe({opSnippet:zee}),Mee={kernelName:Iu,backendName:"webgl",kernelFunc:Oee};/** +`,zee=Oe({opSnippet:Fee}),Oee={kernelName:Su,backendName:"webgl",kernelFunc:zee};/** * @license * Copyright 2017 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -15822,7 +15822,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,fJ=Oe({opSnippet:dJ}),pJ={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */class Pee{constructor(e,n,s,r,o){this.variableNames=["Image","Boxes","BoxInd"],this.outputShape=[];const[i,a,l,c]=e,[u]=n,[h,d]=s;this.outputShape=[u,h,d,c];const f=r==="bilinear"?1:0,[p,g]=[`${a-1}.0`,`${l-1}.0`],[x,m,y]=h>1?[`${(a-1)/(h-1)}`,"(y2-y1) * height_ratio",`y1*${p} + float(y)*(height_scale)`]:["0.0","0.0",`0.5 * (y1+y2) * ${p}`],[w,v,b]=d>1?[`${(l-1)/(d-1)}`,"(x2-x1) * width_ratio",`x1*${g} + float(x)*(width_scale)`]:["0.0","0.0",`0.5 * (x1+x2) * ${g}`];this.userCode=` + */class Mee{constructor(e,n,s,r,o){this.variableNames=["Image","Boxes","BoxInd"],this.outputShape=[];const[i,a,l,c]=e,[u]=n,[h,d]=s;this.outputShape=[u,h,d,c];const f=r==="bilinear"?1:0,[p,g]=[`${a-1}.0`,`${l-1}.0`],[x,m,y]=h>1?[`${(a-1)/(h-1)}`,"(y2-y1) * height_ratio",`y1*${p} + float(y)*(height_scale)`]:["0.0","0.0",`0.5 * (y1+y2) * ${p}`],[w,v,b]=d>1?[`${(l-1)/(d-1)}`,"(x2-x1) * width_ratio",`x1*${g} + float(x)*(width_scale)`]:["0.0","0.0",`0.5 * (x1+x2) * ${g}`];this.userCode=` const float height_ratio = float(${x}); const float width_ratio = float(${w}); void main() { @@ -15898,7 +15898,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,fJ=Oe({opSnippet:dJ}),pJ={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const Lee=t=>{const{inputs:e,backend:n,attrs:s}=t,{image:r,boxes:o,boxInd:i}=e,{cropSize:a,method:l,extrapolationValue:c}=s,u=new Pee(r.shape,o.shape,a,l,c);return n.runWebGLProgram(u,[r,o,i],"float32")},Bee={kernelName:ny,backendName:"webgl",kernelFunc:Lee};var su;(function(t){t.Prod="*",t.Sum="+"})(su||(su={}));class Lk{constructor(e,n,s,r){this.op=e,this.outputShape=n,this.variableNames=["x"],this.customUniforms=[{name:"index",type:"float"}];const o=this.outputShape.length,i=this.op===su.Prod?"1.0":"0.0",a=s?i:`getX(${Bk(o,"coords",this.op)})`,l=this.outputShape[this.outputShape.length-1];let c="",u="";s?(c=r?`end != ${l-1}`:"end != 0",u=r?"end + 1":"end - 1"):(c=r?`end + pow2 < ${l}`:"end >= pow2",u=r?"end + pow2":"end - pow2"),this.userCode=` + */const Pee=t=>{const{inputs:e,backend:n,attrs:s}=t,{image:r,boxes:o,boxInd:i}=e,{cropSize:a,method:l,extrapolationValue:c}=s,u=new Mee(r.shape,o.shape,a,l,c);return n.runWebGLProgram(u,[r,o,i],"float32")},Lee={kernelName:ny,backendName:"webgl",kernelFunc:Pee};var su;(function(t){t.Prod="*",t.Sum="+"})(su||(su={}));class Lk{constructor(e,n,s,r){this.op=e,this.outputShape=n,this.variableNames=["x"],this.customUniforms=[{name:"index",type:"float"}];const o=this.outputShape.length,i=this.op===su.Prod?"1.0":"0.0",a=s?i:`getX(${Bk(o,"coords",this.op)})`,l=this.outputShape[this.outputShape.length-1];let c="",u="";s?(c=r?`end != ${l-1}`:"end != 0",u=r?"end + 1":"end - 1"):(c=r?`end + pow2 < ${l}`:"end >= pow2",u=r?"end + pow2":"end - pow2"),this.userCode=` void main() { ${Ze(o)} coords = getOutputCoords(); int end = ${Vk(o,"coords",this.op)}; @@ -15941,7 +15941,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,fJ=Oe({opSnippet:dJ}),pJ={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function Vee(t){const{inputs:e,backend:n,attrs:s}=t,{x:r}=e,{axis:o,exclusive:i,reverse:a}=s;return yD(su.Prod,r,n,o,i,a)}const Wee={kernelName:ty,backendName:"webgl",kernelFunc:Vee};/** + */function Bee(t){const{inputs:e,backend:n,attrs:s}=t,{x:r}=e,{axis:o,exclusive:i,reverse:a}=s;return yD(su.Prod,r,n,o,i,a)}const Vee={kernelName:ty,backendName:"webgl",kernelFunc:Bee};/** * @license * Copyright 2022 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -15956,7 +15956,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,fJ=Oe({opSnippet:dJ}),pJ={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function Uee(t){const{inputs:e,backend:n,attrs:s}=t,{x:r}=e,{axis:o,exclusive:i,reverse:a}=s;return yD(su.Sum,r,n,o,i,a)}const Gee={kernelName:$p,backendName:"webgl",kernelFunc:Uee};/** + */function Wee(t){const{inputs:e,backend:n,attrs:s}=t,{x:r}=e,{axis:o,exclusive:i,reverse:a}=s;return yD(su.Sum,r,n,o,i,a)}const Uee={kernelName:$p,backendName:"webgl",kernelFunc:Wee};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -15971,7 +15971,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,fJ=Oe({opSnippet:dJ}),pJ={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function Hee(t){const{inputs:e,backend:n,attrs:s}=t,{x:r,weights:o}=e,{size:i,binaryOutput:a}=s;if(r.shape.length===1){const l=n.readSync(r.dataId),c=n.readSync(o.dataId),u=ZA(l,c,o.dtype,o.shape,i);return n.makeTensorInfo([i],o.dtype,u)}else if(r.shape.length===2){const l=n.bufferSync(r),c=n.bufferSync(o),u=qY(l,c,i,a);return n.makeTensorInfo(u.shape,o.dtype,u.values)}throw new Error(`Error in denseBincount: input must be at most rank 2, but got rank${r.shape.length}.`)}const jee={kernelName:sy,backendName:"webgl",kernelFunc:Hee};/** + */function Gee(t){const{inputs:e,backend:n,attrs:s}=t,{x:r,weights:o}=e,{size:i,binaryOutput:a}=s;if(r.shape.length===1){const l=n.readSync(r.dataId),c=n.readSync(o.dataId),u=ZA(l,c,o.dtype,o.shape,i);return n.makeTensorInfo([i],o.dtype,u)}else if(r.shape.length===2){const l=n.bufferSync(r),c=n.bufferSync(o),u=XY(l,c,i,a);return n.makeTensorInfo(u.shape,o.dtype,u.values)}throw new Error(`Error in denseBincount: input must be at most rank 2, but got rank${r.shape.length}.`)}const Hee={kernelName:sy,backendName:"webgl",kernelFunc:Gee};/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -15986,7 +15986,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,fJ=Oe({opSnippet:dJ}),pJ={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */class Kee{constructor(e,n,s){this.variableNames=["x"],this.outputShape=[],this.outputShape=e,this.blockSize=n,this.dataFormat=s,this.userCode=` + */class jee{constructor(e,n,s){this.variableNames=["x"],this.outputShape=[],this.outputShape=e,this.blockSize=n,this.dataFormat=s,this.userCode=` void main() { ivec4 coords = getOutputCoords(); int b = coords[0]; @@ -16020,7 +16020,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,fJ=Oe({opSnippet:dJ}),pJ={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function Xee(t){const{inputs:e,backend:n,attrs:s}=t,{x:r}=e,{blockSize:o,dataFormat:i}=s,a=r.shape[0],l=i==="NHWC"?r.shape[1]:r.shape[2],c=i==="NHWC"?r.shape[2]:r.shape[3],u=i==="NHWC"?r.shape[3]:r.shape[1],h=l*o,d=c*o,f=u/(o*o),p=i==="NHWC"?[a,h,d,f]:[a,f,h,d],g=new Kee(p,o,i);return n.runWebGLProgram(g,[r],r.dtype)}const qee={kernelName:ry,backendName:"webgl",kernelFunc:Xee};/** + */function Kee(t){const{inputs:e,backend:n,attrs:s}=t,{x:r}=e,{blockSize:o,dataFormat:i}=s,a=r.shape[0],l=i==="NHWC"?r.shape[1]:r.shape[2],c=i==="NHWC"?r.shape[2]:r.shape[3],u=i==="NHWC"?r.shape[3]:r.shape[1],h=l*o,d=c*o,f=u/(o*o),p=i==="NHWC"?[a,h,d,f]:[a,f,h,d],g=new jee(p,o,i);return n.runWebGLProgram(g,[r],r.dtype)}const Xee={kernelName:ry,backendName:"webgl",kernelFunc:Kee};/** * @license * Copyright 2017 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -16307,7 +16307,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,fJ=Oe({opSnippet:dJ}),pJ={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function Yee(t){const{inputs:e,backend:n,attrs:s}=t,{x:r,filter:o}=e,{strides:i,pad:a,dilations:l,dimRoundingMode:c}=s;let u=l;u==null&&(u=[1,1]),I(dn(i,u),()=>`Error in depthwiseConv2d: Either strides or dilations must be 1. Got strides ${i} and dilations '${u}'`);const h=nn(r.shape,o.shape,i,u,a,c,!0);let d;W().getBool("WEBGL_PACK_DEPTHWISECONV")&&h.strideWidth<=2&&h.outChannels/h.inChannels===1?d=new vD(h):d=new wD(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,[r,o],"float32",f)}const Qee={kernelName:Np,backendName:"webgl",kernelFunc:Yee};/** + */function qee(t){const{inputs:e,backend:n,attrs:s}=t,{x:r,filter:o}=e,{strides:i,pad:a,dilations:l,dimRoundingMode:c}=s;let u=l;u==null&&(u=[1,1]),I(dn(i,u),()=>`Error in depthwiseConv2d: Either strides or dilations must be 1. Got strides ${i} and dilations '${u}'`);const h=nn(r.shape,o.shape,i,u,a,c,!0);let d;W().getBool("WEBGL_PACK_DEPTHWISECONV")&&h.strideWidth<=2&&h.outChannels/h.inChannels===1?d=new vD(h):d=new wD(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,[r,o],"float32",f)}const Yee={kernelName:Np,backendName:"webgl",kernelFunc:qee};/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -16322,7 +16322,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,fJ=Oe({opSnippet:dJ}),pJ={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */class Zee{constructor(e){this.variableNames=["x","dy"],this.outputShape=e.filterShape;const n=e.strideHeight,s=e.strideWidth,r=e.padInfo.top,o=e.padInfo.left,i=e.outChannels/e.inChannels;this.userCode=` + */class Qee{constructor(e){this.variableNames=["x","dy"],this.outputShape=e.filterShape;const n=e.strideHeight,s=e.strideWidth,r=e.padInfo.top,o=e.padInfo.left,i=e.outChannels/e.inChannels;this.userCode=` void main() { ivec4 coords = getOutputCoords(); int wR = coords.x; @@ -16357,7 +16357,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,fJ=Oe({opSnippet:dJ}),pJ={kernelNam } setOutput(dotProd); } - `}}class Jee{constructor(e){this.variableNames=["dy","W"],this.outputShape=e.inShape;const n=e.filterHeight,s=e.filterWidth,r=e.strideHeight,o=e.strideWidth,i=n-1-e.padInfo.top,a=s-1-e.padInfo.left,l=e.outChannels/e.inChannels;this.userCode=` + `}}class Zee{constructor(e){this.variableNames=["dy","W"],this.outputShape=e.inShape;const n=e.filterHeight,s=e.filterWidth,r=e.strideHeight,o=e.strideWidth,i=n-1-e.padInfo.top,a=s-1-e.padInfo.left,l=e.outChannels/e.inChannels;this.userCode=` const ivec2 pads = ivec2(${i}, ${a}); void main() { @@ -16417,7 +16417,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,fJ=Oe({opSnippet:dJ}),pJ={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function ete(t){const{inputs:e,backend:n,attrs:s}=t,{x:r,dy:o}=e,{strides:i,dilations:a,pad:l,dimRoundingMode:c,filterShape:u}=s,h=nn(r.shape,u,i,a,l,c,!0),d=new Zee(h);return n.runWebGLProgram(d,[r,o],"float32")}const tte={kernelName:oy,backendName:"webgl",kernelFunc:ete};/** + */function Jee(t){const{inputs:e,backend:n,attrs:s}=t,{x:r,dy:o}=e,{strides:i,dilations:a,pad:l,dimRoundingMode:c,filterShape:u}=s,h=nn(r.shape,u,i,a,l,c,!0),d=new Qee(h);return n.runWebGLProgram(d,[r,o],"float32")}const ete={kernelName:oy,backendName:"webgl",kernelFunc:Jee};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -16432,7 +16432,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,fJ=Oe({opSnippet:dJ}),pJ={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function nte(t){const{inputs:e,backend:n,attrs:s}=t,{dy:r,filter:o}=e,{strides:i,dilations:a,pad:l,dimRoundingMode:c,inputShape:u}=s,h=nn(u,o.shape,i,a,l,c,!0),d=new Jee(h);return n.runWebGLProgram(d,[r,o],"float32")}const ste={kernelName:iy,backendName:"webgl",kernelFunc:nte};/** + */function tte(t){const{inputs:e,backend:n,attrs:s}=t,{dy:r,filter:o}=e,{strides:i,dilations:a,pad:l,dimRoundingMode:c,inputShape:u}=s,h=nn(u,o.shape,i,a,l,c,!0),d=new Zee(h);return n.runWebGLProgram(d,[r,o],"float32")}const nte={kernelName:iy,backendName:"webgl",kernelFunc:tte};/** * @license * Copyright 2019 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -16447,7 +16447,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,fJ=Oe({opSnippet:dJ}),pJ={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */class rte{constructor(e){this.variableNames=["X"],this.outputShape=[e,e],this.userCode=` + */class ste{constructor(e){this.variableNames=["X"],this.outputShape=[e,e],this.userCode=` void main() { ivec2 coords = getOutputCoords(); float val = coords[0] == coords[1] ? getX(coords[0]) : 0.0; @@ -16468,7 +16468,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,fJ=Oe({opSnippet:dJ}),pJ={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function ote(t){const{inputs:e,backend:n}=t,{x:s}=e,r=[...s.shape,...s.shape],o=j(s.shape),i=re({inputs:{x:s},backend:n,attrs:{shape:[o]}}),a=new rte(o),l=n.runWebGLProgram(a,[i],i.dtype),c=re({inputs:{x:l},backend:n,attrs:{shape:r}});return n.disposeIntermediateTensorInfo(i),n.disposeIntermediateTensorInfo(l),c}const ite={kernelName:e$,backendName:"webgl",kernelFunc:ote};/** + */function rte(t){const{inputs:e,backend:n}=t,{x:s}=e,r=[...s.shape,...s.shape],o=j(s.shape),i=re({inputs:{x:s},backend:n,attrs:{shape:[o]}}),a=new ste(o),l=n.runWebGLProgram(a,[i],i.dtype),c=re({inputs:{x:l},backend:n,attrs:{shape:r}});return n.disposeIntermediateTensorInfo(i),n.disposeIntermediateTensorInfo(l),c}const ote={kernelName:e$,backendName:"webgl",kernelFunc:rte};/** * @license * Copyright 2017 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -16483,7 +16483,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,fJ=Oe({opSnippet:dJ}),pJ={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */class ate{constructor(e){this.variableNames=["x","W"],this.outputShape=e.outShape;const{inHeight:n,inWidth:s,padInfo:r,strideHeight:o,strideWidth:i,filterHeight:a,filterWidth:l,dilationHeight:c,dilationWidth:u}=e,{top:h,left:d}=r;this.userCode=` + */class ite{constructor(e){this.variableNames=["x","W"],this.outputShape=e.outShape;const{inHeight:n,inWidth:s,padInfo:r,strideHeight:o,strideWidth:i,filterHeight:a,filterWidth:l,dilationHeight:c,dilationWidth:u}=e,{top:h,left:d}=r;this.userCode=` const ivec2 strides = ivec2(${o}, ${i}); const ivec2 pads = ivec2(${h}, ${d}); const float neg_infinity = -3.4e38; @@ -16536,7 +16536,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,fJ=Oe({opSnippet:dJ}),pJ={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function lte(t){const{inputs:e,backend:n,attrs:s}=t,{x:r,filter:o}=e,{strides:i,pad:a,dilations:l}=s,c=hh(r.shape,o.shape,i,a,"NHWC",l);let u;const h=new ate(c);u=n.runWebGLProgram(h,[r,o],"float32");const d=re({inputs:{x:u},backend:n,attrs:{shape:c.outShape}});return n.disposeIntermediateTensorInfo(u),d}const cte={kernelName:Tp,backendName:"webgl",kernelFunc:lte};/** + */function ate(t){const{inputs:e,backend:n,attrs:s}=t,{x:r,filter:o}=e,{strides:i,pad:a,dilations:l}=s,c=uh(r.shape,o.shape,i,a,"NHWC",l);let u;const h=new ite(c);u=n.runWebGLProgram(h,[r,o],"float32");const d=re({inputs:{x:u},backend:n,attrs:{shape:c.outShape}});return n.disposeIntermediateTensorInfo(u),d}const lte={kernelName:Tp,backendName:"webgl",kernelFunc:ate};/** * @license * Copyright 2021 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -16551,7 +16551,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,fJ=Oe({opSnippet:dJ}),pJ={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function ute(t){const{inputs:e,backend:n,attrs:s}=t,{equation:r}=s,o=e,{allDims:i,summedDims:a,idDims:l}=Ow(r,o.length);Pw(i.length,l,o);const{path:c,steps:u}=Lw(a,l),h=u.length;let d=null,f=i.length;const p=[];for(let g=0;g=0&&(d=Bm({inputs:{x:d},backend:n,attrs:{axis:c[g]-(i.length-f),keepDims:!1}}),p.push(d)),f--)}for(const g of p)g!==d&&n.disposeIntermediateTensorInfo(g);return d}const hte={kernelName:ay,backendName:"webgl",kernelFunc:ute};/** + */function cte(t){const{inputs:e,backend:n,attrs:s}=t,{equation:r}=s,o=e,{allDims:i,summedDims:a,idDims:l}=Ow(r,o.length);Pw(i.length,l,o);const{path:c,steps:u}=Lw(a,l),h=u.length;let d=null,f=i.length;const p=[];for(let g=0;g=0&&(d=Bm({inputs:{x:d},backend:n,attrs:{axis:c[g]-(i.length-f),keepDims:!1}}),p.push(d)),f--)}for(const g of p)g!==d&&n.disposeIntermediateTensorInfo(g);return d}const ute={kernelName:ay,backendName:"webgl",kernelFunc:cte};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -16566,7 +16566,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,fJ=Oe({opSnippet:dJ}),pJ={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const dte="return (x >= 0.0) ? x : (exp(x) - 1.0);",fte=` + */const hte="return (x >= 0.0) ? x : (exp(x) - 1.0);",dte=` vec4 result; result.r = (x.r >= 0.0) ? x.r : (exp(x.r) - 1.0); @@ -16575,7 +16575,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,fJ=Oe({opSnippet:dJ}),pJ={kernelNam result.a = (x.a >= 0.0) ? x.a : (exp(x.a) - 1.0); return result; -`,pte=Oe({opSnippet:dte,packedOpSnippet:fte}),mte={kernelName:Nu,backendName:"webgl",kernelFunc:pte};/** +`,fte=Oe({opSnippet:hte,packedOpSnippet:dte}),pte={kernelName:$u,backendName:"webgl",kernelFunc:fte};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -16590,10 +16590,10 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,fJ=Oe({opSnippet:dJ}),pJ={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const gte="return (b >= 0.0) ? a : a * (b + 1.0);",xte=` + */const mte="return (b >= 0.0) ? a : a * (b + 1.0);",gte=` vec4 bGTEZero = vec4(greaterThanEqual(b, vec4(0.))); return (bGTEZero * a) + ((vec4(1.0) - bGTEZero) * (a * (b + vec4(1.0)))); -`,yte=t=>{const{inputs:e,backend:n}=t,{dy:s,y:r}=e,o=W().getBool("WEBGL_PACK_BINARY_OPERATIONS")?new Dl(xte,s.shape,r.shape):new Wi(gte,s.shape,r.shape);return n.runWebGLProgram(o,[s,r],s.dtype)},wte={kernelName:ly,backendName:"webgl",kernelFunc:yte};/** +`,xte=t=>{const{inputs:e,backend:n}=t,{dy:s,y:r}=e,o=W().getBool("WEBGL_PACK_BINARY_OPERATIONS")?new Dl(gte,s.shape,r.shape):new Wi(mte,s.shape,r.shape);return n.runWebGLProgram(o,[s,r],s.dtype)},yte={kernelName:ly,backendName:"webgl",kernelFunc:xte};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -16608,9 +16608,9 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,fJ=Oe({opSnippet:dJ}),pJ={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const vte=` + */const wte=` return vec4(equal(a, b)); -`,bte="return float(a == b);",Cte=rn({opSnippet:bte,packedOpSnippet:vte,dtype:"bool",cpuKernelImpl:eQ}),kte={kernelName:Ep,backendName:"webgl",kernelFunc:Cte};/** +`,vte="return float(a == b);",bte=rn({opSnippet:vte,packedOpSnippet:wte,dtype:"bool",cpuKernelImpl:JY}),Cte={kernelName:Ep,backendName:"webgl",kernelFunc:bte};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -16625,7 +16625,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,fJ=Oe({opSnippet:dJ}),pJ={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const Ste=` + */const kte=` // Error function is calculated approximately with elementary function. // See "Handbook of Mathematical Functions with Formulas, // Graphs, and Mathematical Tables", Abramowitz and Stegun. @@ -16640,7 +16640,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,fJ=Oe({opSnippet:dJ}),pJ={kernelNam x = abs(x); float t = 1.0 / (1.0 + p * x); return sign * (1.0 - (((((a5*t + a4)*t) + a3)*t + a2)*t + a1)*t*exp(-x*x)); -`,Ite=Oe({opSnippet:Ste}),$te={kernelName:Tu,backendName:"webgl",kernelFunc:Ite};/** +`,Ste=Oe({opSnippet:kte}),Ite={kernelName:Nu,backendName:"webgl",kernelFunc:Ste};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -16655,9 +16655,9 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,fJ=Oe({opSnippet:dJ}),pJ={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const Nte=_l+` + */const $te=_l+` return exp(x); -`,Tte=` +`,Nte=` vec4 result = exp(x); bvec4 isNaN = isnan(x); result.r = isNaN.r ? x.r : result.r; @@ -16666,7 +16666,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,fJ=Oe({opSnippet:dJ}),pJ={kernelNam result.a = isNaN.a ? x.a : result.a; return result; -`,bD=Oe({opSnippet:Nte,packedOpSnippet:Tte,cpuKernelImpl:tQ,dtype:"float32"}),Ete={kernelName:Eu,backendName:"webgl",kernelFunc:bD};/** +`,bD=Oe({opSnippet:$te,packedOpSnippet:Nte,cpuKernelImpl:eQ,dtype:"float32"}),Tte={kernelName:Tu,backendName:"webgl",kernelFunc:bD};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the License); @@ -16681,7 +16681,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,fJ=Oe({opSnippet:dJ}),pJ={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function R1(t){const{inputs:e,attrs:n,backend:s}=t,{dim:r}=n,{input:o}=e,i=o.shape.length,a=o.shape.slice();let l=r;return r<0&&(I(-(i+1)<=r,()=>`Axis must be in the interval [${-(i+1)}, ${i}]`),l=i+r+1),a.splice(l,0,1),re({inputs:{x:o},backend:s,attrs:{shape:a}})}const Rte={kernelName:Rp,backendName:"webgl",kernelFunc:R1};/** + */function R1(t){const{inputs:e,attrs:n,backend:s}=t,{dim:r}=n,{input:o}=e,i=o.shape.length,a=o.shape.slice();let l=r;return r<0&&(I(-(i+1)<=r,()=>`Axis must be in the interval [${-(i+1)}, ${i}]`),l=i+r+1),a.splice(l,0,1),re({inputs:{x:o},backend:s,attrs:{shape:a}})}const Ete={kernelName:Rp,backendName:"webgl",kernelFunc:R1};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -16696,7 +16696,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,fJ=Oe({opSnippet:dJ}),pJ={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const Wk="return exp(x) - 1.0;",Ate=Oe({opSnippet:Wk,packedOpSnippet:Wk,cpuKernelImpl:nQ}),Dte={kernelName:Ru,backendName:"webgl",kernelFunc:Ate};/** + */const Wk="return exp(x) - 1.0;",Rte=Oe({opSnippet:Wk,packedOpSnippet:Wk,cpuKernelImpl:tQ}),Ate={kernelName:Eu,backendName:"webgl",kernelFunc:Rte};/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -16774,7 +16774,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,fJ=Oe({opSnippet:dJ}),pJ={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function _te(t){const{inputs:e,backend:n}=t,{input:s}=e;return CD(s,!1,n)}const Fte={kernelName:cy,backendName:"webgl",kernelFunc:_te};/** + */function Dte(t){const{inputs:e,backend:n}=t,{input:s}=e;return CD(s,!1,n)}const _te={kernelName:cy,backendName:"webgl",kernelFunc:Dte};/** * @license * Copyright 2019 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -16789,7 +16789,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,fJ=Oe({opSnippet:dJ}),pJ={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */class zte{constructor(e,n){this.outputShape=[],this.customUniforms=[{name:"value",type:"float"}],this.variableNames=["x"],this.outputShape=e,this.userCode=` + */class Fte{constructor(e,n){this.outputShape=[],this.customUniforms=[{name:"value",type:"float"}],this.variableNames=["x"],this.outputShape=e,this.userCode=` void main() { // Input can be obtained from uniform value. setOutput(value); @@ -16809,7 +16809,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,fJ=Oe({opSnippet:dJ}),pJ={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function Dh(t){const{backend:e,attrs:n}=t,{shape:s,value:r}=n;let{dtype:o}=n;if(o=o||wl(r),o==="string"){const i=kt(o,j(s));return i.fill(r),e.makeTensorInfo(s,o,i)}else{const i=new zte(s,r),a=[[r]];return e.runWebGLProgram(i,[],o,a)}}const Ote={kernelName:uy,backendName:"webgl",kernelFunc:Dh};/** + */function Ah(t){const{backend:e,attrs:n}=t,{shape:s,value:r}=n;let{dtype:o}=n;if(o=o||wl(r),o==="string"){const i=kt(o,j(s));return i.fill(r),e.makeTensorInfo(s,o,i)}else{const i=new Fte(s,r),a=[[r]];return e.runWebGLProgram(i,[],o,a)}}const zte={kernelName:uy,backendName:"webgl",kernelFunc:Ah};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -16824,7 +16824,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,fJ=Oe({opSnippet:dJ}),pJ={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */class Mte{constructor(e){this.variableNames=["Image"],this.outputShape=[];const n=e[2];this.outputShape=e,this.userCode=` + */class Ote{constructor(e){this.variableNames=["Image"],this.outputShape=[];const n=e[2];this.outputShape=e,this.userCode=` void main() { ivec4 coords = getOutputCoords(); int x = coords[2]; @@ -16853,7 +16853,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,fJ=Oe({opSnippet:dJ}),pJ={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const Pte={kernelName:hy,backendName:"webgl",kernelFunc:({inputs:t,backend:e})=>{const{image:n}=t,s=e,r=new Mte(n.shape);return s.runWebGLProgram(r,[n],n.dtype)}};/** + */const Mte={kernelName:hy,backendName:"webgl",kernelFunc:({inputs:t,backend:e})=>{const{image:n}=t,s=e,r=new Ote(n.shape);return s.runWebGLProgram(r,[n],n.dtype)}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -16868,7 +16868,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,fJ=Oe({opSnippet:dJ}),pJ={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const Gk="return floor(x);",Lte=Oe({opSnippet:Gk,packedOpSnippet:Gk,cpuKernelImpl:sQ}),Bte={kernelName:Au,backendName:"webgl",kernelFunc:Lte};/** + */const Gk="return floor(x);",Pte=Oe({opSnippet:Gk,packedOpSnippet:Gk,cpuKernelImpl:nQ}),Lte={kernelName:Ru,backendName:"webgl",kernelFunc:Pte};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -16883,7 +16883,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,fJ=Oe({opSnippet:dJ}),pJ={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const Vte=` + */const Bte=` float s = sign(a) * sign(b); int ia = round(a); int ib = round(b); @@ -16893,7 +16893,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,fJ=Oe({opSnippet:dJ}),pJ={kernelNam } else { return NAN; } -`,Wte=` +`,Vte=` ivec4 ia = round(a); ivec4 ib = round(b); bvec4 cond = notEqual(ib, ivec4(0)); @@ -16914,7 +16914,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,fJ=Oe({opSnippet:dJ}),pJ={kernelNam result[3] = idiv(ia[3], ib[3], s[3]); } return vec4(result); -`,Ute=rn({opSnippet:Vte,packedOpSnippet:Wte,dtype:"int32"}),Gte={kernelName:Du,backendName:"webgl",kernelFunc:Ute};/** +`,Wte=rn({opSnippet:Bte,packedOpSnippet:Vte,dtype:"int32"}),Ute={kernelName:Au,backendName:"webgl",kernelFunc:Wte};/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -16929,7 +16929,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,fJ=Oe({opSnippet:dJ}),pJ={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */class Hte{constructor(e){this.variableNames=["A"];const n=$n(),[s,r]=e;this.outputShape=e,this.userCode=` + */class Gte{constructor(e){this.variableNames=["A"];const n=$n(),[s,r]=e;this.outputShape=e,this.userCode=` void main() { ivec3 coords = getOutputCoords(); int texR = coords[0]; @@ -16966,7 +16966,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,fJ=Oe({opSnippet:dJ}),pJ={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */class jte{constructor(e){this.variableNames=["A"],this.packedInputs=!1,this.packedOutput=!0;const n=$n(),[s,r]=e;this.outputShape=e,this.userCode=` + */class Hte{constructor(e){this.variableNames=["A"],this.packedInputs=!1,this.packedOutput=!0;const n=$n(),[s,r]=e;this.outputShape=e,this.userCode=` void main() { ivec3 coords = getOutputCoords(); int texR = coords[0]; @@ -17015,7 +17015,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,fJ=Oe({opSnippet:dJ}),pJ={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const Kte={kernelName:GM,backendName:"webgl",kernelFunc:Xte};let la,Mg=W().getBool("CANVAS2D_WILL_READ_FREQUENTLY_FOR_GPU");function Xte(t){const{inputs:e,backend:n,attrs:s}=t;let{pixels:r}=e;const{numChannels:o}=s,i=typeof HTMLVideoElement<"u"&&r instanceof HTMLVideoElement,a=typeof HTMLImageElement<"u"&&r instanceof HTMLImageElement,[l,c]=i?[r.videoWidth,r.videoHeight]:[r.width,r.height],u=[c,l],h=[c,l,o];if(a||i){const g=W().getBool("CANVAS2D_WILL_READ_FREQUENTLY_FOR_GPU");(la==null||g!==Mg)&&(Mg=g,la=document.createElement("canvas").getContext("2d",{willReadFrequently:Mg})),la.canvas.width=l,la.canvas.height=c,la.drawImage(r,0,0,l,c),r=la.canvas}const d=n.makeTensorInfo(u,"int32");n.texData.get(d.dataId).usage=ns.PIXELS,n.gpgpu.uploadPixelDataToTexture(n.getTexture(d.dataId),r);const f=W().getBool("WEBGL_PACK")?new jte(h):new Hte(h),p=n.runWebGLProgram(f,[d],"int32");return n.disposeData(d.dataId),p}/** + */const jte={kernelName:UM,backendName:"webgl",kernelFunc:Kte};let la,Mg=W().getBool("CANVAS2D_WILL_READ_FREQUENTLY_FOR_GPU");function Kte(t){const{inputs:e,backend:n,attrs:s}=t;let{pixels:r}=e;const{numChannels:o}=s,i=typeof HTMLVideoElement<"u"&&r instanceof HTMLVideoElement,a=typeof HTMLImageElement<"u"&&r instanceof HTMLImageElement,[l,c]=i?[r.videoWidth,r.videoHeight]:[r.width,r.height],u=[c,l],h=[c,l,o];if(a||i){const g=W().getBool("CANVAS2D_WILL_READ_FREQUENTLY_FOR_GPU");(la==null||g!==Mg)&&(Mg=g,la=document.createElement("canvas").getContext("2d",{willReadFrequently:Mg})),la.canvas.width=l,la.canvas.height=c,la.drawImage(r,0,0,l,c),r=la.canvas}const d=n.makeTensorInfo(u,"int32");n.texData.get(d.dataId).usage=ns.PIXELS,n.gpgpu.uploadPixelDataToTexture(n.getTexture(d.dataId),r);const f=W().getBool("WEBGL_PACK")?new Hte(h):new Gte(h),p=n.runWebGLProgram(f,[d],"int32");return n.disposeData(d.dataId),p}/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -17030,7 +17030,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,fJ=Oe({opSnippet:dJ}),pJ={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function qte(t){const{inputs:e,backend:n,attrs:s}=t,{x:r,filter:o,bias:i,preluActivationWeights:a}=e,{strides:l,pad:c,dataFormat:u,dilations:h,dimRoundingMode:d,activation:f,leakyreluAlpha:p}=s,g=Qr(u),x=nn(r.shape,o.shape,l,h,c,d,!1,g);let m;const y=[],w=i!=null,v=a!=null,b=f==="leakyrelu",C=()=>{const S=[r,o],$=(N,A)=>{if(A==="NCHW"&&N.shape.length===1&&N.shape[0]!==1){const M=re({inputs:{x:N},backend:n,attrs:{shape:[N.shape[0],1,1]}});return y.push(M),M}return N};if(w&&S.push($(i,u)),v&&S.push($(a,u)),b){const N=n.makeTensorInfo([],"float32",Wo(p,"float32"));S.push(N),y.push(N)}return S};if(x.filterHeight===1&&x.filterWidth===1&&x.dilationHeight===1&&x.dilationWidth===1&&x.strideHeight===1&&x.strideWidth===1&&(x.padInfo.type==="SAME"||x.padInfo.type==="VALID"))m=gD({x:r,filter:o,convInfo:x,backend:n,bias:i,activation:f,preluActivationWeights:a,leakyreluAlpha:p});else if(x.strideWidth<=2&&g==="channelsLast"&&W().getBool("WEBGL_EXP_CONV")){const S=f?tu(f,!0):null,$=new mD(x,w,S,v,b),N=[[x.padInfo.top,x.padInfo.left],[x.strideHeight,x.strideWidth],[x.dilationHeight,x.dilationWidth],[x.inHeight,x.inWidth]],A=C();m=n.runWebGLProgram($,A,"float32",N)}else if(W().getBool("WEBGL_CONV_IM2COL"))m=xD({x:r,filter:o,convInfo:x,backend:n,bias:i,activation:f,preluActivationWeights:a,leakyreluAlpha:p});else{const S=f?tu(f,!1):null,$=new pD(x,w,S,v,b),N=C();m=n.runWebGLProgram($,N,"float32")}const k=re({inputs:{x:m},backend:n,attrs:{shape:x.outShape}});return y.push(m),y.forEach(S=>n.disposeIntermediateTensorInfo(S)),k}const Yte={kernelName:pf,backendName:"webgl",kernelFunc:qte};/** + */function Xte(t){const{inputs:e,backend:n,attrs:s}=t,{x:r,filter:o,bias:i,preluActivationWeights:a}=e,{strides:l,pad:c,dataFormat:u,dilations:h,dimRoundingMode:d,activation:f,leakyreluAlpha:p}=s,g=Qr(u),x=nn(r.shape,o.shape,l,h,c,d,!1,g);let m;const y=[],w=i!=null,v=a!=null,b=f==="leakyrelu",C=()=>{const S=[r,o],$=(N,A)=>{if(A==="NCHW"&&N.shape.length===1&&N.shape[0]!==1){const M=re({inputs:{x:N},backend:n,attrs:{shape:[N.shape[0],1,1]}});return y.push(M),M}return N};if(w&&S.push($(i,u)),v&&S.push($(a,u)),b){const N=n.makeTensorInfo([],"float32",Wo(p,"float32"));S.push(N),y.push(N)}return S};if(x.filterHeight===1&&x.filterWidth===1&&x.dilationHeight===1&&x.dilationWidth===1&&x.strideHeight===1&&x.strideWidth===1&&(x.padInfo.type==="SAME"||x.padInfo.type==="VALID"))m=gD({x:r,filter:o,convInfo:x,backend:n,bias:i,activation:f,preluActivationWeights:a,leakyreluAlpha:p});else if(x.strideWidth<=2&&g==="channelsLast"&&W().getBool("WEBGL_EXP_CONV")){const S=f?tu(f,!0):null,$=new mD(x,w,S,v,b),N=[[x.padInfo.top,x.padInfo.left],[x.strideHeight,x.strideWidth],[x.dilationHeight,x.dilationWidth],[x.inHeight,x.inWidth]],A=C();m=n.runWebGLProgram($,A,"float32",N)}else if(W().getBool("WEBGL_CONV_IM2COL"))m=xD({x:r,filter:o,convInfo:x,backend:n,bias:i,activation:f,preluActivationWeights:a,leakyreluAlpha:p});else{const S=f?tu(f,!1):null,$=new pD(x,w,S,v,b),N=C();m=n.runWebGLProgram($,N,"float32")}const k=re({inputs:{x:m},backend:n,attrs:{shape:x.outShape}});return y.push(m),y.forEach(S=>n.disposeIntermediateTensorInfo(S)),k}const qte={kernelName:ff,backendName:"webgl",kernelFunc:Xte};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -17045,7 +17045,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,fJ=Oe({opSnippet:dJ}),pJ={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function Qte(t){const{inputs:e,backend:n,attrs:s}=t,{x:r,filter:o,bias:i,preluActivationWeights:a}=e,{strides:l,pad:c,dilations:u,dimRoundingMode:h,activation:d,leakyreluAlpha:f}=s,p=[];let g=u;g==null&&(g=[1,1]),I(dn(l,g),()=>`Error in depthwiseConv2d: Either strides or dilations must be 1. Got strides ${l} and dilations '${g}'`);const x=nn(r.shape,o.shape,l,g,c,h,!0),m=W().getBool("WEBGL_PACK_DEPTHWISECONV")&&x.strideWidth<=2&&x.outChannels/x.inChannels===1,y=d?tu(d,m):null,w=[r,o],v=i!=null,b=a!=null,C=d==="leakyrelu";if(v&&w.push(i),b&&w.push(a),C){const N=n.makeTensorInfo([],"float32",Wo(f,"float32"));w.push(N),p.push(N)}let k;m?k=new vD(x,v,y,b,C):k=new wD(x,v,y,b,C);const S=[[x.padInfo.top,x.padInfo.left],[x.strideHeight,x.strideWidth],[x.dilationHeight,x.dilationWidth],[x.inHeight,x.inWidth]],$=n.runWebGLProgram(k,w,"float32",S);return p.forEach(N=>n.disposeIntermediateTensorInfo(N)),$}const Zte={kernelName:w$,backendName:"webgl",kernelFunc:Qte};class Jte{constructor(e,n,s,r){this.sliceDim=e,this.strides=n,this.paramsShape=r,this.variableNames=["x","indices"],this.outputShape=s;const o=Ze(s.length);let i=` + */function Yte(t){const{inputs:e,backend:n,attrs:s}=t,{x:r,filter:o,bias:i,preluActivationWeights:a}=e,{strides:l,pad:c,dilations:u,dimRoundingMode:h,activation:d,leakyreluAlpha:f}=s,p=[];let g=u;g==null&&(g=[1,1]),I(dn(l,g),()=>`Error in depthwiseConv2d: Either strides or dilations must be 1. Got strides ${l} and dilations '${g}'`);const x=nn(r.shape,o.shape,l,g,c,h,!0),m=W().getBool("WEBGL_PACK_DEPTHWISECONV")&&x.strideWidth<=2&&x.outChannels/x.inChannels===1,y=d?tu(d,m):null,w=[r,o],v=i!=null,b=a!=null,C=d==="leakyrelu";if(v&&w.push(i),b&&w.push(a),C){const N=n.makeTensorInfo([],"float32",Wo(f,"float32"));w.push(N),p.push(N)}let k;m?k=new vD(x,v,y,b,C):k=new wD(x,v,y,b,C);const S=[[x.padInfo.top,x.padInfo.left],[x.strideHeight,x.strideWidth],[x.dilationHeight,x.dilationWidth],[x.inHeight,x.inWidth]],$=n.runWebGLProgram(k,w,"float32",S);return p.forEach(N=>n.disposeIntermediateTensorInfo(N)),$}const Qte={kernelName:w$,backendName:"webgl",kernelFunc:Yte};class Zte{constructor(e,n,s,r){this.sliceDim=e,this.strides=n,this.paramsShape=r,this.variableNames=["x","indices"],this.outputShape=s;const o=Ze(s.length);let i=` int index;`;for(let a=0;a= 0) && (index < ${e[2]}) ? 1.0 : 0.0; setOutput(inBounds * getA(${r})); } - `}}function sne(t,e){const n=["resRC.x","resRC.y","resRC.z","resRC.w"],s=[];for(let r=0;r=0,()=>`GatherV2: the index value ${b} is not in [0, ${w-1}]`)}}const c=Ww(r,o,l,a),u=j(o.shape),h=[],d=re({inputs:{x:r},backend:n,attrs:{shape:[c.batchSize,c.outerSize,c.dimSize,c.sliceSize]}}),f=re({inputs:{x:o},backend:n,attrs:{shape:[c.batchSize,u/c.batchSize]}});h.push(d),h.push(f);const p=[c.batchSize,c.outerSize,u/c.batchSize,c.sliceSize];if(n.shouldExecuteOnCPU([r,o])||r.dtype==="string"){const y=n.bufferSync(f),w=n.bufferSync(d),v=oQ(w,y,p);return h.forEach(b=>n.disposeIntermediateTensorInfo(b)),n.makeTensorInfo(c.outputShape,v.dtype,v.values)}const g=new nne(d.shape,p),x=n.runWebGLProgram(g,[d,f],d.dtype);h.push(x);const m=re({inputs:{x},backend:n,attrs:{shape:c.outputShape}});return h.forEach(y=>n.disposeIntermediateTensorInfo(y)),m}const rne={kernelName:Dp,backendName:"webgl",kernelFunc:kD};/** + */function kD(t){const{inputs:e,backend:n,attrs:s}=t,{x:r,indices:o}=e,{axis:i,batchDims:a}=s,l=Re(i,r.shape)[0];if(W().get("DEBUG")){const y=n.readSync(o.dataId),w=r.shape[l];for(let v=0;v=0,()=>`GatherV2: the index value ${b} is not in [0, ${w-1}]`)}}const c=Ww(r,o,l,a),u=j(o.shape),h=[],d=re({inputs:{x:r},backend:n,attrs:{shape:[c.batchSize,c.outerSize,c.dimSize,c.sliceSize]}}),f=re({inputs:{x:o},backend:n,attrs:{shape:[c.batchSize,u/c.batchSize]}});h.push(d),h.push(f);const p=[c.batchSize,c.outerSize,u/c.batchSize,c.sliceSize];if(n.shouldExecuteOnCPU([r,o])||r.dtype==="string"){const y=n.bufferSync(f),w=n.bufferSync(d),v=rQ(w,y,p);return h.forEach(b=>n.disposeIntermediateTensorInfo(b)),n.makeTensorInfo(c.outputShape,v.dtype,v.values)}const g=new tne(d.shape,p),x=n.runWebGLProgram(g,[d,f],d.dtype);h.push(x);const m=re({inputs:{x},backend:n,attrs:{shape:c.outputShape}});return h.forEach(y=>n.disposeIntermediateTensorInfo(y)),m}const sne={kernelName:Dp,backendName:"webgl",kernelFunc:kD};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -17127,9 +17127,9 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,fJ=Oe({opSnippet:dJ}),pJ={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const one="return float(a > b);",ine=` + */const rne="return float(a > b);",one=` return vec4(greaterThan(a, b)); -`,ane=rn({opSnippet:one,packedOpSnippet:ine,cpuKernelImpl:iQ,dtype:"bool"}),lne={kernelName:_p,backendName:"webgl",kernelFunc:ane};/** +`,ine=rn({opSnippet:rne,packedOpSnippet:one,cpuKernelImpl:oQ,dtype:"bool"}),ane={kernelName:_p,backendName:"webgl",kernelFunc:ine};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -17144,9 +17144,9 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,fJ=Oe({opSnippet:dJ}),pJ={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const cne="return float(a >= b);",une=` + */const lne="return float(a >= b);",cne=` return vec4(greaterThanEqual(a, b)); -`,hne=rn({opSnippet:cne,packedOpSnippet:une,dtype:"bool",cpuKernelImpl:aQ}),dne={kernelName:_u,backendName:"webgl",kernelFunc:hne};/** +`,une=rn({opSnippet:lne,packedOpSnippet:cne,dtype:"bool",cpuKernelImpl:iQ}),hne={kernelName:Du,backendName:"webgl",kernelFunc:une};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -17161,7 +17161,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,fJ=Oe({opSnippet:dJ}),pJ={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function fne(t){const{inputs:e,backend:n}=t,{input:s}=e;return CD(s,!0,n)}const pne={kernelName:dy,backendName:"webgl",kernelFunc:fne};/** + */function dne(t){const{inputs:e,backend:n}=t,{input:s}=e;return CD(s,!0,n)}const fne={kernelName:dy,backendName:"webgl",kernelFunc:dne};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -17176,7 +17176,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,fJ=Oe({opSnippet:dJ}),pJ={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const mne="return float(!isnan(x) && !isinf(x));",gne=Oe({opSnippet:mne,dtype:"bool"}),xne={kernelName:zu,backendName:"webgl",kernelFunc:gne};/** + */const pne="return float(!isnan(x) && !isinf(x));",mne=Oe({opSnippet:pne,dtype:"bool"}),gne={kernelName:Fu,backendName:"webgl",kernelFunc:mne};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -17191,7 +17191,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,fJ=Oe({opSnippet:dJ}),pJ={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const yne="return float(isinf(x));",wne=Oe({opSnippet:yne,dtype:"bool"}),vne={kernelName:Ou,backendName:"webgl",kernelFunc:wne};/** + */const xne="return float(isinf(x));",yne=Oe({opSnippet:xne,dtype:"bool"}),wne={kernelName:zu,backendName:"webgl",kernelFunc:yne};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -17206,7 +17206,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,fJ=Oe({opSnippet:dJ}),pJ={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const bne="return float(isnan(x));",Cne=Oe({opSnippet:bne,dtype:"bool"}),kne={kernelName:Mu,backendName:"webgl",kernelFunc:Cne};/** + */const vne="return float(isnan(x));",bne=Oe({opSnippet:vne,dtype:"bool"}),Cne={kernelName:Ou,backendName:"webgl",kernelFunc:bne};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -17221,9 +17221,9 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,fJ=Oe({opSnippet:dJ}),pJ={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const Sne="return float(a < b);",Ine=` + */const kne="return float(a < b);",Sne=` return vec4(lessThan(a, b)); -`,$ne=rn({opSnippet:Sne,packedOpSnippet:Ine,cpuKernelImpl:lQ,dtype:"bool"}),Nne={kernelName:zp,backendName:"webgl",kernelFunc:$ne};/** +`,Ine=rn({opSnippet:kne,packedOpSnippet:Sne,cpuKernelImpl:aQ,dtype:"bool"}),$ne={kernelName:zp,backendName:"webgl",kernelFunc:Ine};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -17238,9 +17238,9 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,fJ=Oe({opSnippet:dJ}),pJ={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const Tne="return float(a <= b);",Ene=` + */const Nne="return float(a <= b);",Tne=` return vec4(lessThanEqual(a, b)); -`,Rne=rn({opSnippet:Tne,packedOpSnippet:Ene,cpuKernelImpl:cQ,dtype:"bool"}),Ane={kernelName:Op,backendName:"webgl",kernelFunc:Rne};/** +`,Ene=rn({opSnippet:Nne,packedOpSnippet:Tne,cpuKernelImpl:lQ,dtype:"bool"}),Rne={kernelName:Op,backendName:"webgl",kernelFunc:Ene};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -17255,7 +17255,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,fJ=Oe({opSnippet:dJ}),pJ={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function Dne(t){const{backend:e,attrs:n}=t,{start:s,stop:r,num:o}=n,i=uQ(s,r,o);return e.makeTensorInfo([i.length],"float32",i)}const _ne={kernelName:n$,backendName:"webgl",kernelFunc:Dne};/** + */function Ane(t){const{backend:e,attrs:n}=t,{start:s,stop:r,num:o}=n,i=cQ(s,r,o);return e.makeTensorInfo([i.length],"float32",i)}const Dne={kernelName:n$,backendName:"webgl",kernelFunc:Ane};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -17270,9 +17270,9 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,fJ=Oe({opSnippet:dJ}),pJ={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const Fne=_l+` + */const _ne=_l+` return x < 0.0 ? 0./0. : log(x); -`,zne=` +`,Fne=` vec4 result = log(x); bvec4 isNaN = isnan(x); result.r = isNaN.r ? x.r : (x.r < 0.0 ? 0./0. : result.r); @@ -17280,7 +17280,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,fJ=Oe({opSnippet:dJ}),pJ={kernelNam result.b = isNaN.b ? x.b : (x.b < 0.0 ? 0./0. : result.b); result.a = isNaN.a ? x.a : (x.a < 0.0 ? 0./0. : result.a); return result; -`,One=Oe({opSnippet:Fne,packedOpSnippet:zne,cpuKernelImpl:hQ}),Mne={kernelName:Pu,backendName:"webgl",kernelFunc:One};/** +`,zne=Oe({opSnippet:_ne,packedOpSnippet:Fne,cpuKernelImpl:uQ}),One={kernelName:Mu,backendName:"webgl",kernelFunc:zne};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -17295,9 +17295,9 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,fJ=Oe({opSnippet:dJ}),pJ={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const Pne=_l+` + */const Mne=_l+` return log(1.0 + x); -`,Lne=Oe({opSnippet:Pne}),Bne={kernelName:Lu,backendName:"webgl",kernelFunc:Lne};/** +`,Pne=Oe({opSnippet:Mne}),Lne={kernelName:Pu,backendName:"webgl",kernelFunc:Pne};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -17312,11 +17312,11 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,fJ=Oe({opSnippet:dJ}),pJ={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const Vne="return float(a >= 1.0 && b >= 1.0);",Wne=` + */const Bne="return float(a >= 1.0 && b >= 1.0);",Vne=` return vec4( vec4(greaterThanEqual(a, vec4(1.0))) * vec4(greaterThanEqual(b, vec4(1.0)))); -`,Une=rn({opSnippet:Vne,packedOpSnippet:Wne,dtype:"bool"}),Gne={kernelName:Mp,backendName:"webgl",kernelFunc:Une};/** +`,Wne=rn({opSnippet:Bne,packedOpSnippet:Vne,dtype:"bool"}),Une={kernelName:Mp,backendName:"webgl",kernelFunc:Wne};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -17331,7 +17331,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,fJ=Oe({opSnippet:dJ}),pJ={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const Hne="return float(!(x >= 1.0));",jne=Oe({opSnippet:Hne}),Kne={kernelName:Pp,backendName:"webgl",kernelFunc:jne};/** + */const Gne="return float(!(x >= 1.0));",Hne=Oe({opSnippet:Gne}),jne={kernelName:Pp,backendName:"webgl",kernelFunc:Hne};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -17346,12 +17346,12 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,fJ=Oe({opSnippet:dJ}),pJ={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const Xne="return float(a >= 1.0 || b >= 1.0);",qne=` + */const Kne="return float(a >= 1.0 || b >= 1.0);",Xne=` return min( vec4(greaterThanEqual(a, vec4(1.0))) + vec4(greaterThanEqual(b, vec4(1.0))), vec4(1.0)); -`,Yne=rn({opSnippet:Xne,packedOpSnippet:qne,dtype:"bool"}),Qne={kernelName:Lp,backendName:"webgl",kernelFunc:Yne};/** +`,qne=rn({opSnippet:Kne,packedOpSnippet:Xne,dtype:"bool"}),Yne={kernelName:Lp,backendName:"webgl",kernelFunc:qne};/** * @license * Copyright 2017 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -17366,7 +17366,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,fJ=Oe({opSnippet:dJ}),pJ={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */class Zne{constructor(e,n,s,r,o){this.variableNames=["x"],this.outputShape=[];const i=n,a=e[3]-1;this.outputShape=e;let l;const c=`float(${s}) + float(${r}) * sum`;o===.5?l=`inversesqrt(${c})`:o===1?l=`1.0/(${c})`:l=`exp(log(${c}) * float(-${o}));`,this.userCode=` + */class Qne{constructor(e,n,s,r,o){this.variableNames=["x"],this.outputShape=[];const i=n,a=e[3]-1;this.outputShape=e;let l;const c=`float(${s}) + float(${r}) * sum`;o===.5?l=`inversesqrt(${c})`:o===1?l=`1.0/(${c})`:l=`exp(log(${c}) * float(-${o}));`,this.userCode=` void main() { ivec4 coords = getOutputCoords(); int b = coords[0]; @@ -17400,7 +17400,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,fJ=Oe({opSnippet:dJ}),pJ={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */class Jne{constructor(e,n,s,r,o){this.variableNames=["x"],this.outputShape=[],this.packedInputs=!0,this.packedOutput=!0;const i=n,a=e[3]-1;this.outputShape=e;let l;const c=`float(${s}) + float(${r}) * sum`;o===.5?l=`inversesqrt(${c})`:o===1?l=`1.0/(${c})`:l=`exp(log(${c}) * float(-${o}));`,this.userCode=` + */class Zne{constructor(e,n,s,r,o){this.variableNames=["x"],this.outputShape=[],this.packedInputs=!0,this.packedOutput=!0;const i=n,a=e[3]-1;this.outputShape=e;let l;const c=`float(${s}) + float(${r}) * sum`;o===.5?l=`inversesqrt(${c})`:o===1?l=`1.0/(${c})`:l=`exp(log(${c}) * float(-${o}));`,this.userCode=` void main() { ivec4 coords = getOutputCoords(); int b = coords.x; @@ -17477,7 +17477,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,fJ=Oe({opSnippet:dJ}),pJ={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const ese=t=>{const{inputs:e,backend:n,attrs:s}=t,{x:r}=e,{depthRadius:o,bias:i,alpha:a,beta:l}=s,c=W().getBool("WEBGL_PACK_NORMALIZATION")?new Jne(r.shape,o,i,a,l):new Zne(r.shape,o,i,a,l);return n.runWebGLProgram(c,[r],r.dtype)},tse={kernelName:Bp,backendName:"webgl",kernelFunc:ese};/** + */const Jne=t=>{const{inputs:e,backend:n,attrs:s}=t,{x:r}=e,{depthRadius:o,bias:i,alpha:a,beta:l}=s,c=W().getBool("WEBGL_PACK_NORMALIZATION")?new Zne(r.shape,o,i,a,l):new Qne(r.shape,o,i,a,l);return n.runWebGLProgram(c,[r],r.dtype)},ese={kernelName:Bp,backendName:"webgl",kernelFunc:Jne};/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -17492,7 +17492,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,fJ=Oe({opSnippet:dJ}),pJ={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */class nse{constructor(e,n,s,r,o){this.variableNames=["inputImage","outputImage","dy"],this.outputShape=[],this.outputShape=e,this.depth=e[3],this.depthRadius=n,this.bias=s,this.alpha=r,this.beta=o,this.userCode=` + */class tse{constructor(e,n,s,r,o){this.variableNames=["inputImage","outputImage","dy"],this.outputShape=[],this.outputShape=e,this.depth=e[3],this.depthRadius=n,this.bias=s,this.alpha=r,this.beta=o,this.userCode=` void main() { ivec4 coords = getOutputCoords(); int b = coords[0]; @@ -17562,7 +17562,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,fJ=Oe({opSnippet:dJ}),pJ={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const sse=t=>{const{inputs:e,backend:n,attrs:s}=t,{x:r,y:o,dy:i}=e,{depthRadius:a,bias:l,alpha:c,beta:u}=s,h=new nse(r.shape,a,l,c,u);return n.runWebGLProgram(h,[r,o,i],r.dtype)},rse={kernelName:py,backendName:"webgl",kernelFunc:sse};/** + */const nse=t=>{const{inputs:e,backend:n,attrs:s}=t,{x:r,y:o,dy:i}=e,{depthRadius:a,bias:l,alpha:c,beta:u}=s,h=new tse(r.shape,a,l,c,u);return n.runWebGLProgram(h,[r,o,i],r.dtype)},sse={kernelName:py,backendName:"webgl",kernelFunc:nse};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -17577,7 +17577,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,fJ=Oe({opSnippet:dJ}),pJ={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function ose(t,e,n,s){const r=j(e),i=j(t.shape)/r,a=re({inputs:{x:t},attrs:{shape:[i,r]},backend:s}),l=sa(a,t.dtype,"max",s),c=re({inputs:{x:l},attrs:{shape:n},backend:s});return s.disposeIntermediateTensorInfo(a),s.disposeIntermediateTensorInfo(l),c}/** + */function rse(t,e,n,s){const r=j(e),i=j(t.shape)/r,a=re({inputs:{x:t},attrs:{shape:[i,r]},backend:s}),l=sa(a,t.dtype,"max",s),c=re({inputs:{x:l},attrs:{shape:n},backend:s});return s.disposeIntermediateTensorInfo(a),s.disposeIntermediateTensorInfo(l),c}/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -17592,7 +17592,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,fJ=Oe({opSnippet:dJ}),pJ={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function SD(t){const{inputs:e,backend:n,attrs:s}=t,{x:r}=e,{reductionIndices:o,keepDims:i}=s,a=r.shape.length,l=Re(o,r.shape);let c=l;const u=yt(c,a),h=u!=null,d=n.shouldExecuteOnCPU([r]);let f=r;if(h){if(d){const w=n.texData.get(f.dataId).values,v=new Array(a);for(let k=0;k`Error in maxPool: Either strides or dilations must be 1. Got strides ${i} and dilations '${c}'`);const u=As(r.shape,o,i,c,a,l);if(u.filterWidth===1&&u.filterHeight===1&&Ue(u.inShape,u.outShape))return Yn({inputs:{x:r},backend:n});const h=new nu(u,"max",!1);return n.runWebGLProgram(h,[r],r.dtype)}const dse={kernelName:Wp,backendName:"webgl",kernelFunc:hse};/** + */function use(t){const{inputs:e,backend:n,attrs:s}=t,{x:r}=e;Th(r,"maxPool");const{filterSize:o,strides:i,pad:a,dimRoundingMode:l}=s,c=1;I(dn(i,c),()=>`Error in maxPool: Either strides or dilations must be 1. Got strides ${i} and dilations '${c}'`);const u=As(r.shape,o,i,c,a,l);if(u.filterWidth===1&&u.filterHeight===1&&Ue(u.inShape,u.outShape))return Yn({inputs:{x:r},backend:n});const h=new nu(u,"max",!1);return n.runWebGLProgram(h,[r],r.dtype)}const hse={kernelName:Wp,backendName:"webgl",kernelFunc:use};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -17646,7 +17646,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,fJ=Oe({opSnippet:dJ}),pJ={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function fse(t){const{inputs:e,backend:n,attrs:s}=t,{x:r}=e,{filterSize:o,strides:i,pad:a,dataFormat:l,dimRoundingMode:c}=s,u=[1,1,1],h=Yr(r.shape,o,i,u,a,c,l),d=new Nv(h,"max",!1);return n.runWebGLProgram(d,[r],r.dtype)}const pse={kernelName:Up,backendName:"webgl",kernelFunc:fse};/** + */function dse(t){const{inputs:e,backend:n,attrs:s}=t,{x:r}=e,{filterSize:o,strides:i,pad:a,dataFormat:l,dimRoundingMode:c}=s,u=[1,1,1],h=Yr(r.shape,o,i,u,a,c,l),d=new Nv(h,"max",!1);return n.runWebGLProgram(d,[r],r.dtype)}const fse={kernelName:Up,backendName:"webgl",kernelFunc:dse};/** * @license * Copyright 2017 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -17661,7 +17661,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,fJ=Oe({opSnippet:dJ}),pJ={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */class mse{constructor(e){this.variableNames=["dy","maxPos"],this.outputShape=e.inShape;const n=e.strideHeight,s=e.strideWidth,r=e.dilationHeight,o=e.effectiveFilterHeight,i=e.effectiveFilterWidth,a=o-1-e.padInfo.top,l=i-1-e.padInfo.left,c=o*i-1;this.userCode=` + */class pse{constructor(e){this.variableNames=["dy","maxPos"],this.outputShape=e.inShape;const n=e.strideHeight,s=e.strideWidth,r=e.dilationHeight,o=e.effectiveFilterHeight,i=e.effectiveFilterWidth,a=o-1-e.padInfo.top,l=i-1-e.padInfo.left,c=o*i-1;this.userCode=` const ivec2 pads = ivec2(${a}, ${l}); void main() { @@ -17707,7 +17707,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,fJ=Oe({opSnippet:dJ}),pJ={kernelNam } setOutput(dotProd); } - `}}class gse{constructor(e){this.variableNames=["dy","maxPos"],this.outputShape=e.inShape;const n=e.strideDepth,s=e.strideHeight,r=e.strideWidth,o=e.dilationDepth,i=e.dilationHeight,a=e.dilationWidth,l=e.effectiveFilterDepth,c=e.effectiveFilterHeight,u=e.effectiveFilterWidth,h=l-1-e.padInfo.front,d=c-1-e.padInfo.top,f=u-1-e.padInfo.left,p=l*c*u-1;this.userCode=` + `}}class mse{constructor(e){this.variableNames=["dy","maxPos"],this.outputShape=e.inShape;const n=e.strideDepth,s=e.strideHeight,r=e.strideWidth,o=e.dilationDepth,i=e.dilationHeight,a=e.dilationWidth,l=e.effectiveFilterDepth,c=e.effectiveFilterHeight,u=e.effectiveFilterWidth,h=l-1-e.padInfo.front,d=c-1-e.padInfo.top,f=u-1-e.padInfo.left,p=l*c*u-1;this.userCode=` const ivec3 pads = ivec3(${h}, ${d}, ${f}); void main() { @@ -17786,7 +17786,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,fJ=Oe({opSnippet:dJ}),pJ={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function xse(t){const{inputs:e,backend:n,attrs:s}=t,{dy:r,input:o}=e,i=o,{filterSize:a,strides:l,pad:c,dimRoundingMode:u}=s,h=[1,1,1],d=Yr(i.shape,a,l,h,c,u),f=new Nv(d,"max",!0),p=n.runWebGLProgram(f,[i],i.dtype),g=new gse(d),x=n.runWebGLProgram(g,[r,p],i.dtype);return n.disposeIntermediateTensorInfo(p),x}const yse={kernelName:gy,backendName:"webgl",kernelFunc:xse};/** + */function gse(t){const{inputs:e,backend:n,attrs:s}=t,{dy:r,input:o}=e,i=o,{filterSize:a,strides:l,pad:c,dimRoundingMode:u}=s,h=[1,1,1],d=Yr(i.shape,a,l,h,c,u),f=new Nv(d,"max",!0),p=n.runWebGLProgram(f,[i],i.dtype),g=new mse(d),x=n.runWebGLProgram(g,[r,p],i.dtype);return n.disposeIntermediateTensorInfo(p),x}const xse={kernelName:gy,backendName:"webgl",kernelFunc:gse};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -17801,7 +17801,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,fJ=Oe({opSnippet:dJ}),pJ={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function wse(t){const{inputs:e,backend:n,attrs:s}=t,{dy:r,input:o,output:i}=e,a=o;Eh([o,i],"maxPoolGrad");const{filterSize:l,strides:c,pad:u,dimRoundingMode:h}=s,d=As(a.shape,l,c,1,u,h),f=!0,p=new nu(d,"max",f),g=n.runWebGLProgram(p,[a],a.dtype),x=new mse(d),m=n.runWebGLProgram(x,[r,g],a.dtype);return n.disposeIntermediateTensorInfo(g),m}const vse={kernelName:my,backendName:"webgl",kernelFunc:wse};/** + */function yse(t){const{inputs:e,backend:n,attrs:s}=t,{dy:r,input:o,output:i}=e,a=o;Th([o,i],"maxPoolGrad");const{filterSize:l,strides:c,pad:u,dimRoundingMode:h}=s,d=As(a.shape,l,c,1,u,h),f=!0,p=new nu(d,"max",f),g=n.runWebGLProgram(p,[a],a.dtype),x=new pse(d),m=n.runWebGLProgram(x,[r,g],a.dtype);return n.disposeIntermediateTensorInfo(g),m}const wse={kernelName:my,backendName:"webgl",kernelFunc:yse};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -17816,7 +17816,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,fJ=Oe({opSnippet:dJ}),pJ={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function bse(t,e,n,s){let r=new nu(n,"max",!1);const o=s.runWebGLProgram(r,[t],"float32");r=new nu(n,"max",!0,!0,e);const i=s.runWebGLProgram(r,[t],"float32");return[o,i]}/** + */function vse(t,e,n,s){let r=new nu(n,"max",!1);const o=s.runWebGLProgram(r,[t],"float32");r=new nu(n,"max",!0,!0,e);const i=s.runWebGLProgram(r,[t],"float32");return[o,i]}/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -17831,7 +17831,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,fJ=Oe({opSnippet:dJ}),pJ={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const Cse={kernelName:s$,backendName:"webgl",kernelFunc:({inputs:t,attrs:e,backend:n})=>{const{x:s}=t,{filterSize:r,strides:o,pad:i,includeBatchInIndex:a}=e,l=n;I(s.shape.length===4,()=>`Error in maxPool: input must be rank 4 but got rank ${s.shape.length}.`);const c=[1,1];I(dn(o,c),()=>`Error in maxPool: Either strides or dilations must be 1. Got strides ${o} and dilations '${c}'`);const u=As(s.shape,r,o,c,i),[h,d]=bse(s,a,u,l);return[h,d]}};/** + */const bse={kernelName:s$,backendName:"webgl",kernelFunc:({inputs:t,attrs:e,backend:n})=>{const{x:s}=t,{filterSize:r,strides:o,pad:i,includeBatchInIndex:a}=e,l=n;I(s.shape.length===4,()=>`Error in maxPool: input must be rank 4 but got rank ${s.shape.length}.`);const c=[1,1];I(dn(o,c),()=>`Error in maxPool: Either strides or dilations must be 1. Got strides ${o} and dilations '${c}'`);const u=As(s.shape,r,o,c,i),[h,d]=vse(s,a,u,l);return[h,d]}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -17846,7 +17846,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,fJ=Oe({opSnippet:dJ}),pJ={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function kse(t,e,n,s){const r=j(e),i=j(t.shape)/r,a=re({inputs:{x:t},attrs:{shape:[i,r]},backend:s}),l=sa(a,"float32","mean",s),c=re({inputs:{x:l},attrs:{shape:n},backend:s});return s.disposeIntermediateTensorInfo(a),s.disposeIntermediateTensorInfo(l),c}/** + */function Cse(t,e,n,s){const r=j(e),i=j(t.shape)/r,a=re({inputs:{x:t},attrs:{shape:[i,r]},backend:s}),l=sa(a,"float32","mean",s),c=re({inputs:{x:l},attrs:{shape:n},backend:s});return s.disposeIntermediateTensorInfo(a),s.disposeIntermediateTensorInfo(l),c}/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -17861,7 +17861,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,fJ=Oe({opSnippet:dJ}),pJ={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const Sse={kernelName:Gp,backendName:"webgl",kernelFunc:({inputs:t,attrs:e,backend:n})=>{const{x:s}=t,{keepDims:r,axis:o}=e,i=n,a=s.shape.length,l=Re(o,s.shape);let c=l;const u=yt(c,a),h=u!=null,d=i.shouldExecuteOnCPU([s]),f=[];let p=s;if(h){if(d){const v=i.texData.get(p.dataId).values,b=new Array(a);for(let S=0;S{const{x:s}=t,{keepDims:r,axis:o}=e,i=n,a=s.shape.length,l=Re(o,s.shape);let c=l;const u=yt(c,a),h=u!=null,d=i.shouldExecuteOnCPU([s]),f=[];let p=s;if(h){if(d){const v=i.texData.get(p.dataId).values,b=new Array(a);for(let S=0;Su[0]+e[h]+u[1]);const r=e.length,o=Ze(r),i=n.map(u=>u[0]).join(","),a=n.map((u,h)=>u[0]+e[h]).join(","),l=["coords[0]","coords[1]","coords[2]","coords[3]"].slice(0,r),c=s==="reflect"?0:1;if(r===1){this.userCode=` + */class Rse{constructor(e,n,s){this.variableNames=["x"],this.outputShape=n.map((u,h)=>u[0]+e[h]+u[1]);const r=e.length,o=Ze(r),i=n.map(u=>u[0]).join(","),a=n.map((u,h)=>u[0]+e[h]).join(","),l=["coords[0]","coords[1]","coords[2]","coords[3]"].slice(0,r),c=s==="reflect"?0:1;if(r===1){this.userCode=` int start = ${i}; int end = ${a}; @@ -17959,7 +17959,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,fJ=Oe({opSnippet:dJ}),pJ={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */class Dse{constructor(e,n,s){this.variableNames=["x"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=n.map((p,g)=>p[0]+e[g]+p[1]);const r=e.length,o=Ze(r),i=n.map(p=>p[0]).join(","),a=n.map((p,g)=>p[0]+e[g]).join(","),l=vn("rc",r),c=vn("source",r),u=`${l[r-1]} < ${this.outputShape[r-1]}`,h=r===1?"source":`vec2(${c.slice(-2).join()})`,d=s==="reflect"?0:1;let f="";if(r===1){const p=` + */class Ase{constructor(e,n,s){this.variableNames=["x"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=n.map((p,g)=>p[0]+e[g]+p[1]);const r=e.length,o=Ze(r),i=n.map(p=>p[0]).join(","),a=n.map((p,g)=>p[0]+e[g]).join(","),l=vn("rc",r),c=vn("source",r),u=`${l[r-1]} < ${this.outputShape[r-1]}`,h=r===1?"source":`vec2(${c.slice(-2).join()})`,d=s==="reflect"?0:1;let f="";if(r===1){const p=` ${o} source = rc; if (source < start) { source = start * 2 - source - ${d}; @@ -18030,7 +18030,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,fJ=Oe({opSnippet:dJ}),pJ={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const _se=({inputs:t,backend:e,attrs:n})=>{const{x:s}=t,{paddings:r,mode:o}=n,i=W().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new Dse(s.shape,r,o):new Ase(s.shape,r,o);return e.runWebGLProgram(i,[s],s.dtype)},Fse={kernelName:jp,backendName:"webgl",kernelFunc:_se};/** + */const Dse=({inputs:t,backend:e,attrs:n})=>{const{x:s}=t,{paddings:r,mode:o}=n,i=W().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new Ase(s.shape,r,o):new Rse(s.shape,r,o);return e.runWebGLProgram(i,[s],s.dtype)},_se={kernelName:jp,backendName:"webgl",kernelFunc:Dse};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -18045,13 +18045,13 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,fJ=Oe({opSnippet:dJ}),pJ={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const zse=`if (b == 0.0) return NAN; - return mod(a, b);`,Ose=` + */const Fse=`if (b == 0.0) return NAN; + return mod(a, b);`,zse=` vec4 result = mod(a, b); bvec4 isNaN = equal(b, vec4(0.0)); `+na+` return result; -`,Mse=rn({opSnippet:zse,packedOpSnippet:Ose}),Pse={kernelName:Wu,backendName:"webgl",kernelFunc:Mse};/** +`,Ose=rn({opSnippet:Fse,packedOpSnippet:zse}),Mse={kernelName:Vu,backendName:"webgl",kernelFunc:Ose};/** * @license * Copyright 2017 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -18066,7 +18066,7 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,fJ=Oe({opSnippet:dJ}),pJ={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */class Lse{constructor(e,n,s){this.variableNames=["probs"],this.customUniforms=[{name:"seed",type:"float"}],this.outputShape=[e,s],this.userCode=` + */class Pse{constructor(e,n,s){this.variableNames=["probs"],this.customUniforms=[{name:"seed",type:"float"}],this.outputShape=[e,s],this.userCode=` void main() { ivec2 coords = getOutputCoords(); int batch = coords[0]; @@ -18101,11 +18101,11 @@ return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,fJ=Oe({opSnippet:dJ}),pJ={kernelNam * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const Bse=` + */const Lse=` if (a == b) { return 1.0; }; -return a / b;`,Vse=` +return a / b;`,Bse=` // vec4 one = vec4(equal(a, b)); // return one + (vec4(1.0) - one) * a / b; vec4 result = a / b; @@ -18123,7 +18123,7 @@ return a / b;`,Vse=` } return result; -`,ID=rn({opSnippet:Bse,packedOpSnippet:Vse,checkOutOfBounds:!0}),Wse={kernelName:$u,backendName:"webgl",kernelFunc:ID};/** +`,ID=rn({opSnippet:Lse,packedOpSnippet:Bse,checkOutOfBounds:!0}),Vse={kernelName:Iu,backendName:"webgl",kernelFunc:ID};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -18138,7 +18138,7 @@ return a / b;`,Vse=` * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const Hk="return a - b;",$D=rn({opSnippet:Hk,packedOpSnippet:Hk,supportsComplex:!0,cpuKernelImpl:zQ}),Use={kernelName:rh,backendName:"webgl",kernelFunc:$D};/** + */const Hk="return a - b;",$D=rn({opSnippet:Hk,packedOpSnippet:Hk,supportsComplex:!0,cpuKernelImpl:FQ}),Wse={kernelName:sh,backendName:"webgl",kernelFunc:$D};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -18153,7 +18153,7 @@ return a / b;`,Vse=` * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function ND(t){const{inputs:e,backend:n,attrs:s}=t,{logits:r}=e,{dim:o}=s,i=Re([o],r.shape),a=SD({inputs:{x:r},backend:n,attrs:{reductionIndices:i,keepDims:!1}}),l=Dt(a.shape,i),c=re({inputs:{x:a},backend:n,attrs:{shape:l}}),u=$D({inputs:{a:r,b:c},backend:n}),h=bD({inputs:{x:u},backend:n}),d=Bm({inputs:{x:h},backend:n,attrs:{axis:i,keepDims:!1}}),f=re({inputs:{x:d},backend:n,attrs:{shape:l}}),p=ID({inputs:{a:h,b:f},backend:n});return n.disposeIntermediateTensorInfo(a),n.disposeIntermediateTensorInfo(c),n.disposeIntermediateTensorInfo(u),n.disposeIntermediateTensorInfo(h),n.disposeIntermediateTensorInfo(d),n.disposeIntermediateTensorInfo(f),p}const Gse={kernelName:um,backendName:"webgl",kernelFunc:ND};/** + */function ND(t){const{inputs:e,backend:n,attrs:s}=t,{logits:r}=e,{dim:o}=s,i=Re([o],r.shape),a=SD({inputs:{x:r},backend:n,attrs:{reductionIndices:i,keepDims:!1}}),l=Dt(a.shape,i),c=re({inputs:{x:a},backend:n,attrs:{shape:l}}),u=$D({inputs:{a:r,b:c},backend:n}),h=bD({inputs:{x:u},backend:n}),d=Bm({inputs:{x:h},backend:n,attrs:{axis:i,keepDims:!1}}),f=re({inputs:{x:d},backend:n,attrs:{shape:l}}),p=ID({inputs:{a:h,b:f},backend:n});return n.disposeIntermediateTensorInfo(a),n.disposeIntermediateTensorInfo(c),n.disposeIntermediateTensorInfo(u),n.disposeIntermediateTensorInfo(h),n.disposeIntermediateTensorInfo(d),n.disposeIntermediateTensorInfo(f),p}const Use={kernelName:um,backendName:"webgl",kernelFunc:ND};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -18168,7 +18168,7 @@ return a / b;`,Vse=` * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function Hse(t){const{inputs:e,backend:n,attrs:s}=t,{logits:r}=e,{numSamples:o,seed:i,normalized:a}=s,l=a?r:ND({inputs:{logits:r},backend:n,attrs:{dim:r.shape.length-1}}),c=l.shape[0],u=l.shape[1],h=new Lse(c,u,o),d=[[i]],f=n.runWebGLProgram(h,[l],"int32",d);return a||n.disposeIntermediateTensorInfo(l),f}const jse={kernelName:r$,backendName:"webgl",kernelFunc:Hse};/** + */function Gse(t){const{inputs:e,backend:n,attrs:s}=t,{logits:r}=e,{numSamples:o,seed:i,normalized:a}=s,l=a?r:ND({inputs:{logits:r},backend:n,attrs:{dim:r.shape.length-1}}),c=l.shape[0],u=l.shape[1],h=new Pse(c,u,o),d=[[i]],f=n.runWebGLProgram(h,[l],"int32",d);return a||n.disposeIntermediateTensorInfo(l),f}const Hse={kernelName:r$,backendName:"webgl",kernelFunc:Gse};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -18183,9 +18183,9 @@ return a / b;`,Vse=` * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const Kse=_s+` + */const jse=_s+` return -x; -`,Xse=` +`,Kse=` vec4 result = -x; bvec4 isNaN = isnan(x); @@ -18195,7 +18195,7 @@ return a / b;`,Vse=` result.a = isNaN.a ? x.a : result.a; return result; -`;function qse(t){const{inputs:e,backend:n}=t,{x:s}=e;if(n.shouldExecuteOnCPU([s])){const o=n.texData.get(s.dataId),[i,a]=gQ(o.values,s.shape,s.dtype);return n.makeTensorInfo(a,s.dtype,i)}let r;return W().getBool("WEBGL_PACK_UNARY_OPERATIONS")?r=new po(s.shape,Xse):r=new pr(s.shape,Kse),n.runWebGLProgram(r,[s],s.dtype)}const Yse={kernelName:Kp,backendName:"webgl",kernelFunc:qse};/** +`;function Xse(t){const{inputs:e,backend:n}=t,{x:s}=e;if(n.shouldExecuteOnCPU([s])){const o=n.texData.get(s.dataId),[i,a]=mQ(o.values,s.shape,s.dtype);return n.makeTensorInfo(a,s.dtype,i)}let r;return W().getBool("WEBGL_PACK_UNARY_OPERATIONS")?r=new po(s.shape,Kse):r=new pr(s.shape,jse),n.runWebGLProgram(r,[s],s.dtype)}const qse={kernelName:Kp,backendName:"webgl",kernelFunc:Xse};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -18210,7 +18210,7 @@ return a / b;`,Vse=` * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const Qse=dw;function Zse(t){es("tf.nonMaxSuppression() in webgl locks the UI thread. Call tf.nonMaxSuppressionAsync() instead");const{inputs:e,backend:n,attrs:s}=t,{boxes:r,scores:o}=e,{maxOutputSize:i,iouThreshold:a,scoreThreshold:l}=s,c=n.readSync(r.dataId),u=n.readSync(o.dataId),{selectedIndices:h}=Qse(c,u,i,a,l);return n.makeTensorInfo([h.length],"int32",new Int32Array(h))}const Jse={kernelName:xy,backendName:"webgl",kernelFunc:Zse};/** + */const Yse=dw;function Qse(t){es("tf.nonMaxSuppression() in webgl locks the UI thread. Call tf.nonMaxSuppressionAsync() instead");const{inputs:e,backend:n,attrs:s}=t,{boxes:r,scores:o}=e,{maxOutputSize:i,iouThreshold:a,scoreThreshold:l}=s,c=n.readSync(r.dataId),u=n.readSync(o.dataId),{selectedIndices:h}=Yse(c,u,i,a,l);return n.makeTensorInfo([h.length],"int32",new Int32Array(h))}const Zse={kernelName:xy,backendName:"webgl",kernelFunc:Qse};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -18225,7 +18225,7 @@ return a / b;`,Vse=` * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const ere=fw;function tre(t){es("tf.nonMaxSuppression() in webgl locks the UI thread. Call tf.nonMaxSuppressionAsync() instead");const{inputs:e,backend:n,attrs:s}=t,{boxes:r,scores:o}=e,{maxOutputSize:i,iouThreshold:a,scoreThreshold:l,padToMaxOutputSize:c}=s,u=n.readSync(r.dataId),h=n.readSync(o.dataId),{selectedIndices:d,validOutputs:f}=ere(u,h,i,a,l,c);return[n.makeTensorInfo([d.length],"int32",new Int32Array(d)),n.makeTensorInfo([],"int32",new Int32Array([f]))]}const nre={kernelName:yy,backendName:"webgl",kernelFunc:tre};/** + */const Jse=fw;function ere(t){es("tf.nonMaxSuppression() in webgl locks the UI thread. Call tf.nonMaxSuppressionAsync() instead");const{inputs:e,backend:n,attrs:s}=t,{boxes:r,scores:o}=e,{maxOutputSize:i,iouThreshold:a,scoreThreshold:l,padToMaxOutputSize:c}=s,u=n.readSync(r.dataId),h=n.readSync(o.dataId),{selectedIndices:d,validOutputs:f}=Jse(u,h,i,a,l,c);return[n.makeTensorInfo([d.length],"int32",new Int32Array(d)),n.makeTensorInfo([],"int32",new Int32Array([f]))]}const tre={kernelName:yy,backendName:"webgl",kernelFunc:ere};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -18240,7 +18240,7 @@ return a / b;`,Vse=` * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const sre=pw;function rre(t){es("tf.nonMaxSuppression() in webgl locks the UI thread. Call tf.nonMaxSuppressionAsync() instead");const{inputs:e,backend:n,attrs:s}=t,{boxes:r,scores:o}=e,{maxOutputSize:i,iouThreshold:a,scoreThreshold:l,softNmsSigma:c}=s,u=n.readSync(r.dataId),h=n.readSync(o.dataId),d=i,f=a,p=l,g=c,{selectedIndices:x,selectedScores:m}=sre(u,h,d,f,p,g);return[n.makeTensorInfo([x.length],"int32",new Int32Array(x)),n.makeTensorInfo([m.length],"float32",new Float32Array(m))]}const ore={kernelName:wy,backendName:"webgl",kernelFunc:rre};/** + */const nre=pw;function sre(t){es("tf.nonMaxSuppression() in webgl locks the UI thread. Call tf.nonMaxSuppressionAsync() instead");const{inputs:e,backend:n,attrs:s}=t,{boxes:r,scores:o}=e,{maxOutputSize:i,iouThreshold:a,scoreThreshold:l,softNmsSigma:c}=s,u=n.readSync(r.dataId),h=n.readSync(o.dataId),d=i,f=a,p=l,g=c,{selectedIndices:x,selectedScores:m}=nre(u,h,d,f,p,g);return[n.makeTensorInfo([x.length],"int32",new Int32Array(x)),n.makeTensorInfo([m.length],"float32",new Float32Array(m))]}const rre={kernelName:wy,backendName:"webgl",kernelFunc:sre};/** * @license * Copyright 2017 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -18255,7 +18255,7 @@ return a / b;`,Vse=` * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */class ire{constructor(e,n,s,r){this.variableNames=["indices"],this.outputShape=[e,n],this.userCode=` + */class ore{constructor(e,n,s,r){this.variableNames=["indices"],this.outputShape=[e,n],this.userCode=` void main() { ivec2 coords = getOutputCoords(); int index = round(getIndices(coords.x)); @@ -18277,7 +18277,7 @@ return a / b;`,Vse=` * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const are=t=>{const{inputs:e,backend:n,attrs:s}=t,{indices:r}=e,{dtype:o,depth:i,onValue:a,offValue:l}=s,c=j(r.shape),u=new ire(c,i,a,l),h=re({inputs:{x:r},backend:n,attrs:{shape:[c]}}),d=n.runWebGLProgram(u,[h],o);n.disposeIntermediateTensorInfo(h);const f=[...r.shape,i],p=re({inputs:{x:d},backend:n,attrs:{shape:f}});return n.disposeIntermediateTensorInfo(d),p},lre={kernelName:Yp,backendName:"webgl",kernelFunc:are};/** + */const ire=t=>{const{inputs:e,backend:n,attrs:s}=t,{indices:r}=e,{dtype:o,depth:i,onValue:a,offValue:l}=s,c=j(r.shape),u=new ore(c,i,a,l),h=re({inputs:{x:r},backend:n,attrs:{shape:[c]}}),d=n.runWebGLProgram(u,[h],o);n.disposeIntermediateTensorInfo(h);const f=[...r.shape,i],p=re({inputs:{x:d},backend:n,attrs:{shape:f}});return n.disposeIntermediateTensorInfo(d),p},are={kernelName:Yp,backendName:"webgl",kernelFunc:ire};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -18292,7 +18292,7 @@ return a / b;`,Vse=` * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function Wf(t){const{inputs:e,backend:n}=t,{x:s}=e;if(s.dtype==="complex64"){const r=Ah({inputs:{input:s},backend:n}),o=Wf({inputs:{x:r},backend:n}),i=Vm({inputs:{input:s},backend:n}),a=Wf({inputs:{x:i},backend:n}),l=Qo({inputs:{real:o,imag:a},backend:n});return n.disposeIntermediateTensorInfo(r),n.disposeIntermediateTensorInfo(o),n.disposeIntermediateTensorInfo(i),n.disposeIntermediateTensorInfo(a),l}else return Dh({attrs:{shape:s.shape,dtype:s.dtype,value:s.dtype==="string"?"":0},backend:n})}const cre={kernelName:fm,backendName:"webgl",kernelFunc:Wf};/** + */function Vf(t){const{inputs:e,backend:n}=t,{x:s}=e;if(s.dtype==="complex64"){const r=Rh({inputs:{input:s},backend:n}),o=Vf({inputs:{x:r},backend:n}),i=Vm({inputs:{input:s},backend:n}),a=Vf({inputs:{x:i},backend:n}),l=Qo({inputs:{real:o,imag:a},backend:n});return n.disposeIntermediateTensorInfo(r),n.disposeIntermediateTensorInfo(o),n.disposeIntermediateTensorInfo(i),n.disposeIntermediateTensorInfo(a),l}else return Ah({attrs:{shape:s.shape,dtype:s.dtype,value:s.dtype==="string"?"":0},backend:n})}const lre={kernelName:fm,backendName:"webgl",kernelFunc:Vf};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -18307,7 +18307,7 @@ return a / b;`,Vse=` * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function TD(t){const{inputs:e,backend:n}=t,{x:s}=e;if(s.dtype==="string")throw new Error("onesLike is not supported under string dtype");if(s.dtype==="complex64"){const r=Ah({inputs:{input:s},backend:n}),o=TD({inputs:{x:r},backend:n}),i=Vm({inputs:{input:s},backend:n}),a=Wf({inputs:{x:i},backend:n}),l=Qo({inputs:{real:o,imag:a},backend:n});return n.disposeIntermediateTensorInfo(r),n.disposeIntermediateTensorInfo(o),n.disposeIntermediateTensorInfo(i),n.disposeIntermediateTensorInfo(a),l}else return Dh({attrs:{shape:s.shape,dtype:s.dtype,value:1},backend:n})}const ure={kernelName:qp,backendName:"webgl",kernelFunc:TD};/** + */function TD(t){const{inputs:e,backend:n}=t,{x:s}=e;if(s.dtype==="string")throw new Error("onesLike is not supported under string dtype");if(s.dtype==="complex64"){const r=Rh({inputs:{input:s},backend:n}),o=TD({inputs:{x:r},backend:n}),i=Vm({inputs:{input:s},backend:n}),a=Vf({inputs:{x:i},backend:n}),l=Qo({inputs:{real:o,imag:a},backend:n});return n.disposeIntermediateTensorInfo(r),n.disposeIntermediateTensorInfo(o),n.disposeIntermediateTensorInfo(i),n.disposeIntermediateTensorInfo(a),l}else return Ah({attrs:{shape:s.shape,dtype:s.dtype,value:1},backend:n})}const cre={kernelName:qp,backendName:"webgl",kernelFunc:TD};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -18322,7 +18322,7 @@ return a / b;`,Vse=` * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function hre(t){const{inputs:e,backend:n,attrs:s}=t,{axis:r}=s;if(e.length===1)return R1({inputs:{input:e[0]},backend:n,attrs:{dim:r}});const o=e[0].shape,i=e[0].dtype;e.forEach(u=>{Lx(o,u.shape,"All tensors passed to stack must have matching shapes"),I(i===u.dtype,()=>"All tensors passed to stack must have matching dtypes")});const a=[],l=e.map(u=>{const h=R1({inputs:{input:u},backend:n,attrs:{dim:r}});return a.push(h),h}),c=fD({inputs:l,backend:n,attrs:{axis:r}});return a.forEach(u=>n.disposeIntermediateTensorInfo(u)),c}const dre={kernelName:Qp,backendName:"webgl",kernelFunc:hre};/** + */function ure(t){const{inputs:e,backend:n,attrs:s}=t,{axis:r}=s;if(e.length===1)return R1({inputs:{input:e[0]},backend:n,attrs:{dim:r}});const o=e[0].shape,i=e[0].dtype;e.forEach(u=>{Lx(o,u.shape,"All tensors passed to stack must have matching shapes"),I(i===u.dtype,()=>"All tensors passed to stack must have matching dtypes")});const a=[],l=e.map(u=>{const h=R1({inputs:{input:u},backend:n,attrs:{dim:r}});return a.push(h),h}),c=fD({inputs:l,backend:n,attrs:{axis:r}});return a.forEach(u=>n.disposeIntermediateTensorInfo(u)),c}const hre={kernelName:Qp,backendName:"webgl",kernelFunc:ure};/** * @license * Copyright 2017 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -18337,7 +18337,7 @@ return a / b;`,Vse=` * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */class fre{constructor(e,n,s){this.variableNames=["x"],this.customUniforms=[{name:"value",type:"float"}],this.outputShape=n.map((c,u)=>c[0]+e[u]+c[1]);const r=e.length,o=Ze(r),i=n.map(c=>c[0]).join(","),a=n.map((c,u)=>c[0]+e[u]).join(","),l=["coords[0]","coords[1]","coords[2]","coords[3]"].slice(0,r);if(r===1){this.userCode=` + */class dre{constructor(e,n,s){this.variableNames=["x"],this.customUniforms=[{name:"value",type:"float"}],this.outputShape=n.map((c,u)=>c[0]+e[u]+c[1]);const r=e.length,o=Ze(r),i=n.map(c=>c[0]).join(","),a=n.map((c,u)=>c[0]+e[u]).join(","),l=["coords[0]","coords[1]","coords[2]","coords[3]"].slice(0,r);if(r===1){this.userCode=` int start = ${i}; int end = ${a}; @@ -18377,7 +18377,7 @@ return a / b;`,Vse=` * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */class pre{constructor(e,n,s){this.variableNames=["x"],this.packedInputs=!0,this.packedOutput=!0,this.customUniforms=[{name:"value",type:"float"}],this.outputShape=n.map((g,x)=>g[0]+e[x]+g[1]);const r=e.length,o=Ze(r),i=n.map(g=>g[0]).join(","),a=n.map((g,x)=>g[0]+e[x]).join(","),l=vn("rc",r),c=vn("source",r),u=`${l[r-1]} < ${this.outputShape[r-1]}`,h=r===1?"source":`vec2(${c.slice(-2).join()})`,d=[`${o} rc = outputLoc;`,`${l[r-1]} += 1; + */class fre{constructor(e,n,s){this.variableNames=["x"],this.packedInputs=!0,this.packedOutput=!0,this.customUniforms=[{name:"value",type:"float"}],this.outputShape=n.map((g,x)=>g[0]+e[x]+g[1]);const r=e.length,o=Ze(r),i=n.map(g=>g[0]).join(","),a=n.map((g,x)=>g[0]+e[x]).join(","),l=vn("rc",r),c=vn("source",r),u=`${l[r-1]} < ${this.outputShape[r-1]}`,h=r===1?"source":`vec2(${c.slice(-2).join()})`,d=[`${o} rc = outputLoc;`,`${l[r-1]} += 1; if(${u}) { `,r===1?"":`} rc = outputLoc; @@ -18416,7 +18416,7 @@ return a / b;`,Vse=` * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const ED=t=>{const{inputs:e,backend:n,attrs:s}=t,{x:r}=e,{paddings:o,constantValue:i}=s;if(j(r.shape)===0){const c=o.map((u,h)=>u[0]+r.shape[h]+u[1]);return Dh({backend:n,attrs:{shape:c,value:i,dtype:r.dtype}})}const a=W().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new pre(r.shape,o,i):new fre(r.shape,o,i),l=[[i]];return n.runWebGLProgram(a,[r],r.dtype,l)},mre={kernelName:Zp,backendName:"webgl",kernelFunc:ED};/** + */const ED=t=>{const{inputs:e,backend:n,attrs:s}=t,{x:r}=e,{paddings:o,constantValue:i}=s;if(j(r.shape)===0){const c=o.map((u,h)=>u[0]+r.shape[h]+u[1]);return Ah({backend:n,attrs:{shape:c,value:i,dtype:r.dtype}})}const a=W().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new fre(r.shape,o,i):new dre(r.shape,o,i),l=[[i]];return n.runWebGLProgram(a,[r],r.dtype,l)},pre={kernelName:Zp,backendName:"webgl",kernelFunc:ED};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -18431,7 +18431,7 @@ return a / b;`,Vse=` * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const gre=` + */const mre=` if(a < 0.0 && floor(b) < b){ return NAN; } @@ -18440,7 +18440,7 @@ return a / b;`,Vse=` } return (round(mod(b, 2.0)) != 1) ? pow(abs(a), b) : sign(a) * pow(abs(a), b); -`,xre=` +`,gre=` // isModRound1 has 1 for components with round(mod(b, 2.0)) == 1, 0 otherwise. vec4 isModRound1 = vec4(equal(round(mod(b, 2.0)), ivec4(1))); vec4 multiplier = sign(a) * isModRound1 + (vec4(1.0) - isModRound1); @@ -18458,7 +18458,7 @@ return a / b;`,Vse=` bvec4 isNaN = bvec4(isNaN1.x && isNaN2.x, isNaN1.y && isNaN2.y, isNaN1.z && isNaN2.z, isNaN1.w && isNaN2.w); `+na+` return result; -`,yre=rn({opSnippet:gre,packedOpSnippet:xre}),wre={kernelName:Gu,backendName:"webgl",kernelFunc:yre};/** +`,xre=rn({opSnippet:mre,packedOpSnippet:gre}),yre={kernelName:Uu,backendName:"webgl",kernelFunc:xre};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -18473,7 +18473,7 @@ return a / b;`,Vse=` * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function vre(t){const{inputs:e,backend:n,attrs:s}=t,{x:r}=e,{axis:o,keepDims:i}=s,a=r.shape.length,l=[],c=Re(o,r.shape);let u=c;const h=yt(u,a);let d=r;h!=null&&(d=Sn({inputs:{x:r},backend:n,attrs:{perm:h}}),u=$t(u.length,a),l.push(d)),sn("prod",u,a);let f;if(n.shouldExecuteOnCPU([d])){const p=n.texData.get(d.dataId).values,{outVals:g,outShape:x,outDtype:m}=yQ(d.shape,d.dtype,p,u);f=n.makeTensorInfo(x,m,g)}else{const[p,g]=Yt(d.shape,u),x=j(g),m=re({inputs:{x:d},backend:n,attrs:{shape:[-1,x]}}),y=Dy(r.dtype),w=sa(m,y,"prod",n);f=re({inputs:{x:w},backend:n,attrs:{shape:p}}),l.push(m),l.push(w)}if(i){l.push(f);const p=Dt(f.shape,c);f=re({inputs:{x:f},backend:n,attrs:{shape:p}})}return l.forEach(p=>n.disposeIntermediateTensorInfo(p)),f}const bre={kernelName:em,backendName:"webgl",kernelFunc:vre};/** + */function wre(t){const{inputs:e,backend:n,attrs:s}=t,{x:r}=e,{axis:o,keepDims:i}=s,a=r.shape.length,l=[],c=Re(o,r.shape);let u=c;const h=yt(u,a);let d=r;h!=null&&(d=Sn({inputs:{x:r},backend:n,attrs:{perm:h}}),u=$t(u.length,a),l.push(d)),sn("prod",u,a);let f;if(n.shouldExecuteOnCPU([d])){const p=n.texData.get(d.dataId).values,{outVals:g,outShape:x,outDtype:m}=xQ(d.shape,d.dtype,p,u);f=n.makeTensorInfo(x,m,g)}else{const[p,g]=Yt(d.shape,u),x=j(g),m=re({inputs:{x:d},backend:n,attrs:{shape:[-1,x]}}),y=Dy(r.dtype),w=sa(m,y,"prod",n);f=re({inputs:{x:w},backend:n,attrs:{shape:p}}),l.push(m),l.push(w)}if(i){l.push(f);const p=Dt(f.shape,c);f=re({inputs:{x:f},backend:n,attrs:{shape:p}})}return l.forEach(p=>n.disposeIntermediateTensorInfo(p)),f}const vre={kernelName:em,backendName:"webgl",kernelFunc:wre};/** * @license * Copyright 2022 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -18488,7 +18488,7 @@ return a / b;`,Vse=` * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function Cre(t){const{inputs:e,backend:n,attrs:s}=t,{paramsNestedSplits:r,paramsDenseValues:o,indices:i}=e,{outputRaggedRank:a}=s,l=r.map(m=>n.readSync(m.dataId)),c=r.map(m=>m.shape),u=n.readSync(o.dataId),h=n.readSync(i.dataId),[d,f,p]=wQ(l,c,u,o.shape,o.dtype,h,i.shape,a),g=d.map(m=>n.makeTensorInfo([m.length],"int32",m)),x=n.makeTensorInfo(p,o.dtype,f);return g.concat([x])}const kre={kernelName:o$,backendName:"webgl",kernelFunc:Cre};/** + */function bre(t){const{inputs:e,backend:n,attrs:s}=t,{paramsNestedSplits:r,paramsDenseValues:o,indices:i}=e,{outputRaggedRank:a}=s,l=r.map(m=>n.readSync(m.dataId)),c=r.map(m=>m.shape),u=n.readSync(o.dataId),h=n.readSync(i.dataId),[d,f,p]=yQ(l,c,u,o.shape,o.dtype,h,i.shape,a),g=d.map(m=>n.makeTensorInfo([m.length],"int32",m)),x=n.makeTensorInfo(p,o.dtype,f);return g.concat([x])}const Cre={kernelName:o$,backendName:"webgl",kernelFunc:bre};/** * @license * Copyright 2022 Google LLC. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -18503,7 +18503,7 @@ return a / b;`,Vse=` * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function Sre(t){const{inputs:e,backend:n}=t,{starts:s,limits:r,deltas:o}=e,i=n.readSync(s.dataId),a=n.readSync(r.dataId),l=n.readSync(o.dataId),[c,u]=vQ(i,s.shape,s.dtype,a,r.shape,l,o.shape),h=n.makeTensorInfo([c.length],"int32",c),d=n.makeTensorInfo([u.length],s.dtype,u);return[h,d]}const Ire={kernelName:i$,backendName:"webgl",kernelFunc:Sre};/** + */function kre(t){const{inputs:e,backend:n}=t,{starts:s,limits:r,deltas:o}=e,i=n.readSync(s.dataId),a=n.readSync(r.dataId),l=n.readSync(o.dataId),[c,u]=wQ(i,s.shape,s.dtype,a,r.shape,l,o.shape),h=n.makeTensorInfo([c.length],"int32",c),d=n.makeTensorInfo([u.length],s.dtype,u);return[h,d]}const Sre={kernelName:i$,backendName:"webgl",kernelFunc:kre};/** * @license * Copyright 2022 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -18518,7 +18518,7 @@ return a / b;`,Vse=` * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function $re(t){const{inputs:e,backend:n,attrs:s}=t,{shape:r,values:o,defaultValue:i,rowPartitionTensors:a}=e,{rowPartitionTypes:l}=s,c=n.readSync(r.dataId),u=n.readSync(o.dataId),h=n.readSync(i.dataId),d=a.map(x=>n.readSync(x.dataId)),f=a.map(x=>x.shape),[p,g]=bQ(c,r.shape,u,o.shape,o.dtype,h,i.shape,d,f,l);return n.makeTensorInfo(p,o.dtype,g)}const Nre={kernelName:a$,backendName:"webgl",kernelFunc:$re};/** + */function Ire(t){const{inputs:e,backend:n,attrs:s}=t,{shape:r,values:o,defaultValue:i,rowPartitionTensors:a}=e,{rowPartitionTypes:l}=s,c=n.readSync(r.dataId),u=n.readSync(o.dataId),h=n.readSync(i.dataId),d=a.map(x=>n.readSync(x.dataId)),f=a.map(x=>x.shape),[p,g]=vQ(c,r.shape,u,o.shape,o.dtype,h,i.shape,d,f,l);return n.makeTensorInfo(p,o.dtype,g)}const $re={kernelName:a$,backendName:"webgl",kernelFunc:Ire};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -18533,7 +18533,7 @@ return a / b;`,Vse=` * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const RD=t=>{const{backend:e,attrs:n}=t,{start:s,stop:r,step:o,dtype:i}=n,a=CQ(s,r,o,i);return e.makeTensorInfo([a.length],i,a)},Tre={kernelName:vy,backendName:"webgl",kernelFunc:RD};/** + */const RD=t=>{const{backend:e,attrs:n}=t,{start:s,stop:r,step:o,dtype:i}=n,a=bQ(s,r,o,i);return e.makeTensorInfo([a.length],i,a)},Nre={kernelName:vy,backendName:"webgl",kernelFunc:RD};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -18548,7 +18548,7 @@ return a / b;`,Vse=` * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const Ere="return 1.0 / x;",Rre=Oe({opSnippet:Ere}),Are={kernelName:Hu,backendName:"webgl",kernelFunc:Rre};/** + */const Tre="return 1.0 / x;",Ere=Oe({opSnippet:Tre}),Rre={kernelName:Gu,backendName:"webgl",kernelFunc:Ere};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -18563,9 +18563,9 @@ return a / b;`,Vse=` * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const Dre=_s+` + */const Are=_s+` return (x < 0.0) ? 0.0 : x; -`,_re=` +`,Dre=` vec4 result = x * vec4(greaterThanEqual(x, vec4(0.0))); bvec4 isNaN = isnan(x); @@ -18575,7 +18575,7 @@ return a / b;`,Vse=` result.a = isNaN.a ? x.a : result.a; return result; -`,Fre=Oe({opSnippet:Dre,packedOpSnippet:_re}),zre={kernelName:ju,backendName:"webgl",kernelFunc:Fre};/** +`,_re=Oe({opSnippet:Are,packedOpSnippet:Dre}),Fre={kernelName:Hu,backendName:"webgl",kernelFunc:_re};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -18590,9 +18590,9 @@ return a / b;`,Vse=` * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const Ore=_s+` + */const zre=_s+` return (x < 0.0) ? 0.0 : min(6.0, x); -`,Mre=` +`,Ore=` vec4 result = min(x, vec4(6.)) * vec4(greaterThanEqual(x, vec4(0.0))); bvec4 isNaN = isnan(x); @@ -18602,7 +18602,7 @@ return a / b;`,Vse=` result.a = isNaN.a ? x.a : result.a; return result; -`,Pre=Oe({opSnippet:Ore,packedOpSnippet:Mre}),Lre={kernelName:Ku,backendName:"webgl",kernelFunc:Pre};/** +`,Mre=Oe({opSnippet:zre,packedOpSnippet:Ore}),Pre={kernelName:ju,backendName:"webgl",kernelFunc:Mre};/** * @license * Copyright 2017 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -18617,7 +18617,7 @@ return a / b;`,Vse=` * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */class Bre{constructor(e,n,s,r,o){this.variableNames=["A"],this.outputShape=[];const[i,a,l,c]=e;this.outputShape=[i,n,s,c];const u=[r&&n>1?a-1:a,r&&s>1?l-1:l],h=[r&&n>1?n-1:n,r&&s>1?s-1:s];let d;o?d="(vec2(yRC) + vec2(0.5)) * effectiveInputOverOutputRatioRC - vec2(0.5)":d="vec2(yRC) * effectiveInputOverOutputRatioRC",this.userCode=` + */class Lre{constructor(e,n,s,r,o){this.variableNames=["A"],this.outputShape=[];const[i,a,l,c]=e;this.outputShape=[i,n,s,c];const u=[r&&n>1?a-1:a,r&&s>1?l-1:l],h=[r&&n>1?n-1:n,r&&s>1?s-1:s];let d;o?d="(vec2(yRC) + vec2(0.5)) * effectiveInputOverOutputRatioRC - vec2(0.5)":d="vec2(yRC) * effectiveInputOverOutputRatioRC",this.userCode=` const vec2 effectiveInputOverOutputRatioRC = vec2( ${u[0]/h[0]}, ${u[1]/h[1]}); @@ -18665,7 +18665,7 @@ return a / b;`,Vse=` * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */class Vre{constructor(e,n,s,r,o){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=[];const[i,a,l,c]=e;this.outputShape=[i,n,s,c];const u=[r&&n>1?a-1:a,r&&s>1?l-1:l],h=[r&&n>1?n-1:n,r&&s>1?s-1:s];let d;o?d="(vec3(yRC) + vec3(0.5)) * effectiveInputOverOutputRatioRC - vec3(0.5)":d="vec3(yRC) * effectiveInputOverOutputRatioRC",this.userCode=` + */class Bre{constructor(e,n,s,r,o){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=[];const[i,a,l,c]=e;this.outputShape=[i,n,s,c];const u=[r&&n>1?a-1:a,r&&s>1?l-1:l],h=[r&&n>1?n-1:n,r&&s>1?s-1:s];let d;o?d="(vec3(yRC) + vec3(0.5)) * effectiveInputOverOutputRatioRC - vec3(0.5)":d="vec3(yRC) * effectiveInputOverOutputRatioRC",this.userCode=` const vec3 effectiveInputOverOutputRatioRC = vec3( ${u[0]/h[0]}, ${u[1]/h[1]}, @@ -18757,7 +18757,7 @@ return a / b;`,Vse=` * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function Wre(t){const{inputs:e,backend:n,attrs:s}=t,{images:r}=e,{alignCorners:o,halfPixelCenters:i,size:a}=s,[l,c]=a,u=W().getBool("WEBGL_PACK_IMAGE_OPERATIONS")?new Vre(r.shape,l,c,o,i):new Bre(r.shape,l,c,o,i);return n.runWebGLProgram(u,[r],"float32")}const Ure={kernelName:sm,backendName:"webgl",kernelFunc:Wre};/** + */function Vre(t){const{inputs:e,backend:n,attrs:s}=t,{images:r}=e,{alignCorners:o,halfPixelCenters:i,size:a}=s,[l,c]=a,u=W().getBool("WEBGL_PACK_IMAGE_OPERATIONS")?new Bre(r.shape,l,c,o,i):new Lre(r.shape,l,c,o,i);return n.runWebGLProgram(u,[r],"float32")}const Wre={kernelName:sm,backendName:"webgl",kernelFunc:Vre};/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -18772,7 +18772,7 @@ return a / b;`,Vse=` * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */class Gre{constructor(e,n,s){this.variableNames=["dy"],this.outputShape=[],this.outputShape=n;const[,r,o]=n,[,i,a]=e,l=[s&&i>1?r-1:r,s&&a>1?o-1:o],c=[s&&i>1?i-1:i,s&&a>1?a-1:a],u=l[0]/c[0],h=l[1]/c[1],d=1/u,f=1/h,p=Math.ceil(d)*2+2,g=Math.ceil(f)*2+2;this.userCode=` + */class Ure{constructor(e,n,s){this.variableNames=["dy"],this.outputShape=[],this.outputShape=n;const[,r,o]=n,[,i,a]=e,l=[s&&i>1?r-1:r,s&&a>1?o-1:o],c=[s&&i>1?i-1:i,s&&a>1?a-1:a],u=l[0]/c[0],h=l[1]/c[1],d=1/u,f=1/h,p=Math.ceil(d)*2+2,g=Math.ceil(f)*2+2;this.userCode=` void main() { ivec4 coords = getOutputCoords(); int b = coords[0]; @@ -18868,7 +18868,7 @@ return a / b;`,Vse=` * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function Hre(t){const{inputs:e,backend:n,attrs:s}=t,{images:r,dy:o}=e,{alignCorners:i}=s,a=new Gre(o.shape,r.shape,i);return n.runWebGLProgram(a,[o],o.dtype)}const jre={kernelName:ky,backendName:"webgl",kernelFunc:Hre};/** + */function Gre(t){const{inputs:e,backend:n,attrs:s}=t,{images:r,dy:o}=e,{alignCorners:i}=s,a=new Ure(o.shape,r.shape,i);return n.runWebGLProgram(a,[o],o.dtype)}const Hre={kernelName:ky,backendName:"webgl",kernelFunc:Gre};/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -18883,7 +18883,7 @@ return a / b;`,Vse=` * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */class Kre{constructor(e,n,s,r,o){this.variableNames=["A"],this.outputShape=[];const[i,a,l,c]=e;this.outputShape=[i,n,s,c];const u=[r&&n>1?a-1:a,r&&s>1?l-1:l],h=[r&&n>1?n-1:n,r&&s>1?s-1:s],d=r?"0.5":"0.0";let f;o?f="max((vec2(yRC) + vec2(0.5)) * effectiveInputOverOutputRatioRC, vec2(0.0))":f="vec2(yRC) * effectiveInputOverOutputRatioRC",this.userCode=` + */class jre{constructor(e,n,s,r,o){this.variableNames=["A"],this.outputShape=[];const[i,a,l,c]=e;this.outputShape=[i,n,s,c];const u=[r&&n>1?a-1:a,r&&s>1?l-1:l],h=[r&&n>1?n-1:n,r&&s>1?s-1:s],d=r?"0.5":"0.0";let f;o?f="max((vec2(yRC) + vec2(0.5)) * effectiveInputOverOutputRatioRC, vec2(0.0))":f="vec2(yRC) * effectiveInputOverOutputRatioRC",this.userCode=` const vec2 effectiveInputOverOutputRatioRC = vec2( ${u[0]/h[0]}, ${u[1]/h[1]}); @@ -18920,7 +18920,7 @@ return a / b;`,Vse=` * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */class Xre{constructor(e,n,s,r,o){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=[];const[i,a,l,c]=e;this.outputShape=[i,n,s,c];const u=[r&&n>1?a-1:a,r&&s>1?l-1:l],h=[r&&n>1?n-1:n,r&&s>1?s-1:s],d=r?"0.5":"0.0";let f;o?f="max((vec3(yRC) + vec3(0.5)) * effectiveInputOverOutputRatioRC, vec3(0.0))":f="vec3(yRC) * effectiveInputOverOutputRatioRC",this.userCode=` + */class Kre{constructor(e,n,s,r,o){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=[];const[i,a,l,c]=e;this.outputShape=[i,n,s,c];const u=[r&&n>1?a-1:a,r&&s>1?l-1:l],h=[r&&n>1?n-1:n,r&&s>1?s-1:s],d=r?"0.5":"0.0";let f;o?f="max((vec3(yRC) + vec3(0.5)) * effectiveInputOverOutputRatioRC, vec3(0.0))":f="vec3(yRC) * effectiveInputOverOutputRatioRC",this.userCode=` const vec3 effectiveInputOverOutputRatioRC = vec3( ${u[0]/h[0]}, ${u[1]/h[1]}, @@ -18976,7 +18976,7 @@ return a / b;`,Vse=` * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function qre(t){const{inputs:e,backend:n,attrs:s}=t,{images:r}=e,{alignCorners:o,halfPixelCenters:i,size:a}=s,[l,c]=a,u=W().getBool("WEBGL_PACK_IMAGE_OPERATIONS")?new Xre(r.shape,l,c,o,i):new Kre(r.shape,l,c,o,i);return n.runWebGLProgram(u,[r],r.dtype)}const Yre={kernelName:nm,backendName:"webgl",kernelFunc:qre};/** + */function Xre(t){const{inputs:e,backend:n,attrs:s}=t,{images:r}=e,{alignCorners:o,halfPixelCenters:i,size:a}=s,[l,c]=a,u=W().getBool("WEBGL_PACK_IMAGE_OPERATIONS")?new Kre(r.shape,l,c,o,i):new jre(r.shape,l,c,o,i);return n.runWebGLProgram(u,[r],r.dtype)}const qre={kernelName:nm,backendName:"webgl",kernelFunc:Xre};/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -18991,7 +18991,7 @@ return a / b;`,Vse=` * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */class Qre{constructor(e,n,s){this.variableNames=["dy"],this.outputShape=[],this.outputShape=n;const[,r,o]=n,[,i,a]=e,l=[s&&i>1?r-1:r,s&&a>1?o-1:o],c=[s&&i>1?i-1:i,s&&a>1?a-1:a],u=l[0]/c[0],h=l[1]/c[1],d=1/u,f=1/h,p=Math.ceil(d)*2+2,g=Math.ceil(f)*2+2;this.userCode=` + */class Yre{constructor(e,n,s){this.variableNames=["dy"],this.outputShape=[],this.outputShape=n;const[,r,o]=n,[,i,a]=e,l=[s&&i>1?r-1:r,s&&a>1?o-1:o],c=[s&&i>1?i-1:i,s&&a>1?a-1:a],u=l[0]/c[0],h=l[1]/c[1],d=1/u,f=1/h,p=Math.ceil(d)*2+2,g=Math.ceil(f)*2+2;this.userCode=` void main() { ivec4 coords = getOutputCoords(); int b = coords[0]; @@ -19076,7 +19076,7 @@ return a / b;`,Vse=` * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function Zre(t){const{inputs:e,backend:n,attrs:s}=t,{images:r,dy:o}=e,{alignCorners:i}=s,a=new Qre(o.shape,r.shape,i);return n.runWebGLProgram(a,[o],o.dtype)}const Jre={kernelName:Cy,backendName:"webgl",kernelFunc:Zre};/** + */function Qre(t){const{inputs:e,backend:n,attrs:s}=t,{images:r,dy:o}=e,{alignCorners:i}=s,a=new Yre(o.shape,r.shape,i);return n.runWebGLProgram(a,[o],o.dtype)}const Zre={kernelName:Cy,backendName:"webgl",kernelFunc:Qre};/** * @license * Copyright 2017 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -19091,7 +19091,7 @@ return a / b;`,Vse=` * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */class eoe{constructor(e,n){this.variableNames=["x"];const s=e.length;if(s>4)throw new Error(`WebGL backend: Reverse of rank-${s} tensor is not yet supported`);if(this.outputShape=e,s===1){this.userCode=` + */class Jre{constructor(e,n){this.variableNames=["x"];const s=e.length;if(s>4)throw new Error(`WebGL backend: Reverse of rank-${s} tensor is not yet supported`);if(this.outputShape=e,s===1){this.userCode=` void main() { int coord = getOutputCoords(); setOutput(getX(${e[0]} - coord - 1)); @@ -19116,7 +19116,7 @@ return a / b;`,Vse=` * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */class toe{constructor(e,n){this.variableNames=["x"],this.packedInputs=!0,this.packedOutput=!0;const s=e.length;if(s>4)throw new Error(`WebGL backend: Reverse of rank-${s} tensor is not yet supported`);this.outputShape=e;const r=vn("rc",s),o=`${r[s-1]} + 1 < ${this.outputShape[s-1]}`,i=`${r[s-2]} + 1 < ${this.outputShape[s-2]}`,a=Ze(s);s===1?this.userCode=` + */class eoe{constructor(e,n){this.variableNames=["x"],this.packedInputs=!0,this.packedOutput=!0;const s=e.length;if(s>4)throw new Error(`WebGL backend: Reverse of rank-${s} tensor is not yet supported`);this.outputShape=e;const r=vn("rc",s),o=`${r[s-1]} + 1 < ${this.outputShape[s-1]}`,i=`${r[s-2]} + 1 < ${this.outputShape[s-2]}`,a=Ze(s);s===1?this.userCode=` void main(){ int rc = getOutputCoords(); vec4 result = vec4(0.); @@ -19159,7 +19159,7 @@ return a / b;`,Vse=` * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function noe(t){const{inputs:e,backend:n,attrs:s}=t,{x:r}=e,{dims:o}=s,i=r.shape.length,a=Re(o,r.shape);if(i===0)return Yn({inputs:{x:r},backend:n});const l=W().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new toe(r.shape,a):new eoe(r.shape,a);return n.runWebGLProgram(l,[r],r.dtype)}const soe={kernelName:rm,backendName:"webgl",kernelFunc:noe};/** + */function toe(t){const{inputs:e,backend:n,attrs:s}=t,{x:r}=e,{dims:o}=s,i=r.shape.length,a=Re(o,r.shape);if(i===0)return Yn({inputs:{x:r},backend:n});const l=W().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new eoe(r.shape,a):new Jre(r.shape,a);return n.runWebGLProgram(l,[r],r.dtype)}const noe={kernelName:rm,backendName:"webgl",kernelFunc:toe};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -19174,7 +19174,7 @@ return a / b;`,Vse=` * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */class roe{constructor(e,n){this.variableNames=["Image"],this.outputShape=[],this.customUniforms=[{name:"params",type:"vec4"}];const s=e[1],r=e[2];this.outputShape=e;let o="";typeof n=="number"?o=`float outputValue = ${n.toFixed(2)};`:o=` + */class soe{constructor(e,n){this.variableNames=["Image"],this.outputShape=[],this.customUniforms=[{name:"params",type:"vec4"}];const s=e[1],r=e[2];this.outputShape=e;let o="";typeof n=="number"?o=`float outputValue = ${n.toFixed(2)};`:o=` vec3 fill = vec3(${n.join(",")}); float outputValue = fill[coords[3]];`,this.userCode=` void main() { @@ -19208,7 +19208,7 @@ return a / b;`,Vse=` * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const ooe={kernelName:Ry,backendName:"webgl",kernelFunc:({inputs:t,attrs:e,backend:n})=>{const{image:s}=t,{radians:r,fillValue:o,center:i}=e,a=n,l=new roe(s.shape,o),[c,u]=$w(i,s.shape[1],s.shape[2]),h=[[c,u,Math.sin(r),Math.cos(r)]];return a.runWebGLProgram(l,[s],s.dtype,h)}};/** + */const roe={kernelName:Ry,backendName:"webgl",kernelFunc:({inputs:t,attrs:e,backend:n})=>{const{image:s}=t,{radians:r,fillValue:o,center:i}=e,a=n,l=new soe(s.shape,o),[c,u]=$w(i,s.shape[1],s.shape[2]),h=[[c,u,Math.sin(r),Math.cos(r)]];return a.runWebGLProgram(l,[s],s.dtype,h)}};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -19223,7 +19223,7 @@ return a / b;`,Vse=` * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const ioe=` + */const ooe=` // OpenGL ES does not support round function. // The algorithm is based on banker's rounding. float base = floor(x); @@ -19238,7 +19238,7 @@ return a / b;`,Vse=` return base + 1.0; } } -`,aoe=Oe({opSnippet:ioe}),loe={kernelName:Xu,backendName:"webgl",kernelFunc:aoe};/** +`,ioe=Oe({opSnippet:ooe}),aoe={kernelName:Ku,backendName:"webgl",kernelFunc:ioe};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -19253,7 +19253,7 @@ return a / b;`,Vse=` * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const coe="return inversesqrt(x);",uoe=Oe({opSnippet:coe,cpuKernelImpl:kQ}),hoe={kernelName:qu,backendName:"webgl",kernelFunc:uoe};/** + */const loe="return inversesqrt(x);",coe=Oe({opSnippet:loe,cpuKernelImpl:CQ}),uoe={kernelName:Xu,backendName:"webgl",kernelFunc:coe};/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -19303,7 +19303,7 @@ return a / b;`,Vse=` * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */class doe{constructor(e,n,s,r,o,i,a=!0,l=!1){this.variableNames=["updates","indices","defaultValue"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=i;const c=Ze(o.length),u=Ze(i.length);let h="";s===1?h="i":s===2&&(h="i, j");const d=`getIndices(${h})`;let f="";r===1?f="i":r===2&&(f="i, coords[1]");const p=`getUpdates(${f})`;let g="";l&&(g="coords[0], coords[1]");const x=`getDefaultValue(${g})`,m=n>1?"strides[j]":"strides",y=n>1?"strides[j + 1]":"strides";this.userCode=` + */class hoe{constructor(e,n,s,r,o,i,a=!0,l=!1){this.variableNames=["updates","indices","defaultValue"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=i;const c=Ze(o.length),u=Ze(i.length);let h="";s===1?h="i":s===2&&(h="i, j");const d=`getIndices(${h})`;let f="";r===1?f="i":r===2&&(f="i, coords[1]");const p=`getUpdates(${f})`;let g="";l&&(g="coords[0], coords[1]");const x=`getDefaultValue(${g})`,m=n>1?"strides[j]":"strides",y=n>1?"strides[j + 1]":"strides";this.userCode=` ${c} strides = ${c}(${o}); void main() { @@ -19355,7 +19355,7 @@ return a / b;`,Vse=` * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function foe(t){const{inputs:e,backend:n,attrs:s}=t,{indices:r,updates:o}=e,{shape:i}=s,{sliceRank:a,numUpdates:l,sliceSize:c,strides:u,outputSize:h}=Qi(o,r,i),d=[h/c,c];if(h===0)return n.makeTensorInfo(i,r.dtype);const f=re({inputs:{x:r},backend:n,attrs:{shape:[l,a]}}),p=re({inputs:{x:o},backend:n,attrs:{shape:[l,c]}}),g=n.makeTensorInfo([],"float32",new Float32Array([0]));let x;W().getBool("WEBGL_PACK")?x=new doe(l,a,f.shape.length,p.shape.length,u,d):x=new Tv(l,a,f.shape.length,p.shape.length,u,d);const m=n.runWebGLProgram(x,[p,f,g],p.dtype),y=re({inputs:{x:m},backend:n,attrs:{shape:i}});return n.disposeIntermediateTensorInfo(f),n.disposeIntermediateTensorInfo(p),n.disposeIntermediateTensorInfo(m),n.disposeIntermediateTensorInfo(g),y}const poe={kernelName:l$,backendName:"webgl",kernelFunc:foe};/** + */function doe(t){const{inputs:e,backend:n,attrs:s}=t,{indices:r,updates:o}=e,{shape:i}=s,{sliceRank:a,numUpdates:l,sliceSize:c,strides:u,outputSize:h}=Qi(o,r,i),d=[h/c,c];if(h===0)return n.makeTensorInfo(i,r.dtype);const f=re({inputs:{x:r},backend:n,attrs:{shape:[l,a]}}),p=re({inputs:{x:o},backend:n,attrs:{shape:[l,c]}}),g=n.makeTensorInfo([],"float32",new Float32Array([0]));let x;W().getBool("WEBGL_PACK")?x=new hoe(l,a,f.shape.length,p.shape.length,u,d):x=new Tv(l,a,f.shape.length,p.shape.length,u,d);const m=n.runWebGLProgram(x,[p,f,g],p.dtype),y=re({inputs:{x:m},backend:n,attrs:{shape:i}});return n.disposeIntermediateTensorInfo(f),n.disposeIntermediateTensorInfo(p),n.disposeIntermediateTensorInfo(m),n.disposeIntermediateTensorInfo(g),y}const foe={kernelName:l$,backendName:"webgl",kernelFunc:doe};/** * @license * Copyright 2022 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -19370,7 +19370,7 @@ return a / b;`,Vse=` * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */class moe{constructor(e,n,s,r){this.variableNames=["sortedSequence","values"],this.customUniforms=[{name:"numInputs",type:"int"}],this.outputShape=[e,s];const o="while (left < right) {",i=`for (int i = 0; i < ${Math.ceil(Math.log2(n+1))}; ++i) { if (left >= right) break;`,a=W().getNumber("WEBGL_VERSION")===2?o:i,l=r==="left"?"<":"<=";this.userCode=` + */class poe{constructor(e,n,s,r){this.variableNames=["sortedSequence","values"],this.customUniforms=[{name:"numInputs",type:"int"}],this.outputShape=[e,s];const o="while (left < right) {",i=`for (int i = 0; i < ${Math.ceil(Math.log2(n+1))}; ++i) { if (left >= right) break;`,a=W().getNumber("WEBGL_VERSION")===2?o:i,l=r==="left"?"<":"<=";this.userCode=` int findBound(int batch, float value) { int left = 0; int right = numInputs; @@ -19410,7 +19410,7 @@ return a / b;`,Vse=` * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function goe(t){const{inputs:e,backend:n,attrs:s}=t,{sortedSequence:r,values:o}=e,{side:i}=s,a=new moe(r.shape[0],r.shape[1],o.shape[1],i),l=[[r.shape[1]]];return n.runWebGLProgram(a,[r,o],"int32",l)}const xoe={kernelName:u$,backendName:"webgl",kernelFunc:goe};/** + */function moe(t){const{inputs:e,backend:n,attrs:s}=t,{sortedSequence:r,values:o}=e,{side:i}=s,a=new poe(r.shape[0],r.shape[1],o.shape[1],i),l=[[r.shape[1]]];return n.runWebGLProgram(a,[r,o],"int32",l)}const goe={kernelName:u$,backendName:"webgl",kernelFunc:moe};/** * @license * Copyright 2017 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -19425,7 +19425,7 @@ return a / b;`,Vse=` * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */class yoe{constructor(e,n,s){this.variableNames=["c","a","b"],this.outputShape=n;let r,o;if(s>4)throw Error(`Where for rank ${s} is not yet supported`);if(s===1)o="resRC",r="resRC";else{const a=["resRC.x","resRC.y","resRC.z","resRC.w"],l=[],c=[];for(let u=0;u4)throw Error(`Where for rank ${s} is not yet supported`);if(s===1)o="resRC",r="resRC";else{const a=["resRC.x","resRC.y","resRC.z","resRC.w"],l=[],c=[];for(let u=0;u= 0.0) ? scale * x : scaleAlpha * (exp(x) - 1.0); -`,Coe=Oe({opSnippet:boe}),koe={kernelName:Yu,backendName:"webgl",kernelFunc:Coe};/** +`,boe=Oe({opSnippet:voe}),Coe={kernelName:qu,backendName:"webgl",kernelFunc:boe};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -19486,9 +19486,9 @@ return a / b;`,Vse=` * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const Soe=_l+` + */const koe=_l+` return 1.0 / (1.0 + exp(-1.0 * x)); -`,Ioe=` +`,Soe=` vec4 result = 1.0 / (1.0 + exp(-1.0 * x)); bvec4 isNaN = isnan(x); @@ -19498,7 +19498,7 @@ return a / b;`,Vse=` result.a = isNaN.a ? x.a : result.a; return result; -`,$oe=Oe({opSnippet:Soe,packedOpSnippet:Ioe,cpuKernelImpl:IQ}),Noe={kernelName:eh,backendName:"webgl",kernelFunc:$oe};/** +`,Ioe=Oe({opSnippet:koe,packedOpSnippet:Soe,cpuKernelImpl:SQ}),$oe={kernelName:Ju,backendName:"webgl",kernelFunc:Ioe};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -19513,10 +19513,10 @@ return a / b;`,Vse=` * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const Toe=` + */const Noe=` if (isnan(x)) { return 0.0; } return sign(x); -`,Eoe=Oe({opSnippet:Toe}),Roe={kernelName:Ju,backendName:"webgl",kernelFunc:Eoe};/** +`,Toe=Oe({opSnippet:Noe}),Eoe={kernelName:Zu,backendName:"webgl",kernelFunc:Toe};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -19531,14 +19531,14 @@ return a / b;`,Vse=` * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const Aoe=_l+` + */const Roe=_l+` return sin(x); -`,Doe=` +`,Aoe=` vec4 result = sin(x); bvec4 isNaN = isnan(x); ${na} return result; -`,_oe=Oe({opSnippet:Aoe,packedOpSnippet:Doe}),Foe={kernelName:Qu,backendName:"webgl",kernelFunc:_oe};/** +`,Doe=Oe({opSnippet:Roe,packedOpSnippet:Aoe}),_oe={kernelName:Yu,backendName:"webgl",kernelFunc:Doe};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -19553,10 +19553,10 @@ return a / b;`,Vse=` * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const zoe=` + */const Foe=` float e2x = exp(x); return (e2x - 1.0 / e2x) / 2.0; -`,Ooe=Oe({opSnippet:zoe}),Moe={kernelName:Zu,backendName:"webgl",kernelFunc:Ooe};/** +`,zoe=Oe({opSnippet:Foe}),Ooe={kernelName:Qu,backendName:"webgl",kernelFunc:zoe};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -19571,7 +19571,7 @@ return a / b;`,Vse=` * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const Poe=` + */const Moe=` float epsilon = 1.1920928955078125e-7; float threshold = log(epsilon) + 2.0; @@ -19591,7 +19591,7 @@ return a / b;`,Vse=` result = log(exp_x + 1.0); } return result; -`,Loe=Oe({opSnippet:Poe}),Boe={kernelName:th,backendName:"webgl",kernelFunc:Loe};/** +`,Poe=Oe({opSnippet:Moe}),Loe={kernelName:eh,backendName:"webgl",kernelFunc:Poe};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -19606,7 +19606,7 @@ return a / b;`,Vse=` * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const Voe=t=>{const{inputs:e,backend:n,attrs:s}=t,{x:r}=e,{blockShape:o,paddings:i}=s;I(r.shape.length<=4,()=>"spaceToBatchND for rank > 4 with a WebGL backend not implemented yet");const a=o.reduce((m,y)=>m*y),l=[[0,0]];l.push(...i);for(let m=1+o.length;mn.disposeIntermediateTensorInfo(m)),x},Woe={kernelName:lm,backendName:"webgl",kernelFunc:Voe};/** + */const Boe=t=>{const{inputs:e,backend:n,attrs:s}=t,{x:r}=e,{blockShape:o,paddings:i}=s;I(r.shape.length<=4,()=>"spaceToBatchND for rank > 4 with a WebGL backend not implemented yet");const a=o.reduce((m,y)=>m*y),l=[[0,0]];l.push(...i);for(let m=1+o.length;mn.disposeIntermediateTensorInfo(m)),x},Voe={kernelName:lm,backendName:"webgl",kernelFunc:Boe};/** * @license * Copyright 2021 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -19621,11 +19621,11 @@ return a / b;`,Vse=` * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function Uoe(t){const{inputs:e,backend:n}=t,{indices:s,values:r,denseShape:o,defaultValue:i}=e;if(o.shape.length!==1)throw new Error(`Dense shape must be a vector, saw: + */function Woe(t){const{inputs:e,backend:n}=t,{indices:s,values:r,denseShape:o,defaultValue:i}=e;if(o.shape.length!==1)throw new Error(`Dense shape must be a vector, saw: ${o.shape}`);if(s.shape.length!==2)throw new Error(`Indices must be a matrix, saw: ${s.shape}`);if(r.shape.length!==1)throw new Error(`Values must be a vector, saw: ${r.shape}`);if(i.shape.length!==0)throw new Error(`Default value must be a scalar, saw: - ${i.shape}`);const a=n.readSync(s.dataId),l=n.readSync(r.dataId),c=n.readSync(o.dataId),u=n.readSync(i.dataId)[0],[h,d,f,p,g]=NQ(a,s.shape,s.dtype,l,r.dtype,c,u);return[n.makeTensorInfo(d,s.dtype,h),n.makeTensorInfo([d[0]],r.dtype,f),n.makeTensorInfo([p.length],"bool",new Uint8Array(p.map(x=>Number(x)))),n.makeTensorInfo([g.length],s.dtype,new Int32Array(g))]}const Goe={kernelName:h$,backendName:"webgl",kernelFunc:Uoe};/** + ${i.shape}`);const a=n.readSync(s.dataId),l=n.readSync(r.dataId),c=n.readSync(o.dataId),u=n.readSync(i.dataId)[0],[h,d,f,p,g]=$Q(a,s.shape,s.dtype,l,r.dtype,c,u);return[n.makeTensorInfo(d,s.dtype,h),n.makeTensorInfo([d[0]],r.dtype,f),n.makeTensorInfo([p.length],"bool",new Uint8Array(p.map(x=>Number(x)))),n.makeTensorInfo([g.length],s.dtype,new Int32Array(g))]}const Uoe={kernelName:h$,backendName:"webgl",kernelFunc:Woe};/** * @license * Copyright 2021 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -19640,7 +19640,7 @@ return a / b;`,Vse=` * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function Hoe(t){const{inputs:e,backend:n}=t,{inputIndices:s,inputShape:r,newShape:o}=e;if(s.shape.length!==2)throw new Error(`Input indices should be a matrix but received shape ${s.shape}`);if(r.shape.length!==1)throw new Error(`Input shape should be a vector but received shape ${r.shape}`);if(o.shape.length!==1)throw new Error(`Target shape should be a vector but received shape ${o.shape}`);const i=Array.from(n.readSync(r.dataId)),a=n.readSync(s.dataId),l=Array.from(n.readSync(o.dataId)),[c,u,h]=TQ(a,s.shape,s.dtype,i,l);return[n.makeTensorInfo(u,s.dtype,c),n.makeTensorInfo([h.length],o.dtype,new Int32Array(h))]}const joe={kernelName:d$,backendName:"webgl",kernelFunc:Hoe};/** + */function Goe(t){const{inputs:e,backend:n}=t,{inputIndices:s,inputShape:r,newShape:o}=e;if(s.shape.length!==2)throw new Error(`Input indices should be a matrix but received shape ${s.shape}`);if(r.shape.length!==1)throw new Error(`Input shape should be a vector but received shape ${r.shape}`);if(o.shape.length!==1)throw new Error(`Target shape should be a vector but received shape ${o.shape}`);const i=Array.from(n.readSync(r.dataId)),a=n.readSync(s.dataId),l=Array.from(n.readSync(o.dataId)),[c,u,h]=NQ(a,s.shape,s.dtype,i,l);return[n.makeTensorInfo(u,s.dtype,c),n.makeTensorInfo([h.length],o.dtype,new Int32Array(h))]}const Hoe={kernelName:d$,backendName:"webgl",kernelFunc:Goe};/** * @license * Copyright 2021 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -19655,9 +19655,9 @@ return a / b;`,Vse=` * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function Koe(t){const{inputs:e,backend:n}=t,{data:s,indices:r,segmentIds:o}=e;if(s.shape.length<1)throw new Error("Data should be at least 1 dimensional but received scalar");if(r.shape.length!==1)throw new Error(`Indices should be a vector but received shape + */function joe(t){const{inputs:e,backend:n}=t,{data:s,indices:r,segmentIds:o}=e;if(s.shape.length<1)throw new Error("Data should be at least 1 dimensional but received scalar");if(r.shape.length!==1)throw new Error(`Indices should be a vector but received shape ${r.shape}`);if(o.shape.length!==1)throw new Error(`Segment ids should be a vector but received shape - ${o.shape}`);const i=n.readSync(s.dataId),a=n.readSync(r.dataId),l=n.readSync(o.dataId),[c,u]=eD(i,s.shape,s.dtype,a,l,!0);return n.makeTensorInfo(u,s.dtype,c)}const Xoe={kernelName:f$,backendName:"webgl",kernelFunc:Koe};/** + ${o.shape}`);const i=n.readSync(s.dataId),a=n.readSync(r.dataId),l=n.readSync(o.dataId),[c,u]=eD(i,s.shape,s.dtype,a,l,!0);return n.makeTensorInfo(u,s.dtype,c)}const Koe={kernelName:f$,backendName:"webgl",kernelFunc:joe};/** * @license * Copyright 2021 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -19672,9 +19672,9 @@ return a / b;`,Vse=` * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function qoe(t){const{inputs:e,backend:n}=t,{data:s,indices:r,segmentIds:o}=e;if(s.shape.length<1)throw new Error("Data should be at least 1 dimensional but received scalar");if(r.shape.length!==1)throw new Error(`Indices should be a vector but received shape + */function Xoe(t){const{inputs:e,backend:n}=t,{data:s,indices:r,segmentIds:o}=e;if(s.shape.length<1)throw new Error("Data should be at least 1 dimensional but received scalar");if(r.shape.length!==1)throw new Error(`Indices should be a vector but received shape ${r.shape}`);if(o.shape.length!==1)throw new Error(`Segment ids should be a vector but received shape - ${o.shape}`);const i=n.readSync(s.dataId),a=n.readSync(r.dataId),l=n.readSync(o.dataId),[c,u]=eD(i,s.shape,s.dtype,a,l);return n.makeTensorInfo(u,s.dtype,c)}const Yoe={kernelName:p$,backendName:"webgl",kernelFunc:qoe};/** + ${o.shape}`);const i=n.readSync(s.dataId),a=n.readSync(r.dataId),l=n.readSync(o.dataId),[c,u]=eD(i,s.shape,s.dtype,a,l);return n.makeTensorInfo(u,s.dtype,c)}const qoe={kernelName:p$,backendName:"webgl",kernelFunc:Xoe};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -19689,7 +19689,7 @@ return a / b;`,Vse=` * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function Qoe(t){const{inputs:e,backend:n,attrs:s}=t,{sparseIndices:r,sparseValues:o,defaultValue:i}=e,{outputShape:a}=s,{sliceRank:l,numUpdates:c,sliceSize:u,strides:h,outputSize:d}=Qi(o,r,a),f=!1;if(o.dtype==="string"){const m=n.bufferSync(r),y=n.bufferSync(o),w=Do(n.readSync(i.dataId)[0]),v=SQ(m,y,a,d,u,c,l,h,w,f);return n.makeTensorInfo(a,v.dtype,v.values)}const p=new Tv(c,l,r.shape.length,o.shape.length,h,[d,1],f),g=n.runWebGLProgram(p,[o,r,i],o.dtype),x=re({inputs:{x:g},backend:n,attrs:{shape:a}});return n.disposeIntermediateTensorInfo(g),x}const Zoe={kernelName:m$,backendName:"webgl",kernelFunc:Qoe};/** + */function Yoe(t){const{inputs:e,backend:n,attrs:s}=t,{sparseIndices:r,sparseValues:o,defaultValue:i}=e,{outputShape:a}=s,{sliceRank:l,numUpdates:c,sliceSize:u,strides:h,outputSize:d}=Qi(o,r,a),f=!1;if(o.dtype==="string"){const m=n.bufferSync(r),y=n.bufferSync(o),w=Do(n.readSync(i.dataId)[0]),v=kQ(m,y,a,d,u,c,l,h,w,f);return n.makeTensorInfo(a,v.dtype,v.values)}const p=new Tv(c,l,r.shape.length,o.shape.length,h,[d,1],f),g=n.runWebGLProgram(p,[o,r,i],o.dtype),x=re({inputs:{x:g},backend:n,attrs:{shape:a}});return n.disposeIntermediateTensorInfo(g),x}const Qoe={kernelName:m$,backendName:"webgl",kernelFunc:Yoe};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -19704,7 +19704,7 @@ return a / b;`,Vse=` * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function Joe(t){const{inputs:e,backend:n,attrs:s}=t,{x:r}=e,{numOrSizeSplits:o,axis:i}=s,a=Re(i,r.shape)[0],l=Vw(r,o,a),c=r.shape.length,u=new Array(c).fill(0),h=r.shape.slice();return l.map(d=>{const f=[...h];f[a]=d;const p=Fl({inputs:{x:r},backend:n,attrs:{begin:u,size:f}});return u[a]+=d,p})}const eie={kernelName:cm,backendName:"webgl",kernelFunc:Joe};/** + */function Zoe(t){const{inputs:e,backend:n,attrs:s}=t,{x:r}=e,{numOrSizeSplits:o,axis:i}=s,a=Re(i,r.shape)[0],l=Vw(r,o,a),c=r.shape.length,u=new Array(c).fill(0),h=r.shape.slice();return l.map(d=>{const f=[...h];f[a]=d;const p=Fl({inputs:{x:r},backend:n,attrs:{begin:u,size:f}});return u[a]+=d,p})}const Joe={kernelName:cm,backendName:"webgl",kernelFunc:Zoe};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -19719,7 +19719,7 @@ return a / b;`,Vse=` * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const jk="return sqrt(x);",tie=Oe({opSnippet:jk,packedOpSnippet:jk,cpuKernelImpl:EQ}),nie={kernelName:nh,backendName:"webgl",kernelFunc:tie};/** + */const jk="return sqrt(x);",eie=Oe({opSnippet:jk,packedOpSnippet:jk,cpuKernelImpl:TQ}),tie={kernelName:th,backendName:"webgl",kernelFunc:eie};/** * @license * Copyright 2019 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -19734,7 +19734,7 @@ return a / b;`,Vse=` * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const sie="return x * x;",rie=Oe({opSnippet:sie}),oie={kernelName:Sy,backendName:"webgl",kernelFunc:rie};/** + */const nie="return x * x;",sie=Oe({opSnippet:nie}),rie={kernelName:Sy,backendName:"webgl",kernelFunc:sie};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -19749,7 +19749,7 @@ return a / b;`,Vse=` * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const Kk="return (a - b) * (a - b);",iie=rn({opSnippet:Kk,packedOpSnippet:Kk}),aie={kernelName:sh,backendName:"webgl",kernelFunc:iie};/** + */const Kk="return (a - b) * (a - b);",oie=rn({opSnippet:Kk,packedOpSnippet:Kk}),iie={kernelName:nh,backendName:"webgl",kernelFunc:oie};/** * @license * Copyright 2023 Google LLC. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -19764,7 +19764,7 @@ return a / b;`,Vse=` * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function lie(t){const{inputs:e,backend:n,attrs:s}=t,{x:r}=e;if(r.dtype!=="string")throw new Error("Input must be of datatype string");const o=n.readSync(r.dataId),i=Kr(o),a=RQ(i,"string",s);return n.makeTensorInfo(r.shape,"string",a)}const cie={kernelName:Iy,backendName:"webgl",kernelFunc:lie};/** + */function aie(t){const{inputs:e,backend:n,attrs:s}=t,{x:r}=e;if(r.dtype!=="string")throw new Error("Input must be of datatype string");const o=n.readSync(r.dataId),i=Kr(o),a=EQ(i,"string",s);return n.makeTensorInfo(r.shape,"string",a)}const lie={kernelName:Iy,backendName:"webgl",kernelFunc:aie};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -19779,9 +19779,9 @@ return a / b;`,Vse=` * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function uie({inputs:t,attrs:e,backend:n}){const{x:s}=t,r=_s+` + */function cie({inputs:t,attrs:e,backend:n}){const{x:s}=t,r=_s+` return x > 0.0 ? 1.0 : float(${e.alpha}); - `,o=new pr(s.shape,r);return n.runWebGLProgram(o,[s],s.dtype)}const hie={kernelName:lh,backendName:"webgl",kernelFunc:uie};/** + `,o=new pr(s.shape,r);return n.runWebGLProgram(o,[s],s.dtype)}const uie={kernelName:ah,backendName:"webgl",kernelFunc:cie};/** * @license * Copyright 2017 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -19796,7 +19796,7 @@ return a / b;`,Vse=` * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */class die{constructor(e,n,s){this.variableNames=["x"],this.outputShape=s;const r=s.length,o=Ze(s.length),i=Ze(s.length);let a="";if(r===1)a="coords * strides + begin";else{let l=0;a=s.map((c,u)=>(l++,s.length===1?`coords * strides[${u}] + begin[${u}]`:`coords[${l-1}] * strides[${u}] + begin[${u}]`)).join(",")}this.userCode=` + */class hie{constructor(e,n,s){this.variableNames=["x"],this.outputShape=s;const r=s.length,o=Ze(s.length),i=Ze(s.length);let a="";if(r===1)a="coords * strides + begin";else{let l=0;a=s.map((c,u)=>(l++,s.length===1?`coords * strides[${u}] + begin[${u}]`:`coords[${l-1}] * strides[${u}] + begin[${u}]`)).join(",")}this.userCode=` ${o} begin = ${o}(${e}); ${o} strides = ${o}(${n}); @@ -19819,7 +19819,7 @@ return a / b;`,Vse=` * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function fie(t){const{inputs:e,backend:n,attrs:s}=t,{x:r}=e,{begin:o,end:i,strides:a,beginMask:l,endMask:c,ellipsisMask:u,newAxisMask:h,shrinkAxisMask:d}=s,{finalShapeSparse:f,finalShape:p,isIdentity:g,sliceDim0:x,isSimpleSlice:m,begin:y,end:w,strides:v}=kw(r.shape,o,i,a,l,c,u,h,d);let b;if(g)b=re({inputs:{x:r},backend:n,attrs:{shape:p}});else if(x||m){I(r.shape.length>=1,()=>`Input must have rank at least 1, got: ${r.shape.length}`);const k=vw(y,w,v),S=Fl({inputs:{x:r},backend:n,attrs:{begin:y,size:k}});b=re({inputs:{x:S},backend:n,attrs:{shape:p}}),n.disposeIntermediateTensorInfo(S)}else if(n.shouldExecuteOnCPU([r])){const S=n.readSync(r.dataId),$=Ee(r.shape,r.dtype,S),N=AQ(f,$,v,y);b=n.makeTensorInfo(p,r.dtype,N.values)}else{const S=new die(y,v,f);b=n.runWebGLProgram(S,[r],r.dtype)}const C=re({inputs:{x:b},backend:n,attrs:{shape:p}});return n.disposeIntermediateTensorInfo(b),C}const pie={kernelName:$y,backendName:"webgl",kernelFunc:fie};/** + */function die(t){const{inputs:e,backend:n,attrs:s}=t,{x:r}=e,{begin:o,end:i,strides:a,beginMask:l,endMask:c,ellipsisMask:u,newAxisMask:h,shrinkAxisMask:d}=s,{finalShapeSparse:f,finalShape:p,isIdentity:g,sliceDim0:x,isSimpleSlice:m,begin:y,end:w,strides:v}=kw(r.shape,o,i,a,l,c,u,h,d);let b;if(g)b=re({inputs:{x:r},backend:n,attrs:{shape:p}});else if(x||m){I(r.shape.length>=1,()=>`Input must have rank at least 1, got: ${r.shape.length}`);const k=vw(y,w,v),S=Fl({inputs:{x:r},backend:n,attrs:{begin:y,size:k}});b=re({inputs:{x:S},backend:n,attrs:{shape:p}}),n.disposeIntermediateTensorInfo(S)}else if(n.shouldExecuteOnCPU([r])){const S=n.readSync(r.dataId),$=Ee(r.shape,r.dtype,S),N=RQ(f,$,v,y);b=n.makeTensorInfo(p,r.dtype,N.values)}else{const S=new hie(y,v,f);b=n.runWebGLProgram(S,[r],r.dtype)}const C=re({inputs:{x:b},backend:n,attrs:{shape:p}});return n.disposeIntermediateTensorInfo(b),C}const fie={kernelName:$y,backendName:"webgl",kernelFunc:die};/** * @license * Copyright 2021 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -19834,7 +19834,7 @@ return a / b;`,Vse=` * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function mie(t){const{inputs:e,backend:n,attrs:s}=t,{separator:r,nGramWidths:o,leftPad:i,rightPad:a,padWidth:l,preserveShortSequences:c}=s,{data:u,dataSplits:h}=e,d=n.readSync(u.dataId),f=n.readSync(h.dataId),[p,g]=DQ(d,f,r,o,i,a,l,c);return[n.makeTensorInfo([p.length],"string",p),n.makeTensorInfo(h.shape,"int32",g)]}const gie={kernelName:g$,backendName:"webgl",kernelFunc:mie};/** + */function pie(t){const{inputs:e,backend:n,attrs:s}=t,{separator:r,nGramWidths:o,leftPad:i,rightPad:a,padWidth:l,preserveShortSequences:c}=s,{data:u,dataSplits:h}=e,d=n.readSync(u.dataId),f=n.readSync(h.dataId),[p,g]=AQ(d,f,r,o,i,a,l,c);return[n.makeTensorInfo([p.length],"string",p),n.makeTensorInfo(h.shape,"int32",g)]}const mie={kernelName:g$,backendName:"webgl",kernelFunc:pie};/** * @license * Copyright 2021 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -19849,7 +19849,7 @@ return a / b;`,Vse=` * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function xie(t){const{inputs:e,backend:n,attrs:s}=t,{skipEmpty:r}=s,{input:o,delimiter:i}=e;if(o.dtype!=="string")throw new Error("Input must be of datatype string");if(o.shape.length!==1)throw new Error(`Input must be a vector, got shape: ${o.shape}`);if(i.shape.length!==0)throw new Error(`Delimiter must be a scalar, got shape: ${i.shape}`);const a=n.readSync(o.dataId),l=n.readSync(i.dataId)[0],[c,u,h]=_Q(a,l,r),d=u.length;return[n.makeTensorInfo([d,2],"int32",c),n.makeTensorInfo([d],"string",u),n.makeTensorInfo([2],"int32",new Int32Array(h))]}const yie={kernelName:x$,backendName:"webgl",kernelFunc:xie};/** + */function gie(t){const{inputs:e,backend:n,attrs:s}=t,{skipEmpty:r}=s,{input:o,delimiter:i}=e;if(o.dtype!=="string")throw new Error("Input must be of datatype string");if(o.shape.length!==1)throw new Error(`Input must be a vector, got shape: ${o.shape}`);if(i.shape.length!==0)throw new Error(`Delimiter must be a scalar, got shape: ${i.shape}`);const a=n.readSync(o.dataId),l=n.readSync(i.dataId)[0],[c,u,h]=DQ(a,l,r),d=u.length;return[n.makeTensorInfo([d,2],"int32",c),n.makeTensorInfo([d],"string",u),n.makeTensorInfo([2],"int32",new Int32Array(h))]}const xie={kernelName:x$,backendName:"webgl",kernelFunc:gie};/** * @license * Copyright 2021 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -19864,7 +19864,7 @@ return a / b;`,Vse=` * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function wie(t){const{inputs:e,backend:n,attrs:s}=t,{numBuckets:r}=s,{input:o}=e;if(o.dtype!=="string")throw new Error("Input must be of datatype string");if(r<=0)throw new Error("Number of buckets must be at least 1");const i=n.readSync(o.dataId),a=FQ(i,r);return n.makeTensorInfo(o.shape,"int32",a)}const vie={kernelName:y$,backendName:"webgl",kernelFunc:wie};/** + */function yie(t){const{inputs:e,backend:n,attrs:s}=t,{numBuckets:r}=s,{input:o}=e;if(o.dtype!=="string")throw new Error("Input must be of datatype string");if(r<=0)throw new Error("Number of buckets must be at least 1");const i=n.readSync(o.dataId),a=_Q(i,r);return n.makeTensorInfo(o.shape,"int32",a)}const wie={kernelName:y$,backendName:"webgl",kernelFunc:yie};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -19879,7 +19879,7 @@ return a / b;`,Vse=` * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const bie="return tan(x);",Cie=Oe({opSnippet:bie}),kie={kernelName:oh,backendName:"webgl",kernelFunc:Cie};/** + */const vie="return tan(x);",bie=Oe({opSnippet:vie}),Cie={kernelName:rh,backendName:"webgl",kernelFunc:bie};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -19894,10 +19894,10 @@ return a / b;`,Vse=` * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const Sie=` + */const kie=` float e2x = exp(-2.0 * abs(x)); return sign(x) * (1.0 - e2x) / (1.0 + e2x); -`,Iie=Oe({opSnippet:Sie}),$ie={kernelName:ih,backendName:"webgl",kernelFunc:Iie};/** +`,Sie=Oe({opSnippet:kie}),Iie={kernelName:oh,backendName:"webgl",kernelFunc:Sie};/** * @license * Copyright 2022 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -19912,7 +19912,7 @@ return a / b;`,Vse=` * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function Nie(t){const{inputs:e,backend:n,attrs:s}=t,{tensor:r,indices:o,updates:i}=e,{sliceRank:a,numUpdates:l,sliceSize:c,strides:u,outputSize:h}=Qi(i,o,r.shape),d=[h/c,c];if(h===0)return n.makeTensorInfo(r.shape,o.dtype);const f=re({inputs:{x:o},backend:n,attrs:{shape:[l,a]}}),p=re({inputs:{x:i},backend:n,attrs:{shape:[l,c]}}),g=re({inputs:{x:r},backend:n,attrs:{shape:d}}),x=new Tv(l,a,f.shape.length,p.shape.length,u,d,!1,!0),m=n.runWebGLProgram(x,[p,f,g],g.dtype),y=re({inputs:{x:m},backend:n,attrs:{shape:r.shape}});return n.disposeIntermediateTensorInfo(f),n.disposeIntermediateTensorInfo(p),n.disposeIntermediateTensorInfo(g),n.disposeIntermediateTensorInfo(m),y}const Tie={kernelName:c$,backendName:"webgl",kernelFunc:Nie};/** + */function $ie(t){const{inputs:e,backend:n,attrs:s}=t,{tensor:r,indices:o,updates:i}=e,{sliceRank:a,numUpdates:l,sliceSize:c,strides:u,outputSize:h}=Qi(i,o,r.shape),d=[h/c,c];if(h===0)return n.makeTensorInfo(r.shape,o.dtype);const f=re({inputs:{x:o},backend:n,attrs:{shape:[l,a]}}),p=re({inputs:{x:i},backend:n,attrs:{shape:[l,c]}}),g=re({inputs:{x:r},backend:n,attrs:{shape:d}}),x=new Tv(l,a,f.shape.length,p.shape.length,u,d,!1,!0),m=n.runWebGLProgram(x,[p,f,g],g.dtype),y=re({inputs:{x:m},backend:n,attrs:{shape:r.shape}});return n.disposeIntermediateTensorInfo(f),n.disposeIntermediateTensorInfo(p),n.disposeIntermediateTensorInfo(g),n.disposeIntermediateTensorInfo(m),y}const Nie={kernelName:c$,backendName:"webgl",kernelFunc:$ie};/** * @license * Copyright 2017 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -19927,12 +19927,12 @@ return a / b;`,Vse=` * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */class Eie{constructor(e,n){this.variableNames=["A"];const s=new Array(e.length);for(let i=0;i5)throw Error(`Tile for rank ${e} is not yet supported`);if(e===1)return`imod(resRC, ${t[0]})`;const n=["resRC.x","resRC.y","resRC.z","resRC.w","resRC.u"],s=[];for(let r=0;r5)throw Error(`Tile for rank ${e} is not yet supported`);if(e===1)return`imod(resRC, ${t[0]})`;const n=["resRC.x","resRC.y","resRC.z","resRC.w","resRC.u"],s=[];for(let r=0;r5){const l=n.readSync(r.dataId),c=r.dtype==="string"?l.map(d=>Do(d)):l,u=Ee(r.shape,r.dtype,c),h=OQ(u,o);return n.makeTensorInfo(h.shape,h.dtype,h.values)}const i=new Eie(r.shape,o);return n.runWebGLProgram(i,[r],r.dtype)}const Aie={kernelName:ah,backendName:"webgl",kernelFunc:AD};class Die{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=` + */function AD(t){const{inputs:e,backend:n,attrs:s}=t,{x:r}=e,{reps:o}=s;if(r.dtype==="string"||r.shape.length>5){const l=n.readSync(r.dataId),c=r.dtype==="string"?l.map(d=>Do(d)):l,u=Ee(r.shape,r.dtype,c),h=zQ(u,o);return n.makeTensorInfo(h.shape,h.dtype,h.values)}const i=new Tie(r.shape,o);return n.runWebGLProgram(i,[r],r.dtype)}const Rie={kernelName:ih,backendName:"webgl",kernelFunc:AD};class Aie{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=` void main() { ivec2 coords = getOutputCoords(); int batch = coords[0]; @@ -19987,7 +19987,7 @@ return a / b;`,Vse=` setOutput(float(i1)); } } - `}}class _ie{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=` + `}}class Die{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=` void main() { // Takes max of indices (0, k), (1, k + 1), (2, k + 2) ... ivec2 coords = getOutputCoords(); @@ -20036,7 +20036,7 @@ return a / b;`,Vse=` * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function ti(t,e){e!==null&&t.disposeIntermediateTensorInfo(e)}function Xk(t){let e=1;for(;el){const N=n.readSync(r.dataId),[A,M]=MQ(N,c,r.dtype,o,i);return[n.makeTensorInfo(A.shape,A.dtype,A.values),n.makeTensorInfo(M.shape,M.dtype,M.values)]}if(o===0)return c[c.length-1]=0,[n.makeTensorInfo(c,r.dtype,[]),n.makeTensorInfo(c,"int32",[])];if(u===1)return[r,Dh({attrs:{shape:c,dtype:"int32",value:0},backend:n})];const h=n.texData.get(r.dataId),d=h!==null&&h.isPacked,f=d?n.unpackTensor(r):r,g=j(c)/u,x=re({inputs:{x:f},attrs:{shape:[g,u]},backend:n});d&&ti(n,f);const m=Xk(o),y=Xk(u);let w=null;const v=()=>w===null?[x,x]:[x,w],b=(N,A,M)=>{const L=v(),V=new Die(M),U=[[u],[w===null?1:0],[Number.NEGATIVE_INFINITY],[N],[A]],K=w;w=n.runWebGLProgram(V,L,"int32",U),ti(n,K)};for(let N=1;N=1;M/=2)b(A,M,[g,y])}for(let N=y;N>m;N/=2){const A=v(),M=new _ie([g,N/2]),V=[[u],[w===null?1:0],[m]],B=w;w=n.runWebGLProgram(M,A,"int32",V),ti(n,B);const U=m/2,K=U*2;for(let R=U;R>=1;R/=2)b(K,R,w.shape)}let C=w;w=Fl({inputs:{x:w},backend:n,attrs:{begin:0,size:[g,o]}}),ti(n,C);let k=kD({inputs:{x,indices:w},backend:n,attrs:{axis:1,batchDims:1}});ti(n,x);const S=c.slice(0,-1);S.push(o),C=w,w=re({inputs:{x:w},attrs:{shape:S},backend:n}),ti(n,C);const $=k;return k=re({inputs:{x:k},attrs:{shape:S},backend:n}),ti(n,$),[k,w]}const zie={kernelName:Ny,backendName:"webgl",kernelFunc:Fie};/** + */function ti(t,e){e!==null&&t.disposeIntermediateTensorInfo(e)}function Xk(t){let e=1;for(;el){const N=n.readSync(r.dataId),[A,M]=OQ(N,c,r.dtype,o,i);return[n.makeTensorInfo(A.shape,A.dtype,A.values),n.makeTensorInfo(M.shape,M.dtype,M.values)]}if(o===0)return c[c.length-1]=0,[n.makeTensorInfo(c,r.dtype,[]),n.makeTensorInfo(c,"int32",[])];if(u===1)return[r,Ah({attrs:{shape:c,dtype:"int32",value:0},backend:n})];const h=n.texData.get(r.dataId),d=h!==null&&h.isPacked,f=d?n.unpackTensor(r):r,g=j(c)/u,x=re({inputs:{x:f},attrs:{shape:[g,u]},backend:n});d&&ti(n,f);const m=Xk(o),y=Xk(u);let w=null;const v=()=>w===null?[x,x]:[x,w],b=(N,A,M)=>{const L=v(),V=new Aie(M),U=[[u],[w===null?1:0],[Number.NEGATIVE_INFINITY],[N],[A]],K=w;w=n.runWebGLProgram(V,L,"int32",U),ti(n,K)};for(let N=1;N=1;M/=2)b(A,M,[g,y])}for(let N=y;N>m;N/=2){const A=v(),M=new Die([g,N/2]),V=[[u],[w===null?1:0],[m]],B=w;w=n.runWebGLProgram(M,A,"int32",V),ti(n,B);const U=m/2,K=U*2;for(let R=U;R>=1;R/=2)b(K,R,w.shape)}let C=w;w=Fl({inputs:{x:w},backend:n,attrs:{begin:0,size:[g,o]}}),ti(n,C);let k=kD({inputs:{x,indices:w},backend:n,attrs:{axis:1,batchDims:1}});ti(n,x);const S=c.slice(0,-1);S.push(o),C=w,w=re({inputs:{x:w},attrs:{shape:S},backend:n}),ti(n,C);const $=k;return k=re({inputs:{x:k},attrs:{shape:S},backend:n}),ti(n,$),[k,w]}const Fie={kernelName:Ny,backendName:"webgl",kernelFunc:_ie};/** * @license * Copyright 2021 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -20051,7 +20051,7 @@ return a / b;`,Vse=` * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */class Oie{constructor(e,n,s,r,o,i){this.variableNames=["Image","Transforms"],this.outputShape=i;const a=s==="nearest"?1:2;let l;switch(r){case"constant":l=1;break;case"reflect":l=2;break;case"wrap":l=3;break;case"nearest":l=4;break;default:l=1;break}this.userCode=` + */class zie{constructor(e,n,s,r,o,i){this.variableNames=["Image","Transforms"],this.outputShape=i;const a=s==="nearest"?1:2;let l;switch(r){case"constant":l=1;break;case"reflect":l=2;break;case"wrap":l=3;break;case"nearest":l=4;break;default:l=1;break}this.userCode=` float mapCoord(float outCoord, float len) { float inCoord = outCoord; if(${l} == 2) { @@ -20178,7 +20178,7 @@ return a / b;`,Vse=` * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function Mie(t){const{inputs:e,backend:n,attrs:s}=t,{image:r,transforms:o}=e,{interpolation:i,fillMode:a,fillValue:l,outputShape:c}=s,[u,h,d,f]=r.shape,[p,g]=c??[h,d],x=[u,p,g,f],m=new Oie(h,d,i,a,l,x);return n.runWebGLProgram(m,[r,o],"float32")}const Pie={kernelName:Ty,backendName:"webgl",kernelFunc:Mie};/** + */function Oie(t){const{inputs:e,backend:n,attrs:s}=t,{image:r,transforms:o}=e,{interpolation:i,fillMode:a,fillValue:l,outputShape:c}=s,[u,h,d,f]=r.shape,[p,g]=c??[h,d],x=[u,p,g,f],m=new zie(h,d,i,a,l,x);return n.runWebGLProgram(m,[r,o],"float32")}const Mie={kernelName:Ty,backendName:"webgl",kernelFunc:Oie};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the License); @@ -20193,7 +20193,7 @@ return a / b;`,Vse=` * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function Lie(t){const{inputs:e,attrs:n,backend:s}=t,{axis:r}=n,{x:o}=e;Eh(o,"unique"),console.warn("WARNING: ","UI might be locked temporarily as data is being downloaded");const i=s.readSync(o.dataId),{outputValues:a,outputShape:l,indices:c}=PQ(i,r,o.shape,o.dtype);return[s.makeTensorInfo(l,o.dtype,a),s.makeTensorInfo([c.length],"int32",c)]}const Bie={kernelName:Ey,backendName:"webgl",kernelFunc:Lie};/** + */function Pie(t){const{inputs:e,attrs:n,backend:s}=t,{axis:r}=n,{x:o}=e;Th(o,"unique"),console.warn("WARNING: ","UI might be locked temporarily as data is being downloaded");const i=s.readSync(o.dataId),{outputValues:a,outputShape:l,indices:c}=MQ(i,r,o.shape,o.dtype);return[s.makeTensorInfo(l,o.dtype,a),s.makeTensorInfo([c.length],"int32",c)]}const Lie={kernelName:Ey,backendName:"webgl",kernelFunc:Pie};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -20208,7 +20208,7 @@ return a / b;`,Vse=` * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function Vie(t){const{inputs:e,backend:n,attrs:s}=t,{value:r}=e;let{axis:o}=s;o<0&&(o+=r.shape.length);const i=r,a=i.shape.length,l=r.shape[o],c=new Array(a-1);let u=0;for(let g=0;gn.disposeIntermediateTensorInfo(g)),p}const Wie={kernelName:hm,backendName:"webgl",kernelFunc:Vie};/** + */function Bie(t){const{inputs:e,backend:n,attrs:s}=t,{value:r}=e;let{axis:o}=s;o<0&&(o+=r.shape.length);const i=r,a=i.shape.length,l=r.shape[o],c=new Array(a-1);let u=0;for(let g=0;gn.disposeIntermediateTensorInfo(g)),p}const Vie={kernelName:hm,backendName:"webgl",kernelFunc:Bie};/** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -20223,7 +20223,7 @@ return a / b;`,Vse=` * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */class Uie{constructor(e,n){this.variableNames=["x","segmentIds"];const s=e.windowSize,r=e.batchSize,o=e.inSize,i=e.numSegments,a=i*Math.ceil(o/s);this.outputShape=[r,a];const l="0.0",c="sumValue",u=Math.floor(s/4)*4,h=s%4,d=` + */class Wie{constructor(e,n){this.variableNames=["x","segmentIds"];const s=e.windowSize,r=e.batchSize,o=e.inSize,i=e.numSegments,a=i*Math.ceil(o/s);this.outputShape=[r,a];const l="0.0",c="sumValue",u=Math.floor(s/4)*4,h=s%4,d=` sumValue += dot(values, segFilter); `;let f="";o%s>0&&(f=` if (inIdx < 0 || inIdx >= ${o}) { @@ -20344,7 +20344,7 @@ return a / b;`,Vse=` * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */function Gie(t){const{inputs:e,backend:n,attrs:s}=t,{x:r,segmentIds:o}=e,{numSegments:i}=s,a=r.shape.length,l=[];let c=0;const u=yt([c],a);let h=r;u!=null&&(h=Sn({inputs:{x:r},backend:n,attrs:{perm:u}}),l.push(h),c=$t(1,a)[0]);const d=dT(h.shape,c,i),f=j([h.shape[c]]),p=re({inputs:{x:h},backend:n,attrs:{shape:[-1,f]}});l.push(p);const g=Dy(r.dtype),x=(v,b,C,k,S)=>{const $=v.shape[0],N=v.shape[1],A=hT(N,S),M={windowSize:A,inSize:N,batchSize:$,numSegments:S},L=new Uie(M,b),V=n.compileAndRun(L,[v,C],k);if(l.push(V),V.shape[1]===S)return V;const B=RD({backend:n,attrs:{start:0,stop:S,step:1,dtype:"float32"}}),U=AD({inputs:{x:B},backend:n,attrs:{reps:[N/A]}});return l.push(B),l.push(U),x(V,b,U,k,S)},m=x(p,"unsortedSegmentSum",o,g,i),y=re({inputs:{x:m},backend:n,attrs:{shape:d}});let w=y;if(u!=null){l.push(y);const v=Ho(u);w=Sn({inputs:{x:w},backend:n,attrs:{perm:v}})}return l.forEach(v=>n.disposeIntermediateTensorInfo(v)),w}const Hie={kernelName:dm,backendName:"webgl",kernelFunc:Gie};/** + */function Uie(t){const{inputs:e,backend:n,attrs:s}=t,{x:r,segmentIds:o}=e,{numSegments:i}=s,a=r.shape.length,l=[];let c=0;const u=yt([c],a);let h=r;u!=null&&(h=Sn({inputs:{x:r},backend:n,attrs:{perm:u}}),l.push(h),c=$t(1,a)[0]);const d=dT(h.shape,c,i),f=j([h.shape[c]]),p=re({inputs:{x:h},backend:n,attrs:{shape:[-1,f]}});l.push(p);const g=Dy(r.dtype),x=(v,b,C,k,S)=>{const $=v.shape[0],N=v.shape[1],A=hT(N,S),M={windowSize:A,inSize:N,batchSize:$,numSegments:S},L=new Wie(M,b),V=n.compileAndRun(L,[v,C],k);if(l.push(V),V.shape[1]===S)return V;const B=RD({backend:n,attrs:{start:0,stop:S,step:1,dtype:"float32"}}),U=AD({inputs:{x:B},backend:n,attrs:{reps:[N/A]}});return l.push(B),l.push(U),x(V,b,U,k,S)},m=x(p,"unsortedSegmentSum",o,g,i),y=re({inputs:{x:m},backend:n,attrs:{shape:d}});let w=y;if(u!=null){l.push(y);const v=Ho(u);w=Sn({inputs:{x:w},backend:n,attrs:{perm:v}})}return l.forEach(v=>n.disposeIntermediateTensorInfo(v)),w}const Gie={kernelName:dm,backendName:"webgl",kernelFunc:Uie};/** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -20359,7 +20359,7 @@ return a / b;`,Vse=` * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= - */const jie=[EZ,AZ,FZ,MZ,LZ,WZ,GZ,jZ,YZ,ZZ,tJ,rJ,aJ,hJ,pJ,gJ,yJ,CJ,SJ,$J,RJ,MJ,LJ,UJ,HJ,QJ,JJ,see,dZ,iee,hee,mee,bee,See,$ee,Tee,Ree,Fee,Mee,Bee,Wee,Gee,jee,qee,Qee,tte,ste,ite,cte,hte,mte,wte,kte,$te,Ete,Rte,Dte,Fte,Ote,Pte,Bte,Gte,Kte,Yte,Zte,tne,rne,lne,dne,hZ,pne,cee,xne,vne,kne,pZ,Nne,Ane,_ne,Mne,Bne,Gne,Kne,Qne,tse,rse,ise,use,dse,pse,yse,vse,Cse,Sse,$se,Rse,Fse,Pse,jse,xZ,Yse,Jse,nre,ore,KJ,lre,ure,dre,mre,wre,gZ,bre,kre,Ire,Nre,Tre,XJ,Wse,Are,zre,Lre,wZ,Ure,jre,Yre,Jre,soe,ooe,loe,hoe,poe,xoe,voe,koe,Noe,Roe,Foe,Moe,zJ,Gse,Boe,Woe,Goe,joe,Xoe,Yoe,Zoe,eie,nie,oie,aie,cie,hie,pie,gie,yie,vie,Use,$Z,kie,$ie,Tie,Aie,zie,Pie,NZ,Bie,Wie,Hie,cre];for(const t of jie)v$(t);const lr={tank:0,warrior:1,archer:2,artillery:3},Sc={"advance-wait":4,advance:5,"wait-advance":6,"flank-left":7,"flank-right":8},ru=30,Uf=Math.floor(ru/(So/Io));let Ic=null;async function Kie(){try{Ic?console.log("Model is already loaded"):(Ic=await lH(window.location.origin+window.location.pathname+"/tfmodel/model.json"),console.log("Model loaded successfully"))}catch(t){throw console.error("Failed to load the model:",t),t}}function Xie(t){return[t.data.map(e=>e.flat())]}async function qie(t){if(Ic||await Kie(),!Ic)throw new Error("Model not loaded. Call loadModel() first.");const e=YV(Xie(t)),n=Ic.predict(e),s=n.squeeze([0]),r=s.arraySync();return e.dispose(),n.dispose(),s.dispose(),{data:r.map(o=>o.reduce((i,a,l)=>(l%9===0&&i.push(o.slice(l,l+9)),i),[])),cols:ru,rows:Uf}}function DD(t){return t.map(e=>({...e,col:-e.col,row:-e.row}))}function Yie(t){const e=ru,n=Uf,s=Array.from({length:n},()=>Array.from({length:e},()=>Array(Object.keys(lr).length+Object.keys(Sc).length).fill(0)));let r=0;for(const o of t)for(let i=0;iu.map(h=>Object.values(lr).map(d=>h[d]))).flat(2),r=Math.min(...s),o=Math.max(...s),i=r+(o-r)*.5;for(let u=0;u[p,t.data[u][h][lr[p]]]).sort((p,g)=>g[1]-p[1]).filter(p=>p[1]>i))==null?void 0:a[0])==null?void 0:l[0],f=(c=Object.keys(Sc).map(p=>[p,t.data[u][h][Sc[p]]]).sort((p,g)=>g[1]-p[1])[0])==null?void 0:c[0];d&&(n[u+","+h]={type:d,command:f})}for(let u=0;u({...o})),s=Gf(n);if(s<=e)return n;let r=s-e;for(n.sort((o,i)=>i.sizeCol*i.sizeRow-o.sizeCol*o.sizeRow);r>0;){let o=!1;for(const i of n)if(i.sizeCol>1&&i.sizeRow>1){const a=i.sizeCol*i.sizeRow-(i.sizeCol-1)*(i.sizeRow-1);if(a<=0)continue;if(a<=r&&(i.sizeCol-=1,i.sizeRow-=1,r-=a,o=!0,r<=0))break}if(!o){for(const i of n)if(i.sizeCol>1&&i.sizeRow>1){if(i.sizeCol/i.sizeRow>=1?(i.sizeCol-=1,r-=i.sizeRow):(i.sizeRow-=1,r-=i.sizeCol),r<=0)break}else if(i.sizeCol>1&&i.sizeRow===1){if(i.sizeCol-=1,r-=i.sizeRow,r<=0)break}else if(i.sizeRow>1&&i.sizeCol===1&&(i.sizeRow-=1,r-=i.sizeCol,r<=0))break;break}}if(r>0){n.sort((o,i)=>i.sizeCol*i.sizeRow-o.sizeCol*o.sizeRow);for(const o of n){for(;r>0;){if(o.sizeCol>1&&o.sizeRow>1)o.sizeCol-=1,o.sizeRow-=1,r-=o.sizeCol+o.sizeRow+1;else if(o.sizeCol>1)o.sizeCol-=1,r-=o.sizeRow;else if(o.sizeRow>1)o.sizeRow-=1,r-=o.sizeCol;else break;if(o.sizeCol<1||o.sizeRow<1){o.sizeCol=Math.max(o.sizeCol,1),o.sizeRow=Math.max(o.sizeRow,1);break}if(r<=0)break}if(r<=0)break}}return n}function Gf(t){return t.reduce((e,n)=>e+n.sizeCol*n.sizeRow,0)}function Jie(t){var u,h,d;if(t.length===0)return[];let e=1/0,n=1/0,s=-1/0,r=-1/0;t.forEach(f=>{e=Math.min(e,f.col),n=Math.min(n,f.row),s=Math.max(s,f.col+f.sizeCol-1),r=Math.max(r,f.row+f.sizeRow-1)});const o=s-e+1,i=r-n+1,a=Array.from({length:i},()=>Array(o).fill(null));t.forEach(f=>{var p;for(let g=f.row;gf.id))+1;for(let f=0;f{const[t,e]=ye.useState([]),n=ye.useCallback(async s=>{let r;try{r=await eae(s),console.log("Generated counter plan using AI model"),Gf(r)Ox,updateOppositionPlan:n}},nae=({unit:t,position:e,onModifyUnit:n})=>{const[s,r]=ye.useState(null),o=l=>{r(s===l?null:l)},i=l=>{n(t.id,{type:l}),r(null)},a=l=>{n(t.id,l),r(null)};return De.jsxs(rae,{style:{left:e.x,top:e.y},children:[De.jsxs(qk,{onClick:()=>o("type"),children:[De.jsx(oae,{src:K0[t.type],alt:t.type}),s==="type"&&De.jsx(Yk,{children:["warrior","archer","tank","artillery"].map(l=>De.jsx(aae,{src:K0[l],alt:l,onClick:()=>i(l)},l))})]}),De.jsxs(qk,{onClick:()=>o("formation"),children:[De.jsxs(iae,{children:[t.sizeCol,"x",t.sizeRow]}),s==="formation"&&De.jsx(Yk,{children:sae(t.sizeCol,t.sizeRow).map(l=>De.jsxs(lae,{onClick:()=>a(l),children:[l.sizeCol,"x",l.sizeRow]},`${l.sizeCol}x${l.sizeRow}`))})]})]})};function sae(t,e){const n=t*e;return[{sizeCol:n,sizeRow:1},...Array.from({length:n-1},(s,r)=>({sizeCol:r+1,sizeRow:Math.ceil(n/(r+1))})).filter(s=>s.sizeCol*s.sizeRow<=n),{sizeCol:1,sizeRow:n}]}const rae=In.div` + */const Hie=[TZ,RZ,_Z,OZ,PZ,VZ,UZ,HZ,qZ,QZ,eJ,sJ,iJ,uJ,fJ,mJ,xJ,bJ,kJ,IJ,EJ,OJ,PJ,WJ,GJ,YJ,ZJ,nee,hZ,oee,uee,pee,vee,kee,Iee,Nee,Eee,_ee,Oee,Lee,Vee,Uee,Hee,Xee,Yee,ete,nte,ote,lte,ute,pte,yte,Cte,Ite,Tte,Ete,Ate,_te,zte,Mte,Lte,Ute,jte,qte,Qte,ene,sne,ane,hne,uZ,fne,lee,gne,wne,Cne,fZ,$ne,Rne,Dne,One,Lne,Une,jne,Yne,ese,sse,ose,cse,hse,fse,xse,wse,bse,kse,Ise,Ese,_se,Mse,Hse,gZ,qse,Zse,tre,rre,jJ,are,cre,hre,pre,yre,mZ,vre,Cre,Sre,$re,Nre,KJ,Vse,Rre,Fre,Pre,yZ,Wre,Hre,qre,Zre,noe,roe,aoe,uoe,foe,goe,woe,Coe,$oe,Eoe,_oe,Ooe,FJ,Use,Loe,Voe,Uoe,Hoe,Koe,qoe,Qoe,Joe,tie,rie,iie,lie,uie,fie,mie,xie,wie,Wse,IZ,Cie,Iie,Nie,Rie,Fie,Mie,$Z,Lie,Vie,Gie,lre];for(const t of Hie)v$(t);const lr={tank:0,warrior:1,archer:2,artillery:3},Sc={"advance-wait":4,advance:5,"wait-advance":6,"flank-left":7,"flank-right":8},ru=30,Wf=Math.floor(ru/(So/Io));let Ic=null;async function jie(){try{Ic?console.log("Model is already loaded"):(Ic=await aH(window.location.origin+window.location.pathname+"/tfmodel/model.json"),console.log("Model loaded successfully"))}catch(t){throw console.error("Failed to load the model:",t),t}}function Kie(t){return[t.data.map(e=>e.flat())]}async function Xie(t){if(Ic||await jie(),!Ic)throw new Error("Model not loaded. Call loadModel() first.");const e=qV(Kie(t)),n=Ic.predict(e),s=n.squeeze([0]),r=s.arraySync();return e.dispose(),n.dispose(),s.dispose(),{data:r.map(o=>o.reduce((i,a,l)=>(l%9===0&&i.push(o.slice(l,l+9)),i),[])),cols:ru,rows:Wf}}function DD(t){return t.map(e=>({...e,col:-e.col,row:-e.row}))}function qie(t){const e=ru,n=Wf,s=Array.from({length:n},()=>Array.from({length:e},()=>Array(Object.keys(lr).length+Object.keys(Sc).length).fill(0)));let r=0;for(const o of t)for(let i=0;iu.map(h=>Object.values(lr).map(d=>h[d]))).flat(2),r=Math.min(...s),o=Math.max(...s),i=r+(o-r)*.5;for(let u=0;u[p,t.data[u][h][lr[p]]]).sort((p,g)=>g[1]-p[1]).filter(p=>p[1]>i))==null?void 0:a[0])==null?void 0:l[0],f=(c=Object.keys(Sc).map(p=>[p,t.data[u][h][Sc[p]]]).sort((p,g)=>g[1]-p[1])[0])==null?void 0:c[0];d&&(n[u+","+h]={type:d,command:f})}for(let u=0;u({...o})),s=Uf(n);if(s<=e)return n;let r=s-e;for(n.sort((o,i)=>i.sizeCol*i.sizeRow-o.sizeCol*o.sizeRow);r>0;){let o=!1;for(const i of n)if(i.sizeCol>1&&i.sizeRow>1){const a=i.sizeCol*i.sizeRow-(i.sizeCol-1)*(i.sizeRow-1);if(a<=0)continue;if(a<=r&&(i.sizeCol-=1,i.sizeRow-=1,r-=a,o=!0,r<=0))break}if(!o){for(const i of n)if(i.sizeCol>1&&i.sizeRow>1){if(i.sizeCol/i.sizeRow>=1?(i.sizeCol-=1,r-=i.sizeRow):(i.sizeRow-=1,r-=i.sizeCol),r<=0)break}else if(i.sizeCol>1&&i.sizeRow===1){if(i.sizeCol-=1,r-=i.sizeRow,r<=0)break}else if(i.sizeRow>1&&i.sizeCol===1&&(i.sizeRow-=1,r-=i.sizeCol,r<=0))break;break}}if(r>0){n.sort((o,i)=>i.sizeCol*i.sizeRow-o.sizeCol*o.sizeRow);for(const o of n){for(;r>0;){if(o.sizeCol>1&&o.sizeRow>1)o.sizeCol-=1,o.sizeRow-=1,r-=o.sizeCol+o.sizeRow+1;else if(o.sizeCol>1)o.sizeCol-=1,r-=o.sizeRow;else if(o.sizeRow>1)o.sizeRow-=1,r-=o.sizeCol;else break;if(o.sizeCol<1||o.sizeRow<1){o.sizeCol=Math.max(o.sizeCol,1),o.sizeRow=Math.max(o.sizeRow,1);break}if(r<=0)break}if(r<=0)break}}return n}function Uf(t){return t.reduce((e,n)=>e+n.sizeCol*n.sizeRow,0)}function Zie(t){var u,h,d;if(t.length===0)return[];let e=1/0,n=1/0,s=-1/0,r=-1/0;t.forEach(f=>{e=Math.min(e,f.col),n=Math.min(n,f.row),s=Math.max(s,f.col+f.sizeCol-1),r=Math.max(r,f.row+f.sizeRow-1)});const o=s-e+1,i=r-n+1,a=Array.from({length:i},()=>Array(o).fill(null));t.forEach(f=>{var p;for(let g=f.row;gf.id))+1;for(let f=0;f{const[t,e]=ye.useState([]),n=ye.useCallback(async s=>{let r;try{r=await Jie(s),console.log("Generated counter plan using AI model"),Uf(r)Ox,updateOppositionPlan:n}},tae=({unit:t,position:e,onModifyUnit:n})=>{const[s,r]=ye.useState(null),o=l=>{r(s===l?null:l)},i=l=>{n(t.id,{type:l}),r(null)},a=l=>{n(t.id,l),r(null)};return De.jsxs(sae,{style:{left:e.x,top:e.y},children:[De.jsxs(qk,{onClick:()=>o("type"),children:[De.jsx(rae,{src:K0[t.type],alt:t.type}),s==="type"&&De.jsx(Yk,{children:["warrior","archer","tank","artillery"].map(l=>De.jsx(iae,{src:K0[l],alt:l,onClick:()=>i(l)},l))})]}),De.jsxs(qk,{onClick:()=>o("formation"),children:[De.jsxs(oae,{children:[t.sizeCol,"x",t.sizeRow]}),s==="formation"&&De.jsx(Yk,{children:nae(t.sizeCol,t.sizeRow).map(l=>De.jsxs(aae,{onClick:()=>a(l),children:[l.sizeCol,"x",l.sizeRow]},`${l.sizeCol}x${l.sizeRow}`))})]})]})};function nae(t,e){const n=t*e;return[{sizeCol:n,sizeRow:1},...Array.from({length:n-1},(s,r)=>({sizeCol:r+1,sizeRow:Math.ceil(n/(r+1))})).filter(s=>s.sizeCol*s.sizeRow<=n),{sizeCol:1,sizeRow:n}]}const sae=In.div` position: absolute; display: flex; gap: 10px; @@ -20383,10 +20383,10 @@ return a / b;`,Vse=` `,qk=In.div` position: relative; cursor: pointer; -`,oae=In.img` +`,rae=In.img` width: 32px; height: 32px; -`,iae=In.div` +`,oae=In.div` width: 32px; height: 32px; display: flex; @@ -20421,7 +20421,7 @@ return a / b;`,Vse=` transform: scaleY(1); } } -`,aae=In.img` +`,iae=In.img` width: 24px; height: 24px; cursor: pointer; @@ -20430,7 +20430,7 @@ return a / b;`,Vse=` &:hover { transform: scale(1.1); } -`,lae=In.div` +`,aae=In.div` width: 36px; height: 24px; display: flex; @@ -20447,11 +20447,11 @@ return a / b;`,Vse=` &:hover { background-color: #ddd; } -`,Pg=100,Lg=50,ca=10;function cae(t,e,n,s){const r=e.getBoundingClientRect(),o=(t.col+t.sizeCol/2)*n/(e.width/r.width),i=(t.row+t.sizeRow)*s/(e.height/r.height);let a=o+r.left+r.width/2,l=i+r.top+r.height/2;return a+Pg+ca>r.right&&(a=o-Pg+r.left),l+Lg+ca>r.bottom&&(l=i-Lg+r.top+r.height/2),a=Math.max(r.left+ca,Math.min(a,r.right-Pg-ca)),l=Math.max(r.top+ca,Math.min(l,r.bottom-Lg-ca)),{x:a,y:l}}const uae=({units:t})=>{const e=()=>{};return De.jsx(hae,{children:De.jsx(zx,{width:yi,height:wi,cellWidth:is*(yi/yi),cellHeight:Ur*(wi/wi),units:t,selectedUnitId:null,onCellClick:e,onMouseDown:e,onMouseMove:e,onMouseUp:e,onTouchStart:e,onTouchMove:e,onTouchEnd:e,onModifyUnit:e,isPlayerArea:!1})})},hae=In.div` +`,Pg=100,Lg=50,ca=10;function lae(t,e,n,s){const r=e.getBoundingClientRect(),o=(t.col+t.sizeCol/2)*n/(e.width/r.width),i=(t.row+t.sizeRow)*s/(e.height/r.height);let a=o+r.left+r.width/2,l=i+r.top+r.height/2;return a+Pg+ca>r.right&&(a=o-Pg+r.left),l+Lg+ca>r.bottom&&(l=i-Lg+r.top+r.height/2),a=Math.max(r.left+ca,Math.min(a,r.right-Pg-ca)),l=Math.max(r.top+ca,Math.min(l,r.bottom-Lg-ca)),{x:a,y:l}}const cae=({units:t})=>{const e=()=>{};return De.jsx(uae,{children:De.jsx(zx,{width:yi,height:wi,cellWidth:is*(yi/yi),cellHeight:Ur*(wi/wi),units:t,selectedUnitId:null,onCellClick:e,onMouseDown:e,onMouseMove:e,onMouseUp:e,onTouchStart:e,onTouchMove:e,onTouchEnd:e,onModifyUnit:e,isPlayerArea:!1})})},uae=In.div` width: 100%; height: 50%; position: relative; -`,dae=({onStartBattle:t,initialPlayerUnits:e})=>{const[n,s]=ye.useState([]),[r,o]=ye.useState([]),[i,a]=ye.useState(!1),[l,c]=ye.useState({x:0,y:0}),u=ye.useRef(null),{selectedUnit:h,handleUnitSelect:d,setSelectedUnit:f}=UO(n),{handleDragStart:p,handleDragMove:g,handleDragEnd:x,isDragging:m}=WO(n,s),{generateOppositionPlan:y,updateOppositionPlan:w}=tae();ye.useEffect(()=>{s(e??fae),o(y())},[]);const v=ye.useCallback((k,S)=>{s($=>$.map(N=>N.id===k?{...N,...S}:N)),f($=>($==null?void 0:$.id)===k?{...$,...S}:$)},[]),b=ye.useCallback(async()=>{t(n,await w(n))},[n,r,t]),C=ye.useCallback((k,S)=>{d(k,S)},[d]);return ye.useEffect(()=>{if(m)a(!1);else if(h&&u.current){const k=cae(h,u.current.querySelector('canvas[data-is-player-area="true"]'),is,Ur);c(k),a(!0)}else a(!1)},[m,h]),EO(()=>{w(n).then(o)},1e3,[n]),De.jsxs(pae,{ref:u,children:[De.jsx(uae,{units:r}),De.jsx(mae,{children:De.jsx(zx,{isPlayerArea:!0,width:yi,height:wi,cellWidth:is*(yi/yi),cellHeight:Ur*(wi/wi),units:n,selectedUnitId:(h==null?void 0:h.id)||null,onCellClick:C,onMouseDown:p,onMouseMove:g,onMouseUp:x,onTouchStart:p,onTouchMove:g,onTouchEnd:x,onModifyUnit:v})}),i&&h&&De.jsx(nae,{unit:h,position:l,onModifyUnit:v}),De.jsx(gae,{onClick:b,children:"Start Battle"})]})},fae=DD(Ox),pae=In.div` +`,hae=({onStartBattle:t,initialPlayerUnits:e})=>{const[n,s]=ye.useState([]),[r,o]=ye.useState([]),[i,a]=ye.useState(!1),[l,c]=ye.useState({x:0,y:0}),u=ye.useRef(null),{selectedUnit:h,handleUnitSelect:d,setSelectedUnit:f}=WO(n),{handleDragStart:p,handleDragMove:g,handleDragEnd:x,isDragging:m}=VO(n,s),{generateOppositionPlan:y,updateOppositionPlan:w}=eae();ye.useEffect(()=>{s(e??dae),o(y())},[]);const v=ye.useCallback((k,S)=>{s($=>$.map(N=>N.id===k?{...N,...S}:N)),f($=>($==null?void 0:$.id)===k?{...$,...S}:$)},[]),b=ye.useCallback(async()=>{t(n,await w(n))},[n,r,t]),C=ye.useCallback((k,S)=>{d(k,S)},[d]);return ye.useEffect(()=>{if(m)a(!1);else if(h&&u.current){const k=lae(h,u.current.querySelector('canvas[data-is-player-area="true"]'),is,Ur);c(k),a(!0)}else a(!1)},[m,h]),TO(()=>{w(n).then(o)},1e3,[n]),De.jsxs(fae,{ref:u,children:[De.jsx(cae,{units:r}),De.jsx(pae,{children:De.jsx(zx,{isPlayerArea:!0,width:yi,height:wi,cellWidth:is*(yi/yi),cellHeight:Ur*(wi/wi),units:n,selectedUnitId:(h==null?void 0:h.id)||null,onCellClick:C,onMouseDown:p,onMouseMove:g,onMouseUp:x,onTouchStart:p,onTouchMove:g,onTouchEnd:x,onModifyUnit:v})}),i&&h&&De.jsx(tae,{unit:h,position:l,onModifyUnit:v}),De.jsx(mae,{onClick:b,children:"Start Battle"})]})},dae=DD(Ox),fae=In.div` position: absolute; width: 100%; height: 100%; @@ -20460,10 +20460,10 @@ return a / b;`,Vse=` overflow: hidden; display: flex; flex-direction: column; -`,mae=In.div` +`,pae=In.div` flex: 1; position: relative; -`,gae=In.button` +`,mae=In.button` position: absolute; bottom: 20px; left: 50%; @@ -20475,7 +20475,7 @@ return a / b;`,Vse=` border: none; border-radius: 5px; cursor: pointer; -`;function xae(t,e){const n=new CustomEvent(t,{bubbles:!0,detail:e});document.dispatchEvent(n)}function yae(t,e){ye.useEffect(()=>{const n=s=>{e(s.detail)};return document.addEventListener(t,n,!1),()=>{document.removeEventListener(t,n,!1)}},[t,e])}const wae=GI` +`;function gae(t,e){const n=new CustomEvent(t,{bubbles:!0,detail:e});document.dispatchEvent(n)}function xae(t,e){ye.useEffect(()=>{const n=s=>{e(s.detail)};return document.addEventListener(t,n,!1),()=>{document.removeEventListener(t,n,!1)}},[t,e])}const yae=GI` #game-hud { position: fixed; z-index: 2; @@ -20618,7 +20618,7 @@ canvas#layer-default { pointer-events: none; z-index: 1; } -`;let mt=0;const _D=mt++,FD=mt++,zD=mt++,vae=mt++,bae=mt++,OD=mt++,MD=mt++,Cae=mt++,kae=mt++,Sae=mt++,Iae=mt++,$ae=mt++,PD=mt++,Nae=mt++,Tae=mt++,Eae=mt++,Rae=mt++,Aae=mt++,Dae=mt++,_ae=mt++,Fae=mt++,zae=mt++,Oae=mt++,A1=mt++,D1=mt++,we={EPSILON:Math.pow(2,-16),length:function(t){return Math.sqrt(t[0]*t[0]+t[1]*t[1])},distanceSquared:function(t,e){return Math.pow(t[0]-e[0],2)+Math.pow(t[1]-e[1],2)},distance:function(t,e){return Math.sqrt(this.distanceSquared(t,e))},withinDistance:function(t,e,n){const s=t[0]-e[0],r=t[1]-e[1];if(Math.abs(s)>n||Math.abs(r)>n)return!1;const o=Math.pow(s,2)+Math.pow(r,2);return Math.sqrt(o)1||l>1))return[a,l]},intersectSphereSphere:function(t,e,n,s,r,o){const i=this.sub(e,t),a=this.sub(s,n),l=r+o,c=this.dot(i,i),u=l*l,h=this.dot(a,a);if(h==0)return;const d=2*this.dot(a,i),f=c-u;if(c<=u)return[0,0];let p=d*d-4*h*f;if(p<0)return;p=Math.sqrt(p);const g=(-d-p)/(2*h),x=(-d+p)/(2*h);return g0;){const r=s-1>>1,o=this.values[r];if(n>=o)break;this.ids[s]=this.ids[r],this.values[s]=o,s=r}this.ids[s]=e,this.values[s]=n}pop(){if(this.length===0)return;const e=this.ids[0];if(this.length--,this.length>0){const n=this.ids[0]=this.ids[this.length],s=this.values[0]=this.values[this.length],r=this.length>>1;let o=0;for(;o=s)break;this.ids[o]=l,this.values[o]=c,o=i}this.ids[o]=n,this.values[o]=s}return e}peek(){if(this.length!==0)return this.ids[0]}peekValue(){if(this.length!==0)return this.values[0]}shrink(){this.ids.length=this.values.length=this.length}}const Qk=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array],Bg=3;class Ev{static from(e,n=0){if(n%8!==0)throw new Error("byteOffset must be 8-byte aligned.");if(!e||e.byteLength===void 0||e.buffer)throw new Error("Data must be an instance of ArrayBuffer or SharedArrayBuffer.");const[s,r]=new Uint8Array(e,n+0,2);if(s!==251)throw new Error("Data does not appear to be in a Flatbush format.");const o=r>>4;if(o!==Bg)throw new Error(`Got v${o} data when expected v${Bg}.`);const i=Qk[r&15];if(!i)throw new Error("Unrecognized array type.");const[a]=new Uint16Array(e,n+2,1),[l]=new Uint32Array(e,n+4,1);return new Ev(l,a,i,void 0,e,n)}constructor(e,n=16,s=Float64Array,r=ArrayBuffer,o,i=0){if(e===void 0)throw new Error("Missing required argument: numItems.");if(isNaN(e)||e<=0)throw new Error(`Unexpected numItems value: ${e}.`);this.numItems=+e,this.nodeSize=Math.min(Math.max(+n,2),65535),this.byteOffset=i;let a=e,l=a;this._levelBounds=[a*4];do a=Math.ceil(a/this.nodeSize),l+=a,this._levelBounds.push(l*4);while(a!==1);this.ArrayType=s,this.IndexArrayType=l<16384?Uint16Array:Uint32Array;const c=Qk.indexOf(this.ArrayType),u=l*4*this.ArrayType.BYTES_PER_ELEMENT;if(c<0)throw new Error(`Unexpected typed array class: ${s}.`);o&&o.byteLength!==void 0&&!o.buffer?(this.data=o,this._boxes=new this.ArrayType(this.data,i+8,l*4),this._indices=new this.IndexArrayType(this.data,i+8+u,l),this._pos=l*4,this.minX=this._boxes[this._pos-4],this.minY=this._boxes[this._pos-3],this.maxX=this._boxes[this._pos-2],this.maxY=this._boxes[this._pos-1]):(this.data=new r(8+u+l*this.IndexArrayType.BYTES_PER_ELEMENT),this._boxes=new this.ArrayType(this.data,8,l*4),this._indices=new this.IndexArrayType(this.data,8+u,l),this._pos=0,this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0,new Uint8Array(this.data,0,2).set([251,(Bg<<4)+c]),new Uint16Array(this.data,2,1)[0]=n,new Uint32Array(this.data,4,1)[0]=e),this._queue=new Mae}add(e,n,s=e,r=n){const o=this._pos>>2,i=this._boxes;return this._indices[o]=o,i[this._pos++]=e,i[this._pos++]=n,i[this._pos++]=s,i[this._pos++]=r,ethis.maxX&&(this.maxX=s),r>this.maxY&&(this.maxY=r),o}finish(){if(this._pos>>2!==this.numItems)throw new Error(`Added ${this._pos>>2} items when expected ${this.numItems}.`);const e=this._boxes;if(this.numItems<=this.nodeSize){e[this._pos++]=this.minX,e[this._pos++]=this.minY,e[this._pos++]=this.maxX,e[this._pos++]=this.maxY;return}const n=this.maxX-this.minX||1,s=this.maxY-this.minY||1,r=new Uint32Array(this.numItems),o=65535;for(let i=0,a=0;i>2]=c,e[this._pos++]=u,e[this._pos++]=h,e[this._pos++]=d,e[this._pos++]=f}}}search(e,n,s,r,o){if(this._pos!==this._boxes.length)throw new Error("Data not yet indexed - call index.finish().");let i=this._boxes.length-4;const a=[],l=[];for(;i!==void 0;){const c=Math.min(i+this.nodeSize*4,Jk(i,this._levelBounds));for(let u=i;uthis._boxes[u+2]||n>this._boxes[u+3])continue;const h=this._indices[u>>2]|0;i>=this.numItems*4?a.push(h):(o===void 0||o(h))&&l.push(h)}i=a.pop()}return l}neighbors(e,n,s=1/0,r=1/0,o){if(this._pos!==this._boxes.length)throw new Error("Data not yet indexed - call index.finish().");let i=this._boxes.length-4;const a=this._queue,l=[],c=r*r;e:for(;i!==void 0;){const u=Math.min(i+this.nodeSize*4,Jk(i,this._levelBounds));for(let h=i;h>2]|0,f=Zk(e,this._boxes[h],this._boxes[h+2]),p=Zk(n,this._boxes[h+1],this._boxes[h+3]),g=f*f+p*p;g>c||(i>=this.numItems*4?a.push(d<<1,g):(o===void 0||o(d))&&a.push((d<<1)+1,g))}for(;a.length&&a.peek()&1;)if(a.peekValue()>c||(l.push(a.pop()>>1),l.length===s))break e;i=a.length?a.pop()>>1:void 0}return a.clear(),l}}function Zk(t,e,n){return t>1;e[r]>t?s=r:n=r+1}return e[n]}function _1(t,e,n,s,r,o){if(Math.floor(s/o)>=Math.floor(r/o))return;const i=t[s+r>>1];let a=s-1,l=r+1;for(;;){do a++;while(t[a]i);if(a>=l)break;Pae(t,e,n,a,l)}_1(t,e,n,s,l,o),_1(t,e,n,l+1,r,o)}function Pae(t,e,n,s,r){const o=t[s];t[s]=t[r],t[r]=o;const i=4*s,a=4*r,l=e[i],c=e[i+1],u=e[i+2],h=e[i+3];e[i]=e[a],e[i+1]=e[a+1],e[i+2]=e[a+2],e[i+3]=e[a+3],e[a]=l,e[a+1]=c,e[a+2]=u,e[a+3]=h;const d=n[s];n[s]=n[r],n[r]=d}function Lae(t,e){let n=t^e,s=65535^n,r=65535^(t|e),o=t&(e^65535),i=n|s>>1,a=n>>1^n,l=r>>1^s&o>>1^r,c=n&r>>1^o>>1^o;n=i,s=a,r=l,o=c,i=n&n>>2^s&s>>2,a=n&s>>2^s&(n^s)>>2,l^=n&r>>2^s&o>>2,c^=s&r>>2^(n^s)&o>>2,n=i,s=a,r=l,o=c,i=n&n>>4^s&s>>4,a=n&s>>4^s&(n^s)>>4,l^=n&r>>4^s&o>>4,c^=s&r>>4^(n^s)&o>>4,n=i,s=a,r=l,o=c,l^=n&r>>8^s&o>>8,c^=s&r>>8^(n^s)&o>>8,n=l^l>>1,s=c^c>>1;let u=t^e,h=s|65535^(u|n);return u=(u|u<<8)&16711935,u=(u|u<<4)&252645135,u=(u|u<<2)&858993459,u=(u|u<<1)&1431655765,h=(h|h<<8)&16711935,h=(h|h<<4)&252645135,h=(h|h<<2)&858993459,h=(h|h<<1)&1431655765,(h<<1|u)>>>0}function Bae(t){return{searchSoldiers:eS(t.queryObjects("Soldier")),searchArrows:eS(t.queryObjects("Arrow").filter(e=>e.isHit()))}}function eS(t,e){t=[...t];const n=t.length===0?void 0:new Ev(t.length);for(const o of t)n==null||n.add(o.vec[0],o.vec[1],o.vec[0],o.vec[1]);n==null||n.finish();const s=new Map;return{byRect:o=>(n==null?void 0:n.search(o.left,o.top,o.right,o.bottom).map(i=>t[i]))??[],byRadius:(o,i)=>(n==null?void 0:n.neighbors(o[0],o[1],void 0,i).map(a=>t[a]))??[],byProperty:(o,i)=>{if(!s.has(o)){const a=s.set(o,new Map).get(o);t.forEach(l=>{if(o in l){const c=l[o];a.has(c)||a.set(c,[]),a.get(c).push(l)}})}return s.get(o).get(i)??[]},resetPropertyCache:()=>{s.clear()}}}const Hf=class Hf{constructor(e,n,s,r,o){ee(this,"id");ee(this,"vec");ee(this,"direction");ee(this,"objectWidth");ee(this,"objectHeight");this.id=String(Hf.idCounter++),this.vec=[e,n],this.direction=o,this.objectWidth=s,this.objectHeight=r}getTargetVelocity(){}render(e){e.save().translate(-this.getWidth()/2,-this.getHeight()/2).fillRect(0,0,this.getWidth(),this.getHeight()).restore()}getX(){return this.vec[0]}setX(e){this.vec[0]=e}getY(){return this.vec[1]}setY(e){this.vec[1]=e}getDirection(){return this.direction}setDirection(e){this.direction=e}getWidth(){return this.objectWidth}getHeight(){return this.objectHeight}getClass(){return"Object"}};ee(Hf,"idCounter",0);let ou=Hf;const tS={arrow:[10,1],ball:[10,10]};class LD extends ou{constructor(n,s,r,o,i){super(n[0],n[1],tS[i][0],tS[i][1],we.atan2(n,s));ee(this,"world");ee(this,"from");ee(this,"to");ee(this,"maxDist");ee(this,"attackBase");ee(this,"type");ee(this,"v");ee(this,"adir");ee(this,"ay");this.world=r,this.from=n,this.to=s,this.maxDist=we.distance(n,s),this.attackBase=o,this.type=i,this.v=we.normalize(we.sub(s,n))}update(n){const s=we.scale(this.v,n*20);this.vec[0]+=s[0],this.vec[1]+=s[1];const r=Math.sin(we.distance(this.from,this.vec)/this.maxDist*Math.PI);this.adir=this.direction-Math.PI/3*(1-r),this.ay=this.vec[1]-r*this.maxDist/10,we.distance(this.from,this.vec)>this.maxDist&&this.world.removeObject(this)}getY(){return this.ay}getDirection(){return this.adir}isHit(){return this.maxDist-we.distance(this.from,this.vec)<10}hit(n,s){n.hitByArrow(this,s)}getAttack(){return this.attackBase}getClass(){return"Arrow"}}class Vae extends ou{constructor(n,s,r){super(n[0],n[1],za*2,za*2,0);ee(this,"time");ee(this,"world");this.time=s,this.world=r}render(n){const s=this.world.getTime()-this.time;s<100&&n.save().arc(0,0,za*Math.min(s/100,1)).restore()}update(){}getClass(){return"Explosion"}}class Wae{constructor(e){ee(this,"soldier");ee(this,"velocity",0);ee(this,"targetVelocity",1);ee(this,"force",[0,0]);ee(this,"targetDirection");this.soldier=e,this.targetDirection=e.getDirection()}update(e){this.updateVelocity(e),this.updatePosition(e),this.updateDirection(e),this.updateForce(e)}updateVelocity(e){this.velocity=this.getTargetVelocity()*e+this.velocity*(1-e)}updatePosition(e){this.soldier.setX(this.soldier.getX()+this.force[0]*e),this.soldier.setY(this.soldier.getY()+this.force[1]*e)}updateDirection(e){const n=Math.cos(this.soldier.getDirection())*(1-e),s=Math.sin(this.soldier.getDirection())*(1-e),r=Math.cos(this.targetDirection)*e,o=Math.sin(this.targetDirection)*e;this.soldier.setDirection(Math.atan2(s+o,n+r))}updateForce(e){this.soldier.state.isAlive()&&this.addForce(we.scale([Math.cos(this.soldier.getDirection()),Math.sin(this.soldier.getDirection())],this.velocity*(1-Math.random())*e/2)),this.force=we.sub(this.force,we.scale(this.force,e*.1)),we.length(this.force)0?-.9:10),l=0,c=d.m==1?0:(1-d.m)*(1-d.m)*2e4+32},this.totalReset=function(){this.reset();var d=this._params;return t=d.b*d.b*1e5,e=d.c*d.c*1e5,n=d.e*d.e*1e5+12,((t+e+n)/3|0)*3},this.synthWave=function(d,f){var p=this._params,g=p.s!=1||p.v,x=p.v*p.v*.1,m=1+p.w*3e-4,y=p.s*p.s*p.s*.1,w=1+p.t*1e-4,v=p.s!=1,b=p.x*p.x,C=p.g,k=p.q||p.r,S=p.r*p.r*p.r*.2,$=p.q*p.q*(p.q<0?-1020:1020),N=p.p?((1-p.p)*(1-p.p)*2e4|0)+32:0,A=p.d,M=p.j/2,L=p.k*p.k*.01,V=p.a,B=t,U=1/t,K=1/e,R=1/n,O=5/(1+p.u*p.u*20)*(.01+y);O>.8&&(O=.8),O=1-O;var G=!1,X=0,q=0,Q=0,te=0,Z=0,se,ie=0,ce,ue=0,xe,be=0,ke,He=0,Ne,Me,Be=0,qe=new Array(1024),Ge=new Array(32);for(let Ut=qe.length;Ut--;)qe[Ut]=0;for(let Ut=Ge.length;Ut--;)Ge[Ut]=Math.random()*2-1;for(var Pn=0;Pn=N&&(He=0,this.reset()),c&&++l>=c&&(c=0,s*=a),o+=i,s*=o,s>r&&(s=r,C>0&&(G=!0)),ce=s,M>0&&(Be+=L,ce*=1+Math.sin(Be)*M),ce|=0,ce<8&&(ce=8),V||(u+=h,u<0?u=0:u>.5&&(u=.5)),++q>B)switch(q=0,++X){case 1:B=e;break;case 2:B=n}switch(X){case 0:Q=q*U;break;case 1:Q=1+(1-q*K)*2*A;break;case 2:Q=1-q*R;break;case 3:Q=0,G=!0}k&&($+=S,xe=$|0,xe<0?xe=-xe:xe>1023&&(xe=1023)),g&&m&&(x*=m,x<1e-5?x=1e-5:x>.1&&(x=.1)),Me=0;for(var _t=8;_t--;){if(ue++,ue>=ce&&(ue%=ce,V==3))for(var Fs=Ge.length;Fs--;)Ge[Fs]=Math.random()*2-1;switch(V){case 0:Ne=ue/ce.5?ke-1:ke)*6.28318531,Ne=1.27323954*ke+.405284735*ke*ke*(ke<0?1:-1),Ne=.225*((Ne<0?-1:1)*Ne*Ne-Ne)+Ne;break;case 3:Ne=Ge[Math.abs(ue*32/ce|0)]}g&&(se=ie,y*=w,y<0?y=0:y>.1&&(y=.1),v?(Z+=(Ne-ie)*y,Z*=O):(ie=Ne,Z=0),ie+=Z,te+=ie-se,te*=1-x,Ne=te),k&&(qe[be%1024]=Ne,Ne+=qe[(be-xe+1024)%1024],be++),Me+=Ne}Me*=.125*Q*b,d[Pn]=Me>=1?32767:Me<=-1?-32768:Me*32767|0}return f}}var Vg=new Gae;const Hae=function(t){Vg._params.setSettings(t);var e=Vg.totalReset(),n=new Uint8Array(((e+1)/2|0)*4+44),s=Vg.synthWave(new Uint16Array(n.buffer,44),e)*2,r=new Uint32Array(n.buffer,0,44);r[0]=1179011410,r[1]=s+36,r[2]=1163280727,r[3]=544501094,r[4]=16,r[5]=65537,r[6]=44100,r[7]=88200,r[8]=1048578,r[9]=1635017060,r[10]=s,s+=44;for(var o=0,i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a="data:audio/wav;base64,";o>18]+i[l>>12&63]+i[l>>6&63]+i[l&63]}return a},Wg=typeof window<"u";class jae{constructor(){this.sounds={},Wg&&(this.audioContext=new(window.AudioContext||window.webkitAudioContext))}async add(e,n,s){if(Wg){this.sounds[e]=[];for(let r=0;r1?n[Math.floor(Math.random()*n.length)]:n[0],r=this.audioContext.createBufferSource();r.buffer=s.buffers[s.tick];const o=this.audioContext.createGain();r.connect(o),o.connect(this.audioContext.destination),r.start(0),s.tick0}isDead(){return this.type==="smoke"?this.life<=0:this.life<=0&&this.z<=this.terrain.getHeightAt([this.x,this.y])&&Math.abs(this.velocityX)<.01&&Math.abs(this.velocityY)<.01}}const Ug=typeof window<"u";class Kae{constructor(e,n,s){ee(this,"particles",[]);ee(this,"deadParticlesCanvas");ee(this,"deadParticlesContext");this.terrain=s,Ug&&(this.deadParticlesCanvas=document.createElement("canvas"),this.deadParticlesCanvas.width=e,this.deadParticlesCanvas.height=n,this.deadParticlesContext=this.deadParticlesCanvas.getContext("2d"),this.deadParticlesContext.translate(e/2,n/2))}addParticle(e){Ug&&this.particles.push(e)}update(e){if(!Ug)return;const n=[];this.particles=this.particles.filter(s=>(s.update(e),s.isDead()?(s.type==="blood"&&n.push(s),!1):!0)),this.renderDeadParticles(n)}renderDeadParticles(e){const n=new Path2D;e.forEach(s=>{s.type==="blood"&&(n.moveTo(s.x,s.y-s.z),n.arc(s.x,s.y-s.z,1,0,Math.PI*2),n.closePath())}),this.deadParticlesContext&&(this.deadParticlesContext.fillStyle="rgba(255, 0, 0, 0.5)",this.deadParticlesContext.fill(n))}renderDead(e){this.deadParticlesCanvas&&e.drawImage(this.deadParticlesCanvas,-this.deadParticlesCanvas.width/2,-this.deadParticlesCanvas.height/2)}renderActive(e){e.save();const n=new Path2D,s=new Path2D;this.particles.forEach(r=>{const o=r.type==="smoke"?s:n;o.moveTo(r.x,r.y-r.z),o.arc(r.x,r.y-r.z,r.type==="smoke"?Math.min(r.life,2):1,0,Math.PI*2),o.closePath()}),e.fillStyle("rgba(255, 0, 0, 0.5)"),e.fill(n),e.fillStyle("rgba(128, 128, 128, 0.5)"),e.fill(s),e.restore()}}function Xae([t,e],[n,s],r){const[o,i]=we.scale(we.normalize([t-n,e-s]),5),a=30+Math.random()*10;for(let l=0;le)&&this.clearEnemy(),!this.enemy&&this.soldier.state.cooldown("seek-"+e,zO)&&this.setEnemy(this.queryEnemy(e)),this.enemy){const n=this.enemy.vec,s=we.distance(this.soldier.vec,n),r=we.atan2(this.soldier.vec,n);this.soldier.movement.setTargetDirection(r);let o=0;return this.soldier.state.canCharge&&s>50&&sthis.soldier.state.attackRange?1+o:0),this.soldier.state.rangeAttack&&sFO&&this.soldier.state.cooldown("arrow",this.soldier.state.rangedCooldown)&&(this.soldier.world.addObject(new LD(this.soldier.vec,this.enemy.vec,this.soldier.world,this.soldier.state.rangeAttack,this.soldier.state.rangeType)),pl.play("arrow"),this.soldier.type==="artillery"&&(this.soldier.state.hitBy(50),Xae(this.soldier.vec,this.enemy.vec,this.soldier.world.particles))),ss.isEnemy(this.soldier)&&s.state.life>0&&we.withinDistance(s.vec,this.soldier.vec,e)&&this.soldier.plan.canClaim(s,this.soldier));if(n.length>0){const s=this.soldier.type==="artillery"?(r,o)=>o.distance(this.soldier)>r.distance(this.soldier)?o:r:(r,o)=>o.distance(this.soldier)this.cooldowns[e]?(this.cooldowns[e]=this.soldier.world.getTime()+n,!0):!1}hitBy(e){this.newLife=Math.max(this.newLife-e,0)}isAlive(){return this.life>0}}function Zae(t,e){const n=Math.cos(e),s=Math.sin(e);return t.map(r=>{const o=r.x*n-r.z*s,i=r.x*s+r.z*n;return{x:o,y:r.y,z:i}})}function Jae(t,e=200){const n=e/(e+t.z);return{x:t.x*n,y:t.y*n,z:t.z}}function ele(t,e,n=1){const s=Math.cos(e)*.3+.7,r=parseInt(t.slice(1),16),o=Math.floor((r>>16&255)*s),i=Math.floor((r>>8&255)*s),a=Math.floor((r&255)*s);return`rgba(${o},${i},${a},${n})`}function tle(t,e,n=!0,s){const r=t.getCtx();r.beginPath(),r.moveTo(e[0].x,e[0].y);for(let o=1;oa[1].zIndex-l[1].zIndex);for(const[,a]of i){const c=Zae(a.points,s+Math.PI/2).map(h=>Jae(h)),u=ele(r,s,this.soldier.state.isAlive()?1:.5);n.fillStyle=u,tle(e,c)}n.restore()}}let ale=0;class Fd extends ou{constructor(n,s,r,o,i,a,l){r+=(Math.random()-Math.random())/1e3;super(n,s,is,Ur,r);ee(this,"soldierId");ee(this,"plan");ee(this,"world");ee(this,"type");ee(this,"color");ee(this,"movement");ee(this,"targeting");ee(this,"attack");ee(this,"state");ee(this,"soldierRender");ee(this,"lastAttackTime",0);ee(this,"attackDuration",500);this.soldierId=ale++,this.plan=o,this.world=i,this.type=l,this.color=a,this.movement=new Wae(this),this.targeting=new qae(this),this.attack=new Yae(this),this.state=new Qae(this),this.soldierRender=new ile(this),this.initializeTypeSpecificProperties()}initializeTypeSpecificProperties(){switch(this.type){case"warrior":this.initializeWarrior();break;case"tank":this.initializeTank();break;case"archer":this.initializeArcher();break;case"artillery":this.initializeArtillery();break}}initializeWarrior(){this.state.setProperties({seekRange:tC,attackRange:j0,rangeDefence:30,meleeDefence:50,meleeAttack:25,baseSpeed:3,canCharge:!0,isMelee:!0})}initializeTank(){this.state.setProperties({seekRange:tC,attackRange:j0*1.1,rangeDefence:100,meleeDefence:100,meleeAttack:15,life:hf*2,newLife:hf*2,defenceCooldown:HI/5,weight:3,canCharge:!1,isMelee:!0})}initializeArcher(){this.state.setProperties({seekRange:sC,attackRange:nC,rangeAttack:45,rangeDefence:25,rangedCooldown:rC,meleeDefence:10,meleeAttack:10,rangeType:"arrow"})}initializeArtillery(){this.state.setProperties({seekRange:sC,attackRange:nC*5,weight:10,baseSpeed:.1,rangeAttack:100,rangeDefence:1,rangedCooldown:rC*10,meleeDefence:1,meleeAttack:1,rangeType:"ball"})}update(n){this.state.isAlive()?this.updatePlan():this.targeting.hasEnemy()&&this.targeting.clearEnemy(),this.movement.update(n),this.state.update()}updatePlan(){this.targeting.seekEnemy()||this.plan.getCommand(this.world.getTime()).execute(this)}render(n){this.soldierRender.render(n)}distance(n){return this.movement.distance(n)}hitByArrow(n,s){this.attack.hitByArrow(n,s)}isEnemy(n){return this.plan.masterPlan!==n.plan.masterPlan}getClass(){return"Soldier"}}function lle(t,e,n){let s=0;for(let r=-1;r<=1;r++)for(let o=-1;o<=1;o++){if(r===0&&o===0)continue;const i=e+r,a=n+o;i>=0&&i=0&&a0?1:0)}return s}function cle(t,e){const n=t.map(s=>[...s]);for(let s=0;s0?n[r][o]=i<2||i>4?0:1:n[r][o]=i===3?1:0}return n}function ule(t,e){const n=t.map(s=>[...s]);for(let s=0;s=0&&c=0&&uArray(s+1).fill(0));for(let h=0;h<=r;h++)for(let d=0;d<=s;d++)o[h][d]=(Math.sin(d/s*2*Math.PI*2)*.25+Math.cos(h/r*Math.PI*3)*.25)*n*3;const i=Math.max(...o.flat()),a=Math.min(...o.flat()),l=o.map(h=>h.map(d=>(d-a)/(i-a))),c=cle(l,5);for(let h=0;h<=r;h++)for(let d=0;d<=s;d++)o[h][d]+=c[h][d]*n*.5;return ule(o,.3)}function dle(t){const e=ws*3,n=ws*2,s=hle(e,n,t);return{width:e,height:n,heightMap:s}}const sS={grass:"#6B8E23",dirt:"#D2B48C"};function fle(t,e,n,s=1){const r=Math.min(Math.max(n/50,0),1),o=(Math.cos(e)*.3+.7)*(.8+r*.4),i=parseInt(t.slice(1),16),a=Math.floor((i>>16&255)*o),l=Math.floor((i>>8&255)*o),c=Math.floor((i&255)*o);return`rgba(${a},${l},${c},${s})`}function ple(t,e,n,s){const r=t[n][e],o=t[n][Math.min(e+1,t[0].length-1)],i=t[Math.min(n+1,t.length-1)][e],a=[s,0,o-r],l=[0,s,i-r],c=[l[1]*a[2]-l[2]*a[1],l[2]*a[0]-l[0]*a[2],l[0]*a[1]-l[1]*a[0]],u=Math.sqrt(c[0]*c[0]+c[1]*c[1]+c[2]*c[2]);return[c[0]/u,c[1]/u,c[2]/u]}function mle(t,e,n,s,r){var a,l;const o=Math.ceil(n/r),i=Math.ceil(s/r);for(let c=0;c20?sS.dirt:sS.grass,k=fle(C,v,b);t.beginPath(),t.moveTo(u*r,g),t.lineTo((u+1)*r,x),t.lineTo((u+1)*r,y),t.lineTo(u*r,m),t.closePath(),t.fillStyle=k,t.fill(),t.strokeStyle="rgba(0,0,0,0.1)",t.stroke()}}function gle(t,e,n,s){const r=document.createElement("canvas");r.width=t,r.height=e;const o=r.getContext("2d");return mle(o,n,t,e,s),r}class xle{constructor(){ee(this,"tileSize",32);ee(this,"offsetX",ws*1.5/this.tileSize);ee(this,"offsetY",ws/this.tileSize);ee(this,"terrainCanvas");ee(this,"heightMap");ee(this,"width");ee(this,"height");const{width:e,height:n,heightMap:s}=dle(this.tileSize);this.width=e,this.height=n,this.heightMap=s,this.terrainCanvas=gle(e,n,s,this.tileSize)}render(e){e.drawImage(this.terrainCanvas,0,0)}getHeightAt(e){const n=e[0]/this.tileSize+this.offsetX,s=e[1]/this.tileSize+this.offsetY,r=Math.floor(n),o=Math.min(r+1,this.heightMap[0].length-1),i=Math.floor(s),a=Math.min(i+1,this.heightMap.length-1),l=this.heightMap[i][r],c=this.heightMap[i][o],u=this.heightMap[a][r],h=this.heightMap[a][o],d=n-r,f=s-i,p=l*(1-d)+c*d,g=u*(1-d)+h*d;return p*(1-f)+g*f}}class yle{constructor(){ee(this,"objects");ee(this,"objectsByType");ee(this,"collisionHandlers");ee(this,"edgeRadius");ee(this,"worldTime");ee(this,"particles");ee(this,"terrain");this.objects=[],this.objectsByType={Soldier:[],Arrow:[],Explosion:[]},this.collisionHandlers=[],this.edgeRadius=ws*1.5,this.terrain=new xle,this.particles=new Kae(ws*3,ws*2,this.terrain),this.worldTime=0,this.onCollision(Fd,Fd,this.onSoldierCollision.bind(this)),this.onCollision(Fd,LD,this.onArrowCollision.bind(this))}destroy(){}getTime(){return this.worldTime}getEdgeRadius(){return this.edgeRadius}addObject(...e){for(const n of e)this.objects.push(n),this.objectsByType[n.getClass()].push(n)}removeObject(e){this.objects.splice(this.objects.indexOf(e),1)}queryObjects(e,n){return this.objectsByType[e].filter(s=>!n||n(s))}update(e){const n=Math.min(e,AO);return this.objects.forEach(s=>{this.updateObject(s,n/eC)}),e-=n,this.worldTime+=n,this.collisions(),this.edgeRadius=Math.max(ws*1.5*(1-this.getTime()/6e4),400),this.particles.update(n/eC),e}collisions(){const e=Bae(this),n={},s=this.queryObjects("Arrow",r=>r.isHit());this.queryObjects("Soldier").forEach(r=>{r.state.life<=0||(e.searchSoldiers.byRadius(r.vec,r.getWidth()).forEach(o=>{o.state.life<=0||r===o||n[r.id+o.id]||n[o.id+r.id]||(n[r.id+o.id]=!0,we.withinDistance(r.vec,o.vec,r.getWidth())&&this.triggerCollisions(r,o))}),e.searchArrows.byRadius(r.vec,Math.max(oC,za)).forEach(o=>{o&&we.withinDistance(r.vec,o.vec,o.type==="arrow"?oC:za)&&this.triggerCollisions(r,o)}),we.withinDistance(r.vec,[0,0],this.getEdgeRadius())||r.movement.addForce(we.scale(we.normalize(r.vec),-1)))},this),s.forEach(r=>{this.objects.splice(this.objects.indexOf(r),1),this.objectsByType.Arrow.splice(this.objectsByType.Arrow.indexOf(r),1),r.type==="ball"&&this.addObject(new Vae(r.vec,this.getTime(),this))})}triggerCollisions(e,n){this.collisionHandlers.forEach(function(s){e instanceof s.left&&n instanceof s.right&&s.handler(e,n),n instanceof s.left&&e instanceof s.right&&s.handler(n,e)})}onCollision(e,n,s){this.collisionHandlers.push({left:e,right:n,handler:s})}onSoldierCollision(e,n){const s=we.distance(e.vec,n.vec);if(s===0){const r=we.scale([Math.random()-Math.random(),Math.random()-Math.random()],1/Number.MAX_SAFE_INTEGER);e.movement.addForce(r),n.movement.addForce(we.scale(r,-1))}else{const r=we.scale(we.normalize(we.sub(e.vec,n.vec)),e.getWidth()-s);e.movement.addForce(we.scale(r,1/e.state.weight*n.state.weight)),n.movement.addForce(we.scale(r,-1*e.state.weight/n.state.weight))}}onArrowCollision(e,n){const s=we.distance(n.vec,e.vec);if(n.type==="arrow")n.hit(e,s);else if(n.type==="ball"&&e.state.cooldown("ballhit",150)){n.hit(e,s);const r=we.scale(we.normalize(we.sub(e.vec,n.vec)),e.getWidth()-s);e.movement.addForce(we.scale(r,-.5/e.state.weight*(1-s/za)))}}updateObject(e,n){e.update(n)}getAlive(){return this.queryObjects("Soldier",e=>e.state.life>0).reduce((e,n)=>(e[n.color]=(e[n.color]||0)+1,e),{"#ff0000":0,"#00ff00":0})}getBalance(){const e=this.getAlive(),n=Object.keys(this.getAlive());return e[n[0]]/(e[n[0]]+e[n[1]])}}class Rv{constructor(){ee(this,"startTime",-1);ee(this,"done",!1)}start(e){this.startTime=e}}class F1 extends Rv{constructor(n){super();ee(this,"duration");this.duration=n}isDone(n){return!!this.duration&&this.startTime>=0&&n-this.startTime>this.duration}execute(n){n.movement.setTargetVelocity(0)}}class zd extends Rv{constructor(){super()}getTarget(e){return e.plan.formation}execute(e){const n=this.getTarget(e),s=we.distance(e.vec,n),r=we.atan2(e.vec,n);s>50?(e.movement.setTargetVelocity(1),e.movement.setTargetDirection(r)):(e.movement.setTargetVelocity(0),this.done=!0)}isDone(){return this.done}}class VD extends zd{constructor(n){super();ee(this,"angle");this.angle=n}getTarget(n){return we.add(we.rotate([200,100*Math.sign(Math.cos(this.angle))],this.angle),n.plan.formation)}}class wle extends VD{getTarget(e){return we.add(we.rotate([200,-100*Math.sign(Math.cos(this.angle))],this.angle),e.plan.formation)}}class ua extends Rv{constructor(){super()}execute(e){e.targeting.seekEnemy(ws)||(this.done=!0)}isDone(){return this.done}}class vle{constructor(e,n,s){ee(this,"masterPlan");ee(this,"formation");ee(this,"plan");ee(this,"currentCommand");ee(this,"claims");this.masterPlan=e,this.formation=n,this.plan=s,this.currentCommand=null,this.claims=e.claims}getPosition(){return this.formation}getCommand(e){return(!this.currentCommand||this.currentCommand.isDone(e))&&this.plan.length>0&&(this.currentCommand=this.plan.splice(0,1)[0],this.currentCommand.start(e)),this.currentCommand||(this.currentCommand=new F1),this.currentCommand}canClaim(e,n){if(this.claims[e.soldierId]||(this.claims[e.soldierId]=[]),this.claims[e.soldierId].length<5)return!0;const s=n.distance(e);return this.claims[e.soldierId].filter(o=>o.distance(e)>s).length===this.claims[e.soldierId].length}unclaim(e,n){const s=this.claims[e.soldierId].indexOf(n);s>=0&&this.claims[e.soldierId].splice(s,1)}claim(e,n){return this.canClaim(e,n)?(this.claims[e.soldierId].push(n),!0):!1}}class ble{constructor(e,n){ee(this,"type");ee(this,"formation");ee(this,"plan");ee(this,"claims");const s=we.atan2(e,[0,0]);this.type=[],this.formation=[],this.plan=[],this.claims={},n.forEach(r=>{const o=r.sizeCol*r.sizeRow,i=[r.col*is,r.row*Ur];for(let a=0;a2/3,this.balanceRight.style.width=(1-r)*100+"%",this.balanceRight.dataset.winning=r<1/3}renderResults(e){var n=this.getBalance(e),s="";if(n>1/3&&n<2/3)this.battleResult.innerHTML=`
+`;let mt=0;const _D=mt++,FD=mt++,zD=mt++,wae=mt++,vae=mt++,OD=mt++,MD=mt++,bae=mt++,Cae=mt++,kae=mt++,Sae=mt++,Iae=mt++,PD=mt++,$ae=mt++,Nae=mt++,Tae=mt++,Eae=mt++,Rae=mt++,Aae=mt++,Dae=mt++,_ae=mt++,Fae=mt++,zae=mt++,A1=mt++,D1=mt++,we={EPSILON:Math.pow(2,-16),length:function(t){return Math.sqrt(t[0]*t[0]+t[1]*t[1])},distanceSquared:function(t,e){return Math.pow(t[0]-e[0],2)+Math.pow(t[1]-e[1],2)},distance:function(t,e){return Math.sqrt(this.distanceSquared(t,e))},withinDistance:function(t,e,n){const s=t[0]-e[0],r=t[1]-e[1];if(Math.abs(s)>n||Math.abs(r)>n)return!1;const o=Math.pow(s,2)+Math.pow(r,2);return Math.sqrt(o)1||l>1))return[a,l]},intersectSphereSphere:function(t,e,n,s,r,o){const i=this.sub(e,t),a=this.sub(s,n),l=r+o,c=this.dot(i,i),u=l*l,h=this.dot(a,a);if(h==0)return;const d=2*this.dot(a,i),f=c-u;if(c<=u)return[0,0];let p=d*d-4*h*f;if(p<0)return;p=Math.sqrt(p);const g=(-d-p)/(2*h),x=(-d+p)/(2*h);return g0;){const r=s-1>>1,o=this.values[r];if(n>=o)break;this.ids[s]=this.ids[r],this.values[s]=o,s=r}this.ids[s]=e,this.values[s]=n}pop(){if(this.length===0)return;const e=this.ids[0];if(this.length--,this.length>0){const n=this.ids[0]=this.ids[this.length],s=this.values[0]=this.values[this.length],r=this.length>>1;let o=0;for(;o=s)break;this.ids[o]=l,this.values[o]=c,o=i}this.ids[o]=n,this.values[o]=s}return e}peek(){if(this.length!==0)return this.ids[0]}peekValue(){if(this.length!==0)return this.values[0]}shrink(){this.ids.length=this.values.length=this.length}}const Qk=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array],Bg=3;class Ev{static from(e,n=0){if(n%8!==0)throw new Error("byteOffset must be 8-byte aligned.");if(!e||e.byteLength===void 0||e.buffer)throw new Error("Data must be an instance of ArrayBuffer or SharedArrayBuffer.");const[s,r]=new Uint8Array(e,n+0,2);if(s!==251)throw new Error("Data does not appear to be in a Flatbush format.");const o=r>>4;if(o!==Bg)throw new Error(`Got v${o} data when expected v${Bg}.`);const i=Qk[r&15];if(!i)throw new Error("Unrecognized array type.");const[a]=new Uint16Array(e,n+2,1),[l]=new Uint32Array(e,n+4,1);return new Ev(l,a,i,void 0,e,n)}constructor(e,n=16,s=Float64Array,r=ArrayBuffer,o,i=0){if(e===void 0)throw new Error("Missing required argument: numItems.");if(isNaN(e)||e<=0)throw new Error(`Unexpected numItems value: ${e}.`);this.numItems=+e,this.nodeSize=Math.min(Math.max(+n,2),65535),this.byteOffset=i;let a=e,l=a;this._levelBounds=[a*4];do a=Math.ceil(a/this.nodeSize),l+=a,this._levelBounds.push(l*4);while(a!==1);this.ArrayType=s,this.IndexArrayType=l<16384?Uint16Array:Uint32Array;const c=Qk.indexOf(this.ArrayType),u=l*4*this.ArrayType.BYTES_PER_ELEMENT;if(c<0)throw new Error(`Unexpected typed array class: ${s}.`);o&&o.byteLength!==void 0&&!o.buffer?(this.data=o,this._boxes=new this.ArrayType(this.data,i+8,l*4),this._indices=new this.IndexArrayType(this.data,i+8+u,l),this._pos=l*4,this.minX=this._boxes[this._pos-4],this.minY=this._boxes[this._pos-3],this.maxX=this._boxes[this._pos-2],this.maxY=this._boxes[this._pos-1]):(this.data=new r(8+u+l*this.IndexArrayType.BYTES_PER_ELEMENT),this._boxes=new this.ArrayType(this.data,8,l*4),this._indices=new this.IndexArrayType(this.data,8+u,l),this._pos=0,this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0,new Uint8Array(this.data,0,2).set([251,(Bg<<4)+c]),new Uint16Array(this.data,2,1)[0]=n,new Uint32Array(this.data,4,1)[0]=e),this._queue=new Oae}add(e,n,s=e,r=n){const o=this._pos>>2,i=this._boxes;return this._indices[o]=o,i[this._pos++]=e,i[this._pos++]=n,i[this._pos++]=s,i[this._pos++]=r,ethis.maxX&&(this.maxX=s),r>this.maxY&&(this.maxY=r),o}finish(){if(this._pos>>2!==this.numItems)throw new Error(`Added ${this._pos>>2} items when expected ${this.numItems}.`);const e=this._boxes;if(this.numItems<=this.nodeSize){e[this._pos++]=this.minX,e[this._pos++]=this.minY,e[this._pos++]=this.maxX,e[this._pos++]=this.maxY;return}const n=this.maxX-this.minX||1,s=this.maxY-this.minY||1,r=new Uint32Array(this.numItems),o=65535;for(let i=0,a=0;i>2]=c,e[this._pos++]=u,e[this._pos++]=h,e[this._pos++]=d,e[this._pos++]=f}}}search(e,n,s,r,o){if(this._pos!==this._boxes.length)throw new Error("Data not yet indexed - call index.finish().");let i=this._boxes.length-4;const a=[],l=[];for(;i!==void 0;){const c=Math.min(i+this.nodeSize*4,Jk(i,this._levelBounds));for(let u=i;uthis._boxes[u+2]||n>this._boxes[u+3])continue;const h=this._indices[u>>2]|0;i>=this.numItems*4?a.push(h):(o===void 0||o(h))&&l.push(h)}i=a.pop()}return l}neighbors(e,n,s=1/0,r=1/0,o){if(this._pos!==this._boxes.length)throw new Error("Data not yet indexed - call index.finish().");let i=this._boxes.length-4;const a=this._queue,l=[],c=r*r;e:for(;i!==void 0;){const u=Math.min(i+this.nodeSize*4,Jk(i,this._levelBounds));for(let h=i;h>2]|0,f=Zk(e,this._boxes[h],this._boxes[h+2]),p=Zk(n,this._boxes[h+1],this._boxes[h+3]),g=f*f+p*p;g>c||(i>=this.numItems*4?a.push(d<<1,g):(o===void 0||o(d))&&a.push((d<<1)+1,g))}for(;a.length&&a.peek()&1;)if(a.peekValue()>c||(l.push(a.pop()>>1),l.length===s))break e;i=a.length?a.pop()>>1:void 0}return a.clear(),l}}function Zk(t,e,n){return t>1;e[r]>t?s=r:n=r+1}return e[n]}function _1(t,e,n,s,r,o){if(Math.floor(s/o)>=Math.floor(r/o))return;const i=t[s+r>>1];let a=s-1,l=r+1;for(;;){do a++;while(t[a]i);if(a>=l)break;Mae(t,e,n,a,l)}_1(t,e,n,s,l,o),_1(t,e,n,l+1,r,o)}function Mae(t,e,n,s,r){const o=t[s];t[s]=t[r],t[r]=o;const i=4*s,a=4*r,l=e[i],c=e[i+1],u=e[i+2],h=e[i+3];e[i]=e[a],e[i+1]=e[a+1],e[i+2]=e[a+2],e[i+3]=e[a+3],e[a]=l,e[a+1]=c,e[a+2]=u,e[a+3]=h;const d=n[s];n[s]=n[r],n[r]=d}function Pae(t,e){let n=t^e,s=65535^n,r=65535^(t|e),o=t&(e^65535),i=n|s>>1,a=n>>1^n,l=r>>1^s&o>>1^r,c=n&r>>1^o>>1^o;n=i,s=a,r=l,o=c,i=n&n>>2^s&s>>2,a=n&s>>2^s&(n^s)>>2,l^=n&r>>2^s&o>>2,c^=s&r>>2^(n^s)&o>>2,n=i,s=a,r=l,o=c,i=n&n>>4^s&s>>4,a=n&s>>4^s&(n^s)>>4,l^=n&r>>4^s&o>>4,c^=s&r>>4^(n^s)&o>>4,n=i,s=a,r=l,o=c,l^=n&r>>8^s&o>>8,c^=s&r>>8^(n^s)&o>>8,n=l^l>>1,s=c^c>>1;let u=t^e,h=s|65535^(u|n);return u=(u|u<<8)&16711935,u=(u|u<<4)&252645135,u=(u|u<<2)&858993459,u=(u|u<<1)&1431655765,h=(h|h<<8)&16711935,h=(h|h<<4)&252645135,h=(h|h<<2)&858993459,h=(h|h<<1)&1431655765,(h<<1|u)>>>0}function Lae(t){return{searchSoldiers:eS(t.queryObjects("Soldier")),searchArrows:eS(t.queryObjects("Arrow").filter(e=>e.isHit()))}}function eS(t,e){t=[...t];const n=t.length===0?void 0:new Ev(t.length);for(const o of t)n==null||n.add(o.vec[0],o.vec[1],o.vec[0],o.vec[1]);n==null||n.finish();const s=new Map;return{byRect:o=>(n==null?void 0:n.search(o.left,o.top,o.right,o.bottom).map(i=>t[i]))??[],byRadius:(o,i)=>(n==null?void 0:n.neighbors(o[0],o[1],void 0,i).map(a=>t[a]))??[],byProperty:(o,i)=>{if(!s.has(o)){const a=s.set(o,new Map).get(o);t.forEach(l=>{if(o in l){const c=l[o];a.has(c)||a.set(c,[]),a.get(c).push(l)}})}return s.get(o).get(i)??[]},resetPropertyCache:()=>{s.clear()}}}const Gf=class Gf{constructor(e,n,s,r,o,i){ee(this,"id");ee(this,"vec");ee(this,"direction");ee(this,"objectWidth");ee(this,"objectHeight");ee(this,"world");this.id=String(Gf.idCounter++),this.vec=[e,n],this.direction=o,this.objectWidth=s,this.objectHeight=r,this.world=i}getTargetVelocity(){}render(e){e.addObjectCommand(this.getZ(),this.getY(),!0,"red",n=>{n.fillRect(-this.getWidth()/2+this.getX(),-this.getHeight()/2+this.getY()-this.getZ(),this.getWidth(),this.getHeight())})}getX(){return this.vec[0]}setX(e){this.vec[0]=e}getY(){return this.vec[1]}setY(e){this.vec[1]=e}getZ(){return this.world.terrain.getHeightAt(this.vec)}getDirection(){return this.direction}setDirection(e){this.direction=e}getWidth(){return this.objectWidth}getHeight(){return this.objectHeight}getClass(){return"Object"}};ee(Gf,"idCounter",0);let ou=Gf;const tS={arrow:[10,1],ball:[10,10]};class LD extends ou{constructor(n,s,r,o,i){super(n[0],n[1],tS[i][0],tS[i][1],we.atan2(n,s),r);ee(this,"from");ee(this,"to");ee(this,"maxDist");ee(this,"attackBase");ee(this,"type");ee(this,"v");ee(this,"adir");ee(this,"ay");this.from=n,this.to=s,this.maxDist=we.distance(n,s),this.attackBase=o,this.type=i,this.v=we.normalize(we.sub(s,n))}update(n){const s=we.scale(this.v,n*20);this.vec[0]+=s[0],this.vec[1]+=s[1];const r=Math.sin(we.distance(this.from,this.vec)/this.maxDist*Math.PI);this.adir=this.direction-Math.PI/3*(1-r),this.ay=this.vec[1]-r*this.maxDist/10,we.distance(this.from,this.vec)>this.maxDist&&this.world.removeObject(this)}render(n){n.addObjectCommand(this.getZ(),this.getY(),!0,"red",s=>{s.save().translate(this.getX(),this.getY()-this.getZ()).rotate(this.getDirection()).fillRect(-this.getWidth()/2,-this.getHeight()/2,this.getWidth(),this.getHeight()).restore()})}getY(){return this.ay}getDirection(){return this.adir}isHit(){return this.maxDist-we.distance(this.from,this.vec)<10}hit(n,s){n.hitByArrow(this,s)}getAttack(){return this.attackBase}getClass(){return"Arrow"}}class Bae extends ou{constructor(n,s,r){super(n[0],n[1],za*2,za*2,0,r);ee(this,"time");this.time=s}render(n){const s=this.world.getTime()-this.time;s<100&&n.addObjectCommand(this.getZ(),this.getY(),!0,"black",r=>{r.save().strokeStyle("black").translate(this.getX(),this.getY()-this.getZ()).arc(0,0,za*Math.min(s/100,1)).restore()})}update(){}getClass(){return"Explosion"}}class Vae{constructor(e){ee(this,"soldier");ee(this,"velocity",0);ee(this,"targetVelocity",1);ee(this,"force",[0,0]);ee(this,"targetDirection");this.soldier=e,this.targetDirection=e.getDirection()}update(e){this.updateVelocity(e),this.updatePosition(e),this.updateDirection(e),this.updateForce(e)}updateVelocity(e){this.velocity=this.getTargetVelocity()*e+this.velocity*(1-e)}updatePosition(e){this.soldier.setX(this.soldier.getX()+this.force[0]*e),this.soldier.setY(this.soldier.getY()+this.force[1]*e)}updateDirection(e){const n=Math.cos(this.soldier.getDirection())*(1-e),s=Math.sin(this.soldier.getDirection())*(1-e),r=Math.cos(this.targetDirection)*e,o=Math.sin(this.targetDirection)*e;this.soldier.setDirection(Math.atan2(s+o,n+r))}updateForce(e){this.soldier.state.isAlive()&&this.addForce(we.scale([Math.cos(this.soldier.getDirection()),Math.sin(this.soldier.getDirection())],this.velocity*(1-Math.random())*e/2)),this.force=we.sub(this.force,we.scale(this.force,e*.1)),we.length(this.force)0?-.9:10),l=0,c=d.m==1?0:(1-d.m)*(1-d.m)*2e4+32},this.totalReset=function(){this.reset();var d=this._params;return t=d.b*d.b*1e5,e=d.c*d.c*1e5,n=d.e*d.e*1e5+12,((t+e+n)/3|0)*3},this.synthWave=function(d,f){var p=this._params,g=p.s!=1||p.v,x=p.v*p.v*.1,m=1+p.w*3e-4,y=p.s*p.s*p.s*.1,w=1+p.t*1e-4,v=p.s!=1,b=p.x*p.x,C=p.g,k=p.q||p.r,S=p.r*p.r*p.r*.2,$=p.q*p.q*(p.q<0?-1020:1020),N=p.p?((1-p.p)*(1-p.p)*2e4|0)+32:0,A=p.d,M=p.j/2,L=p.k*p.k*.01,V=p.a,B=t,U=1/t,K=1/e,R=1/n,O=5/(1+p.u*p.u*20)*(.01+y);O>.8&&(O=.8),O=1-O;var G=!1,X=0,q=0,Q=0,te=0,Z=0,se,ie=0,ce,ue=0,xe,be=0,ke,He=0,Ne,Me,Be=0,qe=new Array(1024),Ge=new Array(32);for(let Ut=qe.length;Ut--;)qe[Ut]=0;for(let Ut=Ge.length;Ut--;)Ge[Ut]=Math.random()*2-1;for(var Pn=0;Pn=N&&(He=0,this.reset()),c&&++l>=c&&(c=0,s*=a),o+=i,s*=o,s>r&&(s=r,C>0&&(G=!0)),ce=s,M>0&&(Be+=L,ce*=1+Math.sin(Be)*M),ce|=0,ce<8&&(ce=8),V||(u+=h,u<0?u=0:u>.5&&(u=.5)),++q>B)switch(q=0,++X){case 1:B=e;break;case 2:B=n}switch(X){case 0:Q=q*U;break;case 1:Q=1+(1-q*K)*2*A;break;case 2:Q=1-q*R;break;case 3:Q=0,G=!0}k&&($+=S,xe=$|0,xe<0?xe=-xe:xe>1023&&(xe=1023)),g&&m&&(x*=m,x<1e-5?x=1e-5:x>.1&&(x=.1)),Me=0;for(var _t=8;_t--;){if(ue++,ue>=ce&&(ue%=ce,V==3))for(var Fs=Ge.length;Fs--;)Ge[Fs]=Math.random()*2-1;switch(V){case 0:Ne=ue/ce.5?ke-1:ke)*6.28318531,Ne=1.27323954*ke+.405284735*ke*ke*(ke<0?1:-1),Ne=.225*((Ne<0?-1:1)*Ne*Ne-Ne)+Ne;break;case 3:Ne=Ge[Math.abs(ue*32/ce|0)]}g&&(se=ie,y*=w,y<0?y=0:y>.1&&(y=.1),v?(Z+=(Ne-ie)*y,Z*=O):(ie=Ne,Z=0),ie+=Z,te+=ie-se,te*=1-x,Ne=te),k&&(qe[be%1024]=Ne,Ne+=qe[(be-xe+1024)%1024],be++),Me+=Ne}Me*=.125*Q*b,d[Pn]=Me>=1?32767:Me<=-1?-32768:Me*32767|0}return f}}var Vg=new Uae;const Gae=function(t){Vg._params.setSettings(t);var e=Vg.totalReset(),n=new Uint8Array(((e+1)/2|0)*4+44),s=Vg.synthWave(new Uint16Array(n.buffer,44),e)*2,r=new Uint32Array(n.buffer,0,44);r[0]=1179011410,r[1]=s+36,r[2]=1163280727,r[3]=544501094,r[4]=16,r[5]=65537,r[6]=44100,r[7]=88200,r[8]=1048578,r[9]=1635017060,r[10]=s,s+=44;for(var o=0,i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a="data:audio/wav;base64,";o>18]+i[l>>12&63]+i[l>>6&63]+i[l&63]}return a},Wg=typeof window<"u";class Hae{constructor(){this.sounds={},Wg&&(this.audioContext=new(window.AudioContext||window.webkitAudioContext))}async add(e,n,s){if(Wg){this.sounds[e]=[];for(let r=0;r1?n[Math.floor(Math.random()*n.length)]:n[0],r=this.audioContext.createBufferSource();r.buffer=s.buffers[s.tick];const o=this.audioContext.createGain();r.connect(o),o.connect(this.audioContext.destination),r.start(0),s.tick0}isDead(){return this.life<=0}}const Ug=typeof window<"u";class jae{constructor(e,n,s){ee(this,"particles",[]);ee(this,"deadParticlesCanvas");ee(this,"deadParticlesContext");this.terrain=s,Ug&&(this.deadParticlesCanvas=document.createElement("canvas"),this.deadParticlesCanvas.width=e,this.deadParticlesCanvas.height=n,this.deadParticlesContext=this.deadParticlesCanvas.getContext("2d"),this.deadParticlesContext.translate(e/2,n/2))}addParticle(e){Ug&&this.particles.push(e)}update(e){if(!Ug)return;const n=[];this.particles=this.particles.filter(s=>(s.update(e),s.isDead()?(s.type==="blood"&&n.push(s),!1):!0)),this.renderDeadParticles(n)}renderDeadParticles(e){const n=new Path2D;e.forEach(s=>{s.type==="blood"&&(n.moveTo(s.x,s.y-s.z),n.arc(s.x,s.y-s.z,1,0,Math.PI*2),n.closePath())}),this.deadParticlesContext&&(this.deadParticlesContext.fillStyle="rgba(255, 0, 0, 0.5)",this.deadParticlesContext.fill(n))}renderDead(e){this.deadParticlesCanvas&&e.drawImage(this.deadParticlesCanvas,-this.deadParticlesCanvas.width/2,-this.deadParticlesCanvas.height/2)}addRenderCommands(e){const n=this.particles.filter(r=>r.type==="blood"),s=this.particles.filter(r=>r.type==="smoke");n.length>0&&n.forEach(r=>{e.addParticleCommand(r.z,r.y,"rgba(255, 0, 0, 0.5)",o=>{const i=new Path2D;i.moveTo(r.x,r.y-r.z),i.arc(r.x,r.y-r.z,1,0,Math.PI*2),i.closePath(),o.fill(i)})}),s.length>0&&s.forEach(r=>{e.addParticleCommand(r.z,r.y,"rgba(128, 128, 128, 0.5)",o=>{const i=new Path2D;i.moveTo(r.x,r.y-r.z),i.arc(r.x,r.y-r.z,Math.min(r.life,2),0,Math.PI*2),i.closePath(),o.fill(i)})})}}function Kae([t,e],[n,s],r){const[o,i]=we.scale(we.normalize([t-n,e-s]),5),a=3+Math.random()*2;for(let l=0;le)&&this.clearEnemy(),!this.enemy&&this.soldier.state.cooldown("seek-"+e,FO)&&this.setEnemy(this.queryEnemy(e)),this.enemy){const n=this.enemy.vec,s=we.distance(this.soldier.vec,n),r=we.atan2(this.soldier.vec,n);this.soldier.movement.setTargetDirection(r);let o=0;return this.soldier.state.canCharge&&s>50&&sthis.soldier.state.attackRange?1+o:0),this.soldier.state.rangeAttack&&s_O&&this.soldier.state.cooldown("arrow",this.soldier.state.rangedCooldown)&&(this.soldier.world.addObject(new LD(this.soldier.vec,this.enemy.vec,this.soldier.world,this.soldier.state.rangeAttack,this.soldier.state.rangeType)),pl.play("arrow"),this.soldier.type==="artillery"&&(this.soldier.state.hitBy(50),Kae(this.soldier.vec,this.enemy.vec,this.soldier.world.particles))),ss.isEnemy(this.soldier)&&s.state.life>0&&we.withinDistance(s.vec,this.soldier.vec,e)&&this.soldier.plan.canClaim(s,this.soldier));if(n.length>0){const s=this.soldier.type==="artillery"?(r,o)=>o.distance(this.soldier)>r.distance(this.soldier)?o:r:(r,o)=>o.distance(this.soldier)this.cooldowns[e]?(this.cooldowns[e]=this.soldier.world.getTime()+n,!0):!1}hitBy(e){this.newLife=Math.max(this.newLife-e,0)}isAlive(){return this.life>0}}function Qae(t,e){const n=Math.cos(e),s=Math.sin(e);return t.map(r=>{const o=r.x*n-r.z*s,i=r.x*s+r.z*n;return{x:o,y:r.y,z:i}})}function Zae(t,e=200){const n=e/(e+t.z);return{x:t.x*n,y:t.y*n,z:t.z}}function Jae(t,e,n=1){const s=Math.cos(e)*.3+.7,r=parseInt(t.slice(1),16),o=Math.floor((r>>16&255)*s),i=Math.floor((r>>8&255)*s),a=Math.floor((r&255)*s);return`rgba(${o},${i},${a},${n})`}function ele(t,e,n,s,r=!0){const o=n.getCtx();o.beginPath(),o.moveTo(s[0].x+t,s[0].y+e);for(let i=1;i{o.save().translate(this.soldier.getX(),this.soldier.getY()-this.soldier.getZ()),nle(o,this.soldier),o.restore()}),this.renderSoldier(e)}renderSoldier(e){const n=this.soldier.state.isAlive(),s=n?this.soldier.getDirection():Math.PI/2,r=n?this.unitColor:"#808080",o=n?this.shapes:this.fallenShapes,i=Object.entries(o).sort((a,l)=>a[1].zIndex-l[1].zIndex);for(const[,a]of i){const c=Qae(a.points,s+Math.PI/2).map(h=>Zae(h)),u=Jae(r,s,this.soldier.state.isAlive()?1:.5);e.addObjectCommand(this.soldier.getZ(),this.soldier.getY(),n,u,h=>{ele(this.soldier.getX(),this.soldier.getY()-this.soldier.getZ()+(n?0:this.soldier.getHeight()/2),h,c)})}}}let ile=0;class _d extends ou{constructor(n,s,r,o,i,a,l){r+=(Math.random()-Math.random())/1e3;super(n,s,is,Ur,r,i);ee(this,"soldierId");ee(this,"plan");ee(this,"type");ee(this,"color");ee(this,"movement");ee(this,"targeting");ee(this,"attack");ee(this,"state");ee(this,"soldierRender");ee(this,"lastAttackTime",0);ee(this,"attackDuration",500);this.soldierId=ile++,this.plan=o,this.type=l,this.color=a,this.movement=new Vae(this),this.targeting=new Xae(this),this.attack=new qae(this),this.state=new Yae(this),this.soldierRender=new ole(this),this.initializeTypeSpecificProperties()}initializeTypeSpecificProperties(){switch(this.type){case"warrior":this.initializeWarrior();break;case"tank":this.initializeTank();break;case"archer":this.initializeArcher();break;case"artillery":this.initializeArtillery();break}}initializeWarrior(){this.state.setProperties({seekRange:tC,attackRange:j0,rangeDefence:30,meleeDefence:50,meleeAttack:25,baseSpeed:3,canCharge:!0,isMelee:!0})}initializeTank(){this.state.setProperties({seekRange:tC,attackRange:j0*1.1,rangeDefence:100,meleeDefence:100,meleeAttack:15,life:uf*2,newLife:uf*2,defenceCooldown:HI/5,weight:3,canCharge:!1,isMelee:!0})}initializeArcher(){this.state.setProperties({seekRange:sC,attackRange:nC,rangeAttack:45,rangeDefence:25,rangedCooldown:rC,meleeDefence:10,meleeAttack:10,rangeType:"arrow"})}initializeArtillery(){this.state.setProperties({seekRange:sC,attackRange:nC*5,weight:10,baseSpeed:.1,rangeAttack:100,rangeDefence:1,rangedCooldown:rC*10,meleeDefence:1,meleeAttack:1,rangeType:"ball"})}update(n){this.state.isAlive()?this.updatePlan():this.targeting.hasEnemy()&&this.targeting.clearEnemy(),this.movement.update(n),this.state.update()}updatePlan(){this.targeting.seekEnemy()||this.plan.getCommand(this.world.getTime()).execute(this)}render(n){this.soldierRender.addRenderCommands(n)}distance(n){return this.movement.distance(n)}hitByArrow(n,s){this.attack.hitByArrow(n,s)}isEnemy(n){return this.plan.masterPlan!==n.plan.masterPlan}getClass(){return"Soldier"}}function ale(t,e,n){let s=0;for(let r=-1;r<=1;r++)for(let o=-1;o<=1;o++){if(r===0&&o===0)continue;const i=e+r,a=n+o;i>=0&&i=0&&a0?1:0)}return s}function lle(t,e){const n=t.map(s=>[...s]);for(let s=0;s0?n[r][o]=i<2||i>4?0:1:n[r][o]=i===3?1:0}return n}function cle(t,e){const n=t.map(s=>[...s]);for(let s=0;s=0&&c=0&&uArray(s+1).fill(0));for(let h=0;h<=r;h++)for(let d=0;d<=s;d++)o[h][d]=(Math.sin(d/s*2*Math.PI*2)*.25+Math.cos(h/r*Math.PI*3)*.25)*n*3;const i=Math.max(...o.flat()),a=Math.min(...o.flat()),l=o.map(h=>h.map(d=>(d-a)/(i-a))),c=lle(l,5);for(let h=0;h<=r;h++)for(let d=0;d<=s;d++)o[h][d]+=c[h][d]*n*.5;return cle(o,.3)}function hle(t){const e=ws*3,n=ws*2,s=ule(e,n,t);return{width:e,height:n,heightMap:s}}const sS={grass:"#6B8E23",dirt:"#D2B48C"};function dle(t,e,n,s=1){const r=Math.min(Math.max(n/50,0),1),o=(Math.cos(e)*.3+.7)*(.8+r*.4),i=parseInt(t.slice(1),16),a=Math.floor((i>>16&255)*o),l=Math.floor((i>>8&255)*o),c=Math.floor((i&255)*o);return`rgba(${a},${l},${c},${s})`}function fle(t,e,n,s){const r=t[n][e],o=t[n][Math.min(e+1,t[0].length-1)],i=t[Math.min(n+1,t.length-1)][e],a=[s,0,o-r],l=[0,s,i-r],c=[l[1]*a[2]-l[2]*a[1],l[2]*a[0]-l[0]*a[2],l[0]*a[1]-l[1]*a[0]],u=Math.sqrt(c[0]*c[0]+c[1]*c[1]+c[2]*c[2]);return[c[0]/u,c[1]/u,c[2]/u]}function ple(t,e,n,s,r){var a,l;const o=Math.ceil(n/r),i=Math.ceil(s/r);for(let c=0;c20?sS.dirt:sS.grass,k=dle(C,v,b);t.beginPath(),t.moveTo(u*r,g),t.lineTo((u+1)*r,x),t.lineTo((u+1)*r,y),t.lineTo(u*r,m),t.closePath(),t.fillStyle=k,t.fill(),t.strokeStyle="rgba(0,0,0,0.1)",t.stroke()}}function mle(t,e,n,s){const r=document.createElement("canvas");r.width=t,r.height=e;const o=r.getContext("2d");return ple(o,n,t,e,s),r}class gle{constructor(){ee(this,"tileSize",32);ee(this,"offsetX",ws*1.5/this.tileSize);ee(this,"offsetY",ws/this.tileSize);ee(this,"terrainCanvas");ee(this,"heightMap");ee(this,"width");ee(this,"height");const{width:e,height:n,heightMap:s}=hle(this.tileSize);this.width=e,this.height=n,this.heightMap=s,this.terrainCanvas=mle(e,n,s,this.tileSize)}render(e){e.drawImage(this.terrainCanvas,0,0)}getHeightAt(e){const n=e[0]/this.tileSize+this.offsetX,s=e[1]/this.tileSize+this.offsetY,r=Math.floor(n),o=Math.min(r+1,this.heightMap[0].length-1),i=Math.floor(s),a=Math.min(i+1,this.heightMap.length-1),l=this.heightMap[i][r],c=this.heightMap[i][o],u=this.heightMap[a][r],h=this.heightMap[a][o],d=n-r,f=s-i,p=l*(1-d)+c*d,g=u*(1-d)+h*d;return p*(1-f)+g*f}}class xle{constructor(){ee(this,"objects");ee(this,"objectsByType");ee(this,"collisionHandlers");ee(this,"edgeRadius");ee(this,"worldTime");ee(this,"particles");ee(this,"terrain");this.objects=[],this.objectsByType={Soldier:[],Arrow:[],Explosion:[]},this.collisionHandlers=[],this.edgeRadius=ws*1.5,this.terrain=new gle,this.particles=new jae(ws*3,ws*2,this.terrain),this.worldTime=0,this.onCollision(_d,_d,this.onSoldierCollision.bind(this)),this.onCollision(_d,LD,this.onArrowCollision.bind(this))}destroy(){}getTime(){return this.worldTime}getEdgeRadius(){return this.edgeRadius}addObject(...e){for(const n of e)this.objects.push(n),this.objectsByType[n.getClass()].push(n)}removeObject(e){this.objects.splice(this.objects.indexOf(e),1)}queryObjects(e,n){return this.objectsByType[e].filter(s=>!n||n(s))}update(e){const n=Math.min(e,RO);return this.objects.forEach(s=>{this.updateObject(s,n/eC)}),e-=n,this.worldTime+=n,this.collisions(),this.edgeRadius=Math.max(ws*1.5*(1-this.getTime()/6e4),400),this.particles.update(n/eC),e}collisions(){const e=Lae(this),n={},s=this.queryObjects("Arrow",r=>r.isHit());this.queryObjects("Soldier").forEach(r=>{r.state.life<=0||(e.searchSoldiers.byRadius(r.vec,r.getWidth()).forEach(o=>{o.state.life<=0||r===o||n[r.id+o.id]||n[o.id+r.id]||(n[r.id+o.id]=!0,we.withinDistance(r.vec,o.vec,r.getWidth())&&this.triggerCollisions(r,o))}),e.searchArrows.byRadius(r.vec,Math.max(oC,za)).forEach(o=>{o&&we.withinDistance(r.vec,o.vec,o.type==="arrow"?oC:za)&&this.triggerCollisions(r,o)}),we.withinDistance(r.vec,[0,0],this.getEdgeRadius())||r.movement.addForce(we.scale(we.normalize(r.vec),-1)))},this),s.forEach(r=>{this.objects.splice(this.objects.indexOf(r),1),this.objectsByType.Arrow.splice(this.objectsByType.Arrow.indexOf(r),1),r.type==="ball"&&this.addObject(new Bae(r.vec,this.getTime(),this))})}triggerCollisions(e,n){this.collisionHandlers.forEach(function(s){e instanceof s.left&&n instanceof s.right&&s.handler(e,n),n instanceof s.left&&e instanceof s.right&&s.handler(n,e)})}onCollision(e,n,s){this.collisionHandlers.push({left:e,right:n,handler:s})}onSoldierCollision(e,n){const s=we.distance(e.vec,n.vec);if(s===0){const r=we.scale([Math.random()-Math.random(),Math.random()-Math.random()],1/Number.MAX_SAFE_INTEGER);e.movement.addForce(r),n.movement.addForce(we.scale(r,-1))}else{const r=we.scale(we.normalize(we.sub(e.vec,n.vec)),e.getWidth()-s);e.movement.addForce(we.scale(r,1/e.state.weight*n.state.weight)),n.movement.addForce(we.scale(r,-1*e.state.weight/n.state.weight))}}onArrowCollision(e,n){const s=we.distance(n.vec,e.vec);if(n.type==="arrow")n.hit(e,s);else if(n.type==="ball"&&e.state.cooldown("ballhit",150)){n.hit(e,s);const r=we.scale(we.normalize(we.sub(e.vec,n.vec)),e.getWidth()-s);e.movement.addForce(we.scale(r,-.5/e.state.weight*(1-s/za)))}}updateObject(e,n){e.update(n)}getAlive(){return this.queryObjects("Soldier",e=>e.state.life>0).reduce((e,n)=>(e[n.color]=(e[n.color]||0)+1,e),{"#ff0000":0,"#00ff00":0})}getBalance(){const e=this.getAlive(),n=Object.keys(this.getAlive());return e[n[0]]/(e[n[0]]+e[n[1]])}}class Rv{constructor(){ee(this,"startTime",-1);ee(this,"done",!1)}start(e){this.startTime=e}}class F1 extends Rv{constructor(n){super();ee(this,"duration");this.duration=n}isDone(n){return!!this.duration&&this.startTime>=0&&n-this.startTime>this.duration}execute(n){n.movement.setTargetVelocity(0)}}class Fd extends Rv{constructor(){super()}getTarget(e){return e.plan.formation}execute(e){const n=this.getTarget(e),s=we.distance(e.vec,n),r=we.atan2(e.vec,n);s>50?(e.movement.setTargetVelocity(1),e.movement.setTargetDirection(r)):(e.movement.setTargetVelocity(0),this.done=!0)}isDone(){return this.done}}class VD extends Fd{constructor(n){super();ee(this,"angle");this.angle=n}getTarget(n){return we.add(we.rotate([200,100*Math.sign(Math.cos(this.angle))],this.angle),n.plan.formation)}}class yle extends VD{getTarget(e){return we.add(we.rotate([200,-100*Math.sign(Math.cos(this.angle))],this.angle),e.plan.formation)}}class ua extends Rv{constructor(){super()}execute(e){e.targeting.seekEnemy(ws)||(this.done=!0)}isDone(){return this.done}}class wle{constructor(e,n,s){ee(this,"masterPlan");ee(this,"formation");ee(this,"plan");ee(this,"currentCommand");ee(this,"claims");this.masterPlan=e,this.formation=n,this.plan=s,this.currentCommand=null,this.claims=e.claims}getPosition(){return this.formation}getCommand(e){return(!this.currentCommand||this.currentCommand.isDone(e))&&this.plan.length>0&&(this.currentCommand=this.plan.splice(0,1)[0],this.currentCommand.start(e)),this.currentCommand||(this.currentCommand=new F1),this.currentCommand}canClaim(e,n){if(this.claims[e.soldierId]||(this.claims[e.soldierId]=[]),this.claims[e.soldierId].length<5)return!0;const s=n.distance(e);return this.claims[e.soldierId].filter(o=>o.distance(e)>s).length===this.claims[e.soldierId].length}unclaim(e,n){const s=this.claims[e.soldierId].indexOf(n);s>=0&&this.claims[e.soldierId].splice(s,1)}claim(e,n){return this.canClaim(e,n)?(this.claims[e.soldierId].push(n),!0):!1}}class vle{constructor(e,n){ee(this,"type");ee(this,"formation");ee(this,"plan");ee(this,"claims");const s=we.atan2(e,[0,0]);this.type=[],this.formation=[],this.plan=[],this.claims={},n.forEach(r=>{const o=r.sizeCol*r.sizeRow,i=[r.col*is,r.row*Ur];for(let a=0;a2/3,this.balanceRight.style.width=(1-r)*100+"%",this.balanceRight.dataset.winning=r<1/3}renderResults(e){var n=this.getBalance(e),s="";if(n>1/3&&n<2/3)this.battleResult.innerHTML=`
DRAW!${s} Click to continue${s}
`;else{var r=n>.3333333333333333?"#ff0000":"#00ff00";return this.battleResult.innerHTML=`
@@ -20626,4 +20626,4 @@ canvas#layer-default { ${n>2/3?this.balanceLeft.dataset.username:this.balanceRight.dataset.username} wins!${s} ${n>2/3?this.balanceRight.dataset.username:this.balanceLeft.dataset.username} defeated!${s} Click to continue${s} -
`,r}}showPause(){}}function WD(t){t=t||du;const e=Va.layers[t];return e||(Va.layers[t]=new Va(t))}function kle(t){t=t||du;const e=Va.layers[t];e&&(e.destroy(),delete Va.layers[t])}class Va{constructor(e){ee(this,"element");ee(this,"ctx");this.element=document.createElement("canvas"),this.element.id=e,this.element.width=ws*3,this.element.height=ws*2,this.ctx=this.element.getContext("2d"),document.body.appendChild(this.element)}destroy(){document.body.removeChild(this.element)}getWidth(){return this.element.width}getHeight(){return this.element.height}clear(){return this.ctx.clearRect(0,0,this.getWidth(),this.getHeight()),this}drawText(e,n,s){return this.ctx.fillStyle="white",this.ctx.font="11px serif",this.ctx.fillText(s,e-this.ctx.measureText(s).width/2,n),this}fillStyle(e){return this.ctx.fillStyle=e,this}strokeStyle(e){return this.ctx.strokeStyle=e,this}fillRect(e,n,s,r){return this.ctx.fillRect(e,n,s,r),this}arc(e,n,s){return this.ctx.beginPath(),this.ctx.arc(e,n,s,0,Math.PI*2),this.ctx.stroke(),this}line(e,n,s,r){return this.save(),this.ctx.beginPath(),this.ctx.moveTo(e,n),this.ctx.lineTo(s,r),this.ctx.stroke(),this.restore(),this}drawImage(e,n,s){return this.ctx.drawImage(e,n,s),this}fill(e){this.ctx.fill(e)}scale(e){return this.ctx.scale(e,e),this}translate(e,n){return this.ctx.translate(e,n),this}rotate(e){return this.ctx.rotate(e),this}save(){return this.ctx.save(),this}restore(){return this.ctx.restore(),this}getCtx(){return this.ctx}}ee(Va,"layers",{});function Av(t){const e=WD(du);e.clear(),t.terrain.render(e),e.save().translate(e.getWidth()/2,e.getHeight()/2),t.particles.renderDead(e),t.queryObjects("Soldier",n=>n.state.life===0).forEach(n=>dd(n,t)),t.queryObjects("Soldier",n=>n.state.life>0).sort((n,s)=>n.getY()-s.getY()).forEach(n=>dd(n,t)),t.queryObjects("Arrow").forEach(n=>dd(n,t)),t.queryObjects("Explosion").forEach(n=>dd(n,t)),t.particles.renderActive(e),e.restore()}function dd(t,e){const n=WD(du);n.save().fillStyle("red").translate(t.getX(),t.getY()-e.terrain.getHeightAt(t.vec)),t.getClass()!=="Soldier"&&n.rotate(t.getDirection()),t.render(n),n.restore()}function rS(t,e,n,s){const r=Math.PI/2*e,o=[0,e*ws/2],i=new ble(o,s);for(let a=0;a0;)a=t.update(a);Av(t)}if(o===OD&&e.render(t),o===MD){const a=e.getBalance(t);if(t.getTime()>6e4||a===0||a===1)return $le(t,e)}if(o===A1||o===D1){const{damage:a,soldier:l}=i;n[o][l.color]+=a,s[o][l.color]++}}}function $le(t,e){return e.renderResults(t),function(s){if(Av(t),s===PD)return kle(du),e.destroy(),xae("battleEnd"),UD()}}function UD(){return function(e,n){if(e==zD)return Sle(n.playerUnits,n.oppositionUnits)}}let uc;function Nle(){uc=UD()}function ht(t,e){const n=uc(t,e);n&&n!==uc&&(console.log("Transition from "+uc.name+" to "+n.name),uc=n)}document.addEventListener("visibilitychange",function(){document.hidden?ht(vae):ht(bae)});window.addEventListener("resize",function(){ht(Cae)});function ha(t,e){ye.useEffect(()=>(window.addEventListener(t,e),()=>{window.removeEventListener(t,e)}),[t,e])}function Tle(){return ha("keydown",function(t){t.keyCode==37&&ht(Eae),t.keyCode==38&&ht(Aae),t.keyCode==39&&ht(Rae),t.keyCode==40&&ht(Dae),t.keyCode==27&&ht(kae),ht(Nae,t.keyCode)}),ha("keyup",function(t){t.keyCode==37&&ht(_ae),t.keyCode==38&&ht(zae),t.keyCode==39&&ht(Fae),t.keyCode==40&&ht(Oae),ht(Tae,t)}),ha("mousedown",function(t){ht(Sae,t)}),ha("mouseup",function(t){ht(Iae,t)}),ha("mousemove",function(t){ht($ae,t)}),ha("click",function(t){ht(PD,t)}),null}function Ele({onBattleEnd:t,playerUnits:e,oppositionUnits:n}){ye.useEffect(()=>{Nle(),ht(zD,{playerUnits:e,oppositionUnits:n});const r=setTimeout(()=>ht(_D),1e3),o=setInterval(()=>ht(OD),100),i=setInterval(()=>ht(MD),1e3);return()=>{clearTimeout(r),clearInterval(o),clearInterval(i)}},[]),yae("battleEnd",()=>{t()});const s=ye.useRef();return RO(()=>{const r=Date.now();s.current&&ht(FD,r-s.current),s.current=r}),De.jsxs(De.Fragment,{children:[De.jsx(wae,{}),De.jsx(Tle,{}),De.jsxs("div",{id:"game-hud",children:[De.jsxs("div",{id:"battle-stats",children:[De.jsx("div",{id:"battle-time",children:" "}),De.jsxs("div",{id:"battle-balance",children:[De.jsx("div",{id:"battle-balance-left",children:" "}),De.jsx("div",{id:"battle-balance-right",children:" "})]})]}),De.jsx("div",{id:"battle-result"})]})]})}const Rle=()=>{const[t,e]=ye.useState({name:"intro"}),n=()=>{e({name:"designer"})},s=(o,i)=>{e({name:"battle",playerUnits:o,oppositionUnits:i}),console.log("Battle started!")},r=()=>{e({name:"designer",playerUnits:t.name==="battle"?t.playerUnits:void 0})};return De.jsxs(Gs.StrictMode,{children:[De.jsx(kO,{}),(t==null?void 0:t.name)==="intro"&&De.jsx(NO,{onPlayClick:n}),(t==null?void 0:t.name)==="designer"&&De.jsx(dae,{onStartBattle:s,initialPlayerUnits:t.playerUnits}),(t==null?void 0:t.name)==="battle"&&De.jsx(Ele,{onBattleEnd:r,playerUnits:t.playerUnits,oppositionUnits:t.oppositionUnits})]})},Ale=Gg.createRoot(document.getElementById("root"));Ale.render(De.jsx(Rle,{})); +
`,r}}showPause(){}}function Cle(t){t=t||fp;const e=Va.layers[t];return e||(Va.layers[t]=new Va(t))}function kle(t){t=t||fp;const e=Va.layers[t];e&&(e.destroy(),delete Va.layers[t])}class Va{constructor(e){ee(this,"element");ee(this,"ctx");this.element=document.createElement("canvas"),this.element.id=e,this.element.width=ws*3,this.element.height=ws*2,this.ctx=this.element.getContext("2d"),document.body.appendChild(this.element)}destroy(){document.body.removeChild(this.element)}getWidth(){return this.element.width}getHeight(){return this.element.height}clear(){return this.ctx.clearRect(0,0,this.getWidth(),this.getHeight()),this}drawText(e,n,s){return this.ctx.fillStyle="white",this.ctx.font="11px serif",this.ctx.fillText(s,e-this.ctx.measureText(s).width/2,n),this}fillStyle(e){return this.ctx.fillStyle=e,this}strokeStyle(e){return this.ctx.strokeStyle=e,this}fillRect(e,n,s,r){return this.ctx.fillRect(e,n,s,r),this}arc(e,n,s){return this.ctx.beginPath(),this.ctx.arc(e,n,s,0,Math.PI*2),this.ctx.stroke(),this}line(e,n,s,r){return this.save(),this.ctx.beginPath(),this.ctx.moveTo(e,n),this.ctx.lineTo(s,r),this.ctx.stroke(),this.restore(),this}drawImage(e,n,s){return this.ctx.drawImage(e,n,s),this}fill(e){this.ctx.fill(e)}scale(e){return this.ctx.scale(e,e),this}translate(e,n){return this.ctx.translate(e,n),this}rotate(e){return this.ctx.rotate(e),this}save(){return this.ctx.save(),this}restore(){return this.ctx.restore(),this}getCtx(){return this.ctx}}ee(Va,"layers",{});const hd={terrain:0,deadObjects:1,shadows:2,objects:3,particles:4};class Sle{constructor(){ee(this,"commands",[])}addCommand(e){this.commands.push(e)}sortCommands(e){return e.sort((n,s)=>hd[n.layer]!==hd[s.layer]?hd[n.layer]-hd[s.layer]:n.y!==s.y?n.y-s.y:n.z-s.z)}batchCommands(){const e=this.sortCommands(this.commands),n=[];let s=[],r;for(const o of e)o.fillStyle!==r&&s.length>0&&(n.push(s),s=[]),s.push(o),r=o.fillStyle;return s.length>0&&n.push(s),n}render(e){const n=this.batchCommands();for(const s of n){e.save(),s[0].fillStyle&&e.fillStyle(s[0].fillStyle);for(const r of s)r.render(e);e.restore()}this.commands=[]}addObjectCommand(e,n,s,r,o){this.addCommand({layer:s?"objects":"deadObjects",z:e,y:n,fillStyle:r,render:o})}addShadowCommand(e,n,s,r){this.addCommand({layer:"shadows",z:e,y:n,fillStyle:s,render:r})}addParticleCommand(e,n,s,r){this.addCommand({layer:"particles",z:e,y:n,fillStyle:s,render:r})}}function Av(t){const e=Cle(fp),n=new Sle;e.clear(),t.terrain.render(e),e.save().translate(e.getWidth()/2,e.getHeight()/2),t.particles.renderDead(e),t.objects.forEach(s=>s.render(n)),t.particles.addRenderCommands(n),n.render(e),e.restore()}function rS(t,e,n,s){const r=Math.PI/2*e,o=[0,e*ws/2],i=new vle(o,s);for(let a=0;a0;)a=t.update(a);Av(t)}if(o===OD&&e.render(t),o===MD){const a=e.getBalance(t);if(t.getTime()>6e4||a===0||a===1)return Nle(t,e)}if(o===A1||o===D1){const{damage:a,soldier:l}=i;n[o][l.color]+=a,s[o][l.color]++}}}function Nle(t,e){return e.renderResults(t),function(s){if(Av(t),s===PD)return kle(fp),e.destroy(),gae("battleEnd"),WD()}}function WD(){return function(e,n){if(e==zD)return Ile(n.playerUnits,n.oppositionUnits)}}let uc;function Tle(){uc=WD()}function ht(t,e){const n=uc(t,e);n&&n!==uc&&(console.log("Transition from "+uc.name+" to "+n.name),uc=n)}document.addEventListener("visibilitychange",function(){document.hidden?ht(wae):ht(vae)});window.addEventListener("resize",function(){ht(bae)});function ha(t,e){ye.useEffect(()=>(window.addEventListener(t,e),()=>{window.removeEventListener(t,e)}),[t,e])}function Ele(){return ha("keydown",function(t){t.keyCode==37&&ht(Tae),t.keyCode==38&&ht(Rae),t.keyCode==39&&ht(Eae),t.keyCode==40&&ht(Aae),t.keyCode==27&&ht(Cae),ht($ae,t.keyCode)}),ha("keyup",function(t){t.keyCode==37&&ht(Dae),t.keyCode==38&&ht(Fae),t.keyCode==39&&ht(_ae),t.keyCode==40&&ht(zae),ht(Nae,t)}),ha("mousedown",function(t){ht(kae,t)}),ha("mouseup",function(t){ht(Sae,t)}),ha("mousemove",function(t){ht(Iae,t)}),ha("click",function(t){ht(PD,t)}),null}function Rle({onBattleEnd:t,playerUnits:e,oppositionUnits:n}){ye.useEffect(()=>{Tle(),ht(zD,{playerUnits:e,oppositionUnits:n});const r=setTimeout(()=>ht(_D),1e3),o=setInterval(()=>ht(OD),100),i=setInterval(()=>ht(MD),1e3);return()=>{clearTimeout(r),clearInterval(o),clearInterval(i)}},[]),xae("battleEnd",()=>{t()});const s=ye.useRef();return EO(()=>{const r=Date.now();s.current&&ht(FD,r-s.current),s.current=r}),De.jsxs(De.Fragment,{children:[De.jsx(yae,{}),De.jsx(Ele,{}),De.jsxs("div",{id:"game-hud",children:[De.jsxs("div",{id:"battle-stats",children:[De.jsx("div",{id:"battle-time",children:" "}),De.jsxs("div",{id:"battle-balance",children:[De.jsx("div",{id:"battle-balance-left",children:" "}),De.jsx("div",{id:"battle-balance-right",children:" "})]})]}),De.jsx("div",{id:"battle-result"})]})]})}const Ale=()=>{const[t,e]=ye.useState({name:"intro"}),n=()=>{e({name:"designer"})},s=(o,i)=>{e({name:"battle",playerUnits:o,oppositionUnits:i}),console.log("Battle started!")},r=()=>{e({name:"designer",playerUnits:t.name==="battle"?t.playerUnits:void 0})};return De.jsxs(Gs.StrictMode,{children:[De.jsx(CO,{}),(t==null?void 0:t.name)==="intro"&&De.jsx($O,{onPlayClick:n}),(t==null?void 0:t.name)==="designer"&&De.jsx(hae,{onStartBattle:s,initialPlayerUnits:t.playerUnits}),(t==null?void 0:t.name)==="battle"&&De.jsx(Rle,{onBattleEnd:r,playerUnits:t.playerUnits,oppositionUnits:t.oppositionUnits})]})},Dle=Gg.createRoot(document.getElementById("root"));Dle.render(De.jsx(Ale,{})); diff --git a/games/masterplan/index.html b/games/masterplan/index.html index 97b44424..35a3cdf9 100644 --- a/games/masterplan/index.html +++ b/games/masterplan/index.html @@ -1,7 +1,7 @@ Master Plan - +