1/*! For license information please see 6062.2090eb9b.js.LICENSE.txt */ 2(self.webpackChunkpwa=self.webpackChunkpwa||[]).push([[6062],{448:function(e,t,n){"use strict";n.d(t,{r:function(){return o}});var r=n(21722),a=n(45119);function o(e,t="float32",n){return t=t||"float32",a.SA(e),new r.yl(e,t,n)}},7180:function(e,t,n){var r;!function(e,a){function o(e){var t=this,n=function(){var e=4022871197,t=function(t){t=String(t);for(var n=0;n<t.length;n++){var r=.02519603282416938*(e+=t.charCodeAt(n));r-=e=r>>>0,e=(r*=e)>>>0,e+=4294967296*(r-=e)}return 2.3283064365386963e-10*(e>>>0)};return t}();t.next=function(){var e=2091639*t.s0+2.3283064365386963e-10*t.c;return t.s0=t.s1,t.s1=t.s2,t.s2=e-(t.c=0|e)},t.c=1,t.s0=n(" "),t.s1=n(" "),t.s2=n(" "),t.s0-=n(e),t.s0<0&&(t.s0+=1),t.s1-=n(e),t.s1<0&&(t.s1+=1),t.s2-=n(e),t.s2<0&&(t.s2+=1),n=null}function s(e,t){return t.c=e.c,t.s0=e.s0,t.s1=e.s1,t.s2=e.s2,t}function i(e,t){var n=new o(e),r=t&&t.state,a=n.next;return a.int32=function(){return 4294967296*n.next()|0},a.double=function(){return a()+11102230246251565e-32*(2097152*a()|0)},a.quick=a,r&&("object"==typeof r&&s(r,n),a.state=function(){return s(n,{})}),a}a&&a.exports?a.exports=i:n.amdD&&n.amdO?void 0===(r=function(){return i}.call(t,n,t,a))||(a.exports=r):this.alea=i}(0,e=n.nmd(e),n.amdD)},7391:function(e,t,n){var r=n(7180),a=n(43181),o=n(43031),s=n(9067),i=n(96833),u=n(43717),c=n(74801);c.alea=r,c.xor128=a,c.xorwow=o,c.xorshift7=s,c.xor4096=i,c.tychei=u,e.exports=c},9067:function(e,t,n){var r;!function(e,a){function o(e){var t=this;t.next=function(){var e,n,r=t.x,a=t.i;return e=r[a],n=(e^=e>>>7)^e<<24,n^=(e=r[a+1&7])^e>>>10,n^=(e=r[a+3&7])^e>>>3,n^=(e=r[a+4&7])^e<<7,e=r[a+7&7],n^=(e^=e<<13)^e<<9,r[a]=n,t.i=a+1&7,n},function(e,t){var n,r=[];if(t===(0|t))r[0]=t;else for(t=""+t,n=0;n<t.length;++n)r[7&n]=r[7&n]<<15^t.charCodeAt(n)+r[n+1&7]<<13;for(;r.length<8;)r.push(0);for(n=0;n<8&&0===r[n];++n);for(8==n?r[7]=-1:r[n],e.x=r,e.i=0,n=256;n>0;--n)e.next()}(t,e)}function s(e,t){return t.x=e.x.slice(),t.i=e.i,t}function i(e,t){null==e&&(e=+new Date);var n=new o(e),r=t&&t.state,a=function(){return(n.next()>>>0)/4294967296};return a.double=function(){do{var e=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},a.int32=n.next,a.quick=a,r&&(r.x&&s(r,n),a.state=function(){return s(n,{})}),a}a&&a.exports?a.exports=i:n.amdD&&n.amdO?void 0===(r=function(){return i}.call(t,n,t,a))||(a.exports=r):this.xorshift7=i}(0,e=n.nmd(e),n.amdD)},9258:function(e,t,n){"use strict";n.d(t,{l:function(){return i}});var r=n(57260),a=n(15441),o=n(30565),s=n(28189);const i=(0,n(70929).op)({mul_:function(e,t){let n=(0,s.YT)(e,"a","mul"),i=(0,s.YT)(t,"b","mul");[n,i]=(0,o.h0)(n,i);const u={a:n,b:i};return r.T2.runKernel(a.xu7,u)}})},10700:function(e,t,n){"use strict";n.d(t,{P:function(){return s}});var r=n(57260),a=n(15441),o=n(28189);const s=(0,n(70929).op)({step_:function(e,t=0){const n={x:(0,o.YT)(e,"x","step")},s={alpha:t};return r.T2.runKernel(a.pnw,n,s)}})},15149:function(e,t,n){"use strict";n.d(t,{GJ:function(){return r},uI:function(){return a}});class r{constructor(e,t){this.backend=e,this.dataMover=t,this.data=new WeakMap,this.dataIdsCount=0}get(e){return this.data.has(e)||this.dataMover.moveData(this.backend,e),this.data.get(e)}set(e,t){this.dataIdsCount++,this.data.set(e,t)}has(e){return this.data.has(e)}delete(e){return this.dataIdsCount--,this.data.delete(e)}numDataIds(){return this.dataIdsCount}}class a{refCount(e){return o("refCount")}incRef(e){return o("incRef")}timerAvailable(){return!0}time(e){return o("time")}read(e){return o("read")}readSync(e){return o("readSync")}readToGPU(e,t){return o("readToGPU")}numDataIds(){return o("numDataIds")}disposeData(e,t){return o("disposeData")}write(e,t,n){return o("write")}move(e,t,n,r,a){return o("move")}memory(){return o("memory")}floatPrecision(){return o("floatPrecision")}epsilon(){return 32===this.floatPrecision()?1e-7:1e-4}dispose(){return o("dispose")}}function o(e){throw new Error(`'${e}' not yet implemented or not found in the registry. This kernel may not be supported by the tfjs backend you have chosen`)}},15441:function(e,t,n){"use strict";n.d(t,{$dB:function(){return A},$jE:function(){return Wt},$zE:function(){return I},A1h:function(){return F},A8B:function(){return At},BK4:function(){return rn},BLA:function(){return Ue},BRl:function(){return ee},Blb:function(){return Rt},BoJ:function(){return Ft},BxF:function(){return se},C8s:function(){return Ot},Cg$:function(){return ke},CwD:function(){return Te},D7i:function(){return mt},Ddj:function(){return Pt},Dr:function(){return an},DvZ:function(){return Lt},E3$:function(){return xe},EkD:function(){return i},ElG:function(){return ue},EwU:function(){return qt},FAs:function(){return Ht},FCQ:function(){return dt},FSt:function(){return c},Fin:function(){return $t},Ik2:function(){return T},J3C:function(){return Ct},JiE:function(){return Tt},Jp_:function(){return l},KXH:function(){return k},L6G:function(){return Dt},LDN:function(){return _e},LG0:function(){return Ve},LRy:function(){return st},LWX:function(){return Xe},LXA:function(){return Ne},M6A:function(){return Bt},MRQ:function(){return z},Mn0:function(){return M},MnK:function(){return P},N4F:function(){return S},Ncv:function(){return tt},O4G:function(){return pe},OAQ:function(){return me},ODT:function(){return Je},OMN:function(){return s},ORI:function(){return H},PH8:function(){return o},P_L:function(){return ft},Pah:function(){return q},PbM:function(){return Gt},Q6t:function(){return ot},QDP:function(){return E},QKF:function(){return h},Qgm:function(){return X},R23:function(){return ct},RUm:function(){return Ee},RXX:function(){return Fe},SDM:function(){return He},SQl:function(){return oe},T7M:function(){return sn},TBb:function(){return Yt},TL8:function(){return Me},TMz:function(){return W},TOR:function(){return yt},ToN:function(){return Ae},TyE:function(){return f},UcO:function(){return Vt},VAI:function(){return Re},VCH:function(){return x},Vvy:function(){return a},WT3:function(){return We},WuN:function(){return It},X$8:function(){return j},X0$:function(){return ve},XQy:function(){return pt},XhZ:function(){return he},YAb:function(){return zt},YVe:function(){return kt},ZgB:function(){return ie},Zl4:function(){return Ye},_s9:function(){return J},aAr:function(){return on},awo:function(){return nn},cHb:function(){return Le},cS:function(){return b},dFH:function(){return Nt},dLy:function(){return Zt},dXR:function(){return Qt},dv8:function(){return ge},e0f:function(){return Ze},epO:function(){return d},fUj:function(){return ut},g5A:function(){return Pe},gC7:function(){return L},gIW:function(){return ye},hVg:function(){return gt},hgw:function(){return ht},ho8:function(){return y},hql:function(){return St},huO:function(){return it},i5R:function(){return ce},iGz:function(){return D},iPs:function(){return be},iW0:function(){return Ut},iuW:function(){return Kt},jAQ:function(){return w},jM4:function(){return Ie},jOE:function(){return lt},jfg:function(){return O},jgd:function(){return Mt},jj_:function(){return B},jxD:function(){return Y},kdj:function(){return nt},l0G:function(){return je},l6P:function(){return vt},lLS:function(){return de},lNG:function(){return Be},ljI:function(){return r},lxb:function(){return g},lzr:function(){return fe},mH5:function(){return at},mIA:function(){return we},mM$:function(){return Qe},mnI:function(){return Se},mxL:function(){return le},nVu:function(){return K},nY8:function(){return V},nZd:function(){return $e},oFs:function(){return jt},oJ2:function(){return rt},ox3:function(){return te},p2J:function(){return R},pJc:function(){return xt},pPe:function(){return Jt},p_m:function(){return p},pnw:function(){return tn},pr3:function(){return N},pyJ:function(){return et},rFG:function(){return _t},rFm:function(){return _},rGP:function(){return ae},rsH:function(){return Q},sDr:function(){return Z},t3d:function(){return Oe},tG8:function(){return Ce},tGH:function(){return G},u$b:function(){return wt},u8Z:function(){return u},uWl:function(){return bt},urI:function(){return qe},vI1:function(){return Et},vaV:function(){return $},vj7:function(){return C},wNW:function(){return U},wwC:function(){return v},wx0:function(){return Xt},x7F:function(){return ze},xJ3:function(){return en},xu7:function(){return Ge},ySp:function(){return De},ybN:function(){return ne},ybj:function(){return re},ylV:function(){return Ke},zP9:function(){return m}});const r="Abs",a="Acos",o="Acosh",s="Add",i="AddN",u="All",c="Any",l="ArgMax",p="ArgMin",h="Asin",d="Asinh",f="Atan",m="Atanh",g="Atan2",y="AvgPool",x="AvgPoolGrad",b="AvgPool3D",v="AvgPool3DGrad",w="BatchMatMul",T="BatchToSpaceND",S="Bincount",C="BroadcastArgs",k="Cast",E="Ceil",$="ClipByValue",N="Complex",I="ComplexAbs",A="Concat",R="Conv2D",_="Conv2DBackpropFilter",O="Conv2DBackpropInput",F="Conv3D",D="Conv3DBackpropFilterV2",L="Conv3DBackpropInputV2",M="Cos",P="Cosh",B="Cumprod",V="Cumsum",z="CropAndResize",U="DenseBincount",W="DepthToSpace",G="DepthwiseConv2dNative",j="DepthwiseConv2dNativeBackpropFilter",K="DepthwiseConv2dNativeBackpropInput",H="Diag",Y="Dilation2D",Z="RealDiv",X="Einsum",q="Elu",Q="EluGrad",J="Erf",ee="Equal",te="Exp",ne="ExpandDims",re="Expm1",ae="FFT",oe="Fill",se="FlipLeftRight",ie="Floor",ue="FloorDiv",ce="FusedBatchNorm",le="GatherV2",pe="GatherNd",he="Greater",de="GreaterEqual",fe="Identity",me="IFFT",ge="Imag",ye="IsFinite",xe="IsInf",be="IsNan",ve="LeakyRelu",we="Less",Te="LessEqual",Se="LinSpace",Ce="Log",ke="Log1p",
2Ee="LogicalAnd",$e="LogicalNot",Ne="LogicalOr",Ie="LRN",Ae="LRNGrad",Re="Max",_e="Maximum",Oe="MaxPool",Fe="MaxPoolGrad",De="MaxPool3D",Le="MaxPool3DGrad",Me="MaxPoolWithArgmax",Pe="Mean",Be="Min",Ve="Minimum",ze="MirrorPad",Ue="Mod",We="Multinomial",Ge="Multiply",je="Neg",Ke="NotEqual",He="NonMaxSuppressionV3",Ye="NonMaxSuppressionV4",Ze="NonMaxSuppressionV5",Xe="OnesLike",qe="OneHot",Qe="Pack",Je="PadV2",et="Pow",tt="Prelu",nt="Prod",rt="RaggedGather",at="RaggedTensorToTensor",ot="Range",st="Real",it="Reciprocal",ut="Relu",ct="Reshape",lt="ResizeNearestNeighbor",pt="ResizeNearestNeighborGrad",ht="ResizeBilinear",dt="ResizeBilinearGrad",ft="Relu6",mt="Reverse",gt="Round",yt="Rsqrt",xt="ScatterNd",bt="SearchSorted",vt="Select",wt="Selu",Tt="Slice",St="Sin",Ct="Sinh",kt="Sign",Et="Sigmoid",$t="Softplus",Nt="Sqrt",It="Sum",At="SpaceToBatchND",Rt="SplitV",_t="Softmax",Ot="SparseFillEmptyRows",Ft="SparseReshape",Dt="SparseSegmentMean",Lt="SparseSegmentSum",Mt="SparseToDense",Pt="SquaredDifference",Bt="Square",Vt="StridedSlice",zt="StringNGrams",Ut="StringSplit",Wt="StringToHashBucketFast",Gt="Sub",jt="Tan",Kt="Tanh",Ht="Tile",Yt="TopK",Zt="Transform",Xt="Transpose",qt="Unique",Qt="Unpack",Jt="UnsortedSegmentSum",en="ZerosLike",tn="Step",nn="FromPixels",rn="RotateWithOffset",an="_FusedMatMul",on="FusedConv2D",sn="FusedDepthwiseConv2D"},19171:function(e,t,n){"use strict";n.d(t,{Q:function(){return s}});var r=n(57260),a=n(45119),o=n(31259);function s(e,t,n,s){if(null==s&&(s=(0,a.X$)(e)),"complex64"===s)throw new Error("Cannot construct a complex64 tensor directly. Please use tf.complex(real, imag).");if(!(0,a.iu)(e)&&!Array.isArray(e)&&"number"!=typeof e&&"boolean"!=typeof e&&"string"!=typeof e)throw new Error("values passed to tensor(values) must be a number/boolean/string or an array of numbers/booleans/strings, or a TypedArray");if(null!=t){(0,a.SA)(t);const e=(0,a.Ze)(t),r=(0,a.Ze)(n);(0,a.vA)(e===r,()=>`Based on the provided shape, [${t}], the tensor should have ${e} values but has ${r}`);for(let e=0;e<n.length;++e){const r=n[e],o=e!==n.length-1||r!==(0,a.Ze)(t.slice(e));(0,a.vA)(n[e]===t[e]||!o,()=>`Error creating a new Tensor. Inferred shape (${n}) does not match the provided shape (${t}). `)}}return(0,a.iu)(e)||Array.isArray(e)||(e=[e]),t=t||n,e="string"!==s?(0,o.toTypedArray)(e,s):(0,a.Bq)(e,[],!0),r.T2.makeTensor(e,t,s)}},21078:function(e,t,n){"use strict";n.d(t,{Em:function(){return c},SM:function(){return i},WC:function(){return u},WH:function(){return a},aF:function(){return o},fK:function(){return p},gx:function(){return l},lb:function(){return s}});var r=n(45119);function a(e,t){for(let n=0;n<e.length;++n)if(e[e.length-n-1]!==t-1-n)return!1;return!0}function o(e,t,n){const r=e.length+t.length,a=[];let o=0,s=0;for(let i=0;i<r;i++)-1===n.indexOf(i)?a.push(e[o++]):a.push(t[s++]);return a}function s(e,t){const n=[],r=e.length;for(let a=0;a<r;a++)-1===t.indexOf(a)&&n.push(e[a]);return[n,t.map(t=>e[t])]}function i(e,t){return o(e,t.map(e=>1),t)}function u(e,t,n){r.vA(a(t,n),()=>`${e} supports only inner-most axes for now. Got axes ${t} and rank-${n} input.`)}function c(e,t){if(a(e,t))return null;const n=[];for(let r=0;r<t;++r)-1===e.indexOf(r)&&n.push(r);return e.forEach(e=>n.push(e)),n}function l(e){return e.map((e,t)=>[t,e]).sort((e,t)=>e[1]-t[1]).map(e=>e[0])}function p(e,t){const n=[];for(let r=t-e;r<t;++r)n.push(r);return n}},21722:function(e,t,n){"use strict";n.d(t,{qY:function(){return x},yl:function(){return p},rT:function(){return b},B4:function(){return y},Q5:function(){return g},qP:function(){return m}});var r=n(41743),a=n(45119);function o(e,t,n,r){const o=(0,a.Ur)(t),i=function(e,t,n,r){const o=(0,a.Ze)(t),i=r[r.length-1],u=new Array(i).fill(0),l=t.length,p="complex64"===n?c(e):e;if(l>1)for(let e=0;e<o/i;e++){const t=e*i;for(let e=0;e<i;e++)u[e]=Math.max(u[e],s(p[t+e],0,n).length)}return u}(e,t,n,o),l=t.length,p=u(e,t,n,o,i),h=["Tensor"];return r&&(h.push(` dtype: ${n}`),h.push(` rank: ${l}`),h.push(` shape: [${t}]`),h.push(" values:")),h.push(p.map(e=>" "+e).join("\n")),h.join("\n")}function s(e,t,n){let r;return r=Array.isArray(e)?`${parseFloat(e[0].toFixed(7))} + ${parseFloat(e[1].toFixed(7))}j`:(0,a.Kg)(e)?`'${e}'`:"bool"===n?i(e):parseFloat(e.toFixed(7)).toString(),(0,a.av)(r,t)}function i(e){return 0===e?"false":"true"}function u(e,t,n,r,a,o=!0){const l="complex64"===n?2:1,p=t[0],h=t.length;if(0===h){if("complex64"===n){return[s(c(e)[0],0,n)]}return"bool"===n?[i(e[0])]:[e[0].toString()]}if(1===h){if(p>20){const t=3*l;let r=Array.from(e.slice(0,t)),o=Array.from(e.slice((p-3)*l,p*l));return"complex64"===n&&(r=c(r),o=c(o)),["["+r.map((e,t)=>s(e,a[t],n)).join(", ")+", ..., "+o.map((e,t)=>s(e,a[p-3+t],n)).join(", ")+"]"]}return["["+("complex64"===n?c(e):Array.from(e)).map((e,t)=>s(e,a[t],n)).join(", ")+"]"]}const d=t.slice(1),f=r.slice(1),m=r[0]*l,g=[];if(p>20){for(let t=0;t<3;t++){const r=t*m,o=r+m;g.push(...u(e.slice(r,o),d,n,f,a,!1))}g.push("...");for(let t=p-3;t<p;t++){const r=t*m,o=r+m;g.push(...u(e.slice(r,o),d,n,f,a,t===p-1))}}else for(let t=0;t<p;t++){const r=t*m,o=r+m;g.push(...u(e.slice(r,o),d,n,f,a,t===p-1))}const y=2===h?",":"";g[0]="["+g[0]+y;for(let e=1;e<g.length-1;e++)g[e]=" "+g[e]+y;let x=",\n";for(let e=2;e<h;e++)x+="\n";
2return g[g.length-1]=" "+g[g.length-1]+"]"+(o?"":x),g}function c(e){const t=[];for(let n=0;n<e.length;n+=2)t.push([e[n],e[n+1]]);return t}var l=n(31259);class p{constructor(e,t,n){if(this.dtype=t,this.shape=e.slice(),this.size=a.Ze(e),null!=n){const e=n.length;a.vA(e===this.size,()=>`Length of values '${e}' does not match the size inferred by the shape '${this.size}'.`)}if("complex64"===t)throw new Error("complex64 dtype TensorBuffers are not supported. Please create a TensorBuffer for the real and imaginary parts separately and call tf.complex(real, imag).");this.values=n||a.Ab(t,this.size),this.strides=(0,a.Ur)(e)}set(e,...t){0===t.length&&(t=[0]),a.vA(t.length===this.rank,()=>`The number of provided coordinates (${t.length}) must match the rank (${this.rank})`);const n=this.locToIndex(t);this.values[n]=e}get(...e){0===e.length&&(e=[0]);let t=0;for(const n of e){if(n<0||n>=this.shape[t]){const t=`Requested out of range element at ${e}. Buffer shape=${this.shape}`;throw new Error(t)}t++}let n=e[e.length-1];for(let t=0;t<e.length-1;++t)n+=this.strides[t]*e[t];return this.values[n]}locToIndex(e){if(0===this.rank)return 0;if(1===this.rank)return e[0];let t=e[e.length-1];for(let n=0;n<e.length-1;++n)t+=this.strides[n]*e[n];return t}indexToLoc(e){if(0===this.rank)return[];if(1===this.rank)return[e];const t=new Array(this.shape.length);for(let n=0;n<t.length-1;++n)t[n]=Math.floor(e/this.strides[n]),e-=t[n]*this.strides[n];return t[t.length-1]=e,t}get rank(){return this.shape.length}toTensor(){return h().makeTensor(this.values,this.shape,this.dtype)}}let h=null,d=null,f=null;function m(e){h=e}function g(e){d=e}function y(e){f=e}class x{constructor(e,t,n,r){this.kept=!1,this.isDisposedInternal=!1,this.shape=e.slice(),this.dtype=t||"float32",this.size=a.Ze(e),this.strides=(0,a.Ur)(e),this.dataId=n,this.id=r,this.rankType=this.rank<5?this.rank.toString():"higher"}get rank(){return this.shape.length}async buffer(){const e=await this.data();return d.buffer(this.shape,this.dtype,e)}bufferSync(){return d.buffer(this.shape,this.dtype,this.dataSync())}async array(){const e=await this.data();return(0,a.yw)(this.shape,e,"complex64"===this.dtype)}arraySync(){return(0,a.yw)(this.shape,this.dataSync(),"complex64"===this.dtype)}async data(){this.throwIfDisposed();const e=h().read(this.dataId);if("string"===this.dtype){const t=await e;try{return t.map(e=>l.decodeString(e))}catch(e){throw new Error("Failed to decode the string bytes into utf-8. To get the original bytes, call tensor.bytes().")}}return e}dataToGPU(e){return this.throwIfDisposed(),h().readToGPU(this.dataId,e)}dataSync(){this.throwIfDisposed();const e=h().readSync(this.dataId);if("string"===this.dtype)try{return e.map(e=>l.decodeString(e))}catch(e){throw new Error("Failed to decode the string bytes into utf-8. To get the original bytes, call tensor.bytes().")}return e}async bytes(){this.throwIfDisposed();const e=await h().read(this.dataId);return"string"===this.dtype?e:new Uint8Array(e.buffer)}dispose(){this.isDisposed||(h().disposeTensor(this),this.isDisposedInternal=!0)}get isDisposed(){return this.isDisposedInternal}throwIfDisposed(){if(this.isDisposed)throw new Error("Tensor is disposed.")}print(e=!1){return d.print(this,e)}clone(){return this.throwIfDisposed(),d.clone(this)}toString(e=!1){return o(this.dataSync(),this.shape,this.dtype,e)}cast(e){return this.throwIfDisposed(),d.cast(this,e)}variable(e=!0,t,n){return this.throwIfDisposed(),h().makeVariable(this,e,t,n)}}Object.defineProperty(x,Symbol.hasInstance,{value:e=>!!e&&null!=e.data&&null!=e.dataSync&&null!=e.throwIfDisposed}),(0,r.m)("Tensor",()=>x);class b extends x{constructor(e,t,n,r){super(e.shape,e.dtype,e.dataId,r),this.trainable=t,this.name=n}assign(e){if(e.dtype!==this.dtype)throw new Error(`dtype of the new value (${e.dtype}) and previous value (${this.dtype}) must match`);if(!a.r1(e.shape,this.shape))throw new Error(`shape of the new value (${e.shape}) and previous value (${this.shape}) must match`);h().disposeTensor(this),this.dataId=e.dataId,h().incRef(this,null)}dispose(){h().disposeVariable(this),this.isDisposedInternal=!0}}Object.defineProperty(b,Symbol.hasInstance,{value:e=>e instanceof x&&null!=e.assign&&e.assign instanceof Function})},26170:function(e,t,n){"use strict";n.d(t,{Ly:function(){return a},TT:function(){return o},l8:function(){return s}});var r=n(45119);function a(e,t,n){const r=t.rank>1?t.shape[t.rank-1]:1,a=t.rank>1?t.rank-1:1,o=`Must have updates.shape = indices.shape[:batchDim] + shape[sliceDim:], got updates.shape: ${n.shape}, indices.shape: ${t.shape}, shape: ${e}, sliceDim: ${r}, and batchDim: ${a}.`;if(n.rank<a)throw new Error(o+` update.rank < ${a}. `);if(e.length<r+(n.rank-a))throw new Error(o+` Output shape length < ${r+(n.rank-a)}`);if(n.rank!==a+e.length-r)throw new Error(o+" update.rank != "+(a+e.length-r));for(let e=0;e<a;++e)if(n.shape[e]!==t.shape[e])throw new Error(o+` updates.shape[${e}] (${n.shape[e]}) != indices.shape[${e}] (${t.shape[e]}).`);for(let t=0;t<n.rank-a;++t)if(n.shape[t+a]!==e[t+r])throw new Error(o+` updates.shape[${t+a}] (${n.shape[t+a]}) != shape[${t+a}] (${e[t+a]})`)}function o(e,t,n){if(t.rank<1)throw new Error(`tf.scatterND() expects the indices to be rank 1 or higher, but the rank was ${t.rank}.`);if(e.rank<1)throw new Error(`tf.scatterND() expects the updates to be rank 1 or higher, but the rank was ${e.rank}.`);if("int32"!==t.dtype)throw new Error(`The dtype of 'indices' should be int32, but got dtype: ${t.dtype}`);if(n.length<1)throw new Error(`Output rank must be greater or equal to 1, but got shape: ${n}`);if(0===n.length){if(0===t.size)throw new Error(`Indices specified for empty output. indices shape: ${t.shape}`);if(0===e.size)throw new Error(`Updates specified for empty output. updates shape: ${e.shape}`)}a(n,t,e)}function s(e,t,n){const a=t.shape.length,o=a>1?t.shape[a-1]:1,s=n.length;let i=1;for(let e=o;e<s;++e)i*=n[e];const u=o<1?1:o;return{sliceRank:o,numUpdates:(0,r.Ze)(t.shape)/u,sliceSize:i,strides:[...(0,r.Ur)(n.slice(0,o)),1],outputSize:(0,r.Ze)(n)}}},28059:function(e,t,n){"use strict";n.d(t,{ox:function(){return Ue}});var r={};n.r(r),n.d(r,{json:function(){return D}});var a={};n.r(a),n.d(a,{json:function(){return L}});var o={};n.r(o),n.d(o,{json:function(){return M}});var s={};n.r(s),n.d(s,{json:function(){return P}});var i={};n.r(i),n.d(i,{json:function(){return B}});var u={};n.r(u),n.d(u,{json:function(){return V}});var c={};n.r(c),n.d(c,{json:function(){return z}});var l={};n.r(l),n.d(l,{json:function(){return U}});var p={};n.r(p),n.d(p,{json:function(){return W}});var h={};n.r(h),n.d(h,{json:function(){return G}});var d={};n.r(d),n.d(d,{json:function(){return j}});var f={};n.r(f),n.d(f,{json:function(){return K}});var m={};n.r(m),n.d(m,{json:function(){return H}});var g={};n.r(g),n.d(g,{json:function(){return Y}});var y={};n.r(y),n.d(y,{json:function(){return Z}});var x={};n.r(x),n.d(x,{json:function(){return X}});var b={};n.r(b),n.d(b,{json:function(){return q}});var v={};n.r(v),n.d(v,{json:function(){return Q}});var w={};n.r(w),n.d(w,{json:function(){return J}});var T={};n.r(T),n.d(T,{OP_SCOPE_SUFFIX:function(){return ge.BTT},abs:function(){return ge.tnl},acos:function(){return ge.HQu},acosh:function(){return ge.FqL},add:function(){return ge.WQq},addN:function(){return ge.QiD},all:function(){return ge.Q7R},any:function(){return ge.bzn},argMax:function(){return ge.FLi},argMin:function(){return ge.XRg},asin:function(){return ge.qRo},asinh:function(){return ge.yHs},atan:function(){return ge.rYl},atan2:function(){return ge.FPz},atanh:function(){return ge.rfv},avgPool:function(){return ge.$jT},avgPool3d:function(){return ge.sub},basicLSTMCell:function(){return ge.lZX},batchNorm:function(){return ge.$v7},batchNorm2d:function(){return ge.BFc},batchNorm3d:function(){return ge.kSi},batchNorm4d:function(){return ge.T5N},batchToSpaceND:function(){return ge.GTe},bincount:function(){return ge.HbZ},booleanMaskAsync:function(){return ge.ftb},broadcastArgs:function(){return ge.ROE},broadcastTo:function(){return ge.hOW},buffer:function(){return ge.ra8},cast:function(){return ge.wgE},ceil:function(){return ge.mkO},clipByValue:function(){return ge.zQh},clone:function(){return ge.o8B}
2,complex:function(){return ge.faB},concat:function(){return ge.xWs},concat1d:function(){return ge.I1m},concat2d:function(){return ge.RPU},concat3d:function(){return ge.O5O},concat4d:function(){return ge.P1l},conv1d:function(){return ge.kA9},conv2d:function(){return ge.Xtf},conv2dTranspose:function(){return ge.wX9},conv3d:function(){return ge.IPL},conv3dTranspose:function(){return ge.jIJ},cos:function(){return ge.gnS},cosh:function(){return ge.yIG},cosineWindow:function(){return ge._jP},cumprod:function(){return ge.Lp0},cumsum:function(){return ge.rCv},denseBincount:function(){return ge.aOp},depthToSpace:function(){return ge.Rj8},depthwiseConv2d:function(){return ge.Gl3},diag:function(){return ge.smy},dilation2d:function(){return ge.X7t},div:function(){return ge.y4m},divNoNan:function(){return ge.ek5},dot:function(){return ge.Omf},dropout:function(){return ge.EZY},einsum:function(){return ge._3C},elu:function(){return ge.Pqc},enclosingPowerOfTwo:function(){return ge.FJY},equal:function(){return ge.LCg},erf:function(){return ge.Y12},euclideanNorm:function(){return ge.p4S},exp:function(){return ge.oNF},expandDims:function(){return ge.UG6},expm1:function(){return ge.IYd},eye:function(){return ge.y5U},fft:function(){return ge.hVP},fill:function(){return ge.GSj},floor:function(){return ge.RIf},floorDiv:function(){return ge.wh_},fused:function(){return ge.cZk},gather:function(){return ge.kgh},gatherND:function(){return ge.SY9},greater:function(){return ge.rhj},greaterEqual:function(){return ge.DQN},ifft:function(){return ge.KGM},imag:function(){return ge.ngS},image:function(){return ge.Slp},inTopKAsync:function(){return ge.U4u},irfft:function(){return ge.ggX},isFinite:function(){return ge.MIs},isInf:function(){return ge.EN4},isNaN:function(){return ge.yrW},leakyRelu:function(){return ge.H8d},less:function(){return ge.M7h},lessEqual:function(){return ge.InN},linalg:function(){return ge.mPL},linspace:function(){return ge.mT8},localResponseNormalization:function(){return ge.Kgs},log:function(){return ge.Rm2},log1p:function(){return ge.Kko},logSigmoid:function(){return ge.nqI},logSoftmax:function(){return ge.HPB},logSumExp:function(){return ge.VZ},logicalAnd:function(){return ge.n76},logicalNot:function(){return ge.NSZ},logicalOr:function(){return ge.ztW},logicalXor:function(){return ge.rxB},losses:function(){return ge.YYh},lowerBound:function(){return ge.yzS},matMul:function(){return ge.NoW},max:function(){return ge.T9B},maxPool:function(){return ge.jgi},maxPool3d:function(){return ge.NYV},maxPoolWithArgmax:function(){return ge.RO},maximum:function(){return ge.PhQ},mean:function(){return ge.i2o},meshgrid:function(){return ge.OYQ},min:function(){return ge.jkA},minimum:function(){return ge.BpO},mirrorPad:function(){return ge.FFZ},mod:function(){return ge.ziu},moments:function(){return ge.Clk},movingAverage:function(){return ge.CRk},mul:function(){return ge.lKK},multiRNNCell:function(){return ge.YDF},multinomial:function(){return ge.OjQ},neg:function(){return ge.HZy},norm:function(){return ge.xbf},notEqual:function(){return ge.Ec},oneHot:function(){return ge.Mw0},ones:function(){return ge.SaS},onesLike:function(){return ge.P61},op:function(){return ge.op},outerProduct:function(){return ge.X4o},pad:function(){return ge.eVF},pad1d:function(){return ge.BZs},pad2d:function(){return ge.grY},pad3d:function(){return ge.XHu},pad4d:function(){return ge.WLX},pool:function(){return ge.dzn},pow:function(){return ge.n7C},prelu:function(){return ge.NsG},print:function(){return ge.yyV},prod:function(){return ge._eU},raggedGather:function(){return ge.whe},raggedTensorToTensor:function(){return ge.Q0_},rand:function(){return ge._9M},randomGamma:function(){return ge.pR9},randomNormal:function(){return ge.FE$},randomStandardNormal:function(){return ge.m0H},randomUniform:function(){return ge.YeY},range:function(){return ge.y17},real:function(){return ge.xav},reciprocal:function(){return ge.VOZ},relu:function(){return ge.VVh},relu6:function(){return ge.j__},reshape:function(){return ge.tQQ},reverse:function(){return ge.BEg},reverse1d:function(){return ge.QD2},reverse2d:function(){return ge.LMr},reverse3d:function(){return ge.I2l},reverse4d:function(){return ge.JYU},rfft:function(){return ge.z8$},round:function(){return ge.LIG},rsqrt:function(){return ge.Z$r},scalar:function(){return ge.d_2},scatterND:function(){return ge.NFr},searchSorted:function(){return ge.sZg},selu:function(){return ge.WfX},separableConv2d:function(){return ge.wdz},setdiff1dAsync:function(){return ge.F12},sigmoid:function(){return ge.ry7},sign:function(){return ge._SZ},signal:function(){return ge.vPA},sin:function(){return ge.F8e},sinh:function(){return ge.L0l},slice:function(){return ge.dik},slice1d:function(){return ge.Q$M},slice2d:function(){return ge.zAd},slice3d:function(){return ge.wck},slice4d:function(){return ge.R0O},softmax:function(){return ge.Vs9},softplus:function(){return ge.lw0},spaceToBatchND:function(){return ge.eDJ},sparse:function(){return ge.lMo},sparseToDense:function(){return ge.Zhr},spectral:function(){return ge.lOn},split:function(){return ge.lDo},sqrt:function(){return ge.RZD},square:function(){return ge.EwI},squaredDifference:function(){return ge.Pbu},squeeze:function(){return ge.r2V},stack:function(){return ge.t$z},step:function(){return ge.PMw},stridedSlice:function(){return ge.Ym9},string:function(){return ge.YjP},sub:function(){return ge.jbE},sum:function(){return ge.czq},tan:function(){return ge.Mlm},tanh:function(){return ge.ymU},tensor:function(){return ge.OEK},tensor1d:function(){return ge.tGX},tensor2d:function(){return ge.KtR},tensor3d:function(){return ge.$_$},tensor4d:function(){return ge.g9W},tensor5d:function(){return ge.Lpo},tensor6d:function(){return ge.yxw},tile:function(){return ge.Vsq},topk:function(){return ge.rfw},transpose:function(){return ge.mgz},truncatedNormal:function(){return ge.efE},unique:function(){return ge.AmM},unsortedSegmentSum:function(){return ge.zAU},unstack:function(){return ge.K$i},upperBound:function(){return ge.rni},variable:function(){return ge.bvq},where:function(){return ge._M9},whereAsync:function(){return ge.YJN},zeros:function(){return ge.Ul9},zerosLike:function(){return ge.POl}});var S=n(77367);var C,k;(0,S._K2)().registerFlag("KEEP_INTERMEDIATE_TENSORS",()=>!1,e=>{}),function(e){e[e.DT_INVALID=0]="DT_INVALID",e[e.DT_FLOAT=1]="DT_FLOAT",e[e.DT_DOUBLE=2]="DT_DOUBLE",e[e.DT_INT32=3]="DT_INT32",e[e.DT_UINT8=4]="DT_UINT8",e[e.DT_INT16=5]="DT_INT16",e[e.DT_INT8=6]="DT_INT8",e[e.DT_STRING=7]="DT_STRING",e[e.DT_COMPLEX64=8]="DT_COMPLEX64",e[e.DT_INT64=9]="DT_INT64",e[e.DT_BOOL=10]="DT_BOOL",e[e.DT_QINT8=11]="DT_QINT8",e[e.DT_QUINT8=12]="DT_QUINT8",e[e.DT_QINT32=13]="DT_QINT32",e[e.DT_BFLOAT16=14]="DT_BFLOAT16",e[e.DT_QINT16=15]="DT_QINT16",e[e.DT_QUINT16=16]="DT_QUINT16",e[e.DT_UINT16=17]="DT_UINT16",e[e.DT_COMPLEX128=18]="DT_COMPLEX128",e[e.DT_HALF=19]="DT_HALF",e[e.DT_RESOURCE=20]="DT_RESOURCE",e[e.DT_VARIANT=2
21]="DT_VARIANT",e[e.DT_UINT32=22]="DT_UINT32",e[e.DT_UINT64=23]="DT_UINT64",e[e.DT_FLOAT_REF=101]="DT_FLOAT_REF",e[e.DT_DOUBLE_REF=102]="DT_DOUBLE_REF",e[e.DT_INT32_REF=103]="DT_INT32_REF",e[e.DT_UINT8_REF=104]="DT_UINT8_REF",e[e.DT_INT16_REF=105]="DT_INT16_REF",e[e.DT_INT8_REF=106]="DT_INT8_REF",e[e.DT_STRING_REF=107]="DT_STRING_REF",e[e.DT_COMPLEX64_REF=108]="DT_COMPLEX64_REF",e[e.DT_INT64_REF=109]="DT_INT64_REF",e[e.DT_BOOL_REF=110]="DT_BOOL_REF",e[e.DT_QINT8_REF=111]="DT_QINT8_REF",e[e.DT_QUINT8_REF=112]="DT_QUINT8_REF",e[e.DT_QINT32_REF=113]="DT_QINT32_REF",e[e.DT_BFLOAT16_REF=114]="DT_BFLOAT16_REF",e[e.DT_QINT16_REF=115]="DT_QINT16_REF",e[e.DT_QUINT16_REF=116]="DT_QUINT16_REF",e[e.DT_UINT16_REF=117]="DT_UINT16_REF",e[e.DT_COMPLEX128_REF=118]="DT_COMPLEX128_REF",e[e.DT_HALF_REF=119]="DT_HALF_REF",e[e.DT_RESOURCE_REF=120]="DT_RESOURCE_REF",e[e.DT_VARIANT_REF=121]="DT_VARIANT_REF",e[e.DT_UINT32_REF=122]="DT_UINT32_REF",e[e.DT_UINT64_REF=123]="DT_UINT64_REF"}(C||(C={})),function(e){let t;!function(e){e[e.LEGACY=0]="LEGACY",e[e.V1=1]="V1",e[e.V2=2]="V2"}(t=e.CheckpointFormatVersion||(e.CheckpointFormatVersion={}))}(k||(k={}));const E={};function $(e){return E[e]}function N(e,t,n,r,a){const o=t.inputParams[e];if(o&&void 0!==o.inputIndexStart){const e=o.inputIndexStart,s=0===o.inputIndexEnd?void 0:void 0===o.inputIndexEnd?e+1:o.inputIndexEnd;if("tensor"===o.type)return I(t.inputNames[o.inputIndexStart],n,r,a);if("tensors"===o.type){return t.inputNames.slice(e,s).map(e=>I(e,n,r,a))}const i=I(t.inputNames.slice(e)[0],n,r,a),u=i.dataSync();return"number"===o.type?u[0]:S.ZSL.toNestedArray(i.shape,u)}const s=t.attrParams[e];return s&&s.value}function I(e,t,n,r){const[a,o]=_(e);if(null!=r){const e=r.getHashTableHandleByName(a);if(null!=e)return e}const s=n.currentContextIds.find(e=>!!t[R(a,e)]);return void 0!==s?t[R(a,s)][o]:void 0}function A(e,t){const[n,r,a]=_(e);return[R(n,t&&t.currentContextId),r,a]}function R(e,t){return t?`${e}-${t}`:e}function _(e){const t=e.split(":");if(1===t.length)return[e,0,void 0];const n=t[0],r=3===t.length?t[1]:void 0;return[n,Number(t[t.length-1]),r]}function O(e,t,n){let r=N("pad",e,t,n);if("explicit"===r){r=N("explicitPaddings",e,t,n);const a=[[0,0],[0,0],[0,0],[0,0]];for(let e=0;e<4;e++)a[e][0]=r[2*e],a[e][1]=r[2*e+1];return a}return r}function F(e){return e.kept?e:(0,S.o8B)(e)}const D=[{tfOpName:"Add",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"AddV2",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"AddN",category:"arithmetic",inputs:[{start:0,end:0,name:"tensors",type:"tensors"}]},{tfOpName:"BiasAdd",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0},{tfName:"data_format",name:"dataFormat",type:"string",notSupported:!0}]},{tfOpName:"Sub",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"RealDiv",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Div",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"DivNoNan",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"FloorDiv",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Mul",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}
2]},{tfOpName:"Maximum",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Minimum",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Pow",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"SquaredDifference",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Mod",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"FloorMod",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]}],L=[{tfOpName:"Abs",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Acos",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Asin",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Atan",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Atan2",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"y",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Ceil",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"ClipByValue",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"clipValueMin",type:"number"},{start:2,name:"clipValueMax",type:"number"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Complex",category:"basic_math",inputs:[{start:0,name:"real",type:"tensor"},{start:1,name:"imag",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"ComplexAbs",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Cos",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Cosh",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Elu",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Exp",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Floor",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Log",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Imag",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0},{tfName:"Tout",name:"outputType",type:"dtype",notSupported:!0}]},{tfOpName:"Neg",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Real",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0},{tfName:"Tout",name:"outputType",type:"dtype",notSupported:!0}]},{tfOpName:"Prelu",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"alpha",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}
2]},{tfOpName:"Relu",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Relu6",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Selu",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Sigmoid",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Sin",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Sinh",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Sqrt",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Rsqrt",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Square",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Tan",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Tanh",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Sign",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Round",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Expm1",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Log1p",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Reciprocal",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Softplus",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Asinh",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Acosh",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Atanh",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Erf",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Prod",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axes",type:"number[]"}],attrs:[{tfName:"keep_dims",name:"keepDims",type:"bool",notSupported:!0},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"LeakyRelu",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"alpha",name:"alpha",type:"number",defaultValue:.2},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"IsNan",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]}],M=[{tfOpName:"EmptyTensorList",category:"control",inputs:[{start:0,name:"elementShape",type:"shape"},{start:1,name:"maxNumElements",type:"number"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"LoopCond",category:"control",inputs:[{start:0,name:"pred",type:"tensor"}]},{tfOpName:"Switch",category:"control",inputs:[{start:0,name:"data",type:"tensor"},{start:1,name:"pred",type:"tensor"}]}
2,{tfOpName:"Merge",category:"control",inputs:[{start:0,end:0,name:"tensors",type:"tensors"}]},{tfOpName:"Enter",category:"control",inputs:[{start:0,name:"tensor",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0},{tfName:"frame_name",name:"frameName",type:"string"},{tfName:"is_constant",name:"isConstant",type:"bool"}]},{tfOpName:"Exit",category:"control",inputs:[{start:0,name:"tensor",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"NextIteration",category:"control",inputs:[{start:0,name:"tensor",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"TensorArrayV3",category:"control",inputs:[{start:0,name:"size",type:"number"}],attrs:[{tfName:"dtype",name:"dtype",type:"dtype"},{tfName:"element_shape",name:"elementShape",type:"shape"},{tfName:"dynamic_size",name:"dynamicSize",type:"bool"},{tfName:"clear_after_read",name:"clearAfterRead",type:"bool"},{tfName:"identical_element_shapes",name:"identicalElementShapes",type:"bool"},{tfName:"tensor_array_name",name:"name",type:"string"}]},{tfOpName:"TensorArrayWriteV3",category:"control",inputs:[{start:0,name:"tensorArrayId",type:"tensor"},{start:1,name:"index",type:"number"},{start:2,name:"tensor",type:"tensor"},{start:3,name:"flowIn",type:"number"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"TensorArrayReadV3",category:"control",inputs:[{start:0,name:"tensorArrayId",type:"tensor"},{start:1,name:"index",type:"number"},{start:2,name:"flowIn",type:"number"}],attrs:[{tfName:"dtype",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"TensorArrayGatherV3",category:"control",inputs:[{start:0,name:"tensorArrayId",type:"tensor"},{start:1,name:"indices",type:"number[]"},{start:2,name:"flowIn",type:"number"}],attrs:[{tfName:"dtype",name:"dtype",type:"dtype"},{tfName:"element_shape",name:"elementShape",type:"shape"}]},{tfOpName:"TensorArrayScatterV3",category:"control",inputs:[{start:0,name:"tensorArrayId",type:"tensor"},{start:1,name:"indices",type:"number[]"},{start:2,name:"tensor",type:"tensor"},{start:3,name:"flowIn",type:"number"}],attrs:[{tfName:"T",name:"dtype",type:"dtype"}]},{tfOpName:"TensorArrayConcatV3",category:"control",inputs:[{start:0,name:"tensorArrayId",type:"tensor"},{start:1,name:"flowIn",type:"number"}],attrs:[{tfName:"dtype",name:"dtype",type:"dtype"},{tfName:"element_shape_except0",name:"elementShapeExcept0",type:"shape",notSupported:!0}]},{tfOpName:"TensorArraySplitV3",category:"control",inputs:[{start:0,name:"tensorArrayId",type:"tensor"},{start:1,name:"tensor",type:"tensor"},{start:2,name:"lengths",type:"number[]"},{start:3,name:"flowIn",type:"number"}],attrs:[{tfName:"T",name:"dtype",type:"dtype"}]},{tfOpName:"TensorArraySizeV3",category:"control",inputs:[{start:0,name:"tensorArrayId",type:"tensor"},{start:1,name:"flowIn",type:"number"}]},{tfOpName:"TensorArrayCloseV3",category:"control",inputs:[{start:0,name:"tensorArrayId",type:"tensor"}]},{tfOpName:"StatelessIf",category:"control",inputs:[{start:0,name:"cond",type:"tensor"},{start:1,end:0,name:"args",type:"tensors"}],attrs:[{tfName:"then_branch",name:"thenBranch",type:"func"},{tfName:"else_branch",name:"elseBranch",type:"func"}]},{tfOpName:"If",category:"control",inputs:[{start:0,name:"cond",type:"tensor"},{start:1,end:0,name:"args",type:"tensors"}],attrs:[{tfName:"then_branch",name:"thenBranch",type:"func"},{tfName:"else_branch",name:"elseBranch",type:"func"}]},{tfOpName:"StatelessWhile",category:"control",inputs:[{start:0,end:0,name:"args",type:"tensors"}],attrs:[{tfName:"cond",name:"cond",type:"func"},{tfName:"body",name:"body",type:"func"}]},{tfOpName:"While",category:"control",inputs:[{start:0,end:0,name:"args",type:"tensors"}],attrs:[{tfName:"cond",name:"cond",type:"func"},{tfName:"body",name:"body",type:"func"}]},{tfOpName:"TensorListScatter",category:"control",inputs:[{start:0,name:"tensor",type:"tensor"},{start:1,name:"indices",type:"number[]"},{start:2,name:"elementShape",type:"shape"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]}
2,{tfOpName:"TensorListScatterV2",category:"control",inputs:[{start:0,name:"tensor",type:"tensor"},{start:1,name:"indices",type:"number[]"},{start:2,name:"elementShape",type:"shape"},{start:3,name:"numElements",type:"number"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListGather",category:"control",inputs:[{start:0,name:"tensorListId",type:"tensor"},{start:1,name:"indices",type:"number[]"},{start:2,name:"elementShape",type:"shape"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListGetItem",category:"control",inputs:[{start:0,name:"tensorListId",type:"tensor"},{start:1,name:"index",type:"number"},{start:2,name:"elementShape",type:"shape"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListSetItem",category:"control",inputs:[{start:0,name:"tensorListId",type:"tensor"},{start:1,name:"index",type:"number"},{start:2,name:"tensor",type:"tensor"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListReserve",category:"control",inputs:[{start:0,name:"elementShape",type:"shape"},{start:1,name:"numElements",type:"number"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListFromTensor",category:"control",inputs:[{start:0,name:"tensor",type:"tensor"},{start:1,name:"elementShape",type:"shape"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListStack",category:"control",inputs:[{start:0,name:"tensorListId",type:"tensor"},{start:1,name:"elementShape",type:"shape"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"},{tfName:"num_elements",name:"numElements",type:"dtype"}]},{tfOpName:"TensorListSplit",category:"control",inputs:[{start:0,name:"tensor",type:"tensor"},{start:1,name:"elementShape",type:"shape"},{start:2,name:"lengths",type:"number[]"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListConcat",category:"control",inputs:[{start:0,name:"tensorListId",type:"tensor"}],attrs:[{tfName:"element_shape",name:"elementShape",type:"shape"},{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListConcatV2",category:"control",inputs:[{start:0,name:"tensorListId",type:"tensor"}],attrs:[{tfName:"element_shape",name:"elementShape",type:"shape"},{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListPopBack",category:"control",inputs:[{start:0,name:"tensorListId",type:"tensor"},{start:1,name:"elementShape",type:"shape"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListPushBack",category:"control",inputs:[{start:0,name:"tensorListId",type:"tensor"},{start:1,name:"tensor",type:"tensor"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListLength",category:"control",inputs:[{start:0,name:"tensorListId",type:"tensor"}]},{tfOpName:"TensorListResize",category:"control",inputs:[{start:0,name:"tensorListId",type:"tensor"},{start:1,name:"size",type:"number"}]}],P=[{tfOpName:"AvgPool",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",notSupported:!0},{tfName:"ksize",name:"kernelSize",type:"number[]"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"MaxPool",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",notSupported:!0},{tfName:"ksize",name:"kernelSize",type:"number[]"},{tfName:"explicit_paddings",name:"explicitPaddings",type:"number[]",defaultValue:[],notSupported:!0},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"MaxPoolWithArgmax",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"ksize",name:"kernelSize",type:"number[]"},{tfName:"include_batch_in_index",name:"includeBatchInIndex",type:"bool"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}
vendor: 9,231 bytes, line 2
2]},{tfOpName:"AvgPool3D",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",notSupported:!0},{tfName:"ksize",name:"kernelSize",type:"number[]"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"MaxPool3D",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",notSupported:!0},{tfName:"ksize",name:"kernelSize",type:"number[]"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Conv1D",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"filter",type:"tensor"}],attrs:[{tfName:"stride",name:"stride",type:"number"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",defaultValue:"NWC"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0},{tfName:"dilation",name:"dilation",type:"number",defaultValue:1}]},{tfOpName:"Conv2D",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"filter",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0},{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"useCudnnOnGpu",name:"useCudnnOnGpu",type:"bool"},{tfName:"data_format",name:"dataFormat",type:"string",defaultValue:"NHWC"},{tfName:"explicit_paddings",name:"explicitPaddings",type:"number[]",defaultValue:[]},{tfName:"dilations",name:"dilations",type:"number[]"}]},{tfOpName:"_FusedConv2D",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"filter",type:"tensor"},{start:2,end:0,name:"args",type:"tensors"}],attrs:[{tfName:"num_args",name:"numArgs",type:"number"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0},{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"explicit_paddings",name:"explicitPaddings",type:"number[]",defaultValue:[]},{tfName:"use_cudnn_on_gpu",name:"useCudnnOnGpu",type:"bool",defaultValue:!0},{tfName:"data_format",name:"dataFormat",type:"string",defaultValue:"NHWC"},{tfName:"dilations",name:"dilations",type:"number[]",defaultValue:[1,1,1,1]},{tfName:"fused_ops",name:"fusedOps",type:"string[]",defaultValue:[]},{tfName:"epsilon",name:"epsilon",type:"number",defaultValue:1e-4},{tfName:"leakyrelu_alpha",name:"leakyreluAlpha",type:"number",defaultValue:.2}]},{tfOpName:"Conv2DBackpropInput",category:"convolution",inputs:[{start:2,name:"x",type:"tensor"},{start:1,name:"filter",type:"tensor"},{start:0,name:"outputShape",type:"number[]"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",notSupported:!0},{tfName:"explicit_paddings",name:"explicitPaddings",type:"number[]",defaultValue:[]},{tfName:"dilations",name:"dilations",type:"number[]",notSupported:!0}]},{tfOpName:"DepthwiseConv2d",category:"convolution",inputs:[{start:0,name:"input",type:"tensor"},{start:1,name:"filter",type:"tensor"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",defaultValue:"NHWC"},{tfName:"explicit_paddings",name:"explicitPaddings",type:"number[]",defaultValue:[]},{tfName:"dilations",name:"dilations",type:"number[]"}]},{tfOpName:"DepthwiseConv2dNative",category:"convolution",inputs:[{start:0,name:"input",type:"tensor"},{start:1,name:"filter",type:"tensor"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",defaultValue:"NHWC"},{tfName:"explicit_paddings",name:"explicitPaddings",type:"number[]",defaultValue:[]},{tfName:"dilations",name:"dilations",type:"number[]"}]},{tfOpName:"FusedDepthwiseConv2dNative",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"filter",type:"tensor"},{start:2,end:0,name:"args",type:"tensors"}],attrs:[{tfName:"num_args",name:"numArgs",type:"number"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0},{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",defaultValue:"NHWC"},{tfName:"dilations",name:"dilations",type:"number[]",defaultValue:[1,1,1,1]},{tfName:"fused_ops",name:"fusedOps",type:"string[]",defaultValue:[]},{tfName:"explicit_paddings",name:"explicitPaddings",type:"number[]",defaultValue:[]}]},{tfOpName:"Conv3D",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"filter",type:"tensor"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",defaultValue:"NHWC"},{tfName:"dilations",name:"dilations",type:"number[]"}]},{tfOpName:"Dilation2D",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"filter",type:"tensor"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"rates",name:"dilations",type:"number[]"},{tfName:"padding",name:"pad",type:"string"}]}],B=[{tfOpName:"Fill",category:"creation",inputs:[{start:0,name:"shape",type:"number[]"},{start:1,name:"value",type:"number"}],attrs:[{tfName:"T",name:"dtype",type:"dtype"}]},{tfOpName:"LinSpace",category:"creation",inputs:[{start:0,name:"start",type:"number"},{start:1,name:"stop",type:"number"},{start:2,name:"num",type:"number"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"OneHot",category:"creation",inputs:[{start:0,name:"indices",type:"tensor"},{start:1,name:"depth",type:"number"},{start:2,name:"onValue",type:"number",defaultValue:1},{start:3,name:"offValue",type:"number",defaultValue:0}],attrs:[{tfName:"axis",name:"axis",type:"number",notSupported:!0},{tfName:"T",name:"dtype",type:"dtype"}]},{tfOpName:"Ones",category:"creation",inputs:[{start:0,name:"shape",type:"number[]"}],attrs:[{tfName:"T",name:"dtype",type:"dtype"}]},{tfOpName:"OnesLike",category:"creation",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"dtype",name:"dtype",type:"dtype"}]},{tfOpName:"RandomStandardNormal",category:"creation",inputs:[{start:0,name:"shape",type:"number[]"}],attrs:[{tfName:"seed",name:"seed",type:"number",defaultValue:0},{tfName:"seed2",name:"seed2",type:"number",defaultValue:0,notSupported:!0},{tfName:"dtype",name:"dtype",type:"dtype"},{tfName:"T",name:"T",type:"number",notSupported:!0}]},{tfOpName:"RandomUniform",category:"creation",inputs:[{start:0,name:"shape",type:"number[]"}],attrs:[{tfName:"minval",name:"minval",type:"number",defaultValue:0},{tfName:"maxval",name:"maxval",type:"number",defaultValue:1},{tfName:"dtype",name:"dtype",type:"dtype"},{tfName:"seed",name:"seed",type:"number",defaultValue:0},{tfName:"seed2",name:"seed2",type:"number",defaultValue:0,notSupported:!0},{tfName:"T",name:"T",type:"number",notSupported:!0}]},{tfOpName:"Range",category:"creation",inputs:[{start:0,name:"start",type:"number"},{start:1,name:"stop",type:"number"},{start:2,name:"step",type:"number",defaultValue:0}],attrs:[{tfName:"Tidx",name:"dtype",type:"dtype"}]},{tfOpName:"TruncatedNormal",category:"creation",inputs:[{start:0,name:"shape",type:"number[]"}],attrs:[{tfName:"means",name:"mean",type:"number",defaultValue:0},{tfName:"stddev",name:"stdDev",type:"number",defaultValue:1},{tfName:"seed",name:"seed",type:"number"},{tfName:"seed2",name:"seed2",type:"number",defaultValue:0,notSupported:!0},{tfName:"dtype",name:"dtype",type:"dtype"},{tfName:"T",name:"T",type:"number",notSupported:!0}]},{tfOpName:"Zeros",category:"creation",inputs:[{start:0,name:"shape",type:"number[]"}],attrs:[{tfName:"T",name:"dtype",type:"dtype"}]},{tfOpName:"ZerosLike",category:"creation",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype"}]},{tfOpName:"Multinomial",category:"creation",inputs:[{start:0,name:"logits",type:"tensor"},{start:1,name:"numSamples",type:"number"}],attrs:[{tfName:"seed",name:"seed",type:"number"},{tfName:"seed2",name:"seed2",type:"number"},{tfName:"T",name:"dtype",type:"dtype"},{tfName:"output_dtype",name:"output_dtype",type:"dtype"}]}],V=[{tfOpName:"NonMaxSuppressionV2",category:"dynamic",inputs:[{start:0,name:"boxes",type:"tensor"},{start:1,name:"scores",type:"tensor"},{start:2,name:"maxOutputSize",type:"number"},{start:3,name:"iouThreshold",type:"number"}]},{tfOpName:"NonMaxSuppressionV3",category:"dynamic",inputs:[{start:0,name:"boxes",type:"tensor"},{start:1,name:"scores",type:"tensor"},{start:2,name:"maxOutputSize",type:"number"},{start:3,name:"iouThreshold",type:"number"},{start:4,name:"scoreThreshold",type:"number"}]},{tfOpName:"NonMaxSuppressionV4",category:"dynamic",inputs:[{start:0,name:"boxes",type:"tensor"},{start:1,name:"scores",type:"tensor"},{start:2,name:"maxOutputSize",type:"number"},{start:3,name:"iouThreshold",type:"number"},{start:4,name:"scoreThreshold",type:"number"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}
2,{tfName:"T_threshold",name:"threshold",type:"dtype",notSupported:!0},{tfName:"pad_to_max_output_size",name:"padToMaxOutputSize",type:"bool"}]},{tfOpName:"NonMaxSuppressionV5",category:"dynamic",inputs:[{start:0,name:"boxes",type:"tensor"},{start:1,name:"scores",type:"tensor"},{start:2,name:"maxOutputSize",type:"number"},{start:3,name:"iouThreshold",type:"number"},{start:4,name:"scoreThreshold",type:"number"},{start:5,name:"softNmsSigma",type:"number"}]},{tfOpName:"Where",category:"dynamic",inputs:[{start:0,name:"condition",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"ListDiff",category:"dynamic",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"y",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]}],z=[{tfOpName:"LowerBound",category:"evaluation",inputs:[{start:0,name:"sortedSequence",type:"tensor"},{start:1,name:"values",type:"tensor"}]},{tfOpName:"TopKV2",category:"evaluation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"k",type:"number"}],attrs:[{tfName:"sorted",name:"sorted",type:"bool"}]},{tfOpName:"UpperBound",category:"evaluation",inputs:[{start:0,name:"sortedSequence",type:"tensor"},{start:1,name:"values",type:"tensor"}]},{tfOpName:"Unique",category:"evaluation",inputs:[{start:0,name:"x",type:"tensor"}]},{tfOpName:"UniqueV2",category:"evaluation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number"}]}],U=[{tfOpName:"PlaceholderWithDefault",category:"graph",inputs:[{start:0,name:"default",type:"tensor"}],attrs:[{tfName:"shape",name:"shape",type:"shape"},{tfName:"dtype",name:"dtype",type:"dtype"}]},{tfOpName:"Placeholder",category:"graph",attrs:[{tfName:"shape",name:"shape",type:"shape"},{tfName:"dtype",name:"dtype",type:"dtype"}]},{tfOpName:"Const",category:"graph"},{tfOpName:"Identity",category:"graph",inputs:[{start:0,name:"x",type:"tensor"}]},{tfOpName:"IdentityN",category:"graph",inputs:[{start:0,end:0,name:"x",type:"tensors"}]},{tfOpName:"Snapshot",category:"graph",inputs:[{start:0,name:"x",type:"tensor"}]},{tfOpName:"Rank",category:"graph",inputs:[{start:0,name:"x",type:"tensor"}]},{tfOpName:"Size",category:"graph",inputs:[{start:0,name:"x",type:"tensor"}]},{tfOpName:"Shape",category:"graph",inputs:[{start:0,name:"x",type:"tensor"}]},{tfOpName:"ShapeN",category:"graph",inputs:[{start:0,end:0,name:"x",type:"tensors"}]},{tfOpName:"Print",category:"graph",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"data",type:"tensors"}],attrs:[{tfName:"message",name:"message",type:"string"},{tfName:"first_n",name:"firstN",type:"number",notSupported:!0},{tfName:"summarize",name:"summarize",type:"number",defaultValue:3}]},{tfOpName:"NoOp",category:"graph",inputs:[]},{tfOpName:"StopGradient",category:"graph",inputs:[{start:0,name:"x",type:"tensor"}]},{tfOpName:"FakeQuantWithMinMaxVars",category:"graph",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"min",name:"min",type:"number"},{tfName:"max",name:"max",type:"number"}]}],W=[{tfOpName:"HashTable",category:"hash_table",inputs:[],attrs:[{tfName:"shared_name",name:"sharedName",type:"string"},{tfName:"use_node_name_sharing",name:"useNodeNameSharing",type:"bool"},{tfName:"key_dtype",name:"keyDType",type:"dtype"},{tfName:"value_dtype",name:"valueDType",type:"dtype"}]},{tfOpName:"HashTableV2",category:"hash_table",inputs:[],attrs:[{tfName:"shared_name",name:"sharedName",type:"string"},{tfName:"use_node_name_sharing",name:"useNodeNameSharing",type:"bool"},{tfName:"key_dtype",name:"keyDType",type:"dtype"},{tfName:"value_dtype",name:"valueDType",type:"dtype"}]},{tfOpName:"LookupTableImport",category:"hash_table",inputs:[{start:0,name:"tableHandle",type:"tensor"},{start:1,name:"keys",type:"tensor"},{start:2,name:"values",type:"tensor"}],attrs:[{tfName:"Tin",name:"tIn",type:"dtype",notSupported:!0},{tfName:"Tout",name:"tOut",type:"dtype",notSupported:!0}]},{tfOpName:"LookupTableImportV2",category:"hash_table",inputs:[{start:0,name:"tableHandle",type:"tensor"},{start:1,name:"keys",type:"tensor"},{start:2,name:"values",type:"tensor"}],attrs:[{tfName:"Tin",name:"tIn",type:"dtype",notSupported:!0}
2,{tfName:"Tout",name:"tOut",type:"dtype",notSupported:!0}]},{tfOpName:"LookupTableFind",category:"hash_table",inputs:[{start:0,name:"tableHandle",type:"tensor"},{start:1,name:"keys",type:"tensor"},{start:2,name:"defaultValue",type:"tensor"}],attrs:[{tfName:"Tin",name:"tIn",type:"dtype",notSupported:!0},{tfName:"Tout",name:"tOut",type:"dtype",notSupported:!0}]},{tfOpName:"LookupTableFindV2",category:"hash_table",inputs:[{start:0,name:"tableHandle",type:"tensor"},{start:1,name:"keys",type:"tensor"},{start:2,name:"defaultValue",type:"tensor"}],attrs:[{tfName:"Tin",name:"tIn",type:"dtype",notSupported:!0},{tfName:"Tout",name:"tOut",type:"dtype",notSupported:!0}]},{tfOpName:"LookupTableSize",category:"hash_table",inputs:[{start:0,name:"tableHandle",type:"tensor"}]},{tfOpName:"LookupTableSizeV2",category:"hash_table",inputs:[{start:0,name:"tableHandle",type:"tensor"}]}],G=[{tfOpName:"ResizeBilinear",category:"image",inputs:[{start:0,name:"images",type:"tensor"},{start:1,name:"size",type:"number[]"}],attrs:[{tfName:"align_corners",name:"alignCorners",type:"bool"},{tfName:"half_pixel_centers",name:"halfPixelCenters",type:"bool"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"ResizeNearestNeighbor",category:"image",inputs:[{start:0,name:"images",type:"tensor"},{start:1,name:"size",type:"number[]"}],attrs:[{tfName:"align_corners",name:"alignCorners",type:"bool"},{tfName:"half_pixel_centers",name:"halfPixelCenters",type:"bool"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"CropAndResize",category:"image",inputs:[{start:0,name:"image",type:"tensor"},{start:1,name:"boxes",type:"tensor"},{start:2,name:"boxInd",type:"tensor"},{start:3,name:"cropSize",type:"number[]"}],attrs:[{tfName:"method",name:"method",type:"string"},{tfName:"extrapolation_value",name:"extrapolationValue",type:"number"}]},{tfOpName:"ImageProjectiveTransformV3",category:"image",inputs:[{start:0,name:"images",type:"tensor"},{start:1,name:"transforms",type:"tensor"},{start:2,name:"outputShape",type:"number[]"},{start:3,name:"fillValue",type:"number"}],attrs:[{tfName:"interpolation",name:"interpolation",type:"string"},{tfName:"fill_mode",name:"fillMode",type:"string"}]}],j=[{tfOpName:"Equal",category:"logical",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"NotEqual",category:"logical",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Greater",category:"logical",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"GreaterEqual",category:"logical",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Less",category:"logical",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"LessEqual",category:"logical",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"LogicalAnd",category:"logical",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"LogicalNot",category:"logical",inputs:[{start:0,name:"a",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"LogicalOr",category:"logical",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Select",category:"logical",inputs:[{start:0,name:"condition",type:"tensor"},{start:1,name:"a",type:"tensor"},{start:2,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"SelectV2",category:"logical",inputs:[{start:0,name:"condition",type:"tensor"},{start:1,name:"a",type:"tensor"},{start:2,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}
2]}],K=[{tfOpName:"_FusedMatMul",category:"matrices",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"},{start:2,end:0,name:"args",type:"tensors"}],attrs:[{tfName:"num_args",name:"numArgs",type:"number"},{tfName:"fused_ops",name:"fusedOps",type:"string[]",defaultValue:[]},{tfName:"epsilon",name:"epsilon",type:"number",defaultValue:1e-4},{tfName:"transpose_a",name:"transposeA",type:"bool",defaultValue:!1},{tfName:"transpose_b",name:"transposeB",type:"bool",defaultValue:!1},{tfName:"leakyrelu_alpha",name:"leakyreluAlpha",type:"number",defaultValue:.2},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"MatMul",category:"matrices",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"transpose_a",name:"transposeA",type:"bool",defaultValue:!1},{tfName:"transpose_b",name:"transposeB",type:"bool",defaultValue:!1},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"BatchMatMul",category:"matrices",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"adj_x",name:"transposeA",type:"bool",defaultValue:!1},{tfName:"adj_y",name:"transposeB",type:"bool",defaultValue:!1},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"BatchMatMulV2",category:"matrices",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"adj_x",name:"transposeA",type:"bool",defaultValue:!1},{tfName:"adj_y",name:"transposeB",type:"bool",defaultValue:!1},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Transpose",category:"matrices",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"perm",type:"number[]"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Einsum",category:"matrices",inputs:[{start:0,end:0,name:"tensors",type:"tensors"}],attrs:[{tfName:"equation",name:"equation",type:"string"},{tfName:"N",name:"n",type:"number",defaultValue:2},{tfName:"T",name:"dtype",type:"dtype"}]}],H=[{tfOpName:"EuclideanNorm",category:"normalization",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number[]"}],attrs:[{tfName:"keep_dims",name:"keepDims",type:"bool",defaultValue:!1}]},{tfOpName:"FusedBatchNorm",category:"normalization",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"scale",type:"tensor"},{start:2,name:"offset",type:"tensor"},{start:3,name:"mean",type:"tensor"},{start:4,name:"variance",type:"tensor"}],attrs:[{tfName:"epsilon",name:"epsilon",type:"number",defaultValue:.001},{tfName:"data_format",name:"dataFormat",type:"string",notSupported:!0}]},{tfOpName:"FusedBatchNormV2",category:"normalization",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"scale",type:"tensor"},{start:2,name:"offset",type:"tensor"},{start:3,name:"mean",type:"tensor"},{start:4,name:"variance",type:"tensor"}],attrs:[{tfName:"epsilon",name:"epsilon",type:"number",defaultValue:.001},{tfName:"data_format",name:"dataFormat",type:"string",notSupported:!0}]},{tfOpName:"FusedBatchNormV3",category:"normalization",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"scale",type:"tensor"},{start:2,name:"offset",type:"tensor"},{start:3,name:"mean",type:"tensor"},{start:4,name:"variance",type:"tensor"}],attrs:[{tfName:"epsilon",name:"epsilon",type:"number",defaultValue:.001},{tfName:"data_format",name:"dataFormat",type:"string",notSupported:!0}]},{tfOpName:"LRN",category:"normalization",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"depth_radius",name:"radius",type:"number",defaultValue:5},{tfName:"bias",name:"bias",type:"number",defaultValue:1},{tfName:"alpha",name:"alpha",type:"number",defaultValue:1},{tfName:"beta",name:"beta",type:"number",defaultValue:.5}]},{tfOpName:"Softmax",category:"normalization",inputs:[{start:0,name:"x",type:"tensor"}]},{tfOpName:"LogSoftmax",category:"normalization",inputs:[{start:0,name:"x",type:"tensor"}]},{tfOpName:"SparseToDense",category:"normalization",inputs:[{start:0,name:"sparseIndices",type:"tensor"},{start:1,name:"outputShape",type:"number[]"},{start:2,name:"sparseValues",type:"tensor"},{start:3,name:"defaultValue",type:"tensor"}],attrs:[{tfName:"validate_indices",name:"validateIndices",type:"bool",defaultValue:!0,notSupported:!0}
2]}],Y=[{tfOpName:"Bincount",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"size",type:"number"},{start:2,name:"weights",type:"tensor"}]},{tfOpName:"DenseBincount",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"size",type:"number"},{start:2,name:"weights",type:"tensor"}],attrs:[{tfName:"binary_output",name:"binaryOutput",type:"bool"}]},{tfOpName:"Max",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number[]"}],attrs:[{tfName:"keep_dims",name:"keepDims",type:"bool"}]},{tfOpName:"Mean",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number[]"}],attrs:[{tfName:"keep_dims",name:"keepDims",type:"bool"}]},{tfOpName:"Min",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number[]"}],attrs:[{tfName:"keep_dims",name:"keepDims",type:"bool"}]},{tfOpName:"Sum",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number[]"}],attrs:[{tfName:"keep_dims",name:"keepDims",type:"bool"}]},{tfOpName:"All",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number[]"}],attrs:[{tfName:"keep_dims",name:"keepDims",type:"bool"}]},{tfOpName:"Any",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number[]"}],attrs:[{tfName:"keep_dims",name:"keepDims",type:"bool"}]},{tfOpName:"ArgMax",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number"}]},{tfOpName:"ArgMin",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number"}]},{tfOpName:"Prod",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number[]"}],attrs:[{tfName:"keep_dims",name:"keepDims",type:"bool"}]},{tfOpName:"Cumprod",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number"}],attrs:[{tfName:"exclusive",name:"exclusive",type:"bool"},{tfName:"reverse",name:"reverse",type:"bool"}]},{tfOpName:"Cumsum",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number"}],attrs:[{tfName:"exclusive",name:"exclusive",type:"bool"},{tfName:"reverse",name:"reverse",type:"bool"}]}],Z=[{tfOpName:"ConcatV2",category:"slice_join",inputs:[{start:0,end:-1,name:"tensors",type:"tensors"},{start:-1,name:"axis",type:"number"}],attrs:[{tfName:"N",name:"n",type:"number",defaultValue:2}]},{tfOpName:"Concat",category:"slice_join",inputs:[{start:1,end:0,name:"tensors",type:"tensors"},{start:0,name:"axis",type:"number"}],attrs:[{tfName:"N",name:"n",type:"number",defaultValue:2}]},{tfOpName:"GatherV2",category:"slice_join",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"indices",type:"tensor"},{start:2,name:"axis",type:"number",defaultValue:0}],attrs:[{tfName:"batch_dims",name:"batchDims",type:"number",defaultValue:0}]},{tfOpName:"Gather",category:"slice_join",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"indices",type:"tensor"}],attrs:[{tfName:"validate_indices",name:"validateIndices",type:"bool",notSupported:!0}]},{tfOpName:"Reverse",category:"slice_join",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"dims",type:"bool[]"}]},{tfOpName:"ReverseV2",category:"slice_join",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number[]"}]},{tfOpName:"Slice",category:"slice_join",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"begin",type:"number[]"},{start:2,name:"size",type:"number[]"}]},{tfOpName:"StridedSlice",category:"slice_join",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"begin",type:"number[]"},{start:2,name:"end",type:"number[]"},{start:3,name:"strides",type:"number[]"}],attrs:[{tfName:"begin_mask",name:"beginMask",type:"number",defaultValue:0},{tfName:"end_mask",name:"endMask",type:"number",defaultValue:0},{tfName:"new_axis_mask",name:"newAxisMask",type:"number",defaultValue:0},{tfName:"ellipsis_mask",name:"ellipsisMask",type:"number",defaultValue:0},{tfName:"shrink_axis_mask",name:"shrinkAxisMask",type:"number",defaultValue:0}]},{tfOpName:"Pack",category:"slice_join",inputs:[{start:0,end:0,name:"tensors",type:"tensors"}],attrs:[{tfName:"axis",name:"axis",type:"number",defaultValue:0}]},{tfOpName:"Unpack",category:"slice_join",inputs:[{start:0,name:"tensor",type:"tensor"}],attrs:[{tfName:"axis",name:"axis",type:"number",defaultValue:0},{tfName:"num",name:"num",type:"number",defaultValue:0,notSupported:!0}
2]},{tfOpName:"Tile",category:"slice_join",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"reps",type:"number[]"}]},{tfOpName:"Split",category:"slice_join",inputs:[{start:0,name:"axis",type:"number",defaultValue:0},{start:1,name:"x",type:"tensor"}],attrs:[{tfName:"num_split",name:"numOrSizeSplits",type:"number",defaultValue:1}]},{tfOpName:"SplitV",category:"slice_join",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"numOrSizeSplits",type:"number[]"},{start:2,name:"axis",type:"number",defaultValue:0}]},{tfOpName:"ScatterNd",category:"slice_join",inputs:[{start:0,name:"indices",type:"tensor"},{start:1,name:"values",type:"tensor"},{start:2,name:"shape",type:"number[]"}]},{tfOpName:"GatherNd",category:"slice_join",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"indices",type:"tensor"}]},{tfOpName:"SparseToDense",category:"slice_join",inputs:[{start:0,name:"sparseIndices",type:"tensor"},{start:1,name:"outputShape",type:"number[]"},{start:2,name:"sparseValues",type:"tensor"},{start:3,name:"defaultValue",type:"tensor"}],attrs:[{tfName:"validate_indices",name:"validateIndices",type:"bool",defaultValue:!1,notSupported:!0}]}],X=[{tfOpName:"SparseFillEmptyRows",category:"sparse",inputs:[{start:0,name:"indices",type:"tensor"},{start:1,name:"values",type:"tensor"},{start:2,name:"denseShape",type:"tensor"},{start:3,name:"defaultValue",type:"tensor"}]},{tfOpName:"SparseReshape",category:"sparse",inputs:[{start:0,name:"inputIndices",type:"tensor"},{start:1,name:"inputShape",type:"tensor"},{start:2,name:"newShape",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"SparseSegmentMean",category:"sparse",inputs:[{start:0,name:"data",type:"tensor"},{start:1,name:"indices",type:"tensor"},{start:2,name:"segmentIds",type:"tensor"}]},{tfOpName:"SparseSegmentSum",category:"sparse",inputs:[{start:0,name:"data",type:"tensor"},{start:1,name:"indices",type:"tensor"},{start:2,name:"segmentIds",type:"tensor"}]}],q=[{tfOpName:"FFT",category:"spectral",inputs:[{start:0,name:"x",type:"tensor"}]},{tfOpName:"IFFT",category:"spectral",inputs:[{start:0,name:"x",type:"tensor"}]},{tfOpName:"RFFT",category:"spectral",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"fft_length",type:"number",notSupported:!0}]},{tfOpName:"IRFFT",category:"spectral",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"fft_length",type:"number",notSupported:!0}]}],Q=[{tfOpName:"StringNGrams",category:"string",inputs:[{start:0,name:"data",type:"tensor"},{start:1,name:"dataSplits",type:"tensor"}],attrs:[{tfName:"separator",name:"separator",type:"string"},{tfName:"ngram_widths",name:"nGramWidths",type:"number[]"},{tfName:"left_pad",name:"leftPad",type:"string"},{tfName:"right_pad",name:"rightPad",type:"string"},{tfName:"pad_width",name:"padWidth",type:"number"},{tfName:"preserve_short_sequences",name:"preserveShortSequences",type:"bool"}],outputs:["ngrams","ngrams_splits"]},{tfOpName:"StringSplit",category:"string",inputs:[{start:0,name:"input",type:"tensor"},{start:1,name:"delimiter",type:"tensor"}],attrs:[{tfName:"skip_empty",name:"skipEmpty",type:"bool"}],outputs:["indices","values","shape"]},{tfOpName:"StringToHashBucketFast",category:"string",inputs:[{start:0,name:"input",type:"tensor"}],attrs:[{tfName:"num_buckets",name:"numBuckets",type:"number"}]}],J=[{tfOpName:"Cast",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"SrcT",name:"sdtype",type:"dtype",notSupported:!0},{tfName:"DstT",name:"dtype",type:"dtype"}]},{tfOpName:"ExpandDims",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number"}]},{tfOpName:"MirrorPad",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"padding",type:"number[]"}],attrs:[{tfName:"mode",name:"mode",type:"string"}]},{tfOpName:"Pad",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"padding",type:"number[]"}],attrs:[{tfName:"constant_value",name:"constantValue",type:"number",defaultValue:0}]},{tfOpName:"PadV2",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"padding",type:"number[]"},{start:2,name:"constantValue",type:"number",defaultValue:0}]},{tfOpName:"Reshape",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"shape",type:"number[]"}]},{tfOpName:"Squeeze",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"axis",tfDeprecatedName:"squeeze_dims",name:"axis",type:"number[]"}]},{tfOpName:"SpaceToBatchND",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"blockShape",type:"number[]"},{start:2,name:"paddings",type:"number[]"}]},{tfOpName:"BatchToSpaceND",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"blockShape",type:"number[]"},{start:2,name:"crops",type:"number[]"}]},{tfOpName:"DepthToSpace",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"block_size",name:"blockSize",type:"number"},{tfName:"data_format",name:"dataFormat",type:"string"}]},{tfOpName:"BroadcastTo",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"shape",type:"number[]"}],attrs:[]},{tfOpName:"BroadcastArgs",category:"transformation",inputs:[{start:0,name:"s0",type:"tensor"},{start:1,name:"s1",type:"tensor"}],attrs:[]}];class ee{static get Instance(){return this._instance||(this._instance=new this)}constructor(){const e=[].concat(...[r,a,o,s,i,u,c,l,p,h,d,f,m,g,y,x,b,v,w].map(e=>e.json));this.opMappers=e.reduce((e,t)=>
2(e[t.tfOpName]=t,e),{})}transformGraph(e,t={}){const n=e.node,r=[],a=[],o=[],s=n.reduce((e,t)=>(e[t.name]=this.mapNode(t),t.op.startsWith("Placeholder")?r.push(e[t.name]):"Const"===t.op?a.push(e[t.name]):null!=t.input&&0!==t.input.length||o.push(e[t.name]),e),{});let i=[];const u=[];let c={},l={};null!=t&&(c=this.mapSignatureEntries(t.inputs),l=this.mapSignatureEntries(t.outputs));const p=Object.keys(s);p.forEach(e=>{const t=s[e];t.inputNames.forEach((e,n)=>{const[r,,a]=A(e),o=s[r];if(null!=o.outputs){const e=o.outputs.indexOf(a);if(-1!==e){const a=`${r}:${e}`;t.inputNames[n]=a}}t.inputs.push(o),o.children.push(t)})}),0===Object.keys(l).length?p.forEach(e=>{const t=s[e];0===t.children.length&&u.push(t)}):Object.keys(l).forEach(e=>{const[t]=A(e),n=s[t];null!=n&&(n.signatureKey=l[e],u.push(n))}),Object.keys(c).length>0?Object.keys(c).forEach(e=>{const[t]=A(e),n=s[t];n&&(n.signatureKey=c[e],i.push(n))}):i=r;let h={};null!=e.library&&null!=e.library.function&&(h=e.library.function.reduce((e,t)=>(e[t.signature.name]=this.mapFunction(t),e),{}));const d={nodes:s,inputs:i,outputs:u,weights:a,placeholders:r,signature:t,functions:h};return o.length>0&&(d.initNodes=o),d}mapSignatureEntries(e){return Object.keys(e||{}).reduce((t,n)=>(t[e[n].name]=n,t),{})}mapNode(e){const t=$(e.op)||this.opMappers[e.op]||{};null==e.attr&&(e.attr={});const n={name:e.name,op:e.op,category:t.category,inputNames:(e.input||[]).map(e=>e.startsWith("^")?e.slice(1):e),inputs:[],children:[],inputParams:{},attrParams:{},rawAttrs:e.attr,outputs:t.outputs};return null!=t.inputs&&(n.inputParams=t.inputs.reduce((e,t)=>(e[t.name]={type:t.type,inputIndexStart:t.start,inputIndexEnd:t.end},e),{})),null!=t.attrs&&(n.attrParams=t.attrs.reduce((t,n)=>{const r=n.type;let a;switch(n.type){case"string":a=ne(e.attr,n.tfName,n.defaultValue),void 0===a&&n.tfDeprecatedName&&(a=ne(e.attr,n.tfDeprecatedName,n.defaultValue));break;case"string[]":a=he(e.attr,n.tfName,n.defaultValue),void 0===a&&n.tfDeprecatedName&&(a=he(e.attr,n.tfDeprecatedName,n.defaultValue));break;case"number":a=ae(e.attr,n.tfName,n.defaultValue||0),void 0===a&&n.tfDeprecatedName&&(a=ae(e.attr,n.tfDeprecatedName,n.defaultValue));break;case"number[]":a=pe(e.attr,n.tfName,n.defaultValue),void 0===a&&n.tfDeprecatedName&&(a=pe(e.attr,n.tfDeprecatedName,n.defaultValue));break;case"bool":a=re(e.attr,n.tfName,n.defaultValue),void 0===a&&n.tfDeprecatedName&&(a=re(e.attr,n.tfDeprecatedName,n.defaultValue));break;case"bool[]":a=fe(e.attr,n.tfName,n.defaultValue),void 0===a&&n.tfDeprecatedName&&(a=fe(e.attr,n.tfDeprecatedName,n.defaultValue));break;case"shape":a=le(e.attr,n.tfName,n.defaultValue),void 0===a&&n.tfDeprecatedName&&(a=le(e.attr,n.tfDeprecatedName,n.defaultValue));break;case"shape[]":a=de(e.attr,n.tfName,n.defaultValue),void 0===a&&n.tfDeprecatedName&&(a=de(e.attr,n.tfDeprecatedName,n.defaultValue));break;case"dtype":a=ie(e.attr,n.tfName,n.defaultValue),void 0===a&&n.tfDeprecatedName&&(a=ie(e.attr,n.tfDeprecatedName,n.defaultValue));break;case"dtype[]":a=ue(e.attr,n.tfName,n.defaultValue),void 0===a&&n.tfDeprecatedName&&(a=ue(e.attr,n.tfDeprecatedName,n.defaultValue));break;case"func":a=se(e.attr,n.tfName,n.defaultValue),void 0===a&&n.tfDeprecatedName&&(a=se(e.attr,n.tfDeprecatedName,n.defaultValue));break;case"tensor":case"tensors":break;default:throw new Error(`Unsupported param type: ${n.type} for op: ${e.op}`)}return t[n.name]={value:a,type:r},t},{})),n}mapFunction(e){const t=e.nodeDef,n=[];let r={};null!=t&&(r=t.reduce((e,t)=>(e[t.name]=this.mapNode(t),"Const"===t.op&&n.push(e[t.name]),e),{}));const a=[],o=[];e.signature.inputArg.forEach(e=>{const[t]=A(e.name),n={name:t,op:"Placeholder",inputs:[],inputNames:[],category:"graph",inputParams:{},attrParams:{dtype:{value:oe(e.type),type:"dtype"}},children:[]};n.signatureKey=e.name,a.push(n),r[t]=n});Object.keys(r).forEach(e=>{const t=r[e];t.inputNames.forEach((e,n)=>{const[a,,o]=A(e),s=r[a];if(null!=s.outputs){const e=s.outputs.indexOf(o);if(-1!==e){const r=`${a}:${e}`;t.inputNames[n]=r}}t.inputs.push(s),s.children.push(t)})});const s=e.ret;
2e.signature.outputArg.forEach(e=>{const[t,n]=A(s[e.name]),a=r[t];null!=a&&(a.defaultOutput=n,o.push(a))});const i=this.mapArgsToSignature(e);return{nodes:r,inputs:a,outputs:o,weights:n,placeholders:[],signature:i}}mapArgsToSignature(e){return{methodName:e.signature.name,inputs:e.signature.inputArg.reduce((e,t)=>(e[t.name]=this.mapArgToTensorInfo(t),e),{}),outputs:e.signature.outputArg.reduce((t,n)=>(t[n.name]=this.mapArgToTensorInfo(n,e.ret),t),{})}}mapArgToTensorInfo(e,t){let n=e.name;return null!=t&&(n=t[n]),{name:n,dtype:e.type}}}function te(e,t){const n=Array.isArray(e)?String.fromCharCode.apply(null,e):function(e){const t=(0,S._K2)().global;if(void 0!==t.atob)return t.atob(e);if("undefined"!=typeof Buffer)return new Buffer(e,"base64").toString();throw new Error("Unable to decode base64 in this environment. Missing built-in atob() or Buffer()")}(e);return t?n:n.toLowerCase()}function ne(e,t,n,r=!1){const a=e[t];return null!=a?te(a.s,r):n}function re(e,t,n){const r=e[t];return r?r.b:n}function ae(e,t,n){const r=e[t]||{},a=null!=r.i?r.i:null!=r.f?r.f:n;return"number"==typeof a?a:parseInt(a,10)}function oe(e){switch("string"==typeof e&&(e=C[e]),e){case C.DT_FLOAT:case C.DT_HALF:return"float32";case C.DT_INT32:case C.DT_INT64:case C.DT_INT8:case C.DT_UINT8:return"int32";case C.DT_BOOL:return"bool";case C.DT_DOUBLE:return"float32";case C.DT_STRING:return"string";default:return null}}function se(e,t,n){const r=e[t];return r&&r.func?r.func.name:n}function ie(e,t,n){const r=e[t];return r&&r.type?oe(r.type):n}function ue(e,t,n){const r=e[t];return r&&r.list&&r.list.type?r.list.type.map(e=>oe(e)):n}function ce(e){if(!e.unknownRank)return null!=e.dim?e.dim.map(e=>"number"==typeof e.size?e.size:parseInt(e.size,10)):[]}function le(e,t,n){const r=e[t];return r&&r.shape?ce(r.shape):n}function pe(e,t,n){const r=e[t];return r?((r.list.f&&r.list.f.length?r.list.f:r.list.i)||[]).map(e=>"number"==typeof e?e:parseInt(e,10)):n}function he(e,t,n,r=!1){const a=e[t];return a&&a.list&&a.list.s?a.list.s.map(e=>te(e,r)):n}function de(e,t,n){const r=e[t];return r&&r.list&&r.list.shape?r.list.shape.map(e=>ce(e)):n}function fe(e,t,n){const r=e[t];return r&&r.list&&r.list.b?r.list.b:n}class me{constructor(e,t,n){this.node=e,this.tensorMap=t,this.context=n,this.inputs=[],this.attrs={},this.inputs=e.inputNames.map(e=>this.getInput(e)),null!=e.rawAttrs&&(this.attrs=Object.keys(e.rawAttrs).reduce((e,t)=>(e[t]=this.getAttr(t),e),{}))}getInput(e){return I(e,this.tensorMap,this.context)}getAttr(e,t){const n=this.node.rawAttrs[e];if(null!=n.tensor)return I(e,this.tensorMap,this.context);if(null!=n.i||null!=n.f)return ae(this.node.rawAttrs,e,t);if(null!=n.s)return ne(this.node.rawAttrs,e,t);if(null!=n.b)return re(this.node.rawAttrs,e,t);if(null!=n.shape)return le(this.node.rawAttrs,e,t);if(null!=n.type)return ie(this.node.rawAttrs,e,t);if(null!=n.list){if(null!=n.list.i||null!=n.list.f)return pe(this.node.rawAttrs,e,t);if(null!=n.list.s)return he(this.node.rawAttrs,e,t);if(null!=n.list.shape)return de(this.node.rawAttrs,e,t);if(null!=n.list.b)return fe(this.node.rawAttrs,e,t);if(null!=n.list.type)return ue(this.node.rawAttrs,e,t)}return t}}var ge=n(97856);function ye(e,t,n=""){if("number"!=typeof e&&"number"!=typeof t){S.ZSL.assert(e.length===t.length,()=>n+` Shapes ${e} and ${t} must match`);for(let r=0;r<e.length;r++){const a=e[r],o=t[r];S.ZSL.assert(a<0||o<0||a===o,()=>n+` Shapes ${e} and ${t} must match`)}}}function xe(e){return"number"!=typeof e&&!e.some(e=>e<0)}function be(e,t,n){let r=ve(e,n);const a=!xe(r);if(a&&0===t.length)throw new Error(`Tried to calculate elements of an empty list with non-fully-defined elementShape: ${r}`);if(a&&t.forEach(e=>{r=ve(e.shape,r)}),!xe(r))throw new Error(`Non-fully-defined elementShape: ${r}`);return r}function ve(e,t){if("number"==typeof e)return t;if("number"==typeof t)return e;if(e.length!==t.length)throw new Error(`Incompatible ranks during merge: ${e} vs. ${t}`);const n=[];for(let r=0;r<e.length;++r){const a=e[r],o=t[r];if(a>=0&&o>=0&&a!==o)throw new Error(`Incompatible shape during merge: ${e} vs. ${t}`);n[r]=a>=0?a:o}return n}class we{constructor(e,t,n,r,a,o,s){this.name=e,this.dtype=t,this.maxSize=n,this.elementShape=r,this.identicalElementShapes=a,this.dynamicSize=o,this.clearAfterRead=s,this.tensors=[],this.closed_
2=!1,this.idTensor=(0,S.d_2)(0),(0,S.aCs)(this.idTensor)}get id(){return this.idTensor.id}get closed(){return this.closed_}clearAndClose(e){this.tensors.forEach(t=>{null!=e&&e.has(t.tensor.id)||t.tensor.dispose()}),this.tensors=[],this.closed_=!0,this.idTensor.dispose()}size(){return this.tensors.length}read(e){if(this.closed_)throw new Error(`TensorArray ${this.name} has already been closed.`);if(e<0||e>=this.size())throw new Error(`Tried to read from index ${e}, but array size is: ${this.size()}`);const t=this.tensors[e];if(t.cleared)throw new Error(`TensorArray ${this.name}: Could not read index ${e} twice because it was cleared after a previous read (perhaps try setting clear_after_read = false?).`);return this.clearAfterRead&&(t.cleared=!0),t.read=!0,t.tensor}readMany(e){return e.map(e=>this.read(e))}write(e,t){if(this.closed_)throw new Error(`TensorArray ${this.name} has already been closed.`);if(e<0||!this.dynamicSize&&e>=this.maxSize)throw new Error(`Tried to write to index ${e}, but array is not resizeable and size is: ${this.maxSize}`);const n=this.tensors[e]||{};if(t.dtype!==this.dtype)throw new Error(`TensorArray ${this.name}: Could not write to TensorArray index ${e},\n because the value dtype is ${t.dtype}, but TensorArray dtype is ${this.dtype}.`);if(0!==this.size()||null!=this.elementShape&&0!==this.elementShape.length||(this.elementShape=t.shape),ye(this.elementShape,t.shape,`TensorArray ${this.name}: Could not write to TensorArray index ${e}.`),n.read)throw new Error(`TensorArray ${this.name}: Could not write to TensorArray index ${e}, because it has already been read.`);if(n.written)throw new Error(`TensorArray ${this.name}: Could not write to TensorArray index ${e}, because it has already been written.`);n.tensor=t,(0,S.aCs)(t),n.written=!0,this.tensors[e]=n}writeMany(e,t){if(e.length!==t.length)throw new Error(`TensorArray ${this.name}: could not write multiple tensors,because the index size: ${e.length} is not the same as tensors size: ${t.length}.`);e.forEach((e,n)=>this.write(e,t[n]))}gather(e,t){if(t&&t!==this.dtype)throw new Error(`TensorArray dtype is ${this.dtype} but gather requested dtype ${t}`);if(e)e=e.slice(0,this.size());else{e=[];for(let t=0;t<this.size();t++)e.push(t)}if(0===e.length)return(0,S.OEK)([],[0].concat(this.elementShape));const n=this.readMany(e);return ye(this.elementShape,n[0].shape,"TensorArray shape mismatch: "),(0,S.t$z)(n,0)}concat(e){if(e&&e!==this.dtype)throw new Error(`TensorArray dtype is ${this.dtype} but concat requested dtype ${e}`);if(0===this.size())return(0,S.OEK)([],[0].concat(this.elementShape));const t=[];for(let e=0;e<this.size();e++)t.push(e);const n=this.readMany(t);return ye(this.elementShape,n[0].shape,`TensorArray shape mismatch: tensor array shape (${this.elementShape}) vs first tensor shape (${n[0].shape})`),(0,S.xWs)(n,0)}scatter(e,t){if(t.dtype!==this.dtype)throw new Error(`TensorArray dtype is ${this.dtype} but tensor has dtype ${t.dtype}`);if(e.length!==t.shape[0])throw new Error(`Expected len(indices) == tensor.shape[0], but saw: ${e.length} vs. ${t.shape[0]}`);const n=Math.max(...e);if(!this.dynamicSize&&n>=this.maxSize)throw new Error(`Max index must be < array size (${n} vs. ${this.maxSize})`);this.writeMany(e,(0,S.K$i)(t,0))}split(e,t){if(t.dtype!==this.dtype)throw new Error(`TensorArray dtype is ${this.dtype} but tensor has dtype ${t.dtype}`);let n=0;const r=e.map(e=>(n+=e,n));if(n!==t.shape[0])throw new Error(`Expected sum of lengths to be equal to\n tensor.shape[0], but sum of lengths is\n ${n}, and tensor's shape is: ${t.shape}`);if(!this.dynamicSize&&e.length!==this.maxSize)throw new Error(`TensorArray's size is not equal to the size of lengths (${this.maxSize} vs. ${e.length}), and the TensorArray is not marked as dynamically resizeable`);const a=0===n?0:t.size/n,o=[];(0,S.DZQ)(()=>{t=(0,S.tQQ)(t,[1,n,a]);for(let n=0;n<e.length;++n){const s=[0,0===n?0:r[n-1],0],i=[1,e[n],a];o[n]=(0,S.tQQ)((0,S.dik)(t,s,i),this.elementShape)}return o});const s=[];for(let t=0;t<e.length;t++)s[t]=t;this.writeMany(s,o)}}class Te{constructor(e,t,n,r=-1){this.tensors=e,this.elementShape=t,this.elementDtype=n,null!=e&&e.forEach(e
2=>{if(n!==e.dtype)throw new Error(`Invalid data types; op elements ${n}, but list elements ${e.dtype}`);ye(t,e.shape,"TensorList shape mismatch: "),(0,S.aCs)(e)}),this.idTensor=(0,S.d_2)(0),this.maxNumElements=r,(0,S.aCs)(this.idTensor)}get id(){return this.idTensor.id}copy(){return new Te([...this.tensors],this.elementShape,this.elementDtype)}clearAndClose(e){this.tensors.forEach(t=>{null!=e&&e.has(t.id)||t.dispose()}),this.tensors.length=0,this.idTensor.dispose()}size(){return this.tensors.length}stack(e,t,n=-1){if(t!==this.elementDtype)throw new Error(`Invalid data types; op elements ${t}, but list elements ${this.elementDtype}`);if(-1!==n&&this.tensors.length!==n)throw new Error(`Operation expected a list with ${n} elements but got a list with ${this.tensors.length} elements.`);ye(e,this.elementShape,"TensorList shape mismatch: ");const r=be(this.elementShape,this.tensors,e);return(0,S.DZQ)(()=>{const e=this.tensors.map(e=>(0,S.tQQ)(e,r));return(0,S.t$z)(e,0)})}popBack(e,t){if(t!==this.elementDtype)throw new Error(`Invalid data types; op elements ${t}, but list elements ${this.elementDtype}`);if(0===this.size())throw new Error("Trying to pop from an empty list.");const n=be(this.elementShape,this.tensors,e),r=this.tensors.pop();return r.kept=!1,ye(r.shape,e,"TensorList shape mismatch: "),(0,S.tQQ)(r,n)}pushBack(e){if(e.dtype!==this.elementDtype)throw new Error(`Invalid data types; op elements ${e.dtype}, but list elements ${this.elementDtype}`);if(ye(e.shape,this.elementShape,"TensorList shape mismatch: "),this.maxNumElements===this.size())throw new Error("Trying to push element into a full list.");(0,S.aCs)(e),this.tensors.push(e)}resize(e){if(e<0)throw new Error(`TensorListResize expects size to be non-negative. Got: ${e}`);if(-1!==this.maxNumElements&&e>this.maxNumElements)throw new Error(`TensorListResize input size ${e} is greater maxNumElement ${this.maxNumElements}.`);const t=new Te([],this.elementShape,this.elementDtype,this.maxNumElements);t.tensors.length=e;for(let n=0;n<Math.min(this.tensors.length,e);++n)t.tensors[n]=this.tensors[n];return t}getItem(e,t,n){if(n!==this.elementDtype)throw new Error(`Invalid data types; op elements ${n}, but list elements ${this.elementDtype}`);if(e<0||e>this.tensors.length)throw new Error(`Trying to access element ${e} in a list with ${this.tensors.length} elements.`);if(null==this.tensors[e])throw new Error(`element at index ${e} is null.`);ye(this.tensors[e].shape,t,"TensorList shape mismatch: ");const r=be(this.elementShape,this.tensors,t);return(0,S.tQQ)(this.tensors[e],r)}setItem(e,t){if(t.dtype!==this.elementDtype)throw new Error(`Invalid data types; op elements ${t.dtype}, but list elements ${this.elementDtype}`);if(e<0||-1!==this.maxNumElements&&e>=this.maxNumElements)throw new Error(`Trying to set element ${e} in a list with max ${this.maxNumElements} elements.`);ye(this.elementShape,t.shape,"TensorList shape mismatch: "),(0,S.aCs)(t),null!=this.tensors[e]&&(this.tensors[e].kept=!1),this.tensors[e]=t}gather(e,t,n){if(t!==this.elementDtype)throw new Error(`Invalid data types; op elements ${t}, but list elements ${this.elementDtype}`);ye(this.elementShape,n,"TensorList shape mismatch: "),e=e.slice(0,this.size());const r=be(this.elementShape,this.tensors,n);return 0===e.length?(0,S.OEK)([],[0].concat(r)):(0,S.DZQ)(()=>{const t=e.map(e=>(0,S.tQQ)(this.tensors[e],r));return(0,S.t$z)(t,0)})}concat(e,t){if(e&&e!==this.elementDtype)throw new Error(`TensorList dtype is ${this.elementDtype} but concat requested dtype ${e}`);ye(this.elementShape,t,"TensorList shape mismatch: ");const n=be(this.elementShape,this.tensors,t);return 0===this.size()?(0,S.OEK)([],[0].concat(n)):(0,S.DZQ)(()=>{const e=this.tensors.map(e=>(0,S.tQQ)(e,n));return(0,S.xWs)(e,0)})}}const Se=async(e,t,n)=>{switch(e.op){case"If":case"StatelessIf":{const r=N("thenBranch",e,t,n),a=N("elseBranch",e,t,n),o=N("cond",e,t,n),s=N("args",e,t,n);return(await o.data())[0]?n.functionMap[r].executeFunctionAsync(s,n.tensorArrayMap,n.tensorListMap):n.functionMap[a].executeFunctionAsync(s,n.tensorArrayMap,n.tensorListMap)}case"While":case"StatelessWhile":{const r=N("body",e,t,n),a=N("cond",e,t,n),o=N("args",e,t,n),s=await n.functionMap[a].executeFunctionAsync(o,n.tensorArrayMap,n.tensorListMap),i=o.map(e=>e.id);let u=await s[0].data();
2s.forEach(e=>{e.kept||-1!==i.indexOf(e.id)||e.dispose()});let c=o;for(;u[0];){const e=c;c=await n.functionMap[r].executeFunctionAsync(c,n.tensorArrayMap,n.tensorListMap);const t=c.map(e=>e.id);e.forEach(e=>{e.kept||-1!==i.indexOf(e.id)||-1!==t.indexOf(e.id)||e.dispose()});const o=await n.functionMap[a].executeFunctionAsync(c,n.tensorArrayMap,n.tensorListMap);u=await o[0].data(),o.forEach(e=>{e.kept||-1!==i.indexOf(e.id)||-1!==t.indexOf(e.id)||e.dispose()})}return c}case"LoopCond":return[F(N("pred",e,t,n))];case"Switch":{const r=N("pred",e,t,n);let a=N("data",e,t,n);return a.kept||(a=F(a)),(await r.data())[0]?[void 0,a]:[a,void 0]}case"Merge":{const r=e.inputNames.find(e=>void 0!==I(e,t,n));if(r){return[F(I(r,t,n))]}return}case"Enter":{const r=N("frameName",e,t,n),a=N("tensor",e,t,n);return n.enterFrame(r),[F(a)]}case"Exit":{const r=N("tensor",e,t,n);return n.exitFrame(),[F(r)]}case"NextIteration":{const r=N("tensor",e,t,n);return n.nextIteration(),[F(r)]}case"TensorArrayV3":{const r=N("size",e,t,n),a=N("dtype",e,t,n),o=N("elementShape",e,t,n),s=N("dynamicSize",e,t,n),i=N("clearAfterRead",e,t,n),u=N("identicalElementShapes",e,t,n),c=N("name",e,t,n),l=new we(c,a,r,o,u,s,i);return n.addTensorArray(l),[l.idTensor,(0,S.d_2)(1)]}case"TensorArrayWriteV3":{const r=N("tensorArrayId",e,t,n),a=N("index",e,t,n),o=N("tensor",e,t,n),s=n.getTensorArray(r.id);return s.write(a,o),[s.idTensor]}case"TensorArrayReadV3":{const r=N("tensorArrayId",e,t,n),a=N("index",e,t,n);return[n.getTensorArray(r.id).read(a)]}case"TensorArrayGatherV3":{const r=N("tensorArrayId",e,t,n),a=N("indices",e,t,n),o=N("dtype",e,t,n);return[n.getTensorArray(r.id).gather(a,o)]}case"TensorArrayScatterV3":{const r=N("tensorArrayId",e,t,n),a=N("indices",e,t,n),o=N("tensor",e,t,n),s=n.getTensorArray(r.id);return s.scatter(a,o),[s.idTensor]}case"TensorArrayConcatV3":{const r=N("tensorArrayId",e,t,n),a=n.getTensorArray(r.id),o=N("dtype",e,t,n);return[a.concat(o)]}case"TensorArraySplitV3":{const r=N("tensorArrayId",e,t,n),a=N("tensor",e,t,n),o=N("lengths",e,t,n),s=n.getTensorArray(r.id);return s.split(o,a),[s.idTensor]}case"TensorArraySizeV3":{const r=N("tensorArrayId",e,t,n),a=n.getTensorArray(r.id);return[(0,S.d_2)(a.size(),"int32")]}case"TensorArrayCloseV3":{const r=N("tensorArrayId",e,t,n),a=n.getTensorArray(r.id);return a.clearAndClose(),[a.idTensor]}case"TensorListSetItem":{const r=N("tensorListId",e,t,n),a=N("index",e,t,n),o=N("tensor",e,t,n),s=n.getTensorList(r.id);return s.setItem(a,o),[s.idTensor]}case"TensorListGetItem":{const r=N("tensorListId",e,t,n),a=N("index",e,t,n),o=N("elementShape",e,t,n),s=N("elementDType",e,t,n);return[n.getTensorList(r.id).getItem(a,o,s)]}case"TensorListScatterV2":case"TensorListScatter":{const r=N("indices",e,t,n),a=function(e,t,n,r){if(t.length!==e.shape[0])throw new Error(`Expected len(indices) == tensor.shape[0], but saw: ${t.length} vs. ${e.shape[0]}`);const a=Math.max(...t);if(null!=r&&-1!==r&&a>=r)throw new Error(`Max index must be < array size (${a} vs. ${r})`);const o=new Te([],n,e.dtype,r),s=(0,S.K$i)(e,0);return t.forEach((e,t)=>{o.setItem(e,s[t])}),o}(N("tensor",e,t,n),r,N("elementShape",e,t,n),N("numElements",e,t,n));return n.addTensorList(a),[a.idTensor]}case"TensorListReserve":case"EmptyTensorList":{const r=N("elementShape",e,t,n),a=N("elementDType",e,t,n);let o;o="TensorListReserve"===e.op?"numElements":"maxNumElements";const s=N(o,e,t,n),i=function(e,t,n,r){return new Te([],e,t,r)}(r,a,0,"TensorListReserve"===e.op?-1:s);return n.addTensorList(i),[i.idTensor]}case"TensorListGather":{const r=N("tensorListId",e,t,n),a=N("indices",e,t,n),o=N("elementShape",e,t,n),s=N("elementDType",e,t,n);return[n.getTensorList(r.id).gather(a,s,o)]}case"TensorListStack":{const r=N("tensorListId",e,t,n),a=N("elementShape",e,t,n),o=N("elementDType",e,t,n),s=N("numElements",e,t,n);return[n.getTensorList(r.id).stack(a,o,s)]}case"TensorListFromTensor":{const r=function(e,t,n){const r=e.dtype;if(e.shape.length<1)throw new Error(`Tensor must be at least a vector, but saw shape: ${e.shape}`);if(e.dtype!==n)throw new Error(`Invalid data types; op elements ${e.dtype}, but list elements ${n}`);ye(e.shape.slice(1),t,"TensorList shape mismatch: ");const a=(0,S.K$i)(e);return new Te(a,t,r)}(N("tensor",e,t,n),N("elementShape",e,t,n),N("elementDType",e,t,n));return n.addTensorList(r),[r.idTensor]}case"TensorListConcat":case"TensorListConcatV2":{const r=N("tensorListId",e,t,n),a=n.getTensorList(r.id),o=N("dtype",e,t,n),s=N("elementShape",e,t,n);return[a.concat(o,s)]}case"TensorListPushBack":{const r=N("tensorListId",e,t,n),a=N("tensor",e,t,n),o=n.getTensorList(r.id);return o.pushBack(a),[o.idTensor]}case"TensorListPopBack":{const r=N("tensorListId",e,t,n),a=N("elementShape",e,t,n),o=N("elementDType",e,t,n);return[n.getTensorList(r.id).popBack(a,o)]}case"TensorListSplit":{const r=N("tensor",e,t,n),a=N("elementShape",e,t,n),o=function(e,t,n){let r=0;const a=t.map(e=>(r+=e,r));if(r!==e.shape[0])throw new Error(`Expected sum of lengths to be equal to\n tensor.shape[0], but sum of lengths is\n ${r}, and tensor's shape is: ${e.shape}`);const o=ve(e.shape.slice(1),n),s=0===r?0:e.size/r,i=(0,S.DZQ)(()=>{const n=[];e=(0,S.tQQ)(e,[1,r,s]);for(let r=0;r<t.length;++r){const i=[0,0===r?0:a[r-1],0],u=[1,t[r],s];n[r]=(0,S.tQQ)((0,S.dik)(e,i,u),o)}return e.dispose(),n}),u=new Te([],n,e.dtype,t.length);for(let e=0;e<i.length;e++)u.setItem(e,i[e]);return u}(r,N("lengths",e,t,n),a);return n.addTensorList(o),[o.idTensor]}case"TensorListLength":{const r=N("tensorListId",e,t,n),a=n.getTensorList(r.id);return[(0,S.d_2)(a.size(),"int32")]}case"TensorListResize":{const r=N("tensorListId",e,t,n),a=N("size",e,t,n),o=n.getTensorList(r.id).resize(a);return n.addTensorList(o),[o.idTensor]}default:throw TypeError(`Node type ${e.op} is not implemented`)}};function Ce(e,t,n){const[r,a]=N("fusedOps",e,t,n),o="biasadd"===r,s=!o,i="prelu"===a,u="fusedbatchnorm"===r,c=N("numArgs",e,t,n);if(o){if(i&&2!==c)throw new Error("FusedConv2d and DepthwiseConv2d with BiasAdd and Prelu must have two extra arguments: bias and alpha.");if(!i&&o&&1!==c)throw new Error("FusedConv2d and DepthwiseConv2d with BiasAdd must have one extra argument: bias.")}if(u)throw new Error("FusedConv2d and DepthwiseConv2d with FusedBatchNorm is not supported");const l=N("strides",e,t,n),p=O(e,t,n),h=N("dataFormat",e,t,n).toUpperCase(),d=N("dilations",e,t,n);let[f,m]=N("args",e,t,n);s&&(m=f,f=void 0);return{stride:l,pad:p,dataFormat:h,dilations:d,biasArg:f,preluArg:m,activationFunc:a,leakyreluAlpha:N("leakyreluAlpha",e,t,n)}}function ke(e,t,n){return{boxes:N("boxes",e,t,n),scores:N("scores",e,t,n),maxOutputSize:N("maxOutputSize",e,t,n),iouThreshold:N("iouThreshold",e,t,n),scoreThreshold:N("scoreThreshold",e,t,n),softNmsSigma:N("softNmsSigma",e,t,n)}}var Ee=n(45702);class $e{constructor(e,t){this.keyDType=e,this.valueDType=t,this.handle=(0,S.d_2)(0),this.tensorMap=new Map,(0,S.aCs)(this.handle)}get id(){return this.handle.id}
vendor: 13,718 bytes, line 2
2clearAndClose(){this.tensorMap.forEach(e=>e.dispose()),this.tensorMap.clear(),this.handle.dispose()}size(){return this.tensorMap.size}tensorSize(){return Ee.d(this.size(),"int32")}async import(e,t){this.checkKeyAndValueTensor(e,t);const n=await e.data();return this.tensorMap.forEach(e=>e.dispose()),this.tensorMap.clear(),(0,S.DZQ)(()=>{const e=(0,S.K$i)(t),r=n.length,a=e.length;S.ZSL.assert(r===a,()=>`The number of elements doesn't match, keys has ${r} elements, the values has ${a} elements.`);for(let t=0;t<r;t++){const r=n[t],a=e[t];(0,S.aCs)(a),this.tensorMap.set(r,a)}return this.handle})}async find(e,t){this.checkKeyAndValueTensor(e,t);const n=await e.data();return(0,S.DZQ)(()=>{const e=[];for(let r=0;r<n.length;r++){const a=n[r],o=this.findWithDefault(a,t);e.push(o)}return(0,S.t$z)(e)})}findWithDefault(e,t){const n=this.tensorMap.get(e);return null!=n?n:t}checkKeyAndValueTensor(e,t){if(e.dtype!==this.keyDType)throw new Error(`Expect key dtype ${this.keyDType}, but got ${e.dtype}`);if(t.dtype!==this.valueDType)throw new Error(`Expect value dtype ${this.valueDType}, but got ${t.dtype}`)}}function Ne(e,t,n,r,a=S.DZQ){const o=((e,t,n)=>{switch(e.category){case"arithmetic":return a(()=>((e,t,n,r=T)=>{switch(e.op){case"BiasAdd":case"AddV2":case"Add":return[r.add(N("a",e,t,n),N("b",e,t,n))];case"AddN":return[r.addN(N("tensors",e,t,n))];case"FloorMod":case"Mod":return[r.mod(N("a",e,t,n),N("b",e,t,n))];case"Mul":return[r.mul(N("a",e,t,n),N("b",e,t,n))];case"RealDiv":case"Div":return[r.div(N("a",e,t,n),N("b",e,t,n))];case"DivNoNan":return[r.divNoNan(N("a",e,t,n),N("b",e,t,n))];case"FloorDiv":return[r.floorDiv(N("a",e,t,n),N("b",e,t,n))];case"Sub":return[r.sub(N("a",e,t,n),N("b",e,t,n))];case"Minimum":return[r.minimum(N("a",e,t,n),N("b",e,t,n))];case"Maximum":return[r.maximum(N("a",e,t,n),N("b",e,t,n))];case"Pow":return[r.pow(N("a",e,t,n),N("b",e,t,n))];case"SquaredDifference":return[r.squaredDifference(N("a",e,t,n),N("b",e,t,n))];default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,n));case"basic_math":return a(()=>((e,t,n,r=T)=>{switch(e.op){case"Abs":case"ComplexAbs":return[r.abs(N("x",e,t,n))];case"Acos":return[r.acos(N("x",e,t,n))];case"Acosh":return[r.acosh(N("x",e,t,n))];case"Asin":return[r.asin(N("x",e,t,n))];case"Asinh":return[r.asinh(N("x",e,t,n))];case"Atan":return[r.atan(N("x",e,t,n))];case"Atan2":return[r.atan2(N("x",e,t,n),N("y",e,t,n))];case"Atanh":return[r.atanh(N("x",e,t,n))];case"Ceil":return[r.ceil(N("x",e,t,n))];case"Complex":return[r.complex(N("real",e,t,n),N("imag",e,t,n))];case"Cos":return[r.cos(N("x",e,t,n))];case"Cosh":return[r.cosh(N("x",e,t,n))];case"Elu":return[r.elu(N("x",e,t,n))];case"Erf":return[r.erf(N("x",e,t,n))];case"Exp":return[r.exp(N("x",e,t,n))];case"Expm1":return[r.expm1(N("x",e,t,n))];case"Floor":return[r.floor(N("x",e,t,n))];case"Log":return[r.log(N("x",e,t,n))];case"Log1p":return[r.log1p(N("x",e,t,n))];case"Imag":return[r.imag(N("x",e,t,n))];case"Neg":return[r.neg(N("x",e,t,n))];case"Reciprocal":return[r.reciprocal(N("x",e,t,n))];case"Real":return[r.real(N("x",e,t,n))];case"Relu":return[r.relu(N("x",e,t,n))];case"Round":return[r.round(N("x",e,t,n))];case"Selu":return[r.selu(N("x",e,t,n))];case"Sigmoid":return[r.sigmoid(N("x",e,t,n))];case"Sin":return[r.sin(N("x",e,t,n))];case"Sign":return[r.sign(N("x",e,t,n))];case"Sinh":return[r.sinh(N("x",e,t,n))];case"Softplus":return[r.softplus(N("x",e,t,n))];case"Sqrt":return[r.sqrt(N("x",e,t,n))];case"Square":return[r.square(N("x",e,t,n))];case"Tanh":return[r.tanh(N("x",e,t,n))];case"Tan":return[r.tan(N("x",e,t,n))];case"ClipByValue":return[r.clipByValue(N("x",e,t,n),N("clipValueMin",e,t,n),N("clipValueMax",e,t,n))];case"Relu6":return[r.relu6(N("x",e,t,n))];case"Rsqrt":return[r.rsqrt(I(e.inputNames[0],t,n))];case"Prod":return[r.prod(N("x",e,t,n),N("axes",e,t,n))];case"LeakyRelu":return[r.leakyRelu(N("x",e,t,n),N("alpha",e,t,n))];case"Prelu":return[r.prelu(N("x",e,t,n),N("alpha",e,t,n))];case"IsNan":return[r.isNaN(I(e.inputNames[0],t,n))];default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,n));case"control":return Se(e,t,n);case"convolution":return a(()=>((e,t,n,r=T)=>{switch(e.op){case"Conv1D":{const a=N("stride",e,t,n),o=N("pad",e,t,n),s=N("dataFormat",e,t,n).toUpperCase(),i=N("dilation",e,t,n);return[r.conv1d(N("x",e,t,n),N("filter",e,t,n),a,o,s,i)]}case"Conv2D":{const a=N("strides",e,t,n),o=O(e,t,n),s=N("dataFormat",e,t,n).toUpperCase(),i=N("dilations",e,t,n);return[r.conv2d(N("x",e,t,n),N("filter",e,t,n),[a[1],a[2]],o,s,[i[1],i[2]])]}case"_FusedConv2D":{const{stride:a,pad:o,dataFormat:s,dilations:i,biasArg:u,preluArg:c,activationFunc:l,leakyreluAlpha:p}=Ce(e,t,n);return[r.fused.conv2d({x:N("x",e,t,n),filter:N("filter",e,t,n),strides:[a[1],a[2]],pad:o,dataFormat:s,dilations:[i[1],i[2]],bias:u,activation:l,preluActivationWeights:c,leakyreluAlpha:p})]}case"FusedDepthwiseConv2dNative":{const{stride:a,pad:o,dataFormat:s,dilations:i,biasArg:u,preluArg:c,activationFunc:l,leakyreluAlpha:p}=Ce(e,t,n);return[r.fused.depthwiseConv2d({x:N("x",e,t,n),filter:N("filter",e,t,n),strides:[a[1],a[2]],pad:o,dataFormat:s,dilations:[i[1],i[2]],bias:u,activation:l,preluActivationWeights:c,leakyreluAlpha:p})]}case"Conv2DBackpropInput":case"Conv2dTranspose":{const a=N("outputShape",e,t,n),o=N("strides",e,t,n),s=O(e,t,n);return[r.conv2dTranspose(N("x",e,t,n),N("filter",e,t,n),a,[o[1],o[2]],s)]}case"DepthwiseConv2dNative":case"DepthwiseConv2d":{const a=N("strides",e,t,n),o=O(e,t,n),s=N("dilations",e,t,n),i=N("dataFormat",e,t,n).toUpperCase();return[r.depthwiseConv2d(N("input",e,t,n),N("filter",e,t,n),[a[1],a[2]],o,i,[s[1],s[2]])]}case"Conv3D":{const a=N("strides",e,t,n),o=N("pad",e,t,n),s=N("dataFormat",e,t,n).toUpperCase(),i=N("dilations",e,t,n);return[r.conv3d(N("x",e,t,n),N("filter",e,t,n),[a[1],a[2],a[3]],o,s,[i[1],i[2],i[3]])]}case"AvgPool":{const a=N("strides",e,t,n),o=N("pad",e,t,n),s=N("kernelSize",e,t,n);return[r.avgPool(N("x",e,t,n),[s[1],s[2]],[a[1],a[2]],o)]}case"MaxPool":{const a=N("strides",e,t,n),o=N("pad",e,t,n),s=N("kernelSize",e,t,n);return[r.maxPool(N("x",e,t,n),[s[1],s[2]],[a[1],a[2]],o)]}case"MaxPoolWithArgmax":{const a=N("strides",e,t,n),o=N("pad",e,t,n),s=N("kernelSize",e,t,n),i=N("includeBatchInIndex",e,t,n),{result:u,indexes:c}=r.maxPoolWithArgmax(N("x",e,t,n),[s[1],s[2]],[a[1],a[2]],o,i);return[u,c]}case"AvgPool3D":{const a=N("strides",e,t,n),o=N("pad",e,t,n),s=N("kernelSize",e,t,n);return[r.avgPool3d(N("x",e,t,n),[s[1],s[2],s[3]],[a[1],a[2],a[3]],o)]}case"MaxPool3D":{const a=N("strides",e,t,n),o=N("pad",e,t,n),s=N("kernelSize",e,t,n);return[r.maxPool3d(N("x",e,t,n),[s[1],s[2],s[3]],[a[1],a[2],a[3]],o)]}case"Dilation2D":{const a=N("strides",e,t,n),o=N("pad",e,t,n),s=N("dilations",e,t,n),i=a[1],u=a[2],c=s[1],l=s[2];return[r.dilation2d(N("x",e,t,n),N("filter",e,t,n),[i,u],o,[c,l],"NHWC")]}default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,n));case"creation":return a(()=>((e,t,n,r=T)=>{switch(e.op){case"Fill":{const a=N("shape",e,t,n),o=N("dtype",e,t,n),s=N("value",e,t,n);return[r.fill(a,s,o)]}case"LinSpace":{const a=N("start",e,t,n),o=N("stop",e,t,n),s=N("num",e,t,n);return[r.linspace(a,o,s)]}case"Multinomial":{const a=N("logits",e,t,n),o=N("numSamples",e,t,n),s=N("seed",e,t,n);return[r.multinomial(a,o,s)]}case"OneHot":{const a=N("indices",e,t,n),o=N("depth",e,t,n),s=N("onValue",e,t,n),i=N("offValue",e,t,n),u=N("dtype",e,t,n);return[r.oneHot(a,o,s,i,u)]}case"Ones":return[r.ones(N("shape",e,t,n),N("dtype",e,t,n))];case"OnesLike":return[r.onesLike(N("x",e,t,n))];case"RandomStandardNormal":return[r.randomStandardNormal(N("shape",e,t,n),N("dtype",e,t,n),N("seed",e,t,n))];case"RandomUniform":return[r.randomUniform(N("shape",e,t,n),N("minval",e,t,n),N("maxval",e,t,n),N("dtype",e,t,n))];case"Range":{const a=N("start",e,t,n),o=N("stop",e,t,n),s=N("step",e,t,n);return[r.range(a,o,s,N("dtype",e,t,n))]}case"TruncatedNormal":{const a=N("shape",e,t,n),o=N("mean",e,t,n),s=N("stdDev",e,t,n),i=N("seed",e,t,n);return[r.truncatedNormal(a,o,s,N("dtype",e,t,n),i)]}case"Zeros":return[r.zeros(N("shape",e,t,n),N("dtype",e,t,n))];case"ZerosLike":return[r.zerosLike(N("x",e,t,n))];default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,n));case"dynamic":return(async(e,t,n,r,a=T)=>{switch(e.op){case"NonMaxSuppressionV5":{const{boxes:r,scores:o,maxOutputSize:s,iouThreshold:i,scoreThreshold:u,softNmsSigma:c}=ke(e,t,n),l=await a.image.nonMaxSuppressionWithScoreAsync(r,o,s,i,u,c);return[l.selectedIndices,l.selectedScores]}case"NonMaxSuppressionV4":{const{boxes:r,scores:o,maxOutputSize:s,iouThreshold:i,scoreThreshold:u}=ke(e,t,n),c=N("padToMaxOutputSize",e,t,n),l=await a.image.nonMaxSuppressionPaddedAsync(r,o,s,i,u,c);return[l.selectedIndices,l.validOutputs]}case"NonMaxSuppressionV3":case"NonMaxSuppressionV2":{const{boxes:r,scores:o,maxOutputSize:s,iouThreshold:i,scoreThreshold:u}=ke(e,t,n);return[await a.image.nonMaxSuppressionAsync(r,o,s,i,u)]}case"Where":{const r=a.cast(N("condition",e,t,n),"bool"),o=[await a.whereAsync(r)];return r.dispose(),o}case"ListDiff":return a.setdiff1dAsync(N("x",e,t,n),N("y",e,t,n));default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,n);case"evaluation":return a(()=>((e,t,n,r=T)=>{switch(e.op){case"LowerBound":{const a=N("sortedSequence",e,t,n),o=N("values",e,t,n);return[r.lowerBound(a,o)]}case"TopKV2":{const a=N("x",e,t,n),o=N("k",e,t,n),s=N("sorted",e,t,n),i=r.topk(a,o,s);return[i.values,i.indices]}case"UpperBound":{const a=N("sortedSequence",e,t,n),o=N("values",e,t,n);return[r.upperBound(a,o)]}case"Unique":{const a=N("x",e,t,n),o=r.unique(a);return[o.values,o.indices]}case"UniqueV2":{const a=N("x",e,t,n),o=N("axis",e,t,n),s=r.unique(a,o);return[s.values,s.indices]}default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,n));case"image":return a(()=>((e,t,n,r=T)=>{switch(e.op){case"ResizeBilinear":{const a=N("images",e,t,n),o=N("size",e,t,n),s=N("alignCorners",e,t,n),i=N("halfPixelCenters",e,t,n);return[r.image.resizeBilinear(a,[o[0],o[1]],s,i)]}case"ResizeNearestNeighbor":{const a=N("images",e,t,n),o=N("size",e,t,n),s=N("alignCorners",e,t,n),i=N("halfPixelCenters",e,t,n);return[r.image.resizeNearestNeighbor(a,[o[0],o[1]],s,i)]}case"CropAndResize":{const a=N("image",e,t,n),o=N("boxes",e,t,n),s=N("boxInd",e,t,n),i=N("cropSize",e,t,n),u=N("method",e,t,n),c=N("extrapolationValue",e,t,n);return[r.image.cropAndResize(a,o,s,i,u,c)]}case"ImageProjectiveTransformV3":{const a=N("images",e,t,n),o=N("transforms",e,t,n),s=N("outputShape",e,t,n),i=N("fillValue",e,t,n),u=N("interpolation",e,t,n),c=N("fillMode",e,t,n);return[r.image.transform(a,o,u.toLowerCase(),c.toLowerCase(),i,s)]}default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,n));case"graph":return a(()=>((e,t,n,r=T)=>{switch(e.op){case"Const":return t[e.name];case"PlaceholderWithDefault":const a=N("default",e,t,n);return[I(e.name,t,n)||a];case"Placeholder":return[I(e.name,t,n)];case"Identity":case"StopGradient":case"FakeQuantWithMinMaxVars":case"Snapshot":return[F(N("x",e,t,n))];case"IdentityN":return N("x",e,t,n).map(e=>F(e));case"Shape":return[r.tensor1d(N("x",e,t,n).shape,"int32")];case"ShapeN":return N("x",e,t,n).map(e=>r.tensor1d(e.shape));case"Size":return[r.scalar(N("x",e,t,n).size,"int32")];case"Rank":return[r.scalar(N("x",e,t,n).rank,"int32")];case"NoOp":return[r.scalar(1)];case"Print":const o=N("x",e,t,n),s=N("data",e,t,n);N("message",e,t,n),N("summarize",e,t,n);for(let e=0;e<s.length;e++);return[o];default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,n));case"logical":return a(()=>((e,t,n,r=T)=>{switch(e.op){case"Equal":return[r.equal(N("a",e,t,n),N("b",e,t,n))];case"NotEqual":return[r.notEqual(N("a",e,t,n),N("b",e,t,n))];case"Greater":return[r.greater(N("a",e,t,n),N("b",e,t,n))];case"GreaterEqual":return[r.greaterEqual(N("a",e,t,n),N("b",e,t,n))];case"Less":return[r.less(N("a",e,t,n),N("b",e,t,n))];case"LessEqual":return[r.lessEqual(N("a",e,t,n),N("b",e,t,n))];case"LogicalAnd":return[r.logicalAnd(N("a",e,t,n),N("b",e,t,n))];case"LogicalNot":return[r.logicalNot(N("a",e,t,n))];case"LogicalOr":return[r.logicalOr(N("a",e,t,n),N("b",e,t,n))];case"Select":case"SelectV2":return[r.where(N("condition",e,t,n),N("a",e,t,n),N("b",e,t,n))];default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,n));case"matrices":return a(()=>((e,t,n,r=T)=>{switch(e.op){case"BatchMatMul":case"BatchMatMulV2":case"MatMul":return[r.matMul(N("a",e,t,n),N("b",e,t,n),N("transposeA",e,t,n),N("transposeB",e,t,n))];case"Einsum":return[r.einsum(N("equation",e,t,n),...N("tensors",e,t,n))];case"Transpose":return[r.transpose(N("x",e,t,n),N("perm",e,t,n))];case"_FusedMatMul":const[a,o]=N("fusedOps",e,t,n),s="biasadd"===a,i="prelu"===o,u=N("numArgs",e,t,n),c=N("leakyreluAlpha",e,t,n);if(s){if(i&&2!==u)throw new Error("Fused MatMul with BiasAdd and Prelu must have two extra arguments: bias and alpha.");if(!i&&1!==u)throw new Error("Fused MatMul with BiasAdd must have one extra argument: bias.")}const[l,p]=N("args",e,t,n);return[r.fused.matMul({a:N("a",e,t,n),b:N("b",e,t,n),transposeA:N("transposeA",e,t,n),transposeB:N("transposeB",e,t,n),bias:l,activation:o,preluActivationWeights:p,leakyreluAlpha:c})];default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,n));case"normalization":return a(()=>((e,t,n,r=T)=>{switch(e.op){case"EuclideanNorm":return[r.euclideanNorm(N("x",e,t,n),N("axis",e,t,n),N("keepDims",e,t,n))];case"FusedBatchNorm":case"FusedBatchNormV2":case"FusedBatchNormV3":return[r.batchNorm(N("x",e,t,n),N("mean",e,t,n),N("variance",e,t,n),N("offset",e,t,n),N("scale",e,t,n),N("epsilon",e,t,n))];case"LRN":return[r.localResponseNormalization(N("x",e,t,n),N("radius",e,t,n),N("bias",e,t,n),N("alph
2a",e,t,n),N("beta",e,t,n))];case"Softmax":return[r.softmax(N("x",e,t,n))];case"LogSoftmax":return[r.logSoftmax(N("x",e,t,n))];case"SparseToDense":return[r.sparseToDense(N("sparseIndices",e,t,n),N("outputShape",e,t,n),N("sparseValues",e,t,n),N("defaultValue",e,t,n))];default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,n));case"reduction":return a(()=>((e,t,n,r=T)=>{switch(e.op){case"Max":{const a=N("axis",e,t,n),o=N("keepDims",e,t,n);return[r.max(N("x",e,t,n),a,o)]}case"Mean":{const a=N("axis",e,t,n),o=N("keepDims",e,t,n);return[r.mean(N("x",e,t,n),a,o)]}case"Min":{const a=N("axis",e,t,n),o=N("keepDims",e,t,n);return[r.min(N("x",e,t,n),a,o)]}case"Sum":{const a=N("axis",e,t,n),o=N("keepDims",e,t,n);return[r.sum(N("x",e,t,n),a,o)]}case"All":{const a=N("axis",e,t,n),o=N("keepDims",e,t,n);return[r.all(N("x",e,t,n),a,o)]}case"Any":{const a=N("axis",e,t,n),o=N("keepDims",e,t,n);return[r.any(N("x",e,t,n),a,o)]}case"ArgMax":{const a=N("axis",e,t,n);return[r.argMax(N("x",e,t,n),a)]}case"ArgMin":{const a=N("axis",e,t,n);return[r.argMin(N("x",e,t,n),a)]}case"Prod":{const a=N("axis",e,t,n),o=N("keepDims",e,t,n);return[r.prod(N("x",e,t,n),a,o)]}case"Cumprod":{const a=N("axis",e,t,n),o=N("exclusive",e,t,n),s=N("reverse",e,t,n);return[r.cumprod(N("x",e,t,n),a,o,s)]}case"Cumsum":{const a=N("axis",e,t,n),o=N("exclusive",e,t,n),s=N("reverse",e,t,n);return[r.cumsum(N("x",e,t,n),a,o,s)]}case"Bincount":const a=N("x",e,t,n),o=N("weights",e,t,n),s=N("size",e,t,n);return[r.bincount(a,o,s)];case"DenseBincount":{const a=N("x",e,t,n),o=N("weights",e,t,n),s=N("size",e,t,n),i=N("binaryOutput",e,t,n);return[r.denseBincount(a,o,s,i)]}default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,n));case"slice_join":return a(()=>((e,t,n,r=T)=>{switch(e.op){case"ConcatV2":case"Concat":{const a=N("n",e,t,n),o=N("axis",e,t,n);let s=N("tensors",e,t,n);return s=s.slice(0,a),[r.concat(s,o)]}case"Gather":{const a=N("x",e,t,n),o=N("indices",e,t,n);return[r.gather(a,r.cast(o,"int32"),0)]}case"GatherV2":{const a=N("axis",e,t,n),o=N("batchDims",e,t,n),s=N("x",e,t,n),i=N("indices",e,t,n);return[r.gather(s,r.cast(i,"int32"),a,o)]}case"Reverse":{const a=N("dims",e,t,n),o=[];for(let e=0;e<a.length;e++)a[e]&&o.push(e);const s=N("x",e,t,n);return[r.reverse(s,o)]}case"ReverseV2":{const a=N("axis",e,t,n),o=N("x",e,t,n);return[r.reverse(o,a)]}case"Slice":{const a=N("begin",e,t,n),o=N("size",e,t,n);return[r.slice(N("x",e,t,n),a,o)]}case"StridedSlice":{const a=N("begin",e,t,n),o=N("end",e,t,n),s=N("strides",e,t,n),i=N("beginMask",e,t,n),u=N("endMask",e,t,n),c=N("ellipsisMask",e,t,n),l=N("newAxisMask",e,t,n),p=N("shrinkAxisMask",e,t,n),h=N("x",e,t,n);return[r.stridedSlice(h,a,o,s,i,u,c,l,p)]}case"Pack":return(0,S.DZQ)(()=>{const a=N("axis",e,t,n),o=N("tensors",e,t,n),s=o[0].shape,i=r.squeeze(o[0]).shape,u=o.map(e=>{const t=S.ZSL.arraysEqual(e.shape,s);if(!t&&!S.ZSL.arraysEqual(r.squeeze(e).shape,i))throw new Error("the input tensors shape does not match");return t?e:r.reshape(e,s)});return[r.stack(u,a)]});case"Unpack":{const a=N("axis",e,t,n),o=N("tensor",e,t,n);return r.unstack(o,a)}case"Tile":{const a=N("reps",e,t,n);return[r.tile(N("x",e,t,n),a)]}case"Split":case"SplitV":{const a=N("axis",e,t,n),o=N("numOrSizeSplits",e,t,n),s=N("x",e,t,n);return r.split(s,o,a)}case"ScatterNd":{const a=N("indices",e,t,n),o=N("values",e,t,n),s=N("shape",e,t,n);return[r.scatterND(a,o,s)]}case"GatherNd":{const a=N("x",e,t,n),o=N("indices",e,t,n);return[r.gatherND(a,o)]}case"SparseToDense":{const a=N("sparseIndices",e,t,n),o=N("outputShape",e,t,n),s=N("sparseValues",e,t,n),i=N("defaultValue",e,t,n);return[r.sparseToDense(a,s,o,s.dtype===i.dtype?i:r.cast(i,s.dtype))]}default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,n));case"sparse":return a(()=>((e,t,n,r=T)=>{switch(e.op){case"SparseFillEmptyRows":{const{outputIndices:a,outputValues:o,emptyRowIndicator:s,reverseIndexMap:i}=r.sparse.sparseFillEmptyRows(N("indices",e,t,n),N("values",e,t,n),N("denseShape",e,t,n),N("defaultValue",e,t,n));return[a,o,s,i]}case"SparseReshape":{const{outputIndices:a,outputShape:o}=r.sparse.sparseReshape(N("inputIndices",e,t,n),N("inputShape",e,t,n),N("newShape",e,t,n));return[a,o]}case"SparseSegmentMean":return[r.sparse.sparseSegmentMean(N("data",e,t,n),N("indices",e,t,n),N("segmentIds",e,t,n))];case"SparseSegmentSum":return[r.sparse.sparseSegmentSum(N("data",e,t,n),N("indices",e,t,n),N("segmentIds",e,t,n))];default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,n));case"spectral":return a(()=>((e,t,n,r=T)=>{switch(e.op){case"FFT":return[r.fft(N("x",e,t,n))];case"IFFT":return[r.ifft(N("x",e,t,n))];case"RFFT":return[r.rfft(N("x",e,t,n))];case"IRFFT":return[r.irfft(N("x",e,t,n))];default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,n));case"string":return a(()=>((e,t,n,r=T)=>{switch(e.op){case"StringNGrams":{const{nGrams:a,nGramsSplits:o}=r.string.stringNGrams(N("data",e,t,n),N("dataSplits",e,t,n),N("separator",e,t,n),N("nGramWidths",e,t,n),N("leftPad",e,t,n),N("rightPad",e,t,n),N("padWidth",e,t,n),N("preserveShortSequences",e,t,n));return[a,o]}case"StringSplit":{const{indices:a,values:o,shape:s}=r.string.stringSplit(N("input",e,t,n),N("delimiter",e,t,n),N("skipEmpty",e,t,n));return[a,o,s]}case"StringToHashBucketFast":return[r.string.stringToHashBucketFast(N("input",e,t,n),N("numBuckets",e,t,n))];default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,n));case"transformation":return a(()=>((e,t,n,r=T)=>{switch(e.op){case"Cast":return[r.cast(N("x",e,t,n),N("dtype",e,t,n))];case"ExpandDims":{const a=N("axis",e,t,n);return[r.expandDims(N("x",e,t,n),a)]}case"Squeeze":{const a=N("axis",e,t,n);return[r.squeeze(N("x",e,t,n),a)]}case"Reshape":return[r.reshape(N("x",e,t,n),N("shape",e,t,n))];case"MirrorPad":return[r.mirrorPad(N("x",e,t,n),N("padding",e,t,n),N("mode",e,t,n))];case"PadV2":case"Pad":return[r.pad(N("x",e,t,n),N("padding",e,t,n),N("constantValue",e,t,n))];
2case"SpaceToBatchND":{const a=N("blockShape",e,t,n),o=N("paddings",e,t,n);return[r.spaceToBatchND(N("x",e,t,n),a,o)]}case"BatchToSpaceND":{const a=N("blockShape",e,t,n),o=N("crops",e,t,n);return[r.batchToSpaceND(N("x",e,t,n),a,o)]}case"DepthToSpace":{const a=N("blockSize",e,t,n),o=N("dataFormat",e,t,n).toUpperCase();return[r.depthToSpace(N("x",e,t,n),a,o)]}case"BroadcastTo":return[r.broadcastTo(N("x",e,t,n),N("shape",e,t,n))];case"BroadcastArgs":return[r.broadcastArgs(N("s0",e,t,n),N("s1",e,t,n))];default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,n));case"hash_table":return(async(e,t,n,r)=>{switch(e.op){case"HashTable":case"HashTableV2":{const a=N("keyDType",e,t,n),o=N("valueDType",e,t,n),s=new $e(a,o);return r.addHashTable(e.name,s),[s.handle]}case"LookupTableImport":case"LookupTableImportV2":{const a=N("tableHandle",e,t,n,r),o=N("keys",e,t,n),s=N("values",e,t,n),i=r.getHashTableById(a.id);return[await i.import(o,s)]}case"LookupTableFind":case"LookupTableFindV2":{const a=N("tableHandle",e,t,n,r),o=N("keys",e,t,n),s=N("defaultValue",e,t,n),i=r.getHashTableById(a.id);return[await i.find(o,s)]}case"LookupTableSize":case"LookupTableSizeV2":{const a=N("tableHandle",e,t,n,r);return[r.getHashTableById(a.id).tensorSize()]}default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,n,r);case"custom":const o=$(e.op);if(o&&o.customExecutor)return o.customExecutor(new me(e,t,n));throw TypeError(`Custom op ${e.op} is not registered.`);default:throw TypeError(`Unknown op '${e.op}'. File an issue at https://github.com/tensorflow/tfjs/issues so we can add it, or register a custom execution with tf.registerOp()`)}})(e,t,n);return S.ZSL.isPromise(o)?o.then(e=>[].concat(e)):[].concat(o)}class Ie{constructor(e={},t={},n={},r={}){this.weightMap=e,this.tensorArrayMap=t,this.tensorListMap=n,this.functionMap=r,this.rootContext={id:0,frameName:"",iterationId:0},this.contexts=[this.rootContext],this.lastId=0,this.generateCurrentContextIds()}newFrame(e,t){return{id:e,frameName:t,iterationId:0}}set currentContext(e){this.contexts!==e&&(this.contexts=e,this.generateCurrentContextIds())}get currentContext(){return this.contexts}get currentContextId(){return this._currentContextIds[0]}get currentContextIds(){return this._currentContextIds}generateCurrentContextIds(){const e=[];for(let t=0;t<this.contexts.length-1;t++){const n=this.contexts.slice(0,this.contexts.length-t);e.push(this.contextIdforContexts(n))}e.push(""),this._currentContextIds=e}contextIdforContexts(e){return e?e.map(e=>0===e.id&&0===e.iterationId?"":`${e.frameName}-${e.iterationId}`).join("/"):""}enterFrame(e){this.contexts&&(this.lastId++,this.contexts=this.contexts.slice(),this.contexts.push(this.newFrame(this.lastId,e)),this._currentContextIds.unshift(this.contextIdforContexts(this.contexts)))}exitFrame(){if(!(this.contexts&&this.contexts.length>1))throw new Error("Cannot exit frame, the context is empty");this.contexts=this.contexts.slice(),this.contexts.splice(-1),this.currentContextIds.shift()}nextIteration(){if(!(this.contexts&&this.contexts.length>0))throw new Error("Cannot increase frame iteration, the context is empty");{this.contexts=this.contexts.slice(),this.lastId++;const e=Object.assign({},this.contexts[this.contexts.length-1]);e.iterationId+=1,e.id=this.lastId,this.contexts.splice(-1,1,e),this._currentContextIds.splice(0,1,this.contextIdforContexts(this.contexts))}}getWeight(e){return this.weightMap[e]}addTensorArray(e){this.tensorArrayMap[e.id]=e}getTensorArray(e){return this.tensorArrayMap[e]}addTensorList(e){this.tensorListMap[e.id]=e}getTensorList(e){return this.tensorListMap[e]}dispose(e){for(const t in this.tensorArrayMap)this.tensorArrayMap[t].clearAndClose(e);for(const t in this.tensorListMap)this.tensorListMap[t].clearAndClose(e)}}function Ae(e,t,n,r){const a=new Set,o=[];let s=null,i=null;const u=new Set,c=Object.keys(e).map(e=>_(e)[0]);let l=[];null!=r&&(l=r.map(e=>_(e.name)[0]));const p=[...t];for(;p.length>0;){const e=p.pop();(Fe(e)||De(e)||Le(e))&&null==s&&(s=e,i=s.children.map(e=>e.name).filter(e=>a.has(e))),a.add(e.name),null==n[e.name]&&(-1===c.indexOf(e.name)&&-1===l.indexOf(e.name)&&(0!==e.inputs.length?e.inputs.forEac
2h(e=>{u.has(e.name)||(u.add(e.name),p.push(e))}):o.push(e.name)))}return{inputs:e,outputs:t,usedNodes:a,missingInputs:o,dynamicNode:s,syncInputs:i}}const Re=["Switch","Merge","Enter","Exit","NextIteration","StatelessIf","StatelessWhile","if","While"],_e=["NonMaxSuppressionV2","NonMaxSuppressionV3","NonMaxSuppressionV5","Where"],Oe=["HashTable","HashTableV2","LookupTableImport","LookupTableImportV2","LookupTableFind","LookupTableFindV2","LookupTableSize","LookupTableSizeV2"];function Fe(e){return Re.indexOf(e.op)>=0}function De(e){return _e.indexOf(e.op)>=0}function Le(e){return Oe.indexOf(e.op)>=0}class Me{constructor(e,t){this.graph=e,this.parent=t,this.compiledMap=new Map,this._weightMap={},this.SEPERATOR=",",this._functions={},this._functionExecutorMap={},this.intermediateTensors={},this.keepTensorForDebug=!1,this._outputs=e.outputs,this._inputs=e.inputs,this._initNodes=e.initNodes,this._signature=e.signature,this._functions=e.functions,null!=e.functions&&Object.keys(e.functions).forEach(t=>{this._functionExecutorMap[t]=new Me(e.functions[t],this)})}get weightIds(){return this.parent?this.parent.weightIds:this._weightIds}get functionExecutorMap(){return this.parent?this.parent.functionExecutorMap:this._functionExecutorMap}get weightMap(){return this.parent?this.parent.weightMap:this._weightMap}set weightMap(e){const t=Object.keys(e).map(t=>e[t].map(e=>e.id));this._weightIds=[].concat(...t),this._weightMap=e}set resourceManager(e){this._resourceManager=e}get inputs(){return this._inputs.map(e=>({name:e.name,shape:e.attrParams.shape?e.attrParams.shape.value:void 0,dtype:e.attrParams.dtype?e.attrParams.dtype.value:void 0}))}get outputs(){return this._outputs.map(e=>({name:e.name,shape:e.attrParams.shape?e.attrParams.shape.value:void 0,dtype:e.attrParams.dtype?e.attrParams.dtype.value:void 0}))}get inputNodes(){return this._inputs.map(e=>e.signatureKey||e.name)}get outputNodes(){return this._outputs.map(e=>{const t=e.signatureKey||e.name;return e.defaultOutput?`${t}:${e.defaultOutput}`:t})}get functions(){return Object.keys(this._functions).reduce((e,t)=>(e[t]=this._functions[t].signature,e),{})}getCompilationKey(e,t){const n=e.map(e=>e.name).sort(),r=t.map(e=>e.name).sort();return n.join(this.SEPERATOR)+"--"+r.join(this.SEPERATOR)}compile(e,t){const n=Ae(e,t,this.weightMap,this._initNodes),{missingInputs:r,dynamicNode:a,syncInputs:o}=n;if(null!=a)throw new Error(`This execution contains the node '${a.name}', which has the dynamic op '${a.op}'. Please use model.executeAsync() instead. Alternatively, to avoid the dynamic ops, specify the inputs [${o}]`);if(r.length>0){const n=t.map(e=>e.name),a=Object.keys(e);throw new Error(`Cannot compute the outputs [${n}] from the provided inputs [${a}]. Missing the following inputs: [${r}]`)}return function(e,t,n){const{usedNodes:r,inputs:a}=n,o=[],s=Object.keys(a).map(e=>_(e)[0]).map(t=>e.nodes[t]),i=e.initNodes;s.forEach(e=>{r.has(e.name)&&o.push(e)}),e.weights.forEach(e=>{r.has(e.name)&&o.push(e)}),null!=i&&i.forEach(e=>{r.has(e.name)&&o.push(e)});const u=new Set,c=[];for(;o.length>0;){const e=o.pop();u.add(e.name),t[e.name]||c.push(e),e.children.forEach(e=>{!u.has(e.name)&&r.has(e.name)&&e.inputs.every(e=>u.has(e.name))&&o.push(e)})}return c}(this.graph,this.weightMap,n)}execute(e,t){e=this.mapInputs(e);const n=Object.keys(e).sort();this.checkInputs(e),this.checkInputShapeAndType(e),t=this.mapOutputs(t),this.checkOutputs(t);const r=n.map(e=>this.graph.nodes[_(e)[0]]),a=t.map(e=>_(e)[0]);let o=a.map(e=>this.graph.nodes[e]);this.resetIntermediateTensors(),0===o.length&&(o=this._outputs);const s=this.getCompilationKey(r,o);let i=this.compiledMap.get(s);null==i&&(i=this.compile(e,o),this.compiledMap.set(s,i));const u={},c={};return(0,S.DZQ)(()=>{const n=new Ie(this.weightMap,u,c,this.functionExecutorMap),r=Object.assign({},this.weightMap);Object.keys(e).forEach(t=>{const[n,a]=_(t),o=[];o[a]=e[t],r[n]=o});const o=this.getFrozenTensorIds(r),s={};for(let e=0;e<i.length;e++){const t=i[e];if(!r[t.name]){const e=Ne(t,r,n,this._resourceManager);if(S.ZSL.isPromise(e))throw new Error(`The execution of the op '${t.op}' returned a promise. Please use model.executeAsync() instead.`);r[t.name]=e,this.checkTensorForDisposal(t.name,t,r,n,o,a,s)}}return null==this.parent&&n.dispose(o),t.map(e=>I(e,r,n))})}getFrozenTensorIds(e){const t=[].concat.apply([],Object.keys(e).map(t=>e[t]).map(e=>e.map(e=>e.id)));return new Set(t)}checkTensorForDisposal(e,t,n,r,a,o,s){"control"!==t.category&&-1===o.indexOf(e)&&(n[e].forEach(e
2=>{null!=e&&(s[e.id]=(s[e.id]||0)+t.children.length)}),t.inputs.forEach(e=>{if("control"!==e.category){const o=function(e,t,n){return t[R(e,n.currentContextId)]}(e.name,n,r);null!=o&&o.forEach(e=>{if(e&&!e.kept&&!a.has(e.id)){const n=s[e.id];if(1===n){if(this.keepTensorForDebug){const[n,a]=A(t.name,r);this.intermediateTensors[n]||(this.intermediateTensors[n]=[]),this.intermediateTensors[n][a]=e}else e.dispose();delete s[e.id]}else null!=n&&s[e.id]--}})}}))}async executeAsync(e,t){return this._executeAsync(e,t)}disposeIntermediateTensors(){this.intermediateTensors&&(Object.keys(this.intermediateTensors).forEach(e=>this.intermediateTensors[e].forEach(e=>e.dispose())),this.disposeTensorsMap())}disposeTensorsMap(){this.tensorsMap&&Object.keys(this.tensorsMap).forEach(e=>{this.tensorsMap[e].forEach(e=>{!e||e.kept||e.isDisposed||this.keepIds.has(e.id)||e.dispose()})})}getIntermediateTensors(){return this.tensorsMap}resetIntermediateTensors(){for(const e in this.intermediateTensors)this.intermediateTensors[e].forEach(e=>e.dispose()),delete this.intermediateTensors[e]}async _executeAsync(e,t,n=!1,r={},a={}){n||(e=this.mapInputs(e),this.checkInputs(e),this.checkInputShapeAndType(e),t=this.mapOutputs(t),this.checkOutputs(t));try{this.keepTensorForDebug=(0,S._K2)().getBool("KEEP_INTERMEDIATE_TENSORS")}catch(e){}this.resetIntermediateTensors();const o=new Ie(this.weightMap,r,a,this.functionExecutorMap);this.tensorsMap=await this.executeWithControlFlow(e,o,t,n);const s=t.map(e=>I(e,this.tensorsMap,o)),i=s.map(e=>e.id),u=Object.keys(e).map(t=>e[t].id);return this.keepIds=new Set([...i,...u,...this.weightIds]),this.keepTensorForDebug||this.disposeTensorsMap(),null==this.parent&&o.dispose(this.keepIds),s}async executeFunctionAsync(e,t,n){const r=e.reduce((e,t,n)=>(e[this.inputs[n].name]=t,e),{});return this._executeAsync(r,this.outputNodes,!0,t,n)}async executeWithControlFlow(e,t,n,r){const a=Object.keys(e),o=a.map(e=>this.graph.nodes[_(e)[0]]),s=n.map(e=>_(e)[0]);let i=s.map(e=>this.graph.nodes[e]);0===i.length&&(i=this._outputs);const{usedNodes:u,missingInputs:c,dynamicNode:l,syncInputs:p}=Ae(e,i,this.weightMap,this._initNodes),h=[...o,...this.graph.weights,...this._initNodes||[]].map(e=>({node:e,contexts:t.currentContext})),d=Object.assign({},this.weightMap);Object.keys(e).forEach(t=>{const[n,r]=_(t),a=[];a[r]=e[t],d[n]=a});const f={},m=this.getFrozenTensorIds(d),g={};for(;h.length>0;){const e=this.processStack(o,h,t,d,g,m,s,f,u);await Promise.all(e)}const y=i.filter(e=>!Fe(e)&&!I(e.name,d,t)).map(e=>e.name);if(y.length>0){let e="";throw null!=l&&(e=`Alternatively, to avoid the dynamic ops, use model.execute() and specify the inputs [${p}]`),new Error(`Cannot compute the outputs [${y}] from the provided inputs [${a}]. Consider providing the following inputs: [${c}]. ${e}`)}return d}processStack(e,t,n,r,a,o,s,i,u){const c=[];for(;t.length>0;){const e=t.pop();n.currentContext=e.contexts;let l="";if("Enter"===e.node.op&&N("isConstant",e.node,r,n)&&([l]=A(e.node.name,n)),null==r[e.node.name]){const p=Ne(e.node,r,n,this._resourceManager);l||([l]=A(e.node.name,n));const h=n.currentContext;S.ZSL.isPromise(p)?c.push(p.then(c=>(r[l]=c,n.currentContext=h,this.checkTensorForDisposal(l,e.node,r,n,o,s,i),this.processChildNodes(e.node,t,n,r,a,u),c))):(r[l]=p,this.checkTensorForDisposal(l,e.node,r,n,o,s,i),this.processChildNodes(e.node,t,n,r,a,u))}else this.processChildNodes(e.node,t,n,r,a,u)}return c}processChildNodes(e,t,n,r,a,o){e.children.forEach(e=>{const[s]=A(e.name,n);!a[s]&&o.has(e.name)&&("Merge"===e.op?e.inputNames.some(e=>!!I(e,r,n))&&(a[s]=!0,t.push({contexts:n.currentContext,node:e})):e.inputNames.every(e=>!!I(e,r,n))&&(a[s]=!0,t.push({contexts:n.currentContext,node:e})))})}dispose(){Object.keys(this.weightMap).forEach(e=>this.weightMap[e].forEach(e=>e.dispose()))}checkInputShapeAndType(e){Object.keys(e).forEach(t=>{const n=e[t],[r]=_(t),a=this.graph.nodes[r];if(a.attrParams.shape&&a.attrParams.shape.value){const e=a.attrParams.shape.value,t=e.length===n.shape.length&&n.shape.every((t,n)=>-1===e[n]||e[n]===t);S.ZSL.assert(t,()=>`The shape of dict['${a.name}'] provided in model.execute(dict) must be [${e}], but was [${n.shape}]`)}a.attrParams.dtype&&a.attrParams.dtype.value&&S.ZSL.assert(n.dtype===a.attrParams.dtype.value,()=>`The dtype of dict['${a.name}'] provided in model.execute(dict) must be ${a.attrParams.dtype.value}, but was ${n.dtype}`)})}mapInputs(e){const t={};for(const n in e)if(null!=this._signature&&null!=this._signature.inputs&&null!=this._signature.inputs[n]){t[this._signature.inputs[n].name]=e[n]}else t[n]=e[n];return t}checkInputs(e){const t=Object.keys(e).filter(e=>{const[t]=_(e);return null==this.graph.nodes[t]});if(t.length>0)throw new Error(`The dict provided in model.execute(dict) has keys: [${t}] that are not part of graph`)}mapOutputs(e){return e.map(e=>{if(null!=this._signature&&null!=this._signature.outputs&&null!=this._signature.outputs[e]){return this._signature.outputs[e].name}return e},{})}
2checkOutputs(e){e.forEach(e=>{const[t]=_(e);if(!this.graph.nodes[t])throw new Error(`The output '${e}' is not found in the graph`)})}}class Pe{constructor(e={},t={}){this.hashTableNameToHandle=e,this.hashTableMap=t}addHashTable(e,t){this.hashTableNameToHandle[e]=t.handle,this.hashTableMap[t.id]=t}getHashTableHandleByName(e){return this.hashTableNameToHandle[e]}getHashTableById(e){return this.hashTableMap[e]}dispose(){for(const e in this.hashTableMap)this.hashTableMap[e].clearAndClose(),delete this.hashTableMap[e];for(const e in this.hashTableNameToHandle)this.hashTableNameToHandle[e].dispose(),delete this.hashTableNameToHandle[e]}}const Be="?tfjs-format=file",Ve="model.json";class ze{constructor(e,t={},n=S.io){this.modelUrl=e,this.loadOptions=t,this.version="n/a",this.io=n,null==t&&(this.loadOptions={}),this.resourceManager=new Pe}get modelVersion(){return this.version}get inputNodes(){return this.executor.inputNodes}get outputNodes(){return this.executor.outputNodes}get inputs(){return this.executor.inputs}get outputs(){return this.executor.outputs}get weights(){return this.executor.weightMap}get metadata(){return this.artifacts.userDefinedMetadata}get modelSignature(){return this.signature}get modelStructuredOutputKeys(){return this.structuredOutputKeys}findIOHandler(){const e=this.modelUrl;if(null!=e.load)this.handler=e;else if(null!=this.loadOptions.requestInit)this.handler=this.io.browserHTTPRequest(e,this.loadOptions);else{const t=this.io.getLoadHandlers(e,this.loadOptions);if(0===t.length)t.push(this.io.browserHTTPRequest(e,this.loadOptions));else if(t.length>1)throw new Error(`Found more than one (${t.length}) load handlers for URL '${[e]}'`);this.handler=t[0]}}load(){if(this.findIOHandler(),null==this.handler.load)throw new Error("Cannot proceed with model loading because the IOHandler provided does not have the `load` method implemented.");const e=this.handler.load();return S.ZSL.isPromise(e)?e.then(e=>this.loadSync(e)):this.loadSync(e)}loadSync(e){this.artifacts=e;const t=this.artifacts.modelTopology;let n=this.artifacts.signature;if(null!=this.artifacts.userDefinedMetadata){const e=this.artifacts.userDefinedMetadata;null!=e.signature&&(n=e.signature),null!=e.structuredOutputKeys&&(this.structuredOutputKeys=e.structuredOutputKeys)}this.signature=n,this.version=`${t.versions.producer}.${t.versions.minConsumer}`;const r=this.io.decodeWeights(this.artifacts.weightData,this.artifacts.weightSpecs);if(this.executor=new Me(ee.Instance.transformGraph(t,this.signature)),this.executor.weightMap=this.convertTensorMapToTensorsMap(r),this.executor.resourceManager=this.resourceManager,null!=e.modelInitializer&&null!=e.modelInitializer.node){const t=ee.Instance.transformGraph(e.modelInitializer);this.initializer=new Me(t),this.initializer.weightMap=this.executor.weightMap,this.initializer.resourceManager=this.resourceManager,this.initializer.executeAsync({},[])}return!0}async save(e,t){if("string"==typeof e){const t=this.io.getSaveHandlers(e);if(0===t.length)throw new Error(`Cannot find any save handlers for URL '${e}'`);if(t.length>1)throw new Error(`Found more than one (${t.length}) save handlers for URL '${e}'`);e=t[0]}if(null==e.save)throw new Error("GraphModel.save() cannot proceed because the IOHandler provided does not have the `save` attribute defined.");return e.save(this.artifacts)}predict(e,t){const n=this.execute(e,this.outputNodes);if(this.structuredOutputKeys){const e=n instanceof S.qYS?[n]:n,t={};return e.forEach((e,n)=>t[this.structuredOutputKeys[n]]=e),t}return n}normalizeInputs(e){if(!(e instanceof S.qYS||Array.isArray(e)))return e;if((e=Array.isArray(e)?e:[e]).length!==this.inputNodes.length)throw new Error(`Input tensor count mismatch,the graph model has ${this.inputNodes.length} placeholders, while there are ${e.length} input tensors.`);return this.inputNodes.reduce((t,n,r)=>(t[n]=e[r],t),{})}normalizeOutputs(e){return e=e||this.outputNodes,Array.isArray(e)?e:[e]}execute(e,t){e=this.normalizeInputs(e),t=this.normalizeOutputs(t);const n=this.executor.execute(e,t);return n.length>1?n:n[0]}async executeAsync(e,t){e=this.normalizeInputs(e),t=this.normalizeOutputs(t);const n=await this.executor.executeAsync(e,t);return n.length>1?n:n[0]}getIntermediateTensors(){return this.executor.getIntermediateTensors()}disposeIntermediateTensors(){this.executor.disposeIntermediateTensors()}convertTensorMapToTensorsMap(e){return Object.keys(e).reduce((t,n)=>(t[n]=[e[n]],t),{})}dispose(){this.executor.dispose(),this.initializer&&this.initializer.dispose(),this.resourceManager.dispose()}}async function Ue(e,t={},n=S.io){if(null==e)throw new Error("modelUrl in loadGraphModel() cannot be null. Please provide a url or an IOHandler that loads the model");null==t&&(t={}),t.fromTFHub&&"string"==typeof e&&(e=function(e){e.endsWith("/")||(e+="/");return`${e}${Ve}${Be}`}(e));const r=new ze(e,t,n);return await r.load(),r}},28189:function(e,t,n){"use strict";n.d(t,{MZ:function(){return u},YT:function(){return p},j1:function(){return h}});var r=n(57260),a=n(46574),o=n(21722),s=n(45119),i=n(31259);function u(e,t){let n=e;if((0,s.iu)(e))return"string"===t?[]:[e.length];if(!Array.isArray(e))return[];const r=[];for(;Array.isArray(n)||(0,s.iu)(n)&&"string"!==t;)r.push(n.length),n=n[0];return Array.isArray(e)&&(0,a._K)().getBool("TENSORLIKE_CHECK_SHAPE_CONSISTENCY")&&c(e,r,[]),r}
vendor: 10,597 bytes, line 2
2function c(e,t,n){if(n=n||[],!Array.isArray(e)&&!(0,s.iu)(e))return void(0,s.vA)(0===t.length,()=>`Element arr[${n.join("][")}] is a primitive, but should be an array/TypedArray of ${t[0]} elements`);(0,s.vA)(t.length>0,()=>`Element arr[${n.join("][")}] should be a primitive, but is an array of ${e.length} elements`),(0,s.vA)(e.length===t[0],()=>`Element arr[${n.join("][")}] should have ${t[0]} elements, but has ${e.length} elements`);const r=t.slice(1);for(let t=0;t<e.length;++t)c(e[t],r,n.concat(t))}function l(e,t,n,r){if("string_or_numeric"!==e){if(null==e)throw new Error("Expected dtype cannot be null.");if("numeric"!==e&&e!==t||"numeric"===e&&"string"===t)throw new Error(`Argument '${n}' passed to '${r}' must be ${e} tensor, but got ${t} tensor`)}}function p(e,t,n,a="numeric"){if(e instanceof o.qY)return l(a,e.dtype,t,n),e;let c=(0,s.X$)(e);if("string"!==c&&["bool","int32","float32"].indexOf(a)>=0&&(c=a),l(a,c,t,n),null==e||!(0,s.iu)(e)&&!Array.isArray(e)&&"number"!=typeof e&&"boolean"!=typeof e&&"string"!=typeof e){const r=null==e?"null":e.constructor.name;throw new Error(`Argument '${t}' passed to '${n}' must be a Tensor or TensorLike, but got '${r}'`)}const p=u(e,c);(0,s.iu)(e)||Array.isArray(e)||(e=[e]);const h="string"!==c?(0,i.toTypedArray)(e,c):(0,s.Bq)(e,[],!0);return r.T2.makeTensor(h,p,c)}function h(e,t,n,r="numeric"){if(!Array.isArray(e))throw new Error(`Argument ${t} passed to ${n} must be a \`Tensor[]\` or \`TensorLike[]\``);return e.map((e,a)=>p(e,`${t}[${a}]`,n,r))}},28570:function(e){e.exports=n;var t=null;try{t=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(e){}function n(e,t,n){this.low=0|e,this.high=0|t,this.unsigned=!!n}function r(e){return!0===(e&&e.__isLong__)}n.prototype.__isLong__,Object.defineProperty(n.prototype,"__isLong__",{value:!0}),n.isLong=r;var a={},o={};function s(e,t){var n,r,s;return t?(s=0<=(e>>>=0)&&e<256)&&(r=o[e])?r:(n=u(e,(0|e)<0?-1:0,!0),s&&(o[e]=n),n):(s=-128<=(e|=0)&&e<128)&&(r=a[e])?r:(n=u(e,e<0?-1:0,!1),s&&(a[e]=n),n)}function i(e,t){if(isNaN(e))return t?y:g;if(t){if(e<0)return y;if(e>=d)return T}else{if(e<=-f)return S;if(e+1>=f)return w}return e<0?i(-e,t).neg():u(e%h|0,e/h|0,t)}function u(e,t,r){return new n(e,t,r)}n.fromInt=s,n.fromNumber=i,n.fromBits=u;var c=Math.pow;function l(e,t,n){if(0===e.length)throw Error("empty string");if("NaN"===e||"Infinity"===e||"+Infinity"===e||"-Infinity"===e)return g;if("number"==typeof t?(n=t,t=!1):t=!!t,(n=n||10)<2||36<n)throw RangeError("radix");var r;if((r=e.indexOf("-"))>0)throw Error("interior hyphen");if(0===r)return l(e.substring(1),t,n).neg();for(var a=i(c(n,8)),o=g,s=0;s<e.length;s+=8){var u=Math.min(8,e.length-s),p=parseInt(e.substring(s,s+u),n);if(u<8){var h=i(c(n,u));o=o.mul(h).add(i(p))}else o=(o=o.mul(a)).add(i(p))}return o.unsigned=t,o}function p(e,t){return"number"==typeof e?i(e,t):"string"==typeof e?l(e,t):u(e.low,e.high,"boolean"==typeof t?t:e.unsigned)}n.fromString=l,n.fromValue=p;var h=4294967296,d=h*h,f=d/2,m=s(1<<24),g=s(0);n.ZERO=g;var y=s(0,!0);n.UZERO=y;var x=s(1);n.ONE=x;var b=s(1,!0);n.UONE=b;var v=s(-1);n.NEG_ONE=v;var w=u(-1,2147483647,!1);n.MAX_VALUE=w;var T=u(-1,-1,!0);n.MAX_UNSIGNED_VALUE=T;var S=u(0,-2147483648,!1);n.MIN_VALUE=S;var C=n.prototype;C.toInt=function(){return this.unsigned?this.low>>>0:this.low},C.toNumber=function(){return this.unsigned?(this.high>>>0)*h+(this.low>>>0):this.high*h+(this.low>>>0)},C.toString=function(e){if((e=e||10)<2||36<e)throw RangeError("radix");if(this.isZero())return"0";if(this.isNegative()){if(this.eq(S)){var t=i(e),n=this.div(t),r=n.mul(t).sub(this);return n.toString(e)+r.toInt().toString(e)}return"-"+this.neg().toString(e)}for(var a=i(c(e,6),this.unsigned),o=this,s="";;){var u=o.div(a),l=(o.sub(u.mul(a)).toInt()>>>0).toString(e);if((o=u).isZero())return l+s;for(;l.length<6;)l="0"+l;s=""+l+s}},C.getHighBits=function(){return this.high},C.getHighBitsUnsigned=function(){return this.high>>>0},C.getLowBits=function(){return this.low},C.getLowBitsUnsigned=function(){return this.low>>>0},C.getNumBitsAbs=function(){if(this.isNegative())return this.eq(S)?64:this.neg().getNumBitsAbs();for(var e=0!=this.high?this.high:this.low,t=31;t>0&&!(e&1<<t);t--);return 0!=this.high?t+33:t+1},C.isZero=function(){return 0===this.high&&0===this.low},C.eqz=C.isZero,C.isNegative=function(){return!this.unsigned&&this.high<0},C.isPositive=function(){return this.unsigned||this.high>=0},C.isOdd=function(){return!(1&~this.low)},C.isEven=function(){return!(1&this.low)},C.equals=function(e){return r(e)||(e=p(e)),(this.unsigned===e.unsigned||this.high>>>31!=1||e.high>>>31!=1)&&(this.high===e.high&&this.low===e.low)},C.eq=C.equals,C.notEquals=function(e){return!this.eq(e)},C.neq=C.notEquals,C.ne=C.notEquals,C.lessThan=function(e){return this.comp(e)<0},C.lt=C.lessThan,C.lessThanOrEqual=function(e){return this.comp(e)<=0},C.lte=C.lessThanOrEqual,C.le=C.lessThanOrEqual,C.greaterThan=function(e){return this.comp(e)>0},C.gt=C.greaterThan,C.greaterThanOrEqual=function(e){return this.comp(e)>=0},C.gte=C.greaterThanOrEqual,C.ge=C.greaterThanOrEqual,C.compare=function(e){if(r(e)||(e=p(e)),this.eq(e))return 0;var t=this.isNegative(),n=e.isNegative();return t&&!n?-1:!t&&n?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},C.comp=C.compare,C.negate=function(){return!this.unsigned&&this.eq(S)?S:this.not().add(x)},C.neg=C.negate,C.add=function(e){r(e)||(e=p(e));var t=this.high>>>16,n=65535&this.high,a=this.low>>>16,o=65535&this.low,s=e.high>>>16,i=65535&e.high,c=e.low>>>16,l=0,h=0,d=0,f=0;return d+=(f+=o+(65535&e.low))>>>16,h+=(d+=a+c)>>>16,l+=(h+=n+i)>>>16,l+=t+s,u((d&=65535)<<16|(f&=65535),(l&=65535)<<16|(h&=65535),this.unsigned)},C.subtract=function(e){return r(e)||(e=p(e)),this.add(e.neg())},C.sub=C.subtract,C.multiply=function(e){if(this.isZero())return g;if(r(e)||(e=p(e)),t)return u(t.mul(this.low,this.high,e.low,e.high),t.get_high(),this.unsigned);if(e.isZero())return g;if(this.eq(S))return e.isOdd()?S:g;if(e.eq(S))return this.isOdd()?S:g;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(m)&&e.lt(m))return i(this.toNumber()*e.toNumber(),this.unsigned);var n=this.high>>>16,a=65535&this.high,o=this.low>>>16,s=65535&this.low,c=e.high>>>16,l=65535&e.high,h=e.low>>>16,d=65535&e.low,f=0,y=0,x=0,b=0;return x+=(b+=s*d)>>>16,y+=(x+=o*d)>>>16,x&=65535,y+=(x+=s*h)>>>16,f+=(y+=a*d)>>>16,y&=65535,f+=(y+=o*h)>>>16,y&=65535,f+=(y+=s*l)>>>16,f+=n*d+a*h+o*l+s*c,u((x&=65535)<<16|(b&=65535),(f&=65535)<<16|(y&=65535),this.unsigned)},C.mul=C.multiply,C.divide=function(e){if(r(e)||(e=p(e)),e.isZero())throw Error("division by zero");var n,a,o;if(t)return this.unsigned||-2147483648!==this.high||-1!==e.low||-1!==e.high?u((this.unsigned?t.div_u:t.div_s)(this.low,this.high,e.low,e.high),t.get_high(),this.unsigned):this;if(this.isZero())return this.unsigned?y:g;if(this.unsigned){if(e.unsigned||(e=e.toUnsigned()),e.gt(this))return y;if(e.gt(this.shru(1)))return b;o=y}else{if(this.eq(S))return e.eq(x)||e.eq(v)?S:e.eq(S)?x:(n=this.shr(1).div(e).shl(1)).eq(g)?e.isNegative()?x:v:(a=this.sub(e.mul(n)),o=n.add(a.div(e)));if(e.eq(S))return this.unsigned?y:g;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=g}for(a=this;a.gte(e);){n=Math.max(1,Math.floor(a.toNumber()/e.toNumber()));for(var s=Math.ceil(Math.log(n)/Math.LN2),l=s<=48?1:c(2,s-48),h=i(n),d=h.mul(e);d.isNegative()||d.gt(a);)d=(h=i(n-=l,this.unsigned)).mul(e);h.isZero()&&(h=x),o=o.add(h),a=a.sub(d)}return o},C.div=C.divide,C.modulo=function(e){return r(e)||(e=p(e)),t?u((this.unsigned?t.rem_u:t.rem_s)(this.low,this.high,e.low,e.high),t.get_high(),this.unsigned):this.sub(this.div(e).mul(e))},C.mod=C.modulo,C.rem=C.modulo,C.not=function(){return u(~this.low,~this.high,this.unsigned)},C.and=function(e){return r(e)||(e=p(e)),u(this.low&e.low,this.high&e.high,this.unsigned)},C.or=function(e){return r(e)||(e=p(e)),u(this.low|e.low,this.high|e.high,this.unsigned)},C.xor=function(e){return r(e)||(e=p(e)),u(this.low^e.low,this.high^e.high,this.unsigned)},C.shiftLeft=function(e){return r(e)&&(e=e.toInt()),0==(e&=63)?this:e<32?u(this.low<<e,this.high<<e|this.low>>>32-e,this.unsigned):u(0,this.low<<e-32,this.unsigned)},C.shl=C.shiftLeft,C.shiftRight=function(e){return r(e)&&(e=e.toInt()),0==(e&=63)?this:e<32?u(this.low>>>e|this.high<<32-e,this.high>>e,this.unsigned):u(this.high>>e-32,this.high>=0?0:-1,this.unsigned)},C.shr=C.shiftRight,C.shiftRightUnsigned=function(e){if(r(e)&&(e=e.toInt()),0===(e&=63))return this;var t=this.high;return e<32?u(this.low>>>e|t<<32-e,t>>>e,this.unsigned):u(32===e?t:t>>>e-32,0,this.unsigned)},C.shru=C.shiftRightUnsigned,C.shr_u=C.shiftRightUnsigned,C.toSigned=function(){return this.unsigned?u(this.low,this.high,!1):this},C.toUnsigned=function(){return this.unsigned?this:u(this.low,this.high,!0)},C.toBytes=function(e){return e?this.toBytesLE():this.toBytesBE()},C.toBytesLE=function(){var e=this.high,t=this.low;return[255&t,t>>>8&255,t>>>16&255,t>>>24,255&e,e>>>8&255,e>>>16&255,e>>>24]},C.toBytesBE=function(){var e=this.high,t=this.low;return[e>>>24,e>>>16&255,e>>>8&255,255&e,t>>>24,t>>>16&255,t>>>8&255,255&t]},n.fromBytes=function(e,t,r){return r?n.fromBytesLE(e,t):n.fromBytesBE(e,t)},n.fromBytesLE=function(e,t){return new n(e[0]|e[1]<<8|e[2]<<16|e[3]<<24,e[4]|e[5]<<8|e[6]<<16|e[7]<<24,t)},n.fromBytesBE=function(e,t){return new n(e[4]<<24|e[5]<<16|e[6]<<8|e[7],e[0]<<24|e[1]<<16|e[2]<<8|e[3],t)}},28968:function(e,t,n){"use strict";n.d(t,{r:function(){return s}});var r=n(57260),a=n(15441),o=n(28189);
2const s=(0,n(70929).op)({sigmoid_:function(e){const t={x:(0,o.YT)(e,"x","sigmoid","float32")};return r.T2.runKernel(a.vI1,t)}})},29809:function(e,t,n){"use strict";n.d(t,{w:function(){return i}});var r=n(57260),a=n(15441),o=n(28189),s=n(45119);const i=(0,n(70929).op)({cast_:function(e,t){const n=(0,o.YT)(e,"x","cast");if(!s.xn(t))throw new Error(`Failed to cast to unknown dtype ${t}`);if("string"===t&&"string"!==n.dtype||"string"!==t&&"string"===n.dtype)throw new Error("Only strings can be casted to strings");const i={x:n},u={dtype:t};return r.T2.runKernel(a.KXH,i,u)}})},30565:function(e,t,n){"use strict";n.d(t,{NB:function(){return u},h0:function(){return s},rt:function(){return i}});var r=n(21722),a=n(52046),o=n(45119);function s(e,t){if(e.dtype===t.dtype)return[e,t];const n=(0,a.Tu)(e.dtype,t.dtype);return[e.cast(n),t.cast(n)]}function i(e,t){(0,o.vA)(e.dtype===t.dtype,()=>`The dtypes of the first(${e.dtype}) and second(${t.dtype}) input must match`)}function u(e){const t=[];return c(e,t,new Set),t}function c(e,t,n){if(null==e)return;if(e instanceof r.qY)return void t.push(e);if(a=e,!Array.isArray(a)&&"object"!=typeof a)return;var a;const o=e;for(const e in o){const r=o[e];n.has(r)||(n.add(r),c(r,t,n))}}},31259:function(e,t,n){"use strict";n.r(t),n.d(t,{arraysEqual:function(){return a.r1},assert:function(){return a.vA},assertNonNegativeIntegerDimensions:function(){return a.SA},assertNonNull:function(){return a.HO},assertShapesMatch:function(){return a.O3},bytesFromStringArray:function(){return a.SL},bytesPerElement:function(){return a.jv},checkConversionForErrors:function(){return a.nd},clamp:function(){return a.qE},computeStrides:function(){return a.Ur},createScalarValue:function(){return b},createShuffledIndices:function(){return a.P8},decodeString:function(){return C},distSquared:function(){return a.oO},encodeString:function(){return S},fetch:function(){return T},fingerPrint64:function(){return x},flatten:function(){return a.Bq},getArrayFromDType:function(){return a.Ab},getTypedArrayFromDType:function(){return a.ce},hasEncodingLoss:function(){return a.BE},hexToLong:function(){return i},indexToLoc:function(){return a._k},inferDtype:function(){return a.X$},inferFromImplicitShape:function(){return a.XT},isBoolean:function(){return a.Lm},isFunction:function(){return a.Tn},isInt:function(){return a.E6},isNumber:function(){return a.Et},isPromise:function(){return a.yL},isScalarShape:function(){return a.Sf},isString:function(){return a.Kg},isTypedArray:function(){return a.iu},isValidDtype:function(){return a.xn},locToIndex:function(){return a.sX},makeOnesTypedArray:function(){return a.FZ},makeZerosNestedTypedArray:function(){return a.c7},makeZerosTypedArray:function(){return a.Ty},nearestDivisor:function(){return a.lK},nearestLargerEven:function(){return a.eV},now:function(){return w},parseAxisParam:function(){return a.Y6},randUniform:function(){return a.so},repeatedTry:function(){return a._q},rightPad:function(){return a.av},shuffle:function(){return a.k4},shuffleCombo:function(){return a.a0},sizeFromShape:function(){return a.Ze},sizeToSquarishShape:function(){return a.gS},squeezeShape:function(){return a.gx},sum:function(){return a.cz},swap:function(){return a.wg},tanh:function(){return a.ym},toNestedArray:function(){return a.yw},toTypedArray:function(){return v}});var r=n(46574),a=n(45119),o=n(28570);const s=n.n(o)()||o;function i(e){return s.fromString(e,!0,16)}const u=i("c3a5c85c97cb3127"),c=i("b492b66fbe98f273"),l=i("9ae16a3b2f90404f");function p(e){return e.xor(e.shru(47))}function h(e,t,n){const r=e.slice(t,t+n);return s.fromBytes(Array.from(r),!0,!0)}function d(e,t){return h(e,t,8)}function f(e,t){return h(e,t,4)}function m(e,t){return 0===t?e:e.shru(t).or(e.shl(64-t))}function g(e,t,n=i("9ddfea08eb382d69")){let r=e.xor(t).mul(n);r=r.xor(r.shru(47));let a=t.xor(r).mul(n);return a=a.xor(a.shru(47)),a=a.mul(n),a}function y(e,t,n,r){return function(e,t,n,r,a,o){a=a.add(e),o=m(o.add(a).add(r),21);const s=a;return a=(a=a.add(t)).add(n),o=o.add(m(a,44)),[a.add(r),o.add(s)]}(d(e,t),d(e,t+8),d(e,t+16),d(e,t+24),n,r)}function x(e,t=e.length){const n=s.fromNumber(81,!0);if(t<=32)return t<=16?function(e,t=e.length){if(t>=8){const n=l.add(2*t),r=d(e,0).add(l),a=d(e,t-8);return g(m(a,37).mul(n).add(r),m(r,25).add(a).mul(n),n)}if(t>=4){const n=l.add(2*t);return g(f(e,0).shl(3).add(t),f(e,t-4),n)}if(t>0){const n=e[0]+(e[t>>1]<<8),r=t+(e[t-1]<<2);return p(l.mul(n).xor(u.mul(r))).mul(l)}return l}(e,t):function(e,t=e.length){const n=l.add(2*t),r=d(e,0).mul(c),a=d(e,8),o=d(e,t-8).mul(n),s=d(e,t-16).mul(l);return g(m(r.add(a),43).add(m(o,30)).add(s),r.add(m(a.add(l),18)).add(o),n)}(e,t);if(t<=64)return function(e,t=e.length){const n=l.add(2*t),r=d(e,0).mul(l),a=d(e,8),o=d(e,t-8).mul(n),s=d(e,t-16).mul(l),i=m(r.add(a),43).add(m(o,30)).add(s),u=g(i,r.add(m(a.add(l),18)).add(o),n),c=d(e,16).mul(n),p=d(e,24),h=i.add(d(e,t-32)).mul(n),f=u.add(d(e,t-24)).mul(n);return g(m(c.add(p),43).add(m(h,30)).add(f),c.add(m(p.add(r),18)).add(h),n)}(e,t);let r=n,a=n.mul(c).add(113),o=p(a.mul(l).add(113)).mul(l),i=[s.UZERO,s.UZERO],h=[s.UZERO,s.UZERO];r=r.mul(l).add(d(e,0));let x=0;const b=64*(t-1>>6),v=b+(t-1&63)-63;do{r=m(r.add(a).add(i[0]).add(d(e,x+8)),37).mul(c),a=m(a.add(i[1]).add(d(e,x+48)),42).mul(c),r=r.xor(h[1]),a=a.add(i[0]).add(d(e,x+40)),o=m(o.add(h[0]),33).mul(c),i=y(e,x,i[1].mul(c),r.add(h[0])),h=y(e,x+32,o.add(h[1]),a.add(d(e,x+16))),[o,r]=[r,o],x+=64}while(x!==b);const w=c.add(o.and(255).shl(1));return x=v,h[0]=h[0].add(t-1&63),i[0]=i[0].add(h[0]),h[0]=h[0].add(i[0]),r=m(r.add(a).add(i[0]).add(d(e,x+8)),37).mul(w),a=m(a.add(i[1]).add(d(e,x+48)),42).mul(w),r=r.xor(h[1].mul(9)),a=a.add(i[0].mul(9).add(d(e,x+40))),o=m(o.add(h[0]),33).mul(w),i=y(e,x,i[1].mul(w),r.add(h[0])),h=y(e,x+32,o.add(h[1]),a.add(d(e,x+16))),[o,r]=[r,o],g(g(i[0],h[0],w).add(p(a).mul(u)).add(o),g(i[1],h[1],w).add(r),w)}function b(e,t){return"string"===t?S(e):v([e],t)}function v(e,t){if("string"===t)throw new Error("Cannot convert a string[] to a TypedArray");if(Array.isArray(e)&&(e=a.Bq(e)),(0,r._K)().getBool("DEBUG")&&a.nd(e,t),function(e,t){return e instanceof Float32Array&&"float32"===t||e instanceof Int32Array&&"int32"===t||e instanceof Uint8Array&&"bool"===t}(e,t))return e;if(null==t||"float32"===t||"complex64"===t)return new Float32Array(e);if("int32"===t)return new Int32Array(e);if("bool"===t){const t=new Uint8Array(e.length);for(let n=0;n<t.length;++n)0!==Math.round(e[n])&&(t[n]=1);return t}throw new Error(`Unknown data type ${t}`)}function w(){return(0,r._K)().platform.now()}function T(e,t){return(0,r._K)().platform.fetch(e,t)}function S(e,t="utf-8"){return t=t||"utf-8",(0,r._K)().platform.encode(e,t)}function C(e,t="utf-8"){return t=t||"utf-8",(0,r._K)().platform.decode(e,t)}},35287:function(e,t,n){"use strict";n.d(t,{AS:function(){return c},DZ:function(){return u},Hi:function(){return i},aC:function(){return l},gJ:function(){return p}});var r=n(57260),a=n(46574),o=n(21722),s=n(30565);function i(){return r.T2}function u(e,t){return r.T2.tidy(e,t)}
2function c(e){(0,s.NB)(e).forEach(e=>e.dispose())}function l(e){return r.T2.keep(e)}function p(e,t,n=1){return r.T2.registerBackend(e,t,n)}(0,o.B4)(function(e){(0,a._K)().getBool("DEPRECATION_WARNINGS_ENABLED")})},37074:function(e,t,n){"use strict";n.d(t,{Op:function(){return c},_5:function(){return i},tA:function(){return l},vQ:function(){return u}});var r=n(41743),a=n(73673);const o=(0,r.m)("kernelRegistry",()=>new Map),s=(0,r.m)("gradRegistry",()=>new Map);function i(e,t){const n=p(e,t);return o.get(n)}function u(e){return s.get(e)}function c(e){const t=o.entries(),n=[];for(;;){const{done:r,value:a}=t.next();if(r)break;const[o,s]=a,[i]=o.split("_");i===e&&n.push(s)}return n}function l(e){const{kernelName:t,backendName:n}=e,r=p(t,n);o.has(r)&&a.i(`The kernel '${t}' for backend '${n}' is already registered`),o.set(r,e)}function p(e,t){return`${t}_${e}`}},37148:function(e,t,n){"use strict";n.d(t,{f:function(){return i}});var r=n(57260),a=n(15441),o=n(28189),s=n(45119);const i=(0,n(70929).op)({complex_:function(e,t){const n=(0,o.YT)(e,"real","complex"),i=(0,o.YT)(t,"imag","complex");s.O3(n.shape,i.shape,`real and imag shapes, ${n.shape} and ${i.shape}, must match in call to tf.complex().`);const u={real:n,imag:i};return r.T2.runKernel(a.pr3,u)}})},41743:function(e,t,n){"use strict";let r;function a(){if(null==r){let e;if("undefined"!=typeof window)e=window;else if(void 0!==n.g)e=n.g;else if("undefined"!=typeof process)e=process;else{if("undefined"==typeof self)throw new Error("Could not find a global object");e=self}r=e}return r}function o(e,t){const n=function(){const e=a();return null==e._tfGlobals&&(e._tfGlobals=new Map),e._tfGlobals}();if(n.has(e))return n.get(e);{const r=t();return n.set(e,r),n.get(e)}}n.d(t,{L:function(){return a},m:function(){return o}})},42768:function(e,t,n){"use strict";n.d(t,{$:function(){return s}});var r=n(28189),a=n(45119),o=n(19171);function s(e,t,n){if((0,a.HO)(e),null!=t&&3!==t.length)throw new Error("tensor3d() requires shape to have three numbers");const s=(0,r.MZ)(e,n);if(3!==s.length&&1!==s.length)throw new Error("tensor3d() requires values to be number[][][] or flat/TypedArray");if(1===s.length&&null==t)throw new Error("tensor3d() requires shape to be provided when `values` are a flat array");return(0,o.Q)(e,t,s,n)}},43031:function(e,t,n){var r;!function(e,a){function o(e){var t=this,n="";t.next=function(){var e=t.x^t.x>>>2;return t.x=t.y,t.y=t.z,t.z=t.w,t.w=t.v,(t.d=t.d+362437|0)+(t.v=t.v^t.v<<4^e^e<<1)|0},t.x=0,t.y=0,t.z=0,t.w=0,t.v=0,e===(0|e)?t.x=e:n+=e;for(var r=0;r<n.length+64;
2r++)t.x^=0|n.charCodeAt(r),r==n.length&&(t.d=t.x<<10^t.x>>>4),t.next()}function s(e,t){return t.x=e.x,t.y=e.y,t.z=e.z,t.w=e.w,t.v=e.v,t.d=e.d,t}function i(e,t){var n=new o(e),r=t&&t.state,a=function(){return(n.next()>>>0)/4294967296};return a.double=function(){do{var e=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},a.int32=n.next,a.quick=a,r&&("object"==typeof r&&s(r,n),a.state=function(){return s(n,{})}),a}a&&a.exports?a.exports=i:n.amdD&&n.amdO?void 0===(r=function(){return i}.call(t,n,t,a))||(a.exports=r):this.xorwow=i}(0,e=n.nmd(e),n.amdD)},43181:function(e,t,n){var r;!function(e,a){function o(e){var t=this,n="";t.x=0,t.y=0,t.z=0,t.w=0,t.next=function(){var e=t.x^t.x<<11;return t.x=t.y,t.y=t.z,t.z=t.w,t.w^=t.w>>>19^e^e>>>8},e===(0|e)?t.x=e:n+=e;for(var r=0;r<n.length+64;r++)t.x^=0|n.charCodeAt(r),t.next()}function s(e,t){return t.x=e.x,t.y=e.y,t.z=e.z,t.w=e.w,t}function i(e,t){var n=new o(e),r=t&&t.state,a=function(){return(n.next()>>>0)/4294967296};return a.double=function(){do{var e=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},a.int32=n.next,a.quick=a,r&&("object"==typeof r&&s(r,n),a.state=function(){return s(n,{})}),a}a&&a.exports?a.exports=i:n.amdD&&n.amdO?void 0===(r=function(){return i}.call(t,n,t,a))||(a.exports=r):this.xor128=i}(0,e=n.nmd(e),n.amdD)},43303:function(e,t,n){"use strict";function r(e,t,n){const r=function(e,t,n){return function(e,t,n){let r=0,a=e.length,o=0,s=!1;for(;r<a;){o=r+(a-r>>>1);const i=n(t,e[o]);i>0?r=o+1:(a=o,s=!i)}return s?r:-r-1}(e,t,n||a)}(e,t,n),o=r<0?-(r+1):r;e.splice(o,0,t)}function a(e,t){return e>t?1:e<t?-1:0}function o(e,t,n,r,a){return u(e,t,n,r,a,0)}function s(e,t,n,r,a,o){return u(e,t,n,r,a,0,!1,o,!0)}function i(e,t,n,r,a,o){return u(e,t,n,r,a,o,!0)}function u(e,t,n,a,o,s,i=!1,u=!1,h=!1){const d=[];for(let e=0;e<t.length;e++)t[e]>o&&d.push({score:t[e],boxIndex:e,suppressBeginIndex:0});d.sort(p);const f=s>0?-.5/s:0,m=[],g=[];for(;m.length<n&&d.length>0;){const t=d.pop(),{score:n,boxIndex:s,suppressBeginIndex:i}=t;if(n<o)break;let u=!1;for(let n=m.length-1;n>=i;--n){const r=c(e,s,m[n]);if(r>=a){u=!0;break}if(t.score=t.score*l(a,f,r),t.score<=o)break}t.suppressBeginIndex=m.length,u||(t.score===n?(m.push(s),g.push(t.score)):t.score>o&&r(d,t,p))}const y=m.length,x=n-y;u&&x>0&&(m.push(...new Array(x).fill(0)),g.push(...new Array(x).fill(0)));const b={selectedIndices:m};return i&&(b.selectedScores=g),h&&(b.validOutputs=y),b}function c(e,t,n){const r=e.subarray(4*t,4*t+4),a=e.subarray(4*n,4*n+4),o=Math.min(r[0],r[2]),s=Math.min(r[1],r[3]),i=Math.max(r[0],r[2]),u=Math.max(r[1],r[3]),c=Math.min(a[0],a[2]),l=Math.min(a[1],a[3]),p=Math.max(a[0],a[2]),h=Math.max(a[1],a[3]),d=(i-o)*(u-s),f=(p-c)*(h-l);if(d<=0||f<=0)return 0;const m=Math.max(o,c),g=Math.max(s,l),y=Math.min(i,p),x=Math.min(u,h),b=Math.max(y-m,0)*Math.max(x-g,0);return b/(d+f-b)}function l(e,t,n){const r=Math.exp(t*n*n);return n<=e?r:0}function p(e,t){return e.score-t.score||e.score===t.score&&t.boxIndex-e.boxIndex}n.d(t,{c7:function(){return o},ZS:function(){return s},ut:function(){return i}})},43717:function(e,t,n){var r;!function(e,a){function o(e){var t=this,n="";t.next=function(){var e=t.b,n=t.c,r=t.d,a=t.a;return e=e<<25^e>>>7^n,n=n-r|0,r=r<<24^r>>>8^a,a=a-e|0,t.b=e=e<<20^e>>>12^n,t.c=n=n-r|0,t.d=r<<16^n>>>16^a,t.a=a-e|0},t.a=0,t.b=0,t.c=-1640531527,t.d=1367130551,e===Math.floor(e)?(t.a=e/4294967296|0,t.b=0|e):n+=e;for(var r=0;r<n.length+20;r++)t.b^=0|n.charCodeAt(r),t.next()}function s(e,t){return t.a=e.a,t.b=e.b,t.c=e.c,t.d=e.d,t}function i(e,t){var n=new o(e),r=t&&t.state,a=function(){return(n.next()>>>0)/4294967296};return a.double=function(){do{var e=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},a.int32=n.next,a.quick=a,r&&("object"==typeof r&&s(r,n),a.state=function(){return s(n,{})}),a}a&&a.exports?a.exports=i:n.amdD&&n.amdO?void 0===(r=function(){return i}.call(t,n,t,a))||(a.exports=r):this.tychei=i}(0,e=n.nmd(e),n.amdD)},45119:function(e,t,n){"use strict";function r(e){let t=e.length,n=0;for(;t>0;
2)n=Math.random()*t|0,t--,i(e,t,n)}function a(e,t){if(e.length!==t.length)throw new Error(`Array sizes must match to be shuffled together First array length was ${e.length}Second array length was ${t.length}`);let n=e.length,r=0;for(;n>0;)r=Math.random()*n|0,n--,i(e,n,r),i(t,n,r)}function o(e,t,n){return Math.max(e,Math.min(t,n))}function s(e){return e%2==0?e:e+1}function i(e,t,n){const r=e[t];e[t]=e[n],e[n]=r}function u(e){let t=0;for(let n=0;n<e.length;n++)t+=e[n];return t}function c(e,t){const n=Math.random();return t*n+(1-n)*e}function l(e,t){let n=0;for(let r=0;r<e.length;r++){const a=Number(e[r])-Number(t[r]);n+=a*a}return n}function p(e,t){if(!e)throw new Error("string"==typeof t?t:t())}function h(e,t,n=""){p(y(e,t),()=>n+` Shapes ${e} and ${t} must match`)}function d(e){p(null!=e,()=>"The input to the tensor constructor must be a non-null value.")}function f(e,t=[],n=!1){if(null==t&&(t=[]),Array.isArray(e)||_(e)&&!n)for(let r=0;r<e.length;++r)f(e[r],t,n);else t.push(e);return t}function m(e){if(0===e.length)return 1;let t=e[0];for(let n=1;n<e.length;n++)t*=e[n];return t}function g(e){return 0===e.length}function y(e,t){if(e===t)return!0;if(null==e||null==t)return!1;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function x(e){return e%1==0}function b(e){if(null!=Math.tanh)return Math.tanh(e);if(e===1/0)return 1;if(e===-1/0)return-1;{const t=Math.exp(2*e);return(t-1)/(t+1)}}function v(e){const t=Math.ceil(Math.sqrt(e));return[t,Math.ceil(e/t)]}function w(e){const t=new Uint32Array(e);for(let n=0;n<e;++n)t[n]=n;return r(t),t}function T(e,t){return t<=e.length?e:e+" ".repeat(t-e.length)}function S(e,t=e=>0,n,r=setTimeout){return new Promise((a,o)=>{let s=0;const i=()=>{if(e())return void a();s++;const u=t(s);null!=n&&s>=n?o():r(i,u)};i()})}function C(e,t){let n=1,r=-1;for(let t=0;t<e.length;++t)if(e[t]>=0)n*=e[t];else if(-1===e[t]){if(-1!==r)throw Error(`Shapes can only have 1 implicit size. Found -1 at dim ${r} and dim ${t}`);r=t}else if(e[t]<0)throw Error(`Shapes can not be < 0. Found ${e[t]} at dim ${t}`);if(-1===r){if(t>0&&t!==n)throw Error(`Size(${t}) must match the product of shape ${e}`);return e}if(0===n)throw Error(`Cannot infer the missing size in [${e}] when there are 0 elements`);if(t%n!==0)throw Error(`The implicit shape can't be a fractional number. Got ${t} / ${n}`);const a=e.slice();return a[r]=t/n,a}function k(e,t){const n=t.length;return p((e=null==e?t.map((e,t)=>t):[].concat(e)).every(e=>e>=-n&&e<n),()=>`All values in axis param must be in range [-${n}, ${n}) but got axis ${e}`),p(e.every(e=>x(e)),()=>`All values in axis param must be integers but got axis ${e}`),e.map(e=>e<0?n+e:e)}function E(e,t){const n=[],r=[],a=null!=t&&Array.isArray(t)&&0===t.length,o=null==t||a?null:k(t,e).sort();let s=0;for(let t=0;t<e.length;++t){if(null!=o){if(o[s]===t&&1!==e[t])throw new Error(`Can't squeeze axis ${t} since its dim '${e[t]}' is not 1`);(null==o[s]||o[s]>t)&&1===e[t]&&(n.push(e[t]),r.push(t)),o[s]<=t&&s++}1!==e[t]&&(n.push(e[t]),r.push(t))}return{newShape:n,keptDims:r}}function $(e,t){let n=null;if(null==e||"float32"===e)n=new Float32Array(t);else if("int32"===e)n=new Int32Array(t);else{if("bool"!==e)throw new Error(`Unknown data type ${e}`);n=new Uint8Array(t)}return n}function N(e,t){let n=null;if(null==e||"float32"===e)n=new Float32Array(t);else if("int32"===e)n=new Int32Array(t);else if("bool"===e)n=new Uint8Array(t);else{if("string"!==e)throw new Error(`Unknown data type ${e}`);n=new Array(t)}return n}function I(e,t){for(let n=0;n<e.length;n++){const r=e[n];if(isNaN(r)||!isFinite(r))throw Error(`A tensor of type ${t} being uploaded contains ${r}.`)}}function A(e){return"bool"===e||"complex64"===e||"float32"===e||"int32"===e||"string"===e}function R(e,t){return"complex64"!==t&&(("float32"!==t||"complex64"===e)&&(("int32"!==t||"float32"===e||"complex64"===e)&&("bool"!==t||"bool"!==e)))}function _(e){return e instanceof Float32Array||e instanceof Int32Array||e instanceof Uint8Array||e instanceof Uint8ClampedArray}function O(e){if("float32"===e||"int32"===e)return 4;if("complex64"===e)return 8;if("bool"===e)return 1;throw new Error(`Unknown dtype ${e}`)}function F(e){if(null==e)return 0;let t=0;
2return e.forEach(e=>t+=e.length),t}function D(e){return"string"==typeof e||e instanceof String}function L(e){return"boolean"==typeof e}function M(e){return"number"==typeof e}function P(e){return Array.isArray(e)?P(e[0]):e instanceof Float32Array?"float32":e instanceof Int32Array||e instanceof Uint8Array||e instanceof Uint8ClampedArray?"int32":M(e)?"float32":D(e)?"string":L(e)?"bool":"float32"}function B(e){return!!(e&&e.constructor&&e.call&&e.apply)}function V(e,t){for(let n=t;n<e;++n)if(e%n===0)return n;return e}function z(e){const t=e.length;if(t<2)return[];const n=new Array(t-1);n[t-2]=e[t-1];for(let r=t-3;r>=0;--r)n[r]=n[r+1]*e[r+1];return n}function U(e,t,n,r=!1){const a=new Array;if(1===t.length){const o=t[0]*(r?2:1);for(let t=0;t<o;t++)a[t]=n[e+t]}else{const o=t[0],s=t.slice(1),i=s.reduce((e,t)=>e*t)*(r?2:1);for(let t=0;t<o;t++)a[t]=U(e+t*i,s,n,r)}return a}function W(e,t,n=!1){if(0===e.length)return t[0];const r=e.reduce((e,t)=>e*t)*(n?2:1);if(0===r)return[];if(r!==t.length)throw new Error(`[${e}] does not match the input size ${t.length}${n?" for a complex tensor":""}.`);return U(0,e,t,n)}function G(e,t){const n=j(e,t);for(let e=0;e<n.length;e++)n[e]=1;return n}function j(e,t){if(null==t||"float32"===t||"complex64"===t)return new Float32Array(e);if("int32"===t)return new Int32Array(e);if("bool"===t)return new Uint8Array(e);throw new Error(`Unknown data type ${t}`)}function K(e,t){const n=e.reduce((e,t)=>e*t,1);if(null==t||"float32"===t)return W(e,new Float32Array(n));if("int32"===t)return W(e,new Int32Array(n));if("bool"===t)return W(e,new Uint8Array(n));throw new Error(`Unknown data type ${t}`)}function H(e){e.forEach(t=>{p(Number.isInteger(t)&&t>=0,()=>`Tensor must have a shape comprised of positive integers but got shape [${e}].`)})}function Y(e,t,n){if(0===t)return 0;if(1===t)return e[0];let r=e[e.length-1];for(let t=0;t<e.length-1;++t)r+=n[t]*e[t];return r}function Z(e,t,n){if(0===t)return[];if(1===t)return[e];const r=new Array(t);for(let t=0;t<r.length-1;++t)r[t]=Math.floor(e/n[t]),e-=r[t]*n[t];return r[r.length-1]=e,r}function X(e){return e&&e.then&&"function"==typeof e.then}n.d(t,{Ab:function(){return N},BE:function(){return R},Bq:function(){return f},E6:function(){return x},Et:function(){return M},FZ:function(){return G},HO:function(){return d},Kg:function(){return D},Lm:function(){return L},O3:function(){return h},P8:function(){return w},SA:function(){return H},SL:function(){return F},Sf:function(){return g},Tn:function(){return B},Ty:function(){return j},Ur:function(){return z},X$:function(){return P},XT:function(){return C},Y6:function(){return k},Ze:function(){return m},_k:function(){return Z},_q:function(){return S},a0:function(){return a},av:function(){return T},c7:function(){return K},ce:function(){return $},cz:function(){return u},eV:function(){return s},gS:function(){return v},gx:function(){return E},iu:function(){return _},jv:function(){return O},k4:function(){return r},lK:function(){return V},nd:function(){return I},oO:function(){return l},qE:function(){return o},r1:function(){return y},sX:function(){return Y},so:function(){return c},vA:function(){return p},wg:function(){return i},xn:function(){return A},yL:function(){return X},ym:function(){return b},yw:function(){return W}})},45702:function(e,t,n){"use strict";n.d(t,{d:function(){return o}});var r=n(45119),a=n(19171);function o(e,t){if(((0,r.iu)(e)&&"string"!==t||Array.isArray(e))&&"complex64"!==t)throw new Error("Error creating a new Scalar: value must be a primitive (number|boolean|string)");if("string"===t&&(0,r.iu)(e)&&!(e instanceof Uint8Array))throw new Error("When making a scalar from encoded string, the value must be `Uint8Array`.");return(0,a.Q)(e,[],[],t)}},46574:function(e,t,n){"use strict";n.d(t,{OH:function(){return o},_K:function(){return i},tj:function(){return c}});var r=n(45119);const a="tfjsflags";class o{constructor(e){this.global=e,this.flags={},this.flagRegistry={},this.urlFlags={},this.getQueryParams=s,this.populateURLFlags()}setPlatform(e,t){null!=this.platform&&!i().getBool("IS_TEST")&&i().getBool("PROD"),this.platformName=e,this.platform=t}registerFlag(e,t,n){if(this.flagRegistry[e]={evaluationFn:t,setHook:n},null!=this.urlFlags[e]){const t=this.urlFlags[e];!i().getBool("IS_TEST")&&i().getBool("PROD"),this.set(e,t)}}async getAsync(e){return e in this.flags||(this.flags[e]=await this.evaluateFlag(e)),this.flags[e]}get(e){if(e in this.flags)return this.flags[e];const t=this.evaluateFlag(e);if((0,r.yL)(t))throw new Error(`Flag ${e} cannot be synchronously evaluated. Please use getAsync() instead.`);return this.flags[e]=t,this.flags[e]}getNumber(e){return this.get(e)}getBool(e){return this.get(e)}getFlags(){return this.flags}get features(){return this.flags}set(e,t){if(null==this.flagRegistry[e])throw new Error(`Cannot set flag ${e} as it has not been registered.`);this.flags[e]=t,null!=this.flagRegistry[e].setHook&&this.flagRegistry[e].setHook(t)}evaluateFlag(e){if(null==this.flagRegistry[e])throw new Error(`Cannot evaluate flag '${e}': no evaluation function found.`);return this.flagRegistry[e].evaluationFn()}setFlags(e){this.flags=Object.assign({},e)}reset(){this.flags={},this.urlFlags={},this.populateURLFlags()}populateURLFlags(){if(void 0===this.global||void 0===this.global.location||void 0===this.global.location.search)return;const e=this.getQueryParams(this.global.location.search);
2if(a in e){e[a].split(",").forEach(e=>{const[t,n]=e.split(":");this.urlFlags[t]=function(e,t){if("true"===(t=t.toLowerCase())||"false"===t)return"true"===t;if(""+ +t===t)return+t;throw new Error(`Could not parse value flag value ${t} for flag ${e}.`)}(t,n)})}}}function s(e){const t={};return e.replace(/[?&]([^=?&]+)(?:=([^&]*))?/g,(e,...n)=>(function(e,t,n){e[decodeURIComponent(t)]=decodeURIComponent(n||"")}(t,n[0],n[1]),n.join("="))),t}function i(){return u}let u=null;function c(e){u=e}},47049:function(e,t,n){"use strict";var r={};n.r(r),n.d(r,{mx:function(){return Ve},XI:function(){return Ue},Nk:function(){return We},ct:function(){return Le},YG:function(){return He},hH:function(){return Ye},z3:function(){return Ze},sG:function(){return Xe},uM:function(){return qe},vS:function(){return Qe},qB:function(){return Je},GG:function(){return et},lg:function(){return nt},rq:function(){return tt},cu:function(){return at},WR:function(){return rt},GE:function(){return ot},px:function(){return st},jC:function(){return it},He:function(){return ut},hE:function(){return ct},BF:function(){return lt},Dk:function(){return ht},cl:function(){return dt},_B:function(){return mt},ub:function(){return bt},Ku:function(){return Ct},qy:function(){return kt},Zy:function(){return Et},bu:function(){return $t},zv:function(){return Nt},dH:function(){return Ae},HS:function(){return It},yH:function(){return At},l3:function(){return Rt},z9:function(){return _t},x6:function(){return Ot},eW:function(){return Ft},GK:function(){return Lt},SP:function(){return Pt},f6:function(){return Bt},dl:function(){return Vt},Dw:function(){return Ut},xT:function(){return jt},_X:function(){return ft},wz:function(){return Kt}});var a=n(77367);const o={},s={alpha:!1,antialias:!1,premultipliedAlpha:!1,preserveDrawingBuffer:!1,depth:!1,stencil:!1,failIfMajorPerformanceCaveat:!0};function i(e,t){if(!(e in o)||null!=t){const n=function(e,t){if(1!==e&&2!==e)throw new Error("Cannot get WebGL rendering context, WebGL is disabled.");const n=null==t?function(e){if("undefined"!=typeof OffscreenCanvas&&2===e)return new OffscreenCanvas(300,150);if("undefined"!=typeof document)return document.createElement("canvas");throw new Error("Cannot create a canvas in this context")}(e):t;n.addEventListener("webglcontextlost",t=>{t.preventDefault(),delete o[e]},!1),(0,a._K2)().getBool("SOFTWARE_WEBGL_ENABLED")&&(s.failIfMajorPerformanceCaveat=!1);if(1===e)return n.getContext("webgl",s)||n.getContext("experimental-webgl",s);return n.getContext("webgl2",s)}(e,t);if(null===n)return null;o[e]=n}const n=o[e];return null==n||n.isContextLost()?(delete o[e],i(e)):(n.disable(n.DEPTH_TEST),n.disable(n.STENCIL_TEST),n.disable(n.BLEND),n.disable(n.DITHER),n.disable(n.POLYGON_OFFSET_FILL),n.disable(n.SAMPLE_COVERAGE),n.enable(n.SCISSOR_TEST),n.enable(n.CULL_FACE),n.cullFace(n.BACK),o[e])}var u,c,l;function p(e,t){return[t,e]}function h(e){const t=a.ZSL.sizeFromShape(e),n=Math.ceil(t/4);return a.ZSL.sizeToSquarishShape(n)}function d(e,t){return[Math.max(1,Math.ceil(t/2)),Math.max(1,Math.ceil(e/2))]}function f(e,t){const n=e;let r,o,s,i,u,c,l,p,h,d;return 2===(0,a._K2)().getNumber("WEBGL_VERSION")?(r=n.R32F,o=n.R16F,s=n.RGBA16F,i=n.RGBA32F,u=n.RED,l=4,p=1,h=n.HALF_FLOAT,d=n.FLOAT,c=n.RGBA8):(r=e.RGBA,o=e.RGBA,s=e.RGBA,i=n.RGBA,u=e.RGBA,l=4,p=4,h=null!=t?t.HALF_FLOAT_OES:null,d=e.FLOAT,c=e.RGBA),{internalFormatFloat:r,internalFormatHalfFloat:o,internalFormatPackedHalfFloat:s,internalFormatPackedFloat:i,textureFormatFloat:u,downloadTextureFormat:c,downloadUnpackNumChannels:l,defaultNumChannels:p,textureTypeHalfFloat:h,textureTypeFloat:d}}function m(e,t){const n=t();return(0,a._K2)().getBool("DEBUG")&&function(e){const t=e.getError();if(t!==e.NO_ERROR)throw new Error("WebGL Error: "+function(e,t){switch(t){case e.NO_ERROR:return"NO_ERROR";case e.INVALID_ENUM:return"INVALID_ENUM";case e.INVALID_VALUE:return"INVALID_VALUE";case e.INVALID_OPERATION:return"INVALID_OPERATION";case e.INVALID_FRAMEBUFFER_OPERATION:return"INVALID_FRAMEBUFFER_OPERATION";case e.OUT_OF_MEMORY:return"OUT_OF_MEMORY";case e.CONTEXT_LOST_WEBGL:return"CONTEXT_LOST_WEBGL";default:return`Unknown error code ${t}`}}(e,t))}(e),n}!function(e){e[e.DENSE=0]="DENSE",e[e.SHARED_BATCH=1]="SHARED_BATCH"}(u||(u={})),function(e){e[e.RENDER=0]="RENDER",e[e.UPLOAD=1]="UPLOAD",e[e.PIXELS=2]="PIXELS",e[e.DOWNLOAD=3]="DOWNLOAD"}(c||(c={})),function(e){e[e.UNPACKED_FLOAT16=0]="UNPACKED_FLOAT16",e[e.UNPACKED_FLOAT32=1]="UNPACKED_FLOAT32",e[e.PACKED_4X1_UNSIGNED_BYTE=2]="PACKED_4X1_UNSIGNED_BYTE",e[e.PACKED_2X2_FLOAT32=3]="PACKED_2X2_FLOAT32",e[e.PACKED_2X2_FLOAT16=4]="PACKED_2X2_FLOAT16"}(l||(l={}));function g(e){return!!((0,a._K2)().getBool("WEBGL_RENDER_FLOAT32_ENABLED")||0===e||5.96e-8<Math.abs(e)&&Math.abs(e)<65504)}function y(e,t){return E(e,()=>e.getExtension(t),'Extension "'+t+'" not supported on this browser.')}const x=/ERROR: [0-9]+:([0-9]+):/g;function b(e,t){const n=x.exec(t);if(null==n)return;const r=+n[1],o=e.split("\n"),s=o.length.toString().length+2,i=o.map((e,t)=>a.ZSL.rightPad((t+1).toString(),s)+e);let u=0;for(let e=0;e<i.length;e++)u=Math.max(i[e].length,u);i.slice(0,r-1),i.slice(r-1,r),i.slice(r)}function v(e,t){if(m(e,()=>e.validateProgram(t)),!1===e.getProgramParameter(t,e.VALIDATE_STATUS))throw new Error("Shader program validation failed.")}function w(e,t,n,r,a,o,s){const i=e.getAttribLocation(t,n);return-1!==i&&(m(e,()=>e.bindBuffer(e.ARRAY_BUFFER,r)),m(e,()=>e.vertexAttribPointer(i,a,e.FLOAT,!1,o,s)),m(e,()=>e.enableVertexAttribArray(i)),!0)}function T(e,t,n,r){m(e,()=>function(e,t,n){$(e,n),m(e,()=>e.activeTexture(e.TEXTURE0+n)),m(e,()=>e.bindTexture(e.TEXTURE_2D,t))}(e,t,r)),m(e,()=>e.uniform1i(n,r))}function S(e,t,n){m(e,()=>e.bindFramebuffer(e.FRAMEBUFFER,n)),m(e,()=>e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,t,0))}function C(e,t){m(e,()=>e.bindFramebuffer(e.FRAMEBUFFER,t)),m(e,()=>e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,null,0))}function k(e){const t=e.checkFramebufferStatus(e.FRAMEBUFFER);if(t!==e.FRAMEBUFFER_COMPLETE)throw new Error("Error binding framebuffer: "+function(e,t){switch(t){case e.FRAMEBUFFER_INCOMPLETE_ATTACHMENT:return"FRAMEBUFFER_INCOMPLETE_ATTACHMENT";case e.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT:return"FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT";case e.FRAMEBUFFER_INCOMPLETE_DIMENSIONS:return"FRAMEBUFFER_INCOMPLETE_DIMENSIONS";case e.FRAMEBUFFER_UNSUPPORTED:return"FRAMEBUFFER_UNSUPPORTED";default:return`unknown error ${t}`}}(e,t))}function E(e,t,n){const r=m(e,()=>t());if(null==r)throw new Error(n);return r}function $(e,t){const n=e.MAX_COMBINED_TEXTURE_IMAGE_UNITS-1,r=t+e.TEXTURE0;if(r<e.TEXTURE0||r>n){throw new Error(`textureUnit must be in ${`[gl.TEXTURE0, gl.TEXTURE${n}]`}.`)}}function N(e,t=2){return a.ZSL.sizeFromShape(e.slice(0,e.length-t))}function I(e){if(0===e.length)throw Error("Cannot get rows and columns of an empty shape array.");return[e.length>1?e[e.length-2]:1,e[e.length-1]]}function A(e){let t=[1,1,1];return 0===e.length||1===e.length&&1===e[0]||(t=[N(e),...I(e)]),t}function R(e){return e%2==0}
2function _(e,t){if(e=e.slice(-2),t=t.slice(-2),a.ZSL.arraysEqual(e,t))return!0;if(!e.length||!t.length)return!0;if(0===e[0]||0===e[1]||0===t[0]||0===t[1])return!0;if(e.length!==t.length){const n=e.slice(-1)[0],r=t.slice(-1)[0];if(n===r)return!0;if(R(n)&&R(r)&&(1===e[0]||1===t[0]))return!0}return e[1]===t[1]&&R(e[0])&&R(t[0])}let O,F;function D(e,t){return null!=e.getExtension(t)}function L(e){try{if(null!=i(e))return!0}catch(e){return!1}return!1}function M(e){if(0===e)return!1;const t=i(e);if(1!==e){if(D(t,"EXT_color_buffer_float"))return P(t);const e="EXT_color_buffer_half_float";if(D(t,e)){const n=t.getExtension(e);return function(e,t){const n=f(e,t),r=e.createTexture();e.bindTexture(e.TEXTURE_2D,r);const a=1,o=1;e.texImage2D(e.TEXTURE_2D,0,n.internalFormatHalfFloat,a,o,0,n.textureFormatFloat,n.textureTypeHalfFloat,null);const s=e.createFramebuffer();e.bindFramebuffer(e.FRAMEBUFFER,s),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,r,0);const i=e.checkFramebufferStatus(e.FRAMEBUFFER)===e.FRAMEBUFFER_COMPLETE;return e.bindTexture(e.TEXTURE_2D,null),e.bindFramebuffer(e.FRAMEBUFFER,null),e.deleteTexture(r),e.deleteFramebuffer(s),i}(t,n)}return!1}if(!D(t,"OES_texture_float"))return!1;if(!D(t,"WEBGL_color_buffer_float"))return!1;return P(t)}function P(e){const t=f(e),n=e.createTexture();e.bindTexture(e.TEXTURE_2D,n);e.texImage2D(e.TEXTURE_2D,0,t.internalFormatFloat,1,1,0,t.textureFormatFloat,t.textureTypeFloat,null);const r=e.createFramebuffer();e.bindFramebuffer(e.FRAMEBUFFER,r),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,n,0);const a=e.checkFramebufferStatus(e.FRAMEBUFFER)===e.FRAMEBUFFER_COMPLETE;return e.bindTexture(e.TEXTURE_2D,null),e.bindFramebuffer(e.FRAMEBUFFER,null),e.deleteTexture(n),e.deleteFramebuffer(r),a}function B(e,t){Array.isArray(e)||(e=[e]),e.forEach(e=>{null!=e&&a.ZSL.assert("complex64"!==e.dtype,()=>`${t} does not support complex64 tensors in the WebGL backend.`)})}const V=(0,a._K2)();function z(){let e,t,n,r,o,s,i,u,c,l;return 2===(0,a._K2)().getNumber("WEBGL_VERSION")?(e="#version 300 es",t="in",n="out",r="in",o="texture",s="outputColor",i="out vec4 outputColor;",u=(0,a._K2)().getBool("WEBGL2_ISNAN_CUSTOM")?"\n bool isnan_custom(float val) {\n uint floatToUint = floatBitsToUint(val);\n return (floatToUint & 0x7fffffffu) > 0x7f800000u;\n }\n\n bvec4 isnan_custom(vec4 val) {\n return bvec4(isnan_custom(val.x),\n isnan_custom(val.y), isnan_custom(val.z), isnan_custom(val.w));\n }\n\n #define isnan(value) isnan_custom(value)\n ":"",c="",l="\n #define round(value) newRound(value)\n int newRound(float value) {\n return int(floor(value + 0.5));\n }\n\n ivec4 newRound(vec4 value) {\n return ivec4(floor(value + vec4(0.5)));\n }\n "):(e="",t="attribute",n="varying",r="varying",o="texture2D",s="gl_FragColor",i="",u="\n #define isnan(value) isnan_custom(value)\n bool isnan_custom(float val) {\n return (val > 0. || val < 1. || val == 0.) ? false : true;\n }\n bvec4 isnan_custom(vec4 val) {\n return bvec4(isnan(val.x), isnan(val.y), isnan(val.z), isnan(val.w));\n }\n ",c="\n uniform float INFINITY;\n\n bool isinf(float val) {\n return abs(val) == INFINITY;\n }\n bvec4 isinf(vec4 val) {\n return equal(abs(val), vec4(INFINITY));\n }\n ",l="\n int round(float value) {\n return int(floor(value + 0.5));\n }\n\n ivec4 round(vec4 value) {\n return ivec4(floor(value + vec4(0.5)));\n }\n "),{version:e,attribute:t,varyingVs:n,varyingFs:r,texture2D:o,output:s,defineOutput:i,defineSpecialNaN:u,defineSpecialInf:c,defineRound:l}}function U(e,t,n="index"){const r=a.ZSL.computeStrides(t);return r.map((t,a)=>`${`int ${e[a]} = ${n} / ${t}`}; ${a===r.length-1?`int ${e[a+1]} = ${n} - ${e[a]} * ${t}`:`index -= ${e[a]} * ${t}`};`).join("")}function W(e,t,n="index"){const r=a.ZSL.computeStrides(t);return r.map((t,a)=>`${`int ${e[a]} = ${n} / outShapeStrides[${a}]`}; ${a===r.length-1?`int ${e[a+1]} = ${n} - ${e[a]} * outShapeStrides[${a}]`:`index -= ${e[a]} * outShapeStrides[${a}]`};`).join("")}function G(e,t,n="index"){const r=function(e,t){const n=e.length,r=e.map(e=>`${t}[${e}]`),a=new Array(n-1);a[n-2]=r[n-1];for(let e=n-3;e>=0;--e)a[e]=`(${a[e+1]} * ${r[e+1]})`;return a}(e.map((e,t)=>t),t);return r.map((t,a)=>`${`int ${e[a]} = ${n} / ${r[a]}`}; ${a===r.length-1?`int ${e[a+1]} = ${n} - ${e[a]} * ${r[a]}`:`index -= ${e[a]} * ${r[a]}`};`).join("")}function j(e){const t=a.ZSL.computeStrides(e).map(e=>e.toString());return`\n int getFlatIndex(ivec3 coords) {\n return coords.x * ${t[0]} + coords.y * ${t[1]} + coords.z;\n }\n`}
2V.registerFlag("HAS_WEBGL",()=>V.getNumber("WEBGL_VERSION")>0),V.registerFlag("WEBGL_VERSION",()=>L(2)?2:L(1)?1:0),V.registerFlag("WEBGL_CHECK_NUMERICAL_PROBLEMS",()=>!1),V.registerFlag("WEBGL_BUFFER_SUPPORTED",()=>2===V.get("WEBGL_VERSION")),V.registerFlag("WEBGL_CPU_FORWARD",()=>!0),V.registerFlag("WEBGL_FORCE_F16_TEXTURES",()=>!1),V.registerFlag("WEBGL_PACK",()=>V.getBool("HAS_WEBGL")),V.registerFlag("WEBGL_PACK_NORMALIZATION",()=>V.getBool("WEBGL_PACK")),V.registerFlag("WEBGL_PACK_CLIP",()=>V.getBool("WEBGL_PACK")),V.registerFlag("WEBGL_PACK_DEPTHWISECONV",()=>V.getBool("WEBGL_PACK")),V.registerFlag("WEBGL_PACK_BINARY_OPERATIONS",()=>V.getBool("WEBGL_PACK")),V.registerFlag("WEBGL_PACK_UNARY_OPERATIONS",()=>V.getBool("WEBGL_PACK")),V.registerFlag("WEBGL_PACK_ARRAY_OPERATIONS",()=>V.getBool("WEBGL_PACK")),V.registerFlag("WEBGL_PACK_IMAGE_OPERATIONS",()=>V.getBool("WEBGL_PACK")),V.registerFlag("WEBGL_PACK_REDUCE",()=>V.getBool("WEBGL_PACK")),V.registerFlag("WEBGL_LAZILY_UNPACK",()=>V.getBool("WEBGL_PACK")),V.registerFlag("WEBGL_CONV_IM2COL",()=>V.getBool("WEBGL_PACK")),V.registerFlag("WEBGL_MAX_TEXTURE_SIZE",()=>function(e){if(null==O){const t=i(e);O=t.getParameter(t.MAX_TEXTURE_SIZE)}return O}(V.getNumber("WEBGL_VERSION"))),V.registerFlag("WEBGL_MAX_TEXTURES_IN_SHADER",()=>function(e){if(null==F){const t=i(e);F=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS)}return Math.min(16,F)}(V.getNumber("WEBGL_VERSION"))),V.registerFlag("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION",()=>{const e=V.getNumber("WEBGL_VERSION");return 0===e?0:function(e){if(0===e)return 0;let t;const n=i(e);return t=D(n,"EXT_disjoint_timer_query_webgl2")&&2===e?2:D(n,"EXT_disjoint_timer_query")?1:0,t}(e)}),V.registerFlag("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE",()=>V.getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")>0&&!a.eMq.isMobile()),V.registerFlag("WEBGL_RENDER_FLOAT32_CAPABLE",()=>function(e){if(0===e)return!1;const t=i(e);if(1===e){if(!D(t,"OES_texture_float"))return!1}else if(!D(t,"EXT_color_buffer_float"))return!1;return P(t)}(V.getNumber("WEBGL_VERSION"))),V.registerFlag("WEBGL_RENDER_FLOAT32_ENABLED",()=>!V.getBool("WEBGL_FORCE_F16_TEXTURES")&&V.getBool("WEBGL_RENDER_FLOAT32_CAPABLE")),V.registerFlag("WEBGL_DOWNLOAD_FLOAT_ENABLED",()=>M(V.getNumber("WEBGL_VERSION"))),V.registerFlag("WEBGL_FENCE_API_ENABLED",()=>{return 2===(e=V.getNumber("WEBGL_VERSION"))&&null!=i(e).fenceSync;var e}),V.registerFlag("WEBGL_SIZE_UPLOAD_UNIFORM",()=>V.getBool("WEBGL_RENDER_FLOAT32_ENABLED")?4:0),V.registerFlag("WEBGL_DELETE_TEXTURE_THRESHOLD",()=>-1,e=>{if(e<0&&-1!==e)throw new Error(`WEBGL_DELETE_TEXTURE_THRESHOLD must be -1 (indicating never delete) or at least 0, but got ${e}.`)}),V.registerFlag("WEBGL_FLUSH_THRESHOLD",()=>a.eMq.isMobile()?1:-1,e=>{if(e<0&&-1!==e)throw new Error(`WEBGL_FLUSH_THRESHOLD must be -1 (indicating never manual flush) or at least 0, but got ${e}.`)}),V.registerFlag("CPU_HANDOFF_SIZE_THRESHOLD",()=>128),V.registerFlag("WEBGL_USE_SHAPES_UNIFORMS",()=>!1),V.registerFlag("TOPK_LAST_DIM_CPU_HANDOFF_SIZE_THRESHOLD",()=>1e5),V.registerFlag("TOPK_K_CPU_HANDOFF_THRESHOLD",()=>128),V.registerFlag("WEBGL_EXP_CONV",()=>!1),V.registerFlag("SOFTWARE_WEBGL_ENABLED",()=>V.getBool("IS_TEST")),V.registerFlag("WEBGL_MAX_SIZE_FOR_NARROW_TEXTURE",()=>1/0),V.registerFlag("WEBGL_AUTO_SQUARIFY_NARROW_TEXTURE_SHAPE",()=>!1),V.registerFlag("WEBGL2_ISNAN_CUSTOM",()=>!1);const K="\n const float FLOAT_MAX = 1.70141184e38;\n const float FLOAT_MIN = 1.17549435e-38;\n\n lowp vec4 encode_float(highp float v) {\n if (isnan(v)) {\n return vec4(255, 255, 255, 255);\n }\n\n highp float av = abs(v);\n\n if(av < FLOAT_MIN) {\n return vec4(0.0, 0.0, 0.0, 0.0);\n } else if(v > FLOAT_MAX) {\n return vec4(0.0, 0.0, 128.0, 127.0) / 255.0;\n } else if(v < -FLOAT_MAX) {\n return vec4(0.0, 0.0, 128.0, 255.0) / 255.0;\n }\n\n highp vec4 c = vec4(0,0,0,0);\n\n highp float e = floor(log2(av));\n highp float m = exp2(fract(log2(av))) - 1.0;\n\n c[2] = floor(128.0 * m);\n m -= c[2] / 128.0;\n c[1] = floor(32768.0 * m);\n m -= c[1] / 32768.0;\n c[0] = floor(8388608.0 * m);\n\n highp float ebias = e + 127.0;\n c[3] = floor(ebias / 2.0);\n ebias -= c[3] * 2.0;\n c[2] += floor(ebias) * 128.0;\n\n c[3] += 128.0 * step(0.0, -v);\n\n return c / 255.0;\n }\n",{getBroadcastDims:H}=a.C0T;function Y(e,t,n){const r=[];
vendor: 1,038 bytes, line 2
2if(e.forEach(e=>{const t=a.ZSL.sizeFromShape(e.shapeInfo.logicalShape);if(e.shapeInfo.isUniform?r.push(`uniform float ${e.name}${t>1?`[${t}]`:""};`):(r.push(`uniform sampler2D ${e.name};`),r.push(`uniform int offset${e.name};`)),n.enableShapeUniforms){const{uniformShape:t}=oe(n.packedInputs,e.shapeInfo.logicalShape,e.shapeInfo.texShape);switch(t.length){case 1:r.push(`uniform int ${e.name}Shape;`);break;case 2:r.push(`uniform ivec2 ${e.name}Shape;`);break;case 3:r.push(`uniform ivec3 ${e.name}Shape;`);break;case 4:r.push(`uniform ivec4 ${e.name}Shape;`)}r.push(`uniform ivec2 ${e.name}TexShape;`)}}),n.enableShapeUniforms){switch(t.logicalShape.length){case 1:r.push("uniform int outShape;");break;case 2:r.push("uniform ivec2 outShape;"),r.push("uniform int outShapeStrides;");break;case 3:r.push("uniform ivec3 outShape;"),r.push("uniform ivec2 outShapeStrides;");break;case 4:r.push("uniform ivec4 outShape;"),r.push("uniform ivec3 outShapeStrides;")}r.push("uniform ivec2 outTexShape;")}n.customUniforms&&n.customUniforms.forEac
2h(e=>{r.push(`uniform ${e.type} ${e.name}${e.arrayIndex?`[${e.arrayIndex}]`:""};`)});const o=r.join("\n"),s=e.map(e=>function(e,t,n=!1,r){let o="";o+=n?X(e,r):Z(e,r);const s=e.shapeInfo.logicalShape,i=t.logicalShape;s.length<=i.length&&(o+=n?function(e,t){const n=e.name,r=n.charAt(0).toUpperCase()+n.slice(1),o="get"+r+"AtOutCoords",s=e.shapeInfo.logicalShape.length,i=t.logicalShape.length,u=H(e.shapeInfo.logicalShape,t.logicalShape),c=ae(i),l=i-s;let p;const h=["x","y","z","w","u","v"];p=0===s?"":i<2&&u.length>=1?"coords = 0;":u.map(e=>`coords.${h[e+l]} = 0;`).join("\n");let d="";d=i<2&&s>0?"coords":e.shapeInfo.logicalShape.map((e,t)=>`coords.${h[t+l]}`).join(", ");let f="return outputValue;";const m=1===a.ZSL.sizeFromShape(e.shapeInfo.logicalShape),g=a.ZSL.sizeFromShape(t.logicalShape),y=1===g;if(1!==s||m||y){if(m&&!y)f=1===i?"\n return vec4(outputValue.x, outputValue.x, 0., 0.);\n ":"\n return vec4(outputValue.x);\n ";else if(u.length){const e=s-2,t=s-1;u.indexOf(e)>-1&&u.indexOf(t)>-1?f="return vec4(outputValue.x);":u.indexOf(e)>-1?f="return vec4(outputValue.x, outputValue.y, outputValue.x, outputValue.y);":u.indexOf(t)>-1&&(f="return vec4(outputValue.xx, outputValue.zz);")}}else f="\n return vec4(outputValue.xy, outputValue.xy);\n ";return`\n vec4 ${o}() {\n ${c} coords = getOutputCoords();\n ${p}\n vec4 outputValue = get${r}(${d});\n ${f}\n }\n `}(e,t):function(e,t){const n=e.name,r=n.charAt(0).toUpperCase()+n.slice(1),o="get"+r+"AtOutCoords",s=t.texShape,i=e.shapeInfo.texShape,u=e.shapeInfo.logicalShape.length,c=t.logicalShape.length;if(!e.shapeInfo.isUniform&&u===c&&null==e.shapeInfo.flatOffset&&a.ZSL.arraysEqual(i,s))return`\n float ${o}() {\n return sampleTexture(${n}, resultUV);\n }\n `;const l=ae(c),p=H(e.shapeInfo.logicalShape,t.logicalShape),h=c-u;let d;const f=["x","y","z","w","u","v"];d=0===u?"":c<2&&p.length>=1?"coords = 0;":p.map(e=>`coords.${f[e+h]} = 0;`).join("\n");let m="";m=c<2&&u>0?"coords":e.shapeInfo.logicalShape.map((e,t)=>`coords.${f[t+h]}`).join(", ");return`\n float ${o}() {\n ${l} coords = getOutputCoords();\n ${d}\n return get${r}(${m});\n }\n `}(e,t));return o}(e,t,n.packedInputs,n.enableShapeUniforms)).join("\n"),i=t.texShape,u=z(),c=function(e){return`\n float sampleTexture(sampler2D textureSampler, vec2 uv) {\n return ${e.texture2D}(textureSampler, uv).r;\n }\n `}(u);let l,p,h=function(e){const t=`${e.version}\n precision highp float;\n precision highp int;\n precision highp sampler2D;\n ${e.varyingFs} vec2 resultUV;\n ${e.defineOutput}\n const vec2 halfCR = vec2(0.5, 0.5);\n\n struct ivec5\n {\n int x;\n int y;\n int z;\n int w;\n int u;\n };\n\n struct ivec6\n {\n int x;\n int y;\n int z;\n int w;\n int u;\n int v;\n };\n\n uniform float NAN;\n ${e.defineSpecialNaN}\n ${e.defineSpecialInf}\n ${e.defineRound}\n\n int imod(int x, int y) {\n return x - y * (x / y);\n }\n\n int idiv(int a, int b, float sign) {\n int res = a / b;\n int mod = imod(a, b);\n if (sign < 0. && mod != 0) {\n res -= 1;\n }\n return res;\n }\n\n //Based on the work of Dave Hoskins\n //https://www.shadertoy.com/view/4djSRW\n #define HASHSCALE1 443.8975\n float random(float seed){\n vec2 p = resultUV * seed;\n vec3 p3 = fract(vec3(p.xyx) * HASHSCALE1);\n p3 += dot(p3, p3.yzx + 19.19);\n return fract((p3.x + p3.y) * p3.z);\n }\n\n ${q}\n ${Q}\n ${J}\n `;return t}(u);t.isPacked?(l=function(e,t,n){switch(e.length){case 0:return te();case 1:return function(e,t,n){const r=[Math.ceil(t[0]/2),Math.ceil(t[1]/2)];if(1===r[0])return n?"\n int getOutputCoords() {\n return 2 * int(resultUV.x * ceil(float(outTexShape[1]) / 2.0));\n }\n ":`\n int getOutputCoords() {\n return 2 * int(resultUV.x * ${r[1]}.0);\n }\n `;if(1===r[1])return n?"\n int getOutputCoords() {\n return 2 * int(resultUV.y * ceil(float(outTexShape[0]) / 2.0));\n }\n ":`\n int getOutputCoords() {\n return 2 * int(resultUV.y * ${r[0]}.0);\n }\n `;if(n)return"\n int getOutputCoords() {\n ivec2 packedTexShape = ivec2(ceil(float(outTexShape[0]) / 2.0), ceil(float(outTexShape[1]) / 2.0));
2\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(packedTexShape[0], packedTexShape[1]));\n return 2 * (resTexRC.x * packedTexShape[1] + resTexRC.y);\n }\n ";return`\n int getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(${r[0]}, ${r[1]}));\n return 2 * (resTexRC.x * ${r[1]} + resTexRC.y);\n }\n `}(0,t,n);case 2:return function(e,t,n){const r=[Math.ceil(t[0]/2),Math.ceil(t[1]/2)];if(a.ZSL.arraysEqual(e,t))return n?"\n ivec2 getOutputCoords() {\n ivec2 packedTexShape = ivec2(ceil(float(outTexShape[0]) / 2.0), ceil(float(outTexShape[1]) / 2.0));\n return 2 * ivec2(resultUV.yx * vec2(packedTexShape[0], packedTexShape[1]));\n }\n ":`\n ivec2 getOutputCoords() {\n return 2 * ivec2(resultUV.yx * vec2(${r[0]}, ${r[1]}));\n }\n `;const o=Math.ceil(e[1]/2);if(n)return"\n ivec2 getOutputCoords() {\n ivec2 packedTexShape = ivec2(ceil(float(outTexShape[0]) / 2.0), ceil(float(outTexShape[1]) / 2.0));\n int texelsInLogicalRow = int(ceil(float(outShape[1]) / 2.0));\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(packedTexShape[0], packedTexShape[1]));\n\n int index = resTexRC.x * packedTexShape[1] + resTexRC.y;\n int r = 2 * (index / texelsInLogicalRow);\n int c = imod(index, texelsInLogicalRow) * 2;\n\n return ivec2(r, c);\n }\n ";return`\n ivec2 getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(${r[0]}, ${r[1]}));\n\n int index = resTexRC.x * ${r[1]} + resTexRC.y;\n int r = 2 * (index / ${o});\n int c = imod(index, ${o}) * 2;\n\n return ivec2(r, c);\n }\n `}(e,t,n);case 3:return function(e,t,n){if(n)return"\n ivec3 getOutputCoords() {\n ivec2 packedTexShape = ivec2(ceil(float(outTexShape[0]) / 2.0), ceil(float(outTexShape[1]) / 2.0));\n int texelsInLogicalRow = int(ceil(float(outShape[2]) / 2.0));\n int texelsInBatch = texelsInLogicalRow * int(ceil(float(outShape[1]) / 2.0));\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(packedTexShape[0], packedTexShape[1]));\n int index = resTexRC.x * packedTexShape[1] + resTexRC.y;\n\n int b = index / texelsInBatch;\n index -= b * texelsInBatch;\n\n int r = 2 * (index / texelsInLogicalRow);\n int c = imod(index, texelsInLogicalRow) * 2;\n\n return ivec3(b, r, c);\n }\n ";const r=[Math.ceil(t[0]/2),Math.ceil(t[1]/2)],a=Math.ceil(e[2]/2),o=a*Math.ceil(e[1]/2);return`\n ivec3 getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(${r[0]}, ${r[1]}));\n int index = resTexRC.x * ${r[1]} + resTexRC.y;\n\n int b = index / ${o};\n index -= b * ${o};\n\n int r = 2 * (index / ${a});\n int c = imod(index, ${a}) * 2;\n\n return ivec3(b, r, c);\n }\n `}(e,t,n);default:return function(e,t,n){if(n)return"\n ivec4 getOutputCoords() {\n ivec2 packedTexShape = ivec2(ceil(float(outTexShape[0]) / 2.0), ceil(float(outTexShape[1]) / 2.0));\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(packedTexShape[0], packedTexShape[1]));\n int index = resTexRC.x * packedTexShape[1] + resTexRC.y;\n\n int texelsInLogicalRow = int(ceil(float(outShape[3]) / 2.0));\n int texelsInBatch = texelsInLogicalRow * int(ceil(float(outShape[2]) / 2.0));\n int texelsInBatchN = texelsInBatch * outShape[1];\n\n int b2 = index / texelsInBatchN;\n index -= b2 * texelsInBatchN;\n\n int b = index / texelsInBatch;\n index -= b * texelsInBatch;\n\n int r = 2 * (index / texelsInLogicalRow);\n int c = imod(index, texelsInLogicalRow) * 2;\n\n return ivec4(b2, b, r, c);\n }\n ";const r=[Math.ceil(t[0]/2),Math.ceil(t[1]/2)],a=Math.ceil(e[e.length-1]/2),o=a*Math.ceil(e[e.length-2]/2);let s=o,i="",u="b, r, c";for(let t=2;t<e.length-1;t++)s*=e[e.length-t-1],i=`\n int b${t} = index / ${s};\n index -= b${t} * ${s};\n `+i,u=`b${t}, `+u;return`\n ivec${e.length}
2 getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(${r[0]}, ${r[1]}));\n int index = resTexRC.x * ${r[1]} + resTexRC.y;\n\n ${i}\n\n int b = index / ${o};\n index -= b * ${o};\n\n int r = 2 * (index / ${a});\n int c = imod(index, ${a}) * 2;\n\n return ivec${e.length}(${u});\n }\n `}(e,t,n)}}(t.logicalShape,i,n.enableShapeUniforms),p=function(e){return`\n void setOutput(vec4 val) {\n ${e.output} = val;\n }\n `}(u)):(l=function(e,t,n){switch(e.length){case 0:return te();case 1:return function(e,t,n){if(1===t[0])return n?"\n int getOutputCoords() {\n return int(resultUV.x * float(outTexShape[1]));\n }\n ":`\n int getOutputCoords() {\n return int(resultUV.x * ${t[1]}.0);\n }\n `;if(1===t[1])return n?"\n int getOutputCoords() {\n return int(resultUV.y * float(outTexShape[0]));\n }\n ":`\n int getOutputCoords() {\n return int(resultUV.y * ${t[0]}.0);\n }\n `;if(n)return"\n int getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(outTexShape[0], outTexShape[1]));\n return resTexRC.x * outTexShape[1] + resTexRC.y;\n }\n ";return`\n int getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(${t[0]}, ${t[1]}));\n return resTexRC.x * ${t[1]} + resTexRC.y;\n }\n `}(0,t,n);case 2:return function(e,t,n){if(a.ZSL.arraysEqual(e,t))return n?"\n ivec2 getOutputCoords() {\n return ivec2(resultUV.yx * vec2(outTexShape[0], outTexShape[1]));\n }\n ":`\n ivec2 getOutputCoords() {\n return ivec2(resultUV.yx * vec2(${t[0]}, ${t[1]}));\n }\n `;if(1===e[1])return n?"\n ivec2 getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(outTexShape[0], outTexShape[1]));\n int index = resTexRC.x * outTexShape[1] + resTexRC.y;\n return ivec2(index, 0);\n }\n ":`\n ivec2 getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(${t[0]}, ${t[1]}));\n int index = resTexRC.x * ${t[1]} + resTexRC.y;\n return ivec2(index, 0);\n }\n `;if(1===e[0])return n?"\n ivec2 getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(outTexShape[0], outTexShape[1]));\n int index = resTexRC.x * outTexShape[1] + resTexRC.y;\n return ivec2(0, index);\n }\n ":`\n ivec2 getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(${t[0]}, ${t[1]}));\n int index = resTexRC.x * ${t[1]} + resTexRC.y;\n return ivec2(0, index);\n }\n `;if(n)return"\n ivec2 getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(outTexShape[0], outTexShape[1]));\n int index = resTexRC.x * outTexShape[1] + resTexRC.y;\n int r = index / outShape[1];\n int c = index - r * outShape[1];\n return ivec2(r, c);\n }\n ";return`\n ivec2 getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(${t[0]}, ${t[1]}));\n int index = resTexRC.x * ${t[1]} + resTexRC.y;\n int r = index / ${e[1]};\n int c = index - r * ${e[1]};\n return ivec2(r, c);\n }\n `}(e,t,n);case 3:return function(e,t,n){if(n){return`\n ivec3 getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(outTexShape[0], outTexShape[1]));\n int index = resTexRC.x * outTexShape[1] + resTexRC.y;\n ${W(["r","c","d"],e)}\n return ivec3(r, c, d);\n }\n`}const r=U(["r","c","d"],e);return`\n ivec3 getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(${t[0]}, ${t[1]}));\n int index = resTexRC.x * ${t[1]} + resTexRC.y;\n ${r}\n return ivec3(r, c, d);\n }\n `}(e,t,n);case 4:return function(e,t,n){if(n){return`\n ivec4 getOutputCoords() {\n ivec2 resTexRC = ive
2c2(resultUV.yx *\n vec2(outTexShape[0], outTexShape[1]));\n int index = resTexRC.x * outTexShape[1] + resTexRC.y;\n ${W(["r","c","d","d2"],e)}\n return ivec4(r, c, d, d2);\n }\n `}const r=U(["r","c","d","d2"],e);return`\n ivec4 getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(${t[0]}, ${t[1]}));\n int index = resTexRC.x * ${t[1]} + resTexRC.y;\n ${r}\n return ivec4(r, c, d, d2);\n }\n `}(e,t,n);case 5:return function(e,t){const n=U(["r","c","d","d2","d3"],e);return`\n ivec5 getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx * vec2(${t[0]},\n ${t[1]}));\n\n int index = resTexRC.x * ${t[1]} + resTexRC.y;\n\n ${n}\n\n ivec5 outShape = ivec5(r, c, d, d2, d3);\n return outShape;\n }\n `}(e,t);case 6:return function(e,t){const n=U(["r","c","d","d2","d3","d4"],e);return`\n ivec6 getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(${t[0]}, ${t[1]}));\n int index = resTexRC.x * ${t[1]} + resTexRC.y;\n\n ${n}\n\n ivec6 result = ivec6(r, c, d, d2, d3, d4);\n return result;\n }\n `}(e,t);default:throw new Error(`${e.length}-D output sampling is not yet supported`)}}(t.logicalShape,i,n.enableShapeUniforms),p=function(e){return`\n void setOutput(float val) {\n ${e.output} = vec4(val, 0, 0, 0);\n }\n `}(u)),n.packedInputs&&(h+=ee);return[h,c,p,o,l,s,n.userCode].join("\n")}function Z(e,t=!1){const n=e.shapeInfo.logicalShape;switch(n.length){case 0:return function(e,t){const n=e.name,r="get"+n.charAt(0).toUpperCase()+n.slice(1);if(e.shapeInfo.isUniform)return`float ${r}() {return ${n};}`;const[a,o]=e.shapeInfo.texShape;if(1===a&&1===o)return`\n float ${r}() {\n return sampleTexture(${n}, halfCR);\n }\n `;const s=ne(n);if(t)return`\n float ${r}() {\n vec2 uv = uvFromFlat(${n}TexShape[0], ${n}TexShape[1], ${s});\n return sampleTexture(${n}, uv);\n }\n `;const[i,u]=e.shapeInfo.texShape;return`\n float ${r}() {\n vec2 uv = uvFromFlat(${i}, ${u}, ${s});\n return sampleTexture(${n}, uv);\n }\n `}(e,t);case 1:return function(e,t){const n=e.name,r="get"+n.charAt(0).toUpperCase()+n.slice(1);if(e.shapeInfo.isUniform)return`\n float ${r}(int index) {\n ${re(e)}\n }\n `;const a=e.shapeInfo.texShape,o=a[0],s=a[1];if(1===s&&1===o)return`\n float ${r}(int index) {\n return sampleTexture(${n}, halfCR);\n }\n `;const i=ne(n);if(1===s)return t?`\n float ${r}(int index) {\n vec2 uv = vec2(0.5, (float(index + ${i}) + 0.5) / float(${n}TexShape[0]));\n return sampleTexture(${n}, uv);\n }\n `:`\n float ${r}(int index) {\n vec2 uv = vec2(0.5, (float(index + ${i}) + 0.5) / ${o}.0);\n return sampleTexture(${n}, uv);\n }\n `;if(1===o)return t?`\n float ${r}(int index) {\n vec2 uv = vec2((float(index + ${i}) + 0.5) / float(${n}TexShape[1]), 0.5);\n return sampleTexture(${n}, uv);\n }\n `:`\n float ${r}(int index) {\n vec2 uv = vec2((float(index + ${i}) + 0.5) / ${s}.0, 0.5);\n return sampleTexture(${n}, uv);\n }\n `;if(t)return`\n float ${r}(int index) {\n vec2 uv = uvFromFlat(${n}TexShape[0], ${n}TexShape[1], index + ${i});\n return sampleTexture(${n}, uv);\n }\n `;return`\n float ${r}(int index) {\n vec2 uv = uvFromFlat(${o}, ${s}, index + ${i});\n return sampleTexture(${n}, uv);\n }\n `}(e,t);case 2:return function(e,t){const n=e.shapeInfo.logicalShape,r=e.name,o="get"+r.charAt(0).toUpperCase()+r.slice(1),s=e.shapeInfo.texShape;if(null!=s&&a.ZSL.arraysEqual(n,s)){if(t)return`\n float ${o}(int row, int col) {\n vec2 uv = (vec2(col, row) + halfCR) / vec2(${r}TexShape[1], ${r}TexShape[0]);\n return sampleTexture(${r}, uv);\n }\n `;const e=s[0];return`\n float ${o}(int row, int col) {\n vec2 uv = (vec2(col, row) + halfCR) / vec2(${s[1]}.0, ${e}.0);\n return sampleTexture(${r}, uv);\n }\n `}const{newShape:i,keptDims:u}=a.ZSL.squeezeShape(n),c=i;
vendor: 4,352 bytes, line 2
2if(c.length<n.length){const n=["row","col"];return`\n ${Z(se(e,c),t)}\n float ${o}(int row, int col) {\n return ${o}(${ie(n,u)});\n }\n `}if(e.shapeInfo.isUniform)return`\n float ${o}(int row, int col) {\n int index = round(dot(vec2(row, col), vec2(${n[1]}, 1)));\n ${re(e)}\n }\n `;const l=s[0],p=s[1],h=ne(r);if(1===p)return t?`\n float ${o}(int row, int col) {\n float index = dot(vec3(row, col, ${h}), vec3(${r}Shape[1], 1, 1));\n vec2 uv = vec2(0.5, (index + 0.5) / float(${r}TexShape[0]));\n return sampleTexture(${r}, uv);\n }\n `:`\n float ${o}(int row, int col) {\n float index = dot(vec3(row, col, ${h}), vec3(${n[1]}, 1, 1));\n vec2 uv = vec2(0.5, (index + 0.5) / ${l}.0);\n return sampleTexture(${r}, uv);\n }\n `;if(1===l)return t?`\n float ${o}(int row, int col) {\n float index = dot(vec3(row, col, ${h}), vec3(${r}Shape[1], 1, 1));\n vec2 uv = vec2((index + 0.5) / float(${r}TexShape[1]), 0.5);\n return sampleTexture(${r}, uv);\n }\n `:`\n float ${o}(int row, int col) {\n float index = dot(vec3(row, col, ${h}), vec3(${n[1]}, 1, 1));\n vec2 uv = vec2((index + 0.5) / ${p}.0, 0.5);\n return sampleTexture(${r}, uv);\n }\n `;if(t)return`\n float ${o}(int row, int col) {\n // Explicitly use integer operations as dot() only works on floats.\n int index = row * ${r}Shape[1] + col + ${h};\n vec2 uv = uvFromFlat(${r}TexShape[0], ${r}TexShape[1], index);\n return sampleTexture(${r}, uv);\n }\n `;return`\n float ${o}(int row, int col) {\n // Explicitly use integer operations as dot() only works on floats.\n int index = row * ${n[1]} + col + ${h};\n vec2 uv = uvFromFlat(${l}, ${p}, index);\n return sampleTexture(${r}, uv);\n }\n`}(e,t);case 3:return function(e,t){const n=e.shapeInfo.logicalShape,r=e.name,o="get"+r.charAt(0).toUpperCase()+r.slice(1),s=n[1]*n[2],i=n[2],{newShape:u,keptDims:c}=a.ZSL.squeezeShape(n),l=u;if(l.length<n.length){const n=["row","col","depth"];return`\n ${Z(se(e,l),t)}\n float ${o}(int row, int col, int depth) {\n return ${o}(${ie(n,c)});\n }\n `}if(e.shapeInfo.isUniform)return`\n float ${o}(int row, int col, int depth) {\n int index = round(dot(vec3(row, col, depth),\n vec3(${s}, ${i}, 1)));\n ${re(e)}\n }\n `;const p=e.shapeInfo.texShape,h=p[0],d=p[1],f=e.shapeInfo.flatOffset;if(d===s&&null==f)return t?`\n float ${o}(int row, int col, int depth) {\n int stride1 = ${r}Shape[2];\n float texR = float(row);\n float texC = dot(vec2(col, depth), vec2(stride1, 1));\n vec2 uv = (vec2(texC, texR) + halfCR) /\n vec2(${r}TexShape[1], ${r}TexShape[0]);\n return sampleTexture(${r}, uv);\n }\n `:`\n float ${o}(int row, int col, int depth) {\n float texR = float(row);\n float texC = dot(vec2(col, depth), vec2(${i}, 1));\n vec2 uv = (vec2(texC, texR) + halfCR) /\n vec2(${d}.0, ${h}.0);\n return sampleTexture(${r}, uv);\n }\n `;if(d===i&&null==f)return t?`\n float ${o}(int row, int col, int depth) {\n float texR = dot(vec2(row, col), vec2(${r}Shape[1], 1));\n float texC = float(depth);\n vec2 uv = (vec2(texC, texR) + halfCR) / vec2(${r}TexShape[1], ${r}TexShape[0]);\n return sampleTexture(${r}, uv);\n }\n `:`\n float ${o}(int row, int col, int depth) {\n float texR = dot(vec2(row, col), vec2(${n[1]}, 1));\n float texC = float(depth);\n vec2 uv = (vec2(texC, texR) + halfCR) / vec2(${d}.0, ${h}.0);\n return sampleTexture(${r}, uv);\n }\n `;const m=ne(r);if(t)return`\n float ${o}(int row, int col, int depth) {\n // Explicitly use integer operations as dot() only works on floats.\n int stride0 = ${r}Shape[1] * ${r}Shape[2];\n int stride1 = ${r}Shape[2];\n int index = row * stride0 + col * stride1 + depth + ${m};\n vec2 uv = uvFromFlat(${r}TexShape[0], ${r}TexShape[1], index);\n return sampleTexture(${r}, uv);\n }\n `;return`\n float ${o}(int row, int col, int depth) {\n // Explicitly use integer operations as dot() only w
2orks on floats.\n int index = row * ${s} + col * ${i} + depth + ${m};\n vec2 uv = uvFromFlat(${h}, ${d}, index);\n return sampleTexture(${r}, uv);\n }\n `}(e,t);case 4:return function(e,t){const n=e.shapeInfo.logicalShape,r=e.name,o="get"+r.charAt(0).toUpperCase()+r.slice(1),s=n[3],i=n[2]*s,u=n[1]*i,{newShape:c,keptDims:l}=a.ZSL.squeezeShape(n);if(c.length<n.length){const n=["row","col","depth","depth2"];return`\n ${Z(se(e,c),t)}\n float ${o}(int row, int col, int depth, int depth2) {\n return ${o}(${ie(n,l)});\n }\n `}if(e.shapeInfo.isUniform)return`\n float ${o}(int row, int col, int depth, int depth2) {\n int index = round(dot(vec4(row, col, depth, depth2),\n vec4(${u}, ${i}, ${s}, 1)));\n ${re(e)}\n }\n `;const p=e.shapeInfo.flatOffset,h=e.shapeInfo.texShape,d=h[0],f=h[1],m=`int stride2 = ${r}Shape[3];`,g=`int stride1 = ${r}Shape[2] * stride2;`,y=`int stride0 = ${r}Shape[1] * stride1;`;if(f===u&&null==p)return t?`\n float ${o}(int row, int col, int depth, int depth2) {\n ${m}\n ${g}\n float texR = float(row);\n float texC =\n dot(vec3(col, depth, depth2),\n vec3(stride1, stride2, 1));\n vec2 uv = (vec2(texC, texR) + halfCR) /\n vec2(${r}TexShape[1], ${r}TexShape[0]);\n return sampleTexture(${r}, uv);\n }\n `:`\n float ${o}(int row, int col, int depth, int depth2) {\n float texR = float(row);\n float texC =\n dot(vec3(col, depth, depth2),\n vec3(${i}, ${s}, 1));\n vec2 uv = (vec2(texC, texR) + halfCR) /\n vec2(${f}.0, ${d}.0);\n return sampleTexture(${r}, uv);\n }\n `;if(f===s&&null==p)return t?`\n float ${o}(int row, int col, int depth, int depth2) {\n float texR = dot(vec3(row, col, depth),\n vec3(${r}Shape[1] * ${r}Shape[2], ${r}Shape[2], 1));\n float texC = float(depth2);\n vec2 uv = (vec2(texC, texR) + halfCR) /\n vec2(${r}TexShape[1], ${r}TexShape[0]);\n return sampleTexture(${r}, uv);\n }\n `:`\n float ${o}(int row, int col, int depth, int depth2) {\n float texR = dot(vec3(row, col, depth),\n vec3(${n[1]*n[2]}, ${n[2]}, 1));\n float texC = float(depth2);\n vec2 uv = (vec2(texC, texR) + halfCR) /\n vec2(${f}.0, ${d}.0);\n return sampleTexture(${r}, uv);\n }\n `;const x=ne(r);if(t)return`\n float ${o}(int row, int col, int depth, int depth2) {\n // Explicitly use integer operations as dot() only works on floats.\n ${m}\n ${g}\n ${y}\n int index = row * stride0 + col * stride1 +\n depth * stride2 + depth2;\n vec2 uv = uvFromFlat(${r}TexShape[0], ${r}TexShape[1], index + ${x});\n return sampleTexture(${r}, uv);\n }\n `;return`\n float ${o}(int row, int col, int depth, int depth2) {\n // Explicitly use integer operations as dot() only works on floats.\n int index = row * ${u} + col * ${i} +\n depth * ${s} + depth2;\n vec2 uv = uvFromFlat(${d}, ${f}, index + ${x});\n return sampleTexture(${r}, uv);\n }\n `}(e,t);case 5:return function(e){const t=e.shapeInfo.logicalShape,n=e.name,r="get"+n.charAt(0).toUpperCase()+n.slice(1),o=t[4],s=t[3]*o,i=t[2]*s,u=t[1]*i,{newShape:c,keptDims:l}=a.ZSL.squeezeShape(t);if(c.length<t.length){const t=["row","col","depth","depth2","depth3"];return`\n ${Z(se(e,c))}\n float ${r}(int row, int col, int depth, int depth2, int depth3) {\n return ${r}(${ie(t,l)});\n }\n `}if(e.shapeInfo.isUniform)return`\n float ${r}(int row, int col, int depth, int depth2, int depth3) {\n float index = dot(\n vec4(row, col, depth, depth2),\n vec4(${u}, ${i}, ${s}, ${o})) +\n depth3;\n ${re(e)}\n }\n `;const p=e.shapeInfo.flatOffset,h=e.shapeInfo.texShape,d=h[0],f=h[1];if(f===u&&null==p)return`\n float ${r}(int row, int col, int depth, int depth2, int depth3) {\n int texR = row;\n float texC = dot(vec4(col, depth, depth2, depth3),\n vec4(${i}, ${s}, ${o}, 1));\n vec2 uv = (vec2(texC, texR) + halfCR) /\n vec2(${f}.0, ${d}.0);\n return sampleTexture(${n}, uv);\n }\n `;if(f===o&&null==p)return`\n float ${r}(int row, int col, int depth, int depth2, int depth3) {\n float texR = dot
2(\n vec4(row, col, depth, depth2),\n vec4(${t[1]*t[2]*t[3]},\n ${t[2]*t[3]}, ${t[3]}, 1));\n int texC = depth3;\n vec2 uv = (vec2(texC, texR) + halfCR) /\n vec2(${f}.0, ${d}.0);\n return sampleTexture(${n}, uv);\n }\n `;const m=ne(n);return`\n float ${r}(int row, int col, int depth, int depth2, int depth3) {\n // Explicitly use integer operations as dot() only works on floats.\n int index = row * ${u} + col * ${i} + depth * ${s} +\n depth2 * ${o} + depth3 + ${m};\n vec2 uv = uvFromFlat(${d}, ${f}, index);\n return sampleTexture(${n}, uv);\n }\n `}(e);case 6:return function(e){const t=e.shapeInfo.logicalShape,n=e.name,r="get"+n.charAt(0).toUpperCase()+n.slice(1),{newShape:o,keptDims:s}=a.ZSL.squeezeShape(t);if(o.length<t.length){const t=["row","col","depth","depth2","depth3","depth4"];return`\n ${Z(se(e,o))}\n float ${r}(int row, int col, int depth,\n int depth2, int depth3, int depth4) {\n return ${r}(${ie(t,s)});\n }\n `}const i=t[5],u=t[4]*i,c=t[3]*u,l=t[2]*c,p=t[1]*l;if(e.shapeInfo.isUniform)return`\n float ${r}(int row, int col, int depth,\n int depth2, int depth3, int depth4) {\n int index = round(dot(\n vec4(row, col, depth, depth2),\n vec4(${p}, ${l}, ${c}, ${u})) +\n dot(\n vec2(depth3, depth4),\n vec2(${i}, 1)));\n ${re(e)}\n }\n `;const h=e.shapeInfo.flatOffset,d=e.shapeInfo.texShape,f=d[0],m=d[1];if(m===p&&null==h)return`\n float ${r}(int row, int col, int depth,\n int depth2, int depth3, int depth4) {\n int texR = row;\n float texC = dot(vec4(col, depth, depth2, depth3),\n vec4(${l}, ${c}, ${u}, ${i})) +\n float(depth4);\n vec2 uv = (vec2(texC, texR) + halfCR) /\n vec2(${m}.0, ${f}.0);\n return sampleTexture(${n}, uv);\n }\n `;if(m===i&&null==h)return`\n float ${r}(int row, int col, int depth,\n int depth2, int depth3, int depth4) {\n float texR = dot(vec4(row, col, depth, depth2),\n vec4(${t[1]*t[2]*t[3]*t[4]},\n ${t[2]*t[3]*t[4]},\n ${t[3]*t[4]},\n ${t[4]})) + float(depth3);\n int texC = depth4;\n vec2 uv = (vec2(texC, texR) + halfCR) /\n vec2(${m}.0, ${f}.0);\n return sampleTexture(${n}, uv);\n }\n `;const g=ne(n);return`\n float ${r}(int row, int col, int depth,\n int depth2, int depth3, int depth4) {\n // Explicitly use integer operations as dot() only works on floats.\n int index = row * ${p} + col * ${l} + depth * ${c} +\n depth2 * ${u} + depth3 * ${i} + depth4 + ${g};\n vec2 uv = uvFromFlat(${f}, ${m}, index);\n return sampleTexture(${n}, uv);\n }\n `}(e);default:throw new Error(`${n.length}-D input sampling is not yet supported`)}}function X(e,t){switch(e.shapeInfo.logicalShape.length){case 0:return function(e){const t=e.name,n="get"+t.charAt(0).toUpperCase()+t.slice(1),r=z();return`\n vec4 ${n}() {\n return ${r.texture2D}(${t}, halfCR);\n }\n `}(e);case 1:return function(e,t){const n=e.name,r="get"+n.charAt(0).toUpperCase()+n.slice(1),a=e.shapeInfo.texShape,o=z();if(t)return`\n vec4 ${r}(int index) {\n ivec2 packedTexShape = ivec2(ceil(float(${n}TexShape[0]) / 2.0), ceil(float(${n}TexShape[1]) / 2.0));\n vec2 uv = packedUVfrom1D(\n packedTexShape[0], packedTexShape[1], index);\n return ${o.texture2D}(${n}, uv);\n }\n `;const s=[Math.ceil(a[0]/2),Math.ceil(a[1]/2)];return`\n vec4 ${r}(int index) {\n vec2 uv = packedUVfrom1D(\n ${s[0]}, ${s[1]}, index);\n return ${o.texture2D}(${n}, uv);\n }\n `}(e,t);case 2:return function(e,t){const n=e.shapeInfo.logicalShape,r=e.name,o="get"+r.charAt(0).toUpperCase()+r.slice(1),s=e.shapeInfo.texShape,i=s[0],u=s[1],c=z();if(null!=s&&a.ZSL.arraysEqual(n,s))return t?`\n vec4 ${o}(int row, int col) {\n vec2 uv = (vec2(col, row) + halfCR) / vec2(${r}TexShape[1], ${r}TexShape[0]);\n\n return ${c.texture2D}(${r}, uv);\n }\n `:`\n vec4 ${o}(int row, int col) {\n vec2 uv = (vec2(col, row) + halfCR) / vec2(${u}.0, ${i}.0);\n\n return ${c.texture2D}(${r}, uv);\n }\n `;if(t)return`\n vec4 ${o}(int row, int col) {\n ivec2 packedTexShape = ivec2(ceil(float(${r}TexShape[0]) / 2.0), ceil(float(${r}TexShape[1]) / 2.0));\n int valuesPerRow = int(ceil(float(${r}Shape[1]) / 2.0));\n vec2 uv = packedUVfrom2D(valuesPerRow, packedTexShape[0], packedTexShape[1], row, c
2ol);\n return ${c.texture2D}(${r}, uv);\n }\n `;const l=[Math.ceil(s[0]/2),Math.ceil(s[1]/2)],p=Math.ceil(n[1]/2);return`\n vec4 ${o}(int row, int col) {\n vec2 uv = packedUVfrom2D(${p}, ${l[0]}, ${l[1]}, row, col);\n return ${c.texture2D}(${r}, uv);\n }\n `}(e,t);case 3:return function(e,t){const n=e.shapeInfo.logicalShape,r=e.name,a="get"+r.charAt(0).toUpperCase()+r.slice(1),o=e.shapeInfo.texShape,s=[Math.ceil(o[0]/2),Math.ceil(o[1]/2)];if(1===n[0]){const r=[1,2],o=["b","row","col"];return`\n ${X(se(e,n.slice(1)),t)}\n vec4 ${a}(int b, int row, int col) {\n return ${a}(${ie(o,r)});\n }\n `}const i=z();if(t)return`\n vec4 ${a}(int b, int row, int col) {\n ivec2 packedTexShape = ivec2(ceil(float(${r}TexShape[0]) / 2.0), ceil(float(${r}TexShape[1]) / 2.0));\n int valuesPerRow = int(ceil(float(${r}Shape[2]) / 2.0));\n int texelsInBatch = valuesPerRow * int(ceil(float(${r}Shape[1]) / 2.0));\n vec2 uv = packedUVfrom3D(\n packedTexShape[0], packedTexShape[1], texelsInBatch, valuesPerRow, b, row, col);\n return ${i.texture2D}(${r}, uv);\n }\n `;const u=s[0],c=s[1],l=Math.ceil(n[2]/2),p=l*Math.ceil(n[1]/2);return`\n vec4 ${a}(int b, int row, int col) {\n vec2 uv = packedUVfrom3D(\n ${u}, ${c}, ${p}, ${l}, b, row, col);\n return ${i.texture2D}(${r}, uv);\n }\n `}(e,t);default:return function(e,t){const n=e.name,r="get"+n.charAt(0).toUpperCase()+n.slice(1),a=z();if(t)return`\n vec4 ${r}(int b2, int b, int row, int col) {\n int valuesPerRow = int(ceil(float(${n}Shape[3]) / 2.0));\n int texelsInBatch = valuesPerRow * int(ceil(float(${n}Shape[2]) / 2.0));\n int index = b * texelsInBatch + (row / 2) * valuesPerRow + (col / 2);\n texelsInBatch *= ${n}Shape[1];\n index = b2 * texelsInBatch + index;\n ivec2 packedTexShape = ivec2(ceil(float(${n}TexShape[0]) / 2.0), ceil(float(${n}TexShape[1]) / 2.0));\n int texR = index / packedTexShape[1];\n int texC = index - texR * packedTexShape[1];\n vec2 uv = (vec2(texC, texR) + halfCR) / vec2(packedTexShape[1], packedTexShape[0]); return ${a.texture2D}(${n}, uv);\n }\n `;const o=e.shapeInfo.logicalShape,s=o.length,i=e.shapeInfo.texShape,u=[Math.ceil(i[0]/2),Math.ceil(i[1]/2)],c=u[0],l=u[1],p=Math.ceil(o[s-1]/2);let h=p*Math.ceil(o[s-2]/2),d="int b, int row, int col",f=`b * ${h} + (row / 2) * ${p} + (col / 2)`;for(let e=2;e<s-1;e++)d=`int b${e}, `+d,h*=o[s-e-1],f=`b${e} * ${h} + `+f;return`\n vec4 ${r}(${d}) {\n int index = ${f};\n int texR = index / ${l};\n int texC = index - texR * ${l};\n vec2 uv = (vec2(texC, texR) + halfCR) / vec2(${l}, ${c});\n return ${a.texture2D}(${n}, uv);\n }\n `}(e,t)}}const q="\nvec2 uvFromFlat(int texNumR, int texNumC, int index) {\n int texR = index / texNumC;\n int texC = index - texR * texNumC;\n return (vec2(texC, texR) + halfCR) / vec2(texNumC, texNumR);\n}\nvec2 packedUVfrom1D(int texNumR, int texNumC, int index) {\n int texelIndex = index / 2;\n int texR = texelIndex / texNumC;\n int texC = texelIndex - texR * texNumC;\n return (vec2(texC, texR) + halfCR) / vec2(texNumC, texNumR);\n}\n",Q="\nvec2 packedUVfrom2D(int texelsInLogicalRow, int texNumR,\n int texNumC, int row, int col) {\n int texelIndex = (row / 2) * texelsInLogicalRow + (col / 2);\n int texR = texelIndex / texNumC;\n int texC = texelIndex - texR * texNumC;\n return (vec2(texC, texR) + halfCR) / vec2(texNumC, texNumR);\n}\n",J="\nvec2 packedUVfrom3D(int texNumR, int texNumC,\n int texelsInBatch, int texelsInLogicalRow, int b,\n int row, int col) {\n int index = b * texelsInBatch + (row / 2) * texelsInLogicalRow + (col / 2);\n int texR = index / texNumC;\n int texC = index - texR * texNumC;\n return (vec2(texC, texR) + halfCR) / vec2(texNumC, texNumR);\n}\n",ee="\n float getChannel(vec4 frag, vec2 innerDims) {\n vec2 modCoord = mod(innerDims, 2.);\n return modCoord.x == 0. ?\n (modCoord.y == 0. ? frag.r : frag.g) :\n (modCoord.y == 0. ? frag.b : frag.a);\n }\n float getChannel(vec4 frag, int dim) {\n float modCoord = mod(float(dim), 2.);\n return modCoord == 0. ? frag.r : frag.g;\n }\n";function te(){return"\n int getOutputCoords() {\n return 0;\n }\n "}function ne(e){return`offset${e}`}function re(e){const t=e.name,n=a.ZSL.sizeFromShape(e.shapeInfo.logicalShape);return n<2?`return ${t};`:`\n for (int i = 0; i < ${n};
2 i++) {\n if (i == index) {\n return ${t}[i];\n }\n }\n `}function ae(e){if(e<=1)return"int";if(2===e)return"ivec2";if(3===e)return"ivec3";if(4===e)return"ivec4";if(5===e)return"ivec5";if(6===e)return"ivec6";throw Error(`GPU for rank ${e} is not yet supported`)}function oe(e,t,n){const{newShape:r,keptDims:o}=a.ZSL.squeezeShape(t),s=t.length,i=e&&3===s&&1===t[0],u=i?t.slice(1):r,c=!e&&s>1&&!a.ZSL.arraysEqual(t,n)&&r.length<s||i;return{useSqueezeShape:c,uniformShape:c?u:t,keptDims:o}}function se(e,t){const n=JSON.parse(JSON.stringify(e));return n.shapeInfo.logicalShape=t,n}function ie(e,t){return t.map(t=>e[t]).join(", ")}function ue(e,t,n,r){const o=n.map((e,n)=>{const r={logicalShape:e.shape,texShape:e.isUniform?null:e.texData.texShape,isUniform:e.isUniform,isPacked:!e.isUniform&&e.texData.isPacked,flatOffset:null};return null!=e.texData&&null!=e.texData.slice&&e.texData.slice.flatOffset>0&&(r.flatOffset=e.texData.slice.flatOffset),{name:t.variableNames[n],shapeInfo:r}}),s=o.map(e=>e.shapeInfo),i={logicalShape:r.shape,texShape:r.texData.texShape,isUniform:!1,isPacked:r.texData.isPacked,flatOffset:null},u=Y(o,i,t),c=function(e,t){const n=E(e,()=>e.createShader(e.FRAGMENT_SHADER),"Unable to create fragment WebGLShader.");if(m(e,()=>e.shaderSource(n,t)),m(e,()=>e.compileShader(n)),(0,a._K2)().get("ENGINE_COMPILE_ONLY"))return n;if(!1===e.getShaderParameter(n,e.COMPILE_STATUS))throw b(t,e.getShaderInfoLog(n)),new Error("Failed to compile fragment shader.");return n}(e.gl,u),l=e.createProgram(c);return(0,a._K2)().get("ENGINE_COMPILE_ONLY")?{program:t,fragmentShader:c,source:u,webGLProgram:l,inShapeInfos:s,outShapeInfo:i,uniformLocations:null,customUniformLocations:null,infLoc:null,nanLoc:null,inShapesLocations:null,inTexShapesLocations:null,outShapeLocation:null,outShapeStridesLocation:null,outTexShapeLocation:null}:Object.assign({program:t,fragmentShader:c,source:u,webGLProgram:l,inShapeInfos:s,outShapeInfo:i},ce(e,t,l))}function ce(e,t,n){const r={},o={},s={},i=[];let u,c,l,p=null,h=null;h=e.getUniformLocation(n,"NAN",!1),1===(0,a._K2)().getNumber("WEBGL_VERSION")&&(p=e.getUniformLocation(n,"INFINITY",!1));const d=!1;for(let a=0;a<t.variableNames.length;a++){const i=t.variableNames[a];r[i]=e.getUniformLocation(n,i,d),r[`offset${i}`]=e.getUniformLocation(n,`offset${i}`,d),t.enableShapeUniforms&&(o[`${i}Shape`]=e.getUniformLocation(n,`${i}Shape`,d),s[`${i}TexShape`]=e.getUniformLocation(n,`${i}TexShape`,d))}return t.enableShapeUniforms&&(u=e.getUniformLocation(n,"outShape",d),l=e.getUniformLocation(n,"outShapeStrides",d),c=e.getUniformLocation(n,"outTexShape",d)),t.customUniforms&&t.customUniforms.forEac
2h((t,r)=>{i[r]=e.getUniformLocation(n,t.name,d)}),{uniformLocations:r,customUniformLocations:i,infLoc:p,nanLoc:h,inShapesLocations:o,inTexShapesLocations:s,outShapeLocation:u,outShapeStridesLocation:l,outTexShapeLocation:c}}function le(e,t){if(e.length!==t.length)throw Error(`Binary was compiled with ${e.length} inputs, but was executed with ${t.length} inputs`);e.forEach((e,n)=>{const r=e.logicalShape,o=t[n],s=o.shape;if(!a.ZSL.arraysEqual(r,s))throw Error(`Binary was compiled with different shapes than the current args. Shapes ${r} and ${s} must match`);if(e.isUniform&&o.isUniform)return;const i=e.texShape,u=o.isUniform?null:o.texData.texShape;if(!a.ZSL.arraysEqual(i,u))throw Error(`Binary was compiled with different texture shapes than the current args. Shape ${i} and ${u} must match`)})}function pe(e){return(0,a._K2)().getBool("WEBGL_USE_SHAPES_UNIFORMS")&&e<=4}class he{constructor(e){this.variableNames=["A"],this.packedInputs=!1,this.packedOutput=!0,this.outPackingScheme=u.DENSE,this.customUniforms=[{name:"texShape",type:"ivec2"}];const t=z();this.outputShape=e,this.enableShapeUniforms=pe(this.outputShape.length),this.userCode=`\n ivec3 outCoordsFromFlatIndex(int index) {\n ${this.enableShapeUniforms?W(["r","c","d"],e):U(["r","c","d"],e)}\n return ivec3(r, c, d);\n }\n\n void main() {\n ivec2 resTexRC = ivec2(resultUV.yx * vec2(texShape[0], texShape[1]));\n int index = 4 * (resTexRC.x * texShape[1] + resTexRC.y);\n\n vec4 result = vec4(0.);\n\n for (int i=0; i<4; i++) {\n int flatIndex = index + i;\n ivec3 rc = outCoordsFromFlatIndex(flatIndex);\n result[i] = getA(rc.x, rc.y, rc.z);\n }\n\n ${t.output} = result;\n }\n `}}class de{constructor(e){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outPackingScheme=u.DENSE,this.customUniforms=[{name:"texShape",type:"ivec2"}];const t=z();this.outputShape=e,this.enableShapeUniforms=pe(this.outputShape.length),this.userCode=`\n ivec3 outCoordsFromFlatIndex(int index) {\n ${this.enableShapeUniforms?W(["r","c","d"],e):U(["r","c","d"],e)}\n return ivec3(r, c, d);\n }\n\n void main() {\n ivec2 resTexRC = ivec2(resultUV.yx * vec2(texShape[0], texShape[1]));\n int index = 4 * (resTexRC.x * texShape[1] + resTexRC.y);\n\n vec4 result = vec4(0.);\n\n for (int i=0; i<4; i++) {\n int flatIndex = index + i;\n ivec3 rc = outCoordsFromFlatIndex(flatIndex);\n result[i] = getChannel(getA(rc.x, rc.y, rc.z), vec2(rc.y, rc.z));\n }\n\n ${t.output} = result;\n }\n `}}class fe{constructor(e){this.variableNames=["A"],this.outTexUsage=c.DOWNLOAD;const t=z();this.outputShape=e,this.userCode=`\n ${K}\n\n void main() {\n float x = getAAtOutCoords();\n ${t.output} = encode_float(x);\n }\n `}}class me{constructor(e){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!1,this.outTexUsage=c.DOWNLOAD;const t=z();this.outputShape=e,this.userCode=`\n ${K}\n\n void main() {\n ivec3 coords = getOutputCoords();\n float x = getChannel(getAAtOutCoords(), vec2(coords.y, coords.z));\n ${t.output} = encode_float(x);\n }\n `}}class ge{constructor(e,t=!1){this.variableNames=["A"],this.customUniforms=[{name:"texShape",type:"ivec2"}];const n=z();this.outputShape=e,this.enableShapeUniforms=pe(this.outputShape.length);let r="result";t&&(r="floor(result * 255. + 0.5)"),this.userCode=`\n ${this.enableShapeUniforms?"\n int getFlatIndex(ivec3 coords) {\n return coords.x * outShapeStrides[0] + coords.y * outShapeStrides[1] + coords.z;\n }\n":j(e)}\n\n void main() {\n ivec3 coords = getOutputCoords();\n\n int flatIndex = getFlatIndex(coords);\n int offset = imod(flatIndex, 4);\n\n flatIndex = idiv(flatIndex, 4, 1.);\n\n int r = flatIndex / texShape[1];\n int c = imod(flatIndex, texShape[1]);\n vec2 uv = (vec2(c, r) + halfCR) / vec2(texShape[1], texShape[0]);\n vec4 values = ${n.texture2D}(A, uv);\n\n float result;\n\n if(offset == 0) {\n result = values[0];\n } else if(offset == 1) {\n result = values[1];\n } else if(offset == 2) {\n result = values[2];\n } else {\n result = values[3];\n }\n\n ${n.output} = vec4(${r}, 0., 0., 0.);\n }\n `}}class ye{constructor(e,t=!1){this.variableNames=["A"],this.packedInputs=!1,this.packedOutput=!0,this.customUniforms=[{name:"texShape",type:"ivec2"}];const n=z();this.outputShape=e,this.enableShapeUniforms=pe(this.outputShape.length);let r="",a="result";t&&(a="floor(result * 255. + 0.5)");for(let t=0;t<=1;t++)for(let a=0;a<=1;a++){const o=2*t+a;r+=`\n localCoords = coords;\n if(localCoords[2] + ${a} < ${this.enableShapeUniforms?"outShape[2]":`${e[2]}`}
2) {\n localCoords[2] += ${a};\n if (localCoords[1] + ${t} < ${this.enableShapeUniforms?"outShape[1]":`${e[1]}`}) {\n localCoords[1] += ${t};\n\n flatIndex = getFlatIndex(localCoords);\n offset = imod(flatIndex, 4);\n\n flatIndex = idiv(flatIndex, 4, 1.);\n\n int r = flatIndex / texShape[1];\n int c = imod(flatIndex, texShape[1]);\n vec2 uv = (vec2(c, r) + halfCR) / vec2(texShape[1], texShape[0]);\n values = ${n.texture2D}(A, uv);\n\n if (offset == 0) {\n result[${o}] = values[0];\n } else if (offset == 1) {\n result[${o}] = values[1];\n } else if (offset == 2) {\n result[${o}] = values[2];\n } else {\n result[${o}] = values[3];\n }\n }\n }\n `}this.userCode=`\n ${this.enableShapeUniforms?"\n int getFlatIndex(ivec3 coords) {\n return coords.x * outShapeStrides[0] + coords.y * outShapeStrides[1] + coords.z;\n }\n":j(e)}\n\n void main() {\n ivec3 coords = getOutputCoords();\n\n vec4 result = vec4(0.);\n int flatIndex, r, c, offset;\n ivec3 localCoords;\n vec2 uv;\n vec4 values;\n\n ${r}\n\n ${n.output} = ${a};\n }\n `}}function xe(e){const t=z();return function(e,t){const n=E(e,()=>e.createShader(e.VERTEX_SHADER),"Unable to create vertex WebGLShader.");if(m(e,()=>e.shaderSource(n,t)),m(e,()=>e.compileShader(n)),!1===e.getShaderParameter(n,e.COMPILE_STATUS))throw new Error("Failed to compile vertex shader.");return n}(e,`${t.version}\n precision highp float;\n ${t.attribute} vec3 clipSpacePos;\n ${t.attribute} vec2 uv;\n ${t.varyingVs} vec2 resultUV;\n\n void main() {\n gl_Position = vec4(clipSpacePos, 1);\n resultUV = uv;\n }`)}function be(e){return function(e,t){const n=E(e,()=>e.createBuffer(),"Unable to create WebGLBuffer");return m(e,()=>e.bindBuffer(e.ARRAY_BUFFER,n)),m(e,()=>e.bufferData(e.ARRAY_BUFFER,t,e.STATIC_DRAW)),n}(e,new Float32Array([-1,1,0,0,1,-1,-1,0,0,0,1,1,0,1,1,1,-1,0,1,0]))}function ve(e){return function(e,t){const n=E(e,()=>e.createBuffer(),"Unable to create WebGLBuffer");return m(e,()=>e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,n)),m(e,()=>e.bufferData(e.ELEMENT_ARRAY_BUFFER,t,e.STATIC_DRAW)),n}(e,new Uint16Array([0,1,2,2,1,3]))}function we(e,t,n,r,o,s){!function(e,t){const n=(0,a._K2)().getNumber("WEBGL_MAX_TEXTURE_SIZE");if(e<=0||t<=0)throw new Error(`Requested texture size [${e}x${t}] is invalid.`);if(e>n||t>n)throw new Error(`Requested texture size [${e}x${t}] greater than WebGL maximum on this browser / GPU [${n}x${n}].`)}(t,n);const i=function(e){return E(e,()=>e.createTexture(),"Unable to create WebGLTexture.")}(e),u=e.TEXTURE_2D;return m(e,()=>e.bindTexture(u,i)),m(e,()=>e.texParameteri(u,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE)),m(e,()=>e.texParameteri(u,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE)),m(e,()=>e.texParameteri(u,e.TEXTURE_MIN_FILTER,e.NEAREST)),m(e,()=>e.texParameteri(u,e.TEXTURE_MAG_FILTER,e.NEAREST)),1===(0,a._K2)().getNumber("WEBGL_VERSION")?m(e,()=>e.texImage2D(u,0,r,t,n,0,o,s,null)):m(e,()=>e.texStorage2D(u,1,r,t,n)),m(e,()=>e.bindTexture(e.TEXTURE_2D,null)),{texture:i,texShape:[n,t]}}function Te(e){return e.internalFormatFloat}function Se(e){return e.internalFormatHalfFloat}function Ce(e){return e.downloadTextureFormat}function ke(e){return e.internalFormatPackedFloat}function Ee(e){return e.internalFormatPackedHalfFloat}function $e(e,t,n,r,a,o,s,i){const u=e,c=new Float32Array(function(e,t){const[n,r]=d(e,t);return n*r*4}(o,s));return u.bindBuffer(u.PIXEL_PACK_BUFFER,t),u.getBufferSubData(u.PIXEL_PACK_BUFFER,0,c),u.bindBuffer(u.PIXEL_PACK_BUFFER,null),c}class Ne{constructor(e){this.outputTexture=null,this.program=null,this.disposed=!1,this.vertexAttrsAreBound=!1,this.itemsToPoll=[];const t=(0,a._K2)().getNumber("WEBGL_VERSION");null!=e?(this.gl=e,function(e,t){o[e]=t}(t,e)):this.gl=i(t);let n="WEBGL_color_buffer_float";const r="EXT_color_buffer_half_float";if(this.parallelCompilationExtension=this.gl.getExtension("KHR_parallel_shader_compile"),1===(0,a._K2)().getNumber("WEBGL_VERSION")){const e="OES_texture_float",t="OES_texture_half_float";if(this.textureFloatExtension=y(this.gl,e),D(this.gl,t))this.textureHalfFloatExtension=y(this.gl,t);else if((0,a._K2)().get("WEBGL_FORCE_F16_TEXTURES"))throw new Error("GL context does not support half float textures, yet the environment flag WEBGL_FORCE_F16_TEXTURES is set to true.");if(this.colorBufferFloatExtension=this.gl.getExtension(n),D(this.gl,r))this.colorBufferHalfFloatExtension=y(this.gl,r);else if((0,a._K2)().get("WEBGL_FORCE_F16_TEXTURES"))throw new Error("GL context does not support color renderable half floats, yet the environment flag WEBGL_FORCE_F16_TEXTURES is set to true.")}else if(n="EXT_color_buffer_float",D(this.gl,n))this.colorBufferFloatExtension=this.gl.getExtension(n);else{if(!D(this.gl,r))throw new Error("GL context does not support color renderable floats");this.colorBufferHalfFloatExtension=this.gl.getExtension(r)}this.vertexBuffer=be(this.gl),this.indexBuffer=ve(this.gl),this.framebuffer=function(e){return E(e,()=>e.createFramebuffer(),"Unable to create WebGLFramebuffer.")}(this.gl),this.textureConfig=f(this.gl,this.textureHalfFloatExtension)}get debug(){return(0,a._K2)().getBool("DEBUG")}dispose(){if(this.disposed)return;this.program,this.outputTexture;const e=this.gl;m(e,()=>e.finish()),m(e,()=>e.bindFramebuffer(e.FRAMEBUFFER,null)),m(e,()=>e.deleteFramebuffer(this.framebuffer)),m(e,()=>e.bindBuffer(e.ARRAY_BUFFER,null)),m(e,()=>e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,null)),m(e,()=>e.deleteBuffer(this.indexBuffer)),this.disposed=!0}createFloat32MatrixTexture(e,t){return this.throwIfDisposed(),function(e,t,n,r){const[a,o]=p(t,n);return we(e,a,o,Te(r),r.textureFormatFloat,e.FLOAT)}(this.gl,e,t,this.textureConfig)}createFloat16MatrixTexture(e,t){return this.throwIfDisposed(),function(e,t,n,r){const[a,o]=p(t,n);return we(e,a,o,Se(r),r.textureFormatFloat,r.textureTypeHalfFloat)}(this.gl,e,t,this.textureConfig)}createUnsignedBytesMatrixTexture(e,t){return this.throwIfDisposed(),function(e,t,n,r){const[a,o]=p(t,n);return we(e,a,o,Ce(r),e.RGBA,e.UNSIGNED_BYTE)}(this.gl,e,t,this.textureConfig)}uploadPixelDataToTexture(e,t){this.throwIfDisposed(),function(e,t,n){m(e,()=>e.bindTexture(e.TEXTURE_2D,t)),n.data instanceof Uint8Array?2===(0,a._K2)().getNumber("WEBGL_VERSION")?m(e,()=>e.texSubImage2D(e.TEXTURE_2D,0,0,0,n.width,n.height,e.RGBA,e.UNSIGNED_BYTE,n.data)):m(e,()=>e.texImage2D(e.TEXTURE_2D,0,e.RGBA,n.width,n.height,0,e.RGBA,e.UNSIGNED_BYTE,n.data)):2===(0,a._K2)().getNumber("WEBGL_VERSION")?m(e,()=>e.texSubImage2D(e.TEXTURE_2D,0,0,0,e.RGBA,e.UNSIGNED_BYTE,n)):m(e,()=>e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,n)),m(e,()=>e.bindTexture(e.TEXTURE_2D,null))}(this.gl,e,t)}uploadDenseMatrixToTexture(e,t,n,r){this.throwIfDisposed(),function(e,t,n,r,o,s){let i,u,c;m(e,()=>e.bindTexture(e.TEXTURE_2D,t)),o instanceof Uint8Array?(i=new Uint8Array(n*r*4),u=e.UNSIGNED_BYTE,c=e.RGBA):(i=new Float32Array(n*r*4),u=e.FLOAT,c=s.internalFormatPackedFloat),i.set(o),2===(0,a._K2)().getNumber("WEBGL_VERSION")?m(e,()=>e.texSubImage2D(e.TEXTURE_2D,0,0,0,n,r,e.RGBA,u,i)):m(e,()=>e.texImage2D(e.TEXTURE_2D,0,c,n,r,0,e.RGBA,u,i)),m(e,()=>e.bindTexture(e.TEXTURE_2D,null))}(this.gl,e,t,n,r,this.textureConfig)}createFloat16PackedMatrixTexture(e,t){return this.throwIfDisposed(),function(e,t,n,r){const[a,o]=d(t,n);return we(e,a,o,Ee(r),e.RGBA,r.textureTypeHalfFloat)}(this.gl,e,t,this.textureConfig)}createPackedMatrixTexture(e,t){return this.throwIfDisposed(),function(e,t,n,r){const[a,o]=d(t,n);return we(e,a,o,ke(r),e.RGBA,e.FLOAT)}(this.gl,e,t,this.textureConfig)}deleteMatrixTexture(e){this.throwIfDisposed(),this.outputTexture===e&&(C(this.gl,this.framebuffer),this.outputTexture=null),m(this.gl,()=>this.gl.deleteTexture(e))}downloadByteEncodedFloatMatrixFromOutputTexture(e,t,n){return this.downloadMatrixDriver(e,()=>function(e,t,n,r){const[a,o]=p(t,n),s=new Uint8Array(t*n*4);return m(e,()=>e.readPixels(0,0,a,o,r.downloadTextureFormat,e.UNSIGNED_BYTE,s)),new Float32Array(s.buffer)}(this.gl,t,n,this.textureConfig))}downloadPackedMatrixFromBuffer(e,t,n,r,a,o){return $e(this.gl,e,0,0,0,a,o,this.textureConfig)}downloadFloat32MatrixFromBuffer(e,t){return function(e,t,n){const r=e,a=new Float32Array(n);return r.bindBuffer(r.PIXEL_PACK_BUFFER,t),r.getBufferSubData(r.PIXEL_PACK_BUFFER,0,a),r.bindBuffer(r.PIXEL_PACK_BUFFER,null),a}(this.gl,e,t)}createBufferFromTexture(e,t,n){this.bindTextureToFrameBuffer(e);const r=function(e,t,n){const r=e.createBuffer();m(e,()=>e.bindBuffer(e.PIXEL_PACK_BUFFER,r));const a=16*t*n;return m(e,()=>e.bufferData(e.PIXEL_PACK_BUFFER,a,e.STREAM_READ)),m(e,()=>e.readPixels(0,0,n,t,e.RGBA,e.FLOAT,0)),m(e,()=>e.bindBuffer(e.PIXEL_PACK_BUFFER,null)),r}(this.gl,t,n,this.textureConfig);return this.unbindTextureToFrameBuffer(),r}createAndWaitForFence(){const e=this.createFence(this.gl);
2return this.pollFence(e)}createFence(e){let t,n;if((0,a._K2)().getBool("WEBGL_FENCE_API_ENABLED")){const r=e,a=r.fenceSync(r.SYNC_GPU_COMMANDS_COMPLETE,0);e.flush(),n=()=>{const e=r.clientWaitSync(a,0,0);return e===r.ALREADY_SIGNALED||e===r.CONDITION_SATISFIED},t=a}else(0,a._K2)().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")>0?(t=this.beginQuery(),this.endQuery(),n=()=>this.isQueryAvailable(t,(0,a._K2)().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION"))):n=()=>!0;return{query:t,isFencePassed:n}}downloadMatrixFromPackedTexture(e,t,n){return this.downloadMatrixDriver(e,()=>function(e,t,n){const r=new Float32Array(t*n*4);return m(e,()=>e.readPixels(0,0,n,t,e.RGBA,e.FLOAT,r)),r}(this.gl,t,n))}createProgram(e){this.throwIfDisposed();const t=this.gl;null==this.vertexShader&&(this.vertexShader=xe(t));const n=function(e){return E(e,()=>e.createProgram(),"Unable to create WebGLProgram.")}(t);return m(t,()=>t.attachShader(n,this.vertexShader)),m(t,()=>t.attachShader(n,e)),function(e,t){if(m(e,()=>e.linkProgram(t)),!(0,a._K2)().get("ENGINE_COMPILE_ONLY")&&!1===e.getProgramParameter(t,e.LINK_STATUS))throw new Error("Failed to link vertex and fragment shaders.")}(t,n),this.debug&&v(t,n),this.vertexAttrsAreBound||(this.setProgram(n),this.vertexAttrsAreBound=function(e,t,n){return m(e,()=>e.bindBuffer(e.ARRAY_BUFFER,n)),w(e,t,"clipSpacePos",n,3,20,0)&&w(e,t,"uv",n,2,20,12)}(t,this.program,this.vertexBuffer)),n}deleteProgram(e){this.throwIfDisposed(),e===this.program&&(this.program=null),null!=e&&m(this.gl,()=>this.gl.deleteProgram(e))}setProgram(e){this.throwIfDisposed(),this.program=e,null!=this.program&&this.debug&&v(this.gl,this.program),m(this.gl,()=>this.gl.useProgram(e))}getUniformLocation(e,t,n=!0){return this.throwIfDisposed(),n?function(e,t,n){return E(e,()=>e.getUniformLocation(t,n),'uniform "'+n+'" not present in program.')}(this.gl,e,t):function(e,t,n){return e.getUniformLocation(t,n)}(this.gl,e,t)}getAttributeLocation(e,t){return this.throwIfDisposed(),m(this.gl,()=>this.gl.getAttribLocation(e,t))}getUniformLocationNoThrow(e,t){return this.throwIfDisposed(),this.gl.getUniformLocation(e,t)}setInputMatrixTexture(e,t,n){this.throwIfDisposed(),this.throwIfNoProgram(),T(this.gl,e,t,n)}setOutputMatrixTexture(e,t,n){this.setOutputMatrixTextureDriver(e,n,t)}setOutputPackedMatrixTexture(e,t,n){this.throwIfDisposed();const[r,a]=d(t,n);this.setOutputMatrixTextureDriver(e,r,a)}setOutputMatrixWriteRegion(e,t,n,r){this.setOutputMatrixWriteRegionDriver(n,e,r,t)}setOutputPackedMatrixWriteRegion(e,t,n,r){throw new Error("setOutputPackedMatrixWriteRegion not implemented.")}debugValidate(){null!=this.program&&v(this.gl,this.program),k(this.gl)}executeProgram(){this.throwIfDisposed(),this.throwIfNoProgram();const e=this.gl;this.debug&&this.debugValidate(),m(e,()=>e.drawElements(e.TRIANGLES,6,e.UNSIGNED_SHORT,0))}blockUntilAllProgramsCompleted(){this.throwIfDisposed(),m(this.gl,()=>this.gl.finish())}getQueryTimerExtension(){return null==this.disjointQueryTimerExtension&&(this.disjointQueryTimerExtension=y(this.gl,2===(0,a._K2)().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")?"EXT_disjoint_timer_query_webgl2":"EXT_disjoint_timer_query")),this.disjointQueryTimerExtension}getQueryTimerExtensionWebGL2(){return this.getQueryTimerExtension()}getQueryTimerExtensionWebGL1(){return this.getQueryTimerExtension()}beginQuery(){if(2===(0,a._K2)().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")){const e=this.gl,t=this.getQueryTimerExtensionWebGL2(),n=e.createQuery();return e.beginQuery(t.TIME_ELAPSED_EXT,n),n}const e=this.getQueryTimerExtensionWebGL1(),t=e.createQueryEXT();return e.beginQueryEXT(e.TIME_ELAPSED_EXT,t),t}endQuery(){if(2===(0,a._K2)().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")){const e=this.gl,t=this.getQueryTimerExtensionWebGL2();return void e.endQuery(t.TIME_ELAPSED_EXT)}const e=this.getQueryTimerExtensionWebGL1();e.endQueryEXT(e.TIME_ELAPSED_EXT)}async waitForQueryAndGetTime(e){return await a.ZSL.repeatedTry(()=>this.disposed||this.isQueryAvailable(e,(0,a._K2)().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION"))),this.getQueryTime(e,(0,a._K2)().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION"))}getQueryTime(e,t){if(0===t)return null;if(2===t){const t=this.gl;return t.getQueryParameter(e,t.QUERY_RESULT)/1e6}{const t=this.getQueryTimerExtensionWebGL1();return t.getQueryObjectEXT(e,t.QUERY_RESULT_EXT)/1e6}}isQueryAvailable(e,t){if(0===t)return!0;
2if(2===t){const t=this.gl,n=this.getQueryTimerExtensionWebGL2(),r=t.getQueryParameter(e,t.QUERY_RESULT_AVAILABLE);return null==this.disjoint&&(this.disjoint=this.gl.getParameter(n.GPU_DISJOINT_EXT)),r&&!this.disjoint}{const t=this.getQueryTimerExtensionWebGL1(),n=t.getQueryObjectEXT(e,t.QUERY_RESULT_AVAILABLE_EXT);return null==this.disjoint&&(this.disjoint=this.gl.getParameter(t.GPU_DISJOINT_EXT)),n&&!this.disjoint}}pollFence(e){return new Promise(t=>{this.addItemToPoll(()=>e.isFencePassed(),()=>t())})}pollItems(){const e=function(e){let t=0;for(;t<e.length;++t){if(!e[t]())break}return t-1}(this.itemsToPoll.map(e=>e.isDoneFn));for(let t=0;t<=e;++t){const{resolveFn:e}=this.itemsToPoll[t];e()}this.itemsToPoll=this.itemsToPoll.slice(e+1)}addItemToPoll(e,t){if(this.itemsToPoll.push({isDoneFn:e,resolveFn:t}),this.itemsToPoll.length>1)return;let n;"setTimeoutCustom"in(0,a._K2)().platform&&(n=(0,a._K2)().platform.setTimeoutCustom.bind((0,a._K2)().platform)),a.ZSL.repeatedTry(()=>(this.pollItems(),0===this.itemsToPoll.length),()=>0,null,n)}bindTextureToFrameBuffer(e){this.throwIfDisposed(),S(this.gl,e,this.framebuffer),this.debug&&k(this.gl)}unbindTextureToFrameBuffer(){null!=this.outputTexture?(S(this.gl,this.outputTexture,this.framebuffer),this.debug&&k(this.gl)):C(this.gl,this.framebuffer)}downloadMatrixDriver(e,t){this.bindTextureToFrameBuffer(e);const n=t();return this.unbindTextureToFrameBuffer(),n}setOutputMatrixTextureDriver(e,t,n){this.throwIfDisposed();const r=this.gl;S(r,e,this.framebuffer),this.debug&&k(r),this.outputTexture=e,m(r,()=>r.viewport(0,0,t,n)),m(r,()=>r.scissor(0,0,t,n))}setOutputMatrixWriteRegionDriver(e,t,n,r){this.throwIfDisposed(),m(this.gl,()=>this.gl.scissor(e,t,n,r))}throwIfDisposed(){if(this.disposed)throw new Error("Attempted to use disposed GPGPUContext.")}throwIfNoProgram(){if(null==this.program)throw new Error("No GPU program is currently set.")}}function Ie(e,t){Array.isArray(e)||(e=[e]),e.forEach(e=>{null!=e&&a.ZSL.assert("complex64"!==e.dtype,()=>`${t} does not support complex64 tensors in the CPU backend.`)})}function Ae(e){const t=new Float32Array(e.length);for(let n=0;n<e.length;++n)t[n]=Math.abs(e[n]);return t}a.ljI;function Re(e){return(t,n,r,o,s)=>{const i=a.C0T.assertAndGetBroadcastShape(t,n),u=i.length,c=a.ZSL.computeStrides(i),l=a.ZSL.sizeFromShape(i),p=a.ZSL.getTypedArrayFromDType(s,l),h=t.length,d=n.length,f=a.ZSL.computeStrides(t),m=a.ZSL.computeStrides(n),g=a.C0T.getBroadcastDims(t,i),y=a.C0T.getBroadcastDims(n,i);if(g.length+y.length===0)for(let t=0;t<p.length;++t)p[t]=e(r[t%r.length],o[t%o.length]);else for(let t=0;t<p.length;
vendor: 4,178 bytes, line 2
2++t){const n=a.ZSL.indexToLoc(t,u,c),s=n.slice(-h);g.forEach(e=>s[e]=0);const i=a.ZSL.locToIndex(s,h,f),l=n.slice(-d);y.forEach(e=>l[e]=0);const x=a.ZSL.locToIndex(l,d,m);p[t]=e(r[i],o[x])}return[p,i]}}function _e(e){const{inputs:t,backend:n}=e,{real:r,imag:a}=t,o=n.data.get(r.dataId).values,s=n.data.get(a.dataId).values,i=n.makeTensorInfo(r.shape,"complex64");return n.data.get(i.dataId).complexTensorInfos={real:n.makeTensorInfo(r.shape,"float32",o),imag:n.makeTensorInfo(a.shape,"float32",s)},i}a.pr3;function Oe(e,t,n="float32"){if("complex64"===n){return _e({inputs:{real:Oe(e,t,"float32"),imag:Oe(e,t,"float32")},backend:e})}const r=a.ZSL.makeZerosTypedArray(a.ZSL.sizeFromShape(t),n);return e.makeTensorInfo(t,n,r)}function Fe(e){const{inputs:t,backend:n}=e,{x:r}=t;return n.incRef(r.dataId),{dataId:r.dataId,shape:r.shape,dtype:r.dtype}}a.lzr;function De(e){const{inputs:t,backend:n}=e,{input:r}=t,a=n.data.get(r.dataId).complexTensorInfos.real,o=n.data.get(a.dataId).values;return n.makeTensorInfo(a.shape,a.dtype,o)}a.LRy;function Le(e,t,n,r){if("int32"===r){return[t,"int32",Int32Array.from(e)]}if("bool"===r){const r=a.ZSL.toTypedArray([0],n),[o,s]=Re((e,t)=>e!==t?1:0)(t,[],e,r,"bool");return[s,"bool",o]}throw new Error(`Error in Cast: failed to cast ${n} to ${r}`)}function Me(e){const{inputs:t,backend:n,attrs:r}=e,{x:o}=t,{dtype:s}=r;if("complex64"===s){if("complex64"===o.dtype)return Fe({inputs:{x:o},backend:n});const e=Oe(n,o.shape,o.dtype),t=Me({inputs:{x:o},backend:n,attrs:{dtype:"float32"}}),r=_e({inputs:{real:t,imag:e},backend:n});return n.disposeIntermediateTensorInfo(e),n.disposeIntermediateTensorInfo(t),r}if("complex64"===o.dtype){const e=De({inputs:{input:o},backend:n}),t=Me({inputs:{x:e},backend:n,attrs:{dtype:s}});return n.disposeIntermediateTensorInfo(e),t}if(!a.ZSL.hasEncodingLoss(o.dtype,s)){const e=Fe({inputs:{x:o},backend:n});return{dataId:e.dataId,shape:e.shape,dtype:s}}const i=n.data.get(o.dataId).values,[u,c,l]=Le(i,o.shape,o.dtype,s);return n.makeTensorInfo(u,c,l)}a.KXH;function Pe(e,t,n,r){return null==n?({inputs:n,backend:o})=>{const{a:s,b:i}=n,u=o;Ie([s,i],e);const c=u.data.get(s.dataId).values,l=u.data.get(i.dataId).values,p="string"===s.dtype?a.C0T.fromUint8ToStringArray(c):c,h="string"===s.dtype?a.C0T.fromUint8ToStringArray(l):l,d=r||s.dtype,[f,m]=t(s.shape,i.shape,p,h,d);return u.makeTensorInfo(m,d,f)}:({inputs:e,backend:a})=>{const{a:o,b:s}=e,i=a;if("complex64"===o.dtype||"complex64"===s.dtype){const e=Me({inputs:{x:o},backend:i,attrs:{dtype:"complex64"}}),t=i.data.get(e.dataId),r=t.complexTensorInfos.real,a=t.complexTensorInfos.imag,u=i.data.get(r.dataId).values,c=i.data.get(a.dataId).values,l=Me({inputs:{x:s},backend:i,attrs:{dtype:"complex64"}}),p=i.data.get(l.dataId),h=p.complexTensorInfos.real,d=p.complexTensorInfos.imag,f=i.data.get(h.dataId).values,m=i.data.get(d.dataId).values,[g,y,x]=n(o.shape,s.shape,u,c,f,m),b=i.makeTensorInfo(x,"float32",g),v=i.makeTensorInfo(x,"float32",y),w=_e({inputs:{real:b,imag:v},backend:i});return i.disposeIntermediateTensorInfo(e),i.disposeIntermediateTensorInfo(l),i.disposeIntermediateTensorInfo(b),i.disposeIntermediateTensorInfo(v),w}{const e=i.data.get(o.dataId).values,n=i.data.get(s.dataId).values,a=r||o.dtype,[u,c]=t(o.shape,s.shape,e,n,a);return i.makeTensorInfo(c,a,u)}}}function Be(e){return(t,n,r,o,s,i)=>{const u=a.C0T.assertAndGetBroadcastShape(t,n),c=a.ZSL.sizeFromShape(u),l=u.length,p=a.ZSL.computeStrides(u),h=a.ZSL.getTypedArrayFromDType("float32",c),d=a.ZSL.getTypedArrayFromDType("float32",c),f=a.C0T.getBroadcastDims(t,u),m=a.C0T.getBroadcastDims(n,u),g=a.C0T.mergeRealAndImagArrays(r,o),y=a.C0T.mergeRealAndImagArrays(s,i),x=t.length,b=a.ZSL.computeStrides(t),v=n.length,w=a.ZSL.computeStrides(n);if(f.length+m.length===0)for(let t=0;t<h.length;t++){const n=t%g.length,r=t%y.length,a=e(g[2*n],g[2*n+1],y[2*r],y[2*r+1]);h[t]=a.real,d[t]=a.imag}else for(let t=0;t<h.length;t++){const n=a.ZSL.indexToLoc(t,l,p),r=n.slice(-x);f.forEach(e=>r[e]=0);const o=a.ZSL.locToIndex(r,x,b),s=n.slice(-v);m.forEach(e=>s[e]=0);const i=a.ZSL.locToIndex(s,v,w),u=e(g[2*o],g[2*o+1],y[2*i],y[2*i+1]);h[t]=u.real,d[t]=u.imag}return[h,d,u]}}const Ve=Re((e,t)=>
2e+t),ze=Be((e,t,n,r)=>({real:e+n,imag:t+r}));Pe(a.OMN,Ve,ze),a.OMN;function Ue(e,t,n,r,o){const s=a.ZSL.sizeFromShape(r),i=a.ZSL.makeZerosTypedArray(o,n);for(let n=0;n<e.length;n++){const r=e[n];if(r<0)throw new Error("Input x must be non-negative!");r>=o||(i[r]+=s>0?t[n]:1)}return i}function We(e,t,n,r=!1){const o=e.shape[0],s=e.shape[1],i=(0,a.ra8)([o,n],t.dtype);for(let a=0;a<o;a++)for(let o=0;o<s;o++){const s=e.get(a,o);if(s<0)throw new Error("Input x must be non-negative!");s>=n||(r?i.set(1,a,s):t.size>0?i.set(i.get(a,s)+t.get(a,o),a,s):i.set(i.get(a,s)+1,a,s))}return i}function Ge(e){return(t,n,r)=>{const o=a.ZSL.getTypedArrayFromDType(n,t.length);for(let n=0;n<t.length;++n)o[n]=e(t[n],r);return o}}function je(e,t,n){return({inputs:r,attrs:o,backend:s})=>{const{x:i}=r;if(Ie(i,e),"string"===i.dtype||"string"===n)throw new Error("unaryKernelFunc does not support string input/output");const u=s,c=u.data.get(i.dataId).values,l=a.ZSL.sizeFromShape(i.shape),p=n||i.dtype,h=a.ZSL.getArrayFromDType(p,l);for(let e=0;e<l;++e)h[e]=t(c[e],o);return u.makeTensorInfo(i.shape,p,h)}}function Ke(e,t,n){return({inputs:r,attrs:a,backend:o})=>{const{x:s}=r;if(Ie(s,e),"string"===s.dtype||"string"===n)throw new Error("unaryKernelFunc does not support string input/output");const i=o,u=i.data.get(s.dataId).values,c=n||s.dtype,l=t(u,c,a);return i.makeTensorInfo(s.shape,c,l)}}const He=Ge(e=>Math.ceil(e));Ke(a.QDP,He),a.QDP;function Ye(e,t,n,r){const o=a.ZSL.getArrayFromDType(n,a.ZSL.sizeFromShape(t));if(r&&"string"!==n){let t=0;e.forEach(e=>{const n=a.ZSL.sizeFromShape(e.shape);o.set(e.vals,t),t+=n})}else{let r=0;e.forEach(e=>{const s="string"===n?a.C0T.fromUint8ToStringArray(e.vals):e.vals;let i=0;for(let n=0;n<e.shape[0];++n){const a=n*t[1]+r;for(let t=0;t<e.shape[1];++t)o[a+t]=s[i++]}r+=e.shape[1]})}return o}const Ze=Re((e,t)=>e===t?1:0),Xe=(Pe(a.BRl,Ze,null,"bool"),a.BRl,Ge(e=>Math.exp(e))),qe=(Ke(a.ox3,Xe,"float32"),a.ox3,Ge(e=>Math.expm1(e))),Qe=(Ke(a.ybj,qe),a.ybj,Ge(e=>Math.floor(e)));Ke(a.ZgB,Qe),a.ZgB;function Je(e,t,n,r,o,s,i,u,c){const l=(0,a.ra8)([r,s],n);for(let n=0;n<r;n++){const r=[];let a=0;for(let t=0;t<o;t++){const s=e[n*o+t];a+=s*i[t],r.push(s)}if(a<0||a>=c/s)throw new Error(`Invalid indices: ${r} does not index into ${u}`);for(let e=0;e<s;e++)l.values[n*s+e]=t.get(...t.indexToLoc(a*s+e))}return l}function et(e,t,n){const r=(0,a.ra8)(n,e.dtype);for(let n=0;n<r.size;++n){const a=r.indexToLoc(n).slice(),o=a[0],s=a[2],i=t.locToIndex([o,s]);a[2]=t.values[i];const u=e.locToIndex(a);0<=u&&u<e.values.length&&(r.values[n]=e.values[u])}return r}const tt=Re((e,t)=>e>t?1:0),nt=(Pe(a.XhZ,tt,null,"bool"),a.XhZ,Re((e,t)=>e>=t?1:0)),rt=(Pe(a.lLS,nt,null,"bool"),a.lLS,Re((e,t)=>e<t?1:0)),at=(Pe(a.mIA,rt,null,"bool"),a.mIA,Re((e,t)=>
2e<=t?1:0));Pe(a.CwD,at,null,"bool"),a.CwD;function ot(e,t,n){const r=(t-e)/(n-1),o=a.ZSL.makeZerosTypedArray(n,"float32");o[0]=e;for(let e=1;e<o.length;e++)o[e]=o[e-1]+r;return o}const st=Ge(e=>Math.log(e));Ke(a.tG8,st),a.tG8;function it(e,t,n,r){const o=a.ZSL.getTypedArrayFromDType(r,a.ZSL.sizeFromShape(n));for(let n=0;n<o.length;++n){const r=n*t;let a=e[r];for(let n=0;n<t;++n){const t=e[r+n];(Number.isNaN(t)||t>a)&&(a=t)}o[n]=a}return o}const ut=Re((e,t)=>Math.max(e,t)),ct=(Pe(a.LDN,ut),a.LDN,Re((e,t)=>Math.min(e,t))),lt=(Pe(a.LG0,ct),a.LG0,Re((e,t)=>e*t)),pt=Be((e,t,n,r)=>({real:e*n-t*r,imag:e*r+t*n}));Pe(a.xu7,lt,pt),a.xu7;function ht(e,t,n){const r=a.ZSL.createScalarValue(-1,n);return lt([],t,r,e,n)}a.l0G;const dt=Re((e,t)=>e!==t?1:0);Pe(a.ylV,dt,null,"bool"),a.ylV;function ft(e,t,n,r,o){const s=t.length,i=a.ZSL.sizeFromShape(t),u=a.ZSL.computeStrides(t),c=a.ZSL.computeStrides(o),l=a.ZSL.getTypedArrayFromDType(n,a.ZSL.sizeFromShape(o));for(let t=0;t<i;++t){const n=a.ZSL.indexToLoc(t,s,u),o=new Array(n.length);for(let e=0;e<o.length;e++)o[e]=n[r[e]];l[a.ZSL.locToIndex(o,s,c)]=e[t]}return l}a.wx0;function mt(e,t,n,r){const[o,s]=a.C0T.computeOutAndReduceShapes(e,r),i=(0,a.TuY)(t,"int32"),u=a.ZSL.makeZerosTypedArray(a.ZSL.sizeFromShape(o),i),c=a.ZSL.sizeFromShape(s);for(let e=0;e<u.length;++e){const t=e*c;let r=1;for(let e=0;e<c;++e)r*=n[t+e];u[e]=r}return{outVals:u,outShape:o,outDtype:i}}a.kdj;function gt(e,t,n,r){const a=[];let o=0;const s=t.length-1+n.length,i=new Array(s).fill(null).map(()=>[0]);!function(e,t){for(let n=0;n<e.length;++n){const r=e[n],a=n===e.length-1?t:e[n+1].length;if(0===r.length)throw new Error("Ragged splits may not be empty");if(r[0]<0)throw new Error("Ragged splits must be non-negative");if(r[r.length-1]>a)throw new Error("Ragged splits must not point past values");for(let e=1;e<r.length;++e)if(r[e-1]>r[e])throw new Error("Ragged splits must be sorted in ascending order")}}(n,r);let u=1;for(let e=0;e<t.length-1;++e){u*=t[e];const n=t[e+1];for(let t=1;t<u+1;++t)i[e].push(t*n)}for(let r=0;r<e.length;++r){let s=e[r],u=e[r]+1;for(let e=0;e<n.length;++e){const r=n[e],a=e+t.length-1;if(a>=0){const e=i[a],t=e[e.length-1]-r[s];for(let e=s;e<u;++e)i[a].push(r[e+1]+t)}s=r[s],u=r[u]}u!==s&&(a.push([s,u]),o+=u-s)}return{outSplits:i,valueSlices:a,numValues:o}}function yt(e,t){const n=e.slice(0,t);for(;n.length<t;)n.push(1);for(let r=t;r<e.length;r++)n[t-1]*=e[r];return n}function xt(e,t,n,r,o){const s=t.slice();s[0]=o;const i=a.ZSL.getArrayFromDType(n,a.ZSL.sizeFromShape(s)),u=e.length;return function(e,t,n,r,a,o){const s=yt(t,2)[1],i=yt(o,2)[1];let u=0;for(const t of n)for(let n=t[0];n<t[1];++n){for(let t=0;t<r;++t)a[u*i+t]=e[n*s+t];++u}}(e,t,r,0===u?0:u/t[0],i,s),[i,s]}function bt(e,t,n,r,o,s,i,u){if(0===e.length)throw new Error("paramsNestedSplits must be non empty");if(0===t[0].length)throw new Error("Split tensors must not be scalars");if(function(e,t,n){e.forEach((e,r)=>{if(e<0||e>=n){const o=a.ZSL.indexToLoc(r,t.length,a.ZSL.computeStrides(t)).join(",");throw new Error(`indices[${o}] = ${e} is not in [0, ${n})`)}})}(s,i,t[0][0]-1),0===r.length)throw new Error("params.rank must be nonzero");const c=r[0],{outSplits:l,valueSlices:p,numValues:h}=gt(s,i,e,c),d=function(e){const t=[];for(let n=0;n<e.length;++n){const r=e[n].length,o=a.ZSL.getArrayFromDType("int32",r);t.push(o),e[n].forEach((e,t)=>o[t]=e)}return t}(l),f=xt(n,r,o,p,h);return[d,f[0],f[1]]}var vt=a.C0T.RowPartitionType;class wt{constructor(e,t,n,r,o,s,i,u,c,l){this.shape=e,this.shapeShape=t,this.values=n,this.valuesShape=r,this.valuesDType=o,this.defaultValue=s,this.defaultValueShape=i,this.rowPartitionValues=u,this.rowPartitionValuesShapes=c,this.rowPartitionTypes=a.C0T.getRowPartitionTypesHelper(l),this.raggedRank=a.C0T.getRaggedRank(this.rowPartitionTypes)}getRowPartitionTypeByDimension(e){return this.rowPartitionTypes[0]===vt.FIRST_DIM_SIZE?this.rowPartitionTypes[e+1]:this.rowPartitionTypes[e]}getRowPartitionTensor(e){return this.rowPartitionTypes[0]===vt.FIRST_DIM_SIZE?this.rowPartitionValues[e+1]:this.rowPartitionValues[e]}getMaxWidth(e){const t=this.getRowPartitionTensor(e-1);switch(this.getRowPartitionTypeByDimension(e-1)){case vt.VALUE_ROWIDS:return wt.getMaxWidthValueRowID(t);case vt.ROW_SPLITS:return wt.getMaxWidthRowSplit(t);default:throw new Error(`Cannot handle partition type ${vt[this.getRowPartitionTypeByDimension(e-1)]}`)}}static getMaxWidthRowSplit(e){const t=e.length;if(0===t||1===t)return 0;let n=0;for(let r=0;r<t-1;++r){const t=e[r+1]-e[r];t>n&&(n=t)}return n}static getMaxWidthValueRowID(e){const t=e.length;if(0===t)return 0;let n=0,r=e[0],a=0;for(let o=1;o<t;++o){const t=e[o];t!==r&&(r=t,a=Math.max(o-n,a),n=o)}return Math.max(t-n,a)}tensorShapeFromTensor(e,t,n=!0){if(0===t.length){if(-1===e[0])return[];throw new Error("The only valid scalar shape tensor is the fully unknown shape specified as -1.")}return St(e,n)}calculateOutputSize(e){const t=this.valuesShape,n=this.defaultValueShape;a.C0T.validateDefaultValueShape(n,t);const r=this.tensorShapeFromTensor(this.shape,this.shapeShape),o=a.C0T.comb
vendor: 8,869 bytes, line 2
2ineRaggedTensorToTensorShapes(this.raggedRank,r,t);o[0]<0&&(o[0]=e);for(let e=1;e<=this.raggedRank;++e)o[e]<0&&(o[e]=this.getMaxWidth(e));return o}calculateFirstParentOutputIndex(e,t,n){const r=Math.min(e,n),o=[];let s=0;for(let e=0;e<r;++e,s+=t)o.push(s);for(let t=r;t<e;++t)o.push(-1);return a.ZSL.assert(o.length===e,()=>"Final length of result must be equal to firstDimension."),o}calculateOutputIndexRowSplit(e,t,n,r){const a=e.length,o=[];for(let s=0;s<a-1;++s){const a=e[s+1]-e[s];let i=Math.min(r,a),u=t[s];-1===u&&(i=0);for(let e=0;e<i;++e)o.push(u),u+=n;for(let e=0;e<a-i;++e)o.push(-1)}if(a>0&&o.length!==e[a-1])throw new Error("Invalid row split size.");return o}calculateOutputIndexValueRowID(e,t,n,r){const a=e.length,o=[];if(0===a)return[];let s=0,i=e[0];if(i>=t.length)throw new Error(`Got currentValueRowId=${i}, which is not less than ${t.length}`);let u=t[i];o.push(u);for(let c=1;c<a;++c){const a=e[c];if(a===i)u>=0&&(++s,s<r?u+=n:u=-1);else{if(s=0,i=a,a>=t.length)throw new Error(`Got nextValueRowId=${a} which is not less than ${t.length}`);u=t[a]}o.push(u)}if(o.length!==e.length)throw new Error("Invalid row ids.");return o}calculateOutputIndex(e,t,n,r){const a=this.getRowPartitionTensor(e),o=this.getRowPartitionTypeByDimension(e);switch(o){case vt.VALUE_ROWIDS:return this.calculateOutputIndexValueRowID(a,t,n,r);case vt.ROW_SPLITS:if(a.length-1>t.length)throw new Error(`Row partition size is greater than output size: ${a.length-1} > ${t.length}`);return this.calculateOutputIndexRowSplit(a,t,n,r);default:throw new Error(`Unsupported partition type: ${vt[o]}`)}}getFirstDimensionSize(){const e=this.rowPartitionValues[0];if(0===this.rowPartitionTypes.length)throw new Error("No row_partition_types given.");const t=this.rowPartitionTypes[0];switch(t){case vt.FIRST_DIM_SIZE:return e[0];case vt.VALUE_ROWIDS:throw new Error("Cannot handle VALUE_ROWIDS in first dimension.");case vt.ROW_SPLITS:return this.rowPartitionValuesShapes[0][0]-1;default:throw new Error(`Cannot handle type ${vt[t]}`)}}compute(){if(this.rowPartitionValues[0].length<=0)throw new Error("Invalid first partition input. Tensor requires at least one element.");const e=this.getFirstDimensionSize(),t=this.calculateOutputSize(e),n=new Array(this.raggedRank+1);n[n.length-1]=1;for(let e=n.length-2;e>=0;--e)n[e]=n[e+1]*t[e+1];const r=St(t,!1),o=a.ZSL.getArrayFromDType(this.valuesDType,a.ZSL.sizeFromShape(r));if(n[0]*t[0]>0){let a=this.calculateFirstParentOutputIndex(e,n[0],t[0]);for(let e=1;e<=this.raggedRank;++e){a=this.calculateOutputIndex(e-1,a,n[e],t[e])}this.setOutput(this.raggedRank,a,o,r)}return[r,o]}setOutput(e,t,n,r){if(0===n.length)return;const o=this.values,s=n;let i=r.slice();i=i.slice(e+1);const u=a.ZSL.sizeFromShape(i),c=t.length;let l=this.defaultValue;if(l.length!==u&&1!==l.length){const e=this.defaultValueShape;(0,a.DZQ)(()=>{const t=(0,a.tQQ)(l,e),n=(0,a.hOW)(t,i);l=n.dataSync()})}let p=0,h=0,d=0;for(let e=0;e<=c;++e){let r=e<c?t[e]:-1;if(r!==d){if(h<d){const e=o.subarray(p*u);Tt(s.subarray(h*u),e,(d-h)*u)}if(e>=c){const e=n.length;r=Math.floor(e/u)}if(r>d)if(1===this.defaultValue.length)s.subarray(d*u,r*u).fill(this.defaultValue[0]),d=r;else for(;r>d;){Tt(s.slice(d*u),l,u),++d}r<0?(p=e+1,h=d):(p=e,h=d,d=h+1)}else++d}}}function Tt(e,t,n){for(let r=0;r<n;r++)e[r]=t[r]}function St(e,t){const n=[];for(let r of e){if(r<0){if(!t)throw new Error(`Dimension ${r} must be >= 0`);if(r<-1)throw new Error(`Dimension ${r} must be >= -1`);r=-1}n.push(r)}return n}function Ct(e,t,n,r,a,o,s,i,u,c){return new wt(e,t,n,r,a,o,s,i,u,c).compute()}function kt(e,t,n,r){if(e===t||e<t&&n<0||t<e&&n>1)return a.ZSL.makeZerosTypedArray(0,r);const o=Math.abs(Math.ceil((t-e)/n)),s=a.ZSL.makeZerosTypedArray(o,r);t<e&&1===n&&(n=-1),s[0]=e;for(let e=1;e<s.length;e++)s[e]=s[e-1]+n;return s}const Et=Ge(e=>1/Math.sqrt(e));Ke(a.TOR,Et),a.TOR;function $t(e,t,n,r,o,s,i,u,c,l){const p=[r/o,o],h=e.values,d=t.values;if(0===r)return(0,a.ra8)(n,t.dtype);const f=(0,a.ra8)(p,t.dtype);"string"==typeof c||"number"==typeof c?f.values.fill(c):"boolean"==typeof c&&f.values.fill(+c);for(let e=0;e<s;e++){const a=[];let s=0;for(let t=0;t<i;t++){const n=h[e*i+t];a.push(n),s+=n*u[t]}if(s<0||s>=r/o)throw new Error(`Invalid indices: ${a} does not index into ${n}`);for(let n=0;n<o;n++)l?f.values[s*o+n]+=d[e*o+n]:f.values[s*o+n]=0===t.rank?d[0]:d[e*o+n]}return f}const Nt=Ge(e=>1/(1+Math.exp(-e)));je(a.vI1,e=>1/(1+Math.exp(-e))),a.vI1;function It(e,t,n,r,o){const s=a.Kro.isSliceContinous(r,t,n),i=a.ZSL.sizeFromShape(n),u=a.ZSL.computeStrides(r);if(s){const n=a.Kro.computeFlatOffset(t,u);return"string"===o?e.slice(n,n+i):e.subarray(n,n+i)}const c="string"===o?a.C0T.fromUint8ToStringArray(e):e,l=(0,a.ra8)(r,o,c),p=(0,a.ra8)(n,o);for(let e=0;e<p.size;++e){const n=p.indexToLoc(e),r=n.map((e,n)=>e+t[n]);p.set(l.get(...r),...n)}return"string"===o?a.C0T.fromStringArrayToUint8(p.values):p.values}a.JiE;function At(e,t,n,r,o,s,i){const u=t[0],c=s[0],l=new Array(c),p=new Array(u),h=t[1];if(0===c){if(0!==u)throw new Error(a.C0T.getSparseFillEmptyRowsIndicesDenseShapeMismatch(u));return[a.ZSL.getArrayFromDType(n,0),[0,h],a.ZSL.getArrayFromDType(o,0),l,p]}let d=!0,f=0;const m=new Array(c).fill(0);for(let t=0;t<u;++t){const n=e[t*h];if(n<0)throw new Error(a.C0T.getSparseFillEmptyRowsNegativeIndexErrorMessage(t,n));if(n>=c)throw new Error(a.C0T.getSparseFillEmptyRowsOutOfRangeIndexErrorMessage(t,n,c));++m[n],d=d&&n>=f,f=n}let g=!0;for(let e=0;e<c;++e){const t=0===m[e];l[e]=t,g=g&&!t,m[e]=Math.max(m[e],1),e>0&&(m[e]+=m[e-1])}if(g&&d){const t=e,n=r;for(let e=0;e<u;++e)p[e]=e;return[t,[u,h],n,l,p]}{const t=m[c-1],s=a.ZSL.getArrayFromDType(n,t*h),d=a.ZSL.getArrayFromDType(o,t),f=new Array(c).fill(0);for(let t=0;t<u;++t){const n=e[t*h],a=f[n],o=(0===n?0:m[n-1])+a;f[n]++;for(let n=0;n<h;++n)s[o*h+n]=e[t*h+n];d[o]=r[t],p[t]=o}for(let e=0;e<c;++e){if(0===f[e]){const t=0===e?0:m[e-1];s[t*h+0]=e;for(let e=1;e<h;++e)s[t*h+e]=0;d[t]=i}}return[s,[t,h],d,l,p]}}function Rt(e,t,n,r,o){const s=a.ZSL.sizeFromShape(r),i=t[0],u=o.length,c=[];let l=1,p=-1;for(let e=0;e<u;++e){const t=o[e];if(-1===t){if(-1!==p)throw new Error(a.C0T.getSparseReshapeMultipleNegativeOneOutputDimErrorMessage(p,e));p=e,c.push(1)}else{if(t<0)throw new Error(a.C0T.getSparseReshapeNegativeOutputDimErrorMessage(e,t));l*=t,c.push(t)}}if(-1!==p){if(l<=0)throw new Error(a.C0T.getSparseReshapeEmptyTensorZeroOutputDimErrorMessage());const e=Math.trunc(s/l);if(l*e!==s)throw new Error(a.C0T.getSparseReshapeInputOutputMultipleErrorMessage(r,c));c[p]=e}if(a.ZSL.sizeFromShape(c)!==s)throw new Error(a.C0T.getSparseReshapeInputOutputMismatchErrorMessage(r,c));const h=r.length,d=[];if(h>0){d[h-1]=1;for(let e=h-2;e>=0;--e)d[e]=d[e+1]*r[e+1]}const f=[];if(u>0){f[u-1]=1;for(let e=u-2;e>=0;--e)f[e]=f[e+1]*c[e+1]}const m=a.ZSL.getArrayFromDType(n,i*u);for(let t=0;t<i;++t){let n=0;for(let r=0;r<h;++r)n+=e[t*h+r]*d[r];for(let e=0;e<u;++e)m[t*u+e]=Math.trunc(n/f[e]),n%=f[e]}return[m,[i,u],c]}function _t(e,t,n,r,o,s=!1,i=0){const u=r.length,c=[t[0],e.length/t[0]],l=c[1],p=u>0?o[u-1]+1:0;if(p<0)throw new Error(a.C0T.getSparseSegmentReductionNegativeSegmentIdsErrorMessage());const h=t.slice();h[0]=p;const d=h.reduce((e,t)=>e*t,1),f=a.ZSL.getArrayFromDType(n,d);if(0===u)return p>0&&f.fill(i),[f,h];if(p<=0)throw new Error(a.C0T.getSparseSegmentReductionNegativeSegmentIdsErrorMessage());let m=0,g=1,y=0,x=o[m];for(;;){let t=0;if(g<u){if(t=o[g],x===t){++g;continue}if(x>=t)throw new Error(a.C0T.getSparseSegmentReductionNonIncreasingSegmentIdsErrorMessage())}if(x<0||x>=p)throw new Error(a.C0T.getSparseSegmentReductionSegmentIdOutOfRangeErrorMessage(x,p));x>y&&f.fill(i,y*l,x*l);for(let t=m;t<g;++t){const n=r[t];if(n<0||n>=c[0])throw new Error(a.C0T.getSparseSegmentReductionIndicesOutOfRangeErrorMessage(t,r[t],c[0]));for(let t=0;t<l;t++)f[x*l+t]+=e[n*l+t]}if(s)for(let e=0;e<l;e++)f[x*l+e]/=g-m;if(m=g,++g,y=x+1,x=t,g>u)break}return y<p&&f.fill(i,y*l,p*l),[f,h]}const Ot=Ge(e=>Math.sqrt(e));je(a.dFH,e=>Math.sqrt(e)),a.dFH;function Ft(e,t,n,r){const o=(0,a.ra8)(e,t.dtype);for(let e=0;e<o.size;e++){const a=o.indexToLoc(e),s=new Array(a.length);for(let e=0;e<s.length;e++)s[e]=a[e]*n[e]+r[e];o.set(t.get(...s),...a)}return o}class Dt{constructor(e,t,n,r,o,s){this.separator=a.ZSL.encodeString(e),this.nGramWidths=t,this.leftPad=a.ZSL.encodeString(n),this.rightPad=a.ZSL.encodeString(r),this.padWidth=o,this.preserveShort=s}getPadWidth(e){return Math.min(this.padWidth<0?e-1:this.padWidth,e-1)}getNumNGrams(e,t){const n=this.getPadWidth(t);return Math.max(0,e+2*n-t+1)}createNGrams(e,t,n,r,a,o){for(let s=0;s<a;++s){const i=this.getPadWidth(o),u=Math.max(0,i-s),c=Math.max(0,i-(a-(s+1))),l=o-(u+c),p=t+(u>0?0:s-i);let h=0;h+=u*this.leftPad.length;for(let t=0;t<l;++t)h+=e[p+t].length;h+=c*this.rightPad.length;h+=(u+c+l-1)*this.separator.length,n[r+s]=new Uint8Array(h);const d=n[r+s];let f=0;const m=e=>
2e.forEach(e=>d[f++]=e);for(let e=0;e<u;++e)m(this.leftPad),m(this.separator);for(let t=0;t<l-1;++t)m(e[p+t]),m(this.separator);if(l>0){m(e[p+l-1]);for(let e=0;e<c;++e)m(this.separator),m(this.rightPad)}else{for(let e=0;e<c-1;++e)m(this.rightPad),m(this.separator);m(this.rightPad)}}}compute(e,t){const n=e.length,r=t.length;if(r>0){let e=t[0];if(0!==e)throw new Error(`First split value must be 0, got ${e}`);for(let a=1;a<r;++a){let r=t[a]>=e;if(r=r&&t[a]<=n,!r)throw new Error(`Invalid split value ${t[a]}, must be in [${e}, ${n}]`);e=t[a]}if(e!==n)throw new Error(`Last split value must be data size. Expected ${n}, got ${e}`)}const o=r-1,s=a.ZSL.getArrayFromDType("int32",r);if(0===n||0===r){const e=new Array(n);for(let e=0;e<=o;++e)s[e]=0;return[e,s]}s[0]=0;for(let e=1;e<=o;++e){const n=t[e]-t[e-1];let r=0;this.nGramWidths.forEach(e=>{r+=this.getNumNGrams(n,e)}),this.preserveShort&&n>0&&0===r&&(r=1),s[e]=s[e-1]+r}const i=new Array(s[o]);for(let n=0;n<o;++n){const r=t[n];let a=s[n];if(this.nGramWidths.forEach(o=>{const s=t[n+1]-t[n],u=this.getNumNGrams(s,o);this.createNGrams(e,r,i,a,u,o),a+=u}),this.preserveShort&&a===s[n]){const o=t[n+1]-t[n];if(0===o)continue;const s=o+2*this.padWidth,u=1;this.createNGrams(e,r,i,a,u,s)}}return[i,s]}}function Lt(e,t,n,r,a,o,s,i){return new Dt(n,r,a,o,s,i).compute(e,t)}function Mt(e,t,n,r){if(!e.length)return;if(0===t.length){for(let t=0;t<e.length;++t)r.push(e.subarray(t,t+1));return}if(1===t.length){const a=t[0];let o=e.indexOf(a);for(;-1!==o;){const t=e.subarray(0,o);n&&0===t.length||r.push(t),o=(e=e.subarray(o+1)).indexOf(a)}return void(n&&0===e.length||r.push(e))}let a=0;for(let o=0;o<e.length+1;o++)if(o===e.length||-1!==t.indexOf(e[o])){const t=e.subarray(a,o);n&&0===t.length||r.push(t),a=o+1}}function Pt(e,t,n){const r=e.length,o=[];let s=0,i=0;const u=new Array(r);for(let a=0;a<r;++a){const r=o.length;Mt(e[a],t,n,o);const c=o.length-r;u[a]=c,s+=c,i=Math.max(i,c)}const c=a.ZSL.getArrayFromDType("int32",2*s),l=new Array(s),p=[r,i];let h=0;for(let e=0;e<r;++e)for(let t=0;t<u[e];++t)c[2*h]=e,c[2*h+1]=t,l[h]=o[h],++h;return[c,l,p]}function Bt(e,t){const n=a.ZSL.getArrayFromDType("int32",e.length);for(let r=0;r<e.length;++r)n[r]=a.ZSL.fingerPrint64(e[r]).modulo(t).getLowBitsUnsigned();return n}const Vt=Re((e,t)=>e-t),zt=Be((e,t,n,r)=>({real:e-n,imag:t-r}));Pe(a.PbM,Vt,zt),a.PbM;function Ut(e,t){const n=new Array(e.rank);for(let r=0;r<n.length;r++)n[r]=e.shape[r]*t[r];const r=(0,a.ra8)(n,e.dtype);for(let t=0;t<r.values.length;++t){const n=r.indexToLoc(t),a=new Array(e.rank);for(let t=0;t<a.length;t++)a[t]=n[t]%e.shape[t];const o=e.locToIndex(a);r.values[t]=e.values[o]}return r}const Wt=(e,t)=>{const n=t.value-e.value;return 0===n?e.index-t.index:n};function Gt(e,t,n=0,r=e.length-1){for(;r>n;){if(r-n>600){const a=r-n+1,o=t-n+1,s=Math.log(a),i=.5*Math.exp(2*s/3),u=.5*Math.sqrt(s*i*(a-i)/a)*Math.sign(o-a/2);Gt(e,t,Math.max(n,Math.floor(t-o*i/a+u)),Math.min(r,Math.floor(t+(a-o)*i/a+u)))}const o=e[t];let s=n,i=r;for(a.ZSL.swap(e,n,t),Wt(e[r],o)>0&&a.ZSL.swap(e,n,r);s<i;){for(a.ZSL.swap(e,s,i),s++,i--;Wt(e[s],o)<0;)s+=1;for(;Wt(e[i],o)>0;)i-=1}0===Wt(e[n],o)?a.ZSL.swap(e,n,i):(i+=1,a.ZSL.swap(e,i,r)),i<=t&&(n=i+1),t<=i&&(r=i-1)}}function jt(e,t,n,r,o){const s=t[t.length-1],[i,u]=[e.length/s,s],c=a.ZSL.getTypedArrayFromDType(n,i*r),l=a.ZSL.getTypedArrayFromDType("int32",i*r);for(let t=0;t<i;t++){const n=t*u,a=e.subarray(n,n+u);let s=new Array(a.length);a.forEach((e,t)=>s[t]={value:e,index:t}),r<s.length&&(Gt(s,r),s=s.slice(0,r)),o&&s.sort(Wt);const i=t*r,p=c.subarray(i,i+r),h=l.subarray(i,i+r);for(let e=0;e<r;e++)p[e]=s[e].value,h[e]=s[e].index}const p=t.slice();return p[p.length-1]=r,[(0,a.ra8)(p,n,c),(0,a.ra8)(p,"int32",l)]}function Kt(e,t,n,r){const o=a.ZSL.parseAxisParam(t,n)[0],s=[1,n[0],1];for(let e=0;e<o;e++)s[0]*=n[e];s[1]=n[o];for(let e=o+1;e<n.length;e++)s[2]*=n[e];const i={},u=new Int32Array(n[o]),c=new a.ylz(s,r,e),l=[],p=1===s[0]&&1===s[2];for(let t=0;t<n[o];t++){let n;if(p)n=e[t].toString();else{const e=[];for(let n=0;n<s[0];n++)for(let r=0;r<s[2];r++)e.push(c.get(n,t,r));n=e.join(",")}if(void 0!==i[n])u[t]=i[n];else{const e=Object.keys(i).length;i[n]=e,u[t]=e,l.push(t)}}const h=s.slice();h[1]=Object.keys(i).length;const d=new a.ylz(h,r);l.forEach((e,t)=>{for(let n=0;n<s[0];n++)for(let r=0;r<s[2];r++)d.set(c.get(n,e,r),n,t,r)});const f=n.slice();return f[o]=h[1],{outputValues:d.values,outputShape:f,indices:u}}const{mx:Ht,XI:Yt,Nk:Zt,ct:Xt,YG:qt,hH:Qt,z3:Jt,sG:en,uM:tn,vS:nn,qB:rn,GG:an,rq:on,lg:sn,WR:un,cu:cn,GE:ln,px:pn,jC:hn,He:dn,hE:fn,BF:mn,Dk:gn,cl:yn,_B:xn,ub:bn,Ku:vn,qy:wn,Zy:Tn,bu:Sn,zv:Cn,dH:kn,HS:En,yH:$n,l3:Nn,z9:In,x6:An,eW:Rn,GK:_n,SP:On,f6:Fn,dl:Dn,Dw:Ln,xT:Mn,_X:Pn,wz:Bn}=r;function Vn(e,t){return["x","y","z","w","u","v"].slice(0,t).map(t=>`${e}.${t}`)}function zn(e,t){return 1===t?[e]:Vn(e,t)}class Un{constructor(e){if(this.variableNames=["A"],this.packedInputs=!1,this.packedOutput=!0,this.outputShape=e,this.rank=e.length,this.enableShapeUniforms=pe(this.outputShape.length),0===this.rank)this.userCode="\n void main() {\n setOutput(vec4(getA(), 0., 0., 0.));\n }\n ";else{const e=zn("rc",this.rank),t=ae(this.rank),n=this.getOutOfBoundsCondition(e),r=this.getSetup(e),a=this.getOutput(e);this.userCode=`\n void main() {\n ${t} rc = getOutputCoords();\n\n if(${n}) {\n setOutput(vec4(0));\n } else {\n ${r}\n\n setOutput(vec4(${a}));\n }\n }\n `}}getSourceCoordsArr(e){const t=[];for(let n=0;n<=1;n++)for(let r=0;r<=1;r++){let a=`${0===n?"r":"rp1"}, ${0===r?"c":"cp1"}`;for(let t=2;t<this.rank;t++)a=`${e[e.length-1-t]},`+a;t.push(a)}return t}getOutOfBoundsCondition(e){if(1===this.rank)return`rc > ${this.enableShapeUniforms?"outShape":this.outputShape[0]}`;let t="";for(let n=this.rank-2;n<this.rank;n++)t+=`${e[n]} >= ${this.enableShapeUniforms?`outShape[${n}]`:this.outputShape[n]}`,n<this.rank-1&&(t+="||");return t}getSetup(e){if(1===this.rank)return"";const t=e.slice(-2),n=this.enableShapeUniforms?`outShape[${this.rank} - 1]`:this.outputShape[this.rank-1],r=this.enableShapeUniforms?`outShape[${this.rank} - 2]`:this.outputShape[this.rank-2];return`\n int r = ${t[0]};\n int c = ${t[1]};\n int rp1 = r + 1;\n int cp1 = c + 1;\n\n bool cEdge = cp1 >= ${n};\n bool rEdge = rp1 >= ${r};\n `}getOutput(e){const t=this.getSourceCoordsArr(e);if(1===this.rank){return`getA(rc), (rc + 1 >= ${this.enableShapeUniforms?"outShape":this.outputShape[0]} ? 0. : getA(rc + 1)), 0, 0`}return`getA(${t[0]}),\n cEdge ? 0. : getA(${t[1]}
2),\n rEdge ? 0. : getA(${t[2]}),\n rEdge || cEdge ? 0. : getA(${t[3]})`}}class Wn{constructor(e,t){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.customUniforms=[{name:"inputShape",type:"ivec3"}],this.outputShape=e,this.enableShapeUniforms=pe(this.outputShape.length);let n="";for(let e=0;e<4;e++){let t="thisRC = rc;";e%2==1&&(t+="thisRC.z += 1;"),e>1&&(t+="thisRC.y += 1;"),n+=`\n ${t}\n ${e>0?"if(thisRC.y < rows && thisRC.z < cols){":""}\n int flatIndex = getFlatIndex(thisRC);\n\n ivec3 inputRC = inputCoordsFromReshapedOutCoords(flatIndex);\n vec2 inputRCInnerDims = vec2(float(inputRC.y),float(inputRC.z));\n\n result[${e}] =\n getChannel(getA(inputRC.x, inputRC.y, inputRC.z), inputRCInnerDims);\n ${e>0?"}":""}\n `}var r,a;this.userCode=`\n ${r=t,a=this.enableShapeUniforms,`\n ivec3 inputCoordsFromReshapedOutCoords(int index) {\n ${a?G(["r","c","d"],"inputShape"):U(["r","c","d"],r)}\n return ivec3(r, c, d);\n }\n `}\n ${this.enableShapeUniforms?"\n int getFlatIndex(ivec3 coords) {\n return coords.x * outShapeStrides[0] + coords.y * outShapeStrides[1] + coords.z;\n }\n":j(e)}\n\n void main() {\n ivec3 rc = getOutputCoords();\n\n vec4 result = vec4(0.);\n\n ivec3 thisRC;\n int rows = ${this.enableShapeUniforms?"outShape[1]":e[1]};\n int cols = ${this.enableShapeUniforms?"outShape[2]":e[2]};\n\n ${n}\n\n setOutput(result);\n }\n `}}class Gn{constructor(e){this.gpgpu=e,this.numUsedTextures=0,this.numFreeTextures=0,this._numBytesAllocated=0,this._numBytesFree=0,this.freeTextures={},this.logEnabled=!1,this.usedTextures={}}acquireTexture(e,t,n){const r=Kn(t,n),a=Hn(e,r,n);a in this.freeTextures||(this.freeTextures[a]=[]),a in this.usedTextures||(this.usedTextures[a]=[]);const o=jn(e,r,this.gpgpu.gl,this.gpgpu.textureConfig,n);if(this.freeTextures[a].length>0){this.numFreeTextures--,this.numUsedTextures++,this._numBytesFree-=o,this.log();const e=this.freeTextures[a].shift();return this.usedTextures[a].push(e),e}let s;return r===l.PACKED_2X2_FLOAT32?s=this.gpgpu.createPackedMatrixTexture(e[0],e[1]):r===l.PACKED_2X2_FLOAT16?s=this.gpgpu.createFloat16PackedMatrixTexture(e[0],e[1]):r===l.UNPACKED_FLOAT32?s=this.gpgpu.createFloat32MatrixTexture(e[0],e[1]):r===l.UNPACKED_FLOAT16?s=this.gpgpu.createFloat16MatrixTexture(e[0],e[1]):r===l.PACKED_4X1_UNSIGNED_BYTE&&(s=this.gpgpu.createUnsignedBytesMatrixTexture(e[0],e[1])),this.usedTextures[a].push(s),this.numUsedTextures++,this._numBytesAllocated+=o,this.log(),s}releaseTexture(e,t,n,r){if(null==this.freeTextures)return;const o=Kn(n,r),s=Hn(t,o,r);s in this.freeTextures||(this.freeTextures[s]=[]);const i=jn(t,o,this.gpgpu.gl,this.gpgpu.textureConfig,r),u=(0,a._K2)().get("WEBGL_DELETE_TEXTURE_THRESHOLD");-1!==u&&this._numBytesAllocated>u?(this.gpgpu.deleteMatrixTexture(e.texture),this._numBytesAllocated-=i):(this.freeTextures[s].push(e),this.numFreeTextures++,this._numBytesFree+=i),this.numUsedTextures--;const c=this.usedTextures[s],l=c.indexOf(e);if(l<0)throw new Error("Cannot release a texture that was never provided by this texture manager");c.splice(l,1),this.log()}log(){if(!this.logEnabled)return;this.numFreeTextures,this.numUsedTextures,this._numBytesFree,this._numBytesAllocated}get numBytesAllocated(){return this._numBytesAllocated}get numBytesFree(){return this._numBytesFree}getNumUsedTextures(){return this.numUsedTextures}getNumFreeTextures(){return this.numFreeTextures}dispose(){if(null!=this.freeTextures){for(const e in this.freeTextures)this.freeTextures[e].forEach(e=>{this.gpgpu.deleteMatrixTexture(e.texture)});for(const e in this.usedTextures)this.usedTextures[e].forEach(e=>{this.gpgpu.deleteMatrixTexture(e.texture)});this.freeTextures=null,this.usedTextures=null,this.numUsedTextures=0,this.numFreeTextures=0,this._numBytesAllocated=0,this._numBytesFree=0}}}function jn(e,t,n,r,a){const o=function(e,t){switch(e){case l.PACKED_2X2_FLOAT32:return ke(t);case l.PACKED_2X2_FLOAT16:return Ee(t);case l.UNPACKED_FLOAT32:return Te(t);case l.UNPACKED_FLOAT16:return Se(t);case l.PACKED_4X1_UNSIGNED_BYTE:return Ce(t);default:throw new Error(`Unknown physical texture type ${e}`)}}(t,r);let s;if(a){const[t,n]=d(e[0],e[1]);s=t*n}else{const[t,n]=p(e[0],e[1]);s=t*n}const i=function(e,t){const n=e;if(t===n.R32F)return 4;if(t===n.R16F)return 2;if(t===n.RGBA32F)return 16;if(t===e.RGBA)return 16;if(t===n.RGBA16F)return 8;if(t===n.RGBA8)return 4;throw new Error(`Unknown internal format ${t}`)}(n,o);return s*i}function Kn(e,t){if(e===c.UPLOAD)return l.PACKED_2X2_FLOAT32;if(e===c.RENDER||null==e)return function(e){return(0,a._K2)().getBool("WEBGL_RENDER_FLOAT32_ENABLED")?e?l.PACKED_2X2_FLOAT32:l.UNPACKED_FLOAT32:e?l.PACKED_2X2_FLOAT16:l.UNPACKED_FLOAT16}(t);
2if(e===c.DOWNLOAD||e===c.PIXELS)return l.PACKED_4X1_UNSIGNED_BYTE;throw new Error(`Unknown logical texture type ${e}`)}function Hn(e,t,n){return`${e[0]}_${e[1]}_${t}_${n}`}class Yn{constructor(e,t){this.variableNames=["A"],this.outputShape=e,this.enableShapeUniforms=pe(this.outputShape.length),this.userCode=`\n float unaryOperation(float x) {\n ${t}\n }\n\n void main() {\n float x = getAAtOutCoords();\n float y = unaryOperation(x);\n\n setOutput(y);\n }\n `}}const Zn="if (isnan(x)) return x;",Xn="return abs(x);";const qn=Zn+"\n return (x < 0.0) ? 0.0 : x;\n",Qn=Zn+"\n return (x < 0.0) ? 0.0 : min(6.0, x);\n",Jn="return x;";class er{constructor(e,t){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=e,this.enableShapeUniforms=pe(this.outputShape.length),this.userCode=`\n vec4 unaryOperation(vec4 x) {\n ${t}\n }\n\n void main() {\n vec4 x = getAAtOutCoords();\n vec4 y = unaryOperation(x);\n\n setOutput(y);\n }\n `}}class tr{constructor(e){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!1,this.outputShape=e,this.enableShapeUniforms=pe(this.outputShape.length);const t=e.length,n=zn("rc",t),r=ae(t),a=function(e,t){if(1===e)return"rc";let n="";for(let r=0;r<e;r++)n+=t[r],r<e-1&&(n+=",");return n}(t,n),o=n.slice(-2),s=t<=1?"rc":`vec2(${o.join(",")})`;this.userCode=`\n void main() {\n ${r} rc = getOutputCoords();\n vec4 packedInput = getA(${a});\n\n setOutput(getChannel(packedInput, ${s}));\n }\n `}}const nr=a.kpo.YO,rr={};const ar=(0,a._K2)().getNumber("CPU_HANDOFF_SIZE_THRESHOLD");class or extends a.uI_{constructor(e){if(super(),this.pendingRead=new WeakMap,this.pendingDisposal=new WeakSet,this.dataRefCount=new WeakMap,this.numBytesInGPU=0,this.uploadWaitMs=0,this.downloadWaitMs=0,this.lastGlFlushTime=0,this.warnedAboutMemory=!1,this.pendingDeletes=0,this.disposed=!1,!(0,a._K2)().getBool("HAS_WEBGL"))throw new Error("WebGL is not supported on this device");let t;if(null!=e){if(e instanceof Ne)t=e;else{const n=i((0,a._K2)().getNumber("WEBGL_VERSION"),e);t=new Ne(n)}this.binaryCache={},this.gpgpuCreatedLocally=!1}else{const e=i((0,a._K2)().getNumber("WEBGL_VERSION"));t=new Ne(e),this.binaryCache=((n=(0,a._K2)().getNumber("WEBGL_VERSION"))in rr||(rr[n]={}),rr[n]),this.gpgpuCreatedLocally=!0}var n;this.gpgpu=t,this.canvas=this.gpgpu.gl.canvas,this.textureManager=new Gn(this.gpgpu),this.numMBBeforeWarning=null==(0,a._K2)().global.screen?1024:(0,a._K2)().global.screen.height*(0,a._K2)().global.screen.width*window.devicePixelRatio*600/1024/1024,this.texData=new a.GJx(this,(0,a.Hi9)())}nextDataId(){return or.nextDataId++}numDataIds(){return this.texData.numDataIds()-this.pendingDeletes}write(e,t,n){if(((0,a._K2)().getBool("WEBGL_CHECK_NUMERICAL_PROBLEMS")||(0,a._K2)().getBool("DEBUG"))&&this.checkNumericalProblems(e),"complex64"===n&&null!=e)throw new Error("Cannot write to a complex64 dtype. Please use tf.complex(real, imag).");const r={id:this.nextDataId()};return this.texData.set(r,{shape:t,dtype:n,values:e,usage:c.UPLOAD,refCount:1}),r}refCount(e){if(this.texData.has(e)){return this.texData.get(e).refCount}return 0}incRef(e){this.texData.get(e).refCount++}decRef(e){if(this.texData.has(e)){this.texData.get(e).refCount--}}move(e,t,n,r,o){if((0,a._K2)().getBool("DEBUG")&&this.checkNumericalProblems(t),"complex64"===r)throw new Error("Cannot write to a complex64 dtype. Please use tf.complex(real, imag).");this.texData.set(e,{shape:n,dtype:r,values:t,usage:c.UPLOAD,refCount:o})}disposeIntermediateTensorInfo(e){this.disposeData(e.dataId)}readSync(e){const t=this.texData.get(e),{values:n,dtype:r,complexTensorInfos:o,slice:s,shape:i,isPacked:u}=t;if(null!=s){let t;t=u?new er(i,Jn):new Yn(i,Jn);const n=this.runWebGLProgram(t,[{dataId:e,shape:i,dtype:r}],r),a=this.readSync(n.dataId);return this.disposeIntermediateTensorInfo(n),a}if(null!=n)return this.convertAndCacheOnCPU(e);if("string"===r)return n;const c=null!=this.activeTimers;let l,p;if(c&&(l=a.ZSL.now()),"complex64"===r){const e=this.readSync(o.real.dataId),t=this.readSync(o.imag.dataId);p=a.C0T.mergeRealAndImagArrays(e,t)}else p=this.getValuesFromTexture(e);return c&&(this.downloadWaitMs+=a.ZSL.now()-l),this.convertAndCacheOnCPU(e,p)}async read(e){if(this.pendingRead.has(e)){const t=this.pendingRead.get(e);return new Promise(e=>t.push(e))}const t=this.texData.get(e),{values:n,shape:r,slice:o,dtype:s,complexTensorInfos:i,isPacked:u}=t;if(null!=o){let t;t=u?new er(r,Jn):new Yn(r,Jn);const n=this.runWebGLProgram(t,[{dataId:e,shape:r,dtype:s}],s),a=this.read(n.dataId);return this.disposeIntermediateTensorInfo(n),a}if(null!=n)return this.convertAndCacheOnCPU(e);if((0,a._K2)().getBool("DEBUG")&&!(0,a._K2)().getBool("WEBGL_DOWNLOAD_FLOAT_ENABLED")&&2===(0,a._K2)().getNumber("WEBGL_VERSION"))throw new Error("tensor.data() with WEBGL_DOWNLOAD_FLOAT_ENABLED=false and WEBGL_VERSION=2 not yet supported.");let c,l,p=null;if("complex64"!==s&&(0,a._K2)().get("WEBGL_BUFFER_SUPPORTED")){c=this.decode(e);const t=this.texData.get(c.dataId);p=this.gpgpu.createBufferFromTexture(t.texture.texture,...h(r))}if(this.pendingRead.set(e,[]),"complex64"!==s&&await this.gpgpu.createAndWaitForFence(),"complex64"===s){const e=await Promise.all([this.read(i.real.dataId),this.read(i.imag.dataId)]),t=e[0],n=e[1];l=a.C0T.mergeRealAndImagArrays(t,n)}else if(null==p)l=this.getValuesFromTexture(e);else{const e=a.ZSL.sizeFromShape(r);l=this.gpgpu.downloadFloat32MatrixFromBuffer(p,e)}if(null!=c&&this.disposeIntermediateTensorInfo(c),null!=p){const e=this.gpgpu.gl;m(e,()=>e.deleteBuffer(p))}const d=this.convertAndCacheOnCPU(e,l),f=this.pendingRead.get(e);
2return this.pendingRead.delete(e),f.forEach(e=>e(d)),this.pendingDisposal.has(e)&&(this.pendingDisposal.delete(e),this.disposeData(e)&&(0,a.Hi9)().removeDataId(e,this),this.pendingDeletes--),d}readToGPU(e,t={}){const n=this.texData.get(e),{values:r,shape:o,slice:s,dtype:i,isPacked:u,texture:c}=n;if("complex64"===i)throw new Error("Does not support reading texture for complex64 dtype.");if(null!=s){let n;n=u?new er(o,Jn):new Yn(o,Jn);const r=this.runWebGLProgram(n,[{dataId:e,shape:o,dtype:i}],i),a=this.readToGPU(r,t);return this.disposeIntermediateTensorInfo(r),a}if(null==c)throw null!=r?new Error("Data is not on GPU but on CPU."):new Error("There is no data on GPU or CPU.");const l=this.decode(e,t.customTexShape),p=(0,a.Hi9)().makeTensorFromTensorInfo(l),h=this.texData.get(l.dataId);return Object.assign({tensorRef:p},h.texture)}bufferSync(e){const t=this.readSync(e.dataId);if("string"===e.dtype)try{const n=t.map(e=>a.ZSL.decodeString(e));return(0,a.ra8)(e.shape,e.dtype,n)}catch(e){throw new Error("Failed to decode encoded string bytes into utf-8")}return(0,a.ra8)(e.shape,e.dtype,t)}checkNumericalProblems(e){if(null!=e)for(let t=0;t<e.length;t++){const n=e[t];if(!g(n)){if((0,a._K2)().getBool("WEBGL_RENDER_FLOAT32_CAPABLE"))throw Error(`The value ${n} cannot be represented with your current settings. Consider enabling float32 rendering: 'tf.env().set('WEBGL_RENDER_FLOAT32_ENABLED', true);'`);throw Error(`The value ${n} cannot be represented on this device.`)}}}getValuesFromTexture(e){const{shape:t,dtype:n,isPacked:r}=this.texData.get(e),o=a.ZSL.sizeFromShape(t);if((0,a._K2)().getBool("WEBGL_DOWNLOAD_FLOAT_ENABLED")){const n=this.decode(e),r=this.texData.get(n.dataId),a=this.gpgpu.downloadMatrixFromPackedTexture(r.texture.texture,...h(t)).subarray(0,o);return this.disposeIntermediateTensorInfo(n),a}const s=(0,a._K2)().getBool("WEBGL_PACK")&&!0===r,i=s?A(t):t,u=s?new me(i):new fe(i),c=this.runWebGLProgram(u,[{shape:i,dtype:n,dataId:e}],"float32"),l=this.texData.get(c.dataId),p=this.gpgpu.downloadByteEncodedFloatMatrixFromOutputTexture(l.texture.texture,l.texShape[0],l.texShape[1]).subarray(0,o);return this.disposeIntermediateTensorInfo(c),p}timerAvailable(){return(0,a._K2)().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE")>0}time(e){const t=this.activeTimers,n=[];let r=!1;null==this.programTimersStack?(this.programTimersStack=n,r=!0):this.activeTimers.push(n),this.activeTimers=n,e();const o=a.ZSL.flatten(this.activeTimers.map(e=>e.query)).filter(e=>null!=e),s=a.ZSL.flatten(this.activeTimers.map(e=>e.name)).filter(e=>null!=e);this.activeTimers=t,r&&(this.programTimersStack=null);const i={uploadWaitMs:this.uploadWaitMs,downloadWaitMs:this.downloadWaitMs,kernelMs:null,wallMs:null};return(async()=>{if((0,a._K2)().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE")>0){const e=await Promise.all(o);i.kernelMs=a.ZSL.sum(e),i.getExtraProfileInfo=()=>e.map((e,t)=>({name:s[t],ms:e})).map(e=>`${e.name}: ${e.ms}`).join(", ")}else i.kernelMs={error:"WebGL query timers are not supported in this environment."};return this.uploadWaitMs=0,this.downloadWaitMs=0,i})()}memory(){return{unreliable:!1,numBytesInGPU:this.numBytesInGPU,numBytesInGPUAllocated:this.textureManager.numBytesAllocated,numBytesInGPUFree:this.textureManager.numBytesFree}}startTimer(){return(0,a._K2)().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE")>0?this.gpgpu.beginQuery():{startMs:a.ZSL.now(),endMs:null}}endTimer(e){return(0,a._K2)().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE")>0?(this.gpgpu.endQuery(),e):(e.endMs=a.ZSL.now(),e)}async getQueryTime(e){if((0,a._K2)().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE")>0)return this.gpgpu.waitForQueryAndGetTime(e);const t=e;return t.endMs-t.startMs}disposeData(e,t=!1){if(this.pendingDisposal.has(e))return!1;if(!this.texData.has(e))return!0;if(t?this.texData.get(e).refCount=0:this.texData.get(e).refCount--,!t&&this.texData.get(e).refCount>0)return!1;if(this.pendingRead.has(e))return this.pendingDisposal.add(e),this.pendingDeletes++,!1;this.releaseGPUData(e);const{complexTensorInfos:n}=this.texData.get(e);return null!=n&&(this.disposeData(n.real.dataId,t),this.disposeData(n.imag.dataId,t)),this.texData.delete(e),!0}releaseGPUData(e){const{texture:t,dtype:n,texShape:r,usage:a,isPacked:o,slice:s}=this.texData.get(e),i=s&&s.origDataId||e,u=this.dataRefCount.get(i);u>1?this.dataRefCount.set(i,u-1):(this.dataRefCount.delete(i),null!=t&&(this.numBytesInGPU-=this.computeBytes(r,n),this.textureManager.releaseTexture(t,r,a,o)));const c=this.texData.get(e);c.texture=null,c.texShape=null,c.isPacked=!1,c.slice=null}getTexture(e){return this.uploadToGPU(e),this.texData.get(e).texture.texture}getDataInfo(e){return this.texData.get(e)}shouldExecuteOnCPU(e,t=ar){return(0,a._K2)().getBool("WEBGL_CPU_FORWARD")&&e.every(e=>null==this.texData.get(e.dataId).texture&&a.ZSL.sizeFromShape(e.shape)<t)}getGPGPUContext(){return this.gpgpu}where(e){a.C0T.warn("tf.where() in webgl locks the UI thread. Call tf.whereAsync() instead");const t=e.dataSync();return nr(e.shape,t)}packedUnaryOp(e,t,n){const r=new er(e.shape,t),o=this.compileAndRun(r,[e],n);return(0,a.Hi9)().makeTensorFromTensorInfo(o)}abs(e){if(this.shouldExecuteOnCPU([e])&&"complex64"!==e.dtype){const t=kn(this.texData.get(e.dataId).values);return this.makeOutput(e.shape,e.dtype,t)}if((0,a._K2)().getBool("WEBGL_PACK_UNARY_OPERATIONS"))return this.packedUnaryOp(e,Xn,e.dtype);const t=new Yn(e.shape,Xn),n=this.compileAndRun(t,[e]);return(0,a.Hi9)().makeTensorFromTensorInfo(n)}makeTensorInfo(e,t,n){let r;if("string"===t&&null!=n&&n.length>0&&a.ZSL.isString(n[0])){const o=n.map(e=>a.ZSL.encodeString(e));r=this.write(o,e,t)}else r=this.write(n,e,t);return this.texData.get(r).usage=null,{dataId:r,shape:e,dtype:t}}makeOutput(e,t,n){return(0,a.Hi9)().makeTensorFromTensorInfo(this.makeTensorInfo(e,t,n),this)}unpackTensor(e){const t=new tr(e.shape);return this.runWebGLProgram(t,[e],e.dtype)}packTensor(e){const t=new Un(e.shape);return this.runWebGLProgram(t,[e],e.dtype,null,!0)}packedReshape(e,t){const n=[N(e.shape),...I(e.shape)],r={dtype:e.dtype,shape:n,dataId:e.dataId},a=[N(t),...I(t)],o=new Wn(a,n),s=[n],i=this.runWebGLProgram(o,[r],e.dtype,s,!0);return{dataId:i.dataId,shape:t,dtype:i.dtype}}decode(e,t){const n=this.texData.get(e),{isPacked:r,shape:o,dtype:s}=n;if(null!=t){const e=a.ZSL.sizeFromShape(o),n=t[0]*t[1]*4;a.ZSL.assert(e<=n,()=>"customTexShape is too small. Row * Column * 4 should be equal or larger than the size of the tensor data.")}const i=A(o);let u;u=r?new de(i):new he(i);const c=[null!=t?t:h(i)];return{dtype:s,shape:o,dataId:this.runWebGLProgram(u,[{shape:i,dtype:s,dataId:e}],s,c,!0,t).dataId}}runWebGLProgram(e,t,n,r,o=!1,s){const i=this.makeTensorInfo(e.outputShape,n),c=this.texData.get(i.dataId);if(e.packedOutput&&(c.isPacked=!0),e.outPackingScheme===u.DENSE){const t=null!=s?s:h(e.outputShape);c.texShape=t.map(e=>2*e)}if(null!=e.outTexUsage&&(c.usage=e.outTexUsage),0===a.ZSL.sizeFromShape(i.shape))return c.values=a.ZSL.getTypedArrayFromDType(i.dtype,0),i;const l=[],p=t.map(t=>{if("complex64"===t.dtype)throw new Error("GPGPUProgram does not support complex64 input. For complex64 dtypes, please separate the program into real and imaginary parts.");let n=this.texData.get(t.dataId);
2if(null==n.texture){if(!e.packedInputs&&a.ZSL.sizeFromShape(t.shape)<=(0,a._K2)().getNumber("WEBGL_SIZE_UPLOAD_UNIFORM"))return{shape:t.shape,texData:null,isUniform:!0,uniformValues:n.values};e.packedInputs&&(n.isPacked=!0,n.shape=t.shape)}if(this.uploadToGPU(t.dataId),!!n.isPacked!=!!e.packedInputs)t=n.isPacked?this.unpackTensor(t):this.packTensor(t),l.push(t),n=this.texData.get(t.dataId);else if(n.isPacked&&!_(n.shape,t.shape)){const e=t,r=t.shape;t.shape=n.shape,t=this.packedReshape(t,r),l.push(t),n=this.texData.get(t.dataId),e.shape=r}return{shape:t.shape,texData:n,isUniform:!1}});this.uploadToGPU(i.dataId);const d={shape:i.shape,texData:c,isUniform:!1},f=function(e,t,n){let r="";t.concat(n).forEach(t=>{const o=null!=t.texData&&null!=t.texData.slice&&t.texData.slice.flatOffset>0;if(e.enableShapeUniforms&&!t.isUniform){const s=t.texData.texShape,{useSqueezeShape:i,uniformShape:u,keptDims:c}=oe(e.packedInputs,t.shape,s);let l="",p="",h="";if(1===u.length&&e.packedInputs){const e=[Math.ceil(s[0]/2),Math.ceil(s[1]/2)];l=`${e[0]>1}_${e[1]>1}`}else if(2!==u.length||e.packedInputs){if(u.length>2&&!e.packedInputs){const e=a.ZSL.computeStrides(u);h=`${e[0]===s[1]}_${e[e.length-1]===s[1]}`}}else p=`${u[0]>1}_${u[1]>1}`;const d=t.shape.length,f=2===u.length&&a.ZSL.arraysEqual(t.shape,s),m=1===a.ZSL.sizeFromShape(t.shape),g=a.C0T.getBroadcastDims(t.shape,n.shape),y=!e.packedInputs&&d===n.shape.length&&a.ZSL.arraysEqual(s,n.texData.texShape),x=e.packedInputs||u.length>2?"":`${s[0]>1}_${s[1]>1}`;r+=`${d}_${y}_${i?c:""}_${u.length}_${m}_${g}_${f}_${l}_${p}_${h}_${x}_${o}`}else{const e=t.isUniform?"uniform":t.texData.texShape;r+=`${t.shape}_${e}_${o}`}});const o=e.userCode;let s=e.constructor.name;return s+="_"+r+"_"+o+`${(0,a._K2)().getNumber("WEBGL_VERSION")}`,s}(e,p,d),m=this.getAndSaveBinary(f,()=>ue(this.gpgpu,e,p,d)),g=null!=this.activeTimers;let y;g&&(y=this.startTimer()),(0,a._K2)().get("ENGINE_COMPILE_ONLY")||function(e,t,n,r,o){t.program.enableShapeUniforms||(le(t.inShapeInfos,n),le([t.outShapeInfo],[r]));const s=r.texData.texture,i=r.texData.texShape;r.texData.isPacked?e.setOutputPackedMatrixTexture(s.texture,i[0],i[1]):e.setOutputMatrixTexture(s.texture,i[0],i[1]),e.setProgram(t.webGLProgram),1===(0,a._K2)().getNumber("WEBGL_VERSION")&&null!==t.infLoc&&e.gl.uniform1f(t.infLoc,1/0),null!==t.nanLoc&&e.gl.uniform1f(t.nanLoc,NaN),n.forEach((n,r)=>{const o=t.program.variableNames[r],s=t.uniformLocations[o],i=t.uniformLocations[`offset${o}`],u=t.inShapesLocations[`${o}Shape`],c=t.inTexShapesLocations[`${o}TexShape`];if(u){const{uniformShape:r}=oe(t.program.packedInputs,n.shape,n.texData.texShape);switch(r.length){case 1:e.gl.uniform1iv(u,new Int32Array(r));break;case 2:e.gl.uniform2iv(u,new Int32Array(r));break;case 3:e.gl.uniform3iv(u,new Int32Array(r));break;case 4:e.gl.uniform4iv(u,new Int32Array(r))}}if(c&&e.gl.uniform2i(c,n.texData.texShape[0],n.texData.texShape[1]),null!=s)if(n.isUniform)if(a.ZSL.sizeFromShape(n.shape)<2)e.gl.uniform1f(s,n.uniformValues[0]);else{let t=n.uniformValues;t instanceof Float32Array||(t=new Float32Array(t)),e.gl.uniform1fv(s,t)}else null!=n.texData.slice&&null!=i&&e.gl.uniform1i(i,n.texData.slice.flatOffset),e.setInputMatrixTexture(n.texData.texture.texture,s,r)});const u=t.outShapeLocation;if(u)switch(r.shape.length){case 1:e.gl.uniform1iv(u,new Int32Array(r.shape));break;case 2:e.gl.uniform2iv(u,new Int32Array(r.shape));break;case 3:e.gl.uniform3iv(u,new Int32Array(r.shape));break;case 4:e.gl.uniform4iv(u,new Int32Array(r.shape))}if(t.outShapeStridesLocation){const n=a.ZSL.computeStrides(r.shape);switch(r.shape.length){case 2:e.gl.uniform1iv(t.outShapeStridesLocation,new Int32Array(n));break;case 3:e.gl.uniform2iv(t.outShapeStridesLocation,new Int32Array(n));break;case 4:e.gl.uniform3iv(t.outShapeStridesLocation,new Int32Array(n))}}t.outTexShapeLocation&&e.gl.uniform2i(t.outTexShapeLocation,r.texData.texShape[0],r.texData.texShape[1]),t.program.customUniforms&&o&&t.program.customUniforms.forEac
2h((n,r)=>{const a=t.customUniformLocations[r],s=o[r];if("float"===n.type)e.gl.uniform1fv(a,s);else if("vec2"===n.type)e.gl.uniform2fv(a,s);else if("vec3"===n.type)e.gl.uniform3fv(a,s);else if("vec4"===n.type)e.gl.uniform4fv(a,s);else if("int"===n.type)e.gl.uniform1iv(a,s);else if("ivec2"===n.type)e.gl.uniform2iv(a,s);else if("ivec3"===n.type)e.gl.uniform3iv(a,s);else{if("ivec4"!==n.type)throw Error(`uniform type ${n.type} is not supported yet.`);e.gl.uniform4iv(a,s)}}),e.executeProgram()}(this.gpgpu,m,p,d,r),l.forEach(e=>this.disposeIntermediateTensorInfo(e)),g&&(y=this.endTimer(y),this.activeTimers.push({name:e.constructor.name,query:this.getQueryTime(y)}));const x=(0,a._K2)().get("WEBGL_FLUSH_THRESHOLD");if(x>0){const e=a.ZSL.now();e-this.lastGlFlushTime>x&&(this.gpgpu.gl.flush(),this.lastGlFlushTime=e)}if(!(0,a._K2)().getBool("WEBGL_LAZILY_UNPACK")&&c.isPacked&&!1===o){const e=this.unpackTensor(i);return this.disposeIntermediateTensorInfo(i),e}return i}compileAndRun(e,t,n,r,a=!1){n=n||t[0].dtype;return this.runWebGLProgram(e,t,n,r,a)}getAndSaveBinary(e,t){return e in this.binaryCache||(this.binaryCache[e]=t()),this.binaryCache[e]}getTextureManager(){return this.textureManager}dispose(){if(!this.disposed){if(!(0,a._K2)().getBool("IS_TEST")){Object.keys(this.binaryCache).forEach(e=>{this.gpgpu.deleteProgram(this.binaryCache[e].webGLProgram),delete this.binaryCache[e]})}this.textureManager.dispose(),null!=this.canvas&&"undefined"!=typeof HTMLCanvasElement&&this.canvas instanceof HTMLCanvasElement?this.canvas.remove():this.canvas=null,this.gpgpuCreatedLocally&&(this.gpgpu.program=null,this.gpgpu.dispose()),this.disposed=!0}}floatPrecision(){return null==this.floatPrecisionValue&&(this.floatPrecisionValue=(0,a.DZQ)(()=>{if(!(0,a._K2)().get("WEBGL_RENDER_FLOAT32_ENABLED")){const e=(0,a._K2)().getBool("DEBUG");(0,a._K2)().set("DEBUG",!1);const t=this.abs((0,a.d_2)(1e-8)).dataSync()[0];if((0,a._K2)().set("DEBUG",e),t>0)return 32}return 16})),this.floatPrecisionValue}epsilon(){return 32===this.floatPrecision()?1e-7:1e-4}uploadToGPU(e){const t=this.texData.get(e),{shape:n,dtype:r,values:o,texture:s,usage:i,isPacked:u}=t;if(null!=s)return;const l=null!=this.activeTimers;let p;l&&(p=a.ZSL.now());let h=t.texShape;if(null==h&&(h=function(e,t=!1){let n=(0,a._K2)().getNumber("WEBGL_MAX_TEXTURE_SIZE"),r=(0,a._K2)().getNumber("WEBGL_MAX_SIZE_FOR_NARROW_TEXTURE");if(r===1/0&&(0,a._K2)().getBool("WEBGL_AUTO_SQUARIFY_NARROW_TEXTURE_SHAPE")&&(r=n/2),t&&(n*=2,r*=2,1===(e=e.map((t,n)=>n>=e.length-2?a.ZSL.nearestLargerEven(e[n]):e[n])).length&&(e=[2,e[0]])),2!==e.length){const t=a.ZSL.squeezeShape(e);e=t.newShape}let o=a.ZSL.sizeFromShape(e),s=null;e.length<=1&&o<=n?s=[1,o]:2===e.length&&e[0]<=n&&e[1]<=n?s=e:3===e.length&&e[0]*e[1]<=n&&e[2]<=n?s=[e[0]*e[1],e[2]]:3===e.length&&e[0]<=n&&e[1]*e[2]<=n?s=[e[0],e[1]*e[2]]:4===e.length&&e[0]*e[1]*e[2]<=n&&e[3]<=n?s=[e[0]*e[1]*e[2],e[3]]:4===e.length&&e[0]<=n&&e[1]*e[2]*e[3]<=n&&(s=[e[0],e[1]*e[2]*e[3]]);const i=null!=s&&Math.max(...s)>r&&Math.min(...s)<=(t?2:1)&&Math.min(...s)>0;if(null==s||i)if(t){const t=N(e);let n=2,r=2;e.length&&([n,r]=I(e)),o=t*(n/2)*(r/2),s=a.ZSL.sizeToSquarishShape(o).map(e=>2*e)}else s=a.ZSL.sizeToSquarishShape(o);return s}(n,u),t.texShape=h),null!=o){const e=A(n);let s,i=h[1],f=h[0];const m=o instanceof Uint8Array||o instanceof Uint8ClampedArray;!u&&m||([i,f]=d(h[0],h[1])),s=u?new ye(e,m):new ge(e,m);const g=m?[f,i]:h,y=this.makeTensorInfo(g,r),x=this.texData.get(y.dataId);x.usage=m?c.PIXELS:c.UPLOAD,x.texShape=g,this.gpgpu.uploadDenseMatrixToTexture(this.getTexture(y.dataId),i,f,o);const b=[[f,i]],v=!0,w=this.runWebGLProgram(s,[y],r,b,v),T=this.texData.get(w.dataId);t.texShape=T.texShape,t.isPacked=T.isPacked,t.usage=T.usage,(0,a._K2)().get("ENGINE_COMPILE_ONLY")?this.disposeData(w.dataId):(t.texture=T.texture,t.values=null,this.texData.delete(w.dataId)),this.disposeIntermediateTensorInfo(y),l&&(this.uploadWaitMs+=a.ZSL.now()-p)}else{const e=this.acquireTexture(h,i,r,u);t.texture=e}}convertAndCacheOnCPU(e,t){const n=this.texData.get(e),{dtype:r}=n;return this.releaseGPUData(e),null!=t&&(n.values=function(e,t){if("float32"===t||"complex64"===t)return e;if("int32"===t||"bool"===t){const n="int32"===t?new Int32Array(e.length):new Uint8Array(e.length);for(let t=0;t<n.length;++t)n[t]=Math.round(e[t]);return n}throw new Error(`Unknown dtype ${t}`)}(t,r)),n.values}acquireTexture(e,t,n,r){if(this.numBytesInGPU+=this.computeBytes(e,n),!this.warnedAboutMemory&&this.numBytesInGPU>1024*this.numMBBeforeWarning*1024){(this.numBytesInGPU/1024/1024).toFixed(2);this.warnedAboutMemory=!0}return this.textureManager.acquireTexture(e,t,r)}computeBytes(e,t){return e[0]*e[1]*a.ZSL.bytesPerElement(t)}checkCompileCompletion(){for(const[,e]of Object.entries(this.binaryCache))this.checkCompletion_(e)}async checkCompileCompletionAsync(){const e=[];
2if(this.gpgpu.parallelCompilationExtension){for(const[,t]of Object.entries(this.binaryCache))e.push(this.checkCompletionAsync_(t));return Promise.all(e)}for(const[,t]of Object.entries(this.binaryCache)){const n=new Promise(e=>{try{this.checkCompletion_(t),e(!0)}catch(e){throw e}});e.push(n)}return Promise.all(e)}async checkCompletionAsync_(e){return this.gpgpu.gl.getProgramParameter(e.webGLProgram,this.gpgpu.parallelCompilationExtension.COMPLETION_STATUS_KHR)?this.checkCompletion_(e):(await(0,a.dA1)(),this.checkCompletionAsync_(e))}checkCompletion_(e){if(!1===this.gpgpu.gl.getProgramParameter(e.webGLProgram,this.gpgpu.gl.LINK_STATUS)){if(!1===this.gpgpu.gl.getShaderParameter(e.fragmentShader,this.gpgpu.gl.COMPILE_STATUS))throw b(e.source,this.gpgpu.gl.getShaderInfoLog(e.fragmentShader)),new Error("Failed to compile fragment shader.");throw new Error("Failed to link vertex and fragment shaders.")}return!0}getUniformLocations(){for(const[,e]of Object.entries(this.binaryCache)){const{uniformLocations:t,customUniformLocations:n,infLoc:r,nanLoc:a,inShapesLocations:o,inTexShapesLocations:s,outShapeLocation:i,outShapeStridesLocation:u,outTexShapeLocation:c}=ce(this.gpgpu,e.program,e.webGLProgram);e.uniformLocations=t,e.customUniformLocations=n,e.infLoc=r,e.nanLoc=a,e.inShapesLocations=o,e.inTexS
2hapesLocations=s,e.outShapeLocation=i,e.outShapeStridesLocation=u,e.outTexShapeLocation=c}}}or.nextDataId=0,a.eMq.isBrowser()&&(0,a.gJX)("webgl",()=>new or,2);const sr="\n if (isnan(a)) return a;\n if (isnan(b)) return b;\n";class ir{constructor(e,t,n){this.variableNames=["A","B"],this.outputShape=a.C0T.assertAndGetBroadcastShape(t,n),this.enableShapeUniforms=pe(this.outputShape.length),this.userCode=`\n float binaryOperation(float a, float b) {\n ${e}\n }\n\n void main() {\n float a = getAAtOutCoords();\n float b = getBAtOutCoords();\n setOutput(binaryOperation(a, b));\n }\n `}}const ur="\n result.r = isNaN.r ? NAN : result.r;\n result.g = isNaN.g ? NAN : result.g;\n result.b = isNaN.b ? NAN : result.b;\n result.a = isNaN.a ? NAN : result.a;\n";class cr{constructor(e,t,n,r=!1){this.variableNames=["A","B"],this.supportsBroadcasting=!0,this.packedInputs=!0,this.packedOutput=!0,this.outputShape=a.C0T.assertAndGetBroadcastShape(t,n);const o=this.outputShape.length;this.enableShapeUniforms=pe(o);let s="";if(r)if(0===o||1===a.ZSL.sizeFromShape(this.outputShape))s="\n result.y = 0.;\n result.z = 0.;\n result.w = 0.;\n ";else{if(s=`\n ${ae(o)} coords = getOutputCoords();\n `,1===o)this.enableShapeUniforms?s+="\n result.y = (coords + 1) >= outShape ? 0. : result.y;\n result.z = 0.;\n result.w = 0.;\n ":s+=`\n result.y = (coords + 1) >= ${this.outputShape[0]} ? 0. : result.y;\n result.z = 0.;\n result.w = 0.;\n `;else{const e=zn("coords",o);this.enableShapeUniforms?s+=`\n bool nextRowOutOfBounds =\n (${e[o-2]} + 1) >= outShape[${o} - 2];\n bool nextColOutOfBounds =\n (${e[o-1]} + 1) >= outShape[${o} - 1];\n result.y = nextColOutOfBounds ? 0. : result.y;\n result.z = nextRowOutOfBounds ? 0. : result.z;\n result.w = nextColOutOfBounds || nextRowOutOfBounds ? 0. : result.w;\n `:s+=`\n bool nextRowOutOfBounds =\n (${e[o-2]} + 1) >= ${this.outputShape[o-2]};\n bool nextColOutOfBounds =\n (${e[o-1]} + 1) >= ${this.outputShape[o-1]};\n result.y = nextColOutOfBounds ? 0. : result.y;\n result.z = nextRowOutOfBounds ? 0. : result.z;\n result.w = nextColOutOfBounds || nextRowOutOfBounds ? 0. : result.w;\n `}}this.userCode=`\n vec4 binaryOperation(vec4 a, vec4 b) {\n ${e}\n }\n\n void main() {\n vec4 a = getAAtOutCoords();\n vec4 b = getBAtOutCoords();\n\n vec4 result = binaryOperation(a, b);\n ${s}\n\n setOutput(result);\n }\n `}}function lr(e){const{inputs:t,backend:n}=e,{x:r}=t;return n.incRef(r.dataId),{dataId:r.dataId,shape:r.shape,dtype:r.dtype}}const pr={kernelName:a.lzr,backendName:"webgl",kernelFunc:lr};function hr(e){const{inputs:t,backend:n}=e,{real:r,imag:a}=t,o=n.makeTensorInfo(r.shape,"complex64"),s=n.texData.get(o.dataId),i=lr({inputs:{x:r},backend:n}),u=lr({inputs:{x:a},backend:n});return s.complexTensorInfos={real:i,imag:u},o}const dr={kernelName:a.pr3,backendName:"webgl",kernelFunc:hr},fr="return (a < 0.) ? b * a : a;",mr="\n vec4 aLessThanZero = vec4(lessThan(a, vec4(0.)));
2\n return (aLessThanZero * (b * a)) + ((vec4(1.0) - aLessThanZero) * a);\n";const gr={kernelName:a.X0$,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:o}=t,{alpha:s}=r,i=n.makeTensorInfo([],"float32",a.ZSL.createScalarValue(s,"float32")),u=(0,a._K2)().getBool("WEBGL_PACK_BINARY_OPERATIONS")?new cr(mr,o.shape,i.shape):new ir(fr,o.shape,i.shape),c=n.runWebGLProgram(u,[o,i],"float32");return n.disposeIntermediateTensorInfo(i),c}},yr="return (a < 0.) ? b * a : a;",xr="\n vec4 aLessThanZero = vec4(lessThan(a, vec4(0.)));\n return (aLessThanZero * (b * a)) + ((vec4(1.0) - aLessThanZero) * a);\n";const br={kernelName:a.Ncv,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n}=e,{x:r,alpha:o}=t,s=(0,a._K2)().getBool("WEBGL_PACK_BINARY_OPERATIONS")?new cr(xr,r.shape,o.shape):new ir(yr,r.shape,o.shape);return n.runWebGLProgram(s,[r,o],"float32")}},vr="if (isnan(x)) return x;";function wr({opSnippet:e,packedOpSnippet:t,cpuKernelImpl:n,dtype:r}){return({inputs:o,backend:s})=>{const{x:i}=o,u=s,c=r||i.dtype;if(u.shouldExecuteOnCPU([i])&&null!=n){const e=u.texData.get(i.dataId),t=n(e.values,c);return u.makeTensorInfo(i.shape,c,t)}let l;return l=(0,a._K2)().getBool("WEBGL_PACK_UNARY_OPERATIONS")&&null!=t?new er(i.shape,t):new Yn(i.shape,e),u.runWebGLProgram(l,[i],c)}}function Tr({opSnippet:e,packedOpSnippet:t,checkOutOfBounds:n=!1,supportsComplex:r=!1,cpuKernelImpl:o,dtype:s}){return({inputs:i,backend:u})=>{const{a:c,b:l}=i,p=u;if(r&&"complex64"===c.dtype){const t=p.texData.get(c.dataId),n=p.texData.get(l.dataId),[r,o]=[[t.complexTensorInfos.real,n.complexTensorInfos.real],[t.complexTensorInfos.imag,n.complexTensorInfos.imag]].map(t=>{const[n,r]=t,o={dataId:n.dataId,dtype:n.dtype,shape:c.shape},s={dataId:r.dataId,dtype:r.dtype,shape:l.shape},i=new ir(e,c.shape,l.shape);return p.runWebGLProgram(i,[o,s],(0,a.TuY)(n.dtype,r.dtype))}),s=hr({inputs:{real:r,imag:o},backend:p});return p.disposeIntermediateTensorInfo(r),p.disposeIntermediateTensorInfo(o),s}const h=s||(0,a.TuY)(c.dtype,l.dtype);if(("string"===c.dtype||"string"===l.dtype||p.shouldExecuteOnCPU([c,l]))&&null!=o){const e=p.texData.get(c.dataId).values,t=p.texData.get(l.dataId).values,n="string"===c.dtype?a.C0T.fromUint8ToStringArray(e):e,r="string"===c.dtype?a.C0T.fromUint8ToStringArray(t):t,[s,i]=o(c.shape,l.shape,n,r,h),u=p.makeTensorInfo(i,h);return p.texData.get(u.dataId).values=s,u}let d;return d=(0,a._K2)().getBool("WEBGL_PACK_BINARY_OPERATIONS")&&null!=t?new cr(t,c.shape,l.shape,n):new ir(e,c.shape,l.shape),p.runWebGLProgram(d,[c,l],h)}}function Sr(e,t=!1){if("linear"===e)return"return x;";if("relu"===e)return t?"\n vec4 result = x * vec4(greaterThanEqual(x, vec4(0.0)));\n bvec4 isNaN = isnan(x);\n\n result.r = isNaN.r ? x.r : result.r;\n result.g = isNaN.g ? x.g : result.g;\n result.b = isNaN.b ? x.b : result.b;\n result.a = isNaN.a ? x.a : result.a;\n\n return result;\n":qn;if("elu"===e)return t?"\n vec4 result;\n\n result.r = (x.r >= 0.0) ? x.r : (exp(x.r) - 1.0);\n result.g = (x.g >= 0.0) ? x.g : (exp(x.g) - 1.0);\n result.b = (x.b >= 0.0) ? x.b : (exp(x.b) - 1.0);\n result.a = (x.a >= 0.0) ? x.a : (exp(x.a) - 1.0);\n\n return result;\n":"return (x >= 0.0) ? x : (exp(x) - 1.0);";if("relu6"===e)return t?"\n vec4 result = min(x, vec4(6.)) * vec4(greaterThanEqual(x, vec4(0.0)));\n bvec4 isNaN = isnan(x);\n\n result.r = isNaN.r ? x.r : result.r;\n result.g = isNaN.g ? x.g : result.g;\n result.b = isNaN.b ? x.b : result.b;\n result.a = isNaN.a ? x.a : result.a;\n\n return result;\n":Qn;if("prelu"===e)return t?xr:yr;if("leakyrelu"===e)return t?mr:fr;if("sigmoid"===e)return"return 1.0 / (1.0 + exp(-1.0 * x));";throw new Error(`Activation ${e} has not been implemented for the WebGL backend.`)}class Cr{constructor(e,t,n,r=!1,a=!1,o=!1,s=null,i=!1,u=!1){this.variableNames=["matrixA","matrixB"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=n,this.enableShapeUniforms=pe(this.outputShape.length);const c=r?e[1]:e[2],l=Math.ceil(c/2),p=r?"i * 2, rc.y":"rc.y, i * 2",h=a?"rc.z, i * 2":"i * 2, rc.z",d=r?["a.xxyy","a.zzww"]:["a.xxzz","a.yyww"],f=a?["b.xzxz","b.
2ywyw"]:["b.xyxy","b.zwzw"];let m="",g="";s&&(m=i?`vec4 activation(vec4 a) {\n vec4 b = getPreluActivationWeightsAtOutCoords();\n ${s}\n }`:u?`vec4 activation(vec4 a) {\n vec4 b = getLeakyreluAlphaAtOutCoords();\n ${s}\n }`:`vec4 activation(vec4 x) {\n ${s}\n }`,g="result = activation(result);");const y=o?"result += getBiasAtOutCoords();":"";o&&this.variableNames.push("bias"),i&&this.variableNames.push("preluActivationWeights"),u&&this.variableNames.push("leakyreluAlpha");let x="rc.x",b="rc.x";e[0]<t[0]?x=`int(min(float(rc.x), ${e[0]-1}.))`:t[0]<e[0]&&(b=`int(min(float(rc.x), ${t[0]-1}.))`),this.userCode=`\n ${m}\n // Don't use uniform for sharedDimensionPacked for performance.\n const float sharedDimension = ${l}.0;\n\n vec4 dot2x2ARowBCol(ivec3 rc) {\n vec4 result = vec4(0);\n for (int i = 0; i < ${l}; i++) {\n int batchA = ${x};\n int batchB = ${b};\n vec4 a = getMatrixA(batchA, ${p});\n vec4 b = getMatrixB(batchB, ${h});\n\n // These swizzled products need to be separately added.\n // See: https://github.com/tensorflow/tfjs/issues/1735\n result += (${d[0]} * ${f[0]});\n result += (${d[1]} * ${f[1]});\n }\n return result;\n }\n\n void main() {\n ivec3 rc = getOutputCoords();\n vec4 result = dot2x2ARowBCol(rc);\n\n ${y}\n\n ${g}\n\n setOutput(result);\n }\n `}}const kr="return areal * breal - aimag * bimag;",Er="return areal * bimag + aimag * breal;";class $r{constructor(e,t,n){this.variableNames=["AReal","AImag","BReal","BImag"],this.outputShape=a.C0T.assertAndGetBroadcastShape(t,n),this.userCode=`\n float binaryOpComplex(\n float areal, float aimag, float breal, float bimag) {\n ${e}\n }\n\n void main() {\n float areal = getARealAtOutCoords();\n float aimag = getAImagAtOutCoords();\n float breal = getBRealAtOutCoords();\n float bimag = getBImagAtOutCoords();\n setOutput(binaryOpComplex(areal, aimag, breal, bimag));\n }\n `}}const Nr="return a * b;";function Ir(e){const{inputs:t,backend:n}=e,{a:r,b:o}=t,s=a.C0T.upcastType(r.dtype,o.dtype);if("complex64"===r.dtype){const e=n.texData.get(r.dataId),t=n.texData.get(o.dataId),a=new $r(kr,r.shape,o.shape),s=new $r(Er,r.shape,o.shape),i=[{dataId:e.complexTensorInfos.real.dataId,dtype:e.complexTensorInfos.real.dtype,shape:r.shape},{dataId:e.complexTensorInfos.imag.dataId,dtype:e.complexTensorInfos.imag.dtype,shape:r.shape},{dataId:t.complexTensorInfos.real.dataId,dtype:t.complexTensorInfos.real.dtype,shape:o.shape},{dataId:t.complexTensorInfos.imag.dataId,dtype:t.complexTensorInfos.imag.dtype,shape:o.shape}],u=n.runWebGLProgram(a,i,"float32"),c=n.runWebGLProgram(s,i,"float32"),l=hr({inputs:{real:u,imag:c},backend:n});return n.disposeIntermediateTensorInfo(u),n.disposeIntermediateTensorInfo(c),l}if(n.shouldExecuteOnCPU([r,o])){const e=n.texData.get(r.dataId),t=n.texData.get(o.dataId),[a,i]=mn(r.shape,o.shape,e.values,t.values,s),u=n.makeTensorInfo(i,s);return n.texData.get(u.dataId).values=a,u}let i;return i=(0,a._K2)().getBool("WEBGL_PACK_BINARY_OPERATIONS")?new cr(Nr,r.shape,o.shape):new ir(Nr,r.shape,o.shape),n.runWebGLProgram(i,[r,o],s)}const Ar={kernelName:a.xu7,backendName:"webgl",kernelFunc:Ir};function Rr(e){const{inputs:t,backend:n,attrs:r}=e,{x:o}=t,{shape:s}=r,i=n,u=a.ZSL.sizeFromShape(o.shape),c=a.ZSL.inferFromImplicitShape(s,u),l=a.ZSL.sizeFromShape(c);a.ZSL.assert(u===l,()=>`The new shape (${c}) has ${l} elements and the old shape (${o.shape}) has ${u} elements. The new shape and old shape must have the same number of elements.`);const p=i.texData.get(o.dataId);return!p.isPacked||_(o.shape,c)||null!==p.texture&&_(p.shape,c)?(i.incRef(o.dataId),{dataId:o.dataId,shape:c,dtype:o.dtype}):function(e,t,n){const r=[N(e.shape),...I(e.shape)],a={dtype:e.dtype,shape:r,dataId:e.dataId},o=[N(t),...I(t)],s=new Wn(o,r),i=[r],u=n.runWebGLProgram(s,[a],e.dtype,i,!0);return{dataId:u.dataId,shape:t,dtype:u.dtype}}(o,c,i)}const _r={kernelName:a.R23,backendName:"webgl",kernelFunc:Rr};class Or{constructor(e,t){this.variableNames=["x"];const{windowSize:n,batchSize:r,inSize:o,outSize:s}=e;this.outputShape=[r,s];const i=4*Math.floor(n/4),u=n%4;let c="sumValue += dot(values, ones);";if(null!=t){const e=1/t;c=`sumValue += dot(values * ${a.ZSL.isInt(e)?e.toPrecision(2):e}, ones);`}let l="";o%n>0&&(l=`\n if (inIdx < 0 || inIdx >= ${o}) {\n return 0.0;\n }\n `),this.userCode=`\n const vec4 ones = vec4(1.0, 1.0, 1.0, 1.0);\n\n float getValue(int batch, int inIdx) {\n ${l}\n return getX(batch, inIdx);\n }\n\n void main() {\n ivec2 coords = getOutputCoords();\n int batch = coords[0];\n int outIdx = coords[1];\n int inOffset = outIdx * ${n};\n\n float sumValue = 0.0;\n\n for (int i = 0; i < ${i}; i += 4) {\n int inIdx = inOffset + i;\n vec4 values = vec4(\n getValue(batch, inIdx),\n getValue(batch, inIdx + 1),\n getValue(batch, inIdx + 2),\n getValue(batch, inIdx + 3)\n );\n\n ${c}\n }\n\n int inIdx = inOffset + ${i};\n if (${1===u}) {\n vec4 values = vec4(getValue(batch, inIdx), 0.0, 0.0, 0.0);\n\n ${c}\n } else if (${2===u}) {\n vec4 values = vec4(\n getValue(batch, inIdx),\n getValue(batch, inIdx + 1), 0.0, 0.0);\n\n ${c}\n } else if (${3===u}) {\n vec4 values = vec4(\n getValue(batch, inIdx),\n getValue(batch, inIdx + 1),\n getValue(batch, inIdx + 2), 0.0);\n\n ${c}\n }\n setOutput(sumValue);\n }\n `}}class Fr{constructor(e,t){this.variableNames=["x"];const{windowSize:n,batchSize:r,inSize:a,outSize:o}=e;this.outputShape=[r,o];let s="0.0",i="";"prod"===t?s="1.0":"min"===t?(s="1.0 / 1e-20",i="min"):"max"===t&&(s="-1.0 / 1e-20",i="max");let u=`${t}(${t}(${t}(minMaxValue[0], minMaxValue[1]), minMaxValue[2]), minMaxValue[3])`;"sum"===t?u="sumValue":"prod"===t?u="prodValue":"all"===t?u="allValue":"any"===t&&(u="anyValue");const c=4*Math.floor(n/4),l=n%4;let p=`\n if (${"sum"===t}) {\n sumValue += dot(values, ones);\n } else if (${"prod"===t}) {\n vec2 tmp = vec2(values[0], values[1]) * vec2(values[2], values[3]);\n prodValue *= tmp[0] * tmp[1];\n } else {\n minMaxValue = ${i}(values, minMaxValue);\n if (${"min"===t} || ${"max"===t}) {\n minMaxValue = ${i}(values, minMaxValue);\n bvec4 isNaN = isnan(values);\n if (isNaN.r || isNaN.g || isNaN.b || isNaN.a) {\n minMaxValue = vec4(NAN);\n }\n }\n }\n `,h="vec4";"all"===t?(s="1.0",p="\n bool reducedAllValue = all(values);\n float floatedReducedAllValue = float(reducedAllValue);\n allValue = float(allValue >= 1.0 && floatedReducedAllValue >= 1.0);\n ",h="bvec4"):"any"===t&&(s="0.0",p="\n bool reducedAnyValue = any(values);\n float floatedReducedAnyValue = float(reducedAnyValue);\n anyValue = float(anyValue >= 1.0 || floatedReducedAnyValue >= 1.0);\n ",h="bvec4");let d="";a%n>0&&(d=`\n if (inIdx < 0 || inIdx >= ${a}) {\n return initializationValue;\n }\n `),this.userCode=`\n const float initializationValue = ${s};\n const vec4 ones = vec4(1.0, 1.0, 1.0, 1.0);\n\n float getValue(int batch, int inIdx) {\n ${d}\n return getX(batch, inIdx);\n }\n\n void main() {\n ivec2 coords = getOutputCoords();\n int batch = coords[0];\n int outIdx = coords[1];\n int inOffset = outIdx * ${n};\n\n vec4 minMaxValue = vec4(${s});\n float prodValue = 1.0;\n float sumValue = 0.0;\n float allValue = 1.0;\n float anyValue = 0.0;\n\n for (int i = 0; i < ${c}; i += 4) {\n int inIdx = inOffset + i;\n ${h} values = ${h}(\n getValue(batch, inIdx),\n getValue(batch, inIdx + 1),\n getValue(batch, inIdx + 2),\n getValue(batch, inIdx + 3)\n );\n\n ${p}\n }\n\n int inIdx = inOffset + ${c};\n if (${1===l}) {\n ${h} values = ${h}(\n getValue(batch, inIdx),\n initializationValue,\n initializationValue,\n initializationValue\n );\n\n ${p}\n } else if (${2===l}) {\n ${h} values = ${h}(\n getValue(batch, inIdx),\n getValue(batch, inIdx + 1),\n initializationValue,\n initializationValue\n );\n\n ${p}\n } else if (${3===l}) {\n ${h} values = ${h}(\n getValue(batch, inIdx),\n getValue(batch, inIdx + 1),\n getValue(batch, inIdx + 2),\n initializationValue\n );\n\n ${p}\n }\n setOutput(${u});\n }\n `}}function Dr(e,t,n,r){const o=function(e){const t=[];for(;0===t.length||1!==t[t.length-1].outSize;){const n=t.length?t[t.length-1].outSize:e[1],r=a.C0T.computeOptimalWindowSize(n);t.push({inSize:n,windowSize:r,outSize:Math.ceil(n/r)})}return t}(e.shape);let s=e;for(let a=0;a<o.length;a++){const{inSize:i,windowSize:u,outSize:c}=o[a];let l,p;l="mean"===n?0===a?new Or({windowSize:u,inSize:i,batchSize:e.shape[0],outSize:c},i):new Or({windowSize:u,inSize:i,batchSize:e.shape[0],outSize:c}):new Fr({windowSize:u,inSize:i,batchSize:e.shape[0],outSize:c},n),p=s,s=r.runWebGLProgram(l,[s],t),p.dataId!==e.dataId&&r.disposeIntermediateTensorInfo(p)}return s}class Lr{constructor(e,t){this.variableNames=["A"];const n=new Array(e.length);for(let r=0;r<n.length;r++)n[r]=e[t[r]];this.outputShape=n,this.rank=n.length;const r=ae(this.rank),a=function(e){const t=e.length;if(t>6)throw Error(`Transpose for rank ${t} is not yet supported`);const n=["resRC.x","resRC.y","resRC.z","resRC.w","resRC.u","resRC.v"],r=new Array(t);for(let t=0;t<e.length;t++)r[e[t]]=n[t];return r.join()}(t);this.userCode=`\n void main() {\n ${r} resRC = getOutputCoords();\n setOutput(getA(${a}));\n }\n `}}class Mr{constructor(e,t){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0;const n=new Array(e.length);for(let r=0;r<n.length;r++)n[r]=e[t[r]];if(this.outputShape=n,this.rank=n.length,this.rank>6)throw Error(`Packed transpose for rank ${this.rank} is not yet supported.`);const r=ae(this.rank),a=Vn("rc",this.rank),o=new Array(this.rank);for(let e=0;e<t.length;e++)o[t[e]]=a[e];const s=`vec2(${o.slice(-2).join()})`,i=`++${a[this.rank-1]} < ${n[this.rank-1]}`,u=`getChannel(getA(${o.join()}), ${s})`;this.userCode=`\n void main() {\n ${r} rc = getOutputCoords();\n vec4 result = vec4(0.);\n result[0] = ${u};\n if(${i}) {\n result[1] = ${u};\n }\n --${a[this.rank-1]};\n if(++${a[this.rank-2]} < ${n[this.rank-2]}) {\n result[2] = ${u};\n if(${i}) {\n result[3] = ${u};\n }\n }\n setOutput(result);\n }\n `}}function Pr(e,t,n){const r=(0,a._K2)().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new Mr(e.shape,t):new Lr(e.shape,t);return n.runWebGLProgram(r,[e],e.dtype)}function Br(e){const{inputs:t,backend:n,attrs:r}=e,{x:o}=t,{axis:s,keepDims:i}=r;return function(e,t,n,r){const o=t,s=e.shape.length,i=a.ZSL.parseAxisParam(o,e.shape);let u=i;const c=a.C0T.getAxesPermutation(u,s),l=null!=c;let p=e;l&&(p=Pr(e,c,r),u=a.C0T.getInnerMostAxes(u.length,s)),a.C0T.assertAxesAreInnerMostDims("sum",u,s);const[h,d]=a.C0T.computeOutAndReduceShapes(p.shape,u);let f=h;n&&(f=a.C0T.expandShapeToKeepDim(h,i));const m=a.ZSL.sizeFromShape(d),g=Rr({inputs:{x:p},attrs:{shape:[a.ZSL.sizeFromShape(e.shape)/m,m]},backend:r}),y=Dr(g,(0,a.chL)(e.dtype),"sum",r),x=Rr({inputs:{x:y},attrs:{shape:f},backend:r});return r.disposeIntermediateTensorInfo(g),r.disposeIntermediateTensorInfo(y),l&&r.disposeIntermediateTensorInfo(p),x}(o,s,i,n)}const Vr={kernelName:a.WuN,backendName:"webgl",kernelFunc:Br};function zr(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{perm:o}=r,s=n,i=a.shape.length,u=new Array(i);for(let e=0;e<u.length;e++)u[e]=a.shape[o[e]];let c;if(s.shouldExecuteOnCPU([a])){const e=s.texData.get(a.dataId).values,t=Pn(e,a.shape,a.dtype,o,u);c=s.makeTensorInfo(u,a.dtype);s.texData.get(c.dataId).values=t}else c=Pr(a,o,s);return c}const Ur={kernelName:a.wx0,backendName:"webgl",kernelFunc:zr};function Wr({a:e,b:t,transposeA:n,transposeB:r,backend:o,bias:s=null,preluActivationWeights:i=null,leakyreluAlpha:u=0,activation:c=null}){const l=e.shape.length,p=t.shape.length,h=n?e.shape[l-2]:e.shape[l-1],d=r?t.shape[p-1]:t.shape[p-2],f=n?e.shape[l-1]:e.shape[l-2],m=r?t.shape[p-2]:t.shape[p-1],g=e.shape.slice(0,-2),y=t.shape.slice(0,-2),x=a.ZSL.sizeFromShape(g),b=
2a.ZSL.sizeFromShape(y),v=a.ZEY.assertAndGetBroadcastShape(e.shape.slice(0,-2),t.shape.slice(0,-2)).concat([f,m]);a.ZSL.assert(h===d,()=>`Error in matMul: inner shapes (${h}) and (${d}) of Tensors with shapes ${e.shape} and ${t.shape} and transposeA=${n} and transposeB=${r} must match.`);const w=n?[x,h,f]:[x,f,h],T=r?[b,m,d]:[b,d,m],S=Rr({inputs:{x:e},backend:o,attrs:{shape:w}}),C=Rr({inputs:{x:t},backend:o,attrs:{shape:T}}),k=[S,C],E=Math.max(x,b),$=n?S.shape[1]:S.shape[2],N=null!=s,I=null!=i,A="leakyrelu"===c,R=null!=c?Sr(c,!0):null;let _;if((1===f||1===m)&&$>1e3&&!1===(N||I||A||null!=R)){let e=S,t=C;n&&(e=zr({inputs:{x:S},backend:o,attrs:{perm:[0,2,1]}}),k.push(e)),r&&(t=zr({inputs:{x:C},backend:o,attrs:{perm:[0,2,1]}}),k.push(t));const a=1===m;let s=e;1!==m&&(s=Rr({inputs:{x:e},backend:o,attrs:{shape:[E,$,1]}}),k.push(s));const i=1===m?2:1;let u=t;a&&(u=Rr({inputs:{x:t},backend:o,attrs:{shape:[E,1,$]}}),k.push(u));const c=Ir({inputs:{a:s,b:u},backend:o});_=Br({inputs:{x:c},backend:o,attrs:{axis:i,keepDims:!0}}),k.push(c)}else{const c=(0,a.TuY)(e.dtype,t.dtype),l=new Cr(w,T,[E,f,m],n,r,N,R,I,A),p=[S,C];if(null!=s&&p.push(s),I&&p.push(i),A){const e=o.makeTensorInfo([],"float32",a.ZSL.createScalarValue(u,"float32"));p.push(e),k.push(e)}_=o.runWebGLProgram(l,p,c)}const O=Rr({inputs:{x:_},backend:o,attrs:{shape:v}});k.push(_);for(const e of k)o.disposeIntermediateTensorInfo(e);return O}const Gr={kernelName:a.Dr,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{a:a,b:o,bias:s,preluActivationWeights:i}=t,{transposeA:u,transposeB:c,activation:l,leakyreluAlpha:p}=r;return Wr({a:a,b:o,transposeA:u,transposeB:c,backend:n,bias:s,preluActivationWeights:i,leakyreluAlpha:p,activation:l})}},jr="return abs(x);";const Kr={kernelName:a.ljI,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n}=e,{x:r}=t;if(n.shouldExecuteOnCPU([r])&&"complex64"!==r.dtype){const e=n.texData.get(r.dataId),t=kn(e.values);return n.makeTensorInfo(r.shape,r.dtype,t)}let o;return o=(0,a._K2)().getBool("WEBGL_PACK_UNARY_OPERATIONS")?new er(r.shape,jr):new Yn(r.shape,jr),n.runWebGLProgram(o,[r],r.dtype)}},Hr=wr({opSnippet:Zn+"\n if (abs(x) > 1.) {\n return NAN;\n }\n return acos(x);\n"}),Yr={kernelName:a.Vvy,backendName:"webgl",kernelFunc:Hr},Zr=wr({opSnippet:Zn+"\n if (x < 1.0) return NAN;\nreturn log(x + sqrt(x * x - 1.0));"}),Xr={kernelName:a.PH8,backendName:"webgl",kernelFunc:Zr},qr="return a + b;",Qr=Tr({opSnippet:qr,packedOpSnippet:qr,supportsComplex:!0,cpuKernelImpl:Ht}),Jr={kernelName:a.OMN,backendName:"webgl",kernelFunc:Qr};class ea{constructor(e,t){this.outputShape=[],this.outputShape=e,this.variableNames=t.map((e,t)=>`T${t}`);const n=[];this.variableNames.forEach(e=>{n.push(`float v${e} = get${e}AtOutCoords();`)});const r=this.variableNames.map(e=>`v${e}`).join(" + ");this.userCode=`\n void main() {\n ${n.join("\n ")}\n\n float result = ${r};\n setOutput(result);\n }\n `}}class ta{constructor(e,t){this.outputShape=[],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=e,this.variableNames=t.map((e,t)=>`T${t}`);const n=[];this.variableNames.forEach(e=>{n.push(`vec4 v${e} = get${e}AtOutCoords();`)});const r=this.variableNames.map(e=>`v${e}`).join(" + ");this.userCode=`\n void main() {\n ${n.join("\n ")}\n\n vec4 result = ${r};\n setOutput(result);\n }\n `}}const na={kernelName:a.EkD,backendName:"webgl",kernelFunc:function e(t){const{inputs:n,backend:r}=t,o=n;if(1===o.length)return lr({inputs:{x:o[0]},backend:r});if(o.length>(0,a._K2)().get("WEBGL_MAX_TEXTURES_IN_SHADER")){const t=Math.floor(o.length/2),n=e({
2inputs:o.slice(0,t),backend:r}),a=e({inputs:o.slice(t),backend:r});return e({inputs:[n,a],backend:r})}const s=o.map(e=>e.dtype).reduce((e,t)=>(0,a.TuY)(e,t)),i=o.map(e=>e.shape),u=(0,a._K2)().getBool("WEBGL_PACK")?new ta(o[0].shape,i):new ea(o[0].shape,i);return r.runWebGLProgram(u,o,s)}};const ra={kernelName:a.u8Z,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:o}=t,{axis:s,keepDims:i}=r,u=o.shape.length,c=a.ZSL.parseAxisParam(s,o.shape);let l=c;const p=a.C0T.getAxesPermutation(l,u);let h=o;null!=p&&(h=zr({inputs:{x:o},backend:n,attrs:{perm:p}}),l=a.C0T.getInnerMostAxes(l.length,u)),a.C0T.assertAxesAreInnerMostDims("all",l,u);const[d,f]=a.C0T.computeOutAndReduceShapes(h.shape,l),m=Rr({inputs:{x:h},backend:n,attrs:{shape:[-1,a.ZSL.sizeFromShape(f)]}}),g=Dr(m,m.dtype,"all",n);let y;if(i){y=Rr({inputs:{x:g},backend:n,attrs:{shape:a.C0T.expandShapeToKeepDim(d,c)}})}else y=Rr({inputs:{x:g},backend:n,attrs:{shape:d}});return n.disposeIntermediateTensorInfo(m),n.disposeIntermediateTensorInfo(g),null!=p&&n.disposeIntermediateTensorInfo(h),y}};const aa={kernelName:a.FSt,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:o}=t,{axis:s,keepDims:i}=r,u=o.shape.length,c=a.ZSL.parseAxisParam(s,o.shape);let l=c;const p=a.C0T.getAxesPermutation(l,u);let h=o;null!=p&&(h=zr({inputs:{x:o},backend:n,attrs:{perm:p}}),l=a.C0T.getInnerMostAxes(l.length,u)),a.C0T.assertAxesAreInnerMostDims("any",l,u);const[d,f]=a.C0T.computeOutAndReduceShapes(h.shape,l),m=Rr({inputs:{x:h},backend:n,attrs:{shape:[-1,a.ZSL.sizeFromShape(f)]}}),g=Dr(m,m.dtype,"any",n);let y;if(i){y=Rr({inputs:{x:g},backend:n,attrs:{shape:a.C0T.expandShapeToKeepDim(d,c)}})}else y=Rr({inputs:{x:g},backend:n,attrs:{shape:d}});return n.disposeIntermediateTensorInfo(m),n.disposeIntermediateTensorInfo(g),null!=p&&n.disposeIntermediateTensorInfo(h),y}};class oa{constructor(e,t,n){this.variableNames=["A"];const{windowSize:r,batchSize:a,outSize:o}=e;n||this.variableNames.push("bestIndicesA"),this.outputShape=[a,o];const s="max"===t?">":"<",i=n?"inOffset + i;":"round(getBestIndicesA(batch, inOffset + i));";this.userCode=`\n void main() {\n ivec2 coords = getOutputCoords();\n int batch = coords[0];\n int outIdx = coords[1];\n int inOffset = outIdx * ${r};\n\n int bestIndex = inOffset;\n float bestValue = getA(batch, bestIndex);\n\n for (int i = 0; i < ${r}; i++) {\n int inIdx = ${i};\n float candidate = getA(batch, inIdx);\n if (candidate ${s} bestValue) {\n bestValue = candidate;\n bestIndex = inIdx;\n }\n }\n setOutput(float(bestIndex));\n }\n `}}class sa{constructor(e,t,n,r){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,a.ZSL.assert(e.length>2,()=>`Packed arg${n.charAt(0).toUpperCase()+n.slice(1)} supports only inputs with rank above 2.`);const o=e[e.length-1],s=Math.ceil(o/t);this.outputShape=e.slice(0,-1),s>1&&this.outputShape.push(s),r||this.variableNames.push("bestIndicesA");const i=this.outputShape,u=i.length,c=ae(u),l=zn("coords",u);let p,h;if(1===s){h=u+1;const e=ae(h);p=`\n ${e} sourceLocR = ${e}(${l.join()}, 0);\n ++${l[u-1]};\n ${e} sourceLocG = ${e}(${l.join()}, 0);\n ++${l[u-2]};\n ${e} sourceLocA = ${e}(${l.join()}, 0);\n --${l[u-1]};\n ${e} sourceLocB = ${e}(${l.join()}, 0);\n --${l[u-2]};`}else h=u,p=`\n ${c} sourceLocR = coords;\n ++${l[u-1]};\n ${c} sourceLocG = coords;\n ++${l[u-2]};\n ${c} sourceLocA = coords;\n --${l[u-1]};\n ${c} sourceLocB = coords;\n --${l[u-2]};`;const d=["x","y","z","w","u","v"].slice(0,h),f="."+d[h-1],m=d.map(e=>"int "+e),g=zn("sourceLocR",h-1).concat("inIdx.r"),y=zn("sourceLocG",h-1).concat("inIdx.g"),x=zn("sourceLocB",h-1).concat("inIdx.b"),b=zn("sourceLocA",h-1).concat("inIdx.a"),v="max"===n?"greaterThan":"lessThan",w=r?"":`\n inIdx = round(vec4(getBestIndicesAChannel(${g.join()}),\n getBestIndicesAChannel(${y.join()}),\n getBestIndicesAChannel(${x.join()}),\n getBestIndicesAChannel(${b.join()})));`,T=`vec4(\n getAChannel(${g.join()}),\n hasNextCol ? getAChannel(${y.join()}) : 0.,\n hasNextRow ? getAChannel(${x.join()}) : 0.,\n hasNextRow && hasNextCol ? getAChannel(${b.join()}) : 0.)`,S=r?"":`\n float getBestIndicesAChannel(${m.join()}) {\n return getChannel(getBestIndicesA(${d.join()}),\n vec2(${d.slice(-2).join()}));\n }`;this.userCode=`\n float getAChannel(${m.join()}) {\n return getChannel(getA(${d.join()}),\n vec2(${d.slice(-2).join()}));\n }\n ${S}\n void main() {\n ${c} coords = getOutputCoords();\n bool hasNextCol = ${l[u-1]} < ${i[u-1]-1};\n bool hasNextRow = ${l[u-2]} < ${i[u-2]-1};\n ${p}\n ivec4 srcIdx = ivec4(sourceLocR${f}, sourceLocG${f},\n sourceLocB${f}, sourceLocA${f}) * ${t};\n ivec4 inIdx = srcIdx;\n vec4 bestIndex = vec4(inIdx);\n vec4 bestValue = ${T};\n\n for (int i = 0; i < ${t};
2 i++) {\n inIdx = srcIdx;\n ${w}\n vec4 candidate = ${T};\n bvec4 nan = isnan(candidate);\n bvec4 replace = bvec4(\n vec4(${v}(candidate, bestValue)) * (vec4(1.0) - vec4(nan)));\n\n bestValue = vec4(replace.x ? candidate.x : bestValue.x,\n replace.y ? candidate.y : bestValue.y,\n replace.z ? candidate.z : bestValue.z,\n replace.w ? candidate.w : bestValue.w);\n bestIndex = mix(bestIndex, vec4(inIdx), vec4(replace));\n srcIdx++;\n }\n setOutput(bestIndex);\n }\n `}}function ia(e,t,n,r=null){let o=t.shape[0],s=t.shape[1];null!=r&&(o=r.shape[0],s=r.shape[1]);const i=a.C0T.computeOptimalWindowSize(s),u={windowSize:i,inSize:s,batchSize:o,outSize:Math.ceil(s/i)},c=new oa(u,n,null==r),l=[t];null!=r&&l.push(r);const p=e.runWebGLProgram(c,l,"int32");if(1===p.shape[1])return p;const h=ia(e,t,n,p);return e.disposeIntermediateTensorInfo(p),h}function ua(e,t,n,r=null){const o=null!=r?r.shape:t.shape,s=o[o.length-1],i=a.C0T.computeOptimalWindowSize(s),u=new sa(o,i,n,null==r),c=null==r?[t]:[t,r],l=e.runWebGLProgram(u,c,"int32");if(l.shape.length===t.shape.length){const r=ua(e,t,n,l);return e.disposeIntermediateTensorInfo(l),r}return l}function ca(e,t,n,r){const o=[n];if(a.C0T.assertAxesAreInnerMostDims("arg"+r.charAt(0).toUpperCase()+r.slice(1),o,t.shape.length),!(0,a._K2)().getBool("WEBGL_PACK_REDUCE")||t.shape.length<=2){const n=[],s=e.texData.get(t.dataId);let i=t;null!==s&&s.isPacked&&(i=e.unpackTensor(t),n.push(i));const[u,c]=a.C0T.computeOutAndReduceShapes(i.shape,o),l=a.ZSL.sizeFromShape(c),p=Rr({inputs:{x:i},backend:e,attrs:{shape:[-1,l]}});n.push(p);const h=ia(e,p,r);n.push(h);const d=Rr({inputs:{x:h},backend:e,attrs:{shape:u}});return n.forEach(t=>e.disposeIntermediateTensorInfo(t)),d}return ua(e,t,r)}const la={kernelName:a.Jp_,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:o}=t,{axis:s}=r;let i=a.ZSL.parseAxisParam(s,o.shape);const u=a.C0T.getAxesPermutation(i,o.shape.length);let c=o;const l=[];null!=u&&(c=zr({inputs:{x:o},backend:n,attrs:{perm:u}}),l.push(c),i=a.C0T.getInnerMostAxes(i.length,c.shape.length)),a.C0T.assertAxesAreInnerMostDims("argMax",[i[0]],c.shape.length);const p=ca(n,c,i[0],"max");return l.forEach(e=>n.disposeIntermediateTensorInfo(e)),p}};const pa={kernelName:a.p_m,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:o}=t,{axis:s}=r;let i=a.ZSL.parseAxisParam(s,o.shape);const u=a.C0T.getAxesPermutation(i,o.shape.length);let c=o;const l=[];null!=u&&(c=zr({inputs:{x:o},backend:n,attrs:{perm:u}}),l.push(c),i=a.C0T.getInnerMostAxes(i.length,c.shape.length)),a.C0T.assertAxesAreInnerMostDims("argMin",[i[0]],c.shape.length);const p=ca(n,c,i[0],"min");return l.forEach(e=>n.disposeIntermediateTensorInfo(e)),p}},ha=wr({opSnippet:Zn+"\n if (abs(x) > 1.) {\n return NAN;\n }\n return asin(x);\n"}),da={kernelName:a.QKF,backendName:"webgl",kernelFunc:ha},fa=wr({opSnippet:Zn+"return log(x + sqrt(x * x + 1.0));"}),ma={kernelName:a.epO,backendName:"webgl",kernelFunc:fa},ga=wr({opSnippet:Zn+"\n return atan(x);\n"}),ya={kernelName:a.TyE,backendName:"webgl",kernelFunc:ga},xa=Tr({opSnippet:sr+"\n return atan(a, b);\n",packedOpSnippet:"\n vec4 result = atan(a, b);\n bvec4 isNaNA = isnan(a);\n bvec4 isNaNB = isnan(b);\n bvec4 isNaN = bvec4(isNaNA.x || isNaNB.x, isNaNA.y || isNaNB.y, isNaNA.z || isNaNB.z, isNaNA.w || isNaNB.w);\n "+ur+"\n return result;\n"}),ba={kernelName:a.lxb,backendName:"webgl",kernelFunc:xa},va=wr({opSnippet:Zn+"\n if ((x < -1.0) || (x > 1.0)) return NAN;\nreturn (log(1.0 + x) - log(1.0 - x)) / 2.0;"}),wa={kernelName:a.zP9,backendName:"webgl",kernelFunc:va};class Ta{constructor(e,t,n,r=!1,a=!1){if(this.variableNames=["x"],"avg"===t&&n)throw new Error("Cannot compute positions for average pool.");const o=e.filterWidth,s=e.strideHeight,i=e.strideWidth,u=e.dilationHeight,c=e.dilationWidth,l=e.effectiveFilterHeight,p=e.effectiveFilterWidth,h=e.padInfo.top,d=e.padInfo.left;this.outputShape=e.outShape;const f="avg"===t,m=`((batch * ${e.inHeight} + xR) * ${e.inWidth} + xC) * ${e.inChannels} + d`,g=`(xR * ${e.inWidth} + xC) * ${e.inChannels} + d`;let y="0.0";if(f||(y="-1.0 / 1e-20"),n){const t=">=";return void(this.userCode=`\n const ivec2 strides = ivec2(${s}, ${i});\n const ivec2 pads = ivec2(${h}, ${d});\n\n void main() {\n ivec4 coords = getOutputCoords();\n int batch = coords[0];\n int d = coords[3];\n\n ivec2 xRCCorner = coords.yz * strides - pads;\n int xRCorner = xRCCorner.x;\n int xCCorner = xRCCorner.y;\n\n // max/min x(?, ?, d) to get y(yR, yC, d).\n // ? = to be determined\n float minMaxValue = 0.0;\n float minMaxValueFound = 0.0;\n int minMaxPosition = 0;\n float avgValue = 0.0;\n\n for (int wR = 0; wR < ${l};\n wR += ${u}) {\n int xR = xRCorner + wR;\n\n if (xR < 0 || xR >= ${e.inHeight}) {\n continue;\n }\n\n for (int wC = 0; wC < ${p};\n wC += ${c}) {\n int xC = xCCorner + wC;\n\n if (xC < 0 || xC >= ${e.inWidth}) {\n continue;\n }\n\n float value = getX(batch, xR, xC, d);\n\n // If a min / max value has already been found, use it. If not,\n // use the current value.\n float currMinMaxValue = mix(\n value, minMaxValue, minMaxValueFound);\n if (value ${t} currMinMaxValue) {\n minMaxValue = value;\n minMaxValueFound = 1.0;\n minMaxPosition = ${r?a?m:g:`wR * ${p} + wC`};\n }\n }\n }\n setOutput(float(minMaxPosition));\n }\n `)}let x=`${t}(${t}(${t}(minMaxValue[0], minMaxValue[1]), minMaxValue[2]), minMaxValue[3])`;"avg"===t&&(x="avgValue / count");const b=4*Math.floor(o/4),v=o%4,w=`\n if (${f}
2) {\n avgValue += dot(values, ones);\n } else {\n minMaxValue = max(values, minMaxValue);\n }\n `;this.userCode=`\n const ivec2 strides = ivec2(${s}, ${i});\n const ivec2 pads = ivec2(${h}, ${d});\n const float initializationValue = ${y};\n const vec4 ones = vec4(1.0, 1.0, 1.0, 1.0);\n\n float count = 0.0;\n\n float getValue(int batch, int xR, int xC, int d) {\n if (xC < 0 || xC >= ${e.inWidth}) {\n return initializationValue;\n }\n count += 1.0;\n return getX(batch, xR, xC, d);\n }\n\n void main() {\n ivec4 coords = getOutputCoords();\n int batch = coords[0];\n int d = coords[3];\n\n ivec2 xRCCorner = coords.yz * strides - pads;\n int xRCorner = xRCCorner.x;\n int xCCorner = xRCCorner.y;\n\n // max/min x(?, ?, d) to get y(yR, yC, d).\n // ? = to be determined\n vec4 minMaxValue = vec4(${y});\n float avgValue = 0.0;\n count = 0.0;\n\n for (int wR = 0; wR < ${l};\n wR += ${u}) {\n int xR = xRCorner + wR;\n\n if (xR < 0 || xR >= ${e.inHeight}) {\n continue;\n }\n\n for (int wC = 0; wC < ${b}; wC += 4) {\n int xC = xCCorner + wC * ${c};\n\n vec4 values = vec4(\n getValue(batch, xR, xC, d),\n getValue(batch, xR, xC + ${c}, d),\n getValue(batch, xR, xC + 2 * ${c}, d),\n getValue(batch, xR, xC + 3 * ${c}, d)\n );\n\n ${w}\n }\n\n int xC = xCCorner + ${b};\n if (${1===v}) {\n vec4 values = vec4(\n getValue(batch, xR, xC, d),\n initializationValue,\n initializationValue,\n initializationValue\n );\n\n ${w}\n } else if (${2===v}) {\n vec4 values = vec4(\n getValue(batch, xR, xC, d),\n getValue(batch, xR, xC + ${c}, d),\n initializationValue,\n initializationValue\n );\n\n ${w}\n } else if (${3===v}) {\n vec4 values = vec4(\n getValue(batch, xR, xC, d),\n getValue(batch, xR, xC + ${c}, d),\n getValue(batch, xR, xC + 2 * ${c}, d),\n initializationValue\n );\n\n ${w}\n }\n }\n setOutput(${x});\n }\n `}}class Sa{constructor(e,t,n,r=!1,a=!1){if(this.variableNames=["x"],"avg"===t&&n)throw new Error("Cannot compute positions for average pool.");const o=e.filterWidth,s=e.strideDepth,i=e.strideHeight,u=e.strideWidth,c=e.dilationDepth,l=e.dilationHeight,p=e.dilationWidth,h=e.effectiveFilterDepth,d=e.effectiveFilterHeight,f=e.effectiveFilterWidth,m=e.padInfo.front,g=e.padInfo.top,y=e.padInfo.left;this.outputShape=e.outShape;const x="avg"===t;let b="0.0";if(x||(b="-1.0 / 1e-20"),n){const t=">=";return void(this.userCode=`\n const ivec3 strides =\n ivec3(${s}, ${i}, ${u});\n const ivec3 pads = ivec3(${m}, ${g}, ${y});\n\n void main() {\n ivec5 coords = getOutputCoords();\n int batch = coords.x;\n int ch = coords.u;\n\n ivec3 xCorner = ivec3(coords.y, coords.z, coords.w) * strides - pads;\n int xDCorner = xCorner.x;\n int xRCorner = xCorner.y;\n int xCCorner = xCorner.z;\n\n // max/min x(?, ?, ?, ch) to get y(yD, yR, yC, ch).\n // ? = to be determined\n float minMaxValue = 0.0;\n float minMaxValueFound = 0.0;\n int minMaxPosition = 0;\n\n for (int wD = 0; wD < ${h};\n wD += ${c}) {\n int xD = xDCorner + wD;\n\n if (xD < 0 || xD >= ${e.inDepth}) {\n continue;\n }\n\n for (int wR = 0; wR < ${d};\n wR += ${l}) {\n int xR = xRCorner + wR;\n\n if (xR < 0 || xR >= ${e.inHeight}) {\n continue;\n }\n\n for (int wC = 0; wC < ${f};\n wC += ${p}) {\n int xC = xCCorner + wC;\n\n if (xC < 0 || xC >= ${e.inWidth}) {\n continue;\n }\n\n float value = getX(batch, xD, xR, xC, ch);\n\n // If a min / max value has already been found, use it. If not,\n // use the current value.\n float currMinMaxValue = mix(\n value, minMaxValue, minMaxValueFound);\n if (value ${t} currMinMaxValue) {\n minMaxValue = value;\n minMaxValueFound = 1.0;
2\n minMaxPosition = ${r?a?`(((batch * ${e.inDepth} + xD) * ${e.inHeight} + xR) * ${e.inWidth} + xC) * ${e.inChannels} + ch`:`((xD * ${e.inHeight} + xR) * ${e.inWidth} + xC) * ${e.inChannels} + ch`:`wD * ${d} * ${f} +\n wR * ${f} + wC`};\n }\n }\n }\n }\n setOutput(float(minMaxPosition));\n }\n `)}let v=`${t}(${t}(${t}(minMaxValue[0], minMaxValue[1]), minMaxValue[2]), minMaxValue[3])`;"avg"===t&&(v="avgValue / count");const w=4*Math.floor(o/4),T=o%4,S=`\n if (${x}) {\n avgValue += dot(values, ones);\n } else {\n minMaxValue = max(values, minMaxValue);\n }\n `;this.userCode=`\n const ivec3 strides =\n ivec3(${s}, ${i}, ${u});\n const ivec3 pads = ivec3(${m}, ${g}, ${y});\n const float initializationValue = ${b};\n const vec4 ones = vec4(1.0, 1.0, 1.0, 1.0);\n\n float count = 0.0;\n\n float getValue(int batch, int xD, int xR, int xC, int ch) {\n if (xC < 0 || xC >= ${e.inWidth}) {\n return initializationValue;\n }\n count += 1.0;\n return getX(batch, xD, xR, xC, ch);\n }\n\n void main() {\n ivec5 coords = getOutputCoords();\n int batch = coords.x;\n int ch = coords.u;\n\n ivec3 xCorner = ivec3(coords.y, coords.z, coords.w) * strides - pads;\n int xDCorner = xCorner.x;\n int xRCorner = xCorner.y;\n int xCCorner = xCorner.z;\n\n // max/min x(?, ?, ?, d) to get y(yD, yR, yC, ch).\n // ? = to be determined\n vec4 minMaxValue = vec4(${b});\n float avgValue = 0.0;\n count = 0.0;\n\n for (int wD = 0; wD < ${h};\n wD += ${c}) {\n int xD = xDCorner + wD;\n\n if (xD < 0 || xD >= ${e.inDepth}) {\n continue;\n }\n\n for (int wR = 0; wR < ${d};\n wR += ${l}) {\n int xR = xRCorner + wR;\n\n if (xR < 0 || xR >= ${e.inHeight}) {\n continue;\n }\n\n for (int wC = 0; wC < ${w}; wC += 4) {\n int xC = xCCorner + wC * ${p};\n\n vec4 values = vec4(\n getValue(batch, xD, xR, xC, ch),\n getValue(batch, xD, xR, xC + ${p}, ch),\n getValue(batch, xD, xR, xC + 2 * ${p}, ch),\n getValue(batch, xD, xR, xC + 3 * ${p}, ch)\n );\n\n ${S}\n }\n\n int xC = xCCorner + ${w};\n if (${1===T}) {\n vec4 values = vec4(\n getValue(batch, xD, xR, xC, ch),\n initializationValue,\n initializationValue,\n initializationValue\n );\n\n ${S}\n } else if (${2===T}) {\n vec4 values = vec4(\n getValue(batch, xD, xR, xC, ch),\n getValue(batch, xD, xR, xC + ${p}, ch),\n initializationValue,\n initializationValue\n );\n\n ${S}\n } else if (${3===T}) {\n vec4 values = vec4(\n getValue(batch, xD, xR, xC, ch),\n getValue(batch, xD, xR, xC + ${p}, ch),\n getValue(batch, xD, xR, xC + 2 * ${p}, ch),\n initializationValue\n );\n\n ${S}\n }\n }\n setOutput(${v});\n }\n }\n `}}const Ca={kernelName:a.ho8,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:o}=t;B(o,"avgPool");const{filterSize:s,strides:i,pad:u,dimRoundingMode:c}=r;a.ZSL.assert(a.C0T.eitherStridesOrDilationsAreOne(i,1),()=>`Error in avgPool: Either strides or dilations must be 1. Got strides ${i} and dilations '1'`);const l=a.C0T.computePool2DInfo(o.shape,s,i,1,u,c);if(1===l.filterWidth&&1===l.filterHeight&&a.ZSL.arraysEqual(l.inShape,l.outShape))return lr({inputs:{x:o},backend:n});const p=new Ta(l,"avg",!1);return n.runWebGLProgram(p,[o],"float32")}};const ka={kernelName:a.cS,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:o}=t,{filterSize:s,strides:i,pad:u,dimRoundingMode:c,dataFormat:l}
vendor: 4,243 bytes, line 2
2=r,p=a.C0T.computePool3DInfo(o.shape,s,i,[1,1,1],u,c,l),h=new Sa(p,"avg",!1);return n.runWebGLProgram(h,[o],"float32")}};class Ea{constructor(e){this.variableNames=["dy"],this.outputShape=e.inShape;const t=e.filterHeight,n=e.filterWidth,r=e.strideHeight,a=e.strideWidth,o=e.dilationHeight,s=e.dilationWidth,i=e.effectiveFilterHeight,u=e.effectiveFilterWidth,c=i-1-e.padInfo.top,l=u-1-e.padInfo.left,p=1/(t*n);this.userCode=`\n const ivec2 pads = ivec2(${c}, ${l});\n const float avgMultiplier = float(${p});\n\n void main() {\n ivec4 coords = getOutputCoords();\n int b = coords[0];\n int d = coords[3];\n\n ivec2 dyRCCorner = coords.yz - pads;\n int dyRCorner = dyRCCorner.x;\n int dyCCorner = dyRCCorner.y;\n\n // Convolve dy(?, ?, d) with pos mask(:, :, d) to get dx(xR, xC, d).\n // ? = to be determined. : = across all values in that axis.\n float dotProd = 0.0;\n for (int wR = 0; wR < ${i};\n wR += ${o}) {\n float dyR = float(dyRCorner + wR) / ${r}.0;\n\n if (dyR < 0.0 || dyR >= ${e.outHeight}.0 || fract(dyR) > 0.0) {\n continue;\n }\n int idyR = int(dyR);\n\n for (int wC = 0; wC < ${u};\n wC+= ${s}) {\n float dyC = float(dyCCorner + wC) / ${a}.0;\n\n if (dyC < 0.0 || dyC >= ${e.outWidth}.0 ||\n fract(dyC) > 0.0) {\n continue;\n }\n int idyC = int(dyC);\n\n float dyValue = getDy(b, idyR, idyC, d);\n\n dotProd += dyValue * avgMultiplier;\n }\n }\n setOutput(dotProd);\n }\n `}}class $a{constructor(e){this.variableNames=["dy"],this.outputShape=e.inShape;const t=e.filterDepth,n=e.filterHeight,r=e.filterWidth,a=e.strideDepth,o=e.strideHeight,s=e.strideWidth,i=e.dilationDepth,u=e.dilationHeight,c=e.dilationWidth,l=e.effectiveFilterDepth,p=e.effectiveFilterHeight,h=e.effectiveFilterWidth,d=l-1-e.padInfo.front,f=p-1-e.padInfo.top,m=h-1-e.padInfo.left,g=1/(t*n*r);this.userCode=`\n const ivec3 pads = ivec3(${d}, ${f}, ${m});\n const float avgMultiplier = float(${g});\n\n void main() {\n ivec5 coords = getOutputCoords();\n int batch = coords.x;\n int ch = coords.u;\n\n ivec3 dyCorner = ivec3(coords.y, coords.z, coords.w) - pads;\n int dyDCorner = dyCorner.x;\n int dyRCorner = dyCorner.y;\n int dyCCorner = dyCorner.z;\n\n // Convolve dy(?, ?, ?, d) with pos mask(:, :, :, ch) to get\n // dx(xD, xR, xC, ch).\n // ? = to be determined. : = across all values in that axis.\n float dotProd = 0.0;\n\n for (int wD = 0; wD < ${l};\n wD += ${i}) {\n float dyD = float(dyDCorner + wD) / ${a}.0;\n\n if (dyD < 0.0 || dyD >= ${e.outDepth}.0 || fract(dyD) > 0.0) {\n continue;\n }\n int idyD = int(dyD);\n\n for (int wR = 0; wR < ${p};\n wR += ${u}) {\n float dyR = float(dyRCorner + wR) / ${o}.0;\n\n if (dyR < 0.0 || dyR >= ${e.outHeight}.0 ||\n fract(dyR) > 0.0) {\n continue;\n }\n int idyR = int(dyR);\n\n for (int wC = 0; wC < ${h};\n wC += ${c}) {\n float dyC = float(dyCCorner + wC) / ${s}.0;\n\n if (dyC < 0.0 || dyC >= ${e.outWidth}.0 ||\n fract(dyC) > 0.0) {\n continue;\n }\n int idyC = int(dyC);\n\n float dyValue = getDy(batch, idyD, idyR, idyC, ch);\n\n dotProd += dyValue * avgMultiplier;\n }\n }\n }\n setOutput(dotProd);\n }\n `}}const Na={kernelName:a.wwC,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{dy:o,input:s}=t,i=s,{filterSize:u,strides:c,pad:l,dimRoundingMode:p}=r,h=a.C0T.computePool3DInfo(i.shape,u,c,[1,1,1],l,p),d=new $a(h);return n.runWebGLProgram(d,[o],i.dtype)}};const Ia={kernelName:a.VCH,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{dy:o,input:s}=t,i=s;B([o,s],"avgPoolGrad");const{filterSize:u,strides:c,pad:l}
2=r,p=a.C0T.computePool2DInfo(i.shape,u,c,1,l),h=new Ea(p);return n.runWebGLProgram(h,[o],i.dtype)}};const Aa={kernelName:a.jAQ,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{a:a,b:o}=t,{transposeA:s,transposeB:i}=r;return Wr({a:a,b:o,transposeA:s,transposeB:i,backend:n})}};class Ra{constructor(e,t,n,r,o,s){this.outputShape=[],this.variableNames=["x","mean","variance"],a.C0T.assertAndGetBroadcastShape(e,t),a.C0T.assertAndGetBroadcastShape(e,n);let i="0.0";null!=r&&(a.C0T.assertAndGetBroadcastShape(e,r),this.variableNames.push("offset"),i="getOffsetAtOutCoords()");let u="1.0";null!=o&&(a.C0T.assertAndGetBroadcastShape(e,o),this.variableNames.push("scale"),u="getScaleAtOutCoords()"),this.outputShape=e,this.userCode=`\n void main() {\n float x = getXAtOutCoords();\n float mean = getMeanAtOutCoords();\n float variance = getVarianceAtOutCoords();\n float offset = ${i};\n float scale = ${u};\n float inv = scale * inversesqrt(variance + float(${s}));\n setOutput(dot(vec3(x, -mean, offset), vec3(inv, inv, 1)));\n }\n `}}class _a{constructor(e,t,n,r,o,s){this.packedInputs=!0,this.packedOutput=!0,this.variableNames=["x","mean","variance"],a.C0T.assertAndGetBroadcastShape(e,t),a.C0T.assertAndGetBroadcastShape(e,n);let i="vec4(0.0)";null!=r&&(a.C0T.assertAndGetBroadcastShape(e,r),this.variableNames.push("offset"),i="getOffsetAtOutCoords()");let u="vec4(1.0)";null!=o&&(a.C0T.assertAndGetBroadcastShape(e,o),this.variableNames.push("scale"),u="getScaleAtOutCoords()"),this.outputShape=e,this.userCode=`\n void main() {\n vec4 offset = ${i};\n vec4 scale = ${u};\n\n vec4 x = getXAtOutCoords();\n vec4 mean = getMeanAtOutCoords();\n vec4 variance = getVarianceAtOutCoords();\n\n vec4 inv = scale * inversesqrt(variance + vec4(${s}));\n\n setOutput((x - mean) * inv + offset);\n }\n `}}const Oa={kernelName:a.i5R,backendName:"webgl",kernelFunc:({inputs:e,backend:t,attrs:n})=>{const{x:r,mean:o,variance:s,offset:i,scale:u}=e;a.ZSL.assert(o.shape.length===s.shape.length,()=>"Batch normalization gradient requires mean and variance to have equal ranks."),a.ZSL.assert(null==i||o.shape.length===i.shape.length,()=>"Batch normalization gradient requires mean and offset to have equal ranks."),a.ZSL.assert(null==u||o.shape.length===u.shape.length,()=>"Batch normalization gradient requires mean and scale to have equal ranks.");let{varianceEpsilon:c}=n;null==c&&(c=.001);const l=[r,o,s];let p=null;null!=i&&(p=i.shape,l.push(i));let h=null;null!=u&&(h=u.shape,l.push(u));const d=(0,a._K2)().getBool("WEBGL_PACK_NORMALIZATION")?new _a(r.shape,o.shape,s.shape,p,h,c):new Ra(r.shape,o.shape,s.shape,p,h,c);return t.runWebGLProgram(d,l,l[0].dtype)}};class Fa{constructor(e){this.variableNames=["source"],this.outputShape=e,this.rank=e.length;const t=ae(this.rank);this.customUniforms=[{name:"start",arrayIndex:this.rank,type:"int"}];const n=function(e){if(1===e)return"sourceLoc";if(e<=6)return Da.slice(0,e).map(e=>"sourceLoc."+e).join(",");throw Error(`Slicing for rank ${e} is not yet supported`)}(this.rank);let r;r=`\n ${t} sourceLoc;\n ${t} coords = getOutputCoords();\n ${e.map((e,t)=>`sourceLoc.${Da[t]} = start[${t}] + coords.${Da[t]};`).join("\n")}\n `,this.userCode=`\n void main() {\n ${r}\n setOutput(getSource(${n}));\n }\n `}}const Da=["x","y","z","w","u","v"];class La{constructor(e){this.variableNames=["source"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=e,this.rank=e.length,this.customUniforms=[{name:"start",arrayIndex:this.rank,type:"int"}];const t=ae(this.rank),n=zn("coords",this.rank),r=zn("sourceLoc",this.rank),a=1===this.rank?"sourceLoc":`vec2(${r.slice(-2).join()})`,o=`getChannel(getSource(${r.join()}), ${a})`,s=`\n result.x = ${o};\n if (++${n[this.rank-1]} < ${e[this.rank-1]}) {\n ++${r[this.rank-1]};\n result.y = ${o};\n --${r[this.rank-1]};\n }\n `,i=1===this.rank?"":`\n --${n[this.rank-1]};\n if (++${n[this.rank-2]} < ${e[this.rank-2]}) {\n ++${r[this.rank-2]};\n result.z = ${o};\n if (++${n[this.rank-1]} < ${e[this.rank-1]}) {\n ++${r[this.rank-1]};\n result.w = ${o};\n }\n }
2\n `,u=this.rank<=4?`sourceLoc = coords +\n ${t}(${e.map((e,t)=>`start[${t}]`).join()});`:e.map((e,t)=>`${r[t]} = ${n[t]} + start[${t}];`).join("\n");this.userCode=`\n void main() {\n ${t} coords = getOutputCoords();\n ${t} sourceLoc;\n ${u}\n vec4 result = vec4(0.);\n ${s}\n ${i}\n setOutput(result);\n }\n `}}function Ma(e){const{inputs:t,backend:n,attrs:r}=e,{x:o}=t,{begin:s,size:i}=r,[u,c]=a.Kro.parseSliceParams(o,s,i);if(a.Kro.assertParamsValid(o,u,c),0===a.ZSL.sizeFromShape(c))return n.makeTensorInfo(c,o.dtype,[]);if(n.shouldExecuteOnCPU([o])||"string"===o.dtype){const e=n.texData.get(o.dataId),t=En(e.values,u,c,o.shape,o.dtype);return n.makeTensorInfo(c,o.dtype,t)}const{isPacked:l}=n.texData.get(o.dataId),p=a.Kro.isSliceContinous(o.shape,u,c);if(l||!p){const e=(0,a._K2)().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new La(c):new Fa(c),t=[u];return n.runWebGLProgram(e,[o],o.dtype,t)}return n.uploadToGPU(o.dataId),function(e,t,n,r){const o=r.texData.get(e.dataId),s=r.makeTensorInfo(n,e.dtype),i=r.texData.get(s.dataId);Object.assign(i,o),i.refCount=1,i.shape=n,i.dtype=e.dtype;let u=a.Kro.computeFlatOffset(t,a.ZSL.computeStrides(e.shape));o.slice&&(u+=o.slice.flatOffset),i.slice={flatOffset:u,origDataId:o.slice&&o.slice.origDataId||e.dataId};const c=r.dataRefCount.get(i.slice.origDataId)||1;return r.dataRefCount.set(i.slice.origDataId,c+1),s}(o,u,c,n)}const Pa={kernelName:a.JiE,backendName:"webgl",kernelFunc:Ma},Ba={kernelName:a.Ik2,backendName:"webgl",kernelFunc:e=>{const{inputs:t,backend:n,attrs:r}=e,{x:o}=t,{blockShape:s,crops:i}=r;a.ZSL.assert(o.shape.length<=4,()=>"batchToSpaceND for rank > 4 with a WebGL backend not implemented yet");const u=s.reduce((e,t)=>e*t),c=a.C0T.getReshaped(o.shape,s,u),l=a.C0T.getPermuted(c.length,s.length),p=a.C0T.getReshapedPermuted(o.shape,s,u),h=a.C0T.getSliceBeginCoords(i,s.length),d=a.C0T.getSliceSize(p,i,s.length),f=[],m=Rr({inputs:{x:o},backend:n,attrs:{shape:c}}),g=zr({inputs:{x:m},backend:n,attrs:{perm:l}}),y=Rr({inputs:{x:g},backend:n,attrs:{shape:p}}),x=Ma({inputs:{x:y},backend:n,attrs:{begin:h,size:d}});return f.push(m),f.push(g),f.push(y),f.forEach(e=>n.disposeIntermediateTensorInfo(e)),x}};const Va={kernelName:a.N4F,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a,weights:o}=t,{size:s}=r,i=n.readSync(a.dataId),u=n.readSync(o.dataId),c=Yt(i,u,o.dtype,o.shape,s);return n.makeTensorInfo([s],o.dtype,c)}};const za={kernelName:a.vj7,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n}=e,{s0:r,s1:o}=t,s=n.readSync(r.dataId),i=n.readSync(o.dataId),u=a.C0T.assertAndGetBroadcastShape(Array.from(s),Array.from(i));return n.makeTensorInfo([u.length],"int32",Int32Array.from(u))}},Ua=Tr({opSnippet:"return float(a != b);",cpuKernelImpl:yn,dtype:"bool"}),Wa={kernelName:a.ylV,backendName:"webgl",kernelFunc:Ua};function Ga(e){const{inputs:t,backend:n}=e,{input:r}=t;return lr({inputs:{x:n.texData.get(r.dataId).complexTensorInfos.real},backend:n})}const ja={kernelName:a.LRy,backendName:"webgl",kernelFunc:Ga};const Ka={kernelName:a.KXH,backendName:"webgl",kernelFunc:function e(t){const{inputs:n,backend:r,attrs:o}=t,{x:s}=n,{dtype:i}=o;if("complex64"===i){if("complex64"===s.dtype)return lr({inputs:{x:s},backend:r});const t=a.Ul9(s.shape),n=e({inputs:{x:s},backend:r,attrs:{dtype:"float32"}}),o=hr({inputs:{real:n,imag:t},backend:r});return t.dispose(),r.disposeIntermediateTensorInfo(n),o}if("complex64"===s.dtype){const t=Ga({inputs:{input:s},backend:r}),n=e({inputs:{x:t},backend:r,attrs:{dtype:i}});return r.disposeIntermediateTensorInfo(t),n}if(!a.ZSL.hasEncodingLoss(s.dtype,i)){const e=lr({inputs:{x:s},backend:r});return{dataId:e.dataId,shape:e.shape,dtype:i}}if(r.shouldExecuteOnCPU([s])){const e=r.texData.get(s.dataId).values,[t,n,a]=Xt(e,s.shape,s.dtype,i);return r.makeTensorInfo(t,n,a)}if("int32"===i)return function(e,t){const n=new Yn(e.shape,"return float(int(x));"),r=t.runWebGLProgram(n,[e],"int32");return{dataId:r.dataId,shape:r.shape,dtype:r.dtype}}(s,r);if("bool"===i){const e=r.makeTensorInfo([],"bool",a.ZSL.getTypedArrayFromDType("bool",1)),t=Ua({inputs:{a:s,b:e},backend:r});return r.disposeIntermediateTensorInfo(e),t}throw new Error(`Error in Cast: failed to cast ${s.dtype} to ${i}`)}},Ha="return ceil(x);",Ya=wr({opSnippet:Ha,packedOpSnippet:Ha,cpuKernelImpl:qt}),Za={kernelName:a.QDP,backendName:"webgl",kernelFunc:Ya};class Xa{constructor(e){this.variableNames=["A"],this.customUniforms=[{name:"minVal",type:"float"},{name:"maxVal",type:"float"}],this.outputShape=e,this.userCode="\n\n void main() {\n float value = getAAtOutCoords();\n if (isnan(value)) {\n setOutput(value);\n return;\n }\n\n setOutput(clamp(value, minVal, maxVal));\n }\n "}}class qa{constructor(e){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.customUniforms=[{name:"minVal",type:"float"},{name:"maxVal",type:"float"}],this.outputShape=e,this.userCode="\n void main() {\n vec4 value = getAAtOutCoords();\n\n if (any(isnan(value))) {\n setOutput(value);\n return;\n }\n\n setOutput(clamp(value, vec4(minVal), vec4(maxVal)));\n }\n "}}const Qa={kernelName:a.vaV,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:o}=t,{clipValueMin:s,clipValueMax:i}=r;let u;u=(0,a._K2)().getBool("WEBGL_PACK_CLIP")?new qa(o.shape):new Xa(o.shape);const c=[[s],[i]];return n.runWebGLProgram(u,[o],o.dtype,c)}};class Ja{constructor(e){this.variableNames=["real","imag"],this.outputShape=e,this.userCode="\n void main() {\n float re = abs(getRealAtOutCoords());\n float im = abs(getImagAtOutCoords());\n float mx = max(re, im);\n\n // sadly the length function in glsl is not underflow-safe\n // (at least not on Intel GPUs). So the safe solution is\n // to ensure underflow-safety in all cases.\n setOutput(\n mx == 0.0 ? 0.0 : mx * length(vec2(1, min(re, im)/mx))\n );\n }\n "}}function eo(e,t){return{dataId:t.dataId,dtype:t.dtype,shape:e.shape}}const to={kernelName:a.$zE,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n}=e,{x:r}=t,a=n.texData.get(r.dataId),o=new Ja(r.shape),s=[eo(r,a.complexTensorInfos.real),eo(r,a.complexTensorInfos.imag)];return n.runWebGLProgram(o,s,s[0].dtype)}};
2class no{constructor(e){this.outputShape=[],this.outputShape=a.C0T.computeOutShape(e,1),this.variableNames=e.map((e,t)=>`T${t}`);const t=new Array(e.length-1);t[0]=e[0][1];for(let n=1;n<t.length;n++)t[n]=t[n-1]+e[n][1];const n=[`if (yC < ${t[0]}) setOutput(getT0(yR, yC));`];for(let e=1;e<t.length;e++){const r=t[e-1];n.push(`else if (yC < ${t[e]}) setOutput(getT${e}(yR, yC-${r}));`)}const r=t.length,o=t[t.length-1];n.push(`else setOutput(getT${r}(yR, yC-${o}));`),this.userCode=`\n void main() {\n ivec2 coords = getOutputCoords();\n int yR = coords.x;\n int yC = coords.y;\n\n ${n.join("\n ")}\n }\n `}}class ro{constructor(e,t){this.packedInputs=!0,this.packedOutput=!0,this.outputShape=[],this.outputShape=a.C0T.computeOutShape(e,t);const n=this.outputShape,r=n.length,o=ae(r),s=zn("coords",r),i=["x","y","z","w","u","v"].slice(0,r);this.variableNames=e.map((e,t)=>`T${t}`);const u=new Array(e.length-1);u[0]=e[0][t];for(let n=1;n<u.length;n++)u[n]=u[n-1]+e[n][t];const c=i[t],l=i.slice(-2),p=i.join();let h=`if (${c} < ${u[0]}) {\n return getChannel(\n getT0(${p}), vec2(${l.join()}));\n }`;for(let e=1;e<u.length;e++){const t=u[e-1];h+=`\n if (${c} < ${u[e]} && ${c} >= ${u[e-1]}) {\n return getChannel(\n getT${e}(${ao(i,c,t)}),\n vec2(${ao(l,c,t)}));\n }`}const d=u.length,f=u[u.length-1];h+=`\n return getChannel(\n getT${d}(${ao(i,c,f)}),\n vec2(${ao(l,c,f)}));`,this.userCode=`\n float getValue(${i.map(e=>"int "+e)}) {\n ${h}\n }\n\n void main() {\n ${o} coords = getOutputCoords();\n vec4 result = vec4(getValue(${s}), 0., 0., 0.);\n\n ${s[r-1]} = ${s[r-1]} + 1;\n if (${s[r-1]} < ${n[r-1]}) {\n result.g = getValue(${s});\n }\n\n ${s[r-2]} = ${s[r-2]} + 1;\n if (${s[r-2]} < ${n[r-2]}) {\n result.a = getValue(${s});\n }\n\n ${s[r-1]} = ${s[r-1]} - 1;\n if (${s[r-2]} < ${n[r-2]} &&\n ${s[r-1]} < ${n[r-1]}) {\n result.b = getValue(${s});\n }\n setOutput(result);\n }\n `}}function ao(e,t,n){const r=e.indexOf(t);return e.map((e,t)=>t===r?`${e} - ${n}`:e).join()}function oo(e){const{inputs:t,backend:n}=e,{input:r}=t;return lr({inputs:{x:n.texData.get(r.dataId).complexTensorInfos.imag},backend:n})}const so={kernelName:a.dv8,backendName:"webgl",kernelFunc:oo};function io(e,t,n){const r=e[0].dtype;if("complex64"===r){const r=e.map(e=>Ga({inputs:{input:e},backend:n})),a=e.map(e=>oo({inputs:{input:e},backend:n})),o=io(r,t,n),s=io(a,t,n),i=hr({inputs:{real:o,imag:s},backend:n});return r.forEach(e=>n.disposeIntermediateTensorInfo(e)),a.forEach(e=>n.disposeIntermediateTensorInfo(e)),n.disposeIntermediateTensorInfo(o),n.disposeIntermediateTensorInfo(s),i}let o=n.shouldExecuteOnCPU(e);if("string"===r&&(o=!0),o){const o=e.map(e=>{const r=a.ZSL.sizeFromShape(e.shape.slice(t));return Rr({inputs:{x:e},backend:n,attrs:{shape:[-1,r]}})}),s=o.map(e=>({vals:n.readSync(e.dataId),shape:e.shape})),i=a.C0T.computeOutShape(o.map(e=>e.shape),1),u=1===o[0].shape[0],c=Qt(s,i,r,u),l=a.C0T.computeOutShape(e.map(e=>e.shape),t),p=n.makeTensorInfo(l,r,c);return o.forEach(e=>n.disposeIntermediateTensorInfo(e)),p}const s=(0,a._K2)().getNumber("WEBGL_MAX_TEXTURES_IN_SHADER");if(e.length>s){const r=[];for(let a=0;a<e.length;a+=s){const o=e.slice(a,a+s);r.push(io(o,t,n))}const a=io(r,t,n);for(const e of r)n.disposeIntermediateTensorInfo(e);return a}if((0,a._K2)().getBool("WEBGL_PACK_ARRAY_OPERATIONS")&&e[0].shape.length>1){const a=new ro(e.map(e=>e.shape),t);return n.runWebGLProgram(a,e,r)}const{tensors2D:i,outShape:u}=function(e,t,n){const r=a.C0T.computeOutShape(e.map(e=>e.shape),t),o=e.map(e=>Rr({inputs:{x:e},attrs:{shape:[-1,a.ZSL.sizeFromShape(e.shape.slice(t))]},backend:n}));return{tensors2D:o,outShape:r}}(e,t,n),c=new no(i.map(e=>e.shape)),l=n.runWebGLProgram(c,i,r);i.forEach(e=>n.disposeIntermediateTensorInfo(e));const p=Rr({inputs:{x:l},attrs:{shape:u},backend:n});return n.disposeIntermediateTensorInfo(l),p}function uo(e){const{inputs:t,backend:n,attrs:r}=e,{axis:o}=r,s=a.ZSL.parseAxisParam(o,t[0].shape)[0],i=t.map(e=>e.shape);a.C0T.assertParamsConsistent(i,s);const u=a.C0T.computeOutShape(t.map(e=>e.shape),s);if(0===a.ZSL.sizeFromShape(u))return n.makeTensorInfo(u,t[0].dtype,[]);const c=t.filter(e=>a.ZSL.sizeFromShape(e.shape)>0);
vendor: 5,898 bytes, line 2
2return 1===c.length?lr({inputs:{x:c[0]},backend:n}):io(c,s,n)}const co={kernelName:a.$dB,backendName:"webgl",kernelFunc:uo};class lo{constructor(e,t=!1,n=null,r=!1,a=!1){this.variableNames=["x","W"],this.outputShape=e.outShape;const o=e.padInfo.top,s=e.padInfo.left,i=e.strideHeight,u=e.strideWidth,c=e.dilationHeight,l=e.dilationWidth,p=e.filterHeight,h=e.filterWidth,d=4*Math.floor(e.inChannels/4),f=e.inChannels%4,m="channelsLast"===e.dataFormat,g=m?1:2,y=m?2:3,x=m?3:1;let b="",v="";n&&(b=r?`float activation(float a) {\n float b = getPreluActivationWeightsAtOutCoords();\n ${n}\n }`:a?`float activation(float a) {\n float b = getLeakyreluAlphaAtOutCoords();\n ${n}\n }`:`\n float activation(float x) {\n ${n}\n }\n `,v="result = activation(result);");const w=t?"result += getBiasAtOutCoords();":"";t&&this.variableNames.push("bias"),r&&this.variableNames.push("preluActivationWeights"),a&&this.variableNames.push("leakyreluAlpha"),this.userCode=`\n ${b}\n\n const ivec2 strides = ivec2(${i}, ${u});\n const ivec2 pads = ivec2(${o}, ${s});\n\n void main() {\n ivec4 coords = getOutputCoords();\n int batch = coords[0];\n int d2 = coords[${x}];\n\n ivec2 xRCCorner =\n ivec2(coords[${g}], coords[${y}]) * strides - pads;\n int xRCorner = xRCCorner.x;\n int xCCorner = xRCCorner.y;\n\n // Convolve x(?, ?, d1) with w(:, :, d1, d2) to get y(yR, yC, d2).\n // ? = to be determined. : = across all values in that axis.\n float dotProd = 0.0;\n for (int wR = 0; wR < ${p}; wR++) {\n int xR = xRCorner + wR * ${c};\n\n if (xR < 0 || xR >= ${e.inHeight}) {\n continue;\n }\n\n for (int wC = 0; wC < ${h}; wC++) {\n int xC = xCCorner + wC * ${l};\n\n if (xC < 0 || xC >= ${e.inWidth}) {\n continue;\n }\n\n for (int d1 = 0; d1 < ${d}; d1 += 4) {\n vec4 wValues = vec4(\n getW(wR, wC, d1, d2),\n getW(wR, wC, d1 + 1, d2),\n getW(wR, wC, d1 + 2, d2),\n getW(wR, wC, d1 + 3, d2)\n );\n\n if (${m}) {\n vec4 xValues = vec4(\n getX(batch, xR, xC, d1),\n getX(batch, xR, xC, d1 + 1),\n getX(batch, xR, xC, d1 + 2),\n getX(batch, xR, xC, d1 + 3)\n );\n dotProd += dot(xValues, wValues);\n } else {\n vec4 xValues = vec4(\n getX(batch, d1, xR, xC),\n getX(batch, d1 + 1, xR, xC),\n getX(batch, d1 + 2, xR, xC),\n getX(batch, d1 + 3, xR, xC)\n );\n dotProd += dot(xValues, wValues);\n }\n }\n\n if (${1===f}) {\n\n if (${m}) {\n dotProd +=\n getX(batch, xR, xC, ${d}) *\n getW(wR, wC, ${d}, d2);\n } else {\n dotProd +=\n getX(batch, ${d}, xR, xC) *\n getW(wR, wC, ${d}, d2);\n }\n\n } else if (${2===f}) {\n vec2 wValues = vec2(\n getW(wR, wC, ${d}, d2),\n getW(wR, wC, ${d} + 1, d2)\n );\n\n if (${m}) {\n vec2 xValues = vec2(\n getX(batch, xR, xC, ${d}),\n getX(batch, xR, xC, ${d} + 1)\n );\n dotProd += dot(xValues, wValues);\n } else {\n vec2 xValues = vec2(\n getX(batch, ${d}, xR, xC),\n getX(batch, ${d} + 1, xR, xC)\n );\n dotProd += dot(xValues, wValues);\n }\n\n } else if (${3===f}) {\n vec3 wValues = vec3(\n getW(wR, wC, ${d}, d2),\n getW(wR, wC, ${d} + 1, d2),\n getW(wR, wC, ${d} + 2, d2)\n );\n\n if (${m}) {\n vec3 xValues = vec3(\n getX(batch, xR, xC, ${d}),\n getX(batch, xR, xC, ${d} + 1),\n getX(batch, xR, xC, ${d} + 2)\n );\n dotProd += dot(xValues, wValues);\n } else {\n vec3 xValues = vec3(\n getX(batch, ${d}, xR, xC),\n getX(batch, ${d} + 1, xR, xC),\n getX(batch, ${d} + 2, xR, xC)\n );\n dotProd += dot(xValues, wValues);\n }\n\n }\n }\n }\n\n float result = dotProd;\n ${w}\n ${v}\n setOutput(result);\n }\n `}}class po{constructor(e){this.variableNames=["x","W"],this.outputShape=e.outShape;const t=e.padInfo.front,n=e.padInfo.top,r=e.padInfo.left,a=e.strideDepth,o=e.strideHeight,s=e.strideWidth,i=e.dilationDepth,u=e.dilationHeight,c=e.dilationWidth,l=e.filterDepth,p=e.filterHeight,h=e.filterWidth,d=4*Math.floor(e.inChannels/4),f=e.inChannels%4;this.userCode=`\n const ivec3 strides = ivec3(${a}, ${o}, ${s});\n const ivec3 pads = ivec3(${t}, ${n}, ${r});\n\n void main() {\n ivec5 coords = getOutputCoords();\n int batch = coords.x;\n int d2 = coords.u;\n\n ivec3 xFRCCorner = ivec3(coords.y, coords.z, coords.w) * strides - pads;\n int xFCorner = xFRCCorner.x;\n int xRCorner = xFRCCorner.y;\n int xCCorner = xFRCCorner.z;\n\n // Convolve x(?, ?, ?, d1) with w(:, :, :, d1, d2) to get\n // y(yF, yR, yC, d2). ? = to be determined. : = across all\n // values in that axis.\n float dotProd = 0.0;\n for (int wF = 0; wF < ${l};
2 wF++) {\n int xF = xFCorner + wF * ${i};\n\n if (xF < 0 || xF >= ${e.inDepth}) {\n continue;\n }\n\n for (int wR = 0; wR < ${p}; wR++) {\n int xR = xRCorner + wR * ${u};\n\n if (xR < 0 || xR >= ${e.inHeight}) {\n continue;\n }\n\n for (int wC = 0; wC < ${h}; wC++) {\n int xC = xCCorner + wC * ${c};\n\n if (xC < 0 || xC >= ${e.inWidth}) {\n continue;\n }\n\n for (int d1 = 0; d1 < ${d}; d1 += 4) {\n vec4 xValues = vec4(\n getX(batch, xF, xR, xC, d1),\n getX(batch, xF, xR, xC, d1 + 1),\n getX(batch, xF, xR, xC, d1 + 2),\n getX(batch, xF, xR, xC, d1 + 3)\n );\n vec4 wValues = vec4(\n getW(wF, wR, wC, d1, d2),\n getW(wF, wR, wC, d1 + 1, d2),\n getW(wF, wR, wC, d1 + 2, d2),\n getW(wF, wR, wC, d1 + 3, d2)\n );\n\n dotProd += dot(xValues, wValues);\n }\n\n if (${1===f}) {\n dotProd +=\n getX(batch, xF, xR, xC, ${d}) *\n getW(wF, wR, wC, ${d}, d2);\n } else if (${2===f}) {\n vec2 xValues = vec2(\n getX(batch, xF, xR, xC, ${d}),\n getX(batch, xF, xR, xC, ${d} + 1)\n );\n vec2 wValues = vec2(\n getW(wF, wR, wC, ${d}, d2),\n getW(wF, wR, wC, ${d} + 1, d2)\n );\n dotProd += dot(xValues, wValues);\n } else if (${3===f}) {\n vec3 xValues = vec3(\n getX(batch, xF, xR, xC, ${d}),\n getX(batch, xF, xR, xC, ${d} + 1),\n getX(batch, xF, xR, xC, ${d} + 2)\n );\n vec3 wValues = vec3(\n getW(wF, wR, wC, ${d}, d2),\n getW(wF, wR, wC, ${d} + 1, d2),\n getW(wF, wR, wC, ${d} + 2, d2)\n );\n dotProd += dot(xValues, wValues);\n }\n }\n }\n }\n setOutput(dotProd);\n }\n `}}class ho{constructor(e,t=!1,n=null,r=!1,o=!1){this.variableNames=["x","W"],this.packedInputs=!0,this.packedOutput=!0,this.customUniforms=[{name:"pads",type:"ivec2"},{name:"strides",type:"ivec2"},{name:"dilations",type:"ivec2"},{name:"inDims",type:"ivec2"}],this.outputShape=e.outShape,this.enableShapeUniforms=pe(this.outputShape.length);const s=e.padInfo.left,i=e.strideWidth,u=e.dilationWidth,c=e.filterHeight,l=e.filterWidth,p=l;let h="\n int xR; int xC; int xCOffset;\n vec4 wTexel; vec4 previous; vec4 final;";for(let e=0;e<l;e++)h+=`\n vec4 xTexelC${2*e};\n int xTexelC${2*e}Ready;\n vec4 xTexelC${2*e+1};\n int xTexelC${2*e+1}Ready;\n vec4 xC${e};`;h+=`\n for (int r = 0; r < ${c}; r++) {\n for (int d1 = 0; d1 < ${e.inChannels}; d1 += 2) {\n `;for(let e=0;e<l;e++)h+=`\n xTexelC${2*e} = vec4(0.0);\n xTexelC${2*e}Ready = 0;\n xTexelC${2*e+1} = vec4(0.0);\n xTexelC${2*e+1}Ready = 0;\n xC${e} = vec4(0.0);`;h+="\n xR = xRCorner + r * dilations[0];\n if (xR >=0 && xR < inDims[0]) {\n ";for(let t=0;t<(p+1)/2;t++){const n=2*t;if(h+=`\n xC = xCCorner + ${n*u};\n `,1===i){if(n<l&&(s%2==1?(h+=`\n xCOffset = xC + 1;\n if (xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${n}Ready == 0) {\n xTexelC${n} = getX(batch, xR, xCOffset, d1);\n\n // Need to manually clear unused channels in case\n // we're reading from recycled texture.\n if (xCOffset + 1 >= inDims[1]) {\n xTexelC${n}.zw = vec2(0.0);\n }\n xTexelC${n}Ready = 1;\n }\n `,h+=1===u&&n>0?`\n xC${n} = vec4(xTexelC${n-2}.zw, xTexelC${n}.xy);\n `:`\n xCOffset = xC + 1 - 2;\n\n if (xCOffset >= 0 && xCOffset < inDims[1]) {\n previous = getX(batch, xR, xCOffset, d1);\n\n // Need to manually clear unused channels in case\n // we're reading from recycled texture.\n if (xCOffset + 1 >= inDims[1]) {\n previous.zw = vec2(0.0);\n }\n\n xC${n} = vec4(previous.zw, xTexelC${n}.xy);\n } else {\n xC${n} = vec4(0.0, 0.0, xTexelC${n}.xy);\n }\n `):h+=`\n if (xC >= 0 && xC < inDims[1] && xTexelC${n}Ready == 0) {\n xTexelC${n} = getX(batch, xR, xC, d1);\n if (xC + 1 >= inDims[1]) {\n xTexelC${n}.zw = vec2(0.0);\n }\n xTexelC${n}Ready = 1;\n }\n\n xC${n} = xTexelC${n};\n `,n+1<l)){const e=s%2==0?a.ZSL.nearestLargerEven(u):u;u%2==0&&s%2==1||u%2!=0&&s%2!=1?(h+=`\n xCOffset = xC + imod(pads[1], 2) + ${e};\n\n if (xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${n+1}Ready == 0) {\n xTexelC${n+1} = getX(batch, xR, xCOffset, d1);\n\n // Need to manually clear unused channels in case\n // we're reading from recycled texture.\n if (xCOffset + 1 >= inDims[1]) {\n xTexelC${n+1}.zw = vec2(0.0);\n }\n xTexelC${n+1}Ready = 1;\n }\n `,h+=u>1?`\n xCOffset -= 2;\n if (xCOffset >= 0 && xCOffset < inDims[1]) {\n previous = getX(batch, xR, xCOffset, d1);\n xC${n+1} = vec4(previous.zw, xTexelC${n+1}.xy);\n } else {\n xC${n+1} = vec4(0.0, 0.0, xTexelC${n+1}.xy);\n }\n `:`\n xC${n+1} = vec4(xTexelC${n}.zw, xTexelC${n+1}.xy);
2\n `):h+=1===e?`\n xC${n+1} = xTexelC${n};\n `:`\n xCOffset = xC + ${e};\n\n if (xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${n+1}Ready == 0) {\n xTexelC${n+1} = getX(batch, xR, xCOffset, d1);\n if (xCOffset + 1 >= inDims[1]) {\n xTexelC${n+1}.zw = vec2(0.0);\n }\n xTexelC${n+1}Ready = 1;\n }\n\n xC${n+1} = xTexelC${n+1};\n `}}else n<l&&(s%2==1?(h+=`\n xCOffset = xC + 1 - strides[1];\n if(xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${n}Ready == 0) {\n xTexelC${n} = getX(batch, xR, xCOffset, d1);\n // Need to manually clear unused channels in case\n // we're reading from recycled texture.\n if (xCOffset + 1 >= inDims[1]) {\n xTexelC${n}.zw = vec2(0.0);\n }\n xTexelC${n}Ready = 1;\n }\n\n if(xC + 1 >= 0 && xC + 1 < inDims[1] && xTexelC${n+1}Ready == 0) {\n xTexelC${n+1} = getX(batch, xR, xC + 1, d1);\n // Need to manually clear unused channels in case\n // we're reading from recycled texture.\n if (xC + 2 >= inDims[1]) {\n xTexelC${n+1}.zw = vec2(0.0);\n }\n xTexelC${n+1}Ready = 1;\n }\n\n xC${n} = vec4(xTexelC${n}.zw, xTexelC${n+1}.zw);\n `,n+1<l&&(h+=`\n final = vec4(0.0);\n xCOffset = xC + 1 + strides[1];\n if(xCOffset >= 0 && xCOffset < inDims[1]) {\n final = getX(batch, xR, xCOffset, d1);\n }\n xC${n+1} = vec4(xTexelC${n+1}.xy, final.xy);\n `)):(h+=`\n if(xC >= 0 && xC < inDims[1] && xTexelC${n}Ready == 0) {\n xTexelC${n} = getX(batch, xR, xC, d1);\n if (xC + 1 >= inDims[1]) {\n xTexelC${n}.zw = vec2(0.0);\n }\n xTexelC${n}Ready = 1;\n }\n\n xCOffset = xC + strides[1];\n if(xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${n+1}Ready == 0) {\n xTexelC${n+1} = getX(batch, xR, xCOffset, d1);\n if (xCOffset + 1 >= inDims[1]) {\n xTexelC${n+1}.zw = vec2(0.);\n }\n xTexelC${n+1}Ready = 1;\n }\n\n xC${n} = vec4(\n xTexelC${n}.xy, xTexelC${n+1}.xy);\n `,n+1<l&&(h+=`\n xC${n+1} = vec4(xTexelC${n}.zw, xTexelC${n+1}.zw);\n `)));n<l&&(h+=`\n wTexel = getW(r, ${n}, d1, d2);\n dotProd += xC${n}.xxzz * vec4(wTexel.xy, wTexel.xy);\n if(d1 + 1 < ${e.inChannels}) {\n dotProd += xC${n}.yyww * vec4(wTexel.zw, wTexel.zw);\n }\n `,n+1<l&&(h+=`\n wTexel = getW(r, ${n+1}, d1, d2);\n dotProd += xC${n+1}.xxzz * vec4(wTexel.xy, wTexel.xy);\n if(d1 + 1 < ${e.inChannels}) {\n dotProd += xC${n+1}.yyww * vec4(wTexel.zw, wTexel.zw);\n }\n `))}h+="\n }\n ",h+="\n }\n ",h+="\n }\n ";let d="",f="";n&&(d=r?`vec4 activation(vec4 a) {\n vec4 b = getPreluActivationWeightsAtOutCoords();\n ${n}\n }`:o?`vec4 activation(vec4 a) {\n vec4 b = getLeakyreluAlphaAtOutCoords();\n ${n}\n }`:`vec4 activation(vec4 x) {\n ${n}\n }`,f="result = activation(result);");const m=t?"result += getBiasAtOutCoords();":"";t&&this.variableNames.push("bias"),r&&this.variableNames.push("preluActivationWeights"),o&&this.variableNames.push("leakyreluAlpha"),this.userCode=`\n ${d}\n\n void main() {\n ivec4 coords = getOutputCoords();\n int batch = coords.x;\n ivec2 xRCCorner = coords.yz * strides - pads;\n int d2 = coords.w;\n int xRCorner = xRCCorner.x;\n int xCCorner = xRCCorner.y;\n\n //intialize dotProd with a small epsilon seems to reduce GPU accuracy loss.\n vec4 dotProd = vec4(0.000000000000001);\n\n ${h}\n\n vec4 result = dotProd - vec4(0.000000000000001);\n ${m}\n ${f}\n setOutput(result);\n }\n `}}class fo{constructor(e,t){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.customUniforms=[{name:"inputShape",type:"ivec4"},{name:"pad",type:"ivec2"},{name:"stride",type:"ivec2"},{name:"dilation",type:"ivec2"},{name:"inChannels",type:"int"},{name:"itemsPerBlockRow",type:"int"},{name:"outWidth",type:"int"}],this.outputShape=e,this.enableShapeUniforms=pe(this.outputShape.length);const{dataFormat:n}=t,r=z(),a="channelsLast"===n,o=a?1:2,s=a?2:3,i=this.enableShapeUniforms?"if(blockIndex < outShape[2] && pos < outShape[1]) {":`if(blockIndex < ${e[2]} && pos < ${e[1]}) {`;let u="";for(let e=0;e<=1;e++)for(let t=0;t<=1;t++)u+=`\n blockIndex = rc.z + ${t};\n pos = rc.y + ${e};\n\n ${i}\n offsetY = int(blockIndex / outWidth) * stride[0] - pad[0];\n d0 = offsetY + dilation[0] * (pos / itemsPerBlockRow);\n\n if(d0 < inputShape[${o}] && d0 >= 0) {\n // Use custom imod instead mod. On Intel GPU, mod may generate\n // unexpected value.\n // https://github.com/tensorflow/tfjs/issues/5447\n offsetX = imod(blockIndex, outWidth) * stride[1] - pad[
21];\n d1 = offsetX + dilation[1] * (imod(pos, itemsPerBlockRow) /\n inChannels);\n\n if(d1 < inputShape[${s}] && d1 >= 0) {\n\n ch = imod(pos, inChannels);\n\n if (${a}) {\n innerDims = vec2(d1, ch);\n result[${2*e+t}] = getChannel(\n getA(rc.x, d0, int(innerDims.x),\n int(innerDims.y)), innerDims);\n } else {\n innerDims = vec2(d0, d1);\n result[${2*e+t}] = getChannel(\n getA(rc.x, ch, int(innerDims.x),\n int(innerDims.y)), innerDims);\n }\n }\n }\n }\n `;this.userCode=`\n void main() {\n ivec3 rc = getOutputCoords();\n\n vec4 result = vec4(0);\n\n int blockIndex, pos, offsetY, d0, offsetX, d1, ch;\n vec2 innerDims;\n\n ${u}\n\n ${r.output} = result;\n }\n `}}function mo(e,t){const n=e.length;return n>=3?t?[...e.slice(0,-3),e[n-3]*e[n-2],e[n-1]]:[...e.slice(0,-3),e[n-3],e[n-2]*e[n-1]]:!t&&1===n&&e[0]>1?[e[0],1]:null}function go({x:e,filter:t,convInfo:n,backend:r,bias:o=null,preluActivationWeights:s=null,leakyreluAlpha:i=0,activation:u=null}){const c=e.shape,l=r.texData.get(e.dataId),p=n.inChannels,h=c[0]*c[1]*c[2],d=n.outChannels,f="channelsLast"===n.dataFormat,m=!1;let g;const y=[];if(null!=s){const e=mo(s.shape,f);null!=e&&(s=Rr({inputs:{x:s},backend:r,attrs:{shape:e}}),y.push(s))}if(null!=o){const e=mo(o.shape,f);null!=e&&(o=Rr({inputs:{x:o},backend:r,attrs:{shape:e}}),y.push(o))}if(!((1===h||1===d)&&p>1e3)&&l.isPacked&&f&&null!=l.texture&&c[2]%2!=0&&a.ZSL.arraysEqual(l.shape.slice(-3),c.slice(-3))){const p=c[0]*c[1]*(c[2]+1),h={dataId:e.dataId,shape:[1,p,n.inChannels],dtype:e.dtype},d=l.shape;l.shape=l.shape.slice(),l.shape[l.shape.length-2]++,a.ZSL.assert(_(l.shape,h.shape),()=>`packed reshape ${l.shape} to ${h.shape} isn't free`);const f=Rr({inputs:{x:t},backend:r,attrs:{shape:[1,n.inChannels,n.outChannels]}});y.push(f);const x=Wr({a:h,b:f,backend:r,transposeA:false,transposeB:m,bias:o,activation:u,preluActivationWeights:s,leakyreluAlpha:i}),b=r.texData.get(x.dataId);a.ZSL.assert(b.isPacked,()=>"batchMatMul result is expected to be packed"),l.shape=d,b.shape=n.outShape,g=lr({inputs:{x:x},backend:r}),g.shape=n.outShape,y.push(x)}else{const a=n.outHeight*n.outWidth,c=Rr({inputs:{x:e},backend:r,attrs:{shape:f?[n.batchSize,a,n.inChannels]:[n.batchSize,n.inChannels,a]}}),l=Rr({inputs:{x:t},backend:r,attrs:{shape:[1,n.inChannels,n.outChannels]}}),p=Wr({a:f?c:l,b:f?l:c,transposeA:!f,transposeB:m,backend:r,bias:o,activation:u,preluActivationWeights:s,leakyreluAlpha:i});g=Rr({inputs:{x:p},backend:r,attrs:{shape:n.outShape}}),y.push(c),y.push(l),y.push(p)}for(const e of y)r.disposeIntermediateTensorInfo(e);return g}function yo({x:e,filter:t,convInfo:n,backend:r,bias:o=null,preluActivationWeights:s=null,leakyreluAlpha:i=0,activation:u=null}){const{filterWidth:c,filterHeight:l,inChannels:p,outWidth:h,outHeight:d,dataFormat:f}=n,m="channelsLast"===f,g=c*l*p,y=d*h,x=[n.batchSize,g,y],b=[];if(null!=s){const e=mo(s.shape,m);null!=e&&(s=Rr({inputs:{x:s},backend:r,attrs:{shape:e}}),b.push(s))}if(null!=o){const e=mo(o.shape,m);null!=e&&(o=Rr({inputs:{x:o},backend:r,attrs:{shape:e}}),b.push(o))}const v=Rr({inputs:{x:t},backend:r,attrs:{shape:[1,g,a.ZSL.sizeFromShape(t.shape)/g]}});b.push(v);const w=new fo(x,n),T=[e.shape,[n.padInfo.top,n.padInfo.left],[n.strideHeight,n.strideWidth],[n.dilationHeight,n.dilationWidth],[n.inChannels],[n.filterWidth*n.inChannels],[n.outWidth]],S=r.runWebGLProgram(w,[e],"float32",T),C=Rr({inputs:{x:S},backend:r,attrs:{shape:x}});b.push(S),b.push(C);const k=null!=o,E=null!=s,$="leakyrelu"===u,N=u?Sr(u,!0):null,I=new Cr(m?C.shape:v.shape,m?v.shape:C.shape,m?[n.batchSize,y,n.outChannels]:[n.batchSize,n.outChannels,y],!0,!1,k,N,E,$),A=m?[C,v]:[v,C];if(o&&A.push(o),E&&A.push(s),$){const e=r.makeTensorInfo([],"float32",a.ZSL.createScalarValue(i,"float32"));A.push(e),b.push(e)}
vendor: 5,153 bytes, line 2
2const R=r.runWebGLProgram(I,A,"float32"),_=Rr({inputs:{x:R},backend:r,attrs:{shape:n.outShape}});b.push(R);for(const e of b)r.disposeIntermediateTensorInfo(e);return _}const xo={kernelName:a.p2J,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:o,filter:s}=t,{strides:i,pad:u,dataFormat:c,dilations:l,dimRoundingMode:p}=r,h=a.C0T.convertConv2DDataFormat(c),d=a.C0T.computeConv2DInfo(o.shape,s.shape,i,l,u,p,!1,h);let f;if(1!==d.filterHeight||1!==d.filterWidth||1!==d.dilationHeight||1!==d.dilationWidth||1!==d.strideHeight||1!==d.strideWidth||"SAME"!==d.padInfo.type&&"VALID"!==d.padInfo.type)if(d.strideWidth<=2&&"channelsLast"===h&&(0,a._K2)().getBool("WEBGL_EXP_CONV")){const e=new ho(d),t=[[d.padInfo.top,d.padInfo.left],[d.strideHeight,d.strideWidth],[d.dilationHeight,d.dilationWidth],[d.inHeight,d.inWidth]];f=n.runWebGLProgram(e,[o,s],"float32",t)}else if((0,a._K2)().getBool("WEBGL_CONV_IM2COL"))f=yo({x:o,filter:s,convInfo:d,backend:n});else{const e=new lo(d);f=n.runWebGLProgram(e,[o,s],"float32")}else f=go({x:o,filter:s,convInfo:d,backend:n});const m=Rr({inputs:{x:f},backend:n,attrs:{shape:d.outShape}});return n.disposeIntermediateTensorInfo(f),m}};class bo{constructor(e){this.variableNames=["x","dy"],this.outputShape=e.filterShape;const t=e.strideHeight,n=e.strideWidth,r=e.padInfo.top,a=e.padInfo.left,o="channelsLast"===e.dataFormat;this.userCode=`\n void main() {\n ivec4 coords = getOutputCoords();\n int wR = coords.x;\n int wC = coords.y;\n int d1 = coords.z;\n int d2 = coords.w;\n\n // Convolve x(?, ?, d1) with dy(:, :, d2) to get dw(wR, wC, d1, d2).\n // ? = to be determined. : = across all values in that axis.\n float dotProd = 0.0;\n\n for (int b = 0; b < ${e.batchSize}; b++) {\n for (int yR = 0; yR < ${e.outHeight}; yR++) {\n int xR = wR + yR * ${t} - ${r};\n\n if (xR < 0 || xR >= ${e.inHeight}) {\n continue;\n }\n\n for (int yC = 0; yC < ${e.outWidth}; yC++) {\n int xC = wC + yC * ${n} - ${a};\n\n if (xC < 0 || xC >= ${e.inWidth}) {\n continue;\n }\n\n if (${o}) {\n float dyValue = getDy(b, yR, yC, d2);\n float xValue = getX(b, xR, xC, d1);\n dotProd += (xValue * dyValue);\n } else {\n float dyValue = getDy(b, d2, yR, yC);\n float xValue = getX(b, d1, xR, xC);\n dotProd += (xValue * dyValue);\n }\n\n }\n }\n }\n setOutput(dotProd);\n }\n `}}class vo{constructor(e){this.variableNames=["dy","W"],this.outputShape=e.inShape;const t=e.filterHeight,n=e.filterWidth,r=e.strideHeight,a=e.strideWidth,o="channelsLast"===e.dataFormat,s=t-1-e.padInfo.top,i=n-1-e.padInfo.left,u=o?1:2,c=o?2:3,l=o?3:1;this.userCode=`\n const ivec2 pads = ivec2(${s}, ${i});\n\n void main() {\n ivec4 coords = getOutputCoords();\n int batch = coords[0];\n int d1 = coords[${l}];\n\n ivec2 dyCorner = ivec2(coords[${u}], coords[${c}]) - pads;\n int dyRCorner = dyCorner.x;\n int dyCCorner = dyCorner.y;\n\n // Convolve dy(?, ?, d2) with w(:, :, d1, d2) to compute dx(xR, xC, d1).\n // ? = to be determined. : = across all values in that axis.\n float dotProd = 0.0;\n for (int wR = 0; wR < ${t}; wR++) {\n float dyR = float(dyRCorner + wR) / ${r}.0;\n\n if (dyR < 0.0 || dyR >= ${e.outHeight}.0 || fract(dyR) > 0.0) {\n continue;\n }\n int idyR = int(dyR);\n\n int wRPerm = ${t} - 1 - wR;\n\n for (int wC = 0; wC < ${n}; wC++) {\n float dyC = float(dyCCorner + wC) / ${a}.0;\n\n if (dyC < 0.0 || dyC >= ${e.outWidth}.0 ||\n fract(dyC) > 0.0) {\n continue;\n }\n int idyC = int(dyC);\n\n int wCPerm = ${n} - 1 - wC;\n\n for (int d2 = 0; d2 < ${e.outChannels}; d2++) {\n\n if (${o}) {\n float xValue = getDy(batch, idyR, idyC, d2);\n float wValue = getW(wRPerm, wCPerm, d1, d2);\n dotProd += xValue * wValue;\n } else {\n float xValue = getDy(batch, d2, idyR, idyC);\n float wValue = getW(wRPerm, wCPerm, d1, d2);\n dotProd += xValue * wValue;\n }\n\n }\n }\n }\n setOutput(dotProd);\n }\n `}}class wo{constructor(e){this.variableNames=["x","dy"],this.outputShape=e.filterShape;const t=e.strideDepth,n=e.strideHeight,r=e.strideWidth,a=e.padInfo.front,o=e.padInfo.top,s=e.padInfo.left;this.userCode=`\n void main() {\n ivec5 coords = getOutputCoords();\n int wF = coords.x;\n int wR = coords.y;\n int wC = coords.z;\n int d1 = coords.w;\n int d2 = coords.u;\n\n float dotProd = 0.0;\n\n for (int b = 0; b < ${e.batchSize}; b++) {\n for (int yF = 0; yF < ${e.outDepth};
2 yF++) {\n int xF = wF + yF * ${t} - ${a};\n\n if (xF < 0 || xF >= ${e.inDepth}) {\n continue;\n }\n\n for (int yR = 0; yR < ${e.outHeight}; yR++) {\n int xR = wR + yR * ${n} - ${o};\n\n if (xR < 0 || xR >= ${e.inHeight}) {\n continue;\n }\n\n for (int yC = 0; yC < ${e.outWidth}; yC++) {\n int xC = wC + yC * ${r} - ${s};\n\n if (xC < 0 || xC >= ${e.inWidth}) {\n continue;\n }\n\n float dyValue = getDy(b, yF, yR, yC, d2);\n float xValue = getX(b, xF, xR, xC, d1);\n dotProd += (xValue * dyValue);\n }\n }\n }\n }\n setOutput(dotProd);\n }\n `}}class To{constructor(e){this.variableNames=["dy","W"],this.outputShape=e.inShape;const t=e.filterDepth,n=e.filterHeight,r=e.filterWidth,a=e.strideDepth,o=e.strideHeight,s=e.strideWidth,i=t-1-e.padInfo.front,u=n-1-e.padInfo.top,c=r-1-e.padInfo.left;this.userCode=`\n const ivec3 pads = ivec3(${i}, ${u}, ${c});\n\n void main() {\n ivec5 coords = getOutputCoords();\n int batch = coords.x;\n int d1 = coords.u;\n\n\n ivec3 dyCorner = ivec3(coords.y, coords.z, coords.w) - pads;\n int dyFCorner = dyCorner.x;\n int dyRCorner = dyCorner.y;\n int dyCCorner = dyCorner.z;\n\n float dotProd = 0.0;\n for (int wF = 0; wF < ${t}; wF++) {\n float dyF = float(dyFCorner + wF) / ${a}.0;\n\n if (dyF < 0.0 || dyF >= ${e.outDepth}.0 || fract(dyF) > 0.0) {\n continue;\n }\n int idyF = int(dyF);\n\n int wFPerm = ${t} - 1 - wF;\n\n for (int wR = 0; wR < ${n}; wR++) {\n float dyR = float(dyRCorner + wR) / ${o}.0;\n\n if (dyR < 0.0 || dyR >= ${e.outHeight}.0 ||\n fract(dyR) > 0.0) {\n continue;\n }\n int idyR = int(dyR);\n\n int wRPerm = ${n} - 1 - wR;\n\n for (int wC = 0; wC < ${r}; wC++) {\n float dyC = float(dyCCorner + wC) / ${s}.0;\n\n if (dyC < 0.0 || dyC >= ${e.outWidth}.0 ||\n fract(dyC) > 0.0) {\n continue;\n }\n int idyC = int(dyC);\n\n int wCPerm = ${r} - 1 - wC;\n\n for (int d2 = 0; d2 < ${e.outChannels}; d2++) {\n float xValue = getDy(batch, idyF, idyR, idyC, d2);\n float wValue = getW(wFPerm, wRPerm, wCPerm, d1, d2);\n dotProd += xValue * wValue;\n }\n }\n }\n }\n setOutput(dotProd);\n }\n `}}const So={kernelName:a.rFm,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:o,dy:s}=t,{strides:i,pad:u,dataFormat:c,dimRoundingMode:l,filterShape:p}=r,h=a.C0T.convertConv2DDataFormat(c),d=a.C0T.computeConv2DInfo(o.shape,p,i,1,u,l,!1,h),f=new bo(d);return n.runWebGLProgram(f,[o,s],"float32")}};const Co={kernelName:a.jfg,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{dy:o,filter:s}=t,{inputShape:i,strides:u,pad:c,dataFormat:l,dimRoundingMode:p}=r,h=a.C0T.convertConv2DDataFormat(l),d=a.C0T.computeConv2DInfo(i,s.shape,u,1,c,p,!1,h),f=new vo(d);return n.runWebGLProgram(f,[o,s],"float32")}};const ko={kernelName:a.A1h,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:o,filter:s}=t,{strides:i,pad:u,dilations:c}=r,l=a.C0T.computeConv3DInfo(o.shape,s.shape,i,c,u),p=new po(l);return n.runWebGLProgram(p,[o,s],"float32")}};const Eo={kernelName:a.iGz,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:o,dy:s}=t,{strides:i,pad:u,filterShape:c}=r,l=a.C0T.computeConv3DInfo(o.shape,c,i,1,u),p=new wo(l);return n.runWebGLProgram(p,[o,s],"float32")}};const $o={kernelName:a.gC7,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{dy:o,filter:s}=t,{pad:i,strides:u,inputShape:c}=r,l=a.C0T.computeConv3DInfo(c,s.shape,u,1,i),p=new To(l);return n.runWebGLProgram(p,[o,s],"float32")}},No=wr({opSnippet:vr+"\n return cos(x);\n"}),Io={kernelName:a.Mn0,backendName:"webgl",kernelFunc:No},Ao=wr({opSnippet:"\n float e2x = exp(-x);\n return (e2x + 1.0 / e2x) / 2.0;\n"}),Ro={kernelName:a.MnK,backendName:"webgl",kernelFunc:Ao};class _o{constructor(e,t,n,r,a){this.variableNames=["Image","Boxes","BoxInd"],this.outputShape=[];const[o,s,i,u]=e,[c]=t,[l,p]=n;this.outputShape=[c,l,p,u];const h="bilinear"===r?1:0,[d,f]=[s-1+".0",i-1+".0"],[m,g,y]=l>1?[""+(s-1)/(l-1),"(y2-y1) * height_ratio",`y1*${d} + float(y)*(height_scale)`]:["0.0","0.0",`0.5 * (y1+y2) * ${d}`],[x,b,v]=p>1?[""+(i-1)/(p-1),"(x2-x1) * width_ratio",`x1*${f} + float(x)*(width_scale)`]:["0.0","0.0",`0.5 * (x1+x2) * ${f}`];this.userCode=`\n const float height_ratio = float(${m});\n const float width_ratio = float(${x});\n void main() {\n ivec4 coords = getOutputCoords();\n int b = coords[0];\n int y = coords[1];\n int x = coords[2];\n int d = coords[3];\n\n // get box vals\n float y1 = getBoxes(b,0);\n float x1 = getBoxes(b,1);\n float y2 = getBoxes(b,2);\n float x2 = getBoxes(b,3);\n\n // get image in batch index\n int bInd = round(getBoxInd(b));\n if(bInd < 0 || bInd >= ${o}) {\n return;\n }\n\n float height_scale = ${g};\n float width_scale = ${b};\n\n float in_y = ${y};\n if( in_y < 0.0 || in_y > ${d} ) {\n setOutput(float(${a}));\n return;\n }\n float in_x = ${v};\n if( in_x < 0.0 || in_x > ${f} ) {\n setOutput(float(${a}));\n return;\n }\n\n vec2 sourceFracIndexCR = vec2(in_x,in_y);\n if(${h} == 1) {\n // Compute the four integer indices.\n ivec2 sourceFloorCR = ivec2(sourceFracIndexCR);\n ivec2 sourceCeilCR = ivec2(ceil(sourceFracIndexCR));\n\n float topLeft = getImage(b, sourceFloorCR.y, sourceFloorCR.x, d);\n float bottomLeft = getImage(b, sourceCeilCR.y, sourceFloorCR.x, d);\n float topRight = getImage(b, sourceFloorCR.y, sourceCeilCR.x, d);\n float bottomRight = getImage(b, sourceCeilCR.y, sourceCeilCR.x, d);\n\n vec2 fracCR = sourceFracIndexCR - vec2(sourceFloorCR);\n\n float top = topLeft + (topRight - topLeft) * fracCR.x;\n float bottom = bottomLeft + (bottomRight - bottomLeft) * fracCR.x;\n float newValue = top + (bottom - top) * fracCR.y;\n setOutput(newValue);\n } else {\n // Compute the coordinators of nearest neighbor point.\n ivec2 sourceNearestCR = ivec2(floor(\n sourceFracIndexCR + vec2(0.5,0.5)));\n float newValue = getImage(b, sourceNearestCR.y, sourceNearestCR.x, d);\n setOutput(newValue);\n }\n }\n `}}const Oo={kernelName:a.MRQ,backendName:"webgl",kernelFunc:e=>{const{inputs:t,backend:n,attrs:r}=e,{image:a,boxes:o,boxInd:s}=t,{cropSize:i,method:u,extrapolationValue:c}
vendor: 10,711 bytes, line 2
2=r,l=new _o(a.shape,o.shape,i,u,c);return n.runWebGLProgram(l,[a,o,s],"float32")}};var Fo;!function(e){e.Prod="*",e.Sum="+"}(Fo||(Fo={}));class Do{constructor(e,t,n,r){this.op=e,this.outputShape=t,this.variableNames=["x"],this.customUniforms=[{name:"index",type:"float"}];const a=this.outputShape.length,o=this.op===Fo.Prod?"1.0":"0.0",s=n?o:`getX(${Lo(a,"coords",this.op)})`,i=this.outputShape[this.outputShape.length-1];let u="",c="";n?(u=r?"end != "+(i-1):"end != 0",c=r?"end + 1":"end - 1"):(u=r?`end + pow2 < ${i}`:"end >= pow2",c=r?"end + pow2":"end - pow2"),this.userCode=`\n void main() {\n ${ae(a)} coords = getOutputCoords();\n int end = ${Mo(a,"coords",this.op)};\n float val = ${s};\n int pow2 = int(pow(2.0, index));\n if (${u}) {\n int idx = ${c};\n ${Mo(a,"coords",this.op)} = idx;\n val ${this.op}= getX(${Lo(a,"coords",this.op)});\n }\n setOutput(val);\n }\n `}}function Lo(e,t,n){if(1===e)return`${t}`;if(2===e)return`${t}.x, ${t}.y`;if(3===e)return`${t}.x, ${t}.y, ${t}.z`;if(4===e)return`${t}.x, ${t}.y, ${t}.z, ${t}.w`;throw new Error(`Cumulative ${n} for rank ${e} is not yet supported`)}function Mo(e,t,n){if(1===e)return`${t}`;if(2===e)return`${t}.y`;if(3===e)return`${t}.z`;if(4===e)return`${t}.w`;throw new Error(`Cumulative ${n} for rank ${e} is not yet supported`)}function Po(e,t,n,r,o,s){const i=t.shape.length,u=a.C0T.getAxesPermutation([r],i);let c=t;null!=u&&(c=zr({inputs:{x:t},backend:n,attrs:{perm:u}}));const l=a.C0T.getInnerMostAxes(1,i)[0];if(l!==i-1)throw new Error(`WebGL cumprod shader expects an inner-most axis=${t.shape.length-1} but got axis=${r}`);const p=c.shape[l];let h=lr({inputs:{x:c},backend:n});for(let t=0;t<=Math.ceil(Math.log2(p))-1;t++){const r=new Do(e,c.shape,!1,s),a=[[t]],o=h;h=n.runWebGLProgram(r,[h],h.dtype,a),n.disposeIntermediateTensorInfo(o)}if(o){const t=new Do(e,c.shape,o,s),r=h;h=n.runWebGLProgram(t,[h],h.dtype),n.disposeIntermediateTensorInfo(r)}if(null!=u){const e=zr({inputs:{x:h},backend:n,attrs:{perm:a.C0T.getUndoAxesPermutation(u)}});return n.disposeIntermediateTensorInfo(h),n.disposeIntermediateTensorInfo(c),e}return h}const Bo={kernelName:a.jj_,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{axis:o,exclusive:s,reverse:i}=r;return Po(Fo.Prod,a,n,o,s,i)}};const Vo={kernelName:a.nY8,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{axis:o,exclusive:s,reverse:i}=r;return Po(Fo.Sum,a,n,o,s,i)}};const zo={kernelName:a.wNW,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a,weights:o}=t,{size:s,binaryOutput:i}=r;if(1===a.shape.length){const e=n.readSync(a.dataId),t=n.readSync(o.dataId),r=Yt(e,t,o.dtype,o.shape,s);return n.makeTensorInfo([s],o.dtype,r)}if(2===a.shape.length){const e=n.bufferSync(a),t=n.bufferSync(o),r=Zt(e,t,s,i);return n.makeTensorInfo(r.shape,o.dtype,r.values)}throw new Error(`Error in denseBincount: input must be at most rank 2, but got rank${a.shape.length}.`)}};class Uo{constructor(e,t,n){this.variableNames=["x"],this.outputShape=[],this.outputShape=e,this.blockSize=t,this.dataFormat=n,this.userCode=`\n void main() {\n ivec4 coords = getOutputCoords();\n int b = coords[0];\n int h = ${this.getHeightCoordString()};\n int w = ${this.getWidthCoordString()};\n int d = ${this.getDepthCoordString()};\n\n int in_h = h / ${t};\n int offset_h = imod(h, ${t});\n int in_w = w / ${t};\n int offset_w = imod(w, ${t});\n int offset_d = (offset_h * ${t} + offset_w) *\n ${this.getOutputDepthSize()};\n int in_d = d + offset_d;\n\n float result = ${this.getInputSamplingString()};\n setOutput(result);\n }\n `}getHeightCoordString(){return"NHWC"===this.dataFormat?"coords[1]":"coords[2]"}getWidthCoordString(){return"NHWC"===this.dataFormat?"coords[2]":"coords[3]"}getDepthCoordString(){return"NHWC"===this.dataFormat?"coords[3]":"coords[1]"}getOutputDepthSize(){return"NHWC"===this.dataFormat?this.outputShape[3]:this.outputShape[1]}getInputSamplingString(){return"NHWC"===this.dataFormat?"getX(b, in_h, in_w, in_d)":"getX(b, in_d, in_h, in_w)"}}const Wo={kernelName:a.TMz,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{blockSize:o,dataFormat:s}=r,i=a.shape[0],u=("NHWC"===s?a.shape[1]:a.shape[2])*o,c=("NHWC"===s?a.shape[2]:a.shape[3])*o,l=("NHWC"===s?a.shape[3]:a.shape[1])/(o*o),p=new Uo("NHWC"===s?[i,u,c,l]:[i,l,u,c],o,s);return n.runWebGLProgram(p,[a],a.dtype)}};class Go{constructor(e,t=!1,n=null,r=!1,a=!1){this.variableNames=["x","W"],this.customUniforms=[{name:"pads",type:"ivec2"},{name:"strides",type:"ivec2"},{name:"dilations",type:"ivec2"},{name:"inDims",type:"ivec2"}],this.outputShape=e.outShape,this.enableShapeUniforms=pe(this.outputShape.length);const o=e.filterHeight,s=e.filterWidth,i=e.outChannels/e.inChannels;let u="",c="";n&&(u=r?`float activation(float a) {\n float b = getPreluActivationWeightsAtOutCoords();\n ${n}\n }`:a?`float activation(float a) {\n float b = getLeakyreluAlphaAtOutCoords();\n ${n}\n }`:`\n float activation(float x) {\n ${n}\n }\n `,c="result = activation(result);");const l=t?"result += getBiasAtOutCoords();":"";t&&this.variableNames.push("bias"),r&&this.variableNames.push("preluActivationWeights"),a&&this.variableNames.push("leakyreluAlpha"),this.userCode=`\n ${u}\n\n void main() {\n ivec4 coords = getOutputCoords();\n int batch = coords.x;\n ivec2 xRCCorner = coords.yz * strides - pads;\n int d2 = coords.w;\n int d1 = d2 / ${i};\n int q = d2 - d1 * ${i};\n\n int xRCorner = xRCCorner.x;\n int xCCorner = xRCCorner.y;\n\n // Convolve x(?, ?, d1) with w(:, :, d1, q) to get y(yR, yC, d2).\n // ? = to be determined. : = across all values in that axis.\n float dotProd = 0.0;\n // TO DO(dsmilkov): Flatten the two for loops and vec4 the operations.\n for (int wR = 0; wR < ${o}; wR++) {\n int xR = xRCorner + wR * dilations[0];\n\n if (xR < 0 || xR >= inDims[0]) {\n continue;\n }\n\n for (int wC = 0; wC < ${s}; wC++) {\n int xC = xCCorner + wC * dilations[1];\n\n if (xC < 0 || xC >= inDims[1]) {\n continue;\n }\n\n float xVal = getX(batch, xR, xC, d1);\n float wVal = getW(wR, wC, d1, q);\n dotProd += xVal * wVal;\n }\n }\n\n float result = dotProd;\n ${l}\n ${c}\n setOutput(result);\n }\n `}}class jo{constructor(e,t=!1,n=null,r=!1,o=!1){this.variableNames=["x","W"],this.packedInputs=!0,this.packedOutput=!0,this.customUniforms=[{name:"pads",type:"ivec2"},{name:"strides",type:"ivec2"},{name:"dilations",type:"ivec2"},{name:"inDims",type:"ivec2"}],this.outputShape=e.outShape,this.enableShapeUniforms=pe(this.outputShape.length);const s=e.outChannels/e.inChannels,i=e.padInfo.left,u=e.strideWidth,c=e.dilationWidth,l=e.filterHeight,p=e.filterWidth,h=p;let d="\n int xR; int xC; int xCOffset;\n vec4 wTexel; vec4 previous; vec4 final;";for(let e=0;e<p;e++)d+=`\n vec4 xTexelC${2*e};\n int xTexelC${2*e}Ready;\n vec4 xTexelC${2*e+1};\n int xTexelC${2*e+1}Ready;\n vec4 xC${e};`;d+=`\n for (int r = 0; r < ${l}; r++) {\n `;for(let e=0;e<p;e++)d+=`\n xTexelC${2*e} = vec4(0.0);\n xTexelC${2*e}Ready = 0;\n xTexelC${2*e+1} = vec4(0.0);\n xTexelC${2*e+1}Ready = 0;\n xC${e} = vec4(0.0);`;d+="\n xR = xRCorner + r * dilations[0];\n if (xR >=0 && xR < inDims[0]) {\n ";for(let e=0;e<(h+1)/2;e++){const t=2*e;if(d+=`\n xC = xCCorner + ${t*c};\n `,1===u){if(t<p&&(i%2==1?(d+=`\n xCOffset = xC + 1;\n if (xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${t}Ready == 0) {\n xTexelC${t} = getX(batch, xR, xCOffset, d1);\n\n // Need to manually clear unused channels in case\n // we're reading from recycled texture.\n if (xCOffset + 1 >= inDims[1]) {\n xTexelC${t}.zw = vec2(0.0);\n }\n xTexelC${t}Ready = 1;\n }\n `,d+=1===c&&t>0?`\n xC${t} = vec4(xTexelC${t-2}.zw, xTexelC${t}.xy);\n `:`\n xCOffset = xC + 1 - 2;\n\n if (xCOffset >= 0 && xCOffset < inDims[1]) {\n previous = getX(batch, xR, xCOffset, d1);\n\n // Need to manually clear unused channels in case\n // we're reading from recycled texture.\n if (xCOffset + 1 >= inDims[1]) {\n previous.zw = vec2(0.0);\n }\n\n xC${t} = vec4(previous.zw, xTexelC${t}.xy);\n } else {\n xC${t} = vec4(0.0, 0.0, xTexelC${t}.xy);\n }\n `):d+=`\n if (xC >= 0 && xC < inDims[1] && xTexelC${t}Ready == 0) {\n xTexelC${t} = getX(batch, xR, xC, d1);\n if (xC + 1 >= inDims[1]) {\n xTexelC${t}.zw = vec2(0.0);\n }\n xTexelC${t}Ready = 1;\n }\n\n xC${t} = xTexelC${t};\n `,t+1<p)){const e=i%2==0?a.ZSL.nearestLargerEven(c):c;c%2==0&&i%2==1||c%2!=0&&i%2!=1?(d+=`\n xCOffset = xC + imod(pads[1], 2) + ${e};\n\n if (xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${t+1}Ready == 0) {\n xTexelC${t+1} = getX(batch, xR, xCOffset, d1);\n\n // Need to manually clear unused channels in case\n // we're reading from recycled texture.\n if (xCOffset + 1 >= inDims[1]) {\n xTexelC${t+1}.zw = vec2(0.0);\n }\n xTexelC${t+1}Ready = 1;\n }\n `,d+=c>1?`\n xCOffset -= 2;\n if (xCOffset >= 0 && xCOffset < inDims[1]) {\n previous = getX(batch, xR, xCOffset, d1);\n xC${t+1} = vec4(previous.zw, xTexelC${t+1}.xy);\n } else {\n xC${t+1} = vec4(0.0, 0.0, xTexelC${t+1}.xy);\n }\n `:`\n xC${t+1} = vec4(xTexelC${t}.zw, xTexelC${t+1}.xy);
2\n `):d+=1===e?`\n xC${t+1} = xTexelC${t};\n `:`\n xCOffset = xC + ${e};\n\n if (xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${t+1}Ready == 0) {\n xTexelC${t+1} = getX(batch, xR, xCOffset, d1);\n if (xCOffset + 1 >= inDims[1]) {\n xTexelC${t+1}.zw = vec2(0.0);\n }\n xTexelC${t+1}Ready = 1;\n }\n\n xC${t+1} = xTexelC${t+1};\n `}}else t<p&&(i%2==1?(d+=`\n xCOffset = xC + 1 - strides[1];\n if(xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${t}Ready == 0) {\n xTexelC${t} = getX(batch, xR, xCOffset, d1);\n // Need to manually clear unused channels in case\n // we're reading from recycled texture.\n if (xCOffset + 1 >= inDims[1]) {\n xTexelC${t}.zw = vec2(0.0);\n }\n xTexelC${t}Ready = 1;\n }\n\n if(xC + 1 >= 0 && xC + 1 < inDims[1] && xTexelC${t+1}Ready == 0) {\n xTexelC${t+1} = getX(batch, xR, xC + 1, d1);\n // Need to manually clear unused channels in case\n // we're reading from recycled texture.\n if (xC + 2 >= inDims[1]) {\n xTexelC${t+1}.zw = vec2(0.0);\n }\n xTexelC${t+1}Ready = 1;\n }\n\n xC${t} = vec4(xTexelC${t}.zw, xTexelC${t+1}.zw);\n `,t+1<p&&(d+=`\n final = vec4(0.0);\n xCOffset = xC + 1 + strides[1];\n if(xCOffset >= 0 && xCOffset < inDims[1]) {\n final = getX(batch, xR, xCOffset, d1);\n }\n xC${t+1} = vec4(xTexelC${t+1}.xy, final.xy);\n `)):(d+=`\n if(xC >= 0 && xC < inDims[1] && xTexelC${t}Ready == 0) {\n xTexelC${t} = getX(batch, xR, xC, d1);\n if (xC + 1 >= inDims[1]) {\n xTexelC${t}.zw = vec2(0.0);\n }\n xTexelC${t}Ready = 1;\n }\n\n xCOffset = xC + strides[1];\n if(xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${t+1}Ready == 0) {\n xTexelC${t+1} = getX(batch, xR, xCOffset, d1);\n if (xCOffset + 1 >= inDims[1]) {\n xTexelC${t+1}.zw = vec2(0.);\n }\n xTexelC${t+1}Ready = 1;\n }\n\n xC${t} = vec4(\n xTexelC${t}.xy, xTexelC${t+1}.xy);\n `,t+1<p&&(d+=`\n xC${t+1} = vec4(xTexelC${t}.zw, xTexelC${t+1}.zw);\n `)));t<p&&(d+=`\n wTexel = getW(r, ${t}, d1, q);\n dotProd += xC${t} * vec4(wTexel.xz, wTexel.xz);\n `,t+1<p&&(d+=`\n wTexel = getW(r, ${t+1}, d1, q);\n dotProd += xC${t+1} * vec4(wTexel.xz, wTexel.xz);\n `))}d+="\n }\n ",d+="\n }\n ";let f="",m="";n&&(f=r?`vec4 activation(vec4 a) {\n vec4 b = getPreluActivationWeightsAtOutCoords();\n ${n}\n }`:o?`vec4 activation(vec4 a) {\n vec4 b = getLeakyreluAlphaAtOutCoords();\n ${n}\n }`:`vec4 activation(vec4 x) {\n ${n}\n }`,m="result = activation(result);");const g=t?"result += getBiasAtOutCoords();":"";t&&this.variableNames.push("bias"),r&&this.variableNames.push("preluActivationWeights"),o&&this.variableNames.push("leakyreluAlpha"),this.userCode=`\n ${f}\n\n void main() {\n ivec4 coords = getOutputCoords();\n int batch = coords.x;\n ivec2 xRCCorner = coords.yz * strides - pads;\n int d2 = coords.w;\n int d1 = d2 / ${s};\n int q = d2 - d1 * ${s};\n int xRCorner = xRCCorner.x;\n int xCCorner = xRCCorner.y;\n\n //intialize dotProd with a small epsilon seems to reduce GPU accuracy loss.\n vec4 dotProd = vec4(0.000000000000001);\n\n ${d}\n\n vec4 result = dotProd - vec4(0.000000000000001);\n ${g}\n ${m}\n setOutput(result);\n }\n `}}const Ko={kernelName:a.tGH,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:o,filter:s}=t,{strides:i,pad:u,dilations:c,dimRoundingMode:l}=r;let p=c;null==p&&(p=[1,1]),a.ZSL.assert(a.C0T.eitherStridesOrDilationsAreOne(i,p),()=>`Error in depthwiseConv2d: Either strides or dilations must be 1. Got strides ${i} and dilations '${p}'`);const h=a.C0T.computeConv2DInfo(o.shape,s.shape,i,p,u,l,!0);let d;d=(0,a._K2)().getBool("WEBGL_PACK_DEPTHWISECONV")&&h.strideWidth<=2&&h.outChannels/h.inChannels===1?new jo(h):new Go(h);const f=[[h.padInfo.top,h.padInfo.left],[h.strideHeight,h.strideWidth],[h.dilationHeight,h.dilationWidth],[h.inHeight,h.inWidth
vendor: 4,840 bytes, line 2
2]];return n.runWebGLProgram(d,[o,s],"float32",f)}};class Ho{constructor(e){this.variableNames=["x","dy"],this.outputShape=e.filterShape;const t=e.strideHeight,n=e.strideWidth,r=e.padInfo.top,a=e.padInfo.left,o=e.outChannels/e.inChannels;this.userCode=`\n void main() {\n ivec4 coords = getOutputCoords();\n int wR = coords.x;\n int wC = coords.y;\n int d1 = coords.z;\n int dm = coords.w;\n int d2 = d1 * ${o} + dm;\n\n float dotProd = 0.0;\n\n // TO DO: Vec4 over the batch size\n for (int b = 0; b < ${e.batchSize}; b++) {\n for (int yR = 0; yR < ${e.outHeight}; yR++) {\n int xR = wR + yR * ${t} - ${r};\n\n if (xR < 0 || xR >= ${e.inHeight}) {\n continue;\n }\n\n for (int yC = 0; yC < ${e.outWidth}; yC++) {\n int xC = wC + yC * ${n} - ${a};\n\n if (xC < 0 || xC >= ${e.inWidth}) {\n continue;\n }\n\n float dyValue = getDy(b, yR, yC, d2);\n float xValue = getX(b, xR, xC, d1);\n dotProd += (xValue * dyValue);\n }\n }\n }\n setOutput(dotProd);\n }\n `}}class Yo{constructor(e){this.variableNames=["dy","W"],this.outputShape=e.inShape;const t=e.filterHeight,n=e.filterWidth,r=e.strideHeight,a=e.strideWidth,o=t-1-e.padInfo.top,s=n-1-e.padInfo.left,i=e.outChannels/e.inChannels;this.userCode=`\n const ivec2 pads = ivec2(${o}, ${s});\n\n void main() {\n ivec4 coords = getOutputCoords();\n int batch = coords[0];\n int d1 = coords[3];\n ivec2 dyCorner = coords.yz - pads;\n int dyRCorner = dyCorner.x;\n int dyCCorner = dyCorner.y;\n\n float dotProd = 0.0;\n\n for (int wR = 0; wR < ${t}; wR++) {\n float dyR = float(dyRCorner + wR) / ${r}.0;\n\n if (dyR < 0.0 || dyR >= ${e.outHeight}.0 || fract(dyR) > 0.0) {\n continue;\n }\n int idyR = int(dyR);\n\n int wRPerm = ${t} - 1 - wR;\n\n for (int wC = 0; wC < ${n}; wC++) {\n float dyC = float(dyCCorner + wC) / ${a}.0;\n\n if (dyC < 0.0 || dyC >= ${e.outWidth}.0 ||\n fract(dyC) > 0.0) {\n continue;\n }\n int idyC = int(dyC);\n\n int wCPerm = ${n} - 1 - wC;\n\n // TO DO: Vec4 over the channelMul\n for (int dm = 0; dm < ${i}; dm++) {\n int d2 = d1 * ${i} + dm;\n float xValue = getDy(batch, idyR, idyC, d2);\n float wValue = getW(wRPerm, wCPerm, d1, dm);\n dotProd += xValue * wValue;\n }\n }\n }\n setOutput(dotProd);\n }\n `}}const Zo={kernelName:a.X$8,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:o,dy:s}=t,{strides:i,dilations:u,pad:c,dimRoundingMode:l,filterShape:p}=r,h=a.C0T.computeConv2DInfo(o.shape,p,i,u,c,l,!0),d=new Ho(h);return n.runWebGLProgram(d,[o,s],"float32")}};const Xo={kernelName:a.nVu,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{dy:o,filter:s}=t,{strides:i,dilations:u,pad:c,dimRoundingMode:l,inputShape:p}=r,h=a.C0T.computeConv2DInfo(p,s.shape,i,u,c,l,!0),d=new Yo(h);return n.runWebGLProgram(d,[o,s],"float32")}};class qo{constructor(e){this.variableNames=["X"],this.outputShape=[e,e],this.userCode="\n void main() {\n ivec2 coords = getOutputCoords();\n float val = coords[0] == coords[1] ? getX(coords[0]) : 0.0;\n setOutput(val);\n }\n "}}const Qo={kernelName:a.ORI,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n}=e,{x:r}=t,o=[...r.shape,...r.shape],s=a.ZSL.sizeFromShape(r.shape),i=Rr({inputs:{x:r},backend:n,attrs:{shape:[s]}}),u=new qo(s),c=n.runWebGLProgram(u,[i],i.dtype),l=Rr({inputs:{x:c},backend:n,attrs:{shape:o}});return n.disposeIntermediateTensorInfo(i),n.disposeIntermediateTensorInfo(c),l}};class Jo{constructor(e){this.variableNames=["x","W"],this.outputShape=e.outShape;const{inHeight:t,inWidth:n,padInfo:r,strideHeight:a,strideWidth:o,filterHeight:s,filterWidth:i,dilationHeight:u,dilationWidth:c}=e,{top:l,left:p}=r;this.userCode=`\n const ivec2 strides = ivec2(${a}, ${o});\n const ivec2 pads = ivec2(${l}, ${p});\n const float neg_infinity = -3.4e38;\n\n void main() {\n ivec4 coords = getOutputCoords();\n int batch = coords.x;\n int d1 = coords.w;\n ivec2 outTopLeftCorner =\n coords.yz * strides - pads;\n int hBeg = outTopLeftCorner.x;\n int wBeg = outTopLeftCorner.y;\n\n float curVal = neg_infinity;\n for (int h = 0; h < ${s}; h++) {\n int hIn = hBeg + h * ${u};\n\n if (hIn >= 0 && hIn < ${t}
2) {\n for (int w = 0; w < ${i}; w++) {\n int wIn = wBeg + w * ${c};\n\n if (wIn >= 0 && wIn < ${n}) {\n float xVal = getX(batch, hIn, wIn, d1);\n float wVal = getW(h, w, d1);\n\n float val = xVal + wVal;\n if (val > curVal) {\n curVal = val;\n }\n }\n }\n }\n }\n\n float result = curVal;\n setOutput(result);\n }\n `}}const es={kernelName:a.jxD,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:o,filter:s}=t,{strides:i,pad:u,dilations:c}=r,l=a.C0T.computeDilation2DInfo(o.shape,s.shape,i,u,"NHWC",c);let p;const h=new Jo(l);p=n.runWebGLProgram(h,[o,s],"float32");const d=Rr({inputs:{x:p},backend:n,attrs:{shape:l.outShape}});return n.disposeIntermediateTensorInfo(p),d}};const ts={kernelName:a.Qgm,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{equation:o}=r,s=t,{allDims:i,summedDims:u,idDims:c}=a.C0T.decodeEinsumEquation(o,s.length);a.C0T.checkEinsumDimSizes(i.length,c,s);const{path:l,steps:p}=a.C0T.getEinsumComputePath(u,c),h=p.length;let d=null,f=i.length;const m=[];for(let e=0;e<h;++e){for(const t of p[e]){const{permutationIndices:e,expandDims:r}=a.C0T.getEinsumPermutation(f,c[t]);let o;a.C0T.isIdentityPermutation(e)?o=s[t]:(o=zr({inputs:{x:s[t]},backend:n,attrs:{perm:e}}),m.push(o));const i=o.shape.slice();for(let e=0;e<r.length;++e)i.splice(r[e],0,1);a.ZSL.arraysEqual(o.shape,i)||(o=Rr({inputs:{x:o},backend:n,attrs:{shape:i}}),m.push(o)),null===d?d=o:(d=Ir({inputs:{a:o,b:d},backend:n}),m.push(d))}e<h-1&&(l[e]>=0&&(d=Br({inputs:{x:d},backend:n,attrs:{axis:l[e]-(i.length-f),keepDims:!1}}),m.push(d)),f--)}for(const e of m)e!==d&&n.disposeIntermediateTensorInfo(e);return d}},ns=wr({opSnippet:"return (x >= 0.0) ? x : (exp(x) - 1.0);",packedOpSnippet:"\n vec4 result;\n\n result.r = (x.r >= 0.0) ? x.r : (exp(x.r) - 1.0);\n result.g = (x.g >= 0.0) ? x.g : (exp(x.g) - 1.0);\n result.b = (x.b >= 0.0) ? x.b : (exp(x.b) - 1.0);\n result.a = (x.a >= 0.0) ? x.a : (exp(x.a) - 1.0);\n\n return result;\n"}),rs={kernelName:a.Pah,backendName:"webgl",kernelFunc:ns},as={kernelName:a.rsH,backendName:"webgl",kernelFunc:e=>{const{inputs:t,backend:n}=e,{dy:r,y:o}=t,s=(0,a._K2)().getBool("WEBGL_PACK_BINARY_OPERATIONS")?new cr("\n vec4 bGTEZero = vec4(greaterThanEqual(b, vec4(0.)));
2\n return (bGTEZero * a) + ((vec4(1.0) - bGTEZero) * (a * (b + vec4(1.0))));\n",r.shape,o.shape):new ir("return (b >= 1.0) ? a : a * (b + 1.0);",r.shape,o.shape);return n.runWebGLProgram(s,[r,o],r.dtype)}},os=Tr({opSnippet:"return float(a == b);",packedOpSnippet:"\n return vec4(equal(a, b));\n",dtype:"bool",cpuKernelImpl:Jt}),ss={kernelName:a.BRl,backendName:"webgl",kernelFunc:os},is=wr({opSnippet:`\n // Error function is calculated approximately with elementary function.\n // See "Handbook of Mathematical Functions with Formulas,\n // Graphs, and Mathematical Tables", Abramowitz and Stegun.\n float p = ${a.C0T.ERF_P};\n float a1 = ${a.C0T.ERF_A1};\n float a2 = ${a.C0T.ERF_A2};\n float a3 = ${a.C0T.ERF_A3};\n float a4 = ${a.C0T.ERF_A4};\n float a5 = ${a.C0T.ERF_A5};\n\n float sign = sign(x);\n x = abs(x);\n float t = 1.0 / (1.0 + p * x);\n return sign * (1.0 - (((((a5*t + a4)*t) + a3)*t + a2)*t + a1)*t*exp(-x*x));\n`}),us={kernelName:a._s9,backendName:"webgl",kernelFunc:is},cs=wr({opSnippet:vr+"\n return exp(x);\n",packedOpSnippet:"\n vec4 result = exp(x);\n bvec4 isNaN = isnan(x);\n result.r = isNaN.r ? x.r : result.r;\n result.g = isNaN.g ? x.g : result.g;\n result.b = isNaN.b ? x.b : result.b;\n result.a = isNaN.a ? x.a : result.a;\n\n return result;\n",cpuKernelImpl:en,dtype:"float32"}),ls={kernelName:a.ox3,backendName:"webgl",kernelFunc:cs};function ps(e){const{inputs:t,attrs:n,backend:r}=e,{dim:o}=n,{input:s}=t,i=s.shape.length,u=s.shape.slice();let c=o;return o<0&&(a.ZSL.assert(-(i+1)<=o,()=>`Axis must be in the interval [${-(i+1)}, ${i}]`),c=i+o+1),u.splice(c,0,1),Rr({inputs:{x:s},backend:r,attrs:{shape:u}})}const hs={kernelName:a.ybN,backendName:"webgl",kernelFunc:ps},ds="return exp(x) - 1.0;",fs=wr({opSnippet:ds,packedOpSnippet:ds,cpuKernelImpl:tn}),ms={kernelName:a.ybj,backendName:"webgl",kernelFunc:fs};class gs{constructor(e,t,n){this.variableNames=["real","imag"];const r=t[1];this.outputShape=t;const a=n?`2.0 * ${Math.PI}`:`-2.0 * ${Math.PI}`,o=n?`${r}.0`:"1.0";let s;if("real"===e)s="return real * expR - imag * expI;";else{if("imag"!==e)throw new Error(`FFT component must be either "real" or "imag", got ${e}.`);s="return real * expI + imag * expR;"}this.userCode=`\n const float exponentMultiplier = ${a};\n\n float unaryOpComplex(float real, float expR, float imag, float expI) {\n ${s}\n }\n\n float mulMatDFT(int batch, int index) {\n float indexRatio = float(index) / float(${r});\n float exponentMultiplierTimesIndexRatio =\n exponentMultiplier * indexRatio;\n\n float result = 0.0;\n\n for (int i = 0; i < ${r}; i++) {\n // x = (-2|2 * PI / N) * index * i;\n float x = exponentMultiplierTimesIndexRatio * float(i);\n float expR = cos(x);\n float expI = sin(x);\n float real = getReal(batch, i);\n float imag = getImag(batch, i);\n\n result +=\n unaryOpComplex(real, expR, imag, expI) / ${o};\n }\n\n return result;\n }\n\n void main() {\n ivec2 coords = getOutputCoords();\n setOutput(mulMatDFT(coords[0], coords[1]));\n }\n `}}function ys(e,t,n){const r=n.texData.get(e.dataId),o=a.ZSL.sizeFromShape(e.shape),s=e.shape[e.shape.length-1],i=Rr({inputs:{x:e},backend:n,attrs:{shape:[o/s,s]}}),u=i.shape,c=new gs("real",u,t),l=new gs("imag",u,t),p=[{dataId:r.complexTensorInfos.real.dataId,dtype:r.complexTensorInfos.real.dtype,shape:u},{dataId:r.complexTensorInfos.imag.dataId,dtype:r.complexTensorInfos.imag.dtype,shape:u}],h=n.runWebGLProgram(c,p,"float32"),d=n.runWebGLProgram(l,p,"float32"),f=hr({inputs:{real:h,imag:d},backend:n});n.disposeIntermediateTensorInfo(h),n.disposeIntermediateTensorInfo(d);const m=Rr({inputs:{x:f},backend:n,attrs:{shape:e.shape}});return n.disposeIntermediateTensorInfo(i),n.disposeIntermediateTensorInfo(f),m}const xs={kernelName:a.rGP,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n}=e,{input:r}=t;return ys(r,!1,n)}};class bs{constructor(e,t){this.outputShape=[],this.customUniforms=[{name:"value",type:"float"}],this.variableNames=["x"],this.outputShape=e,this.userCode="\n void main() {\n // In
2put can be obtained from uniform value.\n setOutput(value);\n }\n "}}function vs(e){const{backend:t,attrs:n}=e,{shape:r,value:o}=n;let{dtype:s}=n;if(s=s||a.ZSL.inferDtype(o),"string"===s){const e=a.ZSL.getArrayFromDType(s,a.ZSL.sizeFromShape(r));return e.fill(o),t.makeTensorInfo(r,s,e)}{const e=new bs(r,o),n=[[o]];return t.runWebGLProgram(e,[],s,n)}}const ws={kernelName:a.SQl,backendName:"webgl",kernelFunc:vs};class Ts{constructor(e){this.variableNames=["Image"],this.outputShape=[];const t=e[2];this.outputShape=e,this.userCode=`\n void main() {\n ivec4 coords = getOutputCoords();\n int x = coords[2];\n\n int coordX = ${t} - x - 1;\n float outputValue;\n if(coordX >= 0 && coordX < ${t}) {\n outputValue = getImage(coords[0], coords[1], coordX, coords[3]);\n } else {\n outputValue = getImage(coords[0], coords[1], coords[2], coords[3]);\n }\n setOutput(outputValue);\n }\n `}}const Ss={kernelName:a.BxF,backendName:"webgl",kernelFunc:({inputs:e,backend:t})=>{const{image:n}=e,r=t,a=new Ts(n.shape);return r.runWebGLProgram(a,[n],n.dtype)}},Cs="return floor(x);",ks=wr({opSnippet:Cs,packedOpSnippet:Cs,cpuKernelImpl:nn}),Es={kernelName:a.ZgB,backendName:"webgl",kernelFunc:ks},$s=Tr({opSnippet:"\n float s = sign(a) * sign(b);\n int ia = round(a);\n int ib = round(b);\n if (ib != 0) {\n // Windows (D3D) wants guaranteed non-zero int division at compile-time.\n return float(idiv(ia, ib, s));\n } else {\n return NAN;\n }\n",packedOpSnippet:"\n ivec4 ia = round(a);\n ivec4 ib = round(b);\n bvec4 cond = notEqual(ib, ivec4(0));\n ivec4 result = ivec4(0);\n vec4 s = sign(a) * sign(b);\n\n // Windows (D3D) wants guaranteed non-zero int division at compile-time.\n if (cond[0]) {\n result[0] = idiv(ia[0], ib[0], s[0]);\n }\n if (cond[1]) {\n result[1] = idiv(ia[1], ib[1], s[1]);\n }\n if (cond[2]) {\n result[2] = idiv(ia[2], ib[2], s[2]);\n }\n if (cond[3]) {\n result[3] = idiv(ia[3], ib[3], s[3]);\n }\n return vec4(result);\n",dtype:"int32"}),Ns={kernelName:a.ElG,backendName:"webgl",kernelFunc:$s};class Is{constructor(e){this.variableNames=["A"];const t=z(),[n,r]=e;this.outputShape=e,this.userCode=`\n void main() {\n ivec3 coords = getOutputCoords();\n int texR = coords[0];\n int texC = coords[1];\n int depth = coords[2];\n vec2 uv = (vec2(texC, texR) + halfCR) / vec2(${r}.0, ${n}.0);\n\n vec4 values = ${t.texture2D}(A, uv);\n float value;\n if (depth == 0) {\n value = values.r;\n } else if (depth == 1) {\n value = values.g;\n } else if (depth == 2) {\n value = values.b;\n } else if (depth == 3) {\n value = values.a;\n }\n\n setOutput(floor(value * 255.0 + 0.5));\n }\n `}}class As{constructor(e){this.variableNames=["A"],this.packedInputs=!1,this.packedOutput=!0;const t=z(),[n,r]=e;this.outputShape=e,this.userCode=`\n void main() {\n ivec3 coords = getOutputCoords();\n int texR = coords[0];\n int texC = coords[1];\n int depth = coords[2];\n\n vec4 result = vec4(0.);\n\n for(int row=0; row<=1; row++) {\n for(int col=0; col<=1; col++) {\n texC = coords[1] + row;\n depth = coords[2] + col;\n\n vec2 uv = (vec2(texC, texR) + halfCR) /\n vec2(${r}.0, ${n}.0);\n vec4 values = ${t.texture2D}(A, uv);\n float value;\n if (depth == 0) {\n value = values.r;\n } else if (depth == 1) {\n value = values.g;\n } else if (depth == 2) {\n value = values.b;\n } else if (depth == 3) {\n value = values.a;\n }\n\n result[row * 2 + col] = floor(value * 255.0 + 0.5);\n }\n }\n\n ${t.output} = result;\n }\n `}}const Rs={kernelName:a.awo,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e;let{pixels:o}=t;const{numChannels:s}=r,i="undefined"!=typeof HTMLVideoElement&&o instanceof HTMLVideoElement,u="undefined"!=typeof HTMLImageElement&&o instanceof HTMLImageElement,[l,p]=i?[o.videoWidth,o.videoHeight]:[o.width,o.height],h=[p,l],d=[p,l,
2s];if(u||i){const e=(0,a._K2)().getBool("CANVAS2D_WILL_READ_FREQUENTLY_FOR_GPU");null!=_s&&e===Os||(Os=e,_s=document.createElement("canvas").getContext("2d",{willReadFrequently:Os})),_s.canvas.width=l,_s.canvas.height=p,_s.drawImage(o,0,0,l,p),o=_s.canvas}const f=n.makeTensorInfo(h,"int32");n.texData.get(f.dataId).usage=c.PIXELS,n.gpgpu.uploadPixelDataToTexture(n.getTexture(f.dataId),o);const m=(0,a._K2)().getBool("WEBGL_PACK")?new As(d):new Is(d),g=n.runWebGLProgram(m,[f],"int32");return n.disposeData(f.dataId),g}};let _s,Os=(0,a._K2)().getBool("CANVAS2D_WILL_READ_FREQUENTLY_FOR_GPU");const Fs={kernelName:a.aAr,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:o,filter:s,bias:i,preluActivationWeights:u}=t,{strides:c,pad:l,dataFormat:p,dilations:h,dimRoundingMode:d,activation:f,leakyreluAlpha:m}=r,g=a.C0T.convertConv2DDataFormat(p),y=a.C0T.computeConv2DInfo(o.shape,s.shape,c,h,l,d,!1,g);let x;const b=[],v=null!=i,w=null!=u,T="leakyrelu"===f,S=()=>{const e=[o,s],t=(e,t)=>{if("NCHW"===t&&1===e.shape.length&&1!==e.shape[0]){const t=Rr({inputs:{x:e},backend:n,attrs:{shape:[e.shape[0],1,1]}});return b.push(t),t}return e};if(v&&e.push(t(i,p)),w&&e.push(t(u,p)),T){const t=n.makeTensorInfo([],"float32",a.ZSL.createScalarValue(m,"float32"));e.push(t),b.push(t)}return e};if(1!==y.filterHeight||1!==y.filterWidth||1!==y.dilationHeight||1!==y.dilationWidth||1!==y.strideHeight||1!==y.strideWidth||"SAME"!==y.padInfo.type&&"VALID"!==y.padInfo.type)if(y.strideWidth<=2&&"channelsLast"===g&&(0,a._K2)().getBool("WEBGL_EXP_CONV")){const e=f?Sr(f,!0):null,t=new ho(y,v,e,w,T),r=[[y.padInfo.top,y.padInfo.left],[y.strideHeight,y.strideWidth],[y.dilationHeight,y.dilationWidth],[y.inHeight,y.inWidth]],a=S();x=n.runWebGLProgram(t,a,"float32",r)}else if((0,a._K2)().getBool("WEBGL_CONV_IM2COL"))x=yo({x:o,filter:s,convInfo:y,backend:n,bias:i,activation:f,preluActivationWeights:u,leakyreluAlpha:m});else{const e=f?Sr(f,!1):null,t=new lo(y,v,e,w,T),r=S();x=n.runWebGLProgram(t,r,"float32")}else x=go({x:o,filter:s,convInfo:y,backend:n,bias:i,activation:f,preluActivationWeights:u,leakyreluAlpha:m});const C=Rr({inputs:{x:x},backend:n,attrs:{shape:y.outShape}});return b.push(x),b.forEach(e=>n.disposeIntermediateTensorInfo(e)),C}};const Ds={kernelName:a.T7M,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:o,filter:s,bias:i,preluActivationWeights:u}=t,{strides:c,pad:l,dilations:p,dimRoundingMode:h,activation:d,leakyreluAlpha:f}=r,m=[];let g=p;null==g&&(g=[1,1]),a.ZSL.assert(a.C0T.eitherStridesOrDilationsAreOne(c,g),()=>`Error in depthwiseConv2d: Either strides or dilations must be 1. Got strides ${c} and dilations '${g}'`);const y=a.C0T.computeConv2DInfo(o.shape,s.shape,c,g,l,h,!0),x=(0,a._K2)().getBool("WEBGL_PACK_DEPTHWISECONV")&&y.strideWidth<=2&&y.outChannels/y.inChannels===1,b=d?Sr(d,x):null,v=[o,s],w=null!=i,T=null!=u,S="leakyrelu"===d;if(w&&v.push(i),T&&v.push(u),S){const e=n.makeTensorInfo([],"float32",a.ZSL.createScalarValue(f,"float32"));v.push(e),m.push(e)}let C;C=x?new jo(y,w,b,T,S):new Go(y,w,b,T,S);const k=[[y.padInfo.top,y.padInfo.left],[y.strideHeight,y.strideWidth],[y.dilationHeight,y.dilationWidth],[y.inHeight,y.inWidth]],E=n.runWebGLProgram(C,v,"float32",k);return m.forEach(e=>n.disposeIntermediateTensorInfo(e)),E}};class Ls{constructor(e,t,n,r){this.sliceDim=e,this.strides=t,this.paramsShape=r,this.variableNames=["x","indices"],this.outputShape=n;const a=ae(n.length);let o="\n int index;";for(let e=0;e<this.sliceDim;e++)o+=`\n index = round(getIndices(coords[0], ${e}));\n out_of_bounds = out_of_bounds || index < 0;\n out_of_bounds = out_of_bounds || index >= ${this.paramsShape[e]};\n flattenIndex += index * ${this.strides[e]};`;this.userCode=`\n void main() {\n ${a} coords = getOutputCoords();\n int flattenIndex = 0;\n bool out_of_bounds = false;\n\n ${o}\n\n setOutput(out_of_bounds ? 0.0 : getX(flattenIndex, coords[1]));\n }\n `}}const Ms={kernelName:a.O4G,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n}=e,{params:r,indices:o}=t,s=o.shape,i=s[s.length-1],u=a.ZSL.sizeFromShape(r.shape),[c,l,p,h]=a.C0T.prepareAndValidate(r,o),d=Rr({inputs:{x:o},backend:n,attrs:{shape:[l,i]}}),f=Rr({inputs:{x:r},backend:n,attrs:{shape:[a.ZSL.sizeFromShape(r.shape)/p,p]}});if(n.shouldExecuteOnCPU([r,o])||"string"===r.dtype){const e=n.readSync(o.dataId),t=n.bufferSync(r),a=rn(e,t,r.dtype,l,i,p,h,r.shape,u);return n.makeTensorInfo(c,r.dtype,a.values)}const m=new Ls(i,h,[l,p],r.shape),g=n.runWebGLProgram(m,[f,d],f.dtype),y=Rr({inputs:{x:g},backend:n,attrs:{shape:c}});return n.disposeIntermediateTensorInfo(d),n.disposeIntermediateTensorInfo(f),n.disposeIntermediateTensorInfo(g),y}};class Ps{constructor(e,t){this.variableNames=["A","indices"],this.outputShape=t,this.rank=t.length;const n=ae(this.rank),r=function(e){const t=["resRC.x","resRC.y","resRC.z","resRC.w"],n=[];for(let r=0;r<e.length;r++)2===r?n.push("index"):n.push(`${t[r]}`);return n.join()}(e);this.userCode=`\n void main() {\n ${n} resRC = getOutputCoords();\n int index = int(getIndices(resRC.x, resRC.z));\n float inBounds = (index >= 0) && (index < ${e[2]}) ? 1.0 : 0.0;\n setOutput(inBounds * getA(${r}));\n }\n `}}function Bs(e){const{inputs:t,backend:n,attrs:r}=e,{x:o,indices:s}=t,{axis:i,batchDims:u}=r,c=a.ZSL.parseAxisParam(i,o.shape)[0];if((0,a._K2)().get("DEBUG")){const e=n.readSync(s.dataId),t=o.shape[c];for(let n=0;n<e.length;++n){const r=e[n];a.ZSL.assert(r<=t-1&&r>=0,()=>`GatherV2: the index value ${r} is not in [0, ${t-1}]`)}}const l=a.C0T.segment_util.collectGatherOpShapeInfo(o,s,c,u),p=a.ZSL.sizeFromShape(s.shape),h=[],d=Rr({inputs:{x:o},backend:n,attrs:{shape:[l.batchSize,l.outerSize,l.dimSize,l.sliceSize]}}),f=Rr({inputs:{x:s},backend:n,attrs:{shape:[l.batchSize,p/l.batchSize]}});h.push(d),h.push(f);const m=[l.batchSize,l.outerSize,p/l.batchSize,l.sliceSize];if(n.shouldExecuteOnCPU([o,s])||"string"===o.dtype){const e=n.bufferSync(f),t=n.bufferSync(d),r=an(t,e,m);
2return h.forEach(e=>n.disposeIntermediateTensorInfo(e)),n.makeTensorInfo(l.outputShape,r.dtype,r.values)}const g=new Ps(d.shape,m),y=n.runWebGLProgram(g,[d,f],d.dtype);h.push(y);const x=Rr({inputs:{x:y},backend:n,attrs:{shape:l.outputShape}});return h.forEach(e=>n.disposeIntermediateTensorInfo(e)),x}const Vs={kernelName:a.mxL,backendName:"webgl",kernelFunc:Bs},zs=Tr({opSnippet:"return float(a > b);",packedOpSnippet:"\n return vec4(greaterThan(a, b));\n",cpuKernelImpl:on,dtype:"bool"}),Us={kernelName:a.XhZ,backendName:"webgl",kernelFunc:zs},Ws=Tr({opSnippet:"return float(a >= b);",packedOpSnippet:"\n return vec4(greaterThanEqual(a, b));\n",dtype:"bool",cpuKernelImpl:sn}),Gs={kernelName:a.lLS,backendName:"webgl",kernelFunc:Ws};const js={kernelName:a.OAQ,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n}=e,{input:r}=t;return ys(r,!0,n)}},Ks=wr({opSnippet:"return float(!isnan(x) && !isinf(x));",dtype:"bool"}),Hs={kernelName:a.gIW,backendName:"webgl",kernelFunc:Ks},Ys=wr({opSnippet:"return float(isinf(x));",dtype:"bool"}),Zs={kernelName:a.E3$,backendName:"webgl",kernelFunc:Ys},Xs=wr({opSnippet:"return float(isnan(x));",dtype:"bool"}),qs={kernelName:a.iPs,backendName:"webgl",kernelFunc:Xs},Qs=Tr({opSnippet:"return float(a < b);",packedOpSnippet:"\n return vec4(lessThan(a, b));\n",cpuKernelImpl:un,dtype:"bool"}),Js={kernelName:a.mIA,backendName:"webgl",kernelFunc:Qs},ei=Tr({opSnippet:"return float(a <= b);",packedOpSnippet:"\n return vec4(lessThanEqual(a, b));\n",cpuKernelImpl:cn,dtype:"bool"}),ti={kernelName:a.CwD,backendName:"webgl",kernelFunc:ei};const ni={kernelName:a.mnI,backendName:"webgl",kernelFunc:function(e){const{backend:t,attrs:n}=e,{start:r,stop:a,num:o}=n,s=ln(r,a,o);return t.makeTensorInfo([s.length],"float32",s)}},ri=wr({opSnippet:vr+"\n return x < 0.0 ? 0./0. : log(x);\n",packedOpSnippet:"\n vec4 result = log(x);\n bvec4 isNaN = isnan(x);\n result.r = isNaN.r ? x.r : (x.r < 0.0 ? 0./0. : result.r);\n result.g = isNaN.g ? x.g : (x.g < 0.0 ? 0./0. : result.g);\n result.b = isNaN.b ? x.b : (x.b < 0.0 ? 0./0. : result.b);\n result.a = isNaN.a ? x.a : (x.a < 0.0 ? 0./0. : result.a);\n return result;\n",cpuKernelImpl:pn}),ai={kernelName:a.tG8,backendName:"webgl",kernelFunc:ri},oi=wr({opSnippet:vr+"\n return log(1.0 + x);\n"}),si={kernelName:a.Cg$,backendName:"webgl",kernelFunc:oi},ii=Tr({opSnippet:"return float(a >= 1.0 && b >= 1.0);",packedOpSnippet:"\n return vec4(\n vec4(greaterThanEqual(a, vec4(1.0))) *\n vec4(greaterThanEqual(b, vec4(1.0))));\n",dtype:"bool"}),ui={kernelName:a.RUm,backendName:"webgl",kernelFunc:ii},ci=wr({opSnippet:"return float(!(x >= 1.0));"}),li={kernelName:a.nZd,backendName:"webgl",kernelFunc:ci},pi=Tr({opSnippet:"return float(a >= 1.0 || b >= 1.0);",packedOpSnippet:"\n return min(\n vec4(greaterThanEqual(a, vec4(1.0))) +\n vec4(greaterThanEqual(b, vec4(1.0))),\n vec4(1.0));\n",dtype:"bool"}),hi={kernelName:a.LXA,backendName:"webgl",kernelFunc:pi};class di{constructor(e,t,n,r,a){this.variableNames=["x"],this.outputShape=[];const o=t,s=e[3]-1;let i;this.outputShape=e;const u=`float(${n}) + float(${r}) * sum`;i=.5===a?`inversesqrt(${u})`:1===a?`1.0/(${u})`:`exp(log(${u}) * float(-${a}));`,this.userCode=`\n void main() {\n ivec4 coords = getOutputCoords();\n int b = coords[0];\n int r = coords[1];\n int c = coords[2];\n int d = coords[3];\n float x = getX(b, r, c, d);\n float sum = 0.0;\n for (int j = -${o}; j <= ${o}; j++) {\n int idx = d + j;\n if (idx >= 0 && idx <= ${s}) {\n float z = getX(b, r, c, idx);\n sum += z * z;\n }\n }\n float val = x * ${i};\n setOutput(val);\n }\n `}}class fi{constructor(e,t,n,r,a){this.variableNames=["x"],this.outputShape=[],this.packedInputs=!0,this.packedOutput=!0;const o=t,s=e[3]-1;let i;this.outputShape=e;const u=`float(${n}) + float(${r}) * sum`;i=.5===a?`inversesqrt(${u})`:1===a?`1.0/(${u})`:`exp(log(${u}) * float(-${a}));`,this.userCode=`\n void main() {\n ivec4 coords = getOutputCoords();\n int b = coords.x;\n int r = coords.y;\n int c = coords.z;\n int d = coords.w;\n\n bool hasNextCol = d < ${this.outputShape[3]};\n bool hasNextRow = c < ${this.outputShape[2]};\n\n vec4 sum = vec4(0.);\n vec4 xFragAtOutputCoords = getX(b, r, c, d);\n\n vec4 xAtOutputCoords = vec4(\n getChannel(xFragAtOutputCoords, vec2(c, d)),\n hasNextCol ?\n getChannel(xFragAtOutputCoords, vec2(c, d + 1)) : 0.0,\n hasNextRow ?\n getChannel(xFragAtOutputCoords , vec2(c + 1, d)) : 0.0,\n (hasNextRow && hasNextCol) ?\n getChannel(xFragAtOutputCoords, vec2(c + 1, d + 1)) : 0.0\n );\n\n int firstChannel = d - ${o};\n vec2 cache = vec2(0.);\n if(firstChannel >= 0){\n vec4 firstChannelFrag = getX(b, r, c, firstChannel);\n cache.x = getChannel(firstChannelFrag, vec2(c, firstChannel));\n if(hasNextRow){\n cache.y = getChannel(firstChannelFrag, vec2(c + 1, firstChannel));\n }\n }
2\n\n ivec2 depth = ivec2(d, d + 1);\n for (int j = - ${o}; j <= ${o}; j++) {\n ivec2 idx = depth + j;\n bvec2 aboveLowerBound = greaterThanEqual(idx, ivec2(0));\n bvec2 belowUpperBound = lessThanEqual(idx, ivec2(${s}));\n\n bool depthInRange = aboveLowerBound.x && belowUpperBound.x;\n bool depthPlusOneInRange = aboveLowerBound.y && belowUpperBound.y;\n\n if(depthInRange || depthPlusOneInRange){\n vec4 z = vec4(0.);\n vec4 xFragAtCurrentDepth;\n z.xz = cache.xy;\n if(depthPlusOneInRange && hasNextCol){\n xFragAtCurrentDepth = idx.y != d ?\n getX(b, r, c, idx.y) : xFragAtOutputCoords;\n z.y = getChannel(xFragAtCurrentDepth, vec2(c, idx.y));\n if(hasNextRow){\n z.w = getChannel(xFragAtCurrentDepth, vec2(c + 1, idx.y));\n }\n }\n cache.xy = z.yw;\n sum += z * z;\n }\n }\n vec4 result = xAtOutputCoords * ${i};\n setOutput(result);\n }\n `}}const mi={kernelName:a.jM4,backendName:"webgl",kernelFunc:e=>{const{inputs:t,backend:n,attrs:r}=e,{x:o}=t,{depthRadius:s,bias:i,alpha:u,beta:c}=r,l=(0,a._K2)().getBool("WEBGL_PACK_NORMALIZATION")?new fi(o.shape,s,i,u,c):new di(o.shape,s,i,u,c);return n.runWebGLProgram(l,[o],o.dtype)}};class gi{constructor(e,t,n,r,a){this.variableNames=["inputImage","outputImage","dy"],this.outputShape=[],this.outputShape=e,this.depth=e[3],this.depthRadius=t,this.bias=n,this.alpha=r,this.beta=a,this.userCode=`\n void main() {\n ivec4 coords = getOutputCoords();\n int b = coords[0];\n int r = coords[1];\n int c = coords[2];\n\n float result = 0.0;\n for (int d = 0; d < ${this.depth}; ++d) {\n int depthBegin = int(max(0.0, float(d - ${t})));\n int depthEnd = int(min(float(${this.depth}),\n float(d + ${t} + 1)));\n\n const int MIN_DEPTH_BEGIN = 0;\n const int MAX_DEPTH_END = ${this.depth};\n\n float norm = 0.0;\n for (int k = MIN_DEPTH_BEGIN; k < MAX_DEPTH_END; ++k) {\n if (k < depthBegin){\n continue;\n }\n else if (k >= depthBegin && k < depthEnd) {\n norm += getInputImage(b, r, c, k) * getInputImage(b, r, c, k);\n }\n else {\n break;\n }\n }\n\n norm = float(${r}) * norm + float(${n});\n\n for(int k = MIN_DEPTH_BEGIN; k < MAX_DEPTH_END; ++k){\n if (k < depthBegin){\n continue;\n }\n else if (k >= depthBegin && k < depthEnd){\n float dyi = -2.0 * float(${r})\n * float(${a})\n * getInputImage(b ,r ,c, k) * getOutputImage(b, r, c, d)\n / norm;\n if (k == d) {\n dyi += pow(norm, -1.0 * ${a});\n }\n if (k == coords[3]) {\n dyi *= getDy(b, r, c, d);\n result += dyi;\n }\n }\n else {\n break;\n }\n }\n }\n setOutput(result);\n }\n `}}const yi={kernelName:a.ToN,backendName:"webgl",kernelFunc:e=>{const{inputs:t,backend:n,attrs:r}=e,{x:a,y:o,dy:s}=t,{depthRadius:i,bias:u,alpha:c,beta:l}=r,p=new gi(a.shape,i,u,c,l);return n.runWebGLProgram(p,[a,o,s],a.dtype)}};function xi(e){const{inputs:t,backend:n,attrs:r}=e,{x:o}=t,{reductionIndices:s,keepDims:i}=r,u=o.shape.length,c=a.ZSL.parseAxisParam(s,o.shape);let l=c;const p=a.C0T.getAxesPermutation(l,u),h=null!=p,d=n.shouldExecuteOnCPU([o]);let f=o;if(h){if(d){const e=n.texData.get(f.dataId).values,t=new Array(u);for(let e=0;e<t.length;e++)t[e]=o.shape[p[e]];const r=Pn(e,o.shape,o.dtype,p,t);f=n.makeTensorInfo(t,o.dtype);n.texData.get(f.dataId).values=r}else f=Pr(o,p,n);l=a.C0T.getInnerMostAxes(l.length,u)}a.C0T.assertAxesAreInnerMostDims("max",l,u);const[m,g]=a.C0T.computeOutAndReduceShapes(f.shape,l);let y,x=m;if(i&&(x=a.C0T.expandShapeToKeepDim(m,c)),d){const e=n.texData.get(f.dataId).values,t=hn(e,a.ZSL.sizeFromShape(g),x,o.dtype);y=n.makeTensorInfo(x,o.dtype);n.texData.get(y.dataId).values=t}else y=function(e,t,n,r){const o=a.ZSL.sizeFromShape(t),s=Rr({inputs:{x:e},attrs:{shape:[a.ZSL.sizeFromShape(e.shape)/o,o]},backend:r}),i=Dr(s,e.dtype,"max",r),u=Rr({inputs:{x:i},attrs:{shape:n},backend:r});return r.disposeIntermediateTensorInfo(s),r.disposeIntermediateTensorInfo(i),u}(f,g,x,n);return h&&n.disposeIntermediateTensorInfo(f),y}const bi={kernelName:a.VAI,backendName:"webgl",kernelFunc:xi},vi=Tr({opSnippet:sr+"\n return max(a, b);\n",packedOpSnippet:"\n vec4 result = vec4(max(a, b));\n bvec4 isNaNA = isnan(a);\n bvec4 isNaNB = isnan(b);\n bvec4 isNaN = bvec4(isNaNA.x || isNaNB.x, isNaNA.y || isNaNB.y, isNaNA.z || isNaNB.z, isNaNA.w || isNaNB.w);\n "+ur+"\n return result;\n",cpuKernelImpl:dn}),wi={kernelName:a.LDN,backendName:"webgl",kernelFunc:vi};const Ti={kernelName:a.t3d,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:o}=t;B(o,"maxPool");const{filterSize:s,strides:i,pad:u,dimRoundingMode:c}=r;a.ZSL.assert(a.C0T.eitherStridesOrDilationsAreOne(i,1),()=>`Error in maxPool: Either strides or dilations must be 1. Got strides ${i} and dilations '1'`);const l=a.C0T.computePool2DInfo(o.shape,s,i,1,u,c);if(1===l.filterWidth&&1===l.filterHeight&&a.ZSL.arraysEqual(l.inShape,l.outShape))return lr({inputs:{x:o},backend:n});const p=new Ta(l,"max",!1);
vendor: 5,326 bytes, line 2
2return n.runWebGLProgram(p,[o],o.dtype)}};const Si={kernelName:a.ySp,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:o}=t,{filterSize:s,strides:i,pad:u,dataFormat:c,dimRoundingMode:l}=r,p=a.C0T.computePool3DInfo(o.shape,s,i,[1,1,1],u,l,c),h=new Sa(p,"max",!1);return n.runWebGLProgram(h,[o],o.dtype)}};class Ci{constructor(e){this.variableNames=["dy","maxPos"],this.outputShape=e.inShape;const t=e.strideHeight,n=e.strideWidth,r=e.dilationHeight,a=e.effectiveFilterHeight,o=e.effectiveFilterWidth,s=a-1-e.padInfo.top,i=o-1-e.padInfo.left,u=a*o-1;this.userCode=`\n const ivec2 pads = ivec2(${s}, ${i});\n\n void main() {\n ivec4 coords = getOutputCoords();\n int b = coords[0];\n int d = coords[3];\n\n ivec2 dyRCCorner = coords.yz - pads;\n int dyRCorner = dyRCCorner.x;\n int dyCCorner = dyRCCorner.y;\n\n // Convolve dy(?, ?, d) with pos mask(:, :, d) to get dx(xR, xC, d).\n // ? = to be determined. : = across all values in that axis.\n float dotProd = 0.0;\n for (int wR = 0; wR < ${a};\n wR += ${r}) {\n float dyR = float(dyRCorner + wR) / ${t}.0;\n\n if (dyR < 0.0 || dyR >= ${e.outHeight}.0 || fract(dyR) > 0.0) {\n continue;\n }\n int idyR = int(dyR);\n\n for (int wC = 0; wC < ${o}; wC++) {\n float dyC = float(dyCCorner + wC) / ${n}.0;\n\n if (dyC < 0.0 || dyC >= ${e.outWidth}.0 ||\n fract(dyC) > 0.0) {\n continue;\n }\n int idyC = int(dyC);\n\n float dyValue = getDy(b, idyR, idyC, d);\n int maxPosValue = ${u} - int(getMaxPos(b, idyR, idyC, d));\n\n // Get the current value, check it against the value from the\n // position matrix.\n int curPosValue = wR * ${o} + wC;\n float mask = float(maxPosValue == curPosValue ? 1.0 : 0.0);\n\n dotProd += dyValue * mask;\n }\n }\n setOutput(dotProd);\n }\n `}}class ki{constructor(e){this.variableNames=["dy","maxPos"],this.outputShape=e.inShape;const t=e.strideDepth,n=e.strideHeight,r=e.strideWidth,a=e.dilationDepth,o=e.dilationHeight,s=e.dilationWidth,i=e.effectiveFilterDepth,u=e.effectiveFilterHeight,c=e.effectiveFilterWidth,l=i-1-e.padInfo.front,p=u-1-e.padInfo.top,h=c-1-e.padInfo.left,d=i*u*c-1;this.userCode=`\n const ivec3 pads = ivec3(${l}, ${p}, ${h});\n\n void main() {\n ivec5 coords = getOutputCoords();\n int batch = coords.x;\n int ch = coords.u;\n\n ivec3 dyCorner = ivec3(coords.y, coords.z, coords.w) - pads;\n int dyDCorner = dyCorner.x;\n int dyRCorner = dyCorner.y;\n int dyCCorner = dyCorner.z;\n\n // Convolve dy(?, ?, ?, ch) with pos mask(:, :, :, d) to get\n // dx(xD, xR, xC, ch).\n // ? = to be determined. : = across all values in that axis.\n float dotProd = 0.0;\n\n for (int wD = 0; wD < ${i};\n wD += ${a}) {\n float dyD = float(dyDCorner + wD) / ${t}.0;\n\n if (dyD < 0.0 || dyD >= ${e.outDepth}.0 || fract(dyD) > 0.0) {\n continue;\n }\n int idyD = int(dyD);\n\n for (int wR = 0; wR < ${u};\n wR += ${o}) {\n float dyR = float(dyRCorner + wR) / ${n}.0;\n\n if (dyR < 0.0 || dyR >= ${e.outHeight}.0 ||\n fract(dyR) > 0.0) {\n continue;\n }\n int idyR = int(dyR);\n\n for (int wC = 0; wC < ${c};\n wC += ${s}) {\n float dyC = float(dyCCorner + wC) / ${r}.0;\n\n if (dyC < 0.0 || dyC >= ${e.outWidth}.0 ||\n fract(dyC) > 0.0) {\n continue;\n }\n int idyC = int(dyC);\n\n float dyValue = getDy(batch, idyD, idyR, idyC, ch);\n int maxPosValue = ${d} -\n int(getMaxPos(batch, idyD, idyR, idyC, ch));\n\n // Get the current value, check it against the value from the\n // position matrix.\n int curPosValue =\n wD * ${u} * ${c} +\n wR * ${c} + wC;\n float mask = float(maxPosValue == curPosValue ? 1.0 : 0.0);\n\n dotProd += dyValue * mask;\n }\n }\n }\n setOutput(dotProd);\n }\n `}}const Ei={kernelName:a.cHb,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{dy:o,input:s}=t,i=s,{filterSize:u,strides:c,pad:l,dimRoundingMode:p}=r,h=a.C0T.computePool3DInfo(i.shape,u,c,[1,1,1],l,p),d=new Sa(h,"max",!0),f=n.runWebGLProgram(d,[i],i.dtype),m=new ki(h),g=n.runWebGLProgram(m,[o,f],i.dtype);return n.disposeIntermediateTensorInfo(f),g}};const $i={kernelName:a.RXX,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{dy:o,input:s,output:i}=t,u=s;B([s,i],"maxPoolGrad");const{filterSize:c,strides:l,pad:p,dimRoundingMode:h}=r,d=a.C0T.computePool2DInfo(u.shape,c,l,1,p,h),f=new Ta(d,"max",!0),m=n.runWebGLProgram(f,[u],u.dtype),g=new Ci(d),y=n.runWebGLProgram(g,[o,m],u.dtype);return n.disposeIntermediateTensorInfo(m),y}};const Ni={kernelName:a.TL8,backendName:"webgl",kernelFunc:({input
2s:e,attrs:t,backend:n})=>{const{x:r}=e,{filterSize:o,strides:s,pad:i,includeBatchInIndex:u}=t,c=n;a.ZSL.assert(4===r.shape.length,()=>`Error in maxPool: input must be rank 4 but got rank ${r.shape.length}.`);const l=[1,1];a.ZSL.assert(a.C0T.eitherStridesOrDilationsAreOne(s,l),()=>`Error in maxPool: Either strides or dilations must be 1. Got strides ${s} and dilations '${l}'`);const p=a.C0T.computePool2DInfo(r.shape,o,s,l,i),[h,d]=function(e,t,n,r){let a=new Ta(n,"max",!1);const o=r.runWebGLProgram(a,[e],"float32");return a=new Ta(n,"max",!0,!0,t),[o,r.runWebGLProgram(a,[e],"float32")]}(r,u,p,c);return[h,d]}};const Ii={kernelName:a.g5A,backendName:"webgl",kernelFunc:({inputs:e,attrs:t,backend:n})=>{const{x:r}=e,{keepDims:o,axis:s}=t,i=n,u=r.shape.length,c=a.ZSL.parseAxisParam(s,r.shape);let l=c;const p=a.C0T.getAxesPermutation(l,u),h=null!=p,d=i.shouldExecuteOnCPU([r]),f=[];let m=r;if(h){if(d){const e=i.texData.get(m.dataId).values,t=new Array(u);for(let e=0;e<t.length;e++)t[e]=r.shape[p[e]];const n=Pn(e,r.shape,r.dtype,p,t);m=i.makeTensorInfo(t,r.dtype);i.texData.get(m.dataId).values=n}else m=Pr(r,p,i);f.push(m),l=a.C0T.getInnerMostAxes(l.length,u)}a.C0T.assertAxesAreInnerMostDims("sum",l,u);const[g,y]=a.C0T.computeOutAndReduceShapes(m.shape,l);let x=g;o&&(x=a.C0T.expandShapeToKeepDim(g,c));const b=function(e,t,n,r){const o=a.ZSL.sizeFromShape(t),s=Rr({inputs:{x:e},attrs:{shape:[a.ZSL.sizeFromShape(e.shape)/o,o]},backend:r}),i=Dr(s,"float32","mean",r),u=Rr({inputs:{x:i},attrs:{shape:n},backend:r});return r.disposeIntermediateTensorInfo(s),r.disposeIntermediateTensorInfo(i),u}(m,y,x,i);for(const e of f)i.disposeIntermediateTensorInfo(e);return b}};const Ai={kernelName:a.lNG,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:o}=t,{axis:s,keepDims:i}=r,u=o.shape.length,c=a.ZSL.parseAxisParam(s,o.shape);let l=c;const p=a.C0T.getAxesPermutation(l,u);let h=o;null!=p&&(h=zr({inputs:{x:o},backend:n,attrs:{perm:p}}),l=a.C0T.getInnerMostAxes(l.length,o.shape.length)),a.C0T.assertAxesAreInnerMostDims("min",l,u);const[d,f]=a.C0T.computeOutAndReduceShapes(h.shape,l),m=Rr({inputs:{x:h},backend:n,attrs:{shape:[-1,a.ZSL.sizeFromShape(f)]}}),g=Dr(m,m.dtype,"min",n);let y;if(i){y=Rr({inputs:{x:g},backend:n,attrs:{shape:a.C0T.expandShapeToKeepDim(d,c)}})}else y=Rr({inputs:{x:g},backend:n,attrs:{shape:d}});return n.disposeIntermediateTensorInfo(m),n.disposeIntermediateTensorInfo(g),null!=p&&n.disposeIntermediateTensorInfo(h),y}},Ri=Tr({opSnippet:sr+"\n return min(a, b);\n",packedOpSnippet:"\n vec4 result = vec4(min(a, b));\n bvec4 isNaNA = isnan(a);\n bvec4 isNaNB = isnan(b);\n bvec4 isNaN = bvec4(isNaNA.x || isNaNB.x, isNaNA.y || isNaNB.y, isNaNA.z || isNaNB.z, isNaNA.w || isNaNB.w);\n "+ur+"\n return result;\n",cpuKernelImpl:fn}),_i={kernelName:a.LG0,backendName:"webgl",kernelFunc:Ri};class Oi{constructor(e,t,n){this.variableNames=["x"],this.outputShape=t.map((t,n)=>t[0]+e[n]+t[1]);const r=e.length,a=ae(r),o=t.map(e=>e[0]).join(","),s=t.map((t,n)=>t[0]+e[n]).join(","),i=["coords[0]","coords[1]","coords[2]","coords[3]"].slice(0,r),u="reflect"===n?0:1;this.userCode=1!==r?`\n ${a} start = ${a}(${o});\n ${a} end = ${a}(${s});\n\n void main() {\n ${a} outC = getOutputCoords();\n for (int i = 0; i < ${r}; i++) {\n if (outC[i] < start[i]) {\n outC[i] = start[i] * 2 - outC[i] - ${u};\n } else if(outC[i] >= end[i]) {\n outC[i] = (end[i] - 1) * 2 - outC[i] + ${u};\n }\n }\n ${a} coords = outC - start;\n setOutput(getX(${i}));\n }\n `:`\n int start = ${o};\n int end = ${s};\n\n void main() {\n int outC = getOutputCoords();\n if (outC < start) {\n outC = start * 2 - outC - ${u};\n } else if(outC >= end) {\n outC = (end - 1) * 2 - outC + ${u};\n }\n setOutput(getX(outC - start));\n }\n `}}class Fi{constructor(e,t,n){this.variableNames=["x"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=t.map((t,n)=>t[0]+e[n]+t[1]);const r=e.length,a=ae(r),o=t.map(e=>e[0]).join(","),s=t.map((t,n)=>t[0]+e[n]).join(","),i=zn("rc",r),u=zn("source",r),c=`${i[r-1]} < ${this.outputShape[r-1]}`,l=1===r?"source":`vec2(${u.slice(-2).join()})`,p="reflect"===n?0:1;let h="";if(1===r){const e=`\n ${a} source = rc;\n if (source < start) {\n source = start * 2 - source - ${p};\n } else if (source >
2= end) {\n source = (end - 1) * 2 - source + ${p};\n }\n source -= start;\n `;h=`\n ${a} rc = outputLoc;\n ${e}\n result[0] = getChannel(getX(${u.join()}), ${l});\n ${i[r-1]} += 1;\n if(${c}) {\n ${e}\n result[1] = getChannel(getX(${u.join()}), ${l});\n }\n `}else{const e=`\n ${a} source = rc;\n ${a} lt = ${a}(lessThan(source, start));\n ${a} gte = ${a}(greaterThanEqual(source, end));\n ${a} orig = 1 - (lt + gte);\n source = orig * source +\n lt * (start * 2 - source - ${p}) +\n gte * ((end - 1) * 2 - source + ${p});\n source -= start;\n `;h=`\n ${a} rc = outputLoc;\n ${e}\n result[0] = getChannel(getX(${u.join()}), ${l});\n ${i[r-1]} += 1;\n if(${c}) {\n ${e}\n result[1] = getChannel(getX(${u.join()}), ${l});\n }\n rc = outputLoc;\n ${i[r-2]} += 1;\n if(${i[r-2]} < ${this.outputShape[r-2]}) {\n ${e}\n result[2] = getChannel(getX(${u.join()}), ${l});\n ${i[r-1]} += 1;\n if(${c}) {\n ${e}\n result[3] = getChannel(getX(${u.join()}), ${l});\n }\n }\n `}this.userCode=`\n const ${a} start = ${a}(${o});\n const ${a} end = ${a}(${s});\n\n void main() {\n ${a} outputLoc = getOutputCoords();\n vec4 result = vec4(0.);\n ${h}\n setOutput(result);\n }\n `}}const Di={kernelName:a.x7F,backendName:"webgl",kernelFunc:({inputs:e,backend:t,attrs:n})=>{const{x:r}=e,{paddings:o,mode:s}=n,i=(0,a._K2)().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new Fi(r.shape,o,s):new Oi(r.shape,o,s);return t.runWebGLProgram(i,[r],r.dtype)}},Li=Tr({opSnippet:"if (b == 0.0) return NAN;\n return mod(a, b);",packedOpSnippet:"\n vec4 result = mod(a, b);\n bvec4 isNaN = equal(b, vec4(0.0));\n "+ur+"\n return result;\n"}),Mi={kernelName:a.BLA,backendName:"webgl",kernelFunc:Li};class Pi{constructor(e,t,n){this.variableNames=["probs"],this.customUniforms=[{name:"seed",type:"float"}],this.outputShape=[e,n],this.userCode=`\n void main() {\n ivec2 coords = getOutputCoords();\n int batch = coords[0];\n\n float r = random(seed);\n float cdf = 0.0;\n\n for (int i = 0; i < ${t-1}; i++) {\n cdf += getProbs(batch, i);\n\n if (r < cdf) {\n setOutput(float(i));\n return;\n }\n }\n\n // If no other event happened, last event happened.\n setOutput(float(${t-1}));\n }\n `}}const Bi=Tr({opSnippet:"\nif (a == b) {\n return 1.0;\n};\nreturn a / b;",packedOpSnippet:"\n // vec4 one = vec4(equal(a, b));\n // return one + (vec4(1.0) - one) * a / b;\n vec4 result = a / b;\n if(a.x == b.x) {\n result.x = 1.;\n }\n if(a.y == b.y) {\n result.y = 1.;\n }\n if(a.z == b.z) {\n result.z = 1.;\n }\n if(a.w == b.w) {\n result.w = 1.;\n }\n\n return result;\n",checkOutOfBounds:!0}),Vi={kernelName:a.sDr,backendName:"webgl",kernelFunc:Bi},zi="return a - b;",Ui=Tr({opSnippet:zi,packedOpSnippet:zi,supportsComplex:!0,cpuKernelImpl:Dn}),Wi={kernelName:a.PbM,backendName:"webgl",kernelFunc:Ui};function Gi(e){const{inputs:t,backend:n,attrs:r}=e,{logits:o}=t,{dim:s}=r,i=a.ZSL.parseAxisParam([s],o.shape),u=xi({inputs:{x:o},backend:n,attrs:{reductionIndices:i,keepDims:!1}}),c=a.C0T.expandShapeToKeepDim(u.shape,i),l=Rr({inputs:{x:u},backend:n,attrs:{shape:c}}
vendor: 4,521 bytes, line 2
2),p=Ui({inputs:{a:o,b:l},backend:n}),h=cs({inputs:{x:p},backend:n}),d=Br({inputs:{x:h},backend:n,attrs:{axis:i,keepDims:!1}}),f=Rr({inputs:{x:d},backend:n,attrs:{shape:c}}),m=Bi({inputs:{a:h,b:f},backend:n});return n.disposeIntermediateTensorInfo(u),n.disposeIntermediateTensorInfo(l),n.disposeIntermediateTensorInfo(p),n.disposeIntermediateTensorInfo(h),n.disposeIntermediateTensorInfo(d),n.disposeIntermediateTensorInfo(f),m}const ji={kernelName:a.rFG,backendName:"webgl",kernelFunc:Gi};const Ki={kernelName:a.WT3,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{logits:a}=t,{numSamples:o,seed:s,normalized:i}=r,u=i?a:Gi({inputs:{logits:a},backend:n,attrs:{dim:a.shape.length-1}}),c=u.shape[0],l=u.shape[1],p=new Pi(c,l,o),h=[[s]],d=n.runWebGLProgram(p,[u],"int32",h);return i||n.disposeIntermediateTensorInfo(u),d}},Hi=Zn+"\n return -x;\n";const Yi={kernelName:a.l0G,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n}=e,{x:r}=t;if(n.shouldExecuteOnCPU([r])){const e=n.texData.get(r.dataId),[t,a]=gn(e.values,r.shape,r.dtype);return n.makeTensorInfo(a,r.dtype,t)}let o;return o=(0,a._K2)().getBool("WEBGL_PACK_UNARY_OPERATIONS")?new er(r.shape,"\n vec4 result = -x;\n bvec4 isNaN = isnan(x);\n\n result.r = isNaN.r ? x.r : result.r;\n result.g = isNaN.g ? x.g : result.g;\n result.b = isNaN.b ? x.b : result.b;\n result.a = isNaN.a ? x.a : result.a;\n\n return result;\n"):new Yn(r.shape,Hi),n.runWebGLProgram(o,[r],r.dtype)}},Zi=a.kpo.c7;const Xi={kernelName:a.SDM,backendName:"webgl",kernelFunc:function(e){a.C0T.warn("tf.nonMaxSuppression() in webgl locks the UI thread. Call tf.nonMaxSuppressionAsync() instead");const{inputs:t,backend:n,attrs:r}=e,{boxes:o,scores:s}=t,{maxOutputSize:i,iouThreshold:u,scoreThreshold:c}=r,l=n.readSync(o.dataId),p=n.readSync(s.dataId),{selectedIndices:h}=Zi(l,p,i,u,c);return n.makeTensorInfo([h.length],"int32",new Int32Array(h))}},qi=a.kpo.ZS;const Qi={kernelName:a.Zl4,backendName:"webgl",kernelFunc:function(e){a.C0T.warn("tf.nonMaxSuppression() in webgl locks the UI thread. Call tf.nonMaxSuppressionAsync() instead");const{inputs:t,backend:n,attrs:r}=e,{boxes:o,scores:s}=t,{maxOutputSize:i,iouThreshold:u,scoreThreshold:c,padToMaxOutputSize:l}=r,p=n.readSync(o.dataId),h=n.readSync(s.dataId),{selectedIndices:d,validOutputs:f}=qi(p,h,i,u,c,l);return[n.makeTensorInfo([d.length],"int32",new Int32Array(d)),n.makeTensorInfo([],"int32",new Int32Array([f]))]}},Ji=a.kpo.ut;const eu={kernelName:a.e0f,backendName:"webgl",kernelFunc:function(e){a.C0T.warn("tf.nonMaxSuppression() in webgl locks the UI thread. Call tf.nonMaxSuppressionAsync() instead");const{inputs:t,backend:n,attrs:r}=e,{boxes:o,scores:s}=t,{maxOutputSize:i,iouThreshold:u,scoreThreshold:c,softNmsSigma:l}=r,p=n.readSync(o.dataId),h=n.readSync(s.dataId),d=i,f=u,m=c,g=l,{selectedIndices:y,selectedScores:x}=Ji(p,h,d,f,m,g);return[n.makeTensorInfo([y.length],"int32",new Int32Array(y)),n.makeTensorInfo([x.length],"float32",new Float32Array(x))]}};class tu{constructor(e,t,n,r){this.variableNames=["indices"],this.outputShape=[e,t],this.userCode=`\n void main() {\n ivec2 coords = getOutputCoords();\n int index = round(getIndices(coords.x));\n setOutput(mix(float(${r}), float(${n}),\n float(index == coords.y)));\n }\n `}}const nu={kernelName:a.urI,backendName:"webgl",kernelFunc:e=>{const{inputs:t,backend:n,attrs:r}=e,{indices:o}=t,{dtype:s,depth:i,onValue:u,offValue:c}=r,l=a.ZSL.sizeFromShape(o.shape),p=new tu(l,i,u,c),h=Rr({inputs:{x:o},backend:n,attrs:{shape:[l]}}),d=n.runWebGLProgram(p,[h],s);n.disposeIntermediateTensorInfo(h);const f=Rr({inputs:{x:d},backend:n,attrs:{shape:[...o.shape,i]}});return n.disposeIntermediateTensorInfo(d),f}};function ru(e){const{inputs:t,backend:n}=e,{x:r}=t;if("complex64"===r.dtype){const e=Ga({inputs:{input:r},backend:n}),t=ru({inputs:{x:e},backend:n}),a=oo({inputs:{input:r},backend:n}),o=ru({inputs:{x:a},backend:n}),s=hr({inputs:{real:t,imag:o},backend:n});return n.disposeIntermediateTensorInfo(e),n.disposeIntermediateTensorInfo(t),n.disposeIntermediateTensorInfo(a),n.disposeIntermediateTensorInfo(o),s}return vs({attrs:{shape:r.shape,dtype:r.dtype,value:"string"===r.dtype?"":0},backend:n})}const au={kernelName:a.xJ3,backendName:"webgl",kernelFunc:ru};const ou={kernelName:a.LWX,backendName:"webgl",kernelFunc:function e(t){const{inputs:n,backend:r}=t,{x:a}=n;if("string"===a.dtype)throw new Error("onesLike is not supported under string dtype");
2if("complex64"===a.dtype){const t=Ga({inputs:{input:a},backend:r}),n=e({inputs:{x:t},backend:r}),o=oo({inputs:{input:a},backend:r}),s=ru({inputs:{x:o},backend:r}),i=hr({inputs:{real:n,imag:s},backend:r});return r.disposeIntermediateTensorInfo(t),r.disposeIntermediateTensorInfo(n),r.disposeIntermediateTensorInfo(o),r.disposeIntermediateTensorInfo(s),i}return vs({attrs:{shape:a.shape,dtype:a.dtype,value:1},backend:r})}};const su={kernelName:a.mM$,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{axis:o}=r;if(1===t.length)return ps({inputs:{input:t[0]},backend:n,attrs:{dim:o}});const s=t[0].shape,i=t[0].dtype;t.forEach(e=>{a.ZSL.assertShapesMatch(s,e.shape,"All tensors passed to stack must have matching shapes"),a.ZSL.assert(i===e.dtype,()=>"All tensors passed to stack must have matching dtypes")});const u=[],c=uo({inputs:t.map(e=>{const t=ps({inputs:{input:e},backend:n,attrs:{dim:o}});return u.push(t),t}),backend:n,attrs:{axis:o}});return u.forEach(e=>n.disposeIntermediateTensorInfo(e)),c}};class iu{constructor(e,t,n){this.variableNames=["x"],this.customUniforms=[{name:"value",type:"float"}],this.outputShape=t.map((t,n)=>t[0]+e[n]+t[1]);const r=e.length,a=ae(r),o=t.map(e=>e[0]).join(","),s=t.map((t,n)=>t[0]+e[n]).join(","),i=["coords[0]","coords[1]","coords[2]","coords[3]"].slice(0,r);this.userCode=1!==r?`\n ${a} start = ${a}(${o});\n ${a} end = ${a}(${s});\n\n void main() {\n ${a} outC = getOutputCoords();\n if (any(lessThan(outC, start)) || any(greaterThanEqual(outC, end))) {\n setOutput(value);\n } else {\n ${a} coords = outC - start;\n setOutput(getX(${i}));\n }\n }\n `:`\n int start = ${o};\n int end = ${s};\n\n void main() {\n int outC = getOutputCoords();\n if (outC < start || outC >= end) {\n setOutput(value);\n } else {\n setOutput(getX(outC - start));\n }\n }\n `}}class uu{constructor(e,t,n){this.variableNames=["x"],this.packedInputs=!0,this.packedOutput=!0,this.customUniforms=[{name:"value",type:"float"}],this.outputShape=t.map((t,n)=>t[0]+e[n]+t[1]);const r=e.length,a=ae(r),o=t.map(e=>e[0]).join(","),s=t.map((t,n)=>t[0]+e[n]).join(","),i=zn("rc",r),u=zn("source",r),c=`${i[r-1]} < ${this.outputShape[r-1]}`,l=1===r?"source":`vec2(${u.slice(-2).join()})`,p=[`${a} rc = outputLoc;`,`${i[r-1]} += 1;\n if(${c}) {\n `,1===r?"":`}\n rc = outputLoc;\n ${i[r-2]} += 1;\n if(${i[r-2]} < ${this.outputShape[r-2]}) {`,1===r?"":` ${i[r-1]} += 1;\n if(${c}) {`],h=1===r?"rc < start || rc >= end":"any(lessThan(rc, start)) || any(greaterThanEqual(rc, end))";let d="";for(let e=0,t=1===r?2:4;e<t;e++)d+=`\n ${p[e]}\n if (${h}) {\n result[${e}] = float(value);\n } else {\n ${a} source = rc - start;\n result[${e}] = getChannel(getX(${u.join()}), ${l});\n }\n `;d+=1===r?"} ":"}}",this.userCode=`\n const ${a} start = ${a}(${o});\n const ${a} end = ${a}(${s});\n\n void main() {\n ${a} outputLoc = getOutputCoords();\n vec4 result = vec4(0.);\n ${d}\n setOutput(result);\n }\n `}}const cu=e=>{const{inputs:t,backend:n,attrs:r}=e,{x:o}=t,{paddings:s,constantValue:i}=r;if(0===a.ZSL.sizeFromShape(o.shape)){return vs({backend:n,attrs:{shape:s.map((e,t)=>e[0]+o.shape[t]+e[1]),value:i,dtype:o.dtype}})}const u=(0,a._K2)().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new uu(o.shape,s,i):new iu(o.shape,s,i),c=[[i]];return n.runWebGLProgram(u,[o],o.dtype,c)},lu={kernelName:a.ODT,backendName:"webgl",kernelFunc:cu},pu=Tr({opSnippet:"\n if(a < 0.0 && floor(b) < b){\n return NAN;\n }\n if (b == 0.0) {\n return 1.0;\n }\n return (round(mod(b, 2.0)) != 1) ?\n pow(abs(a), b) : sign(a) * pow(abs(a), b);\n",packedOpSnippet:"\n // isModRound1 has 1 for components with round(mod(b, 2.0)) == 1, 0 otherwise.\n vec4 isModRound1 = vec4(equal(round(mod(b, 2.0)), ivec4(1)));\n vec4 multiplier = sign(a) * isModRound1 + (vec4(1.0) - isModRound1);\n vec4 result = multiplier * pow(abs(a), b);\n\n // Ensure that a^0 = 1, including 0^0 = 1 as this correspond to TF and JS\n bvec4 isExpZero = equal(b, vec4(0.0));\n result.r = isExpZero.r ? 1.0 : result.r;\n result.g = isExpZero.g ? 1.0 : result.g;\n result.b = isExpZero.b ? 1.0 : result.b;\n result.a = isExpZero.a ? 1.0 : result.a;\n\n bvec4 isNaN1 = lessThan(a, vec4(0.0));\n bvec4 isNaN2 = lessThan(floor(b), b);\n bvec4 isNaN = bvec4(isNaN1.x && isNaN2.x, isNaN1.y && isNaN2.y, isNaN1.z && isNaN2.z, isNaN1.w && isNaN2.
2w);\n "+ur+"\n return result;\n"}),hu={kernelName:a.pyJ,backendName:"webgl",kernelFunc:pu};const du={kernelName:a.kdj,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:o}=t,{axis:s,keepDims:i}=r,u=o.shape.length,c=[],l=a.ZSL.parseAxisParam(s,o.shape);let p=l;const h=a.C0T.getAxesPermutation(p,u);let d,f=o;if(null!=h&&(f=zr({inputs:{x:o},backend:n,attrs:{perm:h}}),p=a.C0T.getInnerMostAxes(p.length,u),c.push(f)),a.C0T.assertAxesAreInnerMostDims("prod",p,u),n.shouldExecuteOnCPU([f])){const e=n.texData.get(f.dataId).values,{outVals:t,outShape:r,outDtype:a}=xn(f.shape,f.dtype,e,p);d=n.makeTensorInfo(r,a,t)}else{const[e,t]=a.C0T.computeOutAndReduceShapes(f.shape,p),r=a.ZSL.sizeFromShape(t),s=Rr({inputs:{x:f},backend:n,attrs:{shape:[-1,r]}}),i=Dr(s,(0,a.chL)(o.dtype),"prod",n);d=Rr({inputs:{x:i},backend:n,attrs:{shape:e}}),c.push(s),c.push(i)}if(i){c.push(d);const e=a.C0T.expandShapeToKeepDim(d.shape,l);d=Rr({inputs:{x:d},backend:n,attrs:{shape:e}})}return c.forEach(e=>n.disposeIntermediateTensorInfo(e)),d}};const fu={kernelName:a.oJ2,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{paramsNestedSplits:a,paramsDenseValues:o,indices:s}=t,{outputRaggedRank:i}=r,u=a.map(e=>n.readSync(e.dataId)),c=a.map(e=>e.shape),l=n.readSync(o.dataId),p=n.readSync(s.dataId),[h,d,f]=bn(u,c,l,o.shape,o.dtype,p,s.shape,i),m=h.map(e=>n.makeTensorInfo([e.length],"int32",e)),g=n.makeTensorInfo(f,o.dtype,d);return m.concat([g])}};const mu={kernelName:a.mH5,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{shape:a,values:o,defaultValue:s,rowPartitionTensors:i}=t,{rowPartitionTypes:u}=r,c=n.readSync(a.dataId),l=n.readSync(o.dataId),p=n.readSync(s.dataId),h=i.map(e=>n.readSync(e.dataId)),d=i.map(e=>e.shape),[f,m]=vn(c,a.shape,l,o.shape,o.dtype,p,s.shape,h,d,u);return n.makeTensorInfo(f,o.dtype,m)}},gu=e=>{const{backend:t,attrs:n}=e,{start:r,stop:a,step:o,dtype:s}=n,i=wn(r,a,o,s);return t.makeTensorInfo([i.length],s,i)},yu={kernelName:a.Q6t,backendName:"webgl",kernelFunc:gu},xu=wr({opSnippet:"return 1.0 / x;"}),bu={kernelName:a.huO,backendName:"webgl",kernelFunc:xu},vu=wr({opSnippet:Zn+"\n return (x < 0.0) ? 0.0 : x;\n",packedOpSnippet:"\n vec4 result = x * vec4(greaterThanEqual(x, vec4(0.0)));\n bvec4 isNaN = isnan(x);\n\n result.r = isNaN.r ? x.r : result.r;\n result.g = isNaN.g ? x.g : result.g;\n result.b = isNaN.b ? x.b : result.b;\n result.a = isNaN.a ? x.a : result.a;\n\n return result;\n"}),wu={kernelName:a.fUj,backendName:"webgl",kernelFunc:vu},Tu=wr({opSnippet:Zn+"\n return (x < 0.0) ? 0.0 : min(6.0, x);\n",packedOpSnippet:"\n vec4 result = min(x, vec4(6.)) * vec4(greaterThanEqual(x, vec4(0.0)));\n bvec4 isNaN = isnan(x);\n\n result.r = isNaN.r ? x.r : result.r;\n result.g = isNaN.g ? x.g : result.g;\n result.b = isNaN.b ? x.b : result.b;\n result.a = isNaN.a ? x.a : result.a;\n\n return result;\n"}),Su={kernelName:a.P_L,backendName:"webgl",kernelFunc:Tu};class Cu{constructor(e,t,n,r,a){this.variableNames=["A"],this.outputShape=[];const[o,s,i,u]=e;this.outputShape=[o,t,n,u];const c=[r&&t>1?s-1:s,r&&n>1?i-1:i],l=[r&&t>1?t-1:t,r&&n>1?n-1:n];let p;p=a?"(vec2(yRC) + vec2(0.5)) * effectiveInputOverOutputRatioRC - vec2(0.5)":"vec2(yRC) * effectiveInputOverOutputRatioRC",this.userCode=`\n const vec2 effectiveInputOverOutputRatioRC = vec2(\n ${c[0]/l[0]},\n ${c[1]/l[1]});\n const vec2 inputShapeRC = vec2(${s}.0, ${i}.0);\n\n void main() {\n ivec4 coords = getOutputCoords();\n int b = coords[0];\n int d = coords[3];\n ivec2 yRC = coords.yz;\n\n // Fractional source index.\n vec2 sourceFracIndexRC = ${p};\n\n // Compute the four integer indices.\n ivec2 sourceFloorRC = ivec2(max(sourceFracIndexRC, vec2(0.0)));\n ivec2 sourceCeilRC = ivec2(\n min(inputShapeRC - 1.0, ceil(sourceFracIndexRC)));\n\n float topLeft = getA(b, sourceFloorRC.x, sourceFloorRC.y, d);\n float bottomLeft = getA(b, sourceCeilRC.x, sourceFloorRC.y, d);\n float topRight = getA(b, sourceFloorRC.x, sourceCeilRC.y, d);\n float bottomRight = getA(b, sourceCeilRC.x, sourceCeilRC.y, d);\n\n vec2 fracRC = sourceFracIndexRC - vec2(sourceFloorRC);\n\n float top = topLeft + (topRight - topLeft) * fracRC.y;\n float bottom = bottomLeft + (bottomRight - bottomLeft) * fracRC.y;\n float newValue = top + (bottom - top) * fracRC.x;\n\n setOutput(newValue);\n }\n `}}
vendor: 3,261 bytes, line 2
2class ku{constructor(e,t,n,r,a){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=[];const[o,s,i,u]=e;this.outputShape=[o,t,n,u];const c=[r&&t>1?s-1:s,r&&n>1?i-1:i],l=[r&&t>1?t-1:t,r&&n>1?n-1:n];let p;p=a?"(vec3(yRC) + vec3(0.5)) * effectiveInputOverOutputRatioRC - vec3(0.5)":"vec3(yRC) * effectiveInputOverOutputRatioRC",this.userCode=`\n const vec3 effectiveInputOverOutputRatioRC = vec3(\n ${c[0]/l[0]},\n ${c[1]/l[1]},\n ${c[1]/l[1]});\n const vec3 inputShapeRC = vec3(${s}.0, ${i}.0,\n ${i}.0);\n\n float getAValue(int b, int r, int c, int d) {\n return getChannel(getA(b, r, c, d), vec2(c, d));\n }\n\n void main() {\n ivec4 coords = getOutputCoords();\n int b = coords[0];\n int d = coords[3];\n // Calculate values for next column in yRC.z.\n ivec3 yRC = coords.yzz + ivec3(0, 0, 1);\n\n // Fractional source index.\n vec3 sourceFracIndexRC = ${p};\n\n // Compute the four integer indices.\n ivec3 sourceFloorRC = ivec3(max(sourceFracIndexRC, vec3(0.0)));\n ivec3 sourceCeilRC = ivec3(\n min(inputShapeRC - 1.0, ceil(sourceFracIndexRC)));\n\n // Should we calculate next column and row elements in 2x2 packed cell.\n bool hasNextCol = d < ${u-1};\n bool hasNextRow = coords.z < ${n-1};\n\n // In parallel, construct four corners for all four components in\n // packed 2x2 cell.\n vec4 topLeft = vec4(\n getAValue(b, sourceFloorRC.x, sourceFloorRC.y, d),\n hasNextCol ? getAValue(b, sourceFloorRC.x, sourceFloorRC.y, d + 1)\n : 0.0,\n hasNextRow ? getAValue(b, sourceFloorRC.x, sourceFloorRC.z, d)\n : 0.0,\n (hasNextRow && hasNextCol) ?\n getAValue(b, sourceFloorRC.x, sourceFloorRC.z, d + 1) : 0.0);\n\n vec4 bottomLeft = vec4(\n getAValue(b, sourceCeilRC.x, sourceFloorRC.y, d),\n hasNextCol ? getAValue(b, sourceCeilRC.x, sourceFloorRC.y, d + 1)\n : 0.0,\n hasNextRow ? getAValue(b, sourceCeilRC.x, sourceFloorRC.z, d)\n : 0.0,\n (hasNextRow && hasNextCol) ?\n getAValue(b, sourceCeilRC.x, sourceFloorRC.z, d + 1) : 0.0);\n\n vec4 topRight = vec4(\n getAValue(b, sourceFloorRC.x, sourceCeilRC.y, d),\n hasNextCol ? getAValue(b, sourceFloorRC.x, sourceCeilRC.y, d + 1)\n : 0.0,\n hasNextRow ? getAValue(b, sourceFloorRC.x, sourceCeilRC.z, d)\n : 0.0,\n (hasNextRow && hasNextCol) ?\n getAValue(b, sourceFloorRC.x, sourceCeilRC.z, d + 1) : 0.0);\n\n vec4 bottomRight = vec4(\n getAValue(b, sourceCeilRC.x, sourceCeilRC.y, d),\n hasNextCol ? getAValue(b, sourceCeilRC.x, sourceCeilRC.y, d + 1)\n : 0.0,\n hasNextRow ? getAValue(b, sourceCeilRC.x, sourceCeilRC.z, d)\n : 0.0,\n (hasNextRow && hasNextCol) ?\n getAValue(b, sourceCeilRC.x, sourceCeilRC.z, d + 1) : 0.0);\n\n vec3 fracRC = sourceFracIndexRC - vec3(sourceFloorRC);
2\n\n vec4 top = mix(topLeft, topRight, fracRC.yyzz);\n vec4 bottom = mix(bottomLeft, bottomRight, fracRC.yyzz);\n vec4 newValue = mix(top, bottom, fracRC.x);\n\n setOutput(newValue);\n }\n `}}const Eu={kernelName:a.hgw,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{images:o}=t,{alignCorners:s,halfPixelCenters:i,size:u}=r,[c,l]=u,p=(0,a._K2)().getBool("WEBGL_PACK_IMAGE_OPERATIONS")?new ku(o.shape,c,l,s,i):new Cu(o.shape,c,l,s,i);return n.runWebGLProgram(p,[o],"float32")}};class $u{constructor(e,t,n){this.variableNames=["dy"],this.outputShape=[],this.outputShape=t;const[,r,a]=t,[,o,s]=e,i=[n&&o>1?r-1:r,n&&s>1?a-1:a],u=[n&&o>1?o-1:o,n&&s>1?s-1:s],c=i[0]/u[0],l=i[1]/u[1],p=1/c,h=1/l,d=2*Math.ceil(p)+2,f=2*Math.ceil(h)+2;this.userCode=`\n void main() {\n ivec4 coords = getOutputCoords();\n int b = coords[0];\n int d = coords[3];\n int r = coords[1];\n int c = coords[2];\n\n float accumulator = 0.0;\n\n const float heightScale = float(${c});\n const float widthScale = float(${l});\n\n const float invHeightScale = float(${p});\n const float invWidthScale = float(${h});\n\n const int winHeight = int(${d});\n const int winWidth = int(${f});\n\n // Compute bounds for where in dy we will look\n float startRLerp = floor(float(r) * invHeightScale);\n int startDyR = int(startRLerp - float(winHeight / 2));\n\n float startCLerp = floor(float(c) * invWidthScale);\n int startDyC = int(startCLerp - float(winWidth / 2));\n\n // Loop over dy\n for (int dyROffset = 0; dyROffset < winHeight; dyROffset++) {\n int dyR = dyROffset + startDyR;\n\n // Guard against the window exceeding the bounds of dy\n if (dyR < 0 || dyR >= ${o}) {\n continue;\n }\n\n for (int dyCOffset = 0; dyCOffset < winWidth; dyCOffset++) {\n int dyC = dyCOffset + startDyC;\n\n // Guard against the window exceeding the bounds of dy\n if (dyC < 0 || dyC >= ${s}) {\n continue;\n }\n\n float dxR = float(dyR) * heightScale;\n int topDxRIndex = int(floor(dxR));\n int bottomDxRIndex = int(min(ceil(dxR), ${r-1}.0));\n float dxRLerp = dxR - float(topDxRIndex);\n float inverseDxRLerp = 1.0 - dxRLerp;\n\n float dxC = float(dyC) * widthScale;\n int leftDxCIndex = int(floor(dxC));\n int rightDxCIndex = int(min(ceil(dxC), ${a-1}.0));\n float dxCLerp = dxC - float(leftDxCIndex);\n float inverseDxCLerp = 1.0 - dxCLerp;\n\n if (r == topDxRIndex && c == leftDxCIndex) {\n // topLeft\n accumulator +=\n getDy(b, dyR, dyC, d) * inverseDxRLerp * inverseDxCLerp;\n }\n\n if (r == topDxRIndex && c == rightDxCIndex) {\n // topRight\n accumulator += getDy(b, dyR, dyC, d) * inverseDxRLerp * dxCLerp;\n }\n\n if (r == bottomDxRIndex && c == leftDxCIndex) {\n // bottomLeft\n accumulator += getDy(b, dyR, dyC, d) * dxRLerp * inverseDxCLerp;\n }\n\n if (r == bottomDxRIndex && c == rightDxCIndex) {\n // bottomRight\n accumulator += getDy(b, dyR, dyC, d) * dxRLerp * dxCLerp;\n }\n }\n }\n // End loop over dy\n\n setOutput(accumulator);\n }\n `}}const Nu={kernelName:a.FCQ,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{images:a,dy:o}=t,{alignCorners:s}=r,i=new $u(o.shape,a.shape,s);return n.runWebGLProgram(i,[o],o.dtype)}};class Iu{constructor(e,t,n,r,a){this.variableNames=["A"],this.outputShape=[];const[o,s,i,u]=e;this.outputShape=[o,t,n,u];const c=[r&&t>1?s-1:s,r&&n>1?i-1:i],l=[r&&t>1?t-1:t,r&&n>1?n-1:n],p=r?"0.5":"0.0";let h;h=a?"max((vec2(yRC) + vec2(0.5)) * effectiveInputOverOutputRatioRC, vec2(0.0))":"vec2(yRC) * effectiveInputOverOutputRatioRC",this.userCode=`\n const vec2 effectiveInputOverOutputRatioRC = vec2(\n ${c[0]/l[0]},\n ${c[1]/l[1]});\n const vec2 inputShapeRC = vec2(${s}.0, ${i}.0);\n\n void main() {\n ivec4 coords = getOutputCoords();\n int b = coords[0];\n int d = coords[3];\n ivec2 yRC = coords.yz;\n\n // Fractional source index.\n vec2 sourceFracIndexRC = ${h};\n\n // Compute the coordinators of nearest neighbor point.\n ivec2 sourceNearestRC = ivec2(\n min(inputShapeRC - 1.0, floor(sourceFracIndexRC + ${p})));\n float newValue = getA(b, sourceNearestRC.x, sourceNearestRC.y, d);\n\n setOutput(newValue);\n }\n `}}class Au{constructor(e,t,n,r,a){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=[];const[o,s,i,u]=e;this.outputShape=[o,t,n,u];const c=[r&&t>1?s-1:s,r&&n>1?i-1:i],l=[r&&t>1?t-1:t,r&&n>1?n-1:n],p=r?"0.5":"0.0";let h;h=a?"max((vec3(yRC) + vec3(0.5)) * effectiveInputOverOutputRatioRC, vec3(0.0))":"vec3(yRC) * effectiveInputOverOutputRatioRC",this.userCode=`\n const vec3 effectiveInputOverOutputRatioRC = vec3(\n ${c[0]/l[0]},\n ${c[1]/l[1]},\n ${c[1]/l[1]});\n const vec3 inputShapeRC = vec3(${s}.0, ${i}.0,\n ${i}.0);\n\n float getAValue(int b, int r, int c, int d) {\n return getChannel(getA(b, r, c, d), vec2(c, d));\n }\n\n void main() {\n ivec4 coords = getOutputCoords();\n int b = coords[0];\n int d = coords[3];\n // Calculate values for next column in yRC.z.\n ivec3 yRC = coords.yzz + ivec3(0, 0, 1);\n\n // Fractional source index.\n vec3 sourceFracIndexRC = ${h};\n\n // Compute the coordinators of nearest neighbor point.\n ivec3 sourceNearestRC = ivec3(\n min(inputShapeRC - 1.0, floor(sourceFracIndexRC + ${p})));\n\n // Should we calculate next column and row elements in 2x2 packed cell.\n bool hasNextCol = d < ${u-1};\n bool hasNextRow = coords.z < ${n-1};
2\n\n vec4 newValue = vec4(\n getAValue(b, sourceNearestRC.x, sourceNearestRC.y, d),\n hasNextCol ? getAValue(b, sourceNearestRC.x, sourceNearestRC.y, d + 1)\n : 0.0,\n hasNextRow ? getAValue(b, sourceNearestRC.x, sourceNearestRC.z, d)\n : 0.0,\n (hasNextRow && hasNextCol) ?\n getAValue(b, sourceNearestRC.x, sourceNearestRC.z, d + 1) : 0.0);\n\n setOutput(newValue);\n }\n `}}const Ru={kernelName:a.jOE,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{images:o}=t,{alignCorners:s,halfPixelCenters:i,size:u}=r,[c,l]=u,p=(0,a._K2)().getBool("WEBGL_PACK_IMAGE_OPERATIONS")?new Au(o.shape,c,l,s,i):new Iu(o.shape,c,l,s,i);return n.runWebGLProgram(p,[o],o.dtype)}};class _u{constructor(e,t,n){this.variableNames=["dy"],this.outputShape=[],this.outputShape=t;const[,r,a]=t,[,o,s]=e,i=[n&&o>1?r-1:r,n&&s>1?a-1:a],u=[n&&o>1?o-1:o,n&&s>1?s-1:s],c=i[0]/u[0],l=i[1]/u[1],p=1/c,h=1/l,d=2*Math.ceil(p)+2,f=2*Math.ceil(h)+2;this.userCode=`\n void main() {\n ivec4 coords = getOutputCoords();\n int b = coords[0];\n int d = coords[3];\n int r = coords[1];\n int c = coords[2];\n\n float accumulator = 0.0;\n\n const float heightScale = float(${c});\n const float widthScale = float(${l});\n\n const float invHeightScale = float(${p});\n const float invWidthScale = float(${h});\n\n const int winHeight = int(${d});\n const int winWidth = int(${f});\n\n // Compute bounds for where in dy we will look\n float startRLerp = floor(float(r) * invHeightScale);\n int startDyR = int(floor(startRLerp - float(winHeight / 2)));\n\n float startCLerp = floor(float(c) * invWidthScale);\n int startDyC = int(floor(startCLerp - float(winWidth / 2)));\n\n // Loop over dy\n for (int dyROffset = 0; dyROffset < winHeight; dyROffset++) {\n int dyR = dyROffset + startDyR;\n\n // Guard against the window exceeding the bounds of dy\n if (dyR < 0 || dyR >= ${o}) {\n continue;\n }\n\n for (int dyCOffset = 0; dyCOffset < winWidth; dyCOffset++) {\n int dyC = dyCOffset + startDyC;\n\n // Guard against the window exceeding the bounds of dy\n if (dyC < 0 || dyC >= ${s}) {\n continue;\n }\n\n float sourceFracRow =\n float(${i[0]}) *\n (float(dyR) / float(${u[0]}));\n\n float sourceFracCol =\n float(${i[1]}) *\n (float(dyC) / float(${u[1]}));\n\n int sourceNearestRow = int(min(\n float(int(${r}) - 1),\n ${n} ? float(round(sourceFracRow)) :\n float(floor(sourceFracRow))));\n\n int sourceNearestCol = int(min(\n float(int(${a}) - 1),\n ${n} ? float(round(sourceFracCol)) :\n float(floor(sourceFracCol))));\n\n if (r == sourceNearestRow && c == sourceNearestCol) {\n accumulator += getDy(b, dyR, dyC, d);\n }\n }\n }\n // End loop over dy\n\n setOutput(accumulator);\n }\n `}}const Ou={kernelName:a.XQy,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{images:a,dy:o}=t,{alignCorners:s}=r,i=new _u(o.shape,a.shape,s);return n.runWebGLProgram(i,[o],o.dtype)}};class Fu{constructor(e,t){this.variableNames=["x"];const n=e.length;if(n>4)throw new Error(`WebGL backend: Reverse of rank-${n} tensor is not yet supported`);if(this.outputShape=e,1===n)return void(this.userCode=`\n void main() {\n int coord = getOutputCoords();\n setOutput(getX(${e[0]} - coord - 1));\n }\n `);const r=e.map((n,r)=>(n=>-1!==t.indexOf(n)&&1!==e[n]?`${e[n]} - coords[${n}] - 1`:`coords[${n}]`)(r)).join(","),a=ae(n);this.userCode=`\n void main() {\n ${a} coords = getOutputCoords();\n setOutput(getX(${r}));\n }\n `}}class Du{constructor(e,t){this.variableNames=["x"],this.packedInputs=!0,this.packedOutput=!0;const n=e.length;if(n>4)throw new Error(`WebGL backend: Reverse of rank-${n} tensor is not yet supported`);this.outputShape=e;const r=zn("rc",n),a=`${r[n-1]} + 1 < ${this.outputShape[n-1]}`,o=`${r[n-2]} + 1 < ${this.outputShape[n-2]}`,s=ae(n);function i(n){const r=e.map((r,a)=>function(n,r){return-1!==t.indexOf(n)&&1!==e[n]?`${e[n]} - ${r[n]} - 1`:`${r[n]}`}(a,n));return`getChannel(getX(${r.join(",")}), vec2(${r.slice(-2).join(",")}))`}this.userCode=1===n?`\n void main(){\n int rc = getOutputCoords();\n vec4 result = vec4(0.);\n result.r = getChannel(getX(${e[0]} - rc - 1),\n ${e[0]} - rc - 1);\n if(${a}){\n result.g = getChannel(getX(${e[0]} - (rc + 1) - 1),\n ${e[0]} - (rc + 1) - 1);\n }\n setOutput(result);\n }\n `:`\n void main() {\n ${s} rc = getOutputCoords();\n vec4 result = vec4(0.);\n result.r = ${function(e){return i(e)}(r.slice())};\n if(${a}){\n result.g = ${function(e){return e[n-1]="("+e[n-1]+" + 1)",i(e)}(r.slice())};\n }\n if(${o}) {\n result.b = ${function(e){return e[n-2]="("+e[n-2]+" + 1)",i(e)}(r.slice())};\n if(${a}) {\n result.a = ${function(e){return e[n-1]="("+e[n-1]+" + 1)",e[n-2]="("+e[n-2]+" + 1)",i(e)}(r.slice())};\n }\n }\n setOutput(result);\n }\n `}}const Lu={kernelName:a.D7i,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:o}=t,{dims:s}=r,i=o.shape.length,u=a.ZSL.parseAxisParam(s,o.shape);if(0===i)return lr({inputs:{x:o},backend:n});const c=(0,a._K2)().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new Du(o.shape,u):new Fu(o.shape,u);return n.runWebGLProgram(c,[o],o.dtype)}};class Mu{constructor(e,t){this.variableNames=["Image"],this.outputShape=[],this.customUniforms=[{name:"params",type:"vec4"}];const n=e[1],r=e[2];this.outputShape=e;let a="";a="number"==typeof t?`float outputValue = ${t.toFixed(2)};`:`\n vec3 fill = vec3(${t.join(",")});\n float outputValue = fill[coords[3]];`,this.userCode=`\n void main() {\n ivec4 coords = getOutputCoords();\n int x = coords[2];\n int y = coords[1];\n float coordXFloat = (float(x) - params[0]) * params[3] -\n (float(y) - params[1]) * params[2];\n float coordYFloat = (float(x) - params[0]) * params[2] +\n (float(y) - params[1]) * params[3];
2\n int coordX = int(round(coordXFloat + params[0]));\n int coordY = int(round(coordYFloat + params[1]));\n ${a}\n if(coordX >= 0 && coordX < ${r} && coordY >= 0 && coordY < ${n}) {\n outputValue = getImage(coords[0], coordY, coordX, coords[3]);\n }\n setOutput(outputValue);\n }\n `}}const Pu={kernelName:a.BK4,backendName:"webgl",kernelFunc:({inputs:e,attrs:t,backend:n})=>{const{image:r}=e,{radians:o,fillValue:s,center:i}=t,u=n,c=new Mu(r.shape,s),[l,p]=a.C0T.getImageCenter(i,r.shape[1],r.shape[2]),h=[[l,p,Math.sin(o),Math.cos(o)]];return u.runWebGLProgram(c,[r],r.dtype,h)}},Bu=wr({opSnippet:"\n // OpenGL ES does not support round function.\n // The algorithm is based on banker's rounding.\n float base = floor(x);\n if ((x - base) < 0.5) {\n return floor(x);\n } else if ((x - base) > 0.5) {\n return ceil(x);\n } else {\n if (mod(base, 2.0) == 0.0) {\n return base;\n } else {\n return base + 1.0;\n }\n }\n"}),Vu={kernelName:a.hVg,backendName:"webgl",kernelFunc:Bu},zu=wr({opSnippet:"return inversesqrt(x);",cpuKernelImpl:Tn}),Uu={kernelName:a.TOR,backendName:"webgl",kernelFunc:zu};class Wu{constructor(e,t,n,r,a,o,s=!0){this.variableNames=["updates","indices","defaultValue"],this.outputShape=o;const i=ae(a.length),u=ae(o.length);let c="";1===n?c="i":2===n&&(c="i, j");const l=`getIndices(${c})`;let p="";1===r?p="i":2===r&&(p="i, coords[1]");const h=`getUpdates(${p})`,d=t>1?"strides[j]":"strides";this.userCode=`\n ${i} strides = ${i}(${a});\n\n void main() {\n ${u} coords = getOutputCoords();\n float sum = 0.0;\n bool found = false;\n for (int i = 0; i < ${e}; i++) {\n int flattenedIndex = 0;\n for (int j = 0; j < ${t}; j++) {\n int index = round(${l});\n flattenedIndex += index * ${d};\n }\n if (flattenedIndex == coords[0]) {\n sum += ${h};\n found = true;\n }\n }\n setOutput(mix(getDefaultValue(), sum, float(found)));\n }\n `}}const Gu={kernelName:a.pJc,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{indices:o,updates:s}=t,{shape:i}=r,{sliceRank:u,numUpdates:c,sliceSize:l,strides:p,outputSize:h}=a.C0T.calculateShapes(s,o,i),d=[h/l,l];if(0===h)return n.makeTensorInfo(i,o.dtype);const f=Rr({inputs:{x:o},backend:n,attrs:{shape:[c,u]}}),m=Rr({inputs:{x:s},backend:n,attrs:{shape:[c,l]}}),g=n.makeTensorInfo([],"float32",new Float32Array([0])),y=new Wu(c,u,f.shape.length,m.shape.length,p,d),x=n.runWebGLProgram(y,[m,f,g],m.dtype),b=Rr({inputs:{x:x},backend:n,attrs:{shape:i}});return n.disposeIntermediateTensorInfo(f),n.disposeIntermediateTensorInfo(m),n.disposeIntermediateTensorInfo(x),n.disposeIntermediateTensorInfo(g),b}};class ju{constructor(e,t,n,r){this.variableNames=["sortedSequence","values"],this.customUniforms=[{name:"numInputs",type:"int"}],this.outputShape=[e,n];const o=`for (int i = 0; i < ${Math.ceil(Math.log2(t+1))}; ++i) { if (left >= right) break;`,s=2===(0,a._K2)().getNumber("WEBGL_VERSION")?"while (left < right) {":o,i="left"===r?"<":"<=";this.userCode=`\n int findBound(int batch, float value) {\n int left = 0;\n int right = numInputs;\n int mid;\n ${s}\n mid = (left + right) / 2;\n if (getSortedSequence(batch, mid) ${i} value) {\n left = mid + 1;\n } else {\n right = mid;\n }\n }\n return right;\n }\n\n void main() {\n ivec2 coords = getOutputCoords();\n int batch = coords[0];\n int valueIndex = coords[1];\n\n float value = getValues(batch, valueIndex);\n\n setOutput(float(findBound(batch, value)));\n }\n `}}const Ku={kernelName:a.uWl,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{sortedSequence:a,values:o}=t,{side:s}=r,i=new ju(a.shape[0],a.shape[1],o.shape[1],s),u=[[a.shape[1]]];return n.runWebGLProgram(i,[a,o],"int32",u)}};class Hu{constructor(e,t,n){let r,a;
2if(this.variableNames=["c","a","b"],this.outputShape=t,n>4)throw Error(`Where for rank ${n} is not yet supported`);if(1===n)a="resRC",r="resRC";else{const n=["resRC.x","resRC.y","resRC.z","resRC.w"],o=[],s=[];for(let r=0;r<t.length;r++)s.push(`${n[r]}`),r<e&&o.push(`${n[r]}`);r=o.join(),a=s.join()}const o=ae(n);this.userCode=`\n void main() {\n ${o} resRC = getOutputCoords();\n float cVal = getC(${r});\n if (cVal >= 1.0) {\n setOutput(getA(${a}));\n } else {\n setOutput(getB(${a}));\n }\n }\n `}}const Yu={kernelName:a.l6P,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n}=e,{condition:r,t:o,e:s}=t,i=new Hu(r.shape.length,o.shape,o.shape.length);return n.runWebGLProgram(i,[r,o,s],(0,a.TuY)(o.dtype,s.dtype))}},Zu=wr({opSnippet:`\n // Stable and Attracting Fixed Point (0, 1) for Normalized Weights.\n // see: https://arxiv.org/abs/1706.02515\n float scaleAlpha = ${a.C0T.SELU_SCALEALPHA};\n float scale = ${a.C0T.SELU_SCALE};\n return (x >= 0.0) ? scale * x : scaleAlpha * (exp(x) - 1.0);\n`}),Xu={kernelName:a.u$b,backendName:"webgl",kernelFunc:Zu},qu=wr({opSnippet:vr+"\n return 1.0 / (1.0 + exp(-1.0 * x));\n",packedOpSnippet:"\n vec4 result = 1.0 / (1.0 + exp(-1.0 * x));\n bvec4 isNaN = isnan(x);\n\n result.r = isNaN.r ? x.r : result.r;\n result.g = isNaN.g ? x.g : result.g;\n result.b = isNaN.b ? x.b : result.b;\n result.a = isNaN.a ? x.a : result.a;\n\n return result;\n",cpuKernelImpl:Cn}),Qu={kernelName:a.vI1,backendName:"webgl",kernelFunc:qu},Ju=wr({opSnippet:"\n if (isnan(x)) { return 0.0; }\n return sign(x);\n"}),ec={kernelName:a.YVe,backendName:"webgl",kernelFunc:Ju},tc=wr({opSnippet:vr+"\n return sin(x);\n"}),nc={kernelName:a.hql,backendName:"webgl",kernelFunc:tc},rc=wr({opSnippet:"\n float e2x = exp(x);\n return (e2x - 1.0 / e2x) / 2.0;\n"}),ac={kernelName:a.J3C,backendName:"webgl",kernelFunc:rc},oc=wr({opSnippet:"\n float epsilon = 1.1920928955078125e-7;\n float threshold = log(epsilon) + 2.0;\n\n bool too_large = x > -threshold;\n bool too_small = x < threshold;\n\n float result;\n float exp_x = exp(x);\n\n if (too_large){\n result = x;\n }\n else if (too_small){\n result = exp_x;\n }\n else{\n result = log(exp_x + 1.0);\n }\n return result;\n"}),sc={kernelName:a.Fin,backendName:"webgl",kernelFunc:oc},ic={kernelName:a.A8B,backendName:"webgl",kernelFunc:e=>{const{inputs:t,backend:n,attrs:r}=e,{x:o}=t,{blockShape:s,paddings:i}=r;a.ZSL.assert(o.shape.length<=4,()=>"spaceToBatchND for rank > 4 with a WebGL backend not implemented yet");const u=s.reduce((e,t)=>e*t),c=[[0,0]];c.push(...i);for(let e=1+s.length;e<o.shape.length;++e)c.push([0,0]);const l=[],p=cu({inputs:{x:o},backend:n,attrs:{paddings:c,constantValue:0}}),h=a.C0T.getReshaped(p.shape,s,u,!1),d=a.C0T.getPermuted(h.length,s.length,!1),f=a.C0T.getReshapedPermuted(p.shape,s,u,!1),m=Rr({inputs:{x:p},backend:n,attrs:{shape:h}}),g=zr({inputs:{x:m},backend:n,attrs:{perm:d}}),y=Rr({inputs:{x:g},backend:n,attrs:{shape:f}});return l.push(p),l.push(m),l.push(g),l.forEach(e=>n.disposeIntermediateTensorInfo(e)),y}};const uc={kernelName:a.C8s,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n}=e,{indices:r,values:a,denseShape:o,defaultValue:s}=t;if(1!==o.shape.length)throw new Error(`Dense shape must be a vector, saw:\n ${o.shape}`);if(2!==r.shape.length)throw new Error(`Indices must be a matrix, saw:\n ${r.shape}`);if(1!==a.shape.length)throw new Error(`Values must be a vector, saw:\n ${a.shape}`);if(0!==s.shape.length)throw new Error(`Default value must be a scalar, saw:\n ${s.shape}`);const i=n.readSync(r.dataId),u=n.readSync(a.dataId),c=n.readSync(o.dataId),l=n.readSync(s.dataId)[0],[p,h,d,f,m]=$n(i,r.shape,r.dtype,u,a.dtype,c,l);return[n.makeTensorInfo(h,r.dtype,p),n.makeTensorInfo([h[0]],a.dtype,d),n.makeTensorInfo([f.length],"bool",new Uint8Array(f.map(e=>Number(e)))),n.makeTensorInfo([m.length],r.dtype,new Int32Array(m))]}};const cc={kernelName:a.BoJ,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n}=e,{inputIndices:r,inputShape:a,newShape:o}=t;if(2!==r.shape.length)throw new Error(`Input indices should be a matrix but received shape ${r.shape}`);if(1!==a.shape.length)throw new Error(`Input shape should be a vector but received shape ${a.shape}`);if(1!==o.shape.length)throw new Error(`Target shape should be a vector but received shape ${o.shape}`);const s=Array.from(n.readSync(a.dataId)),i=n.readSync(r.dataId),u=Array.from(n.readSync(o.dataId)),[c,l,p]=Nn(i,r.shape,r.dtype,s,u);return[n.makeTensorInfo(l,r.dtype,c),n.makeTensorInfo([p.length],o.dtype,new Int32Array(p))]}};const lc={kernelName:a.L6G,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n}=e,{data:r,indices:a,segmentIds:o}=t;if(r.shape.length<1)throw new Error("Data should be at least 1 dimensional but received scalar");
vendor: 7,255 bytes, line 2
2if(1!==a.shape.length)throw new Error(`Indices should be a vector but received shape\n ${a.shape}`);if(1!==o.shape.length)throw new Error(`Segment ids should be a vector but received shape\n ${o.shape}`);const s=n.readSync(r.dataId),i=n.readSync(a.dataId),u=n.readSync(o.dataId),[c,l]=In(s,r.shape,r.dtype,i,u,!0);return n.makeTensorInfo(l,r.dtype,c)}};const pc={kernelName:a.DvZ,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n}=e,{data:r,indices:a,segmentIds:o}=t;if(r.shape.length<1)throw new Error("Data should be at least 1 dimensional but received scalar");if(1!==a.shape.length)throw new Error(`Indices should be a vector but received shape\n ${a.shape}`);if(1!==o.shape.length)throw new Error(`Segment ids should be a vector but received shape\n ${o.shape}`);const s=n.readSync(r.dataId),i=n.readSync(a.dataId),u=n.readSync(o.dataId),[c,l]=In(s,r.shape,r.dtype,i,u);return n.makeTensorInfo(l,r.dtype,c)}};const hc={kernelName:a.jgd,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{sparseIndices:o,sparseValues:s,defaultValue:i}=t,{outputShape:u}=r,{sliceRank:c,numUpdates:l,sliceSize:p,strides:h,outputSize:d}=a.C0T.calculateShapes(s,o,u),f=!1;if("string"===s.dtype){const e=n.bufferSync(o),t=n.bufferSync(s),r=a.ZSL.decodeString(n.readSync(i.dataId)[0]),m=Sn(e,t,u,d,p,l,c,h,r,f);return n.makeTensorInfo(u,m.dtype,m.values)}const m=new Wu(l,c,o.shape.length,s.shape.length,h,[d,1],f),g=n.runWebGLProgram(m,[s,o,i],s.dtype),y=Rr({inputs:{x:g},backend:n,attrs:{shape:u}});return n.disposeIntermediateTensorInfo(g),y}};const dc={kernelName:a.Blb,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:o}=t,{numOrSizeSplits:s,axis:i}=r,u=a.ZSL.parseAxisParam(i,o.shape)[0],c=a.C0T.prepareSplitSize(o,s,u),l=o.shape.length,p=new Array(l).fill(0),h=o.shape.slice();return c.map(e=>{const t=[...h];t[u]=e;const r=Ma({inputs:{x:o},backend:n,attrs:{begin:p,size:t}});return p[u]+=e,r})}},fc="return sqrt(x);",mc=wr({opSnippet:fc,packedOpSnippet:fc,cpuKernelImpl:An}),gc={kernelName:a.dFH,backendName:"webgl",kernelFunc:mc},yc=wr({opSnippet:"return x * x;"}),xc={kernelName:a.M6A,backendName:"webgl",kernelFunc:yc},bc="return (a - b) * (a - b);",vc=Tr({opSnippet:bc,packedOpSnippet:bc}),wc={kernelName:a.Ddj,backendName:"webgl",kernelFunc:vc};const Tc={kernelName:a.pnw,backendName:"webgl",kernelFunc:function({inputs:e,attrs:t,backend:n}){const{x:r}=e,a=Zn+`\n return x > 0.0 ? 1.0 : float(${t.alpha});\n `,o=new Yn(r.shape,a);return n.runWebGLProgram(o,[r],r.dtype)}};class Sc{constructor(e,t,n){this.variableNames=["x"],this.outputShape=n;const r=n.length,a=ae(n.length),o=ae(n.length);let s="";if(1===r)s="coords * strides + begin";else{let e=0;s=n.map((t,r)=>(e++,1===n.length?`coords * strides[${r}] + begin[${r}]`:`coords[${e-1}] * strides[${r}] + begin[${r}]`)).join(",")}this.userCode=`\n ${a} begin = ${a}(${e});\n ${a} strides = ${a}(${t});\n\n void main() {\n ${o} coords = getOutputCoords();\n setOutput(getX(${s}));\n }\n `}}const Cc={kernelName:a.UcO,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:o}=t,{begin:s,end:i,strides:u,beginMask:c,endMask:l,ellipsisMask:p,newAxisMask:h,shrinkAxisMask:d}=r,{finalShapeSparse:f,finalShape:m,isIdentity:g,sliceDim0:y,isSimpleSlice:x,begin:b,end:v,strides:w}=a.Kro.sliceInfo(o.shape,s,i,u,c,l,p,h,d);let T;if(g)T=Rr({inputs:{x:o},backend:n,attrs:{shape:m}});else if(y||x){a.ZSL.assert(o.shape.length>=1,()=>`Input must have rank at least 1, got: ${o.shape.length}`);const e=a.Kro.computeOutShape(b,v,w),t=Ma({inputs:{x:o},backend:n,attrs:{begin:b,size:e}});T=Rr({inputs:{x:t},backend:n,attrs:{shape:m}}),n.disposeIntermediateTensorInfo(t)}else{if(n.shouldExecuteOnCPU([o])){const e=n.readSync(o.dataId),t=(0,a.ra8)(o.shape,o.dtype,e),r=Rn(f,t,w,b);T=n.makeTensorInfo(m,o.dtype,r.values)}else{const e=new Sc(b,w,f);T=n.runWebGLProgram(e,[o],o.dtype)}}const S=Rr({inputs:{x:T},backend:n,attrs:{shape:m}});return n.disposeIntermediateTensorInfo(T),S}};const kc={kernelName:a.YAb,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{separator:a,nGramWidths:o,leftPad:s,rightPad:i,padWidth:u,preserveShortSequences:c}=r,{data:l,dataSplits:p}=t,h=n.readSync(l.dataId),d=n.readSync(p.dataId),[f,m]=_n(h,d,a,o,s,i,u,c);return[n.makeTensorInfo([f.length],"string",f),n.makeTensorInfo(p.shape,"int32",m)]}};const Ec={kernelName:a.iW0,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{skipEmpty:a}=r,{input:o,delimiter:s}=t;if("string"!==o.dtype)throw new Error("Input must be of datatype string");if(1!==o.shape.length)throw new Error(`Input must be a vector, got shape: ${o.shape}`);if(0!==s.shape.length)throw new Error(`Delimiter must be a scalar, got shape: ${s.shape}`);const i=n.readSync(o.dataId),u=n.readSync(s.dataId)[0],[c,l,p]=On(i,u,a),h=l.length;return[n.makeTensorInfo([h,2],"int32",c),n.makeTensorInfo([h],"string",l),n.makeTensorInfo([2],"int32",new Int32Array(p))]}};const $c={kernelName:a.$jE,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{numBuckets:a}=r,{input:o}=t;if("string"!==o.dtype)throw new Error("Input must be of datatype string");if(a<=0)throw new Error("Number of buckets must be at least 1");const s=n.readSync(o.dataId),i=Fn(s,a);return n.makeTensorInfo(o.shape,"int32",i)}},Nc=wr({opSnippet:"return tan(x);"}),Ic={kernelName:a.oFs,backendName:"webgl",kernelFunc:Nc},Ac=wr({opSnippet:"\n float e2x = exp(-2.0 * abs(x));\n return sign(x) * (1.0 - e2x) / (1.0 + e2x);\n"}),Rc={kernelName:a.iuW,backendName:"webgl",kernelFunc:Ac};class _c{constructor(e,t){this.variableNames=["A"];const n=new Array(e.length);for(let r=0;r<n.length;r++)n[r]=e[r]*t[r];this.outputShape=n,this.rank=n.length;const r=ae(this.rank),a=function(e){const t=e.length;if(t>5)throw Error(`Tile for rank ${t} is not yet supported`);if(1===t)return`imod(resRC, ${e[0]})`;const n=["resRC.x","resRC.y","resRC.z","resRC.w","resRC.u"],r=[];for(let t=0;t<e.length;t++)r.push(`imod(${n[t]}, ${e[t]})`);return r.join()}(e);this.userCode=`\n void main() {\n ${r} resRC = getOutputCoords();\n setOutput(getA(${a}));\n }\n `}}function Oc(e){const{inputs:t,backend:n,attrs:r}=e,{x:o}=t,{reps:s}=r;if("string"===o.dtype||o.shape.length>5){const e=n.readSync(o.dataId),t="string"===o.dtype?e.map(e=>a.ZSL.decodeString(e)):e,r=(0,a.ra8)(o.shape,o.dtype,t),i=Ln(r,s);return n.makeTensorInfo(i.shape,i.dtype,i.values)}const i=new _c(o.shape,s);return n.runWebGLProgram(i,[o],o.dtype)}const Fc={kernelName:a.FAs,backendName:"webgl",kernelFunc:Oc};class Dc{constructor(e){this.variableNames=["x","indices"],this.customUniforms=[{name:"n",type:"int"},{name:"firstPass",type:"int"},{name:"negativeInf",type:"float"},{name:"dir",type:"int"},{name:"inc",type:"int"}],this.outputShape=e,this.userCode="\n void main() {\n ivec2 coords = getOutputCoords();\n int batch = coords[0];\n int elemIdx = coords[1];\n\n // We compare elements pair-wise within a group of size 2 * inc.\n // The comparing rule for each group alternates between ascending\n // and desce
2nding. Within each group, we compare each pair at\n // positions i and i+inc. To decide whether an element at position i\n // is x0 or x1, we mod it by 2 * inc, if the result is smaller than\n // inc, it is in the first half of the group, we denote it as x0,\n // otherwise we denote it as x1.\n // For example, as shown in the Bitonic top K paper referenced above,\n // Figure5(a) shows that element[1] is in the\n // second half of the group when group size is 2, but it is in the\n // first half of the group when group size is 4.\n\n bool isFirstInPair = imod(elemIdx, 2 * inc) < inc;\n int i = isFirstInPair ? elemIdx : elemIdx - inc;\n\n int i0 = firstPass == 1 ? i : int(getIndices(batch, i));\n int i1 = firstPass == 1 ? i + inc : int(getIndices(batch, i + inc));\n float x0 = i0 < n ? getX(batch, i0) : negativeInf;\n float x1 = i1 < n ? getX(batch, i1) : negativeInf;\n\n // Denotes which direction indices are in (ascending or descending).\n bool reverse = imod(elemIdx, 2 * dir) >= dir;\n bool isGreater = x0 > x1 || (x0 == x1 && i1 > i0);\n if (reverse == isGreater) { // Elements in opposite order of direction\n int iTemp = i0;\n i0 = i1;\n i1 = iTemp;\n }\n if (isFirstInPair) {\n setOutput(float(i0));\n } else {\n setOutput(float(i1));\n }\n }\n "}}class Lc{constructor(e){this.variableNames=["x","indices"],this.customUniforms=[{name:"n",type:"int"},{name:"firstPass",type:"int"},{name:"k",type:"int"}],this.outputShape=e,this.userCode="\n void main() {\n // Takes max of indices (0, k), (1, k + 1), (2, k + 2) ...\n ivec2 coords = getOutputCoords();\n int batch = coords[0];\n int elemIdx = coords[1];\n\n // The output size is half of the previous size.\n // If the previous sequence is | | | | _ _ _ _ | | | | _ _ _ _ (k=4),\n // we only need to output the indices at positions |, the indices at\n // positions _ can be thrown away, see Figure5(b) After Phase 2\n // (Merge phase) in the Bitonic Top K paper referenced above.\n // For example, the paper shows we only need to output the orange bars.\n // The output sequence should look like this | | | | | | | |.\n // Because the sequence is halved, to map the output index back\n // to the previous sequence to find the corresponding value,\n // we need to double the index. When we double the index,\n // we basically interpolate a position, so 2i looks like\n // | _ | _ | _ | _ | _ | _ | _. We move the | to the first k position\n // of each 2k positions by - elemIdx % k. E.g. for output at\n // index 4,5,6,7, we want to get the corresponding element at\n // original index 8,9,10,11, for output at index 8,9,10,11,\n // we want to get the corresponding element at original index\n // 16,17,18,19, so on and so forth.\n\n int i = elemIdx < k ? elemIdx : (elemIdx * 2 - imod(elemIdx, k));\n int i0 = firstPass == 1 ? i : int(getIndices(batch, i));\n int i1 = firstPass == 1 ? i + k : int(getIndices(batch, i + k));\n\n float x0 = getX(batch, i0);\n float x1 = i1 < n ? getX(batch, i1) : x0;\n\n setOutput(x0 >= x1 ? float(i0) : float(i1));\n }\n "}}function Mc(e,t){null!==t&&e.disposeIntermediateTensorInfo(t)}function Pc(e){let t=1;for(;t<e;)t*=2;return t}const Bc={kernelName:a.TBb,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:o}=t,{k:s,sorted:i}=r,u=(0,a._K2)().getNumber("TOPK_LAST_DIM_CPU_HANDOFF_SIZE_THRESHOLD"),c=(0,a._K2)().getNumber("TOPK_K_CPU_HANDOFF_THRESHOLD"),l=o.shape,p=l[l.length-1];if(n.shouldExecuteOnCPU([o])||p<u||s>c){const e=n.readSync(o.dataId),[t,r]=Mn(e,l,o.dtype,s,i);return[n.makeTensorInfo(t.shape,t.dtype,t.values),n.makeTensorInfo(r.shape,r.dtype,r.values)]}if(0===s)return l[l.length-1]=0,[n.makeTensorInfo(l,o.dtype,[]),n.makeTensorInfo(l,"int32",[])];if(1===p)return[o,vs({attrs:{shape:l,dtype:"int32",value:0},backend:n})];const h=n.texData.get(o.dataId),d=null!==h&&h.isPacked,f=d?n.unpackTensor(o):o,m=a.ZSL.sizeFromShape(l)/p,g=Rr({inputs:{x:f},attrs:{shape:[m,p]},backend:n});d&&Mc(n,f);const y=Pc(s),x=Pc(p);let b=null;const v=()=>null===b?[g,g]:[g,b],w=(e,t,r)=>{const a=v(),o=new Dc(r),s=[[p],[null===b?1:0],[Number.NEGATIVE_INFINITY],[e],[t]],i=b;b=n.runWebGLProgram(o,a,"int32",s),Mc(n,i)};for(let e=1;e<y;e*=2){const t=2*e;for(let n=e;n>=1;n/=2)w(t,n,[m,x])}for(let e=x;e>y;e/=2){const t=v(),r=new Lc([m,e/2]),a=[[p],[null===b?1:0],[y]],o=b;b=n.runWebGLProgram(r,t,"int32",a),Mc(n,o);const s=y/2,i=2*s;for(let e=s;e>=1;e/=2)w(i,e,b.shape)}let T=b;b=Ma({inputs:{x:b},backend:n,attrs:{begin:0,size:[m,s]}}),Mc(n,T);
vendor: 2,656 bytes, line 2
2let S=Bs({inputs:{x:g,indices:b},backend:n,attrs:{axis:1,batchDims:1}});Mc(n,g);const C=l.slice(0,-1);C.push(s),T=b,b=Rr({inputs:{x:b},attrs:{shape:C},backend:n}),Mc(n,T);const k=S;return S=Rr({inputs:{x:S},attrs:{shape:C},backend:n}),Mc(n,k),[S,b]}};class Vc{constructor(e,t,n,r,a,o){this.variableNames=["Image","Transforms"],this.outputShape=o;const s="nearest"===n?1:2;let i;switch(r){case"constant":default:i=1;break;case"reflect":i=2;break;case"wrap":i=3;break;case"nearest":i=4}this.userCode=`\n float mapCoord(float outCoord, float len) {\n float inCoord = outCoord;\n if(${i} == 2) {\n if (inCoord < 0.0) {\n if (len <= 1.0) {\n inCoord = 0.0;\n } else {\n float sz2 = 2.0 * len;\n if (inCoord < sz2) {\n inCoord = sz2 * float(int(float(-inCoord / sz2))) +\n inCoord;\n }\n inCoord = inCoord < -len ? inCoord + sz2 : -inCoord - 1.0;\n }\n } else if (inCoord > len - 1.0) {\n if (len <= 1.0) {\n inCoord = 0.0;\n } else {\n float sz2 = 2.0 * len;\n inCoord -= sz2 * float(int(float(inCoord / sz2)));\n if (inCoord >= len) {\n inCoord = sz2 - inCoord - 1.0;\n }\n }\n }\n return clamp(inCoord, 0.0, len - 1.0);\n } else if (${i} == 3) {\n if (inCoord < 0.0) {\n if (len <= 1.0) {\n inCoord = 0.0;\n } else {\n float sz = len - 1.0;\n inCoord += len * (float(int(float(-inCoord / sz))) + 1.0);\n }\n } else if (inCoord > len - 1.0) {\n if (len <= 1.0) {\n inCoord = 0.0;\n } else {\n float sz = len - 1.0;\n inCoord -= len * float(int(float(inCoord / sz)));\n }\n }\n return clamp(inCoord, 0.0, len - 1.0);\n } else if (${i} == 4) {\n return clamp(outCoord, 0.0, len - 1.0);\n } else {\n return outCoord;\n }\n }\n\n float readWithFillValue(int batch, int coordY, int coordX,\n int channel) {\n float outputValue;\n if (0 <= coordY && coordY < ${e} && 0 <= coordX && coordX < ${t}
2) {\n outputValue = getImage(batch, coordY, coordX, channel);\n } else {\n outputValue = float(${a});\n }\n return outputValue;\n }\n\n void main() {\n ivec4 coords = getOutputCoords();\n float outputValue;\n int batch = coords[0];\n int x = coords[2];\n int y = coords[1];\n int channel = coords[3];\n float xf = float(x);\n float yf = float(y);\n float a1 = getTransforms(batch, 0);\n float a2 = getTransforms(batch, 1);\n float a3 = getTransforms(batch, 2);\n float b1 = getTransforms(batch, 3);\n float b2 = getTransforms(batch, 4);\n float b3 = getTransforms(batch, 5);\n float c1 = getTransforms(batch, 6);\n float c2 = getTransforms(batch, 7);\n float projection = c1 * xf + c2 * yf + 1.0;\n if (projection == 0.0) {\n outputValue = float(${a});\n } else {\n float inX = (a1 * xf + a2 * yf + a3) / projection;\n float inY = (b1 * xf + b2 * yf + b3) / projection;\n float mapX = mapCoord(inX, float(${t}));\n float mapY = mapCoord(inY, float(${e}));\n\n if (${s} == 1) {\n int coordY = int(round(mapY));
2\n int coordX = int(round(mapX));\n outputValue = readWithFillValue(batch, coordY, coordX,\n channel);\n } else {\n float yFloor = floor(mapY);\n float xFloor = floor(mapX);\n float yCeil = yFloor + 1.0;\n float xCeil = xFloor + 1.0;\n float valueYFloor = (xCeil - mapX) *\n readWithFillValue(batch, int(yFloor), int(xFloor), channel) +\n (mapX - xFloor) *\n readWithFillValue(batch, int(yFloor), int(xCeil), channel);\n float valueYCeil = (xCeil - mapX) *\n readWithFillValue(batch, int(yCeil), int(xFloor), channel) +\n (mapX - xFloor) *\n readWithFillValue(batch, int(yCeil), int(xCeil), channel);\n outputValue = (yCeil - mapY) * valueYFloor +\n (mapY - yFloor) * valueYCeil;\n }\n }\n setOutput(outputValue);\n }\n `}}const zc={kernelName:a.dLy,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{image:a,transforms:o}=t,{interpolation:s,fillMode:i,fillValue:u,outputShape:c}=r,[l,p,h,d]=a.shape,[f,m]=null!=c?c:[p,h],g=new Vc(p,h,s,i,u,[l,f,m,d]);return n.runWebGLProgram(g,[a,o],"float32")}};const Uc={kernelName:a.EwU,backendName:"webgl",kernelFunc:function(e){const{inputs:t,attrs:n,backend:r}=e,{axis:a}=n,{x:o}=t;B(o,"unique");const s=r.readSync(o.dataId),{outputValues:i,outputShape:u,indices:c}=Bn(s,a,o.shape,o.dtype);return[r.makeTensorInfo(u,o.dtype,i),r.makeTensorInfo([c.length],"int32",c)]}};const Wc={kernelName:a.dXR,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{value:a}=t;let{axis:o}=r;o<0&&(o+=a.shape.length);const s=a,i=s.shape.length,u=a.shape[o],c=new Array(i-1);let l=0;for(let e=0;e<i;e++)e!==o&&(c[l++]=s.shape[e]);const p=[],h=new Array(i).fill(0),d=s.shape.slice();d[o]=1;const f=new Array(u);for(let e=0;e<f.length;e++){h[o]=e;const t=Ma({inputs:{x:s},backend:n,attrs:{begin:h,size:d}}),r=Rr({inputs:{x:t},backend:n,attrs:{shape:c}});f[e]=r,p.push(t)}return p.forEach(e=>n.disposeIntermediateTensorInfo(e)),f}};class Gc{constructor(e,t){this.variableNames=["x","segmentIds"];const n=e.windowSize,r=e.batchSize,a=e.inSize,o=e.numSegments,s=o*Math.ceil(a/n);this.outputShape=[r,s];const i=4*Math.floor(n/4),u=n%4,c="\n sumValue += dot(values, segFilter);\n ";let l="";a%n>0&&(l=`\n if (inIdx < 0 || inIdx >= ${a}) {\n return initializationValue;\n }\n `);let p="";a%n>0&&(p=`\n if (inIdx < 0 || inIdx >= ${a}) {\n return -1.0;\n }\n `),this.userCode=`\n const float initializationValue = 0.0;\n\n float getValue(int batch, int inIdx) {\n ${l}\n return getX(batch, inIdx);\n }\n\n float getSegmentIdAtIndex(int inIdx) {\n ${p}\n return getSegmentIds(inIdx);\n }\n\n void main() {\n ivec2 coords = getOutputCoords();\n int batch = coords[0];\n int outIdx = coords[1];\n int inOffset = int(floor(float(outIdx) / float(\n ${o})) * float(${n}));\n int currentSeg = int(mod(float(outIdx), float(${o})));\n\n float sumValue = 0.0;\n\n for (int i = 0; i < ${i}; i += 4) {\n int inIdx = inOffset + i;\n vec4 values = vec4(\n getValue(batch, inIdx),\n getValue(batch, inIdx + 1),\n getValue(batch, inIdx + 2),\n getValue(batch, inIdx + 3)\n );\n\n vec4 segFilter = vec4(\n int(getSegmentIdAtIndex(inIdx)) == currentSeg ? 1 : 0,\n int(getSegmentIdAtIndex(inIdx + 1)) == currentSeg ? 1 : 0,\n int(getSegmentIdAtIndex(inIdx + 2)) == currentSeg ? 1 : 0,\n int(getSegmentIdAtIndex(inIdx + 3)) == currentSeg ? 1 : 0\n );\n\n ${c}\n }\n\n int inIdx = inOffset + ${i};\n if (${1===u}) {\n vec4 values = vec4(\n getValue(batch, inIdx),\n initializationValue,\n initializationValue,\n initializationValue\n );\n\n int inIdxSeg = int(getSegmentIdAtIndex(inIdx));\n\n vec4 segFilter = vec4(\n int(getSegmentIdAtIndex(inIdx)) == currentSeg ? 1 : 0,\n 0,\n 0,\n 0\n );\n\n ${c}\n } else if (${2===u}) {\n vec4 values = vec4(\n getValue(batch, inIdx),\n getValue(batch, inIdx + 1),\n initializationValue,\n initializationValue\n );\n\n vec4 segFilter = vec4(\n int(getSegmentIdAtIndex(inIdx)) == currentSeg ? 1 : 0,\n int(getSegmentIdAtIndex(inIdx + 1)) == currentSeg ? 1 : 0,\n 0,\n 0\n );\n\n ${c}\n } else if (${3===u}) {\n vec4 values = vec4(\n getValue(batch, inIdx),\n getValue(batch, inIdx + 1),\n getValue(batch, inIdx + 2),\n initializationValue\n );\n\n vec4 segFilter = vec4(\n int(getSegmentIdAtIndex(inIdx)) == currentSeg ? 1 : 0,\n int(getSegmentIdAtIndex(inIdx + 1)) == currentSeg ? 1 : 0,\n int(getSegmentIdAtIndex(inIdx + 2)) == currentSeg ? 1 : 0,\n 0\n );\n\n ${c}\n }\n setOutput(sumValue);\n }\n `}}const jc=[Gr,Kr,Yr,Xr,Jr,na,ra,aa,la,pa,da,ma,ya,ba,wa,Ca,ka,Na,Ia,Aa,Oa,Ba,Va,za,Ka,Za,Qa,dr,to,co,xo,So,Co,ko,Eo,$o,Io,Ro,Oo,Bo,Vo,zo,Wo,Ko,Zo,Xo,Qo,es,ts,rs,as,ss,us,ls,hs,ms,xs,ws,Ss,Es,Ns,Rs,Fs,Ds,Ms,Vs,Us,Gs,pr,js,so,Hs,Zs,qs,gr,Js,ti,ni,ai,si,ui,li,hi,mi,yi,bi,wi,Ti,Si,Ei,$i,Ni,Ii,Ai,_i,Di,Mi,Ki,Ar,Yi,Xi,Qi,eu,Wa,nu,ou,su,lu,hu,br,du,fu,mu,yu,ja,Vi,bu,
2wu,Su,_r,Eu,Nu,Ru,Ou,Lu,Pu,Vu,Uu,Gu,Ku,Yu,Xu,Qu,ec,nc,ac,Pa,ji,sc,ic,uc,cc,lc,pc,hc,dc,gc,xc,wc,Tc,Cc,kc,Ec,$c,Wi,Vr,Ic,Rc,Fc,Bc,zc,Ur,Uc,Wc,{kernelName:a.pPe,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:o,segmentIds:s}=t,{numSegments:i}=r,u=o.shape.length,c=[];let l=0;const p=a.C0T.getAxesPermutation([l],u);let h=o;null!=p&&(h=zr({inputs:{x:o},backend:n,attrs:{perm:p}}),c.push(h),l=a.C0T.getInnerMostAxes(1,u)[0]);const d=a.C0T.segment_util.computeOutShape(h.shape,l,i),f=a.ZSL.sizeFromShape([h.shape[l]]),m=Rr({inputs:{x:h},backend:n,attrs:{shape:[-1,f]}});c.push(m);const g=(0,a.chL)(o.dtype),y=(e,t,r,o,s)=>{const i=e.shape[0],u=e.shape[1],l=a.C0T.segment_util.segOpComputeOptimalWindowSize(u,s),p=new Gc({windowSize:l,inSize:u,batchSize:i,numSegments:s},t),h=n.compileAndRun(p,[e,r],o);if(c.push(h),h.shape[1]===s)return h;const d=gu({backend:n,attrs:{start:0,stop:s,step:1,dtype:"float32"}}),f=Oc({inputs:{x:d},backend:n,attrs:{reps:[u/l]}});c.push(d),c.push(f);return y(h,t,f,o,s)},x=Rr({inputs:{x:y(m,"unsortedSegmentSum",s,g,i)},backend:n,attrs:{shape:d}});let b=x;if(null!=p){c.push(x);const e=a.C0T.getUndoAxesPermutation(p);b=zr({inputs:{x:b},backend:n,attrs:{perm:e}})}return c.forEach(e=>n.disposeIntermediateTensorInfo(e)),b}},au];for(const e of jc)(0,a.tAK)(e)},47195:function(e,t,n){"use strict";n.d(t,{$Q:function(){return g},Dh:function(){return f},E6:function(){return o},G0:function(){return m},G8:function(){return c},YQ:function(){return a},l5:function(){return s},p$:function(){return u},s_:function(){return y},uf:function(){return i}});var r=n(45119);function a(e,t,n,r,a="NHWC",o){return i(e,[...t,e[3]],n,o,r,null,null,g(a))}function o(e,t,n,r,a,o,s="channelsLast"){const[u,c]=l(t);let p;if("channelsLast"===s)p=[u,c,e[3],e[3]];else{if("channelsFirst"!==s)throw new Error(`Unknown dataFormat ${s}`);p=[u,c,e[1],e[1]]}return i(e,p,n,r,a,o,!1,s)}function s(e,t,n,r,a,o,s="NDHWC"){const[i,c,l]=p(t);let h,d;if("NDHWC"===s)d="channelsLast",h=[i,c,l,e[4],e[4]];else{if("NCDHW"!==s)throw new Error(`Unknown dataFormat ${s}`);d="channelsFirst",h=[i,c,l,e[1],e[1]]}return u(e,h,n,r,a,!1,d,o)}function i(e,t,n,r,a,o,s=!1,i="channelsLast"){let[u,p,f,m]=[-1,-1,-1,-1];if("channelsLast"===i)[u,p,f,m]=e;else{if("channelsFirst"!==i)throw new Error(`Unknown dataFormat ${i}`);[u,m,p,f]=e}const[g,y,,x]=t,[b,v]=l(n),[w,T]=l(r),S=h(g,w),C=h(y,T),{padInfo:k,outHeight:E,outWidth:$}=function(e,t,n,r,a,o,s,i,u){let l,p,h;if("number"==typeof e){l={top:e,bottom:e,left:e,right:e,type:0===e?"VALID":"NUMBER"};const a=function(e,t,n,r,a){null==r&&(r=c(e,t,n));const o=e[0],s=e[1],i=d((o-t+2*r)/n+1,a),u=d((s-t+2*r)/n+1,a);return[i,u]}([t,n],o,r,e,i);p=a[0],h=a[1]}else if("same"===e){p=Math.ceil(t/r),h=Math.ceil(n/a);const e=Math.max(0,(p-1)*r+o-t),i=Math.max(0,(h-1)*a+s-n),u=Math.floor(e/2),c=e-u,d=Math.floor(i/2);l={top:u,bottom:c,left:d,right:i-d,type:"SAME"}}else if("valid"===e)l={top:0,bottom:0,left:0,right:0,type:"VALID"},p=Math.ceil((t-o+1)/r),h=Math.ceil((n-s+1)/a);else{if("object"!=typeof e)throw Error(`Unknown padding parameter: ${e}`);{const c="channelsLast"===u?e[1][0]:e[2][0],f="channelsLast"===u?e[1][1]:e[2][1],m="channelsLast"===u?e[2][0]:e[3][0],g="channelsLast"===u?e[2][1]:e[3][1];l={top:c,bottom:f,left:m,right:g,type:0===c&&0===f&&0===m&&0===g?"VALID":"EXPLICIT"},p=d((t-o+c+f)/r+1,i),h=d((n-s+m+g)/a+1,i)}}return{padInfo:l,outHeight:p,outWidth:h}}(a,p,f,b,v,S,C,o,i),N=s?x*m:x;let I;return"channelsFirst"===i?I=[u,N,E,$]:"channelsLast"===i&&(I=[u,E,$,N]),{batchSize:u,dataFormat:i,inHeight:p,inWidth:f,inChannels:m,outHeight:E,outWidth:$,outChannels:N,padInfo:k,strideHeight:b,strideWidth:v,filterHeight:g,filterWidth:y,effectiveFilterHeight:S,effectiveFilterWidth:C,dilationHeight:w,dilationWidth:T,inShape:e,outShape:I,filterShape:t}}function u(e,t,n,r,a,o=!1,s="channelsLast",i){let[u,l,f,m,g]=[-1,-1,-1,-1,-1];if("channelsLast"===s)[u,l,f,m,g]=e;else{if("channelsFirst"!==s)throw new Error(`Unknown dataFormat ${s}`);[u,g,l,f,m]=e}const[y,x,b,,v]=t,[w,T,S]=p(n),[C,k,E]=p(r),$=h(y,C),N=h(x,k),I=h(b,E),{padInfo:A,outDepth:R,outHeight:_,outWidth:O}=function(e,t,n,r,a,o,s,i,u,l,p){let h,f,m,g;if("number"==typeof e){h={top:e,bottom:e,left:e,right:e,front:e,back:e,type:0===e?"VALID":"NUMBER"};const o=function(e,t,n,r,a,o){null==a&&(a=c(e,t,r));const s=e[0],i=e[1],u=e[2],l=d((s-t+2*a)/r+1,o),p=d((i-t+2*a)/r+1,o),h=d((u-t+2*a)/r+1,o);return[l,p,h,n]}([t,n,r,1],i,1,a,e,p);
2f=o[0],m=o[1],g=o[2]}else if("same"===e){f=Math.ceil(t/a),m=Math.ceil(n/o),g=Math.ceil(r/s);const e=(f-1)*a+i-t,c=(m-1)*o+u-n,p=(g-1)*s+l-r,d=Math.floor(e/2),y=e-d,x=Math.floor(c/2),b=c-x,v=Math.floor(p/2);h={top:x,bottom:b,left:v,right:p-v,front:d,back:y,type:"SAME"}}else{if("valid"!==e)throw Error(`Unknown padding parameter: ${e}`);h={top:0,bottom:0,left:0,right:0,front:0,back:0,type:"VALID"},f=Math.ceil((t-i+1)/a),m=Math.ceil((n-u+1)/o),g=Math.ceil((r-l+1)/s)}return{padInfo:h,outDepth:f,outHeight:m,outWidth:g}}(a,l,f,m,w,T,S,$,N,I,i),F=o?v*g:v;let D;return"channelsFirst"===s?D=[u,F,R,_,O]:"channelsLast"===s&&(D=[u,R,_,O,F]),{batchSize:u,dataFormat:s,inDepth:l,inHeight:f,inWidth:m,inChannels:g,outDepth:R,outHeight:_,outWidth:O,outChannels:F,padInfo:A,strideDepth:w,strideHeight:T,strideWidth:S,filterDepth:y,filterHeight:x,filterWidth:b,effectiveFilterDepth:$,effectiveFilterHeight:N,effectiveFilterWidth:I,dilationDepth:C,dilationHeight:k,dilationWidth:E,inShape:e,outShape:D,filterShape:t}}function c(e,t,n,r=1){const a=h(t,r);return Math.floor((e[0]*(n-1)-n+a)/2)}function l(e){return"number"==typeof e?[e,e,e]:2===e.length?[e[0],e[1],1]:e}function p(e){return"number"==typeof e?[e,e,e]:e}function h(e,t){return t<=1?e:e+(e-1)*(t-1)}function d(e,t){if(!t)return Math.trunc(e);switch(t){case"round":return Math.round(e);case"ceil":return Math.ceil(e);case"floor":return Math.floor(e);default:throw new Error(`Unknown roundingMode ${t}`)}}function f(e){const[t,n,r]=l(e);return 1===t&&1===n&&1===r}function m(e,t){return f(e)||f(t)}function g(e){if("NHWC"===e)return"channelsLast";if("NCHW"===e)return"channelsFirst";throw new Error(`Unknown dataFormat ${e}`)}function y(e,t,n){if(null!=n){if("string"==typeof t)throw Error(`Error in ${e}: pad must be an integer when using dimRoundingMode ${n} but got pad ${t}.`);if("number"==typeof t)r.vA(r.E6(t),()=>`Error in ${e}: pad must be an integer when using dimRoundingMode ${n} but got pad ${t}.`);else{if("object"!=typeof t)throw Error(`Error in ${e}: Unknown padding parameter: ${t}`);t.forEach(t=>{t.forEach(t=>{r.vA(r.E6(t),()=>`Error in ${e}: pad must be an integer when using dimRoundingMode ${n} but got pad ${t}.`)})})}}}},52046:function(e,t,n){"use strict";var r,a,o,s,i;n.d(t,{Tu:function(){return c},ch:function(){return l}}),function(e){e.R0="R0",e.R1="R1",e.R2="R2",e.R3="R3",e.R4="R4",e.R5="R5",e.R6="R6"}(r||(r={})),function(e){e.float32="float32",e.int32="int32",e.bool="int32",e.complex64="complex64"}(a||(a={})),function(e){e.float32="float32",e.int32="int32",e.bool="bool",e.complex64="complex64"}(o||(o={})),function(e){e.float32="float32",e.int32="float32",e.bool="float32",e.complex64="complex64"}(s||(s={})),function(e){e.float32="complex64",e.int32="complex64",e.bool="complex64",e.complex64="complex64"}(i||(i={}));const u={float32:s,int32:a,bool:o,complex64:i};function c(e,t){if("string"===e||"string"===t){if("string"===e&&"string"===t)return"string";throw new Error(`Can not upcast ${e} with ${t}`)}return u[e][t]}function l(e){return c(e,"int32")}},54411:function(e,t,n){"use strict";n.d(t,{Y:function(){return a}});var r=n(448);function a(e,t){const n=[];for(let e=0;e<t.length;e++)t[e]&&n.push(e);const a=(0,r.r)(e,"int32"),o=(0,r.r)([n.length,e.length],"int32");for(let t=0;t<n.length;t++){const r=a.indexToLoc(n[t]),s=t*e.length;o.values.set(r,s)}return o.toTensor()}},57260:function(e,t,n){"use strict";n.d(t,{T2:function(){return v},Ye:function(){return b}});var r=n(15149),a=n(46574),o=n(41743),s=n(15441),i=n(37074),u=n(73673),c=n(31259),l=n(45119);class p{constructor(e,t){this.backendTimer=e,this.logger=t,null==t&&(this.logger=new d)}profileKernel(e,t,n){let r;const o=()=>{r=n()};let s;const i=c.now();if(this.backendTimer.timerAvailable())s=this.backendTimer.time(o);else{o();for(const e of r)e.dataSync();s=Promise.resolve({kernelMs:c.now()-i})}if((0,a._K)().getBool("CHECK_COMPUTATION_FOR_ERRORS"))for(let t=0;t<r.length;t++){const n=r[t];n.data().then(t=>{h(t,n.dtype,e)})}return{kernelName:e,outputs:r,inputs:t,timeMs:s.then(e=>e.kernelMs),extraInfo:s.then(e=>null!=e.getExtraProfileInfo?e.getExtraProfileInfo():"")}}logKernelProfile(e){const{kernelName:t,outputs:n,timeMs:r,inputs:a,extraInfo:o}=e;
2n.forEach(e=>{Promise.all([e.data(),r,o]).then(n=>{this.logger.logKernelProfile(t,e,n[0],n[1],a,n[2])})})}}function h(e,t,n){if("float32"!==t)return!1;for(let t=0;t<e.length;t++){const n=e[t];if(isNaN(n)||!isFinite(n))return!0}return!1}class d{logKernelProfile(e,t,n,r,a,o){"number"==typeof r?l.av(`${r}ms`,9):r.error,l.av(e,25),t.rank,t.size,l.av(t.shape.toString(),14);let s="";for(const e in a){const n=a[e];if(null!=n){const r=n.shape||t.shape,a=r.length;s+=`${e}: ${a}D ${a>0?r:""} `}}}}var f=n(21722),m=n(30565);function g(e){return null!=e.kernelName}class y{constructor(){this.registeredVariables={},this.nextTapeNodeId=0,this.numBytes=0,this.numTensors=0,this.numStringTensors=0,this.numDataBuffers=0,this.gradientDepth=0,this.kernelDepth=0,this.scopeStack=[],this.numDataMovesStack=[],this.nextScopeId=0,this.tensorInfo=new WeakMap,this.profiling=!1,this.activeProfile={newBytes:0,newTensors:0,peakBytes:0,kernels:[],result:null,get kernelNames(){return Array.from(new Set(this.kernels.map(e=>e.name)))}}}dispose(){for(const e in this.registeredVariables)this.registeredVariables[e].dispose()}}class x{constructor(e){this.ENV=e,this.registry={},this.registryFactory={},this.pendingBackendInitId=0,this.state=new y}async ready(){if(null!=this.pendingBackendInit)return this.pendingBackendInit.then(()=>{});if(null!=this.backendInstance)return;const e=this.getSortedBackends();for(let t=0;t<e.length;t++){const n=e[t];if(await this.initializeBackend(n).success)return void await this.setBackend(n)}throw new Error("Could not initialize any backends, all backend initializations failed.")}get backend(){if(null!=this.pendingBackendInit)throw new Error(`Backend '${this.backendName}' has not yet been initialized. Make sure to await tf.ready() or await tf.setBackend() before calling other methods`);if(null==this.backendInstance){const{name:e,asyncInit:t}=this.initializeBackendsAndReturnBest();if(t)throw new Error(`The highest priority backend '${e}' has not yet been initialized. Make sure to await tf.ready() or await tf.setBackend() before calling other methods`);this.setBackend(e)}return this.backendInstance}backendNames(){return Object.keys(this.registryFactory)}findBackend(e){if(!(e in this.registry)){if(!(e in this.registryFactory))return null;{const{asyncInit:t}=this.initializeBackend(e);if(t)return null}}return this.registry[e]}findBackendFactory(e){return e in this.registryFactory?this.registryFactory[e].factory:null}registerBackend(e,t,n=1){return e in this.registryFactory?(u.i(`${e} backend was already registered. Reusing existing backend factory.`),!1):(this.registryFactory[e]={factory:t,priority:n},!0)}async setBackend(e){if(null==this.registryFactory[e])throw new Error(`Backend name '${e}' not found in registry`);
vendor: 9,302 bytes, line 2
2if(this.backendName=e,null==this.registry[e]){this.backendInstance=null;const{success:t,asyncInit:n}=this.initializeBackend(e);if(!(n?await t:t))return!1}return this.backendInstance=this.registry[e],this.setupRegisteredKernels(),this.profiler=new p(this.backendInstance),!0}setupRegisteredKernels(){(0,i.Op)(this.backendName).forEach(e=>{null!=e.setupFunc&&e.setupFunc(this.backendInstance)})}disposeRegisteredKernels(e){(0,i.Op)(e).forEach(t=>{null!=t.disposeFunc&&t.disposeFunc(this.registry[e])})}initializeBackend(e){const t=this.registryFactory[e];if(null==t)throw new Error(`Cannot initialize backend ${e}, no registration found.`);try{const n=t.factory();if(!n||n instanceof r.uI||"function"!=typeof n.then)return this.registry[e]=n,{success:!0,asyncInit:!1};{const t=++this.pendingBackendInitId,r=n.then(n=>!(t<this.pendingBackendInitId)&&(this.registry[e]=n,this.pendingBackendInit=null,!0)).catch(n=>(t<this.pendingBackendInitId||(this.pendingBackendInit=null,u.i(`Initialization of backend ${e} failed`),u.i(n.stack||n.message)),!1));return this.pendingBackendInit=r,{success:r,asyncInit:!0}}}catch(t){return u.i(`Initialization of backend ${e} failed`),u.i(t.stack||t.message),{success:!1,asyncInit:!1}}}removeBackend(e){if(!(e in this.registryFactory))throw new Error(`${e} backend not found in registry`);this.backendName===e&&null!=this.pendingBackendInit&&this.pendingBackendInitId++,e in this.registry&&(this.disposeRegisteredKernels(e),this.registry[e].dispose(),delete this.registry[e]),delete this.registryFactory[e],this.backendName===e&&(this.pendingBackendInit=null,this.backendName=null,this.backendInstance=null)}getSortedBackends(){if(0===Object.keys(this.registryFactory).length)throw new Error("No backend found in registry.");return Object.keys(this.registryFactory).sort((e,t)=>this.registryFactory[t].priority-this.registryFactory[e].priority)}initializeBackendsAndReturnBest(){const e=this.getSortedBackends();for(let t=0;t<e.length;t++){const n=e[t],{success:r,asyncInit:a}=this.initializeBackend(n);if(a||r)return{name:n,asyncInit:a}}throw new Error("Could not initialize any backends, all backend initializations failed.")}moveData(e,t){const n=this.state.tensorInfo.get(t),r=n.backend,a=this.readSync(t),o=r.refCount(t);r.disposeData(t,!0),n.backend=e,e.move(t,a,n.shape,n.dtype,o),this.shouldCheckForMemLeaks()&&this.state.numDataMovesStack[this.state.numDataMovesStack.length-1]++}tidy(e,t){let n,r=null;if(null==t){if("function"!=typeof e)throw new Error("Please provide a function to tidy()");t=e}else{if("string"!=typeof e&&!(e instanceof String))throw new Error("When calling with two arguments, the first argument to tidy() must be a string");if("function"!=typeof t)throw new Error("When calling with two arguments, the 2nd argument to tidy() must be a function");r=e}return this.scopedRun(()=>this.startScope(r),()=>this.endScope(n),()=>(n=t(),n))}scopedRun(e,t,n){e();try{const e=n();return t(),e}catch(e){throw t(),e}}nextTensorId(){return x.nextTensorId++}nextVariableId(){return x.nextVariableId++}clone(e){const t=v.runKernel(s.lzr,{x:e}),n={x:e};return this.addTapeNode(this.state.activeScope.name,n,[t],e=>({x:()=>{const t={x:e},n={dtype:"float32"};return v.runKernel(s.KXH,t,n)}}),[],{}),t}runKernel(e,t,n){null==this.backendName&&this.backend;if(!(null!=(0,i._5)(e,this.backendName)))throw new Error(`Kernel '${e}' not registered for backend '${this.backendName}'`);return this.runKernelFunc({kernelName:e,inputs:t,attrs:n})}shouldCheckForMemLeaks(){return this.ENV.getBool("IS_TEST")}checkKernelForMemLeak(e,t,n){const r=this.backend.numDataIds();let a=0;n.forEach(e=>{a+="complex64"===e.dtype?3:1});const o=this.state.numDataMovesStack[this.state.numDataMovesStack.length-1],s=r-t-a-o;if(s>0)throw new Error(`Backend '${this.backendName}' has an internal memory leak (${s} data ids) after running '${e}'`)}runKernelFunc(e){let t,n=[];const r=this.isTapeOn(),a=this.state.numBytes,o=this.state.numTensors;let s,u;this.shouldCheckForMemLeaks()&&this.state.numDataMovesStack.push(0),null==this.backendName&&this.backend;const c=g(e)?e.kernelName:null!=this.state.activeScope?this.state.activeScope.name:"";if(g(e)){const{kernelName:t,inputs:a,attrs:o}=e;null==this.backendName&&this.backend;const c=(0,i._5)(t,this.backendName);l.vA(null!=c,()=>`Cannot find registered kernel '${t}' for backend '${this.backendName}'`),s=()=>{const e=this.backend.numDataIds();u=c.kernelFunc({inputs:a,attrs:o,backend:this.backend});const s=Array.isArray(u)?u:[u];this.shouldCheckForMemLeaks()&&this.checkKernelForMemLeak(t,e,s);const i=s.map(e=>null!=e.rank?e:this.makeTensorFromTensorInfo(e));if(r){const e=this.getTensorsForGradient(t,a,i);n=this.saveTensorsForBackwardMode(e)}return i}}else{const{forwardFunc:t}=e,a=e=>{r&&(n=e.map(e=>this.keep(this.clone(e))))};s=()=>{const e=this.backend.numDataIds();u=this.tidy(()=>t(this.backend,a));const n=Array.isArray(u)?u:[u];return this.shouldCheckForMemLeaks()&&this.checkKernelForMemLeak(c,e,n),n}}const{inputs:p,attrs:h}=e,d=g(e)?null:e.backwardsFunc;let f;return this.scopedRun(()=>this.state.kernelDepth++,()=>this.state.kernelDepth--,()=>{this.ENV.getBool("DEBUG")||this.state.profiling?(f=this.profiler.profileKernel(c,p,()=>s()),this.ENV.getBool("DEBUG")&&this.profiler.logKernelProfile(f),t=f.outputs):t=s()}),r&&this.addTapeNode(c,p,t,d,n,h),this.state.profiling&&this.state.activeProfile.kernels.push({name:c,bytesAdded:this.state.numBytes-a,totalBytesSnapshot:this.state.numBytes,tensorsAdded:this.state.numTensors-o,totalTensorsSnapshot:this.state.numTensors,inputShapes:Object.keys(p).map(e=>null!=p[e]?p[e].shape:null),outputShapes:t.map(e=>e.shape),kernelTimeMs:f.timeMs,extraInfo:f.extraInfo}),Array.isArray(u)?t:t[0]}saveTensorsForBackwardMode(e){const t=e.map(e=>this.keep(this.clone(e)));return t}getTensorsForGradient(e,t,n){const r=(0,i.vQ)(e);if(null!=r){const e=r.inputsToSave||[],a=r.outputsToSave||[];let o;r.saveAllInputs?(l.vA(Array.isArray(t),()=>"saveAllInputs is true, expected inputs to be an array."),o=Object.keys(t).map(e=>t[e])):o=e.map(e=>t[e]);const s=n.filter((e,t)=>a[t]);return o.concat(s)}return[]}makeTensor(e,t,n,r){if(null==e)throw new Error("Values passed to engine.makeTensor() are null");n=n||"float32",r=r||this.backend;let a=e;"string"===n&&l.Kg(e[0])&&(a=e.map(e=>c.encodeString(e)));const o=r.write(a,t,n),s=new f.qY(t,n,o,this.nextTensorId());if(this.trackTensor(s,r),"string"===n){const e=this.state.tensorInfo.get(o),t=(0,l.SL)(a);this.state.numBytes+=t-e.bytes,e.bytes=t}return s}makeTensorFromDataId(e,t,n,r){const a={dataId:e,shape:t,dtype:n=n||"float32"};return this.makeTensorFromTensorInfo(a,r)}makeTensorFromTensorInfo(e,t){const{dataId:n,shape:r,dtype:a}=e,o=new f.qY(r,a,n,this.nextTensorId());return this.trackTensor(o,t),o}makeVariable(e,t=!0,n,r){n=n||this.nextVariableId().toString(),null!=r&&r!==e.dtype&&(e=e.cast(r));const a=new f.rT(e,t,n,this.nextTensorId());if(null!=this.state.registeredVariables[a.name])throw new Error(`Variable with name ${a.name} was already registered`);return this.state.registeredVariables[a.name]=a,this.incRef(a,this.backend),a}trackTensor(e,t){this.state.numTensors++,"string"===e.dtype&&this.state.numStringTensors++;let n=0;"complex64"!==e.dtype&&"string"!==e.dtype&&(n=e.size*l.jv(e.dtype)),this.state.numBytes+=n,this.state.tensorInfo.has(e.dataId)||(this.state.numDataBuffers++,this.state.tensorInfo.set(e.dataId,{backend:t||this.backend,dtype:e.dtype,shape:e.shape,bytes:n})),e instanceof f.rT||this.track(e)}incRef(e,t){this.trackTensor(e,t),this.backend.incRef(e.dataId)}removeDataId(e,t){this.state.tensorInfo.has(e)&&this.state.tensorInfo.get(e).backend===t&&(this.state.tensorInfo.delete(e),this.state.numDataBuffers--)}disposeTensor(e){if(!this.state.tensorInfo.has(e.dataId))return;const t=this.state.tensorInfo.get(e.dataId);if(this.state.numTensors--,"string"===e.dtype&&(this.state.numStringTensors--,this.state.numBytes-=t.bytes),"complex64"!==e.dtype&&"string"!==e.dtype){const t=e.size*l.jv(e.dtype);this.state.numBytes-=t}t.backend.disposeData(e.dataId)&&this.removeDataId(e.dataId,t.backend)}disposeVariables(){for(const e in this.state.registeredVariables){const t=this.state.registeredVariables[e];this.disposeVariable(t)}}disposeVariable(e){this.disposeTensor(e),null!=this.state.registeredVariables[e.name]&&delete this.state.registeredVariables[e.name]}memory(){const e=this.backend.memory();return e.numTensors=this.state.numTensors,e.numDataBuffers=this.state.numDataBuffers,e.numBytes=this.state.numBytes,this.state.numStringTensors>0&&(e.unreliable=!0,null==e.reasons&&(e.reasons=[]),e.reasons.push("Memory usage by string tensors is approximate (2 bytes per character)")),e}async profile(e){this.state.profiling=!0;const t=this.state.numBytes,n=this.state.numTensors;this.state.activeProfile.kernels=[],this.state.activeProfile.result=await e(),this.state.profiling=!1,this.state.activeProfile.peakBytes=Math.max(...this.state.activeProfile.kernels.map(e=>e.totalBytesSnapshot)),this.state.activeProfile.newBytes=this.state.numBytes-t,this.state.activeProfile.newTensors=this.state.numTensors-n;for(const e of this.state.activeProfile.kernels)e.kernelTimeMs=await e.kernelTimeMs,e.extraInfo=await e.extraInfo;return this.state.activeProfile}isTapeOn(){return this.state.gradientDepth>
20&&0===this.state.kernelDepth}addTapeNode(e,t,n,r,a,o){const s={id:this.state.nextTapeNodeId++,kernelName:e,inputs:t,outputs:n,saved:a},u=(0,i.vQ)(e);null!=u&&(r=u.gradFunc),null!=r&&(s.gradient=e=>(e=e.map((e,t)=>{if(null==e){const e=n[t],r=l.Ty(e.size,e.dtype);return this.makeTensor(r,e.shape,e.dtype)}return e}),r(e.length>1?e:e[0],a,o))),this.state.activeTape.push(s)}keep(e){return e.kept=!0,e}startTape(){0===this.state.gradientDepth&&(this.state.activeTape=[]),this.state.gradientDepth++}endTape(){this.state.gradientDepth--}startScope(e){const t={track:[],name:"unnamed scope",id:this.state.nextScopeId++};e&&(t.name=e),this.state.scopeStack.push(t),this.state.activeScope=t}endScope(e){const t=(0,m.NB)(e),n=new Set(t.map(e=>e.id));for(let e=0;e<this.state.activeScope.track.length;e++){const t=this.state.activeScope.track[e];t.kept||n.has(t.id)||t.dispose()}const r=this.state.scopeStack.pop();this.state.activeScope=0===this.state.scopeStack.length?null:this.state.scopeStack[this.state.scopeStack.length-1],t.forEach(e=>{e.kept||e.scopeId!==r.id||this.track(e)})}gradients(e,t,n,r=!1){if(l.vA(t.length>0,()=>"gradients() received an empty list of xs."),null!=n&&"float32"!==n.dtype)throw new Error(`dy must have 'float32' dtype, but has '${n.dtype}'`);const a=this.scopedRun(()=>this.startTape(),()=>this.endTape(),()=>this.tidy("forward",e));l.vA(a instanceof f.qY,()=>"The result y returned by f() must be a tensor.");const o=function(e,t,n){const r={},a={};for(let e=0;e<t.length;e++)r[t[e].id]=!0;for(let n=0;n<e.length;n++){const o=e[n],s=o.inputs;for(const e in s){const n=s[e];let i=!1;for(let e=0;e<t.length;e++)if(r[n.id]){o.outputs.forEach(e=>r[e.id]=!0),i=!0,a[o.id]=!0;break}if(i)break}}const o={};o[n.id]=!0;const s={};for(let t=e.length-1;t>=0;t--){const n=e[t],r=n.inputs;for(let e=0;e<n.outputs.length;e++)if(o[n.outputs[e].id]){for(const e in r)o[r[e].id]=!0,s[n.id]=!0;break}}const i=[];for(let t=0;t<e.length;t++){const n=e[t];if(a[n.id]&&s[n.id]){const e={};for(const t in n.inputs){const a=n.inputs[t];r[a.id]&&(e[t]=a)}const t=Object.assign({},n);t.inputs=e,t.outputs=n.outputs,i.push(t)}}return i}(this.state.activeTape,t,a);if(!r&&0===o.length&&t.length>0)throw new Error("Cannot compute gradient of y=f(x) with respect to x. Make sure that the f you passed encloses all operations that lead from x to y.");return this.tidy("backward",()=>{const e={};e[a.id]=null==n?function(e){const t=(0,l.FZ)((0,l.Ze)(e),"float32");return v.makeTensor(t,e,"float32")}(a.shape):n,function(e,t,n,r){for(let a=t.length-1;a>=0;a--){const o=t[a],s=[];if(o.outputs.forEach(t=>{const n=e[t.id];null!=n?s.push(n):s.push(null)}),null==o.gradient)throw new Error(`Cannot compute gradient: gradient function not found for ${o.kernelName}.`);const i=o.gradient(s);for(const t in o.inputs){if(!(t in i))throw new Error(`Cannot backprop through input ${t}. Available gradients found: ${Object.keys(i)}.`);const a=n(()=>i[t]());if("float32"!==a.dtype)throw new Error(`Error in gradient for op ${o.kernelName}. The gradient of input ${t} must have 'float32' dtype, but has '${a.dtype}'`);const s=o.inputs[t];if(!l.r1(a.shape,s.shape))throw new Error(`Error in gradient for op ${o.kernelName}. The gradient of input '${t}' has shape '${a.shape}', which does not match the shape of the input '${s.shape}'`);if(null==e[s.id])e[s.id]=a;else{const t=e[s.id];e[s.id]=r(t,a),t.dispose()}}}}(e,o,e=>this.tidy(e),w);const r=t.map(t=>e[t.id]);return 0===this.state.gradientDepth&&(this.state.activeTape.forEach(e=>{for(const t of e.saved)t.dispose()}),this.state.activeTape=null),{value:a,grads:r}})}customGrad(e){return l.vA(l.Tn(e),()=>"The f passed in customGrad(f) must be a function."),(...t)=>{let n;l.vA(t.every(e=>e instanceof f.qY),()=>"The args passed in customGrad(f)(x1, x2,...) must all be tensors");const r={};t.forEach((e,t)=>{r[t]=e});return this.runKernelFunc({forwardFunc:(r,a)=>(n=e(...t,a),l.vA(n.value instanceof f.qY,()=>"The function f passed in customGrad(f) must return an object where `obj.value` is a tensor"),l.vA(l.Tn(n.gradFunc),()=>"The function f passed in customGrad(f) must return an object where `obj.gradFunc` is a function."),n.value),backwardsFunc:(e,r)=>{const a=n.gradFunc(e,r),o=Array.isArray(a)?a:[a];l.vA(o.length===t.length,()=>"The function f passed in customGrad(f) must return an object where `obj.gradFunc` is a function that returns the same number of tensors as inputs passed to f(...)."),l.vA(o.every(e=>e instanceof f.qY),()=>"The function f passed in customGrad(f) must return an object where `obj.gradFunc` is a function that returns a list of only tensors.");const s={};return o.forEach((e,t)=>{s[t]=()=>e}),s},inputs:r})}}readSync(e){return this.state.tensorInfo.get(e).backend.readSync(e)}read(e){return this.state.tensorInfo.get(e).backend.read(e)}readToGPU(e,t){return this.state.tensorInfo.get(e).backend.readToGPU(e,t)}async time(e){const t=(0,c.now)(),n=await this.backend.time(e);return n.wallMs=(0,c.now)()-t,n}track(e){return null!=this.state.activeScope&&(e.scopeId=this.state.activeScope.id,this.state.activeScope.track.push(e)),e}get registeredVariables(){return this.state.registeredVariables}reset(){this.pendingBackendInitId++,this.state.dispose(),this.ENV.reset(),this.state=new y;for(const e in this.registry)this.disposeRegisteredKernels(e),this.registry[e].dispose(),delete this.registry[e];this.backendName=null,this.backendInstance=null,this.pendingBackendInit=null}}function b(){const e=(0,o.L)();if(null==e._tfengine){const t=new a.OH(e);e._tfengine=new x(t)}return(0,a.tj)(e._tfengine.ENV),(0,f.qP)(()=>e._tfengine),e._tfengine}x.nextTensorId=0,x.nextVariableId=0;const v=b();function w(e,t){const n={a:e,b:t};return v.runKernel(s.OMN,n)}},62198:function(e,t,n){"use strict";function r(e,t){const n=e.length,r=[];for(let a=0;a<n;a++){const o=n-1-a,s=e[o]||1;(t[t.length-1-a]||1)>1&&1===s&&r.unshift(o)}return r}function a(e,t){const n=[];for(let r=0;r<t.length;r++){const a=e[e.length-r-1],o=t.length-r-1,s=t[o];(null==a||1===a&&s>1)&&n.unshift(o)}return n}function o(e,t){const n=[],r=Math.max(e.length,t.length);for(let a=0;a<r;a++){let r=e[e.length-a-1];null==r&&(r=1);let o=t[t.length-a-1];if(null==o&&(o=1),1===r)n.unshift(o);else if(1===o)n.unshift(r);else{if(r!==o){throw Error(`Operands could not be broadcast together with shapes ${e} and ${t}.`)}n.unshift(r)}}return n}n.r(t),n.d(t,{assertAndGetBroadcastShape:function(){return o},getBroadcastDims:function(){return r},getReductionAxes:function(){return a}})},62302:function(e,t,n){"use strict";n.d(t,{t:function(){return s}});var r=n(57260),a=n(15441),o=n(28189);
vendor: 6,777 bytes, line 2
2const s=(0,n(70929).op)({reshape_:function(e,t){const n={x:(0,o.YT)(e,"x","reshape","string_or_numeric")},s={shape:t};return r.T2.runKernel(a.R23,n,s)}})},62726:function(e,t,n){(function(){"use strict";var e;function t(e){var t=0;return function(){return t<e.length?{done:!1,value:e[t++]}:{done:!0}}}var r="function"==typeof Object.defineProperties?Object.defineProperty:function(e,t,n){return e==Array.prototype||e==Object.prototype||(e[t]=n.value),e};var a=function(e){e=["object"==typeof globalThis&&globalThis,e,"object"==typeof window&&window,"object"==typeof self&&self,"object"==typeof n.g&&n.g];for(var t=0;t<e.length;++t){var r=e[t];if(r&&r.Math==Math)return r}throw Error("Cannot find global object")}(this);function o(e,t){if(t)e:{var n=a;e=e.split(".");for(var o=0;o<e.length-1;o++){var s=e[o];if(!(s in n))break e;n=n[s]}(t=t(o=n[e=e[e.length-1]]))!=o&&null!=t&&r(n,e,{configurable:!0,writable:!0,value:t})}}function s(e){return(e={next:e})[Symbol.iterator]=function(){return this},e}function i(e){var n="undefined"!=typeof Symbol&&Symbol.iterator&&e[Symbol.iterator];return n?n.call(e):{next:t(e)}}function u(e){if(!(e instanceof Array)){e=i(e);for(var t,n=[];!(t=e.next()).done;)n.push(t.value);e=n}return e}o("Symbol",function(e){function t(e,t){this.g=e,r(this,"description",{configurable:!0,writable:!0,value:t})}if(e)return e;t.prototype.toString=function(){return this.g};var n="jscomp_symbol_"+(1e9*Math.random()>>>0)+"_",a=0;return function e(r){if(this instanceof e)throw new TypeError("Symbol is not a constructor");return new t(n+(r||"")+"_"+a++,r)}}),o("Symbol.iterator",function(e){if(e)return e;e=Symbol("Symbol.iterator");for(var n="Array Int8Array Uint8Array Uint8ClampedArray Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array".split(" "),o=0;o<n.length;o++){var i=a[n[o]];"function"==typeof i&&"function"!=typeof i.prototype[e]&&r(i.prototype,e,{configurable:!0,writable:!0,value:function(){return s(t(this))}})}return e});var c,l="function"==typeof Object.create?Object.create:function(e){function t(){}return t.prototype=e,new t};if("function"==typeof Object.setPrototypeOf)c=Object.setPrototypeOf;else{var p;e:{var h={};try{h.__proto__={a:!0},p=h.a;break e}catch(e){}p=!1}c=p?function(e,t){if(e.__proto__=t,e.__proto__!==t)throw new TypeError(e+" is not extensible");return e}:null}var d=c;function f(e,t){if(e.prototype=l(t.prototype),e.prototype.constructor=e,d)d(e,t);else for(var n in t)if("prototype"!=n)if(Object.defineProperties){var r=Object.getOwnPropertyDescriptor(t,n);r&&Object.defineProperty(e,n,r)}else e[n]=t[n];e.ea=t.prototype}function m(){this.l=!1,this.i=null,this.h=void 0,this.g=1,this.s=this.m=0,this.j=null}function g(e){if(e.l)throw new TypeError("Generator is already running");e.l=!0}function y(e,t){e.j={U:t,V:!0},e.g=e.m||e.s}function x(e,t,n){return e.g=n,{value:t}}function b(e){this.g=new m,this.h=e}function v(e,t,n,r){try{var a=t.call(e.g.i,n);if(!(a instanceof Object))throw new TypeError("Iterator result "+a+" is not an object");if(!a.done)return e.g.l=!1,a;var o=a.value}catch(t){return e.g.i=null,y(e.g,t),w(e)}return e.g.i=null,r.call(e.g,o),w(e)}function w(e){for(;e.g.g;)try{var t=e.h(e.g);if(t)return e.g.l=!1,{value:t.value,done:!1}}catch(t){e.g.h=void 0,y(e.g,t)}if(e.g.l=!1,e.g.j){if(t=e.g.j,e.g.j=null,t.V)throw t.U;return{value:t.return,done:!0}}return{value:void 0,done:!0}}function T(e){this.next=function(t){return g(e.g),e.g.i?t=v(e,e.g.i.next,t,e.g.o):(e.g.o(t),t=w(e)),t},this.throw=function(t){return g(e.g),e.g.i?t=v(e,e.g.i.throw,t,e.g.o):(y(e.g,t),t=w(e)),t},this.return=function(t){return function(e,t){g(e.g);var n=e.g.i;return n?v(e,"return"in n?n.return:function(e){return{value:e,done:!0}},t,e.g.return):(e.g.return(t),w(e))}(e,t)},this[Symbol.iterator]=function(){return this}}function S(e,t){return t=new T(new b(t)),d&&e.prototype&&d(t,e.prototype),t}m.prototype.o=function(e){this.h=e},m.prototype.return=function(e){this.j={return:e},this.g=this.s};var C="function"==typeof Object.assign?Object.assign:function(e,t){for(var n=1;n<arguments.length;n++){var r=arguments[n];if(r)for(var a in r)Object.prototype.hasOwnProperty.call(r,a)&&(e[a]=r[a])}return e};o("Object.assign",function(e){return e||C}),o("Promise",function(e){function t(e){this.h=0,this.i=void 0,this.g=[],this.o=!1;var t=this.j();try{e(t.resolve,t.reject)}catch(e){t.reject(e)}}function n(){this.g=null}function r(e){return e instanceof t?e:new t(function(t){t(e)})}if(e)return e;n.prototype.h=function(e){if(null==this.g){this.g=[];var t=this;this.i(function(){t.l()})}this.g.push(e)};var o=a.setTimeout;n.prototype.i=function(e){o(e,0)},n.prototype.l=function(){for(;this.g&&this.g.length;){var e=this.g;this.g=[];for(var t=0;t<e.length;++t){var n=e[t];e[t]=null;try{n()}catch(e){this.j(e)}}}this.g=null},n.prototype.j=function(e){this.i(function(){throw e})},t.prototype.j=function(){function e(e){return function(r){n||(n=!0,e.call(t,r))}}var t=this,n=!1;return{resolve:e(this.C),reject:e(this.l)}},t.prototype.C=function(e){if(e===this)this.l(new TypeError("A Promise cannot resolve to itself"));else if(e instanceof t)this.F(e);else{e:switch(typeof e){case"object":var n=null!=e;break e;case"function":n=!0;break e;default:n=!1}n?this.u(e):this.m(e)}},t.prototype.u=function(e){var t=void 0;try{t=e.then}catch(e){return void this.l(e)}"function"==typeof t?this.G(t,e):this.m(e)},t.prototype.l=function(e){this.s(2,e)},t.prototype.m=function(e){this.s(1,e)},t.prototype.s=function(e,t){if(0!=this.h)throw Error("Cannot settle("+e+", "+t+"): Promise already settled in state"+this.h);this.h=e,this.i=t,2===this.h&&this.D(),this.A()},t.prototype.D=function(){var e=this;o(function(){if(e.B()){var t=a.console;void 0!==t&&t.error(e.i)}},1)},t.prototype.B=function(){if(this.o)return!1;var e=a.CustomEvent,t=a.Event,n=a.dispatchEvent;return void 0===n||("function"==typeof e?e=new e("unhandledrejection",{cancelable:!0}):"function"==typeof t?e=new t("unhandledrejection",{cancelable:!0}):(e=a.document.createEvent("CustomEvent")).initCustomEvent("unhandledrejection",!1,!0,e),e.promise=this,e.reason=this.i,n(e))},t.prototype.A=function(){if(null!=this.g){for(var e=0;e<this.g.length;++e)s.h(this.g[e]);this.g=null}};var s=new n;return t.prototype.F=function(e){var t=this.j();e.J(t.resolve,t.reject)},t.prototype.G=function(e,t){var n=this.j();try{e.call(t,n.resolve,n.reject)}catch(e){n.reject(e)}},t.prototype.then=function(e,n){function r(e,t){return"function"==typeof e?function(t){try{a(e(t))}catch(e){o(e)}}:t}var a,o,s=new t(function(e,t){a=e,o=t});return this.J(r(e,a),r(n,o)),s},t.prototype.catch=function(e){return this.then(void 0,e)},t.prototype.J=function(e,t){function n(){switch(r.h){case 1:e(r.i);break;case 2:t(r.i);break;default:throw Error("Unexpected state: "+r.h)}}
2var r=this;null==this.g?s.h(n):this.g.push(n),this.o=!0},t.resolve=r,t.reject=function(e){return new t(function(t,n){n(e)})},t.race=function(e){return new t(function(t,n){for(var a=i(e),o=a.next();!o.done;o=a.next())r(o.value).J(t,n)})},t.all=function(e){var n=i(e),a=n.next();return a.done?r([]):new t(function(e,t){function o(t){return function(n){s[t]=n,0==--i&&e(s)}}var s=[],i=0;do{s.push(void 0),i++,r(a.value).J(o(s.length-1),t),a=n.next()}while(!a.done)})},t}),o("Object.is",function(e){return e||function(e,t){return e===t?0!==e||1/e==1/t:e!=e&&t!=t}}),o("Array.prototype.includes",function(e){return e||function(e,t){var n=this;n instanceof String&&(n=String(n));var r=n.length;for(0>(t=t||0)&&(t=Math.max(t+r,0));t<r;t++){var a=n[t];if(a===e||Object.is(a,e))return!0}return!1}}),o("String.prototype.includes",function(e){return e||function(e,t){if(null==this)throw new TypeError("The 'this' value for String.prototype.includes must not be null or undefined");if(e instanceof RegExp)throw new TypeError("First argument to String.prototype.includes must not be a regular expression");return-1!==this.indexOf(e,t||0)}}),o("Array.prototype.keys",function(e){return e||function(){return function(e,t){e instanceof String&&(e+="");var n=0,r=!1,a={next:function(){if(!r&&n<e.length){var a=n++;return{value:t(a,e[a]),done:!1}}return r=!0,{done:!0,value:void 0}}};return a[Symbol.iterator]=function(){return a},a}(this,function(e){return e})}});var k=this||self;function E(e,t){e=e.split(".");var n,r=k;e[0]in r||void 0===r.execScript||r.execScript("var "+e[0]);for(;e.length&&(n=e.shift());)e.length||void 0===t?r=r[n]&&r[n]!==Object.prototype[n]?r[n]:r[n]={}:r[n]=t}function $(e,t){return t=String.fromCharCode.apply(null,t),null==e?t:e+t}var N,I,A="undefined"!=typeof TextDecoder,R="undefined"!=typeof TextEncoder;function _(e){if(R)e=(I||(I=new TextEncoder)).encode(e);else{var t=void 0;t=void 0!==t&&t;for(var n=0,r=new Uint8Array(3*e.length),a=0;a<e.length;a++){var o=e.charCodeAt(a);if(128>o)r[n++]=o;else{if(2048>o)r[n++]=o>>6|192;else{if(55296<=o&&57343>=o){if(56319>=o&&a<e.length){var s=e.charCodeAt(++a);if(56320<=s&&57343>=s){o=1024*(o-55296)+s-56320+65536,r[n++]=o>>18|240,r[n++]=o>>12&63|128,r[n++]=o>>6&63|128,r[n++]=63&o|128;continue}a--}if(t)throw Error("Found an unpaired surrogate");o=65533}r[n++]=o>>12|224,r[n++]=o>>6&63|128}r[n++]=63&o|128}}e=r.subarray(0,n)}return e}var O={},F=null;function D(e,t){void 0===t&&(t=0),M(),t=O[t];for(var n=Array(Math.floor(e.length/3)),r=t[64]||"",a=0,o=0;a<e.length-2;a+=3){var s=e[a],i=e[a+1],u=e[a+2],c=t[s>>2];s=t[(3&s)<<4|i>>4],i=t[(15&i)<<2|u>>6],u=t[63&u],n[o++]=c+s+i+u}switch(c=0,u=r,e.length-a){case 2:u=t[(15&(c=e[a+1]))<<2]||r;case 1:e=e[a],n[o]=t[e>>2]+t[(3&e)<<4|c>>4]+u+r}return n.join("")}function L(e){var t=e.length,n=3*t/4;n%3?n=Math.floor(n):-1!="=.".indexOf(e[t-1])&&(n=-1!="=.".indexOf(e[t-2])?n-2:n-1);var r=new Uint8Array(n),a=0;return function(e,t){function n(t){for(;r<e.length;){var n=e.charAt(r++),a=F[n];if(null!=a)return a;if(!/^[\s\xa0]*$/.test(n))throw Error("Unknown base64 encoding at char: "+n)}return t}M();for(var r=0;;){var a=n(-1),o=n(0),s=n(64),i=n(64);if(64===i&&-1===a)break;t(a<<2|o>>4),64!=s&&(t(o<<4&240|s>>2),64!=i&&t(s<<6&192|i))}}(e,function(e){r[a++]=e}),r.subarray(0,a)}function M(){if(!F){F={};for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".split(""),t=["+/=","+/","-_=","-_.","-_"],n=0;5>n;n++){var r=e.concat(t[n].split(""));O[n]=r;for(var a=0;a<r.length;a++){var o=r[a];void 0===F[o]&&(F[o]=a)}}}}var P,B="function"==typeof Uint8Array.prototype.slice;function V(e,t,n){return t===n?P||(P=new Uint8Array(0)):B?e.slice(t,n):new Uint8Array(e.subarray(t,n))}var z=0;function U(e,t){t=void 0!==(t=void 0===t?{}:t).v&&t.v,this.h=null,this.g=this.j=this.l=0,this.m=!1,this.v=t,e&&W(this,e)}function W(e,t){t=t.constructor===Uint8Array?t:t.constructor===ArrayBuffer||t.constructor===Array?new Uint8Array(t):t.constructor===String?L(t):t instanceof Uint8Array?new Uint8Array(t.buffer,t.byteOffset,t.byteLength):new Uint8Array(0),e.h=t,e.l=0,e.j=e.h.length,e.g=e.l}function G(e){for(var t=128,n=0,r=0,a=0;4>a&&128<=t;a++)n|=(127&(t=e.h[e.g++]))<<7*a;if(128<=t&&(n|=(127&(t=e.h[e.g++]))<<28,r|=(127&t)>>4),128<=t)for(a=0;5>a&&128<=t;a++)r|=(127&(t=e.h[e.g++]))<<7*a+3;if(128>t)return e=n>>>0,(r=2147483648&(t=r>>>0))&&(t=~t>>>0,0==(e=1+~e>>>0)&&(t=t+1>>>0)),e=4294967296*t+(e>>>0),r?-e:e;e.m=!0}U.prototype.reset=function(){this.g=this.l},U.prototype.i=function(){var e=this.h,t=e[this.g],n=127&t;return 128>t?(this.g+=1,n):(n|=(127&(t=e[this.g+1]))<<7,128>t?(this.g+=2,n):(n|=(127&(t=e[this.g+2]))<<14,128>t?(this.g+=3,n):(n|=(127&(t=e[this.g+3]))<<21,128>t?(this.g+=4,n):(n|=(15&(t=e[this.g+4]))<<28,128>t?(this.g+=5,n>>>0):(this.g+=5,128<=e[this.g++]&&128<=e[this.g++]&&128<=e[this.g++]&&128<=e[this.g++]&&this.g++,n)))))},U.prototype.o=function(){var e=this.h[this.g],t=this.h[this.g+1],n=this.h[this.g+2],r=this.h[this.g+3];return this.g+=4,e=2*((n=(e|t<<8|n<<16|r<<24)>>>0)>>31)+1,t=n>>>23&255,n&=8388607,255==t?n?NaN:1/0*e:0==t?e*Math.pow(2,-149)*n:e*Math.pow(2,t-150)*(n+Math.pow(2,23))};var j=[];function K(){this.g=new Uint8Array(64),this.h=0}function H(e,t){for(;127<t;)e.push(127&t|128),t>>>=7;e.push(t)}function Y(e){var t={},n=void 0!==t.N&&t.N;this.o={v:void 0!==t.v&&t.v},this.N=n,t=this.o,j.length?(n=j.pop(),t&&(n.v=t.v),e&&W(n,e),e=n):e=new U(e,t),this.g=e,this.m=this.g.g,this.h=this.i=this.l=-1,this.j=!1}function Z(e){var t=e.g;if((t=t.g==t.j)||(t=e.j)||(t=(t=e.g).m||0>t.g||t.g>t.j),t)return!1;e.m=e.g.g;var n=7&(t=e.g.i());return 0!=n&&5!=n&&1!=n&&2!=n&&3!=n&&4!=n?(e.j=!0,!1):(e.i=t,e.l=t>>>3,e.h=n,!0)}function X(e){switch(e.h){case 0:if(0!=e.h)X(e);else{for(e=e.g;128&e.h[e.g];)e.g++;e.g++}break;case 1:1!=e.h?X(e):(e=e.g).g+=8;break;case 2:if(2!=e.h)X(e);else{var t=e.g.i();(e=e.g).g+=t}break;case 5:5!=e.h?X(e):(e=e.g).g+=4;break;case 3:for(t=e.l;;){if(!Z(e)){e.j=!0;break}if(4==e.h){e.l!=t&&(e.j=!0);break}X(e)}break;default:e.j=!0}}function q(e,t,n){var r=e.g.j,a=e.g.i(),o=e.g.g+a;
2if(e.g.j=o,n(t,e),0!==(n=o-e.g.g))throw Error("Message parsing ended unexpectedly. Expected to read "+a+" bytes, instead read "+(a-n)+" bytes, either the data ended unexpectedly or the message misreported its own length");return e.g.g=o,e.g.j=r,t}function Q(e){return e.g.o()}function J(e){var t,n=e.g.i(),r=(e=e.g).g;if(e.g+=n,e=e.h,A)(t=N)||(t=N=new TextDecoder("utf-8",{fatal:!1})),t=t.decode(e.subarray(r,r+n));else{n=r+n;for(var a,o,s,i=[],u=null;r<n;)128>(a=e[r++])?i.push(a):224>a?r>=n?i.push(65533):(o=e[r++],194>a||128!=(192&o)?(r--,i.push(65533)):i.push((31&a)<<6|63&o)):240>a?r>=n-1?i.push(65533):128!=(192&(o=e[r++]))||224===a&&160>o||237===a&&160<=o||128!=(192&(t=e[r++]))?(r--,i.push(65533)):i.push((15&a)<<12|(63&o)<<6|63&t):244>=a?r>=n-2?i.push(65533):128!=(192&(o=e[r++]))||o-144+(a<<28)>>30||128!=(192&(t=e[r++]))||128!=(192&(s=e[r++]))?(r--,i.push(65533)):(a=(7&a)<<18|(63&o)<<12|(63&t)<<6|63&s,a-=65536,i.push(55296+(a>>10&1023),56320+(1023&a))):i.push(65533),8192<=i.length&&(u=$(u,i),i.length=0);t=$(u,i)}return t}function ee(e,t,n){var r=e.g.i();for(r=e.g.g+r;e.g.g<r;)n.push(t.call(e.g))}function te(e,t){2==e.h?ee(e,U.prototype.o,t):t.push(Q(e))}function ne(){this.h=[],this.i=0,this.g=new K}function re(e,t){0!==t.length&&(e.h.push(t),e.i+=t.length)}function ae(e){var t=e.i+e.g.length();if(0===t)return new Uint8Array(0);t=new Uint8Array(t);for(var n=e.h,r=n.length,a=0,o=0;o<r;o++){var s=n[o];0!==s.length&&(t.set(s,a),a+=s.length)}return 0!==(r=(n=e.g).h)&&(t.set(n.g.subarray(0,r),a),n.h=0),e.h=[t],t}function oe(e,t,n){if(null!=n){H(e.g,8*t+5),e=e.g;var r=n;0===(r=(n=0>r?1:0)?-r:r)?0<1/r?z=0:z=2147483648:isNaN(r)?z=2147483647:34028234663852886e22<r?z=(n<<31|2139095040)>>>0:11754943508222875e-54>r?(r=Math.round(r/Math.pow(2,-149)),z=(n<<31|r)>>>0):(t=Math.floor(Math.log(r)/Math.LN2),r*=Math.pow(2,-t),16777216<=(r=Math.round(8388608*r))&&++t,z=(n<<31|t+127<<23|8388607&r)>>>0),n=z,e.push(n>>>0&255),e.push(n>>>8&255),e.push(n>>>16&255),e.push(n>>>24&255)}}K.prototype.push=function(e){if(!(this.h+1<this.g.length)){var t=this.g;this.g=new Uint8Array(Math.ceil(1+2*this.g.length)),this.g.set(t)}this.g[this.h++]=e},K.prototype.length=function(){return this.h},K.prototype.end=function(){var e=this.g,t=this.h;return this.h=0,V(e,0,t)},Y.prototype.reset=function(){this.g.reset(),this.h=this.l=-1};var se="function"==typeof Uint8Array;function ie(e,t,n){if(null!=e)return"object"==typeof e?se&&e instanceof Uint8Array?n(e):ue(e,t,n):t(e)}function ue(e,t,n){if(Array.isArray(e)){for(var r=Array(e.length),a=0;a<e.length;a++)r[a]=ie(e[a],t,n);return Array.isArray(e)&&e.W&&he(r),r}for(a in r={},e)r[a]=ie(e[a],t,n);return r}function ce(e){return"number"==typeof e?isFinite(e)?e:String(e):e}var le,pe={W:{value:!0,configurable:!0}};function he(e){return Array.isArray(e)&&!Object.isFrozen(e)&&Object.defineProperties(e,pe),e}function de(e,t,n){var r=le;if(le=null,e||(e=r),r=this.constructor.ca,e||(e=r?[r]:[]),this.j=r?0:-1,this.m=this.g=null,this.h=e,e=(r=this.h.length)-1,!r||(null===(r=this.h[e])||"object"!=typeof r||Array.isArray(r)||se&&r instanceof Uint8Array)?void 0!==t&&-1<t?(this.l=Math.max(t,e+1-this.j),this.i=null):this.l=Number.MAX_VALUE:(this.l=e-this.j,this.i=r),n)for(t=0;t<n.length;t++)(e=n[t])<this.l?(e+=this.j,(r=this.h[e])?he(r):this.h[e]=fe):(me(this),(r=this.i[e])?he(r):this.i[e]=fe)}var fe=Object.freeze(he([]));function me(e){var t=e.l+e.j;e.h[t]||(e.i=e.h[t]={})}function ge(e,t,n){return-1===t?null:void 0!==n&&n||t>=e.l?e.i?e.i[t]:void 0:e.h[t+e.j]}function ye(e,t){var n=void 0!==n&&n,r=ge(e,t,n);return null==r&&(r=fe),r===fe&&we(e,t,r=he([]),n),r}function xe(e){var t=ye(e,3);if(e.m||(e.m={}),!e.m[3]){for(var n=0;n<t.length;n++)t[n]=+t[n];e.m[3]=!0}return t}function be(e,t,n){return null==(e=ge(e,t))?n:e}function ve(e,t,n){return null==(e=null==(e=ge(e,t))?e:+e)?void 0===n?0:n:e}function we(e,t,n,r){void 0!==r&&r||t>=e.l?(me(e),e.i[t]=n):e.h[t+e.j]=n}function Te(e,t,n){if(-1===n)return null;if(e.g||(e.g={}),!e.g[n]){var r=ge(e,n,!1);r&&(e.g[n]=new t(r))}return e.g[n]}function Se(e,t){e.g||(e.g={});var n=e.g[1];if(!n){var r=ye(e,1);n=[];for(var a=0;a<r.length;a++)n[a]=new t(r[a]);e.g[1]=n}return n}function Ce(e,t,n){var r=void 0!==r&&r;e.g||(e.g={});var a=n?Ee(n,!1):n;e.g[t]=n,we(e,t,a,r)}function ke(e,t,n,r){var a=Se(e,n);t=t||new n,e=ye(e,1),null!=r?(a.splice(r,0,t),e.splice(r,0,Ee(t,!1))):(a.push(t),e.push(Ee(t,!1)))}function Ee(e,t){if(e.g)for(var n in e.g){var r=e.g[n];if(Array.isArray(r))for(var a=0;a<r.length;a++)r[a]&&Ee(r[a],t);else r&&Ee(r,t)}return e.h}function $e(e,t){if(e=e.o){re(t,t.g.end());for(var n=0;n<e.length;n++)re(t,e[n])}}function Ne(e,t){if(4==t.h)return!1;var n=t.m;return X(t),t.N||(t=V(t.g.h,n,t.g.g),(n=e.o)?n.push(t):e.o=[t]),!0}function Ie(e){de.call(this,e,-1,Re)}function Ae(e,t){for(;Z(t);)switch(t.i){case 8:var n=t.g.i();we(e,1,n);break;case 16:we(e,2,n=t.g.i());break;case 29:case 26:te(t,e.getPackedDataList());break;case 32:we(e,4,n=G(t.g));break;default:if(!Ne(e,t))return e}return e}de.prototype.toJSON=function(){return ue(Ee(this,!1),ce,D)},de.prototype.toString=function(){return Ee(this,!1).toString()},f(Ie,de),Ie.prototype.getRows=function(){return ge(this,1)},Ie.prototype.getCols=function(){return ge(this,2)},Ie.prototype.getPackedDataList=function(){return xe(this)},Ie.prototype.getLayout=function(){return be(this,4,0)};var Re=[3];function _e(e,t){var n=void 0;
2return new(n||(n=Promise))(function(r,a){function o(e){try{i(t.next(e))}catch(e){a(e)}}function s(e){try{i(t.throw(e))}catch(e){a(e)}}function i(e){e.done?r(e.value):new n(function(t){t(e.value)}).then(o,s)}i((t=t.apply(e,void 0)).next())})}function Oe(e){de.call(this,e)}function Fe(e,t){for(;Z(t);)switch(t.i){case 8:var n=t.g.i();we(e,1,n);break;case 21:we(e,2,n=Q(t));break;case 26:we(e,3,n=J(t));break;case 34:we(e,4,n=J(t));break;default:if(!Ne(e,t))return e}return e}function De(e){de.call(this,e,-1,Le)}f(Oe,de),f(De,de),De.prototype.addClassification=function(e,t){return ke(this,e,Oe,t),this};var Le=[1];function Me(e){de.call(this,e)}function Pe(e,t){for(;Z(t);)switch(t.i){case 13:var n=Q(t);we(e,1,n);break;case 21:we(e,2,n=Q(t));break;case 29:we(e,3,n=Q(t));break;case 37:we(e,4,n=Q(t));break;case 45:we(e,5,n=Q(t));break;default:if(!Ne(e,t))return e}return e}function Be(e){de.call(this,e,-1,ze)}function Ve(e){e:{var t=new Be;for(e=new Y(e);Z(e);)if(10===e.i){ke(t,q(e,new Me,Pe),Me,void 0)}else if(!Ne(t,e))break e}return t}f(Me,de),f(Be,de);var ze=[1];function Ue(e){de.call(this,e)}function We(e){de.call(this,e,-1,je)}function Ge(e,t){for(;Z(t);)switch(t.i){case 8:var n=G(t.g);we(e,1,n);break;case 16:we(e,2,n=G(t.g));break;case 29:case 26:te(t,e.getVertexBufferList());break;case 32:case 34:n=t;var r=e.getIndexBufferList();2==n.h?ee(n,U.prototype.i,r):r.push(n.g.i());break;default:if(!Ne(e,t))return e}return e}f(Ue,de),f(We,de),We.prototype.getVertexType=function(){return be(this,1,0)},We.prototype.getPrimitiveType=function(){return be(this,2,0)},We.prototype.getVertexBufferList=function(){return xe(this)},We.prototype.getIndexBufferList=function(){return ye(this,4)};var je=[3,4];function Ke(e){de.call(this,e)}function He(e,t,n){if(n=e.createShader(0===n?e.VERTEX_SHADER:e.FRAGMENT_SHADER),e.shaderSource(n,t),e.compileShader(n),!e.getShaderParameter(n,e.COMPILE_STATUS))throw Error("Could not compile WebGL shader.\n\n"+e.getShaderInfoLog(n));return n}function Ye(e){return Se(e,Oe).map(function(e){return{index:be(e,1,0),Y:ve(e,2),label:null!=ge(e,3)?be(e,3,""):void 0,displayName:null!=ge(e,4)?be(e,4,""):void 0}})}function Ze(e){return{x:ve(e,1),y:ve(e,2),z:ve(e,3),visibility:null!=ge(e,4)?ve(e,4):void 0}}function Xe(e,t){this.h=e,this.g=t,this.l=0}function qe(e,t,n){return function(e,t){var n=e.g;if(void 0===e.m){var r=He(n,"\n attribute vec2 aVertex;\n attribute vec2 aTex;\n varying vec2 vTex;\n void main(void) {\n gl_Position = vec4(aVertex, 0.0, 1.0);\n vTex = aTex;\n }",0),a=He(n,"\n precision mediump float;\n varying vec2 vTex;\n uniform sampler2D sampler0;\n void main(){\n gl_FragColor = texture2D(sampler0, vTex);\n }",1),o=n.createProgram();if(n.attachShader(o,r),n.attachShader(o,a),n.linkProgram(o),!n.getProgramParameter(o,n.LINK_STATUS))throw Error("Could not compile WebGL program.\n\n"+n.getProgramInfoLog(o));r=e.m=o,n.useProgram(r),a=n.getUniformLocation(r,"sampler0"),e.j={I:n.getAttribLocation(r,"aVertex"),H:n.getAttribLocation(r,"aTex"),da:a},e.s=n.createBuffer(),n.bindBuffer(n.ARRAY_BUFFER,e.s),n.enableVertexAttribArray(e.j.I),n.vertexAttribPointer(e.j.I,2,n.FLOAT,!1,0,0),n.bufferData(n.ARRAY_BUFFER,new Float32Array([-1,-1,-1,1,1,1,1,-1]),n.STATIC_DRAW),n.bindBuffer(n.ARRAY_BUFFER,null),e.o=n.createBuffer(),n.bindBuffer(n.ARRAY_BUFFER,e.o),n.enableVertexAttribArray(e.j.H),n.vertexAttribPointer(e.j.H,2,n.FLOAT,!1,0,0),n.bufferData(n.ARRAY_BUFFER,new Float32Array([0,1,0,0,1,0,1,1]),n.STATIC_DRAW),n.bindBuffer(n.ARRAY_BUFFER,null),n.uniform1i(a,0)}r=e.j,n.useProgram(e.m),n.canvas.width=t.width,n.canvas.height=t.height,n.viewport(0,0,t.width,t.height),n.activeTexture(n.TEXTURE0),e.h.bindTexture2d(t.glName),n.enableVertexAttribArray(r.I),n.bindBuffer(n.ARRAY_BUFFER,e.s),n.vertexAttribPointer(r.I,2,n.FLOAT,!1,0,0),n.enableVertexAttribArray(r.H),n.bindBuffer(n.ARRAY_BUFFER,e.o),n.vertexAttribPointer(r.H,2,n.FLOAT,!1,0,0),n.bindFramebuffer(n.DRAW_FRAMEBUFFER?n.DRAW_FRAMEBUFFER:n.FRAMEBUFFER,null),n.clearColor(0,0,0,0),n.clear(n.COLOR_BUFFER_BIT),n.colorMask(!0,!0,!0,!0),n.drawArrays(n.TRIANGLE_FAN,0,4),n.disableVertexAttribArray(r.I),n.disableVertexAttribArray(r.H),n.bindBuffer(n.ARRAY_BUFFER,null),e.h.bindTexture2d(0)}(e,t),"function"==typeof e.g.canvas.transferToImageBitmap?Promise.resolve(e.g.canvas.transferToImageBitmap()):n?Promise.resolve(e.g.canvas):"function"==typeof createImageBitmap?createImageBitmap(e.g.canvas):(void 0===e.i&&(e.i=document.createElement("canvas")),new Promise(function(t){e.i.height=e.g.canvas.height,e.i.width=e.g.canvas.width,e.i.getContext("2d",{}).drawImage(e.g.canvas,0,0,e.g.canvas.width,e.g.canvas.height),t(e.i)}))}function Qe(e){this.g=e}f(Ke,de),Ke.prototype.getMesh=function(){return Te(this,We,1)},Ke.prototype.getPoseTransformMatrix=function(){return Te(this,Ie,2)};var Je=new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,10,9,1,7,0,65,0,253,15,26,11]);function et(e,t){return t+e}function tt(e,t){window[e]=t}function nt(e){if(this.g=e,this.listeners={},this.j={},this.F={},this.m={},this.s={},this.G=this.o=this.R=!0,this.C=Promise.resolve(),this.P="",this.B={},this.locateFile=e&&e.locateFile||et,"object"==typeof window)var t=window.location.pathname.toString().substring(0,window.location.pathname.toString().lastIndexOf("/"))+"/";else{if("undefined"==typeof location)throw Error("solutions can only be loaded on a web page or in a web worker");t=location.pathname.toString().substring(0,location.pathname.toString().lastIndexOf("/"))+"/"}if(this.S=t,e.options)for(var n=(t=i(Object.keys(e.options))).next();!n.done;n=t.next()){n=n.value;var r=e.options[n].default;void 0!==r&&(this.j[n]="function"==typeof r?r():r)}}function rt(e){return _e(e,function e(){var t,n,r,a,o,s,i,c,l,p,h,d=this;return S(e,function(e){switch(e.g){case 1:return t=d,d.R?(n=function(e,t){return void 0===e.g.files?[]:"function"==typeof e.g.files?e.g.files(t):e.g.files}(d,d.j),x(e,function(){return _e(this,function e(){return S(e,function(e){switch(e.g){case 1:return e.m=2,x(e,WebAssembly.instantiate(Je),4);case 4:e.g=3,e.m=0;break;case 2:return e.m=0,e.j=null,e.return(!1);case 3:return e.return(!0)}})})}(),2)):e.return();case 2:if(r=e.h,"object"==typeof window)return tt("createMediapipeSolutionsWasm",{locateFile:d.locateFile}),tt("createMediapipeSolutionsPackedAssets",{locateFile:d.locateFile}),s=n.filter(function(e){return void 0!==e.data}),i=n.filter(function(e){return void 0===e.data}),c=Promise.all(s.map(function(e){var n=at(t,e.url);if(void 0!==e.path){var r=e.path;n=n.then(function(e){return t.overrideFile(r,e),Promise.resolve(e)})}return n})),l=Promise.all(i.map(function(e){return void 0===e.simd||e.simd&&r||!e.simd&&!r?function(e){var t=document.createElement("script");return t.setAttribute("src",e),t.setAttribute("crossorigin","anonymous"),new Promise(function(e){t.addEventListener("load",function(){e()},!1),t.addEventListener("error",function(){e()},!1),document.body.appendChild(t)})}(t.locateFile(e.url,t.S)):Promise.resolve()})).then(function(){return _e(t,function e(){var t,n,r=this;return S(e,function(e){if(1==e.g)return t=window.createMediapipeSolutionsWasm,n=window.createMediapipeSolutionsPackedAssets,x(e,t(n),2);r.h=e.h,e.g=0})})}),p=_e(t,function e(){var t=this;return S(e,function(e){return t.g.graph&&t.g.graph.url?e=x(e,at(t,t.g.graph.url),0):(e.g=0,e=void 0),e})}),x(e,Promise.all([l,c,p]),7);if("function"!=typeof importScripts)throw Error("solutions can only be loaded on a web page or in a web worker");return a=n.filter(function(e){return void 0===e.simd||e.simd&&r||!e.simd&&!r}).map(function(e){return t.locateFile(e.url,t.S)}),importScripts.apply(null,u(a)),x(e,createMediapipeSolutionsWasm(Module),6);case 6:d.h=e.h,d.l=new OffscreenCanvas(1,1),d.h.canvas=d.l,o=d.h.GL.createContext(d.l,{antialias:!1,alpha:!1,ba:"undefined"!=typeof WebGL2RenderingContext?2:1}),d.h.GL.makeContextCurrent(o),e.g=4;break;case 7:if(d.l=document.createElement("canvas"),!(h=d.l.getContext("webgl2",{}))&&!(h=d.l.getContext("webgl",{})))return alert("Failed to create WebGL canvas context when passing video frame."),e.return();d.D=h,d.h.canvas=d.l,d.h.createContext(d.l,!0,!0,{});case 4:d.i=new d.h.SolutionWasm,d.R=!1,e.g=0}})})}function at(e,t){return _e(e,function e(){var n,r,a=this;return S(e,function(e){return t in a.F?e.return(a.F[t]):(n=a.locateFile(t,""),r=fetch(n).then(function(e){return e.arrayBuffer()}),a.F[t]=r,e.return(r))})})}function ot(e,t,n){return _e(e,function e(){var r,a,o,s,u,c,l,p,h,d,f,m,g,y,b=this;return S(e,function(e){switch(e.g){case 1:if(!n)return e.return(t);for(r={},a=0,o=i(Object.keys(n)),s=o.next();!s.done;s=o.next())u=s.value,"string"!=typeof(c=n[u])&&"texture"===c.type&&void 0!==t[c.stream]&&++a;1<a&&(b.G=!1),l=i(Object.keys(n)),s=l.next();case 2:if(s.done){e.g=4;break}if(p=s.value,"string"==typeof(h=n[p]))return g=r,y=p,x(e,function(e,t,n){return _e(e,function e(){var r,a=this;return S(e,function(e){return"number"==typeof n||n instanceof Uint8Array||n instanceof a.h.Uint8BlobList?e.return(n):n instanceof a.h.Texture2dDataOut?((r=a.s[t])||(r=new Xe(a.h,a.D),a.s[t]=r),e.return(qe(r,n,a.G))):e.return(void 0)})})}(b,p,t[h]),14);if(d=t[h.stream],"detection_list"===h.type){if(d){for(var v=d.getRectList(),w=d.getLandmarksList(),T=d.getClassificationsList(),C=[],k=0;k<v.size();++k){var E=v.get(k);e:{var $=new Ue;for(E=new Y(E);Z(E);)switch(E.i){case 13:var N=Q(E);we($,1,N);break;case 21:we($,2,N=Q(E));break;case 29:we($,3,N=Q(E));break;case 37:we($,4,N=Q(E));break;case 45:we($,5,N=Q(E));break;case 48:we($,6,N=G(E.g));break;default:if(!Ne($,E))break e}}$={Z:ve($,1),$:ve($,2),height:ve($,3),width:ve($,4),rotation:ve($,5,0),X:be($,6,0
2)},E=Se(Ve(w.get(k)),Me).map(Ze);var I=T.get(k);e:for(N=new De,I=new Y(I);Z(I);)if(10===I.i)N.addClassification(q(I,new Oe,Fe));else if(!Ne(N,I))break e;$={T:$,O:E,M:Ye(N)},C.push($)}v=C}else v=[];r[p]=v,e.g=7;break}if("proto_list"===h.type){if(d){for(v=Array(d.size()),w=0;w<d.size();w++)v[w]=d.get(w);d.delete()}else v=[];r[p]=v,e.g=7;break}if(void 0===d){e.g=3;break}if("float_list"===h.type){r[p]=d,e.g=7;break}if("proto"===h.type){r[p]=d,e.g=7;break}if("texture"!==h.type)throw Error("Unknown output config type: '"+h.type+"'");return(f=b.s[p])||(f=new Xe(b.h,b.D),b.s[p]=f),x(e,qe(f,d,b.G),13);case 13:m=e.h,r[p]=m;case 7:h.transform&&r[p]&&(r[p]=h.transform(r[p])),e.g=3;break;case 14:g[y]=e.h;case 3:s=l.next(),e.g=2;break;case 4:return e.return(r)}})})}function st(e,t){for(var n=t.name||"$",r=[].concat(u(t.wants)),a=new e.h.StringList,o=i(t.wants),s=o.next();!s.done;s=o.next())a.push_back(s.value);o=e.h.PacketListener.implement({onResults:function(a){for(var o={},s=0;s<t.wants.length;++s)o[r[s]]=a.get(s);var i=e.listeners[n];i&&(e.C=ot(e,o,t.outs).then(function(n){n=i(n);for(var a=0;a<t.wants.length;++a){var s=o[r[a]];"object"==typeof s&&s.hasOwnProperty&&s.hasOwnProperty("delete")&&s.delete()}n&&(e.C=n)}))}}),e.i.attachMultiListener(a,o),a.delete()}function it(e){e=function(e){e:{var t=new Ke;for(e=new Y(e);Z(e);)switch(e.i){case 10:var n=q(e,new We,Ge);Ce(t,1,n);break;case 18:Ce(t,2,n=q(e,new Ie,Ae));break;default:if(!Ne(t,e))break e}}return t}(e);var t=e.getMesh();if(!t)return e;var n=new Float32Array(t.getVertexBufferList());t.getVertexBufferList=function(){return n};var r=new Uint32Array(t.getIndexBufferList());return t.getIndexBufferList=function(){return r},e}(e=nt.prototype).close=function(){return this.i&&this.i.delete(),Promise.resolve()},e.reset=function(){return _e(this,function e(){var t=this;return S(e,function(e){t.i&&(t.i.reset(),t.m={},t.s={}),e.g=0})})},e.setOptions=function(e,t){var n=this;if(t=t||this.g.options){for(var r=[],a=[],o={},s=i(Object.keys(e)),u=s.next();!u.done;o={K:o.K,L:o.L},u=s.next()){var c=u.value;c in this.j&&this.j[c]===e[c]||(this.j[c]=e[c],void 0!==(u=t[c])&&(u.onChange&&(o.K=u.onChange,o.L=e[c],r.push(function(e){return function(){return _e(n,function t(){var n=this;return S(t,function(t){if(1==t.g)return x(t,e.K(e.L),2);!0===t.h&&(n.o=!0),t.g=0})})}}(o))),u.graphOptionXref&&(c={valueNumber:1===u.type?e[c]:0,valueBoolean:0===u.type&&e[c],valueString:2===u.type?e[c]:""},u=Object.assign(Object.assign(Object.assign({},{calculatorName:"",calculatorIndex:0}),u.graphOptionXref),c),a.push(u))))}0===r.length&&0===a.length||(this.o=!0,this.A=(void 0===this.A?[]:this.A).concat(a),this.u=(void 0===this.u?[]:this.u).concat(r))}},e.initialize=function(){return _e(this,function e(){var t=this;return S(e,function(e){return 1==e.g?x(e,rt(t),2):3!=e.g?x(e,_e(t,function e(){var t,n,r,a,o,s,u,c,l=this;return S(e,function(e){if(1==e.g)return l.g.graph&&l.g.graph.url&&l.P===l.g.graph.url?e.return():(l.o=!0,l.g.graph&&l.g.graph.url?(l.P=l.g.graph.url,x(e,at(l,l.g.graph.url),3)):void(e.g=2));for(2!=e.g&&(t=e.h,l.i.loadGraph(t)),n=i(Object.keys(l.B)),r=n.next();!r.done;r=n.next())a=r.value,l.i.overrideFile(a,l.B[a]);if(l.B={},l.g.listeners)for(o=i(l.g.listeners),s=o.next();!s.done;s=o.next())u=s.value,st(l,u);c=l.j,l.j={},l.setOptions(c),e.g=0})}),3):x(e,function(e){return _e(e,function e(){var t,n,r,a,o,s,u=this;return S(e,function(e){switch(e.g){case 1:if(!u.o)return e.return();if(!u.u){e.g=2;break}t=i(u.u),n=t.next();case 3:if(n.done){e.g=5;break}return x(e,(0,n.value)(),4);case 4:n=t.next(),e.g=3;break;case 5:u.u=void 0;case 2:if(u.A){for(r=new u.h.GraphOptionChangeRequestList,a=i(u.A),o=a.next();!o.done;o=a.next())s=o.value,r.push_back(s);u.i.changeOptions(r),r.delete(),u.A=void 0}u.o=!1,e.g=0}})})}(t),0)})})},e.overrideFile=function(e,t){this.i?this.i.overrideFile(e,t):this.B[e]=t},e.clearOverriddenFiles=function(){this.B={},this.i&&this.i.clearOverriddenFiles()},e.send=function(e,t){return _e(this,function n(){var r,a,o,s,u,c,l,p,h,d=this;return S(n,function(n){switch(n.g){case 1:return d.g.inputs?(r=1e3*(null==t?performance.now():t),x(n,d.C,2)):n.return();case 2:return x(n,d.initialize(),3);case 3:for(a=new d.h.PacketDataList,o=i(Object.keys(e)),s=o.next();!s.done;
2s=o.next())if(u=s.value,c=d.g.inputs[u]){e:{var f=d,m=e[u];switch(c.type){case"video":var g=f.m[c.stream];if(g||(g=new Xe(f.h,f.D),f.m[c.stream]=g),0===(f=g).l&&(f.l=f.h.createTexture()),"undefined"!=typeof HTMLVideoElement&&m instanceof HTMLVideoElement){var y=m.videoWidth;g=m.videoHeight}else"undefined"!=typeof HTMLImageElement&&m instanceof HTMLImageElement?(y=m.naturalWidth,g=m.naturalHeight):(y=m.width,g=m.height);g={glName:f.l,width:y,height:g},(y=f.g).canvas.width=g.width,y.canvas.height=g.height,y.activeTexture(y.TEXTURE0),f.h.bindTexture2d(f.l),y.texImage2D(y.TEXTURE_2D,0,y.RGBA,y.RGBA,y.UNSIGNED_BYTE,m),f.h.bindTexture2d(0),f=g;break e;case"detections":for((g=f.m[c.stream])||(g=new Qe(f.h),f.m[c.stream]=g),(f=g).data||(f.data=new f.g.DetectionListData),f.data.reset(m.length),g=0;g<m.length;++g){y=m[g];var b=f.data,v=b.setBoundingBox,w=g,T=y.T,S=new Ue;we(S,1,T.Z),we(S,2,T.$),we(S,3,T.height),we(S,4,T.width),we(S,5,T.rotation),we(S,6,T.X);var C=T=new ne;oe(C,1,ge(S,1)),oe(C,2,ge(S,2)),oe(C,3,ge(S,3)),oe(C,4,ge(S,4)),oe(C,5,ge(S,5));var k=ge(S,6);if(null!=k&&null!=k){H(C.g,48);var E=C.g,$=k;k=0>$;var N=($=Math.abs($))>>>0;for($=Math.floor(($-N)/4294967296),$>>>=0,k&&($=~$>>>0,4294967295<(N=(~N>>>0)+1)&&(N=0,4294967295<++$&&($=0))),k=z=N,N=$;0<N||127<k;)E.push(127&k|128),k=(k>>>7|N<<25)>>>0,N>>>=7;E.push(k)}if($e(S,C),T=ae(T),v.call(b,w,T),y.O)for(b=0;b<y.O.length;++b)C=!!(S=y.O[b]).visibility,w=(v=f.data).addNormalizedLandmark,T=g,S=Object.assign(Object.assign({},S),{visibility:C?S.visibility:0}),we(C=new Me,1,S.x),we(C,2,S.y),we(C,3,S.z),S.visibility&&we(C,4,S.visibility),oe(E=S=new ne,1,ge(C,1)),oe(E,2,ge(C,2)),oe(E,3,ge(C,3)),oe(E,4,ge(C,4)),oe(E,5,ge(C,5)),$e(C,E),S=ae(S),w.call(v,T,S);if(y.M)for(b=0;b<y.M.length;++b){if(w=(v=f.data).addClassification,T=g,S=y.M[b],we(C=new Oe,2,S.Y),S.index&&we(C,1,S.index),S.label&&we(C,3,S.label),S.displayName&&we(C,4,S.displayName),E=S=new ne,null!=(N=ge(C,1))&&null!=N)if(H(E.g,8),k=E.g,0<=N)H(k,N);else{for($=0;9>$;$++)k.push(127&N|128),N>>=7;k.push(1)}oe(E,2,ge(C,2)),null!=(k=ge(C,3))&&(k=_(k),H(E.g,26),H(E.g,k.length),re(E,E.g.end()),re(E,k)),null!=(k=ge(C,4))&&(k=_(k),H(E.g,34),H(E.g,k.length),re(E,E.g.end()),re(E,k)),$e(C,E),S=ae(S),w.call(v,T,S)}}f=f.data;break e;default:f={}}}switch(l=f,p=c.stream,c.type){case"video":a.pushTexture2d(Object.assign(Object.assign({},l),{stream:p,timestamp:r}));break;case"detections":(h=l).stream=p,h.timestamp=r,a.pushDetectionList(h);break;default:throw Error("Unknown input config type: '"+c.type+"'")}}return d.i.send(a),x(n,d.C,4);case 4:a.delete(),n.g=0}})})},e.onResults=function(e,t){this.listeners[t||"$"]=e},E("Solution",nt),E("OptionType",{BOOL:0,NUMBER:1,aa:2,0:"BOOL",1:"NUMBER",2:"STRING"});var ut={files:[{url:"face_mesh_solution_packed_assets_loader.js"},{simd:!0,url:"face_mesh_solution_simd_wasm_bin.js"},{simd:!1,url:"face_mesh_solution_wasm_bin.js"}],graph:{url:"face_mesh.binarypb"},listeners:[{wants:["multi_face_geometry","image_transformed","multi_face_landmarks"],outs:{image:"image_transformed",multiFaceGeometry:{type:"proto_list",stream:"multi_face_geometry",transform:function(e){return e.map(it)}},multiFaceLandmarks:{type:"proto_list",stream:"multi_face_landmarks",transform:function(e){return e.map(function(e){return Se(Ve(e),Me).map(Ze)})}}}}],inputs:{image:{type:"video",stream:"input_frames_gpu"}},options:{useCpuInference:{type:0,graphOptionXref:{calculatorType:"InferenceCalculator",fieldName:"use_cpu_inference"},default:"iPad Simulator;iPhone Simulator;iPod Simulator;iPad;iPhone;iPod".split(";").includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document},enableFaceGeometry:{type:0,graphOptionXref:{calculatorName:"EnableFaceGeometryConstant",calculatorType:"ConstantSidePacketCalculator",fieldName:"bool_value"}},selfieMode:{type:0,graphOptionXref:{calculatorType:"GlScalerCalculator",calculatorIndex:1,fieldName:"flip_horizontal"}},maxNumFaces:{type:1,graphOptionXref:{calculatorType:"ConstantSidePacketCalculator",calculatorName:"ConstantSidePacketCalculatorNumFaces",fieldName:"int_value"}},refineLandmarks:{type:0,graphOptionXref:{calculatorType:"ConstantSidePacketCalculator",calculatorName:"ConstantSidePacketCalculatorRefineLandmarks",fieldName:"bool_value"}},minDetectionConfidence:{type:1,graphOptionXref:{calculatorType:"TensorsToDetectionsCalculator",calculatorName:"facelandmarkfrontgpu__facedetectionshortrangegpu__facedetectionshortrangecommon__TensorsToDetectionsCalculator",fieldName:"min_score_thresh"}},minTrackingConfidence:{type:1,graphOptionXref:{calculatorType:"ThresholdingCalculator",calculatorName:"facelandmarkfrontgpu__facelandmarkgpu__ThresholdingCalculator",fieldName:"threshold"}},cameraNear:{type:1,graphOptionXref:{calculatorType:"FaceGeometryEnvGeneratorCalculator",fieldName:"near"}},cameraFar:{type:1,graphOptionXref:{calculatorType:"FaceGeometryEnvGeneratorCalculator",fieldName:"far"}},cameraVerticalFovDegrees:{type:1,graphOptionXref:{calculatorType:"FaceGeometryEnvGeneratorCalculator",fieldName:"vertical_fov_degrees"}}}},ct=[[61,146],[146,91],[91,181],[181,84],[84,17],[17,314],[314,405],[405,321],[321,375],[375,291],[61,185],[185,40],[40,39],[39,37],[37,0],[0,267],[267,269],[269,270],[270,409],[409,291],[78,95],[95,88],[88,178],[178,87],[87,14],[14,317],[317,402],[402,318],[318,324],[324,308],[78,191],[191,80],[80,81],[81,82],[82,13],[13,312],[312,311],[311,310],[310,415],[415,308]],lt=[[263,249],[249,390],[390,373],[373,374],[374,380],[380,381],[381,382],[382,362],[263,466],[466,388],[388,387],[387,386],[386,385],[385,384],[384,398],[398,362]],pt=[[276,283],[283,282],[282,295],[295,285],[300,293],[293,334],[334,296],[296,336]],ht=[[33,7],[7,163],[163,144],[144,145],[145,153],[153,154],[154,155],[155,133],[33,246],[246,161],[161,160],[160,159],[159,158],[158,157],[157,173],[173,133]],dt=[[46,53],[53,52],[52,65],[65,55],[70,63],[63,105],[105,66],[66,107]],ft=[[10,338],[338,297],[297,332],[332,284],[284,251],[251,389],[389,356],[356,454],[454,323],[323,3
261],[361,288],[288,397],[397,365],[365,379],[379,378],[378,400],[400,377],[377,152],[152,148],[148,176],[176,149],[149,150],[150,136],[136,172],[172,58],[58,132],[132,93],[93,234],[234,127],[127,162],[162,21],[21,54],[54,103],[103,67],[67,109],[109,10]],mt=[].concat(u(ct),u(lt),u(pt),u(ht),u(dt),u(ft));function gt(e){e=e||{},e=Object.assign(Object.assign({},ut),e),this.g=new nt(e)}(e=gt.prototype).close=function(){return this.g.close(),Promise.resolve()},e.onResults=function(e){this.g.onResults(e)},e.initialize=function(){return _e(this,function e(){var t=this;return S(e,function(e){return x(e,t.g.initialize(),0)})})},e.reset=function(){this.g.reset()},e.send=function(e){return _e(this,function t(){var n=this;return S(t,function(t){return x(t,n.g.send(e),0)})})},e.setOptions=function(e){this.g.setOptions(e)},E("FACE_GEOMETRY",{Layout:{COLUMN_MAJOR:0,ROW_MAJOR:1,0:"COLUMN_MAJOR",1:"ROW_MAJOR"},PrimitiveType:{TRIANGLE:0,0:"TRIANGLE"},VertexType:{VERTEX_PT:0,0:"VERTEX_PT"},DEFAULT_CAMERA_PARAMS:{verticalFovDegrees:63,near:1,far:1e4}}),E("FaceMesh",gt),E("FACEMESH_LIPS",ct),E("FACEMESH_LEFT_EYE",lt),E("FACEMESH_LEFT_EYEBROW",pt),E("FACEMESH_LEFT_IRIS",[[474,475],[475,476],[476,477],[477,474]]),E("FACEMESH_RIGHT_EYE",ht),E("FACEMESH_RIGHT_EYEBROW",dt),E("FACEMESH_RIGHT_IRIS",[[469,470],[470,471],[471,472],[472,469]]),E("FACEMESH_FACE_OVAL",ft),E("FACEMESH_CONTOURS",mt),E
vendor: 24,372 bytes, line 2
2("FACEMESH_TESSELATION",[[127,34],[34,139],[139,127],[11,0],[0,37],[37,11],[232,231],[231,120],[120,232],[72,37],[37,39],[39,72],[128,121],[121,47],[47,128],[232,121],[121,128],[128,232],[104,69],[69,67],[67,104],[175,171],[171,148],[148,175],[118,50],[50,101],[101,118],[73,39],[39,40],[40,73],[9,151],[151,108],[108,9],[48,115],[115,131],[131,48],[194,204],[204,211],[211,194],[74,40],[40,185],[185,74],[80,42],[42,183],[183,80],[40,92],[92,186],[186,40],[230,229],[229,118],[118,230],[202,212],[212,214],[214,202],[83,18],[18,17],[17,83],[76,61],[61,146],[146,76],[160,29],[29,30],[30,160],[56,157],[157,173],[173,56],[106,204],[204,194],[194,106],[135,214],[214,192],[192,135],[203,165],[165,98],[98,203],[21,71],[71,68],[68,21],[51,45],[45,4],[4,51],[144,24],[24,23],[23,144],[77,146],[146,91],[91,77],[205,50],[50,187],[187,205],[201,200],[200,18],[18,201],[91,106],[106,182],[182,91],[90,91],[91,181],[181,90],[85,84],[84,17],[17,85],[206,203],[203,36],[36,206],[148,171],[171,140],[140,148],[92,40],[40,39],[39,92],[193,189],[189,244],[244,193],[159,158],[158,28],[28,159],[247,246],[246,161],[161,247],[236,3],[3,196],[196,236],[54,68],[68,104],[104,54],[193,168],[168,8],[8,193],[117,228],[228,31],[31,117],[189,193],[193,55],[55,189],[98,97],[97,99],[99,98],[126,47],[47,100],[100,126],[166,79],[79,218],[218,166],[155,154],[154,26],[26,155],[209,49],[49,131],[131,209],[135,136],[136,150],[150,135],[47,126],[126,217],[217,47],[223,52],[52,53],[53,223],[45,51],[51,134],[134,45],[211,170],[170,140],[140,211],[67,69],[69,108],[108,67],[43,106],[106,91],[91,43],[230,119],[119,120],[120,230],[226,130],[130,247],[247,226],[63,53],[53,52],[52,63],[238,20],[20,242],[242,238],[46,70],[70,156],[156,46],[78,62],[62,96],[96,78],[46,53],[53,63],[63,46],[143,34],[34,227],[227,143],[123,117],[117,111],[111,123],[44,125],[125,19],[19,44],[236,134],[134,51],[51,236],[216,206],[206,205],[205,216],[154,153],[153,22],[22,154],[39,37],[37,167],[167,39],[200,201],[201,208],[208,200],[36,142],[142,100],[100,36],[57,212],[212,202],[202,57],[20,60],[60,99],[99,20],[28,158],[158,157],[157,28],[35,226],[226,113],[113,35],[160,159],[159,27],[27,160],[204,202],[202,210],[210,204],[113,225],[225,46],[46,113],[43,202],[202,204],[204,43],[62,76],[76,77],[77,62],[137,123],[123,116],[116,137],[41,38],[38,72],[72,41],[203,129],[129,142],[142,203],[64,98],[98,240],[240,64],[49,102],[102,64],[64,49],[41,73],[73,74],[74,41],[212,216],[216,207],[207,212],[42,74],[74,184],[184,42],[169,170],[170,211],[211,169],[170,149],[149,176],[176,170],[105,66],[66,69],[69,105],[122,6],[6,168],[168,122],[123,147],[147,187],[187,123],[96,77],[77,90],[90,96],[65,55],[55,107],[107,65],[89,90],[90,180],[180,89],[101,100],[100,120],[120,101],[63,105],[105,104],[104,63],[93,137],[137,227],[227,93],[15,86],[86,85],[85,15],[129,102],[102,49],[49,129],[14,87],[87,86],[86,14],[55,8],[8,9],[9,55],[100,47],[47,121],[121,100],[145,23],[23,22],[22,145],[88,89],[89,179],[179,88],[6,122],[122,196],[196,6],[88,95],[95,96],[96,88],[138,172],[172,136],[136,138],[215,58],[58,172],[172,215],[115,48],[48,219],[219,115],[42,80],[80,81],[81,42],[195,3],[3,51],[51,195],[43,146],[146,61],[61,43],[171,175],[175,199],[199,171],[81,82],[82,38],[38,81],[53,46],[46,225],[225,53],[144,163],[163,110],[110,144],[52,65],[65,66],[66,52],[229,228],[228,117],[117,229],[34,127],[127,234],[234,34],[107,108],[108,69],[69,107],[109,108],[108,151],[151,109],[48,64],[64,235],[235,48],[62,78],[78,191],[191,62],[129,209],[209,126],[126,129],[111,35],[35,143],[143,111],[117,123],[123,50],[50,117],[222,65],[65,52],[52,222],[19,125],[125,141],[141,19],[221,55],[55,65],[65,221],[3,195],[195,197],[197,3],[25,7],[7,33],[33,25],[220,237],[237,44],[44,220],[70,71],[71,139],[139,70],[122,193],[193,245],[245,122],[247,130],[130,33],[33,247],[71,21],[21,162],[162,71],[170,169],[169,150],[150,170],[188,174],[174,196],[196,188],[216,186],[186,92],[92,216],[2,97],[97,167],[167,2],[141,125],[125,241],[241,141],[164,167],[167,37],[37,164],[72,38],[38,12],[12,72],[38,82],[82,13],[13,38],[63,68],[68,71],[71,63],[226,35],[35,111],[111,226],[101,50],[50,205],[205,101],[206,92],[92,165],[165,206],[209,198],[198,217],[217,209],[165,167],[167,97],[97,165],[220,115],[115,218],[218,220],[133,112],[112,243],[243,133],[239,238],[238,241],[241,239],[214,135],[135,169],[169,214],[190,173],[173,133],[133,190],[171,208],[208,32],[32,171],[125,44],[44,237],[237,125],[86,87],[87,178],[178,86],[85,86],[86,179],[179,85],[84,85],[85,180],[180,84],[83,84],[84,181],[181,83],[201,83],[83,182],[182,201],[137,93],[93,132],[132,137],[76,62],[62,183],[183,76],[61,76],[76,184],[184,61],[57,61],[61,185],[185,57],[212,57],[57,186],[186,212],[214,207],[207,187],[187,214],[34,143],[143,156],[156,34],[79,239],[239,237],[237,79],[123,137],[137,177],[177,123],[44,1],[1,4],[4,44],[201,194],[194,32],[32,201],[64,102],[102,129],[129,64],[213,215],[215,138],[138,213],[59,166],[166,219],[219,59],[242,99],[99,97],[97,242],[2,94],[94,141],[141,2],[75,59],[59,235],[235,75],[24,110],[110,228],[228,24],[25,130],[130,226],[226,25],[23,24],[24,229],[229,23],[22,23],[23,230],[230,22],[26,22],[22,231],[231,26],[112,26],[26,232],[232,112],[189,190],[190,243],[243,189],[221,56],[56,190],[190,221],[28,56],[56,221],[221,28],[27,28],[28,222],[222,27],[29,27],[27,223],[223,29],[30,29],[29,224],[224,30],[247,30],[30,225],[225,247],[238,79],[79,20],[20,238],[166,59],[59,75],[75,166],[60,75],[75,240],[240,60],[147,177],[177,215],[215,147],[20,79],[79,166],[166,20],[187,147],[147,213],[213,187],[112,233],[233,244],[244,112],[233,128],[128,245],[245,233],[128,114],[114,188],[188,128],[114,217],[217,174],[174,114],[131,115],[115,220],[220,131],[217,198],[198,236],[236,217],[198,131],[131,134],[134,198],[177,132],[132,58],[58,177],[143,35],[35,124],[124,143],[110,163],[163,7],[7,110],[228,110],[110,25],[25,228],[356,389],[389,368],[368,356],[11,302],[302,267],[267,11],[452,350],[350,349],[349,452],[302,303],[303,269],[269,302],[357,343],[343,277],[277,357],[452,453],[453,357],[357,452],[333,332],[332,297],[297,333],[175,152],[152,377],[377,175],[347,348],[348,330],[330,347],[303,304],[304,270],[270,303],[9,336],[336,337],[337,9],[278,279],[279,360],[360,278],[418,262],[262,431],[431,418],[304,408],[408,409],[409,304],[310,415],[415,407],[407,310],[270,409],[409,410],[410,270],[450,348],[348,347],[347,450],[422,430],[430,434],[434,422],[313,314],[314,17],[17,313],[306,307],[307,375],[375,306],[387,388],[388,260],[260,387],[286,414],[414,398],[398,286],[335,406],[406,418],[418,335],[364,367],[367,416],[416,364],[423,358],[358,327],[327,423],[251,284],[284,298],[298,251],[281,5],[5,4],[4,281],[373,374],[374,253],[253,373],[307,320],[320,321],[321,307],[425,427],[427,411],[411,425],[421,313],[313,18],[18,421],[321,405],[405,406],[406,321],[320,404],[404,405],[405,320],[315,16],[16,17],[17,315],[426,425],[425,266],[266,426],[377,400],[400,369],[369,377],[322,391],[391,269],[269,322],[417,465],[465,464],[464,417],[386,257],[257,258],[258,386],[466,260],[260,388],[388,466],[456,399],[399,419],[419,456],[284,332],[332,333],[333,284],[417,285],[285,8],[8,417],[346,340],[340,261],[261,346],[413,441],[441,285],[285,413],[327,460],[460,328],[328,327],[355,371],[371,329],[329,355],[392,439],[439,438],[438,392],[382,341],[341,256],[256,382],[429,420],[420,360],[360,429],[364,394],[394,379],[379,364],[277,343],[343,437],[437,277],[443,444],[444,283],[283,443],[275,440],[440,363],[363,275],[431,262],[262,369],[369,431],[297,338],[338,337],[337,297],[273,375],[375,321],[321,273],[450,451],[451,349],[349,450],[446,342],[342,467],[467,446],[293,334],[334,282],[282,293],[458,461],[461,462],[462,458],[276,353],[353,383],[383,276],[308,324],[324,325],[325,308],[276,300],[300,293],[293,276],[372,345],[345,447],[447,372],[352,345],[345,340],[340,352],[274,1],[1,19],[19,274],[456,248],[248,281],[281,456],[436,427],[427,425],[425,436],[381,256],[256,252],[252,381],[269,391],[391,393],[393,269],[200,199],[199,428],[428,200],[266,330],[330,329],[329,266],[287,273],[273,422],[422,287],[250,462],[462,328],[328,250],[258,286],[286,384],[384,258],[265,353],[353,342],[342,265],[387,259],[259,257],[257,387],[424,431],[431,430],[430,424],[342,353],[353,276],[276,342],[273,335],[335,424],[424,273],[292,325],[325,307],[307,292],[366,447],[447,345],[345,366],[271,303],[303,302],[302,271],[423,266],[266,371],[371,423],[294,455],[455,460],[460,294],[279,278],[278,294],[294,279],[271,272],[272,304],[304,271],[432,434],[434,427],[427,432],[272,407],[407,408],[408,272],[394,430],[430,431],[431,394],[395,369],[369,400],[400,395],[334,333],[333,299],[299,334],[351,417],[417,168],[168,351],[352,280],[280,411],[411,352],[325,319],[319,320],[320,325],[295,296],[296,336],[336,295],[319,403],[403,404],[404,319],[330,348],[348,349],[349,330],[293,298],[298,333],[333,293],[323,454],[454,447],[447,323],[15,16],[16,315],[315,15],[358,429],[429,279],[279,358],[14,15],[15,316],[316,14],[285,336],[336,9],[9,285],[329,349],[349,350],[350,329],[374,380],[380,252],[252,374],[318,402],[402,403],[403,318],[6,197],[197,419],[419,6],[318,319],[319,325],[325,318],[367,364],[364,365],[365,367],[435,367],[367,397],[397,435],[344,438],[438,439],[439,344],[272,271],[271,311],[311,272],[195,5],[5,281],[281,195],[273,287],[287,291],[291,273],[396,428],[428,199],[199,396],[311,271],[271,268],[268,311],[283,444],[444,445],[445,283],[373,254],[254,339],[339,373],[282,334],[334,296],[296,282],[449,347],[347,346],[346,449],[264,447],[447,454],[454,264],[336,296],[296,299],[299,336],[338,10],[10,151],[151,338],[278,439],[439,455],[455,278],[292,407],[407,415],[415,292],[358,371],[371,355],[355,358],[340,345],[345,372],[372,340],[346,347],[347,280],[280,346],[442,443],[443,282],[282,442],[19,94],[94,370],[370,19],[441,442],[442,295],[295,441],[248,419],[419,197],[197,248],[263,255],[255,359],[359,263],[440,275],[275,274],[274,440],[300,383],[383,368],[368,300],[351,412],[412,465],[465,351],[263,467],[467,466],[466,263],[301,368],[368,389],[389,301],[395,378],[378,379],[379,395],[412,351],[351,419],[419,412],[436,426],[426,322],[322,436],[2,164],[164,393],[393,2],[370,462],[462,461],[461,370],[164,0],[0,267],[267,164],[302,11],[11,12],[12,302],[268,12],[12,13],[13,268],[293,300],[300,301],[301,293],[446,261],[261,340],[340,446],[330,266],[266,425],[425,330],[426,423],[423,391],[391,426],[429,355],[355,437],[437,429],[391,327],[327,326],[326,391],[440,457],[457,438],[438,440],[341,382],[382,362],[362,341],[459,457],[457,461],[461,459],[434,430],[430,394],[394,434],[414,463],[463,362],[362,414],[396,369],[369,262],[262,396],[354,461],[461,457],[457,354],[316,403],[403,402],[402,316],[315,404],[404,403],[403,315],[314,405],[405,404],[404,314],[313,406],[406,405],[405,313],[421,418],[418,406],[406,421],[366,401],[401,361],[361,366],[306,408],[408,407],[407,306],[291,409],[409,408],[408,291],[287,410],[410,409],[409,287],[432,436],[436,410],[410,432],[434,416],[416,411],[411,434],[264,368],[368,383],[383,264],[309,438],[438,457],[457,309],[352,376],[376,401],[401,352],[274,275],[275,4],[4,274],[421,428],[428,262],[262,421],[294,327],[327,358],[358,294],[433,416],[416,367],[367,433],[289,455],[455,439],[439,289],[462,370],[370,326],[326,462],[2,326],[326,370],[370,2],[305,460],[460,455],[455,305],[254,449],[449,448],[448,254],[255,261],[261,446],[446,255],[253,450],[450,449],[449,253],[252,451],[451,450],[450,252],[256,452],[452,451],[451,256],[341,453],[453,452],[452,341],[413,464],[464,463],[463,413],[441,413],[413,414],[414,441],[258,442],[442,441],[441,258],[257,443],[443,442],[442,257],[259,444],[444,443],[443,259],[260,445],[445,444],[444,260],[467,342],[342,445],[445,467],[459,458],[458,250],[250,459],[289,392],[392,290],[290,289],[290,328],[328,460],[460,290],[376,433],[433,435],[435,376],[250,290],[290,392],[392,250],[411,416],[416,433],[433,411],[341,463],[463,464],[464,341],[453,464],[464,465],[465,453],[357,465],[465,412],[412,357],[343,412],[412,399],[399,343],[360,363],[363,440],[440,360],[437,399],[399,456],[456,437],[420,456],[456,363],[363,420],[401,435],[435,288],[288,401],[372,383],[383,353],[353,372],[339,255],[255,249],[249,339],[448,261],[261,255],[255,448],[133,243],[243,190],[190,133],[133,155],[155,112],[112,133],[33,246],[246,247],[247,33],[33,130],[130,25],[25,33],[398,384],[384,286],[286,398],[362,398],[398,414],[414,362],[362,463],[463,341],[341,362],[263,359],[359,467],[467,263],[263,249],[249,255],[255,263],[466,467],[467,260],[260,466],[75,60],[60,166],[166,75],[238,239],[239,79],[79,238],[162,127],[127,139],[139,162],[72,11],[11,37],[37,72],[121,232],[232,120],[120,121],[73,72],[72,39],[39,73],[114,128],[128,47],[47,114],[233,232],[232,128],[128,233],[103,104],[104,67],[67,103],[152,175],[175,148],[148,152],[119,118],[118,101],[101,119],[74,73],[73,40],[40,74],[107,9],[9,108],[108,107],[49,48],[48,131],[131,49],[32,194],[194,211],[211,32],[184,74],[74,185],[185,184],[191,80],[80,183],[183,191],[185,40],[40,186],[186,185],[119,230],[230,118],[118,119],[210,202],[202,214],[214,210],[84,83],[83,17],[17,84],[77,76],[76,146],[146,77],[161,160],[160,30],[30,161],[190,56],[56,173],[173,190],[182,106],[106,194],[194,182],[138,135],[135,192],[192,138],[129,203],[203,98],[98,129],[54,21],[21,68],[68,54],[5,51],[51,4],[4,5],[145,144],[144,23],[23,145],[90,77],[77,91],[91,90],[207,205],[205,187],[187,207],[83,201],[201,18],[18,83],[181,91],[91,182],[182,181],[180,90],[90,181],[181,180],[16,85],[85,17],[17,16],[205,206],[206,36],[36,205],[176,148],[148,140],[140,176],[165,92],[92,39],[39,165],[245,193],[193,244],[244,245],[27,159],[159,28],[28,27],[30,247],[247,161],[161,30],[174,236],[236,196],[196,174],[103,54],[54,104],[104,103],[55,193],[193,8],[8,55],[111,117],[117,31],[31,111],[221,189],[189,55],[55,221],[240,98],[98,99],[99,240],[142,126],[126,100],[100,142],[219,166],[166,218],[218,219],[112,155],[155,26],[26,112],[198,209],[209,131],[131,198],[169,135],[135,150],[150,169],[114,47],[47,217],[217,114],[224,223],[223,53],[53,224],[220,45],[45,134],[134,220],[32,211],[211,140],[140,32],[109,67],[67,108],[108,109],[146,43],[43,91],[91,146],[231,230],[230,120],[120,231],[113,226],[226,247],[247,113],[105,63],[63,52],[52,105],[241,238],[238,242],[242,241],[124,46],[46,156],[156,124],[95,78],[78,96],[96,95],[70,46],[46,63],[63,70],[116,143],[143,227],[227,116],[116,123],[123,111],[111,116],[1,44],[44,19],[19,1],[3,236],[236,51],[51,3],[207,216],[216,205],[205,207],[26,154],[154,22],[22,26],[165,39],[39,167],[167,165],[199,200],[200,208],[208,199],[101,36],[36,100],[100,101],[43,57],[57,202],[202,43],[242,20],[20,99],[99,242],[56,28],[28,157],[157,56],[124,35],[35,113],[113,124],[29,160],[160,27],[27,29],[211,204],[204,210],[210,211],[124,113],[113,46],[46,124],[106,43],[43,204],[204,106],[96,62],[62,77],[77,96],[227,137],[137,116],[116,227],[73,41],[41,72],[72,73],[36,203],[203,142],[142,36],[235,64],[64,240],[240,235],[48,49],[49,64],[64,48],[42,41],[41,74],[74,42],[214,212],[212,207],[207,214],[183,42],[42,184],[184,183],[210,169],[169,211],[211,210],[140,170],[170,176],[176,140],[104,105],[105,69],[69,104],[193,122],[122,168],[168,193],[50,123],[123,187],[187,50],[89,96],[96,90],[90,89],[66,65],[65,107],[107,66],[179,89],[89,180],[180,179],[119,101],[101,120],[120,119],[68,63],[63,104],[104,68],[234,93],[93,227],[227,234],[16,15],[15,85],[85,16],[209,129],[129,49],[49,209],[15,14],[14,86],[86,15],[107,55],[55,9],[9,107],[120,100],[100,121],[121,120],[153,145],[145,22],[22,153],[178,88],[88,179],[179,178],[197,6],[6,196],[196,197],[89,88],[88,96],[96,89],[135,138],[138,136],[136,135],[138,215],[215,172],[172,138],[218,115],[115,219],[219,218],[41,42],[42,81],[81,41],[5,195],[195,51],[51,5],[57,43],[43,61],[61,57],[208,171],[171,199],[199,208],[41,81],[81,38],[38,41],[224,53],[53,225],[225,224],[24,144],[144,110],[110,24],[105,52],[52,66],[66,105],[118,229],[229,117],[117,118],[227,34],[34,234],[234,227],[66,107],[107,69],[69,66],[10,109],[109,151],[151,10],[219,48],[48,235],[235,219],[183,62],[62,191],[191,183],[142,129],[129,126],[126,142],[116,111],[111,143],[143,116],[118,117],[117,50],[50,118],[223,222],[222,52],[52,223],[94,19],[19,141],[141,94],[222,221],[221,65],[65,222],[196,3],[3,197],[197,196],[45,220],[220,44],[44,45],[156,70],[70,139],[139,156],[188,122],[122,245],[245,188],[139,71],[71,162],[162,139],[149,170],[170,150],[150,149],[122,188],[188,196],[196,122],[206,216],[216,92],[92,206],[164,2],[2,167],[167,164],[242,141],[141,241],[241,242],[0,164],[164,37],[37,0],[11,72],[72,12],[12,11],[12,38],[38,13],[13,12],[70,63],[63,71],[71,70],[31,226],[226,111],[111,31],[36,101],[101,205],[205,36],[203,206],[206,165],[165,203],[126,209],[209,217],[217,126],[98,165],[165,97],[97,98],[237,220],[220,218],[218,237],[237,239],[239,241],[241,237],[210,214],[214,169],[169,210],[140,171],[171,32],[32,140],[241,125],[125,237],[237,241],[179,86],[86,178],[178,179],[180,85],[85,179],[179,180],[181,84],[84,180],[180,181],[182,83],[83,181],[181,182],[194,201],[201,182],[182,194],[177,137],[137,132],[132,177],[184,76],[76,183],[183,184],[185,61],[61,184],[184,185],[186,57],[57,185],[185,186],[216,212],[212,186],[186,216],[192,214],[214,187],[187,192],[139,34],[34,156],[156,139],[218,79],[79,237],[237,218],[147,123],[123,177],[177,147],[45,44],[44,4],[4,45],[208,201],[201,32],[32,208],[98,64],[64,129],[129,98],[192,213],[213,138],[138,192],[235,59],[59,219],[219,235],[141,242],[242,97],[97,141],[97,2],[2,141],[141,97],[240,75],[75,235],[235,240],[229,24],[24,228],[228,229],[31,25],[25,226],[226,31],[230,23],[23,229],[229,230],[231,22],[22,230],[230,231],[232,26],[26,231],[231,232],[233,112],[112,232],[232,233],[244,189],[189,243],[243,244],[189,221],[221,190],[190,189],[222,28],[28,221],[221,222],[223,27],[27,222],[222,223],[224,29],[29,223],[223,224],[225,30],[30,224],[224,225],[113,247],[247,225],[225,113],[99,60],[60,240],[240,99],[213,147],[147,215],[215,213],[60,20],[20,166],[166,60],[192,187],[187,213],[213,192],[243,112],[112,244],[244,243],[244,233],[233,245],[245,244],[245,128],[128,188],[188,245],[188,114],[114,174],[174,188],[134,131],[131,220],[220,134],[174,217],[217,236],[236,174],[236,198],[198,134],[134,236],[215,177],[177,58],[58,215],[156,143],[143,124],[124,156],[25,110],[110,7],[7,25],[31,228],[228,25],[25,31],[264,356],[356,368],[368,264],[0,11],[11,267],[267,0],[451,452],[452,349],[349,451],[267,302],[302,269],[269,267],[350,357],[357,277],[277,350],[350,452],[452,357],[357,350],[299,333],[333,297],[297,299],[396,175],[175,377],[377,396],[280,347],[347,330],[330,280],[269,303],[303,270],[270,269],[151,9],[9,337],[337,151],[344,278],[278,360],[360,344],[424,418],[418,431],[431,424],[270,304],[304,409],[409,270],[272,310],[310,407],[407,272],[322,270],[270,410],[410,322],[449,450],[450,347],[347,449],[432,422],[422,434],[434,432],[18,313],[313,17],[17,18],[291,306],[306,375],[375,291],[259,387],[387,260],[260,259],[424,335],[335,418],[418,424],[434,364],[364,416],[416,434],[391,423],[423,327],[327,391],[301,251],[251,298],[298,301],[275,281],[281,4],[4,275],[254,373],[373,253],[253,254],[375,307],[307,321],[321,375],[280,425],[425,411],[411,280],[200,421],[421,18],[18,200],[335,321],[321,406],[406,335],[321,320],[320,405],[405,321],[314,315],[315,17],[17,314],[423,426],[426,266],[266,423],[396,377],[377,369],[369,396],[270,322],[322,269],[269,270],[413,417],[417,464],[464,413],[385,386],[386,258],[258,385],[248,456],[456,419],[419,248],[298,284],[284,333],[333,298],[168,417],[417,8],[8,168],[448,346],[346,261],[261,448],[417,413],[413,285],[285,417],[326,327],[327,328],[328,326],[277,355],[355,329],[329,277],[309,392],[392,438],[438,309],[381,382],[382,256],[256,381],[279,429],[429,360],[360,279],[365,364],[364,379],[379,365],[355,277],[277,437],[437,355],[282,443],[443,283],[283,282],[281,275],[275,363],[363,281],[395,431],[431,369],[369,395],[299,297],[297,337],[337,299],[335,273],[273,321],[321,335],[348,450],[450,349],[349,348],[359,446],[446,467],[467,359],[283,293],[293,282],[282,283],[250,458],[458,462],[462,250],[300,276],[276,383],[383,300],[292,308],[308,325],[325,292],[283,276],[276,293],[293,283],[264,372],[372,447],[447,264],[346,352],[352,340],[340,346],[354,274],[274,19],[19,354],[363,456],[456,281],[281,363],[426,436],[436,425],[425,426],[380,381],[381,252],[252,380],[267,269],[269,393],[393,267],[421,200],[200,428],[428,421],[371,266],[266,329],[329,371],[432,287],[287,422],[422,432],[290,250],[250,328],[328,290],[385,258],[258,384],[384,385],[446,265],[265,342],[342,446],[386,387],[387,257],[257,386],[422,424],[424,430],[430,422],[445,342],[342,276],[276,445],[422,273],[273,424],[424,422],[306,292],[292,307],[307,306],[352,366],[366,345],[345,352],[268,271],[271,302],[302,268],[358,423],[423,371],[371,358],[327,294],[294,460],[460,327],[331,279],[279,294],[294,331],[303,271],[271,304],[304,303],[436,432],[432,427],[427,436],[304,272],[272,408],[408,304],[395,394],[394,431],[431,395],[378,395],[395,400],[400,378],[296,334],[334,299],[299,296],[6,351],[351,168],[168,6],[376,352],[352,411],[411,376],[307,325],[325,320],[320,307],[285,295],[295,336],[336,285],[320,319],[319,404],[404,320],[329,330],[330,349],[349,329],[334,293],[293,333],[333,334],[366,323],[323,447],[447,366],[316,15],[15,315],[315,316],[331,358],[358,279],[279,331],[317,14],[14,316],[316,317],[8,285],[285,9],[9,8],[277,329],[329,350],[350,277],[253,374],[374,252],[252,253],[319,318],[318,403],[403,319],[351,6],[6,419],[419,351],[324,318],[318,325],[325,324],[397,367],[367,365],[365,397],[288,435],[435,397],[397,288],[278,344],[344,439],[439,278],[310,272],[272,311],[311,310],[248,195],[195,281],[281,248],[375,273],[273,291],[291,375],[175,396],[396,199],[199,175],[312,311],[311,268],[268,312],[276,283],[283,445],[445,276],[390,373],[373,339],[339,390],[295,282],[282,296],[296,295],[448,449],[449,346],[346,448],[356,264],[264,454],[454,356],[337,336],[336,299],[299,337],[337,338],[338,151],[151,337],[294,278],[278,455],[455,294],[308,292],[292,415],[415,308],[429,358],[358,355],[355,429],[265,340],[340,372],[372,265],[352,346],[346,280],[280,352],[295,442],[442,282],[282,295],[354,19],[19,370],[370,354],[285,441],[441,295],[295,285],[195,248],[248,197],[197,195],[457,440],[440,274],[274,457],[301,300],[300,368],[368,301],[417,351],[351,465],[465,417],[251,301],[301,389],[389,251],[394,395],[395,379],[379,394],[399,412],[412,419],[419,399],[410,436],[436,322],[322,410],[326,2],[2,393],[393,326],[354,370],[370,461],[461,354],[393,164],[164,267],[267,393],[268,302],[302,12],[12,268],[312,268],[268,13],[13,312],[298,293],[293,301],[301,298],[265,446],[446,340],[340,265],[280,330],[330,425],[425,280],[322,426],[426,391],[391,322],[420,429],[429,437],[437,420],[393,391],[391,326],[326,393],[344,440],[440,438],[438,344],[458,459],[459,461],[461,458],[364,434],[434,394],[394,364],[428,396],[396,262],[262,428],[274,354],[354,457],[457,274],[317,316],[316,402],[402,317],[316,315],[315,403],[403,316],[315,314],[314,404],[404,315],[314,313],[313,405],[405,314],[313,421],[421,406],[406,313],[323,366],[366,361],[361,323],[292,306],[306,407],[407,292],[306,291],[291,408],[408,306],[291,287],[287,409],[409,291],[287,432],[432,410],[410,287],[427,434],[434,411],[411,427],[372,264],[264,383],[383,372],[459,309],[309,457],[457,459],[366,352],[352,401],[401,366],[1,274],[274,4],[4,1],[418,421],[421,262],[262,418],[331,294],[294,358],[358,331],[435,433],[433,367],[367,435],[392,289],[289,439],[439,392],[328,462],[462,326],[326,328],[94,2],[2,370],[370,94],[289,305],[305,455],[455,289],[339,254],[254,448],[448,339],[359,255],[255,446],[446,359],[254,253],[253,449],[449,254],[253,252],[252,450],[450,253],[252,256],[256,451],[451,252],[256,341],[341,452],[452,256],[414,413],[413,463],[463,414],[286,441],[441,414],[414,286],[286,258],[258,441],[441,286],[258,257],[257,442],[442,258],[257,259],[259,443],[443,257],[259,260],[260,444],[444,259],[260,467],[467,445],[445,260],[309,459],[459,250],[250,309],[305,289],[289,290],[290,305],[305,290],[290,460],[460,305],[401,376],[376,435],[435,401],[309,250],[250,392],[392,309],[376,411],[411,433],[433,376],[453,341],[341,464],[464,453],[357,453],[453,465],[465,357],[343,357],[357,412],[412,343],[437,343],[343,399],[399,437],[344,360],[360,440],[440,344],[420,437],[437,456],[456,420],[360,420],[420,363],[363,360],[361,401],[401,288],[288,361],[265,372],[372,353],[353,265],[390,339],[339,249],[249,390],[339,448],[448,255],[255,339]]),E("
2matrixDataToMatrix",function(e){for(var t=e.getCols(),n=e.getRows(),r=e.getPackedDataList(),a=[],o=0;o<n;o++)a.push(Array(t));for(o=0;o<n;o++)for(var s=0;s<t;s++){var i=1===e.getLayout()?o*t+s:s*n+o;a[o][s]=r[i]}return a}),E("VERSION","0.4.1633559619")}).call(this)},64394:function(e,t,n){"use strict";n.d(t,{N:function(){return s}});var r=n(57260),a=n(15441),o=n(28189);const s=(0,n(70929).op)({prelu_:function(e,t){const n={x:(0,o.YT)(e,"x","prelu"),alpha:(0,o.YT)(t,"alpha","prelu")};return r.T2.runKernel(a.Ncv,n)}})},66919:function(e,t,n){"use strict";n.d(t,{H:function(){return s}});var r=n(57260),a=n(15441),o=n(28189);const s=(0,n(70929).op)({leakyRelu_:function(e,t=.2){const n={x:(0,o.YT)(e,"x","leakyRelu")},s={alpha:t};return r.T2.runKernel(a.X0$,n,s)}})},68646:function(e,t,n){"use strict";n.d(t,{Do:function(){return m},XB:function(){return f},f2:function(){return g},zE:function(){return y}});var r=n(62198),a=n(83416),o=n(66919),s=n(9258),i=n(64394),u=n(90112),c=n(83732),l=n(62302),p=n(28968),h=n(10700),d=n(83791);function f(e,t,n){if(null==n||"linear"===n)return e;if("relu"===n)return(0,s.l)(e,(0,h.P)(t));throw new Error(`Cannot compute gradient for fused activation ${n}.`)}function m(e,t){let n=t;const a=r.getReductionAxes(e.shape,t.shape);return a.length>0&&(n=(0,d.c)(n,a)),(0,l.t)(n,e.shape)}function g(e,t,n,r){if("linear"===t)return e;if("relu"===t)return(0,u.V)(e);if("elu"===t)return(0,a.P)(e);if("relu6"===t)return(0,c.j)(e);if("prelu"===t)return(0,i.N)(e,n);if("leakyrelu"===t)return(0,o.H)(e,r);if("sigmoid"===t)return(0,p.r)(e);throw new Error(`Unknown fused activation ${t}.`)}const y=(e,t)=>!(e>0)||"linear"===t},70125:function(e,t,n){"use strict";n.d(t,{o:function(){return s}});var r=n(57260),a=n(15441),o=n(28189);const s=(0,n(70929).op)({clone_:function(e){const t={x:(0,o.YT)(e,"x","clone","string_or_numeric")};return r.T2.runKernel(a.lzr,t)}})},70929:function(e,t,n){"use strict";n.d(t,{B:function(){return o},op:function(){return s}});var r=n(57260),a=n(45119);const o="__op";function s(e){const t=Object.keys(e);if(1!==t.length)throw new Error(`Please provide an object with a single key (operation name) mapping to a function. Got an object with ${t.length} keys.`);let n=t[0];const s=e[n];n.endsWith("_")&&(n=n.substring(0,n.length-1)),n+=o;const i=(...e)=>{r.T2.startScope(n);try{const t=s(...e);return(0,a.yL)(t),r.T2.endScope(t),t}catch(e){throw r.T2.endScope(null),e}};return Object.defineProperty(i,"name",{value:n,configurable:!0}),i}},73673:function(e,t,n){"use strict";n.d(t,{R:function(){return o},i:function(){return a}});var r=n(46574);function a(...e){!(0,r._K)().getBool("IS_TEST")&&(0,r._K)().getBool("PROD")}function o(...e){!(0,r._K)().getBool("IS_TEST")&&(0,r._K)().getBool("PROD")}},74027:function(e,t,n){"use strict";n.d(t,{O:function(){return o}});var r=n(28189),a=n(19171);function o(e,t,n){const o=(0,r.MZ)(e,n);return(0,a.Q)(e,t,o,n)}},74801:function(e,t,n){var r;!function(a,o,s){var i,u=256,c=s.pow(u,6),l=s.pow(2,52),p=2*l,h=255;function d(e,t,n){var r=[],h=y(g((t=1==t?{entropy:!0}:t||{}).entropy?[e,x(o)]:null==e?function(){try{var e;return i&&(e=i.randomBytes)?e=e(u):(e=new Uint8Array(u),(a.crypto||a.msCrypto).getRandomValues(e)),x(e)}catch(e){var t=a.navigator,n=t&&t.plugins;return[+new Date,a,n,a.screen,x(o)]}}():e,3),r),d=new f(r),b=function(){for(var e=d.g(6),t=c,n=0;e<l;)e=(e+n)*u,t*=u,n=d.g(1);for(;e>=p;)e/=2,t/=2,n>>>=1;return(e+n)/t};return b.int32=function(){return 0|d.g(4)},b.quick=function(){return d.g(4)/4294967296},b.double=b,y(x(d.S),o),(t.pass||n||function(e,t,n,r){return r&&(r.S&&m(r,d),e.state=function(){return m(d,{})}),n?(s.random=e,t):e})(b,h,"global"in t?t.global:this==s,t.state)}function f(e){var t,n=e.length,r=this,a=0,o=r.i=r.j=0,s=r.S=[];for(n||(e=[n++]);a<u;)s[a]=a++;for(a=0;a<u;a++)s[a]=s[o=h&o+e[a%n]+(t=s[a])],s[o]=t;(r.g=function(e){for(var t,n=0,a=r.i,o=r.j,s=r.S;e--;)t=s[a=h&a+1],n=n*u+s[h&(s[a]=s[o=h&o+t])+(s[o]=t)];return r.i=a,r.j=o,n})(u)}function m(e,t){return t.i=e.i,t.j=e.j,t.S=e.S.slice(),t}function g(e,t){var n,r=[],a=typeof e;if(t&&"object"==a)for(n in e)try{r.push(g(e[n],t-1))}catch(e){}return r.length?r:"string"==a?e:e+"\0"}function y(e,t){for(var n,r=e+"",a=0;a<r.length;)t[h&a]=h&(n^=19*t[h&a])+r.charCodeAt(a++);return x(t)}function x(e){return String.fromCharCode.apply(0,e)}if(y(s.random(),o),e.exports){e.exports=d;try{i=n(41234)}catch(e){}}else void 0===(r=function(){return d}.call(t,n,t,e))||(e.exports=r)}("undefined"!=typeof self?self:this,[],Math)},75295:function(e,t,n){"use strict";function r(e,t=!1){}n.d(t,{y:function(){return r}})},77367:function(e,t,n){"use strict";n.d(t,{ljI:function(){return Ke.ljI},Vvy:function(){return Ke.Vvy},PH8:function(){return Ke.PH8},OMN:function(){return Ke.OMN},EkD:function(){return Ke.EkD},u8Z:function(){return Ke.u8Z},FSt:function(){return Ke.FSt}
2,Jp_:function(){return Ke.Jp_},p_m:function(){return Ke.p_m},QKF:function(){return Ke.QKF},epO:function(){return Ke.epO},TyE:function(){return Ke.TyE},lxb:function(){return Ke.lxb},zP9:function(){return Ke.zP9},ho8:function(){return Ke.ho8},cS:function(){return Ke.cS},wwC:function(){return Ke.wwC},VCH:function(){return Ke.VCH},jAQ:function(){return Ke.jAQ},Ik2:function(){return Ke.Ik2},N4F:function(){return Ke.N4F},vj7:function(){return Ke.vj7},KXH:function(){return Ke.KXH},QDP:function(){return Ke.QDP},vaV:function(){return Ke.vaV},pr3:function(){return Ke.pr3},$zE:function(){return Ke.$zE},$dB:function(){return Ke.$dB},p2J:function(){return Ke.p2J},rFm:function(){return Ke.rFm},jfg:function(){return Ke.jfg},A1h:function(){return Ke.A1h},iGz:function(){return Ke.iGz},gC7:function(){return Ke.gC7},Mn0:function(){return Ke.Mn0},MnK:function(){return Ke.MnK},MRQ:function(){return Ke.MRQ},jj_:function(){return Ke.jj_},nY8:function(){return Ke.nY8},GJx:function(){return Un.GJ},wNW:function(){return Ke.wNW},TMz:function(){return Ke.TMz},tGH:function(){return Ke.tGH},X$8:function(){return Ke.X$8},nVu:function(){return Ke.nVu},ORI:function(){return Ke.ORI},jxD:function(){return Ke.jxD},Qgm:function(){return Ke.Qgm},Pah:function(){return Ke.Pah},rsH:function(){return Ke.rsH},BRl:function(){return Ke.BRl},_s9:function(){return Ke._s9},ox3:function(){return Ke.ox3},ybN:function(){return Ke.ybN},ybj:function(){return Ke.ybj},rGP:function(){return Ke.rGP},SQl:function(){return Ke.SQl},BxF:function(){return Ke.BxF},ZgB:function(){return Ke.ZgB},ElG:function(){return Ke.ElG},awo:function(){return Ke.awo},i5R:function(){return Ke.i5R},aAr:function(){return Ke.aAr},T7M:function(){return Ke.T7M},O4G:function(){return Ke.O4G},mxL:function(){return Ke.mxL},XhZ:function(){return Ke.XhZ},lLS:function(){return Ke.lLS},OAQ:function(){return Ke.OAQ},lzr:function(){return Ke.lzr},dv8:function(){return Ke.dv8},gIW:function(){return Ke.gIW},E3$:function(){return Ke.E3$},iPs:function(){return Ke.iPs},uI_:function(){return Un.uI},jM4:function(){return Ke.jM4},ToN:function(){return Ke.ToN},X0$:function(){return Ke.X0$},mIA:function(){return Ke.mIA},CwD:function(){return Ke.CwD},mnI:function(){return Ke.mnI},tG8:function(){return Ke.tG8},Cg$:function(){return Ke.Cg$},RUm:function(){return Ke.RUm},nZd:function(){return Ke.nZd},LXA:function(){return Ke.LXA},VAI:function(){return Ke.VAI},t3d:function(){return Ke.t3d},ySp:function(){return Ke.ySp},cHb:function(){return Ke.cHb},RXX:function(){return Ke.RXX},TL8:function(){return Ke.TL8},LDN:function(){return Ke.LDN},g5A:function(){return Ke.g5A},lNG:function(){return Ke.lNG},LG0:function(){return Ke.LG0},x7F:function(){return Ke.x7F},BLA:function(){return Ke.BLA},WT3:function(){return Ke.WT3},xu7:function(){return Ke.xu7},l0G:function(){return Ke.l0G},SDM:function(){return Ke.SDM},Zl4:function(){return Ke.Zl4},e0f:function(){return Ke.e0f},ylV:function(){return Ke.ylV},urI:function(){return Ke.urI},LWX:function(){return Ke.LWX},mM$:function(){return Ke.mM$},ODT:function(){return Ke.ODT},pyJ:function(){return Ke.pyJ},Ncv:function(){return Ke.Ncv},kdj:function(){return Ke.kdj},oJ2:function(){return Ke.oJ2},mH5:function(){return Ke.mH5},Q6t:function(){return Ke.Q6t},LRy:function(){return Ke.LRy},sDr:function(){return Ke.sDr},huO:function(){return Ke.huO},fUj:function(){return Ke.fUj},P_L:function(){return Ke.P_L},R23:function(){return Ke.R23},hgw:function(){return Ke.hgw},FCQ:function(){return Ke.FCQ},jOE:function(){return Ke.jOE},XQy:function(){return Ke.XQy},D7i:function(){return Ke.D7i},BK4:function(){return Ke.BK4},hVg:function(){return Ke.hVg},TOR:function(){return Ke.TOR},pJc:function(){return Ke.pJc},uWl:function(){return Ke.uWl},l6P:function(){return Ke.l6P},u$b:function(){return Ke.u$b},vI1:function(){return Ke.vI1},YVe:function(){return Ke.YVe},hql:function(){return Ke.hql},J3C:function(){return Ke.J3C},JiE:function(){return Ke.JiE},rFG:function(){return Ke.rFG},Fin:function(){return Ke.Fin},A8B:function(){return Ke.A8B},C8s:function(){return Ke.C8s},BoJ:function(){return Ke.BoJ},L6G:function(){return Ke.L6G},DvZ:function(){return Ke.DvZ},jgd:function(){return Ke.jgd},Blb:function(){return Ke.Blb},dFH:function(){return Ke.dFH},M6A:function(){return Ke.M6A},Ddj:function(){return Ke.Ddj},pnw:function(){return Ke.pnw},UcO:function(){return Ke.UcO},YAb:function(){return Ke.YAb},iW0:function(){return Ke.iW0},$jE:function(){return Ke.$jE},PbM:function(){return Ke.PbM},WuN:function(){return Ke.WuN},oFs:function(){return Ke.oFs},iuW:function(){return Ke.iuW},qYS:function(){return Se.qY},ylz:function(){return Se.yl},FAs:function(){return Ke.FAs},TBb:function(){return Ke.TBb},dLy:function(){return Ke.dLy},wx0:function(){return Ke.wx0},EwU:function(){return Ke.EwU},dXR:function(){return Ke.dXR},pPe:function(){return Ke.pPe},xJ3:function(){return Ke.xJ3},Dr:function(){return Ke.Dr},WQq:function(){return Ct.WQq},C0T:function(){return u},hOW:function(){return Ct.hOW},ZEY:function(){return je},TaL:function(){return o},ra8:function(){return Ct.ra8},wgE:function(){return Ct.wgE},zQh:function(){return Ct.zQh},o8B:function(){return Ct.o8B},xWs:function(){return Ct.xWs},eMq:function(){return r},ASo:function(){return kt.AS},y4m:function(){return Ct.y4m},Hi9:function(){return kt.Hi},_K2:function(){return m._K},oNF:function(){return Ct.oNF},UG6:function(){return Ct.UG6},Slp:function(){return Ct.Slp},io:function(){return a},aCs:function(){return kt.aC},kpo:function(){return c},lKK:function(){return Ct.lKK},dA1:function(){return $t},gJX:function(){return kt.gJ},tAK:function(){return He.tA},tQQ:function(){return Ct.tQQ},d_2:function(){return Ct.d_2},ry7:function(){return Ct.ry7},dik:function(){return Ct.dik},Kro:function(){return s},r2V:function(){return Ct.r2V},t$z:function(){return Ct.t$z},jbE:function(){return Ct.jbE},chL:function(){return St.ch},OEK:function(){return Ct.OEK},tGX:function(){return Ct.tGX},KtR:function(){return Ct.KtR},DZQ:function(){return kt.DZ},K$i:function(){return Ct.K$i},TuY:function(){return St.Tu},ZSL:function(){return Tt},Ul9:function(){return Ct.Ul9}}
2);var r={};n.r(r),n.d(r,{isBrowser:function(){return f},isMobile:function(){return d},mockIsMobile:function(){return h}});var a={};n.r(a),n.d(a,{browserFiles:function(){return Ne},browserHTTPRequest:function(){return Me},concatenateArrayBuffers:function(){return $},copyModel:function(){return de},decodeWeights:function(){return S},encodeWeights:function(){return T},fromMemory:function(){return ze},fromMemorySync:function(){return Ue},getLoadHandlers:function(){return B},getModelArtifactsForJSON:function(){return R},getModelArtifactsForJSONSync:function(){return A},getModelArtifactsInfoForJSON:function(){return _},getSaveHandlers:function(){return P},getWeightSpecs:function(){return O},http:function(){return Le},isHTTPScheme:function(){return Fe},listModels:function(){return pe},loadWeights:function(){return Re},moveModel:function(){return fe},registerLoadRouter:function(){return M},registerSaveRouter:function(){return L},removeModel:function(){return he},weightsLoaderFactory:function(){return _e},withSaveHandler:function(){return We},withSaveHandlerSync:function(){return Ge}});var o={};n.r(o),n.d(o,{fromPixels:function(){return nt},fromPixelsAsync:function(){return et},toPixels:function(){return tt}});var s={};n.r(s),n.d(s,{assertParamsValid:function(){return ot},computeFlatOffset:function(){return xt},computeOutShape:function(){return it},getNormalizedAxes:function(){return pt},isSliceContinous:function(){return yt},maskToAxes:function(){return st},parseSliceParams:function(){return bt},sliceInfo:function(){return vt},startForAxis:function(){return mt},startIndicesWithElidedDims:function(){return ht},stopForAxis:function(){return gt},stopIndicesWithElidedDims:function(){return dt},stridesForAxis:function(){return ft},stridesWithElidedDims:function(){return ut}});var i={};n.r(i),n.d(i,{collectGatherOpShapeInfo:function(){return Mn},computeOutShape:function(){return Ln},segOpComputeOptimalWindowSize:function(){return Dn}});var u={};n.r(u),n.d(u,{ERF_A1:function(){return qt},ERF_A2:function(){return Qt},ERF_A3:function(){return Jt},ERF_A4:function(){return en},ERF_A5:function(){return tn},ERF_P:function(){return Xt},PARALLELIZE_THRESHOLD:function(){return Pt},RowPartitionType:function(){return Rt},SELU_SCALE:function(){return Zt},SELU_SCALEALPHA:function(){return Yt},applyActivation:function(){return Ot.f2},assertAndGetBroadcastShape:function(){return je.assertAndGetBroadcastShape},assertAxesAreInnerMostDims:function(){return Nt.WC},assertParamsConsistent:function(){return It},assignToTypedArray:function(){return cn},axesAreInnerMostDims:function(){return Nt.WH},calculateShapes:function(){return Ht.l8},checkEinsumDimSizes:function(){return xn},checkPadOnDimRoundingMode:function(){return _t.s_},combineLocations:function(){return Nt.aF},combineRaggedTensorToTensorShapes:function(){return Ft},complexWithEvenIndex:function(){return on},complexWithOddIndex:function(){return sn},computeConv2DInfo:function(){return _t.uf},computeConv3DInfo:function(){return _t.p$},computeDefaultPad:function(){return _t.G8},computeDilation2DInfo:function(){return _t.YQ}
2,computeOptimalWindowSize:function(){return Bt},computeOutAndReduceShapes:function(){return Nt.lb},computeOutShape:function(){return At},computePool2DInfo:function(){return _t.E6},computePool3DInfo:function(){return _t.l5},convertConv2DDataFormat:function(){return _t.$Q},decodeEinsumEquation:function(){return gn},eitherStridesOrDilationsAreOne:function(){return _t.G0},expandShapeToKeepDim:function(){return Nt.SM},exponent:function(){return pn},exponents:function(){return ln},fromStringArrayToUint8:function(){return Bn},fromUint8ToStringArray:function(){return Pn},getAxesPermutation:function(){return Nt.Em},getBroadcastDims:function(){return je.getBroadcastDims},getComplexWithIndex:function(){return un},getEinsumComputePath:function(){return bn},getEinsumPermutation:function(){return yn},getFusedBiasGradient:function(){return Ot.Do},getFusedDyActivation:function(){return Ot.XB},getImageCenter:function(){return Vt},getInnerMostAxes:function(){return Nt.fK},getPermuted:function(){return Ut},getRaggedRank:function(){return Lt},getReductionAxes:function(){return je.getReductionAxes},getReshaped:function(){return zt},getReshapedPermuted:function(){return Wt},getRowPartitionTypesHelper:function(){return Dt},getSliceBeginCoords:function(){return Gt},getSliceSize:function(){return jt},getSparseFillEmptyRowsIndicesDenseShapeMismatch:function(){return Sn},getSparseFillEmptyRowsNegativeIndexErrorMessage:function(){return Cn},getSparseFillEmptyRowsOutOfRangeIndexErrorMessage:function(){return kn},getSparseReshapeEmptyTensorZeroOutputDimErrorMessage:function(){return Nn},getSparseReshapeInputOutputMismatchErrorMessage:function(){return An},getSparseReshapeInputOutputMultipleErrorMessage:function(){return In},getSparseReshapeMultipleNegativeOneOutputDimErrorMessage:function(){return En},getSparseReshapeNegativeOutputDimErrorMessage:function(){return $n},getSparseSegmentReductionIndicesOutOfRangeErrorMessage:function(){return Fn},getSparseSegmentReductionNegativeSegmentIdsErrorMessage:function(){return Rn},getSparseSegmentReductionNonIncreasingSegmentIdsErrorMessage:function(){return _n},getSparseSegmentReductionSegmentIdOutOfRangeErrorMessage:function(){return On},getUndoAxesPermutation:function(){return Nt.gx},isIdentityPermutation:function(){return vn},log:function(){return nn.R},mergeRealAndImagArrays:function(){return rn},prepareAndValidate:function(){return Kt},prepareSplitSize:function(){return Tn},segment_util:function(){return i},shouldFuse:function(){return Ot.zE},slice_util:function(){return s},splitRealAndImagArrays:function(){return an},tupleValuesAreOne:function(){return _t.Dh},upcastType:function(){return St.Tu},validateDefaultValueShape:function(){return Mt},validateInput:function(){return Ht.TT},validateUpdateShape:function(){return Ht.Ly},warn:function(){return nn.i}});var c={};n.r(c),n.d(c,{c7:function(){return Vn.c7},ZS:function(){return Vn.ZS},ut:function(){return Vn.ut},YO:function(){return zn.Y}});var l=n(57260);let p;function h(e){p=e}function d(e){if(void 0!==p)return p;if(e||"undefined"!=typeof navigator&&null!=navigator){if(e||(e=navigator),"ReactNative"===e.product)return!0;const t=e.userAgent||e.vendor||("undefined"!=typeof window?window.opera:"");if(!t){const t=e;return t.userAgentData&&t.userAgentData.mobile}return/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(t)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|
2sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(t.substr(0,4))}return!1}function f(){return"undefined"!=typeof window&&null!=window.document||"undefined"!=typeof WorkerGlobalScope}var m=n(46574);const g=(0,m._K)();g.registerFlag("DEBUG",()=>!1,e=>{}),g.registerFlag("IS_BROWSER",()=>f()),g.registerFlag("IS_NODE",()=>"undefined"!=typeof process&&void 0!==process.versions&&void 0!==process.versions.node),g.registerFlag("IS_CHROME",()=>"undefined"!=typeof navigator&&null!=navigator&&null!=navigator.userAgent&&/Chrome/.test(navigator.userAgent)&&/Google Inc/.test(navigator.vendor)),g.registerFlag("PROD",()=>!1),g.registerFlag("TENSORLIKE_CHECK_SHAPE_CONSISTENCY",()=>g.getBool("DEBUG")),g.registerFlag("DEPRECATION_WARNINGS_ENABLED",()=>!0),g.registerFlag("IS_TEST",()=>!1),g.registerFlag("CHECK_COMPUTATION_FOR_ERRORS",()=>!0),g.registerFlag("WRAP_TO_IMAGEBITMAP",()=>!1),g.registerFlag("ENGINE_COMPILE_ONLY",()=>!1),g.registerFlag("CANVAS2D_WILL_READ_FREQUENTLY_FOR_GPU",()=>!1),g.registerFlag("USE_SETTIMEOUTCUSTOM",()=>!1);var y=n(37148),x=n(74027),b=n(45119);const v={float32:4,float16:2,int32:4,uint16:2,uint8:1,bool:1,complex64:8},w=4;async function T(e,t){const n=[],r=[],a=Array.isArray(e)?e.map(e=>e.name):Object.keys(e);for(let o=0;o<a.length;++o){const s=a[o],i=Array.isArray(e)?e[o].tensor:e[s];if("float32"!==i.dtype&&"int32"!==i.dtype&&"bool"!==i.dtype&&"string"!==i.dtype&&"complex64"!==i.dtype)throw new Error(`Unsupported dtype in weight '${s}': ${i.dtype}`);const u={name:s,shape:i.shape,dtype:i.dtype};if("string"===i.dtype){const e=new Promise(async e=>{const t=await i.bytes(),n=t.reduce((e,t)=>e+t.length,0)+w*t.length,r=new Uint8Array(n);let a=0;for(let e=0;e<t.length;e++){const n=t[e],o=new Uint8Array(new Uint32Array([n.length]).buffer);r.set(o,a),a+=w,r.set(n,a),a+=n.length}e(r)});r.push(e)}else r.push(i.data());null!=t&&(u.group=t),n.push(u)}return{data:C(await Promise.all(r)),specs:n}}function S(e,t){const n={};let r,a=0;for(const o of t){const t=o.name,s=o.dtype,i=o.shape,u=(0,b.Ze)(i);let c;if("quantization"in o){const n=o.quantization;if("uint8"===n.dtype||"uint16"===n.dtype){if(!("min"in n)||!("scale"in n))throw new Error(`Weight ${o.name} with quantization ${n.dtype} doesn't have corresponding metadata min and scale.`)}else{if("float16"!==n.dtype)throw new Error(`Weight ${o.name} has unknown quantization dtype ${n.dtype}. Supported quantization dtypes are: 'uint8', 'uint16', and 'float16'.`);if("float32"!==s)throw new Error(`Weight ${o.name} is quantized with ${n.dtype} which only supports weights of type float32 not ${s}.`)}const i=v[n.dtype],l=e.slice(a,a+u*i),p="uint8"===n.dtype?new Uint8Array(l):new Uint16Array(l);if("float32"===s)if("uint8"===n.dtype||"uint16"===n.dtype){c=new Float32Array(p.length);for(let e=0;e<p.length;e++){const t=p[e];c[e]=t*n.scale+n.min}}else{if("float16"!==n.dtype)throw new Error(`Unsupported quantization type ${n.dtype} for weight type float32.`);void 0===r&&(r=F()),c=r(p)}else{if("int32"!==s)throw new Error(`Unsupported dtype in weight '${t}': ${s}`);if("uint8"!==n.dtype&&"uint16"!==n.dtype)throw new Error(`Unsupported quantization type ${n.dtype} for weight type int32.`);c=new Int32Array(p.length);for(let e=0;e<p.length;e++){const t=p[e];c[e]=Math.round(t*n.scale+n.min)}}a+=u*i}else if("string"===s){const t=(0,b.Ze)(o.shape);c=[];for(let n=0;n<t;n++){const t=new Uint32Array(e.slice(a,a+w))[0];a+=w;const n=new Uint8Array(e.slice(a,a+t));c.push(n),a+=t}}else{const r=v[s],o=e.slice(a,a+u*r);if("float32"===s)c=new Float32Array(o);else if("int32"===s)c=new Int32Array(o);else if("bool"===s)c=new Uint8Array(o);else{if("complex64"!==s)throw new Error(`Unsupported dtype in weight '${t}': ${s}`);{c=new Float32Array(o);const e=new Float32Array(c.length/2),r=new Float32Array(c.length/2);for(let t=0;t<e.length;t++)e[t]=c[2*t],r[t]=c[2*t+1];const a=(0,x.O)(e,i,"float32"),s=(0,x.O)(r,i,"float32");n[t]=(0,y.f)(a,s),a.dispose(),s.dispose()}}a+=u*r}"complex64"!==s&&(n[t]=(0,x.O)(c,i,s))}return n}function C(e){if(null===e)throw new Error(`Invalid input value: ${JSON.stringify(e)}`);let t=0;const n=[];
2e.forEach(e=>{if(t+=e.byteLength,n.push(e.byteLength===e.buffer.byteLength?e:new e.constructor(e)),!(e instanceof Float32Array||e instanceof Int32Array||e instanceof Uint8Array))throw new Error(`Unsupported TypedArray subtype: ${e.constructor.name}`)});const r=new Uint8Array(t);let a=0;return n.forEach(e=>{r.set(new Uint8Array(e.buffer),a),a+=e.byteLength}),r.buffer}const k="undefined"!=typeof Buffer&&("undefined"==typeof Blob||"undefined"==typeof atob||"undefined"==typeof btoa);function E(e){return k?Buffer.byteLength(e):new Blob([e]).size}function $(e){if(1===e.length)return e[0];let t=0;e.forEach(e=>{t+=e.byteLength});const n=new Uint8Array(t);let r=0;return e.forEach(e=>{n.set(new Uint8Array(e),r),r+=e.byteLength}),n.buffer}function N(e){for(e=e.trim();e.endsWith("/");)e=e.slice(0,e.length-1);const t=e.split("/");return t[t.length-1]}function I(e,t){const n={modelTopology:e.modelTopology,format:e.format,generatedBy:e.generatedBy,convertedBy:e.convertedBy,weightsManifest:t};return null!=e.signature&&(n.signature=e.signature),null!=e.userDefinedMetadata&&(n.userDefinedMetadata=e.userDefinedMetadata),null!=e.modelInitializer&&(n.modelInitializer=e.modelInitializer),null!=e.trainingConfig&&(n.trainingConfig=e.trainingConfig),n}function A(e,t,n){const r={modelTopology:e.modelTopology,format:e.format,generatedBy:e.generatedBy,convertedBy:e.convertedBy};if(null!=e.trainingConfig&&(r.trainingConfig=e.trainingConfig),null!=e.weightsManifest){if(!t)throw new Error("modelJSON has weightsManifest but weightSpecs is null");if(!n)throw new Error("modelJSON has weightsManifest but weightData is null");r.weightSpecs=t,r.weightData=n}return null!=e.signature&&(r.signature=e.signature),null!=e.userDefinedMetadata&&(r.userDefinedMetadata=e.userDefinedMetadata),null!=e.modelInitializer&&(r.modelInitializer=e.modelInitializer),r}async function R(e,t){let n,r;return null!=e.weightsManifest&&([n,r]=await t(e.weightsManifest)),A(e,n,r)}function _(e){if(e.modelTopology instanceof ArrayBuffer)throw new Error("Expected JSON model topology, received ArrayBuffer.");return{dateSaved:new Date,modelTopologyType:"JSON",modelTopologyBytes:null==e.modelTopology?0:E(JSON.stringify(e.modelTopology)),weightSpecsBytes:null==e.weightSpecs?0:E(JSON.stringify(e.weightSpecs)),weightDataBytes:null==e.weightData?0:e.weightData.byteLength}}function O(e){const t=[];for(const n of e)t.push(...n.weights);return t}function F(){const e=function(){const e=e=>{let t=e<<13,n=0;for(;!(8388608&t);)n-=8388608,t<<=1;return t&=-8388609,n+=947912704,t|n},t=new Uint32Array(2048);t[0]=0;for(let n=1;n<1024;n++)t[n]=e(n);for(let e=1024;e<2048;e++)t[e]=939524096+(e-1024<<13);return t}(),t=function(){const e=new Uint32Array(64);e[0]=0,e[31]=1199570944,e[32]=2147483648,e[63]=3347054592;for(let t=1;t<31;t++)e[t]=t<<23;for(let t=33;t<63;t++)e[t]=2147483648+(t-32<<23);return e}(),n=function(){const e=new Uint32Array(64);for(let t=0;t<64;t++)e[t]=1024;return e[0]=e[32]=0,e}();return r=>{const a=new ArrayBuffer(4*r.length),o=new Uint32Array(a);for(let a=0;a<r.length;a++){const s=r[a],i=e[n[s>>10]+(1023&s)]+t[s>>10];o[a]=i}return new Float32Array(a)}}class D{constructor(){this.saveRouters=[],this.loadRouters=[]}static getInstance(){return null==D.instance&&(D.instance=new D),D.instance}static registerSaveRouter(e){D.getInstance().saveRouters.push(e)}static registerLoadRouter(e){D.getInstance().loadRouters.push(e)}static getSaveHandlers(e){return D.getHandlers(e,"save")}static getLoadHandlers(e,t){return D.getHandlers(e,"load",t)}static getHandlers(e,t,n){const r=[];return("load"===t?D.getInstance().loadRouters:D.getInstance().saveRouters).forEach(t=>{const a=t(e,n);null!==a&&r.push(a)}),r}}const L=e=>D.registerSaveRouter(e),M=e=>D.registerLoadRouter(e),P=e=>D.getSaveHandlers(e),B=(e,t)=>D.getLoadHandlers(e,t),V="tensorflowjs",z="models_store",U="model_info_store";function W(){if(!(0,m._K)().getBool("IS_BROWSER"))throw new Error("Failed to obtain IndexedDB factory because the current environmentis not a web browser.");const e="undefined"==typeof window?self:window,t=e.indexedDB||e.mozIndexedDB||e.webkitIndexedDB||e.msIndexedDB||e.shimIndexedDB;if(null==t)throw new Error("The current browser does not appear to supp
2ort IndexedDB.");return t}function G(e){const t=e.result;t.createObjectStore(z,{keyPath:"modelPath"}),t.createObjectStore(U,{keyPath:"modelPath"})}class j{constructor(e){if(this.indexedDB=W(),null==e||!e)throw new Error("For IndexedDB, modelPath must not be null, undefined or empty.");this.modelPath=e}async save(e){if(e.modelTopology instanceof ArrayBuffer)throw new Error("BrowserLocalStorage.save() does not support saving model topology in binary formats yet.");return this.databaseAction(this.modelPath,e)}async load(){return this.databaseAction(this.modelPath)}databaseAction(e,t){return new Promise((e,n)=>{const r=this.indexedDB.open(V,1);r.onupgradeneeded=()=>G(r),r.onsuccess=()=>{const a=r.result;if(null==t){const t=a.transaction(z,"readonly"),r=t.objectStore(z).get(this.modelPath);r.onsuccess=()=>{if(null==r.result)return a.close(),n(new Error(`Cannot find model with path '${this.modelPath}' in IndexedDB.`));e(r.result.modelArtifacts)},r.onerror=e=>(a.close(),n(r.error)),t.oncomplete=()=>a.close()}else{const r=_(t),o=a.transaction(U,"readwrite");let s=o.objectStore(U);const i=s.put({modelPath:this.modelPath,modelArtifactsInfo:r});let u;i.onsuccess=()=>{u=a.transaction(z,"readwrite");const i=u.objectStore(z).put({modelPath:this.modelPath,modelArtifacts:t,modelArtifactsInfo:r});i.onsuccess=()=>e({modelArtifactsInfo:r}),i.onerror=e=>{s=o.objectStore(U);const t=s.delete(this.modelPath);t.onsuccess=()=>(a.close(),n(i.error)),t.onerror=e=>(a.close(),n(i.error))}},i.onerror=e=>(a.close(),n(i.error)),o.oncomplete=()=>{null==u?a.close():u.oncomplete=()=>a.close()}}},r.onerror=e=>n(r.error)})}}j.URL_SCHEME="indexeddb://";const K=e=>{return(0,m._K)().getBool("IS_BROWSER")&&!Array.isArray(e)&&e.startsWith(j.URL_SCHEME)?(t=e.slice(j.URL_SCHEME.length),new j(t)):null;var t};D.registerSaveRouter(K),D.registerLoadRouter(K);class H{constructor(){this.indexedDB=W()}async listModels(){return new Promise((e,t)=>{const n=this.indexedDB.open(V,1);n.onupgradeneeded=()=>G(n),n.onsuccess=()=>{const r=n.result,a=r.transaction(U,"readonly"),o=a.objectStore(U).getAll();o.onsuccess=()=>{const t={};for(const e of o.result)t[e.modelPath]=e.modelArtifactsInfo;e(t)},o.onerror=e=>(r.close(),t(o.error)),a.oncomplete=()=>r.close()},n.onerror=e=>t(n.error)})}async removeModel(e){var t;return e=(t=e).startsWith(j.URL_SCHEME)?t.slice(j.URL_SCHEME.length):t,new Promise((t,n)=>{const r=this.indexedDB.open(V,1);r.onupgradeneeded=()=>G(r),r.onsuccess=()=>{const a=r.result,o=a.transaction(U,"readwrite"),s=o.objectStore(U),i=s.get(e);let u;i.onsuccess=()=>{if(null==i.result)return a.close(),n(new Error(`Cannot find model with path '${e}' in IndexedDB.`));{const r=s.delete(e),o=()=>{u=a.transaction(z,"readwrite");const r=u.objectStore(z).delete(e);r.onsuccess=()=>t(i.result.modelArtifactsInfo),r.onerror=e=>n(i.error)};r.onsuccess=o,r.onerror=e=>(o(),a.close(),n(i.error))}},i.onerror=e=>(a.close(),n(i.error)),o.oncomplete=()=>{null==u?a.close():u.oncomplete=()=>a.close()}},r.onerror=e=>n(r.error)})}}const Y="/",Z="tensorflowjs_models",X="info",q="model_topology",Q="weight_specs",J="weight_data",ee="model_metadata";function te(e){return{info:[Z,e,X].join(Y),topology:[Z,e,q].join(Y),weightSpecs:[Z,e,Q].join(Y),weightData:[Z,e,J].join(Y),modelMetadata:[Z,e,ee].join(Y)}}function ne(e){for(const t of Object.values(e))window.localStorage.removeItem(t)}function re(e){const t=e.split(Y);if(t.length<3)throw new Error(`Invalid key format: ${e}`);return t.slice(1,t.length-1).join(Y)}class ae{constructor(e){if(!(0,m._K)().getBool("IS_BROWSER")||"undefined"==typeof window||void 0===window.localStorage)throw new Error("The current environment does not support local storage.");if(this.LS=window.localStorage,null==e||!e)throw new Error("For local storage, modelPath must not be null, undefined or empty.");this.modelPath=e,this.keys=te(this.modelPath)}async save(e){if(e.modelTopology instanceof ArrayBuffer)throw new Error("BrowserLocalStorage.save() does not support saving model topology in binary formats yet.");{const t=JSON.stringify(e.modelTopology),n=JSON.stringify(e.weightSpecs),r=_(e);try{this.LS.setItem(this.keys.info,JSON.stringify(r)),this.LS.setItem(this.keys.topology,t),this.LS.setItem(this.keys.weightSpecs,n),this.LS.setItem(this.keys.weightData,function(e){if(k)return Buffer.from(e).toString("base64");const t=new Uint8Array(e);let n="";for(let e=0,r=t.length;e<r;e++)n+=String.fromCharCode(t[e]);return btoa(n)}(e.weightData));const a={format:e.format,generatedBy:e.generatedBy,convertedBy:e.convertedBy,signature:null!=e.signature?e.signature:void 0,userDefinedMetadata:null!=e.userDefinedMetadata?e.userDefinedMetadata:void 0,modelInitializer:null!=e.modelInitializer?e.modelInitializer:void 0,trainingConfig:null!=e.trainingConfig?e.trainingConfig:void 0};return this.LS.setItem(this.keys.modelMetadata,JSON.stringify(a)),{modelArtifactsInfo:r}}catch(e){throw ne(this.keys),new Error(`Failed to save model '${this.modelPath}' to local storage: size quota being exceeded is a possible cause of this failure: modelTopologyBytes=${r.modelTopologyBytes}, weightSpecsBytes=${r.weightSpecsBytes}, weightDataBytes=${r.weightDataBytes}.`)}}}async load(){const e=JSON.parse(this.LS.getItem(this.keys.info));if(null==e)throw new Error(`In local storage, there is no model with name '${this.modelPath}'`);if("JSON"!==e.modelTopologyType)throw new Error("BrowserLocalStorage does not support loading non-JSON model topology yet.");const t={},n=JSON.parse(this.LS.getItem(this.keys.topology));if(null==n)throw new Error(`In local storage, the topology of model '${this.modelPath}' is missing.`);t.modelTopology=n;const r=JSON.parse(this.LS.getItem(this.keys.weightSpecs));if(null==r)throw new Error(`In local storage, the weight specs of model '${this.modelPath}' are missing.`);t.weightSpecs=r;const a=this.LS.getItem(this.keys.modelMetadata);if(null!=a){const e=JSON.parse(a);t.format=e.format,t.generatedBy=e.generatedBy,t.convertedBy=e.convertedBy,null!=e.signature&&(t.signature=e.signature),null!=e.userDefinedMetadata&&(t.userDefinedMetadata=e.userDefinedMetadata),null!=e.modelInitializer&&(t.modelInitializer=e.modelInitializer),null!=e.trainingConfig&&(t.trainingConfig=e.trainingConfig)}const o=this.LS.getItem(this.keys.weightData);if(null==o)throw new Error(`In local storage, the binary weight values of model '${this.modelPath}' are missing.`);return t.weightData=function(e){if(k){const t=Buffer.from(e,"base64");return t.buffer.slice(t.byteOffset,t.byteOffset+t.byteLength)}const t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;++e)n.set([t.charCodeAt(e)],e);return n.buffer}(o),t}}ae.URL_SCHEME="localstorage://";const oe=e=>
2{return(0,m._K)().getBool("IS_BROWSER")&&!Array.isArray(e)&&e.startsWith(ae.URL_SCHEME)?(t=e.slice(ae.URL_SCHEME.length),new ae(t)):null;var t};D.registerSaveRouter(oe),D.registerLoadRouter(oe);class se{constructor(){(0,b.vA)((0,m._K)().getBool("IS_BROWSER"),()=>"Current environment is not a web browser"),(0,b.vA)("undefined"==typeof window||void 0!==window.localStorage,()=>"Current browser does not appear to support localStorage"),this.LS=window.localStorage}async listModels(){const e={},t=Z+Y,n=Y+X;for(let r=0;r<this.LS.length;++r){const a=this.LS.key(r);if(a.startsWith(t)&&a.endsWith(n)){e[re(a)]=JSON.parse(this.LS.getItem(a))}}return e}async removeModel(e){var t;const n=te(e=(t=e).startsWith(ae.URL_SCHEME)?t.slice(ae.URL_SCHEME.length):t);if(null==this.LS.getItem(n.info))throw new Error(`Cannot find model at path '${e}'`);const r=JSON.parse(this.LS.getItem(n.info));return ne(n),r}}const ie="://";class ue{constructor(){this.managers={}}static getInstance(){return null==ue.instance&&(ue.instance=new ue),ue.instance}static registerManager(e,t){(0,b.vA)(null!=e,()=>"scheme must not be undefined or null."),e.endsWith(ie)&&(e=e.slice(0,e.indexOf(ie))),(0,b.vA)(e.length>0,()=>"scheme must not be an empty string.");const n=ue.getInstance();(0,b.vA)(null==n.managers[e],()=>`A model store manager is already registered for scheme '${e}'.`),n.managers[e]=t}static getManager(e){const t=ue.getInstance().managers[e];if(null==t)throw new Error(`Cannot find model manager for scheme '${e}'`);return t}static getSchemes(){return Object.keys(ue.getInstance().managers)}}function ce(e){if(-1===e.indexOf(ie))throw new Error(`The url string provided does not contain a scheme. Supported schemes are: ${ue.getSchemes().join(",")}`);return{scheme:e.split(ie)[0],path:e.split(ie)[1]}}async function le(e,t,n=!1){(0,b.vA)(e!==t,()=>`Old path and new path are the same: '${e}'`);const r=D.getLoadHandlers(e);(0,b.vA)(r.length>0,()=>`Copying failed because no load handler is found for source URL ${e}.`),(0,b.vA)(r.length<2,()=>`Copying failed because more than one (${r.length}) load handlers for source URL ${e}.`);const a=r[0],o=D.getSaveHandlers(t);(0,b.vA)(o.length>0,()=>`Copying failed because no save handler is found for destination URL ${t}.`),(0,b.vA)(o.length<2,()=>`Copying failed because more than one (${r.length}) save handlers for destination URL ${t}.`);const s=o[0],i=ce(e).scheme,u=ce(e).path,c=i===ce(e).scheme,l=await a.load();n&&c&&await ue.getManager(i).removeModel(u);const p=await s.save(l);return n&&!c&&await ue.getManager(i).removeModel(u),p.modelArtifactsInfo}async function pe(){const e=ue.getSchemes(),t={};for(const n of e){const e=await ue.getManager(n).listModels();for(const r in e){t[n+ie+r]=e[r]}}return t}async function he(e){const t=ce(e);return ue.getManager(t.scheme).removeModel(t.path)}async function de(e,t){return le(e,t,!1)}async function fe(e,t){return le(e,t,!0)}class me{constructor(){this.messageName="setTimeoutCustom",this.functionRefs=[],this.handledMessageCount=0,this.hasEventListener=!1}fetch(e,t){return fetch(e,t)}now(){return performance.now()}encode(e,t){if("utf-8"!==t&&"utf8"!==t)throw new Error(`Browser's encoder only supports utf-8, but got ${t}`);return null==this.textEncoder&&(this.textEncoder=new TextEncoder),this.textEncoder.encode(e)}decode(e,t){return new TextDecoder(t).decode(e)}setTimeoutCustom(e,t){window&&(0,m._K)().getBool("USE_SETTIMEOUTCUSTOM")?(this.functionRefs.push(e),setTimeout(()=>{window.postMessage({name:this.messageName,index:this.functionRefs.length-1},"*")},t),this.hasEventListener||(this.hasEventListener=!0,window.addEventListener("message",e=>{if(e.source===window&&e.data.name===this.messageName){e.stopPropagation();(0,this.functionRefs[e.data.index])(),this.handledMessageCount++,this.handledMessageCount===this.functionRefs.length&&(this.functionRefs=[],this.handledMessageCount=0)}},!0))):setTimeout(e,t)}}if((0,m._K)().get("IS_BROWSER")){(0,m._K)().setPlatform("browser",new me);try{ue.registerManager(ae.URL_SCHEME,new se)}catch(e){}try{ue.registerManager(j.URL_SCHEME,new H)}catch(e){}}const ge=()=>n(85817);let ye;class xe{constructor(){this.util=n(18590),this.textEncoder=new this.util.TextEncoder}fetch(e,t){return null!=(0,m._K)().global.fetch?(0,m._K)().global.fetch(e,t):(null==ye&&(ye=ge()),ye(e,t))}now(){const e=process.hrtime();return 1e3*e[0]+e[1]/1e6}encode(e,t){if("utf-8"!==t&&"utf8"!==t)throw new Error(`Node built-in encoder only supports utf-8, but got ${t}`);return this.textEncoder.encode(e)}decode(e,t){return 0===e.length?"":new this.util.TextDecoder(t).decode(e)}}
2(0,m._K)().get("IS_NODE")&&!(0,m._K)().get("IS_BROWSER")&&(0,m._K)().setPlatform("node",new xe);var be=n(448),ve=n(29809),we=n(70125),Te=n(75295),Se=n(21722);(0,l.Ye)();const Ce={buffer:be.r,cast:ve.w,clone:we.o,print:Te.y};(0,Se.Q5)(Ce);function ke(e){return new Promise(e=>setTimeout(e)).then(e)}class Ee{constructor(e){if(!(0,m._K)().getBool("IS_BROWSER"))throw new Error("browserDownloads() cannot proceed because the current environment is not a browser.");e.startsWith(Ee.URL_SCHEME)&&(e=e.slice(Ee.URL_SCHEME.length)),null!=e&&0!==e.length||(e="model"),this.modelJsonFileName=e+".json",this.weightDataFileName=e+".weights.bin"}async save(e){if("undefined"==typeof document)throw new Error("Browser downloads are not supported in this environment since `document` is not present");const t=window.URL.createObjectURL(new Blob([e.weightData],{type:"application/octet-stream"}));if(e.modelTopology instanceof ArrayBuffer)throw new Error("BrowserDownloads.save() does not support saving model topology in binary formats yet.");{const n=I(e,[{paths:["./"+this.weightDataFileName],weights:e.weightSpecs}]),r=window.URL.createObjectURL(new Blob([JSON.stringify(n)],{type:"application/json"})),a=null==this.modelJsonAnchor?document.createElement("a"):this.modelJsonAnchor;if(a.download=this.modelJsonFileName,a.href=r,await ke(()=>a.dispatchEvent(new MouseEvent("click"))),null!=e.weightData){const e=null==this.weightDataAnchor?document.createElement("a"):this.weightDataAnchor;e.download=this.weightDataFileName,e.href=t,await ke(()=>e.dispatchEvent(new MouseEvent("click")))}return{modelArtifactsInfo:_(e)}}}}Ee.URL_SCHEME="downloads://";class $e{constructor(e){if(null==e||e.length<1)throw new Error(`When calling browserFiles, at least 1 file is required, but received ${e}`);this.jsonFile=e[0],this.weightsFiles=e.slice(1)}async load(){return new Promise((e,t)=>{const n=new FileReader;n.onload=n=>{const r=JSON.parse(n.target.result),a=r.modelTopology;if(null==a)return void t(new Error(`modelTopology field is missing from file ${this.jsonFile.name}`));if(null==r.weightsManifest)return void t(new Error(`weightManifest field is missing from file ${this.jsonFile.name}`));if(0===this.weightsFiles.length)return void e({modelTopology:a});const o=R(r,e=>this.loadWeights(e));e(o)},n.onerror=e=>t(`Failed to read model topology and weights manifest JSON from file '${this.jsonFile.name}'. BrowserFiles supports loading Keras-style tf.Model artifacts only.`),n.readAsText(this.jsonFile)})}loadWeights(e){const t=[],n=[];for(const r of e)t.push(...r.weights),n.push(...r.paths);const r=this.checkManifestAndWeightFiles(e),a=n.map(e=>this.loadWeightsFile(e,r[e]));return Promise.all(a).then(e=>[t,$(e)])}loadWeightsFile(e,t){return new Promise((n,r)=>{const a=new FileReader;a.onload=e=>{const t=e.target.result;n(t)},a.onerror=t=>r(`Failed to weights data from file of path '${e}'.`),a.readAsArrayBuffer(t)})}checkManifestAndWeightFiles(e){const t=[],n=this.weightsFiles.map(e=>N(e.name)),r={};for(const a of e)a.paths.forEach(e=>{const a=N(e);if(-1!==t.indexOf(a))throw new Error(`Duplicate file basename found in weights manifest: '${a}'`);if(t.push(a),-1===n.indexOf(a))throw new Error(`Weight file with basename '${a}' is not provided.`);r[e]=this.weightsFiles[n.indexOf(a)]});if(t.length!==this.weightsFiles.length)throw new Error(`Mismatch in the number of files in weights manifest (${t.length}) and the number of weight files provided (${this.weightsFiles.length}).`);return r}}function Ne(e){return new $e(e)}function Ie(e,t,n,r){!function(e){(0,b.vA)(null!=e&&Array.isArray(e)&&e.length>0,()=>"promises must be a none empty array")}(e),function(e,t){(0,b.vA)(e>=0&&e<=1,()=>`Progress fraction must be in range [0, 1], but got startFraction ${e}`),(0,b.vA)(t>=0&&t<=1,()=>`Progress fraction must be in range [0, 1], but got endFraction ${t}`),(0,b.vA)(t>=e,()=>`startFraction must be no more than endFraction, but got startFraction ${e} and endFraction ${t}`)}(n=null==n?0:n,r=null==r?1:r);let a=0;return Promise.all(e.map(o=>(o.then(o=>{const s=n+ ++a/e.length*(r-n);return t(s),o}),o)))}async function Ae(e,t){null==t&&(t={});const n=null==t.fetchFunc?(0,m._K)().platform.fetch:t.fetchFunc,r=e.map(e=>n(e,t.requestInit,{isBinary:!0})),a=(null==t.onProgress?await Promise.all(r):await Ie(r,t.onProgress,0,.5)).map(e=>e.arrayBuffer());return null==t.onProgress?await Promise.all(a):await Ie(a,t.onProgress,.5,1)}async function Re(e,t="",n,r){return _e(e=>Ae(e,{requestInit:r}))(e,t,n)}function _e(e){return async(t,n="",r)=>{const a=t.map(()=>!1),o={},s=null!=r?r.map(()=>!1):[],i=[];if(t.forEach((e,t)=>{let n=0;
2e.weights.forEach(e=>{const u="quantization"in e?e.quantization.dtype:e.dtype,c=v[u]*b.Ze(e.shape),l=()=>{a[t]=!0,null==o[t]&&(o[t]=[]),o[t].push({manifestEntry:e,groupOffset:n,sizeBytes:c})};null!=r?r.forEach((t,n)=>{t===e.name&&(l(),s[n]=!0)}):l(),i.push(e.name),n+=c})}),!s.every(e=>e)){const e=r.filter((e,t)=>!s[t]);throw new Error(`Could not find weights in manifest with names: ${e.join(", ")}. \nManifest JSON has weights with names: ${i.join(", ")}.`)}const u=a.reduce((e,t,n)=>(t&&e.push(n),e),[]),c=[];u.forEach(e=>{t[e].paths.forEach(e=>{const t=n+(n.endsWith("/")?"":"/")+e;c.push(t)})});const l=await e(c),p={};let h=0;return u.forEach(e=>{const n=t[e].paths.length;let r=0;for(let e=0;e<n;e++)r+=l[h+e].byteLength;const a=new ArrayBuffer(r),s=new Uint8Array(a);let i=0;for(let e=0;e<n;e++){const t=new Uint8Array(l[h+e]);s.set(t,i),i+=t.byteLength}o[e].forEach(e=>{const t=S(a.slice(e.groupOffset,e.groupOffset+e.sizeBytes),[e.manifestEntry]);for(const e in t)p[e]=t[e]}),h+=n}),p}}D.registerSaveRouter(e=>(0,m._K)().getBool("IS_BROWSER")&&!Array.isArray(e)&&e.startsWith(Ee.URL_SCHEME)?function(e="model"){return new Ee(e)}(e.slice(Ee.URL_SCHEME.length)):null);class Oe{constructor(e,t){if(this.DEFAULT_METHOD="POST",null==t&&(t={}),this.weightPathPrefix=t.weightPathPrefix,this.onProgress=t.onProgress,this.weightUrlConverter=t.weightUrlConverter,null!=t.fetchFunc?((0,b.vA)("function"==typeof t.fetchFunc,()=>"Must pass a function that matches the signature of `fetch` (see https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API)"),this.fetch=t.fetchFunc):this.fetch=(0,m._K)().platform.fetch,(0,b.vA)(null!=e&&e.length>0,()=>"URL path for http must not be null, undefined or empty."),Array.isArray(e)&&(0,b.vA)(2===e.length,()=>`URL paths for http must have a length of 2, (actual length is ${e.length}).`),this.path=e,null!=t.requestInit&&null!=t.requestInit.body)throw new Error("requestInit is expected to have no pre-existing body, but has one.");this.requestInit=t.requestInit||{}}async save(e){if(e.modelTopology instanceof ArrayBuffer)throw new Error("BrowserHTTPRequest.save() does not support saving model topology in binary formats yet.");const t=Object.assign({method:this.DEFAULT_METHOD},this.requestInit);t.body=new FormData;const n=I(e,[{paths:["./model.weights.bin"],weights:e.weightSpecs}]);t.body.append("model.json",new Blob([JSON.stringify(n)],{type:"application/json"}),"model.json"),null!=e.weightData&&t.body.append("model.weights.bin",new Blob([e.weightData],{type:"application/octet-stream"}),"model.weights.bin");const r=await this.fetch(this.path,t);if(r.ok)return{modelArtifactsInfo:_(e),responses:[r]};throw new Error(`BrowserHTTPRequest.save() failed due to HTTP response status ${r.status}.`)}async load(){const e=await this.fetch(this.path,this.requestInit);if(!e.ok)throw new Error(`Request to ${this.path} failed with status code ${e.status}. Please verify this URL points to the model JSON of the model to load.`);let t;try{t=await e.json()}catch(e){let t=`Failed to parse model JSON of response from ${this.path}.`;throw this.path.endsWith(".pb")?t+=" Your path contains a .pb file extension. Support for .pb models have been removed in TensorFlow.js 1.0 in favor of .json models. You can re-convert your Python TensorFlow model using the TensorFlow.js 1.0 conversion scripts or you can convert your.pb models with the 'pb2json'NPM script in the tensorflow/tfjs-converter repository.":t+=" Please make sure the server is serving valid JSON for this request.",new Error(t)}const n=t.modelTopology,r=t.weightsManifest;if(null==n&&null==r)throw new Error(`The JSON from HTTP path ${this.path} contains neither model topology or manifest for weights.`);return R(t,e=>this.loadWeights(e))}async loadWeights(e){const t=Array.isArray(this.path)?this.path[1]:this.path,[n,r]=function(e){const t=e.lastIndexOf("/"),n=e.lastIndexOf("?"),r=e.substring(0,t),a=n>t?e.substring(n):"";return[r+"/",a]}(t),a=this.weightPathPrefix||n,o=O(e),s=[],i=[];for(const t of e)for(const e of t.paths)null!=this.weightUrlConverter?i.push(this.weightUrlConverter(e)):s.push(a+e+r);this.weightUrlConverter&&s.push(...await Promise.all(i));return[o,$(await Ae(s,{requestInit:this.requestInit,fetchFunc:this.fetch,onProgress:this.onProgress}))]}}function Fe(e){return null!=e.match(Oe.URL_SCHEME_REGEX)}Oe.URL_SCHEME_REGEX=/^https?:\/\//;const De=(e,t)=>{if("undefined"==typeof fetch&&(null==t||null==t.fetchFunc))return null;{let n=!0;if(n=Array.isArray(e)?e.every(e=>Fe(e)):Fe(e),n)return Le(e,t)}return null};function Le(e,t){return new Oe(e,t)}function Me(e,t){return Le(e,t)}D.registerSaveRouter(De),D.registerLoadRouter(De);class Pe{constructor(e){this.modelArtifacts=e}load(){return this.modelArtifacts}}class Be{constructor(e){this.saveHandler=e}save(e){return this.saveHandler(e)}}class Ve{constructor(e){e.load&&(this.load=()=>Promise.resolve(e.load())),e.save&&(this.save=t=>Promise.resolve(e.save(t)))}}function ze(e,t,n,r){return new Ve(Ue(...arguments))}function Ue(e,t,n,r){if(1===arguments.length){const t=null!=e.modelTopology||null!=e.weightSpecs;return new Pe(t?e:{modelTopology:e})}return new Pe({modelTopology:e,weightSpecs:t,weightData:n,trainingConfig:r})}function We(e){return new Be(e)}function Ge(e){return new Be(e)}var je=n(62198),Ke=n(15441),He=n(37074),Ye=n(28189),Ze=n(70929),Xe=n(42768);let qe;function Qe(e,t=3){if(t>4)throw new Error("Cannot construct Tensor with more than 4 channels from pixels.");if(null==e)throw new Error("pixels passed to tf.browser.fromPixels() can not be null");let n=!1,r=!1,a=!1,o=!1,s=!1,i=!1;if(e.data instanceof Uint8Array)n=!0;else if("undefined"!=typeof ImageData&&e instanceof ImageData)r=!0;else if("undefined"!=typeof HTMLVideoElement&&e instanceof HTMLVideoElement)a=!0;else if("undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement)o=!0;else if(null!=e.getContext)s=!0;else{if(!("undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap))throw new Error(`pixels passed to tf.browser.fromPixels() must be either an HTMLVideoElement, HTMLImageElement, HTMLCanvasElement, ImageData in browser, or OffscreenCanvas, ImageData in webworker or {data: Uint32Array, width: number, height: number}, but was ${e.constructor.name}`);i=!0}if(null!=(0,He._5)(Ke.awo,l.T2.backendName)){const n={pixels:e},r={numChannels:t};return l.T2.runKernel(Ke.awo,n,r)}const[u,c]=a?[e.videoWidth,e.videoHeight]:[e.width,e.height];let p,h;if(s)p=e.getContext("2d").getImageData(0,0,u,c).data;else if(r||n)p=e.data;else if(o||a||i){if(null==qe)if("undefined"==typeof document){if("undefined"==typeof OffscreenCanvas||"undefined"==typeof OffscreenCanvasRenderingContext2D)throw new Error("Cannot parse input in current context. Reason: OffscreenCanvas Context2D rendering is not supported.");qe=new OffscreenCanvas(1,1).getContext("2d")}else qe=document.createElement("canvas").getContext("2d",{willReadFrequently:!0});qe.canvas.width=u,qe.canvas.height=c,qe.drawImage(e,0,0,u,c),p=qe.getImageData(0,0,u,c).data}if(4===t)h=new Int32Array(p);else{const e=u*c;h=new Int32Array(e*t);for(let n=0;n<e;n++)for(let e=0;e<t;++e)h[n*t+e]=p[4*n+e]}const d=[c,u,t];return(0,Xe.$)(h,d,"int32")}function Je(e){return"undefined"!=typeof window&&"undefined"!=typeof ImageBitmap&&window.hasOwnProperty("createImageBitmap")&&!(e instanceof ImageBitmap)&&function(e){return null!=e&&0!==e.width&&0!==e.height}(e)&&!function(e){return null!=e&&e.data instanceof Uint8Array}(e)}async function et(e,t=3){let n=null;if((0,m._K)().getBool("WRAP_TO_IMAGEBITMAP")&&Je(e)){let t;try{t=await createImageBitmap(e,{premultiplyAlpha:"none"})}catch(e){t=null}n=null!=t&&t.width===e.width&&t.height===e.height?t:e}else n=e;return Qe(n,t)}async function tt(e,t){let n=(0,Ye.YT)(e,"img","toPixels");if(!(e instanceof Se.qY)){const e=n;n=(0,ve.w)(e,"int32"),e.dispose()}
2if(2!==n.rank&&3!==n.rank)throw new Error(`toPixels only supports rank 2 or 3 tensors, got rank ${n.rank}.`);const[r,a]=n.shape.slice(0,2),o=2===n.rank?1:n.shape[2];if(o>4||2===o)throw new Error(`toPixels only supports depth of size 1, 3 or 4 but got ${o}`);if("float32"!==n.dtype&&"int32"!==n.dtype)throw new Error(`Unsupported type for toPixels: ${n.dtype}. Please use float32 or int32 tensors.`);const s=await n.data(),i="float32"===n.dtype?255:1,u=new Uint8ClampedArray(a*r*4);for(let e=0;e<r*a;++e){const t=[0,0,0,255];for(let r=0;r<o;r++){const a=s[e*o+r];if("float32"===n.dtype){if(a<0||a>1)throw new Error(`Tensor values for a float32 Tensor must be in the range [0 - 1] but encountered ${a}.`)}else if("int32"===n.dtype&&(a<0||a>255))throw new Error(`Tensor values for a int32 Tensor must be in the range [0 - 255] but encountered ${a}.`);1===o?(t[0]=a*i,t[1]=a*i,t[2]=a*i):t[r]=a*i}const r=4*e;u[r+0]=Math.round(t[0]),u[r+1]=Math.round(t[1]),u[r+2]=Math.round(t[2]),u[r+3]=Math.round(t[3])}if(null!=t){t.width=a,t.height=r;const e=t.getContext("2d"),n=new ImageData(u,a,r);e.putImageData(n,0,0)}return n!==e&&n.dispose(),u}const nt=(0,Ze.op)({fromPixels_:Qe}),rt=-2,at=-1;function ot(e,t,n){const r=e.shape.length;b.vA(r===t.length,()=>`Error in slice${r}D: Length of begin ${t} must match the rank of the array (${r}).`),b.vA(r===n.length,()=>`Error in slice${r}D: Length of size ${n} must match the rank of the array (${r}).`);for(let a=0;a<r;++a)b.vA(t[a]+n[a]<=e.shape[a],()=>`Error in slice${r}D: begin[${a}] + size[${a}] (${t[a]+n[a]}) would overflow input.shape[${a}] (${e.shape[a]})`)}function st(e){const t=[];let n=0;for(;e>0;)1&e&&t.push(n),e/=2,n++;return t}function it(e,t,n){const r=[];for(let a=0;a<e.length;a++)r[a]=Math.ceil((t[a]-e[a])/n[a]);return r}function ut(e,t,n,r){const a=[...e];for(let e=a.length;e<r.length;e++)a.push(1);for(let e=0;e<n;e++)0===e?a[t]=1:(a.splice(t,0,1),a.pop());return a}function ct(e,t,n){return n<=e?n:n-(t-1)}function lt(e,t){const n=[];for(let r=0;r<e;r++)n.push(t+r);return n}function pt(e,t,n,r,a,o,s,i,u){const c=e.length;let l=new Array(c),p=new Array(c),h=new Array(c);if(t.length&&n>0){const u=t[0],c=n+1;l=ht(s,u,c,r,e),p=dt(i,u,c,a,e),h=ut(o,u,c,e)}else for(let t=0;t<c;t++)l[t]=mt(s,r,o,e,t,u),p[t]=gt(i,a,o,e,t,u),h[t]=ft(o,t,u);return{begin:l,end:p,strides:h}}function ht(e,t,n,r,a){const o=[...a],s=lt(n,t);for(let a=0;a<o.length;a++)if(s.indexOf(a)>-1)o[a]=0;else{const s=ct(t,n,a);let i=r[s];e&1<<s&&(i=0),o[a]=i}return o}function dt(e,t,n,r,a){const o=[...a],s=lt(n,t);for(let a=0;a<o.length;a++)if(s.indexOf(a)>-1)o[a]=Number.MAX_SAFE_INTEGER;else{const s=ct(t,n,a);let i=r[s];e&1<<s&&(i=Number.MAX_SAFE_INTEGER),o[a]=i}for(let e=0;e<o.length;e++){const t=a[e];o[e]<0&&(o[e]+=t),o[e]=b.qE(0,o[e],a[e])}return o}function ft(e,t,n){let r=e[t];return(n&1<<t||null==r)&&(r=1),r}function mt(e,t,n,r,a,o){let s=t[a];const i=n[a]||1;(e&1<<a||o&1<<a||null==s)&&(s=i>0?Number.MIN_SAFE_INTEGER:Number.MAX_SAFE_INTEGER);const u=r[a];return s<0&&(s+=u),s=b.qE(0,s,u-1),s}function gt(e,t,n,r,a,o){let s=t[a];const i=n[a]||1;(e&1<<a||o&1<<a||null==s)&&(s=i>0?Number.MAX_SAFE_INTEGER:Number.MIN_SAFE_INTEGER);const u=r[a];return s<0&&(s+=u),s=i>0?b.qE(0,s,u):b.qE(-1,s,u-1),s}function yt(e,t,n){let r=n.length;for(let e=0;e<n.length;e++)if(n[e]>1){r=e;break}for(let a=r+1;a<n.length;a++)if(t[a]>0||n[a]!==e[a])return!1;return!0}function xt(e,t){let n=e.length>0?e[e.length-1]:1;for(let r=0;r<e.length-1;r++)n+=e[r]*t[r];return n}function bt(e,t,n){let r;const a=e.shape.length;let o;return r="number"==typeof t?[t,...new Array(a-1).fill(0)]:t.length<a?t.concat(new Array(a-t.length).fill(0)):t.slice(),r.forEach(e=>{b.vA(-1!==e,()=>"slice() does not support negative begin indexing.")}),o=null==n?new Array(a).fill(-1):"number"==typeof n?[n,...new Array(a-1).fill(-1)]:n.length<a?n.concat(new Array(a-n.length).fill(-1)):n,o=o.map((t,n)=>t>=0?t:(b.vA(-1===t,()=>`Negative size values should be exactly -1 but got ${t} for the slice() size at index ${n}.`),e.shape[n]-r[n])),[r,o]}function vt(e,t,n,r,a,o,s,i,u){let c;if(null==r?(c=new Array(t.length),c.fill(1)):c=r,null!=s&&s&s-1)throw new Error("Multiple ellipses in slice is not allowed.");let l=!1;const p={dims:c.length,numAddAxisAfterEllipsis:0,begin:t.slice(),end:n.slice(),strides:c.slice(),beginMask:a,endMask:o,ellipsisMask:s,newAxisMask:i,shrinkAxisMask:u};for(let e=0;e<p.dims;
vendor: 5,937 bytes, line 2
2e++)l&&1<<e&i&&p.numAddAxisAfterEllipsis++,1<<e&s&&(l=!0);l||(p.ellipsisMask|=1<<p.dims,p.dims++);const h={dims:e.length,beginMask:0,endMask:0,beginValid:!1,endValid:!1};!function(e,t){t.beginMask=0,t.endMask=0,t.shrinkAxisMask=0;let n=0;t.beginValid=null!=e.begin,t.endValid=null!=e.end,t.begin=new Array(t.dims),t.end=new Array(t.dims),t.strides=new Array(t.dims),t.finalShapeGatherIndices=[],t.finalShapeGatherIndicesSparse=[],t.inputShapeGatherIndicesSparse=new Array(t.dims);for(let r=0;r<e.dims;r++)if(1<<r&e.ellipsisMask){const a=Math.min(t.dims-(e.dims-r)+1+e.numAddAxisAfterEllipsis,t.dims);for(;n<a;n++)t.begin[n]=0,t.end[n]=0,t.strides[n]=1,t.beginMask|=1<<n,t.endMask|=1<<n,t.finalShapeGatherIndices.push(n),t.finalShapeGatherIndicesSparse.push(-1),t.inputShapeGatherIndicesSparse[n]=r}else if(1<<r&e.newAxisMask)t.finalShapeGatherIndices.push(rt),t.finalShapeGatherIndicesSparse.push(-1);else{if(n===t.begin.length)throw Error(`Index out of range using input dim ${n}; input has only ${t.dims} dims, ${t.begin.length}.`);null!=e.begin&&(t.begin[n]=e.begin[r]),null!=e.end&&(t.end[n]=e.end[r]),t.strides[n]=e.strides[r],e.beginMask&1<<r&&(t.beginMask|=1<<n),e.endMask&1<<r&&(t.endMask|=1<<n),e.shrinkAxisMask&1<<r?(t.finalShapeGatherIndices.push(at),t.finalShapeGatherIndicesSparse.push(-1),t.shrinkAxisMask|=1<<n):(t.finalShapeGatherIndices.push(n),t.finalShapeGatherIndicesSparse.push(r)),t.inputShapeGatherIndicesSparse[n]=r,n++}}(p,h);let d=!0,f=!0,m=!0;const g=[],y=[];for(let t=0;t<e.length;++t){if(0===h.strides[t])throw Error(`strides[${t}] must be non-zero`);const n=!!(h.shrinkAxisMask&1<<t),r=e[t];if(-1===r){g.push(n?1:-1);continue}const a=[h.beginMask&1<<t,h.endMask&1<<t],o=[h.strides[t]>0?0:-1,h.strides[t]>0?r:r-1];if(n&&h.strides[t]<=0)throw Error("only stride 1 allowed on non-range indexing.");m=m&&1===h.strides[t];const s=!!(h.beginMask&1<<t&&h.endMask&1<<t);if(h.beginValid&&h.endValid){if(n){const e=h.begin[t]<0?r+h.begin[t]:h.begin[t];if(h.begin[t]=e,h.end[t]=h.begin[t]+1,e<0||e>=r)throw Error(`slice index ${h.begin[t]} of dimension ${t} out of bounds.`)}else h.begin[t]=wt(h.begin[t],0,h.strides[t],r,a,o),h.end[t]=wt(h.end[t],1,h.strides[t],r,a,o);const e=1===h.strides[t]&&0===h.begin[t]&&h.end[t]===r;d=d&&e,f=f&&(0===t&&1===h.strides[t]||e)}else d=d&&1===h.strides[t]&&s,f=f&&(0===t&&1===h.strides[t]||s);let i,u=!1;if(h.beginValid&&h.endValid?(i=h.end[t]-h.begin[t],u=!0):n?(i=1,u=!0):s&&r>=0&&(i=h.strides[t]<0?-r:r,u=!0),u){let e;e=0===i||i<0!=h.strides[t]<0?0:Math.trunc(i/h.strides[t])+(i%h.strides[t]!==0?1:0),g.push(e)}else g.push(-1)}for(let e=0;e<h.finalShapeGatherIndices.length;++e){const t=h.finalShapeGatherIndices[e];t>=0?y.push(g[t]):t===rt&&y.push(1)}return{finalShapeSparse:y.filter((e,t)=>h.finalShapeGatherIndices[t]!==rt),finalShape:y,isIdentity:d,sliceDim0:f,isSimpleSlice:m,begin:h.begin,end:h.end,strides:h.strides}}function wt(e,t,n,r,a,o){if(a[t])return n>0?o[t]:o[t+1&1];{const t=e<0?r+e:e;return t<o[0]?o[0]:t>o[1]?o[1]:t}}var Tt=n(31259),St=n(52046),Ct=n(97856),kt=n(35287);const Et="undefined"!=typeof requestAnimationFrame?requestAnimationFrame:"undefined"!=typeof setImmediate?setImmediate:e=>e();function $t(){return new Promise(e=>Et(()=>e()))}var Nt=n(21078);function It(e,t){const n=e[0].length;e.forEach((e,t)=>{b.vA(e.length===n,()=>`Error in concat${n}D: rank of tensors[${t}] must be the same as the rank of the rest (${n})`)}),b.vA(t>=0&&t<n,()=>`Error in concat${n}D: axis must be between 0 and ${n-1}.`);const r=e[0];e.forEach((e,a)=>{for(let o=0;o<n;o++)b.vA(o===t||e[o]===r[o],()=>`Error in concat${n}D: Shape of tensors[${a}] (${e}) does not match the shape of the rest (${r}) along the non-concatenated axis ${a}.`)})}function At(e,t){const n=e[0].slice();for(let r=1;r<e.length;r++)n[t]+=e[r][t];return n}var Rt,_t=n(47195),Ot=n(68646);function Ft(e,t,n){let r=new Array;if(null==n&&null==t)return r;if(null==t)for(;r.length<e+n.length;)r.push(-1);else r=t.slice();if(null==n)return r;if(e+n.length!==r.length)throw new Error(`rt input.shape and shape=${t} are incompatible: rt input.rank = ${e+n.length}, but shape.rank = ${r.length}`);for(let a=1;a<n.length;++a){const o=n[a],s=r[r.length-n.length+a],i=r[s];if(o>=0)if(i>=0){if(i!==o)throw new Error(`rt input.shape and shape=${t} are incompatible: rt input.shape[${a+e}] = ${o} but shape[${a+e}] = ${i}`)}else r[s]=o}return r}function Dt(e){const t={FIRST_DIM_SIZE:Rt.FIRST_DIM_SIZE,VALUE_ROWIDS:Rt.VALUE_ROWIDS,ROW_LENGTHS:Rt.ROW_LENGTHS,ROW_SPLITS:Rt.ROW_SPLITS,ROW_LIMITS:Rt.ROW_LIMITS,ROW_STARTS:Rt.ROW_STARTS},n=[];for(const r of e){if(!(r in t))break;n.push(t[r])}return n}function Lt(e){return 0===e.length?0:e[0]===Rt.FIRST_DIM_SIZE?e.length-1:e.length}function Mt(e,t){if(null==e||null==t)return;const n=e.length,r=t.length;if(n>=r)throw new Error(`defaultValue.shape=${e} and ragged tensor flatValues.shape=${t}, are incompatible: defaultValue.rank = ${n} must be less than ragged tensor input flatValues.rank = ${r})`);for(let a=0;a<Math.min(n,r-1);++a){const n=e[a],r=t[a+1];if(n>=0&&r>=0&&1!==n&&n!==r)throw new Error(`defaultValue.shape=${e}, and ragged tensor input flatValues.shape=${t} are incompatible: defaultValue.shape[${a-e.length}] = ${n} but ragged tensor input.flatValues.shape[${a-e.length}] = ${r}`)}}!function(e){e[e.FIRST_DIM_SIZE=0]="FIRST_DIM_SIZE",e[e.VALUE_ROWIDS=1]="VALUE_ROWIDS",e[e.ROW_LENGTHS=2]="ROW_LENGTHS",e[e.ROW_SPLITS=3]="ROW_SPLITS",e[e.ROW_LIMITS=4]="ROW_LIMITS",e[e.ROW_STARTS=5]="ROW_STARTS"}(Rt||(Rt={}));const Pt=30;function Bt(e){return e<=Pt?e:(0,b.lK)(e,Math.floor(Math.sqrt(e)))}function Vt(e,t,n){return[n*("number"==typeof e?e:e[0]),t*("number"==typeof e?e:e[1])]}function zt(e,t,n,r=!0){let a=[];if(r)a=a.concat(t.slice(0)),a.push(e[0]/n),a=a.concat(e.slice(1));else{a=a.concat(e[0]);const n=t.length;for(let r=0;r<n;++r)a=a.concat([e[r+1]/t[r],t[r]]);a=a.concat(e.slice(n+1))}return a}function Ut(e,t,n=!0){const r=[];if(n){r.push(t);
2for(let n=t+1;n<e;++n)n<=2*t?(r.push(n),r.push(n-(t+1))):r.push(n)}else{const n=[],a=[];for(let r=1;r<e;++r)r>=2*t+1||r%2==1?a.push(r):n.push(r);r.push(...n),r.push(0),r.push(...a)}return r}function Wt(e,t,n,r=!0){const a=[];r?a.push(e[0]/n):a.push(e[0]*n);for(let n=1;n<e.length;++n)n<=t.length?r?a.push(t[n-1]*e[n]):a.push(e[n]/t[n-1]):a.push(e[n]);return a}function Gt(e,t){const n=[0];for(let r=0;r<t;++r)n.push(e[r][0]);return n}function jt(e,t,n){const r=e.slice(0,1);for(let a=0;a<n;++a)r.push(e[a+1]-t[a][0]-t[a][1]);return r}function Kt(e,t){const n=e.shape.length,r=t.shape.length;if(n<1)throw new Error(`tf.gatherND() expects the input to be rank 1 or higher, but the rank was ${n}.`);if(r<1)throw new Error(`tf.gatherND() expects the indices to be rank 1 or higher, but the rank was ${r}.`);if("int32"!==t.dtype)throw new Error(`tf.gatherND() expects the indices to be int32 type, but the dtype was ${t.dtype}.`);if(t.shape[r-1]>n)throw new Error(`index innermost dimension length must be <= tensor rank; saw: ${t.shape[r-1]} vs. ${n}`);if(0===(0,b.Ze)(e.shape))throw new Error(`Requested more than 0 entries, but input is empty. Input shape: ${e.shape}.`);const a=t.shape,o=a[a.length-1];let s=1;for(let e=0;e<a.length-1;++e)s*=a[e];const i=e.shape,u=a.slice();u.pop();let c=1;for(let e=o;e<n;++e)c*=i[e],u.push(i[e]);const l=[...(0,b.Ur)(e.shape).map(e=>e/c),1].slice(0,o);return[u,s,c,l]}var Ht=n(26170);const Yt=1.7580993408473768,Zt=1.0507009873554805,Xt=.3275911,qt=.254829592,Qt=-.284496736,Jt=1.421413741,en=-1.453152027,tn=1.061405429;var nn=n(73673);function rn(e,t){if(e.length!==t.length)throw new Error(`Cannot merge real and imag arrays of different lengths. real:${e.length}, imag: ${t.length}.`);const n=new Float32Array(2*e.length);for(let r=0;r<n.length;r+=2)n[r]=e[r/2],n[r+1]=t[r/2];return n}function an(e){const t=new Float32Array(e.length/2),n=new Float32Array(e.length/2);for(let r=0;r<e.length;r+=2)t[r/2]=e[r],n[r/2]=e[r+1];return{real:t,imag:n}}function on(e){const t=Math.ceil(e.length/4),n=new Float32Array(t),r=new Float32Array(t);for(let t=0;t<e.length;t+=4)n[Math.floor(t/4)]=e[t],r[Math.floor(t/4)]=e[t+1];return{real:n,imag:r}}function sn(e){const t=Math.floor(e.length/4),n=new Float32Array(t),r=new Float32Array(t);for(let t=2;t<e.length;t+=4)n[Math.floor(t/4)]=e[t],r[Math.floor(t/4)]=e[t+1];return{real:n,imag:r}}function un(e,t){return{real:e[2*t],imag:e[2*t+1]}}function cn(e,t,n,r){e[2*r]=t,e[2*r+1]=n}function ln(e,t){const n=new Float32Array(e/2),r=new Float32Array(e/2);for(let a=0;a<Math.ceil(e/2);a++){const o=(t?2:-2)*Math.PI*(a/e);n[a]=Math.cos(o),r[a]=Math.sin(o)}return{real:n,imag:r}}function pn(e,t,n){const r=(n?2:-2)*Math.PI*(e/t);return{real:Math.cos(r),imag:Math.sin(r)}}const hn="->",dn=/->/g,fn=",",mn="...";function gn(e,t){const n=((e=e.replace(/\s/g,"")).length-e.replace(dn,"").length)/hn.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 ("${hn}").`);const[r,a]=e.split(hn);(0,b.vA)(-1===r.indexOf(mn),()=>`The ellipsis notation ("${mn}") is not supported yet.`);const o=r.split(fn),s=o.length;if(t!==s)throw new Error(`Expected ${s} input tensors, received ${t}`);if(s>2)throw new Error("Support for more than 2 input tensors is not implemented yet.");const i=[];for(let e=0;e<a.length;++e){const t=a[e];if(!o.some(e=>-1!==e.indexOf(t)))throw new Error(`Output subscripts contain the label ${t} not present in the input subscripts.`);-1===i.indexOf(t)&&i.push(t)}for(let e=0;e<r.length;++e){const t=r[e];-1===i.indexOf(t)&&t!==fn&&i.push(t)}const u=new Array(o.length);for(let e=0;e<s;++e){if(new Set(o[e].split("")).size!==o[e].length)throw new Error(`Found duplicate axes in input component ${o[e]}. Support for duplicate axes in input is not implemented yet.`);u[e]=[];for(let t=0;t<o[e].length;++t)u[e].push(i.indexOf(o[e][t]))}const c=i.length,l=[];for(let e=a.length;e<c;++e)l.push(e);return{allDims:i,summedDims:l,idDims:u}}function yn(e,t){let n=new Array(e);n.fill(-1);for(let e=0;e<t.length;++e)n[t[e]]=e;const r=[];for(let t=0;t<e;++t)-1===n[t]&&r.push(t);return n=n.filter(e=>-1!==e),{permutationIndices:n,expandDims:r}}function xn(e,t,n){const r=new Array(e);for(let e=0;e<n.length;++e){const a=n[e].shape;for(let n=0;n<t[e].length;++n)void 0===r[t[e][n]]?r[t[e][n]]=a[n]:(0,b.vA)(r[t[e][n]]===a[n],()=>`Expected dimension ${r[t[e][n]]} at axis ${n} of input shaped ${JSON.stringify(a)}, but got dimension ${a[n]}`)}}function bn(e,t){const n=e,r=[];let a=0;0===e.length&&n.push(-1),a=e.length+1;for(let e=0;e<a;++e)r.push([]);const o=[];for(let e=0;e<n.length;++e){const a=wn(t,n[e]);for(const t of a)-1===o.indexOf(t)&&(r[e].push(t),o.push(t))}return{path:n,steps:r}}function vn(e){return e.every((e,t)=>e===t)}function wn(e,t){const n=[];for(let r=0;r<e.length;++r)0!==e[r].length&&-1===e[r].indexOf(t)&&-1!==t||n.push(r);return n}function Tn(e,t,n=0){let r=[];if("number"==typeof t)(0,b.vA)(e.shape[n]%t===0,()=>"Number of splits must evenly divide the axis."),r=new Array(t).fill(e.shape[n]/t);else{const a=t.reduce((e,t)=>
2(-1===t&&(e+=1),e),0);(0,b.vA)(a<=1,()=>"There should be only one negative value in split array.");const o=t.indexOf(-1);if(-1!==o){const r=t.reduce((e,t)=>t>0?e+t:e);t[o]=e.shape[n]-r}(0,b.vA)(e.shape[n]===t.reduce((e,t)=>e+t),()=>"The sum of sizes must match the size of the axis dimension."),r=t}return r}function Sn(e){return`Received SparseTensor with denseShape[0] = 0 but\n indices.shape[0] = ${e}`}function Cn(e,t){return`indices(${e}, 0) is invalid: ${t} < 0`}function kn(e,t,n){return`indices(${e}, 0) is invalid: ${t} >= ${n}`}function En(e,t){return`only one output dimension may be -1, not both ${e} and ${t}`}function $n(e,t){return`size ${e} must be non-negative, not ${t}`}function Nn(){return"reshape cannot infer the missing input size for an empty tensor unless all specified input sizes are non-zero"}function In(e,t){return`Input to reshape is a SparseTensor with ${(0,b.Ze)(e)}\n dense values, but the requested shape requires a multiple of ${(0,b.Ze)(t)}. inputShape=${e} outputShape= ${t}`}function An(e,t){return`Input to reshape is a tensor with ${(0,b.Ze)(e)} dense values, but the requested shape has ${(0,b.Ze)(t)}. inputShape=${e} outputShape=${t}`}function Rn(){return"segment ids must be >= 0"}function _n(){return"segment ids are not increasing"}function On(e,t){return`Segment id ${e} out of range [0, ${t}), possibly because segmentIds input is not sorted.`}function Fn(e,t,n){return`Bad: indices[${e}] == ${t} out of range [0, ${n})`}function Dn(e,t){let n,r=!1;for(e<=Pt?(n=e,r=!0):n=(0,b.lK)(e,Math.floor(Math.sqrt(e)));!r;)n>t||n===e?r=!0:n=(0,b.lK)(e,n+1);return n}function Ln(e,t,n){const r=[],a=e.length;for(let o=0;o<a;o++)o!==t?r.push(e[o]):r.push(n);return r}function Mn(e,t,n,r){const a=t.shape.length,o=e.shape.length;if(0!==r&&(r<-a||r>a))throw new Error(`Expect batchDims in the range of [-${a}, ${a}], but got ${r}`);if(r<0&&(r+=a),r>o)throw new Error(`batchDims (${r}) must be less than rank(x) (\n ${o}).`);if(n<r)throw new Error(`batchDims (${r}) must be less than or equal to axis (${n}).`);for(let n=0;n<r;++n)if(e.shape[n]!==t.shape[n])throw new Error(`x.shape[${n}]: ${e.shape[n]} should be equal to indices.shape[${n}]: ${t.shape[n]}.`);const s=e.shape[n],i=[];let u=1,c=1,l=1;for(let t=0;t<r;++t)i.push(e.shape[t]),u*=e.shape[t];for(let t=r;t<n;t++)i.push(e.shape[t]),c*=e.shape[t];for(let e=r;e<a;e++)i.push(t.shape[e]);for(let t=n+1;t<o;t++)i.push(e.shape[t]),l*=e.shape[t];return{batchSize:u,sliceSize:l,outerSize:c,dimSize:s,outputShape:i}}function Pn(e){try{return e.map(e=>(0,Tt.decodeString)(e))}catch(e){throw new Error(`Failed to decode encoded string bytes into utf-8, error: ${e}`)}}function Bn(e){return e.map(e=>(0,Tt.encodeString)(e))}var Vn=n(43303),zn=n(54411),Un=n(15149)},83416:function(e,t,n){"use strict";n.d(t,{P:function(){return s}});var r=n(57260),a=n(15441),o=n(28189);const s=(0,n(70929).op)({elu_:function(e){const t={x:(0,o.YT)(e,"x","elu","float32")};return r.T2.runKernel(a.Pah,t)}})},83732:function(e,t,n){"use strict";n.d(t,{j:function(){return s}});var r=n(57260),a=n(15441),o=n(28189);const s=(0,n(70929).op)({relu6_:function(e){const t={x:(0,o.YT)(e,"x","relu6")};return r.T2.runKernel(a.P_L,t)}})},83791:function(e,t,n){"use strict";n.d(t,{c:function(){return i}});var r=n(57260),a=n(15441),o=n(28189),s=n(29809);const i=(0,n(70929).op)({sum_:function(e,t=null,n=!1){let i=(0,o.YT)(e,"x","sum");"bool"===i.dtype&&(i=(0,s.w)(i,"int32"));const u={x:i},c={axis:t,keepDims:n};return r.T2.runKernel(a.WuN,u,c)}})},90112:function(e,t,n){"use strict";n.d(t,{V:function(){return s}});var r=n(57260),a=n(15441),o=n(28189);const s=(0,n(70929).op)({relu_:function(e){const t={x:(0,o.YT)(e,"x","relu")};return r.T2.runKernel(a.fUj,t)}})},93476:function(e,t,n){"use strict";n.d(t,{Fz:function(){return Ne},JZ:function(){return pe}});var r=n(62726),a=n(77367),o=n(28059),s=function(){return s=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var a in t=arguments[n])Object.prototype.hasOwnProperty.call(t,a)&&(e[a]=t[a]);return e},s.apply(this,arguments)};
2function i(e,t,n,r){return new(n||(n=Promise))(function(a,o){function s(e){try{u(r.next(e))}catch(e){o(e)}}function i(e){try{u(r.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?a(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,i)}u((r=r.apply(e,t||[])).next())})}function u(e,t){var n,r,a,o,s={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return o={next:i(0),throw:i(1),return:i(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function i(o){return function(i){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(a=2&o[0]?r.return:o[0]?r.throw||((a=r.return)&&a.call(r),0):r.next)&&!(a=a.call(r,o[1])).done)return a;switch(r=0,a&&(o=[2&o[0],a.value]),o[0]){case 0:case 1:a=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,r=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!((a=(a=s.trys).length>0&&a[a.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!a||o[1]>a[0]&&o[1]<a[3])){s.label=o[1];break}if(6===o[0]&&s.label<a[1]){s.label=a[1],a=o;break}if(a&&s.label<a[2]){s.label=a[2],s.ops.push(o);break}a[2]&&s.ops.pop(),s.trys.pop();continue}o=t.call(e,s)}catch(e){o=[6,e],r=0}finally{n=a=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,i])}}}function c(e){var t=e.map(function(e){return e[0]});return t.push(e[e.length-1][1]),t}var l={lips:c([[61,146],[146,91],[91,181],[181,84],[84,17],[17,314],[314,405],[405,321],[321,375],[375,291],[61,185],[185,40],[40,39],[39,37],[37,0],[0,267],[267,269],[269,270],[270,409],[409,291],[78,95],[95,88],[88,178],[178,87],[87,14],[14,317],[317,402],[402,318],[318,324],[324,308],[78,191],[191,80],[80,81],[81,82],[82,13],[13,312],[312,311],[311,310],[310,415],[415,308]]),leftEye:c([[263,249],[249,390],[390,373],[373,374],[374,380],[380,381],[381,382],[382,362],[263,466],[466,388],[388,387],[387,386],[386,385],[385,384],[384,398],[398,362]]),leftEyebrow:c([[276,283],[283,282],[282,295],[295,285],[300,293],[293,334],[334,296],[296,336]]),leftIris:c([[474,475],[475,476],[476,477],[477,474]]),rightEye:c([[33,7],[7,163],[163,144],[144,145],[145,153],[153,154],[154,155],[155,133],[33,246],[246,161],[161,160],[160,159],[159,158],[158,157],[157,173],[173,133]]),rightEyebrow:c([[46,53],[53,52],[52,65],[65,55],[70,63],[63,105],[105,66],[66,107]]),rightIris:c([[469,470],[470,471],[471,472],[472,469]]),faceOval:c([[10,338],[338,297],[297,332],[332,284],[284,251],[251,389],[389,356],[356,454],[454,323],[323,361],[361,288],[288,397],[397,365],[365,379],[379,378],[378,400],[400,377],[377,152],[152,148],[148,176],[176,149],[149,150],[150,136],[136,172],[172,58],[58,132],[132,93],[93,234],[234,127],[127,162],[162,21],[21,54],[54,103],[103,67],[67,109],[109,10]])},p=
vendor: 24,343 bytes, line 2
2[[127,34],[34,139],[139,127],[11,0],[0,37],[37,11],[232,231],[231,120],[120,232],[72,37],[37,39],[39,72],[128,121],[121,47],[47,128],[232,121],[121,128],[128,232],[104,69],[69,67],[67,104],[175,171],[171,148],[148,175],[118,50],[50,101],[101,118],[73,39],[39,40],[40,73],[9,151],[151,108],[108,9],[48,115],[115,131],[131,48],[194,204],[204,211],[211,194],[74,40],[40,185],[185,74],[80,42],[42,183],[183,80],[40,92],[92,186],[186,40],[230,229],[229,118],[118,230],[202,212],[212,214],[214,202],[83,18],[18,17],[17,83],[76,61],[61,146],[146,76],[160,29],[29,30],[30,160],[56,157],[157,173],[173,56],[106,204],[204,194],[194,106],[135,214],[214,192],[192,135],[203,165],[165,98],[98,203],[21,71],[71,68],[68,21],[51,45],[45,4],[4,51],[144,24],[24,23],[23,144],[77,146],[146,91],[91,77],[205,50],[50,187],[187,205],[201,200],[200,18],[18,201],[91,106],[106,182],[182,91],[90,91],[91,181],[181,90],[85,84],[84,17],[17,85],[206,203],[203,36],[36,206],[148,171],[171,140],[140,148],[92,40],[40,39],[39,92],[193,189],[189,244],[244,193],[159,158],[158,28],[28,159],[247,246],[246,161],[161,247],[236,3],[3,196],[196,236],[54,68],[68,104],[104,54],[193,168],[168,8],[8,193],[117,228],[228,31],[31,117],[189,193],[193,55],[55,189],[98,97],[97,99],[99,98],[126,47],[47,100],[100,126],[166,79],[79,218],[218,166],[155,154],[154,26],[26,155],[209,49],[49,131],[131,209],[135,136],[136,150],[150,135],[47,126],[126,217],[217,47],[223,52],[52,53],[53,223],[45,51],[51,134],[134,45],[211,170],[170,140],[140,211],[67,69],[69,108],[108,67],[43,106],[106,91],[91,43],[230,119],[119,120],[120,230],[226,130],[130,247],[247,226],[63,53],[53,52],[52,63],[238,20],[20,242],[242,238],[46,70],[70,156],[156,46],[78,62],[62,96],[96,78],[46,53],[53,63],[63,46],[143,34],[34,227],[227,143],[123,117],[117,111],[111,123],[44,125],[125,19],[19,44],[236,134],[134,51],[51,236],[216,206],[206,205],[205,216],[154,153],[153,22],[22,154],[39,37],[37,167],[167,39],[200,201],[201,208],[208,200],[36,142],[142,100],[100,36],[57,212],[212,202],[202,57],[20,60],[60,99],[99,20],[28,158],[158,157],[157,28],[35,226],[226,113],[113,35],[160,159],[159,27],[27,160],[204,202],[202,210],[210,204],[113,225],[225,46],[46,113],[43,202],[202,204],[204,43],[62,76],[76,77],[77,62],[137,123],[123,116],[116,137],[41,38],[38,72],[72,41],[203,129],[129,142],[142,203],[64,98],[98,240],[240,64],[49,102],[102,64],[64,49],[41,73],[73,74],[74,41],[212,216],[216,207],[207,212],[42,74],[74,184],[184,42],[169,170],[170,211],[211,169],[170,149],[149,176],[176,170],[105,66],[66,69],[69,105],[122,6],[6,168],[168,122],[123,147],[147,187],[187,123],[96,77],[77,90],[90,96],[65,55],[55,107],[107,65],[89,90],[90,180],[180,89],[101,100],[100,120],[120,101],[63,105],[105,104],[104,63],[93,137],[137,227],[227,93],[15,86],[86,85],[85,15],[129,102],[102,49],[49,129],[14,87],[87,86],[86,14],[55,8],[8,9],[9,55],[100,47],[47,121],[121,100],[145,23],[23,22],[22,145],[88,89],[89,179],[179,88],[6,122],[122,196],[196,6],[88,95],[95,96],[96,88],[138,172],[172,136],[136,138],[215,58],[58,172],[172,215],[115,48],[48,219],[219,115],[42,80],[80,81],[81,42],[195,3],[3,51],[51,195],[43,146],[146,61],[61,43],[171,175],[175,199],[199,171],[81,82],[82,38],[38,81],[53,46],[46,225],[225,53],[144,163],[163,110],[110,144],[52,65],[65,66],[66,52],[229,228],[228,117],[117,229],[34,127],[127,234],[234,34],[107,108],[108,69],[69,107],[109,108],[108,151],[151,109],[48,64],[64,235],[235,48],[62,78],[78,191],[191,62],[129,209],[209,126],[126,129],[111,35],[35,143],[143,111],[117,123],[123,50],[50,117],[222,65],[65,52],[52,222],[19,125],[125,141],[141,19],[221,55],[55,65],[65,221],[3,195],[195,197],[197,3],[25,7],[7,33],[33,25],[220,237],[237,44],[44,220],[70,71],[71,139],[139,70],[122,193],[193,245],[245,122],[247,130],[130,33],[33,247],[71,21],[21,162],[162,71],[170,169],[169,150],[150,170],[188,174],[174,196],[196,188],[216,186],[186,92],[92,216],[2,97],[97,167],[167,2],[141,125],[125,241],[241,141],[164,167],[167,37],[37,164],[72,38],[38,12],[12,72],[38,82],[82,13],[13,38],[63,68],[68,71],[71,63],[226,35],[35,111],[111,226],[101,50],[50,205],[205,101],[206,92],[92,165],[165,206],[209,198],[198,217],[217,209],[165,167],[167,97],[97,165],[220,115],[115,218],[218,220],[133,112],[112,243],[243,133],[239,238],[238,241],[241,239],[214,135],[135,169],[169,214],[190,173],[173,133],[133,190],[171,208],[208,32],[32,171],[125,44],[44,237],[237,125],[86,87],[87,178],[178,86],[85,86],[86,179],[179,85],[84,85],[85,180],[180,84],[83,84],[84,181],[181,83],[201,83],[83,182],[182,201],[137,93],[93,132],[132,137],[76,62],[62,183],[183,76],[61,76],[76,184],[184,61],[57,61],[61,185],[185,57],[212,57],[57,186],[186,212],[214,207],[207,187],[187,214],[34,143],[143,156],[156,34],[79,239],[239,237],[237,79],[123,137],[137,177],[177,123],[44,1],[1,4],[4,44],[201,194],[194,32],[32,201],[64,102],[102,129],[129,64],[213,215],[215,138],[138,213],[59,166],[166,219],[219,59],[242,99],[99,97],[97,242],[2,94],[94,141],[141,2],[75,59],[59,235],[235,75],[24,110],[110,228],[228,24],[25,130],[130,226],[226,25],[23,24],[24,229],[229,23],[22,23],[23,230],[230,22],[26,22],[22,231],[231,26],[112,26],[26,232],[232,112],[189,190],[190,243],[243,189],[221,56],[56,190],[190,221],[28,56],[56,221],[221,28],[27,28],[28,222],[222,27],[29,27],[27,223],[223,29],[30,29],[29,224],[224,30],[247,30],[30,225],[225,247],[238,79],[79,20],[20,238],[166,59],[59,75],[75,166],[60,75],[75,240],[240,60],[147,177],[177,215],[215,147],[20,79],[79,166],[166,20],[187,147],[147,213],[213,187],[112,233],[233,244],[244,112],[233,128],[128,245],[245,233],[128,114],[114,188],[188,128],[114,217],[217,174],[174,114],[131,115],[115,220],[220,131],[217,198],[198,236],[236,217],[198,131],[131,134],[134,198],[177,132],[132,58],[58,177],[143,35],[35,124],[124,143],[110,163],[163,7],[7,110],[228,110],[110,25],[25,228],[356,389],[389,368],[368,356],[11,302],[302,267],[267,11],[452,350],[350,349],[349,452],[302,303],[303,269],[269,302],[357,343],[343,277],[277,357],[452,453],[453,357],[357,452],[333,332],[332,297],[297,333],[175,152],[152,377],[377,175],[347,348],[348,330],[330,347],[303,304],[304,270],[270,303],[9,336],[336,337],[337,9],[278,279],[279,360],[360,278],[418,262],[262,431],[431,418],[304,408],[408,409],[409,304],[310,415],[415,407],[407,310],[270,409],[409,410],[410,270],[450,348],[348,347],[347,450],[422,430],[430,434],[434,422],[313,314],[314,17],[17,313],[306,307],[307,375],[375,306],[387,388],[388,260],[260,387],[286,414],[414,398],[398,286],[335,406],[406,418],[418,335],[364,367],[367,416],[416,364],[423,358],[358,327],[327,423],[251,284],[284,298],[298,251],[281,5],[5,4],[4,281],[373,374],[374,253],[253,373],[307,320],[320,321],[321,307],[425,427],[427,411],[411,425],[421,313],[313,18],[18,421],[321,405],[405,406],[406,321],[320,404],[404,405],[405,320],[315,16],[16,17],[17,315],[426,425],[425,266],[266,426],[377,400],[400,369],[369,377],[322,391],[391,269],[269,322],[417,465],[465,464],[464,417],[386,257],[257,258],[258,386],[466,260],[260,388],[388,466],[456,399],[399,419],[419,456],[284,332],[332,333],[333,284],[417,285],[285,8],[8,417],[346,340],[340,261],[261,346],[413,441],[441,285],[285,413],[327,460],[460,328],[328,327],[355,371],[371,329],[329,355],[392,439],[439,438],[438,392],[382,341],[341,256],[256,382],[429,420],[420,360],[360,429],[364,394],[394,379],[379,364],[277,343],[343,437],[437,277],[443,444],[444,283],[283,443],[275,440],[440,363],[363,275],[431,262],[262,369],[369,431],[297,338],[338,337],[337,297],[273,375],[375,321],[321,273],[450,451],[451,349],[349,450],[446,342],[342,467],[467,446],[293,334],[334,282],[282,293],[458,461],[461,462],[462,458],[276,353],[353,383],[383,276],[308,324],[324,325],[325,308],[276,300],[300,293],[293,276],[372,345],[345,447],[447,372],[352,345],[345,340],[340,352],[274,1],[1,19],[19,274],[456,248],[248,281],[281,456],[436,427],[427,425],[425,436],[381,256],[256,252],[252,381],[269,391],[391,393],[393,269],[200,199],[199,428],[428,200],[266,330],[330,329],[329,266],[287,273],[273,422],[422,287],[250,462],[462,328],[328,250],[258,286],[286,384],[384,258],[265,353],[353,342],[342,265],[387,259],[259,257],[257,387],[424,431],[431,430],[430,424],[342,353],[353,276],[276,342],[273,335],[335,424],[424,273],[292,325],[325,307],[307,292],[366,447],[447,345],[345,366],[271,303],[303,302],[302,271],[423,266],[266,371],[371,423],[294,455],[455,460],[460,294],[279,278],[278,294],[294,279],[271,272],[272,304],[304,271],[432,434],[434,427],[427,432],[272,407],[407,408],[408,272],[394,430],[430,431],[431,394],[395,369],[369,400],[400,395],[334,333],[333,299],[299,334],[351,417],[417,168],[168,351],[352,280],[280,411],[411,352],[325,319],[319,320],[320,325],[295,296],[296,336],[336,295],[319,403],[403,404],[404,319],[330,348],[348,349],[349,330],[293,298],[298,333],[333,293],[323,454],[454,447],[447,323],[15,16],[16,315],[315,15],[358,429],[429,279],[279,358],[14,15],[15,316],[316,14],[285,336],[336,9],[9,285],[329,349],[349,350],[350,329],[374,380],[380,252],[252,374],[318,402],[402,403],[403,318],[6,197],[197,419],[419,6],[318,319],[319,325],[325,318],[367,364],[364,365],[365,367],[435,367],[367,397],[397,435],[344,438],[438,439],[439,344],[272,271],[271,311],[311,272],[195,5],[5,281],[281,195],[273,287],[287,291],[291,273],[396,428],[428,199],[199,396],[311,271],[271,268],[268,311],[283,444],[444,445],[445,283],[373,254],[254,339],[339,373],[282,334],[334,296],[296,282],[449,347],[347,346],[346,449],[264,447],[447,454],[454,264],[336,296],[296,299],[299,336],[338,10],[10,151],[151,338],[278,439],[439,455],[455,278],[292,407],[407,415],[415,292],[358,371],[371,355],[355,358],[340,345],[345,372],[372,340],[346,347],[347,280],[280,346],[442,443],[443,282],[282,442],[19,94],[94,370],[370,19],[441,442],[442,295],[295,441],[248,419],[419,197],[197,248],[263,255],[255,359],[359,263],[440,275],[275,274],[274,440],[300,383],[383,368],[368,300],[351,412],[412,465],[465,351],[263,467],[467,466],[466,263],[301,368],[368,389],[389,301],[395,378],[378,379],[379,395],[412,351],[351,419],[419,412],[436,426],[426,322],[322,436],[2,164],[164,393],[393,2],[370,462],[462,461],[461,370],[164,0],[0,267],[267,164],[302,11],[11,12],[12,302],[268,12],[12,13],[13,268],[293,300],[300,301],[301,293],[446,261],[261,340],[340,446],[330,266],[266,425],[425,330],[426,423],[423,391],[391,426],[429,355],[355,437],[437,429],[391,327],[327,326],[326,391],[440,457],[457,438],[438,440],[341,382],[382,362],[362,341],[459,457],[457,461],[461,459],[434,430],[430,394],[394,434],[414,463],[463,362],[362,414],[396,369],[369,262],[262,396],[354,461],[461,457],[457,354],[316,403],[403,402],[402,316],[315,404],[404,403],[403,315],[314,405],[405,404],[404,314],[313,406],[406,405],[405,313],[421,418],[418,406],[406,421],[366,401],[401,361],[361,366],[306,408],[408,407],[407,306],[291,409],[409,408],[408,291],[287,410],[410,409],[409,287],[432,436],[436,410],[410,432],[434,416],[416,411],[411,434],[264,368],[368,383],[383,264],[309,438],[438,457],[457,309],[352,376],[376,401],[401,352],[274,275],[275,4],[4,274],[421,428],[428,262],[262,421],[294,327],[327,358],[358,294],[433,416],[416,367],[367,433],[289,455],[455,439],[439,289],[462,370],[370,326],[326,462],[2,326],[326,370],[370,2],[305,460],[460,455],[455,305],[254,449],[449,448],[448,254],[255,261],[261,446],[446,255],[253,450],[450,449],[449,253],[252,451],[451,450],[450,252],[256,452],[452,451],[451,256],[341,453],[453,452],[452,341],[413,464],[464,463],[463,413],[441,413],[413,414],[414,441],[258,442],[442,441],[441,258],[257,443],[443,442],[442,257],[259,444],[444,443],[443,259],[260,445],[445,444],[444,260],[467,342],[342,445],[445,467],[459,458],[458,250],[250,459],[289,392],[392,290],[290,289],[290,328],[328,460],[460,290],[376,433],[433,435],[435,376],[250,290],[290,392],[392,250],[411,416],[416,433],[433,411],[341,463],[463,464],[464,341],[453,464],[464,465],[465,453],[357,465],[465,412],[412,357],[343,412],[412,399],[399,343],[360,363],[363,440],[440,360],[437,399],[399,456],[456,437],[420,456],[456,363],[363,420],[401,435],[435,288],[288,401],[372,383],[383,353],[353,372],[339,255],[255,249],[249,339],[448,261],[261,255],[255,448],[133,243],[243,190],[190,133],[133,155],[155,112],[112,133],[33,246],[246,247],[247,33],[33,130],[130,25],[25,33],[398,384],[384,286],[286,398],[362,398],[398,414],[414,362],[362,463],[463,341],[341,362],[263,359],[359,467],[467,263],[263,249],[249,255],[255,263],[466,467],[467,260],[260,466],[75,60],[60,166],[166,75],[238,239],[239,79],[79,238],[162,127],[127,139],[139,162],[72,11],[11,37],[37,72],[121,232],[232,120],[120,121],[73,72],[72,39],[39,73],[114,128],[128,47],[47,114],[233,232],[232,128],[128,233],[103,104],[104,67],[67,103],[152,175],[175,148],[148,152],[119,118],[118,101],[101,119],[74,73],[73,40],[40,74],[107,9],[9,108],[108,107],[49,48],[48,131],[131,49],[32,194],[194,211],[211,32],[184,74],[74,185],[185,184],[191,80],[80,183],[183,191],[185,40],[40,186],[186,185],[119,230],[230,118],[118,119],[210,202],[202,214],[214,210],[84,83],[83,17],[17,84],[77,76],[76,146],[146,77],[161,160],[160,30],[30,161],[190,56],[56,173],[173,190],[182,106],[106,194],[194,182],[138,135],[135,192],[192,138],[129,203],[203,98],[98,129],[54,21],[21,68],[68,54],[5,51],[51,4],[4,5],[145,144],[144,23],[23,145],[90,77],[77,91],[91,90],[207,205],[205,187],[187,207],[83,201],[201,18],[18,83],[181,91],[91,182],[182,181],[180,90],[90,181],[181,180],[16,85],[85,17],[17,16],[205,206],[206,36],[36,205],[176,148],[148,140],[140,176],[165,92],[92,39],[39,165],[245,193],[193,244],[244,245],[27,159],[159,28],[28,27],[30,247],[247,161],[161,30],[174,236],[236,196],[196,174],[103,54],[54,104],[104,103],[55,193],[193,8],[8,55],[111,117],[117,31],[31,111],[221,189],[189,55],[55,221],[240,98],[98,99],[99,240],[142,126],[126,100],[100,142],[219,166],[166,218],[218,219],[112,155],[155,26],[26,112],[198,209],[209,131],[131,198],[169,135],[135,150],[150,169],[114,47],[47,217],[217,114],[224,223],[223,53],[53,224],[220,45],[45,134],[134,220],[32,211],[211,140],[140,32],[109,67],[67,108],[108,109],[146,43],[43,91],[91,146],[231,230],[230,120],[120,231],[113,226],[226,247],[247,113],[105,63],[63,52],[52,105],[241,238],[238,242],[242,241],[124,46],[46,156],[156,124],[95,78],[78,96],[96,95],[70,46],[46,63],[63,70],[116,143],[143,227],[227,116],[116,123],[123,111],[111,116],[1,44],[44,19],[19,1],[3,236],[236,51],[51,3],[207,216],[216,205],[205,207],[26,154],[154,22],[22,26],[165,39],[39,167],[167,165],[199,200],[200,208],[208,199],[101,36],[36,100],[100,101],[43,57],[57,202],[202,43],[242,20],[20,99],[99,242],[56,28],[28,157],[157,56],[124,35],[35,113],[113,124],[29,160],[160,27],[27,29],[211,204],[204,210],[210,211],[124,113],[113,46],[46,124],[106,43],[43,204],[204,106],[96,62],[62,77],[77,96],[227,137],[137,116],[116,227],[73,41],[41,72],[72,73],[36,203],[203,142],[142,36],[235,64],[64,240],[240,235],[48,49],[49,64],[64,48],[42,41],[41,74],[74,42],[214,212],[212,207],[207,214],[183,42],[42,184],[184,183],[210,169],[169,211],[211,210],[140,170],[170,176],[176,140],[104,105],[105,69],[69,104],[193,122],[122,168],[168,193],[50,123],[123,187],[187,50],[89,96],[96,90],[90,89],[66,65],[65,107],[107,66],[179,89],[89,180],[180,179],[119,101],[101,120],[120,119],[68,63],[63,104],[104,68],[234,93],[93,227],[227,234],[16,15],[15,85],[85,16],[209,129],[129,49],[49,209],[15,14],[14,86],[86,15],[107,55],[55,9],[9,107],[120,100],[100,121],[121,120],[153,145],[145,22],[22,153],[178,88],[88,179],[179,178],[197,6],[6,196],[196,197],[89,88],[88,96],[96,89],[135,138],[138,136],[136,135],[138,215],[215,172],[172,138],[218,115],[115,219],[219,218],[41,42],[42,81],[81,41],[5,195],[195,51],[51,5],[57,43],[43,61],[61,57],[208,171],[171,199],[199,208],[41,81],[81,38],[38,41],[224,53],[53,225],[225,224],[24,144],[144,110],[110,24],[105,52],[52,66],[66,105],[118,229],[229,117],[117,118],[227,34],[34,234],[234,227],[66,107],[107,69],[69,66],[10,109],[109,151],[151,10],[219,48],[48,235],[235,219],[183,62],[62,191],[191,183],[142,129],[129,126],[126,142],[116,111],[111,143],[143,116],[118,117],[117,50],[50,118],[223,222],[222,52],[52,223],[94,19],[19,141],[141,94],[222,221],[221,65],[65,222],[196,3],[3,197],[197,196],[45,220],[220,44],[44,45],[156,70],[70,139],[139,156],[188,122],[122,245],[245,188],[139,71],[71,162],[162,139],[149,170],[170,150],[150,149],[122,188],[188,196],[196,122],[206,216],[216,92],[92,206],[164,2],[2,167],[167,164],[242,141],[141,241],[241,242],[0,164],[164,37],[37,0],[11,72],[72,12],[12,11],[12,38],[38,13],[13,12],[70,63],[63,71],[71,70],[31,226],[226,111],[111,31],[36,101],[101,205],[205,36],[203,206],[206,165],[165,203],[126,209],[209,217],[217,126],[98,165],[165,97],[97,98],[237,220],[220,218],[218,237],[237,239],[239,241],[241,237],[210,214],[214,169],[169,210],[140,171],[171,32],[32,140],[241,125],[125,237],[237,241],[179,86],[86,178],[178,179],[180,85],[85,179],[179,180],[181,84],[84,180],[180,181],[182,83],[83,181],[181,182],[194,201],[201,182],[182,194],[177,137],[137,132],[132,177],[184,76],[76,183],[183,184],[185,61],[61,184],[184,185],[186,57],[57,185],[185,186],[216,212],[212,186],[186,216],[192,214],[214,187],[187,192],[139,34],[34,156],[156,139],[218,79],[79,237],[237,218],[147,123],[123,177],[177,147],[45,44],[44,4],[4,45],[208,201],[201,32],[32,208],[98,64],[64,129],[129,98],[192,213],[213,138],[138,192],[235,59],[59,219],[219,235],[141,242],[242,97],[97,141],[97,2],[2,141],[141,97],[240,75],[75,235],[235,240],[229,24],[24,228],[228,229],[31,25],[25,226],[226,31],[230,23],[23,229],[229,230],[231,22],[22,230],[230,231],[232,26],[26,231],[231,232],[233,112],[112,232],[232,233],[244,189],[189,243],[243,244],[189,221],[221,190],[190,189],[222,28],[28,221],[221,222],[223,27],[27,222],[222,223],[224,29],[29,223],[223,224],[225,30],[30,224],[224,225],[113,247],[247,225],[225,113],[99,60],[60,240],[240,99],[213,147],[147,215],[215,213],[60,20],[20,166],[166,60],[192,187],[187,213],[213,192],[243,112],[112,244],[244,243],[244,233],[233,245],[245,244],[245,128],[128,188],[188,245],[188,114],[114,174],[174,188],[134,131],[131,220],[220,134],[174,217],[217,236],[236,174],[236,198],[198,134],[134,236],[215,177],[177,58],[58,215],[156,143],[143,124],[124,156],[25,110],[110,7],[7,25],[31,228],[228,25],[25,31],[264,356],[356,368],[368,264],[0,11],[11,267],[267,0],[451,452],[452,349],[349,451],[267,302],[302,269],[269,267],[350,357],[357,277],[277,350],[350,452],[452,357],[357,350],[299,333],[333,297],[297,299],[396,175],[175,377],[377,396],[280,347],[347,330],[330,280],[269,303],[303,270],[270,269],[151,9],[9,337],[337,151],[344,278],[278,360],[360,344],[424,418],[418,431],[431,424],[270,304],[304,409],[409,270],[272,310],[310,407],[407,272],[322,270],[270,410],[410,322],[449,450],[450,347],[347,449],[432,422],[422,434],[434,432],[18,313],[313,17],[17,18],[291,306],[306,375],[375,291],[259,387],[387,260],[260,259],[424,335],[335,418],[418,424],[434,364],[364,416],[416,434],[391,423],[423,327],[327,391],[301,251],[251,298],[298,301],[275,281],[281,4],[4,275],[254,373],[373,253],[253,254],[375,307],[307,321],[321,375],[280,425],[425,411],[411,280],[200,421],[421,18],[18,200],[335,321],[321,406],[406,335],[321,320],[320,405],[405,321],[314,315],[315,17],[17,314],[423,426],[426,266],[266,423],[396,377],[377,369],[369,396],[270,322],[322,269],[269,270],[413,417],[417,464],[464,413],[385,386],[386,258],[258,385],[248,456],[456,419],[419,248],[298,284],[284,333],[333,298],[168,417],[417,8],[8,168],[448,346],[346,261],[261,448],[417,413],[413,285],[285,417],[326,327],[327,328],[328,326],[277,355],[355,329],[329,277],[309,392],[392,438],[438,309],[381,382],[382,256],[256,381],[279,429],[429,360],[360,279],[365,364],[364,379],[379,365],[355,277],[277,437],[437,355],[282,443],[443,283],[283,282],[281,275],[275,363],[363,281],[395,431],[431,369],[369,395],[299,297],[297,337],[337,299],[335,273],[273,321],[321,335],[348,450],[450,349],[349,348],[359,446],[446,467],[467,359],[283,293],[293,282],[282,283],[250,458],[458,462],[462,250],[300,276],[276,383],[383,300],[292,308],[308,325],[325,292],[283,276],[276,293],[293,283],[264,372],[372,447],[447,264],[346,352],[352,340],[340,346],[354,274],[274,19],[19,354],[363,456],[456,281],[281,363],[426,436],[436,425],[425,426],[380,381],[381,252],[252,380],[267,269],[269,393],[393,267],[421,200],[200,428],[428,421],[371,266],[266,329],[329,371],[432,287],[287,422],[422,432],[290,250],[250,328],[328,290],[385,258],[258,384],[384,385],[446,265],[265,342],[342,446],[386,387],[387,257],[257,386],[422,424],[424,430],[430,422],[445,342],[342,276],[276,445],[422,273],[273,424],[424,422],[306,292],[292,307],[307,306],[352,366],[366,345],[345,352],[268,271],[271,302],[302,268],[358,423],[423,371],[371,358],[327,294],[294,460],[460,327],[331,279],[279,294],[294,331],[303,271],[271,304],[304,303],[436,432],[432,427],[427,436],[304,272],[272,408],[408,304],[395,394],[394,431],[431,395],[378,395],[395,400],[400,378],[296,334],[334,299],[299,296],[6,351],[351,168],[168,6],[376,352],[352,411],[411,376],[307,325],[325,320],[320,307],[285,295],[295,336],[336,285],[320,319],[319,404],[404,320],[329,330],[330,349],[349,329],[334,293],[293,333],[333,334],[366,323],[323,447],[447,366],[316,15],[15,315],[315,316],[331,358],[358,279],[279,331],[317,14],[14,316],[316,317],[8,285],[285,9],[9,8],[277,329],[329,350],[350,277],[253,374],[374,252],[252,253],[319,318],[318,403],[403,319],[351,6],[6,419],[419,351],[324,318],[318,325],[325,324],[397,367],[367,365],[365,397],[288,435],[435,397],[397,288],[278,344],[344,439],[439,278],[310,272],[272,311],[311,310],[248,195],[195,281],[281,248],[375,273],[273,291],[291,375],[175,396],[396,199],[199,175],[312,311],[311,268],[268,312],[276,283],[283,445],[445,276],[390,373],[373,339],[339,390],[295,282],[282,296],[296,295],[448,449],[449,346],[346,448],[356,264],[264,454],[454,356],[337,336],[336,299],[299,337],[337,338],[338,151],[151,337],[294,278],[278,455],[455,294],[308,292],[292,415],[415,308],[429,358],[358,355],[355,429],[265,340],[340,372],[372,265],[352,346],[346,280],[280,352],[295,442],[442,282],[282,295],[354,19],[19,370],[370,354],[285,441],[441,295],[295,285],[195,248],[248,197],[197,195],[457,440],[440,274],[274,457],[301,300],[300,368],[368,301],[417,351],[351,465],[465,417],[251,301],[301,389],[389,251],[394,395],[395,379],[379,394],[399,412],[412,419],[419,399],[410,436],[436,322],[322,410],[326,2],[2,393],[393,326],[354,370],[370,461],[461,354],[393,164],[164,267],[267,393],[268,302],[302,12],[12,268],[312,268],[268,13],[13,312],[298,293],[293,301],[301,298],[265,446],[446,340],[340,265],[280,330],[330,425],[425,280],[322,426],[426,391],[391,322],[420,429],[429,437],[437,420],[393,391],[391,326],[326,393],[344,440],[440,438],[438,344],[458,459],[459,461],[461,458],[364,434],[434,394],[394,364],[428,396],[396,262],[262,428],[274,354],[354,457],[457,274],[317,316],[316,402],[402,317],[316,315],[315,403],[403,316],[315,314],[314,404],[404,315],[314,313],[313,405],[405,314],[313,421],[421,406],[406,313],[323,366],[366,361],[361,323],[292,306],[306,407],[407,292],[306,291],[291,408],[408,306],[291,287],[287,409],[409,291],[287,432],[432,410],[410,287],[427,434],[434,411],[411,427],[372,264],[264,383],[383,372],[459,309],[309,457],[457,459],[366,352],[352,401],[401,366],[1,274],[274,4],[4,1],[418,421],[421,262],[262,418],[331,294],[294,358],[358,331],[435,433],[433,367],[367,435],[392,289],[289,439],[439,392],[328,462],[462,326],[326,328],[94,2],[2,370],[370,94],[289,305],[305,455],[455,289],[339,254],[254,448],[448,339],[359,255],[255,446],[446,359],[254,253],[253,449],[449,254],[253,252],[252,450],[450,253],[252,256],[256,451],[451,252],[256,341],[341,452],[452,256],[414,413],[413,463],[463,414],[286,441],[441,414],[414,286],[286,258],[258,441],[441,286],[258,257],[257,442],[442,258],[257,259],[259,443],[443,257],[259,260],[260,444],[444,259],[260,467],[467,445],[445,260],[309,459],[459,250],[250,309],[305,289],[289,290],[290,305],[305,290],[290,460],[460,305],[401,376],[376,435],[435,401],[309,250],[250,392],[392,309],[376,411],[411,433],[433,376],[453,341],[341,464],[464,453],[357,453],[453,465],[465,357],[343,357],[357,412],[412,343],[437,343],[343,399],[399,437],[344,360],[360,440],[440,344],[420,437],[437,456],[456,420],[360,420],[420,363],[363,360],[361,401],[401,288],[288,361],[265,372],[372,353],[353,265],[390,339],[339,249],[249,390],[339,448],[448,255],[255,339]]
2,h=Object.entries(l).map(function(e){var t=e[0];return e[1].map(function(e){return[e,t]})}).flat(),d=new Map(h);function f(e){for(var t={locationData:{relativeKeypoints:[]}},n=Number.MAX_SAFE_INTEGER,r=Number.MIN_SAFE_INTEGER,a=Number.MAX_SAFE_INTEGER,o=Number.MIN_SAFE_INTEGER,s=0;s<e.length;++s){var i=e[s];n=Math.min(n,i.x),r=Math.max(r,i.x),a=Math.min(a,i.y),o=Math.max(o,i.y),t.locationData.relativeKeypoints.push({x:i.x,y:i.y})}return t.locationData.relativeBoundingBox={xMin:n,yMin:a,xMax:r,yMax:o,width:r-n,height:o-a},t}var m={runtime:"mediapipe",maxFaces:1,refineLandmarks:!1},g=function(){function e(e){var t=this;this.width=0,this.height=0,this.selfieMode=!1,this.faceMeshSolution=new r.FaceMesh({locateFile:function(t,n){return e.solutionPath?e.solutionPath.replace(/\/+$/,"")+"/"+t:n+"/"+t}}),this.faceMeshSolution.setOptions({refineLandmarks:e.refineLandmarks,selfieMode:this.selfieMode,maxNumFaces:e.maxFaces}),this.faceMeshSolution.onResults(function(e){if(t.height=e.image.height,t.width=e.image.width,t.faces=[],null!==e.multiFaceLandmarks)for(var n=e.multiFaceLandmarks,r=0;r<n.length;r++){var a=t.translateOutput(n[r]);t.faces.push({keypoints:a,box:f(a).locationData.relativeBoundingBox})}})}return e.prototype.translateOutput=function(e){var t=this;return e.map(function(e,n){var r={x:e.x*t.width,y:e.y*t.height,z:e.z*t.width},a=d.get(n);return null!=a&&(r.name=a),r})},e.prototype.estimateFaces=function(e,t){return i(this,void 0,void 0,function(){var n,r;return u(this,function(o){switch(o.label){case 0:return t&&t.flipHorizontal&&t.flipHorizontal!==this.selfieMode&&(this.selfieMode=t.flipHorizontal,this.faceMeshSolution.setOptions({selfieMode:this.selfieMode})),e instanceof a.qYS?(r=ImageData.bind,[4,a.TaL.toPixels(e)]):[3,2];case 1:return n=new(r.apply(ImageData,[void 0,o.sent(),e.shape[1],e.shape[0]])),[3,3];case 2:n=e,o.label=3;case 3:return e=n,[4,this.faceMeshSolution.send({image:e})];case 4:return o.sent(),[2,this.faces]}})})},e.prototype.dispose=function(){this.faceMeshSolution.close()},e.prototype.reset=function(){this.faceMeshSolution.reset(),this.width=0,this.height=0,this.faces=null,this.selfieMode=!1},e.prototype.initialize=function(){return this.faceMeshSolution.initialize()},e}();function y(e){return i(this,void 0,void 0,function(){var t,n;return u(this,function(r){switch(r.label){case 0:return t=function(e){if(null==e)return s({},m);var t=s({},e);return t.runtime="mediapipe",null==t.maxFaces&&(t.maxFaces=m.maxFaces),null==t.refineLandmarks&&(t.refineLandmarks=m.refineLandmarks),t}(e),[4,(n=new g(t)).initialize()];case 1:return r.sent(),[2,n]}})})}var x="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:void 0!==n.g?n.g:"undefined"!=typeof self?self:{},b={};(function(){var e;function t(e){var t=0;return function(){return t<e.length?{done:!1,value:e[t++]}:{done:!0}}}var n="function"==typeof Object.defineProperties?Object.defineProperty:function(e,t,n){return e==Array.prototype||e==Object.prototype||(e[t]=n.value),e},r=function(e){e=["object"==typeof globalThis&&globalThis,e,"object"==typeof window&&window,"object"==typeof self&&self,"object"==typeof x&&x];for(var t=0;t<e.length;++t){var n=e[t];if(n&&n.Math==Math)return n}throw Error("Cannot find global object")}(this);function a(e,t){if(t)e:{var a=r;e=e.split(".");for(var o=0;o<e.length-1;o++){var s=e[o];if(!(s in a))break e;a=a[s]}(t=t(o=a[e=e[e.length-1]]))!=o&&null!=t&&n(a,e,{configurable:!0,writable:!0,value:t})}}function o(e){return(e={next:e})[Symbol.iterator]=function(){return this},e}function s(e){var n="undefined"!=typeof Symbol&&Symbol.iterator&&e[Symbol.iterator];return n?n.call(e):{next:t(e)}}function i(e){if(!(e instanceof Array)){e=s(e);for(var t,n=[];!(t=e.next()).done;)n.push(t.value);e=n}return e}a("Symbol",function(e){function t(e,t){this.g=e,n(this,"description",{configurable:!0,writable:!0,value:t})}if(e)return e;t.prototype.toString=function(){return this.g};var r="jscomp_symbol_"+(1e9*Math.random()>>>0)+"_",a=0;return function e(n){if(this instanceof e)throw new TypeError("Symbol is not a constructor");return new t(r+(n||"")+"_"+a++,n)}}),a("Symbol.iterator",function(e){if(e)return e;e=Symbol("Symbol.iterator");for(var a="Array Int8Array Uint8Array Uint8ClampedArray Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array".split(" "),s=0;s<a.length;s++){var i=r[a[s]];"function"==typeof i&&"function"!=typeof i.prototype[e]&&n(i.prototype,e,{configurable:!0,writable:!0,value:function(){return o(t(this))}})}return e});var u,c="function"==typeof Object.create?Object.create:function(e){function t(){}return t.prototype=e,new t};if("function"==typeof Object.setPrototypeOf)u=Object.setPrototypeOf;else{var l;e:{var p={};try{p.__proto__={a:!0},l=p.a;break e}catch(e){}l=!1}u=l?function(e,t){if(e.__proto__=t,e.__proto__!==t)throw new TypeError(e+" is not extensible");return e}:null}var h=u;function d(e,t){if(e.prototype=c(t.prototype),e.prototype.constructor=e,h)h(e,t);else for(var n in t)if("prototype"!=n)if(Object.defineProperties){var r=Object.getOwnPropertyDescriptor(t,n);r&&Object.defineProperty(e,n,r)}else e[n]=t[n];e.na=t.prototype}function f(){this.l=!1,this.i=null,this.h=void 0,this.g=1,this.u=this.o=0,this.j=null}function m(e){if(e.l)throw new TypeError("Generator is already running");e.l=!0}function g(e,t){e.j={da:t,ea:!0}
2,e.g=e.o||e.u}function y(e,t,n){return e.g=n,{value:t}}function b(e){this.g=new f,this.h=e}function v(e,t,n,r){try{var a=t.call(e.g.i,n);if(!(a instanceof Object))throw new TypeError("Iterator result "+a+" is not an object");if(!a.done)return e.g.l=!1,a;var o=a.value}catch(t){return e.g.i=null,g(e.g,t),w(e)}return e.g.i=null,r.call(e.g,o),w(e)}function w(e){for(;e.g.g;)try{var t=e.h(e.g);if(t)return e.g.l=!1,{value:t.value,done:!1}}catch(t){e.g.h=void 0,g(e.g,t)}if(e.g.l=!1,e.g.j){if(t=e.g.j,e.g.j=null,t.ea)throw t.da;return{value:t.return,done:!0}}return{value:void 0,done:!0}}function T(e){this.next=function(t){return m(e.g),e.g.i?t=v(e,e.g.i.next,t,e.g.s):(e.g.s(t),t=w(e)),t},this.throw=function(t){return m(e.g),e.g.i?t=v(e,e.g.i.throw,t,e.g.s):(g(e.g,t),t=w(e)),t},this.return=function(t){return function(e,t){m(e.g);var n=e.g.i;return n?v(e,"return"in n?n.return:function(e){return{value:e,done:!0}},t,e.g.return):(e.g.return(t),w(e))}(e,t)},this[Symbol.iterator]=function(){return this}}function S(e){return function(e){function t(t){return e.next(t)}function n(t){return e.throw(t)}return new Promise(function(r,a){!function e(o){o.done?r(o.value):Promise.resolve(o.value).then(t,n).then(e,a)}(e.next())})}(new T(new b(e)))}f.prototype.s=function(e){this.h=e},f.prototype.return=function(e){this.j={return:e},this.g=this.u},a("Promise",function(e){function t(e){this.h=0,this.i=void 0,this.g=[],this.s=!1;var t=this.j();try{e(t.resolve,t.reject)}catch(e){t.reject(e)}}function n(){this.g=null}function a(e){return e instanceof t?e:new t(function(t){t(e)})}if(e)return e;n.prototype.h=function(e){if(null==this.g){this.g=[];var t=this;this.i(function(){t.l()})}this.g.push(e)};var o=r.setTimeout;n.prototype.i=function(e){o(e,0)},n.prototype.l=function(){for(;this.g&&this.g.length;){var e=this.g;this.g=[];for(var t=0;t<e.length;++t){var n=e[t];e[t]=null;try{n()}catch(e){this.j(e)}}}this.g=null},n.prototype.j=function(e){this.i(function(){throw e})},t.prototype.j=function(){function e(e){return function(r){n||(n=!0,e.call(t,r))}}var t=this,n=!1;return{resolve:e(this.D),reject:e(this.l)}},t.prototype.D=function(e){if(e===this)this.l(new TypeError("A Promise cannot resolve to itself"));else if(e instanceof t)this.H(e);else{e:switch(typeof e){case"object":var n=null!=e;break e;case"function":n=!0;break e;default:n=!1}n?this.A(e):this.o(e)}},t.prototype.A=function(e){var t=void 0;try{t=e.then}catch(e){return void this.l(e)}"function"==typeof t?this.I(t,e):this.o(e)},t.prototype.l=function(e){this.u(2,e)},t.prototype.o=function(e){this.u(1,e)},t.prototype.u=function(e,t){if(0!=this.h)throw Error("Cannot settle("+e+", "+t+"): Promise already settled in state"+this.h);this.h=e,this.i=t,2===this.h&&this.G(),this.B()},t.prototype.G=function(){var e=this;o(function(){if(e.C()){var t=r.console;void 0!==t&&t.error(e.i)}},1)},t.prototype.C=function(){if(this.s)return!1;var e=r.CustomEvent,t=r.Event,n=r.dispatchEvent;return void 0===n||("function"==typeof e?e=new e("unhandledrejection",{cancelable:!0}):"function"==typeof t?e=new t("unhandledrejection",{cancelable:!0}):(e=r.document.createEvent("CustomEvent")).initCustomEvent("unhandledrejection",!1,!0,e),e.promise=this,e.reason=this.i,n(e))},t.prototype.B=function(){if(null!=this.g){for(var e=0;e<this.g.length;++e)i.h(this.g[e]);this.g=null}};var i=new n;return t.prototype.H=function(e){var t=this.j();e.M(t.resolve,t.reject)},t.prototype.I=function(e,t){var n=this.j();try{e.call(t,n.resolve,n.reject)}catch(e){n.reject(e)}},t.prototype.then=function(e,n){function r(e,t){return"function"==typeof e?function(t){try{a(e(t))}catch(e){o(e)}}:t}var a,o,s=new t(function(e,t){a=e,o=t});return this.M(r(e,a),r(n,o)),s},t.prototype.catch=function(e){return this.then(void 0,e)},t.prototype.M=function(e,t){function n(){switch(r.h){case 1:e(r.i);break;case 2:t(r.i);break;default:throw Error("Unexpected state: "+r.h)}}var r=this;null==this.g?i.h(n):this.g.push(n),this.s=!0},t.resolve=a,t.reject=function(e){return new t(function(t,n){n(e)})},t.race=function(e){return new t(function(t,n){for(var r=s(e),o=r.next();!o.done;o=r.next())a(o.value).M(t,n)})},t.all=function(e){var n=s(e),r=n.next();return r.done?a([]):new t(function(e,t){function o(t){return function(n){s[t]=n,0==--i&&e(s)}}var s=[],i=0;do{s.push(void 0),i++,a(r.value).M(o(s.length-1),t),r=n.next()}while(!r.done)})},t});var C="function"==typeof Object.assign?Object.assign:function(e,t){for(var n=1;n<arguments.length;n++){var r=arguments[n];if(r)for(var a in r)Object.prototype.hasOwnProperty.call(r,a)&&(e[a]=r[a])}return e};a("Object.assign",function(e){return e||C}),a("Object.is",function(e){return e||function(e,t){return e===t?0!==e||1/e==1/t:e!=e&&t!=t}}),a("Array.prototype.includes",function(e){return e||function(e,t){var n=this;n instanceof String&&(n=String(n));var r=n.length;for(0>(t=t||0)&&(t=Math.max(t+r,0));t<r;t++){var a=n[t];if(a===e||Object.is(a,e))return!0}return!1}}),a("String.prototype.includes",function(e){return e||function(e,t){if(null==this)throw new TypeError("The 'this' value for String.prototype.includes must not be null or undefined");if(e instanceof RegExp)throw new TypeError("First argument to String.prototype.includes must not be a regular expression");return-1!==this.indexOf(e,t||0)}}),a("Array.prototype.keys",function(e){return e||function(){return function(e,t){e instanceof String&&(e+="");var n=0,r=!1,a={next:function(){if(!r&&n<e.length){var a=n++;return{value:t(a,e[a]),done:!1}}return r=!0,{done:!0,value:void 0}}};return a[Symbol.iterator]=function(){return a},a}(this,function(e){return e})}});var k=this||self;function E(e,t){e=e.split(".");var n,r=k;e[0]in r||void 0===r.execScript||r.execScript("var "+e[0]);for(;e.length&&(n=e.shift());)e.length||void 0===t?r=r[n]&&r[n]!==Object.prototype[n]?r[n]:r[n]={}:r[n]=t}function $(){throw Error("Invalid UTF8")}function N(e,t){return t=String.fromCharCode.apply(null,t),null==e?t:e+t}var I,A,R="undefined"!=typeof TextDecoder,_="undefined"!=typeof TextEncoder,O={},F=null;function D(e){var t;void 0===t&&(t=0),M(),t=O[t];for(var n=Array(Math.floor(e.length/3)),r=t[64]||"",a=0,o=0;a<e.length-2;a+=3){var s=e[a],i=e[a+1],u=e[a+2],c=t[s>>2];s=t[(3&s)<<4|i>>4],i=t[(15&i)<<2|u>>6],u=t[63&u],n[o++]=c+s+i+u}switch(c=0,u=r,e.length-a){case 2:u=t[(15&(c=e[a+1]))<<2]||r;case 1:e=e[a],n[o]=t[e>>2]+t[(3&e)<<4|c>>4]+u+r}return n.join("")}function L(e){var t=e.length,n=3*t/4;n%3?n=Math.floor(n):-1!="=.".indexOf(e[t-1])&&(n=-1!="=.".indexOf(e[t-2])?n-2:n-1);
2var r=new Uint8Array(n),a=0;return function(e,t){function n(t){for(;r<e.length;){var n=e.charAt(r++),a=F[n];if(null!=a)return a;if(!/^[\s\xa0]*$/.test(n))throw Error("Unknown base64 encoding at char: "+n)}return t}M();for(var r=0;;){var a=n(-1),o=n(0),s=n(64),i=n(64);if(64===i&&-1===a)break;t(a<<2|o>>4),64!=s&&(t(o<<4&240|s>>2),64!=i&&t(s<<6&192|i))}}(e,function(e){r[a++]=e}),a!==n?r.subarray(0,a):r}function M(){if(!F){F={};for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".split(""),t=["+/=","+/","-_=","-_.","-_"],n=0;5>n;n++){var r=e.concat(t[n].split(""));O[n]=r;for(var a=0;a<r.length;a++){var o=r[a];void 0===F[o]&&(F[o]=a)}}}}var P,B="function"==typeof Uint8Array;function V(e){return B&&null!=e&&e instanceof Uint8Array}function z(e){if(this.L=e,null!==e&&0===e.length)throw Error("ByteString should be constructed with non-empty values")}var U="function"==typeof Uint8Array.prototype.slice,W=0;function G(e,t){return Error("Invalid wire type: "+e+" (at position "+t+")")}function j(){return Error("Failed to read varint, encoding is invalid.")}function K(e,t){t=void 0!==(t=void 0===t?{}:t).v&&t.v,this.h=null,this.g=this.i=this.j=0,this.v=t,e&&H(this,e)}function H(e,t){e.h=function(e,t){if(e.constructor===Uint8Array)return e;if(e.constructor===ArrayBuffer)return new Uint8Array(e);if(e.constructor===Array)return new Uint8Array(e);if(e.constructor===String)return L(e);if(e.constructor===z)return!t&&(t=e.L)&&t.constructor===Uint8Array?t:(t=null==(t=e.L)||V(t)?t:"string"==typeof t?L(t):null,(e=e.L=t)?new Uint8Array(e):P||(P=new Uint8Array(0)));if(e instanceof Uint8Array)return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw Error("Type not convertible to a Uint8Array, expected a Uint8Array, an ArrayBuffer, a base64 encoded string, or Array of numbers")}(t,e.v),e.j=0,e.i=e.h.length,e.g=e.j}function Y(e){if(e.g>e.i)throw Error("Tried to read past the end of the data "+e.g+" > "+e.i)}function Z(e){var t=e.h,n=t[e.g],r=127&n;if(128>n)return e.g+=1,Y(e),r;if(r|=(127&(n=t[e.g+1]))<<7,128>n)return e.g+=2,Y(e),r;if(r|=(127&(n=t[e.g+2]))<<14,128>n)return e.g+=3,Y(e),r;if(r|=(127&(n=t[e.g+3]))<<21,128>n)return e.g+=4,Y(e),r;if(n=t[e.g+4],e.g+=5,r|=(15&n)<<28,128>n)return Y(e),r;if(128<=t[e.g++]&&128<=t[e.g++]&&128<=t[e.g++]&&128<=t[e.g++]&&128<=t[e.g++])throw j();return Y(e),r}K.prototype.reset=function(){this.g=this.j};var X=[];function q(){this.g=[]}function Q(e,t){for(;127<t;)e.g.push(127&t|128),t>>>=7;e.g.push(t)}function J(e){var t={},n=void 0!==t.W&&t.W;this.l={v:void 0!==t.v&&t.v},this.W=n,t=this.l,X.length?(n=X.pop(),t&&(n.v=t.v),e&&H(n,e),e=n):e=new K(e,t),this.g=e,this.j=this.g.g,this.h=this.i=-1}function ee(e){var t=e.g;if(t.g==t.i)return!1;e.j=e.g.g;var n=Z(e.g)>>>0;if(t=n>>>3,!(0<=(n&=7)&&5>=n))throw G(n,e.j);if(1>t)throw Error("Invalid field number: "+t+" (at position "+e.j+")");return e.i=t,e.h=n,!0}function te(e){switch(e.h){case 0:if(0!=e.h)te(e);else e:{for(var t=(e=e.g).g,n=t+10;t<n;)if(!(128&e.h[t++])){e.g=t,Y(e);break e}throw j()}break;case 1:(e=e.g).g+=8,Y(e);break;case 2:2!=e.h?te(e):(t=Z(e.g)>>>
20,(e=e.g).g+=t,Y(e));break;case 5:(e=e.g).g+=4,Y(e);break;case 3:for(t=e.i;;){if(!ee(e))throw Error("Unmatched start-group tag: stream EOF");if(4==e.h){if(e.i!=t)throw Error("Unmatched end-group tag");break}te(e)}break;default:throw G(e.h,e.j)}}q.prototype.length=function(){return this.g.length},q.prototype.end=function(){var e=this.g;return this.g=[],e},J.prototype.reset=function(){this.g.reset(),this.j=this.g.g,this.h=this.i=-1};var ne=[];function re(){this.i=[],this.h=0,this.g=new q}function ae(e,t){0!==t.length&&(e.i.push(t),e.h+=t.length)}var oe="function"==typeof Symbol&&"symbol"==typeof Symbol()?Symbol(void 0):void 0;function se(e,t){Object.isFrozen(e)||(oe?e[oe]|=t:void 0!==e.N?e.N|=t:Object.defineProperties(e,{N:{value:t,configurable:!0,writable:!0,enumerable:!1}}))}function ie(e){var t;return null==(t=oe?e[oe]:e.N)?0:t}function ue(e){return se(e,1),e}function ce(e){return!!Array.isArray(e)&&!!(2&ie(e))}function le(e){if(!Array.isArray(e))throw Error("cannot mark non-array as immutable");se(e,2)}function pe(e){return null!==e&&"object"==typeof e&&!Array.isArray(e)&&e.constructor===Object}var he=Object.freeze(ue([]));function de(e){if(ce(e.m))throw Error("Cannot mutate an immutable Message")}var fe,me="undefined"!=typeof Symbol&&void 0!==Symbol.hasInstance;function ge(e){return{value:e,configurable:!1,writable:!1,enumerable:!1}}function ye(e,t,n){return-1===t?null:t>=e.i?e.g?e.g[t]:void 0:void 0!==n&&n&&e.g&&null!=(n=e.g[t])?n:e.m[t+e.h]}function xe(e,t,n,r){r=void 0!==r&&r,de(e),t<e.i&&!r?e.m[t+e.h]=n:(e.g||(e.g=e.m[e.i+e.h]={}))[t]=n}function be(e,t,n,r){n=void 0===n||n;var a=ye(e,t,r=void 0!==r&&r);return null==a&&(a=he),ce(e.m)?n&&(le(a),Object.freeze(a)):(a===he||ce(a))&&xe(e,t,a=ue(a.slice()),r),a}function ve(e,t,n){return null==(e=null==(e=ye(e,t))?e:+e)?void 0===n?0:n:e}function we(e,t,n,r){e.j||(e.j={});var a=ce(e.m),o=e.j[n];if(!o){r=be(e,n,!0,void 0!==r&&r),o=[],a=a||ce(r);for(var s=0;s<r.length;s++)o[s]=new t(r[s]),a&&le(o[s].m);a&&(le(o),Object.freeze(o)),e.j[n]=o}return o}function Te(e,t,n,r,a){var o=void 0!==o&&o;return de(e),o=we(e,n,t,o),n=r||new n,e=be(e,t),null!=a?(o.splice(a,0,n),e.splice(a,0,n.m)):(o.push(n),e.push(n.m)),n}function Se(e,t){return null==(e=ye(e,t))?0:e}function Ce(e,t){return null==(e=ye(e,t))?"":e}function ke(e){return $e(e,void 0===Ne?Ie:Ne)}function Ee(e,t){if(null!=e){if(Array.isArray(e))e=$e(e,t);else if(pe(e)){var n,r={};for(n in e)r[n]=Ee(e[n],t);e=r}else e=t(e);return e}}function $e(e,t){for(var n=e.slice(),r=0;r<n.length;r++)n[r]=Ee(n[r],t);return Array.isArray(e)&&1&ie(e)&&ue(n),n}function Ne(e){return e&&"object"==typeof e&&e.toJSON?e.toJSON():(e=function(e){switch(typeof e){case"number":return isFinite(e)?e:String(e);case"object":if(e&&!Array.isArray(e)){if(V(e))return D(e);if(e instanceof z){var t=e.L;return t=null==t||"string"==typeof t?t:B&&t instanceof Uint8Array?D(t):null,(e.L=t)||""}}}return e}(e),Array.isArray(e)?ke(e):e)}function Ie(e){return V(e)?new Uint8Array(e):e}function Ae(e,t,n){e||(e=fe),fe=null;var r=this.constructor.h;if(e||(e=r?[r]:[]),this.h=(r?0:-1)-(this.constructor.g||0),this.j=void 0,this.m=e,e=(r=this.m.length)-1,r&&pe(r=this.m[e])?(this.i=e-this.h,this.g=r):void 0!==t&&-1<t?(this.i=Math.max(t,e+1-this.h),this.g=void 0):this.i=Number.MAX_VALUE,n)for(t=0;t<n.length;t++)if((e=n[t])<this.i)e+=this.h,(r=this.m[e])?Array.isArray(r)&&ue(r):this.m[e]=he;else{var a=(r=this.g||(this.g=this.m[this.i+this.h]={}))[e];a?Array.isArray(a)&&ue(a):r[e]=he}}function Re(){Ae.apply(this,arguments)}if(Ae.prototype.toJSON=function(){return ke(this.m)},Ae.prototype.toString=function(){return this.m.toString()},d(Re,Ae),me){var _e={};Object.defineProperties(Re,(_e[Symbol.hasInstance]=ge(function(){throw Error("Cannot perform instanceof checks for MutableMessage")}),_e))}function Oe(e,t,n){if(n){var r,a={};for(r in n){var o=n[r],s=o.ha;s||(a.F=o.la||o.fa.P,o.aa?(a.U=Ve(o.aa),s=function(e){return function(t,n,r){return e.F(t,n,r,e.U)}}(a)):o.ca?(a.T=ze(o.X.g,o.ca),s=function(e){return function(t,n,r){return e.F(t,n,r,e.T)}}(a)):s=a.F,o.ha=s),s(t,e,o.X),a={F:a.F,U:a.U,T:a.T}}}!function(e,t){if(t=t.ba){ae(e,e.g.end());for(var n=0;n<t.length;n++)ae(e,t[n])}}(t,e)}var Fe=Symbol();function De(e,t,n){return e[Fe]||(e[Fe]=function(e,r){return t(e,r,n)})}function Le(e){var t=e[Fe];if(!t){var n=Je(e);t=function(e,t){return et(e,t,n)},e[Fe]=t}return t}function Me(e){var t=function(e){var t=e.aa;return t?Le(t):(t=e.ka)?De(e.X.g,t,e.ca):void 0}(e),n=e.X,r=e.fa.O;return t?function(e,a){return r(e,a,n,t)}:function(e,t){return r(e,t,n)}}function Pe(e,t,n,r,a,o){var s=0;for((e=e()).length&&"number"!=typeof e[0]&&(n(t,e[0]),s++);s<e.length;){n=e[s++];for(var i=s+1;i<e.length&&"number"!=typeof e[i];)i++;var u=e[s++];switch(i-=s){case 0:r(t,n,u);break;case 1:r(t,n,u,e[s++]);break;case 2:a(t,n,u,e[s++],e[s++]);break;case 3:i=e[s++];var c=e[s++],l=e[s++];Array.isArray(l)?a(t,n,u,i,c,l):o(t,n,u,i,c,l);break;case 4:o(t,n,u,e[s++],e[s++],e[s++],e[s++]);break;default:throw Error("unexpected number of binary field arguments: "+i)}}return t}var Be=Symbol();function Ve(e){var t=e[Be];if(!t){var n=He(e);t=function(e,t){return nt(e,t,n)},e[Be]=t}return t}function ze(e,t){var n=e[Be];return n||(n=function(e,n){return Oe(e,n,t)},e[Be]=n),n}var Ue=Symbol();function We(e,t){e.push(t)}function Ge(e,t,n){e.push(t,n.P)}function je(e,t,n,r,a){var o=Ve(a),s=n.P;e.push(t,function(e,t,n){return s(e,t,n,r,o)})}function Ke(e,t,n,r,a,o){var s=ze(r,o),i=n.P;
2e.push(t,function(e,t,n){return i(e,t,n,r,s)})}function He(e){return e[Ue]||Pe(e,e[Ue]=[],We,Ge,je,Ke)}var Ye=Symbol();function Ze(e,t){e[0]=t}function Xe(e,t,n,r){var a=n.O;e[t]=r?function(e,t,n){return a(e,t,n,r)}:a}function qe(e,t,n,r,a,o){var s=n.O,i=Le(a);e[t]=function(e,t,n){return s(e,t,n,r,i,o)}}function Qe(e,t,n,r,a,o,s){var i=n.O,u=De(r,a,o);e[t]=function(e,t,n){return i(e,t,n,r,u,s)}}function Je(e){return e[Ye]||Pe(e,e[Ye]={},Ze,Xe,qe,Qe)}function et(e,t,n){for(;ee(t)&&4!=t.h;){var r=t.i,a=n[r];if(!a){var o=n[0];o&&(o=o[r])&&(a=n[r]=Me(o))}if(!(a&&a(t,e,r)||(a=t,r=e,o=a.j,te(a),a.W))){var s=a.g.h;a=o===(a=a.g.g)?P||(P=new Uint8Array(0)):U?s.slice(o,a):new Uint8Array(s.subarray(o,a)),(o=r.ba)?o.push(a):r.ba=[a]}}return e}function tt(e,t,n){if(ne.length){var r=ne.pop();e&&(H(r.g,e),r.i=-1,r.h=-1),e=r}else e=new J(e);try{return et(new t,e,Je(n))}finally{(t=e.g).h=null,t.j=0,t.i=0,t.g=0,t.v=!1,e.i=-1,e.h=-1,100>ne.length&&ne.push(e)}}function nt(e,t,n){for(var r=n.length,a=1==r%2,o=a?1:0;o<r;o+=2)(0,n[o+1])(t,e,n[o]);Oe(e,t,a?n[0]:void 0)}function rt(e,t){var n=new re;nt(e,n,He(t)),ae(n,n.g.end()),e=new Uint8Array(n.h);for(var r=(t=n.i).length,a=0,o=0;o<r;o++){var s=t[o];e.set(s,a),a+=s.length}return n.i=[e],e}function at(e,t){return{O:e,P:t}}var ot=at(function(e,t,n){if(5!==e.h)return!1;var r=(e=e.g).h[e.g],a=e.h[e.g+1],o=e.h[e.g+2],s=e.h[e.g+3];return e.g+=4,Y(e),e=2*((a=(r|a<<8|o<<16|s<<24)>>>0)>>31)+1,r=a>>>23&255,a&=8388607,xe(t,n,255==r?a?NaN:1/0*e:0==r?e*Math.pow(2,-149)*a:e*Math.pow(2,r-150)*(a+Math.pow(2,23))),!0},function(e,t,n){if(null!=(t=ye(t,n))){Q(e.g,8*n+5),e=e.g;var r=t;0===(r=(n=0>r?1:0)?-r:r)?W=0<1/r?0:2147483648:isNaN(r)?W=2147483647:34028234663852886e22<r?W=(n<<31|2139095040)>>>0:11754943508222875e-54>r?(r=Math.round(r/Math.pow(2,-149)),W=(n<<31|r)>>>0):(t=Math.floor(Math.log(r)/Math.LN2),r*=Math.pow(2,-t),16777216<=(r=Math.round(8388608*r))&&++t,W=(n<<31|t+127<<23|8388607&r)>>>0),n=W,e.g.push(n>>>0&255),e.g.push(n>>>8&255),e.g.push(n>>>16&255),e.g.push(n>>>24&255)}}),st=at(function(e,t,n){if(0!==e.h)return!1;for(var r=e.g,a=128,o=0,s=e=0;4>s&&128<=a;s++)a=r.h[r.g++],Y(r),o|=(127&a)<<7*s;if(128<=a&&(a=r.h[r.g++],Y(r),o|=(127&a)<<28,e|=(127&a)>>4),128<=a)for(s=0;5>s&&128<=a;s++)a=r.h[r.g++],Y(r),e|=(127&a)<<7*s+3;if(!(128>a))throw j();return r=o>>>0,(e=2147483648&(a=e>>>0))&&(a=~a>>>0,0==(r=1+~r>>>0)&&(a=a+1>>>0)),r=4294967296*a+(r>>>0),xe(t,n,e?-r:r),!0},function(e,t,n){if(null!=(t=ye(t,n))&&null!=t){Q(e.g,8*n),e=e.g;var r=t;for(n=0>r,t=(r=Math.abs(r))>>>0,r=Math.floor((r-t)/4294967296),r>>>=0,n&&(r=~r>>>0,4294967295<(t=1+(~t>>>0))&&(t=0,4294967295<++r&&(r=0))),n=W=t,t=r;0<t||127<n;)e.g.push(127&n|128),n=(n>>>7|t<<25)>>>0,t>>>=7;e.g.push(n)}}),it=at(function(e,t,n){return 0===e.h&&(xe(t,n,Z(e.g)),!0)},function(e,t,n){if(null!=(t=ye(t,n))&&null!=t)if(Q(e.g,8*n),e=e.g,0<=(n=t))Q(e,n);else{for(t=0;9>t;t++)e.g.push(127&n|128),n>>=7;e.g.push(1)}}),ut=at(function(e,t,n){if(2!==e.h)return!1;var r,a=Z(e.g)>>>0,o=(e=e.g).g;if(e.g+=a,Y(e),e=e.h,R)(r=I)||(r=I=new TextDecoder("utf-8",{fatal:!0})),r=r.decode(e.subarray(o,o+a));else{a=o+a;for(var s,i,u,c=[],l=null;o<a;)128>(s=e[o++])?c.push(s):224>s?o>=a?$():(i=e[o++],194>s||128!=(192&i)?(o--,$()):c.push((31&s)<<6|63&i)):240>s?o>=a-1?$():128!=(192&(i=e[o++]))||224===s&&160>i||237===s&&160<=i||128!=(192&(r=e[o++]))?(o--,$()):c.push((15&s)<<12|(63&i)<<6|63&r):244>=s?o>=a-2?$():128!=(192&(i=e[o++]))||i-144+(s<<28)>>30||128!=(192&(r=e[o++]))||128!=(192&(u=e[o++]))?(o--,$()):(s=(7&s)<<18|(63&i)<<12|(63&r)<<6|63&u,s-=65536,c.push(55296+(s>>10&1023),56320+(1023&s))):$(),8192<=c.length&&(l=N(l,c),c.length=0);r=N(l,c)}return xe(t,n,r),!0},function(e,t,n){if(null!=(t=ye(t,n))){var r=!1;if(r=void 0!==r&&r,_){if(r&&/(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])/.test(t))throw Error("Found an unpaired surrogate");t=(A||(A=new TextEncoder)).encode(t)}else{for(var a=0,o=new Uint8Array(3*t.length),s=0;s<t.length;s++){var i=t.charCodeAt(s);if(128>i)o[a++]=i;else{if(2048>i)o[a++]=i>>6|192;else{if(55296<=i&&57343>=i){if(56319>=i&&s<t.length){var u=t.charCodeAt(++s);if(56320<=u&&57343>=u){i=1024*(i-55296)+u-56320+65536,o[a++]=i>>18|240,o[a++]=i>>12&63|128,o[a++]=i>>6&63|128,o[a++]=63&i|128;continue}s--}if(r)throw Error("Found an unpaired surrogate");i=65533}o[a++]=i>>12|224,o[a++]=i>>6&63|128}o[a++]=63&i|128}}t=o.subarray(0,a)}Q(e.g,8*n+2),Q(e.g,t.length),ae(e,e.g.end()),ae(e,t)}}),ct=at(function(e,t,n,r,a){if(2!==e.h)return!1;t=Te(t,n,r),n=e.g.i,r=Z(e.g)>>>0;var o=e.g.g+r,s=o-n;if(0>=s&&(e.g.i=o,a(t,e),s=o-e.g.g),s)throw Error("Message parsing ended unexpectedly. Expected to read "+r+" bytes, instead read "+(r-s)+" bytes, either the data ended unexpectedly or the message misreported its own length");return e.g.g=o,e.g.i=n,!0},function(e,t,n,r,a){if(null!=(t=we(t,r,n)))for(r=0;r<t.length;r++){var o=e;Q(o.g,8*n+2);var s=o.g.end();ae(o,s),s.push(o.h),o=s,a(t[r],e),s=e;var i=o.pop();for(i=s.h+s.g.length()-i;127<i;)o.push(127&i|128),i>>>=7,s.h++;o.push(i),s.h++}});function lt(){Re.apply(this,arguments)}if(d(lt,Re),me){var pt={};Object.defineProperties(lt,(pt[Symbol.hasInstance]=ge(Object[Symbol.hasInstance]),pt))}function ht(e){lt.call(this,e)}function dt(){return[1,it,2,ot,3,ut,4,ut]}function ft(e){lt.call(this,e,-1,gt)}function mt(){return[1,ct,ht,dt]}d(ht,lt),d(ft,lt),ft.prototype.addClassification=function(e,t){return Te(this,1,ht,e,t),this};var gt=[1];function yt(e){lt.call(this,e)}
2function xt(){return[1,ot,2,ot,3,ot,4,ot,5,ot]}function bt(e){lt.call(this,e,-1,wt)}function vt(){return[1,ct,yt,xt]}d(yt,lt),d(bt,lt);var wt=[1];function Tt(e){lt.call(this,e)}function St(){return[1,ot,2,ot,3,ot,4,ot,5,ot,6,st]}d(Tt,lt);var Ct=[[61,146],[146,91],[91,181],[181,84],[84,17],[17,314],[314,405],[405,321],[321,375],[375,291],[61,185],[185,40],[40,39],[39,37],[37,0],[0,267],[267,269],[269,270],[270,409],[409,291],[78,95],[95,88],[88,178],[178,87],[87,14],[14,317],[317,402],[402,318],[318,324],[324,308],[78,191],[191,80],[80,81],[81,82],[82,13],[13,312],[312,311],[311,310],[310,415],[415,308]],kt=[[263,249],[249,390],[390,373],[373,374],[374,380],[380,381],[381,382],[382,362],[263,466],[466,388],[388,387],[387,386],[386,385],[385,384],[384,398],[398,362]],Et=[[276,283],[283,282],[282,295],[295,285],[300,293],[293,334],[334,296],[296,336]],$t=[[33,7],[7,163],[163,144],[144,145],[145,153],[153,154],[154,155],[155,133],[33,246],[246,161],[161,160],[160,159],[159,158],[158,157],[157,173],[173,133]],Nt=[[46,53],[53,52],[52,65],[65,55],[70,63],[63,105],[105,66],[66,107]],It=[[10,338],[338,297],[297,332],[332,284],[284,251],[251,389],[389,356],[356,454],[454,323],[323,361],[361,288],[288,397],[397,365],[365,379],[379,378],[378,400],[400,377],[377,152],[152,148],[148,176],[176,149],[149,150],[150,136],[136,172],[172,58],[58,132],[132,93],[93,234],[234,127],[127,162],[162,21],[21,54],[54,103],[103,67],[67,109],[109,10]],At=[].concat(i(Ct),i(kt),i(Et),i($t),i(Nt),i(It));function Rt(e,t,n){if(n=e.createShader(0===n?e.VERTEX_SHADER:e.FRAGMENT_SHADER),e.shaderSource(n,t),e.compileShader(n),!e.getShaderParameter(n,e.COMPILE_STATUS))throw Error("Could not compile WebGL shader.\n\n"+e.getShaderInfoLog(n));return n}function _t(e){return we(e,ht,1).map(function(e){return{index:Se(e,1),ga:ve(e,2),label:null!=ye(e,3)?Ce(e,3):void 0,displayName:null!=ye(e,4)?Ce(e,4):void 0}})}function Ot(e){return{x:ve(e,1),y:ve(e,2),z:ve(e,3),visibility:null!=ye(e,4)?ve(e,4):void 0}}function Ft(e,t){this.h=e,this.g=t,this.l=0}function Dt(e,t,n){return function(e,t){var n=e.g;if(void 0===e.o){var r=Rt(n,"\n attribute vec2 aVertex;\n attribute vec2 aTex;\n varying vec2 vTex;\n void main(void) {\n gl_Position = vec4(aVertex, 0.0, 1.0);\n vTex = aTex;\n }",0),a=Rt(n,"\n precision mediump float;\n varying vec2 vTex;\n uniform sampler2D sampler0;\n void main(){\n gl_FragColor = texture2D(sampler0, vTex);\n }",1),o=n.createProgram();if(n.attachShader(o,r),n.attachShader(o,a),n.linkProgram(o),!n.getProgramParameter(o,n.LINK_STATUS))throw Error("Could not compile WebGL program.\n\n"+n.getProgramInfoLog(o));r=e.o=o,n.useProgram(r),a=n.getUniformLocation(r,"sampler0"),e.j={K:n.getAttribLocation(r,"aVertex"),J:n.getAttribLocation(r,"aTex"),ma:a},e.u=n.createBuffer(),n.bindBuffer(n.ARRAY_BUFFER,e.u),n.enableVertexAttribArray(e.j.K),n.vertexAttribPointer(e.j.K,2,n.FLOAT,!1,0,0),n.bufferData(n.ARRAY_BUFFER,new Float32Array([-1,-1,-1,1,1,1,1,-1]),n.STATIC_DRAW),n.bindBuffer(n.ARRAY_BUFFER,null),e.s=n.createBuffer(),n.bindBuffer(n.ARRAY_BUFFER,e.s),n.enableVertexAttribArray(e.j.J),n.vertexAttribPointer(e.j.J,2,n.FLOAT,!1,0,0),n.bufferData(n.ARRAY_BUFFER,new Float32Array([0,1,0,0,1,0,1,1]),n.STATIC_DRAW),n.bindBuffer(n.ARRAY_BUFFER,null),n.uniform1i(a,0)}r=e.j,n.useProgram(e.o),n.canvas.width=t.width,n.canvas.height=t.height,n.viewport(0,0,t.width,t.height),n.activeTexture(n.TEXTURE0),e.h.bindTexture2d(t.glName),n.enableVertexAttribArray(r.K),n.bindBuffer(n.ARRAY_BUFFER,e.u),n.vertexAttribPointer(r.K,2,n.FLOAT,!1,0,0),n.enableVertexAttribArray(r.J),n.bindBuffer(n.ARRAY_BUFFER,e.s),n.vertexAttribPointer(r.J,2,n.FLOAT,!1,0,0),n.bindFramebuffer(n.DRAW_FRAMEBUFFER?n.DRAW_FRAMEBUFFER:n.FRAMEBUFFER,null),n.clearColor(0,0,0,0),n.clear(n.COLOR_BUFFER_BIT),n.colorMask(!0,!0,!0,!0),n.drawArrays(n.TRIANGLE_FAN,0,4),n.disableVertexAttribArray(r.K),n.disableVertexAttribArray(r.J),n.bindBuffer(n.ARRAY_BUFFER,null),e.h.bindTexture2d(0)}(e,t),"function"==typeof e.g.canvas.transferToImageBitmap?Promise.resolve(e.g.canvas.transferToImageBitmap()):n?Promise.resolve(e.g.canvas):"function"==typeof createImageBitmap?createImageBitmap(e.g.canvas):(void 0===e.i&&(e.i=document.createElement("canvas")),new Promise(function(t){e.i.height=e.g.canvas.height,e.i.width=e.g.canvas.width,e.i.getContext("2d",{}).drawImage(e.g.canvas,0,0,e.g.canvas.width,e.g.canvas.height),t(e.i)}))}function Lt(e){this.g=e}var Mt=new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,10,9,1,7,0,65,0,253,15,26,11]);function Pt(e,t){return t+e}function Bt(e,t){window[e]=t}function Vt(e){if(this.g=e,this.listeners={},this.j={},this.H={},this.o={},this.u={},this.I=this.s=this.Z=!0,this.D=Promise.resolve(),this.Y="",this.C={},this.locateFile=e&&e.locateFile||Pt,"object"==typeof window)var t=window.location.pathname.toString().substring(0,window.location.pathname.toString().lastIndexOf("/"))+"/";else{if("undefined"==typeof location)throw Error("solutions can only be loaded on a web page or in a web worker");t=location.pathname.toString().substring(0,location.pathname.toString().lastIndexOf("/"))+"/"}if(this.$=t,e.options)for(var n=(t=s(Object.keys(e.options))).next();!n.done;n=t.next()){n=n.value;var r=e.options[n].default;void 0!==r&&(this.j[n]="function"==typeof r?r():r)}}function zt(e,t){var n,r;return S(function(a){return t in e.H?a.return(e.H[t]):(n=e.locateFile(t,""),r=fetch(n).then(function(e){return e.arrayBuffer()}),e.H[t]=r,a.return(r))})}function Ut(e,t,n){var r,a,o,i,u,c,l,p,h,d,f,m,g,x;return S(function(b){switch(b.g){case 1:if(!n)return b.return(t);for(r={},a=0,o=s(Object.keys(n)),i=o.next();!i.done;i=o.next())u=i.value,"string"!=typeof(c=n[u])&&"texture"===c.type&&void 0!==t[c.stream]&&++a;1<a&&(e.I=!1),l=s(Object.keys(n)),i=l.next();case 2:if(i.done){b.g=4;break}if(p=i.value,"string"==typeof(h=n[p]))return g=r,x=p,y(b,function(e,t,n){var r;return S(function(a){return"number"==typeof n||n instanceof Uint8Array||n instanceof e.h.Uint8BlobList?a.return(n):n instanceof e.h.Texture2dDataOut?((r=e.u[t])||(r=new Ft(e.h,e.G),e.u[t]=r),a.return(Dt(r,n,e.I))):a.return(void 0)})}(e,p,t[h]),14);if(d=t[h.stream],"detection_list"===h.type){if(d){for(var v=d.getRectList(),w=d.getLandmarksList(),T=d.getClassificationsList(),C=[],k=0;k<v.size();++k){var E=tt(v.get(k),Tt,St);E={boundingBox:{xCenter:ve(E,1),yCenter:ve(E,2),height:ve(E,3),width:ve(E,4),rotation:ve(E,5,0),rectId:Se(E,6)},landmarks:we(tt(w.get(k),bt,vt),yt,1).map(Ot),V:_t(tt(T.get(k),ft,mt))},C.push(E)}v=C}else v=[];r[p]=v,b.g=7;break}if("proto_list"===h.type){if(d){for(v=Array(d.size()),w=0;w<d.size();w++)v[w]=d.get(w);d.delete()}else v=[];r[p]=v,b.g=7;break}if(void 0===d){b.g=3;break}if("float_list"===h.type){r[p]=d,b.g=7;break}if("proto"===h.type){r[p]=d,b.g=7;break}if("texture"!==h.type)throw Error("Unknown output config type: '"+h.type+"'");return(f=e.u[p])||(f=new Ft(e.h,e.G),e.u[p]=f),y(b,Dt(f,d,e.I),13);case 13:m=b.h,r[p]=m;case 7:h.transform&&r[p]&&(r[p]=h.transform(r[p])),b.g=3;break;case 14:g[x]=b.h;case 3:i=l.next(),b.g=2;break;case 4:return b.return(r)}})}function Wt(e,t){for(var n=t.name||"$",r=[].concat(i(t.wants)),a=new e.h.StringList,o=s(t.wants),u=o.next();!u.done;u=o.next())a.push_back(u.value);o=e.h.PacketListener.implement({onResults:function(a){for(var o={},s=0;s<t.wants.length;++s)o[r[s]]=a.get(s);var i=e.listeners[n];i&&(e.D=Ut(e,o,t.outs).then(function(n){n=i(n);for(var a=0;a<t.wants.length;++a){var s=o[r[a]];"object"==typeof s&&s.hasOwnProperty&&s.hasOwnProperty("delete")&&s.delete()}n&&(e.D=n)}))}}),e.i.attachMultiListener(a,o),a.delete()}function Gt(e){var t=this;e=e||{};var n={url:"face_detection_short.binarypb"},r={type:1,graphOptionXref:{calculatorType:"TensorsToDetectionsCalculator",calculatorName:"facedetectionshortrangegpu__facedetectionshortrangecommon__TensorsToDetectionsCalculator",fieldName:"min_score_thresh"}};this.g=new Vt({locateFile:e.locateFile,files:[{data:!0,url:"face_detection_short.binarypb"},{data:!0,url:"face_detection_short_range.tflite"},{simd:!0,url:"face_detection_solution_simd_wasm_bin.js"},{simd:!1,url:"face_detection_solution_wasm_bin.js"}],graph:n,listeners:[{wants:["detections","image_transformed"],outs:{image:"image_transformed",detections:{type:"detection_list",stream:"detections"}}}
2],inputs:{image:{type:"video",stream:"input_frames_gpu"}},options:{useCpuInference:{type:0,graphOptionXref:{calculatorType:"InferenceCalculator",fieldName:"use_cpu_inference"},default:"object"==typeof window&&void 0!==window.navigator&&("iPad Simulator;iPhone Simulator;iPod Simulator;iPad;iPhone;iPod".split(";").includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document)},selfieMode:{type:0,graphOptionXref:{calculatorType:"GlScalerCalculator",calculatorIndex:1,fieldName:"flip_horizontal"}},model:{type:0,onChange:function(e){var a,o,i,u,c;return S(function(l){switch(l.g){case 1:a=s("short"===e?["face_detection_short_range.tflite"]:["face_detection_full_range_sparse.tflite"]),o=a.next();case 2:if(o.done){l.g=4;break}return i=o.value,u="third_party/mediapipe/modules/face_detection/"+i,y(l,zt(t.g,i),5);case 5:c=l.h,t.g.overrideFile(u,c),o=a.next(),l.g=2;break;case 4:return n.url="short"===e?"face_detection_short.binarypb":"face_detection_full.binarypb",r.graphOptionXref.calculatorName="short"===e?"facedetectionshortrangegpu__facedetectionshortrangecommon__TensorsToDetectionsCalculator":"facedetectionfullrangegpu__facedetectionfullrangecommon__TensorsToDetectionsCalculator",l.return(!0)}})}},minDetectionConfidence:r}})}(e=Vt.prototype).close=function(){return this.i&&this.i.delete(),Promise.resolve()},e.reset=function(){var e=this;return S(function(t){e.i&&(e.i.reset(),e.o={},e.u={}),t.g=0})},e.setOptions=function(e,t){var n=this;if(t=t||this.g.options){for(var r=[],a=[],o={},i=s(Object.keys(e)),u=i.next();!u.done;o={R:o.R,S:o.S},u=i.next()){var c=u.value;c in this.j&&this.j[c]===e[c]||(this.j[c]=e[c],void 0!==(u=t[c])&&(u.onChange&&(o.R=u.onChange,o.S=e[c],r.push(function(e){return function(){return S(function(t){if(1==t.g)return y(t,e.R(e.S),2);!0===t.h&&(n.s=!0),t.g=0})}}(o))),u.graphOptionXref&&(c={valueNumber:1===u.type?e[c]:0,valueBoolean:0===u.type&&e[c],valueString:2===u.type?e[c]:""},u=Object.assign(Object.assign(Object.assign({},{calculatorName:"",calculatorIndex:0}),u.graphOptionXref),c),a.push(u))))}0===r.length&&0===a.length||(this.s=!0,this.B=(void 0===this.B?[]:this.B).concat(a),this.A=(void 0===this.A?[]:this.A).concat(r))}},e.initialize=function(){var e=this;return S(function(t){return 1==t.g?y(t,function(e){var t,n,r,a,o,s,u,c,l,p,h;return S(function(d){switch(d.g){case 1:return e.Z?(t=void 0===e.g.files?[]:"function"==typeof e.g.files?e.g.files(e.j):e.g.files,y(d,S(function(e){switch(e.g){case 1:return e.o=2,y(e,WebAssembly.instantiate(Mt),4);case 4:e.g=3,e.o=0;break;case 2:return e.o=0,e.j=null,e.return(!1);case 3:return e.return(!0)}}),2)):d.return();case 2:if(n=d.h,"object"==typeof window)return Bt("createMediapipeSolutionsWasm",{locateFile:e.locateFile}),Bt("createMediapipeSolutionsPackedAssets",{locateFile:e.locateFile}),s=t.filter(function(e){return void 0!==e.data}),u=t.filter(function(e){return void 0===e.data}),c=Promise.all(s.map(function(t){var n=zt(e,t.url);if(void 0!==t.path){var r=t.path;n=n.then(function(t){return e.overrideFile(r,t),Promise.resolve(t)})}return n})),l=Promise.all(u.map(function(t){return void 0===t.simd||t.simd&&n||!t.simd&&!n?function(e){var t=document.createElement("script");return t.setAttribute("src",e),t.setAttribute("crossorigin","anonymous"),new Promise(function(e){t.addEventListener("load",function(){e()},!1),t.addEventListener("error",function(){e()},!1),document.body.appendChild(t)})}(e.locateFile(t.url,e.$)):Promise.resolve()})).then(function(){var t,n,r;return S(function(a){if(1==a.g)return t=window.createMediapipeSolutionsWasm,n=window.createMediapipeSolutionsPackedAssets,r=e,y(a,t(n),2);r.h=a.h,a.g=0})}),p=S(function(t){return e.g.graph&&e.g.graph.url?t=y(t,zt(e,e.g.graph.url),0):(t.g=0,t=void 0),t}),y(d,Promise.all([l,c,p]),7);if("function"!=typeof importScripts)throw Error("solutions can only be loaded on a web page or in a web worker");return r=t.filter(function(e){return void 0===e.simd||e.simd&&n||!e.simd&&!n}).map(function(t){return e.locateFile(t.url,e.$)}),importScripts.apply(null,i(r)),a=e,y(d,createMediapipeSolutionsWasm(Module),6);
2case 6:a.h=d.h,e.l=new OffscreenCanvas(1,1),e.h.canvas=e.l,o=e.h.GL.createContext(e.l,{antialias:!1,alpha:!1,ja:"undefined"!=typeof WebGL2RenderingContext?2:1}),e.h.GL.makeContextCurrent(o),d.g=4;break;case 7:if(e.l=document.createElement("canvas"),!(h=e.l.getContext("webgl2",{}))&&!(h=e.l.getContext("webgl",{})))return alert("Failed to create WebGL canvas context when passing video frame."),d.return();e.G=h,e.h.canvas=e.l,e.h.createContext(e.l,!0,!0,{});case 4:e.i=new e.h.SolutionWasm,e.Z=!1,d.g=0}})}(e),2):3!=t.g?y(t,function(e){var t,n,r,a,o,i,u,c;return S(function(l){if(1==l.g)return e.g.graph&&e.g.graph.url&&e.Y===e.g.graph.url?l.return():(e.s=!0,e.g.graph&&e.g.graph.url?(e.Y=e.g.graph.url,y(l,zt(e,e.g.graph.url),3)):void(l.g=2));for(2!=l.g&&(t=l.h,e.i.loadGraph(t)),n=s(Object.keys(e.C)),r=n.next();!r.done;r=n.next())a=r.value,e.i.overrideFile(a,e.C[a]);if(e.C={},e.g.listeners)for(o=s(e.g.listeners),i=o.next();!i.done;i=o.next())u=i.value,Wt(e,u);c=e.j,e.j={},e.setOptions(c),l.g=0})}(e),3):y(t,function(e){var t,n,r,a,o,i;return S(function(u){switch(u.g){case 1:if(!e.s)return u.return();if(!e.A){u.g=2;break}t=s(e.A),n=t.next();case 3:if(n.done){u.g=5;break}return y(u,(0,n.value)(),4);case 4:n=t.next(),u.g=3;break;case 5:e.A=void 0;case 2:if(e.B){for(r=new e.h.GraphOptionChangeRequestList,a=s(e.B),o=a.next();!o.done;o=a.next())i=o.value,r.push_back(i);e.i.changeOptions(r),r.delete(),e.B=void 0}e.s=!1,u.g=0}})}(e),0)})},e.overrideFile=function(e,t){this.i?this.i.overrideFile(e,t):this.C[e]=t},e.clearOverriddenFiles=function(){this.C={},this.i&&this.i.clearOverriddenFiles()},e.send=function(e,t){var n,r,a,o,i,u,c,l,p,h=this;return S(function(d){switch(d.g){case 1:return h.g.inputs?(n=1e3*(null==t?performance.now():t),y(d,h.D,2)):d.return();case 2:return y(d,h.initialize(),3);case 3:for(r=new h.h.PacketDataList,a=s(Object.keys(e)),o=a.next();!o.done;o=a.next())if(i=o.value,u=h.g.inputs[i]){e:{var f=e[i];switch(u.type){case"video":var m=h.o[u.stream];if(m||(m=new Ft(h.h,h.G),h.o[u.stream]=m),0===m.l&&(m.l=m.h.createTexture()),"undefined"!=typeof HTMLVideoElement&&f instanceof HTMLVideoElement)var g=f.videoWidth,x=f.videoHeight;else"undefined"!=typeof HTMLImageElement&&f instanceof HTMLImageElement?(g=f.naturalWidth,x=f.naturalHeight):(g=f.width,x=f.height);x={glName:m.l,width:g,height:x},(g=m.g).canvas.width=x.width,g.canvas.height=x.height,g.activeTexture(g.TEXTURE0),m.h.bindTexture2d(m.l),g.texImage2D(g.TEXTURE_2D,0,g.RGBA,g.RGBA,g.UNSIGNED_BYTE,f),m.h.bindTexture2d(0),m=x;break e;case"detections":for((m=h.o[u.stream])||(m=new Lt(h.h),h.o[u.stream]=m),m.data||(m.data=new m.g.DetectionListData),m.data.reset(f.length),x=0;x<f.length;++x){g=f[x];var b=m.data,v=b.setBoundingBox,w=x,T=g.boundingBox,S=new Tt;if(xe(S,1,T.xCenter),xe(S,2,T.yCenter),xe(S,3,T.height),xe(S,4,T.width),xe(S,5,T.rotation),xe(S,6,T.rectId),T=rt(S,St),v.call(b,w,T),g.landmarks)for(b=0;b<g.landmarks.length;++b){var C=!!(S=g.landmarks[b]).visibility;w=(v=m.data).addNormalizedLandmark,T=x,S=Object.assign(Object.assign({},S),{visibility:C?S.visibility:0}),xe(C=new yt,1,S.x),xe(C,2,S.y),xe(C,3,S.z),S.visibility&&xe(C,4,S.visibility),S=rt(C,xt),w.call(v,T,S)}if(g.V)for(b=0;b<g.V.length;++b)w=(v=m.data).addClassification,T=x,S=g.V[b],xe(C=new ht,2,S.ga),S.index&&xe(C,1,S.index),S.label&&xe(C,3,S.label),S.displayName&&xe(C,4,S.displayName),S=rt(C,dt),w.call(v,T,S)}m=m.data;break e;default:m={}}}switch(c=m,l=u.stream,u.type){case"video":r.pushTexture2d(Object.assign(Object.assign({},c),{stream:l,timestamp:n}));break;case"detections":(p=c).stream=l,p.timestamp=n,r.pushDetectionList(p);break;default:throw Error("Unknown input config type: '"+u.type+"'")}}return h.i.send(r),y(d,h.D,4);case 4:r.delete(),d.g=0}})},e.onResults=function(e,t){this.listeners[t||"$"]=e},E("Solution",Vt),E("OptionType",{BOOL:0,NUMBER:1,ia:2,0:"BOOL",1:"NUMBER",2:"STRING"}),(e=Gt.prototype).close=function(){return this.g.close(),Promise.resolve()},e.onResults=function(e){this.g.onResults(e)},e.initialize=function(){var e=this;return S(function(t){return y(t,e.g.initialize(),0)})},e.reset=function(){this.g.reset()},e.send=function(e){var t=this;return S(function(n){return y(n,t.g.send(e),0)})},e.setOptions=function(e){this.g.setOptions(e)},E("FaceDetection",Gt),E("FACEDETECTION_LIPS",Ct),E("FACEDETECTION_LEFT_EYE",kt),E("FACEDETECTION_LEFT_EYEBROW",Et),E("FACEDETECTION_RIGHT_EYE",$t),E("FACEDETECTION_RIGHT_EYEBROW",Nt),E("FACEDETECTION_FACE_OVAL",It),E("FACEDETECTION_CONTOURS",At),E("FACEDETECTION
vendor: 24,396 bytes, line 2
2_TESSELATION",[[127,34],[34,139],[139,127],[11,0],[0,37],[37,11],[232,231],[231,120],[120,232],[72,37],[37,39],[39,72],[128,121],[121,47],[47,128],[232,121],[121,128],[128,232],[104,69],[69,67],[67,104],[175,171],[171,148],[148,175],[118,50],[50,101],[101,118],[73,39],[39,40],[40,73],[9,151],[151,108],[108,9],[48,115],[115,131],[131,48],[194,204],[204,211],[211,194],[74,40],[40,185],[185,74],[80,42],[42,183],[183,80],[40,92],[92,186],[186,40],[230,229],[229,118],[118,230],[202,212],[212,214],[214,202],[83,18],[18,17],[17,83],[76,61],[61,146],[146,76],[160,29],[29,30],[30,160],[56,157],[157,173],[173,56],[106,204],[204,194],[194,106],[135,214],[214,192],[192,135],[203,165],[165,98],[98,203],[21,71],[71,68],[68,21],[51,45],[45,4],[4,51],[144,24],[24,23],[23,144],[77,146],[146,91],[91,77],[205,50],[50,187],[187,205],[201,200],[200,18],[18,201],[91,106],[106,182],[182,91],[90,91],[91,181],[181,90],[85,84],[84,17],[17,85],[206,203],[203,36],[36,206],[148,171],[171,140],[140,148],[92,40],[40,39],[39,92],[193,189],[189,244],[244,193],[159,158],[158,28],[28,159],[247,246],[246,161],[161,247],[236,3],[3,196],[196,236],[54,68],[68,104],[104,54],[193,168],[168,8],[8,193],[117,228],[228,31],[31,117],[189,193],[193,55],[55,189],[98,97],[97,99],[99,98],[126,47],[47,100],[100,126],[166,79],[79,218],[218,166],[155,154],[154,26],[26,155],[209,49],[49,131],[131,209],[135,136],[136,150],[150,135],[47,126],[126,217],[217,47],[223,52],[52,53],[53,223],[45,51],[51,134],[134,45],[211,170],[170,140],[140,211],[67,69],[69,108],[108,67],[43,106],[106,91],[91,43],[230,119],[119,120],[120,230],[226,130],[130,247],[247,226],[63,53],[53,52],[52,63],[238,20],[20,242],[242,238],[46,70],[70,156],[156,46],[78,62],[62,96],[96,78],[46,53],[53,63],[63,46],[143,34],[34,227],[227,143],[123,117],[117,111],[111,123],[44,125],[125,19],[19,44],[236,134],[134,51],[51,236],[216,206],[206,205],[205,216],[154,153],[153,22],[22,154],[39,37],[37,167],[167,39],[200,201],[201,208],[208,200],[36,142],[142,100],[100,36],[57,212],[212,202],[202,57],[20,60],[60,99],[99,20],[28,158],[158,157],[157,28],[35,226],[226,113],[113,35],[160,159],[159,27],[27,160],[204,202],[202,210],[210,204],[113,225],[225,46],[46,113],[43,202],[202,204],[204,43],[62,76],[76,77],[77,62],[137,123],[123,116],[116,137],[41,38],[38,72],[72,41],[203,129],[129,142],[142,203],[64,98],[98,240],[240,64],[49,102],[102,64],[64,49],[41,73],[73,74],[74,41],[212,216],[216,207],[207,212],[42,74],[74,184],[184,42],[169,170],[170,211],[211,169],[170,149],[149,176],[176,170],[105,66],[66,69],[69,105],[122,6],[6,168],[168,122],[123,147],[147,187],[187,123],[96,77],[77,90],[90,96],[65,55],[55,107],[107,65],[89,90],[90,180],[180,89],[101,100],[100,120],[120,101],[63,105],[105,104],[104,63],[93,137],[137,227],[227,93],[15,86],[86,85],[85,15],[129,102],[102,49],[49,129],[14,87],[87,86],[86,14],[55,8],[8,9],[9,55],[100,47],[47,121],[121,100],[145,23],[23,22],[22,145],[88,89],[89,179],[179,88],[6,122],[122,196],[196,6],[88,95],[95,96],[96,88],[138,172],[172,136],[136,138],[215,58],[58,172],[172,215],[115,48],[48,219],[219,115],[42,80],[80,81],[81,42],[195,3],[3,51],[51,195],[43,146],[146,61],[61,43],[171,175],[175,199],[199,171],[81,82],[82,38],[38,81],[53,46],[46,225],[225,53],[144,163],[163,110],[110,144],[52,65],[65,66],[66,52],[229,228],[228,117],[117,229],[34,127],[127,234],[234,34],[107,108],[108,69],[69,107],[109,108],[108,151],[151,109],[48,64],[64,235],[235,48],[62,78],[78,191],[191,62],[129,209],[209,126],[126,129],[111,35],[35,143],[143,111],[117,123],[123,50],[50,117],[222,65],[65,52],[52,222],[19,125],[125,141],[141,19],[221,55],[55,65],[65,221],[3,195],[195,197],[197,3],[25,7],[7,33],[33,25],[220,237],[237,44],[44,220],[70,71],[71,139],[139,70],[122,193],[193,245],[245,122],[247,130],[130,33],[33,247],[71,21],[21,162],[162,71],[170,169],[169,150],[150,170],[188,174],[174,196],[196,188],[216,186],[186,92],[92,216],[2,97],[97,167],[167,2],[141,125],[125,241],[241,141],[164,167],[167,37],[37,164],[72,38],[38,12],[12,72],[38,82],[82,13],[13,38],[63,68],[68,71],[71,63],[226,35],[35,111],[111,226],[101,50],[50,205],[205,101],[206,92],[92,165],[165,206],[209,198],[198,217],[217,209],[165,167],[167,97],[97,165],[220,115],[115,218],[218,220],[133,112],[112,243],[243,133],[239,238],[238,241],[241,239],[214,135],[135,169],[169,214],[190,173],[173,133],[133,190],[171,208],[208,32],[32,171],[125,44],[44,237],[237,125],[86,87],[87,178],[178,86],[85,86],[86,179],[179,85],[84,85],[85,180],[180,84],[83,84],[84,181],[181,83],[201,83],[83,182],[182,201],[137,93],[93,132],[132,137],[76,62],[62,183],[183,76],[61,76],[76,184],[184,61],[57,61],[61,185],[185,57],[212,57],[57,186],[186,212],[214,207],[207,187],[187,214],[34,143],[143,156],[156,34],[79,239],[239,237],[237,79],[123,137],[137,177],[177,123],[44,1],[1,4],[4,44],[201,194],[194,32],[32,201],[64,102],[102,129],[129,64],[213,215],[215,138],[138,213],[59,166],[166,219],[219,59],[242,99],[99,97],[97,242],[2,94],[94,141],[141,2],[75,59],[59,235],[235,75],[24,110],[110,228],[228,24],[25,130],[130,226],[226,25],[23,24],[24,229],[229,23],[22,23],[23,230],[230,22],[26,22],[22,231],[231,26],[112,26],[26,232],[232,112],[189,190],[190,243],[243,189],[221,56],[56,190],[190,221],[28,56],[56,221],[221,28],[27,28],[28,222],[222,27],[29,27],[27,223],[223,29],[30,29],[29,224],[224,30],[247,30],[30,225],[225,247],[238,79],[79,20],[20,238],[166,59],[59,75],[75,166],[60,75],[75,240],[240,60],[147,177],[177,215],[215,147],[20,79],[79,166],[166,20],[187,147],[147,213],[213,187],[112,233],[233,244],[244,112],[233,128],[128,245],[245,233],[128,114],[114,188],[188,128],[114,217],[217,174],[174,114],[131,115],[115,220],[220,131],[217,198],[198,236],[236,217],[198,131],[131,134],[134,198],[177,132],[132,58],[58,177],[143,35],[35,124],[124,143],[110,163],[163,7],[7,110],[228,110],[110,25],[25,228],[356,389],[389,368],[368,356],[11,302],[302,267],[267,11],[452,350],[350,349],[349,452],[302,303],[303,269],[269,302],[357,343],[343,277],[277,357],[452,453],[453,357],[357,452],[333,332],[332,297],[297,333],[175,152],[152,377],[377,175],[347,348],[348,330],[330,347],[303,304],[304,270],[270,303],[9,336],[336,337],[337,9],[278,279],[279,360],[360,278],[418,262],[262,431],[431,418],[304,408],[408,409],[409,304],[310,415],[415,407],[407,310],[270,409],[409,410],[410,270],[450,348],[348,347],[347,450],[422,430],[430,434],[434,422],[313,314],[314,17],[17,313],[306,307],[307,375],[375,306],[387,388],[388,260],[260,387],[286,414],[414,398],[398,286],[335,406],[406,418],[418,335],[364,367],[367,416],[416,364],[423,358],[358,327],[327,423],[251,284],[284,298],[298,251],[281,5],[5,4],[4,281],[373,374],[374,253],[253,373],[307,320],[320,321],[321,307],[425,427],[427,411],[411,425],[421,313],[313,18],[18,421],[321,405],[405,406],[406,321],[320,404],[404,405],[405,320],[315,16],[16,17],[17,315],[426,425],[425,266],[266,426],[377,400],[400,369],[369,377],[322,391],[391,269],[269,322],[417,465],[465,464],[464,417],[386,257],[257,258],[258,386],[466,260],[260,388],[388,466],[456,399],[399,419],[419,456],[284,332],[332,333],[333,284],[417,285],[285,8],[8,417],[346,340],[340,261],[261,346],[413,441],[441,285],[285,413],[327,460],[460,328],[328,327],[355,371],[371,329],[329,355],[392,439],[439,438],[438,392],[382,341],[341,256],[256,382],[429,420],[420,360],[360,429],[364,394],[394,379],[379,364],[277,343],[343,437],[437,277],[443,444],[444,283],[283,443],[275,440],[440,363],[363,275],[431,262],[262,369],[369,431],[297,338],[338,337],[337,297],[273,375],[375,321],[321,273],[450,451],[451,349],[349,450],[446,342],[342,467],[467,446],[293,334],[334,282],[282,293],[458,461],[461,462],[462,458],[276,353],[353,383],[383,276],[308,324],[324,325],[325,308],[276,300],[300,293],[293,276],[372,345],[345,447],[447,372],[352,345],[345,340],[340,352],[274,1],[1,19],[19,274],[456,248],[248,281],[281,456],[436,427],[427,425],[425,436],[381,256],[256,252],[252,381],[269,391],[391,393],[393,269],[200,199],[199,428],[428,200],[266,330],[330,329],[329,266],[287,273],[273,422],[422,287],[250,462],[462,328],[328,250],[258,286],[286,384],[384,258],[265,353],[353,342],[342,265],[387,259],[259,257],[257,387],[424,431],[431,430],[430,424],[342,353],[353,276],[276,342],[273,335],[335,424],[424,273],[292,325],[325,307],[307,292],[366,447],[447,345],[345,366],[271,303],[303,302],[302,271],[423,266],[266,371],[371,423],[294,455],[455,460],[460,294],[279,278],[278,294],[294,279],[271,272],[272,304],[304,271],[432,434],[434,427],[427,432],[272,407],[407,408],[408,272],[394,430],[430,431],[431,394],[395,369],[369,400],[400,395],[334,333],[333,299],[299,334],[351,417],[417,168],[168,351],[352,280],[280,411],[411,352],[325,319],[319,320],[320,325],[295,296],[296,336],[336,295],[319,403],[403,404],[404,319],[330,348],[348,349],[349,330],[293,298],[298,333],[333,293],[323,454],[454,447],[447,323],[15,16],[16,315],[315,15],[358,429],[429,279],[279,358],[14,15],[15,316],[316,14],[285,336],[336,9],[9,285],[329,349],[349,350],[350,329],[374,380],[380,252],[252,374],[318,402],[402,403],[403,318],[6,197],[197,419],[419,6],[318,319],[319,325],[325,318],[367,364],[364,365],[365,367],[435,367],[367,397],[397,435],[344,438],[438,439],[439,344],[272,271],[271,311],[311,272],[195,5],[5,281],[281,195],[273,287],[287,291],[291,273],[396,428],[428,199],[199,396],[311,271],[271,268],[268,311],[283,444],[444,445],[445,283],[373,254],[254,339],[339,373],[282,334],[334,296],[296,282],[449,347],[347,346],[346,449],[264,447],[447,454],[454,264],[336,296],[296,299],[299,336],[338,10],[10,151],[151,338],[278,439],[439,455],[455,278],[292,407],[407,415],[415,292],[358,371],[371,355],[355,358],[340,345],[345,372],[372,340],[346,347],[347,280],[280,346],[442,443],[443,282],[282,442],[19,94],[94,370],[370,19],[441,442],[442,295],[295,441],[248,419],[419,197],[197,248],[263,255],[255,359],[359,263],[440,275],[275,274],[274,440],[300,383],[383,368],[368,300],[351,412],[412,465],[465,351],[263,467],[467,466],[466,263],[301,368],[368,389],[389,301],[395,378],[378,379],[379,395],[412,351],[351,419],[419,412],[436,426],[426,322],[322,436],[2,164],[164,393],[393,2],[370,462],[462,461],[461,370],[164,0],[0,267],[267,164],[302,11],[11,12],[12,302],[268,12],[12,13],[13,268],[293,300],[300,301],[301,293],[446,261],[261,340],[340,446],[330,266],[266,425],[425,330],[426,423],[423,391],[391,426],[429,355],[355,437],[437,429],[391,327],[327,326],[326,391],[440,457],[457,438],[438,440],[341,382],[382,362],[362,341],[459,457],[457,461],[461,459],[434,430],[430,394],[394,434],[414,463],[463,362],[362,414],[396,369],[369,262],[262,396],[354,461],[461,457],[457,354],[316,403],[403,402],[402,316],[315,404],[404,403],[403,315],[314,405],[405,404],[404,314],[313,406],[406,405],[405,313],[421,418],[418,406],[406,421],[366,401],[401,361],[361,366],[306,408],[408,407],[407,306],[291,409],[409,408],[408,291],[287,410],[410,409],[409,287],[432,436],[436,410],[410,432],[434,416],[416,411],[411,434],[264,368],[368,383],[383,264],[309,438],[438,457],[457,309],[352,376],[376,401],[401,352],[274,275],[275,4],[4,274],[421,428],[428,262],[262,421],[294,327],[327,358],[358,294],[433,416],[416,367],[367,433],[289,455],[455,439],[439,289],[462,370],[370,326],[326,462],[2,326],[326,370],[370,2],[305,460],[460,455],[455,305],[254,449],[449,448],[448,254],[255,261],[261,446],[446,255],[253,450],[450,449],[449,253],[252,451],[451,450],[450,252],[256,452],[452,451],[451,256],[341,453],[453,452],[452,341],[413,464],[464,463],[463,413],[441,413],[413,414],[414,441],[258,442],[442,441],[441,258],[257,443],[443,442],[442,257],[259,444],[444,443],[443,259],[260,445],[445,444],[444,260],[467,342],[342,445],[445,467],[459,458],[458,250],[250,459],[289,392],[392,290],[290,289],[290,328],[328,460],[460,290],[376,433],[433,435],[435,376],[250,290],[290,392],[392,250],[411,416],[416,433],[433,411],[341,463],[463,464],[464,341],[453,464],[464,465],[465,453],[357,465],[465,412],[412,357],[343,412],[412,399],[399,343],[360,363],[363,440],[440,360],[437,399],[399,456],[456,437],[420,456],[456,363],[363,420],[401,435],[435,288],[288,401],[372,383],[383,353],[353,372],[339,255],[255,249],[249,339],[448,261],[261,255],[255,448],[133,243],[243,190],[190,133],[133,155],[155,112],[112,133],[33,246],[246,247],[247,33],[33,130],[130,25],[25,33],[398,384],[384,286],[286,398],[362,398],[398,414],[414,362],[362,463],[463,341],[341,362],[263,359],[359,467],[467,263],[263,249],[249,255],[255,263],[466,467],[467,260],[260,466],[75,60],[60,166],[166,75],[238,239],[239,79],[79,238],[162,127],[127,139],[139,162],[72,11],[11,37],[37,72],[121,232],[232,120],[120,121],[73,72],[72,39],[39,73],[114,128],[128,47],[47,114],[233,232],[232,128],[128,233],[103,104],[104,67],[67,103],[152,175],[175,148],[148,152],[119,118],[118,101],[101,119],[74,73],[73,40],[40,74],[107,9],[9,108],[108,107],[49,48],[48,131],[131,49],[32,194],[194,211],[211,32],[184,74],[74,185],[185,184],[191,80],[80,183],[183,191],[185,40],[40,186],[186,185],[119,230],[230,118],[118,119],[210,202],[202,214],[214,210],[84,83],[83,17],[17,84],[77,76],[76,146],[146,77],[161,160],[160,30],[30,161],[190,56],[56,173],[173,190],[182,106],[106,194],[194,182],[138,135],[135,192],[192,138],[129,203],[203,98],[98,129],[54,21],[21,68],[68,54],[5,51],[51,4],[4,5],[145,144],[144,23],[23,145],[90,77],[77,91],[91,90],[207,205],[205,187],[187,207],[83,201],[201,18],[18,83],[181,91],[91,182],[182,181],[180,90],[90,181],[181,180],[16,85],[85,17],[17,16],[205,206],[206,36],[36,205],[176,148],[148,140],[140,176],[165,92],[92,39],[39,165],[245,193],[193,244],[244,245],[27,159],[159,28],[28,27],[30,247],[247,161],[161,30],[174,236],[236,196],[196,174],[103,54],[54,104],[104,103],[55,193],[193,8],[8,55],[111,117],[117,31],[31,111],[221,189],[189,55],[55,221],[240,98],[98,99],[99,240],[142,126],[126,100],[100,142],[219,166],[166,218],[218,219],[112,155],[155,26],[26,112],[198,209],[209,131],[131,198],[169,135],[135,150],[150,169],[114,47],[47,217],[217,114],[224,223],[223,53],[53,224],[220,45],[45,134],[134,220],[32,211],[211,140],[140,32],[109,67],[67,108],[108,109],[146,43],[43,91],[91,146],[231,230],[230,120],[120,231],[113,226],[226,247],[247,113],[105,63],[63,52],[52,105],[241,238],[238,242],[242,241],[124,46],[46,156],[156,124],[95,78],[78,96],[96,95],[70,46],[46,63],[63,70],[116,143],[143,227],[227,116],[116,123],[123,111],[111,116],[1,44],[44,19],[19,1],[3,236],[236,51],[51,3],[207,216],[216,205],[205,207],[26,154],[154,22],[22,26],[165,39],[39,167],[167,165],[199,200],[200,208],[208,199],[101,36],[36,100],[100,101],[43,57],[57,202],[202,43],[242,20],[20,99],[99,242],[56,28],[28,157],[157,56],[124,35],[35,113],[113,124],[29,160],[160,27],[27,29],[211,204],[204,210],[210,211],[124,113],[113,46],[46,124],[106,43],[43,204],[204,106],[96,62],[62,77],[77,96],[227,137],[137,116],[116,227],[73,41],[41,72],[72,73],[36,203],[203,142],[142,36],[235,64],[64,240],[240,235],[48,49],[49,64],[64,48],[42,41],[41,74],[74,42],[214,212],[212,207],[207,214],[183,42],[42,184],[184,183],[210,169],[169,211],[211,210],[140,170],[170,176],[176,140],[104,105],[105,69],[69,104],[193,122],[122,168],[168,193],[50,123],[123,187],[187,50],[89,96],[96,90],[90,89],[66,65],[65,107],[107,66],[179,89],[89,180],[180,179],[119,101],[101,120],[120,119],[68,63],[63,104],[104,68],[234,93],[93,227],[227,234],[16,15],[15,85],[85,16],[209,129],[129,49],[49,209],[15,14],[14,86],[86,15],[107,55],[55,9],[9,107],[120,100],[100,121],[121,120],[153,145],[145,22],[22,153],[178,88],[88,179],[179,178],[197,6],[6,196],[196,197],[89,88],[88,96],[96,89],[135,138],[138,136],[136,135],[138,215],[215,172],[172,138],[218,115],[115,219],[219,218],[41,42],[42,81],[81,41],[5,195],[195,51],[51,5],[57,43],[43,61],[61,57],[208,171],[171,199],[199,208],[41,81],[81,38],[38,41],[224,53],[53,225],[225,224],[24,144],[144,110],[110,24],[105,52],[52,66],[66,105],[118,229],[229,117],[117,118],[227,34],[34,234],[234,227],[66,107],[107,69],[69,66],[10,109],[109,151],[151,10],[219,48],[48,235],[235,219],[183,62],[62,191],[191,183],[142,129],[129,126],[126,142],[116,111],[111,143],[143,116],[118,117],[117,50],[50,118],[223,222],[222,52],[52,223],[94,19],[19,141],[141,94],[222,221],[221,65],[65,222],[196,3],[3,197],[197,196],[45,220],[220,44],[44,45],[156,70],[70,139],[139,156],[188,122],[122,245],[245,188],[139,71],[71,162],[162,139],[149,170],[170,150],[150,149],[122,188],[188,196],[196,122],[206,216],[216,92],[92,206],[164,2],[2,167],[167,164],[242,141],[141,241],[241,242],[0,164],[164,37],[37,0],[11,72],[72,12],[12,11],[12,38],[38,13],[13,12],[70,63],[63,71],[71,70],[31,226],[226,111],[111,31],[36,101],[101,205],[205,36],[203,206],[206,165],[165,203],[126,209],[209,217],[217,126],[98,165],[165,97],[97,98],[237,220],[220,218],[218,237],[237,239],[239,241],[241,237],[210,214],[214,169],[169,210],[140,171],[171,32],[32,140],[241,125],[125,237],[237,241],[179,86],[86,178],[178,179],[180,85],[85,179],[179,180],[181,84],[84,180],[180,181],[182,83],[83,181],[181,182],[194,201],[201,182],[182,194],[177,137],[137,132],[132,177],[184,76],[76,183],[183,184],[185,61],[61,184],[184,185],[186,57],[57,185],[185,186],[216,212],[212,186],[186,216],[192,214],[214,187],[187,192],[139,34],[34,156],[156,139],[218,79],[79,237],[237,218],[147,123],[123,177],[177,147],[45,44],[44,4],[4,45],[208,201],[201,32],[32,208],[98,64],[64,129],[129,98],[192,213],[213,138],[138,192],[235,59],[59,219],[219,235],[141,242],[242,97],[97,141],[97,2],[2,141],[141,97],[240,75],[75,235],[235,240],[229,24],[24,228],[228,229],[31,25],[25,226],[226,31],[230,23],[23,229],[229,230],[231,22],[22,230],[230,231],[232,26],[26,231],[231,232],[233,112],[112,232],[232,233],[244,189],[189,243],[243,244],[189,221],[221,190],[190,189],[222,28],[28,221],[221,222],[223,27],[27,222],[222,223],[224,29],[29,223],[223,224],[225,30],[30,224],[224,225],[113,247],[247,225],[225,113],[99,60],[60,240],[240,99],[213,147],[147,215],[215,213],[60,20],[20,166],[166,60],[192,187],[187,213],[213,192],[243,112],[112,244],[244,243],[244,233],[233,245],[245,244],[245,128],[128,188],[188,245],[188,114],[114,174],[174,188],[134,131],[131,220],[220,134],[174,217],[217,236],[236,174],[236,198],[198,134],[134,236],[215,177],[177,58],[58,215],[156,143],[143,124],[124,156],[25,110],[110,7],[7,25],[31,228],[228,25],[25,31],[264,356],[356,368],[368,264],[0,11],[11,267],[267,0],[451,452],[452,349],[349,451],[267,302],[302,269],[269,267],[350,357],[357,277],[277,350],[350,452],[452,357],[357,350],[299,333],[333,297],[297,299],[396,175],[175,377],[377,396],[280,347],[347,330],[330,280],[269,303],[303,270],[270,269],[151,9],[9,337],[337,151],[344,278],[278,360],[360,344],[424,418],[418,431],[431,424],[270,304],[304,409],[409,270],[272,310],[310,407],[407,272],[322,270],[270,410],[410,322],[449,450],[450,347],[347,449],[432,422],[422,434],[434,432],[18,313],[313,17],[17,18],[291,306],[306,375],[375,291],[259,387],[387,260],[260,259],[424,335],[335,418],[418,424],[434,364],[364,416],[416,434],[391,423],[423,327],[327,391],[301,251],[251,298],[298,301],[275,281],[281,4],[4,275],[254,373],[373,253],[253,254],[375,307],[307,321],[321,375],[280,425],[425,411],[411,280],[200,421],[421,18],[18,200],[335,321],[321,406],[406,335],[321,320],[320,405],[405,321],[314,315],[315,17],[17,314],[423,426],[426,266],[266,423],[396,377],[377,369],[369,396],[270,322],[322,269],[269,270],[413,417],[417,464],[464,413],[385,386],[386,258],[258,385],[248,456],[456,419],[419,248],[298,284],[284,333],[333,298],[168,417],[417,8],[8,168],[448,346],[346,261],[261,448],[417,413],[413,285],[285,417],[326,327],[327,328],[328,326],[277,355],[355,329],[329,277],[309,392],[392,438],[438,309],[381,382],[382,256],[256,381],[279,429],[429,360],[360,279],[365,364],[364,379],[379,365],[355,277],[277,437],[437,355],[282,443],[443,283],[283,282],[281,275],[275,363],[363,281],[395,431],[431,369],[369,395],[299,297],[297,337],[337,299],[335,273],[273,321],[321,335],[348,450],[450,349],[349,348],[359,446],[446,467],[467,359],[283,293],[293,282],[282,283],[250,458],[458,462],[462,250],[300,276],[276,383],[383,300],[292,308],[308,325],[325,292],[283,276],[276,293],[293,283],[264,372],[372,447],[447,264],[346,352],[352,340],[340,346],[354,274],[274,19],[19,354],[363,456],[456,281],[281,363],[426,436],[436,425],[425,426],[380,381],[381,252],[252,380],[267,269],[269,393],[393,267],[421,200],[200,428],[428,421],[371,266],[266,329],[329,371],[432,287],[287,422],[422,432],[290,250],[250,328],[328,290],[385,258],[258,384],[384,385],[446,265],[265,342],[342,446],[386,387],[387,257],[257,386],[422,424],[424,430],[430,422],[445,342],[342,276],[276,445],[422,273],[273,424],[424,422],[306,292],[292,307],[307,306],[352,366],[366,345],[345,352],[268,271],[271,302],[302,268],[358,423],[423,371],[371,358],[327,294],[294,460],[460,327],[331,279],[279,294],[294,331],[303,271],[271,304],[304,303],[436,432],[432,427],[427,436],[304,272],[272,408],[408,304],[395,394],[394,431],[431,395],[378,395],[395,400],[400,378],[296,334],[334,299],[299,296],[6,351],[351,168],[168,6],[376,352],[352,411],[411,376],[307,325],[325,320],[320,307],[285,295],[295,336],[336,285],[320,319],[319,404],[404,320],[329,330],[330,349],[349,329],[334,293],[293,333],[333,334],[366,323],[323,447],[447,366],[316,15],[15,315],[315,316],[331,358],[358,279],[279,331],[317,14],[14,316],[316,317],[8,285],[285,9],[9,8],[277,329],[329,350],[350,277],[253,374],[374,252],[252,253],[319,318],[318,403],[403,319],[351,6],[6,419],[419,351],[324,318],[318,325],[325,324],[397,367],[367,365],[365,397],[288,435],[435,397],[397,288],[278,344],[344,439],[439,278],[310,272],[272,311],[311,310],[248,195],[195,281],[281,248],[375,273],[273,291],[291,375],[175,396],[396,199],[199,175],[312,311],[311,268],[268,312],[276,283],[283,445],[445,276],[390,373],[373,339],[339,390],[295,282],[282,296],[296,295],[448,449],[449,346],[346,448],[356,264],[264,454],[454,356],[337,336],[336,299],[299,337],[337,338],[338,151],[151,337],[294,278],[278,455],[455,294],[308,292],[292,415],[415,308],[429,358],[358,355],[355,429],[265,340],[340,372],[372,265],[352,346],[346,280],[280,352],[295,442],[442,282],[282,295],[354,19],[19,370],[370,354],[285,441],[441,295],[295,285],[195,248],[248,197],[197,195],[457,440],[440,274],[274,457],[301,300],[300,368],[368,301],[417,351],[351,465],[465,417],[251,301],[301,389],[389,251],[394,395],[395,379],[379,394],[399,412],[412,419],[419,399],[410,436],[436,322],[322,410],[326,2],[2,393],[393,326],[354,370],[370,461],[461,354],[393,164],[164,267],[267,393],[268,302],[302,12],[12,268],[312,268],[268,13],[13,312],[298,293],[293,301],[301,298],[265,446],[446,340],[340,265],[280,330],[330,425],[425,280],[322,426],[426,391],[391,322],[420,429],[429,437],[437,420],[393,391],[391,326],[326,393],[344,440],[440,438],[438,344],[458,459],[459,461],[461,458],[364,434],[434,394],[394,364],[428,396],[396,262],[262,428],[274,354],[354,457],[457,274],[317,316],[316,402],[402,317],[316,315],[315,403],[403,316],[315,314],[314,404],[404,315],[314,313],[313,405],[405,314],[313,421],[421,406],[406,313],[323,366],[366,361],[361,323],[292,306],[306,407],[407,292],[306,291],[291,408],[408,306],[291,287],[287,409],[409,291],[287,432],[432,410],[410,287],[427,434],[434,411],[411,427],[372,264],[264,383],[383,372],[459,309],[309,457],[457,459],[366,352],[352,401],[401,366],[1,274],[274,4],[4,1],[418,421],[421,262],[262,418],[331,294],[294,358],[358,331],[435,433],[433,367],[367,435],[392,289],[289,439],[439,392],[328,462],[462,326],[326,328],[94,2],[2,370],[370,94],[289,305],[305,455],[455,289],[339,254],[254,448],[448,339],[359,255],[255,446],[446,359],[254,253],[253,449],[449,254],[253,252],[252,450],[450,253],[252,256],[256,451],[451,252],[256,341],[341,452],[452,256],[414,413],[413,463],[463,414],[286,441],[441,414],[414,286],[286,258],[258,441],[441,286],[258,257],[257,442],[442,258],[257,259],[259,443],[443,257],[259,260],[260,444],[444,259],[260,467],[467,445],[445,260],[309,459],[459,250],[250,309],[305,289],[289,290],[290,305],[305,290],[290,460],[460,305],[401,376],[376,435],[435,401],[309,250],[250,392],[392,309],[376,411],[411,433],[433,376],[453,341],[341,464],[464,453],[357,453],[453,465],[465,357],[343,357],[357,412],[412,343],[437,343],[343,399],[399,437],[344,360],[360,440],[440,344],[420,437],[437,456],[456,420],[360,420],[420,363],[363,360],[361,401],[401,288],[288,361],[265,372],[372,353],[353,265],[390,339],[339,249],[249,390],[339,448],[448,255],[255,339]]),E("VERSION","0.4.1646425229")}).call(
2x);var v=function(){return v=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var a in t=arguments[n])Object.prototype.hasOwnProperty.call(t,a)&&(e[a]=t[a]);return e},v.apply(this,arguments)};function w(e,t,n,r){return new(n||(n=Promise))(function(a,o){function s(e){try{u(r.next(e))}catch(e){o(e)}}function i(e){try{u(r.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?a(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,i)}u((r=r.apply(e,t||[])).next())})}function T(e,t){var n,r,a,o,s={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return o={next:i(0),throw:i(1),return:i(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function i(o){return function(i){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(a=2&o[0]?r.return:o[0]?r.throw||((a=r.return)&&a.call(r),0):r.next)&&!(a=a.call(r,o[1])).done)return a;switch(r=0,a&&(o=[2&o[0],a.value]),o[0]){case 0:case 1:a=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,r=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!((a=(a=s.trys).length>0&&a[a.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!a||o[1]>a[0]&&o[1]<a[3])){s.label=o[1];break}if(6===o[0]&&s.label<a[1]){s.label=a[1],a=o;break}if(a&&s.label<a[2]){s.label=a[2],s.ops.push(o);break}a[2]&&s.ops.pop(),s.trys.pop();continue}o=t.call(e,s)}catch(e){o=[6,e],r=0}finally{n=a=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,i])}}}var S=["rightEye","leftEye","noseTip","mouthCenter","rightEarTragion","leftEarTragion"],C={modelType:"short",runtime:"mediapipe",maxFaces:1},k=function(){function e(e){var t=this;this.width=0,this.height=0,this.selfieMode=!1,this.faceDetectorSolution=new b.FaceDetection({locateFile:function(t,n){return e.solutionPath?e.solutionPath.replace(/\/+$/,"")+"/"+t:n+"/"+t}}),this.faceDetectorSolution.setOptions({selfieMode:this.selfieMode,model:e.modelType}),this.faceDetectorSolution.onResults(function(e){if(t.height=e.image.height,t.width=e.image.width,t.faces=[],null!==e.detections)for(var n=0,r=e.detections;n<r.length;n++){var a=r[n];t.faces.push(t.normalizedToAbsolute(a.landmarks,{xMin:s=(o=a.boundingBox).xCenter-o.width/2,xMax:s+o.width,yMin:i=o.yCenter-o.height/2,yMax:i+o.height,width:o.width,height:o.height}))}var o,s,i})}return e.prototype.normalizedToAbsolute=function(e,t){var n=this;return{keypoints:e.map(function(e,t){return{x:e.x*n.width,y:e.y*n.height,name:S[t]}}),box:{xMin:t.xMin*this.width,yMin:t.yMin*this.height,xMax:t.xMax*this.width,yMax:t.yMax*this.height,width:t.width*this.width,height:t.height*this.height}}},e.prototype.estimateFaces=function(e,t){return w(this,void 0,void 0,function(){var n,r;return T(this,function(o){switch(o.label){case 0:return t&&t.flipHorizontal&&t.flipHorizontal!==this.selfieMode&&(this.selfieMode=t.flipHorizontal,this.faceDetectorSolution.setOptions({selfieMode:this.selfieMode})),e instanceof a.qYS?(r=ImageData.bind,[4,a.TaL.toPixels(e)]):[3,2];case 1:return n=new(r.apply(ImageData,[void 0,o.sent(),e.shape[1],e.shape[0]])),[3,3];case 2:n=e,o.label=3;case 3:return e=n,[4,this.faceDetectorSolution.send({image:e})];case 4:return o.sent(),[2,this.faces]}})})},e.prototype.dispose=function(){this.faceDetectorSolution.close()},e.prototype.reset=function(){this.faceDetectorSolution.reset(),this.width=0,this.height=0,this.faces=null,this.selfieMode=!1},e.prototype.initialize=function(){return this.faceDetectorSolution.initialize()},e}();function E(e){return w(this,void 0,void 0,function(){var t,n;return T(this,function(r){switch(r.label){case 0:return t=function(e){if(null==e)return v({},C);var t=v({},e);return t.runtime="mediapipe",null==t.modelType&&(t.modelType=C.modelType),null==t.maxFaces&&(t.maxFaces=C.maxFaces),t}(e),[4,(n=new k(t)).initialize()];case 1:return r.sent(),[2,n]}})})}function $(e){return e instanceof a.qYS?{height:e.shape[0],width:e.shape[1]}:{height:e.height,width:e.width}}function N(e){return e instanceof a.qYS?e:a.TaL.fromPixels(e)}function I(e,t){a.ZSL.assert(0!==e.width,function(){return t+" width cannot be 0."}),a.ZSL.assert(0!==e.height,function(){return t+" height cannot be 0."})}function A(e){null==e.reduceBoxesInLowestLayer&&(e.reduceBoxesInLowestLayer=!1),null==e.interpolatedScaleAspectRatio&&(e.interpolatedScaleAspectRatio=1),null==e.fixedAnchorSize&&(e.fixedAnchorSize=!1);for(var t=[],n=0;n<e.numLayers;){for(var r=[],a=[],o=[],s=[],i=n;i<e.strides.length&&e.strides[i]===e.strides[n];){var u=R(e.minScale,e.maxScale,i,e.strides.length);if(0===i&&e.reduceBoxesInLowestLayer)o.push(1),o.push(2),o.push(.5),s.push(.1),s.push(u),s.push(u);else{for(var c=0;c<e.aspectRatios.length;++c)o.push(e.aspectRatios[c]),s.push(u);if(e.interpolatedScaleAspectRatio>0){var l=i===e.strides.length-1?1:R(e.minScale,e.maxScale,i+1,e.strides.length);s.push(Math.sqrt(u*l)),o.push(e.interpolatedScaleAspectRatio)}}i++}for(var p=0;p<o.length;++p){var h=Math.sqrt(o[p]);r.push(s[p]/h),a.push(s[p]*h)}var d=0,f=0;if(e.featureMapHeight.length>0)d=e.featureMapHeight[n],f=e.featureMapWidth[n];else{var m=e.strides[n];d=Math.ceil(e.inputSizeHeight/m),f=Math.ceil(e.inputSizeWidth/m)}for(var g=0;g<d;++g)for(var y=0;y<f;++y)for(var x=0;x<r.length;++x){var b={xCenter:(y+e.anchorOffsetX)/f,yCenter:(g+e.anchorOffsetY)/d,width:0,height:0};e.fixedAnchorSize?(b.width=1,b.height=1):(b.width=a[x],b.height=r[x]),t.push(b)}n=i}return t}function R(e,t,n,r){return 1===r?.5*(e+t):e+(t-e)*n/(r-1)}function _(e,t){var n=t[0],r=t[1];return[n*e[0]+r*e[1]+e[3],n*e[4]+r*e[5]+e[7]]}function O(e,t,n,r){return w(this,void 0,void 0,function(){var r,o,s,i,u;return T(this,function(c){switch(c.label){case 0:return e.sort(function(e,t){return Math.max.apply(Math,t.score)-Math.max.apply(Math,e.score)}),r=(0,a.KtR)(e.map(function(e){return[e.locationData.relativeBoundingBox.yMin,e.locationData.relativeBoundingBox.xMin,e.locationData.relativeBoundingBox.yMax,e.locationData.relativeBoundingBox.xMax]})),o=(0,a.tGX)(e.map(function(e){return e.score[0]})),[4,a.Slp.nonMaxSuppressionAsync(r,o,t,n)];case 1:return[4,(s=c.sent()).array()];case 2:return i=c.sent(),u=e.filter(function(e,t){return i.indexOf(t)>-1}),(0,a.ASo)([r,o,s]),[2,u]}})})}function F(e,t,n){return w(this,void 0,void 0,function(){var r,o,s,i,u;return T(this,function(c){switch(c.label){case 0:return r=e[0],o=e[1],s=function(e,t,n){return(0,a.DZQ)(function(){var r,o,s,i;n.reverseOutputOrder?(o=(0,a.r2V)((0,a.dik)(e,[0,n.boxCoordOffset+0],[-1,1])),r=(0,a.r2V)((0,a.dik)(e,[0,n.boxCoordOffset+1],[-1,1])),i=(0,a.r2V)((0,a.dik)(e,[0,n.boxCoordOffset+2],[-1,1])),s=(0,a.r2V)((0,a.dik)(e,[0,n.boxCoordOffset+3],[-1,1]))):(r=(0,a.r2V)((0,a.dik)(e,[0,n.boxCoordOffset+0],[-1,1])),o=(0,a.r2V)((0,a.dik)(e,[0,n.boxCoordOffset+1],[-1,1])),s=(0,a.r2V)((0,a.dik)(e,[0,n.boxCoordOffset+2],[-1,1])),i=(0,a.r2V)((0,a.dik)(e,[0,n.boxCoordOffset+3],[-1,1]))),o=(0,a.WQq)((0,a.lKK)((0,a.y4m)(o,n.xScale),t.w),t.x),r=(0,a.WQq)((0,a.lKK)((0,a.y4m)(r,n.yScale),t.h),t.y),n.applyExponentialOnBoxSize?(s=(0,a.lKK)((0,a.oNF)((0,a.y4m)(s,n.hScale)),t.h),i=(0,a.lKK)((0,a.oNF)((0,a.y4m)(i,n.wScale)),t.w)):(s=(0,a.lKK)((0,a.y4m)(s,n.hScale),t.h),i=(0,a.lKK)((0,a.y4m)(i,n.wScale),t.h));var u=(0,a.jbE)(r,(0,a.y4m)(s,2)),c=(0,a.jbE)(o,(0,a.y4m)(i,2)),l=(0,a.WQq)(r,(0,a.y4m)(s,2)),p=(0,a.WQq)(o,(0,a.y4m)(i,2)),h=(0,a.xWs)([(0,a.tQQ)(u,[n.numBoxes,1]),(0,a.tQQ)(c,[n.numBoxes,1]),(0,a.tQQ)(l,[n.numBoxes,1]),(0,a.tQQ)(p,[n.numBoxes,1])],1
2);if(n.numKeypoints)for(var d=0;d<n.numKeypoints;++d){var f=n.keypointCoordOffset+d*n.numValuesPerKeypoint,m=void 0,g=void 0;n.reverseOutputOrder?(m=(0,a.r2V)((0,a.dik)(e,[0,f],[-1,1])),g=(0,a.r2V)((0,a.dik)(e,[0,f+1],[-1,1]))):(g=(0,a.r2V)((0,a.dik)(e,[0,f],[-1,1])),m=(0,a.r2V)((0,a.dik)(e,[0,f+1],[-1,1])));var y=(0,a.WQq)((0,a.lKK)((0,a.y4m)(m,n.xScale),t.w),t.x),x=(0,a.WQq)((0,a.lKK)((0,a.y4m)(g,n.yScale),t.h),t.y);h=(0,a.xWs)([h,(0,a.tQQ)(y,[n.numBoxes,1]),(0,a.tQQ)(x,[n.numBoxes,1])],1)}return h})}(o,t,n),i=(0,a.DZQ)(function(){var e=r;return n.sigmoidScore?(null!=n.scoreClippingThresh&&(e=(0,a.zQh)(r,-n.scoreClippingThresh,n.scoreClippingThresh)),e=(0,a.ry7)(e)):e}),[4,D(s,i,n)];case 1:return u=c.sent(),(0,a.ASo)([s,i]),[2,u]}})})}function D(e,t,n){return w(this,void 0,void 0,function(){var r,a,o,s,i,u,c,l,p,h,d,f;return T(this,function(m){switch(m.label){case 0:return r=[],[4,e.data()];case 1:return a=m.sent(),[4,t.data()];case 2:for(o=m.sent(),s=0;s<n.numBoxes;++s)if(!(null!=n.minScoreThresh&&o[s]<n.minScoreThresh||(i=s*n.numCoords,u=L(a[i+0],a[i+1],a[i+2],a[i+3],o[s],n.flipVertically,s),(c=u.locationData.relativeBoundingBox).width<0||c.height<0))){if(n.numKeypoints>0)for((l=u.locationData).relativeKeypoints=[],p=n.numKeypoints*n.numValuesPerKeypoint,h=0;h<p;h+=n.numValuesPerKeypoint)d=i+n.keypointCoordOffset+h,f={x:a[d+0],y:n.flipVertically?1-a[d+1]:a[d+1]},l.relativeKeypoints.push(f);r.push(u)}return[2,r]}})})}function L(e,t,n,r,a,o,s){return{score:[a],ind:s,locationData:{relativeBoundingBox:{xMin:t,yMin:o?1-n:e,xMax:r,yMax:o?1-e:n,width:r-t,height:n-e}}}}var M,P={reduceBoxesInLowestLayer:!1,interpolatedScaleAspectRatio:1,featureMapHeight:[],featureMapWidth:[],numLayers:4,minScale:.1484375,maxScale:.75,inputSizeHeight:128,inputSizeWidth:128,anchorOffsetX:.5,anchorOffsetY:.5,strides:[8,16,16,16],aspectRatios:[1],fixedAnchorSize:!0},B={reduceBoxesInLowestLayer:!1,interpolatedScaleAspectRatio:0,featureMapHeight:[],featureMapWidth:[],numLayers:1,minScale:.1484375,maxScale:.75,inputSizeHeight:192,inputSizeWidth:192,anchorOffsetX:.5,anchorOffsetY:.5,strides:[4],aspectRatios:[1],fixedAnchorSize:!0},V={runtime:"tfjs",modelType:"short",maxFaces:1,detectorModelUrl:"https://tfhub.dev/mediapipe/tfjs-model/face_detection/short/1"},z={applyExponentialOnBoxSize:!1,flipVertically:!1,ignoreClasses:[],numClasses:1,numBoxes:896,numCoords:16,boxCoordOffset:0,keypointCoordOffset:4,numKeypoints:6,numValuesPerKeypoint:2,sigmoidScore:!0,scoreClippingThresh:100,reverseOutputOrder:!0,xScale:128,yScale:128,hScale:128,wScale:128,minScoreThresh:.5},U={applyExponentialOnBoxSize:!1,flipVertically:!1,ignoreClasses:[],numClasses:1,numBoxes:2304,numCoords:16,boxCoordOffset:0,keypointCoordOffset:4,numKeypoints:6,numValuesPerKeypoint:2,sigmoidScore:!0,scoreClippingThresh:100,reverseOutputOrder:!0,xScale:192,yScale:192,hScale:192,wScale:192,minScoreThresh:.6},W={outputTensorSize:{width:128,height:128},keepAspectRatio:!0,outputTensorFloatRange:[-1,1],borderMode:"zero"},G={outputTensorSize:{width:192,height:192},keepAspectRatio:!0,outputTensorFloatRange:[-1,1],borderMode:"zero"},j=function(){function e(e,t,n){this.detectorModel=t,this.maxFaces=n,"full"===e?(this.imageToTensorConfig=G,this.tensorsToDetectionConfig=U,this.anchors=A(B)):(this.imageToTensorConfig=W,this.tensorsToDetectionConfig=z,this.anchors=A(P));var r=(0,a.tGX)(this.anchors.map(function(e){return e.width})),o=(0,a.tGX)(this.anchors.map(function(e){return e.height})),s=(0,a.tGX)(this.anchors.map(function(e){return e.xCenter})),i=(0,a.tGX)(this.anchors.map(function(e){return e.yCenter}));this.anchorTensor={x:s,y:i,w:r,h:o}}return e.prototype.dispose=function(){this.detectorModel.dispose(),(0,a.ASo)([this.anchorTensor.x,this.anchorTensor.y,this.anchorTensor.
2w,this.anchorTensor.h])},e.prototype.reset=function(){},e.prototype.detectFaces=function(e,t){return void 0===t&&(t=!1),w(this,void 0,void 0,function(){var n,r,o,s,i,u,c,l,p,h,d;return T(this,function(f){switch(f.label){case 0:return null==e?(this.reset(),[2,[]]):(n=(0,a.DZQ)(function(){var n=(0,a.wgE)(N(e),"float32");return t&&(n=(0,a.r2V)(a.Slp.flipLeftRight((0,a.UG6)(n,0)),[0])),n}),r=function(e,t,n){var r=t.outputTensorSize,o=t.keepAspectRatio,s=t.borderMode,i=t.outputTensorFloatRange,u=$(e),c=function(e,t){return t?{xCenter:t.xCenter*e.width,yCenter:t.yCenter*e.height,width:t.width*e.width,height:t.height*e.height,rotation:t.rotation}:{xCenter:.5*e.width,yCenter:.5*e.height,width:e.width,height:e.height,rotation:0}}(u,n),l=function(e,t,n){if(void 0===n&&(n=!1),!n)return{top:0,left:0,right:0,bottom:0};var r=t.height,a=t.width;I(t,"targetSize"),I(e,"roi");var o,s,i=r/a,u=e.height/e.width,c=0,l=0;return i>u?(o=e.width,s=e.width*i,l=(1-u/i)/2):(o=e.height/i,s=e.height,c=(1-i/u)/2),e.width=o,e.height=s,{top:l,left:c,right:c,bottom:l}}(c,r,o),p=function(e,t,n){var r=e.width,a=e.height,o=Math.cos(e.rotation),s=Math.sin(e.rotation),i=e.xCenter,u=e.yCenter,c=1/t,l=1/n,p=new Array(16);return p[0]=r*o*1*c,p[1]=-a*s*c,p[2]=0,p[3]=(-.5*r*o*1+.5*a*s+i)*c,p[4]=r*s*1*l,p[5]=a*o*l,p[6]=0,p[7]=(-.5*a*o-.5*r*s*1+u)*l,p[8]=0,p[9]=0,p[10]=r*c,p[11]=0,p[12]=0,p[13]=0,p[14]=0,p[15]=1,function(e){if(16!==e.length)throw new Error("Array length must be 16 but got "+e.length);return[[e[0],e[1],e[2],e[3]],[e[4],e[5],e[6],e[7]],[e[8],e[9],e[10],e[11]],[e[12],e[13],e[14],e[15]]]}(p)}(c,u.width,u.height),h=(0,a.DZQ)(function(){var t=N(e),n=(0,a.KtR)(function(e,t,n){return I(n,"inputResolution"),[1/n.width*e[0][0]*t.width,1/n.height*e[0][1]*t.width,e[0][3]*t.width,1/n.width*e[1][0]*t.height,1/n.height*e[1][1]*t.height,e[1][3]*t.height,0,0]}(p,u,r),[1,8]),o="zero"===s?"constant":"nearest",c=a.Slp.transform((0,a.UG6)((0,a.wgE)(t,"float32")),n,"bilinear",o,0,[r.height,r.width]);return null!=i?function(e,t){var n=function(e,t,n,r){var a=(r-n)/255;return{scale:a,offset:n-0*a}}(0,0,t[0],t[1]);return(0,a.DZQ)(function(){return(0,a.WQq)((0,a.lKK)(e,n.scale),n.offset)})}(c,i):c});return{imageTensor:h,padding:l,transformationMatrix:p}}(n,this.imageToTensorConfig),o=r.imageTensor,s=r.transformationMatrix,i=this.detectorModel.execute(o,"Identity:0"),u=function(e){return(0,a.DZQ)(function(){var t=function(e){return(0,a.DZQ)(function(){return[(0,a.dik)(e,[0,0,0],[1,-1,1]),(0,a.dik)(e,[0,0,1],[1,-1,-1])]})}(e),n=t[0],r=t[1];return{boxes:(0,a.r2V)(r),logits:(0,a.r2V)(n)}})}(i),c=u.boxes,[4,F([l=u.logits,c],this.anchorTensor,this.tensorsToDetectionConfig)]);case 1:return 0===(p=f.sent()).length?((0,a.ASo)([n,o,i,l,c]),[2,p]):[4,O(p,this.maxFaces,.3)];case 2:return h=f.sent(),d=function(e,t){void 0===e&&(e=[]);var n,r=(n=t,[].concat.apply([],n));return e.forEach(function(e){var t=e.locationData;t.relativeKeypoints.forEach(function(e){var t=_(r,[e.x,e.y]),n=t[0],a=t[1];e.x=n,e.y=a});var n=t.relativeBoundingBox,a=Number.MAX_VALUE,o=Number.MAX_VALUE,s=Number.MIN_VALUE,i=Number.MIN_VALUE;[[n.xMin,n.yMin],[n.xMin+n.width,n.yMin],[n.xMin+n.width,n.yMin+n.height],[n.xMin,n.yMin+n.height]].forEach(function(e){var t=_(r,e),n=t[0],u=t[1];a=Math.min(a,n),s=Math.max(s,n),o=Math.min(o,u),i=Math.max(i,u)}),t.relativeBoundingBox={xMin:a,xMax:s,yMin:o,yMax:i,width:s-a,height:i-o}}),e}(h,s),(0,a.ASo)([n,o,i,l,c]),[2,d]}})})},e.prototype.estimateFaces=function(e,t){return w(this,void 0,void 0,function(){var n,r;return T(this,function(a){return n=$(e),r=!!t&&t.flipHorizontal,[2,this.detectFaces(e,r).then(function(e){return e.map(function(e){for(var t=e.locationData.relativeKeypoints.map(function(e,t){return v(v({},e),{x:e.x*n.width,y:e.y*n.height,name:S[t]})}),r=e.locationData.relativeBoundingBox,a=0,o=["width","xMax","xMin"];a<o.length;a++)r[o[a]]*=n.width;for(var s=0,i=["height","yMax","yMin"];s<i.length;s++)r[i[s]]*=n.height;return{keypoints:t,box:r}})})]})})},e}();function K(e){return w(this,void 0,void 0,function(){var t,n,r;return T(this,function(a){switch(a.label){case 0:return t=function(e){if(null==e)return v({},V);var t=v({},e);return null==t.modelType&&(t.modelType=V.modelType),null==t.maxFaces&&(t.maxFaces=V.maxFaces),null==t.detectorModelUrl&&("full"===t.modelType?t.detectorModelUrl="https://tfhub.dev/mediapipe/tfjs-model/face_detection/full/1":t.detectorModelUrl="https://tfhub.dev/mediapipe/tfjs-model/face_detection/short/1"),t}(e),n="string"==typeof t.detectorModelUrl&&t.detectorModelUrl.indexOf("https://tfhub.dev")>-1,[4,(0,o.ox)(t.detectorModelUrl,{fromTFHub:n})];case 1:return r=a.sent(),[2,new j(t.modelType,r,t.maxFaces)]}})})}function H(e,t){return w(this,void 0,void 0,function(){var n,r;
2return T(this,function(a){if(e===M.MediaPipeFaceDetector){if(r=void 0,null!=(n=t)){if("tfjs"===n.runtime)return[2,K(n)];if("mediapipe"===n.runtime)return[2,E(n)];r=n.runtime}throw new Error("Expect modelConfig.runtime to be either 'tfjs' or 'mediapipe', but got "+r)}throw new Error(e+" is not a supported model name.")})})}function Y(e){return e.width*e.height}function Z(e){var t=e.xCenter-e.width/2,n=t+e.width,r=e.yCenter-e.height/2;return{xMin:t,xMax:n,yMin:r,yMax:r+e.height,width:e.width,height:e.height}}function X(e){return e instanceof a.qYS?{height:e.shape[0],width:e.shape[1]}:{height:e.height,width:e.width}}function q(e){return e-2*Math.PI*Math.floor((e+Math.PI)/(2*Math.PI))}function Q(e){return e instanceof a.qYS?e:a.TaL.fromPixels(e)}function J(e,t){a.ZSL.assert(0!==e.width,function(){return t+" width cannot be 0."}),a.ZSL.assert(0!==e.height,function(){return t+" height cannot be 0."})}function ee(e,t,n){var r=t.outputTensorSize,o=t.keepAspectRatio,s=t.borderMode,i=t.outputTensorFloatRange,u=X(e),c=function(e,t){return t?{xCenter:t.xCenter*e.width,yCenter:t.yCenter*e.height,width:t.width*e.width,height:t.height*e.height,rotation:t.rotation}:{xCenter:.5*e.width,yCenter:.5*e.height,width:e.width,height:e.height,rotation:0}}(u,n),l=function(e,t,n){if(void 0===n&&(n=!1),!n)return{top:0,left:0,right:0,bottom:0};var r=t.height,a=t.width;J(t,"targetSize"),J(e,"roi");var o,s,i=r/a,u=e.height/e.width,c=0,l=0;return i>u?(o=e.width,s=e.width*i,l=(1-u/i)/2):(o=e.height/i,s=e.height,c=(1-i/u)/2),e.width=o,e.height=s,{top:l,left:c,right:c,bottom:l}}(c,r,o),p=function(e,t,n,r){var a=e.width,o=e.height,s=r?-1:1,i=Math.cos(e.rotation),u=Math.sin(e.rotation),c=e.xCenter,l=e.yCenter,p=1/t,h=1/n,d=new Array(16);return d[0]=a*i*s*p,d[1]=-o*u*p,d[2]=0,d[3]=(-.5*a*i*s+.5*o*u+c)*p,d[4]=a*u*s*h,d[5]=o*i*h,d[6]=0,d[7]=(-.5*o*i-.5*a*u*s+l)*h,d[8]=0,d[9]=0,d[10]=a*p,d[11]=0,d[12]=0,d[13]=0,d[14]=0,d[15]=1,function(e){if(16!==e.length)throw new Error("Array length must be 16 but got "+e.length);return[[e[0],e[1],e[2],e[3]],[e[4],e[5],e[6],e[7]],[e[8],e[9],e[10],e[11]],[e[12],e[13],e[14],e[15]]]}(d)}(c,u.width,u.height,!1),h=a.DZQ(function(){var t=Q(e),n=a.KtR(function(e,t,n){return J(n,"inputResolution"),[1/n.width*e[0][0]*t.width,1/n.height*e[0][1]*t.width,e[0][3]*t.width,1/n.width*e[1][0]*t.height,1/n.height*e[1][1]*t.height,e[1][3]*t.height,0,0]}(p,u,r),[1,8]),o="zero"===s?"constant":"nearest",c=a.Slp.transform(a.UG6(a.wgE(t,"float32")),n,"bilinear",o,0,[r.height,r.width]);return null!=i?function(e,t){var n=function(e,t,n,r){var a=(r-n)/255;return{scale:a,offset:n-0*a}}(0,0,t[0],t[1]);return a.DZQ(function(){return a.WQq(a.lKK(e,n.scale),n.offset)})}(c,i):c});return{imageTensor:h,padding:l,transformationMatrix:p}}function te(e){return{xCenter:e.xMin+e.width/2,yCenter:e.yMin+e.height/2,width:e.width,height:e.height}}function ne(e){var t=e.relativeKeypoints;if(t.length<=1)throw new Error("2 or more keypoints required to calculate a rect.");var n=Number.MAX_VALUE,r=Number.MAX_VALUE,a=Number.MIN_VALUE,o=Number.MIN_VALUE;return t.forEach(function(e){n=Math.min(n,e.x),a=Math.max(a,e.x),r=Math.min(r,e.y),o=Math.max(o,e.y)}),{xCenter:(n+a)/2,yCenter:(r+o)/2,width:a-n,height:o-r}}function re(e,t,n,r,a){var o="rect"===n?function(e,t,n){var r,a=e.locationData;if("boundingbox"===t)r=te(a.boundingBox);else{r=ne(a);var o=n.width,s=n.height;r.xCenter=Math.round(r.xCenter*o),r.yCenter=Math.round(r.yCenter*s),r.width=Math.round(r.width*o),r.height=Math.round(r.height*s)}return r}(e,t,r):function(e,t){var n=e.locationData;return"boundingbox"===t?te(n.relativeBoundingBox):ne(n)}(e,t);return a&&(o.rotation=function(e,t,n){var r,a=e.locationData,o=n.rotationVectorStartKeypointIndex,s=n.rotationVectorEndKeypointIndex;r=n.rotationVectorTargetAngle?n.rotationVectorTargetAngle:Math.PI*n.rotationVectorTargetAngleDegree/180;var i=a.relativeKeypoints[o].x*t.width,u=a.relativeKeypoints[o].y*t.height,c=a.relativeKeypoints[s].x*t.width,l=a.relativeKeypoints[s].y*t.height;return q(r-Math.atan2(-(l-u),c-i))}(e,r,a)),o}function ae(e,t,n){for(var r=0;r<t.length;++r){var a=t[r],o=n[e[r]];o.x=a.x,o.y=a.y}}function oe(e,t,n,r){if("string"==typeof t){if("copy"===t)for(var a=0;a<n.length;++a)r[e[a]].z=n[a].z}else{var o=function(e,t){for(var n=0,r=0;r<t.length;++r)n+=e[t[r]].z;return n/t.length}(r,t);for(a=0;a<e.length;++a)r[e[a]].z=o}}function se(e,t){for(var n=function(e){var t=[].concat.apply([],e.map(function(e){return e.indexesMapping}));if(0===t.length)throw new Error("There should be at least one landmark in indexes mapping");var n=t[0],r=t[0],a=new Set(t);a.forEach(function(e){n=Math.min(n,e),r=Math.max(r,e)});var o=a.size;if(0!==n)throw new Error("Indexes are expected to start with 0 instead of "+n);if(r+1!==o)throw new Error("Indexes should have no gaps but "+(r-o+1)+" indexes are missing");return o}(t),r=new Array(n).fill(null).map(Object),a=0;a<e.length;++a){var o=e[a],s=t[a];if(o.length!==s.indexesMapping.length)throw new Error("There are "+o.length+" refinement landmarks while mapping has "+s.indexesMapping.length);ae(s.indexesMapping,o,r),oe(s.indexesMapping,s.zRefinement,o,r)}return r}function ie(e,t){return e.map(function(e){var n=s(s({},e),{x:e.x*t.width,y:e.y*t.height});return null!=e.z&&(n.z=e.z*t.width),n})}function ue(e,t){return"none"===e?t:function(e){return 1/(1+Math.exp(-e))}(t)}function ce(e,t,n,r){return i(this,void 0,void 0,function(){var a,o,s,i,c,l,p,h;return u(this,function(u){switch(u.label){case 0:return n=n||t.flipHorizontally||!1,r=r||t.flipVertically||!1,a=e.size,o=a/t.numLandmarks,[4,e.data()];case 1:for(s=u.sent(),i=[],c=0;c<t.numLandmarks;++c)l=c*o,(h={x:0,y:0}).x=n?t.inputImageWidth-s[l]:s[l],o>1&&(h.y=r?t.inputImageHeight-s[l+1]:s[l+1]),o>2&&(h.z=s[l+2]),o>3&&(h.score=ue(t.visibilityActivation,s[l+3])),i.push(h);for(p=0;p<i.length;++p)(h=i[p]).x=h.x/t.inputImageWidth,h.y=h.y/t.inputImageHeight,h.z=h.z/t.inputImageWidth/(t.normalizeZ||1);return[2,i]}})})}function le(e,t,n){var r=e.width,a=e.height,o=e.rotation;if(null==n.rotation&&null==n.rotationDegree||(o=function(e,t){return null!=t.rotation?e+=t.rotation:null!=t.rotationDegree&&(e+=Math.PI*t.rotationDegree/180),q(e)}
2(o,n)),0===o)e.xCenter=e.xCenter+r*n.shiftX,e.yCenter=e.yCenter+a*n.shiftY;else{var s=(t.width*r*n.shiftX*Math.cos(o)-t.height*a*n.shiftY*Math.sin(o))/t.width,i=(t.width*r*n.shiftX*Math.sin(o)+t.height*a*n.shiftY*Math.cos(o))/t.height;e.xCenter=e.xCenter+s,e.yCenter=e.yCenter+i}if(n.squareLong){var u=Math.max(r*t.width,a*t.height);r=u/t.width,a=u/t.height}else if(n.squareShort){var c=Math.min(r*t.width,a*t.height);r=c/t.width,a=c/t.height}return e.width=r*n.scaleX,e.height=a*n.scaleY,e}(M||(M={})).MediaPipeFaceDetector="MediaPipeFaceDetector";var pe,he={runtime:"tfjs",maxFaces:1,refineLandmarks:!1,landmarkModelUrl:"https://tfhub.dev/mediapipe/tfjs-model/face_landmarks_detection/face_mesh/1"},de={flipHorizontal:!1,staticImageMode:!1},fe={shiftX:0,shiftY:0,scaleX:1.5,scaleY:1.5,squareLong:!0},me={outputTensorSize:{width:192,height:192},outputTensorFloatRange:[0,1],borderMode:"replicate"},ge={numLandmarks:468,inputImageWidth:192,inputImageHeight:192,visibilityActivation:"none",flipHorizontally:!1,flipVertically:!1},ye={numLandmarks:80,inputImageWidth:192,inputImageHeight:192,visibilityActivation:"none",flipHorizontally:!1,flipVertically:!1},xe={numLandmarks:71,inputImageWidth:192,inputImageHeight:192,visibilityActivation:"none",flipHorizontally:!1,flipVertically:!1},be={numLandmarks:5,inputImageWidth:192,inputImageHeight:192,visibilityActivation:"none",flipHorizontally:!1,flipVertically:!1},ve={indexesMapping:Array.from(Array(468).keys()),zRefinement:"copy"},we={indexesMapping:[61,146,91,181,84,17,314,405,321,375,291,185,40,39,37,0,267,269,270,409,78,95,88,178,87,14,317,402,318,324,308,191,80,81,82,13,312,311,310,415,76,77,90,180,85,16,315,404,320,307,306,184,74,73,72,11,302,303,304,408,62,96,89,179,86,15,316,403,319,325,292,183,42,41,38,12,268,271,272,407],zRefinement:"none"},Te={indexesMapping:[33,7,163,144,145,153,154,155,133,246,161,160,159,158,157,173,130,25,110,24,23,22,26,112,243,247,30,29,27,28,56,190,226,31,228,229,230,231,232,233,244,113,225,224,223,222,221,189,35,124,46,53,52,65,143,111,117,118,119,120,121,128,245,156,70,63,105,66,107,55,193],zRefinement:"none"},Se={indexesMapping:[263,249,390,373,374,380,381,382,362,466,388,387,386,385,384,398,359,255,339,254,253,252,256,341,463,467,260,259,257,258,286,414,446,261,448,449,450,451,452,453,464,342,445,444,443,442,441,413,265,353,276,283,282,295,372,340,346,347,348,349,350,357,465,383,300,293,334,296,336,285,417],zRefinement:"none"},Ce={indexesMapping:[468,469,470,471,472],zRefinement:[33,7,163,144,145,153,154,155,133,246,161,160,159,158,157,173]},ke={indexesMapping:[473,474,475,476,477],zRefinement:[263,249,390,373,374,380,381,382,362,466,388,387,386,385,384,398]},Ee=function(){function e(e,t,n,r){this.detector=e,this.landmarkModel=t,this.maxFaces=n,this.withAttention=r,this.prevFaceRectsFromLandmarks=null}return e.prototype.estimateFaces=function(e,t){return i(this,void 0,void 0,function(){var n,r,o,i,c,l,p,h,m,g,y,x,b,v=this;return u(this,function(u){switch(u.label){case 0:return n=function(e){if(null==e)return s({},de);var t=s({},e);return null==t.flipHorizontal&&(t.flipHorizontal=de.flipHorizontal),null==t.staticImageMode&&(t.staticImageMode=de.staticImageMode),t}(t),null==e?(this.reset(),[2,[]]):(r=X(e),o=a.DZQ(function(){var t=a.wgE(Q(e),"float32");return n.flipHorizontal&&(t=a.r2V(a.Slp.flipLeftRight(a.UG6(t,0)),[0])),t}),i=this.prevFaceRectsFromLandmarks,n.staticImageMode||null==i||i.length<this.maxFaces?[4,this.detector.detectFaces(o,!1)]:[3,2]);case 1:return 0===(l=u.sent()).length?(this.reset(),o.dispose(),[2,[]]):(c=l.map(function(e){return v.faceDetectionFrontDetectionToRoi(e,r)}),[3,3]);case 2:c=[],u.label=3;case 3:return w=[],[c,i||[]].forEach(function(e){return e.forEach(function(e){(w=w.filter(function(t){return function(e,t){var n=Z(e),r=Z(t);if(!function(e,t){return!(e.xMax<t.xMin||t.xMax<e.xMin||e.yMax<t.yMin||t.yMax<e.yMin)}(n,r))return 0;var a=Y(function(e,t){var n=Math.max(e.xMin,t.xMin),r=Math.min(e.xMax,t.xMax),a=Math.max(e.yMin,t.yMin),o=Math.min(e.yMax,t.yMax);return{xMin:n,xMax:r,yMin:a,yMax:o,width:Math.max(r-n,0),height:Math.max(o-a,0)}}(n,r)),o=Y(n)+Y(r)-a;return o>0?a/o:0}(e,t)<=.5})).push(e)})}),p=w,[4,Promise.all(p.map(function(e){return v.faceLandmark(e,o)}))];case 4:for(h=u.sent(),m=[],this.prevFaceRectsFromLandmarks=[],g=0;g<h.length;++g)null!=(y=h[g])&&(this.prevFaceRectsFromLandmarks.push(this.faceLandmarksToRoi(y,r)),null!=(x=ie(y,r))&&x.forEach(function(e,t){var n=d.get(t);null!=n&&(e.name=n)}),b=f(x),m.push({keypoints:x,box:b.locationData.relativeBoundingBox}));return o.dispose(),[2,m]}var w})})},e.prototype.dispose=function(){this.detector.dispose(),this.landmarkModel.dispose()},e.prototype.reset=function(){this.detector.reset(),this.prevFaceRectsFromLandmarks=null},e.prototype.faceDetectionFrontDetectionToRoi=function(e,t){return le(re(e,"boundingbox","normRect",t,{rotationVectorStartKeypointIndex:0,rotationVectorEndKeypointIndex:1,rotationVectorTargetAngleDegree:0}),t,fe)},e.prototype.faceLandmark=function(e,t){return i(this,void 0,void 0,function(){var n,r,o,i,c,l,p;return u(this,function(u){switch(u.label){case 0:return n=ee(t,me,e).imageTensor,r=["output_faceflag"].concat(this.withAttention?["output_mesh_identity","output_lips","Identity_6:0","Identity_1:0","Identity_2:0","Identity_5:0"]:["output_mesh"]),o=this.landmarkModel.execute(n,r),i=o[0],c=o.slice(1),[4,i.data()];
2case 1:return u.sent()[0]<.5?(a.ASo(o),a.ASo(n),[2,null]):this.withAttention?[4,this.tensorsToFaceLandmarksWithAttention(c)]:[3,3];case 2:return l=u.sent(),[3,5];case 3:return[4,this.tensorsToFaceLandmarks(c)];case 4:l=u.sent(),u.label=5;case 5:return p=function(e,t,n){void 0===n&&(n={ignoreRotation:!1});for(var r=[],a=0,o=e;a<o.length;a++){var i=o[a],u=i.x-.5,c=i.y-.5,l=n.ignoreRotation?0:t.rotation,p=Math.cos(l)*u-Math.sin(l)*c,h=Math.sin(l)*u+Math.cos(l)*c;p=p*t.width+t.xCenter,h=h*t.height+t.yCenter;var d=i.z*t.width,f=s({},i);f.x=p,f.y=h,f.z=d,r.push(f)}return r}(l,e),a.ASo(o),a.ASo(n),[2,p]}})})},e.prototype.tensorsToFaceLandmarks=function(e){return i(this,void 0,void 0,function(){return u(this,function(t){return[2,ce(e[0],ge)]})})},e.prototype.tensorsToFaceLandmarksWithAttention=function(e){return i(this,void 0,void 0,function(){var t,n,r,a,o,s;return u(this,function(i){switch(i.label){case 0:return[4,ce(e[0],ge)];case 1:return t=i.sent(),[4,ce(e[1],ye)];case 2:return n=i.sent(),[4,ce(e[3],xe)];case 3:return r=i.sent(),[4,ce(e[5],xe)];case 4:return a=i.sent(),[4,ce(e[4],be)];case 5:return o=i.sent(),[4,ce(e[2],be)];case 6:return s=i.sent(),[2,se([t,n,r,a,o,s],[ve,we,Te,Se,Ce,ke])]}})})},e.prototype.faceLandmarksToRoi=function(e,t){return le(re(f(e),"boundingbox","normRect",t,{rotationVectorStartKeypointIndex:33,rotationVectorEndKeypointIndex:263,rotationVectorTargetAngleDegree:0}),t,fe)},e}();function $e(e){return i(this,void 0,void 0,function(){var t,n,r,a;return u(this,function(i){switch(i.label){case 0:return t=function(e){if(null==e)return s({},he);var t=s({},e);return t.runtime="tfjs",null==t.maxFaces&&(t.maxFaces=he.maxFaces),null==t.refineLandmarks&&(t.refineLandmarks=he.refineLandmarks),null==t.landmarkModelUrl&&(t.landmarkModelUrl=t.refineLandmarks?"https://tfhub.dev/mediapipe/tfjs-model/face_landmarks_detection/attention_mesh/1":"https://tfhub.dev/mediapipe/tfjs-model/face_landmarks_detection/face_mesh/1"),t}(e),n="string"==typeof t.landmarkModelUrl&&t.landmarkModelUrl.indexOf("https://tfhub.dev")>-1,[4,o.ox(t.landmarkModelUrl,{fromTFHub:n})];case 1:return r=i.sent(),[4,H(M.MediaPipeFaceDetector,{modelType:"short",maxFaces:t.maxFaces,detectorModelUrl:t.detectorModelUrl,runtime:t.runtime})];case 2:return a=i.sent(),[2,new Ee(a,r,t.maxFaces,t.refineLandmarks)]}})})}function Ne(e,t){return i(this,void 0,void 0,function(){var n,r;return u(this,function(a){if(e===pe.MediaPipeFaceMesh){if(r=void 0,null!=(n=t)){if("tfjs"===n.runtime)return[2,$e(n)];if("mediapipe"===n.runtime)return[2,y(n)];r=n.runtime}throw new Error("Expect modelConfig.runtime to be either 'tfjs' or 'mediapipe', but got "+r)}throw new Error(e+" is not a supported model name.")})})}(pe||(pe={})).MediaPipeFaceMesh="MediaPipeFaceMesh";Object.freeze({__proto__:null,getKeypointIndexByContour:function(e){if(e===pe.MediaPipeFaceMesh)return l;throw new Error("Model "+e+" is not supported.")},getAdjacentPairs:function(e){if(e===pe.MediaPipeFaceMesh)return p;throw new Error("Model "+e+" is not supported.")}})},96833:function(e,t,n){var r;!function(e,a){function o(e){var t=this;t.next=function(){var e,n,r=t.w,a=t.X,o=t.i;return t.w=r=r+1640531527|0,n=a[o+34&127],e=a[o=o+1&127],n^=n<<13,e^=e<<17,n^=n>>>15,e^=e>>>12,n=a[o]=n^e,t.i=o,n+(r^r>>>16)|0},function(e,t){var n,r,a,o,s,i=[],u=128;for(t===(0|t)?(r=t,t=null):(t+="\0",r=0,u=Math.max(u,t.length)),a=0,o=-32;o<u;++o)t&&(r^=t.charCodeAt((o+32)%t.length)),0===o&&(s=r),r^=r<<10,r^=r>>>15,r^=r<<4,r^=r>>>13,o>=0&&(s=s+1640531527|0,a=0==(n=i[127&o]^=r+s)?a+1:0);for(a>=128&&(i[127&(t&&t.length||0)]=-1),a=127,o=512;o>0;--o)r=i[a+34&127],n=i[a=a+1&127],r^=r<<13,n^=n<<17,r^=r>>>15,n^=n>>>12,i[a]=r^n;e.w=s,e.X=i,e.i=a}(t,e)}function s(e,t){return t.i=e.i,t.w=e.w,t.X=e.X.slice(),t}function i(e,t){null==e&&(e=+new Date);var n=new o(e),r=t&&t.state,a=function(){return(n.next()>>>0)/4294967296};return a.double=function(){do{var e=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},a.int32=n.next,a.quick=a,r&&(r.X&&s(r,n),a.state=function(){return s(n,{})}),a}a&&a.exports?a.exports=i:n.amdD&&n.amdO?void 0===(r=function(){return i}.call(t,n,t,a))||(a.exports=r):this.xor4096=i}(0,e=n.nmd(e),n.amdD)},97856:function(e,t,n){"use strict";n.d(t,{BTT:function(){return i.B},tnl:function(){return u},HQu:function(){return c},FqL:function(){return l},WQq:function(){return h},QiD:function(){return f},Q7R:function(){return m},bzn:function(){return g},FLi:function(){return y},XRg:function(){return x},qRo:function(){return b},yHs:function(){return v},rYl:function(){return w},FPz:function(){return T},rfv:function(){return S},$jT:function(){return $},sub:function(){return N},lZX:function(){return L},$v7:function(){return P},BFc:function(){return B},kSi:function(){return V},T5N:function(){return z},GTe:function(){return M},HbZ:function(){return U},ftb:function(){return nr},ROE:function(){return W},hOW:function(){return G},ra8:function(){return j.r},wgE:function(){return C.w},mkO:function(){return K},zQh:function(){return Y},o8B:function(){return I.o},faB:function(){return Z.f},xWs:function(){return A},I1m:function(){return X},RPU:function(){return q},O5O:function(){return Q},P1l:function(){return J},kA9:function(){return te},Xtf:function(){return ee},wX9:function(){return re},IPL:function(){return ae},jIJ:function(){return se},gnS:function(){return ie},yIG:function(){return ue},_jP:function(){return hr},Lp0:function(){return ce},rCv:function(){return le},aOp:function(){return pe},Rj8:function(){return he},Gl3:function(){return de},smy:function(){return fe},X7t:function(){return me},y4m:function(){return ye},ek5:function(){return Te},Omf:function(){return Se},EZY:function(){return lr},_3C:function(){return Ce},Pqc:function(){return ke.P},FJY:function(){return pr},LCg:function(){return be},Y12:function(){return Ee},p4S:function(){return Me},oNF:function(){return Pe},UG6:function(){return Be},IYd:function(){return Ve},y5U:function(){return Ue},hVP:function(){return Nn},GSj:function(){return H},RIf:function(){return We},wh_:function(){return ge},cZk:function(){return r},kgh:function(){return Ge},SY9:function(){return cr},rhj:function(){return je},DQN:function(){return Ke},KGM:function(){return In},ngS:function(){return He},Slp:function(){return la},U4u:function(){return dr},ggX:function(){return An},MIs:function(){return Ye},EN4:function(){return Ze},yrW:function(){return Xe},H8d:function(){return qe.H}
2,M7h:function(){return Qe},InN:function(){return Je},mPL:function(){return pa},mT8:function(){return et},Kgs:function(){return tt},Rm2:function(){return nt},Kko:function(){return rt},nqI:function(){return ut},HPB:function(){return lt},VZ:function(){return pt},n76:function(){return ht},NSZ:function(){return dt},ztW:function(){return ft},rxB:function(){return mt},YYh:function(){return ha},yzS:function(){return xt},NoW:function(){return R},T9B:function(){return Ne},jgi:function(){return bt},NYV:function(){return vt},RO:function(){return wt},PhQ:function(){return Tt},i2o:function(){return St},OYQ:function(){return Et},jkA:function(){return Ie},BpO:function(){return $t},FFZ:function(){return Nt},ziu:function(){return It},Clk:function(){return At},CRk:function(){return or},lKK:function(){return _.l},YDF:function(){return Rt},OjQ:function(){return _t},HZy:function(){return st},xbf:function(){return Le},Ec:function(){return Ot},Mw0:function(){return Ft},SaS:function(){return kt},P61:function(){return Dt},op:function(){return i.op},X4o:function(){return Lt},eVF:function(){return Mt},BZs:function(){return Pt},grY:function(){return Bt},XHu:function(){return Vt},WLX:function(){return zt},dzn:function(){return Wt},n7C:function(){return Ae},NsG:function(){return Gt.N},yyV:function(){return jt.y},_eU:function(){return Kt},whe:function(){return Ht},Q0_:function(){return Yt},_9M:function(){return Zt},pR9:function(){return en},FE$:function(){return tn},m0H:function(){return nn},YeY:function(){return rn},y17:function(){return an},xav:function(){return on},VOZ:function(){return sn},VVh:function(){return un.V},j__:function(){return cn.j},tQQ:function(){return E.t},BEg:function(){return ln},QD2:function(){return pn},LMr:function(){return hn},I2l:function(){return dn},JYU:function(){return fn},z8$:function(){return _n},LIG:function(){return mn},Z$r:function(){return gn},d_2:function(){return Re.d},NFr:function(){return ir},sZg:function(){return yt},WfX:function(){return yn},wdz:function(){return xn},F12:function(){return bn},ry7:function(){return O.r},_SZ:function(){return vn},vPA:function(){return ca},F8e:function(){return wn},L0l:function(){return Tn},dik:function(){return F},Q$M:function(){return Sn},zAd:function(){return Cn},wck:function(){return kn},R0O:function(){return En},Vs9:function(){return $n},lw0:function(){return it},eDJ:function(){return Ut},lMo:function(){return da},Zhr:function(){return ur},lOn:function(){return ua},lDo:function(){return Rn},RZD:function(){return _e},EwI:function(){return Oe},Pbu:function(){return On},r2V:function(){return Fn},t$z:function(){return Dn},PMw:function(){return Ln.P},Ym9:function(){return Mn},YjP:function(){return fa},jbE:function(){return ct},czq:function(){return Fe.c},Mlm:function(){return Pn},ymU:function(){return D},OEK:function(){return Bn.O},tGX:function(){return zn},KtR:function(){return Un},$_$:function(){return Wn.$},g9W:function(){return Gn},Lpo:function(){return jn},yxw:function(){return Kn},Vsq:function(){return ze},rfw:function(){return Hn},mgz:function(){return ar},efE:function(){return Yn},AmM:function(){return Zn},zAU:function(){return Xn},K$i:function(){return qn},rni:function(){return Qn},bvq:function(){return Jn},_M9:function(){return ve},YJN:function(){return tr},Ul9:function(){return Ct},POl:function(){return we}});var r={};n.r(r),n.d(r,{conv2d:function(){return gr},depthwiseConv2d:function(){return br},matMul:function(){return vr}});var a=n(57260),o=n(15441),s=n(28189),i=n(70929);const u=(0,i.op)({abs_:function(e){const t=(0,s.YT)(e,"x","abs");if("complex64"===t.dtype){const e={x:t};return a.T2.runKernel(o.$zE,e)}{const e={x:t};return a.T2.runKernel(o.ljI,e)}}});const c=(0,i.op)({acos_:function(e){const t={x:(0,s.YT)(e,"x","acos")};return a.T2.runKernel(o.Vvy,t)}});const l=(0,i.op)({acosh_:function(e){const t={x:(0,s.YT)(e,"x","acosh")};return a.T2.runKernel(o.PH8,t)}});var p=n(30565);const h=(0,i.op)({add_:function(e,t){let n=(0,s.YT)(e,"a","add"),r=(0,s.YT)(t,"b","add");[n,r]=(0,p.h0)(n,r);const i={a:n,b:r};return a.T2.runKernel(o.OMN,i)}});var d=n(45119);const f=(0,i.op)({addN_:function(e){d.vA(Array.isArray(e),()=>"The argument passed to tf.addN() must be a list of tensors"),d.vA(e.length>=1,()=>`Must pass at least one tensor to tf.addN(), but got ${e.length}`);const t=e.map((e,t)=>(0,s.YT)(e,`tensors${t}`,"addN")),n=t[0];
2t.forEach(e=>{if(e.dtype!==n.dtype)throw new Error("All tensors passed to tf.addN() must have the same dtype")}),t.forEach(e=>{if(!d.r1(e.shape,n.shape))throw new Error("All tensors passed to tf.addN() must have the same shape")});const r=t;return a.T2.runKernel(o.EkD,r)}});const m=(0,i.op)({all_:function(e,t=null,n=!1){const r={x:(0,s.YT)(e,"x","all","bool")},i={axis:t,keepDims:n};return a.T2.runKernel(o.u8Z,r,i)}});const g=(0,i.op)({any_:function(e,t=null,n=!1){const r={x:(0,s.YT)(e,"x","any","bool")},i={axis:t,keepDims:n};return a.T2.runKernel(o.FSt,r,i)}});const y=(0,i.op)({argMax_:function(e,t=0){const n={x:(0,s.YT)(e,"x","argMax")},r={axis:t};return a.T2.runKernel(o.Jp_,n,r)}});const x=(0,i.op)({argMin_:function(e,t=0){const n={x:(0,s.YT)(e,"x","argMin")},r={axis:t};return a.T2.runKernel(o.p_m,n,r)}});const b=(0,i.op)({asin_:function(e){const t={x:(0,s.YT)(e,"x","asin")};return a.T2.runKernel(o.QKF,t)}});const v=(0,i.op)({asinh_:function(e){const t={x:(0,s.YT)(e,"x","asinh")};return a.T2.runKernel(o.epO,t)}});const w=(0,i.op)({atan_:function(e){const t={x:(0,s.YT)(e,"x","atan")};return a.T2.runKernel(o.TyE,t)}});const T=(0,i.op)({atan2_:function(e,t){let n=(0,s.YT)(e,"a","atan2"),r=(0,s.YT)(t,"b","atan2");[n,r]=(0,p.h0)(n,r);const i={a:n,b:r};return a.T2.runKernel(o.lxb,i)}});const S=(0,i.op)({atanh_:function(e){const t={x:(0,s.YT)(e,"x","atanh")};return a.T2.runKernel(o.zP9,t)}});var C=n(29809),k=n(47195),E=n(62302);const $=(0,i.op)({avgPool_:function(e,t,n,r,i){const u=(0,s.YT)(e,"x","avgPool","float32");d.vA(k.G0(n,1),()=>`Error in avgPool: Either strides or dilations must be 1. Got strides ${n} and dilations '1'`);let c=u,l=!1;3===u.rank&&(l=!0,c=(0,E.t)(u,[1,u.shape[0],u.shape[1],u.shape[2]])),d.vA(4===c.rank,()=>`Error in avgPool: x must be rank 4 but got rank ${c.rank}.`),k.s_("avgPool",r,i);const p={x:c},h={filterSize:t,strides:n,pad:r,dimRoundingMode:i};let f=a.T2.runKernel(o.ho8,p,h);return f=(0,C.w)(f,u.dtype),l?(0,E.t)(f,[f.shape[1],f.shape[2],f.shape[3]]):f}});const N=(0,i.op)({avgPool3d_:function(e,t,n,r,i,u="NDHWC"){const c=(0,s.YT)(e,"x","avgPool3d","float32");let l=c,p=!1;4===c.rank&&(p=!0,l=(0,E.t)(c,[1,c.shape[0],c.shape[1],c.shape[2],c.shape[3]])),d.vA(5===l.rank,()=>`Error in avgPool3d: x must be rank 5 but got rank ${l.rank}.`),d.vA("NDHWC"===u,()=>`Error in avgPool3d: Only NDHWC is currently supported, but got dataFormat of ${u}`),(0,k.s_)("avgPool3d",r,i);const h={x:l},f={filterSize:t,strides:n,pad:r,dimRoundingMode:i,dataFormat:u};let m=a.T2.runKernel(o.cS,h,f);return m=(0,C.w)(m,l.dtype),p?(0,E.t)(m,[m.shape[1],m.shape[2],m.shape[3],m.shape[4]]):m}});var I=n(70125);const A=(0,i.op)({concat_:function(e,t=0){(0,d.vA)(e.length>=1,()=>"Pass at least one tensor to concat");const n=(0,s.j1)(e,"tensors","concat","string_or_numeric");
2if("complex64"===n[0].dtype&&n.forEach(e=>{if("complex64"!==e.dtype)throw new Error(`Cannot concatenate complex64 tensors with a tensor\n with dtype ${e.dtype}. `)}),1===n.length)return(0,I.o)(n[0]);const r=n,i={axis:t};return a.T2.runKernel(o.$dB,r,i)}});const R=(0,i.op)({matMul_:function(e,t,n=!1,r=!1){let i=(0,s.YT)(e,"a","matMul"),u=(0,s.YT)(t,"b","matMul");[i,u]=(0,p.h0)(i,u);const c={a:i,b:u},l={transposeA:n,transposeB:r};return a.T2.runKernel(o.jAQ,c,l)}});var _=n(9258),O=n(28968);const F=(0,i.op)({slice_:function(e,t,n){const r=(0,s.YT)(e,"x","slice","string_or_numeric");if(0===r.rank)throw new Error("Slicing scalar is not possible");const i={x:r},u={begin:t,size:n};return a.T2.runKernel(o.JiE,i,u)}});const D=(0,i.op)({tanh_:function(e){const t={x:(0,s.YT)(e,"x","tanh","float32")};return a.T2.runKernel(o.iuW,t)}});const L=(0,i.op)({basicLSTMCell_:function(e,t,n,r,a,o){const i=(0,s.YT)(e,"forgetBias","basicLSTMCell"),u=(0,s.YT)(t,"lstmKernel","basicLSTMCell"),c=(0,s.YT)(n,"lstmBias","basicLSTMCell"),l=(0,s.YT)(r,"data","basicLSTMCell"),p=(0,s.YT)(a,"c","basicLSTMCell"),d=(0,s.YT)(o,"h","basicLSTMCell"),f=A([l,d],1),m=R(f,u),g=h(m,c),y=g.shape[0],x=g.shape[1]/4,b=[y,x],v=F(g,[0,0],b),w=F(g,[0,x],b),T=F(g,[0,2*x],b),S=F(g,[0,3*x],b),C=h((0,_.l)((0,O.r)(v),D(w)),(0,_.l)(p,(0,O.r)(h(i,T))));return[C,(0,_.l)(D(C),(0,O.r)(S))]}});const M=(0,i.op)({batchToSpaceND_:function(e,t,n){const r=(0,s.YT)(e,"x","batchToSpaceND"),i=t.reduce((e,t)=>e*t);d.vA(r.rank>=1+t.length,()=>`input rank is ${r.rank} but should be > than blockShape.length ${t.length}`),d.vA(n.length===t.length,()=>`crops.length is ${n.length} but should be equal to blockShape.length ${t.length}`),d.vA(r.shape[0]%i===0,()=>`input tensor batch is ${r.shape[0]} but is not divisible by the product of the elements of blockShape ${t.join(" * ")} === ${i}`);const u={x:r},c={blockShape:t,crops:n};return a.T2.runKernel(o.Ik2,u,c)}});const P=(0,i.op)({batchNorm_:function(e,t,n,r,i,u){null==u&&(u=.001);const c=(0,s.YT)(e,"x","batchNorm"),l=(0,s.YT)(t,"mean","batchNorm"),p=(0,s.YT)(n,"variance","batchNorm");let h,f;null!=i&&(h=(0,s.YT)(i,"scale","batchNorm")),null!=r&&(f=(0,s.YT)(r,"offset","batchNorm")),d.vA(l.rank===p.rank,()=>"Batch normalization gradient requires mean and variance to have equal ranks."),d.vA(null==f||l.rank===f.rank,()=>"Batch normalization gradient requires mean and offset to have equal ranks."),d.vA(null==h||l.rank===h.rank,()=>"Batch normalization gradient requires mean and scale to have equal ranks.");const m={x:function(e){let t;return t=0===e.rank||1===e.rank?(0,E.t)(e,[1,1,1,e.size]):2===e.rank?(0,E.t)(e,[1,1,e.shape[0],e.shape[1]]):3===e.rank?(0,E.t)(e,[1,e.shape[0],e.shape[1],e.shape[2]]):e,t}(c),scale:h,offset:f,mean:l,variance:p},g={varianceEpsilon:u},y=a.T2.runKernel(o.i5R,m,g);return(0,E.t)(y,c.shape)}});const B=(0,i.op)({batchNorm2d_:function(e,t,n,r,a,o){const i=(0,s.YT)(e,"x","batchNorm"),u=(0,s.YT)(t,"mean","batchNorm"),c=(0,s.YT)(n,"variance","batchNorm");let l,p;return null!=a&&(l=(0,s.YT)(a,"scale","batchNorm")),null!=r&&(p=(0,s.YT)(r,"offset","batchNorm")),d.vA(2===i.rank,()=>`Error in batchNorm2D: x must be rank 2 but got rank ${i.rank}.`),d.vA(2===u.rank||1===u.rank,()=>`Error in batchNorm2D: mean must be rank 2 or rank 1 but got rank ${u.rank}.`),d.vA(2===c.rank||1===c.rank,()=>`Error in batchNorm2D: variance must be rank 2 or rank 1 but got rank ${c.rank}.`),null!=l&&d.vA(2===l.rank||1===l.rank,()=>`Error in batchNorm2D: scale must be rank 2 or rank 1 but got rank ${l.rank}.`),null!=p&&d.vA(2===p.rank||1===p.rank,()=>`Error in batchNorm2D: offset must be rank 2 or rank 1 but got rank ${p.rank}.`),P(i,u,c,p,l,o)}});const V=(0,i.op)({batchNorm3d_:function(e,t,n,r,a,o){const i=(0,s.YT)(e,"x","batchNorm"),u=(0,s.YT)(t,"mean","batchNorm"),c=(0,s.YT)(n,"variance","batchNorm");let l,p;return null!=a&&(l=(0,s.YT)(a,"scale","batchNorm")),null!=r&&(p=(0,s.YT)(r,"offset","batchNorm")),d.vA(3===i.rank,()=>`Error in batchNorm3D: x must be rank 3 but got rank ${i.rank}.`),d.vA(3===u.rank||1===u.rank,()=>`Error in batchNorm3D: mean must be rank 3 or rank 1 but got rank ${u.rank}.`),d.vA(3===c.rank||1===c.rank,()=>`Error in batchNorm3D: variance must be rank 3 or rank 1 but got rank ${c.rank}.`),null!=l&&d.vA(3===l.rank||1===l.rank,()=>`Error in batchNorm3D: scale must be rank 3 or rank 1 but got rank ${l.rank}.`),null!=p&&d.vA(3===p.rank||1===p.rank,()=>`Error in batchNorm3D: offset must be rank 3 or rank 1 but got rank ${p.rank}.`),P(i,u,c,p,l,o)}});const z=(0,i.op)({batchNorm4d_:function(e,t,n,r,a,o){const i=(0,s.YT)(e,"x","batchNorm"),u=(0,s.YT)(t,"mean","batchNorm"),c=(0,s.YT)(n,"variance","batchNorm");let l,p;return null!=a&&(l=(0,s.YT)(a,"scale","batchNorm")),null!=r&&(p=(0,s.YT)(r,"offset","batchNorm")),d.vA(4===i.rank,()=>`Error in batchNorm4D: x must be rank 4 but got rank ${i.rank}
2.`),d.vA(4===u.rank||1===u.rank,()=>`Error in batchNorm4D: mean must be rank 4 or rank 1 but got rank ${u.rank}.`),d.vA(4===c.rank||1===c.rank,()=>`Error in batchNorm4D: variance must be rank 4 or rank 1 but got rank ${c.rank}.`),null!=l&&d.vA(4===l.rank||1===l.rank,()=>`Error in batchNorm4D: scale must be rank 4 or rank 1 but got rank ${l.rank}.`),null!=p&&d.vA(4===p.rank||1===p.rank,()=>`Error in batchNorm4D: offset must be rank 4 or rank 1 but got rank ${p.rank}.`),P(i,u,c,p,l,o)}});const U=(0,i.op)({bincount_:function(e,t,n){const r=(0,s.YT)(e,"x","bincount"),i=(0,s.YT)(t,"weights","bincount");d.vA("int32"===r.dtype,()=>`Error in bincount: input dtype must be int32, but got ${r.dtype}`),d.vA(n>=0,()=>`size must be non-negative, but got ${n}.`),d.vA(i.size===r.size||0===i.size,()=>`Error in bincount: weights must have the same size as input or0-length, but got input shape: ${r.shape}, weights shape: ${i.shape}.`);const u={x:r,weights:i},c={size:n};return a.T2.runKernel(o.N4F,u,c)}});const W=(0,i.op)({broadcastArgs_:function(e,t){const n=(0,s.YT)(e,"s0","broadcastArgs","int32"),r=(0,s.YT)(t,"s1","broadcastArgs","int32");if(1!==n.rank)throw new Error(`broadcastArgs(): first input must be a vector (rank=1). Has rank ${n.rank}`);if(1!==r.rank)throw new Error(`broadcastArgs(): second input must be a vector (rank=1). Has rank ${r.rank}`);const i={s0:n,s1:r};return a.T2.runKernel(o.vj7,i)}});const G=(0,i.op)({broadcastTo_:function(e,t){let n=(0,s.YT)(e,"broadcastTo","x");const r=n.shape;if(t.some(e=>!(e>0)||e%1!=0))throw new Error(`broadcastTo(): Invalid broadcast shape [${t}].`);if(t.length<n.rank)throw new Error(`broadcastTo(): shape.length=${t.length} < input.rank=${n.rank}.`);if(t.length>n.rank){const e=n.shape.slice();for(;e.length<t.length;)e.unshift(1);n=(0,E.t)(n,e)}const i=n.shape,u=Array.from(t);for(let e=t.length-1;e>=0;e--)if(i[e]===t[e])u[e]=1;else if(1!==n.shape[e])throw new Error(`broadcastTo(): [${r}] cannot be broadcast to [${t}].`);if(0===u.map((e,t)=>e>1?t:-1).filter(e=>e>=0).length)return(0,I.o)(n);const c={x:n},l={reps:u};return a.T2.runKernel(o.FAs,c,l)}});var j=n(448);const K=(0,i.op)({ceil_:function(e){const t={x:(0,s.YT)(e,"x","ceil","float32")};return a.T2.runKernel(o.QDP,t)}});function H(e,t,n){const r={shape:e,value:t,dtype:n};return a.T2.runKernel(o.SQl,{},r)}const Y=(0,i.op)({clipByValue_:function(e,t,n){const r=(0,s.YT)(e,"x","clipByValue");if(d.vA(t<=n,()=>`Error in clip: min (${t}) must be less than or equal to max (${n}).`),t===n)return H(r.shape,t,r.dtype);const i={x:r},u={clipValueMin:t,clipValueMax:n};return a.T2.runKernel(o.vaV,i,u)}});var Z=n(37148);const X=(0,i.op)({concat1d_:function(e){return A(e,0)}});const q=(0,i.op)({concat2d_:function(e,t){return A(e,t)}});const Q=(0,i.op)({concat3d_:function(e,t){return A(e,t)}});const J=(0,i.op)({concat4d_:function(e,t){return A(e,t)}});const ee=(0,i.op)({conv2d_:function(e,t,n,r,i="NHWC",u=[1,1],c){const l=(0,s.YT)(e,"x","conv2d","float32"),p=(0,s.YT)(t,"filter","conv2d","float32");let h=l,f=!1;3===l.rank&&(f=!0,h=(0,E.t)(l,[1,l.shape[0],l.shape[1],l.shape[2]])),d.vA(4===h.rank,()=>`Error in conv2d: input must be rank 4, but got rank ${h.rank}.`),d.vA(4===p.rank,()=>`Error in conv2d: filter must be rank 4, but got rank ${p.rank}.`),k.s_("conv2d",r,c);const m="NHWC"===i?h.shape[3]:h.shape[1];d.vA(m===p.shape[2],()=>`Error in conv2d: depth of input (${m}) must match input depth for filter ${p.shape[2]}.`),d.vA(k.G0(n,u),()=>`Error in conv2D: Either strides or dilations must be 1. Got strides ${n} and dilations '${u}'`);const g={x:h,filter:p},y={strides:n,pad:r,dataFormat:i,dilations:u,dimRoundingMode:c},x=a.T2.runKernel(o.p2J,g,y);return f?(0,E.t)(x,[x.shape[1],x.shape[2],x.shape[3]]):x}});const te=(0,i.op)({conv1d_:function(e,t,n,r,a="NWC",o=1,i){const u=(0,s.YT)(e,"x","conv1d"),c=(0,s.YT)(t,"filter","conv1d");let l=u,p=!1;2===u.rank&&(p=!0,l=(0,E.t)(u,[1,u.shape[0],u.shape[1]])),d.vA(3===l.rank,()=>`Error in conv1d: input must be rank 3, but got rank ${l.rank}.`),d.vA(3===c.rank,()=>`Error in conv1d: filter must be rank 3, but got rank ${c.rank}.`),k.s_("conv1d",r,i),d.vA(l.shape[2]===c.shape[1],()=>`Error in conv1d: depth of input (${l.shape[2]}) must match input depth for filter ${c.shape[1]}.`),d.vA(k.G0(n,o),()=>`Error in conv1D: Either stride or dilation must be 1. Got stride ${n} and dilation '${o}'`),d.vA("NWC"===a,()=>`Error in conv1d: got dataFormat of ${a} but only NWC is currently supported.`);const h=(0,E.t)(c,[1,c.shape[0],c.shape[1],c.shape[2]]),f=(0,E.t)(l,[l.shape[0],1,l.shape[1],l.shape[2]]),m=ee(f,h,[1,n],r,"NHWC",[1,o],i);return p?(0,E.t)(m,[m.shape[2],m.shape[3]]):(0,E.t)(m,[m.shape[0],m.shape[2],m.shape[3]])}});const ne=(0,i.op)({conv2DBackpropInput_:function(e,t,n,r,s,i="NHWC",u){d.vA(e.length===t.rank,()=>`Length of inShape (${e.length}) and rank of dy (${t.rank}) must match`);let c=e,l=t,p=!1;3===t.rank&&(p=!0,l=(0,E.t)(t,[1,t.shape[0],t.shape[1],t.shape[2]]),c=[1,e[0],e[1],e[2]]),d.vA(4===c.length,()=>
2`Error in conv2dDerInput: inShape must be length 4, but got length ${c.length}.`),d.vA(4===l.rank,()=>`Error in conv2dDerInput: dy must be rank 4, but got rank ${l.rank}`),d.vA(4===n.rank,()=>`Error in conv2dDerInput: filter must be rank 4, but got rank ${n.rank}`);const h="NHWC"===i?c[3]:c[1],f="NHWC"===i?l.shape[3]:l.shape[1];d.vA(h===n.shape[2],()=>`Error in conv2dDerInput: depth of input (${h}) must match input depth for filter ${n.shape[2]}.`),d.vA(f===n.shape[3],()=>`Error in conv2dDerInput: depth of output (${f}) must match output depth for filter ${n.shape[3]}.`),k.s_("conv2dDerInput",s,u);const m={dy:l,filter:n},g={strides:r,pad:s,dataFormat:i,dimRoundingMode:u,inputShape:c},y=a.T2.runKernel(o.jfg,m,g);return p?(0,E.t)(y,[y.shape[1],y.shape[2],y.shape[3]]):y}});const re=(0,i.op)({conv2dTranspose_:function(e,t,n,r,a,o){const i=(0,s.YT)(e,"x","conv2dTranspose"),u=(0,s.YT)(t,"filter","conv2dTranspose");return ne(n,i,u,r,a,"NHWC",o)}});const ae=(0,i.op)({conv3d_:function(e,t,n,r,i="NDHWC",u=[1,1,1]){const c=(0,s.YT)(e,"x","conv3d"),l=(0,s.YT)(t,"filter","conv3d");let p=c,h=!1;4===c.rank&&(h=!0,p=(0,E.t)(c,[1,c.shape[0],c.shape[1],c.shape[2],c.shape[3]])),d.vA(5===p.rank,()=>`Error in conv3d: input must be rank 5, but got rank ${p.rank}.`),d.vA(5===l.rank,()=>`Error in conv3d: filter must be rank 5, but got rank ${l.rank}.`),d.vA(p.shape[4]===l.shape[3],()=>`Error in conv3d: depth of input (${p.shape[4]}) must match input depth for filter ${l.shape[3]}.`),d.vA((0,k.G0)(n,u),()=>`Error in conv3D: Either strides or dilations must be 1. Got strides ${n} and dilations '${u}'`),d.vA("NDHWC"===i,()=>`Error in conv3d: got dataFormat of ${i} but only NDHWC is currently supported.`);const f={x:p,filter:l},m={strides:n,pad:r,dataFormat:i,dilations:u},g=a.T2.runKernel(o.A1h,f,m);return h?(0,E.t)(g,[g.shape[1],g.shape[2],g.shape[3],g.shape[4]]):g}});const oe=(0,i.op)({conv3DBackpropInput_:function(e,t,n,r,s){d.vA(e.length===t.rank,()=>`Length of inShape (${e.length}) and rank of dy (${t.rank}) must match`);let i=e,u=t,c=!1;4===t.rank&&(c=!0,u=(0,E.t)(t,[1,t.shape[0],t.shape[1],t.shape[2],t.shape[3]]),i=[1,e[0],e[1],e[2],e[3]]);const l=i[4],p=u.shape[4];d.vA(5===i.length,()=>`Error in conv3dDerInput: inShape must be length 5, but got length ${i.length}.`),d.vA(5===u.rank,()=>`Error in conv3dDerInput: dy must be rank 5, but got rank ${u.rank}`),d.vA(5===n.rank,()=>`Error in conv3dDerInput: filter must be rank 5, but got rank ${n.rank}`),d.vA(l===n.shape[3],()=>`Error in conv3dDerInput: depth of input (${l}) must match input depth for filter ${n.shape[3]}.`),d.vA(p===n.shape[4],()=>`Error in conv3dDerInput: depth of output (${p}) must match output depth for filter ${n.shape[4]}.`);const h={dy:u,filter:n},f={pad:s,strides:r,inputShape:i},m=a.T2.runKernel(o.gC7,h,f);return c?(0,E.t)(m,[m.shape[1],m.shape[2],m.shape[3],m.shape[4]]):m}});const se=(0,i.op)({conv3dTranspose_:function(e,t,n,r,a){const o=(0,s.YT)(e,"x","conv3dTranspose"),i=(0,s.YT)(t,"filter","conv3dTranspose");return oe(n,o,i,r,a)}});const ie=(0,i.op)({cos_:function(e){const t={x:(0,s.YT)(e,"x","cos","float32")};return a.T2.runKernel(o.Mn0,t)}});const ue=(0,i.op)({cosh_:function(e){const t={x:(0,s.YT)(e,"x","cosh","float32")};return a.T2.runKernel(o.MnK,t)}});const ce=(0,i.op)({cumprod_:function(e,t=0,n=!1,r=!1){const i={x:(0,s.YT)(e,"x","cumprod")},u={axis:t,exclusive:n,reverse:r};return a.T2.runKernel(o.jj_,i,u)}});const le=(0,i.op)({cumsum_:function(e,t=0,n=!1,r=!1){const i={x:(0,s.YT)(e,"x","cumsum")},u={axis:t,exclusive:n,reverse:r};return a.T2.runKernel(o.nY8,i,u)}});const pe=(0,i.op)({denseBincount_:function(e,t,n,r=!1){const i=(0,s.YT)(e,"x","denseBincount"),u=(0,s.YT)(t,"weights","denseBincount");d.vA("int32"===i.dtype,()=>`Error in denseBincount: input dtype must be int32, but got ${i.dtype}`),d.vA(i.rank<=2,()=>`Error in denseBincount: input must be at most rank 2, but got rank ${i.rank}.`),d.vA(n>=0,()=>`size must be non-negative, but got ${n}.`),d.vA(u.size===i.size||0===u.size,()=>`Error in denseBincount: weights must have the same shape as x or 0-length, but got x shape: ${i.shape}, weights shape: ${u.shape}.`);const c={x:i,weights:u},l={size:n,binaryOutput:r};return a.T2.runKernel(o.wNW,c,l)}});const he=(0,i.op)({depthToSpace_:function(e,t,n="NHWC"){const r=(0,s.YT)(e,"x","depthToSpace","float32"),i="NHWC"===n?r.shape[1]:r.shape[2],u="NHWC"===n?r.shape[2]:r.shape[3],c="NHWC"===n?r.shape[3]:r.shape[1];d.vA(t>1,()=>`blockSize should be > 1 for depthToSpace, but was: ${t}`),d.vA(i*t>=0,()=>
2`Negative dimension size caused by overflow when multiplying\n ${i} and ${t} for depthToSpace with input shape\n ${r.shape}`),d.vA(u*t>=0,()=>`Negative dimension size caused by overflow when multiplying\n ${u} and ${t} for depthToSpace with input shape\n ${r.shape}`),d.vA(c%(t*t)===0,()=>`Dimension size must be evenly divisible by ${t*t} but is ${c} for depthToSpace with input shape ${r.shape}`);const l={x:r},p={blockSize:t,dataFormat:n};return a.T2.runKernel(o.TMz,l,p)}});const de=(0,i.op)({depthwiseConv2d_:function(e,t,n,r,i="NHWC",u=[1,1],c){const l=(0,s.YT)(e,"x","depthwiseConv2d","float32"),p=(0,s.YT)(t,"filter","depthwiseConv2d","float32");let h=l,f=!1;3===l.rank&&(f=!0,h=(0,E.t)(l,[1,l.shape[0],l.shape[1],l.shape[2]])),d.vA(4===h.rank,()=>`Error in depthwiseConv2d: input must be rank 4, but got rank ${h.rank}.`),d.vA(4===p.rank,()=>`Error in depthwiseConv2d: filter must be rank 4, but got rank ${p.rank}.`);const m="NHWC"===i?h.shape[3]:h.shape[1];d.vA(m===p.shape[2],()=>`Error in depthwiseConv2d: number of input channels (${m}) must match the inChannels dimension in filter ${p.shape[2]}.`),k.s_("depthwiseConv2d",r,c);const g={x:h,filter:p},y={strides:n,pad:r,dataFormat:i,dilations:u,dimRoundingMode:c},x=a.T2.runKernel(o.tGH,g,y);return f?(0,E.t)(x,[x.shape[1],x.shape[2],x.shape[3]]):x}});const fe=(0,i.op)({diag_:function(e){const t={x:(0,s.YT)(e,"x","diag")};return a.T2.runKernel(o.ORI,t)}});const me=(0,i.op)({dilation2d_:function(e,t,n,r,i=[1,1],u="NHWC"){const c=(0,s.YT)(e,"x","dilation2d"),l=(0,s.YT)(t,"filter","dilation2d");d.vA(3===c.rank||4===c.rank,()=>`Error in dilation2d: input must be rank 3 or 4, but got rank ${c.rank}.`),d.vA(3===l.rank,()=>`Error in dilation2d: filter must be rank 3, but got rank ${l.rank}.`),d.vA("NHWC"===u,()=>`Error in dilation2d: Only NHWC is currently supported, but got dataFormat of ${u}`);let p=c,h=!1;3===c.rank&&(p=(0,E.t)(c,[1,c.shape[0],c.shape[1],c.shape[2]]),h=!0);const f={x:p,filter:l},m={strides:n,pad:r,dilations:i},g=a.T2.runKernel(o.jxD,f,m);return h?(0,E.t)(g,[g.shape[1],g.shape[2],g.shape[3]]):g}});const ge=(0,i.op)({floorDiv_:function(e,t){let n=(0,s.YT)(e,"a","floorDiv"),r=(0,s.YT)(t,"b","floorDiv");[n,r]=(0,p.h0)(n,r);const i={a:n,b:r};return a.T2.runKernel(o.ElG,i)}});const ye=(0,i.op)({div_:function(e,t){let n=(0,s.YT)(e,"a","div"),r=(0,s.YT)(t,"b","div");if([n,r]=(0,p.h0)(n,r),"int32"===n.dtype&&"int32"===r.dtype)return ge(n,r);const i={a:n,b:r};return a.T2.runKernel(o.sDr,i,{})}});var xe=n(62198);const be=(0,i.op)({equal_:function(e,t){let n=(0,s.YT)(e,"a","equal","string_or_numeric"),r=(0,s.YT)(t,"b","equal","string_or_numeric");[n,r]=(0,p.h0)(n,r),(0,xe.assertAndGetBroadcastShape)(n.shape,r.shape);const i={a:n,b:r};return a.T2.runKernel(o.BRl,i)}});const ve=(0,i.op)({where_:function(e,t,n){const r=(0,s.YT)(t,"a","where"),i=(0,s.YT)(n,"b","where"),u=(0,s.YT)(e,"condition","where","bool"),c=(0,xe.assertAndGetBroadcastShape)((0,xe.assertAndGetBroadcastShape)(u.shape,r.shape),i.shape),l={condition:G(u,c),t:G(r,c),e:G(i,c)};return a.T2.runKernel(o.l6P,l)}});const we=(0,i.op)({zerosLike_:function(e){const t={x:(0,s.YT)(e,"x","zerosLike")};return a.T2.runKernel(o.xJ3,t)}});const Te=(0,i.op)({divNoNan_:function(e,t){let n=(0,s.YT)(e,"a","div"),r=(0,s.YT)(t,"b","div");[n,r]=(0,p.h0)(n,r);const a=ye(n,r),o=we(a),i=be(r,o);return ve(i,o,a)}});const Se=(0,i.op)({dot_:function(e,t){const n=(0,s.YT)(e,"t1","dot"),r=(0,s.YT)(t,"t2","dot");d.vA(!(1!==n.rank&&2!==n.rank||1!==r.rank&&2!==r.rank),()=>`Error in dot: inputs must all be rank 1 or 2, but got ranks ${n.rank} and ${r.rank}.`);const a=1===n.rank?n.size:n.shape[1],o=1===r.rank?r.size:r.shape[0];if(d.vA(a===o,()=>`Error in dot: inner dimensions of inputs must match, but got ${a} and ${o}.`),1===n.rank&&1===r.rank){const e=(0,E.t)(n,[1,-1]),t=(0,E.t)(r,[-1,1]),a=R(e,t);return(0,E.t)(a,[])}if(1===n.rank&&2===r.rank){const e=(0,E.t)(n,[1,-1]),t=(0,E.t)(r,[r.shape[0],r.shape[1]]),a=R(e,t);return(0,E.t)(a,[a.size])}if(2===n.rank&&1===r.rank){const e=(0,E.t)(r,[-1,1]),t=R(n,e);return(0,E.t)(t,[t.size])}{const e=(0,E.t)(r,[r.shape[0],r.shape[1]]);return R(n,e)}}});const Ce=(0,i.op)({einsum_:function(e,...t){const n=t.map((e,t)=>(0,s.YT)(e,`tensors${t}`,"einsum")),r={equation:e};return a.T2.runKernel(o.Qgm,n,r)}});var ke=n(83416);const Ee=(0,i.op)({erf_:function(e){let t=(0,s.YT)(e,"x","erf");d.vA("int32"===t.dtype||"float32"===t.dtype,()=>"Input dtype must be `int32` or `float32`."),"int32"===t.dtype&&(t=(0,C.w)(t,"float32"));const n={x:t};return a.T2.runKernel(o._s9,n)}});var $e=n(21078);const Ne=(0,i.op)({max_:function(e,t=null,n=!1){const r={x:(0,s.YT)(e,"x","max")},i={reductionIndices:t,keepDims:n};return a.T2.runKernel(o.VAI,r,i)}});const Ie=(0,i.op)({min_:function(e,t=null,n=!1){const r={x:(0,s.YT)(e,"x","min")},i={axis:t,keepDims:n};return a.T2.runKernel(o.lNG,r,i)}});const Ae=(0,i.op)({pow_:function(e,t){let n=(0,s.YT)(e,"base","pow"),r=(0,s.YT)(t,"exp","pow");[n,r]=(0,p.h0)(n,r);const i={a:n,b:r};return a.T2.runKernel(o.pyJ,i)}});var Re=n(45702);const _e=(0,i.op)({sqrt_:function(e){const t={x:(0,s.YT)(e,"x","sqrt","float32")};return a.T2.runKernel(o.dFH,t)}});const Oe=(0,i.op)({square_:function(e){const t=(0,s.YT)(e,"x","square");return a.T2.runKernel("Square",{x:t},{})}});var Fe=n(83791);function De(e,t,n=null){if(0===e.rank)return u(e);
2if(1!==e.rank&&null===n)return De((0,E.t)(e,[-1]),t,n);if(1===e.rank||"number"==typeof n||Array.isArray(n)&&1===n.length){if(1===t)return(0,Fe.c)(u(e),n);if(t===1/0)return Ne(u(e),n);if(t===-1/0)return Ie(u(e),n);if("euclidean"===t||2===t)return _e((0,Fe.c)(Ae(u(e),(0,Re.d)(2,"int32")),n));throw new Error(`Error in norm: invalid ord value: ${t}`)}if(Array.isArray(n)&&2===n.length){if(1===t)return Ne((0,Fe.c)(u(e),n[0]),n[1]-1);if(t===1/0)return Ne((0,Fe.c)(u(e),n[1]),n[0]);if(t===-1/0)return Ie((0,Fe.c)(u(e),n[1]),n[0]);if("fro"===t||"euclidean"===t)return _e((0,Fe.c)(Oe(e),n));throw new Error(`Error in norm: invalid ord value: ${t}`)}throw new Error(`Error in norm: invalid axis: ${n}`)}const Le=(0,i.op)({norm_:function(e,t="euclidean",n=null,r=!1){const a=De(e=(0,s.YT)(e,"x","norm"),t,n);let o=a.shape;if(r){const t=(0,d.Y6)(n,e.shape);o=$e.SM(a.shape,t)}return(0,E.t)(a,o)}});const Me=(0,i.op)({euclideanNorm_:function(e,t=null,n=!1){return Le(e,"euclidean",t,n)}});const Pe=(0,i.op)({exp_:function(e){const t={x:(0,s.YT)(e,"x","exp")};return a.T2.runKernel(o.ox3,t)}});const Be=(0,i.op)({expandDims_:function(e,t=0){const n=(0,s.YT)(e,"x","expandDims","string_or_numeric");d.vA(t<=n.rank,()=>"Axis must be <= rank of the tensor");const r={input:n},i={dim:t};return a.T2.runKernel(o.ybN,r,i)}});const Ve=(0,i.op)({expm1_:function(e){const t={x:(0,s.YT)(e,"x","expm1")};return a.T2.runKernel(o.ybj,t)}});const ze=(0,i.op)({tile_:function(e,t){const n=(0,s.YT)(e,"x","tile","string_or_numeric");d.vA(n.rank===t.length,()=>`Error in transpose: rank of input ${n.rank} must match length of reps ${t}.`);const r={x:n},i={reps:t};return a.T2.runKernel(o.FAs,r,i)}});const Ue=(0,i.op)({eye_:function(e,t,n,r="float32"){null==t&&(t=e);const a=(0,j.r)([e,t],r),o=e<=t?e:t;for(let e=0;e<o;++e)a.set(1,e,e);const s=(0,E.t)(a.toTensor(),[e,t]);if(null==n)return s;if(1===n.length)return ze(Be(s,0),[n[0],1,1]);if(2===n.length)return ze(Be(Be(s,0),0),[n[0],n[1],1,1]);if(3===n.length)return ze(Be(Be(Be(s,0),0),0),[n[0],n[1],n[2],1,1]);throw new Error(`eye() currently supports only 1D and 2D batchShapes, but received ${n.length}D.`)}});const We=(0,i.op)({floor_:function(e){const t={x:(0,s.YT)(e,"x","floor","float32")};return a.T2.runKernel(o.ZgB,t)}});const Ge=(0,i.op)({gather_:function(e,t,n=0,r=0){const i={x:(0,s.YT)(e,"x","gather"),indices:(0,s.YT)(t,"indices","gather","int32")},u={axis:n,batchDims:r};return a.T2.runKernel(o.mxL,i,u)}});const je=(0,i.op)({greater_:function(e,t){let n=(0,s.YT)(e,"a","greater","string_or_numeric"),r=(0,s.YT)(t,"b","greater","string_or_numeric");[n,r]=(0,p.h0)(n,r),(0,xe.assertAndGetBroadcastShape)(n.shape,r.shape);const i={a:n,b:r};return a.T2.runKernel(o.XhZ,i)}});const Ke=(0,i.op)({greaterEqual_:function(e,t){let n=(0,s.YT)(e,"a","greaterEqual","string_or_numeric"),r=(0,s.YT)(t,"b","greaterEqual","string_or_numeric");[n,r]=(0,p.h0)(n,r),(0,xe.assertAndGetBroadcastShape)(n.shape,r.shape);const i={a:n,b:r};return a.T2.runKernel(o.lLS,i)}});const He=(0,i.op)({imag_:function(e){const t={input:(0,s.YT)(e,"input","imag")};return a.T2.runKernel(o.dv8,t)}});const Ye=(0,i.op)({isFinite_:function(e){const t={x:(0,s.YT)(e,"x","isFinite")};return a.T2.runKernel(o.gIW,t)}});const Ze=(0,i.op)({isInf_:function(e){const t={x:(0,s.YT)(e,"x","isInf")};return a.T2.runKernel(o.E3$,t)}});const Xe=(0,i.op)({isNaN_:function(e){const t={x:(0,s.YT)(e,"x","isNaN")};return a.T2.runKernel(o.iPs,t)}});var qe=n(66919);const Qe=(0,i.op)({less_:function(e,t){let n=(0,s.YT)(e,"a","less","string_or_numeric"),r=(0,s.YT)(t,"b","less","string_or_numeric");[n,r]=(0,p.h0)(n,r),(0,xe.assertAndGetBroadcastShape)(n.shape,r.shape);const i={a:n,b:r};return a.T2.runKernel(o.mIA,i)}});const Je=(0,i.op)({lessEqual_:function(e,t){let n=(0,s.YT)(e,"a","lessEqual","string_or_numeric"),r=(0,s.YT)(t,"b","lessEqual","string_or_numeric");[n,r]=(0,p.h0)(n,r),(0,xe.assertAndGetBroadcastShape)(n.shape,r.shape);const i={a:n,b:r};return a.T2.runKernel(o.CwD,i)}});function et(e,t,n){if(n<=0)throw new Error("The number of values should be positive.");const r={start:e,stop:t,num:n};return a.T2.runKernel(o.mnI,{},r)}const tt=(0,i.op)({localResponseNormalization_:function(e,t=5,n=1,r=1,i=.5){const u=(0,s.YT)(e,"x","localResponseNormalization");d.vA(4===u.rank||3===u.rank,()=>`Error in localResponseNormalization: x must be rank 3 or 4 but got\n rank ${u.rank}.`),d.vA(d.E6(t),()=>`Error in localResponseNormalization: depthRadius must be an integer but got depthRadius ${t}.`);let c=u,l=!1;3===u.rank&&(l=!0,c=(0,E.t)(u,[1,u.shape[0],u.shape[1],u.shape[2]]));const p={x:c},h={depthRadius:t,bias:n,alpha:r,beta:i},f=a.T2.runKernel(o.jM4,p,h);return l?(0,E.t)(f,[f.shape[1],f.shape[2],f.shape[3]]):f}});const nt=(0,i.op)({log_:function(e){const t={x:(0,s.YT)(e,"x","log","float32")};return a.T2.runKernel(o.tG8,t)}});const rt=(0,i.op)({log1p_:function(e){const t={x:(0,s.YT)(e,"x","log1p")};return a.T2.runKernel(o.Cg$,t)}});var at=n(21722);function ot(e){return a.T2.customGrad(e)}const st=(0,i.op)({neg_:function(e){const t={x:(0,s.YT)(e,"x","neg")};return a.T2.runKernel(o.l0G,t)}});const it=(0,i.op)({softplus_:function(e){const t={x:(0,s.YT)(e,"x","softplus")};return a.T2.runKernel(o.Fin,t)}});const ut=(0,i.op)({logSigmoid_:function(e){const t=(0,s.YT)(e,"x","logSigmoid");return ot(e=>({value:st(it(st(e))),gradFunc:t=>(0,_.l)(t,(0,O.r)(st(e)))}))(t)}});const ct=(0,i.op)({sub_:function(e,t){let n=(0,s.YT)(e,"a","sub"),r=(0,s.YT)(t,"b","sub");[n,r]=(0,p.h0)(n,r);const i={a:n,b:r};return a.T2.runKernel(o.PbM,i)}});const lt=(0,i.op)({logSoftmax_:function(e,t=-1){const n=(0,s.YT)(e,"logits","logSoftmax");if(-1===t&&(t=n.rank-1),t!==n.rank-1)throw Error(`Log Softmax along a non-last dimension is not yet supported. Logits was rank ${n.rank}
2 and axis was ${t}`);const r=ot((e,n)=>{const r=Ne(e,t,!0),a=ct(e,r),o=ct((0,C.w)(a,"float32"),nt((0,Fe.c)(Pe(a),t,!0)));n([o]);return{value:o,gradFunc:(e,n)=>{const[r]=n,a=Pe(r);return ct(e,(0,_.l)((0,Fe.c)(e,t,!0),a))}}});return r(n)}});const pt=(0,i.op)({logSumExp_:function(e,t=null,n=!1){const r=(0,s.YT)(e,"x","logSumExp"),a=(0,d.Y6)(t,r.shape),o=Ne(r,a,!0),i=ct(r,o),u=Pe(i),c=(0,Fe.c)(u,a),l=nt(c),p=h((0,E.t)(o,l.shape),l);if(n){const e=(0,$e.SM)(p.shape,a);return(0,E.t)(p,e)}return p}});const ht=(0,i.op)({logicalAnd_:function(e,t){const n=(0,s.YT)(e,"a","logicalAnd","bool"),r=(0,s.YT)(t,"b","logicalAnd","bool");(0,xe.assertAndGetBroadcastShape)(n.shape,r.shape);const i={a:n,b:r};return a.T2.runKernel(o.RUm,i)}});const dt=(0,i.op)({logicalNot_:function(e){const t={x:(0,s.YT)(e,"x","logicalNot","bool")};return a.T2.runKernel(o.nZd,t)}});const ft=(0,i.op)({logicalOr_:function(e,t){const n=(0,s.YT)(e,"a","logicalOr","bool"),r=(0,s.YT)(t,"b","logicalOr","bool");(0,xe.assertAndGetBroadcastShape)(n.shape,r.shape);const i={a:n,b:r};return a.T2.runKernel(o.LXA,i)}});const mt=(0,i.op)({logicalXor_:function(e,t){const n=(0,s.YT)(e,"a","logicalXor","bool"),r=(0,s.YT)(t,"b","logicalXor","bool");return(0,xe.assertAndGetBroadcastShape)(n.shape,r.shape),ht(ft(e,t),dt(ht(e,t)))}}),gt=2147483648;const yt=(0,i.op)({searchSorted_:function(e,t,n="left"){const r=(0,s.YT)(e,"sortedSequence","searchSorted"),i=(0,s.YT)(t,"values","searchSorted"),u=r.shape[r.shape.length-1],c=i.shape[i.shape.length-1],l=(0,E.t)(r,[-1,u]),p=(0,E.t)(i,[-1,c]);if(l.rank<2)throw new Error("Sorted input argument must be at least 2-dimensional");if(l.shape[0]!==p.shape[0])throw new Error("Leading dimension of 'sortedSequence' and 'values' must match.");if((0,d.Ze)(p.shape)>=gt)throw new Error("values tensor size must less than 2147483648");if(l.shape[1]>=gt)throw new Error(`trailing dim_size must less than 2147483648 for int32 output type, was ${l.shape[1]}`);const h={sortedSequence:l,values:p},f={side:n};return a.T2.runKernel(o.uWl,h,f)}});function xt(e,t){return yt(e,t,"left")}const bt=(0,i.op)({maxPool_:function(e,t,n,r,i){const u=(0,s.YT)(e,"x","maxPool");let c=u,l=!1;3===u.rank&&(l=!0,c=(0,E.t)(u,[1,u.shape[0],u.shape[1],u.shape[2]])),d.vA(4===c.rank,()=>`Error in maxPool: input must be rank 4 but got rank ${c.rank}.`),d.vA(k.G0(n,1),()=>`Error in maxPool: Either strides or dilations must be 1. Got strides ${n} and dilations '1'`),k.s_("maxPool",r,i);const p={x:c},h={filterSize:t,strides:n,pad:r,dimRoundingMode:i},f=a.T2.runKernel(o.t3d,p,h);return l?(0,E.t)(f,[f.shape[1],f.shape[2],f.shape[3]]):f}});const vt=(0,i.op)({maxPool3d_:function(e,t=[1,1,1],n,r,i,u="NDHWC"){const c=(0,s.YT)(e,"x","maxPool3d");let l=c,p=!1;4===c.rank&&(p=!0,l=(0,E.t)(c,[1,c.shape[0],c.shape[1],c.shape[2],c.shape[3]])),d.vA(5===l.rank,()=>`Error in maxPool3d: x must be rank 5 but got rank ${l.rank}.`),d.vA("NDHWC"===u,()=>`Error in maxPool3d: Only NDHWC is currently supported, but got dataFormat of ${u}`),(0,k.s_)("maxPool3d",r,i);const h={x:l},f={filterSize:t,strides:n,pad:r,dimRoundingMode:i,dataFormat:u},m=a.T2.runKernel(o.ySp,h,f);return p?(0,E.t)(m,[m.shape[1],m.shape[2],m.shape[3],m.shape[4]]):m}});const wt=(0,i.op)({maxPoolWithArgmax_:function(e,t,n,r,i=!1){const u={x:(0,s.YT)(e,"x","maxPoolWithArgmax")},c={filterSize:t,strides:n,pad:r,includeBatchInIndex:i},l=a.T2.runKernel(o.TL8,u,c);return{result:l[0],indexes:l[1]}}});const Tt=(0,i.op)({maximum_:function(e,t){let n=(0,s.YT)(e,"a","maximum"),r=(0,s.YT)(t,"b","maximum");[n,r]=(0,p.h0)(n,r),"bool"===n.dtype&&(n=(0,C.w)(n,"int32"),r=(0,C.w)(r,"int32")),(0,xe.assertAndGetBroadcastShape)(n.shape,r.shape);const i={a:n,b:r};return a.T2.runKernel(o.LDN,i)}});const St=(0,i.op)({mean_:function(e,t=null,n=!1){const r={x:(0,s.YT)(e,"x","mean")},i={axis:t,keepDims:n};return a.T2.runKernel(o.g5A,r,i)}});function Ct(e,t="float32"){if("complex64"===t){const t=Ct(e,"float32"),n=Ct(e,"float32");return(0,Z.f)(t,n)}const n=(0,d.Ty)((0,d.Ze)(e),t);return a.T2.makeTensor(n,e,t)}function kt(e,t="float32"){if("complex64"===t){const t=kt(e,"float32"),n=Ct(e,"float32");return(0,Z.f)(t,n)}const n=(0,d.FZ)((0,d.Ze)(e),t);return a.T2.makeTensor(n,e,t)}function Et(e,t,{indexing:n="xy"}={}){if("xy"!==n&&"ij"!==n)throw new TypeError(`${n} is not a valid third argument to meshgrid`);if(void 0===e)return[];let r=(0,s.YT)(e,"x","meshgrid",e instanceof at.qY?e.dtype:"float32");if(void 0===t)return[r];let a=(0,s.YT)(t,"y","meshgrid",t instanceof at.qY?t.dtype:"float32");const o=(0,d.Ze)(r.shape),i=(0,d.Ze)(a.shape);return"xy"===n?(r=(0,E.t)(r,[1,-1]),a=(0,E.t)(a,[-1,1]),[R(kt([i,1],r.dtype),r),R(a,kt([1,o],a.dtype))]):(r=(0,E.t)(r,[-1,1]),a=(0,E.t)(a,[1,-1]),[R(r,kt([1,i],r.dtype)),R(kt([o,1],a.dtype),a)])}const $t=(0,i.op)({minimum_:function(e,t){let n=(0,s.YT)(e,"a","minimum"),r=(0,s.YT)(t,"b","minimum");[n,r]=(0,p.h0)(n,r),"bool"===n.dtype&&(n=(0,C.w)(n,"int32"),r=(0,C.w)(r,"int32")),(0,xe.assertAndGetBroadcastShape)(n.shape,r.shape);const i={a:n,b:r};return a.T2.runKernel(o.LG0,i)}});const Nt=(0,i.op)({mirrorPad_:function(e,t,n){d.vA("reflect"===n||"symmetric"===n,()=>`Invalid mode. Mode must be either reflect or symmetric. Got ${n}.`);const r=(0,s.YT)(e,"x","mirrorPad");if(0===r.rank)throw new Error("mirrorPad(scalar) is not defined. Pass non-scalar to mirrorPad");d.vA(t.length===r.rank,()=>`Padding doesn't match input. Must be ${r.rank}. Got ${t.length}.`);const i="reflect"===n?1:0;for(let e=0;e<r.rank;e++)d.vA(2===t[e].length,()=>"Invalid number of paddings. Must be length of 2 each."),d.vA(t[e][0]>=0&&t[e][0]<=r.shape[e]-i&&t[e][1]>=0&&t[e][1]<=r.shape[e]-i,()=>`Padding in dimension ${e} cannot be greater than or equal to ${r.shape[e]-i} or less than 0 for input of shape ${r.shape}`);const u={paddings:t,mode:n},c={x:r};return a.T2.runKernel(o.x7F,c,u)}});const It=(0,i.op)({mod_:function(e,t){let n=(0,s.YT)(e,"a","mod"),r=(0,s.YT)(t,"b","mod");[n,r]=(0,p.h0)(n,r);const i={a:n,b:r};return a.T2.runKernel(o.BLA,i)}});const At=(0,i.op)({moments_:function(e,t=null,n=!1){e=(0,s.YT)(e,"x","moments");const r=(0,d.Y6)(t,e.shape),a=St(e,r,n);let o=a.shape;n||(o=(0,$e.SM)(a.shape,r));const i=Oe(ct((0,C.w)(e,"float32"),(0,E.t)(a,o)));return{mean:a,variance:St(i,r,n)}}});const Rt=(0,i.op)({multiRNNCell_:function(e,t,n,r){const a=(0,s.YT)(t,"data","multiRNNCell"),o=(0,s.j1)(n,"c","multiRNNCell"),i=(0,s.j1)(r,"h","multiRNNCell");let u=a;const c=[];for(let t=0;t<e.length;t++){const n=e[t](u,o[t],i[t]);c.push(n[0]),c.push(n[1]),u=n[1]}const l=[],p=[];for(let e=0;e<c.length;e+=2)l.push(c[e]),p.push(c[e+1]);return[l,p]}});const _t=(0,i.op)({multinomial_:function(e,t,n,r=!1){const i=(0,s.YT)(e,"logits","multinomial"),u=i.size,c=i.rank;if(u<2)throw new Error(`Error in multinomial: you need at least 2 outcomes, but got ${u}.`);if(c>2)throw new Error(`Rank of probabilities must be 1 or 2, but is ${c}`);n=n||Math.random();const l={logits:1===c?(0,E.t)(i,[1,-1]):i},p={numSamples:t,seed:n,normalized:r},h=a.T2.runKernel(o.WT3,l,p);return 1===c?(0,E.t)(h,[h.size]):h}});const Ot=(0,i.op)({notEqual_:function(e,t){let n=(0,s.YT)(e,"a","
2notEqual","string_or_numeric"),r=(0,s.YT)(t,"b","notEqual","string_or_numeric");[n,r]=(0,p.h0)(n,r),(0,xe.assertAndGetBroadcastShape)(n.shape,r.shape);const i={a:n,b:r};return a.T2.runKernel(o.ylV,i)}});const Ft=(0,i.op)({oneHot_:function(e,t,n=1,r=0,i="int32"){if(t<2)throw new Error(`Error in oneHot: depth must be >=2, but it is ${t}`);const u={indices:(0,s.YT)(e,"indices","oneHot","int32")},c={dtype:i,depth:t,onValue:n,offValue:r};return a.T2.runKernel(o.urI,u,c)}});const Dt=(0,i.op)({onesLike_:function(e){const t={x:(0,s.YT)(e,"x","onesLike")};return a.T2.runKernel(o.LWX,t)}});const Lt=(0,i.op)({outerProduct_:function(e,t){const n=(0,s.YT)(e,"v1","outerProduct"),r=(0,s.YT)(t,"v2","outerProduct");d.vA(1===n.rank&&1===r.rank,()=>`Error in outerProduct: inputs must be rank 1, but got ranks ${n.rank} and ${r.rank}.`);const a=(0,E.t)(n,[-1,1]),o=(0,E.t)(r,[1,-1]);return R(a,o)}});const Mt=(0,i.op)({pad_:function(e,t,n=0){const r=(0,s.YT)(e,"x","pad");if(0===r.rank)throw new Error("pad(scalar) is not defined. Pass non-scalar to pad");const i={paddings:t,constantValue:n},u={x:r};return a.T2.runKernel(o.ODT,u,i)}});const Pt=(0,i.op)({pad1d_:function(e,t,n=0){return(0,d.vA)(2===t.length,()=>"Invalid number of paddings. Must be length of 2."),Mt(e,[t],n)}});const Bt=(0,i.op)({pad2d_:function(e,t,n=0){return(0,d.vA)(2===t.length&&2===t[0].length&&2===t[1].length,()=>"Invalid number of paddings. Must be length of 2 each."),Mt(e,t,n)}});const Vt=(0,i.op)({pad3d_:function(e,t,n=0){return(0,d.vA)(3===t.length&&2===t[0].length&&2===t[1].length&&2===t[2].length,()=>"Invalid number of paddings. Must be length of 2 each."),Mt(e,t,n)}});const zt=(0,i.op)({pad4d_:function(e,t,n=0){return(0,d.vA)(4===t.length&&2===t[0].length&&2===t[1].length&&2===t[2].length&&2===t[3].length,()=>"Invalid number of paddings. Must be length of 2 each."),Mt(e,t,n)}});const Ut=(0,i.op)({spaceToBatchND_:function(e,t,n){const r=(0,s.YT)(e,"x","spaceToBatchND");d.vA(r.rank>=1+t.length,()=>`input rank ${r.rank} should be > than [blockShape] ${t.length}`),d.vA(n.length===t.length,()=>`paddings.shape[0] ${n.length} must be equal to [blockShape] ${t.length}`),d.vA(r.shape.reduce((e,r,a)=>a>0&&a<=t.length?e&&(r+n[a-1][0]+n[a-1][1])%t[a-1]===0:e,!0),()=>`input spatial dimensions ${r.shape.slice(1)} with paddings ${n.toString()} must be divisible by blockShapes ${t.toString()}`);const i={x:r},u={blockShape:t,paddings:n};return a.T2.runKernel(o.A8B,i,u)}});const Wt=(0,i.op)({pool_:function(e,t,n,r,a,o,i){null==a&&(a=[1,1]),null==o&&(o=1),0===r&&(r="valid");const u=(0,s.YT)(e,"x","maxPool");let c=u,l=!1;3===u.rank&&(l=!0,c=(0,E.t)(u,[1,u.shape[0],u.shape[1],u.shape[2]])),d.vA(k.G0(o,a),()=>`Error in pool: Either strides or dilations must be 1. Got strides ${o} and dilations '${a}'`);const p=k.E6(c.shape,t,o,a,r),h=[p.dilationHeight,p.dilationWidth];let f;f="same"===r?function(e,t){const n=e.map((e,n)=>e+(e-1)*(t[n]-1)),r=n.map(e=>e-1),a=r.map(e=>Math.floor(e/2)),o=r.map((e,t)=>e-a[t]);return r.map((e,t)=>[a[t],o[t]])}([p.filterHeight,p.filterWidth],h):[[0,0],[0,0]];const m=1===h[0]&&1===h[1],[g,y]=function(e,t,n){const r=n.map(e=>e[0]),a=n.map(e=>e[1]),o=e.concat(r,a),s=t.map((e,t)=>(e-o[t]%e)%e),i=a.map((e,t)=>e+s[t]),u=t.map((e,t)=>[r[t],i[t]]),c=t.map((e,t)=>[0,s[t]]);return[u,c]}([p.inHeight,p.inWidth],h,f),x=m?r:"valid",b=m?c:Ut(c,h,g),v=("avg"===n?()=>$(b,t,o,x,i):()=>bt(b,t,o,x,i))(),w=m?v:M(v,h,y);return l?(0,E.t)(w,[w.shape[1],w.shape[2],w.shape[3]]):w}});var Gt=n(64394),jt=n(75295);const Kt=(0,i.op)({prod_:function(e,t=null,n=!1){let r=(0,s.YT)(e,"x","prod");"bool"===r.dtype&&(r=(0,C.w)(r,"int32"));const i={x:r},u={axis:t,keepDims:n};return a.T2.runKernel(o.kdj,i,u)}});const Ht=(0,i.op)({raggedGather_:function(e,t,n,r){const i={paramsNestedSplits:e.map((e,t)=>(0,s.YT)(e,`tensors${t}`,"raggedGather","int32")),paramsDenseValues:(0,s.YT)(t,"paramsDenseValues","raggedGather"),indices:(0,s.YT)(n,"indices","raggedGather","int32")},u={outputRaggedRank:r},c=a.T2.runKernel(o.oJ2,i,u);return{outputNestedSplits:c.slice(0,c.length-1),outputDenseValues:c[c.length-1]}}});const Yt=(0,i.op)({raggedTensorToTensor_:function(e,t,n,r,i){const u=(0,s.YT)(e,"shape","raggedTensorToTensor","int32"),c=(0,s.YT)(t,"values","raggedTensorToTensor"),l={shape:u,values:c,defaultValue:(0,s.YT)(n,"defaultValue","raggedTensorToTensor",c.dtype),rowPartitionTensors:r.map((e,t)=>(0,s.YT)(e,`tensors${t}`,"raggedTensorToTensor","int32"))},p={rowPartitionTypes:i};return a.T2.runKernel(o.mH5,l,p)}});const Zt=(0,i.op)({rand_:function(e,t,n){const r=(0,d.Ze)(e);let o=null;if(null==n||"float32"===n)o=new Float32Array(r);else if("int32"===n)o=new Int32Array(r);else{if("bool"!==n)throw new Error(`Unknown data type ${n}`);o=new Uint8Array(r)}for(let e=0;e<r;e++)o[e]=t();return a.T2.makeTensor(o,e,n)}});var Xt=n(7391);class qt{constructor(e,t,n,r,a){this.mean=e,this.stdDev=t,this.dtype=n,this.nextVal=NaN,this.truncated=r,this.truncated&&(this.upper=this.mean+2*this.stdDev,this.lower=this.mean-2*this.stdDev);const o=a||Math.random();this.random=Xt.alea(o.toString())}nextValue(){if(!isNaN(this.nextVal)){const e=this.nextVal;return this.nextVal=NaN,e}let e,t,n=!1;for(;!n;){let r,a,o;do{r=2*this.random()-1,a=2*this.random()-1,o=r*r+a*a}while(o>=1||0===o);const s=Math.sqrt(-2*Math.log(o)/o);e=this.mean+this.stdDev*r*s,t=this.mean+this.stdDev*a*s,this.truncated&&!this.isValidTruncated(e)||(n=!0)}return this.truncated&&!this.isValidTruncated(t)||(this.nextVal=this.convertValue(t)),this.convertValue(e)}convertValue(e){return null==this.dtype||"float32"===this.dtype?e:Math.round(e)}isValidTruncated(e){return e<=this.upper&&e>=this.lower}}class Qt{constructor(e,t,n,r){this.alpha=e,this.beta=1/t,this.dtype=n;const a=r||Math.random();this.randu=Xt.alea(a.toString()),this.randn=new qt(0,1,n,!1,this.randu()),this.d=e<1?e+2/3:e-1/3,this.c=1/Math.sqrt(9*this.d)}nextValue(){let e,t,n,r,a,o;for(;;){do{r=this.randn.nextValue(),o=1+this.c*r}while(o<=0);if(o*=o*o,e=r*r,t=1-.331*e*e,n=.5*e+this.d*(1-o+Math.log(o)),a=this.randu(),a<t||Math.log(a)<n)break}return o=1/this.beta*this.d*o,this.alpha<1&&(o*=Math.pow(this.randu(),1/this.alpha)),this.convertValue(o)}convertValue(e){return"float32"===this.dtype?e:Math.round(e)}}class Jt{constructor(e=0,t=1,n,r){if(this.canReturnFloat=()=>null==this.dtype||"float32"===this.dtype,this.min=e,this.range=t-e,this.dtype=n,null==r&&(r=Math.random()),"number"==typeof r&&(r=r.toString()),!this.canReturnFloat()&&this.range<=1)throw new Error(`The difference between ${e} - ${t} <= 1 and dtype is not float`);this.random=Xt.alea(r)}convertValue(e){return this.canReturnFloat()?e:Math.round(e)}
2nextValue(){return this.convertValue(this.min+this.range*this.random())}}const en=(0,i.op)({randomGamma_:function(e,t,n=1,r="float32",a){if(null==n&&(n=1),null==r&&(r="float32"),"float32"!==r&&"int32"!==r)throw new Error(`Unsupported data type ${r}`);const o=new Qt(t,n,r,a),s=(0,j.r)(e,r);for(let e=0;e<s.values.length;e++)s.values[e]=o.nextValue();return s.toTensor()}});const tn=(0,i.op)({randomNormal_:function(e,t=0,n=1,r,a){if(null!=r&&"bool"===r)throw new Error(`Unsupported data type ${r}`);const o=new qt(t,n,r,!1,a),s=(0,j.r)(e,r);for(let e=0;e<s.values.length;e++)s.values[e]=o.nextValue();return s.toTensor()}});const nn=(0,i.op)({randomStandardNormal_:function(e,t,n){if(null!=t&&"bool"===t)throw new Error(`Unsupported data type ${t}`);return tn(e,0,1,t,n)}});const rn=(0,i.op)({randomUniform_:function(e,t=0,n=1,r="float32",a){const o=(0,j.r)(e,r),s=new Jt(t,n,null,a);for(let e=0;e<o.values.length;e++)o.values[e]=s.nextValue();return o.toTensor()}});function an(e,t,n=1,r="float32"){if(0===n)throw new Error("Cannot have a step of zero");const s={start:e,stop:t,step:n,dtype:r};return a.T2.runKernel(o.Q6t,{},s)}const on=(0,i.op)({real_:function(e){const t={input:(0,s.YT)(e,"input","real")};return a.T2.runKernel(o.LRy,t)}});const sn=(0,i.op)({reciprocal_:function(e){const t={x:(0,s.YT)(e,"x","reciprocal")};return a.T2.runKernel(o.huO,t)}});var un=n(90112),cn=n(83732);const ln=(0,i.op)({reverse_:function(e,t){const n={x:(0,s.YT)(e,"x","reverse")},r={dims:t};return a.T2.runKernel(o.D7i,n,r)}});const pn=(0,i.op)({reverse1d_:function(e){const t=(0,s.YT)(e,"x","reverse");return d.vA(1===t.rank,()=>`Error in reverse1D: x must be rank 1 but got rank ${t.rank}.`),ln(t,0)}});const hn=(0,i.op)({reverse2d_:function(e,t){const n=(0,s.YT)(e,"x","reverse");return d.vA(2===n.rank,()=>`Error in reverse2D: x must be rank 2 but got rank ${n.rank}.`),ln(n,t)}});const dn=(0,i.op)({reverse3d_:function(e,t){const n=(0,s.YT)(e,"x","reverse");return d.vA(3===n.rank,()=>`Error in reverse3D: x must be rank 3 but got rank ${n.rank}.`),ln(n,t)}});const fn=(0,i.op)({reverse4d_:function(e,t){const n=(0,s.YT)(e,"x","reverse");return d.vA(4===n.rank,()=>`Error in reverse4D: x must be rank 4 but got rank ${n.rank}.`),ln(n,t)}});const mn=(0,i.op)({round_:function(e){const t={x:(0,s.YT)(e,"x","round")};return a.T2.runKernel(o.hVg,t)}});const gn=(0,i.op)({rsqrt_:function(e){const t={x:(0,s.YT)(e,"x","rsqrt","float32")};return a.T2.runKernel(o.TOR,t)}});const yn=(0,i.op)({selu_:function(e){const t={x:(0,s.YT)(e,"x","selu")};return a.T2.runKernel(o.u$b,t)}});const xn=(0,i.op)({separableConv2d_:function(e,t,n,r,a,o=[1,1],i="NHWC"){const u=(0,s.YT)(e,"x","separableConv2d"),c=(0,s.YT)(t,"depthwiseFilter","separableConv2d"),l=(0,s.YT)(n,"pointwiseFilter","separableConv2d");let p=u,h=!1;if(3===u.rank&&(h=!0,p=(0,E.t)(u,[1,u.shape[0],u.shape[1],u.shape[2]])),"NCHW"===i)throw new Error("separableConv2d currently does not support dataFormat NCHW; only NHWC is supported");d.vA(4===p.rank,()=>`Error in separableConv2d: input must be rank 4, but got rank ${p.rank}.`),d.vA(4===c.rank,()=>`Error in separableConv2d: depthwise filter must be rank 4, but got rank ${c.rank}.`),d.vA(4===l.rank,()=>`Error in separableConv2d: pointwise filter must be rank 4, but got rank ${c.rank}.`),d.vA(1===l.shape[0],()=>`Error in separableConv2d: the first dimension of pointwise filter must be 1, but got ${l.shape[0]}.`),d.vA(1===l.shape[1],()=>`Error in separableConv2d: the second dimension of pointwise filter must be 1, but got ${l.shape[1]}.`);const f=c.shape[2],m=c.shape[3];d.vA(l.shape[2]===f*m,()=>`Error in separableConv2d: the third dimension of pointwise filter must be ${f*m}, but got ${l.shape[2]}.`);const g=de(p,c,r,a,i,o),y=ee(g,l,1,"valid",i);return h?(0,E.t)(y,[y.shape[1],y.shape[2],y.shape[3]]):y}});const bn=async function(e,t){const n=(0,s.YT)(e,"x","setdiff1d"),r=(0,s.YT)(t,"y","setdiff1d");d.vA(n.dtype===r.dtype,()=>`x and y should have the same dtype, but got x (${n.dtype}) and y (${r.dtype}).`),d.vA(1===n.rank,()=>`x should be 1D tensor, but got x (${n.shape}).`),d.vA(1===r.rank,()=>`y should be 1D tensor, but got y (${r.shape}).`);const a=await n.data(),o=await r.data(),i=new Set(o);let u=0;for(let e=0;e<a.length;e++)i.has(a[e])||u++;const c=new at.yl([u],n.dtype),l=new at.yl([u],"int32");for(let e=0,t=0;e<a.length;e++)i.has(a[e])||(c.values[t]=a[e],l.values[t]=e,t++);return[c.toTensor(),l.toTensor()]};const vn=(0,i.op)({sign_:function(e){const t={x:(0,s.YT)(e,"x","sign")};return a.T2.runKernel(o.YVe,t)}});const wn=(0,i.op)({sin_:function(e){const t={x:(0,s.YT)(e,"x","sin","float32")};return a.T2.runKernel(o.hql,t)}});const Tn=(0,i.op)({sinh_:function(e){const t={x:(0,s.YT)(e,"x","sinh")};return a.T2.runKernel(o.J3C,t)}});const Sn=(0,i.op)({slice1d_:function(e,t,n){const r=(0,s.YT)(e,"x","slice1d");return d.vA(1===r.rank,()=>`slice1d expects a rank-1 tensor, but got a rank-${r.rank} tensor`),F(r,[t],[n])}});const Cn=(0,i.op)({slice2d_:function(e,t,n){const r=(0,s.YT)(e,"x","slice2d");return d.vA(2===r.rank,()=>`slice2d expects a rank-2 tensor, but got a rank-${r.rank} tensor`),F(r,t,n)}});const kn=(0,i.op)({slice3d_:function(e,t,n){const r=(0,s.YT)(e,"x","slice3d");return d.vA(3===r.rank,()=>`slice3d expects a rank-3 tensor, but got a rank-${r.rank} tensor`),F(r,t,n)}});const En=(0,i.op)({slice4d_:function(e,t,n){const r=(0,s.YT)(e,"x","slice4d");return d.vA(4===r.rank,()=>`slice4d expects a rank-4 tensor, but got a rank-${r.rank} tensor`),F(r,t,n)}});const $n=(0,i.op)({softmax_:function(e,t=-1){const n=(0,s.YT)(e,"logits","softmax","float32");if(-1===t&&(t=n.rank-1),t!==n.rank-1)throw Error(`Softmax along a non-last dimension is not yet supported. Logits was rank ${n.rank}
2 and dim was ${t}`);const r={logits:n},i={dim:t};return a.T2.runKernel(o.rFG,r,i)}});const Nn=(0,i.op)({fft_:function(e){(0,d.vA)("complex64"===e.dtype,()=>`The dtype for tf.spectral.fft() must be complex64 but got ${e.dtype}.`);const t={input:e};return a.T2.runKernel(o.rGP,t)}});const In=(0,i.op)({ifft_:function(e){(0,d.vA)("complex64"===e.dtype,()=>`The dtype for tf.spectral.ifft() must be complex64 but got ${e.dtype}.`);const t={input:e};return a.T2.runKernel(o.OAQ,t)}});const An=(0,i.op)({irfft_:function(e){const t=e.shape[e.shape.length-1],n=e.size/t;let r;if(t<=2){const a=(0,E.t)(e,[n,t]);r=In(a)}else{const a=[n,2*(t-1)],o=(0,E.t)(on(e),[n,t]),s=(0,E.t)(He(e),[n,t]),i=ln(F(o,[0,1],[n,t-2]),1),u=(0,_.l)(ln(F(s,[0,1],[n,t-2]),1),(0,Re.d)(-1)),c=A([o,i],1),l=A([s,u],1),p=(0,E.t)((0,Z.f)(c,l),[a[0],a[1]]);r=In(p)}if(r=on(r),3===e.rank&&0!==e.shape[0]){const t=r,n=e.shape[0];r=(0,E.t)(r,[n,r.shape[0]/n,r.shape[1]]),t.dispose()}return r}});const Rn=(0,i.op)({split_:function(e,t,n=0){const r={x:(0,s.YT)(e,"x","split")},i={numOrSizeSplits:t,axis:n};return a.T2.runKernel(o.Blb,r,i)}});const _n=(0,i.op)({rfft_:function(e,t){(0,d.vA)("float32"===e.dtype,()=>`The dtype for rfft() must be real value but got ${e.dtype}`);let n=e.shape[e.shape.length-1];const r=e.size/n;let a;if(null!=t&&t<n){const r=e.shape.map(e=>0),o=e.shape.map(e=>e);o[e.shape.length-1]=t,a=F(e,r,o),n=t}else if(null!=t&&t>n){const r=e.shape.map(e=>e);r[e.shape.length-1]=t-n,a=A([e,Ct(r)],e.shape.length-1),n=t}else a=e;const o=we(a),s=(0,E.t)((0,Z.f)(a,o),[r,n]),i=Nn(s),u=Math.floor(n/2)+1,c=on(i),l=He(i),p=Rn(c,[u,n-u],c.shape.length-1),h=Rn(l,[u,n-u],l.shape.length-1),f=a.shape.slice();return f[a.shape.length-1]=u,(0,E.t)((0,Z.f)(p[0],h[0]),f)}});const On=(0,i.op)({squaredDifference_:function(e,t){let n=(0,s.YT)(e,"a","squaredDifference"),r=(0,s.YT)(t,"b","squaredDifference");[n,r]=(0,p.h0)(n,r),(0,xe.assertAndGetBroadcastShape)(n.shape,r.shape);const i={a:n,b:r};return a.T2.runKernel(o.Ddj,i,{})}});const Fn=(0,i.op)({squeeze_:function(e,t){const n=(0,s.YT)(e,"x","squeeze","string_or_numeric");return(0,E.t)(n,(0,d.gx)(n.shape,t).newShape)}});const Dn=(0,i.op)({stack_:function(e,t=0){const n=(0,s.j1)(e,"tensors","stack","string_or_numeric");d.vA(n.length>=1,()=>"Pass at least one tensor to tf.stack"),n.length>0&&d.vA(t<=n[0].rank,()=>"Axis must be <= rank of the tensor");const r=n,i={axis:t};return a.T2.runKernel(o.mM$,r,i)}});var Ln=n(10700);const Mn=(0,i.op)({stridedSlice_:function(e,t,n,r,i=0,u=0,c=0,l=0,p=0){const h={x:(0,s.YT)(e,"x","stridedSlice","string_or_numeric")},d={begin:t,end:n,strides:r,beginMask:i,endMask:u,ellipsisMask:c,newAxisMask:l,shrinkAxisMask:p};return a.T2.runKernel(o.UcO,h,d)}});const Pn=(0,i.op)({tan_:function(e){const t={x:(0,s.YT)(e,"x","tan","float32")};return a.T2.runKernel(o.oFs,t)}});var Bn=n(74027),Vn=n(19171);function zn(e,t){(0,d.HO)(e);const n=(0,s.MZ)(e,t);if(1!==n.length)throw new Error("tensor1d() requires values to be a flat/TypedArray");return(0,Vn.Q)(e,null,n,t)}function Un(e,t,n){if((0,d.HO)(e),null!=t&&2!==t.length)throw new Error("tensor2d() requires shape to have two numbers");const r=(0,s.MZ)(e,n);if(2!==r.length&&1!==r.length)throw new Error("tensor2d() requires values to be number[][] or flat/TypedArray");if(1===r.length&&null==t)throw new Error("tensor2d() requires shape to be provided when `values` are a flat/TypedArray");return(0,Vn.Q)(e,t,r,n)}var Wn=n(42768);function Gn(e,t,n){if((0,d.HO)(e),null!=t&&4!==t.length)throw new Error("tensor4d() requires shape to have four numbers");const r=(0,s.MZ)(e,n);if(4!==r.length&&1!==r.length)throw new Error("tensor4d() requires values to be number[][][][] or flat/TypedArray");if(1===r.length&&null==t)throw new Error("tensor4d() requires shape to be provided when `values` are a flat array");return(0,Vn.Q)(e,t,r,n)}function jn(e,t,n){if((0,d.HO)(e),null!=t&&5!==t.length)throw new Error("tensor5d() requires shape to have five numbers");const r=(0,s.MZ)(e,n);if(5!==r.length&&1!==r.length)throw new Error("tensor5d() requires values to be number[][][][][] or flat/TypedArray");if(1===r.length&&null==t)throw new Error("tensor5d() requires shape to be provided when `values` are a flat array");return(0,Vn.Q)(e,t,r,n)}function Kn(e,t,n){if((0,d.HO)(e),null!=t&&6!==t.length)throw new Error("tensor6d() requires shape to have six numbers");const r=(0,s.MZ)(e,n);if(6!==r.length&&1!==r.length)throw new Error("tensor6d() requires values to be number[][][][][][] or flat/TypedArray");if(1===r.length&&null==t)throw new Error("tensor6d() requires shape to be provided when `values` are a flat array");return t=t||r,(0,Vn.Q)(e,t,r,n)}const Hn=(0,i.op)({topk_:function(e,t=1,n=!0){const r=(0,s.YT)(e,"x","topk");
2if(0===r.rank)throw new Error("topk() expects the input to be of rank 1 or higher");const i=r.shape[r.shape.length-1];if(t<0)throw new Error(`'k' passed to topk() must be >= 0 but got ${t}`);if(t>i)throw new Error(`'k' passed to topk() must be <= the last dimension (${i}) but got ${t}`);const u={x:r},c={k:t,sorted:n},[l,p]=a.T2.runKernel(o.TBb,u,c);return{values:l,indices:p}}});const Yn=(0,i.op)({truncatedNormal_:function(e,t=0,n=1,r,a){if(null!=r&&"bool"===r)throw new Error("Unsupported data type $ { dtype }");const o=new qt(t,n,r,!0,a),s=(0,j.r)(e,r);for(let e=0;e<s.values.length;e++)s.values[e]=o.nextValue();return s.toTensor()}});const Zn=(0,i.op)({unique_:function(e,t=0){const n=(0,s.YT)(e,"x","unique","string_or_numeric");(0,d.vA)(n.rank>0,()=>"The input tensor must be at least 1D");const r={x:n},i={axis:t},[u,c]=a.T2.runKernel(o.EwU,r,i);return{values:u,indices:c}}});const Xn=(0,i.op)({unsortedSegmentSum_:function(e,t,n){const r=(0,s.YT)(e,"x","unsortedSegmentSum"),i=(0,s.YT)(t,"segmentIds","unsortedSegmentSum","int32");(0,d.vA)((0,d.E6)(n),()=>"numSegments must be of dtype int");const u={x:r,segmentIds:i},c={numSegments:n};return a.T2.runKernel(o.pPe,u,c)}});const qn=(0,i.op)({unstack_:function(e,t=0){const n=(0,s.YT)(e,"x","unstack","string_or_numeric");d.vA(t>=-n.shape.length&&t<n.shape.length,()=>`Axis = ${t} is not in [-${n.shape.length}, ${n.shape.length})`);const r={value:n},i={axis:t};return a.T2.runKernel(o.dXR,r,i)}});function Qn(e,t){return yt(e,t,"right")}function Jn(e,t=!0,n,r){return a.T2.makeVariable(e,t,n,r)}var er=n(54411);const tr=async function(e){const t=(0,s.YT)(e,"condition","whereAsync","bool"),n=await t.data(),r=(0,er.Y)(t.shape,n);
2return e!==t&&t.dispose(),r};const nr=async function(e,t,n){const r=(0,s.YT)(e,"tensor","boolMask"),a=(0,s.YT)(t,"mask","boolMask","bool"),o=null==n?0:n,i=a.rank,u=r.shape;d.vA(i>0,()=>"mask cannot be scalar"),d.O3(u.slice(o,o+i),a.shape,"mask's shape must match the first K dimensions of tensor's shape,");let c=1;for(let e=o;e<o+i;e++)c*=u[e];const l=u.slice(0,o).concat([c],u.slice(o+i)),p=(0,E.t)(r,l),h=(0,E.t)(a,[-1]),f=await tr(h),m=Fn(f,[1]),g=Ge(p,m,o);return e!==r&&r.dispose(),t!==a&&a.dispose(),m.dispose(),p.dispose(),h.dispose(),f.dispose(),g};var rr=n(35287);const ar=(0,i.op)({transpose_:function(e,t,n){const r=(0,s.YT)(e,"x","transpose");if(null==t&&(t=r.shape.map((e,t)=>t).reverse()),d.vA(r.rank===t.length,()=>`Error in transpose: rank of input ${r.rank} must match length of perm ${t}.`),t.forEach(e=>{d.vA(e>=0&&e<r.rank,()=>"All entries in 'perm' must be between 0 and "+(r.rank-1)+` but got ${t}`)}),r.rank<=1)return r.clone();const i={x:r},u={perm:t};return"complex64"===r.dtype?(0,rr.DZ)(()=>{let e=on(r),t=He(r);return e=a.T2.runKernel(o.wx0,{x:e},u),t=a.T2.runKernel(o.wx0,{x:t},u),n&&(t=st(t)),(0,Z.f)(e,t)}):a.T2.runKernel(o.wx0,i,u)}});const or=(0,i.op)({movingAverage_:function(e,t,n,r,a=!0){const o=(0,s.YT)(e,"v","movingAverage"),i=(0,s.YT)(t,"x","movingAverage"),u=(0,s.YT)(n,"decay","movingAverage");(0,p.rt)(o,i),d.vA(d.r1(o.shape,i.shape),()=>"Shape mismatch in v and x");const c=(0,Re.d)(1),l=ct(c,u);let f=(0,_.l)(ct(i,o),l);if(a){d.vA(null!=r,()=>"When using zeroDebias: true, step is required.");const e=(0,s.YT)(r,"step","movingAverage");f=ye(f,ct(c,Ae(u,e)))}return h(o,f)}});var sr=n(26170);const ir=(0,i.op)({scatterND_:function(e,t,n){const r=(0,s.YT)(e,"indices","scatterND","int32"),i=(0,s.YT)(t,"updates","scatterND");sr.TT(i,r,n);const u={indices:r,updates:i},c={shape:n};return a.T2.runKernel(o.pJc,u,c)}});const ur=(0,i.op)({sparseToDense_:function(e,t,n,r=0){const i=(0,s.YT)(e,"sparseIndices","sparseToDense","int32"),u=(0,s.YT)(t,"sparseValues","sparseToDense","string_or_numeric"),c=(0,s.YT)(r,"defaultValue","sparseToDense",u.dtype);!function(e,t,n,r){if("int32"!==e.dtype)throw new Error(`tf.sparseToDense() expects the indices to be int32 type, but the dtype was ${e.dtype}.`);if(e.rank>2)throw new Error(`sparseIndices should be a scalar, vector, or matrix, but got shape ${e.shape}.`);const a=e.rank>0?e.shape[0]:1,o=e.rank>1?e.shape[1]:1;if(n.length!==o)throw new Error(`outputShape has incorrect number of elements:, ${n.length}, should be: ${o}.`);const s=t.size;if(0!==t.rank&&(1!==t.rank||s!==a))throw new Error(`sparseValues has incorrect shape ${t.shape}, should be [] or [${a}]`);if(t.dtype!==r.dtype)throw new Error("sparseValues.dtype must match defaultValues.dtype")}(i,u,n,c);const l={sparseIndices:i,sparseValues:u,defaultValue:c},p={outputShape:n};return a.T2.runKernel(o.jgd,l,p)}});const cr=(0,i.op)({gatherND_:function(e,t){const n=(0,s.YT)(t,"indices","gatherND","int32"),r={params:(0,s.YT)(e,"x","gatherND","string_or_numeric"),indices:n};return a.T2.runKernel(o.O4G,r)}});const lr=(0,i.op)({dropout_:function(e,t,n,r){const a=(0,s.YT)(e,"x","dropout");if(d.vA("float32"===a.dtype,()=>`x has to be a floating point tensor since it's going to be scaled, but got a ${a.dtype} tensor instead.`),d.vA(t>=0&&t<1,()=>`rate must be a float in the range [0, 1), but got ${t}.`),0===t)return e instanceof at.qY?a.clone():a;const o=function(e,t){if(null==t)return e.shape.slice();if(d.r1(e.shape,t))return t;if(e.shape.length===t.length){const n=[];for(let r=0;r<e.shape.length;r++)null==t[r]&&null!=e.shape[r]?n.push(e.shape[r]):n.push(t[r]);return n}return t}(a,n),i=1-t,u=ye(We(h(rn(o,0,1,"float32",r),i)),i);return(0,_.l)(a,u)}});function pr(e){return Math.floor(Math.pow(2,Math.ceil(Math.log(e)/Math.log(2))))}function hr(e,t,n){const r=1-e%2,a=new Float32Array(e);for(let o=0;o<e;++o){const s=2*Math.PI*o/(e+r-1);a[o]=t-n*Math.cos(s)}return zn(a,"float32")}const dr=async function(e,t,n=1){const r=(0,s.YT)(e,"predictions","inTopK"),a=(0,s.YT)(t,"targets","inTopK");(0,d.vA)(r.rank>1,()=>`inTopK() expects the predictions to be of rank 2 or higher, but got ${r.rank}`),(0,d.vA)(r.rank-1===a.rank,()=>`predictions rank should be 1 larger than targets rank, but got predictions rank ${r.rank} and targets rank ${a.rank}`),(0,d.O3)(r.shape.slice(0,r.shape.length-1),a.shape,"predictions's shape should be align with the targets' shape, except the last dimension.");const o=r.shape[r.shape.length-1];(0,d.vA)(n>0&&n<=o,()=>`'k' passed to inTopK() must be > 0 && <= the predictions last dimension (${o}), but got ${n}`);const i=await r.data(),u=await a.data(),[c,l]=[i.length/o,o],p=(0,d.ce)("bool",c);for(let e=0;e<c;e++){const t=e*l,r=i.subarray(t,t+l),a=[];for(let e=0;e<r.length;e++)a.push({value:r[e],index:e});a.sort((e,t)=>
2t.value-e.value),p[e]=0;for(let t=0;t<n;t++)if(a[t].index===u[e]){p[e]=1;break}}return e!==r&&r.dispose(),t!==a&&a.dispose(),(0,Bn.O)(p,a.shape,"bool")};const fr=(0,i.op)({conv2DBackpropFilter_:function(e,t,n,r,s,i="NHWC",u){let c=e;3===e.rank&&(c=(0,E.t)(e,[1,e.shape[0],e.shape[1],e.shape[2]]));let l=t;3===l.rank&&(l=(0,E.t)(t,[1,t.shape[0],t.shape[1],t.shape[2]])),d.vA(4===c.rank,()=>`Error in conv2dDerFilter: input must be rank 4, but got shape ${c.shape}.`),d.vA(4===l.rank,()=>`Error in conv2dDerFilter: dy must be rank 4, but got shape ${l.shape}.`),d.vA(4===n.length,()=>`Error in conv2dDerFilter: filterShape must be length 4, but got ${n}.`);const p="NHWC"===i?c.shape[3]:c.shape[1],h="NHWC"===i?l.shape[3]:l.shape[1];d.vA(p===n[2],()=>`Error in conv2dDerFilter: depth of input ${p}) must match input depth in filter (${n[2]}.`),d.vA(h===n[3],()=>`Error in conv2dDerFilter: depth of dy (${h}) must match output depth for filter (${n[3]}).`),k.s_("conv2dDerFilter",s,u);const f={x:c,dy:l},m={strides:r,pad:s,dataFormat:i,dimRoundingMode:u,filterShape:n};return a.T2.runKernel(o.rFm,f,m)}});var mr=n(68646);const gr=(0,i.op)({fusedConv2d_:function({x:e,filter:t,strides:n,pad:r,dataFormat:i="NHWC",dilations:u=[1,1],dimRoundingMode:c,bias:l,activation:f="linear",preluActivationWeights:m,leakyreluAlpha:g}){if(f=f||"linear",!1===(0,mr.zE)(a.T2.state.gradientDepth,f)){d.vA("NHWC"===i,()=>`Error in fused conv2d: got dataFormat of ${i} but only NHWC is currently supported for the case of gradient depth is 0 and the activation is not linear.`);let a=ee(e,t,n,r,i,u,c);return null!=l&&(a=h(a,l)),(0,mr.f2)(a,f,m,g)}const y=(0,s.YT)(e,"x","conv2d","float32"),x=(0,s.YT)(t,"filter","conv2d","float32");let b=y,v=!1;3===y.rank&&(v=!0,b=(0,E.t)(y,[1,y.shape[0],y.shape[1],y.shape[2]])),d.vA(4===b.rank,()=>`Error in fused conv2d: input must be rank 4, but got rank ${b.rank}.`),d.vA(4===x.rank,()=>`Error in fused conv2d: filter must be rank 4, but got rank ${x.rank}.`),k.s_("fused conv2d",r,c);const w="NHWC"===i?b.shape[3]:b.shape[1];d.vA(x.shape[2]===w,()=>`Error in conv2d: depth of input (${w}) must match input depth for filter ${x.shape[2]}.`),d.vA(k.G0(n,u),()=>`Error in conv2D: Either strides or dilations must be 1. Got strides ${n} and dilations '${u}'`);const T=k.uf(b.shape,x.shape,n,u,r,c);let S,C;if(null!=l&&(S=(0,s.YT)(l,"bias","fused conv2d"),[S]=(0,p.h0)(S,y),"NHWC"===i?xe.assertAndGetBroadcastShape(T.outShape,S.shape):(d.vA(S.shape.length<=1,()=>`Error in fused conv2d: only supports scalar or 1-D Tensor bias for NCHW format but got the bias of rank-${S.shape.length}.`),d.vA(0===S.shape.length||S.shape[0]===T.outChannels||1===S.shape[0],()=>`Error in fused conv2d: bias shape (${S.shape}) is not compatible with the number of output channels (${T.outChannels})`))),null!=m){const e=m.shape;if(d.vA(e.length<=1||3===e.length,()=>`Error in fused conv2d: only supports scalar, 1-D Tensor or 3-D Tensor PReLU activation weights but got a tensor of rank-${e.length}
2.`),1===e.length)d.vA(1===e[0]||e[0]===T.outChannels,()=>`Error in fused conv2d: PReLU activation weights (${e}) is not compatible with the number of output channels (${T.outChannels}).`);else if(3===e.length)try{xe.assertAndGetBroadcastShape(e,T.outShape)}catch(t){const n=`Error in fused conv2d: PReLU activation weights (${e}) is not compatible with the output shape of the conv2d (${T.outShape}).`;throw Error(n)}C=(0,s.YT)(m,"prelu weights","fused conv2d")}const $=(e,t)=>{d.vA("NHWC"===i,()=>`Error in gradient of fused conv2D: got dataFormat of ${i} but only NHWC is currently supported.`);const[a,o,s,c]=t,l=(0,mr.XB)(e,s,f);d.vA(k.Dh(u),()=>`Error in gradient of fused conv2D: dilation rates greater than 1 are not yet supported in gradients. Got dilations '${u}'`);const p=[ne(o.shape,l,a,n,r),fr(o,l,a.shape,n,r)];if(null!=c){const e=(0,mr.Do)(c,l);p.push(e)}return p},N={x:b,filter:x,bias:S,preluActivationWeights:C},I={strides:n,pad:r,dataFormat:i,dilations:u,dimRoundingMode:c,activation:f,leakyreluAlpha:g};if(null==l){const e=ot((e,t,n)=>{let r=a.T2.runKernel(o.aAr,N,I);return n([t,e,r]),v&&(r=(0,E.t)(r,[r.shape[1],r.shape[2],r.shape[3]])),{value:r,gradFunc:$}});return e(b,x)}{const e=ot((e,t,n,r)=>{let s=a.T2.runKernel(o.aAr,N,I);return r([t,e,s,n]),v&&(s=(0,E.t)(s,[s.shape[1],s.shape[2],s.shape[3]])),{value:s,gradFunc:$}});return e(b,x,S)}}});const yr=(0,i.op)({depthwiseConv2dNativeBackpropFilter_:function(e,t,n,r,s,i=[1,1],u){let c=e;3===e.rank&&(c=(0,E.t)(e,[1,e.shape[0],e.shape[1],e.shape[2]]));let l=t;3===l.rank&&(l=(0,E.t)(t,[1,t.shape[0],t.shape[1],t.shape[2]]));const p={x:c,dy:l},h={strides:r,pad:s,dimRoundingMode:u,dilations:i,filterShape:n};return a.T2.runKernel(o.X$8,p,h)}});const xr=(0,i.op)({depthwiseConv2dNativeBackpropInput_:function(e,t,n,r,s,i=[1,1],u){let c=t,l=!1;3===t.rank&&(l=!0,c=(0,E.t)(t,[1,t.shape[0],t.shape[1],t.shape[2]]));const p={dy:c,filter:n},h={strides:r,pad:s,dimRoundingMode:u,dilations:i,inputShape:e},d=a.T2.runKernel(o.nVu,p,h);return l?(0,E.t)(d,[d.shape[1],d.shape[2],d.shape[3]]):d}});const br=(0,i.op)({fusedDepthwiseConv2d_:function({x:e,filter:t,strides:n,pad:r,dataFormat:i="NHWC",dilations:u=[1,1],dimRoundingMode:c,bias:l,activation:f="linear",preluActivationWeights:m,leakyreluAlpha:g}){if(!1===(0,mr.zE)(a.T2.state.gradientDepth,f)){let a=de(e,t,n,r,i,u,c);return null!=l&&(a=h(a,l)),(0,mr.f2)(a,f,m,g)}const y=(0,s.YT)(e,"x","depthwiseConv2d","float32"),x=(0,s.YT)(t,"filter","depthwiseConv2d","float32");let b=y,v=!1;3===y.rank&&(v=!0,b=(0,E.t)(y,[1,y.shape[0],y.shape[1],y.shape[2]])),d.vA(4===b.rank,()=>`Error in fused depthwiseConv2d: input must be rank 4, but got rank ${b.rank}.`),d.vA(4===x.rank,()=>`Error in fused depthwiseConv2d: filter must be rank 4, but got rank ${x.rank}.`),d.vA(b.shape[3]===x.shape[2],()=>`Error in fused depthwiseConv2d: number of input channels (${b.shape[3]}) must match the inChannels dimension in filter ${x.shape[2]}.`),null==u&&(u=[1,1]),d.vA(k.G0(n,u),()=>`Error in fused depthwiseConv2d: Either strides or dilations must be 1. Got strides ${n} and dilations '${u}'`),k.s_("fused depthwiseConv2d",r,c);const w=k.uf(b.shape,x.shape,n,u,r,c,!0);let T,S;null!=l&&(T=(0,s.YT)(l,"bias","fused conv2d"),[T]=(0,p.h0)(T,y),xe.assertAndGetBroadcastShape(w.outShape,T.shape)),null!=m&&(S=(0,s.YT)(m,"prelu weights","fused depthwiseConv2d"));const C=(e,t)=>{d.vA(k.Dh(u),()=>`Error in gradient of fused depthwiseConv2d: dilation rates greater than 1 are not yet supported. Got dilations '${u}'`);const[a,o,s,i]=t,l=(0,mr.XB)(e,s,f),p=xr(o.shape,l,a,n,r,u,c),h=yr(o,l,a.shape,n,r,u,c);if(null!=i){return[p,h,(0,mr.Do)(T,l)]}return[p,h]},$={x:b,filter:x,bias:T,preluActivationWeights:S},N={strides:n,pad:r,dataFormat:i,dilations:u,dimRoundingMode:c,activation:f,leakyreluAlpha:g};if(null==l){const e=ot((e,t,n)=>{let r=a.T2.runKernel(o.T7M,$,N);return n([t,e,r]),v&&(r=(0,E.t)(r,[r.shape[1],r.shape[2],r.shape[3]])),{value:r,gradFunc:C}});return e(b,x)}{const e=ot((e,t,n,r)=>{let s=a.T2.runKernel(o.T7M,$,N);return r([t,e,s,n]),v&&(s=(0,E.t)(s,[s.shape[1],s.shape[2],s.shape[3]])),{value:s,gradFunc:C}});return e(b,x,T)}}});const vr=(0,i.op)({fusedMatMul_:function({a:e,b:t,transposeA:n=!1,transposeB:r=!1,bias:i,activation:u="linear",preluActivationWeights:c,leakyreluAlpha:l=.2}){if(!1===(0,mr.zE)(a.T2.state.gradientDepth,u)){let a=R(e,t,n,r);return null!=i&&(a=h(a,i)),(0,mr.f2)(a,u,c,l)}let f=(0,s.YT)(e,"a","fused matMul"),m=(0,s.YT)(t,"b","fused matMul");[f,m]=(0,p.h0)(f,m);const g=n?f.shape[f.rank-2]:f.shape[f.rank-1],y=r?m.shape[m.rank-1]:m.shape[m.rank-2],x=n?f.shape[f.rank-1]:f.shape[f.rank-2],b=r?m.shape[m.rank-2]:m.shape[m.rank-1],v=f.shape.slice(0,-2),w=m.shape.slice(0,-2),T=d.Ze(v),S=d.Ze(w);d.vA(g===y,()=>`Error in fused matMul: inner shapes (${g}) and (${y}) of Tensors with shapes ${f.shape} and ${m.shape} and transposeA=${n} and transposeB=${r} must match.`);const C=xe.assertAndGetBroadcastShape(f.shape.slice(0,-2),m.shape.slice(0,-2)).c
2oncat([x,b]),k=n?(0,E.t)(f,[T,g,x]):(0,E.t)(f,[T,x,g]),$=r?(0,E.t)(m,[S,b,y]):(0,E.t)(m,[S,y,b]);let N,I;null!=i&&(N=(0,s.YT)(i,"bias","fused matMul"),[N]=(0,p.h0)(N,f),xe.assertAndGetBroadcastShape(C,N.shape)),null!=c&&(I=(0,s.YT)(c,"prelu weights","fused matMul"));const A=(e,t)=>{const[a,o,s,c]=t,l=(0,mr.XB)((0,E.t)(e,s.shape),s,u);let p,h;if(n||r?!n&&r?(p=R(l,o,!1,!1),h=R(l,a,!0,!1)):n&&!r?(p=R(o,l,!1,!0),h=R(a,l,!1,!1)):(p=R(o,l,!0,!0),h=R(l,a,!0,!0)):(p=R(l,o,!1,!0),h=R(a,l,!0,!1)),null!=i){return[p,h,(0,mr.Do)(c,l)]}return[p,h]},_={a:k,b:$,bias:N,preluActivationWeights:I},O={transposeA:n,transposeB:r,activation:u,leakyreluAlpha:l};if(null==i){const e=ot((e,t,n)=>{const r=a.T2.runKernel(o.Dr,_,O);return n([e,t,r]),{value:(0,E.t)(r,C),gradFunc:A}});return e(k,$)}{const e=ot((e,t,n,r)=>{const s=a.T2.runKernel(o.Dr,_,O);return r([e,t,s,n]),{value:(0,E.t)(s,C),gradFunc:A}});return e(k,$,N)}}});const wr=(0,i.op)({hammingWindow_:function(e){return hr(e,.54,.46)}});const Tr=(0,i.op)({hannWindow_:function(e){return hr(e,.5,.5)}});const Sr=(0,i.op)({frame_:function(e,t,n,r=!1,a=0){let o=0;const s=[];for(;o+t<=e.size;)s.push(F(e,o,t)),o+=n;if(r)for(;o<e.size;){const r=o+t-e.size,i=A([F(e,o,t-r),H([r],a)]);s.push(i),o+=n}return 0===s.length?Un([],[0,t]):(0,E.t)(A(s),[s.length,t])}});const Cr=(0,i.op)({stft_:function(e,t,n,r,a=Tr){null==r&&(r=pr(t));const o=Sr(e,t,n),s=(0,_.l)(o,a(t));return _n(s,r)}});const kr=(0,i.op)({cropAndResize_:function(e,t,n,r,i="bilinear",u=0){const c=(0,s.YT)(e,"image","cropAndResize"),l=(0,s.YT)(t,"boxes","cropAndResize","float32"),p=(0,s.YT)(n,"boxInd","cropAndResize","int32"),h=l.shape[0];d.vA(4===c.rank,()=>`Error in cropAndResize: image must be rank 4,but got rank ${c.rank}.`),d.vA(2===l.rank&&4===l.shape[1],()=>`Error in cropAndResize: boxes must be have size [${h},4] but had shape ${l.shape}.`),d.vA(1===p.rank&&p.shape[0]===h,()=>`Error in cropAndResize: boxInd must be have size [${h}] but had shape ${l.shape}.`),d.vA(2===r.length,()=>`Error in cropAndResize: cropSize must be of length 2, but got length ${r.length}.`),d.vA(r[0]>=1&&r[1]>=1,()=>`cropSize must be atleast [1,1], but was ${r}`),d.vA("bilinear"===i||"nearest"===i,()=>`method must be bilinear or nearest, but was ${i}`);const f={image:c,boxes:l,boxInd:p},m={method:i,extrapolationValue:u,cropSize:r};return a.T2.runKernel(o.MRQ,f,m)}});const Er=(0,i.op)({flipLeftRight_:function(e){const t=(0,s.YT)(e,"image","flipLeftRight","float32");d.vA(4===t.rank,()=>`Error in flipLeftRight: image must be rank 4,but got rank ${t.rank}.`);const n={image:t};return a.T2.runKernel(o.BxF,n,{})}});const $r=(0,i.op)({grayscaleToRGB_:function(e){const t=(0,s.YT)(e,"image","grayscaleToRGB"),n=t.rank-1,r=t.shape[n];d.vA(t.rank>=2,()=>`Error in grayscaleToRGB: images must be at least rank 2, but got rank ${t.rank}.`),d.vA(1===r,()=>`Error in grayscaleToRGB: last dimension of a grayscale image should be size 1, but got size ${r}.`);const a=new Array(t.rank);return a.fill(1,0,n),a[n]=3,ze(t,a)}});const Nr=(0,i.op)({rotateWithOffset_:function(e,t,n=0,r=.5){const i=(0,s.YT)(e,"image","rotateWithOffset","float32");d.vA(4===i.rank,()=>`Error in rotateWithOffset: image must be rank 4,but got rank ${i.rank}.`);const u={image:i},c={radians:t,fillValue:n,center:r};return a.T2.runKernel(o.BK4,u,c)}});function Ir(e,t,n,r,a,o){null==r&&(r=.5),null==a&&(a=Number.NEGATIVE_INFINITY),null==o&&(o=0);const s=e.shape[0];return n=Math.min(n,s),d.vA(0<=r&&r<=1,()=>`iouThreshold must be in [0, 1], but was '${r}'`),d.vA(2===e.rank,()=>`boxes must be a 2D tensor, but was of rank '${e.rank}'`),d.vA(4===e.shape[1],()=>`boxes must have 4 columns, but 2nd dimension was ${e.shape[1]}`),d.vA(1===t.rank,()=>"scores must be a 1D tensor"),d.vA(t.shape[0]===s,()=>`scores has incompatible shape with boxes. Expected ${s}, but was ${t.shape[0]}`),d.vA(0<=o&&o<=1,()=>`softNmsSigma must be in [0, 1], but was '${o}'`),{maxOutputSize:n,iouThreshold:r,scoreThreshold:a,softNmsSigma:o}}const Ar=(0,i.op)({nonMaxSuppression_:function(e,t,n,r=.5,i=Number.NEGATIVE_INFINITY){const u=(0,s.YT)(e,"boxes","nonMaxSuppression","float32"),c=(0,s.YT)(t,"scores","nonMaxSuppression","float32"),l=Ir(u,c,n,r,i),p={maxOutputSize:n=l.maxOutputSize,iouThreshold:r=l.iouThreshold,scoreThreshold:i=l.scoreThreshold};return a.T2.runKernel(o.SDM,{boxes:u,scores:c}
2,p)}});var Rr=n(43303);const _r=async function(e,t,n,r=.5,a=Number.NEGATIVE_INFINITY){const o=(0,s.YT)(e,"boxes","nonMaxSuppressionAsync"),i=(0,s.YT)(t,"scores","nonMaxSuppressionAsync"),u=Ir(o,i,n,r,a);n=u.maxOutputSize,r=u.iouThreshold,a=u.scoreThreshold;const c=await Promise.all([o.data(),i.data()]),l=c[0],p=c[1],{selectedIndices:h}=(0,Rr.c7)(l,p,n,r,a);return o!==e&&o.dispose(),i!==t&&i.dispose(),zn(h,"int32")};const Or=(0,i.op)({nonMaxSuppressionWithScore_:function(e,t,n,r=.5,i=Number.NEGATIVE_INFINITY,u=0){const c=(0,s.YT)(e,"boxes","nonMaxSuppression"),l=(0,s.YT)(t,"scores","nonMaxSuppression"),p=Ir(c,l,n,r,i,u),h={boxes:c,scores:l},d={maxOutputSize:n=p.maxOutputSize,iouThreshold:r=p.iouThreshold,scoreThreshold:i=p.scoreThreshold,softNmsSigma:u=p.softNmsSigma},f=a.T2.runKernel(o.e0f,h,d);return{selectedIndices:f[0],selectedScores:f[1]}}});const Fr=async function(e,t,n,r=.5,a=Number.NEGATIVE_INFINITY,o=0){const i=(0,s.YT)(e,"boxes","nonMaxSuppressionAsync"),u=(0,s.YT)(t,"scores","nonMaxSuppressionAsync"),c=Ir(i,u,n,r,a,o);n=c.maxOutputSize,r=c.iouThreshold,a=c.scoreThreshold,o=c.softNmsSigma;const l=await Promise.all([i.data(),u.data()]),p=l[0],h=l[1],{selectedIndices:d,selectedScores:f}=(0,Rr.ut)(p,h,n,r,a,o);return i!==e&&i.dispose(),u!==t&&u.dispose(),{selectedIndices:zn(d,"int32"),selectedScores:zn(f)}};const Dr=(0,i.op)({nonMaxSuppressionPadded_:function(e,t,n,r=.5,i=Number.NEGATIVE_INFINITY,u=!1){const c=(0,s.YT)(e,"boxes","nonMaxSuppression"),l=(0,s.YT)(t,"scores","nonMaxSuppression"),p=Ir(c,l,n,r,i,null),h={boxes:c,scores:l},d={maxOutputSize:p.maxOutputSize,iouThreshold:p.iouThreshold,scoreThreshold:p.scoreThreshold,padToMaxOutputSize:u},f=a.T2.runKernel(o.Zl4,h,d);return{selectedIndices:f[0],validOutputs:f[1]}}});const Lr=async function(e,t,n,r=.5,a=Number.NEGATIVE_INFINITY,o=!1){const i=(0,s.YT)(e,"boxes","nonMaxSuppressionAsync"),u=(0,s.YT)(t,"scores","nonMaxSuppressionAsync"),c=Ir(i,u,n,r,a,null),l=c.maxOutputSize,p=c.iouThreshold,h=c.scoreThreshold,[d,f]=await Promise.all([i.data(),u.data()]),{selectedIndices:m,validOutputs:g}=(0,Rr.ZS)(d,f,l,p,h,o);return i!==e&&i.dispose(),u!==t&&u.dispose(),{selectedIndices:zn(m,"int32"),validOutputs:(0,Re.d)(g,"int32")}};const Mr=(0,i.op)({resizeBilinear_:function(e,t,n=!1,r=!1){const i=(0,s.YT)(e,"images","resizeBilinear");d.vA(3===i.rank||4===i.rank,()=>`Error in resizeBilinear: x must be rank 3 or 4, but got rank ${i.rank}.`),d.vA(2===t.length,()=>`Error in resizeBilinear: new shape must 2D, but got shape ${t}.`),d.vA(!1===r||!1===n,()=>"Error in resizeBilinear: If halfPixelCenters is true, alignCorners must be false.");let u=i,c=!1;3===i.rank&&(c=!0,u=(0,E.t)(i,[1,i.shape[0],i.shape[1],i.shape[2]]));const[]=t,l={images:u},p={alignCorners:n,halfPixelCenters:r,size:t},h=a.T2.runKernel(o.hgw,l,p);return c?(0,E.t)(h,[h.shape[1],h.shape[2],h.shape[3]]):h}});const Pr=(0,i.op)({resizeNearestNeighbor_:function(e,t,n=!1,r=!1){const i=(0,s.YT)(e,"images","resizeNearestNeighbor");d.vA(3===i.rank||4===i.rank,()=>`Error in resizeNearestNeighbor: x must be rank 3 or 4, but got rank ${i.rank}.`),d.vA(2===t.length,()=>`Error in resizeNearestNeighbor: new shape must 2D, but got shape ${t}.`),d.vA("float32"===i.dtype||"int32"===i.dtype,()=>"`images` must have `int32` or `float32` as dtype"),d.vA(!1===r||!1===n,()=>"Error in resizeNearestNeighbor: If halfPixelCenters is true, alignCorners must be false.");let u=i,c=!1;3===i.rank&&(c=!0,u=(0,E.t)(i,[1,i.shape[0],i.shape[1],i.shape[2]]));const[]=t,l={images:u},p={alignCorners:n,halfPixelCenters:r,size:t},h=a.T2.runKernel(o.jOE,l,p);return c?(0,E.t)(h,[h.shape[1],h.shape[2],h.shape[3]]):h}});const Br=(0,i.op)({threshold_:function(e,t="binary",n=!1,r=.5){const a=(0,s.YT)(e,"image","threshold"),o=a.shape[0]*a.shape[1];let i,u,c,l,p=(0,_.l)(zn([r]),255);if(d.vA(3===a.rank,()=>`Error in threshold: image must be rank 3,but got rank ${a.rank}.`),d.vA(3===a.shape[2]||1===a.shape[2],()=>`Error in threshold: image color channel must be equal to 3 or 1but got ${a.shape[2]}.`),d.vA("int32"===a.dtype||"float32"===a.dtype,()=>`Error in dtype: image dtype must be int32 or float32,but got dtype ${a.dtype}.`),d.vA("otsu"===t||"binary"===t,()=>`Method must be binary or otsu, but was ${t}`),3===a.shape[2]){[i,u,c]=Rn(a,[1,1,1],-1);const e=(0,_.l)(i,.2989),t=(0,_.l)(u,.587),n=(0,_.l)(c,.114);l=h(h(e,t),n)}else l=e;if("otsu"===t){p=function(e,t){let n,r,a,o,s,i,u=zn([-1]),c=zn([0]),l=zn([0]);for(let p=0;p<e.size-1;p++){n=F(e,0,p+1),r=F(e,p+1),s=ye((0,Fe.c)(n),t),i=ye((0,Fe.c)(r),t);const d=(0,Fe.c)((0,_.l)(n,an(0,n.size)));a=ye(d,(0,Fe.c)(n));const f=H(r.shape,n.size),m=h(an(0,r.size),f),g=(0,_.l)(r,m);o=ye((0,Fe.c)(g),(0,Fe.c)(r));const y=ct(a,o),x=ct(a,o),b=(0,_.l)(s,i);l=(0,_.l)((0,_.l)(b,y),x);const v=je(l,c);c=ve(v,l,c),u=ve(v,zn([p]),u)}return u}(U((0,C.w)(mn(l),"int32"),(0,Bn.O)([]),256),o)}const f=n?Je(l,p):je(l,p);return(0,C.w)((0,_.l)(f,255),"int32")}});const Vr=(0,i.op)({transform_:function(e,t,n="nearest",r="constant",i=0,u){const c=(0,s.YT)(e,"image","transform","float32"),l=(0,s.YT)(t,"transforms","transform","float32");d.vA(4===c.rank,()=>`Error in transform: image must be rank 4,but got rank ${c.rank}.`),d.vA(2===l.rank&&(l.shape[0]===c.shape[0]||1===l.shape[0])&&8===l.shape[1],()=>"Error in transform: Input transform should be batch x 8 or 1 x 8"),d.vA(null==u||2===u.length,()=>`Error in transform: outputShape must be [height, width] or null, but got ${u}.`);const p={image:c,transforms:l},h={interpolation:n,fillMode:r,fillValue:i,outputShape:u};return a.T2.runKernel(o.dLy,p,h)}});const zr=(0,i.op)({bandPart_:function(e,t,n){(0,d.vA)(t%1==0,()=>`bandPart(): numLower must be an integer, got ${t}.`),(0,d.vA)(n%1==0,()=>`bandPart(): numUpper must be an integer, got ${n}.`);const r=(0,s.YT)(e,"a","bandPart");(0,d.vA)(r.rank>=2,()=>`bandPart(): Rank must be at least 2, got ${r.rank}.`);const a=r.shape,[o,i]=r.shape.slice(-2);if(!(t<=o))throw new Error(`bandPart(): numLower (${t}) must not be greater than the number of rows (${o}).`);if(!(n<=i))throw new Error(`bandPart(): numUpper (${n}) must not be greater than the number of columns (${i}).`);t<0&&(t=o),n<0&&(n=i);const u=(0,E.t)(an(0,o,1,"int32"),[-1,1]),c=an(0,i,1,"int32"),l=ct(u,c),p=ht(Je(l,(0,Re.d)(+t,"int32")),Ke(l,(0,Re.d)(-n,"int32"))),h=Ct([o,i],r.dtype);return(0,E.t)(Dn(qn((0,E.t)(r,[-1,o,i])).map(e=>ve(p,e,h))),a)}});const Ur=(0,i.op)({gramSchmidt_:function(e){let t;if(Array.isArray(e)){t=!1,(0,d.vA)(null!=e&&e.length>0,()=>"Gram-Schmidt process: input must not be null, undefined, or empty");const n=e[0].shape[0];for(let t=1;t<e.length;++t)(0,d.vA)(e[t].shape[0]===n,()=>
2`Gram-Schmidt: Non-unique lengths found in the input vectors: (${e[t].shape[0]} vs. ${n})`)}else t=!0,e=Rn(e,e.shape[0],0).map(e=>Fn(e,[0]));(0,d.vA)(e.length<=e[0].shape[0],()=>`Gram-Schmidt: Number of vectors (${e.length}) exceeds number of dimensions (${e[0].shape[0]}).`);const n=[],r=e;for(let t=0;t<e.length;++t)n.push(a.T2.tidy(()=>{let e=r[t];if(t>0)for(let r=0;r<t;++r){const t=(0,_.l)((0,Fe.c)((0,_.l)(n[r],e)),n[r]);e=ct(e,t)}return ye(e,Le(e,"euclidean"))}));return t?Dn(n,0):n}});function Wr(e,t=!1){return a.T2.tidy(()=>{(0,d.vA)(2===e.shape.length,()=>`qr2d() requires a 2D Tensor, but got a ${e.shape.length}D Tensor.`);const n=e.shape[0],r=e.shape[1];let o=Ue(n),s=(0,I.o)(e);const i=Un([[1]],[1,1]);let u=(0,I.o)(i);const c=n>=r?r:n;for(let e=0;e<c;++e){const t=s,c=u,l=o;[u,s,o]=a.T2.tidy(()=>{const t=F(s,[e,e],[n-e,1]),a=Le(t),c=F(s,[e,e],[1,1]),l=ve(je(c,0),Un([[-1]]),Un([[1]])),p=ct(c,(0,_.l)(l,a)),h=ye(t,p);u=1===h.shape[0]?(0,I.o)(i):A([i,F(h,[1,0],[h.shape[0]-1,h.shape[1]])],0);const d=st(ye(R(l,p),a)),f=F(s,[e,0],[n-e,r]),m=(0,_.l)(d,u),g=ar(u);if(0===e)s=ct(f,R(m,R(g,f)));else{const t=ct(f,R(m,R(g,f)));s=A([F(s,[0,0],[e,r]),t],0)}const y=ar(m),x=F(o,[0,e],[n,o.shape[1]-e]);if(0===e)o=ct(x,R(R(x,u),y));else{const t=ct(x,R(R(x,u),y));o=A([F(o,[0,0],[n,e]),t],1)}return[u,s,o]}),(0,rr.AS)([t,c,l])}return!t&&n>r&&(o=F(o,[0,0],[n,r]),s=F(s,[0,0],[r,r])),[o,s]})}const Gr=(0,i.op)({qr_:function(e,t=!1){if((0,d.vA)(e.rank>=2,()=>`qr() requires input tensor to have a rank >= 2, but got rank ${e.rank}`),2===e.rank)return Wr(e,t);{const n=e.shape.slice(0,e.shape.length-2).reduce((e,t)=>e*t),r=qn((0,E.t)(e,[n,e.shape[e.shape.length-2],e.shape[e.shape.length-1]]),0),a=[],o=[];r.forEach(e=>{const[n,r]=Wr(e,t);a.push(n),o.push(r)});return[(0,E.t)(Dn(a,0),e.shape),(0,E.t)(Dn(o,0),e.shape)]}}});var jr;!function(e){e[e.NONE=0]="NONE",e[e.MEAN=1]="MEAN",e[e.SUM=2]="SUM",e[e.SUM_BY_NONZERO_WEIGHTS=3]="SUM_BY_NONZERO_WEIGHTS"}(jr||(jr={}));const Kr=(0,i.op)({computeWeightedLoss_:function(e,t,n=jr.SUM_BY_NONZERO_WEIGHTS){const r=(0,s.YT)(e,"losses","computeWeightedLoss");let a=null;null!=t&&(a=(0,s.YT)(t,"weights","computeWeightedLoss"));const o=null==a?r:(0,_.l)(r,a);if(n===jr.NONE)return o;if(n===jr.SUM)return(0,Fe.c)(o);if(n===jr.MEAN){if(null==a)return St(o);{const e=r.size/a.size,t=ye((0,Fe.c)(o),(0,Fe.c)(a));return e>1?ye(t,(0,Re.d)(e)):t}}if(n===jr.SUM_BY_NONZERO_WEIGHTS){if(null==a)return ye((0,Fe.c)(o),(0,Re.d)(r.size));{const e=(0,_.l)(a,kt(r.shape)),t=(0,C.w)((0,Fe.c)(Ot(e,(0,Re.d)(0))),"float32");return ye((0,Fe.c)(o),t)}}throw Error(`Unknown reduction: ${n}`)}});const Hr=(0,i.op)({absoluteDifference_:function(e,t,n,r=jr.SUM_BY_NONZERO_WEIGHTS){const a=(0,s.YT)(e,"labels","absoluteDifference"),o=(0,s.YT)(t,"predictions","absoluteDifference");let i=null;null!=n&&(i=(0,s.YT)(n,"weights","absoluteDifference")),(0,d.O3)(a.shape,o.shape,"Error in absoluteDifference: ");const c=u(ct(a,o));return Kr(c,i,r)}});const Yr=(0,i.op)({cosineDistance_:function(e,t,n,r,a=jr.SUM_BY_NONZERO_WEIGHTS){const o=(0,s.YT)(e,"labels","cosineDistance"),i=(0,s.YT)(t,"predictions","cosineDistance");let u=null;null!=r&&(u=(0,s.YT)(r,"weights","cosineDistance")),(0,d.O3)(o.shape,i.shape,"Error in cosineDistance: ");const c=(0,Re.d)(1),l=ct(c,(0,Fe.c)((0,_.l)(o,i),n,!0));return Kr(l,u,a)}});const Zr=(0,i.op)({hingeLoss_:function(e,t,n,r=jr.SUM_BY_NONZERO_WEIGHTS){let a=(0,s.YT)(e,"labels","hingeLoss");const o=(0,s.YT)(t,"predictions","hingeLoss");let i=null;null!=n&&(i=(0,s.YT)(n,"weights","hingeLoss")),(0,d.O3)(a.shape,o.shape,"Error in hingeLoss: ");const u=(0,Re.d)(1);a=ct((0,_.l)((0,Re.d)(2),a),u);const c=(0,un.V)(ct(u,(0,_.l)(a,o)));return Kr(c,i,r)}});const Xr=(0,i.op)({huberLoss_:function(e,t,n,r=1,a=jr.SUM_BY_NONZERO_WEIGHTS){const o=(0,s.YT)(e,"labels","huberLoss"),i=(0,s.YT)(t,"predictions","huberLoss");let c=null;null!=n&&(c=(0,s.YT)(n,"weights","huberLoss")),(0,d.O3)(o.shape,i.shape,"Error in huberLoss: ");const l=(0,Re.d)(r),p=u(ct(i,o)),f=$t(p,l),m=ct(p,f),g=h((0,_.l)((0,Re.d)(.5),Oe(f)),(0,_.l)(l,m));return Kr(g,c,a)}});const qr=(0,i.op)({logLoss_:function(e,t,n,r=1e-7,a=jr.SUM_BY_NONZERO_WEIGHTS){const o=(0,s.YT)(e,"labels","logLoss"),i=(0,s.YT)(t,"predictions","logLoss");let u=null;null!=n&&(u=(0,s.YT)(n,"weights","logLoss")),(0,d.O3)(o.shape,i.shape,"Error in logLoss: ");const c=(0,Re.d)(1),l=(0,Re.d)(r),p=st((0,_.l)(o,nt(h(i,l)))),f=(0,_.l)(ct(c,o),nt(h(ct(c,i),l))),m=ct(p,f);return Kr(m,u,a)}});const Qr=(0,i.op)({meanSquaredError_:function(e,t,n,r=jr.SUM_BY_NONZERO_WEIGHTS){const a=(0,s.YT)(e,"labels","meanSquaredError"),o=(0,s.YT)(t,"predictions","meanSquaredError");let i=null;null!=n&&(i=(0,s.YT)(n,"weights","meanSquaredError")),(0,d.O3)(a.shape,o.shape,"Error in meanSquaredError: ");const u=On(a,o);return Kr(u,i,r)}});const Jr=(0,i.op)({sigmoidCrossEntropy_:function(e,t,n,r=0,a=jr.SUM_BY_NONZERO_WEIGHTS){let o=(0,s.YT)(e,"multiClassLabels","sigmoidCrossEntropy");const i=(0,s.YT)(t,"logits","sigmoidCrossEntropy");let c=null;if(null!=n&&(c=(0,s.YT)(n,"weights","sigmoidCrossEntropy")),(0,d.O3)(o.shape,i.shape,"Error in sigmoidCrossEntropy: "),r>0){const e=(0,Re.d)(r),t=(0,Re.d)(1),n=(0,Re.d)(.5);o=h((0,_.l)(o,ct(t,e)),(0,_.l)(n,e))}const l=function(e,t){const n=(0,s.YT)(e,"labels","sigmoidCrossEntropyWithLogits"),r=(0,s.YT)(t,"logits","sigmoidCrossEntropyWithLogits");(0,d.O3)(n.shape,r.shape,"Error in sigmoidCrossEntropyWithLogits: ");
2const a=(0,un.V)(r),o=(0,_.l)(r,n),i=rt(Pe(st(u(r))));return h(ct(a,o),i)}(o,i);return Kr(l,c,a)}});const ea=(0,i.op)({softmaxCrossEntropy_:function(e,t,n,r=0,a=jr.SUM_BY_NONZERO_WEIGHTS){let o=(0,s.YT)(e,"onehotLabels","softmaxCrossEntropy");const i=(0,s.YT)(t,"logits","softmaxCrossEntropy");let u=null;if(null!=n&&(u=(0,s.YT)(n,"weights","softmaxCrossEntropy")),(0,d.O3)(o.shape,i.shape,"Error in softmaxCrossEntropy: "),r>0){const e=(0,Re.d)(r),t=(0,Re.d)(1),n=(0,Re.d)(o.shape[1]);o=h((0,_.l)(o,ct(t,e)),ye(e,n))}const c=function(e,t,n=-1){if(-1===n&&(n=t.rank-1),n!==t.rank-1)throw Error(`Softmax cross entropy along a non-last dimension is not yet supported. Labels / logits was rank ${t.rank} and dim was ${n}`);const r=ot((e,t,r)=>{const a=pt(t,[n],!0),o=ct((0,C.w)(t,"float32"),a);r([e,o]);const s=st((0,_.l)(o,e));return{value:(0,Fe.c)(s,[n]),gradFunc:(e,t)=>{const[r,a]=t,o=(0,$e.SM)(e.shape,[n]);return[(0,_.l)((0,E.t)(e,o),ct((0,C.w)(r,"float32"),Pe(a))),(0,_.l)((0,E.t)(e,o),ct(Pe(a),(0,C.w)(r,"float32")))]}}});return r(e,t)}(o,i);return Kr(c,u,a)}});const ta=(0,i.op)({sparseFillEmptyRows_:function(e,t,n,r){const i=(0,s.YT)(e,"indices","sparseFillEmptyRows","int32"),u=(0,s.YT)(t,"values","sparseFillEmptyRows"),c=(0,s.YT)(n,"denseShape","sparseFillEmptyRows","int32"),l=(0,s.YT)(r,"defaultValue","sparseFillEmptyRows",u.dtype);if(2!==i.rank)throw new Error(`Indices should be Tensor2D but received shape\n ${i.shape}`);if(1!==u.rank)throw new Error(`Values should be Tensor1D but received shape ${u.shape}`);if(1!==c.rank)throw new Error(`Dense shape should be Tensor1D but received shape ${c.shape}`);if(0!==l.rank)throw new Error(`Default value should be a scalar but received shape ${l.shape}`);const p={indices:i,values:u,denseShape:c,defaultValue:l},h=a.T2.runKernel(o.C8s,p);return{outputIndices:h[0],outputValues:h[1],emptyRowIndicator:h[2],reverseIndexMap:h[3]}}});const na=(0,i.op)({sparseReshape_:function(e,t,n){const r=(0,s.YT)(e,"inputIndices","sparseReshape","int32"),i=(0,s.YT)(t,"inputShape","sparseReshape","int32"),u=(0,s.YT)(n,"newShape","sparseReshape","int32");if(2!==r.rank)throw new Error(`Input indices should be Tensor2D but received shape\n ${r.shape}`);if(1!==i.rank)throw new Error(`Input shape should be Tensor1D but received shape ${i.shape}`);if(1!==u.rank)throw new Error(`New shape should be Tensor1D but received shape ${u.shape}`);const c={inputIndices:r,inputShape:i,newShape:u},l=a.T2.runKernel(o.BoJ,c);return{outputIndices:l[0],outputShape:l[1]}}});const ra=(0,i.op)({sparseSegmentMean_:function(e,t,n){const r=(0,s.YT)(e,"data","sparseSegmentMean"),i=(0,s.YT)(t,"indices","sparseSegmentMean","int32"),u=(0,s.YT)(n,"segmentIds","sparseSegmentMean","int32");if(r.rank<1)throw new Error("Data should be at least 1 dimensional but received scalar");if(1!==i.rank)throw new Error(`Indices should be Tensor1D but received shape\n ${i.shape}`);if(1!==u.rank)throw new Error(`Segment ids should be Tensor1D but received shape\n ${u.shape}`);const c={data:r,indices:i,segmentIds:u};return a.T2.runKernel(o.L6G,c)}});const aa=(0,i.op)({sparseSegmentSum_:function(e,t,n){const r=(0,s.YT)(e,"data","sparseSegmentSum"),i=(0,s.YT)(t,"indices","sparseSegmentSum","int32"),u=(0,s.YT)(n,"segmentIds","sparseSegmentSum","int32");if(r.rank<1)throw new Error("Data should be at least 1 dimensional but received scalar");if(1!==i.rank)throw new Error(`Indices should be Tensor1D but received shape\n ${i.shape}`);if(1!==u.rank)throw new Error(`Segment ids should be Tensor1D but received shape\n ${u.shape}`);const c={data:r,indices:i,segmentIds:u};return a.T2.runKernel(o.DvZ,c)}});const oa=(0,i.op)({stringNGrams_:function(e,t,n,r,i,u,c,l){const p=(0,s.YT)(e,"data","stringNGrams","string");if("string"!==p.dtype)throw new Error("Data must be of datatype string");if(1!==p.shape.length)throw new Error(`Data must be a vector, saw: ${p.shape}`);const h=(0,s.YT)(t,"dataSplits","stringNGrams");if("int32"!==h.dtype)throw new Error("Data splits must be of datatype int32");
2const d={separator:n,nGramWidths:r,leftPad:i,rightPad:u,padWidth:c,preserveShortSequences:l},f={data:p,dataSplits:h},m=a.T2.runKernel(o.YAb,f,d);return{nGrams:m[0],nGramsSplits:m[1]}}});const sa=(0,i.op)({stringSplit_:function(e,t,n=!0){const r=(0,s.YT)(e,"input","stringSplit","string"),i=(0,s.YT)(t,"delimiter","stringSplit","string");if(1!==r.rank)throw new Error(`Input should be Tensor1D but received shape ${r.shape}`);if(0!==i.rank)throw new Error(`Delimiter should be a scalar but received shape ${i.shape}`);const u={skipEmpty:n},c={input:r,delimiter:i},l=a.T2.runKernel(o.iW0,c,u);return{indices:l[0],values:l[1],shape:l[2]}}});const ia=(0,i.op)({stringToHashBucketFast_:function(e,t){const n=(0,s.YT)(e,"input","stringToHashBucketFast","string"),r={numBuckets:t};if(t<=0)throw new Error("Number of buckets must be at least 1");const i={input:n};return a.T2.runKernel(o.$jE,i,r)}}),ua={fft:Nn,ifft:In,rfft:_n,irfft:An},ca={hammingWindow:wr,hannWindow:Tr,frame:Sr,stft:Cr},la={flipLeftRight:Er,grayscaleToRGB:$r,resizeNearestNeighbor:Pr,resizeBilinear:Mr,rotateWithOffset:Nr,cropAndResize:kr,nonMaxSuppression:Ar,nonMaxSuppressionAsync:_r,nonMaxSuppressionWithScore:Or,nonMaxSuppressionWithScoreAsync:Fr,nonMaxSuppressionPadded:Dr,nonMaxSuppressionPaddedAsync:Lr,threshold:Br,transform:Vr},pa={bandPart:zr,gramSchmidt:Ur,qr:Gr},ha={absoluteDifference:Hr,computeWeightedLoss:Kr,cosineDistance:Yr,hingeLoss:Zr,huberLoss:Xr,logLoss:qr,meanSquaredError:Qr,sigmoidCrossEntropy:Jr,softmaxCrossEntropy:ea},da={sparseFillEmptyRows:ta,sparseReshape:na,sparseSegmentMean:ra,sparseSegmentSum:aa},fa={stringNGrams:oa,stringSplit:sa,stringToHashBucketFast:ia}}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.