mirror of https://github.com/vladmandic/human
5656 lines
1.4 MiB
5656 lines
1.4 MiB
/*
|
|
Human
|
|
homepage: <https://github.com/vladmandic/human>
|
|
author: <https://github.com/vladmandic>'
|
|
*/
|
|
|
|
var Human=(()=>{var Eg=Object.defineProperty;var XC=(e,t,n)=>t in e?Eg(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var KC=e=>Eg(e,"__esModule",{value:!0});var ra=(e=>typeof require!="undefined"?require:typeof Proxy!="undefined"?new Proxy(e,{get:(t,n)=>(typeof require!="undefined"?require:t)[n]}):e)(function(e){if(typeof require!="undefined")return require.apply(this,arguments);throw new Error('Dynamic require of "'+e+'" is not supported')});var lc=(e,t)=>{KC(e);for(var n in t)Eg(e,n,{get:t[n],enumerable:!0})};var he=(e,t,n)=>(XC(e,typeof t!="symbol"?t+"":t,n),n),P5=(e,t,n)=>{if(!t.has(e))throw TypeError("Cannot "+n)};var uc=(e,t,n)=>(P5(e,t,"read from private field"),n?n.call(e):t.get(e)),cc=(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)},dc=(e,t,n,s)=>(P5(e,t,"write to private field"),s?s.call(e,n):t.set(e,n),n);var Bce={};lc(Bce,{Human:()=>eC,default:()=>eC,defaults:()=>aa,env:()=>xe});function tt(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 ee(...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 pe=()=>typeof performance!="undefined"?performance.now():parseInt((Number(process.hrtime.bigint())/1e3/1e3).toString());function Rg(e,t,n="config",s=[]){for(let r of Object.keys(t))if(typeof t[r]=="object")Rg(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&&ee("invalid configuration",s),s}function wn(...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]=wn(a,o):n[r]=o}),n),{})}var aa={backend:"",modelBasePath:"",wasmPath:"",debug:!0,async:!0,warmup:"full",cacheSensitivity:.7,skipAllowed:!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:1,skipFrames:99,skipTime:2500,minConfidence:.2,iouThreshold:.1,return:!1},mesh:{enabled:!0,modelPath:"facemesh.json"},iris:{enabled:!0,modelPath:"iris.json"},emotion:{enabled:!0,minConfidence:.1,skipFrames:99,skipTime:1500,modelPath:"emotion.json"},description:{enabled:!0,modelPath:"faceres.json",skipFrames:99,skipTime:3e3,minConfidence:.1},antispoof:{enabled:!1,skipFrames:99,skipTime:4e3,modelPath:"antispoof.json"}},body:{enabled:!0,modelPath:"movenet-lightning.json",detector:{modelPath:""},maxDetected:-1,minConfidence:.3,skipFrames:1,skipTime:200},hand:{enabled:!0,rotation:!0,skipFrames:99,skipTime:2e3,minConfidence:.5,iouThreshold:.2,maxDetected:-1,landmarks:!0,detector:{modelPath:"handtrack.json"},skeleton:{modelPath:"handskeleton.json"}},object:{enabled:!1,modelPath:"mb3-centernet.json",minConfidence:.2,iouThreshold:.4,maxDetected:10,skipFrames:99,skipTime:1e3},segmentation:{enabled:!1,modelPath:"selfie.json",blur:8}};var Xd={};lc(Xd,{Abs:()=>qi,Acos:()=>Xi,Acosh:()=>Ki,AdadeltaOptimizer:()=>hf,AdagradOptimizer:()=>ff,AdamOptimizer:()=>mf,AdamaxOptimizer:()=>gf,Add:()=>la,AddN:()=>Ka,All:()=>Zi,Any:()=>Yi,ArgMax:()=>Za,ArgMin:()=>gc,Asin:()=>Ji,Asinh:()=>Qi,Atan:()=>el,Atan2:()=>nl,Atanh:()=>tl,AvgPool:()=>Ya,AvgPool3D:()=>Ac,AvgPool3DGrad:()=>Bp,AvgPoolGrad:()=>Lp,BackendWasm:()=>X8,BatchMatMul:()=>Ja,BatchToSpaceND:()=>sl,Bincount:()=>Wp,BroadcastArgs:()=>Vp,BroadcastTo:()=>tb,Callback:()=>Hw,CallbackList:()=>Mv,Cast:()=>Qa,Ceil:()=>eo,ClipByValue:()=>ua,Complex:()=>Up,ComplexAbs:()=>yc,Concat:()=>rl,Conv2D:()=>to,Conv2DBackpropFilter:()=>Gp,Conv2DBackpropInput:()=>no,Conv3D:()=>xc,Conv3DBackpropFilterV2:()=>Hp,Conv3DBackpropInputV2:()=>jp,Cos:()=>so,Cosh:()=>ro,CropAndResize:()=>al,Cumsum:()=>ao,CustomCallback:()=>Lv,DataStorage:()=>$p,DenseBincount:()=>qp,DepthToSpace:()=>ol,DepthwiseConv2dNative:()=>oo,DepthwiseConv2dNativeBackpropFilter:()=>Xp,DepthwiseConv2dNativeBackpropInput:()=>Kp,Diag:()=>Zp,Dilation2D:()=>bc,Dilation2DBackpropFilter:()=>Jp,Dilation2DBackpropInput:()=>Yp,ENV:()=>hr,EarlyStopping:()=>qw,Einsum:()=>Qp,Elu:()=>lo,EluGrad:()=>eh,Environment:()=>Q5,Equal:()=>ll,Erf:()=>il,Exp:()=>uo,ExpandDims:()=>ul,Expm1:()=>cl,FFT:()=>th,Fill:()=>vc,FlipLeftRight:()=>dl,Floor:()=>co,FloorDiv:()=>po,FromPixels:()=>wh,FusedBatchNorm:()=>ho,FusedConv2D:()=>qo,FusedDepthwiseConv2D:()=>Xo,GPGPUContext:()=>g0,GatherNd:()=>hl,GatherV2:()=>pl,GraphModel:()=>S7,Greater:()=>fl,GreaterEqual:()=>fo,History:()=>zv,IFFT:()=>nh,Identity:()=>mo,Imag:()=>sh,InputSpec:()=>Ht,IsFinite:()=>ml,IsInf:()=>gl,IsNan:()=>Al,KernelBackend:()=>hc,LRN:()=>Ic,LRNGrad:()=>ah,LayerVariable:()=>_v,LayersModel:()=>Ur,LeakyRelu:()=>go,Less:()=>yl,LessEqual:()=>xl,LinSpace:()=>rh,Log:()=>Ao,Log1p:()=>bl,LogSoftmax:()=>nb,LogicalAnd:()=>vl,LogicalNot:()=>wc,LogicalOr:()=>kc,MathBackendWebGL:()=>Ou,Max:()=>yo,MaxPool:()=>bo,MaxPool3D:()=>Sc,MaxPool3DGrad:()=>ih,MaxPoolGrad:()=>oh,MaxPoolWithArgmax:()=>lh,Maximum:()=>xo,Mean:()=>vo,Min:()=>wo,Minimum:()=>ko,MirrorPad:()=>Io,Mod:()=>wl,MomentumOptimizer:()=>Af,Multinomial:()=>uh,Multiply:()=>So,Neg:()=>kl,NonMaxSuppressionV3:()=>Sl,NonMaxSuppressionV4:()=>Cl,NonMaxSuppressionV5:()=>Tl,NotEqual:()=>Il,OP_SCOPE_SUFFIX:()=>Ab,OneHot:()=>Co,OnesLike:()=>Nl,Optimizer:()=>Br,Pack:()=>El,PadV2:()=>To,Pool:()=>HT,Pow:()=>No,Prelu:()=>Eo,Prod:()=>Rl,RMSPropOptimizer:()=>yf,RNN:()=>Sr,Range:()=>Cc,Rank:()=>Wg,Real:()=>ch,RealDiv:()=>io,Reciprocal:()=>Dl,Reduction:()=>_n,Relu:()=>Ro,Relu6:()=>_o,Reshape:()=>_l,ResizeBilinear:()=>Do,ResizeBilinearGrad:()=>ph,ResizeNearestNeighbor:()=>Tc,ResizeNearestNeighborGrad:()=>dh,Reverse:()=>Fo,RotateWithOffset:()=>ql,Round:()=>$o,Rsqrt:()=>Oo,SGDOptimizer:()=>od,ScatterNd:()=>Fl,Select:()=>$l,Selu:()=>Ol,Sequential:()=>vu,Sigmoid:()=>Mo,Sign:()=>zl,Sin:()=>Po,Sinh:()=>Ml,Slice:()=>Pl,Softmax:()=>Bo,Softplus:()=>Ll,SpaceToBatchND:()=>Bl,SparseFillEmptyRows:()=>hh,SparseReshape:()=>fh,SparseSegmentMean:()=>mh,SparseSegmentSum:()=>gh,SparseToDense:()=>Ah,SplitV:()=>Wl,Sqrt:()=>zo,Square:()=>Nc,SquaredDifference:()=>Wo,Step:()=>da,StridedSlice:()=>Vl,StringNGrams:()=>yh,StringSplit:()=>xh,StringToHashBucketFast:()=>bh,Sub:()=>Vo,Sum:()=>Lo,SymbolicTensor:()=>nr,Tan:()=>Uo,Tanh:()=>Go,Tensor:()=>Ge,TensorBuffer:()=>Zt,Tile:()=>ca,TopK:()=>Ul,Transform:()=>Gl,Transpose:()=>Ho,Unique:()=>vh,Unpack:()=>Hl,UnsortedSegmentSum:()=>Ec,Variable:()=>Mc,ZerosLike:()=>jl,_FusedMatMul:()=>jo,abs:()=>Vt,acos:()=>gA,acosh:()=>AA,add:()=>le,addN:()=>Oh,all:()=>Ph,any:()=>Uc,argMax:()=>xs,argMin:()=>yA,asin:()=>xA,asinh:()=>bA,atan:()=>vA,atan2:()=>wA,atanh:()=>kA,avgPool:()=>Hc,avgPool3d:()=>CA,backend:()=>gr,backend_util:()=>N,basicLSTMCell:()=>SE,batchNorm:()=>si,batchNorm2d:()=>o3,batchNorm3d:()=>i3,batchNorm4d:()=>l3,batchToSpaceND:()=>jc,bincount:()=>TA,booleanMaskAsync:()=>__,broadcastArgs:()=>u3,broadcastTo:()=>su,browser:()=>Os,buffer:()=>He,callbacks:()=>jB,cast:()=>de,ceil:()=>NA,clipByValue:()=>jn,clone:()=>Xs,complex:()=>fa,concat:()=>mt,concat1d:()=>c3,concat2d:()=>ru,concat3d:()=>d3,concat4d:()=>p3,constraints:()=>dv,conv1d:()=>zh,conv2d:()=>Mr,conv2dTranspose:()=>Lh,conv3d:()=>RA,conv3dTranspose:()=>f3,copyRegisteredKernels:()=>XT,cos:()=>qc,cosh:()=>Bh,cosineWindow:()=>s1,cumsum:()=>Wh,customGrad:()=>yr,data:()=>C7,denseBincount:()=>m3,deprecationWarn:()=>fA,depthToSpace:()=>DA,depthwiseConv2d:()=>au,deregisterOp:()=>XB,device_util:()=>Lc,diag:()=>tR,dilation2d:()=>_A,disableDeprecationWarnings:()=>WN,dispose:()=>Z,disposeVariables:()=>VN,div:()=>fe,divNoNan:()=>FA,dot:()=>g3,dropout:()=>M3,einsum:()=>A3,elu:()=>ou,enableDebugMode:()=>BN,enableProdMode:()=>t3,enclosingPowerOfTwo:()=>z3,engine:()=>ts,env:()=>Y,equal:()=>ns,erf:()=>$A,exp:()=>ss,expandDims:()=>Lt,expm1:()=>OA,eye:()=>PA,fft:()=>sd,fill:()=>iu,findBackend:()=>mA,findBackendFactory:()=>jN,floor:()=>lu,floorDiv:()=>$h,forceHalfFloat:()=>Q4,fused:()=>va,gather:()=>ri,gatherND:()=>P3,gather_util:()=>iA,getBackend:()=>Ks,getGradient:()=>Mg,getKernel:()=>kh,getKernelsForBackend:()=>Or,getThreadsCount:()=>Rue,gpgpu_util:()=>T4,grad:()=>DR,grads:()=>_R,greater:()=>qn,greaterEqual:()=>xa,ifft:()=>hu,imag:()=>Vh,image:()=>_e,inTopKAsync:()=>U_,initializers:()=>yv,input:()=>lw,io:()=>Gn,irfft:()=>nf,isFinite:()=>y3,isInf:()=>x3,isNaN:()=>MA,keep:()=>an,kernel_impls:()=>br,layers:()=>Ev,leakyRelu:()=>Xc,less:()=>Uh,lessEqual:()=>ba,linalg:()=>Z3,linspace:()=>b3,loadGraphModel:()=>Qe,loadLayersModel:()=>nL,localResponseNormalization:()=>zA,log:()=>rs,log1p:()=>Kc,logSigmoid:()=>w3,logSoftmax:()=>Hh,logSumExp:()=>WA,logicalAnd:()=>Ps,logicalNot:()=>Zc,logicalOr:()=>jh,logicalXor:()=>C3,losses:()=>S$,matMul:()=>Ve,math:()=>Ob,max:()=>Rn,maxPool:()=>Yc,maxPool3d:()=>VA,maxPoolWithArgmax:()=>T3,maximum:()=>xr,mean:()=>_t,memory:()=>_h,meshgrid:()=>eD,metrics:()=>Vw,min:()=>Jc,minimum:()=>uu,mirrorPad:()=>UA,mod:()=>GA,model:()=>eL,models:()=>Uw,moments:()=>qh,movingAverage:()=>O_,mul:()=>L,multiRNNCell:()=>lD,multinomial:()=>N3,neg:()=>Ct,nextFrame:()=>Y3,norm:()=>of,notEqual:()=>ii,oneHot:()=>Ql,ones:()=>as,onesLike:()=>os,op:()=>W,outerProduct:()=>hD,pad:()=>vs,pad1d:()=>gD,pad2d:()=>yD,pad3d:()=>bD,pad4d:()=>wD,pool:()=>E3,pow:()=>zr,prelu:()=>ed,print:()=>Eb,prod:()=>Xh,profile:()=>UN,rand:()=>DD,randomGamma:()=>OD,randomNormal:()=>R3,randomUniform:()=>cu,range:()=>du,ready:()=>Fh,real:()=>td,reciprocal:()=>qA,registerBackend:()=>tu,registerCallbackConstructor:()=>sL,registerGradient:()=>sb,registerKernel:()=>pa,registerOp:()=>qB,regularizers:()=>Gw,relu:()=>Zs,relu6:()=>Kh,removeBackend:()=>HN,reshape:()=>V,reverse:()=>is,reverse1d:()=>GD,reverse2d:()=>jD,reverse3d:()=>XD,reverse4d:()=>ZD,rfft:()=>rd,round:()=>Zh,rsqrt:()=>Yh,scalar:()=>Ee,scatterND:()=>O3,scatter_util:()=>lA,selu:()=>Jh,separableConv2d:()=>XA,sequential:()=>tL,serialization:()=>ue,setBackend:()=>n3,setPlatform:()=>qN,setThreadsCount:()=>Eue,setWasmPath:()=>Nue,setWasmPaths:()=>Z8,setWebGLContext:()=>i0,setdiff1dAsync:()=>D3,sigmoid:()=>Hn,sign:()=>KA,signal:()=>I$,sin:()=>Qh,sinh:()=>ef,slice:()=>Fe,slice1d:()=>tf,slice2d:()=>ZA,slice3d:()=>pu,slice4d:()=>nd,slice_util:()=>En,softmax:()=>li,softplus:()=>ai,spaceToBatchND:()=>Qc,sparse:()=>ad,sparseToDense:()=>n1,spectral:()=>k$,split:()=>on,sqrt:()=>mn,square:()=>ht,squaredDifference:()=>sf,squeeze:()=>rt,stack:()=>gn,step:()=>fu,stridedSlice:()=>YA,string:()=>pf,sub:()=>be,sum:()=>Ie,sumOutType:()=>Nh,tan:()=>JA,tanh:()=>ni,tensor:()=>zt,tensor1d:()=>Gt,tensor2d:()=>Ys,tensor3d:()=>Pb,tensor4d:()=>w_,tensor5d:()=>k_,tensor6d:()=>I_,tensor_util:()=>js,test_util:()=>Jb,tidy:()=>G,tile:()=>bs,time:()=>GN,topk:()=>QA,train:()=>ci,transpose:()=>Ke,truncatedNormal:()=>rf,unique:()=>af,unregisterGradient:()=>qT,unregisterKernel:()=>jT,unsortedSegmentSum:()=>e1,unstack:()=>Dn,upcastType:()=>$s,util:()=>w,valueAndGrad:()=>FR,valueAndGrads:()=>$R,variable:()=>_3,variableGrads:()=>v3,version:()=>Wue,version_converter:()=>YW,version_core:()=>Vc,version_layers:()=>z1,version_wasm:()=>Due,version_webgl:()=>uY,webgl:()=>cY,webgl_util:()=>Y6,where:()=>In,whereAsync:()=>t1,zeros:()=>Ut,zerosLike:()=>Ze});var ZC=Object.create,Fp=Object.defineProperty,YC=Object.getOwnPropertyDescriptor,JC=Object.getOwnPropertyNames,QC=Object.getPrototypeOf,eT=Object.prototype.hasOwnProperty,M5=e=>Fp(e,"__esModule",{value:!0}),Gi=(e=>typeof ra!="undefined"?ra:typeof Proxy!="undefined"?new Proxy(e,{get:(t,n)=>(typeof ra!="undefined"?ra:t)[n]}):e)(function(e){if(typeof ra!="undefined")return ra.apply(this,arguments);throw new Error('Dynamic require of "'+e+'" is not supported')}),St=(e,t)=>function(){return t||(0,e[Object.keys(e)[0]])((t={exports:{}}).exports,t),t.exports},ze=(e,t)=>{M5(e);for(var n in t)Fp(e,n,{get:t[n],enumerable:!0})},tT=(e,t,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of JC(t))!eT.call(e,s)&&s!=="default"&&Fp(e,s,{get:()=>t[s],enumerable:!(n=YC(t,s))||n.enumerable});return e},ja=e=>tT(M5(Fp(e!=null?ZC(QC(e)):{},"default",e&&e.__esModule&&"default"in e?{get:()=>e.default,enumerable:!0}:{value:e,enumerable:!0})),e),nT=St({"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{}function s(F,C,M){this.low=F|0,this.high=C|0,this.unsigned=!!M}s.prototype.__isLong__,Object.defineProperty(s.prototype,"__isLong__",{value:!0});function r(F){return(F&&F.__isLong__)===!0}s.isLong=r;var a={},o={};function i(F,C){var M,U,j;return C?(F>>>=0,(j=0<=F&&F<256)&&(U=o[F],U)?U:(M=c(F,(F|0)<0?-1:0,!0),j&&(o[F]=M),M)):(F|=0,(j=-128<=F&&F<128)&&(U=a[F],U)?U:(M=c(F,F<0?-1:0,!1),j&&(a[F]=M),M))}s.fromInt=i;function l(F,C){if(isNaN(F))return C?b:x;if(C){if(F<0)return b;if(F>=g)return O}else{if(F<=-A)return P;if(F+1>=A)return _}return F<0?l(-F,C).neg():c(F%m|0,F/m|0,C)}s.fromNumber=l;function c(F,C,M){return new s(F,C,M)}s.fromBits=c;var u=Math.pow;function d(F,C,M){if(F.length===0)throw Error("empty string");if(F==="NaN"||F==="Infinity"||F==="+Infinity"||F==="-Infinity")return x;if(typeof C=="number"?(M=C,C=!1):C=!!C,M=M||10,M<2||36<M)throw RangeError("radix");var U;if((U=F.indexOf("-"))>0)throw Error("interior hyphen");if(U===0)return d(F.substring(1),C,M).neg();for(var j=l(u(M,8)),q=x,X=0;X<F.length;X+=8){var te=Math.min(8,F.length-X),ne=parseInt(F.substring(X,X+te),M);if(te<8){var se=l(u(M,te));q=q.mul(se).add(l(ne))}else q=q.mul(j),q=q.add(l(ne))}return q.unsigned=C,q}s.fromString=d;function p(F,C){return typeof F=="number"?l(F,C):typeof F=="string"?d(F,C):c(F.low,F.high,typeof C=="boolean"?C:F.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 S=i(1,!0);s.UONE=S;var T=i(-1);s.NEG_ONE=T;var _=c(4294967295|0,2147483647|0,!1);s.MAX_VALUE=_;var O=c(4294967295|0,4294967295|0,!0);s.MAX_UNSIGNED_VALUE=O;var P=c(0,2147483648|0,!1);s.MIN_VALUE=P;var D=s.prototype;D.toInt=function(){return this.unsigned?this.low>>>0:this.low},D.toNumber=function(){return this.unsigned?(this.high>>>0)*m+(this.low>>>0):this.high*m+(this.low>>>0)},D.toString=function(C){if(C=C||10,C<2||36<C)throw RangeError("radix");if(this.isZero())return"0";if(this.isNegative())if(this.eq(P)){var M=l(C),U=this.div(M),j=U.mul(M).sub(this);return U.toString(C)+j.toInt().toString(C)}else return"-"+this.neg().toString(C);for(var q=l(u(C,6),this.unsigned),X=this,te="";;){var ne=X.div(q),se=X.sub(ne.mul(q)).toInt()>>>0,oe=se.toString(C);if(X=ne,X.isZero())return oe+te;for(;oe.length<6;)oe="0"+oe;te=""+oe+te}},D.getHighBits=function(){return this.high},D.getHighBitsUnsigned=function(){return this.high>>>0},D.getLowBits=function(){return this.low},D.getLowBitsUnsigned=function(){return this.low>>>0},D.getNumBitsAbs=function(){if(this.isNegative())return this.eq(P)?64:this.neg().getNumBitsAbs();for(var C=this.high!=0?this.high:this.low,M=31;M>0&&(C&1<<M)==0;M--);return this.high!=0?M+33:M+1},D.isZero=function(){return this.high===0&&this.low===0},D.eqz=D.isZero,D.isNegative=function(){return!this.unsigned&&this.high<0},D.isPositive=function(){return this.unsigned||this.high>=0},D.isOdd=function(){return(this.low&1)==1},D.isEven=function(){return(this.low&1)==0},D.equals=function(C){return r(C)||(C=p(C)),this.unsigned!==C.unsigned&&this.high>>>31==1&&C.high>>>31==1?!1:this.high===C.high&&this.low===C.low},D.eq=D.equals,D.notEquals=function(C){return!this.eq(C)},D.neq=D.notEquals,D.ne=D.notEquals,D.lessThan=function(C){return this.comp(C)<0},D.lt=D.lessThan,D.lessThanOrEqual=function(C){return this.comp(C)<=0},D.lte=D.lessThanOrEqual,D.le=D.lessThanOrEqual,D.greaterThan=function(C){return this.comp(C)>0},D.gt=D.greaterThan,D.greaterThanOrEqual=function(C){return this.comp(C)>=0},D.gte=D.greaterThanOrEqual,D.ge=D.greaterThanOrEqual,D.compare=function(C){if(r(C)||(C=p(C)),this.eq(C))return 0;var M=this.isNegative(),U=C.isNegative();return M&&!U?-1:!M&&U?1:this.unsigned?C.high>>>0>this.high>>>0||C.high===this.high&&C.low>>>0>this.low>>>0?-1:1:this.sub(C).isNegative()?-1:1},D.comp=D.compare,D.negate=function(){return!this.unsigned&&this.eq(P)?P:this.not().add(v)},D.neg=D.negate,D.add=function(C){r(C)||(C=p(C));var M=this.high>>>16,U=this.high&65535,j=this.low>>>16,q=this.low&65535,X=C.high>>>16,te=C.high&65535,ne=C.low>>>16,se=C.low&65535,oe=0,ae=0,re=0,ce=0;return ce+=q+se,re+=ce>>>16,ce&=65535,re+=j+ne,ae+=re>>>16,re&=65535,ae+=U+te,oe+=ae>>>16,ae&=65535,oe+=M+X,oe&=65535,c(re<<16|ce,oe<<16|ae,this.unsigned)},D.subtract=function(C){return r(C)||(C=p(C)),this.add(C.neg())},D.sub=D.subtract,D.multiply=function(C){if(this.isZero())return x;if(r(C)||(C=p(C)),n){var M=n.mul(this.low,this.high,C.low,C.high);return c(M,n.get_high(),this.unsigned)}if(C.isZero())return x;if(this.eq(P))return C.isOdd()?P:x;if(C.eq(P))return this.isOdd()?P:x;if(this.isNegative())return C.isNegative()?this.neg().mul(C.neg()):this.neg().mul(C).neg();if(C.isNegative())return this.mul(C.neg()).neg();if(this.lt(y)&&C.lt(y))return l(this.toNumber()*C.toNumber(),this.unsigned);var U=this.high>>>16,j=this.high&65535,q=this.low>>>16,X=this.low&65535,te=C.high>>>16,ne=C.high&65535,se=C.low>>>16,oe=C.low&65535,ae=0,re=0,ce=0,ge=0;return ge+=X*oe,ce+=ge>>>16,ge&=65535,ce+=q*oe,re+=ce>>>16,ce&=65535,ce+=X*se,re+=ce>>>16,ce&=65535,re+=j*oe,ae+=re>>>16,re&=65535,re+=q*se,ae+=re>>>16,re&=65535,re+=X*ne,ae+=re>>>16,re&=65535,ae+=U*oe+j*se+q*ne+X*te,ae&=65535,c(ce<<16|ge,ae<<16|re,this.unsigned)},D.mul=D.multiply,D.divide=function(C){if(r(C)||(C=p(C)),C.isZero())throw Error("division by zero");if(n){if(!this.unsigned&&this.high===-2147483648&&C.low===-1&&C.high===-1)return this;var M=(this.unsigned?n.div_u:n.div_s)(this.low,this.high,C.low,C.high);return c(M,n.get_high(),this.unsigned)}if(this.isZero())return this.unsigned?b:x;var U,j,q;if(this.unsigned){if(C.unsigned||(C=C.toUnsigned()),C.gt(this))return b;if(C.gt(this.shru(1)))return S;q=b}else{if(this.eq(P)){if(C.eq(v)||C.eq(T))return P;if(C.eq(P))return v;var X=this.shr(1);return U=X.div(C).shl(1),U.eq(x)?C.isNegative()?v:T:(j=this.sub(C.mul(U)),q=U.add(j.div(C)),q)}else if(C.eq(P))return this.unsigned?b:x;if(this.isNegative())return C.isNegative()?this.neg().div(C.neg()):this.neg().div(C).neg();if(C.isNegative())return this.div(C.neg()).neg();q=x}for(j=this;j.gte(C);){U=Math.max(1,Math.floor(j.toNumber()/C.toNumber()));for(var te=Math.ceil(Math.log(U)/Math.LN2),ne=te<=48?1:u(2,te-48),se=l(U),oe=se.mul(C);oe.isNegative()||oe.gt(j);)U-=ne,se=l(U,this.unsigned),oe=se.mul(C);se.isZero()&&(se=v),q=q.add(se),j=j.sub(oe)}return q},D.div=D.divide,D.modulo=function(C){if(r(C)||(C=p(C)),n){var M=(this.unsigned?n.rem_u:n.rem_s)(this.low,this.high,C.low,C.high);return c(M,n.get_high(),this.unsigned)}return this.sub(this.div(C).mul(C))},D.mod=D.modulo,D.rem=D.modulo,D.not=function(){return c(~this.low,~this.high,this.unsigned)},D.and=function(C){return r(C)||(C=p(C)),c(this.low&C.low,this.high&C.high,this.unsigned)},D.or=function(C){return r(C)||(C=p(C)),c(this.low|C.low,this.high|C.high,this.unsigned)},D.xor=function(C){return r(C)||(C=p(C)),c(this.low^C.low,this.high^C.high,this.unsigned)},D.shiftLeft=function(C){return r(C)&&(C=C.toInt()),(C&=63)==0?this:C<32?c(this.low<<C,this.high<<C|this.low>>>32-C,this.unsigned):c(0,this.low<<C-32,this.unsigned)},D.shl=D.shiftLeft,D.shiftRight=function(C){return r(C)&&(C=C.toInt()),(C&=63)==0?this:C<32?c(this.low>>>C|this.high<<32-C,this.high>>C,this.unsigned):c(this.high>>C-32,this.high>=0?0:-1,this.unsigned)},D.shr=D.shiftRight,D.shiftRightUnsigned=function(C){if(r(C)&&(C=C.toInt()),C&=63,C===0)return this;var M=this.high;if(C<32){var U=this.low;return c(U>>>C|M<<32-C,M>>>C,this.unsigned)}else return C===32?c(M,0,this.unsigned):c(M>>>C-32,0,this.unsigned)},D.shru=D.shiftRightUnsigned,D.shr_u=D.shiftRightUnsigned,D.toSigned=function(){return this.unsigned?c(this.low,this.high,!1):this},D.toUnsigned=function(){return this.unsigned?this:c(this.low,this.high,!0)},D.toBytes=function(C){return C?this.toBytesLE():this.toBytesBE()},D.toBytesLE=function(){var C=this.high,M=this.low;return[M&255,M>>>8&255,M>>>16&255,M>>>24,C&255,C>>>8&255,C>>>16&255,C>>>24]},D.toBytesBE=function(){var C=this.high,M=this.low;return[C>>>24,C>>>16&255,C>>>8&255,C&255,M>>>24,M>>>16&255,M>>>8&255,M&255]},s.fromBytes=function(C,M,U){return U?s.fromBytesLE(C,M):s.fromBytesBE(C,M)},s.fromBytesLE=function(C,M){return new s(C[0]|C[1]<<8|C[2]<<16|C[3]<<24,C[4]|C[5]<<8|C[6]<<16|C[7]<<24,M)},s.fromBytesBE=function(C,M){return new s(C[4]<<24|C[5]<<16|C[6]<<8|C[7],C[0]<<24|C[1]<<16|C[2]<<8|C[3],M)}}}),sT=St({"(disabled):node_modules/.pnpm/node-fetch@2.6.5/node_modules/node-fetch/browser.js"(){}}),rT=St({"node_modules/.pnpm/seedrandom@2.4.3/node_modules/seedrandom/lib/alea.js"(e,t){(function(n,s,r){function a(c){var u=this,d=l();u.next=function(){var p=2091639*u.s0+u.c*23283064365386963e-26;return u.s0=u.s1,u.s1=u.s2,u.s2=p-(u.c=p|0)},u.c=1,u.s0=d(" "),u.s1=d(" "),u.s2=d(" "),u.s0-=d(c),u.s0<0&&(u.s0+=1),u.s1-=d(c),u.s1<0&&(u.s1+=1),u.s2-=d(c),u.s2<0&&(u.s2+=1),d=null}function o(c,u){return u.c=c.c,u.s0=c.s0,u.s1=c.s1,u.s2=c.s2,u}function i(c,u){var d=new a(c),p=u&&u.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 c=4022871197,u=function(d){d=d.toString();for(var p=0;p<d.length;p++){c+=d.charCodeAt(p);var h=.02519603282416938*c;c=h>>>0,h-=c,h*=c,c=h>>>0,h-=c,c+=h*4294967296}return(c>>>0)*23283064365386963e-26};return u}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)}}),aT=St({"node_modules/.pnpm/seedrandom@2.4.3/node_modules/seedrandom/lib/xor128.js"(e,t){(function(n,s,r){function a(l){var c=this,u="";c.x=0,c.y=0,c.z=0,c.w=0,c.next=function(){var p=c.x^c.x<<11;return c.x=c.y,c.y=c.z,c.z=c.w,c.w^=c.w>>>19^p^p>>>8},l===(l|0)?c.x=l:u+=l;for(var d=0;d<u.length+64;d++)c.x^=u.charCodeAt(d)|0,c.next()}function o(l,c){return c.x=l.x,c.y=l.y,c.z=l.z,c.w=l.w,c}function i(l,c){var u=new a(l),d=c&&c.state,p=function(){return(u.next()>>>0)/4294967296};return p.double=function(){do var h=u.next()>>>11,f=(u.next()>>>0)/4294967296,m=(h+f)/(1<<21);while(m===0);return m},p.int32=u.next,p.quick=p,d&&(typeof d=="object"&&o(d,u),p.state=function(){return o(u,{})}),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)}}),oT=St({"node_modules/.pnpm/seedrandom@2.4.3/node_modules/seedrandom/lib/xorwow.js"(e,t){(function(n,s,r){function a(l){var c=this,u="";c.next=function(){var p=c.x^c.x>>>2;return c.x=c.y,c.y=c.z,c.z=c.w,c.w=c.v,(c.d=c.d+362437|0)+(c.v=c.v^c.v<<4^(p^p<<1))|0},c.x=0,c.y=0,c.z=0,c.w=0,c.v=0,l===(l|0)?c.x=l:u+=l;for(var d=0;d<u.length+64;d++)c.x^=u.charCodeAt(d)|0,d==u.length&&(c.d=c.x<<10^c.x>>>4),c.next()}function o(l,c){return c.x=l.x,c.y=l.y,c.z=l.z,c.w=l.w,c.v=l.v,c.d=l.d,c}function i(l,c){var u=new a(l),d=c&&c.state,p=function(){return(u.next()>>>0)/4294967296};return p.double=function(){do var h=u.next()>>>11,f=(u.next()>>>0)/4294967296,m=(h+f)/(1<<21);while(m===0);return m},p.int32=u.next,p.quick=p,d&&(typeof d=="object"&&o(d,u),p.state=function(){return o(u,{})}),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)}}),iT=St({"node_modules/.pnpm/seedrandom@2.4.3/node_modules/seedrandom/lib/xorshift7.js"(e,t){(function(n,s,r){function a(l){var c=this;c.next=function(){var d=c.x,p=c.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,c.i=p+1&7,f};function u(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()}u(c,l)}function o(l,c){return c.x=l.x.slice(),c.i=l.i,c}function i(l,c){l==null&&(l=+new Date);var u=new a(l),d=c&&c.state,p=function(){return(u.next()>>>0)/4294967296};return p.double=function(){do var h=u.next()>>>11,f=(u.next()>>>0)/4294967296,m=(h+f)/(1<<21);while(m===0);return m},p.int32=u.next,p.quick=p,d&&(d.x&&o(d,u),p.state=function(){return o(u,{})}),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)}}),lT=St({"node_modules/.pnpm/seedrandom@2.4.3/node_modules/seedrandom/lib/xor4096.js"(e,t){(function(n,s,r){function a(l){var c=this;c.next=function(){var d=c.w,p=c.X,h=c.i,f,m;return c.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,c.i=h,m+(d^d>>>16)|0};function u(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}u(c,l)}function o(l,c){return c.i=l.i,c.w=l.w,c.X=l.X.slice(),c}function i(l,c){l==null&&(l=+new Date);var u=new a(l),d=c&&c.state,p=function(){return(u.next()>>>0)/4294967296};return p.double=function(){do var h=u.next()>>>11,f=(u.next()>>>0)/4294967296,m=(h+f)/(1<<21);while(m===0);return m},p.int32=u.next,p.quick=p,d&&(d.X&&o(d,u),p.state=function(){return o(u,{})}),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)}}),uT=St({"node_modules/.pnpm/seedrandom@2.4.3/node_modules/seedrandom/lib/tychei.js"(e,t){(function(n,s,r){function a(l){var c=this,u="";c.next=function(){var p=c.b,h=c.c,f=c.d,m=c.a;return p=p<<25^p>>>7^h,h=h-f|0,f=f<<24^f>>>8^m,m=m-p|0,c.b=p=p<<20^p>>>12^h,c.c=h=h-f|0,c.d=f<<16^h>>>16^m,c.a=m-p|0},c.a=0,c.b=0,c.c=2654435769|0,c.d=1367130551,l===Math.floor(l)?(c.a=l/4294967296|0,c.b=l|0):u+=l;for(var d=0;d<u.length+20;d++)c.b^=u.charCodeAt(d)|0,c.next()}function o(l,c){return c.a=l.a,c.b=l.b,c.c=l.c,c.d=l.d,c}function i(l,c){var u=new a(l),d=c&&c.state,p=function(){return(u.next()>>>0)/4294967296};return p.double=function(){do var h=u.next()>>>11,f=(u.next()>>>0)/4294967296,m=(h+f)/(1<<21);while(m===0);return m},p.int32=u.next,p.quick=p,d&&(typeof d=="object"&&o(d,u),p.state=function(){return o(u,{})}),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)}}),z5=St({"(disabled):crypto"(){}}),cT=St({"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",c=s.pow(a,o),u=s.pow(2,i),d=u*2,p=a-1,h;function f(v,S,T){var _=[];S=S==!0?{entropy:!0}:S||{};var O=y(A(S.entropy?[v,b(n)]:v??x(),3),_),P=new m(_),D=function(){for(var F=P.g(o),C=c,M=0;F<u;)F=(F+M)*a,C*=a,M=P.g(1);for(;F>=d;)F/=2,C/=2,M>>>=1;return(F+M)/C};return D.int32=function(){return P.g(4)|0},D.quick=function(){return P.g(4)/4294967296},D.double=D,y(b(P.S),n),(S.pass||T||function(F,C,M,U){return U&&(U.S&&g(U,P),F.state=function(){return g(P,{})}),M?(s[l]=F,C):F})(D,O,"global"in S?S.global:this==s,S.state)}s["seed"+l]=f;function m(v){var S,T=v.length,_=this,O=0,P=_.i=_.j=0,D=_.S=[];for(T||(v=[T++]);O<a;)D[O]=O++;for(O=0;O<a;O++)D[O]=D[P=p&P+v[O%T]+(S=D[O])],D[P]=S;(_.g=function(F){for(var C,M=0,U=_.i,j=_.j,q=_.S;F--;)C=q[U=p&U+1],M=M*a+q[p&(q[U]=q[j=p&j+C])+(q[j]=C)];return _.i=U,_.j=j,M})(a)}function g(v,S){return S.i=v.i,S.j=v.j,S.S=v.S.slice(),S}function A(v,S){var T=[],_=typeof v,O;if(S&&_=="object")for(O in v)try{T.push(A(v[O],S-1))}catch{}return T.length?T:_=="string"?v:v+"\0"}function y(v,S){for(var T=v+"",_,O=0;O<T.length;)S[p&O]=p&(_^=S[p&O]*19)+T.charCodeAt(O++);return b(S)}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{var S=r.navigator,T=S&&S.plugins;return[+new Date,r,T,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=z5()}catch{}}else typeof define=="function"&&define.amd&&define(function(){return f})})([],Math)}}),L5=St({"node_modules/.pnpm/seedrandom@2.4.3/node_modules/seedrandom/index.js"(e,t){var n=rT(),s=aT(),r=oT(),a=iT(),o=lT(),i=uT(),l=cT();l.alea=n,l.xor128=s,l.xorwow=r,l.xorshift7=a,l.xor4096=o,l.tychei=i,t.exports=l}}),dT=St({"node_modules/.pnpm/seedrandom@3.0.5/node_modules/seedrandom/lib/alea.js"(e,t){(function(n,s,r){function a(c){var u=this,d=l();u.next=function(){var p=2091639*u.s0+u.c*23283064365386963e-26;return u.s0=u.s1,u.s1=u.s2,u.s2=p-(u.c=p|0)},u.c=1,u.s0=d(" "),u.s1=d(" "),u.s2=d(" "),u.s0-=d(c),u.s0<0&&(u.s0+=1),u.s1-=d(c),u.s1<0&&(u.s1+=1),u.s2-=d(c),u.s2<0&&(u.s2+=1),d=null}function o(c,u){return u.c=c.c,u.s0=c.s0,u.s1=c.s1,u.s2=c.s2,u}function i(c,u){var d=new a(c),p=u&&u.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 c=4022871197,u=function(d){d=String(d);for(var p=0;p<d.length;p++){c+=d.charCodeAt(p);var h=.02519603282416938*c;c=h>>>0,h-=c,h*=c,c=h>>>0,h-=c,c+=h*4294967296}return(c>>>0)*23283064365386963e-26};return u}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)}}),pT=St({"node_modules/.pnpm/seedrandom@3.0.5/node_modules/seedrandom/lib/xor128.js"(e,t){(function(n,s,r){function a(l){var c=this,u="";c.x=0,c.y=0,c.z=0,c.w=0,c.next=function(){var p=c.x^c.x<<11;return c.x=c.y,c.y=c.z,c.z=c.w,c.w^=c.w>>>19^p^p>>>8},l===(l|0)?c.x=l:u+=l;for(var d=0;d<u.length+64;d++)c.x^=u.charCodeAt(d)|0,c.next()}function o(l,c){return c.x=l.x,c.y=l.y,c.z=l.z,c.w=l.w,c}function i(l,c){var u=new a(l),d=c&&c.state,p=function(){return(u.next()>>>0)/4294967296};return p.double=function(){do var h=u.next()>>>11,f=(u.next()>>>0)/4294967296,m=(h+f)/(1<<21);while(m===0);return m},p.int32=u.next,p.quick=p,d&&(typeof d=="object"&&o(d,u),p.state=function(){return o(u,{})}),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)}}),hT=St({"node_modules/.pnpm/seedrandom@3.0.5/node_modules/seedrandom/lib/xorwow.js"(e,t){(function(n,s,r){function a(l){var c=this,u="";c.next=function(){var p=c.x^c.x>>>2;return c.x=c.y,c.y=c.z,c.z=c.w,c.w=c.v,(c.d=c.d+362437|0)+(c.v=c.v^c.v<<4^(p^p<<1))|0},c.x=0,c.y=0,c.z=0,c.w=0,c.v=0,l===(l|0)?c.x=l:u+=l;for(var d=0;d<u.length+64;d++)c.x^=u.charCodeAt(d)|0,d==u.length&&(c.d=c.x<<10^c.x>>>4),c.next()}function o(l,c){return c.x=l.x,c.y=l.y,c.z=l.z,c.w=l.w,c.v=l.v,c.d=l.d,c}function i(l,c){var u=new a(l),d=c&&c.state,p=function(){return(u.next()>>>0)/4294967296};return p.double=function(){do var h=u.next()>>>11,f=(u.next()>>>0)/4294967296,m=(h+f)/(1<<21);while(m===0);return m},p.int32=u.next,p.quick=p,d&&(typeof d=="object"&&o(d,u),p.state=function(){return o(u,{})}),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)}}),fT=St({"node_modules/.pnpm/seedrandom@3.0.5/node_modules/seedrandom/lib/xorshift7.js"(e,t){(function(n,s,r){function a(l){var c=this;c.next=function(){var d=c.x,p=c.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,c.i=p+1&7,f};function u(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()}u(c,l)}function o(l,c){return c.x=l.x.slice(),c.i=l.i,c}function i(l,c){l==null&&(l=+new Date);var u=new a(l),d=c&&c.state,p=function(){return(u.next()>>>0)/4294967296};return p.double=function(){do var h=u.next()>>>11,f=(u.next()>>>0)/4294967296,m=(h+f)/(1<<21);while(m===0);return m},p.int32=u.next,p.quick=p,d&&(d.x&&o(d,u),p.state=function(){return o(u,{})}),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)}}),mT=St({"node_modules/.pnpm/seedrandom@3.0.5/node_modules/seedrandom/lib/xor4096.js"(e,t){(function(n,s,r){function a(l){var c=this;c.next=function(){var d=c.w,p=c.X,h=c.i,f,m;return c.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,c.i=h,m+(d^d>>>16)|0};function u(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}u(c,l)}function o(l,c){return c.i=l.i,c.w=l.w,c.X=l.X.slice(),c}function i(l,c){l==null&&(l=+new Date);var u=new a(l),d=c&&c.state,p=function(){return(u.next()>>>0)/4294967296};return p.double=function(){do var h=u.next()>>>11,f=(u.next()>>>0)/4294967296,m=(h+f)/(1<<21);while(m===0);return m},p.int32=u.next,p.quick=p,d&&(d.X&&o(d,u),p.state=function(){return o(u,{})}),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)}}),gT=St({"node_modules/.pnpm/seedrandom@3.0.5/node_modules/seedrandom/lib/tychei.js"(e,t){(function(n,s,r){function a(l){var c=this,u="";c.next=function(){var p=c.b,h=c.c,f=c.d,m=c.a;return p=p<<25^p>>>7^h,h=h-f|0,f=f<<24^f>>>8^m,m=m-p|0,c.b=p=p<<20^p>>>12^h,c.c=h=h-f|0,c.d=f<<16^h>>>16^m,c.a=m-p|0},c.a=0,c.b=0,c.c=2654435769|0,c.d=1367130551,l===Math.floor(l)?(c.a=l/4294967296|0,c.b=l|0):u+=l;for(var d=0;d<u.length+20;d++)c.b^=u.charCodeAt(d)|0,c.next()}function o(l,c){return c.a=l.a,c.b=l.b,c.c=l.c,c.d=l.d,c}function i(l,c){var u=new a(l),d=c&&c.state,p=function(){return(u.next()>>>0)/4294967296};return p.double=function(){do var h=u.next()>>>11,f=(u.next()>>>0)/4294967296,m=(h+f)/(1<<21);while(m===0);return m},p.int32=u.next,p.quick=p,d&&(typeof d=="object"&&o(d,u),p.state=function(){return o(u,{})}),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)}}),AT=St({"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",c=r.pow(a,o),u=r.pow(2,i),d=u*2,p=a-1,h;function f(v,S,T){var _=[];S=S==!0?{entropy:!0}:S||{};var O=y(A(S.entropy?[v,b(s)]:v??x(),3),_),P=new m(_),D=function(){for(var F=P.g(o),C=c,M=0;F<u;)F=(F+M)*a,C*=a,M=P.g(1);for(;F>=d;)F/=2,C/=2,M>>>=1;return(F+M)/C};return D.int32=function(){return P.g(4)|0},D.quick=function(){return P.g(4)/4294967296},D.double=D,y(b(P.S),s),(S.pass||T||function(F,C,M,U){return U&&(U.S&&g(U,P),F.state=function(){return g(P,{})}),M?(r[l]=F,C):F})(D,O,"global"in S?S.global:this==r,S.state)}function m(v){var S,T=v.length,_=this,O=0,P=_.i=_.j=0,D=_.S=[];for(T||(v=[T++]);O<a;)D[O]=O++;for(O=0;O<a;O++)D[O]=D[P=p&P+v[O%T]+(S=D[O])],D[P]=S;(_.g=function(F){for(var C,M=0,U=_.i,j=_.j,q=_.S;F--;)C=q[U=p&U+1],M=M*a+q[p&(q[U]=q[j=p&j+C])+(q[j]=C)];return _.i=U,_.j=j,M})(a)}function g(v,S){return S.i=v.i,S.j=v.j,S.S=v.S.slice(),S}function A(v,S){var T=[],_=typeof v,O;if(S&&_=="object")for(O in v)try{T.push(A(v[O],S-1))}catch{}return T.length?T:_=="string"?v:v+"\0"}function y(v,S){for(var T=v+"",_,O=0;O<T.length;)S[p&O]=p&(_^=S[p&O]*19)+T.charCodeAt(O++);return b(S)}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{var S=n.navigator,T=S&&S.plugins;return[+new Date,n,T,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=z5()}catch{}}else typeof define=="function"&&define.amd?define(function(){return f}):r["seed"+l]=f})(typeof self!="undefined"?self:e,[],Math)}}),B5=St({"node_modules/.pnpm/seedrandom@3.0.5/node_modules/seedrandom/index.js"(e,t){var n=dT(),s=pT(),r=hT(),a=fT(),o=mT(),i=gT(),l=AT();l.alea=n,l.xor128=s,l.xorwow=r,l.xorshift7=a,l.xor4096=o,l.tychei=i,t.exports=l}}),W5=St({"(disabled):node_modules/.pnpm/string_decoder@1.1.1/node_modules/string_decoder/lib/string_decoder.js"(){}}),pc=St({"(disabled):path"(){}}),yT=St({"(disabled):worker_threads"(){}}),xT=St({"(disabled):perf_hooks"(){}}),bT=St({"node_modules/.pnpm/@tensorflow+tfjs-backend-wasm@3.10.0_@tensorflow+tfjs-core@3.10.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 re.buffer!=kt&&hn(re.buffer),Rt}function o(){return re.buffer!=kt&&hn(re.buffer),Wn}function i(){return re.buffer!=kt&&hn(re.buffer),Sn}function l(){return re.buffer!=kt&&hn(re.buffer),Qn}function c(){return re.buffer!=kt&&hn(re.buffer),As}var u=typeof r!="undefined"?r:{},d,p;u.ready=new Promise(function(I,E){d=I,p=E});var h={},f;for(f in u)u.hasOwnProperty(f)&&(h[f]=u[f]);var m=[],g="./this.program",A=function(I,E){throw E},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 S=u.ENVIRONMENT_IS_PTHREAD||!1;S&&(kt=u.buffer);var T="";function _(I){return u.locateFile?u.locateFile(I,T):T+I}var O,P,D,F,C,M;if(b){x?T=pc().dirname(T)+"/":T=__dirname+"/",O=function(E,z){return C||(C=Gi("fs")),M||(M=pc()),E=M.normalize(E),C.readFileSync(E,z?null:"utf8")},D=function(E){var z=O(E,!0);return z.buffer||(z=new Uint8Array(z)),Ce(z.buffer),z},process.argv.length>1&&(g=process.argv[1].replace(/\\/g,"/")),m=process.argv.slice(2),process.on("uncaughtException",function(I){if(!(I instanceof ic))throw I}),process.on("unhandledRejection",Dr),A=function(I){process.exit(I)},u.inspect=function(){return"[Emscripten Module object]"};var U;try{U=yT()}catch(I){throw console.error('The "worker_threads" module is not supported in this node.js build - perhaps a newer version is needed?'),I}global.Worker=U.Worker}else v?(typeof read!="undefined"&&(O=function(E){return read(E)}),D=function(E){var z;return typeof readbuffer=="function"?new Uint8Array(readbuffer(E)):(z=read(E,"binary"),Ce(typeof z=="object"),z)},typeof scriptArgs!="undefined"?m=scriptArgs:typeof arguments!="undefined"&&(m=arguments),typeof quit=="function"&&(A=function(I){quit(I)}),typeof print!="undefined"&&(typeof console=="undefined"&&(console={}),console.log=print,console.warn=console.error=typeof printErr!="undefined"?printErr:print)):(y||x)&&(x?T=self.location.href:typeof document!="undefined"&&document.currentScript&&(T=document.currentScript.src),typeof s!="undefined"&&s&&(T=s),T.indexOf("blob:")!==0?T=T.substr(0,T.lastIndexOf("/")+1):T="",b?(O=function(E,z){return C||(C=Gi("fs")),M||(M=pc()),E=M.normalize(E),C.readFileSync(E,z?null:"utf8")},D=function(E){var z=O(E,!0);return z.buffer||(z=new Uint8Array(z)),Ce(z.buffer),z}):(O=function(I){var E=new XMLHttpRequest;return E.open("GET",I,!1),E.send(null),E.responseText},x&&(D=function(I){var E=new XMLHttpRequest;return E.open("GET",I,!1),E.responseType="arraybuffer",E.send(null),new Uint8Array(E.response)}),P=function(I,E,z){var K=new XMLHttpRequest;K.open("GET",I,!0),K.responseType="arraybuffer",K.onload=function(){if(K.status==200||K.status==0&&K.response){E(K.response);return}z()},K.onerror=z,K.send(null)}),F=function(I){document.title=I});b&&typeof performance=="undefined"&&(global.performance=xT().performance);var j=u.print||console.log.bind(console),q=u.printErr||console.warn.bind(console);for(f in h)h.hasOwnProperty(f)&&(u[f]=h[f]);h=null,u.arguments&&(m=u.arguments),u.thisProgram&&(g=u.thisProgram),u.quit&&(A=u.quit);function X(I){X.shown||(X.shown={}),X.shown[I]||(X.shown[I]=1,q(I))}var te=Atomics.load,ne=Atomics.store,se=Atomics.compareExchange,oe;u.wasmBinary&&(oe=u.wasmBinary);var ae=u.noExitRuntime||!0;typeof WebAssembly!="object"&&Dr("no native wasm support detected");var re,ce,ge=!1,ve;function Ce(I,E){I||Dr("Assertion failed: "+E)}function Re(I){var E=u["_"+I];return Ce(E,"Cannot call unknown function "+I+", make sure it is exported"),E}function Pe(I,E,z,K,ye){var me={string:function(Cn){var Ui=0;if(Cn!=null&&Cn!==0){var O5=(Cn.length<<2)+1;Ui=Bi(O5),at(Cn,Ui,O5)}return Ui},array:function(Cn){var Ui=Bi(Cn.length);return pt(Cn,Ui),Ui}};function Ae(Cn){return E==="string"?et(Cn):E==="boolean"?Boolean(Cn):Cn}var Te=Re(I),lt=[],nn=0;if(K)for(var Kt=0;Kt<K.length;Kt++){var sa=me[z[Kt]];sa?(nn===0&&(nn=oc()),lt[Kt]=sa(K[Kt])):lt[Kt]=K[Kt]}var Vi=Te.apply(null,lt);return Vi=Ae(Vi),nn!==0&&Li(nn),Vi}function Be(I,E,z,K){z=z||[];var ye=z.every(function(Ae){return Ae==="number"}),me=E!=="string";return me&&ye&&!K?Re(I):function(){return Pe(I,E,z,arguments,K)}}function Ue(I,E,z){for(var K=E+z,ye="";!(E>=K);){var me=I[E++];if(!me)return ye;if(!(me&128)){ye+=String.fromCharCode(me);continue}var Ae=I[E++]&63;if((me&224)==192){ye+=String.fromCharCode((me&31)<<6|Ae);continue}var Te=I[E++]&63;if((me&240)==224?me=(me&15)<<12|Ae<<6|Te:me=(me&7)<<18|Ae<<12|Te<<6|I[E++]&63,me<65536)ye+=String.fromCharCode(me);else{var lt=me-65536;ye+=String.fromCharCode(55296|lt>>10,56320|lt&1023)}}return ye}function et(I,E){return I?Ue(o(),I,E):""}function ut(I,E,z,K){if(!(K>0))return 0;for(var ye=z,me=z+K-1,Ae=0;Ae<I.length;++Ae){var Te=I.charCodeAt(Ae);if(Te>=55296&&Te<=57343){var lt=I.charCodeAt(++Ae);Te=65536+((Te&1023)<<10)|lt&1023}if(Te<=127){if(z>=me)break;E[z++]=Te}else if(Te<=2047){if(z+1>=me)break;E[z++]=192|Te>>6,E[z++]=128|Te&63}else if(Te<=65535){if(z+2>=me)break;E[z++]=224|Te>>12,E[z++]=128|Te>>6&63,E[z++]=128|Te&63}else{if(z+3>=me)break;E[z++]=240|Te>>18,E[z++]=128|Te>>12&63,E[z++]=128|Te>>6&63,E[z++]=128|Te&63}}return E[z]=0,z-ye}function at(I,E,z){return ut(I,o(),E,z)}function ot(I){for(var E=0,z=0;z<I.length;++z){var K=I.charCodeAt(z);K>=55296&&K<=57343&&(K=65536+((K&1023)<<10)|I.charCodeAt(++z)&1023),K<=127?++E:K<=2047?E+=2:K<=65535?E+=3:E+=4}return E}function pt(I,E){a().set(I,E)}function ft(I,E){return I%E>0&&(I+=E-I%E),I}var kt,Rt,Wn,pn,Gs,Sn,Qn,Rs,As;function hn(I){kt=I,u.HEAP8=Rt=new Int8Array(I),u.HEAP16=pn=new Int16Array(I),u.HEAP32=Sn=new Int32Array(I),u.HEAPU8=Wn=new Uint8Array(I),u.HEAPU16=Gs=new Uint16Array(I),u.HEAPU32=Qn=new Uint32Array(I),u.HEAPF32=Rs=new Float32Array(I),u.HEAPF64=As=new Float64Array(I)}var ur=u.INITIAL_MEMORY||16777216;if(S)re=u.wasmMemory,kt=u.buffer;else if(u.wasmMemory)re=u.wasmMemory;else if(re=new WebAssembly.Memory({initial:ur/65536,maximum:2147483648/65536,shared:!0}),!(re.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");re&&(kt=re.buffer),ur=kt.byteLength,hn(kt);var vn,cr=[],dr=[],Yr=[],Zu=[],Hs=[],ip=!1,rm=!1;S||dr.push({func:function(){Sp()}});function lp(){if(!S){if(u.preRun)for(typeof u.preRun=="function"&&(u.preRun=[u.preRun]);u.preRun.length;)am(u.preRun.shift());Pi(cr)}}function up(){ip=!0,!S&&Pi(dr)}function cp(){S||Pi(Yr)}function Vn(){S||(rm=!0)}function dp(){if(!S){if(u.postRun)for(typeof u.postRun=="function"&&(u.postRun=[u.postRun]);u.postRun.length;)om(u.postRun.shift());Pi(Hs)}}function am(I){cr.unshift(I)}function om(I){Hs.unshift(I)}var Ds=0,Yu=null,Va=null;function im(I){Ce(!S,"addRunDependency cannot be used in a pthread worker"),Ds++,u.monitorRunDependencies&&u.monitorRunDependencies(Ds)}function lm(I){if(Ds--,u.monitorRunDependencies&&u.monitorRunDependencies(Ds),Ds==0&&(Yu!==null&&(clearInterval(Yu),Yu=null),Va)){var E=Va;Va=null,E()}}u.preloadedImages={},u.preloadedAudios={};function Dr(I){u.onAbort&&u.onAbort(I),S&&console.error("Pthread aborting at "+new Error().stack),I+="",q(I),ge=!0,ve=1,I="abort("+I+"). Build with -s ASSERTIONS=1 for more info.";var E=new WebAssembly.RuntimeError(I);throw p(E),E}function Ua(I,E){return String.prototype.startsWith?I.startsWith(E):I.indexOf(E)===0}var um="data:application/octet-stream;base64,";function pp(I){return Ua(I,um)}var cm="file://";function hp(I){return Ua(I,cm)}var Un="tfjs-backend-wasm-threaded-simd.wasm";pp(Un)||(Un=_(Un));function fp(I){try{if(I==Un&&oe)return new Uint8Array(oe);if(D)return D(I);throw"both async and sync fetching of the wasm failed"}catch(E){Dr(E)}}function dm(){if(!oe&&(y||x)){if(typeof fetch=="function"&&!hp(Un))return fetch(Un,{credentials:"same-origin"}).then(function(I){if(!I.ok)throw"failed to load wasm binary file at '"+Un+"'";return I.arrayBuffer()}).catch(function(){return fp(Un)});if(P)return new Promise(function(I,E){P(Un,function(z){I(new Uint8Array(z))},E)})}return Promise.resolve().then(function(){return fp(Un)})}function pm(){var I={a:rg};function E(Ae,Te){var lt=Ae.exports;if(u.asm=lt,vn=u.asm.I,ce=Te,!S){var nn=De.unusedWorkers.length;De.unusedWorkers.forEach(function(Kt){De.loadWasmModuleToWorker(Kt,function(){--nn||lm("wasm-instantiate")})})}}S||im("wasm-instantiate");function z(Ae){E(Ae.instance,Ae.module)}function K(Ae){return dm().then(function(Te){return WebAssembly.instantiate(Te,I)}).then(Ae,function(Te){q("failed to asynchronously prepare wasm: "+Te),Dr(Te)})}function ye(){return!oe&&typeof WebAssembly.instantiateStreaming=="function"&&!pp(Un)&&!hp(Un)&&typeof fetch=="function"?fetch(Un,{credentials:"same-origin"}).then(function(Ae){var Te=WebAssembly.instantiateStreaming(Ae,I);return Te.then(z,function(lt){return q("wasm streaming compile failed: "+lt),q("falling back to ArrayBuffer instantiation"),K(z)})}):K(z)}if(u.instantiateWasm)try{var me=u.instantiateWasm(I,E);return me}catch(Ae){return q("Module.instantiateWasm callback failed with error: "+Ae),!1}return ye().catch(p),{}}var hm={10520:function(){throw"Canceled!"},10538:function(I,E){setTimeout(function(){E5(I,E)},0)}};function mp(){De.initRuntime()}function Pi(I){for(;I.length>0;){var E=I.shift();if(typeof E=="function"){E(u);continue}var z=E.func;typeof z=="number"?E.arg===void 0?vn.get(z)():vn.get(z)(E.arg):z(E.arg===void 0?null:E.arg)}}var Jr={EPERM:63,ENOENT:44,ESRCH:71,EINTR:27,EIO:29,ENXIO:60,E2BIG:1,ENOEXEC:45,EBADF:8,ECHILD:12,EAGAIN:6,EWOULDBLOCK:6,ENOMEM:48,EACCES:2,EFAULT:21,ENOTBLK:105,EBUSY:10,EEXIST:20,EXDEV:75,ENODEV:43,ENOTDIR:54,EISDIR:31,EINVAL:28,ENFILE:41,EMFILE:33,ENOTTY:59,ETXTBSY:74,EFBIG:22,ENOSPC:51,ESPIPE:70,EROFS:69,EMLINK:34,EPIPE:64,EDOM:18,ERANGE:68,ENOMSG:49,EIDRM:24,ECHRNG:106,EL2NSYNC:156,EL3HLT:107,EL3RST:108,ELNRNG:109,EUNATCH:110,ENOCSI:111,EL2HLT:112,EDEADLK:16,ENOLCK:46,EBADE:113,EBADR:114,EXFULL:115,ENOANO:104,EBADRQC:103,EBADSLT:102,EDEADLOCK:16,EBFONT:101,ENOSTR:100,ENODATA:116,ETIME:117,ENOSR:118,ENONET:119,ENOPKG:120,EREMOTE:121,ENOLINK:47,EADV:122,ESRMNT:123,ECOMM:124,EPROTO:65,EMULTIHOP:36,EDOTDOT:125,EBADMSG:9,ENOTUNIQ:126,EBADFD:127,EREMCHG:128,ELIBACC:129,ELIBBAD:130,ELIBSCN:131,ELIBMAX:132,ELIBEXEC:133,ENOSYS:52,ENOTEMPTY:55,ENAMETOOLONG:37,ELOOP:32,EOPNOTSUPP:138,EPFNOSUPPORT:139,ECONNRESET:15,ENOBUFS:42,EAFNOSUPPORT:5,EPROTOTYPE:67,ENOTSOCK:57,ENOPROTOOPT:50,ESHUTDOWN:140,ECONNREFUSED:14,EADDRINUSE:3,ECONNABORTED:13,ENETUNREACH:40,ENETDOWN:38,ETIMEDOUT:73,EHOSTDOWN:142,EHOSTUNREACH:23,EINPROGRESS:26,EALREADY:7,EDESTADDRREQ:17,EMSGSIZE:35,EPROTONOSUPPORT:66,ESOCKTNOSUPPORT:137,EADDRNOTAVAIL:4,ENETRESET:39,EISCONN:30,ENOTCONN:53,ETOOMANYREFS:141,EUSERS:136,EDQUOT:19,ESTALE:72,ENOTSUP:138,ENOMEDIUM:148,EILSEQ:25,EOVERFLOW:61,ECANCELED:11,ENOTRECOVERABLE:56,EOWNERDEAD:62,ESTRPIPE:135};function Ju(I,E){if(I<=0||I>a().length||I&!0||E<0)return-28;if(E==0)return 0;E>=2147483647&&(E=1/0);var z=Atomics.load(i(),Wi>>2),K=0;if(z==I){var ye=Atomics.compareExchange(i(),Wi>>2,z,0);if(ye==z&&(--E,K=1,E<=0))return 1}var me=Atomics.notify(i(),I>>2,E);if(me>=0)return me+K;throw"Atomics.notify returned an unexpected value "+me}u._emscripten_futex_wake=Ju;function fm(I){if(S)throw"Internal Error! killThread() can only ever be called from main application thread!";if(!I)throw"Internal Error! Null pthread_ptr in killThread!";i()[I+12>>2]=0;var E=De.pthreads[I];E.worker.terminate(),De.freeThreadData(E),De.runningWorkers.splice(De.runningWorkers.indexOf(E.worker),1),E.worker.pthread=void 0}function mm(I){if(S)throw"Internal Error! cancelThread() can only ever be called from main application thread!";if(!I)throw"Internal Error! Null pthread_ptr in cancelThread!";var E=De.pthreads[I];E.worker.postMessage({cmd:"cancel"})}function gp(I){if(S)throw"Internal Error! cleanupThread() can only ever be called from main application thread!";if(!I)throw"Internal Error! Null pthread_ptr in cleanupThread!";var E=De.pthreads[I];if(E){i()[I+12>>2]=0;var z=E.worker;De.returnWorkerToPool(z)}}var De={unusedWorkers:[],runningWorkers:[],initMainThreadBlock:function(){for(var I=8,E=0;E<I;++E)De.allocateUnusedWorker()},initRuntime:function(){for(var I=Ha(228),E=0;E<228/4;++E)l()[I/4+E]=0;i()[I+12>>2]=I;var z=I+152;i()[z>>2]=z;for(var K=Ha(512),E=0;E<128;++E)l()[K/4+E]=0;Atomics.store(l(),I+100>>2,K),Atomics.store(l(),I+40>>2,I),Tg(I,!x,1),T5(I)},initWorker:function(){},pthreads:{},threadExitHandlers:[],setThreadStatus:function(){},runExitHandlers:function(){for(;De.threadExitHandlers.length>0;)De.threadExitHandlers.pop()();S&&na()&&C5()},runExitHandlersAndDeinitThread:function(I,E){Atomics.store(l(),I+56>>2,1),Atomics.store(l(),I+60>>2,0),De.runExitHandlers(),Atomics.store(l(),I+4>>2,E),Atomics.store(l(),I+0>>2,1),Ju(I+0,2147483647),Tg(0,0,0)},threadExit:function(I){var E=na();E&&(De.runExitHandlersAndDeinitThread(E,I),S&&postMessage({cmd:"exit"}))},threadCancel:function(){De.runExitHandlersAndDeinitThread(na(),-1),postMessage({cmd:"cancelDone"})},terminateAllThreads:function(){for(var I in De.pthreads){var E=De.pthreads[I];E&&E.worker&&De.returnWorkerToPool(E.worker)}De.pthreads={};for(var z=0;z<De.unusedWorkers.length;++z){var K=De.unusedWorkers[z];K.terminate()}De.unusedWorkers=[];for(var z=0;z<De.runningWorkers.length;++z){var K=De.runningWorkers[z],E=K.pthread;De.freeThreadData(E),K.terminate()}De.runningWorkers=[]},freeThreadData:function(I){if(!!I){if(I.threadInfoStruct){var E=i()[I.threadInfoStruct+100>>2];i()[I.threadInfoStruct+100>>2]=0,ac(E),ac(I.threadInfoStruct)}I.threadInfoStruct=0,I.allocatedOwnStack&&I.stackBase&&ac(I.stackBase),I.stackBase=0,I.worker&&(I.worker.pthread=null)}},returnWorkerToPool:function(I){De.runWithoutMainThreadQueuedCalls(function(){delete De.pthreads[I.pthread.threadInfoStruct],De.unusedWorkers.push(I),De.runningWorkers.splice(De.runningWorkers.indexOf(I),1),De.freeThreadData(I.pthread),I.pthread=void 0})},runWithoutMainThreadQueuedCalls:function(I){i()[$5>>2]=0;try{I()}finally{i()[$5>>2]=1}},receiveObjectTransfer:function(I){},loadWasmModuleToWorker:function(I,E){I.onmessage=function(z){var K=z.data,ye=K.cmd;if(I.pthread&&(De.currentProxiedOperationCallerThread=I.pthread.threadInfoStruct),K.targetThread&&K.targetThread!=na()){var me=De.pthreads[K.targetThread];me?me.worker.postMessage(z.data,K.transferList):console.error('Internal error! Worker sent a message "'+ye+'" to target pthread '+K.targetThread+", but that thread no longer exists!"),De.currentProxiedOperationCallerThread=void 0;return}if(ye==="processQueuedMainThreadWork")Dp();else if(ye==="spawnThread")kp(z.data);else if(ye==="cleanupThread")gp(K.thread);else if(ye==="killThread")fm(K.thread);else if(ye==="cancelThread")mm(K.thread);else if(ye==="loaded")I.loaded=!0,E&&E(I),I.runPthread&&(I.runPthread(),delete I.runPthread);else if(ye==="print")j("Thread "+K.threadId+": "+K.text);else if(ye==="printErr")q("Thread "+K.threadId+": "+K.text);else if(ye==="alert")alert("Thread "+K.threadId+": "+K.text);else if(ye==="exit"){var Ae=I.pthread&&Atomics.load(l(),I.pthread.threadInfoStruct+64>>2);Ae&&De.returnWorkerToPool(I)}else if(ye==="exitProcess")try{qC(K.returnCode)}catch(Te){if(Te instanceof ic)return;throw Te}else ye==="cancelDone"?De.returnWorkerToPool(I):ye==="objectTransfer"?De.receiveObjectTransfer(z.data):z.data.target==="setimmediate"?I.postMessage(z.data):q("worker sent an unknown command "+ye);De.currentProxiedOperationCallerThread=void 0},I.onerror=function(z){q("pthread sent an error! "+z.filename+":"+z.lineno+": "+z.message)},b&&(I.on("message",function(z){I.onmessage({data:z})}),I.on("error",function(z){I.onerror(z)}),I.on("exit",function(z){})),I.postMessage({cmd:"load",urlOrBlob:u.mainScriptUrlOrBlob||s,wasmMemory:re,wasmModule:ce})},allocateUnusedWorker:function(){var I=_("tfjs-backend-wasm-threaded-simd.worker.js");De.unusedWorkers.push(new Worker(I))},getNewWorker:function(){return De.unusedWorkers.length==0&&(De.allocateUnusedWorker(),De.loadWasmModuleToWorker(De.unusedWorkers[0])),De.unusedWorkers.length>0?De.unusedWorkers.pop():null},busySpinWait:function(I){for(var E=performance.now()+I;performance.now()<E;);}};function gm(I,E){_5(I,E),Li(I)}u.establishStackSpace=gm;function Am(){return ae}u.getNoExitRuntime=Am;function ym(I,E){return vn.get(I)(E)}u.invokeEntryPoint=ym;function xm(I,E,z,K){Dr("Assertion failed: "+et(I)+", at: "+[E?et(E):"unknown filename",z,K?et(K):"unknown function"])}function bm(I,E){var z=_main(I,E)}var Ga;b?Ga=function(){var I=process.hrtime();return I[0]*1e3+I[1]/1e6}:S?Ga=function(){return performance.now()-u.__performance_now_clock_drift}:typeof dateNow!="undefined"?Ga=dateNow:Ga=function(){return performance.now()};function vm(I){return i()[I5()>>2]=I,I}function wm(I,E){if(S)return Qr(1,1,I,E)}function km(I,E){if(I==E)postMessage({cmd:"processQueuedMainThreadWork"});else if(S)postMessage({targetThread:I,cmd:"processThreadQueue"});else{var z=De.pthreads[I],K=z&&z.worker;if(!K)return;K.postMessage({cmd:"processThreadQueue"})}return 1}function Im(){Dr()}function Sm(I,E,z){var K=Em(E,z);return hm[I].apply(null,K)}function Cm(I,E){}function Ap(I,E,z){if(I<=0||I>a().length||I&!0)return-28;if(y){if(Atomics.load(i(),I>>2)!=E)return-6;for(var ye=performance.now(),me=ye+z,Ae=Atomics.exchange(i(),Wi>>2,I);;){if(ye=performance.now(),ye>me)return Ae=Atomics.exchange(i(),Wi>>2,0),-73;if(Ae=Atomics.exchange(i(),Wi>>2,0),Ae==0)break;if(Dp(),Atomics.load(i(),I>>2)!=E)return-6;Ae=Atomics.exchange(i(),Wi>>2,I)}return 0}else{var K=Atomics.wait(i(),I>>2,E,z);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 Tm(I,E,z){o().copyWithin(I,E,E+z)}function Nm(){return b?Gi("os").cpus().length:navigator.hardwareConcurrency}function Qr(I,E){for(var z=arguments.length-2,K=oc(),ye=z,me=Bi(ye*8),Ae=me>>3,Te=0;Te<z;Te++){var lt=arguments[2+Te];c()[Ae+Te]=lt}var nn=D5(I,ye,me,E);return Li(K),nn}var Qu=[],ec=[];function Em(I,E){ec.length=0;var z;for(E>>=2;z=o()[I++];){var K=z<105;K&&E&1&&E++,ec.push(K?c()[E++>>1]:i()[E]),++E}return ec}function Rm(I,E,z){Qu.length=E;for(var K=z>>3,ye=0;ye<E;ye++)Qu[ye]=c()[K+ye];var me=I<0,Ae=me?hm[-I-1]:sg[I];return Ae.apply(null,Qu)}function Dm(){return o().length}function _m(I){try{return re.grow(I-kt.byteLength+65535>>>16),hn(re.buffer),1}catch{}}function Fm(I){var E=Dm();if(I<=E)return!1;var z=2147483648;if(I>z)return!1;for(var K=1;K<=4;K*=2){var ye=E*(1+.2/K);ye=Math.min(ye,I+100663296);var me=Math.min(z,ft(Math.max(I,ye),65536)),Ae=_m(me);if(Ae)return!0}return!1}var We={inEventHandler:0,removeAllEventListeners:function(){for(var I=We.eventHandlers.length-1;I>=0;--I)We._removeHandler(I);We.eventHandlers=[],We.deferredCalls=[]},registerRemoveEventListeners:function(){We.removeEventListenersRegistered||(Zu.push(We.removeAllEventListeners),We.removeEventListenersRegistered=!0)},deferredCalls:[],deferCall:function(I,E,z){function K(Ae,Te){if(Ae.length!=Te.length)return!1;for(var lt in Ae)if(Ae[lt]!=Te[lt])return!1;return!0}for(var ye in We.deferredCalls){var me=We.deferredCalls[ye];if(me.targetFunction==I&&K(me.argsList,z))return}We.deferredCalls.push({targetFunction:I,precedence:E,argsList:z}),We.deferredCalls.sort(function(Ae,Te){return Ae.precedence<Te.precedence})},removeDeferredCalls:function(I){for(var E=0;E<We.deferredCalls.length;++E)We.deferredCalls[E].targetFunction==I&&(We.deferredCalls.splice(E,1),--E)},canPerformEventHandlerRequests:function(){return We.inEventHandler&&We.currentEventHandler.allowsDeferredCalls},runDeferredCalls:function(){if(!!We.canPerformEventHandlerRequests())for(var I=0;I<We.deferredCalls.length;++I){var E=We.deferredCalls[I];We.deferredCalls.splice(I,1),--I,E.targetFunction.apply(null,E.argsList)}},eventHandlers:[],removeAllHandlersOnTarget:function(I,E){for(var z=0;z<We.eventHandlers.length;++z)We.eventHandlers[z].target==I&&(!E||E==We.eventHandlers[z].eventTypeString)&&We._removeHandler(z--)},_removeHandler:function(I){var E=We.eventHandlers[I];E.target.removeEventListener(E.eventTypeString,E.eventListenerFunc,E.useCapture),We.eventHandlers.splice(I,1)},registerOrRemoveHandler:function(I){var E=function(ye){++We.inEventHandler,We.currentEventHandler=I,We.runDeferredCalls(),I.handlerFunc(ye),We.runDeferredCalls(),--We.inEventHandler};if(I.callbackfunc)I.eventListenerFunc=E,I.target.addEventListener(I.eventTypeString,E,I.useCapture),We.eventHandlers.push(I),We.registerRemoveEventListeners();else for(var z=0;z<We.eventHandlers.length;++z)We.eventHandlers[z].target==I.target&&We.eventHandlers[z].eventTypeString==I.eventTypeString&&We._removeHandler(z--)},queueEventHandlerOnThread_iiii:function(I,E,z,K,ye){var me=oc(),Ae=Bi(12);i()[Ae>>2]=z,i()[Ae+4>>2]=K,i()[Ae+8>>2]=ye,Cg(0,I,637534208,E,K,Ae),Li(me)},getTargetThreadForEventCallback:function(I){switch(I){case 1:return 0;case 2:return De.currentProxiedOperationCallerThread;default:return I}},getNodeNameForTarget:function(I){return I?I==window?"#window":I==screen?"#screen":I&&I.nodeName?I.nodeName:"":""},fullscreenEnabled:function(){return document.fullscreenEnabled||document.webkitFullscreenEnabled}};function $m(I){var E=ot(I)+1,z=Ha(E);return at(I,z,E),z}function Om(I,E,z,K){var ye=oc(),me=Bi(12),Ae=0;E&&(Ae=$m(E)),i()[me>>2]=Ae,i()[me+4>>2]=z,i()[me+8>>2]=K,Cg(0,I,657457152,0,Ae,me),Li(ye)}function Pm(I,E,z,K){E=E?et(E):"",Om(I,E,z,K)}function Mm(I){return I>2?et(I):I}var zm=[0,typeof document!="undefined"?document:0,typeof window!="undefined"?window:0];function Lm(I){I=Mm(I);var E=zm[I]||(typeof document!="undefined"?document.querySelector(I):void 0);return E}function tc(I){return Lm(I)}function yp(I,E,z){var K=tc(I);if(!K)return-4;if(K.canvasSharedPtr&&(i()[K.canvasSharedPtr>>2]=E,i()[K.canvasSharedPtr+4>>2]=z),K.offscreenCanvas||!K.controlTransferredOffscreen){K.offscreenCanvas&&(K=K.offscreenCanvas);var ye=!1;if(K.GLctxObject&&K.GLctxObject.GLctx){var me=K.GLctxObject.GLctx.getParameter(2978);ye=me[0]===0&&me[1]===0&&me[2]===K.width&&me[3]===K.height}K.width=E,K.height=z,ye&&K.GLctxObject.GLctx.viewport(0,0,E,z)}else if(K.canvasSharedPtr){var Ae=i()[K.canvasSharedPtr+8>>2];return Pm(Ae,I,E,z),1}else return-4;return 0}function xp(I,E,z){return S?Qr(2,1,I,E,z):yp(I,E,z)}function Bm(I,E,z){var K=tc(I);return K?yp(I,E,z):xp(I,E,z)}function Wm(I){}function Vm(I,E){}function Um(I){var E=I.getExtension("ANGLE_instanced_arrays");if(E)return I.vertexAttribDivisor=function(z,K){E.vertexAttribDivisorANGLE(z,K)},I.drawArraysInstanced=function(z,K,ye,me){E.drawArraysInstancedANGLE(z,K,ye,me)},I.drawElementsInstanced=function(z,K,ye,me,Ae){E.drawElementsInstancedANGLE(z,K,ye,me,Ae)},1}function Gm(I){var E=I.getExtension("OES_vertex_array_object");if(E)return I.createVertexArray=function(){return E.createVertexArrayOES()},I.deleteVertexArray=function(z){E.deleteVertexArrayOES(z)},I.bindVertexArray=function(z){E.bindVertexArrayOES(z)},I.isVertexArray=function(z){return E.isVertexArrayOES(z)},1}function Hm(I){var E=I.getExtension("WEBGL_draw_buffers");if(E)return I.drawBuffers=function(z,K){E.drawBuffersWEBGL(z,K)},1}function jm(I){return!!(I.multiDrawWebgl=I.getExtension("WEBGL_multi_draw"))}var it={counter:1,buffers:[],programs:[],framebuffers:[],renderbuffers:[],textures:[],uniforms:[],shaders:[],vaos:[],contexts:{},offscreenCanvases:{},timerQueriesEXT:[],programInfos:{},stringCache:{},unpackAlignment:4,recordError:function(E){it.lastError||(it.lastError=E)},getNewId:function(I){for(var E=it.counter++,z=I.length;z<E;z++)I[z]=null;return E},getSource:function(I,E,z,K){for(var ye="",me=0;me<E;++me){var Ae=K?i()[K+me*4>>2]:-1;ye+=et(i()[z+me*4>>2],Ae<0?void 0:Ae)}return ye},createContext:function(I,E){var z=I.getContext("webgl",E);if(!z)return 0;var K=it.registerContext(z,E);return K},registerContext:function(I,E){var z=Ha(8);i()[z+4>>2]=na();var K={handle:z,attributes:E,version:E.majorVersion,GLctx:I};return I.canvas&&(I.canvas.GLctxObject=K),it.contexts[z]=K,(typeof E.enableExtensionsByDefault=="undefined"||E.enableExtensionsByDefault)&&it.initExtensions(K),z},makeContextCurrent:function(I){return it.currentContext=it.contexts[I],u.ctx=ea=it.currentContext&&it.currentContext.GLctx,!(I&&!ea)},getContext:function(I){return it.contexts[I]},deleteContext:function(I){it.currentContext===it.contexts[I]&&(it.currentContext=null),typeof We=="object"&&We.removeAllHandlersOnTarget(it.contexts[I].GLctx.canvas),it.contexts[I]&&it.contexts[I].GLctx.canvas&&(it.contexts[I].GLctx.canvas.GLctxObject=void 0),ac(it.contexts[I].handle),it.contexts[I]=null},initExtensions:function(I){if(I||(I=it.currentContext),!I.initExtensionsDone){I.initExtensionsDone=!0;var E=I.GLctx;Um(E),Gm(E),Hm(E),E.disjointTimerQueryExt=E.getExtension("EXT_disjoint_timer_query"),jm(E);var z=E.getSupportedExtensions()||[];z.forEach(function(K){K.indexOf("lose_context")<0&&K.indexOf("debug")<0&&E.getExtension(K)})}},populateUniformTable:function(I){for(var E=it.programs[I],z=it.programInfos[I]={uniforms:{},maxUniformLength:0,maxAttributeLength:-1,maxUniformBlockNameLength:-1},K=z.uniforms,ye=ea.getProgramParameter(E,35718),me=0;me<ye;++me){var Ae=ea.getActiveUniform(E,me),Te=Ae.name;z.maxUniformLength=Math.max(z.maxUniformLength,Te.length+1),Te.slice(-1)=="]"&&(Te=Te.slice(0,Te.lastIndexOf("[")));var lt=ea.getUniformLocation(E,Te);if(lt){var nn=it.getNewId(it.uniforms);K[Te]=[Ae.size,nn],it.uniforms[nn]=lt;for(var Kt=1;Kt<Ae.size;++Kt){var sa=Te+"["+Kt+"]";lt=ea.getUniformLocation(E,sa),nn=it.getNewId(it.uniforms),it.uniforms[nn]=lt}}}}},qm=["default","low-power","high-performance"];function Xm(I,E){var z=E>>2,K=i()[z+(24>>2)],ye={alpha:!!i()[z+(0>>2)],depth:!!i()[z+(4>>2)],stencil:!!i()[z+(8>>2)],antialias:!!i()[z+(12>>2)],premultipliedAlpha:!!i()[z+(16>>2)],preserveDrawingBuffer:!!i()[z+(20>>2)],powerPreference:qm[K],failIfMajorPerformanceCaveat:!!i()[z+(28>>2)],majorVersion:i()[z+(32>>2)],minorVersion:i()[z+(36>>2)],enableExtensionsByDefault:i()[z+(40>>2)],explicitSwapControl:i()[z+(44>>2)],proxyContextToMainThread:i()[z+(48>>2)],renderViaOffscreenBackBuffer:i()[z+(52>>2)]},me=tc(I);if(!me||ye.explicitSwapControl)return 0;var Ae=it.createContext(me,ye);return Ae}function Km(I,E){return Xm(I,E)}var Mi={mappings:{},buffers:[null,[],[]],printChar:function(I,E){var z=Mi.buffers[I];E===0||E===10?((I===1?j:q)(Ue(z,0)),z.length=0):z.push(E)},varargs:void 0,get:function(){Mi.varargs+=4;var I=i()[Mi.varargs-4>>2];return I},getStr:function(I){var E=et(I);return E},get64:function(I,E){return I}};function bp(I){return S?Qr(3,1,I):0}function vp(I,E,z,K,ye){if(S)return Qr(4,1,I,E,z,K,ye)}function wp(I,E,z,K){if(S)return Qr(5,1,I,E,z,K);for(var ye=0,me=0;me<z;me++){for(var Ae=i()[E+me*8>>2],Te=i()[E+(me*8+4)>>2],lt=0;lt<Te;lt++)Mi.printChar(I,o()[Ae+lt]);ye+=Te}return i()[K>>2]=ye,0}function Zm(I){var E=De.threadExitHandlers.pop();I&&E()}function Ym(I,E){De.threadExitHandlers.push(function(){vn.get(I)(E)})}function kp(I){if(S)throw"Internal Error! spawnThread() can only ever be called from main application thread!";var E=De.getNewWorker();if(E.pthread!==void 0)throw"Internal error!";if(!I.pthread_ptr)throw"Internal error, no pthread ptr!";De.runningWorkers.push(E);for(var z=Ha(128*4),K=0;K<128;++K)i()[z+K*4>>2]=0;var ye=I.stackBase+I.stackSize,me=De.pthreads[I.pthread_ptr]={worker:E,stackBase:I.stackBase,stackSize:I.stackSize,allocatedOwnStack:I.allocatedOwnStack,threadInfoStruct:I.pthread_ptr},Ae=me.threadInfoStruct>>2;Atomics.store(l(),Ae+(64>>2),I.detached),Atomics.store(l(),Ae+(100>>2),z),Atomics.store(l(),Ae+(40>>2),me.threadInfoStruct),Atomics.store(l(),Ae+(80>>2),I.stackSize),Atomics.store(l(),Ae+(76>>2),ye),Atomics.store(l(),Ae+(104>>2),I.stackSize),Atomics.store(l(),Ae+(104+8>>2),ye),Atomics.store(l(),Ae+(104+12>>2),I.detached);var Te=S5(),lt=Te+40;Atomics.store(l(),Ae+(172>>2),lt),E.pthread=me;var nn={cmd:"run",start_routine:I.startRoutine,arg:I.arg,threadInfoStruct:I.pthread_ptr,stackBase:I.stackBase,stackSize:I.stackSize};E.runPthread=function(){nn.time=performance.now(),E.postMessage(nn,I.transferList)},E.loaded&&(E.runPthread(),delete E.runPthread)}function Jm(I,E,z,K){if(typeof SharedArrayBuffer=="undefined")return q("Current environment does not support SharedArrayBuffer, pthreads are not available!"),6;if(!I)return q("pthread_create called with a null thread pointer!"),28;var ye=[],me=0;if(S&&(ye.length===0||me))return R5(687865856,I,E,z,K);if(me)return me;var Ae=0,Te=0,lt=0;E&&E!=-1?(Ae=i()[E>>2],Ae+=81920,Te=i()[E+8>>2],lt=i()[E+12>>2]!==0):Ae=2097152;var nn=Te==0;nn?Te=F5(16,Ae):(Te-=Ae,Ce(Te>0));for(var Kt=Ha(228),sa=0;sa<228>>2;++sa)l()[(Kt>>2)+sa]=0;i()[I>>2]=Kt,i()[Kt+12>>2]=Kt;var Vi=Kt+152;i()[Vi>>2]=Vi;var Cn={stackBase:Te,stackSize:Ae,allocatedOwnStack:nn,detached:lt,startRoutine:z,pthread_ptr:Kt,arg:K,transferList:ye};return S?(Cn.cmd="spawnThread",postMessage(Cn,ye)):kp(Cn),0}function Qm(){if(!!S){var I=na();if(!!I){var E=Atomics.load(l(),I+56>>2);if(!E){var z=Atomics.load(l(),I+0>>2);if(z==2)throw"Canceled!"}}}}function eg(){b||x||X("Blocking on the main thread is very dangerous, see https://emscripten.org/docs/porting/pthreads.html#blocking-on-the-main-browser-thread")}function tg(I,E,z){if(!I)return q("pthread_join attempted on a null thread pointer!"),Jr.ESRCH;if(S&&na()==I)return q("PThread "+I+" is attempting to join to itself!"),Jr.EDEADLK;if(!S&&N5()==I)return q("Main thread "+I+" is attempting to join to itself!"),Jr.EDEADLK;var K=i()[I+12>>2];if(K!==I)return q("pthread_join attempted on thread "+I+", which does not point to a valid thread, or does not exist anymore!"),Jr.ESRCH;var ye=Atomics.load(l(),I+64>>2);if(ye)return q("Attempted to join thread "+I+", which was already detached!"),Jr.EINVAL;for(z&&eg();;){var me=Atomics.load(l(),I+0>>2);if(me==1){var Ae=Atomics.load(l(),I+4>>2);return E&&(i()[E>>2]=Ae),Atomics.store(l(),I+64>>2,1),S?postMessage({cmd:"cleanupThread",thread:I}):gp(I),0}if(!z)return Jr.EBUSY;Qm(),S||Dp(),Ap(I+0,me,S?100:1)}}function ng(I,E){return tg(I,E,!0)}function Ip(I){if(S)return Qr(6,1,I);switch(I){case 30:return 16384;case 85:var E=2147483648;return E/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 vm(28),-1}S||De.initMainThreadBlock();var ea,sg=[null,wm,xp,bp,vp,wp,Ip],rg={e:xm,r:bm,x:km,b:Im,y:Sm,j:Cm,d:Ap,c:Ju,f:Ga,p:Tm,A:Nm,u:Rm,q:Fm,v:Bm,i:Wm,s:Vm,w:Km,l:bp,n:vp,g:wp,o:mp,a:re||u.wasmMemory,z:Zm,k:Ym,h:Jm,m:ng,t:Ip},k5=pm(),Sp=u.___wasm_call_ctors=function(){return(Sp=u.___wasm_call_ctors=u.asm.B).apply(null,arguments)},ag=u._init=function(){return(ag=u._init=u.asm.C).apply(null,arguments)},og=u._init_with_threads_count=function(){return(og=u._init_with_threads_count=u.asm.D).apply(null,arguments)},ig=u._get_threads_count=function(){return(ig=u._get_threads_count=u.asm.E).apply(null,arguments)},lg=u._register_tensor=function(){return(lg=u._register_tensor=u.asm.F).apply(null,arguments)},ug=u._dispose_data=function(){return(ug=u._dispose_data=u.asm.G).apply(null,arguments)},cg=u._dispose=function(){return(cg=u._dispose=u.asm.H).apply(null,arguments)},dg=u._Abs=function(){return(dg=u._Abs=u.asm.J).apply(null,arguments)},pg=u._Add=function(){return(pg=u._Add=u.asm.K).apply(null,arguments)},hg=u._AddN=function(){return(hg=u._AddN=u.asm.L).apply(null,arguments)},fg=u._All=function(){return(fg=u._All=u.asm.M).apply(null,arguments)},mg=u._Any=function(){return(mg=u._Any=u.asm.N).apply(null,arguments)},gg=u._ArgMax=function(){return(gg=u._ArgMax=u.asm.O).apply(null,arguments)},Ag=u._AvgPool=function(){return(Ag=u._AvgPool=u.asm.P).apply(null,arguments)},yg=u._BatchMatMul=function(){return(yg=u._BatchMatMul=u.asm.Q).apply(null,arguments)},xg=u._Ceil=function(){return(xg=u._Ceil=u.asm.R).apply(null,arguments)},bg=u._ClipByValue=function(){return(bg=u._ClipByValue=u.asm.S).apply(null,arguments)},vg=u._Conv2D=function(){return(vg=u._Conv2D=u.asm.T).apply(null,arguments)},wg=u._Conv2DBackpropInput=function(){return(wg=u._Conv2DBackpropInput=u.asm.U).apply(null,arguments)},kg=u._Cos=function(){return(kg=u._Cos=u.asm.V).apply(null,arguments)},Ig=u._Cosh=function(){return(Ig=u._Cosh=u.asm.W).apply(null,arguments)},Cp=u._CropAndResize=function(){return(Cp=u._CropAndResize=u.asm.X).apply(null,arguments)},Tp=u._Cumsum=function(){return(Tp=u._Cumsum=u.asm.Y).apply(null,arguments)},Np=u._DepthToSpace=function(){return(Np=u._DepthToSpace=u.asm.Z).apply(null,arguments)},nc=u._DepthwiseConv2dNative=function(){return(nc=u._DepthwiseConv2dNative=u.asm._).apply(null,arguments)},zi=u._Elu=function(){return(zi=u._Elu=u.asm.$).apply(null,arguments)},Sg=u._Equal=function(){return(Sg=u._Equal=u.asm.aa).apply(null,arguments)},sc=u._Exp=function(){return(sc=u._Exp=u.asm.ba).apply(null,arguments)},J=u._FlipLeftRight=function(){return(J=u._FlipLeftRight=u.asm.ca).apply(null,arguments)},ie=u._Floor=function(){return(ie=u._Floor=u.asm.da).apply(null,arguments)},ke=u._FloorDiv=function(){return(ke=u._FloorDiv=u.asm.ea).apply(null,arguments)},st=u._FusedBatchNorm=function(){return(st=u._FusedBatchNorm=u.asm.fa).apply(null,arguments)},Ot=u._FusedConv2D=function(){return(Ot=u._FusedConv2D=u.asm.ga).apply(null,arguments)},It=u._FusedDepthwiseConv2D=function(){return(It=u._FusedDepthwiseConv2D=u.asm.ha).apply(null,arguments)},Xe=u._Gather=function(){return(Xe=u._Gather=u.asm.ia).apply(null,arguments)},Ye=u._GatherNd=function(){return(Ye=u._GatherNd=u.asm.ja).apply(null,arguments)},fn=u._Greater=function(){return(fn=u._Greater=u.asm.ka).apply(null,arguments)},_r=u._GreaterEqual=function(){return(_r=u._GreaterEqual=u.asm.la).apply(null,arguments)},Fr=u._LeakyRelu=function(){return(Fr=u._LeakyRelu=u.asm.ma).apply(null,arguments)},Ep=u._Less=function(){return(Ep=u._Less=u.asm.na).apply(null,arguments)},rc=u._LessEqual=function(){return(rc=u._LessEqual=u.asm.oa).apply(null,arguments)},es=u._Log=function(){return(es=u._Log=u.asm.pa).apply(null,arguments)},ta=u._LogicalAnd=function(){return(ta=u._LogicalAnd=u.asm.qa).apply(null,arguments)},Rp=u._Max=function(){return(Rp=u._Max=u.asm.ra).apply(null,arguments)},tC=u._MaxPool=function(){return(tC=u._MaxPool=u.asm.sa).apply(null,arguments)},nC=u._Maximum=function(){return(nC=u._Maximum=u.asm.ta).apply(null,arguments)},sC=u._Mean=function(){return(sC=u._Mean=u.asm.ua).apply(null,arguments)},rC=u._Min=function(){return(rC=u._Min=u.asm.va).apply(null,arguments)},aC=u._Minimum=function(){return(aC=u._Minimum=u.asm.wa).apply(null,arguments)},oC=u._MirrorPad=function(){return(oC=u._MirrorPad=u.asm.xa).apply(null,arguments)},iC=u._Multiply=function(){return(iC=u._Multiply=u.asm.ya).apply(null,arguments)},lC=u._Neg=function(){return(lC=u._Neg=u.asm.za).apply(null,arguments)},uC=u._NonMaxSuppressionV3=function(){return(uC=u._NonMaxSuppressionV3=u.asm.Aa).apply(null,arguments)},cC=u._NonMaxSuppressionV4=function(){return(cC=u._NonMaxSuppressionV4=u.asm.Ba).apply(null,arguments)},dC=u._NonMaxSuppressionV5=function(){return(dC=u._NonMaxSuppressionV5=u.asm.Ca).apply(null,arguments)},pC=u._NotEqual=function(){return(pC=u._NotEqual=u.asm.Da).apply(null,arguments)},hC=u._OneHot=function(){return(hC=u._OneHot=u.asm.Ea).apply(null,arguments)},fC=u._PadV2=function(){return(fC=u._PadV2=u.asm.Fa).apply(null,arguments)},mC=u._Pow=function(){return(mC=u._Pow=u.asm.Ga).apply(null,arguments)},gC=u._Prelu=function(){return(gC=u._Prelu=u.asm.Ha).apply(null,arguments)},AC=u._Prod=function(){return(AC=u._Prod=u.asm.Ia).apply(null,arguments)},yC=u._RealDiv=function(){return(yC=u._RealDiv=u.asm.Ja).apply(null,arguments)},xC=u._Relu=function(){return(xC=u._Relu=u.asm.Ka).apply(null,arguments)},bC=u._Relu6=function(){return(bC=u._Relu6=u.asm.La).apply(null,arguments)},vC=u._ResizeBilinear=function(){return(vC=u._ResizeBilinear=u.asm.Ma).apply(null,arguments)},wC=u._Reverse=function(){return(wC=u._Reverse=u.asm.Na).apply(null,arguments)},kC=u._RotateWithOffset=function(){return(kC=u._RotateWithOffset=u.asm.Oa).apply(null,arguments)},IC=u._Round=function(){return(IC=u._Round=u.asm.Pa).apply(null,arguments)},SC=u._Rsqrt=function(){return(SC=u._Rsqrt=u.asm.Qa).apply(null,arguments)},CC=u._ScatterNd=function(){return(CC=u._ScatterNd=u.asm.Ra).apply(null,arguments)},TC=u._SelectV2=function(){return(TC=u._SelectV2=u.asm.Sa).apply(null,arguments)},NC=u._Sigmoid=function(){return(NC=u._Sigmoid=u.asm.Ta).apply(null,arguments)},EC=u._Sin=function(){return(EC=u._Sin=u.asm.Ua).apply(null,arguments)},RC=u._Softmax=function(){return(RC=u._Softmax=u.asm.Va).apply(null,arguments)},DC=u._Sqrt=function(){return(DC=u._Sqrt=u.asm.Wa).apply(null,arguments)},_C=u._Square=function(){return(_C=u._Square=u.asm.Xa).apply(null,arguments)},FC=u._SquaredDifference=function(){return(FC=u._SquaredDifference=u.asm.Ya).apply(null,arguments)},$C=u._Step=function(){return($C=u._Step=u.asm.Za).apply(null,arguments)},OC=u._StridedSlice=function(){return(OC=u._StridedSlice=u.asm._a).apply(null,arguments)},PC=u._Sub=function(){return(PC=u._Sub=u.asm.$a).apply(null,arguments)},MC=u._Sum=function(){return(MC=u._Sum=u.asm.ab).apply(null,arguments)},zC=u._Tan=function(){return(zC=u._Tan=u.asm.bb).apply(null,arguments)},LC=u._Tanh=function(){return(LC=u._Tanh=u.asm.cb).apply(null,arguments)},BC=u._Tile=function(){return(BC=u._Tile=u.asm.db).apply(null,arguments)},WC=u._TopK=function(){return(WC=u._TopK=u.asm.eb).apply(null,arguments)},VC=u._Transform=function(){return(VC=u._Transform=u.asm.fb).apply(null,arguments)},UC=u._Transpose=function(){return(UC=u._Transpose=u.asm.gb).apply(null,arguments)},GC=u.__FusedMatMul=function(){return(GC=u.__FusedMatMul=u.asm.hb).apply(null,arguments)},Ha=u._malloc=function(){return(Ha=u._malloc=u.asm.ib).apply(null,arguments)},ac=u._free=function(){return(ac=u._free=u.asm.jb).apply(null,arguments)},I5=u.___errno_location=function(){return(I5=u.___errno_location=u.asm.kb).apply(null,arguments)},S5=u._emscripten_get_global_libc=function(){return(S5=u._emscripten_get_global_libc=u.asm.lb).apply(null,arguments)},na=u._pthread_self=function(){return(na=u._pthread_self=u.asm.mb).apply(null,arguments)},C5=u.___pthread_tsd_run_dtors=function(){return(C5=u.___pthread_tsd_run_dtors=u.asm.nb).apply(null,arguments)},Dp=u._emscripten_main_thread_process_queued_calls=function(){return(Dp=u._emscripten_main_thread_process_queued_calls=u.asm.ob).apply(null,arguments)},HC=u._emscripten_current_thread_process_queued_calls=function(){return(HC=u._emscripten_current_thread_process_queued_calls=u.asm.pb).apply(null,arguments)},T5=u._emscripten_register_main_browser_thread_id=function(){return(T5=u._emscripten_register_main_browser_thread_id=u.asm.qb).apply(null,arguments)},N5=u._emscripten_main_browser_thread_id=function(){return(N5=u._emscripten_main_browser_thread_id=u.asm.rb).apply(null,arguments)},E5=u.__emscripten_do_dispatch_to_thread=function(){return(E5=u.__emscripten_do_dispatch_to_thread=u.asm.sb).apply(null,arguments)},R5=u._emscripten_sync_run_in_main_thread_4=function(){return(R5=u._emscripten_sync_run_in_main_thread_4=u.asm.tb).apply(null,arguments)},D5=u._emscripten_run_in_main_runtime_thread_js=function(){return(D5=u._emscripten_run_in_main_runtime_thread_js=u.asm.ub).apply(null,arguments)},Cg=u.__emscripten_call_on_thread=function(){return(Cg=u.__emscripten_call_on_thread=u.asm.vb).apply(null,arguments)},jC=u._emscripten_tls_init=function(){return(jC=u._emscripten_tls_init=u.asm.wb).apply(null,arguments)},Tg=u.__emscripten_thread_init=function(){return(Tg=u.__emscripten_thread_init=u.asm.xb).apply(null,arguments)},oc=u.stackSave=function(){return(oc=u.stackSave=u.asm.yb).apply(null,arguments)},Li=u.stackRestore=function(){return(Li=u.stackRestore=u.asm.zb).apply(null,arguments)},Bi=u.stackAlloc=function(){return(Bi=u.stackAlloc=u.asm.Ab).apply(null,arguments)},_5=u._emscripten_stack_set_limits=function(){return(_5=u._emscripten_stack_set_limits=u.asm.Bb).apply(null,arguments)},F5=u._memalign=function(){return(F5=u._memalign=u.asm.Cb).apply(null,arguments)},$5=u.__emscripten_allow_main_runtime_queued_calls=10512,Wi=u.__emscripten_main_thread_futex=12148;u.cwrap=Be,u.PThread=De,u.PThread=De,u.wasmMemory=re,u.ExitStatus=ic;var _p;function ic(I){this.name="ExitStatus",this.message="Program terminated with exit("+I+")",this.status=I}Va=function I(){_p||Ng(),_p||(Va=I)};function Ng(I){if(I=I||m,Ds>0)return;if(S){d(u),up(),postMessage({cmd:"loaded"});return}if(lp(),Ds>0)return;function E(){_p||(_p=!0,u.calledRun=!0,!ge&&(up(),cp(),d(u),u.onRuntimeInitialized&&u.onRuntimeInitialized(),dp()))}u.setStatus?(u.setStatus("Running..."),setTimeout(function(){setTimeout(function(){u.setStatus("")},1),E()},1)):E()}u.run=Ng;function qC(I,E){if(!(E&&ae&&I===0)){if(!E&&S)throw postMessage({cmd:"exitProcess",returnCode:I}),new ic(I);ae||(De.terminateAllThreads(),ve=I,Vn(),u.onExit&&u.onExit(I),ge=!0),A(I,new ic(I))}}if(u.preInit)for(typeof u.preInit=="function"&&(u.preInit=[u.preInit]);u.preInit.length>0;)u.preInit.pop()();return S&&(ae=!1,De.initWorker()),Ng(),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)}}),vT=St({"node_modules/.pnpm/@tensorflow+tfjs-backend-wasm@3.10.0_@tensorflow+tfjs-core@3.10.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,ie){o=J,i=ie});var l={},c;for(c in a)a.hasOwnProperty(c)&&(l[c]=a[c]);var u=[],d="./this.program",p=function(J,ie){throw ie},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,S,T,_;m?(f?A=pc().dirname(A)+"/":A=__dirname+"/",x=function(ie,ke){return T||(T=Gi("fs")),_||(_=pc()),ie=_.normalize(ie),T.readFileSync(ie,ke?null:"utf8")},v=function(ie){var ke=x(ie,!0);return ke.buffer||(ke=new Uint8Array(ke)),j(ke.buffer),ke},process.argv.length>1&&(d=process.argv[1].replace(/\\/g,"/")),u=process.argv.slice(2),process.on("uncaughtException",function(J){if(!(J instanceof Sg))throw J}),process.on("unhandledRejection",Hs),p=function(J){process.exit(J)},a.inspect=function(){return"[Emscripten Module object]"}):g?(typeof read!="undefined"&&(x=function(ie){return read(ie)}),v=function(ie){var ke;return typeof readbuffer=="function"?new Uint8Array(readbuffer(ie)):(ke=read(ie,"binary"),j(typeof ke=="object"),ke)},typeof scriptArgs!="undefined"?u=scriptArgs:typeof arguments!="undefined"&&(u=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 ie=new XMLHttpRequest;return ie.open("GET",J,!1),ie.send(null),ie.responseText},f&&(v=function(J){var ie=new XMLHttpRequest;return ie.open("GET",J,!1),ie.responseType="arraybuffer",ie.send(null),new Uint8Array(ie.response)}),b=function(J,ie,ke){var st=new XMLHttpRequest;st.open("GET",J,!0),st.responseType="arraybuffer",st.onload=function(){if(st.status==200||st.status==0&&st.response){ie(st.response);return}ke()},st.onerror=ke,st.send(null)},S=function(J){document.title=J});var O=a.print||console.log.bind(console),P=a.printErr||console.warn.bind(console);for(c in l)l.hasOwnProperty(c)&&(a[c]=l[c]);l=null,a.arguments&&(u=a.arguments),a.thisProgram&&(d=a.thisProgram),a.quit&&(p=a.quit);var D;a.wasmBinary&&(D=a.wasmBinary);var F=a.noExitRuntime||!0;typeof WebAssembly!="object"&&Hs("no native wasm support detected");var C,M=!1,U;function j(J,ie){J||Hs("Assertion failed: "+ie)}function q(J){var ie=a["_"+J];return j(ie,"Cannot call unknown function "+J+", make sure it is exported"),ie}function X(J,ie,ke,st,Ot){var It={string:function(es){var ta=0;if(es!=null&&es!==0){var Rp=(es.length<<2)+1;ta=nc(Rp),re(es,ta,Rp)}return ta},array:function(es){var ta=nc(es.length);return ce(es,ta),ta}};function Xe(es){return ie==="string"?oe(es):ie==="boolean"?Boolean(es):es}var Ye=q(J),fn=[],_r=0;if(st)for(var Fr=0;Fr<st.length;Fr++){var Ep=It[ke[Fr]];Ep?(_r===0&&(_r=Tp()),fn[Fr]=Ep(st[Fr])):fn[Fr]=st[Fr]}var rc=Ye.apply(null,fn);return rc=Xe(rc),_r!==0&&Np(_r),rc}function te(J,ie,ke,st){ke=ke||[];var Ot=ke.every(function(Xe){return Xe==="number"}),It=ie!=="string";return It&&Ot&&!st?q(J):function(){return X(J,ie,ke,arguments,st)}}var ne=typeof TextDecoder!="undefined"?new TextDecoder("utf8"):void 0;function se(J,ie,ke){for(var st=ie+ke,Ot=ie;J[Ot]&&!(Ot>=st);)++Ot;if(Ot-ie>16&&J.subarray&&ne)return ne.decode(J.subarray(ie,Ot));for(var It="";ie<Ot;){var Xe=J[ie++];if(!(Xe&128)){It+=String.fromCharCode(Xe);continue}var Ye=J[ie++]&63;if((Xe&224)==192){It+=String.fromCharCode((Xe&31)<<6|Ye);continue}var fn=J[ie++]&63;if((Xe&240)==224?Xe=(Xe&15)<<12|Ye<<6|fn:Xe=(Xe&7)<<18|Ye<<12|fn<<6|J[ie++]&63,Xe<65536)It+=String.fromCharCode(Xe);else{var _r=Xe-65536;It+=String.fromCharCode(55296|_r>>10,56320|_r&1023)}}return It}function oe(J,ie){return J?se(Re,J,ie):""}function ae(J,ie,ke,st){if(!(st>0))return 0;for(var Ot=ke,It=ke+st-1,Xe=0;Xe<J.length;++Xe){var Ye=J.charCodeAt(Xe);if(Ye>=55296&&Ye<=57343){var fn=J.charCodeAt(++Xe);Ye=65536+((Ye&1023)<<10)|fn&1023}if(Ye<=127){if(ke>=It)break;ie[ke++]=Ye}else if(Ye<=2047){if(ke+1>=It)break;ie[ke++]=192|Ye>>6,ie[ke++]=128|Ye&63}else if(Ye<=65535){if(ke+2>=It)break;ie[ke++]=224|Ye>>12,ie[ke++]=128|Ye>>6&63,ie[ke++]=128|Ye&63}else{if(ke+3>=It)break;ie[ke++]=240|Ye>>18,ie[ke++]=128|Ye>>12&63,ie[ke++]=128|Ye>>6&63,ie[ke++]=128|Ye&63}}return ie[ke]=0,ke-Ot}function re(J,ie,ke){return ae(J,Re,ie,ke)}function ce(J,ie){Ce.set(J,ie)}function ge(J,ie){return J%ie>0&&(J+=ie-J%ie),J}var ve,Ce,Re,Pe,Be,Ue,et,ut,at;function ot(J){ve=J,a.HEAP8=Ce=new Int8Array(J),a.HEAP16=Pe=new Int16Array(J),a.HEAP32=Ue=new Int32Array(J),a.HEAPU8=Re=new Uint8Array(J),a.HEAPU16=Be=new Uint16Array(J),a.HEAPU32=et=new Uint32Array(J),a.HEAPF32=ut=new Float32Array(J),a.HEAPF64=at=new Float64Array(J)}var pt=a.INITIAL_MEMORY||16777216,ft,kt=[],Rt=[],Wn=[],pn=[],Gs=!1;Rt.push({func:function(){mp()}});function Sn(){if(a.preRun)for(typeof a.preRun=="function"&&(a.preRun=[a.preRun]);a.preRun.length;)hn(a.preRun.shift());Ds(kt)}function Qn(){Gs=!0,Ds(Rt)}function Rs(){Ds(Wn)}function As(){if(a.postRun)for(typeof a.postRun=="function"&&(a.postRun=[a.postRun]);a.postRun.length;)ur(a.postRun.shift());Ds(pn)}function hn(J){kt.unshift(J)}function ur(J){pn.unshift(J)}var vn=0,cr=null,dr=null;function Yr(J){vn++,a.monitorRunDependencies&&a.monitorRunDependencies(vn)}function Zu(J){if(vn--,a.monitorRunDependencies&&a.monitorRunDependencies(vn),vn==0&&(cr!==null&&(clearInterval(cr),cr=null),dr)){var ie=dr;dr=null,ie()}}a.preloadedImages={},a.preloadedAudios={};function Hs(J){a.onAbort&&a.onAbort(J),J+="",P(J),M=!0,U=1,J="abort("+J+"). Build with -s ASSERTIONS=1 for more info.";var ie=new WebAssembly.RuntimeError(J);throw i(ie),ie}function ip(J,ie){return String.prototype.startsWith?J.startsWith(ie):J.indexOf(ie)===0}var rm="data:application/octet-stream;base64,";function lp(J){return ip(J,rm)}var up="file://";function cp(J){return ip(J,up)}var Vn="tfjs-backend-wasm.wasm";lp(Vn)||(Vn=y(Vn));function dp(J){try{if(J==Vn&&D)return new Uint8Array(D);if(v)return v(J);throw"both async and sync fetching of the wasm failed"}catch(ie){Hs(ie)}}function am(){if(!D&&(h||f)){if(typeof fetch=="function"&&!cp(Vn))return fetch(Vn,{credentials:"same-origin"}).then(function(J){if(!J.ok)throw"failed to load wasm binary file at '"+Vn+"'";return J.arrayBuffer()}).catch(function(){return dp(Vn)});if(b)return new Promise(function(J,ie){b(Vn,function(ke){J(new Uint8Array(ke))},ie)})}return Promise.resolve().then(function(){return dp(Vn)})}function om(){var J={a:pm};function ie(Xe,Ye){var fn=Xe.exports;a.asm=fn,C=a.asm.j,ot(C.buffer),ft=a.asm.r,Zu("wasm-instantiate")}Yr("wasm-instantiate");function ke(Xe){ie(Xe.instance)}function st(Xe){return am().then(function(Ye){return WebAssembly.instantiate(Ye,J)}).then(Xe,function(Ye){P("failed to asynchronously prepare wasm: "+Ye),Hs(Ye)})}function Ot(){return!D&&typeof WebAssembly.instantiateStreaming=="function"&&!lp(Vn)&&!cp(Vn)&&typeof fetch=="function"?fetch(Vn,{credentials:"same-origin"}).then(function(Xe){var Ye=WebAssembly.instantiateStreaming(Xe,J);return Ye.then(ke,function(fn){return P("wasm streaming compile failed: "+fn),P("falling back to ArrayBuffer instantiation"),st(ke)})}):st(ke)}if(a.instantiateWasm)try{var It=a.instantiateWasm(J,ie);return It}catch(Xe){return P("Module.instantiateWasm callback failed with error: "+Xe),!1}return Ot().catch(i),{}}function Ds(J){for(;J.length>0;){var ie=J.shift();if(typeof ie=="function"){ie(a);continue}var ke=ie.func;typeof ke=="number"?ie.arg===void 0?ft.get(ke)():ft.get(ke)(ie.arg):ke(ie.arg===void 0?null:ie.arg)}}function Yu(){Hs()}function Va(J,ie,ke){Re.copyWithin(J,ie,ie+ke)}function im(){return Re.length}function lm(J){try{return C.grow(J-ve.byteLength+65535>>>16),ot(C.buffer),1}catch{}}function Dr(J){var ie=im(),ke=2147483648;if(J>ke)return!1;for(var st=1;st<=4;st*=2){var Ot=ie*(1+.2/st);Ot=Math.min(Ot,J+100663296);var It=Math.min(ke,ge(Math.max(J,Ot),65536)),Xe=lm(It);if(Xe)return!0}return!1}var Ua={mappings:{},buffers:[null,[],[]],printChar:function(J,ie){var ke=Ua.buffers[J];ie===0||ie===10?((J===1?O:P)(se(ke,0)),ke.length=0):ke.push(ie)},varargs:void 0,get:function(){Ua.varargs+=4;var J=Ue[Ua.varargs-4>>2];return J},getStr:function(J){var ie=oe(J);return ie},get64:function(J,ie){return J}};function um(J){return 0}function pp(J,ie,ke,st,Ot){}function cm(J,ie,ke,st){for(var Ot=0,It=0;It<ke;It++){for(var Xe=Ue[ie+It*8>>2],Ye=Ue[ie+(It*8+4)>>2],fn=0;fn<Ye;fn++)Ua.printChar(J,Re[Xe+fn]);Ot+=Ye}return Ue[st>>2]=Ot,0}function hp(){return 6}function Un(){return 28}function fp(J){return Ue[Cp()>>2]=J,J}function dm(J){switch(J){case 30:return 16384;case 85:var ie=2147483648;return ie/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 fp(28),-1}var pm={a:Yu,d:Va,e:Dr,f:um,c:pp,b:cm,h:hp,g:Un,i:dm},hm=om(),mp=a.___wasm_call_ctors=function(){return(mp=a.___wasm_call_ctors=a.asm.k).apply(null,arguments)},Pi=a._init=function(){return(Pi=a._init=a.asm.l).apply(null,arguments)},Jr=a._init_with_threads_count=function(){return(Jr=a._init_with_threads_count=a.asm.m).apply(null,arguments)},Ju=a._get_threads_count=function(){return(Ju=a._get_threads_count=a.asm.n).apply(null,arguments)},fm=a._register_tensor=function(){return(fm=a._register_tensor=a.asm.o).apply(null,arguments)},mm=a._dispose_data=function(){return(mm=a._dispose_data=a.asm.p).apply(null,arguments)},gp=a._dispose=function(){return(gp=a._dispose=a.asm.q).apply(null,arguments)},De=a._Abs=function(){return(De=a._Abs=a.asm.s).apply(null,arguments)},gm=a._Add=function(){return(gm=a._Add=a.asm.t).apply(null,arguments)},Am=a._AddN=function(){return(Am=a._AddN=a.asm.u).apply(null,arguments)},ym=a._All=function(){return(ym=a._All=a.asm.v).apply(null,arguments)},xm=a._Any=function(){return(xm=a._Any=a.asm.w).apply(null,arguments)},bm=a._ArgMax=function(){return(bm=a._ArgMax=a.asm.x).apply(null,arguments)},Ga=a._AvgPool=function(){return(Ga=a._AvgPool=a.asm.y).apply(null,arguments)},vm=a._BatchMatMul=function(){return(vm=a._BatchMatMul=a.asm.z).apply(null,arguments)},wm=a._Ceil=function(){return(wm=a._Ceil=a.asm.A).apply(null,arguments)},km=a._ClipByValue=function(){return(km=a._ClipByValue=a.asm.B).apply(null,arguments)},Im=a._Conv2D=function(){return(Im=a._Conv2D=a.asm.C).apply(null,arguments)},Sm=a._Conv2DBackpropInput=function(){return(Sm=a._Conv2DBackpropInput=a.asm.D).apply(null,arguments)},Cm=a._Cos=function(){return(Cm=a._Cos=a.asm.E).apply(null,arguments)},Ap=a._Cosh=function(){return(Ap=a._Cosh=a.asm.F).apply(null,arguments)},Tm=a._CropAndResize=function(){return(Tm=a._CropAndResize=a.asm.G).apply(null,arguments)},Nm=a._Cumsum=function(){return(Nm=a._Cumsum=a.asm.H).apply(null,arguments)},Qr=a._DepthToSpace=function(){return(Qr=a._DepthToSpace=a.asm.I).apply(null,arguments)},Qu=a._DepthwiseConv2dNative=function(){return(Qu=a._DepthwiseConv2dNative=a.asm.J).apply(null,arguments)},ec=a._Elu=function(){return(ec=a._Elu=a.asm.K).apply(null,arguments)},Em=a._Equal=function(){return(Em=a._Equal=a.asm.L).apply(null,arguments)},Rm=a._Exp=function(){return(Rm=a._Exp=a.asm.M).apply(null,arguments)},Dm=a._FlipLeftRight=function(){return(Dm=a._FlipLeftRight=a.asm.N).apply(null,arguments)},_m=a._Floor=function(){return(_m=a._Floor=a.asm.O).apply(null,arguments)},Fm=a._FloorDiv=function(){return(Fm=a._FloorDiv=a.asm.P).apply(null,arguments)},We=a._FusedBatchNorm=function(){return(We=a._FusedBatchNorm=a.asm.Q).apply(null,arguments)},$m=a._FusedConv2D=function(){return($m=a._FusedConv2D=a.asm.R).apply(null,arguments)},Om=a._FusedDepthwiseConv2D=function(){return(Om=a._FusedDepthwiseConv2D=a.asm.S).apply(null,arguments)},Pm=a._Gather=function(){return(Pm=a._Gather=a.asm.T).apply(null,arguments)},Mm=a._GatherNd=function(){return(Mm=a._GatherNd=a.asm.U).apply(null,arguments)},zm=a._Greater=function(){return(zm=a._Greater=a.asm.V).apply(null,arguments)},Lm=a._GreaterEqual=function(){return(Lm=a._GreaterEqual=a.asm.W).apply(null,arguments)},tc=a._LeakyRelu=function(){return(tc=a._LeakyRelu=a.asm.X).apply(null,arguments)},yp=a._Less=function(){return(yp=a._Less=a.asm.Y).apply(null,arguments)},xp=a._LessEqual=function(){return(xp=a._LessEqual=a.asm.Z).apply(null,arguments)},Bm=a._Log=function(){return(Bm=a._Log=a.asm._).apply(null,arguments)},Wm=a._LogicalAnd=function(){return(Wm=a._LogicalAnd=a.asm.$).apply(null,arguments)},Vm=a._Max=function(){return(Vm=a._Max=a.asm.aa).apply(null,arguments)},Um=a._MaxPool=function(){return(Um=a._MaxPool=a.asm.ba).apply(null,arguments)},Gm=a._Maximum=function(){return(Gm=a._Maximum=a.asm.ca).apply(null,arguments)},Hm=a._Mean=function(){return(Hm=a._Mean=a.asm.da).apply(null,arguments)},jm=a._Min=function(){return(jm=a._Min=a.asm.ea).apply(null,arguments)},it=a._Minimum=function(){return(it=a._Minimum=a.asm.fa).apply(null,arguments)},qm=a._MirrorPad=function(){return(qm=a._MirrorPad=a.asm.ga).apply(null,arguments)},Xm=a._Multiply=function(){return(Xm=a._Multiply=a.asm.ha).apply(null,arguments)},Km=a._Neg=function(){return(Km=a._Neg=a.asm.ia).apply(null,arguments)},Mi=a._NonMaxSuppressionV3=function(){return(Mi=a._NonMaxSuppressionV3=a.asm.ja).apply(null,arguments)},bp=a._NonMaxSuppressionV4=function(){return(bp=a._NonMaxSuppressionV4=a.asm.ka).apply(null,arguments)},vp=a._NonMaxSuppressionV5=function(){return(vp=a._NonMaxSuppressionV5=a.asm.la).apply(null,arguments)},wp=a._NotEqual=function(){return(wp=a._NotEqual=a.asm.ma).apply(null,arguments)},Zm=a._OneHot=function(){return(Zm=a._OneHot=a.asm.na).apply(null,arguments)},Ym=a._PadV2=function(){return(Ym=a._PadV2=a.asm.oa).apply(null,arguments)},kp=a._Pow=function(){return(kp=a._Pow=a.asm.pa).apply(null,arguments)},Jm=a._Prelu=function(){return(Jm=a._Prelu=a.asm.qa).apply(null,arguments)},Qm=a._Prod=function(){return(Qm=a._Prod=a.asm.ra).apply(null,arguments)},eg=a._RealDiv=function(){return(eg=a._RealDiv=a.asm.sa).apply(null,arguments)},tg=a._Relu=function(){return(tg=a._Relu=a.asm.ta).apply(null,arguments)},ng=a._Relu6=function(){return(ng=a._Relu6=a.asm.ua).apply(null,arguments)},Ip=a._ResizeBilinear=function(){return(Ip=a._ResizeBilinear=a.asm.va).apply(null,arguments)},ea=a._Reverse=function(){return(ea=a._Reverse=a.asm.wa).apply(null,arguments)},sg=a._RotateWithOffset=function(){return(sg=a._RotateWithOffset=a.asm.xa).apply(null,arguments)},rg=a._Round=function(){return(rg=a._Round=a.asm.ya).apply(null,arguments)},k5=a._Rsqrt=function(){return(k5=a._Rsqrt=a.asm.za).apply(null,arguments)},Sp=a._ScatterNd=function(){return(Sp=a._ScatterNd=a.asm.Aa).apply(null,arguments)},ag=a._SelectV2=function(){return(ag=a._SelectV2=a.asm.Ba).apply(null,arguments)},og=a._Sigmoid=function(){return(og=a._Sigmoid=a.asm.Ca).apply(null,arguments)},ig=a._Sin=function(){return(ig=a._Sin=a.asm.Da).apply(null,arguments)},lg=a._Softmax=function(){return(lg=a._Softmax=a.asm.Ea).apply(null,arguments)},ug=a._Sqrt=function(){return(ug=a._Sqrt=a.asm.Fa).apply(null,arguments)},cg=a._Square=function(){return(cg=a._Square=a.asm.Ga).apply(null,arguments)},dg=a._SquaredDifference=function(){return(dg=a._SquaredDifference=a.asm.Ha).apply(null,arguments)},pg=a._Step=function(){return(pg=a._Step=a.asm.Ia).apply(null,arguments)},hg=a._StridedSlice=function(){return(hg=a._StridedSlice=a.asm.Ja).apply(null,arguments)},fg=a._Sub=function(){return(fg=a._Sub=a.asm.Ka).apply(null,arguments)},mg=a._Sum=function(){return(mg=a._Sum=a.asm.La).apply(null,arguments)},gg=a._Tan=function(){return(gg=a._Tan=a.asm.Ma).apply(null,arguments)},Ag=a._Tanh=function(){return(Ag=a._Tanh=a.asm.Na).apply(null,arguments)},yg=a._Tile=function(){return(yg=a._Tile=a.asm.Oa).apply(null,arguments)},xg=a._TopK=function(){return(xg=a._TopK=a.asm.Pa).apply(null,arguments)},bg=a._Transform=function(){return(bg=a._Transform=a.asm.Qa).apply(null,arguments)},vg=a._Transpose=function(){return(vg=a._Transpose=a.asm.Ra).apply(null,arguments)},wg=a.__FusedMatMul=function(){return(wg=a.__FusedMatMul=a.asm.Sa).apply(null,arguments)},kg=a._malloc=function(){return(kg=a._malloc=a.asm.Ta).apply(null,arguments)},Ig=a._free=function(){return(Ig=a._free=a.asm.Ua).apply(null,arguments)},Cp=a.___errno_location=function(){return(Cp=a.___errno_location=a.asm.Va).apply(null,arguments)},Tp=a.stackSave=function(){return(Tp=a.stackSave=a.asm.Wa).apply(null,arguments)},Np=a.stackRestore=function(){return(Np=a.stackRestore=a.asm.Xa).apply(null,arguments)},nc=a.stackAlloc=function(){return(nc=a.stackAlloc=a.asm.Ya).apply(null,arguments)};a.cwrap=te;var zi;function Sg(J){this.name="ExitStatus",this.message="Program terminated with exit("+J+")",this.status=J}dr=function J(){zi||sc(),zi||(dr=J)};function sc(J){if(J=J||u,vn>0||(Sn(),vn>0))return;function ie(){zi||(zi=!0,a.calledRun=!0,!M&&(Qn(),Rs(),o(a),a.onRuntimeInitialized&&a.onRuntimeInitialized(),As()))}a.setStatus?(a.setStatus("Running..."),setTimeout(function(){setTimeout(function(){a.setStatus("")},1),ie()},1)):ie()}if(a.run=sc,a.preInit)for(typeof a.preInit=="function"&&(a.preInit=[a.preInit]);a.preInit.length>0;)a.preInit.pop()();return sc(),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)}}),wT=1e-7,kT=1e-4,$p=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}},hc=class{refCount(e){return _s("refCount")}incRef(e){return _s("incRef")}timerAvailable(){return!0}time(e){return _s("time")}read(e){return _s("read")}readSync(e){return _s("readSync")}numDataIds(){return _s("numDataIds")}disposeData(e,t){return _s("disposeData")}write(e,t,n){return _s("write")}move(e,t,n,s,r){return _s("move")}memory(){return _s("memory")}floatPrecision(){return _s("floatPrecision")}epsilon(){return this.floatPrecision()===32?wT:kT}dispose(){return _s("dispose")}};function _s(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 V5(e){let t=e.length,n=0;for(;t>0;)n=Math.random()*t|0,t--,Op(e,t,n)}function IT(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--,Op(e,n,s),Op(t,n,s)}function fc(e,t,n){return Math.max(e,Math.min(t,n))}function ST(e){return e%2==0?e:e+1}function Op(e,t,n){let s=e[t];e[t]=e[n],e[n]=s}function CT(e){let t=0;for(let n=0;n<e.length;n++)t+=e[n];return t}function TT(e,t){let n=Math.random();return t*n+(1-n)*e}function NT(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 $(e,t){if(!e)throw new Error(typeof t=="string"?t:t())}function Tn(e,t,n=""){$($r(e,t),()=>n+` Shapes ${e} and ${t} must match`)}function qa(e){$(e!=null,()=>"The input to the tensor constructor must be a non-null value.")}function Xa(e,t=[],n=!1){if(t==null&&(t=[]),Array.isArray(e)||kn(e)&&!n)for(let s=0;s<e.length;++s)Xa(e[s],t,n);else t.push(e);return t}function Mt(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 ET(e){return e.length===0}function $r(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 RT(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 DT(e){let t=Math.ceil(Math.sqrt(e));return[t,Math.ceil(e/t)]}function _T(e){let t=new Uint32Array(e);for(let n=0;n<e;++n)t[n]=n;return V5(t),t}function mc(e,t){return t<=e.length?e:e+" ".repeat(t-e.length)}function FT(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 $T(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 Fs(e,t){let n=t.length;return e=e==null?t.map((s,r)=>r):[].concat(e),$(e.every(s=>s>=-n&&s<n),()=>`All values in axis param must be in range [-${n}, ${n}) but got axis ${e}`),$(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 U5(e,t){let n=[],s=[],r=t!=null&&Array.isArray(t)&&t.length===0,a=t==null||r?null:Fs(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 G5(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 H5(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 j5(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 q5(e){return e==="bool"||e==="complex64"||e==="float32"||e==="int32"||e==="string"}function OT(e,t){return!(t==="complex64"||t==="float32"&&e!=="complex64"||t==="int32"&&e!=="float32"&&e!=="complex64"||t==="bool"&&e==="bool")}function kn(e){return e instanceof Float32Array||e instanceof Int32Array||e instanceof Uint8Array||e instanceof Uint8ClampedArray}function Dg(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 X5(e){if(e==null)return 0;let t=0;return e.forEach(n=>t+=n.length),t}function oa(e){return typeof e=="string"||e instanceof String}function K5(e){return typeof e=="boolean"}function Z5(e){return typeof e=="number"}function Pp(e){return Array.isArray(e)?Pp(e[0]):e instanceof Float32Array?"float32":e instanceof Int32Array||e instanceof Uint8Array||e instanceof Uint8ClampedArray?"int32":Z5(e)?"float32":oa(e)?"string":K5(e)?"bool":"float32"}function ia(e){return!!(e&&e.constructor&&e.call&&e.apply)}function Mp(e,t){for(let n=t;n<e;++n)if(e%n==0)return n;return e}function Hi(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 Y5(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,c)=>l*c)*(s?2:1);for(let l=0;l<a;l++)r[l]=Y5(e+l*i,o,n,s)}return r}function ji(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 Y5(0,e,t,n)}function _g(e,t){let n=zp(e,t);for(let s=0;s<n.length;s++)n[s]=1;return n}function zp(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 PT(e,t){let n=e.reduce((s,r)=>s*r,1);if(t==null||t==="float32")return ji(e,new Float32Array(n));if(t==="int32")return ji(e,new Int32Array(n));if(t==="bool")return ji(e,new Uint8Array(n));throw new Error(`Unknown data type ${t}`)}function Fg(e){e.forEach(t=>{$(Number.isInteger(t)&&t>=0,()=>`Tensor must have a shape comprised of positive integers but got shape [${e}].`)})}function MT(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 zT(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 $g(e){return e&&e.then&&typeof e.then=="function"}function pr(...e){Y().getBool("IS_TEST")||Y().getBool("PROD")||console.warn(...e)}function LT(...e){Y().getBool("IS_TEST")||Y().getBool("PROD")||console.log(...e)}var J5="tfjsflags",Q5=class{constructor(e){this.global=e,this.flags={},this.flagRegistry={},this.urlFlags={},this.getQueryParams=BT,this.populateURLFlags()}setPlatform(e,t){this.platform!=null&&pr(`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];pr(`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($g(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);J5 in e&&e[J5].split(",").forEach(n=>{let[s,r]=n.split(":");this.urlFlags[s]=VT(s,r)})}};function BT(e){let t={};return e.replace(/[?&]([^=?&]+)(?:=([^&]*))?/g,(n,...s)=>(WT(t,s[0],s[1]),s.join("="))),t}function WT(e,t,n){e[decodeURIComponent(t)]=decodeURIComponent(n||"")}function VT(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 hr}var hr=null;function UT(e){hr=e}var Og;function eb(){if(Og==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");Og=e}return Og}function GT(){let e=eb();return e._tfGlobals==null&&(e._tfGlobals=new Map),e._tfGlobals}function Pg(e,t){let n=GT();if(n.has(e))return n.get(e);{let s=t();return n.set(e,s),n.get(e)}}var qi="Abs",Xi="Acos",Ki="Acosh",la="Add",Ka="AddN",Zi="All",Yi="Any",Za="ArgMax",gc="ArgMin",Ji="Asin",Qi="Asinh",el="Atan",tl="Atanh",nl="Atan2",Ya="AvgPool",Lp="AvgPoolGrad",Ac="AvgPool3D",Bp="AvgPool3DGrad",Ja="BatchMatMul",sl="BatchToSpaceND",Wp="Bincount",tb="BroadcastTo",Vp="BroadcastArgs",Qa="Cast",eo="Ceil",ua="ClipByValue",Up="Complex",yc="ComplexAbs",rl="Concat",to="Conv2D",Gp="Conv2DBackpropFilter",no="Conv2DBackpropInput",xc="Conv3D",Hp="Conv3DBackpropFilterV2",jp="Conv3DBackpropInputV2",so="Cos",ro="Cosh",ao="Cumsum",al="CropAndResize",qp="DenseBincount",ol="DepthToSpace",oo="DepthwiseConv2dNative",Xp="DepthwiseConv2dNativeBackpropFilter",Kp="DepthwiseConv2dNativeBackpropInput",Zp="Diag",bc="Dilation2D",Yp="Dilation2DBackpropInput",Jp="Dilation2DBackpropFilter",io="RealDiv",Qp="Einsum",lo="Elu",eh="EluGrad",il="Erf",ll="Equal",uo="Exp",ul="ExpandDims",cl="Expm1",th="FFT",vc="Fill",dl="FlipLeftRight",co="Floor",po="FloorDiv",ho="FusedBatchNorm",pl="GatherV2",hl="GatherNd",fl="Greater",fo="GreaterEqual",mo="Identity",nh="IFFT",sh="Imag",ml="IsFinite",gl="IsInf",Al="IsNan",go="LeakyRelu",yl="Less",xl="LessEqual",rh="LinSpace",Ao="Log",bl="Log1p",vl="LogicalAnd",wc="LogicalNot",kc="LogicalOr",nb="LogSoftmax",Ic="LRN",ah="LRNGrad",yo="Max",xo="Maximum",bo="MaxPool",oh="MaxPoolGrad",Sc="MaxPool3D",ih="MaxPool3DGrad",lh="MaxPoolWithArgmax",vo="Mean",wo="Min",ko="Minimum",Io="MirrorPad",wl="Mod",uh="Multinomial",So="Multiply",kl="Neg",Il="NotEqual",Sl="NonMaxSuppressionV3",Cl="NonMaxSuppressionV4",Tl="NonMaxSuppressionV5",Nl="OnesLike",Co="OneHot",El="Pack",To="PadV2",HT="Pool",No="Pow",Eo="Prelu",Rl="Prod",Cc="Range",ch="Real",Dl="Reciprocal",Ro="Relu",_l="Reshape",Tc="ResizeNearestNeighbor",dh="ResizeNearestNeighborGrad",Do="ResizeBilinear",ph="ResizeBilinearGrad",_o="Relu6",Fo="Reverse",$o="Round",Oo="Rsqrt",Fl="ScatterNd",$l="Select",Ol="Selu",Pl="Slice",Po="Sin",Ml="Sinh",zl="Sign",Mo="Sigmoid",Ll="Softplus",zo="Sqrt",Lo="Sum",Bl="SpaceToBatchND",Wl="SplitV",Bo="Softmax",hh="SparseFillEmptyRows",fh="SparseReshape",mh="SparseSegmentMean",gh="SparseSegmentSum",Ah="SparseToDense",Wo="SquaredDifference",Nc="Square",Vl="StridedSlice",yh="StringNGrams",xh="StringSplit",bh="StringToHashBucketFast",Vo="Sub",Uo="Tan",Go="Tanh",ca="Tile",Ul="TopK",Gl="Transform",Ho="Transpose",vh="Unique",Hl="Unpack",Ec="UnsortedSegmentSum",jl="ZerosLike",da="Step",wh="FromPixels",ql="RotateWithOffset",jo="_FusedMatMul",qo="FusedConv2D",Xo="FusedDepthwiseConv2D",Xl=Pg("kernelRegistry",()=>new Map),Rc=Pg("gradRegistry",()=>new Map);function kh(e,t){let n=zg(e,t);return Xl.get(n)}function Mg(e){return Rc.get(e)}function Or(e){let t=Xl.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 pa(e){let{kernelName:t,backendName:n}=e,s=zg(t,n);Xl.has(s)&&pr(`The kernel '${t}' for backend '${n}' is already registered`),Xl.set(s,e)}function sb(e){let{kernelName:t}=e;Rc.has(t)&&Y().getBool("DEBUG")&&pr(`Overriding the gradient for '${t}'`),Rc.set(t,e)}function jT(e,t){let n=zg(e,t);if(!Xl.has(n))throw new Error(`The kernel '${e}' for backend '${t}' is not registered`);Xl.delete(n)}function qT(e){if(!Rc.has(e))throw new Error(`The gradient '${e}' for backend is not registered`);Rc.delete(e)}function XT(e,t){Or(e).forEach(s=>{let r=Object.assign({},s,{backendName:t});pa(r)})}function zg(e,t){return`${t}_${e}`}var w={};ze(w,{arraysEqual:()=>$r,assert:()=>$,assertNonNegativeIntegerDimensions:()=>Fg,assertNonNull:()=>qa,assertShapesMatch:()=>Tn,bytesFromStringArray:()=>X5,bytesPerElement:()=>Dg,checkConversionForErrors:()=>j5,clamp:()=>fc,computeStrides:()=>Hi,createScalarValue:()=>e9,createShuffledIndices:()=>_T,decodeString:()=>Ch,distSquared:()=>NT,encodeString:()=>Fc,fetch:()=>n9,fingerPrint64:()=>QT,flatten:()=>Xa,getArrayFromDType:()=>H5,getTypedArrayFromDType:()=>G5,hasEncodingLoss:()=>OT,hexToLong:()=>Dc,indexToLoc:()=>zT,inferDtype:()=>Pp,inferFromImplicitShape:()=>$T,isBoolean:()=>K5,isFunction:()=>ia,isInt:()=>sn,isNumber:()=>Z5,isPromise:()=>$g,isScalarShape:()=>ET,isString:()=>oa,isTypedArray:()=>kn,isValidDtype:()=>q5,locToIndex:()=>MT,makeOnesTypedArray:()=>_g,makeZerosNestedTypedArray:()=>PT,makeZerosTypedArray:()=>zp,nearestDivisor:()=>Mp,nearestLargerEven:()=>ST,now:()=>_c,parseAxisParam:()=>Fs,randUniform:()=>TT,repeatedTry:()=>FT,rightPad:()=>mc,shuffle:()=>V5,shuffleCombo:()=>IT,sizeFromShape:()=>Mt,sizeToSquarishShape:()=>DT,squeezeShape:()=>U5,sum:()=>CT,swap:()=>Op,tanh:()=>RT,toNestedArray:()=>ji,toTypedArray:()=>Sh});var rb=ja(nT()),Ko=rb.default||rb;function Dc(e){return Ko.fromString(e,!0,16)}var ab=Dc("c3a5c85c97cb3127"),Zo=Dc("b492b66fbe98f273"),Nn=Dc("9ae16a3b2f90404f");function Lg(e){return e.xor(e.shru(47))}function ob(e,t,n){let s=e.slice(t,t+n);return Ko.fromBytes(Array.from(s),!0,!0)}function yt(e,t){return ob(e,t,8)}function ib(e,t){return ob(e,t,4)}function rn(e,t){return t===0?e:e.shru(t).or(e.shl(64-t))}function ha(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 KT(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 Ih(e,t,n,s){return KT(yt(e,t),yt(e,t+8),yt(e,t+16),yt(e,t+24),n,s)}function ZT(e,t=e.length){if(t>=8){let n=Nn.add(t*2),s=yt(e,0).add(Nn),r=yt(e,t-8),a=rn(r,37).mul(n).add(s),o=rn(s,25).add(r).mul(n);return ha(a,o,n)}if(t>=4){let n=Nn.add(t*2),s=ib(e,0);return ha(s.shl(3).add(t),ib(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 Lg(Nn.mul(a).xor(ab.mul(o))).mul(Nn)}return Nn}function YT(e,t=e.length){let n=Nn.add(t*2),s=yt(e,0).mul(Zo),r=yt(e,8),a=yt(e,t-8).mul(n),o=yt(e,t-16).mul(Nn);return ha(rn(s.add(r),43).add(rn(a,30)).add(o),s.add(rn(r.add(Nn),18)).add(a),n)}function JT(e,t=e.length){let n=Nn.add(t*2),s=yt(e,0).mul(Nn),r=yt(e,8),a=yt(e,t-8).mul(n),o=yt(e,t-16).mul(Nn),i=rn(s.add(r),43).add(rn(a,30)).add(o),l=ha(i,s.add(rn(r.add(Nn),18)).add(a),n),c=yt(e,16).mul(n),u=yt(e,24),d=i.add(yt(e,t-32)).mul(n),p=l.add(yt(e,t-24)).mul(n);return ha(rn(c.add(u),43).add(rn(d,30)).add(p),c.add(rn(u.add(s),18)).add(d),n)}function QT(e,t=e.length){let n=Ko.fromNumber(81,!0);if(t<=32)return t<=16?ZT(e,t):YT(e,t);if(t<=64)return JT(e,t);let s=n,r=n.mul(Zo).add(113),a=Lg(r.mul(Nn).add(113)).mul(Nn),o=[Ko.UZERO,Ko.UZERO],i=[Ko.UZERO,Ko.UZERO];s=s.mul(Nn).add(yt(e,0));let l=0,c=(t-1>>6)*64,u=c+(t-1&63)-63;do s=rn(s.add(r).add(o[0]).add(yt(e,l+8)),37).mul(Zo),r=rn(r.add(o[1]).add(yt(e,l+48)),42).mul(Zo),s=s.xor(i[1]),r=r.add(o[0]).add(yt(e,l+40)),a=rn(a.add(i[0]),33).mul(Zo),o=Ih(e,l,o[1].mul(Zo),s.add(i[0])),i=Ih(e,l+32,a.add(i[1]),r.add(yt(e,l+16))),[a,s]=[s,a],l+=64;while(l!==c);let d=Zo.add(a.and(255).shl(1));return l=u,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(yt(e,l+8)),37).mul(d),r=rn(r.add(o[1]).add(yt(e,l+48)),42).mul(d),s=s.xor(i[1].mul(9)),r=r.add(o[0].mul(9).add(yt(e,l+40))),a=rn(a.add(i[0]),33).mul(d),o=Ih(e,l,o[1].mul(d),s.add(i[0])),i=Ih(e,l+32,a.add(i[1]),r.add(yt(e,l+16))),[a,s]=[s,a],ha(ha(o[0],i[0],d).add(Lg(r).mul(ab)).add(a),ha(o[1],i[1],d).add(s),d)}function e9(e,t){return t==="string"?Fc(e):Sh([e],t)}function t9(e,t){return e instanceof Float32Array&&t==="float32"||e instanceof Int32Array&&t==="int32"||e instanceof Uint8Array&&t==="bool"}function Sh(e,t){if(t==="string")throw new Error("Cannot convert a string[] to a TypedArray");if(Array.isArray(e)&&(e=Xa(e)),Y().getBool("DEBUG")&&j5(e,t),t9(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 _c(){return Y().platform.now()}function n9(e,t){return Y().platform.fetch(e,t)}function Fc(e,t="utf-8"){return t=t||"utf-8",Y().platform.encode(e,t)}function Ch(e,t="utf-8"){return t=t||"utf-8",Y().platform.decode(e,t)}var s9=class{constructor(e,t){this.backendTimer=e,this.logger=t,t==null&&(this.logger=new a9)}profileKernel(e,t,n){let s,r=()=>{s=n()},a,o=_c();if(this.backendTimer.timerAvailable())a=this.backendTimer.time(r);else{r();for(let l of s)l.dataSync();a=Promise.resolve({kernelMs:_c()-o})}if(Y().getBool("CHECK_COMPUTATION_FOR_ERRORS"))for(let l=0;l<s.length;l++){let c=s[l];c.data().then(u=>{r9(u,c.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 r9(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 a9=class{logKernelProfile(e,t,n,s,r,a){let o=typeof s=="number"?mc(`${s}ms`,9):s.error,i=mc(e,25),l=t.rank,c=t.size,u=mc(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 ${u} %c${c} %c${d} %c${a}`,"font-weight:bold","color:red","color:blue","color: orange","color: green","color: steelblue")}};function o9(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 c=e[l],u=c.inputs;for(let d in u){let p=u[d],h=!1;for(let f=0;f<t.length;f++)if(s[p.id]){c.outputs.forEach(m=>s[m.id]=!0),h=!0,r[c.id]=!0;break}if(h)break}}let a={};a[n.id]=!0;let o={};for(let l=e.length-1;l>=0;l--){let c=e[l],u=c.inputs;for(let d=0;d<c.outputs.length;d++)if(a[c.outputs[d].id]){for(let p in u)a[u[p].id]=!0,o[c.id]=!0;break}}let i=[];for(let l=0;l<e.length;l++){let c=e[l];if(r[c.id]&&o[c.id]){let u={};for(let p in c.inputs){let h=c.inputs[p];s[h.id]&&(u[p]=h)}let d=Object.assign({},c);d.inputs=u,d.outputs=c.outputs,i.push(d)}}return i}function i9(e,t,n,s){for(let r=t.length-1;r>=0;r--){let a=t[r],o=[];if(a.outputs.forEach(l=>{let c=e[l.id];c!=null?o.push(c):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 c=n(()=>i[l]());if(c.dtype!=="float32")throw new Error(`Error in gradient for op ${a.kernelName}. The gradient of input ${l} must have 'float32' dtype, but has '${c.dtype}'`);let u=a.inputs[l];if(!$r(c.shape,u.shape))throw new Error(`Error in gradient for op ${a.kernelName}. The gradient of input '${l}' has shape '${c.shape}', which does not match the shape of the input '${u.shape}'`);if(e[u.id]==null)e[u.id]=c;else{let d=e[u.id];e[u.id]=s(d,c),d.dispose()}}}}var lb=20,$c=3,Bg=7;function l9(e,t,n,s){let r=Hi(t),a=u9(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(c=>" "+c).join(`
|
|
`)),l.join(`
|
|
`)}function u9(e,t,n,s){let r=Mt(t),a=s[s.length-1],o=new Array(a).fill(0),i=t.length,l=n==="complex64"?Pc(e):e;if(i>1)for(let c=0;c<r/a;c++){let u=c*a;for(let d=0;d<a;d++)o[d]=Math.max(o[d],Oc(l[u+d],0,n).length)}return o}function Oc(e,t,n){let s;return Array.isArray(e)?s=`${parseFloat(e[0].toFixed(Bg))} + ${parseFloat(e[1].toFixed(Bg))}j`:oa(e)?s=`'${e}'`:n==="bool"?s=ub(e):s=parseFloat(e.toFixed(Bg)).toString(),mc(s,t)}function ub(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=Pc(e);return[Oc(m[0],0,n)]}return n==="bool"?[ub(e[0])]:[e[0].toString()]}if(l===1){if(i>lb){let g=$c*o,A=Array.from(e.slice(0,g)),y=Array.from(e.slice((i-$c)*o,i*o));return n==="complex64"&&(A=Pc(A),y=Pc(y)),["["+A.map((x,b)=>Oc(x,r[b],n)).join(", ")+", ..., "+y.map((x,b)=>Oc(x,r[i-$c+b],n)).join(", ")+"]"]}let m=n==="complex64"?Pc(e):Array.from(e);return["["+m.map((g,A)=>Oc(g,r[A],n)).join(", ")+"]"]}let c=t.slice(1),u=s.slice(1),d=s[0]*o,p=[];if(i>lb){for(let m=0;m<$c;m++){let g=m*d,A=g+d;p.push(...Th(e.slice(g,A),c,n,u,r,!1))}p.push("...");for(let m=i-$c;m<i;m++){let g=m*d,A=g+d;p.push(...Th(e.slice(g,A),c,n,u,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),c,n,u,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 Pc(e){let t=[];for(let n=0;n<e.length;n+=2)t.push([e[n],e[n+1]]);return t}var Zt=class{constructor(e,t,n){if(this.dtype=t,this.shape=e.slice(),this.size=Mt(e),n!=null){let s=n.length;$(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||H5(t,this.size),this.strides=Hi(e)}set(e,...t){t.length===0&&(t=[0]),$(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 fr().makeTensor(this.values,this.shape,this.dtype)}},fr=null,Kl=null,c9=null;function d9(e){fr=e}function p9(e){Kl=e}function h9(e){c9=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=Mt(e),this.strides=Hi(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 Kl.buffer(this.shape,this.dtype,e)}bufferSync(){return Kl.buffer(this.shape,this.dtype,this.dataSync())}async array(){let e=await this.data();return ji(this.shape,e,this.dtype==="complex64")}arraySync(){return ji(this.shape,this.dataSync(),this.dtype==="complex64")}async data(){this.throwIfDisposed();let e=fr().read(this.dataId);if(this.dtype==="string"){let t=await e;try{return t.map(n=>Ch(n))}catch{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=fr().readSync(this.dataId);if(this.dtype==="string")try{return e.map(t=>Ch(t))}catch{throw new Error("Failed to decode the string bytes into utf-8. To get the original bytes, call tensor.bytes().")}return e}async bytes(){this.throwIfDisposed();let e=await fr().read(this.dataId);return this.dtype==="string"?e:new Uint8Array(e.buffer)}dispose(){this.isDisposed||(fr().disposeTensor(this),this.isDisposedInternal=!0)}get isDisposed(){return this.isDisposedInternal}throwIfDisposed(){if(this.isDisposed)throw new Error("Tensor is disposed.")}print(e=!1){return Kl.print(this,e)}clone(){return this.throwIfDisposed(),Kl.clone(this)}toString(e=!1){let t=this.dataSync();return l9(t,this.shape,this.dtype,e)}cast(e){return this.throwIfDisposed(),Kl.cast(this,e)}variable(e=!0,t,n){return this.throwIfDisposed(),fr().makeVariable(this,e,t,n)}};Object.defineProperty(Ge,Symbol.hasInstance,{value:e=>!!e&&e.data!=null&&e.dataSync!=null&&e.throwIfDisposed!=null});function Q(){return Pg("Tensor",()=>Ge)}Q();var Mc=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(!$r(e.shape,this.shape))throw new Error(`shape of the new value (${e.shape}) and previous value (${this.shape}) must match`);fr().disposeTensor(this),this.dataId=e.dataId,fr().incRef(this,null)}dispose(){fr().disposeVariable(this),this.isDisposedInternal=!0}};Object.defineProperty(Mc,Symbol.hasInstance,{value:e=>e instanceof Ge&&e.assign!=null&&e.assign instanceof Function});var js={};ze(js,{assertTypesMatch:()=>cb,getTensorsInContainer:()=>jg,isTensorInList:()=>m9,makeTypesMatch:()=>Dt});var Wg;(function(e){e.R0="R0",e.R1="R1",e.R2="R2",e.R3="R3",e.R4="R4",e.R5="R5",e.R6="R6"})(Wg||(Wg={}));var Vg;(function(e){e.float32="float32",e.int32="int32",e.bool="int32",e.complex64="complex64"})(Vg||(Vg={}));var Ug;(function(e){e.float32="float32",e.int32="int32",e.bool="bool",e.complex64="complex64"})(Ug||(Ug={}));var Gg;(function(e){e.float32="float32",e.int32="float32",e.bool="float32",e.complex64="complex64"})(Gg||(Gg={}));var Hg;(function(e){e.float32="complex64",e.int32="complex64",e.bool="complex64",e.complex64="complex64"})(Hg||(Hg={}));var f9={float32:Gg,int32:Vg,bool:Ug,complex64:Hg};function $s(e,t){if(e==="string"||t==="string"){if(e==="string"&&t==="string")return"string";throw new Error(`Can not upcast ${e} with ${t}`)}return f9[e][t]}function Nh(e){return $s(e,"int32")}function Dt(e,t){if(e.dtype===t.dtype)return[e,t];let n=$s(e.dtype,t.dtype);return[e.cast(n),t.cast(n)]}function cb(e,t){$(e.dtype===t.dtype,()=>`The dtypes of the first(${e.dtype}) and second(${t.dtype}) input must match`)}function m9(e,t){return t.some(n=>n.id===e.id)}function jg(e){let t=[],n=new Set;return db(e,t,n),t}function db(e,t,n){if(e==null)return;if(e instanceof Ge){t.push(e);return}if(!g9(e))return;let s=e;for(let r in s){let a=s[r];n.has(a)||(n.add(a),db(a,t,n))}}function g9(e){return Array.isArray(e)||typeof e=="object"}function qg(e){return e.kernelName!=null}var pb=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()}},zc=class{constructor(e){this.ENV=e,this.registry={},this.registryFactory={},this.pendingBackendInitId=0,this.state=new pb}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?(pr(`${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 s9(this.backendInstance),!0}setupRegisteredKernels(){Or(this.backendName).forEach(t=>{t.setupFunc!=null&&t.setupFunc(this.backendInstance)})}disposeRegisteredKernels(e){Or(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 hc)&&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,pr(`Initialization of backend ${e} failed`),pr(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 pr(`Initialization of backend ${e} failed`),pr(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 zc.nextTensorId++}nextVariableId(){return zc.nextVariableId++}clone(e){let t=B.runKernel(mo,{x:e}),n={x:e},s=a=>({x:()=>{let o="float32",i={x:a},l={dtype:o};return B.runKernel(Qa,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,!(kh(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=qg(e)?e.kernelName:this.state.activeScope!=null?this.state.activeScope.name:"";if(qg(e)){let{kernelName:h,inputs:f,attrs:m}=e;this.backendName==null&&this.backend;let g=kh(h,this.backendName);$(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:S,dtype:T}=b;return this.makeTensorFromDataId(v,S,T)});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:c,attrs:u}=e,d=qg(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,c,()=>o()),this.ENV.getBool("DEBUG")&&this.profiler.logKernelProfile(p),t=p.outputs)}),s&&this.addTapeNode(l,c,t,d,n,u),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(c).map(h=>c[h]!=null?c[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=Mg(e);if(s!=null){let r=s.inputsToSave||[],a=s.outputsToSave||[],o;s.saveAllInputs?($(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,c)=>a[c]);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"&&oa(e[0])&&(r=e.map(i=>Fc(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=X5(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 Mc(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*Dg(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 Mc||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*Dg(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=Mg(e);i!=null&&(s=i.gradFunc),s!=null&&(o.gradient=l=>(l=l.map((c,u)=>{if(c==null){let d=n[u],p=zp(d.size,d.dtype);return this.makeTensor(p,d.shape,d.dtype)}return c}),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=jg(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($(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));$(r instanceof Ge,()=>"The result y returned by f() must be a tensor.");let a=o9(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??A9(r.shape),i9(o,a,l=>this.tidy(l),y9);let i=t.map(l=>o[l.id]);return this.state.gradientDepth===0&&(this.state.activeTape.forEach(l=>{for(let c of l.saved)c.dispose()}),this.state.activeTape=null),{value:r,grads:i}})}customGrad(e){return $(ia(e),()=>"The f passed in customGrad(f) must be a function."),(...t)=>{$(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),$(n.value instanceof Ge,()=>"The function f passed in customGrad(f) must return an object where `obj.value` is a tensor"),$(ia(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),c=Array.isArray(l)?l:[l];$(c.length===t.length,()=>"The function f passed in customGrad(f) must return an object where `obj.gradFunc` is a function that returns the same number of tensors as inputs passed to f(...)."),$(c.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 u={};return c.forEach((d,p)=>{u[p]=()=>d}),u};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=_c(),n=await this.backend.time(e);return n.wallMs=_c()-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 pb;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}};zc.nextTensorId=0;zc.nextVariableId=0;function A9(e){let t=_g(Mt(e),"float32");return B.makeTensor(t,e,"float32")}function hb(){let e=eb();if(e._tfengine==null){let t=new Q5(e);e._tfengine=new zc(t)}return UT(e._tfengine.ENV),d9(()=>e._tfengine),e._tfengine}var B=hb();function y9(e,t){let n={a:e,b:t};return B.runKernel(la,n)}var Lc={};ze(Lc,{isBrowser:()=>fb,isMobile:()=>v9,mockIsMobile:()=>b9});function x9(){return typeof navigator!="undefined"&&navigator!=null}var Xg;function b9(e){Xg=e}function v9(e){if(Xg!==void 0)return Xg;if(e||x9()){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 fb(){return typeof window!="undefined"&&window.document!=null||typeof WorkerGlobalScope!="undefined"}var qs=Y();qs.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.")});qs.registerFlag("IS_BROWSER",()=>fb());qs.registerFlag("IS_NODE",()=>typeof process!="undefined"&&typeof process.versions!="undefined"&&typeof process.versions.node!="undefined");qs.registerFlag("IS_CHROME",()=>typeof navigator!="undefined"&&navigator!=null&&navigator.userAgent!=null&&/Chrome/.test(navigator.userAgent)&&/Google Inc/.test(navigator.vendor));qs.registerFlag("PROD",()=>!1);qs.registerFlag("TENSORLIKE_CHECK_SHAPE_CONSISTENCY",()=>qs.getBool("DEBUG"));qs.registerFlag("DEPRECATION_WARNINGS_ENABLED",()=>!0);qs.registerFlag("IS_TEST",()=>!1);qs.registerFlag("CHECK_COMPUTATION_FOR_ERRORS",()=>!0);qs.registerFlag("WRAP_TO_IMAGEBITMAP",()=>!1);function mr(e,t){let n=e;if(kn(e))return t==="string"?[]:[e.length];if(!Array.isArray(e))return[];let s=[];for(;Array.isArray(n)||kn(n)&&t!=="string";)s.push(n.length),n=n[0];return Array.isArray(e)&&Y().getBool("TENSORLIKE_CHECK_SHAPE_CONSISTENCY")&&mb(e,s,[]),s}function mb(e,t,n){if(n=n||[],!Array.isArray(e)&&!kn(e)){$(t.length===0,()=>`Element arr[${n.join("][")}] is a primitive, but should be an array/TypedArray of ${t[0]} elements`);return}$(t.length>0,()=>`Element arr[${n.join("][")}] should be a primitive, but is an array of ${e.length} elements`),$(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)mb(e[r],s,n.concat(r))}function gb(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 R(e,t,n,s="numeric"){if(e instanceof Ge)return gb(s,e.dtype,t,n),e;let r=Pp(e);if(r!=="string"&&["bool","int32","float32"].indexOf(s)>=0&&(r=s),gb(s,r,t,n),e==null||!kn(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=mr(e,r);!kn(e)&&!Array.isArray(e)&&(e=[e]);let i=r!=="string"?Sh(e,r):Xa(e,[],!0);return B.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)=>R(a,`${t}[${o}]`,n,s))}var Ab="__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+Ab;let r=(...a)=>{B.startScope(n);try{let o=s(...a);return $g(o)&&console.error("Cannot return a Promise inside of tidy."),B.endScope(o),o}catch(o){throw B.endScope(null),o}};return Object.defineProperty(r,"name",{value:n,configurable:!0}),r}function w9(e,t){let n=R(e,"real","complex"),s=R(t,"imag","complex");Tn(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 B.runKernel(Up,r)}var fa=W({complex_:w9});function ma(e,t,n,s){if(s==null&&(s=Pp(e)),s==="complex64")throw new Error("Cannot construct a complex64 tensor directly. Please use tf.complex(real, imag).");if(!kn(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){Fg(t);let r=Mt(t),a=Mt(n);$(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!==Mt(t.slice(o)):!0;$(n[o]===t[o]||!l,()=>`Error creating a new Tensor. Inferred shape (${n}) does not match the provided shape (${t}). `)}}return!kn(e)&&!Array.isArray(e)&&(e=[e]),t=t||n,e=s!=="string"?Sh(e,s):Xa(e,[],!0),B.makeTensor(e,t,s)}function zt(e,t,n){let s=mr(e,n);return ma(e,t,s,n)}var Kg={float32:4,float16:2,int32:4,uint16:2,uint8:1,bool:1,complex64:8},Eh=4;async function k9(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 c={name:i,shape:l.shape,dtype:l.dtype};if(l.dtype==="string"){let u=new Promise(async d=>{let p=await l.bytes(),h=p.reduce((g,A)=>g+A.length,0)+Eh*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+=Eh,f.set(A,m),m+=A.length}d(f)});s.push(u)}else s.push(l.data());t!=null&&(c.group=t),n.push(c)}let a=await Promise.all(s);return{data:I9(a),specs:n}}function yb(e,t){let n={},s,r=0;for(let a of t){let o=a.name,i=a.dtype,l=a.shape,c=Mt(l),u;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=Kg[d.dtype],h=e.slice(r,r+c*p),f=d.dtype==="uint8"?new Uint8Array(h):new Uint16Array(h);if(i==="float32")if(d.dtype==="uint8"||d.dtype==="uint16"){u=new Float32Array(f.length);for(let m=0;m<f.length;m++){let g=f[m];u[m]=g*d.scale+d.min}}else if(d.dtype==="float16")s===void 0&&(s=R9()),u=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.`);u=new Int32Array(f.length);for(let m=0;m<f.length;m++){let g=f[m];u[m]=Math.round(g*d.scale+d.min)}}else throw new Error(`Unsupported dtype in weight '${o}': ${i}`);r+=c*p}else if(i==="string"){let d=Mt(a.shape);u=[];for(let p=0;p<d;p++){let h=new Uint32Array(e.slice(r,r+Eh))[0];r+=Eh;let f=new Uint8Array(e.slice(r,r+h));u.push(f),r+=h}}else{let d=Kg[i],p=e.slice(r,r+c*d);if(i==="float32")u=new Float32Array(p);else if(i==="int32")u=new Int32Array(p);else if(i==="bool")u=new Uint8Array(p);else if(i==="complex64"){u=new Float32Array(p);let h=new Float32Array(u.length/2),f=new Float32Array(u.length/2);for(let A=0;A<h.length;A++)h[A]=u[A*2],f[A]=u[A*2+1];let m=zt(h,l,"float32"),g=zt(f,l,"float32");n[o]=fa(m,g),m.dispose(),g.dispose()}else throw new Error(`Unsupported dtype in weight '${o}': ${i}`);r+=c*d}i!=="complex64"&&(n[o]=zt(u,l,i))}return n}function I9(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 Zg=typeof Buffer!="undefined"&&(typeof Blob=="undefined"||typeof atob=="undefined"||typeof btoa=="undefined");function xb(e){return Zg?Buffer.byteLength(e):new Blob([e]).size}function S9(e){if(Zg)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 C9(e){if(Zg){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 Yg(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 bb(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 vb(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 Jg(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 Wc(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:xb(JSON.stringify(e.modelTopology)),weightSpecsBytes:e.weightSpecs==null?0:xb(JSON.stringify(e.weightSpecs)),weightDataBytes:e.weightData==null?0:e.weightData.byteLength}}function T9(){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 N9(){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 E9(){let e=new Uint32Array(64);for(let t=0;t<64;t++)e[t]=1024;return e[0]=e[32]=0,e}function R9(){let e=T9(),t=N9(),n=E9();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}},D9=e=>Pt.registerSaveRouter(e),_9=e=>Pt.registerLoadRouter(e),F9=e=>Pt.getSaveHandlers(e),$9=(e,t)=>Pt.getLoadHandlers(e,t),Qg="tensorflowjs",eA=1,Yo="models_store",ga="model_info_store";function wb(){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 tA(e){let t=e.result;t.createObjectStore(Yo,{keyPath:"modelPath"}),t.createObjectStore(ga,{keyPath:"modelPath"})}var Jo=class{constructor(e){if(this.indexedDB=wb(),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(Qg,eA);r.onupgradeneeded=()=>tA(r),r.onsuccess=()=>{let a=r.result;if(t==null){let o=a.transaction(Yo,"readonly"),l=o.objectStore(Yo).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=c=>(a.close(),s(l.error)),o.oncomplete=()=>a.close()}else{let o=Wc(t),i=a.transaction(ga,"readwrite"),l=i.objectStore(ga),c=l.put({modelPath:this.modelPath,modelArtifactsInfo:o}),u;c.onsuccess=()=>{u=a.transaction(Yo,"readwrite");let p=u.objectStore(Yo).put({modelPath:this.modelPath,modelArtifacts:t,modelArtifactsInfo:o});p.onsuccess=()=>n({modelArtifactsInfo:o}),p.onerror=h=>{l=i.objectStore(ga);let f=l.delete(this.modelPath);f.onsuccess=()=>(a.close(),s(p.error)),f.onerror=m=>(a.close(),s(p.error))}},c.onerror=d=>(a.close(),s(c.error)),i.oncomplete=()=>{u==null?a.close():u.oncomplete=()=>a.close()}}},r.onerror=a=>s(r.error)})}};Jo.URL_SCHEME="indexeddb://";var kb=e=>Y().getBool("IS_BROWSER")&&!Array.isArray(e)&&e.startsWith(Jo.URL_SCHEME)?O9(e.slice(Jo.URL_SCHEME.length)):null;Pt.registerSaveRouter(kb);Pt.registerLoadRouter(kb);function O9(e){return new Jo(e)}function P9(e){return e.startsWith(Jo.URL_SCHEME)?e.slice(Jo.URL_SCHEME.length):e}var M9=class{constructor(){this.indexedDB=wb()}async listModels(){return new Promise((e,t)=>{let n=this.indexedDB.open(Qg,eA);n.onupgradeneeded=()=>tA(n),n.onsuccess=()=>{let s=n.result,r=s.transaction(ga,"readonly"),o=r.objectStore(ga).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=P9(e),new Promise((t,n)=>{let s=this.indexedDB.open(Qg,eA);s.onupgradeneeded=()=>tA(s),s.onsuccess=()=>{let r=s.result,a=r.transaction(ga,"readwrite"),o=a.objectStore(ga),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 c=o.delete(e),u=()=>{l=r.transaction(Yo,"readwrite");let p=l.objectStore(Yo).delete(e);p.onsuccess=()=>t(i.result.modelArtifactsInfo),p.onerror=h=>n(i.error)};c.onsuccess=u,c.onerror=d=>(u(),r.close(),n(i.error))}},i.onerror=c=>(r.close(),n(i.error)),a.oncomplete=()=>{l==null?r.close():l.oncomplete=()=>r.close()}},s.onerror=r=>n(s.error)})}},Pr="/",Zl="tensorflowjs_models",Ib="info",z9="model_topology",L9="weight_specs",B9="weight_data",W9="model_metadata";function Sb(e){return{info:[Zl,e,Ib].join(Pr),topology:[Zl,e,z9].join(Pr),weightSpecs:[Zl,e,L9].join(Pr),weightData:[Zl,e,B9].join(Pr),modelMetadata:[Zl,e,W9].join(Pr)}}function Cb(e){for(let t of Object.values(e))window.localStorage.removeItem(t)}function V9(e){let t=e.split(Pr);if(t.length<3)throw new Error(`Invalid key format: ${e}`);return t.slice(1,t.length-1).join(Pr)}function U9(e){return e.startsWith(Qo.URL_SCHEME)?e.slice(Qo.URL_SCHEME.length):e}var Qo=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=Sb(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=Wc(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,S9(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{throw Cb(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=C9(a),t}};Qo.URL_SCHEME="localstorage://";var Tb=e=>Y().getBool("IS_BROWSER")&&!Array.isArray(e)&&e.startsWith(Qo.URL_SCHEME)?G9(e.slice(Qo.URL_SCHEME.length)):null;Pt.registerSaveRouter(Tb);Pt.registerLoadRouter(Tb);function G9(e){return new Qo(e)}var H9=class{constructor(){$(Y().getBool("IS_BROWSER"),()=>"Current environment is not a web browser"),$(typeof window=="undefined"||typeof window.localStorage!="undefined",()=>"Current browser does not appear to support localStorage"),this.LS=window.localStorage}async listModels(){let e={},t=Zl+Pr,n=Pr+Ib;for(let s=0;s<this.LS.length;++s){let r=this.LS.key(s);if(r.startsWith(t)&&r.endsWith(n)){let a=V9(r);e[a]=JSON.parse(this.LS.getItem(r))}}return e}async removeModel(e){e=U9(e);let t=Sb(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 Cb(t),n}},Yl="://",ys=class{constructor(){this.managers={}}static getInstance(){return ys.instance==null&&(ys.instance=new ys),ys.instance}static registerManager(e,t){$(e!=null,()=>"scheme must not be undefined or null."),e.endsWith(Yl)&&(e=e.slice(0,e.indexOf(Yl))),$(e.length>0,()=>"scheme must not be an empty string.");let n=ys.getInstance();$(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(Yl)===-1)throw new Error(`The url string provided does not contain a scheme. Supported schemes are: ${ys.getSchemes().join(",")}`);return{scheme:e.split(Yl)[0],path:e.split(Yl)[1]}}async function Nb(e,t,n=!1){$(e!==t,()=>`Old path and new path are the same: '${e}'`);let s=Pt.getLoadHandlers(e);$(s.length>0,()=>`Copying failed because no load handler is found for source URL ${e}.`),$(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);$(a.length>0,()=>`Copying failed because no save handler is found for destination URL ${t}.`),$(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,c=i===Rh(e).scheme,u=await r.load();n&&c&&await ys.getManager(i).removeModel(l);let d=await o.save(u);return n&&!c&&await ys.getManager(i).removeModel(l),d.modelArtifactsInfo}async function j9(){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+Yl+r;t[a]=s[r]}}return t}async function q9(e){let t=Rh(e);return ys.getManager(t.scheme).removeModel(t.path)}async function X9(e,t){return Nb(e,t,!1)}async function K9(e,t){return Nb(e,t,!0)}var Z9=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 Z9);try{ys.registerManager(Qo.URL_SCHEME,new H9)}catch{}try{ys.registerManager(Jo.URL_SCHEME,new M9)}catch{}}var Y9={importFetch:()=>sT()},nA,J9=class{constructor(){this.util=Gi("util"),this.textEncoder=new this.util.TextEncoder}fetch(e,t){return Y().global.fetch!=null?Y().global.fetch(e,t):(nA==null&&(nA=Y9.importFetch()),nA(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 J9);function He(e,t="float32",n){return t=t||"float32",Fg(e),new Zt(e,t,n)}function Q9(e,t){let n=R(e,"x","cast");if(!q5(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 B.runKernel(Qa,s,r)}var de=W({cast_:Q9});function eN(e){let n={x:R(e,"x","clone","string_or_numeric")};return B.runKernel(mo,n)}var Xs=W({clone_:eN});function Eb(e,t=!1){console.log(e.toString(t))}hb();var tN={buffer:He,cast:de,clone:Xs,print:Eb};p9(tN);var Gn={};ze(Gn,{browserFiles:()=>lN,browserHTTPRequest:()=>hN,concatenateArrayBuffers:()=>Yg,copyModel:()=>X9,decodeWeights:()=>yb,encodeWeights:()=>k9,fromMemory:()=>mN,getLoadHandlers:()=>$9,getModelArtifactsForJSON:()=>Jg,getModelArtifactsInfoForJSON:()=>Wc,getSaveHandlers:()=>F9,http:()=>aA,isHTTPScheme:()=>rA,listModels:()=>j9,loadWeights:()=>uN,moveModel:()=>K9,registerLoadRouter:()=>_9,registerSaveRouter:()=>D9,removeModel:()=>q9,weightsLoaderFactory:()=>Fb,withSaveHandler:()=>gN});var nN="model",sN=".json",rN=".weights.bin";function Rb(e){return new Promise(t=>setTimeout(t)).then(e)}var Jl=class{constructor(e){if(!Y().getBool("IS_BROWSER"))throw new Error("browserDownloads() cannot proceed because the current environment is not a browser.");e.startsWith(Jl.URL_SCHEME)&&(e=e.slice(Jl.URL_SCHEME.length)),(e==null||e.length===0)&&(e=nN),this.modelJsonFileName=e+sN,this.weightDataFileName=e+rN}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=vb(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 Rb(()=>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 Rb(()=>o.dispatchEvent(new MouseEvent("click")))}return{modelArtifactsInfo:Wc(e)}}}};Jl.URL_SCHEME="downloads://";var aN=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=Jg(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,Yg(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=>bb(r.name)),s={};for(let r of e)r.paths.forEach(a=>{let o=bb(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}},oN=e=>Y().getBool("IS_BROWSER")&&!Array.isArray(e)&&e.startsWith(Jl.URL_SCHEME)?iN(e.slice(Jl.URL_SCHEME.length)):null;Pt.registerSaveRouter(oN);function iN(e="model"){return new Jl(e)}function lN(e){return new aN(e)}function Db(e,t,n,s){o(e),n=n??0,s=s??1,i(n,s);let r=0,a=l=>(l.then(c=>{let u=n+ ++r/e.length*(s-n);return t(u),c}),l);function o(l){$(l!=null&&Array.isArray(l)&&l.length>0,()=>"promises must be a none empty array")}function i(l,c){$(l>=0&&l<=1,()=>`Progress fraction must be in range [0, 1], but got startFraction ${l}`),$(c>=0&&c<=1,()=>`Progress fraction must be in range [0, 1], but got endFraction ${c}`),$(c>=l,()=>`startFraction must be no more than endFraction, but got startFraction ${l} and endFraction ${c}`)}return Promise.all(e.map(a))}async function _b(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 Db(s,t.onProgress,r,a)).map(d=>d.arrayBuffer()),l=.5,c=1;return t.onProgress==null?await Promise.all(i):await Db(i,t.onProgress,l,c)}async function uN(e,t="",n,s){return Fb(o=>_b(o,{requestInit:s}))(e,t,n)}function Fb(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=Kg[A]*Mt(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),[]),c=[];l.forEach(h=>{t[h].paths.forEach(f=>{let m=n+(n.endsWith("/")?"":"/")+f;c.push(m)})});let u=await e(c),d={},p=0;return l.forEach(h=>{let f=t[h].paths.length,m=0;for(let b=0;b<f;b++)m+=u[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(u[p+b]);A.set(v,y),y+=v.byteLength}a[h].forEach(b=>{let v=g.slice(b.groupOffset,b.groupOffset+b.sizeBytes),S=yb(v,[b.manifestEntry]);for(let T in S)d[T]=S[T]}),p+=f}),d}}var cN="application/octet-stream",dN="application/json",sA=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?($(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,$(e!=null&&e.length>0,()=>"URL path for http must not be null, undefined or empty."),Array.isArray(e)&&$(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=vb(e,n);t.body.append("model.json",new Blob([JSON.stringify(s)],{type:dN}),"model.json"),e.weightData!=null&&t.body.append("model.weights.bin",new Blob([e.weightData],{type:cN}),"model.weights.bin");let r=await this.fetch(this.path,t);if(r.ok)return{modelArtifactsInfo:Wc(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{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 Jg(t,r=>this.loadWeights(r))}async loadWeights(e){let t=Array.isArray(this.path)?this.path[1]:this.path,[n,s]=pN(t),r=this.weightPathPrefix||n,a=[];for(let c of e)a.push(...c.weights);let o=[],i=[];for(let c of e)for(let u of c.paths)this.weightUrlConverter!=null?i.push(this.weightUrlConverter(u)):o.push(r+u+s);this.weightUrlConverter&&o.push(...await Promise.all(i));let l=await _b(o,{requestInit:this.requestInit,fetchFunc:this.fetch,onProgress:this.onProgress});return[a,Yg(l)]}};sA.URL_SCHEME_REGEX=/^https?:\/\//;function pN(e){let t=e.lastIndexOf("/"),n=e.lastIndexOf("?"),s=e.substring(0,t),r=n>t?e.substring(n):"";return[s+"/",r]}function rA(e){return e.match(sA.URL_SCHEME_REGEX)!=null}var $b=(e,t)=>{if(typeof fetch=="undefined"&&(t==null||t.fetchFunc==null))return null;{let n=!0;if(Array.isArray(e)?n=e.every(s=>rA(s)):n=rA(e),n)return aA(e,t)}return null};Pt.registerSaveRouter($b);Pt.registerLoadRouter($b);function aA(e,t){return new sA(e,t)}function hN(e,t){return aA(e,t)}var oA=class{constructor(e){this.modelArtifacts=e}async load(){return this.modelArtifacts}},fN=class{constructor(e){this.saveHandler=e}async save(e){return this.saveHandler(e)}};function mN(e,t,n,s){return arguments.length===1?e.modelTopology!=null||e.weightSpecs!=null?new oA(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 oA({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 oA({modelTopology:e,weightSpecs:t,weightData:n,trainingConfig:s}))}function gN(e){return new fN(e)}var Ob={};ze(Ob,{confusionMatrix:()=>vN});function AN(e,t,n=!1,s=!1){let r=R(e,"a","matMul"),a=R(t,"b","matMul");[r,a]=Dt(r,a);let o={a:r,b:a},i={transposeA:n,transposeB:s};return B.runKernel(Ja,o,i)}var Ve=W({matMul_:AN});function yN(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:R(e,"indices","oneHot","int32")},o={depth:t,onValue:n,offValue:s};return B.runKernel(Co,a,o)}var Ql=W({oneHot_:yN});function xN(e,t){let n=R(e,"x","transpose");if(t==null&&(t=n.shape.map((a,o)=>o).reverse()),$(n.rank===t.length,()=>`Error in transpose: rank of input ${n.rank} must match length of perm ${t}.`),t.forEach(a=>{$(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 B.runKernel(Ho,s,r)}var Ke=W({transpose_:xN});function bN(e,t,n){let s=R(e,"labels","confusionMatrix"),r=R(t,"predictions","confusionMatrix");$(n==null||n>0&&Number.isInteger(n),()=>`If provided, numClasses must be a positive integer, but got ${n}`),$(s.rank===1,()=>`Expected the rank of labels to be 1, but got ${s.rank}`),$(r.rank===1,()=>`Expected the rank of predictions to be 1, but got ${r.rank}`),$(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.`),$(n>0&&Number.isInteger(n),()=>`numClasses is required to be a positive integer, but got ${n}`);let a=Ql(de(s,"int32"),n),o=Ql(de(r,"int32"),n),i=Ke(a),l=Ve(i,o);return de(l,"int32")}var vN=W({confusionMatrix_:bN}),Os={};ze(Os,{fromPixels:()=>NN,fromPixelsAsync:()=>CN,toPixels:()=>TN});function Pb(e,t,n){if(qa(e),t!=null&&t.length!==3)throw new Error("tensor3d() requires shape to have three numbers");let s=mr(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 ma(e,t,s,n)}var eu;function Mb(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(kh(wh,B.backendName)!=null){let f={pixels:e},m={numChannels:t};return B.runKernel(wh,f,m)}let[c,u]=r?[e.videoWidth,e.videoHeight]:[e.width,e.height],d;o?d=e.getContext("2d").getImageData(0,0,c,u).data:s||n?d=e.data:(a||r||i)&&(eu==null&&(eu=document.createElement("canvas").getContext("2d")),eu.canvas.width=c,eu.canvas.height=u,eu.drawImage(e,0,0,c,u),d=eu.getImageData(0,0,c,u).data);let p;if(t===4)p=new Int32Array(d);else{let f=c*u;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 Pb(p,[u,c,t],"int32")}function wN(e){return e!=null&&e.data instanceof Uint8Array}function kN(){return typeof window!="undefined"&&typeof ImageBitmap!="undefined"&&window.hasOwnProperty("createImageBitmap")}function IN(e){return e!=null&&e.width!==0&&e.height!==0}function SN(e){return kN()&&!(e instanceof ImageBitmap)&&IN(e)&&!wN(e)}async function CN(e,t=3){let n=null;if(Y().getBool("WRAP_TO_IMAGEBITMAP")&&SN(e)){let s;try{s=await createImageBitmap(e,{premultiplyAlpha:"none"})}catch{s=null}s!=null&&s.width===e.width&&s.height===e.height?n=s:n=e}else n=e;return Mb(n,t)}async function TN(e,t){let n=R(e,"img","toPixels");if(!(e instanceof Ge)){let c=n;n=de(c,"int32"),c.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 c=0;c<s*r;++c){let u=[0,0,0,255];for(let p=0;p<a;p++){let h=o[c*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?(u[0]=h*i,u[1]=h*i,u[2]=h*i):u[p]=h*i}let d=c*4;l[d+0]=Math.round(u[0]),l[d+1]=Math.round(u[1]),l[d+2]=Math.round(u[2]),l[d+3]=Math.round(u[3])}if(t!=null){t.width=r,t.height=s;let c=t.getContext("2d"),u=new ImageData(l,r,s);c.putImageData(u,0,0)}return n!==e&&n.dispose(),l}var NN=W({fromPixels_:Mb}),iA={};ze(iA,{prepareAndValidate:()=>zb});function zb(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(Mt(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 c=1;for(let d=a;d<n;++d)c*=i[d],l.push(i[d]);let u=[...Hi(e.shape).map(d=>d/c),1].slice(0,a);return[l,o,c,u]}var lA={};ze(lA,{calculateShapes:()=>Lb,validateInput:()=>cA,validateUpdateShape:()=>uA});function uA(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 cA(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}`)}uA(n,t,e)}function Lb(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=Mt(t.shape)/i,c=[...Hi(n.slice(0,r)),1],u=Mt(n);return{sliceRank:r,numUpdates:l,sliceSize:o,strides:c,outputSize:u}}var En={};ze(En,{assertParamsValid:()=>EN,computeFlatOffset:()=>DN,computeOutShape:()=>Bb,getNormalizedAxes:()=>Gb,isSliceContinous:()=>RN,maskToAxes:()=>Dh,parseSliceParams:()=>Zb,sliceInfo:()=>_N,startForAxis:()=>Xb,startIndicesWithElidedDims:()=>Hb,stopForAxis:()=>Kb,stopIndicesWithElidedDims:()=>jb,stridesForAxis:()=>qb,stridesWithElidedDims:()=>Wb});function EN(e,t,n){let s=e.shape.length;$(s===t.length,()=>`Error in slice${s}D: Length of begin ${t} must match the rank of the array (${s}).`),$(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)$(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 Dh(e){let t=[],n=0;for(;e>0;)e&1&&t.push(n),e/=2,n++;return t}function Bb(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 Wb(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 Vb(e,t,n){return n<=e?n:n-(t-1)}function Ub(e,t){let n=[];for(let s=0;s<e;s++)n.push(t+s);return n}function Gb(e,t,n,s,r,a,o,i,l){let c=e.length,u=new Array(c),d=new Array(c),p=new Array(c);if(t.length&&n>0){let h=t[0],f=n+1;u=Hb(o,h,f,s,e),d=jb(i,h,f,r,e),p=Wb(a,h,f,e)}else for(let h=0;h<c;h++)u[h]=Xb(o,s,a,e,h,l),d[h]=Kb(i,r,a,e,h,l),p[h]=qb(a,h,l);return{begin:u,end:d,strides:p}}function Hb(e,t,n,s,r){let a=[...r],o=Ub(n,t);for(let i=0;i<a.length;i++)if(o.indexOf(i)>-1)a[i]=0;else{let l=Vb(t,n,i),c=s[l];e&1<<l&&(c=0),a[i]=c}return a}function jb(e,t,n,s,r){let a=[...r],o=Ub(n,t);for(let i=0;i<a.length;i++)if(o.indexOf(i)>-1)a[i]=Number.MAX_SAFE_INTEGER;else{let l=Vb(t,n,i),c=s[l];e&1<<l&&(c=Number.MAX_SAFE_INTEGER),a[i]=c}for(let i=0;i<a.length;i++){let l=r[i];a[i]<0&&(a[i]+=l),a[i]=fc(0,a[i],r[i])}return a}function qb(e,t,n){let s=e[t];return(n&1<<t||s==null)&&(s=1),s}function Xb(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=fc(0,o,l-1),o}function Kb(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=fc(0,o,l):o=fc(-1,o,l-1),o}function RN(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 DN(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 Zb(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=>{$(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:($(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 _N(e,t,n,s,r,a,o,i,l){let c=t.slice(),u=n.slice(),d=s;s==null&&(d=new Array(c.length));let p=Dh(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-c.length,f=Dh(i),m=e.slice();f.forEach(T=>{c[T]=0,u[T]=1,m.splice(T,0,1)});let{begin:g,end:A,strides:y}=Gb(m,p,h,c,u,d,r,a,o);c=g,u=A,d=y;let x=Dh(l);x.forEach(T=>{u[T]=c[T]+1,d[T]=1});let b=Bb(c,u,d),v=b.filter((T,_)=>x.indexOf(_)===-1);return{nonStrided:d.every(T=>T===1),$begin:c,$end:u,$strides:d,size:b,newShape:m,outShape:v}}var ue={};ze(ue,{Serializable:()=>Yb,SerializationMap:()=>ei,registerClass:()=>Aa});var Yb=class{getClassName(){return this.constructor.className}static fromConfig(e,t){return new e(t)}},ei=class{constructor(){this.classNameMap={}}static getMap(){return ei.instance==null&&(ei.instance=new ei),ei.instance}static register(e){ei.getMap().classNameMap[e.className]=[e,e.fromConfig]}};function Aa(e){$(e.className!=null,()=>"Class being registered does not have the static className property defined."),$(typeof e.className=="string",()=>"className is required to be a string, but got type "+typeof e.className),$(e.className.length>0,()=>"Class being registered has an empty-string as its className, which is disallowed."),ei.register(e)}var Jb={};ze(Jb,{TEST_EPSILON_FLOAT16:()=>Qb,encodeStrings:()=>e3,expectArrayBuffersEqual:()=>LN,expectArraysClose:()=>$N,expectArraysEqual:()=>PN,expectNumbersClose:()=>MN,expectPromiseToFail:()=>ON,expectValuesInRange:()=>zN,testEpsilon:()=>dA});var FN=.001,Qb=.1;function $N(e,t,n){return n==null&&(n=dA()),pA(e,t,(s,r)=>hA(s,r,n))}function dA(){return B.backend.floatPrecision()===32?FN:Qb}function pA(e,t,n){let s=!0;if((kn(e)||kn(t))&&(s=!1),kn(e)&&kn(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=mr(e),i=mr(t);if(!$r(o,i))throw new Error(`Arrays have different shapes. Actual: [${o}]. Expected: [${i}]`)}let r=kn(e)?e:Xa(e),a=kn(t)?t:Xa(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 ON(e,t){e().then(()=>t.fail(),()=>t())}function PN(e,t){let n=typeof t=="string"||typeof t=="number"||typeof t=="boolean"?[t]:t;return oa(e)||oa(e[0])||oa(t)||oa(t[0])?pA(e,n,(s,r)=>s==r):pA(e,t,(s,r)=>hA(s,r,0))}function MN(e,t,n){if(n==null&&(n=dA()),!hA(e,t,n))throw new Error(`Numbers differ: actual === ${e}, expected === ${t}`)}function hA(e,t,n){return!isFinite(e)&&!isFinite(t)?!0:!(isNaN(e)||isNaN(t)||Math.abs(e-t)>n)}function zN(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 LN(e,t){expect(new Float32Array(e)).toEqual(new Float32Array(t))}function e3(e){for(let t=0;t<e.length;t++){let n=e[t];Array.isArray(n)?e3(n):e[t]=Fc(n)}return e}var Vc="3.10.0";function t3(){Y().set("PROD",!0)}function BN(){Y().set("DEBUG",!0)}function WN(){Y().set("DEPRECATION_WARNINGS_ENABLED",!1),console.warn("TensorFlow.js deprecation warnings have been disabled.")}function fA(e){Y().getBool("DEPRECATION_WARNINGS_ENABLED")&&console.warn(e+" You can disable deprecation warnings with tf.disableDeprecationWarnings().")}h9(fA);function VN(){B.disposeVariables()}function ts(){return B}function _h(){return B.memory()}function UN(e){return B.profile(e)}function G(e,t){return B.tidy(e,t)}function Z(e){jg(e).forEach(n=>n.dispose())}function an(e){return B.keep(e)}function GN(e){return B.time(e)}function n3(e){return B.setBackend(e)}function Fh(){return B.ready()}function Ks(){return B.backendName}function HN(e){B.removeBackend(e)}function mA(e){return B.findBackend(e)}function jN(e){return B.findBackendFactory(e)}function tu(e,t,n=1){return B.registerBackend(e,t,n)}function gr(){return B.backend}function qN(e,t){Y().setPlatform(e,t)}function XN(e,t){let n=R(e,"a","add"),s=R(t,"b","add");[n,s]=Dt(n,s);let r={a:n,b:s};return B.runKernel(la,r)}var le=W({add_:XN});function KN(e,t){let n=R(e,"a","floorDiv"),s=R(t,"b","floorDiv");[n,s]=Dt(n,s);let r={a:n,b:s};return B.runKernel(po,r)}var $h=W({floorDiv_:KN});function ZN(e,t){let n=R(e,"a","div"),s=R(t,"b","div");if([n,s]=Dt(n,s),n.dtype==="int32"&&s.dtype==="int32")return $h(n,s);let r={a:n,b:s},a={};return B.runKernel(io,r,a)}var fe=W({div_:ZN});function YN(e,t){let n=R(e,"a","mul"),s=R(t,"b","mul");[n,s]=Dt(n,s);let r={a:n,b:s};return B.runKernel(So,r)}var L=W({mul_:YN});function JN(e){let t=R(e,"x","abs");if(t.dtype==="complex64"){let n={x:t};return B.runKernel(yc,n)}else{let n={x:t};return B.runKernel(qi,n)}}var Vt=W({abs_:JN});function QN(e){let n={x:R(e,"x","acos")};return B.runKernel(Xi,n)}var gA=W({acos_:QN});function eE(e){let n={x:R(e,"x","acosh")};return B.runKernel(Ki,n)}var AA=W({acosh_:eE});function tE(e){$(Array.isArray(e),()=>"The argument passed to tf.addN() must be a list of tensors"),$(e.length>=1,()=>`Must pass at least one tensor to tf.addN(), but got ${e.length}`);let t=e.map((r,a)=>R(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(!$r(r.shape,n.shape))throw new Error("All tensors passed to tf.addN() must have the same shape")});let s=t;return B.runKernel(Ka,s)}var Oh=W({addN_:tE});function nE(e,t=null,n=!1){let r={x:R(e,"x","all","bool")},a={axis:t,keepDims:n};return B.runKernel(Zi,r,a)}var Ph=W({all_:nE});function sE(e,t=null,n=!1){let r={x:R(e,"x","any","bool")},a={axis:t,keepDims:n};return B.runKernel(Yi,r,a)}var Uc=W({any_:sE});function rE(e,t=0){let s={x:R(e,"x","argMax")},r={axis:t};return B.runKernel(Za,s,r)}var xs=W({argMax_:rE});function aE(e,t=0){let s={x:R(e,"x","argMin")},r={axis:t};return B.runKernel(gc,s,r)}var yA=W({argMin_:aE});function oE(e){let n={x:R(e,"x","asin")};return B.runKernel(Ji,n)}var xA=W({asin_:oE});function iE(e){let n={x:R(e,"x","asinh")};return B.runKernel(Qi,n)}var bA=W({asinh_:iE});function lE(e){let n={x:R(e,"x","atan")};return B.runKernel(el,n)}var vA=W({atan_:lE});function uE(e,t){let n=R(e,"a","atan2"),s=R(t,"b","atan2");[n,s]=Dt(n,s);let r={a:n,b:s};return B.runKernel(nl,r)}var wA=W({atan2_:uE});function cE(e){let n={x:R(e,"x","atanh")};return B.runKernel(tl,n)}var kA=W({atanh_:cE});function dE(e,t,n,s,r="NHWC",a){let o=e[3],i=[...t,o],l=a3(r);return Gc(e,i,n,a,s,null,null,l)}function s3(e,t,n,s,r,a,o="channelsLast"){let[i,l]=Mh(t),c;if(o==="channelsLast")c=[i,l,e[3],e[3]];else if(o==="channelsFirst")c=[i,l,e[1],e[1]];else throw new Error(`Unknown dataFormat ${o}`);return Gc(e,c,n,s,r,a,!1,o)}function pE(e,t,n,s,r,a,o="NDHWC"){let[i,l,c]=SA(t),u,d;if(o==="NDHWC")d="channelsLast",u=[i,l,c,e[4],e[4]];else if(o==="NCDHW")d="channelsFirst",u=[i,l,c,e[1],e[1]];else throw new Error(`Unknown dataFormat ${o}`);return r3(e,u,n,s,r,!1,d,a)}function Gc(e,t,n,s,r,a,o=!1,i="channelsLast"){let[l,c,u,d]=[-1,-1,-1,-1];if(i==="channelsLast")[l,c,u,d]=e;else if(i==="channelsFirst")[l,d,c,u]=e;else throw new Error(`Unknown dataFormat ${i}`);let[p,h,,f]=t,[m,g]=Mh(n),[A,y]=Mh(s),x=nu(p,A),b=nu(h,y),{padInfo:v,outHeight:S,outWidth:T}=mE(r,c,u,m,g,x,b,a,i),_=o?f*d:f,O;return i==="channelsFirst"?O=[l,_,S,T]:i==="channelsLast"&&(O=[l,S,T,_]),{batchSize:l,dataFormat:i,inHeight:c,inWidth:u,inChannels:d,outHeight:S,outWidth:T,outChannels:_,padInfo:v,strideHeight:m,strideWidth:g,filterHeight:p,filterWidth:h,effectiveFilterHeight:x,effectiveFilterWidth:b,dilationHeight:A,dilationWidth:y,inShape:e,outShape:O,filterShape:t}}function r3(e,t,n,s,r,a=!1,o="channelsLast",i){let[l,c,u,d,p]=[-1,-1,-1,-1,-1];if(o==="channelsLast")[l,c,u,d,p]=e;else if(o==="channelsFirst")[l,p,c,u,d]=e;else throw new Error(`Unknown dataFormat ${o}`);let[h,f,m,,g]=t,[A,y,x]=SA(n),[b,v,S]=SA(s),T=nu(h,b),_=nu(f,v),O=nu(m,S),{padInfo:P,outDepth:D,outHeight:F,outWidth:C}=gE(r,c,u,d,A,y,x,T,_,O,i),M=a?g*p:g,U;return o==="channelsFirst"?U=[l,M,D,F,C]:o==="channelsLast"&&(U=[l,D,F,C,M]),{batchSize:l,dataFormat:o,inDepth:c,inHeight:u,inWidth:d,inChannels:p,outDepth:D,outHeight:F,outWidth:C,outChannels:M,padInfo:P,strideDepth:A,strideHeight:y,strideWidth:x,filterDepth:h,filterHeight:f,filterWidth:m,effectiveFilterDepth:T,effectiveFilterHeight:_,effectiveFilterWidth:O,dilationDepth:b,dilationHeight:v,dilationWidth:S,inShape:e,outShape:U,filterShape:t}}function hE(e,t,n,s,r){s==null&&(s=IA(e,t,n));let a=e[0],o=e[1],i=ti((a-t+2*s)/n+1,r),l=ti((o-t+2*s)/n+1,r);return[i,l]}function fE(e,t,n,s,r,a){r==null&&(r=IA(e,t,s));let o=e[0],i=e[1],l=e[2],c=ti((o-t+2*r)/s+1,a),u=ti((i-t+2*r)/s+1,a),d=ti((l-t+2*r)/s+1,a);return[c,u,d,n]}function IA(e,t,n,s=1){let r=nu(t,s);return Math.floor((e[0]*(n-1)-n+r)/2)}function Mh(e){return typeof e=="number"?[e,e,e]:e.length===2?[e[0],e[1],1]:e}function SA(e){return typeof e=="number"?[e,e,e]:e}function nu(e,t){return t<=1?e:e+(e-1)*(t-1)}function mE(e,t,n,s,r,a,o,i,l){let c,u,d;if(typeof e=="number"){c={top:e,bottom:e,left:e,right:e,type:e===0?"VALID":"NUMBER"};let h=hE([t,n],a,s,e,i);u=h[0],d=h[1]}else if(e==="same"){u=Math.ceil(t/s),d=Math.ceil(n/r);let p=Math.max(0,(u-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;c={top:f,bottom:m,left:g,right:A,type:"SAME"}}else if(e==="valid")c={top:0,bottom:0,left:0,right:0,type:"VALID"},u=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];c={top:p,bottom:h,left:f,right:m,type:p===0&&h===0&&f===0&&m===0?"VALID":"EXPLICIT"},u=ti((t-a+p+h)/s+1,i),d=ti((n-o+f+m)/r+1,i)}else throw Error(`Unknown padding parameter: ${e}`);return{padInfo:c,outHeight:u,outWidth:d}}function gE(e,t,n,s,r,a,o,i,l,c,u){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=fE([t,n,s,1],i,1,r,e,u);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+c-s,y=Math.floor(m/2),x=m-y,b=Math.floor(g/2),v=g-b,S=Math.floor(A/2),T=A-S;d={top:b,bottom:v,left:S,right:T,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-c+1)/o);else throw Error(`Unknown padding parameter: ${e}`);return{padInfo:d,outDepth:p,outHeight:h,outWidth:f}}function ti(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 ya(e){let[t,n,s]=Mh(e);return t===1&&n===1&&s===1}function Ar(e,t){return ya(e)||ya(t)}function a3(e){if(e==="NHWC")return"channelsLast";if(e==="NCHW")return"channelsFirst";throw new Error(`Unknown dataFormat ${e}`)}function AE(e,t){let s={x:R(e,"x","reshape","string_or_numeric")},r={shape:t};return B.runKernel(_l,s,r)}var V=W({reshape_:AE});function yE(e,t,n,s,r){let a=R(e,"x","avgPool","float32"),o=1;$(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]])),$(i.rank===4,()=>`Error in avgPool: x must be rank 4 but got rank ${i.rank}.`),r!=null&&$(sn(s),()=>`Error in avgPool: pad must be an integer when using, dimRoundingMode ${r} but got pad ${s}.`);let c={x:i},u={filterSize:t,strides:n,pad:s,dimRoundingMode:r},d=B.runKernel(Ya,c,u);return d=de(d,a.dtype),l?V(d,[d.shape[1],d.shape[2],d.shape[3]]):d}var Hc=W({avgPool_:yE});function xE(e,t,n,s,r,a="NDHWC"){let o=R(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]])),$(i.rank===5,()=>`Error in avgPool3d: x must be rank 5 but got rank ${i.rank}.`),$(a==="NDHWC",()=>`Error in avgPool3d: Only NDHWC is currently supported, but got dataFormat of ${a}`),r!=null&&$(sn(s),()=>`Error in avgPool3d: pad must be an integer when using, dimRoundingMode ${r} but got pad ${s}.`);let c={x:i},u={filterSize:t,strides:n,pad:s,dimRoundingMode:r,dataFormat:a},d=B.runKernel(Ac,c,u);return d=de(d,i.dtype),l?V(d,[d.shape[1],d.shape[2],d.shape[3],d.shape[4]]):d}var CA=W({avgPool3d_:xE});function bE(e,t=0){$(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 Xs(n[0]);let s=n,r={axis:t};return B.runKernel(rl,s,r)}var mt=W({concat_:bE});function vE(e){let n={x:R(e,"x","sigmoid","float32")};return B.runKernel(Mo,n)}var Hn=W({sigmoid_:vE});function wE(e,t,n){let s=R(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 B.runKernel(Pl,r,a)}var Fe=W({slice_:wE});function kE(e){let n={x:R(e,"x","tanh","float32")};return B.runKernel(Go,n)}var ni=W({tanh_:kE});function IE(e,t,n,s,r,a){let o=R(e,"forgetBias","basicLSTMCell"),i=R(t,"lstmKernel","basicLSTMCell"),l=R(n,"lstmBias","basicLSTMCell"),c=R(s,"data","basicLSTMCell"),u=R(r,"c","basicLSTMCell"),d=R(a,"h","basicLSTMCell"),p=mt([c,d],1),h=Ve(p,i),f=le(h,l),m=f.shape[0],g=f.shape[1]/4,A=[m,g],y=Fe(f,[0,0],A),x=Fe(f,[0,g],A),b=Fe(f,[0,g*2],A),v=Fe(f,[0,g*3],A),S=le(L(Hn(y),ni(x)),L(u,Hn(le(o,b)))),T=L(ni(S),Hn(v));return[S,T]}var SE=W({basicLSTMCell_:IE});function CE(e,t,n){let s=R(e,"x","batchToSpaceND"),r=t.reduce((i,l)=>i*l);$(s.rank>=1+t.length,()=>`input rank is ${s.rank} but should be > than blockShape.length ${t.length}`),$(n.length===t.length,()=>`crops.length is ${n.length} but should be equal to blockShape.length ${t.length}`),$(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 B.runKernel(sl,a,o)}var jc=W({batchToSpaceND_:CE});function TE(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 NE(e,t,n,s,r,a){a==null&&(a=.001);let o=R(e,"x","batchNorm"),i=R(t,"mean","batchNorm"),l=R(n,"variance","batchNorm"),c;r!=null&&(c=R(r,"scale","batchNorm"));let u;s!=null&&(u=R(s,"offset","batchNorm")),$(i.rank===l.rank,()=>"Batch normalization gradient requires mean and variance to have equal ranks."),$(u==null||i.rank===u.rank,()=>"Batch normalization gradient requires mean and offset to have equal ranks."),$(c==null||i.rank===c.rank,()=>"Batch normalization gradient requires mean and scale to have equal ranks.");let p={x:TE(o),scale:c,offset:u,mean:i,variance:l},h={varianceEpsilon:a},f=B.runKernel(ho,p,h);return V(f,o.shape)}var si=W({batchNorm_:NE});function EE(e,t,n,s,r,a){let o=R(e,"x","batchNorm"),i=R(t,"mean","batchNorm"),l=R(n,"variance","batchNorm"),c;r!=null&&(c=R(r,"scale","batchNorm"));let u;return s!=null&&(u=R(s,"offset","batchNorm")),$(o.rank===2,()=>`Error in batchNorm2D: x must be rank 2 but got rank ${o.rank}.`),$(i.rank===2||i.rank===1,()=>`Error in batchNorm2D: mean must be rank 2 or rank 1 but got rank ${i.rank}.`),$(l.rank===2||l.rank===1,()=>`Error in batchNorm2D: variance must be rank 2 or rank 1 but got rank ${l.rank}.`),c!=null&&$(c.rank===2||c.rank===1,()=>`Error in batchNorm2D: scale must be rank 2 or rank 1 but got rank ${c.rank}.`),u!=null&&$(u.rank===2||u.rank===1,()=>`Error in batchNorm2D: offset must be rank 2 or rank 1 but got rank ${u.rank}.`),si(o,i,l,u,c,a)}var o3=W({batchNorm2d_:EE});function RE(e,t,n,s,r,a){let o=R(e,"x","batchNorm"),i=R(t,"mean","batchNorm"),l=R(n,"variance","batchNorm"),c;r!=null&&(c=R(r,"scale","batchNorm"));let u;return s!=null&&(u=R(s,"offset","batchNorm")),$(o.rank===3,()=>`Error in batchNorm3D: x must be rank 3 but got rank ${o.rank}.`),$(i.rank===3||i.rank===1,()=>`Error in batchNorm3D: mean must be rank 3 or rank 1 but got rank ${i.rank}.`),$(l.rank===3||l.rank===1,()=>`Error in batchNorm3D: variance must be rank 3 or rank 1 but got rank ${l.rank}.`),c!=null&&$(c.rank===3||c.rank===1,()=>`Error in batchNorm3D: scale must be rank 3 or rank 1 but got rank ${c.rank}.`),u!=null&&$(u.rank===3||u.rank===1,()=>`Error in batchNorm3D: offset must be rank 3 or rank 1 but got rank ${u.rank}.`),si(o,i,l,u,c,a)}var i3=W({batchNorm3d_:RE});function DE(e,t,n,s,r,a){let o=R(e,"x","batchNorm"),i=R(t,"mean","batchNorm"),l=R(n,"variance","batchNorm"),c;r!=null&&(c=R(r,"scale","batchNorm"));let u;return s!=null&&(u=R(s,"offset","batchNorm")),$(o.rank===4,()=>`Error in batchNorm4D: x must be rank 4 but got rank ${o.rank}.`),$(i.rank===4||i.rank===1,()=>`Error in batchNorm4D: mean must be rank 4 or rank 1 but got rank ${i.rank}.`),$(l.rank===4||l.rank===1,()=>`Error in batchNorm4D: variance must be rank 4 or rank 1 but got rank ${l.rank}.`),c!=null&&$(c.rank===4||c.rank===1,()=>`Error in batchNorm4D: scale must be rank 4 or rank 1 but got rank ${c.rank}.`),u!=null&&$(u.rank===4||u.rank===1,()=>`Error in batchNorm4D: offset must be rank 4 or rank 1 but got rank ${u.rank}.`),si(o,i,l,u,c,a)}var l3=W({batchNorm4d_:DE});function _E(e,t,n){let s=R(e,"x","bincount"),r=R(t,"weights","bincount");$(s.dtype==="int32",()=>`Error in bincount: input dtype must be int32, but got ${s.dtype}`),$(n>=0,()=>`size must be non-negative, but got ${n}.`),$(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 B.runKernel(Wp,a,o)}var TA=W({bincount_:_E});function FE(e,t){let n=R(e,"s0","broadcastArgs","int32"),s=R(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 B.runKernel(Vp,r)}var u3=W({broadcastArgs_:FE});function $E(e,t){let n=R(e,"broadcastTo","x"),s=n.shape;if(t.some(c=>!(c>0)||c%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 c=n.shape.slice();for(;c.length<t.length;)c.unshift(1);n=V(n,c)}let r=n.shape,a=Array.from(t);for(let c=t.length-1;c>=0;c--)if(r[c]===t[c])a[c]=1;else if(n.shape[c]!==1)throw new Error(`broadcastTo(): [${s}] cannot be broadcast to [${t}].`);if(a.map((c,u)=>c>1?u:-1).filter(c=>c>=0).length===0)return Xs(n);let i={x:n},l={reps:a};return B.runKernel(ca,i,l)}var su=W({broadcastTo_:$E});function OE(e){let n={x:R(e,"x","ceil","float32")};return B.runKernel(eo,n)}var NA=W({ceil_:OE});function PE(e,t,n){let s=R(e,"x","clipByValue");$(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 B.runKernel(ua,r,a)}var jn=W({clipByValue_:PE});function ME(e){return mt(e,0)}var c3=W({concat1d_:ME});function zE(e,t){return mt(e,t)}var ru=W({concat2d_:zE});function LE(e,t){return mt(e,t)}var d3=W({concat3d_:LE});function BE(e,t){return mt(e,t)}var p3=W({concat4d_:BE});function WE(e,t,n,s,r="NHWC",a=[1,1],o){let i=R(e,"x","conv2d","float32"),l=R(t,"filter","conv2d","float32"),c=i,u=!1;i.rank===3&&(u=!0,c=V(i,[1,i.shape[0],i.shape[1],i.shape[2]])),$(c.rank===4,()=>`Error in conv2d: input must be rank 4, but got rank ${c.rank}.`),$(l.rank===4,()=>`Error in conv2d: filter must be rank 4, but got rank ${l.rank}.`),o!=null&&$(sn(s),()=>`Error in conv2d: pad must be an integer when using, dimRoundingMode ${o} but got pad ${s}.`);let d=r==="NHWC"?c.shape[3]:c.shape[1];$(d===l.shape[2],()=>`Error in conv2d: depth of input (${d}) must match input depth for filter ${l.shape[2]}.`),$(Ar(n,a),()=>`Error in conv2D: Either strides or dilations must be 1. Got strides ${n} and dilations '${a}'`);let p={x:c,filter:l},h={strides:n,pad:s,dataFormat:r,dilations:a,dimRoundingMode:o},f=B.runKernel(to,p,h);return u?V(f,[f.shape[1],f.shape[2],f.shape[3]]):f}var Mr=W({conv2d_:WE});function VE(e,t,n,s,r="NWC",a=1,o){let i=R(e,"x","conv1d"),l=R(t,"filter","conv1d"),c=i,u=!1;i.rank===2&&(u=!0,c=V(i,[1,i.shape[0],i.shape[1]])),$(c.rank===3,()=>`Error in conv1d: input must be rank 3, but got rank ${c.rank}.`),$(l.rank===3,()=>`Error in conv1d: filter must be rank 3, but got rank ${l.rank}.`),o!=null&&$(sn(s),()=>`Error in conv1d: pad must be an integer when using, dimRoundingMode ${o} but got pad ${s}.`),$(c.shape[2]===l.shape[1],()=>`Error in conv1d: depth of input (${c.shape[2]}) must match input depth for filter ${l.shape[1]}.`),$(Ar(n,a),()=>`Error in conv1D: Either stride or dilation must be 1. Got stride ${n} and dilation '${a}'`),$(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(c,[c.shape[0],1,c.shape[1],c.shape[2]]),g=Mr(p,d,[1,n],s,"NHWC",[1,a],o);return u?V(g,[g.shape[2],g.shape[3]]):V(g,[g.shape[0],g.shape[2],g.shape[3]])}var zh=W({conv1d_:VE});function UE(e,t,n,s,r,a="NHWC",o){$(e.length===t.rank,()=>`Length of inShape (${e.length}) and rank of dy (${t.rank}) must match`);let i=e,l=t,c=!1;t.rank===3&&(c=!0,l=V(t,[1,t.shape[0],t.shape[1],t.shape[2]]),i=[1,e[0],e[1],e[2]]),$(i.length===4,()=>`Error in conv2dDerInput: inShape must be length 4, but got length ${i.length}.`),$(l.rank===4,()=>`Error in conv2dDerInput: dy must be rank 4, but got rank ${l.rank}`),$(n.rank===4,()=>`Error in conv2dDerInput: filter must be rank 4, but got rank ${n.rank}`);let u=a==="NHWC"?i[3]:i[1],d=a==="NHWC"?l.shape[3]:l.shape[1];$(u===n.shape[2],()=>`Error in conv2dDerInput: depth of input (${u}) must match input depth for filter ${n.shape[2]}.`),$(d===n.shape[3],()=>`Error in conv2dDerInput: depth of output (${d}) must match output depth for filter ${n.shape[3]}.`),o!=null&&$(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=B.runKernel(no,p,h);return c?V(f,[f.shape[1],f.shape[2],f.shape[3]]):f}var EA=W({conv2DBackpropInput_:UE});function GE(e,t,n,s,r,a){let o=R(e,"x","conv2dTranspose"),i=R(t,"filter","conv2dTranspose");return EA(n,o,i,s,r,"NHWC",a)}var Lh=W({conv2dTranspose_:GE});function HE(e,t,n,s,r="NDHWC",a=[1,1,1]){let o=R(e,"x","conv3d"),i=R(t,"filter","conv3d"),l=o,c=!1;o.rank===4&&(c=!0,l=V(o,[1,o.shape[0],o.shape[1],o.shape[2],o.shape[3]])),$(l.rank===5,()=>`Error in conv3d: input must be rank 5, but got rank ${l.rank}.`),$(i.rank===5,()=>`Error in conv3d: filter must be rank 5, but got rank ${i.rank}.`),$(l.shape[4]===i.shape[3],()=>`Error in conv3d: depth of input (${l.shape[4]}) must match input depth for filter ${i.shape[3]}.`),$(Ar(n,a),()=>`Error in conv3D: Either strides or dilations must be 1. Got strides ${n} and dilations '${a}'`),$(r==="NDHWC",()=>`Error in conv3d: got dataFormat of ${r} but only NDHWC is currently supported.`);let u={x:l,filter:i},d={strides:n,pad:s,dataFormat:r,dilations:a},p=B.runKernel(xc,u,d);return c?V(p,[p.shape[1],p.shape[2],p.shape[3],p.shape[4]]):p}var RA=W({conv3d_:HE});function jE(e,t,n,s,r){$(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],c=o.shape[4];$(a.length===5,()=>`Error in conv3dDerInput: inShape must be length 5, but got length ${a.length}.`),$(o.rank===5,()=>`Error in conv3dDerInput: dy must be rank 5, but got rank ${o.rank}`),$(n.rank===5,()=>`Error in conv3dDerInput: filter must be rank 5, but got rank ${n.rank}`),$(l===n.shape[3],()=>`Error in conv3dDerInput: depth of input (${l}) must match input depth for filter ${n.shape[3]}.`),$(c===n.shape[4],()=>`Error in conv3dDerInput: depth of output (${c}) must match output depth for filter ${n.shape[4]}.`);let u={dy:o,filter:n},d={pad:r,strides:s,inputShape:a},p=B.runKernel(jp,u,d);return i?V(p,[p.shape[1],p.shape[2],p.shape[3],p.shape[4]]):p}var h3=W({conv3DBackpropInput_:jE});function qE(e,t,n,s,r){let a=R(e,"x","conv3dTranspose"),o=R(t,"filter","conv3dTranspose");return h3(n,a,o,s,r)}var f3=W({conv3dTranspose_:qE});function XE(e){let n={x:R(e,"x","cos","float32")};return B.runKernel(so,n)}var qc=W({cos_:XE});function KE(e){let n={x:R(e,"x","cosh","float32")};return B.runKernel(ro,n)}var Bh=W({cosh_:KE});function ZE(e,t=0,n=!1,s=!1){let a={x:R(e,"x","cumsum")},o={axis:t,exclusive:n,reverse:s};return B.runKernel(ao,a,o)}var Wh=W({cumsum_:ZE});function YE(e,t,n,s=!1){let r=R(e,"x","denseBincount"),a=R(t,"weights","denseBincount");$(r.dtype==="int32",()=>`Error in denseBincount: input dtype must be int32, but got ${r.dtype}`),$(r.rank<=2,()=>`Error in denseBincount: input must be at most rank 2, but got rank ${r.rank}.`),$(n>=0,()=>`size must be non-negative, but got ${n}.`),$(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 B.runKernel(qp,o,i)}var m3=W({denseBincount_:YE});function JE(e,t,n="NHWC"){let s=R(e,"x","depthToSpace","float32"),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];$(t>1,()=>`blockSize should be > 1 for depthToSpace, but was: ${t}`),$(r*t>=0,()=>`Negative dimension size caused by overflow when multiplying
|
|
${r} and ${t} for depthToSpace with input shape
|
|
${s.shape}`),$(a*t>=0,()=>`Negative dimension size caused by overflow when multiplying
|
|
${a} and ${t} for depthToSpace with input shape
|
|
${s.shape}`),$(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 B.runKernel(ol,i,l)}var DA=W({depthToSpace_:JE});function QE(e,t,n,s,r="NHWC",a=[1,1],o){let i=R(e,"x","depthwiseConv2d","float32"),l=R(t,"filter","depthwiseConv2d","float32"),c=i,u=!1;i.rank===3&&(u=!0,c=V(i,[1,i.shape[0],i.shape[1],i.shape[2]])),$(c.rank===4,()=>`Error in depthwiseConv2d: input must be rank 4, but got rank ${c.rank}.`),$(l.rank===4,()=>`Error in depthwiseConv2d: filter must be rank 4, but got rank ${l.rank}.`),$(c.shape[3]===l.shape[2],()=>`Error in depthwiseConv2d: number of input channels (${c.shape[3]}) must match the inChannels dimension in filter ${l.shape[2]}.`),o!=null&&$(sn(s),()=>`Error in depthwiseConv2d: pad must be an integer when using, dimRoundingMode ${o} but got pad ${s}.`);let d={x:c,filter:l},p={strides:n,pad:s,dataFormat:r,dilations:a,dimRoundingMode:o},h=B.runKernel(oo,d,p);return u?V(h,[h.shape[1],h.shape[2],h.shape[3]]):h}var au=W({depthwiseConv2d_:QE});function eR(e){let n={x:R(e,"x","diag")};return B.runKernel(Zp,n)}var tR=W({diag_:eR});function nR(e,t,n,s,r=[1,1],a="NHWC"){let o=R(e,"x","dilation2d"),i=R(t,"filter","dilation2d");$(o.rank===3||o.rank===4,()=>`Error in dilation2d: input must be rank 3 or 4, but got rank ${o.rank}.`),$(i.rank===3,()=>`Error in dilation2d: filter must be rank 3, but got rank ${i.rank}.`),$(a==="NHWC",()=>`Error in dilation2d: Only NHWC is currently supported, but got dataFormat of ${a}`);let l=o,c=!1;o.rank===3&&(l=V(o,[1,o.shape[0],o.shape[1],o.shape[2]]),c=!0);let u={x:l,filter:i},d={strides:n,pad:s,dilations:r},p=B.runKernel(bc,u,d);return c?V(p,[p.shape[1],p.shape[2],p.shape[3]]):p}var _A=W({dilation2d_:nR});function sR(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 Yt(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 xt(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 rR(e,t){let n=R(e,"a","equal","string_or_numeric"),s=R(t,"b","equal","string_or_numeric");[n,s]=Dt(n,s),xt(n.shape,s.shape);let r={a:n,b:s};return B.runKernel(ll,r)}var ns=W({equal_:rR});function aR(e,t,n){let s=R(t,"a","where"),r=R(n,"b","where"),a=R(e,"condition","where","bool"),o=xt(xt(a.shape,s.shape),r.shape),i=su(a,o),l=su(s,o),c=su(r,o),u={condition:i,t:l,e:c};return B.runKernel($l,u)}var In=W({where_:aR});function oR(e){let n={x:R(e,"x","zerosLike")};return B.runKernel(jl,n)}var Ze=W({zerosLike_:oR});function iR(e,t){let n=R(e,"a","div"),s=R(t,"b","div");[n,s]=Dt(n,s);let r=fe(n,s),a=Ze(r),o=ns(s,a);return In(o,a,r)}var FA=W({divNoNan_:iR});function lR(e,t){let n=R(e,"t1","dot"),s=R(t,"t2","dot");$((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($(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=Ve(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=Ve(o,i);return V(l,[l.size])}else if(n.rank===2&&s.rank===1){let o=V(s,[-1,1]),i=Ve(n,o);return V(i,[i.size])}else{let o=V(s,[s.shape[0],s.shape[1]]);return Ve(n,o)}}var g3=W({dot_:lR});function uR(e,...t){let n=t.map((r,a)=>R(r,`tensors${a}`,"einsum")),s={equation:e};return B.runKernel(Qp,n,s)}var A3=W({einsum_:uR});function cR(e){let n={x:R(e,"x","elu","float32")};return B.runKernel(lo,n)}var ou=W({elu_:cR});function dR(e){let t=R(e,"x","erf");$(t.dtype==="int32"||t.dtype==="float32",()=>"Input dtype must be `int32` or `float32`."),t.dtype==="int32"&&(t=de(t,"float32"));let n={x:t};return B.runKernel(il,n)}var $A=W({erf_:dR});function pR(e){let n={x:R(e,"x","exp")};return B.runKernel(uo,n)}var ss=W({exp_:pR});function hR(e,t=0){let n=R(e,"x","expandDims","string_or_numeric");$(t<=n.rank,()=>"Axis must be <= rank of the tensor");let s={input:n},r={dim:t};return B.runKernel(ul,s,r)}var Lt=W({expandDims_:hR});function fR(e){let n={x:R(e,"x","expm1")};return B.runKernel(cl,n)}var OA=W({expm1_:fR});function mR(e,t){let n=R(e,"x","tile","string_or_numeric");$(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 B.runKernel(ca,s,r)}var bs=W({tile_:mR});function gR(e,t,n,s="float32"){t==null&&(t=e);let r=He([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 PA=W({eye_:gR});function iu(e,t,n){let s={shape:e,value:t,dtype:n};return B.runKernel(vc,{},s)}function AR(e){let n={x:R(e,"x","floor","float32")};return B.runKernel(co,n)}var lu=W({floor_:AR});function yR(e,t,n=0,s=0){let r=R(e,"x","gather"),a=R(t,"indices","gather","int32"),o={x:r,indices:a},i={axis:n,batchDims:s};return B.runKernel(pl,o,i)}var ri=W({gather_:yR});function xR(e,t){let n=R(e,"a","greater","string_or_numeric"),s=R(t,"b","greater","string_or_numeric");[n,s]=Dt(n,s),xt(n.shape,s.shape);let r={a:n,b:s};return B.runKernel(fl,r)}var qn=W({greater_:xR});function bR(e,t){let n=R(e,"a","greaterEqual","string_or_numeric"),s=R(t,"b","greaterEqual","string_or_numeric");[n,s]=Dt(n,s),xt(n.shape,s.shape);let r={a:n,b:s};return B.runKernel(fo,r)}var xa=W({greaterEqual_:bR});function vR(e){let n={input:R(e,"input","imag")};return B.runKernel(sh,n)}var Vh=W({imag_:vR});function wR(e){let n={x:R(e,"x","isFinite")};return B.runKernel(ml,n)}var y3=W({isFinite_:wR});function kR(e){let n={x:R(e,"x","isInf")};return B.runKernel(gl,n)}var x3=W({isInf_:kR});function IR(e){let n={x:R(e,"x","isNaN")};return B.runKernel(Al,n)}var MA=W({isNaN_:IR});function SR(e,t=.2){let s={x:R(e,"x","leakyRelu")},r={alpha:t};return B.runKernel(go,s,r)}var Xc=W({leakyRelu_:SR});function CR(e,t){let n=R(e,"a","less","string_or_numeric"),s=R(t,"b","less","string_or_numeric");[n,s]=Dt(n,s),xt(n.shape,s.shape);let r={a:n,b:s};return B.runKernel(yl,r)}var Uh=W({less_:CR});function TR(e,t){let n=R(e,"a","lessEqual","string_or_numeric"),s=R(t,"b","lessEqual","string_or_numeric");[n,s]=Dt(n,s),xt(n.shape,s.shape);let r={a:n,b:s};return B.runKernel(xl,r)}var ba=W({lessEqual_:TR});function b3(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 B.runKernel(rh,{},s)}function NR(e,t=5,n=1,s=1,r=.5){let a=R(e,"x","localResponseNormalization");$(a.rank===4||a.rank===3,()=>`Error in localResponseNormalization: x must be rank 3 or 4 but got
|
|
rank ${a.rank}.`),$(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},c={depthRadius:t,bias:n,alpha:s,beta:r},u=B.runKernel(Ic,l,c);return i?V(u,[u.shape[1],u.shape[2],u.shape[3]]):u}var zA=W({localResponseNormalization_:NR});function ER(e){let n={x:R(e,"x","log","float32")};return B.runKernel(Ao,n)}var rs=W({log_:ER});function RR(e){let n={x:R(e,"x","log1p")};return B.runKernel(bl,n)}var Kc=W({log1p_:RR});function DR(e){return $(ia(e),()=>"The f passed in grad(f) must be a function"),(t,n)=>{let s=R(t,"x","tf.grad","string_or_numeric"),r=n!=null?R(n,"dy","tf.grad"):null;return B.tidy(()=>{let{value:a,grads:o}=B.gradients(()=>e(s),[s],r);return r!=null&&Tn(a.shape,r.shape,"The shape of dy passed in grad(f)(x, dy) must match the shape returned by f(x)"),Gh(o),o[0]})}}function _R(e){return $(ia(e),()=>"The f passed in grads(f) must be a function"),(t,n)=>{$(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?R(n,"dy","tf.grads"):null;return B.tidy(()=>{let{value:a,grads:o}=B.gradients(()=>e(...s),s,r);return r!=null&&Tn(a.shape,r.shape,"The shape of dy passed in grads(f)([x1,...], dy) must match the shape returned by f([x1,...])"),Gh(o),o})}}function FR(e){return $(ia(e),()=>"The f passed in valueAndGrad(f) must be a function"),(t,n)=>{$(t instanceof Ge,()=>"The x passed in valueAndGrad(f)(x) must be a tensor"),$(n==null||n instanceof Ge,()=>"The dy passed in valueAndGrad(f)(x, dy) must be a tensor");let{grads:s,value:r}=B.gradients(()=>e(t),[t],n);return Gh(s),{grad:s[0],value:r}}}function $R(e){return $(ia(e),()=>"The f passed in valueAndGrads(f) must be a function"),(t,n)=>{$(Array.isArray(t)&&t.every(r=>r instanceof Ge),()=>"The args passed in valueAndGrads(f)(args) must be array of tensors"),$(n==null||n instanceof Ge,()=>"The dy passed in valueAndGrads(f)(args, dy) must be a tensor");let s=B.gradients(()=>e(...t),t,n);return n!=null&&Tn(s.value.shape,n.shape,"The shape of dy passed in valueAndGrads(f)([x1,...], dy) must match the shape returned by f([x1,...])"),Gh(s.grads),s}}function v3(e,t){$(ia(e),()=>"The f passed in variableGrads(f) must be a function"),$(t==null||Array.isArray(t)&&t.every(c=>c instanceof Mc),()=>"The varList passed in variableGrads(f, varList) must be an array of variables");let n=t!=null;if(!n){t=[];for(let c in B.registeredVariables)t.push(B.registeredVariables[c])}let s=n?t.filter(c=>!c.trainable):null,r=t.length;t=t.filter(c=>c.trainable),$(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}=B.gradients(e,t,null,a);$(i.some(c=>c!=null),()=>"Cannot find a connection between any variable and the result of the loss function y=f(x). Please make sure the operations that use variables are inside the function f passed to minimize()."),$(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((c,u)=>{i[u]!=null&&(l[c.name]=i[u])}),s!=null&&s.forEach(c=>l[c.name]=null),{value:o,grads:l}}function yr(e){return B.customGrad(e)}function Gh(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 OR(e){let n={x:R(e,"x","neg")};return B.runKernel(kl,n)}var Ct=W({neg_:OR});function PR(e){let n={x:R(e,"x","softplus")};return B.runKernel(Ll,n)}var ai=W({softplus_:PR});function MR(e){let t=R(e,"x","logSigmoid");return yr(s=>({value:Ct(ai(Ct(s))),gradFunc:o=>L(o,Hn(Ct(s)))}))(t)}var w3=W({logSigmoid_:MR});function zR(e,t=null,n=!1){let r={x:R(e,"x","max")},a={reductionIndices:t,keepDims:n};return B.runKernel(yo,r,a)}var Rn=W({max_:zR});function LR(e,t){let n=R(e,"a","sub"),s=R(t,"b","sub");[n,s]=Dt(n,s);let r={a:n,b:s};return B.runKernel(Vo,r)}var be=W({sub_:LR});function BR(e,t=null,n=!1){let s=R(e,"x","sum");s.dtype==="bool"&&(s=de(s,"int32"));let r={x:s},a={axis:t,keepDims:n};return B.runKernel(Lo,r,a)}var Ie=W({sum_:BR});function WR(e,t=-1){let n=R(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 yr((r,a)=>{let o=!0,i=Rn(r,t,!0),l=be(r,i),c=be(de(l,"float32"),rs(Ie(ss(l),t,o)));return a([c]),{value:c,gradFunc:(d,p)=>{let[h]=p,f=!0,m=ss(h);return be(d,L(Ie(d,t,f),m))}}})(n)}var Hh=W({logSoftmax_:WR});function LA(e,t){for(let n=0;n<e.length;++n)if(e[e.length-n-1]!==t-1-n)return!1;return!0}function k3(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 I3(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 oi(e,t){let n=t.map(s=>1);return k3(e,n,t)}function VR(e,t,n){$(LA(t,n),()=>`${e} supports only inner-most axes for now. Got axes ${t} and rank-${n} input.`)}function S3(e,t){if(LA(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 BA(e){return e.map((t,n)=>[n,t]).sort((t,n)=>t[1]-n[1]).map(t=>t[0])}function UR(e,t){let n=[];for(let s=t-e;s<t;++s)n.push(s);return n}function GR(e,t=null,n=!1){let s=R(e,"x","logSumExp"),r=Fs(t,s.shape),a=Rn(s,r,!0),o=be(s,a),i=ss(o),l=Ie(i,r),c=rs(l),u=le(V(a,c.shape),c);if(n){let d=oi(u.shape,r);return V(u,d)}return u}var WA=W({logSumExp_:GR});function HR(e,t){let n=R(e,"a","logicalAnd","bool"),s=R(t,"b","logicalAnd","bool");xt(n.shape,s.shape);let r={a:n,b:s};return B.runKernel(vl,r)}var Ps=W({logicalAnd_:HR});function jR(e){let n={x:R(e,"x","logicalNot","bool")};return B.runKernel(wc,n)}var Zc=W({logicalNot_:jR});function qR(e,t){let n=R(e,"a","logicalOr","bool"),s=R(t,"b","logicalOr","bool");xt(n.shape,s.shape);let r={a:n,b:s};return B.runKernel(kc,r)}var jh=W({logicalOr_:qR});function XR(e,t){let n=R(e,"a","logicalXor","bool"),s=R(t,"b","logicalXor","bool");return xt(n.shape,s.shape),Ps(jh(e,t),Zc(Ps(e,t)))}var C3=W({logicalXor_:XR});function KR(e,t,n,s,r){let a=R(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]])),$(i.rank===4,()=>`Error in maxPool: input must be rank 4 but got rank ${i.rank}.`),$(Ar(n,o),()=>`Error in maxPool: Either strides or dilations must be 1. Got strides ${n} and dilations '${o}'`),r!=null&&$(sn(s),()=>`Error in maxPool: pad must be an integer when using, dimRoundingMode ${r} but got pad ${s}.`);let c={x:i},u={filterSize:t,strides:n,pad:s,dimRoundingMode:r},d=B.runKernel(bo,c,u);return l?V(d,[d.shape[1],d.shape[2],d.shape[3]]):d}var Yc=W({maxPool_:KR});function ZR(e,t=[1,1,1],n,s,r,a="NDHWC"){let o=R(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]])),$(i.rank===5,()=>`Error in maxPool3d: x must be rank 5 but got rank ${i.rank}.`),$(a==="NDHWC",()=>`Error in maxPool3d: Only NDHWC is currently supported, but got dataFormat of ${a}`),r!=null&&$(sn(s),()=>`Error in maxPool3d: pad must be an integer when using, dimRoundingMode ${r} but got pad ${s}.`);let c={x:i},u={filterSize:t,strides:n,pad:s,dimRoundingMode:r,dataFormat:a},d=B.runKernel(Sc,c,u);return l?V(d,[d.shape[1],d.shape[2],d.shape[3],d.shape[4]]):d}var VA=W({maxPool3d_:ZR});function YR(e,t,n,s,r=!1){let o={x:R(e,"x","maxPoolWithArgmax")},i={filterSize:t,strides:n,pad:s,includeBatchInIndex:r},l=B.runKernel(lh,o,i);return{result:l[0],indexes:l[1]}}var T3=W({maxPoolWithArgmax_:YR});function JR(e,t){let n=R(e,"a","maximum"),s=R(t,"b","maximum");[n,s]=Dt(n,s),n.dtype==="bool"&&(n=de(n,"int32"),s=de(s,"int32")),xt(n.shape,s.shape);let r={a:n,b:s};return B.runKernel(xo,r)}var xr=W({maximum_:JR});function QR(e,t=null,n=!1){let r={x:R(e,"x","mean")},a={axis:t,keepDims:n};return B.runKernel(vo,r,a)}var _t=W({mean_:QR});function Ut(e,t="float32"){if(t==="complex64"){let s=Ut(e,"float32"),r=Ut(e,"float32");return fa(s,r)}let n=zp(Mt(e),t);return B.makeTensor(n,e,t)}function as(e,t="float32"){if(t==="complex64"){let s=as(e,"float32"),r=Ut(e,"float32");return fa(s,r)}let n=_g(Mt(e),t);return B.makeTensor(n,e,t)}function eD(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=R(e,"x","meshgrid",e instanceof Ge?e.dtype:"float32");if(t===void 0)return[s];let r=R(t,"y","meshgrid",t instanceof Ge?t.dtype:"float32"),a=Mt(s.shape),o=Mt(r.shape);return n==="xy"?(s=V(s,[1,-1]),r=V(r,[-1,1]),[Ve(as([o,1],s.dtype),s),Ve(r,as([1,a],r.dtype))]):(s=V(s,[-1,1]),r=V(r,[1,-1]),[Ve(s,as([1,o],s.dtype)),Ve(as([a,1],r.dtype),r)])}function tD(e,t=null,n=!1){let r={x:R(e,"x","min")},a={axis:t,keepDims:n};return B.runKernel(wo,r,a)}var Jc=W({min_:tD});function nD(e,t){let n=R(e,"a","minimum"),s=R(t,"b","minimum");[n,s]=Dt(n,s),n.dtype==="bool"&&(n=de(n,"int32"),s=de(s,"int32")),xt(n.shape,s.shape);let r={a:n,b:s};return B.runKernel(ko,r)}var uu=W({minimum_:nD});function sD(e,t,n){$(n==="reflect"||n==="symmetric",()=>`Invalid mode. Mode must be either reflect or symmetric. Got ${n}.`);let s=R(e,"x","mirrorPad");if(s.rank===0)throw new Error("mirrorPad(scalar) is not defined. Pass non-scalar to mirrorPad");$(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++)$(t[i].length===2,()=>"Invalid number of paddings. Must be length of 2 each."),$(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 B.runKernel(Io,o,a)}var UA=W({mirrorPad_:sD});function rD(e,t){let n=R(e,"a","mod"),s=R(t,"b","mod");[n,s]=Dt(n,s);let r={a:n,b:s};return B.runKernel(wl,r)}var GA=W({mod_:rD});function aD(e){let t=R(e,"x","square"),n={};return B.runKernel("Square",{x:t},n)}var ht=W({square_:aD});function oD(e,t=null,n=!1){e=R(e,"x","moments");let s=Fs(t,e.shape),r=_t(e,s,n),a=r.shape;n||(a=oi(r.shape,s));let o=ht(be(de(e,"float32"),V(r,a))),i=_t(o,s,n);return{mean:r,variance:i}}var qh=W({moments_:oD});function iD(e,t,n,s){let r=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 c=[],u=[];for(let d=0;d<l.length;d+=2)c.push(l[d]),u.push(l[d+1]);return[c,u]}var lD=W({multiRNNCell_:iD});function uD(e,t,n,s=!1){let r=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},c={numSamples:t,seed:n,normalized:s},u=B.runKernel(uh,l,c);return o===1?V(u,[u.size]):u}var N3=W({multinomial_:uD});function cD(e,t){let n=R(e,"a","notEqual","string_or_numeric"),s=R(t,"b","notEqual","string_or_numeric");[n,s]=Dt(n,s),xt(n.shape,s.shape);let r={a:n,b:s};return B.runKernel(Il,r)}var ii=W({notEqual_:cD});function dD(e){let n={x:R(e,"x","onesLike")};return B.runKernel(Nl,n)}var os=W({onesLike_:dD});function pD(e,t){let n=R(e,"v1","outerProduct"),s=R(t,"v2","outerProduct");$(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 Ve(r,a)}var hD=W({outerProduct_:pD});function fD(e,t,n=0){let s=R(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 B.runKernel(To,a,r)}var vs=W({pad_:fD});function mD(e,t,n=0){return $(t.length===2,()=>"Invalid number of paddings. Must be length of 2."),vs(e,[t],n)}var gD=W({pad1d_:mD});function AD(e,t,n=0){return $(t.length===2&&t[0].length===2&&t[1].length===2,()=>"Invalid number of paddings. Must be length of 2 each."),vs(e,t,n)}var yD=W({pad2d_:AD});function xD(e,t,n=0){return $(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."),vs(e,t,n)}var bD=W({pad3d_:xD});function vD(e,t,n=0){return $(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."),vs(e,t,n)}var wD=W({pad4d_:vD});function kD(e,t,n){let s=R(e,"x","spaceToBatchND");$(s.rank>=1+t.length,()=>`input rank ${s.rank} should be > than [blockShape] ${t.length}`),$(n.length===t.length,()=>`paddings.shape[0] ${n.length} must be equal to [blockShape] ${t.length}`),$(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 B.runKernel(Bl,r,a)}var Qc=W({spaceToBatchND_:kD});function ID(e,t,n,s,r,a){r==null&&(r=[1,1]),a==null&&(a=1),s===0&&(s="valid");let o=R(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]])),$(Ar(a,r),()=>`Error in pool: Either strides or dilations must be 1. Got strides ${a} and dilations '${r}'`);let c=s3(i.shape,t,a,r,s),u=[c.dilationHeight,c.dilationWidth],d;s==="same"?d=CD([c.filterHeight,c.filterWidth],u):d=[[0,0],[0,0]];let p=u[0]===1&&u[1]===1,[h,f]=SD([c.inHeight,c.inWidth],u,d),m=p?s:"valid",g=p?i:Qc(i,u,h),y=(n==="avg"?()=>Hc(g,t,a,m):()=>Yc(g,t,a,m))(),x=p?y:jc(y,u,f);return l?V(x,[x.shape[1],x.shape[2],x.shape[3]]):x}function SD(e,t,n){let s=n.map(u=>u[0]),r=n.map(u=>u[1]),a=e.concat(s,r),o=t.map((u,d)=>(u-a[d]%u)%u),i=r.map((u,d)=>u+o[d]),l=t.map((u,d)=>[s[d],i[d]]),c=t.map((u,d)=>[0,o[d]]);return[l,c]}function CD(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 E3=W({pool_:ID});function TD(e,t){let n=R(e,"base","pow"),s=R(t,"exp","pow");[n,s]=Dt(n,s);let r={a:n,b:s};return B.runKernel(No,r)}var zr=W({pow_:TD});function ND(e,t){let n=R(e,"x","prelu"),s=R(t,"alpha","prelu"),r={x:n,alpha:s};return B.runKernel(Eo,r)}var ed=W({prelu_:ND});function ED(e,t=null,n=!1){let s=R(e,"x","prod");s.dtype==="bool"&&(s=de(s,"int32"));let r={x:s},a={axis:t,keepDims:n};return B.runKernel(Rl,r,a)}var Xh=W({prod_:ED});function RD(e,t,n){let s=Mt(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 B.makeTensor(r,e,n)}var DD=W({rand_:RD}),HA=ja(L5()),jA=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=HA.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}},_D=class{constructor(e,t,n,s){this.alpha=e,this.beta=1/t,this.dtype=n;let r=s||Math.random();this.randu=HA.alea(r.toString()),this.randn=new jA(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)}},FD=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=HA.alea(s)}convertValue(e){return this.canReturnFloat()?e:Math.round(e)}nextValue(){return this.convertValue(this.min+this.range*this.random())}};function $D(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 _D(t,n,s,r),o=He(e,s);for(let i=0;i<o.values.length;i++)o.values[i]=a.nextValue();return o.toTensor()}var OD=W({randomGamma_:$D});function PD(e,t=0,n=1,s,r){if(s!=null&&s==="bool")throw new Error(`Unsupported data type ${s}`);let a=new jA(t,n,s,!1,r),o=He(e,s);for(let i=0;i<o.values.length;i++)o.values[i]=a.nextValue();return o.toTensor()}var R3=W({randomNormal_:PD});function MD(e,t=0,n=1,s="float32",r){let a=He(e,s),o=new FD(t,n,null,r);for(let i=0;i<a.values.length;i++)a.values[i]=o.nextValue();return a.toTensor()}var cu=W({randomUniform_:MD});function du(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 B.runKernel(Cc,{},r)}function zD(e){let n={input:R(e,"input","real")};return B.runKernel(ch,n)}var td=W({real_:zD});function LD(e){let n={x:R(e,"x","reciprocal")};return B.runKernel(Dl,n)}var qA=W({reciprocal_:LD});function BD(e){let n={x:R(e,"x","relu")};return B.runKernel(Ro,n)}var Zs=W({relu_:BD});function WD(e){let n={x:R(e,"x","relu6")};return B.runKernel(_o,n)}var Kh=W({relu6_:WD});function VD(e,t){let s={x:R(e,"x","reverse")},r={dims:t};return B.runKernel(Fo,s,r)}var is=W({reverse_:VD});function UD(e){let t=R(e,"x","reverse");return $(t.rank===1,()=>`Error in reverse1D: x must be rank 1 but got rank ${t.rank}.`),is(t,0)}var GD=W({reverse1d_:UD});function HD(e,t){let n=R(e,"x","reverse");return $(n.rank===2,()=>`Error in reverse2D: x must be rank 2 but got rank ${n.rank}.`),is(n,t)}var jD=W({reverse2d_:HD});function qD(e,t){let n=R(e,"x","reverse");return $(n.rank===3,()=>`Error in reverse3D: x must be rank 3 but got rank ${n.rank}.`),is(n,t)}var XD=W({reverse3d_:qD});function KD(e,t){let n=R(e,"x","reverse");return $(n.rank===4,()=>`Error in reverse4D: x must be rank 4 but got rank ${n.rank}.`),is(n,t)}var ZD=W({reverse4d_:KD});function YD(e){let n={x:R(e,"x","round")};return B.runKernel($o,n)}var Zh=W({round_:YD});function JD(e){let n={x:R(e,"x","rsqrt","float32")};return B.runKernel(Oo,n)}var Yh=W({rsqrt_:JD});function Ee(e,t){if((kn(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"&&kn(e)&&!(e instanceof Uint8Array))throw new Error("When making a scalar from encoded string, the value must be `Uint8Array`.");return ma(e,[],[],t)}function QD(e){let n={x:R(e,"x","selu")};return B.runKernel(Ol,n)}var Jh=W({selu_:QD});function e_(e,t,n,s,r,a=[1,1],o="NHWC"){let i=R(e,"x","separableConv2d"),l=R(t,"depthwiseFilter","separableConv2d"),c=R(n,"pointwiseFilter","separableConv2d"),u=i,d=!1;if(i.rank===3&&(d=!0,u=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");$(u.rank===4,()=>`Error in separableConv2d: input must be rank 4, but got rank ${u.rank}.`),$(l.rank===4,()=>`Error in separableConv2d: depthwise filter must be rank 4, but got rank ${l.rank}.`),$(c.rank===4,()=>`Error in separableConv2d: pointwise filter must be rank 4, but got rank ${l.rank}.`),$(c.shape[0]===1,()=>`Error in separableConv2d: the first dimension of pointwise filter must be 1, but got ${c.shape[0]}.`),$(c.shape[1]===1,()=>`Error in separableConv2d: the second dimension of pointwise filter must be 1, but got ${c.shape[1]}.`);let p=l.shape[2],h=l.shape[3];$(c.shape[2]===p*h,()=>`Error in separableConv2d: the third dimension of pointwise filter must be ${p*h}, but got ${c.shape[2]}.`);let f=au(u,l,s,r,o,a),g=Mr(f,c,1,"valid",o);return d?V(g,[g.shape[1],g.shape[2],g.shape[3]]):g}var XA=W({separableConv2d_:e_});async function t_(e,t){let n=R(e,"x","setdiff1d"),s=R(t,"y","setdiff1d");$(n.dtype===s.dtype,()=>`x and y should have the same dtype, but got x (${n.dtype}) and y (${s.dtype}).`),$(n.rank===1,()=>`x should be 1D tensor, but got x (${n.shape}).`),$(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 u=0;u<r.length;u++)o.has(r[u])||i++;let l=new Zt([i],n.dtype),c=new Zt([i],"int32");for(let u=0,d=0;u<r.length;u++)o.has(r[u])||(l.values[d]=r[u],c.values[d]=u,d++);return[l.toTensor(),c.toTensor()]}var D3=t_;function n_(e){let n={x:R(e,"x","sign")};return B.runKernel(zl,n)}var KA=W({sign_:n_});function s_(e){let n={x:R(e,"x","sin","float32")};return B.runKernel(Po,n)}var Qh=W({sin_:s_});function r_(e){let n={x:R(e,"x","sinh")};return B.runKernel(Ml,n)}var ef=W({sinh_:r_});function a_(e,t,n){let s=R(e,"x","slice1d");return $(s.rank===1,()=>`slice1d expects a rank-1 tensor, but got a rank-${s.rank} tensor`),Fe(s,[t],[n])}var tf=W({slice1d_:a_});function o_(e,t,n){let s=R(e,"x","slice2d");return $(s.rank===2,()=>`slice2d expects a rank-2 tensor, but got a rank-${s.rank} tensor`),Fe(s,t,n)}var ZA=W({slice2d_:o_});function i_(e,t,n){let s=R(e,"x","slice3d");return $(s.rank===3,()=>`slice3d expects a rank-3 tensor, but got a rank-${s.rank} tensor`),Fe(s,t,n)}var pu=W({slice3d_:i_});function l_(e,t,n){let s=R(e,"x","slice4d");return $(s.rank===4,()=>`slice4d expects a rank-4 tensor, but got a rank-${s.rank} tensor`),Fe(s,t,n)}var nd=W({slice4d_:l_});function u_(e,t=-1){let n=R(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 B.runKernel(Bo,s,r)}var li=W({softmax_:u_});function c_(e){$(e.dtype==="complex64",()=>`The dtype for tf.spectral.fft() must be complex64 but got ${e.dtype}.`);let t={input:e};return B.runKernel(th,t)}var sd=W({fft_:c_});function d_(e){$(e.dtype==="complex64",()=>`The dtype for tf.spectral.ifft() must be complex64 but got ${e.dtype}.`);let t={input:e};return B.runKernel(nh,t)}var hu=W({ifft_:d_});function p_(e){let t=e.shape[e.shape.length-1],n=e.size/t,s;if(t<=2){let r=V(e,[n,t]);s=hu(r)}else{let r=[n,2*(t-1)],a=V(td(e),[n,t]),o=V(Vh(e),[n,t]),i=is(Fe(a,[0,1],[n,t-2]),1),l=L(is(Fe(o,[0,1],[n,t-2]),1),Ee(-1)),c=mt([a,i],1),u=mt([o,l],1),d=V(fa(c,u),[r[0],r[1]]);s=hu(d)}if(s=td(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 nf=W({irfft_:p_});function h_(e,t,n=0){let r={x:R(e,"x","split")},a={numOrSizeSplits:t,axis:n};return B.runKernel(Wl,r,a)}var on=W({split_:h_});function f_(e,t){$(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=Fe(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=mt([e,Ut(f)],e.shape.length-1),n=t}else r=e;let a=Ze(r),o=V(fa(r,a),[s,n]),i=sd(o),l=Math.floor(n/2)+1,c=td(i),u=Vh(i),d=on(c,[l,n-l],c.shape.length-1),p=on(u,[l,n-l],u.shape.length-1),h=r.shape.slice();return h[r.shape.length-1]=l,V(fa(d[0],p[0]),h)}var rd=W({rfft_:f_});function m_(e){let n={x:R(e,"x","sqrt","float32")};return B.runKernel(zo,n)}var mn=W({sqrt_:m_});function g_(e,t){let n=R(e,"a","squaredDifference"),s=R(t,"b","squaredDifference");[n,s]=Dt(n,s),xt(n.shape,s.shape);let r={a:n,b:s},a={};return B.runKernel(Wo,r,a)}var sf=W({squaredDifference_:g_});function A_(e,t){let n=R(e,"x","squeeze");return V(n,U5(n.shape,t).newShape)}var rt=W({squeeze_:A_});function y_(e,t=0){let n=Bc(e,"tensors","stack","string_or_numeric");$(n.length>=1,()=>"Pass at least one tensor to tf.stack"),n.length>0&&$(t<=n[0].rank,()=>"Axis must be <= rank of the tensor");let s=n,r={axis:t};return B.runKernel(El,s,r)}var gn=W({stack_:y_});function x_(e,t=0){let s={x:R(e,"x","step")},r={alpha:t};return B.runKernel(da,s,r)}var fu=W({step_:x_});function b_(e,t,n,s,r=0,a=0,o=0,i=0,l=0){let u={x:R(e,"x","stridedSlice","string_or_numeric")},d={begin:t,end:n,strides:s,beginMask:r,endMask:a,ellipsisMask:o,newAxisMask:i,shrinkAxisMask:l};return B.runKernel(Vl,u,d)}var YA=W({stridedSlice_:b_});function v_(e){let n={x:R(e,"x","tan","float32")};return B.runKernel(Uo,n)}var JA=W({tan_:v_});function Gt(e,t){qa(e);let n=mr(e,t);if(n.length!==1)throw new Error("tensor1d() requires values to be a flat/TypedArray");return ma(e,null,n,t)}function Ys(e,t,n){if(qa(e),t!=null&&t.length!==2)throw new Error("tensor2d() requires shape to have two numbers");let s=mr(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 ma(e,t,s,n)}function w_(e,t,n){if(qa(e),t!=null&&t.length!==4)throw new Error("tensor4d() requires shape to have four numbers");let s=mr(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 ma(e,t,s,n)}function k_(e,t,n){if(qa(e),t!=null&&t.length!==5)throw new Error("tensor5d() requires shape to have five numbers");let s=mr(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 ma(e,t,s,n)}function I_(e,t,n){if(qa(e),t!=null&&t.length!==6)throw new Error("tensor6d() requires shape to have six numbers");let s=mr(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,ma(e,t,s,n)}function S_(e,t=1,n=!0){let s=R(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]=B.runKernel(Ul,a,o);return{values:i,indices:l}}var QA=W({topk_:S_});function C_(e,t=0,n=1,s,r){if(s!=null&&s==="bool")throw new Error("Unsupported data type $ { dtype }");let a=new jA(t,n,s,!0,r),o=He(e,s);for(let i=0;i<o.values.length;i++)o.values[i]=a.nextValue();return o.toTensor()}var rf=W({truncatedNormal_:C_});function T_(e,t=0){let n=R(e,"x","unique","string_or_numeric");$(n.rank>0,()=>"The input tensor must be at least 1D");let s={x:n},r={axis:t},[a,o]=B.runKernel(vh,s,r);return{values:a,indices:o}}var af=W({unique_:T_});function N_(e,t,n){let s=R(e,"x","unsortedSegmentSum"),r=R(t,"segmentIds","unsortedSegmentSum","int32");$(sn(n),()=>"numSegments must be of dtype int");let a={x:s,segmentIds:r},o={numSegments:n};return B.runKernel(Ec,a,o)}var e1=W({unsortedSegmentSum_:N_});function E_(e,t=0){let n=R(e,"x","unstack","string_or_numeric");$(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 B.runKernel(Hl,s,r)}var Dn=W({unstack_:E_});function _3(e,t=!0,n,s){return B.makeVariable(e,t,n,s)}function F3(e,t){let n=[];for(let a=0;a<t.length;a++)t[a]&&n.push(a);let s=He(e,"int32"),r=He([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 R_(e){let t=R(e,"condition","whereAsync","bool"),n=await t.data(),s=F3(t.shape,n);return e!==t&&t.dispose(),s}var t1=R_;async function D_(e,t,n){let s=R(e,"tensor","boolMask"),r=R(t,"mask","boolMask","bool"),a=n??0,o=r.rank,i=s.shape;$(o>0,()=>"mask cannot be scalar"),Tn(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 c=i.slice(0,a).concat([l],i.slice(a+o)),u=V(s,c),d=V(r,[-1]),p=await t1(d),h=rt(p,[1]),f=ri(u,h,a);return e!==s&&s.dispose(),t!==r&&r.dispose(),h.dispose(),u.dispose(),d.dispose(),p.dispose(),f}var __=D_;function F_(e,t="euclidean",n=null,s=!1){e=R(e,"x","norm");let r=$3(e,t,n),a=r.shape;if(s){let o=Fs(n,e.shape);a=oi(r.shape,o)}return V(r,a)}function $3(e,t,n=null){if(e.rank===0)return Vt(e);if(e.rank!==1&&n===null)return $3(V(e,[-1]),t,n);if(e.rank===1||typeof n=="number"||Array.isArray(n)&&n.length===1){if(t===1)return Ie(Vt(e),n);if(t===1/0)return Rn(Vt(e),n);if(t===-1/0)return Jc(Vt(e),n);if(t==="euclidean"||t===2)return mn(Ie(zr(Vt(e),Ee(2,"int32")),n));throw new Error(`Error in norm: invalid ord value: ${t}`)}if(Array.isArray(n)&&n.length===2){if(t===1)return Rn(Ie(Vt(e),n[0]),n[1]-1);if(t===1/0)return Rn(Ie(Vt(e),n[1]),n[0]);if(t===-1/0)return Jc(Ie(Vt(e),n[1]),n[0]);if(t==="fro"||t==="euclidean")return mn(Ie(ht(e),n));throw new Error(`Error in norm: invalid ord value: ${t}`)}throw new Error(`Error in norm: invalid axis: ${n}`)}var of=W({norm_:F_});function $_(e,t,n,s,r=!0){let a=R(e,"v","movingAverage"),o=R(t,"x","movingAverage"),i=R(n,"decay","movingAverage");cb(a,o),$($r(a.shape,o.shape),()=>"Shape mismatch in v and x");let l=Ee(1),c=be(l,i),u=L(be(o,a),c);if(r){$(s!=null,()=>"When using zeroDebias: true, step is required.");let d=R(s,"step","movingAverage");u=fe(u,be(l,zr(i,d)))}return le(a,u)}var O_=W({movingAverage_:$_});function P_(e,t,n){let s=R(e,"indices","scatterND","int32"),r=R(t,"updates","scatterND");cA(r,s,n);let a={indices:s,updates:r},o={shape:n};return B.runKernel(Fl,a,o)}var O3=W({scatterND_:P_});function M_(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 z_(e,t,n,s=0){let r=R(e,"sparseIndices","sparseToDense","int32"),a=R(t,"sparseValues","sparseToDense"),o=R(s,"defaultValue","sparseToDense",a.dtype);M_(r,a,n,o);let i={sparseIndices:r,sparseValues:a,defaultValue:o},l={outputShape:n};return B.runKernel(Ah,i,l)}var n1=W({sparseToDense_:z_});function L_(e,t){let n=R(t,"indices","gatherND","int32"),r={params:R(e,"x","gatherND","string_or_numeric"),indices:n};return B.runKernel(hl,r)}var P3=W({gatherND_:L_});function B_(e,t){if(t==null)return e.shape.slice();if($r(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 W_(e,t,n,s){let r=R(e,"x","dropout");if($(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.`),$(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=B_(r,n),o=1-t,i=fe(lu(le(cu(a,0,1,"float32",s),o)),o);return L(r,i)}var M3=W({dropout_:W_});function z3(e){return Math.floor(Math.pow(2,Math.ceil(Math.log(e)/Math.log(2))))}function s1(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 Gt(r,"float32")}async function V_(e,t,n=1){let s=R(e,"predictions","inTopK"),r=R(t,"targets","inTopK");$(s.rank>1,()=>`inTopK() expects the predictions to be of rank 2 or higher, but got ${s.rank}`),$(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}`),Tn(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];$(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,c]=[o.length/a,a],u=G5("bool",l);for(let d=0;d<l;d++){let p=d*c,h=o.subarray(p,p+c),f=[];for(let m=0;m<h.length;m++)f.push({value:h[m],index:m});f.sort((m,g)=>g.value-m.value),u[d]=0;for(let m=0;m<n;m++)if(f[m].index===i[d]){u[d]=1;break}}return e!==s&&s.dispose(),t!==r&&r.dispose(),zt(u,r.shape,"bool")}var U_=V_,va={};ze(va,{conv2d:()=>j_,depthwiseConv2d:()=>Z_,matMul:()=>J_});function G_(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]])),$(i.rank===4,()=>`Error in conv2dDerFilter: input must be rank 4, but got shape ${i.shape}.`),$(l.rank===4,()=>`Error in conv2dDerFilter: dy must be rank 4, but got shape ${l.shape}.`),$(n.length===4,()=>`Error in conv2dDerFilter: filterShape must be length 4, but got ${n}.`);let c=a==="NHWC"?i.shape[3]:i.shape[1],u=a==="NHWC"?l.shape[3]:l.shape[1];$(c===n[2],()=>`Error in conv2dDerFilter: depth of input ${c}) must match input depth in filter (${n[2]}.`),$(u===n[3],()=>`Error in conv2dDerFilter: depth of dy (${u}) must match output depth for filter (${n[3]}).`),o!=null&&$(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 B.runKernel(Gp,d,p)}var r1=W({conv2DBackpropFilter_:G_});function lf(e,t,n){if(n==null||n==="linear")return e;if(n==="relu")return L(e,fu(t));throw new Error(`Cannot compute gradient for fused activation ${n}.`)}function uf(e,t){let n=t,s=Yt(e.shape,t.shape);return s.length>0&&(n=Ie(n,s)),V(n,e.shape)}function cf(e,t,n,s){if(t==="linear")return e;if(t==="relu")return Zs(e);if(t==="elu")return ou(e);if(t==="relu6")return Kh(e);if(t==="prelu")return ed(e,n);if(t==="leakyrelu")return Xc(e,s);if(t==="sigmoid")return Hn(e);throw new Error(`Unknown fused activation ${t}.`)}var df=(e,t)=>!(e>0)||t==="linear";function H_({x:e,filter:t,strides:n,pad:s,dataFormat:r="NHWC",dilations:a=[1,1],dimRoundingMode:o,bias:i,activation:l="linear",preluActivationWeights:c,leakyreluAlpha:u}){if(l=l||"linear",df(B.state.gradientDepth,l)===!1){let v=Mr(e,t,n,s,r,a,o);return i!=null&&(v=le(v,i)),cf(v,l,c,u)}let d=R(e,"x","conv2d","float32"),p=R(t,"filter","conv2d","float32"),h=d,f=!1;d.rank===3&&(f=!0,h=V(d,[1,d.shape[0],d.shape[1],d.shape[2]])),$(h.rank===4,()=>`Error in fused conv2d: input must be rank 4, but got rank ${h.rank}.`),$(p.rank===4,()=>`Error in fused conv2d: filter must be rank 4, but got rank ${p.rank}.`),o!=null&&$(sn(s),()=>`Error in fused conv2d: pad must be an integer when using, dimRoundingMode ${o} but got pad ${s}.`),$(h.shape[3]===p.shape[2],()=>`Error in conv2d: depth of input (${h.shape[3]}) must match input depth for filter ${p.shape[2]}.`),$(Ar(n,a),()=>`Error in conv2D: Either strides or dilations must be 1. Got strides ${n} and dilations '${a}'`),$(r==="NHWC",()=>`Error in conv2d: got dataFormat of ${r} but only NHWC is currently supported.`);let m=Gc(h.shape,p.shape,n,a,s,o),g;i!=null&&(g=R(i,"bias","fused conv2d"),[g]=Dt(g,d),xt(m.outShape,g.shape));let A;c!=null&&(A=R(c,"prelu weights","fused conv2d"));let y=(v,S)=>{let[T,_,O,P]=S,D=lf(v,O,l);$(ya(a),()=>`Error in gradient of fused conv2D: dilation rates greater than 1 are not yet supported in gradients. Got dilations '${a}'`);let F=EA(_.shape,D,T,n,s),C=r1(_,D,T.shape,n,s),M=[F,C];if(P!=null){let U=uf(P,D);M.push(U)}return M},x={x:h,filter:p,bias:g,preluActivationWeights:A},b={strides:n,pad:s,dataFormat:r,dilations:a,dimRoundingMode:o,activation:l,leakyreluAlpha:u};return i==null?yr((S,T,_)=>{let O=B.runKernel(qo,x,b);return _([T,S,O]),f&&(O=V(O,[O.shape[1],O.shape[2],O.shape[3]])),{value:O,gradFunc:y}})(h,p):yr((S,T,_,O)=>{let P=B.runKernel(qo,x,b);return O([T,S,P,_]),f&&(P=V(P,[P.shape[1],P.shape[2],P.shape[3]])),{value:P,gradFunc:y}})(h,p,g)}var j_=W({fusedConv2d_:H_});function q_(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 c={x:i,dy:l},u={strides:s,pad:r,dimRoundingMode:o,dilations:a,filterShape:n};return B.runKernel(Xp,c,u)}var L3=W({depthwiseConv2dNativeBackpropFilter_:q_});function X_(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 c={dy:i,filter:n},u={strides:s,pad:r,dimRoundingMode:o,dilations:a,inputShape:e},d=B.runKernel(Kp,c,u);return l?V(d,[d.shape[1],d.shape[2],d.shape[3]]):d}var B3=W({depthwiseConv2dNativeBackpropInput_:X_});function K_({x:e,filter:t,strides:n,pad:s,dataFormat:r="NHWC",dilations:a=[1,1],dimRoundingMode:o,bias:i,activation:l="linear",preluActivationWeights:c,leakyreluAlpha:u}){if(df(B.state.gradientDepth,l)===!1){let v=au(e,t,n,s,r,a,o);return i!=null&&(v=le(v,i)),cf(v,l,c,u)}let d=R(e,"x","depthwiseConv2d","float32"),p=R(t,"filter","depthwiseConv2d","float32"),h=d,f=!1;d.rank===3&&(f=!0,h=V(d,[1,d.shape[0],d.shape[1],d.shape[2]])),$(h.rank===4,()=>`Error in fused depthwiseConv2d: input must be rank 4, but got rank ${h.rank}.`),$(p.rank===4,()=>`Error in fused depthwiseConv2d: filter must be rank 4, but got rank ${p.rank}.`),$(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]),$(Ar(n,a),()=>`Error in fused depthwiseConv2d: Either strides or dilations must be 1. Got strides ${n} and dilations '${a}'`),o!=null&&$(sn(s),()=>`Error in fused depthwiseConv2d: pad must be an integer when using dimRoundingMode ${o} but got pad ${s}.`);let m=Gc(h.shape,p.shape,n,a,s,o,!0),g;i!=null&&(g=R(i,"bias","fused conv2d"),[g]=Dt(g,d),xt(m.outShape,g.shape));let A;c!=null&&(A=R(c,"prelu weights","fused depthwiseConv2d"));let y=(v,S)=>{$(ya(a),()=>`Error in gradient of fused depthwiseConv2d: dilation rates greater than 1 are not yet supported. Got dilations '${a}'`);let[T,_,O,P]=S,D=lf(v,O,l),F=B3(_.shape,D,T,n,s,a,o),C=L3(_,D,T.shape,n,s,a,o);if(P!=null){let M=uf(g,D);return[F,C,M]}return[F,C]},x={x:h,filter:p,bias:g,preluActivationWeights:A},b={strides:n,pad:s,dataFormat:r,dilations:a,dimRoundingMode:o,activation:l,leakyreluAlpha:u};return i==null?yr((S,T,_)=>{let O=B.runKernel(Xo,x,b);return _([T,S,O]),f&&(O=V(O,[O.shape[1],O.shape[2],O.shape[3]])),{value:O,gradFunc:y}})(h,p):yr((S,T,_,O)=>{let P=B.runKernel(Xo,x,b);return O([T,S,P,_]),f&&(P=V(P,[P.shape[1],P.shape[2],P.shape[3]])),{value:P,gradFunc:y}})(h,p,g)}var Z_=W({fusedDepthwiseConv2d_:K_});function Y_({a:e,b:t,transposeA:n=!1,transposeB:s=!1,bias:r,activation:a="linear",preluActivationWeights:o,leakyreluAlpha:i}){if(df(B.state.gradientDepth,a)===!1){let P=Ve(e,t,n,s);return r!=null&&(P=le(P,r)),cf(P,a,o,i)}let l=R(e,"a","fused matMul"),c=R(t,"b","fused matMul");[l,c]=Dt(l,c);let u=n?l.shape[l.rank-2]:l.shape[l.rank-1],d=s?c.shape[c.rank-1]:c.shape[c.rank-2],p=n?l.shape[l.rank-1]:l.shape[l.rank-2],h=s?c.shape[c.rank-2]:c.shape[c.rank-1],f=l.shape.slice(0,-2),m=c.shape.slice(0,-2),g=Mt(f),A=Mt(m);$(l.rank>=2&&c.rank>=2&&l.rank===c.rank,()=>`Error in fused matMul: inputs must have the same rank of at least 2, got ranks ${l.rank} and ${c.rank}.`),$($r(f,m),()=>`Error in fused matMul: outer dimensions (${f}) and (${m}) of Tensors with shapes ${l.shape} and ${c.shape} must match.`),$(u===d,()=>`Error in fused matMul: inner shapes (${u}) and (${d}) of Tensors with shapes ${l.shape} and ${c.shape} and transposeA=${n} and transposeB=${s} must match.`);let y=l.shape.slice(0,-2).concat([p,h]),x=n?V(l,[g,u,p]):V(l,[g,p,u]),b=s?V(c,[A,h,d]):V(c,[A,d,h]),v;r!=null&&(v=R(r,"bias","fused matMul"),[v]=Dt(v,l),xt(y,v.shape));let S;o!=null&&(S=R(o,"prelu weights","fused matMul"));let T=(P,D)=>{let[F,C,M,U]=D,j=lf(V(P,M.shape),M,a),q,X;if(!n&&!s?(q=Ve(j,C,!1,!0),X=Ve(F,j,!0,!1)):!n&&s?(q=Ve(j,C,!1,!1),X=Ve(j,F,!0,!1)):n&&!s?(q=Ve(C,j,!1,!0),X=Ve(F,j,!1,!1)):(q=Ve(C,j,!0,!0),X=Ve(j,F,!0,!0)),r!=null){let te=uf(U,j);return[q,X,te]}else return[q,X]},_={a:x,b,bias:v,preluActivationWeights:S},O={transposeA:n,transposeB:s,activation:a,leakyreluAlpha:i};return r==null?yr((D,F,C)=>{let M=B.runKernel(jo,_,O);return C([D,F,M]),{value:V(M,y),gradFunc:T}})(x,b):yr((D,F,C,M)=>{let U=B.runKernel(jo,_,O);return M([D,F,U,C]),{value:V(U,y),gradFunc:T}})(x,b,v)}var J_=W({fusedMatMul_:Y_});function Q_(e){return s1(e,.54,.46)}var eF=W({hammingWindow_:Q_});function tF(e){return s1(e,.5,.5)}var W3=W({hannWindow_:tF});function nF(e,t,n,s=!1,r=0){let a=0,o=[];for(;a+t<=e.size;)o.push(Fe(e,a,t)),a+=n;if(s)for(;a<e.size;){let i=a+t-e.size,l=mt([Fe(e,a,t-i),iu([i],r)]);o.push(l),a+=n}return o.length===0?Ys([],[0,t]):V(mt(o),[o.length,t])}var V3=W({frame_:nF});function sF(e,t,n,s,r=W3){s==null&&(s=z3(t));let a=V3(e,t,n),o=L(a,r(t));return rd(o,s)}var rF=W({stft_:sF});function aF(e,t,n,s,r="bilinear",a=0){let o=R(e,"image","cropAndResize"),i=R(t,"boxes","cropAndResize","float32"),l=R(n,"boxInd","cropAndResize","int32"),c=i.shape[0];$(o.rank===4,()=>`Error in cropAndResize: image must be rank 4,but got rank ${o.rank}.`),$(i.rank===2&&i.shape[1]===4,()=>`Error in cropAndResize: boxes must be have size [${c},4] but had shape ${i.shape}.`),$(l.rank===1&&l.shape[0]===c,()=>`Error in cropAndResize: boxInd must be have size [${c}] but had shape ${i.shape}.`),$(s.length===2,()=>`Error in cropAndResize: cropSize must be of length 2, but got length ${s.length}.`),$(s[0]>=1&&s[1]>=1,()=>`cropSize must be atleast [1,1], but was ${s}`),$(r==="bilinear"||r==="nearest",()=>`method must be bilinear or nearest, but was ${r}`);let u={image:o,boxes:i,boxInd:l},d={method:r,extrapolationValue:a,cropSize:s};return B.runKernel(al,u,d)}var oF=W({cropAndResize_:aF});function iF(e){let t=R(e,"image","flipLeftRight","float32");$(t.rank===4,()=>`Error in flipLeftRight: image must be rank 4,but got rank ${t.rank}.`);let n={image:t};return B.runKernel(dl,n,{})}var lF=W({flipLeftRight_:iF});function uF(e){let t=R(e,"image","grayscaleToRGB"),n=t.rank-1,s=t.shape[n];$(t.rank>=2,()=>`Error in grayscaleToRGB: images must be at least rank 2, but got rank ${t.rank}.`),$(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 cF=W({grayscaleToRGB_:uF});function dF(e,t,n=0,s=.5){let r=R(e,"image","rotateWithOffset","float32");$(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 B.runKernel(ql,a,o)}var pF=W({rotateWithOffset_:dF});function mu(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),$(0<=s&&s<=1,()=>`iouThreshold must be in [0, 1], but was '${s}'`),$(e.rank===2,()=>`boxes must be a 2D tensor, but was of rank '${e.rank}'`),$(e.shape[1]===4,()=>`boxes must have 4 columns, but 2nd dimension was ${e.shape[1]}`),$(t.rank===1,()=>"scores must be a 1D tensor"),$(t.shape[0]===o,()=>`scores has incompatible shape with boxes. Expected ${o}, but was ${t.shape[0]}`),$(0<=a&&a<=1,()=>`softNmsSigma must be in [0, 1], but was '${a}'`),{maxOutputSize:n,iouThreshold:s,scoreThreshold:r,softNmsSigma:a}}function hF(e,t,n,s=.5,r=Number.NEGATIVE_INFINITY){let a=R(e,"boxes","nonMaxSuppression","float32"),o=R(t,"scores","nonMaxSuppression","float32"),i=mu(a,o,n,s,r);n=i.maxOutputSize,s=i.iouThreshold,r=i.scoreThreshold;let l={maxOutputSize:n,iouThreshold:s,scoreThreshold:r};return B.runKernel(Sl,{boxes:a,scores:o},l)}var fF=W({nonMaxSuppression_:hF});function mF(e,t,n){let s=gF(e,t,n),r=s<0?-(s+1):s;e.splice(r,0,t)}function gF(e,t,n){return yF(e,t,n||AF)}function AF(e,t){return e>t?1:e<t?-1:0}function yF(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 U3(e,t,n,s,r){return a1(e,t,n,s,r,0)}function G3(e,t,n,s,r,a){return a1(e,t,n,s,r,0,!1,a,!0)}function H3(e,t,n,s,r,a){return a1(e,t,n,s,r,a,!0)}function a1(e,t,n,s,r,a,o=!1,i=!1,l=!1){let c=[];for(let g=0;g<t.length;g++)t[g]>r&&c.push({score:t[g],boxIndex:g,suppressBeginIndex:0});c.sort(j3);let u=a>0?-.5/a:0,d=[],p=[];for(;d.length<n&&c.length>0;){let g=c.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 S=xF(e,y,d[v]);if(S>=s){b=!0;break}if(g.score=g.score*bF(s,u,S),g.score<=r)break}g.suppressBeginIndex=d.length,b||(g.score===A?(d.push(y),p.push(g.score)):g.score>r&&mF(c,g,j3))}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 xF(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]),c=Math.min(r[0],r[2]),u=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-c)*(p-u);if(h<=0||f<=0)return 0;let m=Math.max(a,c),g=Math.max(o,u),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 bF(e,t,n){let s=Math.exp(t*n*n);return n<=e?s:0}function j3(e,t){return e.score-t.score||e.score===t.score&&t.boxIndex-e.boxIndex}async function vF(e,t,n,s=.5,r=Number.NEGATIVE_INFINITY){let a=R(e,"boxes","nonMaxSuppressionAsync"),o=R(t,"scores","nonMaxSuppressionAsync"),i=mu(a,o,n,s,r);n=i.maxOutputSize,s=i.iouThreshold,r=i.scoreThreshold;let l=await Promise.all([a.data(),o.data()]),c=l[0],u=l[1],{selectedIndices:d}=U3(c,u,n,s,r);return a!==e&&a.dispose(),o!==t&&o.dispose(),Gt(d,"int32")}var wF=vF;function kF(e,t,n,s=.5,r=Number.NEGATIVE_INFINITY,a=0){let o=R(e,"boxes","nonMaxSuppression"),i=R(t,"scores","nonMaxSuppression"),l=mu(o,i,n,s,r,a);n=l.maxOutputSize,s=l.iouThreshold,r=l.scoreThreshold,a=l.softNmsSigma;let c={boxes:o,scores:i},u={maxOutputSize:n,iouThreshold:s,scoreThreshold:r,softNmsSigma:a},d=B.runKernel(Tl,c,u);return{selectedIndices:d[0],selectedScores:d[1]}}var IF=W({nonMaxSuppressionWithScore_:kF});async function SF(e,t,n,s=.5,r=Number.NEGATIVE_INFINITY,a=0){let o=R(e,"boxes","nonMaxSuppressionAsync"),i=R(t,"scores","nonMaxSuppressionAsync"),l=mu(o,i,n,s,r,a);n=l.maxOutputSize,s=l.iouThreshold,r=l.scoreThreshold,a=l.softNmsSigma;let c=await Promise.all([o.data(),i.data()]),u=c[0],d=c[1],{selectedIndices:p,selectedScores:h}=H3(u,d,n,s,r,a);return o!==e&&o.dispose(),i!==t&&i.dispose(),{selectedIndices:Gt(p,"int32"),selectedScores:Gt(h)}}var CF=SF;function TF(e,t,n,s=.5,r=Number.NEGATIVE_INFINITY,a=!1){let o=R(e,"boxes","nonMaxSuppression"),i=R(t,"scores","nonMaxSuppression"),l=mu(o,i,n,s,r,null),c=l.maxOutputSize,u=l.iouThreshold,d=l.scoreThreshold,p={boxes:o,scores:i},h={maxOutputSize:c,iouThreshold:u,scoreThreshold:d,padToMaxOutputSize:a},f=B.runKernel(Cl,p,h);return{selectedIndices:f[0],validOutputs:f[1]}}var NF=W({nonMaxSuppressionPadded_:TF});async function EF(e,t,n,s=.5,r=Number.NEGATIVE_INFINITY,a=!1){let o=R(e,"boxes","nonMaxSuppressionAsync"),i=R(t,"scores","nonMaxSuppressionAsync"),l=mu(o,i,n,s,r,null),c=l.maxOutputSize,u=l.iouThreshold,d=l.scoreThreshold,[p,h]=await Promise.all([o.data(),i.data()]),{selectedIndices:f,validOutputs:m}=G3(p,h,c,u,d,a);return o!==e&&o.dispose(),i!==t&&i.dispose(),{selectedIndices:Gt(f,"int32"),validOutputs:Ee(m,"int32")}}var RF=EF;function DF(e,t,n=!1,s=!1){let r=R(e,"images","resizeBilinear");$(r.rank===3||r.rank===4,()=>`Error in resizeBilinear: x must be rank 3 or 4, but got rank ${r.rank}.`),$(t.length===2,()=>`Error in resizeBilinear: new shape must 2D, but got shape ${t}.`),$(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},c=B.runKernel(Do,i,l);return o?V(c,[c.shape[1],c.shape[2],c.shape[3]]):c}var q3=W({resizeBilinear_:DF});function _F(e,t,n=!1,s=!1){let r=R(e,"images","resizeNearestNeighbor");$(r.rank===3||r.rank===4,()=>`Error in resizeNearestNeighbor: x must be rank 3 or 4, but got rank ${r.rank}.`),$(t.length===2,()=>`Error in resizeNearestNeighbor: new shape must 2D, but got shape ${t}.`),$(r.dtype==="float32"||r.dtype==="int32",()=>"`images` must have `int32` or `float32` as dtype"),$(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},c=B.runKernel(Tc,i,l);return o?V(c,[c.shape[1],c.shape[2],c.shape[3]]):c}var X3=W({resizeNearestNeighbor_:_F});function FF(e,t="binary",n=!1,s=.5){let r=R(e,"image","threshold"),a=.2989,o=.587,i=.114,l=r.shape[0]*r.shape[1],c=L(Gt([s]),255),u,d,p,h;if($(r.rank===3,()=>`Error in threshold: image must be rank 3,but got rank ${r.rank}.`),$(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]}.`),$(r.dtype==="int32"||r.dtype==="float32",()=>`Error in dtype: image dtype must be int32 or float32,but got dtype ${r.dtype}.`),$(t==="otsu"||t==="binary",()=>`Method must be binary or otsu, but was ${t}`),r.shape[2]===3){[u,d,p]=on(r,[1,1,1],-1);let g=L(u,a),A=L(d,o),y=L(p,i);h=le(le(g,A),y)}else h=e;if(t==="otsu"){let g=TA(de(Zh(h),"int32"),zt([]),256);c=$F(g,l)}let f=n?ba(h,c):qn(h,c);return de(L(f,255),"int32")}function $F(e,t){let n=Gt([-1]),s=Gt([0]),r=Gt([0]),a,o,i,l,c,u;for(let d=0;d<e.size-1;d++){a=Fe(e,0,d+1),o=Fe(e,d+1),c=fe(Ie(a),t),u=fe(Ie(o),t);let p=Ie(L(a,du(0,a.size)));i=fe(p,Ie(a));let h=iu(o.shape,a.size),f=le(du(0,o.size),h),m=L(o,f);l=fe(Ie(m),Ie(o));let g=be(i,l),A=be(i,l),y=L(c,u);r=L(L(y,g),A);let x=qn(r,s);s=In(x,r,s),n=In(x,Gt([d]),n)}return n}var OF=W({threshold_:FF});function PF(e,t,n="nearest",s="constant",r=0,a){let o=R(e,"image","transform","float32"),i=R(t,"transforms","transform","float32");$(o.rank===4,()=>`Error in transform: image must be rank 4,but got rank ${o.rank}.`),$(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"),$(a==null||a.length===2,()=>`Error in transform: outputShape must be [height, width] or null, but got ${a}.`);let l={image:o,transforms:i},c={interpolation:n,fillMode:s,fillValue:r,outputShape:a};return B.runKernel(Gl,l,c)}var MF=W({transform_:PF});function zF(e,t,n){$(t%1==0,()=>`bandPart(): numLower must be an integer, got ${t}.`),$(n%1==0,()=>`bandPart(): numUpper must be an integer, got ${n}.`);let s=R(e,"a","bandPart");$(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(du(0,a,1,"int32"),[-1,1]),l=du(0,o,1,"int32"),c=be(i,l),u=Ps(ba(c,Ee(+t,"int32")),xa(c,Ee(-n,"int32"))),d=Ut([a,o],s.dtype);return V(gn(Dn(V(s,[-1,a,o])).map(p=>In(u,p,d))),r)}var LF=W({bandPart_:zF});function BF(e){let t;if(Array.isArray(e)){t=!1,$(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)$(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=on(e,e.shape[0],0).map(r=>rt(r,[0]));$(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(B.tidy(()=>{let a=s[r];if(r>0)for(let o=0;o<r;++o){let i=L(Ie(L(n[o],a)),n[o]);a=be(a,i)}return fe(a,of(a,"euclidean"))}));return t?gn(n,0):n}var WF=W({gramSchmidt_:BF});function VF(e,t=!1){if($(e.rank>=2,()=>`qr() requires input tensor to have a rank >= 2, but got rank ${e.rank}`),e.rank===2)return K3(e,t);{let n=e.shape.slice(0,e.shape.length-2).reduce((l,c)=>l*c),s=Dn(V(e,[n,e.shape[e.shape.length-2],e.shape[e.shape.length-1]]),0),r=[],a=[];s.forEach(l=>{let[c,u]=K3(l,t);r.push(c),a.push(u)});let o=V(gn(r,0),e.shape),i=V(gn(a,0),e.shape);return[o,i]}}function K3(e,t=!1){return B.tidy(()=>{$(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=PA(n),a=Xs(e),o=Ys([[1]],[1,1]),i=Xs(o),l=n>=s?s:n;for(let c=0;c<l;++c){let u=a,d=i,p=r;[i,a,r]=B.tidy(()=>{let h=Fe(a,[c,c],[n-c,1]),f=of(h),m=Fe(a,[c,c],[1,1]),g=In(qn(m,0),Ys([[-1]]),Ys([[1]])),A=be(m,L(g,f)),y=fe(h,A);y.shape[0]===1?i=Xs(o):i=mt([o,Fe(y,[1,0],[y.shape[0]-1,y.shape[1]])],0);let x=Ct(fe(Ve(g,A),f)),b=Fe(a,[c,0],[n-c,s]),v=L(x,i),S=Ke(i);if(c===0)a=be(b,Ve(v,Ve(S,b)));else{let O=be(b,Ve(v,Ve(S,b)));a=mt([Fe(a,[0,0],[c,s]),O],0)}let T=Ke(v),_=Fe(r,[0,c],[n,r.shape[1]-c]);if(c===0)r=be(_,Ve(Ve(_,i),T));else{let O=be(_,Ve(Ve(_,i),T));r=mt([Fe(r,[0,0],[n,c]),O],1)}return[i,a,r]}),Z([u,d,p])}return!t&&n>s&&(r=Fe(r,[0,0],[n,s]),a=Fe(a,[0,0],[s,s])),[r,a]})}var UF=W({qr_:VF}),_n;(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"})(_n||(_n={}));function GF(e,t,n=_n.SUM_BY_NONZERO_WEIGHTS){let s=R(e,"losses","computeWeightedLoss"),r=null;t!=null&&(r=R(t,"weights","computeWeightedLoss"));let a=r==null?s:L(s,r);if(n===_n.NONE)return a;if(n===_n.SUM)return Ie(a);if(n===_n.MEAN){if(r==null)return _t(a);{let o=s.size/r.size,i=fe(Ie(a),Ie(r));return o>1?fe(i,Ee(o)):i}}if(n===_n.SUM_BY_NONZERO_WEIGHTS){if(r==null)return fe(Ie(a),Ee(s.size));{let o=L(r,as(s.shape)),i=de(Ie(ii(o,Ee(0))),"float32");return fe(Ie(a),i)}}throw Error(`Unknown reduction: ${n}`)}var Lr=W({computeWeightedLoss_:GF});function HF(e,t,n,s=_n.SUM_BY_NONZERO_WEIGHTS){let r=R(e,"labels","absoluteDifference"),a=R(t,"predictions","absoluteDifference"),o=null;n!=null&&(o=R(n,"weights","absoluteDifference")),Tn(r.shape,a.shape,"Error in absoluteDifference: ");let i=Vt(be(r,a));return Lr(i,o,s)}var jF=W({absoluteDifference_:HF});function qF(e,t,n,s,r=_n.SUM_BY_NONZERO_WEIGHTS){let a=R(e,"labels","cosineDistance"),o=R(t,"predictions","cosineDistance"),i=null;s!=null&&(i=R(s,"weights","cosineDistance")),Tn(a.shape,o.shape,"Error in cosineDistance: ");let l=Ee(1),c=be(l,Ie(L(a,o),n,!0));return Lr(c,i,r)}var XF=W({cosineDistance_:qF});function KF(e,t,n,s=_n.SUM_BY_NONZERO_WEIGHTS){let r=R(e,"labels","hingeLoss"),a=R(t,"predictions","hingeLoss"),o=null;n!=null&&(o=R(n,"weights","hingeLoss")),Tn(r.shape,a.shape,"Error in hingeLoss: ");let i=Ee(1);r=be(L(Ee(2),r),i);let l=Zs(be(i,L(r,a)));return Lr(l,o,s)}var ZF=W({hingeLoss_:KF});function YF(e,t,n,s=1,r=_n.SUM_BY_NONZERO_WEIGHTS){let a=R(e,"labels","huberLoss"),o=R(t,"predictions","huberLoss"),i=null;n!=null&&(i=R(n,"weights","huberLoss")),Tn(a.shape,o.shape,"Error in huberLoss: ");let l=Ee(s),c=Vt(be(o,a)),u=uu(c,l),d=be(c,u),p=le(L(Ee(.5),ht(u)),L(l,d));return Lr(p,i,r)}var JF=W({huberLoss_:YF});function QF(e,t,n,s=1e-7,r=_n.SUM_BY_NONZERO_WEIGHTS){let a=R(e,"labels","logLoss"),o=R(t,"predictions","logLoss"),i=null;n!=null&&(i=R(n,"weights","logLoss")),Tn(a.shape,o.shape,"Error in logLoss: ");let l=Ee(1),c=Ee(s),u=Ct(L(a,rs(le(o,c)))),d=L(be(l,a),rs(le(be(l,o),c))),p=be(u,d);return Lr(p,i,r)}var e$=W({logLoss_:QF});function t$(e,t,n,s=_n.SUM_BY_NONZERO_WEIGHTS){let r=R(e,"labels","meanSquaredError"),a=R(t,"predictions","meanSquaredError"),o=null;n!=null&&(o=R(n,"weights","meanSquaredError")),Tn(r.shape,a.shape,"Error in meanSquaredError: ");let i=sf(r,a);return Lr(i,o,s)}var n$=W({meanSquaredError_:t$});function s$(e,t){let n=R(e,"labels","sigmoidCrossEntropyWithLogits"),s=R(t,"logits","sigmoidCrossEntropyWithLogits");Tn(n.shape,s.shape,"Error in sigmoidCrossEntropyWithLogits: ");let r=Zs(s),a=L(s,n),o=Kc(ss(Ct(Vt(s))));return le(be(r,a),o)}function r$(e,t,n,s=0,r=_n.SUM_BY_NONZERO_WEIGHTS){let a=R(e,"multiClassLabels","sigmoidCrossEntropy"),o=R(t,"logits","sigmoidCrossEntropy"),i=null;if(n!=null&&(i=R(n,"weights","sigmoidCrossEntropy")),Tn(a.shape,o.shape,"Error in sigmoidCrossEntropy: "),s>0){let c=Ee(s),u=Ee(1),d=Ee(.5);a=le(L(a,be(u,c)),L(d,c))}let l=s$(a,o);return Lr(l,i,r)}var a$=W({sigmoidCrossEntropy_:r$});function o$(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 yr((r,a,o)=>{let l=WA(a,[n],!0),c=be(de(a,"float32"),l);o([r,c]);let u=Ct(L(c,r));return{value:Ie(u,[n]),gradFunc:(h,f)=>{let[m,g]=f,A=oi(h.shape,[n]);return[L(V(h,A),be(de(m,"float32"),ss(g))),L(V(h,A),be(ss(g),de(m,"float32")))]}}})(e,t)}function i$(e,t,n,s=0,r=_n.SUM_BY_NONZERO_WEIGHTS){let a=R(e,"onehotLabels","softmaxCrossEntropy"),o=R(t,"logits","softmaxCrossEntropy"),i=null;if(n!=null&&(i=R(n,"weights","softmaxCrossEntropy")),Tn(a.shape,o.shape,"Error in softmaxCrossEntropy: "),s>0){let c=Ee(s),u=Ee(1),d=Ee(a.shape[1]);a=le(L(a,be(u,c)),fe(c,d))}let l=o$(a,o);return Lr(l,i,r)}var l$=W({softmaxCrossEntropy_:i$});function u$(e,t,n,s){let r=R(e,"indices","sparseFillEmptyRows"),a=R(t,"values","sparseFillEmptyRows"),o=R(n,"denseShape","sparseFillEmptyRows"),i=R(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},c=B.runKernel(hh,l);return{outputIndices:c[0],outputValues:c[1],emptyRowIndicator:c[2],reverseIndexMap:c[3]}}var c$=W({sparseFillEmptyRows_:u$});function d$(e,t,n){let s=R(e,"inputIndices","sparseReshape"),r=R(t,"inputShape","sparseReshape"),a=R(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=B.runKernel(fh,o);return{outputIndices:i[0],outputShape:i[1]}}var p$=W({sparseReshape_:d$});function h$(e,t,n){let s=R(e,"data","sparseSegmentMean"),r=R(t,"indices","sparseSegmentMean"),a=R(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 B.runKernel(mh,o)}var f$=W({sparseSegmentMean_:h$});function m$(e,t,n){let s=R(e,"data","sparseSegmentSum"),r=R(t,"indices","sparseSegmentSum"),a=R(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 B.runKernel(gh,o)}var g$=W({sparseSegmentSum_:m$});function A$(e,t,n,s,r,a,o,i){let l=R(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 c=R(t,"dataSplits","stringNGrams");if(c.dtype!=="int32")throw new Error("Data splits must be of datatype int32");let u={separator:n,nGramWidths:s,leftPad:r,rightPad:a,padWidth:o,preserveShortSequences:i},d={data:l,dataSplits:c},p=B.runKernel(yh,d,u);return{nGrams:p[0],nGramsSplits:p[1]}}var y$=W({stringNGrams_:A$});function x$(e,t,n=!0){let s=R(e,"input","stringSplit","string"),r=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=B.runKernel(xh,o,a);return{indices:i[0],values:i[1],shape:i[2]}}var b$=W({stringSplit_:x$});function v$(e,t){let n=R(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 B.runKernel(bh,r,s)}var w$=W({stringToHashBucketFast_:v$}),k$={fft:sd,ifft:hu,rfft:rd,irfft:nf},I$={hammingWindow:eF,hannWindow:W3,frame:V3,stft:rF},_e={flipLeftRight:lF,grayscaleToRGB:cF,resizeNearestNeighbor:X3,resizeBilinear:q3,rotateWithOffset:pF,cropAndResize:oF,nonMaxSuppression:fF,nonMaxSuppressionAsync:wF,nonMaxSuppressionWithScore:IF,nonMaxSuppressionWithScoreAsync:CF,nonMaxSuppressionPadded:NF,nonMaxSuppressionPaddedAsync:RF,threshold:OF,transform:MF},Z3={bandPart:LF,gramSchmidt:WF,qr:UF},S$={absoluteDifference:jF,computeWeightedLoss:Lr,cosineDistance:XF,hingeLoss:ZF,huberLoss:JF,logLoss:e$,meanSquaredError:n$,sigmoidCrossEntropy:a$,softmaxCrossEntropy:l$},ad={sparseFillEmptyRows:c$,sparseReshape:p$,sparseSegmentMean:f$,sparseSegmentSum:g$},pf={stringNGrams:y$,stringSplit:b$,stringToHashBucketFast:w$},Br=class extends Yb{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 v3(e,t)}dispose(){this.iterations_!=null&&Z(this.iterations_)}async saveIterations(){return this.iterations_==null&&(this.iterations_=0),{name:"iter",tensor:Ee(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(Br,Symbol.hasInstance,{value:e=>e.minimize!=null&&e.computeGradients!=null&&e.applyGradients!=null});var hf=class extends Br{constructor(e,t,n=null){super();this.learningRate=e,this.rho=t,this.epsilon=n,this.accumulatedGrads=[],this.accumulatedUpdates=[],n==null&&(this.epsilon=B.backend.epsilon())}applyGradients(e){(Array.isArray(e)?e.map(n=>n.name):Object.keys(e)).forEach((n,s)=>{let r=B.registeredVariables[n],a=!1;this.accumulatedGrads[s]==null&&(this.accumulatedGrads[s]={originalName:`${n}/accum_grad`,variable:G(()=>Ze(r).variable(a))}),this.accumulatedUpdates[s]==null&&(this.accumulatedUpdates[s]={originalName:`${n}/accum_var`,variable:G(()=>Ze(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;G(()=>{let c=le(L(i,this.rho),L(ht(o),1-this.rho)),u=L(fe(mn(le(l,this.epsilon)),mn(le(i,this.epsilon))),o),d=le(L(l,this.rho),L(ht(u),1-this.rho));i.assign(c),l.assign(d);let p=le(L(u,-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)}};hf.className="Adadelta";Aa(hf);var ff=class extends Br{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=B.registeredVariables[n];if(this.accumulatedGrads[s]==null){let i=!1;this.accumulatedGrads[s]={originalName:`${n}/accumulator`,variable:G(()=>iu(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;G(()=>{let i=le(o,ht(a));o.assign(i);let l=le(L(fe(a,mn(le(i,B.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)}};ff.className="Adagrad";Aa(ff);var mf=class extends Br{constructor(e,t,n,s=null){super();this.learningRate=e,this.beta1=t,this.beta2=n,this.epsilon=s,this.accumulatedFirstMoment=[],this.accumulatedSecondMoment=[],G(()=>{this.accBeta1=Ee(t).variable(),this.accBeta2=Ee(n).variable()}),s==null&&(this.epsilon=B.backend.epsilon())}applyGradients(e){let t=Array.isArray(e)?e.map(n=>n.name):Object.keys(e);G(()=>{let n=be(1,this.accBeta1),s=be(1,this.accBeta2);t.forEach((r,a)=>{let o=B.registeredVariables[r],i=!1;this.accumulatedFirstMoment[a]==null&&(this.accumulatedFirstMoment[a]={originalName:`${r}/m`,variable:G(()=>Ze(o).variable(i))}),this.accumulatedSecondMoment[a]==null&&(this.accumulatedSecondMoment[a]={originalName:`${r}/v`,variable:G(()=>Ze(o).variable(i))});let l=Array.isArray(e)?e[a].tensor:e[r];if(l==null)return;let c=this.accumulatedFirstMoment[a].variable,u=this.accumulatedSecondMoment[a].variable,d=le(L(c,this.beta1),L(l,1-this.beta1)),p=le(L(u,this.beta2),L(ht(l),1-this.beta2)),h=fe(d,n),f=fe(p,s);c.assign(d),u.assign(p);let m=le(L(fe(h,le(mn(f),this.epsilon)),-this.learningRate),o);o.assign(m)}),this.accBeta1.assign(L(this.accBeta1,this.beta1)),this.accBeta2.assign(L(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),G(()=>{this.accBeta1.assign(zr(this.beta1,this.iterations_+1)),this.accBeta2.assign(zr(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)}};mf.className="Adam";Aa(mf);var gf=class extends Br{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=[],G(()=>{this.iteration=Ee(0).variable(),this.accBeta1=Ee(t).variable()}),s==null&&(this.epsilon=B.backend.epsilon())}applyGradients(e){let t=Array.isArray(e)?e.map(n=>n.name):Object.keys(e);G(()=>{let n=be(1,this.accBeta1),s=fe(-this.learningRate,le(L(this.iteration,this.decay),1));t.forEach((r,a)=>{let o=B.registeredVariables[r],i=!1;this.accumulatedFirstMoment[a]==null&&(this.accumulatedFirstMoment[a]={originalName:`${r}/m`,variable:Ze(o).variable(i)}),this.accumulatedWeightedInfNorm[a]==null&&(this.accumulatedWeightedInfNorm[a]={originalName:`${r}/v`,variable:Ze(o).variable(i)});let l=Array.isArray(e)?e[a].tensor:e[r];if(l==null)return;let c=this.accumulatedFirstMoment[a].variable,u=this.accumulatedWeightedInfNorm[a].variable,d=le(L(c,this.beta1),L(l,1-this.beta1)),p=L(u,this.beta2),h=Vt(l),f=xr(p,h);c.assign(d),u.assign(f);let m=le(L(fe(s,n),fe(d,le(f,this.epsilon))),o);o.assign(m)}),this.iteration.assign(le(this.iteration,1)),this.accBeta1.assign(L(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)}};gf.className="Adamax";Aa(gf);var od=class extends Br{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=B.registeredVariables[n];G(()=>{let o=le(L(this.c,r),a);a.assign(o)})}),this.incrementIterations()}setLearningRate(e){this.learningRate=e,this.c!=null&&this.c.dispose(),this.c=an(Ee(-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)}};od.className="SGD";Aa(od);var Af=class extends od{constructor(e,t,n=!1){super(e);this.learningRate=e,this.momentum=t,this.useNesterov=n,this.accumulations=[],this.m=Ee(this.momentum)}applyGradients(e){(Array.isArray(e)?e.map(n=>n.name):Object.keys(e)).forEach((n,s)=>{let r=B.registeredVariables[n];if(this.accumulations[s]==null){let i=!1;this.accumulations[s]={originalName:`${n}/momentum`,variable:G(()=>Ze(r).variable(i))}}let a=this.accumulations[s].variable,o=Array.isArray(e)?e[s].tensor:e[n];o!=null&&G(()=>{let i,l=le(L(this.m,a),o);this.useNesterov?i=le(L(this.c,le(o,L(l,this.m))),r):i=le(L(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)}};Af.className="Momentum";Aa(Af);var yf=class extends Br{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=B.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=B.registeredVariables[n],a=!1;this.accumulatedMeanSquares[s]==null&&(this.accumulatedMeanSquares[s]={originalName:`${n}/rms`,variable:G(()=>Ze(r).variable(a))}),this.accumulatedMoments[s]==null&&(this.accumulatedMoments[s]={originalName:`${n}/momentum`,variable:G(()=>Ze(r).variable(a))}),this.accumulatedMeanGrads[s]==null&&this.centered&&(this.accumulatedMeanGrads[s]={originalName:`${n}/mg`,variable:G(()=>Ze(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;G(()=>{let c=le(L(i,this.decay),L(ht(o),1-this.decay));if(this.centered){let u=this.accumulatedMeanGrads[s].variable,d=le(L(u,this.decay),L(o,1-this.decay)),p=fe(L(o,this.learningRate),mn(be(c,le(ht(d),this.epsilon)))),h=le(L(l,this.momentum),p);i.assign(c),u.assign(d),l.assign(h);let f=be(r,h);r.assign(f)}else{let u=le(L(i,this.decay),L(ht(o),1-this.decay)),d=le(L(l,this.momentum),fe(L(o,this.learningRate),mn(le(u,this.epsilon))));i.assign(u),l.assign(d);let p=be(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)}};yf.className="RMSProp";Aa(yf);var ui=class{static sgd(e){return new od(e)}static momentum(e,t,n=!1){return new Af(e,t,n)}static rmsprop(e,t=.9,n=0,s=null,r=!1){return new yf(e,t,n,s,r)}static adam(e=.001,t=.9,n=.999,s=null){return new mf(e,t,n,s)}static adadelta(e=.001,t=.95,n=null){return new hf(e,t,n)}static adamax(e=.002,t=.9,n=.999,s=null,r=0){return new gf(e,t,n,s,r)}static adagrad(e,t=.1){return new ff(e,t)}},ci={sgd:ui.sgd,momentum:ui.momentum,adadelta:ui.adadelta,adagrad:ui.adagrad,rmsprop:ui.rmsprop,adamax:ui.adamax,adam:ui.adam},C$=(()=>typeof requestAnimationFrame!="undefined"?requestAnimationFrame:typeof setImmediate!="undefined"?setImmediate:e=>e())();function Y3(){return new Promise(e=>C$(()=>e()))}var N={};ze(N,{ERF_A1:()=>M$,ERF_A2:()=>z$,ERF_A3:()=>L$,ERF_A4:()=>B$,ERF_A5:()=>W$,ERF_P:()=>P$,PARALLELIZE_THRESHOLD:()=>o1,SELU_SCALE:()=>Q3,SELU_SCALEALPHA:()=>J3,applyActivation:()=>cf,assertAndGetBroadcastShape:()=>xt,assertAxesAreInnerMostDims:()=>VR,assertParamsConsistent:()=>T$,assignToTypedArray:()=>q$,axesAreInnerMostDims:()=>LA,calculateShapes:()=>Lb,checkEinsumDimSizes:()=>Q$,combineLocations:()=>k3,complexWithEvenIndex:()=>G$,complexWithOddIndex:()=>H$,computeConv2DInfo:()=>Gc,computeConv3DInfo:()=>r3,computeDefaultPad:()=>IA,computeDilation2DInfo:()=>dE,computeOptimalWindowSize:()=>E$,computeOutAndReduceShapes:()=>I3,computeOutShape:()=>N$,computePool2DInfo:()=>s3,computePool3DInfo:()=>pE,convertConv2DDataFormat:()=>a3,decodeEinsumEquation:()=>Y$,eitherStridesOrDilationsAreOne:()=>Ar,expandShapeToKeepDim:()=>oi,exponent:()=>K$,exponents:()=>X$,fromStringArrayToUint8:()=>lO,fromUint8ToStringArray:()=>iO,getAxesPermutation:()=>S3,getBroadcastDims:()=>sR,getComplexWithIndex:()=>j$,getEinsumComputePath:()=>eO,getEinsumPermutation:()=>J$,getFusedBiasGradient:()=>uf,getFusedDyActivation:()=>lf,getImageCenter:()=>R$,getInnerMostAxes:()=>UR,getPermuted:()=>_$,getReductionAxes:()=>Yt,getReshaped:()=>D$,getReshapedPermuted:()=>F$,getSliceBeginCoords:()=>$$,getSliceSize:()=>O$,getUndoAxesPermutation:()=>BA,isIdentityPermutation:()=>tO,log:()=>LT,mergeRealAndImagArrays:()=>V$,prepareAndValidate:()=>zb,prepareSplitSize:()=>sO,segment_util:()=>nv,shouldFuse:()=>df,slice_util:()=>En,splitRealAndImagArrays:()=>U$,tupleValuesAreOne:()=>ya,upcastType:()=>$s,validateInput:()=>cA,validateUpdateShape:()=>uA,warn:()=>pr});function T$(e,t){let n=e[0].length;e.forEach((r,a)=>{$(r.length===n,()=>`Error in concat${n}D: rank of tensors[${a}] must be the same as the rank of the rest (${n})`)}),$(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++)$(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 N$(e,t){let n=e[0].slice();for(let s=1;s<e.length;s++)n[t]+=e[s][t];return n}var o1=30;function E$(e){return e<=o1?e:Mp(e,Math.floor(Math.sqrt(e)))}function R$(e,t,n){let s=n*(typeof e=="number"?e:e[0]),r=t*(typeof e=="number"?e:e[1]);return[s,r]}function D$(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 _$(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 F$(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 $$(e,t){let n=[0];for(let s=0;s<t;++s)n.push(e[s][0]);return n}function O$(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 J3=1.7580993408473768,Q3=1.0507009873554805,P$=.3275911,M$=.254829592,z$=-.284496736,L$=1.421413741,B$=-1.453152027,W$=1.061405429;function V$(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 U$(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 G$(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 H$(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 j$(e,t){let n=e[t*2],s=e[t*2+1];return{real:n,imag:s}}function q$(e,t,n,s){e[s*2]=t,e[s*2+1]=n}function X$(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 K$(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 i1="->",Z$=/->/g,ev=",",tv="...";function Y$(e,t){e=e.replace(/\s/g,"");let n=(e.length-e.replace(Z$,"").length)/i1.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 ("${i1}").`);let[s,r]=e.split(i1);$(s.indexOf(tv)===-1,()=>`The ellipsis notation ("${tv}") is not supported yet.`);let a=s.split(ev),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!==ev&&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 c=i.length,u=r.length,d=[];for(let p=u;p<c;++p)d.push(p);return{allDims:i,summedDims:d,idDims:l}}function J$(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 Q$(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]:$(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 eO(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=nO(t,i);for(let c of l)a.indexOf(c)===-1&&(s[o].push(c),a.push(c))}return{path:n,steps:s}}function tO(e){return e.every((t,n)=>t===n)}function nO(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 sO(e,t,n=0){let s=[];if(typeof t=="number")$(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);$(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}$(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 nv={};ze(nv,{collectGatherOpShapeInfo:()=>oO,computeOutShape:()=>aO,segOpComputeOptimalWindowSize:()=>rO});function rO(e,t){let n=!1,s;for(e<=o1?(s=e,n=!0):s=Mp(e,Math.floor(Math.sqrt(e)));!n;)s>t||s===e?n=!0:s=Mp(e,s+1);return s}function aO(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 oO(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,c=1,u=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]),c*=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]),u*=e.shape[d];return{batchSize:l,sliceSize:u,outerSize:c,dimSize:o,outputShape:i}}function iO(e){try{return e.map(t=>Ch(t))}catch(t){throw new Error(`Failed to decode encoded string bytes into utf-8, error: ${t}`)}}function lO(e){return e.map(t=>Fc(t))}var br={};ze(br,{nonMaxSuppressionV3Impl:()=>U3,nonMaxSuppressionV4Impl:()=>G3,nonMaxSuppressionV5Impl:()=>H3,whereImpl:()=>F3});var sv={kernelName:qi,inputsToSave:["x"],gradFunc:(e,t)=>{let[n]=t;return{x:()=>L(e,fu(de(n,"float32"),-1))}}},uO={kernelName:Xi,inputsToSave:["x"],gradFunc:(e,t)=>{let[n]=t;return{x:()=>{let s=ht(de(n,"float32")),r=mn(be(Ee(1),s));return Ct(fe(e,r))}}}},cO={kernelName:Ki,inputsToSave:["x"],gradFunc:(e,t)=>{let[n]=t;return{x:()=>{let s=mn(be(ht(de(n,"float32")),1));return fe(e,s)}}}},dO={kernelName:la,inputsToSave:["a","b"],gradFunc:(e,t)=>{let[n,s]=t,r=xt(n.shape,s.shape);return{a:()=>{let i=e,l=Yt(n.shape,r);return l.length>0&&(i=Ie(i,l)),V(i,n.shape)},b:()=>{let i=e,l=Yt(s.shape,r);return l.length>0&&(i=Ie(i,l)),V(i,s.shape)}}}},pO={kernelName:Ka,saveAllInputs:!0,gradFunc:(e,t)=>{let n={};return t.forEach((s,r)=>{n[r]=()=>e.clone()}),n}},hO={kernelName:Za,inputsToSave:["x"],gradFunc:(e,t)=>{let[n]=t;return{x:()=>Ze(n)}}},fO={kernelName:gc,inputsToSave:["x"],gradFunc:(e,t)=>{let[n]=t;return{x:()=>Ze(n)}}},mO={kernelName:Ji,inputsToSave:["x"],gradFunc:(e,t)=>{let[n]=t;return{x:()=>fe(e,mn(be(Ee(1),ht(de(n,"float32")))))}}},gO={kernelName:Qi,inputsToSave:["x"],gradFunc:(e,t)=>{let[n]=t;return{x:()=>{let s=mn(le(Ee(1),ht(de(n,"float32"))));return fe(e,s)}}}},AO={kernelName:nl,inputsToSave:["a","b"],gradFunc:(e,t)=>{let[n,s]=t,r=xt(n.shape,s.shape);return{a:()=>{let i=le(ht(n),ht(s)),l=L(e,fe(s,i)),c=Yt(n.shape,r);return c.length>0&&(l=Ie(l,c)),V(l,n.shape)},b:()=>{let i=le(ht(n),ht(s)),l=Ct(L(e,fe(n,i))),c=Yt(s.shape,r);return c.length>0&&(l=Ie(l,c)),V(l,s.shape)}}}},yO={kernelName:el,inputsToSave:["x"],gradFunc:(e,t)=>{let[n]=t;return{x:()=>fe(e,le(ht(de(n,"float32")),1))}}},xO={kernelName:tl,inputsToSave:["x"],gradFunc:(e,t)=>{let[n]=t;return{x:()=>fe(e,be(Ee(1),ht(de(n,"float32"))))}}};function bO(e,t,n,s,r,a){let o=R(e,"dy","avgPool3dGrad"),i=R(t,"input","avgPool3dGrad"),l=o,c=i,u=!1;i.rank===4&&(u=!0,l=V(o,[1,o.shape[0],o.shape[1],o.shape[2],o.shape[3]]),c=V(i,[1,i.shape[0],i.shape[1],i.shape[2],i.shape[3]])),$(l.rank===5,()=>`Error in avgPool3dGrad: dy must be rank 5 but got rank ${l.rank}.`),$(c.rank===5,()=>`Error in avgPool3dGrad: input must be rank 5 but got rank ${c.rank}.`),a!=null&&$(sn(r),()=>`Error in avgPool3dGrad: pad must be an integer when using, dimRoundingMode ${a} but got pad ${r}.`);let d={dy:l,input:c},p={filterSize:n,strides:s,pad:r,dimRoundingMode:a},h=B.runKernel(Bp,d,p);return u?V(h,[h.shape[1],h.shape[2],h.shape[3],h.shape[4]]):h}var vO=W({avgPool3dGrad_:bO}),wO={kernelName:Ac,inputsToSave:["x"],gradFunc:(e,t,n)=>{let[s]=t,{filterSize:r,strides:a,pad:o,dimRoundingMode:i}=n;return{x:()=>vO(e,s,r,a,o,i)}}};function kO(e,t,n,s,r){let a=R(e,"dy","avgPoolGrad"),o=R(t,"input","avgPoolGrad");$(o.rank===a.rank,()=>`Rank of input (${o.rank}) does not match rank of dy (${a.rank})`);let i=o,l=a,c=!1;o.rank===3&&(c=!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]])),$(l.rank===4,()=>`Error in avgPoolGrad: dy must be rank 4 but got rank ${l.rank}.`),$(i.rank===4,()=>`Error in avgPoolGrad: input must be rank 4 but got rank ${i.rank}.`);let u={dy:l,input:i},d={filterSize:n,strides:s,pad:r},p=B.runKernel(Lp,u,d);return c?V(p,[p.shape[1],p.shape[2],p.shape[3]]):p}var IO=W({avgPoolGrad_:kO}),SO={kernelName:Ya,inputsToSave:["x"],gradFunc:(e,t,n)=>{let[s]=t,{filterSize:r,strides:a,pad:o}=n;return{x:()=>IO(e,s,r,a,o)}}},CO={kernelName:Ja,inputsToSave:["a","b"],gradFunc:(e,t,n)=>{let[s,r]=t,{transposeA:a,transposeB:o}=n;return!a&&!o?{a:()=>Ve(e,r,!1,!0),b:()=>Ve(s,e,!0,!1)}:!a&&o?{a:()=>Ve(e,r,!1,!1),b:()=>Ve(e,s,!0,!1)}:a&&!o?{a:()=>Ve(r,e,!1,!0),b:()=>Ve(s,e,!1,!1)}:{a:()=>Ve(r,e,!0,!0),b:()=>Ve(e,s,!0,!0)}}},TO={kernelName:sl,gradFunc:(e,t,n)=>{let{blockShape:s,crops:r}=n;return{x:()=>Qc(e,s,r)}}},NO={kernelName:tb,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:()=>Ie(e,i,!0)}}},EO={kernelName:Qa,gradFunc:e=>({x:()=>e.clone()})},RO={kernelName:eo,gradFunc:e=>({x:()=>Ze(e)})},DO={kernelName:ua,inputsToSave:["x"],gradFunc:(e,t,n)=>{let[s]=t,{clipValueMin:r,clipValueMax:a}=n;return{x:()=>In(Ps(xa(s,r),ba(s,a)),e,Ze(e))}}},_O={kernelName:yc,inputsToSave:["x"],gradFunc:sv.gradFunc},FO={kernelName:rl,saveAllInputs:!0,gradFunc:(e,t,n)=>{let s=t.map(l=>l.shape),{axis:r}=n,a=Fs(r,t[0].shape)[0],o=s.map(l=>l[a]);return on(e,o,a).map(l=>()=>l)}},$O={kernelName:to,inputsToSave:["x","filter"],gradFunc:(e,t,n)=>{let[s,r]=t,{dilations:a,strides:o,pad:i,dataFormat:l}=n;return $(ya(a),()=>`Error in gradient of conv2D: dilation rates greater than 1 are not yet supported in gradients. Got dilations '${a}'`),{x:()=>EA(s.shape,e,r,o,i,l),filter:()=>r1(s,e,r.shape,o,i,l)}}},OO={kernelName:no,inputsToSave:["dy","filter"],gradFunc:(e,t,n)=>{let[s,r]=t,{strides:a,pad:o,dataFormat:i,dimRoundingMode:l}=n;return{dy:()=>Mr(e,r,a,o,i,1,l),filter:()=>r1(e,s,r.shape,a,o,i,l)}}};function PO(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]])),$(a.rank===5,()=>`Error in conv3dDerFilter: input must be rank 5, but got shape ${a.shape}.`),$(o.rank===5,()=>`Error in conv3dDerFilter: dy must be rank 5, but got shape ${o.shape}.`),$(n.length===5,()=>`Error in conv3dDerFilter: filterShape must be length 5, but got ${n}.`),$(a.shape[4]===n[3],()=>`Error in conv3dDerFilter: depth of input ${a.shape[4]}) must match input depth in filter (${n[3]}.`),$(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 B.runKernel(Hp,i,l)}var MO=W({conv3DBackpropFilter_:PO}),zO={kernelName:xc,inputsToSave:["x","filter"],gradFunc:(e,t,n)=>{let{dilations:s,strides:r,pad:a}=n;$(ya(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:()=>h3(o.shape,e,i,r,a),filter:()=>MO(o,e,i.shape,r,a)}}},LO={kernelName:so,inputsToSave:["x"],gradFunc:(e,t)=>{let[n]=t;return{x:()=>L(Ct(Qh(de(n,"float32"))),e)}}},BO={kernelName:ro,inputsToSave:["x"],gradFunc:(e,t)=>{let[n]=t;return{x:()=>L(ef(de(n,"float32")),e)}}},WO={kernelName:ao,inputsToSave:["x"],gradFunc:(e,t,n)=>{let[s]=t,{axis:r,exclusive:a,reverse:o}=n;return{x:()=>{let i=S3([r],s.rank),l=Wh(e,r,a,!o);return i!=null&&(l=Ke(l,i)),l}}}},VO={kernelName:oo,inputsToSave:["x","filter"],gradFunc:(e,t,n)=>{let{dilations:s,strides:r,pad:a,dimRoundingMode:o}=n,i=s??[1,1];$(ya(i),()=>`Error in gradient of depthwiseConv2dNative: dilation rates greater than 1 are not yet supported. Got dilations '${i}'`);let[l,c]=t;return $(l.rank===4,()=>`Error in gradient of depthwiseConv2dNative: input must be rank 4, but got rank ${l.rank}.`),$(c.rank===4,()=>`Error in gradient of depthwiseConv2dNative: filter must be rank 4, but got rank ${c.rank}.`),$(l.shape[3]===c.shape[2],()=>`Error in gradient of depthwiseConv2d: number of input channels (${l.shape[3]}) must match the inChannels dimension in filter ${c.shape[2]}.`),$(Ar(r,i),()=>`Error in gradient of depthwiseConv2d: Either strides or dilations must be 1. Got strides ${r} and dilations '${i}'.`),o!=null&&$(sn(a),()=>`Error in depthwiseConv2d: pad must be an integer when using, dimRoundingMode ${o} but got pad ${a}.`),{x:()=>B3(l.shape,e,c,r,a,i,o),filter:()=>L3(l,e,c.shape,r,a,i,o)}}},UO={kernelName:bc,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:()=>B.runKernel(Yp,a,n),filter:()=>B.runKernel(Jp,o,n)}}},GO={kernelName:lo,outputsToSave:[!0],gradFunc:(e,t)=>{let[n]=t,s={dy:e,y:n};return{x:()=>B.runKernel(eh,s)}}},HO={kernelName:il,inputsToSave:["x"],gradFunc:(e,t)=>{let[n]=t,s=L(ss(Ct(ht(n))),2/Math.sqrt(Math.PI));return{x:()=>L(e,s)}}},jO={kernelName:uo,outputsToSave:[!0],gradFunc:(e,t)=>{let[n]=t;return{x:()=>L(e,n)}}},qO={kernelName:ul,inputsToSave:["input"],gradFunc:(e,t)=>{let[n]=t;return{input:()=>V(e,n.shape)}}},XO={kernelName:cl,inputsToSave:["x"],gradFunc:(e,t)=>{let[n]=t;return{x:()=>L(e,ss(n))}}},KO={kernelName:co,gradFunc:e=>({x:()=>Ze(e)})},ZO={kernelName:po,inputsToSave:["a","b"],gradFunc:(e,t)=>{let[n,s]=t,r=xt(n.shape,s.shape);return{a:()=>{let i=fe(e,de(s,"float32")),l=Yt(n.shape,r);return l.length>0?V(Ie(i,l),n.shape):i},b:()=>{let i=L(e,de(n,"float32")),l=Yt(s.shape,r);l.length>0&&(i=V(Ie(i,l),s.shape));let c=ht(s);return Ct(fe(i,de(c,"float32")))}}}},YO={kernelName:ho,inputsToSave:["x","mean","variance","scale"],gradFunc:(e,t,n)=>{let{varianceEpsilon:s}=n,[r,a,o,i]=t,l=i??Ee(1),c=Yt(a.shape,r.shape),u=[];if(a.rank===1){for(let b=0;b<r.shape.length-1;++b)u.push(r.shape[b]);u.push(1)}let d=be(r,a),p=L(e,l),h=Yh(le(o,Ee(s))),f=L(L(L(h,h),h),Ee(-.5));return{x:()=>a.rank===1?V(L(L(e,bs(V(h,[1,1,1,a.shape[0]]),u)),l),r.shape):V(L(L(e,h),l),r.shape),mean:()=>{let b=L(L(h,Ee(-1)),p);return a.rank===1&&(b=Ie(b,c)),V(b,a.shape)},variance:()=>{let b=L(L(f,d),p);return a.rank===1&&(b=Ie(b,c)),V(b,a.shape)},scale:()=>{let b=L(d,h),v=L(e,b);return a.rank===1&&(v=Ie(v,c)),V(v,a.shape)},offset:()=>{let b=e;return a.rank===1&&(b=Ie(b,c)),V(b,a.shape)}}}},JO={kernelName:pl,inputsToSave:["x","indices"],gradFunc:(e,t,n)=>{let[s,r]=t,{axis:a}=n,o=Fs(a,s.shape)[0];return{x:()=>{let l=s.shape,c=r.size,u=l.slice(0,o),d=u.length,p=l.slice(a,l.length).slice(1),h=p.length,f=rv(0,d),m=rv(d+1,d+1+h),g=av([u,[c],p]),A=V(e,g),y=V(r,[c]),x=av([[d],f,m]),b=Ke(A,x),v=e1(b,y,s.shape[o]),S=BA(x);return v=Ke(v,S),v},indices:()=>r}}};function rv(e,t){let n=[];for(let s=e;s<t;++s)n.push(s);return n}function av(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 QO={kernelName:fo,inputsToSave:["a","b"],gradFunc:(e,t)=>{let[n,s]=t;return{a:()=>Ze(n),b:()=>Ze(s)}}},eP={kernelName:mo,gradFunc:e=>({x:()=>de(e,"float32")})},tP={kernelName:ml,gradFunc:e=>({x:()=>Ze(e)})},nP={kernelName:gl,gradFunc:e=>({x:()=>Ze(e)})},sP={kernelName:Al,gradFunc:e=>({x:()=>Ze(e)})},rP={kernelName:go,inputsToSave:["x"],gradFunc:(e,t,n)=>{let[s]=t,{alpha:r}=n,a=qn(s,0);return{x:()=>In(a,e,L(e,r))}}},aP={kernelName:bl,inputsToSave:["x"],gradFunc:(e,t)=>{let[n]=t;return{x:()=>fe(e,le(n,1))}}},oP={kernelName:Ao,inputsToSave:["x"],gradFunc:(e,t)=>{let[n]=t;return{x:()=>fe(e,de(n,"float32"))}}},iP={kernelName:nb,inputsToSave:[],outputsToSave:[!0],gradFunc:(e,t,n)=>{let[s]=t,{axis:r}=n;return{logits:()=>{let a=!0,o=ss(s);return be(e,L(Ie(e,r,a),o))}}}};function lP(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 B.runKernel(ah,i,l)}var uP=W({localResponseNormalizationBackprop_:lP}),cP={kernelName:Ic,inputsToSave:["x"],outputsToSave:[!0],gradFunc:(e,t,n)=>{let[s,r]=t,{depthRadius:a,bias:o,alpha:i,beta:l}=n;return{x:()=>uP(s,r,e,a,o,i,l)}}};function ov(e,t,n,s){return t.rank<n.rank&&(t=V(t,oi(t.shape,s))),e.rank<n.rank&&(e=V(e,oi(e.shape,s))),{x:()=>L(e,de(ns(n,t),e.dtype))}}var iv={kernelName:yo,inputsToSave:["x"],outputsToSave:[!0],gradFunc:(e,t,n)=>{let s=n,{reductionIndices:r}=s,a=t[0],o=t[1],i=Fs(r,a.shape),l=ov(e,o,a,i);return{x:()=>l.x()}}},dP={kernelName:xo,inputsToSave:["a","b"],gradFunc:(e,t)=>{let[n,s]=t;return{a:()=>L(e,de(xa(n,s),"float32")),b:()=>L(e,de(Uh(n,s),"float32"))}}};function pP(e,t,n,s,r,a,o){let i=R(e,"dy","maxPool3dGrad"),l=R(t,"input","maxPool3dGrad"),c=R(n,"output","maxPool3dGrad"),u=i,d=l,p=c,h=!1;l.rank===4&&(h=!0,u=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(c,[1,c.shape[0],c.shape[1],c.shape[2],c.shape[3]])),$(u.rank===5,()=>`Error in maxPool3dGrad: dy must be rank 5 but got rank ${u.rank}.`),$(d.rank===5,()=>`Error in maxPool3dGrad: input must be rank 5 but got rank ${d.rank}.`),$(p.rank===5,()=>`Error in maxPool3dGrad: output must be rank 5 but got rank ${p.rank}.`),o!=null&&$(sn(a),()=>`Error in maxPool3dGrad: pad must be an integer when using, dimRoundingMode ${o} but got pad ${a}.`);let f={dy:u,input:d,output:p},m={filterSize:s,strides:r,pad:a,dimRoundingMode:o},g=B.runKernel(ih,f,m);return h?V(g,[g.shape[1],g.shape[2],g.shape[3],g.shape[4]]):g}var hP=W({maxPool3dGrad_:pP}),fP={kernelName:Sc,inputsToSave:["x"],outputsToSave:[!0],gradFunc:(e,t,n)=>{let[s,r]=t,{filterSize:a,strides:o,pad:i,dimRoundingMode:l}=n;return{x:()=>hP(e,s,r,a,o,i,l)}}};function mP(e,t,n,s,r,a,o){let i=R(e,"dy","maxPoolGrad"),l=R(t,"input","maxPoolGrad"),c=R(n,"output","maxPoolGrad");$(l.rank===i.rank,()=>`Rank of input (${l.rank}) does not match rank of dy (${i.rank})`),$(i.rank===4,()=>`Error in maxPoolGrad: dy must be rank 4 but got rank ${i.rank}.`),$(l.rank===4,()=>`Error in maxPoolGrad: input must be rank 4 but got rank ${l.rank}.`),o!=null&&$(sn(a),()=>`Error in maxPoolGrad: pad must be an integer when using, dimRoundingMode ${o} but got pad ${a}.`);let u={dy:i,input:l,output:c},d={filterSize:s,strides:r,pad:a,dimRoundingMode:o};return B.runKernel(oh,u,d)}var gP=W({maxPoolGrad_:mP}),AP={kernelName:bo,inputsToSave:["x"],outputsToSave:[!0],gradFunc:(e,t,n)=>{let[s,r]=t,{filterSize:a,strides:o,pad:i}=n;return{x:()=>gP(e,s,r,a,o,i)}}},yP={kernelName:vo,inputsToSave:["x"],gradFunc:(e,t,n)=>{let[s]=t,{axis:r}=n,a=Fs(r,s.shape),i=I3(s.shape,a)[1],l=Mt(i);return{x:()=>{let u=s.shape.slice();a.forEach(h=>{u[h]=1});let d=V(e,u);return fe(L(d,as(s.shape,"float32")),l)}}}},xP={kernelName:wo,inputsToSave:["x"],outputsToSave:[!0],gradFunc:(e,t,n)=>{let s=n,{axis:r}=s,[a,o]=t,i=Fs(r,a.shape),l=ov(e,o,a,i);return{x:()=>l.x()}}},bP={kernelName:ko,inputsToSave:["a","b"],gradFunc:(e,t)=>{let[n,s]=t;return{a:()=>L(e,de(ba(n,s),"float32")),b:()=>L(e,de(qn(n,s),"float32"))}}},vP={kernelName:Io,inputsToSave:["x"],gradFunc:(e,t,n)=>{let s=t[0],{paddings:r}=n,a=r.map(o=>o[0]);return{x:()=>Fe(e,a,s.shape)}}},wP={kernelName:wl,inputsToSave:["a","b"],gradFunc:(e,t)=>{let[n,s]=t,r=xt(n.shape,s.shape);return{a:()=>{let i=Yt(n.shape,r);return i.length>0?V(Ie(e,i),n.shape):e},b:()=>{let i=L(e,Ct(lu(fe(n,s)))),l=Yt(s.shape,r);return l.length>0?V(Ie(i,l),s.shape):i}}}},kP={kernelName:So,inputsToSave:["a","b"],gradFunc:(e,t)=>{let[n,s]=t,r=xt(n.shape,s.shape);return{a:()=>{let i=L(e,de(s,"float32")),l=Yt(n.shape,r);return l.length>0?V(Ie(i,l),n.shape):i},b:()=>{let i=L(e,de(n,"float32")),l=Yt(s.shape,r);return l.length>0?V(Ie(i,l),s.shape):i}}}},IP={kernelName:kl,gradFunc:e=>({x:()=>Ct(e)})},SP={kernelName:Co,inputsToSave:["indices"],gradFunc:(e,t)=>{let n=t[0];return{indices:()=>Ut(n.shape,"float32")}}},CP={kernelName:Nl,gradFunc:e=>({x:()=>Ze(e)})},TP={kernelName:El,saveAllInputs:!0,gradFunc:(e,t,n)=>{let{axis:s}=n;return Dn(e,s).map(a=>()=>a)}},lv={kernelName:To,inputsToSave:["x"],gradFunc:(e,t,n)=>{let s=t[0],{paddings:r}=n,a=r.map(o=>o[0]);return{x:()=>Fe(e,a,s.shape)}}},NP={kernelName:No,inputsToSave:["a","b"],outputsToSave:[!0],gradFunc:(e,t)=>{let[n,s,r]=t,a=n,o=s,i=xt(a.shape,o.shape);return{a:()=>{let u=de(o,"float32"),d=L(e,L(u,zr(a,be(u,Ee(1))))),p=Yt(a.shape,i);return p.length>0&&(d=Ie(d,p)),V(d,a.shape)},b:()=>{let u=qn(a,0),d=In(u,rs(a),Ze(a)),p=L(e,L(r,d)),h=Yt(o.shape,i);return h.length>0&&(p=Ie(p,h)),V(p,o.shape)}}}},EP={kernelName:Eo,inputsToSave:["x","alpha"],gradFunc:(e,t)=>{let[n,s]=t,r=qn(n,0);return{x:()=>In(r,e,L(e,s)),alpha:()=>{let a=In(r,Ze(e),L(e,n)),o=Yt(s.shape,e.shape);return o.length>0&&(a=Ie(a,o)),V(a,s.shape)}}}},RP={kernelName:io,inputsToSave:["a","b"],gradFunc:(e,t)=>{let[n,s]=t,r=xt(n.shape,s.shape);return{a:()=>{let i=fe(e,de(s,"float32")),l=Yt(n.shape,r);return l.length>0?V(Ie(i,l),n.shape):i},b:()=>{let i=L(e,de(n,"float32")),l=Yt(s.shape,r);l.length>0&&(i=V(Ie(i,l),s.shape));let c=ht(s);return Ct(fe(i,de(c,"float32")))}}}},DP={kernelName:Dl,inputsToSave:["x"],gradFunc:(e,t)=>{let[n]=t;return{x:()=>fe(e,Ct(ht(n)))}}},_P={kernelName:_o,inputsToSave:["x"],gradFunc:(e,t)=>{let[n]=t,s=L(ba(n,6),fu(n));return{x:()=>L(e,de(s,"float32"))}}},FP={kernelName:Ro,inputsToSave:["x"],gradFunc:(e,t)=>{let[n]=t;return{x:()=>L(e,de(fu(n),"float32"))}}},$P={kernelName:_l,inputsToSave:["x"],gradFunc:(e,t)=>{let[n]=t;return{x:()=>V(e,n.shape)}}},OP={kernelName:Do,inputsToSave:["images"],gradFunc:(e,t,n)=>{let[s]=t,r={dy:e,images:s};return{images:()=>B.runKernel(ph,r,n)}}},PP={kernelName:Tc,inputsToSave:["images"],gradFunc:(e,t,n)=>{let[s]=t,r={dy:e,images:s};return{images:()=>B.runKernel(dh,r,n)}}},MP={kernelName:Fo,gradFunc:(e,t,n)=>{let{dims:s}=n,r=Fs(s,e.shape);return{x:()=>is(e,r)}}},zP={kernelName:$o,gradFunc:e=>({x:()=>Ze(e)})},LP={kernelName:Oo,inputsToSave:["x"],gradFunc:(e,t)=>{let[n]=t;return{x:()=>Ct(fe(e,L(zr(n,1.5),2)))}}},BP={kernelName:$l,inputsToSave:["condition"],gradFunc:(e,t)=>{let[n]=t;return{condition:()=>de(Ze(n),"float32"),t:()=>L(e,de(n,e.dtype)),e:()=>L(e,de(Zc(n),e.dtype))}}},WP={kernelName:Ol,inputsToSave:["x"],gradFunc:(e,t)=>{let[n]=t;return{x:()=>{let s=qn(n,Ee(0)),r=Ee(J3),a=Ee(Q3),o=L(e,a),i=L(L(e,r),ss(de(n,"float32")));return In(s,o,i)}}}},VP={kernelName:Mo,outputsToSave:[!0],gradFunc:(e,t)=>{let[n]=t;return{x:()=>L(e,L(n,be(Ee(1),n)))}}},UP={kernelName:zl,gradFunc:e=>({x:()=>Ze(e)})},GP={kernelName:Po,inputsToSave:["x"],gradFunc:(e,t)=>{let[n]=t;return{x:()=>L(qc(de(n,"float32")),e)}}},HP={kernelName:Ml,inputsToSave:["x"],gradFunc:(e,t)=>{let[n]=t;return{x:()=>L(Bh(de(n,"float32")),e)}}},jP={kernelName:Pl,inputsToSave:["x"],gradFunc:(e,t,n)=>{let[s]=t,{begin:r,size:a}=n,o=s.shape,[i,l]=Zb(s,r,a),c=[];for(let u=0;u<e.rank;u++)c.push([i[u],o[u]-i[u]-l[u]]);return{x:()=>vs(e,c)}}},qP={kernelName:Bo,outputsToSave:[!0],gradFunc:(e,t,n)=>{let[s]=t,{dim:r}=n,a=!0,o=L(e,s);return{logits:()=>be(o,L(Ie(o,[r],a),s))}}},XP={kernelName:Ll,inputsToSave:["x"],gradFunc:(e,t)=>{let[n]=t;return{x:()=>L(e,Hn(n))}}},uv={kernelName:Bl,gradFunc:(e,t,n)=>{let{blockShape:s,paddings:r}=n;return{x:()=>jc(e,s,r)}}},cv={kernelName:Wl,gradFunc:(e,t,n)=>{let{axis:s}=n;return{x:()=>mt(e,s)}}},KP={kernelName:zo,inputsToSave:["x"],gradFunc:(e,t)=>{let[n]=t;return{x:()=>fe(e,L(mn(de(n,"float32")),2))}}},ZP={kernelName:Nc,inputsToSave:["x"],gradFunc:(e,t)=>{let[n]=t;return{x:()=>L(e,L(de(n,"float32"),2))}}},YP={kernelName:Wo,inputsToSave:["a","b"],gradFunc:(e,t)=>{let[n,s]=t,r=Ee(2);return{a:()=>L(e,L(r,be(n,s))),b:()=>L(e,L(r,be(s,n)))}}},JP={kernelName:da,gradFunc:e=>({x:()=>Ze(e)})},QP={kernelName:Vo,inputsToSave:["a","b"],gradFunc:(e,t)=>{let[n,s]=t,r=xt(n.shape,s.shape);return{a:()=>{let i=e,l=Yt(n.shape,r);return l.length>0&&(i=Ie(i,l)),V(i,n.shape)},b:()=>{let i=e,l=Yt(s.shape,r);return l.length>0&&(i=Ie(i,l)),V(Ct(i),s.shape)}}}},eM={kernelName:Lo,inputsToSave:["x"],gradFunc:(e,t,n)=>{let[s]=t,r=s.shape.slice(),{axis:a}=n;Fs(a,s.shape).forEach(c=>{r[c]=1});let i=V(e,r),l=L(i,as(s.shape,"float32"));return{x:()=>l}}},tM={kernelName:Uo,inputsToSave:["x"],gradFunc:(e,t)=>{let[n]=t;return{x:()=>fe(e,ht(qc(n)))}}},nM={kernelName:Go,outputsToSave:[!0],gradFunc:(e,t)=>{let[n]=t;return{x:()=>L(be(Ee(1),ht(n)),e)}}},sM={kernelName:ca,inputsToSave:["x"],gradFunc:(e,t,n)=>{let[s]=t,{reps:r}=n;return{x:()=>{let o=Ze(s);if(s.rank===1)for(let i=0;i<r[0];++i)o=le(o,Fe(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=le(o,Fe(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 c=0;c<r[2];++c)o=le(o,Fe(e,[i*s.shape[0],l*s.shape[1],c*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 c=0;c<r[2];++c)for(let u=0;u<r[3];++u)o=le(o,Fe(e,[i*s.shape[0],l*s.shape[1],c*s.shape[2],u*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}}}},rM={kernelName:Ho,gradFunc:(e,t,n)=>{let s=n,{perm:r}=s,a=BA(r);return{x:()=>Ke(e,a)}}},aM={kernelName:Hl,gradFunc:(e,t,n)=>{let s=n,{axis:r}=s;return{value:()=>gn(e,r)}}},oM={kernelName:Ec,inputsToSave:["segmentIds"],gradFunc:(e,t)=>{let[n]=t;return{x:()=>iM(e,n)}}};function iM(e,t){let n=xr(t,Ze(t)),s=ri(e,n),r=xa(t,Ee(0,"int32")),a=s.rank-r.rank;for(let i=0;i<a;++i)r=Lt(r,i+1);r=Ps(r,as(s.shape,"bool"));let o=Ze(s);return In(r,s,o)}var lM={kernelName:jl,gradFunc:e=>({x:()=>Ze(e)})},uM=[sv,uO,cO,dO,pO,hO,fO,mO,gO,AO,yO,xO,wO,SO,CO,TO,NO,EO,RO,DO,_O,FO,OO,$O,zO,LO,BO,WO,VO,UO,RP,GO,HO,jO,qO,XO,ZO,KO,YO,JO,QO,eP,tP,nP,sP,rP,aP,oP,iP,cP,iv,iv,dP,fP,AP,yP,xP,bP,vP,wP,kP,IP,SP,CP,TP,lv,lv,NP,EP,DP,_P,FP,$P,OP,PP,MP,zP,LP,BP,WP,VP,UP,GP,HP,jP,qP,XP,uv,uv,cv,cv,KP,YP,ZP,JP,QP,eM,tM,nM,sM,rM,aM,oM,lM];for(let e of uM)sb(e);Q().prototype.abs=function(){return this.throwIfDisposed(),Vt(this)};Q().prototype.acos=function(){return this.throwIfDisposed(),gA(this)};Q().prototype.acosh=function(){return this.throwIfDisposed(),AA(this)};Q().prototype.add=function(e){return this.throwIfDisposed(),le(this,e)};Q().prototype.all=function(e,t){return this.throwIfDisposed(),Ph(this,e,t)};Q().prototype.any=function(e,t){return this.throwIfDisposed(),Uc(this,e,t)};Q().prototype.argMax=function(e){return this.throwIfDisposed(),xs(this,e)};Q().prototype.argMin=function(e){return this.throwIfDisposed(),yA(this,e)};Q().prototype.asScalar=function(){return this.throwIfDisposed(),$(this.size===1,()=>"The array must have only 1 element."),V(this,[])};Q().prototype.asType=function(e){return this.throwIfDisposed(),de(this,e)};Q().prototype.as1D=function(){return this.throwIfDisposed(),V(this,[this.size])};Q().prototype.as2D=function(e,t){return this.throwIfDisposed(),V(this,[e,t])};Q().prototype.as3D=function(e,t,n){return this.throwIfDisposed(),V(this,[e,t,n])};Q().prototype.as4D=function(e,t,n,s){return this.throwIfDisposed(),V(this,[e,t,n,s])};Q().prototype.as5D=function(e,t,n,s,r){return this.throwIfDisposed(),V(this,[e,t,n,s,r])};Q().prototype.asin=function(){return this.throwIfDisposed(),xA(this)};Q().prototype.asinh=function(){return this.throwIfDisposed(),bA(this)};Q().prototype.atan=function(){return this.throwIfDisposed(),vA(this)};Q().prototype.atan2=function(e){return this.throwIfDisposed(),wA(this,e)};Q().prototype.atanh=function(){return this.throwIfDisposed(),kA(this)};Q().prototype.avgPool=function(e,t,n,s){return this.throwIfDisposed(),Hc(this,e,t,n,s)};Q().prototype.batchToSpaceND=function(e,t){return this.throwIfDisposed(),jc(this,e,t)};Q().prototype.batchNorm=function(e,t,n,s,r){return this.throwIfDisposed(),si(this,e,t,n,s,r)};Q().prototype.broadcastTo=function(e){return this.throwIfDisposed(),su(this,e)};Q().prototype.cast=function(e){return this.throwIfDisposed(),de(this,e)};Q().prototype.ceil=function(){return this.throwIfDisposed(),NA(this)};Q().prototype.clipByValue=function(e,t){return this.throwIfDisposed(),jn(this,e,t)};Q().prototype.concat=function(e,t){return this.throwIfDisposed(),e instanceof Ge&&(e=[e]),mt([this,...e],t)};Q().prototype.conv1d=function(e,t,n,s,r,a){return this.throwIfDisposed(),zh(this,e,t,n,s,r,a)};Q().prototype.conv2dTranspose=function(e,t,n,s,r){return this.throwIfDisposed(),Lh(this,e,t,n,s,r)};Q().prototype.conv2d=function(e,t,n,s,r,a){return this.throwIfDisposed(),Mr(this,e,t,n,s,r,a)};Q().prototype.cos=function(){return this.throwIfDisposed(),qc(this)};Q().prototype.cosh=function(){return this.throwIfDisposed(),Bh(this)};Q().prototype.cumsum=function(e,t,n){return this.throwIfDisposed(),Wh(this,e,t,n)};Q().prototype.depthToSpace=function(e,t){return this.throwIfDisposed(),DA(this,e,t)};Q().prototype.depthwiseConv2d=function(e,t,n,s,r,a){return this.throwIfDisposed(),au(this,e,t,n,s,r,a)};Q().prototype.dilation2d=function(e,t,n,s,r){return this.throwIfDisposed(),_A(this,e,t,n,s,r)};Q().prototype.divNoNan=function(e){return this.throwIfDisposed(),FA(this,e)};Q().prototype.div=function(e){return this.throwIfDisposed(),fe(this,e)};Q().prototype.dot=function(e){return this.throwIfDisposed(),g3(this,e)};Q().prototype.elu=function(){return this.throwIfDisposed(),ou(this)};Q().prototype.equal=function(e){return this.throwIfDisposed(),ns(this,e)};Q().prototype.erf=function(){return this.throwIfDisposed(),$A(this)};Q().prototype.exp=function(){return this.throwIfDisposed(),ss(this)};Q().prototype.expandDims=function(e){return this.throwIfDisposed(),Lt(this,e)};Q().prototype.expm1=function(){return this.throwIfDisposed(),OA(this)};Q().prototype.fft=function(){return this.throwIfDisposed(),sd(this)};Q().prototype.flatten=function(){return this.throwIfDisposed(),V(this,[this.size])};Q().prototype.floor=function(){return this.throwIfDisposed(),lu(this)};Q().prototype.floorDiv=function(e){return this.throwIfDisposed(),$h(this,e)};Q().prototype.gather=function(e,t){return this.throwIfDisposed(),ri(this,e,t)};Q().prototype.greaterEqual=function(e){return this.throwIfDisposed(),xa(this,e)};Q().prototype.greater=function(e){return this.throwIfDisposed(),qn(this,e)};Q().prototype.ifft=function(){return this.throwIfDisposed(),hu(this)};Q().prototype.irfft=function(){return this.throwIfDisposed(),nf(this)};Q().prototype.isFinite=function(){return this.throwIfDisposed(),y3(this)};Q().prototype.isInf=function(){return this.throwIfDisposed(),x3(this)};Q().prototype.isNaN=function(){return this.throwIfDisposed(),MA(this)};Q().prototype.leakyRelu=function(e){return this.throwIfDisposed(),Xc(this,e)};Q().prototype.lessEqual=function(e){return this.throwIfDisposed(),ba(this,e)};Q().prototype.less=function(e){return this.throwIfDisposed(),Uh(this,e)};Q().prototype.localResponseNormalization=function(e,t,n,s){return this.throwIfDisposed(),zA(this,e,t,n,s)};Q().prototype.logSigmoid=function(){return this.throwIfDisposed(),w3(this)};Q().prototype.logSoftmax=function(e){return this.throwIfDisposed(),Hh(this,e)};Q().prototype.logSumExp=function(e,t){return this.throwIfDisposed(),WA(this,e,t)};Q().prototype.log=function(){return this.throwIfDisposed(),rs(this)};Q().prototype.log1p=function(){return this.throwIfDisposed(),Kc(this)};Q().prototype.logicalAnd=function(e){return this.throwIfDisposed(),Ps(this,e)};Q().prototype.logicalNot=function(){return this.throwIfDisposed(),Zc(this)};Q().prototype.logicalOr=function(e){return this.throwIfDisposed(),jh(this,e)};Q().prototype.logicalXor=function(e){return this.throwIfDisposed(),C3(this,e)};Q().prototype.matMul=function(e,t,n){return this.throwIfDisposed(),Ve(this,e,t,n)};Q().prototype.maxPool=function(e,t,n,s){return this.throwIfDisposed(),Yc(this,e,t,n,s)};Q().prototype.max=function(e,t){return this.throwIfDisposed(),Rn(this,e,t)};Q().prototype.maximum=function(e){return this.throwIfDisposed(),xr(this,e)};Q().prototype.mean=function(e,t){return this.throwIfDisposed(),_t(this,e,t)};Q().prototype.min=function(e,t){return this.throwIfDisposed(),Jc(this,e,t)};Q().prototype.minimum=function(e){return this.throwIfDisposed(),uu(this,e)};Q().prototype.mirrorPad=function(e,t){return this.throwIfDisposed(),UA(this,e,t)};Q().prototype.mod=function(e){return this.throwIfDisposed(),GA(this,e)};Q().prototype.mul=function(e){return this.throwIfDisposed(),L(this,e)};Q().prototype.neg=function(){return this.throwIfDisposed(),Ct(this)};Q().prototype.norm=function(e,t,n){return this.throwIfDisposed(),of(this,e,t,n)};Q().prototype.notEqual=function(e){return this.throwIfDisposed(),ii(this,e)};Q().prototype.oneHot=function(e,t=1,n=0){return this.throwIfDisposed(),Ql(this,e,t,n)};Q().prototype.onesLike=function(){return this.throwIfDisposed(),os(this)};Q().prototype.pad=function(e,t){return this.throwIfDisposed(),vs(this,e,t)};Q().prototype.pool=function(e,t,n,s,r){return this.throwIfDisposed(),E3(this,e,t,n,s,r)};Q().prototype.pow=function(e){return this.throwIfDisposed(),zr(this,e)};Q().prototype.prelu=function(e){return this.throwIfDisposed(),ed(this,e)};Q().prototype.prod=function(e,t){return this.throwIfDisposed(),Xh(this,e,t)};Q().prototype.reciprocal=function(){return this.throwIfDisposed(),qA(this)};Q().prototype.relu=function(){return this.throwIfDisposed(),Zs(this)};Q().prototype.relu6=function(){return this.throwIfDisposed(),Kh(this)};Q().prototype.reshapeAs=function(e){return this.throwIfDisposed(),V(this,e.shape)};Q().prototype.reshape=function(e){return this.throwIfDisposed(),V(this,e)};Q().prototype.resizeBilinear=function(e,t,n){return this.throwIfDisposed(),q3(this,e,t,n)};Q().prototype.resizeNearestNeighbor=function(e,t,n){return this.throwIfDisposed(),X3(this,e,t,n)};Q().prototype.reverse=function(e){return this.throwIfDisposed(),is(this,e)};Q().prototype.rfft=function(){return this.throwIfDisposed(),rd(this)};Q().prototype.round=function(){return this.throwIfDisposed(),Zh(this)};Q().prototype.rsqrt=function(){return this.throwIfDisposed(),Yh(this)};Q().prototype.selu=function(){return this.throwIfDisposed(),Jh(this)};Q().prototype.separableConv2d=function(e,t,n,s,r,a){return this.throwIfDisposed(),XA(this,e,t,n,s,r,a)};Q().prototype.sigmoid=function(){return this.throwIfDisposed(),Hn(this)};Q().prototype.sign=function(){return this.throwIfDisposed(),KA(this)};Q().prototype.sin=function(){return this.throwIfDisposed(),Qh(this)};Q().prototype.sinh=function(){return this.throwIfDisposed(),ef(this)};Q().prototype.slice=function(e,t){return this.throwIfDisposed(),Fe(this,e,t)};Q().prototype.softmax=function(e){return this.throwIfDisposed(),li(this,e)};Q().prototype.softplus=function(){return this.throwIfDisposed(),ai(this)};Q().prototype.spaceToBatchND=function(e,t){return this.throwIfDisposed(),Qc(this,e,t)};Q().prototype.split=function(e,t){return this.throwIfDisposed(),on(this,e,t)};Q().prototype.sqrt=function(){return this.throwIfDisposed(),mn(this)};Q().prototype.square=function(){return this.throwIfDisposed(),ht(this)};Q().prototype.squaredDifference=function(e){return this.throwIfDisposed(),sf(this,e)};Q().prototype.squeeze=function(e){return this.throwIfDisposed(),rt(this,e)};Q().prototype.stack=function(e,t){this.throwIfDisposed();let n=e instanceof Ge?[this,e]:[this,...e];return gn(n,t)};Q().prototype.step=function(e){return this.throwIfDisposed(),fu(this,e)};Q().prototype.stridedSlice=function(e,t,n,s,r,a,o,i){return this.throwIfDisposed(),YA(this,e,t,n,s,r,a,o,i)};Q().prototype.sub=function(e){return this.throwIfDisposed(),be(this,e)};Q().prototype.sum=function(e,t){return this.throwIfDisposed(),Ie(this,e,t)};Q().prototype.tan=function(){return this.throwIfDisposed(),JA(this)};Q().prototype.tanh=function(){return this.throwIfDisposed(),ni(this)};Q().prototype.tile=function(e){return this.throwIfDisposed(),bs(this,e)};Q().prototype.toBool=function(){return this.throwIfDisposed(),de(this,"bool")};Q().prototype.toFloat=function(){return this.throwIfDisposed(),de(this,"float32")};Q().prototype.toInt=function(){return this.throwIfDisposed(),de(this,"int32")};Q().prototype.topk=function(e,t){return this.throwIfDisposed(),QA(this,e,t)};Q().prototype.transpose=function(e){return this.throwIfDisposed(),Ke(this,e)};Q().prototype.unique=function(e){return this.throwIfDisposed(),af(this,e)};Q().prototype.unsortedSegmentSum=function(e,t){return this.throwIfDisposed(),e1(this,e,t)};Q().prototype.unstack=function(e){return this.throwIfDisposed(),Dn(this,e)};Q().prototype.where=function(e,t){return this.throwIfDisposed(),In(e,this,t)};Q().prototype.zerosLike=function(){return this.throwIfDisposed(),Ze(this)};var dv={};ze(dv,{maxNorm:()=>hM,minMaxNorm:()=>gM,nonNeg:()=>mM,unitNorm:()=>fM});var l1;function Jt(){return l1==null&&(l1=gr().epsilon()),l1}function Js(){return"channelsLast"}var Wr=class extends Error{constructor(e){super(e);Object.setPrototypeOf(this,Wr.prototype)}},Qs=class extends Error{constructor(e){super(e);Object.setPrototypeOf(this,Qs.prototype)}},H=class extends Error{constructor(e){super(e);Object.setPrototypeOf(this,H.prototype)}},Me=class extends Error{constructor(e){super(e);Object.setPrototypeOf(this,Me.prototype)}},pv=class extends Error{constructor(e){super(e);Object.setPrototypeOf(this,pv.prototype)}};function di(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 vr(e,t){if(!e)throw new pv(t)}function hv(e,t){let n=0;for(let s of e)s===t&&n++;return n}function Xn(e){return e.length===1?e[0]:e}function bt(e){return Array.isArray(e)?e:[e]}function Vr(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 pi(e){return e.length<=1||e.indexOf("_")===-1?e:e.replace(/[_]+(\w|$)/g,(t,n)=>n.toUpperCase())}var Ms={};function u1(e){if(e==null)return null;let t={};return t.className=e.getClassName(),t.config=e.getConfig(),t}function c1(e){if(!(e==null||typeof e!="object"))if(Array.isArray(e))e.forEach(t=>c1(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:c1(s))}}}function id(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 Ms)o=Ms[a];else if(o=t[a],o==null)throw new H(`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 H(`${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 Ms?[i,l]=Ms.className:o in t&&([i,l]=t[o]),i==null)throw new H(`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 c={};for(let h of Object.keys(Ms))c[h]=Ms[h];for(let h of Object.keys(n))c[h]=n[h];let u=a.config;u.customObjects=c;let d=Object.assign({},Ms);for(let h of Object.keys(n))Ms[h]=n[h];c1(a.config);let p=l(i,a.config,n,r);return Ms=Object.assign({},d),p}else{let c=Object.assign({},Ms);for(let d of Object.keys(n))Ms[d]=n[d];let u=new i(a.config);return Ms=Object.assign({},c),u}}}function cM(e,t){return e<t?-1:e>t?1:0}function xf(e,t){return-1*cM(e,t)}function wa(e){if(e==null)return e;let t=[];for(let n of e)t.indexOf(n)===-1&&t.push(n);return t}function dM(e){if(e==null)throw new H(`Invalid value in obj: ${JSON.stringify(e)}`);for(let t in e)if(e.hasOwnProperty(t))return!1;return!0}function hi(e,t,n){if(n!=null&&e.indexOf(n)<0)throw new H(`${n} is not a valid ${t}. Valid values are ${e} or null/undefined.`)}function d1(e,t,n=0,s=1/0){return vr(n>=0),vr(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 ${fv(e)}.`)}function fv(e){return e===null?"null":Array.isArray(e)?"["+e.map(t=>fv(t)).join(",")+"]":typeof e=="string"?`"${e}"`:`${e}`}function pM(e,t,n){let s=n!=null?n():w.now(),r;return(...o)=>{let i=n!=null?n():w.now();return i-s<t||(s=i,r=e(...o)),r}}function mv(e){return e==="relu"?"relu":e==="linear"?"linear":e==="elu"?"elu":null}function p1(e,t){return G(()=>mn(Ie(L(e,e),t,!0)))}var ld=class extends ue.Serializable{getConfig(){return{}}},h1=class extends ld{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 G(()=>{let t=p1(e,this.axis),n=jn(t,0,this.maxValue);return L(e,fe(n,le(Jt(),t)))})}getConfig(){return{maxValue:this.maxValue,axis:this.axis}}};h1.className="MaxNorm";ue.registerClass(h1);var f1=class extends ld{constructor(e){super();this.defaultAxis=0,this.axis=e.axis!=null?e.axis:this.defaultAxis}apply(e){return G(()=>fe(e,le(Jt(),p1(e,this.axis))))}getConfig(){return{axis:this.axis}}};f1.className="UnitNorm";ue.registerClass(f1);var m1=class extends ld{apply(e){return Zs(e)}};m1.className="NonNeg";ue.registerClass(m1);var g1=class extends ld{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 G(()=>{let t=p1(e,this.axis),n=le(L(this.rate,jn(t,this.minValue,this.maxValue)),L(1-this.rate,t));return L(e,fe(n,le(Jt(),t)))})}getConfig(){return{minValue:this.minValue,maxValue:this.maxValue,rate:this.rate,axis:this.axis}}};g1.className="MinMaxNorm";ue.registerClass(g1);var gv={maxNorm:"MaxNorm",minMaxNorm:"MinMaxNorm",nonNeg:"NonNeg",unitNorm:"UnitNorm"};function Qt(e){return u1(e)}function Av(e,t={}){return id(e,ue.SerializationMap.getMap().classNameMap,t,"constraint")}function en(e){if(e==null)return null;if(typeof e=="string"){let n={className:e in gv?gv[e]:e,config:{}};return Av(n)}else return e instanceof ld?e:Av(e)}function hM(e){return new h1(e)}function fM(e){return new f1(e)}function mM(){return new m1}function gM(e){return new g1(e)}var yv={};ze(yv,{constant:()=>LM,glorotNormal:()=>jM,glorotUniform:()=>HM,heNormal:()=>qM,heUniform:()=>XM,identity:()=>UM,leCunNormal:()=>KM,leCunUniform:()=>ZM,ones:()=>zM,orthogonal:()=>YM,randomNormal:()=>WM,randomUniform:()=>BM,truncatedNormal:()=>VM,varianceScaling:()=>GM,zeros:()=>MM});var AM=["channelsFirst","channelsLast"],yM=["nearest","bilinear"],xM=["valid","same","causal"],bM=["max","avg"],vM=["sum","mul","concat","ave"],gu=new Map;function Bt(e){hi(AM,"DataFormat",e)}function wM(e){hi(yM,"InterpolationFormat",e)}function ws(e){hi(xM,"PaddingMode",e)}function xv(e){hi(bM,"PoolMode",e)}var ud=[],bv="/";function fi(e,t){ud.push(e);try{let n=t();return ud.pop(),n}catch(n){throw ud.pop(),n}}function kM(){return ud.length===0?"":ud.join(bv)+bv}function vv(e){if(!kv(e))throw new Error("Not a valid tensor name: '"+e+"'");return kM()+e}function wv(e){if(!kv(e))throw new Error("Not a valid tensor name: '"+e+"'");gu.has(e)||gu.set(e,0);let t=gu.get(e);if(gu.set(e,gu.get(e)+1),t>0){let n=`${e}_${t}`;return gu.set(n,1),n}else return e}var IM=new RegExp(/^[A-Za-z0-9][-A-Za-z0-9\._\/]*$/);function kv(e){return!!e.match(IM)}function SM(e){return e===parseInt(e.toString(),10)}function ka(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 Au(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 Ia(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 er(e,t){if(t<e)throw new H(`end (${t}) < begin (${e}) is forbidden.`);let n=[];for(let s=e;s<t;++s)n.push(s);return n}function bf(e,t){return de(e,t)}function cd(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 CM(e,t){return G(()=>{if(e.shape.length!==2)throw new H(`repeat() expects a rank-2 tensor, but received a rank-${e.shape.length} tensor.`);let n=cd(e,1);return x1(n,[1,t,1])})}function TM(e){let t=[ka(e.shape)];return V(e,t)}function NM(e){if(e.rank<=1)throw new H(`batchFlatten requires a minimum rank of 2. Got rank: ${e.rank}.`);let t=[e.shape[0],ka(e.shape,1)];return V(e,t)}function mi(e,t,n){return G(()=>{switch(e.rank){case 1:return tf(e,t,n);case 2:return ZA(e,[t,0],[n,e.shape[1]]);case 3:return pu(e,[t,0,0],[n,e.shape[1],e.shape[2]]);case 4:return nd(e,[t,0,0,0],[n,e.shape[1],e.shape[2],e.shape[3]]);case 5:return Fe(e,[t,0,0,0,0],[n,e.shape[1],e.shape[2],e.shape[3],e.shape[4]]);case 6:return Fe(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 H(`sliceAlongFirstAxis() received an unsupported tensor rank: ${e.rank}`)}})}function A1(e,t,n){return G(()=>{switch(e.rank){case 1:return tf(e,t,n);case 2:return ZA(e,[0,t],[e.shape[0],n]);case 3:return pu(e,[0,0,t],[e.shape[0],e.shape[1],n]);case 4:return nd(e,[0,0,0,t],[e.shape[0],e.shape[1],e.shape[2],n]);default:throw new H(`sliceAlongLastAxis() received an unsupported tensor rank: ${e.rank}`)}})}function vf(e,t,n,s){return G(()=>{switch(e.rank){case 1:return tf(e,t,n);case 2:switch(s){case 1:return mi(e,t,n);case 2:return A1(e,t,n);default:throw new H(`The axis is not within the rank of the tensor ${s}`)}case 3:switch(s){case 1:return mi(e,t,n);case 2:return pu(e,[0,t,0],[e.shape[0],n,e.shape[2]]);case 3:return A1(e,t,n);default:throw new H(`The axis is not within the rank of the tensor ${s}`)}case 4:switch(s){case 1:return mi(e,t,n);case 2:return nd(e,[0,t,0,0],[e.shape[0],n,e.shape[2],e.shape[3]]);case 3:return nd(e,[0,0,t,0],[e.shape[0],e.shape[1],n,e.shape[3]]);case 4:return A1(e,t,n);default:throw new H(`The axis is not within the rank of the tensor ${s}`)}default:throw new H(`sliceAlongLastAxis() received an unsupported tensor rank: ${e.rank}`)}})}function y1(e,t=-1){let n;return t<0&&(n=e[0].rank,n!==0?t=n:t=0),t===e[0].rank&&(t=-1),mt(e,t)}function Iv(e,t){switch(e.rank){case 1:return c3([e,t]);case 2:return ru([e,t],0);case 3:return d3([e,t],0);case 4:return p3([e,t],0);default:throw new H(`concatAlongFirstAxis() received an unsupported tensor rank: ${e.rank}`)}}function x1(e,t){if(Array.isArray(t)||(t=[t]),e.rank!==t.length)throw new H(`The length of input n (${t.length}) does not match the number of dimensions in input x (${e.rank})`);return bs(e,t)}function wf(e,t=0,n=1,s,r){return R3(e,t,n,s,r)}function wr(e,t,n,s){if(e.rank<2||t.rank<2)throw new Me(`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 Me(`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 va.matMul({a:e,b:t,transposeA:r,transposeB:a,bias:s?b1(e.rank,s,Js()):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(),c=[...o,i],u=Array.from({length:t.rank},(f,m)=>m===0?t.rank-2:m<=t.rank-2?m-1:m);t=V(Ke(t,u),[l,-1]);let d=[...r,...c],p=!1,h=!1;return V(va.matMul({a:e,b:t,transposeA:p,transposeB:h,bias:s?b1(e.rank,s,Js()):null,activation:n}),d)}}function Sv(e,t,n){return G(()=>(Array.isArray(t)?t=Gt(t,"int32"):t=de(t,"int32"),ri(e,t,n)))}function dd(e){return L(e,e)}function b1(e,t,n){let s=t.shape;if(t.rank!==1&&t.rank!==e)throw new H(`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 H(`Unsupported input rank by biasAdd: ${t.rank}`)}function tr(e,t,n){return G(()=>(n==null&&(n=Js()),Bt(n),le(e,b1(e.rank,t,n))))}function EM(e,t=1){if(t!==1)throw new Me(`Support for alpha values other than 1 (${t}) is not implemented yet.`);return ou(e)}function RM(e){return G(()=>fe(e,le(Vt(e),1)))}function Cv(e,t,n,s){return G(()=>M3(e,t,n,s))}function DM(e){return G(()=>{let t=le(.5,L(.2,e));return jn(t,0,1)})}function pd(e,t,n=!1){return n?e():t()}var _M=["fanIn","fanOut","fanAvg"],FM=["normal","uniform","truncatedNormal"];function $M(e){hi(_M,"FanMode",e)}function OM(e){hi(FM,"Distribution",e)}var zs=class extends ue.Serializable{fromConfigUsesCustomObjects(){return!1}getConfig(){return{}}},v1=class extends zs{apply(e,t){return Ut(e,t)}};v1.className="Zeros";ue.registerClass(v1);var kf=class extends zs{apply(e,t){return as(e,t)}};kf.className="Ones";ue.registerClass(kf);var w1=class extends zs{constructor(e){super();if(typeof e!="object")throw new H(`Expected argument of type ConstantConfig but got ${e}`);if(e.value===void 0)throw new H(`config must have value set but got ${e}`);this.value=e.value}apply(e,t){return G(()=>L(Ee(this.value),as(e,t)))}getConfig(){return{value:this.value}}};w1.className="Constant";ue.registerClass(w1);var k1=class extends zs{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 cu(e,this.minval,this.maxval,t)}getConfig(){return{minval:this.minval,maxval:this.maxval,seed:this.seed}}};k1.className="RandomUniform";ue.registerClass(k1);var I1=class extends zs{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 Me(`randomNormal does not support dType ${t}.`);return wf(e,this.mean,this.stddev,t,this.seed)}getConfig(){return{mean:this.mean,stddev:this.stddev,seed:this.seed}}};I1.className="RandomNormal";ue.registerClass(I1);var S1=class extends zs{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 Me(`truncatedNormal does not support dType ${t}.`);return rf(e,this.mean,this.stddev,t,this.seed)}getConfig(){return{mean:this.mean,stddev:this.stddev,seed:this.seed}}};S1.className="TruncatedNormal";ue.registerClass(S1);var C1=class extends zs{constructor(e){super();this.gain=e.gain!=null?e.gain:1}apply(e,t){return G(()=>{if(e.length!==2||e[0]!==e[1])throw new H("Identity matrix initializer can only be used for 2D square matrices.");return L(this.gain,PA(e[0]))})}getConfig(){return{gain:this.gain}}};C1.className="Identity";ue.registerClass(C1);function PM(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=ka(e,2);n=e[1]*r,s=e[0]*r}else if(t==="channelsLast"){let r=ka(e,0,e.length-2);n=e[e.length-2]*r,s=e[e.length-1]*r}}else{let r=ka(e);n=Math.sqrt(r),s=Math.sqrt(r)}return[n,s]}var Kn=class extends zs{constructor(e){super();if(e.scale<0)throw new H(`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,$M(this.mode),this.distribution=e.distribution==null?"normal":e.distribution,OM(this.distribution),this.seed=e.seed}apply(e,t){let n=PM(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 Me(`${this.getClassName()} does not support dType ${t}.`);return rf(e,0,o,t,this.seed)}else{let o=Math.sqrt(3*a);return cu(e,-o,o,t)}}getConfig(){return{scale:this.scale,mode:this.mode,distribution:this.distribution,seed:this.seed}}};Kn.className="VarianceScaling";ue.registerClass(Kn);var If=class extends Kn{constructor(e){super({scale:1,mode:"fanAvg",distribution:"uniform",seed:e==null?null:e.seed})}getClassName(){return Kn.className}};If.className="GlorotUniform";ue.registerClass(If);var Sf=class extends Kn{constructor(e){super({scale:1,mode:"fanAvg",distribution:"normal",seed:e==null?null:e.seed})}getClassName(){return Kn.className}};Sf.className="GlorotNormal";ue.registerClass(Sf);var Cf=class extends Kn{constructor(e){super({scale:2,mode:"fanIn",distribution:"normal",seed:e==null?null:e.seed})}getClassName(){return Kn.className}};Cf.className="HeNormal";ue.registerClass(Cf);var Tf=class extends Kn{constructor(e){super({scale:2,mode:"fanIn",distribution:"uniform",seed:e==null?null:e.seed})}getClassName(){return Kn.className}};Tf.className="HeUniform";ue.registerClass(Tf);var Nf=class extends Kn{constructor(e){super({scale:1,mode:"fanIn",distribution:"normal",seed:e==null?null:e.seed})}getClassName(){return Kn.className}};Nf.className="LeCunNormal";ue.registerClass(Nf);var Ef=class extends Kn{constructor(e){super({scale:1,mode:"fanIn",distribution:"uniform",seed:e==null?null:e.seed})}getClassName(){return Kn.className}};Ef.className="LeCunNormal";ue.registerClass(Ef);var T1=class extends zs{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 Me("Random seed is not implemented for Orthogonal Initializer yet.")}apply(e,t){return G(()=>{if(e.length<2)throw new Me("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=wf(n,0,1,"float32"),r=Z3.gramSchmidt(s);return e[0]>e[1]&&(r=Ke(r)),L(this.gain,r)})}getConfig(){return{gain:this.gain,seed:this.seed}}};T1.className="Orthogonal";ue.registerClass(T1);var Tv={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 Nv(e,t={}){return id(e,ue.SerializationMap.getMap().classNameMap,t,"initializer")}function Ft(e){return u1(e)}function Tt(e){if(typeof e=="string"){let t=e in Tv?Tv[e]:e;if(t==="GlorotNormal")return new Sf;if(t==="GlorotUniform")return new If;if(t==="HeNormal")return new Cf;if(t==="HeUniform")return new Tf;if(t==="LeCunNormal")return new Nf;if(t==="LeCunUniform")return new Ef;{let n={};return n.className=t,n.config={},Nv(n)}}else return e instanceof zs?e:Nv(e)}function MM(){return new v1}function zM(){return new kf}function LM(e){return new w1(e)}function BM(e){return new k1(e)}function WM(e){return new I1(e)}function VM(e){return new S1(e)}function UM(e){return new C1(e)}function GM(e){return new Kn(e)}function HM(e){return new If(e)}function jM(e){return new Sf(e)}function qM(e){return new Cf(e)}function XM(e){return new Tf(e)}function KM(e){return new Nf(e)}function ZM(e){return new Ef(e)}function YM(e){return new T1(e)}var Ev={};ze(Ev,{Layer:()=>Je,RNN:()=>Sr,RNNCell:()=>vd,activation:()=>FL,add:()=>VL,alphaDropout:()=>SB,average:()=>UL,averagePooling1d:()=>Hy,averagePooling2d:()=>jy,averagePooling3d:()=>qy,avgPool1d:()=>JL,avgPool2d:()=>eB,avgPool3d:()=>nB,avgPooling1d:()=>QL,avgPooling2d:()=>tB,avgPooling3d:()=>sB,batchNormalization:()=>KL,bidirectional:()=>AB,concatenate:()=>GL,conv1d:()=>IL,conv2d:()=>SL,conv2dTranspose:()=>CL,conv3d:()=>TL,conv3dTranspose:()=>NL,convLstm2d:()=>hB,convLstm2dCell:()=>fB,cropping2D:()=>RL,dense:()=>$L,depthwiseConv2d:()=>_L,dot:()=>XL,dropout:()=>OL,elu:()=>yL,embedding:()=>WL,flatten:()=>ML,gaussianDropout:()=>IB,gaussianNoise:()=>kB,globalAveragePooling1d:()=>rB,globalAveragePooling2d:()=>aB,globalMaxPool1d:()=>xB,globalMaxPool2d:()=>bB,globalMaxPooling1d:()=>zw,globalMaxPooling2d:()=>Lw,gru:()=>iB,gruCell:()=>lB,input:()=>lw,inputLayer:()=>AL,layerNormalization:()=>ZL,leakyReLU:()=>bL,lstm:()=>uB,lstmCell:()=>cB,masking:()=>CB,maxPool1d:()=>vB,maxPool2d:()=>wB,maxPooling1d:()=>Bw,maxPooling2d:()=>Ww,maxPooling3d:()=>oB,maximum:()=>HL,minimum:()=>jL,multiply:()=>qL,permute:()=>BL,prelu:()=>vL,reLU:()=>xL,repeatVector:()=>zL,reshape:()=>LL,rnn:()=>mB,separableConv2d:()=>EL,simpleRNN:()=>dB,simpleRNNCell:()=>pB,softmax:()=>wL,spatialDropout1d:()=>PL,stackedRNNCells:()=>gB,thresholdedReLU:()=>kL,timeDistributed:()=>yB,upSampling2d:()=>DL,zeroPadding2d:()=>YL});var JM=0;function Rv(){return JM++}var Rf={};function Df(e=""){return e in Rf||(Rf[e]=0),Rf[e]+=1,e+Rf[e].toString()}function N1(e){return Array.isArray(e)&&Array.isArray(e[0])}function _f(e){return e.length===0?[]:Array.isArray(e[0])?e:[e]}function Le(e){let t;if(Array.isArray(e)){if(e.length!==1)throw new H(`Expected Tensor length to be 1; got ${e.length}`);t=e[0]}else t=e;return t}function ct(e){if(Array.isArray(e)&&Array.isArray(e[0])){if(e.length===1)return e=e,e[0];throw new H(`Expected exactly 1 Shape; got ${e.length}`)}else return e}function Ff(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 Dv="Variable",_v=class{constructor(e,t="float32",n=Dv,s=!0,r=null){this.dtype=t??"float32",this.shape=e.shape,this.id=Rv(),n=n??Dv,this.originalName=vv(n),this.name=wv(this.originalName),this.trainable_=s,this.constraint=r,this.val=_3(e,this.trainable_,this.name,this.dtype)}read(){return this.assertNotDisposed(),this.val}write(e){return this.assertNotDisposed(),QM(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 QM(e,t){if(e.shape.toString()!==t.shape.toString())throw new Error("Shape mismatch: "+JSON.stringify(e.shape)+" vs. "+JSON.stringify(t.shape))}function E1(e){return e.map(t=>t.read())}function R1(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||{}}},nr=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=Rv(),a!=null&&(this.originalName=vv(a),this.name=wv(this.originalName)),this.rank=t.length}},ez=0,$f=class{constructor(e,t){this.callArgs=t,this.id=ez++,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}}},tz=0,Je=class extends ue.Serializable{constructor(e={}){super();this._callHook=null,this._addedWeightNames=[],this._stateful=!1,this.id=tz++,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=Vr(n)+"_"+Df(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 Qs(`The layer has never been called and thus has no defined ${t}.`);if(this.inboundNodes.length<=e)throw new H(`Asked to get ${t} at node ${e}, but the layer has only ${this.inboundNodes.length} inbound nodes.`);return this.inboundNodes[e]}getInputAt(e){return Xn(this.getNodeAtIndex(e,"input").inputTensors)}getOutputAt(e){return Xn(this.getNodeAtIndex(e,"output").outputTensors)}get input(){if(this.inboundNodes.length>1)throw new Wr(`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 Wr(`Layer ${this.name} is not connected, no input to return.`);return Xn(this.getNodeAtIndex(0,"input").inputTensors)}get output(){if(this.inboundNodes.length===0)throw new Wr(`Layer ${this.name} has no inbound nodes.`);if(this.inboundNodes.length>1)throw new Wr(`Layer ${this.name} has multiple inbound nodes, hence the notion of "layer output" is ill-defined. Use \`getOutputAt(nodeIndex)\` instead.`);return Xn(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=bt(e),this.inputSpec==null||this.inputSpec.length===0)return;let t=bt(this.inputSpec);if(e.length!==t.length)throw new H(`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 H(`Input ${n} is incompatible with layer ${this.name}: expected ndim=${r.ndim}, found ndim=${a}`);if(r.maxNDim!=null&&a>r.maxNDim)throw new H(`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 H(`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 H(`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),c=r.axes[i],u=l>=0?o[l]:o[o.length+l];if(c!=null&&[c,null].indexOf(u)===-1)throw new H(`Input ${n} is incompatible with layer ${this.name}: expected axis ${l} of input shape to have value ${c} 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 H(`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=bt(e),s=!0;for(let a of n)if(!(a instanceof nr)){s=!1;break}let r=!0;for(let a of n)if(a instanceof nr){r=!1;break}if(s===r)throw new H("Arguments to apply() must be all SymbolicTensors or all Tensors");return fi(this.name,()=>{if(!this.built){this.assertInputCompatibility(e);let a=[];for(let o of bt(e))a.push(o.shape);this.build(Xn(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=bt(a),i=[];for(let l of o)n.indexOf(l)!==-1&&(l=l.clone()),i.push(l);if(a=Xn(i),this.activityRegularizer!=null)throw new Me("Layer invocation in the presence of activity regularizer(s) is not supported yet.");return a}else{let a=nz(e),o=this.computeOutputShape(a),i,l=sz(e);if(this.warnOnIncompatibleInputShape(Array.isArray(e)?a[0]:a),o!=null&&o.length>0&&Array.isArray(o[0])?i=o.map((c,u)=>new nr(l,c,this,bt(e),t,this.name,u)):i=new nr(l,o,this,bt(e),t,this.name),this.addInboundNode(e,i,null,null,a,o,t),this._refCount++,this.activityRegularizer!=null)throw new Me("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 Wr(`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 Wr(`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 Qs(`You tried to call countParams() on ${this.name}, but the layer is not built yet. Build it first by calling build(batchInputShape).`);return Ff(this.weights)}build(e){this.built=!0}getWeights(e=!1){return E1(e?this.trainableWeights:this.weights)}setWeights(e){G(()=>{let t=this.weights;if(t.length!==e.length)throw new H(`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=E1(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 H(`Layer weight shape ${a.shape} not compatible with provided weight shape ${i.shape}`);n.push([o,i])}R1(n)})}addWeight(e,t,n,s,r,a,o,i){if(this._addedWeightNames.indexOf(e)!==-1)throw new H(`Duplicate weight name ${e} for layer ${this.name}`);this._addedWeightNames.push(e),n==null&&(n="float32"),this.fastWeightInitDuringBuild&&(s=i!=null?i():Tt("zeros"));let l=s.apply(t,n),c=new _v(l,n,e,a,o);return l.dispose(),r!=null&&this.addLoss(()=>r.apply(c.read())),a==null&&(a=!0),a?this._trainableWeights.push(c):this._nonTrainableWeights.push(c),c}setFastWeightInitDuringBuild(e){this.fastWeightInitDuringBuild=e}addLoss(e){e==null||Array.isArray(e)&&e.length===0||(e=bt(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=bt(e);t=bt(t),n=bt(n),s=bt(s),r=_f(r),a=_f(a);let l=[],c=[],u=[];for(let d of i)l.push(d.sourceLayer),c.push(d.nodeIndex),u.push(d.tensorIndex);new $f({outboundLayer:this,inboundLayers:l,nodeIndices:c,tensorIndices:u,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 nz(e){e=bt(e);let t=[];for(let n of e)t.push(n.shape);return Xn(t)}function sz(e){return"float32"}function Fv(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],c=Fv(o,i,l);for(let u of c)r.indexOf(u)===-1&&r.push(u)}return r}}}var yu=class extends Je{constructor(e){super({dtype:e.dtype,name:e.name!=null?e.name:Df("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 H("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 H("An InputLayer should be passed either a `batchInputShape` or an `inputShape`.");t=[e.batchSize].concat(e.inputShape)}else if(e.batchSize!=null)throw new H("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 nr(this.dtype,this.batchInputShape,this,[],{},this.name);s.nodeIndex=0,s.tensorIndex=0,new $f({outboundLayer:this,inboundLayers:[],nodeIndices:[],tensorIndices:[],inputTensors:[s],outputTensors:[s],inputMasks:[null],outputMasks:[null],inputShapes:[t],outputShapes:[t]})}apply(e,t){throw new H(`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}}};yu.className="InputLayer";ue.registerClass(yu);function $v(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 H("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 yu({batchInputShape:t,name:e.name,dtype:n,sparse:e.sparse}).inboundNodes[0].outputTensors[0]}async function Sa(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 Ov(e){if(e!=null)for(let t in e){let n=e[t];typeof n!="number"&&n.dispose()}}var Pv;(function(e){e[e.SILENT=0]="SILENT",e[e.VERBOSE=1]="VERBOSE"})(Pv||(Pv={}));var rz=125,xu=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){}},Mv=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)}},az=class extends xu{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=G(()=>le(this.totals[s],L(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:G(()=>{let s=L(fe(1,this.seen),this.totals[n]);t[n]=s,this.totals[n].dispose(),an(t[n])}))}},zv=class extends xu{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]}},Lv=class extends xu{constructor(e,t){super();if(this.currentEpoch=0,this.nowFunc=e.nowFunc,this.nextFrameFunc=e.nextFrameFunc||Y3,this.yieldEvery=t||"auto",this.yieldEvery==="auto"&&(this.yieldEvery=rz),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=pM(this.maybeWait.bind(this),this.yieldEvery,this.nowFunc)),this.trainBegin=e.onTrainBegin,this.trainEnd=e.onTrainEnd,this.epochBegin=e.onEpochBegin,this.epochEnd=e.onEpochEnd,this.batchBegin=e.onBatchBegin,this.batchEnd=e.onBatchEnd,this.yield=e.onYield}async maybeWait(e,t,n){let s=[];this.yield!=null&&(await Sa(n),s.push(this.yield(e,t,n))),s.push(this.nextFrameFunc()),await Promise.all(s)}async onEpochBegin(e,t){this.currentEpoch=e,this.epochBegin!=null&&(await Sa(t),await this.epochBegin(e,t))}async onEpochEnd(e,t){let n=[];this.epochEnd!=null&&(await Sa(t),n.push(this.epochEnd(e,t))),this.yieldEvery==="epoch"&&n.push(this.nextFrameFunc()),await Promise.all(n)}async onBatchBegin(e,t){this.batchBegin!=null&&(await Sa(t),await this.batchBegin(e,t))}async onBatchEnd(e,t){let n=[];this.batchEnd!=null&&(await Sa(t),n.push(this.batchEnd(e,t))),this.yieldEvery==="batch"?n.push(this.nextFrameFunc()):w.isNumber(this.yieldEvery)&&n.push(this.maybeWait(this.currentEpoch,e,t)),await Promise.all(n)}async onTrainBegin(e){this.trainBegin!=null&&(await Sa(e),await this.trainBegin(e))}async onTrainEnd(e){this.trainEnd!=null&&(await Sa(e),await this.trainEnd(e))}};function Bv(e,t){return e==null&&(e={}),e instanceof xu?[e]:Array.isArray(e)&&e[0]instanceof xu?e:bt(e).map(s=>new Lv(s,t))}var Ls=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}`),Ls.checkForDuplicate(t),Ls.constructors[e]==null&&(Ls.constructors[e]=[]),Ls.constructors[e].push(t)}static checkForDuplicate(e){for(let t in Ls.constructors)Ls.constructors[+t].forEach(s=>{if(s===e)throw new H("Duplicate callback constructor.")})}static clear(){Ls.constructors={}}static createCallbacks(e){let t=[];for(let n in Ls.constructors){let s=+n;e>=s&&t.push(...Ls.constructors[s])}return t.map(n=>new n)}};Ls.constructors={};function Wv(e,t,n,s,r,a,o,i,l){let c=new zv,u=[new az,...Ls.createCallbacks(t)];e!=null&&u.push(...e),u.push(c);let d=new Mv(u);return d.setParams({epochs:n,initialEpoch:s,samples:r,steps:a,batchSize:o,verbose:t,doValidation:i,metrics:l}),{callbackList:d,history:c}}function sr(e,t={},n=!1){return id(e,ue.SerializationMap.getMap().classNameMap,t,"layer",n)}function Of(e,t){return G(()=>{e.dtype!=="float32"&&(e=de(e,"float32"));let n=Ie(dd(e),t,!0),s=iu(n.shape,Jt()),r=mn(xr(n,s));return fe(e,r)})}function gi(e,t){return G(()=>_t(dd(be(t,e)),-1))}function Pf(e,t){return G(()=>_t(Vt(be(t,e)),-1))}function bu(e,t){return G(()=>{let n=be(e,t),s=jn(Vt(e),Jt(),Number.MAX_VALUE),r=Vt(fe(n,s));return L(100,_t(r,-1))})}function oz(e,t){return G(()=>{let n=jn(t,Jt(),Number.MAX_VALUE),s=rs(le(1,n)),r=jn(e,Jt(),Number.MAX_VALUE),a=rs(le(1,r));return _t(dd(be(s,a)),-1)})}function iz(e,t){return G(()=>{let n=xr(0,be(1,L(e,t)));return _t(dd(n),-1)})}function lz(e,t){return G(()=>{let n=xr(0,be(1,L(e,t)));return _t(n,-1)})}function uz(e,t){return G(()=>{let n=Ie(L(e,t),-1),s=Rn(L(be(1,e),t),-1);return xr(0,le(1,be(s,n)))})}function cz(e,t){return G(()=>{let n=Math.log(2),s=be(t,e),r=be(le(s,ai(L(-2,s))),n);return _t(r,-1)})}function hd(e,t,n=!1){return G(()=>{if(n)t=li(t);else{let s=Ie(t,t.shape.length-1,!0);t=fe(t,s)}return t=jn(t,Jt(),1-Jt()),Ct(Ie(L(de(e,"float32"),rs(t)),t.shape.length-1))})}function Mf(e,t,n=!1){return G(()=>{let s=de(lu(TM(e)),"int32");t=jn(t,Jt(),1-Jt());let r=t.shape,a=V(Ql(s,r[r.length-1]),r);return hd(a,t,n)})}function dz(e,t){if(!w.arraysEqual(e.shape,t.shape))throw new H(`logits and labels must have the same shape, but got shapes ${JSON.stringify(e.shape)} and ${JSON.stringify(t.shape)}`);return G(()=>{let n=Zs(t),s=Ct(Vt(t));return le(be(n,L(t,e)),Kc(ss(s)))})}function zf(e,t){return G(()=>{let n;return n=jn(t,Jt(),1-Jt()),n=rs(fe(n,be(1,n))),_t(dz(e,n),-1)})}function pz(e,t){return G(()=>{let n=jn(e,Jt(),1),s=jn(t,Jt(),1);return Ie(L(e,rs(fe(n,s))),-1)})}function hz(e,t){return G(()=>{let n=rs(le(Jt(),t));return _t(be(t,L(e,n)),-1)})}function D1(e,t){return G(()=>{let n=Of(e,-1),s=Of(t,-1),r=L(n,s);return Ct(Ie(r,-1))})}var Lf={meanSquaredError:gi,meanAbsoluteError:Pf,meanAbsolutePercentageError:bu,meanSquaredLogarithmicError:oz,squaredHinge:iz,hinge:lz,categoricalHinge:uz,logcosh:cz,categoricalCrossentropy:hd,sparseCategoricalCrossentropy:Mf,binaryCrossentropy:zf,kullbackLeiblerDivergence:pz,poisson:hz,cosineProximity:D1};function _1(e){if(typeof e=="string"){if(e in Lf)return Lf[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 H(t)}else return e}function F1(e,t){return G(()=>{let n=L(.5,os(t)),s=bf(qn(t,n),e.dtype);return _t(ns(e,s),-1)})}function $1(e,t){return G(()=>bf(ns(xs(e,-1),xs(t,-1)),"float32"))}function Vv(e,t){return G(()=>de(Ie(Ps(ns(e,1),ns(t,1))),"float32"))}function fz(e,t){return G(()=>de(Ie(Ps(ns(e,1),ns(t,0))),"float32"))}function mz(e,t){return G(()=>de(Ie(Ps(ns(e,0),ns(t,1))),"float32"))}function Uv(e,t){return G(()=>{let n=Vv(e,t),s=mz(e,t),r=le(n,s);return de(In(qn(r,0),fe(n,r),0),"float32")})}function gz(e,t){return G(()=>{let n=Vv(e,t),s=fz(e,t),r=le(n,s);return de(In(qn(r,0),fe(n,r),0),"float32")})}function Gv(e,t){return zf(e,t)}function Hv(e,t){return e.rank===t.rank&&(e=rt(e,[e.rank-1])),t=xs(t,-1),t.dtype!==e.dtype&&(t=de(t,e.dtype)),de(ns(e,t),"float32")}var Az=gi,yz=gi,xz=Pf,bz=Pf,vz=bu,wz=bu,O1=hd,kz=D1,jv=Mf,Bf={binaryAccuracy:F1,categoricalAccuracy:$1,precision:Uv,categoricalCrossentropy:O1,sparseCategoricalCrossentropy:jv,mse:Az,MSE:yz,mae:xz,MAE:bz,mape:vz,MAPE:wz,cosine:kz};function Iz(e){if(typeof e=="string"&&e in Bf)return Bf[e];if(typeof e!="string"&&e!=null)return e;throw new H(`Unknown metric ${e}`)}function Wf(e){if(vr(e!==null,`Unknown LossOrMetricFn ${e}`),typeof e=="string")return e;{let t;for(let n of Object.keys(Lf))if(Lf[n]===e){t=n;break}if(t!==void 0)return t;for(let n of Object.keys(Bf))if(Bf[n]===e){t=n;break}return t!==void 0?t:e.name}}function Sz(e){let t={Adagrad:()=>ci.adagrad(.01),Adadelta:()=>ci.adadelta(1,.95,Jt()),Adam:()=>ci.adam(.001,.9,.999,Jt()),Adamax:()=>ci.adamax(.002,.9,.999,Jt(),0),RMSProp:()=>ci.rmsprop(.001,.9,0,Jt()),SGD:()=>ci.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 H(`Unknown Optimizer ${e}`)}var qv=1*1024*1024;function Xv(e,t,n=!1){if(e==null||typeof e!="object"||Object.getPrototypeOf(e)!==Object.prototype||!P1(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>qv&&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 <= ${qv}.`)}}function P1(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"||!P1(e[n]))return!1;return!0}else if(Array.isArray(e)){for(let t of e)if(!P1(t))return!1;return!0}else return!1;else{let t=typeof e;return t==="string"||t==="number"||t==="boolean"}}function Cz(e,t,n,s=console.log){let r=Nz(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(u=>Math.floor(t*u)));let o;if(!r){a.push("Receives inputs"),o=[];for(let u in e.nodesByDepth)o.push(...e.nodesByDepth[u])}s("_".repeat(t)),Vf(a,n,s),s("=".repeat(t));let i=e.layers;for(let u=0;u<i.length;++u)r?Ez(i[u],n,s):Rz(i[u],n,o,s),s((u===i.length-1?"=":"_").repeat(t));e.checkTrainableWeightsConsistency();let l=Tz(e),c=Ff(e.nonTrainableWeights);s(`Total params: ${l+c}`),s(`Trainable params: ${l}`),s(`Non-trainable params: ${c}`),s("_".repeat(t))}function Tz(e){let t;return e.collectedTrainableWeights!=null?t=Ff(e.collectedTrainableWeights):t=Ff(e.trainableWeights),t}function Nz(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 Vf(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 Ez(e,t,n){let s;try{s=JSON.stringify(e.outputShape)}catch{s="multiple"}let r=e.name,a=e.getClassName(),o=[`${r} (${a})`,s,e.countParams().toString()];Vf(o,t,n)}function Rz(e,t,n,s){let r;try{r=JSON.stringify(e.outputShape)}catch{r="multiple"}let a=[];for(let u of e.inboundNodes)if(!(n!=null&&n.length>0&&n.indexOf(u)===-1))for(let d=0;d<u.inboundLayers.length;++d){let p=u.inboundLayers[d].name,h=u.nodeIndices[d],f=u.tensorIndices[d];a.push(`${p}[${h}][${f}]`)}let o=e.name,i=e.getClassName(),l=a.length===0?"":a[0],c=[`${o} (${i})`,r,e.countParams().toString(),l];Vf(c,t,s);for(let u=1;u<a.length;++u)Vf(["","","",a[u]],t,s)}function Kv(e,t,n){return(e==="inboundNodes"||e==="outputLayers"||e==="inputLayers")&&t===0&&typeof n=="string"}function fd(e,t){if(e===null)return null;if(typeof e=="string")return pi(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];Kv(t,r,a)?n.push(a):n.push(fd(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=pi(s);n[a]=fd(r,a)}}return n}}function M1(e,t){if(e==null)return null;if(typeof e=="string")return Vr(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];Kv(t,r,a)?n.push(a):n.push(M1(a,t))}return n}else{let n={};for(let s of Object.keys(e)){let r=e[s],a=Vr(s);(s==="name"||s==="className")&&typeof r=="string"?n[a]=r:n[a]=M1(r,s)}return n}}var z1="3.10.0";function Dz(e,t){if(e.dtype==null||e.dtype===t.dtype)return t;try{return de(t,e.dtype)}catch{throw new H(`The dtype of the feed (${t.dtype}) can not be cast to the dtype of the key '${e.name}' (${e.dtype}).`)}}var Ai=class{constructor(e){if(this.id2Value={},this.id2Mask={},this.name2Id={},e instanceof Ai)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]=Dz(e,t),this.name2Id[e.name]=e.id,n!=null&&(this.id2Mask[e.id]=n);else throw new H(`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 nr){if(this.id2Value[e.id]==null)throw new H(`Nonexistent key: ${e.name}`);return this.id2Value[e.id]}else{let t=this.name2Id[e];if(t==null)throw new H(`Feed dict has no SymbolicTensor name: ${e}`);return this.id2Value[t]}}getMask(e){if(e instanceof nr){if(this.id2Value[e.id]==null)throw new H(`Nonexistent key: ${e.name}`);return this.id2Mask[e.id]}else{let t=this.name2Id[e];if(t==null)throw new H(`Feed dict has no SymbolicTensor name: ${e}`);return this.id2Mask[t]}}disposeMasks(){this.id2Mask!=null&&Z(this.id2Mask)}},L1={},Zv={};function md(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=[],c=t.names();for(let f of i)c.indexOf(f)!==-1?l.push(t.getValue(f)):l.push(null);s!=null&&(s.maxNumTensors=-1/0,s.minNumTensors=1/0);let u=i.join(",")+"|"+t.names().join(","),d,p;if(L1[u]==null){let f=_z(o,t);d=f.sorted,p=f.recipientCounts,L1[u]=d,Zv[u]=p}d=L1[u],p={},r||Object.assign(p,Zv[u]);let h=new Ai(t);for(let f=0;f<d.length;++f){if(s!=null){let O=_h().numTensors;O>s.maxNumTensors&&(s.maxNumTensors=O),O<s.minNumTensors&&(s.minNumTensors=O)}let m=d[f],g=m.sourceLayer;if(g instanceof yu)continue;let A=[],y=[],x=[],b=!1;for(let O of m.inputs){let P=h.getValue(O),D=h.getMask(O);A.push(P),y.push(D),D!=null&&(b=!0),r||(p[O.name]--,p[O.name]===0&&!t.hasKey(O)&&i.indexOf(O.name)===-1&&!P.isDisposed&&O.sourceLayer.stateful!==!0&&x.push(P))}b&&(n=n||{},n.mask=y[0]);let v=bt(g.apply(A,n)),S=null;g.supportsMasking&&(S=g.computeMask(A,y));let T=$z(m),_=Array.isArray(T)?T:[T];for(let O=0;O<_.length;++O){h.hasKey(_[O])||h.add(_[O],v[O],Array.isArray(S)?S[0]:S);let P=i.indexOf(_[O].name);P!==-1&&(l[P]=v[O])}r||Z(x)}return h.disposeMasks(),a?l:l[0]}function _z(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=Yv(e[0],t);n=r.sorted,s=r.recipientMap}else{let r=new Set;for(let a of e){let{sorted:o,recipientMap:i}=Yv(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(c=>s[l].add(c))}}return{sorted:n,recipientCounts:Fz(s)}}function Fz(e){let t={};for(let n in e)t[n]=e[n].size;return t}function Yv(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 c of i.inputs)r[c.name]==null&&(r[c.name]=new Set),r[c.name].add(i.name),!n.has(c.name)&&a.push(c)}}return{sorted:s,recipientMap:r}}function $z(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 kr=class extends Je{constructor(e){super({});if(this.containerNodes=new Set,this.name=e.name,this.name==null){let A=this.getClassName().toLowerCase();this.name=Df(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],wa(this.inputs).length!==this.inputs.length)throw new H(`The list of inputs passed to the model is redundant. All inputs should only appear once. Found: ${this.inputs.map(A=>A.name)}`);wa(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;vr(x===0,"input layer has >1 nodes"),vr(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 yu))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,S)=>{(b==null||v==null||S==null)&&(b=A.sourceLayer,v=A.nodeIndex,S=A.tensorIndex);let T=b.inboundNodes[v];if(x.indexOf(T)!==-1)throw new Qs(`The tensor ${A.name} at layer "${b.name}" is part of a cycle.`);if(y.indexOf(T)!==-1)return;this.containerNodes.add(kr.nodeKey(b,v)),b.id in a||(a[b.id]=Object.keys(a).length),x.indexOf(T)===-1&&x.push(T);let _=T.inboundLayers.length;for(let O=0;O<_;O++){let P=T.inputTensors[O],D=T.inboundLayers[O],F=T.nodeIndices[O],C=T.tensorIndices[O];i(P,y,x,D,F,C)}for(y.push(T);x.indexOf(T)>=0;)x.splice(x.indexOf(T),1);o.push(T)},l=[],c=[];for(let A of this.outputs)i(A,l,c);let u=o.slice().reverse();for(let A of u){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],S=A.nodeIndices[b],T=v.inboundNodes[S],_=t[T.id]==null?0:t[T.id];t[T.id]=Math.max(y+1,_),n[T.id]=T}}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(xf);this.layers=[];for(let A of h){let y=p[A];y.sort((x,b)=>{let v=a[x.id],S=a[b.id];return v<S?-1:v>S?1:0});for(let x of y)x instanceof kr&&this.internalContainerRefs.push(x),this.layers.push(x)}this.layersByDepth=p,h=Object.keys(d).map(A=>parseInt(A,10)).sort(xf);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 Qs(`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 Qs(`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 $f({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 H("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 H(`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 H(`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 H(`${a.length} of ${s} weights are not set: ${a}`)}R1(r)}updatedConfig(){let e=this.getConfig(),t={};return t.className=this.getClassName(),t.config=e,t.kerasVersion=`tfjs-layers ${z1}`,t.backend="TensorFlow.js",t}toJSON(e,t=!0){let n=M1(this.updatedConfig());return t?JSON.stringify(n):n}call(e,t){return G(()=>{e=bt(e);let n=new Ai;for(let s=0;s<this.inputs.length;++s)n.add(this.inputs[s],e[s]);return md(this.outputs,n,t)})}computeMask(e,t){return G(()=>{e=bt(e);let n;return t==null?n=di(null,e.length):n=bt(t),this.runInternalGraph(e,n)[1]})}computeOutputShape(e){let t=_f(e);if(t.length!==this.inputLayers.length)throw new H(`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],c=i.name+"_0_0";n[c]=l}let s=Object.keys(this.nodesByDepth).map(o=>parseInt(o,10)).sort(xf);if(s.length>1)for(let o of s){let i=this.nodesByDepth[o];for(let l of i){let c=l.outboundLayer;if(this.inputLayers.map(f=>f.id).indexOf(c.id)!==-1)continue;let u=[];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];u.push(x)}let d=c.computeOutputShape(Xn(u)),p=_f(d),h=c.inboundNodes.indexOf(l);for(let f=0;f<p.length;f++){let m=`${c.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],c=this.outputLayersTensorIndices[o],u=`${i.name}_${l}_${c}`;a.push(u)}for(let o=0;o<a.length;o++){let i=a[o];vr(i in n),r.push(n[i])}return Xn(r)}runInternalGraph(e,t){t==null&&(t=di(null,e.length));let n={};for(let i=0;i<this.inputs.length;++i){let l=this.inputs[i],c=e[i],u=t[i];n[l.id]=[c,u]}let s=Object.keys(this.nodesByDepth).map(i=>parseInt(i,10)).sort(xf);for(let i of s){let l=this.nodesByDepth[i];for(let c of l){let u=c.outboundLayer,d=c.inputTensors,p=c.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(c.callArgs!=null&&(f=c.callArgs),h.length===1){let[x,b]=h[0];f.mask==null&&(f.mask=b),A=bt(u.call(x,f)),y=bt(u.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=bt(u.call(m,f)),y=bt(u.computeMask(m,g));if(u.activityRegularizer)throw new Me("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],S=y[x];n[b.id]=[v,S]}}}}let r=[],a=[],o=[];for(let i of this.outputs){vr(i.id in n,`Could not compute output ${i.name} : ${i.id}`);let[l,c]=n[i.id];o.push(l.shape),r.push(l),a.push(c)}return[r,a,o]}buildNodeConversionMap(e){let t={},n;for(let s of this.layers){n=s instanceof kr?1:0;for(let r=0;r<s.inboundNodes.length;r++){let a=kr.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 H(`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 H("Provide either a layer name or layer index");for(let n of this.layers)if(n.name===e)return n;throw new H(`No such layer: ${e}`)}calculateLosses(){return G(()=>{let e=[];for(let t of this.layers)for(let n=0;n<t.inboundNodes.length;++n){let s=kr.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 u=0;u<a.inboundNodes.length;u++){let d=a.inboundNodes[u],p=kr.nodeKey(a,u),h={};if(this.containerNodes.has(p)){if(d.callArgs)try{JSON.stringify(d.callArgs),h=d.callArgs}catch{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=kr.nodeKey(g,A),b=t[x];b==null&&(b=0),f.push([g.name,b,y,h])}l.push(f)}}}let c={};c.name=a.name,c.className=o,c.config=i,c.inboundNodes=l,n.push(c)}e.layers=n;let s=[];for(let a=0;a<this.inputLayers.length;a++){let o=this.inputLayers[a],i=this.inputLayersNodeIndices[a],l=kr.nodeKey(o,i);if(!this.containerNodes.has(l))continue;let c=t[l];c==null&&(c=0);let u=this.inputLayersTensorIndices[a];s.push([o.name,c,u])}e.inputLayers=s;let r=[];for(let a=0;a<this.outputLayers.length;a++){let o=this.outputLayers[a],i=this.outputLayersNodeIndices[a],l=kr.nodeKey(o,i);if(!this.containerNodes.has(l))continue;let c=t[l];c==null&&(c=0);let u=this.outputLayersTensorIndices[a];r.push([o.name,c,u])}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],S=x[2];if(y=x[3]==null?{}:x[3],!(b in r)){o(m,g);return}let T=r[b];if(T.inboundNodes.length<=v){o(m,g);return}let _=T.inboundNodes[v];A.push(_.outputTensors[S])}A.length>0&&m.apply(Xn(A),y)}function l(m){let g=m.name,A=sr(m,t.customObjects!=null?t.customObjects:{});A.setFastWeightInitDuringBuild(s),r[g]=A,m.inboundNodes.forEach(x=>{if(!(x instanceof Array))throw new H(`Corrupted configuration, expected array for nodeData: ${x}`);o(A,x)})}let c=t.name,u=t.layers;for(let m of u)l(m);for(;!dM(a);)for(let m of u){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];vr(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];vr(g in r);let b=r[g].inboundNodes[A].outputTensors;p.push(b[y])}return new e({inputs:d,outputs:p,name:c})}get stateful(){if(this._stateful)throw new H("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(){G(()=>{this.layers.forEach(e=>{e.stateful&&e.resetStates()})})}};function Oz(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 Jv(e,t){return Oz(e,t,"classWeight")}async function Qv(e,t,n,s){if(t!=null||s!=null)throw new Error("Support sampleWeight is not implemented yet");if(n!=null){let r=G(()=>{if(e.shape.length===1)return Xs(e);if(e.shape.length===2){if(e.shape[1]>1)return xs(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])}),Gt(o,"float32")}else return null}function Pz(e,t){return L(e,t)}var Mz=32;function ew(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=tw("input",e.inputNames,n),o=tw("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 tw(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 H(`The feature data generated by the dataset lacks the required ${e} key '${r}'.`);s.push(n[r])}return s}}function zz(e){if(e.length===3)throw new Me("Validation with sample weights is not implemented yet.");return{xs:e[0],ys:e[1]}}async function Lz(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(nw(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=zz(n.validationData);a=g.xs,o=g.ys}let i=e.makeTrainFunction(),l=e.getDedupedMetricsNames(),c;r?c=l.slice().concat(l.map(g=>"val_"+g)):c=l.slice();let u=Bv(n.callbacks,n.yieldEvery),d=n.verbose==null?1:n.verbose,{callbackList:p,history:h}=Wv(u,d,n.epochs,null,null,Bz(t,n),null,r,c);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}=ew(e,x.value),S={};S.batch=y,S.size=b[0].shape[0],await p.onBatchBegin(y,S);let T=[];if(n.classWeight!=null){let P=Jv(n.classWeight,e.outputNames);for(let D=0;D<P.length;++D)T.push(await Qv(v[D],null,P[D]))}let _=b.concat(v).concat(T),O=i(_);Z(_);for(let P=0;P<l.length;++P){let D=l[P],F=O[P];S[D]=F,an(F)}await p.onBatchEnd(y,S),Ov(S),y++,A++}if(s?A>=n.batchesPerEpoch:x.done){if(r){let b;nw(n.validationData)?b=bt(await e.evaluateDataset(n.validationData,{batches:n.validationBatches})):b=bt(e.evaluate(a,o,{batchSize:n.validationBatchSize==null?Mz: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 Bz(e,t){let n=null;return t.batchesPerEpoch!=null?n=t.batchesPerEpoch:Number.isFinite(e.size)&&(n=e.size),n}function nw(e){return typeof e.iterator=="function"}function Wz(e){return typeof e.next=="function"}async function Vz(e,t,n){n=n||{};let s=n.batches!=null,r=e.testFunction,a=[];if(n.verbose>0)throw new Me("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=Wz(t)?t:await t.iterator(),i=0,l=0;for(;s?l<n.batches:!0;){let c=await o.next();if(a=G(()=>{if(c.value){let{xs:u,ys:d}=ew(e,c.value),p=u.concat(d),h=G(()=>r(p));if(Z(p),l===0)for(let m=0;m<h.length;++m)a.push(Ee(0));let f=p[0].shape[0];for(let m=0;m<h.length;++m){let g=h[m],A=a[m];a[m]=G(()=>le(a[m],L(f,g))),l>0&&Z(A)}Z(h),i+=f,++l}return a}),c.done){s&&console.warn(`Your dataset iterator ran out of data during evaluateDataset(). Interrupting evalution. Make sure that your dataset can generate at least \`batches\` batches (in this case, ${n.batches} batches). You may need to use the repeat() function when building your dataset.`);break}}for(let c=0;c<a.length;++c){let u=a[c];a[c]=fe(a[c],i),Z(u)}return Xn(a)}function B1(e){w.assert(e>0&&Number.isInteger(e),()=>`batchSize is required to be a positive integer, but got ${e}`)}function gd(e,t,n){return e==null?[null]:Array.isArray(e)?e.map(s=>mi(s,t,n-t)):mi(e,t,n-t)}function W1(e,t){return G(()=>e==null?null:Array.isArray(e)?e.map(n=>W1(n,t)):Sv(e,t.dtype==="int32"?t:de(t,"int32")))}function V1(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 Uz(e,t,n,s,r,a,o,i,l,c,u,d,p,h,f){r==null&&(r=32),a==null&&(a=1),u==null&&(u=!0),p==null&&(p=0);let m=!1;if(l!=null&&c!=null&&(m=!0),f!=null&&(m=!0,h==null))throw new H("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=er(0,g)),o==null&&(o=1);let{callbackList:y,history:x}=Wv(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 Me("stepsPerEpoch mode is not implemented yet.");{if(u==="batch")throw new Me("batch shuffling is not implemneted yet");u&&w.shuffle(A);let S=Gt(A),T=V1(g,r);for(let _=0;_<T.length;++_){let O={};if(await y.onBatchBegin(_,O),G(()=>{let P=T[_][0],D=T[_][1],F=mi(S,P,D-P);O.batch=_,O.size=D-P;let C=W1(n,F),M=t(C);for(let U=0;U<s.length;++U){let j=s[U],q=M[U];O[j]=q,an(q)}if(_===T.length-1&&m){let U=e.testLoop(l,c,r);for(let j=0;j<s.length;++j){let q=s[j],X=U[j];an(X),v["val_"+q]=X}}}),await y.onBatchEnd(_,O),Ov(O),e.stopTraining_)break}S.dispose()}if(await y.onEpochEnd(b,v),e.stopTraining_)break}return await y.onTrainEnd(),await e.history.syncData(),e.history}async function Gz(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,c,u;try{let d=s.batchSize==null?32:s.batchSize;B1(d);let p=!1,h=await e.standardizeUserData(t,n,s.sampleWeight,s.classWeight,p,d);r=h[0],a=h[1],u=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 Me("validationData including sample weights is not supported yet."):new H(`When passing validation data, it must contain 2 (valX, valY) or 3 (valX, valY, valSampleWeight) items; ${s.validationData} is invalid.`);let T=!0,_=await e.standardizeUserData(o,i,null,null,T,d);l=_[0],c=_[1],m=l.concat(c)}else if(s.validationSplit!=null&&s.validationSplit>0&&s.validationSplit<1){f=!0;let T=Math.floor(r[0].shape[0]*(1-s.validationSplit)),_=r[0].shape[0];l=gd(r,T,_),r=gd(r,0,T),c=gd(a,T,_),a=gd(a,0,T),m=l.concat(c)}else s.validationSteps!=null&&(f=!0);let g=r.concat(a).concat(u);e.checkTrainableWeightsConsistency();let A=e.makeTrainFunction(),y=e.getDedupedMetricsNames(),x,b;f?(e.makeTestFunction(),x=e.testFunction,b=y.slice().concat(y.map(T=>"val_"+T))):(x=null,m=[],b=y.slice());let v=Bv(s.callbacks,s.yieldEvery);return await Uz(e,A,g,y,d,s.epochs,s.verbose,v,x,m,s.shuffle,b,s.initialEpoch,null,null)}finally{e.isTraining=!1,yi(r,t),yi(a,n),yi(l,o),yi(c,i),u!=null&&Z(u)}}function sw(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(cd(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 yi(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 Hz(e){return e instanceof Ge}function U1(e){return Array.isArray(e)}function rw(e){return!Hz(e)&&!U1(e)}function aw(e,t,n,s=!0,r=""){if(t==null||t.length===0){if(e!=null){let o=!1;if(U1(e)&&e.length>0)o=!0;else if(rw(e)){for(let i in e)if(e.hasOwnProperty(i)){o=!0;break}}else o=!0;if(o)throw new H(`Error when checking model ${r} expected no data, but got ${e}`)}return[]}if(e==null)return t.map(o=>null);let a;if(rw(e)){e=e,a=[];for(let o of t){if(e[o]==null)throw new H(`No data provided for "${o}". Need data for each key in: ${t}`);a.push(e[o])}}else if(U1(e)){if(e=e,e.length!==t.length)throw new H(`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 H(`The model ${r} expects ${t.length} Tensor(s), but only received one Tensor. Found: Tensor with shape ${e.shape}`);a=[e]}if(a=sw(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 H(`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 c=i.shape[l],u=n[o][l];if(u!=null&&u>=0&&c!==u)throw new H(`${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 jz(e,t,n){let s=wa(e.map(a=>a.shape[0]));s.sort();let r=wa(t.map(a=>a.shape[0]));if(r.sort(),s.length>1)throw new H(`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 H(`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 H(`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 qz(e,t,n){let s=[gi,zf,hd];for(let r=0;r<e.length;++r){let a=e[r],o=t[r],i=n[r];if(o!=null){if(o===hd&&a.shape[a.shape.length-1]===1)throw new H(`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),c=i.slice(1);for(let u=0;u<l.length;++u){let d=l[u],p=c[u];if(p!=null&&d!==p)throw new H(`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 ow(e,t,n,s=!0,r=""){let a;if(Array.isArray(e)){if(e.length!==t.length)throw new H(`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 H(`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 H(`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 c=i.shape[l],u=n[o][l];if(u!=null&&u!==c)throw new H(`Error when checking ${r}: expected ${t[o]} to have shape ${JSON.stringify(n[o])} but got array with shape ${JSON.stringify(i.shape)}.`)}}}function Xz(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 Kz="layers-model",Ur=class extends kr{constructor(e){super(e);this.isTraining=!1}summary(e,t,n=console.log){if(!this.built)throw new H("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).");Cz(this,e,t,n)}compile(e){if(e.loss==null&&(e.loss=[]),this.loss=e.loss,typeof e.optimizer=="string")this.optimizer_=Sz(e.optimizer),this.isOptimizerOwned=!0;else{if(!(e.optimizer instanceof Br))throw new H("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 H(`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(_1(e.loss[a]))}else if(Array.isArray(e.loss)){if(e.loss.length!==this.outputs.length)throw new H(`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=>_1(o))}else{let a=_1(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=[],fi("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=Xz(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])};fi("metric",()=>{for(let a=0;a<this.outputs.length;++a){if(n.indexOf(a)!==-1)continue;let o=s[a];(l=>{let c="",u,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]===zf?["accuracy","acc"].indexOf(h)!==-1?d=F1:["crossentropy","ce"].indexOf(h)!==-1&&(d=Gv):this.lossFunctions[a]===Mf?["accuracy","acc"].indexOf(h)!==-1?d=Hv:["crossentropy","ce"].indexOf(h)!==-1&&(d=jv):["accuracy","acc"].indexOf(h)!==-1?d=$1:["crossentropy","ce"].indexOf(h)!==-1&&(d=O1);let g;["accuracy","acc"].indexOf(h)!==-1?g="acc":["crossentropy","ce"].indexOf(h)!==-1&&(g="ce"),p=d,u=c+g}else p=Iz(h),u=c+Wf(h);let f;fi(u,()=>{f=p}),r(a,u,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;B1(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 Xn(l)}finally{yi(a[0],e),yi(a[1],t)}}async evaluateDataset(e,t){return this.makeTestFunction(),Vz(this,e,t)}checkNumSamples(e,t,n,s="steps"){let r;if(n!=null){if(r=null,t!=null)throw new H(`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 H(`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 H("`outputs` is an empty Array, which is not allowed.");let n=Array.isArray(t),s=n?t:[t],r=this.retrieveSymbolicTensors(s),a=new Ai;if(e instanceof Ge&&(e=[e]),Array.isArray(e)){if(e.length!==this.inputs.length)throw new H(`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 H(`No value is provided for the model's input ${i.name}`);a.add(i,l)}let o=md(r,a);return n?o:o[0]}retrieveSymbolicTensors(e){let t=di(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 H(`Cannot find SymbolicTensors for output name(s): ${JSON.stringify(s)}`)}return t}predictLoop(e,t=32,n=!1){return G(()=>{let s=this.checkNumSamples(e);if(n)throw new Me("Verbose predictLoop() is not implemented yet.");let r=V1(s,t),a=this.outputs.map(o=>[]);for(let o=0;o<r.length;++o)G(()=>{let l=r[o][0],c=r[o][1],u=gd(e,l,c),d=[];if(Array.isArray(u))for(let h=0;h<u.length;++h)d.push({key:this.inputs[h],value:u[h]});else d.push({key:this.inputs[0],value:u});let p=new Ai(d);return md(this.outputs,p)}).forEach((l,c)=>a[c].push(l));return Xn(a.map(o=>mt(o,0)))})}predict(e,t={}){let n=sw(e);ow(n,this.inputNames,this.feedInputShapes,!1);try{let s=t.batchSize==null?32:t.batchSize;return B1(s),this.predictLoop(n,s)}finally{yi(n,e)}}predictOnBatch(e){ow(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 Qs("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=aw(e,this.feedInputNames,this.feedInputShapes,!1,"input"),t=aw(t,this.feedOutputNames,r,!1,"target"),jz(e,t,null),qz(t,this.feedLossFns,this.feedOutputShapes),this.stateful&&s!=null&&s>0&&e[0].shape[0]%s!=0)throw new H(`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 c=Jv(s,this.outputNames);l=[];for(let u=0;u<c.length;++u)l.push(await Qv(i[u],null,c[u]))}return[o,i,l]}testLoop(e,t,n,s=0,r){return G(()=>{let a=this.checkNumSamples(t,n,r,"steps"),o=[];if(s>0)throw new Me("Verbose mode is not implemented yet.");if(r!=null)throw new Me("steps mode in testLoop() is not implemented yet");{let i=V1(a,n),l=Gt(er(0,a));for(let c=0;c<i.length;++c){let u=i[c][0],d=i[c][1],p=mi(l,u,d-u),h=W1(t,p),f=e(h);if(c===0)for(let m=0;m<f.length;++m)o.push(Ee(0));for(let m=0;m<f.length;++m){let g=f[m];o[m]=le(o[m],L(d-u,g))}}for(let c=0;c<o.length;++c)o[c]=fe(o[c],a)}return o})}getDedupedMetricsNames(){let e=this.metricsNames,t=[];for(let n=0;n<e.length;++n){let s=e[n],r=s;hv(e,s)>1&&(r+=`_${hv(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 u=[];for(let f=0;f<this.inputs.length;++f)u.push({key:this.inputs[f],value:n[f]});let d=new Ai(u),p=md(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=Pz(g,r[f]));let A=_t(g);t.push(A),f===0?h=g:h=le(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=_t(g(s[A],p[A]))}an(m),a.push(m)}return h=_t(h),this.calculateLosses().forEach(f=>{h=le(h,f)}),h},i=this.collectedTrainableWeights.map(u=>u.read()),l=!0;return[this.optimizer_.minimize(o,l,i)].concat(a)}}makeTestFunction(){this.testFunction=e=>G(()=>{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 Ai(a),i=md(this.outputs,o);for(let l=0;l<this.lossFunctions.length;++l){let c=this.lossFunctions[l],u=_t(c(r[l],i[l]));l===0?n=u:n=le(n,u),t.push(n)}for(let l=0;l<this.metricsTensors.length;++l){let c=this.metricsTensors[l][0],u=this.metricsTensors[l][1],d=_t(c(r[u],i[u]));t.push(d)}return t})}async fit(e,t,n={}){return Gz(this,e,t,n)}async fitDataset(e,t){return Lz(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 c=await l.data();i.push(c[0])}return Z(o),Xn(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=_h().numTensors;this.optimizer_.dispose(),e.numDisposedVariables+=t-_h().numTensors}return e}getLossIdentifiers(){let e;if(typeof this.loss=="string")e=Vr(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=>Vr(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]=Vr(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[Vr(Wf(this.metrics))];if(Array.isArray(this.metrics))return this.metrics.map(e=>Vr(Wf(e)));{let e={};for(let t in this.metrics)e[t]=Vr(Wf(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=fd(e.optimizer_config),n=sr(t),s;if(typeof e.loss=="string")s=pi(e.loss);else if(Array.isArray(e.loss))s=e.loss.map(a=>pi(a));else if(e.loss!=null){s={};for(let a in e.loss)s[a]=pi(e.loss[a])}let r;if(Array.isArray(e.metrics))r=e.metrics.map(a=>pi(a));else if(e.metrics!=null){r={};for(let a in e.metrics)r[a]=pi(e.metrics[a])}this.compile({loss:s,metrics:r,optimizer:n})}async save(e,t){if(typeof e=="string"){let l=Gn.getSaveHandlers(e);if(l.length===0)throw new H(`Cannot find any save handlers for URL '${e}'`);if(l.length>1)throw new H(`Found more than one (${l.length}) save handlers for URL '${e}'`);e=l[0]}if(e.save==null)throw new H("LayersModel.save() cannot proceed because the IOHandler provided does not have the `save` attribute defined.");let n=await Gn.encodeWeights(this.getNamedWeights(t)),s=!1,r=null,o={modelTopology:this.toJSON(r,s),format:Kz,generatedBy:`TensorFlow.js tfjs-layers v${z1}`,convertedBy:null};if((t==null?!1:t.includeOptimizer)&&this.optimizer!=null){o.trainingConfig=this.getTrainingConfig();let l="optimizer",{data:c,specs:u}=await Gn.encodeWeights(await this.optimizer.getWeights(),l);n.specs.push(...u),n.data=Gn.concatenateArrayBuffers([n.data,c])}if(this.userDefinedMetadata!=null){let l=!0;Xv(this.userDefinedMetadata,this.name,l),o.userDefinedMetadata=this.userDefinedMetadata}return o.weightData=n.data,o.weightSpecs=n.specs,e.save(o)}setUserDefinedMetadata(e){Xv(e,this.name),this.userDefinedMetadata=e}getUserDefinedMetadata(){return this.userDefinedMetadata}};Ur.className="Model";ue.registerClass(Ur);var iw=class extends Ur{};iw.className="Functional";ue.registerClass(iw);async function Zz(e,t){"modelTopology"in e||(e={modelTopology:e}),e=e;let n=e.modelTopology;n.model_config!=null&&(n=n.model_config);let s=fd(n),r=sr(s,t);if(e.weightsManifest!=null){let a=await Gn.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 Yz(e,t){if(t==null&&(t={}),typeof e=="string"){let n=Gn.getLoadHandlers(e,t);if(n.length===0)n.push(Gn.browserHTTPRequest(e,t));else if(n.length>1)throw new H(`Found more than one (${n.length}) load handlers for URL '${e}'`);e=n[0]}return Jz(e,void 0,t)}async function Jz(e,t,n){if(n==null&&(n={}),e.load==null)throw new H("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=sr(fd(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 H("LayersModel artifacts contains weight data, but not weight specs. Therefore loading of weights cannot proceed.");let{modelWeights:c,optimizerWeights:u}=Qz(s.weightData,s.weightSpecs);i.loadWeights(c,a),i.optimizer!=null&&u.length>0&&await i.optimizer.setWeights(u),Z(c),Z(u.map(d=>d.tensor))}return i}function Qz(e,t){let n=Gn.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 vu=class extends Ur{constructor(e){super({inputs:[],outputs:[]});if(e=e||{},this.trainable=!0,this.built=!1,this.name=e.name!=null?e.name:Df("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 H(`Negative dimension size caused by adding layer ${e.name} with input shape [${e.inboundNodes[0].inputTensors[0].shape}]`)}add(e){let t=e instanceof vu||e instanceof Ur,n;if(t){if(n=e,n.outputs.length!==1)throw new H("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 H("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 H("The first layer in a Sequential model must get an `inputShape` or `batchInputShape` argument.");let s=$v({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 H(`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 H("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=Fv(this.outputs[0])}this.inboundNodes=[],new $f({outboundLayer:this,inboundLayers:[],nodeIndices:[],tensorIndices:[],inputTensors:this.inputs,outputTensors:this.outputs,inputMasks:di(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(ct(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 Ur({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 Qs("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 Qs("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 Qs("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 Qs("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 H("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 vu))throw new Me(`Sequential.fromConfig called on non-Sequential input: ${o}`);for(let i of r){let c=sr(i,void 0,s);s&&c.setFastWeightInitDuringBuild(!0),o.add(c)}return o}set stopTraining(e){if(this.model==null)throw new H("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 H("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}}};vu.className="Sequential";ue.registerClass(vu);function eL(e){return new Ur(e)}function tL(e){return new vu(e)}function nL(e,t){return t==null&&(t={}),Yz(e,t)}function lw(e){return $v(e)}function sL(e,t){Ls.registerCallbackConstructor(e,t)}var Zn=class extends ue.Serializable{getConfig(){return{}}},uw=class extends Zn{apply(e,t=1){return EM(e,t)}};uw.className="elu";ue.registerClass(uw);var cw=class extends Zn{apply(e){return Jh(e)}};cw.className="selu";ue.registerClass(cw);var dw=class extends Zn{apply(e){return Zs(e)}};dw.className="relu";ue.registerClass(dw);var pw=class extends Zn{apply(e){return G(()=>uu(6,Zs(e)))}};pw.className="relu6";ue.registerClass(pw);var hw=class extends Zn{apply(e){return e}};hw.className="linear";ue.registerClass(hw);var fw=class extends Zn{apply(e){return Hn(e)}};fw.className="sigmoid";ue.registerClass(fw);var mw=class extends Zn{apply(e){return DM(e)}};mw.className="hardSigmoid";ue.registerClass(mw);var gw=class extends Zn{apply(e){return ai(e)}};gw.className="softplus";ue.registerClass(gw);var Aw=class extends Zn{apply(e){return RM(e)}};Aw.className="softsign";ue.registerClass(Aw);var yw=class extends Zn{apply(e){return ni(e)}};yw.className="tanh";ue.registerClass(yw);var G1=class extends Zn{apply(e,t=-1){return li(e,t)}};G1.className="softmax";ue.registerClass(G1);var xw=class extends Zn{apply(e,t=-1){return Hh(e,t)}};xw.className="logSoftmax";ue.registerClass(xw);var bw=class extends Zn{apply(e,t=1){return G(()=>L(Hn(L(e,t)),e))}};bw.className="swish";ue.registerClass(bw);var vw=class extends Zn{apply(e){return G(()=>L(e,ni(ai(e))))}};vw.className="mish";ue.registerClass(vw);function Ca(e){return e.getClassName()}function H1(e,t={}){return id(e,ue.SerializationMap.getMap().classNameMap,t,"activation")}function Ta(e){if(e==null){let t={};return t.className="linear",t.config={},H1(t)}if(typeof e=="string"){let t={};return t.className=e,t.config={},H1(t)}else return e instanceof Zn?e:H1(e)}function j1(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 ww=class extends ue.Serializable{},Ad=class extends ww{constructor(e){super();j1(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 G(()=>{let t=Ut([1]);return this.hasL1&&(t=le(t,Ie(L(this.l1,Vt(e))))),this.hasL2&&(t=le(t,Ie(L(this.l2,dd(e))))),V(t,[])})}getConfig(){return{l1:this.l1,l2:this.l2}}static fromConfig(e,t){return new e({l1:t.l1,l2:t.l2})}};Ad.className="L1L2";ue.registerClass(Ad);function rL(e){return j1(e),new Ad({l1:e!=null?e.l1:null,l2:0})}function aL(e){return j1(e),new Ad({l2:e!=null?e.l2:null,l1:0})}var kw={l1l2:"L1L2"};function gt(e){return u1(e)}function Iw(e,t={}){return id(e,ue.SerializationMap.getMap().classNameMap,t,"regularizer")}function Nt(e){if(e==null)return null;if(typeof e=="string"){let n={className:e in kw?kw[e]:e,config:{}};return Iw(n)}else return e instanceof ww?e:Iw(e)}var q1=class extends Je{constructor(e){super(e??{});this.supportsMasking=!0,e!=null&&(this.maxValue=e.maxValue)}call(e,t){e=Le(e);let n=Zs(e);return this.maxValue!=null&&(n=jn(n,0,this.maxValue)),n}computeOutputShape(e){return e}getConfig(){let e={maxValue:this.maxValue},t=super.getConfig();return Object.assign(e,t),e}};q1.className="ReLU";ue.registerClass(q1);var X1=class extends Je{constructor(e){super(e??{});this.DEFAULT_ALPHA=.3,e==null&&(e={}),this.alpha=e.alpha==null?this.DEFAULT_ALPHA:e.alpha}call(e,t){let n=Le(e);return Xc(n,this.alpha)}computeOutputShape(e){return e}getConfig(){let e={alpha:this.alpha},t=super.getConfig();return Object.assign(e,t),e}};X1.className="LeakyReLU";ue.registerClass(X1);var K1=class extends Je{constructor(e){super(e??{});if(this.DEFAULT_ALPHA_INITIALIZER="zeros",e==null&&(e={}),this.supportsMasking=!0,this.alphaInitializer=Tt(e.alphaInitializer||this.DEFAULT_ALPHA_INITIALIZER),this.alphaRegularizer=Nt(e.alphaRegularizer),this.alphaConstraint=en(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 H(`Expected sharedAxes to be a number or an array of numbers, but got ${e.sharedAxes}`)}build(e){e=ct(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=Le(e),ed(e,this.alpha.read())}getConfig(){let e={alphaInitializer:Ft(this.alphaInitializer),alphaRegularizer:gt(this.alphaRegularizer),alphaConstraint:Qt(this.alphaConstraint),sharedAxes:this.sharedAxes},t=super.getConfig();return Object.assign(e,t),e}};K1.className="PReLU";ue.registerClass(K1);var Z1=class extends Je{constructor(e){super(e??{});if(this.DEFAULT_ALPHA=1,e==null&&(e={}),e.alpha!=null&&e.alpha!==this.DEFAULT_ALPHA)throw new Me(`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=Le(e);return ou(n)}computeOutputShape(e){return e}getConfig(){let e={alpha:this.alpha},t=super.getConfig();return Object.assign(e,t),e}};Z1.className="ELU";ue.registerClass(Z1);var Y1=class extends Je{constructor(e){super(e??{});this.DEFAULT_THETA=1,e==null&&(e={}),this.theta=e.theta==null?this.DEFAULT_THETA:e.theta}call(e,t){let n=Le(e);return L(n,de(qn(n,this.theta),"float32"))}computeOutputShape(e){return e}getConfig(){let e={theta:this.theta},t=super.getConfig();return Object.assign(e,t),e}};Y1.className="ThresholdedReLU";ue.registerClass(Y1);var J1=class extends Je{constructor(e){super(e??{});this.DEFAULT_AXIS=1,e==null&&(e={}),this.softmax=new G1().apply,this.axis=e.axis==null?this.DEFAULT_AXIS:e.axis}call(e,t){let n=Le(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}};J1.className="Softmax";ue.registerClass(J1);function wu(e,t,n){if(typeof e=="number")return di(e,t);if(e.length!==t)throw new H(`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(!SM(r))throw new H(`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 rr(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 Ir(e,t,n,s){if(e==null)return null;if(s==="valid")e=e*t+Ia([n-t,0]);else if(s==="same")e=e*t;else throw new H(`Unsupport padding mode: ${s}.`);return e}function Q1(e,t){return G(()=>(Bt(t),t==="channelsFirst"?Ke(e,[0,2,3,1]):e))}function Sw(e,t){return G(()=>(Bt(t),t==="channelsFirst"?Ke(e,[0,2,3,4,1]):e))}function oL(e,t,n,s=1,r="valid",a,o=1){return G(()=>{if(a==null&&(a=Js()),Bt(a),e.shape.length!==3)throw new H(`The input of a conv1dWithBias operation should be 3, but is ${e.shape.length} instead.`);if(t.shape.length!==3)throw new H(`The kernel for a conv1dWithBias operation should be 3, but is ${t.shape.length} instead`);if(n!=null&&n.shape.length!==1)throw new H(`The bias for a conv1dWithBias operation should be 1, but is ${t.shape.length} instead`);if(a==="channelsFirst"&&(e=Ke(e,[0,2,1])),r==="causal")throw new Me("The support for CAUSAL padding mode in conv1dWithBias is not implemented yet.");let i=zh(e,t,s,r==="same"?"same":"valid","NWC",o);return n!=null&&(i=tr(i,n)),i})}function Cw(e,t,n,s=[1,1],r="valid",a,o,i=null){return G(()=>{if(a==null&&(a=Js()),Bt(a),e.rank!==3&&e.rank!==4)throw new H(`conv2dWithBiasActivation expects input to be of rank 3 or 4, but received ${e.rank}.`);if(t.rank!==3&&t.rank!==4)throw new H(`conv2dWithBiasActivation expects kernel to be of rank 3 or 4, but received ${e.rank}.`);let l=Q1(e,a);if(r==="causal")throw new Me("The support for CAUSAL padding mode in conv1dWithBias is not implemented yet.");return l=va.conv2d({x:l,filter:t,strides:s,pad:r==="same"?"same":"valid",dilations:o,dataFormat:"NHWC",bias:n,activation:i}),a==="channelsFirst"&&(l=Ke(l,[0,3,1,2])),l})}function iL(e,t,n,s=[1,1,1],r="valid",a,o){return G(()=>{if(a==null&&(a=Js()),Bt(a),e.rank!==4&&e.rank!==5)throw new H(`conv3dWithBias expects input to be of rank 4 or 5, but received ${e.rank}.`);if(t.rank!==4&&t.rank!==5)throw new H(`conv3dWithBias expects kernel to be of rank 4 or 5, but received ${e.rank}.`);let i=Sw(e,a);if(r==="causal")throw new Me("The support for CAUSAL padding mode in conv3dWithBias is not implemented yet.");return i=RA(i,t,s,r==="same"?"same":"valid","NDHWC",o),n!=null&&(i=tr(i,n)),a==="channelsFirst"&&(i=Ke(i,[0,4,1,2,3])),i})}var ey=class extends Je{constructor(e,t){super(t);if(this.bias=null,this.DEFAULT_KERNEL_INITIALIZER="glorotNormal",this.DEFAULT_BIAS_INITIALIZER="zeros",ey.verifyArgs(t),this.rank=e,ln(this.rank,"rank"),this.rank!==1&&this.rank!==2&&this.rank!==3)throw new Me(`Convolution layer for rank other than 1, 2, or 3 (${this.rank}) is not implemented yet.`);if(this.kernelSize=wu(t.kernelSize,e,"kernelSize"),this.strides=wu(t.strides==null?1:t.strides,e,"strides"),this.padding=t.padding==null?"valid":t.padding,ws(this.padding),this.dataFormat=t.dataFormat==null?"channelsLast":t.dataFormat,Bt(this.dataFormat),this.activation=Ta(t.activation),this.useBias=t.useBias==null?!0:t.useBias,this.biasInitializer=Tt(t.biasInitializer||this.DEFAULT_BIAS_INITIALIZER),this.biasConstraint=en(t.biasConstraint),this.biasRegularizer=Nt(t.biasRegularizer),this.activityRegularizer=Nt(t.activityRegularizer),this.dilationRate=wu(t.dilationRate==null?1:t.dilationRate,e,"dilationRate"),this.rank===1&&Array.isArray(this.dilationRate)&&this.dilationRate.length!==1)throw new H(`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 H(`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 H(`dilationRate must be a number or array of three numbers for 3D convolution, but received ${JSON.stringify(this.dilationRate)}`)}}static verifyArgs(e){if(vr("kernelSize"in e,"required key 'kernelSize' not in config"),typeof e.kernelSize!="number"&&!d1(e.kernelSize,"number",1,3))throw new H(`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:Ca(this.activation),useBias:this.useBias,biasInitializer:Ft(this.biasInitializer),biasRegularizer:gt(this.biasRegularizer),activityRegularizer:gt(this.activityRegularizer),biasConstraint:Qt(this.biasConstraint)},t=super.getConfig();return Object.assign(e,t),e}},yd=class extends ey{constructor(e,t){super(e,t);this.kernel=null,yd.verifyArgs(t),this.filters=t.filters,ln(this.filters,"filters"),this.kernelInitializer=Tt(t.kernelInitializer||this.DEFAULT_KERNEL_INITIALIZER),this.kernelConstraint=en(t.kernelConstraint),this.kernelRegularizer=Nt(t.kernelRegularizer)}build(e){e=ct(e);let t=this.dataFormat==="channelsFirst"?1:e.length-1;if(e[t]==null)throw new H(`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 G(()=>{e=Le(e);let n,s=this.bias==null?null:this.bias.read(),r=mv(this.activation.getClassName());if(r!=null&&this.rank===2)n=Cw(e,this.kernel.read(),s,this.strides,this.padding,this.dataFormat,this.dilationRate,r);else{if(this.rank===1)n=oL(e,this.kernel.read(),s,this.strides[0],this.padding,this.dataFormat,this.dilationRate[0]);else if(this.rank===2)n=Cw(e,this.kernel.read(),s,this.strides,this.padding,this.dataFormat,this.dilationRate);else if(this.rank===3)n=iL(e,this.kernel.read(),s,this.strides,this.padding,this.dataFormat,this.dilationRate);else throw new Me("convolutions greater than 3D are not implemented yet.");this.activation!=null&&(n=this.activation.apply(n))}return n})}computeOutputShape(e){e=ct(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=rr(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:Ft(this.kernelInitializer),kernelRegularizer:gt(this.kernelRegularizer),kernelConstraint:Qt(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 H(`Convolution layer expected config.filters to be a 'number' > 0 but got ${JSON.stringify(e.filters)}`)}},xd=class extends yd{constructor(e){super(2,e);xd.verifyArgs(e)}getConfig(){let e=super.getConfig();return delete e.rank,e}static verifyArgs(e){if(typeof e.kernelSize!="number"&&!d1(e.kernelSize,"number",1,2))throw new H(`Conv2D expects config.kernelSize to be number or number[] with length 1 or 2, but received ${JSON.stringify(e.kernelSize)}.`)}};xd.className="Conv2D";ue.registerClass(xd);var bd=class extends yd{constructor(e){super(3,e);bd.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 H(`Conv3D expects config.kernelSize to be number or [number, number, number], but received ${JSON.stringify(e.kernelSize)}.`)}};bd.className="Conv3D";ue.registerClass(bd);var ty=class extends xd{constructor(e){super(e);if(this.inputSpec=[new Ht({ndim:4})],this.padding!=="same"&&this.padding!=="valid")throw new H(`Conv2DTranspose currently supports only padding modes 'same' and 'valid', but received padding mode ${this.padding}`)}build(e){if(e=ct(e),e.length!==4)throw new H("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 H("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 G(()=>{let n=Le(e);if(n.shape.length!==4)throw new H(`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],c=this.kernelSize[0],u=this.kernelSize[1],d=this.strides[0],p=this.strides[1],h=Ir(i,d,c,this.padding),f=Ir(l,p,u,this.padding),m=[r,h,f,this.filters];this.dataFormat!=="channelsLast"&&(n=Ke(n,[0,2,3,1]));let g=Lh(n,this.kernel.read(),m,this.strides,this.padding);return this.dataFormat!=="channelsLast"&&(g=Ke(g,[0,3,1,2])),this.bias!=null&&(g=tr(g,this.bias.read(),this.dataFormat)),this.activation!=null&&(g=this.activation.apply(g)),g})}computeOutputShape(e){e=ct(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]=Ir(t[s],i,a,this.padding),t[r]=Ir(t[r],l,o,this.padding),t}getConfig(){let e=super.getConfig();return delete e.dilationRate,e}};ty.className="Conv2DTranspose";ue.registerClass(ty);var ny=class extends bd{constructor(e){super(e);if(this.inputSpec=[new Ht({ndim:5})],this.padding!=="same"&&this.padding!=="valid")throw new H(`Conv3DTranspose currently supports only padding modes 'same' and 'valid', but received padding mode ${this.padding}`)}build(e){if(e=ct(e),e.length!==5)throw new H("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 H("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 G(()=>{let n=Le(e);if(n.shape.length!==5)throw new H(`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],c=s[a],u=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=Ir(l,f,d,this.padding),y=Ir(c,m,p,this.padding),x=Ir(u,g,h,this.padding),b=[r,A,y,x,this.filters];this.dataFormat!=="channelsLast"&&(n=Ke(n,[0,2,3,4,1]));let v=f3(n,this.kernel.read(),b,this.strides,this.padding);return this.dataFormat!=="channelsLast"&&(v=Ke(v,[0,4,1,2,3])),this.bias!==null&&(v=tr(v,this.bias.read(),this.dataFormat)),this.activation!==null&&(v=this.activation.apply(v)),v})}computeOutputShape(e){e=ct(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],c=this.strides[0],u=this.strides[1],d=this.strides[2];return t[n]=this.filters,t[s]=Ir(t[s],c,o,this.padding),t[r]=Ir(t[r],u,i,this.padding),t[a]=Ir(t[a],d,l,this.padding),t}getConfig(){let e=super.getConfig();return delete e.dilationRate,e}};ny.className="Conv3DTranspose";ue.registerClass(ny);var Tw=class extends yd{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 H("The `filters` configuration field is required by SeparableConv, but is unspecified.");if(t.kernelInitializer!=null||t.kernelRegularizer!=null||t.kernelConstraint!=null)throw new H("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 H(`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=Tt(t.depthwiseInitializer||this.DEFAULT_DEPTHWISE_INITIALIZER),this.depthwiseRegularizer=Nt(t.depthwiseRegularizer),this.depthwiseConstraint=en(t.depthwiseConstraint),this.pointwiseInitializer=Tt(t.depthwiseInitializer||this.DEFAULT_POINTWISE_INITIALIZER),this.pointwiseRegularizer=Nt(t.pointwiseRegularizer),this.pointwiseConstraint=en(t.pointwiseConstraint)}build(e){if(e=ct(e),e.length<this.rank+2)throw new H(`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 H(`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 G(()=>{e=Le(e);let n;if(this.rank===1)throw new Me("1D separable convolution is not implemented yet.");return this.rank===2&&(this.dataFormat==="channelsFirst"&&(e=Ke(e,[0,2,3,1])),n=XA(e,this.depthwiseKernel.read(),this.pointwiseKernel.read(),this.strides,this.padding,this.dilationRate,"NHWC")),this.useBias&&(n=tr(n,this.bias.read(),this.dataFormat)),this.activation!=null&&(n=this.activation.apply(n)),this.dataFormat==="channelsFirst"&&(n=Ke(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=Ft(this.depthwiseInitializer),e.pointwiseInitializer=Ft(this.pointwiseInitializer),e.depthwiseRegularizer=gt(this.depthwiseRegularizer),e.pointwiseRegularizer=gt(this.pointwiseRegularizer),e.depthwiseConstraint=Qt(this.depthwiseConstraint),e.pointwiseConstraint=Qt(this.pointwiseConstraint),e}};Tw.className="SeparableConv";var sy=class extends Tw{constructor(e){super(2,e)}};sy.className="SeparableConv2D";ue.registerClass(sy);var Uf=class extends yd{constructor(e){super(1,e);Uf.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"&&!d1(e.kernelSize,"number",1,1))throw new H(`Conv1D expects config.kernelSize to be number or number[] with length 1, but received ${JSON.stringify(e.kernelSize)}.`)}};Uf.className="Conv1D";ue.registerClass(Uf);var ry=class extends Je{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 G(()=>{if(e=Le(e),this.dataFormat==="channelsLast"){let n=vf(e,this.cropping[0][0],e.shape[1]-this.cropping[0][0]-this.cropping[0][1],2);return vf(n,this.cropping[1][0],e.shape[2]-this.cropping[1][1]-this.cropping[1][0],3)}else{let n=vf(e,this.cropping[0][0],e.shape[2]-this.cropping[0][0]-this.cropping[0][1],3);return vf(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}};ry.className="Cropping2D";ue.registerClass(ry);var ay=class extends Je{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,wM(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 G(()=>{let n=Le(e),s=n.shape;if(this.dataFormat==="channelsFirst"){n=Ke(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 Ke(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}};ay.className="UpSampling2D";ue.registerClass(ay);function lL(e,t,n=[1,1],s="valid",r,a){return G(()=>{r==null&&(r=Js()),Bt(r);let o=Q1(e,r);if(e.rank!==4)throw new H(`Input for depthwiseConv2d is required to be 4-D, but is instead ${e.rank}-D`);if(t.rank!==4)throw new H(`depthwiseKernel is required to be 4-D, but is instead ${t.rank}-D`);return o=au(o,t,n,s==="same"?"same":"valid","NHWC",a),r==="channelsFirst"&&(o=Ke(o,[0,3,1,2])),o})}var oy=class extends ey{constructor(e){super(2,e);this.depthwiseKernel=null,this.depthMultiplier=e.depthMultiplier==null?1:e.depthMultiplier,this.depthwiseInitializer=Tt(e.depthwiseInitializer||this.DEFAULT_KERNEL_INITIALIZER),this.depthwiseConstraint=en(e.depthwiseConstraint),this.depthwiseRegularizer=Nt(e.depthwiseRegularizer)}build(e){if(e=ct(e),e.length<4)throw new H(`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 H(`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 G(()=>{e=Le(e);let n=lL(e,this.depthwiseKernel.read(),this.strides,this.padding,this.dataFormat,null);return this.useBias&&(n=tr(n,this.bias.read(),this.dataFormat)),this.activation!=null&&(n=this.activation.apply(n)),n})}computeOutputShape(e){e=ct(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=rr(t,this.kernelSize[0],this.padding,this.strides[0]),a=rr(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=Ft(this.depthwiseInitializer),e.depthwiseRegularizer=gt(this.depthwiseRegularizer),e.depthwiseConstraint=Qt(this.depthwiseRegularizer),e}};oy.className="DepthwiseConv2D";ue.registerClass(oy);function Nw(e,t,n,s){if(Array.isArray(e)){if(t!=null||n!=null)throw new H("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 Ew(e,t,n,s=!1,r,a,o=!1,i=!1){return G(()=>{let l=t.shape.length;if(l<3)throw new H(`Input should be at least 3D, but is ${l}D.`);let c=[1,0].concat(er(2,l));if(t=Ke(t,c),a!=null)throw new Me("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=de(de(r,"bool"),"float32"),r.rank===l-1&&(r=Lt(r,-1)),r=Ke(r,c)),s&&(t=is(t,0),r!=null&&(r=is(r,0)));let u=[],d,p=n,h=t.shape[0],f=Dn(t),m;r!=null&&(m=Dn(r));for(let A=0;A<h;++A){let y=f[A],x=G(()=>e(y,p));if(r==null)d=x[0],p=x[1];else{let b=G(()=>{let v=m[A],S=be(os(v),v),T=le(L(x[0],v),L(p[0],S)),_=p.map((O,P)=>le(L(x[1][P],v),L(O,S)));return{output:T,newStates:_}});d=b.output,p=b.newStates}i&&u.push(d)}let g;return i&&(g=gn(u,1)),[d,g,p]})}var Sr=class extends Je{constructor(e){super(e);let t;if(e.cell==null)throw new H("cell property is missing for the constructor of RNN.");if(Array.isArray(e.cell)?t=new jf({cells:e.cell}):t=e.cell,t.stateSize==null)throw new H("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 er(0,e).map(t=>null)}else return this.states_}setStates(e){this.states_=e}computeOutputShape(e){N1(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 G(()=>{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 Me("Constants support is not implemented in RNN yet.");N1(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 Me("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 H(`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){G(()=>{if(!this.stateful)throw new Wr("Cannot call resetStates() on an RNN Layer that is not stateful.");let n=this.inputSpec[0].shape[0];if(n==null)throw new H("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=>Ut([n,s])):this.states_=[Ut([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=>Ut([n,s])):this.states_[0]=Ut([n,this.cell.stateSize]);else{if(Array.isArray(e)||(e=[e]),e.length!==this.states_.length)throw new H(`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 H(`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=>an(s.clone()))})}apply(e,t){let n=t==null?null:t.initialState,s=t==null?null:t.constants;t==null&&(t={});let r=Nw(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 nr){let l=[e].concat(a),c=this.inputSpec.concat(o),u=this.inputSpec;this.inputSpec=c;let d=super.apply(l,t);return this.inputSpec=u,d}else return super.apply(e,t)}call(e,t){return G(()=>{let n=t==null?null:t.mask,s=t==null?null:t.training,r=t==null?null:t.initialState;e=Le(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 H(`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=Ew((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),c=l[0],u=l[1],d=l[2];this.stateful&&this.resetStates(d,s);let p=this.returnSequences?u:c;return this.returnState?[p].concat(d):p})}getInitialState(e){return G(()=>{let t=Ut(e.shape);return t=Ie(t,[1,2]),t=cd(t),Array.isArray(this.cell.stateSize)?this.cell.stateSize.map(n=>n>1?x1(t,[1,n]):t):this.cell.stateSize>1?[x1(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()===Sr.className&&(t.cell={className:this.cell.getClassName(),config:n}),Object.assign({},n,e,t)}static fromConfig(e,t,n={}){let s=t.cell,r=sr(s,n);return new e(Object.assign(t,{cell:r}))}};Sr.className="RNN";ue.registerClass(Sr);var vd=class extends Je{},Gf=class extends vd{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=Ta(e.activation==null?this.DEFAULT_ACTIVATION:e.activation),this.useBias=e.useBias==null?!0:e.useBias,this.kernelInitializer=Tt(e.kernelInitializer||this.DEFAULT_KERNEL_INITIALIZER),this.recurrentInitializer=Tt(e.recurrentInitializer||this.DEFAULT_RECURRENT_INITIALIZER),this.biasInitializer=Tt(e.biasInitializer||this.DEFAULT_BIAS_INITIALIZER),this.kernelRegularizer=Nt(e.kernelRegularizer),this.recurrentRegularizer=Nt(e.recurrentRegularizer),this.biasRegularizer=Nt(e.biasRegularizer),this.kernelConstraint=en(e.kernelConstraint),this.recurrentConstraint=en(e.recurrentConstraint),this.biasConstraint=en(e.biasConstraint),this.dropout=Au([1,Ia([0,e.dropout==null?0:e.dropout])]),this.recurrentDropout=Au([1,Ia([0,e.recurrentDropout==null?0:e.recurrentDropout])]),this.dropoutFunc=e.dropoutFunc,this.stateSize=this.units,this.dropoutMask=null,this.recurrentDropoutMask=null}build(e){e=ct(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 G(()=>{if(e=e,e.length!==2)throw new H(`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=Na({ones:()=>os(e),rate:this.dropout,training:s,dropoutFunc:this.dropoutFunc})),0<this.recurrentDropout&&this.recurrentDropout<1&&this.recurrentDropoutMask==null&&(this.recurrentDropoutMask=Na({ones:()=>os(n),rate:this.recurrentDropout,training:s,dropoutFunc:this.dropoutFunc}));let r,a=this.dropoutMask,o=this.recurrentDropoutMask;a!=null?r=wr(L(e,a),this.kernel.read()):r=wr(e,this.kernel.read()),this.bias!=null&&(r=tr(r,this.bias.read())),o!=null&&(n=L(n,o));let i=le(r,wr(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:Ca(this.activation),useBias:this.useBias,kernelInitializer:Ft(this.kernelInitializer),recurrentInitializer:Ft(this.recurrentInitializer),biasInitializer:Ft(this.biasInitializer),kernelRegularizer:gt(this.kernelRegularizer),recurrentRegularizer:gt(this.recurrentRegularizer),biasRegularizer:gt(this.biasRegularizer),activityRegularizer:gt(this.activityRegularizer),kernelConstraint:Qt(this.kernelConstraint),recurrentConstraint:Qt(this.recurrentConstraint),biasConstraint:Qt(this.biasConstraint),dropout:this.dropout,recurrentDropout:this.recurrentDropout};return Object.assign({},e,t)}};Gf.className="SimpleRNNCell";ue.registerClass(Gf);var iy=class extends Sr{constructor(e){e.cell=new Gf(e);super(e)}call(e,t){return G(()=>{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)}};iy.className="SimpleRNN";ue.registerClass(iy);var Hf=class extends vd{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 H("GRUCell does not support reset_after parameter set to true.");this.units=e.units,ln(this.units,"units"),this.activation=Ta(e.activation===void 0?this.DEFAULT_ACTIVATION:e.activation),this.recurrentActivation=Ta(e.recurrentActivation===void 0?this.DEFAULT_RECURRENT_ACTIVATION:e.recurrentActivation),this.useBias=e.useBias==null?!0:e.useBias,this.kernelInitializer=Tt(e.kernelInitializer||this.DEFAULT_KERNEL_INITIALIZER),this.recurrentInitializer=Tt(e.recurrentInitializer||this.DEFAULT_RECURRENT_INITIALIZER),this.biasInitializer=Tt(e.biasInitializer||this.DEFAULT_BIAS_INITIALIZER),this.kernelRegularizer=Nt(e.kernelRegularizer),this.recurrentRegularizer=Nt(e.recurrentRegularizer),this.biasRegularizer=Nt(e.biasRegularizer),this.kernelConstraint=en(e.kernelConstraint),this.recurrentConstraint=en(e.recurrentConstraint),this.biasConstraint=en(e.biasConstraint),this.dropout=Au([1,Ia([0,e.dropout==null?0:e.dropout])]),this.recurrentDropout=Au([1,Ia([0,e.recurrentDropout==null?0:e.recurrentDropout])]),this.dropoutFunc=e.dropoutFunc,this.implementation=e.implementation,this.stateSize=this.units,this.dropoutMask=null,this.recurrentDropoutMask=null}build(e){e=ct(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 G(()=>{if(e=e,e.length!==2)throw new H(`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=Na({ones:()=>os(e),rate:this.dropout,training:n,count:3,dropoutFunc:this.dropoutFunc})),0<this.recurrentDropout&&this.recurrentDropout<1&&this.recurrentDropoutMask==null&&(this.recurrentDropoutMask=Na({ones:()=>os(s),rate:this.recurrentDropout,training:n,count:3,dropoutFunc:this.dropoutFunc}));let r=this.dropoutMask,a=this.recurrentDropoutMask,o,i,l;0<this.dropout&&this.dropout<1&&(e=L(e,r[0]));let c=wr(e,this.kernel.read());this.useBias&&(c=tr(c,this.bias.read())),0<this.recurrentDropout&&this.recurrentDropout<1&&(s=L(s,a[0]));let u=this.recurrentKernel.read(),[d,p]=on(u,[2*this.units,this.units],u.rank-1),h=wr(s,d),[f,m,g]=on(c,3,c.rank-1),[A,y]=on(h,2,h.rank-1);o=this.recurrentActivation.apply(le(f,A)),i=this.recurrentActivation.apply(le(m,y));let x=wr(L(i,s),p);l=this.activation.apply(le(g,x));let b=le(L(o,s),L(le(1,Ct(o)),l));return[b,b]})}getConfig(){let e=super.getConfig(),t={units:this.units,activation:Ca(this.activation),recurrentActivation:Ca(this.recurrentActivation),useBias:this.useBias,kernelInitializer:Ft(this.kernelInitializer),recurrentInitializer:Ft(this.recurrentInitializer),biasInitializer:Ft(this.biasInitializer),kernelRegularizer:gt(this.kernelRegularizer),recurrentRegularizer:gt(this.recurrentRegularizer),biasRegularizer:gt(this.biasRegularizer),activityRegularizer:gt(this.activityRegularizer),kernelConstraint:Qt(this.kernelConstraint),recurrentConstraint:Qt(this.recurrentConstraint),biasConstraint:Qt(this.biasConstraint),dropout:this.dropout,recurrentDropout:this.recurrentDropout,implementation:this.implementation,resetAfter:!1};return Object.assign({},e,t)}};Hf.className="GRUCell";ue.registerClass(Hf);var ly=class extends Sr{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 Hf(e);super(e)}call(e,t){return G(()=>{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)}};ly.className="GRU";ue.registerClass(ly);var wd=class extends vd{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=Ta(e.activation===void 0?this.DEFAULT_ACTIVATION:e.activation),this.recurrentActivation=Ta(e.recurrentActivation===void 0?this.DEFAULT_RECURRENT_ACTIVATION:e.recurrentActivation),this.useBias=e.useBias==null?!0:e.useBias,this.kernelInitializer=Tt(e.kernelInitializer||this.DEFAULT_KERNEL_INITIALIZER),this.recurrentInitializer=Tt(e.recurrentInitializer||this.DEFAULT_RECURRENT_INITIALIZER),this.biasInitializer=Tt(e.biasInitializer||this.DEFAULT_BIAS_INITIALIZER),this.unitForgetBias=e.unitForgetBias,this.kernelRegularizer=Nt(e.kernelRegularizer),this.recurrentRegularizer=Nt(e.recurrentRegularizer),this.biasRegularizer=Nt(e.biasRegularizer),this.kernelConstraint=en(e.kernelConstraint),this.recurrentConstraint=en(e.recurrentConstraint),this.biasConstraint=en(e.biasConstraint),this.dropout=Au([1,Ia([0,e.dropout==null?0:e.dropout])]),this.recurrentDropout=Au([1,Ia([0,e.recurrentDropout==null?0:e.recurrentDropout])]),this.dropoutFunc=e.dropoutFunc,this.implementation=e.implementation,this.stateSize=[this.units,this.units],this.dropoutMask=null,this.recurrentDropoutMask=null}build(e){var t;e=ct(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 zs{apply(i,l){let c=r.apply([a]),u=new kf().apply([a]),d=r.apply([a*2]);return Iv(Iv(c,u),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 G(()=>{let n=t.training==null?!1:t.training;if(e=e,e.length!==3)throw new H(`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=Na({ones:()=>os(e),rate:this.dropout,training:n,count:4,dropoutFunc:this.dropoutFunc})),0<this.recurrentDropout&&this.recurrentDropout<1&&this.recurrentDropoutMask==null&&(this.recurrentDropoutMask=Na({ones:()=>os(s),rate:this.recurrentDropout,training:n,count:4,dropoutFunc:this.dropoutFunc}));let a=this.dropoutMask,o=this.recurrentDropoutMask,i,l,c,u;0<this.dropout&&this.dropout<1&&(e=L(e,a[0]));let d=wr(e,this.kernel.read());0<this.recurrentDropout&&this.recurrentDropout<1&&(s=L(s,o[0])),d=le(d,wr(s,this.recurrentKernel.read())),this.useBias&&(d=tr(d,this.bias.read()));let[p,h,f,m]=on(d,4,d.rank-1);i=this.recurrentActivation.apply(p),l=this.recurrentActivation.apply(h),c=le(L(l,r),L(i,this.activation.apply(f))),u=this.recurrentActivation.apply(m);let g=L(u,this.activation.apply(c));return[g,g,c]})}getConfig(){let e=super.getConfig(),t={units:this.units,activation:Ca(this.activation),recurrentActivation:Ca(this.recurrentActivation),useBias:this.useBias,kernelInitializer:Ft(this.kernelInitializer),recurrentInitializer:Ft(this.recurrentInitializer),biasInitializer:Ft(this.biasInitializer),unitForgetBias:this.unitForgetBias,kernelRegularizer:gt(this.kernelRegularizer),recurrentRegularizer:gt(this.recurrentRegularizer),biasRegularizer:gt(this.biasRegularizer),activityRegularizer:gt(this.activityRegularizer),kernelConstraint:Qt(this.kernelConstraint),recurrentConstraint:Qt(this.recurrentConstraint),biasConstraint:Qt(this.biasConstraint),dropout:this.dropout,recurrentDropout:this.recurrentDropout,implementation:this.implementation};return Object.assign({},e,t)}};wd.className="LSTMCell";ue.registerClass(wd);var uy=class extends Sr{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 wd(e);super(e)}call(e,t){return G(()=>{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)}};uy.className="LSTM";ue.registerClass(uy);var jf=class extends vd{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 G(()=>{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){N1(e)&&(e=e[0]),e=e;let t;this.cells.forEach((n,s)=>{fi(`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(sr(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 E1(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]])}R1(t)}};jf.className="StackedRNNCells";ue.registerClass(jf);function Na(e){let{ones:t,rate:n,training:s=!1,count:r=1,dropoutFunc:a}=e,o=()=>a!=null?a(t(),n):Cv(t(),n),i=()=>pd(o,t,s);return!r||r<=1?an(i().clone()):Array(r).fill(void 0).map(i).map(c=>an(c.clone()))}var uL=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},Rw=class extends Sr{constructor(e){if(e.unroll)throw new Me("Unrolling is not possible with convolutional RNNs.");if(Array.isArray(e.cell))throw new Me("It is not possible at the moment to stack convolutional cells.");super(e);this.inputSpec=[new Ht({ndim:5})]}call(e,t){return G(()=>{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 H("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 G(()=>{let{stateSize:t}=this.cell,n=e.shape,s=this.computeSingleOutputShape(n),r=[s[0],...s.slice(2)],a=Ut(r);return Array.isArray(t)?Array(t.length).fill(a):[a]})}resetStates(e,t=!1){G(()=>{if(!this.stateful)throw new Wr("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 H("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(()=>Ut(r)):this.states_=[Ut(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(()=>Ut(r)):this.states_[0]=Ut(r);else{if(Array.isArray(e)||(e=[e]),e.length!==this.states_.length)throw new H(`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 H(`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=>an(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],c=e[i?4:3],u=rr(l,s[0],r,a[0],o[0]),d=rr(c,s[1],r,a[1],o[1]);return[...e.slice(0,2),...i?[n,u,d]:[u,d,n]]}};Rw.className="ConvRNN2D";var qf=class extends wd{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=wu(n,2,"kernelSize"),this.kernelSize.forEach(i=>ln(i,"kernelSize")),this.strides=wu(s||1,2,"strides"),this.strides.forEach(i=>ln(i,"strides")),this.padding=r||"valid",ws(this.padding),this.dataFormat=a||"channelsLast",Bt(this.dataFormat),this.dilationRate=wu(o||1,2,"dilationRate"),this.dilationRate.forEach(i=>ln(i,"dilationRate"))}build(e){var t;e=ct(e);let n=this.dataFormat==="channelsFirst"?1:e.length-1;if(e[n]==null)throw new H(`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,c=this.filters;i=new(t=class extends zs{apply(d,p){let h=l.apply([c]),f=as([c]),m=l.apply([c*2]);return y1([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 G(()=>{if(e.length!==3)throw new H(`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=Na({ones:()=>os(s),rate:this.dropout,training:n,count:o,dropoutFunc:this.dropoutFunc}));let i=this.dropoutMask,l=(te,ne,se)=>!ne||!ne[se]?te:L(ne[se],te),c=l(s,i,0),u=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=Na({ones:()=>os(r),rate:this.recurrentDropout,training:n,count:o,dropoutFunc:this.dropoutFunc}));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,S]=on(this.kernel.read(),o,y),[T,_,O,P]=this.useBias?on(this.bias.read(),o):[null,null,null,null];c=this.inputConv(c,x,T,this.padding),u=this.inputConv(u,b,_,this.padding),d=this.inputConv(d,v,O,this.padding),p=this.inputConv(p,S,P,this.padding);let[D,F,C,M]=on(this.recurrentKernel.read(),o,y);f=this.recurrentConv(f,D),m=this.recurrentConv(m,F),g=this.recurrentConv(g,C),A=this.recurrentConv(A,M);let U=this.recurrentActivation.apply(le(c,f)),j=this.recurrentActivation.apply(le(u,m)),q=le(L(j,a),L(U,this.activation.apply(le(d,g)))),X=L(this.recurrentActivation.apply(le(p,A)),this.activation.apply(q));return[X,X,q]})}getConfig(){let e=super.getConfig(),{units:t}=e,n=uL(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=Mr(e,t,this.strides,s||"valid",this.dataFormat==="channelsFirst"?"NCHW":"NHWC",this.dilationRate);return n?tr(r,n,this.dataFormat):r}recurrentConv(e,t){return Mr(e,t,1,"same",this.dataFormat==="channelsFirst"?"NCHW":"NHWC")}};qf.className="ConvLSTM2DCell";ue.registerClass(qf);var cy=class extends Rw{constructor(e){let t=new qf(e);super(Object.assign({},e,{cell:t}))}static fromConfig(e,t){return new e(t)}};cy.className="ConvLSTM2D";ue.registerClass(cy);var Xf=class extends Je{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 G(()=>{this.invokeCallHook(e,t);let n=Le(e);if(0<this.rate&&this.rate<1){let s=t.training==null?!1:t.training,r=this.getNoiseShape(n);return pd(()=>Cv(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()}};Xf.className="Dropout";ue.registerClass(Xf);var dy=class extends Xf{constructor(e){super(e);this.inputSpec=[{ndim:3}]}getNoiseShape(e){let t=e.shape;return[t[0],1,t[2]]}};dy.className="SpatialDropout1D";ue.registerClass(dy);var py=class extends Je{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=Ta(e.activation),e.useBias!=null&&(this.useBias=e.useBias),this.kernelInitializer=Tt(e.kernelInitializer||this.DEFAULT_KERNEL_INITIALIZER),this.biasInitializer=Tt(e.biasInitializer||this.DEFAULT_BIAS_INITIALIZER),this.kernelConstraint=en(e.kernelConstraint),this.biasConstraint=en(e.biasConstraint),this.kernelRegularizer=Nt(e.kernelRegularizer),this.biasRegularizer=Nt(e.biasRegularizer),this.activityRegularizer=Nt(e.activityRegularizer),this.supportsMasking=!0,this.inputSpec=[{minNDim:2}]}build(e){e=ct(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=ct(e);let t=e.slice();return t[t.length-1]=this.units,t}call(e,t){return G(()=>{this.invokeCallHook(e,t);let n=Le(e),s=mv(this.activation.getClassName()),r;return s!=null?r=wr(n,this.kernel.read(),s,this.bias?this.bias.read():null):(r=wr(n,this.kernel.read()),this.bias!=null&&(r=tr(r,this.bias.read())),this.activation!=null&&(r=this.activation.apply(r))),r})}getConfig(){let e={units:this.units,activation:Ca(this.activation),useBias:this.useBias,kernelInitializer:Ft(this.kernelInitializer),biasInitializer:Ft(this.biasInitializer),kernelRegularizer:gt(this.kernelRegularizer),biasRegularizer:gt(this.biasRegularizer),activityRegularizer:gt(this.activityRegularizer),kernelConstraint:Qt(this.kernelConstraint),biasConstraint:Qt(this.biasConstraint)},t=super.getConfig();return Object.assign(e,t),e}};py.className="Dense";ue.registerClass(py);var hy=class extends Je{constructor(e){e=e||{};super(e);this.inputSpec=[{minNDim:3}],this.dataFormat=e.dataFormat}computeOutputShape(e){e=ct(e);for(let t of e.slice(1))if(t==null)throw new H(`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],ka(e,1)]}call(e,t){return G(()=>{this.invokeCallHook(e,t);let n=Le(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=Ke(n,s)}return NM(n)})}getConfig(){let e={};this.dataFormat!=null&&(e.dataFormat=this.dataFormat);let t=super.getConfig();return Object.assign(e,t),e}};hy.className="Flatten";ue.registerClass(hy);var fy=class extends Je{constructor(e){super(e);this.supportsMasking=!0,this.activation=Ta(e.activation)}call(e,t){return G(()=>{this.invokeCallHook(e,t);let n=Le(e);return this.activation.apply(n)})}getConfig(){let e={activation:Ca(this.activation)},t=super.getConfig();return Object.assign(e,t),e}};fy.className="Activation";ue.registerClass(fy);var my=class extends Je{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 G(()=>(e=Le(e),CM(e,this.n)))}getConfig(){let e={n:this.n},t=super.getConfig();return Object.assign(e,t),e}};my.className="RepeatVector";ue.registerClass(my);var gy=class extends Je{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 H("Can only specifiy one unknown dimension.");else r*=l}let o=ka(e);if(a!==null){if(r===0||o%r!=0)throw new H(n);s[a]=o/r}else if(o!==r)throw new H(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 G(()=>{this.invokeCallHook(e,t);let n=Le(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}};gy.className="Reshape";ue.registerClass(gy);var Ay=class extends Je{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=er(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=ct(e);let t=e.slice();return this.dims.forEach((n,s)=>{t[s+1]=e[n]}),t}call(e,t){return Ke(Le(e),this.dimsIncludingBatch)}getConfig(){let e={dims:this.dims},t=super.getConfig();return Object.assign(e,t),e}};Ay.className="Permute";ue.registerClass(Ay);var yy=class extends Je{constructor(e){super(e??{});this.supportsMasking=!0,e!=null?this.maskValue=e.maskValue==null?0:e.maskValue:this.maskValue=0}computeOutputShape(e){return e}getConfig(){let e=super.getConfig(),t={maskValue:this.maskValue};return Object.assign(t,e),t}computeMask(e,t){let n=Le(e),s=-1;return Uc(ii(n,this.maskValue),s)}call(e,t){return G(()=>{this.invokeCallHook(e,t);let n=Le(e),s=-1,r=!0,a=Uc(ii(n,this.maskValue),s,r);return L(n,de(a,n.dtype))})}};yy.className="Masking";ue.registerClass(yy);var xy=class extends Je{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(bt(e.inputLength))}this.inputDim=e.inputDim,ln(this.inputDim,"inputDim"),this.outputDim=e.outputDim,ln(this.outputDim,"outputDim"),this.embeddingsInitializer=Tt(e.embeddingsInitializer||this.DEFAULT_EMBEDDINGS_INITIALIZER),this.embeddingsRegularizer=Nt(e.embeddingsRegularizer),this.activityRegularizer=Nt(e.activityRegularizer),this.embeddingsConstraint=en(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 G(()=>this.maskZero?(e=Le(e),ii(e,Ze(e))):null)}computeOutputShape(e){if(e=ct(e),this.inputLength==null)return[...e,this.outputDim];let t=bt(this.inputLength);if(t.length!==e.length-1)throw new H(`"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 H(`"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 G(()=>{this.invokeCallHook(e,t);let n=Le(e);n.dtype!=="int32"&&(n=bf(n,"int32"));let s=Sv(this.embeddings.read(),V(n,[n.size]));return V(s,ct(this.computeOutputShape(n.shape)))})}getConfig(){let e={inputDim:this.inputDim,outputDim:this.outputDim,embeddingsInitializer:Ft(this.embeddingsInitializer),embeddingsRegularizer:gt(this.embeddingsRegularizer),activityRegularizer:gt(this.activityRegularizer),embeddingsConstraint:Qt(this.embeddingsConstraint),maskZero:this.maskZero,inputLength:this.inputLength},t=super.getConfig();return Object.assign(e,t),e}};xy.className="Embedding";ue.registerClass(xy);var xi=class extends Je{constructor(e){super(e||{});this.supportsMasking=!0}mergeFunction(e){throw new Me}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 H("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=[ct(e)]),e=e,e.length<2)throw new H(`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=wa(t),t.length>1)throw new H(`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&&wa(s).length===1?this.reshapeRequired=!1:this.reshapeRequired=!0}call(e,t){return G(()=>{if(e=e,this.reshapeRequired){let n=[],s=e.map(r=>r.rank);if(s.indexOf(null)===-1){let r=Ia(s);for(let a of e){let o=a.rank;for(let i=0;i<r-o;++i)a=cd(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 c=i.shape,u=c[0],d=c.slice(1).concat([u]),p=V(i,[u].concat(ka(c.slice(1))));p=Ke(p,[1,0]),p=V(p,d),n.push(p),r=!0}else if(l>1){let c=er(1,l).concat([0]);n.push(Ke(i,c)),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,c=i[l-1],u=[c].concat(i.slice(0,i.length-1));a=V(Ke(V(a,[-1,c]),[1,0]),u)}else if(o>1){let i=[o-1].concat(er(0,o-1));a=Ke(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=wa(n),n.length===1?t=n.concat(t):t=[null].concat(t),t}computeMask(e,t){return G(()=>{if(t==null)return null;if(!Array.isArray(t))throw new H("`mask` should be an Array");if(!Array.isArray(e))throw new H("`inputs` should be an Array");if(t.length!==e.length)throw new H(`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=Ps(n,t[s]);return n})}},by=class extends xi{constructor(e){super(e)}mergeFunction(e){return G(()=>{let t=e[0].clone();for(let n=1;n<e.length;++n)t=le(t,e[n]);return t})}};by.className="Add";ue.registerClass(by);var vy=class extends xi{constructor(e){super(e)}mergeFunction(e){return G(()=>{let t=e[0].clone();for(let n=1;n<e.length;++n)t=L(t,e[n]);return t})}};vy.className="Multiply";ue.registerClass(vy);var wy=class extends xi{constructor(e){super(e)}mergeFunction(e){return G(()=>{let t=e[0].clone();for(let n=1;n<e.length;++n)t=le(t,e[n]);return L(1/e.length,t)})}};wy.className="Average";ue.registerClass(wy);var ky=class extends xi{constructor(e){super(e)}mergeFunction(e){return G(()=>{let t=e[0];for(let n=1;n<e.length;++n)t=xr(t,e[n]);return t})}};ky.className="Maximum";ue.registerClass(ky);var Iy=class extends xi{constructor(e){super(e)}mergeFunction(e){return G(()=>{let t=e[0];for(let n=1;n<e.length;++n)t=uu(t,e[n]);return t})}};Iy.className="Minimum";ue.registerClass(Iy);var Sy=class extends xi{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 H("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 H("A `Concatenate` layer requires inputs with matching shapes except for the concat axis. Got input shapes: "+JSON.stringify(e))}mergeFunction(e){return G(()=>y1(e,this.axis))}computeOutputShape(e){if(!(Array.isArray(e)&&Array.isArray(e[0])))throw new H("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 H("`mask` should be an array for Concatenate");if(!Array.isArray(e))throw new H("`inputs` should be an array for Concatenate");if(t.length!==e.length)throw new H(`Mismatch in the length of mask (${t.length}) and the legnth of inputs (${e.length})`);return G(()=>{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(de(os(e[a]),"bool")):t[a].rank<e[a].rank?s.push(Lt(t[a],-1)):s.push(t[a]);let r=mt(s,this.axis);return Ph(r,-1,!1)})}getConfig(){let e={axis:this.axis},t=super.getConfig();return Object.assign(e,t),e}};Sy.className="Concatenate";ue.registerClass(Sy);function kd(e,t){for(;e<0;)e+=t;return e}function cL(e,t,n){if(e.shape.length>3||t.shape.length>3)throw new Me("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 Me("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 G(()=>{let o;if(s>r){o=s-r;let l=[];for(let c=0;c<o;++c)l.push(1);t=V(t,t.shape.concat(l))}else if(r>s){o=r-s;let l=[];for(let c=0;c<o;++c)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=Ie(L(e,t),a[0]):i=Ie(L(Ke(e,[1,0]),t),a[1]);else{let l=a[0]!==e.shape.length-1,c=a[1]===t.shape.length-1;i=Ve(e,t,l,c)}if(o>0){let l;s>r?l=s+r-3:l=s-1;let c=[];for(let u=l;u<l+o;++u)c.push(u);i=rt(i,c)}return i.shape.length===1&&(i=Lt(i,1)),i})}var Cy=class extends xi{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 Me("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 H(`Dimension incompatibility: ${t[s[0]]} !== ${n[s[1]]}`)}mergeFunction(e){if(e.length!==2)throw new H(`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)=>kd(r,e[a].shape.length)):s=[kd(this.axes,t.shape.length),kd(this.axes,n.shape.length)],this.normalize&&(t=Of(t,s[0]),n=Of(n,s[1])),cL(t,n,s)}interpretAxes(e,t){let n;return Array.isArray(this.axes)?n=this.axes:n=[kd(this.axes,e.length),kd(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 Me("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}};Cy.className="Dot";ue.registerClass(Cy);var Ty=class extends Je{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 G(()=>{this.invokeCallHook(e,t);let n=Le(e);return pd(()=>le(wf(n.shape,0,this.stddev),n),()=>n,t.training||!1)})}};Ty.className="GaussianNoise";ue.registerClass(Ty);var Ny=class extends Je{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 G(()=>{this.invokeCallHook(e,t);let n=Le(e);return this.rate>0&&this.rate<1?pd(()=>{let r=Math.sqrt(this.rate/(1-this.rate));return L(n,wf(n.shape,1,r))},()=>n,t.training||!1):n})}};Ny.className="GaussianDropout";ue.registerClass(Ny);var Ey=class extends Je{constructor(e){super(e);this.supportsMasking=!0,this.rate=e.rate,this.noiseShape=e.noiseShape}_getNoiseShape(e){return this.noiseShape||Le(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 G(()=>{if(this.rate<1&&this.rate>0){let n=this._getNoiseShape(e);return pd(()=>{let r=Le(e),a=1.6732632423543772,o=1.0507009873554805,i=-a*o,l=xa(cu(n),this.rate);l=bf(l,"float32");let c=((1-this.rate)*(1+this.rate*i**2))**-.5,u=-c*i*this.rate,d=le(L(r,l),L(le(l,-1),i));return le(L(d,c),u)},()=>Le(e),t.training||!1)}return e})}};Ey.className="AlphaDropout";ue.registerClass(Ey);function Id(e,t,n,s,r,a=.001){let o;if(e.rank===2)o=o3(e,t,n,s,r,a);else if(e.rank===3)o=i3(e,t,n,s,r,a);else if(e.rank===4)o=l3(e,t,n,s,r,a);else throw new Me(`batchNormalization is not implemented for array of rank ${e.rank} yet`);return o}function dL(e,t,n,s,r=.001){return G(()=>{let a=qh(e,s),o=a.mean,i=a.variance;return[Id(e,o,i,n,t,r),o,i]})}function pL(e,t,n,s,r=.001){return G(()=>{let a=qh(e,s),o=a.mean,i=a.variance,l=[];for(let f of er(0,e.rank))s.indexOf(f)!==-1?l.push(1):l.push(e.shape[f]);let c=V(o,l),u=V(i,l),d=t==null?null:V(t,l),p=n==null?null:V(n,l);return[Id(e,c,u,p,d,r),o,i]})}function hL(e,t,n,s,r=.001){return w.arraysEqual(s.slice().sort(),er(0,e.rank-1))?dL(e,t,n,s,r):pL(e,t,n,s,r)}var Ry=class extends Je{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=Tt(e.betaInitializer||"zeros"),this.gammaInitializer=Tt(e.gammaInitializer||"ones"),this.movingMeanInitializer=Tt(e.movingMeanInitializer||"zeros"),this.movingVarianceInitializer=Tt(e.movingVarianceInitializer||"ones"),this.betaConstraint=en(e.betaConstraint),this.gammaConstraint=en(e.gammaConstraint),this.betaRegularizer=Nt(e.betaRegularizer),this.gammaRegularizer=Nt(e.gammaRegularizer)}build(e){e=ct(e);let t=this.axis>=0?this.axis:this.axis+e.length,n=e[t];if(n==null)throw new H(`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 G(()=>{let n=t.training==null?!1:t.training,s=Le(e),r=s.shape,a=r.length,o=er(0,a),i=this.axis>=0?this.axis:this.axis+a;o.splice(i,1);let l=di(1,a);l[i]=r[i];let c=o.slice();c.sort();let u=!w.arraysEqual(c,er(0,a).slice(0,a-1)),d=()=>{if(u){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 Id(s,A,y,x,b,this.epsilon)}else return Id(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]=hL(s,this.gamma.read(),this.beta.read(),o,this.epsilon),m=(A,y,x)=>{G(()=>{let b=1-x,v=A.read(),S=L(be(v,y),b);A.write(be(v,S))})};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:Ft(this.betaInitializer),gammaInitializer:Ft(this.gammaInitializer),movingMeanInitializer:Ft(this.movingMeanInitializer),movingVarianceInitializer:Ft(this.movingVarianceInitializer),betaRegularizer:gt(this.betaRegularizer),gammaRegularizer:gt(this.gammaRegularizer),betaConstraint:Qt(this.betaConstraint),gammaConstraint:Qt(this.gammaConstraint)},t=super.getConfig();return Object.assign(e,t),e}};Ry.className="BatchNormalization";ue.registerClass(Ry);var Dy=class extends Je{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=Tt(e.betaInitializer||"zeros"),this.gammaInitializer=Tt(e.gammaInitializer||"ones"),this.betaRegularizer=Nt(e.betaRegularizer),this.gammaRegularizer=Nt(e.gammaRegularizer),this.supportsMasking=!0}build(e){e=ct(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!==wa(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=Le(e),s=n.shape,r=s.length;return G(()=>{let a=!0,{mean:o,variance:i}=qh(n,this.axis,a),l=di(1,r);for(let f of this.axis)l[f]=s[f];let c=f=>f!=null&&f.shape.length!==r?V(f,l):f,u=c(this.gamma.read()),d=c(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),u=bs(u,h),d=bs(d,h),Id(n,o,i,d,u,this.epsilon)})}getConfig(){let e={axis:this.axis,epsilon:this.epsilon,center:this.center,scale:this.scale,betaInitializer:Ft(this.betaInitializer),gammaInitializer:Ft(this.gammaInitializer),betaRegularizer:gt(this.betaRegularizer),gammaRegularizer:gt(this.gammaRegularizer)},t=super.getConfig();return Object.assign(e,t),e}};Dy.className="LayerNormalization";ue.registerClass(Dy);function fL(e,t,n){return G(()=>{if(e.rank!==4)throw new H(`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 H("spatial2dPadding expects `padding` to be an Array of two Arrays, each of which is an Array of two integers.");if(n==null&&(n=Js()),n!=="channelsLast"&&n!=="channelsFirst")throw new H(`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]],vs(e,s)})}var _y=class extends Je{constructor(e){e==null&&(e={});super(e);if(this.dataFormat=e.dataFormat==null?Js():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 H(`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 H(`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 H(`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=ct(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 G(()=>fL(Le(e),this.padding,this.dataFormat))}getConfig(){let e={padding:this.padding,dataFormat:this.dataFormat},t=super.getConfig();return Object.assign(e,t),e}};_y.className="ZeroPadding2D";ue.registerClass(_y);function Kf(e,t,n,s,r,a){return G(()=>{Bt(r),xv(a),ws(s),n==null&&(n=[1,1]),s==null&&(s="valid"),r==null&&(r=Js()),a==null&&(a="max"),e=Q1(e,r);let o,i=s==="same"?"same":"valid";return a==="max"?o=Yc(e,t,n,i):o=Hc(e,t,n,i),r==="channelsFirst"&&(o=Ke(o,[0,3,1,2])),o})}function Dw(e,t,n,s,r,a){return G(()=>{Bt(r),xv(a),ws(s),n==null&&(n=[1,1,1]),s==null&&(s="valid"),r==null&&(r=Js()),a==null&&(a="max"),e=Sw(e,r);let o,i=s==="same"?"same":"valid";return a==="max"?o=VA(e,t,n,i):o=CA(e,t,n,i),r==="channelsFirst"&&(o=Ke(o,[0,4,1,2,3])),o})}var _w=class extends Je{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 H(`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 H(`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,ws(this.padding),this.inputSpec=[new Ht({ndim:3})]}computeOutputShape(e){e=ct(e);let t=rr(e[1],this.poolSize[0],this.padding,this.strides[0]);return[e[0],t,e[2]]}call(e,t){return G(()=>{this.invokeCallHook(e,t),e=cd(Le(e),2);let n=this.poolingFunction(Le(e),[this.poolSize[0],1],[this.strides[0],1],this.padding,"channelsLast");return rt(n,[2])})}getConfig(){let e={poolSize:this.poolSize,padding:this.padding,strides:this.strides},t=super.getConfig();return Object.assign(e,t),e}},Fy=class extends _w{constructor(e){super(e)}poolingFunction(e,t,n,s,r){return Bt(r),ws(s),Kf(e,t,n,s,r,"max")}};Fy.className="MaxPooling1D";ue.registerClass(Fy);var $y=class extends _w{constructor(e){super(e)}poolingFunction(e,t,n,s,r){return Bt(r),ws(s),Kf(e,t,n,s,r,"avg")}};$y.className="AveragePooling1D";ue.registerClass($y);var Fw=class extends Je{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 H(`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),ws(this.padding),this.inputSpec=[new Ht({ndim:4})]}computeOutputShape(e){e=ct(e);let t=this.dataFormat==="channelsFirst"?e[2]:e[1],n=this.dataFormat==="channelsFirst"?e[3]:e[2];return t=rr(t,this.poolSize[0],this.padding,this.strides[0]),n=rr(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 G(()=>(this.invokeCallHook(e,t),this.poolingFunction(Le(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}},Oy=class extends Fw{constructor(e){super(e)}poolingFunction(e,t,n,s,r){return Bt(r),ws(s),Kf(e,t,n,s,r,"max")}};Oy.className="MaxPooling2D";ue.registerClass(Oy);var Py=class extends Fw{constructor(e){super(e)}poolingFunction(e,t,n,s,r){return Bt(r),ws(s),Kf(e,t,n,s,r,"avg")}};Py.className="AveragePooling2D";ue.registerClass(Py);var $w=class extends Je{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 H(`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),ws(this.padding),this.inputSpec=[new Ht({ndim:5})]}computeOutputShape(e){e=ct(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=rr(t,this.poolSize[0],this.padding,this.strides[0]),n=rr(n,this.poolSize[1],this.padding,this.strides[1]),s=rr(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 G(()=>(this.invokeCallHook(e,t),this.poolingFunction(Le(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}},My=class extends $w{constructor(e){super(e)}poolingFunction(e,t,n,s,r){return Bt(r),ws(s),Dw(e,t,n,s,r,"max")}};My.className="MaxPooling3D";ue.registerClass(My);var zy=class extends $w{constructor(e){super(e)}poolingFunction(e,t,n,s,r){return Bt(r),ws(s),Dw(e,t,n,s,r,"avg")}};zy.className="AveragePooling3D";ue.registerClass(zy);var Ow=class extends Je{constructor(e){super(e);this.inputSpec=[new Ht({ndim:3})]}computeOutputShape(e){return[e[0],e[2]]}call(e,t){throw new Me}},Ly=class extends Ow{constructor(e){super(e||{})}call(e,t){return G(()=>{let n=Le(e);return _t(n,1)})}};Ly.className="GlobalAveragePooling1D";ue.registerClass(Ly);var By=class extends Ow{constructor(e){super(e||{})}call(e,t){return G(()=>{let n=Le(e);return Rn(n,1)})}};By.className="GlobalMaxPooling1D";ue.registerClass(By);var Pw=class extends Je{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 Me}getConfig(){let e={dataFormat:this.dataFormat},t=super.getConfig();return Object.assign(e,t),e}},Wy=class extends Pw{call(e,t){return G(()=>{let n=Le(e);return this.dataFormat==="channelsLast"?_t(n,[1,2]):_t(n,[2,3])})}};Wy.className="GlobalAveragePooling2D";ue.registerClass(Wy);var Vy=class extends Pw{call(e,t){return G(()=>{let n=Le(e);return this.dataFormat==="channelsLast"?Rn(n,[1,2]):Rn(n,[2,3])})}};Vy.className="GlobalMaxPooling2D";ue.registerClass(Vy);var Mw=class extends Je{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=sr(s,n);delete t.layer;let a={layer:r};return Object.assign(a,t),new e(a)}},Uy=class extends Mw{constructor(e){super(e);this.supportsMasking=!0}build(e){if(e=ct(e),e.length<3)throw new H(`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=ct(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 G(()=>(e=Le(e),Ew((a,o)=>[Le(this.layer.call(a,t)),[]],e,[],!1,null,null,!1,!0)[1]))}};Uy.className="TimeDistributed";ue.registerClass(Uy);function mL(e){hi(vM,"BidirectionalMergeMode",e)}var gL="concat",Gy=class extends Mw{constructor(e){super(e);let t=e.layer.getConfig(),n={};n.className=e.layer.getClassName(),n.config=t,this.forwardLayer=sr(n),t.goBackwards=t.goBackwards!==!0;let s={};if(s.className=e.layer.getClassName(),s.config=t,this.backwardLayer=sr(s),this.forwardLayer.name="forward_"+this.forwardLayer.name,this.backwardLayer.name="backward_"+this.backwardLayer.name,this.mergeMode=e.mergeMode===void 0?gL:e.mergeMode,mL(this.mergeMode),e.weights)throw new Me("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()):Xn(s)}apply(e,t){let n=t==null?null:t.initialState,s=t==null?null:t.constants;t==null&&(t={});let r=Nw(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 H("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 c=n.map(u=>new Ht({shape:u.shape}));this.forwardLayer.stateSpec=c.slice(0,l/2),this.backwardLayer.stateSpec=c.slice(l/2),o.push(...c)}if(s!=null)throw new Me("Support for constants in Bidirectional layers is not implemented yet.");let i=a[0]instanceof nr;for(let l of a)if(l instanceof nr!==i)throw new H("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),c=this.inputSpec.concat(o),u=this.inputSpec;this.inputSpec=c;let d=super.apply(l,t);return this.inputSpec=u,d}else return super.apply(e,t)}call(e,t){return G(()=>{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=is(r,1));let o;return this.mergeMode==="concat"?o=y1([s,r]):this.mergeMode==="sum"?o=le(s,r):this.mergeMode==="ave"?o=L(.5,le(s,r)):this.mergeMode==="mul"?o=L(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){fi(this.forwardLayer.name,()=>{this.forwardLayer.build(e)}),fi(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=sr(t.layer);if(delete t.layer,t.numConstants!=null)throw new Me("Deserialization of a Bidirectional layer with numConstants present is not supported yet.");let s=t;return s.layer=n,new e(s)}};Gy.className="Bidirectional";ue.registerClass(Gy);function AL(e){return new yu(e)}function yL(e){return new Z1(e)}function xL(e){return new q1(e)}function bL(e){return new X1(e)}function vL(e){return new K1(e)}function wL(e){return new J1(e)}function kL(e){return new Y1(e)}function IL(e){return new Uf(e)}function SL(e){return new xd(e)}function CL(e){return new ty(e)}function TL(e){return new bd(e)}function NL(e){return new ny(e)}function EL(e){return new sy(e)}function RL(e){return new ry(e)}function DL(e){return new ay(e)}function _L(e){return new oy(e)}function FL(e){return new fy(e)}function $L(e){return new py(e)}function OL(e){return new Xf(e)}function PL(e){return new dy(e)}function ML(e){return new hy(e)}function zL(e){return new my(e)}function LL(e){return new gy(e)}function BL(e){return new Ay(e)}function WL(e){return new xy(e)}function VL(e){return new by(e)}function UL(e){return new wy(e)}function GL(e){return new Sy(e)}function HL(e){return new ky(e)}function jL(e){return new Iy(e)}function qL(e){return new vy(e)}function XL(e){return new Cy(e)}function KL(e){return new Ry(e)}function ZL(e){return new Dy(e)}function YL(e){return new _y(e)}function Hy(e){return new $y(e)}function JL(e){return Hy(e)}function QL(e){return Hy(e)}function jy(e){return new Py(e)}function eB(e){return jy(e)}function tB(e){return jy(e)}function qy(e){return new zy(e)}function nB(e){return qy(e)}function sB(e){return qy(e)}function rB(e){return new Ly(e)}function aB(e){return new Wy(e)}function zw(e){return new By(e)}function Lw(e){return new Vy(e)}function Bw(e){return new Fy(e)}function Ww(e){return new Oy(e)}function oB(e){return new My(e)}function iB(e){return new ly(e)}function lB(e){return new Hf(e)}function uB(e){return new uy(e)}function cB(e){return new wd(e)}function dB(e){return new iy(e)}function pB(e){return new Gf(e)}function hB(e){return new cy(e)}function fB(e){return new qf(e)}function mB(e){return new Sr(e)}function gB(e){return new jf(e)}function AB(e){return new Gy(e)}function yB(e){return new Uy(e)}var xB=zw,bB=Lw,vB=Bw,wB=Ww;function kB(e){return new Ty(e)}function IB(e){return new Ny(e)}function SB(e){return new Ey(e)}function CB(e){return new yy(e)}var Vw={};ze(Vw,{MAPE:()=>MB,MSE:()=>BB,binaryAccuracy:()=>TB,binaryCrossentropy:()=>NB,categoricalAccuracy:()=>RB,categoricalCrossentropy:()=>DB,cosineProximity:()=>$B,mape:()=>zB,meanAbsoluteError:()=>OB,meanAbsolutePercentageError:()=>PB,meanSquaredError:()=>LB,mse:()=>WB,precision:()=>_B,recall:()=>FB,sparseCategoricalAccuracy:()=>EB});function TB(e,t){return F1(e,t)}function NB(e,t){return Gv(e,t)}function EB(e,t){return Hv(e,t)}function RB(e,t){return $1(e,t)}function DB(e,t){return O1(e,t)}function _B(e,t){return Uv(e,t)}function FB(e,t){return gz(e,t)}function $B(e,t){return D1(e,t)}function OB(e,t){return Pf(e,t)}function PB(e,t){return bu(e,t)}function MB(e,t){return bu(e,t)}function zB(e,t){return bu(e,t)}function LB(e,t){return gi(e,t)}function BB(e,t){return gi(e,t)}function WB(e,t){return gi(e,t)}var Uw={};ze(Uw,{modelFromJSON:()=>Zz});var Gw={};ze(Gw,{l1:()=>UB,l1l2:()=>VB,l2:()=>GB});function VB(e){return new Ad(e)}function UB(e){return rL(e)}function GB(e){return aL(e)}var Hw=class extends xu{constructor(){super(...arguments);this.model=null}setModel(e){if(!(e instanceof Ur))throw new Error("model must be a LayersModel, not some other Container");this.model=e}};function Zf(e,t){return e<t}function jw(e,t){return e>t}var qw=class extends Hw{constructor(e){super();if(e==null&&(e={}),e.restoreBestWeights)throw new Me("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=Zf:this.mode==="max"?this.monitorFunc=jw:this.monitor.indexOf("acc")!==-1?this.monitorFunc=jw:this.monitorFunc=Zf,this.monitorFunc===Zf&&(this.minDelta*=-1)}async onTrainBegin(e){this.wait=0,this.stoppedEpoch=0,this.baseline!=null?this.best=this.baseline:this.best=this.monitorFunc===Zf?1/0:-1/0}async onEpochEnd(e,t){await Sa(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 HB(e){return new qw(e)}var jB={earlyStopping:HB},ar;(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"})(ar||(ar={}));var Xw;(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={}))})(Xw||(Xw={}));var Xy={};function qB(e,t){let n={tfOpName:e,category:"custom",inputs:[],attrs:[],customExecutor:t};Xy[e]=n}function Kw(e){return Xy[e]}function XB(e){delete Xy[e]}function k(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 Fn(t.inputNames[a.inputIndexStart],n,s,r);if(a.type==="tensors")return t.inputNames.slice(i,l).map(p=>Fn(p,n,s,r));let c=Fn(t.inputNames.slice(i)[0],n,s,r),u=c.dataSync();return a.type==="number"?u[0]:w.toNestedArray(c.shape,u)}let o=t.attrParams[e];return o&&o.value}function Fn(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[Yf(r,i)]);return o!==void 0?t[Yf(r,o)][a]:void 0}function KB(e,t,n){return t[Yf(e,n.currentContextId)]}function Gr(e,t){let[n,s,r]=ls(e);return[Yf(n,t&&t.currentContextId),s,r]}function Yf(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 Jf(e,t,n){let s=k("pad",e,t,n);if(s==="explicit"){s=k("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 Hr(e){return e.kept?e:Xs(e)}var Zw={};ze(Zw,{json:()=>ZB});var ZB=[{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}]}],Yw={};ze(Yw,{json:()=>YB});var YB=[{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}]}],Jw={};ze(Jw,{json:()=>JB});var JB=[{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"}]}],Qw={};ze(Qw,{json:()=>QB});var QB=[{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"}]}],e7={};ze(e7,{json:()=>eW});var eW=[{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"}]}],t7={};ze(t7,{json:()=>tW});var tW=[{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}]}],n7={};ze(n7,{json:()=>nW});var nW=[{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"}]}],s7={};ze(s7,{json:()=>sW});var sW=[{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"}]}],r7={};ze(r7,{json:()=>rW});var rW=[{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"}]}],a7={};ze(a7,{json:()=>aW});var aW=[{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"}]}],o7={};ze(o7,{json:()=>oW});var oW=[{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}]}],i7={};ze(i7,{json:()=>iW});var iW=[{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"}]}],l7={};ze(l7,{json:()=>lW});var lW=[{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}]}],u7={};ze(u7,{json:()=>uW});var uW=[{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"}]}],c7={};ze(c7,{json:()=>cW});var cW=[{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}]}],d7={};ze(d7,{json:()=>dW});var dW=[{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"}]}],p7={};ze(p7,{json:()=>pW});var pW=[{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}]}],h7={};ze(h7,{json:()=>hW});var hW=[{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"}]}],f7={};ze(f7,{json:()=>fW});var fW=[{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:[]}],m7=class{static get Instance(){return this._instance||(this._instance=new this)}constructor(){let e=[Zw,Yw,Jw,Qw,e7,t7,n7,s7,r7,a7,o7,i7,l7,u7,c7,d7,p7,h7,f7],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=[],c={},u={};t!=null&&(c=this.mapSignatureEntries(t.inputs),u=this.mapSignatureEntries(t.outputs));let d=Object.keys(o);d.forEach(f=>{let m=o[f];m.inputNames.forEach((g,A)=>{let[y,,x]=Gr(g),b=o[y];if(b.outputs!=null){let v=b.outputs.indexOf(x);if(v!==-1){let S=`${y}:${v}`;m.inputNames[A]=S}}m.inputs.push(b),b.children.push(m)})}),Object.keys(u).length===0?d.forEach(f=>{let m=o[f];m.children.length===0&&l.push(m)}):Object.keys(u).forEach(f=>{let[m]=Gr(f),g=o[m];g!=null&&(g.signatureKey=u[f],l.push(g))}),Object.keys(c).length>0?Object.keys(c).forEach(f=>{let[m]=Gr(f),g=o[m];g&&(g.signatureKey=c[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=Kw(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=Ky(e.attr,r.tfName,r.defaultValue),o===void 0&&!!r.tfDeprecatedName&&(o=Ky(e.attr,r.tfDeprecatedName,r.defaultValue));break;case"string[]":o=s2(e.attr,r.tfName,r.defaultValue),o===void 0&&!!r.tfDeprecatedName&&(o=s2(e.attr,r.tfDeprecatedName,r.defaultValue));break;case"number":o=Yy(e.attr,r.tfName,r.defaultValue||0),o===void 0&&!!r.tfDeprecatedName&&(o=Yy(e.attr,r.tfDeprecatedName,r.defaultValue));break;case"number[]":o=n2(e.attr,r.tfName,r.defaultValue),o===void 0&&!!r.tfDeprecatedName&&(o=n2(e.attr,r.tfDeprecatedName,r.defaultValue));break;case"bool":o=Zy(e.attr,r.tfName,r.defaultValue),o===void 0&&!!r.tfDeprecatedName&&(o=Zy(e.attr,r.tfDeprecatedName,r.defaultValue));break;case"bool[]":o=a2(e.attr,r.tfName,r.defaultValue),o===void 0&&!!r.tfDeprecatedName&&(o=a2(e.attr,r.tfDeprecatedName,r.defaultValue));break;case"shape":o=t2(e.attr,r.tfName,r.defaultValue),o===void 0&&!!r.tfDeprecatedName&&(o=t2(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"dtype":o=Qy(e.attr,r.tfName,r.defaultValue),o===void 0&&!!r.tfDeprecatedName&&(o=Qy(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=A7(e.attr,r.tfName,r.defaultValue),o===void 0&&!!r.tfDeprecatedName&&(o=A7(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((u,d)=>(u[d.name]=this.mapNode(d),d.op==="Const"&&s.push(u[d.name]),u),{}));let a=[],o=[];e.signature.inputArg.forEach(u=>{let[d]=Gr(u.name),p={name:d,op:"Placeholder",inputs:[],inputNames:[],category:"graph",inputParams:{},attrParams:{dtype:{value:Jy(u.type),type:"dtype"}},children:[]};p.signatureKey=u.name,a.push(p),r[d]=p}),Object.keys(r).forEach(u=>{let d=r[u];d.inputNames.forEach((p,h)=>{let[f,,m]=Gr(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(u=>{let[d,p]=Gr(l[u.name]),h=r[d];h!=null&&(h.defaultOutput=p,o.push(h))});let c=this.mapArgsToSignature(e);return{nodes:r,inputs:a,outputs:o,weights:s,placeholders:n,signature:c}}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 mW(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 g7(e,t){let n=Array.isArray(e)?String.fromCharCode.apply(null,e):mW(e);return t?n:n.toLowerCase()}function Ky(e,t,n,s=!1){let r=e[t];return r!=null?g7(r.s,s):n}function Zy(e,t,n){let s=e[t];return s?s.b:n}function Yy(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 Jy(e){switch(typeof e=="string"&&(e=ar[e]),e){case ar.DT_FLOAT:return"float32";case ar.DT_INT32:case ar.DT_INT64:case ar.DT_INT8:case ar.DT_UINT8:return"int32";case ar.DT_BOOL:return"bool";case ar.DT_DOUBLE:return"float32";case ar.DT_STRING:return"string";default:return null}}function A7(e,t,n){let s=e[t];return s&&s.func?s.func.name:n}function Qy(e,t,n){let s=e[t];return s&&s.type?Jy(s.type):n}function e2(e,t,n){let s=e[t];return s&&s.list&&s.list.type?s.list.type.map(r=>Jy(r)):n}function y7(e){if(!e.unknownRank)return e.dim!=null?e.dim.map(t=>typeof t.size=="number"?t.size:parseInt(t.size,10)):[]}function t2(e,t,n){let s=e[t];return s&&s.shape?y7(s.shape):n}function n2(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 s2(e,t,n,s=!1){let r=e[t];return r&&r.list&&r.list.s?r.list.s.map(a=>g7(a,s)):n}function r2(e,t,n){let s=e[t];return s&&s.list&&s.list.shape?s.list.shape.map(r=>y7(r)):n}function a2(e,t,n){let s=e[t];return s&&s.list&&s.list.b?s.list.b:n}var gW=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 Fn(e,this.tensorMap,this.context)}getAttr(e,t){let n=this.node.rawAttrs[e];if(n.tensor!=null)return Fn(e,this.tensorMap,this.context);if(n.i!=null||n.f!=null)return Yy(this.node.rawAttrs,e,t);if(n.s!=null)return Ky(this.node.rawAttrs,e,t);if(n.b!=null)return Zy(this.node.rawAttrs,e,t);if(n.shape!=null)return t2(this.node.rawAttrs,e,t);if(n.type!=null)return Qy(this.node.rawAttrs,e,t);if(n.list!=null){if(n.list.i!=null||n.list.f!=null)return n2(this.node.rawAttrs,e,t);if(n.list.s!=null)return s2(this.node.rawAttrs,e,t);if(n.list.shape!=null)return r2(this.node.rawAttrs,e,t);if(n.list.b!=null)return a2(this.node.rawAttrs,e,t);if(n.list.type!=null)return e2(this.node.rawAttrs,e,t)}return t}},AW=(e,t,n)=>{switch(e.op){case"BiasAdd":case"AddV2":case"Add":return[le(k("a",e,t,n),k("b",e,t,n))];case"AddN":return[Oh(k("tensors",e,t,n))];case"FloorMod":case"Mod":return[GA(k("a",e,t,n),k("b",e,t,n))];case"Mul":return[L(k("a",e,t,n),k("b",e,t,n))];case"RealDiv":case"Div":return[fe(k("a",e,t,n),k("b",e,t,n))];case"DivNoNan":return[FA(k("a",e,t,n),k("b",e,t,n))];case"FloorDiv":return[$h(k("a",e,t,n),k("b",e,t,n))];case"Sub":return[be(k("a",e,t,n),k("b",e,t,n))];case"Minimum":return[uu(k("a",e,t,n),k("b",e,t,n))];case"Maximum":return[xr(k("a",e,t,n),k("b",e,t,n))];case"Pow":return[zr(k("a",e,t,n),k("b",e,t,n))];case"SquaredDifference":return[sf(k("a",e,t,n),k("b",e,t,n))];default:throw TypeError(`Node type ${e.op} is not implemented`)}},yW=(e,t,n)=>{switch(e.op){case"Abs":case"ComplexAbs":return[Vt(k("x",e,t,n))];case"Acos":return[gA(k("x",e,t,n))];case"Acosh":return[AA(k("x",e,t,n))];case"Asin":return[xA(k("x",e,t,n))];case"Asinh":return[bA(k("x",e,t,n))];case"Atan":return[vA(k("x",e,t,n))];case"Atan2":return[wA(k("x",e,t,n),k("y",e,t,n))];case"Atanh":return[kA(k("x",e,t,n))];case"Ceil":return[NA(k("x",e,t,n))];case"Complex":return[fa(k("real",e,t,n),k("imag",e,t,n))];case"Cos":return[qc(k("x",e,t,n))];case"Cosh":return[Bh(k("x",e,t,n))];case"Elu":return[ou(k("x",e,t,n))];case"Erf":return[$A(k("x",e,t,n))];case"Exp":return[ss(k("x",e,t,n))];case"Expm1":return[OA(k("x",e,t,n))];case"Floor":return[lu(k("x",e,t,n))];case"Log":return[rs(k("x",e,t,n))];case"Log1p":return[Kc(k("x",e,t,n))];case"Imag":return[Vh(k("x",e,t,n))];case"Neg":return[Ct(k("x",e,t,n))];case"Reciprocal":return[qA(k("x",e,t,n))];case"Real":return[td(k("x",e,t,n))];case"Relu":return[Zs(k("x",e,t,n))];case"Round":return[Zh(k("x",e,t,n))];case"Selu":return[Jh(k("x",e,t,n))];case"Sigmoid":return[Hn(k("x",e,t,n))];case"Sin":return[Qh(k("x",e,t,n))];case"Sign":return[KA(k("x",e,t,n))];case"Sinh":return[ef(k("x",e,t,n))];case"Softplus":return[ai(k("x",e,t,n))];case"Sqrt":return[mn(k("x",e,t,n))];case"Square":return[ht(k("x",e,t,n))];case"Tanh":return[ni(k("x",e,t,n))];case"Tan":return[JA(k("x",e,t,n))];case"ClipByValue":return[jn(k("x",e,t,n),k("clipValueMin",e,t,n),k("clipValueMax",e,t,n))];case"Relu6":return[Kh(k("x",e,t,n))];case"Rsqrt":return[Yh(Fn(e.inputNames[0],t,n))];case"Prod":return[Xh(k("x",e,t,n),k("axes",e,t,n))];case"LeakyRelu":return[Xc(k("x",e,t,n),k("alpha",e,t,n))];case"Prelu":return[ed(k("x",e,t,n),k("alpha",e,t,n))];case"IsNan":return[MA(Fn(e.inputNames[0],t,n))];default:throw TypeError(`Node type ${e.op} is not implemented`)}};function Bs(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 x7(e){return!(typeof e=="number"||e.some(t=>t<0))}function Sd(e,t,n){let s=o2(e,n),r=!x7(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)}),!x7(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 xW=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=Ee(0),an(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),Bs(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,an(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 zt([],[0].concat(this.elementShape));let n=this.readMany(e);return Bs(this.elementShape,n[0].shape,"TensorArray shape mismatch: "),gn(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 zt([],[0].concat(this.elementShape));let t=[];for(let s=0;s<this.size();s++)t.push(s);let n=this.readMany(t);return Bs(this.elementShape,n[0].shape,`TensorArray shape mismatch: tensor array shape (${this.elementShape}) vs first tensor shape (${n[0].shape})`),mt(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,Dn(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=[];G(()=>{t=V(t,[1,n,r]);for(let i=0;i<e.length;++i){let l=i===0?0:s[i-1],c=[0,l,0],u=[1,e[i],r];a[i]=V(Fe(t,c,u),this.elementShape)}return a});let o=[];for(let i=0;i<e.length;i++)o[i]=i;this.writeMany(o,a)}},Cd=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}`);Bs(t,r.shape,"TensorList shape mismatch: "),an(r)}),this.idTensor=Ee(0),this.maxNumElements=s,an(this.idTensor)}get id(){return this.idTensor.id}copy(){return new Cd([...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.`);Bs(e,this.elementShape,"TensorList shape mismatch: ");let s=Sd(this.elementShape,this.tensors,e);return G(()=>{let r=this.tensors.map(a=>V(a,s));return gn(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=Sd(this.elementShape,this.tensors,e),s=this.tensors.pop();return Bs(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(Bs(e.shape,this.elementShape,"TensorList shape mismatch: "),this.maxNumElements===this.size())throw new Error("Trying to push element into a full list.");an(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.`);Bs(this.tensors[e].shape,t,"TensorList shape mismatch: ");let s=Sd(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.`);Bs(this.elementShape,t.shape,"TensorList shape mismatch: "),an(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}`);Bs(this.elementShape,n,"TensorList shape mismatch: "),e=e.slice(0,this.size());let s=Sd(this.elementShape,this.tensors,n);return e.length===0?zt([],[0].concat(s)):G(()=>{let r=e.map(a=>V(this.tensors[a],s));return gn(r,0)})}concat(e,t){if(!!e&&e!==this.elementDtype)throw new Error(`TensorList dtype is ${this.elementDtype} but concat requested dtype ${e}`);Bs(this.elementShape,t,"TensorList shape mismatch: ");let n=Sd(this.elementShape,this.tensors,t);return this.size()===0?zt([],[0].concat(n)):G(()=>{let s=this.tensors.map(r=>V(r,n));return mt(s,0)})}};function bW(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);Bs(r,t,"TensorList shape mismatch: ");let a=Dn(e);return new Cd(a,t,s)}function vW(e,t,n){return new Cd([],e,t,n)}function wW(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 Cd([],n,e.dtype,s),o=Dn(e,0);return t.forEach((i,l)=>{a.setItem(i,o[l])}),a}function kW(e,t,n){let s=0,r=t.map(u=>(s+=u,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=G(()=>{let u=[];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];u[d]=V(Fe(e,h,f),o)}return e.dispose(),u}),c=new Cd([],n,e.dtype,t.length);for(let u=0;u<l.length;u++)c.setItem(u,l[u]);return c}var IW=async(e,t,n)=>{switch(e.op){case"If":case"StatelessIf":{let s=k("thenBranch",e,t,n),r=k("elseBranch",e,t,n),a=k("cond",e,t,n),o=k("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=k("body",e,t,n),r=k("cond",e,t,n),a=k("args",e,t,n),o=await n.functionMap[r].executeFunctionAsync(a,n.tensorArrayMap,n.tensorListMap),i=a.map(u=>u.id),l=await o[0].data();o.forEach(u=>{!u.kept&&i.indexOf(u.id)===-1&&u.dispose()});let c=a;for(;l[0];){let u=c;c=await n.functionMap[s].executeFunctionAsync(c,n.tensorArrayMap,n.tensorListMap);let d=c.map(h=>h.id);u.forEach(h=>{!h.kept&&i.indexOf(h.id)===-1&&d.indexOf(h.id)===-1&&h.dispose()});let p=await n.functionMap[r].executeFunctionAsync(c,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 c}case"LoopCond":{let s=k("pred",e,t,n);return[Hr(s)]}case"Switch":{let s=k("pred",e,t,n),r=k("data",e,t,n);return r.kept||(r=Hr(r)),(await s.data())[0]?[void 0,r]:[r,void 0]}case"Merge":{let s=e.inputNames.find(r=>Fn(r,t,n)!==void 0);if(s){let r=Fn(s,t,n);return[Hr(r)]}return}case"Enter":{let s=k("frameName",e,t,n),r=k("tensor",e,t,n);return n.enterFrame(s),[Hr(r)]}case"Exit":{let s=k("tensor",e,t,n);return n.exitFrame(),[Hr(s)]}case"NextIteration":{let s=k("tensor",e,t,n);return n.nextIteration(),[Hr(s)]}case"TensorArrayV3":{let s=k("size",e,t,n),r=k("dtype",e,t,n),a=k("elementShape",e,t,n),o=k("dynamicSize",e,t,n),i=k("clearAfterRead",e,t,n),l=k("identicalElementShapes",e,t,n),c=k("name",e,t,n),u=new xW(c,r,s,a,l,o,i);return n.addTensorArray(u),[u.idTensor,Ee(1)]}case"TensorArrayWriteV3":{let s=k("tensorArrayId",e,t,n),r=k("index",e,t,n),a=k("tensor",e,t,n),o=n.getTensorArray(s.id);return o.write(r,a),[o.idTensor]}case"TensorArrayReadV3":{let s=k("tensorArrayId",e,t,n),r=k("index",e,t,n);return[n.getTensorArray(s.id).read(r)]}case"TensorArrayGatherV3":{let s=k("tensorArrayId",e,t,n),r=k("indices",e,t,n),a=k("dtype",e,t,n);return[n.getTensorArray(s.id).gather(r,a)]}case"TensorArrayScatterV3":{let s=k("tensorArrayId",e,t,n),r=k("indices",e,t,n),a=k("tensor",e,t,n),o=n.getTensorArray(s.id);return o.scatter(r,a),[o.idTensor]}case"TensorArrayConcatV3":{let s=k("tensorArrayId",e,t,n),r=n.getTensorArray(s.id),a=k("dtype",e,t,n);return[r.concat(a)]}case"TensorArraySplitV3":{let s=k("tensorArrayId",e,t,n),r=k("tensor",e,t,n),a=k("lengths",e,t,n),o=n.getTensorArray(s.id);return o.split(a,r),[o.idTensor]}case"TensorArraySizeV3":{let s=k("tensorArrayId",e,t,n),r=n.getTensorArray(s.id);return[Ee(r.size(),"int32")]}case"TensorArrayCloseV3":{let s=k("tensorArrayId",e,t,n),r=n.getTensorArray(s.id);return r.clearAndClose(),[r.idTensor]}case"TensorListSetItem":{let s=k("tensorListId",e,t,n),r=k("index",e,t,n),a=k("tensor",e,t,n),o=n.getTensorList(s.id);return o.setItem(r,a),[o.idTensor]}case"TensorListGetItem":{let s=k("tensorListId",e,t,n),r=k("index",e,t,n),a=k("elementShape",e,t,n),o=k("elementDType",e,t,n);return[n.getTensorList(s.id).getItem(r,a,o)]}case"TensorListScatterV2":case"TensorListScatter":{let s=k("indices",e,t,n),r=k("tensor",e,t,n),a=k("elementShape",e,t,n),o=k("numElements",e,t,n),i=wW(r,s,a,o);return n.addTensorList(i),[i.idTensor]}case"TensorListReserve":case"EmptyTensorList":{let s=k("elementShape",e,t,n),r=k("elementDType",e,t,n),a;e.op==="TensorListReserve"?a="numElements":a="maxNumElements";let o=k(a,e,t,n),i=vW(s,r,o);return n.addTensorList(i),[i.idTensor]}case"TensorListGather":{let s=k("tensorListId",e,t,n),r=k("indices",e,t,n),a=k("elementShape",e,t,n),o=k("elementDType",e,t,n);return[n.getTensorList(s.id).gather(r,o,a)]}case"TensorListStack":{let s=k("tensorListId",e,t,n),r=k("elementShape",e,t,n),a=k("elementDType",e,t,n),o=k("numElements",e,t,n);return[n.getTensorList(s.id).stack(r,a,o)]}case"TensorListFromTensor":{let s=k("tensor",e,t,n),r=k("elementShape",e,t,n),a=k("elementDType",e,t,n),o=bW(s,r,a);return n.addTensorList(o),[o.idTensor]}case"TensorListConcat":{let s=k("tensorListId",e,t,n),r=n.getTensorList(s.id),a=k("dtype",e,t,n),o=k("elementShape",e,t,n);return[r.concat(a,o)]}case"TensorListPushBack":{let s=k("tensorListId",e,t,n),r=k("tensor",e,t,n),a=n.getTensorList(s.id);return a.pushBack(r),[a.idTensor]}case"TensorListPopBack":{let s=k("tensorListId",e,t,n),r=k("elementShape",e,t,n),a=k("elementDType",e,t,n);return[n.getTensorList(s.id).popBack(r,a)]}case"TensorListSplit":{let s=k("tensor",e,t,n),r=k("elementShape",e,t,n),a=k("lengths",e,t,n),o=kW(s,a,r);return n.addTensorList(o),[o.idTensor]}default:throw TypeError(`Node type ${e.op} is not implemented`)}};function b7(e,t,n){let[s,r]=k("fusedOps",e,t,n),a=s==="biasadd",o=!a,i=r==="prelu",l=s==="fusedbatchnorm",c=k("numArgs",e,t,n);if(a){if(i&&c!==2)throw new Error("FusedConv2d and DepthwiseConv2d with BiasAdd and Prelu must have two extra arguments: bias and alpha.");if(!i&&a&&c!==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 u=k("strides",e,t,n),d=Jf(e,t,n),p=k("dataFormat",e,t,n).toUpperCase(),h=k("dilations",e,t,n),[f,m]=k("args",e,t,n);o&&(m=f,f=void 0);let g=k("leakyreluAlpha",e,t,n);return{stride:u,pad:d,dataFormat:p,dilations:h,biasArg:f,preluArg:m,activationFunc:r,leakyreluAlpha:g}}var SW=(e,t,n)=>{switch(e.op){case"Conv1D":{let s=k("stride",e,t,n),r=k("pad",e,t,n),a=k("dataFormat",e,t,n).toUpperCase(),o=k("dilation",e,t,n);return[zh(k("x",e,t,n),k("filter",e,t,n),s,r,a,o)]}case"Conv2D":{let s=k("strides",e,t,n),r=Jf(e,t,n),a=k("dataFormat",e,t,n).toUpperCase(),o=k("dilations",e,t,n);return[Mr(k("x",e,t,n),k("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:c,leakyreluAlpha:u}=b7(e,t,n);return[va.conv2d({x:k("x",e,t,n),filter:k("filter",e,t,n),strides:[s[1],s[2]],pad:r,dataFormat:a,dilations:[o[1],o[2]],bias:i,activation:c,preluActivationWeights:l,leakyreluAlpha:u})]}case"FusedDepthwiseConv2dNative":{let{stride:s,pad:r,dataFormat:a,dilations:o,biasArg:i,preluArg:l,activationFunc:c,leakyreluAlpha:u}=b7(e,t,n);return[va.depthwiseConv2d({x:k("x",e,t,n),filter:k("filter",e,t,n),strides:[s[1],s[2]],pad:r,dataFormat:a,dilations:[o[1],o[2]],bias:i,activation:c,preluActivationWeights:l,leakyreluAlpha:u})]}case"Conv2DBackpropInput":case"Conv2dTranspose":{let s=k("outputShape",e,t,n),r=k("strides",e,t,n),a=Jf(e,t,n);return[Lh(k("x",e,t,n),k("filter",e,t,n),s,[r[1],r[2]],a)]}case"DepthwiseConv2dNative":case"DepthwiseConv2d":{let s=k("strides",e,t,n),r=Jf(e,t,n),a=k("dilations",e,t,n),o=k("dataFormat",e,t,n).toUpperCase();return[au(k("input",e,t,n),k("filter",e,t,n),[s[1],s[2]],r,o,[a[1],a[2]])]}case"Conv3D":{let s=k("strides",e,t,n),r=k("pad",e,t,n),a=k("dataFormat",e,t,n).toUpperCase(),o=k("dilations",e,t,n);return[RA(k("x",e,t,n),k("filter",e,t,n),[s[1],s[2],s[3]],r,a,[o[1],o[2],o[3]])]}case"AvgPool":{let s=k("strides",e,t,n),r=k("pad",e,t,n),a=k("kernelSize",e,t,n);return[Hc(k("x",e,t,n),[a[1],a[2]],[s[1],s[2]],r)]}case"MaxPool":{let s=k("strides",e,t,n),r=k("pad",e,t,n),a=k("kernelSize",e,t,n);return[Yc(k("x",e,t,n),[a[1],a[2]],[s[1],s[2]],r)]}case"MaxPoolWithArgmax":{let s=k("strides",e,t,n),r=k("pad",e,t,n),a=k("kernelSize",e,t,n),o=k("includeBatchInIndex",e,t,n),{result:i,indexes:l}=T3(k("x",e,t,n),[a[1],a[2]],[s[1],s[2]],r,o);return[i,l]}case"AvgPool3D":{let s=k("strides",e,t,n),r=k("pad",e,t,n),a=k("kernelSize",e,t,n);return[CA(k("x",e,t,n),[a[1],a[2],a[3]],[s[1],s[2],s[3]],r)]}case"MaxPool3D":{let s=k("strides",e,t,n),r=k("pad",e,t,n),a=k("kernelSize",e,t,n);return[VA(k("x",e,t,n),[a[1],a[2],a[3]],[s[1],s[2],s[3]],r)]}case"Dilation2D":{let s=k("strides",e,t,n),r=k("pad",e,t,n),a=k("dilations",e,t,n),o=s[1],i=s[2],l=a[1],c=a[2];return[_A(k("x",e,t,n),k("filter",e,t,n),[o,i],r,[l,c],"NHWC")]}default:throw TypeError(`Node type ${e.op} is not implemented`)}},CW=(e,t,n)=>{switch(e.op){case"Fill":{let s=k("shape",e,t,n),r=k("dtype",e,t,n),a=k("value",e,t,n);return[iu(s,a,r)]}case"LinSpace":{let s=k("start",e,t,n),r=k("stop",e,t,n),a=k("num",e,t,n);return[b3(s,r,a)]}case"Multinomial":{let s=k("logits",e,t,n),r=k("numSamples",e,t,n),a=k("seed",e,t,n);return[N3(s,r,a)]}case"OneHot":{let s=k("indices",e,t,n),r=k("depth",e,t,n),a=k("onValue",e,t,n),o=k("offValue",e,t,n);return[Ql(s,r,a,o)]}case"Ones":return[as(k("shape",e,t,n),k("dtype",e,t,n))];case"OnesLike":return[os(k("x",e,t,n))];case"RandomUniform":return[cu(k("shape",e,t,n),k("minval",e,t,n),k("maxval",e,t,n),k("dtype",e,t,n))];case"Range":{let s=k("start",e,t,n),r=k("stop",e,t,n),a=k("step",e,t,n);return[du(s,r,a,k("dtype",e,t,n))]}case"TruncatedNormal":{let s=k("shape",e,t,n),r=k("mean",e,t,n),a=k("stdDev",e,t,n),o=k("seed",e,t,n);return[rf(s,r,a,k("dtype",e,t,n),o)]}case"Zeros":return[Ut(k("shape",e,t,n),k("dtype",e,t,n))];case"ZerosLike":return[Ze(k("x",e,t,n))];default:throw TypeError(`Node type ${e.op} is not implemented`)}};function i2(e,t,n){let s=k("boxes",e,t,n),r=k("scores",e,t,n),a=k("maxOutputSize",e,t,n),o=k("iouThreshold",e,t,n),i=k("scoreThreshold",e,t,n),l=k("softNmsSigma",e,t,n);return{boxes:s,scores:r,maxOutputSize:a,iouThreshold:o,scoreThreshold:i,softNmsSigma:l}}var TW=async(e,t,n)=>{switch(e.op){case"NonMaxSuppressionV5":{let{boxes:s,scores:r,maxOutputSize:a,iouThreshold:o,scoreThreshold:i,softNmsSigma:l}=i2(e,t,n),c=await _e.nonMaxSuppressionWithScoreAsync(s,r,a,o,i,l);return[c.selectedIndices,c.selectedScores]}case"NonMaxSuppressionV4":{let{boxes:s,scores:r,maxOutputSize:a,iouThreshold:o,scoreThreshold:i}=i2(e,t,n),l=k("padToMaxOutputSize",e,t,n),c=await _e.nonMaxSuppressionPaddedAsync(s,r,a,o,i,l);return[c.selectedIndices,c.validOutputs]}case"NonMaxSuppressionV3":case"NonMaxSuppressionV2":{let{boxes:s,scores:r,maxOutputSize:a,iouThreshold:o,scoreThreshold:i}=i2(e,t,n);return[await _e.nonMaxSuppressionAsync(s,r,a,o,i)]}case"Where":{let s=de(k("condition",e,t,n),"bool"),r=[await t1(s)];return s.dispose(),r}case"ListDiff":return D3(k("x",e,t,n),k("y",e,t,n));default:throw TypeError(`Node type ${e.op} is not implemented`)}},NW=(e,t,n)=>{switch(e.op){case"TopKV2":{let s=k("x",e,t,n),r=k("k",e,t,n),a=k("sorted",e,t,n),o=QA(s,r,a);return[o.values,o.indices]}case"Unique":{let s=k("x",e,t,n),r=af(s);return[r.values,r.indices]}case"UniqueV2":{let s=k("x",e,t,n),r=k("axis",e,t,n),a=af(s,r);return[a.values,a.indices]}default:throw TypeError(`Node type ${e.op} is not implemented`)}},EW=(e,t,n)=>{switch(e.op){case"Const":return t[e.name];case"PlaceholderWithDefault":let s=k("default",e,t,n);return[Fn(e.name,t,n)||s];case"Placeholder":return[Fn(e.name,t,n)];case"Identity":case"StopGradient":case"FakeQuantWithMinMaxVars":{let c=k("x",e,t,n);return[Hr(c)]}case"IdentityN":return k("x",e,t,n).map(c=>Hr(c));case"Snapshot":let r=k("x",e,t,n);return[Hr(r)];case"Shape":return[Gt(k("x",e,t,n).shape,"int32")];case"ShapeN":return k("x",e,t,n).map(c=>Gt(c.shape));case"Size":return[Ee(k("x",e,t,n).size,"int32")];case"Rank":return[Ee(k("x",e,t,n).rank,"int32")];case"NoOp":return[Ee(1)];case"Print":let a=k("x",e,t,n),o=k("data",e,t,n),i=k("message",e,t,n),l=k("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 c=0;c<o.length;c++)console.log(Array.prototype.slice.call(o[c].dataSync()).slice(0,l));return[a];default:throw TypeError(`Node type ${e.op} is not implemented`)}},RW=class{constructor(e,t){this.keyDType=e,this.valueDType=t,this.handle=Ee(0),this.tensorMap=new Map,an(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 Ee(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(),G(()=>{let s=Dn(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];an(l),this.tensorMap.set(i,l)}return this.handle})}async find(e,t){this.checkKeyAndValueTensor(e,t);let n=await e.data();return G(()=>{let s=[];for(let r=0;r<n.length;r++){let a=n[r],o=this.findWithDefault(a,t);s.push(o)}return gn(s)})}findWithDefault(e,t){let n=this.tensorMap.get(e);return 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}`)}},DW=async(e,t,n,s)=>{switch(e.op){case"HashTable":case"HashTableV2":{let r=k("keyDType",e,t,n),a=k("valueDType",e,t,n),o=new RW(r,a);return s.addHashTable(e.name,o),[o.handle]}case"LookupTableImport":case"LookupTableImportV2":{let r=k("tableHandle",e,t,n,s),a=k("keys",e,t,n),o=k("values",e,t,n);return[await s.getHashTableById(r.id).import(a,o)]}case"LookupTableFind":case"LookupTableFindV2":{let r=k("tableHandle",e,t,n,s),a=k("keys",e,t,n),o=k("defaultValue",e,t,n);return[await s.getHashTableById(r.id).find(a,o)]}case"LookupTableSize":case"LookupTableSizeV2":{let r=k("tableHandle",e,t,n,s);return[s.getHashTableById(r.id).tensorSize()]}default:throw TypeError(`Node type ${e.op} is not implemented`)}},_W=(e,t,n)=>{switch(e.op){case"ResizeBilinear":{let s=k("images",e,t,n),r=k("size",e,t,n),a=k("alignCorners",e,t,n),o=k("halfPixelCenters",e,t,n);return[_e.resizeBilinear(s,[r[0],r[1]],a,o)]}case"ResizeNearestNeighbor":{let s=k("images",e,t,n),r=k("size",e,t,n),a=k("alignCorners",e,t,n),o=k("halfPixelCenters",e,t,n);return[_e.resizeNearestNeighbor(s,[r[0],r[1]],a,o)]}case"CropAndResize":{let s=k("image",e,t,n),r=k("boxes",e,t,n),a=k("boxInd",e,t,n),o=k("cropSize",e,t,n),i=k("method",e,t,n),l=k("extrapolationValue",e,t,n);return[_e.cropAndResize(s,r,a,o,i,l)]}default:throw TypeError(`Node type ${e.op} is not implemented`)}},FW=(e,t,n)=>{switch(e.op){case"Equal":return[ns(k("a",e,t,n),k("b",e,t,n))];case"NotEqual":return[ii(k("a",e,t,n),k("b",e,t,n))];case"Greater":return[qn(k("a",e,t,n),k("b",e,t,n))];case"GreaterEqual":return[xa(k("a",e,t,n),k("b",e,t,n))];case"Less":return[Uh(k("a",e,t,n),k("b",e,t,n))];case"LessEqual":return[ba(k("a",e,t,n),k("b",e,t,n))];case"LogicalAnd":return[Ps(k("a",e,t,n),k("b",e,t,n))];case"LogicalNot":return[Zc(k("a",e,t,n))];case"LogicalOr":return[jh(k("a",e,t,n),k("b",e,t,n))];case"Select":case"SelectV2":return[In(k("condition",e,t,n),k("a",e,t,n),k("b",e,t,n))];default:throw TypeError(`Node type ${e.op} is not implemented`)}},$W=(e,t,n)=>{switch(e.op){case"BatchMatMul":case"BatchMatMulV2":case"MatMul":return[Ve(k("a",e,t,n),k("b",e,t,n),k("transposeA",e,t,n),k("transposeB",e,t,n))];case"Einsum":return[A3(k("equation",e,t,n),...k("tensors",e,t,n))];case"Transpose":return[Ke(k("x",e,t,n),k("perm",e,t,n))];case"_FusedMatMul":let[s,r]=k("fusedOps",e,t,n),a=s==="biasadd",o=r==="prelu",i=k("numArgs",e,t,n),l=k("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[c,u]=k("args",e,t,n);return[va.matMul({a:k("a",e,t,n),b:k("b",e,t,n),transposeA:k("transposeA",e,t,n),transposeB:k("transposeB",e,t,n),bias:c,activation:r,preluActivationWeights:u,leakyreluAlpha:l})];default:throw TypeError(`Node type ${e.op} is not implemented`)}},OW=(e,t,n)=>{switch(e.op){case"FusedBatchNorm":case"FusedBatchNormV2":return[si(k("x",e,t,n),k("mean",e,t,n),k("variance",e,t,n),k("offset",e,t,n),k("scale",e,t,n),k("epsilon",e,t,n))];case"FusedBatchNormV3":return[si(k("x",e,t,n),k("mean",e,t,n),k("variance",e,t,n),k("offset",e,t,n),k("scale",e,t,n),k("epsilon",e,t,n))];case"LRN":return[zA(k("x",e,t,n),k("radius",e,t,n),k("bias",e,t,n),k("alpha",e,t,n),k("beta",e,t,n))];case"Softmax":return[li(k("x",e,t,n))];case"LogSoftmax":return[Hh(k("x",e,t,n))];case"SparseToDense":return[n1(k("sparseIndices",e,t,n),k("outputShape",e,t,n),k("sparseValues",e,t,n),k("defaultValue",e,t,n))];default:throw TypeError(`Node type ${e.op} is not implemented`)}},PW=(e,t,n)=>{switch(e.op){case"Max":{let o=k("axis",e,t,n),i=k("keepDims",e,t,n);return[Rn(k("x",e,t,n),o,i)]}case"Mean":{let o=k("axis",e,t,n),i=k("keepDims",e,t,n);return[_t(k("x",e,t,n),o,i)]}case"Min":{let o=k("axis",e,t,n),i=k("keepDims",e,t,n);return[Jc(k("x",e,t,n),o,i)]}case"Sum":{let o=k("axis",e,t,n),i=k("keepDims",e,t,n);return[Ie(k("x",e,t,n),o,i)]}case"All":{let o=k("axis",e,t,n),i=k("keepDims",e,t,n);return[Ph(k("x",e,t,n),o,i)]}case"Any":{let o=k("axis",e,t,n),i=k("keepDims",e,t,n);return[Uc(k("x",e,t,n),o,i)]}case"ArgMax":{let o=k("axis",e,t,n);return[xs(k("x",e,t,n),o)]}case"ArgMin":{let o=k("axis",e,t,n);return[yA(k("x",e,t,n),o)]}case"Prod":{let o=k("axis",e,t,n),i=k("keepDims",e,t,n);return[Xh(k("x",e,t,n),o,i)]}case"Cumsum":{let o=k("axis",e,t,n),i=k("exclusive",e,t,n),l=k("reverse",e,t,n);return[Wh(k("x",e,t,n),o,i,l)]}case"Bincount":let s=k("x",e,t,n),r=k("weights",e,t,n),a=k("size",e,t,n);return[TA(s,r,a)];case"DenseBincount":{let o=k("x",e,t,n),i=k("weights",e,t,n),l=k("size",e,t,n),c=k("binaryOutput",e,t,n);return[m3(o,i,l,c)]}default:throw TypeError(`Node type ${e.op} is not implemented`)}},MW=(e,t,n)=>{switch(e.op){case"ConcatV2":case"Concat":{let s=k("n",e,t,n),r=k("axis",e,t,n),a=k("tensors",e,t,n);return a=a.slice(0,s),[mt(a,r)]}case"Gather":{let s=k("x",e,t,n),r=k("indices",e,t,n);return[ri(s,de(r,"int32"),0)]}case"GatherV2":{let s=k("axis",e,t,n),r=k("batchDims",e,t,n),a=k("x",e,t,n),o=k("indices",e,t,n);return[ri(a,de(o,"int32"),s,r)]}case"Reverse":{let s=k("dims",e,t,n),r=[];for(let o=0;o<s.length;o++)s[o]&&r.push(o);let a=k("x",e,t,n);return[is(a,r)]}case"ReverseV2":{let s=k("axis",e,t,n),r=k("x",e,t,n);return[is(r,s)]}case"Slice":{let s=k("begin",e,t,n),r=k("size",e,t,n);return[Fe(k("x",e,t,n),s,r)]}case"StridedSlice":{let s=k("begin",e,t,n),r=k("end",e,t,n),a=k("strides",e,t,n),o=k("beginMask",e,t,n),i=k("endMask",e,t,n),l=k("ellipsisMask",e,t,n),c=k("newAxisMask",e,t,n),u=k("shrinkAxisMask",e,t,n),d=k("x",e,t,n);return[YA(d,s,r,a,o,i,l,c,u)]}case"Pack":return G(()=>{let s=k("axis",e,t,n),r=k("tensors",e,t,n),a=r[0].shape,o=rt(r[0]).shape,i=r.map(l=>{let c=w.arraysEqual(l.shape,a);if(!c&&!w.arraysEqual(rt(l).shape,o))throw new Error("the input tensors shape does not match");return c?l:V(l,a)});return[gn(i,s)]});case"Unpack":{let s=k("axis",e,t,n),r=k("tensor",e,t,n);return Dn(r,s)}case"Tile":{let s=k("reps",e,t,n);return[bs(k("x",e,t,n),s)]}case"Split":case"SplitV":{let s=k("axis",e,t,n),r=k("numOrSizeSplits",e,t,n),a=k("x",e,t,n);return on(a,r,s)}case"ScatterNd":{let s=k("indices",e,t,n),r=k("values",e,t,n),a=k("shape",e,t,n);return[O3(s,r,a)]}case"GatherNd":{let s=k("x",e,t,n),r=k("indices",e,t,n);return[P3(s,r)]}case"SparseToDense":{let s=k("sparseIndices",e,t,n),r=k("outputShape",e,t,n),a=k("sparseValues",e,t,n),o=k("defaultValue",e,t,n);return[n1(s,a,r,a.dtype===o.dtype?o:de(o,a.dtype))]}default:throw TypeError(`Node type ${e.op} is not implemented`)}},zW=(e,t,n)=>{switch(e.op){case"SparseFillEmptyRows":{let{outputIndices:s,outputValues:r,emptyRowIndicator:a,reverseIndexMap:o}=ad.sparseFillEmptyRows(k("indices",e,t,n),k("values",e,t,n),k("denseShape",e,t,n),k("defaultValue",e,t,n));return[s,r,a,o]}case"SparseReshape":{let{outputIndices:s,outputShape:r}=ad.sparseReshape(k("inputIndices",e,t,n),k("inputShape",e,t,n),k("newShape",e,t,n));return[s,r]}case"SparseSegmentMean":return[ad.sparseSegmentMean(k("data",e,t,n),k("indices",e,t,n),k("segmentIds",e,t,n))];case"SparseSegmentSum":return[ad.sparseSegmentSum(k("data",e,t,n),k("indices",e,t,n),k("segmentIds",e,t,n))];default:throw TypeError(`Node type ${e.op} is not implemented`)}},LW=(e,t,n)=>{switch(e.op){case"FFT":return[sd(k("x",e,t,n))];case"IFFT":return[hu(k("x",e,t,n))];case"RFFT":return[rd(k("x",e,t,n))];case"IRFFT":return[nf(k("x",e,t,n))];default:throw TypeError(`Node type ${e.op} is not implemented`)}},BW=(e,t,n)=>{switch(e.op){case"StringNGrams":{let{nGrams:s,nGramsSplits:r}=pf.stringNGrams(k("data",e,t,n),k("dataSplits",e,t,n),k("separator",e,t,n),k("nGramWidths",e,t,n),k("leftPad",e,t,n),k("rightPad",e,t,n),k("padWidth",e,t,n),k("preserveShortSequences",e,t,n));return[s,r]}case"StringSplit":{let{indices:s,values:r,shape:a}=pf.stringSplit(k("input",e,t,n),k("delimiter",e,t,n),k("skipEmpty",e,t,n));return[s,r,a]}case"StringToHashBucketFast":return[pf.stringToHashBucketFast(k("input",e,t,n),k("numBuckets",e,t,n))];default:throw TypeError(`Node type ${e.op} is not implemented`)}},WW=(e,t,n)=>{switch(e.op){case"Cast":return[de(k("x",e,t,n),k("dtype",e,t,n))];case"ExpandDims":{let s=k("axis",e,t,n);return[Lt(k("x",e,t,n),s)]}case"Squeeze":{let s=k("axis",e,t,n);return[rt(k("x",e,t,n),s)]}case"Reshape":return[V(k("x",e,t,n),k("shape",e,t,n))];case"MirrorPad":return[UA(k("x",e,t,n),k("padding",e,t,n),k("mode",e,t,n))];case"PadV2":case"Pad":return[vs(k("x",e,t,n),k("padding",e,t,n),k("constantValue",e,t,n))];case"SpaceToBatchND":{let s=k("blockShape",e,t,n),r=k("paddings",e,t,n);return[Qc(k("x",e,t,n),s,r)]}case"BatchToSpaceND":{let s=k("blockShape",e,t,n),r=k("crops",e,t,n);return[jc(k("x",e,t,n),s,r)]}case"DepthToSpace":{let s=k("blockSize",e,t,n),r=k("dataFormat",e,t,n).toUpperCase();return[DA(k("x",e,t,n),s,r)]}case"BroadcastTo":return[su(k("x",e,t,n),k("shape",e,t,n))];case"BroadcastArgs":return[u3(k("s0",e,t,n),k("s1",e,t,n))];default:throw TypeError(`Node type ${e.op} is not implemented`)}};function v7(e,t,n,s){let r=((a,o,i)=>{switch(a.category){case"arithmetic":return G(()=>AW(a,o,i));case"basic_math":return G(()=>yW(a,o,i));case"control":return IW(a,o,i);case"convolution":return G(()=>SW(a,o,i));case"creation":return G(()=>CW(a,o,i));case"dynamic":return TW(a,o,i);case"evaluation":return G(()=>NW(a,o,i));case"image":return G(()=>_W(a,o,i));case"graph":return G(()=>EW(a,o,i));case"logical":return G(()=>FW(a,o,i));case"matrices":return G(()=>$W(a,o,i));case"normalization":return G(()=>OW(a,o,i));case"reduction":return G(()=>PW(a,o,i));case"slice_join":return G(()=>MW(a,o,i));case"sparse":return G(()=>zW(a,o,i));case"spectral":return G(()=>LW(a,o,i));case"string":return G(()=>BW(a,o,i));case"transformation":return G(()=>WW(a,o,i));case"hash_table":return DW(a,o,i,s);case"custom":let l=Kw(a.op);if(l&&l.customExecutor)return l.customExecutor(new gW(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 w7=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 k7(e,t,n,s){let r=new Set,a=[],o=null,i=null,l=new Set,c=Object.keys(e).map(p=>ls(p)[0]),u=[];s!=null&&(u=s.map(p=>ls(p.name)[0]));let d=[...t];for(;d.length>0;){let p=d.pop();if((I7(p)||jW(p)||qW(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&&c.indexOf(p.name)===-1&&u.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 VW(e,t,n){let{usedNodes:s,inputs:r}=n,a=[],o=Object.keys(r).map(u=>ls(u)[0]).map(u=>e.nodes[u]),i=e.initNodes;o.forEach(u=>{s.has(u.name)&&a.push(u)}),e.weights.forEach(u=>{s.has(u.name)&&a.push(u)}),i!=null&&i.forEach(u=>{s.has(u.name)&&a.push(u)});let l=new Set,c=[];for(;a.length>0;){let u=a.pop();l.add(u.name),t[u.name]||c.push(u),u.children.forEach(d=>{!l.has(d.name)&&s.has(d.name)&&d.inputs.every(p=>l.has(p.name))&&a.push(d)})}return c}var UW=["Switch","Merge","Enter","Exit","NextIteration","StatelessIf","StatelessWhile","if","While"],GW=["NonMaxSuppressionV2","NonMaxSuppressionV3","NonMaxSuppressionV5","Where"],HW=["HashTable","HashTableV2","LookupTableImport","LookupTableImportV2","LookupTableFind","LookupTableFindV2","LookupTableSize","LookupTableSizeV2"];function I7(e){return UW.indexOf(e.op)>=0}function jW(e){return GW.indexOf(e.op)>=0}function qW(e){return HW.indexOf(e.op)>=0}var l2=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 l2(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=k7(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 VW(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(u=>this.graph.nodes[ls(u)[0]]),r=t.map(u=>ls(u)[0]),a=r.map(u=>this.graph.nodes[u]);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={},c={};return G(()=>{let u=new w7(this.weightMap,l,c,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=v7(m,d,u,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,u,p,r,h)}}return this.parent==null&&u.dispose(p),t.map(f=>Fn(f,d,u))})}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=KB(i.name,n,s);l!=null&&l.forEach(c=>{if(c&&!c.kept&&!r.has(c.id)){let u=o[c.id];u===1?(c.dispose(),delete o[c.id]):u!=null&&o[c.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 w7(this.weightMap,s,r,this.functionExecutorMap),o=await this.executeWithControlFlow(e,a,t,n),i=t.map(d=>Fn(d,o,a)),l=i.map(d=>d.id),c=Object.keys(e).map(d=>e[d].id),u=new Set([...l,...c,...this.weightIds]);return Object.keys(o).forEach(d=>{o[d].forEach(h=>{h&&!h.kept&&!h.isDisposed&&!u.has(h.id)&&h.dispose()})}),this.parent==null&&a.dispose(u),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:c,dynamicNode:u,syncInputs:d}=k7(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)}u==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=>!I7(y)&&!Fn(y.name,h,t)).map(y=>y.name);if(A.length>0){let y="";throw u!=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: [${c}]. ${y}`)}return h}processStack(e,t,n,s,r,a,o,i,l){let c=[];for(;t.length>0;){let u=t.pop();n.currentContext=u.contexts;let d="";if(u.node.op==="Enter"&&k("isConstant",u.node,s,n)&&([d]=Gr(u.node.name,n)),s[u.node.name]==null){let p=v7(u.node,s,n,this._resourceManager);d||([d]=Gr(u.node.name,n));let h=n.currentContext;w.isPromise(p)?c.push(p.then(f=>(s[d]=f,n.currentContext=h,this.checkTensorForDisposal(d,u.node,s,n,a,o,i),this.processChildNodes(u.node,t,n,s,r,l),f))):(s[d]=p,this.checkTensorForDisposal(d,u.node,s,n,a,o,i),this.processChildNodes(u.node,t,n,s,r,l))}else this.processChildNodes(u.node,t,n,s,r,l)}return c}processChildNodes(e,t,n,s,r,a){e.children.forEach(o=>{let[i]=Gr(o.name,n);r[i]||!a.has(o.name)||(o.op==="Merge"?o.inputNames.some(l=>!!Fn(l,s,n))&&(r[i]=!0,t.push({contexts:n.currentContext,node:o})):o.inputNames.every(l=>!!Fn(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`)})}},XW=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]}},KW="?tfjs-format=file",ZW="model.json",S7=class{constructor(e,t={}){this.modelUrl=e,this.loadOptions=t,this.version="n/a",t==null&&(this.loadOptions={}),this.resourceManager=new XW}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=Gn.browserHTTPRequest(e,this.loadOptions);else{let t=Gn.getLoadHandlers(e,this.loadOptions);if(t.length===0)t.push(Gn.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=Gn.decodeWeights(this.artifacts.weightData,this.artifacts.weightSpecs);if(this.executor=new l2(m7.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=m7.Instance.transformGraph(e.modelInitializer);this.initializer=new l2(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=Gn.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 Qe(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}${ZW}${KW}`);let n=new S7(e,t);return await n.load(),n}var YW="3.10.0",C7={};ze(C7,{CSVDataset:()=>z7,Dataset:()=>Iu,FileDataSource:()=>H7,TextLineDataset:()=>O7,URLDataSource:()=>j7,array:()=>bV,csv:()=>DV,func:()=>_V,generator:()=>FV,microphone:()=>OV,version_data:()=>PV,webcam:()=>$V,zip:()=>vV});var JW=ja(B5()),QW=ja(B5());function eV(e,t){return Qf(e,t)}function Qf(e,t,n=new Map,s=new Set){if(e==null)return null;if(typeof Blob=="function"&&e instanceof Blob)return e.slice();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(ku(e)){let a=Array.isArray(e)?[]:{};s.add(e);for(let o in e){let i=e[o],l=Qf(i,t,n,s);a[o]=l}return s.delete(e),e.__proto__&&(a.__proto__=e.__proto__),a}else throw new Error(`Can't recurse into non-iterable type: ${e}`);else return n.set(e,r.value),r.value}function tV(e,t=N7){return T7(e,t)}function T7(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(ku(s)){let a=Array.isArray(s)?[]:{};n.add(s);for(let o in s){let i=e.map(c=>c[o]),l=T7(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 N7(e){return e===null?null:ku(e[0])?{value:null,recurse:!0}:{value:e,recurse:!1}}async function E7(e,t){let n=new Map;Qf(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 Qf(e,t,n)}function ku(e){let t=!1;if(Y().get("IS_BROWSER"))t=e instanceof TextDecoder;else{let{StringDecoder:n}=W5();t=e instanceof n}return e!=null&&!ArrayBuffer.isView(e)&&(Array.isArray(e)||typeof e=="object"&&!(e instanceof Ge)&&!(e instanceof Promise)&&!t)}function nV(e){return e==null||sV(e)||Array.isArray(e)||typeof e=="object"&&e instanceof Ge||w.isTypedArray(e)}function sV(e){return e===null||typeof e!="object"&&typeof e!="function"}function rV(e){return eV(e,aV)}function aV(e){return e instanceof Ge?{value:e.clone(),recurse:!1}:ku(e)?{value:null,recurse:!0}:{value:e,recurse:!1}}var R7=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}},u2=class extends R7{constructor(){super(u2.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}};u2.INITIAL_CAPACITY=32;function D7(e){return new lV(e)}function c2(e){return new uV(e)}function oV(e,t){return new F7(e,t)}function iV(e,t=Ea.FAIL){return new yV(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 gV(this,e)}filter(e){return new fV(this,e)}map(e){return new mV(this,e)}mapAsync(e){return new _7(this,e)}serialMapAsync(e){return new _7(this,e).serial()}flatmap(e){return new AV(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 hV(this,e,t)}columnMajorBatch(e,t=!0,n=N7){return this.rowMajorBatch(e,t).map(r=>tV(r,n))}concatenate(e,t){return new F7(D7([this,e]),t)}take(e){return e<0||e==null?this:new pV(this,e)}skip(e){return e<0||e==null?this:new dV(this,e)}prefetch(e){return new $7(this,e)}shuffle(e,t){return new xV(this,e,t)}serial(){return new cV(this)}},lV=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:rV(e),done:!1}}},uV=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}}},cV=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()}},dV=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()}},pV=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()}},hV=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}}},fV=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)}}},mV=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=js.getTensorsInContainer(e.value),n=this.transform(e.value),s=js.getTensorsInContainer(n);for(let r of t)js.isTensorInList(r,s)||r.dispose();return{value:n,done:!1}}},gV=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}}}},_7=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=js.getTensorsInContainer(e.value),n=await this.transform(e.value),s=js.getTensorsInContainer(n);for(let r of t)js.isTensorInList(r,s)||r.dispose();return{value:n,done:!1}}},d2=class extends un{constructor(){super();this.outputQueue=new u2,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}}},AV=class extends d2{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=js.getTensorsInContainer(e.value),n=this.transform(e.value),s=js.getTensorsInContainer(n);this.outputQueue.pushAll(n);for(let r of t)js.isTensorInList(r,s)||r.dispose();return!0}},F7=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}},Ea;(function(e){e[e.FAIL=0]="FAIL",e[e.SHORTEST=1]="SHORTEST",e[e.LONGEST=2]="LONGEST"})(Ea||(Ea={}));var yV=class extends un{constructor(e,t=Ea.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 E7(this.iterators,s);if(t===n)return{value:null,done:!0};if(n>0)switch(this.mismatchMode){case Ea.FAIL:throw new Error(`Zipped streams should have the same length. Mismatched at element ${this.count}.`);case Ea.SHORTEST:return{value:null,done:!0};case Ea.LONGEST:default:}return this.count++,{value:r,done:!1}}async next(){return this.currentPromise=this.nextState(this.currentPromise),this.currentPromise}},$7=class extends un{constructor(e,t){super();this.upstream=e,this.bufferSize=t,this.buffer=new R7(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()}},xV=class extends $7{constructor(e,t,n){super(e,t);this.upstream=e,this.windowSize=t,this.upstreamExhausted=!1,this.random=QW.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}}},Iu=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,wV),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=>G(()=>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=>G(()=>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=c2(async()=>({value:await t.iterator(),done:!1}));return oV(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=JW.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()}};Iu.MAX_BUFFER_SIZE=1e4;function us(e,t=null){return new class extends Iu{constructor(){super(...arguments);this.size=t}async iterator(){return e()}}}function bV(e){return us(async()=>D7(e),e.length)}function vV(e){if(!ku(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 E7(e,s=>{if(s instanceof Iu)return{value:s.iterator(),recurse:!1};if(ku(s))return{value:null,recurse:!0};throw new Error("Leaves of the structure passed to zip() must be Datasets, not primitives.")});return iV(n,Ea.SHORTEST)},t)}function wV(e){if(e===null)return null;let t=e[0];return nV(t)?{value:kV(e),recurse:!1}:{value:null,recurse:!0}}function kV(e){if(e.length===0)throw new Error("Can't make a batch of zero elements.");return e[0]instanceof Ge?gn(e):zt(e)}var O7=class extends Iu{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))}},e0='"',Td=Symbol("out"),P7=Symbol("field"),t0=Symbol("quote"),p2=Symbol("quoteafterquote"),M7=Symbol("quoteinquote"),z7=class extends Iu{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 O7(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 c=Number(i);if(isNaN(c))o&&o.dtype==="bool"?l=this.getBoolean(i):l=i;else if(!o||!o.dtype)l=c;else switch(o.dtype){case"float32":l=c;break;case"int32":l=Math.floor(c);break;case"bool":l=this.getBoolean(i);break;default:l=c}}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=Td;for(let o=0;o<r;o++)switch(a){case Td:switch(e.charAt(o)){case e0:s=o+1,a=t0;break;case this.delimiter:if(s=o+1,this.delimiter===" "&&this.delimWhitespace)break;n.push(""),a=Td;break;default:a=P7,s=o;break}break;case P7:switch(e.charAt(o)){case this.delimiter:n.push(e.substring(s,o)),a=Td,s=o+1;break;default:}break;case t0:switch(e.charAt(o)){case e0:a=p2;break;default:}break;case p2:switch(e.charAt(o)){case this.delimiter:n.push(e.substring(s,o-1)),a=Td,s=o+1;break;case e0:a=t0;break;default:a=M7;break}break;case M7:switch(e.charAt(o)){case e0:a=t0;break;default:}break;default:}if(a===p2?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}},L7=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 L7(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),zt(n,t)}},B7=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=Gt([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=Ys([a,r,i,o],[1,4])}else this.cropBox=Ys([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 B7(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=Os.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 G(()=>{let t=Lt(de(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.")}},W7=class{},V7=class extends un{split(e){return new IV(this,e)}},IV=class extends V7{constructor(e,t){super();this.upstream=e,this.impl=new SV(e,t)}summary(){return this.impl.summary()}async next(){return this.impl.next()}},SV=class extends d2{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}},CV=class extends un{decodeUTF8(){return new TV(this)}},TV=class extends V7{constructor(e){super();this.upstream=e,this.impl=new NV(e)}summary(){return this.impl.summary()}async next(){return this.impl.next()}},NV=class extends d2{constructor(e){super();if(this.upstream=e,Y().get("IS_BROWSER"))this.decoder=new TextDecoder("utf-8");else{let{StringDecoder:t}=W5();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}},U7=class extends CV{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 EV(e,t={},n){let s,r;typeof e=="string"?s=e:(s=e.url,r=RV(e));let a=await(n||w.fetch)(s,r);if(a.ok){let o=new Uint8Array(await a.arrayBuffer());return new U7(o,t)}else throw new Error(a.statusText)}var RV=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 G7(e){return typeof e=="string"&&e.substr(0,7)==="file://"}var H7=class extends W7{constructor(e,t={}){super();this.input=e,this.options=t}async iterator(){if(G7(this.input)&&Y().get("IS_NODE")){let e=Gi("fs");this.input=e.readFileSync(this.input.substr(7))}return new U7(this.input,this.options)}},j7=class extends W7{constructor(e,t={}){super();this.url=e,this.fileOptions=t}async iterator(){return G7(this.url)?new H7(this.url,this.fileOptions).iterator():EV(this.url,this.fileOptions)}};function DV(e,t={}){return new z7(new j7(e),t)}function _V(e){let t=c2(e);return us(async()=>t)}function FV(e){return us(async()=>{let t=await e();return c2(()=>t.next())})}async function $V(e,t){return B7.create(e,t)}async function OV(e){return L7.create(e)}var PV="3.10.0";function Ne(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 MV=br.whereImpl,h2=class extends hc{constructor(){super();this.blockSize=48,this.firstUse=!0,this.data=new $p(this,ts())}nextDataId(){return h2.nextDataId++}write(e,t,n){this.firstUse&&(this.firstUse=!1,Y().get("IS_NODE")&&N.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 N.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{throw new Error("Failed to decode encoded string bytes into utf-8")}return He(e.shape,e.dtype,n)}makeOutput(e,t,n){let s=this.write(e,t,n);return ts().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){Ne([e],"where");let t=this.readSync(e.dataId);return MV(e.shape,t)}dispose(){}floatPrecision(){return 32}epsilon(){return super.epsilon()}};h2.nextDataId=0;var q7={};ze(q7,{addImpl:()=>K7,bincountImpl:()=>m2,bincountReduceImpl:()=>Z7,ceilImpl:()=>Y7,concatImpl:()=>g2,equalImpl:()=>J7,expImpl:()=>e6,expm1Impl:()=>n6,floorImpl:()=>s6,gatherNdImpl:()=>r6,gatherV2Impl:()=>a6,greaterEqualImpl:()=>i6,greaterImpl:()=>o6,lessEqualImpl:()=>u6,lessImpl:()=>l6,linSpaceImpl:()=>c6,logImpl:()=>d6,maxImpl:()=>p6,maximumImpl:()=>h6,minimumImpl:()=>f6,multiplyImpl:()=>A2,negImpl:()=>m6,notEqualImpl:()=>g6,prodImpl:()=>A6,rangeImpl:()=>x2,rsqrtImpl:()=>y6,sigmoidImpl:()=>SU,simpleAbsImpl:()=>X7,sliceImpl:()=>r0,sparseFillEmptyRowsImpl:()=>b6,sparseReshapeImpl:()=>v6,sparseSegmentReductionImpl:()=>b2,sqrtImpl:()=>NU,squaredDifferenceImpl:()=>w6,stridedSliceImpl:()=>k6,stringNGramsImpl:()=>I6,stringSplitImpl:()=>S6,stringToHashBucketFastImpl:()=>C6,subImpl:()=>T6,tileImpl:()=>N6,topKImpl:()=>R6,transposeImpl:()=>y2,uniqueImpl:()=>D6});function X7(e){let t=new Float32Array(e.length);for(let n=0;n<e.length;++n)t[n]=Math.abs(e[n]);return t}var zV=e=>{let{x:t}=e.inputs,n=e.backend;Ne(t,"abs");let s=new Float32Array(w.sizeFromShape(t.shape)),r=n.data.get(t.dataId).values;return s=X7(r),n.makeOutput(s,t.shape,t.dtype)},LV={kernelName:qi,backendName:"cpu",kernelFunc:zV};function jt(e){return(t,n,s,r,a)=>{let o=N.assertAndGetBroadcastShape(t,n),i=o.length,l=w.computeStrides(o),c=w.sizeFromShape(o),u=w.getTypedArrayFromDType(a,c),d=t.length,p=n.length,h=w.computeStrides(t),f=w.computeStrides(n),m=N.getBroadcastDims(t,o),g=N.getBroadcastDims(n,o);if(m.length+g.length===0)for(let A=0;A<u.length;++A)u[A]=e(s[A%s.length],r[A%r.length]);else for(let A=0;A<u.length;++A){let y=w.indexToLoc(A,i,l),x=y.slice(-d);m.forEach(T=>x[T]=0);let b=w.locToIndex(x,d,h),v=y.slice(-p);g.forEach(T=>v[T]=0);let S=w.locToIndex(v,p,f);u[A]=e(s[b],r[S])}return[u,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 BV={kernelName:Up,backendName:"cpu",kernelFunc:cs};function n0(e,t,n="float32"){if(n==="complex64"){let r=n0(e,t,"float32"),a=n0(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 Cr(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 WV={kernelName:mo,backendName:"cpu",kernelFunc:Cr};function bi(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 VV={kernelName:ch,backendName:"cpu",kernelFunc:bi};function Ra(e){let{inputs:t,backend:n,attrs:s}=e,{x:r}=t,{dtype:a}=s;if(a==="complex64"){if(r.dtype==="complex64")return Cr({inputs:{x:r},backend:n});let o=n0(n,r.shape,r.dtype),i=Ra({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=bi({inputs:{input:r},backend:n}),i=Ra({inputs:{x:o},backend:n,attrs:{dtype:a}});return n.disposeIntermediateTensorInfo(o),i}if(!w.hasEncodingLoss(r.dtype,a)){let o=Cr({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,c]=jt((u,d)=>u!==d?1:0)(r.shape,[],o,i,"bool");return n.makeTensorInfo(c,"bool",l)}throw new Error(`Error in Cast: failed to cast ${r.dtype} to ${a}`)}var UV={kernelName:Qa,backendName:"cpu",kernelFunc:Ra};function cn(e,t,n,s){return n==null?({inputs:r,backend:a})=>{let{a:o,b:i}=r,l=a;Ne([o,i],e);let c=l.data.get(o.dataId).values,u=l.data.get(i.dataId).values,d=o.dtype==="string"?N.fromUint8ToStringArray(c):c,p=o.dtype==="string"?N.fromUint8ToStringArray(u):u,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 c=Ra({inputs:{x:o},backend:l,attrs:{dtype:"complex64"}}),u=l.data.get(c.dataId),d=u.complexTensorInfos.real,p=u.complexTensorInfos.imag,h=l.data.get(d.dataId).values,f=l.data.get(p.dataId).values,m=Ra({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,S,T]=n(o.shape,i.shape,h,f,x,b),_=l.makeTensorInfo(T,"float32",v),O=l.makeTensorInfo(T,"float32",S),P=cs({inputs:{real:_,imag:O},backend:l});return l.disposeIntermediateTensorInfo(c),l.disposeIntermediateTensorInfo(m),l.disposeIntermediateTensorInfo(_),l.disposeIntermediateTensorInfo(O),P}else{let c=l.data.get(o.dataId).values,u=l.data.get(i.dataId).values,d=s||o.dtype,[p,h]=t(o.shape,i.shape,c,u,d);return l.makeTensorInfo(h,d,p)}}}function f2(e){return(t,n,s,r,a,o)=>{let i=N.assertAndGetBroadcastShape(t,n),l=w.sizeFromShape(i),c=i.length,u=w.computeStrides(i),d=w.getTypedArrayFromDType("float32",l),p=w.getTypedArrayFromDType("float32",l),h=N.getBroadcastDims(t,i),f=N.getBroadcastDims(n,i),m=N.mergeRealAndImagArrays(s,r),g=N.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 S=v%m.length,T=v%g.length,_=e(m[S*2],m[S*2+1],g[T*2],g[T*2+1]);d[v]=_.real,p[v]=_.imag}else for(let v=0;v<d.length;v++){let S=w.indexToLoc(v,c,u),T=S.slice(-A);h.forEach(F=>T[F]=0);let _=w.locToIndex(T,A,y),O=S.slice(-x);f.forEach(F=>O[F]=0);let P=w.locToIndex(O,x,b),D=e(m[_*2],m[_*2+1],g[P*2],g[P*2+1]);d[v]=D.real,p[v]=D.imag}return[d,p,i]}}var K7=jt((e,t)=>e+t),GV=f2((e,t,n,s)=>({real:e+n,imag:t+s})),Nd=cn(la,K7,GV),HV={kernelName:la,backendName:"cpu",kernelFunc:Nd};function m2(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 Z7(e,t,n,s=!1){let r=e.shape[0],a=e.shape[1],o=He([r,n],t.dtype);for(let i=0;i<r;i++)for(let l=0;l<a;l++){let c=e.get(i,l);if(c<0)throw new Error("Input x must be non-negative!");c>=n||(s?o.set(1,i,c):t.size>0?o.set(o.get(i,c)+t.get(i,l),i,c):o.set(o.get(i,c)+1,i,c))}return o}function Da(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 dt(e,t,n){return({inputs:s,attrs:r,backend:a})=>{let{x:o}=s;if(Ne(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,c=w.sizeFromShape(o.shape),u=n||o.dtype,d=w.getArrayFromDType(u,c);for(let p=0;p<c;++p)d[p]=t(l[p],r);return i.makeTensorInfo(o.shape,u,d)}}function Su(e,t,n){return({inputs:s,attrs:r,backend:a})=>{let{x:o}=s;if(Ne(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,c=n||o.dtype,u=t(l,c,r);return i.makeTensorInfo(o.shape,c,u)}}var Y7=Da(e=>Math.ceil(e)),jV=Su(eo,Y7),qV={kernelName:eo,backendName:"cpu",kernelFunc:jV};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"?N.fromUint8ToStringArray(o.vals):o.vals,l=0;for(let c=0;c<o.shape[0];++c){let u=c*t[1]+a;for(let d=0;d<o.shape[1];++d)r[u+d]=i[l++]}a+=o.shape[1]})}return r}var J7=jt((e,t)=>e===t?1:0),Q7=cn(ll,J7,null,"bool"),XV={kernelName:ll,backendName:"cpu",kernelFunc:Q7},e6=Da(e=>Math.exp(e)),t6=Su(uo,e6,"float32"),KV={kernelName:uo,backendName:"cpu",kernelFunc:t6},n6=Da(e=>Math.expm1(e)),ZV=Su(cl,n6),YV={kernelName:cl,backendName:"cpu",kernelFunc:ZV},s6=Da(e=>Math.floor(e)),JV=Su(co,s6),QV={kernelName:co,backendName:"cpu",kernelFunc:JV};function r6(e,t,n,s,r,a,o,i,l){let c=He([s,a],n);for(let u=0;u<s;u++){let d=[],p=0;for(let h=0;h<r;h++){let f=e[u*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++)c.values[u*a+h]=t.get(...t.indexToLoc(p*a+h))}return c}function a6(e,t,n){let s=He(n,e.dtype);for(let r=0;r<s.size;++r){let o=s.indexToLoc(r).slice(),i=o[0],l=o[2],c=t.locToIndex([i,l]);o[2]=t.values[c];let u=e.locToIndex(o);s.values[r]=e.values[u]}return s}var o6=jt((e,t)=>e>t?1:0),eU=cn(fl,o6,null,"bool"),tU={kernelName:fl,backendName:"cpu",kernelFunc:eU},i6=jt((e,t)=>e>=t?1:0),nU=cn(fo,i6,null,"bool"),sU={kernelName:fo,backendName:"cpu",kernelFunc:nU},l6=jt((e,t)=>e<t?1:0),rU=cn(yl,l6,null,"bool"),aU={kernelName:yl,backendName:"cpu",kernelFunc:rU},u6=jt((e,t)=>e<=t?1:0),oU=cn(xl,u6,null,"bool"),iU={kernelName:xl,backendName:"cpu",kernelFunc:oU};function c6(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 d6=Da(e=>Math.log(e)),lU=Su(Ao,d6),uU={kernelName:Ao,backendName:"cpu",kernelFunc:lU};function p6(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 c=e[o+l];(Number.isNaN(c)||c>i)&&(i=c)}r[a]=i}return r}var h6=jt((e,t)=>Math.max(e,t)),cU=cn(xo,h6),dU={kernelName:xo,backendName:"cpu",kernelFunc:cU},f6=jt((e,t)=>Math.min(e,t)),pU=cn(ko,f6),hU={kernelName:ko,backendName:"cpu",kernelFunc:pU},A2=jt((e,t)=>e*t),fU=f2((e,t,n,s)=>({real:e*n-t*s,imag:e*s+t*n})),s0=cn(So,A2,fU),mU={kernelName:So,backendName:"cpu",kernelFunc:s0};function m6(e,t,n){let s=w.createScalarValue(-1,n);return A2([],t,s,e,n)}function gU(e){let{inputs:t,backend:n}=e,{x:s}=t;Ne(s,"neg");let r=n.data.get(s.dataId).values,[a,o]=m6(r,s.shape,s.dtype);return n.makeTensorInfo(o,s.dtype,a)}var AU={kernelName:kl,backendName:"cpu",kernelFunc:gU},g6=jt((e,t)=>e!==t?1:0),yU=cn(Il,g6,null,"bool"),xU={kernelName:Il,backendName:"cpu",kernelFunc:yU};function y2(e,t,n,s,r){let a=t.length,o=w.sizeFromShape(t),i=w.computeStrides(t),l=w.computeStrides(r),c=w.getTypedArrayFromDType(n,w.sizeFromShape(r));for(let u=0;u<o;++u){let d=w.indexToLoc(u,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);c[h]=e[u]}return c}function ks(e){let{inputs:t,attrs:n,backend:s}=e,{x:r}=t,{perm:a}=n;Ne(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,c=y2(l,r.shape,r.dtype,a,i);return{dataId:s.write(c,i,r.dtype),shape:i,dtype:r.dtype}}var bU={kernelName:Ho,backendName:"cpu",kernelFunc:ks};function A6(e,t,n,s){let[r,a]=N.computeOutAndReduceShapes(e,s),o=$s(t,"int32"),i=w.makeZerosTypedArray(w.sizeFromShape(r),o),l=w.sizeFromShape(a);for(let c=0;c<i.length;++c){let u=c*l,d=1;for(let p=0;p<l;++p)d*=n[u+p];i[c]=d}return{outVals:i,outShape:r,outDtype:o}}function vU(e){let{inputs:t,backend:n,attrs:s}=e,{x:r}=t,{axis:a,keepDims:o}=s;Ne(r,"prod");let i=r.shape.length,l=w.parseAxisParam(a,r.shape),c=N.getAxesPermutation(l,i),u=l,d=r,p=[];c!=null&&(d=ks({inputs:{x:r},backend:n,attrs:{perm:c}}),p.push(d),u=N.getInnerMostAxes(u.length,i));let h=n.data.get(d.dataId).values,{outVals:f,outShape:m,outDtype:g}=A6(d.shape,d.dtype,h,u),A=m;return o&&(A=N.expandShapeToKeepDim(m,l)),p.forEach(y=>n.disposeIntermediateTensorInfo(y)),n.makeTensorInfo(A,g,f)}var wU={kernelName:Rl,backendName:"cpu",kernelFunc:vU};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 c=1;c<l.length;c++)l[c]=l[c-1]+n;return l}var y6=Da(e=>1/Math.sqrt(e)),kU=Su(Oo,y6),IU={kernelName:Oo,backendName:"cpu",kernelFunc:kU},SU=Da(e=>1/(1+Math.exp(-e))),x6=dt(Mo,e=>1/(1+Math.exp(-e))),CU={kernelName:Mo,backendName:"cpu",kernelFunc:x6};function r0(e,t,n,s,r){let a=En.isSliceContinous(s,t,n),o=w.sizeFromShape(n),i=w.computeStrides(s);if(a){let d=En.computeFlatOffset(t,i);return r==="string"?e.slice(d,d+o):e.subarray(d,d+o)}let l=r==="string"?N.fromUint8ToStringArray(e):e,c=He(s,r,l),u=He(n,r);for(let d=0;d<u.size;++d){let p=u.indexToLoc(d),h=p.map((f,m)=>f+t[m]);u.set(c.get(...h),...p)}return r==="string"?N.fromStringArrayToUint8(u.values):u.values}function vi(e){let{inputs:t,backend:n,attrs:s}=e,{x:r}=t,{begin:a,size:o}=s;Ne(r,"slice");let[i,l]=En.parseSliceParams(r,a,o);En.assertParamsValid(r,i,l);let c=n.data.get(r.dataId).values,u=r0(c,i,l,r.shape,r.dtype);return n.makeTensorInfo(l,r.dtype,u)}var TU={kernelName:Pl,backendName:"cpu",kernelFunc:vi};function b6(e,t,n,s,r,a,o){let i=t[0],l=a[0],c=new Array(l),u=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,c,u]}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;c[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)u[y]=y;return[g,[i,d],A,c,u]}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],S=x[v],T=(v===0?0:f[v-1])+S;x[v]++;for(let _=0;_<d;++_)A[T*d+_]=e[b*d+_];y[T]=s[b],u[b]=T}for(let b=0;b<l;++b)if(x[b]===0){let S=b===0?0:f[b-1];A[S*d+0]=b;for(let T=1;T<d;++T)A[S*d+T]=0;y[S]=o}return[A,[g,d],y,c,u]}}function v6(e,t,n,s,r){let a=w.sizeFromShape(s),o=t[0],i=r.length,l=[],c=1,u=-1;for(let g=0;g<i;++g){let A=r[g];if(A===-1){if(u!==-1)throw new Error(`only one output dimension may be -1, not both ${u} and ${g}`);u=g,l.push(1)}else{if(A<0)throw new Error(`size ${g} must be non-negative, not ${A}`);c*=A,l.push(A)}}if(u!==-1){if(c<=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/c);if(c*g!==a)throw new Error(`Input to reshape is a SparseTensor with ${a}
|
|
dense values, but the requested shape requires a multiple of ${c}. inputShape=${s} outputShape= ${l}`);l[u]=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 b2(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]],c=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*c,y*c);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 S=0;S<c;S++)f[y*c+S]+=e[v*c+S]}if(a)for(let b=0;b<c;b++)f[y*c+b]/=g-m;if(m=g,++g,A=y+1,y=x,g>i)break}return A<d&&f.fill(o,A*c,d*c),[f,p]}var NU=Da(e=>Math.sqrt(e)),EU=dt(zo,e=>Math.sqrt(e)),RU={kernelName:zo,backendName:"cpu",kernelFunc:EU},w6=jt((e,t)=>{let n=e-t;return n*n}),DU=cn(Wo,w6),_U={kernelName:Wo,backendName:"cpu",kernelFunc:DU};function k6(e,t,n,s){let r=He(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 FU=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),c=Math.max(0,i-(r-(o+1))),u=a-(l+c),d=t+(l>0?0:o-i),p=0;p+=l*this.leftPad.length;for(let A=0;A<u;++A)p+=e[d+A].length;p+=c*this.rightPad.length,p+=(l+c+u-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<u-1;++A)g(e[d+A]),g(this.separator);if(u>0){g(e[d+u-1]);for(let A=0;A<c;++A)g(this.separator),g(this.rightPad)}else{for(let A=0;A<c-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 c=t[l]>=i;if(c=c&&t[l]<=n,!c)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],c=0;this.nGramWidths.forEach(u=>{c+=this.getNumNGrams(l,u)}),this.preserveShort&&l>0&&c===0&&(c=1),a[i]=a[i-1]+c}let o=new Array(a[r]);for(let i=0;i<r;++i){let l=t[i],c=a[i];if(this.nGramWidths.forEach(u=>{let d=t[i+1]-t[i],p=this.getNumNGrams(d,u);this.createNGrams(e,l,o,c,p,u),c+=p}),this.preserveShort&&c===a[i]){let u=t[i+1]-t[i];if(u===0)continue;let d=u+2*this.padWidth,p=1;this.createNGrams(e,l,o,c,p,d)}}return[o,a]}};function I6(e,t,n,s,r,a,o,i){return new FU(n,s,r,a,o,i).compute(e,t)}function $U(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 S6(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;$U(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),c=new Array(a),u=[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,c[d]=r[d],++d;return[l,c,u]}function C6(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 T6=jt((e,t)=>e-t),OU=f2((e,t,n,s)=>({real:e-n,imag:t-s})),v2=cn(Vo,T6,OU),PU={kernelName:Vo,backendName:"cpu",kernelFunc:v2};function N6(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=He(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 Ed=(e,t)=>{let n=t.value-e.value;return n===0?e.index-t.index:n};function E6(e,t,n=0,s=e.length-1){for(;s>n;){if(s-n>600){let i=s-n+1,l=t-n+1,c=Math.log(i),u=.5*Math.exp(2*c/3),d=.5*Math.sqrt(c*u*(i-u)/i)*Math.sign(l-i/2),p=Math.max(n,Math.floor(t-l*u/i+d)),h=Math.min(s,Math.floor(t+(i-l)*u/i+d));E6(e,t,p,h)}let r=e[t],a=n,o=s;for(w.swap(e,n,t),Ed(e[s],r)>0&&w.swap(e,n,s);a<o;){for(w.swap(e,a,o),a++,o--;Ed(e[a],r)<0;)a=a+1;for(;Ed(e[o],r)>0;)o=o-1}Ed(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 R6(e,t,n,s,r){let a=t[t.length-1],[o,i]=[e.length/a,a],l=w.getTypedArrayFromDType(n,o*s),c=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&&(E6(f,s),f=f.slice(0,s)),r&&f.sort(Ed);let m=d*s,g=l.subarray(m,m+s),A=c.subarray(m,m+s);for(let y=0;y<s;y++)g[y]=f[y].value,A[y]=f[y].index}let u=t.slice();return u[u.length-1]=s,[He(u,n,l),He(u,"int32",c)]}function D6(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 Zt(a,s,e),c=[],u=a[0]===1&&a[2]===1;for(let f=0;f<n[r];f++){let m;if(u)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,c.push(f)}}let d=a.slice();d[1]=Object.keys(o).length;let p=new Zt(d,s);c.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}}tu("cpu",()=>new h2,1);var _6=dt(lo,e=>e>=0?e:Math.exp(e)-1),MU={kernelName:lo,backendName:"cpu",kernelFunc:_6};function F6(e){let{inputs:t,backend:n,attrs:s}=e,{x:r}=t,{alpha:a}=s;Ne([r],"leakyRelu");let o=w.sizeFromShape(r.shape),i=n.data.get(r.dataId).values,l=w.getTypedArrayFromDType("float32",o);for(let c=0;c<i.length;c++)l[c]=i[c]<0?a*i[c]:i[c];return n.makeTensorInfo(r.shape,"float32",l)}var zU={kernelName:go,backendName:"cpu",kernelFunc:F6},LU=jt((e,t)=>e<0?t*e:e);function $6(e){let{inputs:t,backend:n}=e,{x:s,alpha:r}=t;Ne([s,r],"prelu");let a=n.data.get(s.dataId).values,o=n.data.get(r.dataId).values,[i,l]=LU(s.shape,r.shape,a,o,"float32");return n.makeTensorInfo(l,"float32",i)}var BU={kernelName:Eo,backendName:"cpu",kernelFunc:$6},O6=dt(Ro,e=>Math.max(0,e)),WU={kernelName:Ro,backendName:"cpu",kernelFunc:O6},P6=dt(_o,e=>Math.min(Math.max(0,e),6)),VU={kernelName:_o,backendName:"cpu",kernelFunc:P6};function w2(e,t,n,s,r){if(n==="linear")return Cr({inputs:{x:t},backend:e});if(n==="relu")return O6({inputs:{x:t},backend:e});if(n==="elu")return _6({inputs:{x:t},backend:e});if(n==="relu6")return P6({inputs:{x:t},backend:e});if(n==="prelu")return $6({inputs:{x:t,alpha:s},backend:e});if(n==="leakyrelu")return F6({inputs:{x:t},backend:e,attrs:{alpha:r}});if(n==="sigmoid")return x6({inputs:{x:t},backend:e});throw new Error(`Activation ${n} has not been implemented for the CPU backend.`)}function vt(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 c=n.data.get(r.dataId);if(c.complexTensorInfos!=null){let u=c.complexTensorInfos.real,d=c.complexTensorInfos.imag;u.shape=i,d.shape=i}return{dataId:r.dataId,shape:i,dtype:r.dtype}}var UU={kernelName:_l,backendName:"cpu",kernelFunc:vt};function M6(e){let{inputs:t,backend:n,attrs:s}=e,{a:r,b:a}=t,{transposeA:o,transposeB:i}=s;Ne([r,a],"matMul");let l=r.shape.length,c=a.shape.length,u=o?r.shape[l-2]:r.shape[l-1],d=i?a.shape[c-1]:a.shape[c-2],p=o?r.shape[l-1]:r.shape[l-2],h=i?a.shape[c-2]:a.shape[c-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&&c>=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(u===d,()=>`Error in matMul: inner shapes (${u}) and (${d}) of Tensors with shapes ${r.shape} and ${a.shape} and transposeA=${o} and transposeB=${i} must match.`);let v=o?[g,u,p]:[g,p,u],S=i?[A,h,d]:[A,d,h],T=vt({inputs:{x:r},backend:n,attrs:{shape:v}}),_=vt({inputs:{x:a},backend:n,attrs:{shape:S}}),O=o?T.shape[1]:T.shape[2],P=o?T.shape[2]:T.shape[1],D=i?_.shape[1]:_.shape[2],F=Math.max(g,A),C=n.data.get(T.dataId).values,M=n.data.get(_.dataId).values,U=w.computeStrides(T.shape),j=w.computeStrides(_.shape),[q,X,te]=o?[U[0],1,U[1]]:[U[0],U[1],1],[ne,se,oe]=i?[1,j[1],j[0]]:[j[1],1,j[0]],ae=P*D,re=He([F,P,D],T.dtype),ce=re.values,ge=n.blockSize;for(let ve=0;ve<F;ve++)for(let Ce=0;Ce<P;Ce+=ge)for(let Re=0;Re<D;Re+=ge)for(let Pe=0;Pe<O;Pe+=ge){let Be=Math.min(Ce+ge,P),Ue=Math.min(Re+ge,D),et=Math.min(Pe+ge,O);for(let ut=Ce;ut<Be;ut++)for(let at=Re;at<Ue;at++){let ot=0;for(let pt=Pe;pt<et;pt++){let ft=Math.min(ve,g-1)*q,kt=Math.min(ve,A-1)*oe,Rt=C[ft+ut*X+pt*te],Wn=M[pt*ne+at*se+kt];ot+=Rt*Wn}ce[ve*ae+(ut*D+at)]+=ot}}return n.disposeIntermediateTensorInfo(T),n.disposeIntermediateTensorInfo(_),n.makeTensorInfo(b,re.dtype,re.values)}var GU={kernelName:Ja,backendName:"cpu",kernelFunc:M6};function HU(e){let{inputs:t,backend:n,attrs:s}=e,{a:r,b:a,bias:o,preluActivationWeights:i}=t,{transposeA:l,transposeB:c,activation:u,leakyreluAlpha:d}=s,p,h,f,m=[];p=M6({inputs:{a:r,b:a},attrs:{transposeA:l,transposeB:c},backend:n}),o&&(h=Nd({inputs:{a:p,b:o},backend:n}),m.push(p),p=h),u&&(f=w2(n,p,u,i,d),m.push(p),p=f);for(let A of m)n.disposeIntermediateTensorInfo(A);return p}var jU={kernelName:jo,backendName:"cpu",kernelFunc:HU},qU=dt(Xi,e=>Math.acos(e)),XU={kernelName:Xi,backendName:"cpu",kernelFunc:qU},KU=dt(Ki,e=>Math.acosh(e)),ZU={kernelName:Ki,backendName:"cpu",kernelFunc:KU};function YU(e){let{inputs:t,backend:n}=e,s=t;Ne(t,"addN");let r=s.map(i=>n.data.get(i.dataId).values),a=He(s[0].shape,s[0].dtype),o=a.values;for(let i=0;i<s.length;i++){let l=r[i];for(let c=0;c<o.length;c++)o[c]+=l[c]}return n.makeTensorInfo(a.shape,a.dtype,a.values)}var JU={kernelName:Ka,backendName:"cpu",kernelFunc:YU};function QU(e){let{inputs:t,backend:n,attrs:s}=e,{x:r}=t,{axis:a,keepDims:o}=s;Ne(r,"all");let i=w.parseAxisParam(a,r.shape),l=i,c=N.getAxesPermutation(l,r.shape.length),u=r;c!=null&&(u=ks({inputs:{x:r},backend:n,attrs:{perm:c}}),l=N.getInnerMostAxes(l.length,r.shape.length)),N.assertAxesAreInnerMostDims("all",l,u.shape.length);let[d,p]=N.computeOutAndReduceShapes(u.shape,l),h=w.sizeFromShape(p),f=w.makeZerosTypedArray(w.sizeFromShape(d),u.dtype),m=n.data.get(u.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}c!=null&&n.disposeIntermediateTensorInfo(u);let g=n.makeTensorInfo(d,u.dtype,f);if(o){let A=N.expandShapeToKeepDim(d,i),y=vt({inputs:{x:g},backend:n,attrs:{shape:A}});return n.disposeIntermediateTensorInfo(g),y}return g}var eG={kernelName:Zi,backendName:"cpu",kernelFunc:QU};function tG(e){let{inputs:t,backend:n,attrs:s}=e,{x:r}=t,{axis:a,keepDims:o}=s;Ne(r,"any");let i=w.parseAxisParam(a,r.shape),l=i,c=N.getAxesPermutation(l,r.shape.length),u=r;c!=null&&(u=ks({inputs:{x:r},backend:n,attrs:{perm:c}}),l=N.getInnerMostAxes(l.length,r.shape.length)),N.assertAxesAreInnerMostDims("any",l,u.shape.length);let[d,p]=N.computeOutAndReduceShapes(u.shape,l),h=w.sizeFromShape(p),f=w.makeZerosTypedArray(w.sizeFromShape(d),u.dtype),m=n.data.get(u.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}c!=null&&n.disposeIntermediateTensorInfo(u);let g=n.makeTensorInfo(d,u.dtype,f);if(o){let A=N.expandShapeToKeepDim(d,i),y=vt({inputs:{x:g},backend:n,attrs:{shape:A}});return n.disposeIntermediateTensorInfo(g),y}return g}var nG={kernelName:Yi,backendName:"cpu",kernelFunc:tG};function sG(e){let{inputs:t,backend:n,attrs:s}=e,{x:r}=t,{axis:a}=s;Ne(r,"argMax");let o=w.parseAxisParam(a,r.shape),i=N.getAxesPermutation(o,r.shape.length),l=r,c=[];i!=null&&(l=ks({inputs:{x:r},backend:n,attrs:{perm:i}}),c.push(l),o=N.getInnerMostAxes(o.length,l.shape.length)),o=[o[0]],N.assertAxesAreInnerMostDims("argMax",o,l.shape.length);let[u,d]=N.computeOutAndReduceShapes(l.shape,o),p=w.sizeFromShape(u),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 c.forEach(g=>n.disposeIntermediateTensorInfo(g)),n.makeTensorInfo(u,"int32",h)}var rG={kernelName:Za,backendName:"cpu",kernelFunc:sG};function aG(e){let{inputs:t,backend:n,attrs:s}=e,{x:r}=t,{axis:a}=s;Ne(r,"argMin");let o=w.parseAxisParam(a,r.shape),i=N.getAxesPermutation(o,r.shape.length),l=r,c=[];i!=null&&(l=ks({inputs:{x:r},backend:n,attrs:{perm:i}}),c.push(l),o=N.getInnerMostAxes(o.length,l.shape.length)),o=[o[0]],N.assertAxesAreInnerMostDims("argMin",o,l.shape.length);let[u,d]=N.computeOutAndReduceShapes(l.shape,o),p=w.sizeFromShape(u),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 c.forEach(g=>n.disposeIntermediateTensorInfo(g)),n.makeTensorInfo(u,"int32",h)}var oG={kernelName:gc,backendName:"cpu",kernelFunc:aG},iG=dt(Ji,e=>Math.asin(e)),lG={kernelName:Ji,backendName:"cpu",kernelFunc:iG},uG=dt(Qi,e=>Math.asinh(e)),cG={kernelName:Qi,backendName:"cpu",kernelFunc:uG},dG=dt(el,e=>Math.atan(e)),pG={kernelName:el,backendName:"cpu",kernelFunc:dG},hG=jt((e,t)=>Math.atan2(e,t)),fG=cn(nl,hG),mG={kernelName:nl,backendName:"cpu",kernelFunc:fG},gG=dt(tl,e=>Math.atanh(e)),AG={kernelName:tl,backendName:"cpu",kernelFunc:gG};function k2(e,t,n,s,r,a){let o=r.strideHeight,i=r.strideWidth,l=r.dilationHeight,c=r.dilationWidth,u=r.effectiveFilterHeight,d=r.effectiveFilterWidth,p=r.padInfo.top,h=r.padInfo.left,f=a==="max"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,m=He(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,S=b*s[0];for(let T=0;T<r.inChannels;++T)for(let _=0;_<r.outHeight;++_){let O=_*o-p,P=Math.max(0,O),D=Math.min(r.inHeight,u+O),F=v+_*y;for(let C=0;C<r.outWidth;++C){let M=C*i-h,U=Math.max(0,M),j=Math.min(r.inWidth,d+M),q=f,X=0,te=0;for(let se=P;se<D;se+=l){let oe=S+se*s[1];for(let ae=U;ae<j;ae+=c){let re=oe+ae*s[2],ce=e[re+T];a==="max"&&ce>q?q=ce:a==="avg"&&(X+=ce,te++)}if(isNaN(q))break}let ne=F+C*x+T;g[ne]=a==="avg"?X/te:q}}}return m}function z6(e,t,n,s,r=!1,a=!1){let o=He(s.outShape,"int32"),i=s.strideHeight,l=s.strideWidth,c=s.dilationHeight,u=s.dilationWidth,d=s.effectiveFilterHeight,p=s.effectiveFilterWidth,h=s.padInfo.top,f=s.padInfo.left,m=He(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+=c;let v=Math.min(s.inHeight,d+x);for(let S=0;S<s.outWidth;++S){let T=S*l-f,_=T;for(;_<0;)_+=u;let O=Math.min(s.inWidth,p+T),P=Number.NEGATIVE_INFINITY,D=-1;for(let F=b;F<v;F+=c){let C=F-x;for(let M=_;M<O;M+=u){let U=M-T,j=m.get(g,F,M,A);j>P&&(P=j,r?D=a?((g*s.inHeight+F)*s.inWidth+M)*s.inChannels+A:(F*s.inWidth+M)*s.inChannels+A:D=C*p+U)}}o.set(D,g,y,S,A)}}return o}function L6(e,t,n,s,r,a){let o=r.strideDepth,i=r.strideHeight,l=r.strideWidth,c=r.dilationDepth,u=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=He(r.outShape,n),b=x.values,v=r.outShape[1]*r.outShape[2]*r.outShape[3]*r.outShape[4],S=r.outShape[2]*r.outShape[3]*r.outShape[4],T=r.outShape[3]*r.outShape[4],_=r.outShape[4];for(let O=0;O<r.batchSize;++O){let P=O*v,D=O*s[0];for(let F=0;F<r.inChannels;++F)for(let C=0;C<r.outDepth;++C){let M=C*o-m,U=M;for(;U<0;)U+=c;let j=Math.min(r.inDepth,p+M),q=P+C*S;for(let X=0;X<r.outHeight;++X){let te=X*i-g,ne=te;for(;ne<0;)ne+=u;let se=Math.min(r.inHeight,h+te),oe=q+X*T;for(let ae=0;ae<r.outWidth;++ae){let re=ae*l-A,ce=re;for(;ce<0;)ce+=d;let ge=Math.min(r.inWidth,f+re),ve=oe+ae*_,Ce=y,Re=0,Pe=0;for(let Ue=U;Ue<j;Ue+=c){let et=D+Ue*s[1];for(let ut=ne;ut<se;ut+=u){let at=et+ut*s[2];for(let ot=ce;ot<ge;ot+=d){let pt=at+ot*s[3],ft=e[pt+F];if(a==="max"&&ft>Ce?Ce=ft:a==="avg"&&(Re+=ft,Pe++),isNaN(Ce))break}if(isNaN(Ce))break}if(isNaN(Ce))break}let Be=ve+F;b[Be]=a==="avg"?Re/Pe:Ce}}}}return x}function yG(e,t){let n=He(t.outShape,"int32"),s=t.strideDepth,r=t.strideHeight,a=t.strideWidth,o=t.dilationDepth,i=t.dilationHeight,l=t.dilationWidth,c=t.effectiveFilterDepth,u=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,c+y);for(let v=0;v<t.outHeight;++v){let S=v*r-h,T=S;for(;T<0;)T+=i;let _=Math.min(t.inHeight,u+S);for(let O=0;O<t.outWidth;++O){let P=O*a-f,D=P;for(;D<0;)D+=l;let F=Math.min(t.inWidth,d+P),C=Number.NEGATIVE_INFINITY,M=-1;for(let U=x;U<b;U+=o){let j=U-y;for(let q=T;q<_;q+=i){let X=q-S;for(let te=D;te<F;te+=l){let ne=te-P,se=e.get(m,U,q,te,g);se>=C&&(C=se,M=j*u*d+X*u+ne)}}}n.set(M,m,A,v,O,g)}}}return n}function xG(e){let{inputs:t,backend:n,attrs:s}=e,{x:r}=t;Ne(r,"avgPool");let{filterSize:a,strides:o,pad:i,dimRoundingMode:l}=s,c=1;w.assert(N.eitherStridesOrDilationsAreOne(o,c),()=>`Error in avgPool: Either strides or dilations must be 1. Got strides ${o} and dilations '${c}'`);let u=N.computePool2DInfo(r.shape,a,o,c,i,l),d;if(u.filterWidth===1&&u.filterHeight===1&&w.arraysEqual(u.inShape,u.outShape))d=Cr({inputs:{x:r},backend:n});else{let p=n.data.get(r.dataId).values,h=w.computeStrides(r.shape),f=k2(p,r.shape,r.dtype,h,u,"avg");d=n.makeTensorInfo(u.outShape,r.dtype,f.values)}return d}var bG={kernelName:Ya,backendName:"cpu",kernelFunc:xG};function vG(e){let{inputs:t,backend:n,attrs:s}=e,{x:r}=t,{filterSize:a,strides:o,pad:i,dimRoundingMode:l,dataFormat:c}=s;Ne(r,"avgPool3d");let u=N.computePool3DInfo(r.shape,a,o,1,i,l,c),d=n.data.get(r.dataId).values,p=L6(d,r.shape,r.dtype,w.computeStrides(r.shape),u,"avg");return n.makeTensorInfo(p.shape,"float32",p.values)}var wG={kernelName:Ac,backendName:"cpu",kernelFunc:vG};function kG(e){let{inputs:t,backend:n,attrs:s}=e,{dy:r,input:a}=t,{filterSize:o,strides:i,pad:l,dimRoundingMode:c}=s;Ne([r,a],"avgPool3DGrad");let u=N.computePool3DInfo(a.shape,o,i,1,l,c),d=u.strideDepth,p=u.strideHeight,h=u.strideWidth,f=u.filterDepth,m=u.filterHeight,g=u.filterWidth,A=u.dilationDepth,y=u.dilationHeight,x=u.dilationWidth,b=u.effectiveFilterDepth,v=u.effectiveFilterHeight,S=u.effectiveFilterWidth,T=b-1-u.padInfo.front,_=S-1-u.padInfo.left,O=v-1-u.padInfo.top,P=He(a.shape,"float32"),D=1/(f*m*g),F=n.bufferSync(r);for(let C=0;C<u.batchSize;++C)for(let M=0;M<u.inChannels;++M)for(let U=0;U<u.inDepth;++U)for(let j=0;j<u.inHeight;++j)for(let q=0;q<u.inWidth;++q){let X=U-T,te=j-O,ne=q-_,se=0;for(let oe=0;oe<b;oe+=A){let ae=(X+oe)/d;if(!(ae<0||ae>=u.outDepth||Math.floor(ae)!==ae))for(let re=0;re<v;re+=y){let ce=(te+re)/p;if(!(ce<0||ce>=u.outHeight||Math.floor(ce)!==ce))for(let ge=0;ge<S;ge+=x){let ve=(ne+ge)/h;if(ve<0||ve>=u.outWidth||Math.floor(ve)!==ve)continue;se+=F.get(C,ae,ce,ve,M)}}}P.set(se*D,C,U,j,q,M)}return n.makeTensorInfo(P.shape,P.dtype,P.values)}var IG={kernelName:Bp,backendName:"cpu",kernelFunc:kG};function SG(e){let{inputs:t,backend:n,attrs:s}=e,{dy:r,input:a}=t,o=a;Ne([r,a],"avgPoolGrad");let{filterSize:i,strides:l,pad:c}=s,u=N.computePool2DInfo(o.shape,i,l,1,c),d=u.strideHeight,p=u.strideWidth,h=u.filterHeight,f=u.filterWidth,m=u.dilationHeight,g=u.dilationWidth,A=u.effectiveFilterHeight,y=u.effectiveFilterWidth,x=y-1-u.padInfo.left,b=A-1-u.padInfo.top,v=He(o.shape,"float32"),S=1/(h*f),T=n.data.get(r.dataId).values,_=He(r.shape,"float32",T);for(let O=0;O<u.batchSize;++O)for(let P=0;P<u.inChannels;++P)for(let D=0;D<u.inHeight;++D)for(let F=0;F<u.inWidth;++F){let C=D-b,M=F-x,U=0;for(let j=0;j<A;j+=m){let q=(C+j)/d;if(!(q<0||q>=u.outHeight||Math.floor(q)!==q))for(let X=0;X<y;X+=g){let te=(M+X)/p;if(te<0||te>=u.outWidth||Math.floor(te)!==te)continue;U+=_.get(O,q,te,P)}}v.set(U*S,O,D,F,P)}return n.makeTensorInfo(v.shape,v.dtype,v.values)}var CG={kernelName:Lp,backendName:"cpu",kernelFunc:SG};function TG(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."),Ne([r,i,l,a,o],"batchNorm");let{varianceEpsilon:c}=s;c==null&&(c=.001);let u=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(u.length),g=f.length,A=h.length,y=p.length,x=d.length,b=0,v=0,S=0,T=0;for(let _=0;_<u.length;++_)m[_]=f[b++]+(u[_]-d[v++])*h[S++]/Math.sqrt(p[T++]+c),b>=g&&(b=0),v>=x&&(v=0),S>=A&&(S=0),T>=y&&(T=0);return n.makeTensorInfo(r.shape,r.dtype,m)}var NG={kernelName:ho,backendName:"cpu",kernelFunc:TG};function EG(e){let{inputs:t,backend:n,attrs:s}=e,{x:r}=t,{blockShape:a,crops:o}=s;Ne([r],"batchToSpaceND");let i=a.reduce((A,y)=>A*y),l=N.getReshaped(r.shape,a,i),c=N.getPermuted(l.length,a.length),u=N.getReshapedPermuted(r.shape,a,i),d=N.getSliceBeginCoords(o,a.length),p=N.getSliceSize(u,o,a.length),h=vt({inputs:{x:r},backend:n,attrs:{shape:l}}),f=ks({inputs:{x:h},backend:n,attrs:{perm:c}}),m=vt({inputs:{x:f},backend:n,attrs:{shape:u}}),g=vi({inputs:{x:m},backend:n,attrs:{begin:d,size:p}});return n.disposeIntermediateTensorInfo(h),n.disposeIntermediateTensorInfo(f),n.disposeIntermediateTensorInfo(m),g}var RG={kernelName:sl,backendName:"cpu",kernelFunc:EG};function DG(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,c=m2(i,l,a.dtype,a.shape,o);return n.makeTensorInfo([o],a.dtype,c)}var _G={kernelName:Wp,backendName:"cpu",kernelFunc:DG};function FG(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=N.assertAndGetBroadcastShape(Array.from(a),Array.from(o));return n.makeTensorInfo([i.length],"int32",Int32Array.from(i))}var $G={kernelName:Vp,backendName:"cpu",kernelFunc:FG},OG=dt(ua,(e,t)=>{let n=t;return e>n.clipValueMax?n.clipValueMax:e<n.clipValueMin?n.clipValueMin:e}),PG={kernelName:ua,backendName:"cpu",kernelFunc:OG},MG=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 c=0;c<i.length;c++){let u=i[c],d=l[c];s[c]=Math.hypot(u,d)}return n.makeOutput(s,t.shape,"float32")},zG={kernelName:yc,backendName:"cpu",kernelFunc:MG};function Cu(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 LG={kernelName:sh,backendName:"cpu",kernelFunc:Cu};function Tu(e){let{inputs:t,backend:n,attrs:s}=e,{axis:r}=s,a=w.parseAxisParam(r,t[0].shape)[0],o=N.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 Cr({inputs:{x:i[0]},backend:n});let l=i.map(m=>m.shape);if(N.assertParamsConsistent(l,a),i[0].dtype==="complex64"){let m=i.map(b=>bi({inputs:{input:b},backend:n})),g=i.map(b=>Cu({inputs:{input:b},backend:n})),A=Tu({inputs:m,backend:n,attrs:{axis:a}}),y=Tu({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 c=i.map(m=>{let g=w.sizeFromShape(m.shape.slice(a));return vt({inputs:{x:m},backend:n,attrs:{shape:[-1,g]}})}),u=c.map(m=>({vals:n.data.get(m.dataId).values,shape:m.shape}));o=N.computeOutShape(c.map(m=>m.shape),1);let d=c[0].shape[0]===1,p=g2(u,o,t[0].dtype,d),h=N.computeOutShape(i.map(m=>m.shape),a),f=n.makeTensorInfo(h,t[0].dtype,p);return c.forEach(m=>n.disposeIntermediateTensorInfo(m)),f}var BG={kernelName:rl,backendName:"cpu",kernelFunc:Tu};function B6(e){let{inputs:t,backend:n,attrs:s}=e,{x:r,filter:a}=t,{strides:o,pad:i,dataFormat:l,dilations:c,dimRoundingMode:u}=s;Ne([r,a],"conv2d");let d=N.convertConv2DDataFormat(l),p=N.computeConv2DInfo(r.shape,a.shape,o,c,i,u,!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 Zt(p.outShape,r.dtype),v=w.computeStrides(r.shape),S=w.computeStrides(a.shape),T=v[0],_=x?v[1]:v[2],O=x?v[2]:1,P=x?1:v[1],D=b.strides[0],F=x?b.strides[1]:b.strides[2],C=x?b.strides[2]:1,M=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*T,ne=X*D;for(let se=0;se<p.outHeight;++se){let oe=ne+se*F,ae=se*p.strideHeight-y;for(let re=0;re<h;++re){let ce=ae+re*m;if(ce<0||ce>=p.inHeight)continue;let ge=re*S[0],ve=te+ce*_;for(let Ce=0;Ce<p.outWidth;++Ce){let Re=oe+Ce*C,Pe=Ce*p.strideWidth-A;for(let Be=0;Be<f;++Be){let Ue=Pe+Be*g;if(Ue<0||Ue>=p.inWidth)continue;let et=ge+Be*S[1],ut=ve+Ue*O,at=et;for(let ot=0;ot<p.inChannels;++ot){let pt=U[ut+ot*P];for(let ft=0;ft<p.outChannels;++ft)q[Re+ft*M]+=pt*j[at+ft];at+=p.outChannels}}}}}}return n.makeTensorInfo(b.shape,b.dtype,q)}var WG={kernelName:to,backendName:"cpu",kernelFunc:B6};function VG(e){let{inputs:t,backend:n,attrs:s}=e,{x:r,dy:a}=t,{strides:o,pad:i,dataFormat:l,dimRoundingMode:c,filterShape:u}=s;Ne([r,a],"conv2dBackpropFilter");let d=N.convertConv2DDataFormat(l),p=N.computeConv2DInfo(r.shape,u,o,1,i,c,!1,d),{strideHeight:h,strideWidth:f,filterHeight:m,filterWidth:g}=p,A=p.dataFormat==="channelsLast",y=new Zt(p.filterShape,"float32"),x=p.padInfo.left,b=p.padInfo.top,v=n.data.get(r.dataId).values,S=n.data.get(a.dataId).values,T=new Zt(r.shape,r.dtype,v),_=new Zt(a.shape,a.dtype,S);for(let O=0;O<m;++O){let P=Math.max(0,Math.ceil((b-O)/h)),D=Math.min(p.outHeight,(p.inHeight+b-O)/h);for(let F=0;F<g;++F){let C=Math.max(0,Math.ceil((x-F)/f)),M=Math.min(p.outWidth,(p.inWidth+x-F)/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=P;te<D;++te){let ne=O+te*h-b;for(let se=C;se<M;++se){let oe=F+se*f-x;A?q+=T.get(X,ne,oe,U)*_.get(X,te,se,j):q+=T.get(X,U,ne,oe)*_.get(X,j,te,se)}}y.set(q,O,F,U,j)}}}return n.makeTensorInfo(y.shape,y.dtype,y.values)}var UG={kernelName:Gp,backendName:"cpu",kernelFunc:VG};function GG(e){let{inputs:t,backend:n,attrs:s}=e,{dy:r,filter:a}=t,{inputShape:o,strides:i,pad:l,dataFormat:c,dimRoundingMode:u}=s;Ne([r,a],"conv2dBackpropInput");let d=w.computeStrides(a.shape),p=w.computeStrides(r.shape),h=N.convertConv2DDataFormat(c),f=N.computeConv2DInfo(o,a.shape,i,1,l,u,!1,h),m=new Zt(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:S,filterHeight:T,filterWidth:_,inChannels:O,inHeight:P,inWidth:D,outChannels:F,outHeight:C,outWidth:M,strideHeight:U,strideWidth:j}=f;h=f.dataFormat;let q=T-1-f.padInfo.top,X=_-1-f.padInfo.left,te=h==="channelsLast",ne=m.strides[0],se=te?m.strides[1]:m.strides[2],oe=te?m.strides[2]:1,ae=te?1:m.strides[1],re=p[0],ce=te?p[1]:p[2],ge=te?p[2]:1,ve=te?1:p[1];for(let Ce=0;Ce<S;++Ce)for(let Re=0;Re<O;++Re)for(let Pe=0;Pe<P;++Pe){let Be=Pe-q,Ue=Math.max(0,Math.ceil(Be/U)),et=Math.min(C,(T+Be)/U);for(let ut=0;ut<D;++ut){let at=ut-X,ot=Math.max(0,Math.ceil(at/j)),pt=Math.min(M,(_+at)/j),ft=0;for(let Rt=Ue;Rt<et;++Rt){let Wn=Rt*U-Be;for(let pn=ot;pn<pt;++pn){let Gs=pn*j-at,Sn=re*Ce+ce*Rt+ge*pn,Qn=x*(T-1-Wn)+b*(_-1-Gs)+v*Re;for(let Rs=0;Rs<F;++Rs){let As=A[Sn+ve*Rs],hn=y[Qn+Rs];ft+=As*hn}}}let kt=ne*Ce+se*Pe+oe*ut+ae*Re;g[kt]=ft}}return n.makeTensorInfo(m.shape,m.dtype,m.values)}var HG={kernelName:no,backendName:"cpu",kernelFunc:GG};function jG(e){let{inputs:t,backend:n,attrs:s}=e,{x:r,filter:a}=t,{strides:o,pad:i,dilations:l}=s;Ne([r,a],"conv3d");let c=N.computeConv3DInfo(r.shape,a.shape,o,l,i),{filterDepth:u,filterHeight:d,filterWidth:p,dilationDepth:h,dilationHeight:f,dilationWidth:m,padInfo:g}=c,A=g.front,y=g.left,x=g.top,b=new Zt(c.outShape,r.dtype),v=n.data.get(r.dataId).values,S=n.data.get(a.dataId).values,T=b.values,_=w.computeStrides(r.shape),O=w.computeStrides(a.shape);for(let P=0;P<c.batchSize;++P){let D=P*_[0],F=P*b.strides[0];for(let C=0;C<c.outDepth;++C){let M=F+C*b.strides[1],U=C*c.strideDepth-A;for(let j=0;j<u;++j){let q=U+j*h;if(q<0||q>=c.inDepth)continue;let X=j*O[0],te=D+q*_[1];for(let ne=0;ne<c.outHeight;++ne){let se=M+ne*b.strides[2],oe=ne*c.strideHeight-x;for(let ae=0;ae<d;++ae){let re=oe+ae*f;if(re<0||re>=c.inHeight)continue;let ce=X+ae*O[1],ge=te+re*_[2];for(let ve=0;ve<c.outWidth;++ve){let Ce=se+ve*c.outChannels,Re=ve*c.strideWidth-y;for(let Pe=0;Pe<p;++Pe){let Be=Re+Pe*m;if(Be<0||Be>=c.inWidth)continue;let Ue=ce+Pe*O[2],et=ge+Be*c.inChannels,ut=Ue;for(let at=0;at<c.inChannels;++at){let ot=v[et+at];for(let pt=0;pt<c.outChannels;++pt)T[Ce+pt]+=ot*S[ut+pt];ut+=c.outChannels}}}}}}}}return n.makeTensorInfo(b.shape,b.dtype,b.values)}var qG={kernelName:xc,backendName:"cpu",kernelFunc:jG};function XG(e){let{inputs:t,backend:n,attrs:s}=e,{x:r,dy:a}=t,{strides:o,pad:i,filterShape:l}=s;Ne([r,a],"conv3dBackpropFilterV2");let c=w.computeStrides(r.shape),u=w.computeStrides(a.shape),d=N.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 Zt(d.filterShape,"float32"),x=y.values,[b,v,S,T]=y.strides,_=n.data.get(a.dataId).values,[O,P,D,F]=u,C=n.data.get(r.dataId).values,[M,U,j,q]=c,X=d.padInfo.front,te=d.padInfo.left,ne=d.padInfo.top;for(let se=0;se<m;++se){let oe=Math.max(0,Math.ceil((X-se)/p)),ae=Math.min(d.outDepth,(d.inDepth+X-se)/p),re=se*b;for(let ce=0;ce<g;++ce){let ge=Math.max(0,Math.ceil((ne-ce)/h)),ve=Math.min(d.outHeight,(d.inHeight+ne-ce)/h),Ce=ce*v+re;for(let Re=0;Re<A;++Re){let Pe=Math.max(0,Math.ceil((te-Re)/f)),Be=Math.min(d.outWidth,(d.inWidth+te-Re)/f),Ue=Re*S+Ce;for(let et=0;et<d.inChannels;++et){let ut=et*T+Ue;for(let at=0;at<d.outChannels;++at){let ot=0;for(let pt=0;pt<d.batchSize;++pt){let ft=pt*M,kt=pt*O;for(let Rt=oe;Rt<ae;++Rt){let pn=(se+Rt*p-X)*U+ft,Gs=Rt*P+kt;for(let Sn=ge;Sn<ve;++Sn){let Rs=(ce+Sn*h-ne)*j+pn,As=Sn*D+Gs;for(let hn=Pe;hn<Be;++hn){let vn=(Re+hn*f-te)*q+Rs,cr=hn*F+As;ot+=C[vn+et]*_[cr+at]}}}}x[ut+at]=ot}}}}}return n.makeTensorInfo(y.shape,y.dtype,y.values)}var KG={kernelName:Hp,backendName:"cpu",kernelFunc:XG};function ZG(e){let{inputs:t,backend:n,attrs:s}=e,{dy:r,filter:a}=t,{pad:o,strides:i,inputShape:l}=s;Ne([r],"conv3dBackpropInputV2");let c=w.computeStrides(r.shape),u=w.computeStrides(a.shape),d=N.computeConv3DInfo(l,a.shape,i,1,o),p=new Zt(d.inShape,"float32"),h=p.values,[f,m,g,A]=p.strides,y=n.data.get(r.dataId).values,[x,b,v,S]=c,T=n.data.get(a.dataId).values,[_,O,P,D]=u,{batchSize:F,filterDepth:C,filterHeight:M,filterWidth:U,inChannels:j,inDepth:q,inHeight:X,inWidth:te,outChannels:ne,outDepth:se,outHeight:oe,outWidth:ae,strideDepth:re,strideHeight:ce,strideWidth:ge}=d,ve=C-1-d.padInfo.front,Ce=M-1-d.padInfo.top,Re=U-1-d.padInfo.left;for(let Pe=0;Pe<F;++Pe)for(let Be=0;Be<j;++Be)for(let Ue=0;Ue<q;++Ue){let et=Ue-ve,ut=Math.max(0,Math.ceil(et/re)),at=Math.min(se,(C+et)/re);for(let ot=0;ot<X;++ot){let pt=ot-Ce,ft=Math.max(0,Math.ceil(pt/ce)),kt=Math.min(oe,(M+pt)/ce);for(let Rt=0;Rt<te;++Rt){let Wn=Rt-Re,pn=Math.max(0,Math.ceil(Wn/ge)),Gs=Math.min(ae,(U+Wn)/ge),Sn=0;for(let Qn=ut;Qn<at;++Qn){let Rs=Qn*re-et;for(let As=ft;As<kt;++As){let hn=As*ce-pt;for(let ur=pn;ur<Gs;++ur){let vn=ur*ge-Wn,cr=x*Pe+b*Qn+v*As+S*ur,dr=_*(C-1-Rs)+O*(M-1-hn)+P*(U-1-vn)+D*Be;for(let Yr=0;Yr<ne;++Yr){let Zu=y[cr+Yr],Hs=T[dr+Yr];Sn+=Zu*Hs}}}}h[f*Pe+m*Ue+g*ot+A*Rt+Be]=Sn}}}return n.makeTensorInfo(p.shape,p.dtype,p.values)}var YG={kernelName:jp,backendName:"cpu",kernelFunc:ZG},JG=dt(so,e=>Math.cos(e)),QG={kernelName:so,backendName:"cpu",kernelFunc:JG},eH=dt(ro,e=>Math.cosh(e)),tH={kernelName:ro,backendName:"cpu",kernelFunc:eH};function nH(e){let{inputs:t,backend:n,attrs:s}=e,{image:r,boxes:a,boxInd:o}=t,{cropSize:i,method:l,extrapolationValue:c}=s,[u,d,p,h]=r.shape,f=a.shape[0],[m,g]=i,A=He([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),S=w.computeStrides(A.shape);for(let T=0;T<f;T++){let _=T*4,O=y[_],P=y[_+1],D=y[_+2],F=y[_+3],C=x[T];if(C>=u)continue;let M=m>1?(D-O)*(d-1)/(m-1):0,U=g>1?(F-P)*(p-1)/(g-1):0;for(let j=0;j<m;j++){let q=m>1?O*(d-1)+j*M:.5*(O+D)*(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*S[2]+j*S[1]+T*S[0];A.values[ne]=c}continue}if(l==="bilinear"){let X=Math.floor(q),te=Math.ceil(q),ne=q-X;for(let se=0;se<g;se++){let oe=g>1?P*(p-1)+se*U:.5*(P+F)*(p-1);if(oe<0||oe>p-1){for(let ge=0;ge<h;ge++){let ve=ge+se*S[2]+j*S[1]+T*S[0];A.values[ve]=c}continue}let ae=Math.floor(oe),re=Math.ceil(oe),ce=oe-ae;for(let ge=0;ge<h;ge++){let ve=ge+ae*v[2]+X*v[1]+C*v[0],Ce=b[ve];ve=ge+re*v[2]+X*v[1]+C*v[0];let Re=b[ve];ve=ge+ae*v[2]+te*v[1]+C*v[0];let Pe=b[ve];ve=ge+re*v[2]+te*v[1]+C*v[0];let Be=b[ve],Ue=Ce+(Re-Ce)*ce,et=Pe+(Be-Pe)*ce;ve=ge+se*S[2]+j*S[1]+T*S[0],A.values[ve]=Ue+(et-Ue)*ne}}}else for(let X=0;X<g;++X){let te=g>1?P*(p-1)+X*U:.5*(P+F)*(p-1);if(te<0||te>p-1){for(let oe=0;oe<h;oe++){let ae=oe+X*S[2]+j*S[1]+T*S[0];A.values[ae]=c}continue}let ne=Math.round(te),se=Math.round(q);for(let oe=0;oe<h;oe++){let ae=oe+ne*v[2]+se*v[1]+C*v[0],re=oe+X*S[2]+j*S[1]+T*S[0];A.values[re]=b[ae]}}}}return n.makeTensorInfo(A.shape,A.dtype,A.values)}var sH={kernelName:al,backendName:"cpu",kernelFunc:nH};function rH(e){let{inputs:t,backend:n,attrs:s}=e,{x:r}=t,{axis:a,exclusive:o,reverse:i}=s;Ne(r,"cumsum");let l=N.getAxesPermutation([a],r.shape.length),c=r;l!=null&&(c=ks({inputs:{x:r},backend:n,attrs:{perm:l}}));let u=N.getInnerMostAxes(1,r.shape.length)[0];if(u!==c.shape.length-1)throw new Error(`backend.cumsum in CPU expects an inner-most axis=${c.shape.length-1} but got axis=${u}`);let d=$s(c.dtype,"int32"),p=w.makeZerosTypedArray(w.sizeFromShape(c.shape),d),h=n.data.get(c.dataId).values,f=c.shape[c.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(c.shape,d,p);if(l!=null){let A=N.getUndoAxesPermutation(l),y=ks({inputs:{x:g},backend:n,attrs:{perm:A}});return n.disposeIntermediateTensorInfo(g),n.disposeIntermediateTensorInfo(c),y}return g}var aH={kernelName:ao,backendName:"cpu",kernelFunc:rH};function oH(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,c=n.data.get(a.dataId).values,u=m2(l,c,a.dtype,a.shape,o);return n.makeTensorInfo([o],a.dtype,u)}else if(r.shape.length===2){let l=n.bufferSync(r),c=n.bufferSync(a),u=Z7(l,c,o,i);return n.makeTensorInfo(u.shape,a.dtype,u.values)}throw new Error(`Error in denseBincount: input must be at most rank 2, but got rank${r.shape.length}.`)}var iH={kernelName:qp,backendName:"cpu",kernelFunc:oH};function lH(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}`);let i=r.shape[0],l=r.shape[1],c=r.shape[2],u=r.shape[3],d=l*a,p=c*a,h=u/(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 S=Math.floor(v/a),T=v%a,_=(b*a+T)*h;for(let O=0;O<h;++O){let D=O+_+u*(S+c*(x+l*A));m[g++]=f[D]}}}return n.makeTensorInfo([i,d,p,h],r.dtype,m)}var uH={kernelName:ol,backendName:"cpu",kernelFunc:lH};function W6(e){let{inputs:t,backend:n,attrs:s}=e,{x:r,filter:a}=t,{strides:o,pad:i,dilations:l,dimRoundingMode:c}=s;Ne([r,a],"depthwiseConv2DNative");let u=w.computeStrides(r.shape),d=w.computeStrides(a.shape),p=l;p==null&&(p=[1,1]),w.assert(N.eitherStridesOrDilationsAreOne(o,p),()=>`Error in depthwiseConv2d: Either strides or dilations must be 1. Got strides ${o} and dilations '${p}'`);let h=N.computeConv2DInfo(r.shape,a.shape,o,p,i,c,!0),{filterHeight:f,filterWidth:m,dilationHeight:g,dilationWidth:A,padInfo:y}=h,x=y.left,b=y.top,v=h.outChannels/h.inChannels,S=new Zt(h.outShape,r.dtype),T=n.data.get(r.dataId).values,_=n.data.get(a.dataId).values,O=S.values;for(let P=0;P<h.batchSize;++P){let D=P*u[0],F=P*S.strides[0];for(let C=0;C<h.outHeight;++C){let M=F+C*S.strides[1],U=C*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=D+q*u[1];for(let ne=0;ne<h.outWidth;++ne){let se=M+ne*S.strides[2],oe=ne*h.strideWidth-x;for(let ae=0;ae<m;++ae){let re=oe+ae*A;if(re<0||re>=h.inWidth)continue;let ce=X+ae*d[1],ge=te+re*h.inChannels,ve=se,Ce=ce;for(let Re=0;Re<h.inChannels;++Re){let Pe=T[ge+Re];for(let Be=0;Be<v;++Be)O[ve+Be]+=Pe*_[Ce+Be];ve+=v,Ce+=v}}}}}}return n.makeTensorInfo(S.shape,S.dtype,S.values)}var cH={kernelName:oo,backendName:"cpu",kernelFunc:W6};function dH(e){let{inputs:t,backend:n,attrs:s}=e,{x:r,dy:a}=t,{strides:o,dilations:i,pad:l,dimRoundingMode:c,filterShape:u}=s;Ne([r,a],"depthwiseConv2dNativeBackpropFilter");let d=N.computeConv2DInfo(r.shape,u,o,i,l,c,!0),{strideHeight:p,strideWidth:h,filterHeight:f,filterWidth:m}=d,g=new Zt(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 Zt(r.shape,r.dtype,b),S=n.data.get(a.dataId).values,T=new Zt(a.shape,a.dtype,S);for(let _=0;_<f;++_){let O=Math.max(0,Math.ceil((y-_)/p)),P=Math.min(d.outHeight,(d.inHeight+y-_)/p);for(let D=0;D<m;++D){let F=Math.max(0,Math.ceil((A-D)/h)),C=Math.min(d.outWidth,(d.inWidth+A-D)/h);for(let M=0;M<d.outChannels;++M){let U=Math.trunc(M/x),j=M%x,q=0;for(let X=0;X<d.batchSize;++X)for(let te=O;te<P;++te){let ne=_+te*p-y;for(let se=F;se<C;++se){let oe=D+se*h-A;q+=v.get(X,ne,oe,U)*T.get(X,te,se,M)}}g.set(q,_,D,U,j)}}}return n.makeTensorInfo(g.shape,g.dtype,g.values)}var pH={kernelName:Xp,backendName:"cpu",kernelFunc:dH};function hH(e){let{inputs:t,backend:n,attrs:s}=e,{dy:r,filter:a}=t,{strides:o,dilations:i,pad:l,dimRoundingMode:c,inputShape:u}=s;Ne([r,a],"depthwiseConv2DNativeBackpropInput");let d=w.computeStrides(r.shape),p=w.computeStrides(a.shape),h=N.computeConv2DInfo(u,a.shape,o,i,l,c,!0),f=new Zt(h.inShape,"float32"),m=f.values,[g,A,y]=f.strides,x=n.data.get(r.dataId).values,[b,v,S]=d,T=n.data.get(a.dataId).values,[_,O,P]=p,{batchSize:D,filterHeight:F,filterWidth:C,inChannels:M,inHeight:U,inWidth:j,outChannels:q,outHeight:X,outWidth:te,strideHeight:ne,strideWidth:se}=h,oe=F-1-h.padInfo.top,ae=C-1-h.padInfo.left,re=q/M;for(let ce=0;ce<D;++ce)for(let ge=0;ge<M;++ge)for(let ve=0;ve<U;++ve){let Ce=ve-oe,Re=Math.max(0,Math.ceil(Ce/ne)),Pe=Math.min(X,(F+Ce)/ne);for(let Be=0;Be<j;++Be){let Ue=Be-ae,et=Math.max(0,Math.ceil(Ue/se)),ut=Math.min(te,(C+Ue)/se),at=0;for(let ot=Re;ot<Pe;++ot){let pt=ot*ne-Ce;for(let ft=et;ft<ut;++ft){let kt=ft*se-Ue,Rt=b*ce+v*ot+S*ft,Wn=_*(F-1-pt)+O*(C-1-kt)+P*ge;for(let pn=0;pn<re;++pn){let Gs=ge*re+pn,Sn=x[Rt+Gs],Qn=T[Wn+pn];at+=Sn*Qn}}}m[g*ce+A*ve+y*Be+ge]=at}}return n.makeTensorInfo(f.shape,f.dtype,f.values)}var fH={kernelName:Kp,backendName:"cpu",kernelFunc:hH};function mH(e){let{inputs:t,backend:n}=e,{x:s}=t,r=w.sizeFromShape(s.shape),a=n.data.get(s.dataId).values,o=He([r,r],s.dtype),i=o.values;for(let c=0;c<a.length;c++)i[c*r+c]=a[c];let l=[...s.shape,...s.shape];return n.makeTensorInfo(l,o.dtype,o.values)}var gH={kernelName:Zp,backendName:"cpu",kernelFunc:mH},AH={kernelName:bc,backendName:"cpu",kernelFunc:({inputs:e,backend:t,attrs:n})=>{let{x:s,filter:r}=e,{strides:a,pad:o,dilations:i}=n,l=t,c=l.data.get(s.dataId).values,u=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:S,filterWidth:T,dilationHeight:_,dilationWidth:O,outShape:P}=N.computeDilation2DInfo(s.shape,r.shape,a,o,"NHWC",i),D=w.sizeFromShape(P),F=P.length,C=w.getArrayFromDType(s.dtype,D);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 ae=0;ae<S;++ae){let re=q+ae*_;if(re>=0&&re<f)for(let ce=0;ce<T;++ce){let ge=te+ce*O;if(ge>=0&&ge<m){let ve=w.locToIndex([U,re,ge,ne],u,w.computeStrides(s.shape)),Ce=w.locToIndex([ae,ce,ne],p,w.computeStrides(r.shape)),Re=c[ve]+d[Ce];Re>se&&(se=Re)}}}let oe=w.locToIndex([U,j,X,ne],F,w.computeStrides(P));C[oe]=se}}}return{dataId:l.write(w.toTypedArray(C,s.dtype),P,s.dtype),shape:P,dtype:s.dtype}}},yH={kernelName:Jp,backendName:"cpu",kernelFunc:({inputs:e,backend:t,attrs:n})=>{let{x:s,filter:r,dy:a}=e,{strides:o,pad:i,dilations:l}=n,c=t,u=w.toNestedArray(s.shape,c.data.get(s.dataId).values),d=w.toNestedArray(r.shape,c.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:S,dilationHeight:T,dilationWidth:_,outShape:O}=N.computeDilation2DInfo(s.shape,r.shape,o,i,"NHWC",l);w.assert(a.rank===O.length,()=>`Error in ${Jp}, dy must have the same rank as output ${O.length}, but got ${a.rank}`);let P=w.toNestedArray(O,c.data.get(a.dataId).values),D=w.makeZerosNestedTypedArray(r.shape,r.dtype);for(let C=0;C<p;++C)for(let M=0;M<g;++M){let U=M*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 oe=0;oe<v;++oe){let ae=U+oe*T;if(ae>=0&&ae<h)for(let re=0;re<S;++re){let ce=q+re*_;if(ce>=0&&ce<f){let ge=u[C][ae][ce][X]+d[oe][re][X];ge>te&&(te=ge,ne=oe,se=re)}}}D[ne][se][X]+=P[C][M][j][X]}}}return{dataId:c.write(w.toTypedArray(D,s.dtype),r.shape,r.dtype),shape:r.shape,dtype:r.dtype}}},xH={kernelName:Yp,backendName:"cpu",kernelFunc:({inputs:e,backend:t,attrs:n})=>{let{x:s,filter:r,dy:a}=e,{strides:o,pad:i,dilations:l}=n,c=t,u=w.toNestedArray(s.shape,c.data.get(s.dataId).values),d=w.toNestedArray(r.shape,c.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:S,dilationHeight:T,dilationWidth:_,outShape:O}=N.computeDilation2DInfo(s.shape,r.shape,o,i,"NHWC",l);w.assert(a.rank===O.length,()=>`Error in ${Yp}, dy must have the same rank as output ${O.length}, but got ${a.rank}`);let P=w.toNestedArray(O,c.data.get(a.dataId).values),D=w.makeZerosNestedTypedArray(s.shape,s.dtype);for(let C=0;C<p;++C)for(let M=0;M<g;++M){let U=M*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 oe=0;oe<v;++oe){let ae=U+oe*T;if(ae>=0&&ae<h)for(let re=0;re<S;++re){let ce=q+re*_;if(ce>=0&&ce<f){let ge=u[C][ae][ce][X]+d[oe][re][X];ge>te&&(te=ge,ne=ae,se=ce)}}}D[C][ne][se][X]+=P[C][M][j][X]}}}return{dataId:c.write(w.toTypedArray(D,s.dtype),s.shape,s.dtype),shape:s.shape,dtype:s.dtype}}};function Rd(e){let{inputs:t,backend:n,attrs:s}=e,{x:r}=t,{axis:a,keepDims:o}=s;Ne(r,"sum");let i;r.dtype==="bool"?i=Ra({inputs:{x:r},backend:n,attrs:{dtype:"int32"}}):i=Cr({inputs:{x:r},backend:n});let l=i.shape.length,c=w.parseAxisParam(a,i.shape),u=N.getAxesPermutation(c,l),d=c,p=i;u!=null&&(p=ks({inputs:{x:i},backend:n,attrs:{perm:u}}),d=N.getInnerMostAxes(d.length,l)),N.assertAxesAreInnerMostDims("sum",d,p.shape.length);let[h,f]=N.computeOutAndReduceShapes(p.shape,d),m=N.upcastType(p.dtype,"int32"),g=n0(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,S=0;for(let T=0;T<A;++T)S+=x[v+T];y[b]=S}if(o){let b=N.expandShapeToKeepDim(g.shape,c),v=g;g=vt({inputs:{x:g},backend:n,attrs:{shape:b}}),n.disposeIntermediateTensorInfo(v)}return n.disposeIntermediateTensorInfo(i),u!=null&&n.disposeIntermediateTensorInfo(p),g}var bH={kernelName:Lo,backendName:"cpu",kernelFunc:Rd};function vH(e){let{inputs:t,backend:n,attrs:s}=e,{equation:r}=s,a=t,{allDims:o,summedDims:i,idDims:l}=N.decodeEinsumEquation(r,a.length);N.checkEinsumDimSizes(o.length,l,a);let{path:c,steps:u}=N.getEinsumComputePath(i,l),d=u.length,p=null,h=o.length,f=[];for(let m=0;m<d;++m){for(let g of u[m]){let{permutationIndices:A,expandDims:y}=N.getEinsumPermutation(h,l[g]),x;N.isIdentityPermutation(A)?x=a[g]:(x=ks({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=vt({inputs:{x},backend:n,attrs:{shape:b}}),f.push(x)),p===null?p=x:(p=s0({inputs:{a:x,b:p},backend:n}),f.push(p))}m<d-1&&(c[m]>=0&&(p=Rd({inputs:{x:p},backend:n,attrs:{axis:c[m]-(o.length-h),keepDims:!1}}),f.push(p)),h--)}for(let m of f)m!==p&&n.disposeIntermediateTensorInfo(m);return p}var wH={kernelName:Qp,backendName:"cpu",kernelFunc:vH};function kH(e){let{inputs:t,backend:n}=e,{dy:s,y:r}=t;Ne([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 c=o[l];c>=1?a[l]=i[l]:a[l]=i[l]*(c+1)}return n.makeTensorInfo(r.shape,"float32",a)}var IH={kernelName:eh,backendName:"cpu",kernelFunc:kH},SH=N.ERF_P,CH=N.ERF_A1,TH=N.ERF_A2,NH=N.ERF_A3,EH=N.ERF_A4,RH=N.ERF_A5,DH=dt(il,e=>{let t=Math.sign(e),n=Math.abs(e),s=1/(1+SH*n);return t*(1-((((RH*s+EH)*s+NH)*s+TH)*s+CH)*s*Math.exp(-n*n))}),_H={kernelName:il,backendName:"cpu",kernelFunc:DH};function a0(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),vt({inputs:{x:r},backend:n,attrs:{shape:i}})}var FH={kernelName:ul,backendName:"cpu",kernelFunc:a0},$H=jt((e,t)=>e/t),I2=cn(io,$H),S2={kernelName:io,backendName:"cpu",kernelFunc:I2};function V6(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,c=[r,a],u=w.sizeFromShape(c),d=w.getTypedArrayFromDType("float32",u),p=w.getTypedArrayFromDType("float32",u);for(let g=0;g<r;g++){let A=vi({inputs:{x:i},backend:n,attrs:{begin:[g,0],size:[1,a]}}),y=vi({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}=OH(x,t,n),S=N.mergeRealAndImagArrays(b,v);for(let T=0;T<a;T++){let _=N.getComplexWithIndex(S,T);d[g*a+T]=_.real,p[g*a+T]=_.imag}n.disposeIntermediateTensorInfo(A),n.disposeIntermediateTensorInfo(y),n.disposeIntermediateTensorInfo(x)}let h=n.makeTensorInfo(c,"float32",d),f=n.makeTensorInfo(c,"float32",p),m=cs({inputs:{real:h,imag:f},backend:n});return n.disposeIntermediateTensorInfo(h),n.disposeIntermediateTensorInfo(f),m}function OH(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(PH(s)){let i=C2(a,o,s,t,n),l=[e.shape[0],e.shape[1]];if(t){let c=n.makeTensorInfo(l,"float32",i.real),u=n.makeTensorInfo(l,"float32",i.imag),d=n.makeTensorInfo([],"float32",w.createScalarValue(s,"float32")),p=Cr({inputs:{x:d},backend:n}),h=S2.kernelFunc({inputs:{a:c,b:d},backend:n}),f=S2.kernelFunc({inputs:{a:u,b:p},backend:n}),m=n.data.get(h.dataId).values,g=n.data.get(f.dataId).values;return n.disposeIntermediateTensorInfo(c),n.disposeIntermediateTensorInfo(u),n.disposeIntermediateTensorInfo(d),n.disposeIntermediateTensorInfo(p),n.disposeIntermediateTensorInfo(h),n.disposeIntermediateTensorInfo(f),{real:m,imag:g}}return i}else{let i=N.mergeRealAndImagArrays(a,o),l=MH(i,s,t);return N.splitRealAndImagArrays(l)}}function PH(e){return(e&e-1)==0}function C2(e,t,n,s,r){if(n===1)return{real:e,imag:t};let a=N.mergeRealAndImagArrays(e,t),o=n/2,i=N.complexWithEvenIndex(a),l=i.real,c=i.imag,u=[l.length],d=r.makeTensorInfo(u,"float32",l),p=r.makeTensorInfo(u,"float32",c),h=cs({inputs:{real:d,imag:p},backend:r}),f=N.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=C2(l,c,o,s,r),S=v.real,T=v.imag,_=[S.length],O=r.makeTensorInfo(_,"float32",S),P=r.makeTensorInfo(_,"float32",T),D=cs({inputs:{real:O,imag:P},backend:r}),F=C2(m,g,o,s,r),C=F.real,M=F.imag,U=[C.length],j=r.makeTensorInfo(U,"float32",C),q=r.makeTensorInfo(U,"float32",M),X=cs({inputs:{real:j,imag:q},backend:r}),te=N.exponents(n,s),ne=[te.real.length],se=r.makeTensorInfo(ne,"float32",te.real),oe=r.makeTensorInfo(ne,"float32",te.imag),ae=cs({inputs:{real:se,imag:oe},backend:r}),re=s0({inputs:{a:ae,b:X},backend:r}),ce=Nd({inputs:{a:D,b:re},backend:r}),ge=v2({inputs:{a:D,b:re},backend:r}),ve=bi({inputs:{input:ce},backend:r}),Ce=bi({inputs:{input:ge},backend:r}),Re=Cu({inputs:{input:ce},backend:r}),Pe=Cu({inputs:{input:ge},backend:r}),Be=Tu({inputs:[ve,Ce],backend:r,attrs:{axis:0}}),Ue=Tu({inputs:[Re,Pe],backend:r,attrs:{axis:0}}),et=r.data.get(Be.dataId).values,ut=r.data.get(Ue.dataId).values;return r.disposeIntermediateTensorInfo(d),r.disposeIntermediateTensorInfo(p),r.disposeIntermediateTensorInfo(h),r.disposeIntermediateTensorInfo(y),r.disposeIntermediateTensorInfo(x),r.disposeIntermediateTensorInfo(b),r.disposeIntermediateTensorInfo(O),r.disposeIntermediateTensorInfo(P),r.disposeIntermediateTensorInfo(D),r.disposeIntermediateTensorInfo(j),r.disposeIntermediateTensorInfo(q),r.disposeIntermediateTensorInfo(X),r.disposeIntermediateTensorInfo(se),r.disposeIntermediateTensorInfo(oe),r.disposeIntermediateTensorInfo(ae),r.disposeIntermediateTensorInfo(re),r.disposeIntermediateTensorInfo(ce),r.disposeIntermediateTensorInfo(ge),r.disposeIntermediateTensorInfo(ve),r.disposeIntermediateTensorInfo(Re),r.disposeIntermediateTensorInfo(Ce),r.disposeIntermediateTensorInfo(Pe),r.disposeIntermediateTensorInfo(Be),r.disposeIntermediateTensorInfo(Ue),{real:et,imag:ut}}function MH(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=N.exponent(r*i,t,n),c=N.getComplexWithIndex(e,i);a+=c.real*l.real-c.imag*l.imag,o+=c.real*l.imag+c.imag*l.real}n&&(a/=t,o/=t),N.assignToTypedArray(s,a,o,r)}return s}function zH(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=vt({inputs:{x:s},backend:n,attrs:{shape:[o,a]}}),l=V6(i,!1,n),c=vt({inputs:{x:l},backend:n,attrs:{shape:s.shape}});return n.disposeIntermediateTensorInfo(i),n.disposeIntermediateTensorInfo(l),c}var LH={kernelName:th,backendName:"cpu",kernelFunc:zH};function T2(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 WH(i,r,o),t.makeTensorInfo(s,o,i)}var BH={kernelName:vc,backendName:"cpu",kernelFunc:T2};function WH(e,t,n){e.fill(t)}var VH={kernelName:dl,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,c]=s.shape,u=r.data.get(s.dataId).values;for(let p=0;p<o;p++){let h=p*l*i*c;for(let f=0;f<i;f++){let m=f*(l*c);for(let g=0;g<l;g++){let A=g*c;for(let y=0;y<c;y++){let x=Math.round(l-g-1),b=h+m+A+y,v=u[b];if(x>=0&&x<l){let S=x*c,T=h+m+S+y;v=u[T]}a[b]=v}}}}return{dataId:r.write(a,s.shape,s.dtype),shape:s.shape,dtype:s.dtype}}},UH=jt((e,t)=>Math.floor(e/t)),GH=cn(po,UH,null,"int32"),HH={kernelName:po,backendName:"cpu",kernelFunc:GH};function jH(e){let{inputs:t,backend:n,attrs:s}=e,{x:r,filter:a,bias:o,preluActivationWeights:i}=t,{strides:l,pad:c,dataFormat:u,dilations:d,dimRoundingMode:p,activation:h,leakyreluAlpha:f}=s,m=B6({inputs:{x:r,filter:a},backend:n,attrs:{strides:l,pad:c,dataFormat:u,dilations:d,dimRoundingMode:p}});if(o){let g=m;m=Nd({inputs:{a:m,b:o},backend:n}),n.disposeIntermediateTensorInfo(g)}if(h){let g=m;m=w2(n,m,h,i,f),n.disposeIntermediateTensorInfo(g)}return m}var qH={kernelName:qo,backendName:"cpu",kernelFunc:jH};function XH(e){let{inputs:t,backend:n,attrs:s}=e,{x:r,filter:a,bias:o,preluActivationWeights:i}=t,{strides:l,pad:c,dataFormat:u,dilations:d,dimRoundingMode:p,activation:h,leakyreluAlpha:f}=s,m=W6({inputs:{x:r,filter:a},backend:n,attrs:{strides:l,pad:c,dataFormat:u,dilations:d,dimRoundingMode:p}});if(o){let g=m;m=Nd({inputs:{a:m,b:o},backend:n}),n.disposeIntermediateTensorInfo(g)}if(h){let g=m;m=w2(n,m,h,i,f),n.disposeIntermediateTensorInfo(g)}return m}var KH={kernelName:Xo,backendName:"cpu",kernelFunc:XH};function ZH(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,c,u,d]=N.prepareAndValidate(s,r);if(c===0)return n.makeTensorInfo(l,s.dtype,[]);let p=n.data.get(r.dataId).values,h=n.bufferSync(s),f=r6(p,h,s.dtype,c,i,u,d,s.shape,a);return n.makeTensorInfo(l,s.dtype,f.values)}var YH={kernelName:hl,backendName:"cpu",kernelFunc:ZH};function JH(e){let{inputs:t,backend:n,attrs:s}=e,{x:r,indices:a}=t,{axis:o,batchDims:i}=s;Ne([r,a],"gatherV2");let l=w.parseAxisParam(o,r.shape)[0],c=n.data.get(a.dataId).values,u=r.shape[l];for(let b=0;b<c.length;++b){let v=c[b];w.assert(v<=u-1&&v>=0,()=>`GatherV2: the index value ${v} is not in [0, ${u-1}]`)}let d=i;i==null&&(d=0);let p=w.sizeFromShape(a.shape),h=N.segment_util.collectGatherOpShapeInfo(r,a,l,d),f=vt({inputs:{x:r},backend:n,attrs:{shape:[h.batchSize,h.outerSize,h.dimSize,h.sliceSize]}}),m=vt({inputs:{x:a},backend:n,attrs:{shape:[h.batchSize,p/h.batchSize]}}),g=[h.batchSize,h.outerSize,p/h.batchSize,h.sliceSize],A=n.bufferSync(m),y=n.bufferSync(f),x=a6(y,A,g);return n.disposeIntermediateTensorInfo(f),n.disposeIntermediateTensorInfo(m),n.makeTensorInfo(h.outputShape,x.dtype,x.values)}var QH={kernelName:pl,backendName:"cpu",kernelFunc:JH};function ej(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=vt({inputs:{x:s},backend:n,attrs:{shape:[o,a]}}),l=V6(i,!0,n),c=vt({inputs:{x:l},backend:n,attrs:{shape:s.shape}});return n.disposeIntermediateTensorInfo(i),n.disposeIntermediateTensorInfo(l),c}var tj={kernelName:nh,backendName:"cpu",kernelFunc:ej},nj=dt(ml,e=>Number.isFinite(e)?1:0,"bool"),sj={kernelName:ml,backendName:"cpu",kernelFunc:nj},rj=dt(gl,e=>Math.abs(e)===1/0?1:0,"bool"),aj={kernelName:gl,backendName:"cpu",kernelFunc:rj},oj=dt(Al,e=>Number.isNaN(e)?1:0,"bool"),ij={kernelName:Al,backendName:"cpu",kernelFunc:oj};function lj(e){let{backend:t,attrs:n}=e,{start:s,stop:r,num:a}=n,o=c6(s,r,a);return t.makeTensorInfo([o.length],"float32",o)}var uj={kernelName:rh,backendName:"cpu",kernelFunc:lj},cj=dt(bl,e=>Math.log1p(e)),dj={kernelName:bl,backendName:"cpu",kernelFunc:cj},pj=jt((e,t)=>e&&t),hj=cn(vl,pj,null,"bool"),fj={kernelName:vl,backendName:"cpu",kernelFunc:hj},mj=dt(wc,e=>e?0:1,"bool"),gj={kernelName:wc,backendName:"cpu",kernelFunc:mj},Aj=jt((e,t)=>e||t),yj=cn(kc,Aj,null,"bool"),xj={kernelName:kc,backendName:"cpu",kernelFunc:yj};function bj(e){let{inputs:t,backend:n,attrs:s}=e,{x:r}=t,{depthRadius:a,bias:o,alpha:i,beta:l}=s;Ne(r,"LRN");let c=r.shape[3],u=c-1,d=n.data.get(r.dataId).values,p=w.sizeFromShape(r.shape),h=new Float32Array(p);function f(m){let g=m%c,A=m-g+Math.max(0,g-a),y=m-g+Math.min(g+a,u),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 vj={kernelName:Ic,backendName:"cpu",kernelFunc:bj};function wj(e){let{inputs:t,backend:n,attrs:s}=e,{x:r,y:a,dy:o}=t,{depthRadius:i,bias:l,alpha:c,beta:u}=s;Ne(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),S=0;for(let T=b;T<v;T++)S+=Math.pow(f[T],2);S=c*S+l;for(let T=b;T<v;T++){let _=-2*c*u*f[T]*m[y]/S;y===T&&(_+=Math.pow(S,-u)),_*=h[y],g[T]+=_}}return n.makeTensorInfo(o.shape,r.dtype,g)}var kj={kernelName:ah,backendName:"cpu",kernelFunc:wj};function U6(e){let{inputs:t,backend:n,attrs:s}=e,{x:r}=t,{reductionIndices:a,keepDims:o}=s,i=n,l=r.shape,c=l.length,u=w.parseAxisParam(a,l),d=u,p=N.getAxesPermutation(d,c),h=i.data.get(r.dataId).values;if(p!=null){let b=new Array(c);for(let v=0;v<b.length;v++)b[v]=l[p[v]];h=y2(h,l,r.dtype,p,b),d=N.getInnerMostAxes(d.length,c),l=b}Ne(r,"max"),N.assertAxesAreInnerMostDims("max",d,c);let[f,m]=N.computeOutAndReduceShapes(l,d),g=w.sizeFromShape(m),A=p6(h,g,f,r.dtype),y=i.write(A,f,r.dtype),x=f;return o&&(x=N.expandShapeToKeepDim(f,u)),{dataId:y,shape:x,dtype:r.dtype}}var Ij={kernelName:yo,backendName:"cpu",kernelFunc:U6};function Sj(e){let{inputs:t,backend:n,attrs:s}=e,{x:r}=t;Ne(r,"maxPool");let{filterSize:a,strides:o,pad:i,dimRoundingMode:l}=s,c=1;w.assert(N.eitherStridesOrDilationsAreOne(o,c),()=>`Error in maxPool: Either strides or dilations must be 1. Got strides ${o} and dilations '${c}'`);let u=N.computePool2DInfo(r.shape,a,o,c,i,l),d;if(u.filterWidth===1&&u.filterHeight===1&&w.arraysEqual(u.inShape,u.outShape))d=Cr({inputs:{x:r},backend:n});else{let p=n.data.get(r.dataId).values,h=w.computeStrides(r.shape),f=k2(p,r.shape,r.dtype,h,u,"max");d=n.makeTensorInfo(u.outShape,r.dtype,f.values)}return d}var Cj={kernelName:bo,backendName:"cpu",kernelFunc:Sj};function Tj(e){let{inputs:t,backend:n,attrs:s}=e,{x:r}=t,{filterSize:a,strides:o,pad:i,dimRoundingMode:l,dataFormat:c}=s;Ne(r,"maxPool3d");let u=N.computePool3DInfo(r.shape,a,o,1,i,l,c),d=n.data.get(r.dataId).values,p=L6(d,r.shape,r.dtype,w.computeStrides(r.shape),u,"max");return n.makeTensorInfo(p.shape,"float32",p.values)}var Nj={kernelName:Sc,backendName:"cpu",kernelFunc:Tj};function Ej(e){let{inputs:t,backend:n,attrs:s}=e,{dy:r,input:a}=t,{filterSize:o,strides:i,pad:l,dimRoundingMode:c}=s;Ne([r,a],"maxPool3DGrad");let u=N.computePool3DInfo(a.shape,o,i,1,l,c),d=n.bufferSync(a),p=yG(d,u),h=u.strideDepth,f=u.strideHeight,m=u.strideWidth,g=u.dilationDepth,A=u.dilationHeight,y=u.dilationWidth,x=u.effectiveFilterDepth,b=u.effectiveFilterHeight,v=u.effectiveFilterWidth,S=x-1-u.padInfo.front,T=v-1-u.padInfo.left,_=b-1-u.padInfo.top,O=He(a.shape,"float32"),P=n.bufferSync(r);for(let D=0;D<u.batchSize;++D)for(let F=0;F<u.inChannels;++F)for(let C=0;C<u.inDepth;++C)for(let M=0;M<u.inHeight;++M)for(let U=0;U<u.inWidth;++U){let j=C-S,q=M-_,X=U-T,te=0;for(let ne=0;ne<x;ne+=g){let se=(j+ne)/h;if(!(se<0||se>=u.outDepth||Math.floor(se)!==se))for(let oe=0;oe<b;oe+=A){let ae=(q+oe)/f;if(!(ae<0||ae>=u.outHeight||Math.floor(ae)!==ae))for(let re=0;re<v;re+=y){let ce=(X+re)/m;if(ce<0||ce>=u.outWidth||Math.floor(ce)!==ce)continue;let ge=x*b*v-1-p.get(D,se,ae,ce,F),ve=ne*b*v+oe*v+re,Ce=ge===ve?1:0;if(Ce===0)continue;te+=P.get(D,se,ae,ce,F)*Ce}}}O.set(te,D,C,M,U,F)}return n.makeTensorInfo(O.shape,O.dtype,O.values)}var Rj={kernelName:ih,backendName:"cpu",kernelFunc:Ej};function Dj(e){let{inputs:t,backend:n,attrs:s}=e,{dy:r,input:a,output:o}=t,i=a;Ne([a,o],"maxPoolGrad");let{filterSize:l,strides:c,pad:u,dimRoundingMode:d}=s,p=N.computePool2DInfo(i.shape,l,c,1,u,d),h=n.data.get(i.dataId).values,f=He(p.outShape,i.dtype,z6(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,S=x-1-p.padInfo.top,T=He(i.shape,"float32"),_=n.data.get(r.dataId).values,O=He(r.shape,"float32",_);for(let P=0;P<p.batchSize;++P)for(let D=0;D<p.inChannels;++D)for(let F=0;F<p.inHeight;++F)for(let C=0;C<p.inWidth;++C){let M=F-S,U=C-v,j=0;for(let q=0;q<x;q+=A){let X=(M+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(P,X,ne,D),oe=q*b+te,ae=se===oe?1:0;if(ae===0)continue;j+=O.get(P,X,ne,D)*ae}}T.set(j,P,F,C,D)}return n.makeTensorInfo(T.shape,T.dtype,T.values)}var _j={kernelName:oh,backendName:"cpu",kernelFunc:Dj};function Fj(e,t,n,s,r){let a=w.computeStrides(t),o=k2(e,t,n,a,r,"max"),i=z6(e,t,n,r,!0,s);return[o.values,i.values]}var $j={kernelName:lh,backendName:"cpu",kernelFunc:({inputs:e,attrs:t,backend:n})=>{let{x:s}=e,{filterSize:r,strides:a,pad:o,includeBatchInIndex:i}=t,l=n;Ne(s,"MaxPoolWithArgmax");let c=l.data.get(s.dataId).values,u=N.computePool2DInfo(s.shape,r,a,[1,1],o),[d,p]=Fj(c,s.shape,s.dtype,i,u),h=l.write(d,u.outShape,s.dtype),f=l.write(p,u.outShape,s.dtype);return[{dataId:h,shape:u.outShape,dtype:s.dtype},{dataId:f,shape:u.outShape,dtype:"int32"}]}};function Oj(e){let{inputs:t,backend:n,attrs:s}=e,{x:r}=t,{axis:a,keepDims:o}=s,i=w.parseAxisParam(a,r.shape),c=N.computeOutAndReduceShapes(r.shape,i)[1],u=w.sizeFromShape(c),d=[],p=n.makeTensorInfo([],"float32",new Float32Array([u]));d.push(p);let h=Ra({inputs:{x:r},backend:n,attrs:{dtype:"float32"}});d.push(h);let f=I2({inputs:{a:h,b:p},backend:n});d.push(f);let m=Rd({inputs:{x:f},backend:n,attrs:{axis:a,keepDims:o}});return d.forEach(g=>n.disposeIntermediateTensorInfo(g)),m}var Pj={kernelName:vo,backendName:"cpu",kernelFunc:Oj};function Mj(e){let{inputs:t,backend:n,attrs:s}=e,{x:r}=t,{axis:a,keepDims:o}=s;Ne(r,"min");let i=w.parseAxisParam(a,r.shape),l=i,c=N.getAxesPermutation(l,r.shape.length),u=r;c!=null&&(u=ks({inputs:{x:r},backend:n,attrs:{perm:c}}),l=N.getInnerMostAxes(l.length,r.shape.length)),N.assertAxesAreInnerMostDims("min",l,u.shape.length);let[d,p]=N.computeOutAndReduceShapes(u.shape,l),h=w.sizeFromShape(p),f=w.makeZerosTypedArray(w.sizeFromShape(d),u.dtype),m=n.data.get(u.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}c!=null&&n.disposeIntermediateTensorInfo(u);let g=n.makeTensorInfo(d,u.dtype,f);if(o){let A=N.expandShapeToKeepDim(d,i),y=vt({inputs:{x:g},backend:n,attrs:{shape:A}});return n.disposeIntermediateTensorInfo(g),y}return g}var zj={kernelName:wo,backendName:"cpu",kernelFunc:Mj};function Lj(e){let{inputs:t,backend:n,attrs:s}=e,{x:r}=t,{paddings:a,mode:o}=s;Ne(r,"mirrorPad");let i=a.map((x,b)=>x[0]+r.shape[b]+x[1]),l=a.map(x=>x[0]),c=a.map((x,b)=>x[0]+r.shape[b]),u=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 S=0;S<m;S++)b[S]<l[S]?b[S]=l[S]*2-b[S]-u:b[S]>=c[S]&&(b[S]=(c[S]-1)*2-b[S]+u);b=b.map((S,T)=>S-l[T]);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 Bj={kernelName:Io,backendName:"cpu",kernelFunc:Lj},Wj=jt((e,t)=>{let n=e%t;return e<0&&t<0||e>=0&&t>=0?n:(n+t)%t}),Vj=cn(wl,Wj),Uj={kernelName:wl,backendName:"cpu",kernelFunc:Vj},Gj=ja(L5());function G6(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),c=U6({inputs:{x:r},backend:n,attrs:{reductionIndices:l,keepDims:!1}}),u=N.expandShapeToKeepDim(c.shape,l),d=vt({inputs:{x:c},backend:n,attrs:{shape:u}}),p=v2({inputs:{a:r,b:d},backend:n}),h=t6({inputs:{x:p},backend:n}),f=Rd({inputs:{x:h},backend:n,attrs:{axis:l,keepDims:!1}}),m=vt({inputs:{x:f},backend:n,attrs:{shape:u}}),g=I2({inputs:{a:h,b:m},backend:n});return n.disposeIntermediateTensorInfo(c),n.disposeIntermediateTensorInfo(d),n.disposeIntermediateTensorInfo(p),n.disposeIntermediateTensorInfo(h),n.disposeIntermediateTensorInfo(f),n.disposeIntermediateTensorInfo(m),g}var Hj={kernelName:Bo,backendName:"cpu",kernelFunc:G6};function jj(e){let{inputs:t,backend:n,attrs:s}=e,{logits:r}=t,{numSamples:a,seed:o,normalized:i}=s;Ne(r,"multinomial");let l=i?r:G6({inputs:{logits:r},backend:n,attrs:{dim:-1}}),c=l.shape[0],u=l.shape[1],d=n.data.get(l.dataId).values,p=[c,a],h=w.makeZerosTypedArray(w.sizeFromShape(p),"int32");for(let f=0;f<c;++f){let m=f*u,g=new Float32Array(u-1);g[0]=d[m];for(let x=1;x<g.length;++x)g[x]=g[x-1]+d[m+x];let A=Gj.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 qj={kernelName:uh,backendName:"cpu",kernelFunc:jj},Xj=br.nonMaxSuppressionV3Impl;function Kj(e){let{inputs:t,backend:n,attrs:s}=e,{boxes:r,scores:a}=t,{maxOutputSize:o,iouThreshold:i,scoreThreshold:l}=s;Ne(r,"NonMaxSuppression");let c=n.data.get(r.dataId).values,u=n.data.get(a.dataId).values,{selectedIndices:d}=Xj(c,u,o,i,l);return n.makeTensorInfo([d.length],"int32",new Int32Array(d))}var Zj={kernelName:Sl,backendName:"cpu",kernelFunc:Kj},Yj=br.nonMaxSuppressionV4Impl;function Jj(e){let{inputs:t,backend:n,attrs:s}=e,{boxes:r,scores:a}=t,{maxOutputSize:o,iouThreshold:i,scoreThreshold:l,padToMaxOutputSize:c}=s;Ne(r,"NonMaxSuppressionPadded");let u=n.data.get(r.dataId).values,d=n.data.get(a.dataId).values,{selectedIndices:p,validOutputs:h}=Yj(u,d,o,i,l,c);return[n.makeTensorInfo([p.length],"int32",new Int32Array(p)),n.makeTensorInfo([],"int32",new Int32Array([h]))]}var Qj={kernelName:Cl,backendName:"cpu",kernelFunc:Jj},eq=br.nonMaxSuppressionV5Impl;function tq(e){let{inputs:t,backend:n,attrs:s}=e,{boxes:r,scores:a}=t,{maxOutputSize:o,iouThreshold:i,scoreThreshold:l,softNmsSigma:c}=s;Ne(r,"NonMaxSuppressionWithScore");let u=n.data.get(r.dataId).values,d=n.data.get(a.dataId).values,p=o,h=i,f=l,m=c,{selectedIndices:g,selectedScores:A}=eq(u,d,p,h,f,m);return[n.makeTensorInfo([g.length],"int32",new Int32Array(g)),n.makeTensorInfo([A.length],"float32",new Float32Array(A))]}var nq={kernelName:Tl,backendName:"cpu",kernelFunc:tq};function sq(e){let{inputs:t,backend:n,attrs:s}=e,{indices:r}=t,{depth:a,onValue:o,offValue:i}=s;Ne(r,"oneHot");let l=w.sizeFromShape(r.shape),c=new Float32Array(l*a);c.fill(i);let u=n.data.get(r.dataId).values;for(let d=0;d<l;++d)u[d]>=0&&u[d]<a&&(c[d*a+u[d]]=o);return n.makeTensorInfo([...r.shape,a],"int32",c)}var rq={kernelName:Co,backendName:"cpu",kernelFunc:sq};function o0(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=bi({inputs:{input:s},backend:n}),a=o0({inputs:{x:r},backend:n}),o=Cu({inputs:{input:s},backend:n}),i=o0({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 T2({backend:n,attrs:{shape:s.shape,value:0,dtype:s.dtype}})}var aq={kernelName:jl,backendName:"cpu",kernelFunc:o0};function H6(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=bi({inputs:{input:s},backend:n}),a=H6({inputs:{x:r},backend:n}),o=Cu({inputs:{input:s},backend:n}),i=o0({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 T2({backend:n,attrs:{shape:s.shape,value:1,dtype:s.dtype}})}var oq={kernelName:Nl,backendName:"cpu",kernelFunc:H6};function j6(e){let{inputs:t,backend:n,attrs:s}=e,{axis:r}=s;if(t.length===1)return a0({inputs:{input:t[0]},backend:n,attrs:{dim:r}});let a=t[0].shape,o=t[0].dtype;t.forEach(u=>{w.assertShapesMatch(a,u.shape,"All tensors passed to stack must have matching shapes"),w.assert(o===u.dtype,()=>"All tensors passed to stack must have matching dtypes")});let i=[],l=t.map(u=>{let d=a0({inputs:{input:u},backend:n,attrs:{dim:r}});return i.push(d),d}),c=Tu({inputs:l,backend:n,attrs:{axis:r}});return i.forEach(u=>n.disposeIntermediateTensorInfo(u)),c}var iq={kernelName:El,backendName:"cpu",kernelFunc:j6};function lq(e){let{inputs:t,backend:n,attrs:s}=e,{x:r}=t,{paddings:a,constantValue:o}=s;Ne(r,"pad");let i=a.map((y,x)=>y[0]+r.shape[x]+y[1]),l=a.map(y=>y[0]),c=n.data.get(r.dataId).values,u=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<u;y++){let b=w.indexToLoc(y,d,p).map((S,T)=>S+l[T]),v=w.locToIndex(b,f,m);g[v]=c[y]}return{dataId:n.write(g,i,r.dtype),shape:i,dtype:r.dtype}}var q6={kernelName:To,backendName:"cpu",kernelFunc:lq},uq=jt((e,t)=>Math.pow(e,t)),cq=cn(No,uq),dq={kernelName:No,backendName:"cpu",kernelFunc:cq};function pq(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 hq={kernelName:Cc,backendName:"cpu",kernelFunc:pq},fq=dt(Dl,e=>1/e),mq={kernelName:Dl,backendName:"cpu",kernelFunc:fq};function gq(e){let{inputs:t,backend:n,attrs:s}=e,{images:r}=t,{alignCorners:a,halfPixelCenters:o,size:i}=s;Ne(r,"resizeBilinear");let l=w.computeStrides(r.shape),[c,u]=i,[d,p,h,f]=r.shape,m=n.data.get(r.dataId).values,g=new Float32Array(w.sizeFromShape([d,c,u,f])),A=[a&&c>1?p-1:p,a&&u>1?h-1:h],y=[a&&c>1?c-1:c,a&&u>1?u-1:u],x=0,b=A[0]/y[0],v=A[1]/y[1];for(let S=0;S<d;S++)for(let T=0;T<c;T++){let _;o?_=b*(T+.5)-.5:_=b*T;let O=Math.max(0,Math.floor(_)),P=_-O,D=Math.min(p-1,Math.ceil(_)),F=S*l[0]+O*l[1],C=S*l[0]+D*l[1];for(let M=0;M<u;M++){let U;o?U=v*(M+.5)-.5:U=v*M;let j=Math.max(0,Math.floor(U)),q=U-j,X=Math.min(h-1,Math.ceil(U)),te=F+j*l[2],ne=C+j*l[2],se=F+X*l[2],oe=C+X*l[2];for(let ae=0;ae<f;ae++){let re=m[te+ae],ce=m[ne+ae],ge=m[se+ae],ve=m[oe+ae],Ce=re+(ge-re)*q,Re=ce+(ve-ce)*q,Pe=Ce+(Re-Ce)*P;g[x++]=Pe}}}return n.makeTensorInfo([d,c,u,f],"float32",g)}var Aq={kernelName:Do,backendName:"cpu",kernelFunc:gq};function yq(e){let{inputs:t,backend:n,attrs:s}=e,{images:r,dy:a}=t,{alignCorners:o}=s;Ne([a,r],"resizeBilinearGrad");let i=w.computeStrides(r.shape),[l,c,u,d]=r.shape,[,p,h]=a.shape,f=new Float32Array(l*c*u*d),m=[o&&p>1?c-1:c,o&&h>1?u-1:u],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 S=v*i[0];for(let T=0;T<p;T++){let _=T*A,O=Math.floor(_),P=Math.min(Math.ceil(_),c-1),D=S+O*i[1],F=S+P*i[1],C=_-O,M=1-C;for(let U=0;U<h;U++){let j=U*y,q=Math.floor(j),X=Math.min(Math.ceil(j),u-1),te=j-q,ne=1-te,se=D+q*i[2],oe=D+X*i[2],ae=F+q*i[2],re=F+X*i[2],ce=M*ne,ge=M*te,ve=C*ne,Ce=C*te;for(let Re=0;Re<d;Re++){let Pe=x[b++];f[se+Re]+=Pe*ce,f[oe+Re]+=Pe*ge,f[ae+Re]+=Pe*ve,f[re+Re]+=Pe*Ce}}}}return n.makeTensorInfo([l,u,c,d],"float32",f)}var xq={kernelName:ph,backendName:"cpu",kernelFunc:yq};function bq(e){let{inputs:t,backend:n,attrs:s}=e,{images:r}=t,{alignCorners:a,halfPixelCenters:o,size:i}=s;Ne(r,"resizeNearestNeighbor");let l=w.computeStrides(r.shape),[c,u]=i,[d,p,h,f]=r.shape,m=n.data.get(r.dataId).values,g=new Float32Array(d*c*u*f),A=[a&&c>1?p-1:p,a&&u>1?h-1:h],y=[a&&c>1?c-1:c,a&&u>1?u-1:u],x=A[0]/y[0],b=A[1]/y[1],v=0;for(let S=0;S<d;S++){let T=S*l[0];for(let _=0;_<c;_++){let O=o?x*(_+.5):x*_,P=Math.min(p-1,a?Math.round(O):Math.floor(O));o&&(P=Math.max(0,P));let D=T+P*l[1];for(let F=0;F<u;F++){let C=o?b*(F+.5):b*F,M=Math.min(h-1,a?Math.round(C):Math.floor(C));o&&(M=Math.max(0,M));let U=D+M*l[2];for(let j=0;j<f;j++){let q=m[U+j];g[v++]=q}}}}return n.makeTensorInfo([d,c,u,f],r.dtype,g)}var vq={kernelName:Tc,backendName:"cpu",kernelFunc:bq};function wq(e){let{inputs:t,backend:n,attrs:s}=e,{images:r,dy:a}=t,{alignCorners:o}=s;Ne([a,r],"resizeNearestNeighborGrad");let i=w.computeStrides(r.shape),l=w.computeStrides(a.shape),[c,u,d,p]=r.shape,[,h,f]=a.shape,m=new Float32Array(c*u*d*p),g=n.data.get(a.dataId).values,A=[o&&h>1?u-1:u,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,S=1/b,T=Math.ceil(v)*2+2,_=Math.ceil(S)*2+2;for(let O=0;O<c;O++){let P=O*i[0];for(let D=0;D<u;D++){let F=P+D*i[1],C=Math.floor(D*v),M=Math.floor(C-T/2);for(let U=0;U<d;U++){let j=F+U*i[2],q=Math.floor(U*S),X=Math.floor(q-_/2);for(let te=0;te<p;te++){let ne=0;for(let se=0;se<T;se++){let oe=se+M;if(oe<0||oe>=h)continue;let ae=P+oe*l[1],re=oe*x,ce=Math.min(u-1,o?Math.round(re):Math.floor(re));if(D===ce)for(let ge=0;ge<_;ge++){let ve=ge+X;if(ve<0||ve>=f)continue;let Ce=ae+ve*l[2],Re=ve*b,Pe=Math.min(d-1,o?Math.round(Re):Math.floor(Re));U===Pe&&(ne+=g[Ce+te])}}m[j+te]=ne}}}}return n.makeTensorInfo(r.shape,r.dtype,m)}var kq={kernelName:dh,backendName:"cpu",kernelFunc:wq};function Iq(e){let{inputs:t,backend:n,attrs:s}=e,{x:r}=t,{dims:a}=s;Ne(r,"reverse");let o=r.shape.length,i=w.parseAxisParam(a,r.shape);if(o===0)return Cr({inputs:{x:r},backend:n});let l=new Zt(r.shape,r.dtype),c=n.bufferSync(r);for(let u=0;u<l.size;u++){let d=l.indexToLoc(u),p=d.slice();i.forEach(h=>p[h]=r.shape[h]-1-p[h]),l.set(c.get(...p),...d)}return n.makeTensorInfo(l.shape,l.dtype,l.values)}var Sq={kernelName:Fo,backendName:"cpu",kernelFunc:Iq},Cq={kernelName:ql,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)),[c,u,d,p]=s.shape,[h,f]=N.getImageCenter(o,u,d),m=255,g=Math.sin(r),A=Math.cos(r),y=i.data.get(s.dataId).values;for(let b=0;b<c;b++){let v=b*d*u*p;for(let S=0;S<u;S++){let T=S*(d*p);for(let _=0;_<d;_++){let O=_*p;for(let P=0;P<p;P++){let D=[c,S,_,P],F=D[2],C=D[1],M=(F-h)*A-(C-f)*g,U=(F-h)*g+(C-f)*A;M=Math.round(M+h),U=Math.round(U+f);let j=a;if(typeof a!="number"&&(P===3?j=m:j=a[P]),M>=0&&M<d&&U>=0&&U<u){let X=U*(d*p),te=M*p,ne=v+X+te+P;j=y[ne]}let q=v+T+O+P;l[q]=j}}}}return{dataId:i.write(l,s.shape,s.dtype),shape:s.shape,dtype:s.dtype}}},Tq=dt($o,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}),Nq={kernelName:$o,backendName:"cpu",kernelFunc:Tq};function X6(e,t,n,s,r,a,o,i,l,c){let u=[s/r,r],d=e.values,p=t.values;if(s===0)return He(n,t.dtype);let h=He(u,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++)c?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 Eq(e){let{inputs:t,backend:n,attrs:s}=e,{indices:r,updates:a}=t,{shape:o}=s,{sliceRank:i,numUpdates:l,sliceSize:c,strides:u,outputSize:d}=N.calculateShapes(a,r,o),p=!0,h=n.bufferSync(r),f=n.bufferSync(a),m=X6(h,f,o,d,c,l,i,u,0,p);return n.makeTensorInfo(o,m.dtype,m.values)}var Rq={kernelName:Fl,backendName:"cpu",kernelFunc:Eq};function Dq(e){let{inputs:t,backend:n}=e,{condition:s,t:r,e:a}=t;Ne([s,r,a],"select");let o=s.shape.length,i=n.data.get(s.dataId).values,l=n.data.get(r.dataId).values,c=n.data.get(a.dataId).values,u=$s(r.dtype,a.dtype),d=w.makeZerosTypedArray(w.sizeFromShape(r.shape),u),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++]=c[f];return n.makeTensorInfo(r.shape,u,d)}var _q={kernelName:$l,backendName:"cpu",kernelFunc:Dq},Fq=N.SELU_SCALEALPHA,$q=N.SELU_SCALE,Oq=dt(Ol,e=>e>=0?$q*e:Fq*(Math.exp(e)-1)),Pq={kernelName:Ol,backendName:"cpu",kernelFunc:Oq},Mq=dt(zl,e=>e<0?-1:e>0?1:0),zq={kernelName:zl,backendName:"cpu",kernelFunc:Mq},Lq=dt(Po,e=>Math.sin(e)),Bq={kernelName:Po,backendName:"cpu",kernelFunc:Lq},Wq=dt(Ml,e=>Math.sinh(e)),Vq={kernelName:Ml,backendName:"cpu",kernelFunc:Wq},Uq=11920928955078125e-23,K6=Math.log(Uq)+2,Gq=dt(Ll,e=>{let t=e>-K6,n=e<K6,s=Math.exp(e),r;return n?r=s:t?r=e:r=Math.log(1+s),r}),Hq={kernelName:Ll,backendName:"cpu",kernelFunc:Gq};function jq(e){let{inputs:t,backend:n,attrs:s}=e,{x:r}=t,{blockShape:a,paddings:o}=s;Ne([r],"spaceToBatchND");let i=w.sizeFromShape(a),l=[[0,0]];l.push(...o);for(let S=1+a.length;S<r.shape.length;++S)l.push([0,0]);let c=q6.kernelFunc({inputs:{x:r},backend:n,attrs:{paddings:l,constantValue:0}}),u=N.getReshaped(c.shape,a,i,!1),d=N.getPermuted(u.length,a.length,!1),p=N.getReshapedPermuted(c.shape,a,i,!1),m=vt({inputs:{x:c},backend:n,attrs:{shape:u}}),y=ks({inputs:{x:m},backend:n,attrs:{perm:d}}),v=vt({inputs:{x:y},backend:n,attrs:{shape:p}});return n.disposeIntermediateTensorInfo(c),n.disposeIntermediateTensorInfo(m),n.disposeIntermediateTensorInfo(y),v}var qq={kernelName:Bl,backendName:"cpu",kernelFunc:jq};function Xq(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,c=n.data.get(a.dataId).values,u=n.data.get(o.dataId).values[0],[d,p,h,f,m]=b6(i,s.shape,s.dtype,l,r.dtype,c,u);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 Kq={kernelName:hh,backendName:"cpu",kernelFunc:Xq};function Zq(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),[c,u,d]=v6(i,s.shape,s.dtype,o,l);return[n.makeTensorInfo(u,s.dtype,c),n.makeTensorInfo([d.length],a.dtype,new Int32Array(d))]}var Yq={kernelName:fh,backendName:"cpu",kernelFunc:Zq};function Jq(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,[c,u]=b2(o,s.shape,s.dtype,i,l,!0);return n.makeTensorInfo(u,s.dtype,c)}var Qq={kernelName:mh,backendName:"cpu",kernelFunc:Jq};function eX(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,[c,u]=b2(o,s.shape,s.dtype,i,l);return n.makeTensorInfo(u,s.dtype,c)}var tX={kernelName:gh,backendName:"cpu",kernelFunc:eX};function nX(e){let{inputs:t,backend:n,attrs:s}=e,{sparseIndices:r,sparseValues:a,defaultValue:o}=t,{outputShape:i}=s,{sliceRank:l,numUpdates:c,sliceSize:u,strides:d,outputSize:p}=N.calculateShapes(a,r,i),h=!1,f=n.bufferSync(r),m=n.bufferSync(a),g=n.data.get(o.dataId).values[0],A=X6(f,m,i,p,u,c,l,d,g,h);return n.makeTensorInfo(i,A.dtype,A.values)}var sX={kernelName:Ah,backendName:"cpu",kernelFunc:nX};function rX(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=N.prepareSplitSize(r,a,i),c=new Array(r.shape.length).fill(0),u=r.shape.slice();return l.map(d=>{let p=[...u];p[i]=d;let h=vi({inputs:{x:r},backend:n,attrs:{begin:c,size:p}});return c[i]+=d,h})}var aX={kernelName:Wl,backendName:"cpu",kernelFunc:rX},oX={kernelName:Nc,backendName:"cpu",kernelFunc:({inputs:e,backend:t})=>{let{x:n}=e,s=t;Ne(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}}},iX=dt(da,(e,t)=>{let n=t;return isNaN(e)?NaN:e>0?1:n.alpha}),lX={kernelName:da,backendName:"cpu",kernelFunc:iX};function uX(e){let{inputs:t,backend:n,attrs:s}=e,{x:r}=t,{begin:a,end:o,strides:i,beginMask:l,endMask:c,ellipsisMask:u,newAxisMask:d,shrinkAxisMask:p}=s;Ne(r,"stridedSlice");let{nonStrided:h,$begin:f,$strides:m,size:g,newShape:A,outShape:y}=En.sliceInfo(r.shape,a,o,i,l,c,u,d,p),x=vt({inputs:{x:r},backend:n,attrs:{shape:A}}),b;if(h){let S=vi({inputs:{x},backend:n,attrs:{begin:f,size:g}});b=vt({inputs:{x:S},backend:n,attrs:{shape:y}}),n.disposeIntermediateTensorInfo(S)}else if(y.some(S=>S===0))b=n.makeTensorInfo(y,r.dtype,[]);else{let S=n.bufferSync(x),T=k6(y,S,m,f);b=n.makeTensorInfo(T.shape,T.dtype,T.values)}let v=vt({inputs:{x:b},backend:n,attrs:{shape:y}});return n.disposeIntermediateTensorInfo(x),n.disposeIntermediateTensorInfo(b),v}var cX={kernelName:Vl,backendName:"cpu",kernelFunc:uX};function dX(e){let{inputs:t,backend:n,attrs:s}=e,{separator:r,nGramWidths:a,leftPad:o,rightPad:i,padWidth:l,preserveShortSequences:c}=s,{data:u,dataSplits:d}=t,p=n.data.get(u.dataId).values,h=n.data.get(d.dataId).values,[f,m]=I6(p,h,r,a,o,i,l,c);return[n.makeTensorInfo([f.length],"string",f),n.makeTensorInfo(d.shape,"int32",m)]}var pX={kernelName:yh,backendName:"cpu",kernelFunc:dX};function hX(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],[c,u,d]=S6(i,l,r),p=u.length;return[n.makeTensorInfo([p,2],"int32",c),n.makeTensorInfo([p],"string",u),n.makeTensorInfo([2],"int32",new Int32Array(d))]}var fX={kernelName:xh,backendName:"cpu",kernelFunc:hX};function mX(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=C6(o,r);return n.makeTensorInfo(a.shape,"int32",i)}var gX={kernelName:bh,backendName:"cpu",kernelFunc:mX},AX=dt(Uo,e=>Math.tan(e)),yX={kernelName:Uo,backendName:"cpu",kernelFunc:AX},xX=dt(Go,e=>Math.tanh(e)),bX={kernelName:Go,backendName:"cpu",kernelFunc:xX};function vX(e){let{inputs:t,backend:n,attrs:s}=e,{x:r}=t,{reps:a}=s;Ne(r,"tile");let o=N6(n.bufferSync(r),a);return n.makeTensorInfo(o.shape,o.dtype,o.values)}var wX={kernelName:ca,backendName:"cpu",kernelFunc:vX};function kX(e){let{inputs:t,backend:n,attrs:s}=e,{x:r}=t,{k:a,sorted:o}=s;Ne(r,"topk");let i=n.data.get(r.dataId).values,[l,c]=R6(i,r.shape,r.dtype,a,o);return[n.makeTensorInfo(l.shape,l.dtype,l.values),n.makeTensorInfo(c.shape,c.dtype,c.values)]}var IX={kernelName:Ul,backendName:"cpu",kernelFunc:kX};function SX(e){let{inputs:t,attrs:n,backend:s}=e,{image:r,transforms:a}=t,{interpolation:o,fillMode:i,fillValue:l,outputShape:c}=n,[u,d,p,h]=r.shape,[f,m]=c??[d,p],g=[u,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 S=s.data.get(r.dataId).values,T=s.data.get(a.dataId).values;for(let O=0;O<u;++O){let P=a.shape[0]===1?T:T.subarray(O*8,O*8+8);for(let D=0;D<f;++D)for(let F=0;F<m;++F)for(let C=0;C<h;++C){let M,U=P[6]*F+P[7]*D+1;if(U===0)continue;let j=(P[0]*F+P[1]*D+P[2])/U,q=(P[3]*F+P[4]*D+P[5])/U,X=Z6(j,p,i),te=Z6(q,d,i);switch(o){case"nearest":M=DX(S,d,p,y,x,b,O,te,X,C,l);break;case"bilinear":M=_X(S,d,p,y,x,b,O,te,X,C,l);break;default:throw new Error(`Error in Transform: Expect 'nearest' or 'bilinear', but got ${o}`)}let ne=O*y+D*x+F*b+C;v[ne]=M}return s.makeTensorInfo(g,r.dtype,v)}return{dataId:s.write(v,g,r.dtype),shape:r.shape,dtype:r.dtype}}var CX={kernelName:Gl,backendName:"cpu",kernelFunc:SX};function Z6(e,t,n){switch(n){case"reflect":return TX(e,t);case"wrap":return NX(e,t);case"nearest":return RX(e,t);case"constant":default:return EX(e,t)}}function TX(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 NX(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 EX(e,t){return e}function RX(e,t){return w.clamp(0,e,t-1)}function Dd(e,t,n,s,r,a,o,i,l,c,u){let d=o*s+i*r+l*a+c;return 0<=i&&i<t&&0<=l&&l<n?e[d]:u}function DX(e,t,n,s,r,a,o,i,l,c,u){let d=Math.round(i),p=Math.round(l);return Dd(e,t,n,s,r,a,o,d,p,c,u)}function _X(e,t,n,s,r,a,o,i,l,c,u){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,c,u)+(l-p)*Dd(e,t,n,s,r,a,o,d,f,c,u),g=(f-l)*Dd(e,t,n,s,r,a,o,h,p,c,u)+(l-p)*Dd(e,t,n,s,r,a,o,h,f,c,u);return(h-i)*m+(i-d)*g}function FX(e){let{inputs:t,attrs:n,backend:s}=e,{axis:r}=n,{x:a}=t;Ne(a,"unique");let o=s.data.get(a.dataId).values,{outputValues:i,outputShape:l,indices:c}=D6(o,r,a.shape,a.dtype);return[s.makeTensorInfo(l,a.dtype,i),s.makeTensorInfo([c.length],"int32",c)]}var $X={kernelName:vh,backendName:"cpu",kernelFunc:FX};function OX(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),c=0;for(let h=0;h<o;h++)h!==a&&(l[c++]=r.shape[h]);let u=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++){u[a]=h;let f=vi({inputs:{x:r},backend:n,attrs:{begin:u,size:d}});p[h]=vt({inputs:{x:f},backend:n,attrs:{shape:l}}),n.disposeIntermediateTensorInfo(f)}return p}var PX={kernelName:Hl,backendName:"cpu",kernelFunc:OX};function MX(e){let{inputs:t,backend:n,attrs:s}=e,{x:r,segmentIds:a}=t,{numSegments:o}=s;Ne(r,"unsortedSegmentSum");let i=r.shape.length,l=a.shape.length,c=[],u=[],d=i-l,p=a;for(let f=0;f<d;++f){let m=a0({inputs:{input:p},backend:n,attrs:{dim:f+1}});p=m,u.push(m)}for(let f=0;f<o;++f){let m=w.createScalarValue(f,"int32"),g=n.makeTensorInfo([],"int32",m),A=Q7({inputs:{a:g,b:p},backend:n}),y=Ra({inputs:{x:A},backend:n,attrs:{dtype:"float32"}}),x=s0({inputs:{a:y,b:r},backend:n}),b=Rd({inputs:{x},backend:n,attrs:{axis:0,keepDims:!1}});c.push(b),u.push(g),u.push(A),u.push(y),u.push(x),u.push(b)}let h=j6({inputs:c,backend:n,attrs:{axis:0}});return u.forEach(f=>n.disposeIntermediateTensorInfo(f)),h}var zX={kernelName:Ec,backendName:"cpu",kernelFunc:MX},LX=[jU,LV,XU,ZU,HV,JU,eG,nG,rG,oG,lG,cG,pG,mG,AG,bG,wG,IG,CG,GU,NG,RG,_G,$G,UV,qV,PG,BV,zG,BG,UG,HG,WG,KG,YG,qG,QG,tH,sH,aH,iH,uH,cH,pH,fH,gH,AH,xH,yH,S2,wH,MU,IH,XV,_H,KV,FH,YV,LH,BH,VH,QV,HH,qH,KH,YH,QH,tU,sU,WV,tj,LG,sj,aj,ij,zU,aU,iU,uj,uU,dj,fj,gj,xj,vj,kj,dU,Cj,Nj,Rj,_j,$j,Ij,Pj,zj,hU,Bj,Uj,qj,mU,AU,Zj,Qj,nq,xU,rq,oq,iq,q6,dq,BU,wU,hq,VV,mq,WU,VU,UU,Aq,xq,vq,kq,Sq,Cq,Nq,IU,Rq,_q,Pq,CU,zq,Bq,Vq,TU,Hj,Hq,qq,Kq,Yq,Qq,tX,sX,aX,RU,oX,_U,lX,cX,pX,fX,gX,PU,bH,yX,bX,wX,IX,bU,CX,$X,PX,zX,aq];for(let e of LX)pa(e);var Y6={};ze(Y6,{assertNotComplex:()=>Eu,bindCanvasToFramebuffer:()=>YX,bindColorTextureToFramebuffer:()=>c0,bindTextureToProgramUniformSampler:()=>p4,bindTextureUnit:()=>u4,bindVertexBufferToProgramAttribute:()=>R2,callAndCheck:()=>Se,canBeRepresented:()=>J6,createFragmentShader:()=>t4,createFramebuffer:()=>l4,createProgram:()=>n4,createStaticIndexBuffer:()=>a4,createStaticVertexBuffer:()=>r4,createTexture:()=>o4,createVertexShader:()=>e4,getBatchDim:()=>ki,getExtensionOrThrow:()=>$d,getFramebufferErrorMessage:()=>h4,getMaxTexturesInShader:()=>A4,getNumChannels:()=>KX,getProgramUniformLocation:()=>d4,getProgramUniformLocationOrThrow:()=>c4,getRowsCols:()=>Ii,getShapeAs3D:()=>d0,getTextureShapeFromLogicalShape:()=>m4,getWebGLDisjointQueryTimerVersion:()=>y4,getWebGLErrorMessage:()=>Q6,getWebGLMaxTextureSize:()=>g4,hasExtension:()=>Ss,isCapableOfRenderingToFloatTexture:()=>x4,isDownloadFloatTextureEnabled:()=>b4,isReshapeFree:()=>Pd,isWebGLFenceEnabled:()=>v4,isWebGLVersionEnabled:()=>_2,linkProgram:()=>s4,resetMaxTextureSize:()=>JX,resetMaxTexturesInShader:()=>QX,unbindColorTextureFromFramebuffer:()=>D2,unbindTextureUnit:()=>ZX,validateFramebuffer:()=>Od,validateProgram:()=>u0,validateTextureSize:()=>i4});var wi={},N2={alpha:!1,antialias:!1,premultipliedAlpha:!1,preserveDrawingBuffer:!1,depth:!1,stencil:!1,failIfMajorPerformanceCaveat:!0};function i0(e,t){wi[e]=t}function Tr(e){if(!(e in wi)){let n=WX(e);if(n!==null)wi[e]=n;else return console.log("Could not get context for WebGL version",e),null}let t=wi[e];return t.isContextLost()?(delete wi[e],Tr(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),wi[e])}function BX(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 WX(e){if(e!==1&&e!==2)throw new Error("Cannot get WebGL rendering context, WebGL is disabled.");let t=BX(e);return t.addEventListener("webglcontextlost",n=>{n.preventDefault(),delete wi[e]},!1),e===1?t.getContext("webgl",N2)||t.getContext("experimental-webgl",N2):t.getContext("webgl2",N2)}var _d;(function(e){e[e.DENSE=0]="DENSE",e[e.SHARED_BATCH=1]="SHARED_BATCH"})(_d||(_d={}));var Is;(function(e){e[e.RENDER=0]="RENDER",e[e.UPLOAD=1]="UPLOAD",e[e.PIXELS=2]="PIXELS",e[e.DOWNLOAD=3]="DOWNLOAD"})(Is||(Is={}));var An;(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"})(An||(An={}));function Fd(e,t){return[t,e]}function VX(e,t){return e*t}function l0(e){let t=w.sizeFromShape(e),n=Math.ceil(t/4);return w.sizeToSquarishShape(n)}function Nu(e,t){return[Math.max(1,Math.ceil(t/2)),Math.max(1,Math.ceil(e/2))]}function UX(e,t){let[n,s]=Nu(e,t);return n*s*4}function E2(e,t){let n=e,s,r,a,o,i,l,c,u,d,p;return Y().getNumber("WEBGL_VERSION")===2?(s=n.R32F,r=n.R16F,a=n.RGBA16F,o=n.RGBA32F,i=n.RED,c=4,u=1,d=n.HALF_FLOAT,p=n.FLOAT):(s=e.RGBA,r=e.RGBA,a=e.RGBA,o=n.RGBA,i=e.RGBA,c=4,u=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:c,defaultNumChannels:u,textureTypeHalfFloat:d,textureTypeFloat:p}}function Se(e,t){let n=t();return Y().getBool("DEBUG")&&GX(e),n}function GX(e){let t=e.getError();if(t!==e.NO_ERROR)throw new Error("WebGL Error: "+Q6(e,t))}var HX=596e-10,jX=65504;function J6(e){return!!(Y().getBool("WEBGL_RENDER_FLOAT32_ENABLED")||e===0||HX<Math.abs(e)&&Math.abs(e)<jX)}function Q6(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 $d(e,t){return jr(e,()=>e.getExtension(t),'Extension "'+t+'" not supported on this browser.')}function e4(e,t){let n=jr(e,()=>e.createShader(e.VERTEX_SHADER),"Unable to create vertex WebGLShader.");if(Se(e,()=>e.shaderSource(n,t)),Se(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 t4(e,t){let n=jr(e,()=>e.createShader(e.FRAGMENT_SHADER),"Unable to create fragment WebGLShader.");if(Se(e,()=>e.shaderSource(n,t)),Se(e,()=>e.compileShader(n)),e.getShaderParameter(n,e.COMPILE_STATUS)===!1)throw XX(t,e.getShaderInfoLog(n)),new Error("Failed to compile fragment shader.");return n}var qX=/ERROR: [0-9]+:([0-9]+):/g;function XX(e,t){let n=qX.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),c=o.slice(s-1,s),u=o.slice(s);console.log(l.join(`
|
|
`)),console.log(t.split(`
|
|
`)[0]),console.log(`%c ${w.rightPad(c[0],i)}`,"border:1px solid red; background-color:#e3d2d2; color:#a61717"),console.log(u.join(`
|
|
`))}function n4(e){return jr(e,()=>e.createProgram(),"Unable to create WebGLProgram.")}function s4(e,t){if(Se(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 u0(e,t){if(Se(e,()=>e.validateProgram(t)),e.getProgramParameter(t,e.VALIDATE_STATUS)===!1)throw console.log(e.getProgramInfoLog(t)),new Error("Shader program validation failed.")}function r4(e,t){let n=jr(e,()=>e.createBuffer(),"Unable to create WebGLBuffer");return Se(e,()=>e.bindBuffer(e.ARRAY_BUFFER,n)),Se(e,()=>e.bufferData(e.ARRAY_BUFFER,t,e.STATIC_DRAW)),n}function a4(e,t){let n=jr(e,()=>e.createBuffer(),"Unable to create WebGLBuffer");return Se(e,()=>e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,n)),Se(e,()=>e.bufferData(e.ELEMENT_ARRAY_BUFFER,t,e.STATIC_DRAW)),n}function KX(){return Y().getNumber("WEBGL_VERSION")===2?1:4}function o4(e){return jr(e,()=>e.createTexture(),"Unable to create WebGLTexture.")}function i4(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 l4(e){return jr(e,()=>e.createFramebuffer(),"Unable to create WebGLFramebuffer.")}function R2(e,t,n,s,r,a,o){let i=e.getAttribLocation(t,n);return i===-1?!1:(Se(e,()=>e.bindBuffer(e.ARRAY_BUFFER,s)),Se(e,()=>e.vertexAttribPointer(i,r,e.FLOAT,!1,a,o)),Se(e,()=>e.enableVertexAttribArray(i)),!0)}function u4(e,t,n){f4(e,n),Se(e,()=>e.activeTexture(e.TEXTURE0+n)),Se(e,()=>e.bindTexture(e.TEXTURE_2D,t))}function ZX(e,t){f4(e,t),Se(e,()=>e.activeTexture(e.TEXTURE0+t)),Se(e,()=>e.bindTexture(e.TEXTURE_2D,null))}function c4(e,t,n){return jr(e,()=>e.getUniformLocation(t,n),'uniform "'+n+'" not present in program.')}function d4(e,t,n){return e.getUniformLocation(t,n)}function p4(e,t,n,s){Se(e,()=>u4(e,t,s)),Se(e,()=>e.uniform1i(n,s))}function YX(e){Se(e,()=>e.bindFramebuffer(e.FRAMEBUFFER,null)),Se(e,()=>e.viewport(0,0,e.canvas.width,e.canvas.height)),Se(e,()=>e.scissor(0,0,e.canvas.width,e.canvas.height))}function c0(e,t,n){Se(e,()=>e.bindFramebuffer(e.FRAMEBUFFER,n)),Se(e,()=>e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,t,0))}function D2(e,t){Se(e,()=>e.bindFramebuffer(e.FRAMEBUFFER,t)),Se(e,()=>e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,null,0))}function Od(e){let t=e.checkFramebufferStatus(e.FRAMEBUFFER);if(t!==e.FRAMEBUFFER_COMPLETE)throw new Error("Error binding framebuffer: "+h4(e,t))}function h4(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 jr(e,t,n){let s=Se(e,()=>t());if(s==null)throw new Error(n);return s}function f4(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 ki(e,t=2){return w.sizeFromShape(e.slice(0,e.length-t))}function Ii(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 d0(e){let t=[1,1,1];return e.length===0||e.length===1&&e[0]===1||(t=[ki(e),...Ii(e)]),t}function m4(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=ki(e),a=2,o=2;return e.length&&([a,o]=Ii(e)),s=r*(a/2)*(o/2),w.sizeToSquarishShape(s).map(i=>i*2)}return w.sizeToSquarishShape(s)}function p0(e){return e%2==0}function Pd(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||p0(n)&&p0(s)&&(e[0]===1||t[0]===1))return!0}return e[1]===t[1]&&p0(e[0])&&p0(t[0])}var h0,f0;function g4(e){if(h0==null){let t=Tr(e);h0=t.getParameter(t.MAX_TEXTURE_SIZE)}return h0}function JX(){h0=null}function QX(){f0=null}function A4(e){if(f0==null){let t=Tr(e);f0=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS)}return Math.min(16,f0)}function y4(e){if(e===0)return 0;let t,n=Tr(e);return Ss(n,"EXT_disjoint_timer_query_webgl2")&&e===2?t=2:Ss(n,"EXT_disjoint_timer_query")?t=1:t=0,t}function Ss(e,t){return e.getExtension(t)!=null}function _2(e){try{if(Tr(e)!=null)return!0}catch(t){return console.log("Error when getting WebGL context: ",t),!1}return!1}function x4(e){if(e===0)return!1;let t=Tr(e);if(e===1){if(!Ss(t,"OES_texture_float"))return!1}else if(!Ss(t,"EXT_color_buffer_float"))return!1;return F2(t)}function b4(e){if(e===0)return!1;let t=Tr(e);if(e===1){if(!Ss(t,"OES_texture_float")||!Ss(t,"WEBGL_color_buffer_float"))return!1}else{if(Ss(t,"EXT_color_buffer_float"))return F2(t);let s="EXT_color_buffer_half_float";if(Ss(t,s)){let r=t.getExtension(s);return eK(t,r)}return!1}return F2(t)}function F2(e){let t=E2(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 eK(e,t){let n=E2(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 v4(e){return e!==2?!1:Tr(e).fenceSync!=null}function Eu(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 $e=Y();$e.registerFlag("HAS_WEBGL",()=>$e.getNumber("WEBGL_VERSION")>0);$e.registerFlag("WEBGL_VERSION",()=>_2(2)?2:_2(1)?1:0);$e.registerFlag("WEBGL_CHECK_NUMERICAL_PROBLEMS",()=>!1);$e.registerFlag("WEBGL_BUFFER_SUPPORTED",()=>$e.get("WEBGL_VERSION")===2);$e.registerFlag("WEBGL_CPU_FORWARD",()=>!0);$e.registerFlag("WEBGL_FORCE_F16_TEXTURES",()=>!1);$e.registerFlag("WEBGL_PACK",()=>$e.getBool("HAS_WEBGL"));$e.registerFlag("WEBGL_PACK_NORMALIZATION",()=>$e.getBool("WEBGL_PACK"));$e.registerFlag("WEBGL_PACK_CLIP",()=>$e.getBool("WEBGL_PACK"));$e.registerFlag("WEBGL_PACK_DEPTHWISECONV",()=>$e.getBool("WEBGL_PACK"));$e.registerFlag("WEBGL_PACK_BINARY_OPERATIONS",()=>$e.getBool("WEBGL_PACK"));$e.registerFlag("WEBGL_PACK_UNARY_OPERATIONS",()=>$e.getBool("WEBGL_PACK"));$e.registerFlag("WEBGL_PACK_ARRAY_OPERATIONS",()=>$e.getBool("WEBGL_PACK"));$e.registerFlag("WEBGL_PACK_IMAGE_OPERATIONS",()=>$e.getBool("WEBGL_PACK"));$e.registerFlag("WEBGL_PACK_REDUCE",()=>$e.getBool("WEBGL_PACK"));$e.registerFlag("WEBGL_LAZILY_UNPACK",()=>$e.getBool("WEBGL_PACK"));$e.registerFlag("WEBGL_CONV_IM2COL",()=>$e.getBool("WEBGL_PACK"));$e.registerFlag("WEBGL_MAX_TEXTURE_SIZE",()=>g4($e.getNumber("WEBGL_VERSION")));$e.registerFlag("WEBGL_MAX_TEXTURES_IN_SHADER",()=>A4($e.getNumber("WEBGL_VERSION")));$e.registerFlag("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION",()=>{let e=$e.getNumber("WEBGL_VERSION");return e===0?0:y4(e)});$e.registerFlag("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE",()=>$e.getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")>0&&!Lc.isMobile());$e.registerFlag("WEBGL_RENDER_FLOAT32_CAPABLE",()=>x4($e.getNumber("WEBGL_VERSION")));$e.registerFlag("WEBGL_RENDER_FLOAT32_ENABLED",()=>$e.getBool("WEBGL_FORCE_F16_TEXTURES")?!1:$e.getBool("WEBGL_RENDER_FLOAT32_CAPABLE"));$e.registerFlag("WEBGL_DOWNLOAD_FLOAT_ENABLED",()=>b4($e.getNumber("WEBGL_VERSION")));$e.registerFlag("WEBGL_FENCE_API_ENABLED",()=>v4($e.getNumber("WEBGL_VERSION")));$e.registerFlag("WEBGL_SIZE_UPLOAD_UNIFORM",()=>$e.getBool("WEBGL_RENDER_FLOAT32_ENABLED")?4:0);$e.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}.`)});$e.registerFlag("WEBGL_FLUSH_THRESHOLD",()=>Lc.isMobile()?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}.`)});$e.registerFlag("CPU_HANDOFF_SIZE_THRESHOLD",()=>128);$e.registerFlag("WEBGL_USE_SHAPES_UNIFORMS",()=>!1);$e.registerFlag("TOPK_LAST_DIM_CPU_HANDOFF_SIZE_THRESHOLD",()=>1e5);$e.registerFlag("TOPK_K_CPU_HANDOFF_THRESHOLD",()=>128);function $n(){let e,t,n,s,r,a,o,i,l,c;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="",c=`
|
|
#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));
|
|
}
|
|
`,c=`
|
|
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:c}}function Si(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 m0(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 tK(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 nK(e,t,n="index"){let s=e.map((a,o)=>o),r=tK(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 $2(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 O2(){return`
|
|
int getFlatIndex(ivec3 coords) {
|
|
return coords.x * outShapeStrides[0] + coords.y * outShapeStrides[1] + coords.z;
|
|
}
|
|
`}var w4=`
|
|
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:k4}=N;function sK(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}=P2(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=>rK(h,t,n.packedInputs,n.enableShapeUniforms)).join(`
|
|
`),o=t.texShape,i=$n(),l=iK(i),c,u,d=cK(i);return t.isPacked?(c=aK(t.logicalShape,o,n.enableShapeUniforms),u=uK(i)):(c=oK(t.logicalShape,o,n.enableShapeUniforms),u=lK(i)),n.packedInputs&&(d+=fK),[d,l,u,r,c,a,n.userCode].join(`
|
|
`)}function Ru(e,t=!1){let n=e.shapeInfo.logicalShape;switch(n.length){case 0:return CK(e,t);case 1:return NK(e,t);case 2:return RK(e,t);case 3:return _K(e,t);case 4:return $K(e,t);case 5:return OK(e);case 6:return PK(e);default:throw new Error(`${n.length}-D input sampling is not yet supported`)}}function I4(e,t){switch(e.shapeInfo.logicalShape.length){case 0:return SK(e);case 1:return TK(e,t);case 2:return EK(e,t);case 3:return DK(e,t);default:return FK(e,t)}}function rK(e,t,n=!1,s){let r="";n?r+=I4(e,s):r+=Ru(e,s);let a=e.shapeInfo.logicalShape,o=t.logicalShape;return a.length<=o.length&&(n?r+=MK(e,t):r+=zK(e,t)),r}function aK(e,t,n){switch(e.length){case 0:return S4();case 1:return mK(e,t,n);case 2:return kK(e,t,n);case 3:return AK(e,t,n);default:return xK(e,t,n)}}function oK(e,t,n){switch(e.length){case 0:return S4();case 1:return gK(e,t,n);case 2:return IK(e,t,n);case 3:return yK(e,t,n);case 4:return bK(e,t,n);case 5:return vK(e,t);case 6:return wK(e,t);default:throw new Error(`${e.length}-D output sampling is not yet supported`)}}function iK(e){return`
|
|
float sampleTexture(sampler2D textureSampler, vec2 uv) {
|
|
return ${e.texture2D}(textureSampler, uv).r;
|
|
}
|
|
`}function lK(e){return`
|
|
void setOutput(float val) {
|
|
${e.output} = vec4(val, 0, 0, 0);
|
|
}
|
|
`}function uK(e){return`
|
|
void setOutput(vec4 val) {
|
|
${e.output} = val;
|
|
}
|
|
`}function cK(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);
|
|
}
|
|
|
|
${dK}
|
|
${pK}
|
|
${hK}
|
|
`}var dK=`
|
|
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);
|
|
}
|
|
`,pK=`
|
|
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);
|
|
}
|
|
`,hK=`
|
|
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);
|
|
}
|
|
`,fK=`
|
|
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 S4(){return`
|
|
int getOutputCoords() {
|
|
return 0;
|
|
}
|
|
`}function mK(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 gK(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 AK(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 yK(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;
|
|
${m0(["r","c","d"],e)}
|
|
return ivec3(r, c, d);
|
|
}
|
|
`;let s=Si(["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 xK(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 c=2;c<e.length-1;c++)o*=e[e.length-c-1],i=`
|
|
int b${c} = index / ${o};
|
|
index -= b${c} * ${o};
|
|
`+i,l=`b${c}, `+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 bK(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;
|
|
${m0(["r","c","d","d2"],e)}
|
|
return ivec4(r, c, d, d2);
|
|
}
|
|
`;let s=Si(["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 vK(e,t){let n=Si(["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 wK(e,t){let n=Si(["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 kK(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 IK(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 Ci(e){return`offset${e}`}function SK(e){let t=e.name,n="get"+t.charAt(0).toUpperCase()+t.slice(1),s=$n();return`
|
|
vec4 ${n}() {
|
|
return ${s.texture2D}(${t}, halfCR);
|
|
}
|
|
`}function CK(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=Ci(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 TK(e,t){let n=e.name,s="get"+n.charAt(0).toUpperCase()+n.slice(1),r=e.shapeInfo.texShape,a=$n();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 NK(e,t){let n=e.name,s="get"+n.charAt(0).toUpperCase()+n.slice(1);if(e.shapeInfo.isUniform)return`
|
|
float ${s}(int index) {
|
|
${Du(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=Ci(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 EK(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=$n();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 c=[Math.ceil(a[0]/2),Math.ceil(a[1]/2)],u=Math.ceil(n[1]/2);return`
|
|
vec4 ${r}(int row, int col) {
|
|
vec2 uv = packedUVfrom2D(${u}, ${c[0]}, ${c[1]}, row, col);
|
|
return ${l.texture2D}(${s}, uv);
|
|
}
|
|
`}function RK(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=_u(e,l),h=["row","col"];return`
|
|
${Ru(p,t)}
|
|
float ${r}(int row, int col) {
|
|
return ${r}(${Fu(h,i)});
|
|
}
|
|
`}if(e.shapeInfo.isUniform)return`
|
|
float ${r}(int row, int col) {
|
|
int index = round(dot(vec2(row, col), vec2(${n[1]}, 1)));
|
|
${Du(e)}
|
|
}
|
|
`;let c=a[0],u=a[1],d=Ci(s);return 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(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) / ${c}.0);
|
|
return sampleTexture(${s}, uv);
|
|
}
|
|
`: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((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) / ${u}.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(${c}, ${u}, index);
|
|
return sampleTexture(${s}, uv);
|
|
}
|
|
`}function DK(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=_u(e,p),m=["b","row","col"];return`
|
|
${I4(f,t)}
|
|
vec4 ${r}(int b, int row, int col) {
|
|
return ${r}(${Fu(m,h)});
|
|
}
|
|
`}let i=$n();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],c=o[1],u=Math.ceil(n[2]/2),d=u*Math.ceil(n[1]/2);return`
|
|
vec4 ${r}(int b, int row, int col) {
|
|
vec2 uv = packedUVfrom3D(
|
|
${l}, ${c}, ${d}, ${u}, b, row, col);
|
|
return ${i.texture2D}(${s}, uv);
|
|
}
|
|
`}function _K(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),c=i;if(c.length<n.length){let m=_u(e,c),g=["row","col","depth"];return`
|
|
${Ru(m,t)}
|
|
float ${r}(int row, int col, int depth) {
|
|
return ${r}(${Fu(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)));
|
|
${Du(e)}
|
|
}
|
|
`;let u=e.shapeInfo.texShape,d=u[0],p=u[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=Ci(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 FK(e,t){let n=e.name,s="get"+n.charAt(0).toUpperCase()+n.slice(1),r=$n();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)],c=l[0],u=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 / ${u};
|
|
int texC = index - texR * ${u};
|
|
vec2 uv = (vec2(texC, texR) + halfCR) / vec2(${u}, ${c});
|
|
return ${r.texture2D}(${n}, uv);
|
|
}
|
|
`}function $K(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:c}=w.squeezeShape(n);if(l.length<n.length){let y=_u(e,l),x=["row","col","depth","depth2"];return`
|
|
${Ru(y,t)}
|
|
float ${r}(int row, int col, int depth, int depth2) {
|
|
return ${r}(${Fu(x,c)});
|
|
}
|
|
`}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)));
|
|
${Du(e)}
|
|
}
|
|
`;let u=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&&u==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&&u==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=Ci(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 OK(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:c}=w.squeezeShape(t);if(l.length<t.length){let m=_u(e,l),g=["row","col","depth","depth2","depth3"];return`
|
|
${Ru(m)}
|
|
float ${s}(int row, int col, int depth, int depth2, int depth3) {
|
|
return ${s}(${Fu(g,c)});
|
|
}
|
|
`}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;
|
|
${Du(e)}
|
|
}
|
|
`;let u=e.shapeInfo.flatOffset,d=e.shapeInfo.texShape,p=d[0],h=d[1];if(h===i&&u==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&&u==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=Ci(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 PK(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=_u(e,r),A=["row","col","depth","depth2","depth3","depth4"];return`
|
|
${Ru(g)}
|
|
float ${s}(int row, int col, int depth,
|
|
int depth2, int depth3, int depth4) {
|
|
return ${s}(${Fu(A,a)});
|
|
}
|
|
`}let o=t[5],i=t[4]*o,l=t[3]*i,c=t[2]*l,u=t[1]*c;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(${u}, ${c}, ${l}, ${i})) +
|
|
dot(
|
|
vec2(depth3, depth4),
|
|
vec2(${o}, 1)));
|
|
${Du(e)}
|
|
}
|
|
`;let d=e.shapeInfo.flatOffset,p=e.shapeInfo.texShape,h=p[0],f=p[1];if(f===u&&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(${c}, ${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=Ci(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 * ${u} + col * ${c} + depth * ${l} +
|
|
depth2 * ${i} + depth3 * ${o} + depth4 + ${m};
|
|
vec2 uv = uvFromFlat(${h}, ${f}, index);
|
|
return sampleTexture(${n}, uv);
|
|
}
|
|
`}function Du(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 MK(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=k4(e.shapeInfo.logicalShape,t.logicalShape),l=At(o),c=o-a,u,d=["x","y","z","w","u","v"];a===0?u="":o<2&&i.length>=1?u="coords = 0;":u=i.map(y=>`coords.${d[y+c]} = 0;`).join(`
|
|
`);let p="";o<2&&a>0?p="coords":p=e.shapeInfo.logicalShape.map((y,x)=>`coords.${d[x+c]}`).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();
|
|
${u}
|
|
vec4 outputValue = get${s}(${p});
|
|
${h}
|
|
}
|
|
`}function zK(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 c=At(l),u=k4(e.shapeInfo.logicalShape,t.logicalShape),d=l-i,p,h=["x","y","z","w","u","v"];i===0?p="":l<2&&u.length>=1?p="coords = 0;":p=u.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}() {
|
|
${c} coords = getOutputCoords();
|
|
${p}
|
|
return get${s}(${f});
|
|
}
|
|
`}function At(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 P2(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 _u(e,t){let n=JSON.parse(JSON.stringify(e));return n.shapeInfo.logicalShape=t,n}function Fu(e,t){return t.map(n=>e[n]).join(", ")}function LK(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=sK(r,o,t),l=e.createProgram(i),c=null,u=e.getUniformLocation(l,"NAN",!1);Y().getNumber("WEBGL_VERSION")===1&&(c=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:c,nanLoc:u,inShapesLocations:h,inTexShapesLocations:f,outShapeLocation:m,outShapeStridesLocation:A,outTexShapeLocation:g}}function C4(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 BK(e,t,n,s,r){t.program.enableShapeUniforms||(C4(t.inShapeInfos,n),C4([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,c)=>{let u=t.program.variableNames[c],d=t.uniformLocations[u],p=t.uniformLocations[`offset${u}`],h=t.inShapesLocations[`${u}Shape`],f=t.inTexShapesLocations[`${u}TexShape`];if(h){let{uniformShape:m}=P2(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,c)}});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,c)=>{let u=t.customUniformLocations[c],d=r[c];if(l.type==="float")e.gl.uniform1fv(u,d);else if(l.type==="vec2")e.gl.uniform2fv(u,d);else if(l.type==="vec3")e.gl.uniform3fv(u,d);else if(l.type==="vec4")e.gl.uniform4fv(u,d);else if(l.type==="int")e.gl.uniform1iv(u,d);else if(l.type==="ivec2")e.gl.uniform2iv(u,d);else if(l.type==="ivec3")e.gl.uniform3iv(u,d);else if(l.type==="ivec4")e.gl.uniform4iv(u,d);else throw Error(`uniform type ${l.type} is not supported yet.`)}),e.executeProgram()}function WK(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:c,uniformShape:u,keptDims:d}=P2(e.packedInputs,o.shape,l),p="",h="",f="";if(u.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(u.length===2&&!e.packedInputs)h=`${u[0]>1}_${u[1]>1}`;else if(u.length>2&&!e.packedInputs){let v=w.computeStrides(u);f=`${v[0]===l[1]}_${v[v.length-1]===l[1]}`}let m=o.shape.length,g=u.length===2&&w.arraysEqual(o.shape,l),A=w.sizeFromShape(o.shape)===1,y=N.getBroadcastDims(o.shape,n.shape),x=!e.packedInputs&&m===n.shape.length&&w.arraysEqual(l,n.texData.texShape),b=e.packedInputs||u.length>2?"":`${l[0]>1}_${l[1]>1}`;s+=`${m}_${x}_${c?d:""}_${u.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 Cs(e){return Y().getBool("WEBGL_USE_SHAPES_UNIFORMS")&&e<=4}var VK=class{constructor(e){this.variableNames=["A"],this.packedInputs=!1,this.packedOutput=!0,this.outPackingScheme=_d.DENSE,this.customUniforms=[{name:"texShape",type:"ivec2"}];let t=$n();this.outputShape=e,this.enableShapeUniforms=Cs(this.outputShape.length),this.userCode=`
|
|
ivec3 outCoordsFromFlatIndex(int index) {
|
|
${this.enableShapeUniforms?m0(["r","c","d"],e):Si(["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;
|
|
}
|
|
`}},UK=class{constructor(e){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outPackingScheme=_d.DENSE,this.customUniforms=[{name:"texShape",type:"ivec2"}];let t=$n();this.outputShape=e,this.enableShapeUniforms=Cs(this.outputShape.length),this.userCode=`
|
|
ivec3 outCoordsFromFlatIndex(int index) {
|
|
${this.enableShapeUniforms?m0(["r","c","d"],e):Si(["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;
|
|
}
|
|
`}},GK=class{constructor(e){this.variableNames=["A"],this.outTexUsage=Is.DOWNLOAD;let t=$n();this.outputShape=e,this.userCode=`
|
|
${w4}
|
|
|
|
void main() {
|
|
float x = getAAtOutCoords();
|
|
${t.output} = encode_float(x);
|
|
}
|
|
`}},HK=class{constructor(e){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!1,this.outTexUsage=Is.DOWNLOAD;let t=$n();this.outputShape=e,this.userCode=`
|
|
${w4}
|
|
|
|
void main() {
|
|
ivec3 coords = getOutputCoords();
|
|
float x = getChannel(getAAtOutCoords(), vec2(coords.y, coords.z));
|
|
${t.output} = encode_float(x);
|
|
}
|
|
`}},jK=class{constructor(e,t=!1){this.variableNames=["A"],this.customUniforms=[{name:"texShape",type:"ivec2"}];let n=$n();this.outputShape=e,this.enableShapeUniforms=Cs(this.outputShape.length);let s="result";t&&(s="floor(result * 255. + 0.5)"),this.userCode=`
|
|
${this.enableShapeUniforms?O2():$2(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.);
|
|
}
|
|
`}},qK=class{constructor(e,t=!1){this.variableNames=["A"],this.packedInputs=!1,this.packedOutput=!0,this.customUniforms=[{name:"texShape",type:"ivec2"}];let n=$n();this.outputShape=e,this.enableShapeUniforms=Cs(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?O2():$2(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};
|
|
}
|
|
`}},T4={};ze(T4,{bindVertexProgramAttributeStreams:()=>P4,createBufferFromOutputTexture:()=>L4,createFloat16MatrixTexture:()=>_4,createFloat16PackedMatrixTexture:()=>O4,createFloat32MatrixTexture:()=>D4,createIndexBuffer:()=>R4,createPackedMatrixTexture:()=>$4,createUnsignedBytesMatrixTexture:()=>F4,createVertexBuffer:()=>E4,createVertexShader:()=>N4,downloadByteEncodedFloatMatrixFromOutputTexture:()=>W4,downloadFloat32MatrixFromBuffer:()=>B4,downloadMatrixFromPackedOutputTexture:()=>U4,downloadPackedMatrixFromBuffer:()=>V4,getInternalFormatForFloat16MatrixTexture:()=>z2,getInternalFormatForFloat16PackedMatrixTexture:()=>W2,getInternalFormatForFloat32MatrixTexture:()=>M2,getInternalFormatForPackedMatrixTexture:()=>B2,getInternalFormatForUnsignedBytesMatrixTexture:()=>L2,uploadDenseMatrixToTexture:()=>M4,uploadPixelDataToTexture:()=>z4});function N4(e){let t=$n(),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 e4(e,n)}function E4(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 r4(e,t)}function R4(e){let t=new Uint16Array([0,1,2,2,1,3]);return a4(e,t)}function Md(e,t,n,s,r,a){i4(t,n);let o=o4(e),i=e.TEXTURE_2D;return Se(e,()=>e.bindTexture(i,o)),Se(e,()=>e.texParameteri(i,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE)),Se(e,()=>e.texParameteri(i,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE)),Se(e,()=>e.texParameteri(i,e.TEXTURE_MIN_FILTER,e.NEAREST)),Se(e,()=>e.texParameteri(i,e.TEXTURE_MAG_FILTER,e.NEAREST)),Se(e,()=>e.texImage2D(i,0,s,t,n,0,r,a,null)),Se(e,()=>e.bindTexture(e.TEXTURE_2D,null)),o}function M2(e){return e.internalFormatFloat}function D4(e,t,n,s){let[r,a]=Fd(t,n);return Md(e,r,a,M2(s),s.textureFormatFloat,e.FLOAT)}function z2(e){return e.internalFormatHalfFloat}function _4(e,t,n,s){let[r,a]=Fd(t,n);return Md(e,r,a,z2(s),s.textureFormatFloat,s.textureTypeHalfFloat)}function L2(e){return e.downloadTextureFormat}function F4(e,t,n,s){let[r,a]=Fd(t,n);return Md(e,r,a,L2(s),e.RGBA,e.UNSIGNED_BYTE)}function B2(e){return e.internalFormatPackedFloat}function $4(e,t,n,s){let[r,a]=Nu(t,n);return Md(e,r,a,B2(s),e.RGBA,e.FLOAT)}function W2(e){return e.internalFormatPackedHalfFloat}function O4(e,t,n,s){let[r,a]=Nu(t,n);return Md(e,r,a,W2(s),e.RGBA,s.textureTypeHalfFloat)}function P4(e,t,n){let s=0,r=3*4,a=3*4+2*4;return Se(e,()=>e.bindBuffer(e.ARRAY_BUFFER,n)),R2(e,t,"clipSpacePos",n,3,a,s)&&R2(e,t,"uv",n,2,a,r)}function M4(e,t,n,s,r,a){Se(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),Se(e,()=>e.texImage2D(e.TEXTURE_2D,0,l,n,s,0,e.RGBA,i,o)),Se(e,()=>e.bindTexture(e.TEXTURE_2D,null))}function z4(e,t,n){Se(e,()=>e.bindTexture(e.TEXTURE_2D,t)),n.data instanceof Uint8Array?Se(e,()=>e.texImage2D(e.TEXTURE_2D,0,e.RGBA,n.width,n.height,0,e.RGBA,e.UNSIGNED_BYTE,n.data)):Se(e,()=>e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,n)),Se(e,()=>e.bindTexture(e.TEXTURE_2D,null))}function L4(e,t,n,s){let r=e.createBuffer();Se(e,()=>e.bindBuffer(e.PIXEL_PACK_BUFFER,r));let i=4*4*t*n;return Se(e,()=>e.bufferData(e.PIXEL_PACK_BUFFER,i,e.STREAM_READ)),Se(e,()=>e.readPixels(0,0,n,t,e.RGBA,e.FLOAT,0)),Se(e,()=>e.bindBuffer(e.PIXEL_PACK_BUFFER,null)),r}function B4(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 W4(e,t,n,s){let[r,a]=Fd(t,n),o=4,i=new Uint8Array(VX(t*n,o));return Se(e,()=>e.readPixels(0,0,r,a,s.downloadTextureFormat,e.UNSIGNED_BYTE,i)),new Float32Array(i.buffer)}function V4(e,t,n,s,r,a,o,i){let l=e,c=new Float32Array(UX(a,o));return l.bindBuffer(l.PIXEL_PACK_BUFFER,t),l.getBufferSubData(l.PIXEL_PACK_BUFFER,0,c),l.bindBuffer(l.PIXEL_PACK_BUFFER,null),c}function U4(e,t,n){let s=new Float32Array(t*n*4);return Se(e,()=>e.readPixels(0,0,n,t,e.RGBA,e.FLOAT,s)),s}var g0=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,i0(t,e)):this.gl=Tr(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=$d(this.gl,r),Ss(this.gl,a))this.textureHalfFloatExtension=$d(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),Ss(this.gl,s))this.colorBufferHalfFloatExtension=$d(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",Ss(this.gl,n))this.colorBufferFloatExtension=this.gl.getExtension(n);else if(Ss(this.gl,s))this.colorBufferHalfFloatExtension=this.gl.getExtension(s);else throw new Error("GL context does not support color renderable floats");this.vertexBuffer=E4(this.gl),this.indexBuffer=R4(this.gl),this.framebuffer=l4(this.gl),this.textureConfig=E2(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;Se(e,()=>e.finish()),Se(e,()=>e.bindFramebuffer(e.FRAMEBUFFER,null)),Se(e,()=>e.deleteFramebuffer(this.framebuffer)),Se(e,()=>e.bindBuffer(e.ARRAY_BUFFER,null)),Se(e,()=>e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,null)),Se(e,()=>e.deleteBuffer(this.indexBuffer)),this.disposed=!0}createFloat32MatrixTexture(e,t){return this.throwIfDisposed(),D4(this.gl,e,t,this.textureConfig)}createFloat16MatrixTexture(e,t){return this.throwIfDisposed(),_4(this.gl,e,t,this.textureConfig)}createUnsignedBytesMatrixTexture(e,t){return this.throwIfDisposed(),F4(this.gl,e,t,this.textureConfig)}uploadPixelDataToTexture(e,t){this.throwIfDisposed(),z4(this.gl,e,t)}uploadDenseMatrixToTexture(e,t,n,s){this.throwIfDisposed(),M4(this.gl,e,t,n,s,this.textureConfig)}createFloat16PackedMatrixTexture(e,t){return this.throwIfDisposed(),O4(this.gl,e,t,this.textureConfig)}createPackedMatrixTexture(e,t){return this.throwIfDisposed(),$4(this.gl,e,t,this.textureConfig)}deleteMatrixTexture(e){this.throwIfDisposed(),this.outputTexture===e&&(D2(this.gl,this.framebuffer),this.outputTexture=null),Se(this.gl,()=>this.gl.deleteTexture(e))}downloadByteEncodedFloatMatrixFromOutputTexture(e,t,n){return this.downloadMatrixDriver(e,()=>W4(this.gl,t,n,this.textureConfig))}downloadPackedMatrixFromBuffer(e,t,n,s,r,a){return V4(this.gl,e,t,n,s,r,a,this.textureConfig)}downloadFloat32MatrixFromBuffer(e,t){return B4(this.gl,e,t)}createBufferFromTexture(e,t,n){this.bindTextureToFrameBuffer(e);let s=L4(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,()=>U4(this.gl,t,n))}createProgram(e){this.throwIfDisposed();let t=this.gl,n=t4(t,e);this.vertexShader==null&&(this.vertexShader=N4(t));let s=n4(t);return Se(t,()=>t.attachShader(s,this.vertexShader)),Se(t,()=>t.attachShader(s,n)),s4(t,s),this.debug&&u0(t,s),this.vertexAttrsAreBound||(this.setProgram(s),this.vertexAttrsAreBound=P4(t,this.program,this.vertexBuffer)),s}deleteProgram(e){this.throwIfDisposed(),e===this.program&&(this.program=null),e!=null&&Se(this.gl,()=>this.gl.deleteProgram(e))}setProgram(e){this.throwIfDisposed(),this.program=e,this.program!=null&&this.debug&&u0(this.gl,this.program),Se(this.gl,()=>this.gl.useProgram(e))}getUniformLocation(e,t,n=!0){return this.throwIfDisposed(),n?c4(this.gl,e,t):d4(this.gl,e,t)}getAttributeLocation(e,t){return this.throwIfDisposed(),Se(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(),p4(this.gl,e,t,n)}setOutputMatrixTexture(e,t,n){this.setOutputMatrixTextureDriver(e,n,t)}setOutputPackedMatrixTexture(e,t,n){this.throwIfDisposed();let[s,r]=Nu(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&&u0(this.gl,this.program),Od(this.gl)}executeProgram(){this.throwIfDisposed(),this.throwIfNoProgram();let e=this.gl;this.debug&&this.debugValidate(),Se(e,()=>e.drawElements(e.TRIANGLES,6,e.UNSIGNED_SHORT,0))}blockUntilAllProgramsCompleted(){this.throwIfDisposed(),Se(this.gl,()=>this.gl.finish())}getQueryTimerExtension(){return this.disjointQueryTimerExtension==null&&(this.disjointQueryTimerExtension=$d(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=XK(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(),c0(this.gl,e,this.framebuffer),this.debug&&Od(this.gl)}unbindTextureToFrameBuffer(){this.outputTexture!=null?(c0(this.gl,this.outputTexture,this.framebuffer),this.debug&&Od(this.gl)):D2(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;c0(s,e,this.framebuffer),this.debug&&Od(s),this.outputTexture=e,Se(s,()=>s.viewport(0,0,t,n)),Se(s,()=>s.scissor(0,0,t,n))}setOutputMatrixWriteRegionDriver(e,t,n,s){this.throwIfDisposed(),Se(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 XK(e){let t=0;for(;t<e.length&&e[t]();++t);return t-1}var{addImpl:KK,bincountImpl:G4,bincountReduceImpl:ZK,ceilImpl:YK,concatImpl:JK,equalImpl:QK,expImpl:eZ,expm1Impl:tZ,floorImpl:nZ,gatherNdImpl:sZ,gatherV2Impl:rZ,greaterImpl:aZ,greaterEqualImpl:oZ,lessImpl:iZ,lessEqualImpl:lZ,linSpaceImpl:uZ,logImpl:cZ,maxImpl:dZ,maximumImpl:pZ,minimumImpl:hZ,multiplyImpl:fZ,negImpl:mZ,notEqualImpl:gZ,prodImpl:AZ,rangeImpl:yZ,rsqrtImpl:xZ,sigmoidImpl:bZ,simpleAbsImpl:H4,sliceImpl:vZ,sparseFillEmptyRowsImpl:wZ,sparseReshapeImpl:kZ,sparseSegmentReductionImpl:j4,sqrtImpl:IZ,stridedSliceImpl:SZ,stringNGramsImpl:CZ,stringSplitImpl:TZ,stringToHashBucketFastImpl:NZ,subImpl:EZ,tileImpl:RZ,topKImpl:DZ,transposeImpl:V2,uniqueImpl:_Z}=q7;function q4(e,t){return["x","y","z","w","u","v"].slice(0,t).map(n=>`${e}.${n}`)}function On(e,t){return t===1?[e]:q4(e,t)}function FZ(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 $Z=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=On("rc",t),s=At(t),r=PZ(t,e,n),a=MZ(t,e[e.length-1],e[e.length-2],n),o=zZ(e,n);this.userCode=`
|
|
void main() {
|
|
${s} rc = getOutputCoords();
|
|
|
|
if(${r}) {
|
|
setOutput(vec4(0));
|
|
} else {
|
|
${a}
|
|
|
|
setOutput(vec4(${o}));
|
|
}
|
|
}
|
|
`}}};function OZ(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 PZ(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 MZ(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 zZ(e,t){let n=e.length,s=OZ(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 X4=class{constructor(e,t){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.customUniforms=[{name:"inputShape",type:"ivec3"}],this.outputShape=e,this.enableShapeUniforms=Cs(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=`
|
|
${LZ(t,this.enableShapeUniforms)}
|
|
${this.enableShapeUniforms?O2():$2(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 LZ(e,t){return`
|
|
ivec3 inputCoordsFromReshapedOutCoords(int index) {
|
|
${t?nK(["r","c","d"],"inputShape"):Si(["r","c","d"],e)}
|
|
return ivec3(r, c, d);
|
|
}
|
|
`}var BZ=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=Z4(t,n),r=Y4(e,s,n);r in this.freeTextures||(this.freeTextures[r]=[]),r in this.usedTextures||(this.usedTextures[r]=[]);let a=K4(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===An.PACKED_2X2_FLOAT32?o=this.gpgpu.createPackedMatrixTexture(e[0],e[1]):s===An.PACKED_2X2_FLOAT16?o=this.gpgpu.createFloat16PackedMatrixTexture(e[0],e[1]):s===An.UNPACKED_FLOAT32?o=this.gpgpu.createFloat32MatrixTexture(e[0],e[1]):s===An.UNPACKED_FLOAT16?o=this.gpgpu.createFloat16MatrixTexture(e[0],e[1]):s===An.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=Z4(n,s),a=Y4(t,r,s);a in this.freeTextures||(this.freeTextures[a]=[]);let o=K4(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],c=l.indexOf(e);if(c<0)throw new Error("Cannot release a texture that was never provided by this texture manager");l.splice(c,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 WZ(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 K4(e,t,n,s,r){let a=VZ(t,s),o;if(r){let[l,c]=Nu(e[0],e[1]);o=l*c}else{let[l,c]=Fd(e[0],e[1]);o=l*c}let i=WZ(n,a);return o*i}function VZ(e,t){switch(e){case An.PACKED_2X2_FLOAT32:return B2(t);case An.PACKED_2X2_FLOAT16:return W2(t);case An.UNPACKED_FLOAT32:return M2(t);case An.UNPACKED_FLOAT16:return z2(t);case An.PACKED_4X1_UNSIGNED_BYTE:return L2(t);default:throw new Error(`Unknown physical texture type ${e}`)}}function UZ(e){return Y().getBool("WEBGL_RENDER_FLOAT32_ENABLED")?e?An.PACKED_2X2_FLOAT32:An.UNPACKED_FLOAT32:e?An.PACKED_2X2_FLOAT16:An.UNPACKED_FLOAT16}function Z4(e,t){if(e===Is.UPLOAD)return An.PACKED_2X2_FLOAT32;if(e===Is.RENDER||e==null)return UZ(t);if(e===Is.DOWNLOAD||e===Is.PIXELS)return An.PACKED_4X1_UNSIGNED_BYTE;throw new Error(`Unknown logical texture type ${e}`)}function Y4(e,t,n){return`${e[0]}_${e[1]}_${t}_${n}`}var _a=class{constructor(e,t){this.variableNames=["A"],this.outputShape=e,this.enableShapeUniforms=Cs(this.outputShape.length),this.userCode=`
|
|
float unaryOperation(float x) {
|
|
${t}
|
|
}
|
|
|
|
void main() {
|
|
float x = getAAtOutCoords();
|
|
float y = unaryOperation(x);
|
|
|
|
setOutput(y);
|
|
}
|
|
`}},or="if (isnan(x)) return x;",GZ="return x;",J4="return abs(x);",HZ="return (x >= 0.0) ? x : (exp(x) - 1.0);",jZ=or+`
|
|
return (x < 0.0) ? 0.0 : x;
|
|
`,qZ=or+`
|
|
return (x < 0.0) ? 0.0 : min(6.0, x);
|
|
`,A0="return x;",XZ="return 1.0 / (1.0 + exp(-1.0 * x));",KZ="return x;",ZZ=`
|
|
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;
|
|
`,YZ=`
|
|
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;
|
|
`,JZ=`
|
|
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;
|
|
`,QZ="return 1.0 / (1.0 + exp(-1.0 * x));",$u=class{constructor(e,t){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=e,this.enableShapeUniforms=Cs(this.outputShape.length),this.userCode=`
|
|
vec4 unaryOperation(vec4 x) {
|
|
${t}
|
|
}
|
|
|
|
void main() {
|
|
vec4 x = getAAtOutCoords();
|
|
vec4 y = unaryOperation(x);
|
|
|
|
setOutput(y);
|
|
}
|
|
`}},eY=class{constructor(e){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!1,this.outputShape=e;let t=e.length,n=On("rc",t),s=At(t),r=FZ(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}));
|
|
}
|
|
`}},tY=br.whereImpl,nY=1e-7,sY=1e-4,y0={};function rY(e){return e in y0||(y0[e]={}),y0[e]}var aY=Y().getNumber("CPU_HANDOFF_SIZE_THRESHOLD"),oY=600;function iY(){return Y().global.screen==null?1024:Y().global.screen.height*Y().global.screen.width*window.devicePixelRatio*oY/1024/1024}var Ou=class extends hc{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=Tr(Y().getNumber("WEBGL_VERSION"));this.binaryCache=rY(Y().getNumber("WEBGL_VERSION")),this.gpgpu=new g0(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 BZ(this.gpgpu),this.numMBBeforeWarning=iY(),this.texData=new $p(this,ts())}nextDataId(){return Ou.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:Is.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:Is.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 $u(o,A0):d=new _a(o,A0);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,c;l&&(c=w.now());let u;if(s==="complex64"){let d=this.readSync(r.real.dataId),p=this.readSync(r.imag.dataId);u=N.mergeRealAndImagArrays(d,p)}else u=this.getValuesFromTexture(e);return l&&(this.downloadWaitMs+=w.now()-c),this.convertAndCacheOnCPU(e,u)}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 $u(s,A0):h=new _a(s,A0);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,c;if(a!=="complex64"&&Y().get("WEBGL_BUFFER_SUPPORTED")){c=this.decode(e);let h=this.texData.get(c.dataId);l=this.gpgpu.createBufferFromTexture(h.texture,...l0(s))}this.pendingRead.set(e,[]),a!=="complex64"&&await this.gpgpu.createAndWaitForFence();let u;if(a==="complex64"){let h=await Promise.all([this.read(o.real.dataId),this.read(o.imag.dataId)]),f=h[0],m=h[1];u=N.mergeRealAndImagArrays(f,m)}else if(l==null)u=this.getValuesFromTexture(e);else{let h=w.sizeFromShape(s);u=this.gpgpu.downloadFloat32MatrixFromBuffer(l,h)}if(c!=null&&this.disposeIntermediateTensorInfo(c),l!=null){let h=this.gpgpu.gl;Se(h,()=>h.deleteBuffer(l))}let d=this.convertAndCacheOnCPU(e,u),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)&&ts().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{throw new Error("Failed to decode encoded string bytes into utf-8")}return He(e.shape,e.dtype,n)}checkNumericalProblems(e){if(e!=null)for(let t=0;t<e.length;t++){let n=e[t];if(!J6(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,...l0(t)).subarray(0,r);return this.disposeIntermediateTensorInfo(d),h}let a=Y().getBool("WEBGL_PACK")&&s===!0,o=a?d0(t):t,i=a?new HK(o):new GK(o),l=this.runWebGLProgram(i,[{shape:o,dtype:n,dataId:e}],"float32"),c=this.texData.get(l.dataId),u=this.gpgpu.downloadByteEncodedFloatMatrixFromOutputTexture(c.texture,c.texShape[0],c.texShape[1]).subarray(0,r);return this.disposeIntermediateTensorInfo(l),u}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,c)=>({name:a[c],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 c=this.texData.get(e);c.texture=null,c.texShape=null,c.isPacked=!1,c.slice=null}getTexture(e){return this.uploadToGPU(e),this.texData.get(e).texture}getDataInfo(e){return this.texData.get(e)}shouldExecuteOnCPU(e,t=aY){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){N.warn("tf.where() in webgl locks the UI thread. Call tf.whereAsync() instead");let t=e.dataSync();return tY(e.shape,t)}packedUnaryOp(e,t,n){let s=new $u(e.shape,t),r=this.compileAndRun(s,[e],n);return ts().makeTensorFromDataId(r.dataId,r.shape,r.dtype)}abs(e){if(this.shouldExecuteOnCPU([e])&&e.dtype!=="complex64"){let s=H4(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,J4,e.dtype);let t=new _a(e.shape,J4),n=this.compileAndRun(t,[e]);return ts().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 ts().makeTensorFromDataId(s,e,t,this)}unpackTensor(e){let t=new eY(e.shape);return this.runWebGLProgram(t,[e],e.dtype)}packTensor(e){let t=new $Z(e.shape),n=!0;return this.runWebGLProgram(t,[e],e.dtype,null,n)}packedReshape(e,t){let n=[ki(e.shape),...Ii(e.shape)],s={dtype:e.dtype,shape:n,dataId:e.dataId},r=[ki(t),...Ii(t)],a=new X4(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=d0(s),o,i=l0(a);n?o=new UK(a):o=new VK(a);let l=!0,c=[i],u=this.runWebGLProgram(o,[{shape:a,dtype:r,dataId:e}],r,c,l);return{dtype:r,shape:s,dataId:u.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===_d.DENSE){let m=l0(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&&!Pd(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 c={shape:a.shape,texData:o,isUniform:!1},u=WK(e,l,c),d=this.getAndSaveBinary(u,()=>LK(this.gpgpu,e,l,c)),p=this.activeTimers!=null,h;p&&(h=this.startTimer()),BK(this.gpgpu,d,l,c,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=G(()=>{if(!Y().get("WEBGL_RENDER_FLOAT32_ENABLED")){let e=Y().getBool("DEBUG");Y().set("DEBUG",!1);let t=this.abs(Ee(1e-8)).dataSync()[0];if(Y().set("DEBUG",e),t>0)return 32}return 16})),this.floatPrecisionValue}epsilon(){return this.floatPrecision()===32?nY:sY}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,c;l&&(c=w.now());let u=t.texShape;if(u==null&&(u=m4(n,i),t.texShape=u),r!=null){let d=d0(n),p,h=u[1],f=u[0],m=r instanceof Uint8Array||r instanceof Uint8ClampedArray;i?([h,f]=Nu(u[0],u[1]),p=new qK(d,m)):p=new jK(d,m);let g=this.makeTensorInfo([f,h],s);m?this.texData.get(g.dataId).usage=Is.PIXELS:this.texData.get(g.dataId).usage=Is.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()-c)}else{let d=this.acquireTexture(u,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=lY(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)}};Ou.nextDataId=0;function lY(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 uY="3.10.0";function Q4(){Y().set("WEBGL_FORCE_F16_TEXTURES",!0)}Lc.isBrowser()&&tu("webgl",()=>new Ou,2);var cY={forceHalfFloat:Q4},ek=`
|
|
if (isnan(a)) return a;
|
|
if (isnan(b)) return b;
|
|
`,Pu=class{constructor(e,t,n){this.variableNames=["A","B"],this.outputShape=N.assertAndGetBroadcastShape(t,n),this.enableShapeUniforms=Cs(this.outputShape.length),this.userCode=`
|
|
float binaryOperation(float a, float b) {
|
|
${e}
|
|
}
|
|
|
|
void main() {
|
|
float a = getAAtOutCoords();
|
|
float b = getBAtOutCoords();
|
|
setOutput(binaryOperation(a, b));
|
|
}
|
|
`}},x0=`
|
|
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;
|
|
`,zd=class{constructor(e,t,n,s=!1){this.variableNames=["A","B"],this.supportsBroadcasting=!0,this.packedInputs=!0,this.packedOutput=!0,this.outputShape=N.assertAndGetBroadcastShape(t,n);let r=this.outputShape.length;this.enableShapeUniforms=Cs(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=`
|
|
${At(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=On("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 dY={kernelName:mo,backendName:"webgl",kernelFunc:ds};function Fa(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 pY={kernelName:Up,backendName:"webgl",kernelFunc:Fa},tk="return (a < 0.) ? b * a : a;",nk=`
|
|
vec4 aLessThanZero = vec4(lessThan(a, vec4(0.)));
|
|
return (aLessThanZero * (b * a)) + ((vec4(1.0) - aLessThanZero) * a);
|
|
`;function hY(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 zd(nk,r.shape,o.shape):new Pu(tk,r.shape,o.shape),l=n.runWebGLProgram(i,[r,o],"float32");return n.disposeIntermediateTensorInfo(o),l}var fY={kernelName:go,backendName:"webgl",kernelFunc:hY},sk="return (a < 0.) ? b * a : a;",rk=`
|
|
vec4 aLessThanZero = vec4(lessThan(a, vec4(0.)));
|
|
return (aLessThanZero * (b * a)) + ((vec4(1.0) - aLessThanZero) * a);
|
|
`;function mY(e){let{inputs:t,backend:n}=e,{x:s,alpha:r}=t,a=Y().getBool("WEBGL_PACK_BINARY_OPERATIONS")?new zd(rk,s.shape,r.shape):new Pu(sk,s.shape,r.shape);return n.runWebGLProgram(a,[s,r],"float32")}var gY={kernelName:Eo,backendName:"webgl",kernelFunc:mY},ak="if (isnan(x)) return x;",AY=`
|
|
if (isnan(a)) return a;
|
|
if (isnan(b)) return b;
|
|
`,yY=`
|
|
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 nt({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 c=Y().getBool("WEBGL_PACK_UNARY_OPERATIONS")&&t!=null,u;return c?u=new $u(o.shape,t):u=new _a(o.shape,e),i.runWebGLProgram(u,[o],l)}}function yn({opSnippet:e,packedOpSnippet:t,checkOutOfBounds:n=!1,supportsComplex:s=!1,cpuKernelImpl:r,dtype:a}){return({inputs:o,backend:i})=>{let{a:l,b:c}=o,u=i;if(s&&l.dtype==="complex64"){let f=u.texData.get(l.dataId),m=u.texData.get(c.dataId),[g,A]=[[f.complexTensorInfos.real,m.complexTensorInfos.real],[f.complexTensorInfos.imag,m.complexTensorInfos.imag]].map(x=>{let[b,v]=x,S={dataId:b.dataId,dtype:b.dtype,shape:l.shape},T={dataId:v.dataId,dtype:v.dtype,shape:c.shape},_=new Pu(e,l.shape,c.shape);return u.runWebGLProgram(_,[S,T],$s(b.dtype,v.dtype))}),y=Fa({inputs:{real:g,imag:A},backend:u});return u.disposeIntermediateTensorInfo(g),u.disposeIntermediateTensorInfo(A),y}let d=a||$s(l.dtype,c.dtype);if((l.dtype==="string"||c.dtype==="string"||u.shouldExecuteOnCPU([l,c]))&&r!=null){let f=u.texData.get(l.dataId).values,m=u.texData.get(c.dataId).values,g=l.dtype==="string"?N.fromUint8ToStringArray(f):f,A=l.dtype==="string"?N.fromUint8ToStringArray(m):m,[y,x]=r(l.shape,c.shape,g,A,d),b=u.makeTensorInfo(x,d),v=u.texData.get(b.dataId);return v.values=y,b}let p=Y().getBool("WEBGL_PACK_BINARY_OPERATIONS")&&t!=null,h;return p?h=new zd(t,l.shape,c.shape,n):h=new Pu(e,l.shape,c.shape),u.runWebGLProgram(h,[l,c],d)}}function b0(e,t=!1){if(e==="linear")return t?KZ:GZ;if(e==="relu")return t?YZ:jZ;if(e==="elu")return t?ZZ:HZ;if(e==="relu6")return t?JZ:qZ;if(e==="prelu")return t?rk:sk;if(e==="leakyrelu")return t?nk:tk;if(e==="sigmoid")return t?QZ:XZ;throw new Error(`Activation ${e} has not been implemented for the WebGL backend.`)}var ok=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=Cs(this.outputShape.length);let c=s?e[1]:e[2],u=Math.ceil(c/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 = ${u}.0;
|
|
|
|
vec4 dot2x2ARowBCol(ivec3 rc) {
|
|
vec4 result = vec4(0);
|
|
for (int i = 0; i < ${u}; 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);
|
|
}
|
|
`}},ik={REAL:"return areal * breal - aimag * bimag;",IMAG:"return areal * bimag + aimag * breal;"},lk=class{constructor(e,t,n){this.variableNames=["AReal","AImag","BReal","BImag"],this.outputShape=N.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));
|
|
}
|
|
`}},uk="return a * b;";function U2(e){let{inputs:t,backend:n}=e,{a:s,b:r}=t,a=N.upcastType(s.dtype,r.dtype);if(s.dtype==="complex64"){let i=n.texData.get(s.dataId),l=n.texData.get(r.dataId),c=new lk(ik.REAL,s.shape,r.shape),u=new lk(ik.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(c,d,"float32"),h=n.runWebGLProgram(u,d,"float32"),f=Fa({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),[c,u]=fZ(s.shape,r.shape,i.values,l.values,a),d=n.makeTensorInfo(u,a),p=n.texData.get(d.dataId);return p.values=c,d}let o;return Y().getBool("WEBGL_PACK_BINARY_OPERATIONS")?o=new zd(uk,s.shape,r.shape):o=new Pu(uk,s.shape,r.shape),n.runWebGLProgram(o,[s,r],a)}var xY={kernelName:So,backendName:"webgl",kernelFunc:U2};function bY(e,t,n){let s=[ki(e.shape),...Ii(e.shape)],r={dtype:e.dtype,shape:s,dataId:e.dataId},a=[ki(t),...Ii(t)],o=new X4(a,s),i=!0,l=[s],c=n.runWebGLProgram(o,[r],e.dtype,l,i);return{dataId:c.dataId,shape:t,dtype:c.dtype}}function we(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),c=w.sizeFromShape(l);w.assert(i===c,()=>`The new shape (${l}) has ${c} elements and the old shape (${r.shape}) has ${i} elements. The new shape and old shape must have the same number of elements.`);let u=o.texData.get(r.dataId);return u.isPacked&&!Pd(r.shape,l)&&!(u.texture!==null&&Pd(u.shape,l))?bY(r,l,o):(o.incRef(r.dataId),{dataId:r.dataId,shape:l,dtype:r.dtype})}var vY={kernelName:_l,backendName:"webgl",kernelFunc:we},ck=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 u=1/t;l=`sumValue += dot(values * ${w.isInt(u)?u.toPrecision(2):u}, ones);`}let c="";r%n>0&&(c=`
|
|
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) {
|
|
${c}
|
|
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);
|
|
}
|
|
`}},wY=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 c=Math.floor(n/4)*4,u=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 < ${c}; 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 + ${c};
|
|
if (${u===1}) {
|
|
${p} values = ${p}(
|
|
getValue(batch, inIdx),
|
|
initializationValue,
|
|
initializationValue,
|
|
initializationValue
|
|
);
|
|
|
|
${d}
|
|
} else if (${u===2}) {
|
|
${p} values = ${p}(
|
|
getValue(batch, inIdx),
|
|
getValue(batch, inIdx + 1),
|
|
initializationValue,
|
|
initializationValue
|
|
);
|
|
|
|
${d}
|
|
} else if (${u===3}) {
|
|
${p} values = ${p}(
|
|
getValue(batch, inIdx),
|
|
getValue(batch, inIdx + 1),
|
|
getValue(batch, inIdx + 2),
|
|
initializationValue
|
|
);
|
|
|
|
${d}
|
|
}
|
|
setOutput(${l});
|
|
}
|
|
`}};function kY(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=N.computeOptimalWindowSize(n);t.push({inSize:n,windowSize:s,outSize:Math.ceil(n/s)})}return t}function Ti(e,t,n,s){let r=kY(e.shape),a=e;for(let o=0;o<r.length;o++){let{inSize:i,windowSize:l,outSize:c}=r[o],u,d;n==="mean"?u=o===0?new ck({windowSize:l,inSize:i,batchSize:e.shape[0],outSize:c},i):new ck({windowSize:l,inSize:i,batchSize:e.shape[0],outSize:c}):u=new wY({windowSize:l,inSize:i,batchSize:e.shape[0],outSize:c},n),d=a,a=s.runWebGLProgram(u,[a],t),d.dataId!==e.dataId&&s.disposeIntermediateTensorInfo(d)}return a}var IY=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=At(this.rank),r=SY(t);this.userCode=`
|
|
void main() {
|
|
${s} resRC = getOutputCoords();
|
|
setOutput(getA(${r}));
|
|
}
|
|
`}};function SY(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 CY=class{constructor(e,t){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0;let n=new Array(e.length);for(let c=0;c<n.length;c++)n[c]=e[t[c]];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=At(this.rank),r=q4("rc",this.rank),a=new Array(this.rank);for(let c=0;c<t.length;c++)a[t[c]]=r[c];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 v0(e,t,n){let s=Y().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new CY(e.shape,t):new IY(e.shape,t);return n.runWebGLProgram(s,[e],e.dtype)}function TY(e,t,n,s){let r=t,a=e.shape.length,o=w.parseAxisParam(r,e.shape),i=o,l=N.getAxesPermutation(i,a),c=l!=null,u=e;c&&(u=v0(e,l,s),i=N.getInnerMostAxes(i.length,a)),N.assertAxesAreInnerMostDims("sum",i,a);let[d,p]=N.computeOutAndReduceShapes(u.shape,i),h=d;n&&(h=N.expandShapeToKeepDim(d,o));let f=w.sizeFromShape(p),g=w.sizeFromShape(e.shape)/f,A=we({inputs:{x:u},attrs:{shape:[g,f]},backend:s}),y=Nh(e.dtype),x=Ti(A,y,"sum",s),b=we({inputs:{x},attrs:{shape:h},backend:s});return s.disposeIntermediateTensorInfo(A),s.disposeIntermediateTensorInfo(x),c&&s.disposeIntermediateTensorInfo(u),b}function w0(e){let{inputs:t,backend:n,attrs:s}=e,{x:r}=t,{axis:a,keepDims:o}=s;return TY(r,a,o,n)}var NY={kernelName:Lo,backendName:"webgl",kernelFunc:w0};function Pn(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 u=0;u<l.length;u++)l[u]=r.shape[a[u]];let c;if(o.shouldExecuteOnCPU([r])){let d=o.texData.get(r.dataId).values,p=V2(d,r.shape,r.dtype,a,l);c=o.makeTensorInfo(l,r.dtype);let h=o.texData.get(c.dataId);h.values=p}else c=v0(r,a,o);return c}var EY={kernelName:Ho,backendName:"webgl",kernelFunc:Pn},dk=1e3;function k0({a:e,b:t,transposeA:n,transposeB:s,backend:r,bias:a=null,preluActivationWeights:o=null,leakyreluAlpha:i=0,activation:l=null}){let c=e.shape.length,u=t.shape.length,d=n?e.shape[c-2]:e.shape[c-1],p=s?t.shape[u-1]:t.shape[u-2],h=n?e.shape[c-1]:e.shape[c-2],f=s?t.shape[u-2]:t.shape[u-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(c>=2&&u>=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 S=n?[A,d,h]:[A,h,d],T=s?[y,f,p]:[y,p,f],_=we({inputs:{x:e},backend:r,attrs:{shape:S}}),O=we({inputs:{x:t},backend:r,attrs:{shape:T}}),P=[_,O],D=Math.max(A,y),F=n?_.shape[1]:_.shape[2],C=a!=null,M=o!=null,U=l==="leakyrelu",j=l!=null?b0(l,!0):null,q=C||M||U||j!=null,X;if((h===1||f===1)&&F>dk&&q===!1){let ne=_,se=O;n&&(ne=Pn({inputs:{x:_},backend:r,attrs:{perm:[0,2,1]}}),P.push(ne)),s&&(se=Pn({inputs:{x:O},backend:r,attrs:{perm:[0,2,1]}}),P.push(se));let oe=f!==1,ae=f===1,re=ne;oe&&(re=we({inputs:{x:ne},backend:r,attrs:{shape:[D,F,1]}}),P.push(re));let ce=f===1?2:1,ge=se;ae&&(ge=we({inputs:{x:se},backend:r,attrs:{shape:[D,1,F]}}),P.push(ge));let ve=U2({inputs:{a:re,b:ge},backend:r});X=w0({inputs:{x:ve},backend:r,attrs:{axis:ce,keepDims:!0}}),P.push(ve)}else{let ne=$s(e.dtype,t.dtype),se=new ok(S,T,[D,h,f],n,s,C,j,M,U),oe=[_,O];if(a!=null&&oe.push(a),M&&oe.push(o),U){let ae=r.makeTensorInfo([],"float32",w.createScalarValue(i,"float32"));oe.push(ae),P.push(ae)}X=r.runWebGLProgram(se,oe,ne)}let te=we({inputs:{x:X},backend:r,attrs:{shape:v}});P.push(X);for(let ne of P)r.disposeIntermediateTensorInfo(ne);return te}function RY(e){let{inputs:t,backend:n,attrs:s}=e,{a:r,b:a,bias:o,preluActivationWeights:i}=t,{transposeA:l,transposeB:c,activation:u,leakyreluAlpha:d}=s;return k0({a:r,b:a,transposeA:l,transposeB:c,backend:n,bias:o,preluActivationWeights:i,leakyreluAlpha:d,activation:u})}var DY={kernelName:jo,backendName:"webgl",kernelFunc:RY},pk="return abs(x);";function _Y(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=H4(a.values);return n.makeTensorInfo(s.shape,s.dtype,o)}let r;return Y().getBool("WEBGL_PACK_UNARY_OPERATIONS")?r=new $u(s.shape,pk):r=new _a(s.shape,pk),n.runWebGLProgram(r,[s],s.dtype)}var FY={kernelName:qi,backendName:"webgl",kernelFunc:_Y},$Y=or+`
|
|
if (abs(x) > 1.) {
|
|
return NAN;
|
|
}
|
|
return acos(x);
|
|
`,OY=nt({opSnippet:$Y}),PY={kernelName:Xi,backendName:"webgl",kernelFunc:OY},MY=or+`
|
|
if (x < 1.0) return NAN;
|
|
return log(x + sqrt(x * x - 1.0));`,zY=nt({opSnippet:MY}),LY={kernelName:Ki,backendName:"webgl",kernelFunc:zY},hk="return a + b;",BY=yn({opSnippet:hk,packedOpSnippet:hk,supportsComplex:!0,cpuKernelImpl:KK}),WY={kernelName:la,backendName:"webgl",kernelFunc:BY},VY=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);
|
|
}
|
|
`}},UY=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 I0(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),c=I0({inputs:s.slice(0,l),backend:n}),u=I0({inputs:s.slice(l),backend:n});return I0({inputs:[c,u],backend:n})}let r=s.map(l=>l.dtype).reduce((l,c)=>$s(l,c)),a=s.map(l=>l.shape),i=Y().getBool("WEBGL_PACK")?new UY(s[0].shape,a):new VY(s[0].shape,a);return n.runWebGLProgram(i,s,r)}var GY={kernelName:Ka,backendName:"webgl",kernelFunc:I0};function HY(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),c=l,u=N.getAxesPermutation(c,i),d=r;u!=null&&(d=Pn({inputs:{x:r},backend:n,attrs:{perm:u}}),c=N.getInnerMostAxes(c.length,i)),N.assertAxesAreInnerMostDims("all",c,i);let[p,h]=N.computeOutAndReduceShapes(d.shape,c),f=w.sizeFromShape(h),m=we({inputs:{x:d},backend:n,attrs:{shape:[-1,f]}}),g=Ti(m,m.dtype,"all",n),A;if(o){let y=N.expandShapeToKeepDim(p,l);A=we({inputs:{x:g},backend:n,attrs:{shape:y}})}else A=we({inputs:{x:g},backend:n,attrs:{shape:p}});return n.disposeIntermediateTensorInfo(m),n.disposeIntermediateTensorInfo(g),u!=null&&n.disposeIntermediateTensorInfo(d),A}var jY={kernelName:Zi,backendName:"webgl",kernelFunc:HY};function qY(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),c=l,u=N.getAxesPermutation(c,i),d=r;u!=null&&(d=Pn({inputs:{x:r},backend:n,attrs:{perm:u}}),c=N.getInnerMostAxes(c.length,i)),N.assertAxesAreInnerMostDims("any",c,i);let[p,h]=N.computeOutAndReduceShapes(d.shape,c),f=w.sizeFromShape(h),m=we({inputs:{x:d},backend:n,attrs:{shape:[-1,f]}}),g=Ti(m,m.dtype,"any",n),A;if(o){let y=N.expandShapeToKeepDim(p,l);A=we({inputs:{x:g},backend:n,attrs:{shape:y}})}else A=we({inputs:{x:g},backend:n,attrs:{shape:p}});return n.disposeIntermediateTensorInfo(m),n.disposeIntermediateTensorInfo(g),u!=null&&n.disposeIntermediateTensorInfo(d),A}var XY={kernelName:Yi,backendName:"webgl",kernelFunc:qY},KY=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));
|
|
}
|
|
`}},ZY=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=At(i),c=On("coords",i),u,d;if(a===1){d=i+1;let T=At(d);u=`
|
|
${T} sourceLocR = ${T}(${c.join()}, 0);
|
|
++${c[i-1]};
|
|
${T} sourceLocG = ${T}(${c.join()}, 0);
|
|
++${c[i-2]};
|
|
${T} sourceLocA = ${T}(${c.join()}, 0);
|
|
--${c[i-1]};
|
|
${T} sourceLocB = ${T}(${c.join()}, 0);
|
|
--${c[i-2]};`}else d=i,u=`
|
|
${l} sourceLocR = coords;
|
|
++${c[i-1]};
|
|
${l} sourceLocG = coords;
|
|
++${c[i-2]};
|
|
${l} sourceLocA = coords;
|
|
--${c[i-1]};
|
|
${l} sourceLocB = coords;
|
|
--${c[i-2]};`;let p=["x","y","z","w","u","v"].slice(0,d),h="."+p[d-1],f=p.map(T=>"int "+T),m=On("sourceLocR",d-1).concat("inIdx.r"),g=On("sourceLocG",d-1).concat("inIdx.g"),A=On("sourceLocB",d-1).concat("inIdx.b"),y=On("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.)`,S=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()}));
|
|
}
|
|
${S}
|
|
void main() {
|
|
${l} coords = getOutputCoords();
|
|
bool hasNextCol = ${c[i-1]} < ${o[i-1]-1};
|
|
bool hasNextRow = ${c[i-2]} < ${o[i-2]-1};
|
|
${u}
|
|
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 fk(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=N.computeOptimalWindowSize(a),i={windowSize:o,inSize:a,batchSize:r,outSize:Math.ceil(a/o)},l=new KY(i,n,s==null),c=[t];s!=null&&c.push(s);let u=e.runWebGLProgram(l,c,"int32");if(u.shape[1]===1)return u;let d=fk(e,t,n,u);return e.disposeIntermediateTensorInfo(u),d}function mk(e,t,n,s=null){let r=s!=null?s.shape:t.shape,a=r[r.length-1],o=N.computeOptimalWindowSize(a),i=new ZY(r,o,n,s==null),l=s==null?[t]:[t,s],c=e.runWebGLProgram(i,l,"int32");if(c.shape.length===t.shape.length){let u=mk(e,t,n,c);return e.disposeIntermediateTensorInfo(c),u}return c}function gk(e,t,n,s){let r=[n];if(N.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[c,u]=N.computeOutAndReduceShapes(l.shape,r),d=w.sizeFromShape(u),p=we({inputs:{x:l},backend:e,attrs:{shape:[-1,d]}});a.push(p);let h=fk(e,p,s);a.push(h);let f=we({inputs:{x:h},backend:e,attrs:{shape:c}});return a.forEach(m=>e.disposeIntermediateTensorInfo(m)),f}return mk(e,t,s)}function YY(e){let{inputs:t,backend:n,attrs:s}=e,{x:r}=t,{axis:a}=s,o=w.parseAxisParam(a,r.shape),i=N.getAxesPermutation(o,r.shape.length),l=r,c=[];i!=null&&(l=Pn({inputs:{x:r},backend:n,attrs:{perm:i}}),c.push(l),o=N.getInnerMostAxes(o.length,l.shape.length)),N.assertAxesAreInnerMostDims("argMax",[o[0]],l.shape.length);let u=gk(n,l,o[0],"max");return c.forEach(d=>n.disposeIntermediateTensorInfo(d)),u}var JY={kernelName:Za,backendName:"webgl",kernelFunc:YY};function QY(e){let{inputs:t,backend:n,attrs:s}=e,{x:r}=t,{axis:a}=s,o=w.parseAxisParam(a,r.shape),i=N.getAxesPermutation(o,r.shape.length),l=r,c=[];i!=null&&(l=Pn({inputs:{x:r},backend:n,attrs:{perm:i}}),c.push(l),o=N.getInnerMostAxes(o.length,l.shape.length)),N.assertAxesAreInnerMostDims("argMin",[o[0]],l.shape.length);let u=gk(n,l,o[0],"min");return c.forEach(d=>n.disposeIntermediateTensorInfo(d)),u}var eJ={kernelName:gc,backendName:"webgl",kernelFunc:QY},tJ=or+`
|
|
if (abs(x) > 1.) {
|
|
return NAN;
|
|
}
|
|
return asin(x);
|
|
`,nJ=nt({opSnippet:tJ}),sJ={kernelName:Ji,backendName:"webgl",kernelFunc:nJ},rJ=or+"return log(x + sqrt(x * x + 1.0));",aJ=nt({opSnippet:rJ}),oJ={kernelName:Qi,backendName:"webgl",kernelFunc:aJ},iJ=or+`
|
|
return atan(x);
|
|
`,lJ=nt({opSnippet:iJ}),uJ={kernelName:el,backendName:"webgl",kernelFunc:lJ},cJ=AY+`
|
|
return atan(a, b);
|
|
`,dJ=`
|
|
vec4 result = atan(a, b);
|
|
vec4 isNaN = min(vec4(isnan(a)) + vec4(isnan(b)), vec4(1.0));
|
|
`+yY+`
|
|
return result;
|
|
`,pJ=yn({opSnippet:cJ,packedOpSnippet:dJ}),hJ={kernelName:nl,backendName:"webgl",kernelFunc:pJ},fJ=or+`
|
|
if ((x < -1.0) || (x > 1.0)) return NAN;
|
|
return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,mJ=nt({opSnippet:fJ}),gJ={kernelName:tl,backendName:"webgl",kernelFunc:mJ},Ld=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,c=e.dilationWidth,u=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 T=">=";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 < ${u};
|
|
wR += ${l}) {
|
|
int xR = xRCorner + wR;
|
|
|
|
if (xR < 0 || xR >= ${e.inHeight}) {
|
|
continue;
|
|
}
|
|
|
|
for (int wC = 0; wC < ${d};
|
|
wC += ${c}) {
|
|
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 ${T} 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,S=`
|
|
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 < ${u};
|
|
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 * ${c};
|
|
|
|
vec4 values = vec4(
|
|
getValue(batch, xR, xC, d),
|
|
getValue(batch, xR, xC + ${c}, d),
|
|
getValue(batch, xR, xC + 2 * ${c}, d),
|
|
getValue(batch, xR, xC + 3 * ${c}, d)
|
|
);
|
|
|
|
${S}
|
|
}
|
|
|
|
int xC = xCCorner + ${b};
|
|
if (${v===1}) {
|
|
vec4 values = vec4(
|
|
getValue(batch, xR, xC, d),
|
|
initializationValue,
|
|
initializationValue,
|
|
initializationValue
|
|
);
|
|
|
|
${S}
|
|
} else if (${v===2}) {
|
|
vec4 values = vec4(
|
|
getValue(batch, xR, xC, d),
|
|
getValue(batch, xR, xC + ${c}, d),
|
|
initializationValue,
|
|
initializationValue
|
|
);
|
|
|
|
${S}
|
|
} else if (${v===3}) {
|
|
vec4 values = vec4(
|
|
getValue(batch, xR, xC, d),
|
|
getValue(batch, xR, xC + ${c}, d),
|
|
getValue(batch, xR, xC + 2 * ${c}, d),
|
|
initializationValue
|
|
);
|
|
|
|
${S}
|
|
}
|
|
}
|
|
setOutput(${x});
|
|
}
|
|
`}},G2=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,c=e.dilationDepth,u=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 O=">=";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 += ${c}) {
|
|
int xD = xDCorner + wD;
|
|
|
|
if (xD < 0 || xD >= ${e.inDepth}) {
|
|
continue;
|
|
}
|
|
|
|
for (int wR = 0; wR < ${h};
|
|
wR += ${u}) {
|
|
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 ${O} 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 S=Math.floor(a/4)*4,T=a%4,_=`
|
|
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 += ${c}) {
|
|
int xD = xDCorner + wD;
|
|
|
|
if (xD < 0 || xD >= ${e.inDepth}) {
|
|
continue;
|
|
}
|
|
|
|
for (int wR = 0; wR < ${h};
|
|
wR += ${u}) {
|
|
int xR = xRCorner + wR;
|
|
|
|
if (xR < 0 || xR >= ${e.inHeight}) {
|
|
continue;
|
|
}
|
|
|
|
for (int wC = 0; wC < ${S}; 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)
|
|
);
|
|
|
|
${_}
|
|
}
|
|
|
|
int xC = xCCorner + ${S};
|
|
if (${T===1}) {
|
|
vec4 values = vec4(
|
|
getValue(batch, xD, xR, xC, ch),
|
|
initializationValue,
|
|
initializationValue,
|
|
initializationValue
|
|
);
|
|
|
|
${_}
|
|
} else if (${T===2}) {
|
|
vec4 values = vec4(
|
|
getValue(batch, xD, xR, xC, ch),
|
|
getValue(batch, xD, xR, xC + ${d}, ch),
|
|
initializationValue,
|
|
initializationValue
|
|
);
|
|
|
|
${_}
|
|
} else if (${T===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
|
|
);
|
|
|
|
${_}
|
|
}
|
|
}
|
|
setOutput(${v});
|
|
}
|
|
}
|
|
`}};function AJ(e){let{inputs:t,backend:n,attrs:s}=e,{x:r}=t;Eu(r,"avgPool");let{filterSize:a,strides:o,pad:i,dimRoundingMode:l}=s,c=1;w.assert(N.eitherStridesOrDilationsAreOne(o,c),()=>`Error in avgPool: Either strides or dilations must be 1. Got strides ${o} and dilations '${c}'`);let u=N.computePool2DInfo(r.shape,a,o,c,i,l);if(u.filterWidth===1&&u.filterHeight===1&&w.arraysEqual(u.inShape,u.outShape))return ds({inputs:{x:r},backend:n});let d=new Ld(u,"avg",!1);return n.runWebGLProgram(d,[r],"float32")}var yJ={kernelName:Ya,backendName:"webgl",kernelFunc:AJ};function xJ(e){let{inputs:t,backend:n,attrs:s}=e,{x:r}=t,{filterSize:a,strides:o,pad:i,dimRoundingMode:l,dataFormat:c}=s,u=[1,1,1],d=N.computePool3DInfo(r.shape,a,o,u,i,l,c),p=new G2(d,"avg",!1);return n.runWebGLProgram(p,[r],"float32")}var bJ={kernelName:Ac,backendName:"webgl",kernelFunc:xJ},vJ=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,c=i-1-e.padInfo.top,u=l-1-e.padInfo.left,d=1/(t*n);this.userCode=`
|
|
const ivec2 pads = ivec2(${c}, ${u});
|
|
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);
|
|
}
|
|
`}},wJ=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,c=e.dilationWidth,u=e.effectiveFilterDepth,d=e.effectiveFilterHeight,p=e.effectiveFilterWidth,h=u-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 < ${u};
|
|
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 += ${c}) {
|
|
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 kJ(e){let{inputs:t,backend:n,attrs:s}=e,{dy:r,input:a}=t,o=a,{filterSize:i,strides:l,pad:c,dimRoundingMode:u}=s,d=[1,1,1],p=N.computePool3DInfo(o.shape,i,l,d,c,u),h=new wJ(p);return n.runWebGLProgram(h,[r],o.dtype)}var IJ={kernelName:Bp,backendName:"webgl",kernelFunc:kJ};function SJ(e){let{inputs:t,backend:n,attrs:s}=e,{dy:r,input:a}=t,o=a;Eu([r,a],"avgPoolGrad");let{filterSize:i,strides:l,pad:c}=s,u=N.computePool2DInfo(o.shape,i,l,1,c),d=new vJ(u);return n.runWebGLProgram(d,[r],o.dtype)}var CJ={kernelName:Lp,backendName:"webgl",kernelFunc:SJ};function TJ(e){let{inputs:t,backend:n,attrs:s}=e,{a:r,b:a}=t,{transposeA:o,transposeB:i}=s;return k0({a:r,b:a,transposeA:o,transposeB:i,backend:n})}var NJ={kernelName:Ja,backendName:"webgl",kernelFunc:TJ},EJ=class{constructor(e,t,n,s,r,a){this.outputShape=[],this.variableNames=["x","mean","variance"],N.assertAndGetBroadcastShape(e,t),N.assertAndGetBroadcastShape(e,n);let o="0.0";s!=null&&(N.assertAndGetBroadcastShape(e,s),this.variableNames.push("offset"),o="getOffsetAtOutCoords()");let i="1.0";r!=null&&(N.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)));
|
|
}
|
|
`}},RJ=class{constructor(e,t,n,s,r,a){this.packedInputs=!0,this.packedOutput=!0,this.variableNames=["x","mean","variance"],N.assertAndGetBroadcastShape(e,t),N.assertAndGetBroadcastShape(e,n);let o="vec4(0.0)";s!=null&&(N.assertAndGetBroadcastShape(e,s),this.variableNames.push("offset"),o="getOffsetAtOutCoords()");let i="vec4(1.0)";r!=null&&(N.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);
|
|
}
|
|
`}},DJ=({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 c=[s,r,a],u=null;o!=null&&(u=o.shape,c.push(o));let d=null;i!=null&&(d=i.shape,c.push(i));let p=Y().getBool("WEBGL_PACK_NORMALIZATION")?new RJ(s.shape,r.shape,a.shape,u,d,l):new EJ(s.shape,r.shape,a.shape,u,d,l);return t.runWebGLProgram(p,c,c[0].dtype)},_J={kernelName:ho,backendName:"webgl",kernelFunc:DJ},FJ=class{constructor(e){this.variableNames=["source"],this.outputShape=e,this.rank=e.length;let t=At(this.rank);this.customUniforms=[{name:"start",arrayIndex:this.rank,type:"int"}];let n=$J(this.rank),s,r=e.map((a,o)=>`sourceLoc.${H2[o]} = start[${o}] + coords.${H2[o]};`);s=`
|
|
${t} sourceLoc;
|
|
${t} coords = getOutputCoords();
|
|
${r.join(`
|
|
`)}
|
|
`,this.userCode=`
|
|
void main() {
|
|
${s}
|
|
setOutput(getSource(${n}));
|
|
}
|
|
`}},H2=["x","y","z","w","u","v"];function $J(e){if(e===1)return"sourceLoc";if(e<=6)return H2.slice(0,e).map(t=>"sourceLoc."+t).join(",");throw Error(`Slicing for rank ${e} is not yet supported`)}var OJ=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=At(this.rank),n=On("coords",this.rank),s=On("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((c,u)=>`start[${u}]`).join()});`:e.map((c,u)=>`${s[u]} = ${n[u]} + start[${u}];`).join(`
|
|
`);this.userCode=`
|
|
void main() {
|
|
${t} coords = getOutputCoords();
|
|
${t} sourceLoc;
|
|
${l}
|
|
vec4 result = vec4(0.);
|
|
${o}
|
|
${i}
|
|
setOutput(result);
|
|
}
|
|
`}};function PJ(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=En.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 Mu(e){let{inputs:t,backend:n,attrs:s}=e,{x:r}=t,{begin:a,size:o}=s,[i,l]=En.parseSliceParams(r,a,o);if(En.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=vZ(d.values,i,l,r.shape,r.dtype);return n.makeTensorInfo(l,r.dtype,p)}let{isPacked:c}=n.texData.get(r.dataId),u=En.isSliceContinous(r.shape,i,l);if(c||!u){let d=Y().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new OJ(l):new FJ(l),p=[i];return n.runWebGLProgram(d,[r],r.dtype,p)}return n.uploadToGPU(r.dataId),PJ(r,i,l,n)}var MJ={kernelName:Pl,backendName:"webgl",kernelFunc:Mu},zJ=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=N.getReshaped(r.shape,a,i),c=N.getPermuted(l.length,a.length),u=N.getReshapedPermuted(r.shape,a,i),d=N.getSliceBeginCoords(o,a.length),p=N.getSliceSize(u,o,a.length),h=[],f=we({inputs:{x:r},backend:n,attrs:{shape:l}}),m=Pn({inputs:{x:f},backend:n,attrs:{perm:c}}),g=we({inputs:{x:m},backend:n,attrs:{shape:u}}),A=Mu({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},LJ={kernelName:sl,backendName:"webgl",kernelFunc:zJ};function BJ(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),c=G4(i,l,a.dtype,a.shape,o);return n.makeTensorInfo([o],a.dtype,c)}var WJ={kernelName:Wp,backendName:"webgl",kernelFunc:BJ};function VJ(e){let{inputs:t,backend:n}=e,{s0:s,s1:r}=t,a=n.readSync(s.dataId),o=n.readSync(r.dataId),i=N.assertAndGetBroadcastShape(Array.from(a),Array.from(o));return n.makeTensorInfo([i.length],"int32",Int32Array.from(i))}var UJ={kernelName:Vp,backendName:"webgl",kernelFunc:VJ},GJ="return float(a != b);",Ak=yn({opSnippet:GJ,cpuKernelImpl:gZ,dtype:"bool"}),HJ={kernelName:Il,backendName:"webgl",kernelFunc:Ak};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 jJ={kernelName:ch,backendName:"webgl",kernelFunc:Bd},qJ="return float(int(x));";function XJ(e,t){let n=new _a(e.shape,qJ),s=t.runWebGLProgram(n,[e],"int32");return{dataId:s.dataId,shape:s.shape,dtype:s.dtype}}function j2(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=Ut(r.shape),i=j2({inputs:{x:r},backend:n,attrs:{dtype:"float32"}}),l=Fa({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=j2({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 XJ(r,n);if(a==="bool"){let o=n.makeTensorInfo([],"bool",w.getTypedArrayFromDType("bool",1)),l=Ak({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 KJ={kernelName:Qa,backendName:"webgl",kernelFunc:j2},yk="return ceil(x);",ZJ=nt({opSnippet:yk,packedOpSnippet:yk,cpuKernelImpl:YK}),YJ={kernelName:eo,backendName:"webgl",kernelFunc:ZJ},JJ=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));
|
|
}
|
|
`}},QJ=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 eQ(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 QJ(r.shape):i=new JJ(r.shape);let l=[[a],[o]];return n.runWebGLProgram(i,[r],r.dtype,l)}var tQ={kernelName:ua,backendName:"webgl",kernelFunc:eQ},nQ=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 xk(e,t){return{dataId:t.dataId,dtype:t.dtype,shape:e.shape}}function sQ(e){let{inputs:t,backend:n}=e,{x:s}=t,r=n.texData.get(s.dataId),a=new nQ(s.shape),o=[xk(s,r.complexTensorInfos.real),xk(s,r.complexTensorInfos.imag)];return n.runWebGLProgram(a,o,o[0].dtype)}var rQ={kernelName:yc,backendName:"webgl",kernelFunc:sQ},aQ=class{constructor(e){this.outputShape=[],this.outputShape=N.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(`
|
|
`)}
|
|
}
|
|
`}},oQ=class{constructor(e,t){this.packedInputs=!0,this.packedOutput=!0,this.outputShape=[],this.outputShape=N.computeOutShape(e,t);let n=this.outputShape,s=n.length,r=At(s),a=On("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],c=o.slice(-2),u=o.join(),d=`if (${l} < ${i[0]}) {
|
|
return getChannel(
|
|
getT0(${u}), vec2(${c.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(c,l,m)}));
|
|
}`}let p=i.length,h=i[i.length-1];d+=`
|
|
return getChannel(
|
|
getT${p}(${S0(o,l,h)}),
|
|
vec2(${S0(c,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 C0(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 iQ={kernelName:sh,backendName:"webgl",kernelFunc:C0};function zu(e,t,n){let s=e[0].dtype;if(s==="complex64"){let u=e.map(m=>Bd({inputs:{input:m},backend:n})),d=e.map(m=>C0({inputs:{input:m},backend:n})),p=zu(u,t,n),h=zu(d,t,n),f=Fa({inputs:{real:p,imag:h},backend:n});return u.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 u=e.map(A=>{let y=w.sizeFromShape(A.shape.slice(t));return we({inputs:{x:A},backend:n,attrs:{shape:[-1,y]}})}),d=u.map(A=>({vals:n.readSync(A.dataId),shape:A.shape})),p=N.computeOutShape(u.map(A=>A.shape),1),h=u[0].shape[0]===1,f=JK(d,p,s,h),m=N.computeOutShape(e.map(A=>A.shape),t),g=n.makeTensorInfo(m,s,f);return u.forEach(A=>n.disposeIntermediateTensorInfo(A)),g}if(e.length>Y().getNumber("WEBGL_MAX_TEXTURES_IN_SHADER")){let u=Math.floor(e.length/2),d=zu(e.slice(0,u),t,n),p=zu(e.slice(u),t,n),h=zu([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 u=new oQ(e.map(d=>d.shape),t);return n.runWebGLProgram(u,e,s)}let{tensors2D:a,outShape:o}=lQ(e,t,n),i=new aQ(a.map(u=>u.shape)),l=n.runWebGLProgram(i,a,s);a.forEach(u=>n.disposeIntermediateTensorInfo(u));let c=we({inputs:{x:l},attrs:{shape:o},backend:n});return n.disposeIntermediateTensorInfo(l),c}function lQ(e,t,n){let s=N.computeOutShape(e.map(a=>a.shape),t);return{tensors2D:e.map(a=>we({inputs:{x:a},attrs:{shape:[-1,w.sizeFromShape(a.shape.slice(t))]},backend:n})),outShape:s}}function bk(e){let{inputs:t,backend:n,attrs:s}=e,{axis:r}=s,a=w.parseAxisParam(r,t[0].shape)[0],o=N.computeOutShape(t.map(c=>c.shape),a);if(w.sizeFromShape(o)===0)return n.makeTensorInfo(o,t[0].dtype,[]);let i=t.filter(c=>w.sizeFromShape(c.shape)>0);if(i.length===1)return ds({inputs:{x:i[0]},backend:n});let l=i.map(c=>c.shape);return N.assertParamsConsistent(l,a),zu(i,a,n)}var uQ={kernelName:rl,backendName:"webgl",kernelFunc:bk},vk=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,c=e.dilationHeight,u=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 * ${c};
|
|
|
|
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 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);
|
|
}
|
|
`}},cQ=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,c=e.dilationWidth,u=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 < ${u}; 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 * ${c};
|
|
|
|
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);
|
|
}
|
|
`}},dQ=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=Cs(this.outputShape.length);let{dataFormat:n}=t,s=$n(),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 c=0;c<=1;c++)for(let u=0;u<=1;u++)l+=`
|
|
blockIndex = rc.y + ${u};
|
|
pos = rc.x + ${c};
|
|
|
|
${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[${c*2+u}] = getChannel(
|
|
getA(d0, int(innerDims.x),
|
|
int(innerDims.y)), innerDims);
|
|
} else {
|
|
innerDims = vec2(d0, d1);
|
|
result[${c*2+u}] = 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 wk({x:e,filter:t,convInfo:n,backend:s,bias:r=null,preluActivationWeights:a=null,leakyreluAlpha:o=0,activation:i=null}){let l=e.shape,c=s.texData.get(e.dataId),u=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)&&u>dk)&&c.isPacked&&h&&c.texture!=null&&l[2]%2!=0&&w.arraysEqual(c.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},S=c.shape;c.shape=c.shape.slice(),c.shape[c.shape.length-2]++,w.assert(Pd(c.shape,v.shape),()=>`packed reshape ${c.shape} to ${v.shape} isn't free`);let T=we({inputs:{x:t},backend:s,attrs:{shape:[1,n.inChannels,n.outChannels]}});A.push(T);let _=k0({a:v,b:T,backend:s,transposeA:f,transposeB:m,bias:r,activation:i,preluActivationWeights:a,leakyreluAlpha:o}),O=s.texData.get(_.dataId);w.assert(O.isPacked,()=>"batchMatMul result is expected to be packed"),c.shape=S,O.shape=n.outShape,g=ds({inputs:{x:_},backend:s}),g.shape=n.outShape,A.push(_)}else{let b=h?l[0]*l[1]*l[2]:l[0]*l[2]*l[3],v=we({inputs:{x:e},backend:s,attrs:{shape:[1,b,n.inChannels]}}),S=we({inputs:{x:t},backend:s,attrs:{shape:[1,n.inChannels,n.outChannels]}}),T=k0({a:v,b:S,transposeA:f,transposeB:m,backend:s,bias:r,activation:i,preluActivationWeights:a,leakyreluAlpha:o});g=we({inputs:{x:T},backend:s,attrs:{shape:n.outShape}}),A.push(v),A.push(S),A.push(T)}for(let b of A)s.disposeIntermediateTensorInfo(b);return g}function kk({x:e,filter:t,convInfo:n,backend:s,bias:r=null,preluActivationWeights:a=null,leakyreluAlpha:o=0,activation:i=null}){let{filterWidth:l,filterHeight:c,inChannels:u,outWidth:d,outHeight:p,dataFormat:h}=n,f=h==="channelsLast",m=l*c*u,g=p*d,A=[m,g],y=!0,x=!1,b=[],v=we({inputs:{x:e},backend:s,attrs:{shape:e.shape.slice(1)}}),S=we({inputs:{x:t},backend:s,attrs:{shape:[1,m,w.sizeFromShape(t.shape)/m]}});b.push(v),b.push(S);let T=new dQ(A,n),_=[v.shape,[n.padInfo.top,n.padInfo.left],[n.strideHeight,n.strideWidth],[n.dilationHeight,n.dilationWidth],[n.inChannels],[n.filterWidth*n.inChannels],[n.outWidth]],O=s.runWebGLProgram(T,[v],"float32",_),P=we({inputs:{x:O},backend:s,attrs:{shape:[1,A[0],A[1]]}});b.push(O),b.push(P);let D=r!=null,F=a!=null,C=i==="leakyrelu",M=i?b0(i,!0):null,U=new ok(P.shape,S.shape,[1,g,n.outChannels],y,x,D,M,F,C),j=[P,S];if(r&&j.push(r),F&&j.push(a),C){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=we({inputs:{x:q},backend:s,attrs:{shape:X}});b.push(q);for(let ne of b)s.disposeIntermediateTensorInfo(ne);return te}function pQ(e){let{inputs:t,backend:n,attrs:s}=e,{x:r,filter:a}=t,{strides:o,pad:i,dataFormat:l,dilations:c,dimRoundingMode:u}=s,d=N.convertConv2DDataFormat(l),p=N.computeConv2DInfo(r.shape,a.shape,o,c,i,u,!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=wk({x:r,filter:a,convInfo:p,backend:n});else if(Y().getBool("WEBGL_CONV_IM2COL")&&r.shape[0]===1)h=kk({x:r,filter:a,convInfo:p,backend:n});else{let m=new vk(p);h=n.runWebGLProgram(m,[r,a],"float32")}let f=we({inputs:{x:h},backend:n,attrs:{shape:p.outShape}});return n.disposeIntermediateTensorInfo(h),f}var hQ={kernelName:to,backendName:"webgl",kernelFunc:pQ},fQ=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);
|
|
}
|
|
`}},mQ=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,c=a?2:3,u=a?3:1;this.userCode=`
|
|
const ivec2 pads = ivec2(${o}, ${i});
|
|
|
|
void main() {
|
|
ivec4 coords = getOutputCoords();
|
|
int batch = coords[0];
|
|
int d1 = coords[${u}];
|
|
|
|
ivec2 dyCorner = ivec2(coords[${l}], coords[${c}]) - 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);
|
|
}
|
|
`}},gQ=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);
|
|
}
|
|
`}},AQ=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,c=s-1-e.padInfo.left;this.userCode=`
|
|
const ivec3 pads = ivec3(${i}, ${l}, ${c});
|
|
|
|
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 yQ(e){let{inputs:t,backend:n,attrs:s}=e,{x:r,dy:a}=t,{strides:o,pad:i,dataFormat:l,dimRoundingMode:c,filterShape:u}=s,d=N.convertConv2DDataFormat(l),p=N.computeConv2DInfo(r.shape,u,o,1,i,c,!1,d),h=new fQ(p);return n.runWebGLProgram(h,[r,a],"float32")}var xQ={kernelName:Gp,backendName:"webgl",kernelFunc:yQ};function bQ(e){let{inputs:t,backend:n,attrs:s}=e,{dy:r,filter:a}=t,{inputShape:o,strides:i,pad:l,dataFormat:c,dimRoundingMode:u}=s,d=N.convertConv2DDataFormat(c),p=N.computeConv2DInfo(o,a.shape,i,1,l,u,!1,d),h=new mQ(p);return n.runWebGLProgram(h,[r,a],"float32")}var vQ={kernelName:no,backendName:"webgl",kernelFunc:bQ};function wQ(e){let{inputs:t,backend:n,attrs:s}=e,{x:r,filter:a}=t,{strides:o,pad:i,dilations:l}=s,c=N.computeConv3DInfo(r.shape,a.shape,o,l,i),u=new cQ(c);return n.runWebGLProgram(u,[r,a],"float32")}var kQ={kernelName:xc,backendName:"webgl",kernelFunc:wQ};function IQ(e){let{inputs:t,backend:n,attrs:s}=e,{x:r,dy:a}=t,{strides:o,pad:i,filterShape:l}=s,c=N.computeConv3DInfo(r.shape,l,o,1,i),u=new gQ(c);return n.runWebGLProgram(u,[r,a],"float32")}var SQ={kernelName:Hp,backendName:"webgl",kernelFunc:IQ};function CQ(e){let{inputs:t,backend:n,attrs:s}=e,{dy:r,filter:a}=t,{pad:o,strides:i,inputShape:l}=s,c=N.computeConv3DInfo(l,a.shape,i,1,o),u=new AQ(c);return n.runWebGLProgram(u,[r,a],"float32")}var TQ={kernelName:jp,backendName:"webgl",kernelFunc:CQ},NQ=ak+`
|
|
return cos(x);
|
|
`,EQ=nt({opSnippet:NQ}),RQ={kernelName:so,backendName:"webgl",kernelFunc:EQ},DQ=`
|
|
float e2x = exp(-x);
|
|
return (e2x + 1.0 / e2x) / 2.0;
|
|
`,_Q=nt({opSnippet:DQ}),FQ={kernelName:ro,backendName:"webgl",kernelFunc:_Q},$Q=class{constructor(e,t,n,s,r){this.variableNames=["Image","Boxes","BoxInd"],this.outputShape=[];let[a,o,i,l]=e,[c]=t,[u,d]=n;this.outputShape=[c,u,d,l];let p=s==="bilinear"?1:0,[h,f]=[`${o-1}.0`,`${i-1}.0`],[m,g,A]=u>1?[`${(o-1)/(u-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);
|
|
}
|
|
}
|
|
`}},OQ=e=>{let{inputs:t,backend:n,attrs:s}=e,{image:r,boxes:a,boxInd:o}=t,{cropSize:i,method:l,extrapolationValue:c}=s,u=new $Q(r.shape,a.shape,i,l,c);return n.runWebGLProgram(u,[r,a,o],"float32")},PQ={kernelName:al,backendName:"webgl",kernelFunc:OQ},Ik=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(${Sk(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() {
|
|
${At(s)} coords = getOutputCoords();
|
|
int end = ${Ck(s,"coords")};
|
|
float val = ${r};
|
|
int pow2 = int(pow(2.0, index));
|
|
if (${o}) {
|
|
int idx = ${i};
|
|
${Ck(s,"coords")} = idx;
|
|
val += getX(${Sk(s,"coords")});
|
|
}
|
|
setOutput(val);
|
|
}
|
|
`}};function Sk(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 Ck(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 MQ(e){let{inputs:t,backend:n,attrs:s}=e,{x:r}=t,{axis:a,exclusive:o,reverse:i}=s,l=r.shape.length,c=N.getAxesPermutation([a],l),u=r;c!=null&&(u=Pn({inputs:{x:r},backend:n,attrs:{perm:c}}));let d=N.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=u.shape[d],h=ds({inputs:{x:u},backend:n});for(let f=0;f<=Math.ceil(Math.log2(p))-1;f++){let m=new Ik(u.shape,!1,i),g=[[f]],A=h;h=n.runWebGLProgram(m,[h],h.dtype,g),n.disposeIntermediateTensorInfo(A)}if(o){let f=new Ik(u.shape,o,i),m=h;h=n.runWebGLProgram(f,[h],h.dtype),n.disposeIntermediateTensorInfo(m)}if(c!=null){let f=N.getUndoAxesPermutation(c),m=Pn({inputs:{x:h},backend:n,attrs:{perm:f}});return n.disposeIntermediateTensorInfo(h),n.disposeIntermediateTensorInfo(u),m}return h}var zQ={kernelName:ao,backendName:"webgl",kernelFunc:MQ};function LQ(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),c=n.readSync(a.dataId),u=G4(l,c,a.dtype,a.shape,o);return n.makeTensorInfo([o],a.dtype,u)}else if(r.shape.length===2){let l=n.bufferSync(r),c=n.bufferSync(a),u=ZK(l,c,o,i);return n.makeTensorInfo(u.shape,a.dtype,u.values)}throw new Error(`Error in denseBincount: input must be at most rank 2, but got rank${r.shape.length}.`)}var BQ={kernelName:qp,backendName:"webgl",kernelFunc:LQ},WQ=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 VQ(e){let{inputs:t,backend:n,attrs:s}=e,{x:r}=t,{blockSize:a,dataFormat:o}=s,i=r.shape[0],l=o==="NHWC"?r.shape[1]:r.shape[2],c=o==="NHWC"?r.shape[2]:r.shape[3],u=o==="NHWC"?r.shape[3]:r.shape[1],d=l*a,p=c*a,h=u/(a*a),f=o==="NHWC"?[i,d,p,h]:[i,h,d,p],m=new WQ(f,a,o);return n.runWebGLProgram(m,[r],r.dtype)}var UQ={kernelName:ol,backendName:"webgl",kernelFunc:VQ},Tk=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=Cs(this.outputShape.length);let a=e.filterHeight,o=e.filterWidth,i=e.outChannels/e.inChannels,l="",c="";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}
|
|
}
|
|
`,c="result = activation(result);");let u=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;
|
|
${u}
|
|
${c}
|
|
setOutput(result);
|
|
}
|
|
`}},Nk=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=Cs(this.outputShape.length);let a=e.outChannels/e.inChannels,o=e.padInfo.left,i=e.strideWidth,l=e.dilationWidth,c=e.filterHeight,u=e.filterWidth,d=u,p=`
|
|
int xR; int xC; int xCOffset;
|
|
vec4 wTexel; vec4 previous; vec4 final;`;for(let g=0;g<u;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};`;p+=`
|
|
for (int r = 0; r < ${c}; r++) {
|
|
`;for(let g=0;g<u;g++)p+=`
|
|
xTexelC${g*2} = vec4(0.0);
|
|
xTexelC${g*2}Ready = 0;
|
|
xTexelC${g*2+1} = vec4(0.0);
|
|
xTexelC${g*2+1}Ready = 0;
|
|
xC${g} = vec4(0.0);`;p+=`
|
|
xR = xRCorner + r * dilations[0];
|
|
if (xR >=0 && xR < inDims[0]) {
|
|
`;for(let g=0;g<(d+1)/2;g++){let A=g*2;if(p+=`
|
|
xC = xCCorner + ${A*l};
|
|
`,i===1){if(A<u&&(o%2==1?(p+=`
|
|
xCOffset = xC + 1;
|
|
if (xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${A}Ready == 0) {
|
|
xTexelC${A} = 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${A}.zw = vec2(0.0);
|
|
}
|
|
xTexelC${A}Ready = 1;
|
|
}
|
|
`,l===1&&A>0?p+=`
|
|
xC${A} = vec4(xTexelC${A-2}.zw, xTexelC${A}.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${A} = vec4(previous.zw, xTexelC${A}.xy);
|
|
} else {
|
|
xC${A} = vec4(0.0, 0.0, xTexelC${A}.xy);
|
|
}
|
|
`):p+=`
|
|
if (xC >= 0 && xC < inDims[1] && xTexelC${A}Ready == 0) {
|
|
xTexelC${A} = getX(batch, xR, xC, d1);
|
|
if (xC + 1 >= inDims[1]) {
|
|
xTexelC${A}.zw = vec2(0.0);
|
|
}
|
|
xTexelC${A}Ready = 1;
|
|
}
|
|
|
|
xC${A} = xTexelC${A};
|
|
`,A+1<u)){let y=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) + ${y};
|
|
|
|
if (xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${A+1}Ready == 0) {
|
|
xTexelC${A+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${A+1}.zw = vec2(0.0);
|
|
}
|
|
xTexelC${A+1}Ready = 1;
|
|
}
|
|
`,l>1&&(p+=`
|
|
xCOffset -= 2;
|
|
if (xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${A}Ready == 0) {
|
|
xTexelC${A} = getX(batch, xR, xCOffset, d1);
|
|
xTexelC${A}Ready = 1;
|
|
}
|
|
`),p+=`
|
|
xC${A+1} = vec4(xTexelC${A}.zw, xTexelC${A+1}.xy);
|
|
`):y===1?p+=`
|
|
xC${A+1} = xTexelC${A};
|
|
`:p+=`
|
|
xCOffset = xC + ${y};
|
|
|
|
if (xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${A+1}Ready == 0) {
|
|
xTexelC${A+1} = getX(batch, xR, xCOffset, d1);
|
|
if (xCOffset + 1 >= inDims[1]) {
|
|
xTexelC${A+1}.zw = vec2(0.0);
|
|
}
|
|
xTexelC${A+1}Ready = 1;
|
|
}
|
|
|
|
xC${A+1} = xTexelC${A+1};
|
|
`}}else A<u&&(o%2==1?(p+=`
|
|
xCOffset = xC + 1 - strides[1];
|
|
if(xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${A}Ready == 0) {
|
|
xTexelC${A} = 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${A}.zw = vec2(0.0);
|
|
}
|
|
xTexelC${A}Ready = 1;
|
|
}
|
|
|
|
if(xC + 1 >= 0 && xC + 1 < inDims[1] && xTexelC${A+1}Ready == 0) {
|
|
xTexelC${A+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${A+1}.zw = vec2(0.0);
|
|
}
|
|
xTexelC${A+1}Ready = 1;
|
|
}
|
|
|
|
xC${A} = vec4(xTexelC${A}.zw, xTexelC${A+1}.zw);
|
|
`,A+1<u&&(p+=`
|
|
final = vec4(0.0);
|
|
xCOffset = xC + 1 + strides[1];
|
|
if(xCOffset >= 0 && xCOffset < inDims[1]) {
|
|
final = getX(batch, xR, xCOffset, d1);
|
|
}
|
|
xC${A+1} = vec4(xTexelC${A+1}.xy, final.xy);
|
|
`)):(p+=`
|
|
if(xC >= 0 && xC < inDims[1] && xTexelC${A}Ready == 0) {
|
|
xTexelC${A} = getX(batch, xR, xC, d1);
|
|
if (xC + 1 >= inDims[1]) {
|
|
xTexelC${A}.zw = vec2(0.0);
|
|
}
|
|
xTexelC${A}Ready = 1;
|
|
}
|
|
|
|
xCOffset = xC + strides[1];
|
|
if(xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${A+1}Ready == 0) {
|
|
xTexelC${A+1} = getX(batch, xR, xCOffset, d1);
|
|
if (xCOffset + 1 >= inDims[1]) {
|
|
xTexelC${A+1}.zw = vec2(0.);
|
|
}
|
|
xTexelC${A+1}Ready = 1;
|
|
}
|
|
|
|
xC${A} = vec4(
|
|
xTexelC${A}.xy, xTexelC${A+1}.xy);
|
|
`,A+1<u&&(p+=`
|
|
xC${A+1} = vec4(xTexelC${A}.zw, xTexelC${A+1}.zw);
|
|
`)));A<u&&(p+=`
|
|
wTexel = getW(r, ${A}, d1, q);
|
|
dotProd += xC${A} * vec4(wTexel.xz, wTexel.xz);
|
|
`,A+1<u&&(p+=`
|
|
wTexel = getW(r, ${A+1}, d1, q);
|
|
dotProd += xC${A+1} * vec4(wTexel.xz, wTexel.xz);
|
|
`))}p+=`
|
|
}
|
|
`,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 GQ(e){let{inputs:t,backend:n,attrs:s}=e,{x:r,filter:a}=t,{strides:o,pad:i,dilations:l,dimRoundingMode:c}=s,u=l;u==null&&(u=[1,1]),w.assert(N.eitherStridesOrDilationsAreOne(o,u),()=>`Error in depthwiseConv2d: Either strides or dilations must be 1. Got strides ${o} and dilations '${u}'`);let d=N.computeConv2DInfo(r.shape,a.shape,o,u,i,c,!0),p;Y().getBool("WEBGL_PACK_DEPTHWISECONV")&&d.strideWidth<=2&&d.outChannels/d.inChannels==1?p=new Nk(d):p=new Tk(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 HQ={kernelName:oo,backendName:"webgl",kernelFunc:GQ},jQ=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);
|
|
}
|
|
`}},qQ=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 XQ(e){let{inputs:t,backend:n,attrs:s}=e,{x:r,dy:a}=t,{strides:o,dilations:i,pad:l,dimRoundingMode:c,filterShape:u}=s,d=N.computeConv2DInfo(r.shape,u,o,i,l,c,!0),p=new jQ(d);return n.runWebGLProgram(p,[r,a],"float32")}var KQ={kernelName:Xp,backendName:"webgl",kernelFunc:XQ};function ZQ(e){let{inputs:t,backend:n,attrs:s}=e,{dy:r,filter:a}=t,{strides:o,dilations:i,pad:l,dimRoundingMode:c,inputShape:u}=s,d=N.computeConv2DInfo(u,a.shape,o,i,l,c,!0),p=new qQ(d);return n.runWebGLProgram(p,[r,a],"float32")}var YQ={kernelName:Kp,backendName:"webgl",kernelFunc:ZQ},JQ=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 QQ(e){let{inputs:t,backend:n}=e,{x:s}=t,r=[...s.shape,...s.shape],a=w.sizeFromShape(s.shape),o=we({inputs:{x:s},backend:n,attrs:{shape:[a]}}),i=new JQ(a),l=n.runWebGLProgram(i,[o],o.dtype),c=we({inputs:{x:l},backend:n,attrs:{shape:r}});return n.disposeIntermediateTensorInfo(o),n.disposeIntermediateTensorInfo(l),c}var eee={kernelName:Zp,backendName:"webgl",kernelFunc:QQ},tee=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:c}=e,{top:u,left:d}=s;this.userCode=`
|
|
const ivec2 strides = ivec2(${r}, ${a});
|
|
const ivec2 pads = ivec2(${u}, ${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 * ${c};
|
|
|
|
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 nee(e){let{inputs:t,backend:n,attrs:s}=e,{x:r,filter:a}=t,{strides:o,pad:i,dilations:l}=s,c=N.computeDilation2DInfo(r.shape,a.shape,o,i,"NHWC",l),u,d=new tee(c);u=n.runWebGLProgram(d,[r,a],"float32");let p=we({inputs:{x:u},backend:n,attrs:{shape:c.outShape}});return n.disposeIntermediateTensorInfo(u),p}var see={kernelName:bc,backendName:"webgl",kernelFunc:nee};function ree(e){let{inputs:t,backend:n,attrs:s}=e,{equation:r}=s,a=t,{allDims:o,summedDims:i,idDims:l}=N.decodeEinsumEquation(r,a.length);N.checkEinsumDimSizes(o.length,l,a);let{path:c,steps:u}=N.getEinsumComputePath(i,l),d=u.length,p=null,h=o.length,f=[];for(let m=0;m<d;++m){for(let g of u[m]){let{permutationIndices:A,expandDims:y}=N.getEinsumPermutation(h,l[g]),x;N.isIdentityPermutation(A)?x=a[g]:(x=Pn({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=we({inputs:{x},backend:n,attrs:{shape:b}}),f.push(x)),p===null?p=x:(p=U2({inputs:{a:x,b:p},backend:n}),f.push(p))}m<d-1&&(c[m]>=0&&(p=w0({inputs:{x:p},backend:n,attrs:{axis:c[m]-(o.length-h),keepDims:!1}}),f.push(p)),h--)}for(let m of f)m!==p&&n.disposeIntermediateTensorInfo(m);return p}var aee={kernelName:Qp,backendName:"webgl",kernelFunc:ree},oee="return (x >= 0.0) ? x : (exp(x) - 1.0);",iee=`
|
|
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;
|
|
`,lee=nt({opSnippet:oee,packedOpSnippet:iee}),uee={kernelName:lo,backendName:"webgl",kernelFunc:lee},cee="return (b >= 1.0) ? a : a * (b + 1.0);",dee=`
|
|
vec4 bGTEZero = vec4(greaterThanEqual(b, vec4(0.)));
|
|
return (bGTEZero * a) + ((vec4(1.0) - bGTEZero) * (a * (b + vec4(1.0))));
|
|
`,pee=e=>{let{inputs:t,backend:n}=e,{dy:s,y:r}=t,a=Y().getBool("WEBGL_PACK_BINARY_OPERATIONS")?new zd(dee,s.shape,r.shape):new Pu(cee,s.shape,r.shape);return n.runWebGLProgram(a,[s,r],s.dtype)},hee={kernelName:eh,backendName:"webgl",kernelFunc:pee},fee=`
|
|
return vec4(equal(a, b));
|
|
`,mee="return float(a == b);",gee=yn({opSnippet:mee,packedOpSnippet:fee,dtype:"bool",cpuKernelImpl:QK}),Aee={kernelName:ll,backendName:"webgl",kernelFunc:gee},yee=`
|
|
// Error function is calculated approximately with elementary function.
|
|
// See "Handbook of Mathematical Functions with Formulas,
|
|
// Graphs, and Mathematical Tables", Abramowitz and Stegun.
|
|
float p = ${N.ERF_P};
|
|
float a1 = ${N.ERF_A1};
|
|
float a2 = ${N.ERF_A2};
|
|
float a3 = ${N.ERF_A3};
|
|
float a4 = ${N.ERF_A4};
|
|
float a5 = ${N.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));
|
|
`,xee=nt({opSnippet:yee}),bee={kernelName:il,backendName:"webgl",kernelFunc:xee},Ek="return exp(x);",Rk=nt({opSnippet:Ek,packedOpSnippet:Ek,cpuKernelImpl:eZ,dtype:"float32"}),vee={kernelName:uo,backendName:"webgl",kernelFunc:Rk};function q2(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),we({inputs:{x:a},backend:s,attrs:{shape:i}})}var wee={kernelName:ul,backendName:"webgl",kernelFunc:q2},Dk="return exp(x) - 1.0;",kee=nt({opSnippet:Dk,packedOpSnippet:Dk,cpuKernelImpl:tZ}),Iee={kernelName:cl,backendName:"webgl",kernelFunc:kee},_k=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 Fk(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=we({inputs:{x:e},backend:n,attrs:{shape:[o,a]}}),l=i.shape,c=new _k("real",l,t),u=new _k("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(c,d,"float32"),h=n.runWebGLProgram(u,d,"float32"),f=Fa({inputs:{real:p,imag:h},backend:n});n.disposeIntermediateTensorInfo(p),n.disposeIntermediateTensorInfo(h);let m=we({inputs:{x:f},backend:n,attrs:{shape:e.shape}});return n.disposeIntermediateTensorInfo(i),n.disposeIntermediateTensorInfo(f),m}function See(e){let{inputs:t,backend:n}=e,{input:s}=t;return Fk(s,!1,n)}var Cee={kernelName:th,backendName:"webgl",kernelFunc:See},Tee=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 Wd(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 Tee(s,r),i=[[r]];return t.runWebGLProgram(o,[],a,i)}}var Nee={kernelName:vc,backendName:"webgl",kernelFunc:Wd},Eee=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);
|
|
}
|
|
`}},Ree={kernelName:dl,backendName:"webgl",kernelFunc:({inputs:e,backend:t})=>{let{image:n}=e,s=t,r=new Eee(n.shape);return s.runWebGLProgram(r,[n],n.dtype)}},$k="return floor(x);",Dee=nt({opSnippet:$k,packedOpSnippet:$k,cpuKernelImpl:nZ}),_ee={kernelName:co,backendName:"webgl",kernelFunc:Dee},Fee=`
|
|
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;
|
|
}
|
|
`,$ee=`
|
|
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);
|
|
`,Oee=yn({opSnippet:Fee,packedOpSnippet:$ee,dtype:"int32"}),Pee={kernelName:po,backendName:"webgl",kernelFunc:Oee},Mee=class{constructor(e){this.variableNames=["A"];let t=$n(),[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));
|
|
}
|
|
`}},zee=class{constructor(e){this.variableNames=["A"],this.packedInputs=!1,this.packedOutput=!0;let t=$n(),[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;
|
|
}
|
|
`}},Lee={kernelName:wh,backendName:"webgl",kernelFunc:Bee},Lu;function Bee(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,c]=o?[r.videoWidth,r.videoHeight]:[r.width,r.height],u=[c,l],d=[c,l,a];(i||o)&&(Lu==null&&(Lu=document.createElement("canvas").getContext("2d")),Lu.canvas.width=l,Lu.canvas.height=c,Lu.drawImage(r,0,0,l,c),r=Lu.canvas);let p=n.makeTensorInfo(u,"int32");n.texData.get(p.dataId).usage=Is.PIXELS,n.gpgpu.uploadPixelDataToTexture(n.getTexture(p.dataId),r);let h=Y().getBool("WEBGL_PACK")?new zee(d):new Mee(d),f=n.runWebGLProgram(h,[p],"int32");return n.disposeData(p.dataId),f}function Wee(e){let{inputs:t,backend:n,attrs:s}=e,{x:r,filter:a,bias:o,preluActivationWeights:i}=t,{strides:l,pad:c,dataFormat:u,dilations:d,dimRoundingMode:p,activation:h,leakyreluAlpha:f}=s,m=N.convertConv2DDataFormat(u),g=N.computeConv2DInfo(r.shape,a.shape,l,d,c,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=wk({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=kk({x:r,filter:a,convInfo:g,backend:n,bias:o,activation:h,preluActivationWeights:i,leakyreluAlpha:f});else{let b=o!=null,v=i!=null,S=h==="leakyrelu",T=h?b0(h,!1):null,_=new vk(g,b,T,v,S),O=[r,a];if(o&&O.push(o),i&&O.push(i),S){let P=n.makeTensorInfo([],"float32",w.createScalarValue(f,"float32"));O.push(P),y.push(P)}A=n.runWebGLProgram(_,O,"float32")}let x=we({inputs:{x:A},backend:n,attrs:{shape:g.outShape}});return y.push(A),y.forEach(b=>n.disposeIntermediateTensorInfo(b)),x}var Vee={kernelName:qo,backendName:"webgl",kernelFunc:Wee};function Uee(e){let{inputs:t,backend:n,attrs:s}=e,{x:r,filter:a,bias:o,preluActivationWeights:i}=t,{strides:l,pad:c,dilations:u,dimRoundingMode:d,activation:p,leakyreluAlpha:h}=s,f=[],m=u;m==null&&(m=[1,1]),w.assert(N.eitherStridesOrDilationsAreOne(l,m),()=>`Error in depthwiseConv2d: Either strides or dilations must be 1. Got strides ${l} and dilations '${m}'`);let g=N.computeConv2DInfo(r.shape,a.shape,l,m,c,d,!0),A=Y().getBool("WEBGL_PACK_DEPTHWISECONV")&&g.strideWidth<=2&&g.outChannels/g.inChannels==1,y=p?b0(p,A):null,x=[r,a],b=o!=null,v=i!=null,S=p==="leakyrelu";if(b&&x.push(o),v&&x.push(i),S){let P=n.makeTensorInfo([],"float32",w.createScalarValue(h,"float32"));x.push(P),f.push(P)}let T;A?T=new Nk(g,b,y,v,S):T=new Tk(g,b,y,v,S);let _=[[g.padInfo.top,g.padInfo.left],[g.strideHeight,g.strideWidth],[g.dilationHeight,g.dilationWidth],[g.inHeight,g.inWidth]],O=n.runWebGLProgram(T,x,"float32",_);return f.forEach(P=>n.disposeIntermediateTensorInfo(P)),O}var Gee={kernelName:Xo,backendName:"webgl",kernelFunc:Uee},Hee=class{constructor(e,t,n){this.sliceDim=e,this.strides=t,this.variableNames=["x","indices"],this.outputShape=n;let s=At(t.length),r=At(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 jee(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,c,u,d]=N.prepareAndValidate(s,r),p=we({inputs:{x:r},backend:n,attrs:{shape:[c,o]}}),h=we({inputs:{x:s},backend:n,attrs:{shape:[w.sizeFromShape(s.shape)/u,u]}});if(n.shouldExecuteOnCPU([s,r])||s.dtype==="string"){let A=n.readSync(r.dataId),y=n.bufferSync(s),x=sZ(A,y,s.dtype,c,o,u,d,s.shape,i);return n.makeTensorInfo(l,s.dtype,x.values)}let f=new Hee(o,d,[c,u]),m=n.runWebGLProgram(f,[h,p],h.dtype),g=we({inputs:{x:m},backend:n,attrs:{shape:l}});return n.disposeIntermediateTensorInfo(p),n.disposeIntermediateTensorInfo(h),n.disposeIntermediateTensorInfo(m),g}var qee={kernelName:hl,backendName:"webgl",kernelFunc:jee},Xee=class{constructor(e,t){this.variableNames=["A","indices"],this.outputShape=t,this.rank=t.length;let n=At(this.rank),s=Kee(e,2);this.userCode=`
|
|
void main() {
|
|
${n} resRC = getOutputCoords();
|
|
setOutput(getA(${s}));
|
|
}
|
|
`}};function Kee(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 Ok(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],c=n.readSync(a.dataId),u=r.shape[l];for(let b=0;b<c.length;++b){let v=c[b];w.assert(v<=u-1&&v>=0,()=>`GatherV2: the index value ${v} is not in [0, ${u-1}]`)}let d=N.segment_util.collectGatherOpShapeInfo(r,a,l,i),p=w.sizeFromShape(a.shape),h=[],f=we({inputs:{x:r},backend:n,attrs:{shape:[d.batchSize,d.outerSize,d.dimSize,d.sliceSize]}}),m=we({inputs:{x:a},backend:n,attrs:{shape:[d.batchSize,p/d.batchSize]}});h.push(f),h.push(m);let g=[d.batchSize,d.outerSize,p/d.batchSize,d.sliceSize];if(n.shouldExecuteOnCPU([r,a])||r.dtype==="string"){let b=n.bufferSync(m),v=n.bufferSync(f),S=rZ(v,b,g);return h.forEach(T=>n.disposeIntermediateTensorInfo(T)),n.makeTensorInfo(d.outputShape,S.dtype,S.values)}let A=new Xee(f.shape,g),y=n.runWebGLProgram(A,[f,m],f.dtype);h.push(y);let x=we({inputs:{x:y},backend:n,attrs:{shape:d.outputShape}});return h.forEach(b=>n.disposeIntermediateTensorInfo(b)),x}var Zee={kernelName:pl,backendName:"webgl",kernelFunc:Ok},Yee="return float(a > b);",Jee=`
|
|
return vec4(greaterThan(a, b));
|
|
`,Qee=yn({opSnippet:Yee,packedOpSnippet:Jee,cpuKernelImpl:aZ,dtype:"bool"}),ete={kernelName:fl,backendName:"webgl",kernelFunc:Qee},tte="return float(a >= b);",nte=`
|
|
return vec4(greaterThanEqual(a, b));
|
|
`,ste=yn({opSnippet:tte,packedOpSnippet:nte,dtype:"bool",cpuKernelImpl:oZ}),rte={kernelName:fo,backendName:"webgl",kernelFunc:ste};function ate(e){let{inputs:t,backend:n}=e,{input:s}=t;return Fk(s,!0,n)}var ote={kernelName:nh,backendName:"webgl",kernelFunc:ate},ite="return float(!isnan(x) && !isinf(x));",lte=nt({opSnippet:ite,dtype:"bool"}),ute={kernelName:ml,backendName:"webgl",kernelFunc:lte},cte="return float(isinf(x));",dte=nt({opSnippet:cte,dtype:"bool"}),pte={kernelName:gl,backendName:"webgl",kernelFunc:dte},hte="return float(isnan(x));",fte=nt({opSnippet:hte,dtype:"bool"}),mte={kernelName:Al,backendName:"webgl",kernelFunc:fte},gte="return float(a < b);",Ate=`
|
|
return vec4(lessThan(a, b));
|
|
`,yte=yn({opSnippet:gte,packedOpSnippet:Ate,cpuKernelImpl:iZ,dtype:"bool"}),xte={kernelName:yl,backendName:"webgl",kernelFunc:yte},bte="return float(a <= b);",vte=`
|
|
return vec4(lessThanEqual(a, b));
|
|
`,wte=yn({opSnippet:bte,packedOpSnippet:vte,cpuKernelImpl:lZ,dtype:"bool"}),kte={kernelName:xl,backendName:"webgl",kernelFunc:wte};function Ite(e){let{backend:t,attrs:n}=e,{start:s,stop:r,num:a}=n,o=uZ(s,r,a);return t.makeTensorInfo([o.length],"float32",o)}var Ste={kernelName:rh,backendName:"webgl",kernelFunc:Ite},Cte=`if (x < 0.0) return NAN;
|
|
return log(x);`,Tte=`
|
|
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;
|
|
`,Nte=nt({opSnippet:Cte,packedOpSnippet:Tte,cpuKernelImpl:cZ}),Ete={kernelName:Ao,backendName:"webgl",kernelFunc:Nte},Rte="return log(1.0 + x);",Dte=nt({opSnippet:Rte}),_te={kernelName:bl,backendName:"webgl",kernelFunc:Dte},Fte="return float(a >= 1.0 && b >= 1.0);",$te=`
|
|
return vec4(
|
|
vec4(greaterThanEqual(a, vec4(1.0))) *
|
|
vec4(greaterThanEqual(b, vec4(1.0))));
|
|
`,Ote=yn({opSnippet:Fte,packedOpSnippet:$te,dtype:"bool"}),Pte={kernelName:vl,backendName:"webgl",kernelFunc:Ote},Mte="return float(!(x >= 1.0));",zte=nt({opSnippet:Mte}),Lte={kernelName:wc,backendName:"webgl",kernelFunc:zte},Bte="return float(a >= 1.0 || b >= 1.0);",Wte=`
|
|
return min(
|
|
vec4(greaterThanEqual(a, vec4(1.0))) +
|
|
vec4(greaterThanEqual(b, vec4(1.0))),
|
|
vec4(1.0));
|
|
`,Vte=yn({opSnippet:Bte,packedOpSnippet:Wte,dtype:"bool"}),Ute={kernelName:kc,backendName:"webgl",kernelFunc:Vte},Gte=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);
|
|
}
|
|
`}},Hte=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);
|
|
}
|
|
`}},jte=e=>{let{inputs:t,backend:n,attrs:s}=e,{x:r}=t,{depthRadius:a,bias:o,alpha:i,beta:l}=s,c=Y().getBool("WEBGL_PACK_NORMALIZATION")?new Hte(r.shape,a,o,i,l):new Gte(r.shape,a,o,i,l);return n.runWebGLProgram(c,[r],r.dtype)},qte={kernelName:Ic,backendName:"webgl",kernelFunc:jte},Xte=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);
|
|
}
|
|
`}},Kte=e=>{let{inputs:t,backend:n,attrs:s}=e,{x:r,y:a,dy:o}=t,{depthRadius:i,bias:l,alpha:c,beta:u}=s,d=new Xte(r.shape,i,l,c,u);return n.runWebGLProgram(d,[r,a,o],r.dtype)},Zte={kernelName:ah,backendName:"webgl",kernelFunc:Kte};function Yte(e,t,n,s){let r=w.sizeFromShape(t),o=w.sizeFromShape(e.shape)/r,i=we({inputs:{x:e},attrs:{shape:[o,r]},backend:s}),l=Ti(i,e.dtype,"max",s),c=we({inputs:{x:l},attrs:{shape:n},backend:s});return s.disposeIntermediateTensorInfo(i),s.disposeIntermediateTensorInfo(l),c}function Pk(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),c=l,u=N.getAxesPermutation(c,i),d=u!=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 T=0;T<b.length;T++)b[T]=r.shape[u[T]];let v=V2(x,r.shape,r.dtype,u,b);h=n.makeTensorInfo(b,r.dtype);let S=n.texData.get(h.dataId);S.values=v}else h=v0(r,u,n);c=N.getInnerMostAxes(c.length,i)}N.assertAxesAreInnerMostDims("max",c,i);let[f,m]=N.computeOutAndReduceShapes(h.shape,c),g=f;o&&(g=N.expandShapeToKeepDim(f,l));let A;if(p){let x=n.texData.get(h.dataId).values,b=dZ(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=Yte(h,m,g,n);return d&&n.disposeIntermediateTensorInfo(h),A}var Jte={kernelName:yo,backendName:"webgl",kernelFunc:Pk},Qte=ek+`
|
|
return max(a, b);
|
|
`,ene=`
|
|
vec4 result = vec4(max(a, b));
|
|
vec4 isNaN = min(vec4(isnan(a)) + vec4(isnan(b)), vec4(1.0));
|
|
`+x0+`
|
|
return result;
|
|
`,tne=yn({opSnippet:Qte,packedOpSnippet:ene,cpuKernelImpl:pZ}),nne={kernelName:xo,backendName:"webgl",kernelFunc:tne};function sne(e){let{inputs:t,backend:n,attrs:s}=e,{x:r}=t;Eu(r,"maxPool");let{filterSize:a,strides:o,pad:i,dimRoundingMode:l}=s,c=1;w.assert(N.eitherStridesOrDilationsAreOne(o,c),()=>`Error in maxPool: Either strides or dilations must be 1. Got strides ${o} and dilations '${c}'`);let u=N.computePool2DInfo(r.shape,a,o,c,i,l);if(u.filterWidth===1&&u.filterHeight===1&&w.arraysEqual(u.inShape,u.outShape))return ds({inputs:{x:r},backend:n});let d=new Ld(u,"max",!1);return n.runWebGLProgram(d,[r],r.dtype)}var rne={kernelName:bo,backendName:"webgl",kernelFunc:sne};function ane(e){let{inputs:t,backend:n,attrs:s}=e,{x:r}=t,{filterSize:a,strides:o,pad:i,dataFormat:l,dimRoundingMode:c}=s,u=[1,1,1],d=N.computePool3DInfo(r.shape,a,o,u,i,c,l),p=new G2(d,"max",!1);return n.runWebGLProgram(p,[r],r.dtype)}var one={kernelName:Sc,backendName:"webgl",kernelFunc:ane},ine=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);
|
|
}
|
|
`}},lne=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,c=e.effectiveFilterWidth,u=i-1-e.padInfo.front,d=l-1-e.padInfo.top,p=c-1-e.padInfo.left,h=i*l*c-1;this.userCode=`
|
|
const ivec3 pads = ivec3(${u}, ${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 < ${c};
|
|
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} * ${c} +
|
|
wR * ${c} + wC;
|
|
float mask = float(maxPosValue == curPosValue ? 1.0 : 0.0);
|
|
|
|
dotProd += dyValue * mask;
|
|
}
|
|
}
|
|
}
|
|
setOutput(dotProd);
|
|
}
|
|
`}};function une(e){let{inputs:t,backend:n,attrs:s}=e,{dy:r,input:a}=t,o=a,{filterSize:i,strides:l,pad:c,dimRoundingMode:u}=s,d=[1,1,1],p=N.computePool3DInfo(o.shape,i,l,d,c,u),h=new G2(p,"max",!0),f=n.runWebGLProgram(h,[o],o.dtype),m=new lne(p),g=n.runWebGLProgram(m,[r,f],o.dtype);return n.disposeIntermediateTensorInfo(f),g}var cne={kernelName:ih,backendName:"webgl",kernelFunc:une};function dne(e){let{inputs:t,backend:n,attrs:s}=e,{dy:r,input:a,output:o}=t,i=a;Eu([a,o],"maxPoolGrad");let{filterSize:l,strides:c,pad:u,dimRoundingMode:d}=s,p=N.computePool2DInfo(i.shape,l,c,1,u,d),h=!0,f=new Ld(p,"max",h),m=n.runWebGLProgram(f,[i],i.dtype),g=new ine(p),A=n.runWebGLProgram(g,[r,m],i.dtype);return n.disposeIntermediateTensorInfo(m),A}var pne={kernelName:oh,backendName:"webgl",kernelFunc:dne};function hne(e,t,n,s){let r=new Ld(n,"max",!1),a=s.runWebGLProgram(r,[e],"float32");r=new Ld(n,"max",!0,!0,t);let o=s.runWebGLProgram(r,[e],"float32");return[a,o]}var fne={kernelName:lh,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 c=[1,1];w.assert(N.eitherStridesOrDilationsAreOne(a,c),()=>`Error in maxPool: Either strides or dilations must be 1. Got strides ${a} and dilations '${c}'`);let u=N.computePool2DInfo(s.shape,r,a,c,o),[d,p]=hne(s,i,u,l);return[d,p]}};function mne(e,t,n,s){let r=w.sizeFromShape(t),o=w.sizeFromShape(e.shape)/r,i=we({inputs:{x:e},attrs:{shape:[o,r]},backend:s}),l=Ti(i,"float32","mean",s),c=we({inputs:{x:l},attrs:{shape:n},backend:s});return s.disposeIntermediateTensorInfo(i),s.disposeIntermediateTensorInfo(l),c}var gne={kernelName:vo,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),c=l,u=N.getAxesPermutation(c,i),d=u!=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 _=0;_<v.length;_++)v[_]=s.shape[u[_]];let S=V2(b,s.shape,s.dtype,u,v);f=o.makeTensorInfo(v,s.dtype);let T=o.texData.get(f.dataId);T.values=S}else f=v0(s,u,o);h.push(f),c=N.getInnerMostAxes(c.length,i)}N.assertAxesAreInnerMostDims("sum",c,i);let[m,g]=N.computeOutAndReduceShapes(f.shape,c),A=m;r&&(A=N.expandShapeToKeepDim(m,l));let y=mne(f,g,A,o);for(let x of h)o.disposeIntermediateTensorInfo(x);return y}};function Ane(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),c=l,u=N.getAxesPermutation(c,i),d=r;u!=null&&(d=Pn({inputs:{x:r},backend:n,attrs:{perm:u}}),c=N.getInnerMostAxes(c.length,r.shape.length)),N.assertAxesAreInnerMostDims("min",c,i);let[p,h]=N.computeOutAndReduceShapes(d.shape,c),f=w.sizeFromShape(h),m=we({inputs:{x:d},backend:n,attrs:{shape:[-1,f]}}),g=Ti(m,m.dtype,"min",n),A;if(o){let y=N.expandShapeToKeepDim(p,l);A=we({inputs:{x:g},backend:n,attrs:{shape:y}})}else A=we({inputs:{x:g},backend:n,attrs:{shape:p}});return n.disposeIntermediateTensorInfo(m),n.disposeIntermediateTensorInfo(g),u!=null&&n.disposeIntermediateTensorInfo(d),A}var yne={kernelName:wo,backendName:"webgl",kernelFunc:Ane},xne=ek+`
|
|
return min(a, b);
|
|
`,bne=`
|
|
vec4 result = vec4(min(a, b));
|
|
vec4 isNaN = min(vec4(isnan(a)) + vec4(isnan(b)), vec4(1.0));
|
|
`+x0+`
|
|
return result;
|
|
`,vne=yn({opSnippet:xne,packedOpSnippet:bne,cpuKernelImpl:hZ}),wne={kernelName:ko,backendName:"webgl",kernelFunc:vne},kne=class{constructor(e,t,n){this.variableNames=["x"],this.outputShape=t.map((c,u)=>c[0]+e[u]+c[1]);let s=e.length,r=At(s),a=t.map(c=>c[0]).join(","),o=t.map((c,u)=>c[0]+e[u]).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}));
|
|
}
|
|
`}},Ine=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=At(s),a=t.map(h=>h[0]).join(","),o=t.map((h,f)=>h[0]+e[f]).join(","),i=On("rc",s),l=On("source",s),c=`${i[s-1]} < ${this.outputShape[s-1]}`,u=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()}), ${u});
|
|
${i[s-1]} += 1;
|
|
if(${c}) {
|
|
${h}
|
|
result[1] = getChannel(getX(${l.join()}), ${u});
|
|
}
|
|
`}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()}), ${u});
|
|
${i[s-1]} += 1;
|
|
if(${c}) {
|
|
${h}
|
|
result[1] = getChannel(getX(${l.join()}), ${u});
|
|
}
|
|
rc = outputLoc;
|
|
${i[s-2]} += 1;
|
|
if(${i[s-2]} < ${this.outputShape[s-2]}) {
|
|
${h}
|
|
result[2] = getChannel(getX(${l.join()}), ${u});
|
|
${i[s-1]} += 1;
|
|
if(${c}) {
|
|
${h}
|
|
result[3] = getChannel(getX(${l.join()}), ${u});
|
|
}
|
|
}
|
|
`}this.userCode=`
|
|
const ${r} start = ${r}(${a});
|
|
const ${r} end = ${r}(${o});
|
|
|
|
void main() {
|
|
${r} outputLoc = getOutputCoords();
|
|
vec4 result = vec4(0.);
|
|
${p}
|
|
setOutput(result);
|
|
}
|
|
`}},Sne=({inputs:e,backend:t,attrs:n})=>{let{x:s}=e,{paddings:r,mode:a}=n,o=Y().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new Ine(s.shape,r,a):new kne(s.shape,r,a);return t.runWebGLProgram(o,[s],s.dtype)},Cne={kernelName:Io,backendName:"webgl",kernelFunc:Sne},Tne=`if (b == 0.0) return NAN;
|
|
return mod(a, b);`,Nne=`
|
|
vec4 result = mod(a, b);
|
|
vec4 isNaN = vec4(equal(b, vec4(0.0)));
|
|
`+x0+`
|
|
return result;
|
|
`,Ene=yn({opSnippet:Tne,packedOpSnippet:Nne}),Rne={kernelName:wl,backendName:"webgl",kernelFunc:Ene},Dne=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}));
|
|
}
|
|
`}},_ne=`
|
|
if (a == b) {
|
|
return 1.0;
|
|
};
|
|
return a / b;`,Fne=`
|
|
// 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;
|
|
`,Mk=yn({opSnippet:_ne,packedOpSnippet:Fne,checkOutOfBounds:!0}),$ne={kernelName:io,backendName:"webgl",kernelFunc:Mk},zk="return a - b;",Lk=yn({opSnippet:zk,packedOpSnippet:zk,supportsComplex:!0,cpuKernelImpl:EZ}),One={kernelName:Vo,backendName:"webgl",kernelFunc:Lk};function Bk(e){let{inputs:t,backend:n,attrs:s}=e,{logits:r}=t,{dim:a}=s,o=w.parseAxisParam([a],r.shape),i=Pk({inputs:{x:r},backend:n,attrs:{reductionIndices:o,keepDims:!1}}),l=N.expandShapeToKeepDim(i.shape,o),c=we({inputs:{x:i},backend:n,attrs:{shape:l}}),u=Lk({inputs:{a:r,b:c},backend:n}),d=Rk({inputs:{x:u},backend:n}),p=w0({inputs:{x:d},backend:n,attrs:{axis:o,keepDims:!1}}),h=we({inputs:{x:p},backend:n,attrs:{shape:l}}),f=Mk({inputs:{a:d,b:h},backend:n});return n.disposeIntermediateTensorInfo(i),n.disposeIntermediateTensorInfo(c),n.disposeIntermediateTensorInfo(u),n.disposeIntermediateTensorInfo(d),n.disposeIntermediateTensorInfo(p),n.disposeIntermediateTensorInfo(h),f}var Pne={kernelName:Bo,backendName:"webgl",kernelFunc:Bk};function Mne(e){let{inputs:t,backend:n,attrs:s}=e,{logits:r}=t,{numSamples:a,seed:o,normalized:i}=s,l=i?r:Bk({inputs:{logits:r},backend:n,attrs:{dim:r.shape.length-1}}),c=l.shape[0],u=l.shape[1],d=new Dne(c,u,a),p=[[o]],h=n.runWebGLProgram(d,[l],"int32",p);return i||n.disposeIntermediateTensorInfo(l),h}var zne={kernelName:uh,backendName:"webgl",kernelFunc:Mne},Wk="return -x;";function Lne(e){let{inputs:t,backend:n}=e,{x:s}=t;if(n.shouldExecuteOnCPU([s])){let a=n.texData.get(s.dataId),[o,i]=mZ(a.values,s.shape,s.dtype);return n.makeTensorInfo(i,s.dtype,o)}let r;return Y().getBool("WEBGL_PACK_UNARY_OPERATIONS")?r=new $u(s.shape,Wk):r=new _a(s.shape,Wk),n.runWebGLProgram(r,[s],s.dtype)}var Bne={kernelName:kl,backendName:"webgl",kernelFunc:Lne},Wne=br.nonMaxSuppressionV3Impl;function Vne(e){N.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,c=n.readSync(r.dataId),u=n.readSync(a.dataId),{selectedIndices:d}=Wne(c,u,o,i,l);return n.makeTensorInfo([d.length],"int32",new Int32Array(d))}var Une={kernelName:Sl,backendName:"webgl",kernelFunc:Vne},Gne=br.nonMaxSuppressionV4Impl;function Hne(e){N.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:c}=s,u=n.readSync(r.dataId),d=n.readSync(a.dataId),{selectedIndices:p,validOutputs:h}=Gne(u,d,o,i,l,c);return[n.makeTensorInfo([p.length],"int32",new Int32Array(p)),n.makeTensorInfo([],"int32",new Int32Array([h]))]}var jne={kernelName:Cl,backendName:"webgl",kernelFunc:Hne},qne=br.nonMaxSuppressionV5Impl;function Xne(e){N.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:c}=s,u=n.readSync(r.dataId),d=n.readSync(a.dataId),p=o,h=i,f=l,m=c,{selectedIndices:g,selectedScores:A}=qne(u,d,p,h,f,m);return[n.makeTensorInfo([g.length],"int32",new Int32Array(g)),n.makeTensorInfo([A.length],"float32",new Float32Array(A))]}var Kne={kernelName:Tl,backendName:"webgl",kernelFunc:Xne},Zne=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)));
|
|
}
|
|
`}},Yne=e=>{let{inputs:t,backend:n,attrs:s}=e,{indices:r}=t,{depth:a,onValue:o,offValue:i}=s,l=w.sizeFromShape(r.shape),c=new Zne(l,a,o,i),u=we({inputs:{x:r},backend:n,attrs:{shape:[l]}}),d=n.runWebGLProgram(c,[u],r.dtype);n.disposeIntermediateTensorInfo(u);let p=[...r.shape,a],h=we({inputs:{x:d},backend:n,attrs:{shape:p}});return n.disposeIntermediateTensorInfo(d),h},Jne={kernelName:Co,backendName:"webgl",kernelFunc:Yne};function T0(e){let{inputs:t,backend:n}=e,{x:s}=t;if(s.dtype==="complex64"){let r=Bd({inputs:{input:s},backend:n}),a=T0({inputs:{x:r},backend:n}),o=C0({inputs:{input:s},backend:n}),i=T0({inputs:{x:o},backend:n}),l=Fa({inputs:{real:a,imag:i},backend:n});return n.disposeIntermediateTensorInfo(r),n.disposeIntermediateTensorInfo(a),n.disposeIntermediateTensorInfo(o),n.disposeIntermediateTensorInfo(i),l}else return Wd({attrs:{shape:s.shape,dtype:s.dtype,value:s.dtype==="string"?"":0},backend:n})}var Qne={kernelName:jl,backendName:"webgl",kernelFunc:T0};function Vk(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=Vk({inputs:{x:r},backend:n}),o=C0({inputs:{input:s},backend:n}),i=T0({inputs:{x:o},backend:n}),l=Fa({inputs:{real:a,imag:i},backend:n});return n.disposeIntermediateTensorInfo(r),n.disposeIntermediateTensorInfo(a),n.disposeIntermediateTensorInfo(o),n.disposeIntermediateTensorInfo(i),l}else return Wd({attrs:{shape:s.shape,dtype:s.dtype,value:1},backend:n})}var ese={kernelName:Nl,backendName:"webgl",kernelFunc:Vk};function tse(e){let{inputs:t,backend:n,attrs:s}=e,{axis:r}=s;if(t.length===1)return q2({inputs:{input:t[0]},backend:n,attrs:{dim:r}});let a=t[0].shape,o=t[0].dtype;t.forEach(u=>{w.assertShapesMatch(a,u.shape,"All tensors passed to stack must have matching shapes"),w.assert(o===u.dtype,()=>"All tensors passed to stack must have matching dtypes")});let i=[],l=t.map(u=>{let d=q2({inputs:{input:u},backend:n,attrs:{dim:r}});return i.push(d),d}),c=bk({inputs:l,backend:n,attrs:{axis:r}});return i.forEach(u=>n.disposeIntermediateTensorInfo(u)),c}var nse={kernelName:El,backendName:"webgl",kernelFunc:tse},sse=class{constructor(e,t,n){this.variableNames=["x"],this.customUniforms=[{name:"value",type:"float"}],this.outputShape=t.map((l,c)=>l[0]+e[c]+l[1]);let s=e.length,r=At(s),a=t.map(l=>l[0]).join(","),o=t.map((l,c)=>l[0]+e[c]).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}));
|
|
}
|
|
}
|
|
`}},rse=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=At(s),a=t.map(f=>f[0]).join(","),o=t.map((f,m)=>f[0]+e[m]).join(","),i=On("rc",s),l=On("source",s),c=`${i[s-1]} < ${this.outputShape[s-1]}`,u=s===1?"source":`vec2(${l.slice(-2).join()})`,d=[`${r} rc = outputLoc;`,`${i[s-1]} += 1;
|
|
if(${c}) {
|
|
`,s===1?"":`}
|
|
rc = outputLoc;
|
|
${i[s-2]} += 1;
|
|
if(${i[s-2]} < ${this.outputShape[s-2]}) {`,s===1?"":` ${i[s-1]} += 1;
|
|
if(${c}) {`],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()}), ${u});
|
|
}
|
|
`;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);
|
|
}
|
|
`}},Uk=e=>{let{inputs:t,backend:n,attrs:s}=e,{x:r}=t,{paddings:a,constantValue:o}=s;if(w.sizeFromShape(r.shape)===0){let c=a.map((u,d)=>u[0]+r.shape[d]+u[1]);return Wd({backend:n,attrs:{shape:c,value:o,dtype:r.dtype}})}let i=Y().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new rse(r.shape,a,o):new sse(r.shape,a,o),l=[[o]];return n.runWebGLProgram(i,[r],r.dtype,l)},ase={kernelName:To,backendName:"webgl",kernelFunc:Uk},ose=`
|
|
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);
|
|
`,ise=`
|
|
// 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));
|
|
`+x0+`
|
|
return result;
|
|
`,lse=yn({opSnippet:ose,packedOpSnippet:ise}),use={kernelName:No,backendName:"webgl",kernelFunc:lse};function cse(e){let{inputs:t,backend:n,attrs:s}=e,{x:r}=t,{axis:a,keepDims:o}=s,i=r.shape.length,l=[],c=w.parseAxisParam(a,r.shape),u=c,d=N.getAxesPermutation(u,i),p=r;d!=null&&(p=Pn({inputs:{x:r},backend:n,attrs:{perm:d}}),u=N.getInnerMostAxes(u.length,i),l.push(p)),N.assertAxesAreInnerMostDims("prod",u,i);let h;if(n.shouldExecuteOnCPU([p])){let f=n.texData.get(p.dataId).values,{outVals:m,outShape:g,outDtype:A}=AZ(p.shape,p.dtype,f,u);h=n.makeTensorInfo(g,A,m)}else{let[f,m]=N.computeOutAndReduceShapes(p.shape,u),g=w.sizeFromShape(m),A=we({inputs:{x:p},backend:n,attrs:{shape:[-1,g]}}),y=Nh(r.dtype),x=Ti(A,y,"prod",n);h=we({inputs:{x},backend:n,attrs:{shape:f}}),l.push(A),l.push(x)}if(o){l.push(h);let f=N.expandShapeToKeepDim(h.shape,c);h=we({inputs:{x:h},backend:n,attrs:{shape:f}})}return l.forEach(f=>n.disposeIntermediateTensorInfo(f)),h}var dse={kernelName:Rl,backendName:"webgl",kernelFunc:cse},Gk=e=>{let{backend:t,attrs:n}=e,{start:s,stop:r,step:a,dtype:o}=n,i=yZ(s,r,a,o);return t.makeTensorInfo([i.length],o,i)},pse={kernelName:Cc,backendName:"webgl",kernelFunc:Gk},hse="return 1.0 / x;",fse=nt({opSnippet:hse}),mse={kernelName:Dl,backendName:"webgl",kernelFunc:fse},gse=or+`
|
|
return (x < 0.0) ? 0.0 : x;
|
|
`,Ase=`
|
|
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;
|
|
`,yse=nt({opSnippet:gse,packedOpSnippet:Ase}),xse={kernelName:Ro,backendName:"webgl",kernelFunc:yse},bse=or+`
|
|
return (x < 0.0) ? 0.0 : min(6.0, x);
|
|
`,vse=`
|
|
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;
|
|
`,wse=nt({opSnippet:bse,packedOpSnippet:vse}),kse={kernelName:_o,backendName:"webgl",kernelFunc:wse},Ise=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 c=[s&&t>1?o-1:o,s&&n>1?i-1:i],u=[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(
|
|
${c[0]/u[0]},
|
|
${c[1]/u[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);
|
|
}
|
|
`}},Sse=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 c=[s&&t>1?o-1:o,s&&n>1?i-1:i],u=[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(
|
|
${c[0]/u[0]},
|
|
${c[1]/u[1]},
|
|
${c[1]/u[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 Cse(e){let{inputs:t,backend:n,attrs:s}=e,{images:r}=t,{alignCorners:a,halfPixelCenters:o,size:i}=s,[l,c]=i,u=Y().getBool("WEBGL_PACK_IMAGE_OPERATIONS")?new Sse(r.shape,l,c,a,o):new Ise(r.shape,l,c,a,o);return n.runWebGLProgram(u,[r],"float32")}var Tse={kernelName:Do,backendName:"webgl",kernelFunc:Cse},Nse=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],c=i[0]/l[0],u=i[1]/l[1],d=1/c,p=1/u,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(${c});
|
|
const float widthScale = float(${u});
|
|
|
|
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 Ese(e){let{inputs:t,backend:n,attrs:s}=e,{images:r,dy:a}=t,{alignCorners:o}=s,i=new Nse(a.shape,r.shape,o);return n.runWebGLProgram(i,[a],a.dtype)}var Rse={kernelName:ph,backendName:"webgl",kernelFunc:Ese},Dse=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 c=[s&&t>1?o-1:o,s&&n>1?i-1:i],u=[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(
|
|
${c[0]/u[0]},
|
|
${c[1]/u[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);
|
|
}
|
|
`}},_se=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 c=[s&&t>1?o-1:o,s&&n>1?i-1:i],u=[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(
|
|
${c[0]/u[0]},
|
|
${c[1]/u[1]},
|
|
${c[1]/u[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 Fse(e){let{inputs:t,backend:n,attrs:s}=e,{images:r}=t,{alignCorners:a,halfPixelCenters:o,size:i}=s,[l,c]=i,u=Y().getBool("WEBGL_PACK_IMAGE_OPERATIONS")?new _se(r.shape,l,c,a,o):new Dse(r.shape,l,c,a,o);return n.runWebGLProgram(u,[r],r.dtype)}var $se={kernelName:Tc,backendName:"webgl",kernelFunc:Fse},Ose=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],c=i[0]/l[0],u=i[1]/l[1],d=1/c,p=1/u,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(${c});
|
|
const float widthScale = float(${u});
|
|
|
|
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 Pse(e){let{inputs:t,backend:n,attrs:s}=e,{images:r,dy:a}=t,{alignCorners:o}=s,i=new Ose(a.shape,r.shape,o);return n.runWebGLProgram(i,[a],a.dtype)}var Mse={kernelName:dh,backendName:"webgl",kernelFunc:Pse},zse=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=At(n);this.userCode=`
|
|
void main() {
|
|
${a} coords = getOutputCoords();
|
|
setOutput(getX(${r}));
|
|
}
|
|
`}},Lse=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=On("rc",n),r=`${s[n-1]} + 1 < ${this.outputShape[n-1]}`,a=`${s[n-2]} + 1 < ${this.outputShape[n-2]}`,o=At(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 = ${c(s.slice())};
|
|
if(${r}) {
|
|
result.a = ${u(s.slice())};
|
|
}
|
|
}
|
|
setOutput(result);
|
|
}
|
|
`;function i(h){return d(h)}function l(h){return h[n-1]="("+h[n-1]+" + 1)",d(h)}function c(h){return h[n-2]="("+h[n-2]+" + 1)",d(h)}function u(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 Bse(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 Lse(r.shape,i):new zse(r.shape,i);return n.runWebGLProgram(l,[r],r.dtype)}var Wse={kernelName:Fo,backendName:"webgl",kernelFunc:Bse},Vse=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);
|
|
}
|
|
`}},Use={kernelName:ql,backendName:"webgl",kernelFunc:({inputs:e,attrs:t,backend:n})=>{let{image:s}=e,{radians:r,fillValue:a,center:o}=t,i=n,l=new Vse(s.shape,a),[c,u]=N.getImageCenter(o,s.shape[1],s.shape[2]),d=[[c,u,Math.sin(r),Math.cos(r)]];return i.runWebGLProgram(l,[s],s.dtype,d)}},Gse=`
|
|
// 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;
|
|
}
|
|
}
|
|
`,Hse=nt({opSnippet:Gse}),jse={kernelName:$o,backendName:"webgl",kernelFunc:Hse},qse="return inversesqrt(x);",Xse=nt({opSnippet:qse,cpuKernelImpl:xZ}),Kse={kernelName:Oo,backendName:"webgl",kernelFunc:Xse},Hk=class{constructor(e,t,n,s,r,a,o=!0){this.variableNames=["updates","indices","defaultValue"],this.outputShape=a;let i=At(r.length),l=At(a.length),c="";n===1?c="i":n===2&&(c="i, j");let u=`getIndices(${c})`,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(${u});
|
|
flattenedIndex += index * ${h};
|
|
}
|
|
if (flattenedIndex == coords[0]) {
|
|
sum += ${p};
|
|
found = true;
|
|
}
|
|
}
|
|
setOutput(mix(getDefaultValue(), sum, float(found)));
|
|
}
|
|
`}};function Zse(e){let{inputs:t,backend:n,attrs:s}=e,{indices:r,updates:a}=t,{shape:o}=s,{sliceRank:i,numUpdates:l,sliceSize:c,strides:u,outputSize:d}=N.calculateShapes(a,r,o),p=[d/c,c];if(d===0)return n.makeTensorInfo(o,r.dtype);let h=we({inputs:{x:r},backend:n,attrs:{shape:[l,i]}}),f=we({inputs:{x:a},backend:n,attrs:{shape:[l,c]}}),m=n.makeTensorInfo([],"float32",new Float32Array([0])),g=new Hk(l,i,h.shape.length,f.shape.length,u,p),A=n.runWebGLProgram(g,[f,h,m],f.dtype),y=we({inputs:{x:A},backend:n,attrs:{shape:o}});return n.disposeIntermediateTensorInfo(h),n.disposeIntermediateTensorInfo(f),n.disposeIntermediateTensorInfo(A),n.disposeIntermediateTensorInfo(m),y}var Yse={kernelName:Fl,backendName:"webgl",kernelFunc:Zse},Jse=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 c=0;c<t.length;c++)l.push(`${o[c]}`),c<e&&i.push(`${o[c]}`);s=i.join(),r=l.join()}let a=At(n);this.userCode=`
|
|
void main() {
|
|
${a} resRC = getOutputCoords();
|
|
float cVal = getC(${s});
|
|
if (cVal >= 1.0) {
|
|
setOutput(getA(${r}));
|
|
} else {
|
|
setOutput(getB(${r}));
|
|
}
|
|
}
|
|
`}};function Qse(e){let{inputs:t,backend:n}=e,{condition:s,t:r,e:a}=t,o=new Jse(s.shape.length,r.shape,r.shape.length);return n.runWebGLProgram(o,[s,r,a],$s(r.dtype,a.dtype))}var ere={kernelName:$l,backendName:"webgl",kernelFunc:Qse},tre=`
|
|
// Stable and Attracting Fixed Point (0, 1) for Normalized Weights.
|
|
// see: https://arxiv.org/abs/1706.02515
|
|
float scaleAlpha = ${N.SELU_SCALEALPHA};
|
|
float scale = ${N.SELU_SCALE};
|
|
return (x >= 0.0) ? scale * x : scaleAlpha * (exp(x) - 1.0);
|
|
`,nre=nt({opSnippet:tre}),sre={kernelName:Ol,backendName:"webgl",kernelFunc:nre},jk="return 1.0 / (1.0 + exp(-1.0 * x));",rre=nt({opSnippet:jk,packedOpSnippet:jk,cpuKernelImpl:bZ}),are={kernelName:Mo,backendName:"webgl",kernelFunc:rre},ore=`
|
|
if (isnan(x)) { return 0.0; }
|
|
return sign(x);
|
|
`,ire=nt({opSnippet:ore}),lre={kernelName:zl,backendName:"webgl",kernelFunc:ire},ure=ak+`
|
|
return sin(x);
|
|
`,cre=nt({opSnippet:ure}),dre={kernelName:Po,backendName:"webgl",kernelFunc:cre},pre=`
|
|
float e2x = exp(x);
|
|
return (e2x - 1.0 / e2x) / 2.0;
|
|
`,hre=nt({opSnippet:pre}),fre={kernelName:Ml,backendName:"webgl",kernelFunc:hre},mre=`
|
|
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;
|
|
`,gre=nt({opSnippet:mre}),Are={kernelName:Ll,backendName:"webgl",kernelFunc:gre},yre=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 c=[],u=Uk({inputs:{x:r},backend:n,attrs:{paddings:l,constantValue:0}}),d=N.getReshaped(u.shape,a,i,!1),p=N.getPermuted(d.length,a.length,!1),h=N.getReshapedPermuted(u.shape,a,i,!1),f=we({inputs:{x:u},backend:n,attrs:{shape:d}}),m=Pn({inputs:{x:f},backend:n,attrs:{perm:p}}),g=we({inputs:{x:m},backend:n,attrs:{shape:h}});return c.push(u),c.push(f),c.push(m),c.forEach(A=>n.disposeIntermediateTensorInfo(A)),g},xre={kernelName:Bl,backendName:"webgl",kernelFunc:yre};function bre(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),c=n.readSync(a.dataId),u=n.readSync(o.dataId)[0],[d,p,h,f,m]=wZ(i,s.shape,s.dtype,l,r.dtype,c,u);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 vre={kernelName:hh,backendName:"webgl",kernelFunc:bre};function wre(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)),[c,u,d]=kZ(i,s.shape,s.dtype,o,l);return[n.makeTensorInfo(u,s.dtype,c),n.makeTensorInfo([d.length],a.dtype,new Int32Array(d))]}var kre={kernelName:fh,backendName:"webgl",kernelFunc:wre};function Ire(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),[c,u]=j4(o,s.shape,s.dtype,i,l,!0);return n.makeTensorInfo(u,s.dtype,c)}var Sre={kernelName:mh,backendName:"webgl",kernelFunc:Ire};function Cre(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),[c,u]=j4(o,s.shape,s.dtype,i,l);return n.makeTensorInfo(u,s.dtype,c)}var Tre={kernelName:gh,backendName:"webgl",kernelFunc:Cre};function Nre(e){let{inputs:t,backend:n,attrs:s}=e,{sparseIndices:r,sparseValues:a,defaultValue:o}=t,{outputShape:i}=s,{sliceRank:l,numUpdates:c,strides:u,outputSize:d}=N.calculateShapes(a,r,i),p=!1,h=new Hk(c,l,r.shape.length,a.shape.length,u,[d,1],p),f=n.runWebGLProgram(h,[a,r,o],a.dtype),m=we({inputs:{x:f},backend:n,attrs:{shape:i}});return n.disposeIntermediateTensorInfo(f),m}var Ere={kernelName:Ah,backendName:"webgl",kernelFunc:Nre};function Rre(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=N.prepareSplitSize(r,a,i),c=r.shape.length,u=new Array(c).fill(0),d=r.shape.slice();return l.map(p=>{let h=[...d];h[i]=p;let f=Mu({inputs:{x:r},backend:n,attrs:{begin:u,size:h}});return u[i]+=p,f})}var Dre={kernelName:Wl,backendName:"webgl",kernelFunc:Rre},qk="return sqrt(x);",_re=nt({opSnippet:qk,packedOpSnippet:qk,cpuKernelImpl:IZ}),Fre={kernelName:zo,backendName:"webgl",kernelFunc:_re},$re="return x * x;",Ore=nt({opSnippet:$re}),Pre={kernelName:Nc,backendName:"webgl",kernelFunc:Ore},Xk="return (a - b) * (a - b);",Mre=yn({opSnippet:Xk,packedOpSnippet:Xk}),zre={kernelName:Wo,backendName:"webgl",kernelFunc:Mre};function Lre({inputs:e,attrs:t,backend:n}){let{x:s}=e,r=or+`
|
|
return x > 0.0 ? 1.0 : float(${t.alpha});
|
|
`,a=new _a(s.shape,r);return n.runWebGLProgram(a,[s],s.dtype)}var Bre={kernelName:da,backendName:"webgl",kernelFunc:Lre},Wre=class{constructor(e,t,n){this.variableNames=["x"],this.outputShape=n;let s=n.length,r=At(n.length),a=At(n.length),o="";if(s===1)o="coords * strides + begin";else{let i=0;o=n.map((l,c)=>(i++,n.length===1?`coords * strides[${c}] + begin[${c}]`:`coords[${i-1}] * strides[${c}] + begin[${c}]`)).join(",")}this.userCode=`
|
|
${r} begin = ${r}(${e});
|
|
${r} strides = ${r}(${t});
|
|
|
|
void main() {
|
|
${a} coords = getOutputCoords();
|
|
setOutput(getX(${o}));
|
|
}
|
|
`}};function Vre(e){let{inputs:t,backend:n,attrs:s}=e,{x:r}=t,{begin:a,end:o,strides:i,beginMask:l,endMask:c,ellipsisMask:u,newAxisMask:d,shrinkAxisMask:p}=s,{nonStrided:h,$begin:f,$strides:m,size:g,newShape:A,outShape:y}=En.sliceInfo(r.shape,a,o,i,l,c,u,d,p),x=we({inputs:{x:r},backend:n,attrs:{shape:A}}),b;if(h){let S=Mu({inputs:{x},backend:n,attrs:{begin:f,size:g}});b=we({inputs:{x:S},backend:n,attrs:{shape:y}}),n.disposeIntermediateTensorInfo(S)}else if(y.some(S=>S===0))b=n.makeTensorInfo(y,r.dtype,[]);else if(n.shouldExecuteOnCPU([x])){let _=n.texData.get(x.dataId).values,O=He(x.shape,x.dtype,_),P=SZ(y,O,m,f);b=n.makeTensorInfo(y,x.dtype,P.values)}else{let T=new Wre(f,m,y);b=n.runWebGLProgram(T,[x],x.dtype)}let v=we({inputs:{x:b},backend:n,attrs:{shape:y}});return n.disposeIntermediateTensorInfo(x),n.disposeIntermediateTensorInfo(b),v}var Ure={kernelName:Vl,backendName:"webgl",kernelFunc:Vre};function Gre(e){let{inputs:t,backend:n,attrs:s}=e,{separator:r,nGramWidths:a,leftPad:o,rightPad:i,padWidth:l,preserveShortSequences:c}=s,{data:u,dataSplits:d}=t,p=n.readSync(u.dataId),h=n.readSync(d.dataId),[f,m]=CZ(p,h,r,a,o,i,l,c);return[n.makeTensorInfo([f.length],"string",f),n.makeTensorInfo(d.shape,"int32",m)]}var Hre={kernelName:yh,backendName:"webgl",kernelFunc:Gre};function jre(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],[c,u,d]=TZ(i,l,r),p=u.length;return[n.makeTensorInfo([p,2],"int32",c),n.makeTensorInfo([p],"string",u),n.makeTensorInfo([2],"int32",new Int32Array(d))]}var qre={kernelName:xh,backendName:"webgl",kernelFunc:jre};function Xre(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=NZ(o,r);return n.makeTensorInfo(a.shape,"int32",i)}var Kre={kernelName:bh,backendName:"webgl",kernelFunc:Xre},Zre="return tan(x);",Yre=nt({opSnippet:Zre}),Jre={kernelName:Uo,backendName:"webgl",kernelFunc:Yre},Qre=`
|
|
float e2x = exp(-2.0 * abs(x));
|
|
return sign(x) * (1.0 - e2x) / (1.0 + e2x);
|
|
`,eae=nt({opSnippet:Qre}),tae={kernelName:Go,backendName:"webgl",kernelFunc:eae},nae=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=At(this.rank),r=sae(e);this.userCode=`
|
|
void main() {
|
|
${s} resRC = getOutputCoords();
|
|
setOutput(getA(${r}));
|
|
}
|
|
`}};function sae(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 Kk(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),c=r.dtype==="string"?l.map(p=>w.decodeString(p)):l,u=He(r.shape,r.dtype,c),d=RZ(u,a);return n.makeTensorInfo(d.shape,d.dtype,d.values)}let o=new nae(r.shape,a);return n.runWebGLProgram(o,[r],r.dtype)}var rae={kernelName:ca,backendName:"webgl",kernelFunc:Kk},aae=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));
|
|
}
|
|
}
|
|
`}},oae=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 Ni(e,t){t!==null&&e.disposeIntermediateTensorInfo(t)}function Zk(e){let t=1;for(;t<e;)t*=2;return t}function iae(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"),c=r.shape,u=c[c.length-1];if(n.shouldExecuteOnCPU([r])||u<i||a>l){let P=n.readSync(r.dataId),[D,F]=DZ(P,c,r.dtype,a,o);return[n.makeTensorInfo(D.shape,D.dtype,D.values),n.makeTensorInfo(F.shape,F.dtype,F.values)]}if(a===0)return c[c.length-1]=0,[n.makeTensorInfo(c,r.dtype,[]),n.makeTensorInfo(c,"int32",[])];if(u===1)return[r,Wd({attrs:{shape:c,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(c)/u,g=we({inputs:{x:h},attrs:{shape:[m,u]},backend:n});p&&Ni(n,h);let A=Zk(a),y=Zk(u),x=null,b=()=>x===null?[g,g]:[g,x],v=(P,D,F)=>{let C=b(),M=new aae(F),j=[[u],[x===null?1:0],[Number.NEGATIVE_INFINITY],[P],[D]],q=x;x=n.runWebGLProgram(M,C,"int32",j),Ni(n,q)};for(let P=1;P<A;P*=2){let D=P*2;for(let F=P;F>=1;F/=2)v(D,F,[m,y])}for(let P=y;P>A;P/=2){let D=b(),F=new oae([m,P/2]),M=[[u],[x===null?1:0],[A]],U=x;x=n.runWebGLProgram(F,D,"int32",M),Ni(n,U);let j=A/2,q=j*2;for(let X=j;X>=1;X/=2)v(q,X,x.shape)}let S=x;x=Mu({inputs:{x},backend:n,attrs:{begin:0,size:[m,a]}}),Ni(n,S);let T=Ok({inputs:{x:g,indices:x},backend:n,attrs:{axis:1,batchDims:1}});Ni(n,g);let _=c.slice(0,-1);_.push(a),S=x,x=we({inputs:{x},attrs:{shape:_},backend:n}),Ni(n,S);let O=T;return T=we({inputs:{x:T},attrs:{shape:_},backend:n}),Ni(n,O),[T,x]}var lae={kernelName:Ul,backendName:"webgl",kernelFunc:iae},uae=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 cae(e){let{inputs:t,backend:n,attrs:s}=e,{image:r,transforms:a}=t,{interpolation:o,fillMode:i,fillValue:l,outputShape:c}=s,[u,d,p,h]=r.shape,[f,m]=c??[d,p],g=[u,f,m,h],A=new uae(d,p,o,i,l,g);return n.runWebGLProgram(A,[r,a],"float32")}var dae={kernelName:Gl,backendName:"webgl",kernelFunc:cae};function pae(e){let{inputs:t,attrs:n,backend:s}=e,{axis:r}=n,{x:a}=t;Eu(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:c}=_Z(o,r,a.shape,a.dtype);return[s.makeTensorInfo(l,a.dtype,i),s.makeTensorInfo([c.length],"int32",c)]}var hae={kernelName:vh,backendName:"webgl",kernelFunc:pae};function fae(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],c=new Array(i-1),u=0;for(let m=0;m<i;m++)m!==a&&(c[u++]=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=Mu({inputs:{x:o},backend:n,attrs:{begin:p,size:h}}),A=we({inputs:{x:g},backend:n,attrs:{shape:c}});f[m]=A,d.push(g)}return d.forEach(m=>n.disposeIntermediateTensorInfo(m)),f}var mae={kernelName:Hl,backendName:"webgl",kernelFunc:fae},gae=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",c=Math.floor(n/4)*4,u=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 < ${c}; 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 + ${c};
|
|
if (${u===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 (${u===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 (${u===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 Aae(e){let{inputs:t,backend:n,attrs:s}=e,{x:r,segmentIds:a}=t,{numSegments:o}=s,i=r.shape.length,l=[],c=0,u=N.getAxesPermutation([c],i),d=r;u!=null&&(d=Pn({inputs:{x:r},backend:n,attrs:{perm:u}}),l.push(d),c=N.getInnerMostAxes(1,i)[0]);let p=N.segment_util.computeOutShape(d.shape,c,o),h=w.sizeFromShape([d.shape[c]]),f=we({inputs:{x:d},backend:n,attrs:{shape:[-1,h]}});l.push(f);let m=Nh(r.dtype),g=(b,v,S,T,_)=>{let O=b.shape[0],P=b.shape[1],D=N.segment_util.segOpComputeOptimalWindowSize(P,_),F={windowSize:D,inSize:P,batchSize:O,numSegments:_},C=new gae(F,v),M=n.compileAndRun(C,[b,S],T);if(l.push(M),M.shape[1]===_)return M;let U=Gk({backend:n,attrs:{start:0,stop:_,step:1,dtype:"float32"}}),j=Kk({inputs:{x:U},backend:n,attrs:{reps:[P/D]}});return l.push(U),l.push(j),g(M,v,j,T,_)},A=g(f,"unsortedSegmentSum",a,m,o),y=we({inputs:{x:A},backend:n,attrs:{shape:p}}),x=y;if(u!=null){l.push(y);let b=N.getUndoAxesPermutation(u);x=Pn({inputs:{x},backend:n,attrs:{perm:b}})}return l.forEach(b=>n.disposeIntermediateTensorInfo(b)),x}var yae={kernelName:Ec,backendName:"webgl",kernelFunc:Aae},xae=[qte,Zte,DY,FY,PY,LY,WY,GY,jY,XY,JY,eJ,sJ,oJ,hJ,uJ,gJ,bJ,yJ,IJ,CJ,NJ,_J,LJ,WJ,UJ,KJ,YJ,tQ,rQ,pY,uQ,xQ,vQ,hQ,SQ,TQ,kQ,RQ,FQ,PQ,zQ,BQ,UQ,KQ,YQ,HQ,eee,see,aee,uee,hee,Aee,bee,vee,wee,Iee,Cee,Nee,Ree,_ee,Pee,Lee,Vee,Gee,qee,Zee,ete,rte,dY,ote,iQ,ute,pte,mte,fY,xte,kte,Ste,_te,Ete,Pte,Lte,Ute,Jte,one,rne,cne,pne,fne,nne,gne,yne,wne,Cne,Rne,zne,xY,Bne,Une,jne,Kne,HJ,Jne,ese,nse,ase,use,gY,dse,pse,jJ,$ne,mse,kse,xse,vY,Tse,Rse,$se,Mse,Wse,Use,jse,Kse,Yse,ere,sre,are,lre,dre,fre,MJ,Pne,Are,xre,vre,kre,Sre,Tre,Ere,Dre,Fre,Pre,zre,Bre,Ure,Hre,qre,Kre,One,NY,Jre,tae,rae,lae,dae,EY,hae,mae,yae,Qne];for(let e of xae)pa(e);var qt;(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"})(qt||(qt={}));var Vd;(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"})(Vd||(Vd={}));var Yk;function bae(e){Yk=e.wasm.cwrap(jo,null,["number","array","number","number","array","number","number","number","number","number","number","number","number"])}function vae(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:c,activation:u,leakyreluAlpha:d}=s,p=n.dataIdMap.get(r.dataId).id,h=n.dataIdMap.get(a.dataId).id,f=0;if(o!=null){let _=n.dataIdMap.get(o.dataId);if(_.shape.length!==1)throw new Error(`_FusedMatMul only supports rank-1 bias but got rank ${_.shape.length}.`);f=_.id}let m=i==null?0:n.dataIdMap.get(i.dataId).id,g=Vd[u];if(g==null)throw new Error(`${u} activation not yet supported for FusedConv2D in the wasm backend.`);let A=l?r.shape[2]:r.shape[1],y=c?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,S=new Uint8Array(new Int32Array(r.shape).buffer),T=new Uint8Array(new Int32Array(a.shape).buffer);return Yk(p,S,r.shape.length,h,T,a.shape.length,l,c,g,f,m,d||0,v),b}var wae={kernelName:jo,backendName:"wasm",setupFunc:bae,kernelFunc:vae};function xn(e,t){let n;function s(a){n=a.wasm.cwrap(e,null,["number","number","number"])}function r(a){let{backend:o,inputs:{x:i}}=a,l=o.dataIdMap.get(i.dataId).id,c=o.makeOutput(i.shape,t||i.dtype),u=o.dataIdMap.get(c.dataId).id;return w.sizeFromShape(c.shape)===0||n(l,qt[i.dtype],u),c}return{kernelName:e,backendName:"wasm",setupFunc:s,kernelFunc:r}}var kae=xn(qi);function Mn(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:c,b:u}=l,d=i.dataIdMap.get(c.dataId).id,p=i.dataIdMap.get(u.dataId).id,h=n??c.dtype,f=N.assertAndGetBroadcastShape(c.shape,u.shape),m=i.makeOutput(f,h);if(w.sizeFromShape(f)===0)return m;let g=new Uint8Array(new Int32Array(c.shape).buffer),A=new Uint8Array(new Int32Array(u.shape).buffer),y=i.dataIdMap.get(m.dataId).id,x=()=>s(d,g,c.shape.length,p,A,u.shape.length,qt[c.dtype],y);if(t&&c.dtype==="float32")return x(),m;let b=N.getBroadcastDims(c.shape,f),v=N.getBroadcastDims(u.shape,f),S=b.every((_,O)=>_===O),T=v.every((_,O)=>_===O);if(S&&T)return x(),m;throw new Error(`Broadcasting along outer dims is not yet supported for ${c.dtype} ${e}.`)}return{kernelName:e,backendName:"wasm",setupFunc:r,kernelFunc:a}}var Iae=!0,Sae=Mn(la,Iae),Jk;function Cae(e){Jk=e.wasm.cwrap(Ka,null,["array","number","number","number"])}function Tae(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 Jk(a,r.length,qt[s.dtype],o),s}var Nae={kernelName:Ka,backendName:"wasm",setupFunc:Cae,kernelFunc:Tae};function N0(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 Eae={kernelName:mo,backendName:"wasm",kernelFunc:N0},Qk;function Rae(e){Qk=e.wasm.cwrap(Ho,null,["number","array","number","number","number","array","number"])}function Bu(e){let{inputs:t,backend:n,attrs:s}=e,[r,a]=_ae(t.x.shape,s.perm),o=!0;for(let f=0;f<a.length;f++)a[f]!==f&&(o=!1);let i=Dae(t.x.shape,s.perm),l={dataId:t.x.dataId,shape:r,dtype:t.x.dtype};if(o){let f=N0({inputs:t,backend:n});return f.shape=i,f}let c=n.makeOutput(i,l.dtype),u=n.dataIdMap.get(l.dataId).id,d=n.dataIdMap.get(c.dataId).id,p=new Uint8Array(new Int32Array(a).buffer),h=new Uint8Array(new Int32Array(l.shape).buffer);return Qk(u,h,l.shape.length,qt[l.dtype],d,p,a.length),c}function Dae(e,t){let n=new Array(e.length);for(let s=0;s<n.length;s++)n[s]=e[t[s]];return n}function _ae(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 Fae={kernelName:Ho,backendName:"wasm",kernelFunc:Bu,setupFunc:Rae};function $a(e,t,n){let s=e.shape,r=e.shape.length,a=w.parseAxisParam(t,s),o=a,i=N.getAxesPermutation(o,r),l=null,c=!1;if(i!=null){let u=new Array(r);for(let h=0;h<u.length;h++)u[h]=s[i[h]];o=N.getInnerMostAxes(o.length,r),l=Bu({inputs:{x:e},attrs:{perm:i},backend:n});let d=n.dataIdMap.get(e.dataId).id;n.dataIdMap.get(l.dataId).id!==d&&(c=!0)}return{transposed:l,originalAxes:a,axes:o,inputWasTransposed:c}}var e8;function $ae(e){e8=e.wasm.cwrap(Zi,null,["number, number, number"])}function Oae(e){let{backend:t,inputs:n,attrs:s}=e,{axis:r,keepDims:a}=s,{x:o}=n,l=t.dataIdMap.get(o.dataId).id,c=o,{transposed:u,axes:d,originalAxes:p,inputWasTransposed:h}=$a(o,r,t);if(h){let x=t.dataIdMap.get(u.dataId).id;c=u,l=x}let f=c.shape.length;N.assertAxesAreInnerMostDims("all",d,f);let[m,g]=N.computeOutAndReduceShapes(c.shape,d),A=w.sizeFromShape(g),y=t.makeOutput(m,o.dtype);if(w.sizeFromShape(c.shape)!==0){let x=t.dataIdMap.get(y.dataId).id;e8(l,A,x)}if(h&&t.disposeData(u.dataId),a){let x=N.expandShapeToKeepDim(y.shape,p);y.shape=x}return y}var Pae={kernelName:Zi,backendName:"wasm",setupFunc:$ae,kernelFunc:Oae},t8;function Mae(e){t8=e.wasm.cwrap(Yi,null,["number, number, number"])}function zae(e){let{backend:t,inputs:n,attrs:s}=e,{axis:r,keepDims:a}=s,{x:o}=n,l=t.dataIdMap.get(o.dataId).id,c=o,{transposed:u,axes:d,originalAxes:p,inputWasTransposed:h}=$a(o,r,t);if(h){let x=t.dataIdMap.get(u.dataId).id;c=u,l=x}let f=c.shape.length;N.assertAxesAreInnerMostDims("any",d,f);let[m,g]=N.computeOutAndReduceShapes(c.shape,d),A=w.sizeFromShape(g),y=t.makeOutput(m,o.dtype);if(w.sizeFromShape(c.shape)!==0){let x=t.dataIdMap.get(y.dataId).id;t8(l,A,x)}if(h&&t.disposeData(u.dataId),a){let x=N.expandShapeToKeepDim(y.shape,p);y.shape=x}return y}var Lae={kernelName:Yi,backendName:"wasm",setupFunc:Mae,kernelFunc:zae},n8;function Bae(e){n8=e.wasm.cwrap(Za,null,["number","number","number","number","number"])}function Wae(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:c,axes:u,inputWasTransposed:d}=$a(a,r,t);if(d){let A=t.dataIdMap.get(c.dataId).id;A!==o&&(l=c,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[u[0]];return n8(i,qt[l.dtype],m,g,f),d&&t.disposeData(c.dataId),h}var Vae={kernelName:Za,backendName:"wasm",kernelFunc:Wae,setupFunc:Bae},s8;function Uae(e){s8=e.wasm.cwrap(Ya,null,["number","number","number","number","number","number","number","number","number","number","number","number","number","number"])}function Gae(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:c}=n,u=N.computePool2DInfo(r.shape,o,i,1,l,c),d=u.filterHeight,p=u.filterWidth,h=u.padInfo.top,f=u.padInfo.right,m=u.padInfo.bottom,g=u.padInfo.left,A=u.strideHeight,y=u.strideWidth,x=u.inChannels;if(u.dataFormat!=="channelsLast")throw new Error(`wasm backend does not support dataFormat:'${u.dataFormat}'. Please use 'channelsLast'.`);if(u.dilationWidth!==1||u.dilationHeight!==1)throw new Error(`was backend only supports average pooling with dilation = [1, 1], got [${u.dilationHeight}, ${u.dilationWidth}].`);let b=s.makeOutput(u.outShape,"float32"),v=s.dataIdMap.get(b.dataId).id;return s8(a,r.shape[0],r.shape[1],r.shape[2],d,p,h,f,m,g,A,y,x,v),b}var Hae={kernelName:Ya,backendName:"wasm",setupFunc:Uae,kernelFunc:Gae};function Yn(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 jae={kernelName:_l,backendName:"wasm",kernelFunc:Yn},r8;function qae(e){r8=e.wasm.cwrap(Ja,null,["number","array","number","number","array","number","number","number","number"])}function Xae(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,c=a.shape.length,u=o?r.shape[l-2]:r.shape[l-1],d=i?a.shape[c-1]:a.shape[c-2],p=o?r.shape[l-1]:r.shape[l-2],h=i?a.shape[c-2]:a.shape[c-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&&c>=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(u===d,()=>`Error in matMul: inner shapes (${u}) and (${d}) of Tensors with shapes ${r.shape} and ${a.shape} and transposeA=${o} and transposeB=${i} must match.`);let v=o?[g,u,p]:[g,p,u],S=i?[A,h,d]:[A,d,h],T=Yn({inputs:{x:r},backend:n,attrs:{shape:v}}),_=Yn({inputs:{x:a},backend:n,attrs:{shape:S}}),O=n.dataIdMap.get(T.dataId).id,P=n.dataIdMap.get(_.dataId).id,D=o?T.shape[2]:T.shape[1],F=i?_.shape[1]:_.shape[2],C=Math.max(g,A),M=n.makeOutput([C,D,F],T.dtype),U=n.dataIdMap.get(M.dataId).id,j=new Uint8Array(new Int32Array(T.shape).buffer),q=new Uint8Array(new Int32Array(_.shape).buffer);return r8(O,j,T.shape.length,P,q,_.shape.length,o,i,U),n.disposeData(T.dataId),n.disposeData(_.dataId),M.shape=b,M}var Kae={kernelName:Ja,backendName:"wasm",setupFunc:qae,kernelFunc:Xae};function Ud(e){let{inputs:{x:t},attrs:{begin:n,size:s},backend:r}=e,[a,o]=En.parseSliceParams(t,n,s),i=En.isSliceContinous(t.shape,a,o),l=r.readSync(t.dataId),c=r.makeOutput(o,t.dtype),u=w.computeStrides(t.shape),d=r.dataIdMap.get(c.dataId);if(i){let f=En.computeFlatOffset(a,u);return t.dtype==="string"?d.stringBytes=l.slice(f,f+w.sizeFromShape(o)):r.typedArrayFromHeap(c).set(l.subarray(f,f+w.sizeFromShape(o))),c}if(t.dtype==="string"){let f=r0(l,a,o,t.shape,t.dtype);return d.stringBytes=f,c}let p=r.typedArrayFromHeap(c),h=t.shape.length;if(h===2)Zae(l,u[0],p,a,o);else if(h===3)Yae(l,u[0],u[1],p,a,o);else if(h===4)Jae(l,u[0],u[1],u[2],p,a,o);else{let f=r0(l,a,o,t.shape,t.dtype);p.set(f)}return c}function Zae(e,t,n,s,r){let a=0,o=s[0],i=s[1],l=o+r[0];for(let c=o;c<l;c++){let u=c*t+i;n.set(e.subarray(u,u+r[1]),a),a+=r[1]}}function Yae(e,t,n,s,r,a){let o=0,i=r[0],l=r[1],c=r[2],u=i+a[0],d=l+a[1];for(let p=i;p<u;p++)for(let h=l;h<d;h++){let f=p*t+h*n+c;s.set(e.subarray(f,f+a[2]),o),o+=a[2]}}function Jae(e,t,n,s,r,a,o){let i=0,l=a[0],c=a[1],u=a[2],d=l+o[0],p=c+o[1],h=u+o[2],f=a[3];for(let m=l;m<d;m++)for(let g=c;g<p;g++)for(let A=u;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 Qae={kernelName:Pl,backendName:"wasm",kernelFunc:Ud};function eoe(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=N.getReshaped(r.shape,a,i),c=N.getPermuted(l.length,a.length),u=N.getReshapedPermuted(r.shape,a,i),d=N.getSliceBeginCoords(o,a.length),p=N.getSliceSize(u,o,a.length),h=Yn({inputs:{x:r},backend:n,attrs:{shape:l}}),f=Bu({inputs:{x:h},backend:n,attrs:{perm:c}}),m=Yn({inputs:{x:f},backend:n,attrs:{shape:u}}),g=Ud({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 toe={kernelName:sl,backendName:"wasm",kernelFunc:eoe};function Gd(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 noe={kernelName:Qa,backendName:"wasm",kernelFunc:Gd},soe=xn(eo),a8;function roe(e){a8=e.wasm.cwrap(ua,null,["number","number","number","number"])}function aoe(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),c=n.dataIdMap.get(l.dataId).id;return a8(i,a,o,c),l}var ooe={kernelName:ua,backendName:"wasm",setupFunc:roe,kernelFunc:aoe};function o8(e){let{inputs:t,backend:n}=e,s=w.parseAxisParam(e.attrs.axis,t[0].shape)[0],r=N.computeOutShape(t.map(h=>h.shape),s),a=t.filter(h=>w.sizeFromShape(h.shape)>0);if(a.length===1)return N0({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(N.assertParamsConsistent(i,s),a[0].dtype==="string"){let h=a.map(x=>{let b=w.sizeFromShape(x.shape.slice(s));return Yn({inputs:{x},backend:n,attrs:{shape:[-1,b]}})}),f=h.map(x=>({vals:n.readSync(x.dataId),shape:x.shape}));r=N.computeOutShape(h.map(x=>x.shape),1);let m=h[0].shape[0]===1,g=g2(f,r,t[0].dtype,m),A=N.computeOutShape(a.map(x=>x.shape),s);o.shape=A;let y=n.dataIdMap.get(o.dataId);return y.stringBytes=N.fromStringArrayToUint8(g),h.forEach(x=>n.disposeData(x.dataId)),o}let l=w.sizeFromShape(a[0].shape.slice(0,s)),c=0,u=a.map(h=>{let f=w.sizeFromShape(h.shape.slice(s));return c+=f,f}),d=a.map(h=>n.typedArrayFromHeap(h)),p=n.typedArrayFromHeap(o);for(let h=0;h<l;h++){let f=h*c;for(let m=0;m<d.length;m++){let g=u[m],A=h*g,y=d[m].subarray(A,A+g);p.set(y,f),f+=g}}return o}var ioe={kernelName:rl,backendName:"wasm",kernelFunc:o8},i8;function loe(e){i8=e.wasm.cwrap(to,null,["number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number"])}function uoe(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:c,pad:u,dimRoundingMode:d,dataFormat:p}=n,h=N.convertConv2DDataFormat(p),f=N.computeConv2DInfo(r.shape,a.shape,l,c,u,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,S=f.dilationWidth,T=f.strideHeight,_=f.strideWidth,O=f.inChannels,P=f.outChannels,D=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 F=s.makeOutput(f.outShape,"float32"),C=s.dataIdMap.get(F.dataId).id;return i8(o,r.shape[0],r.shape[1],r.shape[2],i,m,g,A,y,x,b,D,v,S,T,_,O,P,C),F}var coe={kernelName:to,backendName:"wasm",setupFunc:loe,kernelFunc:uoe},l8;function doe(e){l8=e.wasm.cwrap(no,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 poe(e){let{backend:t,inputs:n,attrs:s}=e,{dy:r,filter:a}=n,{strides:o,pad:i,dataFormat:l,dimRoundingMode:c,inputShape:u}=s,d=1,p=N.convertConv2DDataFormat(l),h=N.computeConv2DInfo(u,a.shape,o,d,i,c,!1,p),{batchSize:f,filterHeight:m,filterWidth:g,inChannels:A,inHeight:y,inWidth:x,outChannels:b,outHeight:v,outWidth:S,strideHeight:T,strideWidth:_}=h,O=m-1-h.padInfo.top,P=g-1-h.padInfo.left,D=h.dataFormat==="channelsLast",F=w.computeStrides(h.inShape),C=w.computeStrides(r.shape),[M,U,j]=w.computeStrides(a.shape),q=F[0],X=D?F[1]:F[2],te=D?F[2]:1,ne=D?1:F[1],se=C[0],oe=D?C[1]:C[2],ae=D?C[2]:1,re=D?1:C[1],ce=t.makeOutput(h.inShape,"float32"),ge=t.dataIdMap.get(ce.dataId).id,ve=t.dataIdMap.get(r.dataId).id,Ce=t.dataIdMap.get(a.dataId).id;return l8(ve,Ce,f,m,g,y,x,A,v,S,b,T,_,O,P,M,U,j,q,X,te,ne,se,oe,ae,re,ge),ce}var hoe={kernelName:no,backendName:"wasm",setupFunc:doe,kernelFunc:poe},foe=xn(so),moe=xn(ro),X2;(function(e){e[e.bilinear=0]="bilinear",e[e.nearest=1]="nearest"})(X2||(X2={}));var u8;function goe(e){u8=e.wasm.cwrap(al,null,["number","number","number","number","array","number","number","number","number","number"])}function Aoe(e){let{backend:t,inputs:n,attrs:s}=e,{method:r,extrapolationValue:a,cropSize:o}=s,{image:i,boxes:l,boxInd:c}=n,u=l.shape[0],[d,p]=o,h=[u,d,p,i.shape[3]],f=t.dataIdMap.get(i.dataId),m;i.dtype!=="float32"&&(m=Gd({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(c.dataId).id,x=t.makeOutput(h,"float32"),b=t.dataIdMap.get(x.dataId).id,v=new Uint8Array(new Int32Array(i.shape).buffer);return u8(g,A,y,u,v,d,p,X2[r],a,b),m!=null&&t.disposeData(m.dataId),x}var yoe={kernelName:al,backendName:"wasm",setupFunc:goe,kernelFunc:Aoe},c8;function xoe(e){c8=e.wasm.cwrap(ao,null,["number","number","number","number","number","number"])}function boe(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 c=N.getAxesPermutation([a],l),u=r;c!==null&&(u=Bu({inputs:{x:r},attrs:{perm:c},backend:n}));let d=N.getInnerMostAxes(1,l)[0];N.assertAxesAreInnerMostDims("cumsum",[d],l);let p=n.makeOutput(u.shape,u.dtype),h=u.shape[d],f=n.dataIdMap.get(u.dataId).id,m=n.dataIdMap.get(p.dataId).id;c8(f,o?1:0,i?1:0,h,m,qt[r.dtype]);let g=p;if(c!==null){let A=N.getUndoAxesPermutation(c);g=Bu({inputs:{x:p},attrs:{perm:A},backend:n}),n.disposeData(u.dataId),n.disposeData(p.dataId)}return g}var voe={kernelName:ao,backendName:"wasm",setupFunc:xoe,kernelFunc:boe},d8;function woe(e){d8=e.wasm.cwrap(ol,null,["number","number","number","array","number","array","array","number","number"])}function koe(e){let{backend:t,inputs:n,attrs:s}=e,{x:r}=n,{blockSize:a,dataFormat:o}=s,i=r.shape[0],l=o==="NHWC"?r.shape[1]:r.shape[2],c=o==="NHWC"?r.shape[2]:r.shape[3],u=o==="NHWC"?r.shape[3]:r.shape[1],d=l*a,p=c*a,h=u/(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 d8(A,a,o==="NHWC"?1:0,y,r.shape.length-1,x,b,f.length,v),m}var Ioe={kernelName:ol,backendName:"wasm",setupFunc:woe,kernelFunc:koe},p8;function Soe(e){p8=e.wasm.cwrap(oo,null,["number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number"])}function Coe(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:c,pad:u,dimRoundingMode:d}=n,p=c??[1,1],h=N.computeConv2DInfo(r.shape,a.shape,l,p,u,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,S=h.strideHeight,T=h.strideWidth,_=h.inChannels,O=h.outChannels,P=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 D=s.makeOutput(h.outShape,"float32"),F=s.dataIdMap.get(D.dataId).id;return p8(o,r.shape[0],r.shape[1],r.shape[2],i,f,m,g,A,y,x,P,b,v,S,T,_,O,F),D}var Toe={kernelName:oo,backendName:"wasm",setupFunc:Soe,kernelFunc:Coe},Noe=xn(lo),Eoe=!1,Roe=Mn(ll,Eoe,"bool"),Doe=xn(uo,"float32");function K2(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),Yn({inputs:{x:r},backend:s,attrs:{shape:i}})}var _oe={kernelName:ul,backendName:"wasm",kernelFunc:K2};function h8(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 Foe={kernelName:vc,backendName:"wasm",kernelFunc:h8},f8;function $oe(e){f8=e.wasm.cwrap(dl,null,["number","number","number","number","number","number"])}function Ooe(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,c,u]=s.shape;return f8(a,i,l,c,u,o),r}var Poe={kernelName:dl,backendName:"wasm",kernelFunc:Ooe,setupFunc:$oe},Moe=xn(co),zoe=!1,Loe=Mn(po,zoe),m8;function Boe(e){m8=e.wasm.cwrap(ho,null,["number","number","number","number","number","number","number"])}function Woe(e){let{backend:t,inputs:n,attrs:s}=e,{varianceEpsilon:r}=s,{x:a,mean:o,variance:i,offset:l,scale:c}=n,u=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=c!=null?t.dataIdMap.get(c.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 m8(u,d,p,h,f,r,g),m}var Voe={kernelName:ho,backendName:"wasm",setupFunc:Boe,kernelFunc:Woe},g8;function Uoe(e){g8=e.wasm.cwrap(qo,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 Goe(e){let{inputs:t,attrs:n,backend:s}=e,{x:r,filter:a,bias:o,preluActivationWeights:i}=t,{strides:l,pad:c,dilations:u,dataFormat:d,dimRoundingMode:p,activation:h,leakyreluAlpha:f}=n,m=N.computeConv2DInfo(r.shape,a.shape,l,u,c,p),g=Vd[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 ae=s.dataIdMap.get(o.dataId);if(ae.shape.length!==1)throw new Error(`FusedConv2D only supports rank-1 bias but got rank ${ae.shape.length}.`);if(ae.shape[0]!==x)throw new Error(`FusedConv2D bias shape (${ae.shape}) does not match the number of output channels (${x})`);b=ae.id}let v=m.filterHeight,S=m.filterWidth,T=m.padInfo.top,_=m.padInfo.right,O=m.padInfo.bottom,P=m.padInfo.left,D=m.dilationHeight,F=m.dilationWidth,C=m.strideHeight,M=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,oe=i==null?0:s.dataIdMap.get(i.dataId).id;return g8(A,q,X,te,y,v,S,b,T,_,O,P,j,D,F,C,M,U,x,g,oe,f||0,se),ne}var Hoe={kernelName:qo,backendName:"wasm",setupFunc:Uoe,kernelFunc:Goe},A8;function joe(e){A8=e.wasm.cwrap(Xo,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 qoe(e){let{inputs:t,attrs:n,backend:s}=e,{x:r,filter:a,bias:o,preluActivationWeights:i}=t,{strides:l,pad:c,dilations:u,dataFormat:d,dimRoundingMode:p,activation:h,leakyreluAlpha:f}=n,m=N.computeConv2DInfo(r.shape,a.shape,l,u,c,p,!0),g=Vd[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 ae=s.dataIdMap.get(o.dataId);if(ae.shape.length!==1)throw new Error(`FusedDepthwiseConv2D only supports rank-1 bias but got rank ${ae.shape.length}.`);if(ae.shape[0]!==x)throw new Error(`FusedDepthwiseConv2D bias shape (${ae.shape}) does not match the number of output channels (${x})`);b=ae.id}let v=m.filterHeight,S=m.filterWidth,T=m.padInfo.top,_=m.padInfo.right,O=m.padInfo.bottom,P=m.padInfo.left,D=m.dilationHeight,F=m.dilationWidth,C=m.strideHeight,M=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,oe=i==null?0:s.dataIdMap.get(i.dataId).id;return A8(A,q,X,te,y,v,S,b,T,_,O,P,j,D,F,C,M,U,x,g,oe,f||0,se),ne}var Xoe={kernelName:Xo,backendName:"wasm",setupFunc:joe,kernelFunc:qoe},y8;function Koe(e){y8=e.wasm.cwrap(hl,null,["number","number","number","number","number","number","array","number"])}function Zoe(e){let{backend:t,inputs:n}=e,{params:s,indices:r}=n,[a,o,i,l]=iA.prepareAndValidate(s,r),c=t.makeOutput(a,s.dtype);if(o===0)return c;let u=r.shape,d=u[u.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(c.dataId).id;return y8(h,qt[s.dtype],m,o,d,i,g,A),c}var Yoe={kernelName:hl,backendName:"wasm",setupFunc:Koe,kernelFunc:Zoe},x8;function Joe(e){x8=e.wasm.cwrap("Gather",null,["number","number","array","number","number","number","array","number"])}function Qoe(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],c=t.readSync(a.dataId),u=r.shape[l];for(let O=0;O<c.length;++O){let P=c[O];w.assert(P<=u-1&&P>=0,()=>`GatherV2: the index value ${P} is not in [0, ${u-1}]`)}let d=N.segment_util.collectGatherOpShapeInfo(r,a,l,i),p=Yn({inputs:{x:r},attrs:{shape:[d.batchSize,d.outerSize,d.dimSize,d.sliceSize]},backend:t}),h=w.sizeFromShape(a.shape),f=Yn({inputs:{x:a},attrs:{shape:[d.batchSize,h/d.batchSize]},backend:t}),m=[d.batchSize,d.outerSize,h/d.batchSize,d.sliceSize],g=t.makeOutput(m,r.dtype);if(w.sizeFromShape(r.shape)===0)return g;let A=p.shape.length-1,x=t.dataIdMap.get(p.dataId).id,v=t.dataIdMap.get(f.dataId).id,S=t.dataIdMap.get(g.dataId).id,T=new Uint8Array(new Int32Array(w.computeStrides(p.shape)).buffer),_=new Uint8Array(new Int32Array(w.computeStrides(m)).buffer);return x8(x,qt[r.dtype],T,A,v,d.batchSize,_,S),t.disposeData(p.dataId),t.disposeData(f.dataId),g.shape=d.outputShape,g}var eie={kernelName:pl,backendName:"wasm",setupFunc:Joe,kernelFunc:Qoe},tie=!1,nie=Mn(fl,tie,"bool"),sie=!1,rie=Mn(fo,sie,"bool"),b8;function aie(e){b8=e.wasm.cwrap(go,null,["number","number","number","number"])}function oie(e){let{inputs:{x:t},attrs:{alpha:n},backend:s}=e,r=s.dataIdMap.get(t.dataId).id,a=s.makeOutput(t.shape,"float32");if(w.sizeFromShape(t.shape)!==0){let o=s.dataIdMap.get(a.dataId).id;b8(r,qt[t.dtype],n,o)}return a}var iie={kernelName:go,backendName:"wasm",setupFunc:aie,kernelFunc:oie},lie=!1,uie=Mn(yl,lie,"bool"),cie=!1,die=Mn(xl,cie,"bool"),pie=xn(Ao),hie=!1,fie=Mn(vl,hie,"bool"),v8;function mie(e){v8=e.wasm.cwrap(yo,null,["number","number","number","number"])}function gie(e){let{backend:t,inputs:n,attrs:s}=e,{reductionIndices:r,keepDims:a}=s,{x:o}=n,l=t.dataIdMap.get(o.dataId).id,c=o,{transposed:u,axes:d,originalAxes:p,inputWasTransposed:h}=$a(o,r,t);if(h){let x=t.dataIdMap.get(u.dataId).id;c=u,l=x}let f=c.shape.length;N.assertAxesAreInnerMostDims("max",d,f);let[m,g]=N.computeOutAndReduceShapes(c.shape,d),A=w.sizeFromShape(g),y=t.makeOutput(m,o.dtype);if(w.sizeFromShape(c.shape)!==0){let x=t.dataIdMap.get(y.dataId).id;v8(l,qt[o.dtype],A,x)}if(h&&t.disposeData(u.dataId),a){let x=N.expandShapeToKeepDim(y.shape,p);y.shape=x}return y}var Aie={kernelName:yo,backendName:"wasm",setupFunc:mie,kernelFunc:gie},yie=!1,xie=Mn(xo,yie),w8;function bie(e){w8=e.wasm.cwrap(bo,null,["number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number"])}function vie(e){let{inputs:t,attrs:n,backend:s}=e,r=t.x,a=s.dataIdMap.get(r.dataId).id;w.assert(r.dtype==="float32",()=>`Error in MaxPool: only float32 input is supported. Got ${r.dtype}.`);let{filterSize:o,strides:i,pad:l,dimRoundingMode:c}=n,u=N.computePool2DInfo(r.shape,o,i,1,l,c),d=u.filterHeight,p=u.filterWidth,h=u.padInfo.top,f=u.padInfo.right,m=u.padInfo.bottom,g=u.padInfo.left,A=u.dilationHeight,y=u.dilationWidth,x=u.strideHeight,b=u.strideWidth,v=u.inChannels,S=u.outChannels;if(u.dataFormat!=="channelsLast")throw new Error(`wasm backend does not support dataFormat:'${u.dataFormat}'. Please use 'channelsLast'.`);let T=s.makeOutput(u.outShape,"float32"),_=s.dataIdMap.get(T.dataId).id;return w8(a,r.shape[0],r.shape[1],r.shape[2],d,p,h,f,m,g,A,y,x,b,v,S,_),T}var wie={kernelName:bo,backendName:"wasm",setupFunc:bie,kernelFunc:vie},k8;function kie(e){k8=e.wasm.cwrap(vo,null,["number, number, number"])}function Iie(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,c=o,{transposed:u,axes:d,originalAxes:p,inputWasTransposed:h}=$a(o,r,t),f=d;if(h){let b=t.dataIdMap.get(u.dataId).id;b!==i&&(c=u,l=b,f=N.getInnerMostAxes(f.length,c.shape.length))}N.assertAxesAreInnerMostDims("mean",f,c.shape.length);let[m,g]=N.computeOutAndReduceShapes(c.shape,f),A=w.sizeFromShape(g),y=c;c.dtype!=="float32"&&(y=Gd({backend:t,inputs:{x:c},attrs:{dtype:"float32"}}),l=t.dataIdMap.get(y.dataId).id);let x=t.makeOutput(m,"float32");if(w.sizeFromShape(c.shape)!==0){let b=t.dataIdMap.get(x.dataId).id;k8(l,A,b)}if(h&&t.disposeData(u.dataId),a){let b=N.expandShapeToKeepDim(x.shape,p);x.shape=b}return c.dtype!=="float32"&&t.disposeData(y.dataId),x}var Sie={kernelName:vo,backendName:"wasm",setupFunc:kie,kernelFunc:Iie},I8;function Cie(e){I8=e.wasm.cwrap(wo,null,["number","number","number","number"])}function Tie(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,c=o,{transposed:u,axes:d,originalAxes:p,inputWasTransposed:h}=$a(o,r,t);if(h){let x=t.dataIdMap.get(u.dataId).id;x!==i&&(c=u,l=x)}let f=c.shape.length;N.assertAxesAreInnerMostDims("min",d,f);let[m,g]=N.computeOutAndReduceShapes(c.shape,d),A=w.sizeFromShape(g),y=t.makeOutput(m,c.dtype);if(w.sizeFromShape(c.shape)!==0){let x=t.dataIdMap.get(y.dataId).id;I8(l,qt[o.dtype],A,x)}if(h&&t.disposeData(u.dataId),a){let x=N.expandShapeToKeepDim(y.shape,p);y.shape=x}return y}var Nie={kernelName:wo,backendName:"wasm",setupFunc:Cie,kernelFunc:Tie},Eie=!1,Rie=Mn(ko,Eie),Z2;(function(e){e[e.reflect=0]="reflect",e[e.symmetric=1]="symmetric"})(Z2||(Z2={}));var S8;function Die(e){S8=e.wasm.cwrap(Io,null,["number","array","number","number","array","array","number","number"])}function _ie(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,c=new Uint8Array(new Int32Array(t.shape).buffer),u=s.map(f=>f[0]),d=s.map(f=>f[1]),p=new Uint8Array(new Int32Array(u).buffer),h=new Uint8Array(new Int32Array(d).buffer);return S8(o,c,t.shape.length,qt[t.dtype],p,h,Z2[r],l),i}var Fie={kernelName:Io,backendName:"wasm",kernelFunc:_ie,setupFunc:Die},$ie=!0,Oie=Mn(So,$ie),Pie=xn(kl);function Y2(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 C8;function Mie(e){C8=e.wasm.cwrap(Sl,"number",["number","number","number","number","number"])}function zie(e){let{backend:t,inputs:n,attrs:s}=e,{iouThreshold:r,maxOutputSize:a,scoreThreshold:o}=s,{boxes:i,scores:l}=n,c=t.dataIdMap.get(i.dataId).id,u=t.dataIdMap.get(l.dataId).id,d=C8(c,u,a,r,o),{pSelectedIndices:p,selectedSize:h,pSelectedScores:f,pValidOutputs:m}=Y2(t,d);return t.wasm._free(f),t.wasm._free(m),t.makeOutput([h],"int32",p)}var Lie={kernelName:Sl,backendName:"wasm",setupFunc:Mie,kernelFunc:zie},T8;function Bie(e){T8=e.wasm.cwrap(Cl,"number",["number","number","number","number","number","bool"])}function Wie(e){let{backend:t,inputs:n,attrs:s}=e,{iouThreshold:r,maxOutputSize:a,scoreThreshold:o,padToMaxOutputSize:i}=s,{boxes:l,scores:c}=n,u=t.dataIdMap.get(l.dataId).id,d=t.dataIdMap.get(c.dataId).id,p=T8(u,d,a,r,o,i),{pSelectedIndices:h,selectedSize:f,pSelectedScores:m,pValidOutputs:g}=Y2(t,p);t.wasm._free(m);let A=t.makeOutput([f],"int32",h),y=t.makeOutput([],"int32",g);return[A,y]}var Vie={kernelName:Cl,backendName:"wasm",setupFunc:Bie,kernelFunc:Wie},N8;function Uie(e){N8=e.wasm.cwrap(Tl,"number",["number","number","number","number","number","number"])}function Gie(e){let{backend:t,inputs:n,attrs:s}=e,{iouThreshold:r,maxOutputSize:a,scoreThreshold:o,softNmsSigma:i}=s,{boxes:l,scores:c}=n,u=t.dataIdMap.get(l.dataId).id,d=t.dataIdMap.get(c.dataId).id,p=N8(u,d,a,r,o,i),{pSelectedIndices:h,selectedSize:f,pSelectedScores:m,pValidOutputs:g}=Y2(t,p);t.wasm._free(g);let A=t.makeOutput([f],"int32",h),y=t.makeOutput([f],"float32",m);return[A,y]}var Hie={kernelName:Tl,backendName:"wasm",setupFunc:Uie,kernelFunc:Gie},jie=!1,qie=Mn(Il,jie,"bool"),E8;function Xie(e){E8=e.wasm.cwrap(Co,null,["number","number","number","number","number"])}function Kie(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"),c=n.dataIdMap.get(l.dataId).id,d=n.dataIdMap.get(r.dataId).id;return E8(d,a,o,i,c),l}var Zie={kernelName:Co,backendName:"wasm",setupFunc:Xie,kernelFunc:Kie};function Yie(e){let{inputs:{x:t},backend:n}=e,s=n.makeOutput(t.shape,t.dtype);return n.typedArrayFromHeap(s).fill(1),s}var Jie={kernelName:Nl,backendName:"wasm",kernelFunc:Yie};function Qie(e){let{inputs:t,backend:n,attrs:s}=e,{axis:r}=s;if(t.length===1)return K2({inputs:{input:t[0]},backend:n,attrs:{dim:r}});let a=t[0].shape,o=t[0].dtype;t.forEach(u=>{w.assertShapesMatch(a,u.shape,"All tensors passed to stack must have matching shapes"),w.assert(o===u.dtype,()=>"All tensors passed to stack must have matching dtypes")});let i=[],l=t.map(u=>{let d=K2({inputs:{input:u},backend:n,attrs:{dim:r}});return i.push(d),d}),c=o8({inputs:l,backend:n,attrs:{axis:r}});return i.forEach(u=>n.disposeData(u.dataId)),c}var ele={kernelName:El,backendName:"wasm",kernelFunc:Qie},R8;function tle(e){R8=e.wasm.cwrap(To,null,["number","array","number","number","array","array","number","number"])}function nle(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 h8({backend:n,attrs:{shape:a,value:r,dtype:t.dtype}});let o=n.dataIdMap.get(t.dataId).id,i=n.makeOutput(a,t.dtype),c=n.dataIdMap.get(i.dataId).id,u=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 R8(o,u,t.shape.length,qt[t.dtype],h,f,r,c),i}var D8={kernelName:To,backendName:"wasm",kernelFunc:nle,setupFunc:tle},sle=!1,rle=Mn(No,sle),_8;function ale(e){_8=e.wasm.cwrap(Eo,null,["number","number","number"])}function ole(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=a,l=s,c=l;l.dtype!=="float32"&&(c=Gd({backend:n,inputs:{x:s},attrs:{dtype:"float32"}}),i=n.dataIdMap.get(c.dataId).id);let u=n.makeOutput(s.shape,"float32"),d=n.dataIdMap.get(u.dataId).id;return _8(i,o,d),l.dtype!=="float32"&&n.disposeData(c.dataId),u}var ile={kernelName:Eo,backendName:"wasm",setupFunc:ale,kernelFunc:ole},F8;function lle(e){F8=e.wasm.cwrap(Rl,null,["number","number","number","number"])}function ule(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,c=o,{transposed:u,axes:d,originalAxes:p,inputWasTransposed:h}=$a(o,r,t),f=d;if(h){let x=t.dataIdMap.get(u.dataId).id;x!==i&&(c=u,l=x,f=N.getInnerMostAxes(f.length,c.shape.length))}N.assertAxesAreInnerMostDims("prod",f,c.shape.length);let[m,g]=N.computeOutAndReduceShapes(c.shape,f),A=w.sizeFromShape(g),y=t.makeOutput(m,c.dtype);if(w.sizeFromShape(c.shape)!==0){let x=t.dataIdMap.get(y.dataId).id;F8(l,A,qt[y.dtype],x)}if(h&&t.disposeData(u.dataId),a){let x=N.expandShapeToKeepDim(y.shape,p);y.shape=x}return y}var cle={kernelName:Rl,backendName:"wasm",setupFunc:lle,kernelFunc:ule},dle=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},ple={kernelName:Cc,backendName:"wasm",kernelFunc:dle},hle=!0,fle=Mn(io,hle),mle=xn(Ro),gle=xn(_o),$8;function Ale(e){$8=e.wasm.cwrap(Do,null,["number","number","number","number","number","number","number","number","number","number"])}function yle(e){let{backend:t,inputs:n,attrs:s}=e,{images:r}=n,{alignCorners:a,halfPixelCenters:o,size:i}=s,[l,c]=i,[u,d,p,h]=r.shape,f=[u,l,c,h],m=t.dataIdMap.get(r.dataId),g;m.dtype!=="float32"&&(g=Gd({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 $8(A,u,d,p,h,l,c,a?1:0,o?1:0,x),g!=null&&t.disposeData(g.dataId),y}var xle={kernelName:Do,backendName:"wasm",setupFunc:Ale,kernelFunc:yle},O8;function ble(e){O8=e.wasm.cwrap(Fo,null,["number","array","number","array","number","number"])}function vle(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 N0({inputs:{x:r},backend:n});let i=n.makeOutput(r.shape,r.dtype),l=n.dataIdMap.get(r.dataId).id,c=n.dataIdMap.get(i.dataId).id,u=new Uint8Array(new Int32Array(o).buffer),d=new Uint8Array(new Int32Array(r.shape).buffer);O8(l,u,o.length,d,r.shape.length,c);let p=Yn({inputs:{x:i},attrs:{shape:r.shape},backend:n});return n.disposeData(i.dataId),p}var wle={kernelName:Fo,backendName:"wasm",kernelFunc:vle,setupFunc:ble},P8;function kle(e){P8=e.wasm.cwrap(ql,null,["number","number","number","number","number","number","number","number","array","number","number"])}function Ile(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),c=n.dataIdMap.get(r.dataId).id,u=n.dataIdMap.get(l.dataId).id,[d,p,h,f]=r.shape,[m,g]=N.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 P8(c,d,p,h,f,a,m,g,b,x.length,u),l}var Sle={kernelName:ql,backendName:"wasm",kernelFunc:Ile,setupFunc:kle},Cle=xn($o),Tle=xn(Oo),M8;function Nle(e){M8=e.wasm.cwrap(Fl,null,["number","number","number","number","number","number","array","number","number"])}function Ele(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:c,sliceSize:u,strides:d,outputSize:p}=lA.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 M8(f,g,qt[a.dtype],l,c,u,A,p,y),i}var Rle={kernelName:Fl,backendName:"wasm",setupFunc:Nle,kernelFunc:Ele},z8;function Dle(e){z8=e.wasm.cwrap("SelectV2",null,["number","number","number","number","number"])}function _le(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,c=n.makeOutput(r.shape,r.dtype),u=n.dataIdMap.get(c.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 z8(o,i,l,h,u),c}var Fle={kernelName:$l,backendName:"wasm",kernelFunc:_le,setupFunc:Dle},L8;function $le(e){L8=e.wasm.cwrap(Mo,null,["number","number"])}function Ole(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||L8(s,a),r}var Ple={kernelName:"Sigmoid",backendName:"wasm",setupFunc:$le,kernelFunc:Ole},Mle=xn(Po),B8;function zle(e){B8=e.wasm.cwrap(Bo,null,["number","number","number","number"])}function Lle(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||B8(r,o,i,l),a}var Ble={kernelName:Bo,backendName:"wasm",setupFunc:zle,kernelFunc:Lle};function Wle(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 S=1+a.length;S<r.shape.length;++S)l.push([0,0]);let c=D8.kernelFunc({inputs:{x:r},backend:n,attrs:{paddings:l,constantValue:0}}),u=N.getReshaped(c.shape,a,i,!1),d=N.getPermuted(u.length,a.length,!1),p=N.getReshapedPermuted(c.shape,a,i,!1),m=Yn({inputs:{x:c},backend:n,attrs:{shape:u}}),y=Bu({inputs:{x:m},backend:n,attrs:{perm:d}}),v=Yn({inputs:{x:y},backend:n,attrs:{shape:p}});return n.disposeData(c.dataId),n.disposeData(m.dataId),n.disposeData(y.dataId),v}var Vle={kernelName:Bl,backendName:"wasm",kernelFunc:Wle};function Ule(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=N.prepareSplitSize(r,a,i),c=new Array(r.shape.length).fill(0),u=r.shape.slice();return l.map(d=>{let p=[...u];p[i]=d;let h=Ud({inputs:{x:r},attrs:{begin:c,size:p},backend:s});return c[i]+=d,h})}var Gle={kernelName:Wl,backendName:"wasm",kernelFunc:Ule},Hle=xn(zo),jle=xn(Nc),qle=!0,Xle=Mn(Wo,qle),W8;function Kle(e){W8=e.wasm.cwrap(da,null,["number","number","number","number"])}function Zle(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 W8(o,r,qt[a.dtype],l),i}var Yle={kernelName:da,backendName:"wasm",setupFunc:Kle,kernelFunc:Zle},V8;function Jle(e){V8=e.wasm.cwrap(Vl,null,["number","array","number","array","array","array","array","array","number","number"])}function Qle(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:c,ellipsisMask:u,newAxisMask:d,shrinkAxisMask:p}=s,h=N.slice_util.maskToAxes(u);if(h.length>1)throw new Error("Multiple ellipses in slice is not allowed.");if(u!==0&&d!==0)throw new Error("Using both ellipsisMask and newAxisMask is not yet supported.");if(u!==0&&p!==0)throw new Error("Using both ellipsisMask and shrinkAxisMask is not yet supported.");let f=r.shape.length-a.length,m=N.slice_util.maskToAxes(d),g=r.shape.slice();m.forEach(D=>{a[D]=0,o[D]=1,g.splice(D,0,1)});let A=Yn({inputs:{x:r},attrs:{shape:g},backend:t}),{begin:y,end:x,strides:b}=N.slice_util.getNormalizedAxes(A.shape,h,f,a,o,i,l,c,u);a=y,o=x,i=b;let v=N.slice_util.maskToAxes(p);v.forEach(D=>{o[D]=a[D]+1,i[D]=1});let S=N.slice_util.computeOutShape(a,o,i),T=S.filter((D,F)=>v.indexOf(F)===-1);if(i.every(D=>D===1)){let D=Ud({inputs:{x:A},attrs:{begin:a,size:S},backend:t});t.disposeData(A.dataId);let F=Yn({inputs:{x:D},attrs:{shape:T},backend:t});return t.disposeData(D.dataId),F}let O=t.makeOutput(T,"float32");if(!T.some(D=>D===0)){let D=t.dataIdMap.get(A.dataId).id,F=new Uint8Array(new Int32Array(w.computeStrides(A.shape)).buffer),C=new Uint8Array(new Int32Array(a).buffer),M=new Uint8Array(new Int32Array(o).buffer),U=new Uint8Array(new Int32Array(i).buffer),j=new Uint8Array(new Int32Array(T).buffer),q=new Uint8Array(new Int32Array(w.computeStrides(T)).buffer),X=t.dataIdMap.get(O.dataId).id;V8(D,F,A.shape.length,C,M,U,j,q,T.length,X)}t.disposeData(A.dataId);let P=Yn({inputs:{x:O},attrs:{shape:T},backend:t});return t.disposeData(O.dataId),P}var eue={kernelName:Vl,backendName:"wasm",setupFunc:Jle,kernelFunc:Qle},tue=!0,nue=Mn(Vo,tue),U8;function sue(e){U8=e.wasm.cwrap(Lo,null,["number","number","number","number"])}function rue(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,c=o,{transposed:u,axes:d,originalAxes:p,inputWasTransposed:h}=$a(o,r,t),f=d;if(h){let x=t.dataIdMap.get(u.dataId).id;x!==i&&(c=u,l=x,f=N.getInnerMostAxes(f.length,c.shape.length))}N.assertAxesAreInnerMostDims("sum",f,c.shape.length);let[m,g]=N.computeOutAndReduceShapes(c.shape,f),A=w.sizeFromShape(g),y=t.makeOutput(m,c.dtype);if(w.sizeFromShape(c.shape)!==0){let x=t.dataIdMap.get(y.dataId).id;U8(l,A,qt[y.dtype],x)}if(h&&t.disposeData(u.dataId),a){let x=N.expandShapeToKeepDim(y.shape,p);y.shape=x}return y}var aue={kernelName:Lo,backendName:"wasm",setupFunc:sue,kernelFunc:rue},oue=xn(Uo),iue=xn(Go),G8;function lue(e){G8=e.wasm.cwrap(ca,null,["number","array","number","array","number","number"])}function uue(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),c=new Uint8Array(new Int32Array(i).buffer),u=n.makeOutput(i,r.dtype),d=n.dataIdMap.get(u.dataId).id;return G8(a,l,r.shape.length,c,i.length,qt[u.dtype],d),u}var cue={kernelName:ca,backendName:"wasm",setupFunc:lue,kernelFunc:uue},H8;function due(e){H8=e.wasm.cwrap(Ul,null,["number","array","number","number","number","bool","number","number"])}var pue=({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 c=t.makeOutput(l,s.dtype),u=t.dataIdMap.get(c.dataId).id,d=t.makeOutput(l,"int32"),p=t.dataIdMap.get(d.dataId).id;return H8(o,i,s.shape.length,qt[s.dtype],r,a,u,p),[c,d]},hue={kernelName:Ul,backendName:"wasm",setupFunc:due,kernelFunc:pue},j8;function fue(e){j8=e.wasm.cwrap(Gl,null,["number","number","bool","number","number","number","number","number","number","array","number","number","number","number","number"])}function mue(e){let{backend:t,inputs:n,attrs:s}=e,{image:r,transforms:a}=n,{interpolation:o,fillMode:i,fillValue:l,outputShape:c}=s,[u,d,p,h]=r.shape,[f,m]=c??[d,p],g=[u,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,T=t.dataIdMap.get(a.dataId).id,_=o==="nearest"?1:2,O;switch(i){case"constant":O=1;break;case"reflect":O=2;break;case"wrap":O=3;break;case"nearest":O=4;break;default:O=1;break}return j8(v,T,a.shape[0]>1,u,f,m,h,p,d,A,r.shape.length-1,_,O,l,x),y}var gue={kernelName:Gl,backendName:"wasm",setupFunc:fue,kernelFunc:mue};function Aue(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),c=0;for(let h=0;h<i;h++)h!==a&&(l[c++]=r.shape[h]);let u=new Array(o),d=new Array(i).fill(0),p=r.shape.slice();p[a]=1;for(let h=0;h<u.length;h++)d[a]=h,u[h]=Ud({inputs:{x:r},attrs:{begin:d,size:p},backend:n});return u.map(({dataId:h,dtype:f})=>({dataId:h,dtype:f,shape:l}))}var yue={kernelName:Hl,backendName:"wasm",kernelFunc:Aue};function xue(e){let{inputs:{x:t},backend:n}=e,s=n.makeOutput(t.shape,t.dtype);return n.typedArrayFromHeap(s).fill(0),s}var bue={kernelName:jl,backendName:"wasm",kernelFunc:xue},vue=[kae,Sae,Nae,Pae,Lae,Vae,Hae,Kae,toe,noe,soe,ooe,ioe,coe,hoe,foe,moe,yoe,voe,Ioe,Toe,Noe,Roe,Doe,_oe,Foe,Poe,Moe,Loe,wae,Voe,Hoe,Xoe,Yoe,eie,nie,rie,Eae,iie,uie,die,pie,fie,Aie,xie,wie,Sie,Nie,Rie,Fie,Oie,Pie,Lie,Vie,Hie,qie,Zie,Jie,ele,D8,rle,ile,cle,ple,fle,mle,gle,jae,xle,wle,Sle,Tle,Cle,Rle,Fle,Ple,Mle,Qae,Ble,Vle,Gle,Hle,jle,Xle,Yle,eue,nue,aue,oue,iue,cue,hue,gue,Fae,yue,bue];for(let e of vue)pa(e);var J2=Y();J2.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])));J2.registerFlag("WASM_HAS_MULTITHREAD_SUPPORT",async()=>{if(J2.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{return!1}});var q8=ja(bT()),wue='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()}}}}',kue=ja(vT()),X8=class extends hc{constructor(e){super();this.wasm=e,this.dataIdNextNumber=1,this.wasm.tfjs.initWithThreadsCount(Y8),ex=this.wasm.tfjs.getThreadsCount(),this.dataIdMap=new $p(this,ts())}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 c=t;this.dataIdMap.set(e,{id:a,stringBytes:c,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 Cue(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 Iue(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 K8(e,t,n){if(E0!=null)return E0;let s="tfjs-backend-wasm.wasm";return e&&t?s="tfjs-backend-wasm-threaded-simd.wasm":e&&(s="tfjs-backend-wasm-simd.wasm"),jd!=null&&jd[s]!=null?jd[s]:n+s}async function Sue(){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 c=wue,u=new Blob([c],{type:"application/javascript"});return URL.createObjectURL(u)}return i.endsWith(".wasm")?K8(e,t,Hd??l):l+i},Q2&&(r.instantiateWasm=Iue(K8(e,t,Hd??"")));let a=!1;r.onAbort=()=>{if(a||qd)return;qd=!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&&E0==null?(r.mainScriptUrlOrBlob=new Blob(["var WasmBackendModuleThreadedSimd = "+q8.default.toString()],{type:"text/javascript"}),o=(0,q8.default)(r)):o=(0,kue.default)(r),o.then(i=>{a=!0,qd=!1;let l=null;i.tfjs={init:i.cwrap("init",null,[]),initWithThreadsCount:i.cwrap("init_with_threads_count",null,["number"]),getThreadsCount:i.cwrap("get_threads_count","number",[]),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 Cue(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 Tue=["tfjs-backend-wasm.wasm","tfjs-backend-wasm-simd.wasm","tfjs-backend-wasm-threaded-simd.wasm"],E0=null,Hd=null,jd={},qd=!1,Q2=!1;function Nue(e,t=!1){if(fA("setWasmPath has been deprecated in favor of setWasmPaths and will be removed in a future release."),qd)throw new Error("The WASM backend was already initialized. Make sure you call `setWasmPath()` before you call `tf.setBackend()` or `tf.ready()`");E0=e,Q2=t}function Z8(e,t=!1){if(qd)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")Hd=e;else{jd=e;let n=Tue.filter(s=>jd[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.`)}Q2=t}var Y8=-1,ex=-1;function Eue(e){Y8=e}function Rue(){if(ex===-1)throw new Error("WASM backend not initialized.");return ex}var Due="3.10.0",_ue=2;tu("wasm",async()=>{let{wasm:e}=await Sue();return new X8(e)},_ue);var Fue="3.10.0",$ue="3.10.0",Oue="3.10.0",Pue="3.10.0",Mue="3.10.0",zue="3.10.0",Lue="3.10.0",Bue="3.10.0",Wue={tfjs:Fue,"tfjs-core":$ue,"tfjs-data":Oue,"tfjs-layers":Pue,"tfjs-converter":Mue,"tfjs-backend-cpu":zue,"tfjs-backend-webgl":Lue,"tfjs-backend-wasm":Bue};var J8=`
|
|
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.);
|
|
}
|
|
`;var Q8=`
|
|
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];
|
|
}
|
|
`,eI=`
|
|
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;
|
|
}
|
|
`,tI=`
|
|
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);
|
|
}
|
|
`,nI=`
|
|
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;
|
|
}
|
|
`,sI=`
|
|
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); // top left
|
|
vec4 c12 = texture2D(texture, vec2(vUv.x, vUv.y - px.y)); // top center
|
|
vec4 c13 = texture2D(texture, vec2(vUv.x + px.x, vUv.y - px.y)); // top right
|
|
vec4 c21 = texture2D(texture, vec2(vUv.x - px.x, vUv.y) ); // mid left
|
|
vec4 c22 = texture2D(texture, vUv); // mid center
|
|
vec4 c23 = texture2D(texture, vec2(vUv.x + px.x, vUv.y) ); // mid right
|
|
vec4 c31 = texture2D(texture, vec2(vUv.x - px.x, vUv.y + px.y) ); // bottom left
|
|
vec4 c32 = texture2D(texture, vec2(vUv.x, vUv.y + px.y) ); // bottom center
|
|
vec4 c33 = texture2D(texture, vUv + px ); // bottom right
|
|
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;
|
|
}
|
|
`;var tx=(e,t,n)=>{let s=new RegExp("\\b"+t+" \\w+ (\\w+)","ig");e.replace(s,(r,a)=>(n[a]=0,r))},rI=class{constructor(t,n,s){he(this,"uniform",{});he(this,"attribute",{});he(this,"gl");he(this,"id");he(this,"compile",(t,n)=>{let s=this.gl.createShader(n);if(this.gl.shaderSource(s,t),this.gl.compileShader(s),!this.gl.getShaderParameter(s,this.gl.COMPILE_STATUS))throw new Error(`filter: gl compile failed: ${this.gl.getShaderInfoLog(s)}`);return s});this.gl=t;let r=this.compile(n,this.gl.VERTEX_SHADER),a=this.compile(s,this.gl.FRAGMENT_SHADER);if(this.id=this.gl.createProgram(),this.gl.attachShader(this.id,r),this.gl.attachShader(this.id,a),this.gl.linkProgram(this.id),!this.gl.getProgramParameter(this.id,this.gl.LINK_STATUS))throw new Error(`filter: gl link failed: ${this.gl.getProgramInfoLog(this.id)}`);this.gl.useProgram(this.id),tx(n,"attribute",this.attribute);for(let o in this.attribute)this.attribute[o]=this.gl.getAttribLocation(this.id,o);tx(n,"uniform",this.uniform),tx(s,"uniform",this.uniform);for(let o in this.uniform)this.uniform[o]=this.gl.getUniformLocation(this.id,o)}};function aI(){let e=0,t=null,n=!1,s=-1,r=[null,null],a=[],o=null,i=null,l=zn(100,100),c={},u={INTERMEDIATE:1},d=l.getContext("webgl");if(!d)throw new Error("filter: cannot get webgl context");function p(y,x){if(!(y===l.width&&x===l.height)){if(l.width=y,l.height=x,!o){let b=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]);o=d.createBuffer(),d.bindBuffer(d.ARRAY_BUFFER,o),d.bufferData(d.ARRAY_BUFFER,b,d.STATIC_DRAW),d.pixelStorei(d.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!0)}d.viewport(0,0,l.width,l.height),r=[null,null]}}function h(y,x){let b=d.createFramebuffer();d.bindFramebuffer(d.FRAMEBUFFER,b);let v=d.createRenderbuffer();d.bindRenderbuffer(d.RENDERBUFFER,v);let S=d.createTexture();return d.bindTexture(d.TEXTURE_2D,S),d.texImage2D(d.TEXTURE_2D,0,d.RGBA,y,x,0,d.RGBA,d.UNSIGNED_BYTE,null),d.texParameteri(d.TEXTURE_2D,d.TEXTURE_MAG_FILTER,d.LINEAR),d.texParameteri(d.TEXTURE_2D,d.TEXTURE_MIN_FILTER,d.LINEAR),d.texParameteri(d.TEXTURE_2D,d.TEXTURE_WRAP_S,d.CLAMP_TO_EDGE),d.texParameteri(d.TEXTURE_2D,d.TEXTURE_WRAP_T,d.CLAMP_TO_EDGE),d.framebufferTexture2D(d.FRAMEBUFFER,d.COLOR_ATTACHMENT0,d.TEXTURE_2D,S,0),d.bindTexture(d.TEXTURE_2D,null),d.bindFramebuffer(d.FRAMEBUFFER,null),{fbo:b,texture:S}}function f(y){return r[y]=r[y]||h(l.width,l.height),r[y]}function m(y=0){if(!i)return;let x=null,b=null,v=!1;e===0?x=t:x=f(s)?.texture||null,e++,n&&!(y&u.INTERMEDIATE)?(b=null,v=e%2==0):(s=(s+1)%2,b=f(s)?.fbo||null),d.bindTexture(d.TEXTURE_2D,x),d.bindFramebuffer(d.FRAMEBUFFER,b),d.uniform1f(i.uniform.flipY,v?-1:1),d.drawArrays(d.TRIANGLES,0,6)}function g(y){if(c[y])return i=c[y],d.useProgram(i?.id||null),i;i=new rI(d,J8,y);let x=Float32Array.BYTES_PER_ELEMENT,b=4*x;return d.enableVertexAttribArray(i.attribute.pos),d.vertexAttribPointer(i.attribute.pos,2,d.FLOAT,!1,b,0*x),d.enableVertexAttribArray(i.attribute.uv),d.vertexAttribPointer(i.attribute.uv,2,d.FLOAT,!1,b,2*x),c[y]=i,i}let A={colorMatrix:y=>{let x=new Float32Array(y);x[4]/=255,x[9]/=255,x[14]/=255,x[19]/=255;let b=x[18]===1&&x[3]===0&&x[8]===0&&x[13]===0&&x[15]===0&&x[16]===0&&x[17]===0&&x[19]===0?eI:Q8,v=g(b);d.uniform1fv(v?.uniform.m,x),m()},brightness:y=>{let x=(y||0)+1;A.colorMatrix([x,0,0,0,0,0,x,0,0,0,0,0,x,0,0,0,0,0,1,0])},saturation:y=>{let x=(y||0)*2/3+1,b=(x-1)*-.5;A.colorMatrix([x,b,b,0,0,b,x,b,0,0,b,b,x,0,0,0,0,0,1,0])},desaturate:()=>{A.saturation(-1)},contrast:y=>{let x=(y||0)+1,b=-128*(x-1);A.colorMatrix([x,0,0,0,b,0,x,0,0,b,0,0,x,0,b,0,0,0,1,0])},negative:()=>{A.contrast(-2)},hue:y=>{y=(y||0)/180*Math.PI;let x=Math.cos(y),b=Math.sin(y),v=.213,S=.715,T=.072;A.colorMatrix([v+x*(1-v)+b*-v,S+x*-S+b*-S,T+x*-T+b*(1-T),0,0,v+x*-v+b*.143,S+x*(1-S)+b*.14,T+x*-T+b*-.283,0,0,v+x*-v+b*-(1-v),S+x*-S+b*S,T+x*(1-T)+b*T,0,0,0,0,0,1,0])},desaturateLuminance:()=>{A.colorMatrix([.2764723,.929708,.0938197,0,-37.1,.2764723,.929708,.0938197,0,-37.1,.2764723,.929708,.0938197,0,-37.1,0,0,0,1,0])},sepia:()=>{A.colorMatrix([.393,.7689999,.18899999,0,0,.349,.6859999,.16799999,0,0,.272,.5339999,.13099999,0,0,0,0,0,1,0])},brownie:()=>{A.colorMatrix([.5997023498159715,.34553243048391263,-.2708298674538042,0,47.43192855600873,-.037703249837783157,.8609577587992641,.15059552388459913,0,-36.96841498319127,.24113635128153335,-.07441037908422492,.44972182064877153,0,-7.562075277591283,0,0,0,1,0])},vintagePinhole:()=>{A.colorMatrix([.6279345635605994,.3202183420819367,-.03965408211312453,0,9.651285835294123,.02578397704808868,.6441188644374771,.03259127616149294,0,7.462829176470591,.0466055556782719,-.0851232987247891,.5241648018700465,0,5.159190588235296,0,0,0,1,0])},kodachrome:()=>{A.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])},technicolor:()=>{A.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])},polaroid:()=>{A.colorMatrix([1.438,-.062,-.062,0,0,-.122,1.378,-.122,0,0,-.016,-.016,1.483,0,0,0,0,0,1,0])},shiftToBGR:()=>{A.colorMatrix([0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,1,0])},convolution:y=>{let x=new Float32Array(y),b=1/l.width,v=1/l.height,S=g(sI);d.uniform1fv(S?.uniform.m,x),d.uniform2f(S?.uniform.px,b,v),m()},detectEdges:()=>{A.convolution.call(this,[0,1,0,1,-4,1,0,1,0])},sobelX:()=>{A.convolution.call(this,[-1,0,1,-2,0,2,-1,0,1])},sobelY:()=>{A.convolution.call(this,[-1,-2,-1,0,0,0,1,2,1])},sharpen:y=>{let x=y||1;A.convolution.call(this,[0,-1*x,0,-1*x,1+4*x,-1*x,0,-1*x,0])},emboss:y=>{let x=y||1;A.convolution.call(this,[-2*x,-1*x,0,-1*x,1,1*x,0,1*x,2*x])},blur:y=>{let x=y/7/l.width,b=y/7/l.height,v=g(nI);d.uniform2f(v?.uniform.px,0,b),m(u.INTERMEDIATE),d.uniform2f(v?.uniform.px,x,0),m()},pixelate:y=>{let x=y/l.width,b=y/l.height,v=g(tI);d.uniform2f(v?.uniform.size,x,b),m()}};this.add=function(y){let x=Array.prototype.slice.call(arguments,1),b=A[y];a.push({func:b,args:x})},this.reset=function(){a=[]},this.get=function(){return a},this.apply=function(y){p(y.width,y.height),e=0,t||(t=d.createTexture()),d.bindTexture(d.TEXTURE_2D,t),d.texParameteri(d.TEXTURE_2D,d.TEXTURE_WRAP_S,d.CLAMP_TO_EDGE),d.texParameteri(d.TEXTURE_2D,d.TEXTURE_WRAP_T,d.CLAMP_TO_EDGE),d.texParameteri(d.TEXTURE_2D,d.TEXTURE_MIN_FILTER,d.NEAREST),d.texParameteri(d.TEXTURE_2D,d.TEXTURE_MAG_FILTER,d.NEAREST),d.texImage2D(d.TEXTURE_2D,0,d.RGBA,d.RGBA,d.UNSIGNED_BYTE,y);for(let x=0;x<a.length;x++){n=x===a.length-1;let b=a[x];b.func.apply(this,b.args||[])}return l},this.draw=function(y){return this.add("brightness",0),this.apply(y)}}var R0=2048,dn=null,bn=null,Wu=null,Et;function zn(e,t){let n;if(xe.browser)if(xe.worker)n=new OffscreenCanvas(e,t);else{if(typeof document=="undefined")throw new Error("attempted to run in web worker but offscreenCanvas is not supported");n=document.createElement("canvas"),n.width=e,n.height=t}else typeof xe.Canvas!="undefined"?n=new xe.Canvas(e,t):typeof globalThis.Canvas!="undefined"&&(n=new globalThis.Canvas(e,t));return n}function nx(e,t){let n=t||zn(e.width,e.height);return n.getContext("2d").drawImage(e,0,0),n}function Vu(e,t,n=!0){if(!e)return t.debug&&ee("input is missing"),{tensor:null,canvas:null};if(!(e instanceof Ge)&&!(typeof Image!="undefined"&&e instanceof Image)&&!(typeof xe.Canvas!="undefined"&&e instanceof xe.Canvas)&&!(typeof globalThis.Canvas!="undefined"&&e instanceof globalThis.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.isDisposedInternal)throw new Error("input tensor is disposed");if(!e.shape||e.shape.length!==4||e.shape[0]!==1||e.shape[3]!==3)throw new Error(`input tensor shape must be [1, height, width, 3] and instead was ${e.shape}`);return{tensor:Xs(e),canvas:t.filter.return?bn:null}}else{if(typeof e.readyState!="undefined"&&e.readyState<=2)return t.debug&&ee("input stream is not ready"),{tensor:null,canvas:dn};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&&ee("cannot determine input dimensions"),{tensor:null,canvas:dn};let a=s,o=r;if(a>R0&&(a=R0,o=Math.trunc(a*r/s)),o>R0&&(o=R0,a=Math.trunc(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");(!dn||dn?.width!==a||dn?.height!==o)&&(dn=zn(a,o));let i=dn.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,dn?.width,dn?.height),i.setTransform(1,0,0,1,0,0)):i.drawImage(e,0,0,s,r,0,0,dn?.width,dn?.height),(!bn||dn.width!==bn.width||dn?.height!==bn?.height)&&(bn=zn(dn.width,dn.height)),t.filter.enabled&&xe.webgl.supported){if(Et||(Et=xe.browser?new aI:null),xe.filter=!!Et,!Et)return{tensor:null,canvas:dn};Et.reset(),t.filter.brightness!==0&&Et.add("brightness",t.filter.brightness),t.filter.contrast!==0&&Et.add("contrast",t.filter.contrast),t.filter.sharpness!==0&&Et.add("sharpen",t.filter.sharpness),t.filter.blur!==0&&Et.add("blur",t.filter.blur),t.filter.saturation!==0&&Et.add("saturation",t.filter.saturation),t.filter.hue!==0&&Et.add("hue",t.filter.hue),t.filter.negative&&Et.add("negative"),t.filter.sepia&&Et.add("sepia"),t.filter.vintage&&Et.add("brownie"),t.filter.sepia&&Et.add("sepia"),t.filter.kodachrome&&Et.add("kodachrome"),t.filter.technicolor&&Et.add("technicolor"),t.filter.polaroid&&Et.add("polaroid"),t.filter.pixelate!==0&&Et.add("pixelate",t.filter.pixelate),Et.get()>0?bn=Et.apply(dn):bn=Et.draw(dn)}else nx(dn,bn),Et&&(Et=null),xe.filter=!!Et;if(!n)return{tensor:null,canvas:bn};if(!bn)throw new Error("cannot create output canvas");let l,c=3;if(typeof ImageData!="undefined"&&e instanceof ImageData||e.data&&e.width&&e.height)if(xe.browser&&Os)l=Os?Os.fromPixels(e):null;else{c=e.data.length/e.height/e.width;let p=new Uint8Array(e.data.buffer);l=zt(p,[e.height,e.width,c],"int32")}else if((!Wu||bn.width!==Wu.width||bn?.height!==Wu?.height)&&(Wu=zn(bn.width,bn.height)),Os&&xe.browser)t.backend==="webgl"||t.backend==="humangl"||t.backend==="webgpu"?l=Os.fromPixels(bn):(Wu=nx(bn),l=Os.fromPixels(Wu));else{let f=nx(bn).getContext("2d").getImageData(0,0,a,o);c=f.data.length/a/o;let m=new Uint8Array(f.data.buffer);l=zt(m,[a,o,c])}if(c===4){let p=pu(l,[0,0,0],[-1,-1,3]);Z(l),l=p}if(!l)throw new Error("cannot create tensor from input");let u=de(l,"float32"),d=Lt(u,0);return Z([l,u]),{tensor:d,canvas:t.filter.return?bn:null}}}var sx=0,rx=1,ax=0,Vue=async e=>{let t=48,n=_e.resizeBilinear(e,[Math.trunc((e.shape[1]||1)/t),Math.trunc((e.shape[2]||1)/t)]),s=async()=>{let o=Ie(n),i=await o.data();return Z(o),i[0]},r=async()=>{let o=await n.data(),i=0;for(let l=0;l<o.length/3;l++)i+=o[3*l+2];return i};if(ax===0){let o=pe();await r();let i=pe();await s();let l=pe();ax=i-o<l-i?1:2}let a=ax===1?await r():await s();return Z(n),a};async function oI(e,t){if(e.cacheSensitivity===0)return!1;let n=await Vue(t),s=100*(Math.max(n,sx)/Math.min(n,sx)-1);sx=n;let r=s<Math.max(e.cacheSensitivity,rx);return rx=s>10*e.cacheSensitivity?0:s,r=r&&rx>0,r}var iI=class{constructor(){he(this,"browser");he(this,"node");he(this,"worker");he(this,"platform","");he(this,"agent","");he(this,"backends",[]);he(this,"initial");he(this,"filter");he(this,"tfjs");he(this,"offscreen");he(this,"perfadd",!1);he(this,"wasm",{supported:void 0,backend:void 0,simd:void 0,multithread:void 0});he(this,"webgl",{supported:void 0,backend:void 0,version:void 0,renderer:void 0});he(this,"webgpu",{supported:void 0,backend:void 0,adapter:void 0});he(this,"cpu",{model:void 0,flags:[]});he(this,"kernels",[]);he(this,"Canvas");he(this,"Image");he(this,"ImageData");if(this.browser=typeof navigator!="undefined",this.node=typeof process!="undefined",this.tfjs={version:Vc},this.offscreen=typeof OffscreenCanvas!="undefined",this.initial=!0,this.worker=this.browser&&this.offscreen?typeof WorkerGlobalScope!="undefined":void 0,typeof navigator!="undefined"){let t=navigator.userAgent.match(/\(([^()]+)\)/g);if(t&&t[0]){let n=t[0].match(/\(([^()]+)\)/g);this.platform=n&&n[0]?n[0].replace(/\(|\)/g,""):"",this.agent=navigator.userAgent.replace(t[0],""),this.platform[1]&&(this.agent=this.agent.replace(t[1],"")),this.agent=this.agent.replace(/ /g," ")}}else typeof process!="undefined"&&(this.platform=`${process.platform} ${process.arch}`,this.agent=`NodeJS ${process.version}`)}async updateBackend(){this.backends=Object.keys(ts().registryFactory),this.wasm.supported=typeof WebAssembly!="undefined",this.wasm.backend=this.backends.includes("wasm"),this.wasm.supported&&this.wasm.backend&&Ks()==="wasm"&&(this.wasm.simd=await Y().getAsync("WASM_HAS_SIMD_SUPPORT"),this.wasm.multithread=await Y().getAsync("WASM_HAS_MULTITHREAD_SUPPORT"));let t=zn(100,100),n=t?t.getContext("webgl2"):void 0;if(this.webgl.supported=typeof n!="undefined",this.webgl.backend=this.backends.includes("webgl"),this.webgl.supported&&this.webgl.backend&&(Ks()==="webgl"||Ks()==="humangl")){let s=gr().gpgpu!=="undefined"?await gr().getGPGPUContext().gl:null;s&&(this.webgl.version=s.getParameter(s.VERSION),this.webgl.renderer=s.getParameter(s.RENDERER))}this.webgpu.supported=this.browser&&typeof navigator.gpu!="undefined",this.webgpu.backend=this.backends.includes("webgpu"),this.webgpu.supported&&(this.webgpu.adapter=(await navigator.gpu.requestAdapter())?.name),this.kernels=Or(Ks()).map(s=>s.kernelName.toLowerCase())}async updateCPU(){let t={model:"",flags:[]};if(this.node&&this.platform?.startsWith("linux")){let n=ra("fs");try{let s=n.readFileSync("/proc/cpuinfo").toString();for(let r of s.split(`
|
|
`))r.startsWith("model name")&&(t.model=r.match(/:(.*)/g)[0].replace(":","").trim()),r.startsWith("flags")&&(t.flags=r.match(/:(.*)/g)[0].replace(":","").trim().split(" ").sort())}catch{}}this.cpu?this.cpu=t:Object.defineProperty(this,"cpu",{value:t})}},xe=new iI;var ox="2.4.2";var Oa;var lde=Number.MAX_SAFE_INTEGER;async function lI(e){return xe.initial&&(Oa=null),Oa?e.debug&&ee("cached model:",Oa.modelUrl):(Oa=await Qe(tt(e.modelBasePath,e.face.agegenderrace.modelPath)),!Oa||!Oa.modelUrl?ee("load model failed:",e.face.agegenderrace.modelPath):e.debug&&ee("load model:",Oa.modelUrl)),Oa}var ps,D0=[],ix=Number.MAX_SAFE_INTEGER,uI=0,cI=0;async function dI(e){return xe.initial&&(ps=null),ps?e.debug&&ee("cached model:",ps.modelUrl):(ps=await Qe(tt(e.modelBasePath,e.face.antispoof?.modelPath||"")),!ps||!ps.modelUrl?ee("load model failed:",e.face.antispoof?.modelPath):e.debug&&ee("load model:",ps.modelUrl)),ps}async function lx(e,t,n,s){if(!ps)return null;let r=(t.face.antispoof?.skipTime||0)>pe()-cI,a=ix<(t.face.antispoof?.skipFrames||0);return t.skipAllowed&&r&&a&&uI===s&&D0[n]?(ix++,D0[n]):(ix=0,new Promise(async o=>{let i=_e.resizeBilinear(e,[ps?.inputs[0].shape?ps.inputs[0].shape[2]:0,ps?.inputs[0].shape?ps.inputs[0].shape[1]:0],!1),l=ps?.predict(i),c=(await l.data())[0];D0[n]=Math.round(100*c)/100,uI=s,cI=pe(),Z([i,l]),o(D0[n])}))}var Nr={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]},ux={count:468,mouth:13,symmetryLine:[13,Nr.midwayBetweenEyes[0]]},Kd={leftEye:0,rightEye:1,nose:2,mouth:3,leftEar:4,rightEar:5,symmetryLine:[3,2]},cx=[{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]}],Zd=[[.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]],Ei=[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 Gue=[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],Hue=[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],jue=[33,133,362,263,1,78,308],fde=Gue.map(e=>Zd[e]),mde=Hue.map(e=>Zd[e]),gde=jue.map(e=>Zd[e]);var pI=e=>({startPoint:Fe(e,[0,0],[-1,2]),endPoint:Fe(e,[0,2],[-1,2])});var Yd=e=>[Math.abs(e.endPoint[0]-e.startPoint[0]),Math.abs(e.endPoint[1]-e.startPoint[1])],_0=e=>[e.startPoint[0]+(e.endPoint[0]-e.startPoint[0])/2,e.startPoint[1]+(e.endPoint[1]-e.startPoint[1])/2],dx=(e,t)=>e?[Math.trunc(Math.max(0,e.startPoint[0])),Math.trunc(Math.max(0,e.startPoint[1])),Math.trunc(Math.min(t.shape[2]||0,e.endPoint[0])-Math.max(0,e.startPoint[0])),Math.trunc(Math.min(t.shape[1]||0,e.endPoint[1])-Math.max(0,e.startPoint[1]))]:[0,0,0,0],px=(e,t)=>e?[e.startPoint[0]/(t.shape[2]||0),e.startPoint[1]/(t.shape[1]||0),(e.endPoint[0]-e.startPoint[0])/(t.shape[2]||0),(e.endPoint[1]-e.startPoint[1])/(t.shape[1]||0)]:[0,0,0,0],hI=(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}},hx=(e,t,n)=>{let s=t.shape[1],r=t.shape[2];return _e.cropAndResize(t,[[e.startPoint[1]/s,e.startPoint[0]/r,e.endPoint[1]/s,e.endPoint[0]/r]],[0],n)},Jd=(e,t=1.5)=>{let n=_0(e),s=Yd(e),r=[t*s[0]/2,t*s[1]/2];return{startPoint:[n[0]-r[0],n[1]-r[1]],endPoint:[n[0]+r[0],n[1]+r[1]],landmarks:e.landmarks}},Qd=e=>{let t=_0(e),n=Yd(e),s=Math.max(...n)/2;return{startPoint:[Math.round(t[0]-s),Math.round(t[1]-s)],endPoint:[Math.round(t[0]+s),Math.round(t[1]+s)],landmarks:e.landmarks}},F0=e=>{let t=e.map(s=>s[0]),n=e.map(s=>s[1]);return{startPoint:[Math.min(...t),Math.min(...n)],endPoint:[Math.max(...t),Math.max(...n)],landmarks:e}},$0=[[1,0,0],[0,1,0],[0,0,1]],que=e=>e-2*Math.PI*Math.floor((e+Math.PI)/(2*Math.PI)),Xue=(e,t)=>que(Math.PI/2-Math.atan2(-(t[1]-e[1]),t[0]-e[0]));var fI=(e,t)=>[[1,0,e],[0,1,t],[0,0,1]],Ri=(e,t)=>{let n=0;for(let s=0;s<e.length;s++)n+=e[s]*t[s];return n},Kue=(e,t)=>{let n=[];for(let s=0;s<e.length;s++)n.push(e[s][t]);return n},mI=(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(Ri(e[r],Kue(t,a)))}return n},gI=(e,t)=>{let n=Math.cos(e),s=Math.sin(e),r=[[n,-s,0],[s,n,0],[0,0,1]],a=fI(t[0],t[1]),o=mI(a,r),i=fI(-t[0],-t[1]);return mI(o,i)},Zue=e=>{let t=[[e[0][0],e[1][0]],[e[0][1],e[1][1]]],n=[e[0][2],e[1][2]],s=[-Ri(t[0],n),-Ri(t[1],n)];return[t[0].concat(s[0]),t[1].concat(s[1]),[0,0,1]]},Yue=(e,t)=>[Ri(e,t[0]),Ri(e,t[1])];function AI(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 c=r*(l+.5);for(let u=0;u<o;u++){let d=r*(u+.5);for(let p=0;p<i;p++)n.push([d,c])}}}return n}function yI(e,t,n,s,r){let a=Yd({startPoint:t.startPoint,endPoint:t.endPoint}),o=e.map(d=>[a[0]/r*(d[0]-r/2),a[1]/r*(d[1]-r/2),d[2]||0]),i=n!==0?gI(n,[0,0]):$0,l=n!==0?o.map(d=>[...Yue(d,i),d[2]]):o,c=n!==0?Zue(s):$0,u=[..._0({startPoint:t.startPoint,endPoint:t.endPoint}),1];return l.map(d=>[Math.round(d[0]+Ri(u,c[0])),Math.round(d[1]+Ri(u,c[1])),Math.round(d[2]||0)])}function fx(e,t,n){let s=e.landmarks.length>=ux.count?ux.symmetryLine:Kd.symmetryLine,r=Xue(e.landmarks[s[0]],e.landmarks[s[1]]),a=_0({startPoint:e.startPoint,endPoint:e.endPoint}),o=[a[0]/t.shape[2],a[1]/t.shape[1]],i=_e.rotateWithOffset(t,r,0,o),l=gI(-r,a),c=hx({startPoint:e.startPoint,endPoint:e.endPoint},i,[n,n]),u=fe(c,255);return Z(c),Z(i),[r,l,u]}var xI=6,ir,mx=[],bI=null,Ts=0,ep=()=>Ts;async function vI(e){return xe.initial&&(ir=null),ir?e.debug&&ee("cached model:",ir.modelUrl):(ir=await Qe(tt(e.modelBasePath,e.face.detector?.modelPath||"")),!ir||!ir.modelUrl?ee("load model failed:",e.face.detector?.modelPath):e.debug&&ee("load model:",ir.modelUrl)),Ts=ir.inputs[0].shape?ir.inputs[0].shape[2]:0,Ts===-1&&(Ts=64),mx=AI(Ts),bI=Ys(mx),ir}function Jue(e){let t=Fe(e,[0,1],[-1,2]),n=le(t,bI),s=Fe(e,[0,3],[-1,2]),r=fe(s,Ts),a=fe(n,Ts),o=fe(r,2),i=be(a,o),l=le(a,o),c=L(i,Ts),u=L(l,Ts);return ru([c,u],1)}async function wI(e,t){if(!e||e.isDisposedInternal||e.shape.length!==4||e.shape[1]<1||e.shape[2]<1)return{boxes:[]};let[n,s,r]=G(()=>{let c=_e.resizeBilinear(e,[Ts,Ts]),u=be(fe(c,127.5),.5),d=ir?.execute(u),p;if(Array.isArray(d)){let g=d.sort((b,v)=>b.size-v.size),A=mt([g[0],g[2]],2),y=mt([g[1],g[3]],2),x=mt([y,A],1);p=rt(x,0)}else p=rt(d);let h=Jue(p),f=Fe(p,[0,0],[-1,1]),m=rt(Hn(f));return[p,h,m]}),a=await _e.nonMaxSuppressionAsync(s,r,t.face.detector?.maxDetected||0,t.face.detector?.iouThreshold||0,t.face.detector?.minConfidence||0),o=await a.array();Z(a);let i=[],l=await r.data();for(let c=0;c<o.length;c++){let u=l[o[c]];if(u>(t.face.detector?.minConfidence||0)){let d=Fe(s,[o[c],0],[1,-1]),p=G(()=>V(rt(Fe(n,[o[c],xI-1],[1,-1])),[xI,-1]));i.push({box:pI(d),landmarks:p,anchor:mx[o[c]],confidence:u}),Z(d)}}return Z(n),Z(s),Z(r),{boxes:i,scaleFactor:[e.shape[2]/Ts,e.shape[1]/Ts]}}var yx={};lc(yx,{connected:()=>Ax,kpt:()=>gx});var gx=["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","bodyCenter","bodyTop","leftThumb","leftHand","rightThumb","rightHand"],Ax={leftLeg:["leftHip","leftKnee","leftAnkle","leftHeel","leftFoot"],rightLeg:["rightHip","rightKnee","rightAnkle","rightHeel","rightFoot"],torso:["leftShoulder","rightShoulder","rightHip","leftHip","leftShoulder"],leftArm:["leftShoulder","leftElbow","leftWrist","leftPalm"],rightArm:["rightShoulder","rightElbow","rightWrist","rightPalm"],leftHand:[],rightHand:[],head:[]};var kI={initial:!0},tn=[null,null],Pa=[[0,0],[0,0]],xx=Number.MAX_SAFE_INTEGER,bx,O0=null,Ma=[[0,0],[0,0],[0,0],[0,0]],II=0;async function SI(e){if(kI.initial&&(tn[0]=null),!tn[0]&&e.body.detector?.modelPath){tn[0]=await Qe(tt(e.modelBasePath,e.body.detector?.modelPath||""));let t=Object.values(tn[0].modelSignature.inputs);Pa[0][0]=Array.isArray(t)?parseInt(t[0].tensorShape.dim[1].size):0,Pa[0][1]=Array.isArray(t)?parseInt(t[0].tensorShape.dim[2].size):0,!tn[0]||!tn[0].modelUrl?ee("load model failed:",e.body.detector?.modelPath):e.debug&&ee("load model:",tn[0].modelUrl)}else e.debug&&tn[0]&&ee("cached model:",tn[0].modelUrl);return tn[0]}async function CI(e){if(kI.initial&&(tn[1]=null),tn[1])e.debug&&ee("cached model:",tn[1].modelUrl);else{tn[1]=await Qe(tt(e.modelBasePath,e.body.modelPath||""));let t=Object.values(tn[1].modelSignature.inputs);Pa[1][0]=Array.isArray(t)?parseInt(t[0].tensorShape.dim[1].size):0,Pa[1][1]=Array.isArray(t)?parseInt(t[0].tensorShape.dim[2].size):0,e.body.modelPath?.includes("lite")?bx=["ld_3d","output_segmentation","output_heatmap","world_3d","output_poseflag"]:bx=["Identity","Identity_2","Identity_3","Identity_4","Identity_1"],!tn[1]||!tn[1].modelUrl?ee("load model failed:",e.body.modelPath):e.debug&&ee("load model:",tn[1].modelUrl)}return tn[1]}function Que(e,t){let n=e.map(o=>o.position[0]),s=e.map(o=>o.position[1]),r=[Math.min(...n),Math.min(...s),Math.max(...n)-Math.min(...n),Math.max(...s)-Math.min(...s)],a=[r[0]/t[0],r[1]/t[1],r[2]/t[0],r[3]/t[1]];return{keypointsBox:r,keypointsBoxRaw:a}}async function ece(e){let t={};if(!e.shape||!e.shape[1]||!e.shape[2])return e;Ma=[[0,0],[e.shape[2]>e.shape[1]?Math.trunc((e.shape[2]-e.shape[1])/2):0,e.shape[2]>e.shape[1]?Math.trunc((e.shape[2]-e.shape[1])/2):0],[e.shape[1]>e.shape[2]?Math.trunc((e.shape[1]-e.shape[2])/2):0,e.shape[1]>e.shape[2]?Math.trunc((e.shape[1]-e.shape[2])/2):0],[0,0]],t.pad=vs(e,Ma),t.resize=_e.resizeBilinear(t.pad,[Pa[1][0],Pa[1][1]]);let n=fe(t.resize,255);return Object.keys(t).forEach(s=>Z(t[s])),n}function tce(e,t){for(let n of e)n.position=[n.position[0]*(t[0]+Ma[2][0]+Ma[2][1])/t[0]-Ma[2][0],n.position[1]*(t[1]+Ma[1][0]+Ma[1][1])/t[1]-Ma[1][0],n.position[2]],n.positionRaw=[n.position[0]/t[0],n.position[1]/t[1],n.position[2]];return e}var TI=e=>1-1/(1+Math.exp(e));async function nce(e,t,n){let s={};s.input=await ece(e),[s.ld,s.segmentation,s.heatmap,s.world,s.poseflag]=await tn[1]?.execute(s.input,bx);let r=(await s.poseflag.data())[0],a=Math.max(0,(r-.8)/(1-.8)),o=await s.ld.data(),i=[],l=5;for(let h=0;h<o.length/l;h++){let f=TI(o[l*h+3]),m=TI(o[l*h+4]),g=Math.trunc(100*f*m*a)/100,A=[o[l*h+0]/Pa[1][0],o[l*h+1]/Pa[1][1],o[l*h+2]+0],y=[Math.trunc(n[0]*A[0]),Math.trunc(n[1]*A[1]),A[2]];i.push({part:gx[h],positionRaw:A,position:y,score:g})}if(a<(t.body.minConfidence||0))return null;let c=tce(i,n),u=Que(c,[n[0],n[1]]);Object.keys(s).forEach(h=>Z(s[h]));let d={};for(let[h,f]of Object.entries(Ax)){let m=[];for(let g=0;g<f.length-1;g++){let A=c.find(x=>x.part===f[g]),y=c.find(x=>x.part===f[g+1]);A&&y&&A.score>(t.body.minConfidence||0)&&y.score>(t.body.minConfidence||0)&&m.push([A.position,y.position])}d[h]=m}return{id:0,score:Math.trunc(100*a)/100,box:u.keypointsBox,boxRaw:u.keypointsBoxRaw,keypoints:c,annotations:d}}async function vx(e,t){let n=[e.shape[2]||0,e.shape[1]||0],s=(t.body.skipTime||0)>pe()-II,r=xx<(t.body.skipFrames||0);return t.skipAllowed&&s&&r&&O0!==null?xx++:(O0=await nce(e,t,n),II=pe(),xx=0),O0?[O0]:[]}var Uu=[{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 Er,Di=0,P0=[],NI=0,wx=Number.MAX_SAFE_INTEGER;async function EI(e){if(xe.initial&&(Er=null),Er)e.debug&&ee("cached model:",Er.modelUrl);else{Gu(["floormod"],e),Er=await Qe(tt(e.modelBasePath,e.object.modelPath||""));let t=Object.values(Er.modelSignature.inputs);Di=Array.isArray(t)?parseInt(t[0].tensorShape.dim[2].size):0,!Er||!Er.modelUrl?ee("load model failed:",e.object.modelPath):e.debug&&ee("load model:",Er.modelUrl)}return Er}async function sce(e,t,n){if(!e)return[];let s=[],r=await e.array(),a=rt(e);Z(e);let o=on(a,6,1);Z(a);let i=gn([o[1],o[0],o[3],o[2]],1),l=rt(i);Z(i);let c=rt(o[4]),u=rt(o[5]);o.forEach(f=>Z(f));let d=await _e.nonMaxSuppressionAsync(l,c,n.object.maxDetected,n.object.iouThreshold,n.object.minConfidence);Z(l),Z(c),Z(u);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=Uu[g].label,[y,x]=[r[0][f][0]/Di,r[0][f][1]/Di],b=[y,x,r[0][f][2]/Di-y,r[0][f][3]/Di-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 kx(e,t){let n=(t.object.skipTime||0)>pe()-NI,s=wx<(t.object.skipFrames||0);return t.skipAllowed&&n&&s&&P0.length>0?(wx++,P0):(wx=0,!xe.kernels.includes("mod")||!xe.kernels.includes("sparsetodense")?P0:new Promise(async r=>{let a=[e.shape[2],e.shape[1]],o=_e.resizeBilinear(e,[Di,Di]),i=t.object.enabled?Er?.execute(o,["tower_0/detections"]):null;NI=pe(),Z(o);let l=await sce(i,a,t);P0=l,r(l)}))}var Cx={};lc(Cx,{connected:()=>Sx,kpt:()=>Ix});var Ix=["head","neck","rightShoulder","rightElbow","rightWrist","chest","leftShoulder","leftElbow","leftWrist","bodyCenter","rightHip","rightKnee","rightAnkle","leftHip","leftKnee","leftAnkle"],Sx={leftLeg:["leftHip","leftKnee","leftAnkle"],rightLeg:["rightHip","rightKnee","rightAnkle"],torso:["leftShoulder","rightShoulder","rightHip","leftHip","leftShoulder"],leftArm:["leftShoulder","leftElbow","leftWrist"],rightArm:["rightShoulder","rightElbow","rightWrist"],head:[]};var Ln,RI=0,Bn={id:0,keypoints:[],box:[0,0,0,0],boxRaw:[0,0,0,0],score:0,annotations:{}},Tx=Number.MAX_SAFE_INTEGER;async function Nx(e){return xe.initial&&(Ln=null),Ln?e.debug&&ee("cached model:",Ln.modelUrl):(Ln=await Qe(tt(e.modelBasePath,e.body.modelPath||"")),!Ln||!Ln.modelUrl?ee("load model failed:",e.body.modelPath):e.debug&&ee("load model:",Ln.modelUrl)),Ln}function rce(e,t){let[n,s]=e.shape;return G(()=>{let r=(i,l)=>be(i,L(fe(i,Ee(l,"int32")),Ee(l,"int32"))),a=V(e,[s*n]),o=Rn(a,0).dataSync()[0];if(o>t){let i=xs(a,0),l=r(i,n).dataSync()[0],c=fe(i,Ee(n,"int32")).dataSync()[0];return[l,c,o]}return[0,0,o]})}async function Ex(e,t){let n=(t.body.skipTime||0)>pe()-RI,s=Tx<(t.body.skipFrames||0);return t.skipAllowed&&n&&s&&Object.keys(Bn.keypoints).length>0?(Tx++,[Bn]):(Tx=0,new Promise(async r=>{let a=G(()=>{if(!Ln?.inputs[0].shape)return null;let d=_e.resizeBilinear(e,[Ln.inputs[0].shape[2],Ln.inputs[0].shape[1]],!1);return L(d,2).sub(1)}),o;if(t.body.enabled&&(o=await Ln?.predict(a)),RI=pe(),Z(a),o){Bn.keypoints.length=0;let d=o.squeeze();Z(o);let p=d.unstack(2);Z(d);for(let h=0;h<p.length;h++){let[f,m,g]=rce(p[h],t.body.minConfidence);g>(t.body?.minConfidence||0)&&Bn.keypoints.push({score:Math.round(100*g)/100,part:Ix[h],positionRaw:[f/Ln.inputs[0].shape[2],m/Ln.inputs[0].shape[1]],position:[Math.round(e.shape[2]*f/Ln.inputs[0].shape[2]),Math.round(e.shape[1]*m/Ln.inputs[0].shape[1])]})}p.forEach(h=>Z(h))}Bn.score=Bn.keypoints.reduce((d,p)=>p.score>d?p.score:d,0);let i=Bn.keypoints.map(d=>d.position[0]),l=Bn.keypoints.map(d=>d.position[1]);Bn.box=[Math.min(...i),Math.min(...l),Math.max(...i)-Math.min(...i),Math.max(...l)-Math.min(...l)];let c=Bn.keypoints.map(d=>d.positionRaw[0]),u=Bn.keypoints.map(d=>d.positionRaw[1]);Bn.boxRaw=[Math.min(...c),Math.min(...u),Math.max(...c)-Math.min(...c),Math.max(...u)-Math.min(...u)];for(let[d,p]of Object.entries(Sx)){let h=[];for(let f=0;f<p.length-1;f++){let m=Bn.keypoints.find(A=>A.part===p[f]),g=Bn.keypoints.find(A=>A.part===p[f+1]);m&&g&&m.score>(t.body.minConfidence||0)&&g.score>(t.body.minConfidence||0)&&h.push([m.position,g.position])}Bn.annotations[d]=h}r([Bn])}))}var ace=["angry","disgust","fear","happy","sad","surprise","neutral"],hs,M0=[],DI=0,_I=0,Rx=Number.MAX_SAFE_INTEGER,Dx=[.2989,.587,.114];async function FI(e){return xe.initial&&(hs=null),hs?e.debug&&ee("cached model:",hs.modelUrl):(hs=await Qe(tt(e.modelBasePath,e.face.emotion?.modelPath||"")),!hs||!hs.modelUrl?ee("load model failed:",e.face.emotion?.modelPath):e.debug&&ee("load model:",hs.modelUrl)),hs}async function _x(e,t,n,s){if(!hs)return null;let r=Rx<(t.face.emotion?.skipFrames||0),a=(t.face.emotion?.skipTime||0)>pe()-_I;return t.skipAllowed&&a&&r&&DI===s&&M0[n]&&M0[n].length>0?(Rx++,M0[n]):(Rx=0,new Promise(async o=>{let i=[];if(t.face.emotion?.enabled){let l=_e.resizeBilinear(e,[hs?.inputs[0].shape?hs.inputs[0].shape[2]:0,hs?.inputs[0].shape?hs.inputs[0].shape[1]:0],!1),[c,u,d]=on(l,3,3);Z(l);let p=L(c,Dx[0]),h=L(u,Dx[1]),f=L(d,Dx[2]);Z(c),Z(u),Z(d);let m=Oh([p,h,f]);Z(p),Z(h),Z(f);let g=G(()=>L(be(m,.5),2));Z(m);let A=await hs?.predict(g);_I=pe();let y=await A.data();Z(A);for(let x=0;x<y.length;x++)y[x]>(t.face.emotion?.minConfidence||0)&&i.push({score:Math.min(.99,Math.trunc(100*y[x])/100),emotion:ace[x]});i.sort((x,b)=>b.score-x.score),Z(g)}M0[n]=i,DI=s,o(i)}))}var Ws,za=0,oce=2.3,Fx=Nr.leftEyeLower0,$x=Nr.rightEyeLower0,Hu={leftBounds:[Fx[0],Fx[Fx.length-1]],rightBounds:[$x[0],$x[$x.length-1]]},ju={upperCenter:3,lowerCenter:4,index:71,numCoordinates:76};async function $I(e){return xe.initial&&(Ws=null),Ws?e.debug&&ee("cached model:",Ws.modelUrl):(Ws=await Qe(tt(e.modelBasePath,e.face.iris?.modelPath||"")),!Ws||!Ws.modelUrl?ee("load model failed:",e.face.iris?.modelPath):e.debug&&ee("load model:",Ws.modelUrl)),za=Ws.inputs[0].shape?Ws.inputs[0].shape[2]:0,za===-1&&(za=64),Ws}function z0(e,t,n,s){for(let r=0;r<cx.length;r++){let{key:a,indices:o}=cx[r],i=Nr[`${n}${a}`];if(!s||s.includes(a))for(let l=0;l<o.length;l++){let c=o[l];e[i[l]]=[t[c][0],t[c][1],(t[c][2]+e[i[l]][2])/2]}}}var ice=e=>{let t=e[Hu.leftBounds[0]][2],n=e[Hu.rightBounds[0]][2];return t-n},OI=(e,t,n,s,r=!1,a)=>{let o=Qd(Jd(F0([e[n],e[s]]),oce)),i=Yd(o),l=_e.cropAndResize(t,[[o.startPoint[1]/a,o.startPoint[0]/a,o.endPoint[1]/a,o.endPoint[0]/a]],[0],[za,za]);if(r&&xe.kernels.includes("flipleftright")){let c=_e.flipLeftRight(l);Z(l),l=c}return{box:o,boxSize:i,crop:l}},PI=(e,t,n,s=!1)=>{let r=[];for(let a=0;a<ju.numCoordinates;a++){let o=e[a*3],i=e[a*3+1],l=e[a*3+2];r.push([(s?1-o/za:o/za)*n[0]+t.startPoint[0],i/za*n[1]+t.startPoint[1],l])}return{rawCoords:r,iris:r.slice(ju.index)}},MI=(e,t,n)=>{let s=e[Nr[`${n}EyeUpper0`][ju.upperCenter]][2],r=e[Nr[`${n}EyeLower0`][ju.lowerCenter]][2],a=(s+r)/2;return t.map((o,i)=>{let l=a;return i===2?l=s:i===4&&(l=r),[o[0],o[1],l]})};async function zI(e,t,n,s){if(!Ws)return n.debug&&ee("face mesh iris detection requested, but model is not loaded"),e;let{box:r,boxSize:a,crop:o}=OI(e,t,Hu.leftBounds[0],Hu.leftBounds[1],!0,s),{box:i,boxSize:l,crop:c}=OI(e,t,Hu.rightBounds[0],Hu.rightBounds[1],!0,s),u=mt([o,c]);Z(o),Z(c);let d=Ws.predict(u);Z(u);let p=await d.data();Z(d);let h=p.slice(0,ju.numCoordinates*3),{rawCoords:f,iris:m}=PI(h,r,a,!0),g=p.slice(ju.numCoordinates*3),{rawCoords:A,iris:y}=PI(g,i,l),x=ice(e);Math.abs(x)<30?(z0(e,f,"left",null),z0(e,A,"right",null)):x<1?z0(e,f,"left",["EyeUpper0","EyeLower0"]):z0(e,A,"right",["EyeUpper0","EyeLower0"]);let b=MI(e,m,"left"),v=MI(e,y,"right");return e.concat(b).concat(v)}var Rr=[],Vs=null,lr=0,Ox=Number.MAX_SAFE_INTEGER,LI=0,BI=0;async function WI(e,t){let n=(t.face.detector?.skipTime||0)>pe()-LI,s=Ox<(t.face.detector?.skipFrames||0);if(!t.skipAllowed||!n||!s||BI===0){let i=await wI(e,t);LI=pe(),Rr=[];for(let l of i.boxes){let c=await l.box.startPoint.data(),u=await l.box.endPoint.data(),d=await l.landmarks.array();Rr.push({startPoint:c,endPoint:u,landmarks:d,confidence:l.confidence})}i.boxes.forEach(l=>Z([l.box.startPoint,l.box.endPoint,l.landmarks]));for(let l=0;l<Rr.length;l++){let c=hI({startPoint:Rr[l].startPoint,endPoint:Rr[l].endPoint},i.scaleFactor),u=Jd(c),d=Qd(u);Rr[l]={...d,confidence:Rr[l].confidence,landmarks:Rr[l].landmarks}}Ox=0}else Ox++;let r=[],a=[],o=0;for(let i of Rr){let l=0,c,u={id:o++,mesh:[],meshRaw:[],box:[0,0,0,0],boxRaw:[0,0,0,0],score:0,boxScore:0,faceScore:0,annotations:{}};if(t.face.detector?.rotation&&t.face.mesh?.enabled&&xe.kernels.includes("rotatewithoffset"))[l,c,u.tensor]=fx(i,e,lr);else{c=$0;let d=hx({startPoint:i.startPoint,endPoint:i.endPoint},e,t.face.mesh?.enabled?[lr,lr]:[ep(),ep()]);u.tensor=fe(d,255),Z(d)}if(u.boxScore=Math.round(100*i.confidence)/100,t.face.mesh?.enabled)if(!Vs)t.debug&&ee("face mesh detection requested, but model is not loaded");else{let[d,p,h]=Vs.execute(u.tensor);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<(t.face.detector?.minConfidence||1))i.confidence=f;else{t.face.iris?.enabled&&(g=await zI(g,u.tensor,t,lr)),u.mesh=yI(g,i,l,c,lr),u.meshRaw=u.mesh.map(A=>[A[0]/(e.shape[2]||0),A[1]/(e.shape[1]||0),(A[2]||0)/lr]),i={...Jd(F0(u.mesh),1.5),confidence:i.confidence};for(let A of Object.keys(Nr))u.annotations[A]=Nr[A].map(y=>u.mesh[y]);t.face.detector?.rotation&&t.face.mesh.enabled&&t.face.description?.enabled&&xe.kernels.includes("rotatewithoffset")&&(Z(u.tensor),[l,c,u.tensor]=fx(i,e,lr)),u.box=dx(i,e),u.boxRaw=px(i,e),u.score=Math.round(100*f||100*i.confidence||0)/100,u.faceScore=Math.round(100*f)/100,i={...Qd(i),confidence:i.confidence,faceConfidence:f}}}else{u.box=dx(i,e),u.boxRaw=px(i,e),u.score=Math.round(100*i.confidence||0)/100,u.mesh=i.landmarks.map(d=>[(i.startPoint[0]+i.endPoint[0])/2+(i.endPoint[0]+i.startPoint[0])*d[0]/ep(),(i.startPoint[1]+i.endPoint[1])/2+(i.endPoint[1]+i.startPoint[1])*d[1]/ep()]),u.meshRaw=u.mesh.map(d=>[d[0]/(e.shape[2]||0),d[1]/(e.shape[1]||0),(d[2]||0)/lr]);for(let d of Object.keys(Kd))u.annotations[d]=[u.mesh[Kd[d]]]}r.push(u),a.push(i)}return t.face.mesh?.enabled&&(Rr=a.filter(i=>i.confidence>(t.face.detector?.minConfidence||0))),BI=r.length,r}async function VI(e){return xe.initial&&(Vs=null),Vs?e.debug&&ee("cached model:",Vs.modelUrl):(Vs=await Qe(tt(e.modelBasePath,e.face.mesh?.modelPath||"")),!Vs||!Vs.modelUrl?ee("load model failed:",e.face.mesh?.modelPath):e.debug&&ee("load model:",Vs.modelUrl)),lr=Vs.inputs[0].shape?Vs.inputs[0].shape[2]:0,lr===-1&&(lr=64),Vs}var UI=Ei,GI=Zd;var Us,L0=[],HI=0,jI=0,Px=Number.MAX_SAFE_INTEGER;async function qI(e){let t=tt(e.modelBasePath,e.face.description?.modelPath||"");return xe.initial&&(Us=null),Us?e.debug&&ee("cached model:",t):(Us=await Qe(t),Us?e.debug&&ee("load model:",t):ee("load model failed:",e.face.description?.modelPath||"")),Us}function Mx(e){return G(()=>{let n=e.image||e.tensor||e;if(!(n instanceof Ge))return null;let s=[[.05,.15,.85,.85]];if(!Us?.inputs[0].shape)return null;let r=n.shape.length===3?_e.cropAndResize(Lt(n,0),s,[0],[Us.inputs[0].shape[2],Us.inputs[0].shape[1]]):_e.cropAndResize(n,s,[0],[Us.inputs[0].shape[2],Us.inputs[0].shape[1]]);return L(r,255)})}async function zx(e,t,n,s){if(!Us)return null;let r=Px<(t.face.description?.skipFrames||0),a=(t.face.description?.skipTime||0)>pe()-HI;return t.skipAllowed&&r&&a&&jI===s&&L0[n]?.age&&L0[n]?.age>0?(Px++,L0[n]):(Px=0,new Promise(async o=>{let i={age:0,gender:"unknown",genderScore:0,descriptor:[]};if(t.face.description?.enabled){let l=Mx(e),c=await Us?.predict(l);HI=pe(),Z(l);let d=await(await c.find(x=>x.shape[1]===1)).data(),p=Math.trunc(200*Math.abs(d[0]-.5))/100;p>(t.face.description?.minConfidence||0)&&(i.gender=d[0]<=.5?"female":"male",i.genderScore=Math.min(.99,p));let h=xs(c.find(x=>x.shape[1]===100),1),f=(await h.data())[0];Z(h);let g=await c.find(x=>x.shape[1]===100).data();i.age=Math.round(g[f-1]>g[f+1]?10*f-100*g[f-1]:10*f+100*g[f+1])/10;let A=c.find(x=>x.shape[1]===1024),y=A?await A.data():[];i.descriptor=Array.from(y),c.forEach(x=>Z(x))}L0[n]=i,jI=s,o(i)}))}function B0(e){return[Math.abs(e.endPoint[0]-e.startPoint[0]),Math.abs(e.endPoint[1]-e.startPoint[1])]}function tp(e){return[e.startPoint[0]+(e.endPoint[0]-e.startPoint[0])/2,e.startPoint[1]+(e.endPoint[1]-e.startPoint[1])/2]}function XI(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 KI(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 W0(e,t=1.5){let n=tp(e),s=B0(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 V0(e){let t=tp(e),n=B0(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}}function lce(e){return e-2*Math.PI*Math.floor((e+Math.PI)/(2*Math.PI))}function ZI(e,t){let n=Math.PI/2-Math.atan2(-(t[1]-e[1]),t[0]-e[0]);return lce(n)}var YI=(e,t)=>[[1,0,e],[0,1,t],[0,0,1]];function La(e,t){let n=0;for(let s=0;s<e.length;s++)n+=e[s]*t[s];return n}function uce(e,t){let n=[];for(let s=0;s<e.length;s++)n.push(e[s][t]);return n}function JI(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(La(e[r],uce(t,a)))}return n}function Lx(e,t){let n=Math.cos(e),s=Math.sin(e),r=[[n,-s,0],[s,n,0],[0,0,1]],a=YI(t[0],t[1]),o=JI(a,r),i=YI(-t[0],-t[1]);return JI(o,i)}function QI(e){let t=[[e[0][0],e[1][0]],[e[0][1],e[1][1]]],n=[e[0][2],e[1][2]],s=[-La(t[0],n),-La(t[1],n)];return[t[0].concat(s[0]),t[1].concat(s[1]),[0,0,1]]}function Bx(e,t){return[La(e,t[0]),La(e,t[1])]}var eS=[{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 Wx=class{constructor(t){he(this,"model");he(this,"anchors");he(this,"anchorsTensor");he(this,"inputSize");he(this,"inputSizeTensor");he(this,"doubleInputSizeTensor");this.model=t,this.anchors=eS.map(n=>[n.x,n.y]),this.anchorsTensor=Ys(this.anchors),this.inputSize=this.model&&this.model.inputs&&this.model.inputs[0].shape?this.model.inputs[0].shape[2]:0,this.inputSizeTensor=Gt([this.inputSize,this.inputSize]),this.doubleInputSizeTensor=Gt([this.inputSize*2,this.inputSize*2])}normalizeBoxes(t){return G(()=>{let n=Fe(t,[0,0],[-1,2]),s=Fe(t,[0,2],[-1,2]),r=le(fe(n,this.inputSizeTensor),this.anchorsTensor),a=fe(s,this.doubleInputSizeTensor),o=L(be(r,a),this.inputSizeTensor),i=L(le(r,a),this.inputSizeTensor);return ru([o,i],1)})}normalizeLandmarks(t,n){return G(()=>{let s=le(fe(V(t,[-1,7,2]),this.inputSizeTensor),this.anchors[n]);return L(s,this.inputSizeTensor)})}async getBoxes(t,n){let s={};s.batched=this.model.predict(t),s.predictions=rt(s.batched),s.scores=G(()=>rt(Hn(Fe(s.predictions,[0,0],[-1,1]))));let r=await s.scores.data();s.boxes=Fe(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=Fe(s.norm,[i,0],[1,-1]),c=G(()=>V(this.normalizeLandmarks(Fe(s.predictions,[i,5],[1,14]),i),[-1,2]));o.push({box:l,palmLandmarks:c,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=G(()=>be(fe(_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 c=await l.box.data(),u=c.slice(0,2),d=c.slice(2,4),p=await l.palmLandmarks.array();Z(l.box),Z(l.palmLandmarks),i.push(KI({startPoint:u,endPoint:d,palmLandmarks:p,confidence:l.confidence},[r/this.inputSize,s/this.inputSize]))}return i}};var cce=5,tS=1.65,nS=[0,5,9,13,17,1,2],dce=0,pce=2,sS=0,Vx=class{constructor(t,n){he(this,"handDetector");he(this,"handPoseModel");he(this,"inputSize");he(this,"storedBoxes");he(this,"skipped");he(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=Number.MAX_SAFE_INTEGER,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=>Bx([...a,1],n)),r=this.calculateLandmarksBoundingBox(s);return W0(V0(r),cce)}getBoxForHandLandmarks(t){let n=this.calculateLandmarksBoundingBox(t),s=W0(V0(n),tS);s.palmLandmarks=[];for(let r=0;r<nS.length;r++)s.palmLandmarks.push(t[nS[r]].slice(0,2));return s}transformRawCoords(t,n,s,r){let a=B0(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=Lx(s,[0,0]),c=i.map(h=>[...Bx(h,l),h[2]]),u=QI(r),d=[...tp(n),1],p=[La(d,u[0]),La(d,u[1])];return c.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,a=(n.hand.skipTime||0)>pe()-sS,o=this.skipped<(n.hand.skipFrames||0);n.skipAllowed&&a&&o&&(r=await this.handDetector.estimateHandBounds(t,n),this.skipped=0),n.skipAllowed&&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 i=[];for(let l=0;l<this.storedBoxes.length;l++){let c=this.storedBoxes[l];if(!!c)if(n.hand.landmarks){let u=n.hand.rotation?ZI(c.palmLandmarks[dce],c.palmLandmarks[pce]):0,d=tp(c),p=[d[0]/t.shape[2],d[1]/t.shape[1]],h=n.hand.rotation&&xe.kernels.includes("rotatewithoffset")?_e.rotateWithOffset(t,u,0,p):t.clone(),f=Lx(-u,d),m=s?this.getBoxForPalmLandmarks(c.palmLandmarks,f):c,g=XI(m,h,[this.inputSize,this.inputSize]),A=fe(g,255);Z(g),Z(h);let[y,x]=await this.handPoseModel.predict(A);sS=pe(),Z(A);let b=(await y.data())[0];if(Z(y),b>=n.hand.minConfidence/4){let v=V(x,[-1,3]),S=await v.array();Z(x),Z(v);let T=this.transformRawCoords(S,m,u,f),_=this.getBoxForHandLandmarks(T);this.storedBoxes[l]={..._,confidence:b};let O={landmarks:T,confidence:b,boxConfidence:c.confidence,fingerConfidence:b,box:{topLeft:_.startPoint,bottomRight:_.endPoint}};i.push(O)}else this.storedBoxes[l]=null;Z(x)}else{let u=W0(V0(c),tS),d={confidence:c.confidence,boxConfidence:c.confidence,fingerConfidence:0,box:{topLeft:u.startPoint,bottomRight:u.endPoint},landmarks:[]};i.push(d)}}return this.storedBoxes=this.storedBoxes.filter(l=>l!==null),this.detectedHands=i.length,i.length>n.hand.maxDetected&&(i.length=n.hand.maxDetected),i}};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]},Jn={none:0,half:1,full:2,nameMapping:{0:"none",1:"half",2:"full"},getName:e=>Jn.nameMapping[e]},je={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=>je.nameMapping[e]},U0=class{constructor(t){he(this,"name");he(this,"curls");he(this,"directions");he(this,"weights");he(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 Ba=new U0("thumbs up");Ba.addCurl(qe.thumb,Jn.none,1);Ba.addDirection(qe.thumb,je.verticalUp,1);Ba.addDirection(qe.thumb,je.diagonalUpLeft,.25);Ba.addDirection(qe.thumb,je.diagonalUpRight,.25);for(let e of[qe.index,qe.middle,qe.ring,qe.pinky])Ba.addCurl(e,Jn.full,1),Ba.addDirection(e,je.horizontalLeft,1),Ba.addDirection(e,je.horizontalRight,1);var Xt=new U0("victory");Xt.addCurl(qe.thumb,Jn.half,.5);Xt.addCurl(qe.thumb,Jn.none,.5);Xt.addDirection(qe.thumb,je.verticalUp,1);Xt.addDirection(qe.thumb,je.diagonalUpLeft,1);Xt.addCurl(qe.index,Jn.none,1);Xt.addDirection(qe.index,je.verticalUp,.75);Xt.addDirection(qe.index,je.diagonalUpLeft,1);Xt.addCurl(qe.middle,Jn.none,1);Xt.addDirection(qe.middle,je.verticalUp,1);Xt.addDirection(qe.middle,je.diagonalUpLeft,.75);Xt.addCurl(qe.ring,Jn.full,1);Xt.addDirection(qe.ring,je.verticalUp,.2);Xt.addDirection(qe.ring,je.diagonalUpLeft,1);Xt.addDirection(qe.ring,je.horizontalLeft,.2);Xt.addCurl(qe.pinky,Jn.full,1);Xt.addDirection(qe.pinky,je.verticalUp,.2);Xt.addDirection(qe.pinky,je.diagonalUpLeft,1);Xt.addDirection(qe.pinky,je.horizontalLeft,.2);Xt.setWeight(qe.index,2);Xt.setWeight(qe.middle,2);var rS=[Ba,Xt];var hce=.7,_i={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 aS(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 oS(e,t){if(!e||!t)return[0,0];let n=aS(e[0],e[1],t[0],t[1]);if(e.length===2)return n;let s=aS(e[1],e[2],t[1],t[2]);return[n,s]}function iS(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 fce(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],c=e[2]-t[2],u=e[2]-n[2],d=t[2]-n[2],p=Math.sqrt(s*s+o*o+c*c),h=Math.sqrt(r*r+i*i+u*u),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>_i.NO_CURL_START_LIMIT?A=Jn.none:g>_i.HALF_CURL_START_LIMIT?A=Jn.half:A=Jn.full,A}function lS(e,t,n,s){let r;return s===Math.abs(e)?e>0?r=je.horizontalLeft:r=je.horizontalRight:s===Math.abs(t)?t>0?r=je.horizontalLeft:r=je.horizontalRight:n>0?r=je.horizontalLeft:r=je.horizontalRight,r}function uS(e,t,n,s){let r;return s===Math.abs(e)?e<0?r=je.verticalDown:r=je.verticalUp:s===Math.abs(t)?t<0?r=je.verticalDown:r=je.verticalUp:n<0?r=je.verticalDown:r=je.verticalUp,r}function mce(e,t,n,s,r,a,o,i){let l,c=uS(e,t,n,s),u=lS(r,a,o,i);return c===je.verticalUp?u===je.horizontalLeft?l=je.diagonalUpLeft:l=je.diagonalUpRight:u===je.horizontalLeft?l=je.diagonalDownLeft:l=je.diagonalDownRight,l}function gce(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],c=t[1]-n[1],u=Math.max(Math.abs(r),Math.abs(a),Math.abs(o)),d=Math.max(Math.abs(i),Math.abs(l),Math.abs(c)),p=0,h=0,f=0,m=d/(u+1e-5);m>1.5?p+=_i.DISTANCE_VOTE_POWER:m>.66?h+=_i.DISTANCE_VOTE_POWER:f+=_i.DISTANCE_VOTE_POWER;let g=Math.sqrt(r*r+i*i),A=Math.sqrt(a*a+l*l),y=Math.sqrt(o*o+c*c),x=Math.max(g,A,y),b=e[0],v=e[1],S=n[0],T=n[1];x===g?(S=n[0],T=n[1]):x===y&&(b=t[0],v=t[1]);let P=oS([b,v],[S,T]),D=iS(P,_i.TOTAL_ANGLE_VOTE_POWER);p+=D[0],h+=D[1],f+=D[2];for(let C of s){let M=iS(C,_i.SINGLE_ANGLE_VOTE_POWER);p+=M[0],h+=M[1],f+=M[2]}let F;return p===Math.max(p,h,f)?F=uS(l,i,c,d):f===Math.max(h,f)?F=lS(a,r,o,u):F=mce(l,i,c,d,a,r,o,u),F}function cS(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 c of o){let u=e[c[0]],d=e[c[1]],p=oS(u,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]],c=e[i[o+1][1]],u=e[i[3][1]],d=fce(l,c,u),p=gce(l,c,u,t[a].slice(o));s[a]=d,r[a]=p}return{curls:s,directions:r}}function G0(e){if(!e||e.length===0)return null;let t=cS(e),n={};for(let s of qe.all)n[qe.getName(s)]={curl:Jn.getName(t.curls[s]),direction:je.getName(t.directions[s])};return n}function dS(e){let t=[];if(!e||e.length===0)return t;let n=cS(e);for(let s of rS){let r=s.matchAgainst(n.curls,n.directions);r>=hce&&t.push({name:s.name,confidence:r})}return t}var pS={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]},qr,Xr,hS;async function Ux(e,t){let n=await hS.estimateHands(e,t);if(!n)return[];let s=[];for(let r=0;r<n.length;r++){let a={};if(n[r].landmarks)for(let u of Object.keys(pS))a[u]=pS[u].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 u of o)u[0]<i[0]&&(i[0]=u[0]),u[1]<i[1]&&(i[1]=u[1]),u[0]>i[2]&&(i[2]=u[0]),u[1]>i[3]&&(i[3]=u[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 c=G0(o);s.push({id:r,score:Math.round(100*n[r].confidence)/100,boxScore:Math.round(100*n[r].boxConfidence)/100,fingerScore:Math.round(100*n[r].fingerConfidence)/100,label:"hand",box:i,boxRaw:l,keypoints:o,annotations:a,landmarks:c})}return s}async function Gx(e){xe.initial&&(qr=null,Xr=null),!qr||!Xr?([qr,Xr]=await Promise.all([e.hand.enabled?Qe(tt(e.modelBasePath,e.hand.detector?.modelPath||""),{fromTFHub:(e.hand.detector?.modelPath||"").includes("tfhub.dev")}):null,e.hand.landmarks?Qe(tt(e.modelBasePath,e.hand.skeleton?.modelPath||""),{fromTFHub:(e.hand.skeleton?.modelPath||"").includes("tfhub.dev")}):null]),e.hand.enabled&&(!qr||!qr.modelUrl?ee("load model failed:",e.hand.detector?.modelPath||""):e.debug&&ee("load model:",qr.modelUrl),!Xr||!Xr.modelUrl?ee("load model failed:",e.hand.skeleton?.modelPath||""):e.debug&&ee("load model:",Xr.modelUrl))):(e.debug&&ee("cached model:",qr.modelUrl),e.debug&&ee("cached model:",Xr.modelUrl));let t=new Wx(qr);return hS=new Vx(t,Xr),[qr,Xr]}function Fi(e,t=[1,1]){let n=[e.map(i=>i[0]),e.map(i=>i[1])],s=[Math.min(...n[0]),Math.min(...n[1])],r=[Math.max(...n[0]),Math.max(...n[1])],a=[s[0],s[1],r[0]-s[0],r[1]-s[1]],o=[a[0]/t[0],a[1]/t[1],a[2]/t[0],a[3]/t[1]];return{box:a,boxRaw:o}}function fS(e,t=[1,1]){let n=[e.map(c=>c[0]),e.map(c=>c[1])],s=[Math.min(...n[0]),Math.min(...n[1])],r=[Math.max(...n[0]),Math.max(...n[1])],a=[(s[0]+r[0])/2,(s[1]+r[1])/2],o=Math.max(a[0]-s[0],a[1]-s[1],-a[0]+r[0],-a[1]+r[1]),i=[Math.trunc(a[0]-o),Math.trunc(a[1]-o),Math.trunc(2*o),Math.trunc(2*o)],l=[i[0]/t[0],i[1]/t[1],i[2]/t[0],i[3]/t[1]];return{box:i,boxRaw:l}}function H0(e,t){let n=[e[2]*t,e[3]*t];return[e[0]-(n[0]-e[2])/2,e[1]-(n[1]-e[3])/2,n[0],n[1]]}function Hx(e){return[Math.max(0,e[1]),Math.max(0,e[0]),Math.min(1,e[3]+e[1]),Math.min(1,e[2]+e[0])]}var wt=[null,null],Ace=["StatefulPartitionedCall/Postprocessor/Slice","StatefulPartitionedCall/Postprocessor/ExpandDims_1"],Wa=[[0,0],[0,0]],yce=["hand","fist","pinch","point","face","tip","pinchtip"],mS=4,gS=1.6,xce=512,bce=1.4,j0=Number.MAX_SAFE_INTEGER,jx=0,Kr=[0,0],Wt={boxes:[],hands:[]},AS={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]};async function yS(e){if(xe.initial&&(wt[0]=null),wt[0])e.debug&&ee("cached model:",wt[0].modelUrl);else{Gu(["tensorlistreserve","enter","tensorlistfromtensor","merge","loopcond","switch","exit","tensorliststack","nextiteration","tensorlistsetitem","tensorlistgetitem","reciprocal","shape","split","where"],e),wt[0]=await Qe(tt(e.modelBasePath,e.hand.detector?.modelPath||""));let t=Object.values(wt[0].modelSignature.inputs);Wa[0][0]=Array.isArray(t)?parseInt(t[0].tensorShape.dim[1].size):0,Wa[0][1]=Array.isArray(t)?parseInt(t[0].tensorShape.dim[2].size):0,!wt[0]||!wt[0].modelUrl?ee("load model failed:",e.hand.detector?.modelPath):e.debug&&ee("load model:",wt[0].modelUrl)}return wt[0]}async function xS(e){if(xe.initial&&(wt[1]=null),wt[1])e.debug&&ee("cached model:",wt[1].modelUrl);else{wt[1]=await Qe(tt(e.modelBasePath,e.hand.skeleton?.modelPath||""));let t=Object.values(wt[1].modelSignature.inputs);Wa[1][0]=Array.isArray(t)?parseInt(t[0].tensorShape.dim[1].size):0,Wa[1][1]=Array.isArray(t)?parseInt(t[0].tensorShape.dim[2].size):0,!wt[1]||!wt[1].modelUrl?ee("load model failed:",e.hand.skeleton?.modelPath):e.debug&&ee("load model:",wt[1].modelUrl)}return wt[1]}async function vce(e,t){let n=[];if(!e||!wt[0])return n;let s={},r=(e.shape[2]||1)/(e.shape[1]||1),a=Math.min(Math.round((e.shape[1]||0)/8)*8,xce),o=Math.round(a*r/8)*8;s.resize=_e.resizeBilinear(e,[a,o]),s.cast=de(s.resize,"int32"),[s.rawScores,s.rawBoxes]=await wt[0].executeAsync(s.cast,Ace),s.boxes=rt(s.rawBoxes,[0,2]),s.scores=rt(s.rawScores,[0]);let i=Dn(s.scores,1);Z(i[mS]),i.splice(mS,1),s.filtered=gn(i,1),Z(i),s.max=Rn(s.filtered,1),s.argmax=xs(s.filtered,1);let l=0;s.nms=await _e.nonMaxSuppressionAsync(s.boxes,s.max,t.hand.maxDetected,t.hand.iouThreshold,t.hand.minConfidence);let c=await s.nms.data(),u=await s.max.data(),d=await s.argmax.data();for(let p of Array.from(c)){let h=Fe(s.boxes,p,1),f=await h.data();Z(h);let m=[f[1],f[0],f[3]-f[1],f[2]-f[0]],g=H0(m,bce),A=Hx(g),y=[Math.trunc(m[0]*Kr[0]),Math.trunc(m[1]*Kr[1]),Math.trunc(m[2]*Kr[0]),Math.trunc(m[3]*Kr[1])],x=u[p],b=yce[d[p]],v={id:l++,score:x,box:y,boxRaw:g,boxCrop:A,label:b};n.push(v)}return Object.keys(s).forEach(p=>Z(s[p])),n.sort((p,h)=>h.score-p.score),n.length>(t.hand.maxDetected||1)&&(n.length=t.hand.maxDetected||1),n}async function qx(e,t,n){let s={id:t.id,score:Math.round(100*t.score)/100,boxScore:Math.round(100*t.score)/100,fingerScore:0,box:t.box,boxRaw:t.boxRaw,label:t.label,keypoints:[],landmarks:{},annotations:{}};if(e&&wt[1]&&n.hand.landmarks&&t.score>(n.hand.minConfidence||0)){let r={};r.crop=_e.cropAndResize(e,[t.boxCrop],[0],[Wa[1][0],Wa[1][1]],"bilinear"),r.cast=de(r.crop,"float32"),r.div=fe(r.cast,255),[r.score,r.keypoints]=wt[1].execute(r.div);let a=(await r.score.data())[0],o=(100-Math.trunc(100/(1+Math.exp(a))))/100;if(o>=(n.hand.minConfidence||0)){s.fingerScore=o,r.reshaped=V(r.keypoints,[-1,3]);let c=(await r.reshaped.array()).map(u=>[u[0]/Wa[1][1],u[1]/Wa[1][0],u[2]||0]).map(u=>[u[0]*t.boxRaw[2],u[1]*t.boxRaw[3],u[2]||0]);s.keypoints=c.map(u=>[Kr[0]*(u[0]+t.boxRaw[0]),Kr[1]*(u[1]+t.boxRaw[1]),u[2]||0]),s.landmarks=G0(s.keypoints);for(let u of Object.keys(AS))s.annotations[u]=AS[u].map(d=>s.landmarks&&s.keypoints[d]?s.keypoints[d]:null)}Object.keys(r).forEach(i=>Z(r[i]))}return s}async function Xx(e,t){if(!wt[0]||!wt[1]||!wt[0]?.inputs[0].shape||!wt[1]?.inputs[0].shape)return[];Kr=[e.shape[2]||0,e.shape[1]||0],j0++;let n=(t.hand.skipTime||0)>pe()-jx,s=j0<(t.hand.skipFrames||0);return t.skipAllowed&&n&&s?Wt.hands:new Promise(async r=>{let a=3*(t.hand.skipTime||0)>pe()-jx,o=j0<3*(t.hand.skipFrames||0);t.skipAllowed&&Wt.hands.length===t.hand.maxDetected?Wt.hands=await Promise.all(Wt.boxes.map(l=>qx(e,l,t))):t.skipAllowed&&a&&o&&Wt.hands.length>0?Wt.hands=await Promise.all(Wt.boxes.map(l=>qx(e,l,t))):(Wt.boxes=await vce(e,t),jx=pe(),Wt.hands=await Promise.all(Wt.boxes.map(l=>qx(e,l,t))),j0=0);let i=[...Wt.boxes];if(Wt.boxes.length=0,t.cacheSensitivity>0)for(let l=0;l<Wt.hands.length;l++){let c=fS(Wt.hands[l].keypoints,Kr);if(c.box[2]/(e.shape[2]||1)>.05&&c.box[3]/(e.shape[1]||1)>.05&&Wt.hands[l].fingerScore&&Wt.hands[l].fingerScore>(t.hand.minConfidence||0)){let u=H0(c.box,gS),d=H0(c.boxRaw,gS),p=Hx(d);Wt.boxes.push({...i[l],box:u,boxRaw:d,boxCrop:p})}}for(let l=0;l<Wt.hands.length;l++){let c=Fi(Wt.hands[l].keypoints,Kr);Wt.hands[l].box=c.box,Wt.hands[l].boxRaw=c.boxRaw}r(Wt.hands)})}var Jx={};lc(Jx,{connected:()=>X0,horizontal:()=>Kx,kpt:()=>q0,relative:()=>Yx,vertical:()=>Zx});var q0=["nose","leftEye","rightEye","leftEar","rightEar","leftShoulder","rightShoulder","leftElbow","rightElbow","leftWrist","rightWrist","leftHip","rightHip","leftKnee","rightKnee","leftAnkle","rightAnkle"],Kx=[["leftEye","rightEye"],["leftEar","rightEar"],["leftShoulder","rightShoulder"],["leftElbow","rightElbow"],["leftWrist","rightWrist"],["leftHip","rightHip"],["leftKnee","rightKnee"],["leftAnkle","rightAnkle"]],Zx=[["leftKnee","leftShoulder"],["rightKnee","rightShoulder"],["leftAnkle","leftKnee"],["rightAnkle","rightKnee"]],Yx=[[["leftHip","rightHip"],["leftShoulder","rightShoulder"]],[["leftElbow","rightElbow"],["leftShoulder","rightShoulder"]]],X0={leftLeg:["leftHip","leftKnee","leftAnkle"],rightLeg:["rightHip","rightKnee","rightAnkle"],torso:["leftShoulder","rightShoulder","rightHip","leftHip","leftShoulder"],leftArm:["leftShoulder","leftElbow","leftWrist"],rightArm:["rightShoulder","rightElbow","rightWrist"],head:[]};var bS=.005,fs={keypoints:[],padding:[[0,0],[0,0],[0,0],[0,0]]};function Qx(e){for(let t of Kx){let n=e.keypoints.findIndex(r=>r.part===t[0]),s=e.keypoints.findIndex(r=>r.part===t[1]);if(e.keypoints[n]&&e.keypoints[s]&&e.keypoints[n].position[0]<e.keypoints[s].position[0]){let r=e.keypoints[n];e.keypoints[n]=e.keypoints[s],e.keypoints[s]=r}}for(let t of Zx){let n=e.keypoints.findIndex(r=>r&&r.part===t[0]),s=e.keypoints.findIndex(r=>r&&r.part===t[1]);e.keypoints[n]&&e.keypoints[s]&&e.keypoints[n].position[1]<e.keypoints[s].position[1]&&e.keypoints.splice(n,1)}for(let[t,n]of Yx){let s=e.keypoints.findIndex(c=>c&&c.part===t[0]),r=e.keypoints.findIndex(c=>c&&c.part===t[1]),a=e.keypoints.findIndex(c=>c&&c.part===n[0]),o=e.keypoints.findIndex(c=>c&&c.part===n[1]);if(!e.keypoints[a]||!e.keypoints[o])continue;let i=e.keypoints[s]?[Math.abs(e.keypoints[a].position[0]-e.keypoints[s].position[0]),Math.abs(e.keypoints[o].position[0]-e.keypoints[s].position[0])]:[0,0],l=e.keypoints[r]?[Math.abs(e.keypoints[o].position[0]-e.keypoints[r].position[0]),Math.abs(e.keypoints[a].position[0]-e.keypoints[r].position[0])]:[0,0];if(i[0]>i[1]||l[0]>l[1]){let c=e.keypoints[s];e.keypoints[s]=e.keypoints[r],e.keypoints[r]=c}}}function vS(e){for(let t=0;t<e.length;t++)if(e[t]&&fs.keypoints[t]){let n=[Math.abs(e[t].positionRaw[0]-fs.keypoints[t].positionRaw[0]),Math.abs(e[t].positionRaw[1]-fs.keypoints[t].positionRaw[1])];n[0]<bS&&n[1]<bS?e[t]=fs.keypoints[t]:fs.keypoints[t]=e[t]}else fs.keypoints[t]=e[t];return e}function wS(e,t){let n={};if(!e.shape||!e.shape[1]||!e.shape[2])return e;fs.padding=[[0,0],[e.shape[2]>e.shape[1]?Math.trunc((e.shape[2]-e.shape[1])/2):0,e.shape[2]>e.shape[1]?Math.trunc((e.shape[2]-e.shape[1])/2):0],[e.shape[1]>e.shape[2]?Math.trunc((e.shape[1]-e.shape[2])/2):0,e.shape[1]>e.shape[2]?Math.trunc((e.shape[1]-e.shape[2])/2):0],[0,0]],n.pad=vs(e,fs.padding),n.resize=_e.resizeBilinear(n.pad,[t,t]);let s=de(n.resize,"int32");return Object.keys(n).forEach(r=>Z(n[r])),s}function kS(e,t){e.keypoints=e.keypoints.filter(s=>s&&s.position);for(let s of e.keypoints)s.position=[s.position[0]*(t[0]+fs.padding[2][0]+fs.padding[2][1])/t[0]-fs.padding[2][0],s.position[1]*(t[1]+fs.padding[1][0]+fs.padding[1][1])/t[1]-fs.padding[1][0]],s.positionRaw=[s.position[0]/t[0],s.position[1]/t[1]];let n=Fi(e.keypoints.map(s=>s.position),t);return e.box=n.box,e.boxRaw=n.boxRaw,e}var Ns,K0=0,e5=Number.MAX_SAFE_INTEGER,$i={boxes:[],bodies:[],last:0};async function IS(e){return xe.initial&&(Ns=null),Ns?e.debug&&ee("cached model:",Ns.modelUrl):(Gu(["size"],e),Ns=await Qe(tt(e.modelBasePath,e.body.modelPath||"")),!Ns||!Ns.modelUrl?ee("load model failed:",e.body.modelPath):e.debug&&ee("load model:",Ns.modelUrl)),K0=Ns.inputs[0].shape?Ns.inputs[0].shape[2]:0,K0===-1&&(K0=256),Ns}async function wce(e,t,n,s){let r=e[0][0],a=[],o=0;for(let d=0;d<r.length;d++)if(o=r[d][2],o>t.body.minConfidence){let p=[(s[3]-s[1])*r[d][1]+s[1],(s[2]-s[0])*r[d][0]+s[0]];a.push({score:Math.round(100*o)/100,part:q0[d],positionRaw:p,position:[Math.round((n.shape[2]||0)*p[0]),Math.round((n.shape[1]||0)*p[1])]})}o=a.reduce((d,p)=>p.score>d?p.score:d,0);let i=[],l=Fi(a.map(d=>d.position),[n.shape[2],n.shape[1]]),c={};for(let[d,p]of Object.entries(X0)){let h=[];for(let f=0;f<p.length-1;f++){let m=a.find(A=>A.part===p[f]),g=a.find(A=>A.part===p[f+1]);m&&g&&m.score>(t.body.minConfidence||0)&&g.score>(t.body.minConfidence||0)&&h.push([m.position,g.position])}c[d]=h}let u={id:0,score:o,box:l.box,boxRaw:l.boxRaw,keypoints:a,annotations:c};return Qx(u),i.push(u),i}async function kce(e,t,n,s){let r=[];for(let a=0;a<e[0].length;a++){let o=e[0][a],i=Math.round(100*o[51+4])/100;if(i>t.body.minConfidence){let l=[];for(let p=0;p<17;p++){let h=o[3*p+2];if(h>t.body.minConfidence){let f=[(s[3]-s[1])*o[3*p+1]+s[1],(s[2]-s[0])*o[3*p+0]+s[0]];l.push({part:q0[p],score:Math.round(100*h)/100,positionRaw:f,position:[Math.round((n.shape[2]||0)*f[0]),Math.round((n.shape[1]||0)*f[1])]})}}let c=Fi(l.map(p=>p.position),[n.shape[2],n.shape[1]]),u={};for(let[p,h]of Object.entries(X0)){let f=[];for(let m=0;m<h.length-1;m++){let g=l.find(y=>y.part===h[m]),A=l.find(y=>y.part===h[m+1]);g&&A&&g.score>(t.body.minConfidence||0)&&A.score>(t.body.minConfidence||0)&&f.push([g.position,A.position])}u[p]=f}let d={id:a,score:i,box:c.box,boxRaw:c.boxRaw,keypoints:[...l],annotations:u};Qx(d),r.push(d)}}return r.sort((a,o)=>o.score-a.score),r.length>t.body.maxDetected&&(r.length=t.body.maxDetected),r}async function t5(e,t){if(!Ns||!Ns?.inputs[0].shape)return[];t.skipAllowed||($i.boxes.length=0),e5++;let n=(t.body.skipTime||0)>pe()-$i.last,s=e5<(t.body.skipFrames||0);return t.skipAllowed&&n&&s?$i.bodies:new Promise(async r=>{let a={};e5=0,a.input=wS(e,K0),a.res=await Ns?.predict(a.input),$i.last=pe();let o=await a.res.array();$i.bodies=a.res.shape[2]===17?await wce(o,t,e,[0,0,1,1]):await kce(o,t,e,[0,0,1,1]);for(let i of $i.bodies)kS(i,[e.shape[2]||1,e.shape[1]||1]),vS(i.keypoints);Object.keys(a).forEach(i=>Z(a[i])),r($i.bodies)})}var ms,Z0=[],SS=0,n5=Number.MAX_SAFE_INTEGER,Y0=2.5;async function CS(e){if(!ms||xe.initial){ms=await Qe(tt(e.modelBasePath,e.object.modelPath||""));let t=Object.values(ms.modelSignature.inputs);if(ms.inputSize=Array.isArray(t)?parseInt(t[0].tensorShape.dim[2].size):null,!ms.inputSize)throw new Error(`cannot determine model inputSize: ${e.object.modelPath}`);!ms||!ms.modelUrl?ee("load model failed:",e.object.modelPath):e.debug&&ee("load model:",ms.modelUrl)}else e.debug&&ee("cached model:",ms.modelUrl);return ms}async function Ice(e,t,n,s){let r=0,a=[];for(let c of[1,2,4])G(async()=>{let u=c*13,d=e.find(g=>g.shape[1]===u**2&&g.shape[2]===Uu.length)?.squeeze(),p=e.find(g=>g.shape[1]===u**2&&g.shape[2]<Uu.length)?.squeeze(),f=await p.reshape([-1,4,p.shape[1]/4]).argMax(2).array(),m=await d.array();for(let g=0;g<d.shape[0];g++)for(let A=0;A<d.shape[1];A++){let y=m[g][A];if(y>s.object.minConfidence&&A!==61){let x=(.5+Math.trunc(g%u))/u,b=(.5+Math.trunc(g/u))/u,v=f[g].map(C=>C*(u/c/t)),[S,T]=[x-Y0/c*v[0],b-Y0/c*v[1]],[_,O]=[x+Y0/c*v[2]-S,b+Y0/c*v[3]-T],P=[S,T,_,O];P=P.map(C=>Math.max(0,Math.min(C,1)));let D=[P[0]*n[0],P[1]*n[1],P[2]*n[0],P[3]*n[1]],F={id:r++,score:Math.round(100*y)/100,class:A+1,label:Uu[A].label,box:D.map(C=>Math.trunc(C)),boxRaw:P};a.push(F)}}});e.forEach(c=>Z(c));let o=a.map(c=>[c.boxRaw[1],c.boxRaw[0],c.boxRaw[3],c.boxRaw[2]]),i=a.map(c=>c.score),l=[];if(o&&o.length>0){let c=await _e.nonMaxSuppressionAsync(o,i,s.object.maxDetected,s.object.iouThreshold,s.object.minConfidence);l=await c.data(),Z(c)}return a=a.filter((c,u)=>l.includes(u)).sort((c,u)=>u.score-c.score),a}async function s5(e,t){let n=(t.object.skipTime||0)>pe()-SS,s=n5<(t.object.skipFrames||0);return t.skipAllowed&&n&&s&&Z0.length>0?(n5++,Z0):(n5=0,!xe.kernels.includes("mod")||!xe.kernels.includes("sparsetodense")?Z0:new Promise(async r=>{let a=[e.shape[2],e.shape[1]],o=_e.resizeBilinear(e,[ms.inputSize,ms.inputSize],!1),i=fe(o,255),l=i.transpose([0,3,1,2]);Z(i),Z(o);let c;t.object.enabled&&(c=await ms.predict(l)),SS=pe(),Z(l);let u=await Ice(c,ms.inputSize,a,t);Z0=u,r(u)}))}var np=["nose","leftEye","rightEye","leftEar","rightEar","leftShoulder","rightShoulder","leftElbow","rightElbow","leftWrist","rightWrist","leftHip","rightHip","leftKnee","rightKnee","leftAnkle","rightAnkle"],Sce=np.length,sp=np.reduce((e,t,n)=>(e[t]=n,e),{}),Cce=[["leftHip","leftShoulder"],["leftElbow","leftShoulder"],["leftElbow","leftWrist"],["leftHip","leftKnee"],["leftKnee","leftAnkle"],["rightHip","rightShoulder"],["rightElbow","rightShoulder"],["rightElbow","rightWrist"],["rightHip","rightKnee"],["rightKnee","rightAnkle"],["leftShoulder","rightShoulder"],["leftHip","rightHip"]],ohe=Cce.map(([e,t])=>[sp[e],sp[t]]),TS=[["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 NS(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 ES(e,[t,n],[s,r]){let a=t/s,o=n/r,i=(c,u)=>({id:u,score:c.score,boxRaw:[c.box[0]/r,c.box[1]/s,c.box[2]/r,c.box[3]/s],box:[Math.trunc(c.box[0]*o),Math.trunc(c.box[1]*a),Math.trunc(c.box[2]*o),Math.trunc(c.box[3]*a)],keypoints:c.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((c,u)=>i(c,u))}var r5=class{constructor(t,n){he(this,"priorityQueue");he(this,"numberOfElements");he(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 a5(e,t,n,s){return{y:s.get(e,t,n),x:s.get(e,t,n+Sce)}}function o5(e,t,n){let{heatmapY:s,heatmapX:r,id:a}=e,{y:o,x:i}=a5(s,r,a,n);return{x:e.heatmapX*t+i,y:e.heatmapY*t+o}}function i5(e,t,n){return e<t?t:e>n?n:e}function RS(e,t,n,s){let r=n-e,a=s-t;return r*r+a*a}function l5(e,t){return{x:e.x+t.x,y:e.y+t.y}}var gs,Tce=["MobilenetV1/offset_2/BiasAdd","MobilenetV1/heatmap_2/BiasAdd","MobilenetV1/displacement_fwd_2/BiasAdd","MobilenetV1/displacement_bwd_2/BiasAdd"],J0=1,qu=16,Nce=50**2;function DS(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:i5(Math.round(A.y/qu),0,y-1),x:i5(Math.round(A.x/qu),0,x-1)}),[c,u]=s.shape,d=l(t.position,c,u),p=i(d),f=l5(t.position,p);for(let A=0;A<o;A++){let y=l(f,c,u),x=a5(y.y,y.x,n,r);f=l5({x:y.x*qu,y:y.y*qu},{x:x.x,y:x.y})}let m=l(f,c,u),g=s.get(m.y,m.x,n);return{position:f,part:np[n],score:g}}function Ece(e,t,n,s,r){let a=TS.map(([p,h])=>[sp[p],sp[h]]),o=a.map(([,p])=>p),i=a.map(([p])=>p),l=t.shape[2],c=o.length,u=new Array(l),d=o5(e.part,qu,n);u[e.part.id]={score:e.score,part:np[e.part.id],position:d};for(let p=c-1;p>=0;--p){let h=o[p],f=i[p];u[h]&&!u[f]&&(u[f]=DS(p,u[h],f,t,n,r))}for(let p=0;p<c;++p){let h=i[p],f=o[p];u[h]&&!u[f]&&(u[f]=DS(p,u[h],f,t,n,s))}return u}function Rce(e,t,n,s,r){let[a,o]=r.shape,i=!0,l=Math.max(n-J0,0),c=Math.min(n+J0+1,a);for(let u=l;u<c;++u){let d=Math.max(s-J0,0),p=Math.min(s+J0+1,o);for(let h=d;h<p;++h)if(r.get(u,h,e)>t){i=!1;break}if(!i)break}return i}function Dce(e,t){let[n,s,r]=t.shape,a=new r5(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 c=t.get(o,i,l);c<e||Rce(l,c,o,i,t)&&a.enqueue({score:c,part:{heatmapY:o,heatmapX:i,id:l}})}return a}function _S(e,{x:t,y:n},s){return e.some(({keypoints:r})=>{let a=r[s]?.position;return a?RS(n,t,a.y,a.x)<=Nce:!1})}function _ce(e,t){return t.reduce((s,{position:r,score:a},o)=>(_S(e,r,o)||(s+=a),s),0)/t.length}function Fce(e,t,n,s,r,a){let o=[],i=Dce(a,t);for(;o.length<r&&!i.empty();){let l=i.dequeue(),c=o5(l.part,qu,e);if(_S(o,c,l.part.id))continue;let u=Ece(l,t,e,n,s);u=u.filter(h=>h.score>a);let d=_ce(o,u),p=NS(u);d>a&&o.push({keypoints:u,box:p,score:Math.round(100*d)/100})}return o}async function u5(e,t){let n=G(()=>{if(!gs.inputs[0].shape)return[];let o=_e.resizeBilinear(e,[gs.inputs[0].shape[2],gs.inputs[0].shape[1]]),i=be(fe(de(o,"float32"),127.5),1),c=gs.execute(i,Tce).map(u=>rt(u,[0]));return c[1]=c[1].sigmoid(),c}),s=await Promise.all(n.map(o=>o.buffer()));for(let o of n)Z(o);let r=await Fce(s[0],s[1],s[2],s[3],t.body.maxDetected,t.body.minConfidence);return gs.inputs[0].shape?ES(r,[e.shape[1],e.shape[2]],[gs.inputs[0].shape[2],gs.inputs[0].shape[1]]):[]}async function FS(e){return!gs||xe.initial?(gs=await Qe(tt(e.modelBasePath,e.body.modelPath||"")),!gs||!gs.modelUrl?ee("load model failed:",e.body.modelPath):e.debug&&ee("load model:",gs.modelUrl)):e.debug&&ee("cached model:",gs.modelUrl),gs}var Es,c5=!1;async function d5(e){return!Es||xe.initial?(Es=await Qe(tt(e.modelBasePath,e.segmentation.modelPath||"")),!Es||!Es.modelUrl?ee("load model failed:",e.segmentation.modelPath):e.debug&&ee("load model:",Es.modelUrl)):e.debug&&ee("cached model:",Es.modelUrl),Es}async function $S(e,t,n){if(c5)return{data:[],canvas:null,alpha:null};c5=!0,Es||await d5(n);let s=Vu(e,n),r=s.canvas?.width||0,a=s.canvas?.height||0;if(!s.tensor)return{data:[],canvas:null,alpha:null};let o={};o.resize=_e.resizeBilinear(s.tensor,[Es.inputs[0].shape?Es.inputs[0].shape[1]:0,Es.inputs[0].shape?Es.inputs[0].shape[2]:0],!1),Z(s.tensor),o.norm=fe(o.resize,255),o.res=Es.predict(o.norm),o.squeeze=rt(o.res,0),o.squeeze.shape[2]===2?(o.softmax=li(o.squeeze),[o.bg,o.fg]=Dn(o.softmax,2),o.expand=Lt(o.fg,2),o.pad=Lt(o.expand,0),o.crop=_e.cropAndResize(o.pad,[[0,0,.5,.5]],[0],[r,a]),o.data=rt(o.crop,0)):o.data=_e.resizeBilinear(o.squeeze,[a,r]);let i=Array.from(await o.data.data());if(xe.node&&!xe.Canvas&&typeof ImageData=="undefined")return n.debug&&ee("canvas support missing"),Object.keys(o).forEach(m=>Z(o[m])),{data:i,canvas:null,alpha:null};let l=zn(r,a);await Os.toPixels(o.data,l);let c=l.getContext("2d");n.segmentation.blur&&n.segmentation.blur>0&&(c.filter=`blur(${n.segmentation.blur}px)`);let u=c.getImageData(0,0,r,a),d=zn(r,a),p=d.getContext("2d");s.canvas&&p.drawImage(s.canvas,0,0),p.globalCompositeOperation="darken",n.segmentation.blur&&n.segmentation.blur>0&&(p.filter=`blur(${n.segmentation.blur}px)`),p.drawImage(l,0,0),p.globalCompositeOperation="source-over",p.filter="none";let h=p.getImageData(0,0,r,a);for(let m=0;m<r*a;m++)h.data[4*m+3]=u.data[4*m+0];p.putImageData(h,0,0);let f=null;if(t&&d){f=zn(r,a);let m=Vu(t,n);Z(m.tensor);let g=f.getContext("2d");g.drawImage(m.canvas,0,0,f.width,f.height),g.drawImage(d,0,0)}return Object.keys(o).forEach(m=>Z(o[m])),c5=!1,{data:i,canvas:f||d,alpha:l}}var p5=class{constructor(){he(this,"age",null);he(this,"agegenderrace",null);he(this,"blazeposedetect",null);he(this,"blazepose",null);he(this,"centernet",null);he(this,"efficientpose",null);he(this,"embedding",null);he(this,"emotion",null);he(this,"facedetect",null);he(this,"faceiris",null);he(this,"facemesh",null);he(this,"faceres",null);he(this,"gender",null);he(this,"handpose",null);he(this,"handskeleton",null);he(this,"handtrack",null);he(this,"movenet",null);he(this,"nanodet",null);he(this,"posenet",null);he(this,"segmentation",null);he(this,"antispoof",null)}};function h5(e){for(let t of Object.keys(e.models))e.models[t]=null}async function OS(e){xe.initial&&h5(e),e.config.hand.enabled&&(!e.models.handpose&&e.config.hand.detector?.modelPath?.includes("handdetect")&&([e.models.handpose,e.models.handskeleton]=await Gx(e.config)),!e.models.handskeleton&&e.config.hand.landmarks&&e.config.hand.detector?.modelPath?.includes("handdetect")&&([e.models.handpose,e.models.handskeleton]=await Gx(e.config))),e.config.face.enabled&&!e.models.facedetect&&(e.models.facedetect=vI(e.config)),e.config.face.enabled&&e.config.face.mesh?.enabled&&!e.models.facemesh&&(e.models.facemesh=VI(e.config)),e.config.face.enabled&&e.config.face.iris?.enabled&&!e.models.faceiris&&(e.models.faceiris=$I(e.config)),e.config.face.enabled&&e.config.face.antispoof?.enabled&&!e.models.antispoof&&(e.models.antispoof=dI(e.config)),e.config.hand.enabled&&!e.models.handtrack&&e.config.hand.detector?.modelPath?.includes("handtrack")&&(e.models.handtrack=yS(e.config)),e.config.hand.enabled&&e.config.hand.landmarks&&!e.models.handskeleton&&e.config.hand.detector?.modelPath?.includes("handtrack")&&(e.models.handskeleton=xS(e.config)),e.config.body.enabled&&!e.models.posenet&&e.config.body?.modelPath?.includes("posenet")&&(e.models.posenet=FS(e.config)),e.config.body.enabled&&!e.models.efficientpose&&e.config.body?.modelPath?.includes("efficientpose")&&(e.models.efficientpose=Nx(e.config)),e.config.body.enabled&&!e.models.blazepose&&e.config.body?.modelPath?.includes("blazepose")&&(e.models.blazepose=CI(e.config)),e.config.body.enabled&&!e.models.blazeposedetect&&e.config.body.detector?.modelPath&&e.config.body?.modelPath?.includes("blazepose")&&(e.models.blazeposedetect=SI(e.config)),e.config.body.enabled&&!e.models.efficientpose&&e.config.body?.modelPath?.includes("efficientpose")&&(e.models.efficientpose=Nx(e.config)),e.config.body.enabled&&!e.models.movenet&&e.config.body?.modelPath?.includes("movenet")&&(e.models.movenet=IS(e.config)),e.config.object.enabled&&!e.models.nanodet&&e.config.object?.modelPath?.includes("nanodet")&&(e.models.nanodet=CS(e.config)),e.config.object.enabled&&!e.models.centernet&&e.config.object?.modelPath?.includes("centernet")&&(e.models.centernet=EI(e.config)),e.config.face.enabled&&e.config.face.emotion?.enabled&&!e.models.emotion&&(e.models.emotion=FI(e.config)),e.config.face.enabled&&e.config.face.description?.enabled&&!e.models.faceres&&(e.models.faceres=qI(e.config)),e.config.segmentation.enabled&&!e.models.segmentation&&(e.models.segmentation=d5(e.config)),e.config.face.enabled&&e.config.face.agegenderrace?.enabled&&!e.models.agegenderrace&&(e.models.agegenderrace=lI(e.config));for await(let t of Object.keys(e.models))e.models[t]&&typeof e.models[t]!="undefined"&&(e.models[t]=await e.models[t])}async function PS(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&&ee("model marked as loaded but not defined:",n);continue}let a=[],o=r?.executor;if(o&&o.graph.nodes)for(let l of Object.values(o.graph.nodes)){let c=l.op.toLowerCase();a.includes(c)||a.push(c)}else!o&&e.config.debug&&ee("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&&ee("model validation:",n,i)}}}var $t={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 $ce(){let e=$t.gl;!e||($t.extensions=e.getSupportedExtensions())}async function MS(e){if(e.config.backend==="humangl"&&($t.name in ts().registry&&(!$t.gl||!$t.gl.getParameter($t.gl.VERSION))&&(ee("error: humangl backend invalid context"),h5(e)),!mA($t.name))){try{$t.canvas=await zn(100,100)}catch(n){ee("error: cannot create canvas:",n);return}try{$t.gl=$t.canvas?.getContext("webgl2",$t.webGLattr),$t.canvas&&($t.canvas.addEventListener("webglcontextlost",async n=>{throw ee("error: humangl:",n.type),ee("possible browser memory leak using webgl or conflict with multiple backend registrations"),e.emit("error"),new Error("browser webgl error")}),$t.canvas.addEventListener("webglcontextrestored",n=>{ee("error: humangl context restored:",n)}),$t.canvas.addEventListener("webglcontextcreationerror",n=>{ee("error: humangl context create:",n)}))}catch(n){ee("error: cannot get WebGL context:",n);return}try{i0(2,$t.gl)}catch(n){ee("error: cannot set WebGL context:",n);return}try{let n=new g0($t.gl);tu($t.name,()=>new Ou(n),$t.priority)}catch(n){ee("error: cannot register WebGL backend:",n);return}try{Or("webgl").forEach(s=>{let r={...s,backendName:$t.name};pa(r)})}catch(n){ee("error: cannot update WebGL backend registration:",n);return}let t=gr().getGPGPUContext?gr().getGPGPUContext().gl:null;if(t)ee(`humangl webgl version:${t.getParameter(t.VERSION)} renderer:${t.getParameter(t.RENDERER)}`);else{ee("error: no current gl context:",t,$t.gl);return}try{hr.set("WEBGL_VERSION",2)}catch(n){ee("error: cannot set WebGL backend flags:",n);return}$ce(),ee("backend registered:",$t.name)}}async function Q0(e,t=!1){if(e.state="backend",t||xe.initial||e.config.backend&&e.config.backend.length>0&&Ks()!==e.config.backend){let n=pe();if(e.config.backend&&e.config.backend.length>0){if(typeof window=="undefined"&&typeof WorkerGlobalScope!="undefined"&&e.config.debug&&e.config.debug&&ee("running inside web worker"),xe.browser&&e.config.backend==="tensorflow"&&(e.config.debug&&ee("override: backend set to tensorflow while running in browser"),e.config.backend="humangl"),xe.node&&(e.config.backend==="webgl"||e.config.backend==="humangl")&&(e.config.debug&&ee(`override: backend set to ${e.config.backend} while running in nodejs`),e.config.backend="tensorflow"),xe.browser&&e.config.backend==="webgpu")if(typeof navigator=="undefined"||typeof navigator.gpu=="undefined")ee("override: backend set to webgpu but browser does not support webgpu"),e.config.backend="humangl";else{let r=await navigator.gpu.requestAdapter();e.config.debug&&ee("enumerated webgpu adapter:",r)}e.config.backend==="humangl"&&await MS(e);let s=Object.keys(ts().registryFactory);if(e.config.debug&&ee("available backends:",s),s.includes(e.config.backend)||(ee(`error: backend ${e.config.backend} not found in registry`),e.config.backend=xe.node?"tensorflow":"webgl",e.config.debug&&ee(`override: setting backend ${e.config.backend}`)),e.config.debug&&ee("setting backend:",e.config.backend),e.config.backend==="wasm"){if(e.config.debug&&ee("wasm path:",e.config.wasmPath),typeof Xd?.setWasmPaths!="undefined")await Z8(e.config.wasmPath);else throw new Error("wasm backend is not loaded");let r=await Y().getAsync("WASM_HAS_SIMD_SUPPORT"),a=await Y().getAsync("WASM_HAS_MULTITHREAD_SUPPORT");e.config.debug&&ee(`wasm execution: ${r?"SIMD":"no SIMD"} ${a?"multithreaded":"singlethreaded"}`),e.config.debug&&!r&&ee("warning: wasm simd support is not enabled")}try{await n3(e.config.backend),await Fh()}catch(r){return ee("error: cannot set backend:",e.config.backend,r),!1}}if(Ks()==="humangl"&&(hr.set("CHECK_COMPUTATION_FOR_ERRORS",!1),hr.set("WEBGL_CPU_FORWARD",!0),hr.set("WEBGL_USE_SHAPES_UNIFORMS",!0),hr.set("CPU_HANDOFF_SIZE_THRESHOLD",256),typeof e.config.deallocate!="undefined"&&e.config.deallocate&&(ee("changing webgl: WEBGL_DELETE_TEXTURE_THRESHOLD:",!0),hr.set("WEBGL_DELETE_TEXTURE_THRESHOLD",0)),gr().getGPGPUContext)){let s=await gr().getGPGPUContext().gl;e.config.debug&&ee(`gl version:${s.getParameter(s.VERSION)} renderer:${s.getParameter(s.RENDERER)}`)}Ks()==="webgpu",t3(),await Fh(),e.performance.initBackend=Math.trunc(pe()-n),e.config.backend=Ks(),xe.updateBackend()}return!0}function Gu(e,t){for(let n of e){let s={kernelName:n,backendName:t.backend,kernelFunc:()=>{t.debug&&ee("kernelFunc",n,t.backend)}};pa(s)}xe.kernels=Or(Ks()).map(n=>n.kernelName.toLowerCase())}var Zr={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,drawGestures:!0,drawPolygons:!0,drawGaze:!0,fillPolygons:!1,useDepth:!0,useCurves:!1},f5=0,Oi=e=>{if(e&&e.getContext)return e.getContext("2d");throw new Error("invalid canvas")},Xu=e=>Math.round(e*180/Math.PI);function m5(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 rp(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 zS(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 Oce(e,t=[],n){if(!(t===void 0||t.length===0)){if(!n.useCurves||t.length<=2){zS(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())}}function LS(e,t,n,s=5){let r,a,o;e.beginPath(),e.moveTo(t[0],t[1]),e.lineTo(n[0],n[1]),r=Math.atan2(n[1]-t[1],n[0]-t[0]),a=s*Math.cos(r)+n[0],o=s*Math.sin(r)+n[1],e.moveTo(a,o),r+=1/3*(2*Math.PI),a=s*Math.cos(r)+n[0],o=s*Math.sin(r)+n[1],e.lineTo(a,o),r+=1/3*(2*Math.PI),a=s*Math.cos(r)+n[0],o=s*Math.sin(r)+n[1],e.lineTo(a,o),e.closePath(),e.stroke(),e.fill()}async function g5(e,t,n){let s=wn(Zr,n);if(!(!t||!e)&&s.drawGestures){let r=Oi(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 c=i[1]>0?`#${i[1]}`:"",u=`${i[0]} ${c}: ${l[1]}`;s.shadowColor&&s.shadowColor!==""&&(r.fillStyle=s.shadowColor,r.fillText(u,8,2+a*s.lineHeight)),r.fillStyle=s.labelColor,r.fillText(u,6,0+a*s.lineHeight),a+=1}}}}async function A5(e,t,n){let s=wn(Zr,n);if(!t||!e)return;let r=Oi(e);for(let a of t){if(r.font=s.font,r.strokeStyle=s.color,r.fillStyle=s.color,s.drawBoxes&&rp(r,a.box[0],a.box[1],a.box[2],a.box[3],s),s.drawLabels){let o=[];if(o.push(`face: ${Math.trunc(100*a.score)}%`),a.genderScore&&o.push(`${a.gender||""} ${Math.trunc(100*a.genderScore)}%`),a.age&&o.push(`age: ${a.age||""}`),a.iris&&o.push(`distance: ${a.iris}`),a.real&&o.push(`real: ${Math.trunc(100*a.real)}%`),a.emotion&&a.emotion.length>0){let i=a.emotion.map(l=>`${Math.trunc(100*l.score)}% ${l.emotion}`);i.length>3&&(i.length=3),o.push(i.join(" "))}a.rotation&&a.rotation.angle&&a.rotation.gaze&&(a.rotation.angle.roll&&o.push(`roll: ${Xu(a.rotation.angle.roll)}\xB0 yaw:${Xu(a.rotation.angle.yaw)}\xB0 pitch:${Xu(a.rotation.angle.pitch)}\xB0`),a.rotation.gaze.bearing&&o.push(`gaze: ${Xu(a.rotation.gaze.bearing)}\xB0`)),o.length===0&&o.push("face"),r.fillStyle=s.color;for(let i=o.length-1;i>=0;i--){let l=Math.max(a.box[0],0),c=i*s.lineHeight+a.box[1];s.shadowColor&&s.shadowColor!==""&&(r.fillStyle=s.shadowColor,r.fillText(o[i],l+5,c+16)),r.fillStyle=s.labelColor,r.fillText(o[i],l+4,c+15)}}if(r.lineWidth=1,a.mesh&&a.mesh.length>0){if(s.drawPoints)for(let o of a.mesh)m5(r,o[0],o[1],o[2],s);if(s.drawPolygons){if(r.lineWidth=1,a.mesh.length>450)for(let o=0;o<Ei.length/3;o++){let i=[Ei[o*3+0],Ei[o*3+1],Ei[o*3+2]].map(l=>a.mesh[l]);zS(r,i,s)}if(a.annotations&&a.annotations.leftEyeIris&&a.annotations.leftEyeIris[0]){r.strokeStyle=s.useDepth?"rgba(255, 200, 255, 0.3)":s.color,r.beginPath();let o=Math.abs(a.annotations.leftEyeIris[3][0]-a.annotations.leftEyeIris[1][0])/2,i=Math.abs(a.annotations.leftEyeIris[4][1]-a.annotations.leftEyeIris[2][1])/2;r.ellipse(a.annotations.leftEyeIris[0][0],a.annotations.leftEyeIris[0][1],o,i,0,0,2*Math.PI),r.stroke(),s.fillPolygons&&(r.fillStyle=s.useDepth?"rgba(255, 255, 200, 0.3)":s.color,r.fill())}if(a.annotations&&a.annotations.rightEyeIris&&a.annotations.rightEyeIris[0]){r.strokeStyle=s.useDepth?"rgba(255, 200, 255, 0.3)":s.color,r.beginPath();let o=Math.abs(a.annotations.rightEyeIris[3][0]-a.annotations.rightEyeIris[1][0])/2,i=Math.abs(a.annotations.rightEyeIris[4][1]-a.annotations.rightEyeIris[2][1])/2;r.ellipse(a.annotations.rightEyeIris[0][0],a.annotations.rightEyeIris[0][1],o,i,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&&a.rotation?.angle){r.strokeStyle="pink";let o=a.box[0]+a.box[2]/2-a.box[3]*Xu(a.rotation.angle.yaw)/90,i=a.box[1]+a.box[3]/2+a.box[2]*Xu(a.rotation.angle.pitch)/90,l=new Path2D(`
|
|
M ${a.box[0]+a.box[2]/2} ${a.box[1]}
|
|
C
|
|
${o} ${a.box[1]},
|
|
${o} ${a.box[1]+a.box[3]},
|
|
${a.box[0]+a.box[2]/2} ${a.box[1]+a.box[3]}
|
|
`),c=new Path2D(`
|
|
M ${a.box[0]} ${a.box[1]+a.box[3]/2}
|
|
C
|
|
${a.box[0]} ${i},
|
|
${a.box[0]+a.box[2]} ${i},
|
|
${a.box[0]+a.box[2]} ${a.box[1]+a.box[3]/2}
|
|
`);r.stroke(c),r.stroke(l)}if(s.drawGaze&&a.rotation?.gaze?.strength&&a.rotation?.gaze?.bearing&&a.annotations.leftEyeIris&&a.annotations.rightEyeIris&&a.annotations.leftEyeIris[0]&&a.annotations.rightEyeIris[0]){r.strokeStyle="pink",r.fillStyle="pink";let o=[a.annotations.leftEyeIris[0][0]+Math.sin(a.rotation.gaze.bearing)*a.rotation.gaze.strength*a.box[3],a.annotations.leftEyeIris[0][1]+Math.cos(a.rotation.gaze.bearing)*a.rotation.gaze.strength*a.box[2]];LS(r,[a.annotations.leftEyeIris[0][0],a.annotations.leftEyeIris[0][1]],[o[0],o[1]],4);let i=[a.annotations.rightEyeIris[0][0]+Math.sin(a.rotation.gaze.bearing)*a.rotation.gaze.strength*a.box[3],a.annotations.rightEyeIris[0][1]+Math.cos(a.rotation.gaze.bearing)*a.rotation.gaze.strength*a.box[2]];LS(r,[a.annotations.rightEyeIris[0][0],a.annotations.rightEyeIris[0][1]],[i[0],i[1]],4)}}}}}async function y5(e,t,n){let s=wn(Zr,n);if(!t||!e)return;let r=Oi(e);r.lineJoin="round";for(let a=0;a<t.length;a++){if(r.strokeStyle=s.color,r.fillStyle=s.color,r.lineWidth=s.lineWidth,r.font=s.font,s.drawBoxes&&t[a].box&&t[a].box?.length===4&&(rp(r,t[a].box[0],t[a].box[1],t[a].box[2],t[a].box[3],s),s.drawLabels&&(s.shadowColor&&s.shadowColor!==""&&(r.fillStyle=s.shadowColor,r.fillText(`body ${100*t[a].score}%`,t[a].box[0]+3,1+t[a].box[1]+s.lineHeight,t[a].box[2])),r.fillStyle=s.labelColor,r.fillText(`body ${100*t[a].score}%`,t[a].box[0]+2,0+t[a].box[1]+s.lineHeight,t[a].box[2]))),s.drawPoints&&t[a].keypoints)for(let o=0;o<t[a].keypoints.length;o++)r.fillStyle=s.useDepth&&t[a].keypoints[o].position[2]?`rgba(${127.5+2*(t[a].keypoints[o].position[2]||0)}, ${127.5-2*(t[a].keypoints[o].position[2]||0)}, 255, 0.5)`:s.color,m5(r,t[a].keypoints[o].position[0],t[a].keypoints[o].position[1],0,s);if(s.drawLabels&&t[a].keypoints){r.font=s.font;for(let o of t[a].keypoints)r.fillStyle=s.useDepth&&o.position[2]?`rgba(${127.5+2*o.position[2]}, ${127.5-2*o.position[2]}, 255, 0.5)`:s.color,r.fillText(`${o.part} ${Math.trunc(100*o.score)}%`,o.position[0]+4,o.position[1]+4)}if(s.drawPolygons&&t[a].keypoints&&t[a].annotations)for(let o of Object.values(t[a].annotations))for(let i of o)Oce(r,i,s)}}async function x5(e,t,n){let s=wn(Zr,n);if(!t||!e)return;let r=Oi(e);r.lineJoin="round",r.font=s.font;for(let a of t){if(s.drawBoxes&&(r.strokeStyle=s.color,r.fillStyle=s.color,rp(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:${Math.trunc(100*a.score)}%`,a.box[0]+3,1+a.box[1]+s.lineHeight,a.box[2])),r.fillStyle=s.labelColor,r.fillText(`hand:${Math.trunc(100*a.score)}%`,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]||0)}, ${127.5-2*(o[2]||0)}, 255, 0.5)`:s.color,m5(r,o[0],o[1],0,s);if(s.drawLabels&&a.annotations){let o=(i,l)=>{!i||i.length===0||!i[0]||(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&&a.annotations){let o=i=>{if(!(!i||i.length===0||!i[0]))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 b5(e,t,n){let s=wn(Zr,n);if(!t||!e)return;let r=Oi(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,rp(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 BS(e,t,n){let s=wn(Zr,n);if(!t||!e)return;let r=Oi(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,rp(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 WS(e,t){if(!e||!t)return;Oi(t).drawImage(e,0,0)}async function VS(e,t,n){if(!t||!t.performance||!t||!e)return null;let s=pe(),r=wn(Zr,n),a=Promise.all([A5(e,t.face,r),y5(e,t.body,r),x5(e,t.hand,r),b5(e,t.object,r),g5(e,t.gesture,r)]);return f5=xe.perfadd?f5+Math.round(pe()-s):Math.round(pe()-s),t.performance.draw=f5,a}var Pce=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]],c=Math.sqrt(l[0]**2+l[1]**2);return c=Math.min(c,e.boxRaw[2]/2,e.boxRaw[3]/2),{bearing:(t([0,0],l)+Math.PI/2)%Math.PI,strength:c}},US=(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,S,T,_,O]=g,P,D,F;return b<1?b>-1?(F=Math.asin(b),D=Math.atan2(-T,A),P=Math.atan2(-S,v)):(F=-Math.PI/2,D=-Math.atan2(_,O),P=0):(F=Math.PI/2,D=Math.atan2(_,O),P=0),isNaN(P)&&(P=0),isNaN(D)&&(D=0),isNaN(F)&&(F=0),{pitch:2*-P,yaw:2*-D,roll:2*-F}},o=g=>{let A=(x,b,v,S)=>Math.atan2(S-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,c=[i[10],i[152],i[234],i[454]].map(g=>[g[0]*t[0]/l,g[1]*t[1]/l,g[2]]),u=n(s(c[1],c[0])),d=n(s(c[3],c[2])),p=n(r(d,u));d=r(u,p);let h=[d[0],d[1],d[2],u[0],u[1],u[2],p[0],p[1],p[2]],f=a(h),m=i.length===478?Pce(e):{bearing:0,strength:0};return{angle:f,matrix:h,gaze:m}};var v5=async(e,t)=>{let n,s,r,a,o,i,l,c,u=[];e.state="run:face",n=pe();let d=await WI(t,e.config);if(e.performance.face=xe.perfadd?(e.performance.face||0)+Math.trunc(pe()-n):Math.trunc(pe()-n),!t.shape||t.shape.length!==4)return[];if(!d)return[];for(let p=0;p<d.length;p++){if(e.analyze("Get Face"),!d[p].tensor||d[p].tensor.isDisposedInternal){ee("Face object is disposed:",d[p].tensor);continue}let h=US(d[p],[t.shape[2],t.shape[1]]);e.analyze("Start Emotion:"),e.config.async?o=e.config.face.emotion.enabled?_x(d[p].tensor||zt([]),e.config,p,d.length):null:(e.state="run:emotion",n=pe(),o=e.config.face.emotion.enabled?await _x(d[p].tensor||zt([]),e.config,p,d.length):null,e.performance.emotion=xe.perfadd?(e.performance.emotion||0)+Math.trunc(pe()-n):Math.trunc(pe()-n)),e.analyze("End Emotion:"),e.analyze("Start AntiSpoof:"),e.config.async?l=e.config.face.antispoof.enabled?lx(d[p].tensor||zt([]),e.config,p,d.length):null:(e.state="run:antispoof",n=pe(),l=e.config.face.antispoof.enabled?await lx(d[p].tensor||zt([]),e.config,p,d.length):null,e.performance.antispoof=xe.perfadd?(e.performance.antispoof||0)+Math.trunc(pe()-n):Math.trunc(pe()-n)),e.analyze("End AntiSpoof:"),e.analyze("Start Description:"),e.config.async?c=e.config.face.description.enabled?zx(d[p].tensor||zt([]),e.config,p,d.length):null:(e.state="run:description",n=pe(),c=e.config.face.description.enabled?await zx(d[p].tensor||zt([]),e.config,p,d.length):null,e.performance.description=xe.perfadd?(e.performance.description||0)+Math.trunc(pe()-n):Math.trunc(pe()-n)),e.analyze("End Description:"),e.config.async&&([s,a,o,i,c,r,l]=await Promise.all([s,a,o,i,c,r,l])),e.analyze("Finish Face:"),!e.config.face.iris.enabled&&d[p]?.annotations?.leftEyeIris&&d[p]?.annotations?.rightEyeIris&&(delete d[p].annotations.leftEyeIris,delete d[p].annotations.rightEyeIris);let f=d[p].annotations&&d[p].annotations.leftEyeIris&&d[p].annotations.leftEyeIris[0]&&d[p].annotations.rightEyeIris&&d[p].annotations.rightEyeIris[0]&&d[p].annotations.leftEyeIris.length>0&&d[p].annotations.rightEyeIris.length>0&&d[p].annotations.leftEyeIris[0]!==null&&d[p].annotations.rightEyeIris[0]!==null?Math.max(Math.abs(d[p].annotations.leftEyeIris[3][0]-d[p].annotations.leftEyeIris[1][0]),Math.abs(d[p].annotations.rightEyeIris[4][1]-d[p].annotations.rightEyeIris[2][1]))/t.shape[2]:0,m=e.config.face.detector.return?rt(d[p].tensor):null;Z(d[p].tensor),d[p].tensor&&delete d[p].tensor,u.push({...d[p],id:p,age:c?.age,gender:c?.gender,genderScore:c?.genderScore,embedding:c?.descriptor,emotion:o,real:l,iris:f!==0?Math.trunc(500/f/11.7)/100:0,rotation:h,tensor:m}),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 GS=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[1]<a.position[1]&&r.position[1]<a.position[1]?t.push({body:n,gesture:"i give up"}):a&&s&&s.position[1]<a.position[1]?t.push({body:n,gesture:"raise left hand"}):a&&r&&r.position[1]<a.position[1]&&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[1]>i.position[1]?"left":"right"}`})}return t},HS=e=>{if(!e)return[];let t=[];for(let n=0;n<e.length;n++)if(e[n].mesh&&e[n].mesh.length>450){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},jS=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.leftEyeIris[0]||!e[n].annotations.rightEyeIris||!e[n].annotations.rightEyeIris[0])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),c=!1;Math.abs(a-l)/Math.max(a,l)<.25&&(c=!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)&&(c=!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)&&(c=!1),(f<.01||h<.01)&&t.push({iris:n,gesture:"looking down"}),(f>.022||h>.022)&&t.push({iris:n,gesture:"looking up"}),c&&t.push({iris:n,gesture:"looking center"})}return t},qS=e=>{if(!e)return[];let t=[];for(let n=0;n<e.length;n++){let s=[];if(e[n].annotations)for(let[r,a]of Object.entries(e[n].annotations))r!=="palmBase"&&Array.isArray(a)&&a[0]&&s.push({name:r.toLowerCase(),position:a[0]});if(s&&s.length>0){let r=s.reduce((o,i)=>o.position[2]<i.position[2]?o:i);t.push({hand:n,gesture:`${r.name} forward`});let a=s.reduce((o,i)=>o.position[1]<i.position[1]?o:i);t.push({hand:n,gesture:`${a.name} up`})}if(e[n].keypoints){let r=dS(e[n].keypoints);for(let a of r)t.push({hand:n,gesture:a.name})}}return t};var Oe={face:[],body:[],hand:[],gesture:[],object:[],persons:[],performance:{},timestamp:0},w5=0;function XS(e,t){let n=pe();if(!e)return{face:[],body:[],hand:[],gesture:[],object:[],persons:[],performance:{},timestamp:0};let s=Date.now()-e.timestamp,r=s<1e3?8-Math.log(s+1):1;if(Oe.canvas=e.canvas,!Oe.body||e.body.length!==Oe.body.length)Oe.body=JSON.parse(JSON.stringify(e.body));else for(let o=0;o<e.body.length;o++){let i=e.body[o].box.map((p,h)=>((r-1)*Oe.body[o].box[h]+p)/r),l=e.body[o].boxRaw.map((p,h)=>((r-1)*Oe.body[o].boxRaw[h]+p)/r),c=e.body[o].keypoints.map((p,h)=>({score:p.score,part:p.part,position:[Oe.body[o].keypoints[h]?((r-1)*Oe.body[o].keypoints[h].position[0]+p.position[0])/r:p.position[0],Oe.body[o].keypoints[h]?((r-1)*Oe.body[o].keypoints[h].position[1]+p.position[1])/r:p.position[1]],positionRaw:[Oe.body[o].keypoints[h]?((r-1)*Oe.body[o].keypoints[h].positionRaw[0]+p.positionRaw[0])/r:p.position[0],Oe.body[o].keypoints[h]?((r-1)*Oe.body[o].keypoints[h].positionRaw[1]+p.positionRaw[1])/r:p.position[1]]})),u={},d={connected:{}};t.body?.modelPath?.includes("efficientpose")?d=Cx:t.body?.modelPath?.includes("blazepose")?d=yx:t.body?.modelPath?.includes("movenet")&&(d=Jx);for(let[p,h]of Object.entries(d.connected)){let f=[];for(let m=0;m<h.length-1;m++){let g=c.find(y=>y.part===h[m]),A=c.find(y=>y.part===h[m+1]);g&&A&&g.score>(t.body.minConfidence||0)&&A.score>(t.body.minConfidence||0)&&f.push([g.position,A.position])}u[p]=f}Oe.body[o]={...e.body[o],box:i,boxRaw:l,keypoints:c,annotations:u}}if(!Oe.hand||e.hand.length!==Oe.hand.length)Oe.hand=JSON.parse(JSON.stringify(e.hand));else for(let o=0;o<e.hand.length;o++){let i=e.hand[o].box.map((d,p)=>((r-1)*Oe.hand[o].box[p]+d)/r),l=e.hand[o].boxRaw.map((d,p)=>((r-1)*Oe.hand[o].boxRaw[p]+d)/r);Oe.hand[o].keypoints.length!==e.hand[o].keypoints.length&&(Oe.hand[o].keypoints=e.hand[o].keypoints);let c=e.hand[o].keypoints&&e.hand[o].keypoints.length>0?e.hand[o].keypoints.map((d,p)=>d.map((h,f)=>((r-1)*(Oe.hand[o].keypoints[p][f]||1)+(h||0))/r)):[],u={};if(Object.keys(Oe.hand[o].annotations).length!==Object.keys(e.hand[o].annotations).length)Oe.hand[o].annotations=e.hand[o].annotations,u=Oe.hand[o].annotations;else if(e.hand[o].annotations)for(let d of Object.keys(e.hand[o].annotations))u[d]=e.hand[o].annotations[d]&&e.hand[o].annotations[d][0]?e.hand[o].annotations[d].map((p,h)=>p.map((f,m)=>((r-1)*Oe.hand[o].annotations[d][h][m]+f)/r)):null;Oe.hand[o]={...e.hand[o],box:i,boxRaw:l,keypoints:c,annotations:u}}if(!Oe.face||e.face.length!==Oe.face.length)Oe.face=JSON.parse(JSON.stringify(e.face));else for(let o=0;o<e.face.length;o++){let i=e.face[o].box.map((u,d)=>((r-1)*Oe.face[o].box[d]+u)/r),l=e.face[o].boxRaw.map((u,d)=>((r-1)*Oe.face[o].boxRaw[d]+u)/r),c={matrix:[0,0,0,0,0,0,0,0,0],angle:{roll:0,yaw:0,pitch:0},gaze:{bearing:0,strength:0}};c.matrix=e.face[o].rotation?.matrix,c.angle={roll:((r-1)*(Oe.face[o].rotation?.angle?.roll||0)+(e.face[o].rotation?.angle?.roll||0))/r,yaw:((r-1)*(Oe.face[o].rotation?.angle?.yaw||0)+(e.face[o].rotation?.angle?.yaw||0))/r,pitch:((r-1)*(Oe.face[o].rotation?.angle?.pitch||0)+(e.face[o].rotation?.angle?.pitch||0))/r},c.gaze={bearing:((r-1)*(Oe.face[o].rotation?.gaze?.bearing||0)+(e.face[o].rotation?.gaze?.bearing||0))/r,strength:((r-1)*(Oe.face[o].rotation?.gaze?.strength||0)+(e.face[o].rotation?.gaze?.strength||0))/r},Oe.face[o]={...e.face[o],rotation:c,box:i,boxRaw:l}}if(!Oe.object||e.object.length!==Oe.object.length)Oe.object=JSON.parse(JSON.stringify(e.object));else for(let o=0;o<e.object.length;o++){let i=e.object[o].box.map((c,u)=>((r-1)*Oe.object[o].box[u]+c)/r),l=e.object[o].boxRaw.map((c,u)=>((r-1)*Oe.object[o].boxRaw[u]+c)/r);Oe.object[o]={...e.object[o],box:i,boxRaw:l}}if(e.persons){let o=e.persons;if(!Oe.persons||o.length!==Oe.persons.length)Oe.persons=JSON.parse(JSON.stringify(o));else for(let i=0;i<o.length;i++)Oe.persons[i].box=o[i].box.map((l,c)=>((r-1)*Oe.persons[i].box[c]+l)/r)}e.gesture&&(Oe.gesture=e.gesture);let a=pe();return w5=xe.perfadd?w5+Math.round(a-n):Math.round(a-n),e.performance&&(Oe.performance={...e.performance,interpolate:w5}),Oe}function em(e,t,n={order:2,multiplier:20}){let s=0;for(let r=0;r<e.length;r++){let a=!n.order||n.order===2?e[r]-t[r]:Math.abs(e[r]-t[r]);s+=!n.order||n.order===2?a*a:a**n.order}return(n.multiplier||20)*s}function KS(e,t,n={order:2,multiplier:20}){let s=em(e,t,n),r=!n.order||n.order===2?Math.sqrt(s):s**(1/n.order);return Math.max(0,100-r)/100}function ZS(e,t,n={order:2,multiplier:20,threshold:0}){if(!Array.isArray(e)||!Array.isArray(t)||e.length<64||t.length===0||e.length!==t[0].length)return{index:-1,distance:Number.POSITIVE_INFINITY,similarity:0};let s=Number.MAX_SAFE_INTEGER,r=-1;for(let a=0;a<t.length;a++){let o=em(e,t[a],n);if(o<s&&(s=o,r=a),s<(n.threshold||0))break}return s=!n.order||n.order===2?Math.sqrt(s):s**(1/n.order),{index:r,distance:s,similarity:Math.max(0,100-s)/100}}function YS(e,t,n,s,r){let a=0,o=[];for(let i of e){let l={id:a++,face:i,body:null,hands:{left:null,right:null},gestures:[],box:[0,0,0,0]};for(let f of t)i.box[0]>f.box[0]&&i.box[0]<f.box[0]+f.box[2]&&i.box[1]+i.box[3]>f.box[1]&&i.box[1]+i.box[3]<f.box[1]+f.box[3]&&(l.body=f);if(l.body)for(let f of n)f.box[0]+f.box[2]>l.body.box[0]&&f.box[0]+f.box[2]<l.body.box[0]+l.body.box[2]&&f.box[1]+f.box[3]>l.body.box[1]&&f.box[1]+f.box[3]<l.body.box[1]+l.body.box[3]&&l.hands&&(l.hands.left=f),f.box[0]<l.body.box[0]+l.body.box[2]&&f.box[0]>l.body.box[0]&&f.box[1]+f.box[3]>l.body.box[1]&&f.box[1]+f.box[3]<l.body.box[1]+l.body.box[3]&&l.hands&&(l.hands.right=f);for(let f of s)(f.face!==void 0&&f.face===i.id||f.iris!==void 0&&f.iris===i.id||f.body!==void 0&&f.body===l.body?.id||f.hand!==void 0&&f.hand===l.hands?.left?.id||f.hand!==void 0&&f.hand===l.hands?.right?.id)&&l.gestures?.push(f);let c=[],u=[],d=f=>{f&&f.length===4&&(c.push(f[0],f[0]+f[2]),u.push(f[1],f[1]+f[3]))};d(l.face?.box),d(l.body?.box),d(l.hands?.left?.box),d(l.hands?.right?.box);let p=Math.min(...c),h=Math.min(...u);l.box=[p,h,Math.max(...c)-p,Math.max(...u)-h],r&&r[1]&&r[2]&&(l.boxRaw=[l.box[0]/r[2],l.box[1]/r[1],l.box[2]/r[2],l.box[3]/r[1]]),o.push(l)}return o}var tm=`
|
|
/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==`,nm=`
|
|
/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 Mce(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(tm);break;case"body":case"full":n=await t(nm);break;default:n=null}if(n){let r=await createImageBitmap(n);s=await e.detect(r,e.config),r.close()}return s}async function zce(e){return new Promise(t=>{let n;switch(e.config.warmup){case"face":n="data:image/jpeg;base64,"+tm;break;case"full":case"body":n="data:image/jpeg;base64,"+nm;break;default:n=null}let s;typeof Image!="undefined"?s=new Image:xe.Image&&(s=new xe.Image),s.onload=async()=>{let r=zn(s.naturalWidth,s.naturalHeight);if(!r)ee("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 Lce(e){let t=r=>Buffer.from(r,"base64"),n;if(e.config.warmup==="face"&&(n=t(tm)),(e.config.warmup==="body"||e.config.warmup==="full")&&(n=t(nm)),!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&&ee("Warmup tfjs-node not loaded");return s}async function JS(e,t){let n=pe();if(e.state="warmup",t&&(e.config=wn(e.config,t)),!e.config.warmup||e.config.warmup==="none")return{error:"null"};let s;return new Promise(async r=>{typeof createImageBitmap=="function"?s=await Mce(e):typeof Image!="undefined"||xe.Canvas!==void 0?s=await zce(e):s=await Lce(e);let a=pe();e.config.debug&&ee("Warmup",e.config.warmup,Math.round(a-n),"ms"),e.emit("warmup"),r(s)})}var Ku,ap,op,sm,eC=class{constructor(t){he(this,"version");he(this,"config");he(this,"result");he(this,"state");he(this,"process");he(this,"tf");he(this,"env");he(this,"draw");he(this,"models");he(this,"events");he(this,"faceTriangulation");he(this,"faceUVMap");he(this,"performance");cc(this,Ku,void 0);cc(this,ap,void 0);cc(this,op,void 0);he(this,"gl");he(this,"analyze",(...t)=>{if(!uc(this,ap))return;let n=this.tf.engine().state.numTensors,s=uc(this,Ku);dc(this,Ku,n);let r=n-s;r!==0&&ee(...t,r)});cc(this,sm,t=>{if(!uc(this,op))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{return"backend not loaded"}return null});he(this,"similarity",KS);he(this,"distance",em);he(this,"match",ZS);he(this,"emit",t=>{this.events&&this.events.dispatchEvent&&this.events?.dispatchEvent(new Event(t))});this.env=xe,aa.wasmPath=Vc.includes("-")?"https://vladmandic.github.io/tfjs/dist/":`https://cdn.jsdelivr.net/npm/@tensorflow/tfjs-backend-wasm@${Vc}/dist/`,aa.modelBasePath=xe.browser?"../models/":"file://models/",aa.backend=xe.browser?"humangl":"tensorflow",this.version=ox,Object.defineProperty(this,"version",{value:ox}),this.config=JSON.parse(JSON.stringify(aa)),Object.seal(this.config),t&&(this.config=wn(this.config,t)),this.tf=Xd,this.state="idle",dc(this,Ku,0),dc(this,ap,!1),dc(this,op,!1),this.performance={},this.events=typeof EventTarget!="undefined"?new EventTarget:void 0,this.models=new p5,this.draw={options:Zr,canvas:(n,s)=>WS(n,s),face:(n,s,r)=>A5(n,s,r),body:(n,s,r)=>y5(n,s,r),hand:(n,s,r)=>x5(n,s,r),gesture:(n,s,r)=>g5(n,s,r),object:(n,s,r)=>b5(n,s,r),person:(n,s,r)=>BS(n,s,r),all:(n,s,r)=>VS(n,s,r)},this.result={face:[],body:[],hand:[],gesture:[],object:[],performance:{},timestamp:0,persons:[]},this.process={tensor:null,canvas:null},this.faceTriangulation=UI,this.faceUVMap=GI,this.gl=$t,this.emit("create")}reset(){let t=this.config.backend;this.config=JSON.parse(JSON.stringify(aa)),this.config.backend=t}validate(t){return Rg(aa,t||this.config)}now(){return pe()}image(t,n=!0){return Vu(t,this.config,n)}async segmentation(t,n){return $S(t,n,this.config)}enhance(t){return Mx(t)}async init(){await Q0(this,!0),await this.tf.ready()}async load(t){this.state="load";let n=pe(),s=Object.values(this.models).filter(o=>o).length;t&&(this.config=wn(this.config,t)),this.env.initial&&(this.config.debug&&ee(`version: ${this.version}`),this.config.debug&&ee(`tfjs version: ${this.tf.version_core}`),await Q0(this)||ee("error: backend check failed"),await Fh(),this.env.browser&&(this.config.debug&&ee("configuration:",this.config),this.config.debug&&ee("environment:",this.env),this.config.debug&&ee("tf flags:",this.tf.ENV.flags))),await OS(this),this.env.initial&&this.config.debug&&ee("tf engine state:",this.tf.engine().state.numBytes,"bytes",this.tf.engine().state.numTensors,"tensors"),this.env.initial=!1,Object.values(this.models).filter(o=>o).length!==s&&(await PS(this),this.emit("load"));let a=Math.trunc(pe()-n);a>(this.performance.loadModels||0)&&(this.performance.loadModels=this.env.perfadd?(this.performance.loadModels||0)+a:a)}next(t=this.result){return XS(t,this.config)}async warmup(t){let n=pe(),s=await JS(this,t),r=pe();return this.performance.warmup=Math.trunc(r-n),s}async detect(t,n){return this.state="detect",new Promise(async s=>{this.state="config";let r;this.config=wn(this.config,n),this.state="check";let a=uc(this,sm).call(this,t);a&&(ee(a,t),s({error:a}));let o=pe();await Q0(this),await this.load(),r=pe(),this.state="image";let i=Vu(t,this.config);if(this.process=i,this.performance.inputProcess=this.env.perfadd?(this.performance.inputProcess||0)+Math.trunc(pe()-r):Math.trunc(pe()-r),this.analyze("Get Image:"),!i.tensor){this.config.debug&&ee("could not convert input to tensor"),s({error:"could not convert input to tensor"});return}this.emit("image"),r=pe(),this.config.skipAllowed=await oI(this.config,i.tensor),this.performance.totalFrames||(this.performance.totalFrames=0),this.performance.cachedFrames||(this.performance.cachedFrames=0),this.performance.totalFrames++,this.config.skipAllowed&&this.performance.cachedFrames++,this.performance.inputCheck=this.env.perfadd?(this.performance.inputCheck||0)+Math.trunc(pe()-r):Math.trunc(pe()-r),this.analyze("Check Changed:");let l=[],c=[],u=[],d=[];this.state="detect:face",this.config.async?(l=this.config.face.enabled?v5(this,i.tensor):[],this.performance.face&&delete this.performance.face):(r=pe(),l=this.config.face.enabled?await v5(this,i.tensor):[],this.performance.face=this.env.perfadd?(this.performance.face||0)+Math.trunc(pe()-r):Math.trunc(pe()-r)),this.config.async&&(this.config.body.maxDetected===-1||this.config.hand.maxDetected===-1)&&(l=await l),this.analyze("Start Body:"),this.state="detect:body";let p=this.config.body.maxDetected===-1?wn(this.config,{body:{maxDetected:this.config.face.enabled?1*l.length:1}}):this.config;this.config.async?(this.config.body.modelPath?.includes("posenet")?c=this.config.body.enabled?u5(i.tensor,p):[]:this.config.body.modelPath?.includes("blazepose")?c=this.config.body.enabled?vx(i.tensor,p):[]:this.config.body.modelPath?.includes("efficientpose")?c=this.config.body.enabled?Ex(i.tensor,p):[]:this.config.body.modelPath?.includes("movenet")&&(c=this.config.body.enabled?t5(i.tensor,p):[]),this.performance.body&&delete this.performance.body):(r=pe(),this.config.body.modelPath?.includes("posenet")?c=this.config.body.enabled?await u5(i.tensor,p):[]:this.config.body.modelPath?.includes("blazepose")?c=this.config.body.enabled?await vx(i.tensor,p):[]:this.config.body.modelPath?.includes("efficientpose")?c=this.config.body.enabled?await Ex(i.tensor,p):[]:this.config.body.modelPath?.includes("movenet")&&(c=this.config.body.enabled?await t5(i.tensor,p):[]),this.performance.body=this.env.perfadd?(this.performance.body||0)+Math.trunc(pe()-r):Math.trunc(pe()-r)),this.analyze("End Body:"),this.analyze("Start Hand:"),this.state="detect:hand";let h=this.config.hand.maxDetected===-1?wn(this.config,{hand:{maxDetected:this.config.face.enabled?2*l.length:1}}):this.config;this.config.async?(this.config.hand.detector?.modelPath?.includes("handdetect")?u=this.config.hand.enabled?Ux(i.tensor,h):[]:this.config.hand.detector?.modelPath?.includes("handtrack")&&(u=this.config.hand.enabled?Xx(i.tensor,h):[]),this.performance.hand&&delete this.performance.hand):(r=pe(),this.config.hand.detector?.modelPath?.includes("handdetect")?u=this.config.hand.enabled?await Ux(i.tensor,h):[]:this.config.hand.detector?.modelPath?.includes("handtrack")&&(u=this.config.hand.enabled?await Xx(i.tensor,h):[]),this.performance.hand=this.env.perfadd?(this.performance.hand||0)+Math.trunc(pe()-r):Math.trunc(pe()-r)),this.analyze("End Hand:"),this.analyze("Start Object:"),this.state="detect:object",this.config.async?(this.config.object.modelPath?.includes("nanodet")?d=this.config.object.enabled?s5(i.tensor,this.config):[]:this.config.object.modelPath?.includes("centernet")&&(d=this.config.object.enabled?kx(i.tensor,this.config):[]),this.performance.object&&delete this.performance.object):(r=pe(),this.config.object.modelPath?.includes("nanodet")?d=this.config.object.enabled?await s5(i.tensor,this.config):[]:this.config.object.modelPath?.includes("centernet")&&(d=this.config.object.enabled?await kx(i.tensor,this.config):[]),this.performance.object=this.env.perfadd?(this.performance.object||0)+Math.trunc(pe()-r):Math.trunc(pe()-r)),this.analyze("End Object:"),this.state="detect:await",this.config.async&&([l,c,u,d]=await Promise.all([l,c,u,d])),this.state="detect:gesture";let f=[];this.config.gesture.enabled&&(r=pe(),f=[...HS(l),...GS(c),...qS(u),...jS(l)],this.config.async?this.performance.gesture&&delete this.performance.gesture:this.performance.gesture=this.env.perfadd?(this.performance.gesture||0)+Math.trunc(pe()-r):Math.trunc(pe()-r)),this.performance.total=this.env.perfadd?(this.performance.total||0)+Math.trunc(pe()-o):Math.trunc(pe()-o);let m=this.process?.tensor?.shape||[];this.result={face:l,body:c,hand:u,gesture:f,object:d,performance:this.performance,canvas:this.process.canvas,timestamp:Date.now(),get persons(){return YS(l,c,u,f,m)}},Z(i.tensor),this.emit("detect"),this.state="idle",s(this.result)})}};Ku=new WeakMap,ap=new WeakMap,op=new WeakMap,sm=new WeakMap;return Bce;})();
|
|
/**
|
|
* @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.
|
|
* =============================================================================
|
|
*/
|
|
/**
|
|
* Human main module
|
|
* @default Human Library
|
|
* @summary <https://github.com/vladmandic/human>
|
|
* @author <https://github.com/vladmandic>
|
|
* @copyright <https://github.com/vladmandic>
|
|
* @license 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 See the LICENSE file. */
|