mirror of https://github.com/vladmandic/human
5546 lines
1.3 MiB
5546 lines
1.3 MiB
/*
|
|
Human
|
|
homepage: <https://github.com/vladmandic/human>
|
|
author: <https://github.com/vladmandic>'
|
|
*/
|
|
|
|
var Human=(()=>{var rg=Object.defineProperty;var lS=(e,t,n)=>t in e?rg(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var uS=e=>rg(e,"__esModule",{value:!0});var ag=typeof require!="undefined"?require:e=>{throw new Error('Dynamic require of "'+e+'" is not supported')};var jx=(e,t)=>{uS(e);for(var n in t)rg(e,n,{get:t[n],enumerable:!0})};var Re=(e,t,n)=>(lS(e,typeof t!="symbol"?t+"":t,n),n),qx=(e,t,n)=>{if(!t.has(e))throw TypeError("Cannot "+n)};var Uu=(e,t,n)=>(qx(e,t,"read from private field"),n?n.call(e):t.get(e)),Hu=(e,t,n)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,n)},Gu=(e,t,n,s)=>(qx(e,t,"write to private field"),s?s.call(e,n):t.set(e,n),n);var Mle={};jx(Mle,{Human:()=>xI,default:()=>xI,defaults:()=>kr,env:()=>de});function xt(e,t){let n=e.endsWith("/")?"":"/",r=t.startsWith(".")||t.startsWith("/")||t.startsWith("http:")||t.startsWith("https:")||t.startsWith("file:")?`${t}`:`${e}${n}${t}`;if(!r.toLocaleLowerCase().includes(".json"))throw new Error(`modelpath error: ${r} expecting json file`);return r}function ie(...e){let t=new Date,n=`${t.getHours().toString().padStart(2,"0")}:${t.getMinutes().toString().padStart(2,"0")}:${t.getSeconds().toString().padStart(2,"0")}.${t.getMilliseconds().toString().padStart(3,"0")}`;e&&console.log(n,"Human:",...e)}var Ze=()=>typeof performance!="undefined"?performance.now():parseInt((Number(process.hrtime.bigint())/1e3/1e3).toString());function ip(e,t,n="config",s=[]){for(let r of Object.keys(t))if(typeof t[r]=="object")ip(e[r],t[r],r,s);else{let a=e&&typeof e[r]!="undefined";a||s.push({reason:"unknown property",where:`${n}.${r} = ${t[r]}`});let o=e&&typeof e[r]==typeof t[r];a&&!o&&s.push({reason:"property type mismatch",where:`${n}.${r} = ${t[r]}`,expected:typeof e[r]})}return t.debug&&n==="config"&&s.length>0&&ie("invalid configuration",s),s}function xn(...e){let t=n=>n&&typeof n=="object";return e.reduce((n,s)=>(Object.keys(s||{}).forEach(r=>{let a=n[r],o=s[r];Array.isArray(a)&&Array.isArray(o)?n[r]=a.concat(...o):t(a)&&t(o)?n[r]=xn(a,o):n[r]=o}),n),{})}var kr={backend:"",modelBasePath:"",wasmPath:"",debug:!0,async:!0,warmup:"full",cacheSensitivity:.75,skipFrame:!1,filter:{enabled:!0,width:0,height:0,flip:!1,return:!0,brightness:0,contrast:0,sharpness:0,blur:0,saturation:0,hue:0,negative:!1,sepia:!1,vintage:!1,kodachrome:!1,technicolor:!1,polaroid:!1,pixelate:0},gesture:{enabled:!0},face:{enabled:!0,detector:{modelPath:"blazeface.json",rotation:!0,maxDetected:15,skipFrames:15,minConfidence:.2,iouThreshold:.1,return:!1},mesh:{enabled:!0,modelPath:"facemesh.json"},iris:{enabled:!0,modelPath:"iris.json"},description:{enabled:!0,modelPath:"faceres.json",skipFrames:11,minConfidence:.1},emotion:{enabled:!0,minConfidence:.1,skipFrames:17,modelPath:"emotion.json"}},body:{enabled:!0,modelPath:"movenet-lightning.json",maxDetected:1,minConfidence:.2,skipFrames:1},hand:{enabled:!0,rotation:!0,skipFrames:18,minConfidence:.8,iouThreshold:.2,maxDetected:1,landmarks:!0,detector:{modelPath:"handdetect.json"},skeleton:{modelPath:"handskeleton.json"}},object:{enabled:!1,modelPath:"mb3-centernet.json",minConfidence:.2,iouThreshold:.4,maxDetected:10,skipFrames:19},segmentation:{enabled:!1,modelPath:"selfie.json"}};var fi={};jx(fi,{Abs:()=>Fi,Acos:()=>Oi,Acosh:()=>Pi,AdadeltaOptimizer:()=>Uh,AdagradOptimizer:()=>Hh,AdamOptimizer:()=>Gh,AdamaxOptimizer:()=>jh,Add:()=>Yr,AddN:()=>Fa,All:()=>Mi,Any:()=>zi,ArgMax:()=>Oa,ArgMin:()=>Zu,Asin:()=>Li,Asinh:()=>Bi,Atan:()=>Wi,Atan2:()=>Ui,Atanh:()=>Vi,AvgPool:()=>Pa,AvgPool3D:()=>Yu,AvgPool3DGrad:()=>mp,AvgPoolGrad:()=>fp,BackendWasm:()=>s8,BatchMatMul:()=>Ma,BatchToSpaceND:()=>Hi,Bincount:()=>gp,BroadcastArgs:()=>pg,BroadcastTo:()=>p5,Callback:()=>e7,CallbackList:()=>j3,Cast:()=>za,Ceil:()=>La,ClipByValue:()=>Jr,Complex:()=>Ap,ComplexAbs:()=>Ju,Concat:()=>Gi,Conv2D:()=>Ba,Conv2DBackpropFilter:()=>yp,Conv2DBackpropInput:()=>Wa,Conv3D:()=>Qu,Conv3DBackpropFilterV2:()=>xp,Conv3DBackpropInputV2:()=>bp,Cos:()=>Va,Cosh:()=>Ua,CropAndResize:()=>ji,Cumsum:()=>Ha,CustomCallback:()=>X3,DataStorage:()=>up,DenseBincount:()=>vp,DepthToSpace:()=>qi,DepthwiseConv2dNative:()=>Ga,DepthwiseConv2dNativeBackpropFilter:()=>wp,DepthwiseConv2dNativeBackpropInput:()=>kp,Diag:()=>Ip,Dilation2D:()=>ec,Dilation2DBackpropFilter:()=>Cp,Dilation2DBackpropInput:()=>Sp,ENV:()=>nr,EarlyStopping:()=>n7,Einsum:()=>Tp,Elu:()=>qa,EluGrad:()=>Np,Environment:()=>c5,Equal:()=>Ki,Erf:()=>Xi,Exp:()=>Xa,ExpandDims:()=>Zi,Expm1:()=>Yi,FFT:()=>Ep,Fill:()=>tc,FlipLeftRight:()=>Ji,Floor:()=>Ka,FloorDiv:()=>Za,FromPixels:()=>Zp,FusedBatchNorm:()=>Ya,FusedConv2D:()=>_o,FusedDepthwiseConv2D:()=>$o,GPGPUContext:()=>Xf,GatherNd:()=>el,GatherV2:()=>Qi,GraphModel:()=>F7,Greater:()=>tl,GreaterEqual:()=>Ja,History:()=>q3,IFFT:()=>Rp,Identity:()=>Qa,Imag:()=>Dp,InputSpec:()=>Ht,IsFinite:()=>nl,IsInf:()=>sl,IsNan:()=>rl,KernelBackend:()=>qu,LRN:()=>rc,LRNGrad:()=>$p,LayerVariable:()=>W3,LayersModel:()=>Fr,LeakyRelu:()=>eo,Less:()=>al,LessEqual:()=>ol,LinSpace:()=>_p,Log:()=>to,Log1p:()=>il,LogSoftmax:()=>h5,LogicalAnd:()=>ll,LogicalNot:()=>nc,LogicalOr:()=>sc,MathBackendWebGL:()=>vu,Max:()=>no,MaxPool:()=>ro,MaxPool3D:()=>ac,MaxPool3DGrad:()=>Op,MaxPoolGrad:()=>Fp,MaxPoolWithArgmax:()=>Pp,Maximum:()=>so,Mean:()=>ao,Min:()=>oo,Minimum:()=>io,MirrorPad:()=>lo,Mod:()=>ul,MomentumOptimizer:()=>qh,Multinomial:()=>Mp,Multiply:()=>uo,Neg:()=>cl,NonMaxSuppressionV3:()=>pl,NonMaxSuppressionV4:()=>hl,NonMaxSuppressionV5:()=>fl,NotEqual:()=>dl,OP_SCOPE_SUFFIX:()=>N5,OneHot:()=>co,OnesLike:()=>ml,Optimizer:()=>Dr,Pack:()=>gl,PadV2:()=>po,Pool:()=>aC,Pow:()=>ho,Prelu:()=>fo,Prod:()=>Al,RMSPropOptimizer:()=>Xh,RNN:()=>hr,Range:()=>oc,Rank:()=>Ag,Real:()=>zp,RealDiv:()=>ja,Reciprocal:()=>yl,Reduction:()=>Tn,Relu:()=>mo,Relu6:()=>Ao,Reshape:()=>xl,ResizeBilinear:()=>go,ResizeBilinearGrad:()=>Bp,ResizeNearestNeighbor:()=>ic,ResizeNearestNeighborGrad:()=>Lp,Reverse:()=>yo,RotateWithOffset:()=>Fl,Round:()=>xo,Rsqrt:()=>bo,SGDOptimizer:()=>Bc,ScatterNd:()=>bl,Select:()=>vl,Selu:()=>wl,Sequential:()=>iu,Sigmoid:()=>wo,Sign:()=>Sl,Sin:()=>vo,Sinh:()=>Il,Slice:()=>kl,Softmax:()=>So,Softplus:()=>Cl,SpaceToBatchND:()=>Tl,SparseFillEmptyRows:()=>Wp,SparseReshape:()=>Vp,SparseSegmentMean:()=>Up,SparseSegmentSum:()=>Hp,SparseToDense:()=>Gp,SplitV:()=>Nl,Sqrt:()=>ko,Square:()=>lc,SquaredDifference:()=>Co,Step:()=>ea,StridedSlice:()=>El,StringNGrams:()=>jp,StringSplit:()=>qp,StringToHashBucketFast:()=>Xp,Sub:()=>To,Sum:()=>Io,SymbolicTensor:()=>Xs,Tan:()=>No,Tanh:()=>Eo,Tensor:()=>Ge,TensorBuffer:()=>Kt,Tile:()=>Qr,TopK:()=>Rl,Transform:()=>Dl,Transpose:()=>Ro,Unique:()=>Kp,Unpack:()=>_l,UnsortedSegmentSum:()=>uc,Variable:()=>Ac,ZerosLike:()=>$l,_FusedMatMul:()=>Do,abs:()=>Wt,acos:()=>Gg,acosh:()=>jg,add:()=>oe,addN:()=>dh,all:()=>ph,any:()=>wc,argMax:()=>Ws,argMin:()=>qg,asin:()=>Xg,asinh:()=>Kg,atan:()=>Zg,atan2:()=>Yg,atanh:()=>Jg,avgPool:()=>Ic,avgPool3d:()=>tA,backend:()=>ia,backend_util:()=>_,basicLSTMCell:()=>zT,batchNorm:()=>Uo,batchNorm2d:()=>gb,batchNorm3d:()=>Ab,batchNorm4d:()=>yb,batchToSpaceND:()=>Sc,bincount:()=>nA,booleanMaskAsync:()=>GR,broadcastArgs:()=>xb,broadcastTo:()=>Hl,browser:()=>xs,buffer:()=>je,callbacks:()=>aL,cast:()=>pe,ceil:()=>sA,clipByValue:()=>Wn,clone:()=>Bs,complex:()=>sa,concat:()=>ft,concat1d:()=>bb,concat2d:()=>Gl,concat3d:()=>vb,concat4d:()=>wb,constraints:()=>b3,conv1d:()=>fh,conv2d:()=>Tr,conv2dTranspose:()=>mh,conv3d:()=>aA,conv3dTranspose:()=>Ib,copyRegisteredKernels:()=>lC,cos:()=>Cc,cosh:()=>gh,cosineWindow:()=>_A,cumsum:()=>Ah,customGrad:()=>or,data:()=>O7,denseBincount:()=>Sb,deprecationWarn:()=>Ug,depthToSpace:()=>oA,depthwiseConv2d:()=>jl,deregisterOp:()=>iL,device_util:()=>xc,diag:()=>fN,dilation2d:()=>iA,disableDeprecationWarnings:()=>eT,dispose:()=>Z,disposeVariables:()=>tT,div:()=>he,divNoNan:()=>lA,dot:()=>Cb,dropout:()=>qb,einsum:()=>Tb,elu:()=>ql,enableDebugMode:()=>Q9,enableProdMode:()=>db,enclosingPowerOfTwo:()=>Xb,engine:()=>Qn,env:()=>Y,equal:()=>es,erf:()=>uA,exp:()=>ts,expandDims:()=>Lt,expm1:()=>cA,eye:()=>dA,fft:()=>Mc,fill:()=>Xl,findBackend:()=>Hg,findBackendFactory:()=>aT,floor:()=>Kl,floorDiv:()=>ch,forceHalfFloat:()=>l4,fused:()=>da,gather:()=>Ho,gatherND:()=>jb,gather_util:()=>Pg,getBackend:()=>Cr,getGradient:()=>hg,getKernel:()=>Yp,getKernelsForBackend:()=>ta,gpgpu_util:()=>P6,grad:()=>HN,grads:()=>GN,greater:()=>Vn,greaterEqual:()=>ua,ifft:()=>Ql,imag:()=>yh,image:()=>$e,inTopKAsync:()=>nD,initializers:()=>T3,input:()=>Av,io:()=>Ln,irfft:()=>$h,isFinite:()=>Nb,isInf:()=>Eb,isNaN:()=>pA,keep:()=>on,kernel_impls:()=>lr,layers:()=>z3,leakyRelu:()=>Tc,less:()=>xh,lessEqual:()=>ca,linalg:()=>o3,linspace:()=>Rb,loadGraphModel:()=>yt,loadLayersModel:()=>mM,localResponseNormalization:()=>hA,log:()=>ns,log1p:()=>Nc,logSigmoid:()=>_b,logSoftmax:()=>vh,logSumExp:()=>gA,logicalAnd:()=>_s,logicalNot:()=>Ec,logicalOr:()=>wh,logicalXor:()=>Pb,losses:()=>z_,matMul:()=>Ue,math:()=>j5,max:()=>ss,maxPool:()=>Rc,maxPool3d:()=>AA,maxPoolWithArgmax:()=>Mb,maximum:()=>ir,mean:()=>Dt,memory:()=>lh,meshgrid:()=>hE,metrics:()=>Yv,min:()=>Dc,minimum:()=>Zl,mirrorPad:()=>yA,mod:()=>xA,model:()=>hM,models:()=>Jv,moments:()=>kh,movingAverage:()=>XR,mul:()=>z,multiRNNCell:()=>vE,multinomial:()=>zb,neg:()=>St,nextFrame:()=>Kh,norm:()=>Mh,notEqual:()=>qo,oneHot:()=>Bl,ones:()=>rs,onesLike:()=>as,op:()=>W,outerProduct:()=>CE,pad:()=>Nr,pad1d:()=>EE,pad2d:()=>DE,pad3d:()=>$E,pad4d:()=>OE,pool:()=>Lb,pow:()=>Er,prelu:()=>$c,print:()=>B5,prod:()=>Ih,profile:()=>nT,rand:()=>HE,randomGamma:()=>XE,randomNormal:()=>Bb,randomUniform:()=>Yl,range:()=>Jl,ready:()=>uh,real:()=>Fc,reciprocal:()=>wA,registerBackend:()=>Vl,registerCallbackConstructor:()=>gM,registerGradient:()=>f5,registerKernel:()=>Fo,registerOp:()=>oL,regularizers:()=>Qv,relu:()=>Vs,relu6:()=>Sh,removeBackend:()=>rT,reshape:()=>V,reverse:()=>os,reverse1d:()=>sR,reverse2d:()=>aR,reverse3d:()=>iR,reverse4d:()=>uR,rfft:()=>zc,round:()=>Ch,rsqrt:()=>Th,scalar:()=>Ce,scatterND:()=>Gb,scatter_util:()=>Mg,selu:()=>Nh,separableConv2d:()=>kA,sequential:()=>fM,serialization:()=>le,setBackend:()=>pb,setPlatform:()=>oT,setWasmPath:()=>Lie,setWasmPaths:()=>a8,setWebGLContext:()=>Lf,setdiff1dAsync:()=>Wb,sigmoid:()=>Bn,sign:()=>IA,signal:()=>M_,sin:()=>Eh,sinh:()=>Rh,slice:()=>_e,slice1d:()=>Dh,slice2d:()=>SA,slice3d:()=>_h,slice4d:()=>Oc,slice_util:()=>Cn,softmax:()=>Pc,softplus:()=>Go,spaceToBatchND:()=>_c,sparse:()=>Lc,sparseToDense:()=>DA,spectral:()=>P_,split:()=>Vt,sqrt:()=>fn,square:()=>pt,squaredDifference:()=>Fh,squeeze:()=>lt,stack:()=>mn,step:()=>eu,stridedSlice:()=>CA,string:()=>Vh,sub:()=>ye,sum:()=>we,sumOutType:()=>nh,tan:()=>TA,tanh:()=>Vo,tensor:()=>an,tensor1d:()=>Ut,tensor2d:()=>Us,tensor3d:()=>ah,tensor4d:()=>OR,tensor5d:()=>PR,tensor6d:()=>MR,tensor_util:()=>zs,test_util:()=>lb,tidy:()=>H,tile:()=>bs,time:()=>sT,topk:()=>NA,train:()=>Ko,transpose:()=>Ye,truncatedNormal:()=>Oh,unique:()=>Ph,unregisterGradient:()=>iC,unregisterKernel:()=>oC,unsortedSegmentSum:()=>EA,unstack:()=>is,upcastType:()=>Ds,util:()=>w,valueAndGrad:()=>jN,valueAndGrads:()=>qN,variable:()=>Vb,variableGrads:()=>Db,version:()=>Zie,version_converter:()=>cB,version_core:()=>ih,version_layers:()=>h1,version_wasm:()=>Bie,version_webgl:()=>wK,webgl:()=>kK,webgl_util:()=>o6,where:()=>vn,whereAsync:()=>RA,zeros:()=>Mt,zerosLike:()=>Je});var cS=Object.create,lp=Object.defineProperty,dS=Object.getOwnPropertyDescriptor,pS=Object.getOwnPropertyNames,hS=Object.getPrototypeOf,fS=Object.prototype.hasOwnProperty,Xx=e=>lp(e,"__esModule",{value:!0}),Di=typeof ag!="undefined"?ag:e=>{throw new Error('Dynamic require of "'+e+'" is not supported')},It=(e,t)=>function(){return t||(0,e[Object.keys(e)[0]])((t={exports:{}}).exports,t),t.exports},Le=(e,t)=>{Xx(e);for(var n in t)lp(e,n,{get:t[n],enumerable:!0})},mS=(e,t,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of pS(t))!fS.call(e,s)&&s!=="default"&&lp(e,s,{get:()=>t[s],enumerable:!(n=dS(t,s))||n.enumerable});return e},Da=e=>mS(Xx(lp(e!=null?cS(hS(e)):{},"default",e&&e.__esModule&&"default"in e?{get:()=>e.default,enumerable:!0}:{value:e,enumerable:!0})),e),gS=It({"node_modules/.pnpm/long@4.0.0/node_modules/long/src/long.js"(e,t){t.exports=s;var n=null;try{n=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(R){}function s(R,T,P){this.low=R|0,this.high=T|0,this.unsigned=!!P}s.prototype.__isLong__,Object.defineProperty(s.prototype,"__isLong__",{value:!0});function r(R){return(R&&R.__isLong__)===!0}s.isLong=r;var a={},o={};function i(R,T){var P,U,j;return T?(R>>>=0,(j=0<=R&&R<256)&&(U=o[R],U)?U:(P=u(R,(R|0)<0?-1:0,!0),j&&(o[R]=P),P)):(R|=0,(j=-128<=R&&R<128)&&(U=a[R],U)?U:(P=u(R,R<0?-1:0,!1),j&&(a[R]=P),P))}s.fromInt=i;function l(R,T){if(isNaN(R))return T?b:x;if(T){if(R<0)return b;if(R>=g)return D}else{if(R<=-A)return O;if(R+1>=A)return C}return R<0?l(-R,T).neg():u(R%m|0,R/m|0,T)}s.fromNumber=l;function u(R,T,P){return new s(R,T,P)}s.fromBits=u;var c=Math.pow;function d(R,T,P){if(R.length===0)throw Error("empty string");if(R==="NaN"||R==="Infinity"||R==="+Infinity"||R==="-Infinity")return x;if(typeof T=="number"?(P=T,T=!1):T=!!T,P=P||10,P<2||36<P)throw RangeError("radix");var U;if((U=R.indexOf("-"))>0)throw Error("interior hyphen");if(U===0)return d(R.substring(1),T,P).neg();for(var j=l(c(P,8)),q=x,X=0;X<R.length;X+=8){var te=Math.min(8,R.length-X),ne=parseInt(R.substring(X,X+te),P);if(te<8){var se=l(c(P,te));q=q.mul(se).add(l(ne))}else q=q.mul(j),q=q.add(l(ne))}return q.unsigned=T,q}s.fromString=d;function p(R,T){return typeof R=="number"?l(R,T):typeof R=="string"?d(R,T):u(R.low,R.high,typeof T=="boolean"?T:R.unsigned)}s.fromValue=p;var h=1<<16,f=1<<24,m=h*h,g=m*m,A=g/2,y=i(f),x=i(0);s.ZERO=x;var b=i(0,!0);s.UZERO=b;var v=i(1);s.ONE=v;var k=i(1,!0);s.UONE=k;var S=i(-1);s.NEG_ONE=S;var C=u(4294967295|0,2147483647|0,!1);s.MAX_VALUE=C;var D=u(4294967295|0,4294967295|0,!0);s.MAX_UNSIGNED_VALUE=D;var O=u(0,2147483648|0,!1);s.MIN_VALUE=O;var E=s.prototype;E.toInt=function(){return this.unsigned?this.low>>>0:this.low},E.toNumber=function(){return this.unsigned?(this.high>>>0)*m+(this.low>>>0):this.high*m+(this.low>>>0)},E.toString=function(T){if(T=T||10,T<2||36<T)throw RangeError("radix");if(this.isZero())return"0";if(this.isNegative())if(this.eq(O)){var P=l(T),U=this.div(P),j=U.mul(P).sub(this);return U.toString(T)+j.toInt().toString(T)}else return"-"+this.neg().toString(T);for(var q=l(c(T,6),this.unsigned),X=this,te="";;){var ne=X.div(q),se=X.sub(ne.mul(q)).toInt()>>>0,re=se.toString(T);if(X=ne,X.isZero())return re+te;for(;re.length<6;)re="0"+re;te=""+re+te}},E.getHighBits=function(){return this.high},E.getHighBitsUnsigned=function(){return this.high>>>0},E.getLowBits=function(){return this.low},E.getLowBitsUnsigned=function(){return this.low>>>0},E.getNumBitsAbs=function(){if(this.isNegative())return this.eq(O)?64:this.neg().getNumBitsAbs();for(var T=this.high!=0?this.high:this.low,P=31;P>0&&(T&1<<P)==0;P--);return this.high!=0?P+33:P+1},E.isZero=function(){return this.high===0&&this.low===0},E.eqz=E.isZero,E.isNegative=function(){return!this.unsigned&&this.high<0},E.isPositive=function(){return this.unsigned||this.high>=0},E.isOdd=function(){return(this.low&1)==1},E.isEven=function(){return(this.low&1)==0},E.equals=function(T){return r(T)||(T=p(T)),this.unsigned!==T.unsigned&&this.high>>>31==1&&T.high>>>31==1?!1:this.high===T.high&&this.low===T.low},E.eq=E.equals,E.notEquals=function(T){return!this.eq(T)},E.neq=E.notEquals,E.ne=E.notEquals,E.lessThan=function(T){return this.comp(T)<0},E.lt=E.lessThan,E.lessThanOrEqual=function(T){return this.comp(T)<=0},E.lte=E.lessThanOrEqual,E.le=E.lessThanOrEqual,E.greaterThan=function(T){return this.comp(T)>0},E.gt=E.greaterThan,E.greaterThanOrEqual=function(T){return this.comp(T)>=0},E.gte=E.greaterThanOrEqual,E.ge=E.greaterThanOrEqual,E.compare=function(T){if(r(T)||(T=p(T)),this.eq(T))return 0;var P=this.isNegative(),U=T.isNegative();return P&&!U?-1:!P&&U?1:this.unsigned?T.high>>>0>this.high>>>0||T.high===this.high&&T.low>>>0>this.low>>>0?-1:1:this.sub(T).isNegative()?-1:1},E.comp=E.compare,E.negate=function(){return!this.unsigned&&this.eq(O)?O:this.not().add(v)},E.neg=E.negate,E.add=function(T){r(T)||(T=p(T));var P=this.high>>>16,U=this.high&65535,j=this.low>>>16,q=this.low&65535,X=T.high>>>16,te=T.high&65535,ne=T.low>>>16,se=T.low&65535,re=0,Q=0,ue=0,ce=0;return ce+=q+se,ue+=ce>>>16,ce&=65535,ue+=j+ne,Q+=ue>>>16,ue&=65535,Q+=U+te,re+=Q>>>16,Q&=65535,re+=P+X,re&=65535,u(ue<<16|ce,re<<16|Q,this.unsigned)},E.subtract=function(T){return r(T)||(T=p(T)),this.add(T.neg())},E.sub=E.subtract,E.multiply=function(T){if(this.isZero())return x;if(r(T)||(T=p(T)),n){var P=n.mul(this.low,this.high,T.low,T.high);return u(P,n.get_high(),this.unsigned)}if(T.isZero())return x;if(this.eq(O))return T.isOdd()?O:x;if(T.eq(O))return this.isOdd()?O:x;if(this.isNegative())return T.isNegative()?this.neg().mul(T.neg()):this.neg().mul(T).neg();if(T.isNegative())return this.mul(T.neg()).neg();if(this.lt(y)&&T.lt(y))return l(this.toNumber()*T.toNumber(),this.unsigned);var U=this.high>>>16,j=this.high&65535,q=this.low>>>16,X=this.low&65535,te=T.high>>>16,ne=T.high&65535,se=T.low>>>16,re=T.low&65535,Q=0,ue=0,ce=0,fe=0;return fe+=X*re,ce+=fe>>>16,fe&=65535,ce+=q*re,ue+=ce>>>16,ce&=65535,ce+=X*se,ue+=ce>>>16,ce&=65535,ue+=j*re,Q+=ue>>>16,ue&=65535,ue+=q*se,Q+=ue>>>16,ue&=65535,ue+=X*ne,Q+=ue>>>16,ue&=65535,Q+=U*re+j*se+q*ne+X*te,Q&=65535,u(ce<<16|fe,Q<<16|ue,this.unsigned)},E.mul=E.multiply,E.divide=function(T){if(r(T)||(T=p(T)),T.isZero())throw Error("division by zero");if(n){if(!this.unsigned&&this.high===-2147483648&&T.low===-1&&T.high===-1)return this;var P=(this.unsigned?n.div_u:n.div_s)(this.low,this.high,T.low,T.high);return u(P,n.get_high(),this.unsigned)}if(this.isZero())return this.unsigned?b:x;var U,j,q;if(this.unsigned){if(T.unsigned||(T=T.toUnsigned()),T.gt(this))return b;if(T.gt(this.shru(1)))return k;q=b}else{if(this.eq(O)){if(T.eq(v)||T.eq(S))return O;if(T.eq(O))return v;var X=this.shr(1);return U=X.div(T).shl(1),U.eq(x)?T.isNegative()?v:S:(j=this.sub(T.mul(U)),q=U.add(j.div(T)),q)}else if(T.eq(O))return this.unsigned?b:x;if(this.isNegative())return T.isNegative()?this.neg().div(T.neg()):this.neg().div(T).neg();if(T.isNegative())return this.div(T.neg()).neg();q=x}for(j=this;j.gte(T);){U=Math.max(1,Math.floor(j.toNumber()/T.toNumber()));for(var te=Math.ceil(Math.log(U)/Math.LN2),ne=te<=48?1:c(2,te-48),se=l(U),re=se.mul(T);re.isNegative()||re.gt(j);)U-=ne,se=l(U,this.unsigned),re=se.mul(T);se.isZero()&&(se=v),q=q.add(se),j=j.sub(re)}return q},E.div=E.divide,E.modulo=function(T){if(r(T)||(T=p(T)),n){var P=(this.unsigned?n.rem_u:n.rem_s)(this.low,this.high,T.low,T.high);return u(P,n.get_high(),this.unsigned)}return this.sub(this.div(T).mul(T))},E.mod=E.modulo,E.rem=E.modulo,E.not=function(){return u(~this.low,~this.high,this.unsigned)},E.and=function(T){return r(T)||(T=p(T)),u(this.low&T.low,this.high&T.high,this.unsigned)},E.or=function(T){return r(T)||(T=p(T)),u(this.low|T.low,this.high|T.high,this.unsigned)},E.xor=function(T){return r(T)||(T=p(T)),u(this.low^T.low,this.high^T.high,this.unsigned)},E.shiftLeft=function(T){return r(T)&&(T=T.toInt()),(T&=63)===0?this:T<32?u(this.low<<T,this.high<<T|this.low>>>32-T,this.unsigned):u(0,this.low<<T-32,this.unsigned)},E.shl=E.shiftLeft,E.shiftRight=function(T){return r(T)&&(T=T.toInt()),(T&=63)===0?this:T<32?u(this.low>>>T|this.high<<32-T,this.high>>T,this.unsigned):u(this.high>>T-32,this.high>=0?0:-1,this.unsigned)},E.shr=E.shiftRight,E.shiftRightUnsigned=function(T){if(r(T)&&(T=T.toInt()),T&=63,T===0)return this;var P=this.high;if(T<32){var U=this.low;return u(U>>>T|P<<32-T,P>>>T,this.unsigned)}else return T===32?u(P,0,this.unsigned):u(P>>>T-32,0,this.unsigned)},E.shru=E.shiftRightUnsigned,E.shr_u=E.shiftRightUnsigned,E.toSigned=function(){return this.unsigned?u(this.low,this.high,!1):this},E.toUnsigned=function(){return this.unsigned?this:u(this.low,this.high,!0)},E.toBytes=function(T){return T?this.toBytesLE():this.toBytesBE()},E.toBytesLE=function(){var T=this.high,P=this.low;return[P&255,P>>>8&255,P>>>16&255,P>>>24,T&255,T>>>8&255,T>>>16&255,T>>>24]},E.toBytesBE=function(){var T=this.high,P=this.low;return[T>>>24,T>>>16&255,T>>>8&255,T&255,P>>>24,P>>>16&255,P>>>8&255,P&255]},s.fromBytes=function(T,P,U){return U?s.fromBytesLE(T,P):s.fromBytesBE(T,P)},s.fromBytesLE=function(T,P){return new s(T[0]|T[1]<<8|T[2]<<16|T[3]<<24,T[4]|T[5]<<8|T[6]<<16|T[7]<<24,P)},s.fromBytesBE=function(T,P){return new s(T[4]<<24|T[5]<<16|T[6]<<8|T[7],T[0]<<24|T[1]<<16|T[2]<<8|T[3],P)}}}),AS=It({"(disabled):node_modules/.pnpm/node-fetch@2.6.2/node_modules/node-fetch/browser.js"(){}}),yS=It({"node_modules/.pnpm/seedrandom@2.4.3/node_modules/seedrandom/lib/alea.js"(e,t){(function(n,s,r){function a(u){var c=this,d=l();c.next=function(){var p=2091639*c.s0+c.c*23283064365386963e-26;return c.s0=c.s1,c.s1=c.s2,c.s2=p-(c.c=p|0)},c.c=1,c.s0=d(" "),c.s1=d(" "),c.s2=d(" "),c.s0-=d(u),c.s0<0&&(c.s0+=1),c.s1-=d(u),c.s1<0&&(c.s1+=1),c.s2-=d(u),c.s2<0&&(c.s2+=1),d=null}function o(u,c){return c.c=u.c,c.s0=u.s0,c.s1=u.s1,c.s2=u.s2,c}function i(u,c){var d=new a(u),p=c&&c.state,h=d.next;return h.int32=function(){return d.next()*4294967296|0},h.double=function(){return h()+(h()*2097152|0)*11102230246251565e-32},h.quick=h,p&&(typeof p=="object"&&o(p,d),h.state=function(){return o(d,{})}),h}function l(){var u=4022871197,c=function(d){d=d.toString();for(var p=0;p<d.length;p++){u+=d.charCodeAt(p);var h=.02519603282416938*u;u=h>>>0,h-=u,h*=u,u=h>>>0,h-=u,u+=h*4294967296}return(u>>>0)*23283064365386963e-26};return c}s&&s.exports?s.exports=i:r&&r.amd?r(function(){return i}):this.alea=i})(e,typeof t=="object"&&t,typeof define=="function"&&define)}}),xS=It({"node_modules/.pnpm/seedrandom@2.4.3/node_modules/seedrandom/lib/xor128.js"(e,t){(function(n,s,r){function a(l){var u=this,c="";u.x=0,u.y=0,u.z=0,u.w=0,u.next=function(){var p=u.x^u.x<<11;return u.x=u.y,u.y=u.z,u.z=u.w,u.w^=u.w>>>19^p^p>>>8},l===(l|0)?u.x=l:c+=l;for(var d=0;d<c.length+64;d++)u.x^=c.charCodeAt(d)|0,u.next()}function o(l,u){return u.x=l.x,u.y=l.y,u.z=l.z,u.w=l.w,u}function i(l,u){var c=new a(l),d=u&&u.state,p=function(){return(c.next()>>>0)/4294967296};return p.double=function(){do var h=c.next()>>>11,f=(c.next()>>>0)/4294967296,m=(h+f)/(1<<21);while(m===0);return m},p.int32=c.next,p.quick=p,d&&(typeof d=="object"&&o(d,c),p.state=function(){return o(c,{})}),p}s&&s.exports?s.exports=i:r&&r.amd?r(function(){return i}):this.xor128=i})(e,typeof t=="object"&&t,typeof define=="function"&&define)}}),bS=It({"node_modules/.pnpm/seedrandom@2.4.3/node_modules/seedrandom/lib/xorwow.js"(e,t){(function(n,s,r){function a(l){var u=this,c="";u.next=function(){var p=u.x^u.x>>>2;return u.x=u.y,u.y=u.z,u.z=u.w,u.w=u.v,(u.d=u.d+362437|0)+(u.v=u.v^u.v<<4^(p^p<<1))|0},u.x=0,u.y=0,u.z=0,u.w=0,u.v=0,l===(l|0)?u.x=l:c+=l;for(var d=0;d<c.length+64;d++)u.x^=c.charCodeAt(d)|0,d==c.length&&(u.d=u.x<<10^u.x>>>4),u.next()}function o(l,u){return u.x=l.x,u.y=l.y,u.z=l.z,u.w=l.w,u.v=l.v,u.d=l.d,u}function i(l,u){var c=new a(l),d=u&&u.state,p=function(){return(c.next()>>>0)/4294967296};return p.double=function(){do var h=c.next()>>>11,f=(c.next()>>>0)/4294967296,m=(h+f)/(1<<21);while(m===0);return m},p.int32=c.next,p.quick=p,d&&(typeof d=="object"&&o(d,c),p.state=function(){return o(c,{})}),p}s&&s.exports?s.exports=i:r&&r.amd?r(function(){return i}):this.xorwow=i})(e,typeof t=="object"&&t,typeof define=="function"&&define)}}),vS=It({"node_modules/.pnpm/seedrandom@2.4.3/node_modules/seedrandom/lib/xorshift7.js"(e,t){(function(n,s,r){function a(l){var u=this;u.next=function(){var d=u.x,p=u.i,h,f,m;return h=d[p],h^=h>>>7,f=h^h<<24,h=d[p+1&7],f^=h^h>>>10,h=d[p+3&7],f^=h^h>>>3,h=d[p+4&7],f^=h^h<<7,h=d[p+7&7],h=h^h<<13,f^=h^h<<9,d[p]=f,u.i=p+1&7,f};function c(d,p){var h,f,m=[];if(p===(p|0))f=m[0]=p;else for(p=""+p,h=0;h<p.length;++h)m[h&7]=m[h&7]<<15^p.charCodeAt(h)+m[h+1&7]<<13;for(;m.length<8;)m.push(0);for(h=0;h<8&&m[h]===0;++h);for(h==8?f=m[7]=-1:f=m[h],d.x=m,d.i=0,h=256;h>0;--h)d.next()}c(u,l)}function o(l,u){return u.x=l.x.slice(),u.i=l.i,u}function i(l,u){l==null&&(l=+new Date);var c=new a(l),d=u&&u.state,p=function(){return(c.next()>>>0)/4294967296};return p.double=function(){do var h=c.next()>>>11,f=(c.next()>>>0)/4294967296,m=(h+f)/(1<<21);while(m===0);return m},p.int32=c.next,p.quick=p,d&&(d.x&&o(d,c),p.state=function(){return o(c,{})}),p}s&&s.exports?s.exports=i:r&&r.amd?r(function(){return i}):this.xorshift7=i})(e,typeof t=="object"&&t,typeof define=="function"&&define)}}),wS=It({"node_modules/.pnpm/seedrandom@2.4.3/node_modules/seedrandom/lib/xor4096.js"(e,t){(function(n,s,r){function a(l){var u=this;u.next=function(){var d=u.w,p=u.X,h=u.i,f,m;return u.w=d=d+1640531527|0,m=p[h+34&127],f=p[h=h+1&127],m^=m<<13,f^=f<<17,m^=m>>>15,f^=f>>>12,m=p[h]=m^f,u.i=h,m+(d^d>>>16)|0};function c(d,p){var h,f,m,g,A,y=[],x=128;for(p===(p|0)?(f=p,p=null):(p=p+"\0",f=0,x=Math.max(x,p.length)),m=0,g=-32;g<x;++g)p&&(f^=p.charCodeAt((g+32)%p.length)),g===0&&(A=f),f^=f<<10,f^=f>>>15,f^=f<<4,f^=f>>>13,g>=0&&(A=A+1640531527|0,h=y[g&127]^=f+A,m=h==0?m+1:0);for(m>=128&&(y[(p&&p.length||0)&127]=-1),m=127,g=4*128;g>0;--g)f=y[m+34&127],h=y[m=m+1&127],f^=f<<13,h^=h<<17,f^=f>>>15,h^=h>>>12,y[m]=f^h;d.w=A,d.X=y,d.i=m}c(u,l)}function o(l,u){return u.i=l.i,u.w=l.w,u.X=l.X.slice(),u}function i(l,u){l==null&&(l=+new Date);var c=new a(l),d=u&&u.state,p=function(){return(c.next()>>>0)/4294967296};return p.double=function(){do var h=c.next()>>>11,f=(c.next()>>>0)/4294967296,m=(h+f)/(1<<21);while(m===0);return m},p.int32=c.next,p.quick=p,d&&(d.X&&o(d,c),p.state=function(){return o(c,{})}),p}s&&s.exports?s.exports=i:r&&r.amd?r(function(){return i}):this.xor4096=i})(e,typeof t=="object"&&t,typeof define=="function"&&define)}}),kS=It({"node_modules/.pnpm/seedrandom@2.4.3/node_modules/seedrandom/lib/tychei.js"(e,t){(function(n,s,r){function a(l){var u=this,c="";u.next=function(){var p=u.b,h=u.c,f=u.d,m=u.a;return p=p<<25^p>>>7^h,h=h-f|0,f=f<<24^f>>>8^m,m=m-p|0,u.b=p=p<<20^p>>>12^h,u.c=h=h-f|0,u.d=f<<16^h>>>16^m,u.a=m-p|0},u.a=0,u.b=0,u.c=2654435769|0,u.d=1367130551,l===Math.floor(l)?(u.a=l/4294967296|0,u.b=l|0):c+=l;for(var d=0;d<c.length+20;d++)u.b^=c.charCodeAt(d)|0,u.next()}function o(l,u){return u.a=l.a,u.b=l.b,u.c=l.c,u.d=l.d,u}function i(l,u){var c=new a(l),d=u&&u.state,p=function(){return(c.next()>>>0)/4294967296};return p.double=function(){do var h=c.next()>>>11,f=(c.next()>>>0)/4294967296,m=(h+f)/(1<<21);while(m===0);return m},p.int32=c.next,p.quick=p,d&&(typeof d=="object"&&o(d,c),p.state=function(){return o(c,{})}),p}s&&s.exports?s.exports=i:r&&r.amd?r(function(){return i}):this.tychei=i})(e,typeof t=="object"&&t,typeof define=="function"&&define)}}),Kx=It({"(disabled):crypto"(){}}),IS=It({"node_modules/.pnpm/seedrandom@2.4.3/node_modules/seedrandom/seedrandom.js"(e,t){(function(n,s){var r=this,a=256,o=6,i=52,l="random",u=s.pow(a,o),c=s.pow(2,i),d=c*2,p=a-1,h;function f(v,k,S){var C=[];k=k==!0?{entropy:!0}:k||{};var D=y(A(k.entropy?[v,b(n)]:v==null?x():v,3),C),O=new m(C),E=function(){for(var R=O.g(o),T=u,P=0;R<c;)R=(R+P)*a,T*=a,P=O.g(1);for(;R>=d;)R/=2,T/=2,P>>>=1;return(R+P)/T};return E.int32=function(){return O.g(4)|0},E.quick=function(){return O.g(4)/4294967296},E.double=E,y(b(O.S),n),(k.pass||S||function(R,T,P,U){return U&&(U.S&&g(U,O),R.state=function(){return g(O,{})}),P?(s[l]=R,T):R})(E,D,"global"in k?k.global:this==s,k.state)}s["seed"+l]=f;function m(v){var k,S=v.length,C=this,D=0,O=C.i=C.j=0,E=C.S=[];for(S||(v=[S++]);D<a;)E[D]=D++;for(D=0;D<a;D++)E[D]=E[O=p&O+v[D%S]+(k=E[D])],E[O]=k;(C.g=function(R){for(var T,P=0,U=C.i,j=C.j,q=C.S;R--;)T=q[U=p&U+1],P=P*a+q[p&(q[U]=q[j=p&j+T])+(q[j]=T)];return C.i=U,C.j=j,P})(a)}function g(v,k){return k.i=v.i,k.j=v.j,k.S=v.S.slice(),k}function A(v,k){var S=[],C=typeof v,D;if(k&&C=="object")for(D in v)try{S.push(A(v[D],k-1))}catch(O){}return S.length?S:C=="string"?v:v+"\0"}function y(v,k){for(var S=v+"",C,D=0;D<S.length;)k[p&D]=p&(C^=k[p&D]*19)+S.charCodeAt(D++);return b(k)}function x(){try{var v;return h&&(v=h.randomBytes)?v=v(a):(v=new Uint8Array(a),(r.crypto||r.msCrypto).getRandomValues(v)),b(v)}catch(C){var k=r.navigator,S=k&&k.plugins;return[+new Date,r,S,r.screen,b(n)]}}function b(v){return String.fromCharCode.apply(0,v)}if(y(s.random(),n),typeof t=="object"&&t.exports){t.exports=f;try{h=Kx()}catch(v){}}else typeof define=="function"&&define.amd&&define(function(){return f})})([],Math)}}),Zx=It({"node_modules/.pnpm/seedrandom@2.4.3/node_modules/seedrandom/index.js"(e,t){var n=yS(),s=xS(),r=bS(),a=vS(),o=wS(),i=kS(),l=IS();l.alea=n,l.xor128=s,l.xorwow=r,l.xorshift7=a,l.xor4096=o,l.tychei=i,t.exports=l}}),SS=It({"node_modules/.pnpm/seedrandom@3.0.5/node_modules/seedrandom/lib/alea.js"(e,t){(function(n,s,r){function a(u){var c=this,d=l();c.next=function(){var p=2091639*c.s0+c.c*23283064365386963e-26;return c.s0=c.s1,c.s1=c.s2,c.s2=p-(c.c=p|0)},c.c=1,c.s0=d(" "),c.s1=d(" "),c.s2=d(" "),c.s0-=d(u),c.s0<0&&(c.s0+=1),c.s1-=d(u),c.s1<0&&(c.s1+=1),c.s2-=d(u),c.s2<0&&(c.s2+=1),d=null}function o(u,c){return c.c=u.c,c.s0=u.s0,c.s1=u.s1,c.s2=u.s2,c}function i(u,c){var d=new a(u),p=c&&c.state,h=d.next;return h.int32=function(){return d.next()*4294967296|0},h.double=function(){return h()+(h()*2097152|0)*11102230246251565e-32},h.quick=h,p&&(typeof p=="object"&&o(p,d),h.state=function(){return o(d,{})}),h}function l(){var u=4022871197,c=function(d){d=String(d);for(var p=0;p<d.length;p++){u+=d.charCodeAt(p);var h=.02519603282416938*u;u=h>>>0,h-=u,h*=u,u=h>>>0,h-=u,u+=h*4294967296}return(u>>>0)*23283064365386963e-26};return c}s&&s.exports?s.exports=i:r&&r.amd?r(function(){return i}):this.alea=i})(e,typeof t=="object"&&t,typeof define=="function"&&define)}}),CS=It({"node_modules/.pnpm/seedrandom@3.0.5/node_modules/seedrandom/lib/xor128.js"(e,t){(function(n,s,r){function a(l){var u=this,c="";u.x=0,u.y=0,u.z=0,u.w=0,u.next=function(){var p=u.x^u.x<<11;return u.x=u.y,u.y=u.z,u.z=u.w,u.w^=u.w>>>19^p^p>>>8},l===(l|0)?u.x=l:c+=l;for(var d=0;d<c.length+64;d++)u.x^=c.charCodeAt(d)|0,u.next()}function o(l,u){return u.x=l.x,u.y=l.y,u.z=l.z,u.w=l.w,u}function i(l,u){var c=new a(l),d=u&&u.state,p=function(){return(c.next()>>>0)/4294967296};return p.double=function(){do var h=c.next()>>>11,f=(c.next()>>>0)/4294967296,m=(h+f)/(1<<21);while(m===0);return m},p.int32=c.next,p.quick=p,d&&(typeof d=="object"&&o(d,c),p.state=function(){return o(c,{})}),p}s&&s.exports?s.exports=i:r&&r.amd?r(function(){return i}):this.xor128=i})(e,typeof t=="object"&&t,typeof define=="function"&&define)}}),TS=It({"node_modules/.pnpm/seedrandom@3.0.5/node_modules/seedrandom/lib/xorwow.js"(e,t){(function(n,s,r){function a(l){var u=this,c="";u.next=function(){var p=u.x^u.x>>>2;return u.x=u.y,u.y=u.z,u.z=u.w,u.w=u.v,(u.d=u.d+362437|0)+(u.v=u.v^u.v<<4^(p^p<<1))|0},u.x=0,u.y=0,u.z=0,u.w=0,u.v=0,l===(l|0)?u.x=l:c+=l;for(var d=0;d<c.length+64;d++)u.x^=c.charCodeAt(d)|0,d==c.length&&(u.d=u.x<<10^u.x>>>4),u.next()}function o(l,u){return u.x=l.x,u.y=l.y,u.z=l.z,u.w=l.w,u.v=l.v,u.d=l.d,u}function i(l,u){var c=new a(l),d=u&&u.state,p=function(){return(c.next()>>>0)/4294967296};return p.double=function(){do var h=c.next()>>>11,f=(c.next()>>>0)/4294967296,m=(h+f)/(1<<21);while(m===0);return m},p.int32=c.next,p.quick=p,d&&(typeof d=="object"&&o(d,c),p.state=function(){return o(c,{})}),p}s&&s.exports?s.exports=i:r&&r.amd?r(function(){return i}):this.xorwow=i})(e,typeof t=="object"&&t,typeof define=="function"&&define)}}),NS=It({"node_modules/.pnpm/seedrandom@3.0.5/node_modules/seedrandom/lib/xorshift7.js"(e,t){(function(n,s,r){function a(l){var u=this;u.next=function(){var d=u.x,p=u.i,h,f,m;return h=d[p],h^=h>>>7,f=h^h<<24,h=d[p+1&7],f^=h^h>>>10,h=d[p+3&7],f^=h^h>>>3,h=d[p+4&7],f^=h^h<<7,h=d[p+7&7],h=h^h<<13,f^=h^h<<9,d[p]=f,u.i=p+1&7,f};function c(d,p){var h,f,m=[];if(p===(p|0))f=m[0]=p;else for(p=""+p,h=0;h<p.length;++h)m[h&7]=m[h&7]<<15^p.charCodeAt(h)+m[h+1&7]<<13;for(;m.length<8;)m.push(0);for(h=0;h<8&&m[h]===0;++h);for(h==8?f=m[7]=-1:f=m[h],d.x=m,d.i=0,h=256;h>0;--h)d.next()}c(u,l)}function o(l,u){return u.x=l.x.slice(),u.i=l.i,u}function i(l,u){l==null&&(l=+new Date);var c=new a(l),d=u&&u.state,p=function(){return(c.next()>>>0)/4294967296};return p.double=function(){do var h=c.next()>>>11,f=(c.next()>>>0)/4294967296,m=(h+f)/(1<<21);while(m===0);return m},p.int32=c.next,p.quick=p,d&&(d.x&&o(d,c),p.state=function(){return o(c,{})}),p}s&&s.exports?s.exports=i:r&&r.amd?r(function(){return i}):this.xorshift7=i})(e,typeof t=="object"&&t,typeof define=="function"&&define)}}),ES=It({"node_modules/.pnpm/seedrandom@3.0.5/node_modules/seedrandom/lib/xor4096.js"(e,t){(function(n,s,r){function a(l){var u=this;u.next=function(){var d=u.w,p=u.X,h=u.i,f,m;return u.w=d=d+1640531527|0,m=p[h+34&127],f=p[h=h+1&127],m^=m<<13,f^=f<<17,m^=m>>>15,f^=f>>>12,m=p[h]=m^f,u.i=h,m+(d^d>>>16)|0};function c(d,p){var h,f,m,g,A,y=[],x=128;for(p===(p|0)?(f=p,p=null):(p=p+"\0",f=0,x=Math.max(x,p.length)),m=0,g=-32;g<x;++g)p&&(f^=p.charCodeAt((g+32)%p.length)),g===0&&(A=f),f^=f<<10,f^=f>>>15,f^=f<<4,f^=f>>>13,g>=0&&(A=A+1640531527|0,h=y[g&127]^=f+A,m=h==0?m+1:0);for(m>=128&&(y[(p&&p.length||0)&127]=-1),m=127,g=4*128;g>0;--g)f=y[m+34&127],h=y[m=m+1&127],f^=f<<13,h^=h<<17,f^=f>>>15,h^=h>>>12,y[m]=f^h;d.w=A,d.X=y,d.i=m}c(u,l)}function o(l,u){return u.i=l.i,u.w=l.w,u.X=l.X.slice(),u}function i(l,u){l==null&&(l=+new Date);var c=new a(l),d=u&&u.state,p=function(){return(c.next()>>>0)/4294967296};return p.double=function(){do var h=c.next()>>>11,f=(c.next()>>>0)/4294967296,m=(h+f)/(1<<21);while(m===0);return m},p.int32=c.next,p.quick=p,d&&(d.X&&o(d,c),p.state=function(){return o(c,{})}),p}s&&s.exports?s.exports=i:r&&r.amd?r(function(){return i}):this.xor4096=i})(e,typeof t=="object"&&t,typeof define=="function"&&define)}}),RS=It({"node_modules/.pnpm/seedrandom@3.0.5/node_modules/seedrandom/lib/tychei.js"(e,t){(function(n,s,r){function a(l){var u=this,c="";u.next=function(){var p=u.b,h=u.c,f=u.d,m=u.a;return p=p<<25^p>>>7^h,h=h-f|0,f=f<<24^f>>>8^m,m=m-p|0,u.b=p=p<<20^p>>>12^h,u.c=h=h-f|0,u.d=f<<16^h>>>16^m,u.a=m-p|0},u.a=0,u.b=0,u.c=2654435769|0,u.d=1367130551,l===Math.floor(l)?(u.a=l/4294967296|0,u.b=l|0):c+=l;for(var d=0;d<c.length+20;d++)u.b^=c.charCodeAt(d)|0,u.next()}function o(l,u){return u.a=l.a,u.b=l.b,u.c=l.c,u.d=l.d,u}function i(l,u){var c=new a(l),d=u&&u.state,p=function(){return(c.next()>>>0)/4294967296};return p.double=function(){do var h=c.next()>>>11,f=(c.next()>>>0)/4294967296,m=(h+f)/(1<<21);while(m===0);return m},p.int32=c.next,p.quick=p,d&&(typeof d=="object"&&o(d,c),p.state=function(){return o(c,{})}),p}s&&s.exports?s.exports=i:r&&r.amd?r(function(){return i}):this.tychei=i})(e,typeof t=="object"&&t,typeof define=="function"&&define)}}),DS=It({"node_modules/.pnpm/seedrandom@3.0.5/node_modules/seedrandom/seedrandom.js"(e,t){(function(n,s,r){var a=256,o=6,i=52,l="random",u=r.pow(a,o),c=r.pow(2,i),d=c*2,p=a-1,h;function f(v,k,S){var C=[];k=k==!0?{entropy:!0}:k||{};var D=y(A(k.entropy?[v,b(s)]:v==null?x():v,3),C),O=new m(C),E=function(){for(var R=O.g(o),T=u,P=0;R<c;)R=(R+P)*a,T*=a,P=O.g(1);for(;R>=d;)R/=2,T/=2,P>>>=1;return(R+P)/T};return E.int32=function(){return O.g(4)|0},E.quick=function(){return O.g(4)/4294967296},E.double=E,y(b(O.S),s),(k.pass||S||function(R,T,P,U){return U&&(U.S&&g(U,O),R.state=function(){return g(O,{})}),P?(r[l]=R,T):R})(E,D,"global"in k?k.global:this==r,k.state)}function m(v){var k,S=v.length,C=this,D=0,O=C.i=C.j=0,E=C.S=[];for(S||(v=[S++]);D<a;)E[D]=D++;for(D=0;D<a;D++)E[D]=E[O=p&O+v[D%S]+(k=E[D])],E[O]=k;(C.g=function(R){for(var T,P=0,U=C.i,j=C.j,q=C.S;R--;)T=q[U=p&U+1],P=P*a+q[p&(q[U]=q[j=p&j+T])+(q[j]=T)];return C.i=U,C.j=j,P})(a)}function g(v,k){return k.i=v.i,k.j=v.j,k.S=v.S.slice(),k}function A(v,k){var S=[],C=typeof v,D;if(k&&C=="object")for(D in v)try{S.push(A(v[D],k-1))}catch(O){}return S.length?S:C=="string"?v:v+"\0"}function y(v,k){for(var S=v+"",C,D=0;D<S.length;)k[p&D]=p&(C^=k[p&D]*19)+S.charCodeAt(D++);return b(k)}function x(){try{var v;return h&&(v=h.randomBytes)?v=v(a):(v=new Uint8Array(a),(n.crypto||n.msCrypto).getRandomValues(v)),b(v)}catch(C){var k=n.navigator,S=k&&k.plugins;return[+new Date,n,S,n.screen,b(s)]}}function b(v){return String.fromCharCode.apply(0,v)}if(y(r.random(),s),typeof t=="object"&&t.exports){t.exports=f;try{h=Kx()}catch(v){}}else typeof define=="function"&&define.amd?define(function(){return f}):r["seed"+l]=f})(typeof self!="undefined"?self:e,[],Math)}}),Yx=It({"node_modules/.pnpm/seedrandom@3.0.5/node_modules/seedrandom/index.js"(e,t){var n=SS(),s=CS(),r=TS(),a=NS(),o=ES(),i=RS(),l=DS();l.alea=n,l.xor128=s,l.xorwow=r,l.xorshift7=a,l.xor4096=o,l.tychei=i,t.exports=l}}),Jx=It({"(disabled):node_modules/.pnpm/string_decoder@1.1.1/node_modules/string_decoder/lib/string_decoder.js"(){}}),ju=It({"(disabled):path"(){}}),_S=It({"(disabled):worker_threads"(){}}),$S=It({"(disabled):perf_hooks"(){}}),FS=It({"node_modules/.pnpm/@tensorflow+tfjs-backend-wasm@3.9.0_@tensorflow+tfjs-core@3.9.0/node_modules/@tensorflow/tfjs-backend-wasm/wasm-out/tfjs-backend-wasm-threaded-simd.js"(e,t){var n=function(){var s=typeof document!="undefined"&&document.currentScript?document.currentScript.src:void 0;return typeof __filename!="undefined"&&(s=s||__filename),function(r){r=r||{};function a(){return Q.buffer!=Xe&&pn(Q.buffer),Pn}function o(){return Q.buffer!=Xe&&pn(Q.buffer),Et}function i(){return Q.buffer!=Xe&&pn(Q.buffer),Ns}function l(){return Q.buffer!=Xe&&pn(Q.buffer),wn}function u(){return Q.buffer!=Xe&&pn(Q.buffer),ms}var c=typeof r!="undefined"?r:{},d,p;c.ready=new Promise(function(N,F){d=N,p=F});var h={},f;for(f in c)c.hasOwnProperty(f)&&(h[f]=c[f]);var m=[],g="./this.program",A=function(N,F){throw F},y=!1,x=!1,b=!1,v=!1;y=typeof window=="object",x=typeof importScripts=="function",b=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string",v=!y&&!b&&!x;var k=c.ENVIRONMENT_IS_PTHREAD||!1;k&&(Xe=c.buffer);var S="";function C(N){return c.locateFile?c.locateFile(N,S):S+N}var D,O,E,R,T,P;if(b){x?S=ju().dirname(S)+"/":S=__dirname+"/",D=function(F,B){return T||(T=Di("fs")),P||(P=ju()),F=P.normalize(F),T.readFileSync(F,B?null:"utf8")},E=function(F){var B=D(F,!0);return B.buffer||(B=new Uint8Array(B)),xe(B.buffer),B},process.argv.length>1&&(g=process.argv[1].replace(/\\/g,"/")),m=process.argv.slice(2),process.on("uncaughtException",function(N){if(!(N instanceof Vu))throw N}),process.on("unhandledRejection",br),A=function(N){process.exit(N)},c.inspect=function(){return"[Emscripten Module object]"};var U;try{U=_S()}catch(N){throw console.error('The "worker_threads" module is not supported in this node.js build - perhaps a newer version is needed?'),N}global.Worker=U.Worker}else v?(typeof read!="undefined"&&(D=function(F){return read(F)}),E=function(F){var B;return typeof readbuffer=="function"?new Uint8Array(readbuffer(F)):(B=read(F,"binary"),xe(typeof B=="object"),B)},typeof scriptArgs!="undefined"?m=scriptArgs:typeof arguments!="undefined"&&(m=arguments),typeof quit=="function"&&(A=function(N){quit(N)}),typeof print!="undefined"&&(typeof console=="undefined"&&(console={}),console.log=print,console.warn=console.error=typeof printErr!="undefined"?printErr:print)):(y||x)&&(x?S=self.location.href:typeof document!="undefined"&&document.currentScript&&(S=document.currentScript.src),typeof s!="undefined"&&s&&(S=s),S.indexOf("blob:")!==0?S=S.substr(0,S.lastIndexOf("/")+1):S="",b?(D=function(F,B){return T||(T=Di("fs")),P||(P=ju()),F=P.normalize(F),T.readFileSync(F,B?null:"utf8")},E=function(F){var B=D(F,!0);return B.buffer||(B=new Uint8Array(B)),xe(B.buffer),B}):(D=function(N){var F=new XMLHttpRequest;return F.open("GET",N,!1),F.send(null),F.responseText},x&&(E=function(N){var F=new XMLHttpRequest;return F.open("GET",N,!1),F.responseType="arraybuffer",F.send(null),new Uint8Array(F.response)}),O=function(N,F,B){var K=new XMLHttpRequest;K.open("GET",N,!0),K.responseType="arraybuffer",K.onload=function(){if(K.status==200||K.status==0&&K.response){F(K.response);return}B()},K.onerror=B,K.send(null)}),R=function(N){document.title=N});b&&typeof performance=="undefined"&&(global.performance=$S().performance);var j=c.print||console.log.bind(console),q=c.printErr||console.warn.bind(console);for(f in h)h.hasOwnProperty(f)&&(c[f]=h[f]);h=null,c.arguments&&(m=c.arguments),c.thisProgram&&(g=c.thisProgram),c.quit&&(A=c.quit);var X=Atomics.load,te=Atomics.store,ne=Atomics.compareExchange,se;c.wasmBinary&&(se=c.wasmBinary);var re=c.noExitRuntime||!0;typeof WebAssembly!="object"&&br("no native wasm support detected");var Q,ue,ce=!1,fe;function xe(N,F){N||br("Assertion failed: "+F)}function Ne(N){var F=c["_"+N];return xe(F,"Cannot call unknown function "+N+", make sure it is exported"),F}function Ee(N,F,B,K,Ae){var me={string:function(kn){var Ri=0;if(kn!=null&&kn!==0){var Gx=(kn.length<<2)+1;Ri=Ti(Gx),at(kn,Ri,Gx)}return Ri},array:function(kn){var Ri=Ti(kn.length);return st(kn,Ri),Ri}};function ge(kn){return F==="string"?Me(kn):F==="boolean"?Boolean(kn):kn}var Ie=Ne(N),it=[],nn=0;if(K)for(var Xt=0;Xt<K.length;Xt++){var Xr=me[B[Xt]];Xr?(nn===0&&(nn=Wu()),it[Xt]=Xr(K[Xt])):it[Xt]=K[Xt]}var Ei=Ie.apply(null,it);return Ei=ge(Ei),nn!==0&&Ci(nn),Ei}function Oe(N,F,B,K){B=B||[];var Ae=B.every(function(ge){return ge==="number"}),me=F!=="string";return me&&Ae&&!K?Ne(N):function(){return Ee(N,F,B,arguments,K)}}function Be(N,F,B){for(var K=F+B,Ae="";!(F>=K);){var me=N[F++];if(!me)return Ae;if(!(me&128)){Ae+=String.fromCharCode(me);continue}var ge=N[F++]&63;if((me&224)==192){Ae+=String.fromCharCode((me&31)<<6|ge);continue}var Ie=N[F++]&63;if((me&240)==224?me=(me&15)<<12|ge<<6|Ie:me=(me&7)<<18|ge<<12|Ie<<6|N[F++]&63,me<65536)Ae+=String.fromCharCode(me);else{var it=me-65536;Ae+=String.fromCharCode(55296|it>>10,56320|it&1023)}}return Ae}function Me(N,F){return N?Be(o(),N,F):""}function ht(N,F,B,K){if(!(K>0))return 0;for(var Ae=B,me=B+K-1,ge=0;ge<N.length;++ge){var Ie=N.charCodeAt(ge);if(Ie>=55296&&Ie<=57343){var it=N.charCodeAt(++ge);Ie=65536+((Ie&1023)<<10)|it&1023}if(Ie<=127){if(B>=me)break;F[B++]=Ie}else if(Ie<=2047){if(B+1>=me)break;F[B++]=192|Ie>>6,F[B++]=128|Ie&63}else if(Ie<=65535){if(B+2>=me)break;F[B++]=224|Ie>>12,F[B++]=128|Ie>>6&63,F[B++]=128|Ie&63}else{if(B+3>=me)break;F[B++]=240|Ie>>18,F[B++]=128|Ie>>12&63,F[B++]=128|Ie>>6&63,F[B++]=128|Ie&63}}return F[B]=0,B-Ae}function at(N,F,B){return ht(N,o(),F,B)}function ot(N){for(var F=0,B=0;B<N.length;++B){var K=N.charCodeAt(B);K>=55296&&K<=57343&&(K=65536+((K&1023)<<10)|N.charCodeAt(++B)&1023),K<=127?++F:K<=2047?F+=2:K<=65535?F+=3:F+=4}return F}function st(N,F){a().set(N,F)}function dt(N,F){return N%F>0&&(N+=F-N%F),N}var Xe,Pn,Et,Zn,dn,Ns,wn,fs,ms;function pn(N){Xe=N,c.HEAP8=Pn=new Int8Array(N),c.HEAP16=Zn=new Int16Array(N),c.HEAP32=Ns=new Int32Array(N),c.HEAPU8=Et=new Uint8Array(N),c.HEAPU16=dn=new Uint16Array(N),c.HEAPU32=wn=new Uint32Array(N),c.HEAPF32=fs=new Float32Array(N),c.HEAPF64=ms=new Float64Array(N)}var gs=c.INITIAL_MEMORY||16777216;if(k)Q=c.wasmMemory,Xe=c.buffer;else if(c.wasmMemory)Q=c.wasmMemory;else if(Q=new WebAssembly.Memory({initial:gs/65536,maximum:2147483648/65536,shared:!0}),!(Q.buffer instanceof SharedArrayBuffer))throw q("requested a shared WebAssembly.Memory but the returned buffer is not a SharedArrayBuffer, indicating that while the browser has SharedArrayBuffer it does not have WebAssembly threads support - you may need to set a flag"),b&&console.log("(on node you may need: --experimental-wasm-threads --experimental-wasm-bulk-memory and also use a recent version)"),Error("bad memory");Q&&(Xe=Q.buffer),gs=Xe.byteLength,pn(Xe);var As,Yn=[],Qs=[],yr=[],Ur=[],bi=[],er=!1,Ld=!1;k||Qs.push({func:function(){ep()}});function _0(){if(!k){if(c.preRun)for(typeof c.preRun=="function"&&(c.preRun=[c.preRun]);c.preRun.length;)Wd(c.preRun.shift());wi(Yn)}}function _u(){er=!0,!k&&wi(Qs)}function $0(){k||wi(yr)}function Bd(){k||(Ld=!0)}function Mn(){if(!k){if(c.postRun)for(typeof c.postRun=="function"&&(c.postRun=[c.postRun]);c.postRun.length;)F0(c.postRun.shift());wi(bi)}}function Wd(N){Yn.unshift(N)}function F0(N){bi.unshift(N)}var xr=0,Hr=null,Na=null;function O0(N){xe(!k,"addRunDependency cannot be used in a pthread worker"),xr++,c.monitorRunDependencies&&c.monitorRunDependencies(xr)}function P0(N){if(xr--,c.monitorRunDependencies&&c.monitorRunDependencies(xr),xr==0&&(Hr!==null&&(clearInterval(Hr),Hr=null),Na)){var F=Na;Na=null,F()}}c.preloadedImages={},c.preloadedAudios={};function br(N){c.onAbort&&c.onAbort(N),k&&console.error("Pthread aborting at "+new Error().stack),N+="",q(N),ce=!0,fe=1,N="abort("+N+"). Build with -s ASSERTIONS=1 for more info.";var F=new WebAssembly.RuntimeError(N);throw p(F),F}function Vd(N,F){return String.prototype.startsWith?N.startsWith(F):N.indexOf(F)===0}var vi="data:application/octet-stream;base64,";function Ud(N){return Vd(N,vi)}var M0="file://";function Hd(N){return Vd(N,M0)}var zn="tfjs-backend-wasm-threaded-simd.wasm";Ud(zn)||(zn=C(zn));function Gd(N){try{if(N==zn&&se)return new Uint8Array(se);if(E)return E(N);throw"both async and sync fetching of the wasm failed"}catch(F){br(F)}}function z0(){if(!se&&(y||x)){if(typeof fetch=="function"&&!Hd(zn))return fetch(zn,{credentials:"same-origin"}).then(function(N){if(!N.ok)throw"failed to load wasm binary file at '"+zn+"'";return N.arrayBuffer()}).catch(function(){return Gd(zn)});if(O)return new Promise(function(N,F){O(zn,function(B){N(new Uint8Array(B))},F)})}return Promise.resolve().then(function(){return Gd(zn)})}function L0(){var N={a:Em};function F(ge,Ie){var it=ge.exports;if(c.asm=it,As=c.asm.F,ue=Ie,!k){var nn=Te.unusedWorkers.length;Te.unusedWorkers.forEach(function(Xt){Te.loadWasmModuleToWorker(Xt,function(){--nn||P0("wasm-instantiate")})})}}k||O0("wasm-instantiate");function B(ge){F(ge.instance,ge.module)}function K(ge){return z0().then(function(Ie){return WebAssembly.instantiate(Ie,N)}).then(ge,function(Ie){q("failed to asynchronously prepare wasm: "+Ie),br(Ie)})}function Ae(){return!se&&typeof WebAssembly.instantiateStreaming=="function"&&!Ud(zn)&&!Hd(zn)&&typeof fetch=="function"?fetch(zn,{credentials:"same-origin"}).then(function(ge){var Ie=WebAssembly.instantiateStreaming(ge,N);return Ie.then(B,function(it){return q("wasm streaming compile failed: "+it),q("falling back to ArrayBuffer instantiation"),K(B)})}):K(B)}if(c.instantiateWasm)try{var me=c.instantiateWasm(N,F);return me}catch(ge){return q("Module.instantiateWasm callback failed with error: "+ge),!1}return Ae().catch(p),{}}var B0={10024:function(){throw"Canceled!"},10042:function(N,F){setTimeout(function(){Lx(N,F)},0)}};function jd(){Te.initRuntime()}function wi(N){for(;N.length>0;){var F=N.shift();if(typeof F=="function"){F(c);continue}var B=F.func;typeof B=="number"?F.arg===void 0?As.get(B)():As.get(B)(F.arg):B(F.arg===void 0?null:F.arg)}}function $u(N,F){if(N<=0||N>a().length||N&!0||F<0)return-28;if(F==0)return 0;F>=2147483647&&(F=1/0);var B=Atomics.load(i(),Ni>>2),K=0;if(B==N){var Ae=Atomics.compareExchange(i(),Ni>>2,B,0);if(Ae==B&&(--F,K=1,F<=0))return 1}var me=Atomics.notify(i(),N>>2,F);if(me>=0)return me+K;throw"Atomics.notify returned an unexpected value "+me}c._emscripten_futex_wake=$u;function W0(N){if(k)throw"Internal Error! killThread() can only ever be called from main application thread!";if(!N)throw"Internal Error! Null pthread_ptr in killThread!";i()[N+12>>2]=0;var F=Te.pthreads[N];F.worker.terminate(),Te.freeThreadData(F),Te.runningWorkers.splice(Te.runningWorkers.indexOf(F.worker),1),F.worker.pthread=void 0}function V0(N){if(k)throw"Internal Error! cancelThread() can only ever be called from main application thread!";if(!N)throw"Internal Error! Null pthread_ptr in cancelThread!";var F=Te.pthreads[N];F.worker.postMessage({cmd:"cancel"})}function U0(N){if(k)throw"Internal Error! cleanupThread() can only ever be called from main application thread!";if(!N)throw"Internal Error! Null pthread_ptr in cleanupThread!";var F=Te.pthreads[N];if(F){i()[N+12>>2]=0;var B=F.worker;Te.returnWorkerToPool(B)}}var Te={unusedWorkers:[],runningWorkers:[],initMainThreadBlock:function(){for(var N=Math.min(4,Math.max(1,(navigator.hardwareConcurrency||1)/2)),F=0;F<N;++F)Te.allocateUnusedWorker()},initRuntime:function(){for(var N=Ra(228),F=0;F<228/4;++F)l()[N/4+F]=0;i()[N+12>>2]=N;var B=N+152;i()[B>>2]=B;for(var K=Ra(512),F=0;F<128;++F)l()[K/4+F]=0;Atomics.store(l(),N+100>>2,K),Atomics.store(l(),N+40>>2,N),ng(N,!x,1),zx(N)},initWorker:function(){},pthreads:{},threadExitHandlers:[],setThreadStatus:function(){},runExitHandlers:function(){for(;Te.threadExitHandlers.length>0;)Te.threadExitHandlers.pop()();k&&Si()&&Mx()},runExitHandlersAndDeinitThread:function(N,F){Atomics.store(l(),N+56>>2,1),Atomics.store(l(),N+60>>2,0),Te.runExitHandlers(),Atomics.store(l(),N+4>>2,F),Atomics.store(l(),N+0>>2,1),$u(N+0,2147483647),ng(0,0,0)},threadExit:function(N){var F=Si();F&&(Te.runExitHandlersAndDeinitThread(F,N),k&&postMessage({cmd:"exit"}))},threadCancel:function(){Te.runExitHandlersAndDeinitThread(Si(),-1),postMessage({cmd:"cancelDone"})},terminateAllThreads:function(){for(var N in Te.pthreads){var F=Te.pthreads[N];F&&F.worker&&Te.returnWorkerToPool(F.worker)}Te.pthreads={};for(var B=0;B<Te.unusedWorkers.length;++B){var K=Te.unusedWorkers[B];K.terminate()}Te.unusedWorkers=[];for(var B=0;B<Te.runningWorkers.length;++B){var K=Te.runningWorkers[B],F=K.pthread;Te.freeThreadData(F),K.terminate()}Te.runningWorkers=[]},freeThreadData:function(N){if(!!N){if(N.threadInfoStruct){var F=i()[N.threadInfoStruct+100>>2];i()[N.threadInfoStruct+100>>2]=0,Bu(F),Bu(N.threadInfoStruct)}N.threadInfoStruct=0,N.allocatedOwnStack&&N.stackBase&&Bu(N.stackBase),N.stackBase=0,N.worker&&(N.worker.pthread=null)}},returnWorkerToPool:function(N){Te.runWithoutMainThreadQueuedCalls(function(){delete Te.pthreads[N.pthread.threadInfoStruct],Te.unusedWorkers.push(N),Te.runningWorkers.splice(Te.runningWorkers.indexOf(N),1),Te.freeThreadData(N.pthread),N.pthread=void 0})},runWithoutMainThreadQueuedCalls:function(N){i()[Hx>>2]=0;try{N()}finally{i()[Hx>>2]=1}},receiveObjectTransfer:function(N){},loadWasmModuleToWorker:function(N,F){N.onmessage=function(B){var K=B.data,Ae=K.cmd;if(N.pthread&&(Te.currentProxiedOperationCallerThread=N.pthread.threadInfoStruct),K.targetThread&&K.targetThread!=Si()){var me=Te.pthreads[K.targetThread];me?me.worker.postMessage(B.data,K.transferList):console.error('Internal error! Worker sent a message "'+Ae+'" to target pthread '+K.targetThread+", but that thread no longer exists!"),Te.currentProxiedOperationCallerThread=void 0;return}if(Ae==="processQueuedMainThreadWork")eg();else if(Ae==="spawnThread")Jd(B.data);else if(Ae==="cleanupThread")U0(K.thread);else if(Ae==="killThread")W0(K.thread);else if(Ae==="cancelThread")V0(K.thread);else if(Ae==="loaded")N.loaded=!0,F&&F(N),N.runPthread&&(N.runPthread(),delete N.runPthread);else if(Ae==="print")j("Thread "+K.threadId+": "+K.text);else if(Ae==="printErr")q("Thread "+K.threadId+": "+K.text);else if(Ae==="alert")alert("Thread "+K.threadId+": "+K.text);else if(Ae==="exit"){var ge=N.pthread&&Atomics.load(l(),N.pthread.threadInfoStruct+64>>2);ge&&Te.returnWorkerToPool(N)}else if(Ae==="exitProcess")try{iS(K.returnCode)}catch(Ie){if(Ie instanceof Vu)return;throw Ie}else Ae==="cancelDone"?Te.returnWorkerToPool(N):Ae==="objectTransfer"?Te.receiveObjectTransfer(B.data):B.data.target==="setimmediate"?N.postMessage(B.data):q("worker sent an unknown command "+Ae);Te.currentProxiedOperationCallerThread=void 0},N.onerror=function(B){q("pthread sent an error! "+B.filename+":"+B.lineno+": "+B.message)},b&&(N.on("message",function(B){N.onmessage({data:B})}),N.on("error",function(B){N.onerror(B)}),N.on("exit",function(B){})),N.postMessage({cmd:"load",urlOrBlob:c.mainScriptUrlOrBlob||s,wasmMemory:Q,wasmModule:ue})},allocateUnusedWorker:function(){var N=C("tfjs-backend-wasm-threaded-simd.worker.js");Te.unusedWorkers.push(new Worker(N))},getNewWorker:function(){return Te.unusedWorkers.length==0&&(Te.allocateUnusedWorker(),Te.loadWasmModuleToWorker(Te.unusedWorkers[0])),Te.unusedWorkers.length>0?Te.unusedWorkers.pop():null},busySpinWait:function(N){for(var F=performance.now()+N;performance.now()<F;);}};function H0(N,F){Vx(N,F),Ci(N)}c.establishStackSpace=H0;function G0(){return re}c.getNoExitRuntime=G0;function j0(N,F){return As.get(N)(F)}c.invokeEntryPoint=j0;function q0(N,F,B,K){br("Assertion failed: "+Me(N)+", at: "+[F?Me(F):"unknown filename",B,K?Me(K):"unknown function"])}function X0(N,F){var B=_main(N,F)}var Ea;b?Ea=function(){var N=process.hrtime();return N[0]*1e3+N[1]/1e6}:k?Ea=function(){return performance.now()-c.__performance_now_clock_drift}:typeof dateNow!="undefined"?Ea=dateNow:Ea=function(){return performance.now()};function K0(N){return i()[Ox()>>2]=N,N}function Z0(N,F){if(k)return Gr(1,1,N,F)}function Y0(N,F){if(N==F)postMessage({cmd:"processQueuedMainThreadWork"});else if(k)postMessage({targetThread:N,cmd:"processThreadQueue"});else{var B=Te.pthreads[N],K=B&&B.worker;if(!K)return;K.postMessage({cmd:"processThreadQueue"})}return 1}function J0(){br()}function Q0(N,F,B){var K=rm(F,B);return B0[N].apply(null,K)}function em(N,F){}function tm(N,F,B){if(N<=0||N>a().length||N&!0)return-28;if(y){if(Atomics.load(i(),N>>2)!=F)return-6;for(var Ae=performance.now(),me=Ae+B,ge=Atomics.exchange(i(),Ni>>2,N);;){if(Ae=performance.now(),Ae>me)return ge=Atomics.exchange(i(),Ni>>2,0),-73;if(ge=Atomics.exchange(i(),Ni>>2,0),ge==0)break;if(eg(),Atomics.load(i(),N>>2)!=F)return-6;ge=Atomics.exchange(i(),Ni>>2,N)}return 0}else{var K=Atomics.wait(i(),N>>2,F,B);if(K==="timed-out")return-73;if(K==="not-equal")return-6;if(K==="ok")return 0;throw"Atomics.wait returned an unexpected value "+K}}function nm(N,F,B){o().copyWithin(N,F,F+B)}function sm(){return b?Di("os").cpus().length:navigator.hardwareConcurrency}function Gr(N,F){for(var B=arguments.length-2,K=Wu(),Ae=B,me=Ti(Ae*8),ge=me>>3,Ie=0;Ie<B;Ie++){var it=arguments[2+Ie];u()[ge+Ie]=it}var nn=Wx(N,Ae,me,F);return Ci(K),nn}var Fu=[],Ou=[];function rm(N,F){Ou.length=0;var B;for(F>>=2;B=o()[N++];){var K=B<105;K&&F&1&&F++,Ou.push(K?u()[F++>>1]:i()[F]),++F}return Ou}function am(N,F,B){Fu.length=F;for(var K=B>>3,Ae=0;Ae<F;Ae++)Fu[Ae]=u()[K+Ae];var me=N<0,ge=me?B0[-N-1]:Nm[N];return ge.apply(null,Fu)}function om(){return o().length}function im(N){try{return Q.grow(N-Xe.byteLength+65535>>>16),pn(Q.buffer),1}catch(F){}}function lm(N){var F=om();if(N<=F)return!1;var B=2147483648;if(N>B)return!1;for(var K=1;K<=4;K*=2){var Ae=F*(1+.2/K);Ae=Math.min(Ae,N+100663296);var me=Math.min(B,dt(Math.max(N,Ae),65536)),ge=im(me);if(ge)return!0}return!1}var Ve={inEventHandler:0,removeAllEventListeners:function(){for(var N=Ve.eventHandlers.length-1;N>=0;--N)Ve._removeHandler(N);Ve.eventHandlers=[],Ve.deferredCalls=[]},registerRemoveEventListeners:function(){Ve.removeEventListenersRegistered||(Ur.push(Ve.removeAllEventListeners),Ve.removeEventListenersRegistered=!0)},deferredCalls:[],deferCall:function(N,F,B){function K(ge,Ie){if(ge.length!=Ie.length)return!1;for(var it in ge)if(ge[it]!=Ie[it])return!1;return!0}for(var Ae in Ve.deferredCalls){var me=Ve.deferredCalls[Ae];if(me.targetFunction==N&&K(me.argsList,B))return}Ve.deferredCalls.push({targetFunction:N,precedence:F,argsList:B}),Ve.deferredCalls.sort(function(ge,Ie){return ge.precedence<Ie.precedence})},removeDeferredCalls:function(N){for(var F=0;F<Ve.deferredCalls.length;++F)Ve.deferredCalls[F].targetFunction==N&&(Ve.deferredCalls.splice(F,1),--F)},canPerformEventHandlerRequests:function(){return Ve.inEventHandler&&Ve.currentEventHandler.allowsDeferredCalls},runDeferredCalls:function(){if(!!Ve.canPerformEventHandlerRequests())for(var N=0;N<Ve.deferredCalls.length;++N){var F=Ve.deferredCalls[N];Ve.deferredCalls.splice(N,1),--N,F.targetFunction.apply(null,F.argsList)}},eventHandlers:[],removeAllHandlersOnTarget:function(N,F){for(var B=0;B<Ve.eventHandlers.length;++B)Ve.eventHandlers[B].target==N&&(!F||F==Ve.eventHandlers[B].eventTypeString)&&Ve._removeHandler(B--)},_removeHandler:function(N){var F=Ve.eventHandlers[N];F.target.removeEventListener(F.eventTypeString,F.eventListenerFunc,F.useCapture),Ve.eventHandlers.splice(N,1)},registerOrRemoveHandler:function(N){var F=function(Ae){++Ve.inEventHandler,Ve.currentEventHandler=N,Ve.runDeferredCalls(),N.handlerFunc(Ae),Ve.runDeferredCalls(),--Ve.inEventHandler};if(N.callbackfunc)N.eventListenerFunc=F,N.target.addEventListener(N.eventTypeString,F,N.useCapture),Ve.eventHandlers.push(N),Ve.registerRemoveEventListeners();else for(var B=0;B<Ve.eventHandlers.length;++B)Ve.eventHandlers[B].target==N.target&&Ve.eventHandlers[B].eventTypeString==N.eventTypeString&&Ve._removeHandler(B--)},queueEventHandlerOnThread_iiii:function(N,F,B,K,Ae){var me=Wu(),ge=Ti(12);i()[ge>>2]=B,i()[ge+4>>2]=K,i()[ge+8>>2]=Ae,tg(0,N,637534208,F,K,ge),Ci(me)},getTargetThreadForEventCallback:function(N){switch(N){case 1:return 0;case 2:return Te.currentProxiedOperationCallerThread;default:return N}},getNodeNameForTarget:function(N){return N?N==window?"#window":N==screen?"#screen":N&&N.nodeName?N.nodeName:"":""},fullscreenEnabled:function(){return document.fullscreenEnabled||document.webkitFullscreenEnabled}};function um(N){var F=ot(N)+1,B=Ra(F);return at(N,B,F),B}function cm(N,F,B,K){var Ae=Wu(),me=Ti(12),ge=0;F&&(ge=um(F)),i()[me>>2]=ge,i()[me+4>>2]=B,i()[me+8>>2]=K,tg(0,N,657457152,0,ge,me),Ci(Ae)}function dm(N,F,B,K){F=F?Me(F):"",cm(N,F,B,K)}function pm(N){return N>2?Me(N):N}var hm=[0,typeof document!="undefined"?document:0,typeof window!="undefined"?window:0];function fm(N){N=pm(N);var F=hm[N]||(typeof document!="undefined"?document.querySelector(N):void 0);return F}function Pu(N){return fm(N)}function qd(N,F,B){var K=Pu(N);if(!K)return-4;if(K.canvasSharedPtr&&(i()[K.canvasSharedPtr>>2]=F,i()[K.canvasSharedPtr+4>>2]=B),K.offscreenCanvas||!K.controlTransferredOffscreen){K.offscreenCanvas&&(K=K.offscreenCanvas);var Ae=!1;if(K.GLctxObject&&K.GLctxObject.GLctx){var me=K.GLctxObject.GLctx.getParameter(2978);Ae=me[0]===0&&me[1]===0&&me[2]===K.width&&me[3]===K.height}K.width=F,K.height=B,Ae&&K.GLctxObject.GLctx.viewport(0,0,F,B)}else if(K.canvasSharedPtr){var ge=i()[K.canvasSharedPtr+8>>2];return dm(ge,N,F,B),1}else return-4;return 0}function Xd(N,F,B){return k?Gr(2,1,N,F,B):qd(N,F,B)}function mm(N,F,B){var K=Pu(N);return K?qd(N,F,B):Xd(N,F,B)}function gm(N){}function Am(N,F){}function ym(N){var F=N.getExtension("ANGLE_instanced_arrays");if(F)return N.vertexAttribDivisor=function(B,K){F.vertexAttribDivisorANGLE(B,K)},N.drawArraysInstanced=function(B,K,Ae,me){F.drawArraysInstancedANGLE(B,K,Ae,me)},N.drawElementsInstanced=function(B,K,Ae,me,ge){F.drawElementsInstancedANGLE(B,K,Ae,me,ge)},1}function xm(N){var F=N.getExtension("OES_vertex_array_object");if(F)return N.createVertexArray=function(){return F.createVertexArrayOES()},N.deleteVertexArray=function(B){F.deleteVertexArrayOES(B)},N.bindVertexArray=function(B){F.bindVertexArrayOES(B)},N.isVertexArray=function(B){return F.isVertexArrayOES(B)},1}function bm(N){var F=N.getExtension("WEBGL_draw_buffers");if(F)return N.drawBuffers=function(B,K){F.drawBuffersWEBGL(B,K)},1}function vm(N){return!!(N.multiDrawWebgl=N.getExtension("WEBGL_multi_draw"))}var rt={counter:1,buffers:[],programs:[],framebuffers:[],renderbuffers:[],textures:[],uniforms:[],shaders:[],vaos:[],contexts:{},offscreenCanvases:{},timerQueriesEXT:[],programInfos:{},stringCache:{},unpackAlignment:4,recordError:function(F){rt.lastError||(rt.lastError=F)},getNewId:function(N){for(var F=rt.counter++,B=N.length;B<F;B++)N[B]=null;return F},getSource:function(N,F,B,K){for(var Ae="",me=0;me<F;++me){var ge=K?i()[K+me*4>>2]:-1;Ae+=Me(i()[B+me*4>>2],ge<0?void 0:ge)}return Ae},createContext:function(N,F){var B=N.getContext("webgl",F);if(!B)return 0;var K=rt.registerContext(B,F);return K},registerContext:function(N,F){var B=Ra(8);i()[B+4>>2]=Si();var K={handle:B,attributes:F,version:F.majorVersion,GLctx:N};return N.canvas&&(N.canvas.GLctxObject=K),rt.contexts[B]=K,(typeof F.enableExtensionsByDefault=="undefined"||F.enableExtensionsByDefault)&&rt.initExtensions(K),B},makeContextCurrent:function(N){return rt.currentContext=rt.contexts[N],c.ctx=jr=rt.currentContext&&rt.currentContext.GLctx,!(N&&!jr)},getContext:function(N){return rt.contexts[N]},deleteContext:function(N){rt.currentContext===rt.contexts[N]&&(rt.currentContext=null),typeof Ve=="object"&&Ve.removeAllHandlersOnTarget(rt.contexts[N].GLctx.canvas),rt.contexts[N]&&rt.contexts[N].GLctx.canvas&&(rt.contexts[N].GLctx.canvas.GLctxObject=void 0),Bu(rt.contexts[N].handle),rt.contexts[N]=null},initExtensions:function(N){if(N||(N=rt.currentContext),!N.initExtensionsDone){N.initExtensionsDone=!0;var F=N.GLctx;ym(F),xm(F),bm(F),F.disjointTimerQueryExt=F.getExtension("EXT_disjoint_timer_query"),vm(F);var B=F.getSupportedExtensions()||[];B.forEach(function(K){K.indexOf("lose_context")<0&&K.indexOf("debug")<0&&F.getExtension(K)})}},populateUniformTable:function(N){for(var F=rt.programs[N],B=rt.programInfos[N]={uniforms:{},maxUniformLength:0,maxAttributeLength:-1,maxUniformBlockNameLength:-1},K=B.uniforms,Ae=jr.getProgramParameter(F,35718),me=0;me<Ae;++me){var ge=jr.getActiveUniform(F,me),Ie=ge.name;B.maxUniformLength=Math.max(B.maxUniformLength,Ie.length+1),Ie.slice(-1)=="]"&&(Ie=Ie.slice(0,Ie.lastIndexOf("[")));var it=jr.getUniformLocation(F,Ie);if(it){var nn=rt.getNewId(rt.uniforms);K[Ie]=[ge.size,nn],rt.uniforms[nn]=it;for(var Xt=1;Xt<ge.size;++Xt){var Xr=Ie+"["+Xt+"]";it=jr.getUniformLocation(F,Xr),nn=rt.getNewId(rt.uniforms),rt.uniforms[nn]=it}}}}},wm=["default","low-power","high-performance"];function km(N,F){var B=F>>2,K=i()[B+(24>>2)],Ae={alpha:!!i()[B+(0>>2)],depth:!!i()[B+(4>>2)],stencil:!!i()[B+(8>>2)],antialias:!!i()[B+(12>>2)],premultipliedAlpha:!!i()[B+(16>>2)],preserveDrawingBuffer:!!i()[B+(20>>2)],powerPreference:wm[K],failIfMajorPerformanceCaveat:!!i()[B+(28>>2)],majorVersion:i()[B+(32>>2)],minorVersion:i()[B+(36>>2)],enableExtensionsByDefault:i()[B+(40>>2)],explicitSwapControl:i()[B+(44>>2)],proxyContextToMainThread:i()[B+(48>>2)],renderViaOffscreenBackBuffer:i()[B+(52>>2)]},me=Pu(N);if(!me||Ae.explicitSwapControl)return 0;var ge=rt.createContext(me,Ae);return ge}function Im(N,F){return km(N,F)}var ki={mappings:{},buffers:[null,[],[]],printChar:function(N,F){var B=ki.buffers[N];F===0||F===10?((N===1?j:q)(Be(B,0)),B.length=0):B.push(F)},varargs:void 0,get:function(){ki.varargs+=4;var N=i()[ki.varargs-4>>2];return N},getStr:function(N){var F=Me(N);return F},get64:function(N,F){return N}};function Kd(N){return k?Gr(3,1,N):0}function Zd(N,F,B,K,Ae){if(k)return Gr(4,1,N,F,B,K,Ae)}function Yd(N,F,B,K){if(k)return Gr(5,1,N,F,B,K);for(var Ae=0,me=0;me<B;me++){for(var ge=i()[F+me*8>>2],Ie=i()[F+(me*8+4)>>2],it=0;it<Ie;it++)ki.printChar(N,o()[ge+it]);Ae+=Ie}return i()[K>>2]=Ae,0}function Sm(N){var F=Te.threadExitHandlers.pop();N&&F()}function Cm(N,F){Te.threadExitHandlers.push(function(){As.get(N)(F)})}function Jd(N){if(k)throw"Internal Error! spawnThread() can only ever be called from main application thread!";var F=Te.getNewWorker();if(F.pthread!==void 0)throw"Internal error!";if(!N.pthread_ptr)throw"Internal error, no pthread ptr!";Te.runningWorkers.push(F);for(var B=Ra(128*4),K=0;K<128;++K)i()[B+K*4>>2]=0;var Ae=N.stackBase+N.stackSize,me=Te.pthreads[N.pthread_ptr]={worker:F,stackBase:N.stackBase,stackSize:N.stackSize,allocatedOwnStack:N.allocatedOwnStack,threadInfoStruct:N.pthread_ptr},ge=me.threadInfoStruct>>2;Atomics.store(l(),ge+(64>>2),N.detached),Atomics.store(l(),ge+(100>>2),B),Atomics.store(l(),ge+(40>>2),me.threadInfoStruct),Atomics.store(l(),ge+(80>>2),N.stackSize),Atomics.store(l(),ge+(76>>2),Ae),Atomics.store(l(),ge+(104>>2),N.stackSize),Atomics.store(l(),ge+(104+8>>2),Ae),Atomics.store(l(),ge+(104+12>>2),N.detached);var Ie=Px(),it=Ie+40;Atomics.store(l(),ge+(172>>2),it),F.pthread=me;var nn={cmd:"run",start_routine:N.startRoutine,arg:N.arg,threadInfoStruct:N.pthread_ptr,stackBase:N.stackBase,stackSize:N.stackSize};F.runPthread=function(){nn.time=performance.now(),F.postMessage(nn,N.transferList)},F.loaded&&(F.runPthread(),delete F.runPthread)}function Tm(N,F,B,K){if(typeof SharedArrayBuffer=="undefined")return q("Current environment does not support SharedArrayBuffer, pthreads are not available!"),6;if(!N)return q("pthread_create called with a null thread pointer!"),28;var Ae=[],me=0;if(k&&(Ae.length===0||me))return Bx(687865856,N,F,B,K);if(me)return me;var ge=0,Ie=0,it=0;F&&F!=-1?(ge=i()[F>>2],ge+=81920,Ie=i()[F+8>>2],it=i()[F+12>>2]!==0):ge=2097152;var nn=Ie==0;nn?Ie=Ux(16,ge):(Ie-=ge,xe(Ie>0));for(var Xt=Ra(228),Xr=0;Xr<228>>2;++Xr)l()[(Xt>>2)+Xr]=0;i()[N>>2]=Xt,i()[Xt+12>>2]=Xt;var Ei=Xt+152;i()[Ei>>2]=Ei;var kn={stackBase:Ie,stackSize:ge,allocatedOwnStack:nn,detached:it,startRoutine:B,pthread_ptr:Xt,arg:K,transferList:Ae};return k?(kn.cmd="spawnThread",postMessage(kn,Ae)):Jd(kn),0}function Qd(N){if(k)return Gr(6,1,N);switch(N){case 30:return 16384;case 85:var F=2147483648;return F/16384;case 132:case 133:case 12:case 137:case 138:case 15:case 235:case 16:case 17:case 18:case 19:case 20:case 149:case 13:case 10:case 236:case 153:case 9:case 21:case 22:case 159:case 154:case 14:case 77:case 78:case 139:case 82:case 68:case 67:case 164:case 11:case 29:case 47:case 48:case 95:case 52:case 51:case 46:return 200809;case 27:case 246:case 127:case 128:case 23:case 24:case 160:case 161:case 181:case 182:case 242:case 183:case 184:case 243:case 244:case 245:case 165:case 178:case 179:case 49:case 50:case 168:case 169:case 175:case 170:case 171:case 172:case 97:case 76:case 32:case 173:case 35:case 80:case 81:case 79:return-1;case 176:case 177:case 7:case 155:case 8:case 157:case 125:case 126:case 92:case 93:case 129:case 130:case 131:case 94:case 91:return 1;case 74:case 60:case 69:case 70:case 4:return 1024;case 31:case 42:case 72:return 32;case 87:case 26:case 33:return 2147483647;case 34:case 1:return 47839;case 38:case 36:return 99;case 43:case 37:return 2048;case 0:return 2097152;case 3:return 65536;case 28:return 32768;case 44:return 32767;case 75:return 16384;case 39:return 1e3;case 89:return 700;case 71:return 256;case 40:return 255;case 2:return 100;case 180:return 64;case 25:return 20;case 5:return 16;case 6:return 6;case 73:return 4;case 84:return typeof navigator=="object"&&navigator.hardwareConcurrency||1}return K0(28),-1}k||Te.initMainThreadBlock();var jr,Nm=[null,Z0,Xd,Kd,Zd,Yd,Qd],Em={e:q0,r:X0,x:Y0,b:J0,y:Q0,j:em,c:tm,d:$u,f:Ea,p:nm,z:sm,u:am,q:lm,v:mm,i:gm,t:Am,w:Im,m:Kd,n:Zd,g:Yd,o:jd,a:Q||c.wasmMemory,k:Sm,l:Cm,h:Tm,s:Qd},Fx=L0(),ep=c.___wasm_call_ctors=function(){return(ep=c.___wasm_call_ctors=c.asm.A).apply(null,arguments)},Rm=c._init=function(){return(Rm=c._init=c.asm.B).apply(null,arguments)},Dm=c._register_tensor=function(){return(Dm=c._register_tensor=c.asm.C).apply(null,arguments)},_m=c._dispose_data=function(){return(_m=c._dispose_data=c.asm.D).apply(null,arguments)},$m=c._dispose=function(){return($m=c._dispose=c.asm.E).apply(null,arguments)},Fm=c._Abs=function(){return(Fm=c._Abs=c.asm.G).apply(null,arguments)},Om=c._Add=function(){return(Om=c._Add=c.asm.H).apply(null,arguments)},Pm=c._AddN=function(){return(Pm=c._AddN=c.asm.I).apply(null,arguments)},Mm=c._All=function(){return(Mm=c._All=c.asm.J).apply(null,arguments)},zm=c._Any=function(){return(zm=c._Any=c.asm.K).apply(null,arguments)},Lm=c._ArgMax=function(){return(Lm=c._ArgMax=c.asm.L).apply(null,arguments)},Bm=c._AvgPool=function(){return(Bm=c._AvgPool=c.asm.M).apply(null,arguments)},Wm=c._BatchMatMul=function(){return(Wm=c._BatchMatMul=c.asm.N).apply(null,arguments)},Vm=c._Ceil=function(){return(Vm=c._Ceil=c.asm.O).apply(null,arguments)},Um=c._ClipByValue=function(){return(Um=c._ClipByValue=c.asm.P).apply(null,arguments)},Hm=c._Conv2D=function(){return(Hm=c._Conv2D=c.asm.Q).apply(null,arguments)},Gm=c._Conv2DBackpropInput=function(){return(Gm=c._Conv2DBackpropInput=c.asm.R).apply(null,arguments)},jm=c._Cos=function(){return(jm=c._Cos=c.asm.S).apply(null,arguments)},qm=c._Cosh=function(){return(qm=c._Cosh=c.asm.T).apply(null,arguments)},Xm=c._CropAndResize=function(){return(Xm=c._CropAndResize=c.asm.U).apply(null,arguments)},Km=c._Cumsum=function(){return(Km=c._Cumsum=c.asm.V).apply(null,arguments)},Zm=c._DepthToSpace=function(){return(Zm=c._DepthToSpace=c.asm.W).apply(null,arguments)},Ym=c._DepthwiseConv2dNative=function(){return(Ym=c._DepthwiseConv2dNative=c.asm.X).apply(null,arguments)},Jm=c._Elu=function(){return(Jm=c._Elu=c.asm.Y).apply(null,arguments)},tp=c._Equal=function(){return(tp=c._Equal=c.asm.Z).apply(null,arguments)},np=c._Exp=function(){return(np=c._Exp=c.asm._).apply(null,arguments)},sp=c._FlipLeftRight=function(){return(sp=c._FlipLeftRight=c.asm.$).apply(null,arguments)},Mu=c._Floor=function(){return(Mu=c._Floor=c.asm.aa).apply(null,arguments)},Ii=c._FloorDiv=function(){return(Ii=c._FloorDiv=c.asm.ba).apply(null,arguments)},Qm=c._FusedBatchNorm=function(){return(Qm=c._FusedBatchNorm=c.asm.ca).apply(null,arguments)},zu=c._FusedConv2D=function(){return(zu=c._FusedConv2D=c.asm.da).apply(null,arguments)},J=c._FusedDepthwiseConv2D=function(){return(J=c._FusedDepthwiseConv2D=c.asm.ea).apply(null,arguments)},ae=c._Gather=function(){return(ae=c._Gather=c.asm.fa).apply(null,arguments)},ve=c._GatherNd=function(){return(ve=c._GatherNd=c.asm.ga).apply(null,arguments)},nt=c._Greater=function(){return(nt=c._Greater=c.asm.ha).apply(null,arguments)},Ot=c._GreaterEqual=function(){return(Ot=c._GreaterEqual=c.asm.ia).apply(null,arguments)},kt=c._LeakyRelu=function(){return(kt=c._LeakyRelu=c.asm.ja).apply(null,arguments)},Ke=c._Less=function(){return(Ke=c._Less=c.asm.ka).apply(null,arguments)},Qe=c._LessEqual=function(){return(Qe=c._LessEqual=c.asm.la).apply(null,arguments)},hn=c._Log=function(){return(hn=c._Log=c.asm.ma).apply(null,arguments)},vr=c._LogicalAnd=function(){return(vr=c._LogicalAnd=c.asm.na).apply(null,arguments)},wr=c._Max=function(){return(wr=c._Max=c.asm.oa).apply(null,arguments)},rp=c._MaxPool=function(){return(rp=c._MaxPool=c.asm.pa).apply(null,arguments)},Lu=c._Maximum=function(){return(Lu=c._Maximum=c.asm.qa).apply(null,arguments)},Jn=c._Mean=function(){return(Jn=c._Mean=c.asm.ra).apply(null,arguments)},qr=c._Min=function(){return(qr=c._Min=c.asm.sa).apply(null,arguments)},ap=c._Minimum=function(){return(ap=c._Minimum=c.asm.ta).apply(null,arguments)},bI=c._MirrorPad=function(){return(bI=c._MirrorPad=c.asm.ua).apply(null,arguments)},vI=c._Multiply=function(){return(vI=c._Multiply=c.asm.va).apply(null,arguments)},wI=c._Neg=function(){return(wI=c._Neg=c.asm.wa).apply(null,arguments)},kI=c._NonMaxSuppressionV3=function(){return(kI=c._NonMaxSuppressionV3=c.asm.xa).apply(null,arguments)},II=c._NonMaxSuppressionV4=function(){return(II=c._NonMaxSuppressionV4=c.asm.ya).apply(null,arguments)},SI=c._NonMaxSuppressionV5=function(){return(SI=c._NonMaxSuppressionV5=c.asm.za).apply(null,arguments)},CI=c._NotEqual=function(){return(CI=c._NotEqual=c.asm.Aa).apply(null,arguments)},TI=c._OneHot=function(){return(TI=c._OneHot=c.asm.Ba).apply(null,arguments)},NI=c._PadV2=function(){return(NI=c._PadV2=c.asm.Ca).apply(null,arguments)},EI=c._Pow=function(){return(EI=c._Pow=c.asm.Da).apply(null,arguments)},RI=c._Prelu=function(){return(RI=c._Prelu=c.asm.Ea).apply(null,arguments)},DI=c._Prod=function(){return(DI=c._Prod=c.asm.Fa).apply(null,arguments)},_I=c._RealDiv=function(){return(_I=c._RealDiv=c.asm.Ga).apply(null,arguments)},$I=c._Relu=function(){return($I=c._Relu=c.asm.Ha).apply(null,arguments)},FI=c._Relu6=function(){return(FI=c._Relu6=c.asm.Ia).apply(null,arguments)},OI=c._ResizeBilinear=function(){return(OI=c._ResizeBilinear=c.asm.Ja).apply(null,arguments)},PI=c._Reverse=function(){return(PI=c._Reverse=c.asm.Ka).apply(null,arguments)},MI=c._RotateWithOffset=function(){return(MI=c._RotateWithOffset=c.asm.La).apply(null,arguments)},zI=c._Round=function(){return(zI=c._Round=c.asm.Ma).apply(null,arguments)},LI=c._Rsqrt=function(){return(LI=c._Rsqrt=c.asm.Na).apply(null,arguments)},BI=c._ScatterNd=function(){return(BI=c._ScatterNd=c.asm.Oa).apply(null,arguments)},WI=c._SelectV2=function(){return(WI=c._SelectV2=c.asm.Pa).apply(null,arguments)},VI=c._Sigmoid=function(){return(VI=c._Sigmoid=c.asm.Qa).apply(null,arguments)},UI=c._Sin=function(){return(UI=c._Sin=c.asm.Ra).apply(null,arguments)},HI=c._Softmax=function(){return(HI=c._Softmax=c.asm.Sa).apply(null,arguments)},GI=c._Sqrt=function(){return(GI=c._Sqrt=c.asm.Ta).apply(null,arguments)},jI=c._Square=function(){return(jI=c._Square=c.asm.Ua).apply(null,arguments)},qI=c._SquaredDifference=function(){return(qI=c._SquaredDifference=c.asm.Va).apply(null,arguments)},XI=c._Step=function(){return(XI=c._Step=c.asm.Wa).apply(null,arguments)},KI=c._StridedSlice=function(){return(KI=c._StridedSlice=c.asm.Xa).apply(null,arguments)},ZI=c._Sub=function(){return(ZI=c._Sub=c.asm.Ya).apply(null,arguments)},YI=c._Sum=function(){return(YI=c._Sum=c.asm.Za).apply(null,arguments)},JI=c._Tan=function(){return(JI=c._Tan=c.asm._a).apply(null,arguments)},QI=c._Tanh=function(){return(QI=c._Tanh=c.asm.$a).apply(null,arguments)},eS=c._Tile=function(){return(eS=c._Tile=c.asm.ab).apply(null,arguments)},tS=c._TopK=function(){return(tS=c._TopK=c.asm.bb).apply(null,arguments)},nS=c._Transform=function(){return(nS=c._Transform=c.asm.cb).apply(null,arguments)},sS=c._Transpose=function(){return(sS=c._Transpose=c.asm.db).apply(null,arguments)},rS=c.__FusedMatMul=function(){return(rS=c.__FusedMatMul=c.asm.eb).apply(null,arguments)},Ra=c._malloc=function(){return(Ra=c._malloc=c.asm.fb).apply(null,arguments)},Bu=c._free=function(){return(Bu=c._free=c.asm.gb).apply(null,arguments)},Ox=c.___errno_location=function(){return(Ox=c.___errno_location=c.asm.hb).apply(null,arguments)},Px=c._emscripten_get_global_libc=function(){return(Px=c._emscripten_get_global_libc=c.asm.ib).apply(null,arguments)},Si=c._pthread_self=function(){return(Si=c._pthread_self=c.asm.jb).apply(null,arguments)},Mx=c.___pthread_tsd_run_dtors=function(){return(Mx=c.___pthread_tsd_run_dtors=c.asm.kb).apply(null,arguments)},eg=c._emscripten_main_thread_process_queued_calls=function(){return(eg=c._emscripten_main_thread_process_queued_calls=c.asm.lb).apply(null,arguments)},aS=c._emscripten_current_thread_process_queued_calls=function(){return(aS=c._emscripten_current_thread_process_queued_calls=c.asm.mb).apply(null,arguments)},zx=c._emscripten_register_main_browser_thread_id=function(){return(zx=c._emscripten_register_main_browser_thread_id=c.asm.nb).apply(null,arguments)},Lx=c.__emscripten_do_dispatch_to_thread=function(){return(Lx=c.__emscripten_do_dispatch_to_thread=c.asm.ob).apply(null,arguments)},Bx=c._emscripten_sync_run_in_main_thread_4=function(){return(Bx=c._emscripten_sync_run_in_main_thread_4=c.asm.pb).apply(null,arguments)},Wx=c._emscripten_run_in_main_runtime_thread_js=function(){return(Wx=c._emscripten_run_in_main_runtime_thread_js=c.asm.qb).apply(null,arguments)},tg=c.__emscripten_call_on_thread=function(){return(tg=c.__emscripten_call_on_thread=c.asm.rb).apply(null,arguments)},oS=c._emscripten_tls_init=function(){return(oS=c._emscripten_tls_init=c.asm.sb).apply(null,arguments)},ng=c.__emscripten_thread_init=function(){return(ng=c.__emscripten_thread_init=c.asm.tb).apply(null,arguments)},Wu=c.stackSave=function(){return(Wu=c.stackSave=c.asm.ub).apply(null,arguments)},Ci=c.stackRestore=function(){return(Ci=c.stackRestore=c.asm.vb).apply(null,arguments)},Ti=c.stackAlloc=function(){return(Ti=c.stackAlloc=c.asm.wb).apply(null,arguments)},Vx=c._emscripten_stack_set_limits=function(){return(Vx=c._emscripten_stack_set_limits=c.asm.xb).apply(null,arguments)},Ux=c._memalign=function(){return(Ux=c._memalign=c.asm.yb).apply(null,arguments)},Hx=c.__emscripten_allow_main_runtime_queued_calls=10016,Ni=c.__emscripten_main_thread_futex=11652;c.cwrap=Oe,c.PThread=Te,c.PThread=Te,c.wasmMemory=Q,c.ExitStatus=Vu;var op;function Vu(N){this.name="ExitStatus",this.message="Program terminated with exit("+N+")",this.status=N}Na=function N(){op||sg(),op||(Na=N)};function sg(N){if(N=N||m,xr>0)return;if(k){d(c),_u(),postMessage({cmd:"loaded"});return}if(_0(),xr>0)return;function F(){op||(op=!0,c.calledRun=!0,!ce&&(_u(),$0(),d(c),c.onRuntimeInitialized&&c.onRuntimeInitialized(),Mn()))}c.setStatus?(c.setStatus("Running..."),setTimeout(function(){setTimeout(function(){c.setStatus("")},1),F()},1)):F()}c.run=sg;function iS(N,F){if(!(F&&re&&N===0)){if(!F&&k)throw postMessage({cmd:"exitProcess",returnCode:N}),new Vu(N);re||(Te.terminateAllThreads(),fe=N,Bd(),c.onExit&&c.onExit(N),ce=!0),A(N,new Vu(N))}}if(c.preInit)for(typeof c.preInit=="function"&&(c.preInit=[c.preInit]);c.preInit.length>0;)c.preInit.pop()();return k&&(re=!1,Te.initWorker()),sg(),r.ready}}();typeof e=="object"&&typeof t=="object"?t.exports=n:typeof define=="function"&&define.amd?define([],function(){return n}):typeof e=="object"&&(e.WasmBackendModuleThreadedSimd=n)}}),OS=It({"node_modules/.pnpm/@tensorflow+tfjs-backend-wasm@3.9.0_@tensorflow+tfjs-core@3.9.0/node_modules/@tensorflow/tfjs-backend-wasm/wasm-out/tfjs-backend-wasm.js"(e,t){var n=function(){var s=typeof document!="undefined"&&document.currentScript?document.currentScript.src:void 0;return typeof __filename!="undefined"&&(s=s||__filename),function(r){r=r||{};var a=typeof r!="undefined"?r:{},o,i;a.ready=new Promise(function(J,ae){o=J,i=ae});var l={},u;for(u in a)a.hasOwnProperty(u)&&(l[u]=a[u]);var c=[],d="./this.program",p=function(J,ae){throw ae},h=!1,f=!1,m=!1,g=!1;h=typeof window=="object",f=typeof importScripts=="function",m=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string",g=!h&&!m&&!f;var A="";function y(J){return a.locateFile?a.locateFile(J,A):A+J}var x,b,v,k,S,C;m?(f?A=ju().dirname(A)+"/":A=__dirname+"/",x=function(ae,ve){return S||(S=Di("fs")),C||(C=ju()),ae=C.normalize(ae),S.readFileSync(ae,ve?null:"utf8")},v=function(ae){var ve=x(ae,!0);return ve.buffer||(ve=new Uint8Array(ve)),j(ve.buffer),ve},process.argv.length>1&&(d=process.argv[1].replace(/\\/g,"/")),c=process.argv.slice(2),process.on("uncaughtException",function(J){if(!(J instanceof Qm))throw J}),process.on("unhandledRejection",er),p=function(J){process.exit(J)},a.inspect=function(){return"[Emscripten Module object]"}):g?(typeof read!="undefined"&&(x=function(ae){return read(ae)}),v=function(ae){var ve;return typeof readbuffer=="function"?new Uint8Array(readbuffer(ae)):(ve=read(ae,"binary"),j(typeof ve=="object"),ve)},typeof scriptArgs!="undefined"?c=scriptArgs:typeof arguments!="undefined"&&(c=arguments),typeof quit=="function"&&(p=function(J){quit(J)}),typeof print!="undefined"&&(typeof console=="undefined"&&(console={}),console.log=print,console.warn=console.error=typeof printErr!="undefined"?printErr:print)):(h||f)&&(f?A=self.location.href:typeof document!="undefined"&&document.currentScript&&(A=document.currentScript.src),s&&(A=s),A.indexOf("blob:")!==0?A=A.substr(0,A.lastIndexOf("/")+1):A="",x=function(J){var ae=new XMLHttpRequest;return ae.open("GET",J,!1),ae.send(null),ae.responseText},f&&(v=function(J){var ae=new XMLHttpRequest;return ae.open("GET",J,!1),ae.responseType="arraybuffer",ae.send(null),new Uint8Array(ae.response)}),b=function(J,ae,ve){var nt=new XMLHttpRequest;nt.open("GET",J,!0),nt.responseType="arraybuffer",nt.onload=function(){if(nt.status==200||nt.status==0&&nt.response){ae(nt.response);return}ve()},nt.onerror=ve,nt.send(null)},k=function(J){document.title=J});var D=a.print||console.log.bind(console),O=a.printErr||console.warn.bind(console);for(u in l)l.hasOwnProperty(u)&&(a[u]=l[u]);l=null,a.arguments&&(c=a.arguments),a.thisProgram&&(d=a.thisProgram),a.quit&&(p=a.quit);var E;a.wasmBinary&&(E=a.wasmBinary);var R=a.noExitRuntime||!0;typeof WebAssembly!="object"&&er("no native wasm support detected");var T,P=!1,U;function j(J,ae){J||er("Assertion failed: "+ae)}function q(J){var ae=a["_"+J];return j(ae,"Cannot call unknown function "+J+", make sure it is exported"),ae}function X(J,ae,ve,nt,Ot){var kt={string:function(Jn){var qr=0;if(Jn!=null&&Jn!==0){var ap=(Jn.length<<2)+1;qr=Mu(ap),ue(Jn,qr,ap)}return qr},array:function(Jn){var qr=Mu(Jn.length);return ce(Jn,qr),qr}};function Ke(Jn){return ae==="string"?re(Jn):ae==="boolean"?Boolean(Jn):Jn}var Qe=q(J),hn=[],vr=0;if(nt)for(var wr=0;wr<nt.length;wr++){var rp=kt[ve[wr]];rp?(vr===0&&(vr=np()),hn[wr]=rp(nt[wr])):hn[wr]=nt[wr]}var Lu=Qe.apply(null,hn);return Lu=Ke(Lu),vr!==0&&sp(vr),Lu}function te(J,ae,ve,nt){ve=ve||[];var Ot=ve.every(function(Ke){return Ke==="number"}),kt=ae!=="string";return kt&&Ot&&!nt?q(J):function(){return X(J,ae,ve,arguments,nt)}}var ne=typeof TextDecoder!="undefined"?new TextDecoder("utf8"):void 0;function se(J,ae,ve){for(var nt=ae+ve,Ot=ae;J[Ot]&&!(Ot>=nt);)++Ot;if(Ot-ae>16&&J.subarray&&ne)return ne.decode(J.subarray(ae,Ot));for(var kt="";ae<Ot;){var Ke=J[ae++];if(!(Ke&128)){kt+=String.fromCharCode(Ke);continue}var Qe=J[ae++]&63;if((Ke&224)==192){kt+=String.fromCharCode((Ke&31)<<6|Qe);continue}var hn=J[ae++]&63;if((Ke&240)==224?Ke=(Ke&15)<<12|Qe<<6|hn:Ke=(Ke&7)<<18|Qe<<12|hn<<6|J[ae++]&63,Ke<65536)kt+=String.fromCharCode(Ke);else{var vr=Ke-65536;kt+=String.fromCharCode(55296|vr>>10,56320|vr&1023)}}return kt}function re(J,ae){return J?se(Ee,J,ae):""}function Q(J,ae,ve,nt){if(!(nt>0))return 0;for(var Ot=ve,kt=ve+nt-1,Ke=0;Ke<J.length;++Ke){var Qe=J.charCodeAt(Ke);if(Qe>=55296&&Qe<=57343){var hn=J.charCodeAt(++Ke);Qe=65536+((Qe&1023)<<10)|hn&1023}if(Qe<=127){if(ve>=kt)break;ae[ve++]=Qe}else if(Qe<=2047){if(ve+1>=kt)break;ae[ve++]=192|Qe>>6,ae[ve++]=128|Qe&63}else if(Qe<=65535){if(ve+2>=kt)break;ae[ve++]=224|Qe>>12,ae[ve++]=128|Qe>>6&63,ae[ve++]=128|Qe&63}else{if(ve+3>=kt)break;ae[ve++]=240|Qe>>18,ae[ve++]=128|Qe>>12&63,ae[ve++]=128|Qe>>6&63,ae[ve++]=128|Qe&63}}return ae[ve]=0,ve-Ot}function ue(J,ae,ve){return Q(J,Ee,ae,ve)}function ce(J,ae){Ne.set(J,ae)}function fe(J,ae){return J%ae>0&&(J+=ae-J%ae),J}var xe,Ne,Ee,Oe,Be,Me,ht,at,ot;function st(J){xe=J,a.HEAP8=Ne=new Int8Array(J),a.HEAP16=Oe=new Int16Array(J),a.HEAP32=Me=new Int32Array(J),a.HEAPU8=Ee=new Uint8Array(J),a.HEAPU16=Be=new Uint16Array(J),a.HEAPU32=ht=new Uint32Array(J),a.HEAPF32=at=new Float32Array(J),a.HEAPF64=ot=new Float64Array(J)}var dt=a.INITIAL_MEMORY||16777216,Xe,Pn=[],Et=[],Zn=[],dn=[],Ns=!1;Et.push({func:function(){jd()}});function wn(){if(a.preRun)for(typeof a.preRun=="function"&&(a.preRun=[a.preRun]);a.preRun.length;)gs(a.preRun.shift());Hr(Pn)}function fs(){Ns=!0,Hr(Et)}function ms(){Hr(Zn)}function pn(){if(a.postRun)for(typeof a.postRun=="function"&&(a.postRun=[a.postRun]);a.postRun.length;)As(a.postRun.shift());Hr(dn)}function gs(J){Pn.unshift(J)}function As(J){dn.unshift(J)}var Yn=0,Qs=null,yr=null;function Ur(J){Yn++,a.monitorRunDependencies&&a.monitorRunDependencies(Yn)}function bi(J){if(Yn--,a.monitorRunDependencies&&a.monitorRunDependencies(Yn),Yn==0&&(Qs!==null&&(clearInterval(Qs),Qs=null),yr)){var ae=yr;yr=null,ae()}}a.preloadedImages={},a.preloadedAudios={};function er(J){a.onAbort&&a.onAbort(J),J+="",O(J),P=!0,U=1,J="abort("+J+"). Build with -s ASSERTIONS=1 for more info.";var ae=new WebAssembly.RuntimeError(J);throw i(ae),ae}function Ld(J,ae){return String.prototype.startsWith?J.startsWith(ae):J.indexOf(ae)===0}var _0="data:application/octet-stream;base64,";function _u(J){return Ld(J,_0)}var $0="file://";function Bd(J){return Ld(J,$0)}var Mn="tfjs-backend-wasm.wasm";_u(Mn)||(Mn=y(Mn));function Wd(J){try{if(J==Mn&&E)return new Uint8Array(E);if(v)return v(J);throw"both async and sync fetching of the wasm failed"}catch(ae){er(ae)}}function F0(){if(!E&&(h||f)){if(typeof fetch=="function"&&!Bd(Mn))return fetch(Mn,{credentials:"same-origin"}).then(function(J){if(!J.ok)throw"failed to load wasm binary file at '"+Mn+"'";return J.arrayBuffer()}).catch(function(){return Wd(Mn)});if(b)return new Promise(function(J,ae){b(Mn,function(ve){J(new Uint8Array(ve))},ae)})}return Promise.resolve().then(function(){return Wd(Mn)})}function xr(){var J={a:L0};function ae(Ke,Qe){var hn=Ke.exports;a.asm=hn,T=a.asm.i,st(T.buffer),Xe=a.asm.o,bi("wasm-instantiate")}Ur("wasm-instantiate");function ve(Ke){ae(Ke.instance)}function nt(Ke){return F0().then(function(Qe){return WebAssembly.instantiate(Qe,J)}).then(Ke,function(Qe){O("failed to asynchronously prepare wasm: "+Qe),er(Qe)})}function Ot(){return!E&&typeof WebAssembly.instantiateStreaming=="function"&&!_u(Mn)&&!Bd(Mn)&&typeof fetch=="function"?fetch(Mn,{credentials:"same-origin"}).then(function(Ke){var Qe=WebAssembly.instantiateStreaming(Ke,J);return Qe.then(ve,function(hn){return O("wasm streaming compile failed: "+hn),O("falling back to ArrayBuffer instantiation"),nt(ve)})}):nt(ve)}if(a.instantiateWasm)try{var kt=a.instantiateWasm(J,ae);return kt}catch(Ke){return O("Module.instantiateWasm callback failed with error: "+Ke),!1}return Ot().catch(i),{}}function Hr(J){for(;J.length>0;){var ae=J.shift();if(typeof ae=="function"){ae(a);continue}var ve=ae.func;typeof ve=="number"?ae.arg===void 0?Xe.get(ve)():Xe.get(ve)(ae.arg):ve(ae.arg===void 0?null:ae.arg)}}function Na(){er()}function O0(J,ae,ve){Ee.copyWithin(J,ae,ae+ve)}function P0(){return Ee.length}function br(J){try{return T.grow(J-xe.byteLength+65535>>>16),st(T.buffer),1}catch(ae){}}function Vd(J){var ae=P0(),ve=2147483648;if(J>ve)return!1;for(var nt=1;nt<=4;nt*=2){var Ot=ae*(1+.2/nt);Ot=Math.min(Ot,J+100663296);var kt=Math.min(ve,fe(Math.max(J,Ot),65536)),Ke=br(kt);if(Ke)return!0}return!1}var vi={mappings:{},buffers:[null,[],[]],printChar:function(J,ae){var ve=vi.buffers[J];ae===0||ae===10?((J===1?D:O)(se(ve,0)),ve.length=0):ve.push(ae)},varargs:void 0,get:function(){vi.varargs+=4;var J=Me[vi.varargs-4>>2];return J},getStr:function(J){var ae=re(J);return ae},get64:function(J,ae){return J}};function Ud(J){return 0}function M0(J,ae,ve,nt,Ot){}function Hd(J,ae,ve,nt){for(var Ot=0,kt=0;kt<ve;kt++){for(var Ke=Me[ae+kt*8>>2],Qe=Me[ae+(kt*8+4)>>2],hn=0;hn<Qe;hn++)vi.printChar(J,Ee[Ke+hn]);Ot+=Qe}return Me[nt>>2]=Ot,0}function zn(){return 6}function Gd(J){return Me[tp()>>2]=J,J}function z0(J){switch(J){case 30:return 16384;case 85:var ae=2147483648;return ae/16384;case 132:case 133:case 12:case 137:case 138:case 15:case 235:case 16:case 17:case 18:case 19:case 20:case 149:case 13:case 10:case 236:case 153:case 9:case 21:case 22:case 159:case 154:case 14:case 77:case 78:case 139:case 82:case 68:case 67:case 164:case 11:case 29:case 47:case 48:case 95:case 52:case 51:case 46:return 200809;case 27:case 246:case 127:case 128:case 23:case 24:case 160:case 161:case 181:case 182:case 242:case 183:case 184:case 243:case 244:case 245:case 165:case 178:case 179:case 49:case 50:case 168:case 169:case 175:case 170:case 171:case 172:case 97:case 76:case 32:case 173:case 35:case 80:case 81:case 79:return-1;case 176:case 177:case 7:case 155:case 8:case 157:case 125:case 126:case 92:case 93:case 129:case 130:case 131:case 94:case 91:return 1;case 74:case 60:case 69:case 70:case 4:return 1024;case 31:case 42:case 72:return 32;case 87:case 26:case 33:return 2147483647;case 34:case 1:return 47839;case 38:case 36:return 99;case 43:case 37:return 2048;case 0:return 2097152;case 3:return 65536;case 28:return 32768;case 44:return 32767;case 75:return 16384;case 39:return 1e3;case 89:return 700;case 71:return 256;case 40:return 255;case 2:return 100;case 180:return 64;case 25:return 20;case 5:return 16;case 6:return 6;case 73:return 4;case 84:return typeof navigator=="object"&&navigator.hardwareConcurrency||1}return Gd(28),-1}var L0={a:Na,d:O0,e:Vd,f:Ud,c:M0,b:Hd,g:zn,h:z0},B0=xr(),jd=a.___wasm_call_ctors=function(){return(jd=a.___wasm_call_ctors=a.asm.j).apply(null,arguments)},wi=a._init=function(){return(wi=a._init=a.asm.k).apply(null,arguments)},$u=a._register_tensor=function(){return($u=a._register_tensor=a.asm.l).apply(null,arguments)},W0=a._dispose_data=function(){return(W0=a._dispose_data=a.asm.m).apply(null,arguments)},V0=a._dispose=function(){return(V0=a._dispose=a.asm.n).apply(null,arguments)},U0=a._Abs=function(){return(U0=a._Abs=a.asm.p).apply(null,arguments)},Te=a._Add=function(){return(Te=a._Add=a.asm.q).apply(null,arguments)},H0=a._AddN=function(){return(H0=a._AddN=a.asm.r).apply(null,arguments)},G0=a._All=function(){return(G0=a._All=a.asm.s).apply(null,arguments)},j0=a._Any=function(){return(j0=a._Any=a.asm.t).apply(null,arguments)},q0=a._ArgMax=function(){return(q0=a._ArgMax=a.asm.u).apply(null,arguments)},X0=a._AvgPool=function(){return(X0=a._AvgPool=a.asm.v).apply(null,arguments)},Ea=a._BatchMatMul=function(){return(Ea=a._BatchMatMul=a.asm.w).apply(null,arguments)},K0=a._Ceil=function(){return(K0=a._Ceil=a.asm.x).apply(null,arguments)},Z0=a._ClipByValue=function(){return(Z0=a._ClipByValue=a.asm.y).apply(null,arguments)},Y0=a._Conv2D=function(){return(Y0=a._Conv2D=a.asm.z).apply(null,arguments)},J0=a._Conv2DBackpropInput=function(){return(J0=a._Conv2DBackpropInput=a.asm.A).apply(null,arguments)},Q0=a._Cos=function(){return(Q0=a._Cos=a.asm.B).apply(null,arguments)},em=a._Cosh=function(){return(em=a._Cosh=a.asm.C).apply(null,arguments)},tm=a._CropAndResize=function(){return(tm=a._CropAndResize=a.asm.D).apply(null,arguments)},nm=a._Cumsum=function(){return(nm=a._Cumsum=a.asm.E).apply(null,arguments)},sm=a._DepthToSpace=function(){return(sm=a._DepthToSpace=a.asm.F).apply(null,arguments)},Gr=a._DepthwiseConv2dNative=function(){return(Gr=a._DepthwiseConv2dNative=a.asm.G).apply(null,arguments)},Fu=a._Elu=function(){return(Fu=a._Elu=a.asm.H).apply(null,arguments)},Ou=a._Equal=function(){return(Ou=a._Equal=a.asm.I).apply(null,arguments)},rm=a._Exp=function(){return(rm=a._Exp=a.asm.J).apply(null,arguments)},am=a._FlipLeftRight=function(){return(am=a._FlipLeftRight=a.asm.K).apply(null,arguments)},om=a._Floor=function(){return(om=a._Floor=a.asm.L).apply(null,arguments)},im=a._FloorDiv=function(){return(im=a._FloorDiv=a.asm.M).apply(null,arguments)},lm=a._FusedBatchNorm=function(){return(lm=a._FusedBatchNorm=a.asm.N).apply(null,arguments)},Ve=a._FusedConv2D=function(){return(Ve=a._FusedConv2D=a.asm.O).apply(null,arguments)},um=a._FusedDepthwiseConv2D=function(){return(um=a._FusedDepthwiseConv2D=a.asm.P).apply(null,arguments)},cm=a._Gather=function(){return(cm=a._Gather=a.asm.Q).apply(null,arguments)},dm=a._GatherNd=function(){return(dm=a._GatherNd=a.asm.R).apply(null,arguments)},pm=a._Greater=function(){return(pm=a._Greater=a.asm.S).apply(null,arguments)},hm=a._GreaterEqual=function(){return(hm=a._GreaterEqual=a.asm.T).apply(null,arguments)},fm=a._LeakyRelu=function(){return(fm=a._LeakyRelu=a.asm.U).apply(null,arguments)},Pu=a._Less=function(){return(Pu=a._Less=a.asm.V).apply(null,arguments)},qd=a._LessEqual=function(){return(qd=a._LessEqual=a.asm.W).apply(null,arguments)},Xd=a._Log=function(){return(Xd=a._Log=a.asm.X).apply(null,arguments)},mm=a._LogicalAnd=function(){return(mm=a._LogicalAnd=a.asm.Y).apply(null,arguments)},gm=a._Max=function(){return(gm=a._Max=a.asm.Z).apply(null,arguments)},Am=a._MaxPool=function(){return(Am=a._MaxPool=a.asm._).apply(null,arguments)},ym=a._Maximum=function(){return(ym=a._Maximum=a.asm.$).apply(null,arguments)},xm=a._Mean=function(){return(xm=a._Mean=a.asm.aa).apply(null,arguments)},bm=a._Min=function(){return(bm=a._Min=a.asm.ba).apply(null,arguments)},vm=a._Minimum=function(){return(vm=a._Minimum=a.asm.ca).apply(null,arguments)},rt=a._MirrorPad=function(){return(rt=a._MirrorPad=a.asm.da).apply(null,arguments)},wm=a._Multiply=function(){return(wm=a._Multiply=a.asm.ea).apply(null,arguments)},km=a._Neg=function(){return(km=a._Neg=a.asm.fa).apply(null,arguments)},Im=a._NonMaxSuppressionV3=function(){return(Im=a._NonMaxSuppressionV3=a.asm.ga).apply(null,arguments)},ki=a._NonMaxSuppressionV4=function(){return(ki=a._NonMaxSuppressionV4=a.asm.ha).apply(null,arguments)},Kd=a._NonMaxSuppressionV5=function(){return(Kd=a._NonMaxSuppressionV5=a.asm.ia).apply(null,arguments)},Zd=a._NotEqual=function(){return(Zd=a._NotEqual=a.asm.ja).apply(null,arguments)},Yd=a._OneHot=function(){return(Yd=a._OneHot=a.asm.ka).apply(null,arguments)},Sm=a._PadV2=function(){return(Sm=a._PadV2=a.asm.la).apply(null,arguments)},Cm=a._Pow=function(){return(Cm=a._Pow=a.asm.ma).apply(null,arguments)},Jd=a._Prelu=function(){return(Jd=a._Prelu=a.asm.na).apply(null,arguments)},Tm=a._Prod=function(){return(Tm=a._Prod=a.asm.oa).apply(null,arguments)},Qd=a._RealDiv=function(){return(Qd=a._RealDiv=a.asm.pa).apply(null,arguments)},jr=a._Relu=function(){return(jr=a._Relu=a.asm.qa).apply(null,arguments)},Nm=a._Relu6=function(){return(Nm=a._Relu6=a.asm.ra).apply(null,arguments)},Em=a._ResizeBilinear=function(){return(Em=a._ResizeBilinear=a.asm.sa).apply(null,arguments)},Fx=a._Reverse=function(){return(Fx=a._Reverse=a.asm.ta).apply(null,arguments)},ep=a._RotateWithOffset=function(){return(ep=a._RotateWithOffset=a.asm.ua).apply(null,arguments)},Rm=a._Round=function(){return(Rm=a._Round=a.asm.va).apply(null,arguments)},Dm=a._Rsqrt=function(){return(Dm=a._Rsqrt=a.asm.wa).apply(null,arguments)},_m=a._ScatterNd=function(){return(_m=a._ScatterNd=a.asm.xa).apply(null,arguments)},$m=a._SelectV2=function(){return($m=a._SelectV2=a.asm.ya).apply(null,arguments)},Fm=a._Sigmoid=function(){return(Fm=a._Sigmoid=a.asm.za).apply(null,arguments)},Om=a._Sin=function(){return(Om=a._Sin=a.asm.Aa).apply(null,arguments)},Pm=a._Softmax=function(){return(Pm=a._Softmax=a.asm.Ba).apply(null,arguments)},Mm=a._Sqrt=function(){return(Mm=a._Sqrt=a.asm.Ca).apply(null,arguments)},zm=a._Square=function(){return(zm=a._Square=a.asm.Da).apply(null,arguments)},Lm=a._SquaredDifference=function(){return(Lm=a._SquaredDifference=a.asm.Ea).apply(null,arguments)},Bm=a._Step=function(){return(Bm=a._Step=a.asm.Fa).apply(null,arguments)},Wm=a._StridedSlice=function(){return(Wm=a._StridedSlice=a.asm.Ga).apply(null,arguments)},Vm=a._Sub=function(){return(Vm=a._Sub=a.asm.Ha).apply(null,arguments)},Um=a._Sum=function(){return(Um=a._Sum=a.asm.Ia).apply(null,arguments)},Hm=a._Tan=function(){return(Hm=a._Tan=a.asm.Ja).apply(null,arguments)},Gm=a._Tanh=function(){return(Gm=a._Tanh=a.asm.Ka).apply(null,arguments)},jm=a._Tile=function(){return(jm=a._Tile=a.asm.La).apply(null,arguments)},qm=a._TopK=function(){return(qm=a._TopK=a.asm.Ma).apply(null,arguments)},Xm=a._Transform=function(){return(Xm=a._Transform=a.asm.Na).apply(null,arguments)},Km=a._Transpose=function(){return(Km=a._Transpose=a.asm.Oa).apply(null,arguments)},Zm=a.__FusedMatMul=function(){return(Zm=a.__FusedMatMul=a.asm.Pa).apply(null,arguments)},Ym=a._malloc=function(){return(Ym=a._malloc=a.asm.Qa).apply(null,arguments)},Jm=a._free=function(){return(Jm=a._free=a.asm.Ra).apply(null,arguments)},tp=a.___errno_location=function(){return(tp=a.___errno_location=a.asm.Sa).apply(null,arguments)},np=a.stackSave=function(){return(np=a.stackSave=a.asm.Ta).apply(null,arguments)},sp=a.stackRestore=function(){return(sp=a.stackRestore=a.asm.Ua).apply(null,arguments)},Mu=a.stackAlloc=function(){return(Mu=a.stackAlloc=a.asm.Va).apply(null,arguments)};a.cwrap=te;var Ii;function Qm(J){this.name="ExitStatus",this.message="Program terminated with exit("+J+")",this.status=J}yr=function J(){Ii||zu(),Ii||(yr=J)};function zu(J){if(J=J||c,Yn>0||(wn(),Yn>0))return;function ae(){Ii||(Ii=!0,a.calledRun=!0,!P&&(fs(),ms(),o(a),a.onRuntimeInitialized&&a.onRuntimeInitialized(),pn()))}a.setStatus?(a.setStatus("Running..."),setTimeout(function(){setTimeout(function(){a.setStatus("")},1),ae()},1)):ae()}if(a.run=zu,a.preInit)for(typeof a.preInit=="function"&&(a.preInit=[a.preInit]);a.preInit.length>0;)a.preInit.pop()();return zu(),r.ready}}();typeof e=="object"&&typeof t=="object"?t.exports=n:typeof define=="function"&&define.amd?define([],function(){return n}):typeof e=="object"&&(e.WasmBackendModule=n)}}),PS=1e-7,MS=1e-4,up=class{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}},qu=class{refCount(e){return Es("refCount")}incRef(e){return Es("incRef")}timerAvailable(){return!0}time(e){return Es("time")}read(e){return Es("read")}readSync(e){return Es("readSync")}numDataIds(){return Es("numDataIds")}disposeData(e,t){return Es("disposeData")}write(e,t,n){return Es("write")}move(e,t,n,s,r){return Es("move")}memory(){return Es("memory")}floatPrecision(){return Es("floatPrecision")}epsilon(){return this.floatPrecision()===32?PS:MS}dispose(){return Es("dispose")}};function Es(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`)}function Qx(e){let t=e.length,n=0;for(;t>0;)n=Math.random()*t|0,t--,cp(e,t,n)}function zS(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,s=0;for(;n>0;)s=Math.random()*n|0,n--,cp(e,n,s),cp(t,n,s)}function Xu(e,t,n){return Math.max(e,Math.min(t,n))}function LS(e){return e%2==0?e:e+1}function cp(e,t,n){let s=e[t];e[t]=e[n],e[n]=s}function BS(e){let t=0;for(let n=0;n<e.length;n++)t+=e[n];return t}function WS(e,t){let n=Math.random();return t*n+(1-n)*e}function VS(e,t){let n=0;for(let s=0;s<e.length;s++){let r=Number(e[s])-Number(t[s]);n+=r*r}return n}function M(e,t){if(!e)throw new Error(typeof t=="string"?t:t())}function In(e,t,n=""){M(Ir(e,t),()=>n+` Shapes ${e} and ${t} must match`)}function _a(e){M(e!=null,()=>"The input to the tensor constructor must be a non-null value.")}function $a(e,t=[],n=!1){if(t==null&&(t=[]),Array.isArray(e)||bn(e)&&!n)for(let s=0;s<e.length;++s)$a(e[s],t,n);else t.push(e);return t}function zt(e){if(e.length===0)return 1;let t=e[0];for(let n=1;n<e.length;n++)t*=e[n];return t}function US(e){return e.length===0}function Ir(e,t){if(e===t)return!0;if(e==null||t==null||e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function sn(e){return e%1==0}function HS(e){if(Math.tanh!=null)return Math.tanh(e);if(e===1/0)return 1;if(e===-1/0)return-1;{let t=Math.exp(2*e);return(t-1)/(t+1)}}function GS(e){let t=Math.ceil(Math.sqrt(e));return[t,Math.ceil(e/t)]}function jS(e){let t=new Uint32Array(e);for(let n=0;n<e;++n)t[n]=n;return Qx(t),t}function Ku(e,t){return t<=e.length?e:e+" ".repeat(t-e.length)}function qS(e,t=s=>0,n){return new Promise((s,r)=>{let a=0,o=()=>{if(e()){s();return}a++;let i=t(a);if(n!=null&&a>=n){r();return}setTimeout(o,i)};o()})}function XS(e,t){let n=1,s=-1;for(let a=0;a<e.length;++a)if(e[a]>=0)n*=e[a];else if(e[a]===-1){if(s!==-1)throw Error(`Shapes can only have 1 implicit size. Found -1 at dim ${s} and dim ${a}`);s=a}else if(e[a]<0)throw Error(`Shapes can not be < 0. Found ${e[a]} at dim ${a}`);if(s===-1){if(t>0&&t!==n)throw Error(`Size(${t}) must match the product of shape ${e}`);return e}if(n===0)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}`);let r=e.slice();return r[s]=t/n,r}function Rs(e,t){let n=t.length;return e=e==null?t.map((s,r)=>r):[].concat(e),M(e.every(s=>s>=-n&&s<n),()=>`All values in axis param must be in range [-${n}, ${n}) but got axis ${e}`),M(e.every(s=>sn(s)),()=>`All values in axis param must be integers but got axis ${e}`),e.map(s=>s<0?n+s:s)}function e5(e,t){let n=[],s=[],r=t!=null&&Array.isArray(t)&&t.length===0,a=t==null||r?null:Rs(t,e).sort(),o=0;for(let i=0;i<e.length;++i){if(a!=null){if(a[o]===i&&e[i]!==1)throw new Error(`Can't squeeze axis ${i} since its dim '${e[i]}' is not 1`);(a[o]==null||a[o]>i)&&e[i]===1&&(n.push(e[i]),s.push(i)),a[o]<=i&&o++}e[i]!==1&&(n.push(e[i]),s.push(i))}return{newShape:n,keptDims:s}}function t5(e,t){let n=null;if(e==null||e==="float32")n=new Float32Array(t);else if(e==="int32")n=new Int32Array(t);else if(e==="bool")n=new Uint8Array(t);else throw new Error(`Unknown data type ${e}`);return n}function n5(e,t){let n=null;if(e==null||e==="float32")n=new Float32Array(t);else if(e==="int32")n=new Int32Array(t);else if(e==="bool")n=new Uint8Array(t);else if(e==="string")n=new Array(t);else throw new Error(`Unknown data type ${e}`);return n}function s5(e,t){for(let n=0;n<e.length;n++){let s=e[n];if(isNaN(s)||!isFinite(s))throw Error(`A tensor of type ${t} being uploaded contains ${s}.`)}}function r5(e){return e==="bool"||e==="complex64"||e==="float32"||e==="int32"||e==="string"}function KS(e,t){return!(t==="complex64"||t==="float32"&&e!=="complex64"||t==="int32"&&e!=="float32"&&e!=="complex64"||t==="bool"&&e==="bool")}function bn(e){return e instanceof Float32Array||e instanceof Int32Array||e instanceof Uint8Array}function og(e){if(e==="float32"||e==="int32")return 4;if(e==="complex64")return 8;if(e==="bool")return 1;throw new Error(`Unknown dtype ${e}`)}function a5(e){if(e==null)return 0;let t=0;return e.forEach(n=>t+=n.length),t}function Kr(e){return typeof e=="string"||e instanceof String}function o5(e){return typeof e=="boolean"}function i5(e){return typeof e=="number"}function dp(e){return Array.isArray(e)?dp(e[0]):e instanceof Float32Array?"float32":e instanceof Int32Array||e instanceof Uint8Array?"int32":i5(e)?"float32":Kr(e)?"string":o5(e)?"bool":"float32"}function Zr(e){return!!(e&&e.constructor&&e.call&&e.apply)}function pp(e,t){for(let n=t;n<e;++n)if(e%n==0)return n;return e}function _i(e){let t=e.length;if(t<2)return[];let n=new Array(t-1);n[t-2]=e[t-1];for(let s=t-3;s>=0;--s)n[s]=n[s+1]*e[s+1];return n}function l5(e,t,n,s=!1){let r=new Array;if(t.length===1){let a=t[0]*(s?2:1);for(let o=0;o<a;o++)r[o]=n[e+o]}else{let a=t[0],o=t.slice(1),i=o.reduce((l,u)=>l*u)*(s?2:1);for(let l=0;l<a;l++)r[l]=l5(e+l*i,o,n,s)}return r}function $i(e,t,n=!1){if(e.length===0)return t[0];let s=e.reduce((r,a)=>r*a)*(n?2:1);if(s===0)return[];if(s!==t.length)throw new Error(`[${e}] does not match the input size ${t.length}${n?" for a complex tensor":""}.`);return l5(0,e,t,n)}function ig(e,t){let n=hp(e,t);for(let s=0;s<n.length;s++)n[s]=1;return n}function hp(e,t){if(t==null||t==="float32"||t==="complex64")return new Float32Array(e);if(t==="int32")return new Int32Array(e);if(t==="bool")return new Uint8Array(e);throw new Error(`Unknown data type ${t}`)}function ZS(e,t){let n=e.reduce((s,r)=>s*r,1);if(t==null||t==="float32")return $i(e,new Float32Array(n));if(t==="int32")return $i(e,new Int32Array(n));if(t==="bool")return $i(e,new Uint8Array(n));throw new Error(`Unknown data type ${t}`)}function lg(e){e.forEach(t=>{M(Number.isInteger(t)&&t>=0,()=>`Tensor must have a shape comprised of positive integers but got shape [${e}].`)})}function YS(e,t,n){if(t===0)return 0;if(t===1)return e[0];let s=e[e.length-1];for(let r=0;r<e.length-1;++r)s+=n[r]*e[r];return s}function JS(e,t,n){if(t===0)return[];if(t===1)return[e];let s=new Array(t);for(let r=0;r<s.length-1;++r)s[r]=Math.floor(e/n[r]),e-=s[r]*n[r];return s[s.length-1]=e,s}function ug(e){return e&&e.then&&typeof e.then=="function"}function tr(...e){Y().getBool("IS_TEST")||Y().getBool("PROD")||console.warn(...e)}function QS(...e){Y().getBool("IS_TEST")||Y().getBool("PROD")||console.log(...e)}var u5="tfjsflags",c5=class{constructor(e){this.global=e,this.flags={},this.flagRegistry={},this.urlFlags={},this.getQueryParams=eC,this.populateURLFlags()}setPlatform(e,t){this.platform!=null&&tr(`Platform ${this.platformName} has already been set. Overwriting the platform with ${t}.`),this.platformName=e,this.platform=t}registerFlag(e,t,n){if(this.flagRegistry[e]={evaluationFn:t,setHook:n},this.urlFlags[e]!=null){let s=this.urlFlags[e];tr(`Setting feature override from URL ${e}: ${s}.`),this.set(e,s)}}async getAsync(e){return e in this.flags?this.flags[e]:(this.flags[e]=await this.evaluateFlag(e),this.flags[e])}get(e){if(e in this.flags)return this.flags[e];let t=this.evaluateFlag(e);if(ug(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(this.flagRegistry[e]==null)throw new Error(`Cannot set flag ${e} as it has not been registered.`);this.flags[e]=t,this.flagRegistry[e].setHook!=null&&this.flagRegistry[e].setHook(t)}evaluateFlag(e){if(this.flagRegistry[e]==null)throw new Error(`Cannot evaluate flag '${e}': no evaluation function found.`);return this.flagRegistry[e].evaluationFn()}setFlags(e){this.flags=Object.assign({},e)}reset(){this.flags={},this.urlFlags={},this.populateURLFlags()}populateURLFlags(){if(typeof this.global=="undefined"||typeof this.global.location=="undefined"||typeof this.global.location.search=="undefined")return;let e=this.getQueryParams(this.global.location.search);u5 in e&&e[u5].split(",").forEach(n=>{let[s,r]=n.split(":");this.urlFlags[s]=nC(s,r)})}};function eC(e){let t={};return e.replace(/[?&]([^=?&]+)(?:=([^&]*))?/g,(n,...s)=>(tC(t,s[0],s[1]),s.join("="))),t}function tC(e,t,n){e[decodeURIComponent(t)]=decodeURIComponent(n||"")}function nC(e,t){if(t=t.toLowerCase(),t==="true"||t==="false")return t==="true";if(`${+t}`===t)return+t;throw new Error(`Could not parse value flag value ${t} for flag ${e}.`)}function Y(){return nr}var nr=null;function sC(e){nr=e}var cg;function d5(){if(cg==null){let e;if(typeof window!="undefined")e=window;else if(typeof global!="undefined")e=global;else if(typeof process!="undefined")e=process;else if(typeof self!="undefined")e=self;else throw new Error("Could not find a global object");cg=e}return cg}function rC(){let e=d5();return e._tfGlobals==null&&(e._tfGlobals=new Map),e._tfGlobals}function dg(e,t){let n=rC();if(n.has(e))return n.get(e);{let s=t();return n.set(e,s),n.get(e)}}var Fi="Abs",Oi="Acos",Pi="Acosh",Yr="Add",Fa="AddN",Mi="All",zi="Any",Oa="ArgMax",Zu="ArgMin",Li="Asin",Bi="Asinh",Wi="Atan",Vi="Atanh",Ui="Atan2",Pa="AvgPool",fp="AvgPoolGrad",Yu="AvgPool3D",mp="AvgPool3DGrad",Ma="BatchMatMul",Hi="BatchToSpaceND",gp="Bincount",p5="BroadcastTo",pg="BroadcastArgs",za="Cast",La="Ceil",Jr="ClipByValue",Ap="Complex",Ju="ComplexAbs",Gi="Concat",Ba="Conv2D",yp="Conv2DBackpropFilter",Wa="Conv2DBackpropInput",Qu="Conv3D",xp="Conv3DBackpropFilterV2",bp="Conv3DBackpropInputV2",Va="Cos",Ua="Cosh",Ha="Cumsum",ji="CropAndResize",vp="DenseBincount",qi="DepthToSpace",Ga="DepthwiseConv2dNative",wp="DepthwiseConv2dNativeBackpropFilter",kp="DepthwiseConv2dNativeBackpropInput",Ip="Diag",ec="Dilation2D",Sp="Dilation2DBackpropInput",Cp="Dilation2DBackpropFilter",ja="RealDiv",Tp="Einsum",qa="Elu",Np="EluGrad",Xi="Erf",Ki="Equal",Xa="Exp",Zi="ExpandDims",Yi="Expm1",Ep="FFT",tc="Fill",Ji="FlipLeftRight",Ka="Floor",Za="FloorDiv",Ya="FusedBatchNorm",Qi="GatherV2",el="GatherNd",tl="Greater",Ja="GreaterEqual",Qa="Identity",Rp="IFFT",Dp="Imag",nl="IsFinite",sl="IsInf",rl="IsNan",eo="LeakyRelu",al="Less",ol="LessEqual",_p="LinSpace",to="Log",il="Log1p",ll="LogicalAnd",nc="LogicalNot",sc="LogicalOr",h5="LogSoftmax",rc="LRN",$p="LRNGrad",no="Max",so="Maximum",ro="MaxPool",Fp="MaxPoolGrad",ac="MaxPool3D",Op="MaxPool3DGrad",Pp="MaxPoolWithArgmax",ao="Mean",oo="Min",io="Minimum",lo="MirrorPad",ul="Mod",Mp="Multinomial",uo="Multiply",cl="Neg",dl="NotEqual",pl="NonMaxSuppressionV3",hl="NonMaxSuppressionV4",fl="NonMaxSuppressionV5",ml="OnesLike",co="OneHot",gl="Pack",po="PadV2",aC="Pool",ho="Pow",fo="Prelu",Al="Prod",oc="Range",zp="Real",yl="Reciprocal",mo="Relu",xl="Reshape",ic="ResizeNearestNeighbor",Lp="ResizeNearestNeighborGrad",go="ResizeBilinear",Bp="ResizeBilinearGrad",Ao="Relu6",yo="Reverse",xo="Round",bo="Rsqrt",bl="ScatterNd",vl="Select",wl="Selu",kl="Slice",vo="Sin",Il="Sinh",Sl="Sign",wo="Sigmoid",Cl="Softplus",ko="Sqrt",Io="Sum",Tl="SpaceToBatchND",Nl="SplitV",So="Softmax",Wp="SparseFillEmptyRows",Vp="SparseReshape",Up="SparseSegmentMean",Hp="SparseSegmentSum",Gp="SparseToDense",Co="SquaredDifference",lc="Square",El="StridedSlice",jp="StringNGrams",qp="StringSplit",Xp="StringToHashBucketFast",To="Sub",No="Tan",Eo="Tanh",Qr="Tile",Rl="TopK",Dl="Transform",Ro="Transpose",Kp="Unique",_l="Unpack",uc="UnsortedSegmentSum",$l="ZerosLike",ea="Step",Zp="FromPixels",Fl="RotateWithOffset",Do="_FusedMatMul",_o="FusedConv2D",$o="FusedDepthwiseConv2D",Ol=dg("kernelRegistry",()=>new Map),cc=dg("gradRegistry",()=>new Map);function Yp(e,t){let n=fg(e,t);return Ol.get(n)}function hg(e){return cc.get(e)}function ta(e){let t=Ol.entries(),n=[];for(;;){let{done:s,value:r}=t.next();if(s)break;let[a,o]=r,[i]=a.split("_");i===e&&n.push(o)}return n}function Fo(e){let{kernelName:t,backendName:n}=e,s=fg(t,n);Ol.has(s)&&tr(`The kernel '${t}' for backend '${n}' is already registered`),Ol.set(s,e)}function f5(e){let{kernelName:t}=e;cc.has(t)&&Y().getBool("DEBUG")&&tr(`Overriding the gradient for '${t}'`),cc.set(t,e)}function oC(e,t){let n=fg(e,t);if(!Ol.has(n))throw new Error(`The kernel '${e}' for backend '${t}' is not registered`);Ol.delete(n)}function iC(e){if(!cc.has(e))throw new Error(`The gradient '${e}' for backend is not registered`);cc.delete(e)}function lC(e,t){ta(e).forEach(s=>{let r=Object.assign({},s,{backendName:t});Fo(r)})}function fg(e,t){return`${t}_${e}`}var w={};Le(w,{arraysEqual:()=>Ir,assert:()=>M,assertNonNegativeIntegerDimensions:()=>lg,assertNonNull:()=>_a,assertShapesMatch:()=>In,bytesFromStringArray:()=>a5,bytesPerElement:()=>og,checkConversionForErrors:()=>s5,clamp:()=>Xu,computeStrides:()=>_i,createScalarValue:()=>fC,createShuffledIndices:()=>jS,decodeString:()=>eh,distSquared:()=>VS,encodeString:()=>hc,fetch:()=>gC,fingerPrint64:()=>hC,flatten:()=>$a,getArrayFromDType:()=>n5,getTypedArrayFromDType:()=>t5,hasEncodingLoss:()=>KS,hexToLong:()=>dc,indexToLoc:()=>JS,inferDtype:()=>dp,inferFromImplicitShape:()=>XS,isBoolean:()=>o5,isFunction:()=>Zr,isInt:()=>sn,isNumber:()=>i5,isPromise:()=>ug,isScalarShape:()=>US,isString:()=>Kr,isTypedArray:()=>bn,isValidDtype:()=>r5,locToIndex:()=>YS,makeOnesTypedArray:()=>ig,makeZerosNestedTypedArray:()=>ZS,makeZerosTypedArray:()=>hp,nearestDivisor:()=>pp,nearestLargerEven:()=>LS,now:()=>pc,parseAxisParam:()=>Rs,randUniform:()=>WS,repeatedTry:()=>qS,rightPad:()=>Ku,shuffle:()=>Qx,shuffleCombo:()=>zS,sizeFromShape:()=>zt,sizeToSquarishShape:()=>GS,squeezeShape:()=>e5,sum:()=>BS,swap:()=>cp,tanh:()=>HS,toNestedArray:()=>$i,toTypedArray:()=>Qp});var m5=Da(gS()),Oo=m5.default||m5;function dc(e){return Oo.fromString(e,!0,16)}var g5=dc("c3a5c85c97cb3127"),Po=dc("b492b66fbe98f273"),Sn=dc("9ae16a3b2f90404f");function mg(e){return e.xor(e.shru(47))}function A5(e,t,n){let s=e.slice(t,t+n);return Oo.fromBytes(Array.from(s),!0,!0)}function At(e,t){return A5(e,t,8)}function y5(e,t){return A5(e,t,4)}function rn(e,t){return t===0?e:e.shru(t).or(e.shl(64-t))}function na(e,t,n=dc("9ddfea08eb382d69")){let s=e.xor(t).mul(n);s=s.xor(s.shru(47));let r=t.xor(s).mul(n);return r=r.xor(r.shru(47)),r=r.mul(n),r}function uC(e,t,n,s,r,a){r=r.add(e),a=rn(a.add(r).add(s),21);let o=r;return r=r.add(t),r=r.add(n),a=a.add(rn(r,44)),[r.add(s),a.add(o)]}function Jp(e,t,n,s){return uC(At(e,t),At(e,t+8),At(e,t+16),At(e,t+24),n,s)}function cC(e,t=e.length){if(t>=8){let n=Sn.add(t*2),s=At(e,0).add(Sn),r=At(e,t-8),a=rn(r,37).mul(n).add(s),o=rn(s,25).add(r).mul(n);return na(a,o,n)}if(t>=4){let n=Sn.add(t*2),s=y5(e,0);return na(s.shl(3).add(t),y5(e,t-4),n)}if(t>0){let n=e[0],s=e[t>>1],r=e[t-1],a=n+(s<<8),o=t+(r<<2);return mg(Sn.mul(a).xor(g5.mul(o))).mul(Sn)}return Sn}function dC(e,t=e.length){let n=Sn.add(t*2),s=At(e,0).mul(Po),r=At(e,8),a=At(e,t-8).mul(n),o=At(e,t-16).mul(Sn);return na(rn(s.add(r),43).add(rn(a,30)).add(o),s.add(rn(r.add(Sn),18)).add(a),n)}function pC(e,t=e.length){let n=Sn.add(t*2),s=At(e,0).mul(Sn),r=At(e,8),a=At(e,t-8).mul(n),o=At(e,t-16).mul(Sn),i=rn(s.add(r),43).add(rn(a,30)).add(o),l=na(i,s.add(rn(r.add(Sn),18)).add(a),n),u=At(e,16).mul(n),c=At(e,24),d=i.add(At(e,t-32)).mul(n),p=l.add(At(e,t-24)).mul(n);return na(rn(u.add(c),43).add(rn(d,30)).add(p),u.add(rn(c.add(s),18)).add(d),n)}function hC(e,t=e.length){let n=Oo.fromNumber(81,!0);if(t<=32)return t<=16?cC(e,t):dC(e,t);if(t<=64)return pC(e,t);let s=n,r=n.mul(Po).add(113),a=mg(r.mul(Sn).add(113)).mul(Sn),o=[Oo.UZERO,Oo.UZERO],i=[Oo.UZERO,Oo.UZERO];s=s.mul(Sn).add(At(e,0));let l=0,u=(t-1>>6)*64,c=u+(t-1&63)-63;do s=rn(s.add(r).add(o[0]).add(At(e,l+8)),37).mul(Po),r=rn(r.add(o[1]).add(At(e,l+48)),42).mul(Po),s=s.xor(i[1]),r=r.add(o[0]).add(At(e,l+40)),a=rn(a.add(i[0]),33).mul(Po),o=Jp(e,l,o[1].mul(Po),s.add(i[0])),i=Jp(e,l+32,a.add(i[1]),r.add(At(e,l+16))),[a,s]=[s,a],l+=64;while(l!==u);let d=Po.add(a.and(255).shl(1));return l=c,i[0]=i[0].add(t-1&63),o[0]=o[0].add(i[0]),i[0]=i[0].add(o[0]),s=rn(s.add(r).add(o[0]).add(At(e,l+8)),37).mul(d),r=rn(r.add(o[1]).add(At(e,l+48)),42).mul(d),s=s.xor(i[1].mul(9)),r=r.add(o[0].mul(9).add(At(e,l+40))),a=rn(a.add(i[0]),33).mul(d),o=Jp(e,l,o[1].mul(d),s.add(i[0])),i=Jp(e,l+32,a.add(i[1]),r.add(At(e,l+16))),[a,s]=[s,a],na(na(o[0],i[0],d).add(mg(r).mul(g5)).add(a),na(o[1],i[1],d).add(s),d)}function fC(e,t){return t==="string"?hc(e):Qp([e],t)}function mC(e,t){return e instanceof Float32Array&&t==="float32"||e instanceof Int32Array&&t==="int32"||e instanceof Uint8Array&&t==="bool"}function Qp(e,t){if(t==="string")throw new Error("Cannot convert a string[] to a TypedArray");if(Array.isArray(e)&&(e=$a(e)),Y().getBool("DEBUG")&&s5(e,t),mC(e,t))return e;if(t==null||t==="float32"||t==="complex64")return new Float32Array(e);if(t==="int32")return new Int32Array(e);if(t==="bool"){let n=new Uint8Array(e.length);for(let s=0;s<n.length;++s)Math.round(e[s])!==0&&(n[s]=1);return n}else throw new Error(`Unknown data type ${t}`)}function pc(){return Y().platform.now()}function gC(e,t){return Y().platform.fetch(e,t)}function hc(e,t="utf-8"){return t=t||"utf-8",Y().platform.encode(e,t)}function eh(e,t="utf-8"){return t=t||"utf-8",Y().platform.decode(e,t)}var AC=class{constructor(e,t){this.backendTimer=e,this.logger=t,t==null&&(this.logger=new xC)}profileKernel(e,t,n){let s,r=()=>{s=n()},a,o=pc();if(this.backendTimer.timerAvailable())a=this.backendTimer.time(r);else{r();for(let l of s)l.dataSync();a=Promise.resolve({kernelMs:pc()-o})}if(Y().getBool("CHECK_COMPUTATION_FOR_ERRORS"))for(let l=0;l<s.length;l++){let u=s[l];u.data().then(c=>{yC(c,u.dtype,e)})}return{kernelName:e,outputs:s,inputs:t,timeMs:a.then(l=>l.kernelMs),extraInfo:a.then(l=>l.getExtraProfileInfo!=null?l.getExtraProfileInfo():"")}}logKernelProfile(e){let{kernelName:t,outputs:n,timeMs:s,inputs:r,extraInfo:a}=e;n.forEach(o=>{Promise.all([o.data(),s,a]).then(i=>{this.logger.logKernelProfile(t,o,i[0],i[1],r,i[2])})})}};function yC(e,t,n){if(t!=="float32")return!1;for(let s=0;s<e.length;s++){let r=e[s];if(isNaN(r)||!isFinite(r))return console.warn(`Found ${r} in the result of '${n}'`),!0}return!1}var xC=class{logKernelProfile(e,t,n,s,r,a){let o=typeof s=="number"?Ku(`${s}ms`,9):s.error,i=Ku(e,25),l=t.rank,u=t.size,c=Ku(t.shape.toString(),14),d="";for(let p in r){let h=r[p];if(h!=null){let f=h.shape||t.shape,m=f.length;d+=`${p}: ${m}D ${m>0?f:""} `}}console.log(`%c${i} %c${o} %c${l}D ${c} %c${u} %c${d} %c${a}`,"font-weight:bold","color:red","color:blue","color: orange","color: green","color: steelblue")}};function bC(e,t,n){let s={},r={};for(let l=0;l<t.length;l++)s[t[l].id]=!0;for(let l=0;l<e.length;l++){let u=e[l],c=u.inputs;for(let d in c){let p=c[d],h=!1;for(let f=0;f<t.length;f++)if(s[p.id]){u.outputs.forEach(m=>s[m.id]=!0),h=!0,r[u.id]=!0;break}if(h)break}}let a={};a[n.id]=!0;let o={};for(let l=e.length-1;l>=0;l--){let u=e[l],c=u.inputs;for(let d=0;d<u.outputs.length;d++)if(a[u.outputs[d].id]){for(let p in c)a[c[p].id]=!0,o[u.id]=!0;break}}let i=[];for(let l=0;l<e.length;l++){let u=e[l];if(r[u.id]&&o[u.id]){let c={};for(let p in u.inputs){let h=u.inputs[p];s[h.id]&&(c[p]=h)}let d=Object.assign({},u);d.inputs=c,d.outputs=u.outputs,i.push(d)}}return i}function vC(e,t,n,s){for(let r=t.length-1;r>=0;r--){let a=t[r],o=[];if(a.outputs.forEach(l=>{let u=e[l.id];u!=null?o.push(u):o.push(null)}),a.gradient==null)throw new Error(`Cannot compute gradient: gradient function not found for ${a.kernelName}.`);let i=a.gradient(o);for(let l in a.inputs){if(!(l in i))throw new Error(`Cannot backprop through input ${l}. Available gradients found: ${Object.keys(i)}.`);let u=n(()=>i[l]());if(u.dtype!=="float32")throw new Error(`Error in gradient for op ${a.kernelName}. The gradient of input ${l} must have 'float32' dtype, but has '${u.dtype}'`);let c=a.inputs[l];if(!Ir(u.shape,c.shape))throw new Error(`Error in gradient for op ${a.kernelName}. The gradient of input '${l}' has shape '${u.shape}', which does not match the shape of the input '${c.shape}'`);if(e[c.id]==null)e[c.id]=u;else{let d=e[c.id];e[c.id]=s(d,u),d.dispose()}}}}var x5=20,fc=3,gg=7;function wC(e,t,n,s){let r=_i(t),a=kC(e,t,n,r),o=t.length,i=th(e,t,n,r,a),l=["Tensor"];return s&&(l.push(` dtype: ${n}`),l.push(` rank: ${o}`),l.push(` shape: [${t}]`),l.push(" values:")),l.push(i.map(u=>" "+u).join(`
|
|
`)),l.join(`
|
|
`)}function kC(e,t,n,s){let r=zt(t),a=s[s.length-1],o=new Array(a).fill(0),i=t.length,l=n==="complex64"?gc(e):e;if(i>1)for(let u=0;u<r/a;u++){let c=u*a;for(let d=0;d<a;d++)o[d]=Math.max(o[d],mc(l[c+d],0,n).length)}return o}function mc(e,t,n){let s;return Array.isArray(e)?s=`${parseFloat(e[0].toFixed(gg))} + ${parseFloat(e[1].toFixed(gg))}j`:Kr(e)?s=`'${e}'`:n==="bool"?s=b5(e):s=parseFloat(e.toFixed(gg)).toString(),Ku(s,t)}function b5(e){return e===0?"false":"true"}function th(e,t,n,s,r,a=!0){let o=n==="complex64"?2:1,i=t[0],l=t.length;if(l===0){if(n==="complex64"){let m=gc(e);return[mc(m[0],0,n)]}return n==="bool"?[b5(e[0])]:[e[0].toString()]}if(l===1){if(i>x5){let g=fc*o,A=Array.from(e.slice(0,g)),y=Array.from(e.slice((i-fc)*o,i*o));return n==="complex64"&&(A=gc(A),y=gc(y)),["["+A.map((x,b)=>mc(x,r[b],n)).join(", ")+", ..., "+y.map((x,b)=>mc(x,r[i-fc+b],n)).join(", ")+"]"]}let m=n==="complex64"?gc(e):Array.from(e);return["["+m.map((g,A)=>mc(g,r[A],n)).join(", ")+"]"]}let u=t.slice(1),c=s.slice(1),d=s[0]*o,p=[];if(i>x5){for(let m=0;m<fc;m++){let g=m*d,A=g+d;p.push(...th(e.slice(g,A),u,n,c,r,!1))}p.push("...");for(let m=i-fc;m<i;m++){let g=m*d,A=g+d;p.push(...th(e.slice(g,A),u,n,c,r,m===i-1))}}else for(let m=0;m<i;m++){let g=m*d,A=g+d;p.push(...th(e.slice(g,A),u,n,c,r,m===i-1))}let h=l===2?",":"";p[0]="["+p[0]+h;for(let m=1;m<p.length-1;m++)p[m]=" "+p[m]+h;let f=`,
|
|
`;for(let m=2;m<l;m++)f+=`
|
|
`;return p[p.length-1]=" "+p[p.length-1]+"]"+(a?"":f),p}function gc(e){let t=[];for(let n=0;n<e.length;n+=2)t.push([e[n],e[n+1]]);return t}var Kt=class{constructor(e,t,n){if(this.dtype=t,this.shape=e.slice(),this.size=zt(e),n!=null){let s=n.length;M(s===this.size,()=>`Length of values '${s}' does not match the size inferred by the shape '${this.size}'.`)}if(t==="complex64")throw new Error("complex64 dtype TensorBuffers are not supported. Please create a TensorBuffer for the real and imaginary parts separately and call tf.complex(real, imag).");this.values=n||n5(t,this.size),this.strides=_i(e)}set(e,...t){t.length===0&&(t=[0]),M(t.length===this.rank,()=>`The number of provided coordinates (${t.length}) must match the rank (${this.rank})`);let n=this.locToIndex(t);this.values[n]=e}get(...e){e.length===0&&(e=[0]);let t=0;for(let s of e){if(s<0||s>=this.shape[t]){let r=`Requested out of range element at ${e}. Buffer shape=${this.shape}`;throw new Error(r)}t++}let n=e[e.length-1];for(let s=0;s<e.length-1;++s)n+=this.strides[s]*e[s];return this.values[n]}locToIndex(e){if(this.rank===0)return 0;if(this.rank===1)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(this.rank===0)return[];if(this.rank===1)return[e];let 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 sr().makeTensor(this.values,this.shape,this.dtype)}},sr=null,Pl=null,IC=null;function SC(e){sr=e}function CC(e){Pl=e}function TC(e){IC=e}var Ge=class{constructor(e,t,n,s){this.kept=!1,this.isDisposedInternal=!1,this.shape=e.slice(),this.dtype=t||"float32",this.size=zt(e),this.strides=_i(e),this.dataId=n,this.id=s,this.rankType=this.rank<5?this.rank.toString():"higher"}get rank(){return this.shape.length}async buffer(){let e=await this.data();return Pl.buffer(this.shape,this.dtype,e)}bufferSync(){return Pl.buffer(this.shape,this.dtype,this.dataSync())}async array(){let e=await this.data();return $i(this.shape,e,this.dtype==="complex64")}arraySync(){return $i(this.shape,this.dataSync(),this.dtype==="complex64")}async data(){this.throwIfDisposed();let e=sr().read(this.dataId);if(this.dtype==="string"){let t=await e;try{return t.map(n=>eh(n))}catch(n){throw new Error("Failed to decode the string bytes into utf-8. To get the original bytes, call tensor.bytes().")}}return e}dataSync(){this.throwIfDisposed();let e=sr().readSync(this.dataId);if(this.dtype==="string")try{return e.map(t=>eh(t))}catch(t){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();let e=await sr().read(this.dataId);return this.dtype==="string"?e:new Uint8Array(e.buffer)}dispose(){this.isDisposed||(sr().disposeTensor(this),this.isDisposedInternal=!0)}get isDisposed(){return this.isDisposedInternal}throwIfDisposed(){if(this.isDisposed)throw new Error("Tensor is disposed.")}print(e=!1){return Pl.print(this,e)}clone(){return this.throwIfDisposed(),Pl.clone(this)}toString(e=!1){let t=this.dataSync();return wC(t,this.shape,this.dtype,e)}cast(e){return this.throwIfDisposed(),Pl.cast(this,e)}variable(e=!0,t,n){return this.throwIfDisposed(),sr().makeVariable(this,e,t,n)}};Object.defineProperty(Ge,Symbol.hasInstance,{value:e=>!!e&&e.data!=null&&e.dataSync!=null&&e.throwIfDisposed!=null});function ee(){return dg("Tensor",()=>Ge)}ee();var Ac=class extends Ge{constructor(e,t,n,s){super(e.shape,e.dtype,e.dataId,s);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(!Ir(e.shape,this.shape))throw new Error(`shape of the new value (${e.shape}) and previous value (${this.shape}) must match`);sr().disposeTensor(this),this.dataId=e.dataId,sr().incRef(this,null)}dispose(){sr().disposeVariable(this),this.isDisposedInternal=!0}};Object.defineProperty(Ac,Symbol.hasInstance,{value:e=>e instanceof Ge&&e.assign!=null&&e.assign instanceof Function});var zs={};Le(zs,{assertTypesMatch:()=>v5,getTensorsInContainer:()=>wg,isTensorInList:()=>EC,makeTypesMatch:()=>Rt});var Ag;(function(e){e.R0="R0",e.R1="R1",e.R2="R2",e.R3="R3",e.R4="R4",e.R5="R5",e.R6="R6"})(Ag||(Ag={}));var yg;(function(e){e.float32="float32",e.int32="int32",e.bool="int32",e.complex64="complex64"})(yg||(yg={}));var xg;(function(e){e.float32="float32",e.int32="int32",e.bool="bool",e.complex64="complex64"})(xg||(xg={}));var bg;(function(e){e.float32="float32",e.int32="float32",e.bool="float32",e.complex64="complex64"})(bg||(bg={}));var vg;(function(e){e.float32="complex64",e.int32="complex64",e.bool="complex64",e.complex64="complex64"})(vg||(vg={}));var NC={float32:bg,int32:yg,bool:xg,complex64:vg};function Ds(e,t){if(e==="string"||t==="string"){if(e==="string"&&t==="string")return"string";throw new Error(`Can not upcast ${e} with ${t}`)}return NC[e][t]}function nh(e){return Ds(e,"int32")}function Rt(e,t){if(e.dtype===t.dtype)return[e,t];let n=Ds(e.dtype,t.dtype);return[e.cast(n),t.cast(n)]}function v5(e,t){M(e.dtype===t.dtype,()=>`The dtypes of the first(${e.dtype}) and second(${t.dtype}) input must match`)}function EC(e,t){return t.some(n=>n.id===e.id)}function wg(e){let t=[],n=new Set;return w5(e,t,n),t}function w5(e,t,n){if(e==null)return;if(e instanceof Ge){t.push(e);return}if(!RC(e))return;let s=e;for(let r in s){let a=s[r];n.has(a)||(n.add(a),w5(a,t,n))}}function RC(e){return Array.isArray(e)||typeof e=="object"}function kg(e){return e.kernelName!=null}var k5=class{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(let e in this.registeredVariables)this.registeredVariables[e].dispose()}},yc=class{constructor(e){this.ENV=e,this.registry={},this.registryFactory={},this.pendingBackendInitId=0,this.state=new k5}async ready(){if(this.pendingBackendInit!=null)return this.pendingBackendInit.then(()=>{});if(this.backendInstance!=null)return;let e=this.getSortedBackends();for(let t=0;t<e.length;t++){let n=e[t];if(await this.initializeBackend(n).success){await this.setBackend(n);return}}throw new Error("Could not initialize any backends, all backend initializations failed.")}get backend(){if(this.pendingBackendInit!=null)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(this.backendInstance==null){let{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){let{asyncInit:t}=this.initializeBackend(e);if(t)return null}else 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?(tr(`${e} backend was already registered. Reusing existing backend factory.`),!1):(this.registryFactory[e]={factory:t,priority:n},!0)}async setBackend(e){if(this.registryFactory[e]==null)throw new Error(`Backend name '${e}' not found in registry`);if(this.backendName=e,this.registry[e]==null){this.backendInstance=null;let{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 AC(this.backendInstance),!0}setupRegisteredKernels(){ta(this.backendName).forEach(t=>{t.setupFunc!=null&&t.setupFunc(this.backendInstance)})}disposeRegisteredKernels(e){ta(e).forEach(n=>{n.disposeFunc!=null&&n.disposeFunc(this.registry[e])})}initializeBackend(e){let t=this.registryFactory[e];if(t==null)throw new Error(`Cannot initialize backend ${e}, no registration found.`);try{let n=t.factory();if(n&&!(n instanceof qu)&&typeof n.then=="function"){let s=++this.pendingBackendInitId,r=n.then(a=>s<this.pendingBackendInitId?!1:(this.registry[e]=a,this.pendingBackendInit=null,!0)).catch(a=>(s<this.pendingBackendInitId||(this.pendingBackendInit=null,tr(`Initialization of backend ${e} failed`),tr(a.stack||a.message)),!1));return this.pendingBackendInit=r,{success:r,asyncInit:!0}}else return this.registry[e]=n,{success:!0,asyncInit:!1}}catch(n){return tr(`Initialization of backend ${e} failed`),tr(n.stack||n.message),{success:!1,asyncInit:!1}}}removeBackend(e){if(!(e in this.registryFactory))throw new Error(`${e} backend not found in registry`);this.backendName===e&&this.pendingBackendInit!=null&&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(Object.keys(this.registryFactory).length===0)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(){let e=this.getSortedBackends();for(let t=0;t<e.length;t++){let n=e[t],{success:s,asyncInit:r}=this.initializeBackend(n);if(r||s)return{name:n,asyncInit:r}}throw new Error("Could not initialize any backends, all backend initializations failed.")}moveData(e,t){let n=this.state.tensorInfo.get(t),s=n.backend,r=this.readSync(t),a=s.refCount(t);s.disposeData(t,!0),n.backend=e,e.move(t,r,n.shape,n.dtype,a),this.shouldCheckForMemLeaks()&&this.state.numDataMovesStack[this.state.numDataMovesStack.length-1]++}tidy(e,t){let n=null;if(t==null){if(typeof e!="function")throw new Error("Please provide a function to tidy()");t=e}else{if(typeof e!="string"&&!(e instanceof String))throw new Error("When calling with two arguments, the first argument to tidy() must be a string");if(typeof t!="function")throw new Error("When calling with two arguments, the 2nd argument to tidy() must be a function");n=e}let s;return this.scopedRun(()=>this.startScope(n),()=>this.endScope(s),()=>(s=t(),s instanceof Promise&&console.error("Cannot return a Promise inside of tidy."),s))}scopedRun(e,t,n){e();try{let s=n();return t(),s}catch(s){throw t(),s}}nextTensorId(){return yc.nextTensorId++}nextVariableId(){return yc.nextVariableId++}clone(e){let t=L.runKernel(Qa,{x:e}),n={x:e},s=a=>({x:()=>{let o="float32",i={x:a},l={dtype:o};return L.runKernel(za,i,l)}}),r=[];return this.addTapeNode(this.state.activeScope.name,n,[t],s,r,{}),t}runKernel(e,t,n){if(this.backendName==null&&this.backend,!(Yp(e,this.backendName)!=null))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){let s=this.backend.numDataIds(),r=0;n.forEach(i=>{r+=i.dtype==="complex64"?3:1});let a=this.state.numDataMovesStack[this.state.numDataMovesStack.length-1],o=s-t-r-a;if(o>0)throw new Error(`Backend '${this.backendName}' has an internal memory leak (${o} data ids) after running '${e}'`)}runKernelFunc(e){let t,n=[],s=this.isTapeOn(),r=this.state.numBytes,a=this.state.numTensors;this.shouldCheckForMemLeaks()&&this.state.numDataMovesStack.push(0);let o;this.backendName==null&&this.backend;let i,l=kg(e)?e.kernelName:this.state.activeScope!=null?this.state.activeScope.name:"";if(kg(e)){let{kernelName:h,inputs:f,attrs:m}=e;this.backendName==null&&this.backend;let g=Yp(h,this.backendName);M(g!=null,()=>`Cannot find registered kernel '${h}' for backend '${this.backendName}'`),o=()=>{let A=this.backend.numDataIds();i=g.kernelFunc({inputs:f,attrs:m,backend:this.backend});let y=Array.isArray(i)?i:[i];this.shouldCheckForMemLeaks()&&this.checkKernelForMemLeak(h,A,y);let x=y.map(b=>{if(b.rank!=null)return b;let{dataId:v,shape:k,dtype:S}=b;return this.makeTensorFromDataId(v,k,S)});if(s){let b=this.getTensorsForGradient(h,f,x);n=this.saveTensorsForBackwardMode(b)}return x}}else{let{forwardFunc:h}=e,f=m=>{!s||(n=m.map(g=>this.keep(this.clone(g))))};o=()=>{let m=this.backend.numDataIds();i=this.tidy(()=>h(this.backend,f));let g=Array.isArray(i)?i:[i];return this.shouldCheckForMemLeaks()&&this.checkKernelForMemLeak(l,m,g),g}}let{inputs:u,attrs:c}=e,d=kg(e)?null:e.backwardsFunc,p;return this.scopedRun(()=>this.state.kernelDepth++,()=>this.state.kernelDepth--,()=>{!this.ENV.getBool("DEBUG")&&!this.state.profiling?t=o():(p=this.profiler.profileKernel(l,u,()=>o()),this.ENV.getBool("DEBUG")&&this.profiler.logKernelProfile(p),t=p.outputs)}),s&&this.addTapeNode(l,u,t,d,n,c),this.state.profiling&&this.state.activeProfile.kernels.push({name:l,bytesAdded:this.state.numBytes-r,totalBytesSnapshot:this.state.numBytes,tensorsAdded:this.state.numTensors-a,totalTensorsSnapshot:this.state.numTensors,inputShapes:Object.keys(u).map(h=>u[h]!=null?u[h].shape:null),outputShapes:t.map(h=>h.shape),kernelTimeMs:p.timeMs,extraInfo:p.extraInfo}),Array.isArray(i)?t:t[0]}saveTensorsForBackwardMode(e){return e.map(n=>this.keep(this.clone(n)))}getTensorsForGradient(e,t,n){let s=hg(e);if(s!=null){let r=s.inputsToSave||[],a=s.outputsToSave||[],o;s.saveAllInputs?(M(Array.isArray(t),()=>"saveAllInputs is true, expected inputs to be an array."),o=Object.keys(t).map(l=>t[l])):o=r.map(l=>t[l]);let i=n.filter((l,u)=>a[u]);return o.concat(i)}return[]}makeTensor(e,t,n,s){if(e==null)throw new Error("Values passed to engine.makeTensor() are null");n=n||"float32",s=s||this.backend;let r=e;n==="string"&&Kr(e[0])&&(r=e.map(i=>hc(i)));let a=s.write(r,t,n),o=new Ge(t,n,a,this.nextTensorId());if(this.trackTensor(o,s),n==="string"){let i=this.state.tensorInfo.get(a),l=a5(r);this.state.numBytes+=l-i.bytes,i.bytes=l}return o}makeTensorFromDataId(e,t,n,s){n=n||"float32";let r=new Ge(t,n,e,this.nextTensorId());return this.trackTensor(r,s),r}makeVariable(e,t=!0,n,s){n=n||this.nextVariableId().toString(),s!=null&&s!==e.dtype&&(e=e.cast(s));let r=new Ac(e,t,n,this.nextTensorId());if(this.state.registeredVariables[r.name]!=null)throw new Error(`Variable with name ${r.name} was already registered`);return this.state.registeredVariables[r.name]=r,this.incRef(r,this.backend),r}trackTensor(e,t){this.state.numTensors++,e.dtype==="string"&&this.state.numStringTensors++;let n=0;e.dtype!=="complex64"&&e.dtype!=="string"&&(n=e.size*og(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 Ac||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;let t=this.state.tensorInfo.get(e.dataId);if(this.state.numTensors--,e.dtype==="string"&&(this.state.numStringTensors--,this.state.numBytes-=t.bytes),e.dtype!=="complex64"&&e.dtype!=="string"){let n=e.size*og(e.dtype);this.state.numBytes-=n}t.backend.disposeData(e.dataId)&&this.removeDataId(e.dataId,t.backend)}disposeVariables(){for(let e in this.state.registeredVariables){let t=this.state.registeredVariables[e];this.disposeVariable(t)}}disposeVariable(e){this.disposeTensor(e),this.state.registeredVariables[e.name]!=null&&delete this.state.registeredVariables[e.name]}memory(){let e=this.backend.memory();return e.numTensors=this.state.numTensors,e.numDataBuffers=this.state.numDataBuffers,e.numBytes=this.state.numBytes,this.state.numStringTensors>0&&(e.unreliable=!0,e.reasons==null&&(e.reasons=[]),e.reasons.push("Memory usage by string tensors is approximate (2 bytes per character)")),e}async profile(e){this.state.profiling=!0;let 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(s=>s.totalBytesSnapshot)),this.state.activeProfile.newBytes=this.state.numBytes-t,this.state.activeProfile.newTensors=this.state.numTensors-n;for(let s of this.state.activeProfile.kernels)s.kernelTimeMs=await s.kernelTimeMs,s.extraInfo=await s.extraInfo;return this.state.activeProfile}isTapeOn(){return this.state.gradientDepth>0&&this.state.kernelDepth===0}addTapeNode(e,t,n,s,r,a){let o={id:this.state.nextTapeNodeId++,kernelName:e,inputs:t,outputs:n,saved:r},i=hg(e);i!=null&&(s=i.gradFunc),s!=null&&(o.gradient=l=>(l=l.map((u,c)=>{if(u==null){let d=n[c],p=hp(d.size,d.dtype);return this.makeTensor(p,d.shape,d.dtype)}return u}),s(l.length>1?l:l[0],r,a))),this.state.activeTape.push(o)}keep(e){return e.kept=!0,e}startTape(){this.state.gradientDepth===0&&(this.state.activeTape=[]),this.state.gradientDepth++}endTape(){this.state.gradientDepth--}startScope(e){let t={track:[],name:"unnamed scope",id:this.state.nextScopeId++};e&&(t.name=e),this.state.scopeStack.push(t),this.state.activeScope=t}endScope(e){let t=wg(e),n=new Set(t.map(r=>r.id));for(let r=0;r<this.state.activeScope.track.length;r++){let a=this.state.activeScope.track[r];!a.kept&&!n.has(a.id)&&a.dispose()}let s=this.state.scopeStack.pop();this.state.activeScope=this.state.scopeStack.length===0?null:this.state.scopeStack[this.state.scopeStack.length-1],t.forEach(r=>{!r.kept&&r.scopeId===s.id&&this.track(r)})}gradients(e,t,n,s=!1){if(M(t.length>0,()=>"gradients() received an empty list of xs."),n!=null&&n.dtype!=="float32")throw new Error(`dy must have 'float32' dtype, but has '${n.dtype}'`);let r=this.scopedRun(()=>this.startTape(),()=>this.endTape(),()=>this.tidy("forward",e));M(r instanceof Ge,()=>"The result y returned by f() must be a tensor.");let a=bC(this.state.activeTape,t,r);if(!s&&a.length===0&&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",()=>{let o={};o[r.id]=n==null?DC(r.shape):n,vC(o,a,l=>this.tidy(l),_C);let i=t.map(l=>o[l.id]);return this.state.gradientDepth===0&&(this.state.activeTape.forEach(l=>{for(let u of l.saved)u.dispose()}),this.state.activeTape=null),{value:r,grads:i}})}customGrad(e){return M(Zr(e),()=>"The f passed in customGrad(f) must be a function."),(...t)=>{M(t.every(o=>o instanceof Ge),()=>"The args passed in customGrad(f)(x1, x2,...) must all be tensors");let n,s={};t.forEach((o,i)=>{s[i]=o});let r=(o,i)=>(n=e(...t,i),M(n.value instanceof Ge,()=>"The function f passed in customGrad(f) must return an object where `obj.value` is a tensor"),M(Zr(n.gradFunc),()=>"The function f passed in customGrad(f) must return an object where `obj.gradFunc` is a function."),n.value),a=(o,i)=>{let l=n.gradFunc(o,i),u=Array.isArray(l)?l:[l];M(u.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(...)."),M(u.every(d=>d instanceof Ge),()=>"The function f passed in customGrad(f) must return an object where `obj.gradFunc` is a function that returns a list of only tensors.");let c={};return u.forEach((d,p)=>{c[p]=()=>d}),c};return this.runKernelFunc({forwardFunc:r,backwardsFunc:a,inputs:s})}}readSync(e){return this.state.tensorInfo.get(e).backend.readSync(e)}read(e){return this.state.tensorInfo.get(e).backend.read(e)}async time(e){let t=pc(),n=await this.backend.time(e);return n.wallMs=pc()-t,n}track(e){return this.state.activeScope!=null&&(e.scopeId=this.state.activeScope.id,this.state.activeScope.track.push(e)),e}get registeredVariables(){return this.state.registeredVariables}reset(){this.pendingBackendInitId++,this.state.dispose(),this.ENV.reset(),this.state=new k5;for(let e in this.registry)this.disposeRegisteredKernels(e),this.registry[e].dispose(),delete this.registry[e];this.backendName=null,this.backendInstance=null,this.pendingBackendInit=null}};yc.nextTensorId=0;yc.nextVariableId=0;function DC(e){let t=ig(zt(e),"float32");return L.makeTensor(t,e,"float32")}function I5(){let e=d5();if(e._tfengine==null){let t=new c5(e);e._tfengine=new yc(t)}return sC(e._tfengine.ENV),SC(()=>e._tfengine),e._tfengine}var L=I5();function _C(e,t){let n={a:e,b:t};return L.runKernel(Yr,n)}var xc={};Le(xc,{isBrowser:()=>S5,isMobile:()=>FC});function $C(){return typeof navigator!="undefined"&&navigator!=null}function FC(e){if(e||$C()){if(e||(e=navigator),e.product==="ReactNative")return!0;let t=e.userAgent||e.vendor||(typeof window!="undefined"?window.opera:"");if(!t){let n=e;return n.userAgentData&&n.userAgentData.mobile}return/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(t)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(t.substr(0,4))}return!1}function S5(){return typeof window!="undefined"&&window.document!=null||typeof WorkerGlobalScope!="undefined"}var Ls=Y();Ls.registerFlag("DEBUG",()=>!1,e=>{e&&console.warn("Debugging mode is ON. The output of every math call will be downloaded to CPU and checked for NaNs. This significantly impacts performance.")});Ls.registerFlag("IS_BROWSER",()=>S5());Ls.registerFlag("IS_NODE",()=>typeof process!="undefined"&&typeof process.versions!="undefined"&&typeof process.versions.node!="undefined");Ls.registerFlag("IS_CHROME",()=>typeof navigator!="undefined"&&navigator!=null&&navigator.userAgent!=null&&/Chrome/.test(navigator.userAgent)&&/Google Inc/.test(navigator.vendor));Ls.registerFlag("PROD",()=>!1);Ls.registerFlag("TENSORLIKE_CHECK_SHAPE_CONSISTENCY",()=>Ls.getBool("DEBUG"));Ls.registerFlag("DEPRECATION_WARNINGS_ENABLED",()=>!0);Ls.registerFlag("IS_TEST",()=>!1);Ls.registerFlag("CHECK_COMPUTATION_FOR_ERRORS",()=>!0);Ls.registerFlag("WRAP_TO_IMAGEBITMAP",()=>!1);function rr(e,t){let n=e;if(bn(e))return t==="string"?[]:[e.length];if(!Array.isArray(e))return[];let s=[];for(;Array.isArray(n)||bn(n)&&t!=="string";)s.push(n.length),n=n[0];return Array.isArray(e)&&Y().getBool("TENSORLIKE_CHECK_SHAPE_CONSISTENCY")&&C5(e,s,[]),s}function C5(e,t,n){if(n=n||[],!Array.isArray(e)&&!bn(e)){M(t.length===0,()=>`Element arr[${n.join("][")}] is a primitive, but should be an array/TypedArray of ${t[0]} elements`);return}M(t.length>0,()=>`Element arr[${n.join("][")}] should be a primitive, but is an array of ${e.length} elements`),M(e.length===t[0],()=>`Element arr[${n.join("][")}] should have ${t[0]} elements, but has ${e.length} elements`);let s=t.slice(1);for(let r=0;r<e.length;++r)C5(e[r],s,n.concat(r))}function T5(e,t,n,s){if(e!=="string_or_numeric"){if(e==null)throw new Error("Expected dtype cannot be null.");if(e!=="numeric"&&e!==t||e==="numeric"&&t==="string")throw new Error(`Argument '${n}' passed to '${s}' must be ${e} tensor, but got ${t} tensor`)}}function $(e,t,n,s="numeric"){if(e instanceof Ge)return T5(s,e.dtype,t,n),e;let r=dp(e);if(r!=="string"&&["bool","int32","float32"].indexOf(s)>=0&&(r=s),T5(s,r,t,n),e==null||!bn(e)&&!Array.isArray(e)&&typeof e!="number"&&typeof e!="boolean"&&typeof e!="string"){let l=e==null?"null":e.constructor.name;throw new Error(`Argument '${t}' passed to '${n}' must be a Tensor or TensorLike, but got '${l}'`)}let a=rr(e,r);!bn(e)&&!Array.isArray(e)&&(e=[e]);let i=r!=="string"?Qp(e,r):$a(e,[],!0);return L.makeTensor(i,a,r)}function bc(e,t,n,s="numeric"){if(!Array.isArray(e))throw new Error(`Argument ${t} passed to ${n} must be a \`Tensor[]\` or \`TensorLike[]\``);return e.map((a,o)=>$(a,`${t}[${o}]`,n,s))}var N5="__op";function W(e){let t=Object.keys(e);if(t.length!==1)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],s=e[n];n.endsWith("_")&&(n=n.substring(0,n.length-1)),n=n+N5;let r=(...a)=>{L.startScope(n);try{let o=s(...a);return ug(o)&&console.error("Cannot return a Promise inside of tidy."),L.endScope(o),o}catch(o){throw L.endScope(null),o}};return Object.defineProperty(r,"name",{value:n,configurable:!0}),r}function OC(e,t){let n=$(e,"real","complex"),s=$(t,"imag","complex");In(n.shape,s.shape,`real and imag shapes, ${n.shape} and ${s.shape}, must match in call to tf.complex().`);let r={real:n,imag:s};return L.runKernel(Ap,r)}var sa=W({complex_:OC});function ra(e,t,n,s){if(s==null&&(s=dp(e)),s==="complex64")throw new Error("Cannot construct a complex64 tensor directly. Please use tf.complex(real, imag).");if(!bn(e)&&!Array.isArray(e)&&typeof e!="number"&&typeof e!="boolean"&&typeof e!="string")throw new Error("values passed to tensor(values) must be a number/boolean/string or an array of numbers/booleans/strings, or a TypedArray");if(t!=null){lg(t);let r=zt(t),a=zt(n);M(r===a,()=>`Based on the provided shape, [${t}], the tensor should have ${r} values but has ${a}`);for(let o=0;o<n.length;++o){let i=n[o],l=o===n.length-1?i!==zt(t.slice(o)):!0;M(n[o]===t[o]||!l,()=>`Error creating a new Tensor. Inferred shape (${n}) does not match the provided shape (${t}). `)}}return!bn(e)&&!Array.isArray(e)&&(e=[e]),t=t||n,e=s!=="string"?Qp(e,s):$a(e,[],!0),L.makeTensor(e,t,s)}function an(e,t,n){let s=rr(e,n);return ra(e,t,s,n)}var Ig={float32:4,float16:2,int32:4,uint16:2,uint8:1,bool:1,complex64:8},sh=4;async function PC(e,t){let n=[],s=[],r=Array.isArray(e)?e.map(o=>o.name):Object.keys(e);for(let o=0;o<r.length;++o){let i=r[o],l=Array.isArray(e)?e[o].tensor:e[i];if(l.dtype!=="float32"&&l.dtype!=="int32"&&l.dtype!=="bool"&&l.dtype!=="string"&&l.dtype!=="complex64")throw new Error(`Unsupported dtype in weight '${i}': ${l.dtype}`);let u={name:i,shape:l.shape,dtype:l.dtype};if(l.dtype==="string"){let c=new Promise(async d=>{let p=await l.bytes(),h=p.reduce((g,A)=>g+A.length,0)+sh*p.length,f=new Uint8Array(h),m=0;for(let g=0;g<p.length;g++){let A=p[g],y=new Uint8Array(new Uint32Array([A.length]).buffer);f.set(y,m),m+=sh,f.set(A,m),m+=A.length}d(f)});s.push(c)}else s.push(l.data());t!=null&&(u.group=t),n.push(u)}let a=await Promise.all(s);return{data:MC(a),specs:n}}function E5(e,t){let n={},s,r=0;for(let a of t){let o=a.name,i=a.dtype,l=a.shape,u=zt(l),c;if("quantization"in a){let d=a.quantization;if(d.dtype==="uint8"||d.dtype==="uint16"){if(!("min"in d&&"scale"in d))throw new Error(`Weight ${a.name} with quantization ${d.dtype} doesn't have corresponding metadata min and scale.`)}else if(d.dtype==="float16"){if(i!=="float32")throw new Error(`Weight ${a.name} is quantized with ${d.dtype} which only supports weights of type float32 not ${i}.`)}else throw new Error(`Weight ${a.name} has unknown quantization dtype ${d.dtype}. Supported quantization dtypes are: 'uint8', 'uint16', and 'float16'.`);let p=Ig[d.dtype],h=e.slice(r,r+u*p),f=d.dtype==="uint8"?new Uint8Array(h):new Uint16Array(h);if(i==="float32")if(d.dtype==="uint8"||d.dtype==="uint16"){c=new Float32Array(f.length);for(let m=0;m<f.length;m++){let g=f[m];c[m]=g*d.scale+d.min}}else if(d.dtype==="float16")s===void 0&&(s=UC()),c=s(f);else throw new Error(`Unsupported quantization type ${d.dtype} for weight type float32.`);else if(i==="int32"){if(d.dtype!=="uint8"&&d.dtype!=="uint16")throw new Error(`Unsupported quantization type ${d.dtype} for weight type int32.`);c=new Int32Array(f.length);for(let m=0;m<f.length;m++){let g=f[m];c[m]=Math.round(g*d.scale+d.min)}}else throw new Error(`Unsupported dtype in weight '${o}': ${i}`);r+=u*p}else if(i==="string"){let d=zt(a.shape);c=[];for(let p=0;p<d;p++){let h=new Uint32Array(e.slice(r,r+sh))[0];r+=sh;let f=new Uint8Array(e.slice(r,r+h));c.push(f),r+=h}}else{let d=Ig[i],p=e.slice(r,r+u*d);if(i==="float32")c=new Float32Array(p);else if(i==="int32")c=new Int32Array(p);else if(i==="bool")c=new Uint8Array(p);else if(i==="complex64"){c=new Float32Array(p);let h=new Float32Array(c.length/2),f=new Float32Array(c.length/2);for(let A=0;A<h.length;A++)h[A]=c[A*2],f[A]=c[A*2+1];let m=an(h,l,"float32"),g=an(f,l,"float32");n[o]=sa(m,g),m.dispose(),g.dispose()}else throw new Error(`Unsupported dtype in weight '${o}': ${i}`);r+=u*d}i!=="complex64"&&(n[o]=an(c,l,i))}return n}function MC(e){if(e===null)throw new Error(`Invalid input value: ${JSON.stringify(e)}`);let t=0,n=[];e.forEach(a=>{if(t+=a.byteLength,n.push(a.byteLength===a.buffer.byteLength?a:new a.constructor(a)),!(a instanceof Float32Array||a instanceof Int32Array||a instanceof Uint8Array))throw new Error(`Unsupported TypedArray subtype: ${a.constructor.name}`)});let s=new Uint8Array(t),r=0;return n.forEach(a=>{s.set(new Uint8Array(a.buffer),r),r+=a.byteLength}),s.buffer}var Sg=typeof Buffer!="undefined"&&(typeof Blob=="undefined"||typeof atob=="undefined"||typeof btoa=="undefined");function R5(e){return Sg?Buffer.byteLength(e):new Blob([e]).size}function zC(e){if(Sg)return Buffer.from(e).toString("base64");let t=new Uint8Array(e),n="";for(let s=0,r=t.length;s<r;s++)n+=String.fromCharCode(t[s]);return btoa(n)}function LC(e){if(Sg){let s=Buffer.from(e,"base64");return s.buffer.slice(s.byteOffset,s.byteOffset+s.byteLength)}let t=atob(e),n=new Uint8Array(t.length);for(let s=0;s<t.length;++s)n.set([t.charCodeAt(s)],s);return n.buffer}function Cg(e){if(e.length===1)return e[0];let t=0;e.forEach(r=>{t+=r.byteLength});let n=new Uint8Array(t),s=0;return e.forEach(r=>{n.set(new Uint8Array(r),s),s+=r.byteLength}),n.buffer}function D5(e){let t="/";for(e=e.trim();e.endsWith(t);)e=e.slice(0,e.length-1);let n=e.split(t);return n[n.length-1]}function _5(e,t){let n={modelTopology:e.modelTopology,format:e.format,generatedBy:e.generatedBy,convertedBy:e.convertedBy,weightsManifest:t};return e.signature!=null&&(n.signature=e.signature),e.userDefinedMetadata!=null&&(n.userDefinedMetadata=e.userDefinedMetadata),e.modelInitializer!=null&&(n.modelInitializer=e.modelInitializer),e.trainingConfig!=null&&(n.trainingConfig=e.trainingConfig),n}async function Tg(e,t){let n={modelTopology:e.modelTopology,format:e.format,generatedBy:e.generatedBy,convertedBy:e.convertedBy};if(e.trainingConfig!=null&&(n.trainingConfig=e.trainingConfig),e.weightsManifest!=null){let[s,r]=await t(e.weightsManifest);n.weightSpecs=s,n.weightData=r}return e.signature!=null&&(n.signature=e.signature),e.userDefinedMetadata!=null&&(n.userDefinedMetadata=e.userDefinedMetadata),e.modelInitializer!=null&&(n.modelInitializer=e.modelInitializer),n}function vc(e){if(e.modelTopology instanceof ArrayBuffer)throw new Error("Expected JSON model topology, received ArrayBuffer.");return{dateSaved:new Date,modelTopologyType:"JSON",modelTopologyBytes:e.modelTopology==null?0:R5(JSON.stringify(e.modelTopology)),weightSpecsBytes:e.weightSpecs==null?0:R5(JSON.stringify(e.weightSpecs)),weightDataBytes:e.weightData==null?0:e.weightData.byteLength}}function BC(){let e=n=>{let s=n<<13,r=0;for(;(s&8388608)==0;)r-=8388608,s<<=1;return s&=~8388608,r+=947912704,s|r},t=new Uint32Array(2048);t[0]=0;for(let n=1;n<1024;n++)t[n]=e(n);for(let n=1024;n<2048;n++)t[n]=939524096+(n-1024<<13);return t}function WC(){let 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}function VC(){let e=new Uint32Array(64);for(let t=0;t<64;t++)e[t]=1024;return e[0]=e[32]=0,e}function UC(){let e=BC(),t=WC(),n=VC();return s=>{let r=new ArrayBuffer(4*s.length),a=new Uint32Array(r);for(let o=0;o<s.length;o++){let i=s[o],l=e[n[i>>10]+(i&1023)]+t[i>>10];a[o]=l}return new Float32Array(r)}}var Pt=class{constructor(){this.saveRouters=[],this.loadRouters=[]}static getInstance(){return Pt.instance==null&&(Pt.instance=new Pt),Pt.instance}static registerSaveRouter(e){Pt.getInstance().saveRouters.push(e)}static registerLoadRouter(e){Pt.getInstance().loadRouters.push(e)}static getSaveHandlers(e){return Pt.getHandlers(e,"save")}static getLoadHandlers(e,t){return Pt.getHandlers(e,"load",t)}static getHandlers(e,t,n){let s=[];return(t==="load"?Pt.getInstance().loadRouters:Pt.getInstance().saveRouters).forEach(a=>{let o=a(e,n);o!==null&&s.push(o)}),s}},HC=e=>Pt.registerSaveRouter(e),GC=e=>Pt.registerLoadRouter(e),jC=e=>Pt.getSaveHandlers(e),qC=(e,t)=>Pt.getLoadHandlers(e,t),Ng="tensorflowjs",Eg=1,Mo="models_store",aa="model_info_store";function $5(){if(!Y().getBool("IS_BROWSER"))throw new Error("Failed to obtain IndexedDB factory because the current environmentis not a web browser.");let e=typeof window=="undefined"?self:window,t=e.indexedDB||e.mozIndexedDB||e.webkitIndexedDB||e.msIndexedDB||e.shimIndexedDB;if(t==null)throw new Error("The current browser does not appear to support IndexedDB.");return t}function Rg(e){let t=e.result;t.createObjectStore(Mo,{keyPath:"modelPath"}),t.createObjectStore(aa,{keyPath:"modelPath"})}var zo=class{constructor(e){if(this.indexedDB=$5(),e==null||!e)throw new Error("For IndexedDB, modelPath must not be null, undefined or empty.");this.modelPath=e}async save(e){if(e.modelTopology instanceof ArrayBuffer)throw new Error("BrowserLocalStorage.save() does not support saving model topology in binary formats yet.");return this.databaseAction(this.modelPath,e)}async load(){return this.databaseAction(this.modelPath)}databaseAction(e,t){return new Promise((n,s)=>{let r=this.indexedDB.open(Ng,Eg);r.onupgradeneeded=()=>Rg(r),r.onsuccess=()=>{let a=r.result;if(t==null){let o=a.transaction(Mo,"readonly"),l=o.objectStore(Mo).get(this.modelPath);l.onsuccess=()=>{if(l.result==null)return a.close(),s(new Error(`Cannot find model with path '${this.modelPath}' in IndexedDB.`));n(l.result.modelArtifacts)},l.onerror=u=>(a.close(),s(l.error)),o.oncomplete=()=>a.close()}else{let o=vc(t),i=a.transaction(aa,"readwrite"),l=i.objectStore(aa),u=l.put({modelPath:this.modelPath,modelArtifactsInfo:o}),c;u.onsuccess=()=>{c=a.transaction(Mo,"readwrite");let p=c.objectStore(Mo).put({modelPath:this.modelPath,modelArtifacts:t,modelArtifactsInfo:o});p.onsuccess=()=>n({modelArtifactsInfo:o}),p.onerror=h=>{l=i.objectStore(aa);let f=l.delete(this.modelPath);f.onsuccess=()=>(a.close(),s(p.error)),f.onerror=m=>(a.close(),s(p.error))}},u.onerror=d=>(a.close(),s(u.error)),i.oncomplete=()=>{c==null?a.close():c.oncomplete=()=>a.close()}}},r.onerror=a=>s(r.error)})}};zo.URL_SCHEME="indexeddb://";var F5=e=>Y().getBool("IS_BROWSER")&&!Array.isArray(e)&&e.startsWith(zo.URL_SCHEME)?XC(e.slice(zo.URL_SCHEME.length)):null;Pt.registerSaveRouter(F5);Pt.registerLoadRouter(F5);function XC(e){return new zo(e)}function KC(e){return e.startsWith(zo.URL_SCHEME)?e.slice(zo.URL_SCHEME.length):e}var ZC=class{constructor(){this.indexedDB=$5()}async listModels(){return new Promise((e,t)=>{let n=this.indexedDB.open(Ng,Eg);n.onupgradeneeded=()=>Rg(n),n.onsuccess=()=>{let s=n.result,r=s.transaction(aa,"readonly"),o=r.objectStore(aa).getAll();o.onsuccess=()=>{let i={};for(let l of o.result)i[l.modelPath]=l.modelArtifactsInfo;e(i)},o.onerror=i=>(s.close(),t(o.error)),r.oncomplete=()=>s.close()},n.onerror=s=>t(n.error)})}async removeModel(e){return e=KC(e),new Promise((t,n)=>{let s=this.indexedDB.open(Ng,Eg);s.onupgradeneeded=()=>Rg(s),s.onsuccess=()=>{let r=s.result,a=r.transaction(aa,"readwrite"),o=a.objectStore(aa),i=o.get(e),l;i.onsuccess=()=>{if(i.result==null)return r.close(),n(new Error(`Cannot find model with path '${e}' in IndexedDB.`));{let u=o.delete(e),c=()=>{l=r.transaction(Mo,"readwrite");let p=l.objectStore(Mo).delete(e);p.onsuccess=()=>t(i.result.modelArtifactsInfo),p.onerror=h=>n(i.error)};u.onsuccess=c,u.onerror=d=>(c(),r.close(),n(i.error))}},i.onerror=u=>(r.close(),n(i.error)),a.oncomplete=()=>{l==null?r.close():l.oncomplete=()=>r.close()}},s.onerror=r=>n(s.error)})}},Sr="/",Ml="tensorflowjs_models",O5="info",YC="model_topology",JC="weight_specs",QC="weight_data",e9="model_metadata";function P5(e){return{info:[Ml,e,O5].join(Sr),topology:[Ml,e,YC].join(Sr),weightSpecs:[Ml,e,JC].join(Sr),weightData:[Ml,e,QC].join(Sr),modelMetadata:[Ml,e,e9].join(Sr)}}function M5(e){for(let t of Object.values(e))window.localStorage.removeItem(t)}function t9(e){let t=e.split(Sr);if(t.length<3)throw new Error(`Invalid key format: ${e}`);return t.slice(1,t.length-1).join(Sr)}function n9(e){return e.startsWith(Lo.URL_SCHEME)?e.slice(Lo.URL_SCHEME.length):e}var Lo=class{constructor(e){if(!Y().getBool("IS_BROWSER")||typeof window=="undefined"||typeof window.localStorage=="undefined")throw new Error("The current environment does not support local storage.");if(this.LS=window.localStorage,e==null||!e)throw new Error("For local storage, modelPath must not be null, undefined or empty.");this.modelPath=e,this.keys=P5(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.");{let t=JSON.stringify(e.modelTopology),n=JSON.stringify(e.weightSpecs),s=vc(e);try{this.LS.setItem(this.keys.info,JSON.stringify(s)),this.LS.setItem(this.keys.topology,t),this.LS.setItem(this.keys.weightSpecs,n),this.LS.setItem(this.keys.weightData,zC(e.weightData));let r={format:e.format,generatedBy:e.generatedBy,convertedBy:e.convertedBy,signature:e.signature!=null?e.signature:void 0,userDefinedMetadata:e.userDefinedMetadata!=null?e.userDefinedMetadata:void 0,modelInitializer:e.modelInitializer!=null?e.modelInitializer:void 0,trainingConfig:e.trainingConfig!=null?e.trainingConfig:void 0};return this.LS.setItem(this.keys.modelMetadata,JSON.stringify(r)),{modelArtifactsInfo:s}}catch(r){throw M5(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=${s.modelTopologyBytes}, weightSpecsBytes=${s.weightSpecsBytes}, weightDataBytes=${s.weightDataBytes}.`)}}}async load(){let e=JSON.parse(this.LS.getItem(this.keys.info));if(e==null)throw new Error(`In local storage, there is no model with name '${this.modelPath}'`);if(e.modelTopologyType!=="JSON")throw new Error("BrowserLocalStorage does not support loading non-JSON model topology yet.");let t={},n=JSON.parse(this.LS.getItem(this.keys.topology));if(n==null)throw new Error(`In local storage, the topology of model '${this.modelPath}' is missing.`);t.modelTopology=n;let s=JSON.parse(this.LS.getItem(this.keys.weightSpecs));if(s==null)throw new Error(`In local storage, the weight specs of model '${this.modelPath}' are missing.`);t.weightSpecs=s;let r=this.LS.getItem(this.keys.modelMetadata);if(r!=null){let o=JSON.parse(r);t.format=o.format,t.generatedBy=o.generatedBy,t.convertedBy=o.convertedBy,o.signature!=null&&(t.signature=o.signature),o.userDefinedMetadata!=null&&(t.userDefinedMetadata=o.userDefinedMetadata),o.modelInitializer!=null&&(t.modelInitializer=o.modelInitializer),o.trainingConfig!=null&&(t.trainingConfig=o.trainingConfig)}let a=this.LS.getItem(this.keys.weightData);if(a==null)throw new Error(`In local storage, the binary weight values of model '${this.modelPath}' are missing.`);return t.weightData=LC(a),t}};Lo.URL_SCHEME="localstorage://";var z5=e=>Y().getBool("IS_BROWSER")&&!Array.isArray(e)&&e.startsWith(Lo.URL_SCHEME)?s9(e.slice(Lo.URL_SCHEME.length)):null;Pt.registerSaveRouter(z5);Pt.registerLoadRouter(z5);function s9(e){return new Lo(e)}var r9=class{constructor(){M(Y().getBool("IS_BROWSER"),()=>"Current environment is not a web browser"),M(typeof window=="undefined"||typeof window.localStorage!="undefined",()=>"Current browser does not appear to support localStorage"),this.LS=window.localStorage}async listModels(){let e={},t=Ml+Sr,n=Sr+O5;for(let s=0;s<this.LS.length;++s){let r=this.LS.key(s);if(r.startsWith(t)&&r.endsWith(n)){let a=t9(r);e[a]=JSON.parse(this.LS.getItem(r))}}return e}async removeModel(e){e=n9(e);let t=P5(e);if(this.LS.getItem(t.info)==null)throw new Error(`Cannot find model at path '${e}'`);let n=JSON.parse(this.LS.getItem(t.info));return M5(t),n}},zl="://",ys=class{constructor(){this.managers={}}static getInstance(){return ys.instance==null&&(ys.instance=new ys),ys.instance}static registerManager(e,t){M(e!=null,()=>"scheme must not be undefined or null."),e.endsWith(zl)&&(e=e.slice(0,e.indexOf(zl))),M(e.length>0,()=>"scheme must not be an empty string.");let n=ys.getInstance();M(n.managers[e]==null,()=>`A model store manager is already registered for scheme '${e}'.`),n.managers[e]=t}static getManager(e){let t=this.getInstance().managers[e];if(t==null)throw new Error(`Cannot find model manager for scheme '${e}'`);return t}static getSchemes(){return Object.keys(this.getInstance().managers)}};function rh(e){if(e.indexOf(zl)===-1)throw new Error(`The url string provided does not contain a scheme. Supported schemes are: ${ys.getSchemes().join(",")}`);return{scheme:e.split(zl)[0],path:e.split(zl)[1]}}async function L5(e,t,n=!1){M(e!==t,()=>`Old path and new path are the same: '${e}'`);let s=Pt.getLoadHandlers(e);M(s.length>0,()=>`Copying failed because no load handler is found for source URL ${e}.`),M(s.length<2,()=>`Copying failed because more than one (${s.length}) load handlers for source URL ${e}.`);let r=s[0],a=Pt.getSaveHandlers(t);M(a.length>0,()=>`Copying failed because no save handler is found for destination URL ${t}.`),M(a.length<2,()=>`Copying failed because more than one (${s.length}) save handlers for destination URL ${t}.`);let o=a[0],i=rh(e).scheme,l=rh(e).path,u=i===rh(e).scheme,c=await r.load();n&&u&&await ys.getManager(i).removeModel(l);let d=await o.save(c);return n&&!u&&await ys.getManager(i).removeModel(l),d.modelArtifactsInfo}async function a9(){let e=ys.getSchemes(),t={};for(let n of e){let s=await ys.getManager(n).listModels();for(let r in s){let a=n+zl+r;t[a]=s[r]}}return t}async function o9(e){let t=rh(e);return ys.getManager(t.scheme).removeModel(t.path)}async function i9(e,t){return L5(e,t,!1)}async function l9(e,t){return L5(e,t,!0)}var u9=class{fetch(e,t){return fetch(e,t)}now(){return performance.now()}encode(e,t){if(t!=="utf-8"&&t!=="utf8")throw new Error(`Browser's encoder only supports utf-8, but got ${t}`);return this.textEncoder==null&&(this.textEncoder=new TextEncoder),this.textEncoder.encode(e)}decode(e,t){return new TextDecoder(t).decode(e)}};if(Y().get("IS_BROWSER")){Y().setPlatform("browser",new u9);try{ys.registerManager(Lo.URL_SCHEME,new r9)}catch(e){}try{ys.registerManager(zo.URL_SCHEME,new ZC)}catch(e){}}var c9={importFetch:()=>AS()},Dg,d9=class{constructor(){this.util=Di("util"),this.textEncoder=new this.util.TextEncoder}fetch(e,t){return Y().global.fetch!=null?Y().global.fetch(e,t):(Dg==null&&(Dg=c9.importFetch()),Dg(e,t))}now(){let e=process.hrtime();return e[0]*1e3+e[1]/1e6}encode(e,t){if(t!=="utf-8"&&t!=="utf8")throw new Error(`Node built-in encoder only supports utf-8, but got ${t}`);return this.textEncoder.encode(e)}decode(e,t){return e.length===0?"":new this.util.TextDecoder(t).decode(e)}};Y().get("IS_NODE")&&Y().setPlatform("node",new d9);function je(e,t="float32",n){return t=t||"float32",lg(e),new Kt(e,t,n)}function p9(e,t){let n=$(e,"x","cast");if(!r5(t))throw new Error(`Failed to cast to unknown dtype ${t}`);if(t==="string"&&n.dtype!=="string"||t!=="string"&&n.dtype==="string")throw new Error("Only strings can be casted to strings");let s={x:n},r={dtype:t};return L.runKernel(za,s,r)}var pe=W({cast_:p9});function h9(e){let n={x:$(e,"x","clone","string_or_numeric")};return L.runKernel(Qa,n)}var Bs=W({clone_:h9});function B5(e,t=!1){console.log(e.toString(t))}I5();var f9={buffer:je,cast:pe,clone:Bs,print:B5};CC(f9);var Ln={};Le(Ln,{browserFiles:()=>v9,browserHTTPRequest:()=>C9,concatenateArrayBuffers:()=>Cg,copyModel:()=>i9,decodeWeights:()=>E5,encodeWeights:()=>PC,fromMemory:()=>N9,getLoadHandlers:()=>qC,getModelArtifactsForJSON:()=>Tg,getModelArtifactsInfoForJSON:()=>vc,getSaveHandlers:()=>jC,http:()=>Fg,isHTTPScheme:()=>$g,listModels:()=>a9,loadWeights:()=>w9,moveModel:()=>l9,registerLoadRouter:()=>GC,registerSaveRouter:()=>HC,removeModel:()=>o9,weightsLoaderFactory:()=>H5,withSaveHandler:()=>E9});var m9="model",g9=".json",A9=".weights.bin";function W5(e){return new Promise(t=>setTimeout(t)).then(e)}var Ll=class{constructor(e){if(!Y().getBool("IS_BROWSER"))throw new Error("browserDownloads() cannot proceed because the current environment is not a browser.");e.startsWith(Ll.URL_SCHEME)&&(e=e.slice(Ll.URL_SCHEME.length)),(e==null||e.length===0)&&(e=m9),this.modelJsonFileName=e+g9,this.weightDataFileName=e+A9}async save(e){if(typeof document=="undefined")throw new Error("Browser downloads are not supported in this environment since `document` is not present");let 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.");{let n=[{paths:["./"+this.weightDataFileName],weights:e.weightSpecs}],s=_5(e,n),r=window.URL.createObjectURL(new Blob([JSON.stringify(s)],{type:"application/json"})),a=this.modelJsonAnchor==null?document.createElement("a"):this.modelJsonAnchor;if(a.download=this.modelJsonFileName,a.href=r,await W5(()=>a.dispatchEvent(new MouseEvent("click"))),e.weightData!=null){let o=this.weightDataAnchor==null?document.createElement("a"):this.weightDataAnchor;o.download=this.weightDataFileName,o.href=t,await W5(()=>o.dispatchEvent(new MouseEvent("click")))}return{modelArtifactsInfo:vc(e)}}}};Ll.URL_SCHEME="downloads://";var y9=class{constructor(e){if(e==null||e.length<1)throw new Error(`When calling browserFiles, at least 1 file is required, but received ${e}`);this.jsonFile=e[0],this.weightsFiles=e.slice(1)}async load(){return new Promise((e,t)=>{let n=new FileReader;n.onload=s=>{let r=JSON.parse(s.target.result),a=r.modelTopology;if(a==null){t(new Error(`modelTopology field is missing from file ${this.jsonFile.name}`));return}if(r.weightsManifest==null){t(new Error(`weightManifest field is missing from file ${this.jsonFile.name}`));return}if(this.weightsFiles.length===0){e({modelTopology:a});return}let i=Tg(r,l=>this.loadWeights(l));e(i)},n.onerror=s=>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){let t=[],n=[];for(let a of e)t.push(...a.weights),n.push(...a.paths);let s=this.checkManifestAndWeightFiles(e),r=n.map(a=>this.loadWeightsFile(a,s[a]));return Promise.all(r).then(a=>[t,Cg(a)])}loadWeightsFile(e,t){return new Promise((n,s)=>{let r=new FileReader;r.onload=a=>{let o=a.target.result;n(o)},r.onerror=a=>s(`Failed to weights data from file of path '${e}'.`),r.readAsArrayBuffer(t)})}checkManifestAndWeightFiles(e){let t=[],n=this.weightsFiles.map(r=>D5(r.name)),s={};for(let r of e)r.paths.forEach(a=>{let o=D5(a);if(t.indexOf(o)!==-1)throw new Error(`Duplicate file basename found in weights manifest: '${o}'`);if(t.push(o),n.indexOf(o)===-1)throw new Error(`Weight file with basename '${o}' is not provided.`);s[a]=this.weightsFiles[n.indexOf(o)]});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 s}},x9=e=>Y().getBool("IS_BROWSER")&&!Array.isArray(e)&&e.startsWith(Ll.URL_SCHEME)?b9(e.slice(Ll.URL_SCHEME.length)):null;Pt.registerSaveRouter(x9);function b9(e="model"){return new Ll(e)}function v9(e){return new y9(e)}function V5(e,t,n,s){o(e),n=n==null?0:n,s=s==null?1:s,i(n,s);let r=0,a=l=>(l.then(u=>{let c=n+ ++r/e.length*(s-n);return t(c),u}),l);function o(l){M(l!=null&&Array.isArray(l)&&l.length>0,()=>"promises must be a none empty array")}function i(l,u){M(l>=0&&l<=1,()=>`Progress fraction must be in range [0, 1], but got startFraction ${l}`),M(u>=0&&u<=1,()=>`Progress fraction must be in range [0, 1], but got endFraction ${u}`),M(u>=l,()=>`startFraction must be no more than endFraction, but got startFraction ${l} and endFraction ${u}`)}return Promise.all(e.map(a))}async function U5(e,t){t==null&&(t={});let n=t.fetchFunc==null?Y().platform.fetch:t.fetchFunc,s=e.map(d=>n(d,t.requestInit,{isBinary:!0})),r=0,a=.5,i=(t.onProgress==null?await Promise.all(s):await V5(s,t.onProgress,r,a)).map(d=>d.arrayBuffer()),l=.5,u=1;return t.onProgress==null?await Promise.all(i):await V5(i,t.onProgress,l,u)}async function w9(e,t="",n,s){return H5(o=>U5(o,{requestInit:s}))(e,t,n)}function H5(e){return async(t,n="",s)=>{let r=t.map(()=>!1),a={},o=s!=null?s.map(()=>!1):[],i=[];if(t.forEach((h,f)=>{let m=0;h.weights.forEach(g=>{let A="quantization"in g?g.quantization.dtype:g.dtype,y=Ig[A]*zt(g.shape),x=()=>{r[f]=!0,a[f]==null&&(a[f]=[]),a[f].push({manifestEntry:g,groupOffset:m,sizeBytes:y})};s!=null?s.forEach((b,v)=>{b===g.name&&(x(),o[v]=!0)}):x(),i.push(g.name),m+=y})}),!o.every(h=>h)){let h=s.filter((f,m)=>!o[m]);throw new Error(`Could not find weights in manifest with names: ${h.join(", ")}.
|
|
Manifest JSON has weights with names: ${i.join(", ")}.`)}let l=r.reduce((h,f,m)=>(f&&h.push(m),h),[]),u=[];l.forEach(h=>{t[h].paths.forEach(f=>{let m=n+(n.endsWith("/")?"":"/")+f;u.push(m)})});let c=await e(u),d={},p=0;return l.forEach(h=>{let f=t[h].paths.length,m=0;for(let b=0;b<f;b++)m+=c[p+b].byteLength;let g=new ArrayBuffer(m),A=new Uint8Array(g),y=0;for(let b=0;b<f;b++){let v=new Uint8Array(c[p+b]);A.set(v,y),y+=v.byteLength}a[h].forEach(b=>{let v=g.slice(b.groupOffset,b.groupOffset+b.sizeBytes),k=E5(v,[b.manifestEntry]);for(let S in k)d[S]=k[S]}),p+=f}),d}}var k9="application/octet-stream",I9="application/json",_g=class{constructor(e,t){if(this.DEFAULT_METHOD="POST",t==null&&(t={}),this.weightPathPrefix=t.weightPathPrefix,this.onProgress=t.onProgress,this.weightUrlConverter=t.weightUrlConverter,t.fetchFunc!=null?(M(typeof t.fetchFunc=="function",()=>"Must pass a function that matches the signature of `fetch` (see https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API)"),this.fetch=t.fetchFunc):this.fetch=Y().platform.fetch,M(e!=null&&e.length>0,()=>"URL path for http must not be null, undefined or empty."),Array.isArray(e)&&M(e.length===2,()=>`URL paths for http must have a length of 2, (actual length is ${e.length}).`),this.path=e,t.requestInit!=null&&t.requestInit.body!=null)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.");let t=Object.assign({method:this.DEFAULT_METHOD},this.requestInit);t.body=new FormData;let n=[{paths:["./model.weights.bin"],weights:e.weightSpecs}],s=_5(e,n);t.body.append("model.json",new Blob([JSON.stringify(s)],{type:I9}),"model.json"),e.weightData!=null&&t.body.append("model.weights.bin",new Blob([e.weightData],{type:k9}),"model.weights.bin");let r=await this.fetch(this.path,t);if(r.ok)return{modelArtifactsInfo:vc(e),responses:[r]};throw new Error(`BrowserHTTPRequest.save() failed due to HTTP response status ${r.status}.`)}async load(){let 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(r){let a=`Failed to parse model JSON of response from ${this.path}.`;throw this.path.endsWith(".pb")?a+=" 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.":a+=" Please make sure the server is serving valid JSON for this request.",new Error(a)}let n=t.modelTopology,s=t.weightsManifest;if(n==null&&s==null)throw new Error(`The JSON from HTTP path ${this.path} contains neither model topology or manifest for weights.`);return Tg(t,r=>this.loadWeights(r))}async loadWeights(e){let t=Array.isArray(this.path)?this.path[1]:this.path,[n,s]=S9(t),r=this.weightPathPrefix||n,a=[];for(let u of e)a.push(...u.weights);let o=[],i=[];for(let u of e)for(let c of u.paths)this.weightUrlConverter!=null?i.push(this.weightUrlConverter(c)):o.push(r+c+s);this.weightUrlConverter&&o.push(...await Promise.all(i));let l=await U5(o,{requestInit:this.requestInit,fetchFunc:this.fetch,onProgress:this.onProgress});return[a,Cg(l)]}};_g.URL_SCHEME_REGEX=/^https?:\/\//;function S9(e){let t=e.lastIndexOf("/"),n=e.lastIndexOf("?"),s=e.substring(0,t),r=n>t?e.substring(n):"";return[s+"/",r]}function $g(e){return e.match(_g.URL_SCHEME_REGEX)!=null}var G5=(e,t)=>{if(typeof fetch=="undefined"&&(t==null||t.fetchFunc==null))return null;{let n=!0;if(Array.isArray(e)?n=e.every(s=>$g(s)):n=$g(e),n)return Fg(e,t)}return null};Pt.registerSaveRouter(G5);Pt.registerLoadRouter(G5);function Fg(e,t){return new _g(e,t)}function C9(e,t){return Fg(e,t)}var Og=class{constructor(e){this.modelArtifacts=e}async load(){return this.modelArtifacts}},T9=class{constructor(e){this.saveHandler=e}async save(e){return this.saveHandler(e)}};function N9(e,t,n,s){return arguments.length===1?e.modelTopology!=null||e.weightSpecs!=null?new Og(e):(console.warn("Please call tf.io.fromMemory() with only one argument. The argument should be of type ModelArtifacts. The multi-argument signature of tf.io.fromMemory() has been deprecated and will be removed in a future release."),new Og({modelTopology:e})):(console.warn("Please call tf.io.fromMemory() with only one argument. The argument should be of type ModelArtifacts. The multi-argument signature of tf.io.fromMemory() has been deprecated and will be removed in a future release."),new Og({modelTopology:e,weightSpecs:t,weightData:n,trainingConfig:s}))}function E9(e){return new T9(e)}var j5={};Le(j5,{confusionMatrix:()=>F9});function R9(e,t,n=!1,s=!1){let r=$(e,"a","matMul"),a=$(t,"b","matMul");[r,a]=Rt(r,a);let o={a:r,b:a},i={transposeA:n,transposeB:s};return L.runKernel(Ma,o,i)}var Ue=W({matMul_:R9});function D9(e,t,n=1,s=0){if(t<2)throw new Error(`Error in oneHot: depth must be >=2, but it is ${t}`);let a={indices:$(e,"indices","oneHot","int32")},o={depth:t,onValue:n,offValue:s};return L.runKernel(co,a,o)}var Bl=W({oneHot_:D9});function _9(e,t){let n=$(e,"x","transpose");if(t==null&&(t=n.shape.map((a,o)=>o).reverse()),M(n.rank===t.length,()=>`Error in transpose: rank of input ${n.rank} must match length of perm ${t}.`),t.forEach(a=>{M(a>=0&&a<n.rank,()=>`All entries in 'perm' must be between 0 and ${n.rank-1} but got ${t}`)}),n.rank<=1)return n.clone();let s={x:n},r={perm:t};return L.runKernel(Ro,s,r)}var Ye=W({transpose_:_9});function $9(e,t,n){let s=$(e,"labels","confusionMatrix"),r=$(t,"predictions","confusionMatrix");M(n==null||n>0&&Number.isInteger(n),()=>`If provided, numClasses must be a positive integer, but got ${n}`),M(s.rank===1,()=>`Expected the rank of labels to be 1, but got ${s.rank}`),M(r.rank===1,()=>`Expected the rank of predictions to be 1, but got ${r.rank}`),M(s.shape[0]===r.shape[0],()=>`Mismatch in the number of examples: ${s.shape[0]} vs. ${r.shape[0]}. Labels and predictions should have the same number of elements.`),M(n>0&&Number.isInteger(n),()=>`numClasses is required to be a positive integer, but got ${n}`);let a=Bl(pe(s,"int32"),n),o=Bl(pe(r,"int32"),n),i=Ye(a),l=Ue(i,o);return pe(l,"int32")}var F9=W({confusionMatrix_:$9}),xs={};Le(xs,{fromPixels:()=>W9,fromPixelsAsync:()=>L9,toPixels:()=>B9});function ah(e,t,n){if(_a(e),t!=null&&t.length!==3)throw new Error("tensor3d() requires shape to have three numbers");let s=rr(e,n);if(s.length!==3&&s.length!==1)throw new Error("tensor3d() requires values to be number[][][] or flat/TypedArray");if(s.length===1&&t==null)throw new Error("tensor3d() requires shape to be provided when `values` are a flat array");return ra(e,t,s,n)}var Wl;function q5(e,t=3){if(t>4)throw new Error("Cannot construct Tensor with more than 4 channels from pixels.");if(e==null)throw new Error("pixels passed to tf.browser.fromPixels() can not be null");let n=!1,s=!1,r=!1,a=!1,o=!1,i=!1;if(e.data instanceof Uint8Array)n=!0;else if(typeof ImageData!="undefined"&&e instanceof ImageData)s=!0;else if(typeof HTMLVideoElement!="undefined"&&e instanceof HTMLVideoElement)r=!0;else if(typeof HTMLImageElement!="undefined"&&e instanceof HTMLImageElement)a=!0;else if(e.getContext!=null)o=!0;else if(typeof ImageBitmap!="undefined"&&e instanceof ImageBitmap)i=!0;else 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}`);if(r){let f=2;if(r&&e.readyState<f)throw new Error("The video element has not loaded data yet. Please wait for `loadeddata` event on the <video> element.")}if(Yp(Zp,L.backendName)!=null){let f={pixels:e},m={numChannels:t};return L.runKernel(Zp,f,m)}let[u,c]=r?[e.videoWidth,e.videoHeight]:[e.width,e.height],d;o?d=e.getContext("2d").getImageData(0,0,u,c).data:s||n?d=e.data:(a||r||i)&&(Wl==null&&(Wl=document.createElement("canvas").getContext("2d")),Wl.canvas.width=u,Wl.canvas.height=c,Wl.drawImage(e,0,0,u,c),d=Wl.getImageData(0,0,u,c).data);let p;if(t===4)p=new Int32Array(d);else{let f=u*c;p=new Int32Array(f*t);for(let m=0;m<f;m++)for(let g=0;g<t;++g)p[m*t+g]=d[m*4+g]}return ah(p,[c,u,t],"int32")}function O9(e){return e!=null&&e.data instanceof Uint8Array}function P9(){return typeof window!="undefined"&&typeof ImageBitmap!="undefined"&&window.hasOwnProperty("createImageBitmap")}function M9(e){return e!=null&&e.width!==0&&e.height!==0}function z9(e){return P9()&&!(e instanceof ImageBitmap)&&M9(e)&&!O9(e)}async function L9(e,t=3){let n=null;if(Y().getBool("WRAP_TO_IMAGEBITMAP")&&z9(e)){let s;try{s=await createImageBitmap(e,{premultiplyAlpha:"none"})}catch(r){s=null}s!=null&&s.width===e.width&&s.height===e.height?n=s:n=e}else n=e;return q5(n,t)}async function B9(e,t){let n=$(e,"img","toPixels");if(!(e instanceof Ge)){let u=n;n=pe(u,"int32"),u.dispose()}if(n.rank!==2&&n.rank!==3)throw new Error(`toPixels only supports rank 2 or 3 tensors, got rank ${n.rank}.`);let[s,r]=n.shape.slice(0,2),a=n.rank===2?1:n.shape[2];if(a>4||a===2)throw new Error(`toPixels only supports depth of size 1, 3 or 4 but got ${a}`);if(n.dtype!=="float32"&&n.dtype!=="int32")throw new Error(`Unsupported type for toPixels: ${n.dtype}. Please use float32 or int32 tensors.`);let o=await n.data(),i=n.dtype==="float32"?255:1,l=new Uint8ClampedArray(r*s*4);for(let u=0;u<s*r;++u){let c=[0,0,0,255];for(let p=0;p<a;p++){let h=o[u*a+p];if(n.dtype==="float32"){if(h<0||h>1)throw new Error(`Tensor values for a float32 Tensor must be in the range [0 - 1] but encountered ${h}.`)}else if(n.dtype==="int32"&&(h<0||h>255))throw new Error(`Tensor values for a int32 Tensor must be in the range [0 - 255] but encountered ${h}.`);a===1?(c[0]=h*i,c[1]=h*i,c[2]=h*i):c[p]=h*i}let d=u*4;l[d+0]=Math.round(c[0]),l[d+1]=Math.round(c[1]),l[d+2]=Math.round(c[2]),l[d+3]=Math.round(c[3])}if(t!=null){t.width=r,t.height=s;let u=t.getContext("2d"),c=new ImageData(l,r,s);u.putImageData(c,0,0)}return n!==e&&n.dispose(),l}var W9=W({fromPixels_:q5}),Pg={};Le(Pg,{prepareAndValidate:()=>X5});function X5(e,t){let n=e.shape.length,s=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(s<1)throw new Error(`tf.gatherND() expects the indices to be rank 1 or higher, but the rank was ${s}.`);if(t.dtype!=="int32")throw new Error(`tf.gatherND() expects the indices to be int32 type, but the dtype was ${t.dtype}.`);if(t.shape[s-1]>n)throw new Error(`index innermost dimension length must be <= tensor rank; saw: ${t.shape[s-1]} vs. ${n}`);if(zt(e.shape)===0)throw new Error(`Requested more than 0 entries, but input is empty. Input shape: ${e.shape}.`);let r=t.shape,a=r[r.length-1],o=1;for(let d=0;d<r.length-1;++d)o*=r[d];let i=e.shape,l=r.slice();l.pop();let u=1;for(let d=a;d<n;++d)u*=i[d],l.push(i[d]);let c=[..._i(e.shape).map(d=>d/u),1].slice(0,a);return[l,o,u,c]}var Mg={};Le(Mg,{calculateShapes:()=>K5,validateInput:()=>Lg,validateUpdateShape:()=>zg});function zg(e,t,n){let s=t.rank>1?t.shape[t.rank-1]:1,r=t.rank>1?t.rank-1:1,a=`Must have updates.shape = indices.shape[:batchDim] + shape[sliceDim:], got updates.shape: ${n.shape}, indices.shape: ${t.shape}, shape: ${e}, sliceDim: ${s}, and batchDim: ${r}.`;if(n.rank<r)throw new Error(a+` update.rank < ${r}. `);if(e.length<s+(n.rank-r))throw new Error(a+` Output shape length < ${s+(n.rank-r)}`);if(n.rank!==r+e.length-s)throw new Error(a+` update.rank != ${r+e.length-s}`);for(let o=0;o<r;++o)if(n.shape[o]!==t.shape[o])throw new Error(a+` updates.shape[${o}] (${n.shape[o]}) != indices.shape[${o}] (${t.shape[o]}).`);for(let o=0;o<n.rank-r;++o)if(n.shape[o+r]!==e[o+s])throw new Error(a+` updates.shape[${o+r}] (${n.shape[o+r]}) != shape[${o+r}] (${e[o+r]})`)}function Lg(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(t.dtype!=="int32")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(n.length===0){if(t.size===0)throw new Error(`Indices specified for empty output. indices shape: ${t.shape}`);if(e.size===0)throw new Error(`Updates specified for empty output. updates shape: ${e.shape}`)}zg(n,t,e)}function K5(e,t,n){let s=t.shape.length,r=s>1?t.shape[s-1]:1,a=n.length,o=1;for(let d=r;d<a;++d)o*=n[d];let i=r<1?1:r,l=zt(t.shape)/i,u=[..._i(n.slice(0,r)),1],c=zt(n);return{sliceRank:r,numUpdates:l,sliceSize:o,strides:u,outputSize:c}}var Cn={};Le(Cn,{assertParamsValid:()=>V9,computeFlatOffset:()=>H9,computeOutShape:()=>Z5,getNormalizedAxes:()=>eb,isSliceContinous:()=>U9,maskToAxes:()=>oh,parseSliceParams:()=>ob,sliceInfo:()=>G9,startForAxis:()=>rb,startIndicesWithElidedDims:()=>tb,stopForAxis:()=>ab,stopIndicesWithElidedDims:()=>nb,stridesForAxis:()=>sb,stridesWithElidedDims:()=>Y5});function V9(e,t,n){let s=e.shape.length;M(s===t.length,()=>`Error in slice${s}D: Length of begin ${t} must match the rank of the array (${s}).`),M(s===n.length,()=>`Error in slice${s}D: Length of size ${n} must match the rank of the array (${s}).`);for(let r=0;r<s;++r)M(t[r]+n[r]<=e.shape[r],()=>`Error in slice${s}D: begin[${r}] + size[${r}] (${t[r]+n[r]}) would overflow input.shape[${r}] (${e.shape[r]})`)}function oh(e){let t=[],n=0;for(;e>0;)e&1&&t.push(n),e/=2,n++;return t}function Z5(e,t,n){let s=[];for(let r=0;r<e.length;r++)s[r]=Math.ceil((t[r]-e[r])/n[r]);return s}function Y5(e,t,n,s){let r=[...e];for(let a=r.length;a<s.length;a++)r.push(1);for(let a=0;a<n;a++)a===0?r[t]=1:(r.splice(t,0,1),r.pop());return r}function J5(e,t,n){return n<=e?n:n-(t-1)}function Q5(e,t){let n=[];for(let s=0;s<e;s++)n.push(t+s);return n}function eb(e,t,n,s,r,a,o,i,l){let u=e.length,c=new Array(u),d=new Array(u),p=new Array(u);if(t.length&&n>0){let h=t[0],f=n+1;c=tb(o,h,f,s,e),d=nb(i,h,f,r,e),p=Y5(a,h,f,e)}else for(let h=0;h<u;h++)c[h]=rb(o,s,a,e,h,l),d[h]=ab(i,r,a,e,h,l),p[h]=sb(a,h,l);return{begin:c,end:d,strides:p}}function tb(e,t,n,s,r){let a=[...r],o=Q5(n,t);for(let i=0;i<a.length;i++)if(o.indexOf(i)>-1)a[i]=0;else{let l=J5(t,n,i),u=s[l];e&1<<l&&(u=0),a[i]=u}return a}function nb(e,t,n,s,r){let a=[...r],o=Q5(n,t);for(let i=0;i<a.length;i++)if(o.indexOf(i)>-1)a[i]=Number.MAX_SAFE_INTEGER;else{let l=J5(t,n,i),u=s[l];e&1<<l&&(u=Number.MAX_SAFE_INTEGER),a[i]=u}for(let i=0;i<a.length;i++){let l=r[i];a[i]<0&&(a[i]+=l),a[i]=Xu(0,a[i],r[i])}return a}function sb(e,t,n){let s=e[t];return(n&1<<t||s==null)&&(s=1),s}function rb(e,t,n,s,r,a){let o=t[r],i=n[r]||1;(e&1<<r||a&1<<r||o==null)&&(i>0?o=Number.MIN_SAFE_INTEGER:o=Number.MAX_SAFE_INTEGER);let l=s[r];return o<0&&(o+=l),o=Xu(0,o,l-1),o}function ab(e,t,n,s,r,a){let o=t[r],i=n[r]||1;(e&1<<r||a&1<<r||o==null)&&(i>0?o=Number.MAX_SAFE_INTEGER:o=Number.MIN_SAFE_INTEGER);let l=s[r];return o<0&&(o+=l),i>0?o=Xu(0,o,l):o=Xu(-1,o,l-1),o}function U9(e,t,n){let s=n.length;for(let r=0;r<n.length;r++)if(n[r]>1){s=r;break}for(let r=s+1;r<n.length;r++)if(t[r]>0||n[r]!==e[r])return!1;return!0}function H9(e,t){let n=e.length>0?e[e.length-1]:1;for(let s=0;s<e.length-1;s++)n+=e[s]*t[s];return n}function ob(e,t,n){let s,r=e.shape.length;typeof t=="number"?s=[t,...new Array(r-1).fill(0)]:t.length<r?s=t.concat(new Array(r-t.length).fill(0)):s=t.slice(),s.forEach(o=>{M(o!==-1,()=>"slice() does not support negative begin indexing.")});let a;return n==null?a=new Array(r).fill(-1):typeof n=="number"?a=[n,...new Array(r-1).fill(-1)]:n.length<r?a=n.concat(new Array(r-n.length).fill(-1)):a=n,a=a.map((o,i)=>o>=0?o:(M(o===-1,()=>`Negative size values should be exactly -1 but got ${o} for the slice() size at index ${i}.`),e.shape[i]-s[i])),[s,a]}function G9(e,t,n,s,r,a,o,i,l){let u=t.slice(),c=n.slice(),d=s;s==null&&(d=new Array(u.length));let p=oh(o);if(p.length>1)throw new Error("Multiple ellipses in slice is not allowed.");if(o!==0&&i!==0)throw new Error("Using both ellipsisMask and newAxisMask is not yet supported.");if(o!==0&&l!==0)throw new Error("Using both ellipsisMask and shrinkAxisMask is not yet supported.");let h=e.length-u.length,f=oh(i),m=e.slice();f.forEach(S=>{u[S]=0,c[S]=1,m.splice(S,0,1)});let{begin:g,end:A,strides:y}=eb(m,p,h,u,c,d,r,a,o);u=g,c=A,d=y;let x=oh(l);x.forEach(S=>{c[S]=u[S]+1,d[S]=1});let b=Z5(u,c,d),v=b.filter((S,C)=>x.indexOf(C)===-1);return{nonStrided:d.every(S=>S===1),$begin:u,$end:c,$strides:d,size:b,newShape:m,outShape:v}}var le={};Le(le,{Serializable:()=>ib,SerializationMap:()=>Bo,registerClass:()=>oa});var ib=class{getClassName(){return this.constructor.className}static fromConfig(e,t){return new e(t)}},Bo=class{constructor(){this.classNameMap={}}static getMap(){return Bo.instance==null&&(Bo.instance=new Bo),Bo.instance}static register(e){Bo.getMap().classNameMap[e.className]=[e,e.fromConfig]}};function oa(e){M(e.className!=null,()=>"Class being registered does not have the static className property defined."),M(typeof e.className=="string",()=>"className is required to be a string, but got type "+typeof e.className),M(e.className.length>0,()=>"Class being registered has an empty-string as its className, which is disallowed."),Bo.register(e)}var lb={};Le(lb,{TEST_EPSILON_FLOAT16:()=>ub,encodeStrings:()=>cb,expectArrayBuffersEqual:()=>J9,expectArraysClose:()=>q9,expectArraysEqual:()=>K9,expectNumbersClose:()=>Z9,expectPromiseToFail:()=>X9,expectValuesInRange:()=>Y9,testEpsilon:()=>Bg});var j9=.001,ub=.1;function q9(e,t,n){return n==null&&(n=Bg()),Wg(e,t,(s,r)=>Vg(s,r,n))}function Bg(){return L.backend.floatPrecision()===32?j9:ub}function Wg(e,t,n){let s=!0;if((bn(e)||bn(t))&&(s=!1),bn(e)&&bn(t)&&(s=!0),s){let o=e.constructor.name,i=t.constructor.name;if(o!==i)throw new Error(`Arrays are of different type. Actual: ${o}. Expected: ${i}`)}if(Array.isArray(e)&&Array.isArray(t)){let o=rr(e),i=rr(t);if(!Ir(o,i))throw new Error(`Arrays have different shapes. Actual: [${o}]. Expected: [${i}]`)}let r=bn(e)?e:$a(e),a=bn(t)?t:$a(t);if(r.length!==a.length)throw new Error(`Arrays have different lengths actual: ${r.length} vs expected: ${a.length}.
|
|
Actual: ${r}.
|
|
Expected: ${a}.`);for(let o=0;o<a.length;++o){let i=r[o],l=a[o];if(!n(i,l))throw new Error(`Arrays differ: actual[${o}] = ${i}, expected[${o}] = ${l}.
|
|
Actual: ${r}.
|
|
Expected: ${a}.`)}}function X9(e,t){e().then(()=>t.fail(),()=>t())}function K9(e,t){let n=typeof t=="string"||typeof t=="number"||typeof t=="boolean"?[t]:t;return Kr(e)||Kr(e[0])||Kr(t)||Kr(t[0])?Wg(e,n,(s,r)=>s==r):Wg(e,t,(s,r)=>Vg(s,r,0))}function Z9(e,t,n){if(n==null&&(n=Bg()),!Vg(e,t,n))throw new Error(`Numbers differ: actual === ${e}, expected === ${t}`)}function Vg(e,t,n){return!isFinite(e)&&!isFinite(t)?!0:!(isNaN(e)||isNaN(t)||Math.abs(e-t)>n)}function Y9(e,t,n){for(let s=0;s<e.length;s++)if(e[s]<t||e[s]>n)throw new Error(`Value out of range:${e[s]} low: ${t}, high: ${n}`)}function J9(e,t){expect(new Float32Array(e)).toEqual(new Float32Array(t))}function cb(e){for(let t=0;t<e.length;t++){let n=e[t];Array.isArray(n)?cb(n):e[t]=hc(n)}return e}var ih="3.9.0";function db(){Y().set("PROD",!0)}function Q9(){Y().set("DEBUG",!0)}function eT(){Y().set("DEPRECATION_WARNINGS_ENABLED",!1),console.warn("TensorFlow.js deprecation warnings have been disabled.")}function Ug(e){Y().getBool("DEPRECATION_WARNINGS_ENABLED")&&console.warn(e+" You can disable deprecation warnings with tf.disableDeprecationWarnings().")}TC(Ug);function tT(){L.disposeVariables()}function Qn(){return L}function lh(){return L.memory()}function nT(e){return L.profile(e)}function H(e,t){return L.tidy(e,t)}function Z(e){wg(e).forEach(n=>n.dispose())}function on(e){return L.keep(e)}function sT(e){return L.time(e)}function pb(e){return L.setBackend(e)}function uh(){return L.ready()}function Cr(){return L.backendName}function rT(e){L.removeBackend(e)}function Hg(e){return L.findBackend(e)}function aT(e){return L.findBackendFactory(e)}function Vl(e,t,n=1){return L.registerBackend(e,t,n)}function ia(){return L.backend}function oT(e,t){Y().setPlatform(e,t)}function iT(e,t){let n=$(e,"a","add"),s=$(t,"b","add");[n,s]=Rt(n,s);let r={a:n,b:s};return L.runKernel(Yr,r)}var oe=W({add_:iT});function lT(e,t){let n=$(e,"a","floorDiv"),s=$(t,"b","floorDiv");[n,s]=Rt(n,s);let r={a:n,b:s};return L.runKernel(Za,r)}var ch=W({floorDiv_:lT});function uT(e,t){let n=$(e,"a","div"),s=$(t,"b","div");if([n,s]=Rt(n,s),n.dtype==="int32"&&s.dtype==="int32")return ch(n,s);let r={a:n,b:s},a={};return L.runKernel(ja,r,a)}var he=W({div_:uT});function cT(e,t){let n=$(e,"a","mul"),s=$(t,"b","mul");[n,s]=Rt(n,s);let r={a:n,b:s};return L.runKernel(uo,r)}var z=W({mul_:cT});function dT(e){let t=$(e,"x","abs");if(t.dtype==="complex64"){let n={x:t};return L.runKernel(Ju,n)}else{let n={x:t};return L.runKernel(Fi,n)}}var Wt=W({abs_:dT});function pT(e){let n={x:$(e,"x","acos")};return L.runKernel(Oi,n)}var Gg=W({acos_:pT});function hT(e){let n={x:$(e,"x","acosh")};return L.runKernel(Pi,n)}var jg=W({acosh_:hT});function fT(e){M(Array.isArray(e),()=>"The argument passed to tf.addN() must be a list of tensors"),M(e.length>=1,()=>`Must pass at least one tensor to tf.addN(), but got ${e.length}`);let t=e.map((r,a)=>$(r,`tensors${a}`,"addN")),n=t[0];t.forEach(r=>{if(r.dtype!==n.dtype)throw new Error("All tensors passed to tf.addN() must have the same dtype")}),t.forEach(r=>{if(!Ir(r.shape,n.shape))throw new Error("All tensors passed to tf.addN() must have the same shape")});let s=t;return L.runKernel(Fa,s)}var dh=W({addN_:fT});function mT(e,t=null,n=!1){let r={x:$(e,"x","all","bool")},a={axis:t,keepDims:n};return L.runKernel(Mi,r,a)}var ph=W({all_:mT});function gT(e,t=null,n=!1){let r={x:$(e,"x","any","bool")},a={axis:t,keepDims:n};return L.runKernel(zi,r,a)}var wc=W({any_:gT});function AT(e,t=0){let s={x:$(e,"x","argMax")},r={axis:t};return L.runKernel(Oa,s,r)}var Ws=W({argMax_:AT});function yT(e,t=0){let s={x:$(e,"x","argMin")},r={axis:t};return L.runKernel(Zu,s,r)}var qg=W({argMin_:yT});function xT(e){let n={x:$(e,"x","asin")};return L.runKernel(Li,n)}var Xg=W({asin_:xT});function bT(e){let n={x:$(e,"x","asinh")};return L.runKernel(Bi,n)}var Kg=W({asinh_:bT});function vT(e){let n={x:$(e,"x","atan")};return L.runKernel(Wi,n)}var Zg=W({atan_:vT});function wT(e,t){let n=$(e,"a","atan2"),s=$(t,"b","atan2");[n,s]=Rt(n,s);let r={a:n,b:s};return L.runKernel(Ui,r)}var Yg=W({atan2_:wT});function kT(e){let n={x:$(e,"x","atanh")};return L.runKernel(Vi,n)}var Jg=W({atanh_:kT});function IT(e,t,n,s,r="NHWC",a){let o=e[3],i=[...t,o],l=mb(r);return kc(e,i,n,a,s,null,null,l)}function hb(e,t,n,s,r,a,o="channelsLast"){let[i,l]=hh(t),u;if(o==="channelsLast")u=[i,l,e[3],e[3]];else if(o==="channelsFirst")u=[i,l,e[1],e[1]];else throw new Error(`Unknown dataFormat ${o}`);return kc(e,u,n,s,r,a,!1,o)}function ST(e,t,n,s,r,a,o="NDHWC"){let[i,l,u]=eA(t),c,d;if(o==="NDHWC")d="channelsLast",c=[i,l,u,e[4],e[4]];else if(o==="NCDHW")d="channelsFirst",c=[i,l,u,e[1],e[1]];else throw new Error(`Unknown dataFormat ${o}`);return fb(e,c,n,s,r,!1,d,a)}function kc(e,t,n,s,r,a,o=!1,i="channelsLast"){let[l,u,c,d]=[-1,-1,-1,-1];if(i==="channelsLast")[l,u,c,d]=e;else if(i==="channelsFirst")[l,d,u,c]=e;else throw new Error(`Unknown dataFormat ${i}`);let[p,h,,f]=t,[m,g]=hh(n),[A,y]=hh(s),x=Ul(p,A),b=Ul(h,y),{padInfo:v,outHeight:k,outWidth:S}=NT(r,u,c,m,g,x,b,a,i),C=o?f*d:f,D;return i==="channelsFirst"?D=[l,C,k,S]:i==="channelsLast"&&(D=[l,k,S,C]),{batchSize:l,dataFormat:i,inHeight:u,inWidth:c,inChannels:d,outHeight:k,outWidth:S,outChannels:C,padInfo:v,strideHeight:m,strideWidth:g,filterHeight:p,filterWidth:h,effectiveFilterHeight:x,effectiveFilterWidth:b,dilationHeight:A,dilationWidth:y,inShape:e,outShape:D,filterShape:t}}function fb(e,t,n,s,r,a=!1,o="channelsLast",i){let[l,u,c,d,p]=[-1,-1,-1,-1,-1];if(o==="channelsLast")[l,u,c,d,p]=e;else if(o==="channelsFirst")[l,p,u,c,d]=e;else throw new Error(`Unknown dataFormat ${o}`);let[h,f,m,,g]=t,[A,y,x]=eA(n),[b,v,k]=eA(s),S=Ul(h,b),C=Ul(f,v),D=Ul(m,k),{padInfo:O,outDepth:E,outHeight:R,outWidth:T}=ET(r,u,c,d,A,y,x,S,C,D,i),P=a?g*p:g,U;return o==="channelsFirst"?U=[l,P,E,R,T]:o==="channelsLast"&&(U=[l,E,R,T,P]),{batchSize:l,dataFormat:o,inDepth:u,inHeight:c,inWidth:d,inChannels:p,outDepth:E,outHeight:R,outWidth:T,outChannels:P,padInfo:O,strideDepth:A,strideHeight:y,strideWidth:x,filterDepth:h,filterHeight:f,filterWidth:m,effectiveFilterDepth:S,effectiveFilterHeight:C,effectiveFilterWidth:D,dilationDepth:b,dilationHeight:v,dilationWidth:k,inShape:e,outShape:U,filterShape:t}}function CT(e,t,n,s,r){s==null&&(s=Qg(e,t,n));let a=e[0],o=e[1],i=Wo((a-t+2*s)/n+1,r),l=Wo((o-t+2*s)/n+1,r);return[i,l]}function TT(e,t,n,s,r,a){r==null&&(r=Qg(e,t,s));let o=e[0],i=e[1],l=e[2],u=Wo((o-t+2*r)/s+1,a),c=Wo((i-t+2*r)/s+1,a),d=Wo((l-t+2*r)/s+1,a);return[u,c,d,n]}function Qg(e,t,n,s=1){let r=Ul(t,s);return Math.floor((e[0]*(n-1)-n+r)/2)}function hh(e){return typeof e=="number"?[e,e,e]:e.length===2?[e[0],e[1],1]:e}function eA(e){return typeof e=="number"?[e,e,e]:e}function Ul(e,t){return t<=1?e:e+(e-1)*(t-1)}function NT(e,t,n,s,r,a,o,i,l){let u,c,d;if(typeof e=="number"){u={top:e,bottom:e,left:e,right:e,type:e===0?"VALID":"NUMBER"};let h=CT([t,n],a,s,e,i);c=h[0],d=h[1]}else if(e==="same"){c=Math.ceil(t/s),d=Math.ceil(n/r);let p=Math.max(0,(c-1)*s+a-t),h=Math.max(0,(d-1)*r+o-n),f=Math.floor(p/2),m=p-f,g=Math.floor(h/2),A=h-g;u={top:f,bottom:m,left:g,right:A,type:"SAME"}}else if(e==="valid")u={top:0,bottom:0,left:0,right:0,type:"VALID"},c=Math.ceil((t-a+1)/s),d=Math.ceil((n-o+1)/r);else if(typeof e=="object"){let p=l==="channelsLast"?e[1][0]:e[2][0],h=l==="channelsLast"?e[1][1]:e[2][1],f=l==="channelsLast"?e[2][0]:e[3][0],m=l==="channelsLast"?e[2][1]:e[3][1];u={top:p,bottom:h,left:f,right:m,type:p===0&&h===0&&f===0&&m===0?"VALID":"EXPLICIT"},c=Wo((t-a+p+h)/s+1,i),d=Wo((n-o+f+m)/r+1,i)}else throw Error(`Unknown padding parameter: ${e}`);return{padInfo:u,outHeight:c,outWidth:d}}function ET(e,t,n,s,r,a,o,i,l,u,c){let d,p,h,f;if(typeof e=="number"){d={top:e,bottom:e,left:e,right:e,front:e,back:e,type:e===0?"VALID":"NUMBER"};let g=TT([t,n,s,1],i,1,r,e,c);p=g[0],h=g[1],f=g[2]}else if(e==="same"){p=Math.ceil(t/r),h=Math.ceil(n/a),f=Math.ceil(s/o);let m=(p-1)*r+i-t,g=(h-1)*a+l-n,A=(f-1)*o+u-s,y=Math.floor(m/2),x=m-y,b=Math.floor(g/2),v=g-b,k=Math.floor(A/2),S=A-k;d={top:b,bottom:v,left:k,right:S,front:y,back:x,type:"SAME"}}else if(e==="valid")d={top:0,bottom:0,left:0,right:0,front:0,back:0,type:"VALID"},p=Math.ceil((t-i+1)/r),h=Math.ceil((n-l+1)/a),f=Math.ceil((s-u+1)/o);else throw Error(`Unknown padding parameter: ${e}`);return{padInfo:d,outDepth:p,outHeight:h,outWidth:f}}function Wo(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 la(e){let[t,n,s]=hh(e);return t===1&&n===1&&s===1}function ar(e,t){return la(e)||la(t)}function mb(e){if(e==="NHWC")return"channelsLast";if(e==="NCHW")return"channelsFirst";throw new Error(`Unknown dataFormat ${e}`)}function RT(e,t){let s={x:$(e,"x","reshape","string_or_numeric")},r={shape:t};return L.runKernel(xl,s,r)}var V=W({reshape_:RT});function DT(e,t,n,s,r){let a=$(e,"x","avgPool","float32"),o=1;M(ar(n,o),()=>`Error in avgPool: Either strides or dilations must be 1. Got strides ${n} and dilations '${o}'`);let i=a,l=!1;a.rank===3&&(l=!0,i=V(a,[1,a.shape[0],a.shape[1],a.shape[2]])),M(i.rank===4,()=>`Error in avgPool: x must be rank 4 but got rank ${i.rank}.`),r!=null&&M(sn(s),()=>`Error in avgPool: pad must be an integer when using, dimRoundingMode ${r} but got pad ${s}.`);let u={x:i},c={filterSize:t,strides:n,pad:s,dimRoundingMode:r},d=L.runKernel(Pa,u,c);return d=pe(d,a.dtype),l?V(d,[d.shape[1],d.shape[2],d.shape[3]]):d}var Ic=W({avgPool_:DT});function _T(e,t,n,s,r,a="NDHWC"){let o=$(e,"x","avgPool3d","float32"),i=o,l=!1;o.rank===4&&(l=!0,i=V(o,[1,o.shape[0],o.shape[1],o.shape[2],o.shape[3]])),M(i.rank===5,()=>`Error in avgPool3d: x must be rank 5 but got rank ${i.rank}.`),M(a==="NDHWC",()=>`Error in avgPool3d: Only NDHWC is currently supported, but got dataFormat of ${a}`),r!=null&&M(sn(s),()=>`Error in avgPool3d: pad must be an integer when using, dimRoundingMode ${r} but got pad ${s}.`);let u={x:i},c={filterSize:t,strides:n,pad:s,dimRoundingMode:r,dataFormat:a},d=L.runKernel(Yu,u,c);return d=pe(d,i.dtype),l?V(d,[d.shape[1],d.shape[2],d.shape[3],d.shape[4]]):d}var tA=W({avgPool3d_:_T});function $T(e,t=0){M(e.length>=1,()=>"Pass at least one tensor to concat");let n=bc(e,"tensors","concat","string_or_numeric");if(n[0].dtype==="complex64"&&n.forEach(a=>{if(a.dtype!=="complex64")throw new Error(`Cannot concatenate complex64 tensors with a tensor
|
|
with dtype ${a.dtype}. `)}),n.length===1)return Bs(n[0]);let s=n,r={axis:t};return L.runKernel(Gi,s,r)}var ft=W({concat_:$T});function FT(e){let n={x:$(e,"x","sigmoid")};return L.runKernel(wo,n)}var Bn=W({sigmoid_:FT});function OT(e,t,n){let s=$(e,"x","slice","string_or_numeric");if(s.rank===0)throw new Error("Slicing scalar is not possible");let r={x:s},a={begin:t,size:n};return L.runKernel(kl,r,a)}var _e=W({slice_:OT});function PT(e){let n={x:$(e,"x","tanh")};return L.runKernel(Eo,n)}var Vo=W({tanh_:PT});function MT(e,t,n,s,r,a){let o=$(e,"forgetBias","basicLSTMCell"),i=$(t,"lstmKernel","basicLSTMCell"),l=$(n,"lstmBias","basicLSTMCell"),u=$(s,"data","basicLSTMCell"),c=$(r,"c","basicLSTMCell"),d=$(a,"h","basicLSTMCell"),p=ft([u,d],1),h=Ue(p,i),f=oe(h,l),m=f.shape[0],g=f.shape[1]/4,A=[m,g],y=_e(f,[0,0],A),x=_e(f,[0,g],A),b=_e(f,[0,g*2],A),v=_e(f,[0,g*3],A),k=oe(z(Bn(y),Vo(x)),z(c,Bn(oe(o,b)))),S=z(Vo(k),Bn(v));return[k,S]}var zT=W({basicLSTMCell_:MT});function LT(e,t,n){let s=$(e,"x","batchToSpaceND"),r=t.reduce((i,l)=>i*l);M(s.rank>=1+t.length,()=>`input rank is ${s.rank} but should be > than blockShape.length ${t.length}`),M(n.length===t.length,()=>`crops.length is ${n.length} but should be equal to blockShape.length ${t.length}`),M(s.shape[0]%r==0,()=>`input tensor batch is ${s.shape[0]} but is not divisible by the product of the elements of blockShape ${t.join(" * ")} === ${r}`);let a={x:s},o={blockShape:t,crops:n};return L.runKernel(Hi,a,o)}var Sc=W({batchToSpaceND_:LT});function BT(e){let t;return e.rank===0||e.rank===1?t=V(e,[1,1,1,e.size]):e.rank===2?t=V(e,[1,1,e.shape[0],e.shape[1]]):e.rank===3?t=V(e,[1,e.shape[0],e.shape[1],e.shape[2]]):t=e,t}function WT(e,t,n,s,r,a){a==null&&(a=.001);let o=$(e,"x","batchNorm"),i=$(t,"mean","batchNorm"),l=$(n,"variance","batchNorm"),u;r!=null&&(u=$(r,"scale","batchNorm"));let c;s!=null&&(c=$(s,"offset","batchNorm")),M(i.rank===l.rank,()=>"Batch normalization gradient requires mean and variance to have equal ranks."),M(c==null||i.rank===c.rank,()=>"Batch normalization gradient requires mean and offset to have equal ranks."),M(u==null||i.rank===u.rank,()=>"Batch normalization gradient requires mean and scale to have equal ranks.");let p={x:BT(o),scale:u,offset:c,mean:i,variance:l},h={varianceEpsilon:a},f=L.runKernel(Ya,p,h);return V(f,o.shape)}var Uo=W({batchNorm_:WT});function VT(e,t,n,s,r,a){let o=$(e,"x","batchNorm"),i=$(t,"mean","batchNorm"),l=$(n,"variance","batchNorm"),u;r!=null&&(u=$(r,"scale","batchNorm"));let c;return s!=null&&(c=$(s,"offset","batchNorm")),M(o.rank===2,()=>`Error in batchNorm2D: x must be rank 2 but got rank ${o.rank}.`),M(i.rank===2||i.rank===1,()=>`Error in batchNorm2D: mean must be rank 2 or rank 1 but got rank ${i.rank}.`),M(l.rank===2||l.rank===1,()=>`Error in batchNorm2D: variance must be rank 2 or rank 1 but got rank ${l.rank}.`),u!=null&&M(u.rank===2||u.rank===1,()=>`Error in batchNorm2D: scale must be rank 2 or rank 1 but got rank ${u.rank}.`),c!=null&&M(c.rank===2||c.rank===1,()=>`Error in batchNorm2D: offset must be rank 2 or rank 1 but got rank ${c.rank}.`),Uo(o,i,l,c,u,a)}var gb=W({batchNorm2d_:VT});function UT(e,t,n,s,r,a){let o=$(e,"x","batchNorm"),i=$(t,"mean","batchNorm"),l=$(n,"variance","batchNorm"),u;r!=null&&(u=$(r,"scale","batchNorm"));let c;return s!=null&&(c=$(s,"offset","batchNorm")),M(o.rank===3,()=>`Error in batchNorm3D: x must be rank 3 but got rank ${o.rank}.`),M(i.rank===3||i.rank===1,()=>`Error in batchNorm3D: mean must be rank 3 or rank 1 but got rank ${i.rank}.`),M(l.rank===3||l.rank===1,()=>`Error in batchNorm3D: variance must be rank 3 or rank 1 but got rank ${l.rank}.`),u!=null&&M(u.rank===3||u.rank===1,()=>`Error in batchNorm3D: scale must be rank 3 or rank 1 but got rank ${u.rank}.`),c!=null&&M(c.rank===3||c.rank===1,()=>`Error in batchNorm3D: offset must be rank 3 or rank 1 but got rank ${c.rank}.`),Uo(o,i,l,c,u,a)}var Ab=W({batchNorm3d_:UT});function HT(e,t,n,s,r,a){let o=$(e,"x","batchNorm"),i=$(t,"mean","batchNorm"),l=$(n,"variance","batchNorm"),u;r!=null&&(u=$(r,"scale","batchNorm"));let c;return s!=null&&(c=$(s,"offset","batchNorm")),M(o.rank===4,()=>`Error in batchNorm4D: x must be rank 4 but got rank ${o.rank}.`),M(i.rank===4||i.rank===1,()=>`Error in batchNorm4D: mean must be rank 4 or rank 1 but got rank ${i.rank}.`),M(l.rank===4||l.rank===1,()=>`Error in batchNorm4D: variance must be rank 4 or rank 1 but got rank ${l.rank}.`),u!=null&&M(u.rank===4||u.rank===1,()=>`Error in batchNorm4D: scale must be rank 4 or rank 1 but got rank ${u.rank}.`),c!=null&&M(c.rank===4||c.rank===1,()=>`Error in batchNorm4D: offset must be rank 4 or rank 1 but got rank ${c.rank}.`),Uo(o,i,l,c,u,a)}var yb=W({batchNorm4d_:HT});function GT(e,t,n){let s=$(e,"x","bincount"),r=$(t,"weights","bincount");M(s.dtype==="int32",()=>`Error in bincount: input dtype must be int32, but got ${s.dtype}`),M(n>=0,()=>`size must be non-negative, but got ${n}.`),M(r.size===s.size||r.size===0,()=>`Error in bincount: weights must have the same size as input or0-length, but got input shape: ${s.shape}, weights shape: ${r.shape}.`);let a={x:s,weights:r},o={size:n};return L.runKernel(gp,a,o)}var nA=W({bincount_:GT});function jT(e,t){let n=$(e,"s0","broadcastArgs","int32"),s=$(t,"s1","broadcastArgs","int32");if(n.rank!==1)throw new Error(`broadcastArgs(): first input must be a vector (rank=1). Has rank ${n.rank}`);if(s.rank!==1)throw new Error(`broadcastArgs(): second input must be a vector (rank=1). Has rank ${s.rank}`);let r={s0:n,s1:s};return L.runKernel(pg,r)}var xb=W({broadcastArgs_:jT});function qT(e,t){let n=$(e,"broadcastTo","x"),s=n.shape;if(t.some(u=>!(u>0)||u%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){let u=n.shape.slice();for(;u.length<t.length;)u.unshift(1);n=V(n,u)}let r=n.shape,a=Array.from(t);for(let u=t.length-1;u>=0;u--)if(r[u]===t[u])a[u]=1;else if(n.shape[u]!==1)throw new Error(`broadcastTo(): [${s}] cannot be broadcast to [${t}].`);if(a.map((u,c)=>u>1?c:-1).filter(u=>u>=0).length===0)return Bs(n);let i={x:n},l={reps:a};return L.runKernel(Qr,i,l)}var Hl=W({broadcastTo_:qT});function XT(e){let n={x:$(e,"x","ceil")};return L.runKernel(La,n)}var sA=W({ceil_:XT});function KT(e,t,n){let s=$(e,"x","clipByValue");M(t<=n,()=>`Error in clip: min (${t}) must be less than or equal to max (${n}).`);let r={x:s},a={clipValueMin:t,clipValueMax:n};return L.runKernel(Jr,r,a)}var Wn=W({clipByValue_:KT});function ZT(e){return ft(e,0)}var bb=W({concat1d_:ZT});function YT(e,t){return ft(e,t)}var Gl=W({concat2d_:YT});function JT(e,t){return ft(e,t)}var vb=W({concat3d_:JT});function QT(e,t){return ft(e,t)}var wb=W({concat4d_:QT});function eN(e,t,n,s,r="NHWC",a=[1,1],o){let i=$(e,"x","conv2d"),l=$(t,"filter","conv2d"),u=i,c=!1;i.rank===3&&(c=!0,u=V(i,[1,i.shape[0],i.shape[1],i.shape[2]])),M(u.rank===4,()=>`Error in conv2d: input must be rank 4, but got rank ${u.rank}.`),M(l.rank===4,()=>`Error in conv2d: filter must be rank 4, but got rank ${l.rank}.`),o!=null&&M(sn(s),()=>`Error in conv2d: pad must be an integer when using, dimRoundingMode ${o} but got pad ${s}.`);let d=r==="NHWC"?u.shape[3]:u.shape[1];M(d===l.shape[2],()=>`Error in conv2d: depth of input (${d}) must match input depth for filter ${l.shape[2]}.`),M(ar(n,a),()=>`Error in conv2D: Either strides or dilations must be 1. Got strides ${n} and dilations '${a}'`);let p={x:u,filter:l},h={strides:n,pad:s,dataFormat:r,dilations:a,dimRoundingMode:o},f=L.runKernel(Ba,p,h);return c?V(f,[f.shape[1],f.shape[2],f.shape[3]]):f}var Tr=W({conv2d_:eN});function tN(e,t,n,s,r="NWC",a=1,o){let i=$(e,"x","conv1d"),l=$(t,"filter","conv1d"),u=i,c=!1;i.rank===2&&(c=!0,u=V(i,[1,i.shape[0],i.shape[1]])),M(u.rank===3,()=>`Error in conv1d: input must be rank 3, but got rank ${u.rank}.`),M(l.rank===3,()=>`Error in conv1d: filter must be rank 3, but got rank ${l.rank}.`),o!=null&&M(sn(s),()=>`Error in conv1d: pad must be an integer when using, dimRoundingMode ${o} but got pad ${s}.`),M(u.shape[2]===l.shape[1],()=>`Error in conv1d: depth of input (${u.shape[2]}) must match input depth for filter ${l.shape[1]}.`),M(ar(n,a),()=>`Error in conv1D: Either stride or dilation must be 1. Got stride ${n} and dilation '${a}'`),M(r==="NWC",()=>`Error in conv1d: got dataFormat of ${r} but only NWC is currently supported.`);let d=V(l,[1,l.shape[0],l.shape[1],l.shape[2]]),p=V(u,[u.shape[0],1,u.shape[1],u.shape[2]]),g=Tr(p,d,[1,n],s,"NHWC",[1,a],o);return c?V(g,[g.shape[2],g.shape[3]]):V(g,[g.shape[0],g.shape[2],g.shape[3]])}var fh=W({conv1d_:tN});function nN(e,t,n,s,r,a="NHWC",o){M(e.length===t.rank,()=>`Length of inShape (${e.length}) and rank of dy (${t.rank}) must match`);let i=e,l=t,u=!1;t.rank===3&&(u=!0,l=V(t,[1,t.shape[0],t.shape[1],t.shape[2]]),i=[1,e[0],e[1],e[2]]),M(i.length===4,()=>`Error in conv2dDerInput: inShape must be length 4, but got length ${i.length}.`),M(l.rank===4,()=>`Error in conv2dDerInput: dy must be rank 4, but got rank ${l.rank}`),M(n.rank===4,()=>`Error in conv2dDerInput: filter must be rank 4, but got rank ${n.rank}`);let c=a==="NHWC"?i[3]:i[1],d=a==="NHWC"?l.shape[3]:l.shape[1];M(c===n.shape[2],()=>`Error in conv2dDerInput: depth of input (${c}) must match input depth for filter ${n.shape[2]}.`),M(d===n.shape[3],()=>`Error in conv2dDerInput: depth of output (${d}) must match output depth for filter ${n.shape[3]}.`),o!=null&&M(sn(r),()=>`Error in conv2dDerInput: pad must be an integer when using, dimRoundingMode ${o} but got pad ${r}.`);let p={dy:l,filter:n},h={strides:s,pad:r,dataFormat:a,dimRoundingMode:o,inputShape:i},f=L.runKernel(Wa,p,h);return u?V(f,[f.shape[1],f.shape[2],f.shape[3]]):f}var rA=W({conv2DBackpropInput_:nN});function sN(e,t,n,s,r,a){let o=$(e,"x","conv2dTranspose"),i=$(t,"filter","conv2dTranspose");return rA(n,o,i,s,r,"NHWC",a)}var mh=W({conv2dTranspose_:sN});function rN(e,t,n,s,r="NDHWC",a=[1,1,1]){let o=$(e,"x","conv3d"),i=$(t,"filter","conv3d"),l=o,u=!1;o.rank===4&&(u=!0,l=V(o,[1,o.shape[0],o.shape[1],o.shape[2],o.shape[3]])),M(l.rank===5,()=>`Error in conv3d: input must be rank 5, but got rank ${l.rank}.`),M(i.rank===5,()=>`Error in conv3d: filter must be rank 5, but got rank ${i.rank}.`),M(l.shape[4]===i.shape[3],()=>`Error in conv3d: depth of input (${l.shape[4]}) must match input depth for filter ${i.shape[3]}.`),M(ar(n,a),()=>`Error in conv3D: Either strides or dilations must be 1. Got strides ${n} and dilations '${a}'`),M(r==="NDHWC",()=>`Error in conv3d: got dataFormat of ${r} but only NDHWC is currently supported.`);let c={x:l,filter:i},d={strides:n,pad:s,dataFormat:r,dilations:a},p=L.runKernel(Qu,c,d);return u?V(p,[p.shape[1],p.shape[2],p.shape[3],p.shape[4]]):p}var aA=W({conv3d_:rN});function aN(e,t,n,s,r){M(e.length===t.rank,()=>`Length of inShape (${e.length}) and rank of dy (${t.rank}) must match`);let a=e,o=t,i=!1;t.rank===4&&(i=!0,o=V(t,[1,t.shape[0],t.shape[1],t.shape[2],t.shape[3]]),a=[1,e[0],e[1],e[2],e[3]]);let l=a[4],u=o.shape[4];M(a.length===5,()=>`Error in conv3dDerInput: inShape must be length 5, but got length ${a.length}.`),M(o.rank===5,()=>`Error in conv3dDerInput: dy must be rank 5, but got rank ${o.rank}`),M(n.rank===5,()=>`Error in conv3dDerInput: filter must be rank 5, but got rank ${n.rank}`),M(l===n.shape[3],()=>`Error in conv3dDerInput: depth of input (${l}) must match input depth for filter ${n.shape[3]}.`),M(u===n.shape[4],()=>`Error in conv3dDerInput: depth of output (${u}) must match output depth for filter ${n.shape[4]}.`);let c={dy:o,filter:n},d={pad:r,strides:s,inputShape:a},p=L.runKernel(bp,c,d);return i?V(p,[p.shape[1],p.shape[2],p.shape[3],p.shape[4]]):p}var kb=W({conv3DBackpropInput_:aN});function oN(e,t,n,s,r){let a=$(e,"x","conv3dTranspose"),o=$(t,"filter","conv3dTranspose");return kb(n,a,o,s,r)}var Ib=W({conv3dTranspose_:oN});function iN(e){let n={x:$(e,"x","cos")};return L.runKernel(Va,n)}var Cc=W({cos_:iN});function lN(e){let n={x:$(e,"x","cosh")};return L.runKernel(Ua,n)}var gh=W({cosh_:lN});function uN(e,t=0,n=!1,s=!1){let a={x:$(e,"x","cumsum")},o={axis:t,exclusive:n,reverse:s};return L.runKernel(Ha,a,o)}var Ah=W({cumsum_:uN});function cN(e,t,n,s=!1){let r=$(e,"x","denseBincount"),a=$(t,"weights","denseBincount");M(r.dtype==="int32",()=>`Error in denseBincount: input dtype must be int32, but got ${r.dtype}`),M(r.rank<=2,()=>`Error in denseBincount: input must be at most rank 2, but got rank ${r.rank}.`),M(n>=0,()=>`size must be non-negative, but got ${n}.`),M(a.size===r.size||a.size===0,()=>`Error in denseBincount: weights must have the same shape as x or 0-length, but got x shape: ${r.shape}, weights shape: ${a.shape}.`);let o={x:r,weights:a},i={size:n,binaryOutput:s};return L.runKernel(vp,o,i)}var Sb=W({denseBincount_:cN});function dN(e,t,n="NHWC"){let s=$(e,"x","depthToSpace"),r=n==="NHWC"?s.shape[1]:s.shape[2],a=n==="NHWC"?s.shape[2]:s.shape[3],o=n==="NHWC"?s.shape[3]:s.shape[1];M(r*t>=0,()=>`Negative dimension size caused by overflow when multiplying
|
|
${r} and ${t} for depthToSpace with input shape
|
|
${s.shape}`),M(a*t>=0,()=>`Negative dimension size caused by overflow when multiplying
|
|
${a} and ${t} for depthToSpace with input shape
|
|
${s.shape}`),M(o%(t*t)==0,()=>`Dimension size must be evenly divisible by ${t*t} but is ${o} for depthToSpace with input shape ${s.shape}`);let i={x:s},l={blockSize:t,dataFormat:n};return L.runKernel(qi,i,l)}var oA=W({depthToSpace_:dN});function pN(e,t,n,s,r="NHWC",a=[1,1],o){let i=$(e,"x","depthwiseConv2d"),l=$(t,"filter","depthwiseConv2d"),u=i,c=!1;i.rank===3&&(c=!0,u=V(i,[1,i.shape[0],i.shape[1],i.shape[2]])),M(u.rank===4,()=>`Error in depthwiseConv2d: input must be rank 4, but got rank ${u.rank}.`),M(l.rank===4,()=>`Error in depthwiseConv2d: filter must be rank 4, but got rank ${l.rank}.`),M(u.shape[3]===l.shape[2],()=>`Error in depthwiseConv2d: number of input channels (${u.shape[3]}) must match the inChannels dimension in filter ${l.shape[2]}.`),o!=null&&M(sn(s),()=>`Error in depthwiseConv2d: pad must be an integer when using, dimRoundingMode ${o} but got pad ${s}.`);let d={x:u,filter:l},p={strides:n,pad:s,dataFormat:r,dilations:a,dimRoundingMode:o},h=L.runKernel(Ga,d,p);return c?V(h,[h.shape[1],h.shape[2],h.shape[3]]):h}var jl=W({depthwiseConv2d_:pN});function hN(e){let n={x:$(e,"x","diag")};return L.runKernel(Ip,n)}var fN=W({diag_:hN});function mN(e,t,n,s,r=[1,1],a="NHWC"){let o=$(e,"x","dilation2d"),i=$(t,"filter","dilation2d");M(o.rank===3||o.rank===4,()=>`Error in dilation2d: input must be rank 3 or 4, but got rank ${o.rank}.`),M(i.rank===3,()=>`Error in dilation2d: filter must be rank 3, but got rank ${i.rank}.`),M(a==="NHWC",()=>`Error in dilation2d: Only NHWC is currently supported, but got dataFormat of ${a}`);let l=o,u=!1;o.rank===3&&(l=V(o,[1,o.shape[0],o.shape[1],o.shape[2]]),u=!0);let c={x:l,filter:i},d={strides:n,pad:s,dilations:r},p=L.runKernel(ec,c,d);return u?V(p,[p.shape[1],p.shape[2],p.shape[3]]):p}var iA=W({dilation2d_:mN});function gN(e,t){let n=e.length,s=[];for(let r=0;r<n;r++){let a=n-1-r,o=e[a]||1;(t[t.length-1-r]||1)>1&&o===1&&s.unshift(a)}return s}function Zt(e,t){let n=[];for(let s=0;s<t.length;s++){let r=e[e.length-s-1],a=t.length-s-1,o=t[a];(r==null||r===1&&o>1)&&n.unshift(a)}return n}function bt(e,t){let n=[],s=Math.max(e.length,t.length);for(let r=0;r<s;r++){let a=e[e.length-r-1];a==null&&(a=1);let o=t[t.length-r-1];if(o==null&&(o=1),a===1)n.unshift(o);else if(o===1)n.unshift(a);else if(a!==o){let i=`Operands could not be broadcast together with shapes ${e} and ${t}.`;throw Error(i)}else n.unshift(a)}return n}function AN(e,t){let n=$(e,"a","equal","string_or_numeric"),s=$(t,"b","equal","string_or_numeric");[n,s]=Rt(n,s),bt(n.shape,s.shape);let r={a:n,b:s};return L.runKernel(Ki,r)}var es=W({equal_:AN});function yN(e,t,n){let s=$(t,"a","where"),r=$(n,"b","where"),a=$(e,"condition","where","bool"),o=bt(bt(a.shape,s.shape),r.shape),i=Hl(a,o),l=Hl(s,o),u=Hl(r,o),c={condition:i,t:l,e:u};return L.runKernel(vl,c)}var vn=W({where_:yN});function xN(e){let n={x:$(e,"x","zerosLike")};return L.runKernel($l,n)}var Je=W({zerosLike_:xN});function bN(e,t){let n=$(e,"a","div"),s=$(t,"b","div");[n,s]=Rt(n,s);let r=he(n,s),a=Je(r),o=es(s,a);return vn(o,a,r)}var lA=W({divNoNan_:bN});function vN(e,t){let n=$(e,"t1","dot"),s=$(t,"t2","dot");M((n.rank===1||n.rank===2)&&(s.rank===1||s.rank===2),()=>`Error in dot: inputs must all be rank 1 or 2, but got ranks ${n.rank} and ${s.rank}.`);let r=n.rank===1?n.size:n.shape[1],a=s.rank===1?s.size:s.shape[0];if(M(r===a,()=>`Error in dot: inner dimensions of inputs must match, but got ${r} and ${a}.`),n.rank===1&&s.rank===1){let o=V(n,[1,-1]),i=V(s,[-1,1]),l=Ue(o,i);return V(l,[])}else if(n.rank===1&&s.rank===2){let o=V(n,[1,-1]),i=V(s,[s.shape[0],s.shape[1]]),l=Ue(o,i);return V(l,[l.size])}else if(n.rank===2&&s.rank===1){let o=V(s,[-1,1]),i=Ue(n,o);return V(i,[i.size])}else{let o=V(s,[s.shape[0],s.shape[1]]);return Ue(n,o)}}var Cb=W({dot_:vN});function wN(e,...t){let n=t.map((r,a)=>$(r,`tensors${a}`,"einsum")),s={equation:e};return L.runKernel(Tp,n,s)}var Tb=W({einsum_:wN});function kN(e){let n={x:$(e,"x","elu")};return L.runKernel(qa,n)}var ql=W({elu_:kN});function IN(e){let t=$(e,"x","erf");M(t.dtype==="int32"||t.dtype==="float32",()=>"Input dtype must be `int32` or `float32`."),t.dtype==="int32"&&(t=pe(t,"float32"));let n={x:t};return L.runKernel(Xi,n)}var uA=W({erf_:IN});function SN(e){let n={x:$(e,"x","exp")};return L.runKernel(Xa,n)}var ts=W({exp_:SN});function CN(e,t=0){let n=$(e,"x","expandDims","string_or_numeric");M(t<=n.rank,()=>"Axis must be <= rank of the tensor");let s={input:n},r={dim:t};return L.runKernel(Zi,s,r)}var Lt=W({expandDims_:CN});function TN(e){let n={x:$(e,"x","expm1")};return L.runKernel(Yi,n)}var cA=W({expm1_:TN});function NN(e,t){let n=$(e,"x","tile","string_or_numeric");M(n.rank===t.length,()=>`Error in transpose: rank of input ${n.rank} must match length of reps ${t}.`);let s={x:n},r={reps:t};return L.runKernel(Qr,s,r)}var bs=W({tile_:NN});function EN(e,t,n,s="float32"){t==null&&(t=e);let r=je([e,t],s),a=e<=t?e:t;for(let i=0;i<a;++i)r.set(1,i,i);let o=V(r.toTensor(),[e,t]);if(n==null)return o;if(n.length===1)return bs(Lt(o,0),[n[0],1,1]);if(n.length===2)return bs(Lt(Lt(o,0),0),[n[0],n[1],1,1]);if(n.length===3)return bs(Lt(Lt(Lt(o,0),0),0),[n[0],n[1],n[2],1,1]);throw new Error(`eye() currently supports only 1D and 2D batchShapes, but received ${n.length}D.`)}var dA=W({eye_:EN});function Xl(e,t,n){let s={shape:e,value:t,dtype:n};return L.runKernel(tc,{},s)}function RN(e){let n={x:$(e,"x","floor")};return L.runKernel(Ka,n)}var Kl=W({floor_:RN});function DN(e,t,n=0,s=0){let r=$(e,"x","gather"),a=$(t,"indices","gather","int32"),o={x:r,indices:a},i={axis:n,batchDims:s};return L.runKernel(Qi,o,i)}var Ho=W({gather_:DN});function _N(e,t){let n=$(e,"a","greater","string_or_numeric"),s=$(t,"b","greater","string_or_numeric");[n,s]=Rt(n,s),bt(n.shape,s.shape);let r={a:n,b:s};return L.runKernel(tl,r)}var Vn=W({greater_:_N});function $N(e,t){let n=$(e,"a","greaterEqual","string_or_numeric"),s=$(t,"b","greaterEqual","string_or_numeric");[n,s]=Rt(n,s),bt(n.shape,s.shape);let r={a:n,b:s};return L.runKernel(Ja,r)}var ua=W({greaterEqual_:$N});function FN(e){let n={input:$(e,"input","imag")};return L.runKernel(Dp,n)}var yh=W({imag_:FN});function ON(e){let n={x:$(e,"x","isFinite")};return L.runKernel(nl,n)}var Nb=W({isFinite_:ON});function PN(e){let n={x:$(e,"x","isInf")};return L.runKernel(sl,n)}var Eb=W({isInf_:PN});function MN(e){let n={x:$(e,"x","isNaN")};return L.runKernel(rl,n)}var pA=W({isNaN_:MN});function zN(e,t=.2){let s={x:$(e,"x","leakyRelu")},r={alpha:t};return L.runKernel(eo,s,r)}var Tc=W({leakyRelu_:zN});function LN(e,t){let n=$(e,"a","less","string_or_numeric"),s=$(t,"b","less","string_or_numeric");[n,s]=Rt(n,s),bt(n.shape,s.shape);let r={a:n,b:s};return L.runKernel(al,r)}var xh=W({less_:LN});function BN(e,t){let n=$(e,"a","lessEqual","string_or_numeric"),s=$(t,"b","lessEqual","string_or_numeric");[n,s]=Rt(n,s),bt(n.shape,s.shape);let r={a:n,b:s};return L.runKernel(ol,r)}var ca=W({lessEqual_:BN});function Rb(e,t,n){if(n<=0)throw new Error("The number of values should be positive.");let s={start:e,stop:t,num:n};return L.runKernel(_p,{},s)}function WN(e,t=5,n=1,s=1,r=.5){let a=$(e,"x","localResponseNormalization");M(a.rank===4||a.rank===3,()=>`Error in localResponseNormalization: x must be rank 3 or 4 but got
|
|
rank ${a.rank}.`),M(sn(t),()=>`Error in localResponseNormalization: depthRadius must be an integer but got depthRadius ${t}.`);let o=a,i=!1;a.rank===3&&(i=!0,o=V(a,[1,a.shape[0],a.shape[1],a.shape[2]]));let l={x:o},u={depthRadius:t,bias:n,alpha:s,beta:r},c=L.runKernel(rc,l,u);return i?V(c,[c.shape[1],c.shape[2],c.shape[3]]):c}var hA=W({localResponseNormalization_:WN});function VN(e){let n={x:$(e,"x","log")};return L.runKernel(to,n)}var ns=W({log_:VN});function UN(e){let n={x:$(e,"x","log1p")};return L.runKernel(il,n)}var Nc=W({log1p_:UN});function HN(e){return M(Zr(e),()=>"The f passed in grad(f) must be a function"),(t,n)=>{let s=$(t,"x","tf.grad","string_or_numeric"),r=n!=null?$(n,"dy","tf.grad"):null;return L.tidy(()=>{let{value:a,grads:o}=L.gradients(()=>e(s),[s],r);return r!=null&&In(a.shape,r.shape,"The shape of dy passed in grad(f)(x, dy) must match the shape returned by f(x)"),bh(o),o[0]})}}function GN(e){return M(Zr(e),()=>"The f passed in grads(f) must be a function"),(t,n)=>{M(Array.isArray(t),()=>"The args passed in grads(f)(args) must be an array of `Tensor`s or `TensorLike`s");let s=bc(t,"args","tf.grads","string_or_numeric"),r=n!=null?$(n,"dy","tf.grads"):null;return L.tidy(()=>{let{value:a,grads:o}=L.gradients(()=>e(...s),s,r);return r!=null&&In(a.shape,r.shape,"The shape of dy passed in grads(f)([x1,...], dy) must match the shape returned by f([x1,...])"),bh(o),o})}}function jN(e){return M(Zr(e),()=>"The f passed in valueAndGrad(f) must be a function"),(t,n)=>{M(t instanceof Ge,()=>"The x passed in valueAndGrad(f)(x) must be a tensor"),M(n==null||n instanceof Ge,()=>"The dy passed in valueAndGrad(f)(x, dy) must be a tensor");let{grads:s,value:r}=L.gradients(()=>e(t),[t],n);return bh(s),{grad:s[0],value:r}}}function qN(e){return M(Zr(e),()=>"The f passed in valueAndGrads(f) must be a function"),(t,n)=>{M(Array.isArray(t)&&t.every(r=>r instanceof Ge),()=>"The args passed in valueAndGrads(f)(args) must be array of tensors"),M(n==null||n instanceof Ge,()=>"The dy passed in valueAndGrads(f)(args, dy) must be a tensor");let s=L.gradients(()=>e(...t),t,n);return n!=null&&In(s.value.shape,n.shape,"The shape of dy passed in valueAndGrads(f)([x1,...], dy) must match the shape returned by f([x1,...])"),bh(s.grads),s}}function Db(e,t){M(Zr(e),()=>"The f passed in variableGrads(f) must be a function"),M(t==null||Array.isArray(t)&&t.every(u=>u instanceof Ac),()=>"The varList passed in variableGrads(f, varList) must be an array of variables");let n=t!=null;if(!n){t=[];for(let u in L.registeredVariables)t.push(L.registeredVariables[u])}let s=n?t.filter(u=>!u.trainable):null,r=t.length;t=t.filter(u=>u.trainable),M(t.length>0,()=>`variableGrads() expects at least one of the input variables to be trainable, but none of the ${r} variables is trainable.`);let a=!0,{value:o,grads:i}=L.gradients(e,t,null,a);M(i.some(u=>u!=null),()=>"Cannot find a connection between any variable and the result of the loss function y=f(x). Please make sure the operations that use variables are inside the function f passed to minimize()."),M(o.rank===0,()=>`The f passed in variableGrads(f) must return a scalar, but it returned a rank-${o.rank} tensor`);let l={};return t.forEach((u,c)=>{i[c]!=null&&(l[u.name]=i[c])}),s!=null&&s.forEach(u=>l[u.name]=null),{value:o,grads:l}}function or(e){return L.customGrad(e)}function bh(e){if(e.filter(n=>n==null).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.`)}function XN(e){let n={x:$(e,"x","neg")};return L.runKernel(cl,n)}var St=W({neg_:XN});function KN(e){let n={x:$(e,"x","softplus")};return L.runKernel(Cl,n)}var Go=W({softplus_:KN});function ZN(e){let t=$(e,"x","logSigmoid");return or(s=>({value:St(Go(St(s))),gradFunc:o=>z(o,Bn(St(s)))}))(t)}var _b=W({logSigmoid_:ZN});function YN(e,t=null,n=!1){let r={x:$(e,"x","max")},a={reductionIndices:t,keepDims:n};return L.runKernel(no,r,a)}var ss=W({max_:YN});function JN(e,t){let n=$(e,"a","sub"),s=$(t,"b","sub");[n,s]=Rt(n,s);let r={a:n,b:s};return L.runKernel(To,r)}var ye=W({sub_:JN});function QN(e,t=null,n=!1){let s=$(e,"x","sum");s.dtype==="bool"&&(s=pe(s,"int32"));let r={x:s},a={axis:t,keepDims:n};return L.runKernel(Io,r,a)}var we=W({sum_:QN});function eE(e,t=-1){let n=$(e,"logits","logSoftmax");if(t===-1&&(t=n.rank-1),t!==n.rank-1)throw Error(`Log Softmax along a non-last dimension is not yet supported. Logits was rank ${n.rank} and axis was ${t}`);return or((r,a)=>{let o=!0,i=ss(r,t,!0),l=ye(r,i),u=ye(pe(l,"float32"),ns(we(ts(l),t,o)));return a([u]),{value:u,gradFunc:(d,p)=>{let[h]=p,f=!0,m=ts(h);return ye(d,z(we(d,t,f),m))}}})(n)}var vh=W({logSoftmax_:eE});function fA(e,t){for(let n=0;n<e.length;++n)if(e[e.length-n-1]!==t-1-n)return!1;return!0}function $b(e,t,n){let s=e.length+t.length,r=[],a=0,o=0;for(let i=0;i<s;i++)n.indexOf(i)===-1?r.push(e[a++]):r.push(t[o++]);return r}function Fb(e,t){let n=[],s=e.length;for(let a=0;a<s;a++)t.indexOf(a)===-1&&n.push(e[a]);let r=t.map(a=>e[a]);return[n,r]}function jo(e,t){let n=t.map(s=>1);return $b(e,n,t)}function tE(e,t,n){M(fA(t,n),()=>`${e} supports only inner-most axes for now. Got axes ${t} and rank-${n} input.`)}function Ob(e,t){if(fA(e,t))return null;let n=[];for(let s=0;s<t;++s)e.indexOf(s)===-1&&n.push(s);return e.forEach(s=>n.push(s)),n}function mA(e){return e.map((t,n)=>[n,t]).sort((t,n)=>t[1]-n[1]).map(t=>t[0])}function nE(e,t){let n=[];for(let s=t-e;s<t;++s)n.push(s);return n}function sE(e,t=null,n=!1){let s=$(e,"x","logSumExp"),r=Rs(t,s.shape),a=ss(s,r,!0),o=ye(s,a),i=ts(o),l=we(i,r),u=ns(l),c=oe(V(a,u.shape),u);if(n){let d=jo(c.shape,r);return V(c,d)}return c}var gA=W({logSumExp_:sE});function rE(e,t){let n=$(e,"a","logicalAnd","bool"),s=$(t,"b","logicalAnd","bool");bt(n.shape,s.shape);let r={a:n,b:s};return L.runKernel(ll,r)}var _s=W({logicalAnd_:rE});function aE(e){let n={x:$(e,"x","logicalNot","bool")};return L.runKernel(nc,n)}var Ec=W({logicalNot_:aE});function oE(e,t){let n=$(e,"a","logicalOr","bool"),s=$(t,"b","logicalOr","bool");bt(n.shape,s.shape);let r={a:n,b:s};return L.runKernel(sc,r)}var wh=W({logicalOr_:oE});function iE(e,t){let n=$(e,"a","logicalXor","bool"),s=$(t,"b","logicalXor","bool");return bt(n.shape,s.shape),_s(wh(e,t),Ec(_s(e,t)))}var Pb=W({logicalXor_:iE});function lE(e,t,n,s,r){let a=$(e,"x","maxPool"),o=1,i=a,l=!1;a.rank===3&&(l=!0,i=V(a,[1,a.shape[0],a.shape[1],a.shape[2]])),M(i.rank===4,()=>`Error in maxPool: input must be rank 4 but got rank ${i.rank}.`),M(ar(n,o),()=>`Error in maxPool: Either strides or dilations must be 1. Got strides ${n} and dilations '${o}'`),r!=null&&M(sn(s),()=>`Error in maxPool: pad must be an integer when using, dimRoundingMode ${r} but got pad ${s}.`);let u={x:i},c={filterSize:t,strides:n,pad:s,dimRoundingMode:r},d=L.runKernel(ro,u,c);return l?V(d,[d.shape[1],d.shape[2],d.shape[3]]):d}var Rc=W({maxPool_:lE});function uE(e,t=[1,1,1],n,s,r,a="NDHWC"){let o=$(e,"x","maxPool3d"),i=o,l=!1;o.rank===4&&(l=!0,i=V(o,[1,o.shape[0],o.shape[1],o.shape[2],o.shape[3]])),M(i.rank===5,()=>`Error in maxPool3d: x must be rank 5 but got rank ${i.rank}.`),M(a==="NDHWC",()=>`Error in maxPool3d: Only NDHWC is currently supported, but got dataFormat of ${a}`),r!=null&&M(sn(s),()=>`Error in maxPool3d: pad must be an integer when using, dimRoundingMode ${r} but got pad ${s}.`);let u={x:i},c={filterSize:t,strides:n,pad:s,dimRoundingMode:r,dataFormat:a},d=L.runKernel(ac,u,c);return l?V(d,[d.shape[1],d.shape[2],d.shape[3],d.shape[4]]):d}var AA=W({maxPool3d_:uE});function cE(e,t,n,s,r=!1){let o={x:$(e,"x","maxPoolWithArgmax")},i={filterSize:t,strides:n,pad:s,includeBatchInIndex:r},l=L.runKernel(Pp,o,i);return{result:l[0],indexes:l[1]}}var Mb=W({maxPoolWithArgmax_:cE});function dE(e,t){let n=$(e,"a","maximum"),s=$(t,"b","maximum");[n,s]=Rt(n,s),n.dtype==="bool"&&(n=pe(n,"int32"),s=pe(s,"int32")),bt(n.shape,s.shape);let r={a:n,b:s};return L.runKernel(so,r)}var ir=W({maximum_:dE});function pE(e,t=null,n=!1){let r={x:$(e,"x","mean")},a={axis:t,keepDims:n};return L.runKernel(ao,r,a)}var Dt=W({mean_:pE});function Mt(e,t="float32"){if(t==="complex64"){let s=Mt(e,"float32"),r=Mt(e,"float32");return sa(s,r)}let n=hp(zt(e),t);return L.makeTensor(n,e,t)}function rs(e,t="float32"){if(t==="complex64"){let s=rs(e,"float32"),r=Mt(e,"float32");return sa(s,r)}let n=ig(zt(e),t);return L.makeTensor(n,e,t)}function hE(e,t,{indexing:n="xy"}={}){if(n!=="xy"&&n!=="ij")throw new TypeError(`${n} is not a valid third argument to meshgrid`);if(e===void 0)return[];let s=$(e,"x","meshgrid",e instanceof Ge?e.dtype:"float32");if(t===void 0)return[s];let r=$(t,"y","meshgrid",t instanceof Ge?t.dtype:"float32"),a=zt(s.shape),o=zt(r.shape);return n==="xy"?(s=V(s,[1,-1]),r=V(r,[-1,1]),[Ue(rs([o,1],s.dtype),s),Ue(r,rs([1,a],r.dtype))]):(s=V(s,[-1,1]),r=V(r,[1,-1]),[Ue(s,rs([1,o],s.dtype)),Ue(rs([a,1],r.dtype),r)])}function fE(e,t=null,n=!1){let r={x:$(e,"x","min")},a={axis:t,keepDims:n};return L.runKernel(oo,r,a)}var Dc=W({min_:fE});function mE(e,t){let n=$(e,"a","minimum"),s=$(t,"b","minimum");[n,s]=Rt(n,s),n.dtype==="bool"&&(n=pe(n,"int32"),s=pe(s,"int32")),bt(n.shape,s.shape);let r={a:n,b:s};return L.runKernel(io,r)}var Zl=W({minimum_:mE});function gE(e,t,n){M(n==="reflect"||n==="symmetric",()=>`Invalid mode. Mode must be either reflect or symmetric. Got ${n}.`);let s=$(e,"x","mirrorPad");if(s.rank===0)throw new Error("mirrorPad(scalar) is not defined. Pass non-scalar to mirrorPad");M(t.length===s.rank,()=>`Padding doesn't match input. Must be ${s.rank}. Got ${t.length}.`);let r=n==="reflect"?1:0;for(let i=0;i<s.rank;i++)M(t[i].length===2,()=>"Invalid number of paddings. Must be length of 2 each."),M(t[i][0]>=0&&t[i][0]<=s.shape[i]-r&&t[i][1]>=0&&t[i][1]<=s.shape[i]-r,()=>`Padding in dimension ${i} cannot be greater than or equal to ${s.shape[i]-r} or less than 0 for input of shape ${s.shape}`);let a={paddings:t,mode:n},o={x:s};return L.runKernel(lo,o,a)}var yA=W({mirrorPad_:gE});function AE(e,t){let n=$(e,"a","mod"),s=$(t,"b","mod");[n,s]=Rt(n,s);let r={a:n,b:s};return L.runKernel(ul,r)}var xA=W({mod_:AE});function yE(e){let t=$(e,"x","square"),n={};return L.runKernel("Square",{x:t},n)}var pt=W({square_:yE});function xE(e,t=null,n=!1){e=$(e,"x","moments");let s=Rs(t,e.shape),r=Dt(e,s,n),a=r.shape;n||(a=jo(r.shape,s));let o=pt(ye(pe(e,"float32"),V(r,a))),i=Dt(o,s,n);return{mean:r,variance:i}}var kh=W({moments_:xE});function bE(e,t,n,s){let r=$(t,"data","multiRNNCell"),a=bc(n,"c","multiRNNCell"),o=bc(s,"h","multiRNNCell"),i=r,l=[];for(let d=0;d<e.length;d++){let p=e[d](i,a[d],o[d]);l.push(p[0]),l.push(p[1]),i=p[1]}let u=[],c=[];for(let d=0;d<l.length;d+=2)u.push(l[d]),c.push(l[d+1]);return[u,c]}var vE=W({multiRNNCell_:bE});function wE(e,t,n,s=!1){let r=$(e,"logits","multinomial"),a=r.size,o=r.rank;if(a<2)throw new Error(`Error in multinomial: you need at least 2 outcomes, but got ${a}.`);if(o>2)throw new Error(`Rank of probabilities must be 1 or 2, but is ${o}`);n=n||Math.random();let l={logits:o===1?V(r,[1,-1]):r},u={numSamples:t,seed:n,normalized:s},c=L.runKernel(Mp,l,u);return o===1?V(c,[c.size]):c}var zb=W({multinomial_:wE});function kE(e,t){let n=$(e,"a","notEqual","string_or_numeric"),s=$(t,"b","notEqual","string_or_numeric");[n,s]=Rt(n,s),bt(n.shape,s.shape);let r={a:n,b:s};return L.runKernel(dl,r)}var qo=W({notEqual_:kE});function IE(e){let n={x:$(e,"x","onesLike")};return L.runKernel(ml,n)}var as=W({onesLike_:IE});function SE(e,t){let n=$(e,"v1","outerProduct"),s=$(t,"v2","outerProduct");M(n.rank===1&&s.rank===1,()=>`Error in outerProduct: inputs must be rank 1, but got ranks ${n.rank} and ${s.rank}.`);let r=V(n,[-1,1]),a=V(s,[1,-1]);return Ue(r,a)}var CE=W({outerProduct_:SE});function TE(e,t,n=0){let s=$(e,"x","pad");if(s.rank===0)throw new Error("pad(scalar) is not defined. Pass non-scalar to pad");let r={paddings:t,constantValue:n},a={x:s};return L.runKernel(po,a,r)}var Nr=W({pad_:TE});function NE(e,t,n=0){return M(t.length===2,()=>"Invalid number of paddings. Must be length of 2."),Nr(e,[t],n)}var EE=W({pad1d_:NE});function RE(e,t,n=0){return M(t.length===2&&t[0].length===2&&t[1].length===2,()=>"Invalid number of paddings. Must be length of 2 each."),Nr(e,t,n)}var DE=W({pad2d_:RE});function _E(e,t,n=0){return M(t.length===3&&t[0].length===2&&t[1].length===2&&t[2].length===2,()=>"Invalid number of paddings. Must be length of 2 each."),Nr(e,t,n)}var $E=W({pad3d_:_E});function FE(e,t,n=0){return M(t.length===4&&t[0].length===2&&t[1].length===2&&t[2].length===2&&t[3].length===2,()=>"Invalid number of paddings. Must be length of 2 each."),Nr(e,t,n)}var OE=W({pad4d_:FE});function PE(e,t,n){let s=$(e,"x","spaceToBatchND");M(s.rank>=1+t.length,()=>`input rank ${s.rank} should be > than [blockShape] ${t.length}`),M(n.length===t.length,()=>`paddings.shape[0] ${n.length} must be equal to [blockShape] ${t.length}`),M(s.shape.reduce((o,i,l)=>l>0&&l<=t.length?o&&(i+n[l-1][0]+n[l-1][1])%t[l-1]==0:o,!0),()=>`input spatial dimensions ${s.shape.slice(1)} with paddings ${n.toString()} must be divisible by blockShapes ${t.toString()}`);let r={x:s},a={blockShape:t,paddings:n};return L.runKernel(Tl,r,a)}var _c=W({spaceToBatchND_:PE});function ME(e,t,n,s,r,a){r==null&&(r=[1,1]),a==null&&(a=1),s===0&&(s="valid");let o=$(e,"x","maxPool"),i=o,l=!1;o.rank===3&&(l=!0,i=V(o,[1,o.shape[0],o.shape[1],o.shape[2]])),M(ar(a,r),()=>`Error in pool: Either strides or dilations must be 1. Got strides ${a} and dilations '${r}'`);let u=hb(i.shape,t,a,r,s),c=[u.dilationHeight,u.dilationWidth],d;s==="same"?d=LE([u.filterHeight,u.filterWidth],c):d=[[0,0],[0,0]];let p=c[0]===1&&c[1]===1,[h,f]=zE([u.inHeight,u.inWidth],c,d),m=p?s:"valid",g=p?i:_c(i,c,h),y=(n==="avg"?()=>Ic(g,t,a,m):()=>Rc(g,t,a,m))(),x=p?y:Sc(y,c,f);return l?V(x,[x.shape[1],x.shape[2],x.shape[3]]):x}function zE(e,t,n){let s=n.map(c=>c[0]),r=n.map(c=>c[1]),a=e.concat(s,r),o=t.map((c,d)=>(c-a[d]%c)%c),i=r.map((c,d)=>c+o[d]),l=t.map((c,d)=>[s[d],i[d]]),u=t.map((c,d)=>[0,o[d]]);return[l,u]}function LE(e,t){let s=e.map((o,i)=>o+(o-1)*(t[i]-1)).map(o=>o-1),r=s.map(o=>Math.floor(o/2)),a=s.map((o,i)=>o-r[i]);return s.map((o,i)=>[r[i],a[i]])}var Lb=W({pool_:ME});function BE(e,t){let n=$(e,"base","pow"),s=$(t,"exp","pow");[n,s]=Rt(n,s);let r={a:n,b:s};return L.runKernel(ho,r)}var Er=W({pow_:BE});function WE(e,t){let n=$(e,"x","prelu"),s=$(t,"alpha","prelu"),r={x:n,alpha:s};return L.runKernel(fo,r)}var $c=W({prelu_:WE});function VE(e,t=null,n=!1){let s=$(e,"x","prod");s.dtype==="bool"&&(s=pe(s,"int32"));let r={x:s},a={axis:t,keepDims:n};return L.runKernel(Al,r,a)}var Ih=W({prod_:VE});function UE(e,t,n){let s=zt(e),r=null;if(n==null||n==="float32")r=new Float32Array(s);else if(n==="int32")r=new Int32Array(s);else if(n==="bool")r=new Uint8Array(s);else throw new Error(`Unknown data type ${n}`);for(let a=0;a<s;a++)r[a]=t();return L.makeTensor(r,e,n)}var HE=W({rand_:UE}),bA=Da(Zx()),vA=class{constructor(e,t,n,s,r){this.mean=e,this.stdDev=t,this.dtype=n,this.nextVal=NaN,this.truncated=s,this.truncated&&(this.upper=this.mean+this.stdDev*2,this.lower=this.mean-this.stdDev*2);let a=r||Math.random();this.random=bA.alea(a.toString())}nextValue(){if(!isNaN(this.nextVal)){let s=this.nextVal;return this.nextVal=NaN,s}let e,t,n=!1;for(;!n;){let s,r,a;do s=2*this.random()-1,r=2*this.random()-1,a=s*s+r*r;while(a>=1||a===0);let o=Math.sqrt(-2*Math.log(a)/a);e=this.mean+this.stdDev*s*o,t=this.mean+this.stdDev*r*o,(!this.truncated||this.isValidTruncated(e))&&(n=!0)}return(!this.truncated||this.isValidTruncated(t))&&(this.nextVal=this.convertValue(t)),this.convertValue(e)}convertValue(e){return this.dtype==null||this.dtype==="float32"?e:Math.round(e)}isValidTruncated(e){return e<=this.upper&&e>=this.lower}},GE=class{constructor(e,t,n,s){this.alpha=e,this.beta=1/t,this.dtype=n;let r=s||Math.random();this.randu=bA.alea(r.toString()),this.randn=new vA(0,1,n,!1,this.randu()),e<1?this.d=e+2/3:this.d=e-1/3,this.c=1/Math.sqrt(9*this.d)}nextValue(){let e,t,n,s,r,a;for(;;){do s=this.randn.nextValue(),a=1+this.c*s;while(a<=0);if(a*=a*a,e=s*s,t=1-.331*e*e,n=.5*e+this.d*(1-a+Math.log(a)),r=this.randu(),r<t||Math.log(r)<n)break}return a=1/this.beta*this.d*a,this.alpha<1&&(a*=Math.pow(this.randu(),1/this.alpha)),this.convertValue(a)}convertValue(e){return this.dtype==="float32"?e:Math.round(e)}},jE=class{constructor(e=0,t=1,n,s){if(this.canReturnFloat=()=>this.dtype==null||this.dtype==="float32",this.min=e,this.range=t-e,this.dtype=n,s==null&&(s=Math.random()),typeof s=="number"&&(s=s.toString()),!this.canReturnFloat()&&this.range<=1)throw new Error(`The difference between ${e} - ${t} <= 1 and dtype is not float`);this.random=bA.alea(s)}convertValue(e){return this.canReturnFloat()?e:Math.round(e)}nextValue(){return this.convertValue(this.min+this.range*this.random())}};function qE(e,t,n=1,s="float32",r){if(n==null&&(n=1),s==null&&(s="float32"),s!=="float32"&&s!=="int32")throw new Error(`Unsupported data type ${s}`);let a=new GE(t,n,s,r),o=je(e,s);for(let i=0;i<o.values.length;i++)o.values[i]=a.nextValue();return o.toTensor()}var XE=W({randomGamma_:qE});function KE(e,t=0,n=1,s,r){if(s!=null&&s==="bool")throw new Error(`Unsupported data type ${s}`);let a=new vA(t,n,s,!1,r),o=je(e,s);for(let i=0;i<o.values.length;i++)o.values[i]=a.nextValue();return o.toTensor()}var Bb=W({randomNormal_:KE});function ZE(e,t=0,n=1,s="float32",r){let a=je(e,s),o=new jE(t,n,null,r);for(let i=0;i<a.values.length;i++)a.values[i]=o.nextValue();return a.toTensor()}var Yl=W({randomUniform_:ZE});function Jl(e,t,n=1,s="float32"){if(n===0)throw new Error("Cannot have a step of zero");let r={start:e,stop:t,step:n,dtype:s};return L.runKernel(oc,{},r)}function YE(e){let n={input:$(e,"input","real")};return L.runKernel(zp,n)}var Fc=W({real_:YE});function JE(e){let n={x:$(e,"x","reciprocal")};return L.runKernel(yl,n)}var wA=W({reciprocal_:JE});function QE(e){let n={x:$(e,"x","relu")};return L.runKernel(mo,n)}var Vs=W({relu_:QE});function eR(e){let n={x:$(e,"x","relu6")};return L.runKernel(Ao,n)}var Sh=W({relu6_:eR});function tR(e,t){let s={x:$(e,"x","reverse")},r={dims:t};return L.runKernel(yo,s,r)}var os=W({reverse_:tR});function nR(e){let t=$(e,"x","reverse");return M(t.rank===1,()=>`Error in reverse1D: x must be rank 1 but got rank ${t.rank}.`),os(t,0)}var sR=W({reverse1d_:nR});function rR(e,t){let n=$(e,"x","reverse");return M(n.rank===2,()=>`Error in reverse2D: x must be rank 2 but got rank ${n.rank}.`),os(n,t)}var aR=W({reverse2d_:rR});function oR(e,t){let n=$(e,"x","reverse");return M(n.rank===3,()=>`Error in reverse3D: x must be rank 3 but got rank ${n.rank}.`),os(n,t)}var iR=W({reverse3d_:oR});function lR(e,t){let n=$(e,"x","reverse");return M(n.rank===4,()=>`Error in reverse4D: x must be rank 4 but got rank ${n.rank}.`),os(n,t)}var uR=W({reverse4d_:lR});function cR(e){let n={x:$(e,"x","round")};return L.runKernel(xo,n)}var Ch=W({round_:cR});function dR(e){let n={x:$(e,"x","rsqrt")};return L.runKernel(bo,n)}var Th=W({rsqrt_:dR});function Ce(e,t){if((bn(e)&&t!=="string"||Array.isArray(e))&&t!=="complex64")throw new Error("Error creating a new Scalar: value must be a primitive (number|boolean|string)");if(t==="string"&&bn(e)&&!(e instanceof Uint8Array))throw new Error("When making a scalar from encoded string, the value must be `Uint8Array`.");return ra(e,[],[],t)}function pR(e){let n={x:$(e,"x","selu")};return L.runKernel(wl,n)}var Nh=W({selu_:pR});function hR(e,t,n,s,r,a=[1,1],o="NHWC"){let i=$(e,"x","separableConv2d"),l=$(t,"depthwiseFilter","separableConv2d"),u=$(n,"pointwiseFilter","separableConv2d"),c=i,d=!1;if(i.rank===3&&(d=!0,c=V(i,[1,i.shape[0],i.shape[1],i.shape[2]])),o==="NCHW")throw new Error("separableConv2d currently does not support dataFormat NCHW; only NHWC is supported");M(c.rank===4,()=>`Error in separableConv2d: input must be rank 4, but got rank ${c.rank}.`),M(l.rank===4,()=>`Error in separableConv2d: depthwise filter must be rank 4, but got rank ${l.rank}.`),M(u.rank===4,()=>`Error in separableConv2d: pointwise filter must be rank 4, but got rank ${l.rank}.`),M(u.shape[0]===1,()=>`Error in separableConv2d: the first dimension of pointwise filter must be 1, but got ${u.shape[0]}.`),M(u.shape[1]===1,()=>`Error in separableConv2d: the second dimension of pointwise filter must be 1, but got ${u.shape[1]}.`);let p=l.shape[2],h=l.shape[3];M(u.shape[2]===p*h,()=>`Error in separableConv2d: the third dimension of pointwise filter must be ${p*h}, but got ${u.shape[2]}.`);let f=jl(c,l,s,r,o,a),g=Tr(f,u,1,"valid",o);return d?V(g,[g.shape[1],g.shape[2],g.shape[3]]):g}var kA=W({separableConv2d_:hR});async function fR(e,t){let n=$(e,"x","setdiff1d"),s=$(t,"y","setdiff1d");M(n.dtype===s.dtype,()=>`x and y should have the same dtype, but got x (${n.dtype}) and y (${s.dtype}).`),M(n.rank===1,()=>`x should be 1D tensor, but got x (${n.shape}).`),M(s.rank===1,()=>`y should be 1D tensor, but got y (${s.shape}).`);let r=await n.data(),a=await s.data(),o=new Set(a),i=0;for(let c=0;c<r.length;c++)o.has(r[c])||i++;let l=new Kt([i],n.dtype),u=new Kt([i],"int32");for(let c=0,d=0;c<r.length;c++)o.has(r[c])||(l.values[d]=r[c],u.values[d]=c,d++);return[l.toTensor(),u.toTensor()]}var Wb=fR;function mR(e){let n={x:$(e,"x","sign")};return L.runKernel(Sl,n)}var IA=W({sign_:mR});function gR(e){let n={x:$(e,"x","sin")};return L.runKernel(vo,n)}var Eh=W({sin_:gR});function AR(e){let n={x:$(e,"x","sinh")};return L.runKernel(Il,n)}var Rh=W({sinh_:AR});function yR(e,t,n){let s=$(e,"x","slice1d");return M(s.rank===1,()=>`slice1d expects a rank-1 tensor, but got a rank-${s.rank} tensor`),_e(s,[t],[n])}var Dh=W({slice1d_:yR});function xR(e,t,n){let s=$(e,"x","slice2d");return M(s.rank===2,()=>`slice2d expects a rank-2 tensor, but got a rank-${s.rank} tensor`),_e(s,t,n)}var SA=W({slice2d_:xR});function bR(e,t,n){let s=$(e,"x","slice3d");return M(s.rank===3,()=>`slice3d expects a rank-3 tensor, but got a rank-${s.rank} tensor`),_e(s,t,n)}var _h=W({slice3d_:bR});function vR(e,t,n){let s=$(e,"x","slice4d");return M(s.rank===4,()=>`slice4d expects a rank-4 tensor, but got a rank-${s.rank} tensor`),_e(s,t,n)}var Oc=W({slice4d_:vR});function wR(e,t=-1){let n=$(e,"logits","softmax","float32");if(t===-1&&(t=n.rank-1),t!==n.rank-1)throw Error(`Softmax along a non-last dimension is not yet supported. Logits was rank ${n.rank} and dim was ${t}`);let s={logits:n},r={dim:t};return L.runKernel(So,s,r)}var Pc=W({softmax_:wR});function kR(e){M(e.dtype==="complex64",()=>`The dtype for tf.spectral.fft() must be complex64 but got ${e.dtype}.`);let t={input:e};return L.runKernel(Ep,t)}var Mc=W({fft_:kR});function IR(e){M(e.dtype==="complex64",()=>`The dtype for tf.spectral.ifft() must be complex64 but got ${e.dtype}.`);let t={input:e};return L.runKernel(Rp,t)}var Ql=W({ifft_:IR});function SR(e){let t=e.shape[e.shape.length-1],n=e.size/t,s;if(t<=2){let r=V(e,[n,t]);s=Ql(r)}else{let r=[n,2*(t-1)],a=V(Fc(e),[n,t]),o=V(yh(e),[n,t]),i=os(_e(a,[0,1],[n,t-2]),1),l=z(os(_e(o,[0,1],[n,t-2]),1),Ce(-1)),u=ft([a,i],1),c=ft([o,l],1),d=V(sa(u,c),[r[0],r[1]]);s=Ql(d)}if(s=Fc(s),e.rank===3&&e.shape[0]!==0){let r=s,a=e.shape[0];s=V(s,[a,s.shape[0]/a,s.shape[1]]),r.dispose()}return s}var $h=W({irfft_:SR});function CR(e,t,n=0){let r={x:$(e,"x","split")},a={numOrSizeSplits:t,axis:n};return L.runKernel(Nl,r,a)}var Vt=W({split_:CR});function TR(e,t){M(e.dtype==="float32",()=>`The dtype for rfft() must be real value but got ${e.dtype}`);let n=e.shape[e.shape.length-1],s=e.size/n,r;if(t!=null&&t<n){let f=e.shape.map(g=>0),m=e.shape.map(g=>g);m[e.shape.length-1]=t,r=_e(e,f,m),n=t}else if(t!=null&&t>n){let f=e.shape.map(m=>m);f[e.shape.length-1]=t-n,r=ft([e,Mt(f)],e.shape.length-1),n=t}else r=e;let a=Je(r),o=V(sa(r,a),[s,n]),i=Mc(o),l=Math.floor(n/2)+1,u=Fc(i),c=yh(i),d=Vt(u,[l,n-l],u.shape.length-1),p=Vt(c,[l,n-l],c.shape.length-1),h=r.shape.slice();return h[r.shape.length-1]=l,V(sa(d[0],p[0]),h)}var zc=W({rfft_:TR});function NR(e){let n={x:$(e,"x","sqrt")};return L.runKernel(ko,n)}var fn=W({sqrt_:NR});function ER(e,t){let n=$(e,"a","squaredDifference"),s=$(t,"b","squaredDifference");[n,s]=Rt(n,s),bt(n.shape,s.shape);let r={a:n,b:s},a={};return L.runKernel(Co,r,a)}var Fh=W({squaredDifference_:ER});function RR(e,t){let n=$(e,"x","squeeze");return V(n,e5(n.shape,t).newShape)}var lt=W({squeeze_:RR});function DR(e,t=0){let n=bc(e,"tensors","stack","string_or_numeric");M(n.length>=1,()=>"Pass at least one tensor to tf.stack"),n.length>0&&M(t<=n[0].rank,()=>"Axis must be <= rank of the tensor");let s=n,r={axis:t};return L.runKernel(gl,s,r)}var mn=W({stack_:DR});function _R(e,t=0){let s={x:$(e,"x","step")},r={alpha:t};return L.runKernel(ea,s,r)}var eu=W({step_:_R});function $R(e,t,n,s,r=0,a=0,o=0,i=0,l=0){let c={x:$(e,"x","stridedSlice","string_or_numeric")},d={begin:t,end:n,strides:s,beginMask:r,endMask:a,ellipsisMask:o,newAxisMask:i,shrinkAxisMask:l};return L.runKernel(El,c,d)}var CA=W({stridedSlice_:$R});function FR(e){let n={x:$(e,"x","tan")};return L.runKernel(No,n)}var TA=W({tan_:FR});function Ut(e,t){_a(e);let n=rr(e,t);if(n.length!==1)throw new Error("tensor1d() requires values to be a flat/TypedArray");return ra(e,null,n,t)}function Us(e,t,n){if(_a(e),t!=null&&t.length!==2)throw new Error("tensor2d() requires shape to have two numbers");let s=rr(e,n);if(s.length!==2&&s.length!==1)throw new Error("tensor2d() requires values to be number[][] or flat/TypedArray");if(s.length===1&&t==null)throw new Error("tensor2d() requires shape to be provided when `values` are a flat/TypedArray");return ra(e,t,s,n)}function OR(e,t,n){if(_a(e),t!=null&&t.length!==4)throw new Error("tensor4d() requires shape to have four numbers");let s=rr(e,n);if(s.length!==4&&s.length!==1)throw new Error("tensor4d() requires values to be number[][][][] or flat/TypedArray");if(s.length===1&&t==null)throw new Error("tensor4d() requires shape to be provided when `values` are a flat array");return ra(e,t,s,n)}function PR(e,t,n){if(_a(e),t!=null&&t.length!==5)throw new Error("tensor5d() requires shape to have five numbers");let s=rr(e,n);if(s.length!==5&&s.length!==1)throw new Error("tensor5d() requires values to be number[][][][][] or flat/TypedArray");if(s.length===1&&t==null)throw new Error("tensor5d() requires shape to be provided when `values` are a flat array");return ra(e,t,s,n)}function MR(e,t,n){if(_a(e),t!=null&&t.length!==6)throw new Error("tensor6d() requires shape to have six numbers");let s=rr(e,n);if(s.length!==6&&s.length!==1)throw new Error("tensor6d() requires values to be number[][][][][][] or flat/TypedArray");if(s.length===1&&t==null)throw new Error("tensor6d() requires shape to be provided when `values` are a flat array");return t=t||s,ra(e,t,s,n)}function zR(e,t=1,n=!0){let s=$(e,"x","topk");if(s.rank===0)throw new Error("topk() expects the input to be of rank 1 or higher");let r=s.shape[s.shape.length-1];if(t<0)throw new Error(`'k' passed to topk() must be >= 0 but got ${t}`);if(t>r)throw new Error(`'k' passed to topk() must be <= the last dimension (${r}) but got ${t}`);let a={x:s},o={k:t,sorted:n},[i,l]=L.runKernel(Rl,a,o);return{values:i,indices:l}}var NA=W({topk_:zR});function LR(e,t=0,n=1,s,r){if(s!=null&&s==="bool")throw new Error("Unsupported data type $ { dtype }");let a=new vA(t,n,s,!0,r),o=je(e,s);for(let i=0;i<o.values.length;i++)o.values[i]=a.nextValue();return o.toTensor()}var Oh=W({truncatedNormal_:LR});function BR(e,t=0){let n=$(e,"x","unique","string_or_numeric");M(n.rank>0,()=>"The input tensor must be at least 1D");let s={x:n},r={axis:t},[a,o]=L.runKernel(Kp,s,r);return{values:a,indices:o}}var Ph=W({unique_:BR});function WR(e,t,n){let s=$(e,"x","unsortedSegmentSum"),r=$(t,"segmentIds","unsortedSegmentSum","int32");M(sn(n),()=>"numSegments must be of dtype int");let a={x:s,segmentIds:r},o={numSegments:n};return L.runKernel(uc,a,o)}var EA=W({unsortedSegmentSum_:WR});function VR(e,t=0){let n=$(e,"x","unstack","string_or_numeric");M(t>=-n.shape.length&&t<n.shape.length,()=>`Axis = ${t} is not in [-${n.shape.length}, ${n.shape.length})`);let s={value:n},r={axis:t};return L.runKernel(_l,s,r)}var is=W({unstack_:VR});function Vb(e,t=!0,n,s){return L.makeVariable(e,t,n,s)}function Ub(e,t){let n=[];for(let a=0;a<t.length;a++)t[a]&&n.push(a);let s=je(e,"int32"),r=je([n.length,e.length],"int32");for(let a=0;a<n.length;a++){let o=s.indexToLoc(n[a]),i=a*e.length;r.values.set(o,i)}return r.toTensor()}async function UR(e){let t=$(e,"condition","whereAsync","bool"),n=await t.data(),s=Ub(t.shape,n);return e!==t&&t.dispose(),s}var RA=UR;async function HR(e,t,n){let s=$(e,"tensor","boolMask"),r=$(t,"mask","boolMask","bool"),a=n==null?0:n,o=r.rank,i=s.shape;M(o>0,()=>"mask cannot be scalar"),In(i.slice(a,a+o),r.shape,"mask's shape must match the first K dimensions of tensor's shape,");let l=1;for(let m=a;m<a+o;m++)l*=i[m];let u=i.slice(0,a).concat([l],i.slice(a+o)),c=V(s,u),d=V(r,[-1]),p=await RA(d),h=lt(p,[1]),f=Ho(c,h,a);return e!==s&&s.dispose(),t!==r&&r.dispose(),h.dispose(),c.dispose(),d.dispose(),p.dispose(),f}var GR=HR;function jR(e,t="euclidean",n=null,s=!1){e=$(e,"x","norm");let r=Hb(e,t,n),a=r.shape;if(s){let o=Rs(n,e.shape);a=jo(r.shape,o)}return V(r,a)}function Hb(e,t,n=null){if(e.rank===0)return Wt(e);if(e.rank!==1&&n===null)return Hb(V(e,[-1]),t,n);if(e.rank===1||typeof n=="number"||Array.isArray(n)&&n.length===1){if(t===1)return we(Wt(e),n);if(t===1/0)return ss(Wt(e),n);if(t===-1/0)return Dc(Wt(e),n);if(t==="euclidean"||t===2)return fn(we(Er(Wt(e),Ce(2,"int32")),n));throw new Error(`Error in norm: invalid ord value: ${t}`)}if(Array.isArray(n)&&n.length===2){if(t===1)return ss(we(Wt(e),n[0]),n[1]-1);if(t===1/0)return ss(we(Wt(e),n[1]),n[0]);if(t===-1/0)return Dc(we(Wt(e),n[1]),n[0]);if(t==="fro"||t==="euclidean")return fn(we(pt(e),n));throw new Error(`Error in norm: invalid ord value: ${t}`)}throw new Error(`Error in norm: invalid axis: ${n}`)}var Mh=W({norm_:jR});function qR(e,t,n,s,r=!0){let a=$(e,"v","movingAverage"),o=$(t,"x","movingAverage"),i=$(n,"decay","movingAverage");v5(a,o),M(Ir(a.shape,o.shape),()=>"Shape mismatch in v and x");let l=Ce(1),u=ye(l,i),c=z(ye(o,a),u);if(r){M(s!=null,()=>"When using zeroDebias: true, step is required.");let d=$(s,"step","movingAverage");c=he(c,ye(l,Er(i,d)))}return oe(a,c)}var XR=W({movingAverage_:qR});function KR(e,t,n){let s=$(e,"indices","scatterND","int32"),r=$(t,"updates","scatterND");Lg(r,s,n);let a={indices:s,updates:r},o={shape:n};return L.runKernel(bl,a,o)}var Gb=W({scatterND_:KR});function ZR(e,t,n,s){if(e.dtype!=="int32")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}.`);let r=e.rank>0?e.shape[0]:1,a=e.rank>1?e.shape[1]:1;if(n.length!==a)throw new Error(`outputShape has incorrect number of elements:, ${n.length}, should be: ${a}.`);let o=t.size;if(!(t.rank===0||t.rank===1&&o===r))throw new Error(`sparseValues has incorrect shape ${t.shape}, should be [] or [${r}]`);if(t.dtype!==s.dtype)throw new Error("sparseValues.dtype must match defaultValues.dtype")}function YR(e,t,n,s=0){let r=$(e,"sparseIndices","sparseToDense","int32"),a=$(t,"sparseValues","sparseToDense"),o=$(s,"defaultValue","sparseToDense",a.dtype);ZR(r,a,n,o);let i={sparseIndices:r,sparseValues:a,defaultValue:o},l={outputShape:n};return L.runKernel(Gp,i,l)}var DA=W({sparseToDense_:YR});function JR(e,t){let n=$(t,"indices","gatherND","int32"),r={params:$(e,"x","gatherND","string_or_numeric"),indices:n};return L.runKernel(el,r)}var jb=W({gatherND_:JR});function QR(e,t){if(t==null)return e.shape.slice();if(Ir(e.shape,t))return t;if(e.shape.length===t.length){let n=[];for(let s=0;s<e.shape.length;s++)t[s]==null&&e.shape[s]!=null?n.push(e.shape[s]):n.push(t[s]);return n}return t}function eD(e,t,n,s){let r=$(e,"x","dropout");if(M(r.dtype==="float32",()=>`x has to be a floating point tensor since it's going to be scaled, but got a ${r.dtype} tensor instead.`),M(t>=0&&t<1,()=>`rate must be a float in the range [0, 1), but got ${t}.`),t===0)return e instanceof Ge?r.clone():r;let a=QR(r,n),o=1-t,i=he(Kl(oe(Yl(a,0,1,"float32",s),o)),o);return z(r,i)}var qb=W({dropout_:eD});function Xb(e){return Math.floor(Math.pow(2,Math.ceil(Math.log(e)/Math.log(2))))}function _A(e,t,n){let s=1-e%2,r=new Float32Array(e);for(let a=0;a<e;++a){let o=2*Math.PI*a/(e+s-1);r[a]=t-n*Math.cos(o)}return Ut(r,"float32")}async function tD(e,t,n=1){let s=$(e,"predictions","inTopK"),r=$(t,"targets","inTopK");M(s.rank>1,()=>`inTopK() expects the predictions to be of rank 2 or higher, but got ${s.rank}`),M(s.rank-1===r.rank,()=>`predictions rank should be 1 larger than targets rank, but got predictions rank ${s.rank} and targets rank ${r.rank}`),In(s.shape.slice(0,s.shape.length-1),r.shape,"predictions's shape should be align with the targets' shape, except the last dimension.");let a=s.shape[s.shape.length-1];M(n>0&&n<=a,()=>`'k' passed to inTopK() must be > 0 && <= the predictions last dimension (${a}), but got ${n}`);let o=await s.data(),i=await r.data(),[l,u]=[o.length/a,a],c=t5("bool",l);for(let d=0;d<l;d++){let p=d*u,h=o.subarray(p,p+u),f=[];for(let m=0;m<h.length;m++)f.push({value:h[m],index:m});f.sort((m,g)=>g.value-m.value),c[d]=0;for(let m=0;m<n;m++)if(f[m].index===i[d]){c[d]=1;break}}return e!==s&&s.dispose(),t!==r&&r.dispose(),an(c,r.shape,"bool")}var nD=tD,da={};Le(da,{conv2d:()=>aD,depthwiseConv2d:()=>uD,matMul:()=>dD});function sD(e,t,n,s,r,a="NHWC",o){let i=e;e.rank===3&&(i=V(e,[1,e.shape[0],e.shape[1],e.shape[2]]));let l=t;l.rank===3&&(l=V(t,[1,t.shape[0],t.shape[1],t.shape[2]])),M(i.rank===4,()=>`Error in conv2dDerFilter: input must be rank 4, but got shape ${i.shape}.`),M(l.rank===4,()=>`Error in conv2dDerFilter: dy must be rank 4, but got shape ${l.shape}.`),M(n.length===4,()=>`Error in conv2dDerFilter: filterShape must be length 4, but got ${n}.`);let u=a==="NHWC"?i.shape[3]:i.shape[1],c=a==="NHWC"?l.shape[3]:l.shape[1];M(u===n[2],()=>`Error in conv2dDerFilter: depth of input ${u}) must match input depth in filter (${n[2]}.`),M(c===n[3],()=>`Error in conv2dDerFilter: depth of dy (${c}) must match output depth for filter (${n[3]}).`),o!=null&&M(sn(r),()=>`Error in conv2dDerFilter: pad must be an integer when using, dimRoundingMode ${o} but got pad ${r}.`);let d={x:i,dy:l},p={strides:s,pad:r,dataFormat:a,dimRoundingMode:o,filterShape:n};return L.runKernel(yp,d,p)}var $A=W({conv2DBackpropFilter_:sD});function zh(e,t,n){if(n==null||n==="linear")return e;if(n==="relu")return z(e,eu(t));throw new Error(`Cannot compute gradient for fused activation ${n}.`)}function Lh(e,t){let n=t,s=Zt(e.shape,t.shape);return s.length>0&&(n=we(n,s)),V(n,e.shape)}function Bh(e,t,n,s){if(t==="linear")return e;if(t==="relu")return Vs(e);if(t==="elu")return ql(e);if(t==="relu6")return Sh(e);if(t==="prelu")return $c(e,n);if(t==="leakyrelu")return Tc(e,s);if(t==="sigmoid")return Bn(e);throw new Error(`Unknown fused activation ${t}.`)}var Wh=(e,t)=>!(e>0)||t==="linear";function rD({x:e,filter:t,strides:n,pad:s,dataFormat:r="NHWC",dilations:a=[1,1],dimRoundingMode:o,bias:i,activation:l="linear",preluActivationWeights:u,leakyreluAlpha:c}){if(l=l||"linear",Wh(L.state.gradientDepth,l)===!1){let v=Tr(e,t,n,s,r,a,o);return i!=null&&(v=oe(v,i)),Bh(v,l,u,c)}let d=$(e,"x","conv2d"),p=$(t,"filter","conv2d"),h=d,f=!1;d.rank===3&&(f=!0,h=V(d,[1,d.shape[0],d.shape[1],d.shape[2]])),M(h.rank===4,()=>`Error in fused conv2d: input must be rank 4, but got rank ${h.rank}.`),M(p.rank===4,()=>`Error in fused conv2d: filter must be rank 4, but got rank ${p.rank}.`),o!=null&&M(sn(s),()=>`Error in fused conv2d: pad must be an integer when using, dimRoundingMode ${o} but got pad ${s}.`),M(h.shape[3]===p.shape[2],()=>`Error in conv2d: depth of input (${h.shape[3]}) must match input depth for filter ${p.shape[2]}.`),M(ar(n,a),()=>`Error in conv2D: Either strides or dilations must be 1. Got strides ${n} and dilations '${a}'`),M(r==="NHWC",()=>`Error in conv2d: got dataFormat of ${r} but only NHWC is currently supported.`);let m=kc(h.shape,p.shape,n,a,s,o),g;i!=null&&(g=$(i,"bias","fused conv2d"),[g]=Rt(g,d),bt(m.outShape,g.shape));let A;u!=null&&(A=$(u,"prelu weights","fused conv2d"));let y=(v,k)=>{let[S,C,D,O]=k,E=zh(v,D,l);M(la(a),()=>`Error in gradient of fused conv2D: dilation rates greater than 1 are not yet supported in gradients. Got dilations '${a}'`);let R=rA(C.shape,E,S,n,s),T=$A(C,E,S.shape,n,s),P=[R,T];if(O!=null){let U=Lh(O,E);P.push(U)}return P},x={x:h,filter:p,bias:g,preluActivationWeights:A},b={strides:n,pad:s,dataFormat:r,dilations:a,dimRoundingMode:o,activation:l,leakyreluAlpha:c};return i==null?or((k,S,C)=>{let D=L.runKernel(_o,x,b);return C([S,k,D]),f&&(D=V(D,[D.shape[1],D.shape[2],D.shape[3]])),{value:D,gradFunc:y}})(h,p):or((k,S,C,D)=>{let O=L.runKernel(_o,x,b);return D([S,k,O,C]),f&&(O=V(O,[O.shape[1],O.shape[2],O.shape[3]])),{value:O,gradFunc:y}})(h,p,g)}var aD=W({fusedConv2d_:rD});function oD(e,t,n,s,r,a=[1,1],o){let i=e;e.rank===3&&(i=V(e,[1,e.shape[0],e.shape[1],e.shape[2]]));let l=t;l.rank===3&&(l=V(t,[1,t.shape[0],t.shape[1],t.shape[2]]));let u={x:i,dy:l},c={strides:s,pad:r,dimRoundingMode:o,dilations:a,filterShape:n};return L.runKernel(wp,u,c)}var Kb=W({depthwiseConv2dNativeBackpropFilter_:oD});function iD(e,t,n,s,r,a=[1,1],o){let i=t,l=!1;t.rank===3&&(l=!0,i=V(t,[1,t.shape[0],t.shape[1],t.shape[2]]));let u={dy:i,filter:n},c={strides:s,pad:r,dimRoundingMode:o,dilations:a,inputShape:e},d=L.runKernel(kp,u,c);return l?V(d,[d.shape[1],d.shape[2],d.shape[3]]):d}var Zb=W({depthwiseConv2dNativeBackpropInput_:iD});function lD({x:e,filter:t,strides:n,pad:s,dataFormat:r="NHWC",dilations:a=[1,1],dimRoundingMode:o,bias:i,activation:l="linear",preluActivationWeights:u,leakyreluAlpha:c}){if(Wh(L.state.gradientDepth,l)===!1){let v=jl(e,t,n,s,r,a,o);return i!=null&&(v=oe(v,i)),Bh(v,l,u,c)}let d=$(e,"x","depthwiseConv2d"),p=$(t,"filter","depthwiseConv2d"),h=d,f=!1;d.rank===3&&(f=!0,h=V(d,[1,d.shape[0],d.shape[1],d.shape[2]])),M(h.rank===4,()=>`Error in fused depthwiseConv2d: input must be rank 4, but got rank ${h.rank}.`),M(p.rank===4,()=>`Error in fused depthwiseConv2d: filter must be rank 4, but got rank ${p.rank}.`),M(h.shape[3]===p.shape[2],()=>`Error in fused depthwiseConv2d: number of input channels (${h.shape[3]}) must match the inChannels dimension in filter ${p.shape[2]}.`),a==null&&(a=[1,1]),M(ar(n,a),()=>`Error in fused depthwiseConv2d: Either strides or dilations must be 1. Got strides ${n} and dilations '${a}'`),o!=null&&M(sn(s),()=>`Error in fused depthwiseConv2d: pad must be an integer when using dimRoundingMode ${o} but got pad ${s}.`);let m=kc(h.shape,p.shape,n,a,s,o,!0),g;i!=null&&(g=$(i,"bias","fused conv2d"),[g]=Rt(g,d),bt(m.outShape,g.shape));let A;u!=null&&(A=$(u,"prelu weights","fused depthwiseConv2d"));let y=(v,k)=>{M(la(a),()=>`Error in gradient of fused depthwiseConv2d: dilation rates greater than 1 are not yet supported. Got dilations '${a}'`);let[S,C,D,O]=k,E=zh(v,D,l),R=Zb(C.shape,E,S,n,s,a,o),T=Kb(C,E,S.shape,n,s,a,o);if(O!=null){let P=Lh(g,E);return[R,T,P]}return[R,T]},x={x:h,filter:p,bias:g,preluActivationWeights:A},b={strides:n,pad:s,dataFormat:r,dilations:a,dimRoundingMode:o,activation:l,leakyreluAlpha:c};return i==null?or((k,S,C)=>{let D=L.runKernel($o,x,b);return C([S,k,D]),f&&(D=V(D,[D.shape[1],D.shape[2],D.shape[3]])),{value:D,gradFunc:y}})(h,p):or((k,S,C,D)=>{let O=L.runKernel($o,x,b);return D([S,k,O,C]),f&&(O=V(O,[O.shape[1],O.shape[2],O.shape[3]])),{value:O,gradFunc:y}})(h,p,g)}var uD=W({fusedDepthwiseConv2d_:lD});function cD({a:e,b:t,transposeA:n=!1,transposeB:s=!1,bias:r,activation:a="linear",preluActivationWeights:o,leakyreluAlpha:i}){if(Wh(L.state.gradientDepth,a)===!1){let O=Ue(e,t,n,s);return r!=null&&(O=oe(O,r)),Bh(O,a,o,i)}let l=$(e,"a","fused matMul"),u=$(t,"b","fused matMul");[l,u]=Rt(l,u);let c=n?l.shape[l.rank-2]:l.shape[l.rank-1],d=s?u.shape[u.rank-1]:u.shape[u.rank-2],p=n?l.shape[l.rank-1]:l.shape[l.rank-2],h=s?u.shape[u.rank-2]:u.shape[u.rank-1],f=l.shape.slice(0,-2),m=u.shape.slice(0,-2),g=zt(f),A=zt(m);M(l.rank>=2&&u.rank>=2&&l.rank===u.rank,()=>`Error in fused matMul: inputs must have the same rank of at least 2, got ranks ${l.rank} and ${u.rank}.`),M(Ir(f,m),()=>`Error in fused matMul: outer dimensions (${f}) and (${m}) of Tensors with shapes ${l.shape} and ${u.shape} must match.`),M(c===d,()=>`Error in fused matMul: inner shapes (${c}) and (${d}) of Tensors with shapes ${l.shape} and ${u.shape} and transposeA=${n} and transposeB=${s} must match.`);let y=l.shape.slice(0,-2).concat([p,h]),x=n?V(l,[g,c,p]):V(l,[g,p,c]),b=s?V(u,[A,h,d]):V(u,[A,d,h]),v;r!=null&&(v=$(r,"bias","fused matMul"),[v]=Rt(v,l),bt(y,v.shape));let k;o!=null&&(k=$(o,"prelu weights","fused matMul"));let S=(O,E)=>{let[R,T,P,U]=E,j=zh(V(O,P.shape),P,a),q,X;if(!n&&!s?(q=Ue(j,T,!1,!0),X=Ue(R,j,!0,!1)):!n&&s?(q=Ue(j,T,!1,!1),X=Ue(j,R,!0,!1)):n&&!s?(q=Ue(T,j,!1,!0),X=Ue(R,j,!1,!1)):(q=Ue(T,j,!0,!0),X=Ue(j,R,!0,!0)),r!=null){let te=Lh(U,j);return[q,X,te]}else return[q,X]},C={a:x,b,bias:v,preluActivationWeights:k},D={transposeA:n,transposeB:s,activation:a,leakyreluAlpha:i};return r==null?or((E,R,T)=>{let P=L.runKernel(Do,C,D);return T([E,R,P]),{value:V(P,y),gradFunc:S}})(x,b):or((E,R,T,P)=>{let U=L.runKernel(Do,C,D);return P([E,R,U,T]),{value:V(U,y),gradFunc:S}})(x,b,v)}var dD=W({fusedMatMul_:cD});function pD(e){return _A(e,.54,.46)}var hD=W({hammingWindow_:pD});function fD(e){return _A(e,.5,.5)}var Yb=W({hannWindow_:fD});function mD(e,t,n,s=!1,r=0){let a=0,o=[];for(;a+t<=e.size;)o.push(_e(e,a,t)),a+=n;if(s)for(;a<e.size;){let i=a+t-e.size,l=ft([_e(e,a,t-i),Xl([i],r)]);o.push(l),a+=n}return o.length===0?Us([],[0,t]):V(ft(o),[o.length,t])}var Jb=W({frame_:mD});function gD(e,t,n,s,r=Yb){s==null&&(s=Xb(t));let a=Jb(e,t,n),o=z(a,r(t));return zc(o,s)}var AD=W({stft_:gD});function yD(e,t,n,s,r="bilinear",a=0){let o=$(e,"image","cropAndResize"),i=$(t,"boxes","cropAndResize","float32"),l=$(n,"boxInd","cropAndResize","int32"),u=i.shape[0];M(o.rank===4,()=>`Error in cropAndResize: image must be rank 4,but got rank ${o.rank}.`),M(i.rank===2&&i.shape[1]===4,()=>`Error in cropAndResize: boxes must be have size [${u},4] but had shape ${i.shape}.`),M(l.rank===1&&l.shape[0]===u,()=>`Error in cropAndResize: boxInd must be have size [${u}] but had shape ${i.shape}.`),M(s.length===2,()=>`Error in cropAndResize: cropSize must be of length 2, but got length ${s.length}.`),M(s[0]>=1&&s[1]>=1,()=>`cropSize must be atleast [1,1], but was ${s}`),M(r==="bilinear"||r==="nearest",()=>`method must be bilinear or nearest, but was ${r}`);let c={image:o,boxes:i,boxInd:l},d={method:r,extrapolationValue:a,cropSize:s};return L.runKernel(ji,c,d)}var xD=W({cropAndResize_:yD});function bD(e){let t=$(e,"image","flipLeftRight","float32");M(t.rank===4,()=>`Error in flipLeftRight: image must be rank 4,but got rank ${t.rank}.`);let n={image:t};return L.runKernel(Ji,n,{})}var vD=W({flipLeftRight_:bD});function wD(e){let t=$(e,"image","grayscaleToRGB"),n=t.rank-1,s=t.shape[n];M(t.rank>=2,()=>`Error in grayscaleToRGB: images must be at least rank 2, but got rank ${t.rank}.`),M(s===1,()=>`Error in grayscaleToRGB: last dimension of a grayscale image should be size 1, but got size ${s}.`);let r=new Array(t.rank);return r.fill(1,0,n),r[n]=3,bs(t,r)}var kD=W({grayscaleToRGB_:wD});function ID(e,t,n=0,s=.5){let r=$(e,"image","rotateWithOffset","float32");M(r.rank===4,()=>`Error in rotateWithOffset: image must be rank 4,but got rank ${r.rank}.`);let a={image:r},o={radians:t,fillValue:n,center:s};return L.runKernel(Fl,a,o)}var SD=W({rotateWithOffset_:ID});function tu(e,t,n,s,r,a){s==null&&(s=.5),r==null&&(r=Number.NEGATIVE_INFINITY),a==null&&(a=0);let o=e.shape[0];return n=Math.min(n,o),M(0<=s&&s<=1,()=>`iouThreshold must be in [0, 1], but was '${s}'`),M(e.rank===2,()=>`boxes must be a 2D tensor, but was of rank '${e.rank}'`),M(e.shape[1]===4,()=>`boxes must have 4 columns, but 2nd dimension was ${e.shape[1]}`),M(t.rank===1,()=>"scores must be a 1D tensor"),M(t.shape[0]===o,()=>`scores has incompatible shape with boxes. Expected ${o}, but was ${t.shape[0]}`),M(0<=a&&a<=1,()=>`softNmsSigma must be in [0, 1], but was '${a}'`),{maxOutputSize:n,iouThreshold:s,scoreThreshold:r,softNmsSigma:a}}function CD(e,t,n,s=.5,r=Number.NEGATIVE_INFINITY){let a=$(e,"boxes","nonMaxSuppression"),o=$(t,"scores","nonMaxSuppression"),i=tu(a,o,n,s,r);n=i.maxOutputSize,s=i.iouThreshold,r=i.scoreThreshold;let l={maxOutputSize:n,iouThreshold:s,scoreThreshold:r};return L.runKernel(pl,{boxes:a,scores:o},l)}var TD=W({nonMaxSuppression_:CD});function ND(e,t,n){let s=ED(e,t,n),r=s<0?-(s+1):s;e.splice(r,0,t)}function ED(e,t,n){return DD(e,t,n||RD)}function RD(e,t){return e>t?1:e<t?-1:0}function DD(e,t,n){let s=0,r=e.length,a=0,o=!1;for(;s<r;){a=s+(r-s>>>1);let i=n(t,e[a]);i>0?s=a+1:(r=a,o=!i)}return o?s:-s-1}function Qb(e,t,n,s,r){return FA(e,t,n,s,r,0)}function e3(e,t,n,s,r,a){return FA(e,t,n,s,r,0,!1,a,!0)}function t3(e,t,n,s,r,a){return FA(e,t,n,s,r,a,!0)}function FA(e,t,n,s,r,a,o=!1,i=!1,l=!1){let u=[];for(let g=0;g<t.length;g++)t[g]>r&&u.push({score:t[g],boxIndex:g,suppressBeginIndex:0});u.sort(n3);let c=a>0?-.5/a:0,d=[],p=[];for(;d.length<n&&u.length>0;){let g=u.pop(),{score:A,boxIndex:y,suppressBeginIndex:x}=g;if(A<r)break;let b=!1;for(let v=d.length-1;v>=x;--v){let k=_D(e,y,d[v]);if(k>=s){b=!0;break}if(g.score=g.score*$D(s,c,k),g.score<=r)break}g.suppressBeginIndex=d.length,b||(g.score===A?(d.push(y),p.push(g.score)):g.score>r&&ND(u,g,n3))}let h=d.length,f=n-h;i&&f>0&&(d.push(...new Array(f).fill(0)),p.push(...new Array(f).fill(0)));let m={selectedIndices:d};return o&&(m.selectedScores=p),l&&(m.validOutputs=h),m}function _D(e,t,n){let s=e.subarray(t*4,t*4+4),r=e.subarray(n*4,n*4+4),a=Math.min(s[0],s[2]),o=Math.min(s[1],s[3]),i=Math.max(s[0],s[2]),l=Math.max(s[1],s[3]),u=Math.min(r[0],r[2]),c=Math.min(r[1],r[3]),d=Math.max(r[0],r[2]),p=Math.max(r[1],r[3]),h=(i-a)*(l-o),f=(d-u)*(p-c);if(h<=0||f<=0)return 0;let m=Math.max(a,u),g=Math.max(o,c),A=Math.min(i,d),y=Math.min(l,p),x=Math.max(A-m,0)*Math.max(y-g,0);return x/(h+f-x)}function $D(e,t,n){let s=Math.exp(t*n*n);return n<=e?s:0}function n3(e,t){return e.score-t.score||e.score===t.score&&t.boxIndex-e.boxIndex}async function FD(e,t,n,s=.5,r=Number.NEGATIVE_INFINITY){let a=$(e,"boxes","nonMaxSuppressionAsync"),o=$(t,"scores","nonMaxSuppressionAsync"),i=tu(a,o,n,s,r);n=i.maxOutputSize,s=i.iouThreshold,r=i.scoreThreshold;let l=await Promise.all([a.data(),o.data()]),u=l[0],c=l[1],{selectedIndices:d}=Qb(u,c,n,s,r);return a!==e&&a.dispose(),o!==t&&o.dispose(),Ut(d,"int32")}var OD=FD;function PD(e,t,n,s=.5,r=Number.NEGATIVE_INFINITY,a=0){let o=$(e,"boxes","nonMaxSuppression"),i=$(t,"scores","nonMaxSuppression"),l=tu(o,i,n,s,r,a);n=l.maxOutputSize,s=l.iouThreshold,r=l.scoreThreshold,a=l.softNmsSigma;let u={boxes:o,scores:i},c={maxOutputSize:n,iouThreshold:s,scoreThreshold:r,softNmsSigma:a},d=L.runKernel(fl,u,c);return{selectedIndices:d[0],selectedScores:d[1]}}var MD=W({nonMaxSuppressionWithScore_:PD});async function zD(e,t,n,s=.5,r=Number.NEGATIVE_INFINITY,a=0){let o=$(e,"boxes","nonMaxSuppressionAsync"),i=$(t,"scores","nonMaxSuppressionAsync"),l=tu(o,i,n,s,r,a);n=l.maxOutputSize,s=l.iouThreshold,r=l.scoreThreshold,a=l.softNmsSigma;let u=await Promise.all([o.data(),i.data()]),c=u[0],d=u[1],{selectedIndices:p,selectedScores:h}=t3(c,d,n,s,r,a);return o!==e&&o.dispose(),i!==t&&i.dispose(),{selectedIndices:Ut(p,"int32"),selectedScores:Ut(h)}}var LD=zD;function BD(e,t,n,s=.5,r=Number.NEGATIVE_INFINITY,a=!1){let o=$(e,"boxes","nonMaxSuppression"),i=$(t,"scores","nonMaxSuppression"),l=tu(o,i,n,s,r,null),u=l.maxOutputSize,c=l.iouThreshold,d=l.scoreThreshold,p={boxes:o,scores:i},h={maxOutputSize:u,iouThreshold:c,scoreThreshold:d,padToMaxOutputSize:a},f=L.runKernel(hl,p,h);return{selectedIndices:f[0],validOutputs:f[1]}}var WD=W({nonMaxSuppressionPadded_:BD});async function VD(e,t,n,s=.5,r=Number.NEGATIVE_INFINITY,a=!1){let o=$(e,"boxes","nonMaxSuppressionAsync"),i=$(t,"scores","nonMaxSuppressionAsync"),l=tu(o,i,n,s,r,null),u=l.maxOutputSize,c=l.iouThreshold,d=l.scoreThreshold,[p,h]=await Promise.all([o.data(),i.data()]),{selectedIndices:f,validOutputs:m}=e3(p,h,u,c,d,a);return o!==e&&o.dispose(),i!==t&&i.dispose(),{selectedIndices:Ut(f,"int32"),validOutputs:Ce(m,"int32")}}var UD=VD;function HD(e,t,n=!1,s=!1){let r=$(e,"images","resizeBilinear");M(r.rank===3||r.rank===4,()=>`Error in resizeBilinear: x must be rank 3 or 4, but got rank ${r.rank}.`),M(t.length===2,()=>`Error in resizeBilinear: new shape must 2D, but got shape ${t}.`),M(s===!1||n===!1,()=>"Error in resizeBilinear: If halfPixelCenters is true, alignCorners must be false.");let a=r,o=!1;r.rank===3&&(o=!0,a=V(r,[1,r.shape[0],r.shape[1],r.shape[2]]));let[]=t,i={images:a},l={alignCorners:n,halfPixelCenters:s,size:t},u=L.runKernel(go,i,l);return o?V(u,[u.shape[1],u.shape[2],u.shape[3]]):u}var s3=W({resizeBilinear_:HD});function GD(e,t,n=!1,s=!1){let r=$(e,"images","resizeNearestNeighbor");M(r.rank===3||r.rank===4,()=>`Error in resizeNearestNeighbor: x must be rank 3 or 4, but got rank ${r.rank}.`),M(t.length===2,()=>`Error in resizeNearestNeighbor: new shape must 2D, but got shape ${t}.`),M(r.dtype==="float32"||r.dtype==="int32",()=>"`images` must have `int32` or `float32` as dtype"),M(s===!1||n===!1,()=>"Error in resizeNearestNeighbor: If halfPixelCenters is true, alignCorners must be false.");let a=r,o=!1;r.rank===3&&(o=!0,a=V(r,[1,r.shape[0],r.shape[1],r.shape[2]]));let[]=t,i={images:a},l={alignCorners:n,halfPixelCenters:s,size:t},u=L.runKernel(ic,i,l);return o?V(u,[u.shape[1],u.shape[2],u.shape[3]]):u}var r3=W({resizeNearestNeighbor_:GD});function jD(e,t="binary",n=!1,s=.5){let r=$(e,"image","threshold"),a=.2989,o=.587,i=.114,l=r.shape[0]*r.shape[1],u=z(Ut([s]),255),c,d,p,h;if(M(r.rank===3,()=>`Error in threshold: image must be rank 3,but got rank ${r.rank}.`),M(r.shape[2]===3||r.shape[2]===1,()=>`Error in threshold: image color channel must be equal to 3 or 1but got ${r.shape[2]}.`),M(r.dtype==="int32"||r.dtype==="float32",()=>`Error in dtype: image dtype must be int32 or float32,but got dtype ${r.dtype}.`),M(t==="otsu"||t==="binary",()=>`Method must be binary or otsu, but was ${t}`),r.shape[2]===3){[c,d,p]=Vt(r,[1,1,1],-1);let g=z(c,a),A=z(d,o),y=z(p,i);h=oe(oe(g,A),y)}else h=e;if(t==="otsu"){let g=nA(pe(Ch(h),"int32"),an([]),256);u=qD(g,l)}let f=n?ca(h,u):Vn(h,u);return pe(z(f,255),"int32")}function qD(e,t){let n=Ut([-1]),s=Ut([0]),r=Ut([0]),a,o,i,l,u,c;for(let d=0;d<e.size-1;d++){a=_e(e,0,d+1),o=_e(e,d+1),u=he(we(a),t),c=he(we(o),t);let p=we(z(a,Jl(0,a.size)));i=he(p,we(a));let h=Xl(o.shape,a.size),f=oe(Jl(0,o.size),h),m=z(o,f);l=he(we(m),we(o));let g=ye(i,l),A=ye(i,l),y=z(u,c);r=z(z(y,g),A);let x=Vn(r,s);s=vn(x,r,s),n=vn(x,Ut([d]),n)}return n}var XD=W({threshold_:jD});function KD(e,t,n="nearest",s="constant",r=0,a){let o=$(e,"image","transform","float32"),i=$(t,"transforms","transform","float32");M(o.rank===4,()=>`Error in transform: image must be rank 4,but got rank ${o.rank}.`),M(i.rank===2&&(i.shape[0]===o.shape[0]||i.shape[0]===1)&&i.shape[1]===8,()=>"Error in transform: Input transform should be batch x 8 or 1 x 8"),M(a==null||a.length===2,()=>`Error in transform: outputShape must be [height, width] or null, but got ${a}.`);let l={image:o,transforms:i},u={interpolation:n,fillMode:s,fillValue:r,outputShape:a};return L.runKernel(Dl,l,u)}var ZD=W({transform_:KD});function YD(e,t,n){M(t%1==0,()=>`bandPart(): numLower must be an integer, got ${t}.`),M(n%1==0,()=>`bandPart(): numUpper must be an integer, got ${n}.`);let s=$(e,"a","bandPart");M(s.rank>=2,()=>`bandPart(): Rank must be at least 2, got ${s.rank}.`);let r=s.shape,[a,o]=s.shape.slice(-2);if(!(t<=a))throw new Error(`bandPart(): numLower (${t}) must not be greater than the number of rows (${a}).`);if(!(n<=o))throw new Error(`bandPart(): numUpper (${n}) must not be greater than the number of columns (${o}).`);t<0&&(t=a),n<0&&(n=o);let i=V(Jl(0,a,1,"int32"),[-1,1]),l=Jl(0,o,1,"int32"),u=ye(i,l),c=_s(ca(u,Ce(+t,"int32")),ua(u,Ce(-n,"int32"))),d=Mt([a,o],s.dtype);return V(mn(is(V(s,[-1,a,o])).map(p=>vn(c,p,d))),r)}var JD=W({bandPart_:YD});function QD(e){let t;if(Array.isArray(e)){t=!1,M(e!=null&&e.length>0,()=>"Gram-Schmidt process: input must not be null, undefined, or empty");let r=e[0].shape[0];for(let a=1;a<e.length;++a)M(e[a].shape[0]===r,()=>`Gram-Schmidt: Non-unique lengths found in the input vectors: (${e[a].shape[0]} vs. ${r})`)}else t=!0,e=Vt(e,e.shape[0],0).map(r=>lt(r,[0]));M(e.length<=e[0].shape[0],()=>`Gram-Schmidt: Number of vectors (${e.length}) exceeds number of dimensions (${e[0].shape[0]}).`);let n=[],s=e;for(let r=0;r<e.length;++r)n.push(L.tidy(()=>{let a=s[r];if(r>0)for(let o=0;o<r;++o){let i=z(we(z(n[o],a)),n[o]);a=ye(a,i)}return he(a,Mh(a,"euclidean"))}));return t?mn(n,0):n}var e_=W({gramSchmidt_:QD});function t_(e,t=!1){if(M(e.rank>=2,()=>`qr() requires input tensor to have a rank >= 2, but got rank ${e.rank}`),e.rank===2)return a3(e,t);{let n=e.shape.slice(0,e.shape.length-2).reduce((l,u)=>l*u),s=is(V(e,[n,e.shape[e.shape.length-2],e.shape[e.shape.length-1]]),0),r=[],a=[];s.forEach(l=>{let[u,c]=a3(l,t);r.push(u),a.push(c)});let o=V(mn(r,0),e.shape),i=V(mn(a,0),e.shape);return[o,i]}}function a3(e,t=!1){return L.tidy(()=>{M(e.shape.length===2,()=>`qr2d() requires a 2D Tensor, but got a ${e.shape.length}D Tensor.`);let n=e.shape[0],s=e.shape[1],r=dA(n),a=Bs(e),o=Us([[1]],[1,1]),i=Bs(o),l=n>=s?s:n;for(let u=0;u<l;++u){let c=a,d=i,p=r;[i,a,r]=L.tidy(()=>{let h=_e(a,[u,u],[n-u,1]),f=Mh(h),m=_e(a,[u,u],[1,1]),g=vn(Vn(m,0),Us([[-1]]),Us([[1]])),A=ye(m,z(g,f)),y=he(h,A);y.shape[0]===1?i=Bs(o):i=ft([o,_e(y,[1,0],[y.shape[0]-1,y.shape[1]])],0);let x=St(he(Ue(g,A),f)),b=_e(a,[u,0],[n-u,s]),v=z(x,i),k=Ye(i);if(u===0)a=ye(b,Ue(v,Ue(k,b)));else{let D=ye(b,Ue(v,Ue(k,b)));a=ft([_e(a,[0,0],[u,s]),D],0)}let S=Ye(v),C=_e(r,[0,u],[n,r.shape[1]-u]);if(u===0)r=ye(C,Ue(Ue(C,i),S));else{let D=ye(C,Ue(Ue(C,i),S));r=ft([_e(r,[0,0],[n,u]),D],1)}return[i,a,r]}),Z([c,d,p])}return!t&&n>s&&(r=_e(r,[0,0],[n,s]),a=_e(a,[0,0],[s,s])),[r,a]})}var n_=W({qr_:t_}),Tn;(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"})(Tn||(Tn={}));function s_(e,t,n=Tn.SUM_BY_NONZERO_WEIGHTS){let s=$(e,"losses","computeWeightedLoss"),r=null;t!=null&&(r=$(t,"weights","computeWeightedLoss"));let a=r==null?s:z(s,r);if(n===Tn.NONE)return a;if(n===Tn.SUM)return we(a);if(n===Tn.MEAN){if(r==null)return Dt(a);{let o=s.size/r.size,i=he(we(a),we(r));return o>1?he(i,Ce(o)):i}}if(n===Tn.SUM_BY_NONZERO_WEIGHTS){if(r==null)return he(we(a),Ce(s.size));{let o=z(r,rs(s.shape)),i=pe(we(qo(o,Ce(0))),"float32");return he(we(a),i)}}throw Error(`Unknown reduction: ${n}`)}var Rr=W({computeWeightedLoss_:s_});function r_(e,t,n,s=Tn.SUM_BY_NONZERO_WEIGHTS){let r=$(e,"labels","absoluteDifference"),a=$(t,"predictions","absoluteDifference"),o=null;n!=null&&(o=$(n,"weights","absoluteDifference")),In(r.shape,a.shape,"Error in absoluteDifference: ");let i=Wt(ye(r,a));return Rr(i,o,s)}var a_=W({absoluteDifference_:r_});function o_(e,t,n,s,r=Tn.SUM_BY_NONZERO_WEIGHTS){let a=$(e,"labels","cosineDistance"),o=$(t,"predictions","cosineDistance"),i=null;s!=null&&(i=$(s,"weights","cosineDistance")),In(a.shape,o.shape,"Error in cosineDistance: ");let l=Ce(1),u=ye(l,we(z(a,o),n,!0));return Rr(u,i,r)}var i_=W({cosineDistance_:o_});function l_(e,t,n,s=Tn.SUM_BY_NONZERO_WEIGHTS){let r=$(e,"labels","hingeLoss"),a=$(t,"predictions","hingeLoss"),o=null;n!=null&&(o=$(n,"weights","hingeLoss")),In(r.shape,a.shape,"Error in hingeLoss: ");let i=Ce(1);r=ye(z(Ce(2),r),i);let l=Vs(ye(i,z(r,a)));return Rr(l,o,s)}var u_=W({hingeLoss_:l_});function c_(e,t,n,s=1,r=Tn.SUM_BY_NONZERO_WEIGHTS){let a=$(e,"labels","huberLoss"),o=$(t,"predictions","huberLoss"),i=null;n!=null&&(i=$(n,"weights","huberLoss")),In(a.shape,o.shape,"Error in huberLoss: ");let l=Ce(s),u=Wt(ye(o,a)),c=Zl(u,l),d=ye(u,c),p=oe(z(Ce(.5),pt(c)),z(l,d));return Rr(p,i,r)}var d_=W({huberLoss_:c_});function p_(e,t,n,s=1e-7,r=Tn.SUM_BY_NONZERO_WEIGHTS){let a=$(e,"labels","logLoss"),o=$(t,"predictions","logLoss"),i=null;n!=null&&(i=$(n,"weights","logLoss")),In(a.shape,o.shape,"Error in logLoss: ");let l=Ce(1),u=Ce(s),c=St(z(a,ns(oe(o,u)))),d=z(ye(l,a),ns(oe(ye(l,o),u))),p=ye(c,d);return Rr(p,i,r)}var h_=W({logLoss_:p_});function f_(e,t,n,s=Tn.SUM_BY_NONZERO_WEIGHTS){let r=$(e,"labels","meanSquaredError"),a=$(t,"predictions","meanSquaredError"),o=null;n!=null&&(o=$(n,"weights","meanSquaredError")),In(r.shape,a.shape,"Error in meanSquaredError: ");let i=Fh(r,a);return Rr(i,o,s)}var m_=W({meanSquaredError_:f_});function g_(e,t){let n=$(e,"labels","sigmoidCrossEntropyWithLogits"),s=$(t,"logits","sigmoidCrossEntropyWithLogits");In(n.shape,s.shape,"Error in sigmoidCrossEntropyWithLogits: ");let r=Vs(s),a=z(s,n),o=Nc(ts(St(Wt(s))));return oe(ye(r,a),o)}function A_(e,t,n,s=0,r=Tn.SUM_BY_NONZERO_WEIGHTS){let a=$(e,"multiClassLabels","sigmoidCrossEntropy"),o=$(t,"logits","sigmoidCrossEntropy"),i=null;if(n!=null&&(i=$(n,"weights","sigmoidCrossEntropy")),In(a.shape,o.shape,"Error in sigmoidCrossEntropy: "),s>0){let u=Ce(s),c=Ce(1),d=Ce(.5);a=oe(z(a,ye(c,u)),z(d,u))}let l=g_(a,o);return Rr(l,i,r)}var y_=W({sigmoidCrossEntropy_:A_});function x_(e,t,n=-1){if(n===-1&&(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}`);return or((r,a,o)=>{let l=gA(a,[n],!0),u=ye(pe(a,"float32"),l);o([r,u]);let c=St(z(u,r));return{value:we(c,[n]),gradFunc:(h,f)=>{let[m,g]=f,A=jo(h.shape,[n]);return[z(V(h,A),ye(pe(m,"float32"),ts(g))),z(V(h,A),ye(ts(g),pe(m,"float32")))]}}})(e,t)}function b_(e,t,n,s=0,r=Tn.SUM_BY_NONZERO_WEIGHTS){let a=$(e,"onehotLabels","softmaxCrossEntropy"),o=$(t,"logits","softmaxCrossEntropy"),i=null;if(n!=null&&(i=$(n,"weights","softmaxCrossEntropy")),In(a.shape,o.shape,"Error in softmaxCrossEntropy: "),s>0){let u=Ce(s),c=Ce(1),d=Ce(a.shape[1]);a=oe(z(a,ye(c,u)),he(u,d))}let l=x_(a,o);return Rr(l,i,r)}var v_=W({softmaxCrossEntropy_:b_});function w_(e,t,n,s){let r=$(e,"indices","sparseFillEmptyRows"),a=$(t,"values","sparseFillEmptyRows"),o=$(n,"denseShape","sparseFillEmptyRows"),i=$(s,"defaultValue","sparseFillEmptyRows",a.dtype);if(r.rank!==2)throw new Error(`Indices should be Tensor2D but received shape
|
|
${r.shape}`);if(a.rank!==1)throw new Error(`Values should be Tensor1D but received shape ${a.shape}`);if(o.rank!==1)throw new Error(`Dense shape should be Tensor1D but received shape ${o.shape}`);if(i.rank!==0)throw new Error(`Default value should be a scalar but received shape ${i.shape}`);let l={indices:r,values:a,denseShape:o,defaultValue:i},u=L.runKernel(Wp,l);return{outputIndices:u[0],outputValues:u[1],emptyRowIndicator:u[2],reverseIndexMap:u[3]}}var k_=W({sparseFillEmptyRows_:w_});function I_(e,t,n){let s=$(e,"inputIndices","sparseReshape"),r=$(t,"inputShape","sparseReshape"),a=$(n,"newShape","sparseReshape");if(s.rank!==2)throw new Error(`Input indices should be Tensor2D but received shape
|
|
${s.shape}`);if(r.rank!==1)throw new Error(`Input shape should be Tensor1D but received shape ${r.shape}`);if(a.rank!==1)throw new Error(`New shape should be Tensor1D but received shape ${a.shape}`);let o={inputIndices:s,inputShape:r,newShape:a},i=L.runKernel(Vp,o);return{outputIndices:i[0],outputShape:i[1]}}var S_=W({sparseReshape_:I_});function C_(e,t,n){let s=$(e,"data","sparseSegmentMean"),r=$(t,"indices","sparseSegmentMean"),a=$(n,"segmentIds","sparseSegmentMean");if(s.rank<1)throw new Error("Data should be at least 1 dimensional but received scalar");if(r.rank!==1)throw new Error(`Indices should be Tensor1D but received shape
|
|
${r.shape}`);if(a.rank!==1)throw new Error(`Segment ids should be Tensor1D but received shape
|
|
${a.shape}`);let o={data:s,indices:r,segmentIds:a};return L.runKernel(Up,o)}var T_=W({sparseSegmentMean_:C_});function N_(e,t,n){let s=$(e,"data","sparseSegmentSum"),r=$(t,"indices","sparseSegmentSum"),a=$(n,"segmentIds","sparseSegmentSum");if(s.rank<1)throw new Error("Data should be at least 1 dimensional but received scalar");if(r.rank!==1)throw new Error(`Indices should be Tensor1D but received shape
|
|
${r.shape}`);if(a.rank!==1)throw new Error(`Segment ids should be Tensor1D but received shape
|
|
${a.shape}`);let o={data:s,indices:r,segmentIds:a};return L.runKernel(Hp,o)}var E_=W({sparseSegmentSum_:N_});function R_(e,t,n,s,r,a,o,i){let l=$(e,"data","stringNGrams","string");if(l.dtype!=="string")throw new Error("Data must be of datatype string");if(l.shape.length!==1)throw new Error(`Data must be a vector, saw: ${l.shape}`);let u=$(t,"dataSplits","stringNGrams");if(u.dtype!=="int32")throw new Error("Data splits must be of datatype int32");let c={separator:n,nGramWidths:s,leftPad:r,rightPad:a,padWidth:o,preserveShortSequences:i},d={data:l,dataSplits:u},p=L.runKernel(jp,d,c);return{nGrams:p[0],nGramsSplits:p[1]}}var D_=W({stringNGrams_:R_});function __(e,t,n=!0){let s=$(e,"input","stringSplit","string"),r=$(t,"delimiter","stringSplit","string");if(s.rank!==1)throw new Error(`Input should be Tensor1D but received shape ${s.shape}`);if(r.rank!==0)throw new Error(`Delimiter should be a scalar but received shape ${r.shape}`);let a={skipEmpty:n},o={input:s,delimiter:r},i=L.runKernel(qp,o,a);return{indices:i[0],values:i[1],shape:i[2]}}var $_=W({stringSplit_:__});function F_(e,t){let n=$(e,"input","stringToHashBucketFast","string"),s={numBuckets:t};if(t<=0)throw new Error("Number of buckets must be at least 1");let r={input:n};return L.runKernel(Xp,r,s)}var O_=W({stringToHashBucketFast_:F_}),P_={fft:Mc,ifft:Ql,rfft:zc,irfft:$h},M_={hammingWindow:hD,hannWindow:Yb,frame:Jb,stft:AD},$e={flipLeftRight:vD,grayscaleToRGB:kD,resizeNearestNeighbor:r3,resizeBilinear:s3,rotateWithOffset:SD,cropAndResize:xD,nonMaxSuppression:TD,nonMaxSuppressionAsync:OD,nonMaxSuppressionWithScore:MD,nonMaxSuppressionWithScoreAsync:LD,nonMaxSuppressionPadded:WD,nonMaxSuppressionPaddedAsync:UD,threshold:XD,transform:ZD},o3={bandPart:JD,gramSchmidt:e_,qr:n_},z_={absoluteDifference:a_,computeWeightedLoss:Rr,cosineDistance:i_,hingeLoss:u_,huberLoss:d_,logLoss:h_,meanSquaredError:m_,sigmoidCrossEntropy:y_,softmaxCrossEntropy:v_},Lc={sparseFillEmptyRows:k_,sparseReshape:S_,sparseSegmentMean:T_,sparseSegmentSum:E_},Vh={stringNGrams:D_,stringSplit:$_,stringToHashBucketFast:O_},Dr=class extends ib{minimize(e,t=!1,n){let{value:s,grads:r}=this.computeGradients(e,n);if(n!=null){let a=n.map(o=>({name:o.name,tensor:r[o.name]}));this.applyGradients(a)}else this.applyGradients(r);return Z(r),t?s:(s.dispose(),null)}get iterations(){return this.iterations_==null&&(this.iterations_=0),this.iterations_}incrementIterations(){this.iterations_=this.iterations+1}computeGradients(e,t){return Db(e,t)}dispose(){this.iterations_!=null&&Z(this.iterations_)}async saveIterations(){return this.iterations_==null&&(this.iterations_=0),{name:"iter",tensor:Ce(this.iterations_,"int32")}}async getWeights(){throw new Error("getWeights() is not implemented for this optimizer yet.")}async setWeights(e){throw new Error(`setWeights() is not implemented for this optimizer class ${this.getClassName()}`)}async extractIterations(e){return this.iterations_=(await e[0].tensor.data())[0],e.slice(1)}};Object.defineProperty(Dr,Symbol.hasInstance,{value:e=>e.minimize!=null&&e.computeGradients!=null&&e.applyGradients!=null});var Uh=class extends Dr{constructor(e,t,n=null){super();this.learningRate=e,this.rho=t,this.epsilon=n,this.accumulatedGrads=[],this.accumulatedUpdates=[],n==null&&(this.epsilon=L.backend.epsilon())}applyGradients(e){(Array.isArray(e)?e.map(n=>n.name):Object.keys(e)).forEach((n,s)=>{let r=L.registeredVariables[n],a=!1;this.accumulatedGrads[s]==null&&(this.accumulatedGrads[s]={originalName:`${n}/accum_grad`,variable:H(()=>Je(r).variable(a))}),this.accumulatedUpdates[s]==null&&(this.accumulatedUpdates[s]={originalName:`${n}/accum_var`,variable:H(()=>Je(r).variable(a))});let o=Array.isArray(e)?e[s].tensor:e[n];if(o==null)return;let i=this.accumulatedGrads[s].variable,l=this.accumulatedUpdates[s].variable;H(()=>{let u=oe(z(i,this.rho),z(pt(o),1-this.rho)),c=z(he(fn(oe(l,this.epsilon)),fn(oe(i,this.epsilon))),o),d=oe(z(l,this.rho),z(pt(c),1-this.rho));i.assign(u),l.assign(d);let p=oe(z(c,-this.learningRate),r);r.assign(p)})}),this.incrementIterations()}dispose(){this.accumulatedUpdates!=null&&(Z(this.accumulatedGrads.map(e=>e.variable)),Z(this.accumulatedUpdates.map(e=>e.variable)))}async getWeights(){let e=[...this.accumulatedGrads,...this.accumulatedUpdates];return[await this.saveIterations()].concat(e.map(t=>({name:t.originalName,tensor:t.variable})))}async setWeights(e){e=await this.extractIterations(e);let t=e.length/2,n=!1;this.accumulatedGrads=e.slice(0,t).map(s=>({originalName:s.name,variable:s.tensor.variable(n)})),this.accumulatedUpdates=e.slice(t,t*2).map(s=>({originalName:s.name,variable:s.tensor.variable(n)}))}getConfig(){return{learningRate:this.learningRate,rho:this.rho,epsilon:this.epsilon}}static fromConfig(e,t){return new e(t.learningRate,t.rho,t.epsilon)}};Uh.className="Adadelta";oa(Uh);var Hh=class extends Dr{constructor(e,t=.1){super();this.learningRate=e,this.initialAccumulatorValue=t,this.accumulatedGrads=[]}applyGradients(e){(Array.isArray(e)?e.map(n=>n.name):Object.keys(e)).forEach((n,s)=>{let r=L.registeredVariables[n];if(this.accumulatedGrads[s]==null){let i=!1;this.accumulatedGrads[s]={originalName:`${n}/accumulator`,variable:H(()=>Xl(r.shape,this.initialAccumulatorValue).variable(i))}}let a=Array.isArray(e)?e[s].tensor:e[n];if(a==null)return;let o=this.accumulatedGrads[s].variable;H(()=>{let i=oe(o,pt(a));o.assign(i);let l=oe(z(he(a,fn(oe(i,L.backend.epsilon()))),-this.learningRate),r);r.assign(l)})}),this.incrementIterations()}dispose(){this.accumulatedGrads!=null&&Z(this.accumulatedGrads.map(e=>e.variable))}async getWeights(){return[await this.saveIterations()].concat(this.accumulatedGrads.map(e=>({name:e.originalName,tensor:e.variable})))}async setWeights(e){e=await this.extractIterations(e);let t=!1;this.accumulatedGrads=e.map(n=>({originalName:n.name,variable:n.tensor.variable(t)}))}getConfig(){return{learningRate:this.learningRate,initialAccumulatorValue:this.initialAccumulatorValue}}static fromConfig(e,t){return new e(t.learningRate,t.initialAccumulatorValue)}};Hh.className="Adagrad";oa(Hh);var Gh=class extends Dr{constructor(e,t,n,s=null){super();this.learningRate=e,this.beta1=t,this.beta2=n,this.epsilon=s,this.accumulatedFirstMoment=[],this.accumulatedSecondMoment=[],H(()=>{this.accBeta1=Ce(t).variable(),this.accBeta2=Ce(n).variable()}),s==null&&(this.epsilon=L.backend.epsilon())}applyGradients(e){let t=Array.isArray(e)?e.map(n=>n.name):Object.keys(e);H(()=>{let n=ye(1,this.accBeta1),s=ye(1,this.accBeta2);t.forEach((r,a)=>{let o=L.registeredVariables[r],i=!1;this.accumulatedFirstMoment[a]==null&&(this.accumulatedFirstMoment[a]={originalName:`${r}/m`,variable:H(()=>Je(o).variable(i))}),this.accumulatedSecondMoment[a]==null&&(this.accumulatedSecondMoment[a]={originalName:`${r}/v`,variable:H(()=>Je(o).variable(i))});let l=Array.isArray(e)?e[a].tensor:e[r];if(l==null)return;let u=this.accumulatedFirstMoment[a].variable,c=this.accumulatedSecondMoment[a].variable,d=oe(z(u,this.beta1),z(l,1-this.beta1)),p=oe(z(c,this.beta2),z(pt(l),1-this.beta2)),h=he(d,n),f=he(p,s);u.assign(d),c.assign(p);let m=oe(z(he(h,oe(fn(f),this.epsilon)),-this.learningRate),o);o.assign(m)}),this.accBeta1.assign(z(this.accBeta1,this.beta1)),this.accBeta2.assign(z(this.accBeta2,this.beta2))}),this.incrementIterations()}dispose(){this.accBeta1.dispose(),this.accBeta2.dispose(),this.accumulatedFirstMoment!=null&&Z(this.accumulatedFirstMoment.map(e=>e.variable)),this.accumulatedSecondMoment!=null&&Z(this.accumulatedSecondMoment.map(e=>e.variable))}async getWeights(){let e=[...this.accumulatedFirstMoment,...this.accumulatedSecondMoment];return[await this.saveIterations()].concat(e.map(t=>({name:t.originalName,tensor:t.variable})))}async setWeights(e){e=await this.extractIterations(e),H(()=>{this.accBeta1.assign(Er(this.beta1,this.iterations_+1)),this.accBeta2.assign(Er(this.beta2,this.iterations_+1))});let t=e.length/2,n=!1;this.accumulatedFirstMoment=e.slice(0,t).map(s=>({originalName:s.name,variable:s.tensor.variable(n)})),this.accumulatedSecondMoment=e.slice(t,t*2).map(s=>({originalName:s.name,variable:s.tensor.variable(n)}))}getConfig(){return{learningRate:this.learningRate,beta1:this.beta1,beta2:this.beta2,epsilon:this.epsilon}}static fromConfig(e,t){return new e(t.learningRate,t.beta1,t.beta2,t.epsilon)}};Gh.className="Adam";oa(Gh);var jh=class extends Dr{constructor(e,t,n,s=null,r=0){super();this.learningRate=e,this.beta1=t,this.beta2=n,this.epsilon=s,this.decay=r,this.accumulatedFirstMoment=[],this.accumulatedWeightedInfNorm=[],H(()=>{this.iteration=Ce(0).variable(),this.accBeta1=Ce(t).variable()}),s==null&&(this.epsilon=L.backend.epsilon())}applyGradients(e){let t=Array.isArray(e)?e.map(n=>n.name):Object.keys(e);H(()=>{let n=ye(1,this.accBeta1),s=he(-this.learningRate,oe(z(this.iteration,this.decay),1));t.forEach((r,a)=>{let o=L.registeredVariables[r],i=!1;this.accumulatedFirstMoment[a]==null&&(this.accumulatedFirstMoment[a]={originalName:`${r}/m`,variable:Je(o).variable(i)}),this.accumulatedWeightedInfNorm[a]==null&&(this.accumulatedWeightedInfNorm[a]={originalName:`${r}/v`,variable:Je(o).variable(i)});let l=Array.isArray(e)?e[a].tensor:e[r];if(l==null)return;let u=this.accumulatedFirstMoment[a].variable,c=this.accumulatedWeightedInfNorm[a].variable,d=oe(z(u,this.beta1),z(l,1-this.beta1)),p=z(c,this.beta2),h=Wt(l),f=ir(p,h);u.assign(d),c.assign(f);let m=oe(z(he(s,n),he(d,oe(f,this.epsilon))),o);o.assign(m)}),this.iteration.assign(oe(this.iteration,1)),this.accBeta1.assign(z(this.accBeta1,this.beta1))}),this.incrementIterations()}dispose(){this.accBeta1.dispose(),this.iteration.dispose(),this.accumulatedFirstMoment!=null&&Z(this.accumulatedFirstMoment.map(e=>e.variable)),this.accumulatedWeightedInfNorm!=null&&Z(this.accumulatedWeightedInfNorm.map(e=>e.variable))}async getWeights(){throw new Error("getWeights() is not implemented for Adamax yet.")}async setWeights(e){throw new Error("setWeights() is not implemented for Adamax yet.")}getConfig(){return{learningRate:this.learningRate,beta1:this.beta1,beta2:this.beta2,epsilon:this.epsilon,decay:this.decay}}static fromConfig(e,t){return new e(t.learningRate,t.beta1,t.beta2,t.epsilon,t.decay)}};jh.className="Adamax";oa(jh);var Bc=class extends Dr{constructor(e){super();this.learningRate=e,this.setLearningRate(e)}applyGradients(e){(Array.isArray(e)?e.map(n=>n.name):Object.keys(e)).forEach((n,s)=>{let r=Array.isArray(e)?e[s].tensor:e[n];if(r==null)return;let a=L.registeredVariables[n];H(()=>{let o=oe(z(this.c,r),a);a.assign(o)})}),this.incrementIterations()}setLearningRate(e){this.learningRate=e,this.c!=null&&this.c.dispose(),this.c=on(Ce(-e))}dispose(){this.c.dispose()}async getWeights(){return[await this.saveIterations()]}async setWeights(e){if(e=await this.extractIterations(e),e.length!==0)throw new Error("SGD optimizer does not have settable weights.")}getConfig(){return{learningRate:this.learningRate}}static fromConfig(e,t){return new e(t.learningRate)}};Bc.className="SGD";oa(Bc);var qh=class extends Bc{constructor(e,t,n=!1){super(e);this.learningRate=e,this.momentum=t,this.useNesterov=n,this.accumulations=[],this.m=Ce(this.momentum)}applyGradients(e){(Array.isArray(e)?e.map(n=>n.name):Object.keys(e)).forEach((n,s)=>{let r=L.registeredVariables[n];if(this.accumulations[s]==null){let i=!1;this.accumulations[s]={originalName:`${n}/momentum`,variable:H(()=>Je(r).variable(i))}}let a=this.accumulations[s].variable,o=Array.isArray(e)?e[s].tensor:e[n];o!=null&&H(()=>{let i,l=oe(z(this.m,a),o);this.useNesterov?i=oe(z(this.c,oe(o,z(l,this.m))),r):i=oe(z(this.c,l),r),a.assign(l),r.assign(i)})}),this.incrementIterations()}dispose(){this.m.dispose(),this.accumulations!=null&&Z(this.accumulations.map(e=>e.variable))}setMomentum(e){this.momentum=e}async getWeights(){return[await this.saveIterations()].concat(this.accumulations.map(e=>({name:e.originalName,tensor:e.variable})))}async setWeights(e){e=await this.extractIterations(e);let t=!1;this.accumulations=e.map(n=>({originalName:n.name,variable:n.tensor.variable(t)}))}getConfig(){return{learningRate:this.learningRate,momentum:this.momentum,useNesterov:this.useNesterov}}static fromConfig(e,t){return new e(t.learningRate,t.momentum,t.useNesterov)}};qh.className="Momentum";oa(qh);var Xh=class extends Dr{constructor(e,t=.9,n=0,s=null,r=!1){super();if(this.learningRate=e,this.decay=t,this.momentum=n,this.epsilon=s,this.accumulatedMeanSquares=[],this.accumulatedMoments=[],this.accumulatedMeanGrads=[],this.centered=r,s==null&&(this.epsilon=L.backend.epsilon()),e==null)throw new Error("learningRate for RMSPropOptimizer must be defined.")}applyGradients(e){(Array.isArray(e)?e.map(n=>n.name):Object.keys(e)).forEach((n,s)=>{let r=L.registeredVariables[n],a=!1;this.accumulatedMeanSquares[s]==null&&(this.accumulatedMeanSquares[s]={originalName:`${n}/rms`,variable:H(()=>Je(r).variable(a))}),this.accumulatedMoments[s]==null&&(this.accumulatedMoments[s]={originalName:`${n}/momentum`,variable:H(()=>Je(r).variable(a))}),this.accumulatedMeanGrads[s]==null&&this.centered&&(this.accumulatedMeanGrads[s]={originalName:`${n}/mg`,variable:H(()=>Je(r).variable(a))});let o=Array.isArray(e)?e[s].tensor:e[n];if(o==null)return;let i=this.accumulatedMeanSquares[s].variable,l=this.accumulatedMoments[s].variable;H(()=>{let u=oe(z(i,this.decay),z(pt(o),1-this.decay));if(this.centered){let c=this.accumulatedMeanGrads[s].variable,d=oe(z(c,this.decay),z(o,1-this.decay)),p=he(z(o,this.learningRate),fn(ye(u,oe(pt(d),this.epsilon)))),h=oe(z(l,this.momentum),p);i.assign(u),c.assign(d),l.assign(h);let f=ye(r,h);r.assign(f)}else{let c=oe(z(i,this.decay),z(pt(o),1-this.decay)),d=oe(z(l,this.momentum),he(z(o,this.learningRate),fn(oe(c,this.epsilon))));i.assign(c),l.assign(d);let p=ye(r,d);r.assign(p)}})}),this.incrementIterations()}dispose(){this.accumulatedMeanSquares!=null&&Z(this.accumulatedMeanSquares.map(e=>e.variable)),this.accumulatedMeanGrads!=null&&this.centered&&Z(this.accumulatedMeanGrads.map(e=>e.variable)),this.accumulatedMoments!=null&&Z(this.accumulatedMoments.map(e=>e.variable))}async getWeights(){let e=[...this.accumulatedMeanSquares,...this.accumulatedMoments];return this.centered&&e.push(...this.accumulatedMeanGrads),[await this.saveIterations()].concat(e.map(t=>({name:t.originalName,tensor:t.variable})))}async setWeights(e){e=await this.extractIterations(e);let t=this.centered?e.length/3:e.length/2,n=!1;this.accumulatedMeanSquares=e.slice(0,t).map(s=>({originalName:s.name,variable:s.tensor.variable(n)})),this.accumulatedMoments=e.slice(t,t*2).map(s=>({originalName:s.name,variable:s.tensor.variable(n)})),this.centered&&(this.accumulatedMeanGrads=e.slice(t*2,t*3).map(s=>({originalName:s.name,variable:s.tensor.variable(n)})))}getConfig(){return{learningRate:this.learningRate,decay:this.decay,momentum:this.momentum,epsilon:this.epsilon,centered:this.centered}}static fromConfig(e,t){return new e(t.learningRate,t.decay,t.momentum,t.epsilon,t.centered)}};Xh.className="RMSProp";oa(Xh);var Xo=class{static sgd(e){return new Bc(e)}static momentum(e,t,n=!1){return new qh(e,t,n)}static rmsprop(e,t=.9,n=0,s=null,r=!1){return new Xh(e,t,n,s,r)}static adam(e=.001,t=.9,n=.999,s=null){return new Gh(e,t,n,s)}static adadelta(e=.001,t=.95,n=null){return new Uh(e,t,n)}static adamax(e=.002,t=.9,n=.999,s=null,r=0){return new jh(e,t,n,s,r)}static adagrad(e,t=.1){return new Hh(e,t)}},Ko={sgd:Xo.sgd,momentum:Xo.momentum,adadelta:Xo.adadelta,adagrad:Xo.adagrad,rmsprop:Xo.rmsprop,adamax:Xo.adamax,adam:Xo.adam},L_=(()=>typeof requestAnimationFrame!="undefined"?requestAnimationFrame:typeof setImmediate!="undefined"?setImmediate:e=>e())();function Kh(){return new Promise(e=>L_(()=>e()))}var _={};Le(_,{ERF_A1:()=>Z_,ERF_A2:()=>Y_,ERF_A3:()=>J_,ERF_A4:()=>Q_,ERF_A5:()=>e$,ERF_P:()=>K_,PARALLELIZE_THRESHOLD:()=>OA,SELU_SCALE:()=>l3,SELU_SCALEALPHA:()=>i3,applyActivation:()=>Bh,assertAndGetBroadcastShape:()=>bt,assertAxesAreInnerMostDims:()=>tE,assertParamsConsistent:()=>B_,assignToTypedArray:()=>o$,axesAreInnerMostDims:()=>fA,calculateShapes:()=>K5,checkEinsumDimSizes:()=>p$,combineLocations:()=>$b,complexWithEvenIndex:()=>s$,complexWithOddIndex:()=>r$,computeConv2DInfo:()=>kc,computeConv3DInfo:()=>fb,computeDefaultPad:()=>Qg,computeDilation2DInfo:()=>IT,computeOptimalWindowSize:()=>V_,computeOutAndReduceShapes:()=>Fb,computeOutShape:()=>W_,computePool2DInfo:()=>hb,computePool3DInfo:()=>ST,convertConv2DDataFormat:()=>mb,decodeEinsumEquation:()=>c$,eitherStridesOrDilationsAreOne:()=>ar,expandShapeToKeepDim:()=>jo,exponent:()=>l$,exponents:()=>i$,fromStringArrayToUint8:()=>v$,fromUint8ToStringArray:()=>b$,getAxesPermutation:()=>Ob,getBroadcastDims:()=>gN,getComplexWithIndex:()=>a$,getEinsumComputePath:()=>h$,getEinsumPermutation:()=>d$,getFusedBiasGradient:()=>Lh,getFusedDyActivation:()=>zh,getImageCenter:()=>U_,getInnerMostAxes:()=>nE,getPermuted:()=>G_,getReductionAxes:()=>Zt,getReshaped:()=>H_,getReshapedPermuted:()=>j_,getSliceBeginCoords:()=>q_,getSliceSize:()=>X_,getUndoAxesPermutation:()=>mA,isIdentityPermutation:()=>f$,log:()=>QS,mergeRealAndImagArrays:()=>t$,prepareAndValidate:()=>X5,prepareSplitSize:()=>g$,segment_util:()=>d3,shouldFuse:()=>Wh,slice_util:()=>Cn,splitRealAndImagArrays:()=>n$,tupleValuesAreOne:()=>la,upcastType:()=>Ds,validateInput:()=>Lg,validateUpdateShape:()=>zg,warn:()=>tr});function B_(e,t){let n=e[0].length;e.forEach((r,a)=>{M(r.length===n,()=>`Error in concat${n}D: rank of tensors[${a}] must be the same as the rank of the rest (${n})`)}),M(t>=0&&t<n,()=>`Error in concat${n}D: axis must be between 0 and ${n-1}.`);let s=e[0];e.forEach((r,a)=>{for(let o=0;o<n;o++)M(o===t||r[o]===s[o],()=>`Error in concat${n}D: Shape of tensors[${a}] (${r}) does not match the shape of the rest (${s}) along the non-concatenated axis ${a}.`)})}function W_(e,t){let n=e[0].slice();for(let s=1;s<e.length;s++)n[t]+=e[s][t];return n}var OA=30;function V_(e){return e<=OA?e:pp(e,Math.floor(Math.sqrt(e)))}function U_(e,t,n){let s=n*(typeof e=="number"?e:e[0]),r=t*(typeof e=="number"?e:e[1]);return[s,r]}function H_(e,t,n,s=!0){let r=[];if(s)r=r.concat(t.slice(0)),r.push(e[0]/n),r=r.concat(e.slice(1));else{r=r.concat(e[0]);let a=t.length;for(let o=0;o<a;++o)r=r.concat([e[o+1]/t[o],t[o]]);r=r.concat(e.slice(a+1))}return r}function G_(e,t,n=!0){let s=[];if(n){s.push(t);for(let r=t+1;r<e;++r)r<=2*t?(s.push(r),s.push(r-(t+1))):s.push(r)}else{let r=[],a=[];for(let o=1;o<e;++o)o>=t*2+1||o%2==1?a.push(o):r.push(o);s.push(...r),s.push(0),s.push(...a)}return s}function j_(e,t,n,s=!0){let r=[];s?r.push(e[0]/n):r.push(e[0]*n);for(let a=1;a<e.length;++a)a<=t.length?s?r.push(t[a-1]*e[a]):r.push(e[a]/t[a-1]):r.push(e[a]);return r}function q_(e,t){let n=[0];for(let s=0;s<t;++s)n.push(e[s][0]);return n}function X_(e,t,n){let s=e.slice(0,1);for(let r=0;r<n;++r)s.push(e[r+1]-t[r][0]-t[r][1]);return s}var i3=1.7580993408473768,l3=1.0507009873554805,K_=.3275911,Z_=.254829592,Y_=-.284496736,J_=1.421413741,Q_=-1.453152027,e$=1.061405429;function t$(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}.`);let n=new Float32Array(e.length*2);for(let s=0;s<n.length;s+=2)n[s]=e[s/2],n[s+1]=t[s/2];return n}function n$(e){let t=new Float32Array(e.length/2),n=new Float32Array(e.length/2);for(let s=0;s<e.length;s+=2)t[s/2]=e[s],n[s/2]=e[s+1];return{real:t,imag:n}}function s$(e){let t=Math.ceil(e.length/4),n=new Float32Array(t),s=new Float32Array(t);for(let r=0;r<e.length;r+=4)n[Math.floor(r/4)]=e[r],s[Math.floor(r/4)]=e[r+1];return{real:n,imag:s}}function r$(e){let t=Math.floor(e.length/4),n=new Float32Array(t),s=new Float32Array(t);for(let r=2;r<e.length;r+=4)n[Math.floor(r/4)]=e[r],s[Math.floor(r/4)]=e[r+1];return{real:n,imag:s}}function a$(e,t){let n=e[t*2],s=e[t*2+1];return{real:n,imag:s}}function o$(e,t,n,s){e[s*2]=t,e[s*2+1]=n}function i$(e,t){let n=new Float32Array(e/2),s=new Float32Array(e/2);for(let r=0;r<Math.ceil(e/2);r++){let a=(t?2:-2)*Math.PI*(r/e);n[r]=Math.cos(a),s[r]=Math.sin(a)}return{real:n,imag:s}}function l$(e,t,n){let s=(n?2:-2)*Math.PI*(e/t),r=Math.cos(s),a=Math.sin(s);return{real:r,imag:a}}var PA="->",u$=/->/g,u3=",",c3="...";function c$(e,t){e=e.replace(/\s/g,"");let n=(e.length-e.replace(u$,"").length)/PA.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 ("${PA}").`);let[s,r]=e.split(PA);M(s.indexOf(c3)===-1,()=>`The ellipsis notation ("${c3}") is not supported yet.`);let a=s.split(u3),o=a.length;if(t!==o)throw new Error(`Expected ${o} input tensors, received ${t}`);if(o>2)throw new Error("Support for more than 2 input tensors is not implemented yet.");let i=[];for(let p=0;p<r.length;++p){let h=r[p];if(!a.some(f=>f.indexOf(h)!==-1))throw new Error(`Output subscripts contain the label ${h} not present in the input subscripts.`);i.indexOf(h)===-1&&i.push(h)}for(let p=0;p<s.length;++p){let h=s[p];i.indexOf(h)===-1&&h!==u3&&i.push(h)}let l=new Array(a.length);for(let p=0;p<o;++p){if(new Set(a[p].split("")).size!==a[p].length)throw new Error(`Found duplicate axes in input component ${a[p]}. Support for duplicate axes in input is not implemented yet.`);l[p]=[];for(let h=0;h<a[p].length;++h)l[p].push(i.indexOf(a[p][h]))}let u=i.length,c=r.length,d=[];for(let p=c;p<u;++p)d.push(p);return{allDims:i,summedDims:d,idDims:l}}function d$(e,t){let n=new Array(e);n.fill(-1);for(let r=0;r<t.length;++r)n[t[r]]=r;let s=[];for(let r=0;r<e;++r)n[r]===-1&&s.push(r);return n=n.filter(r=>r!==-1),{permutationIndices:n,expandDims:s}}function p$(e,t,n){let s=new Array(e);for(let r=0;r<n.length;++r){let a=n[r].shape;for(let o=0;o<t[r].length;++o)s[t[r][o]]===void 0?s[t[r][o]]=a[o]:M(s[t[r][o]]===a[o],()=>`Expected dimension ${s[t[r][o]]} at axis ${o} of input shaped ${JSON.stringify(a)}, but got dimension ${a[o]}`)}}function h$(e,t){let n=e,s=[],r=0;e.length===0&&n.push(-1),r=e.length+1;for(let o=0;o<r;++o)s.push([]);let a=[];for(let o=0;o<n.length;++o){let i=n[o],l=m$(t,i);for(let u of l)a.indexOf(u)===-1&&(s[o].push(u),a.push(u))}return{path:n,steps:s}}function f$(e){return e.every((t,n)=>t===n)}function m$(e,t){let n=[];for(let s=0;s<e.length;++s)(e[s].length===0||e[s].indexOf(t)!==-1||t===-1)&&n.push(s);return n}function g$(e,t,n=0){let s=[];if(typeof t=="number")M(e.shape[n]%t==0,()=>"Number of splits must evenly divide the axis."),s=new Array(t).fill(e.shape[n]/t);else{let r=t.reduce((o,i)=>(i===-1&&(o+=1),o),0);M(r<=1,()=>"There should be only one negative value in split array.");let a=t.indexOf(-1);if(a!==-1){let o=t.reduce((i,l)=>l>0?i+l:i);t[a]=e.shape[n]-o}M(e.shape[n]===t.reduce((o,i)=>o+i),()=>"The sum of sizes must match the size of the axis dimension."),s=t}return s}var d3={};Le(d3,{collectGatherOpShapeInfo:()=>x$,computeOutShape:()=>y$,segOpComputeOptimalWindowSize:()=>A$});function A$(e,t){let n=!1,s;for(e<=OA?(s=e,n=!0):s=pp(e,Math.floor(Math.sqrt(e)));!n;)s>t||s===e?n=!0:s=pp(e,s+1);return s}function y$(e,t,n){let s=[],r=e.length;for(let a=0;a<r;a++)a!==t?s.push(e[a]):s.push(n);return s}function x$(e,t,n,s){let r=t.shape.length,a=e.shape.length;if(s!==0&&(s<-r||s>r))throw new Error(`Expect batchDims in the range of [-${r}, ${r}], but got ${s}`);if(s<0&&(s+=r),s>a)throw new Error(`batchDims (${s}) must be less than rank(x) (
|
|
${a}).`);if(n<s)throw new Error(`batchDims (${s}) must be less than or equal to axis (${n}).`);for(let d=0;d<s;++d)if(e.shape[d]!==t.shape[d])throw new Error(`x.shape[${d}]: ${e.shape[d]} should be equal to indices.shape[${d}]: ${t.shape[d]}.`);let o=e.shape[n],i=[],l=1,u=1,c=1;for(let d=0;d<s;++d)i.push(e.shape[d]),l*=e.shape[d];for(let d=s;d<n;d++)i.push(e.shape[d]),u*=e.shape[d];for(let d=s;d<r;d++)i.push(t.shape[d]);for(let d=n+1;d<a;d++)i.push(e.shape[d]),c*=e.shape[d];return{batchSize:l,sliceSize:c,outerSize:u,dimSize:o,outputShape:i}}function b$(e){try{return e.map(t=>eh(t))}catch(t){throw new Error(`Failed to decode encoded string bytes into utf-8, error: ${t}`)}}function v$(e){return e.map(t=>hc(t))}var lr={};Le(lr,{nonMaxSuppressionV3Impl:()=>Qb,nonMaxSuppressionV4Impl:()=>e3,nonMaxSuppressionV5Impl:()=>t3,whereImpl:()=>Ub});var p3={kernelName:Fi,inputsToSave:["x"],gradFunc:(e,t)=>{let[n]=t;return{x:()=>z(e,eu(pe(n,"float32"),-1))}}},w$={kernelName:Oi,inputsToSave:["x"],gradFunc:(e,t)=>{let[n]=t;return{x:()=>{let s=pt(pe(n,"float32")),r=fn(ye(Ce(1),s));return St(he(e,r))}}}},k$={kernelName:Pi,inputsToSave:["x"],gradFunc:(e,t)=>{let[n]=t;return{x:()=>{let s=fn(ye(pt(pe(n,"float32")),1));return he(e,s)}}}},I$={kernelName:Yr,inputsToSave:["a","b"],gradFunc:(e,t)=>{let[n,s]=t,r=bt(n.shape,s.shape);return{a:()=>{let i=e,l=Zt(n.shape,r);return l.length>0&&(i=we(i,l)),V(i,n.shape)},b:()=>{let i=e,l=Zt(s.shape,r);return l.length>0&&(i=we(i,l)),V(i,s.shape)}}}},S$={kernelName:Fa,saveAllInputs:!0,gradFunc:(e,t)=>{let n={};return t.forEach((s,r)=>{n[r]=()=>e.clone()}),n}},C$={kernelName:Oa,inputsToSave:["x"],gradFunc:(e,t)=>{let[n]=t;return{x:()=>Je(n)}}},T$={kernelName:Zu,inputsToSave:["x"],gradFunc:(e,t)=>{let[n]=t;return{x:()=>Je(n)}}},N$={kernelName:Li,inputsToSave:["x"],gradFunc:(e,t)=>{let[n]=t;return{x:()=>he(e,fn(ye(Ce(1),pt(pe(n,"float32")))))}}},E$={kernelName:Bi,inputsToSave:["x"],gradFunc:(e,t)=>{let[n]=t;return{x:()=>{let s=fn(oe(Ce(1),pt(pe(n,"float32"))));return he(e,s)}}}},R$={kernelName:Ui,inputsToSave:["a","b"],gradFunc:(e,t)=>{let[n,s]=t,r=bt(n.shape,s.shape);return{a:()=>{let i=oe(pt(n),pt(s)),l=z(e,he(s,i)),u=Zt(n.shape,r);return u.length>0&&(l=we(l,u)),V(l,n.shape)},b:()=>{let i=oe(pt(n),pt(s)),l=St(z(e,he(n,i))),u=Zt(s.shape,r);return u.length>0&&(l=we(l,u)),V(l,s.shape)}}}},D$={kernelName:Wi,inputsToSave:["x"],gradFunc:(e,t)=>{let[n]=t;return{x:()=>he(e,oe(pt(pe(n,"float32")),1))}}},_$={kernelName:Vi,inputsToSave:["x"],gradFunc:(e,t)=>{let[n]=t;return{x:()=>he(e,ye(Ce(1),pt(pe(n,"float32"))))}}};function $$(e,t,n,s,r,a){let o=$(e,"dy","avgPool3dGrad"),i=$(t,"input","avgPool3dGrad"),l=o,u=i,c=!1;i.rank===4&&(c=!0,l=V(o,[1,o.shape[0],o.shape[1],o.shape[2],o.shape[3]]),u=V(i,[1,i.shape[0],i.shape[1],i.shape[2],i.shape[3]])),M(l.rank===5,()=>`Error in avgPool3dGrad: dy must be rank 5 but got rank ${l.rank}.`),M(u.rank===5,()=>`Error in avgPool3dGrad: input must be rank 5 but got rank ${u.rank}.`),a!=null&&M(sn(r),()=>`Error in avgPool3dGrad: pad must be an integer when using, dimRoundingMode ${a} but got pad ${r}.`);let d={dy:l,input:u},p={filterSize:n,strides:s,pad:r,dimRoundingMode:a},h=L.runKernel(mp,d,p);return c?V(h,[h.shape[1],h.shape[2],h.shape[3],h.shape[4]]):h}var F$=W({avgPool3dGrad_:$$}),O$={kernelName:Yu,inputsToSave:["x"],gradFunc:(e,t,n)=>{let[s]=t,{filterSize:r,strides:a,pad:o,dimRoundingMode:i}=n;return{x:()=>F$(e,s,r,a,o,i)}}};function P$(e,t,n,s,r){let a=$(e,"dy","avgPoolGrad"),o=$(t,"input","avgPoolGrad");M(o.rank===a.rank,()=>`Rank of input (${o.rank}) does not match rank of dy (${a.rank})`);let i=o,l=a,u=!1;o.rank===3&&(u=!0,i=V(o,[1,o.shape[0],o.shape[1],o.shape[2]]),l=V(a,[1,a.shape[0],a.shape[1],a.shape[2]])),M(l.rank===4,()=>`Error in avgPoolGrad: dy must be rank 4 but got rank ${l.rank}.`),M(i.rank===4,()=>`Error in avgPoolGrad: input must be rank 4 but got rank ${i.rank}.`);let c={dy:l,input:i},d={filterSize:n,strides:s,pad:r},p=L.runKernel(fp,c,d);return u?V(p,[p.shape[1],p.shape[2],p.shape[3]]):p}var M$=W({avgPoolGrad_:P$}),z$={kernelName:Pa,inputsToSave:["x"],gradFunc:(e,t,n)=>{let[s]=t,{filterSize:r,strides:a,pad:o}=n;return{x:()=>M$(e,s,r,a,o)}}},L$={kernelName:Ma,inputsToSave:["a","b"],gradFunc:(e,t,n)=>{let[s,r]=t,{transposeA:a,transposeB:o}=n;return!a&&!o?{a:()=>Ue(e,r,!1,!0),b:()=>Ue(s,e,!0,!1)}:!a&&o?{a:()=>Ue(e,r,!1,!1),b:()=>Ue(e,s,!0,!1)}:a&&!o?{a:()=>Ue(r,e,!1,!0),b:()=>Ue(s,e,!1,!1)}:{a:()=>Ue(r,e,!0,!0),b:()=>Ue(e,s,!0,!0)}}},B$={kernelName:Hi,gradFunc:(e,t,n)=>{let{blockShape:s,crops:r}=n;return{x:()=>_c(e,s,r)}}},W$={kernelName:p5,gradFunc:(e,t,n)=>{let s=n,r=s.inputShape,a=s.shape,o=Array.from(a);for(let l=r.length-1;l>=0;l--)if(r[l]===a[l])o[l]=1;else if(r[l]!==1)throw new Error(`broadcastTo(): [${r}] cannot be broadcast to [${a}].`);let i=[];for(let l=0;l<o.length;l++)o[l]>1&&i.push(l);return{x:()=>we(e,i,!0)}}},V$={kernelName:za,gradFunc:e=>({x:()=>e.clone()})},U$={kernelName:La,gradFunc:e=>({x:()=>Je(e)})},H$={kernelName:Jr,inputsToSave:["x"],gradFunc:(e,t,n)=>{let[s]=t,{clipValueMin:r,clipValueMax:a}=n;return{x:()=>vn(_s(ua(s,r),ca(s,a)),e,Je(e))}}},G$={kernelName:Ju,inputsToSave:["x"],gradFunc:p3.gradFunc},j$={kernelName:Gi,saveAllInputs:!0,gradFunc:(e,t,n)=>{let s=t.map(l=>l.shape),{axis:r}=n,a=Rs(r,t[0].shape)[0],o=s.map(l=>l[a]);return Vt(e,o,a).map(l=>()=>l)}},q$={kernelName:Ba,inputsToSave:["x","filter"],gradFunc:(e,t,n)=>{let[s,r]=t,{dilations:a,strides:o,pad:i,dataFormat:l}=n;return M(la(a),()=>`Error in gradient of conv2D: dilation rates greater than 1 are not yet supported in gradients. Got dilations '${a}'`),{x:()=>rA(s.shape,e,r,o,i,l),filter:()=>$A(s,e,r.shape,o,i,l)}}},X$={kernelName:Wa,inputsToSave:["dy","filter"],gradFunc:(e,t,n)=>{let[s,r]=t,{strides:a,pad:o,dataFormat:i,dimRoundingMode:l}=n;return{dy:()=>Tr(e,r,a,o,i,1,l),filter:()=>$A(e,s,r.shape,a,o,i,l)}}};function K$(e,t,n,s,r){let a=e;e.rank===4&&(a=V(e,[1,e.shape[0],e.shape[1],e.shape[2],e.shape[3]]));let o=t;o.rank===4&&(o=V(t,[1,t.shape[0],t.shape[1],t.shape[2],t.shape[3]])),M(a.rank===5,()=>`Error in conv3dDerFilter: input must be rank 5, but got shape ${a.shape}.`),M(o.rank===5,()=>`Error in conv3dDerFilter: dy must be rank 5, but got shape ${o.shape}.`),M(n.length===5,()=>`Error in conv3dDerFilter: filterShape must be length 5, but got ${n}.`),M(a.shape[4]===n[3],()=>`Error in conv3dDerFilter: depth of input ${a.shape[4]}) must match input depth in filter (${n[3]}.`),M(o.shape[4]===n[4],()=>`Error in conv3dDerFilter: depth of dy (${o.shape[4]}) must match output depth for filter (${n[4]}).`);let i={x:a,dy:o},l={strides:s,pad:r,filterShape:n};return L.runKernel(xp,i,l)}var Z$=W({conv3DBackpropFilter_:K$}),Y$={kernelName:Qu,inputsToSave:["x","filter"],gradFunc:(e,t,n)=>{let{dilations:s,strides:r,pad:a}=n;M(la(s),()=>`Error in gradient of conv3D: dilation rates greater than 1 are not yet supported in gradients. Got dilations '${s}'`);let[o,i]=t;return{x:()=>kb(o.shape,e,i,r,a),filter:()=>Z$(o,e,i.shape,r,a)}}},J$={kernelName:Va,inputsToSave:["x"],gradFunc:(e,t)=>{let[n]=t;return{x:()=>z(St(Eh(pe(n,"float32"))),e)}}},Q$={kernelName:Ua,inputsToSave:["x"],gradFunc:(e,t)=>{let[n]=t;return{x:()=>z(Rh(pe(n,"float32")),e)}}},eF={kernelName:Ha,inputsToSave:["x"],gradFunc:(e,t,n)=>{let[s]=t,{axis:r,exclusive:a,reverse:o}=n;return{x:()=>{let i=Ob([r],s.rank),l=Ah(e,r,a,!o);return i!=null&&(l=Ye(l,i)),l}}}},tF={kernelName:Ga,inputsToSave:["x","filter"],gradFunc:(e,t,n)=>{let{dilations:s,strides:r,pad:a,dimRoundingMode:o}=n,i=s==null?[1,1]:s;M(la(i),()=>`Error in gradient of depthwiseConv2dNative: dilation rates greater than 1 are not yet supported. Got dilations '${i}'`);let[l,u]=t;return M(l.rank===4,()=>`Error in gradient of depthwiseConv2dNative: input must be rank 4, but got rank ${l.rank}.`),M(u.rank===4,()=>`Error in gradient of depthwiseConv2dNative: filter must be rank 4, but got rank ${u.rank}.`),M(l.shape[3]===u.shape[2],()=>`Error in gradient of depthwiseConv2d: number of input channels (${l.shape[3]}) must match the inChannels dimension in filter ${u.shape[2]}.`),M(ar(r,i),()=>`Error in gradient of depthwiseConv2d: Either strides or dilations must be 1. Got strides ${r} and dilations '${i}'.`),o!=null&&M(sn(a),()=>`Error in depthwiseConv2d: pad must be an integer when using, dimRoundingMode ${o} but got pad ${a}.`),{x:()=>Zb(l.shape,e,u,r,a,i,o),filter:()=>Kb(l,e,u.shape,r,a,i,o)}}},nF={kernelName:ec,inputsToSave:["x","filter"],gradFunc:(e,t,n)=>{let[s,r]=t,a={x:s,filter:r,dy:e},o={x:s,filter:r,dy:e};return{x:()=>L.runKernel(Sp,a,n),filter:()=>L.runKernel(Cp,o,n)}}},sF={kernelName:qa,outputsToSave:[!0],gradFunc:(e,t)=>{let[n]=t,s={dy:e,y:n};return{x:()=>L.runKernel(Np,s)}}},rF={kernelName:Xi,inputsToSave:["x"],gradFunc:(e,t)=>{let[n]=t,s=z(ts(St(pt(n))),2/Math.sqrt(Math.PI));return{x:()=>z(e,s)}}},aF={kernelName:Xa,outputsToSave:[!0],gradFunc:(e,t)=>{let[n]=t;return{x:()=>z(e,n)}}},oF={kernelName:Zi,inputsToSave:["input"],gradFunc:(e,t)=>{let[n]=t;return{input:()=>V(e,n.shape)}}},iF={kernelName:Yi,inputsToSave:["x"],gradFunc:(e,t)=>{let[n]=t;return{x:()=>z(e,ts(n))}}},lF={kernelName:Ka,gradFunc:e=>({x:()=>Je(e)})},uF={kernelName:Za,inputsToSave:["a","b"],gradFunc:(e,t)=>{let[n,s]=t,r=bt(n.shape,s.shape);return{a:()=>{let i=he(e,pe(s,"float32")),l=Zt(n.shape,r);return l.length>0?V(we(i,l),n.shape):i},b:()=>{let i=z(e,pe(n,"float32")),l=Zt(s.shape,r);l.length>0&&(i=V(we(i,l),s.shape));let u=pt(s);return St(he(i,pe(u,"float32")))}}}},cF={kernelName:Ya,inputsToSave:["x","mean","variance","scale"],gradFunc:(e,t,n)=>{let{varianceEpsilon:s}=n,[r,a,o,i]=t,l=i==null?Ce(1):i,u=Zt(a.shape,r.shape),c=[];if(a.rank===1){for(let b=0;b<r.shape.length-1;++b)c.push(r.shape[b]);c.push(1)}let d=ye(r,a),p=z(e,l),h=Th(oe(o,Ce(s))),f=z(z(z(h,h),h),Ce(-.5));return{x:()=>a.rank===1?V(z(z(e,bs(V(h,[1,1,1,a.shape[0]]),c)),l),r.shape):V(z(z(e,h),l),r.shape),mean:()=>{let b=z(z(h,Ce(-1)),p);return a.rank===1&&(b=we(b,u)),V(b,a.shape)},variance:()=>{let b=z(z(f,d),p);return a.rank===1&&(b=we(b,u)),V(b,a.shape)},scale:()=>{let b=z(d,h),v=z(e,b);return a.rank===1&&(v=we(v,u)),V(v,a.shape)},offset:()=>{let b=e;return a.rank===1&&(b=we(b,u)),V(b,a.shape)}}}},dF={kernelName:Qi,inputsToSave:["x","indices"],gradFunc:(e,t,n)=>{let[s,r]=t,{axis:a}=n,o=Rs(a,s.shape)[0];return{x:()=>{let l=s.shape,u=r.size,c=l.slice(0,o),d=c.length,p=l.slice(a,l.length).slice(1),h=p.length,f=h3(0,d),m=h3(d+1,d+1+h),g=f3([c,[u],p]),A=V(e,g),y=V(r,[u]),x=f3([[d],f,m]),b=Ye(A,x),v=EA(b,y,s.shape[o]),k=mA(x);return v=Ye(v,k),v},indices:()=>r}}};function h3(e,t){let n=[];for(let s=e;s<t;++s)n.push(s);return n}function f3(e){let t=[];for(let n=0;n<e.length;++n)for(let s=0;s<e[n].length;++s)t.push(e[n][s]);return t}var pF={kernelName:Ja,inputsToSave:["a","b"],gradFunc:(e,t)=>{let[n,s]=t;return{a:()=>Je(n),b:()=>Je(s)}}},hF={kernelName:Qa,gradFunc:e=>({x:()=>pe(e,"float32")})},fF={kernelName:nl,gradFunc:e=>({x:()=>Je(e)})},mF={kernelName:sl,gradFunc:e=>({x:()=>Je(e)})},gF={kernelName:rl,gradFunc:e=>({x:()=>Je(e)})},AF={kernelName:eo,inputsToSave:["x"],gradFunc:(e,t,n)=>{let[s]=t,{alpha:r}=n,a=Vn(s,0);return{x:()=>vn(a,e,z(e,r))}}},yF={kernelName:il,inputsToSave:["x"],gradFunc:(e,t)=>{let[n]=t;return{x:()=>he(e,oe(n,1))}}},xF={kernelName:to,inputsToSave:["x"],gradFunc:(e,t)=>{let[n]=t;return{x:()=>he(e,pe(n,"float32"))}}},bF={kernelName:h5,inputsToSave:[],outputsToSave:[!0],gradFunc:(e,t,n)=>{let[s]=t,{axis:r}=n;return{logits:()=>{let a=!0,o=ts(s);return ye(e,z(we(e,r,a),o))}}}};function vF(e,t,n,s=5,r=1,a=1,o=.5){let i={x:e,y:t,dy:n},l={depthRadius:s,bias:r,alpha:a,beta:o};return L.runKernel($p,i,l)}var wF=W({localResponseNormalizationBackprop_:vF}),kF={kernelName:rc,inputsToSave:["x"],outputsToSave:[!0],gradFunc:(e,t,n)=>{let[s,r]=t,{depthRadius:a,bias:o,alpha:i,beta:l}=n;return{x:()=>wF(s,r,e,a,o,i,l)}}};function m3(e,t,n,s){return t.rank<n.rank&&(t=V(t,jo(t.shape,s))),e.rank<n.rank&&(e=V(e,jo(e.shape,s))),{x:()=>z(e,pe(es(n,t),e.dtype))}}var g3={kernelName:no,inputsToSave:["x"],outputsToSave:[!0],gradFunc:(e,t,n)=>{let s=n,{reductionIndices:r}=s,a=t[0],o=t[1],i=Rs(r,a.shape),l=m3(e,o,a,i);return{x:()=>l.x()}}},IF={kernelName:so,inputsToSave:["a","b"],gradFunc:(e,t)=>{let[n,s]=t;return{a:()=>z(e,pe(ua(n,s),"float32")),b:()=>z(e,pe(xh(n,s),"float32"))}}};function SF(e,t,n,s,r,a,o){let i=$(e,"dy","maxPool3dGrad"),l=$(t,"input","maxPool3dGrad"),u=$(n,"output","maxPool3dGrad"),c=i,d=l,p=u,h=!1;l.rank===4&&(h=!0,c=V(i,[1,i.shape[0],i.shape[1],i.shape[2],i.shape[3]]),d=V(l,[1,l.shape[0],l.shape[1],l.shape[2],l.shape[3]]),p=V(u,[1,u.shape[0],u.shape[1],u.shape[2],u.shape[3]])),M(c.rank===5,()=>`Error in maxPool3dGrad: dy must be rank 5 but got rank ${c.rank}.`),M(d.rank===5,()=>`Error in maxPool3dGrad: input must be rank 5 but got rank ${d.rank}.`),M(p.rank===5,()=>`Error in maxPool3dGrad: output must be rank 5 but got rank ${p.rank}.`),o!=null&&M(sn(a),()=>`Error in maxPool3dGrad: pad must be an integer when using, dimRoundingMode ${o} but got pad ${a}.`);let f={dy:c,input:d,output:p},m={filterSize:s,strides:r,pad:a,dimRoundingMode:o},g=L.runKernel(Op,f,m);return h?V(g,[g.shape[1],g.shape[2],g.shape[3],g.shape[4]]):g}var CF=W({maxPool3dGrad_:SF}),TF={kernelName:ac,inputsToSave:["x"],outputsToSave:[!0],gradFunc:(e,t,n)=>{let[s,r]=t,{filterSize:a,strides:o,pad:i,dimRoundingMode:l}=n;return{x:()=>CF(e,s,r,a,o,i,l)}}};function NF(e,t,n,s,r,a,o){let i=$(e,"dy","maxPoolGrad"),l=$(t,"input","maxPoolGrad"),u=$(n,"output","maxPoolGrad");M(l.rank===i.rank,()=>`Rank of input (${l.rank}) does not match rank of dy (${i.rank})`),M(i.rank===4,()=>`Error in maxPoolGrad: dy must be rank 4 but got rank ${i.rank}.`),M(l.rank===4,()=>`Error in maxPoolGrad: input must be rank 4 but got rank ${l.rank}.`),o!=null&&M(sn(a),()=>`Error in maxPoolGrad: pad must be an integer when using, dimRoundingMode ${o} but got pad ${a}.`);let c={dy:i,input:l,output:u},d={filterSize:s,strides:r,pad:a,dimRoundingMode:o};return L.runKernel(Fp,c,d)}var EF=W({maxPoolGrad_:NF}),RF={kernelName:ro,inputsToSave:["x"],outputsToSave:[!0],gradFunc:(e,t,n)=>{let[s,r]=t,{filterSize:a,strides:o,pad:i}=n;return{x:()=>EF(e,s,r,a,o,i)}}},DF={kernelName:ao,inputsToSave:["x"],gradFunc:(e,t,n)=>{let[s]=t,{axis:r}=n,a=Rs(r,s.shape),i=Fb(s.shape,a)[1],l=zt(i);return{x:()=>{let c=s.shape.slice();a.forEach(h=>{c[h]=1});let d=V(e,c);return he(z(d,rs(s.shape,"float32")),l)}}}},_F={kernelName:oo,inputsToSave:["x"],outputsToSave:[!0],gradFunc:(e,t,n)=>{let s=n,{axis:r}=s,[a,o]=t,i=Rs(r,a.shape),l=m3(e,o,a,i);return{x:()=>l.x()}}},$F={kernelName:io,inputsToSave:["a","b"],gradFunc:(e,t)=>{let[n,s]=t;return{a:()=>z(e,pe(ca(n,s),"float32")),b:()=>z(e,pe(Vn(n,s),"float32"))}}},FF={kernelName:lo,inputsToSave:["x"],gradFunc:(e,t,n)=>{let s=t[0],{paddings:r}=n,a=r.map(o=>o[0]);return{x:()=>_e(e,a,s.shape)}}},OF={kernelName:ul,inputsToSave:["a","b"],gradFunc:(e,t)=>{let[n,s]=t,r=bt(n.shape,s.shape);return{a:()=>{let i=Zt(n.shape,r);return i.length>0?V(we(e,i),n.shape):e},b:()=>{let i=z(e,St(Kl(he(n,s)))),l=Zt(s.shape,r);return l.length>0?V(we(i,l),s.shape):i}}}},PF={kernelName:uo,inputsToSave:["a","b"],gradFunc:(e,t)=>{let[n,s]=t,r=bt(n.shape,s.shape);return{a:()=>{let i=z(e,pe(s,"float32")),l=Zt(n.shape,r);return l.length>0?V(we(i,l),n.shape):i},b:()=>{let i=z(e,pe(n,"float32")),l=Zt(s.shape,r);return l.length>0?V(we(i,l),s.shape):i}}}},MF={kernelName:cl,gradFunc:e=>({x:()=>St(e)})},zF={kernelName:co,inputsToSave:["indices"],gradFunc:(e,t)=>{let n=t[0];return{indices:()=>Mt(n.shape,"float32")}}},LF={kernelName:ml,gradFunc:e=>({x:()=>Je(e)})},BF={kernelName:gl,saveAllInputs:!0,gradFunc:(e,t,n)=>{let{axis:s}=n;return is(e,s).map(a=>()=>a)}},A3={kernelName:po,inputsToSave:["x"],gradFunc:(e,t,n)=>{let s=t[0],{paddings:r}=n,a=r.map(o=>o[0]);return{x:()=>_e(e,a,s.shape)}}},WF={kernelName:ho,inputsToSave:["a","b"],outputsToSave:[!0],gradFunc:(e,t)=>{let[n,s,r]=t,a=n,o=s,i=bt(a.shape,o.shape);return{a:()=>{let c=pe(o,"float32"),d=z(e,z(c,Er(a,ye(c,Ce(1))))),p=Zt(a.shape,i);return p.length>0&&(d=we(d,p)),V(d,a.shape)},b:()=>{let c=Vn(a,0),d=vn(c,ns(a),Je(a)),p=z(e,z(r,d)),h=Zt(o.shape,i);return h.length>0&&(p=we(p,h)),V(p,o.shape)}}}},VF={kernelName:fo,inputsToSave:["x","alpha"],gradFunc:(e,t)=>{let[n,s]=t,r=Vn(n,0);return{x:()=>vn(r,e,z(e,s)),alpha:()=>{let a=vn(r,Je(e),z(e,n)),o=Zt(s.shape,e.shape);return o.length>0&&(a=we(a,o)),V(a,s.shape)}}}},UF={kernelName:ja,inputsToSave:["a","b"],gradFunc:(e,t)=>{let[n,s]=t,r=bt(n.shape,s.shape);return{a:()=>{let i=he(e,pe(s,"float32")),l=Zt(n.shape,r);return l.length>0?V(we(i,l),n.shape):i},b:()=>{let i=z(e,pe(n,"float32")),l=Zt(s.shape,r);l.length>0&&(i=V(we(i,l),s.shape));let u=pt(s);return St(he(i,pe(u,"float32")))}}}},HF={kernelName:yl,inputsToSave:["x"],gradFunc:(e,t)=>{let[n]=t;return{x:()=>he(e,St(pt(n)))}}},GF={kernelName:Ao,inputsToSave:["x"],gradFunc:(e,t)=>{let[n]=t,s=z(ca(n,6),eu(n));return{x:()=>z(e,pe(s,"float32"))}}},jF={kernelName:mo,inputsToSave:["x"],gradFunc:(e,t)=>{let[n]=t;return{x:()=>z(e,pe(eu(n),"float32"))}}},qF={kernelName:xl,inputsToSave:["x"],gradFunc:(e,t)=>{let[n]=t;return{x:()=>V(e,n.shape)}}},XF={kernelName:go,inputsToSave:["images"],gradFunc:(e,t,n)=>{let[s]=t,r={dy:e,images:s};return{images:()=>L.runKernel(Bp,r,n)}}},KF={kernelName:ic,inputsToSave:["images"],gradFunc:(e,t,n)=>{let[s]=t,r={dy:e,images:s};return{images:()=>L.runKernel(Lp,r,n)}}},ZF={kernelName:yo,gradFunc:(e,t,n)=>{let{dims:s}=n,r=Rs(s,e.shape);return{x:()=>os(e,r)}}},YF={kernelName:xo,gradFunc:e=>({x:()=>Je(e)})},JF={kernelName:bo,inputsToSave:["x"],gradFunc:(e,t)=>{let[n]=t;return{x:()=>St(he(e,z(Er(n,1.5),2)))}}},QF={kernelName:vl,inputsToSave:["condition"],gradFunc:(e,t)=>{let[n]=t;return{condition:()=>pe(Je(n),"float32"),t:()=>z(e,pe(n,e.dtype)),e:()=>z(e,pe(Ec(n),e.dtype))}}},eO={kernelName:wl,inputsToSave:["x"],gradFunc:(e,t)=>{let[n]=t;return{x:()=>{let s=Vn(n,Ce(0)),r=Ce(i3),a=Ce(l3),o=z(e,a),i=z(z(e,r),ts(pe(n,"float32")));return vn(s,o,i)}}}},tO={kernelName:wo,outputsToSave:[!0],gradFunc:(e,t)=>{let[n]=t;return{x:()=>z(e,z(n,ye(Ce(1),n)))}}},nO={kernelName:Sl,gradFunc:e=>({x:()=>Je(e)})},sO={kernelName:vo,inputsToSave:["x"],gradFunc:(e,t)=>{let[n]=t;return{x:()=>z(Cc(pe(n,"float32")),e)}}},rO={kernelName:Il,inputsToSave:["x"],gradFunc:(e,t)=>{let[n]=t;return{x:()=>z(gh(pe(n,"float32")),e)}}},aO={kernelName:kl,inputsToSave:["x"],gradFunc:(e,t,n)=>{let[s]=t,{begin:r,size:a}=n,o=s.shape,[i,l]=ob(s,r,a),u=[];for(let c=0;c<e.rank;c++)u.push([i[c],o[c]-i[c]-l[c]]);return{x:()=>Nr(e,u)}}},oO={kernelName:So,outputsToSave:[!0],gradFunc:(e,t,n)=>{let[s]=t,{dim:r}=n,a=!0,o=z(e,s);return{logits:()=>ye(o,z(we(o,[r],a),s))}}},iO={kernelName:Cl,inputsToSave:["x"],gradFunc:(e,t)=>{let[n]=t;return{x:()=>z(e,Bn(n))}}},y3={kernelName:Tl,gradFunc:(e,t,n)=>{let{blockShape:s,paddings:r}=n;return{x:()=>Sc(e,s,r)}}},x3={kernelName:Nl,gradFunc:(e,t,n)=>{let{axis:s}=n;return{x:()=>ft(e,s)}}},lO={kernelName:ko,inputsToSave:["x"],gradFunc:(e,t)=>{let[n]=t;return{x:()=>he(e,z(fn(pe(n,"float32")),2))}}},uO={kernelName:lc,inputsToSave:["x"],gradFunc:(e,t)=>{let[n]=t;return{x:()=>z(e,z(pe(n,"float32"),2))}}},cO={kernelName:Co,inputsToSave:["a","b"],gradFunc:(e,t)=>{let[n,s]=t,r=Ce(2);return{a:()=>z(e,z(r,ye(n,s))),b:()=>z(e,z(r,ye(s,n)))}}},dO={kernelName:ea,gradFunc:e=>({x:()=>Je(e)})},pO={kernelName:To,inputsToSave:["a","b"],gradFunc:(e,t)=>{let[n,s]=t,r=bt(n.shape,s.shape);return{a:()=>{let i=e,l=Zt(n.shape,r);return l.length>0&&(i=we(i,l)),V(i,n.shape)},b:()=>{let i=e,l=Zt(s.shape,r);return l.length>0&&(i=we(i,l)),V(St(i),s.shape)}}}},hO={kernelName:Io,inputsToSave:["x"],gradFunc:(e,t,n)=>{let[s]=t,r=s.shape.slice(),{axis:a}=n;Rs(a,s.shape).forEach(u=>{r[u]=1});let i=V(e,r),l=z(i,rs(s.shape,"float32"));return{x:()=>l}}},fO={kernelName:No,inputsToSave:["x"],gradFunc:(e,t)=>{let[n]=t;return{x:()=>he(e,pt(Cc(n)))}}},mO={kernelName:Eo,outputsToSave:[!0],gradFunc:(e,t)=>{let[n]=t;return{x:()=>z(ye(Ce(1),pt(n)),e)}}},gO={kernelName:Qr,inputsToSave:["x"],gradFunc:(e,t,n)=>{let[s]=t,{reps:r}=n;return{x:()=>{let o=Je(s);if(s.rank===1)for(let i=0;i<r[0];++i)o=oe(o,_e(e,[i*s.shape[0]],[s.shape[0]]));else if(s.rank===2)for(let i=0;i<r[0];++i)for(let l=0;l<r[1];++l)o=oe(o,_e(e,[i*s.shape[0],l*s.shape[1]],[s.shape[0],s.shape[1]]));else if(s.rank===3)for(let i=0;i<r[0];++i)for(let l=0;l<r[1];++l)for(let u=0;u<r[2];++u)o=oe(o,_e(e,[i*s.shape[0],l*s.shape[1],u*s.shape[2]],[s.shape[0],s.shape[1],s.shape[2]]));else if(s.rank===4)for(let i=0;i<r[0];++i)for(let l=0;l<r[1];++l)for(let u=0;u<r[2];++u)for(let c=0;c<r[3];++c)o=oe(o,_e(e,[i*s.shape[0],l*s.shape[1],u*s.shape[2],c*s.shape[3]],[s.shape[0],s.shape[1],s.shape[2],s.shape[3]]));else throw new Error(`Gradient for tile operation is not implemented for rank-${s.rank} tensors yet.`);return o}}}},AO={kernelName:Ro,gradFunc:(e,t,n)=>{let s=n,{perm:r}=s,a=mA(r);return{x:()=>Ye(e,a)}}},yO={kernelName:_l,gradFunc:(e,t,n)=>{let s=n,{axis:r}=s;return{value:()=>mn(e,r)}}},xO={kernelName:uc,inputsToSave:["segmentIds"],gradFunc:(e,t)=>{let[n]=t;return{x:()=>bO(e,n)}}};function bO(e,t){let n=ir(t,Je(t)),s=Ho(e,n),r=ua(t,Ce(0,"int32")),a=s.rank-r.rank;for(let i=0;i<a;++i)r=Lt(r,i+1);r=_s(r,rs(s.shape,"bool"));let o=Je(s);return vn(r,s,o)}var vO={kernelName:$l,gradFunc:e=>({x:()=>Je(e)})},wO=[p3,w$,k$,I$,S$,C$,T$,N$,E$,R$,D$,_$,O$,z$,L$,B$,W$,V$,U$,H$,G$,j$,X$,q$,Y$,J$,Q$,eF,tF,nF,UF,sF,rF,aF,oF,iF,uF,lF,cF,dF,pF,hF,fF,mF,gF,AF,yF,xF,bF,kF,g3,g3,IF,TF,RF,DF,_F,$F,FF,OF,PF,MF,zF,LF,BF,A3,A3,WF,VF,HF,GF,jF,qF,XF,KF,ZF,YF,JF,QF,eO,tO,nO,sO,rO,aO,oO,iO,y3,y3,x3,x3,lO,cO,uO,dO,pO,hO,fO,mO,gO,AO,yO,xO,vO];for(let e of wO)f5(e);ee().prototype.abs=function(){return this.throwIfDisposed(),Wt(this)};ee().prototype.acos=function(){return this.throwIfDisposed(),Gg(this)};ee().prototype.acosh=function(){return this.throwIfDisposed(),jg(this)};ee().prototype.add=function(e){return this.throwIfDisposed(),oe(this,e)};ee().prototype.all=function(e,t){return this.throwIfDisposed(),ph(this,e,t)};ee().prototype.any=function(e,t){return this.throwIfDisposed(),wc(this,e,t)};ee().prototype.argMax=function(e){return this.throwIfDisposed(),Ws(this,e)};ee().prototype.argMin=function(e){return this.throwIfDisposed(),qg(this,e)};ee().prototype.asScalar=function(){return this.throwIfDisposed(),M(this.size===1,()=>"The array must have only 1 element."),V(this,[])};ee().prototype.asType=function(e){return this.throwIfDisposed(),pe(this,e)};ee().prototype.as1D=function(){return this.throwIfDisposed(),V(this,[this.size])};ee().prototype.as2D=function(e,t){return this.throwIfDisposed(),V(this,[e,t])};ee().prototype.as3D=function(e,t,n){return this.throwIfDisposed(),V(this,[e,t,n])};ee().prototype.as4D=function(e,t,n,s){return this.throwIfDisposed(),V(this,[e,t,n,s])};ee().prototype.as5D=function(e,t,n,s,r){return this.throwIfDisposed(),V(this,[e,t,n,s,r])};ee().prototype.asin=function(){return this.throwIfDisposed(),Xg(this)};ee().prototype.asinh=function(){return this.throwIfDisposed(),Kg(this)};ee().prototype.atan=function(){return this.throwIfDisposed(),Zg(this)};ee().prototype.atan2=function(e){return this.throwIfDisposed(),Yg(this,e)};ee().prototype.atanh=function(){return this.throwIfDisposed(),Jg(this)};ee().prototype.avgPool=function(e,t,n,s){return this.throwIfDisposed(),Ic(this,e,t,n,s)};ee().prototype.batchToSpaceND=function(e,t){return this.throwIfDisposed(),Sc(this,e,t)};ee().prototype.batchNorm=function(e,t,n,s,r){return this.throwIfDisposed(),Uo(this,e,t,n,s,r)};ee().prototype.broadcastTo=function(e){return this.throwIfDisposed(),Hl(this,e)};ee().prototype.cast=function(e){return this.throwIfDisposed(),pe(this,e)};ee().prototype.ceil=function(){return this.throwIfDisposed(),sA(this)};ee().prototype.clipByValue=function(e,t){return this.throwIfDisposed(),Wn(this,e,t)};ee().prototype.concat=function(e,t){return this.throwIfDisposed(),e instanceof Ge&&(e=[e]),ft([this,...e],t)};ee().prototype.conv1d=function(e,t,n,s,r,a){return this.throwIfDisposed(),fh(this,e,t,n,s,r,a)};ee().prototype.conv2dTranspose=function(e,t,n,s,r){return this.throwIfDisposed(),mh(this,e,t,n,s,r)};ee().prototype.conv2d=function(e,t,n,s,r,a){return this.throwIfDisposed(),Tr(this,e,t,n,s,r,a)};ee().prototype.cos=function(){return this.throwIfDisposed(),Cc(this)};ee().prototype.cosh=function(){return this.throwIfDisposed(),gh(this)};ee().prototype.cumsum=function(e,t,n){return this.throwIfDisposed(),Ah(this,e,t,n)};ee().prototype.depthToSpace=function(e,t){return this.throwIfDisposed(),oA(this,e,t)};ee().prototype.depthwiseConv2d=function(e,t,n,s,r,a){return this.throwIfDisposed(),jl(this,e,t,n,s,r,a)};ee().prototype.dilation2d=function(e,t,n,s,r){return this.throwIfDisposed(),iA(this,e,t,n,s,r)};ee().prototype.divNoNan=function(e){return this.throwIfDisposed(),lA(this,e)};ee().prototype.div=function(e){return this.throwIfDisposed(),he(this,e)};ee().prototype.dot=function(e){return this.throwIfDisposed(),Cb(this,e)};ee().prototype.elu=function(){return this.throwIfDisposed(),ql(this)};ee().prototype.equal=function(e){return this.throwIfDisposed(),es(this,e)};ee().prototype.erf=function(){return this.throwIfDisposed(),uA(this)};ee().prototype.exp=function(){return this.throwIfDisposed(),ts(this)};ee().prototype.expandDims=function(e){return this.throwIfDisposed(),Lt(this,e)};ee().prototype.expm1=function(){return this.throwIfDisposed(),cA(this)};ee().prototype.fft=function(){return this.throwIfDisposed(),Mc(this)};ee().prototype.flatten=function(){return this.throwIfDisposed(),V(this,[this.size])};ee().prototype.floor=function(){return this.throwIfDisposed(),Kl(this)};ee().prototype.floorDiv=function(e){return this.throwIfDisposed(),ch(this,e)};ee().prototype.gather=function(e,t){return this.throwIfDisposed(),Ho(this,e,t)};ee().prototype.greaterEqual=function(e){return this.throwIfDisposed(),ua(this,e)};ee().prototype.greater=function(e){return this.throwIfDisposed(),Vn(this,e)};ee().prototype.ifft=function(){return this.throwIfDisposed(),Ql(this)};ee().prototype.irfft=function(){return this.throwIfDisposed(),$h(this)};ee().prototype.isFinite=function(){return this.throwIfDisposed(),Nb(this)};ee().prototype.isInf=function(){return this.throwIfDisposed(),Eb(this)};ee().prototype.isNaN=function(){return this.throwIfDisposed(),pA(this)};ee().prototype.leakyRelu=function(e){return this.throwIfDisposed(),Tc(this,e)};ee().prototype.lessEqual=function(e){return this.throwIfDisposed(),ca(this,e)};ee().prototype.less=function(e){return this.throwIfDisposed(),xh(this,e)};ee().prototype.localResponseNormalization=function(e,t,n,s){return this.throwIfDisposed(),hA(this,e,t,n,s)};ee().prototype.logSigmoid=function(){return this.throwIfDisposed(),_b(this)};ee().prototype.logSoftmax=function(e){return this.throwIfDisposed(),vh(this,e)};ee().prototype.logSumExp=function(e,t){return this.throwIfDisposed(),gA(this,e,t)};ee().prototype.log=function(){return this.throwIfDisposed(),ns(this)};ee().prototype.log1p=function(){return this.throwIfDisposed(),Nc(this)};ee().prototype.logicalAnd=function(e){return this.throwIfDisposed(),_s(this,e)};ee().prototype.logicalNot=function(){return this.throwIfDisposed(),Ec(this)};ee().prototype.logicalOr=function(e){return this.throwIfDisposed(),wh(this,e)};ee().prototype.logicalXor=function(e){return this.throwIfDisposed(),Pb(this,e)};ee().prototype.matMul=function(e,t,n){return this.throwIfDisposed(),Ue(this,e,t,n)};ee().prototype.maxPool=function(e,t,n,s){return this.throwIfDisposed(),Rc(this,e,t,n,s)};ee().prototype.max=function(e,t){return this.throwIfDisposed(),ss(this,e,t)};ee().prototype.maximum=function(e){return this.throwIfDisposed(),ir(this,e)};ee().prototype.mean=function(e,t){return this.throwIfDisposed(),Dt(this,e,t)};ee().prototype.min=function(e,t){return this.throwIfDisposed(),Dc(this,e,t)};ee().prototype.minimum=function(e){return this.throwIfDisposed(),Zl(this,e)};ee().prototype.mirrorPad=function(e,t){return this.throwIfDisposed(),yA(this,e,t)};ee().prototype.mod=function(e){return this.throwIfDisposed(),xA(this,e)};ee().prototype.mul=function(e){return this.throwIfDisposed(),z(this,e)};ee().prototype.neg=function(){return this.throwIfDisposed(),St(this)};ee().prototype.norm=function(e,t,n){return this.throwIfDisposed(),Mh(this,e,t,n)};ee().prototype.notEqual=function(e){return this.throwIfDisposed(),qo(this,e)};ee().prototype.oneHot=function(e,t=1,n=0){return this.throwIfDisposed(),Bl(this,e,t,n)};ee().prototype.onesLike=function(){return this.throwIfDisposed(),as(this)};ee().prototype.pad=function(e,t){return this.throwIfDisposed(),Nr(this,e,t)};ee().prototype.pool=function(e,t,n,s,r){return this.throwIfDisposed(),Lb(this,e,t,n,s,r)};ee().prototype.pow=function(e){return this.throwIfDisposed(),Er(this,e)};ee().prototype.prelu=function(e){return this.throwIfDisposed(),$c(this,e)};ee().prototype.prod=function(e,t){return this.throwIfDisposed(),Ih(this,e,t)};ee().prototype.reciprocal=function(){return this.throwIfDisposed(),wA(this)};ee().prototype.relu=function(){return this.throwIfDisposed(),Vs(this)};ee().prototype.relu6=function(){return this.throwIfDisposed(),Sh(this)};ee().prototype.reshapeAs=function(e){return this.throwIfDisposed(),V(this,e.shape)};ee().prototype.reshape=function(e){return this.throwIfDisposed(),V(this,e)};ee().prototype.resizeBilinear=function(e,t,n){return this.throwIfDisposed(),s3(this,e,t,n)};ee().prototype.resizeNearestNeighbor=function(e,t,n){return this.throwIfDisposed(),r3(this,e,t,n)};ee().prototype.reverse=function(e){return this.throwIfDisposed(),os(this,e)};ee().prototype.rfft=function(){return this.throwIfDisposed(),zc(this)};ee().prototype.round=function(){return this.throwIfDisposed(),Ch(this)};ee().prototype.rsqrt=function(){return this.throwIfDisposed(),Th(this)};ee().prototype.selu=function(){return this.throwIfDisposed(),Nh(this)};ee().prototype.separableConv2d=function(e,t,n,s,r,a){return this.throwIfDisposed(),kA(this,e,t,n,s,r,a)};ee().prototype.sigmoid=function(){return this.throwIfDisposed(),Bn(this)};ee().prototype.sign=function(){return this.throwIfDisposed(),IA(this)};ee().prototype.sin=function(){return this.throwIfDisposed(),Eh(this)};ee().prototype.sinh=function(){return this.throwIfDisposed(),Rh(this)};ee().prototype.slice=function(e,t){return this.throwIfDisposed(),_e(this,e,t)};ee().prototype.softmax=function(e){return this.throwIfDisposed(),Pc(this,e)};ee().prototype.softplus=function(){return this.throwIfDisposed(),Go(this)};ee().prototype.spaceToBatchND=function(e,t){return this.throwIfDisposed(),_c(this,e,t)};ee().prototype.split=function(e,t){return this.throwIfDisposed(),Vt(this,e,t)};ee().prototype.sqrt=function(){return this.throwIfDisposed(),fn(this)};ee().prototype.square=function(){return this.throwIfDisposed(),pt(this)};ee().prototype.squaredDifference=function(e){return this.throwIfDisposed(),Fh(this,e)};ee().prototype.squeeze=function(e){return this.throwIfDisposed(),lt(this,e)};ee().prototype.stack=function(e,t){this.throwIfDisposed();let n=e instanceof Ge?[this,e]:[this,...e];return mn(n,t)};ee().prototype.step=function(e){return this.throwIfDisposed(),eu(this,e)};ee().prototype.stridedSlice=function(e,t,n,s,r,a,o,i){return this.throwIfDisposed(),CA(this,e,t,n,s,r,a,o,i)};ee().prototype.sub=function(e){return this.throwIfDisposed(),ye(this,e)};ee().prototype.sum=function(e,t){return this.throwIfDisposed(),we(this,e,t)};ee().prototype.tan=function(){return this.throwIfDisposed(),TA(this)};ee().prototype.tanh=function(){return this.throwIfDisposed(),Vo(this)};ee().prototype.tile=function(e){return this.throwIfDisposed(),bs(this,e)};ee().prototype.toBool=function(){return this.throwIfDisposed(),pe(this,"bool")};ee().prototype.toFloat=function(){return this.throwIfDisposed(),pe(this,"float32")};ee().prototype.toInt=function(){return this.throwIfDisposed(),pe(this,"int32")};ee().prototype.topk=function(e,t){return this.throwIfDisposed(),NA(this,e,t)};ee().prototype.transpose=function(e){return this.throwIfDisposed(),Ye(this,e)};ee().prototype.unique=function(e){return this.throwIfDisposed(),Ph(this,e)};ee().prototype.unsortedSegmentSum=function(e,t){return this.throwIfDisposed(),EA(this,e,t)};ee().prototype.unstack=function(e){return this.throwIfDisposed(),is(this,e)};ee().prototype.where=function(e,t){return this.throwIfDisposed(),vn(e,this,t)};ee().prototype.zerosLike=function(){return this.throwIfDisposed(),Je(this)};var b3={};Le(b3,{maxNorm:()=>CO,minMaxNorm:()=>EO,nonNeg:()=>NO,unitNorm:()=>TO});var MA;function Yt(){return MA==null&&(MA=ia().epsilon()),MA}function Hs(){return"channelsLast"}var _r=class extends Error{constructor(e){super(e);Object.setPrototypeOf(this,_r.prototype)}},Gs=class extends Error{constructor(e){super(e);Object.setPrototypeOf(this,Gs.prototype)}},G=class extends Error{constructor(e){super(e);Object.setPrototypeOf(this,G.prototype)}},ze=class extends Error{constructor(e){super(e);Object.setPrototypeOf(this,ze.prototype)}},v3=class extends Error{constructor(e){super(e);Object.setPrototypeOf(this,v3.prototype)}};function Zo(e,t){if(Array.isArray(e)){let n=[];for(let s=0;s<t;s++)n=n.concat(e);return n}else{let n=new Array(t);return n.fill(e),n}}function ur(e,t){if(!e)throw new v3(t)}function w3(e,t){let n=0;for(let s of e)s===t&&n++;return n}function Un(e){return e.length===1?e[0]:e}function vt(e){return Array.isArray(e)?e:[e]}function $r(e){let n=e.replace(/(.)([A-Z][a-z0-9]+)/g,"$1_$2").replace(/([a-z])([A-Z])/g,"$1_$2").toLowerCase();return n[0]!=="_"?n:"private"+n}function Yo(e){return e.length<=1||e.indexOf("_")===-1?e:e.replace(/[_]+(\w|$)/g,(t,n)=>n.toUpperCase())}var $s={};function zA(e){if(e==null)return null;let t={};return t.className=e.getClassName(),t.config=e.getConfig(),t}function LA(e){if(!(e==null||typeof e!="object"))if(Array.isArray(e))e.forEach(t=>LA(t));else{let t=Object.keys(e);for(let n of t){let s=e[n];s!=null&&typeof s=="object"&&(!Array.isArray(s)&&s.type==="ndarray"&&typeof s.value=="number"?e[n]=s.value:LA(s))}}}function Wc(e,t={},n={},s="object",r=!1){if(typeof e=="string"){let a=e,o;if(a in n)o=n[a];else if(a in $s)o=$s[a];else if(o=t[a],o==null)throw new G(`Unknown ${s}: ${e}. This may be due to one of the following reasons:
|
|
1. The ${s} is defined in Python, in which case it needs to be ported to TensorFlow.js or your JavaScript code.
|
|
2. The custom ${s} is defined in JavaScript, but is not registered properly with tf.serialization.registerClass().`);return o}else{let a=e;if(a.className==null||a.config==null)throw new G(`${s}: Improper config format: ${JSON.stringify(a)}.
|
|
'className' and 'config' must set.`);let o=a.className,i,l;if(o in n?[i,l]=n[o]:o in $s?[i,l]=$s.className:o in t&&([i,l]=t[o]),i==null)throw new G(`Unknown ${s}: ${o}. This may be due to one of the following reasons:
|
|
1. The ${s} is defined in Python, in which case it needs to be ported to TensorFlow.js or your JavaScript code.
|
|
2. The custom ${s} is defined in JavaScript, but is not registered properly with tf.serialization.registerClass().`);if(l!=null){let u={};for(let h of Object.keys($s))u[h]=$s[h];for(let h of Object.keys(n))u[h]=n[h];let c=a.config;c.customObjects=u;let d=Object.assign({},$s);for(let h of Object.keys(n))$s[h]=n[h];LA(a.config);let p=l(i,a.config,n,r);return $s=Object.assign({},d),p}else{let u=Object.assign({},$s);for(let d of Object.keys(n))$s[d]=n[d];let c=new i(a.config);return $s=Object.assign({},u),c}}}function kO(e,t){return e<t?-1:e>t?1:0}function Zh(e,t){return-1*kO(e,t)}function pa(e){if(e==null)return e;let t=[];for(let n of e)t.indexOf(n)===-1&&t.push(n);return t}function IO(e){if(e==null)throw new G(`Invalid value in obj: ${JSON.stringify(e)}`);for(let t in e)if(e.hasOwnProperty(t))return!1;return!0}function Jo(e,t,n){if(n!=null&&e.indexOf(n)<0)throw new G(`${n} is not a valid ${t}. Valid values are ${e} or null/undefined.`)}function BA(e,t,n=0,s=1/0){return ur(n>=0),ur(s>=n),Array.isArray(e)&&e.length>=n&&e.length<=s&&e.every(r=>typeof r===t)}function ln(e,t){Array.isArray(e)?(w.assert(e.length>0,()=>`${t} is unexpectedly an empty array.`),e.forEach((n,s)=>ln(n,`element ${s+1} of ${t}`))):w.assert(Number.isInteger(e)&&e>0,()=>`Expected ${t} to be a positive integer, but got ${k3(e)}.`)}function k3(e){return e===null?"null":Array.isArray(e)?"["+e.map(t=>k3(t)).join(",")+"]":typeof e=="string"?`"${e}"`:`${e}`}function SO(e,t){let n=w.now(),s;return(...a)=>{let o=w.now();return o-n<t||(n=o,s=e(...a)),s}}function I3(e){return e==="relu"?"relu":e==="linear"?"linear":e==="elu"?"elu":null}function WA(e,t){return H(()=>fn(we(z(e,e),t,!0)))}var Vc=class extends le.Serializable{getConfig(){return{}}},VA=class extends Vc{constructor(e){super();this.defaultMaxValue=2,this.defaultAxis=0,this.maxValue=e.maxValue!=null?e.maxValue:this.defaultMaxValue,this.axis=e.axis!=null?e.axis:this.defaultAxis}apply(e){return H(()=>{let t=WA(e,this.axis),n=Wn(t,0,this.maxValue);return z(e,he(n,oe(Yt(),t)))})}getConfig(){return{maxValue:this.maxValue,axis:this.axis}}};VA.className="MaxNorm";le.registerClass(VA);var UA=class extends Vc{constructor(e){super();this.defaultAxis=0,this.axis=e.axis!=null?e.axis:this.defaultAxis}apply(e){return H(()=>he(e,oe(Yt(),WA(e,this.axis))))}getConfig(){return{axis:this.axis}}};UA.className="UnitNorm";le.registerClass(UA);var HA=class extends Vc{apply(e){return Vs(e)}};HA.className="NonNeg";le.registerClass(HA);var GA=class extends Vc{constructor(e){super();this.defaultMinValue=0,this.defaultMaxValue=1,this.defaultRate=1,this.defaultAxis=0,this.minValue=e.minValue!=null?e.minValue:this.defaultMinValue,this.maxValue=e.maxValue!=null?e.maxValue:this.defaultMaxValue,this.rate=e.rate!=null?e.rate:this.defaultRate,this.axis=e.axis!=null?e.axis:this.defaultAxis}apply(e){return H(()=>{let t=WA(e,this.axis),n=oe(z(this.rate,Wn(t,this.minValue,this.maxValue)),z(1-this.rate,t));return z(e,he(n,oe(Yt(),t)))})}getConfig(){return{minValue:this.minValue,maxValue:this.maxValue,rate:this.rate,axis:this.axis}}};GA.className="MinMaxNorm";le.registerClass(GA);var S3={maxNorm:"MaxNorm",minMaxNorm:"MinMaxNorm",nonNeg:"NonNeg",unitNorm:"UnitNorm"};function Jt(e){return zA(e)}function C3(e,t={}){return Wc(e,le.SerializationMap.getMap().classNameMap,t,"constraint")}function Qt(e){if(e==null)return null;if(typeof e=="string"){let n={className:e in S3?S3[e]:e,config:{}};return C3(n)}else return e instanceof Vc?e:C3(e)}function CO(e){return new VA(e)}function TO(e){return new UA(e)}function NO(){return new HA}function EO(e){return new GA(e)}var T3={};Le(T3,{constant:()=>JO,glorotNormal:()=>aP,glorotUniform:()=>rP,heNormal:()=>oP,heUniform:()=>iP,identity:()=>nP,leCunNormal:()=>lP,leCunUniform:()=>uP,ones:()=>YO,orthogonal:()=>cP,randomNormal:()=>eP,randomUniform:()=>QO,truncatedNormal:()=>tP,varianceScaling:()=>sP,zeros:()=>ZO});var RO=["channelsFirst","channelsLast"],DO=["nearest","bilinear"],_O=["valid","same","causal"],$O=["max","avg"],FO=["sum","mul","concat","ave"],nu=new Map;function Bt(e){Jo(RO,"DataFormat",e)}function OO(e){Jo(DO,"InterpolationFormat",e)}function vs(e){Jo(_O,"PaddingMode",e)}function N3(e){Jo($O,"PoolMode",e)}var Uc=[],E3="/";function Qo(e,t){Uc.push(e);try{let n=t();return Uc.pop(),n}catch(n){throw Uc.pop(),n}}function PO(){return Uc.length===0?"":Uc.join(E3)+E3}function R3(e){if(!_3(e))throw new Error("Not a valid tensor name: '"+e+"'");return PO()+e}function D3(e){if(!_3(e))throw new Error("Not a valid tensor name: '"+e+"'");nu.has(e)||nu.set(e,0);let t=nu.get(e);if(nu.set(e,nu.get(e)+1),t>0){let n=`${e}_${t}`;return nu.set(n,1),n}else return e}var MO=new RegExp(/^[A-Za-z0-9][-A-Za-z0-9\._\/]*$/);function _3(e){return!!e.match(MO)}function zO(e){return e===parseInt(e.toString(),10)}function ha(e,t,n){t==null&&(t=0),n==null&&(n=e.length);let s=1;for(let r=t;r<n;++r)s*=e[r];return s}function su(e){if(e.length===0)return Number.NaN;let t=Number.POSITIVE_INFINITY;for(let n=0;n<e.length;n++){let s=e[n];s<t&&(t=s)}return t}function fa(e){if(e.length===0)return Number.NaN;let t=Number.NEGATIVE_INFINITY;for(let n=0;n<e.length;n++){let s=e[n];s>t&&(t=s)}return t}function js(e,t){if(t<e)throw new G(`end (${t}) < begin (${e}) is forbidden.`);let n=[];for(let s=e;s<t;++s)n.push(s);return n}function Yh(e,t){return pe(e,t)}function Hc(e,t=-1){let n=e.shape.slice();return t<0&&(t=n.length+t+1),n.splice(t,0,1),V(e,n)}function LO(e,t){return H(()=>{if(e.shape.length!==2)throw new G(`repeat() expects a rank-2 tensor, but received a rank-${e.shape.length} tensor.`);let n=Hc(e,1);return XA(n,[1,t,1])})}function BO(e){let t=[ha(e.shape)];return V(e,t)}function WO(e){if(e.rank<=1)throw new G(`batchFlatten requires a minimum rank of 2. Got rank: ${e.rank}.`);let t=[e.shape[0],ha(e.shape,1)];return V(e,t)}function ei(e,t,n){return H(()=>{switch(e.rank){case 1:return Dh(e,t,n);case 2:return SA(e,[t,0],[n,e.shape[1]]);case 3:return _h(e,[t,0,0],[n,e.shape[1],e.shape[2]]);case 4:return Oc(e,[t,0,0,0],[n,e.shape[1],e.shape[2],e.shape[3]]);case 5:return _e(e,[t,0,0,0,0],[n,e.shape[1],e.shape[2],e.shape[3],e.shape[4]]);case 6:return _e(e,[t,0,0,0,0,0],[n,e.shape[1],e.shape[2],e.shape[3],e.shape[4],e.shape[5]]);default:throw new G(`sliceAlongFirstAxis() received an unsupported tensor rank: ${e.rank}`)}})}function jA(e,t,n){return H(()=>{switch(e.rank){case 1:return Dh(e,t,n);case 2:return SA(e,[0,t],[e.shape[0],n]);case 3:return _h(e,[0,0,t],[e.shape[0],e.shape[1],n]);case 4:return Oc(e,[0,0,0,t],[e.shape[0],e.shape[1],e.shape[2],n]);default:throw new G(`sliceAlongLastAxis() received an unsupported tensor rank: ${e.rank}`)}})}function Jh(e,t,n,s){return H(()=>{switch(e.rank){case 1:return Dh(e,t,n);case 2:switch(s){case 1:return ei(e,t,n);case 2:return jA(e,t,n);default:throw new G(`The axis is not within the rank of the tensor ${s}`)}case 3:switch(s){case 1:return ei(e,t,n);case 2:return _h(e,[0,t,0],[e.shape[0],n,e.shape[2]]);case 3:return jA(e,t,n);default:throw new G(`The axis is not within the rank of the tensor ${s}`)}case 4:switch(s){case 1:return ei(e,t,n);case 2:return Oc(e,[0,t,0,0],[e.shape[0],n,e.shape[2],e.shape[3]]);case 3:return Oc(e,[0,0,t,0],[e.shape[0],e.shape[1],n,e.shape[3]]);case 4:return jA(e,t,n);default:throw new G(`The axis is not within the rank of the tensor ${s}`)}default:throw new G(`sliceAlongLastAxis() received an unsupported tensor rank: ${e.rank}`)}})}function qA(e,t=-1){let n;return t<0&&(n=e[0].rank,n!==0?t=n:t=0),t===e[0].rank&&(t=-1),ft(e,t)}function $3(e,t){switch(e.rank){case 1:return bb([e,t]);case 2:return Gl([e,t],0);case 3:return vb([e,t],0);case 4:return wb([e,t],0);default:throw new G(`concatAlongFirstAxis() received an unsupported tensor rank: ${e.rank}`)}}function XA(e,t){if(Array.isArray(t)||(t=[t]),e.rank!==t.length)throw new G(`The length of input n (${t.length}) does not match the number of dimensions in input x (${e.rank})`);return bs(e,t)}function Qh(e,t=0,n=1,s,r){return Bb(e,t,n,s,r)}function cr(e,t,n,s){if(e.rank<2||t.rank<2)throw new ze(`dot requires both inputs to be rank >= 2 but got x shape = ${e.shape} and y shape = ${t.shape}`);if(t.rank>=3){let r=e.shape.slice(-1)[0],a=t.shape.slice(-2)[0];if(r!==a)throw new ze(`If rank y >= 3, then the second last dim of y must equal the last dim of x but got x shape = ${e.shape} and y shape = ${t.shape}`)}if(e.rank===2&&t.rank===2){let r=!1,a=!1;return da.matMul({a:e,b:t,transposeA:r,transposeB:a,bias:s?KA(e.rank,s,Hs()):null,activation:n})}else{let r=e.shape.slice(),a=r.pop();e=V(e,[-1,a]);let o=t.shape.slice(),i=o.pop(),l=o.pop(),u=[...o,i],c=Array.from({length:t.rank},(f,m)=>m===0?t.rank-2:m<=t.rank-2?m-1:m);t=V(Ye(t,c),[l,-1]);let d=[...r,...u],p=!1,h=!1;return V(da.matMul({a:e,b:t,transposeA:p,transposeB:h,bias:s?KA(e.rank,s,Hs()):null,activation:n}),d)}}function F3(e,t,n){return H(()=>(Array.isArray(t)?t=Ut(t,"int32"):t=pe(t,"int32"),Ho(e,t,n)))}function Gc(e){return z(e,e)}function KA(e,t,n){let s=t.shape;if(t.rank!==1&&t.rank!==e)throw new G(`Unexpected bias dimensions: ${t.rank}; expected it to be 1 or ${e}`);if(e===5){if(n==="channelsFirst")return s.length===1?V(t,[1,s[0],1,1,1]):V(t,[1,s[3],s[0],s[1],s[2]]);if(n==="channelsLast")return s.length===1?V(t,[1,1,1,1,s[0]]):V(t,[1].concat(s))}else if(e===4){if(n==="channelsFirst")return s.length===1?V(t,[1,s[0],1,1]):V(t,[1,s[2],s[0],s[1]]);if(n==="channelsLast")return s.length===1?V(t,[1,1,1,s[0]]):V(t,[1].concat(s))}else if(e===3){if(n==="channelsFirst")return s.length===1?V(t,[1,s[0],1]):V(t,[1,s[1],s[0]]);if(n==="channelsLast")return s.length===1?V(t,[1,1,s[0]]):V(t,[1].concat(s))}else if(e<3)return t;throw new G(`Unsupported input rank by biasAdd: ${t.rank}`)}function qs(e,t,n){return H(()=>(n==null&&(n=Hs()),Bt(n),oe(e,KA(e.rank,t,n))))}function VO(e,t=1){if(t!==1)throw new ze(`Support for alpha values other than 1 (${t}) is not implemented yet.`);return ql(e)}function UO(e){return H(()=>he(e,oe(Wt(e),1)))}function O3(e,t,n,s){return H(()=>qb(e,t,n,s))}function HO(e){return H(()=>{let t=oe(.5,z(.2,e));return Wn(t,0,1)})}function jc(e,t,n=!1){return n?e():t()}var GO=["fanIn","fanOut","fanAvg"],jO=["normal","uniform","truncatedNormal"];function qO(e){Jo(GO,"FanMode",e)}function XO(e){Jo(jO,"Distribution",e)}var Fs=class extends le.Serializable{fromConfigUsesCustomObjects(){return!1}getConfig(){return{}}},ZA=class extends Fs{apply(e,t){return Mt(e,t)}};ZA.className="Zeros";le.registerClass(ZA);var ef=class extends Fs{apply(e,t){return rs(e,t)}};ef.className="Ones";le.registerClass(ef);var YA=class extends Fs{constructor(e){super();if(typeof e!="object")throw new G(`Expected argument of type ConstantConfig but got ${e}`);if(e.value===void 0)throw new G(`config must have value set but got ${e}`);this.value=e.value}apply(e,t){return H(()=>z(Ce(this.value),rs(e,t)))}getConfig(){return{value:this.value}}};YA.className="Constant";le.registerClass(YA);var JA=class extends Fs{constructor(e){super();this.DEFAULT_MINVAL=-.05,this.DEFAULT_MAXVAL=.05,this.minval=e.minval||this.DEFAULT_MINVAL,this.maxval=e.maxval||this.DEFAULT_MAXVAL,this.seed=e.seed}apply(e,t){return Yl(e,this.minval,this.maxval,t)}getConfig(){return{minval:this.minval,maxval:this.maxval,seed:this.seed}}};JA.className="RandomUniform";le.registerClass(JA);var QA=class extends Fs{constructor(e){super();this.DEFAULT_MEAN=0,this.DEFAULT_STDDEV=.05,this.mean=e.mean||this.DEFAULT_MEAN,this.stddev=e.stddev||this.DEFAULT_STDDEV,this.seed=e.seed}apply(e,t){if(t=t||"float32",t!=="float32"&&t!=="int32")throw new ze(`randomNormal does not support dType ${t}.`);return Qh(e,this.mean,this.stddev,t,this.seed)}getConfig(){return{mean:this.mean,stddev:this.stddev,seed:this.seed}}};QA.className="RandomNormal";le.registerClass(QA);var e1=class extends Fs{constructor(e){super();this.DEFAULT_MEAN=0,this.DEFAULT_STDDEV=.05,this.mean=e.mean||this.DEFAULT_MEAN,this.stddev=e.stddev||this.DEFAULT_STDDEV,this.seed=e.seed}apply(e,t){if(t=t||"float32",t!=="float32"&&t!=="int32")throw new ze(`truncatedNormal does not support dType ${t}.`);return Oh(e,this.mean,this.stddev,t,this.seed)}getConfig(){return{mean:this.mean,stddev:this.stddev,seed:this.seed}}};e1.className="TruncatedNormal";le.registerClass(e1);var t1=class extends Fs{constructor(e){super();this.gain=e.gain!=null?e.gain:1}apply(e,t){return H(()=>{if(e.length!==2||e[0]!==e[1])throw new G("Identity matrix initializer can only be used for 2D square matrices.");return z(this.gain,dA(e[0]))})}getConfig(){return{gain:this.gain}}};t1.className="Identity";le.registerClass(t1);function KO(e,t="channelsLast"){let n,s;if(Bt(t),e.length===2)n=e[0],s=e[1];else if([3,4,5].indexOf(e.length)!==-1){if(t==="channelsFirst"){let r=ha(e,2);n=e[1]*r,s=e[0]*r}else if(t==="channelsLast"){let r=ha(e,0,e.length-2);n=e[e.length-2]*r,s=e[e.length-1]*r}}else{let r=ha(e);n=Math.sqrt(r),s=Math.sqrt(r)}return[n,s]}var Hn=class extends Fs{constructor(e){super();if(e.scale<0)throw new G(`scale must be a positive float. Got: ${e.scale}`);this.scale=e.scale==null?1:e.scale,this.mode=e.mode==null?"fanIn":e.mode,qO(this.mode),this.distribution=e.distribution==null?"normal":e.distribution,XO(this.distribution),this.seed=e.seed}apply(e,t){let n=KO(e),s=n[0],r=n[1],a=this.scale;if(this.mode==="fanIn"?a/=Math.max(1,s):this.mode==="fanOut"?a/=Math.max(1,r):a/=Math.max(1,(s+r)/2),this.distribution==="normal"){let o=Math.sqrt(a);if(t=t||"float32",t!=="float32"&&t!=="int32")throw new ze(`${this.getClassName()} does not support dType ${t}.`);return Oh(e,0,o,t,this.seed)}else{let o=Math.sqrt(3*a);return Yl(e,-o,o,t)}}getConfig(){return{scale:this.scale,mode:this.mode,distribution:this.distribution,seed:this.seed}}};Hn.className="VarianceScaling";le.registerClass(Hn);var tf=class extends Hn{constructor(e){super({scale:1,mode:"fanAvg",distribution:"uniform",seed:e==null?null:e.seed})}getClassName(){return Hn.className}};tf.className="GlorotUniform";le.registerClass(tf);var nf=class extends Hn{constructor(e){super({scale:1,mode:"fanAvg",distribution:"normal",seed:e==null?null:e.seed})}getClassName(){return Hn.className}};nf.className="GlorotNormal";le.registerClass(nf);var sf=class extends Hn{constructor(e){super({scale:2,mode:"fanIn",distribution:"normal",seed:e==null?null:e.seed})}getClassName(){return Hn.className}};sf.className="HeNormal";le.registerClass(sf);var rf=class extends Hn{constructor(e){super({scale:2,mode:"fanIn",distribution:"uniform",seed:e==null?null:e.seed})}getClassName(){return Hn.className}};rf.className="HeUniform";le.registerClass(rf);var af=class extends Hn{constructor(e){super({scale:1,mode:"fanIn",distribution:"normal",seed:e==null?null:e.seed})}getClassName(){return Hn.className}};af.className="LeCunNormal";le.registerClass(af);var of=class extends Hn{constructor(e){super({scale:1,mode:"fanIn",distribution:"uniform",seed:e==null?null:e.seed})}getClassName(){return Hn.className}};of.className="LeCunNormal";le.registerClass(of);var n1=class extends Fs{constructor(e){super();if(this.DEFAULT_GAIN=1,this.gain=e.gain==null?this.DEFAULT_GAIN:e.gain,this.seed=e.seed,this.seed!=null)throw new ze("Random seed is not implemented for Orthogonal Initializer yet.")}apply(e,t){return H(()=>{if(e.length<2)throw new ze("Shape must be at least 2D.");e[0]*e[1]>2e3&&console.warn(`Orthogonal initializer is being called on a matrix with more than 2000 (${e[0]*e[1]}) elements: Slowness may result.`);let n=e[0]>e[1]?[e[1],e[0]]:e,s=Qh(n,0,1,"float32"),r=o3.gramSchmidt(s);return e[0]>e[1]&&(r=Ye(r)),z(this.gain,r)})}getConfig(){return{gain:this.gain,seed:this.seed}}};n1.className="Orthogonal";le.registerClass(n1);var P3={constant:"Constant",glorotNormal:"GlorotNormal",glorotUniform:"GlorotUniform",heNormal:"HeNormal",heUniform:"HeUniform",identity:"Identity",leCunNormal:"LeCunNormal",leCunUniform:"LeCunUniform",ones:"Ones",orthogonal:"Orthogonal",randomNormal:"RandomNormal",randomUniform:"RandomUniform",truncatedNormal:"TruncatedNormal",varianceScaling:"VarianceScaling",zeros:"Zeros"};function M3(e,t={}){return Wc(e,le.SerializationMap.getMap().classNameMap,t,"initializer")}function _t(e){return zA(e)}function Ct(e){if(typeof e=="string"){let t=e in P3?P3[e]:e;if(t==="GlorotNormal")return new nf;if(t==="GlorotUniform")return new tf;if(t==="HeNormal")return new sf;if(t==="HeUniform")return new rf;if(t==="LeCunNormal")return new af;if(t==="LeCunUniform")return new of;{let n={};return n.className=t,n.config={},M3(n)}}else return e instanceof Fs?e:M3(e)}function ZO(){return new ZA}function YO(){return new ef}function JO(e){return new YA(e)}function QO(e){return new JA(e)}function eP(e){return new QA(e)}function tP(e){return new e1(e)}function nP(e){return new t1(e)}function sP(e){return new Hn(e)}function rP(e){return new tf(e)}function aP(e){return new nf(e)}function oP(e){return new sf(e)}function iP(e){return new rf(e)}function lP(e){return new af(e)}function uP(e){return new of(e)}function cP(e){return new n1(e)}var z3={};Le(z3,{Layer:()=>et,RNN:()=>hr,RNNCell:()=>td,activation:()=>jM,add:()=>tz,alphaDropout:()=>zz,average:()=>nz,averagePooling1d:()=>b2,averagePooling2d:()=>v2,averagePooling3d:()=>w2,avgPool1d:()=>dz,avgPool2d:()=>hz,avgPool3d:()=>mz,avgPooling1d:()=>pz,avgPooling2d:()=>fz,avgPooling3d:()=>gz,batchNormalization:()=>lz,bidirectional:()=>Rz,concatenate:()=>sz,conv1d:()=>MM,conv2d:()=>zM,conv2dTranspose:()=>LM,conv3d:()=>BM,conv3dTranspose:()=>WM,convLstm2d:()=>Cz,convLstm2dCell:()=>Tz,cropping2D:()=>UM,dense:()=>qM,depthwiseConv2d:()=>GM,dot:()=>iz,dropout:()=>XM,elu:()=>DM,embedding:()=>ez,flatten:()=>ZM,gaussianDropout:()=>Mz,gaussianNoise:()=>Pz,globalAveragePooling1d:()=>Az,globalAveragePooling2d:()=>yz,globalMaxPool1d:()=>_z,globalMaxPool2d:()=>$z,globalMaxPooling1d:()=>qv,globalMaxPooling2d:()=>Xv,gru:()=>bz,gruCell:()=>vz,input:()=>Av,inputLayer:()=>RM,layerNormalization:()=>uz,leakyReLU:()=>$M,lstm:()=>wz,lstmCell:()=>kz,masking:()=>Lz,maxPool1d:()=>Fz,maxPool2d:()=>Oz,maxPooling1d:()=>Kv,maxPooling2d:()=>Zv,maxPooling3d:()=>xz,maximum:()=>rz,minimum:()=>az,multiply:()=>oz,permute:()=>QM,prelu:()=>FM,reLU:()=>_M,repeatVector:()=>YM,reshape:()=>JM,rnn:()=>Nz,separableConv2d:()=>VM,simpleRNN:()=>Iz,simpleRNNCell:()=>Sz,softmax:()=>OM,spatialDropout1d:()=>KM,stackedRNNCells:()=>Ez,thresholdedReLU:()=>PM,timeDistributed:()=>Dz,upSampling2d:()=>HM,zeroPadding2d:()=>cz});var dP=0;function L3(){return dP++}var lf={};function uf(e=""){return e in lf||(lf[e]=0),lf[e]+=1,e+lf[e].toString()}function s1(e){return Array.isArray(e)&&Array.isArray(e[0])}function cf(e){return e.length===0?[]:Array.isArray(e[0])?e:[e]}function We(e){let t;if(Array.isArray(e)){if(e.length!==1)throw new G(`Expected Tensor length to be 1; got ${e.length}`);t=e[0]}else t=e;return t}function ut(e){if(Array.isArray(e)&&Array.isArray(e[0])){if(e.length===1)return e=e,e[0];throw new G(`Expected exactly 1 Shape; got ${e.length}`)}else return e}function df(e){let t=0;for(let n of e)n.shape.length===0?t+=1:t+=n.shape.reduce((s,r)=>s*r);return t}var B3="Variable",W3=class{constructor(e,t="float32",n=B3,s=!0,r=null){this.dtype=t==null?"float32":t,this.shape=e.shape,this.id=L3(),n=n==null?B3:n,this.originalName=R3(n),this.name=D3(this.originalName),this.trainable_=s,this.constraint=r,this.val=Vb(e,this.trainable_,this.name,this.dtype)}read(){return this.assertNotDisposed(),this.val}write(e){return this.assertNotDisposed(),pP(this.val,e),this.val.id!==e.id&&(this.val.assign(e),this.constraint!=null&&this.val.assign(this.constraint.apply(this.val))),this}dispose(){this.assertNotDisposed(),this.val.dispose()}assertNotDisposed(){if(this.val.isDisposed)throw new Error(`LayersVariable ${this.name} is already disposed.`)}get trainable(){return this.trainable_}set trainable(e){this.trainable_=e,this.val.trainable=e}};function pP(e,t){if(e.shape.toString()!==t.shape.toString())throw new Error("Shape mismatch: "+JSON.stringify(e.shape)+" vs. "+JSON.stringify(t.shape))}function r1(e){return e.map(t=>t.read())}function a1(e){e.forEach(t=>{t[0].write(t[1])})}var Ht=class{constructor(e){this.dtype=e.dtype,this.shape=e.shape,e.shape!=null?this.ndim=e.shape.length:this.ndim=e.ndim,this.maxNDim=e.maxNDim,this.minNDim=e.minNDim,this.axes=e.axes||{}}},Xs=class{constructor(e,t,n,s,r,a,o){this.dtype=e,this.shape=t,this.sourceLayer=n,this.inputs=s,this.callArgs=r,this.outputTensorIndex=o,this.id=L3(),a!=null&&(this.originalName=R3(a),this.name=D3(this.originalName)),this.rank=t.length}},hP=0,pf=class{constructor(e,t){this.callArgs=t,this.id=hP++,this.outboundLayer=e.outboundLayer,this.inboundLayers=e.inboundLayers,this.nodeIndices=e.nodeIndices,this.tensorIndices=e.tensorIndices,this.inputTensors=e.inputTensors,this.outputTensors=e.outputTensors,this.inputMasks=e.inputMasks,this.outputMasks=e.outputMasks,this.inputShapes=e.inputShapes,this.outputShapes=e.outputShapes;for(let n of e.inboundLayers)n!=null&&n.outboundNodes.push(this);e.outboundLayer.inboundNodes.push(this)}getConfig(){let e=[];for(let t of this.inboundLayers)t!=null?e.push(t.name):e.push(null);return{outboundLayer:this.outboundLayer?this.outboundLayer.name:null,inboundLayers:e,nodeIndices:this.nodeIndices,tensorIndices:this.tensorIndices}}},fP=0,et=class extends le.Serializable{constructor(e={}){super();this._callHook=null,this._addedWeightNames=[],this._stateful=!1,this.id=fP++,this.activityRegularizer=null,this.inputSpec=null,this.supportsMasking=!1,this._trainableWeights=[],this._nonTrainableWeights=[],this._losses=[],this._updates=[],this._built=!1,this.inboundNodes=[],this.outboundNodes=[];let t=e.name;if(!t){let n=this.getClassName();t=$r(n)+"_"+uf(n)}if(this.name=t,this.trainable_=e.trainable==null?!0:e.trainable,e.inputShape!=null||e.batchInputShape!=null){let n;if(e.batchInputShape!=null)n=e.batchInputShape;else if(e.inputShape!=null){let r=null;e.batchSize!=null&&(r=e.batchSize),n=[r].concat(e.inputShape)}this.batchInputShape=n;let s=e.dtype;s==null&&(s=e.inputDType),s==null&&(s="float32"),this.dtype=s}e.weights!=null?this.initialWeights=e.weights:this.initialWeights=null,this._refCount=null,this.fastWeightInitDuringBuild=!1}static nodeKey(e,t){return e.name+"_ib-"+t.toString()}getNodeAtIndex(e,t){if(this.inboundNodes.length===0)throw new Gs(`The layer has never been called and thus has no defined ${t}.`);if(this.inboundNodes.length<=e)throw new G(`Asked to get ${t} at node ${e}, but the layer has only ${this.inboundNodes.length} inbound nodes.`);return this.inboundNodes[e]}getInputAt(e){return Un(this.getNodeAtIndex(e,"input").inputTensors)}getOutputAt(e){return Un(this.getNodeAtIndex(e,"output").outputTensors)}get input(){if(this.inboundNodes.length>1)throw new _r(`Layer ${this.name} has multiple inbound nodes, hence the notion of "layer input" is ill-defined. Use \`getInputAt(nodeIndex)\` instead.`);if(this.inboundNodes.length===0)throw new _r(`Layer ${this.name} is not connected, no input to return.`);return Un(this.getNodeAtIndex(0,"input").inputTensors)}get output(){if(this.inboundNodes.length===0)throw new _r(`Layer ${this.name} has no inbound nodes.`);if(this.inboundNodes.length>1)throw new _r(`Layer ${this.name} has multiple inbound nodes, hence the notion of "layer output" is ill-defined. Use \`getOutputAt(nodeIndex)\` instead.`);return Un(this.getNodeAtIndex(0,"output").outputTensors)}get losses(){return this._losses}calculateLosses(){return this.losses.map(e=>e())}get updates(){return this._updates}get built(){return this._built}set built(e){this._built=e}get trainable(){return this.trainable_}set trainable(e){this._trainableWeights.forEach(t=>t.trainable=e),this.trainable_=e}get trainableWeights(){return this.trainable_?this._trainableWeights.filter(e=>e.trainable):[]}set trainableWeights(e){this._trainableWeights=e}get nonTrainableWeights(){return this.trainable?this._trainableWeights.filter(e=>!e.trainable).concat(this._nonTrainableWeights):this._trainableWeights.concat(this._nonTrainableWeights)}set nonTrainableWeights(e){this._nonTrainableWeights=e}get weights(){return this.trainableWeights.concat(this.nonTrainableWeights)}get stateful(){return this._stateful}resetStates(){if(!this.stateful)throw new Error("Cannot call the resetStates() method of a non-stateful Layer object.")}assertInputCompatibility(e){if(e=vt(e),this.inputSpec==null||this.inputSpec.length===0)return;let t=vt(this.inputSpec);if(e.length!==t.length)throw new G(`Layer ${this.name} expects ${t.length} inputs, but it received ${e.length} input tensors. Input received: ${e}`);for(let n=0;n<e.length;n++){let s=e[n],r=t[n];if(r==null)continue;let a=s.rank;if(r.ndim!=null&&a!==r.ndim)throw new G(`Input ${n} is incompatible with layer ${this.name}: expected ndim=${r.ndim}, found ndim=${a}`);if(r.maxNDim!=null&&a>r.maxNDim)throw new G(`Input ${n} is incompatible with layer ${this.name}: expected max_ndim=${r.maxNDim}, found ndim=${a}`);if(r.minNDim!=null&&a<r.minNDim)throw new G(`Input ${n} is incompatible with layer ${this.name}: expected min_ndim=${r.minNDim}, found ndim=${a}.`);if(r.dtype!=null&&s.dtype!==r.dtype)throw new G(`Input ${n} is incompatible with layer ${this.name} : expected dtype=${r.dtype}, found dtype=${s.dtype}.`);if(r.axes){let o=s.shape;for(let i in r.axes){let l=Number(i),u=r.axes[i],c=l>=0?o[l]:o[o.length+l];if(u!=null&&[u,null].indexOf(c)===-1)throw new G(`Input ${n} is incompatible with layer ${this.name}: expected axis ${l} of input shape to have value ${u} but got shape ${o}.`)}}if(r.shape!=null)for(let o=0;o<r.shape.length;++o){let i=r.shape[o],l=s.shape[o];if(i!=null&&l!=null&&i!==l)throw new G(`Input ${n} is incompatible with layer ${this.name}: expected shape=${r.shape}, found shape=${s.shape}.`)}}}call(e,t){return e}invokeCallHook(e,t){this._callHook!=null&&this._callHook(e,t)}setCallHook(e){this._callHook=e}clearCallHook(){this._callHook=null}apply(e,t){t=t||{},this.assertNotDisposed();let n=vt(e),s=!0;for(let a of n)if(!(a instanceof Xs)){s=!1;break}let r=!0;for(let a of n)if(a instanceof Xs){r=!1;break}if(s===r)throw new G("Arguments to apply() must be all SymbolicTensors or all Tensors");return Qo(this.name,()=>{if(!this.built){this.assertInputCompatibility(e);let a=[];for(let o of vt(e))a.push(o.shape);this.build(Un(a)),this.built=!0,this.initialWeights&&this.setWeights(this.initialWeights),this._refCount===null&&r&&(this._refCount=1)}if(this.assertInputCompatibility(e),r){let a=this.call(e,t),o=vt(a),i=[];for(let l of o)n.indexOf(l)!==-1&&(l=l.clone()),i.push(l);if(a=Un(i),this.activityRegularizer!=null)throw new ze("Layer invocation in the presence of activity regularizer(s) is not supported yet.");return a}else{let a=mP(e),o=this.computeOutputShape(a),i,l=gP(e);if(this.warnOnIncompatibleInputShape(Array.isArray(e)?a[0]:a),o!=null&&o.length>0&&Array.isArray(o[0])?i=o.map((u,c)=>new Xs(l,u,this,vt(e),t,this.name,c)):i=new Xs(l,o,this,vt(e),t,this.name),this.addInboundNode(e,i,null,null,a,o,t),this._refCount++,this.activityRegularizer!=null)throw new ze("Layer invocation in the presence of activity regularizer(s) is not supported yet.");return i}})}warnOnIncompatibleInputShape(e){if(this.batchInputShape!=null)if(e.length!==this.batchInputShape.length)console.warn(`The rank of the input tensor provided (shape: ${JSON.stringify(e)}) does not match that of the batchInputShape (${JSON.stringify(this.batchInputShape)}) of the layer ${this.name}`);else{let t=!1;this.batchInputShape.forEach((n,s)=>{n!=null&&e[s]!=null&&e[s]!==n&&(t=!0)}),t&&console.warn(`The shape of the input tensor (${JSON.stringify(e)}) does not match the expectation of layer ${this.name}: ${JSON.stringify(this.batchInputShape)}`)}}get outputShape(){if(this.inboundNodes==null||this.inboundNodes.length===0)throw new _r(`The layer ${this.name} has never been called and thus has no defined output shape.`);let e=[];for(let t of this.inboundNodes){let n=JSON.stringify(t.outputShapes);e.indexOf(n)===-1&&e.push(n)}if(e.length===1){let t=this.inboundNodes[0].outputShapes;return Array.isArray(t)&&Array.isArray(t[0])&&t.length===1?t[0]:t}else throw new _r(`The layer ${this.name} has multiple inbound nodes with different output shapes. Hence the notion of "output shape" is ill-defined for the layer.`)}countParams(){if(!this.built)throw new Gs(`You tried to call countParams() on ${this.name}, but the layer is not built yet. Build it first by calling build(batchInputShape).`);return df(this.weights)}build(e){this.built=!0}getWeights(e=!1){return r1(e?this.trainableWeights:this.weights)}setWeights(e){H(()=>{let t=this.weights;if(t.length!==e.length)throw new G(`You called setWeights(weights) on layer "${this.name}" with a weight list of length ${e.length}, but the layer was expecting ${t.length} weights. Provided weights: ${e}...`);if(t.length===0)return;let n=[],s=r1(t);for(let r=0;r<s.length;++r){let a=s[r],o=t[r],i=e[r];if(!w.arraysEqual(a.shape,i.shape))throw new G(`Layer weight shape ${a.shape} not compatible with provided weight shape ${i.shape}`);n.push([o,i])}a1(n)})}addWeight(e,t,n,s,r,a,o){if(this._addedWeightNames.indexOf(e)!==-1)throw new G(`Duplicate weight name ${e} for layer ${this.name}`);this._addedWeightNames.push(e),n==null&&(n="float32"),this.fastWeightInitDuringBuild&&(s=Ct("zeros"));let i=s.apply(t,n),l=new W3(i,n,e,a,o);return i.dispose(),r!=null&&this.addLoss(()=>r.apply(l.read())),a==null&&(a=!0),a?this._trainableWeights.push(l):this._nonTrainableWeights.push(l),l}setFastWeightInitDuringBuild(e){this.fastWeightInitDuringBuild=e}addLoss(e){e==null||Array.isArray(e)&&e.length===0||(e=vt(e),this._losses!==void 0&&this._losses!==null&&this.losses.push(...e))}computeOutputShape(e){return e}computeMask(e,t){if(!this.supportsMasking){if(t!=null)if(Array.isArray(t))t.forEach(n=>{if(n!=null)throw new TypeError(`Layer ${this.name} does not support masking, but was passed an inputMask.`)});else throw new TypeError(`Layer ${this.name} does not support masking, but was passed an inputMask.`);return null}return t}addInboundNode(e,t,n,s,r,a,o=null){let i=vt(e);t=vt(t),n=vt(n),s=vt(s),r=cf(r),a=cf(a);let l=[],u=[],c=[];for(let d of i)l.push(d.sourceLayer),u.push(d.nodeIndex),c.push(d.tensorIndex);new pf({outboundLayer:this,inboundLayers:l,nodeIndices:u,tensorIndices:c,inputTensors:i,outputTensors:t,inputMasks:n,outputMasks:s,inputShapes:r,outputShapes:a},o);for(let d=0;d<t.length;d++)t[d].sourceLayer=this,t[d].nodeIndex=this.inboundNodes.length-1,t[d].tensorIndex=d}getConfig(){let e={name:this.name,trainable:this.trainable};return this.batchInputShape!=null&&(e.batchInputShape=this.batchInputShape),this.dtype!=null&&(e.dtype=this.dtype),e}disposeWeights(){return this.weights.forEach(e=>e.dispose()),this.weights.length}assertNotDisposed(){if(this._refCount===0)throw new Error(`Layer '${this.name}' is already disposed.`)}dispose(){if(!this.built)throw new Error(`Cannot dispose Layer ${this.name} because it has not been built yet.`);if(this._refCount===null)throw new Error(`Cannot dispose Layer ${this.name} because it has not been used yet.`);this.assertNotDisposed();let e=0;return--this._refCount==0&&(e=this.disposeWeights()),{refCountAfterDispose:this._refCount,numDisposedVariables:e}}};function mP(e){e=vt(e);let t=[];for(let n of e)t.push(n.shape);return Un(t)}function gP(e){return"float32"}function V3(e,t,n){if((t==null||n!=null&&n>0)&&(t=e.sourceLayer,n=e.nodeIndex),t.inboundNodes.length===0)return[e];{let s=t.inboundNodes[n];if(s.inboundLayers.length===0)return s.inputTensors;{let r=[];for(let a=0;a<s.inboundLayers.length;a++){let o=s.inputTensors[a],i=s.inboundLayers[a],l=s.nodeIndices[a],u=V3(o,i,l);for(let c of u)r.indexOf(c)===-1&&r.push(c)}return r}}}var ru=class extends et{constructor(e){super({dtype:e.dtype,name:e.name!=null?e.name:uf("input").toString()});if(e.batchSize==null&&(e.batchSize=null),e.sparse==null&&(e.sparse=!1),this.trainable=!1,this.built=!0,this.sparse=e.sparse,e.inputShape!=null&&e.batchInputShape!=null)throw new G("Only provide the inputShape OR batchInputShape argument to inputLayer, not both at the same time.");let t=e.batchInputShape;if(t==null){if(e.inputShape==null)throw new G("An InputLayer should be passed either a `batchInputShape` or an `inputShape`.");t=[e.batchSize].concat(e.inputShape)}else if(e.batchSize!=null)throw new G("Cannot specify batchSize if batchInputShape is specified when creating an InputLayer.");let n=e.dtype||"float32";this.batchInputShape=t,this.dtype=n,this.inputSpec=[{shape:t}];let s=new Xs(this.dtype,this.batchInputShape,this,[],{},this.name);s.nodeIndex=0,s.tensorIndex=0,new pf({outboundLayer:this,inboundLayers:[],nodeIndices:[],tensorIndices:[],inputTensors:[s],outputTensors:[s],inputMasks:[null],outputMasks:[null],inputShapes:[t],outputShapes:[t]})}apply(e,t){throw new G(`Cannot pass any input to an InputLayer's apply() method. InputLayer name: ${this.name}`)}dispose(){return{refCountAfterDispose:this._refCount,numDisposedVariables:0}}getConfig(){return{batchInputShape:this.batchInputShape,dtype:this.dtype,sparse:this.sparse,name:this.name}}};ru.className="InputLayer";le.registerClass(ru);function U3(e){if(e.batchShape==null&&e.shape==null)throw new Error("Please provide to Input either a `shape` or a `batchShape` argument. Note that `shape` does not include the batch dimension.");if(e.batchShape!=null&&e.shape!=null)throw new G("Please provide either a `shape` or `batchShape` argument to Input, but not both.");let t=e.batchShape;e.shape!=null&&t==null&&(t=[null].concat(e.shape));let n=e.dtype;return n==null&&(n="float32"),new ru({batchInputShape:t,name:e.name,dtype:n,sparse:e.sparse}).inboundNodes[0].outputTensors[0]}async function ma(e){if(e==null)return;let t=[],n=[],s=[];for(let r in e){let a=e[r];if(typeof a!="number"){let o=a;t.push(o.data()),n.push(r),s.push(o)}}if(t.length>0){let r=await Promise.all(t);for(let a=0;a<r.length;++a)e[n[a]]=r[a][0];Z(s)}}function H3(e){if(e!=null)for(let t in e){let n=e[t];typeof n!="number"&&n.dispose()}}var G3;(function(e){e[e.SILENT=0]="SILENT",e[e.VERBOSE=1]="VERBOSE"})(G3||(G3={}));var AP=125,au=class{constructor(){this.validationData=null}setParams(e){this.params=e}async onEpochBegin(e,t){}async onEpochEnd(e,t){}async onBatchBegin(e,t){}async onBatchEnd(e,t){}async onTrainBegin(e){}async onTrainEnd(e){}setModel(e){}},j3=class{constructor(e,t=10){e==null&&(e=[]),this.callbacks=e,this.queueLength=t}append(e){this.callbacks.push(e)}setParams(e){for(let t of this.callbacks)t.setParams(e)}setModel(e){for(let t of this.callbacks)t.setModel(e)}async onEpochBegin(e,t){t==null&&(t={});for(let n of this.callbacks)await n.onEpochBegin(e,t)}async onEpochEnd(e,t){t==null&&(t={});for(let n of this.callbacks)await n.onEpochEnd(e,t)}async onBatchBegin(e,t){t==null&&(t={});for(let n of this.callbacks)await n.onBatchBegin(e,t)}async onBatchEnd(e,t){t==null&&(t={});for(let n of this.callbacks)await n.onBatchEnd(e,t)}async onTrainBegin(e){e==null&&(e={});for(let t of this.callbacks)await t.onTrainBegin(e)}async onTrainEnd(e){e==null&&(e={});for(let t of this.callbacks)await t.onTrainEnd(e)}},yP=class extends au{constructor(){super()}async onEpochBegin(e){this.seen=0,this.totals={}}async onBatchEnd(e,t){t==null&&(t={});let n=t.size==null?0:t.size;this.seen+=n;for(let s in t){let r=t[s];if(typeof r=="number")this.totals.hasOwnProperty(s)||(this.totals[s]=0),this.totals[s]=this.totals[s]+r*n;else{let a;s in this.totals?a=this.totals[s]:this.totals[s]=0;let o=H(()=>oe(this.totals[s],z(r,n)));this.totals[s]=o,a!=null&&a.dispose()}}}async onEpochEnd(e,t){if(t!=null)for(let n of this.params.metrics)this.totals[n]!=null&&(typeof this.totals[n]=="number"?t[n]=this.totals[n]/this.seen:H(()=>{let s=z(he(1,this.seen),this.totals[n]);t[n]=s,this.totals[n].dispose(),on(t[n])}))}},q3=class extends au{async onTrainBegin(e){this.epoch=[],this.history={}}async onEpochEnd(e,t){t==null&&(t={}),this.epoch.push(e);for(let n in t)this.history[n]==null&&(this.history[n]=[]),this.history[n].push(t[n])}async syncData(){let e=[],t=[],n=[];for(let r in this.history){let a=this.history[r];for(let o=0;o<a.length;++o)if(typeof a[o]!="number"){let i=a[o];e.push(i.data()),t.push(r),n.push(o)}}let s=await Promise.all(e);for(let r=0;r<s.length;++r)this.history[t[r]][n[r]].dispose(),this.history[t[r]][n[r]]=s[r][0]}},X3=class extends au{constructor(e,t){super();if(this.currentEpoch=0,this.yieldEvery=t||"auto",this.yieldEvery==="auto"&&(this.yieldEvery=AP),this.yieldEvery==="never"&&e.onYield!=null)throw new Error("yieldEvery is `never` but you provided an `onYield` callback. Either change `yieldEvery` or remove the callback");w.isNumber(this.yieldEvery)&&(this.maybeWait=SO(this.maybeWait.bind(this),this.yieldEvery)),this.trainBegin=e.onTrainBegin,this.trainEnd=e.onTrainEnd,this.epochBegin=e.onEpochBegin,this.epochEnd=e.onEpochEnd,this.batchBegin=e.onBatchBegin,this.batchEnd=e.onBatchEnd,this.yield=e.onYield}async maybeWait(e,t,n){let s=[];this.yield!=null&&(await ma(n),s.push(this.yield(e,t,n))),s.push(Kh()),await Promise.all(s)}async onEpochBegin(e,t){this.currentEpoch=e,this.epochBegin!=null&&(await ma(t),await this.epochBegin(e,t))}async onEpochEnd(e,t){let n=[];this.epochEnd!=null&&(await ma(t),n.push(this.epochEnd(e,t))),this.yieldEvery==="epoch"&&n.push(Kh()),await Promise.all(n)}async onBatchBegin(e,t){this.batchBegin!=null&&(await ma(t),await this.batchBegin(e,t))}async onBatchEnd(e,t){let n=[];this.batchEnd!=null&&(await ma(t),n.push(this.batchEnd(e,t))),this.yieldEvery==="batch"?n.push(Kh()):w.isNumber(this.yieldEvery)&&n.push(this.maybeWait(this.currentEpoch,e,t)),await Promise.all(n)}async onTrainBegin(e){this.trainBegin!=null&&(await ma(e),await this.trainBegin(e))}async onTrainEnd(e){this.trainEnd!=null&&(await ma(e),await this.trainEnd(e))}};function K3(e,t){return e==null&&(e={}),e instanceof au?[e]:Array.isArray(e)&&e[0]instanceof au?e:vt(e).map(s=>new X3(s,t))}var Os=class{constructor(){}static registerCallbackConstructor(e,t){w.assert(e>=0&&Number.isInteger(e),()=>`Verbosity level is expected to be an integer >= 0, but got ${e}`),Os.checkForDuplicate(t),Os.constructors[e]==null&&(Os.constructors[e]=[]),Os.constructors[e].push(t)}static checkForDuplicate(e){for(let t in Os.constructors)Os.constructors[+t].forEach(s=>{if(s===e)throw new G("Duplicate callback constructor.")})}static clear(){Os.constructors={}}static createCallbacks(e){let t=[];for(let n in Os.constructors){let s=+n;e>=s&&t.push(...Os.constructors[s])}return t.map(n=>new n)}};Os.constructors={};function Z3(e,t,n,s,r,a,o,i,l){let u=new q3,c=[new yP,...Os.createCallbacks(t)];e!=null&&c.push(...e),c.push(u);let d=new j3(c);return d.setParams({epochs:n,initialEpoch:s,samples:r,steps:a,batchSize:o,verbose:t,doValidation:i,metrics:l}),{callbackList:d,history:u}}function Ks(e,t={},n=!1){return Wc(e,le.SerializationMap.getMap().classNameMap,t,"layer",n)}function hf(e,t){return H(()=>{e.dtype!=="float32"&&(e=pe(e,"float32"));let n=we(Gc(e),t,!0),s=Xl(n.shape,Yt()),r=fn(ir(n,s));return he(e,r)})}function ti(e,t){return H(()=>Dt(Gc(ye(t,e)),-1))}function ff(e,t){return H(()=>Dt(Wt(ye(t,e)),-1))}function ou(e,t){return H(()=>{let n=ye(e,t),s=Wn(Wt(e),Yt(),Number.MAX_VALUE),r=Wt(he(n,s));return z(100,Dt(r,-1))})}function xP(e,t){return H(()=>{let n=Wn(t,Yt(),Number.MAX_VALUE),s=ns(oe(1,n)),r=Wn(e,Yt(),Number.MAX_VALUE),a=ns(oe(1,r));return Dt(Gc(ye(s,a)),-1)})}function bP(e,t){return H(()=>{let n=ir(0,ye(1,z(e,t)));return Dt(Gc(n),-1)})}function vP(e,t){return H(()=>{let n=ir(0,ye(1,z(e,t)));return Dt(n,-1)})}function wP(e,t){return H(()=>{let n=we(z(e,t),-1),s=ss(z(ye(1,e),t),-1);return ir(0,oe(1,ye(s,n)))})}function kP(e,t){return H(()=>{let n=Math.log(2),s=ye(t,e),r=ye(oe(s,Go(z(-2,s))),n);return Dt(r,-1)})}function qc(e,t,n=!1){return H(()=>{if(n)t=Pc(t);else{let s=we(t,t.shape.length-1,!0);t=he(t,s)}return t=Wn(t,Yt(),1-Yt()),St(we(z(pe(e,"float32"),ns(t)),t.shape.length-1))})}function mf(e,t,n=!1){return H(()=>{let s=pe(Kl(BO(e)),"int32");t=Wn(t,Yt(),1-Yt());let r=t.shape,a=V(Bl(s,r[r.length-1]),r);return qc(a,t,n)})}function IP(e,t){if(!w.arraysEqual(e.shape,t.shape))throw new G(`logits and labels must have the same shape, but got shapes ${JSON.stringify(e.shape)} and ${JSON.stringify(t.shape)}`);return H(()=>{let n=Vs(t),s=St(Wt(t));return oe(ye(n,z(t,e)),Nc(ts(s)))})}function gf(e,t){return H(()=>{let n;return n=Wn(t,Yt(),1-Yt()),n=ns(he(n,ye(1,n))),Dt(IP(e,n),-1)})}function SP(e,t){return H(()=>{let n=Wn(e,Yt(),1),s=Wn(t,Yt(),1);return we(z(e,ns(he(n,s))),-1)})}function CP(e,t){return H(()=>{let n=ns(oe(Yt(),t));return Dt(ye(t,z(e,n)),-1)})}function o1(e,t){return H(()=>{let n=hf(e,-1),s=hf(t,-1),r=z(n,s);return St(we(r,-1))})}var Af={meanSquaredError:ti,meanAbsoluteError:ff,meanAbsolutePercentageError:ou,meanSquaredLogarithmicError:xP,squaredHinge:bP,hinge:vP,categoricalHinge:wP,logcosh:kP,categoricalCrossentropy:qc,sparseCategoricalCrossentropy:mf,binaryCrossentropy:gf,kullbackLeiblerDivergence:SP,poisson:CP,cosineProximity:o1};function i1(e){if(typeof e=="string"){if(e in Af)return Af[e];let t=`Unknown loss ${e}`;throw e.toLowerCase().includes("softmaxcrossentropy")&&(t=`Unknown loss ${e}. Use "categoricalCrossentropy" as the string name for tf.losses.softmaxCrossEntropy`),new G(t)}else return e}function l1(e,t){return H(()=>{let n=z(.5,as(t)),s=Yh(Vn(t,n),e.dtype);return Dt(es(e,s),-1)})}function u1(e,t){return H(()=>Yh(es(Ws(e,-1),Ws(t,-1)),"float32"))}function Y3(e,t){return H(()=>pe(we(_s(es(e,1),es(t,1))),"float32"))}function TP(e,t){return H(()=>pe(we(_s(es(e,1),es(t,0))),"float32"))}function NP(e,t){return H(()=>pe(we(_s(es(e,0),es(t,1))),"float32"))}function J3(e,t){return H(()=>{let n=Y3(e,t),s=NP(e,t),r=oe(n,s);return pe(vn(Vn(r,0),he(n,r),0),"float32")})}function EP(e,t){return H(()=>{let n=Y3(e,t),s=TP(e,t),r=oe(n,s);return pe(vn(Vn(r,0),he(n,r),0),"float32")})}function Q3(e,t){return gf(e,t)}function ev(e,t){return e.rank===t.rank&&(e=lt(e,[e.rank-1])),t=Ws(t,-1),t.dtype!==e.dtype&&(t=pe(t,e.dtype)),pe(es(e,t),"float32")}var RP=ti,DP=ti,_P=ff,$P=ff,FP=ou,OP=ou,c1=qc,PP=o1,tv=mf,yf={binaryAccuracy:l1,categoricalAccuracy:u1,precision:J3,categoricalCrossentropy:c1,sparseCategoricalCrossentropy:tv,mse:RP,MSE:DP,mae:_P,MAE:$P,mape:FP,MAPE:OP,cosine:PP};function MP(e){if(typeof e=="string"&&e in yf)return yf[e];if(typeof e!="string"&&e!=null)return e;throw new G(`Unknown metric ${e}`)}function xf(e){if(ur(e!==null,`Unknown LossOrMetricFn ${e}`),typeof e=="string")return e;{let t;for(let n of Object.keys(Af))if(Af[n]===e){t=n;break}if(t!==void 0)return t;for(let n of Object.keys(yf))if(yf[n]===e){t=n;break}return t!==void 0?t:e.name}}function zP(e){let t={Adagrad:()=>Ko.adagrad(.01),Adadelta:()=>Ko.adadelta(1,.95,Yt()),Adam:()=>Ko.adam(.001,.9,.999,Yt()),Adamax:()=>Ko.adamax(.002,.9,.999,Yt(),0),RMSProp:()=>Ko.rmsprop(.001,.9,0,Yt()),SGD:()=>Ko.sgd(.01)};if(t.adagrad=t.Adagrad,t.adadelta=t.Adadelta,t.adam=t.Adam,t.adamax=t.Adamax,t.rmsprop=t.RMSProp,t.sgd=t.SGD,e in t)return t[e]();throw new G(`Unknown Optimizer ${e}`)}var nv=1*1024*1024;function sv(e,t,n=!1){if(e==null||typeof e!="object"||Object.getPrototypeOf(e)!==Object.prototype||!d1(e))throw new Error("User-defined metadata is expected to be a JSON object, but is not.");if(n){let s=JSON.stringify(e);s.length>nv&&console.warn(`User-defined metadata of model "${t}" is too large in size (length=${s.length} when serialized). It is not recommended to store such large objects in user-defined metadata. Please make sure its serialized length is <= ${nv}.`)}}function d1(e){if(e===null)return!0;if(typeof e=="object")if(Object.getPrototypeOf(e)===Object.prototype){let t=Object.keys(e);for(let n of t)if(typeof n!="string"||!d1(e[n]))return!1;return!0}else if(Array.isArray(e)){for(let t of e)if(!d1(t))return!1;return!0}else return!1;else{let t=typeof e;return t==="string"||t==="number"||t==="boolean"}}function LP(e,t,n,s=console.log){let r=WP(e),a=["Layer (type)","Output shape","Param #"];r?(t=t||65,n=n||[.45,.85,1]):(t=t||98,n=n||[.33,.55,.67,1]),n[n.length-1]<=1&&(n=n.map(c=>Math.floor(t*c)));let o;if(!r){a.push("Receives inputs"),o=[];for(let c in e.nodesByDepth)o.push(...e.nodesByDepth[c])}s("_".repeat(t)),bf(a,n,s),s("=".repeat(t));let i=e.layers;for(let c=0;c<i.length;++c)r?VP(i[c],n,s):UP(i[c],n,o,s),s((c===i.length-1?"=":"_").repeat(t));e.checkTrainableWeightsConsistency();let l=BP(e),u=df(e.nonTrainableWeights);s(`Total params: ${l+u}`),s(`Trainable params: ${l}`),s(`Non-trainable params: ${u}`),s("_".repeat(t))}function BP(e){let t;return e.collectedTrainableWeights!=null?t=df(e.collectedTrainableWeights):t=df(e.trainableWeights),t}function WP(e){let t=!0,n=[],s=[];for(let r in e.nodesByDepth)n.push(e.nodesByDepth[r]);for(let r of n){if(r.length>1||r.length===1&&r[0].inboundLayers.length>1){t=!1;break}s.push(...r)}if(t)for(let r of e.layers){let a=!1;for(let o of r.inboundNodes)if(s.indexOf(o)!==-1)if(a){t=!1;break}else a=!0;if(!t)break}return t}function bf(e,t,n=console.log){let s="";for(let r=0;r<e.length;++r)r>0&&(s=s.slice(0,s.length-1)+" "),s+=e[r],s=s.slice(0,t[r]),s+=" ".repeat(t[r]-s.length);n(s)}function VP(e,t,n){let s;try{s=JSON.stringify(e.outputShape)}catch(i){s="multiple"}let r=e.name,a=e.getClassName(),o=[`${r} (${a})`,s,e.countParams().toString()];bf(o,t,n)}function UP(e,t,n,s){let r;try{r=JSON.stringify(e.outputShape)}catch(c){r="multiple"}let a=[];for(let c of e.inboundNodes)if(!(n!=null&&n.length>0&&n.indexOf(c)===-1))for(let d=0;d<c.inboundLayers.length;++d){let p=c.inboundLayers[d].name,h=c.nodeIndices[d],f=c.tensorIndices[d];a.push(`${p}[${h}][${f}]`)}let o=e.name,i=e.getClassName(),l=a.length===0?"":a[0],u=[`${o} (${i})`,r,e.countParams().toString(),l];bf(u,t,s);for(let c=1;c<a.length;++c)bf(["","","",a[c]],t,s)}function rv(e,t,n){return(e==="inboundNodes"||e==="outputLayers"||e==="inputLayers")&&t===0&&typeof n=="string"}function Xc(e,t){if(e===null)return null;if(typeof e=="string")return Yo(e);if(typeof e=="number"||typeof e=="boolean")return e;if(e instanceof Array){let n=[],s=e.length;for(let r=0;r<s;++r){let a=e[r];rv(t,r,a)?n.push(a):n.push(Xc(a,t))}return n}else{let n={};for(let s of Object.keys(e)){let r=e[s];if(s==="name"&&typeof r=="string")n[s]=r;else{let a=Yo(s);n[a]=Xc(r,a)}}return n}}function p1(e,t){if(e==null)return null;if(typeof e=="string")return $r(e);if(typeof e=="number"||typeof e=="boolean")return e;if(e instanceof Array){let n=[],s=e.length;for(let r=0;r<s;++r){let a=e[r];rv(t,r,a)?n.push(a):n.push(p1(a,t))}return n}else{let n={};for(let s of Object.keys(e)){let r=e[s],a=$r(s);(s==="name"||s==="className")&&typeof r=="string"?n[a]=r:n[a]=p1(r,s)}return n}}var h1="3.9.0";function HP(e,t){if(e.dtype==null||e.dtype===t.dtype)return t;try{return pe(t,e.dtype)}catch(n){throw new G(`The dtype of the feed (${t.dtype}) can not be cast to the dtype of the key '${e.name}' (${e.dtype}).`)}}var ni=class{constructor(e){if(this.id2Value={},this.id2Mask={},this.name2Id={},e instanceof ni)for(let t in e.id2Value)this.id2Value[t]=e.id2Value[t],t in e.id2Mask&&(this.id2Mask[t]=e.id2Mask[t]);else{if(e==null)return;for(let t of e)this.add(t.key,t.value)}}add(e,t,n){if(this.id2Value[e.id]==null)this.id2Value[e.id]=HP(e,t),this.name2Id[e.name]=e.id,n!=null&&(this.id2Mask[e.id]=n);else throw new G(`Duplicate key: name=${e.name}, id=${e.id}`);return this}addFeed(e){this.add(e.key,e.value)}hasKey(e){return this.id2Value[e.id]!=null}names(){return Object.keys(this.name2Id)}getValue(e){if(e instanceof Xs){if(this.id2Value[e.id]==null)throw new G(`Nonexistent key: ${e.name}`);return this.id2Value[e.id]}else{let t=this.name2Id[e];if(t==null)throw new G(`Feed dict has no SymbolicTensor name: ${e}`);return this.id2Value[t]}}getMask(e){if(e instanceof Xs){if(this.id2Value[e.id]==null)throw new G(`Nonexistent key: ${e.name}`);return this.id2Mask[e.id]}else{let t=this.name2Id[e];if(t==null)throw new G(`Feed dict has no SymbolicTensor name: ${e}`);return this.id2Mask[t]}}disposeMasks(){this.id2Mask!=null&&Z(this.id2Mask)}},f1={},av={};function Kc(e,t,n,s){let r=n==null?!1:n.training,a=Array.isArray(e),o=a?e:[e],i=o.map(f=>f.name),l=[],u=t.names();for(let f of i)u.indexOf(f)!==-1?l.push(t.getValue(f)):l.push(null);s!=null&&(s.maxNumTensors=-1/0,s.minNumTensors=1/0);let c=i.join(",")+"|"+t.names().join(","),d,p;if(f1[c]==null){let f=GP(o,t);d=f.sorted,p=f.recipientCounts,f1[c]=d,av[c]=p}d=f1[c],p={},r||Object.assign(p,av[c]);let h=new ni(t);for(let f=0;f<d.length;++f){if(s!=null){let D=lh().numTensors;D>s.maxNumTensors&&(s.maxNumTensors=D),D<s.minNumTensors&&(s.minNumTensors=D)}let m=d[f],g=m.sourceLayer;if(g instanceof ru)continue;let A=[],y=[],x=[],b=!1;for(let D of m.inputs){let O=h.getValue(D),E=h.getMask(D);A.push(O),y.push(E),E!=null&&(b=!0),r||(p[D.name]--,p[D.name]===0&&!t.hasKey(D)&&i.indexOf(D.name)===-1&&!O.isDisposed&&D.sourceLayer.stateful!==!0&&x.push(O))}b&&(n=n||{},n.mask=y[0]);let v=vt(g.apply(A,n)),k=null;g.supportsMasking&&(k=g.computeMask(A,y));let S=qP(m),C=Array.isArray(S)?S:[S];for(let D=0;D<C.length;++D){h.hasKey(C[D])||h.add(C[D],v[D],Array.isArray(k)?k[0]:k);let O=i.indexOf(C[D].name);O!==-1&&(l[O]=v[D])}r||Z(x)}return h.disposeMasks(),a?l:l[0]}function GP(e,t){w.assert(e!=null&&e.length>0,()=>"Expected at least one fetch, got none");let n=[],s={};if(e.length===1){let r=ov(e[0],t);n=r.sorted,s=r.recipientMap}else{let r=new Set;for(let a of e){let{sorted:o,recipientMap:i}=ov(a,t);for(let l of o)r.has(l.name)||(n.push(l),r.add(l.name));for(let l in i)s[l]==null&&(s[l]=new Set),i[l].forEach(u=>s[l].add(u))}}return{sorted:n,recipientCounts:jP(s)}}function jP(e){let t={};for(let n in e)t[n]=e[n].size;return t}function ov(e,t){let n=new Set,s=[],r={};for(let i of t.names())n.add(i);let a=[],o=[];for(a.push(e);a.length>0;){let i=a[a.length-1];if(n.has(i.name)){a.pop();continue}let l=o[o.length-1]===a.length-1;if(i.inputs.length===0||l)a.pop(),s.push(i),n.add(i.name),l&&o.pop();else{o.push(a.length-1);for(let u of i.inputs)r[u.name]==null&&(r[u.name]=new Set),r[u.name].add(i.name),!n.has(u.name)&&a.push(u)}}return{sorted:s,recipientMap:r}}function qP(e){let t;if(e.sourceLayer.inboundNodes.length===1)t=e.sourceLayer.output;else{let n=null;for(let s=0;s<e.sourceLayer.inboundNodes.length;++s)for(let r of e.sourceLayer.inboundNodes[s].outputTensors)if(r.id===e.id){n=s;break}t=e.sourceLayer.getOutputAt(n)}return t}var dr=class extends et{constructor(e){super({});if(this.containerNodes=new Set,this.name=e.name,this.name==null){let A=this.getClassName().toLowerCase();this.name=uf(A)}if(this.supportsMasking=!1,this.trainable_=!0,Array.isArray(e.inputs)?this.inputs=e.inputs.slice():this.inputs=[e.inputs],Array.isArray(e.outputs)?this.outputs=e.outputs.slice():this.outputs=[e.outputs],pa(this.inputs).length!==this.inputs.length)throw new G(`The list of inputs passed to the model is redundant. All inputs should only appear once. Found: ${this.inputs.map(A=>A.name)}`);pa(this.outputs).length!==this.outputs.length&&console.warn(`The list of outputs passed to the model is redundant. All outputs should only appear once. Found: ${this.outputs.map(A=>A.name)}`),this.inputLayers=[],this.inputLayersNodeIndices=[],this.inputLayersTensorIndices=[],this.outputLayers=[],this.outputLayersNodeIndices=[],this.outputLayersTensorIndices=[],this.layers=[],this.internalContainerRefs=[];for(let A of this.outputs){let y=A.sourceLayer,x=A.nodeIndex,b=A.tensorIndex;this.outputLayers.push(y),this.outputLayersNodeIndices.push(x),this.outputLayersTensorIndices.push(b)}for(let A of this.inputs){let y=A.sourceLayer,x=A.nodeIndex,b=A.tensorIndex;ur(x===0,"input layer has >1 nodes"),ur(b===0,"input layer has >1 tensors"),this.inputLayers.push(y),this.inputLayersNodeIndices.push(x),this.inputLayersTensorIndices.push(b)}this.inputNames=[],this.outputNames=[],this.feedInputShapes=[],this.feedInputNames=[],this.feedOutputNames=[];for(let A=0;A<this.inputLayers.length;A++){let y=this.inputLayers[A];if(!(y instanceof ru))throw new TypeError(`Input layers to a LayersModel must be InputLayer objects. Received inputs: ${e.inputs}. Input ${A} (0-based) originates from layer type ${y.getClassName()}.`);this.inputNames.push(y.name),this.feedInputShapes.push(y.batchInputShape),this.feedInputNames.push(y.name)}for(let A of this.outputLayers)this.outputNames.push(A.name);this.internalInputShapes=this.inputs.map(A=>A.shape),this.internalOutputShapes=this.outputs.map(A=>A.shape);let t={},n={},s={},r={},a={},o=[],i=(A,y,x,b,v,k)=>{(b==null||v==null||k==null)&&(b=A.sourceLayer,v=A.nodeIndex,k=A.tensorIndex);let S=b.inboundNodes[v];if(x.indexOf(S)!==-1)throw new Gs(`The tensor ${A.name} at layer "${b.name}" is part of a cycle.`);if(y.indexOf(S)!==-1)return;this.containerNodes.add(dr.nodeKey(b,v)),b.id in a||(a[b.id]=Object.keys(a).length),x.indexOf(S)===-1&&x.push(S);let C=S.inboundLayers.length;for(let D=0;D<C;D++){let O=S.inputTensors[D],E=S.inboundLayers[D],R=S.nodeIndices[D],T=S.tensorIndices[D];i(O,y,x,E,R,T)}for(y.push(S);x.indexOf(S)>=0;)x.splice(x.indexOf(S),1);o.push(S)},l=[],u=[];for(let A of this.outputs)i(A,l,u);let c=o.slice().reverse();for(let A of c){n[A.id]=A,A.id in t||(t[A.id]=0);let y=t[A.id],x=s[A.outboundLayer.id]==null?0:s[A.outboundLayer.id];y=Math.max(y,x),s[A.outboundLayer.id]=y,r[A.outboundLayer.id]=A.outboundLayer,t[A.id]=y;for(let b=0;b<A.inboundLayers.length;b++){let v=A.inboundLayers[b],k=A.nodeIndices[b],S=v.inboundNodes[k],C=t[S.id]==null?0:t[S.id];t[S.id]=Math.max(y+1,C),n[S.id]=S}}let d={};for(let A in t){let y=t[A];y in d||(d[y]=[]),d[y].push(n[A])}let p={};for(let A in s){let y=s[A];y in p||(p[y]=[]),p[y].push(r[A])}let h=Object.keys(p).map(A=>parseInt(A,10)).sort(Zh);this.layers=[];for(let A of h){let y=p[A];y.sort((x,b)=>{let v=a[x.id],k=a[b.id];return v<k?-1:v>k?1:0});for(let x of y)x instanceof dr&&this.internalContainerRefs.push(x),this.layers.push(x)}this.layersByDepth=p,h=Object.keys(d).map(A=>parseInt(A,10)).sort(Zh);let f=this.inputs.slice(),m=[];for(let A of h)for(let y of d[A]){let x=y.outboundLayer;if(x!=null){for(let b of y.inputTensors)if(f.indexOf(b)===-1)throw new Gs(`Graph disconnected: cannot obtain value for tensor ${b} at layer "${x.name}". The following previous layers were accessed without issue: ${m}`);for(let b of y.outputTensors)f.push(b);m.push(x.name)}}this.nodesByDepth=d;let g=this.layers.map(A=>A.name);for(let A of g){let y=g.filter(x=>x===A).length;if(y!==1)throw new Gs(`The name "${A}" is used ${y} times in the model. All layer names should be unique. Layer names: `+JSON.stringify(g))}this.outboundNodes=[],this.inboundNodes=[],new pf({outboundLayer:this,inboundLayers:[],nodeIndices:[],tensorIndices:[],inputTensors:this.inputs,outputTensors:this.outputs,inputMasks:this.inputs.map(A=>null),outputMasks:this.outputs.map(A=>null),inputShapes:this.inputs.map(A=>A.shape),outputShapes:this.outputs.map(A=>A.shape)}),this.built=!0,this._refCount=1}assertNotDisposed(){if(this._refCount===0)throw new Error(`Container '${this.name}' is already disposed.`)}dispose(){this.assertNotDisposed();let e={refCountAfterDispose:null,numDisposedVariables:0};if(--this._refCount==0){for(let t of this.layers)e.numDisposedVariables+=t.dispose().numDisposedVariables;for(let t of this.internalContainerRefs)e.numDisposedVariables+=t.dispose().numDisposedVariables}return e.refCountAfterDispose=this._refCount,e}get trainable(){return this.trainable_}set trainable(e){this.layers.forEach(t=>{t._trainableWeights.forEach(n=>n.trainable=e)}),this.trainable_=e}get trainableWeights(){if(this._trainableWeights.length>0)throw new G("Container instance unexpectedly contains _trainableWeights.The trainable weights of a Container are a union of the trainable weights of its consituent Layers. Its own _trainableWeights must remain an empty Array.");if(!this.trainable)return[];let e=[];for(let t of this.layers)e=e.concat(t.trainableWeights);return e}get nonTrainableWeights(){let e=[];for(let t of this.layers)e.push(...t.nonTrainableWeights);if(!this.trainable){let t=[];for(let n of this.layers)t.push(...n.trainableWeights);return t.concat(e)}return e}get weights(){return this.trainableWeights.concat(this.nonTrainableWeights)}loadWeights(e,t=!0){let n={},s=0;for(let a of this.layers)for(let o of a.weights){if(n[o.originalName]!=null)throw new G(`Duplicate weight name: ${o.originalName}`);n[o.originalName]=o,s++}let r=[];for(let a in e){let o=a;if(n[a]==null){let i=a.split("/");o=i.slice(0,-2).concat([i[i.length-1]]).join("/")}if(n[o]!=null)r.push([n[o],e[a]]);else if(t)throw new G(`Provided weight data has no target variable: ${a}`);delete n[o]}if(t){let a=[];for(let o in n)a.push(o);if(a.length>0)throw new G(`${a.length} of ${s} weights are not set: ${a}`)}a1(r)}updatedConfig(){let e=this.getConfig(),t={};return t.className=this.getClassName(),t.config=e,t.kerasVersion=`tfjs-layers ${h1}`,t.backend="TensorFlow.js",t}toJSON(e,t=!0){let n=p1(this.updatedConfig());return t?JSON.stringify(n):n}call(e,t){return H(()=>{e=vt(e);let n=new ni;for(let s=0;s<this.inputs.length;++s)n.add(this.inputs[s],e[s]);return Kc(this.outputs,n,t)})}computeMask(e,t){return H(()=>{e=vt(e);let n;return t==null?n=Zo(null,e.length):n=vt(t),this.runInternalGraph(e,n)[1]})}computeOutputShape(e){let t=cf(e);if(t.length!==this.inputLayers.length)throw new G(`Invalid inputShape argument ${e}: model has ${this.inputLayers.length} tensor inputs.`);let n={};for(let o=0;o<t.length;o++){let i=this.inputLayers[o],l=t[o],u=i.name+"_0_0";n[u]=l}let s=Object.keys(this.nodesByDepth).map(o=>parseInt(o,10)).sort(Zh);if(s.length>1)for(let o of s){let i=this.nodesByDepth[o];for(let l of i){let u=l.outboundLayer;if(this.inputLayers.map(f=>f.id).indexOf(u.id)!==-1)continue;let c=[];for(let f=0;f<l.inboundLayers.length;f++){let m=l.inboundLayers[f],g=l.nodeIndices[f],A=l.tensorIndices[f],y=`${m.name}_${g}_${A}`,x=n[y];c.push(x)}let d=u.computeOutputShape(Un(c)),p=cf(d),h=u.inboundNodes.indexOf(l);for(let f=0;f<p.length;f++){let m=`${u.name}_${h}_${f}`;n[m]=p[f]}}}let r=[],a=[];for(let o=0;o<this.outputLayers.length;o++){let i=this.outputLayers[o],l=this.outputLayersNodeIndices[o],u=this.outputLayersTensorIndices[o],c=`${i.name}_${l}_${u}`;a.push(c)}for(let o=0;o<a.length;o++){let i=a[o];ur(i in n),r.push(n[i])}return Un(r)}runInternalGraph(e,t){t==null&&(t=Zo(null,e.length));let n={};for(let i=0;i<this.inputs.length;++i){let l=this.inputs[i],u=e[i],c=t[i];n[l.id]=[u,c]}let s=Object.keys(this.nodesByDepth).map(i=>parseInt(i,10)).sort(Zh);for(let i of s){let l=this.nodesByDepth[i];for(let u of l){let c=u.outboundLayer,d=u.inputTensors,p=u.outputTensors,h=new Array;for(let f of d)f.id in n&&h.push(n[f.id]);if(h.length===d.length){let f={},m,g,A,y;if(u.callArgs!=null&&(f=u.callArgs),h.length===1){let[x,b]=h[0];f.mask==null&&(f.mask=b),A=vt(c.call(x,f)),y=vt(c.computeMask(x,b)),m=[x],g=[b]}else m=h.map(x=>x[0]),g=h.map(x=>x[1]),f.mask==null&&(f.mask=g),A=vt(c.call(m,f)),y=vt(c.computeMask(m,g));if(c.activityRegularizer)throw new ze("LayersModel invocation with concrete Tensor value(s) in the presence of activity regularizer(s) is not supported yet.");for(let x=0;x<p.length;++x){let b=p[x],v=A[x],k=y[x];n[b.id]=[v,k]}}}}let r=[],a=[],o=[];for(let i of this.outputs){ur(i.id in n,`Could not compute output ${i.name} : ${i.id}`);let[l,u]=n[i.id];o.push(l.shape),r.push(l),a.push(u)}return[r,a,o]}buildNodeConversionMap(e){let t={},n;for(let s of this.layers){n=s instanceof dr?1:0;for(let r=0;r<s.inboundNodes.length;r++){let a=dr.nodeKey(s,r);this.containerNodes.has(a)&&(t[a]=n,n+=1)}}return t}getLayer(e,t){if(t!=null){if(this.layers.length<=t)throw new G(`Was asked to retrieve layer at index ${t}, but model only has ${this.layers.length} layer(s).`);return this.layers[t]}else if(e==null)throw new G("Provide either a layer name or layer index");for(let n of this.layers)if(n.name===e)return n;throw new G(`No such layer: ${e}`)}calculateLosses(){return H(()=>{let e=[];for(let t of this.layers)for(let n=0;n<t.inboundNodes.length;++n){let s=dr.nodeKey(t,n);this.containerNodes.has(s)&&e.push(...t.calculateLosses())}return e})}getConfig(){let e={name:this.name},t=this.buildNodeConversionMap(this.layers),n=[];for(let a of this.layers){let o=a.getClassName(),i=a.getConfig(),l=[];for(let c=0;c<a.inboundNodes.length;c++){let d=a.inboundNodes[c],p=dr.nodeKey(a,c),h={};if(this.containerNodes.has(p)){if(d.callArgs)try{JSON.stringify(d.callArgs),h=d.callArgs}catch(f){console.warn(`Layer ${a.name} was passed non-serializable keyword arguments: ${d.callArgs}. They will not be included in the serialized model (and thus will be missing at deserialization time).`),h={}}if(d.inboundLayers.length>0){let f=[];for(let m=0;m<d.inboundLayers.length;m++){let g=d.inboundLayers[m],A=d.nodeIndices[m],y=d.tensorIndices[m],x=dr.nodeKey(g,A),b=t[x];b==null&&(b=0),f.push([g.name,b,y,h])}l.push(f)}}}let u={};u.name=a.name,u.className=o,u.config=i,u.inboundNodes=l,n.push(u)}e.layers=n;let s=[];for(let a=0;a<this.inputLayers.length;a++){let o=this.inputLayers[a],i=this.inputLayersNodeIndices[a],l=dr.nodeKey(o,i);if(!this.containerNodes.has(l))continue;let u=t[l];u==null&&(u=0);let c=this.inputLayersTensorIndices[a];s.push([o.name,u,c])}e.inputLayers=s;let r=[];for(let a=0;a<this.outputLayers.length;a++){let o=this.outputLayers[a],i=this.outputLayersNodeIndices[a],l=dr.nodeKey(o,i);if(!this.containerNodes.has(l))continue;let u=t[l];u==null&&(u=0);let c=this.outputLayersTensorIndices[a];r.push([o.name,u,c])}return e.outputLayers=r,e}static fromConfig(e,t,n={},s=!1){let r={},a={};function o(m,g){m.name in a?a[m.name].push(g):a[m.name]=[g]}function i(m,g){let A=[],y;for(let x of g){let b=x[0],v=x[1],k=x[2];if(y=x[3]==null?{}:x[3],!(b in r)){o(m,g);return}let S=r[b];if(S.inboundNodes.length<=v){o(m,g);return}let C=S.inboundNodes[v];A.push(C.outputTensors[k])}A.length>0&&m.apply(Un(A),y)}function l(m){let g=m.name,A=Ks(m,t.customObjects!=null?t.customObjects:{});A.setFastWeightInitDuringBuild(s),r[g]=A,m.inboundNodes.forEach(x=>{if(!(x instanceof Array))throw new G(`Corrupted configuration, expected array for nodeData: ${x}`);o(A,x)})}let u=t.name,c=t.layers;for(let m of c)l(m);for(;!IO(a);)for(let m of c){let g=r[m.name];if(g.name in a){let A=a[g.name];delete a[g.name];for(let y of A)i(g,y)}}let d=[],p=[],h=t.inputLayers;for(let m of h){let g=m[0],A=m[1],y=m[2];ur(g in r);let b=r[g].inboundNodes[A].outputTensors;d.push(b[y])}let f=t.outputLayers;for(let m of f){let g=m[0],A=m[1],y=m[2];ur(g in r);let b=r[g].inboundNodes[A].outputTensors;p.push(b[y])}return new e({inputs:d,outputs:p,name:u})}get stateful(){if(this._stateful)throw new G("Container instance unexpectedly has _stateful = true. The statefulness of a Container is determined by the Layers it contains. Its _stateful property must remain the default false.");for(let e of this.layers)if(e.stateful)return!0;return!1}resetStates(){H(()=>{this.layers.forEach(e=>{e.stateful&&e.resetStates()})})}};function XP(e,t,n){let s=t.length;if(e==null||Array.isArray(e)&&e.length===0)return t.map(r=>null);if(s===1)return Array.isArray(e)&&e.length===1?e:typeof e=="object"&&t[0]in e?[e[t[0]]]:[e];if(Array.isArray(e)){if(e.length!==s)throw new Error(`Provided ${n} is an array of ${e.length} element(s), but the model has ${s} outputs. Make sure a set of weights is provided for each model output.`);return e}else if(typeof e=="object"&&Object.keys(e).length>0&&typeof e[Object.keys(e)[0]]=="object"){let r=[];return t.forEach(a=>{a in e?r.push(e[a]):r.push(null)}),r}else throw new Error(`The model has multiple (${s}) outputs, so ${n} must be either an array with ${s} elements or an object with ${t} keys. Provided ${n} not understood: ${JSON.stringify(e)}`)}function iv(e,t){return XP(e,t,"classWeight")}async function lv(e,t,n,s){if(t!=null||s!=null)throw new Error("Support sampleWeight is not implemented yet");if(n!=null){let r=H(()=>{if(e.shape.length===1)return Bs(e);if(e.shape.length===2){if(e.shape[1]>1)return Ws(e,1);if(e.shape[1]===1)return V(e,[e.shape[0]]);throw new Error(`Encountered unexpected last-dimension size (${e.shape[1]}) during handling of class weights. The size is expected to be >= 1.`)}else throw new Error(`Unexpected rank of target (y) tensor (${e.rank}) during handling of class weights. The rank is expected to be 1 or 2.`)}),a=Array.from(await r.data());Z(r);let o=[];return a.forEach(i=>{if(n[i]==null)throw new Error(`classWeight must contain all classes in the training data. The class ${i} exists in the data but not in classWeight`);o.push(n[i])}),Ut(o,"float32")}else return null}function KP(e,t){return z(e,t)}var ZP=32;function uv(e,t){let n,s,r=t;n=r.xs,s=r.ys,w.assert(n!=null&&s!=null,()=>`A Dataset iterator for fitDataset() is expected to generate objects of the form \`{xs: xVal, ys: yVal}\`, where the two values may be \`tf.Tensor\`, an array of Tensors, or a map of string to Tensor. The provided Dataset instead generates ${t}`);let a=cv("input",e.inputNames,n),o=cv("output",e.outputNames,s),i=a[0].shape[0];w.assert(a.length===e.inputs.length,()=>`LayersModel has ${e.inputs.length} inputs, but the dataset provides ${a.length} inputs. (Expected input keys: ${JSON.stringify(e.inputNames)})`),w.assert(o.length===e.outputs.length,()=>`LayersModel has ${e.outputs.length} outputs, but the dataset provides ${o.length} outputs. (Expected output keys: ${JSON.stringify(e.outputNames)})`);for(let l=0;l<a.length;l++)w.assert(a[l].shape[0]===i,()=>`Batch size mismatch: input ${e.inputNames[l]} has ${a[l].shape[0]}; expected ${i} based on input ${e.inputNames[0]}.`);for(let l=0;l<o.length;l++)w.assert(o[l].shape[0]===i,()=>`Batch size mismatch: output ${e.outputNames[l]} has ${o[l].shape[0]}; expected ${i} based on input ${e.inputNames[0]}.`);return{xs:a,ys:o}}function cv(e,t,n){if(n instanceof Ge)return[n];if(Array.isArray(n))return w.assert(n.length===t.length,()=>`Received an array of ${n.length} Tensors, but expected ${t.length} to match the ${e} keys ${t}.`),n;{let s=[];for(let r of t){if(n[r]==null)throw new G(`The feature data generated by the dataset lacks the required ${e} key '${r}'.`);s.push(n[r])}return s}}function YP(e){if(e.length===3)throw new ze("Validation with sample weights is not implemented yet.");return{xs:e[0],ys:e[1]}}async function JP(e,t,n){let s=n.batchesPerEpoch!=null;if(w.assert(e.optimizer!=null,()=>"You must compile a model before training/testing. Use LayersModel.compile(modelCompileConfig)."),w.assert(n!=null,()=>"For fitDataset(), the 2nd argument (config) is required, but it is not provided in this call."),w.assert(n.epochs!=null&&n.epochs>0&&Number.isInteger(n.epochs),()=>`For fitDataset(), config.epochs is expected to be a positive integer, but got ${n.epochs}`),w.assert(!s||n.batchesPerEpoch>0&&Number.isInteger(n.batchesPerEpoch),()=>`For fitDataset(), config.batchesPerEpoch is expected to be a positive integer if specified, but got ${n.batchesPerEpoch}`),w.assert(n.validationSplit==null,()=>"`validationSplit` is not supported by `fitDataset()`. Use validationData instead."),e.isTraining)throw new Error("Cannot start training because another fit() call is ongoing.");e.isTraining=!0;try{let r=n.validationData!=null,a,o;if(r)if(dv(n.validationData))w.assert(n.validationBatches==null||n.validationBatches>0&&Number.isInteger(n.validationBatches),()=>`For fitDataset() with dataset-based validation, config.validationBatches is expected not to be provided, or to be a positive integer, but got ${n.validationBatches}`);else{let g=YP(n.validationData);a=g.xs,o=g.ys}let i=e.makeTrainFunction(),l=e.getDedupedMetricsNames(),u;r?u=l.slice().concat(l.map(g=>"val_"+g)):u=l.slice();let c=K3(n.callbacks,n.yieldEvery),d=n.verbose==null?1:n.verbose,{callbackList:p,history:h}=Z3(c,d,n.epochs,null,null,QP(t,n),null,r,u);p.setModel(e),e.history=h,await p.onTrainBegin(),e.stopTraining_=!1;let f=n.initialEpoch==null?0:n.initialEpoch,m=await t.iterator();for(;f<n.epochs;){let g={};await p.onEpochBegin(f);let A=0,y=0;for(s||(m=await t.iterator());s?A<n.batchesPerEpoch:!0;){let x=await m.next();if(s&&x.done){console.warn(`You provided \`batchesPerEpoch\` as ${n.batchesPerEpoch}, but your dataset iterator ran out of data after ${A} batches; interrupting training. Make sure that your dataset can generate at least \`batchesPerEpoch * epochs\` batches (in this case, ${n.batchesPerEpoch*n.epochs} batches). You may need to use the repeat() function when building your dataset.`);break}if(x.value!=null){let{xs:b,ys:v}=uv(e,x.value),k={};k.batch=y,k.size=b[0].shape[0],await p.onBatchBegin(y,k);let S=[];if(n.classWeight!=null){let O=iv(n.classWeight,e.outputNames);for(let E=0;E<O.length;++E)S.push(await lv(v[E],null,O[E]))}let C=b.concat(v).concat(S),D=i(C);Z(C);for(let O=0;O<l.length;++O){let E=l[O],R=D[O];k[E]=R,on(R)}await p.onBatchEnd(y,k),H3(k),y++,A++}if(s?A>=n.batchesPerEpoch:x.done){if(r){let b;dv(n.validationData)?b=vt(await e.evaluateDataset(n.validationData,{batches:n.validationBatches})):b=vt(e.evaluate(a,o,{batchSize:n.validationBatchSize==null?ZP:n.validationBatchSize,verbose:0}));for(let v=0;v<e.metricsNames.length;++v)g[`val_${e.metricsNames[v]}`]=b[v]}break}if(e.stopTraining_)break}if(await p.onEpochEnd(f,g),f++,e.stopTraining_)break}return await p.onTrainEnd(),await e.history.syncData(),e.history}finally{e.isTraining=!1}}function QP(e,t){let n=null;return t.batchesPerEpoch!=null?n=t.batchesPerEpoch:Number.isFinite(e.size)&&(n=e.size),n}function dv(e){return typeof e.iterator=="function"}function eM(e){return typeof e.next=="function"}async function tM(e,t,n){n=n||{};let s=n.batches!=null,r=e.testFunction,a=[];if(n.verbose>0)throw new ze("Verbose mode is not implemented yet.");w.assert(!s||n.batches>0&&Number.isInteger(n.batches),()=>`Test loop expects \`batches\` to be a positive integer, but received ${JSON.stringify(n.batches)}`);let o=eM(t)?t:await t.iterator(),i=0,l=0;for(;s?l<n.batches:!0;){let u=await o.next();if(a=H(()=>{if(u.value){let{xs:c,ys:d}=uv(e,u.value),p=c.concat(d),h=H(()=>r(p));if(Z(p),l===0)for(let m=0;m<h.length;++m)a.push(Ce(0));let f=p[0].shape[0];for(let m=0;m<h.length;++m){let g=h[m],A=a[m];a[m]=H(()=>oe(a[m],z(f,g))),l>0&&Z(A)}Z(h),i+=f,++l}return a}),u.done){s&&console.warn(`Your dataset iterator ran out of data during evaluateDataset(). Interrupting evalution. Make sure that your dataset can generate at least \`batches\` batches (in this case, ${n.batches} batches). You may need to use the repeat() function when building your dataset.`);break}}for(let u=0;u<a.length;++u){let c=a[u];a[u]=he(a[u],i),Z(c)}return Un(a)}function m1(e){w.assert(e>0&&Number.isInteger(e),()=>`batchSize is required to be a positive integer, but got ${e}`)}function Zc(e,t,n){return e==null?[null]:Array.isArray(e)?e.map(s=>ei(s,t,n-t)):ei(e,t,n-t)}function g1(e,t){return H(()=>e==null?null:Array.isArray(e)?e.map(n=>g1(n,t)):F3(e,t.dtype==="int32"?t:pe(t,"int32")))}function A1(e,t){let n=[],s=0,r=null;for(;s<e;)r=s+t,r>=e&&(r=e),n.push([s,r]),s=r;return n}async function nM(e,t,n,s,r,a,o,i,l,u,c,d,p,h,f){r==null&&(r=32),a==null&&(a=1),c==null&&(c=!0),p==null&&(p=0);let m=!1;if(l!=null&&u!=null&&(m=!0),f!=null&&(m=!0,h==null))throw new G("Can only use `validationSteps` when doing step-wise training, i.e., `stepsPerEpoch` must be set.");let g=e.checkNumSamples(n,r,h,"steps_per_epoch"),A;g!=null&&(A=js(0,g)),o==null&&(o=1);let{callbackList:y,history:x}=Z3(i,o,a,p,g,h,r,m,d);y.setModel(e),e.history=x,await y.onTrainBegin(),e.stopTraining_=!1;for(let b=p;b<a;++b){await y.onEpochBegin(b);let v={};if(h!=null)throw new ze("stepsPerEpoch mode is not implemented yet.");{if(c==="batch")throw new ze("batch shuffling is not implemneted yet");c&&w.shuffle(A);let k=Ut(A),S=A1(g,r);for(let C=0;C<S.length;++C){let D={};if(await y.onBatchBegin(C,D),H(()=>{let O=S[C][0],E=S[C][1],R=ei(k,O,E-O);D.batch=C,D.size=E-O;let T=g1(n,R),P=t(T);for(let U=0;U<s.length;++U){let j=s[U],q=P[U];D[j]=q,on(q)}if(C===S.length-1&&m){let U=e.testLoop(l,u,r);for(let j=0;j<s.length;++j){let q=s[j],X=U[j];on(X),v["val_"+q]=X}}}),await y.onBatchEnd(C,D),H3(D),e.stopTraining_)break}k.dispose()}if(await y.onEpochEnd(b,v),e.stopTraining_)break}return await y.onTrainEnd(),await e.history.syncData(),e.history}async function sM(e,t,n,s={}){if(e.isTraining)throw new Error("Cannot start training because another fit() call is ongoing.");e.isTraining=!0;let r,a,o,i,l,u,c;try{let d=s.batchSize==null?32:s.batchSize;m1(d);let p=!1,h=await e.standardizeUserData(t,n,s.sampleWeight,s.classWeight,p,d);r=h[0],a=h[1],c=h[2];let f=!1,m;if(s.validationData!=null&&s.validationData.length>0){if(f=!0,s.validationData.length===2)o=s.validationData[0],i=s.validationData[1];else throw s.validationData.length===3?new ze("validationData including sample weights is not supported yet."):new G(`When passing validation data, it must contain 2 (valX, valY) or 3 (valX, valY, valSampleWeight) items; ${s.validationData} is invalid.`);let S=!0,C=await e.standardizeUserData(o,i,null,null,S,d);l=C[0],u=C[1],m=l.concat(u)}else if(s.validationSplit!=null&&s.validationSplit>0&&s.validationSplit<1){f=!0;let S=Math.floor(r[0].shape[0]*(1-s.validationSplit)),C=r[0].shape[0];l=Zc(r,S,C),r=Zc(r,0,S),u=Zc(a,S,C),a=Zc(a,0,S),m=l.concat(u)}else s.validationSteps!=null&&(f=!0);let g=r.concat(a).concat(c);e.checkTrainableWeightsConsistency();let A=e.makeTrainFunction(),y=e.getDedupedMetricsNames(),x,b;f?(e.makeTestFunction(),x=e.testFunction,b=y.slice().concat(y.map(S=>"val_"+S))):(x=null,m=[],b=y.slice());let v=K3(s.callbacks,s.yieldEvery);return await nM(e,A,g,y,d,s.epochs,s.verbose,v,x,m,s.shuffle,b,s.initialEpoch,null,null)}finally{e.isTraining=!1,si(r,t),si(a,n),si(l,o),si(u,i),c!=null&&Z(c)}}function pv(e){let t=[];e instanceof Ge&&(e=[e]);for(let n=0;n<e.length;++n){let s=e[n];if(s.rank===1)t.push(Hc(s,1));else{if(s.rank===0)throw new Error("Expected tensor to be at least 1D, but received a 0D tensor (scalar).");t.push(s)}}return t}function si(e,t){if(e==null)return;let n=[];if(t instanceof Ge)n.push(t.id);else if(Array.isArray(t))t.forEach(r=>n.push(r.id));else if(t!=null)for(let r in t){let a=t[r];n.push(a.id)}let s=[];if(e instanceof Ge)n.indexOf(e.id)===-1&&s.push(e);else if(Array.isArray(e))e.forEach(r=>{n.indexOf(r.id)===-1&&s.push(r)});else if(e!=null)for(let r in e){let a=e[r];n.indexOf(a.id)===-1&&s.push(a)}s.forEach(r=>{r.isDisposed||r.dispose()})}function rM(e){return e instanceof Ge}function y1(e){return Array.isArray(e)}function hv(e){return!rM(e)&&!y1(e)}function fv(e,t,n,s=!0,r=""){if(t==null||t.length===0){if(e!=null){let o=!1;if(y1(e)&&e.length>0)o=!0;else if(hv(e)){for(let i in e)if(e.hasOwnProperty(i)){o=!0;break}}else o=!0;if(o)throw new G(`Error when checking model ${r} expected no data, but got ${e}`)}return[]}if(e==null)return t.map(o=>null);let a;if(hv(e)){e=e,a=[];for(let o of t){if(e[o]==null)throw new G(`No data provided for "${o}". Need data for each key in: ${t}`);a.push(e[o])}}else if(y1(e)){if(e=e,e.length!==t.length)throw new G(`Error when checking model ${r}: the Array of Tensors that you are passing to your model is not the size the model expected. Expected to see ${t.length} Tensor(s), but instead got the following list of Tensor(s): ${e}`);a=e}else{if(e=e,t.length>1)throw new G(`The model ${r} expects ${t.length} Tensor(s), but only received one Tensor. Found: Tensor with shape ${e.shape}`);a=[e]}if(a=pv(a),n!=null)for(let o=0;o<t.length;++o){if(n[o]==null)continue;let i=a[o];if(i.shape.length!==n[o].length)throw new G(`Error when checking ${r}: expected ${t[o]} to have ${n[o].length} dimension(s). but got array with shape ${i.shape}`);for(let l=0;l<n[o].length;++l){if(l===0&&!s)continue;let u=i.shape[l],c=n[o][l];if(c!=null&&c>=0&&u!==c)throw new G(`${r} expected a batch of elements where each example has shape [${n[o].slice(1,n[o].length)}] (i.e.,tensor shape [*,${n[o].slice(1,n[o].length)}]) but the ${r} received an input with ${i.shape[0]} examples, each with shape [${i.shape.slice(1,i.shape.length)}] (tensor shape [${i.shape}])`)}}return a}function aM(e,t,n){let s=pa(e.map(a=>a.shape[0]));s.sort();let r=pa(t.map(a=>a.shape[0]));if(r.sort(),s.length>1)throw new G(`All input Tensors (x) should have the same number of samples. Got array shapes: ${JSON.stringify(e.map(a=>a.shape))}`);if(r.length>1)throw new G(`All target Tensors (y) should have the same number of samples. Got array shapes: ${JSON.stringify(t.map(a=>a.shape))}`);if(s.length>0&&r.length>0&&!w.arraysEqual(s,r))throw new G(`Input Tensors should have the same number of samples as target Tensors. Found ${s[0]} input sample(s) and ${r[0]} target sample(s).`)}function oM(e,t,n){let s=[ti,gf,qc];for(let r=0;r<e.length;++r){let a=e[r],o=t[r],i=n[r];if(o!=null){if(o===qc&&a.shape[a.shape.length-1]===1)throw new G(`You are passing a target array of shape ${a.shape} while using a loss 'categorical_crossentropy'. 'categorical_crossentropy'expects targets to be binary matrices (1s and 0s) of shape [samples, classes].`);if(s.indexOf(o)!==-1){let l=a.shape.slice(1),u=i.slice(1);for(let c=0;c<l.length;++c){let d=l[c],p=u[c];if(p!=null&&d!==p)throw new G(`A target Tensor with shape ${a.shape} was passed for an output of shape ${i}, while using a loss function that expects targets to have the same shape as the output.`)}}}}}function mv(e,t,n,s=!0,r=""){let a;if(Array.isArray(e)){if(e.length!==t.length)throw new G(`Error when checking model ${r}: the Array of Tensors that you are passing to your model is not the size the the model expected. Expected to see ${t.length} Tensor(s), but instead got ${e.length} Tensors(s).`);a=e}else{if(t.length>1)throw new G(`The model expects ${t.length} ${r} Tensors, but only received one Tensor. Found: array with shape ${JSON.stringify(e.shape)}.`);a=[e]}if(n!=null)for(let o=0;o<t.length;++o){if(n[o]==null)continue;let i=a[o];if(i.shape.length!==n[o].length)throw new G(`Error when checking ${r}: expected ${t[o]} to have ${n[o].length} dimension(s), but got array with shape ${JSON.stringify(i.shape)}`);for(let l=0;l<n[o].length;++l){if(l===0&&!s)continue;let u=i.shape[l],c=n[o][l];if(c!=null&&c!==u)throw new G(`Error when checking ${r}: expected ${t[o]} to have shape ${JSON.stringify(n[o])} but got array with shape ${JSON.stringify(i.shape)}.`)}}}function iM(e,t){if(e==null||Array.isArray(e)&&e.length===0)return t.map(s=>[]);let n;if(typeof e=="string"||typeof e=="function")n=[e];else if(Array.isArray(e)||typeof e=="object")n=e;else throw new TypeError(`Type of metrics argument not understood. Expected an string,function, Array, or Object, found: ${e}`);if(Array.isArray(n))return t.map(s=>n);{let s=[];for(let r of t){let a=n.hasOwnProperty(r)?n[r]:[];Array.isArray(a)||(a=[a]),s.push(a)}return s}}var lM="layers-model",Fr=class extends dr{constructor(e){super(e);this.isTraining=!1}summary(e,t,n=console.log){if(!this.built)throw new G("This model has never been called, thus its weights have not been created yet. So no summary can be displayed. Build the model first (e.g., by calling it on some test data).");LP(this,e,t,n)}compile(e){if(e.loss==null&&(e.loss=[]),this.loss=e.loss,typeof e.optimizer=="string")this.optimizer_=zP(e.optimizer),this.isOptimizerOwned=!0;else{if(!(e.optimizer instanceof Dr))throw new G("User-defined optimizer must be an instance of tf.Optimizer.");this.optimizer_=e.optimizer,this.isOptimizerOwned=!1}let t=[];if(!Array.isArray(e.loss)&&typeof e.loss!="string"&&typeof e.loss!="function"){e.loss=e.loss;for(let a in e.loss)if(this.outputNames.indexOf(a)===-1)throw new G(`Unknown entry in loss dictionary: "${a}". Only expected the following keys: ${this.outputNames}`);for(let a of this.outputNames)e.loss[a]==null&&console.warn(`Output "${a}" is missing from loss dictionary. We assume this was done on purpose, and we will not be expecting data to be passed to ${a} during training`),t.push(i1(e.loss[a]))}else if(Array.isArray(e.loss)){if(e.loss.length!==this.outputs.length)throw new G(`When passing an Array as loss, it should have one entry per model output. The model has ${this.outputs.length} output(s), but you passed loss=${e.loss}.`);t=e.loss.map(o=>i1(o))}else{let a=i1(e.loss);this.outputs.forEach(o=>{t.push(a)})}this.lossFunctions=t,this.feedOutputNames=[],this.feedOutputShapes=[],this.feedLossFns=[];for(let a=0;a<this.outputs.length;++a){let o=this.internalOutputShapes[a],i=this.outputNames[a];this.feedOutputNames.push(i),this.feedOutputShapes.push(o),this.feedLossFns.push(this.lossFunctions[a])}let n=[];this.metrics=e.metrics,this.metricsNames=["loss"],this.metricsTensors=[],Qo("loss",()=>{for(let a=0;a<this.outputs.length;++a){if(n.indexOf(a)!==-1)continue;let o=this.lossFunctions[a];this.outputs.length>1&&(this.metricsTensors.push([o,a]),this.metricsNames.push(this.outputNames[a]+"_loss"))}});let s=iM(e.metrics,this.outputNames),r=(a,o,i)=>{this.outputNames.length>1&&(o=this.outputNames[a]+"_"+o),this.metricsNames.push(o),this.metricsTensors.push([i,a])};Qo("metric",()=>{for(let a=0;a<this.outputs.length;++a){if(n.indexOf(a)!==-1)continue;let o=s[a];(l=>{let u="",c,d,p;for(let h of l){if(typeof h=="string"&&["accuracy","acc","crossentropy","ce"].indexOf(h)!==-1){let m=this.internalOutputShapes[a];m[m.length-1]===1||this.lossFunctions[a]===gf?["accuracy","acc"].indexOf(h)!==-1?d=l1:["crossentropy","ce"].indexOf(h)!==-1&&(d=Q3):this.lossFunctions[a]===mf?["accuracy","acc"].indexOf(h)!==-1?d=ev:["crossentropy","ce"].indexOf(h)!==-1&&(d=tv):["accuracy","acc"].indexOf(h)!==-1?d=u1:["crossentropy","ce"].indexOf(h)!==-1&&(d=c1);let g;["accuracy","acc"].indexOf(h)!==-1?g="acc":["crossentropy","ce"].indexOf(h)!==-1&&(g="ce"),p=d,c=u+g}else p=MP(h),c=u+xf(h);let f;Qo(c,()=>{f=p}),r(a,c,f)}})(o)}}),this.collectedTrainableWeights=this.trainableWeights}checkTrainableWeightsConsistency(){this.collectedTrainableWeights!=null&&this.trainableWeights.length!==this.collectedTrainableWeights.length&&console.warn("Discrepancy between trainableweights and collected trainable weights. Did you set `model.trainable` without calling `model.compile()` afterwards?")}evaluate(e,t,n={}){let s=n.batchSize==null?32:n.batchSize;m1(s);let r=!0,a=this.standardizeUserDataXY(e,t,r,s);try{let o=a[0].concat(a[1]);this.makeTestFunction();let i=this.testFunction,l=this.testLoop(i,o,s,n.verbose,n.steps);return Un(l)}finally{si(a[0],e),si(a[1],t)}}async evaluateDataset(e,t){return this.makeTestFunction(),tM(this,e,t)}checkNumSamples(e,t,n,s="steps"){let r;if(n!=null){if(r=null,t!=null)throw new G(`If ${s} is set, batchSize must be null or undefined.Got batchSize = ${t}`)}else if(e!=null)Array.isArray(e)?r=e[0].shape[0]:r=e.shape[0];else throw new G(`Either the input data should have a defined shape, or ${s} shoud be specified.`);return r}execute(e,t){if(Array.isArray(t)&&t.length===0)throw new G("`outputs` is an empty Array, which is not allowed.");let n=Array.isArray(t),s=n?t:[t],r=this.retrieveSymbolicTensors(s),a=new ni;if(e instanceof Ge&&(e=[e]),Array.isArray(e)){if(e.length!==this.inputs.length)throw new G(`The number of inputs provided (${e.length}) does not match the number of inputs of this model (${this.inputs.length}).`);for(let i=0;i<this.inputs.length;++i)a.add(this.inputs[i],e[i])}else for(let i of this.inputs){let l=e[i.name];if(l==null)throw new G(`No value is provided for the model's input ${i.name}`);a.add(i,l)}let o=Kc(r,a);return n?o:o[0]}retrieveSymbolicTensors(e){let t=Zo(null,e.length),n=e.length;for(let s of this.layers){let r=Array.isArray(s.output)?s.output:[s.output],a=r.map(o=>o.name);for(let o=0;o<e.length;++o){let i=a.indexOf(e[o]);if(i!==-1&&(t[o]=r[i],n--),n===0)break}if(n===0)break}if(n>0){let s=[];throw t.forEach((r,a)=>{r==null&&s.push(e[a])}),new G(`Cannot find SymbolicTensors for output name(s): ${JSON.stringify(s)}`)}return t}predictLoop(e,t=32,n=!1){return H(()=>{let s=this.checkNumSamples(e);if(n)throw new ze("Verbose predictLoop() is not implemented yet.");let r=A1(s,t),a=this.outputs.map(o=>[]);for(let o=0;o<r.length;++o)H(()=>{let l=r[o][0],u=r[o][1],c=Zc(e,l,u),d=[];if(Array.isArray(c))for(let h=0;h<c.length;++h)d.push({key:this.inputs[h],value:c[h]});else d.push({key:this.inputs[0],value:c});let p=new ni(d);return Kc(this.outputs,p)}).forEach((l,u)=>a[u].push(l));return Un(a.map(o=>ft(o,0)))})}predict(e,t={}){let n=pv(e);mv(n,this.inputNames,this.feedInputShapes,!1);try{let s=t.batchSize==null?32:t.batchSize;return m1(s),this.predictLoop(n,s)}finally{si(n,e)}}predictOnBatch(e){mv(e,this.inputNames,this.feedInputShapes,!0);let t=(Array.isArray(e)?e[0]:e).shape[0];return this.predictLoop(e,t)}standardizeUserDataXY(e,t,n=!0,s){if(this.optimizer_==null)throw new Gs("You must compile a model before training/testing. Use LayersModel.compile(modelCompileArgs).");let r=[];for(let a=0;a<this.feedOutputShapes.length;++a){let o=this.feedOutputShapes[a];this.feedLossFns[a]===mf?r.push(o.slice(0,o.length-1).concat([1])):r.push(o)}if(e=fv(e,this.feedInputNames,this.feedInputShapes,!1,"input"),t=fv(t,this.feedOutputNames,r,!1,"target"),aM(e,t,null),oM(t,this.feedLossFns,this.feedOutputShapes),this.stateful&&s!=null&&s>0&&e[0].shape[0]%s!=0)throw new G(`In a stateful network, you should only pass inputs with a number of samples that is divisible by the batch size ${s}. Found: ${e[0].shape[0]} sample(s).`);return[e,t]}async standardizeUserData(e,t,n,s,r=!0,a){let[o,i]=this.standardizeUserDataXY(e,t,r,a);if(n!=null)throw new Error("sample weight is not supported yet.");let l=null;if(s!=null){let u=iv(s,this.outputNames);l=[];for(let c=0;c<u.length;++c)l.push(await lv(i[c],null,u[c]))}return[o,i,l]}testLoop(e,t,n,s=0,r){return H(()=>{let a=this.checkNumSamples(t,n,r,"steps"),o=[];if(s>0)throw new ze("Verbose mode is not implemented yet.");if(r!=null)throw new ze("steps mode in testLoop() is not implemented yet");{let i=A1(a,n),l=Ut(js(0,a));for(let u=0;u<i.length;++u){let c=i[u][0],d=i[u][1],p=ei(l,c,d-c),h=g1(t,p),f=e(h);if(u===0)for(let m=0;m<f.length;++m)o.push(Ce(0));for(let m=0;m<f.length;++m){let g=f[m];o[m]=oe(o[m],z(d-c,g))}}for(let u=0;u<o.length;++u)o[u]=he(o[u],a)}return o})}getDedupedMetricsNames(){let e=this.metricsNames,t=[];for(let n=0;n<e.length;++n){let s=e[n],r=s;w3(e,s)>1&&(r+=`_${w3(e.slice(0,n),s)}`),t.push(r)}return t}makeTrainFunction(){return e=>{let t=[],n=e.slice(0,this.inputs.length),s=e.slice(this.inputs.length,this.inputs.length+this.outputs.length),r=e.slice(this.inputs.length+this.outputs.length,this.inputs.length+this.outputs.length*2),a=[],o=()=>{let c=[];for(let f=0;f<this.inputs.length;++f)c.push({key:this.inputs[f],value:n[f]});let d=new ni(c),p=Kc(this.outputs,d,{training:!0}),h;for(let f=0;f<this.lossFunctions.length;++f){let g=this.lossFunctions[f](s[f],p[f]);r[f]!=null&&(g=KP(g,r[f]));let A=Dt(g);t.push(A),f===0?h=g:h=oe(h,g)}for(let f=0;f<this.metricsTensors.length;++f){let m;if(this.outputs.length>1&&f<this.outputs.length)m=t[f];else{let g=this.metricsTensors[f][0],A=this.metricsTensors[f][1];m=Dt(g(s[A],p[A]))}on(m),a.push(m)}return h=Dt(h),this.calculateLosses().forEach(f=>{h=oe(h,f)}),h},i=this.collectedTrainableWeights.map(c=>c.read()),l=!0;return[this.optimizer_.minimize(o,l,i)].concat(a)}}makeTestFunction(){this.testFunction=e=>H(()=>{let t=[],n,s=e.slice(0,this.inputs.length),r=e.slice(this.inputs.length,this.inputs.length+this.outputs.length),a=[];for(let l=0;l<this.inputs.length;++l)a.push({key:this.inputs[l],value:s[l]});let o=new ni(a),i=Kc(this.outputs,o);for(let l=0;l<this.lossFunctions.length;++l){let u=this.lossFunctions[l],c=Dt(u(r[l],i[l]));l===0?n=c:n=oe(n,c),t.push(n)}for(let l=0;l<this.metricsTensors.length;++l){let u=this.metricsTensors[l][0],c=this.metricsTensors[l][1],d=Dt(u(r[c],i[c]));t.push(d)}return t})}async fit(e,t,n={}){return sM(this,e,t,n)}async fitDataset(e,t){return JP(this,e,t)}async trainOnBatch(e,t){let n=await this.standardizeUserData(e,t),s=n[0],r=n[1],o=this.makeTrainFunction()(s.concat(r)),i=[];for(let l of o){let u=await l.data();i.push(u[0])}return Z(o),Un(i)}getNamedWeights(e){let t=[],n=e!=null&&e.trainableOnly,s=n?this.trainableWeights:this.weights,r=this.getWeights(n);for(let a=0;a<s.length;++a)n&&!s[a].trainable||t.push({name:s[a].originalName,tensor:r[a]});return t}set stopTraining(e){this.stopTraining_=e}get stopTraining(){return this.stopTraining_}get optimizer(){return this.optimizer_}set optimizer(e){this.optimizer_!==e&&(this.optimizer_=e,this.isOptimizerOwned=!1)}dispose(){let e=super.dispose();if(e.refCountAfterDispose===0&&this.optimizer!=null&&this.isOptimizerOwned){let t=lh().numTensors;this.optimizer_.dispose(),e.numDisposedVariables+=t-lh().numTensors}return e}getLossIdentifiers(){let e;if(typeof this.loss=="string")e=$r(this.loss);else if(Array.isArray(this.loss)){for(let t of this.loss)if(typeof t!="string")throw new Error("Serialization of non-string loss is not supported.");e=this.loss.map(t=>$r(t))}else{let t=Object.keys(this.loss);e={};let n=this.loss;for(let s of t)if(typeof n[s]=="string")e[s]=$r(n[s]);else throw new Error("Serialization of non-string loss is not supported.")}return e}getMetricIdentifiers(){if(typeof this.metrics=="string"||typeof this.metrics=="function")return[$r(xf(this.metrics))];if(Array.isArray(this.metrics))return this.metrics.map(e=>$r(xf(e)));{let e={};for(let t in this.metrics)e[t]=$r(xf(this.metrics[t]));return e}}getTrainingConfig(){return{loss:this.getLossIdentifiers(),metrics:this.getMetricIdentifiers(),optimizer_config:{class_name:this.optimizer.getClassName(),config:this.optimizer.getConfig()}}}loadTrainingConfig(e){if(e.weighted_metrics!=null)throw new Error("Loading weight_metrics is not supported yet.");if(e.loss_weights!=null)throw new Error("Loading loss_weights is not supported yet.");if(e.sample_weight_mode!=null)throw new Error("Loading sample_weight_mode is not supported yet.");let t=Xc(e.optimizer_config),n=Ks(t),s;if(typeof e.loss=="string")s=Yo(e.loss);else if(Array.isArray(e.loss))s=e.loss.map(a=>Yo(a));else if(e.loss!=null){s={};for(let a in e.loss)s[a]=Yo(e.loss[a])}let r;if(Array.isArray(e.metrics))r=e.metrics.map(a=>Yo(a));else if(e.metrics!=null){r={};for(let a in e.metrics)r[a]=Yo(e.metrics[a])}this.compile({loss:s,metrics:r,optimizer:n})}async save(e,t){if(typeof e=="string"){let l=Ln.getSaveHandlers(e);if(l.length===0)throw new G(`Cannot find any save handlers for URL '${e}'`);if(l.length>1)throw new G(`Found more than one (${l.length}) save handlers for URL '${e}'`);e=l[0]}if(e.save==null)throw new G("LayersModel.save() cannot proceed because the IOHandler provided does not have the `save` attribute defined.");let n=await Ln.encodeWeights(this.getNamedWeights(t)),s=!1,r=null,o={modelTopology:this.toJSON(r,s),format:lM,generatedBy:`TensorFlow.js tfjs-layers v${h1}`,convertedBy:null};if((t==null?!1:t.includeOptimizer)&&this.optimizer!=null){o.trainingConfig=this.getTrainingConfig();let l="optimizer",{data:u,specs:c}=await Ln.encodeWeights(await this.optimizer.getWeights(),l);n.specs.push(...c),n.data=Ln.concatenateArrayBuffers([n.data,u])}if(this.userDefinedMetadata!=null){let l=!0;sv(this.userDefinedMetadata,this.name,l),o.userDefinedMetadata=this.userDefinedMetadata}return o.weightData=n.data,o.weightSpecs=n.specs,e.save(o)}setUserDefinedMetadata(e){sv(e,this.name),this.userDefinedMetadata=e}getUserDefinedMetadata(){return this.userDefinedMetadata}};Fr.className="Model";le.registerClass(Fr);var gv=class extends Fr{};gv.className="Functional";le.registerClass(gv);async function uM(e,t){"modelTopology"in e||(e={modelTopology:e}),e=e;let n=e.modelTopology;n.model_config!=null&&(n=n.model_config);let s=Xc(n),r=Ks(s,t);if(e.weightsManifest!=null){let a=await Ln.loadWeights(e.weightsManifest,e.pathPrefix,r.weights.map(i=>i.originalName)),o={};for(let i of r.weights)o[i.originalName]=a[i.originalName];r.loadWeights(o),Z(a)}return r}async function cM(e,t){if(t==null&&(t={}),typeof e=="string"){let n=Ln.getLoadHandlers(e,t);if(n.length===0)n.push(Ln.browserHTTPRequest(e,t));else if(n.length>1)throw new G(`Found more than one (${n.length}) load handlers for URL '${e}'`);e=n[0]}return dM(e,void 0,t)}async function dM(e,t,n){if(n==null&&(n={}),e.load==null)throw new G("Cannot proceed with model loading because the IOHandler provided does not have the `load` method implemented.");let s=await e.load(),r=s.modelTopology;r.model_config!=null&&(r=r.model_config);let a=n.strict==null?!0:n.strict,o=s.weightData!=null&&s.weightSpecs!=null&&a,i=Ks(Xc(r),t,o),l=s.trainingConfig;if(l!=null&&i.loadTrainingConfig(l),s.userDefinedMetadata!=null&&i.setUserDefinedMetadata(s.userDefinedMetadata),s.weightData!=null){if(s.weightSpecs==null)throw new G("LayersModel artifacts contains weight data, but not weight specs. Therefore loading of weights cannot proceed.");let{modelWeights:u,optimizerWeights:c}=pM(s.weightData,s.weightSpecs);i.loadWeights(u,a),i.optimizer!=null&&c.length>0&&await i.optimizer.setWeights(c),Z(u),Z(c.map(d=>d.tensor))}return i}function pM(e,t){let n=Ln.decodeWeights(e,t),s={},r=[];return t.forEach(a=>{a.group==="optimizer"?r.push({name:a.name,tensor:n[a.name]}):s[a.name]=n[a.name]}),{modelWeights:s,optimizerWeights:r}}var iu=class extends Fr{constructor(e){super({inputs:[],outputs:[]});if(e=e||{},this.trainable=!0,this.built=!1,this.name=e.name!=null?e.name:uf("sequential_"),e.layers!=null)for(let t of e.layers)this.add(t)}checkShape(e){if(e.inboundNodes[0].outputTensors[0].shape.some(n=>n<0))throw new G(`Negative dimension size caused by adding layer ${e.name} with input shape [${e.inboundNodes[0].inputTensors[0].shape}]`)}add(e){let t=e instanceof iu||e instanceof Fr,n;if(t){if(n=e,n.outputs.length!==1)throw new G("All layers in a Sequential model should have a single output tensor. For multi-output layers, use the functional API.");if(n.inputs.length!==1)throw new G("All layers in a Sequential model should have a single input tensor. For multi-input layers, use the functional API.")}if(this.outputs.length===0){if(e.inboundNodes.length===0){if(e.batchInputShape==null)throw new G("The first layer in a Sequential model must get an `inputShape` or `batchInputShape` argument.");let s=U3({batchShape:e.batchInputShape,dtype:e.dtype,name:e.name+"_input"});e.apply(s)}if(t)this.outputs=n.outputs,this.inputs=n.inputs;else{if(e.inboundNodes.length!==1)throw new G(`A layer added to a Sequential model must not already be connected somewhere else. LayersModel received layer ${e.name} which has ${e.inboundNodes.length} pre-existing inbound connections.`);if(e.inboundNodes[0].outputTensors.length!==1)throw new G("All layers in a Sequential model should have a single output tensor. For multi-output layers, use the functional API.");this.checkShape(e),this.outputs=[e.inboundNodes[0].outputTensors[0]],this.inputs=V3(this.outputs[0])}this.inboundNodes=[],new pf({outboundLayer:this,inboundLayers:[],nodeIndices:[],tensorIndices:[],inputTensors:this.inputs,outputTensors:this.outputs,inputMasks:Zo(null,this.inputs.length),outputMasks:[null],inputShapes:this.inputs.map(s=>s.shape),outputShapes:this.outputs[0].shape})}else{let s=e.apply(this.outputs[0]);if(Array.isArray(s))throw new TypeError("All layers in a Sequential model should have a single output tensor. For multi-output layers, use the functional API.");this.checkShape(e),this.outputs=[s],this.inboundNodes[0].outputTensors=this.outputs,this.inboundNodes[0].outputShapes=[this.outputs[0].shape]}this.layers.push(e),this.built=!1}pop(){if(this.layers.length===0)throw new TypeError("There are no layers in the model.");if(this.layers.pop(),this.layers.length===0)this.outputs=[],this.inboundNodes=[],this.outboundNodes=[];else{let e=this.layers.length-1;this.layers[e].outboundNodes=[],this.outputs=[this.layers[e].output],this.inboundNodes[0].outputTensors=this.outputs,this.inboundNodes[0].outputShapes=[this.outputs[0].shape]}}call(e,t){return this.model==null&&this.build(),this.model.call(e,t)}build(e){if(ut(e),this.inputs.length===0||this.outputs.length===0)throw new TypeError("Sequential model cannot be built: model is empty. Add some layers first.");this.model=new Fr({inputs:this.inputs,outputs:this.outputs[0],name:this.name+"_model"}),this.model.trainable=this.trainable,this.supportsMasking=this.model.supportsMasking,this.inputLayers=this.model.inputLayers,this.inputLayersNodeIndices=this.model.inputLayersNodeIndices,this.inputLayersTensorIndices=this.model.inputLayersTensorIndices,this.outputLayers=this.model.outputLayers,this.outputLayersNodeIndices=this.model.outputLayersNodeIndices,this.outputLayersTensorIndices=this.model.outputLayersTensorIndices,this.nodesByDepth=this.model.nodesByDepth,this.containerNodes=this.model.containerNodes,this.outputNames=this.model.outputNames,this.inputNames=this.model.inputNames,this.built=!0}countParams(){return this.built||this.build(),super.countParams()}summary(e,t,n=console.log){this.built||this.build(),super.summary(e,t,n)}setWeights(e){this.model==null&&this.build(),this.model.setWeights(e)}evaluate(e,t,n={}){if(!this.built)throw new Gs("The model needs to be compiled before being used.");return this.model.evaluate(e,t,n)}async evaluateDataset(e,t){if(!this.built)throw new Gs("The model needs to be compiled before being used.");return this.model.evaluateDataset(e,t)}predict(e,t={}){return this.model==null&&this.build(),this.model.predict(e,t)}predictOnBatch(e){return this.model==null&&this.build(),this.model.predictOnBatch(e)}compile(e){this.build(),this.model.compile(e),this.optimizer_=this.model.optimizer,this.isOptimizerOwned=this.model.isOptimizerOwned,this.loss=this.model.loss,this.metrics=this.model.metrics,this.metricsTensors=this.model.metricsTensors,this.metricsNames=this.model.metricsNames}get optimizer(){return this.model==null?void 0:this.model.optimizer}set optimizer(e){this.model.optimizer=e}async fit(e,t,n={}){if(!this.built)throw new Gs("The model needs to be compiled before being used.");return this.model.fit(e,t,n)}async fitDataset(e,t){if(!this.built)throw new Gs("The model needs to be compiled before being used.");return this.model.fitDataset(e,t)}async trainOnBatch(e,t){return this.model.trainOnBatch(e,t)}static fromConfig(e,t,n={},s=!1){let r,a={};if(t instanceof Array){if(t[0].className==null||t[0].className==="Merge")throw new G("Legacy serialization format not supported yet.");r=t}else w.assert(t.layers!=null,()=>"When the config data for a Sequential model is not an Array, it must be an Object that contains the 'layers' field."),r=t.layers,delete t.layers,a=t;let o=new e(a);if(!(o instanceof iu))throw new ze(`Sequential.fromConfig called on non-Sequential input: ${o}`);for(let i of r){let u=Ks(i,void 0,s);s&&u.setFastWeightInitDuringBuild(!0),o.add(u)}return o}set stopTraining(e){if(this.model==null)throw new G("Cannot set the stopTraining property of a sequential model before it is compiled.");this.model.stopTraining=e}get stopTraining(){if(this.model==null)throw new G("Cannot get the stopTraining property of a sequential model before it is compiled.");return this.model.stopTraining}getConfig(){let e=[];for(let t of this.layers){let n={};n.className=t.getClassName(),n.config=t.getConfig(),e.push(n)}return{name:this.name,layers:e}}};iu.className="Sequential";le.registerClass(iu);function hM(e){return new Fr(e)}function fM(e){return new iu(e)}function mM(e,t){return t==null&&(t={}),cM(e,t)}function Av(e){return U3(e)}function gM(e,t){Os.registerCallbackConstructor(e,t)}var Gn=class extends le.Serializable{getConfig(){return{}}},yv=class extends Gn{apply(e,t=1){return VO(e,t)}};yv.className="elu";le.registerClass(yv);var xv=class extends Gn{apply(e){return Nh(e)}};xv.className="selu";le.registerClass(xv);var bv=class extends Gn{apply(e){return Vs(e)}};bv.className="relu";le.registerClass(bv);var vv=class extends Gn{apply(e){return H(()=>Zl(6,Vs(e)))}};vv.className="relu6";le.registerClass(vv);var wv=class extends Gn{apply(e){return e}};wv.className="linear";le.registerClass(wv);var kv=class extends Gn{apply(e){return Bn(e)}};kv.className="sigmoid";le.registerClass(kv);var Iv=class extends Gn{apply(e){return HO(e)}};Iv.className="hardSigmoid";le.registerClass(Iv);var Sv=class extends Gn{apply(e){return Go(e)}};Sv.className="softplus";le.registerClass(Sv);var Cv=class extends Gn{apply(e){return UO(e)}};Cv.className="softsign";le.registerClass(Cv);var Tv=class extends Gn{apply(e){return Vo(e)}};Tv.className="tanh";le.registerClass(Tv);var x1=class extends Gn{apply(e,t=-1){return Pc(e,t)}};x1.className="softmax";le.registerClass(x1);var Nv=class extends Gn{apply(e,t=-1){return vh(e,t)}};Nv.className="logSoftmax";le.registerClass(Nv);var Ev=class extends Gn{apply(e,t=1){return H(()=>z(Bn(z(e,t)),e))}};Ev.className="swish";le.registerClass(Ev);var Rv=class extends Gn{apply(e){return H(()=>z(e,Vo(Go(e))))}};Rv.className="mish";le.registerClass(Rv);function ga(e){return e.getClassName()}function b1(e,t={}){return Wc(e,le.SerializationMap.getMap().classNameMap,t,"activation")}function Aa(e){if(e==null){let t={};return t.className="linear",t.config={},b1(t)}if(typeof e=="string"){let t={};return t.className=e,t.config={},b1(t)}else return e instanceof Gn?e:b1(e)}function v1(e){if(e!=null&&typeof e!="object")throw new Error(`Argument to L1L2 regularizer's constructor is expected to be an object, but received: ${e}`)}var Dv=class extends le.Serializable{},Yc=class extends Dv{constructor(e){super();v1(e),this.l1=e==null||e.l1==null?.01:e.l1,this.l2=e==null||e.l2==null?.01:e.l2,this.hasL1=this.l1!==0,this.hasL2=this.l2!==0}apply(e){return H(()=>{let t=Mt([1]);return this.hasL1&&(t=oe(t,we(z(this.l1,Wt(e))))),this.hasL2&&(t=oe(t,we(z(this.l2,Gc(e))))),V(t,[])})}getConfig(){return{l1:this.l1,l2:this.l2}}static fromConfig(e,t){return new e({l1:t.l1,l2:t.l2})}};Yc.className="L1L2";le.registerClass(Yc);function AM(e){return v1(e),new Yc({l1:e!=null?e.l1:null,l2:0})}function yM(e){return v1(e),new Yc({l2:e!=null?e.l2:null,l1:0})}var _v={l1l2:"L1L2"};function mt(e){return zA(e)}function $v(e,t={}){return Wc(e,le.SerializationMap.getMap().classNameMap,t,"regularizer")}function Tt(e){if(e==null)return null;if(typeof e=="string"){let n={className:e in _v?_v[e]:e,config:{}};return $v(n)}else return e instanceof Dv?e:$v(e)}var w1=class extends et{constructor(e){super(e==null?{}:e);this.supportsMasking=!0,e!=null&&(this.maxValue=e.maxValue)}call(e,t){e=We(e);let n=Vs(e);return this.maxValue!=null&&(n=Wn(n,0,this.maxValue)),n}computeOutputShape(e){return e}getConfig(){let e={maxValue:this.maxValue},t=super.getConfig();return Object.assign(e,t),e}};w1.className="ReLU";le.registerClass(w1);var k1=class extends et{constructor(e){super(e==null?{}:e);this.DEFAULT_ALPHA=.3,e==null&&(e={}),this.alpha=e.alpha==null?this.DEFAULT_ALPHA:e.alpha}call(e,t){let n=We(e);return Tc(n,this.alpha)}computeOutputShape(e){return e}getConfig(){let e={alpha:this.alpha},t=super.getConfig();return Object.assign(e,t),e}};k1.className="LeakyReLU";le.registerClass(k1);var I1=class extends et{constructor(e){super(e==null?{}:e);if(this.DEFAULT_ALPHA_INITIALIZER="zeros",e==null&&(e={}),this.supportsMasking=!0,this.alphaInitializer=Ct(e.alphaInitializer||this.DEFAULT_ALPHA_INITIALIZER),this.alphaRegularizer=Tt(e.alphaRegularizer),this.alphaConstraint=Qt(e.alphaConstraint),e.sharedAxes==null)this.sharedAxes=null;else if(Array.isArray(e.sharedAxes))this.sharedAxes=e.sharedAxes;else if(typeof e.sharedAxes=="number")this.sharedAxes=[e.sharedAxes];else throw new G(`Expected sharedAxes to be a number or an array of numbers, but got ${e.sharedAxes}`)}build(e){e=ut(e);let t=e.slice(1);if(this.sharedAxes!=null)for(let s of this.sharedAxes)t[s-1]=1;this.alpha=this.addWeight("alpha",t,"float32",this.alphaInitializer,this.alphaRegularizer,!0,this.alphaConstraint);let n={};if(this.sharedAxes!=null)for(let s=1;s<e.length;++s)n[s]=e[s];this.inputSpec=[new Ht({ndim:e.length,axes:n})],this.built=!0}call(e,t){return e=We(e),$c(e,this.alpha.read())}getConfig(){let e={alphaInitializer:_t(this.alphaInitializer),alphaRegularizer:mt(this.alphaRegularizer),alphaConstraint:Jt(this.alphaConstraint),sharedAxes:this.sharedAxes},t=super.getConfig();return Object.assign(e,t),e}};I1.className="PReLU";le.registerClass(I1);var S1=class extends et{constructor(e){super(e==null?{}:e);if(this.DEFAULT_ALPHA=1,e==null&&(e={}),e.alpha!=null&&e.alpha!==this.DEFAULT_ALPHA)throw new ze(`Non-default alpha value (${e.alpha}) is not supported by the ELU layer yet.`);this.alpha=e.alpha==null?this.DEFAULT_ALPHA:e.alpha}call(e,t){let n=We(e);return ql(n)}computeOutputShape(e){return e}getConfig(){let e={alpha:this.alpha},t=super.getConfig();return Object.assign(e,t),e}};S1.className="ELU";le.registerClass(S1);var C1=class extends et{constructor(e){super(e==null?{}:e);this.DEFAULT_THETA=1,e==null&&(e={}),this.theta=e.theta==null?this.DEFAULT_THETA:e.theta}call(e,t){let n=We(e);return z(n,pe(Vn(n,this.theta),"float32"))}computeOutputShape(e){return e}getConfig(){let e={theta:this.theta},t=super.getConfig();return Object.assign(e,t),e}};C1.className="ThresholdedReLU";le.registerClass(C1);var T1=class extends et{constructor(e){super(e==null?{}:e);this.DEFAULT_AXIS=1,e==null&&(e={}),this.softmax=new x1().apply,this.axis=e.axis==null?this.DEFAULT_AXIS:e.axis}call(e,t){let n=We(e);return this.softmax(n,this.axis)}computeOutputShape(e){return e}getConfig(){let e={axis:this.axis},t=super.getConfig();return Object.assign(e,t),e}};T1.className="Softmax";le.registerClass(T1);function lu(e,t,n){if(typeof e=="number")return Zo(e,t);if(e.length!==t)throw new G(`The ${n} argument must be an integer or tuple of ${t} integers. Received: ${e.length} elements.`);for(let s=0;s<t;++s){let r=e[s];if(!zO(r))throw new G(`The ${n} argument must be an integer or tuple of ${t} integers. Received: ${JSON.stringify(e)} including a non-integer number ${r}`)}return e}function Zs(e,t,n,s,r=1){if(e==null)return e;let a=t+(t-1)*(r-1),o;return n==="same"?o=e:o=e-a+1,Math.floor((o+s-1)/s)}function pr(e,t,n,s){if(e==null)return null;if(s==="valid")e=e*t+fa([n-t,0]);else if(s==="same")e=e*t;else throw new G(`Unsupport padding mode: ${s}.`);return e}function N1(e,t){return H(()=>(Bt(t),t==="channelsFirst"?Ye(e,[0,2,3,1]):e))}function Fv(e,t){return H(()=>(Bt(t),t==="channelsFirst"?Ye(e,[0,2,3,4,1]):e))}function xM(e,t,n,s=1,r="valid",a,o=1){return H(()=>{if(a==null&&(a=Hs()),Bt(a),e.shape.length!==3)throw new G(`The input of a conv1dWithBias operation should be 3, but is ${e.shape.length} instead.`);if(t.shape.length!==3)throw new G(`The kernel for a conv1dWithBias operation should be 3, but is ${t.shape.length} instead`);if(n!=null&&n.shape.length!==1)throw new G(`The bias for a conv1dWithBias operation should be 1, but is ${t.shape.length} instead`);if(a==="channelsFirst"&&(e=Ye(e,[0,2,1])),r==="causal")throw new ze("The support for CAUSAL padding mode in conv1dWithBias is not implemented yet.");let i=fh(e,t,s,r==="same"?"same":"valid","NWC",o);return n!=null&&(i=qs(i,n)),i})}function Ov(e,t,n,s=[1,1],r="valid",a,o,i=null){return H(()=>{if(a==null&&(a=Hs()),Bt(a),e.rank!==3&&e.rank!==4)throw new G(`conv2dWithBiasActivation expects input to be of rank 3 or 4, but received ${e.rank}.`);if(t.rank!==3&&t.rank!==4)throw new G(`conv2dWithBiasActivation expects kernel to be of rank 3 or 4, but received ${e.rank}.`);let l=N1(e,a);if(r==="causal")throw new ze("The support for CAUSAL padding mode in conv1dWithBias is not implemented yet.");return l=da.conv2d({x:l,filter:t,strides:s,pad:r==="same"?"same":"valid",dilations:o,dataFormat:"NHWC",bias:n,activation:i}),a==="channelsFirst"&&(l=Ye(l,[0,3,1,2])),l})}function bM(e,t,n,s=[1,1,1],r="valid",a,o){return H(()=>{if(a==null&&(a=Hs()),Bt(a),e.rank!==4&&e.rank!==5)throw new G(`conv3dWithBias expects input to be of rank 4 or 5, but received ${e.rank}.`);if(t.rank!==4&&t.rank!==5)throw new G(`conv3dWithBias expects kernel to be of rank 4 or 5, but received ${e.rank}.`);let i=Fv(e,a);if(r==="causal")throw new ze("The support for CAUSAL padding mode in conv3dWithBias is not implemented yet.");return i=aA(i,t,s,r==="same"?"same":"valid","NDHWC",o),n!=null&&(i=qs(i,n)),a==="channelsFirst"&&(i=Ye(i,[0,4,1,2,3])),i})}var E1=class extends et{constructor(e,t){super(t);if(this.bias=null,this.DEFAULT_KERNEL_INITIALIZER="glorotNormal",this.DEFAULT_BIAS_INITIALIZER="zeros",E1.verifyArgs(t),this.rank=e,ln(this.rank,"rank"),this.rank!==1&&this.rank!==2&&this.rank!==3)throw new ze(`Convolution layer for rank other than 1, 2, or 3 (${this.rank}) is not implemented yet.`);if(this.kernelSize=lu(t.kernelSize,e,"kernelSize"),this.strides=lu(t.strides==null?1:t.strides,e,"strides"),this.padding=t.padding==null?"valid":t.padding,vs(this.padding),this.dataFormat=t.dataFormat==null?"channelsLast":t.dataFormat,Bt(this.dataFormat),this.activation=Aa(t.activation),this.useBias=t.useBias==null?!0:t.useBias,this.biasInitializer=Ct(t.biasInitializer||this.DEFAULT_BIAS_INITIALIZER),this.biasConstraint=Qt(t.biasConstraint),this.biasRegularizer=Tt(t.biasRegularizer),this.activityRegularizer=Tt(t.activityRegularizer),this.dilationRate=lu(t.dilationRate==null?1:t.dilationRate,e,"dilationRate"),this.rank===1&&Array.isArray(this.dilationRate)&&this.dilationRate.length!==1)throw new G(`dilationRate must be a number or an array of a single number for 1D convolution, but received ${JSON.stringify(this.dilationRate)}`);if(this.rank===2){if(typeof this.dilationRate=="number")this.dilationRate=[this.dilationRate,this.dilationRate];else if(this.dilationRate.length!==2)throw new G(`dilationRate must be a number or array of two numbers for 2D convolution, but received ${JSON.stringify(this.dilationRate)}`)}else if(this.rank===3){if(typeof this.dilationRate=="number")this.dilationRate=[this.dilationRate,this.dilationRate,this.dilationRate];else if(this.dilationRate.length!==3)throw new G(`dilationRate must be a number or array of three numbers for 3D convolution, but received ${JSON.stringify(this.dilationRate)}`)}}static verifyArgs(e){if(ur("kernelSize"in e,"required key 'kernelSize' not in config"),typeof e.kernelSize!="number"&&!BA(e.kernelSize,"number",1,3))throw new G(`BaseConv expects config.kernelSize to be number or number[] with length 1, 2, or 3, but received ${JSON.stringify(e.kernelSize)}.`)}getConfig(){let e={kernelSize:this.kernelSize,strides:this.strides,padding:this.padding,dataFormat:this.dataFormat,dilationRate:this.dilationRate,activation:ga(this.activation),useBias:this.useBias,biasInitializer:_t(this.biasInitializer),biasRegularizer:mt(this.biasRegularizer),activityRegularizer:mt(this.activityRegularizer),biasConstraint:Jt(this.biasConstraint)},t=super.getConfig();return Object.assign(e,t),e}},Jc=class extends E1{constructor(e,t){super(e,t);this.kernel=null,Jc.verifyArgs(t),this.filters=t.filters,ln(this.filters,"filters"),this.kernelInitializer=Ct(t.kernelInitializer||this.DEFAULT_KERNEL_INITIALIZER),this.kernelConstraint=Qt(t.kernelConstraint),this.kernelRegularizer=Tt(t.kernelRegularizer)}build(e){e=ut(e);let t=this.dataFormat==="channelsFirst"?1:e.length-1;if(e[t]==null)throw new G(`The channel dimension of the input should be defined. Found ${e[t]}`);let n=e[t],s=this.kernelSize.concat([n,this.filters]);this.kernel=this.addWeight("kernel",s,null,this.kernelInitializer,this.kernelRegularizer,!0,this.kernelConstraint),this.useBias&&(this.bias=this.addWeight("bias",[this.filters],null,this.biasInitializer,this.biasRegularizer,!0,this.biasConstraint)),this.inputSpec=[{ndim:this.rank+2,axes:{[t]:n}}],this.built=!0}call(e,t){return H(()=>{e=We(e);let n,s=this.bias==null?null:this.bias.read(),r=I3(this.activation.getClassName());if(r!=null&&this.rank===2)n=Ov(e,this.kernel.read(),s,this.strides,this.padding,this.dataFormat,this.dilationRate,r);else{if(this.rank===1)n=xM(e,this.kernel.read(),s,this.strides[0],this.padding,this.dataFormat,this.dilationRate[0]);else if(this.rank===2)n=Ov(e,this.kernel.read(),s,this.strides,this.padding,this.dataFormat,this.dilationRate);else if(this.rank===3)n=bM(e,this.kernel.read(),s,this.strides,this.padding,this.dataFormat,this.dilationRate);else throw new ze("convolutions greater than 3D are not implemented yet.");this.activation!=null&&(n=this.activation.apply(n))}return n})}computeOutputShape(e){e=ut(e);let t=[],n=this.dataFormat==="channelsLast"?e.slice(1,e.length-1):e.slice(2);for(let r=0;r<n.length;++r){let a=Zs(n[r],this.kernelSize[r],this.padding,this.strides[r],typeof this.dilationRate=="number"?this.dilationRate:this.dilationRate[r]);t.push(a)}let s=[e[0]];return this.dataFormat==="channelsLast"?(s=s.concat(t),s.push(this.filters)):(s.push(this.filters),s=s.concat(t)),s}getConfig(){let e={filters:this.filters,kernelInitializer:_t(this.kernelInitializer),kernelRegularizer:mt(this.kernelRegularizer),kernelConstraint:Jt(this.kernelConstraint)},t=super.getConfig();return Object.assign(e,t),e}static verifyArgs(e){if(!("filters"in e)||typeof e.filters!="number"||e.filters<1)throw new G(`Convolution layer expected config.filters to be a 'number' > 0 but got ${JSON.stringify(e.filters)}`)}},Qc=class extends Jc{constructor(e){super(2,e);Qc.verifyArgs(e)}getConfig(){let e=super.getConfig();return delete e.rank,e}static verifyArgs(e){if(typeof e.kernelSize!="number"&&!BA(e.kernelSize,"number",1,2))throw new G(`Conv2D expects config.kernelSize to be number or number[] with length 1 or 2, but received ${JSON.stringify(e.kernelSize)}.`)}};Qc.className="Conv2D";le.registerClass(Qc);var ed=class extends Jc{constructor(e){super(3,e);ed.verifyArgs(e)}getConfig(){let e=super.getConfig();return delete e.rank,e}static verifyArgs(e){if(typeof e.kernelSize!="number"&&!(Array.isArray(e.kernelSize)&&(e.kernelSize.length===1||e.kernelSize.length===3)))throw new G(`Conv3D expects config.kernelSize to be number or [number, number, number], but received ${JSON.stringify(e.kernelSize)}.`)}};ed.className="Conv3D";le.registerClass(ed);var R1=class extends Qc{constructor(e){super(e);if(this.inputSpec=[new Ht({ndim:4})],this.padding!=="same"&&this.padding!=="valid")throw new G(`Conv2DTranspose currently supports only padding modes 'same' and 'valid', but received padding mode ${this.padding}`)}build(e){if(e=ut(e),e.length!==4)throw new G("Input should have rank 4; Received input shape: "+JSON.stringify(e));let t=this.dataFormat==="channelsFirst"?1:e.length-1;if(e[t]==null)throw new G("The channel dimension of the inputs should be defined. Found `None`.");let n=e[t],s=this.kernelSize.concat([this.filters,n]);this.kernel=this.addWeight("kernel",s,"float32",this.kernelInitializer,this.kernelRegularizer,!0,this.kernelConstraint),this.useBias&&(this.bias=this.addWeight("bias",[this.filters],"float32",this.biasInitializer,this.biasRegularizer,!0,this.biasConstraint)),this.inputSpec=[new Ht({ndim:4,axes:{[t]:n}})],this.built=!0}call(e,t){return H(()=>{let n=We(e);if(n.shape.length!==4)throw new G(`Conv2DTranspose.call() expects input tensor to be rank-4, but received a tensor of rank-${n.shape.length}`);let s=n.shape,r=s[0],a,o;this.dataFormat==="channelsFirst"?(a=2,o=3):(a=1,o=2);let i=s[a],l=s[o],u=this.kernelSize[0],c=this.kernelSize[1],d=this.strides[0],p=this.strides[1],h=pr(i,d,u,this.padding),f=pr(l,p,c,this.padding),m=[r,h,f,this.filters];this.dataFormat!=="channelsLast"&&(n=Ye(n,[0,2,3,1]));let g=mh(n,this.kernel.read(),m,this.strides,this.padding);return this.dataFormat!=="channelsLast"&&(g=Ye(g,[0,3,1,2])),this.bias!=null&&(g=qs(g,this.bias.read(),this.dataFormat)),this.activation!=null&&(g=this.activation.apply(g)),g})}computeOutputShape(e){e=ut(e);let t=e.slice(),n,s,r;this.dataFormat==="channelsFirst"?(n=1,s=2,r=3):(n=3,s=1,r=2);let a=this.kernelSize[0],o=this.kernelSize[1],i=this.strides[0],l=this.strides[1];return t[n]=this.filters,t[s]=pr(t[s],i,a,this.padding),t[r]=pr(t[r],l,o,this.padding),t}getConfig(){let e=super.getConfig();return delete e.dilationRate,e}};R1.className="Conv2DTranspose";le.registerClass(R1);var D1=class extends ed{constructor(e){super(e);if(this.inputSpec=[new Ht({ndim:5})],this.padding!=="same"&&this.padding!=="valid")throw new G(`Conv3DTranspose currently supports only padding modes 'same' and 'valid', but received padding mode ${this.padding}`)}build(e){if(e=ut(e),e.length!==5)throw new G("Input should have rank 5; Received input shape: "+JSON.stringify(e));let t=this.dataFormat==="channelsFirst"?1:e.length-1;if(e[t]==null)throw new G("The channel dimension of the inputs should be defined. Found `None`.");let n=e[t],s=this.kernelSize.concat([this.filters,n]);this.kernel=this.addWeight("kernel",s,"float32",this.kernelInitializer,this.kernelRegularizer,!0,this.kernelConstraint),this.useBias&&(this.bias=this.addWeight("bias",[this.filters],"float32",this.biasInitializer,this.biasRegularizer,!0,this.biasConstraint)),this.inputSpec=[new Ht({ndim:5,axes:{[t]:n}})],this.built=!0}call(e,t){return H(()=>{let n=We(e);if(n.shape.length!==5)throw new G(`Conv3DTranspose.call() expects input tensor to be rank-4, but received a tensor of rank-${n.shape.length}`);let s=n.shape,r=s[0],a,o,i;this.dataFormat==="channelsFirst"?(i=2,a=3,o=4):(i=1,a=2,o=3);let l=s[i],u=s[a],c=s[o],d=this.kernelSize[0],p=this.kernelSize[1],h=this.kernelSize[2],f=this.strides[0],m=this.strides[1],g=this.strides[2],A=pr(l,f,d,this.padding),y=pr(u,m,p,this.padding),x=pr(c,g,h,this.padding),b=[r,A,y,x,this.filters];this.dataFormat!=="channelsLast"&&(n=Ye(n,[0,2,3,4,1]));let v=Ib(n,this.kernel.read(),b,this.strides,this.padding);return this.dataFormat!=="channelsLast"&&(v=Ye(v,[0,4,1,2,3])),this.bias!==null&&(v=qs(v,this.bias.read(),this.dataFormat)),this.activation!==null&&(v=this.activation.apply(v)),v})}computeOutputShape(e){e=ut(e);let t=e.slice(),n,s,r,a;this.dataFormat==="channelsFirst"?(n=1,s=2,r=3,a=4):(n=4,s=1,r=2,a=3);let o=this.kernelSize[0],i=this.kernelSize[1],l=this.kernelSize[2],u=this.strides[0],c=this.strides[1],d=this.strides[2];return t[n]=this.filters,t[s]=pr(t[s],u,o,this.padding),t[r]=pr(t[r],c,i,this.padding),t[a]=pr(t[a],d,l,this.padding),t}getConfig(){let e=super.getConfig();return delete e.dilationRate,e}};D1.className="Conv3DTranspose";le.registerClass(D1);var Pv=class extends Jc{constructor(e,t){super(e,t);if(this.DEFAULT_DEPTHWISE_INITIALIZER="glorotUniform",this.DEFAULT_POINTWISE_INITIALIZER="glorotUniform",this.depthwiseKernel=null,this.pointwiseKernel=null,t.filters==null)throw new G("The `filters` configuration field is required by SeparableConv, but is unspecified.");if(t.kernelInitializer!=null||t.kernelRegularizer!=null||t.kernelConstraint!=null)throw new G("Fields kernelInitializer, kernelRegularizer and kernelConstraint are invalid for SeparableConv2D. Use depthwiseInitializer, depthwiseRegularizer, depthwiseConstraint, pointwiseInitializer, pointwiseRegularizer and pointwiseConstraint instead.");if(t.padding!=null&&t.padding!=="same"&&t.padding!=="valid")throw new G(`SeparableConv${this.rank}D supports only padding modes: 'same' and 'valid', but received ${JSON.stringify(t.padding)}`);this.depthMultiplier=t.depthMultiplier==null?1:t.depthMultiplier,this.depthwiseInitializer=Ct(t.depthwiseInitializer||this.DEFAULT_DEPTHWISE_INITIALIZER),this.depthwiseRegularizer=Tt(t.depthwiseRegularizer),this.depthwiseConstraint=Qt(t.depthwiseConstraint),this.pointwiseInitializer=Ct(t.depthwiseInitializer||this.DEFAULT_POINTWISE_INITIALIZER),this.pointwiseRegularizer=Tt(t.pointwiseRegularizer),this.pointwiseConstraint=Qt(t.pointwiseConstraint)}build(e){if(e=ut(e),e.length<this.rank+2)throw new G(`Inputs to SeparableConv${this.rank}D should have rank ${this.rank+2}, but received input shape: ${JSON.stringify(e)}`);let t=this.dataFormat==="channelsFirst"?1:e.length-1;if(e[t]==null||e[t]<0)throw new G(`The channel dimension of the inputs should be defined, but found ${JSON.stringify(e[t])}`);let n=e[t],s=this.kernelSize.concat([n,this.depthMultiplier]),r=[];for(let o=0;o<this.rank;++o)r.push(1);r.push(n*this.depthMultiplier,this.filters);let a=!0;this.depthwiseKernel=this.addWeight("depthwise_kernel",s,"float32",this.depthwiseInitializer,this.depthwiseRegularizer,a,this.depthwiseConstraint),this.pointwiseKernel=this.addWeight("pointwise_kernel",r,"float32",this.pointwiseInitializer,this.pointwiseRegularizer,a,this.pointwiseConstraint),this.useBias?this.bias=this.addWeight("bias",[this.filters],"float32",this.biasInitializer,this.biasRegularizer,a,this.biasConstraint):this.bias=null,this.inputSpec=[new Ht({ndim:this.rank+2,axes:{[t]:n}})],this.built=!0}call(e,t){return H(()=>{e=We(e);let n;if(this.rank===1)throw new ze("1D separable convolution is not implemented yet.");return this.rank===2&&(this.dataFormat==="channelsFirst"&&(e=Ye(e,[0,2,3,1])),n=kA(e,this.depthwiseKernel.read(),this.pointwiseKernel.read(),this.strides,this.padding,this.dilationRate,"NHWC")),this.useBias&&(n=qs(n,this.bias.read(),this.dataFormat)),this.activation!=null&&(n=this.activation.apply(n)),this.dataFormat==="channelsFirst"&&(n=Ye(n,[0,3,1,2])),n})}getConfig(){let e=super.getConfig();return delete e.rank,delete e.kernelInitializer,delete e.kernelRegularizer,delete e.kernelConstraint,e.depthwiseInitializer=_t(this.depthwiseInitializer),e.pointwiseInitializer=_t(this.pointwiseInitializer),e.depthwiseRegularizer=mt(this.depthwiseRegularizer),e.pointwiseRegularizer=mt(this.pointwiseRegularizer),e.depthwiseConstraint=Jt(this.depthwiseConstraint),e.pointwiseConstraint=Jt(this.pointwiseConstraint),e}};Pv.className="SeparableConv";var _1=class extends Pv{constructor(e){super(2,e)}};_1.className="SeparableConv2D";le.registerClass(_1);var vf=class extends Jc{constructor(e){super(1,e);vf.verifyArgs(e),this.inputSpec=[{ndim:3}]}getConfig(){let e=super.getConfig();return delete e.rank,delete e.dataFormat,e}static verifyArgs(e){if(typeof e.kernelSize!="number"&&!BA(e.kernelSize,"number",1,1))throw new G(`Conv1D expects config.kernelSize to be number or number[] with length 1, but received ${JSON.stringify(e.kernelSize)}.`)}};vf.className="Conv1D";le.registerClass(vf);var $1=class extends et{constructor(e){super(e);typeof e.cropping=="number"?this.cropping=[[e.cropping,e.cropping],[e.cropping,e.cropping]]:typeof e.cropping[0]=="number"?this.cropping=[[e.cropping[0],e.cropping[0]],[e.cropping[1],e.cropping[1]]]:this.cropping=e.cropping,this.dataFormat=e.dataFormat===void 0?"channelsLast":e.dataFormat,this.inputSpec=[{ndim:4}]}computeOutputShape(e){return this.dataFormat==="channelsFirst"?[e[0],e[1],e[2]-this.cropping[0][0]-this.cropping[0][1],e[3]-this.cropping[1][0]-this.cropping[1][1]]:[e[0],e[1]-this.cropping[0][0]-this.cropping[0][1],e[2]-this.cropping[1][0]-this.cropping[1][1],e[3]]}call(e,t){return H(()=>{if(e=We(e),this.dataFormat==="channelsLast"){let n=Jh(e,this.cropping[0][0],e.shape[1]-this.cropping[0][0]-this.cropping[0][1],2);return Jh(n,this.cropping[1][0],e.shape[2]-this.cropping[1][1]-this.cropping[1][0],3)}else{let n=Jh(e,this.cropping[0][0],e.shape[2]-this.cropping[0][0]-this.cropping[0][1],3);return Jh(n,this.cropping[1][0],e.shape[3]-this.cropping[1][1]-this.cropping[1][0],4)}})}getConfig(){let e={cropping:this.cropping,dataFormat:this.dataFormat},t=super.getConfig();return Object.assign(e,t),e}};$1.className="Cropping2D";le.registerClass($1);var F1=class extends et{constructor(e){super(e);this.DEFAULT_SIZE=[2,2],this.inputSpec=[{ndim:4}],this.size=e.size==null?this.DEFAULT_SIZE:e.size,this.dataFormat=e.dataFormat==null?"channelsLast":e.dataFormat,Bt(this.dataFormat),this.interpolation=e.interpolation==null?"nearest":e.interpolation,OO(this.interpolation)}computeOutputShape(e){if(this.dataFormat==="channelsFirst"){let t=e[2]==null?null:this.size[0]*e[2],n=e[3]==null?null:this.size[1]*e[3];return[e[0],e[1],t,n]}else{let t=e[1]==null?null:this.size[0]*e[1],n=e[2]==null?null:this.size[1]*e[2];return[e[0],t,n,e[3]]}}call(e,t){return H(()=>{let n=We(e),s=n.shape;if(this.dataFormat==="channelsFirst"){n=Ye(n,[0,2,3,1]);let r=this.size[0]*s[2],a=this.size[1]*s[3],o=this.interpolation==="nearest"?$e.resizeNearestNeighbor(n,[r,a]):$e.resizeBilinear(n,[r,a]);return Ye(o,[0,3,1,2])}else{let r=this.size[0]*s[1],a=this.size[1]*s[2];return this.interpolation==="nearest"?$e.resizeNearestNeighbor(n,[r,a]):$e.resizeBilinear(n,[r,a])}})}getConfig(){let e={size:this.size,dataFormat:this.dataFormat},t=super.getConfig();return Object.assign(e,t),e}};F1.className="UpSampling2D";le.registerClass(F1);function vM(e,t,n=[1,1],s="valid",r,a){return H(()=>{r==null&&(r=Hs()),Bt(r);let o=N1(e,r);if(e.rank!==4)throw new G(`Input for depthwiseConv2d is required to be 4-D, but is instead ${e.rank}-D`);if(t.rank!==4)throw new G(`depthwiseKernel is required to be 4-D, but is instead ${t.rank}-D`);return o=jl(o,t,n,s==="same"?"same":"valid","NHWC",a),r==="channelsFirst"&&(o=Ye(o,[0,3,1,2])),o})}var O1=class extends E1{constructor(e){super(2,e);this.depthwiseKernel=null,this.depthMultiplier=e.depthMultiplier==null?1:e.depthMultiplier,this.depthwiseInitializer=Ct(e.depthwiseInitializer||this.DEFAULT_KERNEL_INITIALIZER),this.depthwiseConstraint=Qt(e.depthwiseConstraint),this.depthwiseRegularizer=Tt(e.depthwiseRegularizer)}build(e){if(e=ut(e),e.length<4)throw new G(`Inputs to DepthwiseConv2D should have rank 4. Received input shape: ${JSON.stringify(e)}.`);let t=this.dataFormat==="channelsFirst"?1:3;if(e[t]==null||e[t]<0)throw new G(`The channel dimension of the inputs to DepthwiseConv2D should be defined, but is not (${e[t]}).`);let n=e[t],s=[this.kernelSize[0],this.kernelSize[1],n,this.depthMultiplier];this.depthwiseKernel=this.addWeight("depthwise_kernel",s,null,this.depthwiseInitializer,this.depthwiseRegularizer,!0,this.depthwiseConstraint),this.useBias?this.bias=this.addWeight("bias",[n*this.depthMultiplier],null,this.biasInitializer,this.biasRegularizer,!0,this.biasConstraint):this.bias=null,this.built=!0}call(e,t){return H(()=>{e=We(e);let n=vM(e,this.depthwiseKernel.read(),this.strides,this.padding,this.dataFormat,null);return this.useBias&&(n=qs(n,this.bias.read(),this.dataFormat)),this.activation!=null&&(n=this.activation.apply(n)),n})}computeOutputShape(e){e=ut(e);let t=this.dataFormat==="channelsFirst"?e[2]:e[1],n=this.dataFormat==="channelsFirst"?e[3]:e[2],s=this.dataFormat==="channelsFirst"?e[1]*this.depthMultiplier:e[3]*this.depthMultiplier,r=Zs(t,this.kernelSize[0],this.padding,this.strides[0]),a=Zs(n,this.kernelSize[1],this.padding,this.strides[1]);return this.dataFormat==="channelsFirst"?[e[0],s,r,a]:[e[0],r,a,s]}getConfig(){let e=super.getConfig();return e.depthMultiplier=this.depthMultiplier,e.depthwiseInitializer=_t(this.depthwiseInitializer),e.depthwiseRegularizer=mt(this.depthwiseRegularizer),e.depthwiseConstraint=Jt(this.depthwiseRegularizer),e}};O1.className="DepthwiseConv2D";le.registerClass(O1);function Mv(e,t,n,s){if(Array.isArray(e)){if(t!=null||n!=null)throw new G("When inputs is an array, neither initialState or constants should be provided");s!=null&&(n=e.slice(e.length-s,e.length),e=e.slice(0,e.length-s)),e.length>1&&(t=e.slice(1,e.length)),e=e[0]}function r(a){return a==null||Array.isArray(a)?a:[a]}return t=r(t),n=r(n),{inputs:e,initialState:t,constants:n}}function zv(e,t,n,s=!1,r,a,o=!1,i=!1){return H(()=>{let l=t.shape.length;if(l<3)throw new G(`Input should be at least 3D, but is ${l}D.`);let u=[1,0].concat(js(2,l));if(t=Ye(t,u),a!=null)throw new ze("The rnn() functoin of the deeplearn.js backend does not support constants yet.");o&&console.warn("Backend rnn(): the unroll = true option is not applicable to the imperative deeplearn.js backend."),r!=null&&(r=pe(pe(r,"bool"),"float32"),r.rank===l-1&&(r=Lt(r,-1)),r=Ye(r,u)),s&&(t=os(t,0),r!=null&&(r=os(r,0)));let c=[],d,p=n,h=t.shape[0],f=is(t),m;r!=null&&(m=is(r));for(let A=0;A<h;++A){let y=f[A],x=H(()=>e(y,p));if(r==null)d=x[0],p=x[1];else{let b=H(()=>{let v=m[A],k=ye(as(v),v),S=oe(z(x[0],v),z(p[0],k)),C=p.map((D,O)=>oe(z(x[1][O],v),z(D,k)));return{output:S,newStates:C}});d=b.output,p=b.newStates}i&&c.push(d)}let g;return i&&(g=mn(c,1)),[d,g,p]})}var hr=class extends et{constructor(e){super(e);let t;if(e.cell==null)throw new G("cell property is missing for the constructor of RNN.");if(Array.isArray(e.cell)?t=new If({cells:e.cell}):t=e.cell,t.stateSize==null)throw new G("The RNN cell should have an attribute `stateSize` (tuple of integers, one integer per RNN state).");this.cell=t,this.returnSequences=e.returnSequences==null?!1:e.returnSequences,this.returnState=e.returnState==null?!1:e.returnState,this.goBackwards=e.goBackwards==null?!1:e.goBackwards,this._stateful=e.stateful==null?!1:e.stateful,this.unroll=e.unroll==null?!1:e.unroll,this.supportsMasking=!0,this.inputSpec=[new Ht({ndim:3})],this.stateSpec=null,this.states_=null,this.numConstants=null,this.keptStates=[]}getStates(){if(this.states_==null){let e=Array.isArray(this.cell.stateSize)?this.cell.stateSize.length:1;return js(0,e).map(t=>null)}else return this.states_}setStates(e){this.states_=e}computeOutputShape(e){s1(e)&&(e=e[0]),e=e;let t=this.cell.stateSize;Array.isArray(t)||(t=[t]);let n=t[0],s;if(this.returnSequences?s=[e[0],e[1],n]:s=[e[0],n],this.returnState){let r=[];for(let a of t)r.push([e[0],a]);return[s].concat(r)}else return s}computeMask(e,t){return H(()=>{Array.isArray(t)&&(t=t[0]);let n=this.returnSequences?t:null;if(this.returnState){let s=this.states.map(r=>null);return[n].concat(s)}else return n})}get states(){if(this.states_==null){let e=Array.isArray(this.cell.stateSize)?this.cell.stateSize.length:1,t=[];for(let n=0;n<e;++n)t.push(null);return t}else return this.states_}set states(e){this.states_=e}build(e){let t=null;if(this.numConstants!=null)throw new ze("Constants support is not implemented in RNN yet.");s1(e)&&(e=e[0]),e=e;let n=this.stateful?e[0]:null,s=e.slice(2);this.inputSpec[0]=new Ht({shape:[n,null,...s]});let r=[e[0]].concat(e.slice(2));if(t!=null)throw new ze("Constants support is not implemented in RNN yet.");this.cell.build(r);let a;if(Array.isArray(this.cell.stateSize)?a=this.cell.stateSize:a=[this.cell.stateSize],this.stateSpec!=null){if(!w.arraysEqual(this.stateSpec.map(o=>o.shape[o.shape.length-1]),a))throw new G(`An initialState was passed that is not compatible with cell.stateSize. Received stateSpec=${this.stateSpec}; However cell.stateSize is ${this.cell.stateSize}`)}else this.stateSpec=a.map(o=>new Ht({shape:[null,o]}));this.stateful&&this.resetStates()}resetStates(e,t=!1){H(()=>{if(!this.stateful)throw new _r("Cannot call resetStates() on an RNN Layer that is not stateful.");let n=this.inputSpec[0].shape[0];if(n==null)throw new G("If an RNN is stateful, it needs to know its batch size. Specify the batch size of your input tensors: \n- If using a Sequential model, specify the batch size by passing a `batchInputShape` option to your first layer.\n- If using the functional API, specify the batch size by passing a `batchShape` option to your Input layer.");if(this.states_==null)Array.isArray(this.cell.stateSize)?this.states_=this.cell.stateSize.map(s=>Mt([n,s])):this.states_=[Mt([n,this.cell.stateSize])];else if(e==null)Z(this.states_),this.keptStates!=null&&(Z(this.keptStates),this.keptStates=[]),Array.isArray(this.cell.stateSize)?this.states_=this.cell.stateSize.map(s=>Mt([n,s])):this.states_[0]=Mt([n,this.cell.stateSize]);else{if(Array.isArray(e)||(e=[e]),e.length!==this.states_.length)throw new G(`Layer ${this.name} expects ${this.states_.length} state(s), but it received ${e.length} state value(s). Input received: ${e}`);t===!0?this.keptStates.push(this.states_.slice()):Z(this.states_);for(let s=0;s<this.states_.length;++s){let r=e[s],a=Array.isArray(this.cell.stateSize)?this.cell.stateSize[s]:this.cell.stateSize,o=[n,a];if(!w.arraysEqual(r.shape,o))throw new G(`State ${s} is incompatible with layer ${this.name}: expected shape=${o}, received shape=${r.shape}`);this.states_[s]=r}}this.states_=this.states_.map(s=>on(s.clone()))})}apply(e,t){let n=t==null?null:t.initialState,s=t==null?null:t.constants;t==null&&(t={});let r=Mv(e,n,s,this.numConstants);e=r.inputs,n=r.initialState,s=r.constants;let a=[],o=[];if(n!=null){t.initialState=n,a=a.concat(n),this.stateSpec=[];for(let l of n)this.stateSpec.push(new Ht({shape:l.shape}));o=o.concat(this.stateSpec)}if(s!=null&&(t.constants=s,a=a.concat(s),this.numConstants=s.length),a[0]instanceof Xs){let l=[e].concat(a),u=this.inputSpec.concat(o),c=this.inputSpec;this.inputSpec=u;let d=super.apply(l,t);return this.inputSpec=c,d}else return super.apply(e,t)}call(e,t){return H(()=>{let n=t==null?null:t.mask,s=t==null?null:t.training,r=t==null?null:t.initialState;e=We(e),r==null&&(this.stateful?r=this.states_:r=this.getInitialState(e));let a=Array.isArray(this.cell.stateSize)?this.cell.stateSize.length:1;if(r.length!==a)throw new G(`RNN Layer has ${a} state(s) but was passed ${r.length} initial state(s).`);this.unroll&&console.warn("Ignoring unroll = true for RNN layer, due to imperative backend.");let o={training:s},l=zv((h,f)=>{let m=this.cell.call([h].concat(f),o);return[m[0],m.slice(1)]},e,r,this.goBackwards,n,null,this.unroll,this.returnSequences),u=l[0],c=l[1],d=l[2];this.stateful&&this.resetStates(d,s);let p=this.returnSequences?c:u;return this.returnState?[p].concat(d):p})}getInitialState(e){return H(()=>{let t=Mt(e.shape);return t=we(t,[1,2]),t=Hc(t),Array.isArray(this.cell.stateSize)?this.cell.stateSize.map(n=>n>1?XA(t,[1,n]):t):this.cell.stateSize>1?[XA(t,[1,this.cell.stateSize])]:[t]})}get trainableWeights(){return this.trainable?this.cell.trainableWeights:[]}get nonTrainableWeights(){return this.trainable?this.cell.nonTrainableWeights:this.cell.weights}setFastWeightInitDuringBuild(e){super.setFastWeightInitDuringBuild(e),this.cell!=null&&this.cell.setFastWeightInitDuringBuild(e)}getConfig(){let e=super.getConfig(),t={returnSequences:this.returnSequences,returnState:this.returnState,goBackwards:this.goBackwards,stateful:this.stateful,unroll:this.unroll};this.numConstants!=null&&(t.numConstants=this.numConstants);let n=this.cell.getConfig();return this.getClassName()===hr.className&&(t.cell={className:this.cell.getClassName(),config:n}),Object.assign({},n,e,t)}static fromConfig(e,t,n={}){let s=t.cell,r=Ks(s,n);return new e(Object.assign(t,{cell:r}))}};hr.className="RNN";le.registerClass(hr);var td=class extends et{},wf=class extends td{constructor(e){super(e);this.DEFAULT_ACTIVATION="tanh",this.DEFAULT_KERNEL_INITIALIZER="glorotNormal",this.DEFAULT_RECURRENT_INITIALIZER="orthogonal",this.DEFAULT_BIAS_INITIALIZER="zeros",this.units=e.units,ln(this.units,"units"),this.activation=Aa(e.activation==null?this.DEFAULT_ACTIVATION:e.activation),this.useBias=e.useBias==null?!0:e.useBias,this.kernelInitializer=Ct(e.kernelInitializer||this.DEFAULT_KERNEL_INITIALIZER),this.recurrentInitializer=Ct(e.recurrentInitializer||this.DEFAULT_RECURRENT_INITIALIZER),this.biasInitializer=Ct(e.biasInitializer||this.DEFAULT_BIAS_INITIALIZER),this.kernelRegularizer=Tt(e.kernelRegularizer),this.recurrentRegularizer=Tt(e.recurrentRegularizer),this.biasRegularizer=Tt(e.biasRegularizer),this.kernelConstraint=Qt(e.kernelConstraint),this.recurrentConstraint=Qt(e.recurrentConstraint),this.biasConstraint=Qt(e.biasConstraint),this.dropout=su([1,fa([0,e.dropout==null?0:e.dropout])]),this.recurrentDropout=su([1,fa([0,e.recurrentDropout==null?0:e.recurrentDropout])]),this.stateSize=this.units,this.dropoutMask=null,this.recurrentDropoutMask=null}build(e){e=ut(e),this.kernel=this.addWeight("kernel",[e[e.length-1],this.units],null,this.kernelInitializer,this.kernelRegularizer,!0,this.kernelConstraint),this.recurrentKernel=this.addWeight("recurrent_kernel",[this.units,this.units],null,this.recurrentInitializer,this.recurrentRegularizer,!0,this.recurrentConstraint),this.useBias?this.bias=this.addWeight("bias",[this.units],null,this.biasInitializer,this.biasRegularizer,!0,this.biasConstraint):this.bias=null,this.built=!0}call(e,t){return H(()=>{if(e=e,e.length!==2)throw new G(`SimpleRNNCell expects 2 input Tensors, got ${e.length}.`);let n=e[1];e=e[0];let s=t.training==null?!1:t.training;0<this.dropout&&this.dropout<1&&this.dropoutMask==null&&(this.dropoutMask=ya({ones:()=>as(e),rate:this.dropout,training:s})),0<this.recurrentDropout&&this.recurrentDropout<1&&this.recurrentDropoutMask==null&&(this.recurrentDropoutMask=ya({ones:()=>as(n),rate:this.recurrentDropout,training:s}));let r,a=this.dropoutMask,o=this.recurrentDropoutMask;a!=null?r=cr(z(e,a),this.kernel.read()):r=cr(e,this.kernel.read()),this.bias!=null&&(r=qs(r,this.bias.read())),o!=null&&(n=z(n,o));let i=oe(r,cr(n,this.recurrentKernel.read()));return this.activation!=null&&(i=this.activation.apply(i)),[i,i]})}getConfig(){let e=super.getConfig(),t={units:this.units,activation:ga(this.activation),useBias:this.useBias,kernelInitializer:_t(this.kernelInitializer),recurrentInitializer:_t(this.recurrentInitializer),biasInitializer:_t(this.biasInitializer),kernelRegularizer:mt(this.kernelRegularizer),recurrentRegularizer:mt(this.recurrentRegularizer),biasRegularizer:mt(this.biasRegularizer),activityRegularizer:mt(this.activityRegularizer),kernelConstraint:Jt(this.kernelConstraint),recurrentConstraint:Jt(this.recurrentConstraint),biasConstraint:Jt(this.biasConstraint),dropout:this.dropout,recurrentDropout:this.recurrentDropout};return Object.assign({},e,t)}};wf.className="SimpleRNNCell";le.registerClass(wf);var P1=class extends hr{constructor(e){e.cell=new wf(e);super(e)}call(e,t){return H(()=>{this.cell.dropoutMask!=null&&(Z(this.cell.dropoutMask),this.cell.dropoutMask=null),this.cell.recurrentDropoutMask!=null&&(Z(this.cell.recurrentDropoutMask),this.cell.recurrentDropoutMask=null);let n=t==null?null:t.mask,s=t==null?null:t.training,r=t==null?null:t.initialState;return super.call(e,{mask:n,training:s,initialState:r})})}static fromConfig(e,t){return new e(t)}};P1.className="SimpleRNN";le.registerClass(P1);var kf=class extends td{constructor(e){super(e);if(this.DEFAULT_ACTIVATION="tanh",this.DEFAULT_RECURRENT_ACTIVATION="hardSigmoid",this.DEFAULT_KERNEL_INITIALIZER="glorotNormal",this.DEFAULT_RECURRENT_INITIALIZER="orthogonal",this.DEFAULT_BIAS_INITIALIZER="zeros",e.resetAfter)throw new G("GRUCell does not support reset_after parameter set to true.");this.units=e.units,ln(this.units,"units"),this.activation=Aa(e.activation===void 0?this.DEFAULT_ACTIVATION:e.activation),this.recurrentActivation=Aa(e.recurrentActivation===void 0?this.DEFAULT_RECURRENT_ACTIVATION:e.recurrentActivation),this.useBias=e.useBias==null?!0:e.useBias,this.kernelInitializer=Ct(e.kernelInitializer||this.DEFAULT_KERNEL_INITIALIZER),this.recurrentInitializer=Ct(e.recurrentInitializer||this.DEFAULT_RECURRENT_INITIALIZER),this.biasInitializer=Ct(e.biasInitializer||this.DEFAULT_BIAS_INITIALIZER),this.kernelRegularizer=Tt(e.kernelRegularizer),this.recurrentRegularizer=Tt(e.recurrentRegularizer),this.biasRegularizer=Tt(e.biasRegularizer),this.kernelConstraint=Qt(e.kernelConstraint),this.recurrentConstraint=Qt(e.recurrentConstraint),this.biasConstraint=Qt(e.biasConstraint),this.dropout=su([1,fa([0,e.dropout==null?0:e.dropout])]),this.recurrentDropout=su([1,fa([0,e.recurrentDropout==null?0:e.recurrentDropout])]),this.implementation=e.implementation,this.stateSize=this.units,this.dropoutMask=null,this.recurrentDropoutMask=null}build(e){e=ut(e);let t=e[e.length-1];this.kernel=this.addWeight("kernel",[t,this.units*3],null,this.kernelInitializer,this.kernelRegularizer,!0,this.kernelConstraint),this.recurrentKernel=this.addWeight("recurrent_kernel",[this.units,this.units*3],null,this.recurrentInitializer,this.recurrentRegularizer,!0,this.recurrentConstraint),this.useBias?this.bias=this.addWeight("bias",[this.units*3],null,this.biasInitializer,this.biasRegularizer,!0,this.biasConstraint):this.bias=null,this.built=!0}call(e,t){return H(()=>{if(e=e,e.length!==2)throw new G(`GRUCell expects 2 input Tensors (inputs, h, c), got ${e.length}.`);let n=t.training==null?!1:t.training,s=e[1];e=e[0],0<this.dropout&&this.dropout<1&&this.dropoutMask==null&&(this.dropoutMask=ya({ones:()=>as(e),rate:this.dropout,training:n,count:3})),0<this.recurrentDropout&&this.recurrentDropout<1&&this.recurrentDropoutMask==null&&(this.recurrentDropoutMask=ya({ones:()=>as(s),rate:this.recurrentDropout,training:n,count:3}));let r=this.dropoutMask,a=this.recurrentDropoutMask,o,i,l;0<this.dropout&&this.dropout<1&&(e=z(e,r[0]));let u=cr(e,this.kernel.read());this.useBias&&(u=qs(u,this.bias.read())),0<this.recurrentDropout&&this.recurrentDropout<1&&(s=z(s,a[0]));let c=this.recurrentKernel.read(),[d,p]=Vt(c,[2*this.units,this.units],c.rank-1),h=cr(s,d),[f,m,g]=Vt(u,3,u.rank-1),[A,y]=Vt(h,2,h.rank-1);o=this.recurrentActivation.apply(oe(f,A)),i=this.recurrentActivation.apply(oe(m,y));let x=cr(z(i,s),p);l=this.activation.apply(oe(g,x));let b=oe(z(o,s),z(oe(1,St(o)),l));return[b,b]})}getConfig(){let e=super.getConfig(),t={units:this.units,activation:ga(this.activation),recurrentActivation:ga(this.recurrentActivation),useBias:this.useBias,kernelInitializer:_t(this.kernelInitializer),recurrentInitializer:_t(this.recurrentInitializer),biasInitializer:_t(this.biasInitializer),kernelRegularizer:mt(this.kernelRegularizer),recurrentRegularizer:mt(this.recurrentRegularizer),biasRegularizer:mt(this.biasRegularizer),activityRegularizer:mt(this.activityRegularizer),kernelConstraint:Jt(this.kernelConstraint),recurrentConstraint:Jt(this.recurrentConstraint),biasConstraint:Jt(this.biasConstraint),dropout:this.dropout,recurrentDropout:this.recurrentDropout,implementation:this.implementation,resetAfter:!1};return Object.assign({},e,t)}};kf.className="GRUCell";le.registerClass(kf);var M1=class extends hr{constructor(e){e.implementation===0&&console.warn("`implementation=0` has been deprecated, and now defaults to `implementation=1`. Please update your layer call."),e.cell=new kf(e);super(e)}call(e,t){return H(()=>{this.cell.dropoutMask!=null&&(Z(this.cell.dropoutMask),this.cell.dropoutMask=null),this.cell.recurrentDropoutMask!=null&&(Z(this.cell.recurrentDropoutMask),this.cell.recurrentDropoutMask=null);let n=t==null?null:t.mask,s=t==null?null:t.training,r=t==null?null:t.initialState;return super.call(e,{mask:n,training:s,initialState:r})})}static fromConfig(e,t){return t.implmentation===0&&(t.implementation=1),new e(t)}};M1.className="GRU";le.registerClass(M1);var nd=class extends td{constructor(e){super(e);this.DEFAULT_ACTIVATION="tanh",this.DEFAULT_RECURRENT_ACTIVATION="hardSigmoid",this.DEFAULT_KERNEL_INITIALIZER="glorotNormal",this.DEFAULT_RECURRENT_INITIALIZER="orthogonal",this.DEFAULT_BIAS_INITIALIZER="zeros",this.units=e.units,ln(this.units,"units"),this.activation=Aa(e.activation===void 0?this.DEFAULT_ACTIVATION:e.activation),this.recurrentActivation=Aa(e.recurrentActivation===void 0?this.DEFAULT_RECURRENT_ACTIVATION:e.recurrentActivation),this.useBias=e.useBias==null?!0:e.useBias,this.kernelInitializer=Ct(e.kernelInitializer||this.DEFAULT_KERNEL_INITIALIZER),this.recurrentInitializer=Ct(e.recurrentInitializer||this.DEFAULT_RECURRENT_INITIALIZER),this.biasInitializer=Ct(e.biasInitializer||this.DEFAULT_BIAS_INITIALIZER),this.unitForgetBias=e.unitForgetBias,this.kernelRegularizer=Tt(e.kernelRegularizer),this.recurrentRegularizer=Tt(e.recurrentRegularizer),this.biasRegularizer=Tt(e.biasRegularizer),this.kernelConstraint=Qt(e.kernelConstraint),this.recurrentConstraint=Qt(e.recurrentConstraint),this.biasConstraint=Qt(e.biasConstraint),this.dropout=su([1,fa([0,e.dropout==null?0:e.dropout])]),this.recurrentDropout=su([1,fa([0,e.recurrentDropout==null?0:e.recurrentDropout])]),this.implementation=e.implementation,this.stateSize=[this.units,this.units],this.dropoutMask=null,this.recurrentDropoutMask=null}build(e){var t;e=ut(e);let n=e[e.length-1];this.kernel=this.addWeight("kernel",[n,this.units*4],null,this.kernelInitializer,this.kernelRegularizer,!0,this.kernelConstraint),this.recurrentKernel=this.addWeight("recurrent_kernel",[this.units,this.units*4],null,this.recurrentInitializer,this.recurrentRegularizer,!0,this.recurrentConstraint);let s;if(this.useBias){if(this.unitForgetBias){let r=this.biasInitializer,a=this.units;s=new(t=class extends Fs{apply(i,l){let u=r.apply([a]),c=new ef().apply([a]),d=r.apply([a*2]);return $3($3(u,c),d)}},t.className="CustomInit",t)}else s=this.biasInitializer;this.bias=this.addWeight("bias",[this.units*4],null,s,this.biasRegularizer,!0,this.biasConstraint)}else this.bias=null;this.built=!0}call(e,t){return H(()=>{let n=t.training==null?!1:t.training;if(e=e,e.length!==3)throw new G(`LSTMCell expects 3 input Tensors (inputs, h, c), got ${e.length}.`);let s=e[1],r=e[2];e=e[0],0<this.dropout&&this.dropout<1&&this.dropoutMask==null&&(this.dropoutMask=ya({ones:()=>as(e),rate:this.dropout,training:n,count:4})),0<this.recurrentDropout&&this.recurrentDropout<1&&this.recurrentDropoutMask==null&&(this.recurrentDropoutMask=ya({ones:()=>as(s),rate:this.recurrentDropout,training:n,count:4}));let a=this.dropoutMask,o=this.recurrentDropoutMask,i,l,u,c;0<this.dropout&&this.dropout<1&&(e=z(e,a[0]));let d=cr(e,this.kernel.read());0<this.recurrentDropout&&this.recurrentDropout<1&&(s=z(s,o[0])),d=oe(d,cr(s,this.recurrentKernel.read())),this.useBias&&(d=qs(d,this.bias.read()));let[p,h,f,m]=Vt(d,4,d.rank-1);i=this.recurrentActivation.apply(p),l=this.recurrentActivation.apply(h),u=oe(z(l,r),z(i,this.activation.apply(f))),c=this.recurrentActivation.apply(m);let g=z(c,this.activation.apply(u));return[g,g,u]})}getConfig(){let e=super.getConfig(),t={units:this.units,activation:ga(this.activation),recurrentActivation:ga(this.recurrentActivation),useBias:this.useBias,kernelInitializer:_t(this.kernelInitializer),recurrentInitializer:_t(this.recurrentInitializer),biasInitializer:_t(this.biasInitializer),unitForgetBias:this.unitForgetBias,kernelRegularizer:mt(this.kernelRegularizer),recurrentRegularizer:mt(this.recurrentRegularizer),biasRegularizer:mt(this.biasRegularizer),activityRegularizer:mt(this.activityRegularizer),kernelConstraint:Jt(this.kernelConstraint),recurrentConstraint:Jt(this.recurrentConstraint),biasConstraint:Jt(this.biasConstraint),dropout:this.dropout,recurrentDropout:this.recurrentDropout,implementation:this.implementation};return Object.assign({},e,t)}};nd.className="LSTMCell";le.registerClass(nd);var z1=class extends hr{constructor(e){e.implementation===0&&console.warn("`implementation=0` has been deprecated, and now defaults to `implementation=1`. Please update your layer call."),e.cell=new nd(e);super(e)}call(e,t){return H(()=>{this.cell.dropoutMask!=null&&(Z(this.cell.dropoutMask),this.cell.dropoutMask=null),this.cell.recurrentDropoutMask!=null&&(Z(this.cell.recurrentDropoutMask),this.cell.recurrentDropoutMask=null);let n=t==null?null:t.mask,s=t==null?null:t.training,r=t==null?null:t.initialState;return super.call(e,{mask:n,training:s,initialState:r})})}static fromConfig(e,t){return t.implmentation===0&&(t.implementation=1),new e(t)}};z1.className="LSTM";le.registerClass(z1);var If=class extends td{constructor(e){super(e);this.cells=e.cells}get stateSize(){let e=[];for(let t of this.cells.slice().reverse())Array.isArray(t.stateSize)?e.push(...t.stateSize):e.push(t.stateSize);return e}call(e,t){return H(()=>{e=e;let n=e.slice(1),s=[];for(let o of this.cells.slice().reverse())Array.isArray(o.stateSize)?s.push(n.splice(0,o.stateSize.length)):s.push(n.splice(0,1));s.reverse();let r=[],a;for(let o=0;o<this.cells.length;++o){let i=this.cells[o];n=s[o],o===0?a=[e[0]].concat(n):a=[a[0]].concat(n),a=i.call(a,t),r.push(a.slice(1))}n=[];for(let o of r.slice().reverse())n.push(...o);return[a[0]].concat(n)})}build(e){s1(e)&&(e=e[0]),e=e;let t;this.cells.forEach((n,s)=>{Qo(`RNNCell_${s}`,()=>{n.build(e),Array.isArray(n.stateSize)?t=n.stateSize[0]:t=n.stateSize,e=[e[0],t]})}),this.built=!0}getConfig(){let e=super.getConfig(),t=r=>({className:r.getClassName(),config:r.getConfig()}),s={cells:this.cells.map(t)};return Object.assign({},e,s)}static fromConfig(e,t,n={}){let s=[];for(let r of t.cells)s.push(Ks(r,n));return new e({cells:s})}get trainableWeights(){if(!this.trainable)return[];let e=[];for(let t of this.cells)e.push(...t.trainableWeights);return e}get nonTrainableWeights(){let e=[];for(let t of this.cells)e.push(...t.nonTrainableWeights);if(!this.trainable){let t=[];for(let n of this.cells)t.push(...n.trainableWeights);return t.concat(e)}return e}getWeights(){let e=[];for(let t of this.cells)e.push(...t.weights);return r1(e)}setWeights(e){let t=[];for(let n of this.cells){let s=n.weights.length,r=e.splice(s);for(let a=0;a<n.weights.length;++a)t.push([n.weights[a],r[a]])}a1(t)}};If.className="StackedRNNCells";le.registerClass(If);function ya(e){let{ones:t,rate:n,training:s=!1,count:r=1}=e,a=()=>O3(t(),n),o=()=>jc(a,t,s);return!r||r<=1?on(o().clone()):Array(r).fill(void 0).map(o).map(l=>on(l.clone()))}var wM=function(e,t){var n={};for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&t.indexOf(s)<0&&(n[s]=e[s]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,s=Object.getOwnPropertySymbols(e);r<s.length;r++)t.indexOf(s[r])<0&&Object.prototype.propertyIsEnumerable.call(e,s[r])&&(n[s[r]]=e[s[r]]);return n},Lv=class extends hr{constructor(e){if(e.unroll)throw new ze("Unrolling is not possible with convolutional RNNs.");if(Array.isArray(e.cell))throw new ze("It is not possible at the moment to stack convolutional cells.");super(e);this.inputSpec=[new Ht({ndim:5})]}call(e,t){return H(()=>{if(this.cell.dropoutMask!=null&&(Z(this.cell.dropoutMask),this.cell.dropoutMask=null),this.cell.recurrentDropoutMask!=null&&(Z(this.cell.recurrentDropoutMask),this.cell.recurrentDropoutMask=null),t&&t.constants)throw new G("ConvRNN2D cell does not support constants");let n=t==null?null:t.mask,s=t==null?null:t.training,r=t==null?null:t.initialState;return super.call(e,{mask:n,training:s,initialState:r})})}computeOutputShape(e){let t=this.computeSingleOutputShape(e);return this.returnSequences||(t=[t[0],...t.slice(2)]),this.returnState&&(t=[t,...Array(2).fill([e[0],...t.slice(-3)])]),t}getInitialState(e){return H(()=>{let{stateSize:t}=this.cell,n=e.shape,s=this.computeSingleOutputShape(n),r=[s[0],...s.slice(2)],a=Mt(r);return Array.isArray(t)?Array(t.length).fill(a):[a]})}resetStates(e,t=!1){H(()=>{if(!this.stateful)throw new _r("Cannot call resetStates() on an RNN Layer that is not stateful.");let n=this.inputSpec[0].shape,s=this.computeSingleOutputShape(n),r=[s[0],...s.slice(2)];if(n[0]==null)throw new G("If an RNN is stateful, it needs to know its batch size. Specify the batch size of your input tensors: \n- If using a Sequential model, specify the batch size by passing a `batchInputShape` option to your first layer.\n- If using the functional API, specify the batch size by passing a `batchShape` option to your Input layer.");if(this.getStates()==null)Array.isArray(this.cell.stateSize)?this.states_=this.cell.stateSize.map(()=>Mt(r)):this.states_=[Mt(r)];else if(e==null)Z(this.states_),this.keptStates!=null&&(Z(this.keptStates),this.keptStates=[]),Array.isArray(this.cell.stateSize)?this.states_=this.cell.stateSize.map(()=>Mt(r)):this.states_[0]=Mt(r);else{if(Array.isArray(e)||(e=[e]),e.length!==this.states_.length)throw new G(`Layer ${this.name} expects ${this.states_.length} state(s), but it received ${e.length} state value(s). Input received: ${e}`);t?this.keptStates.push(this.states_.slice()):Z(this.states_);for(let o=0;o<this.states_.length;++o){let i=e[o],l=r;if(!w.arraysEqual(i.shape,l))throw new G(`State ${o} is incompatible with layer ${this.name}: expected shape=${l}, received shape=${i.shape}`);this.states_[o]=i}}this.states_=this.states_.map(o=>on(o.clone()))})}computeSingleOutputShape(e){let{dataFormat:t,filters:n,kernelSize:s,padding:r,strides:a,dilationRate:o}=this.cell,i=t==="channelsFirst",l=e[i?3:2],u=e[i?4:3],c=Zs(l,s[0],r,a[0],o[0]),d=Zs(u,s[1],r,a[1],o[1]);return[...e.slice(0,2),...i?[n,c,d]:[c,d,n]]}};Lv.className="ConvRNN2D";var Sf=class extends nd{constructor(e){let{filters:t,kernelSize:n,strides:s,padding:r,dataFormat:a,dilationRate:o}=e;super(Object.assign({},e,{units:t}));this.filters=t,ln(this.filters,"filters"),this.kernelSize=lu(n,2,"kernelSize"),this.kernelSize.forEach(i=>ln(i,"kernelSize")),this.strides=lu(s||1,2,"strides"),this.strides.forEach(i=>ln(i,"strides")),this.padding=r||"valid",vs(this.padding),this.dataFormat=a||"channelsLast",Bt(this.dataFormat),this.dilationRate=lu(o||1,2,"dilationRate"),this.dilationRate.forEach(i=>ln(i,"dilationRate"))}build(e){var t;e=ut(e);let n=this.dataFormat==="channelsFirst"?1:e.length-1;if(e[n]==null)throw new G(`The channel dimension of the input should be defined. Found ${e[n]}`);let s=e[n],r=4,a=this.kernelSize.concat([s,this.filters*r]);this.kernel=this.addWeight("kernel",a,null,this.kernelInitializer,this.kernelRegularizer,!0,this.kernelConstraint);let o=this.kernelSize.concat([this.filters,this.filters*r]);if(this.recurrentKernel=this.addWeight("recurrent_kernel",o,null,this.recurrentInitializer,this.recurrentRegularizer,!0,this.recurrentConstraint),this.useBias){let i;if(this.unitForgetBias){let l=this.biasInitializer,u=this.filters;i=new(t=class extends Fs{apply(d,p){let h=l.apply([u]),f=rs([u]),m=l.apply([u*2]);return qA([h,f,m])}},t.className="CustomInit",t)}else i=this.biasInitializer;this.bias=this.addWeight("bias",[this.filters*r],null,i,this.biasRegularizer,!0,this.biasConstraint)}this.built=!0}call(e,t){return H(()=>{if(e.length!==3)throw new G(`ConvLSTM2DCell expects 3 input Tensors (inputs, h, c), got ${e.length}.`);let n=t.training||!1,s=e[0],r=e[1],a=e[2],o=4;0<this.dropout&&this.dropout<1&&this.dropoutMask==null&&(this.dropoutMask=ya({ones:()=>as(s),rate:this.dropout,training:n,count:o}));let i=this.dropoutMask,l=(te,ne,se)=>!ne||!ne[se]?te:z(ne[se],te),u=l(s,i,0),c=l(s,i,1),d=l(s,i,2),p=l(s,i,3);0<this.recurrentDropout&&this.recurrentDropout<1&&this.recurrentDropoutMask==null&&(this.recurrentDropoutMask=ya({ones:()=>as(r),rate:this.recurrentDropout,training:n,count:o}));let h=this.recurrentDropoutMask,f=l(r,h,0),m=l(r,h,1),g=l(r,h,2),A=l(r,h,3),y=3,[x,b,v,k]=Vt(this.kernel.read(),o,y),[S,C,D,O]=this.useBias?Vt(this.bias.read(),o):[null,null,null,null];u=this.inputConv(u,x,S,this.padding),c=this.inputConv(c,b,C,this.padding),d=this.inputConv(d,v,D,this.padding),p=this.inputConv(p,k,O,this.padding);let[E,R,T,P]=Vt(this.recurrentKernel.read(),o,y);f=this.recurrentConv(f,E),m=this.recurrentConv(m,R),g=this.recurrentConv(g,T),A=this.recurrentConv(A,P);let U=this.recurrentActivation.apply(oe(u,f)),j=this.recurrentActivation.apply(oe(c,m)),q=oe(z(j,a),z(U,this.activation.apply(oe(d,g)))),X=z(this.recurrentActivation.apply(oe(p,A)),this.activation.apply(q));return[X,X,q]})}getConfig(){let e=super.getConfig(),{units:t}=e,n=wM(e,["units"]),s={filters:this.filters,kernelSize:this.kernelSize,padding:this.padding,dataFormat:this.dataFormat,dilationRate:this.dilationRate,strides:this.strides};return Object.assign({},n,s)}inputConv(e,t,n,s){let r=Tr(e,t,this.strides,s||"valid",this.dataFormat==="channelsFirst"?"NCHW":"NHWC",this.dilationRate);return n?qs(r,n,this.dataFormat):r}recurrentConv(e,t){return Tr(e,t,1,"same",this.dataFormat==="channelsFirst"?"NCHW":"NHWC")}};Sf.className="ConvLSTM2DCell";le.registerClass(Sf);var L1=class extends Lv{constructor(e){let t=new Sf(e);super(Object.assign({},e,{cell:t}))}static fromConfig(e,t){return new e(t)}};L1.className="ConvLSTM2D";le.registerClass(L1);var Cf=class extends et{constructor(e){super(e);this.rate=Math.max(Math.min(e.rate,1),0),this.noiseShape=e.noiseShape,this.seed=e.seed,this.supportsMasking=!0}getNoiseShape(e){if(this.noiseShape==null)return this.noiseShape;let t=e.shape,n=[];for(let s=0;s<this.noiseShape.length;++s)n.push(this.noiseShape[s]==null?t[s]:this.noiseShape[s]);return n}call(e,t){return H(()=>{this.invokeCallHook(e,t);let n=We(e);if(0<this.rate&&this.rate<1){let s=t.training==null?!1:t.training,r=this.getNoiseShape(n);return jc(()=>O3(n,this.rate,r,this.seed),()=>n,s)}return e})}getConfig(){let e={rate:this.rate,noiseShape:this.noiseShape,seed:this.seed},t=super.getConfig();return Object.assign(e,t),e}dispose(){return super.dispose()}};Cf.className="Dropout";le.registerClass(Cf);var B1=class extends Cf{constructor(e){super(e);this.inputSpec=[{ndim:3}]}getNoiseShape(e){let t=e.shape;return[t[0],1,t[2]]}};B1.className="SpatialDropout1D";le.registerClass(B1);var W1=class extends et{constructor(e){super(e);if(this.activation=null,this.useBias=!0,this.kernel=null,this.bias=null,this.DEFAULT_KERNEL_INITIALIZER="glorotNormal",this.DEFAULT_BIAS_INITIALIZER="zeros",e.batchInputShape==null&&e.inputShape==null&&e.inputDim!=null){let t=null;e.batchSize!=null&&(t=e.batchSize),this.batchInputShape=[t,e.inputDim]}this.units=e.units,ln(this.units,"units"),this.activation=Aa(e.activation),e.useBias!=null&&(this.useBias=e.useBias),this.kernelInitializer=Ct(e.kernelInitializer||this.DEFAULT_KERNEL_INITIALIZER),this.biasInitializer=Ct(e.biasInitializer||this.DEFAULT_BIAS_INITIALIZER),this.kernelConstraint=Qt(e.kernelConstraint),this.biasConstraint=Qt(e.biasConstraint),this.kernelRegularizer=Tt(e.kernelRegularizer),this.biasRegularizer=Tt(e.biasRegularizer),this.activityRegularizer=Tt(e.activityRegularizer),this.supportsMasking=!0,this.inputSpec=[{minNDim:2}]}build(e){e=ut(e);let t=e[e.length-1];this.kernel==null&&(this.kernel=this.addWeight("kernel",[t,this.units],null,this.kernelInitializer,this.kernelRegularizer,!0,this.kernelConstraint),this.useBias&&(this.bias=this.addWeight("bias",[this.units],null,this.biasInitializer,this.biasRegularizer,!0,this.biasConstraint))),this.inputSpec=[{minNDim:2,axes:{[-1]:t}}],this.built=!0}computeOutputShape(e){e=ut(e);let t=e.slice();return t[t.length-1]=this.units,t}call(e,t){return H(()=>{this.invokeCallHook(e,t);let n=We(e),s=I3(this.activation.getClassName()),r;return s!=null?r=cr(n,this.kernel.read(),s,this.bias?this.bias.read():null):(r=cr(n,this.kernel.read()),this.bias!=null&&(r=qs(r,this.bias.read())),this.activation!=null&&(r=this.activation.apply(r))),r})}getConfig(){let e={units:this.units,activation:ga(this.activation),useBias:this.useBias,kernelInitializer:_t(this.kernelInitializer),biasInitializer:_t(this.biasInitializer),kernelRegularizer:mt(this.kernelRegularizer),biasRegularizer:mt(this.biasRegularizer),activityRegularizer:mt(this.activityRegularizer),kernelConstraint:Jt(this.kernelConstraint),biasConstraint:Jt(this.biasConstraint)},t=super.getConfig();return Object.assign(e,t),e}};W1.className="Dense";le.registerClass(W1);var V1=class extends et{constructor(e){e=e||{};super(e);this.inputSpec=[{minNDim:3}],this.dataFormat=e.dataFormat}computeOutputShape(e){e=ut(e);for(let t of e.slice(1))if(t==null)throw new G(`The shape of the input to "Flatten" is not fully defined (got ${e.slice(1)}). Make sure to pass a complete "input_shape" or "batch_input_shape" argument to the first layer in your model.`);return[e[0],ha(e,1)]}call(e,t){return H(()=>{this.invokeCallHook(e,t);let n=We(e);if(this.dataFormat==="channelsFirst"&&n.rank>1){let s=[0];for(let r=2;r<n.rank;++r)s.push(r);s.push(1),n=Ye(n,s)}return WO(n)})}getConfig(){let e={};this.dataFormat!=null&&(e.dataFormat=this.dataFormat);let t=super.getConfig();return Object.assign(e,t),e}};V1.className="Flatten";le.registerClass(V1);var U1=class extends et{constructor(e){super(e);this.supportsMasking=!0,this.activation=Aa(e.activation)}call(e,t){return H(()=>{this.invokeCallHook(e,t);let n=We(e);return this.activation.apply(n)})}getConfig(){let e={activation:ga(this.activation)},t=super.getConfig();return Object.assign(e,t),e}};U1.className="Activation";le.registerClass(U1);var H1=class extends et{constructor(e){super(e);this.n=e.n,this.inputSpec=[{ndim:2}]}computeOutputShape(e){return[e[0],this.n,e[1]]}call(e,t){return H(()=>(e=We(e),LO(e,this.n)))}getConfig(){let e={n:this.n},t=super.getConfig();return Object.assign(e,t),e}};H1.className="RepeatVector";le.registerClass(H1);var G1=class extends et{constructor(e){super(e);this.targetShape=e.targetShape;for(let t=0;t<this.targetShape.length;++t)this.isUnknown(this.targetShape[t])&&(this.targetShape[t]=null)}isUnknown(e){return e<0||e==null}fixUnknownDimension(e,t){let n="Total size of new array must be unchanged.",s=t.slice(),r=1,a=null;for(let i=0;i<s.length;++i){let l=s[i];if(this.isUnknown(l))if(a===null)a=i;else throw new G("Can only specifiy one unknown dimension.");else r*=l}let o=ha(e);if(a!==null){if(r===0||o%r!=0)throw new G(n);s[a]=o/r}else if(o!==r)throw new G(n);return s}computeOutputShape(e){let t=!1;for(let n=0;n<e.length;++n)if(this.isUnknown(e[n])){t=!0;break}return t?e.slice(0,1).concat(this.targetShape):e.slice(0,1).concat(this.fixUnknownDimension(e.slice(1),this.targetShape))}call(e,t){return H(()=>{this.invokeCallHook(e,t);let n=We(e),s=n.shape,r=s.slice(0,1).concat(this.fixUnknownDimension(s.slice(1),this.targetShape));return V(n,r)})}getConfig(){let e={targetShape:this.targetShape},t=super.getConfig();return Object.assign(e,t),e}};G1.className="Reshape";le.registerClass(G1);var j1=class extends et{constructor(e){super(e);if(e.dims==null)throw new Error("Required configuration field `dims` is missing during Permute constructor call.");if(!Array.isArray(e.dims))throw new Error(`Permute constructor requires \`dims\` to be an Array, but received ${e.dims} instead.`);let t=js(1,e.dims.length+1);if(!w.arraysEqual(e.dims.slice().sort(),t))throw new Error("Invalid permutation `dims`: "+JSON.stringify(e.dims)+" `dims` must contain consecutive integers starting from 1.");this.dims=e.dims,this.dimsIncludingBatch=[0].concat(this.dims),this.inputSpec=[new Ht({ndim:this.dims.length+1})]}computeOutputShape(e){e=ut(e);let t=e.slice();return this.dims.forEach((n,s)=>{t[s+1]=e[n]}),t}call(e,t){return Ye(We(e),this.dimsIncludingBatch)}getConfig(){let e={dims:this.dims},t=super.getConfig();return Object.assign(e,t),e}};j1.className="Permute";le.registerClass(j1);var q1=class extends et{constructor(e){super(e==null?{}:e);this.supportsMasking=!0,e!=null?this.maskValue=e.maskValue==null?0:e.maskValue:this.maskValue=0}computeOutputShape(e){return e}getConfig(){let e=super.getConfig(),t={maskValue:this.maskValue};return Object.assign(t,e),t}computeMask(e,t){let n=We(e),s=-1;return wc(qo(n,this.maskValue),s)}call(e,t){return H(()=>{this.invokeCallHook(e,t);let n=We(e),s=-1,r=!0,a=wc(qo(n,this.maskValue),s,r);return z(n,pe(a,n.dtype))})}};q1.className="Masking";le.registerClass(q1);var X1=class extends et{constructor(e){super(e);if(this.embeddings=null,this.DEFAULT_EMBEDDINGS_INITIALIZER="randomUniform",e.batchInputShape==null&&e.inputShape==null){let t=null;e.batchSize!=null&&(t=e.batchSize),e.inputLength==null?this.batchInputShape=[t,null]:this.batchInputShape=[t].concat(vt(e.inputLength))}this.inputDim=e.inputDim,ln(this.inputDim,"inputDim"),this.outputDim=e.outputDim,ln(this.outputDim,"outputDim"),this.embeddingsInitializer=Ct(e.embeddingsInitializer||this.DEFAULT_EMBEDDINGS_INITIALIZER),this.embeddingsRegularizer=Tt(e.embeddingsRegularizer),this.activityRegularizer=Tt(e.activityRegularizer),this.embeddingsConstraint=Qt(e.embeddingsConstraint),this.maskZero=e.maskZero,this.supportsMasking=e.maskZero,this.inputLength=e.inputLength}build(e){this.embeddings=this.addWeight("embeddings",[this.inputDim,this.outputDim],this.dtype,this.embeddingsInitializer,this.embeddingsRegularizer,!0,this.embeddingsConstraint),this.built=!0}warnOnIncompatibleInputShape(e){}computeMask(e,t){return H(()=>this.maskZero?(e=We(e),qo(e,Je(e))):null)}computeOutputShape(e){if(e=ut(e),this.inputLength==null)return[...e,this.outputDim];let t=vt(this.inputLength);if(t.length!==e.length-1)throw new G(`"inputLength" is ${this.inputLength}, but received input shape has shape ${e}`);{let n=0;for(let s=0;s<t.length;++s){let r=t[s],a=e[s+1];if(r!=null&&a!=null&&r!==a)throw new G(`"inputLength" is ${this.inputLength}, but received input shape has shape ${e}`);r==null&&(t[n]=a),n++}}return[e[0],...t,this.outputDim]}call(e,t){return H(()=>{this.invokeCallHook(e,t);let n=We(e);n.dtype!=="int32"&&(n=Yh(n,"int32"));let s=F3(this.embeddings.read(),V(n,[n.size]));return V(s,ut(this.computeOutputShape(n.shape)))})}getConfig(){let e={inputDim:this.inputDim,outputDim:this.outputDim,embeddingsInitializer:_t(this.embeddingsInitializer),embeddingsRegularizer:mt(this.embeddingsRegularizer),activityRegularizer:mt(this.activityRegularizer),embeddingsConstraint:Jt(this.embeddingsConstraint),maskZero:this.maskZero,inputLength:this.inputLength},t=super.getConfig();return Object.assign(e,t),e}};X1.className="Embedding";le.registerClass(X1);var ri=class extends et{constructor(e){super(e||{});this.supportsMasking=!0}mergeFunction(e){throw new ze}computeElementwiseOpOutputShape(e,t){if(e==null||t==null)return null;if(e.length<t.length)return this.computeElementwiseOpOutputShape(t,e);if(t.length===0)return e;let n=e.slice(0,e.length-t.length);for(let s=0;s<t.length;++s){let r=e[e.length-t.length+s],a=t[s];if(r==null||a==null||r<0||a<0)n.push(null);else if(r===1)n.push(a);else if(a===1)n.push(r);else{if(r!==a)throw new G("Operands could not be broadcast together with shapes "+JSON.stringify(e)+" "+JSON.stringify(t));n.push(r)}}return n}build(e){if(Array.isArray(e)&&!Array.isArray(e[0])&&(e=[ut(e)]),e=e,e.length<2)throw new G(`A merge layer should be called on an Array of at least 2 inputs. Got ${e.length} input(s).`);let t=[];for(let r of e)r!=null&&r[0]!==null&&t.push(r[0]);if(t=pa(t),t.length>1)throw new G(`Can not merge tensors with different batch sizes. Got tensors with shapes: ${JSON.stringify(e)}.`);let n=e[0]==null?null:e[0].slice(1);for(let r=1;r<e.length;++r){let a=e[r]==null?null:e[r].slice(1);n=this.computeElementwiseOpOutputShape(n,a)}let s=e.map(r=>r.length);e.indexOf(null)===-1&&pa(s).length===1?this.reshapeRequired=!1:this.reshapeRequired=!0}call(e,t){return H(()=>{if(e=e,this.reshapeRequired){let n=[],s=e.map(r=>r.rank);if(s.indexOf(null)===-1){let r=fa(s);for(let a of e){let o=a.rank;for(let i=0;i<r-o;++i)a=Hc(a,1);n.push(a)}return this.mergeFunction(n)}else{let r=!1;for(let i of e){let l=i.rank;if(l==null){let u=i.shape,c=u[0],d=u.slice(1).concat([c]),p=V(i,[c].concat(ha(u.slice(1))));p=Ye(p,[1,0]),p=V(p,d),n.push(p),r=!0}else if(l>1){let u=js(1,l).concat([0]);n.push(Ye(i,u)),r=!0}else n.push(i)}let a=this.mergeFunction(n),o=a.rank;if(r){if(o==null){let i=a.shape,l=i.length,u=i[l-1],c=[u].concat(i.slice(0,i.length-1));a=V(Ye(V(a,[-1,u]),[1,0]),c)}else if(o>1){let i=[o-1].concat(js(0,o-1));a=Ye(a,i)}}return a}}else return this.mergeFunction(e)})}computeOutputShape(e){e=e;let t;e[0]==null?t=null:t=e[0].slice(1);for(let s=1;s<e.length;++s){let r=e[s]==null?null:e[s].slice(1);t=this.computeElementwiseOpOutputShape(t,r)}let n=[];for(let s of e)s!=null&&s[0]!==null&&n.push(s[0]);return n=pa(n),n.length===1?t=n.concat(t):t=[null].concat(t),t}computeMask(e,t){return H(()=>{if(t==null)return null;if(!Array.isArray(t))throw new G("`mask` should be an Array");if(!Array.isArray(e))throw new G("`inputs` should be an Array");if(t.length!==e.length)throw new G(`The Array 'inputs' and 'mask' are expected to have the same length, but have different lengths (${e.length} vs ${t.length})`);if(t.every(s=>s==null))return null;t=t.map(s=>s==null?s:Lt(s,0));let n=t[0];for(let s=1;s<t.length-1;++s)n=_s(n,t[s]);return n})}},K1=class extends ri{constructor(e){super(e)}mergeFunction(e){return H(()=>{let t=e[0].clone();for(let n=1;n<e.length;++n)t=oe(t,e[n]);return t})}};K1.className="Add";le.registerClass(K1);var Z1=class extends ri{constructor(e){super(e)}mergeFunction(e){return H(()=>{let t=e[0].clone();for(let n=1;n<e.length;++n)t=z(t,e[n]);return t})}};Z1.className="Multiply";le.registerClass(Z1);var Y1=class extends ri{constructor(e){super(e)}mergeFunction(e){return H(()=>{let t=e[0].clone();for(let n=1;n<e.length;++n)t=oe(t,e[n]);return z(1/e.length,t)})}};Y1.className="Average";le.registerClass(Y1);var J1=class extends ri{constructor(e){super(e)}mergeFunction(e){return H(()=>{let t=e[0];for(let n=1;n<e.length;++n)t=ir(t,e[n]);return t})}};J1.className="Maximum";le.registerClass(J1);var Q1=class extends ri{constructor(e){super(e)}mergeFunction(e){return H(()=>{let t=e[0];for(let n=1;n<e.length;++n)t=Zl(t,e[n]);return t})}};Q1.className="Minimum";le.registerClass(Q1);var e2=class extends ri{constructor(e){super(e);this.DEFAULT_AXIS=-1,e==null&&(e={}),this.axis=e.axis==null?this.DEFAULT_AXIS:e.axis,this.supportsMasking=!0,this.reshapeRequired=!1}build(e){if(!(Array.isArray(e)&&Array.isArray(e[0]))||e.length===1)throw new G("A `Concatenate` layer should be called on a list of at least 2 inputs");e=e;let t=!0;for(let s of e)if(s!=null){t=!1;break}if(t)return;let n=[];for(let s=0;s<e.length;++s){let r=e[s].slice();r.splice(this.axis,1);let a=!1;for(let o of n)if(w.arraysEqual(o,r)){a=!0;break}a||n.push(r)}if(n.length>1)throw new G("A `Concatenate` layer requires inputs with matching shapes except for the concat axis. Got input shapes: "+JSON.stringify(e))}mergeFunction(e){return H(()=>qA(e,this.axis))}computeOutputShape(e){if(!(Array.isArray(e)&&Array.isArray(e[0])))throw new G("A `Concatenate` layer should be called on a list of inputs.");let t=e,n=t[0].slice(),s=this.axis<0?n.length+this.axis:this.axis;for(let r of t.slice(1)){if(n[s]==null||r[s]==null){n[s]=null;break}n[s]+=r[s]}return n}computeMask(e,t){if(t==null)return null;if(!Array.isArray(t))throw new G("`mask` should be an array for Concatenate");if(!Array.isArray(e))throw new G("`inputs` should be an array for Concatenate");if(t.length!==e.length)throw new G(`Mismatch in the length of mask (${t.length}) and the legnth of inputs (${e.length})`);return H(()=>{let n=!0;if(t.forEach(a=>{if(a!=null){n=!1;return}}),n)return null;let s=[];for(let a=0;a<e.length;++a)t[a]==null?s.push(pe(as(e[a]),"bool")):t[a].rank<e[a].rank?s.push(Lt(t[a],-1)):s.push(t[a]);let r=ft(s,this.axis);return ph(r,-1,!1)})}getConfig(){let e={axis:this.axis},t=super.getConfig();return Object.assign(e,t),e}};e2.className="Concatenate";le.registerClass(e2);function sd(e,t){for(;e<0;)e+=t;return e}function kM(e,t,n){if(e.shape.length>3||t.shape.length>3)throw new ze("batchDot is not implemented for tensors of 4D or higher rank yet");if(w.assert(e.shape.length>=2,()=>`batchDot requires the rank of x to be >= 2, but got ${e.shape.length}`),w.assert(e.shape.length>=2,()=>`batchDot requires the rank of y to be >= 2, but got ${t.shape.length}`),typeof n=="number"&&(n=[n,n]),e.dtype==="complex64"||t.dtype==="complex64")throw new ze("batchDot is not implemented for complex64-type Tensors yet.");let s=e.shape.length,r=t.shape.length;n==null&&(n=[s-1,r-2]);let a=n;return H(()=>{let o;if(s>r){o=s-r;let l=[];for(let u=0;u<o;++u)l.push(1);t=V(t,t.shape.concat(l))}else if(r>s){o=r-s;let l=[];for(let u=0;u<o;++u)l.push(1);e=V(e,e.shape.concat(l))}else o=0;let i;if(e.shape.length===2&&t.shape.length===2)a[0]===a[1]?i=we(z(e,t),a[0]):i=we(z(Ye(e,[1,0]),t),a[1]);else{let l=a[0]!==e.shape.length-1,u=a[1]===t.shape.length-1;i=Ue(e,t,l,u)}if(o>0){let l;s>r?l=s+r-3:l=s-1;let u=[];for(let c=l;c<l+o;++c)u.push(c);i=lt(i,u)}return i.shape.length===1&&(i=Lt(i,1)),i})}var t2=class extends ri{constructor(e){super(e);this.axes=e.axes,this.normalize=e.normalize==null?!1:e.normalize,this.supportsMasking=!0,this.reshapeRequired=!1}build(e){w.assert(Array.isArray(e)&&e.length===2&&Array.isArray(e[0])&&Array.isArray(e[1]),()=>"A `Dot` layer should be called on a list of exactly 2 inputs.");let t=e[0],n=e[1];if(t.length>3||n.length>3)throw new ze("Dot layer does not support tensors of 4D or higher rank yet.");let s=this.interpretAxes(t,n);if(t[s[0]]!==n[s[1]])throw new G(`Dimension incompatibility: ${t[s[0]]} !== ${n[s[1]]}`)}mergeFunction(e){if(e.length!==2)throw new G(`A \`Dot\` layer must be called on exactly 2 inputs, but received ${e.length} input(s).`);let t=e[0],n=e[1],s;return Array.isArray(this.axes)?s=this.axes.map((r,a)=>sd(r,e[a].shape.length)):s=[sd(this.axes,t.shape.length),sd(this.axes,n.shape.length)],this.normalize&&(t=hf(t,s[0]),n=hf(n,s[1])),kM(t,n,s)}interpretAxes(e,t){let n;return Array.isArray(this.axes)?n=this.axes:n=[sd(this.axes,e.length),sd(this.axes,t.length)],n}computeOutputShape(e){w.assert(Array.isArray(e)&&e.length===2&&Array.isArray(e[0])&&Array.isArray(e[1]),()=>"A `Dot` layer should be called on a list of exactly 2 inputs.");let t=e[0].slice(),n=e[1].slice();if(t.length>3||n.length>3)throw new ze("Dot layer does not support tensors of 4D or higher rank yet.");let s=this.interpretAxes(t,n);t.splice(s[0],1),n.splice(s[1],1),n.splice(0,1);let r=t.concat(n);return r.length===1&&r.push(1),r}computeMask(e,t){return null}getConfig(){let e={axes:this.axes,normalize:this.normalize},t=super.getConfig();return Object.assign(e,t),e}};t2.className="Dot";le.registerClass(t2);var n2=class extends et{constructor(e){super(e);this.supportsMasking=!0,this.stddev=e.stddev}computeOutputShape(e){return e}getConfig(){let e=super.getConfig(),t={stddev:this.stddev};return Object.assign(t,e),t}call(e,t){return H(()=>{this.invokeCallHook(e,t);let n=We(e);return jc(()=>oe(Qh(n.shape,0,this.stddev),n),()=>n,t.training||!1)})}};n2.className="GaussianNoise";le.registerClass(n2);var s2=class extends et{constructor(e){super(e);this.supportsMasking=!0,this.rate=e.rate}computeOutputShape(e){return e}getConfig(){let e=super.getConfig(),t={rate:this.rate};return Object.assign(t,e),t}call(e,t){return H(()=>{this.invokeCallHook(e,t);let n=We(e);return this.rate>0&&this.rate<1?jc(()=>{let r=Math.sqrt(this.rate/(1-this.rate));return z(n,Qh(n.shape,1,r))},()=>n,t.training||!1):n})}};s2.className="GaussianDropout";le.registerClass(s2);var r2=class extends et{constructor(e){super(e);this.supportsMasking=!0,this.rate=e.rate,this.noiseShape=e.noiseShape}_getNoiseShape(e){return this.noiseShape||We(e).shape}computeOutputShape(e){return e}getConfig(){let e=super.getConfig(),t={rate:this.rate};return Object.assign(t,e),t}call(e,t){return H(()=>{if(this.rate<1&&this.rate>0){let n=this._getNoiseShape(e);return jc(()=>{let r=We(e),a=1.6732632423543772,o=1.0507009873554805,i=-a*o,l=ua(Yl(n),this.rate);l=Yh(l,"float32");let u=((1-this.rate)*(1+this.rate*i**2))**-.5,c=-u*i*this.rate,d=oe(z(r,l),z(oe(l,-1),i));return oe(z(d,u),c)},()=>We(e),t.training||!1)}return e})}};r2.className="AlphaDropout";le.registerClass(r2);function rd(e,t,n,s,r,a=.001){let o;if(e.rank===2)o=gb(e,t,n,s,r,a);else if(e.rank===3)o=Ab(e,t,n,s,r,a);else if(e.rank===4)o=yb(e,t,n,s,r,a);else throw new ze(`batchNormalization is not implemented for array of rank ${e.rank} yet`);return o}function IM(e,t,n,s,r=.001){return H(()=>{let a=kh(e,s),o=a.mean,i=a.variance;return[rd(e,o,i,n,t,r),o,i]})}function SM(e,t,n,s,r=.001){return H(()=>{let a=kh(e,s),o=a.mean,i=a.variance,l=[];for(let f of js(0,e.rank))s.indexOf(f)!==-1?l.push(1):l.push(e.shape[f]);let u=V(o,l),c=V(i,l),d=t==null?null:V(t,l),p=n==null?null:V(n,l);return[rd(e,u,c,p,d,r),o,i]})}function CM(e,t,n,s,r=.001){return w.arraysEqual(s.slice().sort(),js(0,e.rank-1))?IM(e,t,n,s,r):SM(e,t,n,s,r)}var a2=class extends et{constructor(e){e==null&&(e={});super(e);this.supportsMasking=!0,this.axis=e.axis==null?-1:e.axis,this.momentum=e.momentum==null?.99:e.momentum,this.epsilon=e.epsilon==null?.001:e.epsilon,this.center=e.center==null?!0:e.center,this.scale=e.scale==null?!0:e.scale,this.betaInitializer=Ct(e.betaInitializer||"zeros"),this.gammaInitializer=Ct(e.gammaInitializer||"ones"),this.movingMeanInitializer=Ct(e.movingMeanInitializer||"zeros"),this.movingVarianceInitializer=Ct(e.movingVarianceInitializer||"ones"),this.betaConstraint=Qt(e.betaConstraint),this.gammaConstraint=Qt(e.gammaConstraint),this.betaRegularizer=Tt(e.betaRegularizer),this.gammaRegularizer=Tt(e.gammaRegularizer)}build(e){e=ut(e);let t=this.axis>=0?this.axis:this.axis+e.length,n=e[t];if(n==null)throw new G(`Axis ${t} of input tensor should have a defined dimension but the layer received an input with shape ${JSON.stringify(e)}.`);this.inputSpec=[new Ht({ndim:e.length,axes:{[t]:n}})];let s=[n];this.scale&&(this.gamma=this.addWeight("gamma",s,null,this.gammaInitializer,this.gammaRegularizer,!0,this.gammaConstraint)),this.center&&(this.beta=this.addWeight("beta",s,null,this.betaInitializer,this.betaRegularizer,!0,this.betaConstraint)),this.movingMean=this.addWeight("moving_mean",s,null,this.movingMeanInitializer,null,!1),this.movingVariance=this.addWeight("moving_variance",s,null,this.movingVarianceInitializer,null,!1),this.built=!0}call(e,t){return H(()=>{let n=t.training==null?!1:t.training,s=We(e),r=s.shape,a=r.length,o=js(0,a),i=this.axis>=0?this.axis:this.axis+a;o.splice(i,1);let l=Zo(1,a);l[i]=r[i];let u=o.slice();u.sort();let c=!w.arraysEqual(u,js(0,a).slice(0,a-1)),d=()=>{if(c){let A=V(this.movingMean.read(),l),y=V(this.movingVariance.read(),l),x=this.center?V(this.beta.read(),l):null,b=this.scale?V(this.gamma.read(),l):null;return rd(s,A,y,x,b,this.epsilon)}else return rd(s,this.movingMean.read(),this.movingVariance.read(),this.beta==null?null:this.beta.read(),this.gamma==null?null:this.gamma.read(),this.epsilon)};if(!n)return d();let[p,h,f]=CM(s,this.gamma.read(),this.beta.read(),o,this.epsilon),m=(A,y,x)=>{H(()=>{let b=1-x,v=A.read(),k=z(ye(v,y),b);A.write(ye(v,k))})};return(()=>{m(this.movingMean,h,this.momentum),m(this.movingVariance,f,this.momentum)})(),p})}getConfig(){let e={axis:this.axis,momentum:this.momentum,epsilon:this.epsilon,center:this.center,scale:this.scale,betaInitializer:_t(this.betaInitializer),gammaInitializer:_t(this.gammaInitializer),movingMeanInitializer:_t(this.movingMeanInitializer),movingVarianceInitializer:_t(this.movingVarianceInitializer),betaRegularizer:mt(this.betaRegularizer),gammaRegularizer:mt(this.gammaRegularizer),betaConstraint:Jt(this.betaConstraint),gammaConstraint:Jt(this.gammaConstraint)},t=super.getConfig();return Object.assign(e,t),e}};a2.className="BatchNormalization";le.registerClass(a2);var o2=class extends et{constructor(e){e==null&&(e={});super(e);if(this.axis=e.axis==null?-1:e.axis,typeof this.axis=="number"){if(!Number.isInteger(this.axis))throw new Error(`Expected axis to be an integer, but received ${this.axis}`)}else if(Array.isArray(this.axis)){for(let t of this.axis)if(!Number.isInteger(t))throw new Error(`Expected axis to be an array of integers, but received ${JSON.stringify(this.axis)}`)}else throw new Error(`Expected axis to be an integer or an array of integers, but received ${JSON.stringify(this.axis)}`);this.epsilon=e.epsilon==null?.001:e.epsilon,this.center=e.center==null?!0:e.center,this.scale=e.scale==null?!0:e.scale,this.betaInitializer=Ct(e.betaInitializer||"zeros"),this.gammaInitializer=Ct(e.gammaInitializer||"ones"),this.betaRegularizer=Tt(e.betaRegularizer),this.gammaRegularizer=Tt(e.gammaRegularizer),this.supportsMasking=!0}build(e){e=ut(e);let t=e.length;typeof this.axis=="number"&&(this.axis=[this.axis]);for(let r=0;r<this.axis.length;++r)this.axis[r]<0&&(this.axis[r]+=t);for(let r of this.axis)if(r<0||r>=t)throw new Error(`Invalid axis: ${r}`);if(this.axis.length!==pa(this.axis).length)throw new Error(`Found duplicate axes in: ${this.axis}`);let n=this.axis.map(r=>e[r]),s=!0;this.scale?this.gamma=this.addWeight("gamma",n,"float32",this.gammaInitializer,this.gammaRegularizer,s):this.gamma=null,this.center?this.beta=this.addWeight("beta",n,"float32",this.betaInitializer,this.betaRegularizer,s):this.beta=null,this.built=!0}call(e,t){let n=We(e),s=n.shape,r=s.length;return H(()=>{let a=!0,{mean:o,variance:i}=kh(n,this.axis,a),l=Zo(1,r);for(let f of this.axis)l[f]=s[f];let u=f=>f!=null&&f.shape.length!==r&&this.axis!==[r-1]?V(f,l):f,c=u(this.gamma.read()),d=u(this.beta.read()),p=[],h=[];for(let f=0;f<r;++f)this.axis.indexOf(f)!==-1?(p.push(s[f]),h.push(1)):(p.push(1),h.push(s[f]));return o=bs(o,p),i=bs(i,p),c=bs(c,h),d=bs(d,h),rd(n,o,i,d,c,this.epsilon)})}getConfig(){let e={axis:this.axis,epsilon:this.epsilon,center:this.center,scale:this.scale,betaInitializer:_t(this.betaInitializer),gammaInitializer:_t(this.gammaInitializer),betaRegularizer:mt(this.betaRegularizer),gammaRegularizer:mt(this.gammaRegularizer)},t=super.getConfig();return Object.assign(e,t),e}};o2.className="LayerNormalization";le.registerClass(o2);function TM(e,t,n){return H(()=>{if(e.rank!==4)throw new G(`temporalPadding expects input tensor to be 4-D, but received a ${e.rank}-D tensor.`);if(t==null&&(t=[[1,1],[1,1]]),t.length!==2||t[0].length!==2||t[1].length!==2)throw new G("spatial2dPadding expects `padding` to be an Array of two Arrays, each of which is an Array of two integers.");if(n==null&&(n=Hs()),n!=="channelsLast"&&n!=="channelsFirst")throw new G(`Unknown data format: ${n}. Supported data formats are 'channelsLast' and 'channelsFirst.`);let s;return n==="channelsFirst"?s=[[0,0],[0,0],t[0],t[1]]:s=[[0,0],t[0],t[1],[0,0]],Nr(e,s)})}var i2=class extends et{constructor(e){e==null&&(e={});super(e);if(this.dataFormat=e.dataFormat==null?Hs():e.dataFormat,e.padding==null)this.padding=[[1,1],[1,1]];else if(typeof e.padding=="number")this.padding=[[e.padding,e.padding],[e.padding,e.padding]];else{if(e.padding=e.padding,e.padding.length!==2)throw new G(`ZeroPadding2D expects padding to be a length-2 array, but received a length-${e.padding.length} array.`);let t,n;if(typeof e.padding[0]=="number")t=[e.padding[0],e.padding[0]],n=[e.padding[1],e.padding[1]];else{if(e.padding=e.padding,e.padding[0].length!==2)throw new G(`ZeroPadding2D expects height padding to be a length-2 array, but received a length-${e.padding[0].length} array.`);if(t=e.padding[0],e.padding[1].length!==2)throw new G(`ZeroPadding2D expects width padding to be a length-2 array, but received a length-${e.padding[1].length} array.`);n=e.padding[1]}this.padding=[t,n]}this.inputSpec=[new Ht({ndim:4})]}computeOutputShape(e){e=ut(e);let t,n;return this.dataFormat==="channelsFirst"?(e[2]!=null&&e[2]>=0?t=e[2]+this.padding[0][0]+this.padding[0][1]:t=null,e[3]!=null&&e[3]>=0?n=e[3]+this.padding[1][0]+this.padding[1][1]:n=null,[e[0],e[1],t,n]):(e[1]!=null&&e[1]>=0?t=e[1]+this.padding[0][0]+this.padding[0][1]:t=null,e[2]!=null&&e[2]>=0?n=e[2]+this.padding[1][0]+this.padding[1][1]:n=null,[e[0],t,n,e[3]])}call(e,t){return H(()=>TM(We(e),this.padding,this.dataFormat))}getConfig(){let e={padding:this.padding,dataFormat:this.dataFormat},t=super.getConfig();return Object.assign(e,t),e}};i2.className="ZeroPadding2D";le.registerClass(i2);function Tf(e,t,n,s,r,a){return H(()=>{Bt(r),N3(a),vs(s),n==null&&(n=[1,1]),s==null&&(s="valid"),r==null&&(r=Hs()),a==null&&(a="max"),e=N1(e,r);let o,i=s==="same"?"same":"valid";return a==="max"?o=Rc(e,t,n,i):o=Ic(e,t,n,i),r==="channelsFirst"&&(o=Ye(o,[0,3,1,2])),o})}function Bv(e,t,n,s,r,a){return H(()=>{Bt(r),N3(a),vs(s),n==null&&(n=[1,1,1]),s==null&&(s="valid"),r==null&&(r=Hs()),a==null&&(a="max"),e=Fv(e,r);let o,i=s==="same"?"same":"valid";return a==="max"?o=AA(e,t,n,i):o=tA(e,t,n,i),r==="channelsFirst"&&(o=Ye(o,[0,4,1,2,3])),o})}var Wv=class extends et{constructor(e){e.poolSize==null&&(e.poolSize=2);super(e);if(typeof e.poolSize=="number")this.poolSize=[e.poolSize];else if(Array.isArray(e.poolSize)&&e.poolSize.length===1&&typeof e.poolSize[0]=="number")this.poolSize=e.poolSize;else throw new G(`poolSize for 1D convolutional layer must be a number or an Array of a single number, but received ${JSON.stringify(e.poolSize)}`);if(ln(this.poolSize,"poolSize"),e.strides==null)this.strides=this.poolSize;else if(typeof e.strides=="number")this.strides=[e.strides];else if(Array.isArray(e.strides)&&e.strides.length===1&&typeof e.strides[0]=="number")this.strides=e.strides;else throw new G(`strides for 1D convolutional layer must be a number or an Array of a single number, but received ${JSON.stringify(e.strides)}`);ln(this.strides,"strides"),this.padding=e.padding==null?"valid":e.padding,vs(this.padding),this.inputSpec=[new Ht({ndim:3})]}computeOutputShape(e){e=ut(e);let t=Zs(e[1],this.poolSize[0],this.padding,this.strides[0]);return[e[0],t,e[2]]}call(e,t){return H(()=>{this.invokeCallHook(e,t),e=Hc(We(e),2);let n=this.poolingFunction(We(e),[this.poolSize[0],1],[this.strides[0],1],this.padding,"channelsLast");return lt(n,[2])})}getConfig(){let e={poolSize:this.poolSize,padding:this.padding,strides:this.strides},t=super.getConfig();return Object.assign(e,t),e}},l2=class extends Wv{constructor(e){super(e)}poolingFunction(e,t,n,s,r){return Bt(r),vs(s),Tf(e,t,n,s,r,"max")}};l2.className="MaxPooling1D";le.registerClass(l2);var u2=class extends Wv{constructor(e){super(e)}poolingFunction(e,t,n,s,r){return Bt(r),vs(s),Tf(e,t,n,s,r,"avg")}};u2.className="AveragePooling1D";le.registerClass(u2);var Vv=class extends et{constructor(e){e.poolSize==null&&(e.poolSize=[2,2]);super(e);if(this.poolSize=Array.isArray(e.poolSize)?e.poolSize:[e.poolSize,e.poolSize],e.strides==null)this.strides=this.poolSize;else if(Array.isArray(e.strides)){if(e.strides.length!==2)throw new G(`If the strides property of a 2D pooling layer is an Array, it is expected to have a length of 2, but received length ${e.strides.length}.`);this.strides=e.strides}else this.strides=[e.strides,e.strides];ln(this.poolSize,"poolSize"),ln(this.strides,"strides"),this.padding=e.padding==null?"valid":e.padding,this.dataFormat=e.dataFormat==null?"channelsLast":e.dataFormat,Bt(this.dataFormat),vs(this.padding),this.inputSpec=[new Ht({ndim:4})]}computeOutputShape(e){e=ut(e);let t=this.dataFormat==="channelsFirst"?e[2]:e[1],n=this.dataFormat==="channelsFirst"?e[3]:e[2];return t=Zs(t,this.poolSize[0],this.padding,this.strides[0]),n=Zs(n,this.poolSize[1],this.padding,this.strides[1]),this.dataFormat==="channelsFirst"?[e[0],e[1],t,n]:[e[0],t,n,e[3]]}call(e,t){return H(()=>(this.invokeCallHook(e,t),this.poolingFunction(We(e),this.poolSize,this.strides,this.padding,this.dataFormat)))}getConfig(){let e={poolSize:this.poolSize,padding:this.padding,strides:this.strides,dataFormat:this.dataFormat},t=super.getConfig();return Object.assign(e,t),e}},c2=class extends Vv{constructor(e){super(e)}poolingFunction(e,t,n,s,r){return Bt(r),vs(s),Tf(e,t,n,s,r,"max")}};c2.className="MaxPooling2D";le.registerClass(c2);var d2=class extends Vv{constructor(e){super(e)}poolingFunction(e,t,n,s,r){return Bt(r),vs(s),Tf(e,t,n,s,r,"avg")}};d2.className="AveragePooling2D";le.registerClass(d2);var Uv=class extends et{constructor(e){e.poolSize==null&&(e.poolSize=[2,2,2]);super(e);if(this.poolSize=Array.isArray(e.poolSize)?e.poolSize:[e.poolSize,e.poolSize,e.poolSize],e.strides==null)this.strides=this.poolSize;else if(Array.isArray(e.strides)){if(e.strides.length!==3)throw new G(`If the strides property of a 3D pooling layer is an Array, it is expected to have a length of 3, but received length ${e.strides.length}.`);this.strides=e.strides}else this.strides=[e.strides,e.strides,e.strides];ln(this.poolSize,"poolSize"),ln(this.strides,"strides"),this.padding=e.padding==null?"valid":e.padding,this.dataFormat=e.dataFormat==null?"channelsLast":e.dataFormat,Bt(this.dataFormat),vs(this.padding),this.inputSpec=[new Ht({ndim:5})]}computeOutputShape(e){e=ut(e);let t=this.dataFormat==="channelsFirst"?e[2]:e[1],n=this.dataFormat==="channelsFirst"?e[3]:e[2],s=this.dataFormat==="channelsFirst"?e[4]:e[3];return t=Zs(t,this.poolSize[0],this.padding,this.strides[0]),n=Zs(n,this.poolSize[1],this.padding,this.strides[1]),s=Zs(s,this.poolSize[2],this.padding,this.strides[2]),this.dataFormat==="channelsFirst"?[e[0],e[1],t,n,s]:[e[0],t,n,s,e[4]]}call(e,t){return H(()=>(this.invokeCallHook(e,t),this.poolingFunction(We(e),this.poolSize,this.strides,this.padding,this.dataFormat)))}getConfig(){let e={poolSize:this.poolSize,padding:this.padding,strides:this.strides,dataFormat:this.dataFormat},t=super.getConfig();return Object.assign(e,t),e}},p2=class extends Uv{constructor(e){super(e)}poolingFunction(e,t,n,s,r){return Bt(r),vs(s),Bv(e,t,n,s,r,"max")}};p2.className="MaxPooling3D";le.registerClass(p2);var h2=class extends Uv{constructor(e){super(e)}poolingFunction(e,t,n,s,r){return Bt(r),vs(s),Bv(e,t,n,s,r,"avg")}};h2.className="AveragePooling3D";le.registerClass(h2);var Hv=class extends et{constructor(e){super(e);this.inputSpec=[new Ht({ndim:3})]}computeOutputShape(e){return[e[0],e[2]]}call(e,t){throw new ze}},f2=class extends Hv{constructor(e){super(e||{})}call(e,t){return H(()=>{let n=We(e);return Dt(n,1)})}};f2.className="GlobalAveragePooling1D";le.registerClass(f2);var m2=class extends Hv{constructor(e){super(e||{})}call(e,t){return H(()=>{let n=We(e);return ss(n,1)})}};m2.className="GlobalMaxPooling1D";le.registerClass(m2);var Gv=class extends et{constructor(e){super(e);this.dataFormat=e.dataFormat==null?"channelsLast":e.dataFormat,Bt(this.dataFormat),this.inputSpec=[new Ht({ndim:4})]}computeOutputShape(e){return e=e,this.dataFormat==="channelsLast"?[e[0],e[3]]:[e[0],e[1]]}call(e,t){throw new ze}getConfig(){let e={dataFormat:this.dataFormat},t=super.getConfig();return Object.assign(e,t),e}},g2=class extends Gv{call(e,t){return H(()=>{let n=We(e);return this.dataFormat==="channelsLast"?Dt(n,[1,2]):Dt(n,[2,3])})}};g2.className="GlobalAveragePooling2D";le.registerClass(g2);var A2=class extends Gv{call(e,t){return H(()=>{let n=We(e);return this.dataFormat==="channelsLast"?ss(n,[1,2]):ss(n,[2,3])})}};A2.className="GlobalMaxPooling2D";le.registerClass(A2);var jv=class extends et{constructor(e){super(e);this.layer=e.layer}build(e){this.built=!0}get trainable(){return this.layer!=null?this.layer.trainable:!1}set trainable(e){this.layer!=null&&(this.layer.trainable=e)}get trainableWeights(){return this.layer.trainableWeights}get nonTrainableWeights(){return this.layer.nonTrainableWeights}get updates(){return this.layer._updates}get losses(){return this.layer.losses}getWeights(){return this.layer.getWeights()}setWeights(e){this.layer.setWeights(e)}getConfig(){let e={layer:{className:this.layer.getClassName(),config:this.layer.getConfig()}},t=super.getConfig();return Object.assign(e,t),e}setFastWeightInitDuringBuild(e){super.setFastWeightInitDuringBuild(e),this.layer!=null&&this.layer.setFastWeightInitDuringBuild(e)}static fromConfig(e,t,n={}){let s=t.layer,r=Ks(s,n);delete t.layer;let a={layer:r};return Object.assign(a,t),new e(a)}},y2=class extends jv{constructor(e){super(e);this.supportsMasking=!0}build(e){if(e=ut(e),e.length<3)throw new G(`TimeDistributed layer expects an input shape >= 3D, but received input shape ${JSON.stringify(e)}`);this.inputSpec=[{shape:e}];let t=[e[0]].concat(e.slice(2));this.layer.built||(this.layer.build(t),this.layer.built=!0),super.build(e)}computeOutputShape(e){e=ut(e);let t=[e[0]].concat(e.slice(2)),n=this.layer.computeOutputShape(t),s=e[1];return[n[0],s].concat(n.slice(1))}call(e,t){return H(()=>(e=We(e),zv((a,o)=>[We(this.layer.call(a,t)),[]],e,[],!1,null,null,!1,!0)[1]))}};y2.className="TimeDistributed";le.registerClass(y2);function NM(e){Jo(FO,"BidirectionalMergeMode",e)}var EM="concat",x2=class extends jv{constructor(e){super(e);let t=e.layer.getConfig(),n={};n.className=e.layer.getClassName(),n.config=t,this.forwardLayer=Ks(n),t.goBackwards=t.goBackwards!==!0;let s={};if(s.className=e.layer.getClassName(),s.config=t,this.backwardLayer=Ks(s),this.forwardLayer.name="forward_"+this.forwardLayer.name,this.backwardLayer.name="backward_"+this.backwardLayer.name,this.mergeMode=e.mergeMode===void 0?EM:e.mergeMode,NM(this.mergeMode),e.weights)throw new ze("weights support is not implemented for Bidirectional layer yet.");this._stateful=e.layer.stateful,this.returnSequences=e.layer.returnSequences,this.returnState=e.layer.returnState,this.supportsMasking=!0,this._trainable=!0,this.inputSpec=e.layer.inputSpec,this.numConstants=null}get trainable(){return this._trainable}set trainable(e){this._trainable=e,this.forwardLayer!=null&&(this.forwardLayer.trainable=e),this.backwardLayer!=null&&(this.backwardLayer.trainable=e)}getWeights(){return this.forwardLayer.getWeights().concat(this.backwardLayer.getWeights())}setWeights(e){let t=e.length,n=Math.floor(t/2);this.forwardLayer.setWeights(e.slice(0,n)),this.backwardLayer.setWeights(e.slice(n))}computeOutputShape(e){let t=this.forwardLayer.computeOutputShape(e);Array.isArray(t)&&Array.isArray(t[0])||(t=[t]),t=t;let n,s,r;return this.returnState&&(r=t.slice(1)),n=t[0],n=n,this.mergeMode==="concat"?(n[n.length-1]*=2,s=[n]):this.mergeMode==null?s=[n,n.slice()]:s=[n],this.returnState?this.mergeMode==null?s.concat(r).concat(r.slice()):[n].concat(r).concat(r.slice()):Un(s)}apply(e,t){let n=t==null?null:t.initialState,s=t==null?null:t.constants;t==null&&(t={});let r=Mv(e,n,s,this.numConstants);if(e=r.inputs,n=r.initialState,s=r.constants,Array.isArray(e)&&(n=e.slice(1),e=e[0]),(n==null||n.length===0)&&s==null)return super.apply(e,t);let a=[],o=[];if(n!=null){let l=n.length;if(l%2>0)throw new G("When passing `initialState` to a Bidrectional RNN, the state should be an Array containing the states of the underlying RNNs.");t.initialState=n,a.push(...n);let u=n.map(c=>new Ht({shape:c.shape}));this.forwardLayer.stateSpec=u.slice(0,l/2),this.backwardLayer.stateSpec=u.slice(l/2),o.push(...u)}if(s!=null)throw new ze("Support for constants in Bidirectional layers is not implemented yet.");let i=a[0]instanceof Xs;for(let l of a)if(l instanceof Xs!==i)throw new G("The initial state of a Bidirectional layer cannot be specified as a mix of symbolic and non-symbolic tensors");if(i){let l=[e].concat(a),u=this.inputSpec.concat(o),c=this.inputSpec;this.inputSpec=u;let d=super.apply(l,t);return this.inputSpec=c,d}else return super.apply(e,t)}call(e,t){return H(()=>{let n=t.initialState,s,r;if(n==null)s=this.forwardLayer.call(e,t),r=this.backwardLayer.call(e,t);else{let i=n.slice(0,n.length/2),l=n.slice(n.length/2);s=this.forwardLayer.call(e,Object.assign(t,{initialState:i})),r=this.backwardLayer.call(e,Object.assign(t,{initialState:l}))}let a;this.returnState&&(Array.isArray(s)&&(a=s.slice(1).concat(r.slice(1))),s=s[0],r=r[0]),this.returnSequences&&(r=os(r,1));let o;return this.mergeMode==="concat"?o=qA([s,r]):this.mergeMode==="sum"?o=oe(s,r):this.mergeMode==="ave"?o=z(.5,oe(s,r)):this.mergeMode==="mul"?o=z(s,r):this.mergeMode==null&&(o=[s,r]),this.returnState?this.mergeMode==null?o.concat(a):[o].concat(a):o})}resetStates(e){this.forwardLayer.resetStates(),this.backwardLayer.resetStates()}build(e){Qo(this.forwardLayer.name,()=>{this.forwardLayer.build(e)}),Qo(this.backwardLayer.name,()=>{this.backwardLayer.build(e)}),this.built=!0}computeMask(e,t){Array.isArray(t)&&(t=t[0]);let n;if(this.returnSequences?this.mergeMode==null?n=[t,t]:n=t:this.mergeMode==null?n=[null,null]:n=null,this.returnState){let r=this.forwardLayer.states.map(a=>null);return Array.isArray(n)?n.concat(r).concat(r):[n].concat(r).concat(r)}else return n}get trainableWeights(){return this.forwardLayer.trainableWeights.concat(this.backwardLayer.trainableWeights)}get nonTrainableWeights(){return this.forwardLayer.nonTrainableWeights.concat(this.backwardLayer.nonTrainableWeights)}setFastWeightInitDuringBuild(e){super.setFastWeightInitDuringBuild(e),this.forwardLayer!=null&&this.forwardLayer.setFastWeightInitDuringBuild(e),this.backwardLayer!=null&&this.backwardLayer.setFastWeightInitDuringBuild(e)}getConfig(){let e={mergeMode:this.mergeMode},t=super.getConfig();return Object.assign(e,t),e}static fromConfig(e,t){let n=Ks(t.layer);if(delete t.layer,t.numConstants!=null)throw new ze("Deserialization of a Bidirectional layer with numConstants present is not supported yet.");let s=t;return s.layer=n,new e(s)}};x2.className="Bidirectional";le.registerClass(x2);function RM(e){return new ru(e)}function DM(e){return new S1(e)}function _M(e){return new w1(e)}function $M(e){return new k1(e)}function FM(e){return new I1(e)}function OM(e){return new T1(e)}function PM(e){return new C1(e)}function MM(e){return new vf(e)}function zM(e){return new Qc(e)}function LM(e){return new R1(e)}function BM(e){return new ed(e)}function WM(e){return new D1(e)}function VM(e){return new _1(e)}function UM(e){return new $1(e)}function HM(e){return new F1(e)}function GM(e){return new O1(e)}function jM(e){return new U1(e)}function qM(e){return new W1(e)}function XM(e){return new Cf(e)}function KM(e){return new B1(e)}function ZM(e){return new V1(e)}function YM(e){return new H1(e)}function JM(e){return new G1(e)}function QM(e){return new j1(e)}function ez(e){return new X1(e)}function tz(e){return new K1(e)}function nz(e){return new Y1(e)}function sz(e){return new e2(e)}function rz(e){return new J1(e)}function az(e){return new Q1(e)}function oz(e){return new Z1(e)}function iz(e){return new t2(e)}function lz(e){return new a2(e)}function uz(e){return new o2(e)}function cz(e){return new i2(e)}function b2(e){return new u2(e)}function dz(e){return b2(e)}function pz(e){return b2(e)}function v2(e){return new d2(e)}function hz(e){return v2(e)}function fz(e){return v2(e)}function w2(e){return new h2(e)}function mz(e){return w2(e)}function gz(e){return w2(e)}function Az(e){return new f2(e)}function yz(e){return new g2(e)}function qv(e){return new m2(e)}function Xv(e){return new A2(e)}function Kv(e){return new l2(e)}function Zv(e){return new c2(e)}function xz(e){return new p2(e)}function bz(e){return new M1(e)}function vz(e){return new kf(e)}function wz(e){return new z1(e)}function kz(e){return new nd(e)}function Iz(e){return new P1(e)}function Sz(e){return new wf(e)}function Cz(e){return new L1(e)}function Tz(e){return new Sf(e)}function Nz(e){return new hr(e)}function Ez(e){return new If(e)}function Rz(e){return new x2(e)}function Dz(e){return new y2(e)}var _z=qv,$z=Xv,Fz=Kv,Oz=Zv;function Pz(e){return new n2(e)}function Mz(e){return new s2(e)}function zz(e){return new r2(e)}function Lz(e){return new q1(e)}var Yv={};Le(Yv,{MAPE:()=>Zz,MSE:()=>Qz,binaryAccuracy:()=>Bz,binaryCrossentropy:()=>Wz,categoricalAccuracy:()=>Uz,categoricalCrossentropy:()=>Hz,cosineProximity:()=>qz,mape:()=>Yz,meanAbsoluteError:()=>Xz,meanAbsolutePercentageError:()=>Kz,meanSquaredError:()=>Jz,mse:()=>eL,precision:()=>Gz,recall:()=>jz,sparseCategoricalAccuracy:()=>Vz});function Bz(e,t){return l1(e,t)}function Wz(e,t){return Q3(e,t)}function Vz(e,t){return ev(e,t)}function Uz(e,t){return u1(e,t)}function Hz(e,t){return c1(e,t)}function Gz(e,t){return J3(e,t)}function jz(e,t){return EP(e,t)}function qz(e,t){return o1(e,t)}function Xz(e,t){return ff(e,t)}function Kz(e,t){return ou(e,t)}function Zz(e,t){return ou(e,t)}function Yz(e,t){return ou(e,t)}function Jz(e,t){return ti(e,t)}function Qz(e,t){return ti(e,t)}function eL(e,t){return ti(e,t)}var Jv={};Le(Jv,{modelFromJSON:()=>uM});var Qv={};Le(Qv,{l1:()=>nL,l1l2:()=>tL,l2:()=>sL});function tL(e){return new Yc(e)}function nL(e){return AM(e)}function sL(e){return yM(e)}var e7=class extends au{constructor(){super(...arguments);this.model=null}setModel(e){if(!(e instanceof Fr))throw new Error("model must be a LayersModel, not some other Container");this.model=e}};function Nf(e,t){return e<t}function t7(e,t){return e>t}var n7=class extends e7{constructor(e){super();if(e==null&&(e={}),e.restoreBestWeights)throw new ze("restoreBestWeights = True is not implemented in EarlyStopping yet.");this.monitor=e.monitor||"val_loss",this.minDelta=Math.abs(e.minDelta||0),this.patience=e.patience||0,this.verbose=e.verbose||0,this.mode=e.mode||"auto",this.baseline=e.baseline,["auto","min","max"].indexOf(this.mode)===-1&&(console.warn(`EarlyStopping mode '${this.mode}' is invalid. Falling back to mode 'auto'.`),this.mode="auto"),this.mode==="min"?this.monitorFunc=Nf:this.mode==="max"?this.monitorFunc=t7:this.monitor.indexOf("acc")!==-1?this.monitorFunc=t7:this.monitorFunc=Nf,this.monitorFunc===Nf&&(this.minDelta*=-1)}async onTrainBegin(e){this.wait=0,this.stoppedEpoch=0,this.baseline!=null?this.best=this.baseline:this.best=this.monitorFunc===Nf?1/0:-1/0}async onEpochEnd(e,t){await ma(t);let n=this.getMonitorValue(t);n!=null&&(this.monitorFunc(n-this.minDelta,this.best)?(this.best=n,this.wait=0):(this.wait++,this.wait>=this.patience&&(this.stoppedEpoch=e,this.model.stopTraining=!0)))}async onTrainEnd(e){this.stoppedEpoch>0&&this.verbose&&console.log(`Epoch ${this.stoppedEpoch}: early stopping.`)}getMonitorValue(e){e==null&&(e={});let t=e[this.monitor];return t==null&&console.warn(`Metric for EarlyStopping ${this.monitor} is not available. Available metrics are: ${Object.keys(e)}`),t}};function rL(e){return new n7(e)}var aL={earlyStopping:rL},Ys;(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_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"})(Ys||(Ys={}));var s7;(function(e){let t;(function(n){n[n.LEGACY=0]="LEGACY",n[n.V1=1]="V1",n[n.V2=2]="V2"})(t=e.CheckpointFormatVersion||(e.CheckpointFormatVersion={}))})(s7||(s7={}));var k2={};function oL(e,t){let n={tfOpName:e,category:"custom",inputs:[],attrs:[],customExecutor:t};k2[e]=n}function r7(e){return k2[e]}function iL(e){delete k2[e]}function I(e,t,n,s,r){let a=t.inputParams[e];if(a&&a.inputIndexStart!==void 0){let i=a.inputIndexStart,l=a.inputIndexEnd===0?void 0:a.inputIndexEnd===void 0?i+1:a.inputIndexEnd;if(a.type==="tensor")return Nn(t.inputNames[a.inputIndexStart],n,s,r);if(a.type==="tensors")return t.inputNames.slice(i,l).map(p=>Nn(p,n,s,r));let u=Nn(t.inputNames.slice(i)[0],n,s,r),c=u.dataSync();return a.type==="number"?c[0]:w.toNestedArray(u.shape,c)}let o=t.attrParams[e];return o&&o.value}function Nn(e,t,n,s){let[r,a]=ls(e);if(s!=null){let i=s.getHashTableHandleByName(r);if(i!=null)return i}let o=n.currentContextIds.find(i=>!!t[Ef(r,i)]);return o!==void 0?t[Ef(r,o)][a]:void 0}function lL(e,t,n){return t[Ef(e,n.currentContextId)]}function Or(e,t){let[n,s,r]=ls(e);return[Ef(n,t&&t.currentContextId),s,r]}function Ef(e,t){return t?`${e}-${t}`:e}function ls(e){let t=e.split(":");if(t.length===1)return[e,0,void 0];let n=t[0],s=t.length===3?t[1]:void 0,r=Number(t[t.length-1]);return[n,r,s]}function Rf(e,t,n){let s=I("pad",e,t,n);if(s==="explicit"){s=I("explicitPaddings",e,t,n);let r=[[0,0],[0,0],[0,0],[0,0]];for(let a=0;a<4;a++)r[a][0]=s[a*2],r[a][1]=s[a*2+1];return r}return s}function Pr(e){return e.kept?e:Bs(e)}var a7={};Le(a7,{json:()=>uL});var uL=[{tfOpName:"Add",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"AddV2",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"AddN",category:"arithmetic",inputs:[{start:0,end:0,name:"tensors",type:"tensors"}]},{tfOpName:"BiasAdd",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0},{tfName:"data_format",name:"dataFormat",type:"string",notSupported:!0}]},{tfOpName:"Sub",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"RealDiv",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Div",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"DivNoNan",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"FloorDiv",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Mul",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Maximum",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Minimum",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Pow",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"SquaredDifference",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Mod",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"FloorMod",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]}],o7={};Le(o7,{json:()=>cL});var cL=[{tfOpName:"Abs",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Acos",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Asin",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Atan",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Atan2",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"y",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Ceil",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"ClipByValue",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"clipValueMin",type:"number"},{start:2,name:"clipValueMax",type:"number"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Complex",category:"basic_math",inputs:[{start:0,name:"real",type:"tensor"},{start:1,name:"imag",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"ComplexAbs",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Cos",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Cosh",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Elu",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Exp",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Floor",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Log",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Imag",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0},{tfName:"Tout",name:"outputType",type:"dtype",notSupported:!0}]},{tfOpName:"Neg",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Real",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0},{tfName:"Tout",name:"outputType",type:"dtype",notSupported:!0}]},{tfOpName:"Prelu",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"alpha",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Relu",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Relu6",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Selu",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Sigmoid",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Sin",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Sinh",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Sqrt",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Rsqrt",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Square",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Tan",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Tanh",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Sign",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Round",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Expm1",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Log1p",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Reciprocal",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Softplus",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Asinh",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Acosh",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Atanh",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Erf",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"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}]}],i7={};Le(i7,{json:()=>dL});var dL=[{tfOpName:"EmptyTensorList",category:"control",inputs:[{start:0,name:"elementShape",type:"shape"},{start:1,name:"maxNumElements",type:"number"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"LoopCond",category:"control",inputs:[{start:0,name:"pred",type:"tensor"}]},{tfOpName:"Switch",category:"control",inputs:[{start:0,name:"data",type:"tensor"},{start:1,name:"pred",type:"tensor"}]},{tfOpName:"Merge",category:"control",inputs:[{start:0,end:0,name:"tensors",type:"tensors"}]},{tfOpName:"Enter",category:"control",inputs:[{start:0,name:"tensor",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0},{tfName:"frame_name",name:"frameName",type:"string"},{tfName:"is_constant",name:"isConstant",type:"bool"}]},{tfOpName:"Exit",category:"control",inputs:[{start:0,name:"tensor",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"NextIteration",category:"control",inputs:[{start:0,name:"tensor",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"TensorArrayV3",category:"control",inputs:[{start:0,name:"size",type:"number"}],attrs:[{tfName:"dtype",name:"dtype",type:"dtype"},{tfName:"element_shape",name:"elementShape",type:"shape"},{tfName:"dynamic_size",name:"dynamicSize",type:"bool"},{tfName:"clear_after_read",name:"clearAfterRead",type:"bool"},{tfName:"identical_element_shapes",name:"identicalElementShapes",type:"bool"},{tfName:"tensor_array_name",name:"name",type:"string"}]},{tfOpName:"TensorArrayWriteV3",category:"control",inputs:[{start:0,name:"tensorArrayId",type:"tensor"},{start:1,name:"index",type:"number"},{start:2,name:"tensor",type:"tensor"},{start:3,name:"flowIn",type:"number"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"TensorArrayReadV3",category:"control",inputs:[{start:0,name:"tensorArrayId",type:"tensor"},{start:1,name:"index",type:"number"},{start:2,name:"flowIn",type:"number"}],attrs:[{tfName:"dtype",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"TensorArrayGatherV3",category:"control",inputs:[{start:0,name:"tensorArrayId",type:"tensor"},{start:1,name:"indices",type:"number[]"},{start:2,name:"flowIn",type:"number"}],attrs:[{tfName:"dtype",name:"dtype",type:"dtype"},{tfName:"element_shape",name:"elementShape",type:"shape"}]},{tfOpName:"TensorArrayScatterV3",category:"control",inputs:[{start:0,name:"tensorArrayId",type:"tensor"},{start:1,name:"indices",type:"number[]"},{start:2,name:"tensor",type:"tensor"},{start:3,name:"flowIn",type:"number"}],attrs:[{tfName:"T",name:"dtype",type:"dtype"}]},{tfOpName:"TensorArrayConcatV3",category:"control",inputs:[{start:0,name:"tensorArrayId",type:"tensor"},{start:1,name:"flowIn",type:"number"}],attrs:[{tfName:"dtype",name:"dtype",type:"dtype"},{tfName:"element_shape_except0",name:"elementShapeExcept0",type:"shape",notSupported:!0}]},{tfOpName:"TensorArraySplitV3",category:"control",inputs:[{start:0,name:"tensorArrayId",type:"tensor"},{start:1,name:"tensor",type:"tensor"},{start:2,name:"lengths",type:"number[]"},{start:3,name:"flowIn",type:"number"}],attrs:[{tfName:"T",name:"dtype",type:"dtype"}]},{tfOpName:"TensorArraySizeV3",category:"control",inputs:[{start:0,name:"tensorArrayId",type:"tensor"},{start:1,name:"flowIn",type:"number"}]},{tfOpName:"TensorArrayCloseV3",category:"control",inputs:[{start:0,name:"tensorArrayId",type:"tensor"}]},{tfOpName:"StatelessIf",category:"control",inputs:[{start:0,name:"cond",type:"tensor"},{start:1,end:0,name:"args",type:"tensors"}],attrs:[{tfName:"then_branch",name:"thenBranch",type:"func"},{tfName:"else_branch",name:"elseBranch",type:"func"}]},{tfOpName:"If",category:"control",inputs:[{start:0,name:"cond",type:"tensor"},{start:1,end:0,name:"args",type:"tensors"}],attrs:[{tfName:"then_branch",name:"thenBranch",type:"func"},{tfName:"else_branch",name:"elseBranch",type:"func"}]},{tfOpName:"StatelessWhile",category:"control",inputs:[{start:0,end:0,name:"args",type:"tensors"}],attrs:[{tfName:"cond",name:"cond",type:"func"},{tfName:"body",name:"body",type:"func"}]},{tfOpName:"While",category:"control",inputs:[{start:0,end:0,name:"args",type:"tensors"}],attrs:[{tfName:"cond",name:"cond",type:"func"},{tfName:"body",name:"body",type:"func"}]},{tfOpName:"TensorListScatter",category:"control",inputs:[{start:0,name:"tensor",type:"tensor"},{start:1,name:"indices",type:"number[]"},{start:2,name:"elementShape",type:"shape"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListScatterV2",category:"control",inputs:[{start:0,name:"tensor",type:"tensor"},{start:1,name:"indices",type:"number[]"},{start:2,name:"elementShape",type:"shape"},{start:3,name:"numElements",type:"number"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListGather",category:"control",inputs:[{start:0,name:"tensorListId",type:"tensor"},{start:1,name:"indices",type:"number[]"},{start:2,name:"elementShape",type:"shape"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListGetItem",category:"control",inputs:[{start:0,name:"tensorListId",type:"tensor"},{start:1,name:"index",type:"number"},{start:2,name:"elementShape",type:"shape"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListSetItem",category:"control",inputs:[{start:0,name:"tensorListId",type:"tensor"},{start:1,name:"index",type:"number"},{start:2,name:"tensor",type:"tensor"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListReserve",category:"control",inputs:[{start:0,name:"elementShape",type:"shape"},{start:1,name:"numElements",type:"number"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListFromTensor",category:"control",inputs:[{start:0,name:"tensor",type:"tensor"},{start:1,name:"elementShape",type:"shape"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListStack",category:"control",inputs:[{start:0,name:"tensorListId",type:"tensor"},{start:1,name:"elementShape",type:"shape"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"},{tfName:"num_elements",name:"numElements",type:"dtype"}]},{tfOpName:"TensorListSplit",category:"control",inputs:[{start:0,name:"tensor",type:"tensor"},{start:1,name:"elementShape",type:"shape"},{start:2,name:"lengths",type:"number[]"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListConcat",category:"control",inputs:[{start:0,name:"tensorListId",type:"tensor"}],attrs:[{tfName:"element_shape",name:"elementShape",type:"shape"},{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"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"}]}],l7={};Le(l7,{json:()=>pL});var pL=[{tfOpName:"AvgPool",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",notSupported:!0},{tfName:"ksize",name:"kernelSize",type:"number[]"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"MaxPool",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",notSupported:!0},{tfName:"ksize",name:"kernelSize",type:"number[]"},{tfName:"explicit_paddings",name:"explicitPaddings",type:"number[]",defaultValue:[],notSupported:!0},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"MaxPoolWithArgmax",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"ksize",name:"kernelSize",type:"number[]"},{tfName:"include_batch_in_index",name:"includeBatchInIndex",type:"bool"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"AvgPool3D",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",notSupported:!0},{tfName:"ksize",name:"kernelSize",type:"number[]"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"MaxPool3D",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",notSupported:!0},{tfName:"ksize",name:"kernelSize",type:"number[]"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Conv1D",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"filter",type:"tensor"}],attrs:[{tfName:"stride",name:"stride",type:"number"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",defaultValue:"NWC"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0},{tfName:"dilation",name:"dilation",type:"number",defaultValue:1}]},{tfOpName:"Conv2D",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"filter",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0},{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"useCudnnOnGpu",name:"useCudnnOnGpu",type:"bool"},{tfName:"data_format",name:"dataFormat",type:"string",defaultValue:"NHWC"},{tfName:"explicit_paddings",name:"explicitPaddings",type:"number[]",defaultValue:[]},{tfName:"dilations",name:"dilations",type:"number[]"}]},{tfOpName:"_FusedConv2D",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"filter",type:"tensor"},{start:2,end:0,name:"args",type:"tensors"}],attrs:[{tfName:"num_args",name:"numArgs",type:"number"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0},{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"explicit_paddings",name:"explicitPaddings",type:"number[]",defaultValue:[]},{tfName:"use_cudnn_on_gpu",name:"useCudnnOnGpu",type:"bool",defaultValue:!0},{tfName:"data_format",name:"dataFormat",type:"string",defaultValue:"NHWC"},{tfName:"dilations",name:"dilations",type:"number[]",defaultValue:[1,1,1,1]},{tfName:"fused_ops",name:"fusedOps",type:"string[]",defaultValue:[]},{tfName:"epsilon",name:"epsilon",type:"number",defaultValue:1e-4},{tfName:"leakyrelu_alpha",name:"leakyreluAlpha",type:"number"}]},{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"}]}],u7={};Le(u7,{json:()=>hL});var hL=[{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",notSupported:!0}]},{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:"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"}]}],c7={};Le(c7,{json:()=>fL});var fL=[{tfOpName:"NonMaxSuppressionV2",category:"dynamic",inputs:[{start:0,name:"boxes",type:"tensor"},{start:1,name:"scores",type:"tensor"},{start:2,name:"maxOutputSize",type:"number"},{start:3,name:"iouThreshold",type:"number"}]},{tfOpName:"NonMaxSuppressionV3",category:"dynamic",inputs:[{start:0,name:"boxes",type:"tensor"},{start:1,name:"scores",type:"tensor"},{start:2,name:"maxOutputSize",type:"number"},{start:3,name:"iouThreshold",type:"number"},{start:4,name:"scoreThreshold",type:"number"}]},{tfOpName:"NonMaxSuppressionV4",category:"dynamic",inputs:[{start:0,name:"boxes",type:"tensor"},{start:1,name:"scores",type:"tensor"},{start:2,name:"maxOutputSize",type:"number"},{start:3,name:"iouThreshold",type:"number"},{start:4,name:"scoreThreshold",type:"number"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0},{tfName:"T_threshold",name:"threshold",type:"dtype",notSupported:!0},{tfName:"pad_to_max_output_size",name:"padToMaxOutputSize",type:"bool"}]},{tfOpName:"NonMaxSuppressionV5",category:"dynamic",inputs:[{start:0,name:"boxes",type:"tensor"},{start:1,name:"scores",type:"tensor"},{start:2,name:"maxOutputSize",type:"number"},{start:3,name:"iouThreshold",type:"number"},{start:4,name:"scoreThreshold",type:"number"},{start:5,name:"softNmsSigma",type:"number"}]},{tfOpName:"Where",category:"dynamic",inputs:[{start:0,name:"condition",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"ListDiff",category:"dynamic",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"y",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]}],d7={};Le(d7,{json:()=>mL});var mL=[{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:"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"}]}],p7={};Le(p7,{json:()=>gL});var gL=[{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"}]}],h7={};Le(h7,{json:()=>AL});var AL=[{tfOpName:"HashTable",category:"hash_table",inputs:[],attrs:[{tfName:"shared_name",name:"sharedName",type:"string"},{tfName:"use_node_name_sharing",name:"useNodeNameSharing",type:"bool"},{tfName:"key_dtype",name:"keyDType",type:"dtype"},{tfName:"value_dtype",name:"valueDType",type:"dtype"}]},{tfOpName:"HashTableV2",category:"hash_table",inputs:[],attrs:[{tfName:"shared_name",name:"sharedName",type:"string"},{tfName:"use_node_name_sharing",name:"useNodeNameSharing",type:"bool"},{tfName:"key_dtype",name:"keyDType",type:"dtype"},{tfName:"value_dtype",name:"valueDType",type:"dtype"}]},{tfOpName:"LookupTableImport",category:"hash_table",inputs:[{start:0,name:"tableHandle",type:"tensor"},{start:1,name:"keys",type:"tensor"},{start:2,name:"values",type:"tensor"}],attrs:[{tfName:"Tin",name:"tIn",type:"dtype",notSupported:!0},{tfName:"Tout",name:"tOut",type:"dtype",notSupported:!0}]},{tfOpName:"LookupTableImportV2",category:"hash_table",inputs:[{start:0,name:"tableHandle",type:"tensor"},{start:1,name:"keys",type:"tensor"},{start:2,name:"values",type:"tensor"}],attrs:[{tfName:"Tin",name:"tIn",type:"dtype",notSupported:!0},{tfName:"Tout",name:"tOut",type:"dtype",notSupported:!0}]},{tfOpName:"LookupTableFind",category:"hash_table",inputs:[{start:0,name:"tableHandle",type:"tensor"},{start:1,name:"keys",type:"tensor"},{start:2,name:"defaultValue",type:"tensor"}],attrs:[{tfName:"Tin",name:"tIn",type:"dtype",notSupported:!0},{tfName:"Tout",name:"tOut",type:"dtype",notSupported:!0}]},{tfOpName:"LookupTableFindV2",category:"hash_table",inputs:[{start:0,name:"tableHandle",type:"tensor"},{start:1,name:"keys",type:"tensor"},{start:2,name:"defaultValue",type:"tensor"}],attrs:[{tfName:"Tin",name:"tIn",type:"dtype",notSupported:!0},{tfName:"Tout",name:"tOut",type:"dtype",notSupported:!0}]},{tfOpName:"LookupTableSize",category:"hash_table",inputs:[{start:0,name:"tableHandle",type:"tensor"}]},{tfOpName:"LookupTableSizeV2",category:"hash_table",inputs:[{start:0,name:"tableHandle",type:"tensor"}]}],f7={};Le(f7,{json:()=>yL});var yL=[{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"}]}],m7={};Le(m7,{json:()=>xL});var xL=[{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}]}],g7={};Le(g7,{json:()=>bL});var bL=[{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:"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"}]}],A7={};Le(A7,{json:()=>vL});var vL=[{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}]}],y7={};Le(y7,{json:()=>wL});var wL=[{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:"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"}]}],x7={};Le(x7,{json:()=>kL});var kL=[{tfOpName:"ConcatV2",category:"slice_join",inputs:[{start:0,end:-1,name:"tensors",type:"tensors"},{start:-1,name:"axis",type:"number"}],attrs:[{tfName:"N",name:"n",type:"number",defaultValue:2}]},{tfOpName:"Concat",category:"slice_join",inputs:[{start:1,end:0,name:"tensors",type:"tensors"},{start:0,name:"axis",type:"number"}],attrs:[{tfName:"N",name:"n",type:"number",defaultValue:2}]},{tfOpName:"GatherV2",category:"slice_join",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"indices",type:"tensor"},{start:2,name:"axis",type:"number",defaultValue:0}],attrs:[{tfName:"batch_dims",name:"batchDims",type:"number",defaultValue:0}]},{tfOpName:"Gather",category:"slice_join",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"indices",type:"tensor"}],attrs:[{tfName:"validate_indices",name:"validateIndices",type:"bool",notSupported:!0}]},{tfOpName:"Reverse",category:"slice_join",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"dims",type:"bool[]"}]},{tfOpName:"ReverseV2",category:"slice_join",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number[]"}]},{tfOpName:"Slice",category:"slice_join",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"begin",type:"number[]"},{start:2,name:"size",type:"number[]"}]},{tfOpName:"StridedSlice",category:"slice_join",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"begin",type:"number[]"},{start:2,name:"end",type:"number[]"},{start:3,name:"strides",type:"number[]"}],attrs:[{tfName:"begin_mask",name:"beginMask",type:"number",defaultValue:0},{tfName:"end_mask",name:"endMask",type:"number",defaultValue:0},{tfName:"new_axis_mask",name:"newAxisMask",type:"number",defaultValue:0},{tfName:"ellipsis_mask",name:"ellipsisMask",type:"number",defaultValue:0},{tfName:"shrink_axis_mask",name:"shrinkAxisMask",type:"number",defaultValue:0}]},{tfOpName:"Pack",category:"slice_join",inputs:[{start:0,end:0,name:"tensors",type:"tensors"}],attrs:[{tfName:"axis",name:"axis",type:"number",defaultValue:0}]},{tfOpName:"Unpack",category:"slice_join",inputs:[{start:0,name:"tensor",type:"tensor"}],attrs:[{tfName:"axis",name:"axis",type:"number",defaultValue:0},{tfName:"num",name:"num",type:"number",defaultValue:0,notSupported:!0}]},{tfOpName:"Tile",category:"slice_join",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"reps",type:"number[]"}]},{tfOpName:"Split",category:"slice_join",inputs:[{start:0,name:"axis",type:"number",defaultValue:0},{start:1,name:"x",type:"tensor"}],attrs:[{tfName:"num_split",name:"numOrSizeSplits",type:"number",defaultValue:1}]},{tfOpName:"SplitV",category:"slice_join",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"numOrSizeSplits",type:"number[]"},{start:2,name:"axis",type:"number",defaultValue:0}]},{tfOpName:"ScatterNd",category:"slice_join",inputs:[{start:0,name:"indices",type:"tensor"},{start:1,name:"values",type:"tensor"},{start:2,name:"shape",type:"number[]"}]},{tfOpName:"GatherNd",category:"slice_join",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"indices",type:"tensor"}]},{tfOpName:"SparseToDense",category:"slice_join",inputs:[{start:0,name:"sparseIndices",type:"tensor"},{start:1,name:"outputShape",type:"number[]"},{start:2,name:"sparseValues",type:"tensor"},{start:3,name:"defaultValue",type:"tensor"}],attrs:[{tfName:"validate_indices",name:"validateIndices",type:"bool",defaultValue:!1,notSupported:!0}]}],b7={};Le(b7,{json:()=>IL});var IL=[{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"}]}],v7={};Le(v7,{json:()=>SL});var SL=[{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}]}],w7={};Le(w7,{json:()=>CL});var CL=[{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"}]}],k7={};Le(k7,{json:()=>TL});var TL=[{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:[]}],I7=class{static get Instance(){return this._instance||(this._instance=new this)}constructor(){let e=[a7,o7,i7,l7,u7,c7,d7,p7,h7,f7,m7,g7,A7,y7,x7,b7,v7,w7,k7],t=[].concat(...e.map(n=>n.json));this.opMappers=t.reduce((n,s)=>(n[s.tfOpName]=s,n),{})}transformGraph(e,t={}){let n=e.node,s=[],r=[],a=[],o=n.reduce((f,m)=>(f[m.name]=this.mapNode(m),m.op.startsWith("Placeholder")?s.push(f[m.name]):m.op==="Const"?r.push(f[m.name]):(m.input==null||m.input.length===0)&&a.push(f[m.name]),f),{}),i=[],l=[],u={},c={};t!=null&&(u=this.mapSignatureEntries(t.inputs),c=this.mapSignatureEntries(t.outputs));let d=Object.keys(o);d.forEach(f=>{let m=o[f];m.inputNames.forEach((g,A)=>{let[y,,x]=Or(g),b=o[y];if(b.outputs!=null){let v=b.outputs.indexOf(x);if(v!==-1){let k=`${y}:${v}`;m.inputNames[A]=k}}m.inputs.push(b),b.children.push(m)})}),Object.keys(c).length===0?d.forEach(f=>{let m=o[f];m.children.length===0&&l.push(m)}):Object.keys(c).forEach(f=>{let[m]=Or(f),g=o[m];g!=null&&(g.signatureKey=c[f],l.push(g))}),Object.keys(u).length>0?Object.keys(u).forEach(f=>{let[m]=Or(f),g=o[m];g&&(g.signatureKey=u[f],i.push(g))}):i=s;let p={};e.library!=null&&e.library.function!=null&&(p=e.library.function.reduce((f,m)=>(f[m.signature.name]=this.mapFunction(m),f),{}));let h={nodes:o,inputs:i,outputs:l,weights:r,placeholders:s,signature:t,functions:p};return a.length>0&&(h.initNodes=a),h}mapSignatureEntries(e){return Object.keys(e||{}).reduce((t,n)=>(t[e[n].name]=n,t),{})}mapNode(e){let t=r7(e.op)||this.opMappers[e.op]||{};e.attr==null&&(e.attr={});let n={name:e.name,op:e.op,category:t.category,inputNames:(e.input||[]).map(s=>s.startsWith("^")?s.substr(1):s),inputs:[],children:[],inputParams:{},attrParams:{},rawAttrs:e.attr,outputs:t.outputs};return t.inputs!=null&&(n.inputParams=t.inputs.reduce((s,r)=>(s[r.name]={type:r.type,inputIndexStart:r.start,inputIndexEnd:r.end},s),{})),t.attrs!=null&&(n.attrParams=t.attrs.reduce((s,r)=>{let a=r.type,o;switch(r.type){case"string":o=I2(e.attr,r.tfName,r.defaultValue),o===void 0&&!!r.tfDeprecatedName&&(o=I2(e.attr,r.tfDeprecatedName,r.defaultValue));break;case"string[]":o=_2(e.attr,r.tfName,r.defaultValue),o===void 0&&!!r.tfDeprecatedName&&(o=_2(e.attr,r.tfDeprecatedName,r.defaultValue));break;case"number":o=C2(e.attr,r.tfName,r.defaultValue||0),o===void 0&&!!r.tfDeprecatedName&&(o=C2(e.attr,r.tfDeprecatedName,r.defaultValue));break;case"number[]":o=D2(e.attr,r.tfName,r.defaultValue),o===void 0&&!!r.tfDeprecatedName&&(o=D2(e.attr,r.tfDeprecatedName,r.defaultValue));break;case"bool":o=S2(e.attr,r.tfName,r.defaultValue),o===void 0&&!!r.tfDeprecatedName&&(o=S2(e.attr,r.tfDeprecatedName,r.defaultValue));break;case"bool[]":o=F2(e.attr,r.tfName,r.defaultValue),o===void 0&&!!r.tfDeprecatedName&&(o=F2(e.attr,r.tfDeprecatedName,r.defaultValue));break;case"shape":o=R2(e.attr,r.tfName,r.defaultValue),o===void 0&&!!r.tfDeprecatedName&&(o=R2(e.attr,r.tfDeprecatedName,r.defaultValue));break;case"shape[]":o=$2(e.attr,r.tfName,r.defaultValue),o===void 0&&!!r.tfDeprecatedName&&(o=$2(e.attr,r.tfDeprecatedName,r.defaultValue));break;case"dtype":o=N2(e.attr,r.tfName,r.defaultValue),o===void 0&&!!r.tfDeprecatedName&&(o=N2(e.attr,r.tfDeprecatedName,r.defaultValue));break;case"dtype[]":o=E2(e.attr,r.tfName,r.defaultValue),o===void 0&&!!r.tfDeprecatedName&&(o=E2(e.attr,r.tfDeprecatedName,r.defaultValue));break;case"func":o=C7(e.attr,r.tfName,r.defaultValue),o===void 0&&!!r.tfDeprecatedName&&(o=C7(e.attr,r.tfDeprecatedName,r.defaultValue));break;case"tensor":case"tensors":break;default:throw new Error(`Unsupported param type: ${r.type} for op: ${e.op}`)}return s[r.name]={value:o,type:a},s},{})),n}mapFunction(e){let t=e.nodeDef,n=[],s=[],r={};t!=null&&(r=t.reduce((c,d)=>(c[d.name]=this.mapNode(d),d.op==="Const"&&s.push(c[d.name]),c),{}));let a=[],o=[];e.signature.inputArg.forEach(c=>{let[d]=Or(c.name),p={name:d,op:"Placeholder",inputs:[],inputNames:[],category:"graph",inputParams:{},attrParams:{dtype:{value:T2(c.type),type:"dtype"}},children:[]};p.signatureKey=c.name,a.push(p),r[d]=p}),Object.keys(r).forEach(c=>{let d=r[c];d.inputNames.forEach((p,h)=>{let[f,,m]=Or(p),g=r[f];if(g.outputs!=null){let A=g.outputs.indexOf(m);if(A!==-1){let y=`${f}:${A}`;d.inputNames[h]=y}}d.inputs.push(g),g.children.push(d)})});let l=e.ret;e.signature.outputArg.forEach(c=>{let[d,p]=Or(l[c.name]),h=r[d];h!=null&&(h.defaultOutput=p,o.push(h))});let u=this.mapArgsToSignature(e);return{nodes:r,inputs:a,outputs:o,weights:s,placeholders:n,signature:u}}mapArgsToSignature(e){return{methodName:e.signature.name,inputs:e.signature.inputArg.reduce((t,n)=>(t[n.name]=this.mapArgToTensorInfo(n),t),{}),outputs:e.signature.outputArg.reduce((t,n)=>(t[n.name]=this.mapArgToTensorInfo(n,e.ret),t),{})}}mapArgToTensorInfo(e,t){let n=e.name;return t!=null&&(n=t[n]),{name:n,dtype:e.type}}};function NL(e){let t=Y().global;if(typeof t.atob!="undefined")return t.atob(e);if(typeof Buffer!="undefined")return new Buffer(e,"base64").toString();throw new Error("Unable to decode base64 in this environment. Missing built-in atob() or Buffer()")}function S7(e,t){let n=Array.isArray(e)?String.fromCharCode.apply(null,e):NL(e);return t?n:n.toLowerCase()}function I2(e,t,n,s=!1){let r=e[t];return r!=null?S7(r.s,s):n}function S2(e,t,n){let s=e[t];return s?s.b:n}function C2(e,t,n){let s=e[t]||{},r=s.i!=null?s.i:s.f!=null?s.f:n;return typeof r=="number"?r:parseInt(r,10)}function T2(e){switch(typeof e=="string"&&(e=Ys[e]),e){case Ys.DT_FLOAT:return"float32";case Ys.DT_INT32:case Ys.DT_INT64:case Ys.DT_INT8:case Ys.DT_UINT8:return"int32";case Ys.DT_BOOL:return"bool";case Ys.DT_DOUBLE:return"float32";case Ys.DT_STRING:return"string";default:return null}}function C7(e,t,n){let s=e[t];return s&&s.func?s.func.name:n}function N2(e,t,n){let s=e[t];return s&&s.type?T2(s.type):n}function E2(e,t,n){let s=e[t];return s&&s.list&&s.list.type?s.list.type.map(r=>T2(r)):n}function T7(e){if(!e.unknownRank)return e.dim!=null?e.dim.map(t=>typeof t.size=="number"?t.size:parseInt(t.size,10)):[]}function R2(e,t,n){let s=e[t];return s&&s.shape?T7(s.shape):n}function D2(e,t,n){let s=e[t];return s?((s.list.f&&s.list.f.length?s.list.f:s.list.i)||[]).map(r=>typeof r=="number"?r:parseInt(r,10)):n}function _2(e,t,n,s=!1){let r=e[t];return r&&r.list&&r.list.s?r.list.s.map(a=>S7(a,s)):n}function $2(e,t,n){let s=e[t];return s&&s.list&&s.list.shape?s.list.shape.map(r=>T7(r)):n}function F2(e,t,n){let s=e[t];return s&&s.list&&s.list.b?s.list.b:n}var EL=class{constructor(e,t,n){this.node=e,this.tensorMap=t,this.context=n,this.inputs=[],this.attrs={},this.inputs=e.inputNames.map(s=>this.getInput(s)),e.rawAttrs!=null&&(this.attrs=Object.keys(e.rawAttrs).reduce((s,r)=>(s[r]=this.getAttr(r),s),{}))}getInput(e){return Nn(e,this.tensorMap,this.context)}getAttr(e,t){let n=this.node.rawAttrs[e];if(n.tensor!=null)return Nn(e,this.tensorMap,this.context);if(n.i!=null||n.f!=null)return C2(this.node.rawAttrs,e,t);if(n.s!=null)return I2(this.node.rawAttrs,e,t);if(n.b!=null)return S2(this.node.rawAttrs,e,t);if(n.shape!=null)return R2(this.node.rawAttrs,e,t);if(n.type!=null)return N2(this.node.rawAttrs,e,t);if(n.list!=null){if(n.list.i!=null||n.list.f!=null)return D2(this.node.rawAttrs,e,t);if(n.list.s!=null)return _2(this.node.rawAttrs,e,t);if(n.list.shape!=null)return $2(this.node.rawAttrs,e,t);if(n.list.b!=null)return F2(this.node.rawAttrs,e,t);if(n.list.type!=null)return E2(this.node.rawAttrs,e,t)}return t}},RL=(e,t,n)=>{switch(e.op){case"BiasAdd":case"AddV2":case"Add":return[oe(I("a",e,t,n),I("b",e,t,n))];case"AddN":return[dh(I("tensors",e,t,n))];case"FloorMod":case"Mod":return[xA(I("a",e,t,n),I("b",e,t,n))];case"Mul":return[z(I("a",e,t,n),I("b",e,t,n))];case"RealDiv":case"Div":return[he(I("a",e,t,n),I("b",e,t,n))];case"DivNoNan":return[lA(I("a",e,t,n),I("b",e,t,n))];case"FloorDiv":return[ch(I("a",e,t,n),I("b",e,t,n))];case"Sub":return[ye(I("a",e,t,n),I("b",e,t,n))];case"Minimum":return[Zl(I("a",e,t,n),I("b",e,t,n))];case"Maximum":return[ir(I("a",e,t,n),I("b",e,t,n))];case"Pow":return[Er(I("a",e,t,n),I("b",e,t,n))];case"SquaredDifference":return[Fh(I("a",e,t,n),I("b",e,t,n))];default:throw TypeError(`Node type ${e.op} is not implemented`)}},DL=(e,t,n)=>{switch(e.op){case"Abs":case"ComplexAbs":return[Wt(I("x",e,t,n))];case"Acos":return[Gg(I("x",e,t,n))];case"Acosh":return[jg(I("x",e,t,n))];case"Asin":return[Xg(I("x",e,t,n))];case"Asinh":return[Kg(I("x",e,t,n))];case"Atan":return[Zg(I("x",e,t,n))];case"Atan2":return[Yg(I("x",e,t,n),I("y",e,t,n))];case"Atanh":return[Jg(I("x",e,t,n))];case"Ceil":return[sA(I("x",e,t,n))];case"Complex":return[sa(I("real",e,t,n),I("imag",e,t,n))];case"Cos":return[Cc(I("x",e,t,n))];case"Cosh":return[gh(I("x",e,t,n))];case"Elu":return[ql(I("x",e,t,n))];case"Erf":return[uA(I("x",e,t,n))];case"Exp":return[ts(I("x",e,t,n))];case"Expm1":return[cA(I("x",e,t,n))];case"Floor":return[Kl(I("x",e,t,n))];case"Log":return[ns(I("x",e,t,n))];case"Log1p":return[Nc(I("x",e,t,n))];case"Imag":return[yh(I("x",e,t,n))];case"Neg":return[St(I("x",e,t,n))];case"Reciprocal":return[wA(I("x",e,t,n))];case"Real":return[Fc(I("x",e,t,n))];case"Relu":return[Vs(I("x",e,t,n))];case"Round":return[Ch(I("x",e,t,n))];case"Selu":return[Nh(I("x",e,t,n))];case"Sigmoid":return[Bn(I("x",e,t,n))];case"Sin":return[Eh(I("x",e,t,n))];case"Sign":return[IA(I("x",e,t,n))];case"Sinh":return[Rh(I("x",e,t,n))];case"Softplus":return[Go(I("x",e,t,n))];case"Sqrt":return[fn(I("x",e,t,n))];case"Square":return[pt(I("x",e,t,n))];case"Tanh":return[Vo(I("x",e,t,n))];case"Tan":return[TA(I("x",e,t,n))];case"ClipByValue":return[Wn(I("x",e,t,n),I("clipValueMin",e,t,n),I("clipValueMax",e,t,n))];case"Relu6":return[Sh(I("x",e,t,n))];case"Rsqrt":return[Th(Nn(e.inputNames[0],t,n))];case"Prod":return[Ih(I("x",e,t,n),I("axes",e,t,n))];case"LeakyRelu":return[Tc(I("x",e,t,n),I("alpha",e,t,n))];case"Prelu":return[$c(I("x",e,t,n),I("alpha",e,t,n))];case"IsNan":return[pA(Nn(e.inputNames[0],t,n))];default:throw TypeError(`Node type ${e.op} is not implemented`)}};function Ps(e,t,n=""){if(!(typeof e=="number"||typeof t=="number")){w.assert(e.length===t.length,()=>n+` Shapes ${e} and ${t} must match`);for(let s=0;s<e.length;s++){let r=e[s],a=t[s];w.assert(r<0||a<0||r===a,()=>n+` Shapes ${e} and ${t} must match`)}}}function N7(e){return!(typeof e=="number"||e.some(t=>t<0))}function ad(e,t,n){let s=O2(e,n),r=!N7(s);if(r&&t.length===0)throw new Error(`Tried to calculate elements of an empty list with non-fully-defined elementShape: ${s}`);if(r&&t.forEach(a=>{s=O2(a.shape,s)}),!N7(s))throw new Error(`Non-fully-defined elementShape: ${s}`);return s}function O2(e,t){if(typeof e=="number")return t;if(typeof t=="number")return e;if(e.length!==t.length)throw new Error(`Incompatible ranks during merge: ${e} vs. ${t}`);let n=[];for(let s=0;s<e.length;++s){let r=e[s],a=t[s];if(r>=0&&a>=0&&r!==a)throw new Error(`Incompatible shape during merge: ${e} vs. ${t}`);n[s]=r>=0?r:a}return n}var _L=class{constructor(e,t,n,s,r,a,o){this.name=e,this.dtype=t,this.maxSize=n,this.elementShape=s,this.identicalElementShapes=r,this.dynamicSize=a,this.clearAfterRead=o,this.tensors=[],this.closed_=!1,this.idTensor=Ce(0),on(this.idTensor)}get id(){return this.idTensor.id}get closed(){return this.closed_}clearAndClose(e){this.tensors.forEach(t=>{(e==null||!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()}`);let 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(t=>this.read(t))}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}`);let n=this.tensors[e]||{};if(t.dtype!==this.dtype)throw new Error(`TensorArray ${this.name}: Could not write to TensorArray index ${e},
|
|
because the value dtype is ${t.dtype}, but TensorArray dtype is ${this.dtype}.`);if(this.size()===0&&(this.elementShape==null||this.elementShape.length===0)&&(this.elementShape=t.shape),Ps(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,on(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((n,s)=>this.write(n,t[s]))}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 s=0;s<this.size();s++)e.push(s)}if(e.length===0)return an([],[0].concat(this.elementShape));let n=this.readMany(e);return Ps(this.elementShape,n[0].shape,"TensorArray shape mismatch: "),mn(n,0)}concat(e){if(!!e&&e!==this.dtype)throw new Error(`TensorArray dtype is ${this.dtype} but concat requested dtype ${e}`);if(this.size()===0)return an([],[0].concat(this.elementShape));let t=[];for(let s=0;s<this.size();s++)t.push(s);let n=this.readMany(t);return Ps(this.elementShape,n[0].shape,`TensorArray shape mismatch: tensor array shape (${this.elementShape}) vs first tensor shape (${n[0].shape})`),ft(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]}`);let 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,is(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,s=e.map(i=>(n+=i,n));if(n!==t.shape[0])throw new Error(`Expected sum of lengths to be equal to
|
|
tensor.shape[0], but sum of lengths is
|
|
${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`);let r=n===0?0:t.size/n,a=[];H(()=>{t=V(t,[1,n,r]);for(let i=0;i<e.length;++i){let l=i===0?0:s[i-1],u=[0,l,0],c=[1,e[i],r];a[i]=V(_e(t,u,c),this.elementShape)}return a});let o=[];for(let i=0;i<e.length;i++)o[i]=i;this.writeMany(o,a)}},od=class{constructor(e,t,n,s=-1){this.tensors=e,this.elementShape=t,this.elementDtype=n,e!=null&&e.forEach(r=>{if(n!==r.dtype)throw new Error(`Invalid data types; op elements ${n}, but list elements ${r.dtype}`);Ps(t,r.shape,"TensorList shape mismatch: "),on(r)}),this.idTensor=Ce(0),this.maxNumElements=s,on(this.idTensor)}get id(){return this.idTensor.id}copy(){return new od([...this.tensors],this.elementShape,this.elementDtype)}clearAndClose(e){this.tensors.forEach(t=>{(e==null||!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(n!==-1&&this.tensors.length!==n)throw new Error(`Operation expected a list with ${n} elements but got a list with ${this.tensors.length} elements.`);Ps(e,this.elementShape,"TensorList shape mismatch: ");let s=ad(this.elementShape,this.tensors,e);return H(()=>{let r=this.tensors.map(a=>V(a,s));return mn(r,0)})}popBack(e,t){if(t!==this.elementDtype)throw new Error(`Invalid data types; op elements ${t}, but list elements ${this.elementDtype}`);if(this.size()===0)throw new Error("Trying to pop from an empty list.");let n=ad(this.elementShape,this.tensors,e),s=this.tensors.pop();return Ps(s.shape,e,"TensorList shape mismatch: "),V(s,n)}pushBack(e){if(e.dtype!==this.elementDtype)throw new Error(`Invalid data types; op elements ${e.dtype}, but list elements ${this.elementDtype}`);if(Ps(e.shape,this.elementShape,"TensorList shape mismatch: "),this.maxNumElements===this.size())throw new Error("Trying to push element into a full list.");on(e),this.tensors.push(e)}resize(e){if(e<0)throw new Error(`TensorListResize expects size to be non-negative. Got: ${e}`);if(this.maxNumElements!==-1&&e>this.maxNumElements)throw new Error(`TensorListResize input size ${e} is greater maxNumElement ${this.maxNumElements}.`);this.tensors.length=e}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(this.tensors[e]==null)throw new Error(`element at index ${e} is null.`);Ps(this.tensors[e].shape,t,"TensorList shape mismatch: ");let s=ad(this.elementShape,this.tensors,t);return V(this.tensors[e],s)}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||this.maxNumElements!==-1&&e>=this.maxNumElements)throw new Error(`Trying to set element ${e} in a list with max ${this.maxNumElements} elements.`);Ps(this.elementShape,t.shape,"TensorList shape mismatch: "),on(t),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}`);Ps(this.elementShape,n,"TensorList shape mismatch: "),e=e.slice(0,this.size());let s=ad(this.elementShape,this.tensors,n);return e.length===0?an([],[0].concat(s)):H(()=>{let r=e.map(a=>V(this.tensors[a],s));return mn(r,0)})}concat(e,t){if(!!e&&e!==this.elementDtype)throw new Error(`TensorList dtype is ${this.elementDtype} but concat requested dtype ${e}`);Ps(this.elementShape,t,"TensorList shape mismatch: ");let n=ad(this.elementShape,this.tensors,t);return this.size()===0?an([],[0].concat(n)):H(()=>{let s=this.tensors.map(r=>V(r,n));return ft(s,0)})}};function $L(e,t,n){let s=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}`);let r=e.shape.slice(1);Ps(r,t,"TensorList shape mismatch: ");let a=is(e);return new od(a,t,s)}function FL(e,t,n){return new od([],e,t,n)}function OL(e,t,n,s){if(t.length!==e.shape[0])throw new Error(`Expected len(indices) == tensor.shape[0], but saw: ${t.length} vs. ${e.shape[0]}`);let r=Math.max(...t);if(s!=null&&s!==-1&&r>=s)throw new Error(`Max index must be < array size (${r} vs. ${s})`);let a=new od([],n,e.dtype,s),o=is(e,0);return t.forEach((i,l)=>{a.setItem(i,o[l])}),a}function PL(e,t,n){let s=0,r=t.map(c=>(s+=c,s));if(s!==e.shape[0])throw new Error(`Expected sum of lengths to be equal to
|
|
tensor.shape[0], but sum of lengths is
|
|
${s}, and tensor's shape is: ${e.shape}`);let a=e.shape.slice(1),o=O2(a,n),i=s===0?0:e.size/s,l=H(()=>{let c=[];e=V(e,[1,s,i]);for(let d=0;d<t.length;++d){let p=d===0?0:r[d-1],h=[0,p,0],f=[1,t[d],i];c[d]=V(_e(e,h,f),o)}return e.dispose(),c}),u=new od([],n,e.dtype,t.length);for(let c=0;c<l.length;c++)u.setItem(c,l[c]);return u}var ML=async(e,t,n)=>{switch(e.op){case"If":case"StatelessIf":{let s=I("thenBranch",e,t,n),r=I("elseBranch",e,t,n),a=I("cond",e,t,n),o=I("args",e,t,n);return(await a.data())[0]?n.functionMap[s].executeFunctionAsync(o,n.tensorArrayMap,n.tensorListMap):n.functionMap[r].executeFunctionAsync(o,n.tensorArrayMap,n.tensorListMap)}case"While":case"StatelessWhile":{let s=I("body",e,t,n),r=I("cond",e,t,n),a=I("args",e,t,n),o=await n.functionMap[r].executeFunctionAsync(a,n.tensorArrayMap,n.tensorListMap),i=a.map(c=>c.id),l=await o[0].data();o.forEach(c=>{!c.kept&&i.indexOf(c.id)===-1&&c.dispose()});let u=a;for(;l[0];){let c=u;u=await n.functionMap[s].executeFunctionAsync(u,n.tensorArrayMap,n.tensorListMap);let d=u.map(h=>h.id);c.forEach(h=>{!h.kept&&i.indexOf(h.id)===-1&&d.indexOf(h.id)===-1&&h.dispose()});let p=await n.functionMap[r].executeFunctionAsync(u,n.tensorArrayMap,n.tensorListMap);l=await p[0].data(),p.forEach(h=>{!h.kept&&i.indexOf(h.id)===-1&&d.indexOf(h.id)===-1&&h.dispose()})}return u}case"LoopCond":{let s=I("pred",e,t,n);return[Pr(s)]}case"Switch":{let s=I("pred",e,t,n),r=I("data",e,t,n);return r.kept||(r=Pr(r)),(await s.data())[0]?[void 0,r]:[r,void 0]}case"Merge":{let s=e.inputNames.find(r=>Nn(r,t,n)!==void 0);if(s){let r=Nn(s,t,n);return[Pr(r)]}return}case"Enter":{let s=I("frameName",e,t,n),r=I("tensor",e,t,n);return n.enterFrame(s),[Pr(r)]}case"Exit":{let s=I("tensor",e,t,n);return n.exitFrame(),[Pr(s)]}case"NextIteration":{let s=I("tensor",e,t,n);return n.nextIteration(),[Pr(s)]}case"TensorArrayV3":{let s=I("size",e,t,n),r=I("dtype",e,t,n),a=I("elementShape",e,t,n),o=I("dynamicSize",e,t,n),i=I("clearAfterRead",e,t,n),l=I("identicalElementShapes",e,t,n),u=I("name",e,t,n),c=new _L(u,r,s,a,l,o,i);return n.addTensorArray(c),[c.idTensor,Ce(1)]}case"TensorArrayWriteV3":{let s=I("tensorArrayId",e,t,n),r=I("index",e,t,n),a=I("tensor",e,t,n),o=n.getTensorArray(s.id);return o.write(r,a),[o.idTensor]}case"TensorArrayReadV3":{let s=I("tensorArrayId",e,t,n),r=I("index",e,t,n);return[n.getTensorArray(s.id).read(r)]}case"TensorArrayGatherV3":{let s=I("tensorArrayId",e,t,n),r=I("indices",e,t,n),a=I("dtype",e,t,n);return[n.getTensorArray(s.id).gather(r,a)]}case"TensorArrayScatterV3":{let s=I("tensorArrayId",e,t,n),r=I("indices",e,t,n),a=I("tensor",e,t,n),o=n.getTensorArray(s.id);return o.scatter(r,a),[o.idTensor]}case"TensorArrayConcatV3":{let s=I("tensorArrayId",e,t,n),r=n.getTensorArray(s.id),a=I("dtype",e,t,n);return[r.concat(a)]}case"TensorArraySplitV3":{let s=I("tensorArrayId",e,t,n),r=I("tensor",e,t,n),a=I("lengths",e,t,n),o=n.getTensorArray(s.id);return o.split(a,r),[o.idTensor]}case"TensorArraySizeV3":{let s=I("tensorArrayId",e,t,n),r=n.getTensorArray(s.id);return[Ce(r.size(),"int32")]}case"TensorArrayCloseV3":{let s=I("tensorArrayId",e,t,n),r=n.getTensorArray(s.id);return r.clearAndClose(),[r.idTensor]}case"TensorListSetItem":{let s=I("tensorListId",e,t,n),r=I("index",e,t,n),a=I("tensor",e,t,n),o=n.getTensorList(s.id);return o.setItem(r,a),[o.idTensor]}case"TensorListGetItem":{let s=I("tensorListId",e,t,n),r=I("index",e,t,n),a=I("elementShape",e,t,n),o=I("elementDType",e,t,n);return[n.getTensorList(s.id).getItem(r,a,o)]}case"TensorListScatterV2":case"TensorListScatter":{let s=I("indices",e,t,n),r=I("tensor",e,t,n),a=I("elementShape",e,t,n),o=I("numElements",e,t,n),i=OL(r,s,a,o);return n.addTensorList(i),[i.idTensor]}case"TensorListReserve":case"EmptyTensorList":{let s=I("elementShape",e,t,n),r=I("elementDType",e,t,n),a;e.op==="TensorListReserve"?a="numElements":a="maxNumElements";let o=I(a,e,t,n),i=FL(s,r,o);return n.addTensorList(i),[i.idTensor]}case"TensorListGather":{let s=I("tensorListId",e,t,n),r=I("indices",e,t,n),a=I("elementShape",e,t,n),o=I("elementDType",e,t,n);return[n.getTensorList(s.id).gather(r,o,a)]}case"TensorListStack":{let s=I("tensorListId",e,t,n),r=I("elementShape",e,t,n),a=I("elementDType",e,t,n),o=I("numElements",e,t,n);return[n.getTensorList(s.id).stack(r,a,o)]}case"TensorListFromTensor":{let s=I("tensor",e,t,n),r=I("elementShape",e,t,n),a=I("elementDType",e,t,n),o=$L(s,r,a);return n.addTensorList(o),[o.idTensor]}case"TensorListConcat":{let s=I("tensorListId",e,t,n),r=n.getTensorList(s.id),a=I("dtype",e,t,n),o=I("elementShape",e,t,n);return[r.concat(a,o)]}case"TensorListPushBack":{let s=I("tensorListId",e,t,n),r=I("tensor",e,t,n),a=n.getTensorList(s.id);return a.pushBack(r),[a.idTensor]}case"TensorListPopBack":{let s=I("tensorListId",e,t,n),r=I("elementShape",e,t,n),a=I("elementDType",e,t,n);return[n.getTensorList(s.id).popBack(r,a)]}case"TensorListSplit":{let s=I("tensor",e,t,n),r=I("elementShape",e,t,n),a=I("lengths",e,t,n),o=PL(s,a,r);return n.addTensorList(o),[o.idTensor]}default:throw TypeError(`Node type ${e.op} is not implemented`)}};function E7(e,t,n){let[s,r]=I("fusedOps",e,t,n),a=s==="biasadd",o=!a,i=r==="prelu",l=s==="fusedbatchnorm",u=I("numArgs",e,t,n);if(a){if(i&&u!==2)throw new Error("FusedConv2d and DepthwiseConv2d with BiasAdd and Prelu must have two extra arguments: bias and alpha.");if(!i&&a&&u!==1)throw new Error("FusedConv2d and DepthwiseConv2d with BiasAdd must have one extra argument: bias.")}if(l)throw new Error("FusedConv2d and DepthwiseConv2d with FusedBatchNorm is not supported");let c=I("strides",e,t,n),d=Rf(e,t,n),p=I("dataFormat",e,t,n).toUpperCase(),h=I("dilations",e,t,n),[f,m]=I("args",e,t,n);o&&(m=f,f=void 0);let g=I("leakyreluAlpha",e,t,n);return{stride:c,pad:d,dataFormat:p,dilations:h,biasArg:f,preluArg:m,activationFunc:r,leakyreluAlpha:g}}var zL=(e,t,n)=>{switch(e.op){case"Conv1D":{let s=I("stride",e,t,n),r=I("pad",e,t,n),a=I("dataFormat",e,t,n).toUpperCase(),o=I("dilation",e,t,n);return[fh(I("x",e,t,n),I("filter",e,t,n),s,r,a,o)]}case"Conv2D":{let s=I("strides",e,t,n),r=Rf(e,t,n),a=I("dataFormat",e,t,n).toUpperCase(),o=I("dilations",e,t,n);return[Tr(I("x",e,t,n),I("filter",e,t,n),[s[1],s[2]],r,a,[o[1],o[2]])]}case"_FusedConv2D":{let{stride:s,pad:r,dataFormat:a,dilations:o,biasArg:i,preluArg:l,activationFunc:u,leakyreluAlpha:c}=E7(e,t,n);return[da.conv2d({x:I("x",e,t,n),filter:I("filter",e,t,n),strides:[s[1],s[2]],pad:r,dataFormat:a,dilations:[o[1],o[2]],bias:i,activation:u,preluActivationWeights:l,leakyreluAlpha:c})]}case"FusedDepthwiseConv2dNative":{let{stride:s,pad:r,dataFormat:a,dilations:o,biasArg:i,preluArg:l,activationFunc:u,leakyreluAlpha:c}=E7(e,t,n);return[da.depthwiseConv2d({x:I("x",e,t,n),filter:I("filter",e,t,n),strides:[s[1],s[2]],pad:r,dataFormat:a,dilations:[o[1],o[2]],bias:i,activation:u,preluActivationWeights:l,leakyreluAlpha:c})]}case"Conv2DBackpropInput":case"Conv2dTranspose":{let s=I("outputShape",e,t,n),r=I("strides",e,t,n),a=Rf(e,t,n);return[mh(I("x",e,t,n),I("filter",e,t,n),s,[r[1],r[2]],a)]}case"DepthwiseConv2dNative":case"DepthwiseConv2d":{let s=I("strides",e,t,n),r=Rf(e,t,n),a=I("dilations",e,t,n),o=I("dataFormat",e,t,n).toUpperCase();return[jl(I("input",e,t,n),I("filter",e,t,n),[s[1],s[2]],r,o,[a[1],a[2]])]}case"Conv3D":{let s=I("strides",e,t,n),r=I("pad",e,t,n),a=I("dataFormat",e,t,n).toUpperCase(),o=I("dilations",e,t,n);return[aA(I("x",e,t,n),I("filter",e,t,n),[s[1],s[2],s[3]],r,a,[o[1],o[2],o[3]])]}case"AvgPool":{let s=I("strides",e,t,n),r=I("pad",e,t,n),a=I("kernelSize",e,t,n);return[Ic(I("x",e,t,n),[a[1],a[2]],[s[1],s[2]],r)]}case"MaxPool":{let s=I("strides",e,t,n),r=I("pad",e,t,n),a=I("kernelSize",e,t,n);return[Rc(I("x",e,t,n),[a[1],a[2]],[s[1],s[2]],r)]}case"MaxPoolWithArgmax":{let s=I("strides",e,t,n),r=I("pad",e,t,n),a=I("kernelSize",e,t,n),o=I("includeBatchInIndex",e,t,n),{result:i,indexes:l}=Mb(I("x",e,t,n),[a[1],a[2]],[s[1],s[2]],r,o);return[i,l]}case"AvgPool3D":{let s=I("strides",e,t,n),r=I("pad",e,t,n),a=I("kernelSize",e,t,n);return[tA(I("x",e,t,n),[a[1],a[2],a[3]],[s[1],s[2],s[3]],r)]}case"MaxPool3D":{let s=I("strides",e,t,n),r=I("pad",e,t,n),a=I("kernelSize",e,t,n);return[AA(I("x",e,t,n),[a[1],a[2],a[3]],[s[1],s[2],s[3]],r)]}case"Dilation2D":{let s=I("strides",e,t,n),r=I("pad",e,t,n),a=I("dilations",e,t,n),o=s[1],i=s[2],l=a[1],u=a[2];return[iA(I("x",e,t,n),I("filter",e,t,n),[o,i],r,[l,u],"NHWC")]}default:throw TypeError(`Node type ${e.op} is not implemented`)}},LL=(e,t,n)=>{switch(e.op){case"Fill":{let s=I("shape",e,t,n),r=I("dtype",e,t,n),a=I("value",e,t,n);return[Xl(s,a,r)]}case"LinSpace":{let s=I("start",e,t,n),r=I("stop",e,t,n),a=I("num",e,t,n);return[Rb(s,r,a)]}case"Multinomial":{let s=I("logits",e,t,n),r=I("numSamples",e,t,n),a=I("seed",e,t,n);return[zb(s,r,a)]}case"OneHot":{let s=I("indices",e,t,n),r=I("depth",e,t,n),a=I("onValue",e,t,n),o=I("offValue",e,t,n);return[Bl(s,r,a,o)]}case"Ones":return[rs(I("shape",e,t,n),I("dtype",e,t,n))];case"OnesLike":return[as(I("x",e,t,n))];case"RandomUniform":return[Yl(I("shape",e,t,n),I("minval",e,t,n),I("maxval",e,t,n),I("dtype",e,t,n))];case"Range":{let s=I("start",e,t,n),r=I("stop",e,t,n),a=I("step",e,t,n);return[Jl(s,r,a,I("dtype",e,t,n))]}case"TruncatedNormal":{let s=I("shape",e,t,n),r=I("mean",e,t,n),a=I("stdDev",e,t,n),o=I("seed",e,t,n);return[Oh(s,r,a,I("dtype",e,t,n),o)]}case"Zeros":return[Mt(I("shape",e,t,n),I("dtype",e,t,n))];case"ZerosLike":return[Je(I("x",e,t,n))];default:throw TypeError(`Node type ${e.op} is not implemented`)}};function P2(e,t,n){let s=I("boxes",e,t,n),r=I("scores",e,t,n),a=I("maxOutputSize",e,t,n),o=I("iouThreshold",e,t,n),i=I("scoreThreshold",e,t,n),l=I("softNmsSigma",e,t,n);return{boxes:s,scores:r,maxOutputSize:a,iouThreshold:o,scoreThreshold:i,softNmsSigma:l}}var BL=async(e,t,n)=>{switch(e.op){case"NonMaxSuppressionV5":{let{boxes:s,scores:r,maxOutputSize:a,iouThreshold:o,scoreThreshold:i,softNmsSigma:l}=P2(e,t,n),u=await $e.nonMaxSuppressionWithScoreAsync(s,r,a,o,i,l);return[u.selectedIndices,u.selectedScores]}case"NonMaxSuppressionV4":{let{boxes:s,scores:r,maxOutputSize:a,iouThreshold:o,scoreThreshold:i}=P2(e,t,n),l=I("padToMaxOutputSize",e,t,n),u=await $e.nonMaxSuppressionPaddedAsync(s,r,a,o,i,l);return[u.selectedIndices,u.validOutputs]}case"NonMaxSuppressionV3":case"NonMaxSuppressionV2":{let{boxes:s,scores:r,maxOutputSize:a,iouThreshold:o,scoreThreshold:i}=P2(e,t,n);return[await $e.nonMaxSuppressionAsync(s,r,a,o,i)]}case"Where":{let s=pe(I("condition",e,t,n),"bool"),r=[await RA(s)];return s.dispose(),r}case"ListDiff":return Wb(I("x",e,t,n),I("y",e,t,n));default:throw TypeError(`Node type ${e.op} is not implemented`)}},WL=(e,t,n)=>{switch(e.op){case"TopKV2":{let s=I("x",e,t,n),r=I("k",e,t,n),a=I("sorted",e,t,n),o=NA(s,r,a);return[o.values,o.indices]}case"Unique":{let s=I("x",e,t,n),r=Ph(s);return[r.values,r.indices]}case"UniqueV2":{let s=I("x",e,t,n),r=I("axis",e,t,n),a=Ph(s,r);return[a.values,a.indices]}default:throw TypeError(`Node type ${e.op} is not implemented`)}},VL=(e,t,n)=>{switch(e.op){case"Const":return t[e.name];case"PlaceholderWithDefault":let s=I("default",e,t,n);return[Nn(e.name,t,n)||s];case"Placeholder":return[Nn(e.name,t,n)];case"Identity":case"StopGradient":case"FakeQuantWithMinMaxVars":{let u=I("x",e,t,n);return[Pr(u)]}case"IdentityN":return I("x",e,t,n).map(u=>Pr(u));case"Snapshot":let r=I("x",e,t,n);return[Pr(r)];case"Shape":return[Ut(I("x",e,t,n).shape,"int32")];case"ShapeN":return I("x",e,t,n).map(u=>Ut(u.shape));case"Size":return[Ce(I("x",e,t,n).size,"int32")];case"Rank":return[Ce(I("x",e,t,n).rank,"int32")];case"NoOp":return[Ce(1)];case"Print":let a=I("x",e,t,n),o=I("data",e,t,n),i=I("message",e,t,n),l=I("summarize",e,t,n);console.warn("The graph has a tf.print() operation,usually used for debugging, which slows down performance."),console.log(i);for(let u=0;u<o.length;u++)console.log(Array.prototype.slice.call(o[u].dataSync()).slice(0,l));return[a];default:throw TypeError(`Node type ${e.op} is not implemented`)}},UL=class{constructor(e,t){this.keyDType=e,this.valueDType=t,this.handle=Ce(0),this.tensorMap=new Map,on(this.handle)}get id(){return this.handle.id}clearAndClose(){this.tensorMap.forEach(e=>e.dispose()),this.tensorMap.clear(),this.handle.dispose()}size(){return this.tensorMap.size}tensorSize(){return Ce(this.size(),"int32")}async import(e,t){this.checkKeyAndValueTensor(e,t);let n=await e.data();return this.tensorMap.forEach(s=>s.dispose()),this.tensorMap.clear(),H(()=>{let s=is(t),r=n.length,a=s.length;w.assert(r===a,()=>`The number of elements doesn't match, keys has ${r} elements, the values has ${a} elements.`);for(let o=0;o<r;o++){let i=n[o],l=s[o];on(l),this.tensorMap.set(i,l)}return this.handle})}async find(e,t){this.checkKeyAndValueTensor(e,t);let n=await e.data();return H(()=>{let s=[];for(let r=0;r<n.length;r++){let a=n[r],o=this.findWithDefault(a,t);s.push(o)}return mn(s)})}findWithDefault(e,t){let n=this.tensorMap.get(e);return n!=null?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}`)}},HL=async(e,t,n,s)=>{switch(e.op){case"HashTable":case"HashTableV2":{let r=I("keyDType",e,t,n),a=I("valueDType",e,t,n),o=new UL(r,a);return s.addHashTable(e.name,o),[o.handle]}case"LookupTableImport":case"LookupTableImportV2":{let r=I("tableHandle",e,t,n,s),a=I("keys",e,t,n),o=I("values",e,t,n);return[await s.getHashTableById(r.id).import(a,o)]}case"LookupTableFind":case"LookupTableFindV2":{let r=I("tableHandle",e,t,n,s),a=I("keys",e,t,n),o=I("defaultValue",e,t,n);return[await s.getHashTableById(r.id).find(a,o)]}case"LookupTableSize":case"LookupTableSizeV2":{let r=I("tableHandle",e,t,n,s);return[s.getHashTableById(r.id).tensorSize()]}default:throw TypeError(`Node type ${e.op} is not implemented`)}},GL=(e,t,n)=>{switch(e.op){case"ResizeBilinear":{let s=I("images",e,t,n),r=I("size",e,t,n),a=I("alignCorners",e,t,n),o=I("halfPixelCenters",e,t,n);return[$e.resizeBilinear(s,[r[0],r[1]],a,o)]}case"ResizeNearestNeighbor":{let s=I("images",e,t,n),r=I("size",e,t,n),a=I("alignCorners",e,t,n),o=I("halfPixelCenters",e,t,n);return[$e.resizeNearestNeighbor(s,[r[0],r[1]],a,o)]}case"CropAndResize":{let s=I("image",e,t,n),r=I("boxes",e,t,n),a=I("boxInd",e,t,n),o=I("cropSize",e,t,n),i=I("method",e,t,n),l=I("extrapolationValue",e,t,n);return[$e.cropAndResize(s,r,a,o,i,l)]}default:throw TypeError(`Node type ${e.op} is not implemented`)}},jL=(e,t,n)=>{switch(e.op){case"Equal":return[es(I("a",e,t,n),I("b",e,t,n))];case"NotEqual":return[qo(I("a",e,t,n),I("b",e,t,n))];case"Greater":return[Vn(I("a",e,t,n),I("b",e,t,n))];case"GreaterEqual":return[ua(I("a",e,t,n),I("b",e,t,n))];case"Less":return[xh(I("a",e,t,n),I("b",e,t,n))];case"LessEqual":return[ca(I("a",e,t,n),I("b",e,t,n))];case"LogicalAnd":return[_s(I("a",e,t,n),I("b",e,t,n))];case"LogicalNot":return[Ec(I("a",e,t,n))];case"LogicalOr":return[wh(I("a",e,t,n),I("b",e,t,n))];case"Select":case"SelectV2":return[vn(I("condition",e,t,n),I("a",e,t,n),I("b",e,t,n))];default:throw TypeError(`Node type ${e.op} is not implemented`)}},qL=(e,t,n)=>{switch(e.op){case"BatchMatMul":case"BatchMatMulV2":case"MatMul":return[Ue(I("a",e,t,n),I("b",e,t,n),I("transposeA",e,t,n),I("transposeB",e,t,n))];case"Einsum":return[Tb(I("equation",e,t,n),...I("tensors",e,t,n))];case"Transpose":return[Ye(I("x",e,t,n),I("perm",e,t,n))];case"_FusedMatMul":let[s,r]=I("fusedOps",e,t,n),a=s==="biasadd",o=r==="prelu",i=I("numArgs",e,t,n),l=I("leakyreluAlpha",e,t,n);if(a){if(o&&i!==2)throw new Error("Fused MatMul with BiasAdd and Prelu must have two extra arguments: bias and alpha.");if(!o&&i!==1)throw new Error("Fused MatMul with BiasAdd must have one extra argument: bias.")}let[u,c]=I("args",e,t,n);return[da.matMul({a:I("a",e,t,n),b:I("b",e,t,n),transposeA:I("transposeA",e,t,n),transposeB:I("transposeB",e,t,n),bias:u,activation:r,preluActivationWeights:c,leakyreluAlpha:l})];default:throw TypeError(`Node type ${e.op} is not implemented`)}},XL=(e,t,n)=>{switch(e.op){case"FusedBatchNorm":case"FusedBatchNormV2":return[Uo(I("x",e,t,n),I("mean",e,t,n),I("variance",e,t,n),I("offset",e,t,n),I("scale",e,t,n),I("epsilon",e,t,n))];case"FusedBatchNormV3":return[Uo(I("x",e,t,n),I("mean",e,t,n),I("variance",e,t,n),I("offset",e,t,n),I("scale",e,t,n),I("epsilon",e,t,n))];case"LRN":return[hA(I("x",e,t,n),I("radius",e,t,n),I("bias",e,t,n),I("alpha",e,t,n),I("beta",e,t,n))];case"Softmax":return[Pc(I("x",e,t,n))];case"LogSoftmax":return[vh(I("x",e,t,n))];case"SparseToDense":return[DA(I("sparseIndices",e,t,n),I("outputShape",e,t,n),I("sparseValues",e,t,n),I("defaultValue",e,t,n))];default:throw TypeError(`Node type ${e.op} is not implemented`)}},KL=(e,t,n)=>{switch(e.op){case"Max":{let o=I("axis",e,t,n),i=I("keepDims",e,t,n);return[ss(I("x",e,t,n),o,i)]}case"Mean":{let o=I("axis",e,t,n),i=I("keepDims",e,t,n);return[Dt(I("x",e,t,n),o,i)]}case"Min":{let o=I("axis",e,t,n),i=I("keepDims",e,t,n);return[Dc(I("x",e,t,n),o,i)]}case"Sum":{let o=I("axis",e,t,n),i=I("keepDims",e,t,n);return[we(I("x",e,t,n),o,i)]}case"All":{let o=I("axis",e,t,n),i=I("keepDims",e,t,n);return[ph(I("x",e,t,n),o,i)]}case"Any":{let o=I("axis",e,t,n),i=I("keepDims",e,t,n);return[wc(I("x",e,t,n),o,i)]}case"ArgMax":{let o=I("axis",e,t,n);return[Ws(I("x",e,t,n),o)]}case"ArgMin":{let o=I("axis",e,t,n);return[qg(I("x",e,t,n),o)]}case"Prod":{let o=I("axis",e,t,n),i=I("keepDims",e,t,n);return[Ih(I("x",e,t,n),o,i)]}case"Cumsum":{let o=I("axis",e,t,n),i=I("exclusive",e,t,n),l=I("reverse",e,t,n);return[Ah(I("x",e,t,n),o,i,l)]}case"Bincount":let s=I("x",e,t,n),r=I("weights",e,t,n),a=I("size",e,t,n);return[nA(s,r,a)];case"DenseBincount":{let o=I("x",e,t,n),i=I("weights",e,t,n),l=I("size",e,t,n),u=I("binaryOutput",e,t,n);return[Sb(o,i,l,u)]}default:throw TypeError(`Node type ${e.op} is not implemented`)}},ZL=(e,t,n)=>{switch(e.op){case"ConcatV2":case"Concat":{let s=I("n",e,t,n),r=I("axis",e,t,n),a=I("tensors",e,t,n);return a=a.slice(0,s),[ft(a,r)]}case"Gather":{let s=I("x",e,t,n),r=I("indices",e,t,n);return[Ho(s,pe(r,"int32"),0)]}case"GatherV2":{let s=I("axis",e,t,n),r=I("batchDims",e,t,n),a=I("x",e,t,n),o=I("indices",e,t,n);return[Ho(a,pe(o,"int32"),s,r)]}case"Reverse":{let s=I("dims",e,t,n),r=[];for(let o=0;o<s.length;o++)s[o]&&r.push(o);let a=I("x",e,t,n);return[os(a,r)]}case"ReverseV2":{let s=I("axis",e,t,n),r=I("x",e,t,n);return[os(r,s)]}case"Slice":{let s=I("begin",e,t,n),r=I("size",e,t,n);return[_e(I("x",e,t,n),s,r)]}case"StridedSlice":{let s=I("begin",e,t,n),r=I("end",e,t,n),a=I("strides",e,t,n),o=I("beginMask",e,t,n),i=I("endMask",e,t,n),l=I("ellipsisMask",e,t,n),u=I("newAxisMask",e,t,n),c=I("shrinkAxisMask",e,t,n),d=I("x",e,t,n);return[CA(d,s,r,a,o,i,l,u,c)]}case"Pack":return H(()=>{let s=I("axis",e,t,n),r=I("tensors",e,t,n),a=r[0].shape,o=lt(r[0]).shape,i=r.map(l=>{let u=w.arraysEqual(l.shape,a);if(!u&&!w.arraysEqual(lt(l).shape,o))throw new Error("the input tensors shape does not match");return u?l:V(l,a)});return[mn(i,s)]});case"Unpack":{let s=I("axis",e,t,n),r=I("tensor",e,t,n);return is(r,s)}case"Tile":{let s=I("reps",e,t,n);return[bs(I("x",e,t,n),s)]}case"Split":case"SplitV":{let s=I("axis",e,t,n),r=I("numOrSizeSplits",e,t,n),a=I("x",e,t,n);return Vt(a,r,s)}case"ScatterNd":{let s=I("indices",e,t,n),r=I("values",e,t,n),a=I("shape",e,t,n);return[Gb(s,r,a)]}case"GatherNd":{let s=I("x",e,t,n),r=I("indices",e,t,n);return[jb(s,r)]}case"SparseToDense":{let s=I("sparseIndices",e,t,n),r=I("outputShape",e,t,n),a=I("sparseValues",e,t,n),o=I("defaultValue",e,t,n);return[DA(s,a,r,a.dtype===o.dtype?o:pe(o,a.dtype))]}default:throw TypeError(`Node type ${e.op} is not implemented`)}},YL=(e,t,n)=>{switch(e.op){case"SparseFillEmptyRows":{let{outputIndices:s,outputValues:r,emptyRowIndicator:a,reverseIndexMap:o}=Lc.sparseFillEmptyRows(I("indices",e,t,n),I("values",e,t,n),I("denseShape",e,t,n),I("defaultValue",e,t,n));return[s,r,a,o]}case"SparseReshape":{let{outputIndices:s,outputShape:r}=Lc.sparseReshape(I("inputIndices",e,t,n),I("inputShape",e,t,n),I("newShape",e,t,n));return[s,r]}case"SparseSegmentMean":return[Lc.sparseSegmentMean(I("data",e,t,n),I("indices",e,t,n),I("segmentIds",e,t,n))];case"SparseSegmentSum":return[Lc.sparseSegmentSum(I("data",e,t,n),I("indices",e,t,n),I("segmentIds",e,t,n))];default:throw TypeError(`Node type ${e.op} is not implemented`)}},JL=(e,t,n)=>{switch(e.op){case"FFT":return[Mc(I("x",e,t,n))];case"IFFT":return[Ql(I("x",e,t,n))];case"RFFT":return[zc(I("x",e,t,n))];case"IRFFT":return[$h(I("x",e,t,n))];default:throw TypeError(`Node type ${e.op} is not implemented`)}},QL=(e,t,n)=>{switch(e.op){case"StringNGrams":{let{nGrams:s,nGramsSplits:r}=Vh.stringNGrams(I("data",e,t,n),I("dataSplits",e,t,n),I("separator",e,t,n),I("nGramWidths",e,t,n),I("leftPad",e,t,n),I("rightPad",e,t,n),I("padWidth",e,t,n),I("preserveShortSequences",e,t,n));return[s,r]}case"StringSplit":{let{indices:s,values:r,shape:a}=Vh.stringSplit(I("input",e,t,n),I("delimiter",e,t,n),I("skipEmpty",e,t,n));return[s,r,a]}case"StringToHashBucketFast":return[Vh.stringToHashBucketFast(I("input",e,t,n),I("numBuckets",e,t,n))];default:throw TypeError(`Node type ${e.op} is not implemented`)}},eB=(e,t,n)=>{switch(e.op){case"Cast":return[pe(I("x",e,t,n),I("dtype",e,t,n))];case"ExpandDims":{let s=I("axis",e,t,n);return[Lt(I("x",e,t,n),s)]}case"Squeeze":{let s=I("axis",e,t,n);return[lt(I("x",e,t,n),s)]}case"Reshape":return[V(I("x",e,t,n),I("shape",e,t,n))];case"MirrorPad":return[yA(I("x",e,t,n),I("padding",e,t,n),I("mode",e,t,n))];case"PadV2":case"Pad":return[Nr(I("x",e,t,n),I("padding",e,t,n),I("constantValue",e,t,n))];case"SpaceToBatchND":{let s=I("blockShape",e,t,n),r=I("paddings",e,t,n);return[_c(I("x",e,t,n),s,r)]}case"BatchToSpaceND":{let s=I("blockShape",e,t,n),r=I("crops",e,t,n);return[Sc(I("x",e,t,n),s,r)]}case"DepthToSpace":{let s=I("blockSize",e,t,n),r=I("dataFormat",e,t,n).toUpperCase();return[oA(I("x",e,t,n),s,r)]}case"BroadcastTo":return[Hl(I("x",e,t,n),I("shape",e,t,n))];case"BroadcastArgs":return[xb(I("s0",e,t,n),I("s1",e,t,n))];default:throw TypeError(`Node type ${e.op} is not implemented`)}};function R7(e,t,n,s){let r=((a,o,i)=>{switch(a.category){case"arithmetic":return H(()=>RL(a,o,i));case"basic_math":return H(()=>DL(a,o,i));case"control":return ML(a,o,i);case"convolution":return H(()=>zL(a,o,i));case"creation":return H(()=>LL(a,o,i));case"dynamic":return BL(a,o,i);case"evaluation":return H(()=>WL(a,o,i));case"image":return H(()=>GL(a,o,i));case"graph":return H(()=>VL(a,o,i));case"logical":return H(()=>jL(a,o,i));case"matrices":return H(()=>qL(a,o,i));case"normalization":return H(()=>XL(a,o,i));case"reduction":return H(()=>KL(a,o,i));case"slice_join":return H(()=>ZL(a,o,i));case"sparse":return H(()=>YL(a,o,i));case"spectral":return H(()=>JL(a,o,i));case"string":return H(()=>QL(a,o,i));case"transformation":return H(()=>eB(a,o,i));case"hash_table":return HL(a,o,i,s);case"custom":let l=r7(a.op);if(l&&l.customExecutor)return l.customExecutor(new EL(a,o,i));throw TypeError(`Custom op ${a.op} is not registered.`);default:throw TypeError(`Unknown op '${a.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 w.isPromise(r)?r.then(a=>[].concat(a)):[].concat(r)}var D7=class{constructor(e={},t={},n={},s={}){this.weightMap=e,this.tensorArrayMap=t,this.tensorListMap=n,this.functionMap=s,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(){let e=[];for(let t=0;t<this.contexts.length-1;t++){let 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(t=>t.id===0&&t.iterationId===0?"":`${t.frameName}-${t.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)this.contexts=this.contexts.slice(),this.contexts.splice(-1),this.currentContextIds.shift();else throw new Error("Cannot exit frame, the context is empty")}nextIteration(){if(this.contexts&&this.contexts.length>0){this.contexts=this.contexts.slice(),this.lastId++;let 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))}else throw new Error("Cannot increase frame iteration, the context is empty")}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(let t in this.tensorArrayMap)this.tensorArrayMap[t].clearAndClose(e);for(let t in this.tensorListMap)this.tensorListMap[t].clearAndClose(e)}};function _7(e,t,n,s){let r=new Set,a=[],o=null,i=null,l=new Set,u=Object.keys(e).map(p=>ls(p)[0]),c=[];s!=null&&(c=s.map(p=>ls(p.name)[0]));let d=[...t];for(;d.length>0;){let p=d.pop();if(($7(p)||aB(p)||oB(p))&&o==null&&(o=p,i=o.children.map(h=>h.name).filter(h=>r.has(h))),r.add(p.name),n[p.name]==null&&u.indexOf(p.name)===-1&&c.indexOf(p.name)===-1){if(p.inputs.length===0){a.push(p.name);continue}p.inputs.forEach(h=>{l.has(h.name)||(l.add(h.name),d.push(h))})}}return{inputs:e,outputs:t,usedNodes:r,missingInputs:a,dynamicNode:o,syncInputs:i}}function tB(e,t,n){let{usedNodes:s,inputs:r}=n,a=[],o=Object.keys(r).map(c=>ls(c)[0]).map(c=>e.nodes[c]),i=e.initNodes;o.forEach(c=>{s.has(c.name)&&a.push(c)}),e.weights.forEach(c=>{s.has(c.name)&&a.push(c)}),i!=null&&i.forEach(c=>{s.has(c.name)&&a.push(c)});let l=new Set,u=[];for(;a.length>0;){let c=a.pop();l.add(c.name),t[c.name]||u.push(c),c.children.forEach(d=>{!l.has(d.name)&&s.has(d.name)&&d.inputs.every(p=>l.has(p.name))&&a.push(d)})}return u}var nB=["Switch","Merge","Enter","Exit","NextIteration","StatelessIf","StatelessWhile","if","While"],sB=["NonMaxSuppressionV2","NonMaxSuppressionV3","NonMaxSuppressionV5","Where"],rB=["HashTable","HashTableV2","LookupTableImport","LookupTableImportV2","LookupTableFind","LookupTableFindV2","LookupTableSize","LookupTableSizeV2"];function $7(e){return nB.indexOf(e.op)>=0}function aB(e){return sB.indexOf(e.op)>=0}function oB(e){return rB.indexOf(e.op)>=0}var M2=class{constructor(e,t){this.graph=e,this.parent=t,this.compiledMap=new Map,this._weightMap={},this.SEPERATOR=",",this._functions={},this._functionExecutorMap={},this._outputs=e.outputs,this._inputs=e.inputs,this._initNodes=e.initNodes,this._signature=e.signature,this._functions=e.functions,e.functions!=null&&Object.keys(e.functions).forEach(n=>{this._functionExecutorMap[n]=new M2(e.functions[n],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){let t=Object.keys(e).map(n=>e[n].map(s=>s.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=>{let 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){let n=e.map(r=>r.name).sort(),s=t.map(r=>r.name).sort();return n.join(this.SEPERATOR)+"--"+s.join(this.SEPERATOR)}compile(e,t){let n=_7(e,t,this.weightMap,this._initNodes),{missingInputs:s,dynamicNode:r,syncInputs:a}=n;if(r!=null)throw new Error(`This execution contains the node '${r.name}', which has the dynamic op '${r.op}'. Please use model.executeAsync() instead. Alternatively, to avoid the dynamic ops, specify the inputs [${a}]`);if(s.length>0){let o=t.map(l=>l.name),i=Object.keys(e);throw new Error(`Cannot compute the outputs [${o}] from the provided inputs [${i}]. Missing the following inputs: [${s}]`)}return tB(this.graph,this.weightMap,n)}execute(e,t){e=this.mapInputs(e);let n=Object.keys(e).sort();this.checkInputs(e),this.checkInputShapeAndType(e),t=this.mapOutputs(t),this.checkOutputs(t);let s=n.map(c=>this.graph.nodes[ls(c)[0]]),r=t.map(c=>ls(c)[0]),a=r.map(c=>this.graph.nodes[c]);a.length===0&&(a=this._outputs);let o=this.getCompilationKey(s,a),i=this.compiledMap.get(o);i==null&&(i=this.compile(e,a),this.compiledMap.set(o,i));let l={},u={};return H(()=>{let c=new D7(this.weightMap,l,u,this.functionExecutorMap),d=Object.assign({},this.weightMap);Object.keys(e).forEach(f=>{let[m,g]=ls(f),A=[];A[g]=e[f],d[m]=A});let p=this.getFrozenTensorIds(d),h={};for(let f=0;f<i.length;f++){let m=i[f];if(!d[m.name]){let g=R7(m,d,c,this._resourceManager);if(w.isPromise(g))throw new Error(`The execution of the op '${m.op}' returned a promise. Please use model.executeAsync() instead.`);d[m.name]=g,this.checkTensorForDisposal(m.name,m,d,c,p,r,h)}}return this.parent==null&&c.dispose(p),t.map(f=>Nn(f,d,c))})}getFrozenTensorIds(e){let t=[].concat.apply([],Object.keys(e).map(n=>e[n]).map(n=>n.map(s=>s.id)));return new Set(t)}checkTensorForDisposal(e,t,n,s,r,a,o){t.category==="control"||a.indexOf(e)!==-1||(n[e].forEach(i=>{i!=null&&(o[i.id]=(o[i.id]||0)+t.children.length)}),t.inputs.forEach(i=>{if(i.category!=="control"){let l=lL(i.name,n,s);l!=null&&l.forEach(u=>{if(u&&!u.kept&&!r.has(u.id)){let c=o[u.id];c===1?(u.dispose(),delete o[u.id]):c!=null&&o[u.id]--}})}}))}async executeAsync(e,t){return this._executeAsync(e,t)}async _executeAsync(e,t,n=!1,s={},r={}){n||(e=this.mapInputs(e),this.checkInputs(e),this.checkInputShapeAndType(e),t=this.mapOutputs(t),this.checkOutputs(t));let a=new D7(this.weightMap,s,r,this.functionExecutorMap),o=await this.executeWithControlFlow(e,a,t,n),i=t.map(d=>Nn(d,o,a)),l=i.map(d=>d.id),u=Object.keys(e).map(d=>e[d].id),c=new Set([...l,...u,...this.weightIds]);return Object.keys(o).forEach(d=>{o[d].forEach(h=>{h&&!h.kept&&!h.isDisposed&&!c.has(h.id)&&h.dispose()})}),this.parent==null&&a.dispose(c),i}async executeFunctionAsync(e,t,n){let s=e.reduce((r,a,o)=>(r[this.inputs[o].name]=a,r),{});return this._executeAsync(s,this.outputNodes,!0,t,n)}async executeWithControlFlow(e,t,n,s){let r=Object.keys(e),a=r.map(y=>this.graph.nodes[ls(y)[0]]),o=n.map(y=>ls(y)[0]),i=o.map(y=>this.graph.nodes[y]);i.length===0&&(i=this._outputs);let{usedNodes:l,missingInputs:u,dynamicNode:c,syncInputs:d}=_7(e,i,this.weightMap,this._initNodes),p=[...a,...this.graph.weights,...this._initNodes||[]].map(y=>({node:y,contexts:t.currentContext})),h=Object.assign({},this.weightMap);Object.keys(e).forEach(y=>{let[x,b]=ls(y),v=[];v[b]=e[y],h[x]=v});let f={},m=this.getFrozenTensorIds(h),g={};for(;p.length>0;){let y=this.processStack(a,p,t,h,g,m,o,f,l);await Promise.all(y)}c==null&&!s&&console.warn("This model execution did not contain any nodes with control flow or dynamic output shapes. You can use model.execute() instead.");let A=i.filter(y=>!$7(y)&&!Nn(y.name,h,t)).map(y=>y.name);if(A.length>0){let y="";throw c!=null&&(y=`Alternatively, to avoid the dynamic ops, use model.execute() and specify the inputs [${d}]`),new Error(`Cannot compute the outputs [${A}] from the provided inputs [${r}]. Consider providing the following inputs: [${u}]. ${y}`)}return h}processStack(e,t,n,s,r,a,o,i,l){let u=[];for(;t.length>0;){let c=t.pop();n.currentContext=c.contexts;let d="";if(c.node.op==="Enter"&&I("isConstant",c.node,s,n)&&([d]=Or(c.node.name,n)),s[c.node.name]==null){let p=R7(c.node,s,n,this._resourceManager);d||([d]=Or(c.node.name,n));let h=n.currentContext;w.isPromise(p)?u.push(p.then(f=>(s[d]=f,n.currentContext=h,this.checkTensorForDisposal(d,c.node,s,n,a,o,i),this.processChildNodes(c.node,t,n,s,r,l),f))):(s[d]=p,this.checkTensorForDisposal(d,c.node,s,n,a,o,i),this.processChildNodes(c.node,t,n,s,r,l))}else this.processChildNodes(c.node,t,n,s,r,l)}return u}processChildNodes(e,t,n,s,r,a){e.children.forEach(o=>{let[i]=Or(o.name,n);r[i]||!a.has(o.name)||(o.op==="Merge"?o.inputNames.some(l=>!!Nn(l,s,n))&&(r[i]=!0,t.push({contexts:n.currentContext,node:o})):o.inputNames.every(l=>!!Nn(l,s,n))&&(r[i]=!0,t.push({contexts:n.currentContext,node:o})))})}dispose(){Object.keys(this.weightMap).forEach(e=>this.weightMap[e].forEach(t=>t.dispose()))}checkInputShapeAndType(e){Object.keys(e).forEach(t=>{let n=e[t],[s]=ls(t),r=this.graph.nodes[s];if(r.attrParams.shape&&r.attrParams.shape.value){let a=r.attrParams.shape.value,o=a.length===n.shape.length&&n.shape.every((i,l)=>a[l]===-1||a[l]===i);w.assert(o,()=>`The shape of dict['${r.name}'] provided in model.execute(dict) must be [${a}], but was [${n.shape}]`)}r.attrParams.dtype&&r.attrParams.dtype.value&&w.assert(n.dtype===r.attrParams.dtype.value,()=>`The dtype of dict['${r.name}'] provided in model.execute(dict) must be ${r.attrParams.dtype.value}, but was ${n.dtype}`)})}mapInputs(e){let t={};for(let n in e)if(this._signature!=null&&this._signature.inputs!=null&&this._signature.inputs[n]!=null){let s=this._signature.inputs[n];t[s.name]=e[n]}else t[n]=e[n];return t}checkInputs(e){let t=Object.keys(e).filter(n=>{let[s]=ls(n);return this.graph.nodes[s]==null});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(t=>this._signature!=null&&this._signature.outputs!=null&&this._signature.outputs[t]!=null?this._signature.outputs[t].name:t,{})}checkOutputs(e){e.forEach(t=>{let[n]=ls(t);if(!this.graph.nodes[n])throw new Error(`The output '${t}' is not found in the graph`)})}},iB=class{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(let e in this.hashTableMap)this.hashTableMap[e].clearAndClose(),delete this.hashTableMap[e];for(let e in this.hashTableNameToHandle)this.hashTableNameToHandle[e].dispose(),delete this.hashTableNameToHandle[e]}},lB="?tfjs-format=file",uB="model.json",F7=class{constructor(e,t={}){this.modelUrl=e,this.loadOptions=t,this.version="n/a",t==null&&(this.loadOptions={}),this.resourceManager=new iB}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}findIOHandler(){let e=this.modelUrl;if(e.load!=null)this.handler=e;else if(this.loadOptions.requestInit!=null)this.handler=Ln.browserHTTPRequest(e,this.loadOptions);else{let t=Ln.getLoadHandlers(e,this.loadOptions);if(t.length===0)t.push(Ln.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]}}async load(){if(this.findIOHandler(),this.handler.load==null)throw new Error("Cannot proceed with model loading because the IOHandler provided does not have the `load` method implemented.");let e=await this.handler.load();return this.loadSync(e)}loadSync(e){this.artifacts=e;let t=this.artifacts.modelTopology,n;this.artifacts.userDefinedMetadata!=null&&this.artifacts.userDefinedMetadata.signature!=null?n=this.artifacts.userDefinedMetadata.signature:n=this.artifacts.signature,this.signature=n,this.version=`${t.versions.producer}.${t.versions.minConsumer}`;let s=Ln.decodeWeights(this.artifacts.weightData,this.artifacts.weightSpecs);if(this.executor=new M2(I7.Instance.transformGraph(t,this.signature)),this.executor.weightMap=this.convertTensorMapToTensorsMap(s),this.executor.resourceManager=this.resourceManager,e.modelInitializer!=null&&e.modelInitializer.node!=null){let r=I7.Instance.transformGraph(e.modelInitializer);this.initializer=new M2(r),this.initializer.weightMap=this.executor.weightMap,this.initializer.resourceManager=this.resourceManager,this.initializer.executeAsync({},[])}return!0}async save(e,t){if(typeof e=="string"){let n=Ln.getSaveHandlers(e);if(n.length===0)throw new Error(`Cannot find any save handlers for URL '${e}'`);if(n.length>1)throw new Error(`Found more than one (${n.length}) save handlers for URL '${e}'`);e=n[0]}if(e.save==null)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){return this.execute(e,this.outputNodes)}normalizeInputs(e){if(!(e instanceof Ge)&&!Array.isArray(e))return e;if(e=Array.isArray(e)?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,s)=>(t[n]=e[s],t),{})}normalizeOutputs(e){return e=e||this.outputNodes,Array.isArray(e)?e:[e]}execute(e,t){e=this.normalizeInputs(e),t=this.normalizeOutputs(t);let 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);let n=await this.executor.executeAsync(e,t);return n.length>1?n:n[0]}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 yt(e,t={}){if(e==null)throw new Error("modelUrl in loadGraphModel() cannot be null. Please provide a url or an IOHandler that loads the model");t==null&&(t={}),t.fromTFHub&&e.load==null&&(e.endsWith("/")||(e=e+"/"),e=`${e}${uB}${lB}`);let n=new F7(e,t);return await n.load(),n}var cB="3.9.0",O7={};Le(O7,{CSVDataset:()=>q7,Dataset:()=>cu,FileDataSource:()=>ew,TextLineDataset:()=>H7,URLDataSource:()=>tw,array:()=>$B,csv:()=>HB,func:()=>GB,generator:()=>jB,microphone:()=>XB,version_data:()=>KB,webcam:()=>qB,zip:()=>FB});var dB=Da(Yx()),pB=Da(Yx());function hB(e,t){return Df(e,t)}function Df(e,t,n=new Map,s=new Set){if(e==null)return null;if(s.has(e))throw new Error("Circular references are not supported.");if(n.has(e))return n.get(e);let r=t(e);if(r.recurse&&r.value!==null)throw new Error("A deep map function may not return both a value and recurse=true.");if(r.recurse)if(uu(e)){let a=Array.isArray(e)?[]:{};s.add(e);for(let o in e){let i=e[o],l=Df(i,t,n,s);a[o]=l}return s.delete(e),a}else throw new Error(`Can't recurse into non-iterable type: ${e}`);else return n.set(e,r.value),r.value}function fB(e,t=M7){return P7(e,t)}function P7(e,t,n=new Set){let s=e[0];if(n.has(s))throw new Error("Circular references are not supported.");let r=t(e);if(r.recurse&&r.value!==null)throw new Error("A deep zip function may not return both a value and recurse=true.");if(r.recurse)if(uu(s)){let a=Array.isArray(s)?[]:{};n.add(s);for(let o in s){let i=e.map(u=>u[o]),l=P7(i,t,n);a[o]=l}return n.delete(s),a}else throw new Error(`Can't recurse into non-iterable type: ${s}`);else return r.value}function M7(e){return e===null?null:uu(e[0])?{value:null,recurse:!0}:{value:e,recurse:!1}}async function z7(e,t){let n=new Map;Df(e,t,n);for(let r of Array.from(n.keys())){let a=n.get(r);if(w.isPromise(a)){let o=await a;n.set(r,o)}}return Df(e,t,n)}function uu(e){let t=!1;if(Y().get("IS_BROWSER"))t=e instanceof TextDecoder;else{let{StringDecoder:n}=Jx();t=e instanceof n}return e!=null&&!ArrayBuffer.isView(e)&&(Array.isArray(e)||typeof e=="object"&&!(e instanceof Ge)&&!(e instanceof Promise)&&!t)}function mB(e){return e==null||gB(e)||Array.isArray(e)||typeof e=="object"&&e instanceof Ge||w.isTypedArray(e)}function gB(e){return e===null||typeof e!="object"&&typeof e!="function"}function AB(e){return hB(e,yB)}function yB(e){return e instanceof Ge?{value:e.clone(),recurse:!1}:uu(e)?{value:null,recurse:!0}:{value:e,recurse:!1}}var L7=class{constructor(e){if(this.capacity=e,this.begin=0,this.end=0,e==null)throw new RangeError("Can't create a ring buffer of unknown capacity.");if(e<1)throw new RangeError("Can't create ring buffer of capacity < 1.");this.data=new Array(e),this.doubledCapacity=2*e}wrap(e){for(;e<0;)e+=this.doubledCapacity;return e%this.doubledCapacity}get(e){if(e<0)throw new RangeError("Can't get item at a negative index.");return this.data[e%this.capacity]}set(e,t){if(e<0)throw new RangeError("Can't set item at a negative index.");this.data[e%this.capacity]=t}length(){let e=this.end-this.begin;return e<0&&(e=this.doubledCapacity+e),e}isFull(){return this.length()===this.capacity}isEmpty(){return this.length()===0}push(e){if(this.isFull())throw new RangeError("Ring buffer is full.");this.set(this.end,e),this.end=this.wrap(this.end+1)}pushAll(e){for(let t of e)this.push(t)}pop(){if(this.isEmpty())throw new RangeError("Ring buffer is empty.");this.end=this.wrap(this.end-1);let e=this.get(this.end);return this.set(this.end,void 0),e}unshift(e){if(this.isFull())throw new RangeError("Ring buffer is full.");this.begin=this.wrap(this.begin-1),this.set(this.begin,e)}shift(){if(this.isEmpty())throw new RangeError("Ring buffer is empty.");let e=this.get(this.begin);return this.set(this.begin,void 0),this.begin=this.wrap(this.begin+1),e}shuffleExcise(e){if(this.isEmpty())throw new RangeError("Ring buffer is empty.");let t=this.wrap(this.begin+e),n=this.get(t);return this.set(t,this.pop()),n}},z2=class extends L7{constructor(){super(z2.INITIAL_CAPACITY)}isFull(){return!1}push(e){super.isFull()&&this.expand(),super.push(e)}unshift(e){super.isFull()&&this.expand(),super.unshift(e)}expand(){let e=this.capacity*2,t=new Array(e),n=this.length();for(let s=0;s<n;s++)t[s]=this.get(this.wrap(this.begin+s));this.data=t,this.capacity=e,this.doubledCapacity=2*this.capacity,this.begin=0,this.end=n}};z2.INITIAL_CAPACITY=32;function B7(e){return new vB(e)}function L2(e){return new wB(e)}function xB(e,t){return new V7(e,t)}function bB(e,t=xa.FAIL){return new DB(e,t)}var un=class{async toArray(){let e=[],t=await this.next();for(;!t.done;)e.push(t.value),t=await this.next();return e}async toArrayForTest(){let e=this.prefetch(100),t=[],n=await e.next();for(;!n.done;)t.push(n.value),n=await e.next();return t}async resolveFully(){let e=await this.next();for(;!e.done;)e=await this.next()}async resolveWhile(e){let t=await this.next(),n=e(t.value);for(;!t.done&&n;)t=await this.next(),n=e(t.value)}handleErrors(e){return new EB(this,e)}filter(e){return new TB(this,e)}map(e){return new NB(this,e)}mapAsync(e){return new W7(this,e)}serialMapAsync(e){return new W7(this,e).serial()}flatmap(e){return new RB(this,e)}async forEachAsync(e){return this.map(e).resolveFully()}async serialForEach(e){return this.serialMapAsync(e).resolveWhile(t=>t===!0)}rowMajorBatch(e,t=!0){return new CB(this,e,t)}columnMajorBatch(e,t=!0,n=M7){return this.rowMajorBatch(e,t).map(r=>fB(r,n))}concatenate(e,t){return new V7(B7([this,e]),t)}take(e){return e<0||e==null?this:new SB(this,e)}skip(e){return e<0||e==null?this:new IB(this,e)}prefetch(e){return new U7(this,e)}shuffle(e,t){return new _B(this,e,t)}serial(){return new kB(this)}},vB=class extends un{constructor(e){super();this.items=e,this.trav=0}summary(){return`Array of ${this.items.length} items`}async next(){if(this.trav>=this.items.length)return{value:null,done:!0};let e=this.items[this.trav];return this.trav++,{value:AB(e),done:!1}}},wB=class extends un{constructor(e){super();this.nextFn=e}summary(){return"Function call"}async next(){try{return this.nextFn()}catch(e){throw e.message=`Error thrown while iterating through a dataset: ${e.message}`,e}}},kB=class extends un{constructor(e){super();this.upstream=e,this.lastRead=Promise.resolve({value:null,done:!1})}summary(){return`${this.upstream.summary()} -> Serial`}async next(){return this.lastRead=this.lastRead.then(()=>this.serialNext()),this.lastRead}async serialNext(){return this.upstream.next()}},IB=class extends un{constructor(e,t){super();this.upstream=e,this.maxCount=t,this.count=0,this.lastRead=Promise.resolve({value:null,done:!1})}summary(){return`${this.upstream.summary()} -> Skip`}async next(){return this.lastRead=this.lastRead.then(()=>this.serialNext()),this.lastRead}async serialNext(){for(;this.count++<this.maxCount;){let e=await this.upstream.next();if(e.done)return e;Z(e.value)}return this.upstream.next()}},SB=class extends un{constructor(e,t){super();this.upstream=e,this.maxCount=t,this.count=0}summary(){return`${this.upstream.summary()} -> Take`}async next(){return this.count++>=this.maxCount?{value:null,done:!0}:this.upstream.next()}},CB=class extends un{constructor(e,t,n=!0){super();this.upstream=e,this.batchSize=t,this.enableSmallLastBatch=n,this.lastRead=Promise.resolve({value:null,done:!1})}summary(){return`${this.upstream.summary()} -> RowMajorBatch`}async next(){return this.lastRead=this.lastRead.then(()=>this.serialNext()),this.lastRead}async serialNext(){let e=[];for(;e.length<this.batchSize;){let t=await this.upstream.next();if(t.done)return this.enableSmallLastBatch&&e.length>0?{value:e,done:!1}:{value:null,done:!0};e.push(t.value)}return{value:e,done:!1}}},TB=class extends un{constructor(e,t){super();this.upstream=e,this.predicate=t,this.lastRead=Promise.resolve({value:null,done:!1})}summary(){return`${this.upstream.summary()} -> Filter`}async next(){return this.lastRead=this.lastRead.then(()=>this.serialNext()),this.lastRead}async serialNext(){for(;;){let e=await this.upstream.next();if(e.done||this.predicate(e.value))return e;Z(e.value)}}},NB=class extends un{constructor(e,t){super();this.upstream=e,this.transform=t}summary(){return`${this.upstream.summary()} -> Map`}async next(){let e=await this.upstream.next();if(e.done)return{value:null,done:!0};let t=zs.getTensorsInContainer(e.value),n=this.transform(e.value),s=zs.getTensorsInContainer(n);for(let r of t)zs.isTensorInList(r,s)||r.dispose();return{value:n,done:!1}}},EB=class extends un{constructor(e,t){super();this.upstream=e,this.handler=t,this.count=0,this.lastRead=Promise.resolve({value:null,done:!1})}summary(){return`${this.upstream.summary()} -> handleErrors`}async next(){return this.lastRead=this.lastRead.then(()=>this.serialNext()),this.lastRead}async serialNext(){for(;;)try{return await this.upstream.next()}catch(e){if(!this.handler(e))return{value:null,done:!0}}}},W7=class extends un{constructor(e,t){super();this.upstream=e,this.transform=t}summary(){return`${this.upstream.summary()} -> AsyncMap`}async next(){let e=await this.upstream.next();if(e.done)return{value:null,done:!0};let t=zs.getTensorsInContainer(e.value),n=await this.transform(e.value),s=zs.getTensorsInContainer(n);for(let r of t)zs.isTensorInList(r,s)||r.dispose();return{value:n,done:!1}}},B2=class extends un{constructor(){super();this.outputQueue=new z2,this.lastRead=Promise.resolve({value:null,done:!1})}async next(){return this.lastRead=this.lastRead.then(()=>this.serialNext()),this.lastRead}async serialNext(){for(;this.outputQueue.length()===0;)if(!await this.pump())return{value:null,done:!0};return{value:this.outputQueue.shift(),done:!1}}},RB=class extends B2{constructor(e,t){super();this.upstream=e,this.transform=t}summary(){return`${this.upstream.summary()} -> Flatmap`}async pump(){let e=await this.upstream.next();if(e.done)return!1;let t=zs.getTensorsInContainer(e.value),n=this.transform(e.value),s=zs.getTensorsInContainer(n);this.outputQueue.pushAll(n);for(let r of t)zs.isTensorInList(r,s)||r.dispose();return!0}},V7=class extends un{constructor(e,t){super();this.baseErrorHandler=t,this.lastRead=null,this.iterator=null,this.moreIterators=e}summary(){return"TODO: fill in upstream of chained summaries -> Chained"}async next(){return this.lastRead=this.readFromChain(this.lastRead),this.lastRead}async readFromChain(e){if(await e,this.iterator==null){let n=await this.moreIterators.next();if(n.done)return{value:null,done:!0};this.iterator=n.value,this.baseErrorHandler!=null&&(this.iterator=this.iterator.handleErrors(this.baseErrorHandler))}let t=await this.iterator.next();return t.done?(this.iterator=null,this.readFromChain(e)):t}},xa;(function(e){e[e.FAIL=0]="FAIL",e[e.SHORTEST=1]="SHORTEST",e[e.LONGEST=2]="LONGEST"})(xa||(xa={}));var DB=class extends un{constructor(e,t=xa.FAIL){super();this.iterators=e,this.mismatchMode=t,this.count=0,this.currentPromise=null}summary(){return"{TODO: fill in upstream of zip summaries} -> Zip"}async nextState(e){await e;let t=0,n=0;function s(a){return a instanceof un?{value:a.next().then(i=>(t++,i.done&&n++,i.value)),recurse:!1}:{value:null,recurse:!0}}let r=await z7(this.iterators,s);if(t===n)return{value:null,done:!0};if(n>0)switch(this.mismatchMode){case xa.FAIL:throw new Error(`Zipped streams should have the same length. Mismatched at element ${this.count}.`);case xa.SHORTEST:return{value:null,done:!0};case xa.LONGEST:default:}return this.count++,{value:r,done:!1}}async next(){return this.currentPromise=this.nextState(this.currentPromise),this.currentPromise}},U7=class extends un{constructor(e,t){super();this.upstream=e,this.bufferSize=t,this.buffer=new L7(t)}summary(){return`${this.upstream.summary()} -> Prefetch`}refill(){for(;!this.buffer.isFull();){let e=this.upstream.next();this.buffer.push(e)}}next(){return this.refill(),this.buffer.shift()}},_B=class extends U7{constructor(e,t,n){super(e,t);this.upstream=e,this.windowSize=t,this.upstreamExhausted=!1,this.random=pB.alea(n||w.now().toString()),this.lastRead=Promise.resolve({value:null,done:!1})}async next(){return this.lastRead=this.lastRead.then(()=>this.serialNext()),this.lastRead}randomInt(e){return Math.floor(this.random()*e)}chooseIndex(){return this.randomInt(this.buffer.length())}async serialNext(){for(this.upstreamExhausted||this.refill();!this.buffer.isEmpty();){let e=this.chooseIndex(),t=await this.buffer.shuffleExcise(e);if(t.done)this.upstreamExhausted=!0;else return this.refill(),t}return{value:null,done:!0}}},cu=class{constructor(){this.size=null}batch(e,t=!0){let n=this;w.assert(e>0,()=>`batchSize needs to be positive, but it is
|
|
${e}`);let s;return this.size===1/0||this.size==null?s=this.size:t?s=Math.ceil(this.size/e):s=Math.floor(this.size/e),us(async()=>(await n.iterator()).columnMajorBatch(e,t,OB),s)}concatenate(e){let t=this,n;return this.size===1/0||e.size===1/0?n=1/0:this.size!=null&&e.size!=null?n=this.size+e.size:n=null,us(async()=>(await t.iterator()).concatenate(await e.iterator()),n)}filter(e){let t=this,n;return this.size===1/0?n=1/0:n=null,us(async()=>(await t.iterator()).filter(s=>H(()=>e(s))),n)}async forEachAsync(e){return(await this.iterator()).forEachAsync(e)}map(e){let t=this;return us(async()=>(await t.iterator()).map(n=>H(()=>e(n))),this.size)}mapAsync(e){let t=this;return us(async()=>(await t.iterator()).mapAsync(e),this.size)}prefetch(e){if(e==null)throw new RangeError("`Dataset.prefetch()` requires bufferSize to be specified.");let t=this;return us(async()=>(await t.iterator()).prefetch(e),this.size)}repeat(e){let t=this,n;return this.size!=null&&e>0?n=this.size*e:e===0?n=0:this.size!=null&&(e===void 0||e<0)?n=1/0:n=null,us(async()=>{let s=L2(async()=>({value:await t.iterator(),done:!1}));return xB(s.take(e))},n)}skip(e){let t=this,n;return this.size!=null&&e>=0&&this.size>=e?n=this.size-e:this.size!=null&&(this.size<e||e===void 0||e<0)?n=0:n=null,us(async()=>(await t.iterator()).skip(e),n)}shuffle(e,t,n=!0){if(e==null||e<0)throw this.size==null?new RangeError("`Dataset.shuffle()` requires bufferSize to be specified."):new RangeError(`\`Dataset.shuffle()\` requires bufferSize to be specified. If your data fits in main memory (for regular JS objects), and/or GPU memory (for \`tf.Tensor\`s), consider setting bufferSize to the dataset size (${this.size} elements)`);let s=this,r=dB.alea(t||w.now().toString());return us(async()=>{let a=r.int32();return n&&(a+=r.int32()),(await s.iterator()).shuffle(e,a.toString())},this.size)}take(e){let t=this,n;return this.size!=null&&this.size>e?n=e:this.size!=null&&this.size<=e?n=this.size:n=null,us(async()=>(await t.iterator()).take(e),n)}async toArray(){if(this.size===1/0)throw new Error("Can not convert infinite data stream to array.");return(await this.iterator()).toArray()}async toArrayForTest(){if(this.size===1/0)throw new Error("Can not convert infinite data stream to array.");return(await this.iterator()).toArrayForTest()}};cu.MAX_BUFFER_SIZE=1e4;function us(e,t=null){return new class extends cu{constructor(){super(...arguments);this.size=t}async iterator(){return e()}}}function $B(e){return us(async()=>B7(e),e.length)}function FB(e){if(!uu(e))throw new Error("The argument to zip() must be an object or array.");let t;if(Array.isArray(e))for(let n=0;n<e.length;n++)t=t==null?e[n].size:Math.min(t,e[n].size);else if(e instanceof Object)for(let n in e)t=t==null?e[n].size:Math.min(t,e[n].size);return us(async()=>{let n=await z7(e,s=>{if(s instanceof cu)return{value:s.iterator(),recurse:!1};if(uu(s))return{value:null,recurse:!0};throw new Error("Leaves of the structure passed to zip() must be Datasets, not primitives.")});return bB(n,xa.SHORTEST)},t)}function OB(e){if(e===null)return null;let t=e[0];return mB(t)?{value:PB(e),recurse:!1}:{value:null,recurse:!0}}function PB(e){if(e.length===0)throw new Error("Can't make a batch of zero elements.");return e[0]instanceof Ge?mn(e):an(e)}var H7=class extends cu{constructor(e){super();this.input=e}async iterator(){return(await this.input.iterator()).decodeUTF8().split(`
|
|
`).map(s=>(s.endsWith("\r")&&(s=s.slice(0,-1)),s))}},_f='"',id=Symbol("out"),G7=Symbol("field"),$f=Symbol("quote"),W2=Symbol("quoteafterquote"),j7=Symbol("quoteinquote"),q7=class extends cu{constructor(e,t){super();this.input=e,this.hasHeader=!0,this.fullColumnNames=null,this.columnNamesValidated=!1,this.columnConfigs=null,this.configuredColumnsOnly=!1,this.delimiter=",",this.delimWhitespace=!1,this.base=new H7(e),t||(t={}),this.hasHeader=t.hasHeader!==!1,this.fullColumnNames=t.columnNames,this.columnConfigs=t.columnConfigs,this.configuredColumnsOnly=t.configuredColumnsOnly,t.delimWhitespace?(w.assert(t.delimiter==null,()=>"Delimiter should not be provided when delimWhitespace is true."),this.delimWhitespace=!0,this.delimiter=" "):this.delimiter=t.delimiter?t.delimiter:","}async columnNames(){return this.columnNamesValidated||await this.setColumnNames(),this.configuredColumnsOnly?Object.keys(this.columnConfigs):this.fullColumnNames}async setColumnNames(){let e=await this.maybeReadHeaderLine();if(!this.fullColumnNames&&!e)throw new Error("Column names must be provided if there is no header line.");this.fullColumnNames&&e&&w.assert(e.length===this.fullColumnNames.length,()=>"The length of provided columnNames ("+this.fullColumnNames.length.toString()+") does not match the length of the header line read from file ("+e.length.toString()+")."),this.fullColumnNames||(this.fullColumnNames=e);let t=this.fullColumnNames.reduce((s,r)=>(s[r]=s[r]+1||1,s),{}),n=Object.keys(t).filter(s=>t[s]>1);if(w.assert(n.length===0,()=>"Duplicate column names found: "+n.toString()),this.columnConfigs){for(let s of Object.keys(this.columnConfigs))if(this.fullColumnNames.indexOf(s)===-1)throw new Error('The key "'+s+'" provided in columnConfigs does not match any of the column names ('+this.fullColumnNames.toString()+").")}this.columnNamesValidated=!0}async maybeReadHeaderLine(){if(this.hasHeader){let t=await(await this.base.iterator()).next();if(t.done)throw new Error("No data was found for CSV parsing.");let n=t.value;return this.parseRow(n,!1)}else return null}async iterator(){this.columnNamesValidated||await this.setColumnNames();let e=await this.base.iterator();return this.hasHeader&&(e=e.skip(1)),e.map(t=>this.makeDataElement(t))}makeDataElement(e){let t=this.parseRow(e),n={},s={};for(let r=0;r<this.fullColumnNames.length;r++){let a=this.fullColumnNames[r],o=this.columnConfigs?this.columnConfigs[a]:null;if(!(this.configuredColumnsOnly&&!o)){let i=t[r],l=null;if(i==="")if(o&&o.default!==void 0)l=o.default;else{if(o&&(o.required||o.isLabel))throw new Error(`Required column ${a} is empty in this line: ${e}`);l=void 0}else{let u=Number(i);if(isNaN(u))o&&o.dtype==="bool"?l=this.getBoolean(i):l=i;else if(!o||!o.dtype)l=u;else switch(o.dtype){case"float32":l=u;break;case"int32":l=Math.floor(u);break;case"bool":l=this.getBoolean(i);break;default:l=u}}o&&o.isLabel?s[a]=l:n[a]=l}}return Object.keys(s).length===0?n:{xs:n,ys:s}}getBoolean(e){return e==="1"||e.toLowerCase()==="true"?1:0}parseRow(e,t=!0){let n=[],s=0,r=e.length,a=id;for(let o=0;o<r;o++)switch(a){case id:switch(e.charAt(o)){case _f:s=o+1,a=$f;break;case this.delimiter:if(s=o+1,this.delimiter===" "&&this.delimWhitespace)break;n.push(""),a=id;break;default:a=G7,s=o;break}break;case G7:switch(e.charAt(o)){case this.delimiter:n.push(e.substring(s,o)),a=id,s=o+1;break;default:}break;case $f:switch(e.charAt(o)){case _f:a=W2;break;default:}break;case W2:switch(e.charAt(o)){case this.delimiter:n.push(e.substring(s,o-1)),a=id,s=o+1;break;case _f:a=$f;break;default:a=j7;break}break;case j7:switch(e.charAt(o)){case _f:a=$f;break;default:}break;default:}if(a===W2?n.push(e.substring(s,r-1)):n.push(e.substring(s)),t&&n.length!==this.fullColumnNames.length)throw new Error(`Invalid row in csv file. Should have ${this.fullColumnNames.length} elements in a row, but got ${n}`);return n}},X7=class extends un{constructor(e){super();this.microphoneConfig=e,this.isClosed=!1,this.fftSize=e.fftSize||1024;let t=Math.log2(this.fftSize);if(this.fftSize<0||t<4||t>14||!Number.isInteger(t))throw new Error(`Invalid fftSize: it must be a power of 2 between 2 to 4 and 2 to 14, but got ${this.fftSize}`);if(this.numFrames=e.numFramesPerSpectrogram||43,this.sampleRateHz=e.sampleRateHz,this.columnTruncateLength=e.columnTruncateLength||this.fftSize,this.audioTrackConstraints=e.audioTrackConstraints,this.smoothingTimeConstant=e.smoothingTimeConstant||0,this.includeSpectrogram=e.includeSpectrogram!==!1,this.includeWaveform=e.includeWaveform===!0,!this.includeSpectrogram&&!this.includeWaveform)throw new Error("Both includeSpectrogram and includeWaveform are false. At least one type of data should be returned.")}summary(){return"microphone"}static async create(e={}){if(Y().get("IS_NODE"))throw new Error("microphone API is only supported in browser environment.");let t=new X7(e);return await t.start(),t}async start(){try{this.stream=await navigator.mediaDevices.getUserMedia({audio:this.audioTrackConstraints==null?!0:this.audioTrackConstraints,video:!1})}catch(n){throw new Error(`Error thrown while initializing video stream: ${n.message}`)}if(!this.stream)throw new Error("Could not obtain audio from microphone.");let e=window.AudioContext||window.webkitAudioContext;if(this.audioContext=new e,!this.sampleRateHz)this.sampleRateHz=this.audioContext.sampleRate;else if(this.audioContext.sampleRate!==this.sampleRateHz)throw new Error(`Mismatch in sampling rate: Expected: ${this.sampleRateHz}; Actual: ${this.audioContext.sampleRate}`);let t=this.audioContext.createMediaStreamSource(this.stream);this.analyser=this.audioContext.createAnalyser(),this.analyser.fftSize=this.fftSize*2,this.analyser.smoothingTimeConstant=this.smoothingTimeConstant,t.connect(this.analyser),this.freqData=new Float32Array(this.fftSize),this.timeData=new Float32Array(this.fftSize)}async next(){if(this.isClosed)return{value:null,done:!0};let e,t,n=await this.getAudioData();if(this.includeSpectrogram){let s=this.flattenQueue(n.freqDataQueue);e=this.getTensorFromAudioDataArray(s,[this.numFrames,this.columnTruncateLength,1])}if(this.includeWaveform){let s=this.flattenQueue(n.timeDataQueue);t=this.getTensorFromAudioDataArray(s,[this.numFrames*this.fftSize,1])}return{value:{spectrogram:e,waveform:t},done:!1}}async capture(){return(await this.next()).value}async getAudioData(){let e=[],t=[],n=0;return new Promise(s=>{let r=setInterval(()=>{this.includeSpectrogram&&(this.analyser.getFloatFrequencyData(this.freqData),this.freqData[0]===-1/0&&s({freqDataQueue:e,timeDataQueue:t}),e.push(this.freqData.slice(0,this.columnTruncateLength))),this.includeWaveform&&(this.analyser.getFloatTimeDomainData(this.timeData),t.push(this.timeData.slice())),++n===this.numFrames&&(clearInterval(r),s({freqDataQueue:e,timeDataQueue:t}))},this.fftSize/this.sampleRateHz*1e3)})}stop(){this.isClosed||(this.isClosed=!0,this.analyser.disconnect(),this.audioContext.close(),this.stream!=null&&this.stream.getTracks().length>0&&this.stream.getTracks()[0].stop())}toArray(){throw new Error("Can not convert infinite audio stream to array.")}getSampleRate(){return this.sampleRateHz}flattenQueue(e){let t=e[0].length,n=new Float32Array(e.length*t);return e.forEach((s,r)=>n.set(s,r*t)),n}getTensorFromAudioDataArray(e,t){let n=new Float32Array(w.sizeFromShape(t));return n.set(e,n.length-e.length),an(n,t)}},K7=class extends un{constructor(e,t){super();if(this.webcamVideoElement=e,this.webcamConfig=t,this.isClosed=!0,this.resize=!1,this.needToResize())if(this.resize=!0,this.cropSize=[this.webcamConfig.resizeHeight,this.webcamConfig.resizeWidth],this.cropBoxInd=Ut([0],"int32"),this.webcamConfig.centerCrop){let n=this.webcamConfig.resizeWidth*1/this.webcamVideoElement.width,s=this.webcamConfig.resizeHeight*1/this.webcamVideoElement.height,r=(1-n)/2,a=(1-s)/2,o=r+n,i=s+a;this.cropBox=Us([a,r,i,o],[1,4])}else this.cropBox=Us([0,0,1,1],[1,4])}summary(){return"webcam"}static async create(e,t={}){if(Y().get("IS_NODE"))throw new Error("tf.data.webcam is only supported in browser environment.");if(!e){if(e=document.createElement("video"),!t.resizeWidth||!t.resizeHeight)throw new Error("Please provide webcam video element, or resizeWidth and resizeHeight to create a hidden video element.");e.width=t.resizeWidth,e.height=t.resizeHeight}let n=new K7(e,t);return await n.start(),n}async start(){this.webcamConfig.facingMode&&w.assert(this.webcamConfig.facingMode==="user"||this.webcamConfig.facingMode==="environment",()=>`Invalid webcam facing mode: ${this.webcamConfig.facingMode}. Please provide 'user' or 'environment'`);try{this.stream=await navigator.mediaDevices.getUserMedia({video:{deviceId:this.webcamConfig.deviceId,facingMode:this.webcamConfig.facingMode?this.webcamConfig.facingMode:"user",width:this.webcamVideoElement.width,height:this.webcamVideoElement.height}})}catch(e){throw e.message=`Error thrown while initializing video stream: ${e.message}`,e}if(!this.stream)throw new Error("Could not obtain video from webcam.");try{this.webcamVideoElement.srcObject=this.stream}catch(e){console.log(e),this.webcamVideoElement.src=window.URL.createObjectURL(this.stream)}return this.webcamVideoElement.play(),this.isClosed=!1,new Promise(e=>{this.webcamVideoElement.onloadedmetadata=()=>{e()}})}async next(){if(this.isClosed)return{value:null,done:!0};let e;try{e=xs.fromPixels(this.webcamVideoElement)}catch(t){throw new Error(`Error thrown converting video to pixels: ${JSON.stringify(t)}`)}if(this.resize)try{return{value:this.cropAndResizeFrame(e),done:!1}}catch(t){throw new Error(`Error thrown cropping the video: ${t.message}`)}finally{e.dispose()}else return{value:e,done:!1}}needToResize(){return!!(this.webcamConfig.resizeWidth&&this.webcamConfig.resizeHeight&&(this.webcamVideoElement.width!==this.webcamConfig.resizeWidth||this.webcamVideoElement.height!==this.webcamConfig.resizeHeight))}cropAndResizeFrame(e){return H(()=>{let t=Lt(pe(e,"float32"),0),n;n=$e.cropAndResize(t,this.cropBox,this.cropBoxInd,this.cropSize,"bilinear");let s=n.shape;return V(n,s.slice(1))})}async capture(){return(await this.next()).value}stop(){this.stream.getTracks().forEach(t=>t.stop());try{this.webcamVideoElement.srcObject=null}catch(t){console.log(t),this.webcamVideoElement.src=null}this.isClosed=!0}toArray(){throw new Error("Can not convert infinite video stream to array.")}},Z7=class{},Y7=class extends un{split(e){return new MB(this,e)}},MB=class extends Y7{constructor(e,t){super();this.upstream=e,this.impl=new zB(e,t)}summary(){return this.impl.summary()}async next(){return this.impl.next()}},zB=class extends B2{constructor(e,t){super();this.upstream=e,this.separator=t,this.carryover=""}summary(){return`${this.upstream.summary()} -> Split('${this.separator}')`}async pump(){let e=await this.upstream.next();if(e.done)return this.carryover===""?!1:(this.outputQueue.push(this.carryover),this.carryover="",!0);let t=e.value.split(this.separator);t[0]=this.carryover+t[0];for(let n of t.slice(0,-1))this.outputQueue.push(n);return this.carryover=t[t.length-1],!0}},LB=class extends un{decodeUTF8(){return new BB(this)}},BB=class extends Y7{constructor(e){super();this.upstream=e,this.impl=new WB(e)}summary(){return this.impl.summary()}async next(){return this.impl.next()}},WB=class extends B2{constructor(e){super();if(this.upstream=e,Y().get("IS_BROWSER"))this.decoder=new TextDecoder("utf-8");else{let{StringDecoder:t}=Jx();this.decoder=new t("utf8")}}summary(){return`${this.upstream.summary()} -> Utf8`}async pump(){let e=await this.upstream.next(),t;if(e.done)return!1;t=e.value;let n;return Y().get("IS_BROWSER")?n=this.decoder.decode(t,{stream:!0}):n=this.decoder.write(Buffer.from(t.buffer)),this.outputQueue.push(n),!0}},J7=class extends LB{constructor(e,t={}){super();this.file=e,this.options=t,w.assert(e instanceof Uint8Array||(Y().get("IS_BROWSER")?e instanceof File||e instanceof Blob:!1),()=>"FileChunkIterator only supports File, Blob and Uint8Array right now."),this.offset=t.offset||0,this.chunkSize=t.chunkSize||1024*1024}summary(){return`FileChunks ${this.file}`}async next(){return this.offset>=(this.file instanceof Uint8Array?this.file.byteLength:this.file.size)?{value:null,done:!0}:{value:await new Promise((t,n)=>{let s=this.offset+this.chunkSize;if(this.file instanceof Uint8Array)t(new Uint8Array(this.file.slice(this.offset,s)));else{let r=new FileReader;r.onload=o=>{let i=r.result;if(i instanceof ArrayBuffer&&(i=new Uint8Array(i)),!(i instanceof Uint8Array))return n(new TypeError("FileReader returned unknown type."));t(i)},r.onabort=o=>n(new Error("Aborted")),r.onerror=o=>n(new Error(o.type));let a=this.file.slice(this.offset,s);r.readAsArrayBuffer(a)}this.offset=s}),done:!1}}};async function VB(e,t={}){let n,s;typeof e=="string"?n=e:(n=e.url,s=UB(e));let r=await w.fetch(n,s);if(r.ok){let a=new Uint8Array(await r.arrayBuffer());return new J7(a,t)}else throw new Error(r.statusText)}var UB=e=>({method:e.method,headers:e.headers,body:e.body,mode:e.mode,credentials:e.credentials,cache:e.cache,redirect:e.redirect,referrer:e.referrer,integrity:e.integrity});function Q7(e){return typeof e=="string"&&e.substr(0,7)==="file://"}var ew=class extends Z7{constructor(e,t={}){super();this.input=e,this.options=t}async iterator(){if(Q7(this.input)&&Y().get("IS_NODE")){let e=Di("fs");this.input=e.readFileSync(this.input.substr(7))}return new J7(this.input,this.options)}},tw=class extends Z7{constructor(e,t={}){super();this.url=e,this.fileOptions=t}async iterator(){return Q7(this.url)?new ew(this.url,this.fileOptions).iterator():VB(this.url,this.fileOptions)}};function HB(e,t={}){return new q7(new tw(e),t)}function GB(e){let t=L2(e);return us(async()=>t)}function jB(e){return us(async()=>{let t=await e();return L2(()=>t.next())})}async function qB(e,t){return K7.create(e,t)}async function XB(e){return X7.create(e)}var KB="3.9.0";function Se(e,t){Array.isArray(e)||(e=[e]),e.forEach(n=>{n!=null&&w.assert(n.dtype!=="complex64",()=>`${t} does not support complex64 tensors in the CPU backend.`)})}var ZB=lr.whereImpl,V2=class extends qu{constructor(){super();this.blockSize=48,this.firstUse=!0,this.data=new up(this,Qn())}nextDataId(){return V2.nextDataId++}write(e,t,n){this.firstUse&&(this.firstUse=!1,Y().get("IS_NODE")&&_.warn(`
|
|
============================
|
|
Hi there \u{1F44B}. Looks like you are running TensorFlow.js in Node.js. To speed things up dramatically, install our node backend, which binds to TensorFlow C++, by running npm i @tensorflow/tfjs-node, or npm i @tensorflow/tfjs-node-gpu if you have CUDA. Then call require('@tensorflow/tfjs-node'); (-gpu suffix for CUDA) at the start of your program. Visit https://github.com/tensorflow/tfjs-node for more details.
|
|
============================`));let s={id:this.nextDataId()};return this.data.set(s,{values:e,dtype:n,refCount:1}),s}makeTensorInfo(e,t,n){let s;if(t==="string"&&n!=null&&n.length>0&&w.isString(n[0])){let r=n.map(a=>w.encodeString(a));s=this.write(r,e,t)}else s=this.write(n,e,t);return{dataId:s,shape:e,dtype:t}}refCount(e){return this.data.has(e)?this.data.get(e).refCount:0}incRef(e){let t=this.data.get(e);t.refCount++}decRef(e){if(this.data.has(e)){let t=this.data.get(e);t.refCount--}}move(e,t,n,s,r){this.data.set(e,{values:t,dtype:s,refCount:r})}numDataIds(){return this.data.numDataIds()}async read(e){return this.readSync(e)}readSync(e){let{dtype:t,complexTensorInfos:n}=this.data.get(e);if(t==="complex64"){let s=this.readSync(n.real.dataId),r=this.readSync(n.imag.dataId);return _.mergeRealAndImagArrays(s,r)}return this.data.get(e).values}bufferSync(e){let t=this.readSync(e.dataId),n=t;if(e.dtype==="string")try{n=t.map(s=>w.decodeString(s))}catch(s){throw new Error("Failed to decode encoded string bytes into utf-8")}return je(e.shape,e.dtype,n)}makeOutput(e,t,n){let s=this.write(e,t,n);return Qn().makeTensorFromDataId(s,t,n,this)}disposeData(e,t=!1){if(this.data.has(e)){if(this.data.get(e).refCount--,!t&&this.data.get(e).refCount>0)return!1;let{complexTensorInfos:n}=this.data.get(e);n!=null&&(this.disposeData(n.real.dataId,!0),this.disposeData(n.imag.dataId,!0)),this.data.delete(e)}return!0}disposeIntermediateTensorInfo(e){this.disposeData(e.dataId)}async time(e){let t=w.now();return e(),{kernelMs:w.now()-t}}memory(){return{unreliable:!0,reasons:["The reported memory is an upper bound. Due to automatic garbage collection, the true allocated memory may be less."]}}where(e){Se([e],"where");let t=this.readSync(e.dataId);return ZB(e.shape,t)}dispose(){}floatPrecision(){return 32}epsilon(){return super.epsilon()}};V2.nextDataId=0;var nw={};Le(nw,{addImpl:()=>rw,bincountImpl:()=>H2,bincountReduceImpl:()=>aw,ceilImpl:()=>ow,concatImpl:()=>G2,equalImpl:()=>iw,expImpl:()=>uw,expm1Impl:()=>dw,floorImpl:()=>pw,gatherNdImpl:()=>hw,gatherV2Impl:()=>fw,greaterEqualImpl:()=>gw,greaterImpl:()=>mw,lessEqualImpl:()=>yw,lessImpl:()=>Aw,linSpaceImpl:()=>xw,logImpl:()=>bw,maxImpl:()=>vw,maximumImpl:()=>ww,minimumImpl:()=>kw,multiplyImpl:()=>j2,negImpl:()=>Iw,notEqualImpl:()=>Sw,prodImpl:()=>Cw,rangeImpl:()=>X2,rsqrtImpl:()=>Tw,sigmoidImpl:()=>zW,simpleAbsImpl:()=>sw,sliceImpl:()=>Pf,sparseFillEmptyRowsImpl:()=>Ew,sparseReshapeImpl:()=>Rw,sparseSegmentReductionImpl:()=>K2,sqrtImpl:()=>WW,squaredDifferenceImpl:()=>Dw,stridedSliceImpl:()=>_w,stringNGramsImpl:()=>$w,stringSplitImpl:()=>Fw,stringToHashBucketFastImpl:()=>Ow,subImpl:()=>Pw,tileImpl:()=>Mw,topKImpl:()=>Lw,transposeImpl:()=>q2,uniqueImpl:()=>Bw});function sw(e){let t=new Float32Array(e.length);for(let n=0;n<e.length;++n)t[n]=Math.abs(e[n]);return t}var YB=e=>{let{x:t}=e.inputs,n=e.backend;Se(t,"abs");let s=new Float32Array(w.sizeFromShape(t.shape)),r=n.data.get(t.dataId).values;return s=sw(r),n.makeOutput(s,t.shape,"float32")},JB={kernelName:Fi,backendName:"cpu",kernelFunc:YB};function Gt(e){return(t,n,s,r,a)=>{let o=_.assertAndGetBroadcastShape(t,n),i=o.length,l=w.computeStrides(o),u=w.sizeFromShape(o),c=w.getTypedArrayFromDType(a,u),d=t.length,p=n.length,h=w.computeStrides(t),f=w.computeStrides(n),m=_.getBroadcastDims(t,o),g=_.getBroadcastDims(n,o);if(m.length+g.length===0)for(let A=0;A<c.length;++A)c[A]=e(s[A%s.length],r[A%r.length]);else for(let A=0;A<c.length;++A){let y=w.indexToLoc(A,i,l),x=y.slice(-d);m.forEach(S=>x[S]=0);let b=w.locToIndex(x,d,h),v=y.slice(-p);g.forEach(S=>v[S]=0);let k=w.locToIndex(v,p,f);c[A]=e(s[b],r[k])}return[c,o]}}function cs(e){let{inputs:t,backend:n}=e,{real:s,imag:r}=t,a=n.data.get(s.dataId).values,o=n.data.get(r.dataId).values,i=n.makeTensorInfo(s.shape,"complex64"),l=n.data.get(i.dataId);return l.complexTensorInfos={real:n.makeTensorInfo(s.shape,"float32",a),imag:n.makeTensorInfo(r.shape,"float32",o)},i}var QB={kernelName:Ap,backendName:"cpu",kernelFunc:cs};function Ff(e,t,n="float32"){if(n==="complex64"){let r=Ff(e,t,"float32"),a=Ff(e,t,"float32");return cs({inputs:{real:r,imag:a},backend:e})}let s=w.makeZerosTypedArray(w.sizeFromShape(t),n);return e.makeTensorInfo(t,n,s)}function fr(e){let{inputs:t,backend:n}=e,{x:s}=t;return n.incRef(s.dataId),{dataId:s.dataId,shape:s.shape,dtype:s.dtype}}var eW={kernelName:Qa,backendName:"cpu",kernelFunc:fr};function ai(e){let{inputs:t,backend:n}=e,{input:s}=t,r=n.data.get(s.dataId).complexTensorInfos.real,a=n.data.get(r.dataId).values;return n.makeTensorInfo(r.shape,r.dtype,a)}var tW={kernelName:zp,backendName:"cpu",kernelFunc:ai};function ba(e){let{inputs:t,backend:n,attrs:s}=e,{x:r}=t,{dtype:a}=s;if(a==="complex64"){if(r.dtype==="complex64")return fr({inputs:{x:r},backend:n});let o=Ff(n,r.shape,r.dtype),i=ba({inputs:{x:r},backend:n,attrs:{dtype:"float32"}}),l=cs({inputs:{real:i,imag:o},backend:n});return n.disposeIntermediateTensorInfo(o),n.disposeIntermediateTensorInfo(i),l}if(r.dtype==="complex64"){let o=ai({inputs:{input:r},backend:n}),i=ba({inputs:{x:o},backend:n,attrs:{dtype:a}});return n.disposeIntermediateTensorInfo(o),i}if(!w.hasEncodingLoss(r.dtype,a)){let o=fr({inputs:{x:r},backend:n});return{dataId:o.dataId,shape:o.shape,dtype:a}}if(a==="int32"){let o=n.data.get(r.dataId).values,i=Int32Array.from(o);return n.makeTensorInfo(r.shape,"int32",i)}if(a==="bool"){let o=n.data.get(r.dataId).values,i=w.toTypedArray([0],r.dtype),[l,u]=Gt((c,d)=>c!==d?1:0)(r.shape,[],o,i,"bool");return n.makeTensorInfo(u,"bool",l)}throw new Error(`Error in Cast: failed to cast ${r.dtype} to ${a}`)}var nW={kernelName:za,backendName:"cpu",kernelFunc:ba};function cn(e,t,n,s){return n==null?({inputs:r,backend:a})=>{let{a:o,b:i}=r,l=a;Se([o,i],e);let u=l.data.get(o.dataId).values,c=l.data.get(i.dataId).values,d=o.dtype==="string"?_.fromUint8ToStringArray(u):u,p=o.dtype==="string"?_.fromUint8ToStringArray(c):c,h=s||o.dtype,[f,m]=t(o.shape,i.shape,d,p,h);return l.makeTensorInfo(m,h,f)}:({inputs:r,backend:a})=>{let{a:o,b:i}=r,l=a;if(o.dtype==="complex64"||i.dtype==="complex64"){let u=ba({inputs:{x:o},backend:l,attrs:{dtype:"complex64"}}),c=l.data.get(u.dataId),d=c.complexTensorInfos.real,p=c.complexTensorInfos.imag,h=l.data.get(d.dataId).values,f=l.data.get(p.dataId).values,m=ba({inputs:{x:i},backend:l,attrs:{dtype:"complex64"}}),g=l.data.get(m.dataId),A=g.complexTensorInfos.real,y=g.complexTensorInfos.imag,x=l.data.get(A.dataId).values,b=l.data.get(y.dataId).values,[v,k,S]=n(o.shape,i.shape,h,f,x,b),C=l.makeTensorInfo(S,"float32",v),D=l.makeTensorInfo(S,"float32",k),O=cs({inputs:{real:C,imag:D},backend:l});return l.disposeIntermediateTensorInfo(u),l.disposeIntermediateTensorInfo(m),l.disposeIntermediateTensorInfo(C),l.disposeIntermediateTensorInfo(D),O}else{let u=l.data.get(o.dataId).values,c=l.data.get(i.dataId).values,d=s||o.dtype,[p,h]=t(o.shape,i.shape,u,c,d);return l.makeTensorInfo(h,d,p)}}}function U2(e){return(t,n,s,r,a,o)=>{let i=_.assertAndGetBroadcastShape(t,n),l=w.sizeFromShape(i),u=i.length,c=w.computeStrides(i),d=w.getTypedArrayFromDType("float32",l),p=w.getTypedArrayFromDType("float32",l),h=_.getBroadcastDims(t,i),f=_.getBroadcastDims(n,i),m=_.mergeRealAndImagArrays(s,r),g=_.mergeRealAndImagArrays(a,o),A=t.length,y=w.computeStrides(t),x=n.length,b=w.computeStrides(n);if(h.length+f.length===0)for(let v=0;v<d.length;v++){let k=v%m.length,S=v%g.length,C=e(m[k*2],m[k*2+1],g[S*2],g[S*2+1]);d[v]=C.real,p[v]=C.imag}else for(let v=0;v<d.length;v++){let k=w.indexToLoc(v,u,c),S=k.slice(-A);h.forEach(R=>S[R]=0);let C=w.locToIndex(S,A,y),D=k.slice(-x);f.forEach(R=>D[R]=0);let O=w.locToIndex(D,x,b),E=e(m[C*2],m[C*2+1],g[O*2],g[O*2+1]);d[v]=E.real,p[v]=E.imag}return[d,p,i]}}var rw=Gt((e,t)=>e+t),sW=U2((e,t,n,s)=>({real:e+n,imag:t+s})),ld=cn(Yr,rw,sW),rW={kernelName:Yr,backendName:"cpu",kernelFunc:ld};function H2(e,t,n,s,r){let a=w.sizeFromShape(s),o=w.makeZerosTypedArray(r,n);for(let i=0;i<e.length;i++){let l=e[i];if(l<0)throw new Error("Input x must be non-negative!");l>=r||(a>0?o[l]+=t[i]:o[l]+=1)}return o}function aw(e,t,n,s=!1){let r=e.shape[0],a=e.shape[1],o=je([r,n],t.dtype);for(let i=0;i<r;i++)for(let l=0;l<a;l++){let u=e.get(i,l);if(u<0)throw new Error("Input x must be non-negative!");u>=n||(s?o.set(1,i,u):t.size>0?o.set(o.get(i,u)+t.get(i,l),i,u):o.set(o.get(i,u)+1,i,u))}return o}function va(e){return(t,n,s)=>{let r=w.getTypedArrayFromDType(n,t.length);for(let a=0;a<t.length;++a)r[a]=e(t[a],s);return r}}function ct(e,t,n){return({inputs:s,attrs:r,backend:a})=>{let{x:o}=s;if(Se(o,e),o.dtype==="string"||n==="string")throw new Error("unaryKernelFunc does not support string input/output");let i=a,l=i.data.get(o.dataId).values,u=w.sizeFromShape(o.shape),c=n||o.dtype,d=w.getArrayFromDType(c,u);for(let p=0;p<u;++p)d[p]=t(l[p],r);return i.makeTensorInfo(o.shape,c,d)}}function du(e,t,n){return({inputs:s,attrs:r,backend:a})=>{let{x:o}=s;if(Se(o,e),o.dtype==="string"||n==="string")throw new Error("unaryKernelFunc does not support string input/output");let i=a,l=i.data.get(o.dataId).values,u=n||o.dtype,c=t(l,u,r);return i.makeTensorInfo(o.shape,u,c)}}var ow=va(e=>Math.ceil(e)),aW=du(La,ow),oW={kernelName:La,backendName:"cpu",kernelFunc:aW};function G2(e,t,n,s){let r=w.getArrayFromDType(n,w.sizeFromShape(t));if(s&&n!=="string"){let a=0;e.forEach(o=>{let i=w.sizeFromShape(o.shape);r.set(o.vals,a),a+=i})}else{let a=0;e.forEach(o=>{let i=n==="string"?_.fromUint8ToStringArray(o.vals):o.vals,l=0;for(let u=0;u<o.shape[0];++u){let c=u*t[1]+a;for(let d=0;d<o.shape[1];++d)r[c+d]=i[l++]}a+=o.shape[1]})}return r}var iw=Gt((e,t)=>e===t?1:0),lw=cn(Ki,iw,null,"bool"),iW={kernelName:Ki,backendName:"cpu",kernelFunc:lw},uw=va(e=>Math.exp(e)),cw=du(Xa,uw),lW={kernelName:Xa,backendName:"cpu",kernelFunc:cw},dw=va(e=>Math.expm1(e)),uW=du(Yi,dw),cW={kernelName:Yi,backendName:"cpu",kernelFunc:uW},pw=va(e=>Math.floor(e)),dW=du(Ka,pw),pW={kernelName:Ka,backendName:"cpu",kernelFunc:dW};function hw(e,t,n,s,r,a,o,i,l){let u=je([s,a],n);for(let c=0;c<s;c++){let d=[],p=0;for(let h=0;h<r;h++){let f=e[c*r+h];p+=f*o[h],d.push(f)}if(p<0||p>=l/a)throw new Error(`Invalid indices: ${d} does not index into ${i}`);for(let h=0;h<a;h++)u.values[c*a+h]=t.get(...t.indexToLoc(p*a+h))}return u}function fw(e,t,n){let s=je(n,e.dtype);for(let r=0;r<s.size;++r){let o=s.indexToLoc(r).slice(),i=o[0],l=o[2],u=t.locToIndex([i,l]);o[2]=t.values[u];let c=e.locToIndex(o);s.values[r]=e.values[c]}return s}var mw=Gt((e,t)=>e>t?1:0),hW=cn(tl,mw,null,"bool"),fW={kernelName:tl,backendName:"cpu",kernelFunc:hW},gw=Gt((e,t)=>e>=t?1:0),mW=cn(Ja,gw,null,"bool"),gW={kernelName:Ja,backendName:"cpu",kernelFunc:mW},Aw=Gt((e,t)=>e<t?1:0),AW=cn(al,Aw,null,"bool"),yW={kernelName:al,backendName:"cpu",kernelFunc:AW},yw=Gt((e,t)=>e<=t?1:0),xW=cn(ol,yw,null,"bool"),bW={kernelName:ol,backendName:"cpu",kernelFunc:xW};function xw(e,t,n){let s=(t-e)/(n-1),r=w.makeZerosTypedArray(n,"float32");r[0]=e;for(let a=1;a<r.length;a++)r[a]=r[a-1]+s;return r}var bw=va(e=>Math.log(e)),vW=du(to,bw),wW={kernelName:to,backendName:"cpu",kernelFunc:vW};function vw(e,t,n,s){let r=w.getTypedArrayFromDType(s,w.sizeFromShape(n));for(let a=0;a<r.length;++a){let o=a*t,i=e[o];for(let l=0;l<t;++l){let u=e[o+l];(Number.isNaN(u)||u>i)&&(i=u)}r[a]=i}return r}var ww=Gt((e,t)=>Math.max(e,t)),kW=cn(so,ww),IW={kernelName:so,backendName:"cpu",kernelFunc:kW},kw=Gt((e,t)=>Math.min(e,t)),SW=cn(io,kw),CW={kernelName:io,backendName:"cpu",kernelFunc:SW},j2=Gt((e,t)=>e*t),TW=U2((e,t,n,s)=>({real:e*n-t*s,imag:e*s+t*n})),Of=cn(uo,j2,TW),NW={kernelName:uo,backendName:"cpu",kernelFunc:Of};function Iw(e,t,n){let s=w.createScalarValue(-1,n);return j2([],t,s,e,n)}function EW(e){let{inputs:t,backend:n}=e,{x:s}=t;Se(s,"neg");let r=n.data.get(s.dataId).values,[a,o]=Iw(r,s.shape,s.dtype);return n.makeTensorInfo(o,s.dtype,a)}var RW={kernelName:cl,backendName:"cpu",kernelFunc:EW},Sw=Gt((e,t)=>e!==t?1:0),DW=cn(dl,Sw,null,"bool"),_W={kernelName:dl,backendName:"cpu",kernelFunc:DW};function q2(e,t,n,s,r){let a=t.length,o=w.sizeFromShape(t),i=w.computeStrides(t),l=w.computeStrides(r),u=w.getTypedArrayFromDType(n,w.sizeFromShape(r));for(let c=0;c<o;++c){let d=w.indexToLoc(c,a,i),p=new Array(d.length);for(let f=0;f<p.length;f++)p[f]=d[s[f]];let h=w.locToIndex(p,a,l);u[h]=e[c]}return u}function ws(e){let{inputs:t,attrs:n,backend:s}=e,{x:r}=t,{perm:a}=n;Se(r,"transpose");let o=r.shape.length,i=new Array(o);for(let d=0;d<i.length;d++)i[d]=r.shape[a[d]];let l=s.data.get(r.dataId).values,u=q2(l,r.shape,r.dtype,a,i);return{dataId:s.write(u,i,r.dtype),shape:i,dtype:r.dtype}}var $W={kernelName:Ro,backendName:"cpu",kernelFunc:ws};function Cw(e,t,n,s){let[r,a]=_.computeOutAndReduceShapes(e,s),o=Ds(t,"int32"),i=w.makeZerosTypedArray(w.sizeFromShape(r),o),l=w.sizeFromShape(a);for(let u=0;u<i.length;++u){let c=u*l,d=1;for(let p=0;p<l;++p)d*=n[c+p];i[u]=d}return{outVals:i,outShape:r,outDtype:o}}function FW(e){let{inputs:t,backend:n,attrs:s}=e,{x:r}=t,{axis:a,keepDims:o}=s;Se(r,"prod");let i=r.shape.length,l=w.parseAxisParam(a,r.shape),u=_.getAxesPermutation(l,i),c=l,d=r,p=[];u!=null&&(d=ws({inputs:{x:r},backend:n,attrs:{perm:u}}),p.push(d),c=_.getInnerMostAxes(c.length,i));let h=n.data.get(d.dataId).values,{outVals:f,outShape:m,outDtype:g}=Cw(d.shape,d.dtype,h,c),A=m;return o&&(A=_.expandShapeToKeepDim(m,l)),p.forEach(y=>n.disposeIntermediateTensorInfo(y)),n.makeTensorInfo(A,g,f)}var OW={kernelName:Al,backendName:"cpu",kernelFunc:FW};function X2(e,t,n,s){let r=e===t,a=e<t&&n<0,o=t<e&&n>1;if(r||a||o)return w.makeZerosTypedArray(0,s);let i=Math.abs(Math.ceil((t-e)/n)),l=w.makeZerosTypedArray(i,s);t<e&&n===1&&(n=-1),l[0]=e;for(let u=1;u<l.length;u++)l[u]=l[u-1]+n;return l}var Tw=va(e=>1/Math.sqrt(e)),PW=du(bo,Tw),MW={kernelName:bo,backendName:"cpu",kernelFunc:PW},zW=va(e=>1/(1+Math.exp(-e))),Nw=ct(wo,e=>1/(1+Math.exp(-e))),LW={kernelName:wo,backendName:"cpu",kernelFunc:Nw};function Pf(e,t,n,s,r){let a=Cn.isSliceContinous(s,t,n),o=w.sizeFromShape(n),i=w.computeStrides(s);if(a){let d=Cn.computeFlatOffset(t,i);return r==="string"?e.slice(d,d+o):e.subarray(d,d+o)}let l=r==="string"?_.fromUint8ToStringArray(e):e,u=je(s,r,l),c=je(n,r);for(let d=0;d<c.size;++d){let p=c.indexToLoc(d),h=p.map((f,m)=>f+t[m]);c.set(u.get(...h),...p)}return r==="string"?_.fromStringArrayToUint8(c.values):c.values}function oi(e){let{inputs:t,backend:n,attrs:s}=e,{x:r}=t,{begin:a,size:o}=s;Se(r,"slice");let[i,l]=Cn.parseSliceParams(r,a,o);Cn.assertParamsValid(r,i,l);let u=n.data.get(r.dataId).values,c=Pf(u,i,l,r.shape,r.dtype);return n.makeTensorInfo(l,r.dtype,c)}var BW={kernelName:kl,backendName:"cpu",kernelFunc:oi};function Ew(e,t,n,s,r,a,o){let i=t[0],l=a[0],u=new Array(l),c=new Array(i),d=t[1];if(l===0){if(i!==0)throw new Error(`Received SparseTensor with denseShape[0] = 0 but
|
|
indices.shape[0] = ${i}`);let g=w.getArrayFromDType(n,0),A=w.getArrayFromDType(r,0);return[g,[0,d],A,u,c]}let p=!0,h=0,f=new Array(l).fill(0);for(let g=0;g<i;++g){let A=e[g*d];if(A<0)throw new Error(`indices(${g}, 0) is invalid: ${A} < 0`);if(A>=l)throw new Error(`indices(${g}, 0) is invalid: ${A} >= ${l}`);++f[A],p=p&&A>=h,h=A}let m=!0;for(let g=0;g<l;++g){let A=f[g]===0;u[g]=A,m=m&&!A,f[g]=Math.max(f[g],1),g>0&&(f[g]+=f[g-1])}if(m&&p){let g=e,A=s;for(let y=0;y<i;++y)c[y]=y;return[g,[i,d],A,u,c]}else{let g=f[l-1],A=w.getArrayFromDType(n,g*d),y=w.getArrayFromDType(r,g),x=new Array(l).fill(0);for(let b=0;b<i;++b){let v=e[b*d],k=x[v],S=(v===0?0:f[v-1])+k;x[v]++;for(let C=0;C<d;++C)A[S*d+C]=e[b*d+C];y[S]=s[b],c[b]=S}for(let b=0;b<l;++b)if(x[b]===0){let k=b===0?0:f[b-1];A[k*d+0]=b;for(let S=1;S<d;++S)A[k*d+S]=0;y[k]=o}return[A,[g,d],y,u,c]}}function Rw(e,t,n,s,r){let a=w.sizeFromShape(s),o=t[0],i=r.length,l=[],u=1,c=-1;for(let g=0;g<i;++g){let A=r[g];if(A===-1){if(c!==-1)throw new Error(`only one output dimension may be -1, not both ${c} and ${g}`);c=g,l.push(1)}else{if(A<0)throw new Error(`size ${g} must be non-negative, not ${A}`);u*=A,l.push(A)}}if(c!==-1){if(u<=0)throw new Error("reshape cannot infer the missing input size for an empty tensor unless all specified input sizes are non-zero");let g=Math.trunc(a/u);if(u*g!==a)throw new Error(`Input to reshape is a SparseTensor with ${a}
|
|
dense values, but the requested shape requires a multiple of ${u}. inputShape=${s} outputShape= ${l}`);l[c]=g}let d=w.sizeFromShape(l);if(d!==a)throw new Error(`Input to reshape is a tensor with ${a} dense values, but the requested shape has ${d}. inputShape=${s} outputShape=${l}`);let p=s.length,h=[];if(p>0){h[p-1]=1;for(let g=p-2;g>=0;--g)h[g]=h[g+1]*s[g+1]}let f=[];if(i>0){f[i-1]=1;for(let g=i-2;g>=0;--g)f[g]=f[g+1]*l[g+1]}let m=w.getArrayFromDType(n,o*i);for(let g=0;g<o;++g){let A=0;for(let y=0;y<p;++y)A+=e[g*p+y]*h[y];for(let y=0;y<i;++y)m[g*i+y]=Math.trunc(A/f[y]),A%=f[y]}return[m,[o,i],l]}function K2(e,t,n,s,r,a=!1,o=0){let i=s.length;if(i!==r.length)throw new Error("segmentIds and indices should have same size.");let l=[t[0],e.length/t[0]],u=l[1],d=i>0?r[i-1]+1:0;if(d<0)throw new Error("segment ids must be >= 0");let p=t.slice();p[0]=d;let h=p.reduce((x,b)=>x*b,1),f=w.getArrayFromDType(n,h);if(i===0)return d>0&&f.fill(o),[f,p];if(d<=0)throw new Error("segment ids must be >= 0");let m=0,g=1,A=0,y=r[m];for(;;){let x=0;if(g<i){if(x=r[g],y===x){++g;continue}if(y>=x)throw new Error("segment ids are not increasing")}if(y<0||y>=d)throw new Error(`Segment id ${y} out of range [0, ${d}), possibly because segmentIds input is not sorted.`);y>A&&f.fill(o,A*u,y*u);for(let b=m;b<g;++b){let v=s[b];if(v<0||v>=l[0])throw new Error(`Bad: indices[${b}] == ${s[b]} out of range [0, ${l[0]})`);for(let k=0;k<u;k++)f[y*u+k]+=e[v*u+k]}if(a)for(let b=0;b<u;b++)f[y*u+b]/=g-m;if(m=g,++g,A=y+1,y=x,g>i)break}return A<d&&f.fill(o,A*u,d*u),[f,p]}var WW=va(e=>Math.sqrt(e)),VW=ct(ko,e=>Math.sqrt(e)),UW={kernelName:ko,backendName:"cpu",kernelFunc:VW},Dw=Gt((e,t)=>{let n=e-t;return n*n}),HW=cn(Co,Dw),GW={kernelName:Co,backendName:"cpu",kernelFunc:HW};function _w(e,t,n,s){let r=je(e,t.dtype);for(let a=0;a<r.size;a++){let o=r.indexToLoc(a),i=new Array(o.length);for(let l=0;l<i.length;l++)i[l]=o[l]*n[l]+s[l];r.set(t.get(...i),...o)}return r}var jW=class{constructor(e,t,n,s,r,a){this.separator=w.encodeString(e),this.nGramWidths=t,this.leftPad=w.encodeString(n),this.rightPad=w.encodeString(s),this.padWidth=r,this.preserveShort=a}getPadWidth(e){return Math.min(this.padWidth<0?e-1:this.padWidth,e-1)}getNumNGrams(e,t){let n=this.getPadWidth(t);return Math.max(0,e+2*n-t+1)}createNGrams(e,t,n,s,r,a){for(let o=0;o<r;++o){let i=this.getPadWidth(a),l=Math.max(0,i-o),u=Math.max(0,i-(r-(o+1))),c=a-(l+u),d=t+(l>0?0:o-i),p=0;p+=l*this.leftPad.length;for(let A=0;A<c;++A)p+=e[d+A].length;p+=u*this.rightPad.length,p+=(l+u+c-1)*this.separator.length,n[s+o]=new Uint8Array(p);let f=n[s+o],m=0,g=A=>A.forEach(y=>f[m++]=y);for(let A=0;A<l;++A)g(this.leftPad),g(this.separator);for(let A=0;A<c-1;++A)g(e[d+A]),g(this.separator);if(c>0){g(e[d+c-1]);for(let A=0;A<u;++A)g(this.separator),g(this.rightPad)}else{for(let A=0;A<u-1;++A)g(this.rightPad),g(this.separator);g(this.rightPad)}}}compute(e,t){let n=e.length,s=t.length;if(s>0){let i=t[0];if(i!==0)throw new Error(`First split value must be 0, got ${i}`);for(let l=1;l<s;++l){let u=t[l]>=i;if(u=u&&t[l]<=n,!u)throw new Error(`Invalid split value ${t[l]}, must be in [${i}, ${n}]`);i=t[l]}if(i!==n)throw new Error(`Last split value must be data size. Expected ${n}, got ${i}`)}let r=s-1,a=w.getArrayFromDType("int32",s);if(n===0||s===0){let i=new Array(n);for(let l=0;l<=r;++l)a[l]=0;return[i,a]}a[0]=0;for(let i=1;i<=r;++i){let l=t[i]-t[i-1],u=0;this.nGramWidths.forEach(c=>{u+=this.getNumNGrams(l,c)}),this.preserveShort&&l>0&&u===0&&(u=1),a[i]=a[i-1]+u}let o=new Array(a[r]);for(let i=0;i<r;++i){let l=t[i],u=a[i];if(this.nGramWidths.forEach(c=>{let d=t[i+1]-t[i],p=this.getNumNGrams(d,c);this.createNGrams(e,l,o,u,p,c),u+=p}),this.preserveShort&&u===a[i]){let c=t[i+1]-t[i];if(c===0)continue;let d=c+2*this.padWidth,p=1;this.createNGrams(e,l,o,u,p,d)}}return[o,a]}};function $w(e,t,n,s,r,a,o,i){return new jW(n,s,r,a,o,i).compute(e,t)}function qW(e,t,n,s){if(!e.length)return;if(t.length===0){for(let a=0;a<e.length;++a)s.push(e.subarray(a,a+1));return}if(t.length===1){let a=t[0],o=e.indexOf(a);for(;o!==-1;){let i=e.subarray(0,o);(!n||i.length!==0)&&s.push(i),e=e.subarray(o+1),o=e.indexOf(a)}(!n||e.length!==0)&&s.push(e);return}let r=0;for(let a=0;a<e.length+1;a++)if(a===e.length||t.indexOf(e[a])!==-1){let o=e.subarray(r,a);(!n||o.length!==0)&&s.push(o),r=a+1}}function Fw(e,t,n){let s=e.length,r=[],a=0,o=0,i=new Array(s);for(let p=0;p<s;++p){let h=r.length;qW(e[p],t,n,r);let f=r.length-h;i[p]=f,a+=f,o=Math.max(o,f)}let l=w.getArrayFromDType("int32",a*2),u=new Array(a),c=[s,o],d=0;for(let p=0;p<s;++p)for(let h=0;h<i[p];++h)l[d*2]=p,l[d*2+1]=h,u[d]=r[d],++d;return[l,u,c]}function Ow(e,t){let n=w.getArrayFromDType("int32",e.length);for(let s=0;s<e.length;++s)n[s]=w.fingerPrint64(e[s]).modulo(t).getLowBitsUnsigned();return n}var Pw=Gt((e,t)=>e-t),XW=U2((e,t,n,s)=>({real:e-n,imag:t-s})),Z2=cn(To,Pw,XW),KW={kernelName:To,backendName:"cpu",kernelFunc:Z2};function Mw(e,t){let n=new Array(e.rank);for(let r=0;r<n.length;r++)n[r]=e.shape[r]*t[r];let s=je(n,e.dtype);for(let r=0;r<s.values.length;++r){let a=s.indexToLoc(r),o=new Array(e.rank);for(let l=0;l<o.length;l++)o[l]=a[l]%e.shape[l];let i=e.locToIndex(o);s.values[r]=e.values[i]}return s}var ud=(e,t)=>{let n=t.value-e.value;return n===0?e.index-t.index:n};function zw(e,t,n=0,s=e.length-1){for(;s>n;){if(s-n>600){let i=s-n+1,l=t-n+1,u=Math.log(i),c=.5*Math.exp(2*u/3),d=.5*Math.sqrt(u*c*(i-c)/i)*Math.sign(l-i/2),p=Math.max(n,Math.floor(t-l*c/i+d)),h=Math.min(s,Math.floor(t+(i-l)*c/i+d));zw(e,t,p,h)}let r=e[t],a=n,o=s;for(w.swap(e,n,t),ud(e[s],r)>0&&w.swap(e,n,s);a<o;){for(w.swap(e,a,o),a++,o--;ud(e[a],r)<0;)a=a+1;for(;ud(e[o],r)>0;)o=o-1}ud(e[n],r)===0?w.swap(e,n,o):(o=o+1,w.swap(e,o,s)),o<=t&&(n=o+1),t<=o&&(s=o-1)}}function Lw(e,t,n,s,r){let a=t[t.length-1],[o,i]=[e.length/a,a],l=w.getTypedArrayFromDType(n,o*s),u=w.getTypedArrayFromDType("int32",o*s);for(let d=0;d<o;d++){let p=d*i,h=e.subarray(p,p+i),f=new Array(h.length);h.forEach((y,x)=>f[x]={value:y,index:x}),s<f.length&&(zw(f,s),f=f.slice(0,s)),r&&f.sort(ud);let m=d*s,g=l.subarray(m,m+s),A=u.subarray(m,m+s);for(let y=0;y<s;y++)g[y]=f[y].value,A[y]=f[y].index}let c=t.slice();return c[c.length-1]=s,[je(c,n,l),je(c,"int32",u)]}function Bw(e,t,n,s){let r=w.parseAxisParam(t,n)[0],a=[1,n[0],1];for(let f=0;f<r;f++)a[0]*=n[f];a[1]=n[r];for(let f=r+1;f<n.length;f++)a[2]*=n[f];let o={},i=new Int32Array(n[r]),l=new Kt(a,s,e),u=[],c=a[0]===1&&a[2]===1;for(let f=0;f<n[r];f++){let m;if(c)m=e[f].toString();else{let g=[];for(let A=0;A<a[0];A++)for(let y=0;y<a[2];y++)g.push(l.get(A,f,y));m=g.join(",")}if(o[m]!==void 0)i[f]=o[m];else{let g=Object.keys(o).length;o[m]=g,i[f]=g,u.push(f)}}let d=a.slice();d[1]=Object.keys(o).length;let p=new Kt(d,s);u.forEach((f,m)=>{for(let g=0;g<a[0];g++)for(let A=0;A<a[2];A++)p.set(l.get(g,f,A),g,m,A)});let h=n.slice();return h[r]=d[1],{outputValues:p.values,outputShape:h,indices:i}}Vl("cpu",()=>new V2,1);var Ww=ct(qa,e=>e>=0?e:Math.exp(e)-1),ZW={kernelName:qa,backendName:"cpu",kernelFunc:Ww};function Vw(e){let{inputs:t,backend:n,attrs:s}=e,{x:r}=t,{alpha:a}=s;Se([r],"leakyRelu");let o=w.sizeFromShape(r.shape),i=n.data.get(r.dataId).values,l=w.getTypedArrayFromDType("float32",o);for(let u=0;u<i.length;u++)l[u]=i[u]<0?a*i[u]:i[u];return n.makeTensorInfo(r.shape,"float32",l)}var YW={kernelName:eo,backendName:"cpu",kernelFunc:Vw},JW=Gt((e,t)=>e<0?t*e:e);function Uw(e){let{inputs:t,backend:n}=e,{x:s,alpha:r}=t;Se([s,r],"prelu");let a=n.data.get(s.dataId).values,o=n.data.get(r.dataId).values,[i,l]=JW(s.shape,r.shape,a,o,s.dtype);return n.makeTensorInfo(l,s.dtype,i)}var QW={kernelName:fo,backendName:"cpu",kernelFunc:Uw},Hw=ct(mo,e=>Math.max(0,e)),eV={kernelName:mo,backendName:"cpu",kernelFunc:Hw},Gw=ct(Ao,e=>Math.min(Math.max(0,e),6)),tV={kernelName:Ao,backendName:"cpu",kernelFunc:Gw};function Y2(e,t,n,s,r){if(n==="linear")return fr({inputs:{x:t},backend:e});if(n==="relu")return Hw({inputs:{x:t},backend:e});if(n==="elu")return Ww({inputs:{x:t},backend:e});if(n==="relu6")return Gw({inputs:{x:t},backend:e});if(n==="prelu")return Uw({inputs:{x:t,alpha:s},backend:e});if(n==="leakyrelu")return Vw({inputs:{x:t},backend:e,attrs:{alpha:r}});if(n==="sigmoid")return Nw({inputs:{x:t},backend:e});throw new Error(`Activation ${n} has not been implemented for the CPU backend.`)}function wt(e){let{inputs:t,backend:n,attrs:s}=e,{x:r}=t,{shape:a}=s,o=w.sizeFromShape(r.shape),i=w.inferFromImplicitShape(a,o),l=w.sizeFromShape(i);w.assert(o===l,()=>`The new shape (${i}) has ${l} elements and the old shape (${r.shape}) has ${o} elements. The new shape and old shape must have the same number of elements.`),n.incRef(r.dataId);let u=n.data.get(r.dataId);if(u.complexTensorInfos!=null){let c=u.complexTensorInfos.real,d=u.complexTensorInfos.imag;c.shape=i,d.shape=i}return{dataId:r.dataId,shape:i,dtype:r.dtype}}var nV={kernelName:xl,backendName:"cpu",kernelFunc:wt};function jw(e){let{inputs:t,backend:n,attrs:s}=e,{a:r,b:a}=t,{transposeA:o,transposeB:i}=s;Se([r,a],"matMul");let l=r.shape.length,u=a.shape.length,c=o?r.shape[l-2]:r.shape[l-1],d=i?a.shape[u-1]:a.shape[u-2],p=o?r.shape[l-1]:r.shape[l-2],h=i?a.shape[u-2]:a.shape[u-1],f=r.shape.slice(0,-2),m=a.shape.slice(0,-2),g=w.sizeFromShape(f),A=w.sizeFromShape(m),y=g===A||g===1||A===1;w.assert(l>=2&&u>=2&&y,()=>`Error in matMul: the input batch dimensions must either be the same or at least one input batch dimension must be 1. Got input batch dimensions of (${f}) and (${m}).`);let b=(g>A?r.shape.slice(0,-2):a.shape.slice(0,-2)).concat([p,h]);w.assert(c===d,()=>`Error in matMul: inner shapes (${c}) and (${d}) of Tensors with shapes ${r.shape} and ${a.shape} and transposeA=${o} and transposeB=${i} must match.`);let v=o?[g,c,p]:[g,p,c],k=i?[A,h,d]:[A,d,h],S=wt({inputs:{x:r},backend:n,attrs:{shape:v}}),C=wt({inputs:{x:a},backend:n,attrs:{shape:k}}),D=o?S.shape[1]:S.shape[2],O=o?S.shape[2]:S.shape[1],E=i?C.shape[1]:C.shape[2],R=Math.max(g,A),T=n.data.get(S.dataId).values,P=n.data.get(C.dataId).values,U=w.computeStrides(S.shape),j=w.computeStrides(C.shape),[q,X,te]=o?[U[0],1,U[1]]:[U[0],U[1],1],[ne,se,re]=i?[1,j[1],j[0]]:[j[1],1,j[0]],Q=O*E,ue=je([R,O,E],S.dtype),ce=ue.values,fe=n.blockSize;for(let xe=0;xe<R;xe++)for(let Ne=0;Ne<O;Ne+=fe)for(let Ee=0;Ee<E;Ee+=fe)for(let Oe=0;Oe<D;Oe+=fe){let Be=Math.min(Ne+fe,O),Me=Math.min(Ee+fe,E),ht=Math.min(Oe+fe,D);for(let at=Ne;at<Be;at++)for(let ot=Ee;ot<Me;ot++){let st=0;for(let dt=Oe;dt<ht;dt++){let Xe=Math.min(xe,g-1)*q,Pn=Math.min(xe,A-1)*re,Et=T[Xe+at*X+dt*te],Zn=P[dt*ne+ot*se+Pn];st+=Et*Zn}ce[xe*Q+(at*E+ot)]+=st}}return n.disposeIntermediateTensorInfo(S),n.disposeIntermediateTensorInfo(C),n.makeTensorInfo(b,ue.dtype,ue.values)}var sV={kernelName:Ma,backendName:"cpu",kernelFunc:jw};function rV(e){let{inputs:t,backend:n,attrs:s}=e,{a:r,b:a,bias:o,preluActivationWeights:i}=t,{transposeA:l,transposeB:u,activation:c,leakyreluAlpha:d}=s,p,h,f,m=[];p=jw({inputs:{a:r,b:a},attrs:{transposeA:l,transposeB:u},backend:n}),o&&(h=ld({inputs:{a:p,b:o},backend:n}),m.push(p),p=h),c&&(f=Y2(n,p,c,i,d),m.push(p),p=f);for(let A of m)n.disposeIntermediateTensorInfo(A);return p}var aV={kernelName:Do,backendName:"cpu",kernelFunc:rV},oV=ct(Oi,e=>Math.acos(e)),iV={kernelName:Oi,backendName:"cpu",kernelFunc:oV},lV=ct(Pi,e=>Math.acosh(e)),uV={kernelName:Pi,backendName:"cpu",kernelFunc:lV};function cV(e){let{inputs:t,backend:n}=e,s=t;Se(t,"addN");let r=s.map(i=>n.data.get(i.dataId).values),a=je(s[0].shape,s[0].dtype),o=a.values;for(let i=0;i<s.length;i++){let l=r[i];for(let u=0;u<o.length;u++)o[u]+=l[u]}return n.makeTensorInfo(a.shape,a.dtype,a.values)}var dV={kernelName:Fa,backendName:"cpu",kernelFunc:cV};function pV(e){let{inputs:t,backend:n,attrs:s}=e,{x:r}=t,{axis:a,keepDims:o}=s;Se(r,"all");let i=w.parseAxisParam(a,r.shape),l=i,u=_.getAxesPermutation(l,r.shape.length),c=r;u!=null&&(c=ws({inputs:{x:r},backend:n,attrs:{perm:u}}),l=_.getInnerMostAxes(l.length,r.shape.length)),_.assertAxesAreInnerMostDims("all",l,c.shape.length);let[d,p]=_.computeOutAndReduceShapes(c.shape,l),h=w.sizeFromShape(p),f=w.makeZerosTypedArray(w.sizeFromShape(d),c.dtype),m=n.data.get(c.dataId).values;for(let A=0;A<f.length;++A){let y=A*h,x=m[y];for(let b=0;b<h;++b){let v=m[y+b];x=x&&v}f[A]=x}u!=null&&n.disposeIntermediateTensorInfo(c);let g=n.makeTensorInfo(d,c.dtype,f);if(o){let A=_.expandShapeToKeepDim(d,i),y=wt({inputs:{x:g},backend:n,attrs:{shape:A}});return n.disposeIntermediateTensorInfo(g),y}return g}var hV={kernelName:Mi,backendName:"cpu",kernelFunc:pV};function fV(e){let{inputs:t,backend:n,attrs:s}=e,{x:r}=t,{axis:a,keepDims:o}=s;Se(r,"any");let i=w.parseAxisParam(a,r.shape),l=i,u=_.getAxesPermutation(l,r.shape.length),c=r;u!=null&&(c=ws({inputs:{x:r},backend:n,attrs:{perm:u}}),l=_.getInnerMostAxes(l.length,r.shape.length)),_.assertAxesAreInnerMostDims("any",l,c.shape.length);let[d,p]=_.computeOutAndReduceShapes(c.shape,l),h=w.sizeFromShape(p),f=w.makeZerosTypedArray(w.sizeFromShape(d),c.dtype),m=n.data.get(c.dataId).values;for(let A=0;A<f.length;++A){let y=A*h,x=m[y];for(let b=0;b<h;++b){let v=m[y+b];x=x||v}f[A]=x}u!=null&&n.disposeIntermediateTensorInfo(c);let g=n.makeTensorInfo(d,c.dtype,f);if(o){let A=_.expandShapeToKeepDim(d,i),y=wt({inputs:{x:g},backend:n,attrs:{shape:A}});return n.disposeIntermediateTensorInfo(g),y}return g}var mV={kernelName:zi,backendName:"cpu",kernelFunc:fV};function gV(e){let{inputs:t,backend:n,attrs:s}=e,{x:r}=t,{axis:a}=s;Se(r,"argMax");let o=w.parseAxisParam(a,r.shape),i=_.getAxesPermutation(o,r.shape.length),l=r,u=[];i!=null&&(l=ws({inputs:{x:r},backend:n,attrs:{perm:i}}),u.push(l),o=_.getInnerMostAxes(o.length,l.shape.length)),o=[o[0]],_.assertAxesAreInnerMostDims("argMax",o,l.shape.length);let[c,d]=_.computeOutAndReduceShapes(l.shape,o),p=w.sizeFromShape(c),h=w.makeZerosTypedArray(p,"int32"),f=w.sizeFromShape(d),m=n.data.get(l.dataId).values;for(let g=0;g<h.length;++g){let A=g*f,y=m[A],x=0;for(let b=0;b<f;++b){let v=m[A+b];v>y&&(y=v,x=b)}h[g]=x}return u.forEach(g=>n.disposeIntermediateTensorInfo(g)),n.makeTensorInfo(c,"int32",h)}var AV={kernelName:Oa,backendName:"cpu",kernelFunc:gV};function yV(e){let{inputs:t,backend:n,attrs:s}=e,{x:r}=t,{axis:a}=s;Se(r,"argMin");let o=w.parseAxisParam(a,r.shape),i=_.getAxesPermutation(o,r.shape.length),l=r,u=[];i!=null&&(l=ws({inputs:{x:r},backend:n,attrs:{perm:i}}),u.push(l),o=_.getInnerMostAxes(o.length,l.shape.length)),o=[o[0]],_.assertAxesAreInnerMostDims("argMin",o,l.shape.length);let[c,d]=_.computeOutAndReduceShapes(l.shape,o),p=w.sizeFromShape(c),h=w.makeZerosTypedArray(p,"int32"),f=w.sizeFromShape(d),m=n.data.get(l.dataId).values;for(let g=0;g<h.length;++g){let A=g*f,y=m[A],x=0;for(let b=0;b<f;++b){let v=m[A+b];v<y&&(y=v,x=b)}h[g]=x}return u.forEach(g=>n.disposeIntermediateTensorInfo(g)),n.makeTensorInfo(c,"int32",h)}var xV={kernelName:Zu,backendName:"cpu",kernelFunc:yV},bV=ct(Li,e=>Math.asin(e)),vV={kernelName:Li,backendName:"cpu",kernelFunc:bV},wV=ct(Bi,e=>Math.asinh(e)),kV={kernelName:Bi,backendName:"cpu",kernelFunc:wV},IV=ct(Wi,e=>Math.atan(e)),SV={kernelName:Wi,backendName:"cpu",kernelFunc:IV},CV=Gt((e,t)=>Math.atan2(e,t)),TV=cn(Ui,CV),NV={kernelName:Ui,backendName:"cpu",kernelFunc:TV},EV=ct(Vi,e=>Math.atanh(e)),RV={kernelName:Vi,backendName:"cpu",kernelFunc:EV};function J2(e,t,n,s,r,a){let o=r.strideHeight,i=r.strideWidth,l=r.dilationHeight,u=r.dilationWidth,c=r.effectiveFilterHeight,d=r.effectiveFilterWidth,p=r.padInfo.top,h=r.padInfo.left,f=a==="max"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,m=je(r.outShape,n),g=m.values,A=r.outShape[1]*r.outShape[2]*r.outShape[3],y=r.outShape[2]*r.outShape[3],x=r.outShape[3];for(let b=0;b<r.batchSize;++b){let v=b*A,k=b*s[0];for(let S=0;S<r.inChannels;++S)for(let C=0;C<r.outHeight;++C){let D=C*o-p,O=Math.max(0,D),E=Math.min(r.inHeight,c+D),R=v+C*y;for(let T=0;T<r.outWidth;++T){let P=T*i-h,U=Math.max(0,P),j=Math.min(r.inWidth,d+P),q=f,X=0,te=0;for(let se=O;se<E;se+=l){let re=k+se*s[1];for(let Q=U;Q<j;Q+=u){let ue=re+Q*s[2],ce=e[ue+S];a==="max"&&ce>q?q=ce:a==="avg"&&(X+=ce,te++)}if(isNaN(q))break}let ne=R+T*x+S;g[ne]=a==="avg"?X/te:q}}}return m}function qw(e,t,n,s,r=!1,a=!1){let o=je(s.outShape,"int32"),i=s.strideHeight,l=s.strideWidth,u=s.dilationHeight,c=s.dilationWidth,d=s.effectiveFilterHeight,p=s.effectiveFilterWidth,h=s.padInfo.top,f=s.padInfo.left,m=je(t,n,e);for(let g=0;g<s.batchSize;++g)for(let A=0;A<s.inChannels;++A)for(let y=0;y<s.outHeight;++y){let x=y*i-h,b=x;for(;b<0;)b+=u;let v=Math.min(s.inHeight,d+x);for(let k=0;k<s.outWidth;++k){let S=k*l-f,C=S;for(;C<0;)C+=c;let D=Math.min(s.inWidth,p+S),O=Number.NEGATIVE_INFINITY,E=-1;for(let R=b;R<v;R+=u){let T=R-x;for(let P=C;P<D;P+=c){let U=P-S,j=m.get(g,R,P,A);j>O&&(O=j,r?E=a?((g*s.inHeight+R)*s.inWidth+P)*s.inChannels+A:(R*s.inWidth+P)*s.inChannels+A:E=T*p+U)}}o.set(E,g,y,k,A)}}return o}function Xw(e,t,n,s,r,a){let o=r.strideDepth,i=r.strideHeight,l=r.strideWidth,u=r.dilationDepth,c=r.dilationHeight,d=r.dilationWidth,p=r.effectiveFilterDepth,h=r.effectiveFilterHeight,f=r.effectiveFilterWidth,m=r.padInfo.front,g=r.padInfo.top,A=r.padInfo.left,y=a==="max"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,x=je(r.outShape,n),b=x.values,v=r.outShape[1]*r.outShape[2]*r.outShape[3]*r.outShape[4],k=r.outShape[2]*r.outShape[3]*r.outShape[4],S=r.outShape[3]*r.outShape[4],C=r.outShape[4];for(let D=0;D<r.batchSize;++D){let O=D*v,E=D*s[0];for(let R=0;R<r.inChannels;++R)for(let T=0;T<r.outDepth;++T){let P=T*o-m,U=P;for(;U<0;)U+=u;let j=Math.min(r.inDepth,p+P),q=O+T*k;for(let X=0;X<r.outHeight;++X){let te=X*i-g,ne=te;for(;ne<0;)ne+=c;let se=Math.min(r.inHeight,h+te),re=q+X*S;for(let Q=0;Q<r.outWidth;++Q){let ue=Q*l-A,ce=ue;for(;ce<0;)ce+=d;let fe=Math.min(r.inWidth,f+ue),xe=re+Q*C,Ne=y,Ee=0,Oe=0;for(let Me=U;Me<j;Me+=u){let ht=E+Me*s[1];for(let at=ne;at<se;at+=c){let ot=ht+at*s[2];for(let st=ce;st<fe;st+=d){let dt=ot+st*s[3],Xe=e[dt+R];if(a==="max"&&Xe>Ne?Ne=Xe:a==="avg"&&(Ee+=Xe,Oe++),isNaN(Ne))break}if(isNaN(Ne))break}if(isNaN(Ne))break}let Be=xe+R;b[Be]=a==="avg"?Ee/Oe:Ne}}}}return x}function DV(e,t){let n=je(t.outShape,"int32"),s=t.strideDepth,r=t.strideHeight,a=t.strideWidth,o=t.dilationDepth,i=t.dilationHeight,l=t.dilationWidth,u=t.effectiveFilterDepth,c=t.effectiveFilterHeight,d=t.effectiveFilterWidth,p=t.padInfo.front,h=t.padInfo.top,f=t.padInfo.left;for(let m=0;m<t.batchSize;++m)for(let g=0;g<t.inChannels;++g)for(let A=0;A<t.outDepth;++A){let y=A*s-p,x=y;for(;x<0;)x+=o;let b=Math.min(t.inDepth,u+y);for(let v=0;v<t.outHeight;++v){let k=v*r-h,S=k;for(;S<0;)S+=i;let C=Math.min(t.inHeight,c+k);for(let D=0;D<t.outWidth;++D){let O=D*a-f,E=O;for(;E<0;)E+=l;let R=Math.min(t.inWidth,d+O),T=Number.NEGATIVE_INFINITY,P=-1;for(let U=x;U<b;U+=o){let j=U-y;for(let q=S;q<C;q+=i){let X=q-k;for(let te=E;te<R;te+=l){let ne=te-O,se=e.get(m,U,q,te,g);se>=T&&(T=se,P=j*c*d+X*c+ne)}}}n.set(P,m,A,v,D,g)}}}return n}function _V(e){let{inputs:t,backend:n,attrs:s}=e,{x:r}=t;Se(r,"avgPool");let{filterSize:a,strides:o,pad:i,dimRoundingMode:l}=s,u=1;w.assert(_.eitherStridesOrDilationsAreOne(o,u),()=>`Error in avgPool: Either strides or dilations must be 1. Got strides ${o} and dilations '${u}'`);let c=_.computePool2DInfo(r.shape,a,o,u,i,l),d;if(c.filterWidth===1&&c.filterHeight===1&&w.arraysEqual(c.inShape,c.outShape))d=fr({inputs:{x:r},backend:n});else{let p=n.data.get(r.dataId).values,h=w.computeStrides(r.shape),f=J2(p,r.shape,r.dtype,h,c,"avg");d=n.makeTensorInfo(c.outShape,r.dtype,f.values)}return d}var $V={kernelName:Pa,backendName:"cpu",kernelFunc:_V};function FV(e){let{inputs:t,backend:n,attrs:s}=e,{x:r}=t,{filterSize:a,strides:o,pad:i,dimRoundingMode:l,dataFormat:u}=s;Se(r,"avgPool3d");let c=_.computePool3DInfo(r.shape,a,o,1,i,l,u),d=n.data.get(r.dataId).values,p=Xw(d,r.shape,r.dtype,w.computeStrides(r.shape),c,"avg");return n.makeTensorInfo(p.shape,"float32",p.values)}var OV={kernelName:Yu,backendName:"cpu",kernelFunc:FV};function PV(e){let{inputs:t,backend:n,attrs:s}=e,{dy:r,input:a}=t,{filterSize:o,strides:i,pad:l,dimRoundingMode:u}=s;Se([r,a],"avgPool3DGrad");let c=_.computePool3DInfo(a.shape,o,i,1,l,u),d=c.strideDepth,p=c.strideHeight,h=c.strideWidth,f=c.filterDepth,m=c.filterHeight,g=c.filterWidth,A=c.dilationDepth,y=c.dilationHeight,x=c.dilationWidth,b=c.effectiveFilterDepth,v=c.effectiveFilterHeight,k=c.effectiveFilterWidth,S=b-1-c.padInfo.front,C=k-1-c.padInfo.left,D=v-1-c.padInfo.top,O=je(a.shape,"float32"),E=1/(f*m*g),R=n.bufferSync(r);for(let T=0;T<c.batchSize;++T)for(let P=0;P<c.inChannels;++P)for(let U=0;U<c.inDepth;++U)for(let j=0;j<c.inHeight;++j)for(let q=0;q<c.inWidth;++q){let X=U-S,te=j-D,ne=q-C,se=0;for(let re=0;re<b;re+=A){let Q=(X+re)/d;if(!(Q<0||Q>=c.outDepth||Math.floor(Q)!==Q))for(let ue=0;ue<v;ue+=y){let ce=(te+ue)/p;if(!(ce<0||ce>=c.outHeight||Math.floor(ce)!==ce))for(let fe=0;fe<k;fe+=x){let xe=(ne+fe)/h;if(xe<0||xe>=c.outWidth||Math.floor(xe)!==xe)continue;se+=R.get(T,Q,ce,xe,P)}}}O.set(se*E,T,U,j,q,P)}return n.makeTensorInfo(O.shape,O.dtype,O.values)}var MV={kernelName:mp,backendName:"cpu",kernelFunc:PV};function zV(e){let{inputs:t,backend:n,attrs:s}=e,{dy:r,input:a}=t,o=a;Se([r,a],"avgPoolGrad");let{filterSize:i,strides:l,pad:u}=s,c=_.computePool2DInfo(o.shape,i,l,1,u),d=c.strideHeight,p=c.strideWidth,h=c.filterHeight,f=c.filterWidth,m=c.dilationHeight,g=c.dilationWidth,A=c.effectiveFilterHeight,y=c.effectiveFilterWidth,x=y-1-c.padInfo.left,b=A-1-c.padInfo.top,v=je(o.shape,"float32"),k=1/(h*f),S=n.data.get(r.dataId).values,C=je(r.shape,"float32",S);for(let D=0;D<c.batchSize;++D)for(let O=0;O<c.inChannels;++O)for(let E=0;E<c.inHeight;++E)for(let R=0;R<c.inWidth;++R){let T=E-b,P=R-x,U=0;for(let j=0;j<A;j+=m){let q=(T+j)/d;if(!(q<0||q>=c.outHeight||Math.floor(q)!==q))for(let X=0;X<y;X+=g){let te=(P+X)/p;if(te<0||te>=c.outWidth||Math.floor(te)!==te)continue;U+=C.get(D,q,te,O)}}v.set(U*k,D,E,R,O)}return n.makeTensorInfo(v.shape,v.dtype,v.values)}var LV={kernelName:fp,backendName:"cpu",kernelFunc:zV};function BV(e){let{inputs:t,backend:n,attrs:s}=e,{x:r,scale:a,offset:o,mean:i,variance:l}=t;w.assert(i.shape.length===l.shape.length,()=>"Batch normalization gradient requires mean and variance to have equal ranks."),w.assert(o==null||i.shape.length===o.shape.length,()=>"Batch normalization gradient requires mean and offset to have equal ranks."),w.assert(a==null||i.shape.length===a.shape.length,()=>"Batch normalization gradient requires mean and scale to have equal ranks."),Se([r,i,l,a,o],"batchNorm");let{varianceEpsilon:u}=s;u==null&&(u=.001);let c=n.data.get(r.dataId).values,d=n.data.get(i.dataId).values,p=n.data.get(l.dataId).values,h=a?n.data.get(a.dataId).values:new Float32Array([1]),f=o?n.data.get(o.dataId).values:new Float32Array([0]),m=new Float32Array(c.length),g=f.length,A=h.length,y=p.length,x=d.length,b=0,v=0,k=0,S=0;for(let C=0;C<c.length;++C)m[C]=f[b++]+(c[C]-d[v++])*h[k++]/Math.sqrt(p[S++]+u),b>=g&&(b=0),v>=x&&(v=0),k>=A&&(k=0),S>=y&&(S=0);return n.makeTensorInfo(r.shape,r.dtype,m)}var WV={kernelName:Ya,backendName:"cpu",kernelFunc:BV};function VV(e){let{inputs:t,backend:n,attrs:s}=e,{x:r}=t,{blockShape:a,crops:o}=s;Se([r],"batchToSpaceND");let i=a.reduce((A,y)=>A*y),l=_.getReshaped(r.shape,a,i),u=_.getPermuted(l.length,a.length),c=_.getReshapedPermuted(r.shape,a,i),d=_.getSliceBeginCoords(o,a.length),p=_.getSliceSize(c,o,a.length),h=wt({inputs:{x:r},backend:n,attrs:{shape:l}}),f=ws({inputs:{x:h},backend:n,attrs:{perm:u}}),m=wt({inputs:{x:f},backend:n,attrs:{shape:c}}),g=oi({inputs:{x:m},backend:n,attrs:{begin:d,size:p}});return n.disposeIntermediateTensorInfo(h),n.disposeIntermediateTensorInfo(f),n.disposeIntermediateTensorInfo(m),g}var UV={kernelName:Hi,backendName:"cpu",kernelFunc:VV};function HV(e){let{inputs:t,backend:n,attrs:s}=e,{x:r,weights:a}=t,{size:o}=s,i=n.data.get(r.dataId).values,l=n.data.get(a.dataId).values,u=H2(i,l,a.dtype,a.shape,o);return n.makeTensorInfo([o],a.dtype,u)}var GV={kernelName:gp,backendName:"cpu",kernelFunc:HV};function jV(e){let{inputs:t,backend:n}=e,{s0:s,s1:r}=t,a=n.data.get(s.dataId).values,o=n.data.get(r.dataId).values,i=_.assertAndGetBroadcastShape(Array.from(a),Array.from(o));return n.makeTensorInfo([i.length],"int32",Int32Array.from(i))}var qV={kernelName:pg,backendName:"cpu",kernelFunc:jV},XV=ct(Jr,(e,t)=>{let n=t;return e>n.clipValueMax?n.clipValueMax:e<n.clipValueMin?n.clipValueMin:e}),KV={kernelName:Jr,backendName:"cpu",kernelFunc:XV},ZV=e=>{let{x:t}=e.inputs,n=e.backend,s=new Float32Array(w.sizeFromShape(t.shape)),r=n.data.get(t.dataId),a=r.complexTensorInfos.real,o=r.complexTensorInfos.imag,i=n.data.get(a.dataId).values,l=n.data.get(o.dataId).values;for(let u=0;u<i.length;u++){let c=i[u],d=l[u];s[u]=Math.hypot(c,d)}return n.makeOutput(s,t.shape,"float32")},YV={kernelName:Ju,backendName:"cpu",kernelFunc:ZV};function pu(e){let{inputs:t,backend:n}=e,{input:s}=t,r=n.data.get(s.dataId).complexTensorInfos.imag,a=n.data.get(r.dataId).values;return n.makeTensorInfo(r.shape,r.dtype,a)}var JV={kernelName:Dp,backendName:"cpu",kernelFunc:pu};function hu(e){let{inputs:t,backend:n,attrs:s}=e,{axis:r}=s,a=w.parseAxisParam(r,t[0].shape)[0],o=_.computeOutShape(t.map(m=>m.shape),a);if(w.sizeFromShape(o)===0)return n.makeTensorInfo(o,t[0].dtype,[]);let i=t.filter(m=>w.sizeFromShape(m.shape)>0);if(i.length===1)return fr({inputs:{x:i[0]},backend:n});let l=i.map(m=>m.shape);if(_.assertParamsConsistent(l,a),i[0].dtype==="complex64"){let m=i.map(b=>ai({inputs:{input:b},backend:n})),g=i.map(b=>pu({inputs:{input:b},backend:n})),A=hu({inputs:m,backend:n,attrs:{axis:a}}),y=hu({inputs:g,backend:n,attrs:{axis:a}}),x=cs({inputs:{real:A,imag:y},backend:n});return m.forEach(b=>n.disposeIntermediateTensorInfo(b)),g.forEach(b=>n.disposeIntermediateTensorInfo(b)),n.disposeIntermediateTensorInfo(A),n.disposeIntermediateTensorInfo(y),x}let u=i.map(m=>{let g=w.sizeFromShape(m.shape.slice(a));return wt({inputs:{x:m},backend:n,attrs:{shape:[-1,g]}})}),c=u.map(m=>({vals:n.data.get(m.dataId).values,shape:m.shape}));o=_.computeOutShape(u.map(m=>m.shape),1);let d=u[0].shape[0]===1,p=G2(c,o,t[0].dtype,d),h=_.computeOutShape(i.map(m=>m.shape),a),f=n.makeTensorInfo(h,t[0].dtype,p);return u.forEach(m=>n.disposeIntermediateTensorInfo(m)),f}var QV={kernelName:Gi,backendName:"cpu",kernelFunc:hu};function Kw(e){let{inputs:t,backend:n,attrs:s}=e,{x:r,filter:a}=t,{strides:o,pad:i,dataFormat:l,dilations:u,dimRoundingMode:c}=s;Se([r,a],"conv2d");let d=_.convertConv2DDataFormat(l),p=_.computeConv2DInfo(r.shape,a.shape,o,u,i,c,!1,d),h=p.filterHeight,f=p.filterWidth,m=p.dilationHeight,g=p.dilationWidth,A=p.padInfo.left,y=p.padInfo.top,x=p.dataFormat==="channelsLast",b=new Kt(p.outShape,r.dtype),v=w.computeStrides(r.shape),k=w.computeStrides(a.shape),S=v[0],C=x?v[1]:v[2],D=x?v[2]:1,O=x?1:v[1],E=b.strides[0],R=x?b.strides[1]:b.strides[2],T=x?b.strides[2]:1,P=x?1:b.strides[1],U=n.data.get(r.dataId).values,j=n.data.get(a.dataId).values,q=b.values;for(let X=0;X<p.batchSize;++X){let te=X*S,ne=X*E;for(let se=0;se<p.outHeight;++se){let re=ne+se*R,Q=se*p.strideHeight-y;for(let ue=0;ue<h;++ue){let ce=Q+ue*m;if(ce<0||ce>=p.inHeight)continue;let fe=ue*k[0],xe=te+ce*C;for(let Ne=0;Ne<p.outWidth;++Ne){let Ee=re+Ne*T,Oe=Ne*p.strideWidth-A;for(let Be=0;Be<f;++Be){let Me=Oe+Be*g;if(Me<0||Me>=p.inWidth)continue;let ht=fe+Be*k[1],at=xe+Me*D,ot=ht;for(let st=0;st<p.inChannels;++st){let dt=U[at+st*O];for(let Xe=0;Xe<p.outChannels;++Xe)q[Ee+Xe*P]+=dt*j[ot+Xe];ot+=p.outChannels}}}}}}return n.makeTensorInfo(b.shape,b.dtype,q)}var eU={kernelName:Ba,backendName:"cpu",kernelFunc:Kw};function tU(e){let{inputs:t,backend:n,attrs:s}=e,{x:r,dy:a}=t,{strides:o,pad:i,dataFormat:l,dimRoundingMode:u,filterShape:c}=s;Se([r,a],"conv2dBackpropFilter");let d=_.convertConv2DDataFormat(l),p=_.computeConv2DInfo(r.shape,c,o,1,i,u,!1,d),{strideHeight:h,strideWidth:f,filterHeight:m,filterWidth:g}=p,A=p.dataFormat==="channelsLast",y=new Kt(p.filterShape,"float32"),x=p.padInfo.left,b=p.padInfo.top,v=n.data.get(r.dataId).values,k=n.data.get(a.dataId).values,S=new Kt(r.shape,r.dtype,v),C=new Kt(a.shape,a.dtype,k);for(let D=0;D<m;++D){let O=Math.max(0,Math.ceil((b-D)/h)),E=Math.min(p.outHeight,(p.inHeight+b-D)/h);for(let R=0;R<g;++R){let T=Math.max(0,Math.ceil((x-R)/f)),P=Math.min(p.outWidth,(p.inWidth+x-R)/f);for(let U=0;U<p.inChannels;++U)for(let j=0;j<p.outChannels;++j){let q=0;for(let X=0;X<p.batchSize;++X)for(let te=O;te<E;++te){let ne=D+te*h-b;for(let se=T;se<P;++se){let re=R+se*f-x;A?q+=S.get(X,ne,re,U)*C.get(X,te,se,j):q+=S.get(X,U,ne,re)*C.get(X,j,te,se)}}y.set(q,D,R,U,j)}}}return n.makeTensorInfo(y.shape,y.dtype,y.values)}var nU={kernelName:yp,backendName:"cpu",kernelFunc:tU};function sU(e){let{inputs:t,backend:n,attrs:s}=e,{dy:r,filter:a}=t,{inputShape:o,strides:i,pad:l,dataFormat:u,dimRoundingMode:c}=s;Se([r,a],"conv2dBackpropInput");let d=w.computeStrides(a.shape),p=w.computeStrides(r.shape),h=_.convertConv2DDataFormat(u),f=_.computeConv2DInfo(o,a.shape,i,1,l,c,!1,h),m=new Kt(f.inShape,"float32"),g=m.values,A=n.data.get(r.dataId).values,y=n.data.get(a.dataId).values,[x,b,v]=d,{batchSize:k,filterHeight:S,filterWidth:C,inChannels:D,inHeight:O,inWidth:E,outChannels:R,outHeight:T,outWidth:P,strideHeight:U,strideWidth:j}=f;h=f.dataFormat;let q=S-1-f.padInfo.top,X=C-1-f.padInfo.left,te=h==="channelsLast",ne=m.strides[0],se=te?m.strides[1]:m.strides[2],re=te?m.strides[2]:1,Q=te?1:m.strides[1],ue=p[0],ce=te?p[1]:p[2],fe=te?p[2]:1,xe=te?1:p[1];for(let Ne=0;Ne<k;++Ne)for(let Ee=0;Ee<D;++Ee)for(let Oe=0;Oe<O;++Oe){let Be=Oe-q,Me=Math.max(0,Math.ceil(Be/U)),ht=Math.min(T,(S+Be)/U);for(let at=0;at<E;++at){let ot=at-X,st=Math.max(0,Math.ceil(ot/j)),dt=Math.min(P,(C+ot)/j),Xe=0;for(let Et=Me;Et<ht;++Et){let Zn=Et*U-Be;for(let dn=st;dn<dt;++dn){let Ns=dn*j-ot,wn=ue*Ne+ce*Et+fe*dn,fs=x*(S-1-Zn)+b*(C-1-Ns)+v*Ee;for(let ms=0;ms<R;++ms){let pn=A[wn+xe*ms],gs=y[fs+ms];Xe+=pn*gs}}}let Pn=ne*Ne+se*Oe+re*at+Q*Ee;g[Pn]=Xe}}return n.makeTensorInfo(m.shape,m.dtype,m.values)}var rU={kernelName:Wa,backendName:"cpu",kernelFunc:sU};function aU(e){let{inputs:t,backend:n,attrs:s}=e,{x:r,filter:a}=t,{strides:o,pad:i,dilations:l}=s;Se([r,a],"conv3d");let u=_.computeConv3DInfo(r.shape,a.shape,o,l,i),{filterDepth:c,filterHeight:d,filterWidth:p,dilationDepth:h,dilationHeight:f,dilationWidth:m,padInfo:g}=u,A=g.front,y=g.left,x=g.top,b=new Kt(u.outShape,r.dtype),v=n.data.get(r.dataId).values,k=n.data.get(a.dataId).values,S=b.values,C=w.computeStrides(r.shape),D=w.computeStrides(a.shape);for(let O=0;O<u.batchSize;++O){let E=O*C[0],R=O*b.strides[0];for(let T=0;T<u.outDepth;++T){let P=R+T*b.strides[1],U=T*u.strideDepth-A;for(let j=0;j<c;++j){let q=U+j*h;if(q<0||q>=u.inDepth)continue;let X=j*D[0],te=E+q*C[1];for(let ne=0;ne<u.outHeight;++ne){let se=P+ne*b.strides[2],re=ne*u.strideHeight-x;for(let Q=0;Q<d;++Q){let ue=re+Q*f;if(ue<0||ue>=u.inHeight)continue;let ce=X+Q*D[1],fe=te+ue*C[2];for(let xe=0;xe<u.outWidth;++xe){let Ne=se+xe*u.outChannels,Ee=xe*u.strideWidth-y;for(let Oe=0;Oe<p;++Oe){let Be=Ee+Oe*m;if(Be<0||Be>=u.inWidth)continue;let Me=ce+Oe*D[2],ht=fe+Be*u.inChannels,at=Me;for(let ot=0;ot<u.inChannels;++ot){let st=v[ht+ot];for(let dt=0;dt<u.outChannels;++dt)S[Ne+dt]+=st*k[at+dt];at+=u.outChannels}}}}}}}}return n.makeTensorInfo(b.shape,b.dtype,b.values)}var oU={kernelName:Qu,backendName:"cpu",kernelFunc:aU};function iU(e){let{inputs:t,backend:n,attrs:s}=e,{x:r,dy:a}=t,{strides:o,pad:i,filterShape:l}=s;Se([r,a],"conv3dBackpropFilterV2");let u=w.computeStrides(r.shape),c=w.computeStrides(a.shape),d=_.computeConv3DInfo(r.shape,l,o,1,i),p=d.strideDepth,h=d.strideHeight,f=d.strideWidth,m=d.filterDepth,g=d.filterHeight,A=d.filterWidth,y=new Kt(d.filterShape,"float32"),x=y.values,[b,v,k,S]=y.strides,C=n.data.get(a.dataId).values,[D,O,E,R]=c,T=n.data.get(r.dataId).values,[P,U,j,q]=u,X=d.padInfo.front,te=d.padInfo.left,ne=d.padInfo.top;for(let se=0;se<m;++se){let re=Math.max(0,Math.ceil((X-se)/p)),Q=Math.min(d.outDepth,(d.inDepth+X-se)/p),ue=se*b;for(let ce=0;ce<g;++ce){let fe=Math.max(0,Math.ceil((ne-ce)/h)),xe=Math.min(d.outHeight,(d.inHeight+ne-ce)/h),Ne=ce*v+ue;for(let Ee=0;Ee<A;++Ee){let Oe=Math.max(0,Math.ceil((te-Ee)/f)),Be=Math.min(d.outWidth,(d.inWidth+te-Ee)/f),Me=Ee*k+Ne;for(let ht=0;ht<d.inChannels;++ht){let at=ht*S+Me;for(let ot=0;ot<d.outChannels;++ot){let st=0;for(let dt=0;dt<d.batchSize;++dt){let Xe=dt*P,Pn=dt*D;for(let Et=re;Et<Q;++Et){let dn=(se+Et*p-X)*U+Xe,Ns=Et*O+Pn;for(let wn=fe;wn<xe;++wn){let ms=(ce+wn*h-ne)*j+dn,pn=wn*E+Ns;for(let gs=Oe;gs<Be;++gs){let Yn=(Ee+gs*f-te)*q+ms,Qs=gs*R+pn;st+=T[Yn+ht]*C[Qs+ot]}}}}x[at+ot]=st}}}}}return n.makeTensorInfo(y.shape,y.dtype,y.values)}var lU={kernelName:xp,backendName:"cpu",kernelFunc:iU};function uU(e){let{inputs:t,backend:n,attrs:s}=e,{dy:r,filter:a}=t,{pad:o,strides:i,inputShape:l}=s;Se([r],"conv3dBackpropInputV2");let u=w.computeStrides(r.shape),c=w.computeStrides(a.shape),d=_.computeConv3DInfo(l,a.shape,i,1,o),p=new Kt(d.inShape,"float32"),h=p.values,[f,m,g,A]=p.strides,y=n.data.get(r.dataId).values,[x,b,v,k]=u,S=n.data.get(a.dataId).values,[C,D,O,E]=c,{batchSize:R,filterDepth:T,filterHeight:P,filterWidth:U,inChannels:j,inDepth:q,inHeight:X,inWidth:te,outChannels:ne,outDepth:se,outHeight:re,outWidth:Q,strideDepth:ue,strideHeight:ce,strideWidth:fe}=d,xe=T-1-d.padInfo.front,Ne=P-1-d.padInfo.top,Ee=U-1-d.padInfo.left;for(let Oe=0;Oe<R;++Oe)for(let Be=0;Be<j;++Be)for(let Me=0;Me<q;++Me){let ht=Me-xe,at=Math.max(0,Math.ceil(ht/ue)),ot=Math.min(se,(T+ht)/ue);for(let st=0;st<X;++st){let dt=st-Ne,Xe=Math.max(0,Math.ceil(dt/ce)),Pn=Math.min(re,(P+dt)/ce);for(let Et=0;Et<te;++Et){let Zn=Et-Ee,dn=Math.max(0,Math.ceil(Zn/fe)),Ns=Math.min(Q,(U+Zn)/fe),wn=0;for(let fs=at;fs<ot;++fs){let ms=fs*ue-ht;for(let pn=Xe;pn<Pn;++pn){let gs=pn*ce-dt;for(let As=dn;As<Ns;++As){let Yn=As*fe-Zn,Qs=x*Oe+b*fs+v*pn+k*As,yr=C*(T-1-ms)+D*(P-1-gs)+O*(U-1-Yn)+E*Be;for(let Ur=0;Ur<ne;++Ur){let bi=y[Qs+Ur],er=S[yr+Ur];wn+=bi*er}}}}h[f*Oe+m*Me+g*st+A*Et+Be]=wn}}}return n.makeTensorInfo(p.shape,p.dtype,p.values)}var cU={kernelName:bp,backendName:"cpu",kernelFunc:uU},dU=ct(Va,e=>Math.cos(e)),pU={kernelName:Va,backendName:"cpu",kernelFunc:dU},hU=ct(Ua,e=>Math.cosh(e)),fU={kernelName:Ua,backendName:"cpu",kernelFunc:hU};function mU(e){let{inputs:t,backend:n,attrs:s}=e,{image:r,boxes:a,boxInd:o}=t,{cropSize:i,method:l,extrapolationValue:u}=s,[c,d,p,h]=r.shape,f=a.shape[0],[m,g]=i,A=je([f,m,g,h],"float32"),y=n.data.get(a.dataId).values,x=n.data.get(o.dataId).values,b=n.data.get(r.dataId).values,v=w.computeStrides(r.shape),k=w.computeStrides(A.shape);for(let S=0;S<f;S++){let C=S*4,D=y[C],O=y[C+1],E=y[C+2],R=y[C+3],T=x[S];if(T>=c)continue;let P=m>1?(E-D)*(d-1)/(m-1):0,U=g>1?(R-O)*(p-1)/(g-1):0;for(let j=0;j<m;j++){let q=m>1?D*(d-1)+j*P:.5*(D+E)*(d-1);if(q<0||q>d-1){for(let X=0;X<g;X++)for(let te=0;te<h;te++){let ne=te+X*k[2]+j*k[1]+S*k[0];A.values[ne]=u}continue}if(l==="bilinear"){let X=Math.floor(q),te=Math.ceil(q),ne=q-X;for(let se=0;se<g;se++){let re=g>1?O*(p-1)+se*U:.5*(O+R)*(p-1);if(re<0||re>p-1){for(let fe=0;fe<h;fe++){let xe=fe+se*k[2]+j*k[1]+S*k[0];A.values[xe]=u}continue}let Q=Math.floor(re),ue=Math.ceil(re),ce=re-Q;for(let fe=0;fe<h;fe++){let xe=fe+Q*v[2]+X*v[1]+T*v[0],Ne=b[xe];xe=fe+ue*v[2]+X*v[1]+T*v[0];let Ee=b[xe];xe=fe+Q*v[2]+te*v[1]+T*v[0];let Oe=b[xe];xe=fe+ue*v[2]+te*v[1]+T*v[0];let Be=b[xe],Me=Ne+(Ee-Ne)*ce,ht=Oe+(Be-Oe)*ce;xe=fe+se*k[2]+j*k[1]+S*k[0],A.values[xe]=Me+(ht-Me)*ne}}}else for(let X=0;X<g;++X){let te=g>1?O*(p-1)+X*U:.5*(O+R)*(p-1);if(te<0||te>p-1){for(let re=0;re<h;re++){let Q=re+X*k[2]+j*k[1]+S*k[0];A.values[Q]=u}continue}let ne=Math.round(te),se=Math.round(q);for(let re=0;re<h;re++){let Q=re+ne*v[2]+se*v[1]+T*v[0],ue=re+X*k[2]+j*k[1]+S*k[0];A.values[ue]=b[Q]}}}}return n.makeTensorInfo(A.shape,A.dtype,A.values)}var gU={kernelName:ji,backendName:"cpu",kernelFunc:mU};function AU(e){let{inputs:t,backend:n,attrs:s}=e,{x:r}=t,{axis:a,exclusive:o,reverse:i}=s;Se(r,"cumsum");let l=_.getAxesPermutation([a],r.shape.length),u=r;l!=null&&(u=ws({inputs:{x:r},backend:n,attrs:{perm:l}}));let c=_.getInnerMostAxes(1,r.shape.length)[0];if(c!==u.shape.length-1)throw new Error(`backend.cumsum in CPU expects an inner-most axis=${u.shape.length-1} but got axis=${c}`);let d=Ds(u.dtype,"int32"),p=w.makeZerosTypedArray(w.sizeFromShape(u.shape),d),h=n.data.get(u.dataId).values,f=u.shape[u.shape.length-1],m=i?(A,y)=>A+f-y-1:(A,y)=>A+y;for(let A=0;A<h.length;A+=f)for(let y=0;y<f;y++){let x=m(A,y);if(y===0)p[x]=o?0:h[x];else{let b=m(A,y-1);p[x]=o?h[b]+p[b]:h[x]+p[b]}}let g=n.makeTensorInfo(u.shape,d,p);if(l!=null){let A=_.getUndoAxesPermutation(l),y=ws({inputs:{x:g},backend:n,attrs:{perm:A}});return n.disposeIntermediateTensorInfo(g),n.disposeIntermediateTensorInfo(u),y}return g}var yU={kernelName:Ha,backendName:"cpu",kernelFunc:AU};function xU(e){let{inputs:t,backend:n,attrs:s}=e,{x:r,weights:a}=t,{size:o,binaryOutput:i}=s;if(r.shape.length===1){let l=n.data.get(r.dataId).values,u=n.data.get(a.dataId).values,c=H2(l,u,a.dtype,a.shape,o);return n.makeTensorInfo([o],a.dtype,c)}else if(r.shape.length===2){let l=n.bufferSync(r),u=n.bufferSync(a),c=aw(l,u,o,i);return n.makeTensorInfo(c.shape,a.dtype,c.values)}throw new Error(`Error in denseBincount: input must be at most rank 2, but got rank${r.shape.length}.`)}var bU={kernelName:vp,backendName:"cpu",kernelFunc:xU};function vU(e){let{inputs:t,backend:n,attrs:s}=e,{x:r}=t,{blockSize:a,dataFormat:o}=s;w.assert(o==="NHWC",()=>`Only NHWC dataFormat supported on CPU for depthToSpace. Got ${o}`),w.assert(a>1,()=>`blockSize should be > 1 for depthToSpace, but was: ${a}`);let i=r.shape[0],l=r.shape[1],u=r.shape[2],c=r.shape[3],d=l*a,p=u*a,h=c/(a*a),f=n.data.get(r.dataId).values,m=new Float32Array(i*d*p*h),g=0;for(let A=0;A<i;++A)for(let y=0;y<d;++y){let x=Math.floor(y/a),b=y%a;for(let v=0;v<p;++v){let k=Math.floor(v/a),S=v%a,C=(b*a+S)*h;for(let D=0;D<h;++D){let E=D+C+c*(k+u*(x+l*A));m[g++]=f[E]}}}return n.makeTensorInfo([i,d,p,h],r.dtype,m)}var wU={kernelName:qi,backendName:"cpu",kernelFunc:vU};function Zw(e){let{inputs:t,backend:n,attrs:s}=e,{x:r,filter:a}=t,{strides:o,pad:i,dilations:l,dimRoundingMode:u}=s;Se([r,a],"depthwiseConv2DNative");let c=w.computeStrides(r.shape),d=w.computeStrides(a.shape),p=l;p==null&&(p=[1,1]),w.assert(_.eitherStridesOrDilationsAreOne(o,p),()=>`Error in depthwiseConv2d: Either strides or dilations must be 1. Got strides ${o} and dilations '${p}'`);let h=_.computeConv2DInfo(r.shape,a.shape,o,p,i,u,!0),{filterHeight:f,filterWidth:m,dilationHeight:g,dilationWidth:A,padInfo:y}=h,x=y.left,b=y.top,v=h.outChannels/h.inChannels,k=new Kt(h.outShape,r.dtype),S=n.data.get(r.dataId).values,C=n.data.get(a.dataId).values,D=k.values;for(let O=0;O<h.batchSize;++O){let E=O*c[0],R=O*k.strides[0];for(let T=0;T<h.outHeight;++T){let P=R+T*k.strides[1],U=T*h.strideHeight-b;for(let j=0;j<f;++j){let q=U+j*g;if(q<0||q>=h.inHeight)continue;let X=j*d[0],te=E+q*c[1];for(let ne=0;ne<h.outWidth;++ne){let se=P+ne*k.strides[2],re=ne*h.strideWidth-x;for(let Q=0;Q<m;++Q){let ue=re+Q*A;if(ue<0||ue>=h.inWidth)continue;let ce=X+Q*d[1],fe=te+ue*h.inChannels,xe=se,Ne=ce;for(let Ee=0;Ee<h.inChannels;++Ee){let Oe=S[fe+Ee];for(let Be=0;Be<v;++Be)D[xe+Be]+=Oe*C[Ne+Be];xe+=v,Ne+=v}}}}}}return n.makeTensorInfo(k.shape,k.dtype,k.values)}var kU={kernelName:Ga,backendName:"cpu",kernelFunc:Zw};function IU(e){let{inputs:t,backend:n,attrs:s}=e,{x:r,dy:a}=t,{strides:o,dilations:i,pad:l,dimRoundingMode:u,filterShape:c}=s;Se([r,a],"depthwiseConv2dNativeBackpropFilter");let d=_.computeConv2DInfo(r.shape,c,o,i,l,u,!0),{strideHeight:p,strideWidth:h,filterHeight:f,filterWidth:m}=d,g=new Kt(d.filterShape,"float32"),A=d.padInfo.left,y=d.padInfo.top,x=d.outChannels/d.inChannels,b=n.data.get(r.dataId).values,v=new Kt(r.shape,r.dtype,b),k=n.data.get(a.dataId).values,S=new Kt(a.shape,a.dtype,k);for(let C=0;C<f;++C){let D=Math.max(0,Math.ceil((y-C)/p)),O=Math.min(d.outHeight,(d.inHeight+y-C)/p);for(let E=0;E<m;++E){let R=Math.max(0,Math.ceil((A-E)/h)),T=Math.min(d.outWidth,(d.inWidth+A-E)/h);for(let P=0;P<d.outChannels;++P){let U=Math.trunc(P/x),j=P%x,q=0;for(let X=0;X<d.batchSize;++X)for(let te=D;te<O;++te){let ne=C+te*p-y;for(let se=R;se<T;++se){let re=E+se*h-A;q+=v.get(X,ne,re,U)*S.get(X,te,se,P)}}g.set(q,C,E,U,j)}}}return n.makeTensorInfo(g.shape,g.dtype,g.values)}var SU={kernelName:wp,backendName:"cpu",kernelFunc:IU};function CU(e){let{inputs:t,backend:n,attrs:s}=e,{dy:r,filter:a}=t,{strides:o,dilations:i,pad:l,dimRoundingMode:u,inputShape:c}=s;Se([r,a],"depthwiseConv2DNativeBackpropInput");let d=w.computeStrides(r.shape),p=w.computeStrides(a.shape),h=_.computeConv2DInfo(c,a.shape,o,i,l,u,!0),f=new Kt(h.inShape,"float32"),m=f.values,[g,A,y]=f.strides,x=n.data.get(r.dataId).values,[b,v,k]=d,S=n.data.get(a.dataId).values,[C,D,O]=p,{batchSize:E,filterHeight:R,filterWidth:T,inChannels:P,inHeight:U,inWidth:j,outChannels:q,outHeight:X,outWidth:te,strideHeight:ne,strideWidth:se}=h,re=R-1-h.padInfo.top,Q=T-1-h.padInfo.left,ue=q/P;for(let ce=0;ce<E;++ce)for(let fe=0;fe<P;++fe)for(let xe=0;xe<U;++xe){let Ne=xe-re,Ee=Math.max(0,Math.ceil(Ne/ne)),Oe=Math.min(X,(R+Ne)/ne);for(let Be=0;Be<j;++Be){let Me=Be-Q,ht=Math.max(0,Math.ceil(Me/se)),at=Math.min(te,(T+Me)/se),ot=0;for(let st=Ee;st<Oe;++st){let dt=st*ne-Ne;for(let Xe=ht;Xe<at;++Xe){let Pn=Xe*se-Me,Et=b*ce+v*st+k*Xe,Zn=C*(R-1-dt)+D*(T-1-Pn)+O*fe;for(let dn=0;dn<ue;++dn){let Ns=fe*ue+dn,wn=x[Et+Ns],fs=S[Zn+dn];ot+=wn*fs}}}m[g*ce+A*xe+y*Be+fe]=ot}}return n.makeTensorInfo(f.shape,f.dtype,f.values)}var TU={kernelName:kp,backendName:"cpu",kernelFunc:CU};function NU(e){let{inputs:t,backend:n}=e,{x:s}=t,r=w.sizeFromShape(s.shape),a=n.data.get(s.dataId).values,o=je([r,r],s.dtype),i=o.values;for(let u=0;u<a.length;u++)i[u*r+u]=a[u];let l=[...s.shape,...s.shape];return n.makeTensorInfo(l,o.dtype,o.values)}var EU={kernelName:Ip,backendName:"cpu",kernelFunc:NU},RU={kernelName:ec,backendName:"cpu",kernelFunc:({inputs:e,backend:t,attrs:n})=>{let{x:s,filter:r}=e,{strides:a,pad:o,dilations:i}=n,l=t,u=l.data.get(s.dataId).values,c=s.shape.length,d=l.data.get(r.dataId).values,p=r.shape.length,{batchSize:h,inHeight:f,inWidth:m,inChannels:g,outHeight:A,outWidth:y,padInfo:x,strideHeight:b,strideWidth:v,filterHeight:k,filterWidth:S,dilationHeight:C,dilationWidth:D,outShape:O}=_.computeDilation2DInfo(s.shape,r.shape,a,o,"NHWC",i),E=w.sizeFromShape(O),R=O.length,T=w.getArrayFromDType(s.dtype,E);for(let U=0;U<h;++U)for(let j=0;j<A;++j){let q=j*b-x.top;for(let X=0;X<y;++X){let te=X*v-x.left;for(let ne=0;ne<g;++ne){let se=Number.MIN_SAFE_INTEGER;for(let Q=0;Q<k;++Q){let ue=q+Q*C;if(ue>=0&&ue<f)for(let ce=0;ce<S;++ce){let fe=te+ce*D;if(fe>=0&&fe<m){let xe=w.locToIndex([U,ue,fe,ne],c,w.computeStrides(s.shape)),Ne=w.locToIndex([Q,ce,ne],p,w.computeStrides(r.shape)),Ee=u[xe]+d[Ne];Ee>se&&(se=Ee)}}}let re=w.locToIndex([U,j,X,ne],R,w.computeStrides(O));T[re]=se}}}return{dataId:l.write(w.toTypedArray(T,s.dtype),O,s.dtype),shape:O,dtype:s.dtype}}},DU={kernelName:Cp,backendName:"cpu",kernelFunc:({inputs:e,backend:t,attrs:n})=>{let{x:s,filter:r,dy:a}=e,{strides:o,pad:i,dilations:l}=n,u=t,c=w.toNestedArray(s.shape,u.data.get(s.dataId).values),d=w.toNestedArray(r.shape,u.data.get(r.dataId).values),{batchSize:p,inHeight:h,inWidth:f,inChannels:m,outHeight:g,outWidth:A,padInfo:y,strideHeight:x,strideWidth:b,filterHeight:v,filterWidth:k,dilationHeight:S,dilationWidth:C,outShape:D}=_.computeDilation2DInfo(s.shape,r.shape,o,i,"NHWC",l);w.assert(a.rank===D.length,()=>`Error in ${Cp}, dy must have the same rank as output ${D.length}, but got ${a.rank}`);let O=w.toNestedArray(D,u.data.get(a.dataId).values),E=w.makeZerosNestedTypedArray(r.shape,r.dtype);for(let T=0;T<p;++T)for(let P=0;P<g;++P){let U=P*x-y.top;for(let j=0;j<A;++j){let q=j*b-y.left;for(let X=0;X<m;++X){let te=Number.MIN_SAFE_INTEGER,ne=0,se=0;for(let re=0;re<v;++re){let Q=U+re*S;if(Q>=0&&Q<h)for(let ue=0;ue<k;++ue){let ce=q+ue*C;if(ce>=0&&ce<f){let fe=c[T][Q][ce][X]+d[re][ue][X];fe>te&&(te=fe,ne=re,se=ue)}}}E[ne][se][X]+=O[T][P][j][X]}}}return{dataId:u.write(w.toTypedArray(E,s.dtype),r.shape,r.dtype),shape:r.shape,dtype:r.dtype}}},_U={kernelName:Sp,backendName:"cpu",kernelFunc:({inputs:e,backend:t,attrs:n})=>{let{x:s,filter:r,dy:a}=e,{strides:o,pad:i,dilations:l}=n,u=t,c=w.toNestedArray(s.shape,u.data.get(s.dataId).values),d=w.toNestedArray(r.shape,u.data.get(r.dataId).values),{batchSize:p,inHeight:h,inWidth:f,inChannels:m,outHeight:g,outWidth:A,padInfo:y,strideHeight:x,strideWidth:b,filterHeight:v,filterWidth:k,dilationHeight:S,dilationWidth:C,outShape:D}=_.computeDilation2DInfo(s.shape,r.shape,o,i,"NHWC",l);w.assert(a.rank===D.length,()=>`Error in ${Sp}, dy must have the same rank as output ${D.length}, but got ${a.rank}`);let O=w.toNestedArray(D,u.data.get(a.dataId).values),E=w.makeZerosNestedTypedArray(s.shape,s.dtype);for(let T=0;T<p;++T)for(let P=0;P<g;++P){let U=P*x-y.top;for(let j=0;j<A;++j){let q=j*b-y.left;for(let X=0;X<m;++X){let te=Number.MIN_SAFE_INTEGER,ne=U<0?0:U,se=q<0?0:q;for(let re=0;re<v;++re){let Q=U+re*S;if(Q>=0&&Q<h)for(let ue=0;ue<k;++ue){let ce=q+ue*C;if(ce>=0&&ce<f){let fe=c[T][Q][ce][X]+d[re][ue][X];fe>te&&(te=fe,ne=Q,se=ce)}}}E[T][ne][se][X]+=O[T][P][j][X]}}}return{dataId:u.write(w.toTypedArray(E,s.dtype),s.shape,s.dtype),shape:s.shape,dtype:s.dtype}}};function cd(e){let{inputs:t,backend:n,attrs:s}=e,{x:r}=t,{axis:a,keepDims:o}=s;Se(r,"sum");let i;r.dtype==="bool"?i=ba({inputs:{x:r},backend:n,attrs:{dtype:"int32"}}):i=fr({inputs:{x:r},backend:n});let l=i.shape.length,u=w.parseAxisParam(a,i.shape),c=_.getAxesPermutation(u,l),d=u,p=i;c!=null&&(p=ws({inputs:{x:i},backend:n,attrs:{perm:c}}),d=_.getInnerMostAxes(d.length,l)),_.assertAxesAreInnerMostDims("sum",d,p.shape.length);let[h,f]=_.computeOutAndReduceShapes(p.shape,d),m=_.upcastType(p.dtype,"int32"),g=Ff(n,h,m),A=w.sizeFromShape(f),y=n.data.get(g.dataId).values,x=n.data.get(p.dataId).values;for(let b=0;b<y.length;++b){let v=b*A,k=0;for(let S=0;S<A;++S)k+=x[v+S];y[b]=k}if(o){let b=_.expandShapeToKeepDim(g.shape,u),v=g;g=wt({inputs:{x:g},backend:n,attrs:{shape:b}}),n.disposeIntermediateTensorInfo(v)}return n.disposeIntermediateTensorInfo(i),c!=null&&n.disposeIntermediateTensorInfo(p),g}var $U={kernelName:Io,backendName:"cpu",kernelFunc:cd};function FU(e){let{inputs:t,backend:n,attrs:s}=e,{equation:r}=s,a=t,{allDims:o,summedDims:i,idDims:l}=_.decodeEinsumEquation(r,a.length);_.checkEinsumDimSizes(o.length,l,a);let{path:u,steps:c}=_.getEinsumComputePath(i,l),d=c.length,p=null,h=o.length,f=[];for(let m=0;m<d;++m){for(let g of c[m]){let{permutationIndices:A,expandDims:y}=_.getEinsumPermutation(h,l[g]),x;_.isIdentityPermutation(A)?x=a[g]:(x=ws({inputs:{x:a[g]},backend:n,attrs:{perm:A}}),f.push(x));let b=x.shape.slice();for(let v=0;v<y.length;++v)b.splice(y[v],0,1);w.arraysEqual(x.shape,b)||(x=wt({inputs:{x},backend:n,attrs:{shape:b}}),f.push(x)),p===null?p=x:(p=Of({inputs:{a:x,b:p},backend:n}),f.push(p))}m<d-1&&(u[m]>=0&&(p=cd({inputs:{x:p},backend:n,attrs:{axis:u[m]-(o.length-h),keepDims:!1}}),f.push(p)),h--)}for(let m of f)m!==p&&n.disposeIntermediateTensorInfo(m);return p}var OU={kernelName:Tp,backendName:"cpu",kernelFunc:FU};function PU(e){let{inputs:t,backend:n}=e,{dy:s,y:r}=t;Se([s,r],"eluGrad");let a=new Float32Array(w.sizeFromShape(r.shape)),o=n.data.get(r.dataId).values,i=n.data.get(s.dataId).values;for(let l=0;l<o.length;++l){let u=o[l];u>=1?a[l]=i[l]:a[l]=i[l]*(u+1)}return n.makeTensorInfo(r.shape,"float32",a)}var MU={kernelName:Np,backendName:"cpu",kernelFunc:PU},zU=_.ERF_P,LU=_.ERF_A1,BU=_.ERF_A2,WU=_.ERF_A3,VU=_.ERF_A4,UU=_.ERF_A5,HU=ct(Xi,e=>{let t=Math.sign(e),n=Math.abs(e),s=1/(1+zU*n);return t*(1-((((UU*s+VU)*s+WU)*s+BU)*s+LU)*s*Math.exp(-n*n))}),GU={kernelName:Xi,backendName:"cpu",kernelFunc:HU};function Mf(e){let{inputs:t,backend:n,attrs:s}=e,{input:r}=t,{dim:a}=s,o=r.shape.length,i=r.shape.slice(),l=a;return a<0&&(w.assert(-(o+1)<=a,()=>`Axis must be in the interval [${-(o+1)}, ${o}]`),l=o+a+1),i.splice(l,0,1),wt({inputs:{x:r},backend:n,attrs:{shape:i}})}var jU={kernelName:Zi,backendName:"cpu",kernelFunc:Mf},qU=Gt((e,t)=>e/t),Q2=cn(ja,qU),ey={kernelName:ja,backendName:"cpu",kernelFunc:Q2};function Yw(e,t,n){let s=e.shape,r=s[0],a=s[1],o=n.data.get(e.dataId),i=o.complexTensorInfos.real,l=o.complexTensorInfos.imag,u=[r,a],c=w.sizeFromShape(u),d=w.getTypedArrayFromDType("float32",c),p=w.getTypedArrayFromDType("float32",c);for(let g=0;g<r;g++){let A=oi({inputs:{x:i},backend:n,attrs:{begin:[g,0],size:[1,a]}}),y=oi({inputs:{x:l},backend:n,attrs:{begin:[g,0],size:[1,a]}}),x=cs({inputs:{real:A,imag:y},backend:n}),{real:b,imag:v}=XU(x,t,n),k=_.mergeRealAndImagArrays(b,v);for(let S=0;S<a;S++){let C=_.getComplexWithIndex(k,S);d[g*a+S]=C.real,p[g*a+S]=C.imag}n.disposeIntermediateTensorInfo(A),n.disposeIntermediateTensorInfo(y),n.disposeIntermediateTensorInfo(x)}let h=n.makeTensorInfo(u,"float32",d),f=n.makeTensorInfo(u,"float32",p),m=cs({inputs:{real:h,imag:f},backend:n});return n.disposeIntermediateTensorInfo(h),n.disposeIntermediateTensorInfo(f),m}function XU(e,t,n){let s=w.sizeFromShape(e.shape),r=n.data.get(e.dataId),a=n.data.get(r.complexTensorInfos.real.dataId).values,o=n.data.get(r.complexTensorInfos.imag.dataId).values;if(KU(s)){let i=ty(a,o,s,t,n),l=[e.shape[0],e.shape[1]];if(t){let u=n.makeTensorInfo(l,"float32",i.real),c=n.makeTensorInfo(l,"float32",i.imag),d=n.makeTensorInfo([],"float32",w.createScalarValue(s,"float32")),p=fr({inputs:{x:d},backend:n}),h=ey.kernelFunc({inputs:{a:u,b:d},backend:n}),f=ey.kernelFunc({inputs:{a:c,b:p},backend:n}),m=n.data.get(h.dataId).values,g=n.data.get(f.dataId).values;return n.disposeIntermediateTensorInfo(u),n.disposeIntermediateTensorInfo(c),n.disposeIntermediateTensorInfo(d),n.disposeIntermediateTensorInfo(p),n.disposeIntermediateTensorInfo(h),n.disposeIntermediateTensorInfo(f),{real:m,imag:g}}return i}else{let i=_.mergeRealAndImagArrays(a,o),l=ZU(i,s,t);return _.splitRealAndImagArrays(l)}}function KU(e){return(e&e-1)==0}function ty(e,t,n,s,r){if(n===1)return{real:e,imag:t};let a=_.mergeRealAndImagArrays(e,t),o=n/2,i=_.complexWithEvenIndex(a),l=i.real,u=i.imag,c=[l.length],d=r.makeTensorInfo(c,"float32",l),p=r.makeTensorInfo(c,"float32",u),h=cs({inputs:{real:d,imag:p},backend:r}),f=_.complexWithOddIndex(a),m=f.real,g=f.imag,A=[m.length],y=r.makeTensorInfo(A,"float32",m),x=r.makeTensorInfo(A,"float32",g),b=cs({inputs:{real:y,imag:x},backend:r}),v=ty(l,u,o,s,r),k=v.real,S=v.imag,C=[k.length],D=r.makeTensorInfo(C,"float32",k),O=r.makeTensorInfo(C,"float32",S),E=cs({inputs:{real:D,imag:O},backend:r}),R=ty(m,g,o,s,r),T=R.real,P=R.imag,U=[T.length],j=r.makeTensorInfo(U,"float32",T),q=r.makeTensorInfo(U,"float32",P),X=cs({inputs:{real:j,imag:q},backend:r}),te=_.exponents(n,s),ne=[te.real.length],se=r.makeTensorInfo(ne,"float32",te.real),re=r.makeTensorInfo(ne,"float32",te.imag),Q=cs({inputs:{real:se,imag:re},backend:r}),ue=Of({inputs:{a:Q,b:X},backend:r}),ce=ld({inputs:{a:E,b:ue},backend:r}),fe=Z2({inputs:{a:E,b:ue},backend:r}),xe=ai({inputs:{input:ce},backend:r}),Ne=ai({inputs:{input:fe},backend:r}),Ee=pu({inputs:{input:ce},backend:r}),Oe=pu({inputs:{input:fe},backend:r}),Be=hu({inputs:[xe,Ne],backend:r,attrs:{axis:0}}),Me=hu({inputs:[Ee,Oe],backend:r,attrs:{axis:0}}),ht=r.data.get(Be.dataId).values,at=r.data.get(Me.dataId).values;return r.disposeIntermediateTensorInfo(d),r.disposeIntermediateTensorInfo(p),r.disposeIntermediateTensorInfo(h),r.disposeIntermediateTensorInfo(y),r.disposeIntermediateTensorInfo(x),r.disposeIntermediateTensorInfo(b),r.disposeIntermediateTensorInfo(D),r.disposeIntermediateTensorInfo(O),r.disposeIntermediateTensorInfo(E),r.disposeIntermediateTensorInfo(j),r.disposeIntermediateTensorInfo(q),r.disposeIntermediateTensorInfo(X),r.disposeIntermediateTensorInfo(se),r.disposeIntermediateTensorInfo(re),r.disposeIntermediateTensorInfo(Q),r.disposeIntermediateTensorInfo(ue),r.disposeIntermediateTensorInfo(ce),r.disposeIntermediateTensorInfo(fe),r.disposeIntermediateTensorInfo(xe),r.disposeIntermediateTensorInfo(Ee),r.disposeIntermediateTensorInfo(Ne),r.disposeIntermediateTensorInfo(Oe),r.disposeIntermediateTensorInfo(Be),r.disposeIntermediateTensorInfo(Me),{real:ht,imag:at}}function ZU(e,t,n){let s=new Float32Array(t*2);for(let r=0;r<t;r++){let a=0,o=0;for(let i=0;i<t;i++){let l=_.exponent(r*i,t,n),u=_.getComplexWithIndex(e,i);a+=u.real*l.real-u.imag*l.imag,o+=u.real*l.imag+u.imag*l.real}n&&(a/=t,o/=t),_.assignToTypedArray(s,a,o,r)}return s}function YU(e){let{inputs:t,backend:n}=e,{input:s}=t,r=w.sizeFromShape(s.shape),a=s.shape[s.shape.length-1],o=r/a,i=wt({inputs:{x:s},backend:n,attrs:{shape:[o,a]}}),l=Yw(i,!1,n),u=wt({inputs:{x:l},backend:n,attrs:{shape:s.shape}});return n.disposeIntermediateTensorInfo(i),n.disposeIntermediateTensorInfo(l),u}var JU={kernelName:Ep,backendName:"cpu",kernelFunc:YU};function ny(e){let{backend:t,attrs:n}=e,{shape:s,value:r,dtype:a}=n,o=a||w.inferDtype(r),i=w.getArrayFromDType(o,w.sizeFromShape(s));return eH(i,r,o),t.makeTensorInfo(s,o,i)}var QU={kernelName:tc,backendName:"cpu",kernelFunc:ny};function eH(e,t,n){e.fill(t)}var tH={kernelName:Ji,backendName:"cpu",kernelFunc:({inputs:e,attrs:t,backend:n})=>{let{image:s}=e,r=n,a=w.getTypedArrayFromDType(s.dtype,w.sizeFromShape(s.shape)),[o,i,l,u]=s.shape,c=r.data.get(s.dataId).values;for(let p=0;p<o;p++){let h=p*l*i*u;for(let f=0;f<i;f++){let m=f*(l*u);for(let g=0;g<l;g++){let A=g*u;for(let y=0;y<u;y++){let x=Math.round(l-g-1),b=h+m+A+y,v=c[b];if(x>=0&&x<l){let k=x*u,S=h+m+k+y;v=c[S]}a[b]=v}}}}return{dataId:r.write(a,s.shape,s.dtype),shape:s.shape,dtype:s.dtype}}},nH=Gt((e,t)=>Math.floor(e/t)),sH=cn(Za,nH,null,"int32"),rH={kernelName:Za,backendName:"cpu",kernelFunc:sH};function aH(e){let{inputs:t,backend:n,attrs:s}=e,{x:r,filter:a,bias:o,preluActivationWeights:i}=t,{strides:l,pad:u,dataFormat:c,dilations:d,dimRoundingMode:p,activation:h,leakyreluAlpha:f}=s,m=Kw({inputs:{x:r,filter:a},backend:n,attrs:{strides:l,pad:u,dataFormat:c,dilations:d,dimRoundingMode:p}});if(o){let g=m;m=ld({inputs:{a:m,b:o},backend:n}),n.disposeIntermediateTensorInfo(g)}if(h){let g=m;m=Y2(n,m,h,i,f),n.disposeIntermediateTensorInfo(g)}return m}var oH={kernelName:_o,backendName:"cpu",kernelFunc:aH};function iH(e){let{inputs:t,backend:n,attrs:s}=e,{x:r,filter:a,bias:o,preluActivationWeights:i}=t,{strides:l,pad:u,dataFormat:c,dilations:d,dimRoundingMode:p,activation:h,leakyreluAlpha:f}=s,m=Zw({inputs:{x:r,filter:a},backend:n,attrs:{strides:l,pad:u,dataFormat:c,dilations:d,dimRoundingMode:p}});if(o){let g=m;m=ld({inputs:{a:m,b:o},backend:n}),n.disposeIntermediateTensorInfo(g)}if(h){let g=m;m=Y2(n,m,h,i,f),n.disposeIntermediateTensorInfo(g)}return m}var lH={kernelName:$o,backendName:"cpu",kernelFunc:iH};function uH(e){let{inputs:t,backend:n}=e,{params:s,indices:r}=t,a=w.sizeFromShape(s.shape),o=r.shape,i=o[o.length-1],[l,u,c,d]=_.prepareAndValidate(s,r);if(u===0)return n.makeTensorInfo(l,s.dtype,[]);let p=n.data.get(r.dataId).values,h=n.bufferSync(s),f=hw(p,h,s.dtype,u,i,c,d,s.shape,a);return n.makeTensorInfo(l,s.dtype,f.values)}var cH={kernelName:el,backendName:"cpu",kernelFunc:uH};function dH(e){let{inputs:t,backend:n,attrs:s}=e,{x:r,indices:a}=t,{axis:o,batchDims:i}=s;Se([r,a],"gatherV2");let l=i;i==null&&(l=0);let u=w.sizeFromShape(a.shape),c=w.parseAxisParam(o,r.shape)[0],d=_.segment_util.collectGatherOpShapeInfo(r,a,c,l),p=wt({inputs:{x:r},backend:n,attrs:{shape:[d.batchSize,d.outerSize,d.dimSize,d.sliceSize]}}),h=wt({inputs:{x:a},backend:n,attrs:{shape:[d.batchSize,u/d.batchSize]}}),f=[d.batchSize,d.outerSize,u/d.batchSize,d.sliceSize],m=n.bufferSync(h),g=n.bufferSync(p),A=fw(g,m,f);return n.disposeIntermediateTensorInfo(p),n.disposeIntermediateTensorInfo(h),n.makeTensorInfo(d.outputShape,A.dtype,A.values)}var pH={kernelName:Qi,backendName:"cpu",kernelFunc:dH};function hH(e){let{inputs:t,backend:n}=e,{input:s}=t,r=w.sizeFromShape(s.shape),a=s.shape[s.shape.length-1],o=r/a,i=wt({inputs:{x:s},backend:n,attrs:{shape:[o,a]}}),l=Yw(i,!0,n),u=wt({inputs:{x:l},backend:n,attrs:{shape:s.shape}});return n.disposeIntermediateTensorInfo(i),n.disposeIntermediateTensorInfo(l),u}var fH={kernelName:Rp,backendName:"cpu",kernelFunc:hH},mH=ct(nl,e=>Number.isFinite(e)?1:0,"bool"),gH={kernelName:nl,backendName:"cpu",kernelFunc:mH},AH=ct(sl,e=>Math.abs(e)===1/0?1:0,"bool"),yH={kernelName:sl,backendName:"cpu",kernelFunc:AH},xH=ct(rl,e=>Number.isNaN(e)?1:0,"bool"),bH={kernelName:rl,backendName:"cpu",kernelFunc:xH};function vH(e){let{backend:t,attrs:n}=e,{start:s,stop:r,num:a}=n,o=xw(s,r,a);return t.makeTensorInfo([o.length],"float32",o)}var wH={kernelName:_p,backendName:"cpu",kernelFunc:vH},kH=ct(il,e=>Math.log1p(e)),IH={kernelName:il,backendName:"cpu",kernelFunc:kH},SH=Gt((e,t)=>e&&t),CH=cn(ll,SH,null,"bool"),TH={kernelName:ll,backendName:"cpu",kernelFunc:CH},NH=ct(nc,e=>e?0:1,"bool"),EH={kernelName:nc,backendName:"cpu",kernelFunc:NH},RH=Gt((e,t)=>e||t),DH=cn(sc,RH,null,"bool"),_H={kernelName:sc,backendName:"cpu",kernelFunc:DH};function $H(e){let{inputs:t,backend:n,attrs:s}=e,{x:r}=t,{depthRadius:a,bias:o,alpha:i,beta:l}=s;Se(r,"LRN");let u=r.shape[3],c=u-1,d=n.data.get(r.dataId).values,p=w.sizeFromShape(r.shape),h=new Float32Array(p);function f(m){let g=m%u,A=m-g+Math.max(0,g-a),y=m-g+Math.min(g+a,c),x=0;for(;A<=y;A++){let b=d[A];x+=b*b}return x}for(let m=0;m<p;m++){let g=f(m),A=d[m]*Math.pow(o+i*g,-l);h[m]=A}return n.makeTensorInfo(r.shape,r.dtype,h)}var FH={kernelName:rc,backendName:"cpu",kernelFunc:$H};function OH(e){let{inputs:t,backend:n,attrs:s}=e,{x:r,y:a,dy:o}=t,{depthRadius:i,bias:l,alpha:u,beta:c}=s;Se(o,"LRNGrad");let d=w.sizeFromShape(o.shape),p=o.shape[3],h=n.data.get(o.dataId).values,f=n.data.get(r.dataId).values,m=n.data.get(a.dataId).values,g=new Float32Array(d),A=d;for(let y=0;y<A;y++){let x=y%p,b=y-x+Math.max(0,x-i),v=y-x+Math.min(p,x+i+1),k=0;for(let S=b;S<v;S++)k+=Math.pow(f[S],2);k=u*k+l;for(let S=b;S<v;S++){let C=-2*u*c*f[S]*m[y]/k;y===S&&(C+=Math.pow(k,-c)),C*=h[y],g[S]+=C}}return n.makeTensorInfo(o.shape,r.dtype,g)}var PH={kernelName:$p,backendName:"cpu",kernelFunc:OH};function Jw(e){let{inputs:t,backend:n,attrs:s}=e,{x:r}=t,{reductionIndices:a,keepDims:o}=s,i=n,l=r.shape,u=l.length,c=w.parseAxisParam(a,l),d=c,p=_.getAxesPermutation(d,u),h=i.data.get(r.dataId).values;if(p!=null){let b=new Array(u);for(let v=0;v<b.length;v++)b[v]=l[p[v]];h=q2(h,l,r.dtype,p,b),d=_.getInnerMostAxes(d.length,u),l=b}Se(r,"max"),_.assertAxesAreInnerMostDims("max",d,u);let[f,m]=_.computeOutAndReduceShapes(l,d),g=w.sizeFromShape(m),A=vw(h,g,f,r.dtype),y=i.write(A,f,r.dtype),x=f;return o&&(x=_.expandShapeToKeepDim(f,c)),{dataId:y,shape:x,dtype:r.dtype}}var MH={kernelName:no,backendName:"cpu",kernelFunc:Jw};function zH(e){let{inputs:t,backend:n,attrs:s}=e,{x:r}=t;Se(r,"maxPool");let{filterSize:a,strides:o,pad:i,dimRoundingMode:l}=s,u=1;w.assert(_.eitherStridesOrDilationsAreOne(o,u),()=>`Error in maxPool: Either strides or dilations must be 1. Got strides ${o} and dilations '${u}'`);let c=_.computePool2DInfo(r.shape,a,o,u,i,l),d;if(c.filterWidth===1&&c.filterHeight===1&&w.arraysEqual(c.inShape,c.outShape))d=fr({inputs:{x:r},backend:n});else{let p=n.data.get(r.dataId).values,h=w.computeStrides(r.shape),f=J2(p,r.shape,r.dtype,h,c,"max");d=n.makeTensorInfo(c.outShape,r.dtype,f.values)}return d}var LH={kernelName:ro,backendName:"cpu",kernelFunc:zH};function BH(e){let{inputs:t,backend:n,attrs:s}=e,{x:r}=t,{filterSize:a,strides:o,pad:i,dimRoundingMode:l,dataFormat:u}=s;Se(r,"maxPool3d");let c=_.computePool3DInfo(r.shape,a,o,1,i,l,u),d=n.data.get(r.dataId).values,p=Xw(d,r.shape,r.dtype,w.computeStrides(r.shape),c,"max");return n.makeTensorInfo(p.shape,"float32",p.values)}var WH={kernelName:ac,backendName:"cpu",kernelFunc:BH};function VH(e){let{inputs:t,backend:n,attrs:s}=e,{dy:r,input:a}=t,{filterSize:o,strides:i,pad:l,dimRoundingMode:u}=s;Se([r,a],"maxPool3DGrad");let c=_.computePool3DInfo(a.shape,o,i,1,l,u),d=n.bufferSync(a),p=DV(d,c),h=c.strideDepth,f=c.strideHeight,m=c.strideWidth,g=c.dilationDepth,A=c.dilationHeight,y=c.dilationWidth,x=c.effectiveFilterDepth,b=c.effectiveFilterHeight,v=c.effectiveFilterWidth,k=x-1-c.padInfo.front,S=v-1-c.padInfo.left,C=b-1-c.padInfo.top,D=je(a.shape,"float32"),O=n.bufferSync(r);for(let E=0;E<c.batchSize;++E)for(let R=0;R<c.inChannels;++R)for(let T=0;T<c.inDepth;++T)for(let P=0;P<c.inHeight;++P)for(let U=0;U<c.inWidth;++U){let j=T-k,q=P-C,X=U-S,te=0;for(let ne=0;ne<x;ne+=g){let se=(j+ne)/h;if(!(se<0||se>=c.outDepth||Math.floor(se)!==se))for(let re=0;re<b;re+=A){let Q=(q+re)/f;if(!(Q<0||Q>=c.outHeight||Math.floor(Q)!==Q))for(let ue=0;ue<v;ue+=y){let ce=(X+ue)/m;if(ce<0||ce>=c.outWidth||Math.floor(ce)!==ce)continue;let fe=x*b*v-1-p.get(E,se,Q,ce,R),xe=ne*b*v+re*v+ue,Ne=fe===xe?1:0;if(Ne===0)continue;te+=O.get(E,se,Q,ce,R)*Ne}}}D.set(te,E,T,P,U,R)}return n.makeTensorInfo(D.shape,D.dtype,D.values)}var UH={kernelName:Op,backendName:"cpu",kernelFunc:VH};function HH(e){let{inputs:t,backend:n,attrs:s}=e,{dy:r,input:a,output:o}=t,i=a;Se([a,o],"maxPoolGrad");let{filterSize:l,strides:u,pad:c,dimRoundingMode:d}=s,p=_.computePool2DInfo(i.shape,l,u,1,c,d),h=n.data.get(i.dataId).values,f=je(p.outShape,i.dtype,qw(h,i.shape,i.dtype,p).values),m=p.strideHeight,g=p.strideWidth,A=p.dilationHeight,y=p.dilationWidth,x=p.effectiveFilterHeight,b=p.effectiveFilterWidth,v=b-1-p.padInfo.left,k=x-1-p.padInfo.top,S=je(i.shape,"float32"),C=n.data.get(r.dataId).values,D=je(r.shape,"float32",C);for(let O=0;O<p.batchSize;++O)for(let E=0;E<p.inChannels;++E)for(let R=0;R<p.inHeight;++R)for(let T=0;T<p.inWidth;++T){let P=R-k,U=T-v,j=0;for(let q=0;q<x;q+=A){let X=(P+q)/m;if(!(X<0||X>=p.outHeight||Math.floor(X)!==X))for(let te=0;te<b;te+=y){let ne=(U+te)/g;if(ne<0||ne>=p.outWidth||Math.floor(ne)!==ne)continue;let se=x*b-1-f.get(O,X,ne,E),re=q*b+te,Q=se===re?1:0;if(Q===0)continue;j+=D.get(O,X,ne,E)*Q}}S.set(j,O,R,T,E)}return n.makeTensorInfo(S.shape,S.dtype,S.values)}var GH={kernelName:Fp,backendName:"cpu",kernelFunc:HH};function jH(e,t,n,s,r){let a=w.computeStrides(t),o=J2(e,t,n,a,r,"max"),i=qw(e,t,n,r,!0,s);return[o.values,i.values]}var qH={kernelName:Pp,backendName:"cpu",kernelFunc:({inputs:e,attrs:t,backend:n})=>{let{x:s}=e,{filterSize:r,strides:a,pad:o,includeBatchInIndex:i}=t,l=n;Se(s,"MaxPoolWithArgmax");let u=l.data.get(s.dataId).values,c=_.computePool2DInfo(s.shape,r,a,[1,1],o),[d,p]=jH(u,s.shape,s.dtype,i,c),h=l.write(d,c.outShape,s.dtype),f=l.write(p,c.outShape,s.dtype);return[{dataId:h,shape:c.outShape,dtype:s.dtype},{dataId:f,shape:c.outShape,dtype:"int32"}]}};function XH(e){let{inputs:t,backend:n,attrs:s}=e,{x:r}=t,{axis:a,keepDims:o}=s,i=w.parseAxisParam(a,r.shape),u=_.computeOutAndReduceShapes(r.shape,i)[1],c=w.sizeFromShape(u),d=[],p=n.makeTensorInfo([],"float32",new Float32Array([c]));d.push(p);let h=ba({inputs:{x:r},backend:n,attrs:{dtype:"float32"}});d.push(h);let f=Q2({inputs:{a:h,b:p},backend:n});d.push(f);let m=cd({inputs:{x:f},backend:n,attrs:{axis:a,keepDims:o}});return d.forEach(g=>n.disposeIntermediateTensorInfo(g)),m}var KH={kernelName:ao,backendName:"cpu",kernelFunc:XH};function ZH(e){let{inputs:t,backend:n,attrs:s}=e,{x:r}=t,{axis:a,keepDims:o}=s;Se(r,"min");let i=w.parseAxisParam(a,r.shape),l=i,u=_.getAxesPermutation(l,r.shape.length),c=r;u!=null&&(c=ws({inputs:{x:r},backend:n,attrs:{perm:u}}),l=_.getInnerMostAxes(l.length,r.shape.length)),_.assertAxesAreInnerMostDims("min",l,c.shape.length);let[d,p]=_.computeOutAndReduceShapes(c.shape,l),h=w.sizeFromShape(p),f=w.makeZerosTypedArray(w.sizeFromShape(d),c.dtype),m=n.data.get(c.dataId).values;for(let A=0;A<f.length;++A){let y=A*h,x=m[y];for(let b=0;b<h;++b){let v=m[y+b];(Number.isNaN(v)||v<x)&&(x=v)}f[A]=x}u!=null&&n.disposeIntermediateTensorInfo(c);let g=n.makeTensorInfo(d,c.dtype,f);if(o){let A=_.expandShapeToKeepDim(d,i),y=wt({inputs:{x:g},backend:n,attrs:{shape:A}});return n.disposeIntermediateTensorInfo(g),y}return g}var YH={kernelName:oo,backendName:"cpu",kernelFunc:ZH};function JH(e){let{inputs:t,backend:n,attrs:s}=e,{x:r}=t,{paddings:a,mode:o}=s;Se(r,"mirrorPad");let i=a.map((x,b)=>x[0]+r.shape[b]+x[1]),l=a.map(x=>x[0]),u=a.map((x,b)=>x[0]+r.shape[b]),c=o==="reflect"?0:1,d=n.data.get(r.dataId).values,p=r.shape.length,h=w.computeStrides(r.shape),f=w.sizeFromShape(i),m=i.length,g=w.computeStrides(i),A=w.getTypedArrayFromDType(r.dtype,f);for(let x=0;x<f;x++){let b=w.indexToLoc(x,m,g);for(let k=0;k<m;k++)b[k]<l[k]?b[k]=l[k]*2-b[k]-c:b[k]>=u[k]&&(b[k]=(u[k]-1)*2-b[k]+c);b=b.map((k,S)=>k-l[S]);let v=w.locToIndex(b,p,h);A[x]=d[v]}return{dataId:n.write(A,i,r.dtype),shape:i,dtype:r.dtype}}var QH={kernelName:lo,backendName:"cpu",kernelFunc:JH},eG=Gt((e,t)=>{let n=e%t;return e<0&&t<0||e>=0&&t>=0?n:(n+t)%t}),tG=cn(ul,eG),nG={kernelName:ul,backendName:"cpu",kernelFunc:tG},sG=Da(Zx());function Qw(e){let{inputs:t,backend:n,attrs:s}=e,{logits:r}=t,{dim:a}=s,o=r.shape.length,i=a;if(i===-1&&(i=o-1),i!==o-1)throw Error(`Softmax along a non-last dimension is not yet supported. Logits was rank ${o} and dim was ${i}`);let l=w.parseAxisParam([i],r.shape),u=Jw({inputs:{x:r},backend:n,attrs:{reductionIndices:l,keepDims:!1}}),c=_.expandShapeToKeepDim(u.shape,l),d=wt({inputs:{x:u},backend:n,attrs:{shape:c}}),p=Z2({inputs:{a:r,b:d},backend:n}),h=cw({inputs:{x:p},backend:n}),f=cd({inputs:{x:h},backend:n,attrs:{axis:l,keepDims:!1}}),m=wt({inputs:{x:f},backend:n,attrs:{shape:c}}),g=Q2({inputs:{a:h,b:m},backend:n});return n.disposeIntermediateTensorInfo(u),n.disposeIntermediateTensorInfo(d),n.disposeIntermediateTensorInfo(p),n.disposeIntermediateTensorInfo(h),n.disposeIntermediateTensorInfo(f),n.disposeIntermediateTensorInfo(m),g}var rG={kernelName:So,backendName:"cpu",kernelFunc:Qw};function aG(e){let{inputs:t,backend:n,attrs:s}=e,{logits:r}=t,{numSamples:a,seed:o,normalized:i}=s;Se(r,"multinomial");let l=i?r:Qw({inputs:{logits:r},backend:n,attrs:{dim:-1}}),u=l.shape[0],c=l.shape[1],d=n.data.get(l.dataId).values,p=[u,a],h=w.makeZerosTypedArray(w.sizeFromShape(p),"int32");for(let f=0;f<u;++f){let m=f*c,g=new Float32Array(c-1);g[0]=d[m];for(let x=1;x<g.length;++x)g[x]=g[x-1]+d[m+x];let A=sG.alea(o.toString()),y=f*a;for(let x=0;x<a;++x){let b=A();h[y+x]=g.length;for(let v=0;v<g.length;v++)if(b<g[v]){h[y+x]=v;break}}}return i||n.disposeIntermediateTensorInfo(l),n.makeTensorInfo(p,"int32",h)}var oG={kernelName:Mp,backendName:"cpu",kernelFunc:aG},iG=lr.nonMaxSuppressionV3Impl;function lG(e){let{inputs:t,backend:n,attrs:s}=e,{boxes:r,scores:a}=t,{maxOutputSize:o,iouThreshold:i,scoreThreshold:l}=s;Se(r,"NonMaxSuppression");let u=n.data.get(r.dataId).values,c=n.data.get(a.dataId).values,{selectedIndices:d}=iG(u,c,o,i,l);return n.makeTensorInfo([d.length],"int32",new Int32Array(d))}var uG={kernelName:pl,backendName:"cpu",kernelFunc:lG},cG=lr.nonMaxSuppressionV4Impl;function dG(e){let{inputs:t,backend:n,attrs:s}=e,{boxes:r,scores:a}=t,{maxOutputSize:o,iouThreshold:i,scoreThreshold:l,padToMaxOutputSize:u}=s;Se(r,"NonMaxSuppressionPadded");let c=n.data.get(r.dataId).values,d=n.data.get(a.dataId).values,{selectedIndices:p,validOutputs:h}=cG(c,d,o,i,l,u);return[n.makeTensorInfo([p.length],"int32",new Int32Array(p)),n.makeTensorInfo([],"int32",new Int32Array([h]))]}var pG={kernelName:hl,backendName:"cpu",kernelFunc:dG},hG=lr.nonMaxSuppressionV5Impl;function fG(e){let{inputs:t,backend:n,attrs:s}=e,{boxes:r,scores:a}=t,{maxOutputSize:o,iouThreshold:i,scoreThreshold:l,softNmsSigma:u}=s;Se(r,"NonMaxSuppressionWithScore");let c=n.data.get(r.dataId).values,d=n.data.get(a.dataId).values,p=o,h=i,f=l,m=u,{selectedIndices:g,selectedScores:A}=hG(c,d,p,h,f,m);return[n.makeTensorInfo([g.length],"int32",new Int32Array(g)),n.makeTensorInfo([A.length],"float32",new Float32Array(A))]}var mG={kernelName:fl,backendName:"cpu",kernelFunc:fG};function gG(e){let{inputs:t,backend:n,attrs:s}=e,{indices:r}=t,{depth:a,onValue:o,offValue:i}=s;Se(r,"oneHot");let l=w.sizeFromShape(r.shape),u=new Float32Array(l*a);u.fill(i);let c=n.data.get(r.dataId).values;for(let d=0;d<l;++d)c[d]>=0&&c[d]<a&&(u[d*a+c[d]]=o);return n.makeTensorInfo([...r.shape,a],"int32",u)}var AG={kernelName:co,backendName:"cpu",kernelFunc:gG};function zf(e){let{inputs:t,backend:n}=e,{x:s}=t;if(s.dtype==="string")throw new Error("zerosLike is not supported for string tensors");if(s.dtype==="complex64"){let r=ai({inputs:{input:s},backend:n}),a=zf({inputs:{x:r},backend:n}),o=pu({inputs:{input:s},backend:n}),i=zf({inputs:{x:o},backend:n}),l=cs({inputs:{real:a,imag:i},backend:n});return n.disposeIntermediateTensorInfo(r),n.disposeIntermediateTensorInfo(a),n.disposeIntermediateTensorInfo(o),n.disposeIntermediateTensorInfo(i),l}else return ny({backend:n,attrs:{shape:s.shape,value:0,dtype:s.dtype}})}var yG={kernelName:$l,backendName:"cpu",kernelFunc:zf};function e6(e){let{inputs:t,backend:n}=e,{x:s}=t;if(s.dtype==="string")throw new Error("onesLike is not supported for string tensors");if(s.dtype==="complex64"){let r=ai({inputs:{input:s},backend:n}),a=e6({inputs:{x:r},backend:n}),o=pu({inputs:{input:s},backend:n}),i=zf({inputs:{x:o},backend:n}),l=cs({inputs:{real:a,imag:i},backend:n});return n.disposeIntermediateTensorInfo(r),n.disposeIntermediateTensorInfo(a),n.disposeIntermediateTensorInfo(o),n.disposeIntermediateTensorInfo(i),l}else return ny({backend:n,attrs:{shape:s.shape,value:1,dtype:s.dtype}})}var xG={kernelName:ml,backendName:"cpu",kernelFunc:e6};function t6(e){let{inputs:t,backend:n,attrs:s}=e,{axis:r}=s;if(t.length===1)return Mf({inputs:{input:t[0]},backend:n,attrs:{dim:r}});let a=t[0].shape,o=t[0].dtype;t.forEach(c=>{w.assertShapesMatch(a,c.shape,"All tensors passed to stack must have matching shapes"),w.assert(o===c.dtype,()=>"All tensors passed to stack must have matching dtypes")});let i=[],l=t.map(c=>{let d=Mf({inputs:{input:c},backend:n,attrs:{dim:r}});return i.push(d),d}),u=hu({inputs:l,backend:n,attrs:{axis:r}});return i.forEach(c=>n.disposeIntermediateTensorInfo(c)),u}var bG={kernelName:gl,backendName:"cpu",kernelFunc:t6};function vG(e){let{inputs:t,backend:n,attrs:s}=e,{x:r}=t,{paddings:a,constantValue:o}=s;Se(r,"pad");let i=a.map((y,x)=>y[0]+r.shape[x]+y[1]),l=a.map(y=>y[0]),u=n.data.get(r.dataId).values,c=w.sizeFromShape(r.shape),d=r.shape.length,p=w.computeStrides(r.shape),h=w.sizeFromShape(i),f=i.length,m=w.computeStrides(i),g=w.getTypedArrayFromDType(r.dtype,h);o!==0&&g.fill(o);for(let y=0;y<c;y++){let b=w.indexToLoc(y,d,p).map((k,S)=>k+l[S]),v=w.locToIndex(b,f,m);g[v]=u[y]}return{dataId:n.write(g,i,r.dtype),shape:i,dtype:r.dtype}}var n6={kernelName:po,backendName:"cpu",kernelFunc:vG},wG=Gt((e,t)=>Math.pow(e,t)),kG=cn(ho,wG),IG={kernelName:ho,backendName:"cpu",kernelFunc:kG};function SG(e){let{backend:t,attrs:n}=e,{start:s,stop:r,dtype:a,step:o}=n,i=X2(s,r,o,a);return t.makeTensorInfo([i.length],a,i)}var CG={kernelName:oc,backendName:"cpu",kernelFunc:SG},TG=ct(yl,e=>1/e),NG={kernelName:yl,backendName:"cpu",kernelFunc:TG};function EG(e){let{inputs:t,backend:n,attrs:s}=e,{images:r}=t,{alignCorners:a,halfPixelCenters:o,size:i}=s;Se(r,"resizeBilinear");let l=w.computeStrides(r.shape),[u,c]=i,[d,p,h,f]=r.shape,m=n.data.get(r.dataId).values,g=new Float32Array(w.sizeFromShape([d,u,c,f])),A=[a&&u>1?p-1:p,a&&c>1?h-1:h],y=[a&&u>1?u-1:u,a&&c>1?c-1:c],x=0,b=A[0]/y[0],v=A[1]/y[1];for(let k=0;k<d;k++)for(let S=0;S<u;S++){let C;o?C=b*(S+.5)-.5:C=b*S;let D=Math.max(0,Math.floor(C)),O=C-D,E=Math.min(p-1,Math.ceil(C)),R=k*l[0]+D*l[1],T=k*l[0]+E*l[1];for(let P=0;P<c;P++){let U;o?U=v*(P+.5)-.5:U=v*P;let j=Math.max(0,Math.floor(U)),q=U-j,X=Math.min(h-1,Math.ceil(U)),te=R+j*l[2],ne=T+j*l[2],se=R+X*l[2],re=T+X*l[2];for(let Q=0;Q<f;Q++){let ue=m[te+Q],ce=m[ne+Q],fe=m[se+Q],xe=m[re+Q],Ne=ue+(fe-ue)*q,Ee=ce+(xe-ce)*q,Oe=Ne+(Ee-Ne)*O;g[x++]=Oe}}}return n.makeTensorInfo([d,u,c,f],"float32",g)}var RG={kernelName:go,backendName:"cpu",kernelFunc:EG};function DG(e){let{inputs:t,backend:n,attrs:s}=e,{images:r,dy:a}=t,{alignCorners:o}=s;Se([a,r],"resizeBilinearGrad");let i=w.computeStrides(r.shape),[l,u,c,d]=r.shape,[,p,h]=a.shape,f=new Float32Array(l*u*c*d),m=[o&&p>1?u-1:u,o&&h>1?c-1:c],g=[o&&p>1?p-1:p,o&&h>1?h-1:h],A=m[0]/g[0],y=m[1]/g[1],x=n.data.get(a.dataId).values,b=0;for(let v=0;v<l;v++){let k=v*i[0];for(let S=0;S<p;S++){let C=S*A,D=Math.floor(C),O=Math.min(Math.ceil(C),u-1),E=k+D*i[1],R=k+O*i[1],T=C-D,P=1-T;for(let U=0;U<h;U++){let j=U*y,q=Math.floor(j),X=Math.min(Math.ceil(j),c-1),te=j-q,ne=1-te,se=E+q*i[2],re=E+X*i[2],Q=R+q*i[2],ue=R+X*i[2],ce=P*ne,fe=P*te,xe=T*ne,Ne=T*te;for(let Ee=0;Ee<d;Ee++){let Oe=x[b++];f[se+Ee]+=Oe*ce,f[re+Ee]+=Oe*fe,f[Q+Ee]+=Oe*xe,f[ue+Ee]+=Oe*Ne}}}}return n.makeTensorInfo([l,c,u,d],"float32",f)}var _G={kernelName:Bp,backendName:"cpu",kernelFunc:DG};function $G(e){let{inputs:t,backend:n,attrs:s}=e,{images:r}=t,{alignCorners:a,halfPixelCenters:o,size:i}=s;Se(r,"resizeNearestNeighbor");let l=w.computeStrides(r.shape),[u,c]=i,[d,p,h,f]=r.shape,m=n.data.get(r.dataId).values,g=new Float32Array(d*u*c*f),A=[a&&u>1?p-1:p,a&&c>1?h-1:h],y=[a&&u>1?u-1:u,a&&c>1?c-1:c],x=A[0]/y[0],b=A[1]/y[1],v=0;for(let k=0;k<d;k++){let S=k*l[0];for(let C=0;C<u;C++){let D=o?x*(C+.5):x*C,O=Math.min(p-1,a?Math.round(D):Math.floor(D));o&&(O=Math.max(0,O));let E=S+O*l[1];for(let R=0;R<c;R++){let T=o?b*(R+.5):b*R,P=Math.min(h-1,a?Math.round(T):Math.floor(T));o&&(P=Math.max(0,P));let U=E+P*l[2];for(let j=0;j<f;j++){let q=m[U+j];g[v++]=q}}}}return n.makeTensorInfo([d,u,c,f],r.dtype,g)}var FG={kernelName:ic,backendName:"cpu",kernelFunc:$G};function OG(e){let{inputs:t,backend:n,attrs:s}=e,{images:r,dy:a}=t,{alignCorners:o}=s;Se([a,r],"resizeNearestNeighborGrad");let i=w.computeStrides(r.shape),l=w.computeStrides(a.shape),[u,c,d,p]=r.shape,[,h,f]=a.shape,m=new Float32Array(u*c*d*p),g=n.data.get(a.dataId).values,A=[o&&h>1?c-1:c,o&&f>1?d-1:d],y=[o&&h>1?h-1:h,o&&f>1?f-1:f],x=A[0]/y[0],b=A[1]/y[1],v=1/x,k=1/b,S=Math.ceil(v)*2+2,C=Math.ceil(k)*2+2;for(let D=0;D<u;D++){let O=D*i[0];for(let E=0;E<c;E++){let R=O+E*i[1],T=Math.floor(E*v),P=Math.floor(T-S/2);for(let U=0;U<d;U++){let j=R+U*i[2],q=Math.floor(U*k),X=Math.floor(q-C/2);for(let te=0;te<p;te++){let ne=0;for(let se=0;se<S;se++){let re=se+P;if(re<0||re>=h)continue;let Q=O+re*l[1],ue=re*x,ce=Math.min(c-1,o?Math.round(ue):Math.floor(ue));if(E===ce)for(let fe=0;fe<C;fe++){let xe=fe+X;if(xe<0||xe>=f)continue;let Ne=Q+xe*l[2],Ee=xe*b,Oe=Math.min(d-1,o?Math.round(Ee):Math.floor(Ee));U===Oe&&(ne+=g[Ne+te])}}m[j+te]=ne}}}}return n.makeTensorInfo(r.shape,r.dtype,m)}var PG={kernelName:Lp,backendName:"cpu",kernelFunc:OG};function MG(e){let{inputs:t,backend:n,attrs:s}=e,{x:r}=t,{dims:a}=s;Se(r,"reverse");let o=r.shape.length,i=w.parseAxisParam(a,r.shape);if(o===0)return fr({inputs:{x:r},backend:n});let l=new Kt(r.shape,r.dtype),u=n.bufferSync(r);for(let c=0;c<l.size;c++){let d=l.indexToLoc(c),p=d.slice();i.forEach(h=>p[h]=r.shape[h]-1-p[h]),l.set(u.get(...p),...d)}return n.makeTensorInfo(l.shape,l.dtype,l.values)}var zG={kernelName:yo,backendName:"cpu",kernelFunc:MG},LG={kernelName:Fl,backendName:"cpu",kernelFunc:({inputs:e,attrs:t,backend:n})=>{let{image:s}=e,{radians:r,fillValue:a,center:o}=t,i=n,l=w.getTypedArrayFromDType(s.dtype,w.sizeFromShape(s.shape)),[u,c,d,p]=s.shape,[h,f]=_.getImageCenter(o,c,d),m=255,g=Math.sin(r),A=Math.cos(r),y=i.data.get(s.dataId).values;for(let b=0;b<u;b++){let v=b*d*c*p;for(let k=0;k<c;k++){let S=k*(d*p);for(let C=0;C<d;C++){let D=C*p;for(let O=0;O<p;O++){let E=[u,k,C,O],R=E[2],T=E[1],P=(R-h)*A-(T-f)*g,U=(R-h)*g+(T-f)*A;P=Math.round(P+h),U=Math.round(U+f);let j=a;if(typeof a!="number"&&(O===3?j=m:j=a[O]),P>=0&&P<d&&U>=0&&U<c){let X=U*(d*p),te=P*p,ne=v+X+te+O;j=y[ne]}let q=v+S+D+O;l[q]=j}}}}return{dataId:i.write(l,s.shape,s.dtype),shape:s.shape,dtype:s.dtype}}},BG=ct(xo,e=>{let t=Math.floor(e);return e-t<.5?Math.floor(e):e-t>.5?Math.ceil(e):t%2==0?t:t+1}),WG={kernelName:xo,backendName:"cpu",kernelFunc:BG};function s6(e,t,n,s,r,a,o,i,l,u){let c=[s/r,r],d=e.values,p=t.values;if(s===0)return je(n,t.dtype);let h=je(c,t.dtype);h.values.fill(l);for(let f=0;f<a;f++){let m=[],g=0;for(let A=0;A<o;A++){let y=d[f*o+A];m.push(y),g+=y*i[A]}if(g<0||g>=s/r)throw new Error(`Invalid indices: ${m} does not index into ${n}`);for(let A=0;A<r;A++)u?h.values[g*r+A]+=p[f*r+A]:h.values[g*r+A]=t.rank===0?p[0]:p[f*r+A]}return h}function VG(e){let{inputs:t,backend:n,attrs:s}=e,{indices:r,updates:a}=t,{shape:o}=s,{sliceRank:i,numUpdates:l,sliceSize:u,strides:c,outputSize:d}=_.calculateShapes(a,r,o),p=!0,h=n.bufferSync(r),f=n.bufferSync(a),m=s6(h,f,o,d,u,l,i,c,0,p);return n.makeTensorInfo(o,m.dtype,m.values)}var UG={kernelName:bl,backendName:"cpu",kernelFunc:VG};function HG(e){let{inputs:t,backend:n}=e,{condition:s,t:r,e:a}=t;Se([s,r,a],"select");let o=s.shape.length,i=n.data.get(s.dataId).values,l=n.data.get(r.dataId).values,u=n.data.get(a.dataId).values,c=Ds(r.dtype,a.dtype),d=w.makeZerosTypedArray(w.sizeFromShape(r.shape),c),p=0,h=o===0||o>1||r.shape.length===1?1:w.sizeFromShape(r.shape.slice(1));for(let f=0;f<i.length;f++)for(let m=0;m<h;m++)i[f]===1?d[p++]=l[f]:d[p++]=u[f];return n.makeTensorInfo(r.shape,c,d)}var GG={kernelName:vl,backendName:"cpu",kernelFunc:HG},jG=_.SELU_SCALEALPHA,qG=_.SELU_SCALE,XG=ct(wl,e=>e>=0?qG*e:jG*(Math.exp(e)-1)),KG={kernelName:wl,backendName:"cpu",kernelFunc:XG},ZG=ct(Sl,e=>e<0?-1:e>0?1:0),YG={kernelName:Sl,backendName:"cpu",kernelFunc:ZG},JG=ct(vo,e=>Math.sin(e)),QG={kernelName:vo,backendName:"cpu",kernelFunc:JG},ej=ct(Il,e=>Math.sinh(e)),tj={kernelName:Il,backendName:"cpu",kernelFunc:ej},nj=11920928955078125e-23,r6=Math.log(nj)+2,sj=ct(Cl,e=>{let t=e>-r6,n=e<r6,s=Math.exp(e),r;return n?r=s:t?r=e:r=Math.log(1+s),r}),rj={kernelName:Cl,backendName:"cpu",kernelFunc:sj};function aj(e){let{inputs:t,backend:n,attrs:s}=e,{x:r}=t,{blockShape:a,paddings:o}=s;Se([r],"spaceToBatchND");let i=w.sizeFromShape(a),l=[[0,0]];l.push(...o);for(let k=1+a.length;k<r.shape.length;++k)l.push([0,0]);let u=n6.kernelFunc({inputs:{x:r},backend:n,attrs:{paddings:l,constantValue:0}}),c=_.getReshaped(u.shape,a,i,!1),d=_.getPermuted(c.length,a.length,!1),p=_.getReshapedPermuted(u.shape,a,i,!1),m=wt({inputs:{x:u},backend:n,attrs:{shape:c}}),y=ws({inputs:{x:m},backend:n,attrs:{perm:d}}),v=wt({inputs:{x:y},backend:n,attrs:{shape:p}});return n.disposeIntermediateTensorInfo(u),n.disposeIntermediateTensorInfo(m),n.disposeIntermediateTensorInfo(y),v}var oj={kernelName:Tl,backendName:"cpu",kernelFunc:aj};function ij(e){let{inputs:t,backend:n}=e,{indices:s,values:r,denseShape:a,defaultValue:o}=t;if(a.shape.length!==1)throw new Error(`Dense shape must be a vector, saw:
|
|
${a.shape}`);if(s.shape.length!==2)throw new Error(`Indices must be a matrix, saw:
|
|
${s.shape}`);if(r.shape.length!==1)throw new Error(`Values must be a vector, saw:
|
|
${r.shape}`);if(o.shape.length!==0)throw new Error(`Default value must be a scalar, saw:
|
|
${o.shape}`);let i=n.data.get(s.dataId).values,l=n.data.get(r.dataId).values,u=n.data.get(a.dataId).values,c=n.data.get(o.dataId).values[0],[d,p,h,f,m]=Ew(i,s.shape,s.dtype,l,r.dtype,u,c);return[n.makeTensorInfo(p,s.dtype,d),n.makeTensorInfo([p[0]],r.dtype,h),n.makeTensorInfo([f.length],"bool",new Uint8Array(f.map(g=>Number(g)))),n.makeTensorInfo([m.length],s.dtype,new Int32Array(m))]}var lj={kernelName:Wp,backendName:"cpu",kernelFunc:ij};function uj(e){let{inputs:t,backend:n}=e,{inputIndices:s,inputShape:r,newShape:a}=t;if(s.shape.length!==2)throw new Error(`Input indices should be a matrix but received shape
|
|
${s.shape}`);if(r.shape.length!==1)throw new Error(`Input shape should be a vector but received shape
|
|
${r.shape}`);if(a.shape.length!==1)throw new Error(`Target shape should be a vector but received shape ${a.shape}`);let o=Array.from(n.data.get(r.dataId).values),i=n.data.get(s.dataId).values,l=Array.from(n.data.get(a.dataId).values),[u,c,d]=Rw(i,s.shape,s.dtype,o,l);return[n.makeTensorInfo(c,s.dtype,u),n.makeTensorInfo([d.length],a.dtype,new Int32Array(d))]}var cj={kernelName:Vp,backendName:"cpu",kernelFunc:uj};function dj(e){let{inputs:t,backend:n}=e,{data:s,indices:r,segmentIds:a}=t;if(s.shape.length<1)throw new Error("Data should be at least 1 dimensional but received scalar");if(r.shape.length!==1)throw new Error(`Indices should be a vector but received shape
|
|
${r.shape}`);if(a.shape.length!==1)throw new Error(`Segment ids should be a vector but received shape
|
|
${a.shape}`);let o=n.data.get(s.dataId).values,i=n.data.get(r.dataId).values,l=n.data.get(a.dataId).values,[u,c]=K2(o,s.shape,s.dtype,i,l,!0);return n.makeTensorInfo(c,s.dtype,u)}var pj={kernelName:Up,backendName:"cpu",kernelFunc:dj};function hj(e){let{inputs:t,backend:n}=e,{data:s,indices:r,segmentIds:a}=t;if(s.shape.length<1)throw new Error("Data should be at least 1 dimensional but received scalar");if(r.shape.length!==1)throw new Error(`Indices should be a vector but received shape
|
|
${r.shape}`);if(a.shape.length!==1)throw new Error(`Segment ids should be a vector but received shape
|
|
${a.shape}`);let o=n.data.get(s.dataId).values,i=n.data.get(r.dataId).values,l=n.data.get(a.dataId).values,[u,c]=K2(o,s.shape,s.dtype,i,l);return n.makeTensorInfo(c,s.dtype,u)}var fj={kernelName:Hp,backendName:"cpu",kernelFunc:hj};function mj(e){let{inputs:t,backend:n,attrs:s}=e,{sparseIndices:r,sparseValues:a,defaultValue:o}=t,{outputShape:i}=s,{sliceRank:l,numUpdates:u,sliceSize:c,strides:d,outputSize:p}=_.calculateShapes(a,r,i),h=!1,f=n.bufferSync(r),m=n.bufferSync(a),g=n.data.get(o.dataId).values[0],A=s6(f,m,i,p,c,u,l,d,g,h);return n.makeTensorInfo(i,A.dtype,A.values)}var gj={kernelName:Gp,backendName:"cpu",kernelFunc:mj};function Aj(e){let{inputs:t,backend:n,attrs:s}=e,{x:r}=t,{numOrSizeSplits:a,axis:o}=s,i=w.parseAxisParam(o,r.shape)[0],l=_.prepareSplitSize(r,a,i),u=new Array(r.shape.length).fill(0),c=r.shape.slice();return l.map(d=>{let p=[...c];p[i]=d;let h=oi({inputs:{x:r},backend:n,attrs:{begin:u,size:p}});return u[i]+=d,h})}var yj={kernelName:Nl,backendName:"cpu",kernelFunc:Aj},xj={kernelName:lc,backendName:"cpu",kernelFunc:({inputs:e,backend:t})=>{let{x:n}=e,s=t;Se(n,"square");let r=s.data.get(n.dataId).values,a=new Float32Array(r.length);for(let i=0;i<r.length;++i){let l=r[i];a[i]=l*l}return{dataId:s.write(a,n.shape,n.dtype),shape:n.shape,dtype:n.dtype}}},bj=ct(ea,(e,t)=>{let n=t;return isNaN(e)?NaN:e>0?1:n.alpha}),vj={kernelName:ea,backendName:"cpu",kernelFunc:bj};function wj(e){let{inputs:t,backend:n,attrs:s}=e,{x:r}=t,{begin:a,end:o,strides:i,beginMask:l,endMask:u,ellipsisMask:c,newAxisMask:d,shrinkAxisMask:p}=s;Se(r,"stridedSlice");let{nonStrided:h,$begin:f,$strides:m,size:g,newShape:A,outShape:y}=Cn.sliceInfo(r.shape,a,o,i,l,u,c,d,p),x=wt({inputs:{x:r},backend:n,attrs:{shape:A}}),b;if(h){let k=oi({inputs:{x},backend:n,attrs:{begin:f,size:g}});b=wt({inputs:{x:k},backend:n,attrs:{shape:y}}),n.disposeIntermediateTensorInfo(k)}else if(y.some(k=>k===0))b=n.makeTensorInfo(y,r.dtype,[]);else{let k=n.bufferSync(x),S=_w(y,k,m,f);b=n.makeTensorInfo(S.shape,S.dtype,S.values)}let v=wt({inputs:{x:b},backend:n,attrs:{shape:y}});return n.disposeIntermediateTensorInfo(x),n.disposeIntermediateTensorInfo(b),v}var kj={kernelName:El,backendName:"cpu",kernelFunc:wj};function Ij(e){let{inputs:t,backend:n,attrs:s}=e,{separator:r,nGramWidths:a,leftPad:o,rightPad:i,padWidth:l,preserveShortSequences:u}=s,{data:c,dataSplits:d}=t,p=n.data.get(c.dataId).values,h=n.data.get(d.dataId).values,[f,m]=$w(p,h,r,a,o,i,l,u);return[n.makeTensorInfo([f.length],"string",f),n.makeTensorInfo(d.shape,"int32",m)]}var Sj={kernelName:jp,backendName:"cpu",kernelFunc:Ij};function Cj(e){let{inputs:t,backend:n,attrs:s}=e,{skipEmpty:r}=s,{input:a,delimiter:o}=t;if(a.dtype!=="string")throw new Error("Input must be of datatype string");if(a.shape.length!==1)throw new Error(`Input must be a vector, got shape: ${a.shape}`);if(o.shape.length!==0)throw new Error(`Delimiter must be a scalar, got shape: ${o.shape}`);let i=n.data.get(a.dataId).values,l=n.data.get(o.dataId).values[0],[u,c,d]=Fw(i,l,r),p=c.length;return[n.makeTensorInfo([p,2],"int32",u),n.makeTensorInfo([p],"string",c),n.makeTensorInfo([2],"int32",new Int32Array(d))]}var Tj={kernelName:qp,backendName:"cpu",kernelFunc:Cj};function Nj(e){let{inputs:t,backend:n,attrs:s}=e,{numBuckets:r}=s,{input:a}=t;if(a.dtype!=="string")throw new Error("Input must be of datatype string");if(r<=0)throw new Error("Number of buckets must be at least 1");let o=n.data.get(a.dataId).values,i=Ow(o,r);return n.makeTensorInfo(a.shape,"int32",i)}var Ej={kernelName:Xp,backendName:"cpu",kernelFunc:Nj},Rj=ct(No,e=>Math.tan(e)),Dj={kernelName:No,backendName:"cpu",kernelFunc:Rj},_j=ct(Eo,e=>Math.tanh(e)),$j={kernelName:Eo,backendName:"cpu",kernelFunc:_j};function Fj(e){let{inputs:t,backend:n,attrs:s}=e,{x:r}=t,{reps:a}=s;Se(r,"tile");let o=Mw(n.bufferSync(r),a);return n.makeTensorInfo(o.shape,o.dtype,o.values)}var Oj={kernelName:Qr,backendName:"cpu",kernelFunc:Fj};function Pj(e){let{inputs:t,backend:n,attrs:s}=e,{x:r}=t,{k:a,sorted:o}=s;Se(r,"topk");let i=n.data.get(r.dataId).values,[l,u]=Lw(i,r.shape,r.dtype,a,o);return[n.makeTensorInfo(l.shape,l.dtype,l.values),n.makeTensorInfo(u.shape,u.dtype,u.values)]}var Mj={kernelName:Rl,backendName:"cpu",kernelFunc:Pj};function zj(e){let{inputs:t,attrs:n,backend:s}=e,{image:r,transforms:a}=t,{interpolation:o,fillMode:i,fillValue:l,outputShape:u}=n,[c,d,p,h]=r.shape,[f,m]=u!=null?u:[d,p],g=[c,f,m,h],A=w.computeStrides(r.shape),y=A[0],x=A[1],b=A[2],v=w.getTypedArrayFromDType(r.dtype,w.sizeFromShape(g));v.fill(l);let k=s.data.get(r.dataId).values,S=s.data.get(a.dataId).values;for(let D=0;D<c;++D){let O=a.shape[0]===1?S:S.subarray(D*8,D*8+8);for(let E=0;E<f;++E)for(let R=0;R<m;++R)for(let T=0;T<h;++T){let P,U=O[6]*R+O[7]*E+1;if(U===0)continue;let j=(O[0]*R+O[1]*E+O[2])/U,q=(O[3]*R+O[4]*E+O[5])/U,X=a6(j,p,i),te=a6(q,d,i);switch(o){case"nearest":P=Hj(k,d,p,y,x,b,D,te,X,T,l);break;case"bilinear":P=Gj(k,d,p,y,x,b,D,te,X,T,l);break;default:throw new Error(`Error in Transform: Expect 'nearest' or 'bilinear', but got ${o}`)}let ne=D*y+E*x+R*b+T;v[ne]=P}return s.makeTensorInfo(g,r.dtype,v)}return{dataId:s.write(v,g,r.dtype),shape:r.shape,dtype:r.dtype}}var Lj={kernelName:Dl,backendName:"cpu",kernelFunc:zj};function a6(e,t,n){switch(n){case"reflect":return Bj(e,t);case"wrap":return Wj(e,t);case"nearest":return Uj(e,t);case"constant":default:return Vj(e,t)}}function Bj(e,t){let n=e;if(n<0)if(t<=1)n=0;else{let s=2*t;n<s&&(n=s*Math.trunc(-n/s)+n),n=n<-t?n+s:-n-1}else if(n>t-1)if(t<=1)n=0;else{let s=2*t;n-=s*Math.trunc(n/s),n>=t&&(n=s-n-1)}return w.clamp(0,n,t-1)}function Wj(e,t){let n=e;if(n<0)if(t<=1)n=0;else{let s=t-1;n+=t*(Math.trunc(-n/s)+1)}else if(n>t-1)if(t<=1)n=0;else{let s=t-1;n-=t*Math.trunc(n/s)}return w.clamp(0,n,t-1)}function Vj(e,t){return e}function Uj(e,t){return w.clamp(0,e,t-1)}function dd(e,t,n,s,r,a,o,i,l,u,c){let d=o*s+i*r+l*a+u;return 0<=i&&i<t&&0<=l&&l<n?e[d]:c}function Hj(e,t,n,s,r,a,o,i,l,u,c){let d=Math.round(i),p=Math.round(l);return dd(e,t,n,s,r,a,o,d,p,u,c)}function Gj(e,t,n,s,r,a,o,i,l,u,c){let d=Math.floor(i),p=Math.floor(l),h=d+1,f=p+1,m=(f-l)*dd(e,t,n,s,r,a,o,d,p,u,c)+(l-p)*dd(e,t,n,s,r,a,o,d,f,u,c),g=(f-l)*dd(e,t,n,s,r,a,o,h,p,u,c)+(l-p)*dd(e,t,n,s,r,a,o,h,f,u,c);return(h-i)*m+(i-d)*g}function jj(e){let{inputs:t,attrs:n,backend:s}=e,{axis:r}=n,{x:a}=t;Se(a,"unique");let o=s.data.get(a.dataId).values,{outputValues:i,outputShape:l,indices:u}=Bw(o,r,a.shape,a.dtype);return[s.makeTensorInfo(l,a.dtype,i),s.makeTensorInfo([u.length],"int32",u)]}var qj={kernelName:Kp,backendName:"cpu",kernelFunc:jj};function Xj(e){let{inputs:t,backend:n,attrs:s}=e,{value:r}=t,{axis:a}=s;a<0&&(a+=r.shape.length);let o=r.shape.length,i=r.shape[a],l=new Array(o-1),u=0;for(let h=0;h<o;h++)h!==a&&(l[u++]=r.shape[h]);let c=new Array(o).fill(0),d=r.shape.slice();d[a]=1;let p=new Array(i);for(let h=0;h<p.length;h++){c[a]=h;let f=oi({inputs:{x:r},backend:n,attrs:{begin:c,size:d}});p[h]=wt({inputs:{x:f},backend:n,attrs:{shape:l}}),n.disposeIntermediateTensorInfo(f)}return p}var Kj={kernelName:_l,backendName:"cpu",kernelFunc:Xj};function Zj(e){let{inputs:t,backend:n,attrs:s}=e,{x:r,segmentIds:a}=t,{numSegments:o}=s;Se(r,"unsortedSegmentSum");let i=r.shape.length,l=a.shape.length,u=[],c=[],d=i-l,p=a;for(let f=0;f<d;++f){let m=Mf({inputs:{input:p},backend:n,attrs:{dim:f+1}});p=m,c.push(m)}for(let f=0;f<o;++f){let m=w.createScalarValue(f,"int32"),g=n.makeTensorInfo([],"int32",m),A=lw({inputs:{a:g,b:p},backend:n}),y=ba({inputs:{x:A},backend:n,attrs:{dtype:"float32"}}),x=Of({inputs:{a:y,b:r},backend:n}),b=cd({inputs:{x},backend:n,attrs:{axis:0,keepDims:!1}});u.push(b),c.push(g),c.push(A),c.push(y),c.push(x),c.push(b)}let h=t6({inputs:u,backend:n,attrs:{axis:0}});return c.forEach(f=>n.disposeIntermediateTensorInfo(f)),h}var Yj={kernelName:uc,backendName:"cpu",kernelFunc:Zj},Jj=[aV,JB,iV,uV,rW,dV,hV,mV,AV,xV,vV,kV,SV,NV,RV,$V,OV,MV,LV,sV,WV,UV,GV,qV,nW,oW,KV,QB,YV,QV,nU,rU,eU,lU,cU,oU,pU,fU,gU,yU,bU,wU,kU,SU,TU,EU,RU,_U,DU,ey,OU,ZW,MU,iW,GU,lW,jU,cW,JU,QU,tH,pW,rH,oH,lH,cH,pH,fW,gW,eW,fH,JV,gH,yH,bH,YW,yW,bW,wH,wW,IH,TH,EH,_H,FH,PH,IW,LH,WH,UH,GH,qH,MH,KH,YH,CW,QH,nG,oG,NW,RW,uG,pG,mG,_W,AG,xG,bG,n6,IG,QW,OW,CG,tW,NG,eV,tV,nV,RG,_G,FG,PG,zG,LG,WG,MW,UG,GG,KG,LW,YG,QG,tj,BW,rG,rj,oj,lj,cj,pj,fj,gj,yj,UW,xj,GW,vj,kj,Sj,Tj,Ej,KW,$U,Dj,$j,Oj,Mj,$W,Lj,qj,Kj,Yj,yG];for(let e of Jj)Fo(e);var o6={};Le(o6,{assertNotComplex:()=>mu,bindCanvasToFramebuffer:()=>cq,bindColorTextureToFramebuffer:()=>Vf,bindTextureToProgramUniformSampler:()=>v6,bindTextureUnit:()=>y6,bindVertexBufferToProgramAttribute:()=>ay,callAndCheck:()=>ke,canBeRepresented:()=>i6,createFragmentShader:()=>c6,createFramebuffer:()=>A6,createProgram:()=>d6,createStaticIndexBuffer:()=>f6,createStaticVertexBuffer:()=>h6,createTexture:()=>m6,createVertexShader:()=>u6,getBatchDim:()=>li,getExtensionOrThrow:()=>fd,getFramebufferErrorMessage:()=>w6,getMaxTexturesInShader:()=>C6,getNumChannels:()=>lq,getProgramUniformLocation:()=>b6,getProgramUniformLocationOrThrow:()=>x6,getRowsCols:()=>ui,getShapeAs3D:()=>Uf,getTextureShapeFromLogicalShape:()=>I6,getWebGLDisjointQueryTimerVersion:()=>T6,getWebGLErrorMessage:()=>l6,getWebGLMaxTextureSize:()=>S6,hasExtension:()=>Is,isCapableOfRenderingToFloatTexture:()=>N6,isDownloadFloatTextureEnabled:()=>E6,isReshapeFree:()=>gd,isWebGLFenceEnabled:()=>R6,isWebGLVersionEnabled:()=>iy,linkProgram:()=>p6,resetMaxTextureSize:()=>dq,resetMaxTexturesInShader:()=>pq,unbindColorTextureFromFramebuffer:()=>oy,unbindTextureUnit:()=>uq,validateFramebuffer:()=>md,validateProgram:()=>Wf,validateTextureSize:()=>g6});var ii={},sy={alpha:!1,antialias:!1,premultipliedAlpha:!1,preserveDrawingBuffer:!1,depth:!1,stencil:!1,failIfMajorPerformanceCaveat:!0};function Lf(e,t){ii[e]=t}function mr(e){if(!(e in ii)){let n=eq(e);if(n!==null)ii[e]=n;else return console.log("Could not get context for WebGL version",e),null}let t=ii[e];return t.isContextLost()?(delete ii[e],mr(e)):(t.disable(t.DEPTH_TEST),t.disable(t.STENCIL_TEST),t.disable(t.BLEND),t.disable(t.DITHER),t.disable(t.POLYGON_OFFSET_FILL),t.disable(t.SAMPLE_COVERAGE),t.enable(t.SCISSOR_TEST),t.enable(t.CULL_FACE),t.cullFace(t.BACK),ii[e])}function Qj(e){if(typeof OffscreenCanvas!="undefined"&&e===2)return new OffscreenCanvas(300,150);if(typeof document!="undefined")return document.createElement("canvas");throw new Error("Cannot create a canvas in this context")}function eq(e){if(e!==1&&e!==2)throw new Error("Cannot get WebGL rendering context, WebGL is disabled.");let t=Qj(e);return t.addEventListener("webglcontextlost",n=>{n.preventDefault(),delete ii[e]},!1),e===1?t.getContext("webgl",sy)||t.getContext("experimental-webgl",sy):t.getContext("webgl2",sy)}var pd;(function(e){e[e.DENSE=0]="DENSE",e[e.SHARED_BATCH=1]="SHARED_BATCH"})(pd||(pd={}));var ks;(function(e){e[e.RENDER=0]="RENDER",e[e.UPLOAD=1]="UPLOAD",e[e.PIXELS=2]="PIXELS",e[e.DOWNLOAD=3]="DOWNLOAD"})(ks||(ks={}));var gn;(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"})(gn||(gn={}));function hd(e,t){return[t,e]}function tq(e,t){return e*t}function Bf(e){let t=w.sizeFromShape(e),n=Math.ceil(t/4);return w.sizeToSquarishShape(n)}function fu(e,t){return[Math.max(1,Math.ceil(t/2)),Math.max(1,Math.ceil(e/2))]}function nq(e,t){let[n,s]=fu(e,t);return n*s*4}function ry(e,t){let n=e,s,r,a,o,i,l,u,c,d,p;return Y().getNumber("WEBGL_VERSION")===2?(s=n.R32F,r=n.R16F,a=n.RGBA16F,o=n.RGBA32F,i=n.RED,u=4,c=1,d=n.HALF_FLOAT,p=n.FLOAT):(s=e.RGBA,r=e.RGBA,a=e.RGBA,o=n.RGBA,i=e.RGBA,u=4,c=4,d=t!=null?t.HALF_FLOAT_OES:null,p=e.FLOAT),l=e.RGBA,{internalFormatFloat:s,internalFormatHalfFloat:r,internalFormatPackedHalfFloat:a,internalFormatPackedFloat:o,textureFormatFloat:i,downloadTextureFormat:l,downloadUnpackNumChannels:u,defaultNumChannels:c,textureTypeHalfFloat:d,textureTypeFloat:p}}function ke(e,t){let n=t();return Y().getBool("DEBUG")&&sq(e),n}function sq(e){let t=e.getError();if(t!==e.NO_ERROR)throw new Error("WebGL Error: "+l6(e,t))}var rq=596e-10,aq=65504;function i6(e){return!!(Y().getBool("WEBGL_RENDER_FLOAT32_ENABLED")||e===0||rq<Math.abs(e)&&Math.abs(e)<aq)}function l6(e,t){switch(t){case e.NO_ERROR:return"NO_ERROR";case e.INVALID_ENUM:return"INVALID_ENUM";case e.INVALID_VALUE:return"INVALID_VALUE";case e.INVALID_OPERATION:return"INVALID_OPERATION";case e.INVALID_FRAMEBUFFER_OPERATION:return"INVALID_FRAMEBUFFER_OPERATION";case e.OUT_OF_MEMORY:return"OUT_OF_MEMORY";case e.CONTEXT_LOST_WEBGL:return"CONTEXT_LOST_WEBGL";default:return`Unknown error code ${t}`}}function fd(e,t){return Mr(e,()=>e.getExtension(t),'Extension "'+t+'" not supported on this browser.')}function u6(e,t){let n=Mr(e,()=>e.createShader(e.VERTEX_SHADER),"Unable to create vertex WebGLShader.");if(ke(e,()=>e.shaderSource(n,t)),ke(e,()=>e.compileShader(n)),e.getShaderParameter(n,e.COMPILE_STATUS)===!1)throw console.log(e.getShaderInfoLog(n)),new Error("Failed to compile vertex shader.");return n}function c6(e,t){let n=Mr(e,()=>e.createShader(e.FRAGMENT_SHADER),"Unable to create fragment WebGLShader.");if(ke(e,()=>e.shaderSource(n,t)),ke(e,()=>e.compileShader(n)),e.getShaderParameter(n,e.COMPILE_STATUS)===!1)throw iq(t,e.getShaderInfoLog(n)),new Error("Failed to compile fragment shader.");return n}var oq=/ERROR: [0-9]+:([0-9]+):/g;function iq(e,t){let n=oq.exec(t);if(n==null){console.log(`Couldn't parse line number in error: ${t}`),console.log(e);return}let s=+n[1],r=e.split(`
|
|
`),a=r.length.toString().length+2,o=r.map((d,p)=>w.rightPad((p+1).toString(),a)+d),i=0;for(let d=0;d<o.length;d++)i=Math.max(o[d].length,i);let l=o.slice(0,s-1),u=o.slice(s-1,s),c=o.slice(s);console.log(l.join(`
|
|
`)),console.log(t.split(`
|
|
`)[0]),console.log(`%c ${w.rightPad(u[0],i)}`,"border:1px solid red; background-color:#e3d2d2; color:#a61717"),console.log(c.join(`
|
|
`))}function d6(e){return Mr(e,()=>e.createProgram(),"Unable to create WebGLProgram.")}function p6(e,t){if(ke(e,()=>e.linkProgram(t)),e.getProgramParameter(t,e.LINK_STATUS)===!1)throw console.log(e.getProgramInfoLog(t)),new Error("Failed to link vertex and fragment shaders.")}function Wf(e,t){if(ke(e,()=>e.validateProgram(t)),e.getProgramParameter(t,e.VALIDATE_STATUS)===!1)throw console.log(e.getProgramInfoLog(t)),new Error("Shader program validation failed.")}function h6(e,t){let n=Mr(e,()=>e.createBuffer(),"Unable to create WebGLBuffer");return ke(e,()=>e.bindBuffer(e.ARRAY_BUFFER,n)),ke(e,()=>e.bufferData(e.ARRAY_BUFFER,t,e.STATIC_DRAW)),n}function f6(e,t){let n=Mr(e,()=>e.createBuffer(),"Unable to create WebGLBuffer");return ke(e,()=>e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,n)),ke(e,()=>e.bufferData(e.ELEMENT_ARRAY_BUFFER,t,e.STATIC_DRAW)),n}function lq(){return Y().getNumber("WEBGL_VERSION")===2?1:4}function m6(e){return Mr(e,()=>e.createTexture(),"Unable to create WebGLTexture.")}function g6(e,t){let n=Y().getNumber("WEBGL_MAX_TEXTURE_SIZE");if(e<=0||t<=0){let s=`[${e}x${t}]`;throw new Error("Requested texture size "+s+" is invalid.")}if(e>n||t>n){let s=`[${e}x${t}]`,r=`[${n}x${n}]`;throw new Error("Requested texture size "+s+" greater than WebGL maximum on this browser / GPU "+r+".")}}function A6(e){return Mr(e,()=>e.createFramebuffer(),"Unable to create WebGLFramebuffer.")}function ay(e,t,n,s,r,a,o){let i=e.getAttribLocation(t,n);return i===-1?!1:(ke(e,()=>e.bindBuffer(e.ARRAY_BUFFER,s)),ke(e,()=>e.vertexAttribPointer(i,r,e.FLOAT,!1,a,o)),ke(e,()=>e.enableVertexAttribArray(i)),!0)}function y6(e,t,n){k6(e,n),ke(e,()=>e.activeTexture(e.TEXTURE0+n)),ke(e,()=>e.bindTexture(e.TEXTURE_2D,t))}function uq(e,t){k6(e,t),ke(e,()=>e.activeTexture(e.TEXTURE0+t)),ke(e,()=>e.bindTexture(e.TEXTURE_2D,null))}function x6(e,t,n){return Mr(e,()=>e.getUniformLocation(t,n),'uniform "'+n+'" not present in program.')}function b6(e,t,n){return e.getUniformLocation(t,n)}function v6(e,t,n,s){ke(e,()=>y6(e,t,s)),ke(e,()=>e.uniform1i(n,s))}function cq(e){ke(e,()=>e.bindFramebuffer(e.FRAMEBUFFER,null)),ke(e,()=>e.viewport(0,0,e.canvas.width,e.canvas.height)),ke(e,()=>e.scissor(0,0,e.canvas.width,e.canvas.height))}function Vf(e,t,n){ke(e,()=>e.bindFramebuffer(e.FRAMEBUFFER,n)),ke(e,()=>e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,t,0))}function oy(e,t){ke(e,()=>e.bindFramebuffer(e.FRAMEBUFFER,t)),ke(e,()=>e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,null,0))}function md(e){let t=e.checkFramebufferStatus(e.FRAMEBUFFER);if(t!==e.FRAMEBUFFER_COMPLETE)throw new Error("Error binding framebuffer: "+w6(e,t))}function w6(e,t){switch(t){case e.FRAMEBUFFER_INCOMPLETE_ATTACHMENT:return"FRAMEBUFFER_INCOMPLETE_ATTACHMENT";case e.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT:return"FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT";case e.FRAMEBUFFER_INCOMPLETE_DIMENSIONS:return"FRAMEBUFFER_INCOMPLETE_DIMENSIONS";case e.FRAMEBUFFER_UNSUPPORTED:return"FRAMEBUFFER_UNSUPPORTED";default:return`unknown error ${t}`}}function Mr(e,t,n){let s=ke(e,()=>t());if(s==null)throw new Error(n);return s}function k6(e,t){let n=e.MAX_COMBINED_TEXTURE_IMAGE_UNITS-1,s=t+e.TEXTURE0;if(s<e.TEXTURE0||s>n){let r=`[gl.TEXTURE0, gl.TEXTURE${n}]`;throw new Error(`textureUnit must be in ${r}.`)}}function li(e,t=2){return w.sizeFromShape(e.slice(0,e.length-t))}function ui(e){if(e.length===0)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 Uf(e){let t=[1,1,1];return e.length===0||e.length===1&&e[0]===1||(t=[li(e),...ui(e)]),t}function I6(e,t=!1){let n=Y().getNumber("WEBGL_MAX_TEXTURE_SIZE");t&&(n=n*2,e=e.map((r,a)=>a>=e.length-2?w.nearestLargerEven(e[a]):e[a]),e.length===1&&(e=[2,e[0]])),e.length!==2&&(e=w.squeezeShape(e).newShape);let s=w.sizeFromShape(e);if(e.length<=1&&s<=n)return[1,s];if(e.length===2&&e[0]<=n&&e[1]<=n)return e;if(e.length===3&&e[0]*e[1]<=n&&e[2]<=n)return[e[0]*e[1],e[2]];if(e.length===3&&e[0]<=n&&e[1]*e[2]<=n)return[e[0],e[1]*e[2]];if(e.length===4&&e[0]*e[1]*e[2]<=n&&e[3]<=n)return[e[0]*e[1]*e[2],e[3]];if(e.length===4&&e[0]<=n&&e[1]*e[2]*e[3]<=n)return[e[0],e[1]*e[2]*e[3]];if(t){let r=li(e),a=2,o=2;return e.length&&([a,o]=ui(e)),s=r*(a/2)*(o/2),w.sizeToSquarishShape(s).map(i=>i*2)}return w.sizeToSquarishShape(s)}function Hf(e){return e%2==0}function gd(e,t){if(e=e.slice(-2),t=t.slice(-2),w.arraysEqual(e,t)||!e.length||!t.length||e[0]===0||e[1]===0||t[0]===0||t[1]===0)return!0;if(e.length!==t.length){let n=e.slice(-1)[0],s=t.slice(-1)[0];if(n===s||Hf(n)&&Hf(s)&&(e[0]===1||t[0]===1))return!0}return e[1]===t[1]&&Hf(e[0])&&Hf(t[0])}var Gf,jf;function S6(e){if(Gf==null){let t=mr(e);Gf=t.getParameter(t.MAX_TEXTURE_SIZE)}return Gf}function dq(){Gf=null}function pq(){jf=null}function C6(e){if(jf==null){let t=mr(e);jf=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS)}return Math.min(16,jf)}function T6(e){if(e===0)return 0;let t,n=mr(e);return Is(n,"EXT_disjoint_timer_query_webgl2")&&e===2?t=2:Is(n,"EXT_disjoint_timer_query")?t=1:t=0,t}function Is(e,t){return e.getExtension(t)!=null}function iy(e){try{if(mr(e)!=null)return!0}catch(t){return console.log("Error when getting WebGL context: ",t),!1}return!1}function N6(e){if(e===0)return!1;let t=mr(e);if(e===1){if(!Is(t,"OES_texture_float"))return!1}else if(!Is(t,"EXT_color_buffer_float"))return!1;return ly(t)}function E6(e){if(e===0)return!1;let t=mr(e);if(e===1){if(!Is(t,"OES_texture_float")||!Is(t,"WEBGL_color_buffer_float"))return!1}else{if(Is(t,"EXT_color_buffer_float"))return ly(t);let s="EXT_color_buffer_half_float";if(Is(t,s)){let r=t.getExtension(s);return hq(t,r)}return!1}return ly(t)}function ly(e){let t=ry(e),n=e.createTexture();e.bindTexture(e.TEXTURE_2D,n);let s=1,r=1;e.texImage2D(e.TEXTURE_2D,0,t.internalFormatFloat,s,r,0,t.textureFormatFloat,t.textureTypeFloat,null);let a=e.createFramebuffer();e.bindFramebuffer(e.FRAMEBUFFER,a),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,n,0);let o=e.checkFramebufferStatus(e.FRAMEBUFFER)===e.FRAMEBUFFER_COMPLETE;return e.bindTexture(e.TEXTURE_2D,null),e.bindFramebuffer(e.FRAMEBUFFER,null),e.deleteTexture(n),e.deleteFramebuffer(a),o}function hq(e,t){let n=ry(e,t),s=e.createTexture();e.bindTexture(e.TEXTURE_2D,s);let r=1,a=1;e.texImage2D(e.TEXTURE_2D,0,n.internalFormatHalfFloat,r,a,0,n.textureFormatFloat,n.textureTypeHalfFloat,null);let o=e.createFramebuffer();e.bindFramebuffer(e.FRAMEBUFFER,o),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,s,0);let i=e.checkFramebufferStatus(e.FRAMEBUFFER)===e.FRAMEBUFFER_COMPLETE;return e.bindTexture(e.TEXTURE_2D,null),e.bindFramebuffer(e.FRAMEBUFFER,null),e.deleteTexture(s),e.deleteFramebuffer(o),i}function R6(e){return e!==2?!1:mr(e).fenceSync!=null}function mu(e,t){Array.isArray(e)||(e=[e]),e.forEach(n=>{n!=null&&w.assert(n.dtype!=="complex64",()=>`${t} does not support complex64 tensors in the WebGL backend.`)})}var De=Y();De.registerFlag("HAS_WEBGL",()=>De.getNumber("WEBGL_VERSION")>0);De.registerFlag("WEBGL_VERSION",()=>iy(2)?2:iy(1)?1:0);De.registerFlag("WEBGL_CHECK_NUMERICAL_PROBLEMS",()=>!1);De.registerFlag("WEBGL_BUFFER_SUPPORTED",()=>De.get("WEBGL_VERSION")===2);De.registerFlag("WEBGL_CPU_FORWARD",()=>!0);De.registerFlag("WEBGL_FORCE_F16_TEXTURES",()=>!1);De.registerFlag("WEBGL_PACK",()=>De.getBool("HAS_WEBGL"));De.registerFlag("WEBGL_PACK_NORMALIZATION",()=>De.getBool("WEBGL_PACK"));De.registerFlag("WEBGL_PACK_CLIP",()=>De.getBool("WEBGL_PACK"));De.registerFlag("WEBGL_PACK_DEPTHWISECONV",()=>De.getBool("WEBGL_PACK"));De.registerFlag("WEBGL_PACK_BINARY_OPERATIONS",()=>De.getBool("WEBGL_PACK"));De.registerFlag("WEBGL_PACK_UNARY_OPERATIONS",()=>De.getBool("WEBGL_PACK"));De.registerFlag("WEBGL_PACK_ARRAY_OPERATIONS",()=>De.getBool("WEBGL_PACK"));De.registerFlag("WEBGL_PACK_IMAGE_OPERATIONS",()=>De.getBool("WEBGL_PACK"));De.registerFlag("WEBGL_PACK_REDUCE",()=>De.getBool("WEBGL_PACK"));De.registerFlag("WEBGL_LAZILY_UNPACK",()=>De.getBool("WEBGL_PACK"));De.registerFlag("WEBGL_CONV_IM2COL",()=>De.getBool("WEBGL_PACK"));De.registerFlag("WEBGL_MAX_TEXTURE_SIZE",()=>S6(De.getNumber("WEBGL_VERSION")));De.registerFlag("WEBGL_MAX_TEXTURES_IN_SHADER",()=>C6(De.getNumber("WEBGL_VERSION")));De.registerFlag("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION",()=>{let e=De.getNumber("WEBGL_VERSION");return e===0?0:T6(e)});De.registerFlag("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE",()=>De.getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")>0&&!xc.isMobile());De.registerFlag("WEBGL_RENDER_FLOAT32_CAPABLE",()=>N6(De.getNumber("WEBGL_VERSION")));De.registerFlag("WEBGL_RENDER_FLOAT32_ENABLED",()=>De.getBool("WEBGL_FORCE_F16_TEXTURES")?!1:De.getBool("WEBGL_RENDER_FLOAT32_CAPABLE"));De.registerFlag("WEBGL_DOWNLOAD_FLOAT_ENABLED",()=>E6(De.getNumber("WEBGL_VERSION")));De.registerFlag("WEBGL_FENCE_API_ENABLED",()=>R6(De.getNumber("WEBGL_VERSION")));De.registerFlag("WEBGL_SIZE_UPLOAD_UNIFORM",()=>De.getBool("WEBGL_RENDER_FLOAT32_ENABLED")?4:0);De.registerFlag("WEBGL_DELETE_TEXTURE_THRESHOLD",()=>-1,e=>{if(e<0&&e!==-1)throw new Error(`WEBGL_DELETE_TEXTURE_THRESHOLD must be -1 (indicating never delete) or at least 0, but got ${e}.`)});De.registerFlag("WEBGL_FLUSH_THRESHOLD",()=>xc.isMobile()&&De.getBool("IS_CHROME")?1:-1,e=>{if(e<0&&e!==-1)throw new Error(`WEBGL_FLUSH_THRESHOLD must be -1 (indicating never manual flush) or at least 0, but got ${e}.`)});De.registerFlag("CPU_HANDOFF_SIZE_THRESHOLD",()=>128);De.registerFlag("WEBGL_USE_SHAPES_UNIFORMS",()=>!1);De.registerFlag("TOPK_LAST_DIM_CPU_HANDOFF_SIZE_THRESHOLD",()=>1e5);De.registerFlag("TOPK_K_CPU_HANDOFF_THRESHOLD",()=>128);function En(){let e,t,n,s,r,a,o,i,l,u;return Y().getNumber("WEBGL_VERSION")===2?(e="#version 300 es",t="in",n="out",s="in",r="texture",a="outputColor",o="out vec4 outputColor;",i=`
|
|
bool isnan_custom(float val) {
|
|
return (val > 0.0 || val < 0.0) ? false : val != 0.0;
|
|
}
|
|
|
|
bvec4 isnan_custom(vec4 val) {
|
|
return bvec4(isnan_custom(val.x),
|
|
isnan_custom(val.y), isnan_custom(val.z), isnan_custom(val.w));
|
|
}
|
|
|
|
#define isnan(value) isnan_custom(value)
|
|
`,l="",u=`
|
|
#define round(value) newRound(value)
|
|
int newRound(float value) {
|
|
return int(floor(value + 0.5));
|
|
}
|
|
|
|
ivec4 newRound(vec4 value) {
|
|
return ivec4(floor(value + vec4(0.5)));
|
|
}
|
|
`):(e="",t="attribute",n="varying",s="varying",r="texture2D",a="gl_FragColor",o="",i=`
|
|
#define isnan(value) isnan_custom(value)
|
|
bool isnan_custom(float val) {
|
|
return (val > 0. || val < 1. || val == 0.) ? false : true;
|
|
}
|
|
bvec4 isnan_custom(vec4 val) {
|
|
return bvec4(isnan(val.x), isnan(val.y), isnan(val.z), isnan(val.w));
|
|
}
|
|
`,l=`
|
|
uniform float INFINITY;
|
|
|
|
bool isinf(float val) {
|
|
return abs(val) == INFINITY;
|
|
}
|
|
bvec4 isinf(vec4 val) {
|
|
return equal(abs(val), vec4(INFINITY));
|
|
}
|
|
`,u=`
|
|
int round(float value) {
|
|
return int(floor(value + 0.5));
|
|
}
|
|
|
|
ivec4 round(vec4 value) {
|
|
return ivec4(floor(value + vec4(0.5)));
|
|
}
|
|
`),{version:e,attribute:t,varyingVs:n,varyingFs:s,texture2D:r,output:a,defineOutput:o,defineSpecialNaN:i,defineSpecialInf:l,defineRound:u}}function ci(e,t,n="index"){let s=w.computeStrides(t);return s.map((r,a)=>{let o=`int ${e[a]} = ${n} / ${r}`,i=a===s.length-1?`int ${e[a+1]} = ${n} - ${e[a]} * ${r}`:`index -= ${e[a]} * ${r}`;return`${o}; ${i};`}).join("")}function qf(e,t,n="index"){let s=w.computeStrides(t);return s.map((r,a)=>{let o=`int ${e[a]} = ${n} / outShapeStrides[${a}]`,i=a===s.length-1?`int ${e[a+1]} = ${n} - ${e[a]} * outShapeStrides[${a}]`:`index -= ${e[a]} * outShapeStrides[${a}]`;return`${o}; ${i};`}).join("")}function fq(e,t){let n=e.length,s=e.map(a=>`${t}[${a}]`),r=new Array(n-1);r[n-2]=s[n-1];for(let a=n-3;a>=0;--a)r[a]=`(${r[a+1]} * ${s[a+1]})`;return r}function mq(e,t,n="index"){let s=e.map((a,o)=>o),r=fq(s,t);return r.map((a,o)=>{let i=`int ${e[o]} = ${n} / ${r[o]}`,l=o===r.length-1?`int ${e[o+1]} = ${n} - ${e[o]} * ${r[o]}`:`index -= ${e[o]} * ${r[o]}`;return`${i}; ${l};`}).join("")}function uy(e){let t=w.computeStrides(e).map(n=>n.toString());return`
|
|
int getFlatIndex(ivec3 coords) {
|
|
return coords.x * ${t[0]} + coords.y * ${t[1]} + coords.z;
|
|
}
|
|
`}function cy(){return`
|
|
int getFlatIndex(ivec3 coords) {
|
|
return coords.x * outShapeStrides[0] + coords.y * outShapeStrides[1] + coords.z;
|
|
}
|
|
`}var D6=`
|
|
const float FLOAT_MAX = 1.70141184e38;
|
|
const float FLOAT_MIN = 1.17549435e-38;
|
|
|
|
lowp vec4 encode_float(highp float v) {
|
|
if (isnan(v)) {
|
|
return vec4(255, 255, 255, 255);
|
|
}
|
|
|
|
highp float av = abs(v);
|
|
|
|
if(av < FLOAT_MIN) {
|
|
return vec4(0.0, 0.0, 0.0, 0.0);
|
|
} else if(v > FLOAT_MAX) {
|
|
return vec4(0.0, 0.0, 128.0, 127.0) / 255.0;
|
|
} else if(v < -FLOAT_MAX) {
|
|
return vec4(0.0, 0.0, 128.0, 255.0) / 255.0;
|
|
}
|
|
|
|
highp vec4 c = vec4(0,0,0,0);
|
|
|
|
highp float e = floor(log2(av));
|
|
highp float m = exp2(fract(log2(av))) - 1.0;
|
|
|
|
c[2] = floor(128.0 * m);
|
|
m -= c[2] / 128.0;
|
|
c[1] = floor(32768.0 * m);
|
|
m -= c[1] / 32768.0;
|
|
c[0] = floor(8388608.0 * m);
|
|
|
|
highp float ebias = e + 127.0;
|
|
c[3] = floor(ebias / 2.0);
|
|
ebias -= c[3] * 2.0;
|
|
c[2] += floor(ebias) * 128.0;
|
|
|
|
c[3] += 128.0 * step(0.0, -v);
|
|
|
|
return c / 255.0;
|
|
}
|
|
`,{getBroadcastDims:_6}=_;function gq(e,t,n){let s=[];if(e.forEach(h=>{let f=w.sizeFromShape(h.shapeInfo.logicalShape);if(h.shapeInfo.isUniform?s.push(`uniform float ${h.name}${f>1?`[${f}]`:""};`):(s.push(`uniform sampler2D ${h.name};`),s.push(`uniform int offset${h.name};`)),n.enableShapeUniforms){let{uniformShape:m}=dy(n.packedInputs,h.shapeInfo.logicalShape,h.shapeInfo.texShape);switch(m.length){case 1:s.push(`uniform int ${h.name}Shape;`);break;case 2:s.push(`uniform ivec2 ${h.name}Shape;`);break;case 3:s.push(`uniform ivec3 ${h.name}Shape;`);break;case 4:s.push(`uniform ivec4 ${h.name}Shape;`);break;default:break}s.push(`uniform ivec2 ${h.name}TexShape;`)}}),n.enableShapeUniforms){switch(t.logicalShape.length){case 1:s.push("uniform int outShape;");break;case 2:s.push("uniform ivec2 outShape;"),s.push("uniform int outShapeStrides;");break;case 3:s.push("uniform ivec3 outShape;"),s.push("uniform ivec2 outShapeStrides;");break;case 4:s.push("uniform ivec4 outShape;"),s.push("uniform ivec3 outShapeStrides;");break;default:break}s.push("uniform ivec2 outTexShape;")}n.customUniforms&&n.customUniforms.forEach(h=>{s.push(`uniform ${h.type} ${h.name}${h.arrayIndex?`[${h.arrayIndex}]`:""};`)});let r=s.join(`
|
|
`),a=e.map(h=>Aq(h,t,n.packedInputs,n.enableShapeUniforms)).join(`
|
|
`),o=t.texShape,i=En(),l=bq(i),u,c,d=kq(i);return t.isPacked?(u=yq(t.logicalShape,o,n.enableShapeUniforms),c=wq(i)):(u=xq(t.logicalShape,o,n.enableShapeUniforms),c=vq(i)),n.packedInputs&&(d+=Tq),[d,l,c,r,u,a,n.userCode].join(`
|
|
`)}function gu(e,t=!1){let n=e.shapeInfo.logicalShape;switch(n.length){case 0:return Lq(e,t);case 1:return Wq(e,t);case 2:return Uq(e,t);case 3:return Gq(e,t);case 4:return qq(e,t);case 5:return Xq(e);case 6:return Kq(e);default:throw new Error(`${n.length}-D input sampling is not yet supported`)}}function $6(e,t){switch(e.shapeInfo.logicalShape.length){case 0:return zq(e);case 1:return Bq(e,t);case 2:return Vq(e,t);case 3:return Hq(e,t);default:return jq(e,t)}}function Aq(e,t,n=!1,s){let r="";n?r+=$6(e,s):r+=gu(e,s);let a=e.shapeInfo.logicalShape,o=t.logicalShape;return a.length<=o.length&&(n?r+=Zq(e,t):r+=Yq(e,t)),r}function yq(e,t,n){switch(e.length){case 0:return F6();case 1:return Nq(e,t,n);case 2:return Pq(e,t,n);case 3:return Rq(e,t,n);default:return _q(e,t,n)}}function xq(e,t,n){switch(e.length){case 0:return F6();case 1:return Eq(e,t,n);case 2:return Mq(e,t,n);case 3:return Dq(e,t,n);case 4:return $q(e,t,n);case 5:return Fq(e,t);case 6:return Oq(e,t);default:throw new Error(`${e.length}-D output sampling is not yet supported`)}}function bq(e){return`
|
|
float sampleTexture(sampler2D textureSampler, vec2 uv) {
|
|
return ${e.texture2D}(textureSampler, uv).r;
|
|
}
|
|
`}function vq(e){return`
|
|
void setOutput(float val) {
|
|
${e.output} = vec4(val, 0, 0, 0);
|
|
}
|
|
`}function wq(e){return`
|
|
void setOutput(vec4 val) {
|
|
${e.output} = val;
|
|
}
|
|
`}function kq(e){return`${e.version}
|
|
precision highp float;
|
|
precision highp int;
|
|
precision highp sampler2D;
|
|
${e.varyingFs} vec2 resultUV;
|
|
${e.defineOutput}
|
|
const vec2 halfCR = vec2(0.5, 0.5);
|
|
|
|
struct ivec5
|
|
{
|
|
int x;
|
|
int y;
|
|
int z;
|
|
int w;
|
|
int u;
|
|
};
|
|
|
|
struct ivec6
|
|
{
|
|
int x;
|
|
int y;
|
|
int z;
|
|
int w;
|
|
int u;
|
|
int v;
|
|
};
|
|
|
|
uniform float NAN;
|
|
${e.defineSpecialNaN}
|
|
${e.defineSpecialInf}
|
|
${e.defineRound}
|
|
|
|
int imod(int x, int y) {
|
|
return x - y * (x / y);
|
|
}
|
|
|
|
int idiv(int a, int b, float sign) {
|
|
int res = a / b;
|
|
int mod = imod(a, b);
|
|
if (sign < 0. && mod != 0) {
|
|
res -= 1;
|
|
}
|
|
return res;
|
|
}
|
|
|
|
//Based on the work of Dave Hoskins
|
|
//https://www.shadertoy.com/view/4djSRW
|
|
#define HASHSCALE1 443.8975
|
|
float random(float seed){
|
|
vec2 p = resultUV * seed;
|
|
vec3 p3 = fract(vec3(p.xyx) * HASHSCALE1);
|
|
p3 += dot(p3, p3.yzx + 19.19);
|
|
return fract((p3.x + p3.y) * p3.z);
|
|
}
|
|
|
|
${Iq}
|
|
${Sq}
|
|
${Cq}
|
|
`}var Iq=`
|
|
vec2 uvFromFlat(int texNumR, int texNumC, int index) {
|
|
int texR = index / texNumC;
|
|
int texC = index - texR * texNumC;
|
|
return (vec2(texC, texR) + halfCR) / vec2(texNumC, texNumR);
|
|
}
|
|
vec2 packedUVfrom1D(int texNumR, int texNumC, int index) {
|
|
int texelIndex = index / 2;
|
|
int texR = texelIndex / texNumC;
|
|
int texC = texelIndex - texR * texNumC;
|
|
return (vec2(texC, texR) + halfCR) / vec2(texNumC, texNumR);
|
|
}
|
|
`,Sq=`
|
|
vec2 packedUVfrom2D(int texelsInLogicalRow, int texNumR,
|
|
int texNumC, int row, int col) {
|
|
int texelIndex = (row / 2) * texelsInLogicalRow + (col / 2);
|
|
int texR = texelIndex / texNumC;
|
|
int texC = texelIndex - texR * texNumC;
|
|
return (vec2(texC, texR) + halfCR) / vec2(texNumC, texNumR);
|
|
}
|
|
`,Cq=`
|
|
vec2 packedUVfrom3D(int texNumR, int texNumC,
|
|
int texelsInBatch, int texelsInLogicalRow, int b,
|
|
int row, int col) {
|
|
int index = b * texelsInBatch + (row / 2) * texelsInLogicalRow + (col / 2);
|
|
int texR = index / texNumC;
|
|
int texC = index - texR * texNumC;
|
|
return (vec2(texC, texR) + halfCR) / vec2(texNumC, texNumR);
|
|
}
|
|
`,Tq=`
|
|
float getChannel(vec4 frag, vec2 innerDims) {
|
|
vec2 modCoord = mod(innerDims, 2.);
|
|
return modCoord.x == 0. ?
|
|
(modCoord.y == 0. ? frag.r : frag.g) :
|
|
(modCoord.y == 0. ? frag.b : frag.a);
|
|
}
|
|
float getChannel(vec4 frag, int dim) {
|
|
float modCoord = mod(float(dim), 2.);
|
|
return modCoord == 0. ? frag.r : frag.g;
|
|
}
|
|
`;function F6(){return`
|
|
int getOutputCoords() {
|
|
return 0;
|
|
}
|
|
`}function Nq(e,t,n){let s=[Math.ceil(t[0]/2),Math.ceil(t[1]/2)];return s[0]===1?n?`
|
|
int getOutputCoords() {
|
|
return 2 * int(resultUV.x * ceil(float(outTexShape[1]) / 2.0));
|
|
}
|
|
`:`
|
|
int getOutputCoords() {
|
|
return 2 * int(resultUV.x * ${s[1]}.0);
|
|
}
|
|
`:s[1]===1?n?`
|
|
int getOutputCoords() {
|
|
return 2 * int(resultUV.y * ceil(float(outTexShape[0]) / 2.0));
|
|
}
|
|
`:`
|
|
int getOutputCoords() {
|
|
return 2 * int(resultUV.y * ${s[0]}.0);
|
|
}
|
|
`:n?`
|
|
int getOutputCoords() {
|
|
ivec2 packedTexShape = ivec2(ceil(float(outTexShape[0]) / 2.0), ceil(float(outTexShape[1]) / 2.0));
|
|
ivec2 resTexRC = ivec2(resultUV.yx *
|
|
vec2(packedTexShape[0], packedTexShape[1]));
|
|
return 2 * (resTexRC.x * packedTexShape[1] + resTexRC.y);
|
|
}
|
|
`:`
|
|
int getOutputCoords() {
|
|
ivec2 resTexRC = ivec2(resultUV.yx *
|
|
vec2(${s[0]}, ${s[1]}));
|
|
return 2 * (resTexRC.x * ${s[1]} + resTexRC.y);
|
|
}
|
|
`}function Eq(e,t,n){return t[0]===1?n?`
|
|
int getOutputCoords() {
|
|
return int(resultUV.x * float(outTexShape[1]));
|
|
}
|
|
`:`
|
|
int getOutputCoords() {
|
|
return int(resultUV.x * ${t[1]}.0);
|
|
}
|
|
`:t[1]===1?n?`
|
|
int getOutputCoords() {
|
|
return int(resultUV.y * float(outTexShape[0]));
|
|
}
|
|
`:`
|
|
int getOutputCoords() {
|
|
return int(resultUV.y * ${t[0]}.0);
|
|
}
|
|
`:n?`
|
|
int getOutputCoords() {
|
|
ivec2 resTexRC = ivec2(resultUV.yx *
|
|
vec2(outTexShape[0], outTexShape[1]));
|
|
return resTexRC.x * outTexShape[1] + resTexRC.y;
|
|
}
|
|
`:`
|
|
int getOutputCoords() {
|
|
ivec2 resTexRC = ivec2(resultUV.yx *
|
|
vec2(${t[0]}, ${t[1]}));
|
|
return resTexRC.x * ${t[1]} + resTexRC.y;
|
|
}
|
|
`}function Rq(e,t,n){if(n)return`
|
|
ivec3 getOutputCoords() {
|
|
ivec2 packedTexShape = ivec2(ceil(float(outTexShape[0]) / 2.0), ceil(float(outTexShape[1]) / 2.0));
|
|
int texelsInLogicalRow = int(ceil(float(outShape[2]) / 2.0));
|
|
int texelsInBatch = texelsInLogicalRow * int(ceil(float(outShape[1]) / 2.0));
|
|
ivec2 resTexRC = ivec2(resultUV.yx *
|
|
vec2(packedTexShape[0], packedTexShape[1]));
|
|
int index = resTexRC.x * packedTexShape[1] + resTexRC.y;
|
|
|
|
int b = index / texelsInBatch;
|
|
index -= b * texelsInBatch;
|
|
|
|
int r = 2 * (index / texelsInLogicalRow);
|
|
int c = imod(index, texelsInLogicalRow) * 2;
|
|
|
|
return ivec3(b, r, c);
|
|
}
|
|
`;let s=[Math.ceil(t[0]/2),Math.ceil(t[1]/2)],r=Math.ceil(e[2]/2),a=r*Math.ceil(e[1]/2);return`
|
|
ivec3 getOutputCoords() {
|
|
ivec2 resTexRC = ivec2(resultUV.yx *
|
|
vec2(${s[0]}, ${s[1]}));
|
|
int index = resTexRC.x * ${s[1]} + resTexRC.y;
|
|
|
|
int b = index / ${a};
|
|
index -= b * ${a};
|
|
|
|
int r = 2 * (index / ${r});
|
|
int c = imod(index, ${r}) * 2;
|
|
|
|
return ivec3(b, r, c);
|
|
}
|
|
`}function Dq(e,t,n){if(n)return`
|
|
ivec3 getOutputCoords() {
|
|
ivec2 resTexRC = ivec2(resultUV.yx *
|
|
vec2(outTexShape[0], outTexShape[1]));
|
|
int index = resTexRC.x * outTexShape[1] + resTexRC.y;
|
|
${qf(["r","c","d"],e)}
|
|
return ivec3(r, c, d);
|
|
}
|
|
`;let s=ci(["r","c","d"],e);return`
|
|
ivec3 getOutputCoords() {
|
|
ivec2 resTexRC = ivec2(resultUV.yx *
|
|
vec2(${t[0]}, ${t[1]}));
|
|
int index = resTexRC.x * ${t[1]} + resTexRC.y;
|
|
${s}
|
|
return ivec3(r, c, d);
|
|
}
|
|
`}function _q(e,t,n){if(n)return`
|
|
ivec4 getOutputCoords() {
|
|
ivec2 packedTexShape = ivec2(ceil(float(outTexShape[0]) / 2.0), ceil(float(outTexShape[1]) / 2.0));
|
|
ivec2 resTexRC = ivec2(resultUV.yx *
|
|
vec2(packedTexShape[0], packedTexShape[1]));
|
|
int index = resTexRC.x * packedTexShape[1] + resTexRC.y;
|
|
|
|
int texelsInLogicalRow = int(ceil(float(outShape[3]) / 2.0));
|
|
int texelsInBatch = texelsInLogicalRow * int(ceil(float(outShape[2]) / 2.0));
|
|
int texelsInBatchN = texelsInBatch * outShape[1];
|
|
|
|
int b2 = index / texelsInBatchN;
|
|
index -= b2 * texelsInBatchN;
|
|
|
|
int b = index / texelsInBatch;
|
|
index -= b * texelsInBatch;
|
|
|
|
int r = 2 * (index / texelsInLogicalRow);
|
|
int c = imod(index, texelsInLogicalRow) * 2;
|
|
|
|
return ivec4(b2, b, r, c);
|
|
}
|
|
`;let s=[Math.ceil(t[0]/2),Math.ceil(t[1]/2)],r=Math.ceil(e[e.length-1]/2),a=r*Math.ceil(e[e.length-2]/2),o=a,i="",l="b, r, c";for(let u=2;u<e.length-1;u++)o*=e[e.length-u-1],i=`
|
|
int b${u} = index / ${o};
|
|
index -= b${u} * ${o};
|
|
`+i,l=`b${u}, `+l;return`
|
|
ivec${e.length} getOutputCoords() {
|
|
ivec2 resTexRC = ivec2(resultUV.yx *
|
|
vec2(${s[0]}, ${s[1]}));
|
|
int index = resTexRC.x * ${s[1]} + resTexRC.y;
|
|
|
|
${i}
|
|
|
|
int b = index / ${a};
|
|
index -= b * ${a};
|
|
|
|
int r = 2 * (index / ${r});
|
|
int c = imod(index, ${r}) * 2;
|
|
|
|
return ivec${e.length}(${l});
|
|
}
|
|
`}function $q(e,t,n){if(n)return`
|
|
ivec4 getOutputCoords() {
|
|
ivec2 resTexRC = ivec2(resultUV.yx *
|
|
vec2(outTexShape[0], outTexShape[1]));
|
|
int index = resTexRC.x * outTexShape[1] + resTexRC.y;
|
|
${qf(["r","c","d","d2"],e)}
|
|
return ivec4(r, c, d, d2);
|
|
}
|
|
`;let s=ci(["r","c","d","d2"],e);return`
|
|
ivec4 getOutputCoords() {
|
|
ivec2 resTexRC = ivec2(resultUV.yx *
|
|
vec2(${t[0]}, ${t[1]}));
|
|
int index = resTexRC.x * ${t[1]} + resTexRC.y;
|
|
${s}
|
|
return ivec4(r, c, d, d2);
|
|
}
|
|
`}function Fq(e,t){let n=ci(["r","c","d","d2","d3"],e);return`
|
|
ivec5 getOutputCoords() {
|
|
ivec2 resTexRC = ivec2(resultUV.yx * vec2(${t[0]},
|
|
${t[1]}));
|
|
|
|
int index = resTexRC.x * ${t[1]} + resTexRC.y;
|
|
|
|
${n}
|
|
|
|
ivec5 outShape = ivec5(r, c, d, d2, d3);
|
|
return outShape;
|
|
}
|
|
`}function Oq(e,t){let n=ci(["r","c","d","d2","d3","d4"],e);return`
|
|
ivec6 getOutputCoords() {
|
|
ivec2 resTexRC = ivec2(resultUV.yx *
|
|
vec2(${t[0]}, ${t[1]}));
|
|
int index = resTexRC.x * ${t[1]} + resTexRC.y;
|
|
|
|
${n}
|
|
|
|
ivec6 result = ivec6(r, c, d, d2, d3, d4);
|
|
return result;
|
|
}
|
|
`}function Pq(e,t,n){let s=[Math.ceil(t[0]/2),Math.ceil(t[1]/2)];if(w.arraysEqual(e,t))return n?`
|
|
ivec2 getOutputCoords() {
|
|
ivec2 packedTexShape = ivec2(ceil(float(outTexShape[0]) / 2.0), ceil(float(outTexShape[1]) / 2.0));
|
|
return 2 * ivec2(resultUV.yx * vec2(packedTexShape[0], packedTexShape[1]));
|
|
}
|
|
`:`
|
|
ivec2 getOutputCoords() {
|
|
return 2 * ivec2(resultUV.yx * vec2(${s[0]}, ${s[1]}));
|
|
}
|
|
`;let r=Math.ceil(e[1]/2);return n?`
|
|
ivec2 getOutputCoords() {
|
|
ivec2 packedTexShape = ivec2(ceil(float(outTexShape[0]) / 2.0), ceil(float(outTexShape[1]) / 2.0));
|
|
int texelsInLogicalRow = int(ceil(float(outShape[1]) / 2.0));
|
|
ivec2 resTexRC = ivec2(resultUV.yx *
|
|
vec2(packedTexShape[0], packedTexShape[1]));
|
|
|
|
int index = resTexRC.x * packedTexShape[1] + resTexRC.y;
|
|
int r = 2 * (index / texelsInLogicalRow);
|
|
int c = imod(index, texelsInLogicalRow) * 2;
|
|
|
|
return ivec2(r, c);
|
|
}
|
|
`:`
|
|
ivec2 getOutputCoords() {
|
|
ivec2 resTexRC = ivec2(resultUV.yx *
|
|
vec2(${s[0]}, ${s[1]}));
|
|
|
|
int index = resTexRC.x * ${s[1]} + resTexRC.y;
|
|
int r = 2 * (index / ${r});
|
|
int c = imod(index, ${r}) * 2;
|
|
|
|
return ivec2(r, c);
|
|
}
|
|
`}function Mq(e,t,n){return w.arraysEqual(e,t)?n?`
|
|
ivec2 getOutputCoords() {
|
|
return ivec2(resultUV.yx * vec2(outTexShape[0], outTexShape[1]));
|
|
}
|
|
`:`
|
|
ivec2 getOutputCoords() {
|
|
return ivec2(resultUV.yx * vec2(${t[0]}, ${t[1]}));
|
|
}
|
|
`:e[1]===1?n?`
|
|
ivec2 getOutputCoords() {
|
|
ivec2 resTexRC = ivec2(resultUV.yx *
|
|
vec2(outTexShape[0], outTexShape[1]));
|
|
int index = resTexRC.x * outTexShape[1] + resTexRC.y;
|
|
return ivec2(index, 0);
|
|
}
|
|
`:`
|
|
ivec2 getOutputCoords() {
|
|
ivec2 resTexRC = ivec2(resultUV.yx *
|
|
vec2(${t[0]}, ${t[1]}));
|
|
int index = resTexRC.x * ${t[1]} + resTexRC.y;
|
|
return ivec2(index, 0);
|
|
}
|
|
`:e[0]===1?n?`
|
|
ivec2 getOutputCoords() {
|
|
ivec2 resTexRC = ivec2(resultUV.yx *
|
|
vec2(outTexShape[0], outTexShape[1]));
|
|
int index = resTexRC.x * outTexShape[1] + resTexRC.y;
|
|
return ivec2(0, index);
|
|
}
|
|
`:`
|
|
ivec2 getOutputCoords() {
|
|
ivec2 resTexRC = ivec2(resultUV.yx *
|
|
vec2(${t[0]}, ${t[1]}));
|
|
int index = resTexRC.x * ${t[1]} + resTexRC.y;
|
|
return ivec2(0, index);
|
|
}
|
|
`:n?`
|
|
ivec2 getOutputCoords() {
|
|
ivec2 resTexRC = ivec2(resultUV.yx *
|
|
vec2(outTexShape[0], outTexShape[1]));
|
|
int index = resTexRC.x * outTexShape[1] + resTexRC.y;
|
|
int r = index / outShape[1];
|
|
int c = index - r * outShape[1];
|
|
return ivec2(r, c);
|
|
}
|
|
`:`
|
|
ivec2 getOutputCoords() {
|
|
ivec2 resTexRC = ivec2(resultUV.yx *
|
|
vec2(${t[0]}, ${t[1]}));
|
|
int index = resTexRC.x * ${t[1]} + resTexRC.y;
|
|
int r = index / ${e[1]};
|
|
int c = index - r * ${e[1]};
|
|
return ivec2(r, c);
|
|
}
|
|
`}function di(e){return`offset${e}`}function zq(e){let t=e.name,n="get"+t.charAt(0).toUpperCase()+t.slice(1),s=En();return`
|
|
vec4 ${n}() {
|
|
return ${s.texture2D}(${t}, halfCR);
|
|
}
|
|
`}function Lq(e,t){let n=e.name,s="get"+n.charAt(0).toUpperCase()+n.slice(1);if(e.shapeInfo.isUniform)return`float ${s}() {return ${n};}`;let[r,a]=e.shapeInfo.texShape;if(r===1&&a===1)return`
|
|
float ${s}() {
|
|
return sampleTexture(${n}, halfCR);
|
|
}
|
|
`;let o=di(n);if(t)return`
|
|
float ${s}() {
|
|
vec2 uv = uvFromFlat(${n}TexShape[0], ${n}TexShape[1], ${o});
|
|
return sampleTexture(${n}, uv);
|
|
}
|
|
`;let[i,l]=e.shapeInfo.texShape;return`
|
|
float ${s}() {
|
|
vec2 uv = uvFromFlat(${i}, ${l}, ${o});
|
|
return sampleTexture(${n}, uv);
|
|
}
|
|
`}function Bq(e,t){let n=e.name,s="get"+n.charAt(0).toUpperCase()+n.slice(1),r=e.shapeInfo.texShape,a=En();if(t)return`
|
|
vec4 ${s}(int index) {
|
|
ivec2 packedTexShape = ivec2(ceil(float(${n}TexShape[0]) / 2.0), ceil(float(${n}TexShape[1]) / 2.0));
|
|
vec2 uv = packedUVfrom1D(
|
|
packedTexShape[0], packedTexShape[1], index);
|
|
return ${a.texture2D}(${n}, uv);
|
|
}
|
|
`;let o=[Math.ceil(r[0]/2),Math.ceil(r[1]/2)];return`
|
|
vec4 ${s}(int index) {
|
|
vec2 uv = packedUVfrom1D(
|
|
${o[0]}, ${o[1]}, index);
|
|
return ${a.texture2D}(${n}, uv);
|
|
}
|
|
`}function Wq(e,t){let n=e.name,s="get"+n.charAt(0).toUpperCase()+n.slice(1);if(e.shapeInfo.isUniform)return`
|
|
float ${s}(int index) {
|
|
${Au(e)}
|
|
}
|
|
`;let r=e.shapeInfo.texShape,a=r[0],o=r[1];if(o===1&&a===1)return`
|
|
float ${s}(int index) {
|
|
return sampleTexture(${n}, halfCR);
|
|
}
|
|
`;let i=di(n);return o===1?t?`
|
|
float ${s}(int index) {
|
|
vec2 uv = vec2(0.5, (float(index + ${i}) + 0.5) / float(${n}TexShape[0]));
|
|
return sampleTexture(${n}, uv);
|
|
}
|
|
`:`
|
|
float ${s}(int index) {
|
|
vec2 uv = vec2(0.5, (float(index + ${i}) + 0.5) / ${a}.0);
|
|
return sampleTexture(${n}, uv);
|
|
}
|
|
`:a===1?t?`
|
|
float ${s}(int index) {
|
|
vec2 uv = vec2((float(index + ${i}) + 0.5) / float(${n}TexShape[1]), 0.5);
|
|
return sampleTexture(${n}, uv);
|
|
}
|
|
`:`
|
|
float ${s}(int index) {
|
|
vec2 uv = vec2((float(index + ${i}) + 0.5) / ${o}.0, 0.5);
|
|
return sampleTexture(${n}, uv);
|
|
}
|
|
`:t?`
|
|
float ${s}(int index) {
|
|
vec2 uv = uvFromFlat(${n}TexShape[0], ${n}TexShape[1], index + ${i});
|
|
return sampleTexture(${n}, uv);
|
|
}
|
|
`:`
|
|
float ${s}(int index) {
|
|
vec2 uv = uvFromFlat(${a}, ${o}, index + ${i});
|
|
return sampleTexture(${n}, uv);
|
|
}
|
|
`}function Vq(e,t){let n=e.shapeInfo.logicalShape,s=e.name,r="get"+s.charAt(0).toUpperCase()+s.slice(1),a=e.shapeInfo.texShape,o=a[0],i=a[1],l=En();if(a!=null&&w.arraysEqual(n,a))return t?`
|
|
vec4 ${r}(int row, int col) {
|
|
vec2 uv = (vec2(col, row) + halfCR) / vec2(${s}TexShape[1], ${s}TexShape[0]);
|
|
|
|
return ${l.texture2D}(${s}, uv);
|
|
}
|
|
`:`
|
|
vec4 ${r}(int row, int col) {
|
|
vec2 uv = (vec2(col, row) + halfCR) / vec2(${i}.0, ${o}.0);
|
|
|
|
return ${l.texture2D}(${s}, uv);
|
|
}
|
|
`;if(t)return`
|
|
vec4 ${r}(int row, int col) {
|
|
ivec2 packedTexShape = ivec2(ceil(float(${s}TexShape[0]) / 2.0), ceil(float(${s}TexShape[1]) / 2.0));
|
|
int valuesPerRow = int(ceil(float(${s}Shape[1]) / 2.0));
|
|
vec2 uv = packedUVfrom2D(valuesPerRow, packedTexShape[0], packedTexShape[1], row, col);
|
|
return ${l.texture2D}(${s}, uv);
|
|
}
|
|
`;let u=[Math.ceil(a[0]/2),Math.ceil(a[1]/2)],c=Math.ceil(n[1]/2);return`
|
|
vec4 ${r}(int row, int col) {
|
|
vec2 uv = packedUVfrom2D(${c}, ${u[0]}, ${u[1]}, row, col);
|
|
return ${l.texture2D}(${s}, uv);
|
|
}
|
|
`}function Uq(e,t){let n=e.shapeInfo.logicalShape,s=e.name,r="get"+s.charAt(0).toUpperCase()+s.slice(1),a=e.shapeInfo.texShape;if(a!=null&&w.arraysEqual(n,a)){if(t)return`
|
|
float ${r}(int row, int col) {
|
|
vec2 uv = (vec2(col, row) + halfCR) / vec2(${s}TexShape[1], ${s}TexShape[0]);
|
|
return sampleTexture(${s}, uv);
|
|
}
|
|
`;let p=a[0],h=a[1];return`
|
|
float ${r}(int row, int col) {
|
|
vec2 uv = (vec2(col, row) + halfCR) / vec2(${h}.0, ${p}.0);
|
|
return sampleTexture(${s}, uv);
|
|
}
|
|
`}let{newShape:o,keptDims:i}=w.squeezeShape(n),l=o;if(l.length<n.length){let p=yu(e,l),h=["row","col"];return`
|
|
${gu(p,t)}
|
|
float ${r}(int row, int col) {
|
|
return ${r}(${xu(h,i)});
|
|
}
|
|
`}if(e.shapeInfo.isUniform)return`
|
|
float ${r}(int row, int col) {
|
|
int index = round(dot(vec2(row, col), vec2(${n[1]}, 1)));
|
|
${Au(e)}
|
|
}
|
|
`;let u=a[0],c=a[1],d=di(s);return c===1?t?`
|
|
float ${r}(int row, int col) {
|
|
float index = dot(vec3(row, col, ${d}), vec3(${s}Shape[1], 1, 1));
|
|
vec2 uv = vec2(0.5, (index + 0.5) / float(${s}TexShape[0]));
|
|
return sampleTexture(${s}, uv);
|
|
}
|
|
`:`
|
|
float ${r}(int row, int col) {
|
|
float index = dot(vec3(row, col, ${d}), vec3(${n[1]}, 1, 1));
|
|
vec2 uv = vec2(0.5, (index + 0.5) / ${u}.0);
|
|
return sampleTexture(${s}, uv);
|
|
}
|
|
`:u===1?t?`
|
|
float ${r}(int row, int col) {
|
|
float index = dot(vec3(row, col, ${d}), vec3(${s}Shape[1], 1, 1));
|
|
vec2 uv = vec2((index + 0.5) / float(${s}TexShape[1]), 0.5);
|
|
return sampleTexture(${s}, uv);
|
|
}
|
|
`:`
|
|
float ${r}(int row, int col) {
|
|
float index = dot(vec3(row, col, ${d}), vec3(${n[1]}, 1, 1));
|
|
vec2 uv = vec2((index + 0.5) / ${c}.0, 0.5);
|
|
return sampleTexture(${s}, uv);
|
|
}
|
|
`:t?`
|
|
float ${r}(int row, int col) {
|
|
// Explicitly use integer operations as dot() only works on floats.
|
|
int index = row * ${s}Shape[1] + col + ${d};
|
|
vec2 uv = uvFromFlat(${s}TexShape[0], ${s}TexShape[1], index);
|
|
return sampleTexture(${s}, uv);
|
|
}
|
|
`:`
|
|
float ${r}(int row, int col) {
|
|
// Explicitly use integer operations as dot() only works on floats.
|
|
int index = row * ${n[1]} + col + ${d};
|
|
vec2 uv = uvFromFlat(${u}, ${c}, index);
|
|
return sampleTexture(${s}, uv);
|
|
}
|
|
`}function Hq(e,t){let n=e.shapeInfo.logicalShape,s=e.name,r="get"+s.charAt(0).toUpperCase()+s.slice(1),a=e.shapeInfo.texShape,o=[Math.ceil(a[0]/2),Math.ceil(a[1]/2)];if(n[0]===1){let p=n.slice(1),h=[1,2],f=yu(e,p),m=["b","row","col"];return`
|
|
${$6(f,t)}
|
|
vec4 ${r}(int b, int row, int col) {
|
|
return ${r}(${xu(m,h)});
|
|
}
|
|
`}let i=En();if(t)return`
|
|
vec4 ${r}(int b, int row, int col) {
|
|
ivec2 packedTexShape = ivec2(ceil(float(${s}TexShape[0]) / 2.0), ceil(float(${s}TexShape[1]) / 2.0));
|
|
int valuesPerRow = int(ceil(float(${s}Shape[2]) / 2.0));
|
|
int texelsInBatch = valuesPerRow * int(ceil(float(${s}Shape[1]) / 2.0));
|
|
vec2 uv = packedUVfrom3D(
|
|
packedTexShape[0], packedTexShape[1], texelsInBatch, valuesPerRow, b, row, col);
|
|
return ${i.texture2D}(${s}, uv);
|
|
}
|
|
`;let l=o[0],u=o[1],c=Math.ceil(n[2]/2),d=c*Math.ceil(n[1]/2);return`
|
|
vec4 ${r}(int b, int row, int col) {
|
|
vec2 uv = packedUVfrom3D(
|
|
${l}, ${u}, ${d}, ${c}, b, row, col);
|
|
return ${i.texture2D}(${s}, uv);
|
|
}
|
|
`}function Gq(e,t){let n=e.shapeInfo.logicalShape,s=e.name,r="get"+s.charAt(0).toUpperCase()+s.slice(1),a=n[1]*n[2],o=n[2],{newShape:i,keptDims:l}=w.squeezeShape(n),u=i;if(u.length<n.length){let m=yu(e,u),g=["row","col","depth"];return`
|
|
${gu(m,t)}
|
|
float ${r}(int row, int col, int depth) {
|
|
return ${r}(${xu(g,l)});
|
|
}
|
|
`}if(e.shapeInfo.isUniform)return`
|
|
float ${r}(int row, int col, int depth) {
|
|
int index = round(dot(vec3(row, col, depth),
|
|
vec3(${a}, ${o}, 1)));
|
|
${Au(e)}
|
|
}
|
|
`;let c=e.shapeInfo.texShape,d=c[0],p=c[1],h=e.shapeInfo.flatOffset;if(p===a&&h==null)return t?`
|
|
float ${r}(int row, int col, int depth) {
|
|
int stride1 = ${s}Shape[2];
|
|
float texR = float(row);
|
|
float texC = dot(vec2(col, depth), vec2(stride1, 1));
|
|
vec2 uv = (vec2(texC, texR) + halfCR) /
|
|
vec2(${s}TexShape[1], ${s}TexShape[0]);
|
|
return sampleTexture(${s}, uv);
|
|
}
|
|
`:`
|
|
float ${r}(int row, int col, int depth) {
|
|
float texR = float(row);
|
|
float texC = dot(vec2(col, depth), vec2(${o}, 1));
|
|
vec2 uv = (vec2(texC, texR) + halfCR) /
|
|
vec2(${p}.0, ${d}.0);
|
|
return sampleTexture(${s}, uv);
|
|
}
|
|
`;if(p===o&&h==null)return t?`
|
|
float ${r}(int row, int col, int depth) {
|
|
float texR = dot(vec2(row, col), vec2(${s}Shape[1], 1));
|
|
float texC = float(depth);
|
|
vec2 uv = (vec2(texC, texR) + halfCR) / vec2(${s}TexShape[1], ${s}TexShape[0]);
|
|
return sampleTexture(${s}, uv);
|
|
}
|
|
`:`
|
|
float ${r}(int row, int col, int depth) {
|
|
float texR = dot(vec2(row, col), vec2(${n[1]}, 1));
|
|
float texC = float(depth);
|
|
vec2 uv = (vec2(texC, texR) + halfCR) / vec2(${p}.0, ${d}.0);
|
|
return sampleTexture(${s}, uv);
|
|
}
|
|
`;let f=di(s);return t?`
|
|
float ${r}(int row, int col, int depth) {
|
|
// Explicitly use integer operations as dot() only works on floats.
|
|
int stride0 = ${s}Shape[1] * ${s}Shape[2];
|
|
int stride1 = ${s}Shape[2];
|
|
int index = row * ${a} + col * ${o} + depth + ${f};
|
|
vec2 uv = uvFromFlat(${s}TexShape[0], ${s}TexShape[1], index);
|
|
return sampleTexture(${s}, uv);
|
|
}
|
|
`:`
|
|
float ${r}(int row, int col, int depth) {
|
|
// Explicitly use integer operations as dot() only works on floats.
|
|
int index = row * ${a} + col * ${o} + depth + ${f};
|
|
vec2 uv = uvFromFlat(${d}, ${p}, index);
|
|
return sampleTexture(${s}, uv);
|
|
}
|
|
`}function jq(e,t){let n=e.name,s="get"+n.charAt(0).toUpperCase()+n.slice(1),r=En();if(t)return`
|
|
vec4 ${s}(int b2, int b, int row, int col) {
|
|
int valuesPerRow = int(ceil(float(${n}Shape[3]) / 2.0));
|
|
int texelsInBatch = valuesPerRow * int(ceil(float(${n}Shape[2]) / 2.0));
|
|
int index = b * texelsInBatch + (row / 2) * valuesPerRow + (col / 2);
|
|
texelsInBatch *= ${n}Shape[1];
|
|
index = b2 * texelsInBatch + index;
|
|
ivec2 packedTexShape = ivec2(ceil(float(${n}TexShape[0]) / 2.0), ceil(float(${n}TexShape[1]) / 2.0));
|
|
int texR = index / packedTexShape[1];
|
|
int texC = index - texR * packedTexShape[1];
|
|
vec2 uv = (vec2(texC, texR) + halfCR) / vec2(packedTexShape[1], packedTexShape[0]); return ${r.texture2D}(${n}, uv);
|
|
}
|
|
`;let a=e.shapeInfo.logicalShape,o=a.length,i=e.shapeInfo.texShape,l=[Math.ceil(i[0]/2),Math.ceil(i[1]/2)],u=l[0],c=l[1],d=Math.ceil(a[o-1]/2),p=d*Math.ceil(a[o-2]/2),h="int b, int row, int col",f=`b * ${p} + (row / 2) * ${d} + (col / 2)`;for(let m=2;m<o-1;m++)h=`int b${m}, `+h,p*=a[o-m-1],f=`b${m} * ${p} + `+f;return`
|
|
vec4 ${s}(${h}) {
|
|
int index = ${f};
|
|
int texR = index / ${c};
|
|
int texC = index - texR * ${c};
|
|
vec2 uv = (vec2(texC, texR) + halfCR) / vec2(${c}, ${u});
|
|
return ${r.texture2D}(${n}, uv);
|
|
}
|
|
`}function qq(e,t){let n=e.shapeInfo.logicalShape,s=e.name,r="get"+s.charAt(0).toUpperCase()+s.slice(1),a=n[3],o=n[2]*a,i=n[1]*o,{newShape:l,keptDims:u}=w.squeezeShape(n);if(l.length<n.length){let y=yu(e,l),x=["row","col","depth","depth2"];return`
|
|
${gu(y,t)}
|
|
float ${r}(int row, int col, int depth, int depth2) {
|
|
return ${r}(${xu(x,u)});
|
|
}
|
|
`}if(e.shapeInfo.isUniform)return`
|
|
float ${r}(int row, int col, int depth, int depth2) {
|
|
int index = round(dot(vec4(row, col, depth, depth2),
|
|
vec4(${i}, ${o}, ${a}, 1)));
|
|
${Au(e)}
|
|
}
|
|
`;let c=e.shapeInfo.flatOffset,d=e.shapeInfo.texShape,p=d[0],h=d[1],f=`int stride2 = ${s}Shape[3];`,m=`int stride1 = ${s}Shape[2] * stride2;`,g=`int stride0 = ${s}Shape[1] * stride1;`;if(h===i&&c==null)return t?`
|
|
float ${r}(int row, int col, int depth, int depth2) {
|
|
${f}
|
|
${m}
|
|
float texR = float(row);
|
|
float texC =
|
|
dot(vec3(col, depth, depth2),
|
|
vec3(stride1, stride2, 1));
|
|
vec2 uv = (vec2(texC, texR) + halfCR) /
|
|
vec2(${s}TexShape[1], ${s}TexShape[0]);
|
|
return sampleTexture(${s}, uv);
|
|
}
|
|
`:`
|
|
float ${r}(int row, int col, int depth, int depth2) {
|
|
float texR = float(row);
|
|
float texC =
|
|
dot(vec3(col, depth, depth2),
|
|
vec3(${o}, ${a}, 1));
|
|
vec2 uv = (vec2(texC, texR) + halfCR) /
|
|
vec2(${h}.0, ${p}.0);
|
|
return sampleTexture(${s}, uv);
|
|
}
|
|
`;if(h===a&&c==null)return t?`
|
|
float ${r}(int row, int col, int depth, int depth2) {
|
|
float texR = dot(vec3(row, col, depth),
|
|
vec3(${s}Shape[1] * ${s}Shape[2], ${s}Shape[2], 1));
|
|
float texC = float(depth2);
|
|
vec2 uv = (vec2(texC, texR) + halfCR) /
|
|
vec2(${s}TexShape[1], ${s}TexShape[0]);
|
|
return sampleTexture(${s}, uv);
|
|
}
|
|
`:`
|
|
float ${r}(int row, int col, int depth, int depth2) {
|
|
float texR = dot(vec3(row, col, depth),
|
|
vec3(${n[1]*n[2]}, ${n[2]}, 1));
|
|
float texC = float(depth2);
|
|
vec2 uv = (vec2(texC, texR) + halfCR) /
|
|
vec2(${h}.0, ${p}.0);
|
|
return sampleTexture(${s}, uv);
|
|
}
|
|
`;let A=di(s);return t?`
|
|
float ${r}(int row, int col, int depth, int depth2) {
|
|
// Explicitly use integer operations as dot() only works on floats.
|
|
${f}
|
|
${m}
|
|
${g}
|
|
int index = row * stride0 + col * stride1 +
|
|
depth * stride2 + depth2;
|
|
vec2 uv = uvFromFlat(${s}TexShape[0], ${s}TexShape[1], index + ${A});
|
|
return sampleTexture(${s}, uv);
|
|
}
|
|
`:`
|
|
float ${r}(int row, int col, int depth, int depth2) {
|
|
// Explicitly use integer operations as dot() only works on floats.
|
|
int index = row * ${i} + col * ${o} +
|
|
depth * ${a} + depth2;
|
|
vec2 uv = uvFromFlat(${p}, ${h}, index + ${A});
|
|
return sampleTexture(${s}, uv);
|
|
}
|
|
`}function Xq(e){let t=e.shapeInfo.logicalShape,n=e.name,s="get"+n.charAt(0).toUpperCase()+n.slice(1),r=t[4],a=t[3]*r,o=t[2]*a,i=t[1]*o,{newShape:l,keptDims:u}=w.squeezeShape(t);if(l.length<t.length){let m=yu(e,l),g=["row","col","depth","depth2","depth3"];return`
|
|
${gu(m)}
|
|
float ${s}(int row, int col, int depth, int depth2, int depth3) {
|
|
return ${s}(${xu(g,u)});
|
|
}
|
|
`}if(e.shapeInfo.isUniform)return`
|
|
float ${s}(int row, int col, int depth, int depth2, int depth3) {
|
|
float index = dot(
|
|
vec4(row, col, depth, depth2),
|
|
vec4(${i}, ${o}, ${a}, ${r})) +
|
|
depth3;
|
|
${Au(e)}
|
|
}
|
|
`;let c=e.shapeInfo.flatOffset,d=e.shapeInfo.texShape,p=d[0],h=d[1];if(h===i&&c==null)return`
|
|
float ${s}(int row, int col, int depth, int depth2, int depth3) {
|
|
int texR = row;
|
|
float texC = dot(vec4(col, depth, depth2, depth3),
|
|
vec4(${o}, ${a}, ${r}, 1));
|
|
vec2 uv = (vec2(texC, texR) + halfCR) /
|
|
vec2(${h}.0, ${p}.0);
|
|
return sampleTexture(${n}, uv);
|
|
}
|
|
`;if(h===r&&c==null)return`
|
|
float ${s}(int row, int col, int depth, int depth2, int depth3) {
|
|
float texR = dot(
|
|
vec4(row, col, depth, depth2),
|
|
vec4(${t[1]*t[2]*t[3]},
|
|
${t[2]*t[3]}, ${t[3]}, 1));
|
|
int texC = depth3;
|
|
vec2 uv = (vec2(texC, texR) + halfCR) /
|
|
vec2(${h}.0, ${p}.0);
|
|
return sampleTexture(${n}, uv);
|
|
}
|
|
`;let f=di(n);return`
|
|
float ${s}(int row, int col, int depth, int depth2, int depth3) {
|
|
// Explicitly use integer operations as dot() only works on floats.
|
|
int index = row * ${i} + col * ${o} + depth * ${a} +
|
|
depth2 * ${r} + depth3 + ${f};
|
|
vec2 uv = uvFromFlat(${p}, ${h}, index);
|
|
return sampleTexture(${n}, uv);
|
|
}
|
|
`}function Kq(e){let t=e.shapeInfo.logicalShape,n=e.name,s="get"+n.charAt(0).toUpperCase()+n.slice(1),{newShape:r,keptDims:a}=w.squeezeShape(t);if(r.length<t.length){let g=yu(e,r),A=["row","col","depth","depth2","depth3","depth4"];return`
|
|
${gu(g)}
|
|
float ${s}(int row, int col, int depth,
|
|
int depth2, int depth3, int depth4) {
|
|
return ${s}(${xu(A,a)});
|
|
}
|
|
`}let o=t[5],i=t[4]*o,l=t[3]*i,u=t[2]*l,c=t[1]*u;if(e.shapeInfo.isUniform)return`
|
|
float ${s}(int row, int col, int depth,
|
|
int depth2, int depth3, int depth4) {
|
|
int index = round(dot(
|
|
vec4(row, col, depth, depth2),
|
|
vec4(${c}, ${u}, ${l}, ${i})) +
|
|
dot(
|
|
vec2(depth3, depth4),
|
|
vec2(${o}, 1)));
|
|
${Au(e)}
|
|
}
|
|
`;let d=e.shapeInfo.flatOffset,p=e.shapeInfo.texShape,h=p[0],f=p[1];if(f===c&&d==null)return`
|
|
float ${s}(int row, int col, int depth,
|
|
int depth2, int depth3, int depth4) {
|
|
int texR = row;
|
|
float texC = dot(vec4(col, depth, depth2, depth3),
|
|
vec4(${u}, ${l}, ${i}, ${o})) +
|
|
float(depth4);
|
|
vec2 uv = (vec2(texC, texR) + halfCR) /
|
|
vec2(${f}.0, ${h}.0);
|
|
return sampleTexture(${n}, uv);
|
|
}
|
|
`;if(f===o&&d==null)return`
|
|
float ${s}(int row, int col, int depth,
|
|
int depth2, int depth3, int depth4) {
|
|
float texR = dot(vec4(row, col, depth, depth2),
|
|
vec4(${t[1]*t[2]*t[3]*t[4]},
|
|
${t[2]*t[3]*t[4]},
|
|
${t[3]*t[4]},
|
|
${t[4]})) + float(depth3);
|
|
int texC = depth4;
|
|
vec2 uv = (vec2(texC, texR) + halfCR) /
|
|
vec2(${f}.0, ${h}.0);
|
|
return sampleTexture(${n}, uv);
|
|
}
|
|
`;let m=di(n);return`
|
|
float ${s}(int row, int col, int depth,
|
|
int depth2, int depth3, int depth4) {
|
|
// Explicitly use integer operations as dot() only works on floats.
|
|
int index = row * ${c} + col * ${u} + depth * ${l} +
|
|
depth2 * ${i} + depth3 * ${o} + depth4 + ${m};
|
|
vec2 uv = uvFromFlat(${h}, ${f}, index);
|
|
return sampleTexture(${n}, uv);
|
|
}
|
|
`}function Au(e){let t=e.name,n=w.sizeFromShape(e.shapeInfo.logicalShape);return n<2?`return ${t};`:`
|
|
for (int i = 0; i < ${n}; i++) {
|
|
if (i == index) {
|
|
return ${t}[i];
|
|
}
|
|
}
|
|
`}function Zq(e,t){let n=e.name,s=n.charAt(0).toUpperCase()+n.slice(1),r="get"+s+"AtOutCoords",a=e.shapeInfo.logicalShape.length,o=t.logicalShape.length,i=_6(e.shapeInfo.logicalShape,t.logicalShape),l=gt(o),u=o-a,c,d=["x","y","z","w","u","v"];a===0?c="":o<2&&i.length>=1?c="coords = 0;":c=i.map(y=>`coords.${d[y+u]} = 0;`).join(`
|
|
`);let p="";o<2&&a>0?p="coords":p=e.shapeInfo.logicalShape.map((y,x)=>`coords.${d[x+u]}`).join(", ");let h="return outputValue;",m=w.sizeFromShape(e.shapeInfo.logicalShape)===1,A=w.sizeFromShape(t.logicalShape)===1;if(a===1&&!m&&!A)h=`
|
|
return vec4(outputValue.xy, outputValue.xy);
|
|
`;else if(m&&!A)o===1?h=`
|
|
return vec4(outputValue.x, outputValue.x, 0., 0.);
|
|
`:h=`
|
|
return vec4(outputValue.x);
|
|
`;else if(i.length){let y=a-2,x=a-1;i.indexOf(y)>-1&&i.indexOf(x)>-1?h="return vec4(outputValue.x);":i.indexOf(y)>-1?h="return vec4(outputValue.x, outputValue.y, outputValue.x, outputValue.y);":i.indexOf(x)>-1&&(h="return vec4(outputValue.xx, outputValue.zz);")}return`
|
|
vec4 ${r}() {
|
|
${l} coords = getOutputCoords();
|
|
${c}
|
|
vec4 outputValue = get${s}(${p});
|
|
${h}
|
|
}
|
|
`}function Yq(e,t){let n=e.name,s=n.charAt(0).toUpperCase()+n.slice(1),r="get"+s+"AtOutCoords",a=t.texShape,o=e.shapeInfo.texShape,i=e.shapeInfo.logicalShape.length,l=t.logicalShape.length;if(!e.shapeInfo.isUniform&&i===l&&e.shapeInfo.flatOffset==null&&w.arraysEqual(o,a))return`
|
|
float ${r}() {
|
|
return sampleTexture(${n}, resultUV);
|
|
}
|
|
`;let u=gt(l),c=_6(e.shapeInfo.logicalShape,t.logicalShape),d=l-i,p,h=["x","y","z","w","u","v"];i===0?p="":l<2&&c.length>=1?p="coords = 0;":p=c.map(m=>`coords.${h[m+d]} = 0;`).join(`
|
|
`);let f="";return l<2&&i>0?f="coords":f=e.shapeInfo.logicalShape.map((m,g)=>`coords.${h[g+d]}`).join(", "),`
|
|
float ${r}() {
|
|
${u} coords = getOutputCoords();
|
|
${p}
|
|
return get${s}(${f});
|
|
}
|
|
`}function gt(e){if(e<=1)return"int";if(e===2)return"ivec2";if(e===3)return"ivec3";if(e===4)return"ivec4";if(e===5)return"ivec5";if(e===6)return"ivec6";throw Error(`GPU for rank ${e} is not yet supported`)}function dy(e,t,n){let{newShape:s,keptDims:r}=w.squeezeShape(t),a=t.length,o=e&&a===3&&t[0]===1,i=o?t.slice(1):s,l=!e&&a>1&&!w.arraysEqual(t,n)&&s.length<a||o;return{useSqueezeShape:l,uniformShape:l?i:t,keptDims:r}}function yu(e,t){let n=JSON.parse(JSON.stringify(e));return n.shapeInfo.logicalShape=t,n}function xu(e,t){return t.map(n=>e[n]).join(", ")}function Jq(e,t,n,s){let r=n.map((x,b)=>{let v={logicalShape:x.shape,texShape:x.isUniform?null:x.texData.texShape,isUniform:x.isUniform,isPacked:x.isUniform?!1:x.texData.isPacked,flatOffset:null};return x.texData!=null&&x.texData.slice!=null&&x.texData.slice.flatOffset>0&&(v.flatOffset=x.texData.slice.flatOffset),{name:t.variableNames[b],shapeInfo:v}}),a=r.map(x=>x.shapeInfo),o={logicalShape:s.shape,texShape:s.texData.texShape,isUniform:!1,isPacked:s.texData.isPacked,flatOffset:null},i=gq(r,o,t),l=e.createProgram(i),u=null,c=e.getUniformLocation(l,"NAN",!1);Y().getNumber("WEBGL_VERSION")===1&&(u=e.getUniformLocation(l,"INFINITY",!1));let d=!1,p={},h={},f={};for(let x=0;x<t.variableNames.length;x++){let b=t.variableNames[x];p[b]=e.getUniformLocation(l,b,d),p[`offset${b}`]=e.getUniformLocation(l,`offset${b}`,d),t.enableShapeUniforms&&(h[`${b}Shape`]=e.getUniformLocation(l,`${b}Shape`,d),f[`${b}TexShape`]=e.getUniformLocation(l,`${b}TexShape`,d))}let m,g,A;t.enableShapeUniforms&&(m=e.getUniformLocation(l,"outShape",d),A=e.getUniformLocation(l,"outShapeStrides",d),g=e.getUniformLocation(l,"outTexShape",d));let y=[];return t.customUniforms&&t.customUniforms.forEach((x,b)=>{y[b]=e.getUniformLocation(l,x.name,d)}),{program:t,source:i,webGLProgram:l,uniformLocations:p,customUniformLocations:y,inShapeInfos:a,outShapeInfo:o,infLoc:u,nanLoc:c,inShapesLocations:h,inTexShapesLocations:f,outShapeLocation:m,outShapeStridesLocation:A,outTexShapeLocation:g}}function O6(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((n,s)=>{let r=n.logicalShape,a=t[s],o=a.shape;if(!w.arraysEqual(r,o))throw Error(`Binary was compiled with different shapes than the current args. Shapes ${r} and ${o} must match`);if(n.isUniform&&a.isUniform)return;let i=n.texShape,l=a.isUniform?null:a.texData.texShape;if(!w.arraysEqual(i,l))throw Error(`Binary was compiled with different texture shapes than the current args. Shape ${i} and ${l} must match`)})}function Qq(e,t,n,s,r){t.program.enableShapeUniforms||(O6(t.inShapeInfos,n),O6([t.outShapeInfo],[s]));let a=s.texData.texture,o=s.texData.texShape;s.texData.isPacked?e.setOutputPackedMatrixTexture(a,o[0],o[1]):e.setOutputMatrixTexture(a,o[0],o[1]),e.setProgram(t.webGLProgram),Y().getNumber("WEBGL_VERSION")===1&&t.infLoc!==null&&e.gl.uniform1f(t.infLoc,1/0),t.nanLoc!==null&&e.gl.uniform1f(t.nanLoc,NaN),n.forEach((l,u)=>{let c=t.program.variableNames[u],d=t.uniformLocations[c],p=t.uniformLocations[`offset${c}`],h=t.inShapesLocations[`${c}Shape`],f=t.inTexShapesLocations[`${c}TexShape`];if(h){let{uniformShape:m}=dy(t.program.packedInputs,l.shape,l.texData.texShape);switch(m.length){case 1:e.gl.uniform1iv(h,new Int32Array(m));break;case 2:e.gl.uniform2iv(h,new Int32Array(m));break;case 3:e.gl.uniform3iv(h,new Int32Array(m));break;case 4:e.gl.uniform4iv(h,new Int32Array(m));break;default:break}}if(f&&e.gl.uniform2i(f,l.texData.texShape[0],l.texData.texShape[1]),d!=null){if(l.isUniform){if(w.sizeFromShape(l.shape)<2)e.gl.uniform1f(d,l.uniformValues[0]);else{let m=l.uniformValues;m instanceof Float32Array||(m=new Float32Array(m)),e.gl.uniform1fv(d,m)}return}l.texData.slice!=null&&p!=null&&e.gl.uniform1i(p,l.texData.slice.flatOffset),e.setInputMatrixTexture(l.texData.texture,d,u)}});let i=t.outShapeLocation;if(i)switch(s.shape.length){case 1:e.gl.uniform1iv(i,new Int32Array(s.shape));break;case 2:e.gl.uniform2iv(i,new Int32Array(s.shape));break;case 3:e.gl.uniform3iv(i,new Int32Array(s.shape));break;case 4:e.gl.uniform4iv(i,new Int32Array(s.shape));break;default:break}if(t.outShapeStridesLocation){let l=w.computeStrides(s.shape);switch(s.shape.length){case 2:e.gl.uniform1iv(t.outShapeStridesLocation,new Int32Array(l));break;case 3:e.gl.uniform2iv(t.outShapeStridesLocation,new Int32Array(l));break;case 4:e.gl.uniform3iv(t.outShapeStridesLocation,new Int32Array(l));break;default:break}}t.outTexShapeLocation&&e.gl.uniform2i(t.outTexShapeLocation,s.texData.texShape[0],s.texData.texShape[1]),t.program.customUniforms&&r&&t.program.customUniforms.forEach((l,u)=>{let c=t.customUniformLocations[u],d=r[u];if(l.type==="float")e.gl.uniform1fv(c,d);else if(l.type==="vec2")e.gl.uniform2fv(c,d);else if(l.type==="vec3")e.gl.uniform3fv(c,d);else if(l.type==="vec4")e.gl.uniform4fv(c,d);else if(l.type==="int")e.gl.uniform1iv(c,d);else if(l.type==="ivec2")e.gl.uniform2iv(c,d);else if(l.type==="ivec3")e.gl.uniform3iv(c,d);else if(l.type==="ivec4")e.gl.uniform4iv(c,d);else throw Error(`uniform type ${l.type} is not supported yet.`)}),e.executeProgram()}function eX(e,t,n){let s="";t.concat(n).forEach(o=>{let i=o.texData!=null&&o.texData.slice!=null&&o.texData.slice.flatOffset>0;if(e.enableShapeUniforms&&!o.isUniform){let l=o.texData.texShape,{useSqueezeShape:u,uniformShape:c,keptDims:d}=dy(e.packedInputs,o.shape,l),p="",h="",f="";if(c.length===1&&e.packedInputs){let v=[Math.ceil(l[0]/2),Math.ceil(l[1]/2)];p=`${v[0]>1}_${v[1]>1}`}else if(c.length===2&&!e.packedInputs)h=`${c[0]>1}_${c[1]>1}`;else if(c.length>2&&!e.packedInputs){let v=w.computeStrides(c);f=`${v[0]===l[1]}_${v[v.length-1]===l[1]}`}let m=o.shape.length,g=c.length===2&&w.arraysEqual(o.shape,l),A=w.sizeFromShape(o.shape)===1,y=_.getBroadcastDims(o.shape,n.shape),x=!e.packedInputs&&m===n.shape.length&&w.arraysEqual(l,n.texData.texShape),b=e.packedInputs||c.length>2?"":`${l[0]>1}_${l[1]>1}`;s+=`${m}_${x}_${u?d:""}_${c.length}_${A}_${y}_${g}_${p}_${h}_${f}_${b}_${i}`}else{let l=o.isUniform?"uniform":o.texData.texShape;s+=`${o.shape}_${l}_${i}`}});let r=e.userCode,a=e.constructor.name;return a+="_"+s+"_"+r+`${Y().getNumber("WEBGL_VERSION")}`,a}function Ss(e){return Y().getBool("WEBGL_USE_SHAPES_UNIFORMS")&&e<=4}var tX=class{constructor(e){this.variableNames=["A"],this.packedInputs=!1,this.packedOutput=!0,this.outPackingScheme=pd.DENSE,this.customUniforms=[{name:"texShape",type:"ivec2"}];let t=En();this.outputShape=e,this.enableShapeUniforms=Ss(this.outputShape.length),this.userCode=`
|
|
ivec3 outCoordsFromFlatIndex(int index) {
|
|
${this.enableShapeUniforms?qf(["r","c","d"],e):ci(["r","c","d"],e)}
|
|
return ivec3(r, c, d);
|
|
}
|
|
|
|
void main() {
|
|
ivec2 resTexRC = ivec2(resultUV.yx * vec2(texShape[0], texShape[1]));
|
|
int index = 4 * (resTexRC.x * texShape[1] + resTexRC.y);
|
|
|
|
vec4 result = vec4(0.);
|
|
|
|
for (int i=0; i<4; i++) {
|
|
int flatIndex = index + i;
|
|
ivec3 rc = outCoordsFromFlatIndex(flatIndex);
|
|
result[i] = getA(rc.x, rc.y, rc.z);
|
|
}
|
|
|
|
${t.output} = result;
|
|
}
|
|
`}},nX=class{constructor(e){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outPackingScheme=pd.DENSE,this.customUniforms=[{name:"texShape",type:"ivec2"}];let t=En();this.outputShape=e,this.enableShapeUniforms=Ss(this.outputShape.length),this.userCode=`
|
|
ivec3 outCoordsFromFlatIndex(int index) {
|
|
${this.enableShapeUniforms?qf(["r","c","d"],e):ci(["r","c","d"],e)}
|
|
return ivec3(r, c, d);
|
|
}
|
|
|
|
void main() {
|
|
ivec2 resTexRC = ivec2(resultUV.yx * vec2(texShape[0], texShape[1]));
|
|
int index = 4 * (resTexRC.x * texShape[1] + resTexRC.y);
|
|
|
|
vec4 result = vec4(0.);
|
|
|
|
for (int i=0; i<4; i++) {
|
|
int flatIndex = index + i;
|
|
ivec3 rc = outCoordsFromFlatIndex(flatIndex);
|
|
result[i] = getChannel(getA(rc.x, rc.y, rc.z), vec2(rc.y, rc.z));
|
|
}
|
|
|
|
${t.output} = result;
|
|
}
|
|
`}},sX=class{constructor(e){this.variableNames=["A"],this.outTexUsage=ks.DOWNLOAD;let t=En();this.outputShape=e,this.userCode=`
|
|
${D6}
|
|
|
|
void main() {
|
|
float x = getAAtOutCoords();
|
|
${t.output} = encode_float(x);
|
|
}
|
|
`}},rX=class{constructor(e){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!1,this.outTexUsage=ks.DOWNLOAD;let t=En();this.outputShape=e,this.userCode=`
|
|
${D6}
|
|
|
|
void main() {
|
|
ivec3 coords = getOutputCoords();
|
|
float x = getChannel(getAAtOutCoords(), vec2(coords.y, coords.z));
|
|
${t.output} = encode_float(x);
|
|
}
|
|
`}},aX=class{constructor(e,t=!1){this.variableNames=["A"],this.customUniforms=[{name:"texShape",type:"ivec2"}];let n=En();this.outputShape=e,this.enableShapeUniforms=Ss(this.outputShape.length);let s="result";t&&(s="floor(result * 255. + 0.5)"),this.userCode=`
|
|
${this.enableShapeUniforms?cy():uy(e)}
|
|
|
|
void main() {
|
|
ivec3 coords = getOutputCoords();
|
|
|
|
int flatIndex = getFlatIndex(coords);
|
|
int offset = imod(flatIndex, 4);
|
|
|
|
flatIndex = idiv(flatIndex, 4, 1.);
|
|
|
|
int r = flatIndex / texShape[1];
|
|
int c = imod(flatIndex, texShape[1]);
|
|
vec2 uv = (vec2(c, r) + halfCR) / vec2(texShape[1], texShape[0]);
|
|
vec4 values = ${n.texture2D}(A, uv);
|
|
|
|
float result;
|
|
|
|
if(offset == 0) {
|
|
result = values[0];
|
|
} else if(offset == 1) {
|
|
result = values[1];
|
|
} else if(offset == 2) {
|
|
result = values[2];
|
|
} else {
|
|
result = values[3];
|
|
}
|
|
|
|
${n.output} = vec4(${s}, 0., 0., 0.);
|
|
}
|
|
`}},oX=class{constructor(e,t=!1){this.variableNames=["A"],this.packedInputs=!1,this.packedOutput=!0,this.customUniforms=[{name:"texShape",type:"ivec2"}];let n=En();this.outputShape=e,this.enableShapeUniforms=Ss(this.outputShape.length);let s="",r="result";t&&(r="floor(result * 255. + 0.5)");for(let a=0;a<=1;a++)for(let o=0;o<=1;o++){let i=a*2+o;s+=`
|
|
localCoords = coords;
|
|
if(localCoords[2] + ${o} < ${this.enableShapeUniforms?"outShape[2]":`${e[2]}`}) {
|
|
localCoords[2] += ${o};
|
|
if (localCoords[1] + ${a} < ${this.enableShapeUniforms?"outShape[1]":`${e[1]}`}) {
|
|
localCoords[1] += ${a};
|
|
|
|
flatIndex = getFlatIndex(localCoords);
|
|
offset = imod(flatIndex, 4);
|
|
|
|
flatIndex = idiv(flatIndex, 4, 1.);
|
|
|
|
int r = flatIndex / texShape[1];
|
|
int c = imod(flatIndex, texShape[1]);
|
|
vec2 uv = (vec2(c, r) + halfCR) / vec2(texShape[1], texShape[0]);
|
|
values = ${n.texture2D}(A, uv);
|
|
|
|
if (offset == 0) {
|
|
result[${i}] = values[0];
|
|
} else if (offset == 1) {
|
|
result[${i}] = values[1];
|
|
} else if (offset == 2) {
|
|
result[${i}] = values[2];
|
|
} else {
|
|
result[${i}] = values[3];
|
|
}
|
|
}
|
|
}
|
|
`}this.userCode=`
|
|
${this.enableShapeUniforms?cy():uy(e)}
|
|
|
|
void main() {
|
|
ivec3 coords = getOutputCoords();
|
|
|
|
vec4 result = vec4(0.);
|
|
int flatIndex, r, c, offset;
|
|
ivec3 localCoords;
|
|
vec2 uv;
|
|
vec4 values;
|
|
|
|
${s}
|
|
|
|
${n.output} = ${r};
|
|
}
|
|
`}},P6={};Le(P6,{bindVertexProgramAttributeStreams:()=>G6,createBufferFromOutputTexture:()=>X6,createFloat16MatrixTexture:()=>W6,createFloat16PackedMatrixTexture:()=>H6,createFloat32MatrixTexture:()=>B6,createIndexBuffer:()=>L6,createPackedMatrixTexture:()=>U6,createUnsignedBytesMatrixTexture:()=>V6,createVertexBuffer:()=>z6,createVertexShader:()=>M6,downloadByteEncodedFloatMatrixFromOutputTexture:()=>Z6,downloadFloat32MatrixFromBuffer:()=>K6,downloadMatrixFromPackedOutputTexture:()=>J6,downloadPackedMatrixFromBuffer:()=>Y6,getInternalFormatForFloat16MatrixTexture:()=>hy,getInternalFormatForFloat16PackedMatrixTexture:()=>gy,getInternalFormatForFloat32MatrixTexture:()=>py,getInternalFormatForPackedMatrixTexture:()=>my,getInternalFormatForUnsignedBytesMatrixTexture:()=>fy,uploadDenseMatrixToTexture:()=>j6,uploadPixelDataToTexture:()=>q6});function M6(e){let t=En(),n=`${t.version}
|
|
precision highp float;
|
|
${t.attribute} vec3 clipSpacePos;
|
|
${t.attribute} vec2 uv;
|
|
${t.varyingVs} vec2 resultUV;
|
|
|
|
void main() {
|
|
gl_Position = vec4(clipSpacePos, 1);
|
|
resultUV = uv;
|
|
}`;return u6(e,n)}function z6(e){let t=new Float32Array([-1,1,0,0,1,-1,-1,0,0,0,1,1,0,1,1,1,-1,0,1,0]);return h6(e,t)}function L6(e){let t=new Uint16Array([0,1,2,2,1,3]);return f6(e,t)}function Ad(e,t,n,s,r,a){g6(t,n);let o=m6(e),i=e.TEXTURE_2D;return ke(e,()=>e.bindTexture(i,o)),ke(e,()=>e.texParameteri(i,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE)),ke(e,()=>e.texParameteri(i,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE)),ke(e,()=>e.texParameteri(i,e.TEXTURE_MIN_FILTER,e.NEAREST)),ke(e,()=>e.texParameteri(i,e.TEXTURE_MAG_FILTER,e.NEAREST)),ke(e,()=>e.texImage2D(i,0,s,t,n,0,r,a,null)),ke(e,()=>e.bindTexture(e.TEXTURE_2D,null)),o}function py(e){return e.internalFormatFloat}function B6(e,t,n,s){let[r,a]=hd(t,n);return Ad(e,r,a,py(s),s.textureFormatFloat,e.FLOAT)}function hy(e){return e.internalFormatHalfFloat}function W6(e,t,n,s){let[r,a]=hd(t,n);return Ad(e,r,a,hy(s),s.textureFormatFloat,s.textureTypeHalfFloat)}function fy(e){return e.downloadTextureFormat}function V6(e,t,n,s){let[r,a]=hd(t,n);return Ad(e,r,a,fy(s),e.RGBA,e.UNSIGNED_BYTE)}function my(e){return e.internalFormatPackedFloat}function U6(e,t,n,s){let[r,a]=fu(t,n);return Ad(e,r,a,my(s),e.RGBA,e.FLOAT)}function gy(e){return e.internalFormatPackedHalfFloat}function H6(e,t,n,s){let[r,a]=fu(t,n);return Ad(e,r,a,gy(s),e.RGBA,s.textureTypeHalfFloat)}function G6(e,t,n){let s=0,r=3*4,a=3*4+2*4;return ke(e,()=>e.bindBuffer(e.ARRAY_BUFFER,n)),ay(e,t,"clipSpacePos",n,3,a,s)&&ay(e,t,"uv",n,2,a,r)}function j6(e,t,n,s,r,a){ke(e,()=>e.bindTexture(e.TEXTURE_2D,t));let o,i,l;r instanceof Uint8Array?(o=new Uint8Array(n*s*4),i=e.UNSIGNED_BYTE,l=e.RGBA):(o=new Float32Array(n*s*4),i=e.FLOAT,l=a.internalFormatPackedFloat),o.set(r),ke(e,()=>e.texImage2D(e.TEXTURE_2D,0,l,n,s,0,e.RGBA,i,o)),ke(e,()=>e.bindTexture(e.TEXTURE_2D,null))}function q6(e,t,n){ke(e,()=>e.bindTexture(e.TEXTURE_2D,t)),n.data instanceof Uint8Array?ke(e,()=>e.texImage2D(e.TEXTURE_2D,0,e.RGBA,n.width,n.height,0,e.RGBA,e.UNSIGNED_BYTE,n.data)):ke(e,()=>e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,n)),ke(e,()=>e.bindTexture(e.TEXTURE_2D,null))}function X6(e,t,n,s){let r=e.createBuffer();ke(e,()=>e.bindBuffer(e.PIXEL_PACK_BUFFER,r));let i=4*4*t*n;return ke(e,()=>e.bufferData(e.PIXEL_PACK_BUFFER,i,e.STREAM_READ)),ke(e,()=>e.readPixels(0,0,n,t,e.RGBA,e.FLOAT,0)),ke(e,()=>e.bindBuffer(e.PIXEL_PACK_BUFFER,null)),r}function K6(e,t,n){let s=e,r=new Float32Array(n);return s.bindBuffer(s.PIXEL_PACK_BUFFER,t),s.getBufferSubData(s.PIXEL_PACK_BUFFER,0,r),s.bindBuffer(s.PIXEL_PACK_BUFFER,null),r}function Z6(e,t,n,s){let[r,a]=hd(t,n),o=4,i=new Uint8Array(tq(t*n,o));return ke(e,()=>e.readPixels(0,0,r,a,s.downloadTextureFormat,e.UNSIGNED_BYTE,i)),new Float32Array(i.buffer)}function Y6(e,t,n,s,r,a,o,i){let l=e,u=new Float32Array(nq(a,o));return l.bindBuffer(l.PIXEL_PACK_BUFFER,t),l.getBufferSubData(l.PIXEL_PACK_BUFFER,0,u),l.bindBuffer(l.PIXEL_PACK_BUFFER,null),u}function J6(e,t,n){let s=new Float32Array(t*n*4);return ke(e,()=>e.readPixels(0,0,n,t,e.RGBA,e.FLOAT,s)),s}var Xf=class{constructor(e){this.outputTexture=null,this.program=null,this.disposed=!1,this.vertexAttrsAreBound=!1,this.itemsToPoll=[];let t=Y().getNumber("WEBGL_VERSION");e!=null?(this.gl=e,Lf(t,e)):this.gl=mr(t);let n="WEBGL_color_buffer_float",s="EXT_color_buffer_half_float";if(Y().getNumber("WEBGL_VERSION")===1){let r="OES_texture_float",a="OES_texture_half_float";if(this.textureFloatExtension=fd(this.gl,r),Is(this.gl,a))this.textureHalfFloatExtension=fd(this.gl,a);else if(Y().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),Is(this.gl,s))this.colorBufferHalfFloatExtension=fd(this.gl,s);else if(Y().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",Is(this.gl,n))this.colorBufferFloatExtension=this.gl.getExtension(n);else if(Is(this.gl,s))this.colorBufferHalfFloatExtension=this.gl.getExtension(s);else throw new Error("GL context does not support color renderable floats");this.vertexBuffer=z6(this.gl),this.indexBuffer=L6(this.gl),this.framebuffer=A6(this.gl),this.textureConfig=ry(this.gl,this.textureHalfFloatExtension)}get debug(){return Y().getBool("DEBUG")}dispose(){if(this.disposed)return;this.program!=null&&console.warn("Disposing a GPGPUContext that still has a bound WebGLProgram. This is probably a resource leak, delete the program with GPGPUContext.deleteProgram before disposing."),this.outputTexture!=null&&console.warn("Disposing a GPGPUContext that still has a bound output matrix texture. This is probably a resource leak, delete the output matrix texture with GPGPUContext.deleteMatrixTexture before disposing.");let e=this.gl;ke(e,()=>e.finish()),ke(e,()=>e.bindFramebuffer(e.FRAMEBUFFER,null)),ke(e,()=>e.deleteFramebuffer(this.framebuffer)),ke(e,()=>e.bindBuffer(e.ARRAY_BUFFER,null)),ke(e,()=>e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,null)),ke(e,()=>e.deleteBuffer(this.indexBuffer)),this.disposed=!0}createFloat32MatrixTexture(e,t){return this.throwIfDisposed(),B6(this.gl,e,t,this.textureConfig)}createFloat16MatrixTexture(e,t){return this.throwIfDisposed(),W6(this.gl,e,t,this.textureConfig)}createUnsignedBytesMatrixTexture(e,t){return this.throwIfDisposed(),V6(this.gl,e,t,this.textureConfig)}uploadPixelDataToTexture(e,t){this.throwIfDisposed(),q6(this.gl,e,t)}uploadDenseMatrixToTexture(e,t,n,s){this.throwIfDisposed(),j6(this.gl,e,t,n,s,this.textureConfig)}createFloat16PackedMatrixTexture(e,t){return this.throwIfDisposed(),H6(this.gl,e,t,this.textureConfig)}createPackedMatrixTexture(e,t){return this.throwIfDisposed(),U6(this.gl,e,t,this.textureConfig)}deleteMatrixTexture(e){this.throwIfDisposed(),this.outputTexture===e&&(oy(this.gl,this.framebuffer),this.outputTexture=null),ke(this.gl,()=>this.gl.deleteTexture(e))}downloadByteEncodedFloatMatrixFromOutputTexture(e,t,n){return this.downloadMatrixDriver(e,()=>Z6(this.gl,t,n,this.textureConfig))}downloadPackedMatrixFromBuffer(e,t,n,s,r,a){return Y6(this.gl,e,t,n,s,r,a,this.textureConfig)}downloadFloat32MatrixFromBuffer(e,t){return K6(this.gl,e,t)}createBufferFromTexture(e,t,n){this.bindTextureToFrameBuffer(e);let s=X6(this.gl,t,n,this.textureConfig);return this.unbindTextureToFrameBuffer(),s}createAndWaitForFence(){let e=this.createFence(this.gl);return this.pollFence(e)}createFence(e){let t,n;if(Y().getBool("WEBGL_FENCE_API_ENABLED")){let s=e,r=s.fenceSync(s.SYNC_GPU_COMMANDS_COMPLETE,0);e.flush(),n=()=>{let a=s.clientWaitSync(r,0,0);return a===s.ALREADY_SIGNALED||a===s.CONDITION_SATISFIED},t=r}else Y().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")>0?(t=this.beginQuery(),this.endQuery(),n=()=>this.isQueryAvailable(t,Y().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION"))):n=()=>!0;return{query:t,isFencePassed:n}}downloadMatrixFromPackedTexture(e,t,n){return this.downloadMatrixDriver(e,()=>J6(this.gl,t,n))}createProgram(e){this.throwIfDisposed();let t=this.gl,n=c6(t,e);this.vertexShader==null&&(this.vertexShader=M6(t));let s=d6(t);return ke(t,()=>t.attachShader(s,this.vertexShader)),ke(t,()=>t.attachShader(s,n)),p6(t,s),this.debug&&Wf(t,s),this.vertexAttrsAreBound||(this.setProgram(s),this.vertexAttrsAreBound=G6(t,this.program,this.vertexBuffer)),s}deleteProgram(e){this.throwIfDisposed(),e===this.program&&(this.program=null),e!=null&&ke(this.gl,()=>this.gl.deleteProgram(e))}setProgram(e){this.throwIfDisposed(),this.program=e,this.program!=null&&this.debug&&Wf(this.gl,this.program),ke(this.gl,()=>this.gl.useProgram(e))}getUniformLocation(e,t,n=!0){return this.throwIfDisposed(),n?x6(this.gl,e,t):b6(this.gl,e,t)}getAttributeLocation(e,t){return this.throwIfDisposed(),ke(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(),v6(this.gl,e,t,n)}setOutputMatrixTexture(e,t,n){this.setOutputMatrixTextureDriver(e,n,t)}setOutputPackedMatrixTexture(e,t,n){this.throwIfDisposed();let[s,r]=fu(t,n);this.setOutputMatrixTextureDriver(e,s,r)}setOutputMatrixWriteRegion(e,t,n,s){this.setOutputMatrixWriteRegionDriver(n,e,s,t)}setOutputPackedMatrixWriteRegion(e,t,n,s){throw new Error("setOutputPackedMatrixWriteRegion not implemented.")}debugValidate(){this.program!=null&&Wf(this.gl,this.program),md(this.gl)}executeProgram(){this.throwIfDisposed(),this.throwIfNoProgram();let e=this.gl;this.debug&&this.debugValidate(),ke(e,()=>e.drawElements(e.TRIANGLES,6,e.UNSIGNED_SHORT,0))}blockUntilAllProgramsCompleted(){this.throwIfDisposed(),ke(this.gl,()=>this.gl.finish())}getQueryTimerExtension(){return this.disjointQueryTimerExtension==null&&(this.disjointQueryTimerExtension=fd(this.gl,Y().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")===2?"EXT_disjoint_timer_query_webgl2":"EXT_disjoint_timer_query")),this.disjointQueryTimerExtension}getQueryTimerExtensionWebGL2(){return this.getQueryTimerExtension()}getQueryTimerExtensionWebGL1(){return this.getQueryTimerExtension()}beginQuery(){if(Y().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")===2){let n=this.gl,s=this.getQueryTimerExtensionWebGL2(),r=n.createQuery();return n.beginQuery(s.TIME_ELAPSED_EXT,r),r}let e=this.getQueryTimerExtensionWebGL1(),t=e.createQueryEXT();return e.beginQueryEXT(e.TIME_ELAPSED_EXT,t),t}endQuery(){if(Y().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")===2){let t=this.gl,n=this.getQueryTimerExtensionWebGL2();t.endQuery(n.TIME_ELAPSED_EXT);return}let e=this.getQueryTimerExtensionWebGL1();e.endQueryEXT(e.TIME_ELAPSED_EXT)}async waitForQueryAndGetTime(e){return await w.repeatedTry(()=>this.disposed||this.isQueryAvailable(e,Y().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION"))),this.getQueryTime(e,Y().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION"))}getQueryTime(e,t){if(t===0)return null;if(t===2){let n=this.gl;return n.getQueryParameter(e,n.QUERY_RESULT)/1e6}else{let n=this.getQueryTimerExtensionWebGL1();return n.getQueryObjectEXT(e,n.QUERY_RESULT_EXT)/1e6}}isQueryAvailable(e,t){if(t===0)return!0;if(t===2){let n=this.gl,s=this.getQueryTimerExtensionWebGL2(),r=n.getQueryParameter(e,n.QUERY_RESULT_AVAILABLE);return this.disjoint==null&&(this.disjoint=this.gl.getParameter(s.GPU_DISJOINT_EXT)),r&&!this.disjoint}else{let n=this.getQueryTimerExtensionWebGL1(),s=n.getQueryObjectEXT(e,n.QUERY_RESULT_AVAILABLE_EXT);return this.disjoint==null&&(this.disjoint=this.gl.getParameter(n.GPU_DISJOINT_EXT)),s&&!this.disjoint}}pollFence(e){return new Promise(t=>{this.addItemToPoll(()=>e.isFencePassed(),()=>t())})}pollItems(){let e=iX(this.itemsToPoll.map(t=>t.isDoneFn));for(let t=0;t<=e;++t){let{resolveFn:n}=this.itemsToPoll[t];n()}this.itemsToPoll=this.itemsToPoll.slice(e+1)}addItemToPoll(e,t){this.itemsToPoll.push({isDoneFn:e,resolveFn:t}),!(this.itemsToPoll.length>1)&&w.repeatedTry(()=>(this.pollItems(),this.itemsToPoll.length===0))}bindTextureToFrameBuffer(e){this.throwIfDisposed(),Vf(this.gl,e,this.framebuffer),this.debug&&md(this.gl)}unbindTextureToFrameBuffer(){this.outputTexture!=null?(Vf(this.gl,this.outputTexture,this.framebuffer),this.debug&&md(this.gl)):oy(this.gl,this.framebuffer)}downloadMatrixDriver(e,t){this.bindTextureToFrameBuffer(e);let n=t();return this.unbindTextureToFrameBuffer(),n}setOutputMatrixTextureDriver(e,t,n){this.throwIfDisposed();let s=this.gl;Vf(s,e,this.framebuffer),this.debug&&md(s),this.outputTexture=e,ke(s,()=>s.viewport(0,0,t,n)),ke(s,()=>s.scissor(0,0,t,n))}setOutputMatrixWriteRegionDriver(e,t,n,s){this.throwIfDisposed(),ke(this.gl,()=>this.gl.scissor(e,t,n,s))}throwIfDisposed(){if(this.disposed)throw new Error("Attempted to use disposed GPGPUContext.")}throwIfNoProgram(){if(this.program==null)throw new Error("No GPU program is currently set.")}};function iX(e){let t=0;for(;t<e.length&&e[t]();++t);return t-1}var{addImpl:lX,bincountImpl:Q6,bincountReduceImpl:uX,ceilImpl:cX,concatImpl:dX,equalImpl:pX,expImpl:hX,expm1Impl:fX,floorImpl:mX,gatherNdImpl:gX,gatherV2Impl:AX,greaterImpl:yX,greaterEqualImpl:xX,lessImpl:bX,lessEqualImpl:vX,linSpaceImpl:wX,logImpl:kX,maxImpl:IX,maximumImpl:SX,minimumImpl:CX,multiplyImpl:TX,negImpl:NX,notEqualImpl:EX,prodImpl:RX,rangeImpl:DX,rsqrtImpl:_X,sigmoidImpl:$X,simpleAbsImpl:e4,sliceImpl:FX,sparseFillEmptyRowsImpl:OX,sparseReshapeImpl:PX,sparseSegmentReductionImpl:t4,sqrtImpl:MX,stridedSliceImpl:zX,stringNGramsImpl:LX,stringSplitImpl:BX,stringToHashBucketFastImpl:WX,subImpl:VX,tileImpl:UX,topKImpl:HX,transposeImpl:Ay,uniqueImpl:GX}=nw;function n4(e,t){return["x","y","z","w","u","v"].slice(0,t).map(n=>`${e}.${n}`)}function Rn(e,t){return t===1?[e]:n4(e,t)}function jX(e,t){if(e===1)return"rc";let n="";for(let s=0;s<e;s++)n+=t[s],s<e-1&&(n+=",");return n}var qX=class{constructor(e){this.variableNames=["A"],this.packedInputs=!1,this.packedOutput=!0,this.outputShape=e;let t=e.length;if(t===0)this.userCode=`
|
|
void main() {
|
|
setOutput(vec4(getA(), 0., 0., 0.));
|
|
}
|
|
`;else{let n=Rn("rc",t),s=gt(t),r=KX(t,e,n),a=ZX(t,e[e.length-1],e[e.length-2],n),o=YX(e,n);this.userCode=`
|
|
void main() {
|
|
${s} rc = getOutputCoords();
|
|
|
|
if(${r}) {
|
|
setOutput(vec4(0));
|
|
} else {
|
|
${a}
|
|
|
|
setOutput(vec4(${o}));
|
|
}
|
|
}
|
|
`}}};function XX(e,t){let n=[];for(let s=0;s<=1;s++)for(let r=0;r<=1;r++){let a=`${s===0?"r":"rp1"}, ${r===0?"c":"cp1"}`;for(let o=2;o<e;o++)a=`${t[t.length-1-o]},`+a;n.push(a)}return n}function KX(e,t,n){if(e===1)return`rc > ${t[0]}`;let s="";for(let r=e-2;r<e;r++)s+=`${n[r]} >= ${t[r]}`,r<e-1&&(s+="||");return s}function ZX(e,t,n,s){if(e===1)return"";let r=s.slice(-2);return`
|
|
int r = ${r[0]};
|
|
int c = ${r[1]};
|
|
int rp1 = r + 1;
|
|
int cp1 = c + 1;
|
|
|
|
bool cEdge = cp1 >= ${t};
|
|
bool rEdge = rp1 >= ${n};
|
|
`}function YX(e,t){let n=e.length,s=XX(n,t);return n===1?`getA(rc),
|
|
rc + 1 >= ${e[0]} ? 0. : getA(rc + 1),
|
|
0, 0`:`getA(${s[0]}),
|
|
cEdge ? 0. : getA(${s[1]}),
|
|
rEdge ? 0. : getA(${s[2]}),
|
|
rEdge || cEdge ? 0. : getA(${s[3]})`}var s4=class{constructor(e,t){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.customUniforms=[{name:"inputShape",type:"ivec3"}],this.outputShape=e,this.enableShapeUniforms=Ss(this.outputShape.length);let n="";for(let s=0;s<4;s++){let r="thisRC = rc;";s%2==1&&(r+="thisRC.z += 1;"),s>1&&(r+="thisRC.y += 1;"),n+=`
|
|
${r}
|
|
${s>0?"if(thisRC.y < rows && thisRC.z < cols){":""}
|
|
int flatIndex = getFlatIndex(thisRC);
|
|
|
|
ivec3 inputRC = inputCoordsFromReshapedOutCoords(flatIndex);
|
|
vec2 inputRCInnerDims = vec2(float(inputRC.y),float(inputRC.z));
|
|
|
|
result[${s}] =
|
|
getChannel(getA(inputRC.x, inputRC.y, inputRC.z), inputRCInnerDims);
|
|
${s>0?"}":""}
|
|
`}this.userCode=`
|
|
${JX(t,this.enableShapeUniforms)}
|
|
${this.enableShapeUniforms?cy():uy(e)}
|
|
|
|
void main() {
|
|
ivec3 rc = getOutputCoords();
|
|
|
|
vec4 result = vec4(0.);
|
|
|
|
ivec3 thisRC;
|
|
int rows = ${this.enableShapeUniforms?"outShape[1]":e[1]};
|
|
int cols = ${this.enableShapeUniforms?"outShape[2]":e[2]};
|
|
|
|
${n}
|
|
|
|
setOutput(result);
|
|
}
|
|
`}};function JX(e,t){return`
|
|
ivec3 inputCoordsFromReshapedOutCoords(int index) {
|
|
${t?mq(["r","c","d"],"inputShape"):ci(["r","c","d"],e)}
|
|
return ivec3(r, c, d);
|
|
}
|
|
`}var QX=class{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){let s=a4(t,n),r=o4(e,s,n);r in this.freeTextures||(this.freeTextures[r]=[]),r in this.usedTextures||(this.usedTextures[r]=[]);let a=r4(e,s,this.gpgpu.gl,this.gpgpu.textureConfig,n);if(this.freeTextures[r].length>0){this.numFreeTextures--,this.numUsedTextures++,this._numBytesFree-=a,this.log();let i=this.freeTextures[r].shift();return this.usedTextures[r].push(i),i}let o;return s===gn.PACKED_2X2_FLOAT32?o=this.gpgpu.createPackedMatrixTexture(e[0],e[1]):s===gn.PACKED_2X2_FLOAT16?o=this.gpgpu.createFloat16PackedMatrixTexture(e[0],e[1]):s===gn.UNPACKED_FLOAT32?o=this.gpgpu.createFloat32MatrixTexture(e[0],e[1]):s===gn.UNPACKED_FLOAT16?o=this.gpgpu.createFloat16MatrixTexture(e[0],e[1]):s===gn.PACKED_4X1_UNSIGNED_BYTE&&(o=this.gpgpu.createUnsignedBytesMatrixTexture(e[0],e[1])),this.usedTextures[r].push(o),this.numUsedTextures++,this._numBytesAllocated+=a,this.log(),o}releaseTexture(e,t,n,s){if(this.freeTextures==null)return;let r=a4(n,s),a=o4(t,r,s);a in this.freeTextures||(this.freeTextures[a]=[]);let o=r4(t,r,this.gpgpu.gl,this.gpgpu.textureConfig,s),i=Y().get("WEBGL_DELETE_TEXTURE_THRESHOLD");i!==-1&&this._numBytesAllocated>i?(this.gpgpu.deleteMatrixTexture(e),this._numBytesAllocated-=o):(this.freeTextures[a].push(e),this.numFreeTextures++,this._numBytesFree+=o),this.numUsedTextures--;let l=this.usedTextures[a],u=l.indexOf(e);if(u<0)throw new Error("Cannot release a texture that was never provided by this texture manager");l.splice(u,1),this.log()}log(){if(!this.logEnabled)return;let e=this.numFreeTextures+this.numUsedTextures;console.log("Free/Used",`${this.numFreeTextures} / ${this.numUsedTextures}`,`(${e})`);let t=this._numBytesFree/this._numBytesAllocated;console.log(`Bytes allocated: ${this._numBytesAllocated}`),console.log(`Bytes unused: ${this._numBytesFree} (${Math.round(100*t)}%)`)}get numBytesAllocated(){return this._numBytesAllocated}get numBytesFree(){return this._numBytesFree}getNumUsedTextures(){return this.numUsedTextures}getNumFreeTextures(){return this.numFreeTextures}dispose(){if(this.freeTextures!=null){for(let e in this.freeTextures)this.freeTextures[e].forEach(t=>{this.gpgpu.deleteMatrixTexture(t)});for(let e in this.usedTextures)this.usedTextures[e].forEach(t=>{this.gpgpu.deleteMatrixTexture(t)});this.freeTextures=null,this.usedTextures=null,this.numUsedTextures=0,this.numFreeTextures=0,this._numBytesAllocated=0,this._numBytesFree=0}}};function eK(e,t){let 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;throw new Error(`Unknown internal format ${t}`)}function r4(e,t,n,s,r){let a=tK(t,s),o;if(r){let[l,u]=fu(e[0],e[1]);o=l*u}else{let[l,u]=hd(e[0],e[1]);o=l*u}let i=eK(n,a);return o*i}function tK(e,t){switch(e){case gn.PACKED_2X2_FLOAT32:return my(t);case gn.PACKED_2X2_FLOAT16:return gy(t);case gn.UNPACKED_FLOAT32:return py(t);case gn.UNPACKED_FLOAT16:return hy(t);case gn.PACKED_4X1_UNSIGNED_BYTE:return fy(t);default:throw new Error(`Unknown physical texture type ${e}`)}}function nK(e){return Y().getBool("WEBGL_RENDER_FLOAT32_ENABLED")?e?gn.PACKED_2X2_FLOAT32:gn.UNPACKED_FLOAT32:e?gn.PACKED_2X2_FLOAT16:gn.UNPACKED_FLOAT16}function a4(e,t){if(e===ks.UPLOAD)return gn.PACKED_2X2_FLOAT32;if(e===ks.RENDER||e==null)return nK(t);if(e===ks.DOWNLOAD||e===ks.PIXELS)return gn.PACKED_4X1_UNSIGNED_BYTE;throw new Error(`Unknown logical texture type ${e}`)}function o4(e,t,n){return`${e[0]}_${e[1]}_${t}_${n}`}var wa=class{constructor(e,t){this.variableNames=["A"],this.outputShape=e,this.enableShapeUniforms=Ss(this.outputShape.length),this.userCode=`
|
|
float unaryOperation(float x) {
|
|
${t}
|
|
}
|
|
|
|
void main() {
|
|
float x = getAAtOutCoords();
|
|
float y = unaryOperation(x);
|
|
|
|
setOutput(y);
|
|
}
|
|
`}},Js="if (isnan(x)) return x;",sK="return x;",i4="return abs(x);",rK="return (x >= 0.0) ? x : (exp(x) - 1.0);",aK=Js+`
|
|
return (x < 0.0) ? 0.0 : x;
|
|
`,oK=Js+`
|
|
return (x < 0.0) ? 0.0 : min(6.0, x);
|
|
`,Kf="return x;",iK="return 1.0 / (1.0 + exp(-1.0 * x));",lK="return x;",uK=`
|
|
vec4 result;
|
|
|
|
result.r = (x.r >= 0.0) ? x.r : (exp(x.r) - 1.0);
|
|
result.g = (x.g >= 0.0) ? x.g : (exp(x.g) - 1.0);
|
|
result.b = (x.b >= 0.0) ? x.b : (exp(x.b) - 1.0);
|
|
result.a = (x.a >= 0.0) ? x.a : (exp(x.a) - 1.0);
|
|
|
|
return result;
|
|
`,cK=`
|
|
vec4 result = x * vec4(greaterThanEqual(x, vec4(0.0)));
|
|
bvec4 isNaN = isnan(x);
|
|
|
|
result.r = isNaN.r ? x.r : result.r;
|
|
result.g = isNaN.g ? x.g : result.g;
|
|
result.b = isNaN.b ? x.b : result.b;
|
|
result.a = isNaN.a ? x.a : result.a;
|
|
|
|
return result;
|
|
`,dK=`
|
|
vec4 result = min(x, vec4(6.)) * vec4(greaterThanEqual(x, vec4(0.0)));
|
|
bvec4 isNaN = isnan(x);
|
|
|
|
result.r = isNaN.r ? x.r : result.r;
|
|
result.g = isNaN.g ? x.g : result.g;
|
|
result.b = isNaN.b ? x.b : result.b;
|
|
result.a = isNaN.a ? x.a : result.a;
|
|
|
|
return result;
|
|
`,pK="return 1.0 / (1.0 + exp(-1.0 * x));",bu=class{constructor(e,t){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=e,this.enableShapeUniforms=Ss(this.outputShape.length),this.userCode=`
|
|
vec4 unaryOperation(vec4 x) {
|
|
${t}
|
|
}
|
|
|
|
void main() {
|
|
vec4 x = getAAtOutCoords();
|
|
vec4 y = unaryOperation(x);
|
|
|
|
setOutput(y);
|
|
}
|
|
`}},hK=class{constructor(e){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!1,this.outputShape=e;let t=e.length,n=Rn("rc",t),s=gt(t),r=jX(t,n),a=n.slice(-2),o=t<=1?"rc":`vec2(${a.join(",")})`;this.userCode=`
|
|
void main() {
|
|
${s} rc = getOutputCoords();
|
|
vec4 packedInput = getA(${r});
|
|
|
|
setOutput(getChannel(packedInput, ${o}));
|
|
}
|
|
`}},fK=lr.whereImpl,mK=1e-7,gK=1e-4,Zf={};function AK(e){return e in Zf||(Zf[e]={}),Zf[e]}var yK=Y().getNumber("CPU_HANDOFF_SIZE_THRESHOLD"),xK=600;function bK(){return Y().global.screen==null?1024:Y().global.screen.height*Y().global.screen.width*window.devicePixelRatio*xK/1024/1024}var vu=class extends qu{constructor(e){super();if(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,!Y().getBool("HAS_WEBGL"))throw new Error("WebGL is not supported on this device");if(e==null){let t=mr(Y().getNumber("WEBGL_VERSION"));this.binaryCache=AK(Y().getNumber("WEBGL_VERSION")),this.gpgpu=new Xf(t),this.canvas=t.canvas,this.gpgpuCreatedLocally=!0}else this.gpgpu=e,this.binaryCache={},this.gpgpuCreatedLocally=!1,this.canvas=e.gl.canvas;this.textureManager=new QX(this.gpgpu),this.numMBBeforeWarning=bK(),this.texData=new up(this,Qn())}nextDataId(){return vu.nextDataId++}numDataIds(){return this.texData.numDataIds()-this.pendingDeletes}write(e,t,n){if((Y().getBool("WEBGL_CHECK_NUMERICAL_PROBLEMS")||Y().getBool("DEBUG"))&&this.checkNumericalProblems(e),n==="complex64"&&e!=null)throw new Error("Cannot write to a complex64 dtype. Please use tf.complex(real, imag).");let s={id:this.nextDataId()};return this.texData.set(s,{shape:t,dtype:n,values:e,usage:ks.UPLOAD,refCount:1}),s}refCount(e){return this.texData.has(e)?this.texData.get(e).refCount:0}incRef(e){let t=this.texData.get(e);t.refCount++}decRef(e){if(this.texData.has(e)){let t=this.texData.get(e);t.refCount--}}move(e,t,n,s,r){if(Y().getBool("DEBUG")&&this.checkNumericalProblems(t),s==="complex64")throw new Error("Cannot write to a complex64 dtype. Please use tf.complex(real, imag).");this.texData.set(e,{shape:n,dtype:s,values:t,usage:ks.UPLOAD,refCount:r})}disposeIntermediateTensorInfo(e){this.disposeData(e.dataId)}readSync(e){let t=this.texData.get(e),{values:n,dtype:s,complexTensorInfos:r,slice:a,shape:o,isPacked:i}=t;if(a!=null){let d;i?d=new bu(o,Kf):d=new wa(o,Kf);let p=this.runWebGLProgram(d,[{dataId:e,shape:o,dtype:s}],s),h=this.readSync(p.dataId);return this.disposeIntermediateTensorInfo(p),h}if(n!=null)return this.convertAndCacheOnCPU(e);if(s==="string")return n;let l=this.activeTimers!=null,u;l&&(u=w.now());let c;if(s==="complex64"){let d=this.readSync(r.real.dataId),p=this.readSync(r.imag.dataId);c=_.mergeRealAndImagArrays(d,p)}else c=this.getValuesFromTexture(e);return l&&(this.downloadWaitMs+=w.now()-u),this.convertAndCacheOnCPU(e,c)}async read(e){if(this.pendingRead.has(e)){let h=this.pendingRead.get(e);return new Promise(f=>h.push(f))}let t=this.texData.get(e),{values:n,shape:s,slice:r,dtype:a,complexTensorInfos:o,isPacked:i}=t;if(r!=null){let h;i?h=new bu(s,Kf):h=new wa(s,Kf);let f=this.runWebGLProgram(h,[{dataId:e,shape:s,dtype:a}],a),m=this.read(f.dataId);return this.disposeIntermediateTensorInfo(f),m}if(n!=null)return this.convertAndCacheOnCPU(e);if(!Y().getBool("WEBGL_DOWNLOAD_FLOAT_ENABLED")&&Y().getNumber("WEBGL_VERSION")===2)throw new Error("tensor.data() with WEBGL_DOWNLOAD_FLOAT_ENABLED=false and WEBGL_VERSION=2 not yet supported.");let l=null,u;if(a!=="complex64"&&Y().get("WEBGL_BUFFER_SUPPORTED")){u=this.decode(e);let h=this.texData.get(u.dataId);l=this.gpgpu.createBufferFromTexture(h.texture,...Bf(s))}this.pendingRead.set(e,[]),a!=="complex64"&&await this.gpgpu.createAndWaitForFence();let c;if(a==="complex64"){let h=await Promise.all([this.read(o.real.dataId),this.read(o.imag.dataId)]),f=h[0],m=h[1];c=_.mergeRealAndImagArrays(f,m)}else if(l==null)c=this.getValuesFromTexture(e);else{let h=w.sizeFromShape(s);c=this.gpgpu.downloadFloat32MatrixFromBuffer(l,h)}if(u!=null&&this.disposeIntermediateTensorInfo(u),l!=null){let h=this.gpgpu.gl;ke(h,()=>h.deleteBuffer(l))}let d=this.convertAndCacheOnCPU(e,c),p=this.pendingRead.get(e);return this.pendingRead.delete(e),p.forEach(h=>h(d)),this.pendingDisposal.has(e)&&(this.pendingDisposal.delete(e),this.disposeData(e)&&Qn().removeDataId(e,this),this.pendingDeletes--),d}bufferSync(e){let t=this.readSync(e.dataId),n=t;if(e.dtype==="string")try{n=t.map(s=>w.decodeString(s))}catch(s){throw new Error("Failed to decode encoded string bytes into utf-8")}return je(e.shape,e.dtype,n)}checkNumericalProblems(e){if(e!=null)for(let t=0;t<e.length;t++){let n=e[t];if(!i6(n))throw Y().getBool("WEBGL_RENDER_FLOAT32_CAPABLE")?Error(`The value ${n} cannot be represented with your current settings. Consider enabling float32 rendering: 'tf.env().set('WEBGL_RENDER_FLOAT32_ENABLED', true);'`):Error(`The value ${n} cannot be represented on this device.`)}}getValuesFromTexture(e){let{shape:t,dtype:n,isPacked:s}=this.texData.get(e),r=w.sizeFromShape(t);if(Y().getBool("WEBGL_DOWNLOAD_FLOAT_ENABLED")){let d=this.decode(e),p=this.texData.get(d.dataId),h=this.gpgpu.downloadMatrixFromPackedTexture(p.texture,...Bf(t)).subarray(0,r);return this.disposeIntermediateTensorInfo(d),h}let a=Y().getBool("WEBGL_PACK")&&s===!0,o=a?Uf(t):t,i=a?new rX(o):new sX(o),l=this.runWebGLProgram(i,[{shape:o,dtype:n,dataId:e}],"float32"),u=this.texData.get(l.dataId),c=this.gpgpu.downloadByteEncodedFloatMatrixFromOutputTexture(u.texture,u.texShape[0],u.texShape[1]).subarray(0,r);return this.disposeIntermediateTensorInfo(l),c}timerAvailable(){return Y().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE")>0}async time(e){let t=this.activeTimers,n=[],s=!1;this.programTimersStack==null?(this.programTimersStack=n,s=!0):this.activeTimers.push(n),this.activeTimers=n,e();let r=w.flatten(this.activeTimers.map(i=>i.query)).filter(i=>i!=null),a=w.flatten(this.activeTimers.map(i=>i.name)).filter(i=>i!=null);this.activeTimers=t,s&&(this.programTimersStack=null);let o={uploadWaitMs:this.uploadWaitMs,downloadWaitMs:this.downloadWaitMs,kernelMs:null,wallMs:null};if(Y().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE")>0){let i=await Promise.all(r);o.kernelMs=w.sum(i),o.getExtraProfileInfo=()=>i.map((l,u)=>({name:a[u],ms:l})).map(l=>`${l.name}: ${l.ms}`).join(", ")}else o.kernelMs={error:"WebGL query timers are not supported in this environment."};return this.uploadWaitMs=0,this.downloadWaitMs=0,o}memory(){return{unreliable:!1,numBytesInGPU:this.numBytesInGPU,numBytesInGPUAllocated:this.textureManager.numBytesAllocated,numBytesInGPUFree:this.textureManager.numBytesFree}}startTimer(){return Y().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE")>0?this.gpgpu.beginQuery():{startMs:w.now(),endMs:null}}endTimer(e){return Y().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE")>0?(this.gpgpu.endQuery(),e):(e.endMs=w.now(),e)}async getQueryTime(e){if(Y().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE")>0)return this.gpgpu.waitForQueryAndGetTime(e);let 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);let{complexTensorInfos:n}=this.texData.get(e);return n!=null&&(this.disposeData(n.real.dataId,t),this.disposeData(n.imag.dataId,t)),this.texData.delete(e),!0}releaseGPUData(e){let{texture:t,dtype:n,texShape:s,usage:r,isPacked:a,slice:o}=this.texData.get(e),i=o&&o.origDataId||e,l=this.dataRefCount.get(i);l>1?this.dataRefCount.set(i,l-1):(this.dataRefCount.delete(i),t!=null&&(this.numBytesInGPU-=this.computeBytes(s,n),this.textureManager.releaseTexture(t,s,r,a)));let u=this.texData.get(e);u.texture=null,u.texShape=null,u.isPacked=!1,u.slice=null}getTexture(e){return this.uploadToGPU(e),this.texData.get(e).texture}getDataInfo(e){return this.texData.get(e)}shouldExecuteOnCPU(e,t=yK){return Y().getBool("WEBGL_CPU_FORWARD")&&e.every(n=>this.texData.get(n.dataId).texture==null&&w.sizeFromShape(n.shape)<t)}getGPGPUContext(){return this.gpgpu}where(e){_.warn("tf.where() in webgl locks the UI thread. Call tf.whereAsync() instead");let t=e.dataSync();return fK(e.shape,t)}packedUnaryOp(e,t,n){let s=new bu(e.shape,t),r=this.compileAndRun(s,[e],n);return Qn().makeTensorFromDataId(r.dataId,r.shape,r.dtype)}abs(e){if(this.shouldExecuteOnCPU([e])&&e.dtype!=="complex64"){let s=e4(this.texData.get(e.dataId).values);return this.makeOutput(e.shape,e.dtype,s)}if(Y().getBool("WEBGL_PACK_UNARY_OPERATIONS"))return this.packedUnaryOp(e,i4,e.dtype);let t=new wa(e.shape,i4),n=this.compileAndRun(t,[e]);return Qn().makeTensorFromDataId(n.dataId,n.shape,n.dtype)}makeTensorInfo(e,t,n){let s;if(t==="string"&&n!=null&&n.length>0&&w.isString(n[0])){let r=n.map(a=>w.encodeString(a));s=this.write(r,e,t)}else s=this.write(n,e,t);return this.texData.get(s).usage=null,{dataId:s,shape:e,dtype:t}}makeOutput(e,t,n){let{dataId:s}=this.makeTensorInfo(e,t,n);return Qn().makeTensorFromDataId(s,e,t,this)}unpackTensor(e){let t=new hK(e.shape);return this.runWebGLProgram(t,[e],e.dtype)}packTensor(e){let t=new qX(e.shape),n=!0;return this.runWebGLProgram(t,[e],e.dtype,null,n)}packedReshape(e,t){let n=[li(e.shape),...ui(e.shape)],s={dtype:e.dtype,shape:n,dataId:e.dataId},r=[li(t),...ui(t)],a=new s4(r,n),o=!0,i=[n],l=this.runWebGLProgram(a,[s],e.dtype,i,o);return{dataId:l.dataId,shape:t,dtype:l.dtype}}decode(e){let t=this.texData.get(e),{isPacked:n,shape:s,dtype:r}=t,a=Uf(s),o,i=Bf(a);n?o=new nX(a):o=new tX(a);let l=!0,u=[i],c=this.runWebGLProgram(o,[{shape:a,dtype:r,dataId:e}],r,u,l);return{dtype:r,shape:s,dataId:c.dataId}}runWebGLProgram(e,t,n,s,r=!1){let a=this.makeTensorInfo(e.outputShape,n),o=this.texData.get(a.dataId);if(e.packedOutput&&(o.isPacked=!0),e.outPackingScheme===pd.DENSE){let m=Bf(e.outputShape);o.texShape=m.map(g=>g*2)}if(e.outTexUsage!=null&&(o.usage=e.outTexUsage),w.sizeFromShape(a.shape)===0)return o.values=w.getTypedArrayFromDType(a.dtype,0),a;let i=[],l=t.map(m=>{if(m.dtype==="complex64")throw new Error("GPGPUProgram does not support complex64 input. For complex64 dtypes, please separate the program into real and imaginary parts.");let g=this.texData.get(m.dataId);if(g.texture==null){if(!e.packedInputs&&w.sizeFromShape(m.shape)<=Y().getNumber("WEBGL_SIZE_UPLOAD_UNIFORM"))return{shape:m.shape,texData:null,isUniform:!0,uniformValues:g.values};e.packedInputs&&(g.isPacked=!0,g.shape=m.shape)}else if(!!g.isPacked!=!!e.packedInputs)m=g.isPacked?this.unpackTensor(m):this.packTensor(m),i.push(m),g=this.texData.get(m.dataId);else if(g.isPacked&&!gd(g.shape,m.shape)){let A=m,y=m.shape;m.shape=g.shape,m=this.packedReshape(m,y),i.push(m),g=this.texData.get(m.dataId),A.shape=y}return this.uploadToGPU(m.dataId),{shape:m.shape,texData:g,isUniform:!1}});this.uploadToGPU(a.dataId);let u={shape:a.shape,texData:o,isUniform:!1},c=eX(e,l,u),d=this.getAndSaveBinary(c,()=>Jq(this.gpgpu,e,l,u)),p=this.activeTimers!=null,h;p&&(h=this.startTimer()),Qq(this.gpgpu,d,l,u,s),i.forEach(m=>this.disposeIntermediateTensorInfo(m)),p&&(h=this.endTimer(h),this.activeTimers.push({name:e.constructor.name,query:this.getQueryTime(h)}));let f=Y().get("WEBGL_FLUSH_THRESHOLD");if(f>0){let m=w.now();m-this.lastGlFlushTime>f&&(this.gpgpu.gl.flush(),this.lastGlFlushTime=m)}if(!Y().getBool("WEBGL_LAZILY_UNPACK")&&o.isPacked&&r===!1){let m=this.unpackTensor(a);return this.disposeIntermediateTensorInfo(a),m}return a}compileAndRun(e,t,n,s,r=!1){return n=n||t[0].dtype,this.runWebGLProgram(e,t,n,s,r)}getAndSaveBinary(e,t){return e in this.binaryCache||(this.binaryCache[e]=t()),this.binaryCache[e]}getTextureManager(){return this.textureManager}dispose(){this.disposed||(Y().getBool("IS_TEST")||Object.keys(this.binaryCache).forEach(t=>{this.gpgpu.deleteProgram(this.binaryCache[t].webGLProgram),delete this.binaryCache[t]}),this.textureManager.dispose(),this.canvas!=null&&typeof HTMLCanvasElement!="undefined"&&this.canvas instanceof HTMLCanvasElement?this.canvas.remove():this.canvas=null,this.gpgpuCreatedLocally&&(this.gpgpu.program=null,this.gpgpu.dispose()),this.disposed=!0)}floatPrecision(){return this.floatPrecisionValue==null&&(this.floatPrecisionValue=H(()=>{if(!Y().get("WEBGL_RENDER_FLOAT32_ENABLED")){let e=Y().getBool("DEBUG");Y().set("DEBUG",!1);let t=this.abs(Ce(1e-8)).dataSync()[0];if(Y().set("DEBUG",e),t>0)return 32}return 16})),this.floatPrecisionValue}epsilon(){return this.floatPrecision()===32?mK:gK}uploadToGPU(e){let t=this.texData.get(e),{shape:n,dtype:s,values:r,texture:a,usage:o,isPacked:i}=t;if(a!=null)return;let l=this.activeTimers!=null,u;l&&(u=w.now());let c=t.texShape;if(c==null&&(c=I6(n,i),t.texShape=c),r!=null){let d=Uf(n),p,h=c[1],f=c[0],m=r instanceof Uint8Array;i?([h,f]=fu(c[0],c[1]),p=new oX(d,m)):p=new aX(d,m);let g=this.makeTensorInfo([f,h],s);m?this.texData.get(g.dataId).usage=ks.PIXELS:this.texData.get(g.dataId).usage=ks.UPLOAD,this.gpgpu.uploadDenseMatrixToTexture(this.getTexture(g.dataId),h,f,r);let A=[[f,h]],y=!0,x=this.runWebGLProgram(p,[g],s,A,y),b=this.texData.get(x.dataId);t.texture=b.texture,t.texShape=b.texShape,t.isPacked=b.isPacked,t.usage=b.usage,this.disposeIntermediateTensorInfo(g),this.texData.delete(x.dataId),t.values=null,l&&(this.uploadWaitMs+=w.now()-u)}else{let d=this.acquireTexture(c,o,s,i);t.texture=d}}convertAndCacheOnCPU(e,t){let n=this.texData.get(e),{dtype:s}=n;return this.releaseGPUData(e),t!=null&&(n.values=vK(t,s)),n.values}acquireTexture(e,t,n,s){if(this.numBytesInGPU+=this.computeBytes(e,n),!this.warnedAboutMemory&&this.numBytesInGPU>this.numMBBeforeWarning*1024*1024){let r=(this.numBytesInGPU/1024/1024).toFixed(2);this.warnedAboutMemory=!0,console.warn(`High memory usage in GPU: ${r} MB, most likely due to a memory leak`)}return this.textureManager.acquireTexture(e,t,s)}computeBytes(e,t){return e[0]*e[1]*w.bytesPerElement(t)}};vu.nextDataId=0;function vK(e,t){if(t==="float32"||t==="complex64")return e;if(t==="int32"||t==="bool"){let n=t==="int32"?new Int32Array(e.length):new Uint8Array(e.length);for(let s=0;s<n.length;++s)n[s]=Math.round(e[s]);return n}else throw new Error(`Unknown dtype ${t}`)}var wK="3.9.0";function l4(){Y().set("WEBGL_FORCE_F16_TEXTURES",!0)}xc.isBrowser()&&Vl("webgl",()=>new vu,2);var kK={forceHalfFloat:l4},u4=`
|
|
if (isnan(a)) return a;
|
|
if (isnan(b)) return b;
|
|
`,wu=class{constructor(e,t,n){this.variableNames=["A","B"],this.outputShape=_.assertAndGetBroadcastShape(t,n),this.enableShapeUniforms=Ss(this.outputShape.length),this.userCode=`
|
|
float binaryOperation(float a, float b) {
|
|
${e}
|
|
}
|
|
|
|
void main() {
|
|
float a = getAAtOutCoords();
|
|
float b = getBAtOutCoords();
|
|
setOutput(binaryOperation(a, b));
|
|
}
|
|
`}},Yf=`
|
|
result.r = isNaN.r > 0. ? NAN : result.r;
|
|
result.g = isNaN.g > 0. ? NAN : result.g;
|
|
result.b = isNaN.b > 0. ? NAN : result.b;
|
|
result.a = isNaN.a > 0. ? NAN : result.a;
|
|
`,yd=class{constructor(e,t,n,s=!1){this.variableNames=["A","B"],this.supportsBroadcasting=!0,this.packedInputs=!0,this.packedOutput=!0,this.outputShape=_.assertAndGetBroadcastShape(t,n);let r=this.outputShape.length;this.enableShapeUniforms=Ss(r);let a="";if(s)if(r===0||w.sizeFromShape(this.outputShape)===1)a=`
|
|
result.y = 0.;
|
|
result.z = 0.;
|
|
result.w = 0.;
|
|
`;else if(a=`
|
|
${gt(r)} coords = getOutputCoords();
|
|
`,r===1)this.enableShapeUniforms?a+=`
|
|
result.y = (coords + 1) >= outShape ? 0. : result.y;
|
|
result.z = 0.;
|
|
result.w = 0.;
|
|
`:a+=`
|
|
result.y = (coords + 1) >= ${this.outputShape[0]} ? 0. : result.y;
|
|
result.z = 0.;
|
|
result.w = 0.;
|
|
`;else{let i=Rn("coords",r);this.enableShapeUniforms?a+=`
|
|
bool nextRowOutOfBounds =
|
|
(${i[r-2]} + 1) >= outShape[${r} - 2];
|
|
bool nextColOutOfBounds =
|
|
(${i[r-1]} + 1) >= outShape[${r} - 1];
|
|
result.y = nextColOutOfBounds ? 0. : result.y;
|
|
result.z = nextRowOutOfBounds ? 0. : result.z;
|
|
result.w = nextColOutOfBounds || nextRowOutOfBounds ? 0. : result.w;
|
|
`:a+=`
|
|
bool nextRowOutOfBounds =
|
|
(${i[r-2]} + 1) >= ${this.outputShape[r-2]};
|
|
bool nextColOutOfBounds =
|
|
(${i[r-1]} + 1) >= ${this.outputShape[r-1]};
|
|
result.y = nextColOutOfBounds ? 0. : result.y;
|
|
result.z = nextRowOutOfBounds ? 0. : result.z;
|
|
result.w = nextColOutOfBounds || nextRowOutOfBounds ? 0. : result.w;
|
|
`}this.userCode=`
|
|
vec4 binaryOperation(vec4 a, vec4 b) {
|
|
${e}
|
|
}
|
|
|
|
void main() {
|
|
vec4 a = getAAtOutCoords();
|
|
vec4 b = getBAtOutCoords();
|
|
|
|
vec4 result = binaryOperation(a, b);
|
|
${a}
|
|
|
|
setOutput(result);
|
|
}
|
|
`}};function ds(e){let{inputs:t,backend:n}=e,{x:s}=t;return n.incRef(s.dataId),{dataId:s.dataId,shape:s.shape,dtype:s.dtype}}var IK={kernelName:Qa,backendName:"webgl",kernelFunc:ds};function ka(e){let{inputs:t,backend:n}=e,{real:s,imag:r}=t,a=n.makeTensorInfo(s.shape,"complex64"),o=n.texData.get(a.dataId),i=ds({inputs:{x:s},backend:n}),l=ds({inputs:{x:r},backend:n});return o.complexTensorInfos={real:i,imag:l},a}var SK={kernelName:Ap,backendName:"webgl",kernelFunc:ka},c4="return (a < 0.) ? b * a : a;",d4=`
|
|
vec4 aLessThanZero = vec4(lessThan(a, vec4(0.)));
|
|
return (aLessThanZero * (b * a)) + ((vec4(1.0) - aLessThanZero) * a);
|
|
`;function CK(e){let{inputs:t,backend:n,attrs:s}=e,{x:r}=t,{alpha:a}=s,o=n.makeTensorInfo([],"float32",w.createScalarValue(a,"float32")),i=Y().getBool("WEBGL_PACK_BINARY_OPERATIONS")?new yd(d4,r.shape,o.shape):new wu(c4,r.shape,o.shape),l=n.runWebGLProgram(i,[r,o],r.dtype);return n.disposeIntermediateTensorInfo(o),l}var TK={kernelName:eo,backendName:"webgl",kernelFunc:CK},p4="return (a < 0.) ? b * a : a;",h4=`
|
|
vec4 aLessThanZero = vec4(lessThan(a, vec4(0.)));
|
|
return (aLessThanZero * (b * a)) + ((vec4(1.0) - aLessThanZero) * a);
|
|
`;function NK(e){let{inputs:t,backend:n}=e,{x:s,alpha:r}=t,a=Y().getBool("WEBGL_PACK_BINARY_OPERATIONS")?new yd(h4,s.shape,r.shape):new wu(p4,s.shape,r.shape);return n.runWebGLProgram(a,[s,r],s.dtype)}var EK={kernelName:fo,backendName:"webgl",kernelFunc:NK},f4="if (isnan(x)) return x;",RK=`
|
|
if (isnan(a)) return a;
|
|
if (isnan(b)) return b;
|
|
`,DK=`
|
|
result.r = isNaN.r > 0. ? NAN : result.r;
|
|
result.g = isNaN.g > 0. ? NAN : result.g;
|
|
result.b = isNaN.b > 0. ? NAN : result.b;
|
|
result.a = isNaN.a > 0. ? NAN : result.a;
|
|
`;function tt({opSnippet:e,packedOpSnippet:t,cpuKernelImpl:n,dtype:s}){return({inputs:r,backend:a})=>{let{x:o}=r,i=a,l=s||o.dtype;if(i.shouldExecuteOnCPU([o])&&n!=null){let d=i.texData.get(o.dataId),p=n(d.values,l);return i.makeTensorInfo(o.shape,l,p)}let u=Y().getBool("WEBGL_PACK_UNARY_OPERATIONS")&&t!=null,c;return u?c=new bu(o.shape,t):c=new wa(o.shape,e),i.runWebGLProgram(c,[o],l)}}function An({opSnippet:e,packedOpSnippet:t,checkOutOfBounds:n=!1,supportsComplex:s=!1,cpuKernelImpl:r,dtype:a}){return({inputs:o,backend:i})=>{let{a:l,b:u}=o,c=i;if(s&&l.dtype==="complex64"){let f=c.texData.get(l.dataId),m=c.texData.get(u.dataId),[g,A]=[[f.complexTensorInfos.real,m.complexTensorInfos.real],[f.complexTensorInfos.imag,m.complexTensorInfos.imag]].map(x=>{let[b,v]=x,k={dataId:b.dataId,dtype:b.dtype,shape:l.shape},S={dataId:v.dataId,dtype:v.dtype,shape:u.shape},C=new wu(e,l.shape,u.shape);return c.runWebGLProgram(C,[k,S],Ds(b.dtype,v.dtype))}),y=ka({inputs:{real:g,imag:A},backend:c});return c.disposeIntermediateTensorInfo(g),c.disposeIntermediateTensorInfo(A),y}let d=a||Ds(l.dtype,u.dtype);if((l.dtype==="string"||u.dtype==="string"||c.shouldExecuteOnCPU([l,u]))&&r!=null){let f=c.texData.get(l.dataId).values,m=c.texData.get(u.dataId).values,g=l.dtype==="string"?_.fromUint8ToStringArray(f):f,A=l.dtype==="string"?_.fromUint8ToStringArray(m):m,[y,x]=r(l.shape,u.shape,g,A,d),b=c.makeTensorInfo(x,d),v=c.texData.get(b.dataId);return v.values=y,b}let p=Y().getBool("WEBGL_PACK_BINARY_OPERATIONS")&&t!=null,h;return p?h=new yd(t,l.shape,u.shape,n):h=new wu(e,l.shape,u.shape),c.runWebGLProgram(h,[l,u],d)}}function Jf(e,t=!1){if(e==="linear")return t?lK:sK;if(e==="relu")return t?cK:aK;if(e==="elu")return t?uK:rK;if(e==="relu6")return t?dK:oK;if(e==="prelu")return t?h4:p4;if(e==="leakyrelu")return t?d4:c4;if(e==="sigmoid")return t?pK:iK;throw new Error(`Activation ${e} has not been implemented for the WebGL backend.`)}var m4=class{constructor(e,t,n,s=!1,r=!1,a=!1,o=null,i=!1,l=!1){this.variableNames=["matrixA","matrixB"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=n,this.enableShapeUniforms=Ss(this.outputShape.length);let u=s?e[1]:e[2],c=Math.ceil(u/2),d=s?"i * 2, rc.y":"rc.y, i * 2",p=r?"rc.z, i * 2":"i * 2, rc.z",h=s?["a.xxyy","a.zzww"]:["a.xxzz","a.yyww"],f=r?["b.xzxz","b.ywyw"]:["b.xyxy","b.zwzw"],m="",g="";o&&(i?m=`vec4 activation(vec4 a) {
|
|
vec4 b = getPreluActivationWeightsAtOutCoords();
|
|
${o}
|
|
}`:l?m=`vec4 activation(vec4 a) {
|
|
vec4 b = getLeakyreluAlphaAtOutCoords();
|
|
${o}
|
|
}`:m=`vec4 activation(vec4 x) {
|
|
${o}
|
|
}`,g="result = activation(result);");let A=a?"result += getBiasAtOutCoords();":"";a&&this.variableNames.push("bias"),i&&this.variableNames.push("preluActivationWeights"),l&&this.variableNames.push("leakyreluAlpha");let y="rc.x",x="rc.x";e[0]<t[0]?y=`int(min(float(rc.x), ${e[0]-1}.))`:t[0]<e[0]&&(x=`int(min(float(rc.x), ${t[0]-1}.))`),this.userCode=`
|
|
${m}
|
|
// Don't use uniform for sharedDimensionPacked for performance.
|
|
const float sharedDimension = ${c}.0;
|
|
|
|
vec4 dot2x2ARowBCol(ivec3 rc) {
|
|
vec4 result = vec4(0);
|
|
for (int i = 0; i < ${c}; i++) {
|
|
int batchA = ${y};
|
|
int batchB = ${x};
|
|
vec4 a = getMatrixA(batchA, ${d});
|
|
vec4 b = getMatrixB(batchB, ${p});
|
|
|
|
// These swizzled products need to be separately added.
|
|
// See: https://github.com/tensorflow/tfjs/issues/1735
|
|
result += (${h[0]} * ${f[0]});
|
|
result += (${h[1]} * ${f[1]});
|
|
}
|
|
return result;
|
|
}
|
|
|
|
void main() {
|
|
ivec3 rc = getOutputCoords();
|
|
vec4 result = dot2x2ARowBCol(rc);
|
|
|
|
${A}
|
|
|
|
${g}
|
|
|
|
setOutput(result);
|
|
}
|
|
`}},g4={REAL:"return areal * breal - aimag * bimag;",IMAG:"return areal * bimag + aimag * breal;"},A4=class{constructor(e,t,n){this.variableNames=["AReal","AImag","BReal","BImag"],this.outputShape=_.assertAndGetBroadcastShape(t,n),this.userCode=`
|
|
float binaryOpComplex(
|
|
float areal, float aimag, float breal, float bimag) {
|
|
${e}
|
|
}
|
|
|
|
void main() {
|
|
float areal = getARealAtOutCoords();
|
|
float aimag = getAImagAtOutCoords();
|
|
float breal = getBRealAtOutCoords();
|
|
float bimag = getBImagAtOutCoords();
|
|
setOutput(binaryOpComplex(areal, aimag, breal, bimag));
|
|
}
|
|
`}},y4="return a * b;";function yy(e){let{inputs:t,backend:n}=e,{a:s,b:r}=t,a=_.upcastType(s.dtype,r.dtype);if(s.dtype==="complex64"){let i=n.texData.get(s.dataId),l=n.texData.get(r.dataId),u=new A4(g4.REAL,s.shape,r.shape),c=new A4(g4.IMAG,s.shape,r.shape),d=[{dataId:i.complexTensorInfos.real.dataId,dtype:i.complexTensorInfos.real.dtype,shape:s.shape},{dataId:i.complexTensorInfos.imag.dataId,dtype:i.complexTensorInfos.imag.dtype,shape:s.shape},{dataId:l.complexTensorInfos.real.dataId,dtype:l.complexTensorInfos.real.dtype,shape:r.shape},{dataId:l.complexTensorInfos.imag.dataId,dtype:l.complexTensorInfos.imag.dtype,shape:r.shape}],p=n.runWebGLProgram(u,d,"float32"),h=n.runWebGLProgram(c,d,"float32"),f=ka({inputs:{real:p,imag:h},backend:n});return n.disposeIntermediateTensorInfo(p),n.disposeIntermediateTensorInfo(h),f}if(n.shouldExecuteOnCPU([s,r])){let i=n.texData.get(s.dataId),l=n.texData.get(r.dataId),[u,c]=TX(s.shape,r.shape,i.values,l.values,a),d=n.makeTensorInfo(c,a),p=n.texData.get(d.dataId);return p.values=u,d}let o;return Y().getBool("WEBGL_PACK_BINARY_OPERATIONS")?o=new yd(y4,s.shape,r.shape):o=new wu(y4,s.shape,r.shape),n.runWebGLProgram(o,[s,r],a)}var _K={kernelName:uo,backendName:"webgl",kernelFunc:yy};function $K(e,t,n){let s=[li(e.shape),...ui(e.shape)],r={dtype:e.dtype,shape:s,dataId:e.dataId},a=[li(t),...ui(t)],o=new s4(a,s),i=!0,l=[s],u=n.runWebGLProgram(o,[r],e.dtype,l,i);return{dataId:u.dataId,shape:t,dtype:u.dtype}}function be(e){let{inputs:t,backend:n,attrs:s}=e,{x:r}=t,{shape:a}=s,o=n,i=w.sizeFromShape(r.shape),l=w.inferFromImplicitShape(a,i),u=w.sizeFromShape(l);w.assert(i===u,()=>`The new shape (${l}) has ${u} elements and the old shape (${r.shape}) has ${i} elements. The new shape and old shape must have the same number of elements.`);let c=o.texData.get(r.dataId);return c.isPacked&&!gd(r.shape,l)&&!(c.texture!==null&&gd(c.shape,l))?$K(r,l,o):(o.incRef(r.dataId),{dataId:r.dataId,shape:l,dtype:r.dtype})}var FK={kernelName:xl,backendName:"webgl",kernelFunc:be},x4=class{constructor(e,t){this.variableNames=["x"];let{windowSize:n,batchSize:s,inSize:r,outSize:a}=e;this.outputShape=[s,a];let o=Math.floor(n/4)*4,i=n%4,l="sumValue += dot(values, ones);";if(t!=null){let c=1/t;l=`sumValue += dot(values * ${w.isInt(c)?c.toPrecision(2):c}, ones);`}let u="";r%n>0&&(u=`
|
|
if (inIdx < 0 || inIdx >= ${r}) {
|
|
return 0.0;
|
|
}
|
|
`),this.userCode=`
|
|
const vec4 ones = vec4(1.0, 1.0, 1.0, 1.0);
|
|
|
|
float getValue(int batch, int inIdx) {
|
|
${u}
|
|
return getX(batch, inIdx);
|
|
}
|
|
|
|
void main() {
|
|
ivec2 coords = getOutputCoords();
|
|
int batch = coords[0];
|
|
int outIdx = coords[1];
|
|
int inOffset = outIdx * ${n};
|
|
|
|
float sumValue = 0.0;
|
|
|
|
for (int i = 0; i < ${o}; i += 4) {
|
|
int inIdx = inOffset + i;
|
|
vec4 values = vec4(
|
|
getValue(batch, inIdx),
|
|
getValue(batch, inIdx + 1),
|
|
getValue(batch, inIdx + 2),
|
|
getValue(batch, inIdx + 3)
|
|
);
|
|
|
|
${l}
|
|
}
|
|
|
|
int inIdx = inOffset + ${o};
|
|
if (${i===1}) {
|
|
vec4 values = vec4(getValue(batch, inIdx), 0.0, 0.0, 0.0);
|
|
|
|
${l}
|
|
} else if (${i===2}) {
|
|
vec4 values = vec4(
|
|
getValue(batch, inIdx),
|
|
getValue(batch, inIdx + 1), 0.0, 0.0);
|
|
|
|
${l}
|
|
} else if (${i===3}) {
|
|
vec4 values = vec4(
|
|
getValue(batch, inIdx),
|
|
getValue(batch, inIdx + 1),
|
|
getValue(batch, inIdx + 2), 0.0);
|
|
|
|
${l}
|
|
}
|
|
setOutput(sumValue);
|
|
}
|
|
`}},OK=class{constructor(e,t){this.variableNames=["x"];let{windowSize:n,batchSize:s,inSize:r,outSize:a}=e;this.outputShape=[s,a];let o="0.0",i="";t==="prod"?o="1.0":t==="min"?(o="1.0 / 1e-20",i="min"):t==="max"&&(o="-1.0 / 1e-20",i="max");let l=`${t}(${t}(${t}(minMaxValue[0], minMaxValue[1]), minMaxValue[2]), minMaxValue[3])`;t==="sum"?l="sumValue":t==="prod"?l="prodValue":t==="all"?l="allValue":t==="any"&&(l="anyValue");let u=Math.floor(n/4)*4,c=n%4,d=`
|
|
if (${t==="sum"}) {
|
|
sumValue += dot(values, ones);
|
|
} else if (${t==="prod"}) {
|
|
vec2 tmp = vec2(values[0], values[1]) * vec2(values[2], values[3]);
|
|
prodValue *= tmp[0] * tmp[1];
|
|
} else {
|
|
minMaxValue = ${i}(values, minMaxValue);
|
|
if (${t==="min"} || ${t==="max"}) {
|
|
minMaxValue = ${i}(values, minMaxValue);
|
|
bvec4 isNaN = isnan(values);
|
|
if (isNaN.r || isNaN.g || isNaN.b || isNaN.a) {
|
|
minMaxValue = vec4(NAN);
|
|
}
|
|
}
|
|
}
|
|
`,p="vec4";t==="all"?(o="1.0",d=`
|
|
bool reducedAllValue = all(values);
|
|
float floatedReducedAllValue = float(reducedAllValue);
|
|
allValue = float(allValue >= 1.0 && floatedReducedAllValue >= 1.0);
|
|
`,p="bvec4"):t==="any"&&(o="0.0",d=`
|
|
bool reducedAnyValue = any(values);
|
|
float floatedReducedAnyValue = float(reducedAnyValue);
|
|
anyValue = float(anyValue >= 1.0 || floatedReducedAnyValue >= 1.0);
|
|
`,p="bvec4");let h="";r%n>0&&(h=`
|
|
if (inIdx < 0 || inIdx >= ${r}) {
|
|
return initializationValue;
|
|
}
|
|
`),this.userCode=`
|
|
const float initializationValue = ${o};
|
|
const vec4 ones = vec4(1.0, 1.0, 1.0, 1.0);
|
|
|
|
float getValue(int batch, int inIdx) {
|
|
${h}
|
|
return getX(batch, inIdx);
|
|
}
|
|
|
|
void main() {
|
|
ivec2 coords = getOutputCoords();
|
|
int batch = coords[0];
|
|
int outIdx = coords[1];
|
|
int inOffset = outIdx * ${n};
|
|
|
|
vec4 minMaxValue = vec4(${o});
|
|
float prodValue = 1.0;
|
|
float sumValue = 0.0;
|
|
float allValue = 1.0;
|
|
float anyValue = 0.0;
|
|
|
|
for (int i = 0; i < ${u}; i += 4) {
|
|
int inIdx = inOffset + i;
|
|
${p} values = ${p}(
|
|
getValue(batch, inIdx),
|
|
getValue(batch, inIdx + 1),
|
|
getValue(batch, inIdx + 2),
|
|
getValue(batch, inIdx + 3)
|
|
);
|
|
|
|
${d}
|
|
}
|
|
|
|
int inIdx = inOffset + ${u};
|
|
if (${c===1}) {
|
|
${p} values = ${p}(
|
|
getValue(batch, inIdx),
|
|
initializationValue,
|
|
initializationValue,
|
|
initializationValue
|
|
);
|
|
|
|
${d}
|
|
} else if (${c===2}) {
|
|
${p} values = ${p}(
|
|
getValue(batch, inIdx),
|
|
getValue(batch, inIdx + 1),
|
|
initializationValue,
|
|
initializationValue
|
|
);
|
|
|
|
${d}
|
|
} else if (${c===3}) {
|
|
${p} values = ${p}(
|
|
getValue(batch, inIdx),
|
|
getValue(batch, inIdx + 1),
|
|
getValue(batch, inIdx + 2),
|
|
initializationValue
|
|
);
|
|
|
|
${d}
|
|
}
|
|
setOutput(${l});
|
|
}
|
|
`}};function PK(e){let t=[];for(;t.length===0||t[t.length-1].outSize!==1;){let n=t.length?t[t.length-1].outSize:e[1],s=_.computeOptimalWindowSize(n);t.push({inSize:n,windowSize:s,outSize:Math.ceil(n/s)})}return t}function pi(e,t,n,s){let r=PK(e.shape),a=e;for(let o=0;o<r.length;o++){let{inSize:i,windowSize:l,outSize:u}=r[o],c,d;n==="mean"?c=o===0?new x4({windowSize:l,inSize:i,batchSize:e.shape[0],outSize:u},i):new x4({windowSize:l,inSize:i,batchSize:e.shape[0],outSize:u}):c=new OK({windowSize:l,inSize:i,batchSize:e.shape[0],outSize:u},n),d=a,a=s.runWebGLProgram(c,[a],t),d.dataId!==e.dataId&&s.disposeIntermediateTensorInfo(d)}return a}var MK=class{constructor(e,t){this.variableNames=["A"];let n=new Array(e.length);for(let a=0;a<n.length;a++)n[a]=e[t[a]];this.outputShape=n,this.rank=n.length;let s=gt(this.rank),r=zK(t);this.userCode=`
|
|
void main() {
|
|
${s} resRC = getOutputCoords();
|
|
setOutput(getA(${r}));
|
|
}
|
|
`}};function zK(e){let t=e.length;if(t>6)throw Error(`Transpose for rank ${t} is not yet supported`);let n=["resRC.x","resRC.y","resRC.z","resRC.w","resRC.u","resRC.v"],s=new Array(t);for(let r=0;r<e.length;r++)s[e[r]]=n[r];return s.join()}var LK=class{constructor(e,t){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0;let n=new Array(e.length);for(let u=0;u<n.length;u++)n[u]=e[t[u]];if(this.outputShape=n,this.rank=n.length,this.rank>6)throw Error(`Packed transpose for rank ${this.rank} is not yet supported.`);let s=gt(this.rank),r=n4("rc",this.rank),a=new Array(this.rank);for(let u=0;u<t.length;u++)a[t[u]]=r[u];let o=`vec2(${a.slice(-2).join()})`,i=`++${r[this.rank-1]} < ${n[this.rank-1]}`,l=`getChannel(getA(${a.join()}), ${o})`;this.userCode=`
|
|
void main() {
|
|
${s} rc = getOutputCoords();
|
|
vec4 result = vec4(0.);
|
|
result[0] = ${l};
|
|
if(${i}) {
|
|
result[1] = ${l};
|
|
}
|
|
--${r[this.rank-1]};
|
|
if(++${r[this.rank-2]} < ${n[this.rank-2]}) {
|
|
result[2] = ${l};
|
|
if(${i}) {
|
|
result[3] = ${l};
|
|
}
|
|
}
|
|
setOutput(result);
|
|
}
|
|
`}};function Qf(e,t,n){let s=Y().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new LK(e.shape,t):new MK(e.shape,t);return n.runWebGLProgram(s,[e],e.dtype)}function BK(e,t,n,s){let r=t,a=e.shape.length,o=w.parseAxisParam(r,e.shape),i=o,l=_.getAxesPermutation(i,a),u=l!=null,c=e;u&&(c=Qf(e,l,s),i=_.getInnerMostAxes(i.length,a)),_.assertAxesAreInnerMostDims("sum",i,a);let[d,p]=_.computeOutAndReduceShapes(c.shape,i),h=d;n&&(h=_.expandShapeToKeepDim(d,o));let f=w.sizeFromShape(p),g=w.sizeFromShape(e.shape)/f,A=be({inputs:{x:c},attrs:{shape:[g,f]},backend:s}),y=nh(e.dtype),x=pi(A,y,"sum",s),b=be({inputs:{x},attrs:{shape:h},backend:s});return s.disposeIntermediateTensorInfo(A),s.disposeIntermediateTensorInfo(x),u&&s.disposeIntermediateTensorInfo(c),b}function e0(e){let{inputs:t,backend:n,attrs:s}=e,{x:r}=t,{axis:a,keepDims:o}=s;return BK(r,a,o,n)}var WK={kernelName:Io,backendName:"webgl",kernelFunc:e0};function Dn(e){let{inputs:t,backend:n,attrs:s}=e,{x:r}=t,{perm:a}=s,o=n,i=r.shape.length,l=new Array(i);for(let c=0;c<l.length;c++)l[c]=r.shape[a[c]];let u;if(o.shouldExecuteOnCPU([r])){let d=o.texData.get(r.dataId).values,p=Ay(d,r.shape,r.dtype,a,l);u=o.makeTensorInfo(l,r.dtype);let h=o.texData.get(u.dataId);h.values=p}else u=Qf(r,a,o);return u}var VK={kernelName:Ro,backendName:"webgl",kernelFunc:Dn},b4=1e3;function t0({a:e,b:t,transposeA:n,transposeB:s,backend:r,bias:a=null,preluActivationWeights:o=null,leakyreluAlpha:i=0,activation:l=null}){let u=e.shape.length,c=t.shape.length,d=n?e.shape[u-2]:e.shape[u-1],p=s?t.shape[c-1]:t.shape[c-2],h=n?e.shape[u-1]:e.shape[u-2],f=s?t.shape[c-2]:t.shape[c-1],m=e.shape.slice(0,-2),g=t.shape.slice(0,-2),A=w.sizeFromShape(m),y=w.sizeFromShape(g),x=A===y||A===1||y===1;w.assert(u>=2&&c>=2&&x,()=>`Error in matMul: the input batch dimensions must either be the same or at least one input batch dimension must be 1. Got input batch dimensions of (${m}) and (${g}).`);let v=(A>y?e.shape.slice(0,-2):t.shape.slice(0,-2)).concat([h,f]);w.assert(d===p,()=>`Error in matMul: inner shapes (${d}) and (${p}) of Tensors with shapes ${e.shape} and ${t.shape} and transposeA=${n} and transposeB=${s} must match.`);let k=n?[A,d,h]:[A,h,d],S=s?[y,f,p]:[y,p,f],C=be({inputs:{x:e},backend:r,attrs:{shape:k}}),D=be({inputs:{x:t},backend:r,attrs:{shape:S}}),O=[C,D],E=Math.max(A,y),R=n?C.shape[1]:C.shape[2],T=a!=null,P=o!=null,U=l==="leakyrelu",j=l!=null?Jf(l,!0):null,q=T||P||U||j!=null,X;if((h===1||f===1)&&R>b4&&q===!1){let ne=C,se=D;n&&(ne=Dn({inputs:{x:C},backend:r,attrs:{perm:[0,2,1]}}),O.push(ne)),s&&(se=Dn({inputs:{x:D},backend:r,attrs:{perm:[0,2,1]}}),O.push(se));let re=f!==1,Q=f===1,ue=ne;re&&(ue=be({inputs:{x:ne},backend:r,attrs:{shape:[E,R,1]}}),O.push(ue));let ce=f===1?2:1,fe=se;Q&&(fe=be({inputs:{x:se},backend:r,attrs:{shape:[E,1,R]}}),O.push(fe));let xe=yy({inputs:{a:ue,b:fe},backend:r});X=e0({inputs:{x:xe},backend:r,attrs:{axis:ce,keepDims:!0}}),O.push(xe)}else{let ne=Ds(e.dtype,t.dtype),se=new m4(k,S,[E,h,f],n,s,T,j,P,U),re=[C,D];if(a!=null&&re.push(a),P&&re.push(o),U){let Q=r.makeTensorInfo([],"float32",w.createScalarValue(i,"float32"));re.push(Q),O.push(Q)}X=r.runWebGLProgram(se,re,ne)}let te=be({inputs:{x:X},backend:r,attrs:{shape:v}});O.push(X);for(let ne of O)r.disposeIntermediateTensorInfo(ne);return te}function UK(e){let{inputs:t,backend:n,attrs:s}=e,{a:r,b:a,bias:o,preluActivationWeights:i}=t,{transposeA:l,transposeB:u,activation:c,leakyreluAlpha:d}=s;return t0({a:r,b:a,transposeA:l,transposeB:u,backend:n,bias:o,preluActivationWeights:i,leakyreluAlpha:d,activation:c})}var HK={kernelName:Do,backendName:"webgl",kernelFunc:UK},v4="return abs(x);";function GK(e){let{inputs:t,backend:n}=e,{x:s}=t;if(n.shouldExecuteOnCPU([s])&&s.dtype!=="complex64"){let a=n.texData.get(s.dataId),o=e4(a.values);return n.makeTensorInfo(s.shape,s.dtype,o)}let r;return Y().getBool("WEBGL_PACK_UNARY_OPERATIONS")?r=new bu(s.shape,v4):r=new wa(s.shape,v4),n.runWebGLProgram(r,[s],s.dtype)}var jK={kernelName:Fi,backendName:"webgl",kernelFunc:GK},qK=Js+`
|
|
if (abs(x) > 1.) {
|
|
return NAN;
|
|
}
|
|
return acos(x);
|
|
`,XK=tt({opSnippet:qK}),KK={kernelName:Oi,backendName:"webgl",kernelFunc:XK},ZK=Js+`
|
|
if (x < 1.0) return NAN;
|
|
return log(x + sqrt(x * x - 1.0));`,YK=tt({opSnippet:ZK}),JK={kernelName:Pi,backendName:"webgl",kernelFunc:YK},w4="return a + b;",QK=An({opSnippet:w4,packedOpSnippet:w4,supportsComplex:!0,cpuKernelImpl:lX}),eZ={kernelName:Yr,backendName:"webgl",kernelFunc:QK},tZ=class{constructor(e,t){this.outputShape=[],this.outputShape=e,this.variableNames=t.map((r,a)=>`T${a}`);let n=[];this.variableNames.forEach(r=>{n.push(`float v${r} = get${r}AtOutCoords();`)});let s=this.variableNames.map(r=>`v${r}`).join(" + ");this.userCode=`
|
|
void main() {
|
|
${n.join(`
|
|
`)}
|
|
|
|
float result = ${s};
|
|
setOutput(result);
|
|
}
|
|
`}},nZ=class{constructor(e,t){this.outputShape=[],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=e,this.variableNames=t.map((r,a)=>`T${a}`);let n=[];this.variableNames.forEach(r=>{n.push(`vec4 v${r} = get${r}AtOutCoords();`)});let s=this.variableNames.map(r=>`v${r}`).join(" + ");this.userCode=`
|
|
void main() {
|
|
${n.join(`
|
|
`)}
|
|
|
|
vec4 result = ${s};
|
|
setOutput(result);
|
|
}
|
|
`}};function n0(e){let{inputs:t,backend:n}=e,s=t;if(s.length===1)return ds({inputs:{x:s[0]},backend:n});if(s.length>Y().get("WEBGL_MAX_TEXTURES_IN_SHADER")){let l=Math.floor(s.length/2),u=n0({inputs:s.slice(0,l),backend:n}),c=n0({inputs:s.slice(l),backend:n});return n0({inputs:[u,c],backend:n})}let r=s.map(l=>l.dtype).reduce((l,u)=>Ds(l,u)),a=s.map(l=>l.shape),i=Y().getBool("WEBGL_PACK")?new nZ(s[0].shape,a):new tZ(s[0].shape,a);return n.runWebGLProgram(i,s,r)}var sZ={kernelName:Fa,backendName:"webgl",kernelFunc:n0};function rZ(e){let{inputs:t,backend:n,attrs:s}=e,{x:r}=t,{axis:a,keepDims:o}=s,i=r.shape.length,l=w.parseAxisParam(a,r.shape),u=l,c=_.getAxesPermutation(u,i),d=r;c!=null&&(d=Dn({inputs:{x:r},backend:n,attrs:{perm:c}}),u=_.getInnerMostAxes(u.length,i)),_.assertAxesAreInnerMostDims("all",u,i);let[p,h]=_.computeOutAndReduceShapes(d.shape,u),f=w.sizeFromShape(h),m=be({inputs:{x:d},backend:n,attrs:{shape:[-1,f]}}),g=pi(m,m.dtype,"all",n),A;if(o){let y=_.expandShapeToKeepDim(p,l);A=be({inputs:{x:g},backend:n,attrs:{shape:y}})}else A=be({inputs:{x:g},backend:n,attrs:{shape:p}});return n.disposeIntermediateTensorInfo(m),n.disposeIntermediateTensorInfo(g),c!=null&&n.disposeIntermediateTensorInfo(d),A}var aZ={kernelName:Mi,backendName:"webgl",kernelFunc:rZ};function oZ(e){let{inputs:t,backend:n,attrs:s}=e,{x:r}=t,{axis:a,keepDims:o}=s,i=r.shape.length,l=w.parseAxisParam(a,r.shape),u=l,c=_.getAxesPermutation(u,i),d=r;c!=null&&(d=Dn({inputs:{x:r},backend:n,attrs:{perm:c}}),u=_.getInnerMostAxes(u.length,i)),_.assertAxesAreInnerMostDims("any",u,i);let[p,h]=_.computeOutAndReduceShapes(d.shape,u),f=w.sizeFromShape(h),m=be({inputs:{x:d},backend:n,attrs:{shape:[-1,f]}}),g=pi(m,m.dtype,"any",n),A;if(o){let y=_.expandShapeToKeepDim(p,l);A=be({inputs:{x:g},backend:n,attrs:{shape:y}})}else A=be({inputs:{x:g},backend:n,attrs:{shape:p}});return n.disposeIntermediateTensorInfo(m),n.disposeIntermediateTensorInfo(g),c!=null&&n.disposeIntermediateTensorInfo(d),A}var iZ={kernelName:zi,backendName:"webgl",kernelFunc:oZ},lZ=class{constructor(e,t,n){this.variableNames=["A"];let{windowSize:s,batchSize:r,outSize:a}=e;n||this.variableNames.push("bestIndicesA"),this.outputShape=[r,a];let o=t==="max"?">":"<",i=n?"inOffset + i;":"round(getBestIndicesA(batch, inOffset + i));";this.userCode=`
|
|
void main() {
|
|
ivec2 coords = getOutputCoords();
|
|
int batch = coords[0];
|
|
int outIdx = coords[1];
|
|
int inOffset = outIdx * ${s};
|
|
|
|
int bestIndex = inOffset;
|
|
float bestValue = getA(batch, bestIndex);
|
|
|
|
for (int i = 0; i < ${s}; i++) {
|
|
int inIdx = ${i};
|
|
float candidate = getA(batch, inIdx);
|
|
if (candidate ${o} bestValue) {
|
|
bestValue = candidate;
|
|
bestIndex = inIdx;
|
|
}
|
|
}
|
|
setOutput(float(bestIndex));
|
|
}
|
|
`}},uZ=class{constructor(e,t,n,s){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,w.assert(e.length>2,()=>`Packed arg${n.charAt(0).toUpperCase()+n.slice(1)} supports only inputs with rank above 2.`);let r=e[e.length-1],a=Math.ceil(r/t);this.outputShape=e.slice(0,-1),a>1&&this.outputShape.push(a),s||this.variableNames.push("bestIndicesA");let o=this.outputShape,i=o.length,l=gt(i),u=Rn("coords",i),c,d;if(a===1){d=i+1;let S=gt(d);c=`
|
|
${S} sourceLocR = ${S}(${u.join()}, 0);
|
|
++${u[i-1]};
|
|
${S} sourceLocG = ${S}(${u.join()}, 0);
|
|
++${u[i-2]};
|
|
${S} sourceLocA = ${S}(${u.join()}, 0);
|
|
--${u[i-1]};
|
|
${S} sourceLocB = ${S}(${u.join()}, 0);
|
|
--${u[i-2]};`}else d=i,c=`
|
|
${l} sourceLocR = coords;
|
|
++${u[i-1]};
|
|
${l} sourceLocG = coords;
|
|
++${u[i-2]};
|
|
${l} sourceLocA = coords;
|
|
--${u[i-1]};
|
|
${l} sourceLocB = coords;
|
|
--${u[i-2]};`;let p=["x","y","z","w","u","v"].slice(0,d),h="."+p[d-1],f=p.map(S=>"int "+S),m=Rn("sourceLocR",d-1).concat("inIdx.r"),g=Rn("sourceLocG",d-1).concat("inIdx.g"),A=Rn("sourceLocB",d-1).concat("inIdx.b"),y=Rn("sourceLocA",d-1).concat("inIdx.a"),x=n==="max"?"greaterThan":"lessThan",b=s?"":`
|
|
inIdx = round(vec4(getBestIndicesAChannel(${m.join()}),
|
|
getBestIndicesAChannel(${g.join()}),
|
|
getBestIndicesAChannel(${A.join()}),
|
|
getBestIndicesAChannel(${y.join()})));`,v=`vec4(
|
|
getAChannel(${m.join()}),
|
|
hasNextCol ? getAChannel(${g.join()}) : 0.,
|
|
hasNextRow ? getAChannel(${A.join()}) : 0.,
|
|
hasNextRow && hasNextCol ? getAChannel(${y.join()}) : 0.)`,k=s?"":`
|
|
float getBestIndicesAChannel(${f.join()}) {
|
|
return getChannel(getBestIndicesA(${p.join()}),
|
|
vec2(${p.slice(-2).join()}));
|
|
}`;this.userCode=`
|
|
float getAChannel(${f.join()}) {
|
|
return getChannel(getA(${p.join()}),
|
|
vec2(${p.slice(-2).join()}));
|
|
}
|
|
${k}
|
|
void main() {
|
|
${l} coords = getOutputCoords();
|
|
bool hasNextCol = ${u[i-1]} < ${o[i-1]-1};
|
|
bool hasNextRow = ${u[i-2]} < ${o[i-2]-1};
|
|
${c}
|
|
ivec4 srcIdx = ivec4(sourceLocR${h}, sourceLocG${h},
|
|
sourceLocB${h}, sourceLocA${h}) * ${t};
|
|
ivec4 inIdx = srcIdx;
|
|
vec4 bestIndex = vec4(inIdx);
|
|
vec4 bestValue = ${v};
|
|
|
|
for (int i = 0; i < ${t}; i++) {
|
|
inIdx = srcIdx;
|
|
${b}
|
|
vec4 candidate = ${v};
|
|
bvec4 nan = isnan(candidate);
|
|
bvec4 replace = bvec4(
|
|
vec4(${x}(candidate, bestValue)) * (vec4(1.0) - vec4(nan)));
|
|
|
|
bestValue = vec4(replace.x ? candidate.x : bestValue.x,
|
|
replace.y ? candidate.y : bestValue.y,
|
|
replace.z ? candidate.z : bestValue.z,
|
|
replace.w ? candidate.w : bestValue.w);
|
|
bestIndex = mix(bestIndex, vec4(inIdx), vec4(replace));
|
|
srcIdx++;
|
|
}
|
|
setOutput(bestIndex);
|
|
}
|
|
`}};function k4(e,t,n,s=null){let r=t.shape[0],a=t.shape[1];s!=null&&(r=s.shape[0],a=s.shape[1]);let o=_.computeOptimalWindowSize(a),i={windowSize:o,inSize:a,batchSize:r,outSize:Math.ceil(a/o)},l=new lZ(i,n,s==null),u=[t];s!=null&&u.push(s);let c=e.runWebGLProgram(l,u,"int32");if(c.shape[1]===1)return c;let d=k4(e,t,n,c);return e.disposeIntermediateTensorInfo(c),d}function I4(e,t,n,s=null){let r=s!=null?s.shape:t.shape,a=r[r.length-1],o=_.computeOptimalWindowSize(a),i=new uZ(r,o,n,s==null),l=s==null?[t]:[t,s],u=e.runWebGLProgram(i,l,"int32");if(u.shape.length===t.shape.length){let c=I4(e,t,n,u);return e.disposeIntermediateTensorInfo(u),c}return u}function S4(e,t,n,s){let r=[n];if(_.assertAxesAreInnerMostDims("arg"+s.charAt(0).toUpperCase()+s.slice(1),r,t.shape.length),!Y().getBool("WEBGL_PACK_REDUCE")||t.shape.length<=2){let a=[],o=e.texData.get(t.dataId),i=o!==null&&o.isPacked,l=t;i&&(l=e.unpackTensor(t),a.push(l));let[u,c]=_.computeOutAndReduceShapes(l.shape,r),d=w.sizeFromShape(c),p=be({inputs:{x:l},backend:e,attrs:{shape:[-1,d]}});a.push(p);let h=k4(e,p,s);a.push(h);let f=be({inputs:{x:h},backend:e,attrs:{shape:u}});return a.forEach(m=>e.disposeIntermediateTensorInfo(m)),f}return I4(e,t,s)}function cZ(e){let{inputs:t,backend:n,attrs:s}=e,{x:r}=t,{axis:a}=s,o=w.parseAxisParam(a,r.shape),i=_.getAxesPermutation(o,r.shape.length),l=r,u=[];i!=null&&(l=Dn({inputs:{x:r},backend:n,attrs:{perm:i}}),u.push(l),o=_.getInnerMostAxes(o.length,l.shape.length)),_.assertAxesAreInnerMostDims("argMax",[o[0]],l.shape.length);let c=S4(n,l,o[0],"max");return u.forEach(d=>n.disposeIntermediateTensorInfo(d)),c}var dZ={kernelName:Oa,backendName:"webgl",kernelFunc:cZ};function pZ(e){let{inputs:t,backend:n,attrs:s}=e,{x:r}=t,{axis:a}=s,o=w.parseAxisParam(a,r.shape),i=_.getAxesPermutation(o,r.shape.length),l=r,u=[];i!=null&&(l=Dn({inputs:{x:r},backend:n,attrs:{perm:i}}),u.push(l),o=_.getInnerMostAxes(o.length,l.shape.length)),_.assertAxesAreInnerMostDims("argMin",[o[0]],l.shape.length);let c=S4(n,l,o[0],"min");return u.forEach(d=>n.disposeIntermediateTensorInfo(d)),c}var hZ={kernelName:Zu,backendName:"webgl",kernelFunc:pZ},fZ=Js+`
|
|
if (abs(x) > 1.) {
|
|
return NAN;
|
|
}
|
|
return asin(x);
|
|
`,mZ=tt({opSnippet:fZ}),gZ={kernelName:Li,backendName:"webgl",kernelFunc:mZ},AZ=Js+"return log(x + sqrt(x * x + 1.0));",yZ=tt({opSnippet:AZ}),xZ={kernelName:Bi,backendName:"webgl",kernelFunc:yZ},bZ=Js+`
|
|
return atan(x);
|
|
`,vZ=tt({opSnippet:bZ}),wZ={kernelName:Wi,backendName:"webgl",kernelFunc:vZ},kZ=RK+`
|
|
return atan(a, b);
|
|
`,IZ=`
|
|
vec4 result = atan(a, b);
|
|
vec4 isNaN = min(vec4(isnan(a)) + vec4(isnan(b)), vec4(1.0));
|
|
`+DK+`
|
|
return result;
|
|
`,SZ=An({opSnippet:kZ,packedOpSnippet:IZ}),CZ={kernelName:Ui,backendName:"webgl",kernelFunc:SZ},TZ=Js+`
|
|
if ((x < -1.0) || (x > 1.0)) return NAN;
|
|
return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,NZ=tt({opSnippet:TZ}),EZ={kernelName:Vi,backendName:"webgl",kernelFunc:NZ},xd=class{constructor(e,t,n,s=!1,r=!1){if(this.variableNames=["x"],t==="avg"&&n)throw new Error("Cannot compute positions for average pool.");let a=e.filterWidth,o=e.strideHeight,i=e.strideWidth,l=e.dilationHeight,u=e.dilationWidth,c=e.effectiveFilterHeight,d=e.effectiveFilterWidth,p=e.padInfo.top,h=e.padInfo.left;this.outputShape=e.outShape;let f=t==="avg",m=`((batch * ${e.inHeight} + xR) * ${e.inWidth} + xC) * ${e.inChannels} + d`,g=`(xR * ${e.inWidth} + xC) * ${e.inChannels} + d`,A="0.0";if(f||(A="-1.0 / 1e-20"),n){let S=">=";this.userCode=`
|
|
const ivec2 strides = ivec2(${o}, ${i});
|
|
const ivec2 pads = ivec2(${p}, ${h});
|
|
|
|
void main() {
|
|
ivec4 coords = getOutputCoords();
|
|
int batch = coords[0];
|
|
int d = coords[3];
|
|
|
|
ivec2 xRCCorner = coords.yz * strides - pads;
|
|
int xRCorner = xRCCorner.x;
|
|
int xCCorner = xRCCorner.y;
|
|
|
|
// max/min x(?, ?, d) to get y(yR, yC, d).
|
|
// ? = to be determined
|
|
float minMaxValue = 0.0;
|
|
float minMaxValueFound = 0.0;
|
|
int minMaxPosition = 0;
|
|
float avgValue = 0.0;
|
|
|
|
for (int wR = 0; wR < ${c};
|
|
wR += ${l}) {
|
|
int xR = xRCorner + wR;
|
|
|
|
if (xR < 0 || xR >= ${e.inHeight}) {
|
|
continue;
|
|
}
|
|
|
|
for (int wC = 0; wC < ${d};
|
|
wC += ${u}) {
|
|
int xC = xCCorner + wC;
|
|
|
|
if (xC < 0 || xC >= ${e.inWidth}) {
|
|
continue;
|
|
}
|
|
|
|
float value = getX(batch, xR, xC, d);
|
|
|
|
// If a min / max value has already been found, use it. If not,
|
|
// use the current value.
|
|
float currMinMaxValue = mix(
|
|
value, minMaxValue, minMaxValueFound);
|
|
if (value ${S} currMinMaxValue) {
|
|
minMaxValue = value;
|
|
minMaxValueFound = 1.0;
|
|
minMaxPosition = ${s?r?m:g:`wR * ${d} + wC`};
|
|
}
|
|
}
|
|
}
|
|
setOutput(float(minMaxPosition));
|
|
}
|
|
`;return}let y="max",x=`${t}(${t}(${t}(minMaxValue[0], minMaxValue[1]), minMaxValue[2]), minMaxValue[3])`;t==="avg"&&(x="avgValue / count");let b=Math.floor(a/4)*4,v=a%4,k=`
|
|
if (${f}) {
|
|
avgValue += dot(values, ones);
|
|
} else {
|
|
minMaxValue = ${y}(values, minMaxValue);
|
|
}
|
|
`;this.userCode=`
|
|
const ivec2 strides = ivec2(${o}, ${i});
|
|
const ivec2 pads = ivec2(${p}, ${h});
|
|
const float initializationValue = ${A};
|
|
const vec4 ones = vec4(1.0, 1.0, 1.0, 1.0);
|
|
|
|
float count = 0.0;
|
|
|
|
float getValue(int batch, int xR, int xC, int d) {
|
|
if (xC < 0 || xC >= ${e.inWidth}) {
|
|
return initializationValue;
|
|
}
|
|
count += 1.0;
|
|
return getX(batch, xR, xC, d);
|
|
}
|
|
|
|
void main() {
|
|
ivec4 coords = getOutputCoords();
|
|
int batch = coords[0];
|
|
int d = coords[3];
|
|
|
|
ivec2 xRCCorner = coords.yz * strides - pads;
|
|
int xRCorner = xRCCorner.x;
|
|
int xCCorner = xRCCorner.y;
|
|
|
|
// max/min x(?, ?, d) to get y(yR, yC, d).
|
|
// ? = to be determined
|
|
vec4 minMaxValue = vec4(${A});
|
|
float avgValue = 0.0;
|
|
count = 0.0;
|
|
|
|
for (int wR = 0; wR < ${c};
|
|
wR += ${l}) {
|
|
int xR = xRCorner + wR;
|
|
|
|
if (xR < 0 || xR >= ${e.inHeight}) {
|
|
continue;
|
|
}
|
|
|
|
for (int wC = 0; wC < ${b}; wC += 4) {
|
|
int xC = xCCorner + wC * ${u};
|
|
|
|
vec4 values = vec4(
|
|
getValue(batch, xR, xC, d),
|
|
getValue(batch, xR, xC + ${u}, d),
|
|
getValue(batch, xR, xC + 2 * ${u}, d),
|
|
getValue(batch, xR, xC + 3 * ${u}, d)
|
|
);
|
|
|
|
${k}
|
|
}
|
|
|
|
int xC = xCCorner + ${b};
|
|
if (${v===1}) {
|
|
vec4 values = vec4(
|
|
getValue(batch, xR, xC, d),
|
|
initializationValue,
|
|
initializationValue,
|
|
initializationValue
|
|
);
|
|
|
|
${k}
|
|
} else if (${v===2}) {
|
|
vec4 values = vec4(
|
|
getValue(batch, xR, xC, d),
|
|
getValue(batch, xR, xC + ${u}, d),
|
|
initializationValue,
|
|
initializationValue
|
|
);
|
|
|
|
${k}
|
|
} else if (${v===3}) {
|
|
vec4 values = vec4(
|
|
getValue(batch, xR, xC, d),
|
|
getValue(batch, xR, xC + ${u}, d),
|
|
getValue(batch, xR, xC + 2 * ${u}, d),
|
|
initializationValue
|
|
);
|
|
|
|
${k}
|
|
}
|
|
}
|
|
setOutput(${x});
|
|
}
|
|
`}},xy=class{constructor(e,t,n,s=!1,r=!1){if(this.variableNames=["x"],t==="avg"&&n)throw new Error("Cannot compute positions for average pool.");let a=e.filterWidth,o=e.strideDepth,i=e.strideHeight,l=e.strideWidth,u=e.dilationDepth,c=e.dilationHeight,d=e.dilationWidth,p=e.effectiveFilterDepth,h=e.effectiveFilterHeight,f=e.effectiveFilterWidth,m=e.padInfo.front,g=e.padInfo.top,A=e.padInfo.left;this.outputShape=e.outShape;let y=t==="avg",x="0.0";if(y||(x="-1.0 / 1e-20"),n){let D=">=";this.userCode=`
|
|
const ivec3 strides =
|
|
ivec3(${o}, ${i}, ${l});
|
|
const ivec3 pads = ivec3(${m}, ${g}, ${A});
|
|
|
|
void main() {
|
|
ivec5 coords = getOutputCoords();
|
|
int batch = coords.x;
|
|
int ch = coords.u;
|
|
|
|
ivec3 xCorner = ivec3(coords.y, coords.z, coords.w) * strides - pads;
|
|
int xDCorner = xCorner.x;
|
|
int xRCorner = xCorner.y;
|
|
int xCCorner = xCorner.z;
|
|
|
|
// max/min x(?, ?, ?, ch) to get y(yD, yR, yC, ch).
|
|
// ? = to be determined
|
|
float minMaxValue = 0.0;
|
|
float minMaxValueFound = 0.0;
|
|
int minMaxPosition = 0;
|
|
|
|
for (int wD = 0; wD < ${p};
|
|
wD += ${u}) {
|
|
int xD = xDCorner + wD;
|
|
|
|
if (xD < 0 || xD >= ${e.inDepth}) {
|
|
continue;
|
|
}
|
|
|
|
for (int wR = 0; wR < ${h};
|
|
wR += ${c}) {
|
|
int xR = xRCorner + wR;
|
|
|
|
if (xR < 0 || xR >= ${e.inHeight}) {
|
|
continue;
|
|
}
|
|
|
|
for (int wC = 0; wC < ${f};
|
|
wC += ${d}) {
|
|
int xC = xCCorner + wC;
|
|
|
|
if (xC < 0 || xC >= ${e.inWidth}) {
|
|
continue;
|
|
}
|
|
|
|
float value = getX(batch, xD, xR, xC, ch);
|
|
|
|
// If a min / max value has already been found, use it. If not,
|
|
// use the current value.
|
|
float currMinMaxValue = mix(
|
|
value, minMaxValue, minMaxValueFound);
|
|
if (value ${D} currMinMaxValue) {
|
|
minMaxValue = value;
|
|
minMaxValueFound = 1.0;
|
|
minMaxPosition = ${s?r?`(((batch * ${e.inDepth} + xD) * ${e.inHeight} + xR) * ${e.inWidth} + xC) * ${e.inChannels} + ch`:`((xD * ${e.inHeight} + xR) * ${e.inWidth} + xC) * ${e.inChannels} + ch`:`wD * ${h} * ${f} +
|
|
wR * ${f} + wC`};
|
|
}
|
|
}
|
|
}
|
|
}
|
|
setOutput(float(minMaxPosition));
|
|
}
|
|
`;return}let b="max",v=`${t}(${t}(${t}(minMaxValue[0], minMaxValue[1]), minMaxValue[2]), minMaxValue[3])`;t==="avg"&&(v="avgValue / count");let k=Math.floor(a/4)*4,S=a%4,C=`
|
|
if (${y}) {
|
|
avgValue += dot(values, ones);
|
|
} else {
|
|
minMaxValue = ${b}(values, minMaxValue);
|
|
}
|
|
`;this.userCode=`
|
|
const ivec3 strides =
|
|
ivec3(${o}, ${i}, ${l});
|
|
const ivec3 pads = ivec3(${m}, ${g}, ${A});
|
|
const float initializationValue = ${x};
|
|
const vec4 ones = vec4(1.0, 1.0, 1.0, 1.0);
|
|
|
|
float count = 0.0;
|
|
|
|
float getValue(int batch, int xD, int xR, int xC, int ch) {
|
|
if (xC < 0 || xC >= ${e.inWidth}) {
|
|
return initializationValue;
|
|
}
|
|
count += 1.0;
|
|
return getX(batch, xD, xR, xC, ch);
|
|
}
|
|
|
|
void main() {
|
|
ivec5 coords = getOutputCoords();
|
|
int batch = coords.x;
|
|
int ch = coords.u;
|
|
|
|
ivec3 xCorner = ivec3(coords.y, coords.z, coords.w) * strides - pads;
|
|
int xDCorner = xCorner.x;
|
|
int xRCorner = xCorner.y;
|
|
int xCCorner = xCorner.z;
|
|
|
|
// max/min x(?, ?, ?, d) to get y(yD, yR, yC, ch).
|
|
// ? = to be determined
|
|
vec4 minMaxValue = vec4(${x});
|
|
float avgValue = 0.0;
|
|
count = 0.0;
|
|
|
|
for (int wD = 0; wD < ${p};
|
|
wD += ${u}) {
|
|
int xD = xDCorner + wD;
|
|
|
|
if (xD < 0 || xD >= ${e.inDepth}) {
|
|
continue;
|
|
}
|
|
|
|
for (int wR = 0; wR < ${h};
|
|
wR += ${c}) {
|
|
int xR = xRCorner + wR;
|
|
|
|
if (xR < 0 || xR >= ${e.inHeight}) {
|
|
continue;
|
|
}
|
|
|
|
for (int wC = 0; wC < ${k}; wC += 4) {
|
|
int xC = xCCorner + wC * ${d};
|
|
|
|
vec4 values = vec4(
|
|
getValue(batch, xD, xR, xC, ch),
|
|
getValue(batch, xD, xR, xC + ${d}, ch),
|
|
getValue(batch, xD, xR, xC + 2 * ${d}, ch),
|
|
getValue(batch, xD, xR, xC + 3 * ${d}, ch)
|
|
);
|
|
|
|
${C}
|
|
}
|
|
|
|
int xC = xCCorner + ${k};
|
|
if (${S===1}) {
|
|
vec4 values = vec4(
|
|
getValue(batch, xD, xR, xC, ch),
|
|
initializationValue,
|
|
initializationValue,
|
|
initializationValue
|
|
);
|
|
|
|
${C}
|
|
} else if (${S===2}) {
|
|
vec4 values = vec4(
|
|
getValue(batch, xD, xR, xC, ch),
|
|
getValue(batch, xD, xR, xC + ${d}, ch),
|
|
initializationValue,
|
|
initializationValue
|
|
);
|
|
|
|
${C}
|
|
} else if (${S===3}) {
|
|
vec4 values = vec4(
|
|
getValue(batch, xD, xR, xC, ch),
|
|
getValue(batch, xD, xR, xC + ${d}, ch),
|
|
getValue(batch, xD, xR, xC + 2 * ${d}, ch),
|
|
initializationValue
|
|
);
|
|
|
|
${C}
|
|
}
|
|
}
|
|
setOutput(${v});
|
|
}
|
|
}
|
|
`}};function RZ(e){let{inputs:t,backend:n,attrs:s}=e,{x:r}=t;mu(r,"avgPool");let{filterSize:a,strides:o,pad:i,dimRoundingMode:l}=s,u=1;w.assert(_.eitherStridesOrDilationsAreOne(o,u),()=>`Error in avgPool: Either strides or dilations must be 1. Got strides ${o} and dilations '${u}'`);let c=_.computePool2DInfo(r.shape,a,o,u,i,l);if(c.filterWidth===1&&c.filterHeight===1&&w.arraysEqual(c.inShape,c.outShape))return ds({inputs:{x:r},backend:n});let d=new xd(c,"avg",!1);return n.runWebGLProgram(d,[r],"float32")}var DZ={kernelName:Pa,backendName:"webgl",kernelFunc:RZ};function _Z(e){let{inputs:t,backend:n,attrs:s}=e,{x:r}=t,{filterSize:a,strides:o,pad:i,dimRoundingMode:l,dataFormat:u}=s,c=[1,1,1],d=_.computePool3DInfo(r.shape,a,o,c,i,l,u),p=new xy(d,"avg",!1);return n.runWebGLProgram(p,[r],"float32")}var $Z={kernelName:Yu,backendName:"webgl",kernelFunc:_Z},FZ=class{constructor(e){this.variableNames=["dy"],this.outputShape=e.inShape;let t=e.filterHeight,n=e.filterWidth,s=e.strideHeight,r=e.strideWidth,a=e.dilationHeight,o=e.dilationWidth,i=e.effectiveFilterHeight,l=e.effectiveFilterWidth,u=i-1-e.padInfo.top,c=l-1-e.padInfo.left,d=1/(t*n);this.userCode=`
|
|
const ivec2 pads = ivec2(${u}, ${c});
|
|
const float avgMultiplier = float(${d});
|
|
|
|
void main() {
|
|
ivec4 coords = getOutputCoords();
|
|
int b = coords[0];
|
|
int d = coords[3];
|
|
|
|
ivec2 dyRCCorner = coords.yz - pads;
|
|
int dyRCorner = dyRCCorner.x;
|
|
int dyCCorner = dyRCCorner.y;
|
|
|
|
// Convolve dy(?, ?, d) with pos mask(:, :, d) to get dx(xR, xC, d).
|
|
// ? = to be determined. : = across all values in that axis.
|
|
float dotProd = 0.0;
|
|
for (int wR = 0; wR < ${i};
|
|
wR += ${a}) {
|
|
float dyR = float(dyRCorner + wR) / ${s}.0;
|
|
|
|
if (dyR < 0.0 || dyR >= ${e.outHeight}.0 || fract(dyR) > 0.0) {
|
|
continue;
|
|
}
|
|
int idyR = int(dyR);
|
|
|
|
for (int wC = 0; wC < ${l};
|
|
wC+= ${o}) {
|
|
float dyC = float(dyCCorner + wC) / ${r}.0;
|
|
|
|
if (dyC < 0.0 || dyC >= ${e.outWidth}.0 ||
|
|
fract(dyC) > 0.0) {
|
|
continue;
|
|
}
|
|
int idyC = int(dyC);
|
|
|
|
float dyValue = getDy(b, idyR, idyC, d);
|
|
|
|
dotProd += dyValue * avgMultiplier;
|
|
}
|
|
}
|
|
setOutput(dotProd);
|
|
}
|
|
`}},OZ=class{constructor(e){this.variableNames=["dy"],this.outputShape=e.inShape;let t=e.filterDepth,n=e.filterHeight,s=e.filterWidth,r=e.strideDepth,a=e.strideHeight,o=e.strideWidth,i=e.dilationDepth,l=e.dilationHeight,u=e.dilationWidth,c=e.effectiveFilterDepth,d=e.effectiveFilterHeight,p=e.effectiveFilterWidth,h=c-1-e.padInfo.front,f=d-1-e.padInfo.top,m=p-1-e.padInfo.left,g=1/(t*n*s);this.userCode=`
|
|
const ivec3 pads = ivec3(${h}, ${f}, ${m});
|
|
const float avgMultiplier = float(${g});
|
|
|
|
void main() {
|
|
ivec5 coords = getOutputCoords();
|
|
int batch = coords.x;
|
|
int ch = coords.u;
|
|
|
|
ivec3 dyCorner = ivec3(coords.y, coords.z, coords.w) - pads;
|
|
int dyDCorner = dyCorner.x;
|
|
int dyRCorner = dyCorner.y;
|
|
int dyCCorner = dyCorner.z;
|
|
|
|
// Convolve dy(?, ?, ?, d) with pos mask(:, :, :, ch) to get
|
|
// dx(xD, xR, xC, ch).
|
|
// ? = to be determined. : = across all values in that axis.
|
|
float dotProd = 0.0;
|
|
|
|
for (int wD = 0; wD < ${c};
|
|
wD += ${i}) {
|
|
float dyD = float(dyDCorner + wD) / ${r}.0;
|
|
|
|
if (dyD < 0.0 || dyD >= ${e.outDepth}.0 || fract(dyD) > 0.0) {
|
|
continue;
|
|
}
|
|
int idyD = int(dyD);
|
|
|
|
for (int wR = 0; wR < ${d};
|
|
wR += ${l}) {
|
|
float dyR = float(dyRCorner + wR) / ${a}.0;
|
|
|
|
if (dyR < 0.0 || dyR >= ${e.outHeight}.0 ||
|
|
fract(dyR) > 0.0) {
|
|
continue;
|
|
}
|
|
int idyR = int(dyR);
|
|
|
|
for (int wC = 0; wC < ${p};
|
|
wC += ${u}) {
|
|
float dyC = float(dyCCorner + wC) / ${o}.0;
|
|
|
|
if (dyC < 0.0 || dyC >= ${e.outWidth}.0 ||
|
|
fract(dyC) > 0.0) {
|
|
continue;
|
|
}
|
|
int idyC = int(dyC);
|
|
|
|
float dyValue = getDy(batch, idyD, idyR, idyC, ch);
|
|
|
|
dotProd += dyValue * avgMultiplier;
|
|
}
|
|
}
|
|
}
|
|
setOutput(dotProd);
|
|
}
|
|
`}};function PZ(e){let{inputs:t,backend:n,attrs:s}=e,{dy:r,input:a}=t,o=a,{filterSize:i,strides:l,pad:u,dimRoundingMode:c}=s,d=[1,1,1],p=_.computePool3DInfo(o.shape,i,l,d,u,c),h=new OZ(p);return n.runWebGLProgram(h,[r],o.dtype)}var MZ={kernelName:mp,backendName:"webgl",kernelFunc:PZ};function zZ(e){let{inputs:t,backend:n,attrs:s}=e,{dy:r,input:a}=t,o=a;mu([r,a],"avgPoolGrad");let{filterSize:i,strides:l,pad:u}=s,c=_.computePool2DInfo(o.shape,i,l,1,u),d=new FZ(c);return n.runWebGLProgram(d,[r],o.dtype)}var LZ={kernelName:fp,backendName:"webgl",kernelFunc:zZ};function BZ(e){let{inputs:t,backend:n,attrs:s}=e,{a:r,b:a}=t,{transposeA:o,transposeB:i}=s;return t0({a:r,b:a,transposeA:o,transposeB:i,backend:n})}var WZ={kernelName:Ma,backendName:"webgl",kernelFunc:BZ},VZ=class{constructor(e,t,n,s,r,a){this.outputShape=[],this.variableNames=["x","mean","variance"],_.assertAndGetBroadcastShape(e,t),_.assertAndGetBroadcastShape(e,n);let o="0.0";s!=null&&(_.assertAndGetBroadcastShape(e,s),this.variableNames.push("offset"),o="getOffsetAtOutCoords()");let i="1.0";r!=null&&(_.assertAndGetBroadcastShape(e,r),this.variableNames.push("scale"),i="getScaleAtOutCoords()"),this.outputShape=e,this.userCode=`
|
|
void main() {
|
|
float x = getXAtOutCoords();
|
|
float mean = getMeanAtOutCoords();
|
|
float variance = getVarianceAtOutCoords();
|
|
float offset = ${o};
|
|
float scale = ${i};
|
|
float inv = scale * inversesqrt(variance + float(${a}));
|
|
setOutput(dot(vec3(x, -mean, offset), vec3(inv, inv, 1)));
|
|
}
|
|
`}},UZ=class{constructor(e,t,n,s,r,a){this.packedInputs=!0,this.packedOutput=!0,this.variableNames=["x","mean","variance"],_.assertAndGetBroadcastShape(e,t),_.assertAndGetBroadcastShape(e,n);let o="vec4(0.0)";s!=null&&(_.assertAndGetBroadcastShape(e,s),this.variableNames.push("offset"),o="getOffsetAtOutCoords()");let i="vec4(1.0)";r!=null&&(_.assertAndGetBroadcastShape(e,r),this.variableNames.push("scale"),i="getScaleAtOutCoords()"),this.outputShape=e,this.userCode=`
|
|
void main() {
|
|
vec4 offset = ${o};
|
|
vec4 scale = ${i};
|
|
|
|
vec4 x = getXAtOutCoords();
|
|
vec4 mean = getMeanAtOutCoords();
|
|
vec4 variance = getVarianceAtOutCoords();
|
|
|
|
vec4 inv = scale * inversesqrt(variance + vec4(${a}));
|
|
|
|
setOutput((x - mean) * inv + offset);
|
|
}
|
|
`}},HZ=({inputs:e,backend:t,attrs:n})=>{let{x:s,mean:r,variance:a,offset:o,scale:i}=e;w.assert(r.shape.length===a.shape.length,()=>"Batch normalization gradient requires mean and variance to have equal ranks."),w.assert(o==null||r.shape.length===o.shape.length,()=>"Batch normalization gradient requires mean and offset to have equal ranks."),w.assert(i==null||r.shape.length===i.shape.length,()=>"Batch normalization gradient requires mean and scale to have equal ranks.");let{varianceEpsilon:l}=n;l==null&&(l=.001);let u=[s,r,a],c=null;o!=null&&(c=o.shape,u.push(o));let d=null;i!=null&&(d=i.shape,u.push(i));let p=Y().getBool("WEBGL_PACK_NORMALIZATION")?new UZ(s.shape,r.shape,a.shape,c,d,l):new VZ(s.shape,r.shape,a.shape,c,d,l);return t.runWebGLProgram(p,u,u[0].dtype)},GZ={kernelName:Ya,backendName:"webgl",kernelFunc:HZ},jZ=class{constructor(e){this.variableNames=["source"],this.outputShape=e,this.rank=e.length;let t=gt(this.rank);this.customUniforms=[{name:"start",arrayIndex:this.rank,type:"int"}];let n=qZ(this.rank),s,r=e.map((a,o)=>`sourceLoc.${by[o]} = start[${o}] + coords.${by[o]};`);s=`
|
|
${t} sourceLoc;
|
|
${t} coords = getOutputCoords();
|
|
${r.join(`
|
|
`)}
|
|
`,this.userCode=`
|
|
void main() {
|
|
${s}
|
|
setOutput(getSource(${n}));
|
|
}
|
|
`}},by=["x","y","z","w","u","v"];function qZ(e){if(e===1)return"sourceLoc";if(e<=6)return by.slice(0,e).map(t=>"sourceLoc."+t).join(",");throw Error(`Slicing for rank ${e} is not yet supported`)}var XZ=class{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"}];let t=gt(this.rank),n=Rn("coords",this.rank),s=Rn("sourceLoc",this.rank),r=this.rank===1?"sourceLoc":`vec2(${s.slice(-2).join()})`,a=`getChannel(getSource(${s.join()}), ${r})`,o=`
|
|
result.x = ${a};
|
|
if (++${n[this.rank-1]} < ${e[this.rank-1]}) {
|
|
++${s[this.rank-1]};
|
|
result.y = ${a};
|
|
--${s[this.rank-1]};
|
|
}
|
|
`,i=this.rank===1?"":`
|
|
--${n[this.rank-1]};
|
|
if (++${n[this.rank-2]} < ${e[this.rank-2]}) {
|
|
++${s[this.rank-2]};
|
|
result.z = ${a};
|
|
if (++${n[this.rank-1]} < ${e[this.rank-1]}) {
|
|
++${s[this.rank-1]};
|
|
result.w = ${a};
|
|
}
|
|
}
|
|
`,l=this.rank<=4?`sourceLoc = coords +
|
|
${t}(${e.map((u,c)=>`start[${c}]`).join()});`:e.map((u,c)=>`${s[c]} = ${n[c]} + start[${c}];`).join(`
|
|
`);this.userCode=`
|
|
void main() {
|
|
${t} coords = getOutputCoords();
|
|
${t} sourceLoc;
|
|
${l}
|
|
vec4 result = vec4(0.);
|
|
${o}
|
|
${i}
|
|
setOutput(result);
|
|
}
|
|
`}};function KZ(e,t,n,s){let r=s.texData.get(e.dataId),a=s.makeTensorInfo(n,e.dtype),o=s.texData.get(a.dataId);Object.assign(o,r),o.refCount=1,o.shape=n,o.dtype=e.dtype;let i=Cn.computeFlatOffset(t,w.computeStrides(e.shape));r.slice&&(i+=r.slice.flatOffset),o.slice={flatOffset:i,origDataId:r.slice&&r.slice.origDataId||e.dataId};let l=s.dataRefCount.get(o.slice.origDataId)||1;return s.dataRefCount.set(o.slice.origDataId,l+1),a}function ku(e){let{inputs:t,backend:n,attrs:s}=e,{x:r}=t,{begin:a,size:o}=s,[i,l]=Cn.parseSliceParams(r,a,o);if(Cn.assertParamsValid(r,i,l),w.sizeFromShape(l)===0)return n.makeTensorInfo(l,r.dtype,[]);if(n.shouldExecuteOnCPU([r])||r.dtype==="string"){let d=n.texData.get(r.dataId),p=FX(d.values,i,l,r.shape,r.dtype);return n.makeTensorInfo(l,r.dtype,p)}let{isPacked:u}=n.texData.get(r.dataId),c=Cn.isSliceContinous(r.shape,i,l);if(u||!c){let d=Y().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new XZ(l):new jZ(l),p=[i];return n.runWebGLProgram(d,[r],r.dtype,p)}return n.uploadToGPU(r.dataId),KZ(r,i,l,n)}var ZZ={kernelName:kl,backendName:"webgl",kernelFunc:ku},YZ=e=>{let{inputs:t,backend:n,attrs:s}=e,{x:r}=t,{blockShape:a,crops:o}=s;w.assert(r.shape.length<=4,()=>"batchToSpaceND for rank > 4 with a WebGL backend not implemented yet");let i=a.reduce((y,x)=>y*x),l=_.getReshaped(r.shape,a,i),u=_.getPermuted(l.length,a.length),c=_.getReshapedPermuted(r.shape,a,i),d=_.getSliceBeginCoords(o,a.length),p=_.getSliceSize(c,o,a.length),h=[],f=be({inputs:{x:r},backend:n,attrs:{shape:l}}),m=Dn({inputs:{x:f},backend:n,attrs:{perm:u}}),g=be({inputs:{x:m},backend:n,attrs:{shape:c}}),A=ku({inputs:{x:g},backend:n,attrs:{begin:d,size:p}});return h.push(f),h.push(m),h.push(g),h.forEach(y=>n.disposeIntermediateTensorInfo(y)),A},JZ={kernelName:Hi,backendName:"webgl",kernelFunc:YZ};function QZ(e){let{inputs:t,backend:n,attrs:s}=e,{x:r,weights:a}=t,{size:o}=s,i=n.readSync(r.dataId),l=n.readSync(a.dataId),u=Q6(i,l,a.dtype,a.shape,o);return n.makeTensorInfo([o],a.dtype,u)}var eY={kernelName:gp,backendName:"webgl",kernelFunc:QZ},tY="return float(a != b);",C4=An({opSnippet:tY,cpuKernelImpl:EX,dtype:"bool"}),nY={kernelName:dl,backendName:"webgl",kernelFunc:C4};function bd(e){let{inputs:t,backend:n}=e,{input:s}=t,r=n.texData.get(s.dataId);return ds({inputs:{x:r.complexTensorInfos.real},backend:n})}var sY={kernelName:zp,backendName:"webgl",kernelFunc:bd},rY="return float(int(x));";function aY(e,t){let n=new wa(e.shape,rY),s=t.runWebGLProgram(n,[e],"int32");return{dataId:s.dataId,shape:s.shape,dtype:s.dtype}}function vy(e){let{inputs:t,backend:n,attrs:s}=e,{x:r}=t,{dtype:a}=s;if(a==="complex64"){if(r.dtype==="complex64")return ds({inputs:{x:r},backend:n});let o=Mt(r.shape),i=vy({inputs:{x:r},backend:n,attrs:{dtype:"float32"}}),l=ka({inputs:{real:i,imag:o},backend:n});return o.dispose(),n.disposeIntermediateTensorInfo(i),l}if(r.dtype==="complex64"){let o=bd({inputs:{input:r},backend:n}),i=vy({inputs:{x:o},backend:n,attrs:{dtype:a}});return n.disposeIntermediateTensorInfo(o),i}if(!w.hasEncodingLoss(r.dtype,a)){let o=ds({inputs:{x:r},backend:n});return{dataId:o.dataId,shape:o.shape,dtype:a}}if(a==="int32")return aY(r,n);if(a==="bool"){let o=n.makeTensorInfo([],"bool",w.getTypedArrayFromDType("bool",1)),l=C4({inputs:{a:r,b:o},backend:n});return n.disposeIntermediateTensorInfo(o),l}throw new Error(`Error in Cast: failed to cast ${r.dtype} to ${a}`)}var oY={kernelName:za,backendName:"webgl",kernelFunc:vy},T4="return ceil(x);",iY=tt({opSnippet:T4,packedOpSnippet:T4,cpuKernelImpl:cX}),lY={kernelName:La,backendName:"webgl",kernelFunc:iY},uY=class{constructor(e){this.variableNames=["A"],this.customUniforms=[{name:"minVal",type:"float"},{name:"maxVal",type:"float"}],this.outputShape=e,this.userCode=`
|
|
|
|
void main() {
|
|
float value = getAAtOutCoords();
|
|
if (isnan(value)) {
|
|
setOutput(value);
|
|
return;
|
|
}
|
|
|
|
setOutput(clamp(value, minVal, maxVal));
|
|
}
|
|
`}},cY=class{constructor(e){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.customUniforms=[{name:"minVal",type:"float"},{name:"maxVal",type:"float"}],this.outputShape=e,this.userCode=`
|
|
void main() {
|
|
vec4 value = getAAtOutCoords();
|
|
|
|
if (any(isnan(value))) {
|
|
setOutput(value);
|
|
return;
|
|
}
|
|
|
|
setOutput(clamp(value, vec4(minVal), vec4(maxVal)));
|
|
}
|
|
`}};function dY(e){let{inputs:t,backend:n,attrs:s}=e,{x:r}=t,{clipValueMin:a,clipValueMax:o}=s,i;Y().getBool("WEBGL_PACK_CLIP")?i=new cY(r.shape):i=new uY(r.shape);let l=[[a],[o]];return n.runWebGLProgram(i,[r],r.dtype,l)}var pY={kernelName:Jr,backendName:"webgl",kernelFunc:dY},hY=class{constructor(e){this.variableNames=["real","imag"],this.outputShape=e,this.userCode=`
|
|
void main() {
|
|
float re = abs(getRealAtOutCoords());
|
|
float im = abs(getImagAtOutCoords());
|
|
float mx = max(re, im);
|
|
|
|
// sadly the length function in glsl is not underflow-safe
|
|
// (at least not on Intel GPUs). So the safe solution is
|
|
// to ensure underflow-safety in all cases.
|
|
setOutput(
|
|
mx == 0.0 ? 0.0 : mx * length(vec2(1, min(re, im)/mx))
|
|
);
|
|
}
|
|
`}};function N4(e,t){return{dataId:t.dataId,dtype:t.dtype,shape:e.shape}}function fY(e){let{inputs:t,backend:n}=e,{x:s}=t,r=n.texData.get(s.dataId),a=new hY(s.shape),o=[N4(s,r.complexTensorInfos.real),N4(s,r.complexTensorInfos.imag)];return n.runWebGLProgram(a,o,o[0].dtype)}var mY={kernelName:Ju,backendName:"webgl",kernelFunc:fY},gY=class{constructor(e){this.outputShape=[],this.outputShape=_.computeOutShape(e,1),this.variableNames=e.map((a,o)=>`T${o}`);let t=new Array(e.length-1);t[0]=e[0][1];for(let a=1;a<t.length;a++)t[a]=t[a-1]+e[a][1];let n=[`if (yC < ${t[0]}) setOutput(getT0(yR, yC));`];for(let a=1;a<t.length;a++){let o=t[a-1];n.push(`else if (yC < ${t[a]}) setOutput(getT${a}(yR, yC-${o}));`)}let s=t.length,r=t[t.length-1];n.push(`else setOutput(getT${s}(yR, yC-${r}));`),this.userCode=`
|
|
void main() {
|
|
ivec2 coords = getOutputCoords();
|
|
int yR = coords.x;
|
|
int yC = coords.y;
|
|
|
|
${n.join(`
|
|
`)}
|
|
}
|
|
`}},AY=class{constructor(e,t){this.packedInputs=!0,this.packedOutput=!0,this.outputShape=[],this.outputShape=_.computeOutShape(e,t);let n=this.outputShape,s=n.length,r=gt(s),a=Rn("coords",s),o=["x","y","z","w","u","v"].slice(0,s);this.variableNames=e.map((f,m)=>`T${m}`);let i=new Array(e.length-1);i[0]=e[0][t];for(let f=1;f<i.length;f++)i[f]=i[f-1]+e[f][t];let l=o[t],u=o.slice(-2),c=o.join(),d=`if (${l} < ${i[0]}) {
|
|
return getChannel(
|
|
getT0(${c}), vec2(${u.join()}));
|
|
}`;for(let f=1;f<i.length;f++){let m=i[f-1];d+=`
|
|
if (${l} < ${i[f]} && ${l} >= ${i[f-1]}) {
|
|
return getChannel(
|
|
getT${f}(${s0(o,l,m)}),
|
|
vec2(${s0(u,l,m)}));
|
|
}`}let p=i.length,h=i[i.length-1];d+=`
|
|
return getChannel(
|
|
getT${p}(${s0(o,l,h)}),
|
|
vec2(${s0(u,l,h)}));`,this.userCode=`
|
|
float getValue(${o.map(f=>"int "+f)}) {
|
|
${d}
|
|
}
|
|
|
|
void main() {
|
|
${r} coords = getOutputCoords();
|
|
vec4 result = vec4(getValue(${a}), 0., 0., 0.);
|
|
|
|
${a[s-1]} = ${a[s-1]} + 1;
|
|
if (${a[s-1]} < ${n[s-1]}) {
|
|
result.g = getValue(${a});
|
|
}
|
|
|
|
${a[s-2]} = ${a[s-2]} + 1;
|
|
if (${a[s-2]} < ${n[s-2]}) {
|
|
result.a = getValue(${a});
|
|
}
|
|
|
|
${a[s-1]} = ${a[s-1]} - 1;
|
|
if (${a[s-2]} < ${n[s-2]} &&
|
|
${a[s-1]} < ${n[s-1]}) {
|
|
result.b = getValue(${a});
|
|
}
|
|
setOutput(result);
|
|
}
|
|
`}};function s0(e,t,n){let s=e.indexOf(t);return e.map((a,o)=>o===s?`${a} - ${n}`:a).join()}function r0(e){let{inputs:t,backend:n}=e,{input:s}=t,r=n.texData.get(s.dataId);return ds({inputs:{x:r.complexTensorInfos.imag},backend:n})}var yY={kernelName:Dp,backendName:"webgl",kernelFunc:r0};function Iu(e,t,n){let s=e[0].dtype;if(s==="complex64"){let c=e.map(m=>bd({inputs:{input:m},backend:n})),d=e.map(m=>r0({inputs:{input:m},backend:n})),p=Iu(c,t,n),h=Iu(d,t,n),f=ka({inputs:{real:p,imag:h},backend:n});return c.forEach(m=>n.disposeIntermediateTensorInfo(m)),d.forEach(m=>n.disposeIntermediateTensorInfo(m)),n.disposeIntermediateTensorInfo(p),n.disposeIntermediateTensorInfo(h),f}let r=n.shouldExecuteOnCPU(e);if(s==="string"&&(r=!0),r){let c=e.map(A=>{let y=w.sizeFromShape(A.shape.slice(t));return be({inputs:{x:A},backend:n,attrs:{shape:[-1,y]}})}),d=c.map(A=>({vals:n.readSync(A.dataId),shape:A.shape})),p=_.computeOutShape(c.map(A=>A.shape),1),h=c[0].shape[0]===1,f=dX(d,p,s,h),m=_.computeOutShape(e.map(A=>A.shape),t),g=n.makeTensorInfo(m,s,f);return c.forEach(A=>n.disposeIntermediateTensorInfo(A)),g}if(e.length>Y().getNumber("WEBGL_MAX_TEXTURES_IN_SHADER")){let c=Math.floor(e.length/2),d=Iu(e.slice(0,c),t,n),p=Iu(e.slice(c),t,n),h=Iu([d,p],t,n);return n.disposeIntermediateTensorInfo(d),n.disposeIntermediateTensorInfo(p),h}if(Y().getBool("WEBGL_PACK_ARRAY_OPERATIONS")&&e[0].shape.length>1){let c=new AY(e.map(d=>d.shape),t);return n.runWebGLProgram(c,e,s)}let{tensors2D:a,outShape:o}=xY(e,t,n),i=new gY(a.map(c=>c.shape)),l=n.runWebGLProgram(i,a,s);a.forEach(c=>n.disposeIntermediateTensorInfo(c));let u=be({inputs:{x:l},attrs:{shape:o},backend:n});return n.disposeIntermediateTensorInfo(l),u}function xY(e,t,n){let s=_.computeOutShape(e.map(a=>a.shape),t);return{tensors2D:e.map(a=>be({inputs:{x:a},attrs:{shape:[-1,w.sizeFromShape(a.shape.slice(t))]},backend:n})),outShape:s}}function E4(e){let{inputs:t,backend:n,attrs:s}=e,{axis:r}=s,a=w.parseAxisParam(r,t[0].shape)[0],o=_.computeOutShape(t.map(u=>u.shape),a);if(w.sizeFromShape(o)===0)return n.makeTensorInfo(o,t[0].dtype,[]);let i=t.filter(u=>w.sizeFromShape(u.shape)>0);if(i.length===1)return ds({inputs:{x:i[0]},backend:n});let l=i.map(u=>u.shape);return _.assertParamsConsistent(l,a),Iu(i,a,n)}var bY={kernelName:Gi,backendName:"webgl",kernelFunc:E4},R4=class{constructor(e,t=!1,n=null,s=!1,r=!1){this.variableNames=["x","W"],this.outputShape=e.outShape;let a=e.padInfo.top,o=e.padInfo.left,i=e.strideHeight,l=e.strideWidth,u=e.dilationHeight,c=e.dilationWidth,d=e.filterHeight,p=e.filterWidth,h=Math.floor(e.inChannels/4)*4,f=e.inChannels%4,m=e.dataFormat==="channelsLast",g=m?1:2,A=m?2:3,y=m?3:1,x="",b="";n&&(s?x=`float activation(float a) {
|
|
float b = getPreluActivationWeightsAtOutCoords();
|
|
${n}
|
|
}`:r?x=`float activation(float a) {
|
|
float b = getLeakyreluAlphaAtOutCoords();
|
|
${n}
|
|
}`:x=`
|
|
float activation(float x) {
|
|
${n}
|
|
}
|
|
`,b="result = activation(result);");let v=t?"result += getBiasAtOutCoords();":"";t&&this.variableNames.push("bias"),s&&this.variableNames.push("preluActivationWeights"),r&&this.variableNames.push("leakyreluAlpha"),this.userCode=`
|
|
${x}
|
|
|
|
const ivec2 strides = ivec2(${i}, ${l});
|
|
const ivec2 pads = ivec2(${a}, ${o});
|
|
|
|
void main() {
|
|
ivec4 coords = getOutputCoords();
|
|
int batch = coords[0];
|
|
int d2 = coords[${y}];
|
|
|
|
ivec2 xRCCorner =
|
|
ivec2(coords[${g}], coords[${A}]) * strides - pads;
|
|
int xRCorner = xRCCorner.x;
|
|
int xCCorner = xRCCorner.y;
|
|
|
|
// Convolve x(?, ?, d1) with w(:, :, d1, d2) to get y(yR, yC, d2).
|
|
// ? = to be determined. : = across all values in that axis.
|
|
float dotProd = 0.0;
|
|
for (int wR = 0; wR < ${d}; wR++) {
|
|
int xR = xRCorner + wR * ${u};
|
|
|
|
if (xR < 0 || xR >= ${e.inHeight}) {
|
|
continue;
|
|
}
|
|
|
|
for (int wC = 0; wC < ${p}; wC++) {
|
|
int xC = xCCorner + wC * ${c};
|
|
|
|
if (xC < 0 || xC >= ${e.inWidth}) {
|
|
continue;
|
|
}
|
|
|
|
for (int d1 = 0; d1 < ${h}; d1 += 4) {
|
|
vec4 wValues = vec4(
|
|
getW(wR, wC, d1, d2),
|
|
getW(wR, wC, d1 + 1, d2),
|
|
getW(wR, wC, d1 + 2, d2),
|
|
getW(wR, wC, d1 + 3, d2)
|
|
);
|
|
|
|
if (${m}) {
|
|
vec4 xValues = vec4(
|
|
getX(batch, xR, xC, d1),
|
|
getX(batch, xR, xC, d1 + 1),
|
|
getX(batch, xR, xC, d1 + 2),
|
|
getX(batch, xR, xC, d1 + 3)
|
|
);
|
|
dotProd += dot(xValues, wValues);
|
|
} else {
|
|
vec4 xValues = vec4(
|
|
getX(batch, d1, xR, xC),
|
|
getX(batch, d1 + 1, xR, xC),
|
|
getX(batch, d1 + 2, xR, xC),
|
|
getX(batch, d1 + 3, xR, xC)
|
|
);
|
|
dotProd += dot(xValues, wValues);
|
|
}
|
|
}
|
|
|
|
if (${f===1}) {
|
|
|
|
if (${m}) {
|
|
dotProd +=
|
|
getX(batch, xR, xC, ${h}) *
|
|
getW(wR, wC, ${h}, d2);
|
|
} else {
|
|
dotProd +=
|
|
getX(batch, ${h}, xR, xC) *
|
|
getW(wR, wC, ${h}, d2);
|
|
}
|
|
|
|
} else if (${f===2}) {
|
|
vec2 wValues = vec2(
|
|
getW(wR, wC, ${h}, d2),
|
|
getW(wR, wC, ${h} + 1, d2)
|
|
);
|
|
|
|
if (${m}) {
|
|
vec2 xValues = vec2(
|
|
getX(batch, xR, xC, ${h}),
|
|
getX(batch, xR, xC, ${h} + 1)
|
|
);
|
|
dotProd += dot(xValues, wValues);
|
|
} else {
|
|
vec2 xValues = vec2(
|
|
getX(batch, ${h}, xR, xC),
|
|
getX(batch, ${h} + 1, xR, xC)
|
|
);
|
|
dotProd += dot(xValues, wValues);
|
|
}
|
|
|
|
} else if (${f===3}) {
|
|
vec3 wValues = vec3(
|
|
getW(wR, wC, ${h}, d2),
|
|
getW(wR, wC, ${h} + 1, d2),
|
|
getW(wR, wC, ${h} + 2, d2)
|
|
);
|
|
|
|
if (${m}) {
|
|
vec3 xValues = vec3(
|
|
getX(batch, xR, xC, ${h}),
|
|
getX(batch, xR, xC, ${h} + 1),
|
|
getX(batch, xR, xC, ${h} + 2)
|
|
);
|
|
dotProd += dot(xValues, wValues);
|
|
} else {
|
|
vec3 xValues = vec3(
|
|
getX(batch, ${h}, xR, xC),
|
|
getX(batch, ${h} + 1, xR, xC),
|
|
getX(batch, ${h} + 2, xR, xC)
|
|
);
|
|
dotProd += dot(xValues, wValues);
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|
|
|
|
float result = dotProd;
|
|
${v}
|
|
${b}
|
|
setOutput(result);
|
|
}
|
|
`}},vY=class{constructor(e){this.variableNames=["x","W"],this.outputShape=e.outShape;let t=e.padInfo.front,n=e.padInfo.top,s=e.padInfo.left,r=e.strideDepth,a=e.strideHeight,o=e.strideWidth,i=e.dilationDepth,l=e.dilationHeight,u=e.dilationWidth,c=e.filterDepth,d=e.filterHeight,p=e.filterWidth,h=Math.floor(e.inChannels/4)*4,f=e.inChannels%4;this.userCode=`
|
|
const ivec3 strides = ivec3(${r}, ${a}, ${o});
|
|
const ivec3 pads = ivec3(${t}, ${n}, ${s});
|
|
|
|
void main() {
|
|
ivec5 coords = getOutputCoords();
|
|
int batch = coords.x;
|
|
int d2 = coords.u;
|
|
|
|
ivec3 xFRCCorner = ivec3(coords.y, coords.z, coords.w) * strides - pads;
|
|
int xFCorner = xFRCCorner.x;
|
|
int xRCorner = xFRCCorner.y;
|
|
int xCCorner = xFRCCorner.z;
|
|
|
|
// Convolve x(?, ?, ?, d1) with w(:, :, :, d1, d2) to get
|
|
// y(yF, yR, yC, d2). ? = to be determined. : = across all
|
|
// values in that axis.
|
|
float dotProd = 0.0;
|
|
for (int wF = 0; wF < ${c}; wF++) {
|
|
int xF = xFCorner + wF * ${i};
|
|
|
|
if (xF < 0 || xF >= ${e.inDepth}) {
|
|
continue;
|
|
}
|
|
|
|
for (int wR = 0; wR < ${d}; wR++) {
|
|
int xR = xRCorner + wR * ${l};
|
|
|
|
if (xR < 0 || xR >= ${e.inHeight}) {
|
|
continue;
|
|
}
|
|
|
|
for (int wC = 0; wC < ${p}; wC++) {
|
|
int xC = xCCorner + wC * ${u};
|
|
|
|
if (xC < 0 || xC >= ${e.inWidth}) {
|
|
continue;
|
|
}
|
|
|
|
for (int d1 = 0; d1 < ${h}; d1 += 4) {
|
|
vec4 xValues = vec4(
|
|
getX(batch, xF, xR, xC, d1),
|
|
getX(batch, xF, xR, xC, d1 + 1),
|
|
getX(batch, xF, xR, xC, d1 + 2),
|
|
getX(batch, xF, xR, xC, d1 + 3)
|
|
);
|
|
vec4 wValues = vec4(
|
|
getW(wF, wR, wC, d1, d2),
|
|
getW(wF, wR, wC, d1 + 1, d2),
|
|
getW(wF, wR, wC, d1 + 2, d2),
|
|
getW(wF, wR, wC, d1 + 3, d2)
|
|
);
|
|
|
|
dotProd += dot(xValues, wValues);
|
|
}
|
|
|
|
if (${f===1}) {
|
|
dotProd +=
|
|
getX(batch, xF, xR, xC, ${h}) *
|
|
getW(wF, wR, wC, ${h}, d2);
|
|
} else if (${f===2}) {
|
|
vec2 xValues = vec2(
|
|
getX(batch, xF, xR, xC, ${h}),
|
|
getX(batch, xF, xR, xC, ${h} + 1)
|
|
);
|
|
vec2 wValues = vec2(
|
|
getW(wF, wR, wC, ${h}, d2),
|
|
getW(wF, wR, wC, ${h} + 1, d2)
|
|
);
|
|
dotProd += dot(xValues, wValues);
|
|
} else if (${f===3}) {
|
|
vec3 xValues = vec3(
|
|
getX(batch, xF, xR, xC, ${h}),
|
|
getX(batch, xF, xR, xC, ${h} + 1),
|
|
getX(batch, xF, xR, xC, ${h} + 2)
|
|
);
|
|
vec3 wValues = vec3(
|
|
getW(wF, wR, wC, ${h}, d2),
|
|
getW(wF, wR, wC, ${h} + 1, d2),
|
|
getW(wF, wR, wC, ${h} + 2, d2)
|
|
);
|
|
dotProd += dot(xValues, wValues);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
setOutput(dotProd);
|
|
}
|
|
`}},wY=class{constructor(e,t){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.customUniforms=[{name:"inputShape",type:"ivec3"},{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=Ss(this.outputShape.length);let{dataFormat:n}=t,s=En(),r=n==="channelsLast",a=r?0:1,o=r?1:2,i=this.enableShapeUniforms?"if(blockIndex < outShape[1] && pos < outShape[0]) {":`if(blockIndex < ${e[1]} && pos < ${e[0]}) {`,l="";for(let u=0;u<=1;u++)for(let c=0;c<=1;c++)l+=`
|
|
blockIndex = rc.y + ${c};
|
|
pos = rc.x + ${u};
|
|
|
|
${i}
|
|
offsetY = int(blockIndex / outWidth) * stride[0] - pad[0];
|
|
d0 = offsetY + dilation[0] * (pos / itemsPerBlockRow);
|
|
|
|
if(d0 < inputShape[${a}] && d0 >= 0) {
|
|
// Use custom imod instead mod. On Intel GPU, mod may generate
|
|
// unexpected value.
|
|
// https://github.com/tensorflow/tfjs/issues/5447
|
|
offsetX = imod(blockIndex, outWidth) * stride[1] - pad[1];
|
|
d1 = offsetX + dilation[1] * (imod(pos, itemsPerBlockRow) /
|
|
inChannels);
|
|
|
|
if(d1 < inputShape[${o}] && d1 >= 0) {
|
|
|
|
ch = imod(pos, inChannels);
|
|
|
|
if (${r}) {
|
|
innerDims = vec2(d1, ch);
|
|
result[${u*2+c}] = getChannel(
|
|
getA(d0, int(innerDims.x),
|
|
int(innerDims.y)), innerDims);
|
|
} else {
|
|
innerDims = vec2(d0, d1);
|
|
result[${u*2+c}] = getChannel(
|
|
getA(ch, int(innerDims.x),
|
|
int(innerDims.y)), innerDims);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
`;this.userCode=`
|
|
void main() {
|
|
ivec2 rc = getOutputCoords();
|
|
|
|
vec4 result = vec4(0);
|
|
|
|
int blockIndex, pos, offsetY, d0, offsetX, d1, ch;
|
|
vec2 innerDims;
|
|
|
|
${l}
|
|
|
|
${s.output} = result;
|
|
}
|
|
`}};function D4({x:e,filter:t,convInfo:n,backend:s,bias:r=null,preluActivationWeights:a=null,leakyreluAlpha:o=0,activation:i=null}){let l=e.shape,u=s.texData.get(e.dataId),c=n.inChannels,d=l[0]*l[1]*l[2],p=n.outChannels,h=n.dataFormat==="channelsLast",f=!1,m=!1,g,A=[];if(!((d===1||p===1)&&c>b4)&&u.isPacked&&h&&u.texture!=null&&l[2]%2!=0&&w.arraysEqual(u.shape.slice(-3),l.slice(-3))){let b=l[0]*l[1]*(l[2]+1),v={dataId:e.dataId,shape:[1,b,n.inChannels],dtype:e.dtype},k=u.shape;u.shape=u.shape.slice(),u.shape[u.shape.length-2]++,w.assert(gd(u.shape,v.shape),()=>`packed reshape ${u.shape} to ${v.shape} isn't free`);let S=be({inputs:{x:t},backend:s,attrs:{shape:[1,n.inChannels,n.outChannels]}});A.push(S);let C=t0({a:v,b:S,backend:s,transposeA:f,transposeB:m,bias:r,activation:i,preluActivationWeights:a,leakyreluAlpha:o}),D=s.texData.get(C.dataId);w.assert(D.isPacked,()=>"batchMatMul result is expected to be packed"),u.shape=k,D.shape=n.outShape,g=ds({inputs:{x:C},backend:s}),g.shape=n.outShape,A.push(C)}else{let b=h?l[0]*l[1]*l[2]:l[0]*l[2]*l[3],v=be({inputs:{x:e},backend:s,attrs:{shape:[1,b,n.inChannels]}}),k=be({inputs:{x:t},backend:s,attrs:{shape:[1,n.inChannels,n.outChannels]}}),S=t0({a:v,b:k,transposeA:f,transposeB:m,backend:s,bias:r,activation:i,preluActivationWeights:a,leakyreluAlpha:o});g=be({inputs:{x:S},backend:s,attrs:{shape:n.outShape}}),A.push(v),A.push(k),A.push(S)}for(let b of A)s.disposeIntermediateTensorInfo(b);return g}function _4({x:e,filter:t,convInfo:n,backend:s,bias:r=null,preluActivationWeights:a=null,leakyreluAlpha:o=0,activation:i=null}){let{filterWidth:l,filterHeight:u,inChannels:c,outWidth:d,outHeight:p,dataFormat:h}=n,f=h==="channelsLast",m=l*u*c,g=p*d,A=[m,g],y=!0,x=!1,b=[],v=be({inputs:{x:e},backend:s,attrs:{shape:e.shape.slice(1)}}),k=be({inputs:{x:t},backend:s,attrs:{shape:[1,m,w.sizeFromShape(t.shape)/m]}});b.push(v),b.push(k);let S=new wY(A,n),C=[v.shape,[n.padInfo.top,n.padInfo.left],[n.strideHeight,n.strideWidth],[n.dilationHeight,n.dilationWidth],[n.inChannels],[n.filterWidth*n.inChannels],[n.outWidth]],D=s.runWebGLProgram(S,[v],"float32",C),O=be({inputs:{x:D},backend:s,attrs:{shape:[1,A[0],A[1]]}});b.push(D),b.push(O);let E=r!=null,R=a!=null,T=i==="leakyrelu",P=i?Jf(i,!0):null,U=new m4(O.shape,k.shape,[1,g,n.outChannels],y,x,E,P,R,T),j=[O,k];if(r&&j.push(r),R&&j.push(a),T){let ne=s.makeTensorInfo([],"float32",w.createScalarValue(o,"float32"));j.push(ne),b.push(ne)}let q=s.runWebGLProgram(U,j,"float32"),X=f?[1,p,d,n.outChannels]:[1,n.outChannels,p,d],te=be({inputs:{x:q},backend:s,attrs:{shape:X}});b.push(q);for(let ne of b)s.disposeIntermediateTensorInfo(ne);return te}function kY(e){let{inputs:t,backend:n,attrs:s}=e,{x:r,filter:a}=t,{strides:o,pad:i,dataFormat:l,dilations:u,dimRoundingMode:c}=s,d=_.convertConv2DDataFormat(l),p=_.computeConv2DInfo(r.shape,a.shape,o,u,i,c,!1,d),h;if(p.filterHeight===1&&p.filterWidth===1&&p.dilationHeight===1&&p.dilationWidth===1&&p.strideHeight===1&&p.strideWidth===1&&(p.padInfo.type==="SAME"||p.padInfo.type==="VALID"))h=D4({x:r,filter:a,convInfo:p,backend:n});else if(Y().getBool("WEBGL_CONV_IM2COL")&&r.shape[0]===1)h=_4({x:r,filter:a,convInfo:p,backend:n});else{let m=new R4(p);h=n.runWebGLProgram(m,[r,a],"float32")}let f=be({inputs:{x:h},backend:n,attrs:{shape:p.outShape}});return n.disposeIntermediateTensorInfo(h),f}var IY={kernelName:Ba,backendName:"webgl",kernelFunc:kY},SY=class{constructor(e){this.variableNames=["x","dy"],this.outputShape=e.filterShape;let t=e.strideHeight,n=e.strideWidth,s=e.padInfo.top,r=e.padInfo.left,a=e.dataFormat==="channelsLast";this.userCode=`
|
|
void main() {
|
|
ivec4 coords = getOutputCoords();
|
|
int wR = coords.x;
|
|
int wC = coords.y;
|
|
int d1 = coords.z;
|
|
int d2 = coords.w;
|
|
|
|
// Convolve x(?, ?, d1) with dy(:, :, d2) to get dw(wR, wC, d1, d2).
|
|
// ? = to be determined. : = across all values in that axis.
|
|
float dotProd = 0.0;
|
|
|
|
for (int b = 0; b < ${e.batchSize}; b++) {
|
|
for (int yR = 0; yR < ${e.outHeight}; yR++) {
|
|
int xR = wR + yR * ${t} - ${s};
|
|
|
|
if (xR < 0 || xR >= ${e.inHeight}) {
|
|
continue;
|
|
}
|
|
|
|
for (int yC = 0; yC < ${e.outWidth}; yC++) {
|
|
int xC = wC + yC * ${n} - ${r};
|
|
|
|
if (xC < 0 || xC >= ${e.inWidth}) {
|
|
continue;
|
|
}
|
|
|
|
if (${a}) {
|
|
float dyValue = getDy(b, yR, yC, d2);
|
|
float xValue = getX(b, xR, xC, d1);
|
|
dotProd += (xValue * dyValue);
|
|
} else {
|
|
float dyValue = getDy(b, d2, yR, yC);
|
|
float xValue = getX(b, d1, xR, xC);
|
|
dotProd += (xValue * dyValue);
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|
|
setOutput(dotProd);
|
|
}
|
|
`}},CY=class{constructor(e){this.variableNames=["dy","W"],this.outputShape=e.inShape;let t=e.filterHeight,n=e.filterWidth,s=e.strideHeight,r=e.strideWidth,a=e.dataFormat==="channelsLast",o=t-1-e.padInfo.top,i=n-1-e.padInfo.left,l=a?1:2,u=a?2:3,c=a?3:1;this.userCode=`
|
|
const ivec2 pads = ivec2(${o}, ${i});
|
|
|
|
void main() {
|
|
ivec4 coords = getOutputCoords();
|
|
int batch = coords[0];
|
|
int d1 = coords[${c}];
|
|
|
|
ivec2 dyCorner = ivec2(coords[${l}], coords[${u}]) - pads;
|
|
int dyRCorner = dyCorner.x;
|
|
int dyCCorner = dyCorner.y;
|
|
|
|
// Convolve dy(?, ?, d2) with w(:, :, d1, d2) to compute dx(xR, xC, d1).
|
|
// ? = to be determined. : = across all values in that axis.
|
|
float dotProd = 0.0;
|
|
for (int wR = 0; wR < ${t}; wR++) {
|
|
float dyR = float(dyRCorner + wR) / ${s}.0;
|
|
|
|
if (dyR < 0.0 || dyR >= ${e.outHeight}.0 || fract(dyR) > 0.0) {
|
|
continue;
|
|
}
|
|
int idyR = int(dyR);
|
|
|
|
int wRPerm = ${t} - 1 - wR;
|
|
|
|
for (int wC = 0; wC < ${n}; wC++) {
|
|
float dyC = float(dyCCorner + wC) / ${r}.0;
|
|
|
|
if (dyC < 0.0 || dyC >= ${e.outWidth}.0 ||
|
|
fract(dyC) > 0.0) {
|
|
continue;
|
|
}
|
|
int idyC = int(dyC);
|
|
|
|
int wCPerm = ${n} - 1 - wC;
|
|
|
|
for (int d2 = 0; d2 < ${e.outChannels}; d2++) {
|
|
|
|
if (${a}) {
|
|
float xValue = getDy(batch, idyR, idyC, d2);
|
|
float wValue = getW(wRPerm, wCPerm, d1, d2);
|
|
dotProd += xValue * wValue;
|
|
} else {
|
|
float xValue = getDy(batch, d2, idyR, idyC);
|
|
float wValue = getW(wRPerm, wCPerm, d1, d2);
|
|
dotProd += xValue * wValue;
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|
|
setOutput(dotProd);
|
|
}
|
|
`}},TY=class{constructor(e){this.variableNames=["x","dy"],this.outputShape=e.filterShape;let t=e.strideDepth,n=e.strideHeight,s=e.strideWidth,r=e.padInfo.front,a=e.padInfo.top,o=e.padInfo.left;this.userCode=`
|
|
void main() {
|
|
ivec5 coords = getOutputCoords();
|
|
int wF = coords.x;
|
|
int wR = coords.y;
|
|
int wC = coords.z;
|
|
int d1 = coords.w;
|
|
int d2 = coords.u;
|
|
|
|
float dotProd = 0.0;
|
|
|
|
for (int b = 0; b < ${e.batchSize}; b++) {
|
|
for (int yF = 0; yF < ${e.outDepth}; yF++) {
|
|
int xF = wF + yF * ${t} - ${r};
|
|
|
|
if (xF < 0 || xF >= ${e.inDepth}) {
|
|
continue;
|
|
}
|
|
|
|
for (int yR = 0; yR < ${e.outHeight}; yR++) {
|
|
int xR = wR + yR * ${n} - ${a};
|
|
|
|
if (xR < 0 || xR >= ${e.inHeight}) {
|
|
continue;
|
|
}
|
|
|
|
for (int yC = 0; yC < ${e.outWidth}; yC++) {
|
|
int xC = wC + yC * ${s} - ${o};
|
|
|
|
if (xC < 0 || xC >= ${e.inWidth}) {
|
|
continue;
|
|
}
|
|
|
|
float dyValue = getDy(b, yF, yR, yC, d2);
|
|
float xValue = getX(b, xF, xR, xC, d1);
|
|
dotProd += (xValue * dyValue);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
setOutput(dotProd);
|
|
}
|
|
`}},NY=class{constructor(e){this.variableNames=["dy","W"],this.outputShape=e.inShape;let t=e.filterDepth,n=e.filterHeight,s=e.filterWidth,r=e.strideDepth,a=e.strideHeight,o=e.strideWidth,i=t-1-e.padInfo.front,l=n-1-e.padInfo.top,u=s-1-e.padInfo.left;this.userCode=`
|
|
const ivec3 pads = ivec3(${i}, ${l}, ${u});
|
|
|
|
void main() {
|
|
ivec5 coords = getOutputCoords();
|
|
int batch = coords.x;
|
|
int d1 = coords.u;
|
|
|
|
|
|
ivec3 dyCorner = ivec3(coords.y, coords.z, coords.w) - pads;
|
|
int dyFCorner = dyCorner.x;
|
|
int dyRCorner = dyCorner.y;
|
|
int dyCCorner = dyCorner.z;
|
|
|
|
float dotProd = 0.0;
|
|
for (int wF = 0; wF < ${t}; wF++) {
|
|
float dyF = float(dyFCorner + wF) / ${r}.0;
|
|
|
|
if (dyF < 0.0 || dyF >= ${e.outDepth}.0 || fract(dyF) > 0.0) {
|
|
continue;
|
|
}
|
|
int idyF = int(dyF);
|
|
|
|
int wFPerm = ${t} - 1 - wF;
|
|
|
|
for (int wR = 0; wR < ${n}; wR++) {
|
|
float dyR = float(dyRCorner + wR) / ${a}.0;
|
|
|
|
if (dyR < 0.0 || dyR >= ${e.outHeight}.0 ||
|
|
fract(dyR) > 0.0) {
|
|
continue;
|
|
}
|
|
int idyR = int(dyR);
|
|
|
|
int wRPerm = ${n} - 1 - wR;
|
|
|
|
for (int wC = 0; wC < ${s}; wC++) {
|
|
float dyC = float(dyCCorner + wC) / ${o}.0;
|
|
|
|
if (dyC < 0.0 || dyC >= ${e.outWidth}.0 ||
|
|
fract(dyC) > 0.0) {
|
|
continue;
|
|
}
|
|
int idyC = int(dyC);
|
|
|
|
int wCPerm = ${s} - 1 - wC;
|
|
|
|
for (int d2 = 0; d2 < ${e.outChannels}; d2++) {
|
|
float xValue = getDy(batch, idyF, idyR, idyC, d2);
|
|
float wValue = getW(wFPerm, wRPerm, wCPerm, d1, d2);
|
|
dotProd += xValue * wValue;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
setOutput(dotProd);
|
|
}
|
|
`}};function EY(e){let{inputs:t,backend:n,attrs:s}=e,{x:r,dy:a}=t,{strides:o,pad:i,dataFormat:l,dimRoundingMode:u,filterShape:c}=s,d=_.convertConv2DDataFormat(l),p=_.computeConv2DInfo(r.shape,c,o,1,i,u,!1,d),h=new SY(p);return n.runWebGLProgram(h,[r,a],"float32")}var RY={kernelName:yp,backendName:"webgl",kernelFunc:EY};function DY(e){let{inputs:t,backend:n,attrs:s}=e,{dy:r,filter:a}=t,{inputShape:o,strides:i,pad:l,dataFormat:u,dimRoundingMode:c}=s,d=_.convertConv2DDataFormat(u),p=_.computeConv2DInfo(o,a.shape,i,1,l,c,!1,d),h=new CY(p);return n.runWebGLProgram(h,[r,a],"float32")}var _Y={kernelName:Wa,backendName:"webgl",kernelFunc:DY};function $Y(e){let{inputs:t,backend:n,attrs:s}=e,{x:r,filter:a}=t,{strides:o,pad:i,dilations:l}=s,u=_.computeConv3DInfo(r.shape,a.shape,o,l,i),c=new vY(u);return n.runWebGLProgram(c,[r,a],"float32")}var FY={kernelName:Qu,backendName:"webgl",kernelFunc:$Y};function OY(e){let{inputs:t,backend:n,attrs:s}=e,{x:r,dy:a}=t,{strides:o,pad:i,filterShape:l}=s,u=_.computeConv3DInfo(r.shape,l,o,1,i),c=new TY(u);return n.runWebGLProgram(c,[r,a],"float32")}var PY={kernelName:xp,backendName:"webgl",kernelFunc:OY};function MY(e){let{inputs:t,backend:n,attrs:s}=e,{dy:r,filter:a}=t,{pad:o,strides:i,inputShape:l}=s,u=_.computeConv3DInfo(l,a.shape,i,1,o),c=new NY(u);return n.runWebGLProgram(c,[r,a],"float32")}var zY={kernelName:bp,backendName:"webgl",kernelFunc:MY},LY=f4+`
|
|
return cos(x);
|
|
`,BY=tt({opSnippet:LY}),WY={kernelName:Va,backendName:"webgl",kernelFunc:BY},VY=`
|
|
float e2x = exp(-x);
|
|
return (e2x + 1.0 / e2x) / 2.0;
|
|
`,UY=tt({opSnippet:VY}),HY={kernelName:Ua,backendName:"webgl",kernelFunc:UY},GY=class{constructor(e,t,n,s,r){this.variableNames=["Image","Boxes","BoxInd"],this.outputShape=[];let[a,o,i,l]=e,[u]=t,[c,d]=n;this.outputShape=[u,c,d,l];let p=s==="bilinear"?1:0,[h,f]=[`${o-1}.0`,`${i-1}.0`],[m,g,A]=c>1?[`${(o-1)/(c-1)}`,"(y2-y1) * height_ratio",`y1*${h} + float(y)*(height_scale)`]:["0.0","0.0",`0.5 * (y1+y2) * ${h}`],[y,x,b]=d>1?[`${(i-1)/(d-1)}`,"(x2-x1) * width_ratio",`x1*${f} + float(x)*(width_scale)`]:["0.0","0.0",`0.5 * (x1+x2) * ${f}`];this.userCode=`
|
|
const float height_ratio = float(${m});
|
|
const float width_ratio = float(${y});
|
|
void main() {
|
|
ivec4 coords = getOutputCoords();
|
|
int b = coords[0];
|
|
int y = coords[1];
|
|
int x = coords[2];
|
|
int d = coords[3];
|
|
|
|
// get box vals
|
|
float y1 = getBoxes(b,0);
|
|
float x1 = getBoxes(b,1);
|
|
float y2 = getBoxes(b,2);
|
|
float x2 = getBoxes(b,3);
|
|
|
|
// get image in batch index
|
|
int bInd = round(getBoxInd(b));
|
|
if(bInd < 0 || bInd >= ${a}) {
|
|
return;
|
|
}
|
|
|
|
float height_scale = ${g};
|
|
float width_scale = ${x};
|
|
|
|
float in_y = ${A};
|
|
if( in_y < 0.0 || in_y > ${h} ) {
|
|
setOutput(float(${r}));
|
|
return;
|
|
}
|
|
float in_x = ${b};
|
|
if( in_x < 0.0 || in_x > ${f} ) {
|
|
setOutput(float(${r}));
|
|
return;
|
|
}
|
|
|
|
vec2 sourceFracIndexCR = vec2(in_x,in_y);
|
|
if(${p} == 1) {
|
|
// Compute the four integer indices.
|
|
ivec2 sourceFloorCR = ivec2(sourceFracIndexCR);
|
|
ivec2 sourceCeilCR = ivec2(ceil(sourceFracIndexCR));
|
|
|
|
float topLeft = getImage(b, sourceFloorCR.y, sourceFloorCR.x, d);
|
|
float bottomLeft = getImage(b, sourceCeilCR.y, sourceFloorCR.x, d);
|
|
float topRight = getImage(b, sourceFloorCR.y, sourceCeilCR.x, d);
|
|
float bottomRight = getImage(b, sourceCeilCR.y, sourceCeilCR.x, d);
|
|
|
|
vec2 fracCR = sourceFracIndexCR - vec2(sourceFloorCR);
|
|
|
|
float top = topLeft + (topRight - topLeft) * fracCR.x;
|
|
float bottom = bottomLeft + (bottomRight - bottomLeft) * fracCR.x;
|
|
float newValue = top + (bottom - top) * fracCR.y;
|
|
setOutput(newValue);
|
|
} else {
|
|
// Compute the coordinators of nearest neighbor point.
|
|
ivec2 sourceNearestCR = ivec2(floor(
|
|
sourceFracIndexCR + vec2(0.5,0.5)));
|
|
float newValue = getImage(b, sourceNearestCR.y, sourceNearestCR.x, d);
|
|
setOutput(newValue);
|
|
}
|
|
}
|
|
`}},jY=e=>{let{inputs:t,backend:n,attrs:s}=e,{image:r,boxes:a,boxInd:o}=t,{cropSize:i,method:l,extrapolationValue:u}=s,c=new GY(r.shape,a.shape,i,l,u);return n.runWebGLProgram(c,[r,a,o],"float32")},qY={kernelName:ji,backendName:"webgl",kernelFunc:jY},$4=class{constructor(e,t,n){this.variableNames=["x"],this.customUniforms=[{name:"index",type:"float"}],this.outputShape=e;let s=e.length,r=t?"0.0":`getX(${F4(s,"coords")})`,a=e[e.length-1],o="",i="";t?(o=n?`end != ${a-1}`:"end != 0",i=n?"end + 1":"end - 1"):(o=n?`end + pow2 < ${a}`:"end >= pow2",i=n?"end + pow2":"end - pow2"),this.userCode=`
|
|
void main() {
|
|
${gt(s)} coords = getOutputCoords();
|
|
int end = ${O4(s,"coords")};
|
|
float val = ${r};
|
|
int pow2 = int(pow(2.0, index));
|
|
if (${o}) {
|
|
int idx = ${i};
|
|
${O4(s,"coords")} = idx;
|
|
val += getX(${F4(s,"coords")});
|
|
}
|
|
setOutput(val);
|
|
}
|
|
`}};function F4(e,t){if(e===1)return`${t}`;if(e===2)return`${t}.x, ${t}.y`;if(e===3)return`${t}.x, ${t}.y, ${t}.z`;if(e===4)return`${t}.x, ${t}.y, ${t}.z, ${t}.w`;throw Error(`Cumulative sum for rank ${e} is not yet supported`)}function O4(e,t){if(e===1)return`${t}`;if(e===2)return`${t}.y`;if(e===3)return`${t}.z`;if(e===4)return`${t}.w`;throw Error(`Cumulative sum for rank ${e} is not yet supported`)}function XY(e){let{inputs:t,backend:n,attrs:s}=e,{x:r}=t,{axis:a,exclusive:o,reverse:i}=s,l=r.shape.length,u=_.getAxesPermutation([a],l),c=r;u!=null&&(c=Dn({inputs:{x:r},backend:n,attrs:{perm:u}}));let d=_.getInnerMostAxes(1,l)[0];if(d!==l-1)throw new Error(`WebGL cumsum shader expects an inner-most axis=${r.shape.length-1} but got axis=${a}`);let p=c.shape[d],h=ds({inputs:{x:c},backend:n});for(let f=0;f<=Math.ceil(Math.log2(p))-1;f++){let m=new $4(c.shape,!1,i),g=[[f]],A=h;h=n.runWebGLProgram(m,[h],h.dtype,g),n.disposeIntermediateTensorInfo(A)}if(o){let f=new $4(c.shape,o,i),m=h;h=n.runWebGLProgram(f,[h],h.dtype),n.disposeIntermediateTensorInfo(m)}if(u!=null){let f=_.getUndoAxesPermutation(u),m=Dn({inputs:{x:h},backend:n,attrs:{perm:f}});return n.disposeIntermediateTensorInfo(h),n.disposeIntermediateTensorInfo(c),m}return h}var KY={kernelName:Ha,backendName:"webgl",kernelFunc:XY};function ZY(e){let{inputs:t,backend:n,attrs:s}=e,{x:r,weights:a}=t,{size:o,binaryOutput:i}=s;if(r.shape.length===1){let l=n.readSync(r.dataId),u=n.readSync(a.dataId),c=Q6(l,u,a.dtype,a.shape,o);return n.makeTensorInfo([o],a.dtype,c)}else if(r.shape.length===2){let l=n.bufferSync(r),u=n.bufferSync(a),c=uX(l,u,o,i);return n.makeTensorInfo(c.shape,a.dtype,c.values)}throw new Error(`Error in denseBincount: input must be at most rank 2, but got rank${r.shape.length}.`)}var YY={kernelName:vp,backendName:"webgl",kernelFunc:ZY},JY=class{constructor(e,t,n){this.variableNames=["x"],this.outputShape=[],this.outputShape=e,this.blockSize=t,this.dataFormat=n,this.userCode=`
|
|
void main() {
|
|
ivec4 coords = getOutputCoords();
|
|
int b = coords[0];
|
|
int h = ${this.getHeightCoordString()};
|
|
int w = ${this.getWidthCoordString()};
|
|
int d = ${this.getDepthCoordString()};
|
|
|
|
int in_h = h / ${t};
|
|
int offset_h = imod(h, ${t});
|
|
int in_w = w / ${t};
|
|
int offset_w = imod(w, ${t});
|
|
int offset_d = (offset_h * ${t} + offset_w) *
|
|
${this.getOutputDepthSize()};
|
|
int in_d = d + offset_d;
|
|
|
|
float result = ${this.getInputSamplingString()};
|
|
setOutput(result);
|
|
}
|
|
`}getHeightCoordString(){return this.dataFormat==="NHWC"?"coords[1]":"coords[2]"}getWidthCoordString(){return this.dataFormat==="NHWC"?"coords[2]":"coords[3]"}getDepthCoordString(){return this.dataFormat==="NHWC"?"coords[3]":"coords[1]"}getOutputDepthSize(){return this.dataFormat==="NHWC"?this.outputShape[3]:this.outputShape[1]}getInputSamplingString(){return this.dataFormat==="NHWC"?"getX(b, in_h, in_w, in_d)":"getX(b, in_d, in_h, in_w)"}};function QY(e){let{inputs:t,backend:n,attrs:s}=e,{x:r}=t,{blockSize:a,dataFormat:o}=s;w.assert(a>1,()=>`blockSize should be > 1 for depthToSpace, but was: ${a}`);let i=r.shape[0],l=o==="NHWC"?r.shape[1]:r.shape[2],u=o==="NHWC"?r.shape[2]:r.shape[3],c=o==="NHWC"?r.shape[3]:r.shape[1],d=l*a,p=u*a,h=c/(a*a),f=o==="NHWC"?[i,d,p,h]:[i,h,d,p],m=new JY(f,a,o);return n.runWebGLProgram(m,[r],r.dtype)}var eJ={kernelName:qi,backendName:"webgl",kernelFunc:QY},P4=class{constructor(e,t=!1,n=null,s=!1,r=!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=Ss(this.outputShape.length);let a=e.filterHeight,o=e.filterWidth,i=e.outChannels/e.inChannels,l="",u="";n&&(s?l=`float activation(float a) {
|
|
float b = getPreluActivationWeightsAtOutCoords();
|
|
${n}
|
|
}`:r?l=`float activation(float a) {
|
|
float b = getLeakyreluAlphaAtOutCoords();
|
|
${n}
|
|
}`:l=`
|
|
float activation(float x) {
|
|
${n}
|
|
}
|
|
`,u="result = activation(result);");let c=t?"result += getBiasAtOutCoords();":"";t&&this.variableNames.push("bias"),s&&this.variableNames.push("preluActivationWeights"),r&&this.variableNames.push("leakyreluAlpha"),this.userCode=`
|
|
${l}
|
|
|
|
void main() {
|
|
ivec4 coords = getOutputCoords();
|
|
int batch = coords.x;
|
|
ivec2 xRCCorner = coords.yz * strides - pads;
|
|
int d2 = coords.w;
|
|
int d1 = d2 / ${i};
|
|
int q = d2 - d1 * ${i};
|
|
|
|
int xRCorner = xRCCorner.x;
|
|
int xCCorner = xRCCorner.y;
|
|
|
|
// Convolve x(?, ?, d1) with w(:, :, d1, q) to get y(yR, yC, d2).
|
|
// ? = to be determined. : = across all values in that axis.
|
|
float dotProd = 0.0;
|
|
// TO DO(dsmilkov): Flatten the two for loops and vec4 the operations.
|
|
for (int wR = 0; wR < ${a}; wR++) {
|
|
int xR = xRCorner + wR * dilations[0];
|
|
|
|
if (xR < 0 || xR >= inDims[0]) {
|
|
continue;
|
|
}
|
|
|
|
for (int wC = 0; wC < ${o}; wC++) {
|
|
int xC = xCCorner + wC * dilations[1];
|
|
|
|
if (xC < 0 || xC >= inDims[1]) {
|
|
continue;
|
|
}
|
|
|
|
float xVal = getX(batch, xR, xC, d1);
|
|
float wVal = getW(wR, wC, d1, q);
|
|
dotProd += xVal * wVal;
|
|
}
|
|
}
|
|
|
|
float result = dotProd;
|
|
${c}
|
|
${u}
|
|
setOutput(result);
|
|
}
|
|
`}},M4=class{constructor(e,t=!1,n=null,s=!1,r=!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=Ss(this.outputShape.length);let a=e.outChannels/e.inChannels,o=e.padInfo.left,i=e.strideWidth,l=e.dilationWidth,u=e.filterHeight,c=e.filterWidth,d=c,p=`
|
|
int xR; int xC; int xCOffset;
|
|
vec4 wTexel; vec4 previous; vec4 final;`;for(let g=0;g<c;g++)p+=`
|
|
vec4 xTexelC${g*2};
|
|
int xTexelC${g*2}Ready;
|
|
vec4 xTexelC${g*2+1};
|
|
int xTexelC${g*2+1}Ready;
|
|
vec4 xC${g};`;for(let g=0;g<u;g++){for(let A=0;A<c;A++)p+=`
|
|
xTexelC${A*2} = vec4(0.0);
|
|
xTexelC${A*2}Ready = 0;
|
|
xTexelC${A*2+1} = vec4(0.0);
|
|
xTexelC${A*2+1}Ready = 0;
|
|
xC${A} = vec4(0.0);`;p+=`
|
|
xR = xRCorner + ${g} * dilations[0];
|
|
if (xR >=0 && xR < inDims[0]) {
|
|
`;for(let A=0;A<(d+1)/2;A++){let y=A*2;if(p+=`
|
|
xC = xCCorner + ${y*l};
|
|
`,i===1){if(y<c&&(o%2==1?(p+=`
|
|
xCOffset = xC + 1;
|
|
if (xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${y}Ready == 0) {
|
|
xTexelC${y} = getX(batch, xR, xCOffset, d1);
|
|
|
|
// Need to manually clear unused channels in case
|
|
// we're reading from recycled texture.
|
|
if (xCOffset + 1 >= inDims[1]) {
|
|
xTexelC${y}.zw = vec2(0.0);
|
|
}
|
|
xTexelC${y}Ready = 1;
|
|
}
|
|
`,l===1&&y>0?p+=`
|
|
xC${y} = vec4(xTexelC${y-2}.zw, xTexelC${y}.xy);
|
|
`:p+=`
|
|
xCOffset = xC + 1 - 2;
|
|
|
|
if (xCOffset >= 0 && xCOffset < inDims[1]) {
|
|
previous = getX(batch, xR, xCOffset, d1);
|
|
|
|
// Need to manually clear unused channels in case
|
|
// we're reading from recycled texture.
|
|
if (xCOffset + 1 >= inDims[1]) {
|
|
previous.zw = vec2(0.0);
|
|
}
|
|
|
|
xC${y} = vec4(previous.zw, xTexelC${y}.xy);
|
|
} else {
|
|
xC${y} = vec4(0.0, 0.0, xTexelC${y}.xy);
|
|
}
|
|
`):p+=`
|
|
if (xC >= 0 && xC < inDims[1] && xTexelC${y}Ready == 0) {
|
|
xTexelC${y} = getX(batch, xR, xC, d1);
|
|
if (xC + 1 >= inDims[1]) {
|
|
xTexelC${y}.zw = vec2(0.0);
|
|
}
|
|
xTexelC${y}Ready = 1;
|
|
}
|
|
|
|
xC${y} = xTexelC${y};
|
|
`,y+1<c)){let x=o%2==0?w.nearestLargerEven(l):l;l%2==0&&o%2==1||l%2!=0&&o%2!=1?(p+=`
|
|
xCOffset = xC + imod(pads[1], 2) + ${x};
|
|
|
|
if (xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${y+1}Ready == 0) {
|
|
xTexelC${y+1} = getX(batch, xR, xCOffset, d1);
|
|
|
|
// Need to manually clear unused channels in case
|
|
// we're reading from recycled texture.
|
|
if (xCOffset + 1 >= inDims[1]) {
|
|
xTexelC${y+1}.zw = vec2(0.0);
|
|
}
|
|
xTexelC${y+1}Ready = 1;
|
|
}
|
|
`,l>1&&(p+=`
|
|
xCOffset -= 2;
|
|
if (xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${y}Ready == 0) {
|
|
xTexelC${y} = getX(batch, xR, xCOffset, d1);
|
|
xTexelC${y}Ready = 1;
|
|
}
|
|
`),p+=`
|
|
xC${y+1} = vec4(xTexelC${y}.zw, xTexelC${y+1}.xy);
|
|
`):x===1?p+=`
|
|
xC${y+1} = xTexelC${y};
|
|
`:p+=`
|
|
xCOffset = xC + ${x};
|
|
|
|
if (xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${y+1}Ready == 0) {
|
|
xTexelC${y+1} = getX(batch, xR, xCOffset, d1);
|
|
if (xCOffset + 1 >= inDims[1]) {
|
|
xTexelC${y+1}.zw = vec2(0.0);
|
|
}
|
|
xTexelC${y+1}Ready = 1;
|
|
}
|
|
|
|
xC${y+1} = xTexelC${y+1};
|
|
`}}else y<c&&(o%2==1?(p+=`
|
|
xCOffset = xC + 1 - strides[1];
|
|
if(xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${y}Ready == 0) {
|
|
xTexelC${y} = getX(batch, xR, xCOffset, d1);
|
|
// Need to manually clear unused channels in case
|
|
// we're reading from recycled texture.
|
|
if (xCOffset + 1 >= inDims[1]) {
|
|
xTexelC${y}.zw = vec2(0.0);
|
|
}
|
|
xTexelC${y}Ready = 1;
|
|
}
|
|
|
|
if(xC + 1 >= 0 && xC + 1 < inDims[1] && xTexelC${y+1}Ready == 0) {
|
|
xTexelC${y+1} = getX(batch, xR, xC + 1, d1);
|
|
// Need to manually clear unused channels in case
|
|
// we're reading from recycled texture.
|
|
if (xC + 2 >= inDims[1]) {
|
|
xTexelC${y+1}.zw = vec2(0.0);
|
|
}
|
|
xTexelC${y+1}Ready = 1;
|
|
}
|
|
|
|
xC${y} = vec4(xTexelC${y}.zw, xTexelC${y+1}.zw);
|
|
`,y+1<c&&(p+=`
|
|
final = vec4(0.0);
|
|
xCOffset = xC + 1 + strides[1];
|
|
if(xCOffset >= 0 && xCOffset < inDims[1]) {
|
|
final = getX(batch, xR, xCOffset, d1);
|
|
}
|
|
xC${y+1} = vec4(xTexelC${y+1}.xy, final.xy);
|
|
`)):(p+=`
|
|
if(xC >= 0 && xC < inDims[1] && xTexelC${y}Ready == 0) {
|
|
xTexelC${y} = getX(batch, xR, xC, d1);
|
|
if (xC + 1 >= inDims[1]) {
|
|
xTexelC${y}.zw = vec2(0.0);
|
|
}
|
|
xTexelC${y}Ready = 1;
|
|
}
|
|
|
|
xCOffset = xC + strides[1];
|
|
if(xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${y+1}Ready == 0) {
|
|
xTexelC${y+1} = getX(batch, xR, xCOffset, d1);
|
|
if (xCOffset + 1 >= inDims[1]) {
|
|
xTexelC${y+1}.zw = vec2(0.);
|
|
}
|
|
xTexelC${y+1}Ready = 1;
|
|
}
|
|
|
|
xC${y} = vec4(
|
|
xTexelC${y}.xy, xTexelC${y+1}.xy);
|
|
`,y+1<c&&(p+=`
|
|
xC${y+1} = vec4(xTexelC${y}.zw, xTexelC${y+1}.zw);
|
|
`)));y<c&&(p+=`
|
|
wTexel = getW(${g}, ${y}, d1, q);
|
|
dotProd += xC${y} * vec4(wTexel.xz, wTexel.xz);
|
|
`,y+1<c&&(p+=`
|
|
wTexel = getW(${g}, ${y+1}, d1, q);
|
|
dotProd += xC${y+1} * vec4(wTexel.xz, wTexel.xz);
|
|
`))}p+=`
|
|
}
|
|
`}let h="",f="";n&&(s?h=`vec4 activation(vec4 a) {
|
|
vec4 b = getPreluActivationWeightsAtOutCoords();
|
|
${n}
|
|
}`:r?h=`vec4 activation(vec4 a) {
|
|
vec4 b = getLeakyreluAlphaAtOutCoords();
|
|
${n}
|
|
}`:h=`vec4 activation(vec4 x) {
|
|
${n}
|
|
}`,f="result = activation(result);");let m=t?"result += getBiasAtOutCoords();":"";t&&this.variableNames.push("bias"),s&&this.variableNames.push("preluActivationWeights"),r&&this.variableNames.push("leakyreluAlpha"),this.userCode=`
|
|
${h}
|
|
|
|
void main() {
|
|
ivec4 coords = getOutputCoords();
|
|
int batch = coords.x;
|
|
ivec2 xRCCorner = coords.yz * strides - pads;
|
|
int d2 = coords.w;
|
|
int d1 = d2 / ${a};
|
|
int q = d2 - d1 * ${a};
|
|
int xRCorner = xRCCorner.x;
|
|
int xCCorner = xRCCorner.y;
|
|
|
|
//intialize dotProd with a small epsilon seems to reduce GPU accuracy loss.
|
|
vec4 dotProd = vec4(0.000000000000001);
|
|
|
|
${p}
|
|
|
|
vec4 result = dotProd - vec4(0.000000000000001);
|
|
${m}
|
|
${f}
|
|
setOutput(result);
|
|
}
|
|
`}};function tJ(e){let{inputs:t,backend:n,attrs:s}=e,{x:r,filter:a}=t,{strides:o,pad:i,dilations:l,dimRoundingMode:u}=s,c=l;c==null&&(c=[1,1]),w.assert(_.eitherStridesOrDilationsAreOne(o,c),()=>`Error in depthwiseConv2d: Either strides or dilations must be 1. Got strides ${o} and dilations '${c}'`);let d=_.computeConv2DInfo(r.shape,a.shape,o,c,i,u,!0),p;Y().getBool("WEBGL_PACK_DEPTHWISECONV")&&d.strideWidth<=2&&d.outChannels/d.inChannels==1?p=new M4(d):p=new P4(d);let h=[[d.padInfo.top,d.padInfo.left],[d.strideHeight,d.strideWidth],[d.dilationHeight,d.dilationWidth],[d.inHeight,d.inWidth]];return n.runWebGLProgram(p,[r,a],"float32",h)}var nJ={kernelName:Ga,backendName:"webgl",kernelFunc:tJ},sJ=class{constructor(e){this.variableNames=["x","dy"],this.outputShape=e.filterShape;let t=e.strideHeight,n=e.strideWidth,s=e.padInfo.top,r=e.padInfo.left,a=e.outChannels/e.inChannels;this.userCode=`
|
|
void main() {
|
|
ivec4 coords = getOutputCoords();
|
|
int wR = coords.x;
|
|
int wC = coords.y;
|
|
int d1 = coords.z;
|
|
int dm = coords.w;
|
|
int d2 = d1 * ${a} + dm;
|
|
|
|
float dotProd = 0.0;
|
|
|
|
// TO DO: Vec4 over the batch size
|
|
for (int b = 0; b < ${e.batchSize}; b++) {
|
|
for (int yR = 0; yR < ${e.outHeight}; yR++) {
|
|
int xR = wR + yR * ${t} - ${s};
|
|
|
|
if (xR < 0 || xR >= ${e.inHeight}) {
|
|
continue;
|
|
}
|
|
|
|
for (int yC = 0; yC < ${e.outWidth}; yC++) {
|
|
int xC = wC + yC * ${n} - ${r};
|
|
|
|
if (xC < 0 || xC >= ${e.inWidth}) {
|
|
continue;
|
|
}
|
|
|
|
float dyValue = getDy(b, yR, yC, d2);
|
|
float xValue = getX(b, xR, xC, d1);
|
|
dotProd += (xValue * dyValue);
|
|
}
|
|
}
|
|
}
|
|
setOutput(dotProd);
|
|
}
|
|
`}},rJ=class{constructor(e){this.variableNames=["dy","W"],this.outputShape=e.inShape;let t=e.filterHeight,n=e.filterWidth,s=e.strideHeight,r=e.strideWidth,a=t-1-e.padInfo.top,o=n-1-e.padInfo.left,i=e.outChannels/e.inChannels;this.userCode=`
|
|
const ivec2 pads = ivec2(${a}, ${o});
|
|
|
|
void main() {
|
|
ivec4 coords = getOutputCoords();
|
|
int batch = coords[0];
|
|
int d1 = coords[3];
|
|
ivec2 dyCorner = coords.yz - pads;
|
|
int dyRCorner = dyCorner.x;
|
|
int dyCCorner = dyCorner.y;
|
|
|
|
float dotProd = 0.0;
|
|
|
|
for (int wR = 0; wR < ${t}; wR++) {
|
|
float dyR = float(dyRCorner + wR) / ${s}.0;
|
|
|
|
if (dyR < 0.0 || dyR >= ${e.outHeight}.0 || fract(dyR) > 0.0) {
|
|
continue;
|
|
}
|
|
int idyR = int(dyR);
|
|
|
|
int wRPerm = ${t} - 1 - wR;
|
|
|
|
for (int wC = 0; wC < ${n}; wC++) {
|
|
float dyC = float(dyCCorner + wC) / ${r}.0;
|
|
|
|
if (dyC < 0.0 || dyC >= ${e.outWidth}.0 ||
|
|
fract(dyC) > 0.0) {
|
|
continue;
|
|
}
|
|
int idyC = int(dyC);
|
|
|
|
int wCPerm = ${n} - 1 - wC;
|
|
|
|
// TO DO: Vec4 over the channelMul
|
|
for (int dm = 0; dm < ${i}; dm++) {
|
|
int d2 = d1 * ${i} + dm;
|
|
float xValue = getDy(batch, idyR, idyC, d2);
|
|
float wValue = getW(wRPerm, wCPerm, d1, dm);
|
|
dotProd += xValue * wValue;
|
|
}
|
|
}
|
|
}
|
|
setOutput(dotProd);
|
|
}
|
|
`}};function aJ(e){let{inputs:t,backend:n,attrs:s}=e,{x:r,dy:a}=t,{strides:o,dilations:i,pad:l,dimRoundingMode:u,filterShape:c}=s,d=_.computeConv2DInfo(r.shape,c,o,i,l,u,!0),p=new sJ(d);return n.runWebGLProgram(p,[r,a],"float32")}var oJ={kernelName:wp,backendName:"webgl",kernelFunc:aJ};function iJ(e){let{inputs:t,backend:n,attrs:s}=e,{dy:r,filter:a}=t,{strides:o,dilations:i,pad:l,dimRoundingMode:u,inputShape:c}=s,d=_.computeConv2DInfo(c,a.shape,o,i,l,u,!0),p=new rJ(d);return n.runWebGLProgram(p,[r,a],"float32")}var lJ={kernelName:kp,backendName:"webgl",kernelFunc:iJ},uJ=class{constructor(e){this.variableNames=["X"],this.outputShape=[e,e],this.userCode=`
|
|
void main() {
|
|
ivec2 coords = getOutputCoords();
|
|
float val = coords[0] == coords[1] ? getX(coords[0]) : 0.0;
|
|
setOutput(val);
|
|
}
|
|
`}};function cJ(e){let{inputs:t,backend:n}=e,{x:s}=t,r=[...s.shape,...s.shape],a=w.sizeFromShape(s.shape),o=be({inputs:{x:s},backend:n,attrs:{shape:[a]}}),i=new uJ(a),l=n.runWebGLProgram(i,[o],o.dtype),u=be({inputs:{x:l},backend:n,attrs:{shape:r}});return n.disposeIntermediateTensorInfo(o),n.disposeIntermediateTensorInfo(l),u}var dJ={kernelName:Ip,backendName:"webgl",kernelFunc:cJ},pJ=class{constructor(e){this.variableNames=["x","W"],this.outputShape=e.outShape;let{inHeight:t,inWidth:n,padInfo:s,strideHeight:r,strideWidth:a,filterHeight:o,filterWidth:i,dilationHeight:l,dilationWidth:u}=e,{top:c,left:d}=s;this.userCode=`
|
|
const ivec2 strides = ivec2(${r}, ${a});
|
|
const ivec2 pads = ivec2(${c}, ${d});
|
|
const float neg_infinity = -3.4e38;
|
|
|
|
void main() {
|
|
ivec4 coords = getOutputCoords();
|
|
int batch = coords.x;
|
|
int d1 = coords.w;
|
|
ivec2 outTopLeftCorner =
|
|
coords.yz * strides - pads;
|
|
int hBeg = outTopLeftCorner.x;
|
|
int wBeg = outTopLeftCorner.y;
|
|
|
|
float curVal = neg_infinity;
|
|
for (int h = 0; h < ${o}; h++) {
|
|
int hIn = hBeg + h * ${l};
|
|
|
|
if (hIn >= 0 && hIn < ${t}) {
|
|
for (int w = 0; w < ${i}; w++) {
|
|
int wIn = wBeg + w * ${u};
|
|
|
|
if (wIn >= 0 && wIn < ${n}) {
|
|
float xVal = getX(batch, hIn, wIn, d1);
|
|
float wVal = getW(h, w, d1);
|
|
|
|
float val = xVal + wVal;
|
|
if (val > curVal) {
|
|
curVal = val;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
float result = curVal;
|
|
setOutput(result);
|
|
}
|
|
`}};function hJ(e){let{inputs:t,backend:n,attrs:s}=e,{x:r,filter:a}=t,{strides:o,pad:i,dilations:l}=s,u=_.computeDilation2DInfo(r.shape,a.shape,o,i,"NHWC",l),c,d=new pJ(u);c=n.runWebGLProgram(d,[r,a],"float32");let p=be({inputs:{x:c},backend:n,attrs:{shape:u.outShape}});return n.disposeIntermediateTensorInfo(c),p}var fJ={kernelName:ec,backendName:"webgl",kernelFunc:hJ};function mJ(e){let{inputs:t,backend:n,attrs:s}=e,{equation:r}=s,a=t,{allDims:o,summedDims:i,idDims:l}=_.decodeEinsumEquation(r,a.length);_.checkEinsumDimSizes(o.length,l,a);let{path:u,steps:c}=_.getEinsumComputePath(i,l),d=c.length,p=null,h=o.length,f=[];for(let m=0;m<d;++m){for(let g of c[m]){let{permutationIndices:A,expandDims:y}=_.getEinsumPermutation(h,l[g]),x;_.isIdentityPermutation(A)?x=a[g]:(x=Dn({inputs:{x:a[g]},backend:n,attrs:{perm:A}}),f.push(x));let b=x.shape.slice();for(let v=0;v<y.length;++v)b.splice(y[v],0,1);w.arraysEqual(x.shape,b)||(x=be({inputs:{x},backend:n,attrs:{shape:b}}),f.push(x)),p===null?p=x:(p=yy({inputs:{a:x,b:p},backend:n}),f.push(p))}m<d-1&&(u[m]>=0&&(p=e0({inputs:{x:p},backend:n,attrs:{axis:u[m]-(o.length-h),keepDims:!1}}),f.push(p)),h--)}for(let m of f)m!==p&&n.disposeIntermediateTensorInfo(m);return p}var gJ={kernelName:Tp,backendName:"webgl",kernelFunc:mJ},AJ="return (x >= 0.0) ? x : (exp(x) - 1.0);",yJ=`
|
|
vec4 result;
|
|
|
|
result.r = (x.r >= 0.0) ? x.r : (exp(x.r) - 1.0);
|
|
result.g = (x.g >= 0.0) ? x.g : (exp(x.g) - 1.0);
|
|
result.b = (x.b >= 0.0) ? x.b : (exp(x.b) - 1.0);
|
|
result.a = (x.a >= 0.0) ? x.a : (exp(x.a) - 1.0);
|
|
|
|
return result;
|
|
`,xJ=tt({opSnippet:AJ,packedOpSnippet:yJ}),bJ={kernelName:qa,backendName:"webgl",kernelFunc:xJ},vJ="return (b >= 1.0) ? a : a * (b + 1.0);",wJ=`
|
|
vec4 bGTEZero = vec4(greaterThanEqual(b, vec4(0.)));
|
|
return (bGTEZero * a) + ((vec4(1.0) - bGTEZero) * (a * (b + vec4(1.0))));
|
|
`,kJ=e=>{let{inputs:t,backend:n}=e,{dy:s,y:r}=t,a=Y().getBool("WEBGL_PACK_BINARY_OPERATIONS")?new yd(wJ,s.shape,r.shape):new wu(vJ,s.shape,r.shape);return n.runWebGLProgram(a,[s,r],s.dtype)},IJ={kernelName:Np,backendName:"webgl",kernelFunc:kJ},SJ=`
|
|
return vec4(equal(a, b));
|
|
`,CJ="return float(a == b);",TJ=An({opSnippet:CJ,packedOpSnippet:SJ,dtype:"bool",cpuKernelImpl:pX}),NJ={kernelName:Ki,backendName:"webgl",kernelFunc:TJ},EJ=`
|
|
// Error function is calculated approximately with elementary function.
|
|
// See "Handbook of Mathematical Functions with Formulas,
|
|
// Graphs, and Mathematical Tables", Abramowitz and Stegun.
|
|
float p = ${_.ERF_P};
|
|
float a1 = ${_.ERF_A1};
|
|
float a2 = ${_.ERF_A2};
|
|
float a3 = ${_.ERF_A3};
|
|
float a4 = ${_.ERF_A4};
|
|
float a5 = ${_.ERF_A5};
|
|
|
|
float sign = sign(x);
|
|
x = abs(x);
|
|
float t = 1.0 / (1.0 + p * x);
|
|
return sign * (1.0 - (((((a5*t + a4)*t) + a3)*t + a2)*t + a1)*t*exp(-x*x));
|
|
`,RJ=tt({opSnippet:EJ}),DJ={kernelName:Xi,backendName:"webgl",kernelFunc:RJ},z4="return exp(x);",L4=tt({opSnippet:z4,packedOpSnippet:z4,cpuKernelImpl:hX}),_J={kernelName:Xa,backendName:"webgl",kernelFunc:L4};function wy(e){let{inputs:t,attrs:n,backend:s}=e,{dim:r}=n,{input:a}=t,o=a.shape.length,i=a.shape.slice(),l=r;return r<0&&(w.assert(-(o+1)<=r,()=>`Axis must be in the interval [${-(o+1)}, ${o}]`),l=o+r+1),i.splice(l,0,1),be({inputs:{x:a},backend:s,attrs:{shape:i}})}var $J={kernelName:Zi,backendName:"webgl",kernelFunc:wy},B4="return exp(x) - 1.0;",FJ=tt({opSnippet:B4,packedOpSnippet:B4,cpuKernelImpl:fX}),OJ={kernelName:Yi,backendName:"webgl",kernelFunc:FJ},W4=class{constructor(e,t,n){this.variableNames=["real","imag"];let s=t[1];this.outputShape=t;let r=n?`2.0 * ${Math.PI}`:`-2.0 * ${Math.PI}`,a=n?`${s}.0`:"1.0",o;if(e==="real")o="return real * expR - imag * expI;";else if(e==="imag")o="return real * expI + imag * expR;";else throw new Error(`FFT component must be either "real" or "imag", got ${e}.`);this.userCode=`
|
|
const float exponentMultiplier = ${r};
|
|
|
|
float unaryOpComplex(float real, float expR, float imag, float expI) {
|
|
${o}
|
|
}
|
|
|
|
float mulMatDFT(int batch, int index) {
|
|
float indexRatio = float(index) / float(${s});
|
|
float exponentMultiplierTimesIndexRatio =
|
|
exponentMultiplier * indexRatio;
|
|
|
|
float result = 0.0;
|
|
|
|
for (int i = 0; i < ${s}; i++) {
|
|
// x = (-2|2 * PI / N) * index * i;
|
|
float x = exponentMultiplierTimesIndexRatio * float(i);
|
|
float expR = cos(x);
|
|
float expI = sin(x);
|
|
float real = getReal(batch, i);
|
|
float imag = getImag(batch, i);
|
|
|
|
result +=
|
|
unaryOpComplex(real, expR, imag, expI) / ${a};
|
|
}
|
|
|
|
return result;
|
|
}
|
|
|
|
void main() {
|
|
ivec2 coords = getOutputCoords();
|
|
setOutput(mulMatDFT(coords[0], coords[1]));
|
|
}
|
|
`}};function V4(e,t,n){let s=n.texData.get(e.dataId),r=w.sizeFromShape(e.shape),a=e.shape[e.shape.length-1],o=r/a,i=be({inputs:{x:e},backend:n,attrs:{shape:[o,a]}}),l=i.shape,u=new W4("real",l,t),c=new W4("imag",l,t),d=[{dataId:s.complexTensorInfos.real.dataId,dtype:s.complexTensorInfos.real.dtype,shape:l},{dataId:s.complexTensorInfos.imag.dataId,dtype:s.complexTensorInfos.imag.dtype,shape:l}],p=n.runWebGLProgram(u,d,"float32"),h=n.runWebGLProgram(c,d,"float32"),f=ka({inputs:{real:p,imag:h},backend:n});n.disposeIntermediateTensorInfo(p),n.disposeIntermediateTensorInfo(h);let m=be({inputs:{x:f},backend:n,attrs:{shape:e.shape}});return n.disposeIntermediateTensorInfo(i),n.disposeIntermediateTensorInfo(f),m}function PJ(e){let{inputs:t,backend:n}=e,{input:s}=t;return V4(s,!1,n)}var MJ={kernelName:Ep,backendName:"webgl",kernelFunc:PJ},zJ=class{constructor(e,t){this.outputShape=[],this.customUniforms=[{name:"value",type:"float"}],this.variableNames=["x"],this.outputShape=e,this.userCode=`
|
|
void main() {
|
|
// Input can be obtained from uniform value.
|
|
setOutput(value);
|
|
}
|
|
`}};function vd(e){let{backend:t,attrs:n}=e,{shape:s,value:r}=n,{dtype:a}=n;if(a=a||w.inferDtype(r),a==="string"){let o=w.getArrayFromDType(a,w.sizeFromShape(s));return o.fill(r),t.makeTensorInfo(s,a,o)}else{let o=new zJ(s,r),i=[[r]];return t.runWebGLProgram(o,[],a,i)}}var LJ={kernelName:tc,backendName:"webgl",kernelFunc:vd},BJ=class{constructor(e){this.variableNames=["Image"],this.outputShape=[];let t=e[2];this.outputShape=e,this.userCode=`
|
|
void main() {
|
|
ivec4 coords = getOutputCoords();
|
|
int x = coords[2];
|
|
|
|
int coordX = ${t} - x - 1;
|
|
float outputValue;
|
|
if(coordX >= 0 && coordX < ${t}) {
|
|
outputValue = getImage(coords[0], coords[1], coordX, coords[3]);
|
|
} else {
|
|
outputValue = getImage(coords[0], coords[1], coords[2], coords[3]);
|
|
}
|
|
setOutput(outputValue);
|
|
}
|
|
`}},WJ={kernelName:Ji,backendName:"webgl",kernelFunc:({inputs:e,backend:t})=>{let{image:n}=e,s=t,r=new BJ(n.shape);return s.runWebGLProgram(r,[n],n.dtype)}},U4="return floor(x);",VJ=tt({opSnippet:U4,packedOpSnippet:U4,cpuKernelImpl:mX}),UJ={kernelName:Ka,backendName:"webgl",kernelFunc:VJ},HJ=`
|
|
float s = sign(a) * sign(b);
|
|
int ia = round(a);
|
|
int ib = round(b);
|
|
if (ib != 0) {
|
|
// Windows (D3D) wants guaranteed non-zero int division at compile-time.
|
|
return float(idiv(ia, ib, s));
|
|
} else {
|
|
return NAN;
|
|
}
|
|
`,GJ=`
|
|
ivec4 ia = round(a);
|
|
ivec4 ib = round(b);
|
|
bvec4 cond = notEqual(ib, ivec4(0));
|
|
ivec4 result = ivec4(0);
|
|
vec4 s = sign(a) * sign(b);
|
|
|
|
// Windows (D3D) wants guaranteed non-zero int division at compile-time.
|
|
if (cond[0]) {
|
|
result[0] = idiv(ia[0], ib[0], s[0]);
|
|
}
|
|
if (cond[1]) {
|
|
result[1] = idiv(ia[1], ib[1], s[1]);
|
|
}
|
|
if (cond[2]) {
|
|
result[2] = idiv(ia[2], ib[2], s[2]);
|
|
}
|
|
if (cond[3]) {
|
|
result[3] = idiv(ia[3], ib[3], s[3]);
|
|
}
|
|
return vec4(result);
|
|
`,jJ=An({opSnippet:HJ,packedOpSnippet:GJ,dtype:"int32"}),qJ={kernelName:Za,backendName:"webgl",kernelFunc:jJ},XJ=class{constructor(e){this.variableNames=["A"];let t=En(),[n,s]=e;this.outputShape=e,this.userCode=`
|
|
void main() {
|
|
ivec3 coords = getOutputCoords();
|
|
int texR = coords[0];
|
|
int texC = coords[1];
|
|
int depth = coords[2];
|
|
vec2 uv = (vec2(texC, texR) + halfCR) / vec2(${s}.0, ${n}.0);
|
|
|
|
vec4 values = ${t.texture2D}(A, uv);
|
|
float value;
|
|
if (depth == 0) {
|
|
value = values.r;
|
|
} else if (depth == 1) {
|
|
value = values.g;
|
|
} else if (depth == 2) {
|
|
value = values.b;
|
|
} else if (depth == 3) {
|
|
value = values.a;
|
|
}
|
|
|
|
setOutput(floor(value * 255.0 + 0.5));
|
|
}
|
|
`}},KJ=class{constructor(e){this.variableNames=["A"],this.packedInputs=!1,this.packedOutput=!0;let t=En(),[n,s]=e;this.outputShape=e,this.userCode=`
|
|
void main() {
|
|
ivec3 coords = getOutputCoords();
|
|
int texR = coords[0];
|
|
int texC = coords[1];
|
|
int depth = coords[2];
|
|
|
|
vec4 result = vec4(0.);
|
|
|
|
for(int row=0; row<=1; row++) {
|
|
for(int col=0; col<=1; col++) {
|
|
texC = coords[1] + row;
|
|
depth = coords[2] + col;
|
|
|
|
vec2 uv = (vec2(texC, texR) + halfCR) /
|
|
vec2(${s}.0, ${n}.0);
|
|
vec4 values = ${t.texture2D}(A, uv);
|
|
float value;
|
|
if (depth == 0) {
|
|
value = values.r;
|
|
} else if (depth == 1) {
|
|
value = values.g;
|
|
} else if (depth == 2) {
|
|
value = values.b;
|
|
} else if (depth == 3) {
|
|
value = values.a;
|
|
}
|
|
|
|
result[row * 2 + col] = floor(value * 255.0 + 0.5);
|
|
}
|
|
}
|
|
|
|
${t.output} = result;
|
|
}
|
|
`}},ZJ={kernelName:Zp,backendName:"webgl",kernelFunc:YJ},Su;function YJ(e){let{inputs:t,backend:n,attrs:s}=e,{pixels:r}=t,{numChannels:a}=s,o=typeof HTMLVideoElement!="undefined"&&r instanceof HTMLVideoElement,i=typeof HTMLImageElement!="undefined"&&r instanceof HTMLImageElement,[l,u]=o?[r.videoWidth,r.videoHeight]:[r.width,r.height],c=[u,l],d=[u,l,a];(i||o)&&(Su==null&&(Su=document.createElement("canvas").getContext("2d")),Su.canvas.width=l,Su.canvas.height=u,Su.drawImage(r,0,0,l,u),r=Su.canvas);let p=n.makeTensorInfo(c,"int32");n.texData.get(p.dataId).usage=ks.PIXELS,n.gpgpu.uploadPixelDataToTexture(n.getTexture(p.dataId),r);let h=Y().getBool("WEBGL_PACK")?new KJ(d):new XJ(d),f=n.runWebGLProgram(h,[p],"int32");return n.disposeData(p.dataId),f}function JJ(e){let{inputs:t,backend:n,attrs:s}=e,{x:r,filter:a,bias:o,preluActivationWeights:i}=t,{strides:l,pad:u,dataFormat:c,dilations:d,dimRoundingMode:p,activation:h,leakyreluAlpha:f}=s,m=_.convertConv2DDataFormat(c),g=_.computeConv2DInfo(r.shape,a.shape,l,d,u,p,!1,m),A,y=[];if(g.filterHeight===1&&g.filterWidth===1&&g.dilationHeight===1&&g.dilationWidth===1&&g.strideHeight===1&&g.strideWidth===1&&(g.padInfo.type==="SAME"||g.padInfo.type==="VALID"))A=D4({x:r,filter:a,convInfo:g,backend:n,bias:o,activation:h,preluActivationWeights:i,leakyreluAlpha:f});else if(Y().getBool("WEBGL_CONV_IM2COL")&&r.shape[0]===1)A=_4({x:r,filter:a,convInfo:g,backend:n,bias:o,activation:h,preluActivationWeights:i,leakyreluAlpha:f});else{let b=o!=null,v=i!=null,k=h==="leakyrelu",S=h?Jf(h,!1):null,C=new R4(g,b,S,v,k),D=[r,a];if(o&&D.push(o),i&&D.push(i),k){let O=n.makeTensorInfo([],"float32",w.createScalarValue(f,"float32"));D.push(O),y.push(O)}A=n.runWebGLProgram(C,D,"float32")}let x=be({inputs:{x:A},backend:n,attrs:{shape:g.outShape}});return y.push(A),y.forEach(b=>n.disposeIntermediateTensorInfo(b)),x}var QJ={kernelName:_o,backendName:"webgl",kernelFunc:JJ};function eQ(e){let{inputs:t,backend:n,attrs:s}=e,{x:r,filter:a,bias:o,preluActivationWeights:i}=t,{strides:l,pad:u,dilations:c,dimRoundingMode:d,activation:p,leakyreluAlpha:h}=s,f=[],m=c;m==null&&(m=[1,1]),w.assert(_.eitherStridesOrDilationsAreOne(l,m),()=>`Error in depthwiseConv2d: Either strides or dilations must be 1. Got strides ${l} and dilations '${m}'`);let g=_.computeConv2DInfo(r.shape,a.shape,l,m,u,d,!0),A=Y().getBool("WEBGL_PACK_DEPTHWISECONV")&&g.strideWidth<=2&&g.outChannels/g.inChannels==1,y=p?Jf(p,A):null,x=[r,a],b=o!=null,v=i!=null,k=p==="leakyrelu";if(b&&x.push(o),v&&x.push(i),k){let O=n.makeTensorInfo([],"float32",w.createScalarValue(h,"float32"));x.push(O),f.push(O)}let S;A?S=new M4(g,b,y,v,k):S=new P4(g,b,y,v,k);let C=[[g.padInfo.top,g.padInfo.left],[g.strideHeight,g.strideWidth],[g.dilationHeight,g.dilationWidth],[g.inHeight,g.inWidth]],D=n.runWebGLProgram(S,x,"float32",C);return f.forEach(O=>n.disposeIntermediateTensorInfo(O)),D}var tQ={kernelName:$o,backendName:"webgl",kernelFunc:eQ},nQ=class{constructor(e,t,n){this.sliceDim=e,this.strides=t,this.variableNames=["x","indices"],this.outputShape=n;let s=gt(t.length),r=gt(n.length),a=this.sliceDim>1?"strides[j]":"strides";this.userCode=`
|
|
${s} strides = ${s}(${this.strides});
|
|
void main() {
|
|
${r} coords = getOutputCoords();
|
|
int flattenIndex = 0;
|
|
for (int j = 0; j < ${this.sliceDim}; j++) {
|
|
int index = round(getIndices(coords[0], j));
|
|
flattenIndex += index * ${a};
|
|
}
|
|
setOutput(getX(flattenIndex, coords[1]));
|
|
}
|
|
`}};function sQ(e){let{inputs:t,backend:n}=e,{params:s,indices:r}=t,a=r.shape,o=a[a.length-1],i=w.sizeFromShape(s.shape),[l,u,c,d]=_.prepareAndValidate(s,r),p=be({inputs:{x:r},backend:n,attrs:{shape:[u,o]}}),h=be({inputs:{x:s},backend:n,attrs:{shape:[w.sizeFromShape(s.shape)/c,c]}});if(n.shouldExecuteOnCPU([s,r])||s.dtype==="string"){let A=n.readSync(r.dataId),y=n.bufferSync(s),x=gX(A,y,s.dtype,u,o,c,d,s.shape,i);return n.makeTensorInfo(l,s.dtype,x.values)}let f=new nQ(o,d,[u,c]),m=n.runWebGLProgram(f,[h,p],h.dtype),g=be({inputs:{x:m},backend:n,attrs:{shape:l}});return n.disposeIntermediateTensorInfo(p),n.disposeIntermediateTensorInfo(h),n.disposeIntermediateTensorInfo(m),g}var rQ={kernelName:el,backendName:"webgl",kernelFunc:sQ},aQ=class{constructor(e,t){this.variableNames=["A","indices"],this.outputShape=t,this.rank=t.length;let n=gt(this.rank),s=oQ(e,2);this.userCode=`
|
|
void main() {
|
|
${n} resRC = getOutputCoords();
|
|
setOutput(getA(${s}));
|
|
}
|
|
`}};function oQ(e,t){let n=["resRC.x","resRC.y","resRC.z","resRC.w"],s=[];for(let r=0;r<e.length;r++)r===2?s.push("int(getIndices(resRC.x, resRC.z))"):s.push(`${n[r]}`);return s.join()}function H4(e){let{inputs:t,backend:n,attrs:s}=e,{x:r,indices:a}=t,{axis:o,batchDims:i}=s,l=w.parseAxisParam(o,r.shape)[0],u=_.segment_util.collectGatherOpShapeInfo(r,a,l,i),c=w.sizeFromShape(a.shape),d=[],p=be({inputs:{x:r},backend:n,attrs:{shape:[u.batchSize,u.outerSize,u.dimSize,u.sliceSize]}}),h=be({inputs:{x:a},backend:n,attrs:{shape:[u.batchSize,c/u.batchSize]}});d.push(p),d.push(h);let f=[u.batchSize,u.outerSize,c/u.batchSize,u.sliceSize];if(n.shouldExecuteOnCPU([r,a])||r.dtype==="string"){let y=n.bufferSync(h),x=n.bufferSync(p),b=AX(x,y,f);return d.forEach(v=>n.disposeIntermediateTensorInfo(v)),n.makeTensorInfo(u.outputShape,b.dtype,b.values)}let m=new aQ(p.shape,f),g=n.runWebGLProgram(m,[p,h],p.dtype);d.push(g);let A=be({inputs:{x:g},backend:n,attrs:{shape:u.outputShape}});return d.forEach(y=>n.disposeIntermediateTensorInfo(y)),A}var iQ={kernelName:Qi,backendName:"webgl",kernelFunc:H4},lQ="return float(a > b);",uQ=`
|
|
return vec4(greaterThan(a, b));
|
|
`,cQ=An({opSnippet:lQ,packedOpSnippet:uQ,cpuKernelImpl:yX,dtype:"bool"}),dQ={kernelName:tl,backendName:"webgl",kernelFunc:cQ},pQ="return float(a >= b);",hQ=`
|
|
return vec4(greaterThanEqual(a, b));
|
|
`,fQ=An({opSnippet:pQ,packedOpSnippet:hQ,dtype:"bool",cpuKernelImpl:xX}),mQ={kernelName:Ja,backendName:"webgl",kernelFunc:fQ};function gQ(e){let{inputs:t,backend:n}=e,{input:s}=t;return V4(s,!0,n)}var AQ={kernelName:Rp,backendName:"webgl",kernelFunc:gQ},yQ="return float(!isnan(x) && !isinf(x));",xQ=tt({opSnippet:yQ,dtype:"bool"}),bQ={kernelName:nl,backendName:"webgl",kernelFunc:xQ},vQ="return float(isinf(x));",wQ=tt({opSnippet:vQ,dtype:"bool"}),kQ={kernelName:sl,backendName:"webgl",kernelFunc:wQ},IQ="return float(isnan(x));",SQ=tt({opSnippet:IQ,dtype:"bool"}),CQ={kernelName:rl,backendName:"webgl",kernelFunc:SQ},TQ="return float(a < b);",NQ=`
|
|
return vec4(lessThan(a, b));
|
|
`,EQ=An({opSnippet:TQ,packedOpSnippet:NQ,cpuKernelImpl:bX,dtype:"bool"}),RQ={kernelName:al,backendName:"webgl",kernelFunc:EQ},DQ="return float(a <= b);",_Q=`
|
|
return vec4(lessThanEqual(a, b));
|
|
`,$Q=An({opSnippet:DQ,packedOpSnippet:_Q,cpuKernelImpl:vX,dtype:"bool"}),FQ={kernelName:ol,backendName:"webgl",kernelFunc:$Q};function OQ(e){let{backend:t,attrs:n}=e,{start:s,stop:r,num:a}=n,o=wX(s,r,a);return t.makeTensorInfo([o.length],"float32",o)}var PQ={kernelName:_p,backendName:"webgl",kernelFunc:OQ},MQ=`if (x < 0.0) return NAN;
|
|
return log(x);`,zQ=`
|
|
vec4 result = log(x);
|
|
vec4 isNaN = vec4(lessThan(x, vec4(0.0)));
|
|
result.r = isNaN.r == 1.0 ? NAN : result.r;
|
|
result.g = isNaN.g == 1.0 ? NAN : result.g;
|
|
result.b = isNaN.b == 1.0 ? NAN : result.b;
|
|
result.a = isNaN.a == 1.0 ? NAN : result.a;
|
|
|
|
return result;
|
|
`,LQ=tt({opSnippet:MQ,packedOpSnippet:zQ,cpuKernelImpl:kX}),BQ={kernelName:to,backendName:"webgl",kernelFunc:LQ},WQ="return log(1.0 + x);",VQ=tt({opSnippet:WQ}),UQ={kernelName:il,backendName:"webgl",kernelFunc:VQ},HQ="return float(a >= 1.0 && b >= 1.0);",GQ=`
|
|
return vec4(
|
|
vec4(greaterThanEqual(a, vec4(1.0))) *
|
|
vec4(greaterThanEqual(b, vec4(1.0))));
|
|
`,jQ=An({opSnippet:HQ,packedOpSnippet:GQ,dtype:"bool"}),qQ={kernelName:ll,backendName:"webgl",kernelFunc:jQ},XQ="return float(!(x >= 1.0));",KQ=tt({opSnippet:XQ}),ZQ={kernelName:nc,backendName:"webgl",kernelFunc:KQ},YQ="return float(a >= 1.0 || b >= 1.0);",JQ=`
|
|
return min(
|
|
vec4(greaterThanEqual(a, vec4(1.0))) +
|
|
vec4(greaterThanEqual(b, vec4(1.0))),
|
|
vec4(1.0));
|
|
`,QQ=An({opSnippet:YQ,packedOpSnippet:JQ,dtype:"bool"}),eee={kernelName:sc,backendName:"webgl",kernelFunc:QQ},tee=class{constructor(e,t,n,s,r){this.variableNames=["x"],this.outputShape=[];let a=t,o=e[3]-1;this.outputShape=e;let i,l=`float(${n}) + float(${s}) * sum`;r===.5?i=`inversesqrt(${l})`:r===1?i=`1.0/(${l})`:i=`exp(log(${l}) * float(-${r}));`,this.userCode=`
|
|
void main() {
|
|
ivec4 coords = getOutputCoords();
|
|
int b = coords[0];
|
|
int r = coords[1];
|
|
int c = coords[2];
|
|
int d = coords[3];
|
|
float x = getX(b, r, c, d);
|
|
float sum = 0.0;
|
|
for (int j = -${a}; j <= ${a}; j++) {
|
|
int idx = d + j;
|
|
if (idx >= 0 && idx <= ${o}) {
|
|
float z = getX(b, r, c, idx);
|
|
sum += z * z;
|
|
}
|
|
}
|
|
float val = x * ${i};
|
|
setOutput(val);
|
|
}
|
|
`}},nee=class{constructor(e,t,n,s,r){this.variableNames=["x"],this.outputShape=[],this.packedInputs=!0,this.packedOutput=!0;let a=t,o=e[3]-1;this.outputShape=e;let i,l=`float(${n}) + float(${s}) * sum`;r===.5?i=`inversesqrt(${l})`:r===1?i=`1.0/(${l})`:i=`exp(log(${l}) * float(-${r}));`,this.userCode=`
|
|
void main() {
|
|
ivec4 coords = getOutputCoords();
|
|
int b = coords.x;
|
|
int r = coords.y;
|
|
int c = coords.z;
|
|
int d = coords.w;
|
|
|
|
bool hasNextCol = d < ${this.outputShape[3]};
|
|
bool hasNextRow = c < ${this.outputShape[2]};
|
|
|
|
vec4 sum = vec4(0.);
|
|
vec4 xFragAtOutputCoords = getX(b, r, c, d);
|
|
|
|
vec4 xAtOutputCoords = vec4(
|
|
getChannel(xFragAtOutputCoords, vec2(c, d)),
|
|
hasNextCol ?
|
|
getChannel(xFragAtOutputCoords, vec2(c, d + 1)) : 0.0,
|
|
hasNextRow ?
|
|
getChannel(xFragAtOutputCoords , vec2(c + 1, d)) : 0.0,
|
|
(hasNextRow && hasNextCol) ?
|
|
getChannel(xFragAtOutputCoords, vec2(c + 1, d + 1)) : 0.0
|
|
);
|
|
|
|
int firstChannel = d - ${a};
|
|
vec2 cache = vec2(0.);
|
|
if(firstChannel >= 0){
|
|
vec4 firstChannelFrag = getX(b, r, c, firstChannel);
|
|
cache.x = getChannel(firstChannelFrag, vec2(c, firstChannel));
|
|
if(hasNextRow){
|
|
cache.y = getChannel(firstChannelFrag, vec2(c + 1, firstChannel));
|
|
}
|
|
}
|
|
|
|
ivec2 depth = ivec2(d, d + 1);
|
|
for (int j = - ${a}; j <= ${a}; j++) {
|
|
ivec2 idx = depth + j;
|
|
bvec2 aboveLowerBound = greaterThanEqual(idx, ivec2(0));
|
|
bvec2 belowUpperBound = lessThanEqual(idx, ivec2(${o}));
|
|
|
|
bool depthInRange = aboveLowerBound.x && belowUpperBound.x;
|
|
bool depthPlusOneInRange = aboveLowerBound.y && belowUpperBound.y;
|
|
|
|
if(depthInRange || depthPlusOneInRange){
|
|
vec4 z = vec4(0.);
|
|
vec4 xFragAtCurrentDepth;
|
|
z.xz = cache.xy;
|
|
if(depthPlusOneInRange && hasNextCol){
|
|
xFragAtCurrentDepth = idx.y != d ?
|
|
getX(b, r, c, idx.y) : xFragAtOutputCoords;
|
|
z.y = getChannel(xFragAtCurrentDepth, vec2(c, idx.y));
|
|
if(hasNextRow){
|
|
z.w = getChannel(xFragAtCurrentDepth, vec2(c + 1, idx.y));
|
|
}
|
|
}
|
|
cache.xy = z.yw;
|
|
sum += z * z;
|
|
}
|
|
}
|
|
vec4 result = xAtOutputCoords * ${i};
|
|
setOutput(result);
|
|
}
|
|
`}},see=e=>{let{inputs:t,backend:n,attrs:s}=e,{x:r}=t,{depthRadius:a,bias:o,alpha:i,beta:l}=s,u=Y().getBool("WEBGL_PACK_NORMALIZATION")?new nee(r.shape,a,o,i,l):new tee(r.shape,a,o,i,l);return n.runWebGLProgram(u,[r],r.dtype)},ree={kernelName:rc,backendName:"webgl",kernelFunc:see},aee=class{constructor(e,t,n,s,r){this.variableNames=["inputImage","outputImage","dy"],this.outputShape=[],this.outputShape=e,this.depth=e[3],this.depthRadius=t,this.bias=n,this.alpha=s,this.beta=r,this.userCode=`
|
|
void main() {
|
|
ivec4 coords = getOutputCoords();
|
|
int b = coords[0];
|
|
int r = coords[1];
|
|
int c = coords[2];
|
|
|
|
float result = 0.0;
|
|
for (int d = 0; d < ${this.depth}; ++d) {
|
|
int depthBegin = int(max(0.0, float(d - ${t})));
|
|
int depthEnd = int(min(float(${this.depth}),
|
|
float(d + ${t} + 1)));
|
|
|
|
const int MIN_DEPTH_BEGIN = 0;
|
|
const int MAX_DEPTH_END = ${this.depth};
|
|
|
|
float norm = 0.0;
|
|
for (int k = MIN_DEPTH_BEGIN; k < MAX_DEPTH_END; ++k) {
|
|
if (k < depthBegin){
|
|
continue;
|
|
}
|
|
else if (k >= depthBegin && k < depthEnd) {
|
|
norm += getInputImage(b, r, c, k) * getInputImage(b, r, c, k);
|
|
}
|
|
else {
|
|
break;
|
|
}
|
|
}
|
|
|
|
norm = float(${s}) * norm + float(${n});
|
|
|
|
for(int k = MIN_DEPTH_BEGIN; k < MAX_DEPTH_END; ++k){
|
|
if (k < depthBegin){
|
|
continue;
|
|
}
|
|
else if (k >= depthBegin && k < depthEnd){
|
|
float dyi = -2.0 * float(${s})
|
|
* float(${r})
|
|
* getInputImage(b ,r ,c, k) * getOutputImage(b, r, c, d)
|
|
/ norm;
|
|
if (k == d) {
|
|
dyi += pow(norm, -1.0 * ${r});
|
|
}
|
|
if (k == coords[3]) {
|
|
dyi *= getDy(b, r, c, d);
|
|
result += dyi;
|
|
}
|
|
}
|
|
else {
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
setOutput(result);
|
|
}
|
|
`}},oee=e=>{let{inputs:t,backend:n,attrs:s}=e,{x:r,y:a,dy:o}=t,{depthRadius:i,bias:l,alpha:u,beta:c}=s,d=new aee(r.shape,i,l,u,c);return n.runWebGLProgram(d,[r,a,o],r.dtype)},iee={kernelName:$p,backendName:"webgl",kernelFunc:oee};function lee(e,t,n,s){let r=w.sizeFromShape(t),o=w.sizeFromShape(e.shape)/r,i=be({inputs:{x:e},attrs:{shape:[o,r]},backend:s}),l=pi(i,e.dtype,"max",s),u=be({inputs:{x:l},attrs:{shape:n},backend:s});return s.disposeIntermediateTensorInfo(i),s.disposeIntermediateTensorInfo(l),u}function G4(e){let{inputs:t,backend:n,attrs:s}=e,{x:r}=t,{reductionIndices:a,keepDims:o}=s,i=r.shape.length,l=w.parseAxisParam(a,r.shape),u=l,c=_.getAxesPermutation(u,i),d=c!=null,p=n.shouldExecuteOnCPU([r]),h=r;if(d){if(p){let x=n.texData.get(h.dataId).values,b=new Array(i);for(let S=0;S<b.length;S++)b[S]=r.shape[c[S]];let v=Ay(x,r.shape,r.dtype,c,b);h=n.makeTensorInfo(b,r.dtype);let k=n.texData.get(h.dataId);k.values=v}else h=Qf(r,c,n);u=_.getInnerMostAxes(u.length,i)}_.assertAxesAreInnerMostDims("max",u,i);let[f,m]=_.computeOutAndReduceShapes(h.shape,u),g=f;o&&(g=_.expandShapeToKeepDim(f,l));let A;if(p){let x=n.texData.get(h.dataId).values,b=IX(x,w.sizeFromShape(m),g,r.dtype);A=n.makeTensorInfo(g,r.dtype);let v=n.texData.get(A.dataId);v.values=b}else A=lee(h,m,g,n);return d&&n.disposeIntermediateTensorInfo(h),A}var uee={kernelName:no,backendName:"webgl",kernelFunc:G4},cee=u4+`
|
|
return max(a, b);
|
|
`,dee=`
|
|
vec4 result = vec4(max(a, b));
|
|
vec4 isNaN = min(vec4(isnan(a)) + vec4(isnan(b)), vec4(1.0));
|
|
`+Yf+`
|
|
return result;
|
|
`,pee=An({opSnippet:cee,packedOpSnippet:dee,cpuKernelImpl:SX}),hee={kernelName:so,backendName:"webgl",kernelFunc:pee};function fee(e){let{inputs:t,backend:n,attrs:s}=e,{x:r}=t;mu(r,"maxPool");let{filterSize:a,strides:o,pad:i,dimRoundingMode:l}=s,u=1;w.assert(_.eitherStridesOrDilationsAreOne(o,u),()=>`Error in maxPool: Either strides or dilations must be 1. Got strides ${o} and dilations '${u}'`);let c=_.computePool2DInfo(r.shape,a,o,u,i,l);if(c.filterWidth===1&&c.filterHeight===1&&w.arraysEqual(c.inShape,c.outShape))return ds({inputs:{x:r},backend:n});let d=new xd(c,"max",!1);return n.runWebGLProgram(d,[r],r.dtype)}var mee={kernelName:ro,backendName:"webgl",kernelFunc:fee};function gee(e){let{inputs:t,backend:n,attrs:s}=e,{x:r}=t,{filterSize:a,strides:o,pad:i,dataFormat:l,dimRoundingMode:u}=s,c=[1,1,1],d=_.computePool3DInfo(r.shape,a,o,c,i,u,l),p=new xy(d,"max",!1);return n.runWebGLProgram(p,[r],r.dtype)}var Aee={kernelName:ac,backendName:"webgl",kernelFunc:gee},yee=class{constructor(e){this.variableNames=["dy","maxPos"],this.outputShape=e.inShape;let t=e.strideHeight,n=e.strideWidth,s=e.dilationHeight,r=e.effectiveFilterHeight,a=e.effectiveFilterWidth,o=r-1-e.padInfo.top,i=a-1-e.padInfo.left,l=r*a-1;this.userCode=`
|
|
const ivec2 pads = ivec2(${o}, ${i});
|
|
|
|
void main() {
|
|
ivec4 coords = getOutputCoords();
|
|
int b = coords[0];
|
|
int d = coords[3];
|
|
|
|
ivec2 dyRCCorner = coords.yz - pads;
|
|
int dyRCorner = dyRCCorner.x;
|
|
int dyCCorner = dyRCCorner.y;
|
|
|
|
// Convolve dy(?, ?, d) with pos mask(:, :, d) to get dx(xR, xC, d).
|
|
// ? = to be determined. : = across all values in that axis.
|
|
float dotProd = 0.0;
|
|
for (int wR = 0; wR < ${r};
|
|
wR += ${s}) {
|
|
float dyR = float(dyRCorner + wR) / ${t}.0;
|
|
|
|
if (dyR < 0.0 || dyR >= ${e.outHeight}.0 || fract(dyR) > 0.0) {
|
|
continue;
|
|
}
|
|
int idyR = int(dyR);
|
|
|
|
for (int wC = 0; wC < ${a}; wC++) {
|
|
float dyC = float(dyCCorner + wC) / ${n}.0;
|
|
|
|
if (dyC < 0.0 || dyC >= ${e.outWidth}.0 ||
|
|
fract(dyC) > 0.0) {
|
|
continue;
|
|
}
|
|
int idyC = int(dyC);
|
|
|
|
float dyValue = getDy(b, idyR, idyC, d);
|
|
int maxPosValue = ${l} - int(getMaxPos(b, idyR, idyC, d));
|
|
|
|
// Get the current value, check it against the value from the
|
|
// position matrix.
|
|
int curPosValue = wR * ${a} + wC;
|
|
float mask = float(maxPosValue == curPosValue ? 1.0 : 0.0);
|
|
|
|
dotProd += dyValue * mask;
|
|
}
|
|
}
|
|
setOutput(dotProd);
|
|
}
|
|
`}},xee=class{constructor(e){this.variableNames=["dy","maxPos"],this.outputShape=e.inShape;let t=e.strideDepth,n=e.strideHeight,s=e.strideWidth,r=e.dilationDepth,a=e.dilationHeight,o=e.dilationWidth,i=e.effectiveFilterDepth,l=e.effectiveFilterHeight,u=e.effectiveFilterWidth,c=i-1-e.padInfo.front,d=l-1-e.padInfo.top,p=u-1-e.padInfo.left,h=i*l*u-1;this.userCode=`
|
|
const ivec3 pads = ivec3(${c}, ${d}, ${p});
|
|
|
|
void main() {
|
|
ivec5 coords = getOutputCoords();
|
|
int batch = coords.x;
|
|
int ch = coords.u;
|
|
|
|
ivec3 dyCorner = ivec3(coords.y, coords.z, coords.w) - pads;
|
|
int dyDCorner = dyCorner.x;
|
|
int dyRCorner = dyCorner.y;
|
|
int dyCCorner = dyCorner.z;
|
|
|
|
// Convolve dy(?, ?, ?, ch) with pos mask(:, :, :, d) to get
|
|
// dx(xD, xR, xC, ch).
|
|
// ? = to be determined. : = across all values in that axis.
|
|
float dotProd = 0.0;
|
|
|
|
for (int wD = 0; wD < ${i};
|
|
wD += ${r}) {
|
|
float dyD = float(dyDCorner + wD) / ${t}.0;
|
|
|
|
if (dyD < 0.0 || dyD >= ${e.outDepth}.0 || fract(dyD) > 0.0) {
|
|
continue;
|
|
}
|
|
int idyD = int(dyD);
|
|
|
|
for (int wR = 0; wR < ${l};
|
|
wR += ${a}) {
|
|
float dyR = float(dyRCorner + wR) / ${n}.0;
|
|
|
|
if (dyR < 0.0 || dyR >= ${e.outHeight}.0 ||
|
|
fract(dyR) > 0.0) {
|
|
continue;
|
|
}
|
|
int idyR = int(dyR);
|
|
|
|
for (int wC = 0; wC < ${u};
|
|
wC += ${o}) {
|
|
float dyC = float(dyCCorner + wC) / ${s}.0;
|
|
|
|
if (dyC < 0.0 || dyC >= ${e.outWidth}.0 ||
|
|
fract(dyC) > 0.0) {
|
|
continue;
|
|
}
|
|
int idyC = int(dyC);
|
|
|
|
float dyValue = getDy(batch, idyD, idyR, idyC, ch);
|
|
int maxPosValue = ${h} -
|
|
int(getMaxPos(batch, idyD, idyR, idyC, ch));
|
|
|
|
// Get the current value, check it against the value from the
|
|
// position matrix.
|
|
int curPosValue =
|
|
wD * ${l} * ${u} +
|
|
wR * ${u} + wC;
|
|
float mask = float(maxPosValue == curPosValue ? 1.0 : 0.0);
|
|
|
|
dotProd += dyValue * mask;
|
|
}
|
|
}
|
|
}
|
|
setOutput(dotProd);
|
|
}
|
|
`}};function bee(e){let{inputs:t,backend:n,attrs:s}=e,{dy:r,input:a}=t,o=a,{filterSize:i,strides:l,pad:u,dimRoundingMode:c}=s,d=[1,1,1],p=_.computePool3DInfo(o.shape,i,l,d,u,c),h=new xy(p,"max",!0),f=n.runWebGLProgram(h,[o],o.dtype),m=new xee(p),g=n.runWebGLProgram(m,[r,f],o.dtype);return n.disposeIntermediateTensorInfo(f),g}var vee={kernelName:Op,backendName:"webgl",kernelFunc:bee};function wee(e){let{inputs:t,backend:n,attrs:s}=e,{dy:r,input:a,output:o}=t,i=a;mu([a,o],"maxPoolGrad");let{filterSize:l,strides:u,pad:c,dimRoundingMode:d}=s,p=_.computePool2DInfo(i.shape,l,u,1,c,d),h=!0,f=new xd(p,"max",h),m=n.runWebGLProgram(f,[i],i.dtype),g=new yee(p),A=n.runWebGLProgram(g,[r,m],i.dtype);return n.disposeIntermediateTensorInfo(m),A}var kee={kernelName:Fp,backendName:"webgl",kernelFunc:wee};function Iee(e,t,n,s){let r=new xd(n,"max",!1),a=s.runWebGLProgram(r,[e],"float32");r=new xd(n,"max",!0,!0,t);let o=s.runWebGLProgram(r,[e],"float32");return[a,o]}var See={kernelName:Pp,backendName:"webgl",kernelFunc:({inputs:e,attrs:t,backend:n})=>{let{x:s}=e,{filterSize:r,strides:a,pad:o,includeBatchInIndex:i}=t,l=n;w.assert(s.shape.length===4,()=>`Error in maxPool: input must be rank 4 but got rank ${s.shape.length}.`);let u=[1,1];w.assert(_.eitherStridesOrDilationsAreOne(a,u),()=>`Error in maxPool: Either strides or dilations must be 1. Got strides ${a} and dilations '${u}'`);let c=_.computePool2DInfo(s.shape,r,a,u,o),[d,p]=Iee(s,i,c,l);return[d,p]}};function Cee(e,t,n,s){let r=w.sizeFromShape(t),o=w.sizeFromShape(e.shape)/r,i=be({inputs:{x:e},attrs:{shape:[o,r]},backend:s}),l=pi(i,"float32","mean",s),u=be({inputs:{x:l},attrs:{shape:n},backend:s});return s.disposeIntermediateTensorInfo(i),s.disposeIntermediateTensorInfo(l),u}var Tee={kernelName:ao,backendName:"webgl",kernelFunc:({inputs:e,attrs:t,backend:n})=>{let{x:s}=e,{keepDims:r,axis:a}=t,o=n,i=s.shape.length,l=w.parseAxisParam(a,s.shape),u=l,c=_.getAxesPermutation(u,i),d=c!=null,p=o.shouldExecuteOnCPU([s]),h=[],f=s;if(d){if(p){let b=o.texData.get(f.dataId).values,v=new Array(i);for(let C=0;C<v.length;C++)v[C]=s.shape[c[C]];let k=Ay(b,s.shape,s.dtype,c,v);f=o.makeTensorInfo(v,s.dtype);let S=o.texData.get(f.dataId);S.values=k}else f=Qf(s,c,o);h.push(f),u=_.getInnerMostAxes(u.length,i)}_.assertAxesAreInnerMostDims("sum",u,i);let[m,g]=_.computeOutAndReduceShapes(f.shape,u),A=m;r&&(A=_.expandShapeToKeepDim(m,l));let y=Cee(f,g,A,o);for(let x of h)o.disposeIntermediateTensorInfo(x);return y}};function Nee(e){let{inputs:t,backend:n,attrs:s}=e,{x:r}=t,{axis:a,keepDims:o}=s,i=r.shape.length,l=w.parseAxisParam(a,r.shape),u=l,c=_.getAxesPermutation(u,i),d=r;c!=null&&(d=Dn({inputs:{x:r},backend:n,attrs:{perm:c}}),u=_.getInnerMostAxes(u.length,r.shape.length)),_.assertAxesAreInnerMostDims("min",u,i);let[p,h]=_.computeOutAndReduceShapes(d.shape,u),f=w.sizeFromShape(h),m=be({inputs:{x:d},backend:n,attrs:{shape:[-1,f]}}),g=pi(m,m.dtype,"min",n),A;if(o){let y=_.expandShapeToKeepDim(p,l);A=be({inputs:{x:g},backend:n,attrs:{shape:y}})}else A=be({inputs:{x:g},backend:n,attrs:{shape:p}});return n.disposeIntermediateTensorInfo(m),n.disposeIntermediateTensorInfo(g),c!=null&&n.disposeIntermediateTensorInfo(d),A}var Eee={kernelName:oo,backendName:"webgl",kernelFunc:Nee},Ree=u4+`
|
|
return min(a, b);
|
|
`,Dee=`
|
|
vec4 result = vec4(min(a, b));
|
|
vec4 isNaN = min(vec4(isnan(a)) + vec4(isnan(b)), vec4(1.0));
|
|
`+Yf+`
|
|
return result;
|
|
`,_ee=An({opSnippet:Ree,packedOpSnippet:Dee,cpuKernelImpl:CX}),$ee={kernelName:io,backendName:"webgl",kernelFunc:_ee},Fee=class{constructor(e,t,n){this.variableNames=["x"],this.outputShape=t.map((u,c)=>u[0]+e[c]+u[1]);let s=e.length,r=gt(s),a=t.map(u=>u[0]).join(","),o=t.map((u,c)=>u[0]+e[c]).join(","),i=["coords[0]","coords[1]","coords[2]","coords[3]"].slice(0,s),l=n==="reflect"?0:1;if(s===1){this.userCode=`
|
|
int start = ${a};
|
|
int end = ${o};
|
|
|
|
void main() {
|
|
int outC = getOutputCoords();
|
|
if (outC < start) {
|
|
outC = start * 2 - outC - ${l};
|
|
} else if(outC >= end) {
|
|
outC = (end - 1) * 2 - outC + ${l};
|
|
}
|
|
setOutput(getX(outC - start));
|
|
}
|
|
`;return}this.userCode=`
|
|
${r} start = ${r}(${a});
|
|
${r} end = ${r}(${o});
|
|
|
|
void main() {
|
|
${r} outC = getOutputCoords();
|
|
for (int i = 0; i < ${s}; i++) {
|
|
if (outC[i] < start[i]) {
|
|
outC[i] = start[i] * 2 - outC[i] - ${l};
|
|
} else if(outC[i] >= end[i]) {
|
|
outC[i] = (end[i] - 1) * 2 - outC[i] + ${l};
|
|
}
|
|
}
|
|
${r} coords = outC - start;
|
|
setOutput(getX(${i}));
|
|
}
|
|
`}},Oee=class{constructor(e,t,n){this.variableNames=["x"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=t.map((h,f)=>h[0]+e[f]+h[1]);let s=e.length,r=gt(s),a=t.map(h=>h[0]).join(","),o=t.map((h,f)=>h[0]+e[f]).join(","),i=Rn("rc",s),l=Rn("source",s),u=`${i[s-1]} < ${this.outputShape[s-1]}`,c=s===1?"source":`vec2(${l.slice(-2).join()})`,d=n==="reflect"?0:1,p="";if(s===1){let h=`
|
|
${r} source = rc;
|
|
if (source < start) {
|
|
source = start * 2 - source - ${d};
|
|
} else if (source >= end) {
|
|
source = (end - 1) * 2 - source + ${d};
|
|
}
|
|
source -= start;
|
|
`;p=`
|
|
${r} rc = outputLoc;
|
|
${h}
|
|
result[0] = getChannel(getX(${l.join()}), ${c});
|
|
${i[s-1]} += 1;
|
|
if(${u}) {
|
|
${h}
|
|
result[1] = getChannel(getX(${l.join()}), ${c});
|
|
}
|
|
`}else{let h=`
|
|
${r} source = rc;
|
|
${r} lt = ${r}(lessThan(source, start));
|
|
${r} gte = ${r}(greaterThanEqual(source, end));
|
|
${r} orig = 1 - (lt + gte);
|
|
source = orig * source +
|
|
lt * (start * 2 - source - ${d}) +
|
|
gte * ((end - 1) * 2 - source + ${d});
|
|
source -= start;
|
|
`;p=`
|
|
${r} rc = outputLoc;
|
|
${h}
|
|
result[0] = getChannel(getX(${l.join()}), ${c});
|
|
${i[s-1]} += 1;
|
|
if(${u}) {
|
|
${h}
|
|
result[1] = getChannel(getX(${l.join()}), ${c});
|
|
}
|
|
rc = outputLoc;
|
|
${i[s-2]} += 1;
|
|
if(${i[s-2]} < ${this.outputShape[s-2]}) {
|
|
${h}
|
|
result[2] = getChannel(getX(${l.join()}), ${c});
|
|
${i[s-1]} += 1;
|
|
if(${u}) {
|
|
${h}
|
|
result[3] = getChannel(getX(${l.join()}), ${c});
|
|
}
|
|
}
|
|
`}this.userCode=`
|
|
const ${r} start = ${r}(${a});
|
|
const ${r} end = ${r}(${o});
|
|
|
|
void main() {
|
|
${r} outputLoc = getOutputCoords();
|
|
vec4 result = vec4(0.);
|
|
${p}
|
|
setOutput(result);
|
|
}
|
|
`}},Pee=({inputs:e,backend:t,attrs:n})=>{let{x:s}=e,{paddings:r,mode:a}=n,o=Y().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new Oee(s.shape,r,a):new Fee(s.shape,r,a);return t.runWebGLProgram(o,[s],s.dtype)},Mee={kernelName:lo,backendName:"webgl",kernelFunc:Pee},zee=`if (b == 0.0) return NAN;
|
|
return mod(a, b);`,Lee=`
|
|
vec4 result = mod(a, b);
|
|
vec4 isNaN = vec4(equal(b, vec4(0.0)));
|
|
`+Yf+`
|
|
return result;
|
|
`,Bee=An({opSnippet:zee,packedOpSnippet:Lee}),Wee={kernelName:ul,backendName:"webgl",kernelFunc:Bee},Vee=class{constructor(e,t,n){this.variableNames=["probs"],this.customUniforms=[{name:"seed",type:"float"}],this.outputShape=[e,n],this.userCode=`
|
|
void main() {
|
|
ivec2 coords = getOutputCoords();
|
|
int batch = coords[0];
|
|
|
|
float r = random(seed);
|
|
float cdf = 0.0;
|
|
|
|
for (int i = 0; i < ${t-1}; i++) {
|
|
cdf += getProbs(batch, i);
|
|
|
|
if (r < cdf) {
|
|
setOutput(float(i));
|
|
return;
|
|
}
|
|
}
|
|
|
|
// If no other event happened, last event happened.
|
|
setOutput(float(${t-1}));
|
|
}
|
|
`}},Uee=`
|
|
if (a == b) {
|
|
return 1.0;
|
|
};
|
|
return a / b;`,Hee=`
|
|
// vec4 one = vec4(equal(a, b));
|
|
// return one + (vec4(1.0) - one) * a / b;
|
|
vec4 result = a / b;
|
|
if(a.x == b.x) {
|
|
result.x = 1.;
|
|
}
|
|
if(a.y == b.y) {
|
|
result.y = 1.;
|
|
}
|
|
if(a.z == b.z) {
|
|
result.z = 1.;
|
|
}
|
|
if(a.w == b.w) {
|
|
result.w = 1.;
|
|
}
|
|
|
|
return result;
|
|
`,j4=An({opSnippet:Uee,packedOpSnippet:Hee,checkOutOfBounds:!0}),Gee={kernelName:ja,backendName:"webgl",kernelFunc:j4},q4="return a - b;",X4=An({opSnippet:q4,packedOpSnippet:q4,supportsComplex:!0,cpuKernelImpl:VX}),jee={kernelName:To,backendName:"webgl",kernelFunc:X4};function K4(e){let{inputs:t,backend:n,attrs:s}=e,{logits:r}=t,{dim:a}=s,o=w.parseAxisParam([a],r.shape),i=G4({inputs:{x:r},backend:n,attrs:{reductionIndices:o,keepDims:!1}}),l=_.expandShapeToKeepDim(i.shape,o),u=be({inputs:{x:i},backend:n,attrs:{shape:l}}),c=X4({inputs:{a:r,b:u},backend:n}),d=L4({inputs:{x:c},backend:n}),p=e0({inputs:{x:d},backend:n,attrs:{axis:o,keepDims:!1}}),h=be({inputs:{x:p},backend:n,attrs:{shape:l}}),f=j4({inputs:{a:d,b:h},backend:n});return n.disposeIntermediateTensorInfo(i),n.disposeIntermediateTensorInfo(u),n.disposeIntermediateTensorInfo(c),n.disposeIntermediateTensorInfo(d),n.disposeIntermediateTensorInfo(p),n.disposeIntermediateTensorInfo(h),f}var qee={kernelName:So,backendName:"webgl",kernelFunc:K4};function Xee(e){let{inputs:t,backend:n,attrs:s}=e,{logits:r}=t,{numSamples:a,seed:o,normalized:i}=s,l=i?r:K4({inputs:{logits:r},backend:n,attrs:{dim:r.shape.length-1}}),u=l.shape[0],c=l.shape[1],d=new Vee(u,c,a),p=[[o]],h=n.runWebGLProgram(d,[l],"int32",p);return i||n.disposeIntermediateTensorInfo(l),h}var Kee={kernelName:Mp,backendName:"webgl",kernelFunc:Xee},Z4="return -x;";function Zee(e){let{inputs:t,backend:n}=e,{x:s}=t;if(n.shouldExecuteOnCPU([s])){let a=n.texData.get(s.dataId),[o,i]=NX(a.values,s.shape,s.dtype);return n.makeTensorInfo(i,s.dtype,o)}let r;return Y().getBool("WEBGL_PACK_UNARY_OPERATIONS")?r=new bu(s.shape,Z4):r=new wa(s.shape,Z4),n.runWebGLProgram(r,[s],s.dtype)}var Yee={kernelName:cl,backendName:"webgl",kernelFunc:Zee},Jee=lr.nonMaxSuppressionV3Impl;function Qee(e){_.warn("tf.nonMaxSuppression() in webgl locks the UI thread. Call tf.nonMaxSuppressionAsync() instead");let{inputs:t,backend:n,attrs:s}=e,{boxes:r,scores:a}=t,{maxOutputSize:o,iouThreshold:i,scoreThreshold:l}=s,u=n.readSync(r.dataId),c=n.readSync(a.dataId),{selectedIndices:d}=Jee(u,c,o,i,l);return n.makeTensorInfo([d.length],"int32",new Int32Array(d))}var ete={kernelName:pl,backendName:"webgl",kernelFunc:Qee},tte=lr.nonMaxSuppressionV4Impl;function nte(e){_.warn("tf.nonMaxSuppression() in webgl locks the UI thread. Call tf.nonMaxSuppressionAsync() instead");let{inputs:t,backend:n,attrs:s}=e,{boxes:r,scores:a}=t,{maxOutputSize:o,iouThreshold:i,scoreThreshold:l,padToMaxOutputSize:u}=s,c=n.readSync(r.dataId),d=n.readSync(a.dataId),{selectedIndices:p,validOutputs:h}=tte(c,d,o,i,l,u);return[n.makeTensorInfo([p.length],"int32",new Int32Array(p)),n.makeTensorInfo([],"int32",new Int32Array([h]))]}var ste={kernelName:hl,backendName:"webgl",kernelFunc:nte},rte=lr.nonMaxSuppressionV5Impl;function ate(e){_.warn("tf.nonMaxSuppression() in webgl locks the UI thread. Call tf.nonMaxSuppressionAsync() instead");let{inputs:t,backend:n,attrs:s}=e,{boxes:r,scores:a}=t,{maxOutputSize:o,iouThreshold:i,scoreThreshold:l,softNmsSigma:u}=s,c=n.readSync(r.dataId),d=n.readSync(a.dataId),p=o,h=i,f=l,m=u,{selectedIndices:g,selectedScores:A}=rte(c,d,p,h,f,m);return[n.makeTensorInfo([g.length],"int32",new Int32Array(g)),n.makeTensorInfo([A.length],"float32",new Float32Array(A))]}var ote={kernelName:fl,backendName:"webgl",kernelFunc:ate},ite=class{constructor(e,t,n,s){this.variableNames=["indices"],this.outputShape=[e,t],this.userCode=`
|
|
void main() {
|
|
ivec2 coords = getOutputCoords();
|
|
int index = round(getIndices(coords.x));
|
|
setOutput(mix(float(${s}), float(${n}),
|
|
float(index == coords.y)));
|
|
}
|
|
`}},lte=e=>{let{inputs:t,backend:n,attrs:s}=e,{indices:r}=t,{depth:a,onValue:o,offValue:i}=s,l=w.sizeFromShape(r.shape),u=new ite(l,a,o,i),c=be({inputs:{x:r},backend:n,attrs:{shape:[l]}}),d=n.runWebGLProgram(u,[c],r.dtype);n.disposeIntermediateTensorInfo(c);let p=[...r.shape,a],h=be({inputs:{x:d},backend:n,attrs:{shape:p}});return n.disposeIntermediateTensorInfo(d),h},ute={kernelName:co,backendName:"webgl",kernelFunc:lte};function a0(e){let{inputs:t,backend:n}=e,{x:s}=t;if(s.dtype==="complex64"){let r=bd({inputs:{input:s},backend:n}),a=a0({inputs:{x:r},backend:n}),o=r0({inputs:{input:s},backend:n}),i=a0({inputs:{x:o},backend:n}),l=ka({inputs:{real:a,imag:i},backend:n});return n.disposeIntermediateTensorInfo(r),n.disposeIntermediateTensorInfo(a),n.disposeIntermediateTensorInfo(o),n.disposeIntermediateTensorInfo(i),l}else return vd({attrs:{shape:s.shape,dtype:s.dtype,value:s.dtype==="string"?"":0},backend:n})}var cte={kernelName:$l,backendName:"webgl",kernelFunc:a0};function Y4(e){let{inputs:t,backend:n}=e,{x:s}=t;if(s.dtype==="string")throw new Error("onesLike is not supported under string dtype");if(s.dtype==="complex64"){let r=bd({inputs:{input:s},backend:n}),a=Y4({inputs:{x:r},backend:n}),o=r0({inputs:{input:s},backend:n}),i=a0({inputs:{x:o},backend:n}),l=ka({inputs:{real:a,imag:i},backend:n});return n.disposeIntermediateTensorInfo(r),n.disposeIntermediateTensorInfo(a),n.disposeIntermediateTensorInfo(o),n.disposeIntermediateTensorInfo(i),l}else return vd({attrs:{shape:s.shape,dtype:s.dtype,value:1},backend:n})}var dte={kernelName:ml,backendName:"webgl",kernelFunc:Y4};function pte(e){let{inputs:t,backend:n,attrs:s}=e,{axis:r}=s;if(t.length===1)return wy({inputs:{input:t[0]},backend:n,attrs:{dim:r}});let a=t[0].shape,o=t[0].dtype;t.forEach(c=>{w.assertShapesMatch(a,c.shape,"All tensors passed to stack must have matching shapes"),w.assert(o===c.dtype,()=>"All tensors passed to stack must have matching dtypes")});let i=[],l=t.map(c=>{let d=wy({inputs:{input:c},backend:n,attrs:{dim:r}});return i.push(d),d}),u=E4({inputs:l,backend:n,attrs:{axis:r}});return i.forEach(c=>n.disposeIntermediateTensorInfo(c)),u}var hte={kernelName:gl,backendName:"webgl",kernelFunc:pte},fte=class{constructor(e,t,n){this.variableNames=["x"],this.customUniforms=[{name:"value",type:"float"}],this.outputShape=t.map((l,u)=>l[0]+e[u]+l[1]);let s=e.length,r=gt(s),a=t.map(l=>l[0]).join(","),o=t.map((l,u)=>l[0]+e[u]).join(","),i=["coords[0]","coords[1]","coords[2]","coords[3]"].slice(0,s);if(s===1){this.userCode=`
|
|
int start = ${a};
|
|
int end = ${o};
|
|
|
|
void main() {
|
|
int outC = getOutputCoords();
|
|
if (outC < start || outC >= end) {
|
|
setOutput(value);
|
|
} else {
|
|
setOutput(getX(outC - start));
|
|
}
|
|
}
|
|
`;return}this.userCode=`
|
|
${r} start = ${r}(${a});
|
|
${r} end = ${r}(${o});
|
|
|
|
void main() {
|
|
${r} outC = getOutputCoords();
|
|
if (any(lessThan(outC, start)) || any(greaterThanEqual(outC, end))) {
|
|
setOutput(value);
|
|
} else {
|
|
${r} coords = outC - start;
|
|
setOutput(getX(${i}));
|
|
}
|
|
}
|
|
`}},mte=class{constructor(e,t,n){this.variableNames=["x"],this.packedInputs=!0,this.packedOutput=!0,this.customUniforms=[{name:"value",type:"float"}],this.outputShape=t.map((f,m)=>f[0]+e[m]+f[1]);let s=e.length,r=gt(s),a=t.map(f=>f[0]).join(","),o=t.map((f,m)=>f[0]+e[m]).join(","),i=Rn("rc",s),l=Rn("source",s),u=`${i[s-1]} < ${this.outputShape[s-1]}`,c=s===1?"source":`vec2(${l.slice(-2).join()})`,d=[`${r} rc = outputLoc;`,`${i[s-1]} += 1;
|
|
if(${u}) {
|
|
`,s===1?"":`}
|
|
rc = outputLoc;
|
|
${i[s-2]} += 1;
|
|
if(${i[s-2]} < ${this.outputShape[s-2]}) {`,s===1?"":` ${i[s-1]} += 1;
|
|
if(${u}) {`],p=s===1?"rc < start || rc >= end":"any(lessThan(rc, start)) || any(greaterThanEqual(rc, end))",h="";for(let f=0,m=s===1?2:4;f<m;f++)h+=`
|
|
${d[f]}
|
|
if (${p}) {
|
|
result[${f}] = float(value);
|
|
} else {
|
|
${r} source = rc - start;
|
|
result[${f}] = getChannel(getX(${l.join()}), ${c});
|
|
}
|
|
`;h+=s===1?"} ":"}}",this.userCode=`
|
|
const ${r} start = ${r}(${a});
|
|
const ${r} end = ${r}(${o});
|
|
|
|
void main() {
|
|
${r} outputLoc = getOutputCoords();
|
|
vec4 result = vec4(0.);
|
|
${h}
|
|
setOutput(result);
|
|
}
|
|
`}},J4=e=>{let{inputs:t,backend:n,attrs:s}=e,{x:r}=t,{paddings:a,constantValue:o}=s;if(w.sizeFromShape(r.shape)===0){let u=a.map((c,d)=>c[0]+r.shape[d]+c[1]);return vd({backend:n,attrs:{shape:u,value:o,dtype:r.dtype}})}let i=Y().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new mte(r.shape,a,o):new fte(r.shape,a,o),l=[[o]];return n.runWebGLProgram(i,[r],r.dtype,l)},gte={kernelName:po,backendName:"webgl",kernelFunc:J4},Ate=`
|
|
if(a < 0.0 && floor(b) < b){
|
|
return NAN;
|
|
}
|
|
if (b == 0.0) {
|
|
return 1.0;
|
|
}
|
|
return (round(mod(b, 2.0)) != 1) ?
|
|
pow(abs(a), b) : sign(a) * pow(abs(a), b);
|
|
`,yte=`
|
|
// isModRound1 has 1 for components with round(mod(b, 2.0)) == 1, 0 otherwise.
|
|
vec4 isModRound1 = vec4(equal(round(mod(b, 2.0)), ivec4(1)));
|
|
vec4 multiplier = sign(a) * isModRound1 + (vec4(1.0) - isModRound1);
|
|
vec4 result = multiplier * pow(abs(a), b);
|
|
|
|
// Ensure that a^0 = 1, including 0^0 = 1 as this correspond to TF and JS
|
|
bvec4 isExpZero = equal(b, vec4(0.0));
|
|
result.r = isExpZero.r ? 1.0 : result.r;
|
|
result.g = isExpZero.g ? 1.0 : result.g;
|
|
result.b = isExpZero.b ? 1.0 : result.b;
|
|
result.a = isExpZero.a ? 1.0 : result.a;
|
|
|
|
vec4 isNaN = vec4(lessThan(a, vec4(0.0))) * vec4(lessThan(floor(b), b));
|
|
`+Yf+`
|
|
return result;
|
|
`,xte=An({opSnippet:Ate,packedOpSnippet:yte}),bte={kernelName:ho,backendName:"webgl",kernelFunc:xte};function vte(e){let{inputs:t,backend:n,attrs:s}=e,{x:r}=t,{axis:a,keepDims:o}=s,i=r.shape.length,l=[],u=w.parseAxisParam(a,r.shape),c=u,d=_.getAxesPermutation(c,i),p=r;d!=null&&(p=Dn({inputs:{x:r},backend:n,attrs:{perm:d}}),c=_.getInnerMostAxes(c.length,i),l.push(p)),_.assertAxesAreInnerMostDims("prod",c,i);let h;if(n.shouldExecuteOnCPU([p])){let f=n.texData.get(p.dataId).values,{outVals:m,outShape:g,outDtype:A}=RX(p.shape,p.dtype,f,c);h=n.makeTensorInfo(g,A,m)}else{let[f,m]=_.computeOutAndReduceShapes(p.shape,c),g=w.sizeFromShape(m),A=be({inputs:{x:p},backend:n,attrs:{shape:[-1,g]}}),y=nh(r.dtype),x=pi(A,y,"prod",n);h=be({inputs:{x},backend:n,attrs:{shape:f}}),l.push(A),l.push(x)}if(o){l.push(h);let f=_.expandShapeToKeepDim(h.shape,u);h=be({inputs:{x:h},backend:n,attrs:{shape:f}})}return l.forEach(f=>n.disposeIntermediateTensorInfo(f)),h}var wte={kernelName:Al,backendName:"webgl",kernelFunc:vte},Q4=e=>{let{backend:t,attrs:n}=e,{start:s,stop:r,step:a,dtype:o}=n,i=DX(s,r,a,o);return t.makeTensorInfo([i.length],o,i)},kte={kernelName:oc,backendName:"webgl",kernelFunc:Q4},Ite="return 1.0 / x;",Ste=tt({opSnippet:Ite}),Cte={kernelName:yl,backendName:"webgl",kernelFunc:Ste},Tte=Js+`
|
|
return (x < 0.0) ? 0.0 : x;
|
|
`,Nte=`
|
|
vec4 result = x * vec4(greaterThanEqual(x, vec4(0.0)));
|
|
bvec4 isNaN = isnan(x);
|
|
|
|
result.r = isNaN.r ? x.r : result.r;
|
|
result.g = isNaN.g ? x.g : result.g;
|
|
result.b = isNaN.b ? x.b : result.b;
|
|
result.a = isNaN.a ? x.a : result.a;
|
|
|
|
return result;
|
|
`,Ete=tt({opSnippet:Tte,packedOpSnippet:Nte}),Rte={kernelName:mo,backendName:"webgl",kernelFunc:Ete},Dte=Js+`
|
|
return (x < 0.0) ? 0.0 : min(6.0, x);
|
|
`,_te=`
|
|
vec4 result = min(x, vec4(6.)) * vec4(greaterThanEqual(x, vec4(0.0)));
|
|
bvec4 isNaN = isnan(x);
|
|
|
|
result.r = isNaN.r ? x.r : result.r;
|
|
result.g = isNaN.g ? x.g : result.g;
|
|
result.b = isNaN.b ? x.b : result.b;
|
|
result.a = isNaN.a ? x.a : result.a;
|
|
|
|
return result;
|
|
`,$te=tt({opSnippet:Dte,packedOpSnippet:_te}),Fte={kernelName:Ao,backendName:"webgl",kernelFunc:$te},Ote=class{constructor(e,t,n,s,r){this.variableNames=["A"],this.outputShape=[];let[a,o,i,l]=e;this.outputShape=[a,t,n,l];let u=[s&&t>1?o-1:o,s&&n>1?i-1:i],c=[s&&t>1?t-1:t,s&&n>1?n-1:n],d;r?d="(vec2(yRC) + vec2(0.5)) * effectiveInputOverOutputRatioRC - vec2(0.5)":d="vec2(yRC) * effectiveInputOverOutputRatioRC",this.userCode=`
|
|
const vec2 effectiveInputOverOutputRatioRC = vec2(
|
|
${u[0]/c[0]},
|
|
${u[1]/c[1]});
|
|
const vec2 inputShapeRC = vec2(${o}.0, ${i}.0);
|
|
|
|
void main() {
|
|
ivec4 coords = getOutputCoords();
|
|
int b = coords[0];
|
|
int d = coords[3];
|
|
ivec2 yRC = coords.yz;
|
|
|
|
// Fractional source index.
|
|
vec2 sourceFracIndexRC = ${d};
|
|
|
|
// Compute the four integer indices.
|
|
ivec2 sourceFloorRC = ivec2(max(sourceFracIndexRC, vec2(0.0)));
|
|
ivec2 sourceCeilRC = ivec2(
|
|
min(inputShapeRC - 1.0, ceil(sourceFracIndexRC)));
|
|
|
|
float topLeft = getA(b, sourceFloorRC.x, sourceFloorRC.y, d);
|
|
float bottomLeft = getA(b, sourceCeilRC.x, sourceFloorRC.y, d);
|
|
float topRight = getA(b, sourceFloorRC.x, sourceCeilRC.y, d);
|
|
float bottomRight = getA(b, sourceCeilRC.x, sourceCeilRC.y, d);
|
|
|
|
vec2 fracRC = sourceFracIndexRC - vec2(sourceFloorRC);
|
|
|
|
float top = topLeft + (topRight - topLeft) * fracRC.y;
|
|
float bottom = bottomLeft + (bottomRight - bottomLeft) * fracRC.y;
|
|
float newValue = top + (bottom - top) * fracRC.x;
|
|
|
|
setOutput(newValue);
|
|
}
|
|
`}},Pte=class{constructor(e,t,n,s,r){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=[];let[a,o,i,l]=e;this.outputShape=[a,t,n,l];let u=[s&&t>1?o-1:o,s&&n>1?i-1:i],c=[s&&t>1?t-1:t,s&&n>1?n-1:n],d;r?d="(vec3(yRC) + vec3(0.5)) * effectiveInputOverOutputRatioRC - vec3(0.5)":d="vec3(yRC) * effectiveInputOverOutputRatioRC",this.userCode=`
|
|
const vec3 effectiveInputOverOutputRatioRC = vec3(
|
|
${u[0]/c[0]},
|
|
${u[1]/c[1]},
|
|
${u[1]/c[1]});
|
|
const vec3 inputShapeRC = vec3(${o}.0, ${i}.0,
|
|
${i}.0);
|
|
|
|
float getAValue(int b, int r, int c, int d) {
|
|
return getChannel(getA(b, r, c, d), vec2(c, d));
|
|
}
|
|
|
|
void main() {
|
|
ivec4 coords = getOutputCoords();
|
|
int b = coords[0];
|
|
int d = coords[3];
|
|
// Calculate values for next column in yRC.z.
|
|
ivec3 yRC = coords.yzz + ivec3(0, 0, 1);
|
|
|
|
// Fractional source index.
|
|
vec3 sourceFracIndexRC = ${d};
|
|
|
|
// Compute the four integer indices.
|
|
ivec3 sourceFloorRC = ivec3(max(sourceFracIndexRC, vec3(0.0)));
|
|
ivec3 sourceCeilRC = ivec3(
|
|
min(inputShapeRC - 1.0, ceil(sourceFracIndexRC)));
|
|
|
|
// Should we calculate next column and row elements in 2x2 packed cell.
|
|
bool hasNextCol = d < ${l-1};
|
|
bool hasNextRow = coords.z < ${n-1};
|
|
|
|
// In parallel, construct four corners for all four components in
|
|
// packed 2x2 cell.
|
|
vec4 topLeft = vec4(
|
|
getAValue(b, sourceFloorRC.x, sourceFloorRC.y, d),
|
|
hasNextCol ? getAValue(b, sourceFloorRC.x, sourceFloorRC.y, d + 1)
|
|
: 0.0,
|
|
hasNextRow ? getAValue(b, sourceFloorRC.x, sourceFloorRC.z, d)
|
|
: 0.0,
|
|
(hasNextRow && hasNextCol) ?
|
|
getAValue(b, sourceFloorRC.x, sourceFloorRC.z, d + 1) : 0.0);
|
|
|
|
vec4 bottomLeft = vec4(
|
|
getAValue(b, sourceCeilRC.x, sourceFloorRC.y, d),
|
|
hasNextCol ? getAValue(b, sourceCeilRC.x, sourceFloorRC.y, d + 1)
|
|
: 0.0,
|
|
hasNextRow ? getAValue(b, sourceCeilRC.x, sourceFloorRC.z, d)
|
|
: 0.0,
|
|
(hasNextRow && hasNextCol) ?
|
|
getAValue(b, sourceCeilRC.x, sourceFloorRC.z, d + 1) : 0.0);
|
|
|
|
vec4 topRight = vec4(
|
|
getAValue(b, sourceFloorRC.x, sourceCeilRC.y, d),
|
|
hasNextCol ? getAValue(b, sourceFloorRC.x, sourceCeilRC.y, d + 1)
|
|
: 0.0,
|
|
hasNextRow ? getAValue(b, sourceFloorRC.x, sourceCeilRC.z, d)
|
|
: 0.0,
|
|
(hasNextRow && hasNextCol) ?
|
|
getAValue(b, sourceFloorRC.x, sourceCeilRC.z, d + 1) : 0.0);
|
|
|
|
vec4 bottomRight = vec4(
|
|
getAValue(b, sourceCeilRC.x, sourceCeilRC.y, d),
|
|
hasNextCol ? getAValue(b, sourceCeilRC.x, sourceCeilRC.y, d + 1)
|
|
: 0.0,
|
|
hasNextRow ? getAValue(b, sourceCeilRC.x, sourceCeilRC.z, d)
|
|
: 0.0,
|
|
(hasNextRow && hasNextCol) ?
|
|
getAValue(b, sourceCeilRC.x, sourceCeilRC.z, d + 1) : 0.0);
|
|
|
|
vec3 fracRC = sourceFracIndexRC - vec3(sourceFloorRC);
|
|
|
|
vec4 top = mix(topLeft, topRight, fracRC.yyzz);
|
|
vec4 bottom = mix(bottomLeft, bottomRight, fracRC.yyzz);
|
|
vec4 newValue = mix(top, bottom, fracRC.x);
|
|
|
|
setOutput(newValue);
|
|
}
|
|
`}};function Mte(e){let{inputs:t,backend:n,attrs:s}=e,{images:r}=t,{alignCorners:a,halfPixelCenters:o,size:i}=s,[l,u]=i,c=Y().getBool("WEBGL_PACK_IMAGE_OPERATIONS")?new Pte(r.shape,l,u,a,o):new Ote(r.shape,l,u,a,o);return n.runWebGLProgram(c,[r],"float32")}var zte={kernelName:go,backendName:"webgl",kernelFunc:Mte},Lte=class{constructor(e,t,n){this.variableNames=["dy"],this.outputShape=[],this.outputShape=t;let[,s,r]=t,[,a,o]=e,i=[n&&a>1?s-1:s,n&&o>1?r-1:r],l=[n&&a>1?a-1:a,n&&o>1?o-1:o],u=i[0]/l[0],c=i[1]/l[1],d=1/u,p=1/c,h=Math.ceil(d)*2+2,f=Math.ceil(p)*2+2;this.userCode=`
|
|
void main() {
|
|
ivec4 coords = getOutputCoords();
|
|
int b = coords[0];
|
|
int d = coords[3];
|
|
int r = coords[1];
|
|
int c = coords[2];
|
|
|
|
float accumulator = 0.0;
|
|
|
|
const float heightScale = float(${u});
|
|
const float widthScale = float(${c});
|
|
|
|
const float invHeightScale = float(${d});
|
|
const float invWidthScale = float(${p});
|
|
|
|
const int winHeight = int(${h});
|
|
const int winWidth = int(${f});
|
|
|
|
// Compute bounds for where in dy we will look
|
|
float startRLerp = floor(float(r) * invHeightScale);
|
|
int startDyR = int(startRLerp - float(winHeight / 2));
|
|
|
|
float startCLerp = floor(float(c) * invWidthScale);
|
|
int startDyC = int(startCLerp - float(winWidth / 2));
|
|
|
|
// Loop over dy
|
|
for (int dyROffset = 0; dyROffset < winHeight; dyROffset++) {
|
|
int dyR = dyROffset + startDyR;
|
|
|
|
// Guard against the window exceeding the bounds of dy
|
|
if (dyR < 0 || dyR >= ${a}) {
|
|
continue;
|
|
}
|
|
|
|
for (int dyCOffset = 0; dyCOffset < winWidth; dyCOffset++) {
|
|
int dyC = dyCOffset + startDyC;
|
|
|
|
// Guard against the window exceeding the bounds of dy
|
|
if (dyC < 0 || dyC >= ${o}) {
|
|
continue;
|
|
}
|
|
|
|
float dxR = float(dyR) * heightScale;
|
|
int topDxRIndex = int(floor(dxR));
|
|
int bottomDxRIndex = int(min(ceil(dxR), ${s-1}.0));
|
|
float dxRLerp = dxR - float(topDxRIndex);
|
|
float inverseDxRLerp = 1.0 - dxRLerp;
|
|
|
|
float dxC = float(dyC) * widthScale;
|
|
int leftDxCIndex = int(floor(dxC));
|
|
int rightDxCIndex = int(min(ceil(dxC), ${r-1}.0));
|
|
float dxCLerp = dxC - float(leftDxCIndex);
|
|
float inverseDxCLerp = 1.0 - dxCLerp;
|
|
|
|
if (r == topDxRIndex && c == leftDxCIndex) {
|
|
// topLeft
|
|
accumulator +=
|
|
getDy(b, dyR, dyC, d) * inverseDxRLerp * inverseDxCLerp;
|
|
}
|
|
|
|
if (r == topDxRIndex && c == rightDxCIndex) {
|
|
// topRight
|
|
accumulator += getDy(b, dyR, dyC, d) * inverseDxRLerp * dxCLerp;
|
|
}
|
|
|
|
if (r == bottomDxRIndex && c == leftDxCIndex) {
|
|
// bottomLeft
|
|
accumulator += getDy(b, dyR, dyC, d) * dxRLerp * inverseDxCLerp;
|
|
}
|
|
|
|
if (r == bottomDxRIndex && c == rightDxCIndex) {
|
|
// bottomRight
|
|
accumulator += getDy(b, dyR, dyC, d) * dxRLerp * dxCLerp;
|
|
}
|
|
}
|
|
}
|
|
// End loop over dy
|
|
|
|
setOutput(accumulator);
|
|
}
|
|
`}};function Bte(e){let{inputs:t,backend:n,attrs:s}=e,{images:r,dy:a}=t,{alignCorners:o}=s,i=new Lte(a.shape,r.shape,o);return n.runWebGLProgram(i,[a],a.dtype)}var Wte={kernelName:Bp,backendName:"webgl",kernelFunc:Bte},Vte=class{constructor(e,t,n,s,r){this.variableNames=["A"],this.outputShape=[];let[a,o,i,l]=e;this.outputShape=[a,t,n,l];let u=[s&&t>1?o-1:o,s&&n>1?i-1:i],c=[s&&t>1?t-1:t,s&&n>1?n-1:n],d=s?"0.5":"0.0",p;r?p="max((vec2(yRC) + vec2(0.5)) * effectiveInputOverOutputRatioRC, vec2(0.0))":p="vec2(yRC) * effectiveInputOverOutputRatioRC",this.userCode=`
|
|
const vec2 effectiveInputOverOutputRatioRC = vec2(
|
|
${u[0]/c[0]},
|
|
${u[1]/c[1]});
|
|
const vec2 inputShapeRC = vec2(${o}.0, ${i}.0);
|
|
|
|
void main() {
|
|
ivec4 coords = getOutputCoords();
|
|
int b = coords[0];
|
|
int d = coords[3];
|
|
ivec2 yRC = coords.yz;
|
|
|
|
// Fractional source index.
|
|
vec2 sourceFracIndexRC = ${p};
|
|
|
|
// Compute the coordinators of nearest neighbor point.
|
|
ivec2 sourceNearestRC = ivec2(
|
|
min(inputShapeRC - 1.0, floor(sourceFracIndexRC + ${d})));
|
|
float newValue = getA(b, sourceNearestRC.x, sourceNearestRC.y, d);
|
|
|
|
setOutput(newValue);
|
|
}
|
|
`}},Ute=class{constructor(e,t,n,s,r){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=[];let[a,o,i,l]=e;this.outputShape=[a,t,n,l];let u=[s&&t>1?o-1:o,s&&n>1?i-1:i],c=[s&&t>1?t-1:t,s&&n>1?n-1:n],d=s?"0.5":"0.0",p;r?p="max((vec3(yRC) + vec3(0.5)) * effectiveInputOverOutputRatioRC, vec3(0.0))":p="vec3(yRC) * effectiveInputOverOutputRatioRC",this.userCode=`
|
|
const vec3 effectiveInputOverOutputRatioRC = vec3(
|
|
${u[0]/c[0]},
|
|
${u[1]/c[1]},
|
|
${u[1]/c[1]});
|
|
const vec3 inputShapeRC = vec3(${o}.0, ${i}.0,
|
|
${i}.0);
|
|
|
|
float getAValue(int b, int r, int c, int d) {
|
|
return getChannel(getA(b, r, c, d), vec2(c, d));
|
|
}
|
|
|
|
void main() {
|
|
ivec4 coords = getOutputCoords();
|
|
int b = coords[0];
|
|
int d = coords[3];
|
|
// Calculate values for next column in yRC.z.
|
|
ivec3 yRC = coords.yzz + ivec3(0, 0, 1);
|
|
|
|
// Fractional source index.
|
|
vec3 sourceFracIndexRC = ${p};
|
|
|
|
// Compute the coordinators of nearest neighbor point.
|
|
ivec3 sourceNearestRC = ivec3(
|
|
min(inputShapeRC - 1.0, floor(sourceFracIndexRC + ${d})));
|
|
|
|
// Should we calculate next column and row elements in 2x2 packed cell.
|
|
bool hasNextCol = d < ${l-1};
|
|
bool hasNextRow = coords.z < ${n-1};
|
|
|
|
vec4 newValue = vec4(
|
|
getAValue(b, sourceNearestRC.x, sourceNearestRC.y, d),
|
|
hasNextCol ? getAValue(b, sourceNearestRC.x, sourceNearestRC.y, d + 1)
|
|
: 0.0,
|
|
hasNextRow ? getAValue(b, sourceNearestRC.x, sourceNearestRC.z, d)
|
|
: 0.0,
|
|
(hasNextRow && hasNextCol) ?
|
|
getAValue(b, sourceNearestRC.x, sourceNearestRC.z, d + 1) : 0.0);
|
|
|
|
setOutput(newValue);
|
|
}
|
|
`}};function Hte(e){let{inputs:t,backend:n,attrs:s}=e,{images:r}=t,{alignCorners:a,halfPixelCenters:o,size:i}=s,[l,u]=i,c=Y().getBool("WEBGL_PACK_IMAGE_OPERATIONS")?new Ute(r.shape,l,u,a,o):new Vte(r.shape,l,u,a,o);return n.runWebGLProgram(c,[r],r.dtype)}var Gte={kernelName:ic,backendName:"webgl",kernelFunc:Hte},jte=class{constructor(e,t,n){this.variableNames=["dy"],this.outputShape=[],this.outputShape=t;let[,s,r]=t,[,a,o]=e,i=[n&&a>1?s-1:s,n&&o>1?r-1:r],l=[n&&a>1?a-1:a,n&&o>1?o-1:o],u=i[0]/l[0],c=i[1]/l[1],d=1/u,p=1/c,h=Math.ceil(d)*2+2,f=Math.ceil(p)*2+2;this.userCode=`
|
|
void main() {
|
|
ivec4 coords = getOutputCoords();
|
|
int b = coords[0];
|
|
int d = coords[3];
|
|
int r = coords[1];
|
|
int c = coords[2];
|
|
|
|
float accumulator = 0.0;
|
|
|
|
const float heightScale = float(${u});
|
|
const float widthScale = float(${c});
|
|
|
|
const float invHeightScale = float(${d});
|
|
const float invWidthScale = float(${p});
|
|
|
|
const int winHeight = int(${h});
|
|
const int winWidth = int(${f});
|
|
|
|
// Compute bounds for where in dy we will look
|
|
float startRLerp = floor(float(r) * invHeightScale);
|
|
int startDyR = int(floor(startRLerp - float(winHeight / 2)));
|
|
|
|
float startCLerp = floor(float(c) * invWidthScale);
|
|
int startDyC = int(floor(startCLerp - float(winWidth / 2)));
|
|
|
|
// Loop over dy
|
|
for (int dyROffset = 0; dyROffset < winHeight; dyROffset++) {
|
|
int dyR = dyROffset + startDyR;
|
|
|
|
// Guard against the window exceeding the bounds of dy
|
|
if (dyR < 0 || dyR >= ${a}) {
|
|
continue;
|
|
}
|
|
|
|
for (int dyCOffset = 0; dyCOffset < winWidth; dyCOffset++) {
|
|
int dyC = dyCOffset + startDyC;
|
|
|
|
// Guard against the window exceeding the bounds of dy
|
|
if (dyC < 0 || dyC >= ${o}) {
|
|
continue;
|
|
}
|
|
|
|
float sourceFracRow =
|
|
float(${i[0]}) *
|
|
(float(dyR) / float(${l[0]}));
|
|
|
|
float sourceFracCol =
|
|
float(${i[1]}) *
|
|
(float(dyC) / float(${l[1]}));
|
|
|
|
int sourceNearestRow = int(min(
|
|
float(int(${s}) - 1),
|
|
${n} ? float(round(sourceFracRow)) :
|
|
float(floor(sourceFracRow))));
|
|
|
|
int sourceNearestCol = int(min(
|
|
float(int(${r}) - 1),
|
|
${n} ? float(round(sourceFracCol)) :
|
|
float(floor(sourceFracCol))));
|
|
|
|
if (r == sourceNearestRow && c == sourceNearestCol) {
|
|
accumulator += getDy(b, dyR, dyC, d);
|
|
}
|
|
}
|
|
}
|
|
// End loop over dy
|
|
|
|
setOutput(accumulator);
|
|
}
|
|
`}};function qte(e){let{inputs:t,backend:n,attrs:s}=e,{images:r,dy:a}=t,{alignCorners:o}=s,i=new jte(a.shape,r.shape,o);return n.runWebGLProgram(i,[a],a.dtype)}var Xte={kernelName:Lp,backendName:"webgl",kernelFunc:qte},Kte=class{constructor(e,t){this.variableNames=["x"];let n=e.length;if(n>4)throw new Error(`WebGL backend: Reverse of rank-${n} tensor is not yet supported`);if(this.outputShape=e,n===1){this.userCode=`
|
|
void main() {
|
|
int coord = getOutputCoords();
|
|
setOutput(getX(${e[0]} - coord - 1));
|
|
}
|
|
`;return}let s=o=>t.indexOf(o)!==-1&&e[o]!==1?`${e[o]} - coords[${o}] - 1`:`coords[${o}]`,r=e.map((o,i)=>s(i)).join(","),a=gt(n);this.userCode=`
|
|
void main() {
|
|
${a} coords = getOutputCoords();
|
|
setOutput(getX(${r}));
|
|
}
|
|
`}},Zte=class{constructor(e,t){this.variableNames=["x"],this.packedInputs=!0,this.packedOutput=!0;let n=e.length;if(n>4)throw new Error(`WebGL backend: Reverse of rank-${n} tensor is not yet supported`);this.outputShape=e;let s=Rn("rc",n),r=`${s[n-1]} + 1 < ${this.outputShape[n-1]}`,a=`${s[n-2]} + 1 < ${this.outputShape[n-2]}`,o=gt(n);n===1?this.userCode=`
|
|
void main(){
|
|
int rc = getOutputCoords();
|
|
vec4 result = vec4(0.);
|
|
result.r = getChannel(getX(${e[0]} - rc - 1),
|
|
${e[0]} - rc - 1);
|
|
if(${r}){
|
|
result.g = getChannel(getX(${e[0]} - (rc + 1) - 1),
|
|
${e[0]} - (rc + 1) - 1);
|
|
}
|
|
setOutput(result);
|
|
}
|
|
`:this.userCode=`
|
|
void main() {
|
|
${o} rc = getOutputCoords();
|
|
vec4 result = vec4(0.);
|
|
result.r = ${i(s.slice())};
|
|
if(${r}){
|
|
result.g = ${l(s.slice())};
|
|
}
|
|
if(${a}) {
|
|
result.b = ${u(s.slice())};
|
|
if(${r}) {
|
|
result.a = ${c(s.slice())};
|
|
}
|
|
}
|
|
setOutput(result);
|
|
}
|
|
`;function i(h){return d(h)}function l(h){return h[n-1]="("+h[n-1]+" + 1)",d(h)}function u(h){return h[n-2]="("+h[n-2]+" + 1)",d(h)}function c(h){return h[n-1]="("+h[n-1]+" + 1)",h[n-2]="("+h[n-2]+" + 1)",d(h)}function d(h){let f=e.map((A,y)=>p(y,h)),m=f.join(","),g=f.slice(-2).join(",");return`getChannel(getX(${m}), vec2(${g}))`}function p(h,f){return t.indexOf(h)!==-1&&e[h]!==1?`${e[h]} - ${f[h]} - 1`:`${f[h]}`}}};function Yte(e){let{inputs:t,backend:n,attrs:s}=e,{x:r}=t,{dims:a}=s,o=r.shape.length,i=w.parseAxisParam(a,r.shape);if(o===0)return ds({inputs:{x:r},backend:n});let l=Y().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new Zte(r.shape,i):new Kte(r.shape,i);return n.runWebGLProgram(l,[r],r.dtype)}var Jte={kernelName:yo,backendName:"webgl",kernelFunc:Yte},Qte=class{constructor(e,t){this.variableNames=["Image"],this.outputShape=[],this.customUniforms=[{name:"params",type:"vec4"}];let n=e[1],s=e[2];this.outputShape=e;let r="";typeof t=="number"?r=`float outputValue = ${t.toFixed(2)};`:r=`
|
|
vec3 fill = vec3(${t.join(",")});
|
|
float outputValue = fill[coords[3]];`,this.userCode=`
|
|
void main() {
|
|
ivec4 coords = getOutputCoords();
|
|
int x = coords[2];
|
|
int y = coords[1];
|
|
float coordXFloat = (float(x) - params[0]) * params[3] -
|
|
(float(y) - params[1]) * params[2];
|
|
float coordYFloat = (float(x) - params[0]) * params[2] +
|
|
(float(y) - params[1]) * params[3];
|
|
int coordX = int(round(coordXFloat + params[0]));
|
|
int coordY = int(round(coordYFloat + params[1]));
|
|
${r}
|
|
if(coordX >= 0 && coordX < ${s} && coordY >= 0 && coordY < ${n}) {
|
|
outputValue = getImage(coords[0], coordY, coordX, coords[3]);
|
|
}
|
|
setOutput(outputValue);
|
|
}
|
|
`}},ene={kernelName:Fl,backendName:"webgl",kernelFunc:({inputs:e,attrs:t,backend:n})=>{let{image:s}=e,{radians:r,fillValue:a,center:o}=t,i=n,l=new Qte(s.shape,a),[u,c]=_.getImageCenter(o,s.shape[1],s.shape[2]),d=[[u,c,Math.sin(r),Math.cos(r)]];return i.runWebGLProgram(l,[s],s.dtype,d)}},tne=`
|
|
// OpenGL ES does not support round function.
|
|
// The algorithm is based on banker's rounding.
|
|
float base = floor(x);
|
|
if ((x - base) < 0.5) {
|
|
return floor(x);
|
|
} else if ((x - base) > 0.5) {
|
|
return ceil(x);
|
|
} else {
|
|
if (mod(base, 2.0) == 0.0) {
|
|
return base;
|
|
} else {
|
|
return base + 1.0;
|
|
}
|
|
}
|
|
`,nne=tt({opSnippet:tne}),sne={kernelName:xo,backendName:"webgl",kernelFunc:nne},rne="return inversesqrt(x);",ane=tt({opSnippet:rne,cpuKernelImpl:_X}),one={kernelName:bo,backendName:"webgl",kernelFunc:ane},ek=class{constructor(e,t,n,s,r,a,o=!0){this.variableNames=["updates","indices","defaultValue"],this.outputShape=a;let i=gt(r.length),l=gt(a.length),u="";n===1?u="i":n===2&&(u="i, j");let c=`getIndices(${u})`,d="";s===1?d="i":s===2&&(d="i, coords[1]");let p=`getUpdates(${d})`,h=t>1?"strides[j]":"strides";this.userCode=`
|
|
${i} strides = ${i}(${r});
|
|
|
|
void main() {
|
|
${l} coords = getOutputCoords();
|
|
float sum = 0.0;
|
|
bool found = false;
|
|
for (int i = 0; i < ${e}; i++) {
|
|
int flattenedIndex = 0;
|
|
for (int j = 0; j < ${t}; j++) {
|
|
int index = round(${c});
|
|
flattenedIndex += index * ${h};
|
|
}
|
|
if (flattenedIndex == coords[0]) {
|
|
sum += ${p};
|
|
found = true;
|
|
}
|
|
}
|
|
setOutput(mix(getDefaultValue(), sum, float(found)));
|
|
}
|
|
`}};function ine(e){let{inputs:t,backend:n,attrs:s}=e,{indices:r,updates:a}=t,{shape:o}=s,{sliceRank:i,numUpdates:l,sliceSize:u,strides:c,outputSize:d}=_.calculateShapes(a,r,o),p=[d/u,u];if(d===0)return n.makeTensorInfo(o,r.dtype);let h=be({inputs:{x:r},backend:n,attrs:{shape:[l,i]}}),f=be({inputs:{x:a},backend:n,attrs:{shape:[l,u]}}),m=n.makeTensorInfo([],"float32",new Float32Array([0])),g=new ek(l,i,h.shape.length,f.shape.length,c,p),A=n.runWebGLProgram(g,[f,h,m],f.dtype),y=be({inputs:{x:A},backend:n,attrs:{shape:o}});return n.disposeIntermediateTensorInfo(h),n.disposeIntermediateTensorInfo(f),n.disposeIntermediateTensorInfo(A),n.disposeIntermediateTensorInfo(m),y}var lne={kernelName:bl,backendName:"webgl",kernelFunc:ine},une=class{constructor(e,t,n){this.variableNames=["c","a","b"],this.outputShape=t;let s,r;if(n>4)throw Error(`Where for rank ${n} is not yet supported`);if(n===1)r="resRC",s="resRC";else{let o=["resRC.x","resRC.y","resRC.z","resRC.w"],i=[],l=[];for(let u=0;u<t.length;u++)l.push(`${o[u]}`),u<e&&i.push(`${o[u]}`);s=i.join(),r=l.join()}let a=gt(n);this.userCode=`
|
|
void main() {
|
|
${a} resRC = getOutputCoords();
|
|
float cVal = getC(${s});
|
|
if (cVal >= 1.0) {
|
|
setOutput(getA(${r}));
|
|
} else {
|
|
setOutput(getB(${r}));
|
|
}
|
|
}
|
|
`}};function cne(e){let{inputs:t,backend:n}=e,{condition:s,t:r,e:a}=t,o=new une(s.shape.length,r.shape,r.shape.length);return n.runWebGLProgram(o,[s,r,a],Ds(r.dtype,a.dtype))}var dne={kernelName:vl,backendName:"webgl",kernelFunc:cne},pne=`
|
|
// Stable and Attracting Fixed Point (0, 1) for Normalized Weights.
|
|
// see: https://arxiv.org/abs/1706.02515
|
|
float scaleAlpha = ${_.SELU_SCALEALPHA};
|
|
float scale = ${_.SELU_SCALE};
|
|
return (x >= 0.0) ? scale * x : scaleAlpha * (exp(x) - 1.0);
|
|
`,hne=tt({opSnippet:pne}),fne={kernelName:wl,backendName:"webgl",kernelFunc:hne},tk="return 1.0 / (1.0 + exp(-1.0 * x));",mne=tt({opSnippet:tk,packedOpSnippet:tk,cpuKernelImpl:$X}),gne={kernelName:wo,backendName:"webgl",kernelFunc:mne},Ane=`
|
|
if (isnan(x)) { return 0.0; }
|
|
return sign(x);
|
|
`,yne=tt({opSnippet:Ane}),xne={kernelName:Sl,backendName:"webgl",kernelFunc:yne},bne=f4+`
|
|
return sin(x);
|
|
`,vne=tt({opSnippet:bne}),wne={kernelName:vo,backendName:"webgl",kernelFunc:vne},kne=`
|
|
float e2x = exp(x);
|
|
return (e2x - 1.0 / e2x) / 2.0;
|
|
`,Ine=tt({opSnippet:kne}),Sne={kernelName:Il,backendName:"webgl",kernelFunc:Ine},Cne=`
|
|
float epsilon = 1.1920928955078125e-7;
|
|
float threshold = log(epsilon) + 2.0;
|
|
|
|
bool too_large = x > -threshold;
|
|
bool too_small = x < threshold;
|
|
|
|
float result;
|
|
float exp_x = exp(x);
|
|
|
|
if (too_large){
|
|
result = x;
|
|
}
|
|
else if (too_small){
|
|
result = exp_x;
|
|
}
|
|
else{
|
|
result = log(exp_x + 1.0);
|
|
}
|
|
return result;
|
|
`,Tne=tt({opSnippet:Cne}),Nne={kernelName:Cl,backendName:"webgl",kernelFunc:Tne},Ene=e=>{let{inputs:t,backend:n,attrs:s}=e,{x:r}=t,{blockShape:a,paddings:o}=s;w.assert(r.shape.length<=4,()=>"spaceToBatchND for rank > 4 with a WebGL backend not implemented yet");let i=a.reduce((A,y)=>A*y),l=[[0,0]];l.push(...o);for(let A=1+a.length;A<r.shape.length;++A)l.push([0,0]);let u=[],c=J4({inputs:{x:r},backend:n,attrs:{paddings:l,constantValue:0}}),d=_.getReshaped(c.shape,a,i,!1),p=_.getPermuted(d.length,a.length,!1),h=_.getReshapedPermuted(c.shape,a,i,!1),f=be({inputs:{x:c},backend:n,attrs:{shape:d}}),m=Dn({inputs:{x:f},backend:n,attrs:{perm:p}}),g=be({inputs:{x:m},backend:n,attrs:{shape:h}});return u.push(c),u.push(f),u.push(m),u.forEach(A=>n.disposeIntermediateTensorInfo(A)),g},Rne={kernelName:Tl,backendName:"webgl",kernelFunc:Ene};function Dne(e){let{inputs:t,backend:n}=e,{indices:s,values:r,denseShape:a,defaultValue:o}=t;if(a.shape.length!==1)throw new Error(`Dense shape must be a vector, saw:
|
|
${a.shape}`);if(s.shape.length!==2)throw new Error(`Indices must be a matrix, saw:
|
|
${s.shape}`);if(r.shape.length!==1)throw new Error(`Values must be a vector, saw:
|
|
${r.shape}`);if(o.shape.length!==0)throw new Error(`Default value must be a scalar, saw:
|
|
${o.shape}`);let i=n.readSync(s.dataId),l=n.readSync(r.dataId),u=n.readSync(a.dataId),c=n.readSync(o.dataId)[0],[d,p,h,f,m]=OX(i,s.shape,s.dtype,l,r.dtype,u,c);return[n.makeTensorInfo(p,s.dtype,d),n.makeTensorInfo([p[0]],r.dtype,h),n.makeTensorInfo([f.length],"bool",new Uint8Array(f.map(g=>Number(g)))),n.makeTensorInfo([m.length],s.dtype,new Int32Array(m))]}var _ne={kernelName:Wp,backendName:"webgl",kernelFunc:Dne};function $ne(e){let{inputs:t,backend:n}=e,{inputIndices:s,inputShape:r,newShape:a}=t;if(s.shape.length!==2)throw new Error(`Input indices should be a matrix but received shape ${s.shape}`);if(r.shape.length!==1)throw new Error(`Input shape should be a vector but received shape ${r.shape}`);if(a.shape.length!==1)throw new Error(`Target shape should be a vector but received shape ${a.shape}`);let o=Array.from(n.readSync(r.dataId)),i=n.readSync(s.dataId),l=Array.from(n.readSync(a.dataId)),[u,c,d]=PX(i,s.shape,s.dtype,o,l);return[n.makeTensorInfo(c,s.dtype,u),n.makeTensorInfo([d.length],a.dtype,new Int32Array(d))]}var Fne={kernelName:Vp,backendName:"webgl",kernelFunc:$ne};function One(e){let{inputs:t,backend:n}=e,{data:s,indices:r,segmentIds:a}=t;if(s.shape.length<1)throw new Error("Data should be at least 1 dimensional but received scalar");if(r.shape.length!==1)throw new Error(`Indices should be a vector but received shape
|
|
${r.shape}`);if(a.shape.length!==1)throw new Error(`Segment ids should be a vector but received shape
|
|
${a.shape}`);let o=n.readSync(s.dataId),i=n.readSync(r.dataId),l=n.readSync(a.dataId),[u,c]=t4(o,s.shape,s.dtype,i,l,!0);return n.makeTensorInfo(c,s.dtype,u)}var Pne={kernelName:Up,backendName:"webgl",kernelFunc:One};function Mne(e){let{inputs:t,backend:n}=e,{data:s,indices:r,segmentIds:a}=t;if(s.shape.length<1)throw new Error("Data should be at least 1 dimensional but received scalar");if(r.shape.length!==1)throw new Error(`Indices should be a vector but received shape
|
|
${r.shape}`);if(a.shape.length!==1)throw new Error(`Segment ids should be a vector but received shape
|
|
${a.shape}`);let o=n.readSync(s.dataId),i=n.readSync(r.dataId),l=n.readSync(a.dataId),[u,c]=t4(o,s.shape,s.dtype,i,l);return n.makeTensorInfo(c,s.dtype,u)}var zne={kernelName:Hp,backendName:"webgl",kernelFunc:Mne};function Lne(e){let{inputs:t,backend:n,attrs:s}=e,{sparseIndices:r,sparseValues:a,defaultValue:o}=t,{outputShape:i}=s,{sliceRank:l,numUpdates:u,strides:c,outputSize:d}=_.calculateShapes(a,r,i),p=!1,h=new ek(u,l,r.shape.length,a.shape.length,c,[d,1],p),f=n.runWebGLProgram(h,[a,r,o],a.dtype),m=be({inputs:{x:f},backend:n,attrs:{shape:i}});return n.disposeIntermediateTensorInfo(f),m}var Bne={kernelName:Gp,backendName:"webgl",kernelFunc:Lne};function Wne(e){let{inputs:t,backend:n,attrs:s}=e,{x:r}=t,{numOrSizeSplits:a,axis:o}=s,i=w.parseAxisParam(o,r.shape)[0],l=_.prepareSplitSize(r,a,i),u=r.shape.length,c=new Array(u).fill(0),d=r.shape.slice();return l.map(p=>{let h=[...d];h[i]=p;let f=ku({inputs:{x:r},backend:n,attrs:{begin:c,size:h}});return c[i]+=p,f})}var Vne={kernelName:Nl,backendName:"webgl",kernelFunc:Wne},nk="return sqrt(x);",Une=tt({opSnippet:nk,packedOpSnippet:nk,cpuKernelImpl:MX}),Hne={kernelName:ko,backendName:"webgl",kernelFunc:Une},Gne="return x * x;",jne=tt({opSnippet:Gne}),qne={kernelName:lc,backendName:"webgl",kernelFunc:jne},sk="return (a - b) * (a - b);",Xne=An({opSnippet:sk,packedOpSnippet:sk}),Kne={kernelName:Co,backendName:"webgl",kernelFunc:Xne};function Zne({inputs:e,attrs:t,backend:n}){let{x:s}=e,r=Js+`
|
|
return x > 0.0 ? 1.0 : float(${t.alpha});
|
|
`,a=new wa(s.shape,r);return n.runWebGLProgram(a,[s],s.dtype)}var Yne={kernelName:ea,backendName:"webgl",kernelFunc:Zne},Jne=class{constructor(e,t,n){this.variableNames=["x"],this.outputShape=n;let s=n.length,r=gt(n.length),a=gt(n.length),o="";if(s===1)o="coords * strides + begin";else{let i=0;o=n.map((l,u)=>(i++,n.length===1?`coords * strides[${u}] + begin[${u}]`:`coords[${i-1}] * strides[${u}] + begin[${u}]`)).join(",")}this.userCode=`
|
|
${r} begin = ${r}(${e});
|
|
${r} strides = ${r}(${t});
|
|
|
|
void main() {
|
|
${a} coords = getOutputCoords();
|
|
setOutput(getX(${o}));
|
|
}
|
|
`}};function Qne(e){let{inputs:t,backend:n,attrs:s}=e,{x:r}=t,{begin:a,end:o,strides:i,beginMask:l,endMask:u,ellipsisMask:c,newAxisMask:d,shrinkAxisMask:p}=s,{nonStrided:h,$begin:f,$strides:m,size:g,newShape:A,outShape:y}=Cn.sliceInfo(r.shape,a,o,i,l,u,c,d,p),x=be({inputs:{x:r},backend:n,attrs:{shape:A}}),b;if(h){let k=ku({inputs:{x},backend:n,attrs:{begin:f,size:g}});b=be({inputs:{x:k},backend:n,attrs:{shape:y}}),n.disposeIntermediateTensorInfo(k)}else if(y.some(k=>k===0))b=n.makeTensorInfo(y,r.dtype,[]);else if(n.shouldExecuteOnCPU([x])){let C=n.texData.get(x.dataId).values,D=je(x.shape,x.dtype,C),O=zX(y,D,m,f);b=n.makeTensorInfo(y,x.dtype,O.values)}else{let S=new Jne(f,m,y);b=n.runWebGLProgram(S,[x],x.dtype)}let v=be({inputs:{x:b},backend:n,attrs:{shape:y}});return n.disposeIntermediateTensorInfo(x),n.disposeIntermediateTensorInfo(b),v}var ese={kernelName:El,backendName:"webgl",kernelFunc:Qne};function tse(e){let{inputs:t,backend:n,attrs:s}=e,{separator:r,nGramWidths:a,leftPad:o,rightPad:i,padWidth:l,preserveShortSequences:u}=s,{data:c,dataSplits:d}=t,p=n.readSync(c.dataId),h=n.readSync(d.dataId),[f,m]=LX(p,h,r,a,o,i,l,u);return[n.makeTensorInfo([f.length],"string",f),n.makeTensorInfo(d.shape,"int32",m)]}var nse={kernelName:jp,backendName:"webgl",kernelFunc:tse};function sse(e){let{inputs:t,backend:n,attrs:s}=e,{skipEmpty:r}=s,{input:a,delimiter:o}=t;if(a.dtype!=="string")throw new Error("Input must be of datatype string");if(a.shape.length!==1)throw new Error(`Input must be a vector, got shape: ${a.shape}`);if(o.shape.length!==0)throw new Error(`Delimiter must be a scalar, got shape: ${o.shape}`);let i=n.readSync(a.dataId),l=n.readSync(o.dataId)[0],[u,c,d]=BX(i,l,r),p=c.length;return[n.makeTensorInfo([p,2],"int32",u),n.makeTensorInfo([p],"string",c),n.makeTensorInfo([2],"int32",new Int32Array(d))]}var rse={kernelName:qp,backendName:"webgl",kernelFunc:sse};function ase(e){let{inputs:t,backend:n,attrs:s}=e,{numBuckets:r}=s,{input:a}=t;if(a.dtype!=="string")throw new Error("Input must be of datatype string");if(r<=0)throw new Error("Number of buckets must be at least 1");let o=n.readSync(a.dataId),i=WX(o,r);return n.makeTensorInfo(a.shape,"int32",i)}var ose={kernelName:Xp,backendName:"webgl",kernelFunc:ase},ise="return tan(x);",lse=tt({opSnippet:ise}),use={kernelName:No,backendName:"webgl",kernelFunc:lse},cse=`
|
|
float e2x = exp(-2.0 * abs(x));
|
|
return sign(x) * (1.0 - e2x) / (1.0 + e2x);
|
|
`,dse=tt({opSnippet:cse}),pse={kernelName:Eo,backendName:"webgl",kernelFunc:dse},hse=class{constructor(e,t){this.variableNames=["A"];let n=new Array(e.length);for(let a=0;a<n.length;a++)n[a]=e[a]*t[a];this.outputShape=n,this.rank=n.length;let s=gt(this.rank),r=fse(e);this.userCode=`
|
|
void main() {
|
|
${s} resRC = getOutputCoords();
|
|
setOutput(getA(${r}));
|
|
}
|
|
`}};function fse(e){let t=e.length;if(t>5)throw Error(`Tile for rank ${t} is not yet supported`);if(t===1)return`imod(resRC, ${e[0]})`;let n=["resRC.x","resRC.y","resRC.z","resRC.w","resRC.u"],s=[];for(let r=0;r<e.length;r++)s.push(`imod(${n[r]}, ${e[r]})`);return s.join()}function rk(e){let{inputs:t,backend:n,attrs:s}=e,{x:r}=t,{reps:a}=s;if(r.dtype==="string"||r.shape.length>5){let l=n.readSync(r.dataId),u=r.dtype==="string"?l.map(p=>w.decodeString(p)):l,c=je(r.shape,r.dtype,u),d=UX(c,a);return n.makeTensorInfo(d.shape,d.dtype,d.values)}let o=new hse(r.shape,a);return n.runWebGLProgram(o,[r],r.dtype)}var mse={kernelName:Qr,backendName:"webgl",kernelFunc:rk},gse=class{constructor(e){this.variableNames=["x","indices"],this.customUniforms=[{name:"n",type:"int"},{name:"firstPass",type:"int"},{name:"negativeInf",type:"float"},{name:"dir",type:"int"},{name:"inc",type:"int"}],this.outputShape=e,this.userCode=`
|
|
void main() {
|
|
ivec2 coords = getOutputCoords();
|
|
int batch = coords[0];
|
|
int elemIdx = coords[1];
|
|
|
|
// We compare elements pair-wise within a group of size 2 * inc.
|
|
// The comparing rule for each group alternates between ascending
|
|
// and descending. Within each group, we compare each pair at
|
|
// positions i and i+inc. To decide whether an element at position i
|
|
// is x0 or x1, we mod it by 2 * inc, if the result is smaller than
|
|
// inc, it is in the first half of the group, we denote it as x0,
|
|
// otherwise we denote it as x1.
|
|
// For example, as shown in the Bitonic top K paper referenced above,
|
|
// Figure5(a) shows that element[1] is in the
|
|
// second half of the group when group size is 2, but it is in the
|
|
// first half of the group when group size is 4.
|
|
|
|
bool isFirstInPair = imod(elemIdx, 2 * inc) < inc;
|
|
int i = isFirstInPair ? elemIdx : elemIdx - inc;
|
|
|
|
int i0 = firstPass == 1 ? i : int(getIndices(batch, i));
|
|
int i1 = firstPass == 1 ? i + inc : int(getIndices(batch, i + inc));
|
|
float x0 = i0 < n ? getX(batch, i0) : negativeInf;
|
|
float x1 = i1 < n ? getX(batch, i1) : negativeInf;
|
|
|
|
// Denotes which direction indices are in (ascending or descending).
|
|
bool reverse = imod(elemIdx, 2 * dir) >= dir;
|
|
bool isGreater = x0 > x1 || (x0 == x1 && i1 > i0);
|
|
if (reverse == isGreater) { // Elements in opposite order of direction
|
|
int iTemp = i0;
|
|
i0 = i1;
|
|
i1 = iTemp;
|
|
}
|
|
if (isFirstInPair) {
|
|
setOutput(float(i0));
|
|
} else {
|
|
setOutput(float(i1));
|
|
}
|
|
}
|
|
`}},Ase=class{constructor(e){this.variableNames=["x","indices"],this.customUniforms=[{name:"n",type:"int"},{name:"firstPass",type:"int"},{name:"k",type:"int"}],this.outputShape=e,this.userCode=`
|
|
void main() {
|
|
// Takes max of indices (0, k), (1, k + 1), (2, k + 2) ...
|
|
ivec2 coords = getOutputCoords();
|
|
int batch = coords[0];
|
|
int elemIdx = coords[1];
|
|
|
|
// The output size is half of the previous size.
|
|
// If the previous sequence is | | | | _ _ _ _ | | | | _ _ _ _ (k=4),
|
|
// we only need to output the indices at positions |, the indices at
|
|
// positions _ can be thrown away, see Figure5(b) After Phase 2
|
|
// (Merge phase) in the Bitonic Top K paper referenced above.
|
|
// For example, the paper shows we only need to output the orange bars.
|
|
// The output sequence should look like this | | | | | | | |.
|
|
// Because the sequence is halved, to map the output index back
|
|
// to the previous sequence to find the corresponding value,
|
|
// we need to double the index. When we double the index,
|
|
// we basically interpolate a position, so 2i looks like
|
|
// | _ | _ | _ | _ | _ | _ | _. We move the | to the first k position
|
|
// of each 2k positions by - elemIdx % k. E.g. for output at
|
|
// index 4,5,6,7, we want to get the corresponding element at
|
|
// original index 8,9,10,11, for output at index 8,9,10,11,
|
|
// we want to get the corresponding element at original index
|
|
// 16,17,18,19, so on and so forth.
|
|
|
|
int i = elemIdx < k ? elemIdx : (elemIdx * 2 - imod(elemIdx, k));
|
|
int i0 = firstPass == 1 ? i : int(getIndices(batch, i));
|
|
int i1 = firstPass == 1 ? i + k : int(getIndices(batch, i + k));
|
|
|
|
float x0 = getX(batch, i0);
|
|
float x1 = i1 < n ? getX(batch, i1) : x0;
|
|
|
|
setOutput(x0 >= x1 ? float(i0) : float(i1));
|
|
}
|
|
`}};function hi(e,t){t!==null&&e.disposeIntermediateTensorInfo(t)}function ak(e){let t=1;for(;t<e;)t*=2;return t}function yse(e){let{inputs:t,backend:n,attrs:s}=e,{x:r}=t,{k:a,sorted:o}=s,i=Y().getNumber("TOPK_LAST_DIM_CPU_HANDOFF_SIZE_THRESHOLD"),l=Y().getNumber("TOPK_K_CPU_HANDOFF_THRESHOLD"),u=r.shape,c=u[u.length-1];if(n.shouldExecuteOnCPU([r])||c<i||a>l){let O=n.readSync(r.dataId),[E,R]=HX(O,u,r.dtype,a,o);return[n.makeTensorInfo(E.shape,E.dtype,E.values),n.makeTensorInfo(R.shape,R.dtype,R.values)]}if(a===0)return u[u.length-1]=0,[n.makeTensorInfo(u,r.dtype,[]),n.makeTensorInfo(u,"int32",[])];if(c===1)return[r,vd({attrs:{shape:u,dtype:"int32",value:0},backend:n})];let d=n.texData.get(r.dataId),p=d!==null&&d.isPacked,h=p?n.unpackTensor(r):r,m=w.sizeFromShape(u)/c,g=be({inputs:{x:h},attrs:{shape:[m,c]},backend:n});p&&hi(n,h);let A=ak(a),y=ak(c),x=null,b=()=>x===null?[g,g]:[g,x],v=(O,E,R)=>{let T=b(),P=new gse(R),j=[[c],[x===null?1:0],[Number.NEGATIVE_INFINITY],[O],[E]],q=x;x=n.runWebGLProgram(P,T,"int32",j),hi(n,q)};for(let O=1;O<A;O*=2){let E=O*2;for(let R=O;R>=1;R/=2)v(E,R,[m,y])}for(let O=y;O>A;O/=2){let E=b(),R=new Ase([m,O/2]),P=[[c],[x===null?1:0],[A]],U=x;x=n.runWebGLProgram(R,E,"int32",P),hi(n,U);let j=A/2,q=j*2;for(let X=j;X>=1;X/=2)v(q,X,x.shape)}let k=x;x=ku({inputs:{x},backend:n,attrs:{begin:0,size:[m,a]}}),hi(n,k);let S=H4({inputs:{x:g,indices:x},backend:n,attrs:{axis:1,batchDims:1}});hi(n,g);let C=u.slice(0,-1);C.push(a),k=x,x=be({inputs:{x},attrs:{shape:C},backend:n}),hi(n,k);let D=S;return S=be({inputs:{x:S},attrs:{shape:C},backend:n}),hi(n,D),[S,x]}var xse={kernelName:Rl,backendName:"webgl",kernelFunc:yse},bse=class{constructor(e,t,n,s,r,a){this.variableNames=["Image","Transforms"],this.outputShape=a;let o=n==="nearest"?1:2,i;switch(s){case"constant":i=1;break;case"reflect":i=2;break;case"wrap":i=3;break;case"nearest":i=4;break;default:i=1;break}this.userCode=`
|
|
float mapCoord(float outCoord, float len) {
|
|
float inCoord = outCoord;
|
|
if(${i} == 2) {
|
|
if (inCoord < 0.0) {
|
|
if (len <= 1.0) {
|
|
inCoord = 0.0;
|
|
} else {
|
|
float sz2 = 2.0 * len;
|
|
if (inCoord < sz2) {
|
|
inCoord = sz2 * float(int(float(-inCoord / sz2))) +
|
|
inCoord;
|
|
}
|
|
inCoord = inCoord < -len ? inCoord + sz2 : -inCoord - 1.0;
|
|
}
|
|
} else if (inCoord > len - 1.0) {
|
|
if (len <= 1.0) {
|
|
inCoord = 0.0;
|
|
} else {
|
|
float sz2 = 2.0 * len;
|
|
inCoord -= sz2 * float(int(float(inCoord / sz2)));
|
|
if (inCoord >= len) {
|
|
inCoord = sz2 - inCoord - 1.0;
|
|
}
|
|
}
|
|
}
|
|
return clamp(inCoord, 0.0, len - 1.0);
|
|
} else if (${i} == 3) {
|
|
if (inCoord < 0.0) {
|
|
if (len <= 1.0) {
|
|
inCoord = 0.0;
|
|
} else {
|
|
float sz = len - 1.0;
|
|
inCoord += len * (float(int(float(-inCoord / sz))) + 1.0);
|
|
}
|
|
} else if (inCoord > len - 1.0) {
|
|
if (len <= 1.0) {
|
|
inCoord = 0.0;
|
|
} else {
|
|
float sz = len - 1.0;
|
|
inCoord -= len * float(int(float(inCoord / sz)));
|
|
}
|
|
}
|
|
return clamp(inCoord, 0.0, len - 1.0);
|
|
} else if (${i} == 4) {
|
|
return clamp(outCoord, 0.0, len - 1.0);
|
|
} else {
|
|
return outCoord;
|
|
}
|
|
}
|
|
|
|
float readWithFillValue(int batch, int coordY, int coordX,
|
|
int channel) {
|
|
float outputValue;
|
|
if (0 <= coordY && coordY < ${e} && 0 <= coordX && coordX < ${t}) {
|
|
outputValue = getImage(batch, coordY, coordX, channel);
|
|
} else {
|
|
outputValue = float(${r});
|
|
}
|
|
return outputValue;
|
|
}
|
|
|
|
void main() {
|
|
ivec4 coords = getOutputCoords();
|
|
float outputValue;
|
|
int batch = coords[0];
|
|
int x = coords[2];
|
|
int y = coords[1];
|
|
int channel = coords[3];
|
|
float xf = float(x);
|
|
float yf = float(y);
|
|
float a1 = getTransforms(batch, 0);
|
|
float a2 = getTransforms(batch, 1);
|
|
float a3 = getTransforms(batch, 2);
|
|
float b1 = getTransforms(batch, 3);
|
|
float b2 = getTransforms(batch, 4);
|
|
float b3 = getTransforms(batch, 5);
|
|
float c1 = getTransforms(batch, 6);
|
|
float c2 = getTransforms(batch, 7);
|
|
float projection = c1 * xf + c2 * yf + 1.0;
|
|
if (projection == 0.0) {
|
|
outputValue = float(${r});
|
|
} else {
|
|
float inX = (a1 * xf + a2 * yf + a3) / projection;
|
|
float inY = (b1 * xf + b2 * yf + b3) / projection;
|
|
float mapX = mapCoord(inX, float(${t}));
|
|
float mapY = mapCoord(inY, float(${e}));
|
|
|
|
if (${o} == 1) {
|
|
int coordY = int(round(mapY));
|
|
int coordX = int(round(mapX));
|
|
outputValue = readWithFillValue(batch, coordY, coordX,
|
|
channel);
|
|
} else {
|
|
float yFloor = floor(mapY);
|
|
float xFloor = floor(mapX);
|
|
float yCeil = yFloor + 1.0;
|
|
float xCeil = xFloor + 1.0;
|
|
float valueYFloor = (xCeil - mapX) *
|
|
readWithFillValue(batch, int(yFloor), int(xFloor), channel) +
|
|
(mapX - xFloor) *
|
|
readWithFillValue(batch, int(yFloor), int(xCeil), channel);
|
|
float valueYCeil = (xCeil - mapX) *
|
|
readWithFillValue(batch, int(yCeil), int(xFloor), channel) +
|
|
(mapX - xFloor) *
|
|
readWithFillValue(batch, int(yCeil), int(xCeil), channel);
|
|
outputValue = (yCeil - mapY) * valueYFloor +
|
|
(mapY - yFloor) * valueYCeil;
|
|
}
|
|
}
|
|
setOutput(outputValue);
|
|
}
|
|
`}};function vse(e){let{inputs:t,backend:n,attrs:s}=e,{image:r,transforms:a}=t,{interpolation:o,fillMode:i,fillValue:l,outputShape:u}=s,[c,d,p,h]=r.shape,[f,m]=u!=null?u:[d,p],g=[c,f,m,h],A=new bse(d,p,o,i,l,g);return n.runWebGLProgram(A,[r,a],"float32")}var wse={kernelName:Dl,backendName:"webgl",kernelFunc:vse};function kse(e){let{inputs:t,attrs:n,backend:s}=e,{axis:r}=n,{x:a}=t;mu(a,"unique"),console.warn("WARNING: ","UI might be locked temporarily as data is being downloaded");let o=s.readSync(a.dataId),{outputValues:i,outputShape:l,indices:u}=GX(o,r,a.shape,a.dtype);return[s.makeTensorInfo(l,a.dtype,i),s.makeTensorInfo([u.length],"int32",u)]}var Ise={kernelName:Kp,backendName:"webgl",kernelFunc:kse};function Sse(e){let{inputs:t,backend:n,attrs:s}=e,{value:r}=t,{axis:a}=s;a<0&&(a+=r.shape.length);let o=r,i=o.shape.length,l=r.shape[a],u=new Array(i-1),c=0;for(let m=0;m<i;m++)m!==a&&(u[c++]=o.shape[m]);let d=[],p=new Array(i).fill(0),h=o.shape.slice();h[a]=1;let f=new Array(l);for(let m=0;m<f.length;m++){p[a]=m;let g=ku({inputs:{x:o},backend:n,attrs:{begin:p,size:h}}),A=be({inputs:{x:g},backend:n,attrs:{shape:u}});f[m]=A,d.push(g)}return d.forEach(m=>n.disposeIntermediateTensorInfo(m)),f}var Cse={kernelName:_l,backendName:"webgl",kernelFunc:Sse},Tse=class{constructor(e,t){this.variableNames=["x","segmentIds"];let n=e.windowSize,s=e.batchSize,r=e.inSize,a=e.numSegments,o=a*Math.ceil(r/n);this.outputShape=[s,o];let i="0.0",l="sumValue",u=Math.floor(n/4)*4,c=n%4,d=`
|
|
sumValue += dot(values, segFilter);
|
|
`,p="";r%n>0&&(p=`
|
|
if (inIdx < 0 || inIdx >= ${r}) {
|
|
return initializationValue;
|
|
}
|
|
`);let h="";r%n>0&&(h=`
|
|
if (inIdx < 0 || inIdx >= ${r}) {
|
|
return -1.0;
|
|
}
|
|
`),this.userCode=`
|
|
const float initializationValue = ${i};
|
|
|
|
float getValue(int batch, int inIdx) {
|
|
${p}
|
|
return getX(batch, inIdx);
|
|
}
|
|
|
|
float getSegmentIdAtIndex(int inIdx) {
|
|
${h}
|
|
return getSegmentIds(inIdx);
|
|
}
|
|
|
|
void main() {
|
|
ivec2 coords = getOutputCoords();
|
|
int batch = coords[0];
|
|
int outIdx = coords[1];
|
|
int inOffset = int(floor(float(outIdx) / float(
|
|
${a})) * float(${n}));
|
|
int currentSeg = int(mod(float(outIdx), float(${a})));
|
|
|
|
float sumValue = 0.0;
|
|
|
|
for (int i = 0; i < ${u}; i += 4) {
|
|
int inIdx = inOffset + i;
|
|
vec4 values = vec4(
|
|
getValue(batch, inIdx),
|
|
getValue(batch, inIdx + 1),
|
|
getValue(batch, inIdx + 2),
|
|
getValue(batch, inIdx + 3)
|
|
);
|
|
|
|
vec4 segFilter = vec4(
|
|
int(getSegmentIdAtIndex(inIdx)) == currentSeg ? 1 : 0,
|
|
int(getSegmentIdAtIndex(inIdx + 1)) == currentSeg ? 1 : 0,
|
|
int(getSegmentIdAtIndex(inIdx + 2)) == currentSeg ? 1 : 0,
|
|
int(getSegmentIdAtIndex(inIdx + 3)) == currentSeg ? 1 : 0
|
|
);
|
|
|
|
${d}
|
|
}
|
|
|
|
int inIdx = inOffset + ${u};
|
|
if (${c===1}) {
|
|
vec4 values = vec4(
|
|
getValue(batch, inIdx),
|
|
initializationValue,
|
|
initializationValue,
|
|
initializationValue
|
|
);
|
|
|
|
int inIdxSeg = int(getSegmentIdAtIndex(inIdx));
|
|
|
|
vec4 segFilter = vec4(
|
|
int(getSegmentIdAtIndex(inIdx)) == currentSeg ? 1 : 0,
|
|
0,
|
|
0,
|
|
0
|
|
);
|
|
|
|
${d}
|
|
} else if (${c===2}) {
|
|
vec4 values = vec4(
|
|
getValue(batch, inIdx),
|
|
getValue(batch, inIdx + 1),
|
|
initializationValue,
|
|
initializationValue
|
|
);
|
|
|
|
vec4 segFilter = vec4(
|
|
int(getSegmentIdAtIndex(inIdx)) == currentSeg ? 1 : 0,
|
|
int(getSegmentIdAtIndex(inIdx + 1)) == currentSeg ? 1 : 0,
|
|
0,
|
|
0
|
|
);
|
|
|
|
${d}
|
|
} else if (${c===3}) {
|
|
vec4 values = vec4(
|
|
getValue(batch, inIdx),
|
|
getValue(batch, inIdx + 1),
|
|
getValue(batch, inIdx + 2),
|
|
initializationValue
|
|
);
|
|
|
|
vec4 segFilter = vec4(
|
|
int(getSegmentIdAtIndex(inIdx)) == currentSeg ? 1 : 0,
|
|
int(getSegmentIdAtIndex(inIdx + 1)) == currentSeg ? 1 : 0,
|
|
int(getSegmentIdAtIndex(inIdx + 2)) == currentSeg ? 1 : 0,
|
|
0
|
|
);
|
|
|
|
${d}
|
|
}
|
|
setOutput(${l});
|
|
}
|
|
`}};function Nse(e){let{inputs:t,backend:n,attrs:s}=e,{x:r,segmentIds:a}=t,{numSegments:o}=s,i=r.shape.length,l=[],u=0,c=_.getAxesPermutation([u],i),d=r;c!=null&&(d=Dn({inputs:{x:r},backend:n,attrs:{perm:c}}),l.push(d),u=_.getInnerMostAxes(1,i)[0]);let p=_.segment_util.computeOutShape(d.shape,u,o),h=w.sizeFromShape([d.shape[u]]),f=be({inputs:{x:d},backend:n,attrs:{shape:[-1,h]}});l.push(f);let m=nh(r.dtype),g=(b,v,k,S,C)=>{let D=b.shape[0],O=b.shape[1],E=_.segment_util.segOpComputeOptimalWindowSize(O,C),R={windowSize:E,inSize:O,batchSize:D,numSegments:C},T=new Tse(R,v),P=n.compileAndRun(T,[b,k],S);if(l.push(P),P.shape[1]===C)return P;let U=Q4({backend:n,attrs:{start:0,stop:C,step:1,dtype:"float32"}}),j=rk({inputs:{x:U},backend:n,attrs:{reps:[O/E]}});return l.push(U),l.push(j),g(P,v,j,S,C)},A=g(f,"unsortedSegmentSum",a,m,o),y=be({inputs:{x:A},backend:n,attrs:{shape:p}}),x=y;if(c!=null){l.push(y);let b=_.getUndoAxesPermutation(c);x=Dn({inputs:{x},backend:n,attrs:{perm:b}})}return l.forEach(b=>n.disposeIntermediateTensorInfo(b)),x}var Ese={kernelName:uc,backendName:"webgl",kernelFunc:Nse},Rse=[ree,iee,HK,jK,KK,JK,eZ,sZ,aZ,iZ,dZ,hZ,gZ,xZ,CZ,wZ,EZ,$Z,DZ,MZ,LZ,WZ,GZ,JZ,eY,oY,lY,pY,mY,SK,bY,RY,_Y,IY,PY,zY,FY,WY,HY,qY,KY,YY,eJ,oJ,lJ,nJ,dJ,fJ,gJ,bJ,IJ,NJ,DJ,_J,$J,OJ,MJ,LJ,WJ,UJ,qJ,ZJ,QJ,tQ,rQ,iQ,dQ,mQ,IK,AQ,yY,bQ,kQ,CQ,TK,RQ,FQ,PQ,UQ,BQ,qQ,ZQ,eee,uee,Aee,mee,vee,kee,See,hee,Tee,Eee,$ee,Mee,Wee,Kee,_K,Yee,ete,ste,ote,nY,ute,dte,hte,gte,bte,EK,wte,kte,sY,Gee,Cte,Fte,Rte,FK,zte,Wte,Gte,Xte,Jte,ene,sne,one,lne,dne,fne,gne,xne,wne,Sne,ZZ,qee,Nne,Rne,_ne,Fne,Pne,zne,Bne,Vne,Hne,qne,Kne,Yne,ese,nse,rse,ose,jee,WK,use,pse,mse,xse,wse,VK,Ise,Cse,Ese,cte];for(let e of Rse)Fo(e);var jn;(function(e){e[e.float32=0]="float32",e[e.int32=1]="int32",e[e.bool=2]="bool",e[e.string=3]="string",e[e.complex64=4]="complex64"})(jn||(jn={}));var wd;(function(e){e[e.linear=0]="linear",e[e.relu=1]="relu",e[e.relu6=2]="relu6",e[e.prelu=3]="prelu",e[e.leakyrelu=4]="leakyrelu",e[e.sigmoid=5]="sigmoid",e[e.elu=6]="elu"})(wd||(wd={}));var ok;function Dse(e){ok=e.wasm.cwrap(Do,null,["number","array","number","number","array","number","number","number","number","number","number","number","number"])}function _se(e){let{inputs:t,backend:n,attrs:s}=e,{a:r,b:a,bias:o,preluActivationWeights:i}=t;if(r.dtype!=="float32"||a.dtype!=="float32")throw new Error("_FusedMatMul for non non-float32 tensors not yet supported.");let{transposeA:l,transposeB:u,activation:c,leakyreluAlpha:d}=s,p=n.dataIdMap.get(r.dataId).id,h=n.dataIdMap.get(a.dataId).id,f=0;if(o!=null){let C=n.dataIdMap.get(o.dataId);if(C.shape.length!==1)throw new Error(`_FusedMatMul only supports rank-1 bias but got rank ${C.shape.length}.`);f=C.id}let m=i==null?0:n.dataIdMap.get(i.dataId).id,g=wd[c];if(g==null)throw new Error(`${c} activation not yet supported for FusedConv2D in the wasm backend.`);let A=l?r.shape[2]:r.shape[1],y=u?a.shape[1]:a.shape[2],x=r.shape[0],b=n.makeOutput([x,A,y],r.dtype),v=n.dataIdMap.get(b.dataId).id,k=new Uint8Array(new Int32Array(r.shape).buffer),S=new Uint8Array(new Int32Array(a.shape).buffer);return ok(p,k,r.shape.length,h,S,a.shape.length,l,u,g,f,m,d||0,v),b}var $se={kernelName:Do,backendName:"wasm",setupFunc:Dse,kernelFunc:_se};function yn(e){let t;function n(r){t=r.wasm.cwrap(e,null,["number","number"])}function s(r){let{backend:a,inputs:{x:o}}=r,i=a.dataIdMap.get(o.dataId).id,l=a.makeOutput(o.shape,o.dtype),u=a.dataIdMap.get(l.dataId).id;return w.sizeFromShape(l.shape)===0||t(i,u),l}return{kernelName:e,backendName:"wasm",setupFunc:n,kernelFunc:s}}var Fse=yn(Fi);function _n(e,t,n){let s;function r(o){s=o.wasm.cwrap(e,null,["number","array","number","number","array","number","number","number"])}function a(o){let{backend:i,inputs:l}=o,{a:u,b:c}=l,d=i.dataIdMap.get(u.dataId).id,p=i.dataIdMap.get(c.dataId).id,h=n!=null?n:u.dtype,f=_.assertAndGetBroadcastShape(u.shape,c.shape),m=i.makeOutput(f,h);if(w.sizeFromShape(f)===0)return m;let g=new Uint8Array(new Int32Array(u.shape).buffer),A=new Uint8Array(new Int32Array(c.shape).buffer),y=i.dataIdMap.get(m.dataId).id,x=()=>s(d,g,u.shape.length,p,A,c.shape.length,jn[u.dtype],y);if(t&&u.dtype==="float32")return x(),m;let b=_.getBroadcastDims(u.shape,f),v=_.getBroadcastDims(c.shape,f),k=b.every((C,D)=>C===D),S=v.every((C,D)=>C===D);if(k&&S)return x(),m;throw new Error(`Broadcasting along outer dims is not yet supported for ${u.dtype} ${e}.`)}return{kernelName:e,backendName:"wasm",setupFunc:r,kernelFunc:a}}var Ose=!0,Pse=_n(Yr,Ose),ik;function Mse(e){ik=e.wasm.cwrap(Fa,null,["array","number","number","number"])}function zse(e){let{inputs:t,backend:n}=e,s=n.makeOutput(t[0].shape,t[0].dtype);if(w.sizeFromShape(s.shape)===0)return s;let r=t.map(i=>n.dataIdMap.get(i.dataId).id),a=new Uint8Array(new Int32Array(r).buffer),o=n.dataIdMap.get(s.dataId).id;return ik(a,r.length,jn[s.dtype],o),s}var Lse={kernelName:Fa,backendName:"wasm",setupFunc:Mse,kernelFunc:zse};function o0(e){let{inputs:{x:t},backend:n}=e,s=n.makeOutput(t.shape,t.dtype),r=n.typedArrayFromHeap(t);return n.typedArrayFromHeap(s).set(r),s}var Bse={kernelName:Qa,backendName:"wasm",kernelFunc:o0},lk;function Wse(e){lk=e.wasm.cwrap(Ro,null,["number","array","number","number","number","array","number"])}function Cu(e){let{inputs:t,backend:n,attrs:s}=e,[r,a]=Use(t.x.shape,s.perm),o=!0;for(let f=0;f<a.length;f++)a[f]!==f&&(o=!1);let i=Vse(t.x.shape,s.perm),l={dataId:t.x.dataId,shape:r,dtype:t.x.dtype};if(o){let f=o0({inputs:t,backend:n});return f.shape=i,f}let u=n.makeOutput(i,l.dtype),c=n.dataIdMap.get(l.dataId).id,d=n.dataIdMap.get(u.dataId).id,p=new Uint8Array(new Int32Array(a).buffer),h=new Uint8Array(new Int32Array(l.shape).buffer);return lk(c,h,l.shape.length,jn[l.dtype],d,p,a.length),u}function Vse(e,t){let n=new Array(e.length);for(let s=0;s<n.length;s++)n[s]=e[t[s]];return n}function Use(e,t){let n=[],s=[];for(let r=0;r<e.length;++r)e[r]!==1&&n.push(e[r]),e[t[r]]!==1&&s.push(t[r]);for(let r=0;r<s.length;++r){let a=-1;for(let o=0;o<s.length;++o)s[o]>=r&&(a===-1||s[a]>s[o])&&(a=o);s[a]=r}return[n,s]}var Hse={kernelName:Ro,backendName:"wasm",kernelFunc:Cu,setupFunc:Wse};function Ia(e,t,n){let s=e.shape,r=e.shape.length,a=w.parseAxisParam(t,s),o=a,i=_.getAxesPermutation(o,r),l=null,u=!1;if(i!=null){let c=new Array(r);for(let h=0;h<c.length;h++)c[h]=s[i[h]];o=_.getInnerMostAxes(o.length,r),l=Cu({inputs:{x:e},attrs:{perm:i},backend:n});let d=n.dataIdMap.get(e.dataId).id;n.dataIdMap.get(l.dataId).id!==d&&(u=!0)}return{transposed:l,originalAxes:a,axes:o,inputWasTransposed:u}}var uk;function Gse(e){uk=e.wasm.cwrap(Mi,null,["number, number, number"])}function jse(e){let{backend:t,inputs:n,attrs:s}=e,{axis:r,keepDims:a}=s,{x:o}=n,l=t.dataIdMap.get(o.dataId).id,u=o,{transposed:c,axes:d,originalAxes:p,inputWasTransposed:h}=Ia(o,r,t);if(h){let x=t.dataIdMap.get(c.dataId).id;u=c,l=x}let f=u.shape.length;_.assertAxesAreInnerMostDims("all",d,f);let[m,g]=_.computeOutAndReduceShapes(u.shape,d),A=w.sizeFromShape(g),y=t.makeOutput(m,o.dtype);if(w.sizeFromShape(u.shape)!==0){let x=t.dataIdMap.get(y.dataId).id;uk(l,A,x)}if(h&&t.disposeData(c.dataId),a){let x=_.expandShapeToKeepDim(y.shape,p);y.shape=x}return y}var qse={kernelName:Mi,backendName:"wasm",setupFunc:Gse,kernelFunc:jse},ck;function Xse(e){ck=e.wasm.cwrap(zi,null,["number, number, number"])}function Kse(e){let{backend:t,inputs:n,attrs:s}=e,{axis:r,keepDims:a}=s,{x:o}=n,l=t.dataIdMap.get(o.dataId).id,u=o,{transposed:c,axes:d,originalAxes:p,inputWasTransposed:h}=Ia(o,r,t);if(h){let x=t.dataIdMap.get(c.dataId).id;u=c,l=x}let f=u.shape.length;_.assertAxesAreInnerMostDims("any",d,f);let[m,g]=_.computeOutAndReduceShapes(u.shape,d),A=w.sizeFromShape(g),y=t.makeOutput(m,o.dtype);if(w.sizeFromShape(u.shape)!==0){let x=t.dataIdMap.get(y.dataId).id;ck(l,A,x)}if(h&&t.disposeData(c.dataId),a){let x=_.expandShapeToKeepDim(y.shape,p);y.shape=x}return y}var Zse={kernelName:zi,backendName:"wasm",setupFunc:Xse,kernelFunc:Kse},dk;function Yse(e){dk=e.wasm.cwrap(Oa,null,["number","number","number","number","number"])}function Jse(e){let{backend:t,inputs:n,attrs:s}=e,{axis:r}=s,{x:a}=n,o=t.dataIdMap.get(a.dataId).id,i=o,l=a,{transposed:u,axes:c,inputWasTransposed:d}=Ia(a,r,t);if(d){let A=t.dataIdMap.get(u.dataId).id;A!==o&&(l=u,i=A)}let p=l.shape.slice(0,-1),h=t.makeOutput(p,"int32"),f=t.dataIdMap.get(h.dataId).id,m=w.sizeFromShape(h.shape),g=l.shape[c[0]];return dk(i,jn[l.dtype],m,g,f),d&&t.disposeData(u.dataId),h}var Qse={kernelName:Oa,backendName:"wasm",kernelFunc:Jse,setupFunc:Yse},pk;function ere(e){pk=e.wasm.cwrap(Pa,null,["number","number","number","number","number","number","number","number","number","number","number","number","number","number"])}function tre(e){let{inputs:t,attrs:n,backend:s}=e,r=t.x,a=s.dataIdMap.get(r.dataId).id,{filterSize:o,strides:i,pad:l,dimRoundingMode:u}=n,c=_.computePool2DInfo(r.shape,o,i,1,l,u),d=c.filterHeight,p=c.filterWidth,h=c.padInfo.top,f=c.padInfo.right,m=c.padInfo.bottom,g=c.padInfo.left,A=c.strideHeight,y=c.strideWidth,x=c.inChannels;if(c.dataFormat!=="channelsLast")throw new Error(`wasm backend does not support dataFormat:'${c.dataFormat}'. Please use 'channelsLast'.`);if(c.dilationWidth!==1||c.dilationHeight!==1)throw new Error(`was backend only supports average pooling with dilation = [1, 1], got [${c.dilationHeight}, ${c.dilationWidth}].`);let b=s.makeOutput(c.outShape,"float32"),v=s.dataIdMap.get(b.dataId).id;return pk(a,r.shape[0],r.shape[1],r.shape[2],d,p,h,f,m,g,A,y,x,v),b}var nre={kernelName:Pa,backendName:"wasm",setupFunc:ere,kernelFunc:tre};function qn(e){let{inputs:t,attrs:n}=e,{x:s}=t,{shape:r}=n,a=w.sizeFromShape(s.shape),o=w.inferFromImplicitShape(r,a);return w.assert(a===w.sizeFromShape(o),()=>`new shape: ${o}, old shape: ${s.shape}. New shape and old shape must have the same number of elements.`),e.backend.incRef(s.dataId),{dataId:s.dataId,shape:o,dtype:s.dtype}}var sre={kernelName:xl,backendName:"wasm",kernelFunc:qn},hk;function rre(e){hk=e.wasm.cwrap(Ma,null,["number","array","number","number","array","number","number","number","number"])}function are(e){let{inputs:t,backend:n,attrs:s}=e,{a:r,b:a}=t,{transposeA:o,transposeB:i}=s;if(r.dtype!=="float32"||a.dtype!=="float32")throw new Error("BatchMatMul for non non-float32 tensors not yet supported.");let l=r.shape.length,u=a.shape.length,c=o?r.shape[l-2]:r.shape[l-1],d=i?a.shape[u-1]:a.shape[u-2],p=o?r.shape[l-1]:r.shape[l-2],h=i?a.shape[u-2]:a.shape[u-1],f=r.shape.slice(0,-2),m=a.shape.slice(0,-2),g=w.sizeFromShape(f),A=w.sizeFromShape(m),y=g===A||g===1||A===1;w.assert(l>=2&&u>=2&&y,()=>`Error in matMul: the input batch dimensions must either be the same or at least one input batch dimension must be 1. Got input batch dimensions of (${f}) and (${m}).`);let b=(g>A?r.shape.slice(0,-2):a.shape.slice(0,-2)).concat([p,h]);w.assert(c===d,()=>`Error in matMul: inner shapes (${c}) and (${d}) of Tensors with shapes ${r.shape} and ${a.shape} and transposeA=${o} and transposeB=${i} must match.`);let v=o?[g,c,p]:[g,p,c],k=i?[A,h,d]:[A,d,h],S=qn({inputs:{x:r},backend:n,attrs:{shape:v}}),C=qn({inputs:{x:a},backend:n,attrs:{shape:k}}),D=n.dataIdMap.get(S.dataId).id,O=n.dataIdMap.get(C.dataId).id,E=o?S.shape[2]:S.shape[1],R=i?C.shape[1]:C.shape[2],T=Math.max(g,A),P=n.makeOutput([T,E,R],S.dtype),U=n.dataIdMap.get(P.dataId).id,j=new Uint8Array(new Int32Array(S.shape).buffer),q=new Uint8Array(new Int32Array(C.shape).buffer);return hk(D,j,S.shape.length,O,q,C.shape.length,o,i,U),n.disposeData(S.dataId),n.disposeData(C.dataId),P.shape=b,P}var ore={kernelName:Ma,backendName:"wasm",setupFunc:rre,kernelFunc:are};function kd(e){let{inputs:{x:t},attrs:{begin:n,size:s},backend:r}=e,[a,o]=Cn.parseSliceParams(t,n,s),i=Cn.isSliceContinous(t.shape,a,o),l=r.readSync(t.dataId),u=r.makeOutput(o,t.dtype),c=w.computeStrides(t.shape),d=r.dataIdMap.get(u.dataId);if(i){let f=Cn.computeFlatOffset(a,c);return t.dtype==="string"?d.stringBytes=l.slice(f,f+w.sizeFromShape(o)):r.typedArrayFromHeap(u).set(l.subarray(f,f+w.sizeFromShape(o))),u}if(t.dtype==="string"){let f=Pf(l,a,o,t.shape,t.dtype);return d.stringBytes=f,u}let p=r.typedArrayFromHeap(u),h=t.shape.length;if(h===2)ire(l,c[0],p,a,o);else if(h===3)lre(l,c[0],c[1],p,a,o);else if(h===4)ure(l,c[0],c[1],c[2],p,a,o);else{let f=Pf(l,a,o,t.shape,t.dtype);p.set(f)}return u}function ire(e,t,n,s,r){let a=0,o=s[0],i=s[1],l=o+r[0];for(let u=o;u<l;u++){let c=u*t+i;n.set(e.subarray(c,c+r[1]),a),a+=r[1]}}function lre(e,t,n,s,r,a){let o=0,i=r[0],l=r[1],u=r[2],c=i+a[0],d=l+a[1];for(let p=i;p<c;p++)for(let h=l;h<d;h++){let f=p*t+h*n+u;s.set(e.subarray(f,f+a[2]),o),o+=a[2]}}function ure(e,t,n,s,r,a,o){let i=0,l=a[0],u=a[1],c=a[2],d=l+o[0],p=u+o[1],h=c+o[2],f=a[3];for(let m=l;m<d;m++)for(let g=u;g<p;g++)for(let A=c;A<h;A++){let y=m*t+g*n+A*s+f;r.set(e.subarray(y,y+o[3]),i),i+=o[3]}}var cre={kernelName:kl,backendName:"wasm",kernelFunc:kd};function dre(e){let{inputs:t,backend:n,attrs:s}=e,{x:r}=t,{blockShape:a,crops:o}=s,i=a.reduce((A,y)=>A*y),l=_.getReshaped(r.shape,a,i),u=_.getPermuted(l.length,a.length),c=_.getReshapedPermuted(r.shape,a,i),d=_.getSliceBeginCoords(o,a.length),p=_.getSliceSize(c,o,a.length),h=qn({inputs:{x:r},backend:n,attrs:{shape:l}}),f=Cu({inputs:{x:h},backend:n,attrs:{perm:u}}),m=qn({inputs:{x:f},backend:n,attrs:{shape:c}}),g=kd({inputs:{x:m},backend:n,attrs:{begin:d,size:p}});return n.disposeData(h.dataId),n.disposeData(f.dataId),n.disposeData(h.dataId),g}var pre={kernelName:Hi,backendName:"wasm",kernelFunc:dre};function i0(e){let{inputs:{x:t},attrs:{dtype:n},backend:s}=e,r=s.makeOutput(t.shape,n),a=s.typedArrayFromHeap(t);return s.typedArrayFromHeap(r).set(a),r}var hre={kernelName:za,backendName:"wasm",kernelFunc:i0},fre=yn(La),fk;function mre(e){fk=e.wasm.cwrap(Jr,null,["number","number","number","number"])}function gre(e){let{inputs:t,backend:n,attrs:s}=e,{x:r}=t,{clipValueMin:a,clipValueMax:o}=s,i=n.dataIdMap.get(r.dataId).id,l=n.makeOutput(r.shape,r.dtype),u=n.dataIdMap.get(l.dataId).id;return fk(i,a,o,u),l}var Are={kernelName:Jr,backendName:"wasm",setupFunc:mre,kernelFunc:gre};function mk(e){let{inputs:t,backend:n}=e,s=w.parseAxisParam(e.attrs.axis,t[0].shape)[0],r=_.computeOutShape(t.map(h=>h.shape),s),a=t.filter(h=>w.sizeFromShape(h.shape)>0);if(a.length===1)return o0({inputs:{x:a[0]},backend:n});let o=n.makeOutput(r,t[0].dtype);if(w.sizeFromShape(r)===0)return o;let i=a.map(h=>h.shape);if(_.assertParamsConsistent(i,s),a[0].dtype==="string"){let h=a.map(x=>{let b=w.sizeFromShape(x.shape.slice(s));return qn({inputs:{x},backend:n,attrs:{shape:[-1,b]}})}),f=h.map(x=>({vals:n.readSync(x.dataId),shape:x.shape}));r=_.computeOutShape(h.map(x=>x.shape),1);let m=h[0].shape[0]===1,g=G2(f,r,t[0].dtype,m),A=_.computeOutShape(a.map(x=>x.shape),s);o.shape=A;let y=n.dataIdMap.get(o.dataId);return y.stringBytes=_.fromStringArrayToUint8(g),h.forEach(x=>n.disposeData(x.dataId)),o}let l=w.sizeFromShape(a[0].shape.slice(0,s)),u=0,c=a.map(h=>{let f=w.sizeFromShape(h.shape.slice(s));return u+=f,f}),d=a.map(h=>n.typedArrayFromHeap(h)),p=n.typedArrayFromHeap(o);for(let h=0;h<l;h++){let f=h*u;for(let m=0;m<d.length;m++){let g=c[m],A=h*g,y=d[m].subarray(A,A+g);p.set(y,f),f+=g}}return o}var yre={kernelName:Gi,backendName:"wasm",kernelFunc:mk},gk;function xre(e){gk=e.wasm.cwrap(Ba,null,["number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number"])}function bre(e){let{inputs:t,attrs:n,backend:s}=e,{x:r,filter:a}=t,o=s.dataIdMap.get(r.dataId).id,i=s.dataIdMap.get(a.dataId).id,{strides:l,dilations:u,pad:c,dimRoundingMode:d,dataFormat:p}=n,h=_.convertConv2DDataFormat(p),f=_.computeConv2DInfo(r.shape,a.shape,l,u,c,d,!1,h),m=f.filterHeight,g=f.filterWidth,A=f.padInfo.top,y=f.padInfo.right,x=f.padInfo.bottom,b=f.padInfo.left,v=f.dilationHeight,k=f.dilationWidth,S=f.strideHeight,C=f.strideWidth,D=f.inChannels,O=f.outChannels,E=f.padInfo.type==="SAME"?1:0;if(f.dataFormat!=="channelsLast")throw new Error(`wasm backend Conv2D does not support dataFormat:'${f.dataFormat}'. Please use 'channelsLast'.`);let R=s.makeOutput(f.outShape,"float32"),T=s.dataIdMap.get(R.dataId).id;return gk(o,r.shape[0],r.shape[1],r.shape[2],i,m,g,A,y,x,b,E,v,k,S,C,D,O,T),R}var vre={kernelName:Ba,backendName:"wasm",setupFunc:xre,kernelFunc:bre},Ak;function wre(e){Ak=e.wasm.cwrap(Wa,null,["number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number"])}function kre(e){let{backend:t,inputs:n,attrs:s}=e,{dy:r,filter:a}=n,{strides:o,pad:i,dataFormat:l,dimRoundingMode:u,inputShape:c}=s,d=1,p=_.convertConv2DDataFormat(l),h=_.computeConv2DInfo(c,a.shape,o,d,i,u,!1,p),{batchSize:f,filterHeight:m,filterWidth:g,inChannels:A,inHeight:y,inWidth:x,outChannels:b,outHeight:v,outWidth:k,strideHeight:S,strideWidth:C}=h,D=m-1-h.padInfo.top,O=g-1-h.padInfo.left,E=h.dataFormat==="channelsLast",R=w.computeStrides(h.inShape),T=w.computeStrides(r.shape),[P,U,j]=w.computeStrides(a.shape),q=R[0],X=E?R[1]:R[2],te=E?R[2]:1,ne=E?1:R[1],se=T[0],re=E?T[1]:T[2],Q=E?T[2]:1,ue=E?1:T[1],ce=t.makeOutput(h.inShape,"float32"),fe=t.dataIdMap.get(ce.dataId).id,xe=t.dataIdMap.get(r.dataId).id,Ne=t.dataIdMap.get(a.dataId).id;return Ak(xe,Ne,f,m,g,y,x,A,v,k,b,S,C,D,O,P,U,j,q,X,te,ne,se,re,Q,ue,fe),ce}var Ire={kernelName:Wa,backendName:"wasm",setupFunc:wre,kernelFunc:kre},Sre=yn(Va),Cre=yn(Ua),ky;(function(e){e[e.bilinear=0]="bilinear",e[e.nearest=1]="nearest"})(ky||(ky={}));var yk;function Tre(e){yk=e.wasm.cwrap(ji,null,["number","number","number","number","array","number","number","number","number","number"])}function Nre(e){let{backend:t,inputs:n,attrs:s}=e,{method:r,extrapolationValue:a,cropSize:o}=s,{image:i,boxes:l,boxInd:u}=n,c=l.shape[0],[d,p]=o,h=[c,d,p,i.shape[3]],f=t.dataIdMap.get(i.dataId),m;i.dtype!=="float32"&&(m=i0({backend:t,inputs:{x:i},attrs:{dtype:"float32"}}),f=t.dataIdMap.get(m.dataId));let g=f.id,A=t.dataIdMap.get(l.dataId).id,y=t.dataIdMap.get(u.dataId).id,x=t.makeOutput(h,"float32"),b=t.dataIdMap.get(x.dataId).id,v=new Uint8Array(new Int32Array(i.shape).buffer);return yk(g,A,y,c,v,d,p,ky[r],a,b),m!=null&&t.disposeData(m.dataId),x}var Ere={kernelName:ji,backendName:"wasm",setupFunc:Tre,kernelFunc:Nre},xk;function Rre(e){xk=e.wasm.cwrap(Ha,null,["number","number","number","number","number","number"])}function Dre(e){let{inputs:t,backend:n,attrs:s}=e,{x:r}=t,{axis:a,exclusive:o,reverse:i}=s,l=r.shape.length;w.assert(r.dtype==="float32"||r.dtype==="int32",()=>`cumsum does not support ${r.dtype} tensors in the WASM backend`);let u=_.getAxesPermutation([a],l),c=r;u!==null&&(c=Cu({inputs:{x:r},attrs:{perm:u},backend:n}));let d=_.getInnerMostAxes(1,l)[0];_.assertAxesAreInnerMostDims("cumsum",[d],l);let p=n.makeOutput(c.shape,c.dtype),h=c.shape[d],f=n.dataIdMap.get(c.dataId).id,m=n.dataIdMap.get(p.dataId).id;xk(f,o?1:0,i?1:0,h,m,jn[r.dtype]);let g=p;if(u!==null){let A=_.getUndoAxesPermutation(u);g=Cu({inputs:{x:p},attrs:{perm:A},backend:n}),n.disposeData(c.dataId),n.disposeData(p.dataId)}return g}var _re={kernelName:Ha,backendName:"wasm",setupFunc:Rre,kernelFunc:Dre},bk;function $re(e){bk=e.wasm.cwrap(qi,null,["number","number","number","array","number","array","array","number","number"])}function Fre(e){let{backend:t,inputs:n,attrs:s}=e,{x:r}=n,{blockSize:a,dataFormat:o}=s;w.assert(a>1,()=>`blockSize should be > 1 for depthToSpace, but was: ${a}`);let i=r.shape[0],l=o==="NHWC"?r.shape[1]:r.shape[2],u=o==="NHWC"?r.shape[2]:r.shape[3],c=o==="NHWC"?r.shape[3]:r.shape[1],d=l*a,p=u*a,h=c/(a*a),f=o==="NHWC"?[i,d,p,h]:[i,h,d,p],m=t.makeOutput(f,"float32"),A=t.dataIdMap.get(r.dataId).id,y=new Uint8Array(new Int32Array(w.computeStrides(r.shape)).buffer),x=new Uint8Array(new Int32Array(f).buffer),b=new Uint8Array(new Int32Array(w.computeStrides(f)).buffer),v=t.dataIdMap.get(m.dataId).id;return bk(A,a,o==="NHWC"?1:0,y,r.shape.length-1,x,b,f.length,v),m}var Ore={kernelName:qi,backendName:"wasm",setupFunc:$re,kernelFunc:Fre},vk;function Pre(e){vk=e.wasm.cwrap(Ga,null,["number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number"])}function Mre(e){let{inputs:t,attrs:n,backend:s}=e,{x:r,filter:a}=t,o=s.dataIdMap.get(r.dataId).id,i=s.dataIdMap.get(a.dataId).id,{strides:l,dilations:u,pad:c,dimRoundingMode:d}=n,p=u==null?[1,1]:u,h=_.computeConv2DInfo(r.shape,a.shape,l,p,c,d,!0),f=h.filterHeight,m=h.filterWidth,g=h.padInfo.top,A=h.padInfo.right,y=h.padInfo.bottom,x=h.padInfo.left,b=h.dilationHeight,v=h.dilationWidth,k=h.strideHeight,S=h.strideWidth,C=h.inChannels,D=h.outChannels,O=h.padInfo.type==="SAME"?1:0;if(h.dataFormat!=="channelsLast")throw new Error(`wasm backend DepthwiseConv2dNative does not support dataFormat:'${h.dataFormat}'. Please use 'channelsLast'.`);let E=s.makeOutput(h.outShape,"float32"),R=s.dataIdMap.get(E.dataId).id;return vk(o,r.shape[0],r.shape[1],r.shape[2],i,f,m,g,A,y,x,O,b,v,k,S,C,D,R),E}var zre={kernelName:Ga,backendName:"wasm",setupFunc:Pre,kernelFunc:Mre},Lre=yn(qa),Bre=!1,Wre=_n(Ki,Bre,"bool"),Vre=yn(Xa);function Iy(e){let{inputs:t,attrs:n,backend:s}=e,{input:r}=t,{dim:a}=n,o=r.shape.length,i=r.shape.slice(),l=a;return a<0&&(w.assert(-(o+1)<=a,()=>`Axis must be in the interval [${-(o+1)}, ${o}]`),l=o+a+1),i.splice(l,0,1),qn({inputs:{x:r},backend:s,attrs:{shape:i}})}var Ure={kernelName:Zi,backendName:"wasm",kernelFunc:Iy};function wk(e){let{attrs:{shape:t,value:n,dtype:s},backend:r}=e,a=r.makeOutput(t,s);return r.typedArrayFromHeap(a).fill(n),a}var Hre={kernelName:tc,backendName:"wasm",kernelFunc:wk},kk;function Gre(e){kk=e.wasm.cwrap(Ji,null,["number","number","number","number","number","number"])}function jre(e){let{inputs:t,backend:n}=e,{image:s}=t,r=n.makeOutput(s.shape,s.dtype),a=n.dataIdMap.get(s.dataId).id,o=n.dataIdMap.get(r.dataId).id,[i,l,u,c]=s.shape;return kk(a,i,l,u,c,o),r}var qre={kernelName:Ji,backendName:"wasm",kernelFunc:jre,setupFunc:Gre},Xre=yn(Ka),Kre=!1,Zre=_n(Za,Kre),Ik;function Yre(e){Ik=e.wasm.cwrap(Ya,null,["number","number","number","number","number","number","number"])}function Jre(e){let{backend:t,inputs:n,attrs:s}=e,{varianceEpsilon:r}=s,{x:a,mean:o,variance:i,offset:l,scale:u}=n,c=t.dataIdMap.get(a.dataId).id,d=t.dataIdMap.get(o.dataId).id,p=t.dataIdMap.get(i.dataId).id,h=l!=null?t.dataIdMap.get(l.dataId).id:0,f=u!=null?t.dataIdMap.get(u.dataId).id:0,m=t.makeOutput(a.shape,a.dtype);if(w.sizeFromShape(a.shape)===0)return m;let g=t.dataIdMap.get(m.dataId).id;return Ik(c,d,p,h,f,r,g),m}var Qre={kernelName:Ya,backendName:"wasm",setupFunc:Yre,kernelFunc:Jre},Sk;function eae(e){Sk=e.wasm.cwrap(_o,null,["number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number"])}function tae(e){let{inputs:t,attrs:n,backend:s}=e,{x:r,filter:a,bias:o,preluActivationWeights:i}=t,{strides:l,pad:u,dilations:c,dataFormat:d,dimRoundingMode:p,activation:h,leakyreluAlpha:f}=n,m=_.computeConv2DInfo(r.shape,a.shape,l,c,u,p),g=wd[h];if(g==null)throw new Error(`${h} activation not yet supported for FusedConv2D in the wasm backend.`);let A=s.dataIdMap.get(r.dataId).id,y=s.dataIdMap.get(a.dataId).id,x=m.outChannels,b=0;if(o!=null){let Q=s.dataIdMap.get(o.dataId);if(Q.shape.length!==1)throw new Error(`FusedConv2D only supports rank-1 bias but got rank ${Q.shape.length}.`);if(Q.shape[0]!==x)throw new Error(`FusedConv2D bias shape (${Q.shape}) does not match the number of output channels (${x})`);b=Q.id}let v=m.filterHeight,k=m.filterWidth,S=m.padInfo.top,C=m.padInfo.right,D=m.padInfo.bottom,O=m.padInfo.left,E=m.dilationHeight,R=m.dilationWidth,T=m.strideHeight,P=m.strideWidth,U=m.inChannels,j=m.padInfo.type==="SAME"?1:0,q=m.batchSize,X=m.inHeight,te=m.inWidth;if(d!=="NHWC")throw new Error(`wasm backend FusedConv2D does not support dataFormat:'${d}'. Please use 'NHWC'.`);let ne=s.makeOutput(m.outShape,"float32"),se=s.dataIdMap.get(ne.dataId).id,re=i==null?0:s.dataIdMap.get(i.dataId).id;return Sk(A,q,X,te,y,v,k,b,S,C,D,O,j,E,R,T,P,U,x,g,re,f||0,se),ne}var nae={kernelName:_o,backendName:"wasm",setupFunc:eae,kernelFunc:tae},Ck;function sae(e){Ck=e.wasm.cwrap($o,null,["number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number"])}function rae(e){let{inputs:t,attrs:n,backend:s}=e,{x:r,filter:a,bias:o,preluActivationWeights:i}=t,{strides:l,pad:u,dilations:c,dataFormat:d,dimRoundingMode:p,activation:h,leakyreluAlpha:f}=n,m=_.computeConv2DInfo(r.shape,a.shape,l,c,u,p,!0),g=wd[h];if(g==null)throw new Error(`${h} activation not yet supported for FusedDepthwiseConv2D in the wasm backend.`);let A=s.dataIdMap.get(r.dataId).id,y=s.dataIdMap.get(a.dataId).id,x=m.outChannels,b=0;if(o!=null){let Q=s.dataIdMap.get(o.dataId);if(Q.shape.length!==1)throw new Error(`FusedDepthwiseConv2D only supports rank-1 bias but got rank ${Q.shape.length}.`);if(Q.shape[0]!==x)throw new Error(`FusedDepthwiseConv2D bias shape (${Q.shape}) does not match the number of output channels (${x})`);b=Q.id}let v=m.filterHeight,k=m.filterWidth,S=m.padInfo.top,C=m.padInfo.right,D=m.padInfo.bottom,O=m.padInfo.left,E=m.dilationHeight,R=m.dilationWidth,T=m.strideHeight,P=m.strideWidth,U=m.inChannels,j=m.padInfo.type==="SAME"?1:0,q=m.batchSize,X=m.inHeight,te=m.inWidth;if(d!=="NHWC")throw new Error(`wasm backend FusedDepthwiseConv2D does not support dataFormat:'${d}'. Please use 'NHWC'.`);let ne=s.makeOutput(m.outShape,"float32"),se=s.dataIdMap.get(ne.dataId).id,re=i==null?0:s.dataIdMap.get(i.dataId).id;return Ck(A,q,X,te,y,v,k,b,S,C,D,O,j,E,R,T,P,U,x,g,re,f||0,se),ne}var aae={kernelName:$o,backendName:"wasm",setupFunc:sae,kernelFunc:rae},Tk;function oae(e){Tk=e.wasm.cwrap(el,null,["number","number","number","number","number","number","array","number"])}function iae(e){let{backend:t,inputs:n}=e,{params:s,indices:r}=n,[a,o,i,l]=Pg.prepareAndValidate(s,r),u=t.makeOutput(a,s.dtype);if(o===0)return u;let c=r.shape,d=c[c.length-1],h=t.dataIdMap.get(s.dataId).id,m=t.dataIdMap.get(r.dataId).id,g=new Uint8Array(new Int32Array(l).buffer),A=t.dataIdMap.get(u.dataId).id;return Tk(h,jn[s.dtype],m,o,d,i,g,A),u}var lae={kernelName:el,backendName:"wasm",setupFunc:oae,kernelFunc:iae},Nk;function uae(e){Nk=e.wasm.cwrap("Gather",null,["number","number","array","number","number","number","array","number"])}function cae(e){let{backend:t,inputs:n,attrs:s}=e,{x:r,indices:a}=n,{axis:o,batchDims:i}=s,l=w.parseAxisParam(o,r.shape)[0],u=_.segment_util.collectGatherOpShapeInfo(r,a,l,i),c=qn({inputs:{x:r},attrs:{shape:[u.batchSize,u.outerSize,u.dimSize,u.sliceSize]},backend:t}),d=w.sizeFromShape(a.shape),p=qn({inputs:{x:a},attrs:{shape:[u.batchSize,d/u.batchSize]},backend:t}),h=[u.batchSize,u.outerSize,d/u.batchSize,u.sliceSize],f=t.makeOutput(h,r.dtype);if(w.sizeFromShape(r.shape)===0)return f;let m=c.shape.length-1,A=t.dataIdMap.get(c.dataId).id,x=t.dataIdMap.get(p.dataId).id,b=t.dataIdMap.get(f.dataId).id,v=new Uint8Array(new Int32Array(w.computeStrides(c.shape)).buffer),k=new Uint8Array(new Int32Array(w.computeStrides(h)).buffer);return Nk(A,jn[r.dtype],v,m,x,u.batchSize,k,b),t.disposeData(c.dataId),t.disposeData(p.dataId),f.shape=u.outputShape,f}var dae={kernelName:Qi,backendName:"wasm",setupFunc:uae,kernelFunc:cae},pae=!1,hae=_n(tl,pae,"bool"),fae=!1,mae=_n(Ja,fae,"bool"),Ek;function gae(e){Ek=e.wasm.cwrap(eo,null,["number","number","number"])}function Aae(e){let{inputs:{x:t},attrs:{alpha:n},backend:s}=e,r=s.dataIdMap.get(t.dataId).id,a=s.makeOutput(t.shape,t.dtype);if(w.sizeFromShape(t.shape)!==0){let o=s.dataIdMap.get(a.dataId).id;Ek(r,n,o)}return a}var yae={kernelName:eo,backendName:"wasm",setupFunc:gae,kernelFunc:Aae},xae=!1,bae=_n(al,xae,"bool"),vae=!1,wae=_n(ol,vae,"bool"),kae=yn(to),Iae=!1,Sae=_n(ll,Iae,"bool"),Rk;function Cae(e){Rk=e.wasm.cwrap(no,null,["number, number, number"])}function Tae(e){let{backend:t,inputs:n,attrs:s}=e,{reductionIndices:r,keepDims:a}=s,{x:o}=n,l=t.dataIdMap.get(o.dataId).id,u=o,{transposed:c,axes:d,originalAxes:p,inputWasTransposed:h}=Ia(o,r,t);if(h){let x=t.dataIdMap.get(c.dataId).id;u=c,l=x}let f=u.shape.length;_.assertAxesAreInnerMostDims("max",d,f);let[m,g]=_.computeOutAndReduceShapes(u.shape,d),A=w.sizeFromShape(g),y=t.makeOutput(m,o.dtype);if(w.sizeFromShape(u.shape)!==0){let x=t.dataIdMap.get(y.dataId).id;Rk(l,A,x)}if(h&&t.disposeData(c.dataId),a){let x=_.expandShapeToKeepDim(y.shape,p);y.shape=x}return y}var Nae={kernelName:no,backendName:"wasm",setupFunc:Cae,kernelFunc:Tae},Eae=!1,Rae=_n(so,Eae),Dk;function Dae(e){Dk=e.wasm.cwrap(ro,null,["number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number"])}function _ae(e){let{inputs:t,attrs:n,backend:s}=e,r=t.x,a=s.dataIdMap.get(r.dataId).id,{filterSize:o,strides:i,pad:l,dimRoundingMode:u}=n,c=_.computePool2DInfo(r.shape,o,i,1,l,u),d=c.filterHeight,p=c.filterWidth,h=c.padInfo.top,f=c.padInfo.right,m=c.padInfo.bottom,g=c.padInfo.left,A=c.dilationHeight,y=c.dilationWidth,x=c.strideHeight,b=c.strideWidth,v=c.inChannels,k=c.outChannels;if(c.dataFormat!=="channelsLast")throw new Error(`wasm backend does not support dataFormat:'${c.dataFormat}'. Please use 'channelsLast'.`);let S=s.makeOutput(c.outShape,"float32"),C=s.dataIdMap.get(S.dataId).id;return Dk(a,r.shape[0],r.shape[1],r.shape[2],d,p,h,f,m,g,A,y,x,b,v,k,C),S}var $ae={kernelName:ro,backendName:"wasm",setupFunc:Dae,kernelFunc:_ae},_k;function Fae(e){_k=e.wasm.cwrap(ao,null,["number, number, number"])}function Oae(e){let{backend:t,inputs:n,attrs:s}=e,{axis:r,keepDims:a}=s,{x:o}=n,i=t.dataIdMap.get(o.dataId).id,l=i,u=o,{transposed:c,axes:d,originalAxes:p,inputWasTransposed:h}=Ia(o,r,t),f=d;if(h){let b=t.dataIdMap.get(c.dataId).id;b!==i&&(u=c,l=b,f=_.getInnerMostAxes(f.length,u.shape.length))}_.assertAxesAreInnerMostDims("mean",f,u.shape.length);let[m,g]=_.computeOutAndReduceShapes(u.shape,f),A=w.sizeFromShape(g),y=u;u.dtype!=="float32"&&(y=i0({backend:t,inputs:{x:u},attrs:{dtype:"float32"}}),l=t.dataIdMap.get(y.dataId).id);let x=t.makeOutput(m,"float32");if(w.sizeFromShape(u.shape)!==0){let b=t.dataIdMap.get(x.dataId).id;_k(l,A,b)}if(h&&t.disposeData(c.dataId),a){let b=_.expandShapeToKeepDim(x.shape,p);x.shape=b}return u.dtype!=="float32"&&t.disposeData(y.dataId),x}var Pae={kernelName:ao,backendName:"wasm",setupFunc:Fae,kernelFunc:Oae},$k;function Mae(e){$k=e.wasm.cwrap(oo,null,["number, number, number"])}function zae(e){let{backend:t,inputs:n,attrs:s}=e,{axis:r,keepDims:a}=s,{x:o}=n,i=t.dataIdMap.get(o.dataId).id,l=i,u=o,{transposed:c,axes:d,originalAxes:p,inputWasTransposed:h}=Ia(o,r,t);if(h){let x=t.dataIdMap.get(c.dataId).id;x!==i&&(u=c,l=x)}let f=u.shape.length;_.assertAxesAreInnerMostDims("min",d,f);let[m,g]=_.computeOutAndReduceShapes(u.shape,d),A=w.sizeFromShape(g),y=t.makeOutput(m,u.dtype);if(w.sizeFromShape(u.shape)!==0){let x=t.dataIdMap.get(y.dataId).id;$k(l,A,x)}if(h&&t.disposeData(c.dataId),a){let x=_.expandShapeToKeepDim(y.shape,p);y.shape=x}return y}var Lae={kernelName:oo,backendName:"wasm",setupFunc:Mae,kernelFunc:zae},Bae=!1,Wae=_n(io,Bae),Sy;(function(e){e[e.reflect=0]="reflect",e[e.symmetric=1]="symmetric"})(Sy||(Sy={}));var Fk;function Vae(e){Fk=e.wasm.cwrap(lo,null,["number","array","number","number","array","array","number","number"])}function Uae(e){let{inputs:{x:t},backend:n,attrs:{paddings:s,mode:r}}=e,a=s.map((f,m)=>f[0]+t.shape[m]+f[1]),o=n.dataIdMap.get(t.dataId).id,i=n.makeOutput(a,t.dtype),l=n.dataIdMap.get(i.dataId).id,u=new Uint8Array(new Int32Array(t.shape).buffer),c=s.map(f=>f[0]),d=s.map(f=>f[1]),p=new Uint8Array(new Int32Array(c).buffer),h=new Uint8Array(new Int32Array(d).buffer);return Fk(o,u,t.shape.length,jn[t.dtype],p,h,Sy[r],l),i}var Hae={kernelName:lo,backendName:"wasm",kernelFunc:Uae,setupFunc:Vae},Gae=!0,jae=_n(uo,Gae),qae=yn(cl);function Cy(e,t){let n=new Int32Array(e.wasm.HEAPU8.buffer,t,4),s=n[0],r=n[1],a=n[2],o=n[3];return e.wasm._free(t),{pSelectedIndices:s,selectedSize:r,pSelectedScores:a,pValidOutputs:o}}var Ok;function Xae(e){Ok=e.wasm.cwrap(pl,"number",["number","number","number","number","number"])}function Kae(e){let{backend:t,inputs:n,attrs:s}=e,{iouThreshold:r,maxOutputSize:a,scoreThreshold:o}=s,{boxes:i,scores:l}=n,u=t.dataIdMap.get(i.dataId).id,c=t.dataIdMap.get(l.dataId).id,d=Ok(u,c,a,r,o),{pSelectedIndices:p,selectedSize:h,pSelectedScores:f,pValidOutputs:m}=Cy(t,d);return t.wasm._free(f),t.wasm._free(m),t.makeOutput([h],"int32",p)}var Zae={kernelName:pl,backendName:"wasm",setupFunc:Xae,kernelFunc:Kae},Pk;function Yae(e){Pk=e.wasm.cwrap(hl,"number",["number","number","number","number","number","bool"])}function Jae(e){let{backend:t,inputs:n,attrs:s}=e,{iouThreshold:r,maxOutputSize:a,scoreThreshold:o,padToMaxOutputSize:i}=s,{boxes:l,scores:u}=n,c=t.dataIdMap.get(l.dataId).id,d=t.dataIdMap.get(u.dataId).id,p=Pk(c,d,a,r,o,i),{pSelectedIndices:h,selectedSize:f,pSelectedScores:m,pValidOutputs:g}=Cy(t,p);t.wasm._free(m);let A=t.makeOutput([f],"int32",h),y=t.makeOutput([],"int32",g);return[A,y]}var Qae={kernelName:hl,backendName:"wasm",setupFunc:Yae,kernelFunc:Jae},Mk;function eoe(e){Mk=e.wasm.cwrap(fl,"number",["number","number","number","number","number","number"])}function toe(e){let{backend:t,inputs:n,attrs:s}=e,{iouThreshold:r,maxOutputSize:a,scoreThreshold:o,softNmsSigma:i}=s,{boxes:l,scores:u}=n,c=t.dataIdMap.get(l.dataId).id,d=t.dataIdMap.get(u.dataId).id,p=Mk(c,d,a,r,o,i),{pSelectedIndices:h,selectedSize:f,pSelectedScores:m,pValidOutputs:g}=Cy(t,p);t.wasm._free(g);let A=t.makeOutput([f],"int32",h),y=t.makeOutput([f],"float32",m);return[A,y]}var noe={kernelName:fl,backendName:"wasm",setupFunc:eoe,kernelFunc:toe},soe=!1,roe=_n(dl,soe,"bool"),zk;function aoe(e){zk=e.wasm.cwrap(co,null,["number","number","number","number","number"])}function ooe(e){let{inputs:t,backend:n,attrs:s}=e,{indices:r}=t,{depth:a,onValue:o,offValue:i}=s,l=n.makeOutput([...r.shape,a],"int32"),u=n.dataIdMap.get(l.dataId).id,d=n.dataIdMap.get(r.dataId).id;return zk(d,a,o,i,u),l}var ioe={kernelName:co,backendName:"wasm",setupFunc:aoe,kernelFunc:ooe};function loe(e){let{inputs:{x:t},backend:n}=e,s=n.makeOutput(t.shape,t.dtype);return n.typedArrayFromHeap(s).fill(1),s}var uoe={kernelName:ml,backendName:"wasm",kernelFunc:loe};function coe(e){let{inputs:t,backend:n,attrs:s}=e,{axis:r}=s;if(t.length===1)return Iy({inputs:{input:t[0]},backend:n,attrs:{dim:r}});let a=t[0].shape,o=t[0].dtype;t.forEach(c=>{w.assertShapesMatch(a,c.shape,"All tensors passed to stack must have matching shapes"),w.assert(o===c.dtype,()=>"All tensors passed to stack must have matching dtypes")});let i=[],l=t.map(c=>{let d=Iy({inputs:{input:c},backend:n,attrs:{dim:r}});return i.push(d),d}),u=mk({inputs:l,backend:n,attrs:{axis:r}});return i.forEach(c=>n.disposeData(c.dataId)),u}var doe={kernelName:gl,backendName:"wasm",kernelFunc:coe},Lk;function poe(e){Lk=e.wasm.cwrap(po,null,["number","array","number","number","array","array","number","number"])}function hoe(e){let{inputs:{x:t},backend:n,attrs:{paddings:s,constantValue:r}}=e,a=s.map((m,g)=>m[0]+t.shape[g]+m[1]);if(w.sizeFromShape(t.shape)===0)return wk({backend:n,attrs:{shape:a,value:r,dtype:t.dtype}});let o=n.dataIdMap.get(t.dataId).id,i=n.makeOutput(a,t.dtype),u=n.dataIdMap.get(i.dataId).id,c=new Uint8Array(new Int32Array(t.shape).buffer),d=s.map(m=>m[0]),p=s.map(m=>m[1]),h=new Uint8Array(new Int32Array(d).buffer),f=new Uint8Array(new Int32Array(p).buffer);return Lk(o,c,t.shape.length,jn[t.dtype],h,f,r,u),i}var Bk={kernelName:po,backendName:"wasm",kernelFunc:hoe,setupFunc:poe},foe=!1,moe=_n(ho,foe),Wk;function goe(e){Wk=e.wasm.cwrap(fo,null,["number","number","number"])}function Aoe(e){let{inputs:t,backend:n}=e,{x:s,alpha:r}=t,a=n.dataIdMap.get(s.dataId).id,o=n.dataIdMap.get(r.dataId).id,i=n.makeOutput(s.shape,"float32"),l=n.dataIdMap.get(i.dataId).id;return Wk(a,o,l),i}var yoe={kernelName:fo,backendName:"wasm",setupFunc:goe,kernelFunc:Aoe},Vk;function xoe(e){Vk=e.wasm.cwrap(Al,null,["number","number","number","number"])}function boe(e){let{backend:t,inputs:n,attrs:s}=e,{axis:r,keepDims:a}=s,{x:o}=n,i=t.dataIdMap.get(o.dataId).id,l=i,u=o,{transposed:c,axes:d,originalAxes:p,inputWasTransposed:h}=Ia(o,r,t),f=d;if(h){let x=t.dataIdMap.get(c.dataId).id;x!==i&&(u=c,l=x,f=_.getInnerMostAxes(f.length,u.shape.length))}_.assertAxesAreInnerMostDims("prod",f,u.shape.length);let[m,g]=_.computeOutAndReduceShapes(u.shape,f),A=w.sizeFromShape(g),y=t.makeOutput(m,u.dtype);if(w.sizeFromShape(u.shape)!==0){let x=t.dataIdMap.get(y.dataId).id;Vk(l,A,jn[y.dtype],x)}if(h&&t.disposeData(c.dataId),a){let x=_.expandShapeToKeepDim(y.shape,p);y.shape=x}return y}var voe={kernelName:Al,backendName:"wasm",setupFunc:xoe,kernelFunc:boe},woe=e=>{let{backend:t,attrs:n}=e,{start:s,stop:r,step:a,dtype:o}=n,i=X2(s,r,a,o),l=t.makeOutput([i.length],o);return t.typedArrayFromHeap(l).set(i),l},koe={kernelName:oc,backendName:"wasm",kernelFunc:woe},Ioe=!0,Soe=_n(ja,Ioe),Coe=yn(mo),Toe=yn(Ao),Uk;function Noe(e){Uk=e.wasm.cwrap(go,null,["number","number","number","number","number","number","number","number","number","number"])}function Eoe(e){let{backend:t,inputs:n,attrs:s}=e,{images:r}=n,{alignCorners:a,halfPixelCenters:o,size:i}=s,[l,u]=i,[c,d,p,h]=r.shape,f=[c,l,u,h],m=t.dataIdMap.get(r.dataId),g;m.dtype!=="float32"&&(g=i0({backend:t,inputs:{x:r},attrs:{dtype:"float32"}}),m=t.dataIdMap.get(g.dataId));let A=m.id,y=t.makeOutput(f,"float32");if(w.sizeFromShape(r.shape)===0)return y;let x=t.dataIdMap.get(y.dataId).id;return Uk(A,c,d,p,h,l,u,a?1:0,o?1:0,x),g!=null&&t.disposeData(g.dataId),y}var Roe={kernelName:go,backendName:"wasm",setupFunc:Noe,kernelFunc:Eoe},Hk;function Doe(e){Hk=e.wasm.cwrap(yo,null,["number","array","number","array","number","number"])}function _oe(e){let{inputs:t,backend:n,attrs:s}=e,{x:r}=t,{dims:a}=s,o=w.parseAxisParam(a,r.shape);if(r.shape.length===0)return o0({inputs:{x:r},backend:n});let i=n.makeOutput(r.shape,r.dtype),l=n.dataIdMap.get(r.dataId).id,u=n.dataIdMap.get(i.dataId).id,c=new Uint8Array(new Int32Array(o).buffer),d=new Uint8Array(new Int32Array(r.shape).buffer);Hk(l,c,o.length,d,r.shape.length,u);let p=qn({inputs:{x:i},attrs:{shape:r.shape},backend:n});return n.disposeData(i.dataId),p}var $oe={kernelName:yo,backendName:"wasm",kernelFunc:_oe,setupFunc:Doe},Gk;function Foe(e){Gk=e.wasm.cwrap(Fl,null,["number","number","number","number","number","number","number","number","array","number","number"])}function Ooe(e){let{inputs:t,backend:n,attrs:s}=e,{image:r}=t,{radians:a,fillValue:o,center:i}=s,l=n.makeOutput(r.shape,r.dtype),u=n.dataIdMap.get(r.dataId).id,c=n.dataIdMap.get(l.dataId).id,[d,p,h,f]=r.shape,[m,g]=_.getImageCenter(i,p,h),A=o===0,y=255,x=typeof o=="number"?[o,o,o,A?0:y]:[...o,y],b=new Uint8Array(new Int32Array(x).buffer);return Gk(u,d,p,h,f,a,m,g,b,x.length,c),l}var Poe={kernelName:Fl,backendName:"wasm",kernelFunc:Ooe,setupFunc:Foe},Moe=yn(xo),zoe=yn(bo),jk;function Loe(e){jk=e.wasm.cwrap(bl,null,["number","number","number","number","number","number","array","number","number"])}function Boe(e){let{backend:t,inputs:n,attrs:s}=e,{indices:r,updates:a}=n,{shape:o}=s,i=t.makeOutput(o,a.dtype);if(w.sizeFromShape(o)===0)return i;let{sliceRank:l,numUpdates:u,sliceSize:c,strides:d,outputSize:p}=Mg.calculateShapes(a,r,o),f=t.dataIdMap.get(r.dataId).id,g=t.dataIdMap.get(a.dataId).id,A=new Uint8Array(new Int32Array(d).buffer),y=t.dataIdMap.get(i.dataId).id;return jk(f,g,jn[a.dtype],l,u,c,A,p,y),i}var Woe={kernelName:bl,backendName:"wasm",setupFunc:Loe,kernelFunc:Boe},qk;function Voe(e){qk=e.wasm.cwrap("SelectV2",null,["number","number","number","number","number"])}function Uoe(e){let{inputs:t,backend:n}=e,{condition:s,t:r,e:a}=t,o=n.dataIdMap.get(s.dataId).id,i=n.dataIdMap.get(r.dataId).id,l=n.dataIdMap.get(a.dataId).id,u=n.makeOutput(r.shape,r.dtype),c=n.dataIdMap.get(u.dataId).id,d=s.shape.length,p=r.shape.length,h=d===0||d>1||p===1?1:w.sizeFromShape(r.shape.slice(1));return qk(o,i,l,h,c),u}var Hoe={kernelName:vl,backendName:"wasm",kernelFunc:Uoe,setupFunc:Voe},Xk;function Goe(e){Xk=e.wasm.cwrap(wo,null,["number","number"])}function joe(e){let{backend:t,inputs:{x:n}}=e,s=t.dataIdMap.get(n.dataId).id,r=t.makeOutput(n.shape,n.dtype),a=t.dataIdMap.get(r.dataId).id;return w.sizeFromShape(r.shape)===0||Xk(s,a),r}var qoe={kernelName:"Sigmoid",backendName:"wasm",setupFunc:Goe,kernelFunc:joe},Xoe=yn(vo),Kk;function Koe(e){Kk=e.wasm.cwrap(So,null,["number","number","number","number"])}function Zoe(e){let{backend:t,inputs:{logits:n},attrs:{dim:s}}=e,r=t.dataIdMap.get(n.dataId).id,a=t.makeOutput(n.shape,n.dtype),o=t.dataIdMap.get(a.dataId).id,i=n.shape[s],l=w.sizeFromShape(n.shape)/i;return w.sizeFromShape(a.shape)===0||Kk(r,o,i,l),a}var Yoe={kernelName:So,backendName:"wasm",setupFunc:Koe,kernelFunc:Zoe};function Joe(e){let{inputs:t,backend:n,attrs:s}=e,{x:r}=t,{blockShape:a,paddings:o}=s,i=w.sizeFromShape(a),l=[[0,0]];l.push(...o);for(let k=1+a.length;k<r.shape.length;++k)l.push([0,0]);let u=Bk.kernelFunc({inputs:{x:r},backend:n,attrs:{paddings:l,constantValue:0}}),c=_.getReshaped(u.shape,a,i,!1),d=_.getPermuted(c.length,a.length,!1),p=_.getReshapedPermuted(u.shape,a,i,!1),m=qn({inputs:{x:u},backend:n,attrs:{shape:c}}),y=Cu({inputs:{x:m},backend:n,attrs:{perm:d}}),v=qn({inputs:{x:y},backend:n,attrs:{shape:p}});return n.disposeData(u.dataId),n.disposeData(m.dataId),n.disposeData(y.dataId),v}var Qoe={kernelName:Tl,backendName:"wasm",kernelFunc:Joe};function eie(e){let{inputs:t,attrs:n,backend:s}=e,{x:r}=t,{numOrSizeSplits:a,axis:o}=n,i=w.parseAxisParam(o,r.shape)[0],l=_.prepareSplitSize(r,a,i),u=new Array(r.shape.length).fill(0),c=r.shape.slice();return l.map(d=>{let p=[...c];p[i]=d;let h=kd({inputs:{x:r},attrs:{begin:u,size:p},backend:s});return u[i]+=d,h})}var tie={kernelName:Nl,backendName:"wasm",kernelFunc:eie},nie=yn(ko),sie=yn(lc),rie=!0,aie=_n(Co,rie),Zk;function oie(e){Zk=e.wasm.cwrap(ea,null,["number","number","number"])}function iie(e){let{backend:t,inputs:n,attrs:s}=e,{alpha:r}=s,{x:a}=n,o=t.dataIdMap.get(a.dataId).id,i=t.makeOutput(a.shape,a.dtype),l=t.dataIdMap.get(i.dataId).id;return Zk(o,r,l),i}var lie={kernelName:ea,backendName:"wasm",setupFunc:oie,kernelFunc:iie},Yk;function uie(e){Yk=e.wasm.cwrap(El,null,["number","array","number","array","array","array","array","array","number","number"])}function cie(e){let{backend:t,inputs:n,attrs:s}=e,{x:r}=n,{begin:a,end:o,strides:i}=s;i==null&&(i=new Array(a.length));let{beginMask:l,endMask:u,ellipsisMask:c,newAxisMask:d,shrinkAxisMask:p}=s,h=_.slice_util.maskToAxes(c);if(h.length>1)throw new Error("Multiple ellipses in slice is not allowed.");if(c!==0&&d!==0)throw new Error("Using both ellipsisMask and newAxisMask is not yet supported.");if(c!==0&&p!==0)throw new Error("Using both ellipsisMask and shrinkAxisMask is not yet supported.");let f=r.shape.length-a.length,m=_.slice_util.maskToAxes(d),g=r.shape.slice();m.forEach(E=>{a[E]=0,o[E]=1,g.splice(E,0,1)});let A=qn({inputs:{x:r},attrs:{shape:g},backend:t}),{begin:y,end:x,strides:b}=_.slice_util.getNormalizedAxes(A.shape,h,f,a,o,i,l,u,c);a=y,o=x,i=b;let v=_.slice_util.maskToAxes(p);v.forEach(E=>{o[E]=a[E]+1,i[E]=1});let k=_.slice_util.computeOutShape(a,o,i),S=k.filter((E,R)=>v.indexOf(R)===-1);if(i.every(E=>E===1)){let E=kd({inputs:{x:A},attrs:{begin:a,size:k},backend:t});t.disposeData(A.dataId);let R=qn({inputs:{x:E},attrs:{shape:S},backend:t});return t.disposeData(E.dataId),R}let D=t.makeOutput(S,"float32");if(!S.some(E=>E===0)){let E=t.dataIdMap.get(A.dataId).id,R=new Uint8Array(new Int32Array(w.computeStrides(A.shape)).buffer),T=new Uint8Array(new Int32Array(a).buffer),P=new Uint8Array(new Int32Array(o).buffer),U=new Uint8Array(new Int32Array(i).buffer),j=new Uint8Array(new Int32Array(S).buffer),q=new Uint8Array(new Int32Array(w.computeStrides(S)).buffer),X=t.dataIdMap.get(D.dataId).id;Yk(E,R,A.shape.length,T,P,U,j,q,S.length,X)}t.disposeData(A.dataId);let O=qn({inputs:{x:D},attrs:{shape:S},backend:t});return t.disposeData(D.dataId),O}var die={kernelName:El,backendName:"wasm",setupFunc:uie,kernelFunc:cie},pie=!0,hie=_n(To,pie),Jk;function fie(e){Jk=e.wasm.cwrap(Io,null,["number, number, number"])}function mie(e){let{backend:t,inputs:n,attrs:s}=e,{axis:r,keepDims:a}=s,{x:o}=n,i=t.dataIdMap.get(o.dataId).id,l=i,u=o,{transposed:c,axes:d,originalAxes:p,inputWasTransposed:h}=Ia(o,r,t),f=d;if(h){let x=t.dataIdMap.get(c.dataId).id;x!==i&&(u=c,l=x,f=_.getInnerMostAxes(f.length,u.shape.length))}_.assertAxesAreInnerMostDims("sum",f,u.shape.length);let[m,g]=_.computeOutAndReduceShapes(u.shape,f),A=w.sizeFromShape(g),y=t.makeOutput(m,u.dtype);if(w.sizeFromShape(u.shape)!==0){let x=t.dataIdMap.get(y.dataId).id;Jk(l,A,x)}if(h&&t.disposeData(c.dataId),a){let x=_.expandShapeToKeepDim(y.shape,p);y.shape=x}return y}var gie={kernelName:Io,backendName:"wasm",setupFunc:fie,kernelFunc:mie},Aie=yn(No),yie=yn(Eo),Qk;function xie(e){Qk=e.wasm.cwrap(Qr,null,["number","array","number","array","number","number"])}function bie(e){let{inputs:t,backend:n,attrs:s}=e,{x:r}=t,a=n.dataIdMap.get(r.dataId).id,{reps:o}=s,i=new Array(r.shape.length);for(let p=0;p<i.length;p++)i[p]=r.shape[p]*o[p];let l=new Uint8Array(new Int32Array(r.shape).buffer),u=new Uint8Array(new Int32Array(i).buffer),c=n.makeOutput(i,r.dtype),d=n.dataIdMap.get(c.dataId).id;return Qk(a,l,r.shape.length,u,i.length,jn[c.dtype],d),c}var vie={kernelName:Qr,backendName:"wasm",setupFunc:xie,kernelFunc:bie},e8;function wie(e){e8=e.wasm.cwrap(Rl,null,["number","array","number","number","number","bool","number","number"])}var kie=({inputs:e,backend:t,attrs:n})=>{let{x:s}=e,{k:r,sorted:a}=n,o=t.dataIdMap.get(s.dataId).id,i=new Uint8Array(new Int32Array(s.shape).buffer),l=s.shape.slice();l[l.length-1]=r;let u=t.makeOutput(l,s.dtype),c=t.dataIdMap.get(u.dataId).id,d=t.makeOutput(l,"int32"),p=t.dataIdMap.get(d.dataId).id;return e8(o,i,s.shape.length,jn[s.dtype],r,a,c,p),[u,d]},Iie={kernelName:Rl,backendName:"wasm",setupFunc:wie,kernelFunc:kie},t8;function Sie(e){t8=e.wasm.cwrap(Dl,null,["number","number","bool","number","number","number","number","number","number","array","number","number","number","number","number"])}function Cie(e){let{backend:t,inputs:n,attrs:s}=e,{image:r,transforms:a}=n,{interpolation:o,fillMode:i,fillValue:l,outputShape:u}=s,[c,d,p,h]=r.shape,[f,m]=u!=null?u:[d,p],g=[c,f,m,h],A=new Uint8Array(new Int32Array(w.computeStrides(r.shape)).buffer),y=t.makeOutput(g,r.dtype),x=t.dataIdMap.get(y.dataId).id,v=t.dataIdMap.get(r.dataId).id,S=t.dataIdMap.get(a.dataId).id,C=o==="nearest"?1:2,D;switch(i){case"constant":D=1;break;case"reflect":D=2;break;case"wrap":D=3;break;case"nearest":D=4;break;default:D=1;break}return t8(v,S,a.shape[0]>1,c,f,m,h,p,d,A,r.shape.length-1,C,D,l,x),y}var Tie={kernelName:Dl,backendName:"wasm",setupFunc:Sie,kernelFunc:Cie};function Nie(e){let{inputs:t,backend:n,attrs:s}=e,{value:r}=t,{axis:a}=s;a<0&&(a+=r.shape.length);let o=r.shape[a],i=r.shape.length,l=new Array(i-1),u=0;for(let h=0;h<i;h++)h!==a&&(l[u++]=r.shape[h]);let c=new Array(o),d=new Array(i).fill(0),p=r.shape.slice();p[a]=1;for(let h=0;h<c.length;h++)d[a]=h,c[h]=kd({inputs:{x:r},attrs:{begin:d,size:p},backend:n});return c.map(({dataId:h,dtype:f})=>({dataId:h,dtype:f,shape:l}))}var Eie={kernelName:_l,backendName:"wasm",kernelFunc:Nie};function Rie(e){let{inputs:{x:t},backend:n}=e,s=n.makeOutput(t.shape,t.dtype);return n.typedArrayFromHeap(s).fill(0),s}var Die={kernelName:$l,backendName:"wasm",kernelFunc:Rie},_ie=[Fse,Pse,Lse,qse,Zse,Qse,nre,ore,pre,hre,fre,Are,yre,vre,Ire,Sre,Cre,Ere,_re,Ore,zre,Lre,Wre,Vre,Ure,Hre,qre,Xre,Zre,$se,Qre,nae,aae,lae,dae,hae,mae,Bse,yae,bae,wae,kae,Sae,Nae,Rae,$ae,Pae,Lae,Wae,Hae,jae,qae,Zae,Qae,noe,roe,ioe,uoe,doe,Bk,moe,yoe,voe,koe,Soe,Coe,Toe,sre,Roe,$oe,Poe,zoe,Moe,Woe,Hoe,qoe,Xoe,cre,Yoe,Qoe,tie,nie,sie,aie,lie,die,hie,gie,Aie,yie,vie,Iie,Tie,Hse,Eie,Die];for(let e of _ie)Fo(e);var Ty=Y();Ty.registerFlag("WASM_HAS_SIMD_SUPPORT",async()=>WebAssembly.validate(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])));Ty.registerFlag("WASM_HAS_MULTITHREAD_SUPPORT",async()=>{if(Ty.get("IS_NODE"))return!1;try{return new MessageChannel().port1.postMessage(new SharedArrayBuffer(1)),WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,5,4,1,3,1,1,10,11,1,9,0,65,0,254,16,2,0,26,11]))}catch(e){return!1}});var n8=Da(FS()),$ie='var Module={};function threadPrintErr(){var text=Array.prototype.slice.call(arguments).join(" ");console.error(text)}function threadAlert(){var text=Array.prototype.slice.call(arguments).join(" ");postMessage({cmd:"alert",text:text,threadId:Module["_pthread_self"]()})}var err=threadPrintErr;this.alert=threadAlert;Module["instantiateWasm"]=function(info,receiveInstance){var instance=new WebAssembly.Instance(Module["wasmModule"],info);Module["wasmModule"]=null;receiveInstance(instance);return instance.exports};function moduleLoaded(){}this.onmessage=function(e){try{if(e.data.cmd==="load"){Module["wasmModule"]=e.data.wasmModule;Module["wasmMemory"]=e.data.wasmMemory;Module["buffer"]=Module["wasmMemory"].buffer;Module["ENVIRONMENT_IS_PTHREAD"]=true;if(typeof e.data.urlOrBlob==="string"){importScripts(e.data.urlOrBlob)}else{var objectUrl=URL.createObjectURL(e.data.urlOrBlob);importScripts(objectUrl);URL.revokeObjectURL(objectUrl)}WasmBackendModuleThreadedSimd(Module).then(function(instance){Module=instance;moduleLoaded()})}else if(e.data.cmd==="objectTransfer"){Module["PThread"].receiveObjectTransfer(e.data)}else if(e.data.cmd==="run"){Module["__performance_now_clock_drift"]=performance.now()-e.data.time;Module["__emscripten_thread_init"](e.data.threadInfoStruct,0,0);var max=e.data.stackBase;var top=e.data.stackBase+e.data.stackSize;Module["establishStackSpace"](top,max);Module["_emscripten_tls_init"]();Module["PThread"].receiveObjectTransfer(e.data);Module["PThread"].setThreadStatus(Module["_pthread_self"](),1);try{var result=Module["invokeEntryPoint"](e.data.start_routine,e.data.arg);if(!Module["getNoExitRuntime"]())Module["PThread"].threadExit(result)}catch(ex){if(ex==="Canceled!"){Module["PThread"].threadCancel()}else if(ex!="unwind"){if(ex instanceof Module["ExitStatus"]){if(Module["getNoExitRuntime"]()){}else{Module["PThread"].threadExit(ex.status)}}else{Module["PThread"].threadExit(-2);throw ex}}}}else if(e.data.cmd==="cancel"){if(Module["_pthread_self"]()){Module["PThread"].threadCancel()}}else if(e.data.target==="setimmediate"){}else if(e.data.cmd==="processThreadQueue"){if(Module["_pthread_self"]()){Module["_emscripten_current_thread_process_queued_calls"]()}}else{err("worker.js received unknown command "+e.data.cmd);err(e.data)}}catch(ex){err("worker.js onmessage() captured an uncaught exception: "+ex);if(ex&&ex.stack)err(ex.stack);throw ex}};if(typeof process==="object"&&typeof process.versions==="object"&&typeof process.versions.node==="string"){self={location:{href:__filename}};var onmessage=this.onmessage;var nodeWorkerThreads=require("worker_threads");global.Worker=nodeWorkerThreads.Worker;var parentPort=nodeWorkerThreads.parentPort;parentPort.on("message",function(data){onmessage({data:data})});var nodeFS=require("fs");var nodeRead=function(filename){return nodeFS.readFileSync(filename,"utf8")};function globalEval(x){global.require=require;global.Module=Module;eval.call(null,x)}importScripts=function(f){globalEval(nodeRead(f))};postMessage=function(msg){parentPort.postMessage(msg)};if(typeof performance==="undefined"){performance={now:function(){return Date.now()}}}}',Fie=Da(OS()),s8=class extends qu{constructor(e){super();this.wasm=e,this.dataIdNextNumber=1,this.wasm.tfjs.init(),this.dataIdMap=new up(this,Qn())}write(e,t,n){let s={id:this.dataIdNextNumber++};return this.move(s,e,t,n,1),s}numDataIds(){return this.dataIdMap.numDataIds()}async time(e){let t=w.now();return e(),{kernelMs:w.now()-t}}move(e,t,n,s,r){let a=this.dataIdNextNumber++;if(s==="string"){let u=t;this.dataIdMap.set(e,{id:a,stringBytes:u,shape:n,dtype:s,memoryOffset:null,refCount:r});return}let o=w.sizeFromShape(n),i=o*w.bytesPerElement(s),l=this.wasm._malloc(i);this.dataIdMap.set(e,{id:a,memoryOffset:l,shape:n,dtype:s,refCount:r}),this.wasm.tfjs.registerTensor(a,o,l),t!=null&&this.wasm.HEAPU8.set(new Uint8Array(t.buffer,t.byteOffset,i),l)}async read(e){return this.readSync(e)}readSync(e){let{memoryOffset:t,dtype:n,shape:s,stringBytes:r}=this.dataIdMap.get(e);if(n==="string")return r;let a=this.wasm.HEAPU8.slice(t,t+w.sizeFromShape(s)*w.bytesPerElement(n));return Mie(a.buffer,n)}disposeData(e,t=!1){if(this.dataIdMap.has(e)){let n=this.dataIdMap.get(e);if(n.refCount--,!t&&n.refCount>0)return!1;this.wasm._free(n.memoryOffset),this.wasm.tfjs.disposeData(n.id),this.dataIdMap.delete(e)}return!0}refCount(e){return this.dataIdMap.has(e)?this.dataIdMap.get(e).refCount:0}incRef(e){let t=this.dataIdMap.get(e);t!=null&&t.refCount++}floatPrecision(){return 32}getMemoryOffset(e){return this.dataIdMap.get(e).memoryOffset}dispose(){this.wasm.tfjs.dispose(),"PThread"in this.wasm&&this.wasm.PThread.terminateAllThreads(),this.wasm=null}memory(){return{unreliable:!1}}makeOutput(e,t,n){let s;if(n==null)s=this.write(null,e,t);else{let r=this.dataIdNextNumber++;s={id:r},this.dataIdMap.set(s,{id:r,memoryOffset:n,shape:e,dtype:t,refCount:1});let a=w.sizeFromShape(e);this.wasm.tfjs.registerTensor(r,a,n)}return{dataId:s,shape:e,dtype:t}}typedArrayFromHeap({shape:e,dtype:t,dataId:n}){let s=this.wasm.HEAPU8.buffer,{memoryOffset:r}=this.dataIdMap.get(n),a=w.sizeFromShape(e);switch(t){case"float32":return new Float32Array(s,r,a);case"int32":return new Int32Array(s,r,a);case"bool":return new Uint8Array(s,r,a);default:throw new Error(`Unknown dtype ${t}`)}}};function Oie(e){return(t,n)=>(w.fetch(e,{credentials:"same-origin"}).then(s=>{s.ok||t.env.a(`failed to load wasm binary file at '${e}'`),s.arrayBuffer().then(r=>{WebAssembly.instantiate(r,t).then(a=>{n(a.instance,a.module)})})}),{})}function r8(e,t,n){if(l0!=null)return l0;let s="tfjs-backend-wasm.wasm";return e&&t?s="tfjs-backend-wasm-threaded-simd.wasm":e&&(s="tfjs-backend-wasm-simd.wasm"),Sd!=null&&Sd[s]!=null?Sd[s]:n+s}async function Pie(){let[e,t]=await Promise.all([Y().getAsync("WASM_HAS_SIMD_SUPPORT"),Y().getAsync("WASM_HAS_MULTITHREAD_SUPPORT")]);return new Promise((n,s)=>{let r={};r.locateFile=(i,l)=>{if(i.endsWith(".worker.js")){let u=$ie,c=new Blob([u],{type:"application/javascript"});return URL.createObjectURL(c)}return i.endsWith(".wasm")?r8(e,t,Id!=null?Id:l):l+i},Ny&&(r.instantiateWasm=Oie(r8(e,t,Id!=null?Id:"")));let a=!1;r.onAbort=()=>{if(a||Cd)return;Cd=!0,s({message:"Make sure the server can serve the `.wasm` file relative to the bundled js file. For more details see https://github.com/tensorflow/tfjs/blob/master/tfjs-backend-wasm/README.md#using-bundlers"})};let o;t&&e&&l0==null?(r.mainScriptUrlOrBlob=new Blob(["var WasmBackendModuleThreadedSimd = "+n8.default.toString()],{type:"text/javascript"}),o=(0,n8.default)(r)):o=(0,Fie.default)(r),o.then(i=>{a=!0,Cd=!1;let l=null;i.tfjs={init:i.cwrap("init",null,[]),registerTensor:i.cwrap("register_tensor",null,["number","number","number"]),disposeData:i.cwrap("dispose_data",l,["number"]),dispose:i.cwrap("dispose",l,[])},n({wasm:i})})})}function Mie(e,t){switch(t){case"float32":return new Float32Array(e);case"int32":return new Int32Array(e);case"bool":return new Uint8Array(e);default:throw new Error(`Unknown dtype ${t}`)}}var zie=["tfjs-backend-wasm.wasm","tfjs-backend-wasm-simd.wasm","tfjs-backend-wasm-threaded-simd.wasm"],l0=null,Id=null,Sd={},Cd=!1,Ny=!1;function Lie(e,t=!1){if(Ug("setWasmPath has been deprecated in favor of setWasmPaths and will be removed in a future release."),Cd)throw new Error("The WASM backend was already initialized. Make sure you call `setWasmPath()` before you call `tf.setBackend()` or `tf.ready()`");l0=e,Ny=t}function a8(e,t=!1){if(Cd)throw new Error("The WASM backend was already initialized. Make sure you call `setWasmPaths()` before you call `tf.setBackend()` or `tf.ready()`");if(typeof e=="string")Id=e;else{Sd=e;let n=zie.filter(s=>Sd[s]==null);if(n.length>0)throw new Error(`There were no entries found for the following binaries: ${n.join(",")}. Please either call setWasmPaths with a map providing a path for each binary, or with a string indicating the directory where all the binaries can be found.`)}Ny=t}var Bie="3.9.0",Wie=2;Vl("wasm",async()=>{let{wasm:e}=await Pie();return new s8(e)},Wie);var Vie="3.9.0",Uie="3.9.0",Hie="3.9.0",Gie="3.9.0",jie="3.9.0",qie="3.9.0",Xie="3.9.0",Kie="3.9.0",Zie={tfjs:Vie,"tfjs-core":Uie,"tfjs-data":Hie,"tfjs-layers":Gie,"tfjs-converter":jie,"tfjs-backend-cpu":qie,"tfjs-backend-webgl":Xie,"tfjs-backend-wasm":Kie};function o8(e,t){let n=[e.startPoint[0]*t[0],e.startPoint[1]*t[1]],s=[e.endPoint[0]*t[0],e.endPoint[1]*t[1]];return{startPoint:n,endPoint:s}}function Td(e){return[Math.abs(e.endPoint[0]-e.startPoint[0]),Math.abs(e.endPoint[1]-e.startPoint[1])]}function Nd(e){return[e.startPoint[0]+(e.endPoint[0]-e.startPoint[0])/2,e.startPoint[1]+(e.endPoint[1]-e.startPoint[1])/2]}function Ed(e,t,n){let s=t.shape[1],r=t.shape[2],a=[[e.startPoint[1]/s,e.startPoint[0]/r,e.endPoint[1]/s,e.endPoint[0]/r]];return $e.cropAndResize(t,a,[0],n)}function u0(e,t=1.5){let n=Nd(e),s=Td(e),r=[t*s[0]/2,t*s[1]/2],a=[n[0]-r[0],n[1]-r[1]],o=[n[0]+r[0],n[1]+r[1]];return{startPoint:a,endPoint:o,landmarks:e.landmarks}}function c0(e){let t=Nd(e),n=Td(e),r=Math.max(...n)/2,a=[Math.round(t[0]-r),Math.round(t[1]-r)],o=[Math.round(t[0]+r),Math.round(t[1]+r)];return{startPoint:a,endPoint:o,landmarks:e.landmarks}}function Ey(e){let t=e.map(a=>a[0]),n=e.map(a=>a[1]),s=[Math.min(...t),Math.min(...n)],r=[Math.max(...t),Math.max(...n)];return{startPoint:s,endPoint:r,landmarks:e}}var i8=e=>({startPoint:_e(e,[0,0],[-1,2]),endPoint:_e(e,[0,2],[-1,2])});var d0=[[1,0,0],[0,1,0],[0,0,1]];function Yie(e){return e-2*Math.PI*Math.floor((e+Math.PI)/(2*Math.PI))}function l8(e,t){let n=Math.PI/2-Math.atan2(-(t[1]-e[1]),t[0]-e[0]);return Yie(n)}function u8(e,t){return[[1,0,e],[0,1,t],[0,0,1]]}function Sa(e,t){let n=0;for(let s=0;s<e.length;s++)n+=e[s]*t[s];return n}function Jie(e,t){let n=[];for(let s=0;s<e.length;s++)n.push(e[s][t]);return n}function c8(e,t){let n=[],s=e.length;for(let r=0;r<s;r++){n.push([]);for(let a=0;a<s;a++)n[r].push(Sa(e[r],Jie(t,a)))}return n}function Ry(e,t){let n=Math.cos(e),s=Math.sin(e),r=[[n,-s,0],[s,n,0],[0,0,1]],a=u8(t[0],t[1]),o=c8(a,r),i=u8(-t[0],-t[1]);return c8(o,i)}function d8(e){let t=[[e[0][0],e[1][0]],[e[0][1],e[1][1]]],n=[e[0][2],e[1][2]],s=[-Sa(t[0],n),-Sa(t[1],n)];return[t[0].concat(s[0]),t[1].concat(s[1]),[0,0,1]]}function p8(e,t){return[Sa(e,t[0]),Sa(e,t[1])]}function h8(e){let t={strides:[e/16,e/8],anchors:[2,6]},n=[];for(let s=0;s<t.strides.length;s++){let r=t.strides[s],a=Math.floor((e+r-1)/r),o=Math.floor((e+r-1)/r),i=t.anchors[s];for(let l=0;l<a;l++){let u=r*(l+.5);for(let c=0;c<o;c++){let d=r*(c+.5);for(let p=0;p<i;p++)n.push([d,u])}}}return n}var f8=6;function Qie(e,t,n){let s=_e(e,[0,1],[-1,2]),r=oe(s,t),a=_e(e,[0,3],[-1,2]),o=he(a,n),i=he(r,n),l=he(o,2),u=ye(i,l),c=oe(i,l),d=z(u,n),p=z(c,n);return Gl([d,p],1)}var m8=class{constructor(t,n){Re(this,"model");Re(this,"anchorsData");Re(this,"anchors");Re(this,"inputSize");Re(this,"config");this.model=t,this.anchorsData=h8(t.inputs[0].shape[1]),this.anchors=Us(this.anchorsData),this.inputSize=t.inputs[0].shape[2],this.config=n}async getBoundingBoxes(t,n){var c,d,p,h;if(!t||t.isDisposedInternal||t.shape.length!==4||t.shape[1]<1||t.shape[2]<1)return{boxes:[]};let[s,r,a]=H(()=>{let f=$e.resizeBilinear(t,[this.inputSize,this.inputSize]),m=ye(he(f,127.5),.5),g=this.model.execute(m),A;if(Array.isArray(g)){let v=g.sort((D,O)=>D.size-O.size),k=ft([v[0],v[2]],2),S=ft([v[1],v[3]],2),C=ft([S,k],1);A=lt(C,0)}else A=lt(g);let y=Qie(A,this.anchors,[this.inputSize,this.inputSize]),x=_e(A,[0,0],[-1,1]),b=lt(Bn(x));return[A,y,b]});this.config=xn(this.config,n);let o=await $e.nonMaxSuppressionAsync(r,a,((c=this.config.face.detector)==null?void 0:c.maxDetected)||0,((d=this.config.face.detector)==null?void 0:d.iouThreshold)||0,((p=this.config.face.detector)==null?void 0:p.minConfidence)||0),i=await o.array();Z(o);let l=[],u=await a.data();for(let f=0;f<i.length;f++){let m=u[i[f]];if(m>(((h=this.config.face.detector)==null?void 0:h.minConfidence)||0)){let g=_e(r,[i[f],0],[1,-1]),A=H(()=>V(lt(_e(s,[i[f],f8-1],[1,-1])),[f8,-1]));l.push({box:i8(g),landmarks:A,anchor:this.anchorsData[i[f]],confidence:m}),Z(g)}}return Z(s),Z(r),Z(a),{boxes:l,scaleFactor:[t.shape[2]/this.inputSize,t.shape[1]/this.inputSize]}}};async function g8(e){var s,r,a;let t=await yt(xt(e.modelBasePath,((s=e.face.detector)==null?void 0:s.modelPath)||""),{fromTFHub:(((r=e.face.detector)==null?void 0:r.modelPath)||"").includes("tfhub.dev")}),n=new m8(t,e);return!t||!t.modelUrl?ie("load model failed:",((a=e.face.detector)==null?void 0:a.modelPath)||""):e.debug&&ie("load model:",t.modelUrl),n}var gr={silhouette:[10,338,297,332,284,251,389,356,454,323,361,288,397,365,379,378,400,377,152,148,176,149,150,136,172,58,132,93,234,127,162,21,54,103,67,109],lipsUpperOuter:[61,185,40,39,37,0,267,269,270,409,291],lipsLowerOuter:[146,91,181,84,17,314,405,321,375,291],lipsUpperInner:[78,191,80,81,82,13,312,311,310,415,308],lipsLowerInner:[78,95,88,178,87,14,317,402,318,324,308],rightEyeUpper0:[246,161,160,159,158,157,173],rightEyeLower0:[33,7,163,144,145,153,154,155,133],rightEyeUpper1:[247,30,29,27,28,56,190],rightEyeLower1:[130,25,110,24,23,22,26,112,243],rightEyeUpper2:[113,225,224,223,222,221,189],rightEyeLower2:[226,31,228,229,230,231,232,233,244],rightEyeLower3:[143,111,117,118,119,120,121,128,245],rightEyebrowUpper:[156,70,63,105,66,107,55,193],rightEyebrowLower:[35,124,46,53,52,65],rightEyeIris:[473,474,475,476,477],leftEyeUpper0:[466,388,387,386,385,384,398],leftEyeLower0:[263,249,390,373,374,380,381,382,362],leftEyeUpper1:[467,260,259,257,258,286,414],leftEyeLower1:[359,255,339,254,253,252,256,341,463],leftEyeUpper2:[342,445,444,443,442,441,413],leftEyeLower2:[446,261,448,449,450,451,452,453,464],leftEyeLower3:[372,340,346,347,348,349,350,357,465],leftEyebrowUpper:[383,300,293,334,296,336,285,417],leftEyebrowLower:[265,353,276,283,282,295],leftEyeIris:[468,469,470,471,472],midwayBetweenEyes:[168],noseTip:[1],noseBottom:[2],noseRightCorner:[98],noseLeftCorner:[327],rightCheek:[205],leftCheek:[425]},Dy=[{key:"EyeUpper0",indices:[9,10,11,12,13,14,15]},{key:"EyeUpper1",indices:[25,26,27,28,29,30,31]},{key:"EyeUpper2",indices:[41,42,43,44,45,46,47]},{key:"EyeLower0",indices:[0,1,2,3,4,5,6,7,8]},{key:"EyeLower1",indices:[16,17,18,19,20,21,22,23,24]},{key:"EyeLower2",indices:[32,33,34,35,36,37,38,39,40]},{key:"EyeLower3",indices:[54,55,56,57,58,59,60,61,62]}],Rd=[[.499976992607117,.652534008026123],[.500025987625122,.547487020492554],[.499974012374878,.602371990680695],[.482113003730774,.471979022026062],[.500150978565216,.527155995368958],[.499909996986389,.498252987861633],[.499523013830185,.40106201171875],[.289712011814117,.380764007568359],[.499954998493195,.312398016452789],[.499987006187439,.269918978214264],[.500023007392883,.107050001621246],[.500023007392883,.666234016418457],[.5000159740448,.679224014282227],[.500023007392883,.692348003387451],[.499976992607117,.695277988910675],[.499976992607117,.70593398809433],[.499976992607117,.719385027885437],[.499976992607117,.737019002437592],[.499967992305756,.781370997428894],[.499816000461578,.562981009483337],[.473773002624512,.573909997940063],[.104906998574734,.254140973091125],[.365929991006851,.409575998783112],[.338757991790771,.41302502155304],[.311120003461838,.409460008144379],[.274657994508743,.389131009578705],[.393361985683441,.403706014156342],[.345234006643295,.344011008739471],[.370094001293182,.346076011657715],[.319321990013123,.347265005111694],[.297903001308441,.353591024875641],[.24779200553894,.410809993743896],[.396889001131058,.842755019664764],[.280097991228104,.375599980354309],[.106310002505779,.399955987930298],[.2099249958992,.391353011131287],[.355807989835739,.534406006336212],[.471751004457474,.65040397644043],[.474155008792877,.680191993713379],[.439785003662109,.657229006290436],[.414617002010345,.66654098033905],[.450374007225037,.680860996246338],[.428770989179611,.682690978050232],[.374971002340317,.727805018424988],[.486716985702515,.547628998756409],[.485300987958908,.527395009994507],[.257764995098114,.314490020275116],[.401223003864288,.455172002315521],[.429818987846375,.548614978790283],[.421351999044418,.533740997314453],[.276895999908447,.532056987285614],[.483370006084442,.499586999416351],[.33721199631691,.282882988452911],[.296391993761063,.293242990970612],[.169294998049736,.193813979625702],[.447580009698868,.302609980106354],[.392390012741089,.353887975215912],[.354490011930466,.696784019470215],[.067304998636246,.730105042457581],[.442739009857178,.572826027870178],[.457098007202148,.584792017936707],[.381974011659622,.694710969924927],[.392388999462128,.694203019142151],[.277076005935669,.271932005882263],[.422551989555359,.563233017921448],[.385919004678726,.281364023685455],[.383103013038635,.255840003490448],[.331431001424789,.119714021682739],[.229923993349075,.232002973556519],[.364500999450684,.189113974571228],[.229622006416321,.299540996551514],[.173287004232407,.278747975826263],[.472878992557526,.666198015213013],[.446828007698059,.668527007102966],[.422762006521225,.673889994621277],[.445307999849319,.580065965652466],[.388103008270264,.693961024284363],[.403039008378983,.706539988517761],[.403629004955292,.693953037261963],[.460041999816895,.557139039039612],[.431158006191254,.692366003990173],[.452181994915009,.692366003990173],[.475387006998062,.692366003990173],[.465828001499176,.779190003871918],[.472328990697861,.736225962638855],[.473087012767792,.717857003211975],[.473122000694275,.704625964164734],[.473033010959625,.695277988910675],[.427942007780075,.695277988910675],[.426479011774063,.703539967536926],[.423162013292313,.711845993995667],[.4183090031147,.720062971115112],[.390094995498657,.639572978019714],[.013953999616206,.560034036636353],[.499913990497589,.58014702796936],[.413199990987778,.69539999961853],[.409626007080078,.701822996139526],[.468080013990402,.601534962654114],[.422728985548019,.585985004901886],[.463079988956451,.593783974647522],[.37211999297142,.47341400384903],[.334562003612518,.496073007583618],[.411671012639999,.546965003013611],[.242175996303558,.14767599105835],[.290776997804642,.201445996761322],[.327338010072708,.256527006626129],[.399509996175766,.748921036720276],[.441727995872498,.261676013469696],[.429764986038208,.187834024429321],[.412198007106781,.108901023864746],[.288955003023148,.398952007293701],[.218936994671822,.435410976409912],[.41278201341629,.398970007896423],[.257135003805161,.355440020561218],[.427684992551804,.437960982322693],[.448339998722076,.536936044692993],[.178560003638268,.45755398273468],[.247308000922203,.457193970680237],[.286267012357712,.467674970626831],[.332827985286713,.460712015628815],[.368755996227264,.447206974029541],[.398963987827301,.432654976844788],[.476410001516342,.405806005001068],[.189241006970406,.523923993110657],[.228962004184723,.348950982093811],[.490725994110107,.562400996685028],[.404670000076294,.485132992267609],[.019469000399113,.401564002037048],[.426243007183075,.420431017875671],[.396993011236191,.548797011375427],[.266469985246658,.376977026462555],[.439121007919312,.51895797252655],[.032313998788595,.644356966018677],[.419054001569748,.387154996395111],[.462783008813858,.505746960639954],[.238978996872902,.779744982719421],[.198220998048782,.831938028335571],[.107550002634525,.540755033493042],[.183610007166862,.740257024765015],[.134409993886948,.333683013916016],[.385764002799988,.883153975009918],[.490967005491257,.579378008842468],[.382384985685349,.508572995662689],[.174399003386497,.397670984268188],[.318785011768341,.39623498916626],[.343364000320435,.400596976280212],[.396100014448166,.710216999053955],[.187885001301765,.588537991046906],[.430987000465393,.944064974784851],[.318993002176285,.898285031318665],[.266247987747192,.869701027870178],[.500023007392883,.190576016902924],[.499976992607117,.954452991485596],[.366169989109039,.398822009563446],[.393207013607025,.39553701877594],[.410373002290726,.391080021858215],[.194993004202843,.342101991176605],[.388664990663528,.362284004688263],[.365961998701096,.355970978736877],[.343364000320435,.355356991291046],[.318785011768341,.35834002494812],[.301414996385574,.363156020641327],[.058132998645306,.319076001644135],[.301414996385574,.387449026107788],[.499987989664078,.618434011936188],[.415838003158569,.624195992946625],[.445681989192963,.566076993942261],[.465844005346298,.620640993118286],[.49992299079895,.351523995399475],[.288718998432159,.819945991039276],[.335278987884521,.852819979190826],[.440512001514435,.902418971061707],[.128294005990028,.791940987110138],[.408771991729736,.373893976211548],[.455606997013092,.451801002025604],[.499877005815506,.908990025520325],[.375436991453171,.924192011356354],[.11421000212431,.615022003650665],[.448662012815475,.695277988910675],[.4480200111866,.704632043838501],[.447111994028091,.715808033943176],[.444831997156143,.730794012546539],[.430011987686157,.766808986663818],[.406787008047104,.685672998428345],[.400738000869751,.681069016456604],[.392399996519089,.677703022956848],[.367855995893478,.663918972015381],[.247923001646996,.601333022117615],[.452769994735718,.420849978923798],[.43639200925827,.359887003898621],[.416164010763168,.368713974952698],[.413385987281799,.692366003990173],[.228018000721931,.683571994304657],[.468268007040024,.352671027183533],[.411361992359161,.804327011108398],[.499989002943039,.469825029373169],[.479153990745544,.442654013633728],[.499974012374878,.439637005329132],[.432112008333206,.493588984012604],[.499886006116867,.866917014122009],[.49991300702095,.821729004383087],[.456548988819122,.819200992584229],[.344549000263214,.745438992977142],[.37890899181366,.574010014533997],[.374292999505997,.780184984207153],[.319687992334366,.570737957954407],[.357154995203018,.604269981384277],[.295284003019333,.621580958366394],[.447750002145767,.862477004528046],[.410986006259918,.508723020553589],[.31395098567009,.775308012962341],[.354128003120422,.812552988529205],[.324548006057739,.703992962837219],[.189096003770828,.646299958229065],[.279776990413666,.71465802192688],[.1338230073452,.682700991630554],[.336768001317978,.644733011722565],[.429883986711502,.466521978378296],[.455527991056442,.548622965812683],[.437114000320435,.558896005153656],[.467287987470627,.529924988746643],[.414712011814117,.335219979286194],[.37704598903656,.322777986526489],[.344107985496521,.320150971412659],[.312875986099243,.32233202457428],[.283526003360748,.333190023899078],[.241245999932289,.382785975933075],[.102986000478268,.468762993812561],[.267612010240555,.424560010433197],[.297879010438919,.433175981044769],[.333433985710144,.433878004550934],[.366427004337311,.426115989685059],[.396012008190155,.416696012020111],[.420121014118195,.41022801399231],[.007561000064015,.480777025222778],[.432949006557465,.569517970085144],[.458638995885849,.479089021682739],[.473466008901596,.545744001865387],[.476087987422943,.563830018043518],[.468472003936768,.555056989192963],[.433990985155106,.582361996173859],[.483518004417419,.562983989715576],[.482482999563217,.57784903049469],[.42645001411438,.389798998832703],[.438998997211456,.39649498462677],[.450067013502121,.400434017181396],[.289712011814117,.368252992630005],[.276670008897781,.363372981548309],[.517862021923065,.471948027610779],[.710287988185883,.380764007568359],[.526226997375488,.573909997940063],[.895093023777008,.254140973091125],[.634069979190826,.409575998783112],[.661242008209229,.41302502155304],[.688880026340485,.409460008144379],[.725341975688934,.389131009578705],[.606630027294159,.40370500087738],[.654766023159027,.344011008739471],[.629905998706818,.346076011657715],[.680678009986877,.347265005111694],[.702096998691559,.353591024875641],[.75221198797226,.410804986953735],[.602918028831482,.842862963676453],[.719901978969574,.375599980354309],[.893692970275879,.399959981441498],[.790081977844238,.391354024410248],[.643998026847839,.534487962722778],[.528249025344849,.65040397644043],[.525849997997284,.680191040039062],[.560214996337891,.657229006290436],[.585384011268616,.66654098033905],[.549625992774963,.680860996246338],[.57122802734375,.682691991329193],[.624852001667023,.72809898853302],[.513050019741058,.547281980514526],[.51509702205658,.527251958847046],[.742246985435486,.314507007598877],[.598631024360657,.454979002475739],[.570338010787964,.548575043678284],[.578631997108459,.533622980117798],[.723087012767792,.532054007053375],[.516445994377136,.499638974666595],[.662801027297974,.282917976379395],[.70362401008606,.293271005153656],[.830704987049103,.193813979625702],[.552385985851288,.302568018436432],[.607609987258911,.353887975215912],[.645429015159607,.696707010269165],[.932694971561432,.730105042457581],[.557260990142822,.572826027870178],[.542901992797852,.584792017936707],[.6180260181427,.694710969924927],[.607590973377228,.694203019142151],[.722943007946014,.271963000297546],[.577413976192474,.563166975975037],[.614082992076874,.281386971473694],[.616907000541687,.255886018276215],[.668509006500244,.119913995265961],[.770092010498047,.232020974159241],[.635536015033722,.189248979091644],[.77039098739624,.299556016921997],[.826722025871277,.278755009174347],[.527121007442474,.666198015213013],[.553171992301941,.668527007102966],[.577238023281097,.673889994621277],[.554691970348358,.580065965652466],[.611896991729736,.693961024284363],[.59696102142334,.706539988517761],[.596370995044708,.693953037261963],[.539958000183105,.557139039039612],[.568841993808746,.692366003990173],[.547818005084991,.692366003990173],[.52461302280426,.692366003990173],[.534089982509613,.779141008853912],[.527670979499817,.736225962638855],[.526912987232208,.717857003211975],[.526877999305725,.704625964164734],[.526966989040375,.695277988910675],[.572058022022247,.695277988910675],[.573521018028259,.703539967536926],[.57683801651001,.711845993995667],[.581691026687622,.720062971115112],[.609944999217987,.639909982681274],[.986046016216278,.560034036636353],[.5867999792099,.69539999961853],[.590372025966644,.701822996139526],[.531915009021759,.601536989212036],[.577268004417419,.585934996604919],[.536915004253387,.593786001205444],[.627542972564697,.473352015018463],[.665585994720459,.495950996875763],[.588353991508484,.546862006187439],[.757824003696442,.14767599105835],[.709249973297119,.201507985591888],[.672684013843536,.256581008434296],[.600408971309662,.74900496006012],[.55826598405838,.261672019958496],[.570303976535797,.187870979309082],[.588165998458862,.109044015407562],[.711045026779175,.398952007293701],[.781069993972778,.435405015945435],[.587247014045715,.398931980133057],[.742869973182678,.355445981025696],[.572156012058258,.437651991844177],[.55186802148819,.536570012569427],[.821442008018494,.457556009292603],[.752701997756958,.457181990146637],[.71375697851181,.467626988887787],[.66711300611496,.460672974586487],[.631101012229919,.447153985500336],[.6008620262146,.432473003864288],[.523481011390686,.405627012252808],[.810747981071472,.523926019668579],[.771045982837677,.348959028720856],[.509127020835876,.562718033790588],[.595292985439301,.485023975372314],[.980530977249146,.401564002037048],[.573499977588654,.420000016689301],[.602994978427887,.548687994480133],[.733529984951019,.376977026462555],[.560611009597778,.519016981124878],[.967685997486115,.644356966018677],[.580985009670258,.387160003185272],[.537728011608124,.505385041236877],[.760966002941132,.779752969741821],[.801778972148895,.831938028335571],[.892440974712372,.54076099395752],[.816350996494293,.740260004997253],[.865594983100891,.333687007427216],[.614073991775513,.883246004581451],[.508952975273132,.579437971115112],[.617941975593567,.508316040039062],[.825608015060425,.397674977779388],[.681214988231659,.39623498916626],[.656635999679565,.400596976280212],[.603900015354156,.710216999053955],[.81208598613739,.588539004325867],[.56801301240921,.944564998149872],[.681007981300354,.898285031318665],[.733752012252808,.869701027870178],[.633830010890961,.398822009563446],[.606792986392975,.39553701877594],[.589659988880157,.391062021255493],[.805015981197357,.342108011245728],[.611334979534149,.362284004688263],[.634037971496582,.355970978736877],[.656635999679565,.355356991291046],[.681214988231659,.35834002494812],[.698584973812103,.363156020641327],[.941866993904114,.319076001644135],[.698584973812103,.387449026107788],[.584177017211914,.624107003211975],[.554318010807037,.566076993942261],[.534153997898102,.62064003944397],[.711217999458313,.819975018501282],[.664629995822906,.852871000766754],[.559099972248077,.902631998062134],[.871706008911133,.791940987110138],[.591234028339386,.373893976211548],[.544341027736664,.451583981513977],[.624562978744507,.924192011356354],[.88577002286911,.615028977394104],[.551338016986847,.695277988910675],[.551980018615723,.704632043838501],[.552887976169586,.715808033943176],[.555167973041534,.730794012546539],[.569944024085999,.767035007476807],[.593203008174896,.685675978660583],[.599261999130249,.681069016456604],[.607599973678589,.677703022956848],[.631937980651855,.663500010967255],[.752032995223999,.601315021514893],[.547226011753082,.420395016670227],[.563543975353241,.359827995300293],[.583841025829315,.368713974952698],[.586614012718201,.692366003990173],[.771915018558502,.683578014373779],[.531597018241882,.352482974529266],[.588370978832245,.804440975189209],[.52079701423645,.442565023899078],[.567984998226166,.493479013442993],[.543282985687256,.819254994392395],[.655317008495331,.745514988899231],[.621008992195129,.574018001556396],[.625559985637665,.78031200170517],[.680198013782501,.570719003677368],[.64276397228241,.604337990283966],[.704662978649139,.621529996395111],[.552012026309967,.862591981887817],[.589071989059448,.508637011051178],[.685944974422455,.775357007980347],[.645735025405884,.812640011310577],[.675342977046967,.703978002071381],[.810858011245728,.646304965019226],[.72012197971344,.714666962623596],[.866151988506317,.682704985141754],[.663187026977539,.644596993923187],[.570082008838654,.466325998306274],[.544561982154846,.548375964164734],[.562758982181549,.558784961700439],[.531987011432648,.530140042304993],[.585271000862122,.335177004337311],[.622952997684479,.32277899980545],[.655896008014679,.320163011550903],[.687132000923157,.322345972061157],[.716481983661652,.333200991153717],[.758756995201111,.382786989212036],[.897013008594513,.468769013881683],[.732392013072968,.424547016620636],[.70211398601532,.433162987232208],[.66652500629425,.433866024017334],[.633504986763,.426087975502014],[.603875994682312,.416586995124817],[.579657971858978,.409945011138916],[.992439985275269,.480777025222778],[.567192018032074,.569419980049133],[.54136598110199,.478899002075195],[.526564002037048,.546118021011353],[.523913025856018,.563830018043518],[.531529009342194,.555056989192963],[.566035985946655,.582329034805298],[.51631098985672,.563053965568542],[.5174720287323,.577877044677734],[.573594987392426,.389806985855103],[.560697972774506,.395331978797913],[.549755990505219,.399751007556915],[.710287988185883,.368252992630005],[.723330020904541,.363372981548309]],mi=[127,34,139,11,0,37,232,231,120,72,37,39,128,121,47,232,121,128,104,69,67,175,171,148,157,154,155,118,50,101,73,39,40,9,151,108,48,115,131,194,204,211,74,40,185,80,42,183,40,92,186,230,229,118,202,212,214,83,18,17,76,61,146,160,29,30,56,157,173,106,204,194,135,214,192,203,165,98,21,71,68,51,45,4,144,24,23,77,146,91,205,50,187,201,200,18,91,106,182,90,91,181,85,84,17,206,203,36,148,171,140,92,40,39,193,189,244,159,158,28,247,246,161,236,3,196,54,68,104,193,168,8,117,228,31,189,193,55,98,97,99,126,47,100,166,79,218,155,154,26,209,49,131,135,136,150,47,126,217,223,52,53,45,51,134,211,170,140,67,69,108,43,106,91,230,119,120,226,130,247,63,53,52,238,20,242,46,70,156,78,62,96,46,53,63,143,34,227,173,155,133,123,117,111,44,125,19,236,134,51,216,206,205,154,153,22,39,37,167,200,201,208,36,142,100,57,212,202,20,60,99,28,158,157,35,226,113,160,159,27,204,202,210,113,225,46,43,202,204,62,76,77,137,123,116,41,38,72,203,129,142,64,98,240,49,102,64,41,73,74,212,216,207,42,74,184,169,170,211,170,149,176,105,66,69,122,6,168,123,147,187,96,77,90,65,55,107,89,90,180,101,100,120,63,105,104,93,137,227,15,86,85,129,102,49,14,87,86,55,8,9,100,47,121,145,23,22,88,89,179,6,122,196,88,95,96,138,172,136,215,58,172,115,48,219,42,80,81,195,3,51,43,146,61,171,175,199,81,82,38,53,46,225,144,163,110,246,33,7,52,65,66,229,228,117,34,127,234,107,108,69,109,108,151,48,64,235,62,78,191,129,209,126,111,35,143,163,161,246,117,123,50,222,65,52,19,125,141,221,55,65,3,195,197,25,7,33,220,237,44,70,71,139,122,193,245,247,130,33,71,21,162,153,158,159,170,169,150,188,174,196,216,186,92,144,160,161,2,97,167,141,125,241,164,167,37,72,38,12,145,159,160,38,82,13,63,68,71,226,35,111,158,153,154,101,50,205,206,92,165,209,198,217,165,167,97,220,115,218,133,112,243,239,238,241,214,135,169,190,173,133,171,208,32,125,44,237,86,87,178,85,86,179,84,85,180,83,84,181,201,83,182,137,93,132,76,62,183,61,76,184,57,61,185,212,57,186,214,207,187,34,143,156,79,239,237,123,137,177,44,1,4,201,194,32,64,102,129,213,215,138,59,166,219,242,99,97,2,94,141,75,59,235,24,110,228,25,130,226,23,24,229,22,23,230,26,22,231,112,26,232,189,190,243,221,56,190,28,56,221,27,28,222,29,27,223,30,29,224,247,30,225,238,79,20,166,59,75,60,75,240,147,177,215,20,79,166,187,147,213,112,233,244,233,128,245,128,114,188,114,217,174,131,115,220,217,198,236,198,131,134,177,132,58,143,35,124,110,163,7,228,110,25,356,389,368,11,302,267,452,350,349,302,303,269,357,343,277,452,453,357,333,332,297,175,152,377,384,398,382,347,348,330,303,304,270,9,336,337,278,279,360,418,262,431,304,408,409,310,415,407,270,409,410,450,348,347,422,430,434,313,314,17,306,307,375,387,388,260,286,414,398,335,406,418,364,367,416,423,358,327,251,284,298,281,5,4,373,374,253,307,320,321,425,427,411,421,313,18,321,405,406,320,404,405,315,16,17,426,425,266,377,400,369,322,391,269,417,465,464,386,257,258,466,260,388,456,399,419,284,332,333,417,285,8,346,340,261,413,441,285,327,460,328,355,371,329,392,439,438,382,341,256,429,420,360,364,394,379,277,343,437,443,444,283,275,440,363,431,262,369,297,338,337,273,375,321,450,451,349,446,342,467,293,334,282,458,461,462,276,353,383,308,324,325,276,300,293,372,345,447,382,398,362,352,345,340,274,1,19,456,248,281,436,427,425,381,256,252,269,391,393,200,199,428,266,330,329,287,273,422,250,462,328,258,286,384,265,353,342,387,259,257,424,431,430,342,353,276,273,335,424,292,325,307,366,447,345,271,303,302,423,266,371,294,455,460,279,278,294,271,272,304,432,434,427,272,407,408,394,430,431,395,369,400,334,333,299,351,417,168,352,280,411,325,319,320,295,296,336,319,403,404,330,348,349,293,298,333,323,454,447,15,16,315,358,429,279,14,15,316,285,336,9,329,349,350,374,380,252,318,402,403,6,197,419,318,319,325,367,364,365,435,367,397,344,438,439,272,271,311,195,5,281,273,287,291,396,428,199,311,271,268,283,444,445,373,254,339,263,466,249,282,334,296,449,347,346,264,447,454,336,296,299,338,10,151,278,439,455,292,407,415,358,371,355,340,345,372,390,249,466,346,347,280,442,443,282,19,94,370,441,442,295,248,419,197,263,255,359,440,275,274,300,383,368,351,412,465,263,467,466,301,368,389,380,374,386,395,378,379,412,351,419,436,426,322,373,390,388,2,164,393,370,462,461,164,0,267,302,11,12,374,373,387,268,12,13,293,300,301,446,261,340,385,384,381,330,266,425,426,423,391,429,355,437,391,327,326,440,457,438,341,382,362,459,457,461,434,430,394,414,463,362,396,369,262,354,461,457,316,403,402,315,404,403,314,405,404,313,406,405,421,418,406,366,401,361,306,408,407,291,409,408,287,410,409,432,436,410,434,416,411,264,368,383,309,438,457,352,376,401,274,275,4,421,428,262,294,327,358,433,416,367,289,455,439,462,370,326,2,326,370,305,460,455,254,449,448,255,261,446,253,450,449,252,451,450,256,452,451,341,453,452,413,464,463,441,413,414,258,442,441,257,443,442,259,444,443,260,445,444,467,342,445,459,458,250,289,392,290,290,328,460,376,433,435,250,290,392,411,416,433,341,463,464,453,464,465,357,465,412,343,412,399,360,363,440,437,399,456,420,456,363,401,435,288,372,383,353,339,255,249,448,261,255,133,243,190,133,155,112,33,246,247,33,130,25,398,384,286,362,398,414,362,463,341,263,359,467,263,249,255,466,467,260,75,60,166,238,239,79,162,127,139,72,11,37,121,232,120,73,72,39,114,128,47,233,232,128,103,104,67,152,175,148,173,157,155,119,118,101,74,73,40,107,9,108,49,48,131,32,194,211,184,74,185,191,80,183,185,40,186,119,230,118,210,202,214,84,83,17,77,76,146,161,160,30,190,56,173,182,106,194,138,135,192,129,203,98,54,21,68,5,51,4,145,144,23,90,77,91,207,205,187,83,201,18,181,91,182,180,90,181,16,85,17,205,206,36,176,148,140,165,92,39,245,193,244,27,159,28,30,247,161,174,236,196,103,54,104,55,193,8,111,117,31,221,189,55,240,98,99,142,126,100,219,166,218,112,155,26,198,209,131,169,135,150,114,47,217,224,223,53,220,45,134,32,211,140,109,67,108,146,43,91,231,230,120,113,226,247,105,63,52,241,238,242,124,46,156,95,78,96,70,46,63,116,143,227,116,123,111,1,44,19,3,236,51,207,216,205,26,154,22,165,39,167,199,200,208,101,36,100,43,57,202,242,20,99,56,28,157,124,35,113,29,160,27,211,204,210,124,113,46,106,43,204,96,62,77,227,137,116,73,41,72,36,203,142,235,64,240,48,49,64,42,41,74,214,212,207,183,42,184,210,169,211,140,170,176,104,105,69,193,122,168,50,123,187,89,96,90,66,65,107,179,89,180,119,101,120,68,63,104,234,93,227,16,15,85,209,129,49,15,14,86,107,55,9,120,100,121,153,145,22,178,88,179,197,6,196,89,88,96,135,138,136,138,215,172,218,115,219,41,42,81,5,195,51,57,43,61,208,171,199,41,81,38,224,53,225,24,144,110,105,52,66,118,229,117,227,34,234,66,107,69,10,109,151,219,48,235,183,62,191,142,129,126,116,111,143,7,163,246,118,117,50,223,222,52,94,19,141,222,221,65,196,3,197,45,220,44,156,70,139,188,122,245,139,71,162,145,153,159,149,170,150,122,188,196,206,216,92,163,144,161,164,2,167,242,141,241,0,164,37,11,72,12,144,145,160,12,38,13,70,63,71,31,226,111,157,158,154,36,101,205,203,206,165,126,209,217,98,165,97,237,220,218,237,239,241,210,214,169,140,171,32,241,125,237,179,86,178,180,85,179,181,84,180,182,83,181,194,201,182,177,137,132,184,76,183,185,61,184,186,57,185,216,212,186,192,214,187,139,34,156,218,79,237,147,123,177,45,44,4,208,201,32,98,64,129,192,213,138,235,59,219,141,242,97,97,2,141,240,75,235,229,24,228,31,25,226,230,23,229,231,22,230,232,26,231,233,112,232,244,189,243,189,221,190,222,28,221,223,27,222,224,29,223,225,30,224,113,247,225,99,60,240,213,147,215,60,20,166,192,187,213,243,112,244,244,233,245,245,128,188,188,114,174,134,131,220,174,217,236,236,198,134,215,177,58,156,143,124,25,110,7,31,228,25,264,356,368,0,11,267,451,452,349,267,302,269,350,357,277,350,452,357,299,333,297,396,175,377,381,384,382,280,347,330,269,303,270,151,9,337,344,278,360,424,418,431,270,304,409,272,310,407,322,270,410,449,450,347,432,422,434,18,313,17,291,306,375,259,387,260,424,335,418,434,364,416,391,423,327,301,251,298,275,281,4,254,373,253,375,307,321,280,425,411,200,421,18,335,321,406,321,320,405,314,315,17,423,426,266,396,377,369,270,322,269,413,417,464,385,386,258,248,456,419,298,284,333,168,417,8,448,346,261,417,413,285,326,327,328,277,355,329,309,392,438,381,382,256,279,429,360,365,364,379,355,277,437,282,443,283,281,275,363,395,431,369,299,297,337,335,273,321,348,450,349,359,446,467,283,293,282,250,458,462,300,276,383,292,308,325,283,276,293,264,372,447,346,352,340,354,274,19,363,456,281,426,436,425,380,381,252,267,269,393,421,200,428,371,266,329,432,287,422,290,250,328,385,258,384,446,265,342,386,387,257,422,424,430,445,342,276,422,273,424,306,292,307,352,366,345,268,271,302,358,423,371,327,294,460,331,279,294,303,271,304,436,432,427,304,272,408,395,394,431,378,395,400,296,334,299,6,351,168,376,352,411,307,325,320,285,295,336,320,319,404,329,330,349,334,293,333,366,323,447,316,15,315,331,358,279,317,14,316,8,285,9,277,329,350,253,374,252,319,318,403,351,6,419,324,318,325,397,367,365,288,435,397,278,344,439,310,272,311,248,195,281,375,273,291,175,396,199,312,311,268,276,283,445,390,373,339,295,282,296,448,449,346,356,264,454,337,336,299,337,338,151,294,278,455,308,292,415,429,358,355,265,340,372,388,390,466,352,346,280,295,442,282,354,19,370,285,441,295,195,248,197,457,440,274,301,300,368,417,351,465,251,301,389,385,380,386,394,395,379,399,412,419,410,436,322,387,373,388,326,2,393,354,370,461,393,164,267,268,302,12,386,374,387,312,268,13,298,293,301,265,446,340,380,385,381,280,330,425,322,426,391,420,429,437,393,391,326,344,440,438,458,459,461,364,434,394,428,396,262,274,354,457,317,316,402,316,315,403,315,314,404,314,313,405,313,421,406,323,366,361,292,306,407,306,291,408,291,287,409,287,432,410,427,434,411,372,264,383,459,309,457,366,352,401,1,274,4,418,421,262,331,294,358,435,433,367,392,289,439,328,462,326,94,2,370,289,305,455,339,254,448,359,255,446,254,253,449,253,252,450,252,256,451,256,341,452,414,413,463,286,441,414,286,258,441,258,257,442,257,259,443,259,260,444,260,467,445,309,459,250,305,289,290,305,290,460,401,376,435,309,250,392,376,411,433,453,341,464,357,453,465,343,357,412,437,343,399,344,360,440,420,437,456,360,420,363,361,401,288,265,372,353,390,339,249,339,448,255];var ele=[127,234,132,58,172,150,149,148,152,377,378,379,397,288,361,454,356,70,63,105,66,107,336,296,334,293,300,168,6,195,4,98,97,2,326,327,33,160,158,133,153,144,362,385,387,263,373,380,57,40,37,0,267,270,287,321,314,17,84,91,78,81,13,311,308,402,14,178],tle=[33,133,362,263,1,62,308,159,145,386,374,6,102,331,2,13,14,70,105,107,336,334,300,54,10,284,50,280,234,454,58,288,152],nle=[33,133,362,263,1,78,308],Yle=ele.map(e=>Rd[e]),Jle=tle.map(e=>Rd[e]),Qle=nle.map(e=>Rd[e]);function sle(e,t,n){let s=function(i,l,u){let c=new RegExp("\\b"+l+" \\w+ (\\w+)","ig");i.replace(c,(d,p)=>(u[p]=0,d))},r=function(i,l){let u=e.createShader(l);if(e.shaderSource(u,i),e.compileShader(u),!e.getShaderParameter(u,e.COMPILE_STATUS))throw new Error("filter: gl compile failed",e.getShaderInfoLog(u));return u};this.uniform={},this.attribute={};let a=r(t,e.VERTEX_SHADER),o=r(n,e.FRAGMENT_SHADER);if(this.id=e.createProgram(),e.attachShader(this.id,a),e.attachShader(this.id,o),e.linkProgram(this.id),!e.getProgramParameter(this.id,e.LINK_STATUS))throw new Error("filter: gl link failed",e.getProgramInfoLog(this.id));e.useProgram(this.id),s(t,"attribute",this.attribute);for(let i in this.attribute)this.attribute[i]=e.getAttribLocation(this.id,i);s(t,"uniform",this.uniform),s(n,"uniform",this.uniform);for(let i in this.uniform)this.uniform[i]=e.getUniformLocation(this.id,i)}function A8(e){e||(e={});let t=0,n=null,s=!1,r=-1,a=[null,null],o=[],i=-1,l=-1,u=null,c=null,d={},p=e.canvas||document.createElement("canvas"),h={},f={INTERMEDIATE:1},m=p.getContext("webgl");if(!m)throw new Error("filter: context failed");this.addFilter=function(v){let k=Array.prototype.slice.call(arguments,1),S=d[v];o.push({func:S,args:k})},this.reset=function(){o=[]};let g=function(v,k){if(!(v===i&&k===l)){if(p.width=v,i=v,p.height=k,l=k,!u){let S=new Float32Array([-1,-1,0,1,1,-1,1,1,-1,1,0,0,-1,1,0,0,1,-1,1,1,1,1,1,0]);u=m.createBuffer(),m.bindBuffer(m.ARRAY_BUFFER,u),m.bufferData(m.ARRAY_BUFFER,S,m.STATIC_DRAW),m.pixelStorei(m.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!0)}m.viewport(0,0,i,l),a=[null,null]}},A=function(v,k){let S=m.createFramebuffer();m.bindFramebuffer(m.FRAMEBUFFER,S);let C=m.createRenderbuffer();m.bindRenderbuffer(m.RENDERBUFFER,C);let D=m.createTexture();return m.bindTexture(m.TEXTURE_2D,D),m.texImage2D(m.TEXTURE_2D,0,m.RGBA,v,k,0,m.RGBA,m.UNSIGNED_BYTE,null),m.texParameteri(m.TEXTURE_2D,m.TEXTURE_MAG_FILTER,m.LINEAR),m.texParameteri(m.TEXTURE_2D,m.TEXTURE_MIN_FILTER,m.LINEAR),m.texParameteri(m.TEXTURE_2D,m.TEXTURE_WRAP_S,m.CLAMP_TO_EDGE),m.texParameteri(m.TEXTURE_2D,m.TEXTURE_WRAP_T,m.CLAMP_TO_EDGE),m.framebufferTexture2D(m.FRAMEBUFFER,m.COLOR_ATTACHMENT0,m.TEXTURE_2D,D,0),m.bindTexture(m.TEXTURE_2D,null),m.bindFramebuffer(m.FRAMEBUFFER,null),{fbo:S,texture:D}},y=function(v){return a[v]=a[v]||A(i,l),a[v]},x=function(v=null){var D,O;let k=null,S=null,C=!1;t===0?k=n:k=(D=y(r))==null?void 0:D.texture,t++,s&&!(v&f.INTERMEDIATE)?(S=null,C=t%2==0):(r=(r+1)%2,S=(O=y(r))==null?void 0:O.fbo),m.bindTexture(m.TEXTURE_2D,k),m.bindFramebuffer(m.FRAMEBUFFER,S),m.uniform1f(c.uniform.flipY,C?-1:1),m.drawArrays(m.TRIANGLES,0,6)};this.apply=function(v){if(g(v.width,v.height),t=0,n||(n=m.createTexture()),m.bindTexture(m.TEXTURE_2D,n),m.texParameteri(m.TEXTURE_2D,m.TEXTURE_WRAP_S,m.CLAMP_TO_EDGE),m.texParameteri(m.TEXTURE_2D,m.TEXTURE_WRAP_T,m.CLAMP_TO_EDGE),m.texParameteri(m.TEXTURE_2D,m.TEXTURE_MIN_FILTER,m.NEAREST),m.texParameteri(m.TEXTURE_2D,m.TEXTURE_MAG_FILTER,m.NEAREST),m.texImage2D(m.TEXTURE_2D,0,m.RGBA,m.RGBA,m.UNSIGNED_BYTE,v),o.length===0)return x(),p;for(let k=0;k<o.length;k++){s=k===o.length-1;let S=o[k];S.func.apply(this,S.args||[])}return p};let b=function(v){if(h[v])return c=h[v],m.useProgram(c.id),c;let k={};k.VERTEX_IDENTITY=["precision highp float;","attribute vec2 pos;","attribute vec2 uv;","varying vec2 vUv;","uniform float flipY;","void main(void) {","vUv = uv;","gl_Position = vec4(pos.x, pos.y*flipY, 0.0, 1.);","}"].join(`
|
|
`),k.FRAGMENT_IDENTITY=["precision highp float;","varying vec2 vUv;","uniform sampler2D texture;","void main(void) {","gl_FragColor = texture2D(texture, vUv);","}"].join(`
|
|
`),c=new sle(m,k.VERTEX_IDENTITY,v);let S=Float32Array.BYTES_PER_ELEMENT,C=4*S;return m.enableVertexAttribArray(c.attribute.pos),m.vertexAttribPointer(c.attribute.pos,2,m.FLOAT,!1,C,0*S),m.enableVertexAttribArray(c.attribute.uv),m.vertexAttribPointer(c.attribute.uv,2,m.FLOAT,!1,C,2*S),h[v]=c,c};d.colorMatrix=function(v){let k=new Float32Array(v);k[4]/=255,k[9]/=255,k[14]/=255,k[19]/=255;let S=k[18]===1&&k[3]===0&&k[8]===0&&k[13]===0&&k[15]===0&&k[16]===0&&k[17]===0&&k[19]===0?d.colorMatrix.SHADER.WITHOUT_ALPHA:d.colorMatrix.SHADER.WITH_ALPHA,C=b(S);m.uniform1fv(C.uniform.m,k),x()},d.colorMatrix.SHADER={},d.colorMatrix.SHADER.WITH_ALPHA=["precision highp float;","varying vec2 vUv;","uniform sampler2D texture;","uniform float m[20];","void main(void) {","vec4 c = texture2D(texture, vUv);","gl_FragColor.r = m[0] * c.r + m[1] * c.g + m[2] * c.b + m[3] * c.a + m[4];","gl_FragColor.g = m[5] * c.r + m[6] * c.g + m[7] * c.b + m[8] * c.a + m[9];","gl_FragColor.b = m[10] * c.r + m[11] * c.g + m[12] * c.b + m[13] * c.a + m[14];","gl_FragColor.a = m[15] * c.r + m[16] * c.g + m[17] * c.b + m[18] * c.a + m[19];","}"].join(`
|
|
`),d.colorMatrix.SHADER.WITHOUT_ALPHA=["precision highp float;","varying vec2 vUv;","uniform sampler2D texture;","uniform float m[20];","void main(void) {","vec4 c = texture2D(texture, vUv);","gl_FragColor.r = m[0] * c.r + m[1] * c.g + m[2] * c.b + m[4];","gl_FragColor.g = m[5] * c.r + m[6] * c.g + m[7] * c.b + m[9];","gl_FragColor.b = m[10] * c.r + m[11] * c.g + m[12] * c.b + m[14];","gl_FragColor.a = c.a;","}"].join(`
|
|
`),d.brightness=function(v){let k=(v||0)+1;d.colorMatrix([k,0,0,0,0,0,k,0,0,0,0,0,k,0,0,0,0,0,1,0])},d.saturation=function(v){let k=(v||0)*2/3+1,S=(k-1)*-.5;d.colorMatrix([k,S,S,0,0,S,k,S,0,0,S,S,k,0,0,0,0,0,1,0])},d.desaturate=function(){d.saturation(-1)},d.contrast=function(v){let k=(v||0)+1,S=-128*(k-1);d.colorMatrix([k,0,0,0,S,0,k,0,0,S,0,0,k,0,S,0,0,0,1,0])},d.negative=function(){d.contrast(-2)},d.hue=function(v){v=(v||0)/180*Math.PI;let k=Math.cos(v),S=Math.sin(v),C=.213,D=.715,O=.072;d.colorMatrix([C+k*(1-C)+S*-C,D+k*-D+S*-D,O+k*-O+S*(1-O),0,0,C+k*-C+S*.143,D+k*(1-D)+S*.14,O+k*-O+S*-.283,0,0,C+k*-C+S*-(1-C),D+k*-D+S*D,O+k*(1-O)+S*O,0,0,0,0,0,1,0])},d.desaturateLuminance=function(){d.colorMatrix([.2764723,.929708,.0938197,0,-37.1,.2764723,.929708,.0938197,0,-37.1,.2764723,.929708,.0938197,0,-37.1,0,0,0,1,0])},d.sepia=function(){d.colorMatrix([.393,.7689999,.18899999,0,0,.349,.6859999,.16799999,0,0,.272,.5339999,.13099999,0,0,0,0,0,1,0])},d.brownie=function(){d.colorMatrix([.5997023498159715,.34553243048391263,-.2708298674538042,0,47.43192855600873,-.037703249837783157,.8609577587992641,.15059552388459913,0,-36.96841498319127,.24113635128153335,-.07441037908422492,.44972182064877153,0,-7.562075277591283,0,0,0,1,0])},d.vintagePinhole=function(){d.colorMatrix([.6279345635605994,.3202183420819367,-.03965408211312453,0,9.651285835294123,.02578397704808868,.6441188644374771,.03259127616149294,0,7.462829176470591,.0466055556782719,-.0851232987247891,.5241648018700465,0,5.159190588235296,0,0,0,1,0])},d.kodachrome=function(){d.colorMatrix([1.1285582396593525,-.3967382283601348,-.03992559172921793,0,63.72958762196502,-.16404339962244616,1.0835251566291304,-.05498805115633132,0,24.732407896706203,-.16786010706155763,-.5603416277695248,1.6014850761964943,0,35.62982807460946,0,0,0,1,0])},d.technicolor=function(){d.colorMatrix([1.9125277891456083,-.8545344976951645,-.09155508482755585,0,11.793603434377337,-.3087833385928097,1.7658908555458428,-.10601743074722245,0,-70.35205161461398,-.231103377548616,-.7501899197440212,1.847597816108189,0,30.950940869491138,0,0,0,1,0])},d.polaroid=function(){d.colorMatrix([1.438,-.062,-.062,0,0,-.122,1.378,-.122,0,0,-.016,-.016,1.483,0,0,0,0,0,1,0])},d.shiftToBGR=function(){d.colorMatrix([0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,1,0])},d.convolution=function(v){let k=new Float32Array(v),S=1/i,C=1/l,D=b(d.convolution.SHADER);m.uniform1fv(D.uniform.m,k),m.uniform2f(D.uniform.px,S,C),x()},d.convolution.SHADER=["precision highp float;","varying vec2 vUv;","uniform sampler2D texture;","uniform vec2 px;","uniform float m[9];","void main(void) {","vec4 c11 = texture2D(texture, vUv - px);","vec4 c12 = texture2D(texture, vec2(vUv.x, vUv.y - px.y));","vec4 c13 = texture2D(texture, vec2(vUv.x + px.x, vUv.y - px.y));","vec4 c21 = texture2D(texture, vec2(vUv.x - px.x, vUv.y) );","vec4 c22 = texture2D(texture, vUv);","vec4 c23 = texture2D(texture, vec2(vUv.x + px.x, vUv.y) );","vec4 c31 = texture2D(texture, vec2(vUv.x - px.x, vUv.y + px.y) );","vec4 c32 = texture2D(texture, vec2(vUv.x, vUv.y + px.y) );","vec4 c33 = texture2D(texture, vUv + px );","gl_FragColor = ","c11 * m[0] + c12 * m[1] + c22 * m[2] +","c21 * m[3] + c22 * m[4] + c23 * m[5] +","c31 * m[6] + c32 * m[7] + c33 * m[8];","gl_FragColor.a = c22.a;","}"].join(`
|
|
`),d.detectEdges=function(){d.convolution.call(this,[0,1,0,1,-4,1,0,1,0])},d.sobelX=function(){d.convolution.call(this,[-1,0,1,-2,0,2,-1,0,1])},d.sobelY=function(){d.convolution.call(this,[-1,-2,-1,0,0,0,1,2,1])},d.sharpen=function(v){let k=v||1;d.convolution.call(this,[0,-1*k,0,-1*k,1+4*k,-1*k,0,-1*k,0])},d.emboss=function(v){let k=v||1;d.convolution.call(this,[-2*k,-1*k,0,-1*k,1,1*k,0,1*k,2*k])},d.blur=function(v){let k=v/7/i,S=v/7/l,C=b(d.blur.SHADER);m.uniform2f(C.uniform.px,0,S),x(f.INTERMEDIATE),m.uniform2f(C.uniform.px,k,0),x()},d.blur.SHADER=["precision highp float;","varying vec2 vUv;","uniform sampler2D texture;","uniform vec2 px;","void main(void) {","gl_FragColor = vec4(0.0);","gl_FragColor += texture2D(texture, vUv + vec2(-7.0*px.x, -7.0*px.y))*0.0044299121055113265;","gl_FragColor += texture2D(texture, vUv + vec2(-6.0*px.x, -6.0*px.y))*0.00895781211794;","gl_FragColor += texture2D(texture, vUv + vec2(-5.0*px.x, -5.0*px.y))*0.0215963866053;","gl_FragColor += texture2D(texture, vUv + vec2(-4.0*px.x, -4.0*px.y))*0.0443683338718;","gl_FragColor += texture2D(texture, vUv + vec2(-3.0*px.x, -3.0*px.y))*0.0776744219933;","gl_FragColor += texture2D(texture, vUv + vec2(-2.0*px.x, -2.0*px.y))*0.115876621105;","gl_FragColor += texture2D(texture, vUv + vec2(-1.0*px.x, -1.0*px.y))*0.147308056121;","gl_FragColor += texture2D(texture, vUv )*0.159576912161;","gl_FragColor += texture2D(texture, vUv + vec2( 1.0*px.x, 1.0*px.y))*0.147308056121;","gl_FragColor += texture2D(texture, vUv + vec2( 2.0*px.x, 2.0*px.y))*0.115876621105;","gl_FragColor += texture2D(texture, vUv + vec2( 3.0*px.x, 3.0*px.y))*0.0776744219933;","gl_FragColor += texture2D(texture, vUv + vec2( 4.0*px.x, 4.0*px.y))*0.0443683338718;","gl_FragColor += texture2D(texture, vUv + vec2( 5.0*px.x, 5.0*px.y))*0.0215963866053;","gl_FragColor += texture2D(texture, vUv + vec2( 6.0*px.x, 6.0*px.y))*0.00895781211794;","gl_FragColor += texture2D(texture, vUv + vec2( 7.0*px.x, 7.0*px.y))*0.0044299121055113265;","}"].join(`
|
|
`),d.pixelate=function(v){let k=v/i,S=v/l,C=b(d.pixelate.SHADER);m.uniform2f(C.uniform.size,k,S),x()},d.pixelate.SHADER=["precision highp float;","varying vec2 vUv;","uniform vec2 size;","uniform sampler2D texture;","vec2 pixelate(vec2 coord, vec2 size) {","return floor( coord / size ) * size;","}","void main(void) {","gl_FragColor = vec4(0.0);","vec2 coord = pixelate(vUv, size);","gl_FragColor += texture2D(texture, coord);","}"].join(`
|
|
`)}var p0=2048,Fe,Nt,jt;function Xn(e,t){let n;return de.browser?typeof OffscreenCanvas!="undefined"?n=new OffscreenCanvas(e,t):(n=document.createElement("canvas"),n.width=e,n.height=t):n=typeof de.Canvas!="undefined"?new de.Canvas(e,t):null,n}function gi(e,t){let n;if(!e)return t.debug&&ie("input is missing"),{tensor:null,canvas:null};if(!(e instanceof Ge)&&!(typeof Image!="undefined"&&e instanceof Image)&&!(typeof de.Canvas!="undefined"&&e instanceof de.Canvas)&&!(typeof ImageData!="undefined"&&e instanceof ImageData)&&!(typeof ImageBitmap!="undefined"&&e instanceof ImageBitmap)&&!(typeof HTMLImageElement!="undefined"&&e instanceof HTMLImageElement)&&!(typeof HTMLMediaElement!="undefined"&&e instanceof HTMLMediaElement)&&!(typeof HTMLVideoElement!="undefined"&&e instanceof HTMLVideoElement)&&!(typeof HTMLCanvasElement!="undefined"&&e instanceof HTMLCanvasElement)&&!(typeof OffscreenCanvas!="undefined"&&e instanceof OffscreenCanvas))throw new Error("input type is not recognized");if(e instanceof Ge)if(e.shape&&e.shape.length===4&&e.shape[0]===1&&e.shape[3]===3)n=Bs(e);else throw new Error(`input tensor shape must be [1, height, width, 3] and instead was ${e.shape}`);else{if(typeof e.readyState!="undefined"&&e.readyState<=2)return t.debug&&ie("input stream is not ready"),{tensor:null,canvas:Fe};let s=e.naturalWidth||e.videoWidth||e.width||e.shape&&e.shape[1]>0,r=e.naturalHeight||e.videoHeight||e.height||e.shape&&e.shape[2]>0;if(!s||!r)return t.debug&&ie("cannot determine input dimensions"),{tensor:null,canvas:Fe};let a=s,o=r;if(a>p0&&(a=p0,o=a*r/s),o>p0&&(o=p0,a=o*s/r),(t.filter.width||0)>0?a=t.filter.width:(t.filter.height||0)>0&&(a=s*((t.filter.height||0)/r)),(t.filter.height||0)>0?o=t.filter.height:(t.filter.width||0)>0&&(o=r*((t.filter.width||0)/s)),!a||!o)throw new Error("input cannot determine dimension");(!Fe||(Fe==null?void 0:Fe.width)!==a||(Fe==null?void 0:Fe.height)!==o)&&(Fe=Xn(a,o));let i=Fe.getContext("2d");if(typeof ImageData!="undefined"&&e instanceof ImageData?i.putImageData(e,0,0):t.filter.flip&&typeof i.translate!="undefined"?(i.translate(s,0),i.scale(-1,1),i.drawImage(e,0,0,s,r,0,0,Fe==null?void 0:Fe.width,Fe==null?void 0:Fe.height),i.setTransform(1,0,0,1,0,0)):i.drawImage(e,0,0,s,r,0,0,Fe==null?void 0:Fe.width,Fe==null?void 0:Fe.height),t.filter.enabled&&de.webgl.supported){if((!jt||!Nt||Fe.width!==Nt.width||(Fe==null?void 0:Fe.height)!==(Nt==null?void 0:Nt.height))&&(Nt=Xn(Fe==null?void 0:Fe.width,Fe==null?void 0:Fe.height),(Nt==null?void 0:Nt.width)!==(Fe==null?void 0:Fe.width)&&(Nt.width=Fe==null?void 0:Fe.width),(Nt==null?void 0:Nt.height)!==(Fe==null?void 0:Fe.height)&&(Nt.height=Fe==null?void 0:Fe.height),jt=de.browser?new A8({canvas:Nt}):null),!jt)return{tensor:null,canvas:Fe};jt.reset(),jt.addFilter("brightness",t.filter.brightness),t.filter.contrast!==0&&jt.addFilter("contrast",t.filter.contrast),t.filter.sharpness!==0&&jt.addFilter("sharpen",t.filter.sharpness),t.filter.blur!==0&&jt.addFilter("blur",t.filter.blur),t.filter.saturation!==0&&jt.addFilter("saturation",t.filter.saturation),t.filter.hue!==0&&jt.addFilter("hue",t.filter.hue),t.filter.negative&&jt.addFilter("negative"),t.filter.sepia&&jt.addFilter("sepia"),t.filter.vintage&&jt.addFilter("brownie"),t.filter.sepia&&jt.addFilter("sepia"),t.filter.kodachrome&&jt.addFilter("kodachrome"),t.filter.technicolor&&jt.addFilter("technicolor"),t.filter.polaroid&&jt.addFilter("polaroid"),t.filter.pixelate!==0&&jt.addFilter("pixelate",t.filter.pixelate),jt.apply(Fe)}else Nt=Fe,jt&&(jt=null);if(!n){let l;if(Nt.data){let u=[Nt.height,Nt.width,3];l=ah(Nt.data,u,"float32")}else if(typeof ImageData!="undefined"&&Nt instanceof ImageData)l=xs?xs.fromPixels(Nt):null;else if(t.backend==="webgl"||t.backend==="humangl"){let u=Xn(a,o);u.width=a,u.height=o;let c=u.getContext("2d");c==null||c.drawImage(Nt,0,0);try{l=xs&&de.browser?xs.fromPixels(u):null}catch(d){throw new Error("browser webgl error")}}else{let u=Xn(a,o);if(!u)return{tensor:null,canvas:Fe};u.width=a,u.height=o;let c=u.getContext("2d");if(!c)return{tensor:null,canvas:Fe};c.drawImage(Nt,0,0);let d=c.getImageData(0,0,a,o);xs&&de.browser?l=xs.fromPixels(d):l=H(()=>{let p=an(Array.from(d.data),[a,o,4]),h=Vt(p,4,2),f=mn([h[0],h[1],h[2]],2);return V(f,[p.shape[0],p.shape[1],3])})}if(l){let u=pe(l,"float32");n=Lt(u,0),Z(l),Z(u)}else throw n=Mt([1,a,o,3]),new Error("cannot create tensor from input")}}return{tensor:n,canvas:t.filter.return?Nt:null}}var _y=0,y8=1;async function x8(e,t){if(e.cacheSensitivity===0)return!1;let n=32;if(!t.shape[1]||!t.shape[2])return!1;let s=$e.resizeBilinear(t,[Math.trunc(t.shape[1]/n),Math.trunc(t.shape[2]/n)]),r=await s.data();Z(s);let a=0;for(let l=0;l<r.length/3;l++)a+=r[3*l+2];let o=100*(Math.max(a,_y)/Math.min(a,_y)-1);_y=a;let i=o<Math.max(e.cacheSensitivity,y8);return y8=o>10*e.cacheSensitivity?0:o,i}var de={browser:void 0,node:void 0,worker:void 0,platform:void 0,agent:void 0,initial:!0,backends:[],tfjs:{version:void 0},wasm:{supported:void 0,backend:void 0,simd:void 0,multithread:void 0},webgl:{supported:void 0,backend:void 0,version:void 0,renderer:void 0},webgpu:{supported:void 0,backend:void 0,adapter:void 0},kernels:[],Canvas:void 0,Image:void 0};async function rle(){var n;de.backends=Object.keys(Qn().registryFactory),de.wasm.supported=typeof WebAssembly!="undefined",de.wasm.backend=de.backends.includes("wasm"),de.wasm.supported&&de.wasm.backend&&Cr()==="wasm"&&(de.wasm.simd=await Y().getAsync("WASM_HAS_SIMD_SUPPORT"),de.wasm.multithread=await Y().getAsync("WASM_HAS_MULTITHREAD_SUPPORT"));let e=Xn(100,100),t=e?e.getContext("webgl2"):void 0;if(de.webgl.supported=typeof t!="undefined",de.webgl.backend=de.backends.includes("webgl"),de.webgl.supported&&de.webgl.backend&&(Cr()==="webgl"||Cr()==="humangl")){let s=ia().gpgpu!=="undefined"?await ia().getGPGPUContext().gl:null;s&&(de.webgl.version=s.getParameter(s.VERSION),de.webgl.renderer=s.getParameter(s.RENDERER))}de.webgpu.supported=de.browser&&typeof navigator.gpu!="undefined",de.webgpu.backend=de.backends.includes("webgpu"),de.webgpu.supported&&(de.webgpu.adapter=(n=await navigator.gpu.requestAdapter())==null?void 0:n.name),de.kernels=ta(Cr()).map(s=>s.kernelName.toLowerCase())}async function h0(){if(de.browser=typeof navigator!="undefined",de.node=typeof process!="undefined",de.worker=de.browser?typeof WorkerGlobalScope!="undefined":void 0,de.tfjs.version=ih,typeof navigator!="undefined"){let e=navigator.userAgent.match(/\(([^()]+)\)/g);if(e&&e[0]){let t=e[0].match(/\(([^()]+)\)/g);de.platform=t&&t[0]?t[0].replace(/\(|\)/g,""):"",de.agent=navigator.userAgent.replace(e[0],""),de.platform[1]&&(de.agent=de.agent.replace(e[1],"")),de.agent=de.agent.replace(/ /g," ")}}else typeof process!="undefined"&&(de.platform=`${process.platform} ${process.arch}`,de.agent=`NodeJS ${process.version}`);await rle()}var $y=gr.leftEyeLower0,Fy=gr.rightEyeLower0,Tu={leftBounds:[$y[0],$y[$y.length-1]],rightBounds:[Fy[0],Fy[Fy.length-1]]},b8={count:468,mouth:13,symmetryLine:[13,gr.midwayBetweenEyes[0]]},ale={leftEye:0,rightEye:1,nose:2,mouth:3,leftEar:4,rightEar:5,symmetryLine:[3,2]},Nu={upperCenter:3,lowerCenter:4,index:71,numCoordinates:76};function f0(e,t,n,s){for(let r=0;r<Dy.length;r++){let{key:a,indices:o}=Dy[r],i=gr[`${n}${a}`];if(!s||s.includes(a))for(let l=0;l<o.length;l++){let u=o[l];e[i[l]]=[t[u][0],t[u][1],(t[u][2]+e[i[l]][2])/2]}}}var Oy=class{constructor(t,n,s){Re(this,"storedBoxes");Re(this,"boundingBoxDetector");Re(this,"meshDetector");Re(this,"irisModel");Re(this,"boxSize");Re(this,"meshSize");Re(this,"irisSize");Re(this,"irisEnlarge");Re(this,"skipped");Re(this,"detectedFaces");var r,a;this.storedBoxes=[],this.boundingBoxDetector=t,this.meshDetector=n,this.irisModel=s,this.boxSize=((r=t==null?void 0:t.model)==null?void 0:r.inputs[0].shape[2])||0,this.meshSize=(n==null?void 0:n.inputs[0].shape[2])||((a=t==null?void 0:t.model)==null?void 0:a.inputs[0].shape[2]),this.irisSize=(s==null?void 0:s.inputs[0].shape[1])||0,this.irisEnlarge=2.3,this.skipped=0,this.detectedFaces=0}transformRawCoords(t,n,s,r){let a=Td({startPoint:n.startPoint,endPoint:n.endPoint}),o=t.map(d=>[a[0]/this.meshSize*(d[0]-this.meshSize/2),a[1]/this.meshSize*(d[1]-this.meshSize/2),d[2]]),i=s!==0?Ry(s,[0,0]):d0,l=s!==0?o.map(d=>[...p8(d,i),d[2]]):o,u=s!==0?d8(r):d0,c=[...Nd({startPoint:n.startPoint,endPoint:n.endPoint}),1];return l.map(d=>[Math.round(d[0]+Sa(c,u[0])),Math.round(d[1]+Sa(c,u[1])),Math.round(d[2])])}getLeftToRightEyeDepthDifference(t){let n=t[Tu.leftBounds[0]][2],s=t[Tu.rightBounds[0]][2];return n-s}getEyeBox(t,n,s,r,a=!1){let o=c0(u0(Ey([t[s],t[r]]),this.irisEnlarge)),i=Td(o),l=$e.cropAndResize(n,[[o.startPoint[1]/this.meshSize,o.startPoint[0]/this.meshSize,o.endPoint[1]/this.meshSize,o.endPoint[0]/this.meshSize]],[0],[this.irisSize,this.irisSize]);if(a&&de.kernels.includes("flipleftright")){let u=$e.flipLeftRight(l);Z(l),l=u}return{box:o,boxSize:i,crop:l}}getEyeCoords(t,n,s,r=!1){let a=[];for(let o=0;o<Nu.numCoordinates;o++){let i=t[o*3],l=t[o*3+1],u=t[o*3+2];a.push([(r?1-i/this.irisSize:i/this.irisSize)*s[0]+n.startPoint[0],l/this.irisSize*s[1]+n.startPoint[1],u])}return{rawCoords:a,iris:a.slice(Nu.index)}}getAdjustedIrisCoords(t,n,s){let r=t[gr[`${s}EyeUpper0`][Nu.upperCenter]][2],a=t[gr[`${s}EyeLower0`][Nu.lowerCenter]][2],o=(r+a)/2;return n.map((i,l)=>{let u=o;return l===2?u=r:l===4&&(u=a),[i[0],i[1],u]})}correctFaceRotation(t,n,s){let[r,a]=n.landmarks.length>=b8.count?b8.symmetryLine:ale.symmetryLine,o=l8(n.landmarks[r],n.landmarks[a]),i=Nd({startPoint:n.startPoint,endPoint:n.endPoint}),l=[i[0]/s.shape[2],i[1]/s.shape[1]],u=$e.rotateWithOffset(s,o,0,l),c=Ry(-o,i),d=t.face.mesh.enabled?Ed({startPoint:n.startPoint,endPoint:n.endPoint},u,[this.meshSize,this.meshSize]):Ed({startPoint:n.startPoint,endPoint:n.endPoint},u,[this.boxSize,this.boxSize]),p=he(d,255);return Z(d),Z(u),[o,c,p]}async augmentIris(t,n){let{box:s,boxSize:r,crop:a}=this.getEyeBox(t,n,Tu.leftBounds[0],Tu.leftBounds[1],!0),{box:o,boxSize:i,crop:l}=this.getEyeBox(t,n,Tu.rightBounds[0],Tu.rightBounds[1]),u=ft([a,l]);Z(a),Z(l);let c=this.irisModel.predict(u);Z(u);let d=await c.data();Z(c);let p=d.slice(0,Nu.numCoordinates*3),{rawCoords:h,iris:f}=this.getEyeCoords(p,s,r,!0),m=d.slice(Nu.numCoordinates*3),{rawCoords:g,iris:A}=this.getEyeCoords(m,o,i),y=this.getLeftToRightEyeDepthDifference(t);Math.abs(y)<30?(f0(t,h,"left",null),f0(t,g,"right",null)):y<1?f0(t,h,"left",["EyeUpper0","EyeLower0"]):f0(t,g,"right",["EyeUpper0","EyeLower0"]);let x=this.getAdjustedIrisCoords(t,f,"left"),b=this.getAdjustedIrisCoords(t,A,"right");return t.concat(x).concat(b)}async predict(t,n){let s=!1,r;if((this.skipped===0||this.skipped>n.face.detector.skipFrames||!n.face.mesh.enabled||!n.skipFrame)&&(r=await this.boundingBoxDetector.getBoundingBoxes(t,n),this.skipped=0),n.skipFrame&&this.skipped++,!n.skipFrame||r&&r.boxes&&(!n.face.mesh.enabled||r.boxes.length!==this.detectedFaces&&this.detectedFaces!==n.face.detector.maxDetected)){this.storedBoxes=[],this.detectedFaces=0;for(let i of r.boxes){let l=await i.box.startPoint.data(),u=await i.box.endPoint.data(),c=await i.landmarks.array();this.storedBoxes.push({startPoint:l,endPoint:u,landmarks:c,confidence:i.confidence})}this.storedBoxes.length>0&&(s=!0)}if(s){if(!r||!r.boxes||r.boxes.length===0)return this.storedBoxes=[],this.detectedFaces=0,null;for(let i=0;i<this.storedBoxes.length;i++){let l=o8({startPoint:this.storedBoxes[i].startPoint,endPoint:this.storedBoxes[i].endPoint},r.scaleFactor),u=u0(l),c=c0(u),d=this.storedBoxes[i].landmarks,p=this.storedBoxes[i].confidence;this.storedBoxes[i]={...c,confidence:p,landmarks:d}}}r&&r.boxes&&r.boxes.forEach(i=>{Z(i.box.startPoint),Z(i.box.endPoint),Z(i.landmarks)});let a=[],o=[];for(let i of this.storedBoxes){let l,u=0,c;if(n.face.detector.rotation&&n.face.mesh.enabled&&de.kernels.includes("rotatewithoffset"))[u,c,l]=this.correctFaceRotation(n,i,t);else{c=d0;let d=t.clone(),p=n.face.mesh.enabled?Ed({startPoint:i.startPoint,endPoint:i.endPoint},d,[this.meshSize,this.meshSize]):Ed({startPoint:i.startPoint,endPoint:i.endPoint},d,[this.boxSize,this.boxSize]);l=he(p,255),Z(p),Z(d)}if(!n.face.mesh.enabled)a.push({mesh:[],box:i,faceConfidence:null,boxConfidence:i.confidence,confidence:i.confidence,image:l});else{let[d,p,h]=this.meshDetector.execute(l);Z(d);let f=(await p.data())[0];Z(p);let m=V(h,[-1,3]),g=await m.array();if(Z(h),Z(m),f<n.face.detector.minConfidence)i.confidence=f,Z(l);else{n.face.iris.enabled&&(g=await this.augmentIris(g,l));let A=this.transformRawCoords(g,i,u,c);i={...u0(Ey(A),1.5),confidence:i.confidence},n.face.detector.rotation&&n.face.mesh.enabled&&n.face.description.enabled&&de.kernels.includes("rotatewithoffset")&&(Z(l),[u,c,l]=this.correctFaceRotation(n,i,t)),a.push({mesh:A,box:i,faceConfidence:f,boxConfidence:i.confidence,confidence:f,image:l}),i={...c0(i),confidence:i.confidence,faceConfidence:f}}}o.push(i)}return n.face.mesh.enabled&&(this.storedBoxes=o.filter(i=>i.confidence>n.face.detector.minConfidence)),this.detectedFaces=a.length,a}};var $t=[null,null,null],Py;async function v8(e,t){let n=await Py.predict(e,t),s=[],r=0;for(let a of n||[]){if(!a||a.isDisposedInternal)continue;let o=a.mesh.map(c=>[c[0]/(e.shape[2]||0),c[1]/(e.shape[1]||0),c[2]/Py.meshSize]),i={};if(a.mesh&&a.mesh.length>0)for(let c of Object.keys(gr))i[c]=gr[c].map(d=>a.mesh[d]);let l=a.box?[Math.trunc(Math.max(0,a.box.startPoint[0])),Math.trunc(Math.max(0,a.box.startPoint[1])),Math.trunc(Math.min(e.shape[2]||0,a.box.endPoint[0])-Math.max(0,a.box.startPoint[0])),Math.trunc(Math.min(e.shape[1]||0,a.box.endPoint[1])-Math.max(0,a.box.startPoint[1]))]:[0,0,0,0],u=a.box?[a.box.startPoint[0]/(e.shape[2]||0),a.box.startPoint[1]/(e.shape[1]||0),(a.box.endPoint[0]-a.box.startPoint[0])/(e.shape[2]||0),(a.box.endPoint[1]-a.box.startPoint[1])/(e.shape[1]||0)]:[0,0,0,0];s.push({id:r++,score:Math.round(100*a.faceConfidence||100*a.boxConfidence||0)/100,boxScore:Math.round(100*a.boxConfidence)/100,faceScore:Math.round(100*a.faceConfidence)/100,box:l,boxRaw:u,mesh:a.mesh,meshRaw:o,annotations:i,tensor:a.image})}return s}async function My(e){return de.initial&&($t=[null,null,null]),!$t[0]&&e.face.enabled||!$t[1]&&e.face.mesh.enabled||!$t[2]&&e.face.iris.enabled||de.initial?($t=await Promise.all([!$t[0]&&e.face.enabled?g8(e):null,!$t[1]&&e.face.mesh.enabled?yt(xt(e.modelBasePath,e.face.mesh.modelPath),{fromTFHub:e.face.mesh.modelPath.includes("tfhub.dev")}):null,!$t[2]&&e.face.iris.enabled?yt(xt(e.modelBasePath,e.face.iris.modelPath),{fromTFHub:e.face.iris.modelPath.includes("tfhub.dev")}):null]),e.face.mesh.enabled&&(!$t[1]||!$t[1].modelUrl?ie("load model failed:",e.face.mesh.modelPath):e.debug&&ie("load model:",$t[1].modelUrl)),e.face.iris.enabled&&(!$t[2]||!$t[2].modelUrl?ie("load model failed:",e.face.iris.modelPath):e.debug&&ie("load model:",$t[2].modelUrl))):e.debug&&($t[0]&&ie("cached model:",$t[0].model.modelUrl),$t[1]&&ie("cached model:",$t[1].modelUrl),$t[2]&&ie("cached model:",$t[2].modelUrl)),Py=new Oy($t[0],$t[1],$t[2]),$t}var w8=mi,k8=Rd;var $n,m0=[],I8=0,zy=Number.MAX_SAFE_INTEGER;async function Ly(e){var n,s;let t=xt(e.modelBasePath,((n=e.face.description)==null?void 0:n.modelPath)||"");return de.initial&&($n=null),$n?e.debug&&ie("cached model:",t):($n=await yt(t),$n?e.debug&&ie("load model:",t):ie("load model failed:",((s=e.face.description)==null?void 0:s.modelPath)||"")),$n}function By(e,t,n=2){if(!e||!t||(e==null?void 0:e.length)===0||(t==null?void 0:t.length)===0||(e==null?void 0:e.length)!==(t==null?void 0:t.length))return 0;let s=5*e.map((a,o)=>Math.abs(e[o]-t[o])**n).reduce((a,o)=>a+o,0)**(1/n);return Math.max(0,100-s)/100}function S8(e,t,n=0){let s={similarity:0,name:"",source:"",embedding:[]};if(!e||!t||!Array.isArray(e)||!Array.isArray(t))return s;for(let r of t)if(r.embedding&&r.name){let a=By(e,r.embedding);a>n&&a>s.similarity&&(s={...r,similarity:a})}return s}function Wy(e){return H(()=>{let n=e.image||e.tensor||e;if(!(n instanceof Ge))return null;let s=[[.05,.15,.85,.85]];if(!($n==null?void 0:$n.inputs[0].shape))return null;let r=n.shape.length===3?$e.cropAndResize(Lt(n,0),s,[0],[$n.inputs[0].shape[2],$n.inputs[0].shape[1]]):$e.cropAndResize(n,s,[0],[$n.inputs[0].shape[2],$n.inputs[0].shape[1]]);return z(r,255)})}async function Vy(e,t,n,s){var r,a,o;return $n?zy<(((r=t.face.description)==null?void 0:r.skipFrames)||0)&&t.skipFrame&&I8===s&&((a=m0[n])==null?void 0:a.age)&&((o=m0[n])==null?void 0:o.age)>0?(zy++,m0[n]):(zy=0,new Promise(async i=>{var d,p;let l=Wy(e),u,c={age:0,gender:"unknown",genderScore:0,descriptor:[]};if(((d=t.face.description)==null?void 0:d.enabled)&&(u=await($n==null?void 0:$n.predict(l))),Z(l),u){let h=await u.find(b=>b.shape[1]===1).data(),f=Math.trunc(200*Math.abs(h[0]-.5))/100;f>(((p=t.face.description)==null?void 0:p.minConfidence)||0)&&(c.gender=h[0]<=.5?"female":"male",c.genderScore=Math.min(.99,f));let m=Ws(u.find(b=>b.shape[1]===100),1),g=(await m.data())[0];Z(m);let A=await u.find(b=>b.shape[1]===100).data();c.age=Math.round(A[g-1]>A[g+1]?10*g-100*A[g-1]:10*g+100*A[g+1])/10;let x=await u.find(b=>b.shape[1]===1024).data();c.descriptor=[...x],u.forEach(b=>Z(b))}m0[n]=c,I8=s,i(c)})):null}var ole=["angry","disgust","fear","happy","sad","surprise","neutral"],en,g0=[],C8=0,Uy=Number.MAX_SAFE_INTEGER,Hy=[.2989,.587,.114];async function Gy(e){var t;return de.initial&&(en=null),en?e.debug&&ie("cached model:",en.modelUrl):(en=await yt(xt(e.modelBasePath,((t=e.face.emotion)==null?void 0:t.modelPath)||"")),!en||!en.modelUrl?ie("load model failed:",e.body.modelPath):e.debug&&ie("load model:",en.modelUrl)),en}async function jy(e,t,n,s){var r;return en?Uy<(((r=t.face.emotion)==null?void 0:r.skipFrames)||0)&&t.skipFrame&&C8===s&&g0[n]&&g0[n].length>0?(Uy++,g0[n]):(Uy=0,new Promise(async a=>{var g,A;let o=$e.resizeBilinear(e,[(en==null?void 0:en.inputs[0].shape)?en.inputs[0].shape[2]:0,(en==null?void 0:en.inputs[0].shape)?en.inputs[0].shape[1]:0],!1),[i,l,u]=Vt(o,3,3);Z(o);let c=z(i,Hy[0]),d=z(l,Hy[1]),p=z(u,Hy[2]);Z(i),Z(l),Z(u);let h=dh([c,d,p]);Z(c),Z(d),Z(p);let f=H(()=>z(ye(h,.5),2));Z(h);let m=[];if((g=t.face.emotion)==null?void 0:g.enabled){let y=await(en==null?void 0:en.predict(f)),x=await y.data();Z(y);for(let b=0;b<x.length;b++)x[b]>(((A=t.face.emotion)==null?void 0:A.minConfidence)||0)&&m.push({score:Math.min(.99,Math.trunc(100*x[b])/100),emotion:ole[b]});m.sort((b,v)=>v.score-b.score)}Z(f),g0[n]=m,C8=s,a(m)})):null}var Dd=["nose","leftEye","rightEye","leftEar","rightEar","leftShoulder","rightShoulder","leftElbow","rightElbow","leftWrist","rightWrist","leftHip","rightHip","leftKnee","rightKnee","leftAnkle","rightAnkle"],T8=Dd.length,_d=Dd.reduce((e,t,n)=>(e[t]=n,e),{}),ile=[["leftHip","leftShoulder"],["leftElbow","leftShoulder"],["leftElbow","leftWrist"],["leftHip","leftKnee"],["leftKnee","leftAnkle"],["rightHip","rightShoulder"],["rightElbow","rightShoulder"],["rightElbow","rightWrist"],["rightHip","rightKnee"],["rightKnee","rightAnkle"],["leftShoulder","rightShoulder"],["leftHip","rightHip"]],lle=ile.map(([e,t])=>[_d[e],_d[t]]),N8=[["nose","leftEye"],["leftEye","leftEar"],["nose","rightEye"],["rightEye","rightEar"],["nose","leftShoulder"],["leftShoulder","leftElbow"],["leftElbow","leftWrist"],["leftShoulder","leftHip"],["leftHip","leftKnee"],["leftKnee","leftAnkle"],["nose","rightShoulder"],["rightShoulder","rightElbow"],["rightElbow","rightWrist"],["rightShoulder","rightHip"],["rightHip","rightKnee"],["rightKnee","rightAnkle"]];function E8(e){let t=e.reduce(({maxX:n,maxY:s,minX:r,minY:a},{position:{x:o,y:i}})=>({maxX:Math.max(n,o),maxY:Math.max(s,i),minX:Math.min(r,o),minY:Math.min(a,i)}),{maxX:Number.NEGATIVE_INFINITY,maxY:Number.NEGATIVE_INFINITY,minX:Number.POSITIVE_INFINITY,minY:Number.POSITIVE_INFINITY});return[t.minX,t.minY,t.maxX-t.minX,t.maxY-t.minY]}function R8(e,[t,n],[s,r]){let a=t/s,o=n/r,i=(u,c)=>({id:c,score:u.score,boxRaw:[u.box[0]/r,u.box[1]/s,u.box[2]/r,u.box[3]/s],box:[Math.trunc(u.box[0]*o),Math.trunc(u.box[1]*a),Math.trunc(u.box[2]*o),Math.trunc(u.box[3]*a)],keypoints:u.keypoints.map(({score:d,part:p,position:h})=>({score:d,part:p,position:[Math.trunc(h.x*o),Math.trunc(h.y*a)],positionRaw:[h.x/s,h.y/s]}))});return e.map((u,c)=>i(u,c))}var qy=class{constructor(t,n){Re(this,"priorityQueue");Re(this,"numberOfElements");Re(this,"getElementValue");this.priorityQueue=new Array(t),this.numberOfElements=-1,this.getElementValue=n}enqueue(t){this.priorityQueue[++this.numberOfElements]=t,this.swim(this.numberOfElements)}dequeue(){let t=this.priorityQueue[0];return this.exchange(0,this.numberOfElements--),this.sink(0),this.priorityQueue[this.numberOfElements+1]=null,t}empty(){return this.numberOfElements===-1}size(){return this.numberOfElements+1}all(){return this.priorityQueue.slice(0,this.numberOfElements+1)}max(){return this.priorityQueue[0]}swim(t){for(;t>0&&this.less(Math.floor(t/2),t);)this.exchange(t,Math.floor(t/2)),t=Math.floor(t/2)}sink(t){for(;2*t<=this.numberOfElements;){let n=2*t;if(n<this.numberOfElements&&this.less(n,n+1)&&n++,!this.less(t,n))break;this.exchange(t,n),t=n}}getValueAt(t){return this.getElementValue(this.priorityQueue[t])}less(t,n){return this.getValueAt(t)<this.getValueAt(n)}exchange(t,n){let s=this.priorityQueue[t];this.priorityQueue[t]=this.priorityQueue[n],this.priorityQueue[n]=s}};function Xy(e,t,n,s){return{y:s.get(e,t,n),x:s.get(e,t,n+T8)}}function Ky(e,t,n){let{heatmapY:s,heatmapX:r,id:a}=e,{y:o,x:i}=Xy(s,r,a,n);return{x:e.heatmapX*t+i,y:e.heatmapY*t+o}}function Zy(e,t,n){return e<t?t:e>n?n:e}function D8(e,t,n,s){let r=n-e,a=s-t;return r*r+a*a}function Yy(e,t){return{x:e.x+t.x,y:e.y+t.y}}var A0=1,Eu=16,ule=50**2;function _8(e,t,n,s,r,a,o=2){let i=A=>({y:a.get(A.y,A.x,e),x:a.get(A.y,A.x,a.shape[2]/2+e)}),l=(A,y,x)=>({y:Zy(Math.round(A.y/Eu),0,y-1),x:Zy(Math.round(A.x/Eu),0,x-1)}),[u,c]=s.shape,d=l(t.position,u,c),p=i(d),f=Yy(t.position,p);for(let A=0;A<o;A++){let y=l(f,u,c),x=Xy(y.y,y.x,n,r);f=Yy({x:y.x*Eu,y:y.y*Eu},{x:x.x,y:x.y})}let m=l(f,u,c),g=s.get(m.y,m.x,n);return{position:f,part:Dd[n],score:g}}function cle(e,t,n,s,r){let a=N8.map(([p,h])=>[_d[p],_d[h]]),o=a.map(([,p])=>p),i=a.map(([p])=>p),l=t.shape[2],u=o.length,c=new Array(l),d=Ky(e.part,Eu,n);c[e.part.id]={score:e.score,part:Dd[e.part.id],position:d};for(let p=u-1;p>=0;--p){let h=o[p],f=i[p];c[h]&&!c[f]&&(c[f]=_8(p,c[h],f,t,n,r))}for(let p=0;p<u;++p){let h=i[p],f=o[p];c[h]&&!c[f]&&(c[f]=_8(p,c[h],f,t,n,s))}return c}function dle(e,t,n,s,r){let[a,o]=r.shape,i=!0,l=Math.max(n-A0,0),u=Math.min(n+A0+1,a);for(let c=l;c<u;++c){let d=Math.max(s-A0,0),p=Math.min(s+A0+1,o);for(let h=d;h<p;++h)if(r.get(c,h,e)>t){i=!1;break}if(!i)break}return i}function ple(e,t){let[n,s,r]=t.shape,a=new qy(n*s*r,({score:o})=>o);for(let o=0;o<n;++o)for(let i=0;i<s;++i)for(let l=0;l<r;++l){let u=t.get(o,i,l);u<e||dle(l,u,o,i,t)&&a.enqueue({score:u,part:{heatmapY:o,heatmapX:i,id:l}})}return a}function $8(e,{x:t,y:n},s){return e.some(({keypoints:r})=>{var o;let a=(o=r[s])==null?void 0:o.position;return a?D8(n,t,a.y,a.x)<=ule:!1})}function hle(e,t){return t.reduce((s,{position:r,score:a},o)=>($8(e,r,o)||(s+=a),s),0)/t.length}function F8(e,t,n,s,r,a){let o=[],i=ple(a,t);for(;o.length<r&&!i.empty();){let l=i.dequeue(),u=Ky(l.part,Eu,e);if($8(o,u,l.part.id))continue;let c=cle(l,t,e,n,s);c=c.filter(h=>h.score>a);let d=hle(o,c),p=E8(c);d>a&&o.push({keypoints:c,box:p,score:Math.round(100*d)/100})}return o}var ps,fle=["MobilenetV1/offset_2/BiasAdd","MobilenetV1/heatmap_2/BiasAdd","MobilenetV1/displacement_fwd_2/BiasAdd","MobilenetV1/displacement_bwd_2/BiasAdd"];async function Jy(e,t){let n=H(()=>{if(!ps.inputs[0].shape)return[];let o=$e.resizeBilinear(e,[ps.inputs[0].shape[2],ps.inputs[0].shape[1]]),i=ye(he(pe(o,"float32"),127.5),1),u=ps.execute(i,fle).map(c=>lt(c,[0]));return u[1]=u[1].sigmoid(),u}),s=await Promise.all(n.map(o=>o.buffer()));for(let o of n)Z(o);let r=await F8(s[0],s[1],s[2],s[3],t.body.maxDetected,t.body.minConfidence);return ps.inputs[0].shape?R8(r,[e.shape[1],e.shape[2]],[ps.inputs[0].shape[2],ps.inputs[0].shape[1]]):[]}async function Qy(e){return!ps||de.initial?(ps=await yt(xt(e.modelBasePath,e.body.modelPath||"")),!ps||!ps.modelUrl?ie("load model failed:",e.body.modelPath):e.debug&&ie("load model:",ps.modelUrl)):e.debug&&ie("cached model:",ps.modelUrl),ps}function y0(e){return[Math.abs(e.endPoint[0]-e.startPoint[0]),Math.abs(e.endPoint[1]-e.startPoint[1])]}function $d(e){return[e.startPoint[0]+(e.endPoint[0]-e.startPoint[0])/2,e.startPoint[1]+(e.endPoint[1]-e.startPoint[1])/2]}function O8(e,t,n){let s=t.shape[1],r=t.shape[2],a=[[e.startPoint[1]/s,e.startPoint[0]/r,e.endPoint[1]/s,e.endPoint[0]/r]];return $e.cropAndResize(t,a,[0],n)}function P8(e,t){let n=[e.startPoint[0]*t[0],e.startPoint[1]*t[1]],s=[e.endPoint[0]*t[0],e.endPoint[1]*t[1]],r=e.palmLandmarks.map(a=>[a[0]*t[0],a[1]*t[1]]);return{startPoint:n,endPoint:s,palmLandmarks:r,confidence:e.confidence}}function x0(e,t=1.5){let n=$d(e),s=y0(e),r=[t*s[0]/2,t*s[1]/2],a=[n[0]-r[0],n[1]-r[1]],o=[n[0]+r[0],n[1]+r[1]];return{startPoint:a,endPoint:o,palmLandmarks:e.palmLandmarks}}function b0(e){let t=$d(e),n=y0(e),r=Math.max(...n)/2,a=[t[0]-r,t[1]-r],o=[t[0]+r,t[1]+r];return{startPoint:a,endPoint:o,palmLandmarks:e.palmLandmarks}}var M8=[{x:.015625,y:.015625},{x:.015625,y:.015625},{x:.046875,y:.015625},{x:.046875,y:.015625},{x:.078125,y:.015625},{x:.078125,y:.015625},{x:.109375,y:.015625},{x:.109375,y:.015625},{x:.140625,y:.015625},{x:.140625,y:.015625},{x:.171875,y:.015625},{x:.171875,y:.015625},{x:.203125,y:.015625},{x:.203125,y:.015625},{x:.234375,y:.015625},{x:.234375,y:.015625},{x:.265625,y:.015625},{x:.265625,y:.015625},{x:.296875,y:.015625},{x:.296875,y:.015625},{x:.328125,y:.015625},{x:.328125,y:.015625},{x:.359375,y:.015625},{x:.359375,y:.015625},{x:.390625,y:.015625},{x:.390625,y:.015625},{x:.421875,y:.015625},{x:.421875,y:.015625},{x:.453125,y:.015625},{x:.453125,y:.015625},{x:.484375,y:.015625},{x:.484375,y:.015625},{x:.515625,y:.015625},{x:.515625,y:.015625},{x:.546875,y:.015625},{x:.546875,y:.015625},{x:.578125,y:.015625},{x:.578125,y:.015625},{x:.609375,y:.015625},{x:.609375,y:.015625},{x:.640625,y:.015625},{x:.640625,y:.015625},{x:.671875,y:.015625},{x:.671875,y:.015625},{x:.703125,y:.015625},{x:.703125,y:.015625},{x:.734375,y:.015625},{x:.734375,y:.015625},{x:.765625,y:.015625},{x:.765625,y:.015625},{x:.796875,y:.015625},{x:.796875,y:.015625},{x:.828125,y:.015625},{x:.828125,y:.015625},{x:.859375,y:.015625},{x:.859375,y:.015625},{x:.890625,y:.015625},{x:.890625,y:.015625},{x:.921875,y:.015625},{x:.921875,y:.015625},{x:.953125,y:.015625},{x:.953125,y:.015625},{x:.984375,y:.015625},{x:.984375,y:.015625},{x:.015625,y:.046875},{x:.015625,y:.046875},{x:.046875,y:.046875},{x:.046875,y:.046875},{x:.078125,y:.046875},{x:.078125,y:.046875},{x:.109375,y:.046875},{x:.109375,y:.046875},{x:.140625,y:.046875},{x:.140625,y:.046875},{x:.171875,y:.046875},{x:.171875,y:.046875},{x:.203125,y:.046875},{x:.203125,y:.046875},{x:.234375,y:.046875},{x:.234375,y:.046875},{x:.265625,y:.046875},{x:.265625,y:.046875},{x:.296875,y:.046875},{x:.296875,y:.046875},{x:.328125,y:.046875},{x:.328125,y:.046875},{x:.359375,y:.046875},{x:.359375,y:.046875},{x:.390625,y:.046875},{x:.390625,y:.046875},{x:.421875,y:.046875},{x:.421875,y:.046875},{x:.453125,y:.046875},{x:.453125,y:.046875},{x:.484375,y:.046875},{x:.484375,y:.046875},{x:.515625,y:.046875},{x:.515625,y:.046875},{x:.546875,y:.046875},{x:.546875,y:.046875},{x:.578125,y:.046875},{x:.578125,y:.046875},{x:.609375,y:.046875},{x:.609375,y:.046875},{x:.640625,y:.046875},{x:.640625,y:.046875},{x:.671875,y:.046875},{x:.671875,y:.046875},{x:.703125,y:.046875},{x:.703125,y:.046875},{x:.734375,y:.046875},{x:.734375,y:.046875},{x:.765625,y:.046875},{x:.765625,y:.046875},{x:.796875,y:.046875},{x:.796875,y:.046875},{x:.828125,y:.046875},{x:.828125,y:.046875},{x:.859375,y:.046875},{x:.859375,y:.046875},{x:.890625,y:.046875},{x:.890625,y:.046875},{x:.921875,y:.046875},{x:.921875,y:.046875},{x:.953125,y:.046875},{x:.953125,y:.046875},{x:.984375,y:.046875},{x:.984375,y:.046875},{x:.015625,y:.078125},{x:.015625,y:.078125},{x:.046875,y:.078125},{x:.046875,y:.078125},{x:.078125,y:.078125},{x:.078125,y:.078125},{x:.109375,y:.078125},{x:.109375,y:.078125},{x:.140625,y:.078125},{x:.140625,y:.078125},{x:.171875,y:.078125},{x:.171875,y:.078125},{x:.203125,y:.078125},{x:.203125,y:.078125},{x:.234375,y:.078125},{x:.234375,y:.078125},{x:.265625,y:.078125},{x:.265625,y:.078125},{x:.296875,y:.078125},{x:.296875,y:.078125},{x:.328125,y:.078125},{x:.328125,y:.078125},{x:.359375,y:.078125},{x:.359375,y:.078125},{x:.390625,y:.078125},{x:.390625,y:.078125},{x:.421875,y:.078125},{x:.421875,y:.078125},{x:.453125,y:.078125},{x:.453125,y:.078125},{x:.484375,y:.078125},{x:.484375,y:.078125},{x:.515625,y:.078125},{x:.515625,y:.078125},{x:.546875,y:.078125},{x:.546875,y:.078125},{x:.578125,y:.078125},{x:.578125,y:.078125},{x:.609375,y:.078125},{x:.609375,y:.078125},{x:.640625,y:.078125},{x:.640625,y:.078125},{x:.671875,y:.078125},{x:.671875,y:.078125},{x:.703125,y:.078125},{x:.703125,y:.078125},{x:.734375,y:.078125},{x:.734375,y:.078125},{x:.765625,y:.078125},{x:.765625,y:.078125},{x:.796875,y:.078125},{x:.796875,y:.078125},{x:.828125,y:.078125},{x:.828125,y:.078125},{x:.859375,y:.078125},{x:.859375,y:.078125},{x:.890625,y:.078125},{x:.890625,y:.078125},{x:.921875,y:.078125},{x:.921875,y:.078125},{x:.953125,y:.078125},{x:.953125,y:.078125},{x:.984375,y:.078125},{x:.984375,y:.078125},{x:.015625,y:.109375},{x:.015625,y:.109375},{x:.046875,y:.109375},{x:.046875,y:.109375},{x:.078125,y:.109375},{x:.078125,y:.109375},{x:.109375,y:.109375},{x:.109375,y:.109375},{x:.140625,y:.109375},{x:.140625,y:.109375},{x:.171875,y:.109375},{x:.171875,y:.109375},{x:.203125,y:.109375},{x:.203125,y:.109375},{x:.234375,y:.109375},{x:.234375,y:.109375},{x:.265625,y:.109375},{x:.265625,y:.109375},{x:.296875,y:.109375},{x:.296875,y:.109375},{x:.328125,y:.109375},{x:.328125,y:.109375},{x:.359375,y:.109375},{x:.359375,y:.109375},{x:.390625,y:.109375},{x:.390625,y:.109375},{x:.421875,y:.109375},{x:.421875,y:.109375},{x:.453125,y:.109375},{x:.453125,y:.109375},{x:.484375,y:.109375},{x:.484375,y:.109375},{x:.515625,y:.109375},{x:.515625,y:.109375},{x:.546875,y:.109375},{x:.546875,y:.109375},{x:.578125,y:.109375},{x:.578125,y:.109375},{x:.609375,y:.109375},{x:.609375,y:.109375},{x:.640625,y:.109375},{x:.640625,y:.109375},{x:.671875,y:.109375},{x:.671875,y:.109375},{x:.703125,y:.109375},{x:.703125,y:.109375},{x:.734375,y:.109375},{x:.734375,y:.109375},{x:.765625,y:.109375},{x:.765625,y:.109375},{x:.796875,y:.109375},{x:.796875,y:.109375},{x:.828125,y:.109375},{x:.828125,y:.109375},{x:.859375,y:.109375},{x:.859375,y:.109375},{x:.890625,y:.109375},{x:.890625,y:.109375},{x:.921875,y:.109375},{x:.921875,y:.109375},{x:.953125,y:.109375},{x:.953125,y:.109375},{x:.984375,y:.109375},{x:.984375,y:.109375},{x:.015625,y:.140625},{x:.015625,y:.140625},{x:.046875,y:.140625},{x:.046875,y:.140625},{x:.078125,y:.140625},{x:.078125,y:.140625},{x:.109375,y:.140625},{x:.109375,y:.140625},{x:.140625,y:.140625},{x:.140625,y:.140625},{x:.171875,y:.140625},{x:.171875,y:.140625},{x:.203125,y:.140625},{x:.203125,y:.140625},{x:.234375,y:.140625},{x:.234375,y:.140625},{x:.265625,y:.140625},{x:.265625,y:.140625},{x:.296875,y:.140625},{x:.296875,y:.140625},{x:.328125,y:.140625},{x:.328125,y:.140625},{x:.359375,y:.140625},{x:.359375,y:.140625},{x:.390625,y:.140625},{x:.390625,y:.140625},{x:.421875,y:.140625},{x:.421875,y:.140625},{x:.453125,y:.140625},{x:.453125,y:.140625},{x:.484375,y:.140625},{x:.484375,y:.140625},{x:.515625,y:.140625},{x:.515625,y:.140625},{x:.546875,y:.140625},{x:.546875,y:.140625},{x:.578125,y:.140625},{x:.578125,y:.140625},{x:.609375,y:.140625},{x:.609375,y:.140625},{x:.640625,y:.140625},{x:.640625,y:.140625},{x:.671875,y:.140625},{x:.671875,y:.140625},{x:.703125,y:.140625},{x:.703125,y:.140625},{x:.734375,y:.140625},{x:.734375,y:.140625},{x:.765625,y:.140625},{x:.765625,y:.140625},{x:.796875,y:.140625},{x:.796875,y:.140625},{x:.828125,y:.140625},{x:.828125,y:.140625},{x:.859375,y:.140625},{x:.859375,y:.140625},{x:.890625,y:.140625},{x:.890625,y:.140625},{x:.921875,y:.140625},{x:.921875,y:.140625},{x:.953125,y:.140625},{x:.953125,y:.140625},{x:.984375,y:.140625},{x:.984375,y:.140625},{x:.015625,y:.171875},{x:.015625,y:.171875},{x:.046875,y:.171875},{x:.046875,y:.171875},{x:.078125,y:.171875},{x:.078125,y:.171875},{x:.109375,y:.171875},{x:.109375,y:.171875},{x:.140625,y:.171875},{x:.140625,y:.171875},{x:.171875,y:.171875},{x:.171875,y:.171875},{x:.203125,y:.171875},{x:.203125,y:.171875},{x:.234375,y:.171875},{x:.234375,y:.171875},{x:.265625,y:.171875},{x:.265625,y:.171875},{x:.296875,y:.171875},{x:.296875,y:.171875},{x:.328125,y:.171875},{x:.328125,y:.171875},{x:.359375,y:.171875},{x:.359375,y:.171875},{x:.390625,y:.171875},{x:.390625,y:.171875},{x:.421875,y:.171875},{x:.421875,y:.171875},{x:.453125,y:.171875},{x:.453125,y:.171875},{x:.484375,y:.171875},{x:.484375,y:.171875},{x:.515625,y:.171875},{x:.515625,y:.171875},{x:.546875,y:.171875},{x:.546875,y:.171875},{x:.578125,y:.171875},{x:.578125,y:.171875},{x:.609375,y:.171875},{x:.609375,y:.171875},{x:.640625,y:.171875},{x:.640625,y:.171875},{x:.671875,y:.171875},{x:.671875,y:.171875},{x:.703125,y:.171875},{x:.703125,y:.171875},{x:.734375,y:.171875},{x:.734375,y:.171875},{x:.765625,y:.171875},{x:.765625,y:.171875},{x:.796875,y:.171875},{x:.796875,y:.171875},{x:.828125,y:.171875},{x:.828125,y:.171875},{x:.859375,y:.171875},{x:.859375,y:.171875},{x:.890625,y:.171875},{x:.890625,y:.171875},{x:.921875,y:.171875},{x:.921875,y:.171875},{x:.953125,y:.171875},{x:.953125,y:.171875},{x:.984375,y:.171875},{x:.984375,y:.171875},{x:.015625,y:.203125},{x:.015625,y:.203125},{x:.046875,y:.203125},{x:.046875,y:.203125},{x:.078125,y:.203125},{x:.078125,y:.203125},{x:.109375,y:.203125},{x:.109375,y:.203125},{x:.140625,y:.203125},{x:.140625,y:.203125},{x:.171875,y:.203125},{x:.171875,y:.203125},{x:.203125,y:.203125},{x:.203125,y:.203125},{x:.234375,y:.203125},{x:.234375,y:.203125},{x:.265625,y:.203125},{x:.265625,y:.203125},{x:.296875,y:.203125},{x:.296875,y:.203125},{x:.328125,y:.203125},{x:.328125,y:.203125},{x:.359375,y:.203125},{x:.359375,y:.203125},{x:.390625,y:.203125},{x:.390625,y:.203125},{x:.421875,y:.203125},{x:.421875,y:.203125},{x:.453125,y:.203125},{x:.453125,y:.203125},{x:.484375,y:.203125},{x:.484375,y:.203125},{x:.515625,y:.203125},{x:.515625,y:.203125},{x:.546875,y:.203125},{x:.546875,y:.203125},{x:.578125,y:.203125},{x:.578125,y:.203125},{x:.609375,y:.203125},{x:.609375,y:.203125},{x:.640625,y:.203125},{x:.640625,y:.203125},{x:.671875,y:.203125},{x:.671875,y:.203125},{x:.703125,y:.203125},{x:.703125,y:.203125},{x:.734375,y:.203125},{x:.734375,y:.203125},{x:.765625,y:.203125},{x:.765625,y:.203125},{x:.796875,y:.203125},{x:.796875,y:.203125},{x:.828125,y:.203125},{x:.828125,y:.203125},{x:.859375,y:.203125},{x:.859375,y:.203125},{x:.890625,y:.203125},{x:.890625,y:.203125},{x:.921875,y:.203125},{x:.921875,y:.203125},{x:.953125,y:.203125},{x:.953125,y:.203125},{x:.984375,y:.203125},{x:.984375,y:.203125},{x:.015625,y:.234375},{x:.015625,y:.234375},{x:.046875,y:.234375},{x:.046875,y:.234375},{x:.078125,y:.234375},{x:.078125,y:.234375},{x:.109375,y:.234375},{x:.109375,y:.234375},{x:.140625,y:.234375},{x:.140625,y:.234375},{x:.171875,y:.234375},{x:.171875,y:.234375},{x:.203125,y:.234375},{x:.203125,y:.234375},{x:.234375,y:.234375},{x:.234375,y:.234375},{x:.265625,y:.234375},{x:.265625,y:.234375},{x:.296875,y:.234375},{x:.296875,y:.234375},{x:.328125,y:.234375},{x:.328125,y:.234375},{x:.359375,y:.234375},{x:.359375,y:.234375},{x:.390625,y:.234375},{x:.390625,y:.234375},{x:.421875,y:.234375},{x:.421875,y:.234375},{x:.453125,y:.234375},{x:.453125,y:.234375},{x:.484375,y:.234375},{x:.484375,y:.234375},{x:.515625,y:.234375},{x:.515625,y:.234375},{x:.546875,y:.234375},{x:.546875,y:.234375},{x:.578125,y:.234375},{x:.578125,y:.234375},{x:.609375,y:.234375},{x:.609375,y:.234375},{x:.640625,y:.234375},{x:.640625,y:.234375},{x:.671875,y:.234375},{x:.671875,y:.234375},{x:.703125,y:.234375},{x:.703125,y:.234375},{x:.734375,y:.234375},{x:.734375,y:.234375},{x:.765625,y:.234375},{x:.765625,y:.234375},{x:.796875,y:.234375},{x:.796875,y:.234375},{x:.828125,y:.234375},{x:.828125,y:.234375},{x:.859375,y:.234375},{x:.859375,y:.234375},{x:.890625,y:.234375},{x:.890625,y:.234375},{x:.921875,y:.234375},{x:.921875,y:.234375},{x:.953125,y:.234375},{x:.953125,y:.234375},{x:.984375,y:.234375},{x:.984375,y:.234375},{x:.015625,y:.265625},{x:.015625,y:.265625},{x:.046875,y:.265625},{x:.046875,y:.265625},{x:.078125,y:.265625},{x:.078125,y:.265625},{x:.109375,y:.265625},{x:.109375,y:.265625},{x:.140625,y:.265625},{x:.140625,y:.265625},{x:.171875,y:.265625},{x:.171875,y:.265625},{x:.203125,y:.265625},{x:.203125,y:.265625},{x:.234375,y:.265625},{x:.234375,y:.265625},{x:.265625,y:.265625},{x:.265625,y:.265625},{x:.296875,y:.265625},{x:.296875,y:.265625},{x:.328125,y:.265625},{x:.328125,y:.265625},{x:.359375,y:.265625},{x:.359375,y:.265625},{x:.390625,y:.265625},{x:.390625,y:.265625},{x:.421875,y:.265625},{x:.421875,y:.265625},{x:.453125,y:.265625},{x:.453125,y:.265625},{x:.484375,y:.265625},{x:.484375,y:.265625},{x:.515625,y:.265625},{x:.515625,y:.265625},{x:.546875,y:.265625},{x:.546875,y:.265625},{x:.578125,y:.265625},{x:.578125,y:.265625},{x:.609375,y:.265625},{x:.609375,y:.265625},{x:.640625,y:.265625},{x:.640625,y:.265625},{x:.671875,y:.265625},{x:.671875,y:.265625},{x:.703125,y:.265625},{x:.703125,y:.265625},{x:.734375,y:.265625},{x:.734375,y:.265625},{x:.765625,y:.265625},{x:.765625,y:.265625},{x:.796875,y:.265625},{x:.796875,y:.265625},{x:.828125,y:.265625},{x:.828125,y:.265625},{x:.859375,y:.265625},{x:.859375,y:.265625},{x:.890625,y:.265625},{x:.890625,y:.265625},{x:.921875,y:.265625},{x:.921875,y:.265625},{x:.953125,y:.265625},{x:.953125,y:.265625},{x:.984375,y:.265625},{x:.984375,y:.265625},{x:.015625,y:.296875},{x:.015625,y:.296875},{x:.046875,y:.296875},{x:.046875,y:.296875},{x:.078125,y:.296875},{x:.078125,y:.296875},{x:.109375,y:.296875},{x:.109375,y:.296875},{x:.140625,y:.296875},{x:.140625,y:.296875},{x:.171875,y:.296875},{x:.171875,y:.296875},{x:.203125,y:.296875},{x:.203125,y:.296875},{x:.234375,y:.296875},{x:.234375,y:.296875},{x:.265625,y:.296875},{x:.265625,y:.296875},{x:.296875,y:.296875},{x:.296875,y:.296875},{x:.328125,y:.296875},{x:.328125,y:.296875},{x:.359375,y:.296875},{x:.359375,y:.296875},{x:.390625,y:.296875},{x:.390625,y:.296875},{x:.421875,y:.296875},{x:.421875,y:.296875},{x:.453125,y:.296875},{x:.453125,y:.296875},{x:.484375,y:.296875},{x:.484375,y:.296875},{x:.515625,y:.296875},{x:.515625,y:.296875},{x:.546875,y:.296875},{x:.546875,y:.296875},{x:.578125,y:.296875},{x:.578125,y:.296875},{x:.609375,y:.296875},{x:.609375,y:.296875},{x:.640625,y:.296875},{x:.640625,y:.296875},{x:.671875,y:.296875},{x:.671875,y:.296875},{x:.703125,y:.296875},{x:.703125,y:.296875},{x:.734375,y:.296875},{x:.734375,y:.296875},{x:.765625,y:.296875},{x:.765625,y:.296875},{x:.796875,y:.296875},{x:.796875,y:.296875},{x:.828125,y:.296875},{x:.828125,y:.296875},{x:.859375,y:.296875},{x:.859375,y:.296875},{x:.890625,y:.296875},{x:.890625,y:.296875},{x:.921875,y:.296875},{x:.921875,y:.296875},{x:.953125,y:.296875},{x:.953125,y:.296875},{x:.984375,y:.296875},{x:.984375,y:.296875},{x:.015625,y:.328125},{x:.015625,y:.328125},{x:.046875,y:.328125},{x:.046875,y:.328125},{x:.078125,y:.328125},{x:.078125,y:.328125},{x:.109375,y:.328125},{x:.109375,y:.328125},{x:.140625,y:.328125},{x:.140625,y:.328125},{x:.171875,y:.328125},{x:.171875,y:.328125},{x:.203125,y:.328125},{x:.203125,y:.328125},{x:.234375,y:.328125},{x:.234375,y:.328125},{x:.265625,y:.328125},{x:.265625,y:.328125},{x:.296875,y:.328125},{x:.296875,y:.328125},{x:.328125,y:.328125},{x:.328125,y:.328125},{x:.359375,y:.328125},{x:.359375,y:.328125},{x:.390625,y:.328125},{x:.390625,y:.328125},{x:.421875,y:.328125},{x:.421875,y:.328125},{x:.453125,y:.328125},{x:.453125,y:.328125},{x:.484375,y:.328125},{x:.484375,y:.328125},{x:.515625,y:.328125},{x:.515625,y:.328125},{x:.546875,y:.328125},{x:.546875,y:.328125},{x:.578125,y:.328125},{x:.578125,y:.328125},{x:.609375,y:.328125},{x:.609375,y:.328125},{x:.640625,y:.328125},{x:.640625,y:.328125},{x:.671875,y:.328125},{x:.671875,y:.328125},{x:.703125,y:.328125},{x:.703125,y:.328125},{x:.734375,y:.328125},{x:.734375,y:.328125},{x:.765625,y:.328125},{x:.765625,y:.328125},{x:.796875,y:.328125},{x:.796875,y:.328125},{x:.828125,y:.328125},{x:.828125,y:.328125},{x:.859375,y:.328125},{x:.859375,y:.328125},{x:.890625,y:.328125},{x:.890625,y:.328125},{x:.921875,y:.328125},{x:.921875,y:.328125},{x:.953125,y:.328125},{x:.953125,y:.328125},{x:.984375,y:.328125},{x:.984375,y:.328125},{x:.015625,y:.359375},{x:.015625,y:.359375},{x:.046875,y:.359375},{x:.046875,y:.359375},{x:.078125,y:.359375},{x:.078125,y:.359375},{x:.109375,y:.359375},{x:.109375,y:.359375},{x:.140625,y:.359375},{x:.140625,y:.359375},{x:.171875,y:.359375},{x:.171875,y:.359375},{x:.203125,y:.359375},{x:.203125,y:.359375},{x:.234375,y:.359375},{x:.234375,y:.359375},{x:.265625,y:.359375},{x:.265625,y:.359375},{x:.296875,y:.359375},{x:.296875,y:.359375},{x:.328125,y:.359375},{x:.328125,y:.359375},{x:.359375,y:.359375},{x:.359375,y:.359375},{x:.390625,y:.359375},{x:.390625,y:.359375},{x:.421875,y:.359375},{x:.421875,y:.359375},{x:.453125,y:.359375},{x:.453125,y:.359375},{x:.484375,y:.359375},{x:.484375,y:.359375},{x:.515625,y:.359375},{x:.515625,y:.359375},{x:.546875,y:.359375},{x:.546875,y:.359375},{x:.578125,y:.359375},{x:.578125,y:.359375},{x:.609375,y:.359375},{x:.609375,y:.359375},{x:.640625,y:.359375},{x:.640625,y:.359375},{x:.671875,y:.359375},{x:.671875,y:.359375},{x:.703125,y:.359375},{x:.703125,y:.359375},{x:.734375,y:.359375},{x:.734375,y:.359375},{x:.765625,y:.359375},{x:.765625,y:.359375},{x:.796875,y:.359375},{x:.796875,y:.359375},{x:.828125,y:.359375},{x:.828125,y:.359375},{x:.859375,y:.359375},{x:.859375,y:.359375},{x:.890625,y:.359375},{x:.890625,y:.359375},{x:.921875,y:.359375},{x:.921875,y:.359375},{x:.953125,y:.359375},{x:.953125,y:.359375},{x:.984375,y:.359375},{x:.984375,y:.359375},{x:.015625,y:.390625},{x:.015625,y:.390625},{x:.046875,y:.390625},{x:.046875,y:.390625},{x:.078125,y:.390625},{x:.078125,y:.390625},{x:.109375,y:.390625},{x:.109375,y:.390625},{x:.140625,y:.390625},{x:.140625,y:.390625},{x:.171875,y:.390625},{x:.171875,y:.390625},{x:.203125,y:.390625},{x:.203125,y:.390625},{x:.234375,y:.390625},{x:.234375,y:.390625},{x:.265625,y:.390625},{x:.265625,y:.390625},{x:.296875,y:.390625},{x:.296875,y:.390625},{x:.328125,y:.390625},{x:.328125,y:.390625},{x:.359375,y:.390625},{x:.359375,y:.390625},{x:.390625,y:.390625},{x:.390625,y:.390625},{x:.421875,y:.390625},{x:.421875,y:.390625},{x:.453125,y:.390625},{x:.453125,y:.390625},{x:.484375,y:.390625},{x:.484375,y:.390625},{x:.515625,y:.390625},{x:.515625,y:.390625},{x:.546875,y:.390625},{x:.546875,y:.390625},{x:.578125,y:.390625},{x:.578125,y:.390625},{x:.609375,y:.390625},{x:.609375,y:.390625},{x:.640625,y:.390625},{x:.640625,y:.390625},{x:.671875,y:.390625},{x:.671875,y:.390625},{x:.703125,y:.390625},{x:.703125,y:.390625},{x:.734375,y:.390625},{x:.734375,y:.390625},{x:.765625,y:.390625},{x:.765625,y:.390625},{x:.796875,y:.390625},{x:.796875,y:.390625},{x:.828125,y:.390625},{x:.828125,y:.390625},{x:.859375,y:.390625},{x:.859375,y:.390625},{x:.890625,y:.390625},{x:.890625,y:.390625},{x:.921875,y:.390625},{x:.921875,y:.390625},{x:.953125,y:.390625},{x:.953125,y:.390625},{x:.984375,y:.390625},{x:.984375,y:.390625},{x:.015625,y:.421875},{x:.015625,y:.421875},{x:.046875,y:.421875},{x:.046875,y:.421875},{x:.078125,y:.421875},{x:.078125,y:.421875},{x:.109375,y:.421875},{x:.109375,y:.421875},{x:.140625,y:.421875},{x:.140625,y:.421875},{x:.171875,y:.421875},{x:.171875,y:.421875},{x:.203125,y:.421875},{x:.203125,y:.421875},{x:.234375,y:.421875},{x:.234375,y:.421875},{x:.265625,y:.421875},{x:.265625,y:.421875},{x:.296875,y:.421875},{x:.296875,y:.421875},{x:.328125,y:.421875},{x:.328125,y:.421875},{x:.359375,y:.421875},{x:.359375,y:.421875},{x:.390625,y:.421875},{x:.390625,y:.421875},{x:.421875,y:.421875},{x:.421875,y:.421875},{x:.453125,y:.421875},{x:.453125,y:.421875},{x:.484375,y:.421875},{x:.484375,y:.421875},{x:.515625,y:.421875},{x:.515625,y:.421875},{x:.546875,y:.421875},{x:.546875,y:.421875},{x:.578125,y:.421875},{x:.578125,y:.421875},{x:.609375,y:.421875},{x:.609375,y:.421875},{x:.640625,y:.421875},{x:.640625,y:.421875},{x:.671875,y:.421875},{x:.671875,y:.421875},{x:.703125,y:.421875},{x:.703125,y:.421875},{x:.734375,y:.421875},{x:.734375,y:.421875},{x:.765625,y:.421875},{x:.765625,y:.421875},{x:.796875,y:.421875},{x:.796875,y:.421875},{x:.828125,y:.421875},{x:.828125,y:.421875},{x:.859375,y:.421875},{x:.859375,y:.421875},{x:.890625,y:.421875},{x:.890625,y:.421875},{x:.921875,y:.421875},{x:.921875,y:.421875},{x:.953125,y:.421875},{x:.953125,y:.421875},{x:.984375,y:.421875},{x:.984375,y:.421875},{x:.015625,y:.453125},{x:.015625,y:.453125},{x:.046875,y:.453125},{x:.046875,y:.453125},{x:.078125,y:.453125},{x:.078125,y:.453125},{x:.109375,y:.453125},{x:.109375,y:.453125},{x:.140625,y:.453125},{x:.140625,y:.453125},{x:.171875,y:.453125},{x:.171875,y:.453125},{x:.203125,y:.453125},{x:.203125,y:.453125},{x:.234375,y:.453125},{x:.234375,y:.453125},{x:.265625,y:.453125},{x:.265625,y:.453125},{x:.296875,y:.453125},{x:.296875,y:.453125},{x:.328125,y:.453125},{x:.328125,y:.453125},{x:.359375,y:.453125},{x:.359375,y:.453125},{x:.390625,y:.453125},{x:.390625,y:.453125},{x:.421875,y:.453125},{x:.421875,y:.453125},{x:.453125,y:.453125},{x:.453125,y:.453125},{x:.484375,y:.453125},{x:.484375,y:.453125},{x:.515625,y:.453125},{x:.515625,y:.453125},{x:.546875,y:.453125},{x:.546875,y:.453125},{x:.578125,y:.453125},{x:.578125,y:.453125},{x:.609375,y:.453125},{x:.609375,y:.453125},{x:.640625,y:.453125},{x:.640625,y:.453125},{x:.671875,y:.453125},{x:.671875,y:.453125},{x:.703125,y:.453125},{x:.703125,y:.453125},{x:.734375,y:.453125},{x:.734375,y:.453125},{x:.765625,y:.453125},{x:.765625,y:.453125},{x:.796875,y:.453125},{x:.796875,y:.453125},{x:.828125,y:.453125},{x:.828125,y:.453125},{x:.859375,y:.453125},{x:.859375,y:.453125},{x:.890625,y:.453125},{x:.890625,y:.453125},{x:.921875,y:.453125},{x:.921875,y:.453125},{x:.953125,y:.453125},{x:.953125,y:.453125},{x:.984375,y:.453125},{x:.984375,y:.453125},{x:.015625,y:.484375},{x:.015625,y:.484375},{x:.046875,y:.484375},{x:.046875,y:.484375},{x:.078125,y:.484375},{x:.078125,y:.484375},{x:.109375,y:.484375},{x:.109375,y:.484375},{x:.140625,y:.484375},{x:.140625,y:.484375},{x:.171875,y:.484375},{x:.171875,y:.484375},{x:.203125,y:.484375},{x:.203125,y:.484375},{x:.234375,y:.484375},{x:.234375,y:.484375},{x:.265625,y:.484375},{x:.265625,y:.484375},{x:.296875,y:.484375},{x:.296875,y:.484375},{x:.328125,y:.484375},{x:.328125,y:.484375},{x:.359375,y:.484375},{x:.359375,y:.484375},{x:.390625,y:.484375},{x:.390625,y:.484375},{x:.421875,y:.484375},{x:.421875,y:.484375},{x:.453125,y:.484375},{x:.453125,y:.484375},{x:.484375,y:.484375},{x:.484375,y:.484375},{x:.515625,y:.484375},{x:.515625,y:.484375},{x:.546875,y:.484375},{x:.546875,y:.484375},{x:.578125,y:.484375},{x:.578125,y:.484375},{x:.609375,y:.484375},{x:.609375,y:.484375},{x:.640625,y:.484375},{x:.640625,y:.484375},{x:.671875,y:.484375},{x:.671875,y:.484375},{x:.703125,y:.484375},{x:.703125,y:.484375},{x:.734375,y:.484375},{x:.734375,y:.484375},{x:.765625,y:.484375},{x:.765625,y:.484375},{x:.796875,y:.484375},{x:.796875,y:.484375},{x:.828125,y:.484375},{x:.828125,y:.484375},{x:.859375,y:.484375},{x:.859375,y:.484375},{x:.890625,y:.484375},{x:.890625,y:.484375},{x:.921875,y:.484375},{x:.921875,y:.484375},{x:.953125,y:.484375},{x:.953125,y:.484375},{x:.984375,y:.484375},{x:.984375,y:.484375},{x:.015625,y:.515625},{x:.015625,y:.515625},{x:.046875,y:.515625},{x:.046875,y:.515625},{x:.078125,y:.515625},{x:.078125,y:.515625},{x:.109375,y:.515625},{x:.109375,y:.515625},{x:.140625,y:.515625},{x:.140625,y:.515625},{x:.171875,y:.515625},{x:.171875,y:.515625},{x:.203125,y:.515625},{x:.203125,y:.515625},{x:.234375,y:.515625},{x:.234375,y:.515625},{x:.265625,y:.515625},{x:.265625,y:.515625},{x:.296875,y:.515625},{x:.296875,y:.515625},{x:.328125,y:.515625},{x:.328125,y:.515625},{x:.359375,y:.515625},{x:.359375,y:.515625},{x:.390625,y:.515625},{x:.390625,y:.515625},{x:.421875,y:.515625},{x:.421875,y:.515625},{x:.453125,y:.515625},{x:.453125,y:.515625},{x:.484375,y:.515625},{x:.484375,y:.515625},{x:.515625,y:.515625},{x:.515625,y:.515625},{x:.546875,y:.515625},{x:.546875,y:.515625},{x:.578125,y:.515625},{x:.578125,y:.515625},{x:.609375,y:.515625},{x:.609375,y:.515625},{x:.640625,y:.515625},{x:.640625,y:.515625},{x:.671875,y:.515625},{x:.671875,y:.515625},{x:.703125,y:.515625},{x:.703125,y:.515625},{x:.734375,y:.515625},{x:.734375,y:.515625},{x:.765625,y:.515625},{x:.765625,y:.515625},{x:.796875,y:.515625},{x:.796875,y:.515625},{x:.828125,y:.515625},{x:.828125,y:.515625},{x:.859375,y:.515625},{x:.859375,y:.515625},{x:.890625,y:.515625},{x:.890625,y:.515625},{x:.921875,y:.515625},{x:.921875,y:.515625},{x:.953125,y:.515625},{x:.953125,y:.515625},{x:.984375,y:.515625},{x:.984375,y:.515625},{x:.015625,y:.546875},{x:.015625,y:.546875},{x:.046875,y:.546875},{x:.046875,y:.546875},{x:.078125,y:.546875},{x:.078125,y:.546875},{x:.109375,y:.546875},{x:.109375,y:.546875},{x:.140625,y:.546875},{x:.140625,y:.546875},{x:.171875,y:.546875},{x:.171875,y:.546875},{x:.203125,y:.546875},{x:.203125,y:.546875},{x:.234375,y:.546875},{x:.234375,y:.546875},{x:.265625,y:.546875},{x:.265625,y:.546875},{x:.296875,y:.546875},{x:.296875,y:.546875},{x:.328125,y:.546875},{x:.328125,y:.546875},{x:.359375,y:.546875},{x:.359375,y:.546875},{x:.390625,y:.546875},{x:.390625,y:.546875},{x:.421875,y:.546875},{x:.421875,y:.546875},{x:.453125,y:.546875},{x:.453125,y:.546875},{x:.484375,y:.546875},{x:.484375,y:.546875},{x:.515625,y:.546875},{x:.515625,y:.546875},{x:.546875,y:.546875},{x:.546875,y:.546875},{x:.578125,y:.546875},{x:.578125,y:.546875},{x:.609375,y:.546875},{x:.609375,y:.546875},{x:.640625,y:.546875},{x:.640625,y:.546875},{x:.671875,y:.546875},{x:.671875,y:.546875},{x:.703125,y:.546875},{x:.703125,y:.546875},{x:.734375,y:.546875},{x:.734375,y:.546875},{x:.765625,y:.546875},{x:.765625,y:.546875},{x:.796875,y:.546875},{x:.796875,y:.546875},{x:.828125,y:.546875},{x:.828125,y:.546875},{x:.859375,y:.546875},{x:.859375,y:.546875},{x:.890625,y:.546875},{x:.890625,y:.546875},{x:.921875,y:.546875},{x:.921875,y:.546875},{x:.953125,y:.546875},{x:.953125,y:.546875},{x:.984375,y:.546875},{x:.984375,y:.546875},{x:.015625,y:.578125},{x:.015625,y:.578125},{x:.046875,y:.578125},{x:.046875,y:.578125},{x:.078125,y:.578125},{x:.078125,y:.578125},{x:.109375,y:.578125},{x:.109375,y:.578125},{x:.140625,y:.578125},{x:.140625,y:.578125},{x:.171875,y:.578125},{x:.171875,y:.578125},{x:.203125,y:.578125},{x:.203125,y:.578125},{x:.234375,y:.578125},{x:.234375,y:.578125},{x:.265625,y:.578125},{x:.265625,y:.578125},{x:.296875,y:.578125},{x:.296875,y:.578125},{x:.328125,y:.578125},{x:.328125,y:.578125},{x:.359375,y:.578125},{x:.359375,y:.578125},{x:.390625,y:.578125},{x:.390625,y:.578125},{x:.421875,y:.578125},{x:.421875,y:.578125},{x:.453125,y:.578125},{x:.453125,y:.578125},{x:.484375,y:.578125},{x:.484375,y:.578125},{x:.515625,y:.578125},{x:.515625,y:.578125},{x:.546875,y:.578125},{x:.546875,y:.578125},{x:.578125,y:.578125},{x:.578125,y:.578125},{x:.609375,y:.578125},{x:.609375,y:.578125},{x:.640625,y:.578125},{x:.640625,y:.578125},{x:.671875,y:.578125},{x:.671875,y:.578125},{x:.703125,y:.578125},{x:.703125,y:.578125},{x:.734375,y:.578125},{x:.734375,y:.578125},{x:.765625,y:.578125},{x:.765625,y:.578125},{x:.796875,y:.578125},{x:.796875,y:.578125},{x:.828125,y:.578125},{x:.828125,y:.578125},{x:.859375,y:.578125},{x:.859375,y:.578125},{x:.890625,y:.578125},{x:.890625,y:.578125},{x:.921875,y:.578125},{x:.921875,y:.578125},{x:.953125,y:.578125},{x:.953125,y:.578125},{x:.984375,y:.578125},{x:.984375,y:.578125},{x:.015625,y:.609375},{x:.015625,y:.609375},{x:.046875,y:.609375},{x:.046875,y:.609375},{x:.078125,y:.609375},{x:.078125,y:.609375},{x:.109375,y:.609375},{x:.109375,y:.609375},{x:.140625,y:.609375},{x:.140625,y:.609375},{x:.171875,y:.609375},{x:.171875,y:.609375},{x:.203125,y:.609375},{x:.203125,y:.609375},{x:.234375,y:.609375},{x:.234375,y:.609375},{x:.265625,y:.609375},{x:.265625,y:.609375},{x:.296875,y:.609375},{x:.296875,y:.609375},{x:.328125,y:.609375},{x:.328125,y:.609375},{x:.359375,y:.609375},{x:.359375,y:.609375},{x:.390625,y:.609375},{x:.390625,y:.609375},{x:.421875,y:.609375},{x:.421875,y:.609375},{x:.453125,y:.609375},{x:.453125,y:.609375},{x:.484375,y:.609375},{x:.484375,y:.609375},{x:.515625,y:.609375},{x:.515625,y:.609375},{x:.546875,y:.609375},{x:.546875,y:.609375},{x:.578125,y:.609375},{x:.578125,y:.609375},{x:.609375,y:.609375},{x:.609375,y:.609375},{x:.640625,y:.609375},{x:.640625,y:.609375},{x:.671875,y:.609375},{x:.671875,y:.609375},{x:.703125,y:.609375},{x:.703125,y:.609375},{x:.734375,y:.609375},{x:.734375,y:.609375},{x:.765625,y:.609375},{x:.765625,y:.609375},{x:.796875,y:.609375},{x:.796875,y:.609375},{x:.828125,y:.609375},{x:.828125,y:.609375},{x:.859375,y:.609375},{x:.859375,y:.609375},{x:.890625,y:.609375},{x:.890625,y:.609375},{x:.921875,y:.609375},{x:.921875,y:.609375},{x:.953125,y:.609375},{x:.953125,y:.609375},{x:.984375,y:.609375},{x:.984375,y:.609375},{x:.015625,y:.640625},{x:.015625,y:.640625},{x:.046875,y:.640625},{x:.046875,y:.640625},{x:.078125,y:.640625},{x:.078125,y:.640625},{x:.109375,y:.640625},{x:.109375,y:.640625},{x:.140625,y:.640625},{x:.140625,y:.640625},{x:.171875,y:.640625},{x:.171875,y:.640625},{x:.203125,y:.640625},{x:.203125,y:.640625},{x:.234375,y:.640625},{x:.234375,y:.640625},{x:.265625,y:.640625},{x:.265625,y:.640625},{x:.296875,y:.640625},{x:.296875,y:.640625},{x:.328125,y:.640625},{x:.328125,y:.640625},{x:.359375,y:.640625},{x:.359375,y:.640625},{x:.390625,y:.640625},{x:.390625,y:.640625},{x:.421875,y:.640625},{x:.421875,y:.640625},{x:.453125,y:.640625},{x:.453125,y:.640625},{x:.484375,y:.640625},{x:.484375,y:.640625},{x:.515625,y:.640625},{x:.515625,y:.640625},{x:.546875,y:.640625},{x:.546875,y:.640625},{x:.578125,y:.640625},{x:.578125,y:.640625},{x:.609375,y:.640625},{x:.609375,y:.640625},{x:.640625,y:.640625},{x:.640625,y:.640625},{x:.671875,y:.640625},{x:.671875,y:.640625},{x:.703125,y:.640625},{x:.703125,y:.640625},{x:.734375,y:.640625},{x:.734375,y:.640625},{x:.765625,y:.640625},{x:.765625,y:.640625},{x:.796875,y:.640625},{x:.796875,y:.640625},{x:.828125,y:.640625},{x:.828125,y:.640625},{x:.859375,y:.640625},{x:.859375,y:.640625},{x:.890625,y:.640625},{x:.890625,y:.640625},{x:.921875,y:.640625},{x:.921875,y:.640625},{x:.953125,y:.640625},{x:.953125,y:.640625},{x:.984375,y:.640625},{x:.984375,y:.640625},{x:.015625,y:.671875},{x:.015625,y:.671875},{x:.046875,y:.671875},{x:.046875,y:.671875},{x:.078125,y:.671875},{x:.078125,y:.671875},{x:.109375,y:.671875},{x:.109375,y:.671875},{x:.140625,y:.671875},{x:.140625,y:.671875},{x:.171875,y:.671875},{x:.171875,y:.671875},{x:.203125,y:.671875},{x:.203125,y:.671875},{x:.234375,y:.671875},{x:.234375,y:.671875},{x:.265625,y:.671875},{x:.265625,y:.671875},{x:.296875,y:.671875},{x:.296875,y:.671875},{x:.328125,y:.671875},{x:.328125,y:.671875},{x:.359375,y:.671875},{x:.359375,y:.671875},{x:.390625,y:.671875},{x:.390625,y:.671875},{x:.421875,y:.671875},{x:.421875,y:.671875},{x:.453125,y:.671875},{x:.453125,y:.671875},{x:.484375,y:.671875},{x:.484375,y:.671875},{x:.515625,y:.671875},{x:.515625,y:.671875},{x:.546875,y:.671875},{x:.546875,y:.671875},{x:.578125,y:.671875},{x:.578125,y:.671875},{x:.609375,y:.671875},{x:.609375,y:.671875},{x:.640625,y:.671875},{x:.640625,y:.671875},{x:.671875,y:.671875},{x:.671875,y:.671875},{x:.703125,y:.671875},{x:.703125,y:.671875},{x:.734375,y:.671875},{x:.734375,y:.671875},{x:.765625,y:.671875},{x:.765625,y:.671875},{x:.796875,y:.671875},{x:.796875,y:.671875},{x:.828125,y:.671875},{x:.828125,y:.671875},{x:.859375,y:.671875},{x:.859375,y:.671875},{x:.890625,y:.671875},{x:.890625,y:.671875},{x:.921875,y:.671875},{x:.921875,y:.671875},{x:.953125,y:.671875},{x:.953125,y:.671875},{x:.984375,y:.671875},{x:.984375,y:.671875},{x:.015625,y:.703125},{x:.015625,y:.703125},{x:.046875,y:.703125},{x:.046875,y:.703125},{x:.078125,y:.703125},{x:.078125,y:.703125},{x:.109375,y:.703125},{x:.109375,y:.703125},{x:.140625,y:.703125},{x:.140625,y:.703125},{x:.171875,y:.703125},{x:.171875,y:.703125},{x:.203125,y:.703125},{x:.203125,y:.703125},{x:.234375,y:.703125},{x:.234375,y:.703125},{x:.265625,y:.703125},{x:.265625,y:.703125},{x:.296875,y:.703125},{x:.296875,y:.703125},{x:.328125,y:.703125},{x:.328125,y:.703125},{x:.359375,y:.703125},{x:.359375,y:.703125},{x:.390625,y:.703125},{x:.390625,y:.703125},{x:.421875,y:.703125},{x:.421875,y:.703125},{x:.453125,y:.703125},{x:.453125,y:.703125},{x:.484375,y:.703125},{x:.484375,y:.703125},{x:.515625,y:.703125},{x:.515625,y:.703125},{x:.546875,y:.703125},{x:.546875,y:.703125},{x:.578125,y:.703125},{x:.578125,y:.703125},{x:.609375,y:.703125},{x:.609375,y:.703125},{x:.640625,y:.703125},{x:.640625,y:.703125},{x:.671875,y:.703125},{x:.671875,y:.703125},{x:.703125,y:.703125},{x:.703125,y:.703125},{x:.734375,y:.703125},{x:.734375,y:.703125},{x:.765625,y:.703125},{x:.765625,y:.703125},{x:.796875,y:.703125},{x:.796875,y:.703125},{x:.828125,y:.703125},{x:.828125,y:.703125},{x:.859375,y:.703125},{x:.859375,y:.703125},{x:.890625,y:.703125},{x:.890625,y:.703125},{x:.921875,y:.703125},{x:.921875,y:.703125},{x:.953125,y:.703125},{x:.953125,y:.703125},{x:.984375,y:.703125},{x:.984375,y:.703125},{x:.015625,y:.734375},{x:.015625,y:.734375},{x:.046875,y:.734375},{x:.046875,y:.734375},{x:.078125,y:.734375},{x:.078125,y:.734375},{x:.109375,y:.734375},{x:.109375,y:.734375},{x:.140625,y:.734375},{x:.140625,y:.734375},{x:.171875,y:.734375},{x:.171875,y:.734375},{x:.203125,y:.734375},{x:.203125,y:.734375},{x:.234375,y:.734375},{x:.234375,y:.734375},{x:.265625,y:.734375},{x:.265625,y:.734375},{x:.296875,y:.734375},{x:.296875,y:.734375},{x:.328125,y:.734375},{x:.328125,y:.734375},{x:.359375,y:.734375},{x:.359375,y:.734375},{x:.390625,y:.734375},{x:.390625,y:.734375},{x:.421875,y:.734375},{x:.421875,y:.734375},{x:.453125,y:.734375},{x:.453125,y:.734375},{x:.484375,y:.734375},{x:.484375,y:.734375},{x:.515625,y:.734375},{x:.515625,y:.734375},{x:.546875,y:.734375},{x:.546875,y:.734375},{x:.578125,y:.734375},{x:.578125,y:.734375},{x:.609375,y:.734375},{x:.609375,y:.734375},{x:.640625,y:.734375},{x:.640625,y:.734375},{x:.671875,y:.734375},{x:.671875,y:.734375},{x:.703125,y:.734375},{x:.703125,y:.734375},{x:.734375,y:.734375},{x:.734375,y:.734375},{x:.765625,y:.734375},{x:.765625,y:.734375},{x:.796875,y:.734375},{x:.796875,y:.734375},{x:.828125,y:.734375},{x:.828125,y:.734375},{x:.859375,y:.734375},{x:.859375,y:.734375},{x:.890625,y:.734375},{x:.890625,y:.734375},{x:.921875,y:.734375},{x:.921875,y:.734375},{x:.953125,y:.734375},{x:.953125,y:.734375},{x:.984375,y:.734375},{x:.984375,y:.734375},{x:.015625,y:.765625},{x:.015625,y:.765625},{x:.046875,y:.765625},{x:.046875,y:.765625},{x:.078125,y:.765625},{x:.078125,y:.765625},{x:.109375,y:.765625},{x:.109375,y:.765625},{x:.140625,y:.765625},{x:.140625,y:.765625},{x:.171875,y:.765625},{x:.171875,y:.765625},{x:.203125,y:.765625},{x:.203125,y:.765625},{x:.234375,y:.765625},{x:.234375,y:.765625},{x:.265625,y:.765625},{x:.265625,y:.765625},{x:.296875,y:.765625},{x:.296875,y:.765625},{x:.328125,y:.765625},{x:.328125,y:.765625},{x:.359375,y:.765625},{x:.359375,y:.765625},{x:.390625,y:.765625},{x:.390625,y:.765625},{x:.421875,y:.765625},{x:.421875,y:.765625},{x:.453125,y:.765625},{x:.453125,y:.765625},{x:.484375,y:.765625},{x:.484375,y:.765625},{x:.515625,y:.765625},{x:.515625,y:.765625},{x:.546875,y:.765625},{x:.546875,y:.765625},{x:.578125,y:.765625},{x:.578125,y:.765625},{x:.609375,y:.765625},{x:.609375,y:.765625},{x:.640625,y:.765625},{x:.640625,y:.765625},{x:.671875,y:.765625},{x:.671875,y:.765625},{x:.703125,y:.765625},{x:.703125,y:.765625},{x:.734375,y:.765625},{x:.734375,y:.765625},{x:.765625,y:.765625},{x:.765625,y:.765625},{x:.796875,y:.765625},{x:.796875,y:.765625},{x:.828125,y:.765625},{x:.828125,y:.765625},{x:.859375,y:.765625},{x:.859375,y:.765625},{x:.890625,y:.765625},{x:.890625,y:.765625},{x:.921875,y:.765625},{x:.921875,y:.765625},{x:.953125,y:.765625},{x:.953125,y:.765625},{x:.984375,y:.765625},{x:.984375,y:.765625},{x:.015625,y:.796875},{x:.015625,y:.796875},{x:.046875,y:.796875},{x:.046875,y:.796875},{x:.078125,y:.796875},{x:.078125,y:.796875},{x:.109375,y:.796875},{x:.109375,y:.796875},{x:.140625,y:.796875},{x:.140625,y:.796875},{x:.171875,y:.796875},{x:.171875,y:.796875},{x:.203125,y:.796875},{x:.203125,y:.796875},{x:.234375,y:.796875},{x:.234375,y:.796875},{x:.265625,y:.796875},{x:.265625,y:.796875},{x:.296875,y:.796875},{x:.296875,y:.796875},{x:.328125,y:.796875},{x:.328125,y:.796875},{x:.359375,y:.796875},{x:.359375,y:.796875},{x:.390625,y:.796875},{x:.390625,y:.796875},{x:.421875,y:.796875},{x:.421875,y:.796875},{x:.453125,y:.796875},{x:.453125,y:.796875},{x:.484375,y:.796875},{x:.484375,y:.796875},{x:.515625,y:.796875},{x:.515625,y:.796875},{x:.546875,y:.796875},{x:.546875,y:.796875},{x:.578125,y:.796875},{x:.578125,y:.796875},{x:.609375,y:.796875},{x:.609375,y:.796875},{x:.640625,y:.796875},{x:.640625,y:.796875},{x:.671875,y:.796875},{x:.671875,y:.796875},{x:.703125,y:.796875},{x:.703125,y:.796875},{x:.734375,y:.796875},{x:.734375,y:.796875},{x:.765625,y:.796875},{x:.765625,y:.796875},{x:.796875,y:.796875},{x:.796875,y:.796875},{x:.828125,y:.796875},{x:.828125,y:.796875},{x:.859375,y:.796875},{x:.859375,y:.796875},{x:.890625,y:.796875},{x:.890625,y:.796875},{x:.921875,y:.796875},{x:.921875,y:.796875},{x:.953125,y:.796875},{x:.953125,y:.796875},{x:.984375,y:.796875},{x:.984375,y:.796875},{x:.015625,y:.828125},{x:.015625,y:.828125},{x:.046875,y:.828125},{x:.046875,y:.828125},{x:.078125,y:.828125},{x:.078125,y:.828125},{x:.109375,y:.828125},{x:.109375,y:.828125},{x:.140625,y:.828125},{x:.140625,y:.828125},{x:.171875,y:.828125},{x:.171875,y:.828125},{x:.203125,y:.828125},{x:.203125,y:.828125},{x:.234375,y:.828125},{x:.234375,y:.828125},{x:.265625,y:.828125},{x:.265625,y:.828125},{x:.296875,y:.828125},{x:.296875,y:.828125},{x:.328125,y:.828125},{x:.328125,y:.828125},{x:.359375,y:.828125},{x:.359375,y:.828125},{x:.390625,y:.828125},{x:.390625,y:.828125},{x:.421875,y:.828125},{x:.421875,y:.828125},{x:.453125,y:.828125},{x:.453125,y:.828125},{x:.484375,y:.828125},{x:.484375,y:.828125},{x:.515625,y:.828125},{x:.515625,y:.828125},{x:.546875,y:.828125},{x:.546875,y:.828125},{x:.578125,y:.828125},{x:.578125,y:.828125},{x:.609375,y:.828125},{x:.609375,y:.828125},{x:.640625,y:.828125},{x:.640625,y:.828125},{x:.671875,y:.828125},{x:.671875,y:.828125},{x:.703125,y:.828125},{x:.703125,y:.828125},{x:.734375,y:.828125},{x:.734375,y:.828125},{x:.765625,y:.828125},{x:.765625,y:.828125},{x:.796875,y:.828125},{x:.796875,y:.828125},{x:.828125,y:.828125},{x:.828125,y:.828125},{x:.859375,y:.828125},{x:.859375,y:.828125},{x:.890625,y:.828125},{x:.890625,y:.828125},{x:.921875,y:.828125},{x:.921875,y:.828125},{x:.953125,y:.828125},{x:.953125,y:.828125},{x:.984375,y:.828125},{x:.984375,y:.828125},{x:.015625,y:.859375},{x:.015625,y:.859375},{x:.046875,y:.859375},{x:.046875,y:.859375},{x:.078125,y:.859375},{x:.078125,y:.859375},{x:.109375,y:.859375},{x:.109375,y:.859375},{x:.140625,y:.859375},{x:.140625,y:.859375},{x:.171875,y:.859375},{x:.171875,y:.859375},{x:.203125,y:.859375},{x:.203125,y:.859375},{x:.234375,y:.859375},{x:.234375,y:.859375},{x:.265625,y:.859375},{x:.265625,y:.859375},{x:.296875,y:.859375},{x:.296875,y:.859375},{x:.328125,y:.859375},{x:.328125,y:.859375},{x:.359375,y:.859375},{x:.359375,y:.859375},{x:.390625,y:.859375},{x:.390625,y:.859375},{x:.421875,y:.859375},{x:.421875,y:.859375},{x:.453125,y:.859375},{x:.453125,y:.859375},{x:.484375,y:.859375},{x:.484375,y:.859375},{x:.515625,y:.859375},{x:.515625,y:.859375},{x:.546875,y:.859375},{x:.546875,y:.859375},{x:.578125,y:.859375},{x:.578125,y:.859375},{x:.609375,y:.859375},{x:.609375,y:.859375},{x:.640625,y:.859375},{x:.640625,y:.859375},{x:.671875,y:.859375},{x:.671875,y:.859375},{x:.703125,y:.859375},{x:.703125,y:.859375},{x:.734375,y:.859375},{x:.734375,y:.859375},{x:.765625,y:.859375},{x:.765625,y:.859375},{x:.796875,y:.859375},{x:.796875,y:.859375},{x:.828125,y:.859375},{x:.828125,y:.859375},{x:.859375,y:.859375},{x:.859375,y:.859375},{x:.890625,y:.859375},{x:.890625,y:.859375},{x:.921875,y:.859375},{x:.921875,y:.859375},{x:.953125,y:.859375},{x:.953125,y:.859375},{x:.984375,y:.859375},{x:.984375,y:.859375},{x:.015625,y:.890625},{x:.015625,y:.890625},{x:.046875,y:.890625},{x:.046875,y:.890625},{x:.078125,y:.890625},{x:.078125,y:.890625},{x:.109375,y:.890625},{x:.109375,y:.890625},{x:.140625,y:.890625},{x:.140625,y:.890625},{x:.171875,y:.890625},{x:.171875,y:.890625},{x:.203125,y:.890625},{x:.203125,y:.890625},{x:.234375,y:.890625},{x:.234375,y:.890625},{x:.265625,y:.890625},{x:.265625,y:.890625},{x:.296875,y:.890625},{x:.296875,y:.890625},{x:.328125,y:.890625},{x:.328125,y:.890625},{x:.359375,y:.890625},{x:.359375,y:.890625},{x:.390625,y:.890625},{x:.390625,y:.890625},{x:.421875,y:.890625},{x:.421875,y:.890625},{x:.453125,y:.890625},{x:.453125,y:.890625},{x:.484375,y:.890625},{x:.484375,y:.890625},{x:.515625,y:.890625},{x:.515625,y:.890625},{x:.546875,y:.890625},{x:.546875,y:.890625},{x:.578125,y:.890625},{x:.578125,y:.890625},{x:.609375,y:.890625},{x:.609375,y:.890625},{x:.640625,y:.890625},{x:.640625,y:.890625},{x:.671875,y:.890625},{x:.671875,y:.890625},{x:.703125,y:.890625},{x:.703125,y:.890625},{x:.734375,y:.890625},{x:.734375,y:.890625},{x:.765625,y:.890625},{x:.765625,y:.890625},{x:.796875,y:.890625},{x:.796875,y:.890625},{x:.828125,y:.890625},{x:.828125,y:.890625},{x:.859375,y:.890625},{x:.859375,y:.890625},{x:.890625,y:.890625},{x:.890625,y:.890625},{x:.921875,y:.890625},{x:.921875,y:.890625},{x:.953125,y:.890625},{x:.953125,y:.890625},{x:.984375,y:.890625},{x:.984375,y:.890625},{x:.015625,y:.921875},{x:.015625,y:.921875},{x:.046875,y:.921875},{x:.046875,y:.921875},{x:.078125,y:.921875},{x:.078125,y:.921875},{x:.109375,y:.921875},{x:.109375,y:.921875},{x:.140625,y:.921875},{x:.140625,y:.921875},{x:.171875,y:.921875},{x:.171875,y:.921875},{x:.203125,y:.921875},{x:.203125,y:.921875},{x:.234375,y:.921875},{x:.234375,y:.921875},{x:.265625,y:.921875},{x:.265625,y:.921875},{x:.296875,y:.921875},{x:.296875,y:.921875},{x:.328125,y:.921875},{x:.328125,y:.921875},{x:.359375,y:.921875},{x:.359375,y:.921875},{x:.390625,y:.921875},{x:.390625,y:.921875},{x:.421875,y:.921875},{x:.421875,y:.921875},{x:.453125,y:.921875},{x:.453125,y:.921875},{x:.484375,y:.921875},{x:.484375,y:.921875},{x:.515625,y:.921875},{x:.515625,y:.921875},{x:.546875,y:.921875},{x:.546875,y:.921875},{x:.578125,y:.921875},{x:.578125,y:.921875},{x:.609375,y:.921875},{x:.609375,y:.921875},{x:.640625,y:.921875},{x:.640625,y:.921875},{x:.671875,y:.921875},{x:.671875,y:.921875},{x:.703125,y:.921875},{x:.703125,y:.921875},{x:.734375,y:.921875},{x:.734375,y:.921875},{x:.765625,y:.921875},{x:.765625,y:.921875},{x:.796875,y:.921875},{x:.796875,y:.921875},{x:.828125,y:.921875},{x:.828125,y:.921875},{x:.859375,y:.921875},{x:.859375,y:.921875},{x:.890625,y:.921875},{x:.890625,y:.921875},{x:.921875,y:.921875},{x:.921875,y:.921875},{x:.953125,y:.921875},{x:.953125,y:.921875},{x:.984375,y:.921875},{x:.984375,y:.921875},{x:.015625,y:.953125},{x:.015625,y:.953125},{x:.046875,y:.953125},{x:.046875,y:.953125},{x:.078125,y:.953125},{x:.078125,y:.953125},{x:.109375,y:.953125},{x:.109375,y:.953125},{x:.140625,y:.953125},{x:.140625,y:.953125},{x:.171875,y:.953125},{x:.171875,y:.953125},{x:.203125,y:.953125},{x:.203125,y:.953125},{x:.234375,y:.953125},{x:.234375,y:.953125},{x:.265625,y:.953125},{x:.265625,y:.953125},{x:.296875,y:.953125},{x:.296875,y:.953125},{x:.328125,y:.953125},{x:.328125,y:.953125},{x:.359375,y:.953125},{x:.359375,y:.953125},{x:.390625,y:.953125},{x:.390625,y:.953125},{x:.421875,y:.953125},{x:.421875,y:.953125},{x:.453125,y:.953125},{x:.453125,y:.953125},{x:.484375,y:.953125},{x:.484375,y:.953125},{x:.515625,y:.953125},{x:.515625,y:.953125},{x:.546875,y:.953125},{x:.546875,y:.953125},{x:.578125,y:.953125},{x:.578125,y:.953125},{x:.609375,y:.953125},{x:.609375,y:.953125},{x:.640625,y:.953125},{x:.640625,y:.953125},{x:.671875,y:.953125},{x:.671875,y:.953125},{x:.703125,y:.953125},{x:.703125,y:.953125},{x:.734375,y:.953125},{x:.734375,y:.953125},{x:.765625,y:.953125},{x:.765625,y:.953125},{x:.796875,y:.953125},{x:.796875,y:.953125},{x:.828125,y:.953125},{x:.828125,y:.953125},{x:.859375,y:.953125},{x:.859375,y:.953125},{x:.890625,y:.953125},{x:.890625,y:.953125},{x:.921875,y:.953125},{x:.921875,y:.953125},{x:.953125,y:.953125},{x:.953125,y:.953125},{x:.984375,y:.953125},{x:.984375,y:.953125},{x:.015625,y:.984375},{x:.015625,y:.984375},{x:.046875,y:.984375},{x:.046875,y:.984375},{x:.078125,y:.984375},{x:.078125,y:.984375},{x:.109375,y:.984375},{x:.109375,y:.984375},{x:.140625,y:.984375},{x:.140625,y:.984375},{x:.171875,y:.984375},{x:.171875,y:.984375},{x:.203125,y:.984375},{x:.203125,y:.984375},{x:.234375,y:.984375},{x:.234375,y:.984375},{x:.265625,y:.984375},{x:.265625,y:.984375},{x:.296875,y:.984375},{x:.296875,y:.984375},{x:.328125,y:.984375},{x:.328125,y:.984375},{x:.359375,y:.984375},{x:.359375,y:.984375},{x:.390625,y:.984375},{x:.390625,y:.984375},{x:.421875,y:.984375},{x:.421875,y:.984375},{x:.453125,y:.984375},{x:.453125,y:.984375},{x:.484375,y:.984375},{x:.484375,y:.984375},{x:.515625,y:.984375},{x:.515625,y:.984375},{x:.546875,y:.984375},{x:.546875,y:.984375},{x:.578125,y:.984375},{x:.578125,y:.984375},{x:.609375,y:.984375},{x:.609375,y:.984375},{x:.640625,y:.984375},{x:.640625,y:.984375},{x:.671875,y:.984375},{x:.671875,y:.984375},{x:.703125,y:.984375},{x:.703125,y:.984375},{x:.734375,y:.984375},{x:.734375,y:.984375},{x:.765625,y:.984375},{x:.765625,y:.984375},{x:.796875,y:.984375},{x:.796875,y:.984375},{x:.828125,y:.984375},{x:.828125,y:.984375},{x:.859375,y:.984375},{x:.859375,y:.984375},{x:.890625,y:.984375},{x:.890625,y:.984375},{x:.921875,y:.984375},{x:.921875,y:.984375},{x:.953125,y:.984375},{x:.953125,y:.984375},{x:.984375,y:.984375},{x:.984375,y:.984375},{x:.03125,y:.03125},{x:.03125,y:.03125},{x:.09375,y:.03125},{x:.09375,y:.03125},{x:.15625,y:.03125},{x:.15625,y:.03125},{x:.21875,y:.03125},{x:.21875,y:.03125},{x:.28125,y:.03125},{x:.28125,y:.03125},{x:.34375,y:.03125},{x:.34375,y:.03125},{x:.40625,y:.03125},{x:.40625,y:.03125},{x:.46875,y:.03125},{x:.46875,y:.03125},{x:.53125,y:.03125},{x:.53125,y:.03125},{x:.59375,y:.03125},{x:.59375,y:.03125},{x:.65625,y:.03125},{x:.65625,y:.03125},{x:.71875,y:.03125},{x:.71875,y:.03125},{x:.78125,y:.03125},{x:.78125,y:.03125},{x:.84375,y:.03125},{x:.84375,y:.03125},{x:.90625,y:.03125},{x:.90625,y:.03125},{x:.96875,y:.03125},{x:.96875,y:.03125},{x:.03125,y:.09375},{x:.03125,y:.09375},{x:.09375,y:.09375},{x:.09375,y:.09375},{x:.15625,y:.09375},{x:.15625,y:.09375},{x:.21875,y:.09375},{x:.21875,y:.09375},{x:.28125,y:.09375},{x:.28125,y:.09375},{x:.34375,y:.09375},{x:.34375,y:.09375},{x:.40625,y:.09375},{x:.40625,y:.09375},{x:.46875,y:.09375},{x:.46875,y:.09375},{x:.53125,y:.09375},{x:.53125,y:.09375},{x:.59375,y:.09375},{x:.59375,y:.09375},{x:.65625,y:.09375},{x:.65625,y:.09375},{x:.71875,y:.09375},{x:.71875,y:.09375},{x:.78125,y:.09375},{x:.78125,y:.09375},{x:.84375,y:.09375},{x:.84375,y:.09375},{x:.90625,y:.09375},{x:.90625,y:.09375},{x:.96875,y:.09375},{x:.96875,y:.09375},{x:.03125,y:.15625},{x:.03125,y:.15625},{x:.09375,y:.15625},{x:.09375,y:.15625},{x:.15625,y:.15625},{x:.15625,y:.15625},{x:.21875,y:.15625},{x:.21875,y:.15625},{x:.28125,y:.15625},{x:.28125,y:.15625},{x:.34375,y:.15625},{x:.34375,y:.15625},{x:.40625,y:.15625},{x:.40625,y:.15625},{x:.46875,y:.15625},{x:.46875,y:.15625},{x:.53125,y:.15625},{x:.53125,y:.15625},{x:.59375,y:.15625},{x:.59375,y:.15625},{x:.65625,y:.15625},{x:.65625,y:.15625},{x:.71875,y:.15625},{x:.71875,y:.15625},{x:.78125,y:.15625},{x:.78125,y:.15625},{x:.84375,y:.15625},{x:.84375,y:.15625},{x:.90625,y:.15625},{x:.90625,y:.15625},{x:.96875,y:.15625},{x:.96875,y:.15625},{x:.03125,y:.21875},{x:.03125,y:.21875},{x:.09375,y:.21875},{x:.09375,y:.21875},{x:.15625,y:.21875},{x:.15625,y:.21875},{x:.21875,y:.21875},{x:.21875,y:.21875},{x:.28125,y:.21875},{x:.28125,y:.21875},{x:.34375,y:.21875},{x:.34375,y:.21875},{x:.40625,y:.21875},{x:.40625,y:.21875},{x:.46875,y:.21875},{x:.46875,y:.21875},{x:.53125,y:.21875},{x:.53125,y:.21875},{x:.59375,y:.21875},{x:.59375,y:.21875},{x:.65625,y:.21875},{x:.65625,y:.21875},{x:.71875,y:.21875},{x:.71875,y:.21875},{x:.78125,y:.21875},{x:.78125,y:.21875},{x:.84375,y:.21875},{x:.84375,y:.21875},{x:.90625,y:.21875},{x:.90625,y:.21875},{x:.96875,y:.21875},{x:.96875,y:.21875},{x:.03125,y:.28125},{x:.03125,y:.28125},{x:.09375,y:.28125},{x:.09375,y:.28125},{x:.15625,y:.28125},{x:.15625,y:.28125},{x:.21875,y:.28125},{x:.21875,y:.28125},{x:.28125,y:.28125},{x:.28125,y:.28125},{x:.34375,y:.28125},{x:.34375,y:.28125},{x:.40625,y:.28125},{x:.40625,y:.28125},{x:.46875,y:.28125},{x:.46875,y:.28125},{x:.53125,y:.28125},{x:.53125,y:.28125},{x:.59375,y:.28125},{x:.59375,y:.28125},{x:.65625,y:.28125},{x:.65625,y:.28125},{x:.71875,y:.28125},{x:.71875,y:.28125},{x:.78125,y:.28125},{x:.78125,y:.28125},{x:.84375,y:.28125},{x:.84375,y:.28125},{x:.90625,y:.28125},{x:.90625,y:.28125},{x:.96875,y:.28125},{x:.96875,y:.28125},{x:.03125,y:.34375},{x:.03125,y:.34375},{x:.09375,y:.34375},{x:.09375,y:.34375},{x:.15625,y:.34375},{x:.15625,y:.34375},{x:.21875,y:.34375},{x:.21875,y:.34375},{x:.28125,y:.34375},{x:.28125,y:.34375},{x:.34375,y:.34375},{x:.34375,y:.34375},{x:.40625,y:.34375},{x:.40625,y:.34375},{x:.46875,y:.34375},{x:.46875,y:.34375},{x:.53125,y:.34375},{x:.53125,y:.34375},{x:.59375,y:.34375},{x:.59375,y:.34375},{x:.65625,y:.34375},{x:.65625,y:.34375},{x:.71875,y:.34375},{x:.71875,y:.34375},{x:.78125,y:.34375},{x:.78125,y:.34375},{x:.84375,y:.34375},{x:.84375,y:.34375},{x:.90625,y:.34375},{x:.90625,y:.34375},{x:.96875,y:.34375},{x:.96875,y:.34375},{x:.03125,y:.40625},{x:.03125,y:.40625},{x:.09375,y:.40625},{x:.09375,y:.40625},{x:.15625,y:.40625},{x:.15625,y:.40625},{x:.21875,y:.40625},{x:.21875,y:.40625},{x:.28125,y:.40625},{x:.28125,y:.40625},{x:.34375,y:.40625},{x:.34375,y:.40625},{x:.40625,y:.40625},{x:.40625,y:.40625},{x:.46875,y:.40625},{x:.46875,y:.40625},{x:.53125,y:.40625},{x:.53125,y:.40625},{x:.59375,y:.40625},{x:.59375,y:.40625},{x:.65625,y:.40625},{x:.65625,y:.40625},{x:.71875,y:.40625},{x:.71875,y:.40625},{x:.78125,y:.40625},{x:.78125,y:.40625},{x:.84375,y:.40625},{x:.84375,y:.40625},{x:.90625,y:.40625},{x:.90625,y:.40625},{x:.96875,y:.40625},{x:.96875,y:.40625},{x:.03125,y:.46875},{x:.03125,y:.46875},{x:.09375,y:.46875},{x:.09375,y:.46875},{x:.15625,y:.46875},{x:.15625,y:.46875},{x:.21875,y:.46875},{x:.21875,y:.46875},{x:.28125,y:.46875},{x:.28125,y:.46875},{x:.34375,y:.46875},{x:.34375,y:.46875},{x:.40625,y:.46875},{x:.40625,y:.46875},{x:.46875,y:.46875},{x:.46875,y:.46875},{x:.53125,y:.46875},{x:.53125,y:.46875},{x:.59375,y:.46875},{x:.59375,y:.46875},{x:.65625,y:.46875},{x:.65625,y:.46875},{x:.71875,y:.46875},{x:.71875,y:.46875},{x:.78125,y:.46875},{x:.78125,y:.46875},{x:.84375,y:.46875},{x:.84375,y:.46875},{x:.90625,y:.46875},{x:.90625,y:.46875},{x:.96875,y:.46875},{x:.96875,y:.46875},{x:.03125,y:.53125},{x:.03125,y:.53125},{x:.09375,y:.53125},{x:.09375,y:.53125},{x:.15625,y:.53125},{x:.15625,y:.53125},{x:.21875,y:.53125},{x:.21875,y:.53125},{x:.28125,y:.53125},{x:.28125,y:.53125},{x:.34375,y:.53125},{x:.34375,y:.53125},{x:.40625,y:.53125},{x:.40625,y:.53125},{x:.46875,y:.53125},{x:.46875,y:.53125},{x:.53125,y:.53125},{x:.53125,y:.53125},{x:.59375,y:.53125},{x:.59375,y:.53125},{x:.65625,y:.53125},{x:.65625,y:.53125},{x:.71875,y:.53125},{x:.71875,y:.53125},{x:.78125,y:.53125},{x:.78125,y:.53125},{x:.84375,y:.53125},{x:.84375,y:.53125},{x:.90625,y:.53125},{x:.90625,y:.53125},{x:.96875,y:.53125},{x:.96875,y:.53125},{x:.03125,y:.59375},{x:.03125,y:.59375},{x:.09375,y:.59375},{x:.09375,y:.59375},{x:.15625,y:.59375},{x:.15625,y:.59375},{x:.21875,y:.59375},{x:.21875,y:.59375},{x:.28125,y:.59375},{x:.28125,y:.59375},{x:.34375,y:.59375},{x:.34375,y:.59375},{x:.40625,y:.59375},{x:.40625,y:.59375},{x:.46875,y:.59375},{x:.46875,y:.59375},{x:.53125,y:.59375},{x:.53125,y:.59375},{x:.59375,y:.59375},{x:.59375,y:.59375},{x:.65625,y:.59375},{x:.65625,y:.59375},{x:.71875,y:.59375},{x:.71875,y:.59375},{x:.78125,y:.59375},{x:.78125,y:.59375},{x:.84375,y:.59375},{x:.84375,y:.59375},{x:.90625,y:.59375},{x:.90625,y:.59375},{x:.96875,y:.59375},{x:.96875,y:.59375},{x:.03125,y:.65625},{x:.03125,y:.65625},{x:.09375,y:.65625},{x:.09375,y:.65625},{x:.15625,y:.65625},{x:.15625,y:.65625},{x:.21875,y:.65625},{x:.21875,y:.65625},{x:.28125,y:.65625},{x:.28125,y:.65625},{x:.34375,y:.65625},{x:.34375,y:.65625},{x:.40625,y:.65625},{x:.40625,y:.65625},{x:.46875,y:.65625},{x:.46875,y:.65625},{x:.53125,y:.65625},{x:.53125,y:.65625},{x:.59375,y:.65625},{x:.59375,y:.65625},{x:.65625,y:.65625},{x:.65625,y:.65625},{x:.71875,y:.65625},{x:.71875,y:.65625},{x:.78125,y:.65625},{x:.78125,y:.65625},{x:.84375,y:.65625},{x:.84375,y:.65625},{x:.90625,y:.65625},{x:.90625,y:.65625},{x:.96875,y:.65625},{x:.96875,y:.65625},{x:.03125,y:.71875},{x:.03125,y:.71875},{x:.09375,y:.71875},{x:.09375,y:.71875},{x:.15625,y:.71875},{x:.15625,y:.71875},{x:.21875,y:.71875},{x:.21875,y:.71875},{x:.28125,y:.71875},{x:.28125,y:.71875},{x:.34375,y:.71875},{x:.34375,y:.71875},{x:.40625,y:.71875},{x:.40625,y:.71875},{x:.46875,y:.71875},{x:.46875,y:.71875},{x:.53125,y:.71875},{x:.53125,y:.71875},{x:.59375,y:.71875},{x:.59375,y:.71875},{x:.65625,y:.71875},{x:.65625,y:.71875},{x:.71875,y:.71875},{x:.71875,y:.71875},{x:.78125,y:.71875},{x:.78125,y:.71875},{x:.84375,y:.71875},{x:.84375,y:.71875},{x:.90625,y:.71875},{x:.90625,y:.71875},{x:.96875,y:.71875},{x:.96875,y:.71875},{x:.03125,y:.78125},{x:.03125,y:.78125},{x:.09375,y:.78125},{x:.09375,y:.78125},{x:.15625,y:.78125},{x:.15625,y:.78125},{x:.21875,y:.78125},{x:.21875,y:.78125},{x:.28125,y:.78125},{x:.28125,y:.78125},{x:.34375,y:.78125},{x:.34375,y:.78125},{x:.40625,y:.78125},{x:.40625,y:.78125},{x:.46875,y:.78125},{x:.46875,y:.78125},{x:.53125,y:.78125},{x:.53125,y:.78125},{x:.59375,y:.78125},{x:.59375,y:.78125},{x:.65625,y:.78125},{x:.65625,y:.78125},{x:.71875,y:.78125},{x:.71875,y:.78125},{x:.78125,y:.78125},{x:.78125,y:.78125},{x:.84375,y:.78125},{x:.84375,y:.78125},{x:.90625,y:.78125},{x:.90625,y:.78125},{x:.96875,y:.78125},{x:.96875,y:.78125},{x:.03125,y:.84375},{x:.03125,y:.84375},{x:.09375,y:.84375},{x:.09375,y:.84375},{x:.15625,y:.84375},{x:.15625,y:.84375},{x:.21875,y:.84375},{x:.21875,y:.84375},{x:.28125,y:.84375},{x:.28125,y:.84375},{x:.34375,y:.84375},{x:.34375,y:.84375},{x:.40625,y:.84375},{x:.40625,y:.84375},{x:.46875,y:.84375},{x:.46875,y:.84375},{x:.53125,y:.84375},{x:.53125,y:.84375},{x:.59375,y:.84375},{x:.59375,y:.84375},{x:.65625,y:.84375},{x:.65625,y:.84375},{x:.71875,y:.84375},{x:.71875,y:.84375},{x:.78125,y:.84375},{x:.78125,y:.84375},{x:.84375,y:.84375},{x:.84375,y:.84375},{x:.90625,y:.84375},{x:.90625,y:.84375},{x:.96875,y:.84375},{x:.96875,y:.84375},{x:.03125,y:.90625},{x:.03125,y:.90625},{x:.09375,y:.90625},{x:.09375,y:.90625},{x:.15625,y:.90625},{x:.15625,y:.90625},{x:.21875,y:.90625},{x:.21875,y:.90625},{x:.28125,y:.90625},{x:.28125,y:.90625},{x:.34375,y:.90625},{x:.34375,y:.90625},{x:.40625,y:.90625},{x:.40625,y:.90625},{x:.46875,y:.90625},{x:.46875,y:.90625},{x:.53125,y:.90625},{x:.53125,y:.90625},{x:.59375,y:.90625},{x:.59375,y:.90625},{x:.65625,y:.90625},{x:.65625,y:.90625},{x:.71875,y:.90625},{x:.71875,y:.90625},{x:.78125,y:.90625},{x:.78125,y:.90625},{x:.84375,y:.90625},{x:.84375,y:.90625},{x:.90625,y:.90625},{x:.90625,y:.90625},{x:.96875,y:.90625},{x:.96875,y:.90625},{x:.03125,y:.96875},{x:.03125,y:.96875},{x:.09375,y:.96875},{x:.09375,y:.96875},{x:.15625,y:.96875},{x:.15625,y:.96875},{x:.21875,y:.96875},{x:.21875,y:.96875},{x:.28125,y:.96875},{x:.28125,y:.96875},{x:.34375,y:.96875},{x:.34375,y:.96875},{x:.40625,y:.96875},{x:.40625,y:.96875},{x:.46875,y:.96875},{x:.46875,y:.96875},{x:.53125,y:.96875},{x:.53125,y:.96875},{x:.59375,y:.96875},{x:.59375,y:.96875},{x:.65625,y:.96875},{x:.65625,y:.96875},{x:.71875,y:.96875},{x:.71875,y:.96875},{x:.78125,y:.96875},{x:.78125,y:.96875},{x:.84375,y:.96875},{x:.84375,y:.96875},{x:.90625,y:.96875},{x:.90625,y:.96875},{x:.96875,y:.96875},{x:.96875,y:.96875},{x:.0625,y:.0625},{x:.0625,y:.0625},{x:.0625,y:.0625},{x:.0625,y:.0625},{x:.0625,y:.0625},{x:.0625,y:.0625},{x:.1875,y:.0625},{x:.1875,y:.0625},{x:.1875,y:.0625},{x:.1875,y:.0625},{x:.1875,y:.0625},{x:.1875,y:.0625},{x:.3125,y:.0625},{x:.3125,y:.0625},{x:.3125,y:.0625},{x:.3125,y:.0625},{x:.3125,y:.0625},{x:.3125,y:.0625},{x:.4375,y:.0625},{x:.4375,y:.0625},{x:.4375,y:.0625},{x:.4375,y:.0625},{x:.4375,y:.0625},{x:.4375,y:.0625},{x:.5625,y:.0625},{x:.5625,y:.0625},{x:.5625,y:.0625},{x:.5625,y:.0625},{x:.5625,y:.0625},{x:.5625,y:.0625},{x:.6875,y:.0625},{x:.6875,y:.0625},{x:.6875,y:.0625},{x:.6875,y:.0625},{x:.6875,y:.0625},{x:.6875,y:.0625},{x:.8125,y:.0625},{x:.8125,y:.0625},{x:.8125,y:.0625},{x:.8125,y:.0625},{x:.8125,y:.0625},{x:.8125,y:.0625},{x:.9375,y:.0625},{x:.9375,y:.0625},{x:.9375,y:.0625},{x:.9375,y:.0625},{x:.9375,y:.0625},{x:.9375,y:.0625},{x:.0625,y:.1875},{x:.0625,y:.1875},{x:.0625,y:.1875},{x:.0625,y:.1875},{x:.0625,y:.1875},{x:.0625,y:.1875},{x:.1875,y:.1875},{x:.1875,y:.1875},{x:.1875,y:.1875},{x:.1875,y:.1875},{x:.1875,y:.1875},{x:.1875,y:.1875},{x:.3125,y:.1875},{x:.3125,y:.1875},{x:.3125,y:.1875},{x:.3125,y:.1875},{x:.3125,y:.1875},{x:.3125,y:.1875},{x:.4375,y:.1875},{x:.4375,y:.1875},{x:.4375,y:.1875},{x:.4375,y:.1875},{x:.4375,y:.1875},{x:.4375,y:.1875},{x:.5625,y:.1875},{x:.5625,y:.1875},{x:.5625,y:.1875},{x:.5625,y:.1875},{x:.5625,y:.1875},{x:.5625,y:.1875},{x:.6875,y:.1875},{x:.6875,y:.1875},{x:.6875,y:.1875},{x:.6875,y:.1875},{x:.6875,y:.1875},{x:.6875,y:.1875},{x:.8125,y:.1875},{x:.8125,y:.1875},{x:.8125,y:.1875},{x:.8125,y:.1875},{x:.8125,y:.1875},{x:.8125,y:.1875},{x:.9375,y:.1875},{x:.9375,y:.1875},{x:.9375,y:.1875},{x:.9375,y:.1875},{x:.9375,y:.1875},{x:.9375,y:.1875},{x:.0625,y:.3125},{x:.0625,y:.3125},{x:.0625,y:.3125},{x:.0625,y:.3125},{x:.0625,y:.3125},{x:.0625,y:.3125},{x:.1875,y:.3125},{x:.1875,y:.3125},{x:.1875,y:.3125},{x:.1875,y:.3125},{x:.1875,y:.3125},{x:.1875,y:.3125},{x:.3125,y:.3125},{x:.3125,y:.3125},{x:.3125,y:.3125},{x:.3125,y:.3125},{x:.3125,y:.3125},{x:.3125,y:.3125},{x:.4375,y:.3125},{x:.4375,y:.3125},{x:.4375,y:.3125},{x:.4375,y:.3125},{x:.4375,y:.3125},{x:.4375,y:.3125},{x:.5625,y:.3125},{x:.5625,y:.3125},{x:.5625,y:.3125},{x:.5625,y:.3125},{x:.5625,y:.3125},{x:.5625,y:.3125},{x:.6875,y:.3125},{x:.6875,y:.3125},{x:.6875,y:.3125},{x:.6875,y:.3125},{x:.6875,y:.3125},{x:.6875,y:.3125},{x:.8125,y:.3125},{x:.8125,y:.3125},{x:.8125,y:.3125},{x:.8125,y:.3125},{x:.8125,y:.3125},{x:.8125,y:.3125},{x:.9375,y:.3125},{x:.9375,y:.3125},{x:.9375,y:.3125},{x:.9375,y:.3125},{x:.9375,y:.3125},{x:.9375,y:.3125},{x:.0625,y:.4375},{x:.0625,y:.4375},{x:.0625,y:.4375},{x:.0625,y:.4375},{x:.0625,y:.4375},{x:.0625,y:.4375},{x:.1875,y:.4375},{x:.1875,y:.4375},{x:.1875,y:.4375},{x:.1875,y:.4375},{x:.1875,y:.4375},{x:.1875,y:.4375},{x:.3125,y:.4375},{x:.3125,y:.4375},{x:.3125,y:.4375},{x:.3125,y:.4375},{x:.3125,y:.4375},{x:.3125,y:.4375},{x:.4375,y:.4375},{x:.4375,y:.4375},{x:.4375,y:.4375},{x:.4375,y:.4375},{x:.4375,y:.4375},{x:.4375,y:.4375},{x:.5625,y:.4375},{x:.5625,y:.4375},{x:.5625,y:.4375},{x:.5625,y:.4375},{x:.5625,y:.4375},{x:.5625,y:.4375},{x:.6875,y:.4375},{x:.6875,y:.4375},{x:.6875,y:.4375},{x:.6875,y:.4375},{x:.6875,y:.4375},{x:.6875,y:.4375},{x:.8125,y:.4375},{x:.8125,y:.4375},{x:.8125,y:.4375},{x:.8125,y:.4375},{x:.8125,y:.4375},{x:.8125,y:.4375},{x:.9375,y:.4375},{x:.9375,y:.4375},{x:.9375,y:.4375},{x:.9375,y:.4375},{x:.9375,y:.4375},{x:.9375,y:.4375},{x:.0625,y:.5625},{x:.0625,y:.5625},{x:.0625,y:.5625},{x:.0625,y:.5625},{x:.0625,y:.5625},{x:.0625,y:.5625},{x:.1875,y:.5625},{x:.1875,y:.5625},{x:.1875,y:.5625},{x:.1875,y:.5625},{x:.1875,y:.5625},{x:.1875,y:.5625},{x:.3125,y:.5625},{x:.3125,y:.5625},{x:.3125,y:.5625},{x:.3125,y:.5625},{x:.3125,y:.5625},{x:.3125,y:.5625},{x:.4375,y:.5625},{x:.4375,y:.5625},{x:.4375,y:.5625},{x:.4375,y:.5625},{x:.4375,y:.5625},{x:.4375,y:.5625},{x:.5625,y:.5625},{x:.5625,y:.5625},{x:.5625,y:.5625},{x:.5625,y:.5625},{x:.5625,y:.5625},{x:.5625,y:.5625},{x:.6875,y:.5625},{x:.6875,y:.5625},{x:.6875,y:.5625},{x:.6875,y:.5625},{x:.6875,y:.5625},{x:.6875,y:.5625},{x:.8125,y:.5625},{x:.8125,y:.5625},{x:.8125,y:.5625},{x:.8125,y:.5625},{x:.8125,y:.5625},{x:.8125,y:.5625},{x:.9375,y:.5625},{x:.9375,y:.5625},{x:.9375,y:.5625},{x:.9375,y:.5625},{x:.9375,y:.5625},{x:.9375,y:.5625},{x:.0625,y:.6875},{x:.0625,y:.6875},{x:.0625,y:.6875},{x:.0625,y:.6875},{x:.0625,y:.6875},{x:.0625,y:.6875},{x:.1875,y:.6875},{x:.1875,y:.6875},{x:.1875,y:.6875},{x:.1875,y:.6875},{x:.1875,y:.6875},{x:.1875,y:.6875},{x:.3125,y:.6875},{x:.3125,y:.6875},{x:.3125,y:.6875},{x:.3125,y:.6875},{x:.3125,y:.6875},{x:.3125,y:.6875},{x:.4375,y:.6875},{x:.4375,y:.6875},{x:.4375,y:.6875},{x:.4375,y:.6875},{x:.4375,y:.6875},{x:.4375,y:.6875},{x:.5625,y:.6875},{x:.5625,y:.6875},{x:.5625,y:.6875},{x:.5625,y:.6875},{x:.5625,y:.6875},{x:.5625,y:.6875},{x:.6875,y:.6875},{x:.6875,y:.6875},{x:.6875,y:.6875},{x:.6875,y:.6875},{x:.6875,y:.6875},{x:.6875,y:.6875},{x:.8125,y:.6875},{x:.8125,y:.6875},{x:.8125,y:.6875},{x:.8125,y:.6875},{x:.8125,y:.6875},{x:.8125,y:.6875},{x:.9375,y:.6875},{x:.9375,y:.6875},{x:.9375,y:.6875},{x:.9375,y:.6875},{x:.9375,y:.6875},{x:.9375,y:.6875},{x:.0625,y:.8125},{x:.0625,y:.8125},{x:.0625,y:.8125},{x:.0625,y:.8125},{x:.0625,y:.8125},{x:.0625,y:.8125},{x:.1875,y:.8125},{x:.1875,y:.8125},{x:.1875,y:.8125},{x:.1875,y:.8125},{x:.1875,y:.8125},{x:.1875,y:.8125},{x:.3125,y:.8125},{x:.3125,y:.8125},{x:.3125,y:.8125},{x:.3125,y:.8125},{x:.3125,y:.8125},{x:.3125,y:.8125},{x:.4375,y:.8125},{x:.4375,y:.8125},{x:.4375,y:.8125},{x:.4375,y:.8125},{x:.4375,y:.8125},{x:.4375,y:.8125},{x:.5625,y:.8125},{x:.5625,y:.8125},{x:.5625,y:.8125},{x:.5625,y:.8125},{x:.5625,y:.8125},{x:.5625,y:.8125},{x:.6875,y:.8125},{x:.6875,y:.8125},{x:.6875,y:.8125},{x:.6875,y:.8125},{x:.6875,y:.8125},{x:.6875,y:.8125},{x:.8125,y:.8125},{x:.8125,y:.8125},{x:.8125,y:.8125},{x:.8125,y:.8125},{x:.8125,y:.8125},{x:.8125,y:.8125},{x:.9375,y:.8125},{x:.9375,y:.8125},{x:.9375,y:.8125},{x:.9375,y:.8125},{x:.9375,y:.8125},{x:.9375,y:.8125},{x:.0625,y:.9375},{x:.0625,y:.9375},{x:.0625,y:.9375},{x:.0625,y:.9375},{x:.0625,y:.9375},{x:.0625,y:.9375},{x:.1875,y:.9375},{x:.1875,y:.9375},{x:.1875,y:.9375},{x:.1875,y:.9375},{x:.1875,y:.9375},{x:.1875,y:.9375},{x:.3125,y:.9375},{x:.3125,y:.9375},{x:.3125,y:.9375},{x:.3125,y:.9375},{x:.3125,y:.9375},{x:.3125,y:.9375},{x:.4375,y:.9375},{x:.4375,y:.9375},{x:.4375,y:.9375},{x:.4375,y:.9375},{x:.4375,y:.9375},{x:.4375,y:.9375},{x:.5625,y:.9375},{x:.5625,y:.9375},{x:.5625,y:.9375},{x:.5625,y:.9375},{x:.5625,y:.9375},{x:.5625,y:.9375},{x:.6875,y:.9375},{x:.6875,y:.9375},{x:.6875,y:.9375},{x:.6875,y:.9375},{x:.6875,y:.9375},{x:.6875,y:.9375},{x:.8125,y:.9375},{x:.8125,y:.9375},{x:.8125,y:.9375},{x:.8125,y:.9375},{x:.8125,y:.9375},{x:.8125,y:.9375},{x:.9375,y:.9375},{x:.9375,y:.9375},{x:.9375,y:.9375},{x:.9375,y:.9375},{x:.9375,y:.9375},{x:.9375,y:.9375}];var ex=class{constructor(t){Re(this,"model");Re(this,"anchors");Re(this,"anchorsTensor");Re(this,"inputSize");Re(this,"inputSizeTensor");Re(this,"doubleInputSizeTensor");this.model=t,this.anchors=M8.map(n=>[n.x,n.y]),this.anchorsTensor=Us(this.anchors),this.inputSize=this.model&&this.model.inputs&&this.model.inputs[0].shape?this.model.inputs[0].shape[2]:0,this.inputSizeTensor=Ut([this.inputSize,this.inputSize]),this.doubleInputSizeTensor=Ut([this.inputSize*2,this.inputSize*2])}normalizeBoxes(t){return H(()=>{let n=_e(t,[0,0],[-1,2]),s=_e(t,[0,2],[-1,2]),r=oe(he(n,this.inputSizeTensor),this.anchorsTensor),a=he(s,this.doubleInputSizeTensor),o=z(ye(r,a),this.inputSizeTensor),i=z(oe(r,a),this.inputSizeTensor);return Gl([o,i],1)})}normalizeLandmarks(t,n){return H(()=>{let s=oe(he(V(t,[-1,7,2]),this.inputSizeTensor),this.anchors[n]);return z(s,this.inputSizeTensor)})}async getBoxes(t,n){let s={};s.batched=this.model.predict(t),s.predictions=lt(s.batched),s.scores=H(()=>lt(Bn(_e(s.predictions,[0,0],[-1,1]))));let r=await s.scores.data();s.boxes=_e(s.predictions,[0,1],[-1,4]),s.norm=this.normalizeBoxes(s.boxes),s.nms=await $e.nonMaxSuppressionAsync(s.norm,s.scores,3*n.hand.maxDetected,n.hand.iouThreshold,n.hand.minConfidence);let a=await s.nms.array(),o=[];for(let i of a){let l=_e(s.norm,[i,0],[1,-1]),u=H(()=>V(this.normalizeLandmarks(_e(s.predictions,[i,5],[1,14]),i),[-1,2]));o.push({box:l,palmLandmarks:u,confidence:r[i]})}for(let i of Object.keys(s))Z(s[i]);return o}async estimateHandBounds(t,n){let s=t.shape[1],r=t.shape[2],a=H(()=>ye(he($e.resizeBilinear(t,[this.inputSize,this.inputSize]),127.5),1)),o=await this.getBoxes(a,n);Z(a);let i=[];if(!o||o.length===0)return i;for(let l of o){let u=await l.box.data(),c=u.slice(0,2),d=u.slice(2,4),p=await l.palmLandmarks.array();Z(l.box),Z(l.palmLandmarks),i.push(P8({startPoint:c,endPoint:d,palmLandmarks:p,confidence:l.confidence},[r/this.inputSize,s/this.inputSize]))}return i}};function mle(e){return e-2*Math.PI*Math.floor((e+Math.PI)/(2*Math.PI))}function z8(e,t){let n=Math.PI/2-Math.atan2(-(t[1]-e[1]),t[0]-e[0]);return mle(n)}var L8=(e,t)=>[[1,0,e],[0,1,t],[0,0,1]];function Ca(e,t){let n=0;for(let s=0;s<e.length;s++)n+=e[s]*t[s];return n}function gle(e,t){let n=[];for(let s=0;s<e.length;s++)n.push(e[s][t]);return n}function B8(e,t){let n=[],s=e.length;for(let r=0;r<s;r++){n.push([]);for(let a=0;a<s;a++)n[r].push(Ca(e[r],gle(t,a)))}return n}function tx(e,t){let n=Math.cos(e),s=Math.sin(e),r=[[n,-s,0],[s,n,0],[0,0,1]],a=L8(t[0],t[1]),o=B8(a,r),i=L8(-t[0],-t[1]);return B8(o,i)}function W8(e){let t=[[e[0][0],e[1][0]],[e[0][1],e[1][1]]],n=[e[0][2],e[1][2]],s=[-Ca(t[0],n),-Ca(t[1],n)];return[t[0].concat(s[0]),t[1].concat(s[1]),[0,0,1]]}function nx(e,t){return[Ca(e,t[0]),Ca(e,t[1])]}var Ale=5,V8=1.65,U8=[0,5,9,13,17,1,2],yle=0,xle=2,sx=class{constructor(t,n){Re(this,"handDetector");Re(this,"handPoseModel");Re(this,"inputSize");Re(this,"storedBoxes");Re(this,"skipped");Re(this,"detectedHands");this.handDetector=t,this.handPoseModel=n,this.inputSize=this.handPoseModel&&this.handPoseModel.inputs[0].shape?this.handPoseModel.inputs[0].shape[2]:0,this.storedBoxes=[],this.skipped=0,this.detectedHands=0}calculateLandmarksBoundingBox(t){let n=t.map(o=>o[0]),s=t.map(o=>o[1]),r=[Math.min(...n),Math.min(...s)],a=[Math.max(...n),Math.max(...s)];return{startPoint:r,endPoint:a}}getBoxForPalmLandmarks(t,n){let s=t.map(a=>nx([...a,1],n)),r=this.calculateLandmarksBoundingBox(s);return x0(b0(r),Ale)}getBoxForHandLandmarks(t){let n=this.calculateLandmarksBoundingBox(t),s=x0(b0(n),V8);s.palmLandmarks=[];for(let r=0;r<U8.length;r++)s.palmLandmarks.push(t[U8[r]].slice(0,2));return s}transformRawCoords(t,n,s,r){let a=y0(n),o=[a[0]/this.inputSize,a[1]/this.inputSize,(a[0]+a[1])/this.inputSize/2],i=t.map(h=>[o[0]*(h[0]-this.inputSize/2),o[1]*(h[1]-this.inputSize/2),o[2]*h[2]]),l=tx(s,[0,0]),u=i.map(h=>[...nx(h,l),h[2]]),c=W8(r),d=[...$d(n),1],p=[Ca(d,c[0]),Ca(d,c[1])];return u.map(h=>[Math.trunc(h[0]+p[0]),Math.trunc(h[1]+p[1]),Math.trunc(h[2])])}async estimateHands(t,n){let s=!1,r;(this.skipped===0||this.skipped>n.hand.skipFrames||!n.hand.landmarks||!n.skipFrame)&&(r=await this.handDetector.estimateHandBounds(t,n),this.skipped=0),n.skipFrame&&this.skipped++,r&&r.length>0&&(r.length!==this.detectedHands&&this.detectedHands!==n.hand.maxDetected||!n.hand.landmarks)&&(this.detectedHands=0,this.storedBoxes=[...r],this.storedBoxes.length>0&&(s=!0));let a=[];for(let o=0;o<this.storedBoxes.length;o++){let i=this.storedBoxes[o];if(!!i)if(n.hand.landmarks){let l=n.hand.rotation?z8(i.palmLandmarks[yle],i.palmLandmarks[xle]):0,u=$d(i),c=[u[0]/t.shape[2],u[1]/t.shape[1]],d=n.hand.rotation&&de.kernels.includes("rotatewithoffset")?$e.rotateWithOffset(t,l,0,c):t.clone(),p=tx(-l,u),h=s?this.getBoxForPalmLandmarks(i.palmLandmarks,p):i,f=O8(h,d,[this.inputSize,this.inputSize]),m=he(f,255);Z(f),Z(d);let[g,A]=await this.handPoseModel.predict(m);Z(m);let y=(await g.data())[0];if(Z(g),y>=n.hand.minConfidence/4){let x=V(A,[-1,3]),b=await x.array();Z(A),Z(x);let v=this.transformRawCoords(b,h,l,p),k=this.getBoxForHandLandmarks(v);this.storedBoxes[o]={...k,confidence:y};let S={landmarks:v,confidence:y,box:{topLeft:k.startPoint,bottomRight:k.endPoint}};a.push(S)}else this.storedBoxes[o]=null;Z(A)}else{let l=x0(b0(i),V8),u={confidence:i.confidence,box:{topLeft:l.startPoint,bottomRight:l.endPoint},landmarks:[]};a.push(u)}}return this.storedBoxes=this.storedBoxes.filter(o=>o!==null),this.detectedHands=a.length,a.length>n.hand.maxDetected&&(a.length=n.hand.maxDetected),a}};var qe={thumb:0,index:1,middle:2,ring:3,pinky:4,all:[0,1,2,3,4],nameMapping:{0:"thumb",1:"index",2:"middle",3:"ring",4:"pinky"},pointsMapping:{0:[[0,1],[1,2],[2,3],[3,4]],1:[[0,5],[5,6],[6,7],[7,8]],2:[[0,9],[9,10],[10,11],[11,12]],3:[[0,13],[13,14],[14,15],[15,16]],4:[[0,17],[17,18],[18,19],[19,20]]},getName:e=>qe.nameMapping[e],getPoints:e=>qe.pointsMapping[e]},Fn={none:0,half:1,full:2,nameMapping:{0:"none",1:"half",2:"full"},getName:e=>Fn.nameMapping[e]},He={verticalUp:0,verticalDown:1,horizontalLeft:2,horizontalRight:3,diagonalUpRight:4,diagonalUpLeft:5,diagonalDownRight:6,diagonalDownLeft:7,nameMapping:{0:"verticalUp",1:"verticalDown",2:"horizontalLeft",3:"horizontalRight",4:"diagonalUpRight",5:"diagonalUpLeft",6:"diagonalDownRight",7:"diagonalDownLeft"},getName:e=>He.nameMapping[e]};var Ai={HALF_CURL_START_LIMIT:60,NO_CURL_START_LIMIT:130,DISTANCE_VOTE_POWER:1.1,SINGLE_ANGLE_VOTE_POWER:.9,TOTAL_ANGLE_VOTE_POWER:1.6};function H8(e,t,n,s){let r=(t-s)/(e-n),a=Math.atan(r)*180/Math.PI;return a<=0?a=-a:a>0&&(a=180-a),a}function G8(e,t){if(!e||!t)return[0,0];let n=H8(e[0],e[1],t[0],t[1]);if(e.length===2)return n;let s=H8(e[1],e[2],t[1],t[2]);return[n,s]}function j8(e,t=1){let n=0,s=0,r=0;return e>=75&&e<=105?n=1*t:e>=25&&e<=155?s=1*t:r=1*t,[n,s,r]}function ble(e,t,n){let s=e[0]-t[0],r=e[0]-n[0],a=t[0]-n[0],o=e[1]-t[1],i=e[1]-n[1],l=t[1]-n[1],u=e[2]-t[2],c=e[2]-n[2],d=t[2]-n[2],p=Math.sqrt(s*s+o*o+u*u),h=Math.sqrt(r*r+i*i+c*c),f=Math.sqrt(a*a+l*l+d*d),m=(f*f+p*p-h*h)/(2*f*p);m>1?m=1:m<-1&&(m=-1);let g=Math.acos(m);g=57.2958*g%180;let A;return g>Ai.NO_CURL_START_LIMIT?A=Fn.none:g>Ai.HALF_CURL_START_LIMIT?A=Fn.half:A=Fn.full,A}function q8(e,t,n,s){let r;return s===Math.abs(e)?e>0?r=He.horizontalLeft:r=He.horizontalRight:s===Math.abs(t)?t>0?r=He.horizontalLeft:r=He.horizontalRight:n>0?r=He.horizontalLeft:r=He.horizontalRight,r}function X8(e,t,n,s){let r;return s===Math.abs(e)?e<0?r=He.verticalDown:r=He.verticalUp:s===Math.abs(t)?t<0?r=He.verticalDown:r=He.verticalUp:n<0?r=He.verticalDown:r=He.verticalUp,r}function vle(e,t,n,s,r,a,o,i){let l,u=X8(e,t,n,s),c=q8(r,a,o,i);return u===He.verticalUp?c===He.horizontalLeft?l=He.diagonalUpLeft:l=He.diagonalUpRight:c===He.horizontalLeft?l=He.diagonalDownLeft:l=He.diagonalDownRight,l}function wle(e,t,n,s){let r=e[0]-t[0],a=e[0]-n[0],o=t[0]-n[0],i=e[1]-t[1],l=e[1]-n[1],u=t[1]-n[1],c=Math.max(Math.abs(r),Math.abs(a),Math.abs(o)),d=Math.max(Math.abs(i),Math.abs(l),Math.abs(u)),p=0,h=0,f=0,m=d/(c+1e-5);m>1.5?p+=Ai.DISTANCE_VOTE_POWER:m>.66?h+=Ai.DISTANCE_VOTE_POWER:f+=Ai.DISTANCE_VOTE_POWER;let g=Math.sqrt(r*r+i*i),A=Math.sqrt(a*a+l*l),y=Math.sqrt(o*o+u*u),x=Math.max(g,A,y),b=e[0],v=e[1],k=n[0],S=n[1];x===g?(k=n[0],S=n[1]):x===y&&(b=t[0],v=t[1]);let O=G8([b,v],[k,S]),E=j8(O,Ai.TOTAL_ANGLE_VOTE_POWER);p+=E[0],h+=E[1],f+=E[2];for(let T of s){let P=j8(T,Ai.SINGLE_ANGLE_VOTE_POWER);p+=P[0],h+=P[1],f+=P[2]}let R;return p===Math.max(p,h,f)?R=X8(l,i,u,d):f===Math.max(h,f)?R=q8(a,r,o,c):R=vle(l,i,u,d,a,r,o,c),R}function rx(e){let t=[],n=[],s=[],r=[];if(!e)return{curls:s,directions:r};for(let a of qe.all){let o=qe.getPoints(a),i=[],l=[];for(let u of o){let c=e[u[0]],d=e[u[1]],p=G8(c,d),h=p[0],f=p[1];i.push(h),l.push(f)}t.push(i),n.push(l)}for(let a of qe.all){let o=a===qe.thumb?1:0,i=qe.getPoints(a),l=e[i[o][0]],u=e[i[o+1][1]],c=e[i[3][1]],d=ble(l,u,c),p=wle(l,u,c,t[a].slice(o));s[a]=d,r[a]=p}return{curls:s,directions:r}}var Fd=class{constructor(t){Re(this,"name");Re(this,"curls");Re(this,"directions");Re(this,"weights");Re(this,"weightsRelative");this.name=t,this.curls={},this.directions={},this.weights=[1,1,1,1,1],this.weightsRelative=[1,1,1,1,1]}addCurl(t,n,s){typeof this.curls[t]=="undefined"&&(this.curls[t]=[]),this.curls[t].push([n,s])}addDirection(t,n,s){this.directions[t]||(this.directions[t]=[]),this.directions[t].push([n,s])}setWeight(t,n){this.weights[t]=n;let s=this.weights.reduce((r,a)=>r+a,0);this.weightsRelative=this.weights.map(r=>r*5/s)}matchAgainst(t,n){let s=0;for(let r in t){let a=t[r],o=this.curls[r];if(typeof o=="undefined"){s+=this.weightsRelative[r];continue}for(let[i,l]of o)if(a===i){s+=l*this.weightsRelative[r];break}}for(let r in n){let a=n[r],o=this.directions[r];if(typeof o=="undefined"){s+=this.weightsRelative[r];continue}for(let[i,l]of o)if(a===i){s+=l*this.weightsRelative[r];break}}return s/10}};var Ta=new Fd("thumbs up");Ta.addCurl(qe.thumb,Fn.none,1);Ta.addDirection(qe.thumb,He.verticalUp,1);Ta.addDirection(qe.thumb,He.diagonalUpLeft,.25);Ta.addDirection(qe.thumb,He.diagonalUpRight,.25);for(let e of[qe.index,qe.middle,qe.ring,qe.pinky])Ta.addCurl(e,Fn.full,1),Ta.addDirection(e,He.horizontalLeft,1),Ta.addDirection(e,He.horizontalRight,1);var qt=new Fd("victory");qt.addCurl(qe.thumb,Fn.half,.5);qt.addCurl(qe.thumb,Fn.none,.5);qt.addDirection(qe.thumb,He.verticalUp,1);qt.addDirection(qe.thumb,He.diagonalUpLeft,1);qt.addCurl(qe.index,Fn.none,1);qt.addDirection(qe.index,He.verticalUp,.75);qt.addDirection(qe.index,He.diagonalUpLeft,1);qt.addCurl(qe.middle,Fn.none,1);qt.addDirection(qe.middle,He.verticalUp,1);qt.addDirection(qe.middle,He.diagonalUpLeft,.75);qt.addCurl(qe.ring,Fn.full,1);qt.addDirection(qe.ring,He.verticalUp,.2);qt.addDirection(qe.ring,He.diagonalUpLeft,1);qt.addDirection(qe.ring,He.horizontalLeft,.2);qt.addCurl(qe.pinky,Fn.full,1);qt.addDirection(qe.pinky,He.verticalUp,.2);qt.addDirection(qe.pinky,He.diagonalUpLeft,1);qt.addDirection(qe.pinky,He.horizontalLeft,.2);qt.setWeight(qe.index,2);qt.setWeight(qe.middle,2);var K8=[Ta,qt];var kle=.7;function Z8(e){if(!e||e.length===0)return null;let t=rx(e),n={};for(let s of qe.all)n[qe.getName(s)]={curl:Fn.getName(t.curls[s]),direction:He.getName(t.directions[s])};return n}function Y8(e){let t=[];if(!e||e.length===0)return t;let n=rx(e);for(let s of K8){let r=s.matchAgainst(n.curls,n.directions);r>=kle&&t.push({name:s.name,confidence:r})}return t}var J8={thumb:[1,2,3,4],index:[5,6,7,8],middle:[9,10,11,12],ring:[13,14,15,16],pinky:[17,18,19,20],palm:[0]},zr,Lr,Q8;async function ax(e,t){let n=await Q8.estimateHands(e,t);if(!n)return[];let s=[];for(let r=0;r<n.length;r++){let a={};if(n[r].landmarks)for(let c of Object.keys(J8))a[c]=J8[c].map(d=>n[r].landmarks[d]);let o=n[r].landmarks,i=[Number.MAX_SAFE_INTEGER,Number.MAX_SAFE_INTEGER,0,0],l=[0,0,0,0];if(o&&o.length>0){for(let c of o)c[0]<i[0]&&(i[0]=c[0]),c[1]<i[1]&&(i[1]=c[1]),c[0]>i[2]&&(i[2]=c[0]),c[1]>i[3]&&(i[3]=c[1]);i[2]-=i[0],i[3]-=i[1],l=[i[0]/(e.shape[2]||0),i[1]/(e.shape[1]||0),i[2]/(e.shape[2]||0),i[3]/(e.shape[1]||0)]}else i=n[r].box?[Math.trunc(Math.max(0,n[r].box.topLeft[0])),Math.trunc(Math.max(0,n[r].box.topLeft[1])),Math.trunc(Math.min(e.shape[2]||0,n[r].box.bottomRight[0])-Math.max(0,n[r].box.topLeft[0])),Math.trunc(Math.min(e.shape[1]||0,n[r].box.bottomRight[1])-Math.max(0,n[r].box.topLeft[1]))]:[0,0,0,0],l=[n[r].box.topLeft[0]/(e.shape[2]||0),n[r].box.topLeft[1]/(e.shape[1]||0),(n[r].box.bottomRight[0]-n[r].box.topLeft[0])/(e.shape[2]||0),(n[r].box.bottomRight[1]-n[r].box.topLeft[1])/(e.shape[1]||0)];let u=Z8(o);s.push({id:r,score:Math.round(100*n[r].confidence)/100,box:i,boxRaw:l,keypoints:o,annotations:a,landmarks:u})}return s}async function ox(e){var n,s,r,a,o,i;de.initial&&(zr=null,Lr=null),!zr||!Lr?([zr,Lr]=await Promise.all([e.hand.enabled?yt(xt(e.modelBasePath,((n=e.hand.detector)==null?void 0:n.modelPath)||""),{fromTFHub:(((s=e.hand.detector)==null?void 0:s.modelPath)||"").includes("tfhub.dev")}):null,e.hand.landmarks?yt(xt(e.modelBasePath,((r=e.hand.skeleton)==null?void 0:r.modelPath)||""),{fromTFHub:(((a=e.hand.skeleton)==null?void 0:a.modelPath)||"").includes("tfhub.dev")}):null]),e.hand.enabled&&(!zr||!zr.modelUrl?ie("load model failed:",((o=e.hand.detector)==null?void 0:o.modelPath)||""):e.debug&&ie("load model:",zr.modelUrl),!Lr||!Lr.modelUrl?ie("load model failed:",((i=e.hand.skeleton)==null?void 0:i.modelPath)||""):e.debug&&ie("load model:",Lr.modelUrl))):(e.debug&&ie("cached model:",zr.modelUrl),e.debug&&ie("cached model:",Lr.modelUrl));let t=new ex(zr);return Q8=new sx(t,Lr),[zr,Lr]}var eI=["nose","leftEyeInside","leftEye","leftEyeOutside","rightEyeInside","rightEye","rightEyeOutside","leftEar","rightEar","leftMouth","rightMouth","leftShoulder","rightShoulder","leftElbow","rightElbow","leftWrist","rightWrist","leftPalm","rightPalm","leftIndex","rightIndex","leftPinky","rightPinky","leftHip","rightHip","leftKnee","rightKnee","leftAnkle","rightAnkle","leftHeel","rightHeel","leftFoot","rightFoot","midHip","forehead","leftThumb","leftHand","rightThumb","rightHand"],tI=["nose","leftEyeInside","leftEye","leftEyeOutside","rightEyeInside","rightEye","rightEyeOutside","leftEar","rightEar","leftMouth","rightMouth","leftShoulder","rightShoulder","leftElbow","rightElbow","left:15","right:16","left:17","right:18","left:19","right:20","left:21","right:22","leftChest","rightChest","neck","forehead","left:27","right:28","left:29","right:30"];var On;async function v0(e){return de.initial&&(On=null),On?e.debug&&ie("cached model:",On.modelUrl):(On=await yt(xt(e.modelBasePath,e.body.modelPath||"")),On.width=parseInt(On.signature.inputs["input_1:0"].tensorShape.dim[2].size),On.height=parseInt(On.signature.inputs["input_1:0"].tensorShape.dim[1].size),!On||!On.modelUrl?ie("load model failed:",e.body.modelPath):e.debug&&ie("load model:",On.modelUrl)),On}async function ix(e,t){if(!On)return[];if(!t.body.enabled)return[];let n={width:e.shape[2]||0,height:e.shape[1]||0},s=$e.resizeBilinear(e,[On.width,On.height],!1),r=he(s,[255]);Z(s);let a=await On.predict(r),o=a.find(g=>g.size===195||g.size===155),i=await(o==null?void 0:o.data())||[];a.forEach(g=>Z(g)),Z(r);let l=[],u=(i==null?void 0:i.length)===195?eI:tI,c=5;for(let g=0;g<i.length/c;g++)l.push({id:g,part:u[g],position:[Math.trunc(n.width*i[c*g+0]/255),Math.trunc(n.height*i[c*g+1]/255),Math.trunc(i[c*g+2])+0],positionRaw:[i[c*g+0]/255,i[c*g+1]/255,i[c*g+2]+0],score:(100-Math.trunc(100/(1+Math.exp(i[c*g+3]))))/100,presence:(100-Math.trunc(100/(1+Math.exp(i[c*g+4]))))/100});let d=l.map(g=>g.position[0]),p=l.map(g=>g.position[1]),h=[Math.min(...d),Math.min(...p),Math.max(...d)-Math.min(...d),Math.max(...p)-Math.min(...d)],f=[0,0,0,0],m=l.reduce((g,A)=>A.score>g?A.score:g,0);return[{id:0,score:m,box:h,boxRaw:f,keypoints:l}]}var tn,Ar=[],lx=[0,0,0,0],ux=[0,0,0,0],w0=0,cx=Number.MAX_SAFE_INTEGER,Ile=["head","neck","rightShoulder","rightElbow","rightWrist","chest","leftShoulder","leftElbow","leftWrist","pelvis","rightHip","rightKnee","rightAnkle","leftHip","leftKnee","leftAnkle"];async function nI(e){return de.initial&&(tn=null),tn?e.debug&&ie("cached model:",tn.modelUrl):(tn=await yt(xt(e.modelBasePath,e.body.modelPath||"")),!tn||!tn.modelUrl?ie("load model failed:",e.body.modelPath):e.debug&&ie("load model:",tn.modelUrl)),tn}function Sle(e,t){let[n,s]=e.shape;return H(()=>{let r=(i,l)=>ye(i,z(he(i,Ce(l,"int32")),Ce(l,"int32"))),a=V(e,[s*n]),o=ss(a,0).dataSync()[0];if(o>t){let i=Ws(a,0),l=r(i,n).dataSync()[0],u=he(i,Ce(n,"int32")).dataSync()[0];return[l,u,o]}return[0,0,o]})}async function dx(e,t){var n;return cx<(((n=t.body)==null?void 0:n.skipFrames)||0)&&t.skipFrame&&Object.keys(Ar).length>0?(cx++,[{id:0,score:w0,box:lx,boxRaw:ux,keypoints:Ar}]):(cx=0,new Promise(async s=>{var c;let r=H(()=>{if(!(tn==null?void 0:tn.inputs[0].shape))return null;let d=$e.resizeBilinear(e,[tn.inputs[0].shape[2],tn.inputs[0].shape[1]],!1);return z(d,2).sub(1)}),a;if(t.body.enabled&&(a=await(tn==null?void 0:tn.predict(r))),Z(r),a){Ar.length=0;let d=a.squeeze();Z(a);let p=d.unstack(2);Z(d);for(let h=0;h<p.length;h++){let[f,m,g]=Sle(p[h],t.body.minConfidence);w0>(((c=t.body)==null?void 0:c.minConfidence)||0)&&Ar.push({score:Math.round(100*g)/100,part:Ile[h],positionRaw:[f/tn.inputs[0].shape[2],m/tn.inputs[0].shape[1]],position:[Math.round(e.shape[2]*f/tn.inputs[0].shape[2]),Math.round(e.shape[1]*m/tn.inputs[0].shape[1])]})}p.forEach(h=>Z(h))}w0=Ar.reduce((d,p)=>p.score>d?p.score:d,0);let o=Ar.map(d=>d.position[0]),i=Ar.map(d=>d.position[1]);lx=[Math.min(...o),Math.min(...i),Math.max(...o)-Math.min(...o),Math.max(...i)-Math.min(...i)];let l=Ar.map(d=>d.positionRaw[0]),u=Ar.map(d=>d.positionRaw[1]);ux=[Math.min(...l),Math.min(...u),Math.max(...l)-Math.min(...l),Math.max(...u)-Math.min(...u)],s([{id:0,score:w0,box:lx,boxRaw:ux,keypoints:Ar}])}))}var Kn,Cs=[],px=[0,0,0,0],Br=[0,0,0,0],Wr=0,hx=Number.MAX_SAFE_INTEGER,sI=["nose","leftEye","rightEye","leftEar","rightEar","leftShoulder","rightShoulder","leftElbow","rightElbow","leftWrist","rightWrist","leftHip","rightHip","leftKnee","rightKnee","leftAnkle","rightAnkle"];async function fx(e){return de.initial&&(Kn=null),Kn?e.debug&&ie("cached model:",Kn.modelUrl):(Kn=await yt(xt(e.modelBasePath,e.body.modelPath||"")),!Kn||!Kn.modelUrl?ie("load model failed:",e.body.modelPath):e.debug&&ie("load model:",Kn.modelUrl)),Kn}async function Cle(e,t,n){Cs.length=0;let s=e[0][0];for(let u=0;u<s.length;u++)Wr=s[u][2],Wr>t.body.minConfidence&&Cs.push({score:Math.round(100*Wr)/100,part:sI[u],positionRaw:[s[u][1],s[u][0]],position:[Math.round((n.shape[2]||0)*s[u][1]),Math.round((n.shape[1]||0)*s[u][0])]});Wr=Cs.reduce((u,c)=>c.score>u?c.score:u,0);let r=Cs.map(u=>u.position[0]),a=Cs.map(u=>u.position[1]);px=[Math.min(...r),Math.min(...a),Math.max(...r)-Math.min(...r),Math.max(...a)-Math.min(...a)];let o=Cs.map(u=>u.positionRaw[0]),i=Cs.map(u=>u.positionRaw[1]);Br=[Math.min(...o),Math.min(...i),Math.max(...o)-Math.min(...o),Math.max(...i)-Math.min(...i)];let l=[];return l.push({id:0,score:Wr,box:px,boxRaw:Br,keypoints:Cs}),l}async function Tle(e,t,n){let s=[];for(let r=0;r<e[0].length;r++){let a=e[0][r];if(Wr=Math.round(100*a[51+4])/100,!(Wr<t.body.minConfidence)){Cs.length=0;for(let o=0;o<17;o++){let i=Math.round(100*a[3*o+2])/100;i>t.body.minConfidence&&Cs.push({part:sI[o],score:i,positionRaw:[a[3*o+1],a[3*o+0]],position:[Math.trunc(a[3*o+1]*(n.shape[2]||0)),Math.trunc(a[3*o+0]*(n.shape[1]||0))]})}Br=[a[51+1],a[51+0],a[51+3]-a[51+1],a[51+2]-a[51+0]],s.push({id:r,score:Wr,boxRaw:Br,box:[Math.trunc(Br[0]*(n.shape[2]||0)),Math.trunc(Br[1]*(n.shape[1]||0)),Math.trunc(Br[2]*(n.shape[2]||0)),Math.trunc(Br[3]*(n.shape[1]||0))],keypoints:Cs})}}return s}async function mx(e,t){return hx<(t.body.skipFrames||0)&&t.skipFrame&&Object.keys(Cs).length>0?(hx++,[{id:0,score:Wr,box:px,boxRaw:Br,keypoints:Cs}]):(hx=0,new Promise(async n=>{let s=H(()=>{if(!(Kn==null?void 0:Kn.inputs[0].shape))return null;let i=Kn.inputs[0].shape[2];i===-1&&(i=256);let l=$e.resizeBilinear(e,[i,i],!1);return pe(l,"int32")}),r;t.body.enabled&&(r=await(Kn==null?void 0:Kn.predict(s))),Z(s),r||n([]);let a=await r.array(),o;r.shape[2]===17?o=await Cle(a,t,e):r.shape[2]===56&&(o=await Tle(a,t,e)),Z(r),n(o)}))}var Ru=[{class:1,label:"person"},{class:2,label:"bicycle"},{class:3,label:"car"},{class:4,label:"motorcycle"},{class:5,label:"airplane"},{class:6,label:"bus"},{class:7,label:"train"},{class:8,label:"truck"},{class:9,label:"boat"},{class:10,label:"traffic light"},{class:11,label:"fire hydrant"},{class:12,label:"stop sign"},{class:13,label:"parking meter"},{class:14,label:"bench"},{class:15,label:"bird"},{class:16,label:"cat"},{class:17,label:"dog"},{class:18,label:"horse"},{class:19,label:"sheep"},{class:20,label:"cow"},{class:21,label:"elephant"},{class:22,label:"bear"},{class:23,label:"zebra"},{class:24,label:"giraffe"},{class:25,label:"backpack"},{class:26,label:"umbrella"},{class:27,label:"handbag"},{class:28,label:"tie"},{class:29,label:"suitcase"},{class:30,label:"frisbee"},{class:31,label:"skis"},{class:32,label:"snowboard"},{class:33,label:"sports ball"},{class:34,label:"kite"},{class:35,label:"baseball bat"},{class:36,label:"baseball glove"},{class:37,label:"skateboard"},{class:38,label:"surfboard"},{class:39,label:"tennis racket"},{class:40,label:"bottle"},{class:41,label:"wine glass"},{class:42,label:"cup"},{class:43,label:"fork"},{class:44,label:"knife"},{class:45,label:"spoon"},{class:46,label:"bowl"},{class:47,label:"banana"},{class:48,label:"apple"},{class:49,label:"sandwich"},{class:50,label:"orange"},{class:51,label:"broccoli"},{class:52,label:"carrot"},{class:53,label:"hot dog"},{class:54,label:"pizza"},{class:55,label:"donut"},{class:56,label:"cake"},{class:57,label:"chair"},{class:58,label:"couch"},{class:59,label:"potted plant"},{class:60,label:"bed"},{class:61,label:"dining table"},{class:62,label:"toilet"},{class:63,label:"tv"},{class:64,label:"laptop"},{class:65,label:"mouse"},{class:66,label:"remote"},{class:67,label:"keyboard"},{class:68,label:"cell phone"},{class:69,label:"microwave"},{class:70,label:"oven"},{class:71,label:"toaster"},{class:72,label:"sink"},{class:73,label:"refrigerator"},{class:74,label:"book"},{class:75,label:"clock"},{class:76,label:"vase"},{class:77,label:"scissors"},{class:78,label:"teddy bear"},{class:79,label:"hair drier"},{class:80,label:"toothbrush"}];var hs,k0=[],gx=Number.MAX_SAFE_INTEGER,I0=2.5;async function Ax(e){if(!hs||de.initial){hs=await yt(xt(e.modelBasePath,e.object.modelPath||""));let t=Object.values(hs.modelSignature.inputs);if(hs.inputSize=Array.isArray(t)?parseInt(t[0].tensorShape.dim[2].size):null,!hs.inputSize)throw new Error(`cannot determine model inputSize: ${e.object.modelPath}`);!hs||!hs.modelUrl?ie("load model failed:",e.object.modelPath):e.debug&&ie("load model:",hs.modelUrl)}else e.debug&&ie("cached model:",hs.modelUrl);return hs}async function Nle(e,t,n,s){let r=0,a=[];for(let u of[1,2,4])H(async()=>{var g,A;let c=u*13,d=(g=e.find(y=>y.shape[1]===c**2&&y.shape[2]===Ru.length))==null?void 0:g.squeeze(),p=(A=e.find(y=>y.shape[1]===c**2&&y.shape[2]<Ru.length))==null?void 0:A.squeeze(),f=await p.reshape([-1,4,p.shape[1]/4]).argMax(2).array(),m=await d.array();for(let y=0;y<d.shape[0];y++)for(let x=0;x<d.shape[1];x++){let b=m[y][x];if(b>s.object.minConfidence&&x!==61){let v=(.5+Math.trunc(y%c))/c,k=(.5+Math.trunc(y/c))/c,S=f[y].map(U=>U*(c/u/t)),[C,D]=[v-I0/u*S[0],k-I0/u*S[1]],[O,E]=[v+I0/u*S[2]-C,k+I0/u*S[3]-D],R=[C,D,O,E];R=R.map(U=>Math.max(0,Math.min(U,1)));let T=[R[0]*n[0],R[1]*n[1],R[2]*n[0],R[3]*n[1]],P={id:r++,score:Math.round(100*b)/100,class:x+1,label:Ru[x].label,box:T.map(U=>Math.trunc(U)),boxRaw:R};a.push(P)}}});e.forEach(u=>Z(u));let o=a.map(u=>[u.boxRaw[1],u.boxRaw[0],u.boxRaw[3],u.boxRaw[2]]),i=a.map(u=>u.score),l=[];if(o&&o.length>0){let u=await $e.nonMaxSuppressionAsync(o,i,s.object.maxDetected,s.object.iouThreshold,s.object.minConfidence);l=await u.data(),Z(u)}return a=a.filter((u,c)=>l.includes(c)).sort((u,c)=>c.score-u.score),a}async function yx(e,t){return gx<(t.object.skipFrames||0)&&t.skipFrame&&k0.length>0?(gx++,k0):(gx=0,!de.kernels.includes("mod")||!de.kernels.includes("sparsetodense")?k0:new Promise(async n=>{let s=[e.shape[2],e.shape[1]],r=$e.resizeBilinear(e,[hs.inputSize,hs.inputSize],!1),a=he(r,255),o=a.transpose([0,3,1,2]);Z(a),Z(r);let i;t.object.enabled&&(i=await hs.predict(o)),Z(o);let l=await Nle(i,hs.inputSize,s,t);k0=l,n(l)}))}var Ms,yi=0,S0=[],xx=Number.MAX_SAFE_INTEGER;async function bx(e){if(de.initial&&(Ms=null),Ms)e.debug&&ie("cached model:",Ms.modelUrl);else{Ms=await yt(xt(e.modelBasePath,e.object.modelPath||""));let t=Object.values(Ms.modelSignature.inputs);yi=Array.isArray(t)?parseInt(t[0].tensorShape.dim[2].size):0,!Ms||!Ms.modelUrl?ie("load model failed:",e.object.modelPath):e.debug&&ie("load model:",Ms.modelUrl)}return Ms}async function Ele(e,t,n){if(!e)return[];let s=[],r=await e.array(),a=lt(e);Z(e);let o=Vt(a,6,1);Z(a);let i=mn([o[1],o[0],o[3],o[2]],1),l=lt(i);Z(i);let u=lt(o[4]),c=lt(o[5]);o.forEach(f=>Z(f));let d=await $e.nonMaxSuppressionAsync(l,u,n.object.maxDetected,n.object.iouThreshold,n.object.minConfidence);Z(l),Z(u),Z(c);let p=await d.data();Z(d);let h=0;for(let f of p){let m=Math.trunc(100*r[0][f][4])/100,g=r[0][f][5],A=Ru[g].label,[y,x]=[r[0][f][0]/yi,r[0][f][1]/yi],b=[y,x,r[0][f][2]/yi-y,r[0][f][3]/yi-x],v=[Math.trunc(b[0]*t[0]),Math.trunc(b[1]*t[1]),Math.trunc(b[2]*t[0]),Math.trunc(b[3]*t[1])];s.push({id:h++,score:m,class:g,label:A,box:v,boxRaw:b})}return s}async function vx(e,t){return xx<(t.object.skipFrames||0)&&t.skipFrame&&S0.length>0?(xx++,S0):(xx=0,!de.kernels.includes("mod")||!de.kernels.includes("sparsetodense")?S0:new Promise(async n=>{let s=[e.shape[2],e.shape[1]],r=$e.resizeBilinear(e,[yi,yi]),a=t.object.enabled?Ms==null?void 0:Ms.execute(r,["tower_0/detections"]):null;Z(r);let o=await Ele(a,s,t);S0=o,n(o)}))}var Ts,wx=!1;async function C0(e){return!Ts||de.initial?(Ts=await yt(xt(e.modelBasePath,e.segmentation.modelPath||"")),!Ts||!Ts.modelUrl?ie("load model failed:",e.segmentation.modelPath):e.debug&&ie("load model:",Ts.modelUrl)):e.debug&&ie("cached model:",Ts.modelUrl),Ts}async function kx(e){var f,m;let t=((f=e.tensor)==null?void 0:f.shape[1])||0,n=((m=e.tensor)==null?void 0:m.shape[2])||0;if(!e.tensor||!Ts||!Ts.inputs[0].shape)return null;let s=$e.resizeBilinear(e.tensor,[Ts.inputs[0].shape[1],Ts.inputs[0].shape[2]],!1),r=he(s,255),a=Ts.predict(r);Z(s),Z(r);let o=lt(a,0);Z(a);let i;if(o.shape[2]===2){let g=o.softmax(),[A,y]=is(g,2),x=Lt(y,2),b=Lt(x,0);Z(g),Z(A),Z(y);let v=$e.cropAndResize(b,[[0,0,.5,.5]],[0],[t,n]);i=lt(v,0),Z(v),Z(x),Z(b)}else i=$e.resizeBilinear(o,[t,n]);if(Z(o),de.node){let g=await i.data();return Z(i),g}let l=Xn(t,n);xs&&await xs.toPixels(i,l),Z(i);let c=Xn(t,n).getContext("2d");c.filter="blur(8px",await c.drawImage(l,0,0);let d=c.getImageData(0,0,t,n).data,p=Xn(t,n),h=p.getContext("2d");return e.canvas&&await h.drawImage(e.canvas,0,0),h.globalCompositeOperation="darken",h.filter="blur(8px)",await h.drawImage(l,0,0),h.globalCompositeOperation="source-over",h.filter="none",e.canvas=p,d}async function rI(e,t,n){var o;if(wx)return null;wx=!0,Ts||await C0(n);let s=gi(e,n),r=gi(t,n);if(!s.canvas||!r.canvas)return n.debug&&ie("segmentation cannot process input or background"),null;let a=await kx(s);if(Z(s.tensor),t&&a){let i=r.canvas;Z(r.tensor);let l=s.canvas,u=(o=l.getContext("2d"))==null?void 0:o.getImageData(0,0,l.width,l.height).data,c=Xn(l.width,l.height),d=c.getContext("2d");d.globalCompositeOperation="copy",d.drawImage(i,0,0,c.width,c.height);let p=d.getImageData(0,0,c.width,c.height);for(let h=0;h<c.width*c.height;h++)p.data[4*h+0]=(255-a[4*h+0])/255*p.data[4*h+0]+a[4*h+0]/255*u[4*h+0],p.data[4*h+1]=(255-a[4*h+1])/255*p.data[4*h+1]+a[4*h+1]/255*u[4*h+1],p.data[4*h+2]=(255-a[4*h+2])/255*p.data[4*h+2]+a[4*h+2]/255*u[4*h+2],p.data[4*h+3]=(255-a[4*h+3])/255*p.data[4*h+3]+a[4*h+3]/255*u[4*h+3];d.putImageData(p,0,0),s.canvas=c}return wx=!1,s.canvas}function Ix(e){e.models={face:null,handpose:null,posenet:null,blazepose:null,efficientpose:null,movenet:null,age:null,gender:null,emotion:null,embedding:null,nanodet:null,centernet:null,faceres:null,segmentation:null}}async function aI(e){de.initial&&Ix(e),e.config.async?[e.models.face,e.models.emotion,e.models.handpose,e.models.posenet,e.models.blazepose,e.models.efficientpose,e.models.movenet,e.models.nanodet,e.models.centernet,e.models.faceres,e.models.segmentation]=await Promise.all([e.models.face||(e.config.face.enabled?My(e.config):null),e.models.emotion||(e.config.face.enabled&&e.config.face.emotion.enabled?Gy(e.config):null),e.models.handpose||(e.config.hand.enabled?ox(e.config):null),e.models.posenet||(e.config.body.enabled&&e.config.body.modelPath.includes("posenet")?Qy(e.config):null),e.models.blazepose||(e.config.body.enabled&&e.config.body.modelPath.includes("blazepose")?v0(e.config):null),e.models.efficientpose||(e.config.body.enabled&&e.config.body.modelPath.includes("efficientpose")?nI(e.config):null),e.models.movenet||(e.config.body.enabled&&e.config.body.modelPath.includes("movenet")?fx(e.config):null),e.models.nanodet||(e.config.object.enabled&&e.config.object.modelPath.includes("nanodet")?Ax(e.config):null),e.models.centernet||(e.config.object.enabled&&e.config.object.modelPath.includes("centernet")?bx(e.config):null),e.models.faceres||(e.config.face.enabled&&e.config.face.description.enabled?Ly(e.config):null),e.models.segmentation||(e.config.segmentation.enabled?C0(e.config):null)]):(e.config.face.enabled&&!e.models.face&&(e.models.face=await My(e.config)),e.config.face.enabled&&e.config.face.emotion.enabled&&!e.models.emotion&&(e.models.emotion=await Gy(e.config)),e.config.hand.enabled&&!e.models.handpose&&(e.models.handpose=await ox(e.config)),e.config.body.enabled&&!e.models.posenet&&e.config.body.modelPath.includes("posenet")&&(e.models.posenet=await Qy(e.config)),e.config.body.enabled&&!e.models.blazepose&&e.config.body.modelPath.includes("blazepose")&&(e.models.blazepose=await v0(e.config)),e.config.body.enabled&&!e.models.efficientpose&&e.config.body.modelPath.includes("efficientpose")&&(e.models.efficientpose=await v0(e.config)),e.config.body.enabled&&!e.models.movenet&&e.config.body.modelPath.includes("movenet")&&(e.models.movenet=await fx(e.config)),e.config.object.enabled&&!e.models.nanodet&&e.config.object.modelPath.includes("nanodet")&&(e.models.nanodet=await Ax(e.config)),e.config.object.enabled&&!e.models.centernet&&e.config.object.modelPath.includes("centernet")&&(e.models.centernet=await bx(e.config)),e.config.face.enabled&&e.config.face.description.enabled&&!e.models.faceres&&(e.models.faceres=await Ly(e.config)),e.config.segmentation.enabled&&!e.models.segmentation&&(e.models.segmentation=await C0(e.config)))}async function oI(e){let t=["const","placeholder","noop","pad","squeeze","add","sub","mul","div"];for(let n of Object.keys(e.models))if(e.models[n]){let s=[];Array.isArray(e.models[n])?s=e.models[n].filter(r=>r!==null).map(r=>r&&r.executor?r:r.model):s=[e.models[n]];for(let r of s){if(!r){e.config.debug&&ie("model marked as loaded but not defined:",n);continue}let a=[],o=r==null?void 0:r.executor;if(o&&o.graph.nodes)for(let l of Object.values(o.graph.nodes)){let u=l.op.toLowerCase();a.includes(u)||a.push(u)}else!o&&e.config.debug&&ie("model signature not determined:",n);let i=[];for(let l of a)!t.includes(l)&&!e.env.kernels.includes(l)&&!e.env.kernels.includes(l.replace("_",""))&&!e.env.kernels.includes(l.replace("native",""))&&!e.env.kernels.includes(l.replace("v2",""))&&i.push(l);i.length>0&&e.config.debug&&ie("model validation:",n,i)}}}var Rle=e=>{let t=(d,p)=>Math.atan2(d[1]-p[1],d[0]-p[0]);if(!e.annotations.rightEyeIris||!e.annotations.leftEyeIris)return{bearing:0,strength:0};let n=[0,-.1],s=1,r=e.mesh[33][2]>e.mesh[263][2],a=r?e.mesh[473]:e.mesh[468],o=r?[(e.mesh[133][0]+e.mesh[33][0])/2,(e.mesh[133][1]+e.mesh[33][1])/2]:[(e.mesh[263][0]+e.mesh[362][0])/2,(e.mesh[263][1]+e.mesh[362][1])/2],i=r?[e.mesh[133][0]-e.mesh[33][0],e.mesh[23][1]-e.mesh[27][1]]:[e.mesh[263][0]-e.mesh[362][0],e.mesh[253][1]-e.mesh[257][1]],l=[(o[0]-a[0])/i[0]-n[0],s*(a[1]-o[1])/i[1]-n[1]],u=Math.sqrt(l[0]**2+l[1]**2);return u=Math.min(u,e.boxRaw[2]/2,e.boxRaw[3]/2),{bearing:(t([0,0],l)+Math.PI/2)%Math.PI,strength:u}},Dle=(e,t)=>{let n=g=>{let A=Math.sqrt(g[0]*g[0]+g[1]*g[1]+g[2]*g[2]);return g[0]/=A,g[1]/=A,g[2]/=A,g},s=(g,A)=>{let y=g[0]-A[0],x=g[1]-A[1],b=g[2]-A[2];return[y,x,b]},r=(g,A)=>{let y=g[1]*A[2]-g[2]*A[1],x=g[2]*A[0]-g[0]*A[2],b=g[0]*A[1]-g[1]*A[0];return[y,x,b]},a=g=>{let[A,y,x,b,v,k,S,C,D]=g,O,E,R;return b<1?b>-1?(R=Math.asin(b),E=Math.atan2(-S,A),O=Math.atan2(-k,v)):(R=-Math.PI/2,E=-Math.atan2(C,D),O=0):(R=Math.PI/2,E=Math.atan2(C,D),O=0),isNaN(O)&&(O=0),isNaN(E)&&(E=0),isNaN(R)&&(R=0),{pitch:2*-O,yaw:2*-E,roll:2*-R}},o=g=>{let A=(x,b,v,k)=>Math.atan2(k-b,v-x);return{pitch:A(g[10][1],g[10][2],g[152][1],g[152][2]),yaw:A(g[33][0],g[33][2],g[263][0],g[263][2]),roll:A(g[33][0],g[33][1],g[263][0],g[263][1])}},i=e.meshRaw;if(!i||i.length<300)return{angle:{pitch:0,yaw:0,roll:0},matrix:[1,0,0,0,1,0,0,0,1],gaze:{bearing:0,strength:0}};let l=Math.max(e.boxRaw[2]*t[0],e.boxRaw[3]*t[1])/1.5,u=[i[10],i[152],i[234],i[454]].map(g=>[g[0]*t[0]/l,g[1]*t[1]/l,g[2]]),c=n(s(u[1],u[0])),d=n(s(u[3],u[2])),p=n(r(d,c));d=r(c,p);let h=[d[0],d[1],d[2],c[0],c[1],c[2],p[0],p[1],p[2]],f=a(h),m=i.length===478?Rle(e):{bearing:0,strength:0};return{angle:f,matrix:h,gaze:m}},Sx=async(e,t)=>{var d,p,h,f,m,g;let n,s,r,a,o,i,l,u=[];e.state="run:face",n=Ze();let c=await v8(t,e.config);if(e.performance.face=Math.trunc(Ze()-n),!t.shape||t.shape.length!==4)return[];if(!c)return[];for(let A=0;A<c.length;A++){if(e.analyze("Get Face"),!c[A].tensor||c[A].tensor.isDisposedInternal){ie("Face object is disposed:",c[A].tensor);continue}let y=Dle(c[A],[t.shape[2],t.shape[1]]);e.analyze("Start Emotion:"),e.config.async?o=e.config.face.emotion.enabled?jy(c[A].tensor||an([]),e.config,A,c.length):{}:(e.state="run:emotion",n=Ze(),o=e.config.face.emotion.enabled?await jy(c[A].tensor||an([]),e.config,A,c.length):{},e.performance.emotion=Math.trunc(Ze()-n)),e.analyze("End Emotion:"),e.analyze("Start Description:"),e.config.async?l=e.config.face.description.enabled?Vy(c[A].tensor||an([]),e.config,A,c.length):[]:(e.state="run:description",n=Ze(),l=e.config.face.description.enabled?await Vy(c[A].tensor||an([]),e.config,A,c.length):[],e.performance.embedding=Math.trunc(Ze()-n)),e.analyze("End Description:"),e.config.async&&([s,a,o,i,l,r]=await Promise.all([s,a,o,i,l,r])),e.analyze("Finish Face:"),!e.config.face.iris.enabled&&((p=(d=c[A])==null?void 0:d.annotations)==null?void 0:p.leftEyeIris)&&((f=(h=c[A])==null?void 0:h.annotations)==null?void 0:f.rightEyeIris)&&(delete c[A].annotations.leftEyeIris,delete c[A].annotations.rightEyeIris);let x=((m=c[A].annotations)==null?void 0:m.leftEyeIris)&&((g=c[A].annotations)==null?void 0:g.rightEyeIris)?Math.max(Math.abs(c[A].annotations.leftEyeIris[3][0]-c[A].annotations.leftEyeIris[1][0]),Math.abs(c[A].annotations.rightEyeIris[4][1]-c[A].annotations.rightEyeIris[2][1]))/t.shape[2]:0,b=e.config.face.detector.return?lt(c[A].tensor):null;Z(c[A].tensor),c[A].tensor&&delete c[A].tensor,u.push({...c[A],id:A,age:l.age,gender:l.gender,genderScore:l.genderScore,embedding:l.descriptor,emotion:o,iris:x!==0?Math.trunc(500/x/11.7)/100:0,rotation:y,tensor:b}),e.analyze("End Face")}return e.analyze("End FaceMesh:"),e.config.async&&(e.performance.face&&delete e.performance.face,e.performance.age&&delete e.performance.age,e.performance.gender&&delete e.performance.gender,e.performance.emotion&&delete e.performance.emotion),u};var iI=e=>{if(!e)return[];let t=[];for(let n=0;n<e.length;n++){let s=e[n].keypoints.find(l=>l.part==="leftWrist"),r=e[n].keypoints.find(l=>l.part==="rightWrist"),a=e[n].keypoints.find(l=>l.part==="nose");a&&s&&r&&s.position.y<a.position.y&&r.position.y<a.position.y?t.push({body:n,gesture:"i give up"}):a&&s&&s.position.y<a.position.y?t.push({body:n,gesture:"raise left hand"}):a&&r&&r.position.y<a.position.y&&t.push({body:n,gesture:"raise right hand"});let o=e[n].keypoints.find(l=>l.part==="leftShoulder"),i=e[n].keypoints.find(l=>l.part==="rightShoulder");o&&i&&t.push({body:n,gesture:`leaning ${o.position.y>i.position.y?"left":"right"}`})}return t},lI=e=>{if(!e)return[];let t=[];for(let n=0;n<e.length;n++)if(e[n].mesh&&e[n].mesh.length>0){let s=e[n].mesh[33][2]-e[n].mesh[263][2];Math.abs(s)<10?t.push({face:n,gesture:"facing center"}):t.push({face:n,gesture:`facing ${s<0?"left":"right"}`}),Math.abs(e[n].mesh[374][1]-e[n].mesh[386][1])/Math.abs(e[n].mesh[443][1]-e[n].mesh[450][1])<.2&&t.push({face:n,gesture:"blink left eye"}),Math.abs(e[n].mesh[145][1]-e[n].mesh[159][1])/Math.abs(e[n].mesh[223][1]-e[n].mesh[230][1])<.2&&t.push({face:n,gesture:"blink right eye"});let o=Math.min(100,500*Math.abs(e[n].mesh[13][1]-e[n].mesh[14][1])/Math.abs(e[n].mesh[10][1]-e[n].mesh[152][1]));o>10&&t.push({face:n,gesture:`mouth ${Math.trunc(o)}% open`});let i=e[n].mesh[152][2];Math.abs(i)>10&&t.push({face:n,gesture:`head ${i<0?"up":"down"}`})}return t},uI=e=>{if(!e)return[];let t=[];for(let n=0;n<e.length;n++){if(!e[n].annotations||!e[n].annotations.leftEyeIris||!e[n].annotations.rightEyeIris)continue;let s=e[n].annotations.leftEyeIris[3][0]-e[n].annotations.leftEyeIris[1][0],r=e[n].annotations.leftEyeIris[4][1]-e[n].annotations.leftEyeIris[2][1],a=Math.abs(s*r),o=e[n].annotations.rightEyeIris[3][0]-e[n].annotations.rightEyeIris[1][0],i=e[n].annotations.rightEyeIris[4][1]-e[n].annotations.rightEyeIris[2][1],l=Math.abs(o*i),u=!1;Math.abs(a-l)/Math.max(a,l)<.25&&(u=!0,t.push({iris:n,gesture:"facing center"}));let d=Math.abs(e[n].mesh[33][0]-e[n].annotations.rightEyeIris[0][0])/e[n].box[2],p=Math.abs(e[n].mesh[263][0]-e[n].annotations.leftEyeIris[0][0])/e[n].box[2];(p>.06||d>.06)&&(u=!1),p>.06&&t.push({iris:n,gesture:"looking right"}),d>.06&&t.push({iris:n,gesture:"looking left"});let h=Math.abs(e[n].mesh[145][1]-e[n].annotations.rightEyeIris[0][1])/e[n].box[3],f=Math.abs(e[n].mesh[374][1]-e[n].annotations.leftEyeIris[0][1])/e[n].box[3];(f<.01||h<.01||f>.022||h>.022)&&(u=!1),(f<.01||h<.01)&&t.push({iris:n,gesture:"looking down"}),(f>.022||h>.022)&&t.push({iris:n,gesture:"looking up"}),u&&t.push({iris:n,gesture:"looking center"})}return t},cI=e=>{if(!e)return[];let t=[];for(let n=0;n<e.length;n++){let s=[];for(let[a,o]of Object.entries(e[n].annotations))a!=="palmBase"&&Array.isArray(o)&&o[0]&&s.push({name:a.toLowerCase(),position:o[0]});if(s&&s.length>0){let a=s.reduce((i,l)=>i.position[2]<l.position[2]?i:l);t.push({hand:n,gesture:`${a.name} forward`});let o=s.reduce((i,l)=>i.position[1]<l.position[1]?i:l);t.push({hand:n,gesture:`${o.name} up`})}let r=Y8(e[n].keypoints);for(let a of r)t.push({hand:n,gesture:a.name})}return t};var Vr={color:"rgba(173, 216, 230, 0.6)",labelColor:"rgba(173, 216, 230, 1)",shadowColor:"black",font:'small-caps 14px "Segoe UI"',lineHeight:18,lineWidth:4,pointSize:2,roundRect:8,drawPoints:!1,drawLabels:!0,drawBoxes:!0,drawPolygons:!0,drawGaze:!0,fillPolygons:!1,useDepth:!0,useCurves:!1,bufferedOutput:!0},xi=e=>{if(e&&e.getContext)return e.getContext("2d");throw new Error("invalid canvas")},T0=e=>Math.round(e*180/Math.PI);function Cx(e,t,n,s=0,r){e.fillStyle=r.useDepth&&s?`rgba(${127.5+2*s}, ${127.5-2*s}, 255, 0.3)`:r.color,e.beginPath(),e.arc(t,n,r.pointSize,0,2*Math.PI),e.fill()}function Od(e,t,n,s,r,a){if(e.beginPath(),a.useCurves){let o=(t+t+s)/2,i=(n+n+r)/2;e.ellipse(o,i,s/2,r/2,0,0,2*Math.PI)}else e.lineWidth=a.lineWidth,e.moveTo(t+a.roundRect,n),e.lineTo(t+s-a.roundRect,n),e.quadraticCurveTo(t+s,n,t+s,n+a.roundRect),e.lineTo(t+s,n+r-a.roundRect),e.quadraticCurveTo(t+s,n+r,t+s-a.roundRect,n+r),e.lineTo(t+a.roundRect,n+r),e.quadraticCurveTo(t,n+r,t,n+r-a.roundRect),e.lineTo(t,n+a.roundRect),e.quadraticCurveTo(t,n,t+a.roundRect,n),e.closePath();e.stroke()}function Tx(e,t=[],n){if(!(t===void 0||t.length===0)){e.beginPath(),e.moveTo(t[0][0],t[0][1]);for(let s of t){let r=s[2]||0;e.strokeStyle=n.useDepth&&r?`rgba(${127.5+2*r}, ${127.5-2*r}, 255, 0.3)`:n.color,e.fillStyle=n.useDepth&&r?`rgba(${127.5+2*r}, ${127.5-2*r}, 255, 0.3)`:n.color,e.lineTo(s[0],Math.round(s[1]))}e.stroke(),n.fillPolygons&&(e.closePath(),e.fill())}}function Pd(e,t=[],n){if(!(t===void 0||t.length===0)){if(!n.useCurves||t.length<=2){Tx(e,t,n);return}e.moveTo(t[0][0],t[0][1]);for(let s=0;s<t.length-2;s++){let r=(t[s][0]+t[s+1][0])/2,a=(t[s][1]+t[s+1][1])/2;e.quadraticCurveTo(t[s][0],t[s][1],r,a)}e.quadraticCurveTo(t[t.length-2][0],t[t.length-2][1],t[t.length-1][0],t[t.length-1][1]),e.stroke(),n.fillPolygons&&(e.closePath(),e.fill())}}async function Nx(e,t,n){let s=xn(Vr,n);if(!t||!e)return;let r=xi(e);r.font=s.font,r.fillStyle=s.color;let a=1;for(let o=0;o<t.length;o++){let i=[],l=[];if([i,l]=Object.entries(t[o]),l.length>1&&l[1].length>0){let u=i[1]>0?`#${i[1]}`:"",c=`${i[0]} ${u}: ${l[1]}`;s.shadowColor&&s.shadowColor!==""&&(r.fillStyle=s.shadowColor,r.fillText(c,8,2+a*s.lineHeight)),r.fillStyle=s.labelColor,r.fillText(c,6,0+a*s.lineHeight),a+=1}}}async function Ex(e,t,n){var a,o,i,l;let s=xn(Vr,n);if(!t||!e)return;let r=xi(e);for(let u of t){r.font=s.font,r.strokeStyle=s.color,r.fillStyle=s.color,s.drawBoxes&&Od(r,u.box[0],u.box[1],u.box[2],u.box[3],s);let c=[];if(c.push(`face: ${Math.trunc(100*u.score)}%`),u.genderScore&&c.push(`${u.gender||""} ${Math.trunc(100*u.genderScore)}%`),u.age&&c.push(`age: ${u.age||""}`),u.iris&&c.push(`distance: ${u.iris}`),u.emotion&&u.emotion.length>0){let d=u.emotion.map(p=>`${Math.trunc(100*p.score)}% ${p.emotion}`);d.length>3&&(d.length=3),c.push(d.join(" "))}u.rotation&&u.rotation.angle&&u.rotation.gaze&&(u.rotation.angle.roll&&c.push(`roll: ${T0(u.rotation.angle.roll)}\xB0 yaw:${T0(u.rotation.angle.yaw)}\xB0 pitch:${T0(u.rotation.angle.pitch)}\xB0`),u.rotation.gaze.bearing&&c.push(`gaze: ${T0(u.rotation.gaze.bearing)}\xB0`)),c.length===0&&c.push("face"),r.fillStyle=s.color;for(let d=c.length-1;d>=0;d--){let p=Math.max(u.box[0],0),h=d*s.lineHeight+u.box[1];s.shadowColor&&s.shadowColor!==""&&(r.fillStyle=s.shadowColor,r.fillText(c[d],p+5,h+16)),r.fillStyle=s.labelColor,r.fillText(c[d],p+4,h+15)}if(r.lineWidth=1,u.mesh&&u.mesh.length>0){if(s.drawPoints)for(let d of u.mesh)Cx(r,d[0],d[1],d[2],s);if(s.drawPolygons){r.lineWidth=1;for(let d=0;d<mi.length/3;d++){let p=[mi[d*3+0],mi[d*3+1],mi[d*3+2]].map(h=>u.mesh[h]);Tx(r,p,s)}if(u.annotations&&u.annotations.leftEyeIris){r.strokeStyle=s.useDepth?"rgba(255, 200, 255, 0.3)":s.color,r.beginPath();let d=Math.abs(u.annotations.leftEyeIris[3][0]-u.annotations.leftEyeIris[1][0])/2,p=Math.abs(u.annotations.leftEyeIris[4][1]-u.annotations.leftEyeIris[2][1])/2;r.ellipse(u.annotations.leftEyeIris[0][0],u.annotations.leftEyeIris[0][1],d,p,0,0,2*Math.PI),r.stroke(),s.fillPolygons&&(r.fillStyle=s.useDepth?"rgba(255, 255, 200, 0.3)":s.color,r.fill())}if(u.annotations&&u.annotations.rightEyeIris){r.strokeStyle=s.useDepth?"rgba(255, 200, 255, 0.3)":s.color,r.beginPath();let d=Math.abs(u.annotations.rightEyeIris[3][0]-u.annotations.rightEyeIris[1][0])/2,p=Math.abs(u.annotations.rightEyeIris[4][1]-u.annotations.rightEyeIris[2][1])/2;r.ellipse(u.annotations.rightEyeIris[0][0],u.annotations.rightEyeIris[0][1],d,p,0,0,2*Math.PI),r.stroke(),s.fillPolygons&&(r.fillStyle=s.useDepth?"rgba(255, 255, 200, 0.3)":s.color,r.fill())}if(s.drawGaze&&((o=(a=u.rotation)==null?void 0:a.gaze)==null?void 0:o.strength)&&((l=(i=u.rotation)==null?void 0:i.gaze)==null?void 0:l.bearing)&&u.annotations.leftEyeIris&&u.annotations.rightEyeIris&&u.annotations.leftEyeIris[0]&&u.annotations.rightEyeIris[0]){r.strokeStyle="pink",r.beginPath();let d=[u.annotations.leftEyeIris[0][0]+Math.sin(u.rotation.gaze.bearing)*u.rotation.gaze.strength*u.box[3],u.annotations.leftEyeIris[0][1]+Math.cos(u.rotation.gaze.bearing)*u.rotation.gaze.strength*u.box[2]];r.moveTo(u.annotations.leftEyeIris[0][0],u.annotations.leftEyeIris[0][1]),r.lineTo(d[0],d[1]);let p=[u.annotations.rightEyeIris[0][0]+Math.sin(u.rotation.gaze.bearing)*u.rotation.gaze.strength*u.box[3],u.annotations.rightEyeIris[0][1]+Math.cos(u.rotation.gaze.bearing)*u.rotation.gaze.strength*u.box[2]];r.moveTo(u.annotations.rightEyeIris[0][0],u.annotations.rightEyeIris[0][1]),r.lineTo(p[0],p[1]),r.stroke()}}}}}async function Rx(e,t,n){var a;let s=xn(Vr,n);if(!t||!e)return;let r=xi(e);r.lineJoin="round";for(let o=0;o<t.length;o++){if(r.strokeStyle=s.color,r.fillStyle=s.color,r.lineWidth=s.lineWidth,r.font=s.font,s.drawBoxes&&t[o].box&&((a=t[o].box)==null?void 0:a.length)===4&&(Od(r,t[o].box[0],t[o].box[1],t[o].box[2],t[o].box[3],s),s.drawLabels&&(s.shadowColor&&s.shadowColor!==""&&(r.fillStyle=s.shadowColor,r.fillText(`body ${100*t[o].score}%`,t[o].box[0]+3,1+t[o].box[1]+s.lineHeight,t[o].box[2])),r.fillStyle=s.labelColor,r.fillText(`body ${100*t[o].score}%`,t[o].box[0]+2,0+t[o].box[1]+s.lineHeight,t[o].box[2]))),s.drawPoints)for(let i=0;i<t[o].keypoints.length;i++)r.fillStyle=s.useDepth&&t[o].keypoints[i].position[2]?`rgba(${127.5+2*(t[o].keypoints[i].position[2]||0)}, ${127.5-2*(t[o].keypoints[i].position[2]||0)}, 255, 0.5)`:s.color,Cx(r,t[o].keypoints[i].position[0],t[o].keypoints[i].position[1],0,s);if(s.drawLabels&&(r.font=s.font,t[o].keypoints))for(let i of t[o].keypoints)r.fillStyle=s.useDepth&&i.position[2]?`rgba(${127.5+2*i.position[2]}, ${127.5-2*i.position[2]}, 255, 0.5)`:s.color,r.fillText(`${i.part} ${Math.trunc(100*i.score)}%`,i.position[0]+4,i.position[1]+4);if(s.drawPolygons&&t[o].keypoints){let i,l=[];l.length=0,i=t[o].keypoints.find(u=>u.part==="leftShoulder"),i&&l.push([i.position[0],i.position[1]]),i=t[o].keypoints.find(u=>u.part==="rightShoulder"),i&&l.push([i.position[0],i.position[1]]),Pd(r,l,s),l.length=0,i=t[o].keypoints.find(u=>u.part==="rightShoulder"),i&&l.push([i.position[0],i.position[1]]),i=t[o].keypoints.find(u=>u.part==="rightHip"),i&&l.push([i.position[0],i.position[1]]),i=t[o].keypoints.find(u=>u.part==="leftHip"),i&&l.push([i.position[0],i.position[1]]),i=t[o].keypoints.find(u=>u.part==="leftShoulder"),i&&l.push([i.position[0],i.position[1]]),l.length===4&&Tx(r,l,s),l.length=0,i=t[o].keypoints.find(u=>u.part==="leftHip"),i&&l.push([i.position[0],i.position[1]]),i=t[o].keypoints.find(u=>u.part==="leftKnee"),i&&l.push([i.position[0],i.position[1]]),i=t[o].keypoints.find(u=>u.part==="leftAnkle"),i&&l.push([i.position[0],i.position[1]]),i=t[o].keypoints.find(u=>u.part==="leftHeel"),i&&l.push([i.position[0],i.position[1]]),i=t[o].keypoints.find(u=>u.part==="leftFoot"),i&&l.push([i.position[0],i.position[1]]),Pd(r,l,s),l.length=0,i=t[o].keypoints.find(u=>u.part==="rightHip"),i&&l.push([i.position[0],i.position[1]]),i=t[o].keypoints.find(u=>u.part==="rightKnee"),i&&l.push([i.position[0],i.position[1]]),i=t[o].keypoints.find(u=>u.part==="rightAnkle"),i&&l.push([i.position[0],i.position[1]]),i=t[o].keypoints.find(u=>u.part==="rightHeel"),i&&l.push([i.position[0],i.position[1]]),i=t[o].keypoints.find(u=>u.part==="rightFoot"),i&&l.push([i.position[0],i.position[1]]),Pd(r,l,s),l.length=0,i=t[o].keypoints.find(u=>u.part==="leftShoulder"),i&&l.push([i.position[0],i.position[1]]),i=t[o].keypoints.find(u=>u.part==="leftElbow"),i&&l.push([i.position[0],i.position[1]]),i=t[o].keypoints.find(u=>u.part==="leftWrist"),i&&l.push([i.position[0],i.position[1]]),i=t[o].keypoints.find(u=>u.part==="leftPalm"),i&&l.push([i.position[0],i.position[1]]),Pd(r,l,s),l.length=0,i=t[o].keypoints.find(u=>u.part==="rightShoulder"),i&&l.push([i.position[0],i.position[1]]),i=t[o].keypoints.find(u=>u.part==="rightElbow"),i&&l.push([i.position[0],i.position[1]]),i=t[o].keypoints.find(u=>u.part==="rightWrist"),i&&l.push([i.position[0],i.position[1]]),i=t[o].keypoints.find(u=>u.part==="rightPalm"),i&&l.push([i.position[0],i.position[1]]),Pd(r,l,s)}}}async function Dx(e,t,n){let s=xn(Vr,n);if(!t||!e)return;let r=xi(e);r.lineJoin="round",r.font=s.font;for(let a of t){if(s.drawBoxes&&(r.strokeStyle=s.color,r.fillStyle=s.color,Od(r,a.box[0],a.box[1],a.box[2],a.box[3],s),s.drawLabels&&(s.shadowColor&&s.shadowColor!==""&&(r.fillStyle=s.shadowColor,r.fillText("hand",a.box[0]+3,1+a.box[1]+s.lineHeight,a.box[2])),r.fillStyle=s.labelColor,r.fillText("hand",a.box[0]+2,0+a.box[1]+s.lineHeight,a.box[2])),r.stroke()),s.drawPoints&&a.keypoints&&a.keypoints.length>0)for(let o of a.keypoints)r.fillStyle=s.useDepth?`rgba(${127.5+2*o[2]}, ${127.5-2*o[2]}, 255, 0.5)`:s.color,Cx(r,o[0],o[1],0,s);if(s.drawLabels){let o=(i,l)=>{!i||(r.fillStyle=s.useDepth?`rgba(${127.5+2*i[i.length-1][2]}, ${127.5-2*i[i.length-1][2]}, 255, 0.5)`:s.color,r.fillText(l,i[i.length-1][0]+4,i[i.length-1][1]+4))};r.font=s.font,o(a.annotations.index,"index"),o(a.annotations.middle,"middle"),o(a.annotations.ring,"ring"),o(a.annotations.pinky,"pinky"),o(a.annotations.thumb,"thumb"),o(a.annotations.palm,"palm")}if(s.drawPolygons){let o=i=>{if(!!i)for(let l=0;l<i.length;l++)r.beginPath(),r.strokeStyle=s.useDepth?`rgba(${127.5+2*i[l][2]}, ${127.5-2*i[l][2]}, 255, 0.5)`:s.color,r.moveTo(i[l>0?l-1:0][0],i[l>0?l-1:0][1]),r.lineTo(i[l][0],i[l][1]),r.stroke()};r.lineWidth=s.lineWidth,o(a.annotations.index),o(a.annotations.middle),o(a.annotations.ring),o(a.annotations.pinky),o(a.annotations.thumb)}}}async function _x(e,t,n){let s=xn(Vr,n);if(!t||!e)return;let r=xi(e);r.lineJoin="round",r.font=s.font;for(let a of t)if(s.drawBoxes){if(r.strokeStyle=s.color,r.fillStyle=s.color,Od(r,a.box[0],a.box[1],a.box[2],a.box[3],s),s.drawLabels){let o=`${a.label} ${Math.round(100*a.score)}%`;s.shadowColor&&s.shadowColor!==""&&(r.fillStyle=s.shadowColor,r.fillText(o,a.box[0]+3,1+a.box[1]+s.lineHeight,a.box[2])),r.fillStyle=s.labelColor,r.fillText(o,a.box[0]+2,0+a.box[1]+s.lineHeight,a.box[2])}r.stroke()}}async function dI(e,t,n){let s=xn(Vr,n);if(!t||!e)return;let r=xi(e);r.lineJoin="round",r.font=s.font;for(let a=0;a<t.length;a++)if(s.drawBoxes){if(r.strokeStyle=s.color,r.fillStyle=s.color,Od(r,t[a].box[0],t[a].box[1],t[a].box[2],t[a].box[3],s),s.drawLabels){let o=`person #${a}`;s.shadowColor&&s.shadowColor!==""&&(r.fillStyle=s.shadowColor,r.fillText(o,t[a].box[0]+3,1+t[a].box[1]+s.lineHeight,t[a].box[2])),r.fillStyle=s.labelColor,r.fillText(o,t[a].box[0]+2,0+t[a].box[1]+s.lineHeight,t[a].box[2])}r.stroke()}}async function pI(e,t){if(!e||!t)return;xi(t).drawImage(e,0,0)}async function hI(e,t,n){if(!t||!t.performance||!t||!e)return null;let s=Ze(),r=xn(Vr,n),a=Promise.all([Ex(e,t.face,r),Rx(e,t.body,r),Dx(e,t.hand,r),_x(e,t.object,r),Nx(e,t.gesture,r)]);return t.performance.draw=Math.trunc(Ze()-s),a}function fI(e,t,n,s,r){var i,l,u,c,d,p,h,f,m,g,A,y,x,b,v,k;let a=0,o=[];for(let S of e){let C={id:a++,face:S,body:null,hands:{left:null,right:null},gestures:[],box:[0,0,0,0]};for(let P of t)S.box[0]>P.box[0]&&S.box[0]<P.box[0]+P.box[2]&&S.box[1]+S.box[3]>P.box[1]&&S.box[1]+S.box[3]<P.box[1]+P.box[3]&&(C.body=P);if(C.body)for(let P of n)P.box[0]+P.box[2]>C.body.box[0]&&P.box[0]+P.box[2]<C.body.box[0]+C.body.box[2]&&P.box[1]+P.box[3]>C.body.box[1]&&P.box[1]+P.box[3]<C.body.box[1]+C.body.box[3]&&C.hands&&(C.hands.left=P),P.box[0]<C.body.box[0]+C.body.box[2]&&P.box[0]>C.body.box[0]&&P.box[1]+P.box[3]>C.body.box[1]&&P.box[1]+P.box[3]<C.body.box[1]+C.body.box[3]&&C.hands&&(C.hands.right=P);for(let P of s)P.face!==void 0&&P.face===S.id?(i=C.gestures)==null||i.push(P):P.iris!==void 0&&P.iris===S.id?(l=C.gestures)==null||l.push(P):P.body!==void 0&&P.body===((u=C.body)==null?void 0:u.id)?(c=C.gestures)==null||c.push(P):P.hand!==void 0&&P.hand===((p=(d=C.hands)==null?void 0:d.left)==null?void 0:p.id)?(h=C.gestures)==null||h.push(P):P.hand!==void 0&&P.hand===((m=(f=C.hands)==null?void 0:f.right)==null?void 0:m.id)&&((g=C.gestures)==null||g.push(P));let D=[],O=[],E=P=>{P&&P.length===4&&(D.push(P[0],P[0]+P[2]),O.push(P[1],P[1]+P[3]))};E((A=C.face)==null?void 0:A.box),E((y=C.body)==null?void 0:y.box),E((b=(x=C.hands)==null?void 0:x.left)==null?void 0:b.box),E((k=(v=C.hands)==null?void 0:v.right)==null?void 0:k.box);let R=Math.min(...D),T=Math.min(...O);C.box=[R,T,Math.max(...D)-R,Math.max(...O)-T],r&&r[1]&&r[2]&&(C.boxRaw=[C.box[0]/r[2],C.box[1]/r[1],C.box[2]/r[2],C.box[3]/r[1]]),o.push(C)}return o}var Pe={face:[],body:[],hand:[],gesture:[],object:[],persons:[],performance:{},timestamp:0};function mI(e){var s,r,a,o,i,l,u,c,d,p,h,f,m,g,A,y,x,b,v,k,S;if(!e)return{face:[],body:[],hand:[],gesture:[],object:[],persons:[],performance:{},timestamp:0};let t=Date.now()-e.timestamp,n=t<1e3?8-Math.log(t+1):1;if(Pe.canvas=e.canvas,!Pe.body||e.body.length!==Pe.body.length)Pe.body=JSON.parse(JSON.stringify(e.body));else for(let C=0;C<e.body.length;C++){let D=e.body[C].box.map((R,T)=>((n-1)*Pe.body[C].box[T]+R)/n),O=e.body[C].boxRaw.map((R,T)=>((n-1)*Pe.body[C].boxRaw[T]+R)/n),E=e.body[C].keypoints.map((R,T)=>({score:R.score,part:R.part,position:[Pe.body[C].keypoints[T]?((n-1)*Pe.body[C].keypoints[T].position[0]+R.position[0])/n:R.position[0],Pe.body[C].keypoints[T]?((n-1)*Pe.body[C].keypoints[T].position[1]+R.position[1])/n:R.position[1]],positionRaw:[Pe.body[C].keypoints[T]?((n-1)*Pe.body[C].keypoints[T].positionRaw[0]+R.positionRaw[0])/n:R.position[0],Pe.body[C].keypoints[T]?((n-1)*Pe.body[C].keypoints[T].positionRaw[1]+R.positionRaw[1])/n:R.position[1]]}));Pe.body[C]={...e.body[C],box:D,boxRaw:O,keypoints:E}}if(!Pe.hand||e.hand.length!==Pe.hand.length)Pe.hand=JSON.parse(JSON.stringify(e.hand));else for(let C=0;C<e.hand.length;C++){let D=e.hand[C].box.map((P,U)=>((n-1)*Pe.hand[C].box[U]+P)/n),O=e.hand[C].boxRaw.map((P,U)=>((n-1)*Pe.hand[C].boxRaw[U]+P)/n),E=e.hand[C].keypoints?e.hand[C].keypoints.map((P,U)=>P.map((j,q)=>((n-1)*Pe.hand[C].keypoints[U][q]+j)/n)):[],R=Object.keys(e.hand[C].annotations),T={};for(let P of R)T[P]=e.hand[C].annotations[P].map((U,j)=>U.map((q,X)=>((n-1)*Pe.hand[C].annotations[P][j][X]+q)/n));Pe.hand[C]={...e.hand[C],box:D,boxRaw:O,keypoints:E,annotations:T}}if(!Pe.face||e.face.length!==Pe.face.length)Pe.face=JSON.parse(JSON.stringify(e.face));else for(let C=0;C<e.face.length;C++){let D=e.face[C].box.map((R,T)=>((n-1)*Pe.face[C].box[T]+R)/n),O=e.face[C].boxRaw.map((R,T)=>((n-1)*Pe.face[C].boxRaw[T]+R)/n),E={matrix:[0,0,0,0,0,0,0,0,0],angle:{roll:0,yaw:0,pitch:0},gaze:{bearing:0,strength:0}};E.matrix=(s=e.face[C].rotation)==null?void 0:s.matrix,E.angle={roll:((n-1)*(((a=(r=Pe.face[C].rotation)==null?void 0:r.angle)==null?void 0:a.roll)||0)+(((i=(o=e.face[C].rotation)==null?void 0:o.angle)==null?void 0:i.roll)||0))/n,yaw:((n-1)*(((u=(l=Pe.face[C].rotation)==null?void 0:l.angle)==null?void 0:u.yaw)||0)+(((d=(c=e.face[C].rotation)==null?void 0:c.angle)==null?void 0:d.yaw)||0))/n,pitch:((n-1)*(((h=(p=Pe.face[C].rotation)==null?void 0:p.angle)==null?void 0:h.pitch)||0)+(((m=(f=e.face[C].rotation)==null?void 0:f.angle)==null?void 0:m.pitch)||0))/n},E.gaze={bearing:((n-1)*(((A=(g=Pe.face[C].rotation)==null?void 0:g.gaze)==null?void 0:A.bearing)||0)+(((x=(y=e.face[C].rotation)==null?void 0:y.gaze)==null?void 0:x.bearing)||0))/n,strength:((n-1)*(((v=(b=Pe.face[C].rotation)==null?void 0:b.gaze)==null?void 0:v.strength)||0)+(((S=(k=e.face[C].rotation)==null?void 0:k.gaze)==null?void 0:S.strength)||0))/n},Pe.face[C]={...e.face[C],rotation:E,box:D,boxRaw:O}}if(!Pe.object||e.object.length!==Pe.object.length)Pe.object=JSON.parse(JSON.stringify(e.object));else for(let C=0;C<e.object.length;C++){let D=e.object[C].box.map((E,R)=>((n-1)*Pe.object[C].box[R]+E)/n),O=e.object[C].boxRaw.map((E,R)=>((n-1)*Pe.object[C].boxRaw[R]+E)/n);Pe.object[C]={...e.object[C],box:D,boxRaw:O}}if(e.persons){let C=e.persons;if(!Pe.persons||C.length!==Pe.persons.length)Pe.persons=JSON.parse(JSON.stringify(C));else for(let D=0;D<C.length;D++)Pe.persons[D].box=C[D].box.map((O,E)=>((n-1)*Pe.persons[D].box[E]+O)/n)}return e.gesture&&(Pe.gesture=e.gesture),e.performance&&(Pe.performance=e.performance),Pe}var Ft={name:"humangl",priority:999,canvas:null,gl:null,extensions:[],webGLattr:{alpha:!1,antialias:!1,premultipliedAlpha:!1,preserveDrawingBuffer:!1,depth:!1,stencil:!1,failIfMajorPerformanceCaveat:!1,desynchronized:!0}};function _le(){let e=Ft.gl;!e||(Ft.extensions=e.getSupportedExtensions())}async function gI(e){var t;if(Ft.name in Qn().registry&&(!Ft.gl||!Ft.gl.getParameter(Ft.gl.VERSION))&&(ie("error: humangl backend invalid context"),Ix(e)),!Hg(Ft.name)){try{Ft.canvas=await Xn(100,100)}catch(s){ie("error: cannot create canvas:",s);return}try{Ft.gl=(t=Ft.canvas)==null?void 0:t.getContext("webgl2",Ft.webGLattr),Ft.canvas&&(Ft.canvas.addEventListener("webglcontextlost",async s=>{throw ie("error: humangl:",s.type),ie("possible browser memory leak using webgl"),e.emit("error"),new Error("browser webgl error")}),Ft.canvas.addEventListener("webglcontextrestored",s=>{ie("error: humangl context restored:",s)}),Ft.canvas.addEventListener("webglcontextcreationerror",s=>{ie("error: humangl context create:",s)}))}catch(s){ie("error: cannot get WebGL context:",s);return}try{Lf(2,Ft.gl)}catch(s){ie("error: cannot set WebGL context:",s);return}let n=ia().getGPGPUContext().gl;n?ie(`humangl webgl version:${n.getParameter(n.VERSION)} renderer:${n.getParameter(n.RENDERER)}`):ie("error: no current context:",n,Ft.gl);try{let s=new Xf(Ft.gl);Vl(Ft.name,()=>new vu(s),Ft.priority)}catch(s){ie("error: cannot register WebGL backend:",s);return}try{ta("webgl").forEach(r=>{let a={...r,backendName:Ft.name};Fo(a)})}catch(s){ie("error: cannot update WebGL backend registration:",s);return}try{nr.set("WEBGL_VERSION",2)}catch(s){ie("error: cannot set WebGL backend flags:",s);return}_le(),ie("backend registered:",Ft.name)}}async function N0(e){if(de.initial||e.config.backend&&e.config.backend.length>0&&Cr()!==e.config.backend){let t=Ze();if(e.state="backend",e.config.backend&&e.config.backend.length>0){if(typeof window=="undefined"&&typeof WorkerGlobalScope!="undefined"&&e.config.debug&&e.config.debug&&ie("running inside web worker"),de.browser&&e.config.backend==="tensorflow"&&(e.config.debug&&ie("override: backend set to tensorflow while running in browser"),e.config.backend="humangl"),de.node&&(e.config.backend==="webgl"||e.config.backend==="humangl")&&(e.config.debug&&ie(`override: backend set to ${e.config.backend} while running in nodejs`),e.config.backend="tensorflow"),de.browser&&e.config.backend==="webgpu")if(typeof navigator=="undefined"||typeof navigator.gpu=="undefined")ie("override: backend set to webgpu but browser does not support webgpu"),e.config.backend="humangl";else{let s=await navigator.gpu.requestAdapter();e.config.debug&&ie("enumerated webgpu adapter:",s)}e.config.backend==="humangl"&&await gI(e);let n=Object.keys(Qn().registryFactory);if(e.config.debug&&ie("available backends:",n),n.includes(e.config.backend)||(ie(`error: backend ${e.config.backend} not found in registry`),e.config.backend=de.node?"tensorflow":"humangl",e.config.debug&&ie(`override: setting backend ${e.config.backend}`)),e.config.debug&&ie("setting backend:",e.config.backend),e.config.backend==="wasm"){if(e.config.debug&&ie("wasm path:",e.config.wasmPath),typeof(fi==null?void 0:fi.setWasmPaths)!="undefined")await a8(e.config.wasmPath);else throw new Error("wasm backend is not loaded");let s=await Y().getAsync("WASM_HAS_SIMD_SUPPORT"),r=await Y().getAsync("WASM_HAS_MULTITHREAD_SUPPORT");e.config.debug&&ie(`wasm execution: ${s?"SIMD":"no SIMD"} ${r?"multithreaded":"singlethreaded"}`),e.config.debug&&!s&&ie("warning: wasm simd support is not enabled")}try{await pb(e.config.backend),await uh()}catch(s){return ie("error: cannot set backend:",e.config.backend,s),!1}}if(Cr()==="humangl"){nr.set("CHECK_COMPUTATION_FOR_ERRORS",!1),nr.set("WEBGL_CPU_FORWARD",!0),nr.set("WEBGL_PACK_DEPTHWISECONV",!1),nr.set("WEBGL_USE_SHAPES_UNIFORMS",!0),typeof e.config.deallocate!="undefined"&&e.config.deallocate&&(ie("changing webgl: WEBGL_DELETE_TEXTURE_THRESHOLD:",!0),nr.set("WEBGL_DELETE_TEXTURE_THRESHOLD",0));let n=await ia().getGPGPUContext().gl;e.config.debug&&ie(`gl version:${n.getParameter(n.VERSION)} renderer:${n.getParameter(n.RENDERER)}`)}db(),await uh(),e.performance.backend=Math.trunc(Ze()-t),e.config.backend=Cr(),h0(),e.env=de}return!0}var $x="2.2.2";var E0=`
|
|
/9j/4AAQSkZJRgABAQEAYABgAAD/4QBoRXhpZgAATU0AKgAAAAgABAEaAAUAAAABAAAAPgEbAAUA
|
|
AAABAAAARgEoAAMAAAABAAIAAAExAAIAAAARAAAATgAAAAAAAABgAAAAAQAAAGAAAAABcGFpbnQu
|
|
bmV0IDQuMi4xMwAA/9sAQwAGBAUGBQQGBgUGBwcGCAoQCgoJCQoUDg8MEBcUGBgXFBYWGh0lHxob
|
|
IxwWFiAsICMmJykqKRkfLTAtKDAlKCko/9sAQwEHBwcKCAoTCgoTKBoWGigoKCgoKCgoKCgoKCgo
|
|
KCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgo/8AAEQgBAAEAAwEhAAIRAQMRAf/E
|
|
AB8AAAEFAQEBAQEBAAAAAAAAAAABAgMEBQYHCAkKC//EALUQAAIBAwMCBAMFBQQEAAABfQECAwAE
|
|
EQUSITFBBhNRYQcicRQygZGhCCNCscEVUtHwJDNicoIJChYXGBkaJSYnKCkqNDU2Nzg5OkNERUZH
|
|
SElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6g4SFhoeIiYqSk5SVlpeYmZqio6Slpqeoqaqys7S1
|
|
tre4ubrCw8TFxsfIycrS09TV1tfY2drh4uPk5ebn6Onq8fLz9PX29/j5+v/EAB8BAAMBAQEBAQEB
|
|
AQEAAAAAAAABAgMEBQYHCAkKC//EALURAAIBAgQEAwQHBQQEAAECdwABAgMRBAUhMQYSQVEHYXET
|
|
IjKBCBRCkaGxwQkjM1LwFWJy0QoWJDThJfEXGBkaJicoKSo1Njc4OTpDREVGR0hJSlNUVVZXWFla
|
|
Y2RlZmdoaWpzdHV2d3h5eoKDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXG
|
|
x8jJytLT1NXW19jZ2uLj5OXm5+jp6vLz9PX29/j5+v/aAAwDAQACEQMRAD8A+qaKACigApGOKAML
|
|
Xp8xlF5A7V4X8RtYs7PzfNImnx8sa8Kp9z3q2tEgp6angWs62ZZ5CTGoJ6DArGNz5p+UrID6EUrF
|
|
PUlW1EuN0XNW7PQ2L5j3JnoKXN0KijqNP0eYoqXBdgPuuo+ZPeupisWn2Jd4+0r924XgsQOCff3/
|
|
AJ1FzRKxDqGii6m3siiQ8F1XGfXI6YNWLfRbiRQMkcZI9fpTDluT2/h6Qy8gDPbtmtG38JeY480Z
|
|
5zSLUTZg8M28YwYxjAArXtdPt402qgHbpSaLWhma3o0Uqk7Nx9DWLaaVblgPs6qRyds2M/gRSQp9
|
|
zZOni2iWS2hlQ+kjYz9OMGrdjq89vIPPVhj+8M/lQyDq9P1WOYBlMZz1AOD+VdDaTiReOKulK0jO
|
|
tHmi0WDTlr0TyxRVhT8tJjIX+9SUxHXUV553BRQAVBcPhSBTSuxPY86+IGti0s5I7dsORy9fM3i6
|
|
8e8mfDO5P90ZrWWiJicNPpZZtxV/xrW0jQt4DOv6Vk2dEEdTY6BHuB25rpbPSo0QARjP0qTRI17W
|
|
wA/hFaMWmoQMgflQXYsDS142rU9tpqqenfNA7GgtihxkdKuRW6qMY/GkDZY8sY4Ap4hXbyB+VArk
|
|
EtuH4wPyrk/EGkOm+a3jw3suRQLc5i38SX9hJ9nnY+XnBUdPyNdFY6pa3KkkAE9l6f8AfJ/pSJT6
|
|
GhDmI+Zb4ZRycdv6ium0nUhKFydrelTsNnS2829RnrVgV6NKXNG55lWPLIM81Op+WrZkRMfmNNzT
|
|
A7GivPO4KKAEY4XNYWt3vkwPg4OK0giJdjw/xrqhm87Zs8tc7pX5A+leSajf6aHYJ50kn4AZpTep
|
|
rBWRm2Vobm4BXfyehPFdnpmnBFUY5rI2SN63tlToK0YI+KZpFF+3QdavwoKTLtoW0Toaswpk5pCb
|
|
LCxipAhoIuP2dKevHXoaYDylRyxhlwRQI4nxVoCXWZI1GfpXGtbSWjYPGP73+NIGupt6TqMsLruZ
|
|
ih4xnP5V09mQ+JLd8gn0xSYJnVaVdkook69K34zuUGunDS3Rx4qOzHVIp4rrOMY3NJQI7GivPO8K
|
|
KAILt9kZrz3xlebYiu8KCCWb0XvW0NFch6ysfO3jLVjfXLIn+pQkKorl7WxNxIPl71g2dUUdpo+l
|
|
pBGvHPet23iC8ihFosrxirkHQUFo0IF4FXI1O726CpKLacCrMJoJLYHAPpTwucHpSRJJ5e4AZI9x
|
|
UqpxzVpCuOC8cUpQUMRnXttuB4rjNdsYyeVwfXpmpGmcvcQyafMCFJjPY10eg34BUg4DcZP8jUO4
|
|
HaRq3lLNF+IHet7R7jz7c56rwa2wz9+xhiVeFy/T1PFegeaNPWigDsc0ZrzzvDNIaAM7VpNqdegr
|
|
xL4l6kywyRhseZ19lrdfAZL4jxYg3Fw20d63tJsdrDI5rm3Z3R0R0Mce1eKnQYAplIkWrMJ45oZS
|
|
NO3PHbNXIyfpSGWowSOasxLUiZdjFSqtNEMkUemKlAGKsRJjAppFAiORMjmsTVrNZEO4cfSoZSOD
|
|
1eJ7WXBUzQZ+7nkfSo7e2Ei+ZaMzxntjBX2NSU1Y6/wxqojiEFzkA8KTXYaUoWRyv3W5rSjpNHPX
|
|
+BmpSg8V6J5gUUAdhRXnneFFAGHrTfu5PpXzj8S70/aZtxzztXFbv4DKHxHI+H4GZiz9zxXXW8G3
|
|
GBXMjvLRXAx0oPGPSmMVeOnWrMTYpFI0bcg1fh54xmgovRcD3qxETSIZcRvzp+/BpEkqsBUqsM9K
|
|
q4Em4Gkxk0yRGXrVW6i8yFhkg+tJjRxGsWrxllkUMh9eK5uMz6bcebbnfG33kPcVkay2OntPKuo0
|
|
nhXI67c8qa7Lw3c+adjcEDGK1paSRhVV4s6A0or0jyRRQ1AHX0V553hRQBz+vNtt5z3xXzX8Qbdm
|
|
uic5YnOMdK3l8JnTXvlbwpYl+WySOgrp5YfLOOB9O1c62O7qQkc+9RsKChFPWp4DluOlSykaNruH
|
|
ArUgHShFNF2NT1qxGO3NBmyxGcE1N2560CFzjrUysO9JAPDDjFOVuKoQuSRTWouBkazbCa3cd8cV
|
|
wF7IISQccHBzUSWpV9C3o1x5b5GAjdQD1rs9DjC3kckbEhqKfxIzn8LOupRXqnkPccBSkUAzraK8
|
|
87wooA5rxMSI3HqK8B8bQl9Q8sffY5b/AAraXwkUviNrw9pH2W1ViMMRTdRjw4HpWNtDti9TPc4P
|
|
FQs2M5qdyyMHLcfjV63HTAoBGtap0wK0YxigpsuRDtVhVYd6GQydVwwIqdRnqKCR23I5pCMUW6gD
|
|
YNKuetAEise9KTxQBWuFyhrznxNZkXjFeN3I+tTIZg2OqmzmxNF0PO3vXp/g2+hukVl4zyPanTXv
|
|
JmVR+60dpThXpnlPceopWFAbnV0V553hSGgRynjC5FujOey14Ssp1HxNmTnc+a3kvcIpv37HoEYQ
|
|
QmMdVHSsnVbYJF5jVk0dsNzlruVIsl2wKxbjWrVHILjg1CRbZJb+ILHPzyhfStODWLQgFJFYd+el
|
|
UJM27HUIXxhga1Y5lLVLKLkMnoauxnPPrSEx7ShF+Y/n2qrc6xBbhizDAqkK1zJuvG9nbg8ZA681
|
|
ly/Ei052RO3uKAsZlx8QGd8xxvt9Aa1NH8dK7AXMcip64zigdkdrZX8F7EJLdwwNXMkrz1qRMRly
|
|
CK4TxmpidWI49felPYSOMmi80NIoOV6qRzXYeA5SskYPfirpfEjGr8LPWVHyD6U4CvQPL3ZItOYc
|
|
UDOoNFeed4Uhpks4H4iE/Z5MeleMeGULeLgjds10S+BGdL+Jc9OSBU2Huc5Nc74yvUtrcDBrJnZF
|
|
63PJdXvLy/lKWw46bvQVz82jXhkLO5Y+9ZlsYthcRnbIjY9R3q3awTRkEM3WmJI6C0ea3dGRsr1x
|
|
XY6TqW9FLHnjrUs0izpLK5DDjofSta3ckH09KRUkZuuTvFGdvPauE1Y3U6Mqbssf/rUxHPTaJPK2
|
|
ZmJPbBqzY6DCZh5xJC9s9aBJHU6dpemJjfEmfetJtI0+VPkUr/unFOxdiextHs33W07YHQHk11mk
|
|
Xb3KbZ1xIvcd6LEyWho4Nct41sTPYb16ipexCPPZN+wYGCvH1rrPAEJmvkPoc1VL4kZVvgZ6yFwK
|
|
cBXoHkkqinFaVyzo80GuE7WJRQSziPiGdthK5HQV4x4J/wBI8WPIewNdEvgRNL42emO/yj1UHNef
|
|
eNpRczbC+I17DvWT2OqJxc0sMK4TCisy41q0hfEkqj8aixdwTXNOlwvmqD9anS9tXH7uVG+hosO4
|
|
/wC0oOhrR0+6G4YNIEzsNEuCxAPNdjZruA4xxUmjINSjURksOlcbqFykbnjFA1sYGoassaknCqO5
|
|
rl7rxhGm7yBnBxuJq0rkSlYpw+NLlsfd5P8AerVsvHEqSBHwPVgcgVpyMyVXU3rXxcHYETAk+hru
|
|
/DWti6ZSTyOKzZqndHaxvvUGq2rQ+dYyqR24qWI8dvbr7LqDxyDAzXpvw6FvIxePGSM06Xxoyr/A
|
|
zviKFHNegeX1J41zUhXioGbuaSuM6wpCaBHG/EcA6HN/exxXjXw2jL67cv8A3Qa6H8CFR+NnoWpO
|
|
I4XI44rxLxrqjQzSEsQM1gdSPM9U1uR1YbmWIdXHf2rmpIb67YS28UrRlsLI3c/jW0VZGUpO5pW1
|
|
jfLNOjahawzwReYI5cjzMkDavHJ5/SrVv9uhtPtVxCPLBwzxnlT9KGghLU3tKvvPjHzbl7EGuisJ
|
|
GRxWLOg7nRXJEbDjmvSNK+aFSfSoZr0KutRkphc4NcRrdkVjL9aVio7Hk3iqS8ubhrWzUlsZY9kG
|
|
cZNc5D4aee5MclzJIFTzHAO0MfatqSOWu7bFS1srDUZEis0vIZoUxPvfcC+4/dx2xjr712XiTwXb
|
|
WmlQ6hol3cRhoFd4rlg3zY5wR0GelavQwjq7GD4etdVvSnk2wAB+9v8A8mvcfA2kXiRo0/UdcDis
|
|
ZnTTulqeoWqbUAJqWUb42X1FZlnjfjSwlGrr5S/eNdD4RkvLAAQ4yRyaUZcruVKl7TQ9I0G+mnzH
|
|
ckFwM8VuIK7ac3KF2eXiKapz5UWYxipNtMyNejNch0jSar3cjR27uoyQCRVRWom9DxTx54gu5fMi
|
|
lbKdMVjfCZPNlv5v9rFbVHpYqjGzbOn8SzFI9o715L4u0r7arYzk+lYdTqSujy7U/C0u4vHk+WwO
|
|
xuh9q3J9dgvbdVukMV1EwbDDgn04rZMwlHoZ+orZ6hfQ3RWVnQYCgZAq+8U0ln5NtBsV2yxYcfgK
|
|
JtW0CnB31LlroVwJ1nQLGDjeP7w+lb0dsFxjrWB0tHS6NuWPJ6A16ToUm63T3Gallr4S7cxiTjrX
|
|
PaxaF7dlVeSMUhxZ5jd+H7qCa4eF3DSE5x3zXN3Wk6jbyeaiFWUY6ZyPStYS5SalPmVipFbX0E4c
|
|
W0alvmPHJrag0rVvEE6LdljGpG2NRtQD+tW5XMI0uU9M8NeFo9PiQhecDIIrtrOMIoG3H4VlJm9t
|
|
C6CB06VPGM1IHLeItGS6uw+ORT7e3jsbQvj7gzUNam0JaWE+HN7NqOqX80n3FO1RXo8YzXdS+BHk
|
|
4z+KyzGPapcU2YIv7qQtiuaxvcaWqG4O6FwfSrS1JbPnrxoxkv7qIfejcitj4V2f2exumI+8+aKn
|
|
xHTT+G5d8Txlm4rjLxMsQwzWT3OiK0Mm6sEkVsAcjFc1d+FEmlGwEDPQVopaEuOpr6f4ZWNAu3tW
|
|
vHpAj5ZQcUFIWaDjGMVUMQ3cVDBmvbhY7QAV2nh+T/R1yeKhlrY31+b61FcQK6nIoJMi401WblRi
|
|
qr6PCw5UYq9y+YgOgWzNkRrx3xWjp+nx2v3FQcelAbmko9anQ4GBUNisPHWr1qMrQhS2K11HvmYV
|
|
hamcxSRZ5xRIqluS/DKAQQXZxyXrvo2FdlL4EeZjH+/ZbjNSZpswLNBrE1Gt7VE4ODVIlnh/j61F
|
|
j4lmeTGyUbq6LwdEqWbeX0YbhSqfEddP4Bddj4JIrhL5d8h7VjI6oLQqKNzelWre3yc4/ClFjaL6
|
|
wqBxxUUxwCKu5BmXRA6c+9ZjP83FSBoQuPs4BrsNBlUW659KmRrDY6G1lyQtW3Hy0lqQ1qVJnAbm
|
|
oy3b9KYJCqRj3o4zRctIlhjLHmpSuOBRbQOpLGpPFaES7UqkZzKN1KsEc87/AHUUmvPLTVGv72aQ
|
|
k7WJwKmRrQ3ud74Ltilgz4++2a6iNDXdS0gjyMU71my7GpqTbxSbMki3SViajTTHqkSeR/GeyZmg
|
|
nQHkEE1S+F+oPPavBL96I4/Cia1udVF+4dVrkW+Fq8+v4tjMDWUkdVJ6WM0cNV+F+MVmjUcZgqnP
|
|
1qpNNnkcVRLiZtxIS1UzzIF7mghlxUZpVQdq6nTVdAoAOKzkbQWhvwM6gMM1twOJYx3NOJE11Kt1
|
|
H1/pVVlwBkk+9NocXoOQ45FPj+fkUJFF2NSB700v/hTEty5ZpkjvVyUgcCq6GM9zC14/8Se6GcZQ
|
|
1574Xs5WkI2HBPHFQ1dm1KSSZ7Rotn9l0+KPHIHNacae1dy0Vjxaj5ptlhVp+2s2CJ9ppCKzuWNx
|
|
zSFc1SYrHNeNdIGpaYw25ZeRXmvheyk0jVpEdcLJ0q3ZxNKTa0O3vQHg/DNcHrsJDmsmjspnNzNt
|
|
fFIJ24GazOhC+azDmgZIOOKBsp3J2qSaZodubq58yQ4QAnmhGT3NO18pb7BORmu205LfYpyKVkWp
|
|
Oxr5gKYWoIZWgfGfloFq1qTPLubnGO1RPtxg4P0oBAkY/hBz6VNDDkZ6AU0W2WSdqkdKr9ZOaGSj
|
|
VtcLHmnOcgmmYvcz7mBLy3MbdD1q9ouiRK6bUAVeelOC1InPlidSsWMDFOCEdq3uefykqrinYqGy
|
|
rFvApMVka2DAowKAsMkRXQqwyDXn/iWyitNQ3qPl6itIvRoF8RXinW4tQ6HI6GuW8SIVBPalc6qe
|
|
5x9x97r3qruwTjrWZ0ksZ9TUmcDNAmZ9/wAoao63rR0+w22MLPtAzt6mghmfofiB76LdJBJBIp5D
|
|
d/oa7bSdWLIPnpDi9TM8TeKdas51XTbIyxd3J/pXS+E/EFxqNoFu7do5OmD60maHWrnZyDRkn/69
|
|
MlEyOR0xntVoNx+FUgYjPxg4FLCuWDZyKQr2RoRnP0qO+nEFpJITgAUzLqZnhu6+0rknOTXpOmwJ
|
|
Fbrt5yMmnHYyr6Oxb2ijaKLnPYMClwKQWK3n0hn+lachHOJ9pNNN0apQFzsY10a4v4hXQh0xpieQ
|
|
MA1XLZNjhK80cT8OdV+3Wl3A7ZZJCw+hrR1qLcjZ/CsbnfHRnFXseHJArOYYbrUs1uPhYbuatqFP
|
|
ByfSkMq3UIINYkto+87Tx6GkSxfsDbflGD7CtTw/pk4nzITtPIFMFudsukh4Rxz71paTpKwP5jcn
|
|
0qTRy0NORMDgVCqewoJTJgAoxjntTiTu7fWmFxAcnn1q3EPl+X8KZMi4gKqB1Peob/Tv7Us5bfeU
|
|
yOoq4R5nYxqT5I8xieH9J1DTbvyJELRg8ODwa9Ms5mSFV9BWiptbnNVrKdmif7Q1KLg96XIZc5Is
|
|
pNL5pqeUrmMtZs0jzV08phchaY00zH1p2ZNxjS1g+LdJOt6U9ssmxjyGp2urDjLlaZzng/wUPDqz
|
|
TSTmWeTrjpVjVk3Rvjr2rnqQ5dDvo1XUd2cTqSNk9OKxXGCeKxZ1DAxHTr2q5C/y8GokUhsz54qu
|
|
uCxzSQjQ0+FZblR2ro4bZYiMVQ0dBb7Qi5x0qzuG5QOh71LYErDufpSeWrHnimIXbjkUjLkH1Hem
|
|
gGxryc+tXI19KYmWegq9YLiLJ7mtqS945cS7QsWehqxA9dEjz4krPSxyZqbFFhGxUm6smjRM55Lk
|
|
HvSvNxXTY57kLT+9MNwKdhXGm5FIbkU7Bca1wMEVhaiuQcVhXWiZ14R6tHGanGBI2OtYkqEHjgVy
|
|
s9ErEeo6UBsHipKEZs5qpPdRxcbhx70NCSuybTNWihc5brW9Fq6vjMnFSdEIdDRi8RRKygZbHFbu
|
|
m6nb3RA3gMegNJhOm0jbXGOoxTuCc1Rz3FyoGKawz9KaAVcZqeMgCmIkB4FaUTbYwB6V00Fuzixb
|
|
0SFMuDU8Mlbs4UPeXHeiOXkUrDuXYnyKk3cVk0ap6HMxxketSMhrcwRC0dMMZFMQ3yzSeVQAeUaz
|
|
9Vj8uPd271nVV4m+GdpnHX67pCeKyLtBtNcR6xlk9RVeWTb3qRnO6trgttyIfm71z7ai8j7/AJmN
|
|
DNqUVa5Yi1AnjynHuBV+11YJhWWXcP8AZNSzqgmaEerSsf3NtIQP4mGKtRavdRgMIpVI9KjU0a7n
|
|
R6T43uYQI7qN2Tpkqciu503VVuQGAYZHQjFVc4alPlZrpKGAznpTwxOc9+lWjIlUACnM4XApiLNk
|
|
nmvnsK0NvpXZRVonmYqV52GsmanhXitTmFkSiJTSAvwrxUxXIrJ7miOfjf1pzNWxkRlqYWpgJupu
|
|
6gQbuahvIxPA6eo4pNXVioS5WmefakGhndH4INZs5DJXA10PaTurmLO21uKpSZqGMoXGnRzBiyjd
|
|
9Kx5rcQS428fSkjanLoaOliHGZFB56VswW+mtPufcBsGOAfmxz+tFkd8HpoaUx09FAtFY8DO71qb
|
|
Sms/Nb7RbecG6AEjFLS5c78t+p0djpVs9wsyQiJAdyr1rW+zqjErzSe559Sbk9S3C+MA1bjbgE1S
|
|
MSXzMVG0vNUI2tPKrAuCMnrVzNd0PhR49W/O2xrHmp4TxVMzQshpIzzQBehqesnuaI5VGzT2bitz
|
|
FEbNTC1ADS1JupgG6l3UAc14s04yR/aYRll+8BXCtLncDXFWjys9TCz5oW7GddH5qqNzWDOgQnC8
|
|
VSuo1kHzAGkPYopEY2+RWxV23Vzj5G/Kg3jWaNazhZuqNXS6TaKhB2c0jR1nJWOlhOxRxU4YkCgx
|
|
Y0OQatQyDbyaaFYe8uF4NY3iC9ltbVGj43NTIL3h7WzMihjzXVQXYYDdW9Cf2WcOJpfaRZ3g9KsQ
|
|
mupnCLIabGeaAL0LcVY3cVmzRHIxtUhetzEjZqjLUAIWpN1ArhupwagAfDKQ3Q1594v0c2bm6tx+
|
|
5Y8j+6ayrR5onThp8s7dzkZjuqAAmuBnqC7c0iwgtzSA0rWzjfGRW3ZadDu4AoNYo2rfS4v7orSh
|
|
05UA2r0pDbsTm29KRottBNyJ0wpJ9KhD7f6U0ikNWffIFBz60zVUW52ow4UcUN6EPcx44WsbgOmd
|
|
ua7TT5Bd24KHnFKnLlZFSN4koluLdueRWvp14swweG9DXoxldHlTjYtzGoo25qzEvwtUxas2jRPQ
|
|
5CNqkLVsYoYzUzdQA3dSFqBBmnqaBhuqhriCXTpVIzxUz+Fl03aSPI9QTypW2/dz0qKNw3SvOPZR
|
|
Mqin8VLKRcs3O4Cuk0w/MDjt1NBtHY6O2IIHY1pxgFaETIRwMkjtVSUEk4570MlFW5bap6dKzWm8
|
|
1tqH8aY+hp2FvGoGayNevVt7/ap4xzUvYjqTLtvLPcvJxSaVcyWsxTnFZlnT2t15xHmCtOBYwQy4
|
|
B9q7cPO+jPPxFO2qLEj5HWo42+aus4HpoX4W4FTF+KlotbHII9SFuK0MUNZqiLUDE3UbqBBupwag
|
|
Bc1DefPbyD/ZND2KjujyPWlKzuPesRZjHJXms9lMuw3StjnmphKDSLTJ7OfE3JrpbO4GQc9qlnRA
|
|
3LO82k5NbFvdADkjBoCSHyXIIIzgVQvdRigT7wzjgUzO1jHknlvG7qnp61etYFQDIpCZoqVijzXn
|
|
3iC8EmsOuaCGb/heR/s0ijkVv6fbxy3QMg5xmsnuX0Ldzut3+UYTPWk+2GJSe+M1pFtamcldalmx
|
|
1eO4XaThhWnC+TXqR2PHqL3maUJ4qRjxSEjj42qXdxVmaGs1MJoATfSbqBAG5p6mgAzTJTmNvpQU
|
|
tzzHXY83D/U1zF5FhjgV5r3Pa6FMsV5HWnLe7RhqBRdmTwagN2d2K2rPU1C5LAnPrUs6Iysbdrq6
|
|
f3gK0BrUKj/WClY05iM6xLOcQAj3NT29uznfKSzHuadzNu7NSBFjHNSm5VO9IRnajqoWMhTzXFtA
|
|
bvUfMduSeg702Qz0rS7FbTToQFwzjJqaGTFyfK5PQViyzUuFmuIdgGABya5u/vTaN5cnUHFUmLoZ
|
|
zyskwlgJweSK6zQdUEwVJeGr0aUrxPLxEfe0OrhPAqVjxWhznGRtUwatDK4jNxURbmkAm6jNABup
|
|
6tQAFqhupNtu59qUnZFwV5JHnWsHdIx96w5lz15rzT2uhRmt85xWbcxMnUGmZlB0bdxmrNvFIcfM
|
|
350mWjbs7YkDJY/jW5ZWW4jikWkdNp9mqYJFaJdEHHakUULu/VB1rLn1Ld/FgetMGYd/qWSQmSa0
|
|
/AemS32pfa7piLeLkg9z6UmQtz0W7uQ2cZx0A9BVzR7cAea6j2rPqX0L99KRat5A6Dk1wOoKZ52a
|
|
YfMORTYRLujiGWEq6/NWza2yKQVHNdOHerRy4laJo6TTnbbtb8KuM3Fdh5z3OJjbmpt3FaMxAtUZ
|
|
agBN1GaQBzTwaAAms3VbjERUGsa07RsdeFpuUuY4jUjljWTKK4j02RE4IpJYFk6imQkVl0xWarsO
|
|
mAEcUi0bNnZBR0rWtoguMCkUi21wI161mXuocEKaYXMS4u+pY/hVCSWSY4HT0pEmlouiSahdpEBl
|
|
mOceleiwWcNjClvHgJH97Hc1EmVFFi3Czy7mwIl/WtJbjP7uLgd/apQ2VNVvtsBhiPzdK5S4nAuR
|
|
nqOCaTGi9pcytPlU+XpmumtWII44rah8ZjiNIXRuWeNvvViQ/LXpJWPJbu7nCRvVkNxVsxBmqJmo
|
|
EPiXca0YLMuOlJsuKuPlsSi5IrNuG8s4HWs5VEkbwoOTKsk+FJY4rC1K53k1xTk5O7PSpwVNWRzt
|
|
4cms+WpKICtSLTETQj5q0YeBSGiys23pUguGxQMq3E59ayrm4x3yaAKiRtO2WPHcmhruKFxFajzZ
|
|
ScA44qRHoXhuMaLpxaUg6hcDLMf4F9KlhuDeXGASIl+8azZslYma68y48m1+7nFW5rtbRNhb5z1p
|
|
iMKbUg0zuW4A4rPgb7VdKXOMmpA7HRbMS7nUYiUda0lkQOBngVrS+JGdbWLRt2bAx5BqeQ/LXpnj
|
|
PQ4GJ+ashuK0MhWaoWcA0AaOmASMK7jRNPWYBmHyiuepO2x10qfcv6vYxCzYqoGK4HVYVTJrmb5l
|
|
c6oaM5TUJ8EgGsG4kLNUHT0M64OaqMMikSRsuKbnFMRLG3zVehOaGNE445NNlnVFpDMu6uie9Vo1
|
|
8z5mOAOST2pDK91cNN+5tsrH3PrW54a06KxT7fdrlh/q1Pc+tJ6IUdZGvHPLezMcnBOWbsPap5r3
|
|
ylFtbdT1xUWNWzU0/Zbwlgfmx8zGsHWtRHmMqE59aAMyNifvHPc1f0gtPdqkY5JosJHeNci2tktY
|
|
euPnNY+oXWZEVJNrZ9aun8SIq/CzodHuriIokhDIR1ronbKZr0o6o8ipoz//2Q==`,R0=`
|
|
/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAsICAoIBwsKCQoNDAsNERwSEQ8PESIZGhQcKSQrKigk
|
|
JyctMkA3LTA9MCcnOEw5PUNFSElIKzZPVU5GVEBHSEX/2wBDAQwNDREPESESEiFFLicuRUVFRUVF
|
|
RUVFRUVFRUVFRUVFRUVFRUVFRUVFRUVFRUVFRUVFRUVFRUVFRUVFRUVFRUX/wAARCASwBLADASIA
|
|
AhEBAxEB/8QAGwABAAIDAQEAAAAAAAAAAAAAAAEDAgQFBgf/xABDEAEAAgECBAMECQIDBgUFAQAA
|
|
AQIDBBEFEiExE0FRBiJhcRQjMkJSgZGhsWLBJDNyFSVTY3OSNEPR4fAHFjWCokT/xAAYAQEAAwEA
|
|
AAAAAAAAAAAAAAAAAQIDBP/EACARAQEBAQADAQEBAQEBAAAAAAABAhEDITFBEjJRIhP/2gAMAwEA
|
|
AhEDEQA/APqYAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
|
AAAAAAKNTq8OkxzfNkisQC8eb1XtRNbzXT4q7eU2nu0MntRq/D8StMccvW29ZmdvgjsTyvZjxOLj
|
|
+s8WLxn8TFPXs6Oj9oct7c14rkxz22nrB2I49KOdTjelmszfmpMeUxv/AA28OqwZ4icWWtt/SUi4
|
|
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
|
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAmdo3nsPNe0Pt
|
|
Fh09Z0+DNWL7+9O/7A3eJcZppsV5raI27esvH6jX5ddM25p79Ilo59VbUZOe2Tm/PeGvfPfT2iKR
|
|
PLv1+DO678XmW/a97U6TtOyzTbTF538/T9WjTNecm9a7126tqk3rSYxY5ta1plRZqZNXGjyZcPXl
|
|
mZmsx+qjBrsuO16xM7eXRt04JrdTltk5OWJnfaWf0a2lty5MdZnfzSn+WOHiOutFpjHa9e8bQ2fp
|
|
+alYy462pk7zXbuxjPesbRS0f6ZZV1ET1tErzXFLHo+A+1ddZf6NrI8PJHa1vN6iJi0bxMTHwfOa
|
|
zhzd61v1846utwniM6DUdb3nBaNrVmd9vjC/ZVePYirBqMWppz4rxaPgtEAAAAAAAAAAAAAAAAAA
|
|
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
|
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAItaK1m09ojcHnvarjM8P0vh49+a/eY8ng9D
|
|
h1fGM1rxjtGPfvbzdbjuTJxHX48cTPNltM/KsS9Dw7S49Jp6UpHaGe2vjz1y9J7LYK13vHWe7bj2
|
|
ex1tvM80ekuxW3RnW3Vm6P5jRx8H0+OYmMcb+bapo8GKPdpC6bQwtdHU8JpWkdJ/JweL6e23iU67
|
|
d4dubSqyVi9Zi0bwIs68XGp36TtEq7ZJmZmevzdbifCKWtbJinkt6eTgZPFw32t+sRurbWVzxs1y
|
|
Rv6T8V1NZNPtfq0seTm+Kevr+SZuxXjvaPiV8N4viycto9HseG6+uu08W6Rkj7UPmFck1tE1nlmP
|
|
Ld3eA8V8HVVi1pjq6Ma/pnqce/ERMTETHaUrKgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
|
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
|
AAAAAAAAAAAAAAAAADW19+TQ5p/p2bLS4v04Zmt5VjeQeJ4bjnLqsupv+Ka1+ERLv4reTmcNxcuC
|
|
vy3l0qdI2hlr66sT02ot0ZV7qqrInruzrVZLGSZ37JjqgYTG0K5lbaFVhDT1Ub456RPweY4hixWi
|
|
eSdpjvD1eWejz3FNHWYtkpvFo9EIseb3tS3SerOms22rfpPqZKzvvHSYUz70TExG6Gdbs2rljeJ/
|
|
Mx5L0vEzPaelnOi98c9J2bFNTFpit47+a+PVUvx9T9nOIfT+GV5p3yY/ds67wvsXqpxau+G09Lx+
|
|
r3TqrEAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
|
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADV4ljnLw3U0jvO
|
|
O0fs2lWqyUw6XLkyfYrWZkHldBEV09eveG3Fq1mI3jd4vPrOIaid8G9MP3Y38k6fNrt/rMk9Ou8s
|
|
tfXXn49rGWInuy8SO/k5Gl1E3rG/fzbOe94wTy99mbRvTrMOOvNfJWsesywniukrG/jU6fF43WYN
|
|
TmtEeJtEQ06aSmK2+bNtEd+qfSO17unF9Hmvy1y13XWyVmN4tExLxVK8PmNq5NrT58zawam+m/yc
|
|
0Xj8NpRYSvQZ7xEOdqI3rPozxayNRXe0ct/ON03jmrKB5nV4q1yTO20Obmv4c+cx8HoeI6WZpNoj
|
|
q83niYmYscU0r8aJ6T1n49zeJ+Meqm1drb9J+Kd5p136StGVem9l9TbHxLDFp7W7+sS+q1nesT6w
|
|
+PcAzVjiGHftzQ+v4f8AJpv6On8jH9ZgIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
|
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
|
AAAAAAAAAAABp8VrW/C9TW0ztOO3b5Nxp8VmI4bn37TWYB8f1HFtTfUfR9FWJmsdZ9I7MtJxDX5s
|
|
d8ta1y0xzteaR2277rcuhycP12SceLxMeWNpjttHwlu8I0mfQ1y+D7k5YmJmY36T36Ka43z/AF1t
|
|
cI1ds+qxVj7/AEej19PCw9HJ4NoK4OIU5Y35YmZdzVTGebVZabx5jJS+Tmns81rNLm1Wrzc9rVw4
|
|
Yibbem72mXTTS0w0M3BvEta1bWrM95ie5EanY87wXgNOL6XPfxraXLhra/W28bR/dzYzarBqJxRe
|
|
bzE7Rt5vWU9n8mPHOGmS0Ypnea1naJb+k9ncNLR7u2y/WcxXO4TOoyUrN6zD0FaW5Y3hu49FiwUi
|
|
KxCvLMR0hlW0jn6ukWw3iXjOJzbDlneOj3GaN6zDzfFOH+LE7SRGo83XNSZ2lbG2/WfdlvaT2cy6
|
|
rNFInlrv1mfJ37cK4PwTTxOoidRm2+/2/KFuyMp47XB4LivXiunrH2b2iH2qn2K/J8x4fGDNxTSZ
|
|
9Nh8OviRvTyfT6xtWI+DeXs9MNZubypASqAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
|
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
|
AAAAAAAAAAAAOZx6/LoOWPvWiHTcf2hiZ0e8fc2mf1E5+vP/AEeuSd7RC2uKtI6QjHfeINTfwtPf
|
|
Jvty9WPfbt/lucP03gxfJf7d/wBoReYpm97zaNeLb4Ims9Nt94auDjem1Wo5PFi1onylS+1o7l8V
|
|
bxvtupjDMdNkYtXS1+Stt+m63xImEJ4xjHER2ZxMUjeUTO3VRmydBbjLJqPi08mbeVOXJPq1sl5Q
|
|
Vbkz9+rRy35rxHqzmZlVEe/Ez5LRlW5iyfR6zffaIjq1OSNZps2a21rZInafSPJhxGMl9LStLRWM
|
|
lorM/A4dkrWbYfLZC2W/7K6eubX6b4RzT+W76K8b7G6X62cu3Sten59nsm3j+OXz3/0ANGIAAAAA
|
|
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
|
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA0OIYfpOHPijvNNo+fdvtXJO18k/
|
|
/OwPFYbz2ls3jx8VqW6xMdWPEdP9D4lkx/dt79flLLHbkxTPwY6nt2512ORTRzE2x4/dpE7cvkme
|
|
E4IrW3hRMxO8THRtU1FKWtvtvK2upx22rzRCtXkqzh2jtF7ZbT122b01ndnpuWuP3Z3+Ky20qDVv
|
|
fauzVy3mejZzNK8dVjqi87KLRLYtXruqvXzkQp7Qoid88R6rcl+WGlW0/Sa22mfhCZOq2x082ix6
|
|
jkm822pO8VrPdr4dNObVeDo8XW3uzMbzK+mvxT7szE27cvnu9j7PcNjSaXx8mOIzZevbrEeic5tN
|
|
+SZnpt8J4fHD9HXHO3PPW0x/DeBtJxx29vaAJQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
|
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
|
AAAAAAAAAAAAAAAAKNRim9Z5e89Nl4DzXtVh5babURHrSf7f3ec1+qnDorWrvvt5Pccb0n0zhmWk
|
|
Rvevv1+cPE2rGTFNZU26PFfxwa5dVkjelI2772nZnX6bbrEUq3o0d678u8wmuDL2ittvVjXdneeK
|
|
cGv4jpJ6U56+kS7+j118+GLXpakzHaWlp9NNY3tv+bbiYiNoQy1y30uyZJlrWmZnuym6q1iIJnop
|
|
yW2Te8bdWnnypQqzZOadokiIpSZntWN5lrxki19vNRxrUeBwnNNd+fJEY6/OejXLn3Xe/wDp9wyn
|
|
E8uo4lqqxblv7lJ26T6vpD5X7G8QycKzeBMbzMRM1/FH/wA/h9QwZ6ajDXLitvWzRgsAAAAAAAAA
|
|
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
|
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAeL45w+dDrZvWv1OWd4+E+j2jX
|
|
12jx67TWw5Y6T2nzifU+rZ1y9eHwzDYxxEy18+DJodXfT5o96vafWPVbjyxDn1OOzHudbM0rt2UW
|
|
iI69mVtRXZq5tREb9VUoy2iIlRbJ0UX1VZ6btTLrI7V6yk62M2oisT1c7JmtkttVMUyZp6x0beDS
|
|
RWOvdKijDimvWd3G9pNRMfRcNfvZOb9Hpb0itJeP47k/3hgjaZnbaP1XxWW3T0movbNS0W645nbf
|
|
0nrMPpXs3xamoxdJiLbe/X1n8Uf3fKsOTw4jbaXo+EarJhtGTHMxeJ6xH7Sti9Zaj6x3HM4NxXFx
|
|
DS1mtoi8dJrv2l011QAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
|
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
|
AGjxLhODieOIye7kr9m8d4eM4to9RwjPXFa0ZIvG9bR0fQXmPbDFvTTZPOJmEWS/V8bs9R43NxLL
|
|
G8eFbePg1bajU5/s0l1ceKLx1hbjwRE9mOpx0y2uRTSZsm3PMw2aaKtIjo6kYo9EXpET0hVLXxYK
|
|
xC6MZvyx1lFs0RHfaPiCnU12pLyHGNDbUajBekWma2npWN3p8+opa20e9LSyZLxExTlpM+vdOdcZ
|
|
a9tPS8MyUvFrzWlI6727u1pYxYrbVmb7x+TQx6au3Nqcl7/0rcmW9axGnwZJj1novmxnZXV0fFp4
|
|
ZxLBPgTGK8xzXr5fOH0bFlpmxVyY7Rato3iYfNuG2x56Wrqa8s2jz+7Lu8O12bS6jkwzN6THNNI6
|
|
tvrN68Y4rxlx1vHa0bskAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
|
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
|
AAA4XtTTm0OKfTJ/aXdcL2pyRGjwU362yb7fkJz9eTxxyZJjyltRXzUZK7TFtl9Lbwy06YzrHwa+
|
|
fJFd/wCVt8m0bQ0eS2qzcm+1K/an+zNZFL5M1pjFXeI72ky48eGnPkvNp27+TPU6nHpMfLXaIjpE
|
|
erk5dRMxOfN1mPeisfshW1ne1a1577Y6x5R3U0zze31FOWI6ze0byU098kRlzbxM9qrMlPDpyRMR
|
|
Md5Vt/Ihp5898mWZm1pjftE91uCt7fCI7dWeHDEW3t723l6rslqxWZnasR+SYhFbzhnfxJ2jyeq9
|
|
lcGXWZcmW0zWKxHLaI7794eJx5fpfEKabT8t8l5isddo3l9S4VjrwrRUwzSJt3tav3pdOL6Y6dXD
|
|
j8HFWm+/KsU4NRXPvtWazHquWVAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
|
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
|
AAAAAa+fXYNP9u8b+kdZBsDkZOO135cWOZn4y5Wu4xqctbe9y19Kp4njt6vi+PDm8DFMWybbzPlV
|
|
5PiGtz67UxbNbeKTtWIjaIXYpnwuaftT5tXJT3vmi1pMsrU5qIrG1V1a+5DCa7b9GFbRr5J6Wnbt
|
|
Cu+Wmk0m8956z8ZWZNorbfzcbX5rZslazPux3hUt41NTntktObJ13+zX1bek01r4/HzVm0bxPXy/
|
|
+bNfDgjVa2uOY92kdfg6ufJOKvLXtttVVSqbcta2vM7zXtHpLQy5ZtMd+vWd+7Zy3mdJHXra3f0c
|
|
vUarw7zFY5rT2hH1Lavnrgx81p3U49Pk4nE5L35MO/StfNRXR5tXnrS8W67WvfyiPSPi7uLHFK1p
|
|
jrtSsbR5Lc4RzsXBaYreP4l45esRD2HD9fnw6evvWvO3Tfr0aGk0U55ra0TFInv6uzgrXFXlx0i0
|
|
77RPlC83Yj+JW7oddqr6vHzTTw9/f6dod+L1t9m0T8pcbFSmPHER3892W0zPuz+jSbVvidkcqmfP
|
|
Sel7bekrI4n4dZnPWIrHeYnZee2Wpy8dEaml4npNZblw5qzb8M9JbYgAAAAAAAAAAAAAAAAAAAAA
|
|
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
|
AAAAAAAAAAAAAAAAAAAAAAAAABEzFYmZnaI7yCXL1XGa0jJXT0571nbee27DiXEprp8nhbxG20W8
|
|
5cbD0ikfnKO+urTPvjoZdXqctdsmTaPSvRpWmsdZ6yztfaGplvv3lWW1tyRlz1x0vkn7Vo5atTNe
|
|
Y0+1o79V2KsZsvX7Ne5mwxnyTNvsx2iGneM/rCdRSuOsTasTt5kRFtpjqmOH4t4nk7estiMNa97R
|
|
Hwhna0iuKTEdmGWa4672nZtRele1N59Zlq6vLOSsYorEc07qcW65euzRvtXvPZy52naZ7ujr6fXV
|
|
rWdukREK8+njHgmZmPc67bq6ivVWhxxgxZLztNrT1mZ/SP4VZs0zaOvfp84WUtNsXLvtv3699+rU
|
|
z7+Jtt5qURqMnPpctaR1rMSw4ZoK57eNk6xHaJRh97Ltt7lo5Z+L1HAPZvVauZ2nFTSzMTzeJEz8
|
|
to6xPfvsZntPZ9rXxabmxzefdrv0j1dXh/BcmstW1qxTHHasR3+b0GPhGl+kWmd64dNEVjf73T7X
|
|
y8vy+Ddx6O3iRakxTH5RXrMw1/lX+3Itw2MFIraN48qRHdZi0cUjmmPen9noox1iO0fNzdXEYrTt
|
|
stcmd9aX0bJ+HePmiKTitO8TMLZ1cVjrMfqpz6ys4pjfrPRWZ9rXXptUit6zO+23VyaRHEc05L1/
|
|
w9J9ys/en1ljqdVbwYw452tlnl3jyjzbmmiMeKtYjpEbLeTXPUU8ee/+qjJpsV5rbkrFqzE1tEbT
|
|
DpYNbW21Mnu29fKWna0KbqTdjXXjld0cvQ63ltGHNPSfs2n+HUbS9c2s2UASqAAAAAAAAAAAAAAA
|
|
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
|
AAAAAAAAAAAAAAAAAAAAAAAAAAAOVxPWe99HpP8ArmP4b+r1EabT3yT3iOkesvMVtN7za07zad5l
|
|
XV5GmM9vVfEstvDx0jtaVVMlq+UJ18b5cMRvPeSuK87bUt+i2Z3PtG7zXpjkzXt6R+TXyTMzvM7t
|
|
ydHqZ+zhv1+Cv/ZuqvPTHMfOYaTMil1a1K2vHSLTELq2v+KWzThGo84rH5rq8JzedqR+ZeI7WnOS
|
|
34pYTafWXR/2Pln/AMyrKOCWnvmiPyR6O1y9585lhWJvl557Q6eo4T4dYiMvW3b3UanhldHpJtGX
|
|
e09unmjsT7eb1l4trI2t0hsZfrdNO0bzy+nzU20/+NmkzO9esz+TZxWis9dttvPv+Tn21jjaW8zn
|
|
26bTG3mp1M/Wzv3t0jyWXiKZJmsTERaZhXXDbNl8WaztWenxZLstPp5pau8frDtVrNMM5cfTfpMf
|
|
3aunxxbes9d/R09Dp8ebJi09ptFr3jtt2WyrW9wy1Jx132mK+Xq9PotT0iIU19ntLtExa3T47T+q
|
|
6nBaYvsZstZ+cT/LeMnUi0TXffo1s2m8Ws2/OIMWk5Jib5L328rS2t94Sh5TV4ppklpW6PT6rh+P
|
|
NbebTHyas8E081mZy5P2W6OFhjxNTE/hr/LoRO0Kvo9dPqctKzMxEx1la5t3tdnjnMs4noievcrO
|
|
yZjeFF1OSnNV0OG62cn1GWffj7Mz5w05joovzY7xes7TE7w0xrjPeex6Ua+j1UarBFu1o6Wj0lsN
|
|
3JfQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
|
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACrU5o0+nvlt92P3BxuM6nxNRGCs+7Tv8
|
|
2hToxm1r3m9utrTvMsonqyt7XTmcja0u3O6FMfi5t/u0/lzdJM81p9O3zdvHTwsUR5+bfPqOfX1h
|
|
dqV+3O7bs1+T31oqmI3TEM4rvCdkDGIIhlFd2daboS0NXG2bD6bufxXU1vlmu/u4us/N0+L1tTSx
|
|
kr9qk7w89j1FNZMV3jxLzvaJ8mer+LSOZqK2xZotbvljfr/89U453rXt9lse081xZtNjx7TGKu0t
|
|
DHlrevSevaN5Y6+tJ8c7VRNMt63n3ub+6/R54rERMztDYy4a5omclYmfxKcenrjtHLvtPrCnVmdb
|
|
eFe3JXmjy6eS/DrMuLVYsta9Mdt++6qLxO+0dEc8UmInr18iUfReHcXrqccb9Z27Q61Lb13eJ9nc
|
|
1Z35rTvE9avY4bTkpG8xEfB05vYxqybc07R281naGMREdoT5JQqy9mply7Q3bV3iXG1eXw7TWSka
|
|
c258t7+tpT5/BjT7MfHqndz12Z+M4lMMKyziUJJiN1WSu9fku23RaOgKNJqbaTU1t9yelo+D0cTE
|
|
xEx1iXmM1Nt3W4PqvFweDaffx9vjDbGvxz+TP66QDRiAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
|
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
|
AAAAAOJxzU73rp6z296zsZMkYsdr2naKxvLyObNOfNfJbvad1dXkaeOdpvsc2yuZVzfbfqybutwu
|
|
s5s8R92J3dvJb3tnO4HSMegtmt3nfZvYp8SZl0z45NfSK7onH1bNcfRFqnUKJr0Y7dVtq7prjEsK
|
|
0XVpEM6028mW20IHK41aPo3J6zs4ODhdcvPnvExFevNXpMOrxi/PlrTee7PLX6Pwa09uaNlKtHg9
|
|
dM3z5d7ReOu02nu0JzZMfblrv5R5uvrcdImZ26T1mYhxs1Os7RH93PZ7axuafNfLitvbaYU3yZYt
|
|
PXs9NwHhui1HBa5LVicsb81onrEuVqNNSuS8Y67dZ6xPZa59Il9uX41vEitImZme3q2Kxbxora0T
|
|
Md/ROSa4Ztkj7c9OafL5LuGYubmyX3iu/TfbdSfVnpvZLT/XZK233+Mbbva1xRXyiPk8pwbH4N6T
|
|
adq5a71n0tD1WDL4tPe6Xr0tDpz8YVnJHWEXYxbqlBedoef4tW0XraO09HdyztSZcbUz43C+ee9b
|
|
SVMaeOfqq7+jGckQ1Yz7+7v2RN/WXPXZPjci2+2yyJaVMuy+uSJlA2d+pNoVRbeDcSxyTE+TDDlt
|
|
pdRXLTynrHrDOyiyZeVFnY9TjvXJjres71tG8MnJ4Nqt4tp7T1jrV1nRL1x2cvABKAAAAAAAAAAA
|
|
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
|
AAAAAAAAAAAAAAAAAAAAAAAAAHJ49qfD09cNZ97JPX5PPw2uI6j6Vrsl/ux7tfk1mWr7dOM8iLdm
|
|
vfebREefRsWldw7SxqNbWbR7lPesrn3Vteo7dYjDpMGCvfbeXQ0uLlxRLRxROfUc34p6fCHYrXlr
|
|
EejqrjY8uzCYW7MZjdVKqK9VlaxCYrsnYExBMRMJRPZA8/xPHtmpP9W2xx76vhWOInvt/C7ike7N
|
|
vwzE9kcapGfhlevTaFbFo8RqJ5vy8/RoW09ek0msxHfp3dzNoLzp4zUmZpMbT8HJyYJi20X2n0lh
|
|
ZY1li/RaidBF4w2mK3jrHaFGp1lN+tptPp5IjBkid5mIp16TKu0abBPv33vPlM7z+iPdFNcWXU5I
|
|
tkrNce/b1W5db1nTaf3ax9q0fxDW1ebNk2phty1mOu09VOm8W19orEz23j1TwfSeERFuEYMddptW
|
|
d43dvBn21eKJ75KbW+cf/JcTgMxXTb3nbljz+TpcPmc2uyZO1KRtVtGVdi0bx07qJnllsRO6rNTe
|
|
N4XVamsy8mnvPwc3R2jPwe8TPbdlxXNOPSZfhWWpwO85OFzv57qrODkzeHntSe8Sn6Rv0a3EZ218
|
|
8nXekfr1a0ZLVnqx19dWb6demXybOO7lYMvNMdW9S/VVLo0us7tPHdtUtEwJiZU3jq2Jhham8CVG
|
|
PNODNTJXvWd3qcWSubFXJWd4tG8PK3pPd1OB6veLaa89Y61/u2xfxh5c/rsgNHOAAAAAAAAAAAAA
|
|
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
|
AAAAAAAAAAAAAAAAAAAAANLimq+i6O0xPv392rdeZ4rq/pOqnlnelOkIt5F8Z7Wj27I2I6sb25YY
|
|
V1ImY3dbQ08LRc23vZp2j5OJG+XJWle9p2h6HHtbJXFT7OOIpX+7TxT31j5rycdTh+Dpz+XaG/sw
|
|
w18PHWseULN2trBE9UcrJKBhFU7JAQi0dEomegNDUYovM7x3jb5tO1ZvpbaTLtzRExWfWPJ08kbT
|
|
Ex5NXWYYyV5omYtHWJieyeDzuizfRs19Jn6TM7Ru1uMcJxZqTkw+5f4ebqa7SV1MR4tdrx2vEfy1
|
|
axqsNOTLjnLXytVXi3Xj8+nmsxTLM16d5npPyUzpekTtSK+U7vS6vQ/SYmK1vWPS1HOn2dvvvvE/
|
|
tDO5XlcO+LbfHSd/W3o6/BdDOXPTnj3Kz38rS6Wm4FNrRyRzTH3p6RH/AKvR8L4dXSzE3jmtHn5I
|
|
mbfqLV+m4dbLSsZInHjr3iI6zLpYaxS01rHuxHRHiT9mv6s67Vj1aqL6326MrWiYa+/Q54BxPaGe
|
|
XRZpj8MquB4+Xg8zPnB7SX30to379GxpK1xcHiKz5IS8xr8PLPixH2bftLTy05o6dHYyVjLhy0t1
|
|
izjZa3pMVv3iO/qz1G2L+NbSajbNyW7xLsY8kTDz+fJXFqKZN4iZnafi6WHL0iYlStI7OO+7axW2
|
|
crFl7dW9jvE9ULN+J3ZbdFGOy+AYWpEqN7afNXLj+1Wd23KrJVMvCzseh0+auow1yU7WhY4fCdV4
|
|
OadPefcvPuz6S7jol649Tl4AJVAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
|
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAV581NPhtkvO0R+4NPi2
|
|
r8DB4dJ9+/7Q83Po2NTqLanNbLfvPaPSFDHV66sZ5ET0hRknyW2lTtMyouz0c8usx2n7s7vScKwx
|
|
zc1vu/y85p+maJh6Th+SOWeveXR4/wDLm8v+nX5mUWa9bbrInolmu5jdTNkxYFk2Isr3TuCzeGMz
|
|
+THdEyDDJO9Ja823rt2XWnya946pGvktDXta0ztWu/ybvLE9dkcoOf4GbJPWK1j49VmLh9JtE33v
|
|
Mevb9G7WsW8l1ccREISophiJ2jpDYpijbaOjOuOJ8ujOdqxsgVcsUjaETYvbaFFrgu5lVsm0yUtu
|
|
ryg43H5m+GIj1XcJzePoL4pnrWGtxmfchr8JvfHS1622if3QljzTTLes+qrNjrkiYtCzPMxnm095
|
|
YZJ6boS5teB49Tqscza97VtvWvlv8V/FOF34RrIxTM2xXjelp/eHoeA6XnzReY3ivX/0dfivDcfE
|
|
9HbDbaLx1pb0lOs+jO7K8Lis3cN+0NKcd9PmthzV5clJ2mF9J9GHHVL108dm1SznYr/Ft0tuhLb8
|
|
mNohFbMhLWy0mJ3rPXvDvcO1karBG8/WV6Wj+7kWrvDDBlvpdRGSnbzj1hpjX4z8mOx6UYYstc2O
|
|
uSk71tG7Ns5AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
|
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACZ2jeXneJ62dVl5KT9VTt8Z9W9xbWclPo+O
|
|
fft9qfSHEU1pv48ftYST23ZTDC/p0YtlVuvVjMbM5+LCZjYGWGdrTPxiHY4ffaf3cjTxz1v6xMS6
|
|
Olty2iXVj/Dk8n+ndrkhnGRo1v8AFdW3RCrZ5uiYsqrboncSu508yjmZRYQt50TfowYTbYGVrKrT
|
|
uTZjvukQnYhMIGVY2ZxPVWyrHVCWzXpVXkt3TE7Va+W4K7X3jv1auTNy3jdba0RZpamfroQN7Hk3
|
|
6wr1GTaN2OOJiu6Mu98NvgDi8Wy74d/yZ8PiPAiO2zU4nb6qIn1bugjfFE/ASp1ke9u15mbbRDZ1
|
|
Mb823kx0Ontn1OOkedoJCvT8I03gaKsz9q/WW+isRWsVjtHRKyrhe0XCfpWL6Vgr9fjjrEfeh5fF
|
|
feH0V5Dj3DPoOo+k4a/U5J6xH3ZZ7z3228evytOk7NvFbo0cdols47bSybt7HbddHVqUs2aW3Qnq
|
|
xVeu8LILR3SlZw3V/R8nhXn6u0/pLuPMXjeHT4Zruf6jLPvR9mZ8/g1xrvpz+TH7HUAaMAAAAAAA
|
|
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
|
AAAAAAAAAAAAAAAAAAABRq9VXSYJyW79qx6yvmdo3l5viGs+maqYrO+OnSvx+KLeLZz2te1rZL2v
|
|
ed7WneZYWnZl5K72YV1xEyxmeqJljzIEWlVkszvbZp5soN3h2SJz3pP3odCnuWmPRxuERfJrZmtZ
|
|
mtY96fR28kbX3dXj/wAuTyf6bmK+9YX1s0cNtm3Sd4LFY2K23W1s16StiUJW7bp22RW3RluBuruz
|
|
mWEgrmCGWyNkoExKE1QlPmsqRDKeyBjaejWy2W3ttDUyz1QKslvehVqKTNosyyTvELabXptIJpaP
|
|
B39Ia2mz+JGpr51jdZefDx2hzuHZObNq58poJaGtjxJ2+LoaKP8ADRPo5+T3skx5OhpOmC0fBNQ0
|
|
5yTbn+bt8A0u9raiY6RHLVwY62mI6zMvaaHBGn0mPHt1iN5+aYVsACBXqMFNTgviyxvW0bSsAeE1
|
|
mkvw7V2w5Ote9besJx2er4rw2nEdNNekZa9aW9JeQjnxZLYskTW9Z2mJY7zz26fHrrdpbZsY7NGt
|
|
mxjvso1b9NmUwpx33XRO4K7VUTE1nmrvEx1bVo2VWiJE/XY4frY1WPlt0y17x6/FuPM0m+HJGTHO
|
|
1qu9pNVXVYt46Xj7VfRtnXXL5MfzexsALsgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
|
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHM4jxOMFJphmJv529Dq
|
|
ZLfjDjPEIx450+K3v2+1MeUOHSOWFc3nJkmZnf4yujpVlqunOeFpV2nctLCZUXRM7MJtsWlRkv3Q
|
|
ky5NmpWt9RnrixVm17TtEQnJabXisRMzPSIew9n+CRoccajURvqLx5/chfOest642OGcIpoOG2w7
|
|
ROW9d72+LQvXevyejcPUU5M+SvpLeOataraw2a0dLbLqTtK1G3Es4lVWWUSoldFtmcXUbpidgXzK
|
|
GEW3TuCUSncnsDFMMLSms9EC6J6FpVzbZE5ALy0809ZbFr9GtfrEoFMzuuwz0Ueey3HbaBLDXe7i
|
|
tMOfwWnP9I+NZbuttvhs1uBRtXPb4SDm3iIvf57N7Dbl0VrS5+XrltEd+Z1Jx7cNms9N4TURRw3T
|
|
+PrcO3WszEvZOD7P6aYiMlvu16S7y1QAIAABxOPcLnUY/pWCv1tI96I+9DtgmXl68Biy7/NtUu3+
|
|
O8HnFa2s0tfd75KR5fFyMWTdhrPHVnX9R0cd21S3Rzsdm1iuqs256wrmGcT0RYSx5d047X02SMmO
|
|
esd49YRE9WcdSXhZ2O1p89NRji9J+cei1xMc3wXi+KZj1j1dTTaqmor06WjvWW+ddcu8XK8BZmAA
|
|
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
|
AAAAAAAAAAAAAAAAMMmWmKu952UZ9XFZmuP3revlDTtzWnmvO8q3XGmfHb9ZanV3yxtWeWn7y4es
|
|
vPNtDqZJ6Ts5mppvdl/XXRMyfGvSNlu/RVvtOzLfoipLT1VTKbSpvfogRkvtDVyZOhkyvQcA4Dzz
|
|
XV6yvTvTHMfvK+c9U3rkW+zvA/D21urr789cdZ8vi9KDb45rejl8Rry6iJ/FV1HP4vXbBTJEfYt1
|
|
+UpiHM295bXsqrO9l8QkZ0lZEqqLeyBZHZLGvZkhIndADKJ3TMoqWQMZ6pjsxll2jsCLSrmU2lFY
|
|
36gieyu0LJk3jbsga0wdqzK20QpyztQGprL/AFMrOE05NLkt6qdVWZxNrSe5o9vWBLiUjnzXn0vL
|
|
q555dHt8HOwV928/1z/LpzXxbYccRvzTB+jucOwxh0dI22mY3ltIrHLWIjyjZKyoAAAAACJiJjaY
|
|
3iXleM8InR5J1GniZw2n3oj7s/8Ao9Wi9a3rNbRE1mNpifNFnVs65XhcWTdt47bnFuF24dm8TFEz
|
|
p7T0/pn0a+HJux1OOrOux08d1ndqY7tillVkzExLOk7yd4YxGwluViJhE45raL0na0dtlWO0+bZr
|
|
1TKi+2zptZGTamT3b/tLacvJjiY3XaTWdYxZZ6/dtPm1zrv1z78fPcbwC7EAAAAAAAAAAAAAAAAA
|
|
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABhkyV
|
|
xUm152iAZWtFazNp2iGhm1Vss8uP3aevnKrNntqLdelI7VRHRnrX/HRjx/tZREVjZXeybW6KbWZt
|
|
pCZ6S08tN7Nmbb7zCrJtyoS5145bSx5mWafelr3tsKmS/o08uXyhlly7RPV2+AcBnPNdZrK+53pS
|
|
fP4ytnPVda4y4BwHxOXV6uvu96Unz+MvVxG0bQRG0bR2G0nHLb2gCUDX12LxtFmpHeazt82wT1gH
|
|
mMN4tWs+rcr2aEV8DU5sM/cvO3yb+O0csLUTSdrLphRE8tlkZI7Atr2ZMazDJVKTYSCawi7Ksq7z
|
|
1QERvLK3ZGPrKbyCrbdnMcsbeaa18/RhvvM7oGEwTG0JmYYTIML22a2e28xELM19oURPNO4lOem+
|
|
n3ZY5+prVnMc2GYU4/L4A0a15cNf6rz/AC6fC6+NxCPOuOu/5tHJTbHj+F5/l1+BYumXJMd9o3/d
|
|
MRXYASgAAAAAAABhlxUz4rY8lYtS0bTEvH8R4ffhmo6bzhtPu29Pg9mq1Gnx6rDbFmrzVsizq2df
|
|
zXkMWTeIbNL7tbXaHLwzUctvexWn3bmPL8WFnHVL326VZ91MfFVjvvVlz79kLrcf2m7j7bNHH3bl
|
|
J2SirLQoy4t1++7G0dBC/RanxI8PJPv18/WG241+alovSdrV6w6mDNGfFF4/OPSW2b1zeTPL1aAs
|
|
zAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
|
AAAAAAAAAAVZ9RXBTe3WZ7R6iZOpzZq4ac1p+UermZMl89+a/byj0Ra9815ted59PQ32hlrXXRjH
|
|
DpCLX6ML5NlNsm/ZRqstfdXzbsZt06sLZNvNB1Za8RDWyZdo7q8udq5Mu/mIMt4md2lmy7JzZuWJ
|
|
dHgfBL8RvGo1MTXTxPSPx/8AstJ1XWpIs4BwSdbeNVqq/URPu0n73/s9hEREbRG0QUpWlYrWIisR
|
|
tER5JbSccur2gCUAAAAPM8Sry8Uyz67fwuxbzVPGsE49XGbvF42V4M0TEL33ERnktsxpk3sumK2j
|
|
admFdPFZ33VS2Mdui2J3UU6LYlFSsN2O5NkCyJ6K7T1TEsbAsxdpReerKkTFGMxvYEz0rsqtbbpC
|
|
b2VT1QEzuwtbaGUxspuJU3neWdKoiu8rq12gCI92YatLcublnzbEz1aOptyZqTuDHLfxN6R0+t5X
|
|
qdJhjBp6UiPLeXl9NSMnEKxHa1+bb8nrlvxUAAAAAAAAAAABTqtNj1eC2LLXeto/R43VabJw/VTh
|
|
ydY+7b1h7ho8V4dXiGlmvbJXrS3xRZ1fGv5rzeHN02bEW3cys3xZJx5ImtqztMS3MeTeGFjqlb2O
|
|
8btql3NpbZtYsnSBLeiWfdTjtutid+ghherHS5p0+f3vsX6T8Fkw181d4lMvEWdnHaGnw/UeNh5L
|
|
T7+PpPxbjdyWcvAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
|
AAAAAAAAAAAAAAAAAAAAAAo1Oprgr63ntAmTqdRqK4K9etp7Q5d7Wy2m953lNrWyWm953mVd77R0
|
|
Za1104xxlN9lV8qnJl2a9s3xUXX2ybsJyRDWtl3YWydEC+2VRkzeW6q+T4tbJm+KRdfK1cmWZnlr
|
|
vNp7RC/R6HU8SycmCk7ed57Q9ZwvgOn4fEXtHi5/O9o7fJaZ6z1uRyOEezVstq6jiEbV71xevzer
|
|
rWtKxWsRFY6REeSRrJxz22gCUAAAAAANbX6aNVpL0npMRvWfSXlKamsRMVvXm+EvZXjmpaPWHzfL
|
|
oNRjzXicfWJ8phfPxFejx72x7xMzK+sXiNoiXlq+Pi6fWV/VfTNqfLJl/WTg9Pji8R70LqvMV1Gq
|
|
j/zcv6yz+lanzzZP1lWpelTET6S81Gp1P/Gyf90s412rjtnyfqql6asREdWM9+jz9eJ6yP8Az7uh
|
|
odZqMt458tpB1JvEViI3/RhzRt13/R1MNaziiZiJn5K9ZNceKZiIiQcu/WekT+iYrWI3lzdTrs+8
|
|
8uW0fJzcur1Np/zsn6g79phVaIeetqNR/wAXJ/3SwnUaj/i5P+6UD0ldonum161h5mNRqP8Ai5P1
|
|
lNtRqJjacuT9Qd22WN5aGeZyZd/KHJy59RHbLf8AVq31Gp/4uT9ZEvS8Lr/vSs2npzRtL1z53wK+
|
|
oza/HW2XJNd99pmX0Rb8VAAAAAAAAAAAAAAcHj/C5yV+l4I9+v24jzj1cLFk8nu5jeNpeW41wmdL
|
|
knU6ev1Vp96sfdn/ANFdTrXG+eq1q5F2LLtbZoY8m8d11bbSydErsYsm+zZrO/zcnBm226uhiyRK
|
|
EtrvCrJDOJTeu8A1MWX6Lqq5N/dnpb5O5ExMbx2cPNTeJb/DM/iYPDtPvY+nzhri/jDy5/W6AuwA
|
|
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
|
AAa2p1UYo5adbz+xbxMlvqJ1OqjDHLXree0ejmzNrWm953tPmTPWbWneZ7yoy5YhjrXXTjH8s75N
|
|
mtkyxt0VZM2/m175N1V03yTKubMLXVXybeYLLX2VXy7eam+b0bOg4VquJW+rry4/O9uyZOq3UjVm
|
|
9r25axMzPaIdvhns1kzbZddM0p5Y47z8/R2+HcF03Doi1a8+Xzvbv+TotJnjDXkt+K8ODHp8cY8N
|
|
IpSO0RCwF2YAAAAAAAAACvUZYw6fJkntWN3k8dfHz2vLucdz8mkjFE9bz1+UOZosX1UzPm0nqI/W
|
|
MYo9FlcPNklfFGeH/NshLGun+Cz6PtHZtVZWlRLS+jxPkRpIn7rdoupHTdA5s6SI+7H6Mfo+32Y2
|
|
+To3neSIiZ7A0IjPXpXLePlMotGW3272t85datKzHZjbTVnsDj+FG/2Y/RlGP4R+jo20u7H6N1Ql
|
|
o+H8I/REY957R+jpfReiK6eOYHLtj2tttH6KrY/6Y/R2c+kjeJiFVtLG24hxpw7/AHY/RRkw9O37
|
|
O99Hrt1YX0tfOBLjcGp4XF8c+u8fs9c4dcVcGemSI61nd3IneN1orQAAAAAAAAAAAAABFqxes1tE
|
|
TE9JiUgPKcX4RbRXnNgiZwWnrH4XPi28PdXpW9JraImsxtMS8pxXhF9DecuGJtgmf+1TWW2N/la1
|
|
L7N7T5e3Vy6W3hsYcvLbqzbO9jvvCzvDR0+XeO7crO6FmGSvRThy/RtVXJ92elvk2rRvDUzU7pl4
|
|
izsd2J3jeBpcNz+Lg5LT7+Pp+Xk3W7js5eAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
|
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADs0NTrN96Yp6edkW8Wzm6+LNTq4pvTHO9vOfRoWtt
|
|
1mes95YWvs1s2fZldddOczLPLn2ju0MmebT3YZc2/mpm3qqllN1drsbZIhr3yzvtHf4AsvlYYseb
|
|
V5Yx4KTe0+UQ6nDvZ3UazbJqd8OKeu33peq0eh0+hxcmnxxWPOfOfm0mP+steT/ji8N9mKY9suum
|
|
L37+HHaPm9DSlaVitKxWsdohI0Y22gAgAAAAAAAAAABXnyRhw3yT92Nwef4xm8bVzET0rPJH5d12
|
|
CvLhho3rN9RWs9Z23n5y6O21YhrVYbdGOCfrrLPJRpv863zVS6FS09SvZj3lVZZRdPSqmnSWdrIE
|
|
ebOkK4ldTsgW1WKqd1oMZhEVZyRAImOjGI6rJ7IiATNd46qL02bHkiaxaoNGY2n4ImPgtyV2n0Vo
|
|
Gvlx7x2beiyTk08RPevSVUxux00+Fn2n7N+n5rRFb4AAAAAAAAAAAAAAACLVres1tETWekxKQHlu
|
|
L8InR2nPp43wz3j8P/s5dLveWrFqzW0bxPeJeV4xwmdFec+CJnDM9Y/CrY1xv8qvTZ+WYdbDk5oh
|
|
5zHk283U0eo3jaZZ2N5XYjrCnLSJhOK+8d1kxvCqzSwZvousrb7k9LfJ3nB1OLeJdLhufx9LEWn3
|
|
6e7LXN9Ofy5/W4AuxAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
|
AAAAAAAAAAAAAETaKxMzO0Qi9646Ta07RDmZ9VbPbaOlI7Qi3i+c3TPUaqcu9adKfy0722ZXvFa9
|
|
XO1OrjrESxt66ZJmcjPUanlidmhkzTZVfLN5VWvsC2b7R3U3yqrZZtO1esz2h2+F+zWTUcuXXTNM
|
|
feKR3n5+iZLVbqRzNJo9TxHLyaekz62ntD1fDOA6fQbZL7Zc/wCKY6R8odLBgxabFGPDSKUjyiFj
|
|
SZkYa3aALKAAAAAAAAAAAAAADQ4pl2pTFH3p3n5Q33E12Tn1eSfKscsLZ+orS00eJqbW+Lfnu1tF
|
|
XaJnZsz3WpCfsyp00fWSvmPdVYOmSUDd8kR3InoQosy7JmUX7MdwZ17ro7KKT1XRPRAsrO0rYndr
|
|
79V1ZBaQiJ6JgCSIJASwrO07MpV2nqBlrv1a1o2bf2qtfLXaQUTO0sb05o3jv3ZXhjS20xEphW5h
|
|
yeJjjf7UdJWNKLziyRePsz0lux1SgAQAAAAAAAAAAAAAADG9K5KTS8Rato2mJZAPIcU4ZbQZuekT
|
|
OC3afT4NXFkmlntc2GmoxWx5K71tG0vHa/RX0GpmlutJ61t6wrY2xr8dXS5uesN+tt4ef0eaa223
|
|
2dnHk3juyreM81OaFGiy/RtZET9jJ7s/2bdutd2jqKeic3iNTsd8a2h1H0jTVtP2o6W+bZbOO+gA
|
|
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABje9cdJt
|
|
adohGTLXFTmvO0fy52bJfU23t0pHaqLeL5xdK9Rnvqb+cUjtCi94xxvK3JetKuHrdZvaa1ljb10y
|
|
cnIs1Wt3naJc++TmVWvMz1YWybfMGdsm3eWek0mo4jm8PT0mfW3lDf4V7P5tdMZdRviwfvZ6/TaX
|
|
DpMMYsFIpWPTzXmf+steT8jn8L4Dp+HxF77Zc/4pjpHydYGjC3oAAAAAAAAAAAAAAAAADG9opS1p
|
|
7RG7zszN6WtPe0zLua+3Joss/wBOzhzG2OsL5+IrY09dsSyYRijbHEMvOChb7KjF0yS2LQ169Mso
|
|
S24noyrPVXWejNVKbTuw3T3REdQWU6LYlVvsyiUDPfqupPRr79VuOQX1lZEqoZxIMksd0gT2VT0l
|
|
bPZVbuCaW8i8bwr32WxbcGnkjaZa9p2ndv5qbw5+aNugLItF6TEtvTX5sMb969HMpfazc0d9stqe
|
|
vVZDdAQAAAAAAAAAAAAAAAADV1+iprtPOO/2u9bektoB4TJTJpNRbHkja1Z6uto8viVht+0HDvpG
|
|
H6Tjj6zHHvbecONw7Ltfkmeqmo6Ma69DXbbZTkr1mGWO3RneOaGbZRoM30fVzSelMnT83aef1FZ7
|
|
x3h1tBqfpGnjmn369LNc3sc3kzy9bQCzIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
|
AAAAAAAAAAAAAAAAAAAAAAAa+q1dNNXr7157VhGp1Xh70x+9f9ocy283m1p5rz3mVbrjXHjt91lz
|
|
5c9+fJ1nyjyhdM8lZlOOIiqrUXikd+kMreunnI5XEdX4dZiZcG+XmtNl/F83PeeWWHDOGanieSKY
|
|
q+5H2rz2hMzWd1Iqx1yajJXHhrNrW6REeb1nCPZumn2z62Ivl7xTyr/6uhwzhGn4Zj2xxzZJ+1kn
|
|
vLoNJnjHW7TbbsAszAAAAAAAAAAAAAAAAAAAAaPFrbaSK/itEOXt0rDf4xb/ACa/GZacRvaF58Q2
|
|
IjasQnzPIhCU92tMbZGzHmotG10C6nZkwpPRmipIllEbMIZIE7solgmJBnCyk9VMM6z1BtVllEqK
|
|
z0WRILYlluriWcSDJVbusV27gwInaSWM9ECyZ3hqamnSWxFmOSOaqRx725bNnSZNs9J+OynVY+WZ
|
|
YYr7TE+nVaIr0Ais81Yn1hKAAAAAAAAAAAAAAAAAABExvG09peU4nov9n66L0j6q/WPg9Y1OJaON
|
|
ZpL0+9HWs/EWzeVz9PbmrEtnyc3h9reHy26TWdnSr2YX6657ijLXpLX0+onSamL/AHJ6W+Tbv2aW
|
|
ekTv16JzeI1Ox6KJiYiY7Slz+E6jxdN4dp3vj6fl5Og2clnKACAAAAAAAAAAAAAAAAAAAAAAAAAA
|
|
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACZ2jeQRMxEbzO0Q08uqtkma4ulfO3r8lefUePMxWf
|
|
cjy9WvlzVxV6T1Z61/x0Y8f7Wc7Ur1lqVy+LqOWJ2hp6rXddon5rOF1tfmz5OkT0qzb8dWbxjp1c
|
|
biuuilJ5Z6r+IcQrixzEy8zl1E6rNt1tMztFY81sztU1eRucN4ffi2p5esRM72n0h7rS6XFo8FcO
|
|
CkVpX082nwXh3+z9FWLxHi36328vg6TZyW9ABAAAAAAAAAAAAAAAAAAAAAADj8Unm1tK/hqppHvw
|
|
y1k8/EMk+m0GOPeafiFpCZYwolnXspvHvLa9mF46gmnZmwozRUiUCBKYYsoBLOFbKAX0llEqqyzi
|
|
QXRLOJVRLOOwLIljZMEgrlhKyYYTAK5nZPN0RZjugUanHzVlz6xtLq361c+9eXItPpXX0dubTU+E
|
|
bL2lw2++O1fSW6m/VYAISAAAAAAAAAAAAAAAAAp1GbwcfTreelYEydcuMcRrM/L9nnlsV6wqpi2r
|
|
tv133mfWVkRyRtEdGFva7MzkYZNoamWN4bV4mYa9qztKIujhVppxGI8r1mJegeZpknBqKZY+7L0t
|
|
LRekWrO8TG8Ns/HJ5ZypAWZAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
|
AAAAAAADS12fp4VJ6z9qVuq1HgUiI+3bpDl589cOKZmevqprXPTbx477rDJlrhr1nq4+s182tMRP
|
|
RqaziXiZJrWekNG17ZbxWJ336M5LXRbI3dLTJrs07RMY6fan1dHLrowY+X7MVjt6N3R6Kul0EbWm
|
|
s7bz8Z+LnabQX43r7Y53php/mXj+Dnv0f1JO1x/8ZxbUzj02O15mfLtD13AvZqnDds+pmMmo26el
|
|
XX0Wh0/D8EYtNjilY7+s/NstpOOTW7QBKgAAAAAAAAAAAAAAAAAAAAAADG88tLW9I3BwJtz6nNf1
|
|
vK/DHVqYJ3pzT5y3MPZeojOWMQylEKpTVjZnDCwkqzYQyRRICATCITAJZQxhMAshnEq4ZQC2srKq
|
|
qrIBZCWNZZgwswmFloVyCu0dFcx1WyrtCBhv5NTPHXds2U5o3hIz4ffbPt+KHUcTSW5c9Jme0u2v
|
|
VYAKpAAAAAAAAAAAAAAAAYZctcVOa35R6tLrltN795/YvknNqrfhpPLH92V5isd9mWq6fHjk6rn0
|
|
ZxG8KK5Jm/wbVZiYZtqrmkqL023bkxvCiY3lJHNyRG81mHS4Rn5sNsNp64+3yaWaNrzOzHBl+i6q
|
|
mT7s9J+S+ay8mex6EIneN47SNXKAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
|
AAAAAAAAAImYiJme0JafEs3h6fkidrZOn5eaLeJk7eOdm1Hi2vmtPTry/CHmOJcUvmvOPF1n09Pm
|
|
6HF9ZGm01qxO3R5vSY7XwzmzTy47zzTEd7en5Mfvt2/PURWdo3tvPrPlKymbktFqTtMTvHzbOLDG
|
|
f63JXbFX7FdnoODcDprZpq9TjiMMTvSn4vj8l5fxnrk91saPSa7i2hpOfbTVt5x1m0fLydzR6PDo
|
|
dPGHBXasd585n1lsRERG0dIF5OOe6tAEqgAAAAAAAAAAAAAAAAAAAAAAADX11+TRZrf0y2Gjxe22
|
|
gtH4piP3TPpXKwxtjhuYo9xq442iIblI2pC1RET2ILd9kxCqRjZmwlCSEohIJAQAAJZISDKGUd2M
|
|
MoBnVbVVCyAWVWeSuqyOwIlXZZKue4MJV2WWYT2QKbKL9YlfdRdIo35b7/Hd3KTzUrPrDh27uxpb
|
|
c2mpPwX/ABX9XAKpAAAAAAAAAAAAAACekTIp1eTwtJmv+GkyJn1oafeazbfpMzLR4jq/o8b823zX
|
|
6XNF8ERCvTcNpxLV5LauvPhx9Irv3lhztdtv8TtaWLicXrt03jzjzb2k1nid56ty3s/w+a7Uwzjn
|
|
1raejlarhmbhl/FpbxMO/fzj5p/ixSeXOvTtRfeI280ZI26tfDm3pWe63LaZx7qtGvniJ6tPLvOK
|
|
fOa9WzbJvTbza02jl3n5SSljscK1MajSxWZ96nSW88xw/VfQ9XMT9nfa3yemid43jtLeXsce88qQ
|
|
EqAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADia3UTm1l4j7OP3Y/u
|
|
7Vp2rM+kPJW1PhYcmS0+9MzKm/jbwz31weMzbV8UppazPL9q0/BF4rk1GLDSNqxPWPhCnHmnNrtT
|
|
qPKteWPm6U6OdHaZvO+SaRNvhv12Ub/q3FhtrNVj0uKOt56z6R5y9zix1w4qY6RtWsREOJ7L6OKa
|
|
S2rvX6zNM7T6Vh3mmZyOfya7eACzIAAAAAAAAAAAAAAAAAAAAAAAAAAczjVvqMVfW/8AZ03I41bf
|
|
Lp6/OVs/UVrY47NyOzUxd4bUJpEbb3Z7IiOrKIVSjZhMLJYyhKIgmGUQSDESIEbJEgQmCITEAmGU
|
|
IiGUAyhZVhDOoM4Wx2VQtqBKuyyWEgqlhKyyuyBVaGtkbNmvk7A15l1eH2300R6TMORPSXT4ZO+O
|
|
8fFefEX63gEAAAAAAAAAAAAAAAq1WPxdLlp+Kkx+y1Fvsz8gjhaDauGK8sx07y3OE3m1tT6RaP4c
|
|
vU6yMNKUx73zT0ilY3l2eF6a+m0kRl/zbzz3+Ez5M8z26fJruW6wzYq5sV8d43raNpZjRzPPaTmx
|
|
5b6bJ9rHO3zb2WJ8GWPEscY9bgzxH2t62n19GWW0eHOzHU5XbjXZ1x8WTnz2iZ7S2M1IjH2+LX0V
|
|
KTqs8zO9ot0j8nUthi1J3UaOFMTfLFo6xMbS9BwHWTqdHOO8+/hnln5eTjYMFo1WTH5VnePzXcIm
|
|
2k4zlpPSmXy/hfF5eMfJns69OA2cgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
|
AAAAAAAADG/2LfJ874rW845mubliY7bPoto5qzHrDz0+yePNF41OotaJ7RWNtpV1OtfHqZ715fhu
|
|
j8adNpcVfeyzE2/vLuanhOu1nEctIxTTFa/+ZPbZ3eHcF0vDbTfFE2yzG03t32+DokynXl9+leDB
|
|
TTYKYccbUpWIhYCzEAAAAAAAAAAAAAAAAAAAAAAAAAAAAcXjE/4zDH9M/wAu04XF5/3jj/0f3Wz9
|
|
RUYmzDWxS2I7FSyjuzY1ZKpRKEygEwiWUIkGIk2QJNhKQhMIhkCYZQxhlAMoZwwZwgWQshVCyATL
|
|
CWc9ldpBhZXLOVdpQK7NfJPRdaWvknoDVvPvOnwuel4+TlXn3nS4VPvXj4QtEV0wAAAAAAAAAAAA
|
|
AAAAAVV02CmTxK4qRf8AFFeq0AAAanEsfPpZmO9Ji0NDLfkwdOsulrumiyzHlVzJrz4Ovoy26vB8
|
|
cTBa9NffLtMY77Rv8Yegx5ImkKdJoY1HC81Y+3OSbVn0mGGkmbY45u6tnrrTOu2xGO0RxCd+nNVj
|
|
qKxTV1vH2pjaGtnyzXXYdo96ZmGXEMk15b7/AGZiVerWPTYckZcNbx5wzc7hGbnxXxzPWk7x8pdF
|
|
0S9jh1OXgAlUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
|
AAAAAAAAAAAAAAAAAAAAAAAAcPjEf4/FP9H93ccXjMf4vDP9Mx+62fqKrx+S+GvibEFSsqyYwlVK
|
|
ZYsmIMoRKYJQIPIEiQ2ATCUQygCGUIhMAyhnDCGUIFkLIV1ZxIMpVWWSrsCuyqyyyq09ECq8tfJK
|
|
66jJ2Bp5J6upwn7dv9Lk5J951uE/av8AJaIrqAAAAAAAAAAAAAAAAAAAAAAq1Mc2myxPnWf4cmtu
|
|
XT9fR0tffk0WSe28bfq5Wbamm3326MtunwfK6PCv/AxPraZ/dz9PO97/AOqf5dHhdZrw7Dv3mOb9
|
|
XOxRFM+avpe38mvkPHf/AFWlrKba7Tzt99ZxKkfR7euyNXMTrtPHfa0z+zPiM/UR8Zj+Wbdu8HpN
|
|
M2bfzrV13M4dO2pyR61dNvj44/J/oAWZgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
|
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADj8bj63BPzdhyeNx0wz8ZWz9RWri7Nmv
|
|
VrYu0NmqaRZHZlDGGSiwxZSgCEkCBCQSCQBMJRCYgEsoYx3Z17AlMIhlCBnDOGEM4AlhZZKq4KrK
|
|
7LLKrIFN2vdfZReAaObu6/CO9vk5OePR1uEd7fJeIrqAIAAAAAAAAAAAAAAAAAAAAGtxCk5NFliI
|
|
3mI32+XVyNTyZOHTee946PQKPoeDffw4777eW/yVs60xv+ZxOnr4Okx1t05KRv8Ao41Z5q3yed5m
|
|
XY1szXRZ5jvFJ/hxItP0aOSN9q7yrtr4f2tHFM5+KT16Yq/vK/iGSbXw4vO14UcPx5MGfNbPG18m
|
|
1oj4THRsTw7VanPXVYpi3gzMcnrvCnG11JOupwuN8+a3pEQ6jT4divjxWnJExa09pbjbM5HHu90A
|
|
JUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
|
AAAAAAAAAAAAAAHM41H1GOf6nTc/jEf4Ws+lls/UX45uGekNujTwdm5RNIthKIZKLDFlsiQIShIC
|
|
EgCUJ7AmGTGO7IDzZQhMSDJMMYZQgZwzhhDOATuqssmVdgVWVWWyqtCBTeVF19lF+wNLNG7q8I+9
|
|
8nLyupwnt+S8RXUAQAAAAAAAAAAAAAAAAAAAAAAItWL1mto3iY2lyrcLyUxzix2ia2nvPeK+jrCL
|
|
OrTVnxpanhuPPemSs8l6RtE7dJj0ldpNP9GwRSZ3neZmV4cR/Vs4AJQAAAAAAAAAAAAAAAAAAAAA
|
|
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAANHi1d9H
|
|
M+kt5ra+vPoskfDdOfqK4mn7Q3aNHBPZu0W0RdDOGFWcKLCJZeTGQQlCQSgASBsCYZQxhlAJTAmA
|
|
TsmAgGcM4YQyjsgRLC3VnaVcgwsrt3Z2V2QK7tbJ1bN5a9waeWO7p8Knt8nNyebpcK8vkvlFdQBA
|
|
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
|
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAK9RXmwZI+ErEWjesx6wQeZwejeo0cccuW8
|
|
elpblJaaRGxVnCuss4ZrMvJEgCAASISCQIBlCYYpieoM0wx8k7gzIRueYM4Z79FcSy3QEsLJmWFp
|
|
BjaVVpZWlXMoGNmvkXXlr3kGtknu6XCf7OXkl1OEdl8orqgIAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
|
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
|
AAAAAAAAAAAAAAAAHmskcmtzV/rls0U62OXiWX4zErcc9GmkRfWVkSqqziWayxCPIANwBIhIJSxS
|
|
CRG6dwZwlhEs4BluMdzfqgZxLLdXuy3AmVdpZTKuZBjaVVpWWV2QlhZRdfZRcGpl7urwfrzfJy8r
|
|
rcH61vPyWitdMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
|
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHA4nHLxKZ9awnH2ZcY
|
|
jbW459aq8fZpfiI2IZwrqzhmsz3Ebm4JN0AMhCQSIASndiAziWUSriWcAyRujc80DM3RCfIETLCW
|
|
UsZEsJYSslXZAwlTddPZTkBp5e7r8Gj6rJPxhx8k9Xa4PG2C8/FaK10QAAAAAAAAAAAAAAAAAAAA
|
|
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
|
AAAAAAAAAAAAAAAAAAAAAAAAAcfjcbZMFvnDWx9m5x2PqcNvS+zSxT7sNPxH62YZQwqzhRZO6UCB
|
|
KUAJTux3SDIRuAncQAmJZRLBMSgZ7iIAZRKd2DICUSlAljLCYWMLIFVukNfI2bNbIDTyT7zu8Ijb
|
|
Sz/qcG/2nf4T/wCE/wD2WnxWt4AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
|
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHL9oL
|
|
+Hw2cm28VvEuPptfgyVj6yIn0no7/FtJfW8NzYMe3PaPd39d3iMug1WktNc2C9dvPbeP1aZ9xF+v
|
|
T471tHu2iflK2HkqWmvaZj5Surqc9Ps5bx+alTHqYHm68S1Vf/NmfnC2vGNTXvyT84Ql6A3cSvHM
|
|
sfaxVn5Ssrxyv3sM/lKB1xza8bwT3pePyWV4tpZ+/MfOEjfGrXiGlt2zV/PotrqcN/s5aT/+wLRj
|
|
FontMSlAlKEgndO6IAZQljDIEgeQljLCzOVdkCu/SGrkbF56NPNeKxMzMRHxENe0+89DwuNtHHzl
|
|
5PJr8NcnLW3Pbf7r1nCZm2gpae8zMrz4i/W6AgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
|
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
|
AAAAAAETETG0xukB4HVaeMHEtRi26RedvkyjBSfX9W77QYvC4xz7dMlYlrU7M929dWJLFc6aPK0q
|
|
7YLxPS0S22FlP6q38Zac0yR92s/KVc3tHfFf8tpbcsLRvB/dR/8ALLVnU0r9uL1+dZI1mnmdvGpv
|
|
6TOy6ym+Oto2tWJ+cJ/tW+KLK5KW+zes/KU7tG+h01p64qx8Y6NXNo6Y+uPJlp8rLf0rfG7MXtHa
|
|
0x8pZxqs9e2a8f8A7Oj7HaTHn0+f6RWM23LETfr6vRW4PoL99NT8ui7F4+vEdXXtnt+fVbXjGsr/
|
|
AOZE/OsPS29nuH27YrV+VpeV9pdPXhOtw49NG9Mld55+vXcTPd42I47qo7xSfyWV9oM8d8VJ/VxM
|
|
d8l46xWF9cV7en6o/qLfxp2I9ob+eCv/AHMo9op89P8A/wBORGmyT5R+qfo2X8P7n9Q/jTsx7RR5
|
|
6ef+4/8AuHftg/8A6cWcOSO9J/WEbWr3pY7Efzp2Lcfv5YK/9zWy8d1E/ZpSv5Oba1/+Hb9lc+LP
|
|
bFt87I7E/wAabWbiurvEx4nL/pjZzc2bJkn372t85ZXx55/BX85lucC0vPxnTxlnnjm32mOiZqUu
|
|
LJ2p4TwnVavNWaYbRTfre0bQ99pcH0bT0xb78vmtiIiNojaErMwAAAAAAAAAAAAAAAAAAAAAAAAA
|
|
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
|
AAAAAAAAAAAAAAAAAAAAAAHnfarF7umzRHaZrLjYrdIen9ocPi8JyTt1xzF4eUw23rCm3R4r6bMy
|
|
wt6kdTaWLdjswmNoZontsCm0K5XWjopnuDC0dGpqG5bs08/daKV672MjbSaif6oh6Z5f2LtvptRX
|
|
0tEvUN3Jfo8f7cYve0eX4zV7B5z20xc/C8eSPuZIRficfXlcPaG7ino08HWIbePpLF2NuiyOyrHK
|
|
3fZFSwuovHVfaVF4QK5YWTM9UT0EKry6Ps1Tn4zjn8NZn9nOtLseydObiWW34cf918fWfk+PYANn
|
|
KAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
|
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAq1WKM+ly4p+/WYeBxTNd6zG0xO0
|
|
vobw3FcP0bi2em20Tbmj5Srr418V9sa2Z7qKyzi07MXUylhaU7yjqhLCeiq3ddaFNxFYW7NLNG8t
|
|
zya+WO6Va9J7FW66mvwidnrXiPY3Ny8RyUn71Jj9Ht3RPjk19HK9pMHj8D1ER3rHN+jqqtTjjNps
|
|
uOe16zAifXzfTz7kNyndpYazS9qT0mszDdoxrsi6m8LazMq6zDOsq1ZEyrt1WWlXaUCqyq0rbKbi
|
|
Fdp6PReyFd8uqv8ACsfy83aXrPZHHto89/xX2/SP/dpj6y8vx6EBq5gAAAAAAAAAAAAAAAAAAAAA
|
|
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
|
AAAAAAAAAAAAAAAAAAAAAAAAAAB5n2q03LfDqqx39y39npmlxbS/TOG5se29tuavzgWzeV4mtui2
|
|
O3RRSY2hdVhqO2MvI36iu9lUsrSrvDHn6spnmSiq5jooyV6tq1VV69RC32byTh43h8otMx+r6I+Z
|
|
aK/g8TwX7bXh9Mid4iW+fjl8n1ICWb57xLBOm4zqse20Tbmj8+qKdnS9q8PhcTw5tumSm0/OHMxz
|
|
0Za+uzx3sX1t0Zxurr1ZxvspWiZYWZbsbT0QK7KLrZVZJFaqt5vbezNOTg9J/FaZeJns93wCvLwb
|
|
T/GJn92uGHldIBowAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
|
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADuAPA67F9H4l
|
|
qMW20VvO3yRWW97T4fC4rXJHSMtI/WGhVlue3b473K2KzMML4+62tujG9pnozXaOSOVFMnVbmq1t
|
|
trJRW5E7wwvUxTvCyY6CHOt7moxz6Wh9PxTzYaT61h8x1MbZK/OH0zTf+Fxf6I/htj45vL9WgLMn
|
|
mvbPFvocGWO9L7fq85p5maw9d7VYvE4JkmPu2if3eW0+PasdFNOnxfF1Y2hlykRsmY+LJ0MZjZXa
|
|
eq2eyi8oQTO0KLdZWzPRjWu6VaqtHR73g0bcI0sf0Q8Nkq93wqNuFaWP+XDTDDytwBowAAAAAAAA
|
|
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
|
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAef9q8HNpcGaI60vtPyl56k9Iew49j8ThGe
|
|
PwxFv0l4zH2U26fDfTYiyJljvsjf4sm6vJ1hrXjq2MkqLdZEVbgbMx0auGdmzNt6iHN1Ub5af6of
|
|
TdPG2nxx6Vj+HzaaTm1+nx/iyVj930ysbViPRrj45vL9SAuyc7j1efguqj+jd4/T33rD3HEcPj8O
|
|
1GP8WOY/Z4TTT7sKadHhbcsZnaCJ3TPZk6VdrKbTutmP0U2nqgrGOsr8deiuI2X09EqKM1dt3uuG
|
|
f/jdN/06/wAPE546S9rwud+Gaaf+XH8NMMPK2wGjAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
|
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
|
AAAAAAAAAAAAAABrcRp4nDtRWPPHP8PCYusPoWSvNjtX1iYfPuWaXtX8MzCuvjfw32siu8ptXoxi
|
|
0wy5t4YulReqmazu2skbquURWFInddM7VYRGyL291KFnCcfj8e0le/Lbmn8n0N4b2Ur4nHLWmPsY
|
|
5e5a5+OXyXugBZmiY3iY9Xz7NjnTa3Ph/BeYj5PoTxftFg8Hjk2iOmWkW/Psrr418V5WrWd2faFc
|
|
V2jdnEMXWxntupmN7NiYU27iWML6dVMVnddjgVqMsdHr+CW5uE6f4Rt+7yuSsTDv+zWXn0WTHP3L
|
|
/tK+GHl+O0A1c4AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
|
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA8Dn93W56/wDM
|
|
t/L3z59qp24jn+OS38lnpr4r7ZxHQ2TEstt3PXUrt27K57rr1VT0BjKnJPRbMqMs7QlV2fYvHvrd
|
|
VknyrEfu9m8f7FZI8fVU85iJewbT45NfQBKo817W4eulzxHaZrL0rje09ItwqbfhtBVs3leai8RD
|
|
KLw1sduesL606dWFdsZT1jdhNeq6K9DlhCVUU6s4jZnt1YzAhnM71dH2bycmszY/K1d/0c6OzY4R
|
|
fwuK4p8rTstn6z8k7HrwGzkAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
|
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHz3
|
|
Vxvr80/8y38voTwGpj/F5/8AqT/JfjTx/WVeyY6FPspc9dZPVXaOq2WEwIUTVRmjo2rNfLHRI3vZ
|
|
DJycXtX8dZh7t879nsnhcbwz23tt+r6I2nxyb+gCVBzuPY/E4PqI9K7ui19fTxNBnp60n+Aj5/pJ
|
|
3jZu1aOnnltMNussdfXbm+l3ZM9URHREdZVXTuT1Nk7boQiOkJw28PU47/htEp5eivJPLMTCZ9Vv
|
|
x7mJ3iJ9UqNHk8XR4b+tIXuhxAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
|
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD
|
|
weqjbWZ4/wCZP8vePCaz/wDIaiP+Zb+UX408f0r9lOxWOifJhXWjfyYWllPRXYQxnrCrJHRd3YZI
|
|
6A1NJecHEsN/S0T+76bE7xE+r5dk93LW3pL6ZpMni6PDf8VIn9m2fjm8s9rgFmQxvHNS0esbMiew
|
|
PnHLyai9fS0w2aNfUTtrs3+uf5bGPqy068fF227KtSsdFlKqNGMV6myyY6sbdIQI8tlOWOi6Jhhk
|
|
j3RD0vA8nicMx9etZmHRcT2Zyb6XNT8N9/2dt0T449T2AJVAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
|
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
|
AAAAAAAAAAAAAAAAAAAHhdfG3E9TH9cvdPEcXjk4zqI/q3L8aeP6xr2TsxpLOekMK6mFo6qpXSrm
|
|
OqBixvHSVmzC4OfqK7S9/wAByeLwbTW9K7fo8Fqo6Paeyl+fglI/Da0NcMPK7QC7AAB8313TiOf/
|
|
AKk/y2MHWrX4jG3E9R/1Lfyv0/aFNOrHxuU7LI7MMayGTVlHWUXhNe6Z6wIUsb9d1m20q7dkDpez
|
|
N9tRqKT5xEvRvKez9+Xis1/FSYerb5+OTyf6AFlAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
|
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
|
AAAAAAAAAAAB43j9eXjN/jWJ/Z7J5L2mry8Upb8VIF8f6aGOey2eynHvOy7bowrrYSxZSwQJ2YXZ
|
|
92N4BoanrEvVexmTm4blr+HJ/aHltRHSXofYm/1Wrp5RaJaYY+X49WA0c4AD51xONuKan/qW/lbp
|
|
+0MOLRtxbU/9SU4J7KadWPjep2WQrr2WRPRk1TvsndXMpiRCb9FNu0rbTuqvKBscCjfi9PhWZeue
|
|
V9n434rafTHL1TfPxy+T/QAszAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
|
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHmv
|
|
avHtfTZfnV6VxPajHzcNrf8ABeJFs/XnMcr4no18c+6vr2YadkY2YM57sEDLyY37Mo7MMnYGlqO0
|
|
vQ+xNfqNVb1tEfs87qZ2rL0/sVX/AHdnt65P7Q0wx8vx6UBo5wAHz/jUbcX1PT78qtO2vaCnJxjP
|
|
8Zif2amnnspp04+OjWejKJ6MKdmcMmyJn4m5ZHzEVPMwtJv0VZLbQDqezcb8RzT6Y/7vUPM+ytZt
|
|
n1OTyiIh6Ztn45N/6AFlAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
|
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABocbxeLw
|
|
nUR5xXm/Rvq8+OMuDJjntaswEeBxT0bNZ6NatZpNqz3rO0rqsdO3PxlaWEMpY+aqWXkryT0ZT2V3
|
|
7A0dVPuy9f7G124NM/iyT/Z4zWT7sw957MYfB4Fp4/FE2/WWmGHldcBowAAeM9qKcvFeb8VIly9P
|
|
0nq7ntbTbVYL+tJj93CwT76unR4/jo0nozhhTsy3Y1sWljM9Ce7HyQIm3RRlttVbaWrnt0Sh6n2U
|
|
x8vD8mSfv3/h3XN4Bi8Lg2nj8Uc36y6TeOPXugCUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
|
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
|
AAAAAAAAAAAAAAPD8RxeBxXUU26Tbmj8+quro+02Lw+I4ssdslNvzhzazvDPbq8d7GW7Dfqz2VzG
|
|
0s2qd+iu/Zn5Ksk9BVztX1mI8930zh2LwOHabH+HHWP2fNYp4+vwYvxXiP3fUqxtWIjyjZtj45/L
|
|
faQFmQADzftfj3w6fJ6WmHmsP23rvaqnNwqLfhvEvIYZ+sV038bo0noy36MK9oZQxrdMyrlnMbMZ
|
|
QKrS1M07zEestq/RRjr4utwY/wAV4j91p9V18fQdJj8LR4ccfdpEfsuREbREJbuMAAAAAAAAAAAA
|
|
BAJAAAAEAJEAJQAJQAJEAJQAJQAJEACUJAQlAJEAJQAJQJAAAEAJEAJBAAAJAABAJEJAAAAAAAAA
|
|
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABwvanDzaPFmjvjv8A
|
|
tLztJ3h7HjGHx+FainnFeaPnHV4vFbeIU038VbHeGF+kso7Mb9mTdhKnLK3dRm7SIrHhGPxeP6Sv
|
|
9cT/AHfSnz72Zx+J7Q45/BWZ/Z9BbZ+OXyfQBZQABzeP4/E4NqI9Ii36S8Ng/wAx9C4jTxOH6ivr
|
|
jn+Hz3B/mQi/GvjdCnWNlsdI2V07LIlg6USrt2ZzZXMoFV+zPhGLxeOaavpbm/RVltEN72Yx+Jxm
|
|
b7dKUmf7L5+s9/HtRA2cqRACRACRACRACUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
|
AAAAAAAAACQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQCQQCRACRACRCQBCQBCQB
|
|
ACRACRACRACRACL1i9LVntMbPATTwdRkxT3pea/u+gPE8Xx+DxrPHlaYt+qNfGvjvtXXsi0dOrKk
|
|
dEXjZg6VMtbP2bMtXUdpEV0/Y2nNxbNf8OP+727xvsXH+N1U/wBEfy9k3nxyb+gCVQAGOWvNivX1
|
|
rMPnGGOXNNfOJ2fSZ6w+dZKeHxDPX8N7R+6L8a+L63KdoZ7q6zvEMpnowdKJ6ywmWUyqvIKM0vQ+
|
|
x+D6rU55+9aKx+TzWa36vbezmDwODYenW+95/Nphj5L6dQBo5wAAAAAAAAAAAAAAAAAAAAAAAAAA
|
|
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAEiAAAEoA
|
|
AAAAAAAAAAAAAEAkEAkRuAkQbgkQAkQAkQAkQAl5T2nx8nEMOT8dNv0l6pwfarHvpcGWPu32/WCr
|
|
YvK4mOem6b9mGKd4Z3idmFdka0y1c892zfpMtLPaNpEV6D2Kj/Eauf6YeweQ9ieuTVz8K/3evbT4
|
|
5NfQBKoAA8FxCvJxrUx/XMvevD8Zry8fz/Haf2RfjTx/6RSOnRMyypHu9kXjowrqVSrvPRnZVl6V
|
|
kK0775MsUjvadn0nT4ow6bFijtSsVfPuFYvpPGtNTy54mfy6vorXDm8l9pEC7JIgBIgBIgBIgBIg
|
|
BIgBIhIAgBIhIAgBIgBIIBIAAhIAhIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAJAAAAAAAAAAAAAAA
|
|
AAAAAAAAABAJQkAEAAAAAAAAAAjc3BIjdG4Mkbo5kcwMjdhzHMDPc3V8xzAs3N1fMjmBZubq+Y5g
|
|
Wbm6vmOYFm5ur5jmBZubq+Y5gWbm6vmOYFm5ur5jmBZubq+Y5gWbm6vmTzAz3N2HMnmBlu5ftFTx
|
|
OEZJ/DMW/d0t2rxKni8N1FPWkiZ9eS08e7Cy8dGGn6UhZaJljXZGnmc3UT3dPP2cnUT78xCIV6j2
|
|
H/8A9c/6f7vXPI+w8bU1U+vL/d63du5NfUiDcVSIAS8b7RV5eOb/AIqRL2TyXtNX/e2KfXH/AHlF
|
|
+NPH/pr4+2xcxx0hFpY11K7R16KM32ZWz3UaidqSgrc9kcPicWyZJjfw6T+727y3sXh2xarN+K0V
|
|
h6lvPjj3e0ASqAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAJQAAAAAkQAkQAkAAAAAAAAAAAAAAA
|
|
EgAAAAAAAAAAAAAAAAAAAAAgAAABKDcAN0bgkY8xzAyRux5kcwM9zdXNkTcFm6OZXzMeYFvMibKu
|
|
ZHMC2bo51U2RuC2bom6rc3BZzom6sBZzI52ADPnOdggFnMc6skFnMc6rc3BbznOp3RzAv50c6nml
|
|
HMC/nOf4qOY5wX85zqOc5wbHOc7X5znBsc6edr85zg2ec52vzpi4NjmY5bROG+/bllVzsNTk5dLl
|
|
n0pP8BHmMHWNmzt0aum8obm08vVjfrtnxztR0mXHzTvaZdjVRMTLkZo6yiFen9iZ2pqY/wBP93rN
|
|
3kPY+/LfPX1rE/u9XzN3HfqzdO6vmTuIZ7m7Hc3Bnu8t7TR/vHBP9E/y9Pu837SV31umn+if5Rfi
|
|
/j/01MMb1hjkrtKzBG0bMsmOZY11tOYamr6Und0LUc7XT7u3rJPqL8er9lcPhcFpbzyWm39v7O00
|
|
+FYvA4Zpsc94xxu227jv1IAgAAAAAAAAABKAAAASgASgBIgBIgBIgBIhIAAAAAAAAAAAAAAAAAAC
|
|
UACUJAAAAAAAAAAAABIAAAAAAAAAAAAAAAAAAAAg3AEbomQZbo3YzLGbAz3RNlc3YzcFs2YzdVN2
|
|
M2Bdzom6nmNwW86JurTAMuY3REJ2BB1ZRVMVBhsbSsiqeUFXLucq3lTygp5TlXcpygp5TlXcpygp
|
|
5TlXcqOUFXKjlXcrGYBXysdlswiYBVMdUTCyY6sZBWxlnMMZgGLGZZSwkDdHMiWO4MuY5mEyjcFn
|
|
N1OdVzHMC3nTzqeY5gX85zqOZPMC+Lqdbk20eb/RKOZr8QybaK/XvtH7iZ9aGlp2luzT3fg19NHS
|
|
OjbmPcYX67XH1XSZ9XIzRvMuzrK7zLkZYmYnciunb9lZ5dTk+OP+71cXeP8AZnJ/ip2nf3J/l6iL
|
|
/Fu5L9bMWZczXi6YuIbEWTzKIuyiwLt3nuO25uI4a/hx7/rLuczg8TicvFLbfdpEK6+NPH/phhjo
|
|
stLGkctUWnoxrrU3j1cnWTzZq1jzl1clo5Zcu8c+txR63iP3Tn6pv4+g4o5cVI9IiGe7CJ2iE7t3
|
|
GyN2O6dwSINwSISAlAAlACRAAlAAlACRACRCQAAAAAAAAAASgASISAAAAAAAAAAAAACQAAAAAAAA
|
|
AAAAAASAAAAAAAAAAAAAAAAIAAAQCAJljuljsCJlhMs9mOwMJYys5TkBVsjZdyHICrZPKt5E8oK4
|
|
qmKrOVOwMIqyirPY2Bjyp2ZbAI2NmSARsbMgEbI2ZAMdjZICNkbMkSCNmOzJEgx2YyzljMAwlhKy
|
|
WEwCuWErJhhMArlhLOWEgxljMpljIImWMyTKJA3N0IBO5vux3NwZbnMx3NwZczT4jf3MdPW27a3a
|
|
fJOq1XNP2KdIRfi+J2trSYfcjeF+Wm1OicVeWIiN9kai8xjY12ORqultnI1Ecsujq79XP1FovWYI
|
|
rTgeq+j8QrWZ+3Mx+r2UXeC0WG2Ti2kiN5mL807eUREvbzbaejefHJv62Iv8WUXa0WTFhVtRdlF2
|
|
rz9WUXBtc7jR9dqc2T1ttHyhvZMvJitb0jdq6XHNcNenWVN3028U99WRj6Kb02be3Tq18/SN2Lpc
|
|
3UdN9nOmZrqKX/DaJ/d0svvTLRzV3jomK6+Pd1vvWJj0ZczT0mXxNJht60hfFnQ4qu3N1cWTEgs3
|
|
Tur5k7gz3N2O5uDM3Y7m4MtxBuCQASIASIASAAAAAAACRCQAAAAAAAAEoSAAAAAAAAAAAlAAlCQA
|
|
AAAAAAAAAAASAAAAAAAAAAAAIASgAAAEJAQJQCNkbMgGOyOVnsAw5TlZ7GwMOVPKy2NgY7GzIBGx
|
|
skA2AAAAAAAAAAQkBAEghEskAxYzDPZGwK5hjMLJhjMAqmGEwumrCagomFcw2JqqtUFEsLLrV82F
|
|
o7gqljKyYYTGwMZRKUSCAQAboJnaN5Bjkneu0d5W4ccViIiOzHFWbTzNumP1Zarr8eeRMbxDW1Mx
|
|
NO67NbkhzNVnmInqzaOZrL93JyZeV0M1++7S02jvxDWxhxx033tPpC8Z6rrezWjmZyazJG2/u03h
|
|
2vFibTHoqvamiwVwY+nLGzV0+SZ1Mx8G0/45tOhzJ5lXMc3UVXRdlF1HP+iYsDPLPPy49/tz1+Te
|
|
pSIr0ho6ak5Ms5J8o2q6NImOrHV7XX488ypzTtHXo0s9t6zG7c1G1qz6ubeZiZ3UatXJG3yauSO7
|
|
cvMTEx5tPLb3prPRMVr0HB8vicNxf0+7+kt+LOJwTJyY/Bnz3tH93X36N58cWvq6LSyiyndMSlC7
|
|
mZcymLJiwLosmJVRLKLAtiU7q4lMSCzc3YxJuDMRuAlKAEgAAAlAkAAAAAABKAEgAAAAAJAAAAAA
|
|
AAAAAAAEgAAAAAAAAAAAAAkAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAhIAAACAAAASgAAAAAAEAAAA
|
|
hGzJAImGMwzQDDZjNVuyNgUTVhNGxysZqDVmiu1G5NN2M4waM0+DCaN2cbGcQNGaMZq3JxMJxA1J
|
|
qx2bU4kU09slorWNwa20z02RXHbJbl26QvtFovbHWkxEdJt5y2MOHlr2U1W3jx+1hiw8vSO63lmI
|
|
XRTaEWmtY6snRHO1VpmJ+DjavpSZl2s8b7y4HFcnh0n0gha5ebJN55KRM2mdoiPN6fh+kpwXh0Wy
|
|
RHj5Otp/s5Ps1p62y31+em9aTMYt/OfVfxTiPjZ52naI7fBrI5t66xz5+a1rW7yx0eSL6iZjtEOX
|
|
qNbSletom3lENjh2fbHzbbWt3iVozruc+5ztWubf4M4ybpQ2Oboyrva0Vjza8WdDR4OkXt3n9ldX
|
|
kaePP9VtYqctYhdvt5oivTeCZ2YOxXk6ubqMfV0b9mrljfqlFcq88k7z2U5axeItDa1OPessuC8P
|
|
ya7XRWYnwqdbT/ZMilvIu4dpslNdixXja8Y5tt85djZdbDWnGOesRtXFtuw6T27No5Kx2OrKYQlC
|
|
ExKJgBnEpiyvdlEgsizKLKollFgWxLKJVRLKJBbEp3VxLKJBnuMWQJEbpBIAAAJAAAABIAAAAAAA
|
|
lAJAAAAAAAAAAAAAASAAAAAAAAAAAAAJAAAABAJABAlAAAAAAAAAAAAAAAAAAAAAAAAIAAAAAAAA
|
|
AAABAJQAAAAgAABAAI2EoBGyJhkgGPKxmqxAKpownHC+YRMdN5BrTj67R3bOn01o7p01Iv71u89o
|
|
b9a7LfBTfS1vWI2jf12VfQPSW8KX2mas+NC2iv6xMNfJpMnLtEbuuxtMRCtzF55NR5rPps1N/ctP
|
|
y6uHreE6nXZ4pak48X3rT06fB7fNeI33cbX6mI32R/MWu7XF116aDSRhxbRERs8f499bkyZeeKae
|
|
kzE2mdon81/tfxDLGOunwbzlzbx08oaHBvZHJlx48mrvaa94pu04y617576rNGLRRM0397JEd/lu
|
|
9Dw/S3x4qxffo6mm4NjwUiKY4iI9Ib1dHFY6QIaNabbrYrLfrpJtaK1rMzPZb/s+05IpP59OyLeJ
|
|
k7eNfRaOc1ue32I7fGXYpi5Y77M8OGMeOKxHSFsU3Y29deZMzirl6dlVvhLatCjJHeYQv1rXnps1
|
|
8k9/VsW6qLVmZIi1rzitlvFKRvaZ2h6TSaenC9FFY+3brM+sqeG8Prp4+kZ+lvuxPkr1mqm95nfp
|
|
DXM459676a2q1dsV7XietvNno78+CJn1cjX6mOeIm0bR33dfRU5NJjidt9t5afjG/V6JZ7I2QMNh
|
|
nyo2BhsMuVG3wAhMSbbQRAMolnE+iuGUSCyJZRKuGUSCyJZK4llEgyZMYTuCUsYSCQASISAAAlCQ
|
|
AAAAAAEoASCASAAAAAAAAAAAAlACRACQAAAAAAAAAEgCEoASCAAAAAAAAAAAAAAAAAAAAAAABAAA
|
|
AAAAAAAISAIAAAAAAQAAACASgAAAQJAQAAhIDHZhln3do7z0WS18mWsajHjmes7pg3dNi5aRMNqO
|
|
yvDHTpPRaigHZhN4hHRlaVN59JY3zRENLUavaO+yq0iNVlitJ6vNcR1MVi0zO0era1/Ea0rPvbz5
|
|
PM5MWp45qvo2GZrhmfrsnpHpHzTCseEcM/2vrr8Q1Eb4qzy44nziPN63HpYiIiI7LNHoqabBTFii
|
|
IpSNohuVxrKtWMEejPwY9G1FFmHB4mWJn7MdfnIM9JpIx15to5pbUaas/a6rqViI7MxPxqX0UT1r
|
|
O3wVzpbR2hviP5i03Y5s6a879FNtHljydhExCv8AMTPJXBnRZbz0iG5ptFjwe/l96zctMVamTJtE
|
|
yTMibu1VrdTzRMR0j0ed4lr64MVpm0RERvMz5NvX62uOJ69XhOKX1HH9bHDtFvNYnfJeOy0Z2ojX
|
|
6jjnEq6fRUmccTvN/J9H0eKcOnx45neaxEbubwHgOHg+milI3vP2resu3Wu0JQmITsmISDHZHKz2
|
|
JgFc1RMLJhGwK9iIZ7MZgEdgmAEwyiWCdwWRLKJVxKYsC2JTuriWUSDNlEsIlMAySx3SCRCQSIAS
|
|
AAACRACQAAAAAAASIASAAAAAAAAAAAAAAACRACRACQASIAAAAAAAAAAAAAAAAAAAAAAAAQCUAAAA
|
|
AAAAAAIAAAAAAAAQAAAAAACBICBICAAEJAQJQCJcLjuS2ny6fPG/LWdpd1o8T0X07SXx/e7wCdJx
|
|
Wa0jmneHQpxPDMdZmJfNtZm49weZrh0/j4o7VtSZ2+Uw0/8A7o49k92vBLc/ntFohFW9PqGXimOI
|
|
6Tu1L8T3eCx6r2t1O3JwvHjifO99v7t/Bwf2l1PXU6rS6eJ8qUm8x+so5TsekzcSjbvs4mt4rzW5
|
|
K2mbT0itesy2cHsvbvqtbmyz5xERWP2jd1tJwrTaONsOKtZ8585+cnDrzmn4Rq+IZObUROHD32n7
|
|
Vv8A0ej0uhxaXFGPFSK1j0bkY4jyZRVZVXFGUVWbGwKsk8mObekNrSW3pWf1a2aYjHbm7bNnQ1id
|
|
PW0TvuDdhJEbQABMsLW2R0ZTMQrvfbz2YWzVhpanUxEd0dWkW5c8R5uXxDX1w4pnfr5Q19XxKuOJ
|
|
2neXltVqtVxbV/RdJ715+1bypANfiOu1HENV9C0MTfNeesx2rD1PAeBYuE6aKx72W3W9/WVnBuB4
|
|
eF4dqRzZbdb5J72l160WVK02ZxCYhOwI23TsnY2BGxsnYBjsiYZsZBjMMZZSgGEolMsQDdG6NwZ7
|
|
piVe6YkFsSziVMWZRILolMSriWUSCyJTuwhMSDMRCQSI3SAlACRCQAAEoAEoASAAAAAAAAACUACR
|
|
ACQAAAAAAAAAAAAASAAAAAAAAAAAAAAAAAAACAAAAAAAAAAAAAABAAAAAAAAAAAAACBKAAAAAAAQ
|
|
JQAAAhICEbJAYTWJ7wx8KvpC0BV4ceieWGewDHlNmWwCNjZICNhIDmcZredBecdpiY69FXCOLW+i
|
|
UiZidukulmxxlx2paN4mNng+K4+I8Hy2yaTfl37TXetoCPfRxfp1qi3F48ofKMvtvxak8s6LDv61
|
|
rZji9rPaLUf5PC+bfttS0q8q3p9W/wBrRMdpUZuKdN99nzvFqPbTVz7nD8OKs+do2/mW3h4D7Xaq
|
|
ZnPrtNpqz35aRaYOHY9Zk4pNt9rR+rl6zi+OnS+WN57Rv1lXp/YrNaYtruL6zNPnGO3hxP6O5w/2
|
|
f0HDuun09Yv55Le9afznqcOvO4tBreMTHu30unnva0bWt8on+70nDuE4OHYYx4Kbesz3tPrMuhGO
|
|
IjpDOKrK9YVpsyiGUQnYGOyUgI2SlAIEmwMWMs9kTAMJYzDOYRMArmGErZhhMArlHmzmGMwDE3Ts
|
|
bAbs4swj5pgFkSziVcM4BZEsolXDKAZwyhjCYBkACQhIAAAAAAAJAAAAAAAAAAAAAAAAAAAShIAA
|
|
AAAAAAJAAAAAAAAAAAAAABAJEAAAAAAAAAAAAAAAIEoBKAAAAAAAAAAAAAAABAlAAAAAAAIAAAAA
|
|
BAkBAkBAkBAlACEgMZjdjbFW8bWrEx8YWANb6Fp+bfwab+vLDKMFK9qxH5L0bAr8OPRPKz2AY7J2
|
|
SbAjYZAI2E7AIEgIEgIEgMdkSy2NgY7MdlmyNoBXsxmFuyNgVTVjNV3KjlBRNTlXTVHKCrlIqt5T
|
|
lBhEMohlFerLlBjEMohMVTEARDKCITsAk2AEgAAAkAAAAAAAAAAAAAAAAAAAAAAAASAAAAAAAAD/
|
|
2Q==`;async function Fle(e){let t=(r,a="application/octet-stream")=>fetch(`data:${a};base64,${r}`).then(o=>o.blob()),n,s;switch(e.config.warmup){case"face":n=await t(E0);break;case"full":n=await t(R0);break;default:n=null}if(n){let r=await createImageBitmap(n);s=await e.detect(r,e.config),r.close()}return s}async function Ole(e){return new Promise(t=>{let n;switch(e.config.warmup){case"face":n="data:image/jpeg;base64,"+E0;break;case"full":case"body":n="data:image/jpeg;base64,"+R0;break;default:n=null}let s;typeof Image!="undefined"?s=new Image:de.Image&&(s=new de.Image),s.onload=async()=>{let r=Xn(s.naturalWidth,s.naturalHeight);if(!r)ie("Warmup: Canvas not found"),t({});else{let a=r.getContext("2d");a&&a.drawImage(s,0,0);let o=await e.image(r),i=await e.detect(o.tensor,e.config);t(i)}},n?s.src=n:t(null)})}async function Ple(e){let t=r=>Buffer.from(r,"base64"),n;if(e.config.warmup==="face"&&(n=t(E0)),(e.config.warmup==="body"||e.config.warmup==="full")&&(n=t(R0)),!n)return null;let s;if(typeof void 0!="undefined"){let r=(void 0).decodeJpeg(n),a=r.expandDims(0);e.tf.dispose(r),s=await e.detect(a,e.config),e.tf.dispose(a)}else e.config.debug&&ie("Warmup tfjs-node not loaded");return s}async function AI(e,t){let n=Ze();if(t&&(e.config=xn(e.config,t)),!e.config.warmup||e.config.warmup==="none")return{error:"null"};let s;typeof createImageBitmap=="function"?s=await Fle(e):typeof Image!="undefined"||de.Canvas!==void 0?s=await Ole(e):s=await Ple(e);let r=Ze();return e.config.debug&&ie("Warmup",e.config.warmup,Math.round(r-n),"ms"),e.emit("warmup"),s}var Du,Md,zd,D0,xI=class{constructor(t){Re(this,"version");Re(this,"config");Re(this,"result");Re(this,"state");Re(this,"process");Re(this,"tf");Re(this,"env");Re(this,"draw");Re(this,"models");Re(this,"events");Re(this,"faceTriangulation");Re(this,"faceUVMap");Re(this,"performance");Hu(this,Du,void 0);Hu(this,Md,void 0);Hu(this,zd,void 0);Re(this,"gl");Re(this,"analyze",(...t)=>{if(!Uu(this,Md))return;let n=this.tf.engine().state.numTensors,s=Uu(this,Du);Gu(this,Du,n);let r=n-s;r!==0&&ie(...t,r)});Hu(this,D0,t=>{if(!Uu(this,zd))return null;if(!t)return"input is not defined";if(this.env.node&&!(t instanceof Ge))return"input must be a tensor";try{this.tf.getBackend()}catch(n){return"backend not loaded"}return null});Re(this,"reset",()=>this.config=JSON.parse(JSON.stringify(kr)));Re(this,"validate",t=>ip(kr,t||this.config));Re(this,"image",t=>gi(t,this.config));Re(this,"emit",t=>{var n;return(n=this.events)==null?void 0:n.dispatchEvent(new Event(t))});h0(),this.env=de,kr.wasmPath=`https://cdn.jsdelivr.net/npm/@tensorflow/tfjs-backend-wasm@${ih}/dist/`,kr.modelBasePath=this.env.browser?"../models/":"file://models/",kr.backend=this.env.browser?"humangl":"tensorflow",this.version=$x,Object.defineProperty(this,"version",{value:$x}),this.config=JSON.parse(JSON.stringify(kr)),Object.seal(this.config),t&&(this.config=xn(this.config,t)),ip(kr,this.config),this.tf=fi,this.state="idle",Gu(this,Du,0),Gu(this,Md,!1),Gu(this,zd,!1),this.performance={backend:0,load:0,image:0,frames:0,cached:0,changed:0,total:0,draw:0},this.events=new EventTarget,this.models={face:null,handpose:null,posenet:null,blazepose:null,efficientpose:null,movenet:null,age:null,gender:null,emotion:null,embedding:null,nanodet:null,centernet:null,faceres:null,segmentation:null},this.draw={options:Vr,canvas:(n,s)=>pI(n,s),face:(n,s,r)=>Ex(n,s,r),body:(n,s,r)=>Rx(n,s,r),hand:(n,s,r)=>Dx(n,s,r),gesture:(n,s,r)=>Nx(n,s,r),object:(n,s,r)=>_x(n,s,r),person:(n,s,r)=>dI(n,s,r),all:(n,s,r)=>hI(n,s,r)},this.result={face:[],body:[],hand:[],gesture:[],object:[],performance:{},timestamp:0,persons:[]},this.process={tensor:null,canvas:null},this.faceTriangulation=w8,this.faceUVMap=k8,this.gl=Ft,this.emit("create")}similarity(t,n){return By(t,n)}async segmentation(t,n){return t?rI(t,n,this.config):null}enhance(t){return Wy(t)}match(t,n,s=0){return S8(t,n,s)}init(){N0(this)}async load(t){this.state="load";let n=Ze(),s=Object.values(this.models).filter(o=>o).length;t&&(this.config=xn(this.config,t)),de.initial&&(this.config.debug&&ie(`version: ${this.version}`),this.config.debug&&ie(`tfjs version: ${this.tf.version_core}`),await N0(this)||ie("error: backend check failed"),await uh(),this.env.browser&&(this.config.debug&&ie("configuration:",this.config),this.config.debug&&ie("tf flags:",this.tf.ENV.flags))),await aI(this),de.initial&&this.config.debug&&ie("tf engine state:",this.tf.engine().state.numBytes,"bytes",this.tf.engine().state.numTensors,"tensors"),de.initial=!1,Object.values(this.models).filter(o=>o).length!==s&&(await oI(this),this.emit("load"));let a=Math.trunc(Ze()-n);a>(this.performance.load||0)&&(this.performance.load=a)}next(t=this.result){return mI(t)}async warmup(t){return AI(this,t)}async detect(t,n){return new Promise(async s=>{var m,g,A,y,x,b,v,k,S,C,D,O,E,R;this.state="config";let r,a;this.config=xn(this.config,n),this.state="check";let o=Uu(this,D0).call(this,t);o&&(ie(o,t),s({error:o}));let i=Ze();await N0(this),await this.load(),r=Ze();let l=gi(t,this.config);if(this.process=l,this.performance.image=Math.trunc(Ze()-r),this.analyze("Get Image:"),this.config.segmentation.enabled&&this.process&&l.tensor&&l.canvas&&(this.analyze("Start Segmentation:"),this.state="run:segmentation",r=Ze(),await kx(l),a=Math.trunc(Ze()-r),a>0&&(this.performance.segmentation=a),l.canvas&&(Z(l.tensor),l=gi(l.canvas,this.config)),this.analyze("End Segmentation:")),!l.tensor){this.config.debug&&ie("could not convert input to tensor"),s({error:"could not convert input to tensor"});return}this.emit("image"),r=Ze(),this.config.skipFrame=await x8(this.config,l.tensor),this.performance.frames||(this.performance.frames=0),this.performance.cached||(this.performance.cached=0),this.performance.frames++,this.config.skipFrame&&this.performance.cached++,this.performance.changed=Math.trunc(Ze()-r),this.analyze("Check Changed:");let u=[],c=[],d=[],p=[];this.config.async?(u=this.config.face.enabled?Sx(this,l.tensor):[],this.performance.face&&delete this.performance.face):(this.state="run:face",r=Ze(),u=this.config.face.enabled?await Sx(this,l.tensor):[],a=Math.trunc(Ze()-r),a>0&&(this.performance.face=a)),this.analyze("Start Body:"),this.config.async?(((m=this.config.body.modelPath)==null?void 0:m.includes("posenet"))?c=this.config.body.enabled?Jy(l.tensor,this.config):[]:((g=this.config.body.modelPath)==null?void 0:g.includes("blazepose"))?c=this.config.body.enabled?ix(l.tensor,this.config):[]:((A=this.config.body.modelPath)==null?void 0:A.includes("efficientpose"))?c=this.config.body.enabled?dx(l.tensor,this.config):[]:((y=this.config.body.modelPath)==null?void 0:y.includes("movenet"))&&(c=this.config.body.enabled?mx(l.tensor,this.config):[]),this.performance.body&&delete this.performance.body):(this.state="run:body",r=Ze(),((x=this.config.body.modelPath)==null?void 0:x.includes("posenet"))?c=this.config.body.enabled?await Jy(l.tensor,this.config):[]:((b=this.config.body.modelPath)==null?void 0:b.includes("blazepose"))?c=this.config.body.enabled?await ix(l.tensor,this.config):[]:((v=this.config.body.modelPath)==null?void 0:v.includes("efficientpose"))?c=this.config.body.enabled?await dx(l.tensor,this.config):[]:((k=this.config.body.modelPath)==null?void 0:k.includes("movenet"))&&(c=this.config.body.enabled?await mx(l.tensor,this.config):[]),a=Math.trunc(Ze()-r),a>0&&(this.performance.body=a)),this.analyze("End Body:"),this.analyze("Start Hand:"),this.config.async?(d=this.config.hand.enabled?ax(l.tensor,this.config):[],this.performance.hand&&delete this.performance.hand):(this.state="run:hand",r=Ze(),d=this.config.hand.enabled?await ax(l.tensor,this.config):[],a=Math.trunc(Ze()-r),a>0&&(this.performance.hand=a)),this.analyze("End Hand:"),this.analyze("Start Object:"),this.config.async?(((S=this.config.object.modelPath)==null?void 0:S.includes("nanodet"))?p=this.config.object.enabled?yx(l.tensor,this.config):[]:((C=this.config.object.modelPath)==null?void 0:C.includes("centernet"))&&(p=this.config.object.enabled?vx(l.tensor,this.config):[]),this.performance.object&&delete this.performance.object):(this.state="run:object",r=Ze(),((D=this.config.object.modelPath)==null?void 0:D.includes("nanodet"))?p=this.config.object.enabled?await yx(l.tensor,this.config):[]:((O=this.config.object.modelPath)==null?void 0:O.includes("centernet"))&&(p=this.config.object.enabled?await vx(l.tensor,this.config):[]),a=Math.trunc(Ze()-r),a>0&&(this.performance.object=a)),this.analyze("End Object:"),this.config.async&&([u,c,d,p]=await Promise.all([u,c,d,p]));let h=[];this.config.gesture.enabled&&(r=Ze(),h=[...lI(u),...iI(c),...cI(d),...uI(u)],this.config.async?this.performance.gesture&&delete this.performance.gesture:this.performance.gesture=Math.trunc(Ze()-r)),this.performance.total=Math.trunc(Ze()-i),this.state="idle";let f=((R=(E=this.process)==null?void 0:E.tensor)==null?void 0:R.shape)||[];this.result={face:u,body:c,hand:d,gesture:h,object:p,performance:this.performance,canvas:this.process.canvas,timestamp:Date.now(),get persons(){return fI(u,c,d,h,f)}},Z(l.tensor),this.emit("detect"),s(this.result)})}};Du=new WeakMap,Md=new WeakMap,zd=new WeakMap,D0=new WeakMap;return Mle;})();
|
|
/**
|
|
* @license
|
|
* Copyright 2017 Google LLC. All Rights Reserved.
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
* =============================================================================
|
|
*/
|
|
/**
|
|
* @license
|
|
* Copyright 2018 Google LLC
|
|
*
|
|
* Use of this source code is governed by an MIT-style
|
|
* license that can be found in the LICENSE file or at
|
|
* https://opensource.org/licenses/MIT.
|
|
* =============================================================================
|
|
*/
|
|
/**
|
|
* @license
|
|
* Copyright 2018 Google LLC. All Rights Reserved.
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*
|
|
* =============================================================================
|
|
*/
|
|
/**
|
|
* @license
|
|
* Copyright 2018 Google LLC. All Rights Reserved.
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
* =============================================================================
|
|
*/
|
|
/**
|
|
* @license
|
|
* Copyright 2019 Google LLC
|
|
*
|
|
* Use of this source code is governed by an MIT-style
|
|
* license that can be found in the LICENSE file or at
|
|
* https://opensource.org/licenses/MIT.
|
|
* =============================================================================
|
|
*/
|
|
/**
|
|
* @license
|
|
* Copyright 2019 Google LLC. All Rights Reserved.
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*
|
|
* =============================================================================
|
|
*/
|
|
/**
|
|
* @license
|
|
* Copyright 2019 Google LLC. All Rights Reserved.
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
* =============================================================================
|
|
*/
|
|
/**
|
|
* @license
|
|
* Copyright 2020 Google Inc. All Rights Reserved.
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
* =============================================================================
|
|
*/
|
|
/**
|
|
* @license
|
|
* Copyright 2020 Google LLC
|
|
*
|
|
* Use of this source code is governed by an MIT-style
|
|
* license that can be found in the LICENSE file or at
|
|
* https://opensource.org/licenses/MIT.
|
|
* =============================================================================
|
|
*/
|
|
/**
|
|
* @license
|
|
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
* =============================================================================
|
|
*/
|
|
/**
|
|
* @license
|
|
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
* Licensed under the Apache License, Version 2.0 (the License);
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an AS IS BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
* =============================================================================
|
|
*/
|
|
/**
|
|
* @license
|
|
* Copyright 2021 Google LLC. All Rights Reserved.
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
* =============================================================================
|
|
*/
|
|
/**
|
|
* @license
|
|
* Copyright 2021 Google LLC. All Rights Reserved.
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* https://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
* =============================================================================
|
|
*/
|
|
/**
|
|
* @license
|
|
* Copyright 2018 Google LLC. All Rights Reserved.
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
* =============================================================================
|
|
*/
|
|
/** @license See the LICENSE file. */
|