mirror of https://github.com/vladmandic/human
5648 lines
1.4 MiB
5648 lines
1.4 MiB
/*
|
|
Human
|
|
homepage: <https://github.com/vladmandic/human>
|
|
author: <https://github.com/vladmandic>'
|
|
*/
|
|
|
|
var Human=(()=>{var R1=Object.defineProperty;var HS=(e,t,n)=>t in e?R1(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var qS=e=>R1(e,"__esModule",{value:!0});var rs=(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 ud=(e,t)=>{qS(e);for(var n in t)R1(e,n,{get:t[n],enumerable:!0})};var ce=(e,t,n)=>(HS(e,typeof t!="symbol"?t+"":t,n),n),O5=(e,t,n)=>{if(!t.has(e))throw TypeError("Cannot "+n)};var dd=(e,t,n)=>(O5(e,t,"read from private field"),n?n.call(e):t.get(e)),pd=(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)},cd=(e,t,n,a)=>(O5(e,t,"write to private field"),a?a.call(e,n):t.set(e,n),n);var zde={};ud(zde,{Env:()=>Mf,Human:()=>JI,Models:()=>rc,default:()=>JI,defaults:()=>ss,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 ie(...e){let t=new Date,n=`${t.getHours().toString().padStart(2,"0")}:${t.getMinutes().toString().padStart(2,"0")}:${t.getSeconds().toString().padStart(2,"0")}.${t.getMilliseconds().toString().padStart(3,"0")}`;e&&console.log(n,"Human:",...e)}var Ae=()=>typeof performance!="undefined"?performance.now():parseInt((Number(process.hrtime.bigint())/1e3/1e3).toString());function M1(e,t,n="config",a=[]){for(let r of Object.keys(t))if(typeof t[r]=="object")M1(e[r],t[r],r,a);else{let s=e&&typeof e[r]!="undefined";s||a.push({reason:"unknown property",where:`${n}.${r} = ${t[r]}`});let i=e&&typeof e[r]==typeof t[r];s&&!i&&a.push({reason:"property type mismatch",where:`${n}.${r} = ${t[r]}`,expected:typeof e[r]})}return t.debug&&n==="config"&&a.length>0&&ie("invalid configuration",a),a}function kn(...e){let t=n=>n&&typeof n=="object";return e.reduce((n,a)=>(Object.keys(a||{}).forEach(r=>{let s=n[r],i=a[r];Array.isArray(s)&&Array.isArray(i)?n[r]=s.concat(...i):t(s)&&t(i)?n[r]=kn(s,i):n[r]=i}),n),{})}var ss={backend:"",modelBasePath:"",wasmPath:"",debug:!0,async:!0,warmup:"full",cacheSensitivity:.75,skipFrame:!1,filter:{enabled:!0,width:0,height:0,flip:!1,return:!0,brightness:0,contrast:0,sharpness:0,blur:0,saturation:0,hue:0,negative:!1,sepia:!1,vintage:!1,kodachrome:!1,technicolor:!1,polaroid:!1,pixelate:0},gesture:{enabled:!0},face:{enabled:!0,detector:{modelPath:"blazeface.json",rotation:!0,maxDetected:1,skipFrames:11,skipTime:2e3,minConfidence:.2,iouThreshold:.1,return:!1},mesh:{enabled:!0,modelPath:"facemesh.json"},iris:{enabled:!0,modelPath:"iris.json"},emotion:{enabled:!0,minConfidence:.1,skipFrames:12,skipTime:2e3,modelPath:"emotion.json"},description:{enabled:!0,modelPath:"faceres.json",skipFrames:13,skipTime:2e3,minConfidence:.1},antispoof:{enabled:!1,skipFrames:14,skipTime:2e3,modelPath:"antispoof.json"}},body:{enabled:!0,modelPath:"movenet-lightning.json",detector:{modelPath:""},maxDetected:-1,minConfidence:.3,skipFrames:1,skipTime:2e3},hand:{enabled:!0,rotation:!0,skipFrames:2,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:15,skipTime:2e3},segmentation:{enabled:!1,modelPath:"selfie.json",blur:8}};var Ro={};ud(Ro,{Abs:()=>Ko,Acos:()=>Zo,Acosh:()=>Yo,AdadeltaOptimizer:()=>h0,AdagradOptimizer:()=>f0,AdamOptimizer:()=>m0,AdamaxOptimizer:()=>g0,Add:()=>ls,AddN:()=>Zs,All:()=>Jo,Any:()=>Qo,ArgMax:()=>Ys,ArgMin:()=>yd,Asin:()=>el,Asinh:()=>tl,Atan:()=>nl,Atan2:()=>rl,Atanh:()=>al,AvgPool:()=>Js,AvgPool3D:()=>Ad,AvgPool3DGrad:()=>Bc,AvgPoolGrad:()=>Wc,BackendWasm:()=>q8,BatchMatMul:()=>Qs,BatchToSpaceND:()=>sl,Bincount:()=>Vc,BroadcastArgs:()=>Uc,BroadcastTo:()=>eb,Callback:()=>j7,CallbackList:()=>_v,Cast:()=>ei,Ceil:()=>ti,ClipByValue:()=>us,Complex:()=>jc,ComplexAbs:()=>xd,Concat:()=>il,Conv2D:()=>ni,Conv2DBackpropFilter:()=>Gc,Conv2DBackpropInput:()=>ai,Conv3D:()=>bd,Conv3DBackpropFilterV2:()=>Hc,Conv3DBackpropInputV2:()=>qc,Cos:()=>ri,Cosh:()=>si,CropAndResize:()=>ol,Cumsum:()=>ii,CustomCallback:()=>zv,DataStorage:()=>Oc,DenseBincount:()=>Xc,DepthToSpace:()=>ll,DepthwiseConv2dNative:()=>oi,DepthwiseConv2dNativeBackpropFilter:()=>Kc,DepthwiseConv2dNativeBackpropInput:()=>Zc,Diag:()=>Yc,Dilation2D:()=>vd,Dilation2DBackpropFilter:()=>Qc,Dilation2DBackpropInput:()=>Jc,ENV:()=>cr,EarlyStopping:()=>H7,Einsum:()=>eh,Elu:()=>ui,EluGrad:()=>th,Environment:()=>J5,Equal:()=>dl,Erf:()=>ul,Exp:()=>di,ExpandDims:()=>pl,Expm1:()=>cl,FFT:()=>nh,Fill:()=>wd,FlipLeftRight:()=>hl,Floor:()=>pi,FloorDiv:()=>ci,FromPixels:()=>kh,FusedBatchNorm:()=>hi,FusedConv2D:()=>qi,FusedDepthwiseConv2D:()=>Xi,GPGPUContext:()=>yf,GatherNd:()=>ml,GatherV2:()=>fl,GraphModel:()=>Iw,Greater:()=>gl,GreaterEqual:()=>fi,History:()=>Pv,IFFT:()=>ah,Identity:()=>mi,Imag:()=>rh,InputSpec:()=>qt,IsFinite:()=>yl,IsInf:()=>Al,IsNan:()=>xl,KernelBackend:()=>fd,LRN:()=>Sd,LRNGrad:()=>ih,LayerVariable:()=>Mv,LayersModel:()=>Vr,LeakyRelu:()=>gi,Less:()=>bl,LessEqual:()=>vl,LinSpace:()=>sh,Log:()=>yi,Log1p:()=>wl,LogSoftmax:()=>tb,LogicalAnd:()=>kl,LogicalNot:()=>kd,LogicalOr:()=>Id,MathBackendWebGL:()=>Pu,Max:()=>Ai,MaxPool:()=>bi,MaxPool3D:()=>Nd,MaxPool3DGrad:()=>lh,MaxPoolGrad:()=>oh,MaxPoolWithArgmax:()=>uh,Maximum:()=>xi,Mean:()=>vi,Min:()=>wi,Minimum:()=>ki,MirrorPad:()=>Ii,Mod:()=>Il,MomentumOptimizer:()=>y0,Multinomial:()=>dh,Multiply:()=>Si,Neg:()=>Sl,NonMaxSuppressionV3:()=>Tl,NonMaxSuppressionV4:()=>Cl,NonMaxSuppressionV5:()=>El,NotEqual:()=>Nl,OP_SCOPE_SUFFIX:()=>gb,OneHot:()=>Ni,OnesLike:()=>Rl,Optimizer:()=>Lr,Pack:()=>Ml,PadV2:()=>Ti,Pool:()=>UN,Pow:()=>Ci,Prelu:()=>Ei,Prod:()=>Fl,RMSPropOptimizer:()=>A0,RNN:()=>Ir,Range:()=>Td,Rank:()=>V1,Real:()=>ph,RealDiv:()=>li,Reciprocal:()=>Dl,Reduction:()=>Fn,Relu:()=>Ri,Relu6:()=>Fi,Reshape:()=>$l,ResizeBilinear:()=>Mi,ResizeBilinearGrad:()=>hh,ResizeNearestNeighbor:()=>Cd,ResizeNearestNeighborGrad:()=>ch,Reverse:()=>Di,RotateWithOffset:()=>Kl,Round:()=>$i,Rsqrt:()=>Oi,SGDOptimizer:()=>op,ScatterNd:()=>Ol,Select:()=>_l,Selu:()=>Pl,Sequential:()=>ku,Sigmoid:()=>Pi,Sign:()=>Wl,Sin:()=>_i,Sinh:()=>Ll,Slice:()=>zl,Softmax:()=>Wi,Softplus:()=>Bl,SpaceToBatchND:()=>Vl,SparseFillEmptyRows:()=>fh,SparseReshape:()=>mh,SparseSegmentMean:()=>gh,SparseSegmentSum:()=>yh,SparseToDense:()=>Ah,SplitV:()=>Ul,Sqrt:()=>zi,Square:()=>Ed,SquaredDifference:()=>Bi,Step:()=>ps,StridedSlice:()=>jl,StringNGrams:()=>xh,StringSplit:()=>bh,StringToHashBucketFast:()=>vh,Sub:()=>Vi,Sum:()=>Li,SymbolicTensor:()=>rr,Tan:()=>Ui,Tanh:()=>ji,Tensor:()=>je,TensorBuffer:()=>Jt,Tile:()=>ds,TopK:()=>Gl,Transform:()=>Hl,Transpose:()=>Gi,Unique:()=>wh,Unpack:()=>ql,UnsortedSegmentSum:()=>Rd,Variable:()=>zd,ZerosLike:()=>Xl,_FusedMatMul:()=>Hi,abs:()=>jt,acos:()=>yg,acosh:()=>Ag,add:()=>le,addN:()=>_h,all:()=>Ph,any:()=>jd,argMax:()=>ka,argMin:()=>xg,asin:()=>bg,asinh:()=>vg,atan:()=>wg,atan2:()=>kg,atanh:()=>Ig,avgPool:()=>Hd,avgPool3d:()=>Tg,backend:()=>mr,backend_util:()=>E,basicLSTMCell:()=>kE,batchNorm:()=>ao,batchNorm2d:()=>s3,batchNorm3d:()=>i3,batchNorm4d:()=>o3,batchToSpaceND:()=>qd,bincount:()=>Cg,booleanMaskAsync:()=>RF,broadcastArgs:()=>l3,broadcastTo:()=>su,browser:()=>za,buffer:()=>Ge,callbacks:()=>jW,cast:()=>pe,ceil:()=>Eg,clipByValue:()=>Zn,clone:()=>Za,complex:()=>fs,concat:()=>mt,concat1d:()=>u3,concat2d:()=>iu,concat3d:()=>d3,concat4d:()=>p3,constraints:()=>dv,conv1d:()=>Lh,conv2d:()=>_r,conv2dTranspose:()=>Wh,conv3d:()=>Mg,conv3dTranspose:()=>h3,copyRegisteredKernels:()=>HN,cos:()=>Xd,cosh:()=>Bh,cosineWindow:()=>ry,cumsum:()=>Vh,customGrad:()=>yr,data:()=>Sw,denseBincount:()=>f3,deprecationWarn:()=>mg,depthToSpace:()=>Fg,depthwiseConv2d:()=>ou,deregisterOp:()=>HW,device_util:()=>Wd,diag:()=>QE,dilation2d:()=>Dg,disableDeprecationWarnings:()=>LC,dispose:()=>Q,disposeVariables:()=>WC,div:()=>he,divNoNan:()=>$g,dot:()=>m3,dropout:()=>_3,einsum:()=>g3,elu:()=>lu,enableDebugMode:()=>zC,enableProdMode:()=>e3,enclosingPowerOfTwo:()=>P3,engine:()=>sa,env:()=>ne,equal:()=>ia,erf:()=>Og,exp:()=>oa,expandDims:()=>Wt,expm1:()=>_g,eye:()=>Pg,fft:()=>rp,fill:()=>uu,findBackend:()=>gg,findBackendFactory:()=>jC,floor:()=>du,floorDiv:()=>Oh,forceHalfFloat:()=>J4,fused:()=>vs,gather:()=>ro,gatherND:()=>O3,gather_util:()=>lg,getBackend:()=>Ya,getGradient:()=>z1,getKernel:()=>Ih,getKernelsForBackend:()=>$r,getThreadsCount:()=>Cue,gpgpu_util:()=>N4,grad:()=>ER,grads:()=>RR,greater:()=>Yn,greaterEqual:()=>xs,ifft:()=>mu,imag:()=>Uh,image:()=>Me,inTopKAsync:()=>BF,initializers:()=>yv,input:()=>o7,io:()=>Xn,irfft:()=>a0,isFinite:()=>y3,isInf:()=>A3,isNaN:()=>zg,keep:()=>pn,kernel_impls:()=>xr,layers:()=>Cv,leakyRelu:()=>Kd,less:()=>jh,lessEqual:()=>bs,linalg:()=>K3,linspace:()=>x3,loadGraphModel:()=>et,loadLayersModel:()=>eL,localResponseNormalization:()=>Lg,log:()=>la,log1p:()=>Zd,logSigmoid:()=>v3,logSoftmax:()=>Hh,logSumExp:()=>Vg,logicalAnd:()=>La,logicalNot:()=>Yd,logicalOr:()=>qh,logicalXor:()=>S3,losses:()=>k$,matMul:()=>Ve,math:()=>$b,max:()=>Rn,maxPool:()=>Jd,maxPool3d:()=>Ug,maxPoolWithArgmax:()=>N3,maximum:()=>Ar,mean:()=>Dt,memory:()=>Dh,meshgrid:()=>JR,metrics:()=>B7,min:()=>Qd,minimum:()=>pu,mirrorPad:()=>jg,mod:()=>Gg,model:()=>Jz,models:()=>V7,moments:()=>Xh,movingAverage:()=>DF,mul:()=>L,multiRNNCell:()=>iM,multinomial:()=>T3,neg:()=>Tt,nextFrame:()=>Z3,norm:()=>o0,notEqual:()=>oo,oneHot:()=>tu,ones:()=>ua,onesLike:()=>da,op:()=>B,outerProduct:()=>pM,pad:()=>Sa,pad1d:()=>fM,pad2d:()=>gM,pad3d:()=>AM,pad4d:()=>bM,pool:()=>C3,pow:()=>Pr,prelu:()=>tp,print:()=>Cb,prod:()=>Kh,profile:()=>BC,rand:()=>EM,randomGamma:()=>DM,randomNormal:()=>E3,randomUniform:()=>cu,range:()=>hu,ready:()=>$h,real:()=>np,reciprocal:()=>Xg,registerBackend:()=>au,registerCallbackConstructor:()=>tL,registerGradient:()=>nb,registerKernel:()=>cs,registerOp:()=>GW,regularizers:()=>U7,relu:()=>Ja,relu6:()=>Zh,removeBackend:()=>UC,reshape:()=>V,reverse:()=>pa,reverse1d:()=>VM,reverse2d:()=>jM,reverse3d:()=>HM,reverse4d:()=>XM,rfft:()=>sp,round:()=>Yh,rsqrt:()=>Jh,scalar:()=>Ce,scatterND:()=>$3,scatter_util:()=>ug,selu:()=>Qh,separableConv2d:()=>Kg,sequential:()=>Qz,serialization:()=>ue,setBackend:()=>t3,setPlatform:()=>GC,setThreadsCount:()=>Tue,setWasmPath:()=>Nue,setWasmPaths:()=>K8,setWebGLContext:()=>lf,setdiff1dAsync:()=>R3,sigmoid:()=>Kn,sign:()=>Zg,signal:()=>w$,sin:()=>e0,sinh:()=>t0,slice:()=>De,slice1d:()=>n0,slice2d:()=>Yg,slice3d:()=>fu,slice4d:()=>ap,slice_util:()=>En,softmax:()=>lo,softplus:()=>so,spaceToBatchND:()=>ep,sparse:()=>ip,sparseToDense:()=>ay,spectral:()=>v$,split:()=>cn,sqrt:()=>An,square:()=>ht,squaredDifference:()=>r0,squeeze:()=>st,stack:()=>xn,step:()=>gu,stridedSlice:()=>Jg,string:()=>c0,sub:()=>ge,sum:()=>Ie,sumOutType:()=>Eh,tan:()=>Qg,tanh:()=>no,tensor:()=>Lt,tensor1d:()=>Ht,tensor2d:()=>Qa,tensor3d:()=>Ob,tensor4d:()=>bF,tensor5d:()=>vF,tensor6d:()=>wF,tensor_util:()=>Xa,test_util:()=>Yb,tidy:()=>G,tile:()=>Ia,time:()=>VC,topk:()=>ey,train:()=>po,transpose:()=>Ze,truncatedNormal:()=>s0,unique:()=>i0,unregisterGradient:()=>GN,unregisterKernel:()=>jN,unsortedSegmentSum:()=>ty,unstack:()=>Mn,upcastType:()=>Pa,util:()=>w,valueAndGrad:()=>MR,valueAndGrads:()=>FR,variable:()=>M3,variableGrads:()=>b3,version:()=>Lue,version_converter:()=>KB,version_core:()=>Ud,version_layers:()=>Ly,version_wasm:()=>Eue,version_webgl:()=>oY,webgl:()=>lY,webgl_util:()=>Z6,where:()=>Sn,whereAsync:()=>ny,zeros:()=>Gt,zerosLike:()=>Ye});var XS=Object.create,$c=Object.defineProperty,KS=Object.getOwnPropertyDescriptor,ZS=Object.getOwnPropertyNames,YS=Object.getPrototypeOf,JS=Object.prototype.hasOwnProperty,_5=e=>$c(e,"__esModule",{value:!0}),Ho=(e=>typeof rs!="undefined"?rs:typeof Proxy!="undefined"?new Proxy(e,{get:(t,n)=>(typeof rs!="undefined"?rs:t)[n]}):e)(function(e){if(typeof rs!="undefined")return rs.apply(this,arguments);throw new Error('Dynamic require of "'+e+'" is not supported')}),Nt=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),ze=(e,t)=>{_5(e);for(var n in t)$c(e,n,{get:t[n],enumerable:!0})},QS=(e,t,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of ZS(t))!JS.call(e,a)&&a!=="default"&&$c(e,a,{get:()=>t[a],enumerable:!(n=KS(t,a))||n.enumerable});return e},qs=e=>QS(_5($c(e!=null?XS(YS(e)):{},"default",e&&e.__esModule&&"default"in e?{get:()=>e.default,enumerable:!0}:{value:e,enumerable:!0})),e),eN=Nt((e,t)=>{t.exports=a;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(S){}function a(S,P,_){this.low=S|0,this.high=P|0,this.unsigned=!!_}a.prototype.__isLong__,Object.defineProperty(a.prototype,"__isLong__",{value:!0});function r(S){return(S&&S.__isLong__)===!0}a.isLong=r;var s={},i={};function o(S,P){var _,j,q;return P?(S>>>=0,(q=0<=S&&S<256)&&(j=i[S],j)?j:(_=d(S,(S|0)<0?-1:0,!0),q&&(i[S]=_),_)):(S|=0,(q=-128<=S&&S<128)&&(j=s[S],j)?j:(_=d(S,S<0?-1:0,!1),q&&(s[S]=_),_))}a.fromInt=o;function l(S,P){if(isNaN(S))return P?b:x;if(P){if(S<0)return b;if(S>=g)return D}else{if(S<=-y)return O;if(S+1>=y)return C}return S<0?l(-S,P).neg():d(S%m|0,S/m|0,P)}a.fromNumber=l;function d(S,P,_){return new a(S,P,_)}a.fromBits=d;var u=Math.pow;function p(S,P,_){if(S.length===0)throw Error("empty string");if(S==="NaN"||S==="Infinity"||S==="+Infinity"||S==="-Infinity")return x;if(typeof P=="number"?(_=P,P=!1):P=!!P,_=_||10,_<2||36<_)throw RangeError("radix");var j;if((j=S.indexOf("-"))>0)throw Error("interior hyphen");if(j===0)return p(S.substring(1),P,_).neg();for(var q=l(u(_,8)),z=x,X=0;X<S.length;X+=8){var Z=Math.min(8,S.length-X),te=parseInt(S.substring(X,X+Z),_);if(Z<8){var J=l(u(_,Z));z=z.mul(J).add(l(te))}else z=z.mul(q),z=z.add(l(te))}return z.unsigned=P,z}a.fromString=p;function c(S,P){return typeof S=="number"?l(S,P):typeof S=="string"?p(S,P):d(S.low,S.high,typeof P=="boolean"?P:S.unsigned)}a.fromValue=c;var h=1<<16,f=1<<24,m=h*h,g=m*m,y=g/2,A=o(f),x=o(0);a.ZERO=x;var b=o(0,!0);a.UZERO=b;var v=o(1);a.ONE=v;var k=o(1,!0);a.UONE=k;var T=o(-1);a.NEG_ONE=T;var C=d(4294967295|0,2147483647|0,!1);a.MAX_VALUE=C;var D=d(4294967295|0,4294967295|0,!0);a.MAX_UNSIGNED_VALUE=D;var O=d(0,2147483648|0,!1);a.MIN_VALUE=O;var F=a.prototype;F.toInt=function(){return this.unsigned?this.low>>>0:this.low},F.toNumber=function(){return this.unsigned?(this.high>>>0)*m+(this.low>>>0):this.high*m+(this.low>>>0)},F.toString=function(S){if(S=S||10,S<2||36<S)throw RangeError("radix");if(this.isZero())return"0";if(this.isNegative())if(this.eq(O)){var P=l(S),_=this.div(P),j=_.mul(P).sub(this);return _.toString(S)+j.toInt().toString(S)}else return"-"+this.neg().toString(S);for(var q=l(u(S,6),this.unsigned),z=this,X="";;){var Z=z.div(q),te=z.sub(Z.mul(q)).toInt()>>>0,J=te.toString(S);if(z=Z,z.isZero())return J+X;for(;J.length<6;)J="0"+J;X=""+J+X}},F.getHighBits=function(){return this.high},F.getHighBitsUnsigned=function(){return this.high>>>0},F.getLowBits=function(){return this.low},F.getLowBitsUnsigned=function(){return this.low>>>0},F.getNumBitsAbs=function(){if(this.isNegative())return this.eq(O)?64:this.neg().getNumBitsAbs();for(var S=this.high!=0?this.high:this.low,P=31;P>0&&(S&1<<P)==0;P--);return this.high!=0?P+33:P+1},F.isZero=function(){return this.high===0&&this.low===0},F.eqz=F.isZero,F.isNegative=function(){return!this.unsigned&&this.high<0},F.isPositive=function(){return this.unsigned||this.high>=0},F.isOdd=function(){return(this.low&1)==1},F.isEven=function(){return(this.low&1)==0},F.equals=function(S){return r(S)||(S=c(S)),this.unsigned!==S.unsigned&&this.high>>>31==1&&S.high>>>31==1?!1:this.high===S.high&&this.low===S.low},F.eq=F.equals,F.notEquals=function(S){return!this.eq(S)},F.neq=F.notEquals,F.ne=F.notEquals,F.lessThan=function(S){return this.comp(S)<0},F.lt=F.lessThan,F.lessThanOrEqual=function(S){return this.comp(S)<=0},F.lte=F.lessThanOrEqual,F.le=F.lessThanOrEqual,F.greaterThan=function(S){return this.comp(S)>0},F.gt=F.greaterThan,F.greaterThanOrEqual=function(S){return this.comp(S)>=0},F.gte=F.greaterThanOrEqual,F.ge=F.greaterThanOrEqual,F.compare=function(S){if(r(S)||(S=c(S)),this.eq(S))return 0;var P=this.isNegative(),_=S.isNegative();return P&&!_?-1:!P&&_?1:this.unsigned?S.high>>>0>this.high>>>0||S.high===this.high&&S.low>>>0>this.low>>>0?-1:1:this.sub(S).isNegative()?-1:1},F.comp=F.compare,F.negate=function(){return!this.unsigned&&this.eq(O)?O:this.not().add(v)},F.neg=F.negate,F.add=function(S){r(S)||(S=c(S));var P=this.high>>>16,_=this.high&65535,j=this.low>>>16,q=this.low&65535,z=S.high>>>16,X=S.high&65535,Z=S.low>>>16,te=S.low&65535,J=0,re=0,Y=0,se=0;return se+=q+te,Y+=se>>>16,se&=65535,Y+=j+Z,re+=Y>>>16,Y&=65535,re+=_+X,J+=re>>>16,re&=65535,J+=P+z,J&=65535,d(Y<<16|se,J<<16|re,this.unsigned)},F.subtract=function(S){return r(S)||(S=c(S)),this.add(S.neg())},F.sub=F.subtract,F.multiply=function(S){if(this.isZero())return x;if(r(S)||(S=c(S)),n){var P=n.mul(this.low,this.high,S.low,S.high);return d(P,n.get_high(),this.unsigned)}if(S.isZero())return x;if(this.eq(O))return S.isOdd()?O:x;if(S.eq(O))return this.isOdd()?O:x;if(this.isNegative())return S.isNegative()?this.neg().mul(S.neg()):this.neg().mul(S).neg();if(S.isNegative())return this.mul(S.neg()).neg();if(this.lt(A)&&S.lt(A))return l(this.toNumber()*S.toNumber(),this.unsigned);var _=this.high>>>16,j=this.high&65535,q=this.low>>>16,z=this.low&65535,X=S.high>>>16,Z=S.high&65535,te=S.low>>>16,J=S.low&65535,re=0,Y=0,se=0,de=0;return de+=z*J,se+=de>>>16,de&=65535,se+=q*J,Y+=se>>>16,se&=65535,se+=z*te,Y+=se>>>16,se&=65535,Y+=j*J,re+=Y>>>16,Y&=65535,Y+=q*te,re+=Y>>>16,Y&=65535,Y+=z*Z,re+=Y>>>16,Y&=65535,re+=_*J+j*te+q*Z+z*X,re&=65535,d(se<<16|de,re<<16|Y,this.unsigned)},F.mul=F.multiply,F.divide=function(S){if(r(S)||(S=c(S)),S.isZero())throw Error("division by zero");if(n){if(!this.unsigned&&this.high===-2147483648&&S.low===-1&&S.high===-1)return this;var P=(this.unsigned?n.div_u:n.div_s)(this.low,this.high,S.low,S.high);return d(P,n.get_high(),this.unsigned)}if(this.isZero())return this.unsigned?b:x;var _,j,q;if(this.unsigned){if(S.unsigned||(S=S.toUnsigned()),S.gt(this))return b;if(S.gt(this.shru(1)))return k;q=b}else{if(this.eq(O)){if(S.eq(v)||S.eq(T))return O;if(S.eq(O))return v;var z=this.shr(1);return _=z.div(S).shl(1),_.eq(x)?S.isNegative()?v:T:(j=this.sub(S.mul(_)),q=_.add(j.div(S)),q)}else if(S.eq(O))return this.unsigned?b:x;if(this.isNegative())return S.isNegative()?this.neg().div(S.neg()):this.neg().div(S).neg();if(S.isNegative())return this.div(S.neg()).neg();q=x}for(j=this;j.gte(S);){_=Math.max(1,Math.floor(j.toNumber()/S.toNumber()));for(var X=Math.ceil(Math.log(_)/Math.LN2),Z=X<=48?1:u(2,X-48),te=l(_),J=te.mul(S);J.isNegative()||J.gt(j);)_-=Z,te=l(_,this.unsigned),J=te.mul(S);te.isZero()&&(te=v),q=q.add(te),j=j.sub(J)}return q},F.div=F.divide,F.modulo=function(S){if(r(S)||(S=c(S)),n){var P=(this.unsigned?n.rem_u:n.rem_s)(this.low,this.high,S.low,S.high);return d(P,n.get_high(),this.unsigned)}return this.sub(this.div(S).mul(S))},F.mod=F.modulo,F.rem=F.modulo,F.not=function(){return d(~this.low,~this.high,this.unsigned)},F.and=function(S){return r(S)||(S=c(S)),d(this.low&S.low,this.high&S.high,this.unsigned)},F.or=function(S){return r(S)||(S=c(S)),d(this.low|S.low,this.high|S.high,this.unsigned)},F.xor=function(S){return r(S)||(S=c(S)),d(this.low^S.low,this.high^S.high,this.unsigned)},F.shiftLeft=function(S){return r(S)&&(S=S.toInt()),(S&=63)==0?this:S<32?d(this.low<<S,this.high<<S|this.low>>>32-S,this.unsigned):d(0,this.low<<S-32,this.unsigned)},F.shl=F.shiftLeft,F.shiftRight=function(S){return r(S)&&(S=S.toInt()),(S&=63)==0?this:S<32?d(this.low>>>S|this.high<<32-S,this.high>>S,this.unsigned):d(this.high>>S-32,this.high>=0?0:-1,this.unsigned)},F.shr=F.shiftRight,F.shiftRightUnsigned=function(S){if(r(S)&&(S=S.toInt()),S&=63,S===0)return this;var P=this.high;if(S<32){var _=this.low;return d(_>>>S|P<<32-S,P>>>S,this.unsigned)}else return S===32?d(P,0,this.unsigned):d(P>>>S-32,0,this.unsigned)},F.shru=F.shiftRightUnsigned,F.shr_u=F.shiftRightUnsigned,F.toSigned=function(){return this.unsigned?d(this.low,this.high,!1):this},F.toUnsigned=function(){return this.unsigned?this:d(this.low,this.high,!0)},F.toBytes=function(S){return S?this.toBytesLE():this.toBytesBE()},F.toBytesLE=function(){var S=this.high,P=this.low;return[P&255,P>>>8&255,P>>>16&255,P>>>24,S&255,S>>>8&255,S>>>16&255,S>>>24]},F.toBytesBE=function(){var S=this.high,P=this.low;return[S>>>24,S>>>16&255,S>>>8&255,S&255,P>>>24,P>>>16&255,P>>>8&255,P&255]},a.fromBytes=function(S,P,_){return _?a.fromBytesLE(S,P):a.fromBytesBE(S,P)},a.fromBytesLE=function(S,P){return new a(S[0]|S[1]<<8|S[2]<<16|S[3]<<24,S[4]|S[5]<<8|S[6]<<16|S[7]<<24,P)},a.fromBytesBE=function(S,P){return new a(S[4]<<24|S[5]<<16|S[6]<<8|S[7],S[0]<<24|S[1]<<16|S[2]<<8|S[3],P)}}),tN=Nt(()=>{}),nN=Nt((e,t)=>{(function(n,a,r){function s(d){var u=this,p=l();u.next=function(){var c=2091639*u.s0+u.c*23283064365386963e-26;return u.s0=u.s1,u.s1=u.s2,u.s2=c-(u.c=c|0)},u.c=1,u.s0=p(" "),u.s1=p(" "),u.s2=p(" "),u.s0-=p(d),u.s0<0&&(u.s0+=1),u.s1-=p(d),u.s1<0&&(u.s1+=1),u.s2-=p(d),u.s2<0&&(u.s2+=1),p=null}function i(d,u){return u.c=d.c,u.s0=d.s0,u.s1=d.s1,u.s2=d.s2,u}function o(d,u){var p=new s(d),c=u&&u.state,h=p.next;return h.int32=function(){return p.next()*4294967296|0},h.double=function(){return h()+(h()*2097152|0)*11102230246251565e-32},h.quick=h,c&&(typeof c=="object"&&i(c,p),h.state=function(){return i(p,{})}),h}function l(){var d=4022871197,u=function(p){p=p.toString();for(var c=0;c<p.length;c++){d+=p.charCodeAt(c);var h=.02519603282416938*d;d=h>>>0,h-=d,h*=d,d=h>>>0,h-=d,d+=h*4294967296}return(d>>>0)*23283064365386963e-26};return u}a&&a.exports?a.exports=o:r&&r.amd?r(function(){return o}):this.alea=o})(e,typeof t=="object"&&t,typeof define=="function"&&define)}),aN=Nt((e,t)=>{(function(n,a,r){function s(l){var d=this,u="";d.x=0,d.y=0,d.z=0,d.w=0,d.next=function(){var c=d.x^d.x<<11;return d.x=d.y,d.y=d.z,d.z=d.w,d.w^=d.w>>>19^c^c>>>8},l===(l|0)?d.x=l:u+=l;for(var p=0;p<u.length+64;p++)d.x^=u.charCodeAt(p)|0,d.next()}function i(l,d){return d.x=l.x,d.y=l.y,d.z=l.z,d.w=l.w,d}function o(l,d){var u=new s(l),p=d&&d.state,c=function(){return(u.next()>>>0)/4294967296};return c.double=function(){do var h=u.next()>>>11,f=(u.next()>>>0)/4294967296,m=(h+f)/(1<<21);while(m===0);return m},c.int32=u.next,c.quick=c,p&&(typeof p=="object"&&i(p,u),c.state=function(){return i(u,{})}),c}a&&a.exports?a.exports=o:r&&r.amd?r(function(){return o}):this.xor128=o})(e,typeof t=="object"&&t,typeof define=="function"&&define)}),rN=Nt((e,t)=>{(function(n,a,r){function s(l){var d=this,u="";d.next=function(){var c=d.x^d.x>>>2;return d.x=d.y,d.y=d.z,d.z=d.w,d.w=d.v,(d.d=d.d+362437|0)+(d.v=d.v^d.v<<4^(c^c<<1))|0},d.x=0,d.y=0,d.z=0,d.w=0,d.v=0,l===(l|0)?d.x=l:u+=l;for(var p=0;p<u.length+64;p++)d.x^=u.charCodeAt(p)|0,p==u.length&&(d.d=d.x<<10^d.x>>>4),d.next()}function i(l,d){return d.x=l.x,d.y=l.y,d.z=l.z,d.w=l.w,d.v=l.v,d.d=l.d,d}function o(l,d){var u=new s(l),p=d&&d.state,c=function(){return(u.next()>>>0)/4294967296};return c.double=function(){do var h=u.next()>>>11,f=(u.next()>>>0)/4294967296,m=(h+f)/(1<<21);while(m===0);return m},c.int32=u.next,c.quick=c,p&&(typeof p=="object"&&i(p,u),c.state=function(){return i(u,{})}),c}a&&a.exports?a.exports=o:r&&r.amd?r(function(){return o}):this.xorwow=o})(e,typeof t=="object"&&t,typeof define=="function"&&define)}),sN=Nt((e,t)=>{(function(n,a,r){function s(l){var d=this;d.next=function(){var p=d.x,c=d.i,h,f,m;return h=p[c],h^=h>>>7,f=h^h<<24,h=p[c+1&7],f^=h^h>>>10,h=p[c+3&7],f^=h^h>>>3,h=p[c+4&7],f^=h^h<<7,h=p[c+7&7],h=h^h<<13,f^=h^h<<9,p[c]=f,d.i=c+1&7,f};function u(p,c){var h,f,m=[];if(c===(c|0))f=m[0]=c;else for(c=""+c,h=0;h<c.length;++h)m[h&7]=m[h&7]<<15^c.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],p.x=m,p.i=0,h=256;h>0;--h)p.next()}u(d,l)}function i(l,d){return d.x=l.x.slice(),d.i=l.i,d}function o(l,d){l==null&&(l=+new Date);var u=new s(l),p=d&&d.state,c=function(){return(u.next()>>>0)/4294967296};return c.double=function(){do var h=u.next()>>>11,f=(u.next()>>>0)/4294967296,m=(h+f)/(1<<21);while(m===0);return m},c.int32=u.next,c.quick=c,p&&(p.x&&i(p,u),c.state=function(){return i(u,{})}),c}a&&a.exports?a.exports=o:r&&r.amd?r(function(){return o}):this.xorshift7=o})(e,typeof t=="object"&&t,typeof define=="function"&&define)}),iN=Nt((e,t)=>{(function(n,a,r){function s(l){var d=this;d.next=function(){var p=d.w,c=d.X,h=d.i,f,m;return d.w=p=p+1640531527|0,m=c[h+34&127],f=c[h=h+1&127],m^=m<<13,f^=f<<17,m^=m>>>15,f^=f>>>12,m=c[h]=m^f,d.i=h,m+(p^p>>>16)|0};function u(p,c){var h,f,m,g,y,A=[],x=128;for(c===(c|0)?(f=c,c=null):(c=c+"\0",f=0,x=Math.max(x,c.length)),m=0,g=-32;g<x;++g)c&&(f^=c.charCodeAt((g+32)%c.length)),g===0&&(y=f),f^=f<<10,f^=f>>>15,f^=f<<4,f^=f>>>13,g>=0&&(y=y+1640531527|0,h=A[g&127]^=f+y,m=h==0?m+1:0);for(m>=128&&(A[(c&&c.length||0)&127]=-1),m=127,g=4*128;g>0;--g)f=A[m+34&127],h=A[m=m+1&127],f^=f<<13,h^=h<<17,f^=f>>>15,h^=h>>>12,A[m]=f^h;p.w=y,p.X=A,p.i=m}u(d,l)}function i(l,d){return d.i=l.i,d.w=l.w,d.X=l.X.slice(),d}function o(l,d){l==null&&(l=+new Date);var u=new s(l),p=d&&d.state,c=function(){return(u.next()>>>0)/4294967296};return c.double=function(){do var h=u.next()>>>11,f=(u.next()>>>0)/4294967296,m=(h+f)/(1<<21);while(m===0);return m},c.int32=u.next,c.quick=c,p&&(p.X&&i(p,u),c.state=function(){return i(u,{})}),c}a&&a.exports?a.exports=o:r&&r.amd?r(function(){return o}):this.xor4096=o})(e,typeof t=="object"&&t,typeof define=="function"&&define)}),oN=Nt((e,t)=>{(function(n,a,r){function s(l){var d=this,u="";d.next=function(){var c=d.b,h=d.c,f=d.d,m=d.a;return c=c<<25^c>>>7^h,h=h-f|0,f=f<<24^f>>>8^m,m=m-c|0,d.b=c=c<<20^c>>>12^h,d.c=h=h-f|0,d.d=f<<16^h>>>16^m,d.a=m-c|0},d.a=0,d.b=0,d.c=2654435769|0,d.d=1367130551,l===Math.floor(l)?(d.a=l/4294967296|0,d.b=l|0):u+=l;for(var p=0;p<u.length+20;p++)d.b^=u.charCodeAt(p)|0,d.next()}function i(l,d){return d.a=l.a,d.b=l.b,d.c=l.c,d.d=l.d,d}function o(l,d){var u=new s(l),p=d&&d.state,c=function(){return(u.next()>>>0)/4294967296};return c.double=function(){do var h=u.next()>>>11,f=(u.next()>>>0)/4294967296,m=(h+f)/(1<<21);while(m===0);return m},c.int32=u.next,c.quick=c,p&&(typeof p=="object"&&i(p,u),c.state=function(){return i(u,{})}),c}a&&a.exports?a.exports=o:r&&r.amd?r(function(){return o}):this.tychei=o})(e,typeof t=="object"&&t,typeof define=="function"&&define)}),P5=Nt(()=>{}),lN=Nt((e,t)=>{(function(n,a){var r=this,s=256,i=6,o=52,l="random",d=a.pow(s,i),u=a.pow(2,o),p=u*2,c=s-1,h;function f(v,k,T){var C=[];k=k==!0?{entropy:!0}:k||{};var D=A(y(k.entropy?[v,b(n)]:v==null?x():v,3),C),O=new m(C),F=function(){for(var S=O.g(i),P=d,_=0;S<u;)S=(S+_)*s,P*=s,_=O.g(1);for(;S>=p;)S/=2,P/=2,_>>>=1;return(S+_)/P};return F.int32=function(){return O.g(4)|0},F.quick=function(){return O.g(4)/4294967296},F.double=F,A(b(O.S),n),(k.pass||T||function(S,P,_,j){return j&&(j.S&&g(j,O),S.state=function(){return g(O,{})}),_?(a[l]=S,P):S})(F,D,"global"in k?k.global:this==a,k.state)}a["seed"+l]=f;function m(v){var k,T=v.length,C=this,D=0,O=C.i=C.j=0,F=C.S=[];for(T||(v=[T++]);D<s;)F[D]=D++;for(D=0;D<s;D++)F[D]=F[O=c&O+v[D%T]+(k=F[D])],F[O]=k;(C.g=function(S){for(var P,_=0,j=C.i,q=C.j,z=C.S;S--;)P=z[j=c&j+1],_=_*s+z[c&(z[j]=z[q=c&q+P])+(z[q]=P)];return C.i=j,C.j=q,_})(s)}function g(v,k){return k.i=v.i,k.j=v.j,k.S=v.S.slice(),k}function y(v,k){var T=[],C=typeof v,D;if(k&&C=="object")for(D in v)try{T.push(y(v[D],k-1))}catch(O){}return T.length?T:C=="string"?v:v+"\0"}function A(v,k){for(var T=v+"",C,D=0;D<T.length;)k[c&D]=c&(C^=k[c&D]*19)+T.charCodeAt(D++);return b(k)}function x(){try{var v;return h&&(v=h.randomBytes)?v=v(s):(v=new Uint8Array(s),(r.crypto||r.msCrypto).getRandomValues(v)),b(v)}catch(C){var k=r.navigator,T=k&&k.plugins;return[+new Date,r,T,r.screen,b(n)]}}function b(v){return String.fromCharCode.apply(0,v)}if(A(a.random(),n),typeof t=="object"&&t.exports){t.exports=f;try{h=P5()}catch(v){}}else typeof define=="function"&&define.amd&&define(function(){return f})})([],Math)}),z5=Nt((e,t)=>{var n=nN(),a=aN(),r=rN(),s=sN(),i=iN(),o=oN(),l=lN();l.alea=n,l.xor128=a,l.xorwow=r,l.xorshift7=s,l.xor4096=i,l.tychei=o,t.exports=l}),uN=Nt((e,t)=>{(function(n,a,r){function s(d){var u=this,p=l();u.next=function(){var c=2091639*u.s0+u.c*23283064365386963e-26;return u.s0=u.s1,u.s1=u.s2,u.s2=c-(u.c=c|0)},u.c=1,u.s0=p(" "),u.s1=p(" "),u.s2=p(" "),u.s0-=p(d),u.s0<0&&(u.s0+=1),u.s1-=p(d),u.s1<0&&(u.s1+=1),u.s2-=p(d),u.s2<0&&(u.s2+=1),p=null}function i(d,u){return u.c=d.c,u.s0=d.s0,u.s1=d.s1,u.s2=d.s2,u}function o(d,u){var p=new s(d),c=u&&u.state,h=p.next;return h.int32=function(){return p.next()*4294967296|0},h.double=function(){return h()+(h()*2097152|0)*11102230246251565e-32},h.quick=h,c&&(typeof c=="object"&&i(c,p),h.state=function(){return i(p,{})}),h}function l(){var d=4022871197,u=function(p){p=String(p);for(var c=0;c<p.length;c++){d+=p.charCodeAt(c);var h=.02519603282416938*d;d=h>>>0,h-=d,h*=d,d=h>>>0,h-=d,d+=h*4294967296}return(d>>>0)*23283064365386963e-26};return u}a&&a.exports?a.exports=o:r&&r.amd?r(function(){return o}):this.alea=o})(e,typeof t=="object"&&t,typeof define=="function"&&define)}),dN=Nt((e,t)=>{(function(n,a,r){function s(l){var d=this,u="";d.x=0,d.y=0,d.z=0,d.w=0,d.next=function(){var c=d.x^d.x<<11;return d.x=d.y,d.y=d.z,d.z=d.w,d.w^=d.w>>>19^c^c>>>8},l===(l|0)?d.x=l:u+=l;for(var p=0;p<u.length+64;p++)d.x^=u.charCodeAt(p)|0,d.next()}function i(l,d){return d.x=l.x,d.y=l.y,d.z=l.z,d.w=l.w,d}function o(l,d){var u=new s(l),p=d&&d.state,c=function(){return(u.next()>>>0)/4294967296};return c.double=function(){do var h=u.next()>>>11,f=(u.next()>>>0)/4294967296,m=(h+f)/(1<<21);while(m===0);return m},c.int32=u.next,c.quick=c,p&&(typeof p=="object"&&i(p,u),c.state=function(){return i(u,{})}),c}a&&a.exports?a.exports=o:r&&r.amd?r(function(){return o}):this.xor128=o})(e,typeof t=="object"&&t,typeof define=="function"&&define)}),pN=Nt((e,t)=>{(function(n,a,r){function s(l){var d=this,u="";d.next=function(){var c=d.x^d.x>>>2;return d.x=d.y,d.y=d.z,d.z=d.w,d.w=d.v,(d.d=d.d+362437|0)+(d.v=d.v^d.v<<4^(c^c<<1))|0},d.x=0,d.y=0,d.z=0,d.w=0,d.v=0,l===(l|0)?d.x=l:u+=l;for(var p=0;p<u.length+64;p++)d.x^=u.charCodeAt(p)|0,p==u.length&&(d.d=d.x<<10^d.x>>>4),d.next()}function i(l,d){return d.x=l.x,d.y=l.y,d.z=l.z,d.w=l.w,d.v=l.v,d.d=l.d,d}function o(l,d){var u=new s(l),p=d&&d.state,c=function(){return(u.next()>>>0)/4294967296};return c.double=function(){do var h=u.next()>>>11,f=(u.next()>>>0)/4294967296,m=(h+f)/(1<<21);while(m===0);return m},c.int32=u.next,c.quick=c,p&&(typeof p=="object"&&i(p,u),c.state=function(){return i(u,{})}),c}a&&a.exports?a.exports=o:r&&r.amd?r(function(){return o}):this.xorwow=o})(e,typeof t=="object"&&t,typeof define=="function"&&define)}),cN=Nt((e,t)=>{(function(n,a,r){function s(l){var d=this;d.next=function(){var p=d.x,c=d.i,h,f,m;return h=p[c],h^=h>>>7,f=h^h<<24,h=p[c+1&7],f^=h^h>>>10,h=p[c+3&7],f^=h^h>>>3,h=p[c+4&7],f^=h^h<<7,h=p[c+7&7],h=h^h<<13,f^=h^h<<9,p[c]=f,d.i=c+1&7,f};function u(p,c){var h,f,m=[];if(c===(c|0))f=m[0]=c;else for(c=""+c,h=0;h<c.length;++h)m[h&7]=m[h&7]<<15^c.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],p.x=m,p.i=0,h=256;h>0;--h)p.next()}u(d,l)}function i(l,d){return d.x=l.x.slice(),d.i=l.i,d}function o(l,d){l==null&&(l=+new Date);var u=new s(l),p=d&&d.state,c=function(){return(u.next()>>>0)/4294967296};return c.double=function(){do var h=u.next()>>>11,f=(u.next()>>>0)/4294967296,m=(h+f)/(1<<21);while(m===0);return m},c.int32=u.next,c.quick=c,p&&(p.x&&i(p,u),c.state=function(){return i(u,{})}),c}a&&a.exports?a.exports=o:r&&r.amd?r(function(){return o}):this.xorshift7=o})(e,typeof t=="object"&&t,typeof define=="function"&&define)}),hN=Nt((e,t)=>{(function(n,a,r){function s(l){var d=this;d.next=function(){var p=d.w,c=d.X,h=d.i,f,m;return d.w=p=p+1640531527|0,m=c[h+34&127],f=c[h=h+1&127],m^=m<<13,f^=f<<17,m^=m>>>15,f^=f>>>12,m=c[h]=m^f,d.i=h,m+(p^p>>>16)|0};function u(p,c){var h,f,m,g,y,A=[],x=128;for(c===(c|0)?(f=c,c=null):(c=c+"\0",f=0,x=Math.max(x,c.length)),m=0,g=-32;g<x;++g)c&&(f^=c.charCodeAt((g+32)%c.length)),g===0&&(y=f),f^=f<<10,f^=f>>>15,f^=f<<4,f^=f>>>13,g>=0&&(y=y+1640531527|0,h=A[g&127]^=f+y,m=h==0?m+1:0);for(m>=128&&(A[(c&&c.length||0)&127]=-1),m=127,g=4*128;g>0;--g)f=A[m+34&127],h=A[m=m+1&127],f^=f<<13,h^=h<<17,f^=f>>>15,h^=h>>>12,A[m]=f^h;p.w=y,p.X=A,p.i=m}u(d,l)}function i(l,d){return d.i=l.i,d.w=l.w,d.X=l.X.slice(),d}function o(l,d){l==null&&(l=+new Date);var u=new s(l),p=d&&d.state,c=function(){return(u.next()>>>0)/4294967296};return c.double=function(){do var h=u.next()>>>11,f=(u.next()>>>0)/4294967296,m=(h+f)/(1<<21);while(m===0);return m},c.int32=u.next,c.quick=c,p&&(p.X&&i(p,u),c.state=function(){return i(u,{})}),c}a&&a.exports?a.exports=o:r&&r.amd?r(function(){return o}):this.xor4096=o})(e,typeof t=="object"&&t,typeof define=="function"&&define)}),fN=Nt((e,t)=>{(function(n,a,r){function s(l){var d=this,u="";d.next=function(){var c=d.b,h=d.c,f=d.d,m=d.a;return c=c<<25^c>>>7^h,h=h-f|0,f=f<<24^f>>>8^m,m=m-c|0,d.b=c=c<<20^c>>>12^h,d.c=h=h-f|0,d.d=f<<16^h>>>16^m,d.a=m-c|0},d.a=0,d.b=0,d.c=2654435769|0,d.d=1367130551,l===Math.floor(l)?(d.a=l/4294967296|0,d.b=l|0):u+=l;for(var p=0;p<u.length+20;p++)d.b^=u.charCodeAt(p)|0,d.next()}function i(l,d){return d.a=l.a,d.b=l.b,d.c=l.c,d.d=l.d,d}function o(l,d){var u=new s(l),p=d&&d.state,c=function(){return(u.next()>>>0)/4294967296};return c.double=function(){do var h=u.next()>>>11,f=(u.next()>>>0)/4294967296,m=(h+f)/(1<<21);while(m===0);return m},c.int32=u.next,c.quick=c,p&&(typeof p=="object"&&i(p,u),c.state=function(){return i(u,{})}),c}a&&a.exports?a.exports=o:r&&r.amd?r(function(){return o}):this.tychei=o})(e,typeof t=="object"&&t,typeof define=="function"&&define)}),mN=Nt((e,t)=>{(function(n,a,r){var s=256,i=6,o=52,l="random",d=r.pow(s,i),u=r.pow(2,o),p=u*2,c=s-1,h;function f(v,k,T){var C=[];k=k==!0?{entropy:!0}:k||{};var D=A(y(k.entropy?[v,b(a)]:v==null?x():v,3),C),O=new m(C),F=function(){for(var S=O.g(i),P=d,_=0;S<u;)S=(S+_)*s,P*=s,_=O.g(1);for(;S>=p;)S/=2,P/=2,_>>>=1;return(S+_)/P};return F.int32=function(){return O.g(4)|0},F.quick=function(){return O.g(4)/4294967296},F.double=F,A(b(O.S),a),(k.pass||T||function(S,P,_,j){return j&&(j.S&&g(j,O),S.state=function(){return g(O,{})}),_?(r[l]=S,P):S})(F,D,"global"in k?k.global:this==r,k.state)}function m(v){var k,T=v.length,C=this,D=0,O=C.i=C.j=0,F=C.S=[];for(T||(v=[T++]);D<s;)F[D]=D++;for(D=0;D<s;D++)F[D]=F[O=c&O+v[D%T]+(k=F[D])],F[O]=k;(C.g=function(S){for(var P,_=0,j=C.i,q=C.j,z=C.S;S--;)P=z[j=c&j+1],_=_*s+z[c&(z[j]=z[q=c&q+P])+(z[q]=P)];return C.i=j,C.j=q,_})(s)}function g(v,k){return k.i=v.i,k.j=v.j,k.S=v.S.slice(),k}function y(v,k){var T=[],C=typeof v,D;if(k&&C=="object")for(D in v)try{T.push(y(v[D],k-1))}catch(O){}return T.length?T:C=="string"?v:v+"\0"}function A(v,k){for(var T=v+"",C,D=0;D<T.length;)k[c&D]=c&(C^=k[c&D]*19)+T.charCodeAt(D++);return b(k)}function x(){try{var v;return h&&(v=h.randomBytes)?v=v(s):(v=new Uint8Array(s),(n.crypto||n.msCrypto).getRandomValues(v)),b(v)}catch(C){var k=n.navigator,T=k&&k.plugins;return[+new Date,n,T,n.screen,b(a)]}}function b(v){return String.fromCharCode.apply(0,v)}if(A(r.random(),a),typeof t=="object"&&t.exports){t.exports=f;try{h=P5()}catch(v){}}else typeof define=="function"&&define.amd?define(function(){return f}):r["seed"+l]=f})(typeof self!="undefined"?self:e,[],Math)}),L5=Nt((e,t)=>{var n=uN(),a=dN(),r=pN(),s=cN(),i=hN(),o=fN(),l=mN();l.alea=n,l.xor128=a,l.xorwow=r,l.xorshift7=s,l.xor4096=i,l.tychei=o,t.exports=l}),W5=Nt(()=>{}),hd=Nt(()=>{}),gN=Nt(()=>{}),yN=Nt(()=>{}),AN=Nt((e,t)=>{var n=function(){var a=typeof document!="undefined"&&document.currentScript?document.currentScript.src:void 0;return typeof __filename!="undefined"&&(a=a||__filename),function(r){r=r||{};function s(){return se.buffer!=It&&Un(se.buffer),Mt}function i(){return se.buffer!=It&&Un(se.buffer),aa}function o(){return se.buffer!=It&&Un(se.buffer),xa}function l(){return se.buffer!=It&&Un(se.buffer),Bn}function d(){return se.buffer!=It&&Un(se.buffer),ba}var u=typeof r!="undefined"?r:{},p,c;u.ready=new Promise(function(N,R){p=N,c=R});var h={},f;for(f in u)u.hasOwnProperty(f)&&(h[f]=u[f]);var m=[],g="./this.program",y=function(N,R){throw R},A=!1,x=!1,b=!1,v=!1;A=typeof window=="object",x=typeof importScripts=="function",b=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string",v=!A&&!b&&!x;var k=u.ENVIRONMENT_IS_PTHREAD||!1;k&&(It=u.buffer);var T="";function C(N){return u.locateFile?u.locateFile(N,T):T+N}var D,O,F,S,P,_;if(b){x?T=hd().dirname(T)+"/":T=__dirname+"/",D=function(N,R){return P||(P=Ho("fs")),_||(_=hd()),N=_.normalize(N),P.readFileSync(N,R?null:"utf8")},F=function(N){var R=D(N,!0);return R.buffer||(R=new Uint8Array(R)),ke(R.buffer),R},process.argv.length>1&&(g=process.argv[1].replace(/\\/g,"/")),m=process.argv.slice(2),process.on("uncaughtException",function(N){if(!(N instanceof ld))throw N}),process.on("unhandledRejection",Rr),y=function(N){process.exit(N)},u.inspect=function(){return"[Emscripten Module object]"};var j;try{j=gN()}catch(N){throw console.error('The "worker_threads" module is not supported in this node.js build - perhaps a newer version is needed?'),N}global.Worker=j.Worker}else v?(typeof read!="undefined"&&(D=function(N){return read(N)}),F=function(N){var R;return typeof readbuffer=="function"?new Uint8Array(readbuffer(N)):(R=read(N,"binary"),ke(typeof R=="object"),R)},typeof scriptArgs!="undefined"?m=scriptArgs:typeof arguments!="undefined"&&(m=arguments),typeof quit=="function"&&(y=function(N){quit(N)}),typeof print!="undefined"&&(typeof console=="undefined"&&(console={}),console.log=print,console.warn=console.error=typeof printErr!="undefined"?printErr:print)):(A||x)&&(x?T=self.location.href:typeof document!="undefined"&&document.currentScript&&(T=document.currentScript.src),typeof a!="undefined"&&a&&(T=a),T.indexOf("blob:")!==0?T=T.substr(0,T.lastIndexOf("/")+1):T="",b?(D=function(N,R){return P||(P=Ho("fs")),_||(_=hd()),N=_.normalize(N),P.readFileSync(N,R?null:"utf8")},F=function(N){var R=D(N,!0);return R.buffer||(R=new Uint8Array(R)),ke(R.buffer),R}):(D=function(N){var R=new XMLHttpRequest;return R.open("GET",N,!1),R.send(null),R.responseText},x&&(F=function(N){var R=new XMLHttpRequest;return R.open("GET",N,!1),R.responseType="arraybuffer",R.send(null),new Uint8Array(R.response)}),O=function(N,R,U){var K=new XMLHttpRequest;K.open("GET",N,!0),K.responseType="arraybuffer",K.onload=function(){if(K.status==200||K.status==0&&K.response){R(K.response);return}U()},K.onerror=U,K.send(null)}),S=function(N){document.title=N});b&&typeof performance=="undefined"&&(global.performance=yN().performance);var q=u.print||console.log.bind(console),z=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&&(y=u.quit);function X(N){X.shown||(X.shown={}),X.shown[N]||(X.shown[N]=1,z(N))}var Z=Atomics.load,te=Atomics.store,J=Atomics.compareExchange,re;u.wasmBinary&&(re=u.wasmBinary);var Y=u.noExitRuntime||!0;typeof WebAssembly!="object"&&Rr("no native wasm support detected");var se,de,be=!1,ve;function ke(N,R){N||Rr("Assertion failed: "+R)}function Ee(N){var R=u["_"+N];return ke(R,"Cannot call unknown function "+N+", make sure it is exported"),R}function _e(N,R,U,K,ye){var fe={string:function(qn){var Go=0;if(qn!=null&&qn!==0){var $5=(qn.length<<2)+1;Go=Vo($5),dt(qn,Go,$5)}return Go},array:function(qn){var Go=Vo(qn.length);return xt(qn,Go),Go}};function me(qn){return R==="string"?Xe(qn):R==="boolean"?Boolean(qn):qn}var Ne=Ee(N),lt=[],ln=0;if(K)for(var Yt=0;Yt<K.length;Yt++){var as=fe[U[Yt]];as?(ln===0&&(ln=od()),lt[Yt]=as(K[Yt])):lt[Yt]=K[Yt]}var jo=Ne.apply(null,lt);return jo=me(jo),ln!==0&&Bo(ln),jo}function We(N,R,U,K){U=U||[];var ye=U.every(function(me){return me==="number"}),fe=R!=="string";return fe&&ye&&!K?Ee(N):function(){return _e(N,R,U,arguments,K)}}function Ue(N,R,U){for(var K=R+U,ye="";!(R>=K);){var fe=N[R++];if(!fe)return ye;if(!(fe&128)){ye+=String.fromCharCode(fe);continue}var me=N[R++]&63;if((fe&224)==192){ye+=String.fromCharCode((fe&31)<<6|me);continue}var Ne=N[R++]&63;if((fe&240)==224?fe=(fe&15)<<12|me<<6|Ne:fe=(fe&7)<<18|me<<12|Ne<<6|N[R++]&63,fe<65536)ye+=String.fromCharCode(fe);else{var lt=fe-65536;ye+=String.fromCharCode(55296|lt>>10,56320|lt&1023)}}return ye}function Xe(N,R){return N?Ue(i(),N,R):""}function ut(N,R,U,K){if(!(K>0))return 0;for(var ye=U,fe=U+K-1,me=0;me<N.length;++me){var Ne=N.charCodeAt(me);if(Ne>=55296&&Ne<=57343){var lt=N.charCodeAt(++me);Ne=65536+((Ne&1023)<<10)|lt&1023}if(Ne<=127){if(U>=fe)break;R[U++]=Ne}else if(Ne<=2047){if(U+1>=fe)break;R[U++]=192|Ne>>6,R[U++]=128|Ne&63}else if(Ne<=65535){if(U+2>=fe)break;R[U++]=224|Ne>>12,R[U++]=128|Ne>>6&63,R[U++]=128|Ne&63}else{if(U+3>=fe)break;R[U++]=240|Ne>>18,R[U++]=128|Ne>>12&63,R[U++]=128|Ne>>6&63,R[U++]=128|Ne&63}}return R[U]=0,U-ye}function dt(N,R,U){return ut(N,i(),R,U)}function at(N){for(var R=0,U=0;U<N.length;++U){var K=N.charCodeAt(U);K>=55296&&K<=57343&&(K=65536+((K&1023)<<10)|N.charCodeAt(++U)&1023),K<=127?++R:K<=2047?R+=2:K<=65535?R+=3:R+=4}return R}function xt(N,R){s().set(N,R)}function ft(N,R){return N%R>0&&(N+=R-N%R),N}var It,Mt,aa,gn,ra,xa,Bn,Vn,ba;function Un(N){It=N,u.HEAP8=Mt=new Int8Array(N),u.HEAP16=gn=new Int16Array(N),u.HEAP32=xa=new Int32Array(N),u.HEAPU8=aa=new Uint8Array(N),u.HEAPU16=ra=new Uint16Array(N),u.HEAPU32=Bn=new Uint32Array(N),u.HEAPF32=Vn=new Float32Array(N),u.HEAPF64=ba=new Float64Array(N)}var Er=u.INITIAL_MEMORY||16777216;if(k)se=u.wasmMemory,It=u.buffer;else if(u.wasmMemory)se=u.wasmMemory;else if(se=new WebAssembly.Memory({initial:Er/65536,maximum:2147483648/65536,shared:!0}),!(se.buffer instanceof SharedArrayBuffer))throw z("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");se&&(It=se.buffer),Er=It.byteLength,Un(It);var jn,Zr=[],dr=[],Yr=[],Yu=[],qa=[],lc=!1,sm=!1;k||dr.push({func:function(){Nc()}});function uc(){if(!k){if(u.preRun)for(typeof u.preRun=="function"&&(u.preRun=[u.preRun]);u.preRun.length;)im(u.preRun.shift());zo(Zr)}}function dc(){lc=!0,!k&&zo(dr)}function pc(){k||zo(Yr)}function Gn(){k||(sm=!0)}function cc(){if(!k){if(u.postRun)for(typeof u.postRun=="function"&&(u.postRun=[u.postRun]);u.postRun.length;)om(u.postRun.shift());zo(qa)}}function im(N){Zr.unshift(N)}function om(N){qa.unshift(N)}var $a=0,Ju=null,Us=null;function lm(N){ke(!k,"addRunDependency cannot be used in a pthread worker"),$a++,u.monitorRunDependencies&&u.monitorRunDependencies($a)}function um(N){if($a--,u.monitorRunDependencies&&u.monitorRunDependencies($a),$a==0&&(Ju!==null&&(clearInterval(Ju),Ju=null),Us)){var R=Us;Us=null,R()}}u.preloadedImages={},u.preloadedAudios={};function Rr(N){u.onAbort&&u.onAbort(N),k&&console.error("Pthread aborting at "+new Error().stack),N+="",z(N),be=!0,ve=1,N="abort("+N+"). Build with -s ASSERTIONS=1 for more info.";var R=new WebAssembly.RuntimeError(N);throw c(R),R}function js(N,R){return String.prototype.startsWith?N.startsWith(R):N.indexOf(R)===0}var dm="data:application/octet-stream;base64,";function hc(N){return js(N,dm)}var pm="file://";function fc(N){return js(N,pm)}var Hn="tfjs-backend-wasm-threaded-simd.wasm";hc(Hn)||(Hn=C(Hn));function mc(N){try{if(N==Hn&&re)return new Uint8Array(re);if(F)return F(N);throw"both async and sync fetching of the wasm failed"}catch(R){Rr(R)}}function cm(){if(!re&&(A||x)){if(typeof fetch=="function"&&!fc(Hn))return fetch(Hn,{credentials:"same-origin"}).then(function(N){if(!N.ok)throw"failed to load wasm binary file at '"+Hn+"'";return N.arrayBuffer()}).catch(function(){return mc(Hn)});if(O)return new Promise(function(N,R){O(Hn,function(U){N(new Uint8Array(U))},R)})}return Promise.resolve().then(function(){return mc(Hn)})}function hm(){var N={a:s1};function R(me,Ne){var lt=me.exports;if(u.asm=lt,jn=u.asm.I,de=Ne,!k){var ln=Re.unusedWorkers.length;Re.unusedWorkers.forEach(function(Yt){Re.loadWasmModuleToWorker(Yt,function(){--ln||um("wasm-instantiate")})})}}k||lm("wasm-instantiate");function U(me){R(me.instance,me.module)}function K(me){return cm().then(function(Ne){return WebAssembly.instantiate(Ne,N)}).then(me,function(Ne){z("failed to asynchronously prepare wasm: "+Ne),Rr(Ne)})}function ye(){return!re&&typeof WebAssembly.instantiateStreaming=="function"&&!hc(Hn)&&!fc(Hn)&&typeof fetch=="function"?fetch(Hn,{credentials:"same-origin"}).then(function(me){var Ne=WebAssembly.instantiateStreaming(me,N);return Ne.then(U,function(lt){return z("wasm streaming compile failed: "+lt),z("falling back to ArrayBuffer instantiation"),K(U)})}):K(U)}if(u.instantiateWasm)try{var fe=u.instantiateWasm(N,R);return fe}catch(me){return z("Module.instantiateWasm callback failed with error: "+me),!1}return ye().catch(c),{}}var fm={10520:function(){throw"Canceled!"},10538:function(N,R){setTimeout(function(){C5(N,R)},0)}};function gc(){Re.initRuntime()}function zo(N){for(;N.length>0;){var R=N.shift();if(typeof R=="function"){R(u);continue}var U=R.func;typeof U=="number"?R.arg===void 0?jn.get(U)():jn.get(U)(R.arg):U(R.arg===void 0?null:R.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 Qu(N,R){if(N<=0||N>s().length||N&!0||R<0)return-28;if(R==0)return 0;R>=2147483647&&(R=1/0);var U=Atomics.load(o(),Uo>>2),K=0;if(U==N){var ye=Atomics.compareExchange(o(),Uo>>2,U,0);if(ye==U&&(--R,K=1,R<=0))return 1}var fe=Atomics.notify(o(),N>>2,R);if(fe>=0)return fe+K;throw"Atomics.notify returned an unexpected value "+fe}u._emscripten_futex_wake=Qu;function mm(N){if(k)throw"Internal Error! killThread() can only ever be called from main application thread!";if(!N)throw"Internal Error! Null pthread_ptr in killThread!";o()[N+12>>2]=0;var R=Re.pthreads[N];R.worker.terminate(),Re.freeThreadData(R),Re.runningWorkers.splice(Re.runningWorkers.indexOf(R.worker),1),R.worker.pthread=void 0}function gm(N){if(k)throw"Internal Error! cancelThread() can only ever be called from main application thread!";if(!N)throw"Internal Error! Null pthread_ptr in cancelThread!";var R=Re.pthreads[N];R.worker.postMessage({cmd:"cancel"})}function yc(N){if(k)throw"Internal Error! cleanupThread() can only ever be called from main application thread!";if(!N)throw"Internal Error! Null pthread_ptr in cleanupThread!";var R=Re.pthreads[N];if(R){o()[N+12>>2]=0;var U=R.worker;Re.returnWorkerToPool(U)}}var Re={unusedWorkers:[],runningWorkers:[],initMainThreadBlock:function(){for(var N=8,R=0;R<N;++R)Re.allocateUnusedWorker()},initRuntime:function(){for(var N=Hs(228),R=0;R<228/4;++R)l()[N/4+R]=0;o()[N+12>>2]=N;var U=N+152;o()[U>>2]=U;for(var K=Hs(512),R=0;R<128;++R)l()[K/4+R]=0;Atomics.store(l(),N+100>>2,K),Atomics.store(l(),N+40>>2,N),C1(N,!x,1),N5(N)},initWorker:function(){},pthreads:{},threadExitHandlers:[],setThreadStatus:function(){},runExitHandlers:function(){for(;Re.threadExitHandlers.length>0;)Re.threadExitHandlers.pop()();k&&ns()&&S5()},runExitHandlersAndDeinitThread:function(N,R){Atomics.store(l(),N+56>>2,1),Atomics.store(l(),N+60>>2,0),Re.runExitHandlers(),Atomics.store(l(),N+4>>2,R),Atomics.store(l(),N+0>>2,1),Qu(N+0,2147483647),C1(0,0,0)},threadExit:function(N){var R=ns();R&&(Re.runExitHandlersAndDeinitThread(R,N),k&&postMessage({cmd:"exit"}))},threadCancel:function(){Re.runExitHandlersAndDeinitThread(ns(),-1),postMessage({cmd:"cancelDone"})},terminateAllThreads:function(){for(var N in Re.pthreads){var R=Re.pthreads[N];R&&R.worker&&Re.returnWorkerToPool(R.worker)}Re.pthreads={};for(var U=0;U<Re.unusedWorkers.length;++U){var K=Re.unusedWorkers[U];K.terminate()}Re.unusedWorkers=[];for(var U=0;U<Re.runningWorkers.length;++U){var K=Re.runningWorkers[U],R=K.pthread;Re.freeThreadData(R),K.terminate()}Re.runningWorkers=[]},freeThreadData:function(N){if(N){if(N.threadInfoStruct){var R=o()[N.threadInfoStruct+100>>2];o()[N.threadInfoStruct+100>>2]=0,id(R),id(N.threadInfoStruct)}N.threadInfoStruct=0,N.allocatedOwnStack&&N.stackBase&&id(N.stackBase),N.stackBase=0,N.worker&&(N.worker.pthread=null)}},returnWorkerToPool:function(N){Re.runWithoutMainThreadQueuedCalls(function(){delete Re.pthreads[N.pthread.threadInfoStruct],Re.unusedWorkers.push(N),Re.runningWorkers.splice(Re.runningWorkers.indexOf(N),1),Re.freeThreadData(N.pthread),N.pthread=void 0})},runWithoutMainThreadQueuedCalls:function(N){o()[D5>>2]=0;try{N()}finally{o()[D5>>2]=1}},receiveObjectTransfer:function(N){},loadWasmModuleToWorker:function(N,R){N.onmessage=function(U){var K=U.data,ye=K.cmd;if(N.pthread&&(Re.currentProxiedOperationCallerThread=N.pthread.threadInfoStruct),K.targetThread&&K.targetThread!=ns()){var fe=Re.pthreads[K.targetThread];fe?fe.worker.postMessage(U.data,K.transferList):console.error('Internal error! Worker sent a message "'+ye+'" to target pthread '+K.targetThread+", but that thread no longer exists!"),Re.currentProxiedOperationCallerThread=void 0;return}if(ye==="processQueuedMainThreadWork")Fc();else if(ye==="spawnThread")Ic(U.data);else if(ye==="cleanupThread")yc(K.thread);else if(ye==="killThread")mm(K.thread);else if(ye==="cancelThread")gm(K.thread);else if(ye==="loaded")N.loaded=!0,R&&R(N),N.runPthread&&(N.runPthread(),delete N.runPthread);else if(ye==="print")q("Thread "+K.threadId+": "+K.text);else if(ye==="printErr")z("Thread "+K.threadId+": "+K.text);else if(ye==="alert")alert("Thread "+K.threadId+": "+K.text);else if(ye==="exit"){var me=N.pthread&&Atomics.load(l(),N.pthread.threadInfoStruct+64>>2);me&&Re.returnWorkerToPool(N)}else if(ye==="exitProcess")try{GS(K.returnCode)}catch(Ne){if(Ne instanceof ld)return;throw Ne}else ye==="cancelDone"?Re.returnWorkerToPool(N):ye==="objectTransfer"?Re.receiveObjectTransfer(U.data):U.data.target==="setimmediate"?N.postMessage(U.data):z("worker sent an unknown command "+ye);Re.currentProxiedOperationCallerThread=void 0},N.onerror=function(U){z("pthread sent an error! "+U.filename+":"+U.lineno+": "+U.message)},b&&(N.on("message",function(U){N.onmessage({data:U})}),N.on("error",function(U){N.onerror(U)}),N.on("exit",function(U){})),N.postMessage({cmd:"load",urlOrBlob:u.mainScriptUrlOrBlob||a,wasmMemory:se,wasmModule:de})},allocateUnusedWorker:function(){var N=C("tfjs-backend-wasm-threaded-simd.worker.js");Re.unusedWorkers.push(new Worker(N))},getNewWorker:function(){return Re.unusedWorkers.length==0&&(Re.allocateUnusedWorker(),Re.loadWasmModuleToWorker(Re.unusedWorkers[0])),Re.unusedWorkers.length>0?Re.unusedWorkers.pop():null},busySpinWait:function(N){for(var R=performance.now()+N;performance.now()<R;);}};function ym(N,R){M5(N,R),Bo(N)}u.establishStackSpace=ym;function Am(){return Y}u.getNoExitRuntime=Am;function xm(N,R){return jn.get(N)(R)}u.invokeEntryPoint=xm;function bm(N,R,U,K){Rr("Assertion failed: "+Xe(N)+", at: "+[R?Xe(R):"unknown filename",U,K?Xe(K):"unknown function"])}function vm(N,R){var U=_main(N,R)}var Gs;b?Gs=function(){var N=process.hrtime();return N[0]*1e3+N[1]/1e6}:k?Gs=function(){return performance.now()-u.__performance_now_clock_drift}:typeof dateNow!="undefined"?Gs=dateNow:Gs=function(){return performance.now()};function wm(N){return o()[k5()>>2]=N,N}function km(N,R){if(k)return Qr(1,1,N,R)}function Im(N,R){if(N==R)postMessage({cmd:"processQueuedMainThreadWork"});else if(k)postMessage({targetThread:N,cmd:"processThreadQueue"});else{var U=Re.pthreads[N],K=U&&U.worker;if(!K)return;K.postMessage({cmd:"processThreadQueue"})}return 1}function Sm(){Rr()}function Nm(N,R,U){var K=Rm(R,U);return fm[N].apply(null,K)}function Tm(N,R){}function Ac(N,R,U){if(N<=0||N>s().length||N&!0)return-28;if(A){if(Atomics.load(o(),N>>2)!=R)return-6;for(var K=performance.now(),ye=K+U,fe=Atomics.exchange(o(),Uo>>2,N);;){if(K=performance.now(),K>ye)return fe=Atomics.exchange(o(),Uo>>2,0),-73;if(fe=Atomics.exchange(o(),Uo>>2,0),fe==0)break;if(Fc(),Atomics.load(o(),N>>2)!=R)return-6;fe=Atomics.exchange(o(),Uo>>2,N)}return 0}else{var me=Atomics.wait(o(),N>>2,R,U);if(me==="timed-out")return-73;if(me==="not-equal")return-6;if(me==="ok")return 0;throw"Atomics.wait returned an unexpected value "+me}}function Cm(N,R,U){i().copyWithin(N,R,R+U)}function Em(){return b?Ho("os").cpus().length:navigator.hardwareConcurrency}function Qr(N,R){for(var U=arguments.length-2,K=od(),ye=U,fe=Vo(ye*8),me=fe>>3,Ne=0;Ne<U;Ne++){var lt=arguments[2+Ne];d()[me+Ne]=lt}var ln=R5(N,ye,fe,R);return Bo(K),ln}var ed=[],td=[];function Rm(N,R){td.length=0;var U;for(R>>=2;U=i()[N++];){var K=U<105;K&&R&1&&R++,td.push(K?d()[R++>>1]:o()[R]),++R}return td}function Mm(N,R,U){ed.length=R;for(var K=U>>3,ye=0;ye<R;ye++)ed[ye]=d()[K+ye];var fe=N<0,me=fe?fm[-N-1]:r1[N];return me.apply(null,ed)}function Fm(){return i().length}function Dm(N){try{return se.grow(N-It.byteLength+65535>>>16),Un(se.buffer),1}catch(R){}}function $m(N){var R=Fm();if(N<=R)return!1;var U=2147483648;if(N>U)return!1;for(var K=1;K<=4;K*=2){var ye=R*(1+.2/K);ye=Math.min(ye,N+100663296);var fe=Math.min(U,ft(Math.max(N,ye),65536)),me=Dm(fe);if(me)return!0}return!1}var Be={inEventHandler:0,removeAllEventListeners:function(){for(var N=Be.eventHandlers.length-1;N>=0;--N)Be._removeHandler(N);Be.eventHandlers=[],Be.deferredCalls=[]},registerRemoveEventListeners:function(){Be.removeEventListenersRegistered||(Yu.push(Be.removeAllEventListeners),Be.removeEventListenersRegistered=!0)},deferredCalls:[],deferCall:function(N,R,U){function K(me,Ne){if(me.length!=Ne.length)return!1;for(var lt in me)if(me[lt]!=Ne[lt])return!1;return!0}for(var ye in Be.deferredCalls){var fe=Be.deferredCalls[ye];if(fe.targetFunction==N&&K(fe.argsList,U))return}Be.deferredCalls.push({targetFunction:N,precedence:R,argsList:U}),Be.deferredCalls.sort(function(me,Ne){return me.precedence<Ne.precedence})},removeDeferredCalls:function(N){for(var R=0;R<Be.deferredCalls.length;++R)Be.deferredCalls[R].targetFunction==N&&(Be.deferredCalls.splice(R,1),--R)},canPerformEventHandlerRequests:function(){return Be.inEventHandler&&Be.currentEventHandler.allowsDeferredCalls},runDeferredCalls:function(){if(Be.canPerformEventHandlerRequests())for(var N=0;N<Be.deferredCalls.length;++N){var R=Be.deferredCalls[N];Be.deferredCalls.splice(N,1),--N,R.targetFunction.apply(null,R.argsList)}},eventHandlers:[],removeAllHandlersOnTarget:function(N,R){for(var U=0;U<Be.eventHandlers.length;++U)Be.eventHandlers[U].target==N&&(!R||R==Be.eventHandlers[U].eventTypeString)&&Be._removeHandler(U--)},_removeHandler:function(N){var R=Be.eventHandlers[N];R.target.removeEventListener(R.eventTypeString,R.eventListenerFunc,R.useCapture),Be.eventHandlers.splice(N,1)},registerOrRemoveHandler:function(N){var R=function(K){++Be.inEventHandler,Be.currentEventHandler=N,Be.runDeferredCalls(),N.handlerFunc(K),Be.runDeferredCalls(),--Be.inEventHandler};if(N.callbackfunc)N.eventListenerFunc=R,N.target.addEventListener(N.eventTypeString,R,N.useCapture),Be.eventHandlers.push(N),Be.registerRemoveEventListeners();else for(var U=0;U<Be.eventHandlers.length;++U)Be.eventHandlers[U].target==N.target&&Be.eventHandlers[U].eventTypeString==N.eventTypeString&&Be._removeHandler(U--)},queueEventHandlerOnThread_iiii:function(N,R,U,K,ye){var fe=od(),me=Vo(12);o()[me>>2]=U,o()[me+4>>2]=K,o()[me+8>>2]=ye,T1(0,N,637534208,R,K,me),Bo(fe)},getTargetThreadForEventCallback:function(N){switch(N){case 1:return 0;case 2:return Re.currentProxiedOperationCallerThread;default:return N}},getNodeNameForTarget:function(N){return N?N==window?"#window":N==screen?"#screen":N&&N.nodeName?N.nodeName:"":""},fullscreenEnabled:function(){return document.fullscreenEnabled||document.webkitFullscreenEnabled}};function Om(N){var R=at(N)+1,U=Hs(R);return dt(N,U,R),U}function _m(N,R,U,K){var ye=od(),fe=Vo(12),me=0;R&&(me=Om(R)),o()[fe>>2]=me,o()[fe+4>>2]=U,o()[fe+8>>2]=K,T1(0,N,657457152,0,me,fe),Bo(ye)}function Pm(N,R,U,K){R=R?Xe(R):"",_m(N,R,U,K)}function zm(N){return N>2?Xe(N):N}var Lm=[0,typeof document!="undefined"?document:0,typeof window!="undefined"?window:0];function Wm(N){N=zm(N);var R=Lm[N]||(typeof document!="undefined"?document.querySelector(N):void 0);return R}function nd(N){return Wm(N)}function xc(N,R,U){var K=nd(N);if(!K)return-4;if(K.canvasSharedPtr&&(o()[K.canvasSharedPtr>>2]=R,o()[K.canvasSharedPtr+4>>2]=U),K.offscreenCanvas||!K.controlTransferredOffscreen){K.offscreenCanvas&&(K=K.offscreenCanvas);var ye=!1;if(K.GLctxObject&&K.GLctxObject.GLctx){var fe=K.GLctxObject.GLctx.getParameter(2978);ye=fe[0]===0&&fe[1]===0&&fe[2]===K.width&&fe[3]===K.height}K.width=R,K.height=U,ye&&K.GLctxObject.GLctx.viewport(0,0,R,U)}else if(K.canvasSharedPtr){var me=o()[K.canvasSharedPtr+8>>2];return Pm(me,N,R,U),1}else return-4;return 0}function bc(N,R,U){return k?Qr(2,1,N,R,U):xc(N,R,U)}function Bm(N,R,U){var K=nd(N);return K?xc(N,R,U):bc(N,R,U)}function Vm(N){}function Um(N,R){}function jm(N){var R=N.getExtension("ANGLE_instanced_arrays");if(R)return N.vertexAttribDivisor=function(U,K){R.vertexAttribDivisorANGLE(U,K)},N.drawArraysInstanced=function(U,K,ye,fe){R.drawArraysInstancedANGLE(U,K,ye,fe)},N.drawElementsInstanced=function(U,K,ye,fe,me){R.drawElementsInstancedANGLE(U,K,ye,fe,me)},1}function Gm(N){var R=N.getExtension("OES_vertex_array_object");if(R)return N.createVertexArray=function(){return R.createVertexArrayOES()},N.deleteVertexArray=function(U){R.deleteVertexArrayOES(U)},N.bindVertexArray=function(U){R.bindVertexArrayOES(U)},N.isVertexArray=function(U){return R.isVertexArrayOES(U)},1}function Hm(N){var R=N.getExtension("WEBGL_draw_buffers");if(R)return N.drawBuffers=function(U,K){R.drawBuffersWEBGL(U,K)},1}function qm(N){return!!(N.multiDrawWebgl=N.getExtension("WEBGL_multi_draw"))}var ot={counter:1,buffers:[],programs:[],framebuffers:[],renderbuffers:[],textures:[],uniforms:[],shaders:[],vaos:[],contexts:{},offscreenCanvases:{},timerQueriesEXT:[],programInfos:{},stringCache:{},unpackAlignment:4,recordError:function(N){ot.lastError||(ot.lastError=N)},getNewId:function(N){for(var R=ot.counter++,U=N.length;U<R;U++)N[U]=null;return R},getSource:function(N,R,U,K){for(var ye="",fe=0;fe<R;++fe){var me=K?o()[K+fe*4>>2]:-1;ye+=Xe(o()[U+fe*4>>2],me<0?void 0:me)}return ye},createContext:function(N,R){var U=N.getContext("webgl",R);if(!U)return 0;var K=ot.registerContext(U,R);return K},registerContext:function(N,R){var U=Hs(8);o()[U+4>>2]=ns();var K={handle:U,attributes:R,version:R.majorVersion,GLctx:N};return N.canvas&&(N.canvas.GLctxObject=K),ot.contexts[U]=K,(typeof R.enableExtensionsByDefault=="undefined"||R.enableExtensionsByDefault)&&ot.initExtensions(K),U},makeContextCurrent:function(N){return ot.currentContext=ot.contexts[N],u.ctx=es=ot.currentContext&&ot.currentContext.GLctx,!(N&&!es)},getContext:function(N){return ot.contexts[N]},deleteContext:function(N){ot.currentContext===ot.contexts[N]&&(ot.currentContext=null),typeof Be=="object"&&Be.removeAllHandlersOnTarget(ot.contexts[N].GLctx.canvas),ot.contexts[N]&&ot.contexts[N].GLctx.canvas&&(ot.contexts[N].GLctx.canvas.GLctxObject=void 0),id(ot.contexts[N].handle),ot.contexts[N]=null},initExtensions:function(N){if(N||(N=ot.currentContext),!N.initExtensionsDone){N.initExtensionsDone=!0;var R=N.GLctx;jm(R),Gm(R),Hm(R),R.disjointTimerQueryExt=R.getExtension("EXT_disjoint_timer_query"),qm(R);var U=R.getSupportedExtensions()||[];U.forEach(function(K){K.indexOf("lose_context")<0&&K.indexOf("debug")<0&&R.getExtension(K)})}},populateUniformTable:function(N){for(var R=ot.programs[N],U=ot.programInfos[N]={uniforms:{},maxUniformLength:0,maxAttributeLength:-1,maxUniformBlockNameLength:-1},K=U.uniforms,ye=es.getProgramParameter(R,35718),fe=0;fe<ye;++fe){var me=es.getActiveUniform(R,fe),Ne=me.name;U.maxUniformLength=Math.max(U.maxUniformLength,Ne.length+1),Ne.slice(-1)=="]"&&(Ne=Ne.slice(0,Ne.lastIndexOf("[")));var lt=es.getUniformLocation(R,Ne);if(lt){var ln=ot.getNewId(ot.uniforms);K[Ne]=[me.size,ln],ot.uniforms[ln]=lt;for(var Yt=1;Yt<me.size;++Yt){var as=Ne+"["+Yt+"]";lt=es.getUniformLocation(R,as),ln=ot.getNewId(ot.uniforms),ot.uniforms[ln]=lt}}}}},Xm=["default","low-power","high-performance"];function Km(N,R){var U=R>>2,K=o()[U+(24>>2)],ye={alpha:!!o()[U+(0>>2)],depth:!!o()[U+(4>>2)],stencil:!!o()[U+(8>>2)],antialias:!!o()[U+(12>>2)],premultipliedAlpha:!!o()[U+(16>>2)],preserveDrawingBuffer:!!o()[U+(20>>2)],powerPreference:Xm[K],failIfMajorPerformanceCaveat:!!o()[U+(28>>2)],majorVersion:o()[U+(32>>2)],minorVersion:o()[U+(36>>2)],enableExtensionsByDefault:o()[U+(40>>2)],explicitSwapControl:o()[U+(44>>2)],proxyContextToMainThread:o()[U+(48>>2)],renderViaOffscreenBackBuffer:o()[U+(52>>2)]},fe=nd(N);if(!fe||ye.explicitSwapControl)return 0;var me=ot.createContext(fe,ye);return me}function Zm(N,R){return Km(N,R)}var Lo={mappings:{},buffers:[null,[],[]],printChar:function(N,R){var U=Lo.buffers[N];R===0||R===10?((N===1?q:z)(Ue(U,0)),U.length=0):U.push(R)},varargs:void 0,get:function(){Lo.varargs+=4;var N=o()[Lo.varargs-4>>2];return N},getStr:function(N){var R=Xe(N);return R},get64:function(N,R){return N}};function vc(N){return k?Qr(3,1,N):0}function wc(N,R,U,K,ye){if(k)return Qr(4,1,N,R,U,K,ye)}function kc(N,R,U,K){if(k)return Qr(5,1,N,R,U,K);for(var ye=0,fe=0;fe<U;fe++){for(var me=o()[R+fe*8>>2],Ne=o()[R+(fe*8+4)>>2],lt=0;lt<Ne;lt++)Lo.printChar(N,i()[me+lt]);ye+=Ne}return o()[K>>2]=ye,0}function Ym(N){var R=Re.threadExitHandlers.pop();N&&R()}function Jm(N,R){Re.threadExitHandlers.push(function(){jn.get(N)(R)})}function Ic(N){if(k)throw"Internal Error! spawnThread() can only ever be called from main application thread!";var R=Re.getNewWorker();if(R.pthread!==void 0)throw"Internal error!";if(!N.pthread_ptr)throw"Internal error, no pthread ptr!";Re.runningWorkers.push(R);for(var U=Hs(128*4),K=0;K<128;++K)o()[U+K*4>>2]=0;var ye=N.stackBase+N.stackSize,fe=Re.pthreads[N.pthread_ptr]={worker:R,stackBase:N.stackBase,stackSize:N.stackSize,allocatedOwnStack:N.allocatedOwnStack,threadInfoStruct:N.pthread_ptr},me=fe.threadInfoStruct>>2;Atomics.store(l(),me+(64>>2),N.detached),Atomics.store(l(),me+(100>>2),U),Atomics.store(l(),me+(40>>2),fe.threadInfoStruct),Atomics.store(l(),me+(80>>2),N.stackSize),Atomics.store(l(),me+(76>>2),ye),Atomics.store(l(),me+(104>>2),N.stackSize),Atomics.store(l(),me+(104+8>>2),ye),Atomics.store(l(),me+(104+12>>2),N.detached);var Ne=I5(),lt=Ne+40;Atomics.store(l(),me+(172>>2),lt),R.pthread=fe;var ln={cmd:"run",start_routine:N.startRoutine,arg:N.arg,threadInfoStruct:N.pthread_ptr,stackBase:N.stackBase,stackSize:N.stackSize};R.runPthread=function(){ln.time=performance.now(),R.postMessage(ln,N.transferList)},R.loaded&&(R.runPthread(),delete R.runPthread)}function Qm(N,R,U,K){if(typeof SharedArrayBuffer=="undefined")return z("Current environment does not support SharedArrayBuffer, pthreads are not available!"),6;if(!N)return z("pthread_create called with a null thread pointer!"),28;var ye=[],fe=0;if(k&&(ye.length===0||fe))return E5(687865856,N,R,U,K);if(fe)return fe;var me=0,Ne=0,lt=0;R&&R!=-1?(me=o()[R>>2],me+=81920,Ne=o()[R+8>>2],lt=o()[R+12>>2]!==0):me=2097152;var ln=Ne==0;ln?Ne=F5(16,me):(Ne-=me,ke(Ne>0));for(var Yt=Hs(228),as=0;as<228>>2;++as)l()[(Yt>>2)+as]=0;o()[N>>2]=Yt,o()[Yt+12>>2]=Yt;var jo=Yt+152;o()[jo>>2]=jo;var qn={stackBase:Ne,stackSize:me,allocatedOwnStack:ln,detached:lt,startRoutine:U,pthread_ptr:Yt,arg:K,transferList:ye};return k?(qn.cmd="spawnThread",postMessage(qn,ye)):Ic(qn),0}function e1(){if(k){var N=ns();if(N){var R=Atomics.load(l(),N+56>>2);if(!R){var U=Atomics.load(l(),N+0>>2);if(U==2)throw"Canceled!"}}}}function t1(){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 n1(N,R,U){if(!N)return z("pthread_join attempted on a null thread pointer!"),Jr.ESRCH;if(k&&ns()==N)return z("PThread "+N+" is attempting to join to itself!"),Jr.EDEADLK;if(!k&&T5()==N)return z("Main thread "+N+" is attempting to join to itself!"),Jr.EDEADLK;var K=o()[N+12>>2];if(K!==N)return z("pthread_join attempted on thread "+N+", which does not point to a valid thread, or does not exist anymore!"),Jr.ESRCH;var ye=Atomics.load(l(),N+64>>2);if(ye)return z("Attempted to join thread "+N+", which was already detached!"),Jr.EINVAL;for(U&&t1();;){var fe=Atomics.load(l(),N+0>>2);if(fe==1){var me=Atomics.load(l(),N+4>>2);return R&&(o()[R>>2]=me),Atomics.store(l(),N+64>>2,1),k?postMessage({cmd:"cleanupThread",thread:N}):yc(N),0}if(!U)return Jr.EBUSY;e1(),k||Fc(),Ac(N+0,fe,k?100:1)}}function a1(N,R){return n1(N,R,!0)}function Sc(N){if(k)return Qr(6,1,N);switch(N){case 30:return 16384;case 85:var R=2147483648;return R/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 wm(28),-1}k||Re.initMainThreadBlock();var es,r1=[null,km,bc,vc,wc,kc,Sc],s1={e:bm,r:vm,x:Im,b:Sm,y:Nm,j:Tm,d:Ac,c:Qu,f:Gs,p:Cm,A:Em,u:Mm,q:$m,v:Bm,i:Vm,s:Um,w:Zm,l:vc,n:wc,g:kc,o:gc,a:se||u.wasmMemory,z:Ym,k:Jm,h:Qm,m:a1,t:Sc},w5=hm(),Nc=u.___wasm_call_ctors=function(){return(Nc=u.___wasm_call_ctors=u.asm.B).apply(null,arguments)},i1=u._init=function(){return(i1=u._init=u.asm.C).apply(null,arguments)},o1=u._init_with_threads_count=function(){return(o1=u._init_with_threads_count=u.asm.D).apply(null,arguments)},l1=u._get_threads_count=function(){return(l1=u._get_threads_count=u.asm.E).apply(null,arguments)},u1=u._register_tensor=function(){return(u1=u._register_tensor=u.asm.F).apply(null,arguments)},d1=u._dispose_data=function(){return(d1=u._dispose_data=u.asm.G).apply(null,arguments)},p1=u._dispose=function(){return(p1=u._dispose=u.asm.H).apply(null,arguments)},c1=u._Abs=function(){return(c1=u._Abs=u.asm.J).apply(null,arguments)},h1=u._Add=function(){return(h1=u._Add=u.asm.K).apply(null,arguments)},f1=u._AddN=function(){return(f1=u._AddN=u.asm.L).apply(null,arguments)},m1=u._All=function(){return(m1=u._All=u.asm.M).apply(null,arguments)},g1=u._Any=function(){return(g1=u._Any=u.asm.N).apply(null,arguments)},y1=u._ArgMax=function(){return(y1=u._ArgMax=u.asm.O).apply(null,arguments)},A1=u._AvgPool=function(){return(A1=u._AvgPool=u.asm.P).apply(null,arguments)},x1=u._BatchMatMul=function(){return(x1=u._BatchMatMul=u.asm.Q).apply(null,arguments)},b1=u._Ceil=function(){return(b1=u._Ceil=u.asm.R).apply(null,arguments)},v1=u._ClipByValue=function(){return(v1=u._ClipByValue=u.asm.S).apply(null,arguments)},w1=u._Conv2D=function(){return(w1=u._Conv2D=u.asm.T).apply(null,arguments)},k1=u._Conv2DBackpropInput=function(){return(k1=u._Conv2DBackpropInput=u.asm.U).apply(null,arguments)},I1=u._Cos=function(){return(I1=u._Cos=u.asm.V).apply(null,arguments)},S1=u._Cosh=function(){return(S1=u._Cosh=u.asm.W).apply(null,arguments)},Tc=u._CropAndResize=function(){return(Tc=u._CropAndResize=u.asm.X).apply(null,arguments)},Cc=u._Cumsum=function(){return(Cc=u._Cumsum=u.asm.Y).apply(null,arguments)},Ec=u._DepthToSpace=function(){return(Ec=u._DepthToSpace=u.asm.Z).apply(null,arguments)},ad=u._DepthwiseConv2dNative=function(){return(ad=u._DepthwiseConv2dNative=u.asm._).apply(null,arguments)},Wo=u._Elu=function(){return(Wo=u._Elu=u.asm.$).apply(null,arguments)},N1=u._Equal=function(){return(N1=u._Equal=u.asm.aa).apply(null,arguments)},rd=u._Exp=function(){return(rd=u._Exp=u.asm.ba).apply(null,arguments)},ee=u._FlipLeftRight=function(){return(ee=u._FlipLeftRight=u.asm.ca).apply(null,arguments)},oe=u._Floor=function(){return(oe=u._Floor=u.asm.da).apply(null,arguments)},Fe=u._FloorDiv=function(){return(Fe=u._FloorDiv=u.asm.ea).apply(null,arguments)},rt=u._FusedBatchNorm=function(){return(rt=u._FusedBatchNorm=u.asm.fa).apply(null,arguments)},_t=u._FusedConv2D=function(){return(_t=u._FusedConv2D=u.asm.ga).apply(null,arguments)},St=u._FusedDepthwiseConv2D=function(){return(St=u._FusedDepthwiseConv2D=u.asm.ha).apply(null,arguments)},Ke=u._Gather=function(){return(Ke=u._Gather=u.asm.ia).apply(null,arguments)},Je=u._GatherNd=function(){return(Je=u._GatherNd=u.asm.ja).apply(null,arguments)},yn=u._Greater=function(){return(yn=u._Greater=u.asm.ka).apply(null,arguments)},Mr=u._GreaterEqual=function(){return(Mr=u._GreaterEqual=u.asm.la).apply(null,arguments)},Fr=u._LeakyRelu=function(){return(Fr=u._LeakyRelu=u.asm.ma).apply(null,arguments)},Rc=u._Less=function(){return(Rc=u._Less=u.asm.na).apply(null,arguments)},sd=u._LessEqual=function(){return(sd=u._LessEqual=u.asm.oa).apply(null,arguments)},va=u._Log=function(){return(va=u._Log=u.asm.pa).apply(null,arguments)},ts=u._LogicalAnd=function(){return(ts=u._LogicalAnd=u.asm.qa).apply(null,arguments)},Mc=u._Max=function(){return(Mc=u._Max=u.asm.ra).apply(null,arguments)},QI=u._MaxPool=function(){return(QI=u._MaxPool=u.asm.sa).apply(null,arguments)},eS=u._Maximum=function(){return(eS=u._Maximum=u.asm.ta).apply(null,arguments)},tS=u._Mean=function(){return(tS=u._Mean=u.asm.ua).apply(null,arguments)},nS=u._Min=function(){return(nS=u._Min=u.asm.va).apply(null,arguments)},aS=u._Minimum=function(){return(aS=u._Minimum=u.asm.wa).apply(null,arguments)},rS=u._MirrorPad=function(){return(rS=u._MirrorPad=u.asm.xa).apply(null,arguments)},sS=u._Multiply=function(){return(sS=u._Multiply=u.asm.ya).apply(null,arguments)},iS=u._Neg=function(){return(iS=u._Neg=u.asm.za).apply(null,arguments)},oS=u._NonMaxSuppressionV3=function(){return(oS=u._NonMaxSuppressionV3=u.asm.Aa).apply(null,arguments)},lS=u._NonMaxSuppressionV4=function(){return(lS=u._NonMaxSuppressionV4=u.asm.Ba).apply(null,arguments)},uS=u._NonMaxSuppressionV5=function(){return(uS=u._NonMaxSuppressionV5=u.asm.Ca).apply(null,arguments)},dS=u._NotEqual=function(){return(dS=u._NotEqual=u.asm.Da).apply(null,arguments)},pS=u._OneHot=function(){return(pS=u._OneHot=u.asm.Ea).apply(null,arguments)},cS=u._PadV2=function(){return(cS=u._PadV2=u.asm.Fa).apply(null,arguments)},hS=u._Pow=function(){return(hS=u._Pow=u.asm.Ga).apply(null,arguments)},fS=u._Prelu=function(){return(fS=u._Prelu=u.asm.Ha).apply(null,arguments)},mS=u._Prod=function(){return(mS=u._Prod=u.asm.Ia).apply(null,arguments)},gS=u._RealDiv=function(){return(gS=u._RealDiv=u.asm.Ja).apply(null,arguments)},yS=u._Relu=function(){return(yS=u._Relu=u.asm.Ka).apply(null,arguments)},AS=u._Relu6=function(){return(AS=u._Relu6=u.asm.La).apply(null,arguments)},xS=u._ResizeBilinear=function(){return(xS=u._ResizeBilinear=u.asm.Ma).apply(null,arguments)},bS=u._Reverse=function(){return(bS=u._Reverse=u.asm.Na).apply(null,arguments)},vS=u._RotateWithOffset=function(){return(vS=u._RotateWithOffset=u.asm.Oa).apply(null,arguments)},wS=u._Round=function(){return(wS=u._Round=u.asm.Pa).apply(null,arguments)},kS=u._Rsqrt=function(){return(kS=u._Rsqrt=u.asm.Qa).apply(null,arguments)},IS=u._ScatterNd=function(){return(IS=u._ScatterNd=u.asm.Ra).apply(null,arguments)},SS=u._SelectV2=function(){return(SS=u._SelectV2=u.asm.Sa).apply(null,arguments)},NS=u._Sigmoid=function(){return(NS=u._Sigmoid=u.asm.Ta).apply(null,arguments)},TS=u._Sin=function(){return(TS=u._Sin=u.asm.Ua).apply(null,arguments)},CS=u._Softmax=function(){return(CS=u._Softmax=u.asm.Va).apply(null,arguments)},ES=u._Sqrt=function(){return(ES=u._Sqrt=u.asm.Wa).apply(null,arguments)},RS=u._Square=function(){return(RS=u._Square=u.asm.Xa).apply(null,arguments)},MS=u._SquaredDifference=function(){return(MS=u._SquaredDifference=u.asm.Ya).apply(null,arguments)},FS=u._Step=function(){return(FS=u._Step=u.asm.Za).apply(null,arguments)},DS=u._StridedSlice=function(){return(DS=u._StridedSlice=u.asm._a).apply(null,arguments)},$S=u._Sub=function(){return($S=u._Sub=u.asm.$a).apply(null,arguments)},OS=u._Sum=function(){return(OS=u._Sum=u.asm.ab).apply(null,arguments)},_S=u._Tan=function(){return(_S=u._Tan=u.asm.bb).apply(null,arguments)},PS=u._Tanh=function(){return(PS=u._Tanh=u.asm.cb).apply(null,arguments)},zS=u._Tile=function(){return(zS=u._Tile=u.asm.db).apply(null,arguments)},LS=u._TopK=function(){return(LS=u._TopK=u.asm.eb).apply(null,arguments)},WS=u._Transform=function(){return(WS=u._Transform=u.asm.fb).apply(null,arguments)},BS=u._Transpose=function(){return(BS=u._Transpose=u.asm.gb).apply(null,arguments)},VS=u.__FusedMatMul=function(){return(VS=u.__FusedMatMul=u.asm.hb).apply(null,arguments)},Hs=u._malloc=function(){return(Hs=u._malloc=u.asm.ib).apply(null,arguments)},id=u._free=function(){return(id=u._free=u.asm.jb).apply(null,arguments)},k5=u.___errno_location=function(){return(k5=u.___errno_location=u.asm.kb).apply(null,arguments)},I5=u._emscripten_get_global_libc=function(){return(I5=u._emscripten_get_global_libc=u.asm.lb).apply(null,arguments)},ns=u._pthread_self=function(){return(ns=u._pthread_self=u.asm.mb).apply(null,arguments)},S5=u.___pthread_tsd_run_dtors=function(){return(S5=u.___pthread_tsd_run_dtors=u.asm.nb).apply(null,arguments)},Fc=u._emscripten_main_thread_process_queued_calls=function(){return(Fc=u._emscripten_main_thread_process_queued_calls=u.asm.ob).apply(null,arguments)},US=u._emscripten_current_thread_process_queued_calls=function(){return(US=u._emscripten_current_thread_process_queued_calls=u.asm.pb).apply(null,arguments)},N5=u._emscripten_register_main_browser_thread_id=function(){return(N5=u._emscripten_register_main_browser_thread_id=u.asm.qb).apply(null,arguments)},T5=u._emscripten_main_browser_thread_id=function(){return(T5=u._emscripten_main_browser_thread_id=u.asm.rb).apply(null,arguments)},C5=u.__emscripten_do_dispatch_to_thread=function(){return(C5=u.__emscripten_do_dispatch_to_thread=u.asm.sb).apply(null,arguments)},E5=u._emscripten_sync_run_in_main_thread_4=function(){return(E5=u._emscripten_sync_run_in_main_thread_4=u.asm.tb).apply(null,arguments)},R5=u._emscripten_run_in_main_runtime_thread_js=function(){return(R5=u._emscripten_run_in_main_runtime_thread_js=u.asm.ub).apply(null,arguments)},T1=u.__emscripten_call_on_thread=function(){return(T1=u.__emscripten_call_on_thread=u.asm.vb).apply(null,arguments)},jS=u._emscripten_tls_init=function(){return(jS=u._emscripten_tls_init=u.asm.wb).apply(null,arguments)},C1=u.__emscripten_thread_init=function(){return(C1=u.__emscripten_thread_init=u.asm.xb).apply(null,arguments)},od=u.stackSave=function(){return(od=u.stackSave=u.asm.yb).apply(null,arguments)},Bo=u.stackRestore=function(){return(Bo=u.stackRestore=u.asm.zb).apply(null,arguments)},Vo=u.stackAlloc=function(){return(Vo=u.stackAlloc=u.asm.Ab).apply(null,arguments)},M5=u._emscripten_stack_set_limits=function(){return(M5=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)},D5=u.__emscripten_allow_main_runtime_queued_calls=10512,Uo=u.__emscripten_main_thread_futex=12148;u.cwrap=We,u.PThread=Re,u.PThread=Re,u.wasmMemory=se,u.ExitStatus=ld;var Dc;function ld(N){this.name="ExitStatus",this.message="Program terminated with exit("+N+")",this.status=N}Us=function N(){Dc||E1(),Dc||(Us=N)};function E1(N){if(N=N||m,$a>0)return;if(k){p(u),dc(),postMessage({cmd:"loaded"});return}if(uc(),$a>0)return;function R(){Dc||(Dc=!0,u.calledRun=!0,!be&&(dc(),pc(),p(u),u.onRuntimeInitialized&&u.onRuntimeInitialized(),cc()))}u.setStatus?(u.setStatus("Running..."),setTimeout(function(){setTimeout(function(){u.setStatus("")},1),R()},1)):R()}u.run=E1;function GS(N,R){if(!(R&&Y&&N===0)){if(!R&&k)throw postMessage({cmd:"exitProcess",returnCode:N}),new ld(N);Y||(Re.terminateAllThreads(),ve=N,Gn(),u.onExit&&u.onExit(N),be=!0),y(N,new ld(N))}}if(u.preInit)for(typeof u.preInit=="function"&&(u.preInit=[u.preInit]);u.preInit.length>0;)u.preInit.pop()();return k&&(Y=!1,Re.initWorker()),E1(),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)}),xN=Nt((e,t)=>{var n=function(){var a=typeof document!="undefined"&&document.currentScript?document.currentScript.src:void 0;return typeof __filename!="undefined"&&(a=a||__filename),function(r){r=r||{};var s=typeof r!="undefined"?r:{},i,o;s.ready=new Promise(function(ee,oe){i=ee,o=oe});var l={},d;for(d in s)s.hasOwnProperty(d)&&(l[d]=s[d]);var u=[],p="./this.program",c=function(ee,oe){throw oe},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 y="";function A(ee){return s.locateFile?s.locateFile(ee,y):y+ee}var x,b,v,k,T,C;m?(f?y=hd().dirname(y)+"/":y=__dirname+"/",x=function(ee,oe){return T||(T=Ho("fs")),C||(C=hd()),ee=C.normalize(ee),T.readFileSync(ee,oe?null:"utf8")},v=function(ee){var oe=x(ee,!0);return oe.buffer||(oe=new Uint8Array(oe)),q(oe.buffer),oe},process.argv.length>1&&(p=process.argv[1].replace(/\\/g,"/")),u=process.argv.slice(2),process.on("uncaughtException",function(ee){if(!(ee instanceof N1))throw ee}),process.on("unhandledRejection",qa),c=function(ee){process.exit(ee)},s.inspect=function(){return"[Emscripten Module object]"}):g?(typeof read!="undefined"&&(x=function(ee){return read(ee)}),v=function(ee){var oe;return typeof readbuffer=="function"?new Uint8Array(readbuffer(ee)):(oe=read(ee,"binary"),q(typeof oe=="object"),oe)},typeof scriptArgs!="undefined"?u=scriptArgs:typeof arguments!="undefined"&&(u=arguments),typeof quit=="function"&&(c=function(ee){quit(ee)}),typeof print!="undefined"&&(typeof console=="undefined"&&(console={}),console.log=print,console.warn=console.error=typeof printErr!="undefined"?printErr:print)):(h||f)&&(f?y=self.location.href:typeof document!="undefined"&&document.currentScript&&(y=document.currentScript.src),a&&(y=a),y.indexOf("blob:")!==0?y=y.substr(0,y.lastIndexOf("/")+1):y="",x=function(ee){var oe=new XMLHttpRequest;return oe.open("GET",ee,!1),oe.send(null),oe.responseText},f&&(v=function(ee){var oe=new XMLHttpRequest;return oe.open("GET",ee,!1),oe.responseType="arraybuffer",oe.send(null),new Uint8Array(oe.response)}),b=function(ee,oe,Fe){var rt=new XMLHttpRequest;rt.open("GET",ee,!0),rt.responseType="arraybuffer",rt.onload=function(){if(rt.status==200||rt.status==0&&rt.response){oe(rt.response);return}Fe()},rt.onerror=Fe,rt.send(null)},k=function(ee){document.title=ee});var D=s.print||console.log.bind(console),O=s.printErr||console.warn.bind(console);for(d in l)l.hasOwnProperty(d)&&(s[d]=l[d]);l=null,s.arguments&&(u=s.arguments),s.thisProgram&&(p=s.thisProgram),s.quit&&(c=s.quit);var F;s.wasmBinary&&(F=s.wasmBinary);var S=s.noExitRuntime||!0;typeof WebAssembly!="object"&&qa("no native wasm support detected");var P,_=!1,j;function q(ee,oe){ee||qa("Assertion failed: "+oe)}function z(ee){var oe=s["_"+ee];return q(oe,"Cannot call unknown function "+ee+", make sure it is exported"),oe}function X(ee,oe,Fe,rt,_t){var St={string:function(va){var ts=0;if(va!=null&&va!==0){var Mc=(va.length<<2)+1;ts=ad(Mc),se(va,ts,Mc)}return ts},array:function(va){var ts=ad(va.length);return de(va,ts),ts}};function Ke(va){return oe==="string"?re(va):oe==="boolean"?Boolean(va):va}var Je=z(ee),yn=[],Mr=0;if(rt)for(var Fr=0;Fr<rt.length;Fr++){var Rc=St[Fe[Fr]];Rc?(Mr===0&&(Mr=Cc()),yn[Fr]=Rc(rt[Fr])):yn[Fr]=rt[Fr]}var sd=Je.apply(null,yn);return sd=Ke(sd),Mr!==0&&Ec(Mr),sd}function Z(ee,oe,Fe,rt){Fe=Fe||[];var _t=Fe.every(function(Ke){return Ke==="number"}),St=oe!=="string";return St&&_t&&!rt?z(ee):function(){return X(ee,oe,Fe,arguments,rt)}}var te=typeof TextDecoder!="undefined"?new TextDecoder("utf8"):void 0;function J(ee,oe,Fe){for(var rt=oe+Fe,_t=oe;ee[_t]&&!(_t>=rt);)++_t;if(_t-oe>16&&ee.subarray&&te)return te.decode(ee.subarray(oe,_t));for(var St="";oe<_t;){var Ke=ee[oe++];if(!(Ke&128)){St+=String.fromCharCode(Ke);continue}var Je=ee[oe++]&63;if((Ke&224)==192){St+=String.fromCharCode((Ke&31)<<6|Je);continue}var yn=ee[oe++]&63;if((Ke&240)==224?Ke=(Ke&15)<<12|Je<<6|yn:Ke=(Ke&7)<<18|Je<<12|yn<<6|ee[oe++]&63,Ke<65536)St+=String.fromCharCode(Ke);else{var Mr=Ke-65536;St+=String.fromCharCode(55296|Mr>>10,56320|Mr&1023)}}return St}function re(ee,oe){return ee?J(Ee,ee,oe):""}function Y(ee,oe,Fe,rt){if(!(rt>0))return 0;for(var _t=Fe,St=Fe+rt-1,Ke=0;Ke<ee.length;++Ke){var Je=ee.charCodeAt(Ke);if(Je>=55296&&Je<=57343){var yn=ee.charCodeAt(++Ke);Je=65536+((Je&1023)<<10)|yn&1023}if(Je<=127){if(Fe>=St)break;oe[Fe++]=Je}else if(Je<=2047){if(Fe+1>=St)break;oe[Fe++]=192|Je>>6,oe[Fe++]=128|Je&63}else if(Je<=65535){if(Fe+2>=St)break;oe[Fe++]=224|Je>>12,oe[Fe++]=128|Je>>6&63,oe[Fe++]=128|Je&63}else{if(Fe+3>=St)break;oe[Fe++]=240|Je>>18,oe[Fe++]=128|Je>>12&63,oe[Fe++]=128|Je>>6&63,oe[Fe++]=128|Je&63}}return oe[Fe]=0,Fe-_t}function se(ee,oe,Fe){return Y(ee,Ee,oe,Fe)}function de(ee,oe){ke.set(ee,oe)}function be(ee,oe){return ee%oe>0&&(ee+=oe-ee%oe),ee}var ve,ke,Ee,_e,We,Ue,Xe,ut,dt;function at(ee){ve=ee,s.HEAP8=ke=new Int8Array(ee),s.HEAP16=_e=new Int16Array(ee),s.HEAP32=Ue=new Int32Array(ee),s.HEAPU8=Ee=new Uint8Array(ee),s.HEAPU16=We=new Uint16Array(ee),s.HEAPU32=Xe=new Uint32Array(ee),s.HEAPF32=ut=new Float32Array(ee),s.HEAPF64=dt=new Float64Array(ee)}var xt=s.INITIAL_MEMORY||16777216,ft,It=[],Mt=[],aa=[],gn=[],ra=!1;Mt.push({func:function(){gc()}});function xa(){if(s.preRun)for(typeof s.preRun=="function"&&(s.preRun=[s.preRun]);s.preRun.length;)Un(s.preRun.shift());$a(It)}function Bn(){ra=!0,$a(Mt)}function Vn(){$a(aa)}function ba(){if(s.postRun)for(typeof s.postRun=="function"&&(s.postRun=[s.postRun]);s.postRun.length;)Er(s.postRun.shift());$a(gn)}function Un(ee){It.unshift(ee)}function Er(ee){gn.unshift(ee)}var jn=0,Zr=null,dr=null;function Yr(ee){jn++,s.monitorRunDependencies&&s.monitorRunDependencies(jn)}function Yu(ee){if(jn--,s.monitorRunDependencies&&s.monitorRunDependencies(jn),jn==0&&(Zr!==null&&(clearInterval(Zr),Zr=null),dr)){var oe=dr;dr=null,oe()}}s.preloadedImages={},s.preloadedAudios={};function qa(ee){s.onAbort&&s.onAbort(ee),ee+="",O(ee),_=!0,j=1,ee="abort("+ee+"). Build with -s ASSERTIONS=1 for more info.";var oe=new WebAssembly.RuntimeError(ee);throw o(oe),oe}function lc(ee,oe){return String.prototype.startsWith?ee.startsWith(oe):ee.indexOf(oe)===0}var sm="data:application/octet-stream;base64,";function uc(ee){return lc(ee,sm)}var dc="file://";function pc(ee){return lc(ee,dc)}var Gn="tfjs-backend-wasm.wasm";uc(Gn)||(Gn=A(Gn));function cc(ee){try{if(ee==Gn&&F)return new Uint8Array(F);if(v)return v(ee);throw"both async and sync fetching of the wasm failed"}catch(oe){qa(oe)}}function im(){if(!F&&(h||f)){if(typeof fetch=="function"&&!pc(Gn))return fetch(Gn,{credentials:"same-origin"}).then(function(ee){if(!ee.ok)throw"failed to load wasm binary file at '"+Gn+"'";return ee.arrayBuffer()}).catch(function(){return cc(Gn)});if(b)return new Promise(function(ee,oe){b(Gn,function(Fe){ee(new Uint8Array(Fe))},oe)})}return Promise.resolve().then(function(){return cc(Gn)})}function om(){var ee={a:hm};function oe(Ke,Je){var yn=Ke.exports;s.asm=yn,P=s.asm.j,at(P.buffer),ft=s.asm.r,Yu("wasm-instantiate")}Yr("wasm-instantiate");function Fe(Ke){oe(Ke.instance)}function rt(Ke){return im().then(function(Je){return WebAssembly.instantiate(Je,ee)}).then(Ke,function(Je){O("failed to asynchronously prepare wasm: "+Je),qa(Je)})}function _t(){return!F&&typeof WebAssembly.instantiateStreaming=="function"&&!uc(Gn)&&!pc(Gn)&&typeof fetch=="function"?fetch(Gn,{credentials:"same-origin"}).then(function(Ke){var Je=WebAssembly.instantiateStreaming(Ke,ee);return Je.then(Fe,function(yn){return O("wasm streaming compile failed: "+yn),O("falling back to ArrayBuffer instantiation"),rt(Fe)})}):rt(Fe)}if(s.instantiateWasm)try{var St=s.instantiateWasm(ee,oe);return St}catch(Ke){return O("Module.instantiateWasm callback failed with error: "+Ke),!1}return _t().catch(o),{}}function $a(ee){for(;ee.length>0;){var oe=ee.shift();if(typeof oe=="function"){oe(s);continue}var Fe=oe.func;typeof Fe=="number"?oe.arg===void 0?ft.get(Fe)():ft.get(Fe)(oe.arg):Fe(oe.arg===void 0?null:oe.arg)}}function Ju(){qa()}function Us(ee,oe,Fe){Ee.copyWithin(ee,oe,oe+Fe)}function lm(){return Ee.length}function um(ee){try{return P.grow(ee-ve.byteLength+65535>>>16),at(P.buffer),1}catch(oe){}}function Rr(ee){var oe=lm(),Fe=2147483648;if(ee>Fe)return!1;for(var rt=1;rt<=4;rt*=2){var _t=oe*(1+.2/rt);_t=Math.min(_t,ee+100663296);var St=Math.min(Fe,be(Math.max(ee,_t),65536)),Ke=um(St);if(Ke)return!0}return!1}var js={mappings:{},buffers:[null,[],[]],printChar:function(ee,oe){var Fe=js.buffers[ee];oe===0||oe===10?((ee===1?D:O)(J(Fe,0)),Fe.length=0):Fe.push(oe)},varargs:void 0,get:function(){js.varargs+=4;var ee=Ue[js.varargs-4>>2];return ee},getStr:function(ee){var oe=re(ee);return oe},get64:function(ee,oe){return ee}};function dm(ee){return 0}function hc(ee,oe,Fe,rt,_t){}function pm(ee,oe,Fe,rt){for(var _t=0,St=0;St<Fe;St++){for(var Ke=Ue[oe+St*8>>2],Je=Ue[oe+(St*8+4)>>2],yn=0;yn<Je;yn++)js.printChar(ee,Ee[Ke+yn]);_t+=Je}return Ue[rt>>2]=_t,0}function fc(){return 6}function Hn(){return 28}function mc(ee){return Ue[Tc()>>2]=ee,ee}function cm(ee){switch(ee){case 30:return 16384;case 85:var oe=2147483648;return oe/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 mc(28),-1}var hm={a:Ju,d:Us,e:Rr,f:dm,c:hc,b:pm,h:fc,g:Hn,i:cm},fm=om(),gc=s.___wasm_call_ctors=function(){return(gc=s.___wasm_call_ctors=s.asm.k).apply(null,arguments)},zo=s._init=function(){return(zo=s._init=s.asm.l).apply(null,arguments)},Jr=s._init_with_threads_count=function(){return(Jr=s._init_with_threads_count=s.asm.m).apply(null,arguments)},Qu=s._get_threads_count=function(){return(Qu=s._get_threads_count=s.asm.n).apply(null,arguments)},mm=s._register_tensor=function(){return(mm=s._register_tensor=s.asm.o).apply(null,arguments)},gm=s._dispose_data=function(){return(gm=s._dispose_data=s.asm.p).apply(null,arguments)},yc=s._dispose=function(){return(yc=s._dispose=s.asm.q).apply(null,arguments)},Re=s._Abs=function(){return(Re=s._Abs=s.asm.s).apply(null,arguments)},ym=s._Add=function(){return(ym=s._Add=s.asm.t).apply(null,arguments)},Am=s._AddN=function(){return(Am=s._AddN=s.asm.u).apply(null,arguments)},xm=s._All=function(){return(xm=s._All=s.asm.v).apply(null,arguments)},bm=s._Any=function(){return(bm=s._Any=s.asm.w).apply(null,arguments)},vm=s._ArgMax=function(){return(vm=s._ArgMax=s.asm.x).apply(null,arguments)},Gs=s._AvgPool=function(){return(Gs=s._AvgPool=s.asm.y).apply(null,arguments)},wm=s._BatchMatMul=function(){return(wm=s._BatchMatMul=s.asm.z).apply(null,arguments)},km=s._Ceil=function(){return(km=s._Ceil=s.asm.A).apply(null,arguments)},Im=s._ClipByValue=function(){return(Im=s._ClipByValue=s.asm.B).apply(null,arguments)},Sm=s._Conv2D=function(){return(Sm=s._Conv2D=s.asm.C).apply(null,arguments)},Nm=s._Conv2DBackpropInput=function(){return(Nm=s._Conv2DBackpropInput=s.asm.D).apply(null,arguments)},Tm=s._Cos=function(){return(Tm=s._Cos=s.asm.E).apply(null,arguments)},Ac=s._Cosh=function(){return(Ac=s._Cosh=s.asm.F).apply(null,arguments)},Cm=s._CropAndResize=function(){return(Cm=s._CropAndResize=s.asm.G).apply(null,arguments)},Em=s._Cumsum=function(){return(Em=s._Cumsum=s.asm.H).apply(null,arguments)},Qr=s._DepthToSpace=function(){return(Qr=s._DepthToSpace=s.asm.I).apply(null,arguments)},ed=s._DepthwiseConv2dNative=function(){return(ed=s._DepthwiseConv2dNative=s.asm.J).apply(null,arguments)},td=s._Elu=function(){return(td=s._Elu=s.asm.K).apply(null,arguments)},Rm=s._Equal=function(){return(Rm=s._Equal=s.asm.L).apply(null,arguments)},Mm=s._Exp=function(){return(Mm=s._Exp=s.asm.M).apply(null,arguments)},Fm=s._FlipLeftRight=function(){return(Fm=s._FlipLeftRight=s.asm.N).apply(null,arguments)},Dm=s._Floor=function(){return(Dm=s._Floor=s.asm.O).apply(null,arguments)},$m=s._FloorDiv=function(){return($m=s._FloorDiv=s.asm.P).apply(null,arguments)},Be=s._FusedBatchNorm=function(){return(Be=s._FusedBatchNorm=s.asm.Q).apply(null,arguments)},Om=s._FusedConv2D=function(){return(Om=s._FusedConv2D=s.asm.R).apply(null,arguments)},_m=s._FusedDepthwiseConv2D=function(){return(_m=s._FusedDepthwiseConv2D=s.asm.S).apply(null,arguments)},Pm=s._Gather=function(){return(Pm=s._Gather=s.asm.T).apply(null,arguments)},zm=s._GatherNd=function(){return(zm=s._GatherNd=s.asm.U).apply(null,arguments)},Lm=s._Greater=function(){return(Lm=s._Greater=s.asm.V).apply(null,arguments)},Wm=s._GreaterEqual=function(){return(Wm=s._GreaterEqual=s.asm.W).apply(null,arguments)},nd=s._LeakyRelu=function(){return(nd=s._LeakyRelu=s.asm.X).apply(null,arguments)},xc=s._Less=function(){return(xc=s._Less=s.asm.Y).apply(null,arguments)},bc=s._LessEqual=function(){return(bc=s._LessEqual=s.asm.Z).apply(null,arguments)},Bm=s._Log=function(){return(Bm=s._Log=s.asm._).apply(null,arguments)},Vm=s._LogicalAnd=function(){return(Vm=s._LogicalAnd=s.asm.$).apply(null,arguments)},Um=s._Max=function(){return(Um=s._Max=s.asm.aa).apply(null,arguments)},jm=s._MaxPool=function(){return(jm=s._MaxPool=s.asm.ba).apply(null,arguments)},Gm=s._Maximum=function(){return(Gm=s._Maximum=s.asm.ca).apply(null,arguments)},Hm=s._Mean=function(){return(Hm=s._Mean=s.asm.da).apply(null,arguments)},qm=s._Min=function(){return(qm=s._Min=s.asm.ea).apply(null,arguments)},ot=s._Minimum=function(){return(ot=s._Minimum=s.asm.fa).apply(null,arguments)},Xm=s._MirrorPad=function(){return(Xm=s._MirrorPad=s.asm.ga).apply(null,arguments)},Km=s._Multiply=function(){return(Km=s._Multiply=s.asm.ha).apply(null,arguments)},Zm=s._Neg=function(){return(Zm=s._Neg=s.asm.ia).apply(null,arguments)},Lo=s._NonMaxSuppressionV3=function(){return(Lo=s._NonMaxSuppressionV3=s.asm.ja).apply(null,arguments)},vc=s._NonMaxSuppressionV4=function(){return(vc=s._NonMaxSuppressionV4=s.asm.ka).apply(null,arguments)},wc=s._NonMaxSuppressionV5=function(){return(wc=s._NonMaxSuppressionV5=s.asm.la).apply(null,arguments)},kc=s._NotEqual=function(){return(kc=s._NotEqual=s.asm.ma).apply(null,arguments)},Ym=s._OneHot=function(){return(Ym=s._OneHot=s.asm.na).apply(null,arguments)},Jm=s._PadV2=function(){return(Jm=s._PadV2=s.asm.oa).apply(null,arguments)},Ic=s._Pow=function(){return(Ic=s._Pow=s.asm.pa).apply(null,arguments)},Qm=s._Prelu=function(){return(Qm=s._Prelu=s.asm.qa).apply(null,arguments)},e1=s._Prod=function(){return(e1=s._Prod=s.asm.ra).apply(null,arguments)},t1=s._RealDiv=function(){return(t1=s._RealDiv=s.asm.sa).apply(null,arguments)},n1=s._Relu=function(){return(n1=s._Relu=s.asm.ta).apply(null,arguments)},a1=s._Relu6=function(){return(a1=s._Relu6=s.asm.ua).apply(null,arguments)},Sc=s._ResizeBilinear=function(){return(Sc=s._ResizeBilinear=s.asm.va).apply(null,arguments)},es=s._Reverse=function(){return(es=s._Reverse=s.asm.wa).apply(null,arguments)},r1=s._RotateWithOffset=function(){return(r1=s._RotateWithOffset=s.asm.xa).apply(null,arguments)},s1=s._Round=function(){return(s1=s._Round=s.asm.ya).apply(null,arguments)},w5=s._Rsqrt=function(){return(w5=s._Rsqrt=s.asm.za).apply(null,arguments)},Nc=s._ScatterNd=function(){return(Nc=s._ScatterNd=s.asm.Aa).apply(null,arguments)},i1=s._SelectV2=function(){return(i1=s._SelectV2=s.asm.Ba).apply(null,arguments)},o1=s._Sigmoid=function(){return(o1=s._Sigmoid=s.asm.Ca).apply(null,arguments)},l1=s._Sin=function(){return(l1=s._Sin=s.asm.Da).apply(null,arguments)},u1=s._Softmax=function(){return(u1=s._Softmax=s.asm.Ea).apply(null,arguments)},d1=s._Sqrt=function(){return(d1=s._Sqrt=s.asm.Fa).apply(null,arguments)},p1=s._Square=function(){return(p1=s._Square=s.asm.Ga).apply(null,arguments)},c1=s._SquaredDifference=function(){return(c1=s._SquaredDifference=s.asm.Ha).apply(null,arguments)},h1=s._Step=function(){return(h1=s._Step=s.asm.Ia).apply(null,arguments)},f1=s._StridedSlice=function(){return(f1=s._StridedSlice=s.asm.Ja).apply(null,arguments)},m1=s._Sub=function(){return(m1=s._Sub=s.asm.Ka).apply(null,arguments)},g1=s._Sum=function(){return(g1=s._Sum=s.asm.La).apply(null,arguments)},y1=s._Tan=function(){return(y1=s._Tan=s.asm.Ma).apply(null,arguments)},A1=s._Tanh=function(){return(A1=s._Tanh=s.asm.Na).apply(null,arguments)},x1=s._Tile=function(){return(x1=s._Tile=s.asm.Oa).apply(null,arguments)},b1=s._TopK=function(){return(b1=s._TopK=s.asm.Pa).apply(null,arguments)},v1=s._Transform=function(){return(v1=s._Transform=s.asm.Qa).apply(null,arguments)},w1=s._Transpose=function(){return(w1=s._Transpose=s.asm.Ra).apply(null,arguments)},k1=s.__FusedMatMul=function(){return(k1=s.__FusedMatMul=s.asm.Sa).apply(null,arguments)},I1=s._malloc=function(){return(I1=s._malloc=s.asm.Ta).apply(null,arguments)},S1=s._free=function(){return(S1=s._free=s.asm.Ua).apply(null,arguments)},Tc=s.___errno_location=function(){return(Tc=s.___errno_location=s.asm.Va).apply(null,arguments)},Cc=s.stackSave=function(){return(Cc=s.stackSave=s.asm.Wa).apply(null,arguments)},Ec=s.stackRestore=function(){return(Ec=s.stackRestore=s.asm.Xa).apply(null,arguments)},ad=s.stackAlloc=function(){return(ad=s.stackAlloc=s.asm.Ya).apply(null,arguments)};s.cwrap=Z;var Wo;function N1(ee){this.name="ExitStatus",this.message="Program terminated with exit("+ee+")",this.status=ee}dr=function ee(){Wo||rd(),Wo||(dr=ee)};function rd(ee){if(ee=ee||u,jn>0||(xa(),jn>0))return;function oe(){Wo||(Wo=!0,s.calledRun=!0,!_&&(Bn(),Vn(),i(s),s.onRuntimeInitialized&&s.onRuntimeInitialized(),ba()))}s.setStatus?(s.setStatus("Running..."),setTimeout(function(){setTimeout(function(){s.setStatus("")},1),oe()},1)):oe()}if(s.run=rd,s.preInit)for(typeof s.preInit=="function"&&(s.preInit=[s.preInit]);s.preInit.length>0;)s.preInit.pop()();return rd(),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)}),bN=1e-7,vN=1e-4,Oc=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}},fd=class{refCount(e){return Oa("refCount")}incRef(e){return Oa("incRef")}timerAvailable(){return!0}time(e){return Oa("time")}read(e){return Oa("read")}readSync(e){return Oa("readSync")}numDataIds(){return Oa("numDataIds")}disposeData(e,t){return Oa("disposeData")}write(e,t,n){return Oa("write")}move(e,t,n,a,r){return Oa("move")}memory(){return Oa("memory")}floatPrecision(){return Oa("floatPrecision")}epsilon(){return this.floatPrecision()===32?bN:vN}dispose(){return Oa("dispose")}};function Oa(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 B5(e){let t=e.length,n=0;for(;t>0;)n=Math.random()*t|0,t--,_c(e,t,n)}function wN(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,a=0;for(;n>0;)a=Math.random()*n|0,n--,_c(e,n,a),_c(t,n,a)}function md(e,t,n){return Math.max(e,Math.min(t,n))}function kN(e){return e%2==0?e:e+1}function _c(e,t,n){let a=e[t];e[t]=e[n],e[n]=a}function IN(e){let t=0;for(let n=0;n<e.length;n++)t+=e[n];return t}function SN(e,t){let n=Math.random();return t*n+(1-n)*e}function NN(e,t){let n=0;for(let a=0;a<e.length;a++){let r=Number(e[a])-Number(t[a]);n+=r*r}return n}function $(e,t){if(!e)throw new Error(typeof t=="string"?t:t())}function Tn(e,t,n=""){$(Dr(e,t),()=>n+` Shapes ${e} and ${t} must match`)}function Xs(e){$(e!=null,()=>"The input to the tensor constructor must be a non-null value.")}function Ks(e,t=[],n=!1){if(t==null&&(t=[]),Array.isArray(e)||In(e)&&!n)for(let a=0;a<e.length;++a)Ks(e[a],t,n);else t.push(e);return t}function zt(e){if(e.length===0)return 1;let t=e[0];for(let n=1;n<e.length;n++)t*=e[n];return t}function TN(e){return e.length===0}function Dr(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 un(e){return e%1==0}function CN(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 EN(e){let t=Math.ceil(Math.sqrt(e));return[t,Math.ceil(e/t)]}function RN(e){let t=new Uint32Array(e);for(let n=0;n<e;++n)t[n]=n;return B5(t),t}function gd(e,t){return t<=e.length?e:e+" ".repeat(t-e.length)}function MN(e,t=a=>0,n){return new Promise((a,r)=>{let s=0,i=()=>{if(e()){a();return}s++;let o=t(s);if(n!=null&&s>=n){r();return}setTimeout(i,o)};i()})}function FN(e,t){let n=1,a=-1;for(let s=0;s<e.length;++s)if(e[s]>=0)n*=e[s];else if(e[s]===-1){if(a!==-1)throw Error(`Shapes can only have 1 implicit size. Found -1 at dim ${a} and dim ${s}`);a=s}else if(e[s]<0)throw Error(`Shapes can not be < 0. Found ${e[s]} at dim ${s}`);if(a===-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[a]=t/n,r}function _a(e,t){let n=t.length;return e=e==null?t.map((a,r)=>r):[].concat(e),$(e.every(a=>a>=-n&&a<n),()=>`All values in axis param must be in range [-${n}, ${n}) but got axis ${e}`),$(e.every(a=>un(a)),()=>`All values in axis param must be integers but got axis ${e}`),e.map(a=>a<0?n+a:a)}function V5(e,t){let n=[],a=[],r=t!=null&&Array.isArray(t)&&t.length===0,s=t==null||r?null:_a(t,e).sort(),i=0;for(let o=0;o<e.length;++o){if(s!=null){if(s[i]===o&&e[o]!==1)throw new Error(`Can't squeeze axis ${o} since its dim '${e[o]}' is not 1`);(s[i]==null||s[i]>o)&&e[o]===1&&(n.push(e[o]),a.push(o)),s[i]<=o&&i++}e[o]!==1&&(n.push(e[o]),a.push(o))}return{newShape:n,keptDims:a}}function U5(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 j5(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 G5(e,t){for(let n=0;n<e.length;n++){let a=e[n];if(isNaN(a)||!isFinite(a))throw Error(`A tensor of type ${t} being uploaded contains ${a}.`)}}function H5(e){return e==="bool"||e==="complex64"||e==="float32"||e==="int32"||e==="string"}function DN(e,t){return!(t==="complex64"||t==="float32"&&e!=="complex64"||t==="int32"&&e!=="float32"&&e!=="complex64"||t==="bool"&&e==="bool")}function In(e){return e instanceof Float32Array||e instanceof Int32Array||e instanceof Uint8Array||e instanceof Uint8ClampedArray}function F1(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 q5(e){if(e==null)return 0;let t=0;return e.forEach(n=>t+=n.length),t}function is(e){return typeof e=="string"||e instanceof String}function X5(e){return typeof e=="boolean"}function K5(e){return typeof e=="number"}function Pc(e){return Array.isArray(e)?Pc(e[0]):e instanceof Float32Array?"float32":e instanceof Int32Array||e instanceof Uint8Array||e instanceof Uint8ClampedArray?"int32":K5(e)?"float32":is(e)?"string":X5(e)?"bool":"float32"}function os(e){return!!(e&&e.constructor&&e.call&&e.apply)}function zc(e,t){for(let n=t;n<e;++n)if(e%n==0)return n;return e}function qo(e){let t=e.length;if(t<2)return[];let n=new Array(t-1);n[t-2]=e[t-1];for(let a=t-3;a>=0;--a)n[a]=n[a+1]*e[a+1];return n}function Z5(e,t,n,a=!1){let r=new Array;if(t.length===1){let s=t[0]*(a?2:1);for(let i=0;i<s;i++)r[i]=n[e+i]}else{let s=t[0],i=t.slice(1),o=i.reduce((l,d)=>l*d)*(a?2:1);for(let l=0;l<s;l++)r[l]=Z5(e+l*o,i,n,a)}return r}function Xo(e,t,n=!1){if(e.length===0)return t[0];let a=e.reduce((r,s)=>r*s)*(n?2:1);if(a===0)return[];if(a!==t.length)throw new Error(`[${e}] does not match the input size ${t.length}${n?" for a complex tensor":""}.`);return Z5(0,e,t,n)}function D1(e,t){let n=Lc(e,t);for(let a=0;a<n.length;a++)n[a]=1;return n}function Lc(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 $N(e,t){let n=e.reduce((a,r)=>a*r,1);if(t==null||t==="float32")return Xo(e,new Float32Array(n));if(t==="int32")return Xo(e,new Int32Array(n));if(t==="bool")return Xo(e,new Uint8Array(n));throw new Error(`Unknown data type ${t}`)}function $1(e){e.forEach(t=>{$(Number.isInteger(t)&&t>=0,()=>`Tensor must have a shape comprised of positive integers but got shape [${e}].`)})}function ON(e,t,n){if(t===0)return 0;if(t===1)return e[0];let a=e[e.length-1];for(let r=0;r<e.length-1;++r)a+=n[r]*e[r];return a}function _N(e,t,n){if(t===0)return[];if(t===1)return[e];let a=new Array(t);for(let r=0;r<a.length-1;++r)a[r]=Math.floor(e/n[r]),e-=a[r]*n[r];return a[a.length-1]=e,a}function O1(e){return e&&e.then&&typeof e.then=="function"}function pr(...e){ne().getBool("IS_TEST")||ne().getBool("PROD")||console.warn(...e)}function PN(...e){ne().getBool("IS_TEST")||ne().getBool("PROD")||console.log(...e)}var Y5="tfjsflags",J5=class{constructor(e){this.global=e,this.flags={},this.flagRegistry={},this.urlFlags={},this.getQueryParams=zN,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 a=this.urlFlags[e];pr(`Setting feature override from URL ${e}: ${a}.`),this.set(e,a)}}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(O1(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);Y5 in e&&e[Y5].split(",").forEach(t=>{let[n,a]=t.split(":");this.urlFlags[n]=WN(n,a)})}};function zN(e){let t={};return e.replace(/[?&]([^=?&]+)(?:=([^&]*))?/g,(n,...a)=>(LN(t,a[0],a[1]),a.join("="))),t}function LN(e,t,n){e[decodeURIComponent(t)]=decodeURIComponent(n||"")}function WN(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 ne(){return cr}var cr=null;function BN(e){cr=e}var _1;function Q5(){if(_1==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");_1=e}return _1}function VN(){let e=Q5();return e._tfGlobals==null&&(e._tfGlobals=new Map),e._tfGlobals}function P1(e,t){let n=VN();if(n.has(e))return n.get(e);{let a=t();return n.set(e,a),n.get(e)}}var Ko="Abs",Zo="Acos",Yo="Acosh",ls="Add",Zs="AddN",Jo="All",Qo="Any",Ys="ArgMax",yd="ArgMin",el="Asin",tl="Asinh",nl="Atan",al="Atanh",rl="Atan2",Js="AvgPool",Wc="AvgPoolGrad",Ad="AvgPool3D",Bc="AvgPool3DGrad",Qs="BatchMatMul",sl="BatchToSpaceND",Vc="Bincount",eb="BroadcastTo",Uc="BroadcastArgs",ei="Cast",ti="Ceil",us="ClipByValue",jc="Complex",xd="ComplexAbs",il="Concat",ni="Conv2D",Gc="Conv2DBackpropFilter",ai="Conv2DBackpropInput",bd="Conv3D",Hc="Conv3DBackpropFilterV2",qc="Conv3DBackpropInputV2",ri="Cos",si="Cosh",ii="Cumsum",ol="CropAndResize",Xc="DenseBincount",ll="DepthToSpace",oi="DepthwiseConv2dNative",Kc="DepthwiseConv2dNativeBackpropFilter",Zc="DepthwiseConv2dNativeBackpropInput",Yc="Diag",vd="Dilation2D",Jc="Dilation2DBackpropInput",Qc="Dilation2DBackpropFilter",li="RealDiv",eh="Einsum",ui="Elu",th="EluGrad",ul="Erf",dl="Equal",di="Exp",pl="ExpandDims",cl="Expm1",nh="FFT",wd="Fill",hl="FlipLeftRight",pi="Floor",ci="FloorDiv",hi="FusedBatchNorm",fl="GatherV2",ml="GatherNd",gl="Greater",fi="GreaterEqual",mi="Identity",ah="IFFT",rh="Imag",yl="IsFinite",Al="IsInf",xl="IsNan",gi="LeakyRelu",bl="Less",vl="LessEqual",sh="LinSpace",yi="Log",wl="Log1p",kl="LogicalAnd",kd="LogicalNot",Id="LogicalOr",tb="LogSoftmax",Sd="LRN",ih="LRNGrad",Ai="Max",xi="Maximum",bi="MaxPool",oh="MaxPoolGrad",Nd="MaxPool3D",lh="MaxPool3DGrad",uh="MaxPoolWithArgmax",vi="Mean",wi="Min",ki="Minimum",Ii="MirrorPad",Il="Mod",dh="Multinomial",Si="Multiply",Sl="Neg",Nl="NotEqual",Tl="NonMaxSuppressionV3",Cl="NonMaxSuppressionV4",El="NonMaxSuppressionV5",Rl="OnesLike",Ni="OneHot",Ml="Pack",Ti="PadV2",UN="Pool",Ci="Pow",Ei="Prelu",Fl="Prod",Td="Range",ph="Real",Dl="Reciprocal",Ri="Relu",$l="Reshape",Cd="ResizeNearestNeighbor",ch="ResizeNearestNeighborGrad",Mi="ResizeBilinear",hh="ResizeBilinearGrad",Fi="Relu6",Di="Reverse",$i="Round",Oi="Rsqrt",Ol="ScatterNd",_l="Select",Pl="Selu",zl="Slice",_i="Sin",Ll="Sinh",Wl="Sign",Pi="Sigmoid",Bl="Softplus",zi="Sqrt",Li="Sum",Vl="SpaceToBatchND",Ul="SplitV",Wi="Softmax",fh="SparseFillEmptyRows",mh="SparseReshape",gh="SparseSegmentMean",yh="SparseSegmentSum",Ah="SparseToDense",Bi="SquaredDifference",Ed="Square",jl="StridedSlice",xh="StringNGrams",bh="StringSplit",vh="StringToHashBucketFast",Vi="Sub",Ui="Tan",ji="Tanh",ds="Tile",Gl="TopK",Hl="Transform",Gi="Transpose",wh="Unique",ql="Unpack",Rd="UnsortedSegmentSum",Xl="ZerosLike",ps="Step",kh="FromPixels",Kl="RotateWithOffset",Hi="_FusedMatMul",qi="FusedConv2D",Xi="FusedDepthwiseConv2D",Zl=P1("kernelRegistry",()=>new Map),Md=P1("gradRegistry",()=>new Map);function Ih(e,t){let n=L1(e,t);return Zl.get(n)}function z1(e){return Md.get(e)}function $r(e){let t=Zl.entries(),n=[];for(;;){let{done:a,value:r}=t.next();if(a)break;let[s,i]=r,[o]=s.split("_");o===e&&n.push(i)}return n}function cs(e){let{kernelName:t,backendName:n}=e,a=L1(t,n);Zl.has(a)&&pr(`The kernel '${t}' for backend '${n}' is already registered`),Zl.set(a,e)}function nb(e){let{kernelName:t}=e;Md.has(t)&&ne().getBool("DEBUG")&&pr(`Overriding the gradient for '${t}'`),Md.set(t,e)}function jN(e,t){let n=L1(e,t);if(!Zl.has(n))throw new Error(`The kernel '${e}' for backend '${t}' is not registered`);Zl.delete(n)}function GN(e){if(!Md.has(e))throw new Error(`The gradient '${e}' for backend is not registered`);Md.delete(e)}function HN(e,t){$r(e).forEach(n=>{let a=Object.assign({},n,{backendName:t});cs(a)})}function L1(e,t){return`${t}_${e}`}var w={};ze(w,{arraysEqual:()=>Dr,assert:()=>$,assertNonNegativeIntegerDimensions:()=>$1,assertNonNull:()=>Xs,assertShapesMatch:()=>Tn,bytesFromStringArray:()=>q5,bytesPerElement:()=>F1,checkConversionForErrors:()=>G5,clamp:()=>md,computeStrides:()=>qo,createScalarValue:()=>JN,createShuffledIndices:()=>RN,decodeString:()=>Th,distSquared:()=>NN,encodeString:()=>$d,fetch:()=>eT,fingerPrint64:()=>YN,flatten:()=>Ks,getArrayFromDType:()=>j5,getTypedArrayFromDType:()=>U5,hasEncodingLoss:()=>DN,hexToLong:()=>Fd,indexToLoc:()=>_N,inferDtype:()=>Pc,inferFromImplicitShape:()=>FN,isBoolean:()=>X5,isFunction:()=>os,isInt:()=>un,isNumber:()=>K5,isPromise:()=>O1,isScalarShape:()=>TN,isString:()=>is,isTypedArray:()=>In,isValidDtype:()=>H5,locToIndex:()=>ON,makeOnesTypedArray:()=>D1,makeZerosNestedTypedArray:()=>$N,makeZerosTypedArray:()=>Lc,nearestDivisor:()=>zc,nearestLargerEven:()=>kN,now:()=>Dd,parseAxisParam:()=>_a,randUniform:()=>SN,repeatedTry:()=>MN,rightPad:()=>gd,shuffle:()=>B5,shuffleCombo:()=>wN,sizeFromShape:()=>zt,sizeToSquarishShape:()=>EN,squeezeShape:()=>V5,sum:()=>IN,swap:()=>_c,tanh:()=>CN,toNestedArray:()=>Xo,toTypedArray:()=>Nh});var ab=qs(eN()),Ki=ab.default||ab;function Fd(e){return Ki.fromString(e,!0,16)}var rb=Fd("c3a5c85c97cb3127"),Zi=Fd("b492b66fbe98f273"),Cn=Fd("9ae16a3b2f90404f");function W1(e){return e.xor(e.shru(47))}function sb(e,t,n){let a=e.slice(t,t+n);return Ki.fromBytes(Array.from(a),!0,!0)}function At(e,t){return sb(e,t,8)}function ib(e,t){return sb(e,t,4)}function dn(e,t){return t===0?e:e.shru(t).or(e.shl(64-t))}function hs(e,t,n=Fd("9ddfea08eb382d69")){let a=e.xor(t).mul(n);a=a.xor(a.shru(47));let r=t.xor(a).mul(n);return r=r.xor(r.shru(47)),r=r.mul(n),r}function qN(e,t,n,a,r,s){r=r.add(e),s=dn(s.add(r).add(a),21);let i=r;return r=r.add(t),r=r.add(n),s=s.add(dn(r,44)),[r.add(a),s.add(i)]}function Sh(e,t,n,a){return qN(At(e,t),At(e,t+8),At(e,t+16),At(e,t+24),n,a)}function XN(e,t=e.length){if(t>=8){let n=Cn.add(t*2),a=At(e,0).add(Cn),r=At(e,t-8),s=dn(r,37).mul(n).add(a),i=dn(a,25).add(r).mul(n);return hs(s,i,n)}if(t>=4){let n=Cn.add(t*2),a=ib(e,0);return hs(a.shl(3).add(t),ib(e,t-4),n)}if(t>0){let n=e[0],a=e[t>>1],r=e[t-1],s=n+(a<<8),i=t+(r<<2);return W1(Cn.mul(s).xor(rb.mul(i))).mul(Cn)}return Cn}function KN(e,t=e.length){let n=Cn.add(t*2),a=At(e,0).mul(Zi),r=At(e,8),s=At(e,t-8).mul(n),i=At(e,t-16).mul(Cn);return hs(dn(a.add(r),43).add(dn(s,30)).add(i),a.add(dn(r.add(Cn),18)).add(s),n)}function ZN(e,t=e.length){let n=Cn.add(t*2),a=At(e,0).mul(Cn),r=At(e,8),s=At(e,t-8).mul(n),i=At(e,t-16).mul(Cn),o=dn(a.add(r),43).add(dn(s,30)).add(i),l=hs(o,a.add(dn(r.add(Cn),18)).add(s),n),d=At(e,16).mul(n),u=At(e,24),p=o.add(At(e,t-32)).mul(n),c=l.add(At(e,t-24)).mul(n);return hs(dn(d.add(u),43).add(dn(p,30)).add(c),d.add(dn(u.add(a),18)).add(p),n)}function YN(e,t=e.length){let n=Ki.fromNumber(81,!0);if(t<=32)return t<=16?XN(e,t):KN(e,t);if(t<=64)return ZN(e,t);let a=n,r=n.mul(Zi).add(113),s=W1(r.mul(Cn).add(113)).mul(Cn),i=[Ki.UZERO,Ki.UZERO],o=[Ki.UZERO,Ki.UZERO];a=a.mul(Cn).add(At(e,0));let l=0,d=(t-1>>6)*64,u=d+(t-1&63)-63;do a=dn(a.add(r).add(i[0]).add(At(e,l+8)),37).mul(Zi),r=dn(r.add(i[1]).add(At(e,l+48)),42).mul(Zi),a=a.xor(o[1]),r=r.add(i[0]).add(At(e,l+40)),s=dn(s.add(o[0]),33).mul(Zi),i=Sh(e,l,i[1].mul(Zi),a.add(o[0])),o=Sh(e,l+32,s.add(o[1]),r.add(At(e,l+16))),[s,a]=[a,s],l+=64;while(l!==d);let p=Zi.add(s.and(255).shl(1));return l=u,o[0]=o[0].add(t-1&63),i[0]=i[0].add(o[0]),o[0]=o[0].add(i[0]),a=dn(a.add(r).add(i[0]).add(At(e,l+8)),37).mul(p),r=dn(r.add(i[1]).add(At(e,l+48)),42).mul(p),a=a.xor(o[1].mul(9)),r=r.add(i[0].mul(9).add(At(e,l+40))),s=dn(s.add(o[0]),33).mul(p),i=Sh(e,l,i[1].mul(p),a.add(o[0])),o=Sh(e,l+32,s.add(o[1]),r.add(At(e,l+16))),[s,a]=[a,s],hs(hs(i[0],o[0],p).add(W1(r).mul(rb)).add(s),hs(i[1],o[1],p).add(a),p)}function JN(e,t){return t==="string"?$d(e):Nh([e],t)}function QN(e,t){return e instanceof Float32Array&&t==="float32"||e instanceof Int32Array&&t==="int32"||e instanceof Uint8Array&&t==="bool"}function Nh(e,t){if(t==="string")throw new Error("Cannot convert a string[] to a TypedArray");if(Array.isArray(e)&&(e=Ks(e)),ne().getBool("DEBUG")&&G5(e,t),QN(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 a=0;a<n.length;++a)Math.round(e[a])!==0&&(n[a]=1);return n}else throw new Error(`Unknown data type ${t}`)}function Dd(){return ne().platform.now()}function eT(e,t){return ne().platform.fetch(e,t)}function $d(e,t="utf-8"){return t=t||"utf-8",ne().platform.encode(e,t)}function Th(e,t="utf-8"){return t=t||"utf-8",ne().platform.decode(e,t)}var tT=class{constructor(e,t){this.backendTimer=e,this.logger=t,t==null&&(this.logger=new aT)}profileKernel(e,t,n){let a,r=()=>{a=n()},s,i=Dd();if(this.backendTimer.timerAvailable())s=this.backendTimer.time(r);else{r();for(let o of a)o.dataSync();s=Promise.resolve({kernelMs:Dd()-i})}if(ne().getBool("CHECK_COMPUTATION_FOR_ERRORS"))for(let o=0;o<a.length;o++){let l=a[o];l.data().then(d=>{nT(d,l.dtype,e)})}return{kernelName:e,outputs:a,inputs:t,timeMs:s.then(o=>o.kernelMs),extraInfo:s.then(o=>o.getExtraProfileInfo!=null?o.getExtraProfileInfo():"")}}logKernelProfile(e){let{kernelName:t,outputs:n,timeMs:a,inputs:r,extraInfo:s}=e;n.forEach(i=>{Promise.all([i.data(),a,s]).then(o=>{this.logger.logKernelProfile(t,i,o[0],o[1],r,o[2])})})}};function nT(e,t,n){if(t!=="float32")return!1;for(let a=0;a<e.length;a++){let r=e[a];if(isNaN(r)||!isFinite(r))return console.warn(`Found ${r} in the result of '${n}'`),!0}return!1}var aT=class{logKernelProfile(e,t,n,a,r,s){let i=typeof a=="number"?gd(`${a}ms`,9):a.error,o=gd(e,25),l=t.rank,d=t.size,u=gd(t.shape.toString(),14),p="";for(let c in r){let h=r[c];if(h!=null){let f=h.shape||t.shape,m=f.length;p+=`${c}: ${m}D ${m>0?f:""} `}}console.log(`%c${o} %c${i} %c${l}D ${u} %c${d} %c${p} %c${s}`,"font-weight:bold","color:red","color:blue","color: orange","color: green","color: steelblue")}};function rT(e,t,n){let a={},r={};for(let l=0;l<t.length;l++)a[t[l].id]=!0;for(let l=0;l<e.length;l++){let d=e[l],u=d.inputs;for(let p in u){let c=u[p],h=!1;for(let f=0;f<t.length;f++)if(a[c.id]){d.outputs.forEach(m=>a[m.id]=!0),h=!0,r[d.id]=!0;break}if(h)break}}let s={};s[n.id]=!0;let i={};for(let l=e.length-1;l>=0;l--){let d=e[l],u=d.inputs;for(let p=0;p<d.outputs.length;p++)if(s[d.outputs[p].id]){for(let c in u)s[u[c].id]=!0,i[d.id]=!0;break}}let o=[];for(let l=0;l<e.length;l++){let d=e[l];if(r[d.id]&&i[d.id]){let u={};for(let c in d.inputs){let h=d.inputs[c];a[h.id]&&(u[c]=h)}let p=Object.assign({},d);p.inputs=u,p.outputs=d.outputs,o.push(p)}}return o}function sT(e,t,n,a){for(let r=t.length-1;r>=0;r--){let s=t[r],i=[];if(s.outputs.forEach(l=>{let d=e[l.id];d!=null?i.push(d):i.push(null)}),s.gradient==null)throw new Error(`Cannot compute gradient: gradient function not found for ${s.kernelName}.`);let o=s.gradient(i);for(let l in s.inputs){if(!(l in o))throw new Error(`Cannot backprop through input ${l}. Available gradients found: ${Object.keys(o)}.`);let d=n(()=>o[l]());if(d.dtype!=="float32")throw new Error(`Error in gradient for op ${s.kernelName}. The gradient of input ${l} must have 'float32' dtype, but has '${d.dtype}'`);let u=s.inputs[l];if(!Dr(d.shape,u.shape))throw new Error(`Error in gradient for op ${s.kernelName}. The gradient of input '${l}' has shape '${d.shape}', which does not match the shape of the input '${u.shape}'`);if(e[u.id]==null)e[u.id]=d;else{let p=e[u.id];e[u.id]=a(p,d),p.dispose()}}}}var ob=20,Od=3,B1=7;function iT(e,t,n,a){let r=qo(t),s=oT(e,t,n,r),i=t.length,o=Ch(e,t,n,r,s),l=["Tensor"];return a&&(l.push(` dtype: ${n}`),l.push(` rank: ${i}`),l.push(` shape: [${t}]`),l.push(" values:")),l.push(o.map(d=>" "+d).join(`
|
|
`)),l.join(`
|
|
`)}function oT(e,t,n,a){let r=zt(t),s=a[a.length-1],i=new Array(s).fill(0),o=t.length,l=n==="complex64"?Pd(e):e;if(o>1)for(let d=0;d<r/s;d++){let u=d*s;for(let p=0;p<s;p++)i[p]=Math.max(i[p],_d(l[u+p],0,n).length)}return i}function _d(e,t,n){let a;return Array.isArray(e)?a=`${parseFloat(e[0].toFixed(B1))} + ${parseFloat(e[1].toFixed(B1))}j`:is(e)?a=`'${e}'`:n==="bool"?a=lb(e):a=parseFloat(e.toFixed(B1)).toString(),gd(a,t)}function lb(e){return e===0?"false":"true"}function Ch(e,t,n,a,r,s=!0){let i=n==="complex64"?2:1,o=t[0],l=t.length;if(l===0){if(n==="complex64"){let m=Pd(e);return[_d(m[0],0,n)]}return n==="bool"?[lb(e[0])]:[e[0].toString()]}if(l===1){if(o>ob){let g=Od*i,y=Array.from(e.slice(0,g)),A=Array.from(e.slice((o-Od)*i,o*i));return n==="complex64"&&(y=Pd(y),A=Pd(A)),["["+y.map((x,b)=>_d(x,r[b],n)).join(", ")+", ..., "+A.map((x,b)=>_d(x,r[o-Od+b],n)).join(", ")+"]"]}let m=n==="complex64"?Pd(e):Array.from(e);return["["+m.map((g,y)=>_d(g,r[y],n)).join(", ")+"]"]}let d=t.slice(1),u=a.slice(1),p=a[0]*i,c=[];if(o>ob){for(let m=0;m<Od;m++){let g=m*p,y=g+p;c.push(...Ch(e.slice(g,y),d,n,u,r,!1))}c.push("...");for(let m=o-Od;m<o;m++){let g=m*p,y=g+p;c.push(...Ch(e.slice(g,y),d,n,u,r,m===o-1))}}else for(let m=0;m<o;m++){let g=m*p,y=g+p;c.push(...Ch(e.slice(g,y),d,n,u,r,m===o-1))}let h=l===2?",":"";c[0]="["+c[0]+h;for(let m=1;m<c.length-1;m++)c[m]=" "+c[m]+h;let f=`,
|
|
`;for(let m=2;m<l;m++)f+=`
|
|
`;return c[c.length-1]=" "+c[c.length-1]+"]"+(s?"":f),c}function Pd(e){let t=[];for(let n=0;n<e.length;n+=2)t.push([e[n],e[n+1]]);return t}var Jt=class{constructor(e,t,n){if(this.dtype=t,this.shape=e.slice(),this.size=zt(e),n!=null){let a=n.length;$(a===this.size,()=>`Length of values '${a}' 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||j5(t,this.size),this.strides=qo(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 a of e){if(a<0||a>=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 a=0;a<e.length-1;++a)n+=this.strides[a]*e[a];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 hr().makeTensor(this.values,this.shape,this.dtype)}},hr=null,Yl=null,lT=null;function uT(e){hr=e}function dT(e){Yl=e}function pT(e){lT=e}var je=class{constructor(e,t,n,a){this.kept=!1,this.isDisposedInternal=!1,this.shape=e.slice(),this.dtype=t||"float32",this.size=zt(e),this.strides=qo(e),this.dataId=n,this.id=a,this.rankType=this.rank<5?this.rank.toString():"higher"}get rank(){return this.shape.length}async buffer(){let e=await this.data();return Yl.buffer(this.shape,this.dtype,e)}bufferSync(){return Yl.buffer(this.shape,this.dtype,this.dataSync())}async array(){let e=await this.data();return Xo(this.shape,e,this.dtype==="complex64")}arraySync(){return Xo(this.shape,this.dataSync(),this.dtype==="complex64")}async data(){this.throwIfDisposed();let e=hr().read(this.dataId);if(this.dtype==="string"){let t=await e;try{return t.map(n=>Th(n))}catch(n){throw new Error("Failed to decode the string bytes into utf-8. To get the original bytes, call tensor.bytes().")}}return e}dataSync(){this.throwIfDisposed();let e=hr().readSync(this.dataId);if(this.dtype==="string")try{return e.map(t=>Th(t))}catch(t){throw new Error("Failed to decode the string bytes into utf-8. To get the original bytes, call tensor.bytes().")}return e}async bytes(){this.throwIfDisposed();let e=await hr().read(this.dataId);return this.dtype==="string"?e:new Uint8Array(e.buffer)}dispose(){this.isDisposed||(hr().disposeTensor(this),this.isDisposedInternal=!0)}get isDisposed(){return this.isDisposedInternal}throwIfDisposed(){if(this.isDisposed)throw new Error("Tensor is disposed.")}print(e=!1){return Yl.print(this,e)}clone(){return this.throwIfDisposed(),Yl.clone(this)}toString(e=!1){let t=this.dataSync();return iT(t,this.shape,this.dtype,e)}cast(e){return this.throwIfDisposed(),Yl.cast(this,e)}variable(e=!0,t,n){return this.throwIfDisposed(),hr().makeVariable(this,e,t,n)}};Object.defineProperty(je,Symbol.hasInstance,{value:e=>!!e&&e.data!=null&&e.dataSync!=null&&e.throwIfDisposed!=null});function ae(){return P1("Tensor",()=>je)}ae();var zd=class extends je{constructor(e,t,n,a){super(e.shape,e.dtype,e.dataId,a);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(!Dr(e.shape,this.shape))throw new Error(`shape of the new value (${e.shape}) and previous value (${this.shape}) must match`);hr().disposeTensor(this),this.dataId=e.dataId,hr().incRef(this,null)}dispose(){hr().disposeVariable(this),this.isDisposedInternal=!0}};Object.defineProperty(zd,Symbol.hasInstance,{value:e=>e instanceof je&&e.assign!=null&&e.assign instanceof Function});var Xa={};ze(Xa,{assertTypesMatch:()=>ub,getTensorsInContainer:()=>q1,isTensorInList:()=>hT,makeTypesMatch:()=>Ft});var V1;(function(e){e.R0="R0",e.R1="R1",e.R2="R2",e.R3="R3",e.R4="R4",e.R5="R5",e.R6="R6"})(V1||(V1={}));var U1;(function(e){e.float32="float32",e.int32="int32",e.bool="int32",e.complex64="complex64"})(U1||(U1={}));var j1;(function(e){e.float32="float32",e.int32="int32",e.bool="bool",e.complex64="complex64"})(j1||(j1={}));var G1;(function(e){e.float32="float32",e.int32="float32",e.bool="float32",e.complex64="complex64"})(G1||(G1={}));var H1;(function(e){e.float32="complex64",e.int32="complex64",e.bool="complex64",e.complex64="complex64"})(H1||(H1={}));var cT={float32:G1,int32:U1,bool:j1,complex64:H1};function Pa(e,t){if(e==="string"||t==="string"){if(e==="string"&&t==="string")return"string";throw new Error(`Can not upcast ${e} with ${t}`)}return cT[e][t]}function Eh(e){return Pa(e,"int32")}function Ft(e,t){if(e.dtype===t.dtype)return[e,t];let n=Pa(e.dtype,t.dtype);return[e.cast(n),t.cast(n)]}function ub(e,t){$(e.dtype===t.dtype,()=>`The dtypes of the first(${e.dtype}) and second(${t.dtype}) input must match`)}function hT(e,t){return t.some(n=>n.id===e.id)}function q1(e){let t=[],n=new Set;return db(e,t,n),t}function db(e,t,n){if(e==null)return;if(e instanceof je){t.push(e);return}if(!fT(e))return;let a=e;for(let r in a){let s=a[r];n.has(s)||(n.add(s),db(s,t,n))}}function fT(e){return Array.isArray(e)||typeof e=="object"}function X1(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()}},Ld=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 tT(this.backendInstance),!0}setupRegisteredKernels(){$r(this.backendName).forEach(e=>{e.setupFunc!=null&&e.setupFunc(this.backendInstance)})}disposeRegisteredKernels(e){$r(e).forEach(t=>{t.disposeFunc!=null&&t.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 fd)&&typeof n.then=="function"){let a=++this.pendingBackendInitId,r=n.then(s=>a<this.pendingBackendInitId?!1:(this.registry[e]=s,this.pendingBackendInit=null,!0)).catch(s=>(a<this.pendingBackendInitId||(this.pendingBackendInit=null,pr(`Initialization of backend ${e} failed`),pr(s.stack||s.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:a,asyncInit:r}=this.initializeBackend(n);if(r||a)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),a=n.backend,r=this.readSync(t),s=a.refCount(t);a.disposeData(t,!0),n.backend=e,e.move(t,r,n.shape,n.dtype,s),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 a;return this.scopedRun(()=>this.startScope(n),()=>this.endScope(a),()=>(a=t(),a instanceof Promise&&console.error("Cannot return a Promise inside of tidy."),a))}scopedRun(e,t,n){e();try{let a=n();return t(),a}catch(a){throw t(),a}}nextTensorId(){return Ld.nextTensorId++}nextVariableId(){return Ld.nextVariableId++}clone(e){let t=W.runKernel(mi,{x:e}),n={x:e},a=s=>({x:()=>{let i="float32",o={x:s},l={dtype:i};return W.runKernel(ei,o,l)}}),r=[];return this.addTapeNode(this.state.activeScope.name,n,[t],a,r,{}),t}runKernel(e,t,n){if(this.backendName==null&&this.backend,Ih(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 a=this.backend.numDataIds(),r=0;n.forEach(o=>{r+=o.dtype==="complex64"?3:1});let s=this.state.numDataMovesStack[this.state.numDataMovesStack.length-1],i=a-t-r-s;if(i>0)throw new Error(`Backend '${this.backendName}' has an internal memory leak (${i} data ids) after running '${e}'`)}runKernelFunc(e){let t,n=[],a=this.isTapeOn(),r=this.state.numBytes,s=this.state.numTensors;this.shouldCheckForMemLeaks()&&this.state.numDataMovesStack.push(0);let i;this.backendName==null&&this.backend;let o,l=X1(e)?e.kernelName:this.state.activeScope!=null?this.state.activeScope.name:"";if(X1(e)){let{kernelName:h,inputs:f,attrs:m}=e;this.backendName==null&&this.backend;let g=Ih(h,this.backendName);$(g!=null,()=>`Cannot find registered kernel '${h}' for backend '${this.backendName}'`),i=()=>{let y=this.backend.numDataIds();o=g.kernelFunc({inputs:f,attrs:m,backend:this.backend});let A=Array.isArray(o)?o:[o];this.shouldCheckForMemLeaks()&&this.checkKernelForMemLeak(h,y,A);let x=A.map(b=>{if(b.rank!=null)return b;let{dataId:v,shape:k,dtype:T}=b;return this.makeTensorFromDataId(v,k,T)});if(a){let b=this.getTensorsForGradient(h,f,x);n=this.saveTensorsForBackwardMode(b)}return x}}else{let{forwardFunc:h}=e,f=m=>{!a||(n=m.map(g=>this.keep(this.clone(g))))};i=()=>{let m=this.backend.numDataIds();o=this.tidy(()=>h(this.backend,f));let g=Array.isArray(o)?o:[o];return this.shouldCheckForMemLeaks()&&this.checkKernelForMemLeak(l,m,g),g}}let{inputs:d,attrs:u}=e,p=X1(e)?null:e.backwardsFunc,c;return this.scopedRun(()=>this.state.kernelDepth++,()=>this.state.kernelDepth--,()=>{!this.ENV.getBool("DEBUG")&&!this.state.profiling?t=i():(c=this.profiler.profileKernel(l,d,()=>i()),this.ENV.getBool("DEBUG")&&this.profiler.logKernelProfile(c),t=c.outputs)}),a&&this.addTapeNode(l,d,t,p,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-s,totalTensorsSnapshot:this.state.numTensors,inputShapes:Object.keys(d).map(h=>d[h]!=null?d[h].shape:null),outputShapes:t.map(h=>h.shape),kernelTimeMs:c.timeMs,extraInfo:c.extraInfo}),Array.isArray(o)?t:t[0]}saveTensorsForBackwardMode(e){return e.map(t=>this.keep(this.clone(t)))}getTensorsForGradient(e,t,n){let a=z1(e);if(a!=null){let r=a.inputsToSave||[],s=a.outputsToSave||[],i;a.saveAllInputs?($(Array.isArray(t),()=>"saveAllInputs is true, expected inputs to be an array."),i=Object.keys(t).map(l=>t[l])):i=r.map(l=>t[l]);let o=n.filter((l,d)=>s[d]);return i.concat(o)}return[]}makeTensor(e,t,n,a){if(e==null)throw new Error("Values passed to engine.makeTensor() are null");n=n||"float32",a=a||this.backend;let r=e;n==="string"&&is(e[0])&&(r=e.map(o=>$d(o)));let s=a.write(r,t,n),i=new je(t,n,s,this.nextTensorId());if(this.trackTensor(i,a),n==="string"){let o=this.state.tensorInfo.get(s),l=q5(r);this.state.numBytes+=l-o.bytes,o.bytes=l}return i}makeTensorFromDataId(e,t,n,a){n=n||"float32";let r=new je(t,n,e,this.nextTensorId());return this.trackTensor(r,a),r}makeVariable(e,t=!0,n,a){n=n||this.nextVariableId().toString(),a!=null&&a!==e.dtype&&(e=e.cast(a));let r=new zd(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*F1(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 zd||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*F1(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(a=>a.totalBytesSnapshot)),this.state.activeProfile.newBytes=this.state.numBytes-t,this.state.activeProfile.newTensors=this.state.numTensors-n;for(let a of this.state.activeProfile.kernels)a.kernelTimeMs=await a.kernelTimeMs,a.extraInfo=await a.extraInfo;return this.state.activeProfile}isTapeOn(){return this.state.gradientDepth>0&&this.state.kernelDepth===0}addTapeNode(e,t,n,a,r,s){let i={id:this.state.nextTapeNodeId++,kernelName:e,inputs:t,outputs:n,saved:r},o=z1(e);o!=null&&(a=o.gradFunc),a!=null&&(i.gradient=l=>(l=l.map((d,u)=>{if(d==null){let p=n[u],c=Lc(p.size,p.dtype);return this.makeTensor(c,p.shape,p.dtype)}return d}),a(l.length>1?l:l[0],r,s))),this.state.activeTape.push(i)}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=q1(e),n=new Set(t.map(r=>r.id));for(let r=0;r<this.state.activeScope.track.length;r++){let s=this.state.activeScope.track[r];!s.kept&&!n.has(s.id)&&s.dispose()}let a=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===a.id&&this.track(r)})}gradients(e,t,n,a=!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 je,()=>"The result y returned by f() must be a tensor.");let s=rT(this.state.activeTape,t,r);if(!a&&s.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 i={};i[r.id]=n==null?mT(r.shape):n,sT(i,s,l=>this.tidy(l),gT);let o=t.map(l=>i[l.id]);return this.state.gradientDepth===0&&(this.state.activeTape.forEach(l=>{for(let d of l.saved)d.dispose()}),this.state.activeTape=null),{value:r,grads:o}})}customGrad(e){return $(os(e),()=>"The f passed in customGrad(f) must be a function."),(...t)=>{$(t.every(i=>i instanceof je),()=>"The args passed in customGrad(f)(x1, x2,...) must all be tensors");let n,a={};t.forEach((i,o)=>{a[o]=i});let r=(i,o)=>(n=e(...t,o),$(n.value instanceof je,()=>"The function f passed in customGrad(f) must return an object where `obj.value` is a tensor"),$(os(n.gradFunc),()=>"The function f passed in customGrad(f) must return an object where `obj.gradFunc` is a function."),n.value),s=(i,o)=>{let l=n.gradFunc(i,o),d=Array.isArray(l)?l:[l];$(d.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(...)."),$(d.every(p=>p instanceof je),()=>"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 d.forEach((p,c)=>{u[c]=()=>p}),u};return this.runKernelFunc({forwardFunc:r,backwardsFunc:s,inputs:a})}}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=Dd(),n=await this.backend.time(e);return n.wallMs=Dd()-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}};Ld.nextTensorId=0;Ld.nextVariableId=0;function mT(e){let t=D1(zt(e),"float32");return W.makeTensor(t,e,"float32")}function cb(){let e=Q5();if(e._tfengine==null){let t=new J5(e);e._tfengine=new Ld(t)}return BN(e._tfengine.ENV),uT(()=>e._tfengine),e._tfengine}var W=cb();function gT(e,t){let n={a:e,b:t};return W.runKernel(ls,n)}var Wd={};ze(Wd,{isBrowser:()=>hb,isMobile:()=>xT,mockIsMobile:()=>AT});function yT(){return typeof navigator!="undefined"&&navigator!=null}var K1;function AT(e){K1=e}function xT(e){if(K1!==void 0)return K1;if(e||yT()){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 hb(){return typeof window!="undefined"&&window.document!=null||typeof WorkerGlobalScope!="undefined"}var Ka=ne();Ka.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.")});Ka.registerFlag("IS_BROWSER",()=>hb());Ka.registerFlag("IS_NODE",()=>typeof process!="undefined"&&typeof process.versions!="undefined"&&typeof process.versions.node!="undefined");Ka.registerFlag("IS_CHROME",()=>typeof navigator!="undefined"&&navigator!=null&&navigator.userAgent!=null&&/Chrome/.test(navigator.userAgent)&&/Google Inc/.test(navigator.vendor));Ka.registerFlag("PROD",()=>!1);Ka.registerFlag("TENSORLIKE_CHECK_SHAPE_CONSISTENCY",()=>Ka.getBool("DEBUG"));Ka.registerFlag("DEPRECATION_WARNINGS_ENABLED",()=>!0);Ka.registerFlag("IS_TEST",()=>!1);Ka.registerFlag("CHECK_COMPUTATION_FOR_ERRORS",()=>!0);Ka.registerFlag("WRAP_TO_IMAGEBITMAP",()=>!1);function fr(e,t){let n=e;if(In(e))return t==="string"?[]:[e.length];if(!Array.isArray(e))return[];let a=[];for(;Array.isArray(n)||In(n)&&t!=="string";)a.push(n.length),n=n[0];return Array.isArray(e)&&ne().getBool("TENSORLIKE_CHECK_SHAPE_CONSISTENCY")&&fb(e,a,[]),a}function fb(e,t,n){if(n=n||[],!Array.isArray(e)&&!In(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 a=t.slice(1);for(let r=0;r<e.length;++r)fb(e[r],a,n.concat(r))}function mb(e,t,n,a){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 '${a}' must be ${e} tensor, but got ${t} tensor`)}}function M(e,t,n,a="numeric"){if(e instanceof je)return mb(a,e.dtype,t,n),e;let r=Pc(e);if(r!=="string"&&["bool","int32","float32"].indexOf(a)>=0&&(r=a),mb(a,r,t,n),e==null||!In(e)&&!Array.isArray(e)&&typeof e!="number"&&typeof e!="boolean"&&typeof e!="string"){let o=e==null?"null":e.constructor.name;throw new Error(`Argument '${t}' passed to '${n}' must be a Tensor or TensorLike, but got '${o}'`)}let s=fr(e,r);!In(e)&&!Array.isArray(e)&&(e=[e]);let i=r!=="string"?Nh(e,r):Ks(e,[],!0);return W.makeTensor(i,s,r)}function Bd(e,t,n,a="numeric"){if(!Array.isArray(e))throw new Error(`Argument ${t} passed to ${n} must be a \`Tensor[]\` or \`TensorLike[]\``);return e.map((r,s)=>M(r,`${t}[${s}]`,n,a))}var gb="__op";function B(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],a=e[n];n.endsWith("_")&&(n=n.substring(0,n.length-1)),n=n+gb;let r=(...s)=>{W.startScope(n);try{let i=a(...s);return O1(i)&&console.error("Cannot return a Promise inside of tidy."),W.endScope(i),i}catch(i){throw W.endScope(null),i}};return Object.defineProperty(r,"name",{value:n,configurable:!0}),r}function bT(e,t){let n=M(e,"real","complex"),a=M(t,"imag","complex");Tn(n.shape,a.shape,`real and imag shapes, ${n.shape} and ${a.shape}, must match in call to tf.complex().`);let r={real:n,imag:a};return W.runKernel(jc,r)}var fs=B({complex_:bT});function ms(e,t,n,a){if(a==null&&(a=Pc(e)),a==="complex64")throw new Error("Cannot construct a complex64 tensor directly. Please use tf.complex(real, imag).");if(!In(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){$1(t);let r=zt(t),s=zt(n);$(r===s,()=>`Based on the provided shape, [${t}], the tensor should have ${r} values but has ${s}`);for(let i=0;i<n.length;++i){let o=n[i],l=i===n.length-1?o!==zt(t.slice(i)):!0;$(n[i]===t[i]||!l,()=>`Error creating a new Tensor. Inferred shape (${n}) does not match the provided shape (${t}). `)}}return!In(e)&&!Array.isArray(e)&&(e=[e]),t=t||n,e=a!=="string"?Nh(e,a):Ks(e,[],!0),W.makeTensor(e,t,a)}function Lt(e,t,n){let a=fr(e,n);return ms(e,t,a,n)}var Z1={float32:4,float16:2,int32:4,uint16:2,uint8:1,bool:1,complex64:8},Rh=4;async function vT(e,t){let n=[],a=[],r=Array.isArray(e)?e.map(i=>i.name):Object.keys(e);for(let i=0;i<r.length;++i){let o=r[i],l=Array.isArray(e)?e[i].tensor:e[o];if(l.dtype!=="float32"&&l.dtype!=="int32"&&l.dtype!=="bool"&&l.dtype!=="string"&&l.dtype!=="complex64")throw new Error(`Unsupported dtype in weight '${o}': ${l.dtype}`);let d={name:o,shape:l.shape,dtype:l.dtype};if(l.dtype==="string"){let u=new Promise(async p=>{let c=await l.bytes(),h=c.reduce((g,y)=>g+y.length,0)+Rh*c.length,f=new Uint8Array(h),m=0;for(let g=0;g<c.length;g++){let y=c[g],A=new Uint8Array(new Uint32Array([y.length]).buffer);f.set(A,m),m+=Rh,f.set(y,m),m+=y.length}p(f)});a.push(u)}else a.push(l.data());t!=null&&(d.group=t),n.push(d)}let s=await Promise.all(a);return{data:wT(s),specs:n}}function yb(e,t){let n={},a,r=0;for(let s of t){let i=s.name,o=s.dtype,l=s.shape,d=zt(l),u;if("quantization"in s){let p=s.quantization;if(p.dtype==="uint8"||p.dtype==="uint16"){if(!("min"in p&&"scale"in p))throw new Error(`Weight ${s.name} with quantization ${p.dtype} doesn't have corresponding metadata min and scale.`)}else if(p.dtype==="float16"){if(o!=="float32")throw new Error(`Weight ${s.name} is quantized with ${p.dtype} which only supports weights of type float32 not ${o}.`)}else throw new Error(`Weight ${s.name} has unknown quantization dtype ${p.dtype}. Supported quantization dtypes are: 'uint8', 'uint16', and 'float16'.`);let c=Z1[p.dtype],h=e.slice(r,r+d*c),f=p.dtype==="uint8"?new Uint8Array(h):new Uint16Array(h);if(o==="float32")if(p.dtype==="uint8"||p.dtype==="uint16"){u=new Float32Array(f.length);for(let m=0;m<f.length;m++){let g=f[m];u[m]=g*p.scale+p.min}}else if(p.dtype==="float16")a===void 0&&(a=CT()),u=a(f);else throw new Error(`Unsupported quantization type ${p.dtype} for weight type float32.`);else if(o==="int32"){if(p.dtype!=="uint8"&&p.dtype!=="uint16")throw new Error(`Unsupported quantization type ${p.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*p.scale+p.min)}}else throw new Error(`Unsupported dtype in weight '${i}': ${o}`);r+=d*c}else if(o==="string"){let p=zt(s.shape);u=[];for(let c=0;c<p;c++){let h=new Uint32Array(e.slice(r,r+Rh))[0];r+=Rh;let f=new Uint8Array(e.slice(r,r+h));u.push(f),r+=h}}else{let p=Z1[o],c=e.slice(r,r+d*p);if(o==="float32")u=new Float32Array(c);else if(o==="int32")u=new Int32Array(c);else if(o==="bool")u=new Uint8Array(c);else if(o==="complex64"){u=new Float32Array(c);let h=new Float32Array(u.length/2),f=new Float32Array(u.length/2);for(let y=0;y<h.length;y++)h[y]=u[y*2],f[y]=u[y*2+1];let m=Lt(h,l,"float32"),g=Lt(f,l,"float32");n[i]=fs(m,g),m.dispose(),g.dispose()}else throw new Error(`Unsupported dtype in weight '${i}': ${o}`);r+=d*p}o!=="complex64"&&(n[i]=Lt(u,l,o))}return n}function wT(e){if(e===null)throw new Error(`Invalid input value: ${JSON.stringify(e)}`);let t=0,n=[];e.forEach(s=>{if(t+=s.byteLength,n.push(s.byteLength===s.buffer.byteLength?s:new s.constructor(s)),!(s instanceof Float32Array||s instanceof Int32Array||s instanceof Uint8Array))throw new Error(`Unsupported TypedArray subtype: ${s.constructor.name}`)});let a=new Uint8Array(t),r=0;return n.forEach(s=>{a.set(new Uint8Array(s.buffer),r),r+=s.byteLength}),a.buffer}var Y1=typeof Buffer!="undefined"&&(typeof Blob=="undefined"||typeof atob=="undefined"||typeof btoa=="undefined");function Ab(e){return Y1?Buffer.byteLength(e):new Blob([e]).size}function kT(e){if(Y1)return Buffer.from(e).toString("base64");let t=new Uint8Array(e),n="";for(let a=0,r=t.length;a<r;a++)n+=String.fromCharCode(t[a]);return btoa(n)}function IT(e){if(Y1){let a=Buffer.from(e,"base64");return a.buffer.slice(a.byteOffset,a.byteOffset+a.byteLength)}let t=atob(e),n=new Uint8Array(t.length);for(let a=0;a<t.length;++a)n.set([t.charCodeAt(a)],a);return n.buffer}function J1(e){if(e.length===1)return e[0];let t=0;e.forEach(r=>{t+=r.byteLength});let n=new Uint8Array(t),a=0;return e.forEach(r=>{n.set(new Uint8Array(r),a),a+=r.byteLength}),n.buffer}function xb(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 bb(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 Q1(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[a,r]=await t(e.weightsManifest);n.weightSpecs=a,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 Vd(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:Ab(JSON.stringify(e.modelTopology)),weightSpecsBytes:e.weightSpecs==null?0:Ab(JSON.stringify(e.weightSpecs)),weightDataBytes:e.weightData==null?0:e.weightData.byteLength}}function ST(){let e=n=>{let a=n<<13,r=0;for(;(a&8388608)==0;)r-=8388608,a<<=1;return a&=~8388608,r+=947912704,a|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 NT(){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 TT(){let e=new Uint32Array(64);for(let t=0;t<64;t++)e[t]=1024;return e[0]=e[32]=0,e}function CT(){let e=ST(),t=NT(),n=TT();return a=>{let r=new ArrayBuffer(4*a.length),s=new Uint32Array(r);for(let i=0;i<a.length;i++){let o=a[i],l=e[n[o>>10]+(o&1023)]+t[o>>10];s[i]=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 a=[];return(t==="load"?Pt.getInstance().loadRouters:Pt.getInstance().saveRouters).forEach(r=>{let s=r(e,n);s!==null&&a.push(s)}),a}},ET=e=>Pt.registerSaveRouter(e),RT=e=>Pt.registerLoadRouter(e),MT=e=>Pt.getSaveHandlers(e),FT=(e,t)=>Pt.getLoadHandlers(e,t),eg="tensorflowjs",tg=1,Yi="models_store",gs="model_info_store";function vb(){if(!ne().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 ng(e){let t=e.result;t.createObjectStore(Yi,{keyPath:"modelPath"}),t.createObjectStore(gs,{keyPath:"modelPath"})}var Ji=class{constructor(e){if(this.indexedDB=vb(),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,a)=>{let r=this.indexedDB.open(eg,tg);r.onupgradeneeded=()=>ng(r),r.onsuccess=()=>{let s=r.result;if(t==null){let i=s.transaction(Yi,"readonly"),o=i.objectStore(Yi).get(this.modelPath);o.onsuccess=()=>{if(o.result==null)return s.close(),a(new Error(`Cannot find model with path '${this.modelPath}' in IndexedDB.`));n(o.result.modelArtifacts)},o.onerror=l=>(s.close(),a(o.error)),i.oncomplete=()=>s.close()}else{let i=Vd(t),o=s.transaction(gs,"readwrite"),l=o.objectStore(gs),d=l.put({modelPath:this.modelPath,modelArtifactsInfo:i}),u;d.onsuccess=()=>{u=s.transaction(Yi,"readwrite");let p=u.objectStore(Yi).put({modelPath:this.modelPath,modelArtifacts:t,modelArtifactsInfo:i});p.onsuccess=()=>n({modelArtifactsInfo:i}),p.onerror=c=>{l=o.objectStore(gs);let h=l.delete(this.modelPath);h.onsuccess=()=>(s.close(),a(p.error)),h.onerror=f=>(s.close(),a(p.error))}},d.onerror=p=>(s.close(),a(d.error)),o.oncomplete=()=>{u==null?s.close():u.oncomplete=()=>s.close()}}},r.onerror=s=>a(r.error)})}};Ji.URL_SCHEME="indexeddb://";var wb=e=>ne().getBool("IS_BROWSER")&&!Array.isArray(e)&&e.startsWith(Ji.URL_SCHEME)?DT(e.slice(Ji.URL_SCHEME.length)):null;Pt.registerSaveRouter(wb);Pt.registerLoadRouter(wb);function DT(e){return new Ji(e)}function $T(e){return e.startsWith(Ji.URL_SCHEME)?e.slice(Ji.URL_SCHEME.length):e}var OT=class{constructor(){this.indexedDB=vb()}async listModels(){return new Promise((e,t)=>{let n=this.indexedDB.open(eg,tg);n.onupgradeneeded=()=>ng(n),n.onsuccess=()=>{let a=n.result,r=a.transaction(gs,"readonly"),s=r.objectStore(gs).getAll();s.onsuccess=()=>{let i={};for(let o of s.result)i[o.modelPath]=o.modelArtifactsInfo;e(i)},s.onerror=i=>(a.close(),t(s.error)),r.oncomplete=()=>a.close()},n.onerror=a=>t(n.error)})}async removeModel(e){return e=$T(e),new Promise((t,n)=>{let a=this.indexedDB.open(eg,tg);a.onupgradeneeded=()=>ng(a),a.onsuccess=()=>{let r=a.result,s=r.transaction(gs,"readwrite"),i=s.objectStore(gs),o=i.get(e),l;o.onsuccess=()=>{if(o.result==null)return r.close(),n(new Error(`Cannot find model with path '${e}' in IndexedDB.`));{let d=i.delete(e),u=()=>{l=r.transaction(Yi,"readwrite");let p=l.objectStore(Yi).delete(e);p.onsuccess=()=>t(o.result.modelArtifactsInfo),p.onerror=c=>n(o.error)};d.onsuccess=u,d.onerror=p=>(u(),r.close(),n(o.error))}},o.onerror=d=>(r.close(),n(o.error)),s.oncomplete=()=>{l==null?r.close():l.oncomplete=()=>r.close()}},a.onerror=r=>n(a.error)})}},Or="/",Jl="tensorflowjs_models",kb="info",_T="model_topology",PT="weight_specs",zT="weight_data",LT="model_metadata";function Ib(e){return{info:[Jl,e,kb].join(Or),topology:[Jl,e,_T].join(Or),weightSpecs:[Jl,e,PT].join(Or),weightData:[Jl,e,zT].join(Or),modelMetadata:[Jl,e,LT].join(Or)}}function Sb(e){for(let t of Object.values(e))window.localStorage.removeItem(t)}function WT(e){let t=e.split(Or);if(t.length<3)throw new Error(`Invalid key format: ${e}`);return t.slice(1,t.length-1).join(Or)}function BT(e){return e.startsWith(Qi.URL_SCHEME)?e.slice(Qi.URL_SCHEME.length):e}var Qi=class{constructor(e){if(!ne().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=Ib(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),a=Vd(e);try{this.LS.setItem(this.keys.info,JSON.stringify(a)),this.LS.setItem(this.keys.topology,t),this.LS.setItem(this.keys.weightSpecs,n),this.LS.setItem(this.keys.weightData,kT(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:a}}catch(r){throw Sb(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=${a.modelTopologyBytes}, weightSpecsBytes=${a.weightSpecsBytes}, weightDataBytes=${a.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 a=JSON.parse(this.LS.getItem(this.keys.weightSpecs));if(a==null)throw new Error(`In local storage, the weight specs of model '${this.modelPath}' are missing.`);t.weightSpecs=a;let r=this.LS.getItem(this.keys.modelMetadata);if(r!=null){let i=JSON.parse(r);t.format=i.format,t.generatedBy=i.generatedBy,t.convertedBy=i.convertedBy,i.signature!=null&&(t.signature=i.signature),i.userDefinedMetadata!=null&&(t.userDefinedMetadata=i.userDefinedMetadata),i.modelInitializer!=null&&(t.modelInitializer=i.modelInitializer),i.trainingConfig!=null&&(t.trainingConfig=i.trainingConfig)}let s=this.LS.getItem(this.keys.weightData);if(s==null)throw new Error(`In local storage, the binary weight values of model '${this.modelPath}' are missing.`);return t.weightData=IT(s),t}};Qi.URL_SCHEME="localstorage://";var Nb=e=>ne().getBool("IS_BROWSER")&&!Array.isArray(e)&&e.startsWith(Qi.URL_SCHEME)?VT(e.slice(Qi.URL_SCHEME.length)):null;Pt.registerSaveRouter(Nb);Pt.registerLoadRouter(Nb);function VT(e){return new Qi(e)}var UT=class{constructor(){$(ne().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=Jl+Or,n=Or+kb;for(let a=0;a<this.LS.length;++a){let r=this.LS.key(a);if(r.startsWith(t)&&r.endsWith(n)){let s=WT(r);e[s]=JSON.parse(this.LS.getItem(r))}}return e}async removeModel(e){e=BT(e);let t=Ib(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 Sb(t),n}},Ql="://",wa=class{constructor(){this.managers={}}static getInstance(){return wa.instance==null&&(wa.instance=new wa),wa.instance}static registerManager(e,t){$(e!=null,()=>"scheme must not be undefined or null."),e.endsWith(Ql)&&(e=e.slice(0,e.indexOf(Ql))),$(e.length>0,()=>"scheme must not be an empty string.");let n=wa.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 Mh(e){if(e.indexOf(Ql)===-1)throw new Error(`The url string provided does not contain a scheme. Supported schemes are: ${wa.getSchemes().join(",")}`);return{scheme:e.split(Ql)[0],path:e.split(Ql)[1]}}async function Tb(e,t,n=!1){$(e!==t,()=>`Old path and new path are the same: '${e}'`);let a=Pt.getLoadHandlers(e);$(a.length>0,()=>`Copying failed because no load handler is found for source URL ${e}.`),$(a.length<2,()=>`Copying failed because more than one (${a.length}) load handlers for source URL ${e}.`);let r=a[0],s=Pt.getSaveHandlers(t);$(s.length>0,()=>`Copying failed because no save handler is found for destination URL ${t}.`),$(s.length<2,()=>`Copying failed because more than one (${a.length}) save handlers for destination URL ${t}.`);let i=s[0],o=Mh(e).scheme,l=Mh(e).path,d=o===Mh(e).scheme,u=await r.load();n&&d&&await wa.getManager(o).removeModel(l);let p=await i.save(u);return n&&!d&&await wa.getManager(o).removeModel(l),p.modelArtifactsInfo}async function jT(){let e=wa.getSchemes(),t={};for(let n of e){let a=await wa.getManager(n).listModels();for(let r in a){let s=n+Ql+r;t[s]=a[r]}}return t}async function GT(e){let t=Mh(e);return wa.getManager(t.scheme).removeModel(t.path)}async function HT(e,t){return Tb(e,t,!1)}async function qT(e,t){return Tb(e,t,!0)}var XT=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(ne().get("IS_BROWSER")){ne().setPlatform("browser",new XT);try{wa.registerManager(Qi.URL_SCHEME,new UT)}catch(e){}try{wa.registerManager(Ji.URL_SCHEME,new OT)}catch(e){}}var KT={importFetch:()=>tN()},ag,ZT=class{constructor(){this.util=Ho("util"),this.textEncoder=new this.util.TextEncoder}fetch(e,t){return ne().global.fetch!=null?ne().global.fetch(e,t):(ag==null&&(ag=KT.importFetch()),ag(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)}};ne().get("IS_NODE")&&ne().setPlatform("node",new ZT);function Ge(e,t="float32",n){return t=t||"float32",$1(e),new Jt(e,t,n)}function YT(e,t){let n=M(e,"x","cast");if(!H5(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 a={x:n},r={dtype:t};return W.runKernel(ei,a,r)}var pe=B({cast_:YT});function JT(e){let t={x:M(e,"x","clone","string_or_numeric")};return W.runKernel(mi,t)}var Za=B({clone_:JT});function Cb(e,t=!1){console.log(e.toString(t))}cb();var QT={buffer:Ge,cast:pe,clone:Za,print:Cb};dT(QT);var Xn={};ze(Xn,{browserFiles:()=>iC,browserHTTPRequest:()=>pC,concatenateArrayBuffers:()=>J1,copyModel:()=>HT,decodeWeights:()=>yb,encodeWeights:()=>vT,fromMemory:()=>hC,getLoadHandlers:()=>FT,getModelArtifactsForJSON:()=>Q1,getModelArtifactsInfoForJSON:()=>Vd,getSaveHandlers:()=>MT,http:()=>ig,isHTTPScheme:()=>sg,listModels:()=>jT,loadWeights:()=>oC,moveModel:()=>qT,registerLoadRouter:()=>RT,registerSaveRouter:()=>ET,removeModel:()=>GT,weightsLoaderFactory:()=>Fb,withSaveHandler:()=>fC});var eC="model",tC=".json",nC=".weights.bin";function Eb(e){return new Promise(t=>setTimeout(t)).then(e)}var eu=class{constructor(e){if(!ne().getBool("IS_BROWSER"))throw new Error("browserDownloads() cannot proceed because the current environment is not a browser.");e.startsWith(eu.URL_SCHEME)&&(e=e.slice(eu.URL_SCHEME.length)),(e==null||e.length===0)&&(e=eC),this.modelJsonFileName=e+tC,this.weightDataFileName=e+nC}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}],a=bb(e,n),r=window.URL.createObjectURL(new Blob([JSON.stringify(a)],{type:"application/json"})),s=this.modelJsonAnchor==null?document.createElement("a"):this.modelJsonAnchor;if(s.download=this.modelJsonFileName,s.href=r,await Eb(()=>s.dispatchEvent(new MouseEvent("click"))),e.weightData!=null){let i=this.weightDataAnchor==null?document.createElement("a"):this.weightDataAnchor;i.download=this.weightDataFileName,i.href=t,await Eb(()=>i.dispatchEvent(new MouseEvent("click")))}return{modelArtifactsInfo:Vd(e)}}}};eu.URL_SCHEME="downloads://";var aC=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=a=>{let r=JSON.parse(a.target.result),s=r.modelTopology;if(s==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:s});return}let i=Q1(r,o=>this.loadWeights(o));e(i)},n.onerror=a=>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 s of e)t.push(...s.weights),n.push(...s.paths);let a=this.checkManifestAndWeightFiles(e),r=n.map(s=>this.loadWeightsFile(s,a[s]));return Promise.all(r).then(s=>[t,J1(s)])}loadWeightsFile(e,t){return new Promise((n,a)=>{let r=new FileReader;r.onload=s=>{let i=s.target.result;n(i)},r.onerror=s=>a(`Failed to weights data from file of path '${e}'.`),r.readAsArrayBuffer(t)})}checkManifestAndWeightFiles(e){let t=[],n=this.weightsFiles.map(r=>xb(r.name)),a={};for(let r of e)r.paths.forEach(s=>{let i=xb(s);if(t.indexOf(i)!==-1)throw new Error(`Duplicate file basename found in weights manifest: '${i}'`);if(t.push(i),n.indexOf(i)===-1)throw new Error(`Weight file with basename '${i}' is not provided.`);a[s]=this.weightsFiles[n.indexOf(i)]});if(t.length!==this.weightsFiles.length)throw new Error(`Mismatch in the number of files in weights manifest (${t.length}) and the number of weight files provided (${this.weightsFiles.length}).`);return a}},rC=e=>ne().getBool("IS_BROWSER")&&!Array.isArray(e)&&e.startsWith(eu.URL_SCHEME)?sC(e.slice(eu.URL_SCHEME.length)):null;Pt.registerSaveRouter(rC);function sC(e="model"){return new eu(e)}function iC(e){return new aC(e)}function Rb(e,t,n,a){i(e),n=n==null?0:n,a=a==null?1:a,o(n,a);let r=0,s=l=>(l.then(d=>{let u=n+ ++r/e.length*(a-n);return t(u),d}),l);function i(l){$(l!=null&&Array.isArray(l)&&l.length>0,()=>"promises must be a none empty array")}function o(l,d){$(l>=0&&l<=1,()=>`Progress fraction must be in range [0, 1], but got startFraction ${l}`),$(d>=0&&d<=1,()=>`Progress fraction must be in range [0, 1], but got endFraction ${d}`),$(d>=l,()=>`startFraction must be no more than endFraction, but got startFraction ${l} and endFraction ${d}`)}return Promise.all(e.map(s))}async function Mb(e,t){t==null&&(t={});let n=t.fetchFunc==null?ne().platform.fetch:t.fetchFunc,a=e.map(d=>n(d,t.requestInit,{isBinary:!0})),r=0,s=.5,i=(t.onProgress==null?await Promise.all(a):await Rb(a,t.onProgress,r,s)).map(d=>d.arrayBuffer()),o=.5,l=1;return t.onProgress==null?await Promise.all(i):await Rb(i,t.onProgress,o,l)}async function oC(e,t="",n,a){return Fb(r=>Mb(r,{requestInit:a}))(e,t,n)}function Fb(e){return async(t,n="",a)=>{let r=t.map(()=>!1),s={},i=a!=null?a.map(()=>!1):[],o=[];if(t.forEach((h,f)=>{let m=0;h.weights.forEach(g=>{let y="quantization"in g?g.quantization.dtype:g.dtype,A=Z1[y]*zt(g.shape),x=()=>{r[f]=!0,s[f]==null&&(s[f]=[]),s[f].push({manifestEntry:g,groupOffset:m,sizeBytes:A})};a!=null?a.forEach((b,v)=>{b===g.name&&(x(),i[v]=!0)}):x(),o.push(g.name),m+=A})}),!i.every(h=>h)){let h=a.filter((f,m)=>!i[m]);throw new Error(`Could not find weights in manifest with names: ${h.join(", ")}.
|
|
Manifest JSON has weights with names: ${o.join(", ")}.`)}let l=r.reduce((h,f,m)=>(f&&h.push(m),h),[]),d=[];l.forEach(h=>{t[h].paths.forEach(f=>{let m=n+(n.endsWith("/")?"":"/")+f;d.push(m)})});let u=await e(d),p={},c=0;return l.forEach(h=>{let f=t[h].paths.length,m=0;for(let x=0;x<f;x++)m+=u[c+x].byteLength;let g=new ArrayBuffer(m),y=new Uint8Array(g),A=0;for(let x=0;x<f;x++){let b=new Uint8Array(u[c+x]);y.set(b,A),A+=b.byteLength}s[h].forEach(x=>{let b=g.slice(x.groupOffset,x.groupOffset+x.sizeBytes),v=yb(b,[x.manifestEntry]);for(let k in v)p[k]=v[k]}),c+=f}),p}}var lC="application/octet-stream",uC="application/json",rg=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=ne().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}],a=bb(e,n);t.body.append("model.json",new Blob([JSON.stringify(a)],{type:uC}),"model.json"),e.weightData!=null&&t.body.append("model.weights.bin",new Blob([e.weightData],{type:lC}),"model.weights.bin");let r=await this.fetch(this.path,t);if(r.ok)return{modelArtifactsInfo:Vd(e),responses:[r]};throw new Error(`BrowserHTTPRequest.save() failed due to HTTP response status ${r.status}.`)}async load(){let e=await this.fetch(this.path,this.requestInit);if(!e.ok)throw new Error(`Request to ${this.path} failed with status code ${e.status}. Please verify this URL points to the model JSON of the model to load.`);let t;try{t=await e.json()}catch(r){let s=`Failed to parse model JSON of response from ${this.path}.`;throw this.path.endsWith(".pb")?s+=" 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.":s+=" Please make sure the server is serving valid JSON for this request.",new Error(s)}let n=t.modelTopology,a=t.weightsManifest;if(n==null&&a==null)throw new Error(`The JSON from HTTP path ${this.path} contains neither model topology or manifest for weights.`);return Q1(t,r=>this.loadWeights(r))}async loadWeights(e){let t=Array.isArray(this.path)?this.path[1]:this.path,[n,a]=dC(t),r=this.weightPathPrefix||n,s=[];for(let d of e)s.push(...d.weights);let i=[],o=[];for(let d of e)for(let u of d.paths)this.weightUrlConverter!=null?o.push(this.weightUrlConverter(u)):i.push(r+u+a);this.weightUrlConverter&&i.push(...await Promise.all(o));let l=await Mb(i,{requestInit:this.requestInit,fetchFunc:this.fetch,onProgress:this.onProgress});return[s,J1(l)]}};rg.URL_SCHEME_REGEX=/^https?:\/\//;function dC(e){let t=e.lastIndexOf("/"),n=e.lastIndexOf("?"),a=e.substring(0,t),r=n>t?e.substring(n):"";return[a+"/",r]}function sg(e){return e.match(rg.URL_SCHEME_REGEX)!=null}var Db=(e,t)=>{if(typeof fetch=="undefined"&&(t==null||t.fetchFunc==null))return null;{let n=!0;if(Array.isArray(e)?n=e.every(a=>sg(a)):n=sg(e),n)return ig(e,t)}return null};Pt.registerSaveRouter(Db);Pt.registerLoadRouter(Db);function ig(e,t){return new rg(e,t)}function pC(e,t){return ig(e,t)}var og=class{constructor(e){this.modelArtifacts=e}async load(){return this.modelArtifacts}},cC=class{constructor(e){this.saveHandler=e}async save(e){return this.saveHandler(e)}};function hC(e,t,n,a){return arguments.length===1?e.modelTopology!=null||e.weightSpecs!=null?new og(e):(console.warn("Please call tf.io.fromMemory() with only one argument. The argument should be of type ModelArtifacts. The multi-argument signature of tf.io.fromMemory() has been deprecated and will be removed in a future release."),new og({modelTopology:e})):(console.warn("Please call tf.io.fromMemory() with only one argument. The argument should be of type ModelArtifacts. The multi-argument signature of tf.io.fromMemory() has been deprecated and will be removed in a future release."),new og({modelTopology:e,weightSpecs:t,weightData:n,trainingConfig:a}))}function fC(e){return new cC(e)}var $b={};ze($b,{confusionMatrix:()=>xC});function mC(e,t,n=!1,a=!1){let r=M(e,"a","matMul"),s=M(t,"b","matMul");[r,s]=Ft(r,s);let i={a:r,b:s},o={transposeA:n,transposeB:a};return W.runKernel(Qs,i,o)}var Ve=B({matMul_:mC});function gC(e,t,n=1,a=0){if(t<2)throw new Error(`Error in oneHot: depth must be >=2, but it is ${t}`);let r={indices:M(e,"indices","oneHot","int32")},s={depth:t,onValue:n,offValue:a};return W.runKernel(Ni,r,s)}var tu=B({oneHot_:gC});function yC(e,t){let n=M(e,"x","transpose");if(t==null&&(t=n.shape.map((s,i)=>i).reverse()),$(n.rank===t.length,()=>`Error in transpose: rank of input ${n.rank} must match length of perm ${t}.`),t.forEach(s=>{$(s>=0&&s<n.rank,()=>`All entries in 'perm' must be between 0 and ${n.rank-1} but got ${t}`)}),n.rank<=1)return n.clone();let a={x:n},r={perm:t};return W.runKernel(Gi,a,r)}var Ze=B({transpose_:yC});function AC(e,t,n){let a=M(e,"labels","confusionMatrix"),r=M(t,"predictions","confusionMatrix");$(n==null||n>0&&Number.isInteger(n),()=>`If provided, numClasses must be a positive integer, but got ${n}`),$(a.rank===1,()=>`Expected the rank of labels to be 1, but got ${a.rank}`),$(r.rank===1,()=>`Expected the rank of predictions to be 1, but got ${r.rank}`),$(a.shape[0]===r.shape[0],()=>`Mismatch in the number of examples: ${a.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 s=tu(pe(a,"int32"),n),i=tu(pe(r,"int32"),n),o=Ze(s),l=Ve(o,i);return pe(l,"int32")}var xC=B({confusionMatrix_:AC}),za={};ze(za,{fromPixels:()=>NC,fromPixelsAsync:()=>IC,toPixels:()=>SC});function Ob(e,t,n){if(Xs(e),t!=null&&t.length!==3)throw new Error("tensor3d() requires shape to have three numbers");let a=fr(e,n);if(a.length!==3&&a.length!==1)throw new Error("tensor3d() requires values to be number[][][] or flat/TypedArray");if(a.length===1&&t==null)throw new Error("tensor3d() requires shape to be provided when `values` are a flat array");return ms(e,t,a,n)}var nu;function _b(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,a=!1,r=!1,s=!1,i=!1,o=!1;if(e.data instanceof Uint8Array)n=!0;else if(typeof ImageData!="undefined"&&e instanceof ImageData)a=!0;else if(typeof HTMLVideoElement!="undefined"&&e instanceof HTMLVideoElement)r=!0;else if(typeof HTMLImageElement!="undefined"&&e instanceof HTMLImageElement)s=!0;else if(e.getContext!=null)i=!0;else if(typeof ImageBitmap!="undefined"&&e instanceof ImageBitmap)o=!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 c=2;if(r&&e.readyState<c)throw new Error("The video element has not loaded data yet. Please wait for `loadeddata` event on the <video> element.")}if(Ih(kh,W.backendName)!=null){let c={pixels:e},h={numChannels:t};return W.runKernel(kh,c,h)}let[l,d]=r?[e.videoWidth,e.videoHeight]:[e.width,e.height],u;i?u=e.getContext("2d").getImageData(0,0,l,d).data:a||n?u=e.data:(s||r||o)&&(nu==null&&(nu=document.createElement("canvas").getContext("2d")),nu.canvas.width=l,nu.canvas.height=d,nu.drawImage(e,0,0,l,d),u=nu.getImageData(0,0,l,d).data);let p;if(t===4)p=new Int32Array(u);else{let c=l*d;p=new Int32Array(c*t);for(let h=0;h<c;h++)for(let f=0;f<t;++f)p[h*t+f]=u[h*4+f]}return Ob(p,[d,l,t],"int32")}function bC(e){return e!=null&&e.data instanceof Uint8Array}function vC(){return typeof window!="undefined"&&typeof ImageBitmap!="undefined"&&window.hasOwnProperty("createImageBitmap")}function wC(e){return e!=null&&e.width!==0&&e.height!==0}function kC(e){return vC()&&!(e instanceof ImageBitmap)&&wC(e)&&!bC(e)}async function IC(e,t=3){let n=null;if(ne().getBool("WRAP_TO_IMAGEBITMAP")&&kC(e)){let a;try{a=await createImageBitmap(e,{premultiplyAlpha:"none"})}catch(r){a=null}a!=null&&a.width===e.width&&a.height===e.height?n=a:n=e}else n=e;return _b(n,t)}async function SC(e,t){let n=M(e,"img","toPixels");if(!(e instanceof je)){let d=n;n=pe(d,"int32"),d.dispose()}if(n.rank!==2&&n.rank!==3)throw new Error(`toPixels only supports rank 2 or 3 tensors, got rank ${n.rank}.`);let[a,r]=n.shape.slice(0,2),s=n.rank===2?1:n.shape[2];if(s>4||s===2)throw new Error(`toPixels only supports depth of size 1, 3 or 4 but got ${s}`);if(n.dtype!=="float32"&&n.dtype!=="int32")throw new Error(`Unsupported type for toPixels: ${n.dtype}. Please use float32 or int32 tensors.`);let i=await n.data(),o=n.dtype==="float32"?255:1,l=new Uint8ClampedArray(r*a*4);for(let d=0;d<a*r;++d){let u=[0,0,0,255];for(let c=0;c<s;c++){let h=i[d*s+c];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}.`);s===1?(u[0]=h*o,u[1]=h*o,u[2]=h*o):u[c]=h*o}let p=d*4;l[p+0]=Math.round(u[0]),l[p+1]=Math.round(u[1]),l[p+2]=Math.round(u[2]),l[p+3]=Math.round(u[3])}if(t!=null){t.width=r,t.height=a;let d=t.getContext("2d"),u=new ImageData(l,r,a);d.putImageData(u,0,0)}return n!==e&&n.dispose(),l}var NC=B({fromPixels_:_b}),lg={};ze(lg,{prepareAndValidate:()=>Pb});function Pb(e,t){let n=e.shape.length,a=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(a<1)throw new Error(`tf.gatherND() expects the indices to be rank 1 or higher, but the rank was ${a}.`);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[a-1]>n)throw new Error(`index innermost dimension length must be <= tensor rank; saw: ${t.shape[a-1]} vs. ${n}`);if(zt(e.shape)===0)throw new Error(`Requested more than 0 entries, but input is empty. Input shape: ${e.shape}.`);let r=t.shape,s=r[r.length-1],i=1;for(let p=0;p<r.length-1;++p)i*=r[p];let o=e.shape,l=r.slice();l.pop();let d=1;for(let p=s;p<n;++p)d*=o[p],l.push(o[p]);let u=[...qo(e.shape).map(p=>p/d),1].slice(0,s);return[l,i,d,u]}var ug={};ze(ug,{calculateShapes:()=>zb,validateInput:()=>pg,validateUpdateShape:()=>dg});function dg(e,t,n){let a=t.rank>1?t.shape[t.rank-1]:1,r=t.rank>1?t.rank-1:1,s=`Must have updates.shape = indices.shape[:batchDim] + shape[sliceDim:], got updates.shape: ${n.shape}, indices.shape: ${t.shape}, shape: ${e}, sliceDim: ${a}, and batchDim: ${r}.`;if(n.rank<r)throw new Error(s+` update.rank < ${r}. `);if(e.length<a+(n.rank-r))throw new Error(s+` Output shape length < ${a+(n.rank-r)}`);if(n.rank!==r+e.length-a)throw new Error(s+` update.rank != ${r+e.length-a}`);for(let i=0;i<r;++i)if(n.shape[i]!==t.shape[i])throw new Error(s+` updates.shape[${i}] (${n.shape[i]}) != indices.shape[${i}] (${t.shape[i]}).`);for(let i=0;i<n.rank-r;++i)if(n.shape[i+r]!==e[i+a])throw new Error(s+` updates.shape[${i+r}] (${n.shape[i+r]}) != shape[${i+r}] (${e[i+r]})`)}function pg(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}`)}dg(n,t,e)}function zb(e,t,n){let a=t.shape.length,r=a>1?t.shape[a-1]:1,s=n.length,i=1;for(let p=r;p<s;++p)i*=n[p];let o=r<1?1:r,l=zt(t.shape)/o,d=[...qo(n.slice(0,r)),1],u=zt(n);return{sliceRank:r,numUpdates:l,sliceSize:i,strides:d,outputSize:u}}var En={};ze(En,{assertParamsValid:()=>TC,computeFlatOffset:()=>EC,computeOutShape:()=>Lb,getNormalizedAxes:()=>Ub,isSliceContinous:()=>CC,maskToAxes:()=>Fh,parseSliceParams:()=>Kb,sliceInfo:()=>RC,startForAxis:()=>qb,startIndicesWithElidedDims:()=>jb,stopForAxis:()=>Xb,stopIndicesWithElidedDims:()=>Gb,stridesForAxis:()=>Hb,stridesWithElidedDims:()=>Wb});function TC(e,t,n){let a=e.shape.length;$(a===t.length,()=>`Error in slice${a}D: Length of begin ${t} must match the rank of the array (${a}).`),$(a===n.length,()=>`Error in slice${a}D: Length of size ${n} must match the rank of the array (${a}).`);for(let r=0;r<a;++r)$(t[r]+n[r]<=e.shape[r],()=>`Error in slice${a}D: begin[${r}] + size[${r}] (${t[r]+n[r]}) would overflow input.shape[${r}] (${e.shape[r]})`)}function Fh(e){let t=[],n=0;for(;e>0;)e&1&&t.push(n),e/=2,n++;return t}function Lb(e,t,n){let a=[];for(let r=0;r<e.length;r++)a[r]=Math.ceil((t[r]-e[r])/n[r]);return a}function Wb(e,t,n,a){let r=[...e];for(let s=r.length;s<a.length;s++)r.push(1);for(let s=0;s<n;s++)s===0?r[t]=1:(r.splice(t,0,1),r.pop());return r}function Bb(e,t,n){return n<=e?n:n-(t-1)}function Vb(e,t){let n=[];for(let a=0;a<e;a++)n.push(t+a);return n}function Ub(e,t,n,a,r,s,i,o,l){let d=e.length,u=new Array(d),p=new Array(d),c=new Array(d);if(t.length&&n>0){let h=t[0],f=n+1;u=jb(i,h,f,a,e),p=Gb(o,h,f,r,e),c=Wb(s,h,f,e)}else for(let h=0;h<d;h++)u[h]=qb(i,a,s,e,h,l),p[h]=Xb(o,r,s,e,h,l),c[h]=Hb(s,h,l);return{begin:u,end:p,strides:c}}function jb(e,t,n,a,r){let s=[...r],i=Vb(n,t);for(let o=0;o<s.length;o++)if(i.indexOf(o)>-1)s[o]=0;else{let l=Bb(t,n,o),d=a[l];e&1<<l&&(d=0),s[o]=d}return s}function Gb(e,t,n,a,r){let s=[...r],i=Vb(n,t);for(let o=0;o<s.length;o++)if(i.indexOf(o)>-1)s[o]=Number.MAX_SAFE_INTEGER;else{let l=Bb(t,n,o),d=a[l];e&1<<l&&(d=Number.MAX_SAFE_INTEGER),s[o]=d}for(let o=0;o<s.length;o++){let l=r[o];s[o]<0&&(s[o]+=l),s[o]=md(0,s[o],r[o])}return s}function Hb(e,t,n){let a=e[t];return(n&1<<t||a==null)&&(a=1),a}function qb(e,t,n,a,r,s){let i=t[r],o=n[r]||1;(e&1<<r||s&1<<r||i==null)&&(o>0?i=Number.MIN_SAFE_INTEGER:i=Number.MAX_SAFE_INTEGER);let l=a[r];return i<0&&(i+=l),i=md(0,i,l-1),i}function Xb(e,t,n,a,r,s){let i=t[r],o=n[r]||1;(e&1<<r||s&1<<r||i==null)&&(o>0?i=Number.MAX_SAFE_INTEGER:i=Number.MIN_SAFE_INTEGER);let l=a[r];return i<0&&(i+=l),o>0?i=md(0,i,l):i=md(-1,i,l-1),i}function CC(e,t,n){let a=n.length;for(let r=0;r<n.length;r++)if(n[r]>1){a=r;break}for(let r=a+1;r<n.length;r++)if(t[r]>0||n[r]!==e[r])return!1;return!0}function EC(e,t){let n=e.length>0?e[e.length-1]:1;for(let a=0;a<e.length-1;a++)n+=e[a]*t[a];return n}function Kb(e,t,n){let a,r=e.shape.length;typeof t=="number"?a=[t,...new Array(r-1).fill(0)]:t.length<r?a=t.concat(new Array(r-t.length).fill(0)):a=t.slice(),a.forEach(i=>{$(i!==-1,()=>"slice() does not support negative begin indexing.")});let s;return n==null?s=new Array(r).fill(-1):typeof n=="number"?s=[n,...new Array(r-1).fill(-1)]:n.length<r?s=n.concat(new Array(r-n.length).fill(-1)):s=n,s=s.map((i,o)=>i>=0?i:($(i===-1,()=>`Negative size values should be exactly -1 but got ${i} for the slice() size at index ${o}.`),e.shape[o]-a[o])),[a,s]}function RC(e,t,n,a,r,s,i,o,l){let d=t.slice(),u=n.slice(),p=a;a==null&&(p=new Array(d.length));let c=Fh(i);if(c.length>1)throw new Error("Multiple ellipses in slice is not allowed.");if(i!==0&&o!==0)throw new Error("Using both ellipsisMask and newAxisMask is not yet supported.");if(i!==0&&l!==0)throw new Error("Using both ellipsisMask and shrinkAxisMask is not yet supported.");let h=e.length-d.length,f=Fh(o),m=e.slice();f.forEach(k=>{d[k]=0,u[k]=1,m.splice(k,0,1)});let{begin:g,end:y,strides:A}=Ub(m,c,h,d,u,p,r,s,i);d=g,u=y,p=A;let x=Fh(l);x.forEach(k=>{u[k]=d[k]+1,p[k]=1});let b=Lb(d,u,p),v=b.filter((k,T)=>x.indexOf(T)===-1);return{nonStrided:p.every(k=>k===1),$begin:d,$end:u,$strides:p,size:b,newShape:m,outShape:v}}var ue={};ze(ue,{Serializable:()=>Zb,SerializationMap:()=>eo,registerClass:()=>ys});var Zb=class{getClassName(){return this.constructor.className}static fromConfig(e,t){return new e(t)}},eo=class{constructor(){this.classNameMap={}}static getMap(){return eo.instance==null&&(eo.instance=new eo),eo.instance}static register(e){eo.getMap().classNameMap[e.className]=[e,e.fromConfig]}};function ys(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."),eo.register(e)}var Yb={};ze(Yb,{TEST_EPSILON_FLOAT16:()=>Jb,encodeStrings:()=>Qb,expectArrayBuffersEqual:()=>PC,expectArraysClose:()=>FC,expectArraysEqual:()=>$C,expectNumbersClose:()=>OC,expectPromiseToFail:()=>DC,expectValuesInRange:()=>_C,testEpsilon:()=>cg});var MC=.001,Jb=.1;function FC(e,t,n){return n==null&&(n=cg()),hg(e,t,(a,r)=>fg(a,r,n))}function cg(){return W.backend.floatPrecision()===32?MC:Jb}function hg(e,t,n){let a=!0;if((In(e)||In(t))&&(a=!1),In(e)&&In(t)&&(a=!0),a){let i=e.constructor.name,o=t.constructor.name;if(i!==o)throw new Error(`Arrays are of different type. Actual: ${i}. Expected: ${o}`)}if(Array.isArray(e)&&Array.isArray(t)){let i=fr(e),o=fr(t);if(!Dr(i,o))throw new Error(`Arrays have different shapes. Actual: [${i}]. Expected: [${o}]`)}let r=In(e)?e:Ks(e),s=In(t)?t:Ks(t);if(r.length!==s.length)throw new Error(`Arrays have different lengths actual: ${r.length} vs expected: ${s.length}.
|
|
Actual: ${r}.
|
|
Expected: ${s}.`);for(let i=0;i<s.length;++i){let o=r[i],l=s[i];if(!n(o,l))throw new Error(`Arrays differ: actual[${i}] = ${o}, expected[${i}] = ${l}.
|
|
Actual: ${r}.
|
|
Expected: ${s}.`)}}function DC(e,t){e().then(()=>t.fail(),()=>t())}function $C(e,t){let n=typeof t=="string"||typeof t=="number"||typeof t=="boolean"?[t]:t;return is(e)||is(e[0])||is(t)||is(t[0])?hg(e,n,(a,r)=>a==r):hg(e,t,(a,r)=>fg(a,r,0))}function OC(e,t,n){if(n==null&&(n=cg()),!fg(e,t,n))throw new Error(`Numbers differ: actual === ${e}, expected === ${t}`)}function fg(e,t,n){return!isFinite(e)&&!isFinite(t)?!0:!(isNaN(e)||isNaN(t)||Math.abs(e-t)>n)}function _C(e,t,n){for(let a=0;a<e.length;a++)if(e[a]<t||e[a]>n)throw new Error(`Value out of range:${e[a]} low: ${t}, high: ${n}`)}function PC(e,t){expect(new Float32Array(e)).toEqual(new Float32Array(t))}function Qb(e){for(let t=0;t<e.length;t++){let n=e[t];Array.isArray(n)?Qb(n):e[t]=$d(n)}return e}var Ud="3.10.0";function e3(){ne().set("PROD",!0)}function zC(){ne().set("DEBUG",!0)}function LC(){ne().set("DEPRECATION_WARNINGS_ENABLED",!1),console.warn("TensorFlow.js deprecation warnings have been disabled.")}function mg(e){ne().getBool("DEPRECATION_WARNINGS_ENABLED")&&console.warn(e+" You can disable deprecation warnings with tf.disableDeprecationWarnings().")}pT(mg);function WC(){W.disposeVariables()}function sa(){return W}function Dh(){return W.memory()}function BC(e){return W.profile(e)}function G(e,t){return W.tidy(e,t)}function Q(e){q1(e).forEach(t=>t.dispose())}function pn(e){return W.keep(e)}function VC(e){return W.time(e)}function t3(e){return W.setBackend(e)}function $h(){return W.ready()}function Ya(){return W.backendName}function UC(e){W.removeBackend(e)}function gg(e){return W.findBackend(e)}function jC(e){return W.findBackendFactory(e)}function au(e,t,n=1){return W.registerBackend(e,t,n)}function mr(){return W.backend}function GC(e,t){ne().setPlatform(e,t)}function HC(e,t){let n=M(e,"a","add"),a=M(t,"b","add");[n,a]=Ft(n,a);let r={a:n,b:a};return W.runKernel(ls,r)}var le=B({add_:HC});function qC(e,t){let n=M(e,"a","floorDiv"),a=M(t,"b","floorDiv");[n,a]=Ft(n,a);let r={a:n,b:a};return W.runKernel(ci,r)}var Oh=B({floorDiv_:qC});function XC(e,t){let n=M(e,"a","div"),a=M(t,"b","div");if([n,a]=Ft(n,a),n.dtype==="int32"&&a.dtype==="int32")return Oh(n,a);let r={a:n,b:a},s={};return W.runKernel(li,r,s)}var he=B({div_:XC});function KC(e,t){let n=M(e,"a","mul"),a=M(t,"b","mul");[n,a]=Ft(n,a);let r={a:n,b:a};return W.runKernel(Si,r)}var L=B({mul_:KC});function ZC(e){let t=M(e,"x","abs");if(t.dtype==="complex64"){let n={x:t};return W.runKernel(xd,n)}else{let n={x:t};return W.runKernel(Ko,n)}}var jt=B({abs_:ZC});function YC(e){let t={x:M(e,"x","acos")};return W.runKernel(Zo,t)}var yg=B({acos_:YC});function JC(e){let t={x:M(e,"x","acosh")};return W.runKernel(Yo,t)}var Ag=B({acosh_:JC});function QC(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,s)=>M(r,`tensors${s}`,"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(!Dr(r.shape,n.shape))throw new Error("All tensors passed to tf.addN() must have the same shape")});let a=t;return W.runKernel(Zs,a)}var _h=B({addN_:QC});function eE(e,t=null,n=!1){let a={x:M(e,"x","all","bool")},r={axis:t,keepDims:n};return W.runKernel(Jo,a,r)}var Ph=B({all_:eE});function tE(e,t=null,n=!1){let a={x:M(e,"x","any","bool")},r={axis:t,keepDims:n};return W.runKernel(Qo,a,r)}var jd=B({any_:tE});function nE(e,t=0){let n={x:M(e,"x","argMax")},a={axis:t};return W.runKernel(Ys,n,a)}var ka=B({argMax_:nE});function aE(e,t=0){let n={x:M(e,"x","argMin")},a={axis:t};return W.runKernel(yd,n,a)}var xg=B({argMin_:aE});function rE(e){let t={x:M(e,"x","asin")};return W.runKernel(el,t)}var bg=B({asin_:rE});function sE(e){let t={x:M(e,"x","asinh")};return W.runKernel(tl,t)}var vg=B({asinh_:sE});function iE(e){let t={x:M(e,"x","atan")};return W.runKernel(nl,t)}var wg=B({atan_:iE});function oE(e,t){let n=M(e,"a","atan2"),a=M(t,"b","atan2");[n,a]=Ft(n,a);let r={a:n,b:a};return W.runKernel(rl,r)}var kg=B({atan2_:oE});function lE(e){let t={x:M(e,"x","atanh")};return W.runKernel(al,t)}var Ig=B({atanh_:lE});function uE(e,t,n,a,r="NHWC",s){let i=e[3],o=[...t,i],l=r3(r);return Gd(e,o,n,s,a,null,null,l)}function n3(e,t,n,a,r,s,i="channelsLast"){let[o,l]=zh(t),d;if(i==="channelsLast")d=[o,l,e[3],e[3]];else if(i==="channelsFirst")d=[o,l,e[1],e[1]];else throw new Error(`Unknown dataFormat ${i}`);return Gd(e,d,n,a,r,s,!1,i)}function dE(e,t,n,a,r,s,i="NDHWC"){let[o,l,d]=Ng(t),u,p;if(i==="NDHWC")p="channelsLast",u=[o,l,d,e[4],e[4]];else if(i==="NCDHW")p="channelsFirst",u=[o,l,d,e[1],e[1]];else throw new Error(`Unknown dataFormat ${i}`);return a3(e,u,n,a,r,!1,p,s)}function Gd(e,t,n,a,r,s,i=!1,o="channelsLast"){let[l,d,u,p]=[-1,-1,-1,-1];if(o==="channelsLast")[l,d,u,p]=e;else if(o==="channelsFirst")[l,p,d,u]=e;else throw new Error(`Unknown dataFormat ${o}`);let[c,h,,f]=t,[m,g]=zh(n),[y,A]=zh(a),x=ru(c,y),b=ru(h,A),{padInfo:v,outHeight:k,outWidth:T}=hE(r,d,u,m,g,x,b,s,o),C=i?f*p:f,D;return o==="channelsFirst"?D=[l,C,k,T]:o==="channelsLast"&&(D=[l,k,T,C]),{batchSize:l,dataFormat:o,inHeight:d,inWidth:u,inChannels:p,outHeight:k,outWidth:T,outChannels:C,padInfo:v,strideHeight:m,strideWidth:g,filterHeight:c,filterWidth:h,effectiveFilterHeight:x,effectiveFilterWidth:b,dilationHeight:y,dilationWidth:A,inShape:e,outShape:D,filterShape:t}}function a3(e,t,n,a,r,s=!1,i="channelsLast",o){let[l,d,u,p,c]=[-1,-1,-1,-1,-1];if(i==="channelsLast")[l,d,u,p,c]=e;else if(i==="channelsFirst")[l,c,d,u,p]=e;else throw new Error(`Unknown dataFormat ${i}`);let[h,f,m,,g]=t,[y,A,x]=Ng(n),[b,v,k]=Ng(a),T=ru(h,b),C=ru(f,v),D=ru(m,k),{padInfo:O,outDepth:F,outHeight:S,outWidth:P}=fE(r,d,u,p,y,A,x,T,C,D,o),_=s?g*c:g,j;return i==="channelsFirst"?j=[l,_,F,S,P]:i==="channelsLast"&&(j=[l,F,S,P,_]),{batchSize:l,dataFormat:i,inDepth:d,inHeight:u,inWidth:p,inChannels:c,outDepth:F,outHeight:S,outWidth:P,outChannels:_,padInfo:O,strideDepth:y,strideHeight:A,strideWidth:x,filterDepth:h,filterHeight:f,filterWidth:m,effectiveFilterDepth:T,effectiveFilterHeight:C,effectiveFilterWidth:D,dilationDepth:b,dilationHeight:v,dilationWidth:k,inShape:e,outShape:j,filterShape:t}}function pE(e,t,n,a,r){a==null&&(a=Sg(e,t,n));let s=e[0],i=e[1],o=to((s-t+2*a)/n+1,r),l=to((i-t+2*a)/n+1,r);return[o,l]}function cE(e,t,n,a,r,s){r==null&&(r=Sg(e,t,a));let i=e[0],o=e[1],l=e[2],d=to((i-t+2*r)/a+1,s),u=to((o-t+2*r)/a+1,s),p=to((l-t+2*r)/a+1,s);return[d,u,p,n]}function Sg(e,t,n,a=1){let r=ru(t,a);return Math.floor((e[0]*(n-1)-n+r)/2)}function zh(e){return typeof e=="number"?[e,e,e]:e.length===2?[e[0],e[1],1]:e}function Ng(e){return typeof e=="number"?[e,e,e]:e}function ru(e,t){return t<=1?e:e+(e-1)*(t-1)}function hE(e,t,n,a,r,s,i,o,l){let d,u,p;if(typeof e=="number"){d={top:e,bottom:e,left:e,right:e,type:e===0?"VALID":"NUMBER"};let c=pE([t,n],s,a,e,o);u=c[0],p=c[1]}else if(e==="same"){u=Math.ceil(t/a),p=Math.ceil(n/r);let c=Math.max(0,(u-1)*a+s-t),h=Math.max(0,(p-1)*r+i-n),f=Math.floor(c/2),m=c-f,g=Math.floor(h/2),y=h-g;d={top:f,bottom:m,left:g,right:y,type:"SAME"}}else if(e==="valid")d={top:0,bottom:0,left:0,right:0,type:"VALID"},u=Math.ceil((t-s+1)/a),p=Math.ceil((n-i+1)/r);else if(typeof e=="object"){let c=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];d={top:c,bottom:h,left:f,right:m,type:c===0&&h===0&&f===0&&m===0?"VALID":"EXPLICIT"},u=to((t-s+c+h)/a+1,o),p=to((n-i+f+m)/r+1,o)}else throw Error(`Unknown padding parameter: ${e}`);return{padInfo:d,outHeight:u,outWidth:p}}function fE(e,t,n,a,r,s,i,o,l,d,u){let p,c,h,f;if(typeof e=="number"){p={top:e,bottom:e,left:e,right:e,front:e,back:e,type:e===0?"VALID":"NUMBER"};let m=cE([t,n,a,1],o,1,r,e,u);c=m[0],h=m[1],f=m[2]}else if(e==="same"){c=Math.ceil(t/r),h=Math.ceil(n/s),f=Math.ceil(a/i);let m=(c-1)*r+o-t,g=(h-1)*s+l-n,y=(f-1)*i+d-a,A=Math.floor(m/2),x=m-A,b=Math.floor(g/2),v=g-b,k=Math.floor(y/2),T=y-k;p={top:b,bottom:v,left:k,right:T,front:A,back:x,type:"SAME"}}else if(e==="valid")p={top:0,bottom:0,left:0,right:0,front:0,back:0,type:"VALID"},c=Math.ceil((t-o+1)/r),h=Math.ceil((n-l+1)/s),f=Math.ceil((a-d+1)/i);else throw Error(`Unknown padding parameter: ${e}`);return{padInfo:p,outDepth:c,outHeight:h,outWidth:f}}function to(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 As(e){let[t,n,a]=zh(e);return t===1&&n===1&&a===1}function gr(e,t){return As(e)||As(t)}function r3(e){if(e==="NHWC")return"channelsLast";if(e==="NCHW")return"channelsFirst";throw new Error(`Unknown dataFormat ${e}`)}function mE(e,t){let n={x:M(e,"x","reshape","string_or_numeric")},a={shape:t};return W.runKernel($l,n,a)}var V=B({reshape_:mE});function gE(e,t,n,a,r){let s=M(e,"x","avgPool","float32"),i=1;$(gr(n,i),()=>`Error in avgPool: Either strides or dilations must be 1. Got strides ${n} and dilations '${i}'`);let o=s,l=!1;s.rank===3&&(l=!0,o=V(s,[1,s.shape[0],s.shape[1],s.shape[2]])),$(o.rank===4,()=>`Error in avgPool: x must be rank 4 but got rank ${o.rank}.`),r!=null&&$(un(a),()=>`Error in avgPool: pad must be an integer when using, dimRoundingMode ${r} but got pad ${a}.`);let d={x:o},u={filterSize:t,strides:n,pad:a,dimRoundingMode:r},p=W.runKernel(Js,d,u);return p=pe(p,s.dtype),l?V(p,[p.shape[1],p.shape[2],p.shape[3]]):p}var Hd=B({avgPool_:gE});function yE(e,t,n,a,r,s="NDHWC"){let i=M(e,"x","avgPool3d","float32"),o=i,l=!1;i.rank===4&&(l=!0,o=V(i,[1,i.shape[0],i.shape[1],i.shape[2],i.shape[3]])),$(o.rank===5,()=>`Error in avgPool3d: x must be rank 5 but got rank ${o.rank}.`),$(s==="NDHWC",()=>`Error in avgPool3d: Only NDHWC is currently supported, but got dataFormat of ${s}`),r!=null&&$(un(a),()=>`Error in avgPool3d: pad must be an integer when using, dimRoundingMode ${r} but got pad ${a}.`);let d={x:o},u={filterSize:t,strides:n,pad:a,dimRoundingMode:r,dataFormat:s},p=W.runKernel(Ad,d,u);return p=pe(p,o.dtype),l?V(p,[p.shape[1],p.shape[2],p.shape[3],p.shape[4]]):p}var Tg=B({avgPool3d_:yE});function AE(e,t=0){$(e.length>=1,()=>"Pass at least one tensor to concat");let n=Bd(e,"tensors","concat","string_or_numeric");if(n[0].dtype==="complex64"&&n.forEach(s=>{if(s.dtype!=="complex64")throw new Error(`Cannot concatenate complex64 tensors with a tensor
|
|
with dtype ${s.dtype}. `)}),n.length===1)return Za(n[0]);let a=n,r={axis:t};return W.runKernel(il,a,r)}var mt=B({concat_:AE});function xE(e){let t={x:M(e,"x","sigmoid","float32")};return W.runKernel(Pi,t)}var Kn=B({sigmoid_:xE});function bE(e,t,n){let a=M(e,"x","slice","string_or_numeric");if(a.rank===0)throw new Error("Slicing scalar is not possible");let r={x:a},s={begin:t,size:n};return W.runKernel(zl,r,s)}var De=B({slice_:bE});function vE(e){let t={x:M(e,"x","tanh","float32")};return W.runKernel(ji,t)}var no=B({tanh_:vE});function wE(e,t,n,a,r,s){let i=M(e,"forgetBias","basicLSTMCell"),o=M(t,"lstmKernel","basicLSTMCell"),l=M(n,"lstmBias","basicLSTMCell"),d=M(a,"data","basicLSTMCell"),u=M(r,"c","basicLSTMCell"),p=M(s,"h","basicLSTMCell"),c=mt([d,p],1),h=Ve(c,o),f=le(h,l),m=f.shape[0],g=f.shape[1]/4,y=[m,g],A=De(f,[0,0],y),x=De(f,[0,g],y),b=De(f,[0,g*2],y),v=De(f,[0,g*3],y),k=le(L(Kn(A),no(x)),L(u,Kn(le(i,b)))),T=L(no(k),Kn(v));return[k,T]}var kE=B({basicLSTMCell_:wE});function IE(e,t,n){let a=M(e,"x","batchToSpaceND"),r=t.reduce((o,l)=>o*l);$(a.rank>=1+t.length,()=>`input rank is ${a.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}`),$(a.shape[0]%r==0,()=>`input tensor batch is ${a.shape[0]} but is not divisible by the product of the elements of blockShape ${t.join(" * ")} === ${r}`);let s={x:a},i={blockShape:t,crops:n};return W.runKernel(sl,s,i)}var qd=B({batchToSpaceND_:IE});function SE(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,a,r,s){s==null&&(s=.001);let i=M(e,"x","batchNorm"),o=M(t,"mean","batchNorm"),l=M(n,"variance","batchNorm"),d;r!=null&&(d=M(r,"scale","batchNorm"));let u;a!=null&&(u=M(a,"offset","batchNorm")),$(o.rank===l.rank,()=>"Batch normalization gradient requires mean and variance to have equal ranks."),$(u==null||o.rank===u.rank,()=>"Batch normalization gradient requires mean and offset to have equal ranks."),$(d==null||o.rank===d.rank,()=>"Batch normalization gradient requires mean and scale to have equal ranks.");let p={x:SE(i),scale:d,offset:u,mean:o,variance:l},c={varianceEpsilon:s},h=W.runKernel(hi,p,c);return V(h,i.shape)}var ao=B({batchNorm_:NE});function TE(e,t,n,a,r,s){let i=M(e,"x","batchNorm"),o=M(t,"mean","batchNorm"),l=M(n,"variance","batchNorm"),d;r!=null&&(d=M(r,"scale","batchNorm"));let u;return a!=null&&(u=M(a,"offset","batchNorm")),$(i.rank===2,()=>`Error in batchNorm2D: x must be rank 2 but got rank ${i.rank}.`),$(o.rank===2||o.rank===1,()=>`Error in batchNorm2D: mean must be rank 2 or rank 1 but got rank ${o.rank}.`),$(l.rank===2||l.rank===1,()=>`Error in batchNorm2D: variance must be rank 2 or rank 1 but got rank ${l.rank}.`),d!=null&&$(d.rank===2||d.rank===1,()=>`Error in batchNorm2D: scale must be rank 2 or rank 1 but got rank ${d.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}.`),ao(i,o,l,u,d,s)}var s3=B({batchNorm2d_:TE});function CE(e,t,n,a,r,s){let i=M(e,"x","batchNorm"),o=M(t,"mean","batchNorm"),l=M(n,"variance","batchNorm"),d;r!=null&&(d=M(r,"scale","batchNorm"));let u;return a!=null&&(u=M(a,"offset","batchNorm")),$(i.rank===3,()=>`Error in batchNorm3D: x must be rank 3 but got rank ${i.rank}.`),$(o.rank===3||o.rank===1,()=>`Error in batchNorm3D: mean must be rank 3 or rank 1 but got rank ${o.rank}.`),$(l.rank===3||l.rank===1,()=>`Error in batchNorm3D: variance must be rank 3 or rank 1 but got rank ${l.rank}.`),d!=null&&$(d.rank===3||d.rank===1,()=>`Error in batchNorm3D: scale must be rank 3 or rank 1 but got rank ${d.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}.`),ao(i,o,l,u,d,s)}var i3=B({batchNorm3d_:CE});function EE(e,t,n,a,r,s){let i=M(e,"x","batchNorm"),o=M(t,"mean","batchNorm"),l=M(n,"variance","batchNorm"),d;r!=null&&(d=M(r,"scale","batchNorm"));let u;return a!=null&&(u=M(a,"offset","batchNorm")),$(i.rank===4,()=>`Error in batchNorm4D: x must be rank 4 but got rank ${i.rank}.`),$(o.rank===4||o.rank===1,()=>`Error in batchNorm4D: mean must be rank 4 or rank 1 but got rank ${o.rank}.`),$(l.rank===4||l.rank===1,()=>`Error in batchNorm4D: variance must be rank 4 or rank 1 but got rank ${l.rank}.`),d!=null&&$(d.rank===4||d.rank===1,()=>`Error in batchNorm4D: scale must be rank 4 or rank 1 but got rank ${d.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}.`),ao(i,o,l,u,d,s)}var o3=B({batchNorm4d_:EE});function RE(e,t,n){let a=M(e,"x","bincount"),r=M(t,"weights","bincount");$(a.dtype==="int32",()=>`Error in bincount: input dtype must be int32, but got ${a.dtype}`),$(n>=0,()=>`size must be non-negative, but got ${n}.`),$(r.size===a.size||r.size===0,()=>`Error in bincount: weights must have the same size as input or0-length, but got input shape: ${a.shape}, weights shape: ${r.shape}.`);let s={x:a,weights:r},i={size:n};return W.runKernel(Vc,s,i)}var Cg=B({bincount_:RE});function ME(e,t){let n=M(e,"s0","broadcastArgs","int32"),a=M(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(a.rank!==1)throw new Error(`broadcastArgs(): second input must be a vector (rank=1). Has rank ${a.rank}`);let r={s0:n,s1:a};return W.runKernel(Uc,r)}var l3=B({broadcastArgs_:ME});function FE(e,t){let n=M(e,"broadcastTo","x"),a=n.shape;if(t.some(l=>!(l>0)||l%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 l=n.shape.slice();for(;l.length<t.length;)l.unshift(1);n=V(n,l)}let r=n.shape,s=Array.from(t);for(let l=t.length-1;l>=0;l--)if(r[l]===t[l])s[l]=1;else if(n.shape[l]!==1)throw new Error(`broadcastTo(): [${a}] cannot be broadcast to [${t}].`);if(s.map((l,d)=>l>1?d:-1).filter(l=>l>=0).length===0)return Za(n);let i={x:n},o={reps:s};return W.runKernel(ds,i,o)}var su=B({broadcastTo_:FE});function DE(e){let t={x:M(e,"x","ceil","float32")};return W.runKernel(ti,t)}var Eg=B({ceil_:DE});function $E(e,t,n){let a=M(e,"x","clipByValue");$(t<=n,()=>`Error in clip: min (${t}) must be less than or equal to max (${n}).`);let r={x:a},s={clipValueMin:t,clipValueMax:n};return W.runKernel(us,r,s)}var Zn=B({clipByValue_:$E});function OE(e){return mt(e,0)}var u3=B({concat1d_:OE});function _E(e,t){return mt(e,t)}var iu=B({concat2d_:_E});function PE(e,t){return mt(e,t)}var d3=B({concat3d_:PE});function zE(e,t){return mt(e,t)}var p3=B({concat4d_:zE});function LE(e,t,n,a,r="NHWC",s=[1,1],i){let o=M(e,"x","conv2d","float32"),l=M(t,"filter","conv2d","float32"),d=o,u=!1;o.rank===3&&(u=!0,d=V(o,[1,o.shape[0],o.shape[1],o.shape[2]])),$(d.rank===4,()=>`Error in conv2d: input must be rank 4, but got rank ${d.rank}.`),$(l.rank===4,()=>`Error in conv2d: filter must be rank 4, but got rank ${l.rank}.`),i!=null&&$(un(a),()=>`Error in conv2d: pad must be an integer when using, dimRoundingMode ${i} but got pad ${a}.`);let p=r==="NHWC"?d.shape[3]:d.shape[1];$(p===l.shape[2],()=>`Error in conv2d: depth of input (${p}) must match input depth for filter ${l.shape[2]}.`),$(gr(n,s),()=>`Error in conv2D: Either strides or dilations must be 1. Got strides ${n} and dilations '${s}'`);let c={x:d,filter:l},h={strides:n,pad:a,dataFormat:r,dilations:s,dimRoundingMode:i},f=W.runKernel(ni,c,h);return u?V(f,[f.shape[1],f.shape[2],f.shape[3]]):f}var _r=B({conv2d_:LE});function WE(e,t,n,a,r="NWC",s=1,i){let o=M(e,"x","conv1d"),l=M(t,"filter","conv1d"),d=o,u=!1;o.rank===2&&(u=!0,d=V(o,[1,o.shape[0],o.shape[1]])),$(d.rank===3,()=>`Error in conv1d: input must be rank 3, but got rank ${d.rank}.`),$(l.rank===3,()=>`Error in conv1d: filter must be rank 3, but got rank ${l.rank}.`),i!=null&&$(un(a),()=>`Error in conv1d: pad must be an integer when using, dimRoundingMode ${i} but got pad ${a}.`),$(d.shape[2]===l.shape[1],()=>`Error in conv1d: depth of input (${d.shape[2]}) must match input depth for filter ${l.shape[1]}.`),$(gr(n,s),()=>`Error in conv1D: Either stride or dilation must be 1. Got stride ${n} and dilation '${s}'`),$(r==="NWC",()=>`Error in conv1d: got dataFormat of ${r} but only NWC is currently supported.`);let p=V(l,[1,l.shape[0],l.shape[1],l.shape[2]]),c=V(d,[d.shape[0],1,d.shape[1],d.shape[2]]),h=_r(c,p,[1,n],a,"NHWC",[1,s],i);return u?V(h,[h.shape[2],h.shape[3]]):V(h,[h.shape[0],h.shape[2],h.shape[3]])}var Lh=B({conv1d_:WE});function BE(e,t,n,a,r,s="NHWC",i){$(e.length===t.rank,()=>`Length of inShape (${e.length}) and rank of dy (${t.rank}) must match`);let o=e,l=t,d=!1;t.rank===3&&(d=!0,l=V(t,[1,t.shape[0],t.shape[1],t.shape[2]]),o=[1,e[0],e[1],e[2]]),$(o.length===4,()=>`Error in conv2dDerInput: inShape must be length 4, but got length ${o.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=s==="NHWC"?o[3]:o[1],p=s==="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]}.`),$(p===n.shape[3],()=>`Error in conv2dDerInput: depth of output (${p}) must match output depth for filter ${n.shape[3]}.`),i!=null&&$(un(r),()=>`Error in conv2dDerInput: pad must be an integer when using, dimRoundingMode ${i} but got pad ${r}.`);let c={dy:l,filter:n},h={strides:a,pad:r,dataFormat:s,dimRoundingMode:i,inputShape:o},f=W.runKernel(ai,c,h);return d?V(f,[f.shape[1],f.shape[2],f.shape[3]]):f}var Rg=B({conv2DBackpropInput_:BE});function VE(e,t,n,a,r,s){let i=M(e,"x","conv2dTranspose"),o=M(t,"filter","conv2dTranspose");return Rg(n,i,o,a,r,"NHWC",s)}var Wh=B({conv2dTranspose_:VE});function UE(e,t,n,a,r="NDHWC",s=[1,1,1]){let i=M(e,"x","conv3d"),o=M(t,"filter","conv3d"),l=i,d=!1;i.rank===4&&(d=!0,l=V(i,[1,i.shape[0],i.shape[1],i.shape[2],i.shape[3]])),$(l.rank===5,()=>`Error in conv3d: input must be rank 5, but got rank ${l.rank}.`),$(o.rank===5,()=>`Error in conv3d: filter must be rank 5, but got rank ${o.rank}.`),$(l.shape[4]===o.shape[3],()=>`Error in conv3d: depth of input (${l.shape[4]}) must match input depth for filter ${o.shape[3]}.`),$(gr(n,s),()=>`Error in conv3D: Either strides or dilations must be 1. Got strides ${n} and dilations '${s}'`),$(r==="NDHWC",()=>`Error in conv3d: got dataFormat of ${r} but only NDHWC is currently supported.`);let u={x:l,filter:o},p={strides:n,pad:a,dataFormat:r,dilations:s},c=W.runKernel(bd,u,p);return d?V(c,[c.shape[1],c.shape[2],c.shape[3],c.shape[4]]):c}var Mg=B({conv3d_:UE});function jE(e,t,n,a,r){$(e.length===t.rank,()=>`Length of inShape (${e.length}) and rank of dy (${t.rank}) must match`);let s=e,i=t,o=!1;t.rank===4&&(o=!0,i=V(t,[1,t.shape[0],t.shape[1],t.shape[2],t.shape[3]]),s=[1,e[0],e[1],e[2],e[3]]);let l=s[4],d=i.shape[4];$(s.length===5,()=>`Error in conv3dDerInput: inShape must be length 5, but got length ${s.length}.`),$(i.rank===5,()=>`Error in conv3dDerInput: dy must be rank 5, but got rank ${i.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]}.`),$(d===n.shape[4],()=>`Error in conv3dDerInput: depth of output (${d}) must match output depth for filter ${n.shape[4]}.`);let u={dy:i,filter:n},p={pad:r,strides:a,inputShape:s},c=W.runKernel(qc,u,p);return o?V(c,[c.shape[1],c.shape[2],c.shape[3],c.shape[4]]):c}var c3=B({conv3DBackpropInput_:jE});function GE(e,t,n,a,r){let s=M(e,"x","conv3dTranspose"),i=M(t,"filter","conv3dTranspose");return c3(n,s,i,a,r)}var h3=B({conv3dTranspose_:GE});function HE(e){let t={x:M(e,"x","cos","float32")};return W.runKernel(ri,t)}var Xd=B({cos_:HE});function qE(e){let t={x:M(e,"x","cosh","float32")};return W.runKernel(si,t)}var Bh=B({cosh_:qE});function XE(e,t=0,n=!1,a=!1){let r={x:M(e,"x","cumsum")},s={axis:t,exclusive:n,reverse:a};return W.runKernel(ii,r,s)}var Vh=B({cumsum_:XE});function KE(e,t,n,a=!1){let r=M(e,"x","denseBincount"),s=M(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}.`),$(s.size===r.size||s.size===0,()=>`Error in denseBincount: weights must have the same shape as x or 0-length, but got x shape: ${r.shape}, weights shape: ${s.shape}.`);let i={x:r,weights:s},o={size:n,binaryOutput:a};return W.runKernel(Xc,i,o)}var f3=B({denseBincount_:KE});function ZE(e,t,n="NHWC"){let a=M(e,"x","depthToSpace","float32"),r=n==="NHWC"?a.shape[1]:a.shape[2],s=n==="NHWC"?a.shape[2]:a.shape[3],i=n==="NHWC"?a.shape[3]:a.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
|
|
${a.shape}`),$(s*t>=0,()=>`Negative dimension size caused by overflow when multiplying
|
|
${s} and ${t} for depthToSpace with input shape
|
|
${a.shape}`),$(i%(t*t)==0,()=>`Dimension size must be evenly divisible by ${t*t} but is ${i} for depthToSpace with input shape ${a.shape}`);let o={x:a},l={blockSize:t,dataFormat:n};return W.runKernel(ll,o,l)}var Fg=B({depthToSpace_:ZE});function YE(e,t,n,a,r="NHWC",s=[1,1],i){let o=M(e,"x","depthwiseConv2d","float32"),l=M(t,"filter","depthwiseConv2d","float32"),d=o,u=!1;o.rank===3&&(u=!0,d=V(o,[1,o.shape[0],o.shape[1],o.shape[2]])),$(d.rank===4,()=>`Error in depthwiseConv2d: input must be rank 4, but got rank ${d.rank}.`),$(l.rank===4,()=>`Error in depthwiseConv2d: filter must be rank 4, but got rank ${l.rank}.`),$(d.shape[3]===l.shape[2],()=>`Error in depthwiseConv2d: number of input channels (${d.shape[3]}) must match the inChannels dimension in filter ${l.shape[2]}.`),i!=null&&$(un(a),()=>`Error in depthwiseConv2d: pad must be an integer when using, dimRoundingMode ${i} but got pad ${a}.`);let p={x:d,filter:l},c={strides:n,pad:a,dataFormat:r,dilations:s,dimRoundingMode:i},h=W.runKernel(oi,p,c);return u?V(h,[h.shape[1],h.shape[2],h.shape[3]]):h}var ou=B({depthwiseConv2d_:YE});function JE(e){let t={x:M(e,"x","diag")};return W.runKernel(Yc,t)}var QE=B({diag_:JE});function eR(e,t,n,a,r=[1,1],s="NHWC"){let i=M(e,"x","dilation2d"),o=M(t,"filter","dilation2d");$(i.rank===3||i.rank===4,()=>`Error in dilation2d: input must be rank 3 or 4, but got rank ${i.rank}.`),$(o.rank===3,()=>`Error in dilation2d: filter must be rank 3, but got rank ${o.rank}.`),$(s==="NHWC",()=>`Error in dilation2d: Only NHWC is currently supported, but got dataFormat of ${s}`);let l=i,d=!1;i.rank===3&&(l=V(i,[1,i.shape[0],i.shape[1],i.shape[2]]),d=!0);let u={x:l,filter:o},p={strides:n,pad:a,dilations:r},c=W.runKernel(vd,u,p);return d?V(c,[c.shape[1],c.shape[2],c.shape[3]]):c}var Dg=B({dilation2d_:eR});function tR(e,t){let n=e.length,a=[];for(let r=0;r<n;r++){let s=n-1-r,i=e[s]||1;(t[t.length-1-r]||1)>1&&i===1&&a.unshift(s)}return a}function Qt(e,t){let n=[];for(let a=0;a<t.length;a++){let r=e[e.length-a-1],s=t.length-a-1,i=t[s];(r==null||r===1&&i>1)&&n.unshift(s)}return n}function bt(e,t){let n=[],a=Math.max(e.length,t.length);for(let r=0;r<a;r++){let s=e[e.length-r-1];s==null&&(s=1);let i=t[t.length-r-1];if(i==null&&(i=1),s===1)n.unshift(i);else if(i===1)n.unshift(s);else if(s!==i){let o=`Operands could not be broadcast together with shapes ${e} and ${t}.`;throw Error(o)}else n.unshift(s)}return n}function nR(e,t){let n=M(e,"a","equal","string_or_numeric"),a=M(t,"b","equal","string_or_numeric");[n,a]=Ft(n,a),bt(n.shape,a.shape);let r={a:n,b:a};return W.runKernel(dl,r)}var ia=B({equal_:nR});function aR(e,t,n){let a=M(t,"a","where"),r=M(n,"b","where"),s=M(e,"condition","where","bool"),i=bt(bt(s.shape,a.shape),r.shape),o=su(s,i),l=su(a,i),d=su(r,i),u={condition:o,t:l,e:d};return W.runKernel(_l,u)}var Sn=B({where_:aR});function rR(e){let t={x:M(e,"x","zerosLike")};return W.runKernel(Xl,t)}var Ye=B({zerosLike_:rR});function sR(e,t){let n=M(e,"a","div"),a=M(t,"b","div");[n,a]=Ft(n,a);let r=he(n,a),s=Ye(r),i=ia(a,s);return Sn(i,s,r)}var $g=B({divNoNan_:sR});function iR(e,t){let n=M(e,"t1","dot"),a=M(t,"t2","dot");$((n.rank===1||n.rank===2)&&(a.rank===1||a.rank===2),()=>`Error in dot: inputs must all be rank 1 or 2, but got ranks ${n.rank} and ${a.rank}.`);let r=n.rank===1?n.size:n.shape[1],s=a.rank===1?a.size:a.shape[0];if($(r===s,()=>`Error in dot: inner dimensions of inputs must match, but got ${r} and ${s}.`),n.rank===1&&a.rank===1){let i=V(n,[1,-1]),o=V(a,[-1,1]),l=Ve(i,o);return V(l,[])}else if(n.rank===1&&a.rank===2){let i=V(n,[1,-1]),o=V(a,[a.shape[0],a.shape[1]]),l=Ve(i,o);return V(l,[l.size])}else if(n.rank===2&&a.rank===1){let i=V(a,[-1,1]),o=Ve(n,i);return V(o,[o.size])}else{let i=V(a,[a.shape[0],a.shape[1]]);return Ve(n,i)}}var m3=B({dot_:iR});function oR(e,...t){let n=t.map((r,s)=>M(r,`tensors${s}`,"einsum")),a={equation:e};return W.runKernel(eh,n,a)}var g3=B({einsum_:oR});function lR(e){let t={x:M(e,"x","elu","float32")};return W.runKernel(ui,t)}var lu=B({elu_:lR});function uR(e){let t=M(e,"x","erf");$(t.dtype==="int32"||t.dtype==="float32",()=>"Input dtype must be `int32` or `float32`."),t.dtype==="int32"&&(t=pe(t,"float32"));let n={x:t};return W.runKernel(ul,n)}var Og=B({erf_:uR});function dR(e){let t={x:M(e,"x","exp")};return W.runKernel(di,t)}var oa=B({exp_:dR});function pR(e,t=0){let n=M(e,"x","expandDims","string_or_numeric");$(t<=n.rank,()=>"Axis must be <= rank of the tensor");let a={input:n},r={dim:t};return W.runKernel(pl,a,r)}var Wt=B({expandDims_:pR});function cR(e){let t={x:M(e,"x","expm1")};return W.runKernel(cl,t)}var _g=B({expm1_:cR});function hR(e,t){let n=M(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 a={x:n},r={reps:t};return W.runKernel(ds,a,r)}var Ia=B({tile_:hR});function fR(e,t,n,a="float32"){t==null&&(t=e);let r=Ge([e,t],a),s=e<=t?e:t;for(let o=0;o<s;++o)r.set(1,o,o);let i=V(r.toTensor(),[e,t]);if(n==null)return i;if(n.length===1)return Ia(Wt(i,0),[n[0],1,1]);if(n.length===2)return Ia(Wt(Wt(i,0),0),[n[0],n[1],1,1]);if(n.length===3)return Ia(Wt(Wt(Wt(i,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 Pg=B({eye_:fR});function uu(e,t,n){let a={shape:e,value:t,dtype:n};return W.runKernel(wd,{},a)}function mR(e){let t={x:M(e,"x","floor","float32")};return W.runKernel(pi,t)}var du=B({floor_:mR});function gR(e,t,n=0,a=0){let r=M(e,"x","gather"),s=M(t,"indices","gather","int32"),i={x:r,indices:s},o={axis:n,batchDims:a};return W.runKernel(fl,i,o)}var ro=B({gather_:gR});function yR(e,t){let n=M(e,"a","greater","string_or_numeric"),a=M(t,"b","greater","string_or_numeric");[n,a]=Ft(n,a),bt(n.shape,a.shape);let r={a:n,b:a};return W.runKernel(gl,r)}var Yn=B({greater_:yR});function AR(e,t){let n=M(e,"a","greaterEqual","string_or_numeric"),a=M(t,"b","greaterEqual","string_or_numeric");[n,a]=Ft(n,a),bt(n.shape,a.shape);let r={a:n,b:a};return W.runKernel(fi,r)}var xs=B({greaterEqual_:AR});function xR(e){let t={input:M(e,"input","imag")};return W.runKernel(rh,t)}var Uh=B({imag_:xR});function bR(e){let t={x:M(e,"x","isFinite")};return W.runKernel(yl,t)}var y3=B({isFinite_:bR});function vR(e){let t={x:M(e,"x","isInf")};return W.runKernel(Al,t)}var A3=B({isInf_:vR});function wR(e){let t={x:M(e,"x","isNaN")};return W.runKernel(xl,t)}var zg=B({isNaN_:wR});function kR(e,t=.2){let n={x:M(e,"x","leakyRelu")},a={alpha:t};return W.runKernel(gi,n,a)}var Kd=B({leakyRelu_:kR});function IR(e,t){let n=M(e,"a","less","string_or_numeric"),a=M(t,"b","less","string_or_numeric");[n,a]=Ft(n,a),bt(n.shape,a.shape);let r={a:n,b:a};return W.runKernel(bl,r)}var jh=B({less_:IR});function SR(e,t){let n=M(e,"a","lessEqual","string_or_numeric"),a=M(t,"b","lessEqual","string_or_numeric");[n,a]=Ft(n,a),bt(n.shape,a.shape);let r={a:n,b:a};return W.runKernel(vl,r)}var bs=B({lessEqual_:SR});function x3(e,t,n){if(n<=0)throw new Error("The number of values should be positive.");let a={start:e,stop:t,num:n};return W.runKernel(sh,{},a)}function NR(e,t=5,n=1,a=1,r=.5){let s=M(e,"x","localResponseNormalization");$(s.rank===4||s.rank===3,()=>`Error in localResponseNormalization: x must be rank 3 or 4 but got
|
|
rank ${s.rank}.`),$(un(t),()=>`Error in localResponseNormalization: depthRadius must be an integer but got depthRadius ${t}.`);let i=s,o=!1;s.rank===3&&(o=!0,i=V(s,[1,s.shape[0],s.shape[1],s.shape[2]]));let l={x:i},d={depthRadius:t,bias:n,alpha:a,beta:r},u=W.runKernel(Sd,l,d);return o?V(u,[u.shape[1],u.shape[2],u.shape[3]]):u}var Lg=B({localResponseNormalization_:NR});function TR(e){let t={x:M(e,"x","log","float32")};return W.runKernel(yi,t)}var la=B({log_:TR});function CR(e){let t={x:M(e,"x","log1p")};return W.runKernel(wl,t)}var Zd=B({log1p_:CR});function ER(e){return $(os(e),()=>"The f passed in grad(f) must be a function"),(t,n)=>{let a=M(t,"x","tf.grad","string_or_numeric"),r=n!=null?M(n,"dy","tf.grad"):null;return W.tidy(()=>{let{value:s,grads:i}=W.gradients(()=>e(a),[a],r);return r!=null&&Tn(s.shape,r.shape,"The shape of dy passed in grad(f)(x, dy) must match the shape returned by f(x)"),Gh(i),i[0]})}}function RR(e){return $(os(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 a=Bd(t,"args","tf.grads","string_or_numeric"),r=n!=null?M(n,"dy","tf.grads"):null;return W.tidy(()=>{let{value:s,grads:i}=W.gradients(()=>e(...a),a,r);return r!=null&&Tn(s.shape,r.shape,"The shape of dy passed in grads(f)([x1,...], dy) must match the shape returned by f([x1,...])"),Gh(i),i})}}function MR(e){return $(os(e),()=>"The f passed in valueAndGrad(f) must be a function"),(t,n)=>{$(t instanceof je,()=>"The x passed in valueAndGrad(f)(x) must be a tensor"),$(n==null||n instanceof je,()=>"The dy passed in valueAndGrad(f)(x, dy) must be a tensor");let{grads:a,value:r}=W.gradients(()=>e(t),[t],n);return Gh(a),{grad:a[0],value:r}}}function FR(e){return $(os(e),()=>"The f passed in valueAndGrads(f) must be a function"),(t,n)=>{$(Array.isArray(t)&&t.every(r=>r instanceof je),()=>"The args passed in valueAndGrads(f)(args) must be array of tensors"),$(n==null||n instanceof je,()=>"The dy passed in valueAndGrads(f)(args, dy) must be a tensor");let a=W.gradients(()=>e(...t),t,n);return n!=null&&Tn(a.value.shape,n.shape,"The shape of dy passed in valueAndGrads(f)([x1,...], dy) must match the shape returned by f([x1,...])"),Gh(a.grads),a}}function b3(e,t){$(os(e),()=>"The f passed in variableGrads(f) must be a function"),$(t==null||Array.isArray(t)&&t.every(d=>d instanceof zd),()=>"The varList passed in variableGrads(f, varList) must be an array of variables");let n=t!=null;if(!n){t=[];for(let d in W.registeredVariables)t.push(W.registeredVariables[d])}let a=n?t.filter(d=>!d.trainable):null,r=t.length;t=t.filter(d=>d.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 s=!0,{value:i,grads:o}=W.gradients(e,t,null,s);$(o.some(d=>d!=null),()=>"Cannot find a connection between any variable and the result of the loss function y=f(x). Please make sure the operations that use variables are inside the function f passed to minimize()."),$(i.rank===0,()=>`The f passed in variableGrads(f) must return a scalar, but it returned a rank-${i.rank} tensor`);let l={};return t.forEach((d,u)=>{o[u]!=null&&(l[d.name]=o[u])}),a!=null&&a.forEach(d=>l[d.name]=null),{value:i,grads:l}}function yr(e){return W.customGrad(e)}function Gh(e){if(e.filter(t=>t==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 DR(e){let t={x:M(e,"x","neg")};return W.runKernel(Sl,t)}var Tt=B({neg_:DR});function $R(e){let t={x:M(e,"x","softplus")};return W.runKernel(Bl,t)}var so=B({softplus_:$R});function OR(e){let t=M(e,"x","logSigmoid");return yr(n=>({value:Tt(so(Tt(n))),gradFunc:a=>L(a,Kn(Tt(n)))}))(t)}var v3=B({logSigmoid_:OR});function _R(e,t=null,n=!1){let a={x:M(e,"x","max")},r={reductionIndices:t,keepDims:n};return W.runKernel(Ai,a,r)}var Rn=B({max_:_R});function PR(e,t){let n=M(e,"a","sub"),a=M(t,"b","sub");[n,a]=Ft(n,a);let r={a:n,b:a};return W.runKernel(Vi,r)}var ge=B({sub_:PR});function zR(e,t=null,n=!1){let a=M(e,"x","sum");a.dtype==="bool"&&(a=pe(a,"int32"));let r={x:a},s={axis:t,keepDims:n};return W.runKernel(Li,r,s)}var Ie=B({sum_:zR});function LR(e,t=-1){let n=M(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((a,r)=>{let s=!0,i=Rn(a,t,!0),o=ge(a,i),l=ge(pe(o,"float32"),la(Ie(oa(o),t,s)));return r([l]),{value:l,gradFunc:(d,u)=>{let[p]=u,c=!0,h=oa(p);return ge(d,L(Ie(d,t,c),h))}}})(n)}var Hh=B({logSoftmax_:LR});function Wg(e,t){for(let n=0;n<e.length;++n)if(e[e.length-n-1]!==t-1-n)return!1;return!0}function w3(e,t,n){let a=e.length+t.length,r=[],s=0,i=0;for(let o=0;o<a;o++)n.indexOf(o)===-1?r.push(e[s++]):r.push(t[i++]);return r}function k3(e,t){let n=[],a=e.length;for(let s=0;s<a;s++)t.indexOf(s)===-1&&n.push(e[s]);let r=t.map(s=>e[s]);return[n,r]}function io(e,t){let n=t.map(a=>1);return w3(e,n,t)}function WR(e,t,n){$(Wg(t,n),()=>`${e} supports only inner-most axes for now. Got axes ${t} and rank-${n} input.`)}function I3(e,t){if(Wg(e,t))return null;let n=[];for(let a=0;a<t;++a)e.indexOf(a)===-1&&n.push(a);return e.forEach(a=>n.push(a)),n}function Bg(e){return e.map((t,n)=>[n,t]).sort((t,n)=>t[1]-n[1]).map(t=>t[0])}function BR(e,t){let n=[];for(let a=t-e;a<t;++a)n.push(a);return n}function VR(e,t=null,n=!1){let a=M(e,"x","logSumExp"),r=_a(t,a.shape),s=Rn(a,r,!0),i=ge(a,s),o=oa(i),l=Ie(o,r),d=la(l),u=le(V(s,d.shape),d);if(n){let p=io(u.shape,r);return V(u,p)}return u}var Vg=B({logSumExp_:VR});function UR(e,t){let n=M(e,"a","logicalAnd","bool"),a=M(t,"b","logicalAnd","bool");bt(n.shape,a.shape);let r={a:n,b:a};return W.runKernel(kl,r)}var La=B({logicalAnd_:UR});function jR(e){let t={x:M(e,"x","logicalNot","bool")};return W.runKernel(kd,t)}var Yd=B({logicalNot_:jR});function GR(e,t){let n=M(e,"a","logicalOr","bool"),a=M(t,"b","logicalOr","bool");bt(n.shape,a.shape);let r={a:n,b:a};return W.runKernel(Id,r)}var qh=B({logicalOr_:GR});function HR(e,t){let n=M(e,"a","logicalXor","bool"),a=M(t,"b","logicalXor","bool");return bt(n.shape,a.shape),La(qh(e,t),Yd(La(e,t)))}var S3=B({logicalXor_:HR});function qR(e,t,n,a,r){let s=M(e,"x","maxPool"),i=1,o=s,l=!1;s.rank===3&&(l=!0,o=V(s,[1,s.shape[0],s.shape[1],s.shape[2]])),$(o.rank===4,()=>`Error in maxPool: input must be rank 4 but got rank ${o.rank}.`),$(gr(n,i),()=>`Error in maxPool: Either strides or dilations must be 1. Got strides ${n} and dilations '${i}'`),r!=null&&$(un(a),()=>`Error in maxPool: pad must be an integer when using, dimRoundingMode ${r} but got pad ${a}.`);let d={x:o},u={filterSize:t,strides:n,pad:a,dimRoundingMode:r},p=W.runKernel(bi,d,u);return l?V(p,[p.shape[1],p.shape[2],p.shape[3]]):p}var Jd=B({maxPool_:qR});function XR(e,t=[1,1,1],n,a,r,s="NDHWC"){let i=M(e,"x","maxPool3d"),o=i,l=!1;i.rank===4&&(l=!0,o=V(i,[1,i.shape[0],i.shape[1],i.shape[2],i.shape[3]])),$(o.rank===5,()=>`Error in maxPool3d: x must be rank 5 but got rank ${o.rank}.`),$(s==="NDHWC",()=>`Error in maxPool3d: Only NDHWC is currently supported, but got dataFormat of ${s}`),r!=null&&$(un(a),()=>`Error in maxPool3d: pad must be an integer when using, dimRoundingMode ${r} but got pad ${a}.`);let d={x:o},u={filterSize:t,strides:n,pad:a,dimRoundingMode:r,dataFormat:s},p=W.runKernel(Nd,d,u);return l?V(p,[p.shape[1],p.shape[2],p.shape[3],p.shape[4]]):p}var Ug=B({maxPool3d_:XR});function KR(e,t,n,a,r=!1){let s={x:M(e,"x","maxPoolWithArgmax")},i={filterSize:t,strides:n,pad:a,includeBatchInIndex:r},o=W.runKernel(uh,s,i);return{result:o[0],indexes:o[1]}}var N3=B({maxPoolWithArgmax_:KR});function ZR(e,t){let n=M(e,"a","maximum"),a=M(t,"b","maximum");[n,a]=Ft(n,a),n.dtype==="bool"&&(n=pe(n,"int32"),a=pe(a,"int32")),bt(n.shape,a.shape);let r={a:n,b:a};return W.runKernel(xi,r)}var Ar=B({maximum_:ZR});function YR(e,t=null,n=!1){let a={x:M(e,"x","mean")},r={axis:t,keepDims:n};return W.runKernel(vi,a,r)}var Dt=B({mean_:YR});function Gt(e,t="float32"){if(t==="complex64"){let a=Gt(e,"float32"),r=Gt(e,"float32");return fs(a,r)}let n=Lc(zt(e),t);return W.makeTensor(n,e,t)}function ua(e,t="float32"){if(t==="complex64"){let a=ua(e,"float32"),r=Gt(e,"float32");return fs(a,r)}let n=D1(zt(e),t);return W.makeTensor(n,e,t)}function JR(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 a=M(e,"x","meshgrid",e instanceof je?e.dtype:"float32");if(t===void 0)return[a];let r=M(t,"y","meshgrid",t instanceof je?t.dtype:"float32"),s=zt(a.shape),i=zt(r.shape);return n==="xy"?(a=V(a,[1,-1]),r=V(r,[-1,1]),[Ve(ua([i,1],a.dtype),a),Ve(r,ua([1,s],r.dtype))]):(a=V(a,[-1,1]),r=V(r,[1,-1]),[Ve(a,ua([1,i],a.dtype)),Ve(ua([s,1],r.dtype),r)])}function QR(e,t=null,n=!1){let a={x:M(e,"x","min")},r={axis:t,keepDims:n};return W.runKernel(wi,a,r)}var Qd=B({min_:QR});function eM(e,t){let n=M(e,"a","minimum"),a=M(t,"b","minimum");[n,a]=Ft(n,a),n.dtype==="bool"&&(n=pe(n,"int32"),a=pe(a,"int32")),bt(n.shape,a.shape);let r={a:n,b:a};return W.runKernel(ki,r)}var pu=B({minimum_:eM});function tM(e,t,n){$(n==="reflect"||n==="symmetric",()=>`Invalid mode. Mode must be either reflect or symmetric. Got ${n}.`);let a=M(e,"x","mirrorPad");if(a.rank===0)throw new Error("mirrorPad(scalar) is not defined. Pass non-scalar to mirrorPad");$(t.length===a.rank,()=>`Padding doesn't match input. Must be ${a.rank}. Got ${t.length}.`);let r=n==="reflect"?1:0;for(let o=0;o<a.rank;o++)$(t[o].length===2,()=>"Invalid number of paddings. Must be length of 2 each."),$(t[o][0]>=0&&t[o][0]<=a.shape[o]-r&&t[o][1]>=0&&t[o][1]<=a.shape[o]-r,()=>`Padding in dimension ${o} cannot be greater than or equal to ${a.shape[o]-r} or less than 0 for input of shape ${a.shape}`);let s={paddings:t,mode:n},i={x:a};return W.runKernel(Ii,i,s)}var jg=B({mirrorPad_:tM});function nM(e,t){let n=M(e,"a","mod"),a=M(t,"b","mod");[n,a]=Ft(n,a);let r={a:n,b:a};return W.runKernel(Il,r)}var Gg=B({mod_:nM});function aM(e){let t=M(e,"x","square"),n={};return W.runKernel("Square",{x:t},n)}var ht=B({square_:aM});function rM(e,t=null,n=!1){e=M(e,"x","moments");let a=_a(t,e.shape),r=Dt(e,a,n),s=r.shape;n||(s=io(r.shape,a));let i=ht(ge(pe(e,"float32"),V(r,s))),o=Dt(i,a,n);return{mean:r,variance:o}}var Xh=B({moments_:rM});function sM(e,t,n,a){let r=M(t,"data","multiRNNCell"),s=Bd(n,"c","multiRNNCell"),i=Bd(a,"h","multiRNNCell"),o=r,l=[];for(let p=0;p<e.length;p++){let c=e[p](o,s[p],i[p]);l.push(c[0]),l.push(c[1]),o=c[1]}let d=[],u=[];for(let p=0;p<l.length;p+=2)d.push(l[p]),u.push(l[p+1]);return[d,u]}var iM=B({multiRNNCell_:sM});function oM(e,t,n,a=!1){let r=M(e,"logits","multinomial"),s=r.size,i=r.rank;if(s<2)throw new Error(`Error in multinomial: you need at least 2 outcomes, but got ${s}.`);if(i>2)throw new Error(`Rank of probabilities must be 1 or 2, but is ${i}`);n=n||Math.random();let o={logits:i===1?V(r,[1,-1]):r},l={numSamples:t,seed:n,normalized:a},d=W.runKernel(dh,o,l);return i===1?V(d,[d.size]):d}var T3=B({multinomial_:oM});function lM(e,t){let n=M(e,"a","notEqual","string_or_numeric"),a=M(t,"b","notEqual","string_or_numeric");[n,a]=Ft(n,a),bt(n.shape,a.shape);let r={a:n,b:a};return W.runKernel(Nl,r)}var oo=B({notEqual_:lM});function uM(e){let t={x:M(e,"x","onesLike")};return W.runKernel(Rl,t)}var da=B({onesLike_:uM});function dM(e,t){let n=M(e,"v1","outerProduct"),a=M(t,"v2","outerProduct");$(n.rank===1&&a.rank===1,()=>`Error in outerProduct: inputs must be rank 1, but got ranks ${n.rank} and ${a.rank}.`);let r=V(n,[-1,1]),s=V(a,[1,-1]);return Ve(r,s)}var pM=B({outerProduct_:dM});function cM(e,t,n=0){let a=M(e,"x","pad");if(a.rank===0)throw new Error("pad(scalar) is not defined. Pass non-scalar to pad");let r={paddings:t,constantValue:n},s={x:a};return W.runKernel(Ti,s,r)}var Sa=B({pad_:cM});function hM(e,t,n=0){return $(t.length===2,()=>"Invalid number of paddings. Must be length of 2."),Sa(e,[t],n)}var fM=B({pad1d_:hM});function mM(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."),Sa(e,t,n)}var gM=B({pad2d_:mM});function yM(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."),Sa(e,t,n)}var AM=B({pad3d_:yM});function xM(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."),Sa(e,t,n)}var bM=B({pad4d_:xM});function vM(e,t,n){let a=M(e,"x","spaceToBatchND");$(a.rank>=1+t.length,()=>`input rank ${a.rank} should be > than [blockShape] ${t.length}`),$(n.length===t.length,()=>`paddings.shape[0] ${n.length} must be equal to [blockShape] ${t.length}`),$(a.shape.reduce((i,o,l)=>l>0&&l<=t.length?i&&(o+n[l-1][0]+n[l-1][1])%t[l-1]==0:i,!0),()=>`input spatial dimensions ${a.shape.slice(1)} with paddings ${n.toString()} must be divisible by blockShapes ${t.toString()}`);let r={x:a},s={blockShape:t,paddings:n};return W.runKernel(Vl,r,s)}var ep=B({spaceToBatchND_:vM});function wM(e,t,n,a,r,s){r==null&&(r=[1,1]),s==null&&(s=1),a===0&&(a="valid");let i=M(e,"x","maxPool"),o=i,l=!1;i.rank===3&&(l=!0,o=V(i,[1,i.shape[0],i.shape[1],i.shape[2]])),$(gr(s,r),()=>`Error in pool: Either strides or dilations must be 1. Got strides ${s} and dilations '${r}'`);let d=n3(o.shape,t,s,r,a),u=[d.dilationHeight,d.dilationWidth],p;a==="same"?p=IM([d.filterHeight,d.filterWidth],u):p=[[0,0],[0,0]];let c=u[0]===1&&u[1]===1,[h,f]=kM([d.inHeight,d.inWidth],u,p),m=c?a:"valid",g=c?o:ep(o,u,h),y=(n==="avg"?()=>Hd(g,t,s,m):()=>Jd(g,t,s,m))(),A=c?y:qd(y,u,f);return l?V(A,[A.shape[1],A.shape[2],A.shape[3]]):A}function kM(e,t,n){let a=n.map(u=>u[0]),r=n.map(u=>u[1]),s=e.concat(a,r),i=t.map((u,p)=>(u-s[p]%u)%u),o=r.map((u,p)=>u+i[p]),l=t.map((u,p)=>[a[p],o[p]]),d=t.map((u,p)=>[0,i[p]]);return[l,d]}function IM(e,t){let n=e.map((s,i)=>s+(s-1)*(t[i]-1)).map(s=>s-1),a=n.map(s=>Math.floor(s/2)),r=n.map((s,i)=>s-a[i]);return n.map((s,i)=>[a[i],r[i]])}var C3=B({pool_:wM});function SM(e,t){let n=M(e,"base","pow"),a=M(t,"exp","pow");[n,a]=Ft(n,a);let r={a:n,b:a};return W.runKernel(Ci,r)}var Pr=B({pow_:SM});function NM(e,t){let n=M(e,"x","prelu"),a=M(t,"alpha","prelu"),r={x:n,alpha:a};return W.runKernel(Ei,r)}var tp=B({prelu_:NM});function TM(e,t=null,n=!1){let a=M(e,"x","prod");a.dtype==="bool"&&(a=pe(a,"int32"));let r={x:a},s={axis:t,keepDims:n};return W.runKernel(Fl,r,s)}var Kh=B({prod_:TM});function CM(e,t,n){let a=zt(e),r=null;if(n==null||n==="float32")r=new Float32Array(a);else if(n==="int32")r=new Int32Array(a);else if(n==="bool")r=new Uint8Array(a);else throw new Error(`Unknown data type ${n}`);for(let s=0;s<a;s++)r[s]=t();return W.makeTensor(r,e,n)}var EM=B({rand_:CM}),Hg=qs(z5()),qg=class{constructor(e,t,n,a,r){this.mean=e,this.stdDev=t,this.dtype=n,this.nextVal=NaN,this.truncated=a,this.truncated&&(this.upper=this.mean+this.stdDev*2,this.lower=this.mean-this.stdDev*2);let s=r||Math.random();this.random=Hg.alea(s.toString())}nextValue(){if(!isNaN(this.nextVal)){let a=this.nextVal;return this.nextVal=NaN,a}let e,t,n=!1;for(;!n;){let a,r,s;do a=2*this.random()-1,r=2*this.random()-1,s=a*a+r*r;while(s>=1||s===0);let i=Math.sqrt(-2*Math.log(s)/s);e=this.mean+this.stdDev*a*i,t=this.mean+this.stdDev*r*i,(!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}},RM=class{constructor(e,t,n,a){this.alpha=e,this.beta=1/t,this.dtype=n;let r=a||Math.random();this.randu=Hg.alea(r.toString()),this.randn=new qg(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,a,r,s;for(;;){do a=this.randn.nextValue(),s=1+this.c*a;while(s<=0);if(s*=s*s,e=a*a,t=1-.331*e*e,n=.5*e+this.d*(1-s+Math.log(s)),r=this.randu(),r<t||Math.log(r)<n)break}return s=1/this.beta*this.d*s,this.alpha<1&&(s*=Math.pow(this.randu(),1/this.alpha)),this.convertValue(s)}convertValue(e){return this.dtype==="float32"?e:Math.round(e)}},MM=class{constructor(e=0,t=1,n,a){if(this.canReturnFloat=()=>this.dtype==null||this.dtype==="float32",this.min=e,this.range=t-e,this.dtype=n,a==null&&(a=Math.random()),typeof a=="number"&&(a=a.toString()),!this.canReturnFloat()&&this.range<=1)throw new Error(`The difference between ${e} - ${t} <= 1 and dtype is not float`);this.random=Hg.alea(a)}convertValue(e){return this.canReturnFloat()?e:Math.round(e)}nextValue(){return this.convertValue(this.min+this.range*this.random())}};function FM(e,t,n=1,a="float32",r){if(n==null&&(n=1),a==null&&(a="float32"),a!=="float32"&&a!=="int32")throw new Error(`Unsupported data type ${a}`);let s=new RM(t,n,a,r),i=Ge(e,a);for(let o=0;o<i.values.length;o++)i.values[o]=s.nextValue();return i.toTensor()}var DM=B({randomGamma_:FM});function $M(e,t=0,n=1,a,r){if(a!=null&&a==="bool")throw new Error(`Unsupported data type ${a}`);let s=new qg(t,n,a,!1,r),i=Ge(e,a);for(let o=0;o<i.values.length;o++)i.values[o]=s.nextValue();return i.toTensor()}var E3=B({randomNormal_:$M});function OM(e,t=0,n=1,a="float32",r){let s=Ge(e,a),i=new MM(t,n,null,r);for(let o=0;o<s.values.length;o++)s.values[o]=i.nextValue();return s.toTensor()}var cu=B({randomUniform_:OM});function hu(e,t,n=1,a="float32"){if(n===0)throw new Error("Cannot have a step of zero");let r={start:e,stop:t,step:n,dtype:a};return W.runKernel(Td,{},r)}function _M(e){let t={input:M(e,"input","real")};return W.runKernel(ph,t)}var np=B({real_:_M});function PM(e){let t={x:M(e,"x","reciprocal")};return W.runKernel(Dl,t)}var Xg=B({reciprocal_:PM});function zM(e){let t={x:M(e,"x","relu")};return W.runKernel(Ri,t)}var Ja=B({relu_:zM});function LM(e){let t={x:M(e,"x","relu6")};return W.runKernel(Fi,t)}var Zh=B({relu6_:LM});function WM(e,t){let n={x:M(e,"x","reverse")},a={dims:t};return W.runKernel(Di,n,a)}var pa=B({reverse_:WM});function BM(e){let t=M(e,"x","reverse");return $(t.rank===1,()=>`Error in reverse1D: x must be rank 1 but got rank ${t.rank}.`),pa(t,0)}var VM=B({reverse1d_:BM});function UM(e,t){let n=M(e,"x","reverse");return $(n.rank===2,()=>`Error in reverse2D: x must be rank 2 but got rank ${n.rank}.`),pa(n,t)}var jM=B({reverse2d_:UM});function GM(e,t){let n=M(e,"x","reverse");return $(n.rank===3,()=>`Error in reverse3D: x must be rank 3 but got rank ${n.rank}.`),pa(n,t)}var HM=B({reverse3d_:GM});function qM(e,t){let n=M(e,"x","reverse");return $(n.rank===4,()=>`Error in reverse4D: x must be rank 4 but got rank ${n.rank}.`),pa(n,t)}var XM=B({reverse4d_:qM});function KM(e){let t={x:M(e,"x","round")};return W.runKernel($i,t)}var Yh=B({round_:KM});function ZM(e){let t={x:M(e,"x","rsqrt","float32")};return W.runKernel(Oi,t)}var Jh=B({rsqrt_:ZM});function Ce(e,t){if((In(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"&&In(e)&&!(e instanceof Uint8Array))throw new Error("When making a scalar from encoded string, the value must be `Uint8Array`.");return ms(e,[],[],t)}function YM(e){let t={x:M(e,"x","selu")};return W.runKernel(Pl,t)}var Qh=B({selu_:YM});function JM(e,t,n,a,r,s=[1,1],i="NHWC"){let o=M(e,"x","separableConv2d"),l=M(t,"depthwiseFilter","separableConv2d"),d=M(n,"pointwiseFilter","separableConv2d"),u=o,p=!1;if(o.rank===3&&(p=!0,u=V(o,[1,o.shape[0],o.shape[1],o.shape[2]])),i==="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}.`),$(d.rank===4,()=>`Error in separableConv2d: pointwise filter must be rank 4, but got rank ${l.rank}.`),$(d.shape[0]===1,()=>`Error in separableConv2d: the first dimension of pointwise filter must be 1, but got ${d.shape[0]}.`),$(d.shape[1]===1,()=>`Error in separableConv2d: the second dimension of pointwise filter must be 1, but got ${d.shape[1]}.`);let c=l.shape[2],h=l.shape[3];$(d.shape[2]===c*h,()=>`Error in separableConv2d: the third dimension of pointwise filter must be ${c*h}, but got ${d.shape[2]}.`);let f=ou(u,l,a,r,i,s),m=_r(f,d,1,"valid",i);return p?V(m,[m.shape[1],m.shape[2],m.shape[3]]):m}var Kg=B({separableConv2d_:JM});async function QM(e,t){let n=M(e,"x","setdiff1d"),a=M(t,"y","setdiff1d");$(n.dtype===a.dtype,()=>`x and y should have the same dtype, but got x (${n.dtype}) and y (${a.dtype}).`),$(n.rank===1,()=>`x should be 1D tensor, but got x (${n.shape}).`),$(a.rank===1,()=>`y should be 1D tensor, but got y (${a.shape}).`);let r=await n.data(),s=await a.data(),i=new Set(s),o=0;for(let u=0;u<r.length;u++)i.has(r[u])||o++;let l=new Jt([o],n.dtype),d=new Jt([o],"int32");for(let u=0,p=0;u<r.length;u++)i.has(r[u])||(l.values[p]=r[u],d.values[p]=u,p++);return[l.toTensor(),d.toTensor()]}var R3=QM;function eF(e){let t={x:M(e,"x","sign")};return W.runKernel(Wl,t)}var Zg=B({sign_:eF});function tF(e){let t={x:M(e,"x","sin","float32")};return W.runKernel(_i,t)}var e0=B({sin_:tF});function nF(e){let t={x:M(e,"x","sinh")};return W.runKernel(Ll,t)}var t0=B({sinh_:nF});function aF(e,t,n){let a=M(e,"x","slice1d");return $(a.rank===1,()=>`slice1d expects a rank-1 tensor, but got a rank-${a.rank} tensor`),De(a,[t],[n])}var n0=B({slice1d_:aF});function rF(e,t,n){let a=M(e,"x","slice2d");return $(a.rank===2,()=>`slice2d expects a rank-2 tensor, but got a rank-${a.rank} tensor`),De(a,t,n)}var Yg=B({slice2d_:rF});function sF(e,t,n){let a=M(e,"x","slice3d");return $(a.rank===3,()=>`slice3d expects a rank-3 tensor, but got a rank-${a.rank} tensor`),De(a,t,n)}var fu=B({slice3d_:sF});function iF(e,t,n){let a=M(e,"x","slice4d");return $(a.rank===4,()=>`slice4d expects a rank-4 tensor, but got a rank-${a.rank} tensor`),De(a,t,n)}var ap=B({slice4d_:iF});function oF(e,t=-1){let n=M(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 a={logits:n},r={dim:t};return W.runKernel(Wi,a,r)}var lo=B({softmax_:oF});function lF(e){$(e.dtype==="complex64",()=>`The dtype for tf.spectral.fft() must be complex64 but got ${e.dtype}.`);let t={input:e};return W.runKernel(nh,t)}var rp=B({fft_:lF});function uF(e){$(e.dtype==="complex64",()=>`The dtype for tf.spectral.ifft() must be complex64 but got ${e.dtype}.`);let t={input:e};return W.runKernel(ah,t)}var mu=B({ifft_:uF});function dF(e){let t=e.shape[e.shape.length-1],n=e.size/t,a;if(t<=2){let r=V(e,[n,t]);a=mu(r)}else{let r=[n,2*(t-1)],s=V(np(e),[n,t]),i=V(Uh(e),[n,t]),o=pa(De(s,[0,1],[n,t-2]),1),l=L(pa(De(i,[0,1],[n,t-2]),1),Ce(-1)),d=mt([s,o],1),u=mt([i,l],1),p=V(fs(d,u),[r[0],r[1]]);a=mu(p)}if(a=np(a),e.rank===3&&e.shape[0]!==0){let r=a,s=e.shape[0];a=V(a,[s,a.shape[0]/s,a.shape[1]]),r.dispose()}return a}var a0=B({irfft_:dF});function pF(e,t,n=0){let a={x:M(e,"x","split")},r={numOrSizeSplits:t,axis:n};return W.runKernel(Ul,a,r)}var cn=B({split_:pF});function cF(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],a=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=De(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,Gt(f)],e.shape.length-1),n=t}else r=e;let s=Ye(r),i=V(fs(r,s),[a,n]),o=rp(i),l=Math.floor(n/2)+1,d=np(o),u=Uh(o),p=cn(d,[l,n-l],d.shape.length-1),c=cn(u,[l,n-l],u.shape.length-1),h=r.shape.slice();return h[r.shape.length-1]=l,V(fs(p[0],c[0]),h)}var sp=B({rfft_:cF});function hF(e){let t={x:M(e,"x","sqrt","float32")};return W.runKernel(zi,t)}var An=B({sqrt_:hF});function fF(e,t){let n=M(e,"a","squaredDifference"),a=M(t,"b","squaredDifference");[n,a]=Ft(n,a),bt(n.shape,a.shape);let r={a:n,b:a},s={};return W.runKernel(Bi,r,s)}var r0=B({squaredDifference_:fF});function mF(e,t){let n=M(e,"x","squeeze");return V(n,V5(n.shape,t).newShape)}var st=B({squeeze_:mF});function gF(e,t=0){let n=Bd(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 a=n,r={axis:t};return W.runKernel(Ml,a,r)}var xn=B({stack_:gF});function yF(e,t=0){let n={x:M(e,"x","step")},a={alpha:t};return W.runKernel(ps,n,a)}var gu=B({step_:yF});function AF(e,t,n,a,r=0,s=0,i=0,o=0,l=0){let d={x:M(e,"x","stridedSlice","string_or_numeric")},u={begin:t,end:n,strides:a,beginMask:r,endMask:s,ellipsisMask:i,newAxisMask:o,shrinkAxisMask:l};return W.runKernel(jl,d,u)}var Jg=B({stridedSlice_:AF});function xF(e){let t={x:M(e,"x","tan","float32")};return W.runKernel(Ui,t)}var Qg=B({tan_:xF});function Ht(e,t){Xs(e);let n=fr(e,t);if(n.length!==1)throw new Error("tensor1d() requires values to be a flat/TypedArray");return ms(e,null,n,t)}function Qa(e,t,n){if(Xs(e),t!=null&&t.length!==2)throw new Error("tensor2d() requires shape to have two numbers");let a=fr(e,n);if(a.length!==2&&a.length!==1)throw new Error("tensor2d() requires values to be number[][] or flat/TypedArray");if(a.length===1&&t==null)throw new Error("tensor2d() requires shape to be provided when `values` are a flat/TypedArray");return ms(e,t,a,n)}function bF(e,t,n){if(Xs(e),t!=null&&t.length!==4)throw new Error("tensor4d() requires shape to have four numbers");let a=fr(e,n);if(a.length!==4&&a.length!==1)throw new Error("tensor4d() requires values to be number[][][][] or flat/TypedArray");if(a.length===1&&t==null)throw new Error("tensor4d() requires shape to be provided when `values` are a flat array");return ms(e,t,a,n)}function vF(e,t,n){if(Xs(e),t!=null&&t.length!==5)throw new Error("tensor5d() requires shape to have five numbers");let a=fr(e,n);if(a.length!==5&&a.length!==1)throw new Error("tensor5d() requires values to be number[][][][][] or flat/TypedArray");if(a.length===1&&t==null)throw new Error("tensor5d() requires shape to be provided when `values` are a flat array");return ms(e,t,a,n)}function wF(e,t,n){if(Xs(e),t!=null&&t.length!==6)throw new Error("tensor6d() requires shape to have six numbers");let a=fr(e,n);if(a.length!==6&&a.length!==1)throw new Error("tensor6d() requires values to be number[][][][][][] or flat/TypedArray");if(a.length===1&&t==null)throw new Error("tensor6d() requires shape to be provided when `values` are a flat array");return t=t||a,ms(e,t,a,n)}function kF(e,t=1,n=!0){let a=M(e,"x","topk");if(a.rank===0)throw new Error("topk() expects the input to be of rank 1 or higher");let r=a.shape[a.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 s={x:a},i={k:t,sorted:n},[o,l]=W.runKernel(Gl,s,i);return{values:o,indices:l}}var ey=B({topk_:kF});function IF(e,t=0,n=1,a,r){if(a!=null&&a==="bool")throw new Error("Unsupported data type $ { dtype }");let s=new qg(t,n,a,!0,r),i=Ge(e,a);for(let o=0;o<i.values.length;o++)i.values[o]=s.nextValue();return i.toTensor()}var s0=B({truncatedNormal_:IF});function SF(e,t=0){let n=M(e,"x","unique","string_or_numeric");$(n.rank>0,()=>"The input tensor must be at least 1D");let a={x:n},r={axis:t},[s,i]=W.runKernel(wh,a,r);return{values:s,indices:i}}var i0=B({unique_:SF});function NF(e,t,n){let a=M(e,"x","unsortedSegmentSum"),r=M(t,"segmentIds","unsortedSegmentSum","int32");$(un(n),()=>"numSegments must be of dtype int");let s={x:a,segmentIds:r},i={numSegments:n};return W.runKernel(Rd,s,i)}var ty=B({unsortedSegmentSum_:NF});function TF(e,t=0){let n=M(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 a={value:n},r={axis:t};return W.runKernel(ql,a,r)}var Mn=B({unstack_:TF});function M3(e,t=!0,n,a){return W.makeVariable(e,t,n,a)}function F3(e,t){let n=[];for(let s=0;s<t.length;s++)t[s]&&n.push(s);let a=Ge(e,"int32"),r=Ge([n.length,e.length],"int32");for(let s=0;s<n.length;s++){let i=a.indexToLoc(n[s]),o=s*e.length;r.values.set(i,o)}return r.toTensor()}async function CF(e){let t=M(e,"condition","whereAsync","bool"),n=await t.data(),a=F3(t.shape,n);return e!==t&&t.dispose(),a}var ny=CF;async function EF(e,t,n){let a=M(e,"tensor","boolMask"),r=M(t,"mask","boolMask","bool"),s=n==null?0:n,i=r.rank,o=a.shape;$(i>0,()=>"mask cannot be scalar"),Tn(o.slice(s,s+i),r.shape,"mask's shape must match the first K dimensions of tensor's shape,");let l=1;for(let m=s;m<s+i;m++)l*=o[m];let d=o.slice(0,s).concat([l],o.slice(s+i)),u=V(a,d),p=V(r,[-1]),c=await ny(p),h=st(c,[1]),f=ro(u,h,s);return e!==a&&a.dispose(),t!==r&&r.dispose(),h.dispose(),u.dispose(),p.dispose(),c.dispose(),f}var RF=EF;function MF(e,t="euclidean",n=null,a=!1){e=M(e,"x","norm");let r=D3(e,t,n),s=r.shape;if(a){let i=_a(n,e.shape);s=io(r.shape,i)}return V(r,s)}function D3(e,t,n=null){if(e.rank===0)return jt(e);if(e.rank!==1&&n===null)return D3(V(e,[-1]),t,n);if(e.rank===1||typeof n=="number"||Array.isArray(n)&&n.length===1){if(t===1)return Ie(jt(e),n);if(t===1/0)return Rn(jt(e),n);if(t===-1/0)return Qd(jt(e),n);if(t==="euclidean"||t===2)return An(Ie(Pr(jt(e),Ce(2,"int32")),n));throw new Error(`Error in norm: invalid ord value: ${t}`)}if(Array.isArray(n)&&n.length===2){if(t===1)return Rn(Ie(jt(e),n[0]),n[1]-1);if(t===1/0)return Rn(Ie(jt(e),n[1]),n[0]);if(t===-1/0)return Qd(Ie(jt(e),n[1]),n[0]);if(t==="fro"||t==="euclidean")return An(Ie(ht(e),n));throw new Error(`Error in norm: invalid ord value: ${t}`)}throw new Error(`Error in norm: invalid axis: ${n}`)}var o0=B({norm_:MF});function FF(e,t,n,a,r=!0){let s=M(e,"v","movingAverage"),i=M(t,"x","movingAverage"),o=M(n,"decay","movingAverage");ub(s,i),$(Dr(s.shape,i.shape),()=>"Shape mismatch in v and x");let l=Ce(1),d=ge(l,o),u=L(ge(i,s),d);if(r){$(a!=null,()=>"When using zeroDebias: true, step is required.");let p=M(a,"step","movingAverage");u=he(u,ge(l,Pr(o,p)))}return le(s,u)}var DF=B({movingAverage_:FF});function $F(e,t,n){let a=M(e,"indices","scatterND","int32"),r=M(t,"updates","scatterND");pg(r,a,n);let s={indices:a,updates:r},i={shape:n};return W.runKernel(Ol,s,i)}var $3=B({scatterND_:$F});function OF(e,t,n,a){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,s=e.rank>1?e.shape[1]:1;if(n.length!==s)throw new Error(`outputShape has incorrect number of elements:, ${n.length}, should be: ${s}.`);let i=t.size;if(!(t.rank===0||t.rank===1&&i===r))throw new Error(`sparseValues has incorrect shape ${t.shape}, should be [] or [${r}]`);if(t.dtype!==a.dtype)throw new Error("sparseValues.dtype must match defaultValues.dtype")}function _F(e,t,n,a=0){let r=M(e,"sparseIndices","sparseToDense","int32"),s=M(t,"sparseValues","sparseToDense"),i=M(a,"defaultValue","sparseToDense",s.dtype);OF(r,s,n,i);let o={sparseIndices:r,sparseValues:s,defaultValue:i},l={outputShape:n};return W.runKernel(Ah,o,l)}var ay=B({sparseToDense_:_F});function PF(e,t){let n=M(t,"indices","gatherND","int32"),a={params:M(e,"x","gatherND","string_or_numeric"),indices:n};return W.runKernel(ml,a)}var O3=B({gatherND_:PF});function zF(e,t){if(t==null)return e.shape.slice();if(Dr(e.shape,t))return t;if(e.shape.length===t.length){let n=[];for(let a=0;a<e.shape.length;a++)t[a]==null&&e.shape[a]!=null?n.push(e.shape[a]):n.push(t[a]);return n}return t}function LF(e,t,n,a){let r=M(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 je?r.clone():r;let s=zF(r,n),i=1-t,o=he(du(le(cu(s,0,1,"float32",a),i)),i);return L(r,o)}var _3=B({dropout_:LF});function P3(e){return Math.floor(Math.pow(2,Math.ceil(Math.log(e)/Math.log(2))))}function ry(e,t,n){let a=1-e%2,r=new Float32Array(e);for(let s=0;s<e;++s){let i=2*Math.PI*s/(e+a-1);r[s]=t-n*Math.cos(i)}return Ht(r,"float32")}async function WF(e,t,n=1){let a=M(e,"predictions","inTopK"),r=M(t,"targets","inTopK");$(a.rank>1,()=>`inTopK() expects the predictions to be of rank 2 or higher, but got ${a.rank}`),$(a.rank-1===r.rank,()=>`predictions rank should be 1 larger than targets rank, but got predictions rank ${a.rank} and targets rank ${r.rank}`),Tn(a.shape.slice(0,a.shape.length-1),r.shape,"predictions's shape should be align with the targets' shape, except the last dimension.");let s=a.shape[a.shape.length-1];$(n>0&&n<=s,()=>`'k' passed to inTopK() must be > 0 && <= the predictions last dimension (${s}), but got ${n}`);let i=await a.data(),o=await r.data(),[l,d]=[i.length/s,s],u=U5("bool",l);for(let p=0;p<l;p++){let c=p*d,h=i.subarray(c,c+d),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[p]=0;for(let m=0;m<n;m++)if(f[m].index===o[p]){u[p]=1;break}}return e!==a&&a.dispose(),t!==r&&r.dispose(),Lt(u,r.shape,"bool")}var BF=WF,vs={};ze(vs,{conv2d:()=>jF,depthwiseConv2d:()=>XF,matMul:()=>ZF});function VF(e,t,n,a,r,s="NHWC",i){let o=e;e.rank===3&&(o=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]])),$(o.rank===4,()=>`Error in conv2dDerFilter: input must be rank 4, but got shape ${o.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 d=s==="NHWC"?o.shape[3]:o.shape[1],u=s==="NHWC"?l.shape[3]:l.shape[1];$(d===n[2],()=>`Error in conv2dDerFilter: depth of input ${d}) 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]}).`),i!=null&&$(un(r),()=>`Error in conv2dDerFilter: pad must be an integer when using, dimRoundingMode ${i} but got pad ${r}.`);let p={x:o,dy:l},c={strides:a,pad:r,dataFormat:s,dimRoundingMode:i,filterShape:n};return W.runKernel(Gc,p,c)}var sy=B({conv2DBackpropFilter_:VF});function l0(e,t,n){if(n==null||n==="linear")return e;if(n==="relu")return L(e,gu(t));throw new Error(`Cannot compute gradient for fused activation ${n}.`)}function u0(e,t){let n=t,a=Qt(e.shape,t.shape);return a.length>0&&(n=Ie(n,a)),V(n,e.shape)}function d0(e,t,n,a){if(t==="linear")return e;if(t==="relu")return Ja(e);if(t==="elu")return lu(e);if(t==="relu6")return Zh(e);if(t==="prelu")return tp(e,n);if(t==="leakyrelu")return Kd(e,a);if(t==="sigmoid")return Kn(e);throw new Error(`Unknown fused activation ${t}.`)}var p0=(e,t)=>!(e>0)||t==="linear";function UF({x:e,filter:t,strides:n,pad:a,dataFormat:r="NHWC",dilations:s=[1,1],dimRoundingMode:i,bias:o,activation:l="linear",preluActivationWeights:d,leakyreluAlpha:u}){if(l=l||"linear",p0(W.state.gradientDepth,l)===!1){let v=_r(e,t,n,a,r,s,i);return o!=null&&(v=le(v,o)),d0(v,l,d,u)}let p=M(e,"x","conv2d","float32"),c=M(t,"filter","conv2d","float32"),h=p,f=!1;p.rank===3&&(f=!0,h=V(p,[1,p.shape[0],p.shape[1],p.shape[2]])),$(h.rank===4,()=>`Error in fused conv2d: input must be rank 4, but got rank ${h.rank}.`),$(c.rank===4,()=>`Error in fused conv2d: filter must be rank 4, but got rank ${c.rank}.`),i!=null&&$(un(a),()=>`Error in fused conv2d: pad must be an integer when using, dimRoundingMode ${i} but got pad ${a}.`),$(h.shape[3]===c.shape[2],()=>`Error in conv2d: depth of input (${h.shape[3]}) must match input depth for filter ${c.shape[2]}.`),$(gr(n,s),()=>`Error in conv2D: Either strides or dilations must be 1. Got strides ${n} and dilations '${s}'`),$(r==="NHWC",()=>`Error in conv2d: got dataFormat of ${r} but only NHWC is currently supported.`);let m=Gd(h.shape,c.shape,n,s,a,i),g;o!=null&&(g=M(o,"bias","fused conv2d"),[g]=Ft(g,p),bt(m.outShape,g.shape));let y;d!=null&&(y=M(d,"prelu weights","fused conv2d"));let A=(v,k)=>{let[T,C,D,O]=k,F=l0(v,D,l);$(As(s),()=>`Error in gradient of fused conv2D: dilation rates greater than 1 are not yet supported in gradients. Got dilations '${s}'`);let S=Rg(C.shape,F,T,n,a),P=sy(C,F,T.shape,n,a),_=[S,P];if(O!=null){let j=u0(O,F);_.push(j)}return _},x={x:h,filter:c,bias:g,preluActivationWeights:y},b={strides:n,pad:a,dataFormat:r,dilations:s,dimRoundingMode:i,activation:l,leakyreluAlpha:u};return o==null?yr((v,k,T)=>{let C=W.runKernel(qi,x,b);return T([k,v,C]),f&&(C=V(C,[C.shape[1],C.shape[2],C.shape[3]])),{value:C,gradFunc:A}})(h,c):yr((v,k,T,C)=>{let D=W.runKernel(qi,x,b);return C([k,v,D,T]),f&&(D=V(D,[D.shape[1],D.shape[2],D.shape[3]])),{value:D,gradFunc:A}})(h,c,g)}var jF=B({fusedConv2d_:UF});function GF(e,t,n,a,r,s=[1,1],i){let o=e;e.rank===3&&(o=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 d={x:o,dy:l},u={strides:a,pad:r,dimRoundingMode:i,dilations:s,filterShape:n};return W.runKernel(Kc,d,u)}var z3=B({depthwiseConv2dNativeBackpropFilter_:GF});function HF(e,t,n,a,r,s=[1,1],i){let o=t,l=!1;t.rank===3&&(l=!0,o=V(t,[1,t.shape[0],t.shape[1],t.shape[2]]));let d={dy:o,filter:n},u={strides:a,pad:r,dimRoundingMode:i,dilations:s,inputShape:e},p=W.runKernel(Zc,d,u);return l?V(p,[p.shape[1],p.shape[2],p.shape[3]]):p}var L3=B({depthwiseConv2dNativeBackpropInput_:HF});function qF({x:e,filter:t,strides:n,pad:a,dataFormat:r="NHWC",dilations:s=[1,1],dimRoundingMode:i,bias:o,activation:l="linear",preluActivationWeights:d,leakyreluAlpha:u}){if(p0(W.state.gradientDepth,l)===!1){let v=ou(e,t,n,a,r,s,i);return o!=null&&(v=le(v,o)),d0(v,l,d,u)}let p=M(e,"x","depthwiseConv2d","float32"),c=M(t,"filter","depthwiseConv2d","float32"),h=p,f=!1;p.rank===3&&(f=!0,h=V(p,[1,p.shape[0],p.shape[1],p.shape[2]])),$(h.rank===4,()=>`Error in fused depthwiseConv2d: input must be rank 4, but got rank ${h.rank}.`),$(c.rank===4,()=>`Error in fused depthwiseConv2d: filter must be rank 4, but got rank ${c.rank}.`),$(h.shape[3]===c.shape[2],()=>`Error in fused depthwiseConv2d: number of input channels (${h.shape[3]}) must match the inChannels dimension in filter ${c.shape[2]}.`),s==null&&(s=[1,1]),$(gr(n,s),()=>`Error in fused depthwiseConv2d: Either strides or dilations must be 1. Got strides ${n} and dilations '${s}'`),i!=null&&$(un(a),()=>`Error in fused depthwiseConv2d: pad must be an integer when using dimRoundingMode ${i} but got pad ${a}.`);let m=Gd(h.shape,c.shape,n,s,a,i,!0),g;o!=null&&(g=M(o,"bias","fused conv2d"),[g]=Ft(g,p),bt(m.outShape,g.shape));let y;d!=null&&(y=M(d,"prelu weights","fused depthwiseConv2d"));let A=(v,k)=>{$(As(s),()=>`Error in gradient of fused depthwiseConv2d: dilation rates greater than 1 are not yet supported. Got dilations '${s}'`);let[T,C,D,O]=k,F=l0(v,D,l),S=L3(C.shape,F,T,n,a,s,i),P=z3(C,F,T.shape,n,a,s,i);if(O!=null){let _=u0(g,F);return[S,P,_]}return[S,P]},x={x:h,filter:c,bias:g,preluActivationWeights:y},b={strides:n,pad:a,dataFormat:r,dilations:s,dimRoundingMode:i,activation:l,leakyreluAlpha:u};return o==null?yr((v,k,T)=>{let C=W.runKernel(Xi,x,b);return T([k,v,C]),f&&(C=V(C,[C.shape[1],C.shape[2],C.shape[3]])),{value:C,gradFunc:A}})(h,c):yr((v,k,T,C)=>{let D=W.runKernel(Xi,x,b);return C([k,v,D,T]),f&&(D=V(D,[D.shape[1],D.shape[2],D.shape[3]])),{value:D,gradFunc:A}})(h,c,g)}var XF=B({fusedDepthwiseConv2d_:qF});function KF({a:e,b:t,transposeA:n=!1,transposeB:a=!1,bias:r,activation:s="linear",preluActivationWeights:i,leakyreluAlpha:o}){if(p0(W.state.gradientDepth,s)===!1){let O=Ve(e,t,n,a);return r!=null&&(O=le(O,r)),d0(O,s,i,o)}let l=M(e,"a","fused matMul"),d=M(t,"b","fused matMul");[l,d]=Ft(l,d);let u=n?l.shape[l.rank-2]:l.shape[l.rank-1],p=a?d.shape[d.rank-1]:d.shape[d.rank-2],c=n?l.shape[l.rank-1]:l.shape[l.rank-2],h=a?d.shape[d.rank-2]:d.shape[d.rank-1],f=l.shape.slice(0,-2),m=d.shape.slice(0,-2),g=zt(f),y=zt(m);$(l.rank>=2&&d.rank>=2&&l.rank===d.rank,()=>`Error in fused matMul: inputs must have the same rank of at least 2, got ranks ${l.rank} and ${d.rank}.`),$(Dr(f,m),()=>`Error in fused matMul: outer dimensions (${f}) and (${m}) of Tensors with shapes ${l.shape} and ${d.shape} must match.`),$(u===p,()=>`Error in fused matMul: inner shapes (${u}) and (${p}) of Tensors with shapes ${l.shape} and ${d.shape} and transposeA=${n} and transposeB=${a} must match.`);let A=l.shape.slice(0,-2).concat([c,h]),x=n?V(l,[g,u,c]):V(l,[g,c,u]),b=a?V(d,[y,h,p]):V(d,[y,p,h]),v;r!=null&&(v=M(r,"bias","fused matMul"),[v]=Ft(v,l),bt(A,v.shape));let k;i!=null&&(k=M(i,"prelu weights","fused matMul"));let T=(O,F)=>{let[S,P,_,j]=F,q=l0(V(O,_.shape),_,s),z,X;if(!n&&!a?(z=Ve(q,P,!1,!0),X=Ve(S,q,!0,!1)):!n&&a?(z=Ve(q,P,!1,!1),X=Ve(q,S,!0,!1)):n&&!a?(z=Ve(P,q,!1,!0),X=Ve(S,q,!1,!1)):(z=Ve(P,q,!0,!0),X=Ve(q,S,!0,!0)),r!=null){let Z=u0(j,q);return[z,X,Z]}else return[z,X]},C={a:x,b,bias:v,preluActivationWeights:k},D={transposeA:n,transposeB:a,activation:s,leakyreluAlpha:o};return r==null?yr((O,F,S)=>{let P=W.runKernel(Hi,C,D);return S([O,F,P]),{value:V(P,A),gradFunc:T}})(x,b):yr((O,F,S,P)=>{let _=W.runKernel(Hi,C,D);return P([O,F,_,S]),{value:V(_,A),gradFunc:T}})(x,b,v)}var ZF=B({fusedMatMul_:KF});function YF(e){return ry(e,.54,.46)}var JF=B({hammingWindow_:YF});function QF(e){return ry(e,.5,.5)}var W3=B({hannWindow_:QF});function eD(e,t,n,a=!1,r=0){let s=0,i=[];for(;s+t<=e.size;)i.push(De(e,s,t)),s+=n;if(a)for(;s<e.size;){let o=s+t-e.size,l=mt([De(e,s,t-o),uu([o],r)]);i.push(l),s+=n}return i.length===0?Qa([],[0,t]):V(mt(i),[i.length,t])}var B3=B({frame_:eD});function tD(e,t,n,a,r=W3){a==null&&(a=P3(t));let s=B3(e,t,n),i=L(s,r(t));return sp(i,a)}var nD=B({stft_:tD});function aD(e,t,n,a,r="bilinear",s=0){let i=M(e,"image","cropAndResize"),o=M(t,"boxes","cropAndResize","float32"),l=M(n,"boxInd","cropAndResize","int32"),d=o.shape[0];$(i.rank===4,()=>`Error in cropAndResize: image must be rank 4,but got rank ${i.rank}.`),$(o.rank===2&&o.shape[1]===4,()=>`Error in cropAndResize: boxes must be have size [${d},4] but had shape ${o.shape}.`),$(l.rank===1&&l.shape[0]===d,()=>`Error in cropAndResize: boxInd must be have size [${d}] but had shape ${o.shape}.`),$(a.length===2,()=>`Error in cropAndResize: cropSize must be of length 2, but got length ${a.length}.`),$(a[0]>=1&&a[1]>=1,()=>`cropSize must be atleast [1,1], but was ${a}`),$(r==="bilinear"||r==="nearest",()=>`method must be bilinear or nearest, but was ${r}`);let u={image:i,boxes:o,boxInd:l},p={method:r,extrapolationValue:s,cropSize:a};return W.runKernel(ol,u,p)}var rD=B({cropAndResize_:aD});function sD(e){let t=M(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 W.runKernel(hl,n,{})}var iD=B({flipLeftRight_:sD});function oD(e){let t=M(e,"image","grayscaleToRGB"),n=t.rank-1,a=t.shape[n];$(t.rank>=2,()=>`Error in grayscaleToRGB: images must be at least rank 2, but got rank ${t.rank}.`),$(a===1,()=>`Error in grayscaleToRGB: last dimension of a grayscale image should be size 1, but got size ${a}.`);let r=new Array(t.rank);return r.fill(1,0,n),r[n]=3,Ia(t,r)}var lD=B({grayscaleToRGB_:oD});function uD(e,t,n=0,a=.5){let r=M(e,"image","rotateWithOffset","float32");$(r.rank===4,()=>`Error in rotateWithOffset: image must be rank 4,but got rank ${r.rank}.`);let s={image:r},i={radians:t,fillValue:n,center:a};return W.runKernel(Kl,s,i)}var dD=B({rotateWithOffset_:uD});function yu(e,t,n,a,r,s){a==null&&(a=.5),r==null&&(r=Number.NEGATIVE_INFINITY),s==null&&(s=0);let i=e.shape[0];return n=Math.min(n,i),$(0<=a&&a<=1,()=>`iouThreshold must be in [0, 1], but was '${a}'`),$(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]===i,()=>`scores has incompatible shape with boxes. Expected ${i}, but was ${t.shape[0]}`),$(0<=s&&s<=1,()=>`softNmsSigma must be in [0, 1], but was '${s}'`),{maxOutputSize:n,iouThreshold:a,scoreThreshold:r,softNmsSigma:s}}function pD(e,t,n,a=.5,r=Number.NEGATIVE_INFINITY){let s=M(e,"boxes","nonMaxSuppression","float32"),i=M(t,"scores","nonMaxSuppression","float32"),o=yu(s,i,n,a,r);n=o.maxOutputSize,a=o.iouThreshold,r=o.scoreThreshold;let l={maxOutputSize:n,iouThreshold:a,scoreThreshold:r};return W.runKernel(Tl,{boxes:s,scores:i},l)}var cD=B({nonMaxSuppression_:pD});function hD(e,t,n){let a=fD(e,t,n),r=a<0?-(a+1):a;e.splice(r,0,t)}function fD(e,t,n){return gD(e,t,n||mD)}function mD(e,t){return e>t?1:e<t?-1:0}function gD(e,t,n){let a=0,r=e.length,s=0,i=!1;for(;a<r;){s=a+(r-a>>>1);let o=n(t,e[s]);o>0?a=s+1:(r=s,i=!o)}return i?a:-a-1}function V3(e,t,n,a,r){return iy(e,t,n,a,r,0)}function U3(e,t,n,a,r,s){return iy(e,t,n,a,r,0,!1,s,!0)}function j3(e,t,n,a,r,s){return iy(e,t,n,a,r,s,!0)}function iy(e,t,n,a,r,s,i=!1,o=!1,l=!1){let d=[];for(let g=0;g<t.length;g++)t[g]>r&&d.push({score:t[g],boxIndex:g,suppressBeginIndex:0});d.sort(G3);let u=s>0?-.5/s:0,p=[],c=[];for(;p.length<n&&d.length>0;){let g=d.pop(),{score:y,boxIndex:A,suppressBeginIndex:x}=g;if(y<r)break;let b=!1;for(let v=p.length-1;v>=x;--v){let k=yD(e,A,p[v]);if(k>=a){b=!0;break}if(g.score=g.score*AD(a,u,k),g.score<=r)break}g.suppressBeginIndex=p.length,b||(g.score===y?(p.push(A),c.push(g.score)):g.score>r&&hD(d,g,G3))}let h=p.length,f=n-h;o&&f>0&&(p.push(...new Array(f).fill(0)),c.push(...new Array(f).fill(0)));let m={selectedIndices:p};return i&&(m.selectedScores=c),l&&(m.validOutputs=h),m}function yD(e,t,n){let a=e.subarray(t*4,t*4+4),r=e.subarray(n*4,n*4+4),s=Math.min(a[0],a[2]),i=Math.min(a[1],a[3]),o=Math.max(a[0],a[2]),l=Math.max(a[1],a[3]),d=Math.min(r[0],r[2]),u=Math.min(r[1],r[3]),p=Math.max(r[0],r[2]),c=Math.max(r[1],r[3]),h=(o-s)*(l-i),f=(p-d)*(c-u);if(h<=0||f<=0)return 0;let m=Math.max(s,d),g=Math.max(i,u),y=Math.min(o,p),A=Math.min(l,c),x=Math.max(y-m,0)*Math.max(A-g,0);return x/(h+f-x)}function AD(e,t,n){let a=Math.exp(t*n*n);return n<=e?a:0}function G3(e,t){return e.score-t.score||e.score===t.score&&t.boxIndex-e.boxIndex}async function xD(e,t,n,a=.5,r=Number.NEGATIVE_INFINITY){let s=M(e,"boxes","nonMaxSuppressionAsync"),i=M(t,"scores","nonMaxSuppressionAsync"),o=yu(s,i,n,a,r);n=o.maxOutputSize,a=o.iouThreshold,r=o.scoreThreshold;let l=await Promise.all([s.data(),i.data()]),d=l[0],u=l[1],{selectedIndices:p}=V3(d,u,n,a,r);return s!==e&&s.dispose(),i!==t&&i.dispose(),Ht(p,"int32")}var bD=xD;function vD(e,t,n,a=.5,r=Number.NEGATIVE_INFINITY,s=0){let i=M(e,"boxes","nonMaxSuppression"),o=M(t,"scores","nonMaxSuppression"),l=yu(i,o,n,a,r,s);n=l.maxOutputSize,a=l.iouThreshold,r=l.scoreThreshold,s=l.softNmsSigma;let d={boxes:i,scores:o},u={maxOutputSize:n,iouThreshold:a,scoreThreshold:r,softNmsSigma:s},p=W.runKernel(El,d,u);return{selectedIndices:p[0],selectedScores:p[1]}}var wD=B({nonMaxSuppressionWithScore_:vD});async function kD(e,t,n,a=.5,r=Number.NEGATIVE_INFINITY,s=0){let i=M(e,"boxes","nonMaxSuppressionAsync"),o=M(t,"scores","nonMaxSuppressionAsync"),l=yu(i,o,n,a,r,s);n=l.maxOutputSize,a=l.iouThreshold,r=l.scoreThreshold,s=l.softNmsSigma;let d=await Promise.all([i.data(),o.data()]),u=d[0],p=d[1],{selectedIndices:c,selectedScores:h}=j3(u,p,n,a,r,s);return i!==e&&i.dispose(),o!==t&&o.dispose(),{selectedIndices:Ht(c,"int32"),selectedScores:Ht(h)}}var ID=kD;function SD(e,t,n,a=.5,r=Number.NEGATIVE_INFINITY,s=!1){let i=M(e,"boxes","nonMaxSuppression"),o=M(t,"scores","nonMaxSuppression"),l=yu(i,o,n,a,r,null),d=l.maxOutputSize,u=l.iouThreshold,p=l.scoreThreshold,c={boxes:i,scores:o},h={maxOutputSize:d,iouThreshold:u,scoreThreshold:p,padToMaxOutputSize:s},f=W.runKernel(Cl,c,h);return{selectedIndices:f[0],validOutputs:f[1]}}var ND=B({nonMaxSuppressionPadded_:SD});async function TD(e,t,n,a=.5,r=Number.NEGATIVE_INFINITY,s=!1){let i=M(e,"boxes","nonMaxSuppressionAsync"),o=M(t,"scores","nonMaxSuppressionAsync"),l=yu(i,o,n,a,r,null),d=l.maxOutputSize,u=l.iouThreshold,p=l.scoreThreshold,[c,h]=await Promise.all([i.data(),o.data()]),{selectedIndices:f,validOutputs:m}=U3(c,h,d,u,p,s);return i!==e&&i.dispose(),o!==t&&o.dispose(),{selectedIndices:Ht(f,"int32"),validOutputs:Ce(m,"int32")}}var CD=TD;function ED(e,t,n=!1,a=!1){let r=M(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}.`),$(a===!1||n===!1,()=>"Error in resizeBilinear: If halfPixelCenters is true, alignCorners must be false.");let s=r,i=!1;r.rank===3&&(i=!0,s=V(r,[1,r.shape[0],r.shape[1],r.shape[2]]));let[]=t,o={images:s},l={alignCorners:n,halfPixelCenters:a,size:t},d=W.runKernel(Mi,o,l);return i?V(d,[d.shape[1],d.shape[2],d.shape[3]]):d}var H3=B({resizeBilinear_:ED});function RD(e,t,n=!1,a=!1){let r=M(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"),$(a===!1||n===!1,()=>"Error in resizeNearestNeighbor: If halfPixelCenters is true, alignCorners must be false.");let s=r,i=!1;r.rank===3&&(i=!0,s=V(r,[1,r.shape[0],r.shape[1],r.shape[2]]));let[]=t,o={images:s},l={alignCorners:n,halfPixelCenters:a,size:t},d=W.runKernel(Cd,o,l);return i?V(d,[d.shape[1],d.shape[2],d.shape[3]]):d}var q3=B({resizeNearestNeighbor_:RD});function MD(e,t="binary",n=!1,a=.5){let r=M(e,"image","threshold"),s=.2989,i=.587,o=.114,l=r.shape[0]*r.shape[1],d=L(Ht([a]),255),u,p,c,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,p,c]=cn(r,[1,1,1],-1);let m=L(u,s),g=L(p,i),y=L(c,o);h=le(le(m,g),y)}else h=e;if(t==="otsu"){let m=Cg(pe(Yh(h),"int32"),Lt([]),256);d=FD(m,l)}let f=n?bs(h,d):Yn(h,d);return pe(L(f,255),"int32")}function FD(e,t){let n=Ht([-1]),a=Ht([0]),r=Ht([0]),s,i,o,l,d,u;for(let p=0;p<e.size-1;p++){s=De(e,0,p+1),i=De(e,p+1),d=he(Ie(s),t),u=he(Ie(i),t);let c=Ie(L(s,hu(0,s.size)));o=he(c,Ie(s));let h=uu(i.shape,s.size),f=le(hu(0,i.size),h),m=L(i,f);l=he(Ie(m),Ie(i));let g=ge(o,l),y=ge(o,l),A=L(d,u);r=L(L(A,g),y);let x=Yn(r,a);a=Sn(x,r,a),n=Sn(x,Ht([p]),n)}return n}var DD=B({threshold_:MD});function $D(e,t,n="nearest",a="constant",r=0,s){let i=M(e,"image","transform","float32"),o=M(t,"transforms","transform","float32");$(i.rank===4,()=>`Error in transform: image must be rank 4,but got rank ${i.rank}.`),$(o.rank===2&&(o.shape[0]===i.shape[0]||o.shape[0]===1)&&o.shape[1]===8,()=>"Error in transform: Input transform should be batch x 8 or 1 x 8"),$(s==null||s.length===2,()=>`Error in transform: outputShape must be [height, width] or null, but got ${s}.`);let l={image:i,transforms:o},d={interpolation:n,fillMode:a,fillValue:r,outputShape:s};return W.runKernel(Hl,l,d)}var OD=B({transform_:$D});function _D(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 a=M(e,"a","bandPart");$(a.rank>=2,()=>`bandPart(): Rank must be at least 2, got ${a.rank}.`);let r=a.shape,[s,i]=a.shape.slice(-2);if(!(t<=s))throw new Error(`bandPart(): numLower (${t}) must not be greater than the number of rows (${s}).`);if(!(n<=i))throw new Error(`bandPart(): numUpper (${n}) must not be greater than the number of columns (${i}).`);t<0&&(t=s),n<0&&(n=i);let o=V(hu(0,s,1,"int32"),[-1,1]),l=hu(0,i,1,"int32"),d=ge(o,l),u=La(bs(d,Ce(+t,"int32")),xs(d,Ce(-n,"int32"))),p=Gt([s,i],a.dtype);return V(xn(Mn(V(a,[-1,s,i])).map(c=>Sn(u,c,p))),r)}var PD=B({bandPart_:_D});function zD(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 s=1;s<e.length;++s)$(e[s].shape[0]===r,()=>`Gram-Schmidt: Non-unique lengths found in the input vectors: (${e[s].shape[0]} vs. ${r})`)}else t=!0,e=cn(e,e.shape[0],0).map(r=>st(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=[],a=e;for(let r=0;r<e.length;++r)n.push(W.tidy(()=>{let s=a[r];if(r>0)for(let i=0;i<r;++i){let o=L(Ie(L(n[i],s)),n[i]);s=ge(s,o)}return he(s,o0(s,"euclidean"))}));return t?xn(n,0):n}var LD=B({gramSchmidt_:zD});function WD(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 X3(e,t);{let n=e.shape.slice(0,e.shape.length-2).reduce((l,d)=>l*d),a=Mn(V(e,[n,e.shape[e.shape.length-2],e.shape[e.shape.length-1]]),0),r=[],s=[];a.forEach(l=>{let[d,u]=X3(l,t);r.push(d),s.push(u)});let i=V(xn(r,0),e.shape),o=V(xn(s,0),e.shape);return[i,o]}}function X3(e,t=!1){return W.tidy(()=>{$(e.shape.length===2,()=>`qr2d() requires a 2D Tensor, but got a ${e.shape.length}D Tensor.`);let n=e.shape[0],a=e.shape[1],r=Pg(n),s=Za(e),i=Qa([[1]],[1,1]),o=Za(i),l=n>=a?a:n;for(let d=0;d<l;++d){let u=s,p=o,c=r;[o,s,r]=W.tidy(()=>{let h=De(s,[d,d],[n-d,1]),f=o0(h),m=De(s,[d,d],[1,1]),g=Sn(Yn(m,0),Qa([[-1]]),Qa([[1]])),y=ge(m,L(g,f)),A=he(h,y);A.shape[0]===1?o=Za(i):o=mt([i,De(A,[1,0],[A.shape[0]-1,A.shape[1]])],0);let x=Tt(he(Ve(g,y),f)),b=De(s,[d,0],[n-d,a]),v=L(x,o),k=Ze(o);if(d===0)s=ge(b,Ve(v,Ve(k,b)));else{let D=ge(b,Ve(v,Ve(k,b)));s=mt([De(s,[0,0],[d,a]),D],0)}let T=Ze(v),C=De(r,[0,d],[n,r.shape[1]-d]);if(d===0)r=ge(C,Ve(Ve(C,o),T));else{let D=ge(C,Ve(Ve(C,o),T));r=mt([De(r,[0,0],[n,d]),D],1)}return[o,s,r]}),Q([u,p,c])}return!t&&n>a&&(r=De(r,[0,0],[n,a]),s=De(s,[0,0],[a,a])),[r,s]})}var BD=B({qr_:WD}),Fn;(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"})(Fn||(Fn={}));function VD(e,t,n=Fn.SUM_BY_NONZERO_WEIGHTS){let a=M(e,"losses","computeWeightedLoss"),r=null;t!=null&&(r=M(t,"weights","computeWeightedLoss"));let s=r==null?a:L(a,r);if(n===Fn.NONE)return s;if(n===Fn.SUM)return Ie(s);if(n===Fn.MEAN){if(r==null)return Dt(s);{let i=a.size/r.size,o=he(Ie(s),Ie(r));return i>1?he(o,Ce(i)):o}}if(n===Fn.SUM_BY_NONZERO_WEIGHTS){if(r==null)return he(Ie(s),Ce(a.size));{let i=L(r,ua(a.shape)),o=pe(Ie(oo(i,Ce(0))),"float32");return he(Ie(s),o)}}throw Error(`Unknown reduction: ${n}`)}var zr=B({computeWeightedLoss_:VD});function UD(e,t,n,a=Fn.SUM_BY_NONZERO_WEIGHTS){let r=M(e,"labels","absoluteDifference"),s=M(t,"predictions","absoluteDifference"),i=null;n!=null&&(i=M(n,"weights","absoluteDifference")),Tn(r.shape,s.shape,"Error in absoluteDifference: ");let o=jt(ge(r,s));return zr(o,i,a)}var jD=B({absoluteDifference_:UD});function GD(e,t,n,a,r=Fn.SUM_BY_NONZERO_WEIGHTS){let s=M(e,"labels","cosineDistance"),i=M(t,"predictions","cosineDistance"),o=null;a!=null&&(o=M(a,"weights","cosineDistance")),Tn(s.shape,i.shape,"Error in cosineDistance: ");let l=Ce(1),d=ge(l,Ie(L(s,i),n,!0));return zr(d,o,r)}var HD=B({cosineDistance_:GD});function qD(e,t,n,a=Fn.SUM_BY_NONZERO_WEIGHTS){let r=M(e,"labels","hingeLoss"),s=M(t,"predictions","hingeLoss"),i=null;n!=null&&(i=M(n,"weights","hingeLoss")),Tn(r.shape,s.shape,"Error in hingeLoss: ");let o=Ce(1);r=ge(L(Ce(2),r),o);let l=Ja(ge(o,L(r,s)));return zr(l,i,a)}var XD=B({hingeLoss_:qD});function KD(e,t,n,a=1,r=Fn.SUM_BY_NONZERO_WEIGHTS){let s=M(e,"labels","huberLoss"),i=M(t,"predictions","huberLoss"),o=null;n!=null&&(o=M(n,"weights","huberLoss")),Tn(s.shape,i.shape,"Error in huberLoss: ");let l=Ce(a),d=jt(ge(i,s)),u=pu(d,l),p=ge(d,u),c=le(L(Ce(.5),ht(u)),L(l,p));return zr(c,o,r)}var ZD=B({huberLoss_:KD});function YD(e,t,n,a=1e-7,r=Fn.SUM_BY_NONZERO_WEIGHTS){let s=M(e,"labels","logLoss"),i=M(t,"predictions","logLoss"),o=null;n!=null&&(o=M(n,"weights","logLoss")),Tn(s.shape,i.shape,"Error in logLoss: ");let l=Ce(1),d=Ce(a),u=Tt(L(s,la(le(i,d)))),p=L(ge(l,s),la(le(ge(l,i),d))),c=ge(u,p);return zr(c,o,r)}var JD=B({logLoss_:YD});function QD(e,t,n,a=Fn.SUM_BY_NONZERO_WEIGHTS){let r=M(e,"labels","meanSquaredError"),s=M(t,"predictions","meanSquaredError"),i=null;n!=null&&(i=M(n,"weights","meanSquaredError")),Tn(r.shape,s.shape,"Error in meanSquaredError: ");let o=r0(r,s);return zr(o,i,a)}var e$=B({meanSquaredError_:QD});function t$(e,t){let n=M(e,"labels","sigmoidCrossEntropyWithLogits"),a=M(t,"logits","sigmoidCrossEntropyWithLogits");Tn(n.shape,a.shape,"Error in sigmoidCrossEntropyWithLogits: ");let r=Ja(a),s=L(a,n),i=Zd(oa(Tt(jt(a))));return le(ge(r,s),i)}function n$(e,t,n,a=0,r=Fn.SUM_BY_NONZERO_WEIGHTS){let s=M(e,"multiClassLabels","sigmoidCrossEntropy"),i=M(t,"logits","sigmoidCrossEntropy"),o=null;if(n!=null&&(o=M(n,"weights","sigmoidCrossEntropy")),Tn(s.shape,i.shape,"Error in sigmoidCrossEntropy: "),a>0){let d=Ce(a),u=Ce(1),p=Ce(.5);s=le(L(s,ge(u,d)),L(p,d))}let l=t$(s,i);return zr(l,o,r)}var a$=B({sigmoidCrossEntropy_:n$});function r$(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((a,r,s)=>{let i=Vg(r,[n],!0),o=ge(pe(r,"float32"),i);s([a,o]);let l=Tt(L(o,a));return{value:Ie(l,[n]),gradFunc:(d,u)=>{let[p,c]=u,h=io(d.shape,[n]);return[L(V(d,h),ge(pe(p,"float32"),oa(c))),L(V(d,h),ge(oa(c),pe(p,"float32")))]}}})(e,t)}function s$(e,t,n,a=0,r=Fn.SUM_BY_NONZERO_WEIGHTS){let s=M(e,"onehotLabels","softmaxCrossEntropy"),i=M(t,"logits","softmaxCrossEntropy"),o=null;if(n!=null&&(o=M(n,"weights","softmaxCrossEntropy")),Tn(s.shape,i.shape,"Error in softmaxCrossEntropy: "),a>0){let d=Ce(a),u=Ce(1),p=Ce(s.shape[1]);s=le(L(s,ge(u,d)),he(d,p))}let l=r$(s,i);return zr(l,o,r)}var i$=B({softmaxCrossEntropy_:s$});function o$(e,t,n,a){let r=M(e,"indices","sparseFillEmptyRows"),s=M(t,"values","sparseFillEmptyRows"),i=M(n,"denseShape","sparseFillEmptyRows"),o=M(a,"defaultValue","sparseFillEmptyRows",s.dtype);if(r.rank!==2)throw new Error(`Indices should be Tensor2D but received shape
|
|
${r.shape}`);if(s.rank!==1)throw new Error(`Values should be Tensor1D but received shape ${s.shape}`);if(i.rank!==1)throw new Error(`Dense shape should be Tensor1D but received shape ${i.shape}`);if(o.rank!==0)throw new Error(`Default value should be a scalar but received shape ${o.shape}`);let l={indices:r,values:s,denseShape:i,defaultValue:o},d=W.runKernel(fh,l);return{outputIndices:d[0],outputValues:d[1],emptyRowIndicator:d[2],reverseIndexMap:d[3]}}var l$=B({sparseFillEmptyRows_:o$});function u$(e,t,n){let a=M(e,"inputIndices","sparseReshape"),r=M(t,"inputShape","sparseReshape"),s=M(n,"newShape","sparseReshape");if(a.rank!==2)throw new Error(`Input indices should be Tensor2D but received shape
|
|
${a.shape}`);if(r.rank!==1)throw new Error(`Input shape should be Tensor1D but received shape ${r.shape}`);if(s.rank!==1)throw new Error(`New shape should be Tensor1D but received shape ${s.shape}`);let i={inputIndices:a,inputShape:r,newShape:s},o=W.runKernel(mh,i);return{outputIndices:o[0],outputShape:o[1]}}var d$=B({sparseReshape_:u$});function p$(e,t,n){let a=M(e,"data","sparseSegmentMean"),r=M(t,"indices","sparseSegmentMean"),s=M(n,"segmentIds","sparseSegmentMean");if(a.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(s.rank!==1)throw new Error(`Segment ids should be Tensor1D but received shape
|
|
${s.shape}`);let i={data:a,indices:r,segmentIds:s};return W.runKernel(gh,i)}var c$=B({sparseSegmentMean_:p$});function h$(e,t,n){let a=M(e,"data","sparseSegmentSum"),r=M(t,"indices","sparseSegmentSum"),s=M(n,"segmentIds","sparseSegmentSum");if(a.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(s.rank!==1)throw new Error(`Segment ids should be Tensor1D but received shape
|
|
${s.shape}`);let i={data:a,indices:r,segmentIds:s};return W.runKernel(yh,i)}var f$=B({sparseSegmentSum_:h$});function m$(e,t,n,a,r,s,i,o){let l=M(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 d=M(t,"dataSplits","stringNGrams");if(d.dtype!=="int32")throw new Error("Data splits must be of datatype int32");let u={separator:n,nGramWidths:a,leftPad:r,rightPad:s,padWidth:i,preserveShortSequences:o},p={data:l,dataSplits:d},c=W.runKernel(xh,p,u);return{nGrams:c[0],nGramsSplits:c[1]}}var g$=B({stringNGrams_:m$});function y$(e,t,n=!0){let a=M(e,"input","stringSplit","string"),r=M(t,"delimiter","stringSplit","string");if(a.rank!==1)throw new Error(`Input should be Tensor1D but received shape ${a.shape}`);if(r.rank!==0)throw new Error(`Delimiter should be a scalar but received shape ${r.shape}`);let s={skipEmpty:n},i={input:a,delimiter:r},o=W.runKernel(bh,i,s);return{indices:o[0],values:o[1],shape:o[2]}}var A$=B({stringSplit_:y$});function x$(e,t){let n=M(e,"input","stringToHashBucketFast","string"),a={numBuckets:t};if(t<=0)throw new Error("Number of buckets must be at least 1");let r={input:n};return W.runKernel(vh,r,a)}var b$=B({stringToHashBucketFast_:x$}),v$={fft:rp,ifft:mu,rfft:sp,irfft:a0},w$={hammingWindow:JF,hannWindow:W3,frame:B3,stft:nD},Me={flipLeftRight:iD,grayscaleToRGB:lD,resizeNearestNeighbor:q3,resizeBilinear:H3,rotateWithOffset:dD,cropAndResize:rD,nonMaxSuppression:cD,nonMaxSuppressionAsync:bD,nonMaxSuppressionWithScore:wD,nonMaxSuppressionWithScoreAsync:ID,nonMaxSuppressionPadded:ND,nonMaxSuppressionPaddedAsync:CD,threshold:DD,transform:OD},K3={bandPart:PD,gramSchmidt:LD,qr:BD},k$={absoluteDifference:jD,computeWeightedLoss:zr,cosineDistance:HD,hingeLoss:XD,huberLoss:ZD,logLoss:JD,meanSquaredError:e$,sigmoidCrossEntropy:a$,softmaxCrossEntropy:i$},ip={sparseFillEmptyRows:l$,sparseReshape:d$,sparseSegmentMean:c$,sparseSegmentSum:f$},c0={stringNGrams:g$,stringSplit:A$,stringToHashBucketFast:b$},Lr=class extends Zb{minimize(e,t=!1,n){let{value:a,grads:r}=this.computeGradients(e,n);if(n!=null){let s=n.map(i=>({name:i.name,tensor:r[i.name]}));this.applyGradients(s)}else this.applyGradients(r);return Q(r),t?a:(a.dispose(),null)}get iterations(){return this.iterations_==null&&(this.iterations_=0),this.iterations_}incrementIterations(){this.iterations_=this.iterations+1}computeGradients(e,t){return b3(e,t)}dispose(){this.iterations_!=null&&Q(this.iterations_)}async saveIterations(){return this.iterations_==null&&(this.iterations_=0),{name:"iter",tensor:Ce(this.iterations_,"int32")}}async getWeights(){throw new Error("getWeights() is not implemented for this optimizer yet.")}async setWeights(e){throw new Error(`setWeights() is not implemented for this optimizer class ${this.getClassName()}`)}async extractIterations(e){return this.iterations_=(await e[0].tensor.data())[0],e.slice(1)}};Object.defineProperty(Lr,Symbol.hasInstance,{value:e=>e.minimize!=null&&e.computeGradients!=null&&e.applyGradients!=null});var h0=class extends Lr{constructor(e,t,n=null){super();this.learningRate=e,this.rho=t,this.epsilon=n,this.accumulatedGrads=[],this.accumulatedUpdates=[],n==null&&(this.epsilon=W.backend.epsilon())}applyGradients(e){(Array.isArray(e)?e.map(t=>t.name):Object.keys(e)).forEach((t,n)=>{let a=W.registeredVariables[t],r=!1;this.accumulatedGrads[n]==null&&(this.accumulatedGrads[n]={originalName:`${t}/accum_grad`,variable:G(()=>Ye(a).variable(r))}),this.accumulatedUpdates[n]==null&&(this.accumulatedUpdates[n]={originalName:`${t}/accum_var`,variable:G(()=>Ye(a).variable(r))});let s=Array.isArray(e)?e[n].tensor:e[t];if(s==null)return;let i=this.accumulatedGrads[n].variable,o=this.accumulatedUpdates[n].variable;G(()=>{let l=le(L(i,this.rho),L(ht(s),1-this.rho)),d=L(he(An(le(o,this.epsilon)),An(le(i,this.epsilon))),s),u=le(L(o,this.rho),L(ht(d),1-this.rho));i.assign(l),o.assign(u);let p=le(L(d,-this.learningRate),a);a.assign(p)})}),this.incrementIterations()}dispose(){this.accumulatedUpdates!=null&&(Q(this.accumulatedGrads.map(e=>e.variable)),Q(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(a=>({originalName:a.name,variable:a.tensor.variable(n)})),this.accumulatedUpdates=e.slice(t,t*2).map(a=>({originalName:a.name,variable:a.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)}};h0.className="Adadelta";ys(h0);var f0=class extends Lr{constructor(e,t=.1){super();this.learningRate=e,this.initialAccumulatorValue=t,this.accumulatedGrads=[]}applyGradients(e){(Array.isArray(e)?e.map(t=>t.name):Object.keys(e)).forEach((t,n)=>{let a=W.registeredVariables[t];if(this.accumulatedGrads[n]==null){let i=!1;this.accumulatedGrads[n]={originalName:`${t}/accumulator`,variable:G(()=>uu(a.shape,this.initialAccumulatorValue).variable(i))}}let r=Array.isArray(e)?e[n].tensor:e[t];if(r==null)return;let s=this.accumulatedGrads[n].variable;G(()=>{let i=le(s,ht(r));s.assign(i);let o=le(L(he(r,An(le(i,W.backend.epsilon()))),-this.learningRate),a);a.assign(o)})}),this.incrementIterations()}dispose(){this.accumulatedGrads!=null&&Q(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)}};f0.className="Adagrad";ys(f0);var m0=class extends Lr{constructor(e,t,n,a=null){super();this.learningRate=e,this.beta1=t,this.beta2=n,this.epsilon=a,this.accumulatedFirstMoment=[],this.accumulatedSecondMoment=[],G(()=>{this.accBeta1=Ce(t).variable(),this.accBeta2=Ce(n).variable()}),a==null&&(this.epsilon=W.backend.epsilon())}applyGradients(e){let t=Array.isArray(e)?e.map(n=>n.name):Object.keys(e);G(()=>{let n=ge(1,this.accBeta1),a=ge(1,this.accBeta2);t.forEach((r,s)=>{let i=W.registeredVariables[r],o=!1;this.accumulatedFirstMoment[s]==null&&(this.accumulatedFirstMoment[s]={originalName:`${r}/m`,variable:G(()=>Ye(i).variable(o))}),this.accumulatedSecondMoment[s]==null&&(this.accumulatedSecondMoment[s]={originalName:`${r}/v`,variable:G(()=>Ye(i).variable(o))});let l=Array.isArray(e)?e[s].tensor:e[r];if(l==null)return;let d=this.accumulatedFirstMoment[s].variable,u=this.accumulatedSecondMoment[s].variable,p=le(L(d,this.beta1),L(l,1-this.beta1)),c=le(L(u,this.beta2),L(ht(l),1-this.beta2)),h=he(p,n),f=he(c,a);d.assign(p),u.assign(c);let m=le(L(he(h,le(An(f),this.epsilon)),-this.learningRate),i);i.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&&Q(this.accumulatedFirstMoment.map(e=>e.variable)),this.accumulatedSecondMoment!=null&&Q(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(Pr(this.beta1,this.iterations_+1)),this.accBeta2.assign(Pr(this.beta2,this.iterations_+1))});let t=e.length/2,n=!1;this.accumulatedFirstMoment=e.slice(0,t).map(a=>({originalName:a.name,variable:a.tensor.variable(n)})),this.accumulatedSecondMoment=e.slice(t,t*2).map(a=>({originalName:a.name,variable:a.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)}};m0.className="Adam";ys(m0);var g0=class extends Lr{constructor(e,t,n,a=null,r=0){super();this.learningRate=e,this.beta1=t,this.beta2=n,this.epsilon=a,this.decay=r,this.accumulatedFirstMoment=[],this.accumulatedWeightedInfNorm=[],G(()=>{this.iteration=Ce(0).variable(),this.accBeta1=Ce(t).variable()}),a==null&&(this.epsilon=W.backend.epsilon())}applyGradients(e){let t=Array.isArray(e)?e.map(n=>n.name):Object.keys(e);G(()=>{let n=ge(1,this.accBeta1),a=he(-this.learningRate,le(L(this.iteration,this.decay),1));t.forEach((r,s)=>{let i=W.registeredVariables[r],o=!1;this.accumulatedFirstMoment[s]==null&&(this.accumulatedFirstMoment[s]={originalName:`${r}/m`,variable:Ye(i).variable(o)}),this.accumulatedWeightedInfNorm[s]==null&&(this.accumulatedWeightedInfNorm[s]={originalName:`${r}/v`,variable:Ye(i).variable(o)});let l=Array.isArray(e)?e[s].tensor:e[r];if(l==null)return;let d=this.accumulatedFirstMoment[s].variable,u=this.accumulatedWeightedInfNorm[s].variable,p=le(L(d,this.beta1),L(l,1-this.beta1)),c=L(u,this.beta2),h=jt(l),f=Ar(c,h);d.assign(p),u.assign(f);let m=le(L(he(a,n),he(p,le(f,this.epsilon))),i);i.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&&Q(this.accumulatedFirstMoment.map(e=>e.variable)),this.accumulatedWeightedInfNorm!=null&&Q(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)}};g0.className="Adamax";ys(g0);var op=class extends Lr{constructor(e){super();this.learningRate=e,this.setLearningRate(e)}applyGradients(e){(Array.isArray(e)?e.map(t=>t.name):Object.keys(e)).forEach((t,n)=>{let a=Array.isArray(e)?e[n].tensor:e[t];if(a==null)return;let r=W.registeredVariables[t];G(()=>{let s=le(L(this.c,a),r);r.assign(s)})}),this.incrementIterations()}setLearningRate(e){this.learningRate=e,this.c!=null&&this.c.dispose(),this.c=pn(Ce(-e))}dispose(){this.c.dispose()}async getWeights(){return[await this.saveIterations()]}async setWeights(e){if(e=await this.extractIterations(e),e.length!==0)throw new Error("SGD optimizer does not have settable weights.")}getConfig(){return{learningRate:this.learningRate}}static fromConfig(e,t){return new e(t.learningRate)}};op.className="SGD";ys(op);var y0=class extends op{constructor(e,t,n=!1){super(e);this.learningRate=e,this.momentum=t,this.useNesterov=n,this.accumulations=[],this.m=Ce(this.momentum)}applyGradients(e){(Array.isArray(e)?e.map(t=>t.name):Object.keys(e)).forEach((t,n)=>{let a=W.registeredVariables[t];if(this.accumulations[n]==null){let i=!1;this.accumulations[n]={originalName:`${t}/momentum`,variable:G(()=>Ye(a).variable(i))}}let r=this.accumulations[n].variable,s=Array.isArray(e)?e[n].tensor:e[t];s!=null&&G(()=>{let i,o=le(L(this.m,r),s);this.useNesterov?i=le(L(this.c,le(s,L(o,this.m))),a):i=le(L(this.c,o),a),r.assign(o),a.assign(i)})}),this.incrementIterations()}dispose(){this.m.dispose(),this.accumulations!=null&&Q(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)}};y0.className="Momentum";ys(y0);var A0=class extends Lr{constructor(e,t=.9,n=0,a=null,r=!1){super();if(this.learningRate=e,this.decay=t,this.momentum=n,this.epsilon=a,this.accumulatedMeanSquares=[],this.accumulatedMoments=[],this.accumulatedMeanGrads=[],this.centered=r,a==null&&(this.epsilon=W.backend.epsilon()),e==null)throw new Error("learningRate for RMSPropOptimizer must be defined.")}applyGradients(e){(Array.isArray(e)?e.map(t=>t.name):Object.keys(e)).forEach((t,n)=>{let a=W.registeredVariables[t],r=!1;this.accumulatedMeanSquares[n]==null&&(this.accumulatedMeanSquares[n]={originalName:`${t}/rms`,variable:G(()=>Ye(a).variable(r))}),this.accumulatedMoments[n]==null&&(this.accumulatedMoments[n]={originalName:`${t}/momentum`,variable:G(()=>Ye(a).variable(r))}),this.accumulatedMeanGrads[n]==null&&this.centered&&(this.accumulatedMeanGrads[n]={originalName:`${t}/mg`,variable:G(()=>Ye(a).variable(r))});let s=Array.isArray(e)?e[n].tensor:e[t];if(s==null)return;let i=this.accumulatedMeanSquares[n].variable,o=this.accumulatedMoments[n].variable;G(()=>{let l=le(L(i,this.decay),L(ht(s),1-this.decay));if(this.centered){let d=this.accumulatedMeanGrads[n].variable,u=le(L(d,this.decay),L(s,1-this.decay)),p=he(L(s,this.learningRate),An(ge(l,le(ht(u),this.epsilon)))),c=le(L(o,this.momentum),p);i.assign(l),d.assign(u),o.assign(c);let h=ge(a,c);a.assign(h)}else{let d=le(L(i,this.decay),L(ht(s),1-this.decay)),u=le(L(o,this.momentum),he(L(s,this.learningRate),An(le(d,this.epsilon))));i.assign(d),o.assign(u);let p=ge(a,u);a.assign(p)}})}),this.incrementIterations()}dispose(){this.accumulatedMeanSquares!=null&&Q(this.accumulatedMeanSquares.map(e=>e.variable)),this.accumulatedMeanGrads!=null&&this.centered&&Q(this.accumulatedMeanGrads.map(e=>e.variable)),this.accumulatedMoments!=null&&Q(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(a=>({originalName:a.name,variable:a.tensor.variable(n)})),this.accumulatedMoments=e.slice(t,t*2).map(a=>({originalName:a.name,variable:a.tensor.variable(n)})),this.centered&&(this.accumulatedMeanGrads=e.slice(t*2,t*3).map(a=>({originalName:a.name,variable:a.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)}};A0.className="RMSProp";ys(A0);var uo=class{static sgd(e){return new op(e)}static momentum(e,t,n=!1){return new y0(e,t,n)}static rmsprop(e,t=.9,n=0,a=null,r=!1){return new A0(e,t,n,a,r)}static adam(e=.001,t=.9,n=.999,a=null){return new m0(e,t,n,a)}static adadelta(e=.001,t=.95,n=null){return new h0(e,t,n)}static adamax(e=.002,t=.9,n=.999,a=null,r=0){return new g0(e,t,n,a,r)}static adagrad(e,t=.1){return new f0(e,t)}},po={sgd:uo.sgd,momentum:uo.momentum,adadelta:uo.adadelta,adagrad:uo.adagrad,rmsprop:uo.rmsprop,adamax:uo.adamax,adam:uo.adam},I$=(()=>typeof requestAnimationFrame!="undefined"?requestAnimationFrame:typeof setImmediate!="undefined"?setImmediate:e=>e())();function Z3(){return new Promise(e=>I$(()=>e()))}var E={};ze(E,{ERF_A1:()=>O$,ERF_A2:()=>_$,ERF_A3:()=>P$,ERF_A4:()=>z$,ERF_A5:()=>L$,ERF_P:()=>$$,PARALLELIZE_THRESHOLD:()=>oy,SELU_SCALE:()=>J3,SELU_SCALEALPHA:()=>Y3,applyActivation:()=>d0,assertAndGetBroadcastShape:()=>bt,assertAxesAreInnerMostDims:()=>WR,assertParamsConsistent:()=>S$,assignToTypedArray:()=>G$,axesAreInnerMostDims:()=>Wg,calculateShapes:()=>zb,checkEinsumDimSizes:()=>Y$,combineLocations:()=>w3,complexWithEvenIndex:()=>V$,complexWithOddIndex:()=>U$,computeConv2DInfo:()=>Gd,computeConv3DInfo:()=>a3,computeDefaultPad:()=>Sg,computeDilation2DInfo:()=>uE,computeOptimalWindowSize:()=>T$,computeOutAndReduceShapes:()=>k3,computeOutShape:()=>N$,computePool2DInfo:()=>n3,computePool3DInfo:()=>dE,convertConv2DDataFormat:()=>r3,decodeEinsumEquation:()=>K$,eitherStridesOrDilationsAreOne:()=>gr,expandShapeToKeepDim:()=>io,exponent:()=>q$,exponents:()=>H$,fromStringArrayToUint8:()=>iO,fromUint8ToStringArray:()=>sO,getAxesPermutation:()=>I3,getBroadcastDims:()=>tR,getComplexWithIndex:()=>j$,getEinsumComputePath:()=>J$,getEinsumPermutation:()=>Z$,getFusedBiasGradient:()=>u0,getFusedDyActivation:()=>l0,getImageCenter:()=>C$,getInnerMostAxes:()=>BR,getPermuted:()=>R$,getReductionAxes:()=>Qt,getReshaped:()=>E$,getReshapedPermuted:()=>M$,getSliceBeginCoords:()=>F$,getSliceSize:()=>D$,getUndoAxesPermutation:()=>Bg,isIdentityPermutation:()=>Q$,log:()=>PN,mergeRealAndImagArrays:()=>W$,prepareAndValidate:()=>Pb,prepareSplitSize:()=>tO,segment_util:()=>tv,shouldFuse:()=>p0,slice_util:()=>En,splitRealAndImagArrays:()=>B$,tupleValuesAreOne:()=>As,upcastType:()=>Pa,validateInput:()=>pg,validateUpdateShape:()=>dg,warn:()=>pr});function S$(e,t){let n=e[0].length;e.forEach((r,s)=>{$(r.length===n,()=>`Error in concat${n}D: rank of tensors[${s}] 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 a=e[0];e.forEach((r,s)=>{for(let i=0;i<n;i++)$(i===t||r[i]===a[i],()=>`Error in concat${n}D: Shape of tensors[${s}] (${r}) does not match the shape of the rest (${a}) along the non-concatenated axis ${s}.`)})}function N$(e,t){let n=e[0].slice();for(let a=1;a<e.length;a++)n[t]+=e[a][t];return n}var oy=30;function T$(e){return e<=oy?e:zc(e,Math.floor(Math.sqrt(e)))}function C$(e,t,n){let a=n*(typeof e=="number"?e:e[0]),r=t*(typeof e=="number"?e:e[1]);return[a,r]}function E$(e,t,n,a=!0){let r=[];if(a)r=r.concat(t.slice(0)),r.push(e[0]/n),r=r.concat(e.slice(1));else{r=r.concat(e[0]);let s=t.length;for(let i=0;i<s;++i)r=r.concat([e[i+1]/t[i],t[i]]);r=r.concat(e.slice(s+1))}return r}function R$(e,t,n=!0){let a=[];if(n){a.push(t);for(let r=t+1;r<e;++r)r<=2*t?(a.push(r),a.push(r-(t+1))):a.push(r)}else{let r=[],s=[];for(let i=1;i<e;++i)i>=t*2+1||i%2==1?s.push(i):r.push(i);a.push(...r),a.push(0),a.push(...s)}return a}function M$(e,t,n,a=!0){let r=[];a?r.push(e[0]/n):r.push(e[0]*n);for(let s=1;s<e.length;++s)s<=t.length?a?r.push(t[s-1]*e[s]):r.push(e[s]/t[s-1]):r.push(e[s]);return r}function F$(e,t){let n=[0];for(let a=0;a<t;++a)n.push(e[a][0]);return n}function D$(e,t,n){let a=e.slice(0,1);for(let r=0;r<n;++r)a.push(e[r+1]-t[r][0]-t[r][1]);return a}var Y3=1.7580993408473768,J3=1.0507009873554805,$$=.3275911,O$=.254829592,_$=-.284496736,P$=1.421413741,z$=-1.453152027,L$=1.061405429;function W$(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 a=0;a<n.length;a+=2)n[a]=e[a/2],n[a+1]=t[a/2];return n}function B$(e){let t=new Float32Array(e.length/2),n=new Float32Array(e.length/2);for(let a=0;a<e.length;a+=2)t[a/2]=e[a],n[a/2]=e[a+1];return{real:t,imag:n}}function V$(e){let t=Math.ceil(e.length/4),n=new Float32Array(t),a=new Float32Array(t);for(let r=0;r<e.length;r+=4)n[Math.floor(r/4)]=e[r],a[Math.floor(r/4)]=e[r+1];return{real:n,imag:a}}function U$(e){let t=Math.floor(e.length/4),n=new Float32Array(t),a=new Float32Array(t);for(let r=2;r<e.length;r+=4)n[Math.floor(r/4)]=e[r],a[Math.floor(r/4)]=e[r+1];return{real:n,imag:a}}function j$(e,t){let n=e[t*2],a=e[t*2+1];return{real:n,imag:a}}function G$(e,t,n,a){e[a*2]=t,e[a*2+1]=n}function H$(e,t){let n=new Float32Array(e/2),a=new Float32Array(e/2);for(let r=0;r<Math.ceil(e/2);r++){let s=(t?2:-2)*Math.PI*(r/e);n[r]=Math.cos(s),a[r]=Math.sin(s)}return{real:n,imag:a}}function q$(e,t,n){let a=(n?2:-2)*Math.PI*(e/t),r=Math.cos(a),s=Math.sin(a);return{real:r,imag:s}}var ly="->",X$=/->/g,Q3=",",ev="...";function K$(e,t){e=e.replace(/\s/g,"");let n=(e.length-e.replace(X$,"").length)/ly.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 ("${ly}").`);let[a,r]=e.split(ly);$(a.indexOf(ev)===-1,()=>`The ellipsis notation ("${ev}") is not supported yet.`);let s=a.split(Q3),i=s.length;if(t!==i)throw new Error(`Expected ${i} input tensors, received ${t}`);if(i>2)throw new Error("Support for more than 2 input tensors is not implemented yet.");let o=[];for(let c=0;c<r.length;++c){let h=r[c];if(!s.some(f=>f.indexOf(h)!==-1))throw new Error(`Output subscripts contain the label ${h} not present in the input subscripts.`);o.indexOf(h)===-1&&o.push(h)}for(let c=0;c<a.length;++c){let h=a[c];o.indexOf(h)===-1&&h!==Q3&&o.push(h)}let l=new Array(s.length);for(let c=0;c<i;++c){if(new Set(s[c].split("")).size!==s[c].length)throw new Error(`Found duplicate axes in input component ${s[c]}. Support for duplicate axes in input is not implemented yet.`);l[c]=[];for(let h=0;h<s[c].length;++h)l[c].push(o.indexOf(s[c][h]))}let d=o.length,u=r.length,p=[];for(let c=u;c<d;++c)p.push(c);return{allDims:o,summedDims:p,idDims:l}}function Z$(e,t){let n=new Array(e);n.fill(-1);for(let r=0;r<t.length;++r)n[t[r]]=r;let a=[];for(let r=0;r<e;++r)n[r]===-1&&a.push(r);return n=n.filter(r=>r!==-1),{permutationIndices:n,expandDims:a}}function Y$(e,t,n){let a=new Array(e);for(let r=0;r<n.length;++r){let s=n[r].shape;for(let i=0;i<t[r].length;++i)a[t[r][i]]===void 0?a[t[r][i]]=s[i]:$(a[t[r][i]]===s[i],()=>`Expected dimension ${a[t[r][i]]} at axis ${i} of input shaped ${JSON.stringify(s)}, but got dimension ${s[i]}`)}}function J$(e,t){let n=e,a=[],r=0;e.length===0&&n.push(-1),r=e.length+1;for(let i=0;i<r;++i)a.push([]);let s=[];for(let i=0;i<n.length;++i){let o=n[i],l=eO(t,o);for(let d of l)s.indexOf(d)===-1&&(a[i].push(d),s.push(d))}return{path:n,steps:a}}function Q$(e){return e.every((t,n)=>t===n)}function eO(e,t){let n=[];for(let a=0;a<e.length;++a)(e[a].length===0||e[a].indexOf(t)!==-1||t===-1)&&n.push(a);return n}function tO(e,t,n=0){let a=[];if(typeof t=="number")$(e.shape[n]%t==0,()=>"Number of splits must evenly divide the axis."),a=new Array(t).fill(e.shape[n]/t);else{let r=t.reduce((i,o)=>(o===-1&&(i+=1),i),0);$(r<=1,()=>"There should be only one negative value in split array.");let s=t.indexOf(-1);if(s!==-1){let i=t.reduce((o,l)=>l>0?o+l:o);t[s]=e.shape[n]-i}$(e.shape[n]===t.reduce((i,o)=>i+o),()=>"The sum of sizes must match the size of the axis dimension."),a=t}return a}var tv={};ze(tv,{collectGatherOpShapeInfo:()=>rO,computeOutShape:()=>aO,segOpComputeOptimalWindowSize:()=>nO});function nO(e,t){let n=!1,a;for(e<=oy?(a=e,n=!0):a=zc(e,Math.floor(Math.sqrt(e)));!n;)a>t||a===e?n=!0:a=zc(e,a+1);return a}function aO(e,t,n){let a=[],r=e.length;for(let s=0;s<r;s++)s!==t?a.push(e[s]):a.push(n);return a}function rO(e,t,n,a){let r=t.shape.length,s=e.shape.length;if(a!==0&&(a<-r||a>r))throw new Error(`Expect batchDims in the range of [-${r}, ${r}], but got ${a}`);if(a<0&&(a+=r),a>s)throw new Error(`batchDims (${a}) must be less than rank(x) (
|
|
${s}).`);if(n<a)throw new Error(`batchDims (${a}) must be less than or equal to axis (${n}).`);for(let p=0;p<a;++p)if(e.shape[p]!==t.shape[p])throw new Error(`x.shape[${p}]: ${e.shape[p]} should be equal to indices.shape[${p}]: ${t.shape[p]}.`);let i=e.shape[n],o=[],l=1,d=1,u=1;for(let p=0;p<a;++p)o.push(e.shape[p]),l*=e.shape[p];for(let p=a;p<n;p++)o.push(e.shape[p]),d*=e.shape[p];for(let p=a;p<r;p++)o.push(t.shape[p]);for(let p=n+1;p<s;p++)o.push(e.shape[p]),u*=e.shape[p];return{batchSize:l,sliceSize:u,outerSize:d,dimSize:i,outputShape:o}}function sO(e){try{return e.map(t=>Th(t))}catch(t){throw new Error(`Failed to decode encoded string bytes into utf-8, error: ${t}`)}}function iO(e){return e.map(t=>$d(t))}var xr={};ze(xr,{nonMaxSuppressionV3Impl:()=>V3,nonMaxSuppressionV4Impl:()=>U3,nonMaxSuppressionV5Impl:()=>j3,whereImpl:()=>F3});var nv={kernelName:Ko,inputsToSave:["x"],gradFunc:(e,t)=>{let[n]=t;return{x:()=>L(e,gu(pe(n,"float32"),-1))}}},oO={kernelName:Zo,inputsToSave:["x"],gradFunc:(e,t)=>{let[n]=t;return{x:()=>{let a=ht(pe(n,"float32")),r=An(ge(Ce(1),a));return Tt(he(e,r))}}}},lO={kernelName:Yo,inputsToSave:["x"],gradFunc:(e,t)=>{let[n]=t;return{x:()=>{let a=An(ge(ht(pe(n,"float32")),1));return he(e,a)}}}},uO={kernelName:ls,inputsToSave:["a","b"],gradFunc:(e,t)=>{let[n,a]=t,r=bt(n.shape,a.shape);return{a:()=>{let s=e,i=Qt(n.shape,r);return i.length>0&&(s=Ie(s,i)),V(s,n.shape)},b:()=>{let s=e,i=Qt(a.shape,r);return i.length>0&&(s=Ie(s,i)),V(s,a.shape)}}}},dO={kernelName:Zs,saveAllInputs:!0,gradFunc:(e,t)=>{let n={};return t.forEach((a,r)=>{n[r]=()=>e.clone()}),n}},pO={kernelName:Ys,inputsToSave:["x"],gradFunc:(e,t)=>{let[n]=t;return{x:()=>Ye(n)}}},cO={kernelName:yd,inputsToSave:["x"],gradFunc:(e,t)=>{let[n]=t;return{x:()=>Ye(n)}}},hO={kernelName:el,inputsToSave:["x"],gradFunc:(e,t)=>{let[n]=t;return{x:()=>he(e,An(ge(Ce(1),ht(pe(n,"float32")))))}}},fO={kernelName:tl,inputsToSave:["x"],gradFunc:(e,t)=>{let[n]=t;return{x:()=>{let a=An(le(Ce(1),ht(pe(n,"float32"))));return he(e,a)}}}},mO={kernelName:rl,inputsToSave:["a","b"],gradFunc:(e,t)=>{let[n,a]=t,r=bt(n.shape,a.shape);return{a:()=>{let s=le(ht(n),ht(a)),i=L(e,he(a,s)),o=Qt(n.shape,r);return o.length>0&&(i=Ie(i,o)),V(i,n.shape)},b:()=>{let s=le(ht(n),ht(a)),i=Tt(L(e,he(n,s))),o=Qt(a.shape,r);return o.length>0&&(i=Ie(i,o)),V(i,a.shape)}}}},gO={kernelName:nl,inputsToSave:["x"],gradFunc:(e,t)=>{let[n]=t;return{x:()=>he(e,le(ht(pe(n,"float32")),1))}}},yO={kernelName:al,inputsToSave:["x"],gradFunc:(e,t)=>{let[n]=t;return{x:()=>he(e,ge(Ce(1),ht(pe(n,"float32"))))}}};function AO(e,t,n,a,r,s){let i=M(e,"dy","avgPool3dGrad"),o=M(t,"input","avgPool3dGrad"),l=i,d=o,u=!1;o.rank===4&&(u=!0,l=V(i,[1,i.shape[0],i.shape[1],i.shape[2],i.shape[3]]),d=V(o,[1,o.shape[0],o.shape[1],o.shape[2],o.shape[3]])),$(l.rank===5,()=>`Error in avgPool3dGrad: dy must be rank 5 but got rank ${l.rank}.`),$(d.rank===5,()=>`Error in avgPool3dGrad: input must be rank 5 but got rank ${d.rank}.`),s!=null&&$(un(r),()=>`Error in avgPool3dGrad: pad must be an integer when using, dimRoundingMode ${s} but got pad ${r}.`);let p={dy:l,input:d},c={filterSize:n,strides:a,pad:r,dimRoundingMode:s},h=W.runKernel(Bc,p,c);return u?V(h,[h.shape[1],h.shape[2],h.shape[3],h.shape[4]]):h}var xO=B({avgPool3dGrad_:AO}),bO={kernelName:Ad,inputsToSave:["x"],gradFunc:(e,t,n)=>{let[a]=t,{filterSize:r,strides:s,pad:i,dimRoundingMode:o}=n;return{x:()=>xO(e,a,r,s,i,o)}}};function vO(e,t,n,a,r){let s=M(e,"dy","avgPoolGrad"),i=M(t,"input","avgPoolGrad");$(i.rank===s.rank,()=>`Rank of input (${i.rank}) does not match rank of dy (${s.rank})`);let o=i,l=s,d=!1;i.rank===3&&(d=!0,o=V(i,[1,i.shape[0],i.shape[1],i.shape[2]]),l=V(s,[1,s.shape[0],s.shape[1],s.shape[2]])),$(l.rank===4,()=>`Error in avgPoolGrad: dy must be rank 4 but got rank ${l.rank}.`),$(o.rank===4,()=>`Error in avgPoolGrad: input must be rank 4 but got rank ${o.rank}.`);let u={dy:l,input:o},p={filterSize:n,strides:a,pad:r},c=W.runKernel(Wc,u,p);return d?V(c,[c.shape[1],c.shape[2],c.shape[3]]):c}var wO=B({avgPoolGrad_:vO}),kO={kernelName:Js,inputsToSave:["x"],gradFunc:(e,t,n)=>{let[a]=t,{filterSize:r,strides:s,pad:i}=n;return{x:()=>wO(e,a,r,s,i)}}},IO={kernelName:Qs,inputsToSave:["a","b"],gradFunc:(e,t,n)=>{let[a,r]=t,{transposeA:s,transposeB:i}=n;return!s&&!i?{a:()=>Ve(e,r,!1,!0),b:()=>Ve(a,e,!0,!1)}:!s&&i?{a:()=>Ve(e,r,!1,!1),b:()=>Ve(e,a,!0,!1)}:s&&!i?{a:()=>Ve(r,e,!1,!0),b:()=>Ve(a,e,!1,!1)}:{a:()=>Ve(r,e,!0,!0),b:()=>Ve(e,a,!0,!0)}}},SO={kernelName:sl,gradFunc:(e,t,n)=>{let{blockShape:a,crops:r}=n;return{x:()=>ep(e,a,r)}}},NO={kernelName:eb,gradFunc:(e,t,n)=>{let a=n,r=a.inputShape,s=a.shape,i=Array.from(s);for(let l=r.length-1;l>=0;l--)if(r[l]===s[l])i[l]=1;else if(r[l]!==1)throw new Error(`broadcastTo(): [${r}] cannot be broadcast to [${s}].`);let o=[];for(let l=0;l<i.length;l++)i[l]>1&&o.push(l);return{x:()=>Ie(e,o,!0)}}},TO={kernelName:ei,gradFunc:e=>({x:()=>e.clone()})},CO={kernelName:ti,gradFunc:e=>({x:()=>Ye(e)})},EO={kernelName:us,inputsToSave:["x"],gradFunc:(e,t,n)=>{let[a]=t,{clipValueMin:r,clipValueMax:s}=n;return{x:()=>Sn(La(xs(a,r),bs(a,s)),e,Ye(e))}}},RO={kernelName:xd,inputsToSave:["x"],gradFunc:nv.gradFunc},MO={kernelName:il,saveAllInputs:!0,gradFunc:(e,t,n)=>{let a=t.map(o=>o.shape),{axis:r}=n,s=_a(r,t[0].shape)[0],i=a.map(o=>o[s]);return cn(e,i,s).map(o=>()=>o)}},FO={kernelName:ni,inputsToSave:["x","filter"],gradFunc:(e,t,n)=>{let[a,r]=t,{dilations:s,strides:i,pad:o,dataFormat:l}=n;return $(As(s),()=>`Error in gradient of conv2D: dilation rates greater than 1 are not yet supported in gradients. Got dilations '${s}'`),{x:()=>Rg(a.shape,e,r,i,o,l),filter:()=>sy(a,e,r.shape,i,o,l)}}},DO={kernelName:ai,inputsToSave:["dy","filter"],gradFunc:(e,t,n)=>{let[a,r]=t,{strides:s,pad:i,dataFormat:o,dimRoundingMode:l}=n;return{dy:()=>_r(e,r,s,i,o,1,l),filter:()=>sy(e,a,r.shape,s,i,o,l)}}};function $O(e,t,n,a,r){let s=e;e.rank===4&&(s=V(e,[1,e.shape[0],e.shape[1],e.shape[2],e.shape[3]]));let i=t;i.rank===4&&(i=V(t,[1,t.shape[0],t.shape[1],t.shape[2],t.shape[3]])),$(s.rank===5,()=>`Error in conv3dDerFilter: input must be rank 5, but got shape ${s.shape}.`),$(i.rank===5,()=>`Error in conv3dDerFilter: dy must be rank 5, but got shape ${i.shape}.`),$(n.length===5,()=>`Error in conv3dDerFilter: filterShape must be length 5, but got ${n}.`),$(s.shape[4]===n[3],()=>`Error in conv3dDerFilter: depth of input ${s.shape[4]}) must match input depth in filter (${n[3]}.`),$(i.shape[4]===n[4],()=>`Error in conv3dDerFilter: depth of dy (${i.shape[4]}) must match output depth for filter (${n[4]}).`);let o={x:s,dy:i},l={strides:a,pad:r,filterShape:n};return W.runKernel(Hc,o,l)}var OO=B({conv3DBackpropFilter_:$O}),_O={kernelName:bd,inputsToSave:["x","filter"],gradFunc:(e,t,n)=>{let{dilations:a,strides:r,pad:s}=n;$(As(a),()=>`Error in gradient of conv3D: dilation rates greater than 1 are not yet supported in gradients. Got dilations '${a}'`);let[i,o]=t;return{x:()=>c3(i.shape,e,o,r,s),filter:()=>OO(i,e,o.shape,r,s)}}},PO={kernelName:ri,inputsToSave:["x"],gradFunc:(e,t)=>{let[n]=t;return{x:()=>L(Tt(e0(pe(n,"float32"))),e)}}},zO={kernelName:si,inputsToSave:["x"],gradFunc:(e,t)=>{let[n]=t;return{x:()=>L(t0(pe(n,"float32")),e)}}},LO={kernelName:ii,inputsToSave:["x"],gradFunc:(e,t,n)=>{let[a]=t,{axis:r,exclusive:s,reverse:i}=n;return{x:()=>{let o=I3([r],a.rank),l=Vh(e,r,s,!i);return o!=null&&(l=Ze(l,o)),l}}}},WO={kernelName:oi,inputsToSave:["x","filter"],gradFunc:(e,t,n)=>{let{dilations:a,strides:r,pad:s,dimRoundingMode:i}=n,o=a==null?[1,1]:a;$(As(o),()=>`Error in gradient of depthwiseConv2dNative: dilation rates greater than 1 are not yet supported. Got dilations '${o}'`);let[l,d]=t;return $(l.rank===4,()=>`Error in gradient of depthwiseConv2dNative: input must be rank 4, but got rank ${l.rank}.`),$(d.rank===4,()=>`Error in gradient of depthwiseConv2dNative: filter must be rank 4, but got rank ${d.rank}.`),$(l.shape[3]===d.shape[2],()=>`Error in gradient of depthwiseConv2d: number of input channels (${l.shape[3]}) must match the inChannels dimension in filter ${d.shape[2]}.`),$(gr(r,o),()=>`Error in gradient of depthwiseConv2d: Either strides or dilations must be 1. Got strides ${r} and dilations '${o}'.`),i!=null&&$(un(s),()=>`Error in depthwiseConv2d: pad must be an integer when using, dimRoundingMode ${i} but got pad ${s}.`),{x:()=>L3(l.shape,e,d,r,s,o,i),filter:()=>z3(l,e,d.shape,r,s,o,i)}}},BO={kernelName:vd,inputsToSave:["x","filter"],gradFunc:(e,t,n)=>{let[a,r]=t,s={x:a,filter:r,dy:e},i={x:a,filter:r,dy:e};return{x:()=>W.runKernel(Jc,s,n),filter:()=>W.runKernel(Qc,i,n)}}},VO={kernelName:ui,outputsToSave:[!0],gradFunc:(e,t)=>{let[n]=t,a={dy:e,y:n};return{x:()=>W.runKernel(th,a)}}},UO={kernelName:ul,inputsToSave:["x"],gradFunc:(e,t)=>{let[n]=t,a=L(oa(Tt(ht(n))),2/Math.sqrt(Math.PI));return{x:()=>L(e,a)}}},jO={kernelName:di,outputsToSave:[!0],gradFunc:(e,t)=>{let[n]=t;return{x:()=>L(e,n)}}},GO={kernelName:pl,inputsToSave:["input"],gradFunc:(e,t)=>{let[n]=t;return{input:()=>V(e,n.shape)}}},HO={kernelName:cl,inputsToSave:["x"],gradFunc:(e,t)=>{let[n]=t;return{x:()=>L(e,oa(n))}}},qO={kernelName:pi,gradFunc:e=>({x:()=>Ye(e)})},XO={kernelName:ci,inputsToSave:["a","b"],gradFunc:(e,t)=>{let[n,a]=t,r=bt(n.shape,a.shape);return{a:()=>{let s=he(e,pe(a,"float32")),i=Qt(n.shape,r);return i.length>0?V(Ie(s,i),n.shape):s},b:()=>{let s=L(e,pe(n,"float32")),i=Qt(a.shape,r);i.length>0&&(s=V(Ie(s,i),a.shape));let o=ht(a);return Tt(he(s,pe(o,"float32")))}}}},KO={kernelName:hi,inputsToSave:["x","mean","variance","scale"],gradFunc:(e,t,n)=>{let{varianceEpsilon:a}=n,[r,s,i,o]=t,l=o==null?Ce(1):o,d=Qt(s.shape,r.shape),u=[];if(s.rank===1){for(let m=0;m<r.shape.length-1;++m)u.push(r.shape[m]);u.push(1)}let p=ge(r,s),c=L(e,l),h=Jh(le(i,Ce(a))),f=L(L(L(h,h),h),Ce(-.5));return{x:()=>s.rank===1?V(L(L(e,Ia(V(h,[1,1,1,s.shape[0]]),u)),l),r.shape):V(L(L(e,h),l),r.shape),mean:()=>{let m=L(L(h,Ce(-1)),c);return s.rank===1&&(m=Ie(m,d)),V(m,s.shape)},variance:()=>{let m=L(L(f,p),c);return s.rank===1&&(m=Ie(m,d)),V(m,s.shape)},scale:()=>{let m=L(p,h),g=L(e,m);return s.rank===1&&(g=Ie(g,d)),V(g,s.shape)},offset:()=>{let m=e;return s.rank===1&&(m=Ie(m,d)),V(m,s.shape)}}}},ZO={kernelName:fl,inputsToSave:["x","indices"],gradFunc:(e,t,n)=>{let[a,r]=t,{axis:s}=n,i=_a(s,a.shape)[0];return{x:()=>{let o=a.shape,l=r.size,d=o.slice(0,i),u=d.length,p=o.slice(s,o.length).slice(1),c=p.length,h=av(0,u),f=av(u+1,u+1+c),m=rv([d,[l],p]),g=V(e,m),y=V(r,[l]),A=rv([[u],h,f]),x=Ze(g,A),b=ty(x,y,a.shape[i]),v=Bg(A);return b=Ze(b,v),b},indices:()=>r}}};function av(e,t){let n=[];for(let a=e;a<t;++a)n.push(a);return n}function rv(e){let t=[];for(let n=0;n<e.length;++n)for(let a=0;a<e[n].length;++a)t.push(e[n][a]);return t}var YO={kernelName:fi,inputsToSave:["a","b"],gradFunc:(e,t)=>{let[n,a]=t;return{a:()=>Ye(n),b:()=>Ye(a)}}},JO={kernelName:mi,gradFunc:e=>({x:()=>pe(e,"float32")})},QO={kernelName:yl,gradFunc:e=>({x:()=>Ye(e)})},e_={kernelName:Al,gradFunc:e=>({x:()=>Ye(e)})},t_={kernelName:xl,gradFunc:e=>({x:()=>Ye(e)})},n_={kernelName:gi,inputsToSave:["x"],gradFunc:(e,t,n)=>{let[a]=t,{alpha:r}=n,s=Yn(a,0);return{x:()=>Sn(s,e,L(e,r))}}},a_={kernelName:wl,inputsToSave:["x"],gradFunc:(e,t)=>{let[n]=t;return{x:()=>he(e,le(n,1))}}},r_={kernelName:yi,inputsToSave:["x"],gradFunc:(e,t)=>{let[n]=t;return{x:()=>he(e,pe(n,"float32"))}}},s_={kernelName:tb,inputsToSave:[],outputsToSave:[!0],gradFunc:(e,t,n)=>{let[a]=t,{axis:r}=n;return{logits:()=>{let s=!0,i=oa(a);return ge(e,L(Ie(e,r,s),i))}}}};function i_(e,t,n,a=5,r=1,s=1,i=.5){let o={x:e,y:t,dy:n},l={depthRadius:a,bias:r,alpha:s,beta:i};return W.runKernel(ih,o,l)}var o_=B({localResponseNormalizationBackprop_:i_}),l_={kernelName:Sd,inputsToSave:["x"],outputsToSave:[!0],gradFunc:(e,t,n)=>{let[a,r]=t,{depthRadius:s,bias:i,alpha:o,beta:l}=n;return{x:()=>o_(a,r,e,s,i,o,l)}}};function sv(e,t,n,a){return t.rank<n.rank&&(t=V(t,io(t.shape,a))),e.rank<n.rank&&(e=V(e,io(e.shape,a))),{x:()=>L(e,pe(ia(n,t),e.dtype))}}var iv={kernelName:Ai,inputsToSave:["x"],outputsToSave:[!0],gradFunc:(e,t,n)=>{let a=n,{reductionIndices:r}=a,s=t[0],i=t[1],o=_a(r,s.shape),l=sv(e,i,s,o);return{x:()=>l.x()}}},u_={kernelName:xi,inputsToSave:["a","b"],gradFunc:(e,t)=>{let[n,a]=t;return{a:()=>L(e,pe(xs(n,a),"float32")),b:()=>L(e,pe(jh(n,a),"float32"))}}};function d_(e,t,n,a,r,s,i){let o=M(e,"dy","maxPool3dGrad"),l=M(t,"input","maxPool3dGrad"),d=M(n,"output","maxPool3dGrad"),u=o,p=l,c=d,h=!1;l.rank===4&&(h=!0,u=V(o,[1,o.shape[0],o.shape[1],o.shape[2],o.shape[3]]),p=V(l,[1,l.shape[0],l.shape[1],l.shape[2],l.shape[3]]),c=V(d,[1,d.shape[0],d.shape[1],d.shape[2],d.shape[3]])),$(u.rank===5,()=>`Error in maxPool3dGrad: dy must be rank 5 but got rank ${u.rank}.`),$(p.rank===5,()=>`Error in maxPool3dGrad: input must be rank 5 but got rank ${p.rank}.`),$(c.rank===5,()=>`Error in maxPool3dGrad: output must be rank 5 but got rank ${c.rank}.`),i!=null&&$(un(s),()=>`Error in maxPool3dGrad: pad must be an integer when using, dimRoundingMode ${i} but got pad ${s}.`);let f={dy:u,input:p,output:c},m={filterSize:a,strides:r,pad:s,dimRoundingMode:i},g=W.runKernel(lh,f,m);return h?V(g,[g.shape[1],g.shape[2],g.shape[3],g.shape[4]]):g}var p_=B({maxPool3dGrad_:d_}),c_={kernelName:Nd,inputsToSave:["x"],outputsToSave:[!0],gradFunc:(e,t,n)=>{let[a,r]=t,{filterSize:s,strides:i,pad:o,dimRoundingMode:l}=n;return{x:()=>p_(e,a,r,s,i,o,l)}}};function h_(e,t,n,a,r,s,i){let o=M(e,"dy","maxPoolGrad"),l=M(t,"input","maxPoolGrad"),d=M(n,"output","maxPoolGrad");$(l.rank===o.rank,()=>`Rank of input (${l.rank}) does not match rank of dy (${o.rank})`),$(o.rank===4,()=>`Error in maxPoolGrad: dy must be rank 4 but got rank ${o.rank}.`),$(l.rank===4,()=>`Error in maxPoolGrad: input must be rank 4 but got rank ${l.rank}.`),i!=null&&$(un(s),()=>`Error in maxPoolGrad: pad must be an integer when using, dimRoundingMode ${i} but got pad ${s}.`);let u={dy:o,input:l,output:d},p={filterSize:a,strides:r,pad:s,dimRoundingMode:i};return W.runKernel(oh,u,p)}var f_=B({maxPoolGrad_:h_}),m_={kernelName:bi,inputsToSave:["x"],outputsToSave:[!0],gradFunc:(e,t,n)=>{let[a,r]=t,{filterSize:s,strides:i,pad:o}=n;return{x:()=>f_(e,a,r,s,i,o)}}},g_={kernelName:vi,inputsToSave:["x"],gradFunc:(e,t,n)=>{let[a]=t,{axis:r}=n,s=_a(r,a.shape),i=k3(a.shape,s)[1],o=zt(i);return{x:()=>{let l=a.shape.slice();s.forEach(u=>{l[u]=1});let d=V(e,l);return he(L(d,ua(a.shape,"float32")),o)}}}},y_={kernelName:wi,inputsToSave:["x"],outputsToSave:[!0],gradFunc:(e,t,n)=>{let a=n,{axis:r}=a,[s,i]=t,o=_a(r,s.shape),l=sv(e,i,s,o);return{x:()=>l.x()}}},A_={kernelName:ki,inputsToSave:["a","b"],gradFunc:(e,t)=>{let[n,a]=t;return{a:()=>L(e,pe(bs(n,a),"float32")),b:()=>L(e,pe(Yn(n,a),"float32"))}}},x_={kernelName:Ii,inputsToSave:["x"],gradFunc:(e,t,n)=>{let a=t[0],{paddings:r}=n,s=r.map(i=>i[0]);return{x:()=>De(e,s,a.shape)}}},b_={kernelName:Il,inputsToSave:["a","b"],gradFunc:(e,t)=>{let[n,a]=t,r=bt(n.shape,a.shape);return{a:()=>{let s=Qt(n.shape,r);return s.length>0?V(Ie(e,s),n.shape):e},b:()=>{let s=L(e,Tt(du(he(n,a)))),i=Qt(a.shape,r);return i.length>0?V(Ie(s,i),a.shape):s}}}},v_={kernelName:Si,inputsToSave:["a","b"],gradFunc:(e,t)=>{let[n,a]=t,r=bt(n.shape,a.shape);return{a:()=>{let s=L(e,pe(a,"float32")),i=Qt(n.shape,r);return i.length>0?V(Ie(s,i),n.shape):s},b:()=>{let s=L(e,pe(n,"float32")),i=Qt(a.shape,r);return i.length>0?V(Ie(s,i),a.shape):s}}}},w_={kernelName:Sl,gradFunc:e=>({x:()=>Tt(e)})},k_={kernelName:Ni,inputsToSave:["indices"],gradFunc:(e,t)=>{let n=t[0];return{indices:()=>Gt(n.shape,"float32")}}},I_={kernelName:Rl,gradFunc:e=>({x:()=>Ye(e)})},S_={kernelName:Ml,saveAllInputs:!0,gradFunc:(e,t,n)=>{let{axis:a}=n;return Mn(e,a).map(r=>()=>r)}},ov={kernelName:Ti,inputsToSave:["x"],gradFunc:(e,t,n)=>{let a=t[0],{paddings:r}=n,s=r.map(i=>i[0]);return{x:()=>De(e,s,a.shape)}}},N_={kernelName:Ci,inputsToSave:["a","b"],outputsToSave:[!0],gradFunc:(e,t)=>{let[n,a,r]=t,s=n,i=a,o=bt(s.shape,i.shape);return{a:()=>{let l=pe(i,"float32"),d=L(e,L(l,Pr(s,ge(l,Ce(1))))),u=Qt(s.shape,o);return u.length>0&&(d=Ie(d,u)),V(d,s.shape)},b:()=>{let l=Yn(s,0),d=Sn(l,la(s),Ye(s)),u=L(e,L(r,d)),p=Qt(i.shape,o);return p.length>0&&(u=Ie(u,p)),V(u,i.shape)}}}},T_={kernelName:Ei,inputsToSave:["x","alpha"],gradFunc:(e,t)=>{let[n,a]=t,r=Yn(n,0);return{x:()=>Sn(r,e,L(e,a)),alpha:()=>{let s=Sn(r,Ye(e),L(e,n)),i=Qt(a.shape,e.shape);return i.length>0&&(s=Ie(s,i)),V(s,a.shape)}}}},C_={kernelName:li,inputsToSave:["a","b"],gradFunc:(e,t)=>{let[n,a]=t,r=bt(n.shape,a.shape);return{a:()=>{let s=he(e,pe(a,"float32")),i=Qt(n.shape,r);return i.length>0?V(Ie(s,i),n.shape):s},b:()=>{let s=L(e,pe(n,"float32")),i=Qt(a.shape,r);i.length>0&&(s=V(Ie(s,i),a.shape));let o=ht(a);return Tt(he(s,pe(o,"float32")))}}}},E_={kernelName:Dl,inputsToSave:["x"],gradFunc:(e,t)=>{let[n]=t;return{x:()=>he(e,Tt(ht(n)))}}},R_={kernelName:Fi,inputsToSave:["x"],gradFunc:(e,t)=>{let[n]=t,a=L(bs(n,6),gu(n));return{x:()=>L(e,pe(a,"float32"))}}},M_={kernelName:Ri,inputsToSave:["x"],gradFunc:(e,t)=>{let[n]=t;return{x:()=>L(e,pe(gu(n),"float32"))}}},F_={kernelName:$l,inputsToSave:["x"],gradFunc:(e,t)=>{let[n]=t;return{x:()=>V(e,n.shape)}}},D_={kernelName:Mi,inputsToSave:["images"],gradFunc:(e,t,n)=>{let[a]=t,r={dy:e,images:a};return{images:()=>W.runKernel(hh,r,n)}}},$_={kernelName:Cd,inputsToSave:["images"],gradFunc:(e,t,n)=>{let[a]=t,r={dy:e,images:a};return{images:()=>W.runKernel(ch,r,n)}}},O_={kernelName:Di,gradFunc:(e,t,n)=>{let{dims:a}=n,r=_a(a,e.shape);return{x:()=>pa(e,r)}}},__={kernelName:$i,gradFunc:e=>({x:()=>Ye(e)})},P_={kernelName:Oi,inputsToSave:["x"],gradFunc:(e,t)=>{let[n]=t;return{x:()=>Tt(he(e,L(Pr(n,1.5),2)))}}},z_={kernelName:_l,inputsToSave:["condition"],gradFunc:(e,t)=>{let[n]=t;return{condition:()=>pe(Ye(n),"float32"),t:()=>L(e,pe(n,e.dtype)),e:()=>L(e,pe(Yd(n),e.dtype))}}},L_={kernelName:Pl,inputsToSave:["x"],gradFunc:(e,t)=>{let[n]=t;return{x:()=>{let a=Yn(n,Ce(0)),r=Ce(Y3),s=Ce(J3),i=L(e,s),o=L(L(e,r),oa(pe(n,"float32")));return Sn(a,i,o)}}}},W_={kernelName:Pi,outputsToSave:[!0],gradFunc:(e,t)=>{let[n]=t;return{x:()=>L(e,L(n,ge(Ce(1),n)))}}},B_={kernelName:Wl,gradFunc:e=>({x:()=>Ye(e)})},V_={kernelName:_i,inputsToSave:["x"],gradFunc:(e,t)=>{let[n]=t;return{x:()=>L(Xd(pe(n,"float32")),e)}}},U_={kernelName:Ll,inputsToSave:["x"],gradFunc:(e,t)=>{let[n]=t;return{x:()=>L(Bh(pe(n,"float32")),e)}}},j_={kernelName:zl,inputsToSave:["x"],gradFunc:(e,t,n)=>{let[a]=t,{begin:r,size:s}=n,i=a.shape,[o,l]=Kb(a,r,s),d=[];for(let u=0;u<e.rank;u++)d.push([o[u],i[u]-o[u]-l[u]]);return{x:()=>Sa(e,d)}}},G_={kernelName:Wi,outputsToSave:[!0],gradFunc:(e,t,n)=>{let[a]=t,{dim:r}=n,s=!0,i=L(e,a);return{logits:()=>ge(i,L(Ie(i,[r],s),a))}}},H_={kernelName:Bl,inputsToSave:["x"],gradFunc:(e,t)=>{let[n]=t;return{x:()=>L(e,Kn(n))}}},lv={kernelName:Vl,gradFunc:(e,t,n)=>{let{blockShape:a,paddings:r}=n;return{x:()=>qd(e,a,r)}}},uv={kernelName:Ul,gradFunc:(e,t,n)=>{let{axis:a}=n;return{x:()=>mt(e,a)}}},q_={kernelName:zi,inputsToSave:["x"],gradFunc:(e,t)=>{let[n]=t;return{x:()=>he(e,L(An(pe(n,"float32")),2))}}},X_={kernelName:Ed,inputsToSave:["x"],gradFunc:(e,t)=>{let[n]=t;return{x:()=>L(e,L(pe(n,"float32"),2))}}},K_={kernelName:Bi,inputsToSave:["a","b"],gradFunc:(e,t)=>{let[n,a]=t,r=Ce(2);return{a:()=>L(e,L(r,ge(n,a))),b:()=>L(e,L(r,ge(a,n)))}}},Z_={kernelName:ps,gradFunc:e=>({x:()=>Ye(e)})},Y_={kernelName:Vi,inputsToSave:["a","b"],gradFunc:(e,t)=>{let[n,a]=t,r=bt(n.shape,a.shape);return{a:()=>{let s=e,i=Qt(n.shape,r);return i.length>0&&(s=Ie(s,i)),V(s,n.shape)},b:()=>{let s=e,i=Qt(a.shape,r);return i.length>0&&(s=Ie(s,i)),V(Tt(s),a.shape)}}}},J_={kernelName:Li,inputsToSave:["x"],gradFunc:(e,t,n)=>{let[a]=t,r=a.shape.slice(),{axis:s}=n;_a(s,a.shape).forEach(l=>{r[l]=1});let i=V(e,r),o=L(i,ua(a.shape,"float32"));return{x:()=>o}}},Q_={kernelName:Ui,inputsToSave:["x"],gradFunc:(e,t)=>{let[n]=t;return{x:()=>he(e,ht(Xd(n)))}}},eP={kernelName:ji,outputsToSave:[!0],gradFunc:(e,t)=>{let[n]=t;return{x:()=>L(ge(Ce(1),ht(n)),e)}}},tP={kernelName:ds,inputsToSave:["x"],gradFunc:(e,t,n)=>{let[a]=t,{reps:r}=n;return{x:()=>{let s=Ye(a);if(a.rank===1)for(let i=0;i<r[0];++i)s=le(s,De(e,[i*a.shape[0]],[a.shape[0]]));else if(a.rank===2)for(let i=0;i<r[0];++i)for(let o=0;o<r[1];++o)s=le(s,De(e,[i*a.shape[0],o*a.shape[1]],[a.shape[0],a.shape[1]]));else if(a.rank===3)for(let i=0;i<r[0];++i)for(let o=0;o<r[1];++o)for(let l=0;l<r[2];++l)s=le(s,De(e,[i*a.shape[0],o*a.shape[1],l*a.shape[2]],[a.shape[0],a.shape[1],a.shape[2]]));else if(a.rank===4)for(let i=0;i<r[0];++i)for(let o=0;o<r[1];++o)for(let l=0;l<r[2];++l)for(let d=0;d<r[3];++d)s=le(s,De(e,[i*a.shape[0],o*a.shape[1],l*a.shape[2],d*a.shape[3]],[a.shape[0],a.shape[1],a.shape[2],a.shape[3]]));else throw new Error(`Gradient for tile operation is not implemented for rank-${a.rank} tensors yet.`);return s}}}},nP={kernelName:Gi,gradFunc:(e,t,n)=>{let a=n,{perm:r}=a,s=Bg(r);return{x:()=>Ze(e,s)}}},aP={kernelName:ql,gradFunc:(e,t,n)=>{let a=n,{axis:r}=a;return{value:()=>xn(e,r)}}},rP={kernelName:Rd,inputsToSave:["segmentIds"],gradFunc:(e,t)=>{let[n]=t;return{x:()=>sP(e,n)}}};function sP(e,t){let n=Ar(t,Ye(t)),a=ro(e,n),r=xs(t,Ce(0,"int32")),s=a.rank-r.rank;for(let o=0;o<s;++o)r=Wt(r,o+1);r=La(r,ua(a.shape,"bool"));let i=Ye(a);return Sn(r,a,i)}var iP={kernelName:Xl,gradFunc:e=>({x:()=>Ye(e)})},oP=[nv,oO,lO,uO,dO,pO,cO,hO,fO,mO,gO,yO,bO,kO,IO,SO,NO,TO,CO,EO,RO,MO,DO,FO,_O,PO,zO,LO,WO,BO,C_,VO,UO,jO,GO,HO,XO,qO,KO,ZO,YO,JO,QO,e_,t_,n_,a_,r_,s_,l_,iv,iv,u_,c_,m_,g_,y_,A_,x_,b_,v_,w_,k_,I_,S_,ov,ov,N_,T_,E_,R_,M_,F_,D_,$_,O_,__,P_,z_,L_,W_,B_,V_,U_,j_,G_,H_,lv,lv,uv,uv,q_,K_,X_,Z_,Y_,J_,Q_,eP,tP,nP,aP,rP,iP];for(let e of oP)nb(e);ae().prototype.abs=function(){return this.throwIfDisposed(),jt(this)};ae().prototype.acos=function(){return this.throwIfDisposed(),yg(this)};ae().prototype.acosh=function(){return this.throwIfDisposed(),Ag(this)};ae().prototype.add=function(e){return this.throwIfDisposed(),le(this,e)};ae().prototype.all=function(e,t){return this.throwIfDisposed(),Ph(this,e,t)};ae().prototype.any=function(e,t){return this.throwIfDisposed(),jd(this,e,t)};ae().prototype.argMax=function(e){return this.throwIfDisposed(),ka(this,e)};ae().prototype.argMin=function(e){return this.throwIfDisposed(),xg(this,e)};ae().prototype.asScalar=function(){return this.throwIfDisposed(),$(this.size===1,()=>"The array must have only 1 element."),V(this,[])};ae().prototype.asType=function(e){return this.throwIfDisposed(),pe(this,e)};ae().prototype.as1D=function(){return this.throwIfDisposed(),V(this,[this.size])};ae().prototype.as2D=function(e,t){return this.throwIfDisposed(),V(this,[e,t])};ae().prototype.as3D=function(e,t,n){return this.throwIfDisposed(),V(this,[e,t,n])};ae().prototype.as4D=function(e,t,n,a){return this.throwIfDisposed(),V(this,[e,t,n,a])};ae().prototype.as5D=function(e,t,n,a,r){return this.throwIfDisposed(),V(this,[e,t,n,a,r])};ae().prototype.asin=function(){return this.throwIfDisposed(),bg(this)};ae().prototype.asinh=function(){return this.throwIfDisposed(),vg(this)};ae().prototype.atan=function(){return this.throwIfDisposed(),wg(this)};ae().prototype.atan2=function(e){return this.throwIfDisposed(),kg(this,e)};ae().prototype.atanh=function(){return this.throwIfDisposed(),Ig(this)};ae().prototype.avgPool=function(e,t,n,a){return this.throwIfDisposed(),Hd(this,e,t,n,a)};ae().prototype.batchToSpaceND=function(e,t){return this.throwIfDisposed(),qd(this,e,t)};ae().prototype.batchNorm=function(e,t,n,a,r){return this.throwIfDisposed(),ao(this,e,t,n,a,r)};ae().prototype.broadcastTo=function(e){return this.throwIfDisposed(),su(this,e)};ae().prototype.cast=function(e){return this.throwIfDisposed(),pe(this,e)};ae().prototype.ceil=function(){return this.throwIfDisposed(),Eg(this)};ae().prototype.clipByValue=function(e,t){return this.throwIfDisposed(),Zn(this,e,t)};ae().prototype.concat=function(e,t){return this.throwIfDisposed(),e instanceof je&&(e=[e]),mt([this,...e],t)};ae().prototype.conv1d=function(e,t,n,a,r,s){return this.throwIfDisposed(),Lh(this,e,t,n,a,r,s)};ae().prototype.conv2dTranspose=function(e,t,n,a,r){return this.throwIfDisposed(),Wh(this,e,t,n,a,r)};ae().prototype.conv2d=function(e,t,n,a,r,s){return this.throwIfDisposed(),_r(this,e,t,n,a,r,s)};ae().prototype.cos=function(){return this.throwIfDisposed(),Xd(this)};ae().prototype.cosh=function(){return this.throwIfDisposed(),Bh(this)};ae().prototype.cumsum=function(e,t,n){return this.throwIfDisposed(),Vh(this,e,t,n)};ae().prototype.depthToSpace=function(e,t){return this.throwIfDisposed(),Fg(this,e,t)};ae().prototype.depthwiseConv2d=function(e,t,n,a,r,s){return this.throwIfDisposed(),ou(this,e,t,n,a,r,s)};ae().prototype.dilation2d=function(e,t,n,a,r){return this.throwIfDisposed(),Dg(this,e,t,n,a,r)};ae().prototype.divNoNan=function(e){return this.throwIfDisposed(),$g(this,e)};ae().prototype.div=function(e){return this.throwIfDisposed(),he(this,e)};ae().prototype.dot=function(e){return this.throwIfDisposed(),m3(this,e)};ae().prototype.elu=function(){return this.throwIfDisposed(),lu(this)};ae().prototype.equal=function(e){return this.throwIfDisposed(),ia(this,e)};ae().prototype.erf=function(){return this.throwIfDisposed(),Og(this)};ae().prototype.exp=function(){return this.throwIfDisposed(),oa(this)};ae().prototype.expandDims=function(e){return this.throwIfDisposed(),Wt(this,e)};ae().prototype.expm1=function(){return this.throwIfDisposed(),_g(this)};ae().prototype.fft=function(){return this.throwIfDisposed(),rp(this)};ae().prototype.flatten=function(){return this.throwIfDisposed(),V(this,[this.size])};ae().prototype.floor=function(){return this.throwIfDisposed(),du(this)};ae().prototype.floorDiv=function(e){return this.throwIfDisposed(),Oh(this,e)};ae().prototype.gather=function(e,t){return this.throwIfDisposed(),ro(this,e,t)};ae().prototype.greaterEqual=function(e){return this.throwIfDisposed(),xs(this,e)};ae().prototype.greater=function(e){return this.throwIfDisposed(),Yn(this,e)};ae().prototype.ifft=function(){return this.throwIfDisposed(),mu(this)};ae().prototype.irfft=function(){return this.throwIfDisposed(),a0(this)};ae().prototype.isFinite=function(){return this.throwIfDisposed(),y3(this)};ae().prototype.isInf=function(){return this.throwIfDisposed(),A3(this)};ae().prototype.isNaN=function(){return this.throwIfDisposed(),zg(this)};ae().prototype.leakyRelu=function(e){return this.throwIfDisposed(),Kd(this,e)};ae().prototype.lessEqual=function(e){return this.throwIfDisposed(),bs(this,e)};ae().prototype.less=function(e){return this.throwIfDisposed(),jh(this,e)};ae().prototype.localResponseNormalization=function(e,t,n,a){return this.throwIfDisposed(),Lg(this,e,t,n,a)};ae().prototype.logSigmoid=function(){return this.throwIfDisposed(),v3(this)};ae().prototype.logSoftmax=function(e){return this.throwIfDisposed(),Hh(this,e)};ae().prototype.logSumExp=function(e,t){return this.throwIfDisposed(),Vg(this,e,t)};ae().prototype.log=function(){return this.throwIfDisposed(),la(this)};ae().prototype.log1p=function(){return this.throwIfDisposed(),Zd(this)};ae().prototype.logicalAnd=function(e){return this.throwIfDisposed(),La(this,e)};ae().prototype.logicalNot=function(){return this.throwIfDisposed(),Yd(this)};ae().prototype.logicalOr=function(e){return this.throwIfDisposed(),qh(this,e)};ae().prototype.logicalXor=function(e){return this.throwIfDisposed(),S3(this,e)};ae().prototype.matMul=function(e,t,n){return this.throwIfDisposed(),Ve(this,e,t,n)};ae().prototype.maxPool=function(e,t,n,a){return this.throwIfDisposed(),Jd(this,e,t,n,a)};ae().prototype.max=function(e,t){return this.throwIfDisposed(),Rn(this,e,t)};ae().prototype.maximum=function(e){return this.throwIfDisposed(),Ar(this,e)};ae().prototype.mean=function(e,t){return this.throwIfDisposed(),Dt(this,e,t)};ae().prototype.min=function(e,t){return this.throwIfDisposed(),Qd(this,e,t)};ae().prototype.minimum=function(e){return this.throwIfDisposed(),pu(this,e)};ae().prototype.mirrorPad=function(e,t){return this.throwIfDisposed(),jg(this,e,t)};ae().prototype.mod=function(e){return this.throwIfDisposed(),Gg(this,e)};ae().prototype.mul=function(e){return this.throwIfDisposed(),L(this,e)};ae().prototype.neg=function(){return this.throwIfDisposed(),Tt(this)};ae().prototype.norm=function(e,t,n){return this.throwIfDisposed(),o0(this,e,t,n)};ae().prototype.notEqual=function(e){return this.throwIfDisposed(),oo(this,e)};ae().prototype.oneHot=function(e,t=1,n=0){return this.throwIfDisposed(),tu(this,e,t,n)};ae().prototype.onesLike=function(){return this.throwIfDisposed(),da(this)};ae().prototype.pad=function(e,t){return this.throwIfDisposed(),Sa(this,e,t)};ae().prototype.pool=function(e,t,n,a,r){return this.throwIfDisposed(),C3(this,e,t,n,a,r)};ae().prototype.pow=function(e){return this.throwIfDisposed(),Pr(this,e)};ae().prototype.prelu=function(e){return this.throwIfDisposed(),tp(this,e)};ae().prototype.prod=function(e,t){return this.throwIfDisposed(),Kh(this,e,t)};ae().prototype.reciprocal=function(){return this.throwIfDisposed(),Xg(this)};ae().prototype.relu=function(){return this.throwIfDisposed(),Ja(this)};ae().prototype.relu6=function(){return this.throwIfDisposed(),Zh(this)};ae().prototype.reshapeAs=function(e){return this.throwIfDisposed(),V(this,e.shape)};ae().prototype.reshape=function(e){return this.throwIfDisposed(),V(this,e)};ae().prototype.resizeBilinear=function(e,t,n){return this.throwIfDisposed(),H3(this,e,t,n)};ae().prototype.resizeNearestNeighbor=function(e,t,n){return this.throwIfDisposed(),q3(this,e,t,n)};ae().prototype.reverse=function(e){return this.throwIfDisposed(),pa(this,e)};ae().prototype.rfft=function(){return this.throwIfDisposed(),sp(this)};ae().prototype.round=function(){return this.throwIfDisposed(),Yh(this)};ae().prototype.rsqrt=function(){return this.throwIfDisposed(),Jh(this)};ae().prototype.selu=function(){return this.throwIfDisposed(),Qh(this)};ae().prototype.separableConv2d=function(e,t,n,a,r,s){return this.throwIfDisposed(),Kg(this,e,t,n,a,r,s)};ae().prototype.sigmoid=function(){return this.throwIfDisposed(),Kn(this)};ae().prototype.sign=function(){return this.throwIfDisposed(),Zg(this)};ae().prototype.sin=function(){return this.throwIfDisposed(),e0(this)};ae().prototype.sinh=function(){return this.throwIfDisposed(),t0(this)};ae().prototype.slice=function(e,t){return this.throwIfDisposed(),De(this,e,t)};ae().prototype.softmax=function(e){return this.throwIfDisposed(),lo(this,e)};ae().prototype.softplus=function(){return this.throwIfDisposed(),so(this)};ae().prototype.spaceToBatchND=function(e,t){return this.throwIfDisposed(),ep(this,e,t)};ae().prototype.split=function(e,t){return this.throwIfDisposed(),cn(this,e,t)};ae().prototype.sqrt=function(){return this.throwIfDisposed(),An(this)};ae().prototype.square=function(){return this.throwIfDisposed(),ht(this)};ae().prototype.squaredDifference=function(e){return this.throwIfDisposed(),r0(this,e)};ae().prototype.squeeze=function(e){return this.throwIfDisposed(),st(this,e)};ae().prototype.stack=function(e,t){this.throwIfDisposed();let n=e instanceof je?[this,e]:[this,...e];return xn(n,t)};ae().prototype.step=function(e){return this.throwIfDisposed(),gu(this,e)};ae().prototype.stridedSlice=function(e,t,n,a,r,s,i,o){return this.throwIfDisposed(),Jg(this,e,t,n,a,r,s,i,o)};ae().prototype.sub=function(e){return this.throwIfDisposed(),ge(this,e)};ae().prototype.sum=function(e,t){return this.throwIfDisposed(),Ie(this,e,t)};ae().prototype.tan=function(){return this.throwIfDisposed(),Qg(this)};ae().prototype.tanh=function(){return this.throwIfDisposed(),no(this)};ae().prototype.tile=function(e){return this.throwIfDisposed(),Ia(this,e)};ae().prototype.toBool=function(){return this.throwIfDisposed(),pe(this,"bool")};ae().prototype.toFloat=function(){return this.throwIfDisposed(),pe(this,"float32")};ae().prototype.toInt=function(){return this.throwIfDisposed(),pe(this,"int32")};ae().prototype.topk=function(e,t){return this.throwIfDisposed(),ey(this,e,t)};ae().prototype.transpose=function(e){return this.throwIfDisposed(),Ze(this,e)};ae().prototype.unique=function(e){return this.throwIfDisposed(),i0(this,e)};ae().prototype.unsortedSegmentSum=function(e,t){return this.throwIfDisposed(),ty(this,e,t)};ae().prototype.unstack=function(e){return this.throwIfDisposed(),Mn(this,e)};ae().prototype.where=function(e,t){return this.throwIfDisposed(),Sn(e,this,t)};ae().prototype.zerosLike=function(){return this.throwIfDisposed(),Ye(this)};var dv={};ze(dv,{maxNorm:()=>pP,minMaxNorm:()=>fP,nonNeg:()=>hP,unitNorm:()=>cP});var uy;function en(){return uy==null&&(uy=mr().epsilon()),uy}function er(){return"channelsLast"}var Wr=class extends Error{constructor(e){super(e);Object.setPrototypeOf(this,Wr.prototype)}},tr=class extends Error{constructor(e){super(e);Object.setPrototypeOf(this,tr.prototype)}},H=class extends Error{constructor(e){super(e);Object.setPrototypeOf(this,H.prototype)}},Pe=class extends Error{constructor(e){super(e);Object.setPrototypeOf(this,Pe.prototype)}},pv=class extends Error{constructor(e){super(e);Object.setPrototypeOf(this,pv.prototype)}};function co(e,t){if(Array.isArray(e)){let n=[];for(let a=0;a<t;a++)n=n.concat(e);return n}else{let n=new Array(t);return n.fill(e),n}}function br(e,t){if(!e)throw new pv(t)}function cv(e,t){let n=0;for(let a of e)a===t&&n++;return n}function Jn(e){return e.length===1?e[0]:e}function vt(e){return Array.isArray(e)?e:[e]}function Br(e){let t=e.replace(/(.)([A-Z][a-z0-9]+)/g,"$1_$2").replace(/([a-z])([A-Z])/g,"$1_$2").toLowerCase();return t[0]!=="_"?t:"private"+t}function ho(e){return e.length<=1||e.indexOf("_")===-1?e:e.replace(/[_]+(\w|$)/g,(t,n)=>n.toUpperCase())}var Wa={};function dy(e){if(e==null)return null;let t={};return t.className=e.getClassName(),t.config=e.getConfig(),t}function py(e){if(!(e==null||typeof e!="object"))if(Array.isArray(e))e.forEach(t=>py(t));else{let t=Object.keys(e);for(let n of t){let a=e[n];a!=null&&typeof a=="object"&&(!Array.isArray(a)&&a.type==="ndarray"&&typeof a.value=="number"?e[n]=a.value:py(a))}}}function lp(e,t={},n={},a="object",r=!1){if(typeof e=="string"){let s=e,i;if(s in n)i=n[s];else if(s in Wa)i=Wa[s];else if(i=t[s],i==null)throw new H(`Unknown ${a}: ${e}. This may be due to one of the following reasons:
|
|
1. The ${a} is defined in Python, in which case it needs to be ported to TensorFlow.js or your JavaScript code.
|
|
2. The custom ${a} is defined in JavaScript, but is not registered properly with tf.serialization.registerClass().`);return i}else{let s=e;if(s.className==null||s.config==null)throw new H(`${a}: Improper config format: ${JSON.stringify(s)}.
|
|
'className' and 'config' must set.`);let i=s.className,o,l;if(i in n?[o,l]=n[i]:i in Wa?[o,l]=Wa.className:i in t&&([o,l]=t[i]),o==null)throw new H(`Unknown ${a}: ${i}. This may be due to one of the following reasons:
|
|
1. The ${a} is defined in Python, in which case it needs to be ported to TensorFlow.js or your JavaScript code.
|
|
2. The custom ${a} is defined in JavaScript, but is not registered properly with tf.serialization.registerClass().`);if(l!=null){let d={};for(let h of Object.keys(Wa))d[h]=Wa[h];for(let h of Object.keys(n))d[h]=n[h];let u=s.config;u.customObjects=d;let p=Object.assign({},Wa);for(let h of Object.keys(n))Wa[h]=n[h];py(s.config);let c=l(o,s.config,n,r);return Wa=Object.assign({},p),c}else{let d=Object.assign({},Wa);for(let p of Object.keys(n))Wa[p]=n[p];let u=new o(s.config);return Wa=Object.assign({},d),u}}}function lP(e,t){return e<t?-1:e>t?1:0}function x0(e,t){return-1*lP(e,t)}function ws(e){if(e==null)return e;let t=[];for(let n of e)t.indexOf(n)===-1&&t.push(n);return t}function uP(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 fo(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 cy(e,t,n=0,a=1/0){return br(n>=0),br(a>=n),Array.isArray(e)&&e.length>=n&&e.length<=a&&e.every(r=>typeof r===t)}function hn(e,t){Array.isArray(e)?(w.assert(e.length>0,()=>`${t} is unexpectedly an empty array.`),e.forEach((n,a)=>hn(n,`element ${a+1} of ${t}`))):w.assert(Number.isInteger(e)&&e>0,()=>`Expected ${t} to be a positive integer, but got ${hv(e)}.`)}function hv(e){return e===null?"null":Array.isArray(e)?"["+e.map(t=>hv(t)).join(",")+"]":typeof e=="string"?`"${e}"`:`${e}`}function dP(e,t,n){let a=n!=null?n():w.now(),r;return(...s)=>{let i=n!=null?n():w.now();return i-a<t||(a=i,r=e(...s)),r}}function fv(e){return e==="relu"?"relu":e==="linear"?"linear":e==="elu"?"elu":null}function hy(e,t){return G(()=>An(Ie(L(e,e),t,!0)))}var up=class extends ue.Serializable{getConfig(){return{}}},fy=class extends up{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=hy(e,this.axis),n=Zn(t,0,this.maxValue);return L(e,he(n,le(en(),t)))})}getConfig(){return{maxValue:this.maxValue,axis:this.axis}}};fy.className="MaxNorm";ue.registerClass(fy);var my=class extends up{constructor(e){super();this.defaultAxis=0,this.axis=e.axis!=null?e.axis:this.defaultAxis}apply(e){return G(()=>he(e,le(en(),hy(e,this.axis))))}getConfig(){return{axis:this.axis}}};my.className="UnitNorm";ue.registerClass(my);var gy=class extends up{apply(e){return Ja(e)}};gy.className="NonNeg";ue.registerClass(gy);var yy=class extends up{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=hy(e,this.axis),n=le(L(this.rate,Zn(t,this.minValue,this.maxValue)),L(1-this.rate,t));return L(e,he(n,le(en(),t)))})}getConfig(){return{minValue:this.minValue,maxValue:this.maxValue,rate:this.rate,axis:this.axis}}};yy.className="MinMaxNorm";ue.registerClass(yy);var mv={maxNorm:"MaxNorm",minMaxNorm:"MinMaxNorm",nonNeg:"NonNeg",unitNorm:"UnitNorm"};function tn(e){return dy(e)}function gv(e,t={}){return lp(e,ue.SerializationMap.getMap().classNameMap,t,"constraint")}function nn(e){if(e==null)return null;if(typeof e=="string"){let t={className:e in mv?mv[e]:e,config:{}};return gv(t)}else return e instanceof up?e:gv(e)}function pP(e){return new fy(e)}function cP(e){return new my(e)}function hP(){return new gy}function fP(e){return new yy(e)}var yv={};ze(yv,{constant:()=>PP,glorotNormal:()=>jP,glorotUniform:()=>UP,heNormal:()=>GP,heUniform:()=>HP,identity:()=>BP,leCunNormal:()=>qP,leCunUniform:()=>XP,ones:()=>_P,orthogonal:()=>KP,randomNormal:()=>LP,randomUniform:()=>zP,truncatedNormal:()=>WP,varianceScaling:()=>VP,zeros:()=>OP});var mP=["channelsFirst","channelsLast"],gP=["nearest","bilinear"],yP=["valid","same","causal"],AP=["max","avg"],xP=["sum","mul","concat","ave"],Au=new Map;function Bt(e){fo(mP,"DataFormat",e)}function bP(e){fo(gP,"InterpolationFormat",e)}function Na(e){fo(yP,"PaddingMode",e)}function Av(e){fo(AP,"PoolMode",e)}var dp=[],xv="/";function mo(e,t){dp.push(e);try{let n=t();return dp.pop(),n}catch(n){throw dp.pop(),n}}function vP(){return dp.length===0?"":dp.join(xv)+xv}function bv(e){if(!wv(e))throw new Error("Not a valid tensor name: '"+e+"'");return vP()+e}function vv(e){if(!wv(e))throw new Error("Not a valid tensor name: '"+e+"'");Au.has(e)||Au.set(e,0);let t=Au.get(e);if(Au.set(e,Au.get(e)+1),t>0){let n=`${e}_${t}`;return Au.set(n,1),n}else return e}var wP=new RegExp(/^[A-Za-z0-9][-A-Za-z0-9\._\/]*$/);function wv(e){return!!e.match(wP)}function kP(e){return e===parseInt(e.toString(),10)}function ks(e,t,n){t==null&&(t=0),n==null&&(n=e.length);let a=1;for(let r=t;r<n;++r)a*=e[r];return a}function xu(e){if(e.length===0)return Number.NaN;let t=Number.POSITIVE_INFINITY;for(let n=0;n<e.length;n++){let a=e[n];a<t&&(t=a)}return t}function Is(e){if(e.length===0)return Number.NaN;let t=Number.NEGATIVE_INFINITY;for(let n=0;n<e.length;n++){let a=e[n];a>t&&(t=a)}return t}function nr(e,t){if(t<e)throw new H(`end (${t}) < begin (${e}) is forbidden.`);let n=[];for(let a=e;a<t;++a)n.push(a);return n}function b0(e,t){return pe(e,t)}function pp(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 IP(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=pp(e,1);return by(n,[1,t,1])})}function SP(e){let t=[ks(e.shape)];return V(e,t)}function NP(e){if(e.rank<=1)throw new H(`batchFlatten requires a minimum rank of 2. Got rank: ${e.rank}.`);let t=[e.shape[0],ks(e.shape,1)];return V(e,t)}function go(e,t,n){return G(()=>{switch(e.rank){case 1:return n0(e,t,n);case 2:return Yg(e,[t,0],[n,e.shape[1]]);case 3:return fu(e,[t,0,0],[n,e.shape[1],e.shape[2]]);case 4:return ap(e,[t,0,0,0],[n,e.shape[1],e.shape[2],e.shape[3]]);case 5:return De(e,[t,0,0,0,0],[n,e.shape[1],e.shape[2],e.shape[3],e.shape[4]]);case 6:return De(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 Ay(e,t,n){return G(()=>{switch(e.rank){case 1:return n0(e,t,n);case 2:return Yg(e,[0,t],[e.shape[0],n]);case 3:return fu(e,[0,0,t],[e.shape[0],e.shape[1],n]);case 4:return ap(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 v0(e,t,n,a){return G(()=>{switch(e.rank){case 1:return n0(e,t,n);case 2:switch(a){case 1:return go(e,t,n);case 2:return Ay(e,t,n);default:throw new H(`The axis is not within the rank of the tensor ${a}`)}case 3:switch(a){case 1:return go(e,t,n);case 2:return fu(e,[0,t,0],[e.shape[0],n,e.shape[2]]);case 3:return Ay(e,t,n);default:throw new H(`The axis is not within the rank of the tensor ${a}`)}case 4:switch(a){case 1:return go(e,t,n);case 2:return ap(e,[0,t,0,0],[e.shape[0],n,e.shape[2],e.shape[3]]);case 3:return ap(e,[0,0,t,0],[e.shape[0],e.shape[1],n,e.shape[3]]);case 4:return Ay(e,t,n);default:throw new H(`The axis is not within the rank of the tensor ${a}`)}default:throw new H(`sliceAlongLastAxis() received an unsupported tensor rank: ${e.rank}`)}})}function xy(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 kv(e,t){switch(e.rank){case 1:return u3([e,t]);case 2:return iu([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 by(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 Ia(e,t)}function w0(e,t=0,n=1,a,r){return E3(e,t,n,a,r)}function vr(e,t,n,a){if(e.rank<2||t.rank<2)throw new Pe(`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],s=t.shape.slice(-2)[0];if(r!==s)throw new Pe(`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,s=!1;return vs.matMul({a:e,b:t,transposeA:r,transposeB:s,bias:a?vy(e.rank,a,er()):null,activation:n})}else{let r=e.shape.slice(),s=r.pop();e=V(e,[-1,s]);let i=t.shape.slice(),o=i.pop(),l=i.pop(),d=[...i,o],u=Array.from({length:t.rank},(f,m)=>m===0?t.rank-2:m<=t.rank-2?m-1:m);t=V(Ze(t,u),[l,-1]);let p=[...r,...d],c=!1,h=!1;return V(vs.matMul({a:e,b:t,transposeA:c,transposeB:h,bias:a?vy(e.rank,a,er()):null,activation:n}),p)}}function Iv(e,t,n){return G(()=>(Array.isArray(t)?t=Ht(t,"int32"):t=pe(t,"int32"),ro(e,t,n)))}function cp(e){return L(e,e)}function vy(e,t,n){let a=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 a.length===1?V(t,[1,a[0],1,1,1]):V(t,[1,a[3],a[0],a[1],a[2]]);if(n==="channelsLast")return a.length===1?V(t,[1,1,1,1,a[0]]):V(t,[1].concat(a))}else if(e===4){if(n==="channelsFirst")return a.length===1?V(t,[1,a[0],1,1]):V(t,[1,a[2],a[0],a[1]]);if(n==="channelsLast")return a.length===1?V(t,[1,1,1,a[0]]):V(t,[1].concat(a))}else if(e===3){if(n==="channelsFirst")return a.length===1?V(t,[1,a[0],1]):V(t,[1,a[1],a[0]]);if(n==="channelsLast")return a.length===1?V(t,[1,1,a[0]]):V(t,[1].concat(a))}else if(e<3)return t;throw new H(`Unsupported input rank by biasAdd: ${t.rank}`)}function ar(e,t,n){return G(()=>(n==null&&(n=er()),Bt(n),le(e,vy(e.rank,t,n))))}function TP(e,t=1){if(t!==1)throw new Pe(`Support for alpha values other than 1 (${t}) is not implemented yet.`);return lu(e)}function CP(e){return G(()=>he(e,le(jt(e),1)))}function Sv(e,t,n,a){return G(()=>_3(e,t,n,a))}function EP(e){return G(()=>{let t=le(.5,L(.2,e));return Zn(t,0,1)})}function hp(e,t,n=!1){return n?e():t()}var RP=["fanIn","fanOut","fanAvg"],MP=["normal","uniform","truncatedNormal"];function FP(e){fo(RP,"FanMode",e)}function DP(e){fo(MP,"Distribution",e)}var Ba=class extends ue.Serializable{fromConfigUsesCustomObjects(){return!1}getConfig(){return{}}},wy=class extends Ba{apply(e,t){return Gt(e,t)}};wy.className="Zeros";ue.registerClass(wy);var k0=class extends Ba{apply(e,t){return ua(e,t)}};k0.className="Ones";ue.registerClass(k0);var ky=class extends Ba{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(Ce(this.value),ua(e,t)))}getConfig(){return{value:this.value}}};ky.className="Constant";ue.registerClass(ky);var Iy=class extends Ba{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}}};Iy.className="RandomUniform";ue.registerClass(Iy);var Sy=class extends Ba{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 Pe(`randomNormal does not support dType ${t}.`);return w0(e,this.mean,this.stddev,t,this.seed)}getConfig(){return{mean:this.mean,stddev:this.stddev,seed:this.seed}}};Sy.className="RandomNormal";ue.registerClass(Sy);var Ny=class extends Ba{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 Pe(`truncatedNormal does not support dType ${t}.`);return s0(e,this.mean,this.stddev,t,this.seed)}getConfig(){return{mean:this.mean,stddev:this.stddev,seed:this.seed}}};Ny.className="TruncatedNormal";ue.registerClass(Ny);var Ty=class extends Ba{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,Pg(e[0]))})}getConfig(){return{gain:this.gain}}};Ty.className="Identity";ue.registerClass(Ty);function $P(e,t="channelsLast"){let n,a;if(Bt(t),e.length===2)n=e[0],a=e[1];else if([3,4,5].indexOf(e.length)!==-1){if(t==="channelsFirst"){let r=ks(e,2);n=e[1]*r,a=e[0]*r}else if(t==="channelsLast"){let r=ks(e,0,e.length-2);n=e[e.length-2]*r,a=e[e.length-1]*r}}else{let r=ks(e);n=Math.sqrt(r),a=Math.sqrt(r)}return[n,a]}var Qn=class extends Ba{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,FP(this.mode),this.distribution=e.distribution==null?"normal":e.distribution,DP(this.distribution),this.seed=e.seed}apply(e,t){let n=$P(e),a=n[0],r=n[1],s=this.scale;if(this.mode==="fanIn"?s/=Math.max(1,a):this.mode==="fanOut"?s/=Math.max(1,r):s/=Math.max(1,(a+r)/2),this.distribution==="normal"){let i=Math.sqrt(s);if(t=t||"float32",t!=="float32"&&t!=="int32")throw new Pe(`${this.getClassName()} does not support dType ${t}.`);return s0(e,0,i,t,this.seed)}else{let i=Math.sqrt(3*s);return cu(e,-i,i,t)}}getConfig(){return{scale:this.scale,mode:this.mode,distribution:this.distribution,seed:this.seed}}};Qn.className="VarianceScaling";ue.registerClass(Qn);var I0=class extends Qn{constructor(e){super({scale:1,mode:"fanAvg",distribution:"uniform",seed:e==null?null:e.seed})}getClassName(){return Qn.className}};I0.className="GlorotUniform";ue.registerClass(I0);var S0=class extends Qn{constructor(e){super({scale:1,mode:"fanAvg",distribution:"normal",seed:e==null?null:e.seed})}getClassName(){return Qn.className}};S0.className="GlorotNormal";ue.registerClass(S0);var N0=class extends Qn{constructor(e){super({scale:2,mode:"fanIn",distribution:"normal",seed:e==null?null:e.seed})}getClassName(){return Qn.className}};N0.className="HeNormal";ue.registerClass(N0);var T0=class extends Qn{constructor(e){super({scale:2,mode:"fanIn",distribution:"uniform",seed:e==null?null:e.seed})}getClassName(){return Qn.className}};T0.className="HeUniform";ue.registerClass(T0);var C0=class extends Qn{constructor(e){super({scale:1,mode:"fanIn",distribution:"normal",seed:e==null?null:e.seed})}getClassName(){return Qn.className}};C0.className="LeCunNormal";ue.registerClass(C0);var E0=class extends Qn{constructor(e){super({scale:1,mode:"fanIn",distribution:"uniform",seed:e==null?null:e.seed})}getClassName(){return Qn.className}};E0.className="LeCunNormal";ue.registerClass(E0);var Cy=class extends Ba{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 Pe("Random seed is not implemented for Orthogonal Initializer yet.")}apply(e,t){return G(()=>{if(e.length<2)throw new Pe("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,a=w0(n,0,1,"float32"),r=K3.gramSchmidt(a);return e[0]>e[1]&&(r=Ze(r)),L(this.gain,r)})}getConfig(){return{gain:this.gain,seed:this.seed}}};Cy.className="Orthogonal";ue.registerClass(Cy);var Nv={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 Tv(e,t={}){return lp(e,ue.SerializationMap.getMap().classNameMap,t,"initializer")}function $t(e){return dy(e)}function Ct(e){if(typeof e=="string"){let t=e in Nv?Nv[e]:e;if(t==="GlorotNormal")return new S0;if(t==="GlorotUniform")return new I0;if(t==="HeNormal")return new N0;if(t==="HeUniform")return new T0;if(t==="LeCunNormal")return new C0;if(t==="LeCunUniform")return new E0;{let n={};return n.className=t,n.config={},Tv(n)}}else return e instanceof Ba?e:Tv(e)}function OP(){return new wy}function _P(){return new k0}function PP(e){return new ky(e)}function zP(e){return new Iy(e)}function LP(e){return new Sy(e)}function WP(e){return new Ny(e)}function BP(e){return new Ty(e)}function VP(e){return new Qn(e)}function UP(e){return new I0(e)}function jP(e){return new S0(e)}function GP(e){return new N0(e)}function HP(e){return new T0(e)}function qP(e){return new C0(e)}function XP(e){return new E0(e)}function KP(e){return new Cy(e)}var Cv={};ze(Cv,{Layer:()=>Qe,RNN:()=>Ir,RNNCell:()=>wp,activation:()=>ML,add:()=>WL,alphaDropout:()=>kW,average:()=>BL,averagePooling1d:()=>HA,averagePooling2d:()=>qA,averagePooling3d:()=>XA,avgPool1d:()=>ZL,avgPool2d:()=>JL,avgPool3d:()=>eW,avgPooling1d:()=>YL,avgPooling2d:()=>QL,avgPooling3d:()=>tW,batchNormalization:()=>qL,bidirectional:()=>mW,concatenate:()=>VL,conv1d:()=>wL,conv2d:()=>kL,conv2dTranspose:()=>IL,conv3d:()=>SL,conv3dTranspose:()=>NL,convLstm2d:()=>pW,convLstm2dCell:()=>cW,cropping2D:()=>CL,dense:()=>FL,depthwiseConv2d:()=>RL,dot:()=>HL,dropout:()=>DL,elu:()=>gL,embedding:()=>LL,flatten:()=>OL,gaussianDropout:()=>wW,gaussianNoise:()=>vW,globalAveragePooling1d:()=>nW,globalAveragePooling2d:()=>aW,globalMaxPool1d:()=>yW,globalMaxPool2d:()=>AW,globalMaxPooling1d:()=>P7,globalMaxPooling2d:()=>z7,gru:()=>sW,gruCell:()=>iW,input:()=>o7,inputLayer:()=>mL,layerNormalization:()=>XL,leakyReLU:()=>AL,lstm:()=>oW,lstmCell:()=>lW,masking:()=>IW,maxPool1d:()=>xW,maxPool2d:()=>bW,maxPooling1d:()=>L7,maxPooling2d:()=>W7,maxPooling3d:()=>rW,maximum:()=>UL,minimum:()=>jL,multiply:()=>GL,permute:()=>zL,prelu:()=>xL,reLU:()=>yL,repeatVector:()=>_L,reshape:()=>PL,rnn:()=>hW,separableConv2d:()=>TL,simpleRNN:()=>uW,simpleRNNCell:()=>dW,softmax:()=>bL,spatialDropout1d:()=>$L,stackedRNNCells:()=>fW,thresholdedReLU:()=>vL,timeDistributed:()=>gW,upSampling2d:()=>EL,zeroPadding2d:()=>KL});var ZP=0;function Ev(){return ZP++}var R0={};function M0(e=""){return e in R0||(R0[e]=0),R0[e]+=1,e+R0[e].toString()}function Ey(e){return Array.isArray(e)&&Array.isArray(e[0])}function F0(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 pt(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 D0(e){let t=0;for(let n of e)n.shape.length===0?t+=1:t+=n.shape.reduce((a,r)=>a*r);return t}var Rv="Variable",Mv=class{constructor(e,t="float32",n=Rv,a=!0,r=null){this.dtype=t==null?"float32":t,this.shape=e.shape,this.id=Ev(),n=n==null?Rv:n,this.originalName=bv(n),this.name=vv(this.originalName),this.trainable_=a,this.constraint=r,this.val=M3(e,this.trainable_,this.name,this.dtype)}read(){return this.assertNotDisposed(),this.val}write(e){return this.assertNotDisposed(),YP(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 YP(e,t){if(e.shape.toString()!==t.shape.toString())throw new Error("Shape mismatch: "+JSON.stringify(e.shape)+" vs. "+JSON.stringify(t.shape))}function Ry(e){return e.map(t=>t.read())}function My(e){e.forEach(t=>{t[0].write(t[1])})}var qt=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||{}}},rr=class{constructor(e,t,n,a,r,s,i){this.dtype=e,this.shape=t,this.sourceLayer=n,this.inputs=a,this.callArgs=r,this.outputTensorIndex=i,this.id=Ev(),s!=null&&(this.originalName=bv(s),this.name=vv(this.originalName)),this.rank=t.length}},JP=0,$0=class{constructor(e,t){this.callArgs=t,this.id=JP++,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}}},QP=0,Qe=class extends ue.Serializable{constructor(e={}){super();this._callHook=null,this._addedWeightNames=[],this._stateful=!1,this.id=QP++,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=Br(n)+"_"+M0(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 a=e.dtype;a==null&&(a=e.inputDType),a==null&&(a="float32"),this.dtype=a}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 tr(`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 Jn(this.getNodeAtIndex(e,"input").inputTensors)}getOutputAt(e){return Jn(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 Jn(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 Jn(this.getNodeAtIndex(0,"output").outputTensors)}get losses(){return this._losses}calculateLosses(){return this.losses.map(e=>e())}get updates(){return this._updates}get built(){return this._built}set built(e){this._built=e}get trainable(){return this.trainable_}set trainable(e){this._trainableWeights.forEach(t=>t.trainable=e),this.trainable_=e}get trainableWeights(){return this.trainable_?this._trainableWeights.filter(e=>e.trainable):[]}set trainableWeights(e){this._trainableWeights=e}get nonTrainableWeights(){return this.trainable?this._trainableWeights.filter(e=>!e.trainable).concat(this._nonTrainableWeights):this._trainableWeights.concat(this._nonTrainableWeights)}set nonTrainableWeights(e){this._nonTrainableWeights=e}get weights(){return this.trainableWeights.concat(this.nonTrainableWeights)}get stateful(){return this._stateful}resetStates(){if(!this.stateful)throw new Error("Cannot call the resetStates() method of a non-stateful Layer object.")}assertInputCompatibility(e){if(e=vt(e),this.inputSpec==null||this.inputSpec.length===0)return;let t=vt(this.inputSpec);if(e.length!==t.length)throw new 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 a=e[n],r=t[n];if(r==null)continue;let s=a.rank;if(r.ndim!=null&&s!==r.ndim)throw new H(`Input ${n} is incompatible with layer ${this.name}: expected ndim=${r.ndim}, found ndim=${s}`);if(r.maxNDim!=null&&s>r.maxNDim)throw new H(`Input ${n} is incompatible with layer ${this.name}: expected max_ndim=${r.maxNDim}, found ndim=${s}`);if(r.minNDim!=null&&s<r.minNDim)throw new H(`Input ${n} is incompatible with layer ${this.name}: expected min_ndim=${r.minNDim}, found ndim=${s}.`);if(r.dtype!=null&&a.dtype!==r.dtype)throw new H(`Input ${n} is incompatible with layer ${this.name} : expected dtype=${r.dtype}, found dtype=${a.dtype}.`);if(r.axes){let i=a.shape;for(let o in r.axes){let l=Number(o),d=r.axes[o],u=l>=0?i[l]:i[i.length+l];if(d!=null&&[d,null].indexOf(u)===-1)throw new H(`Input ${n} is incompatible with layer ${this.name}: expected axis ${l} of input shape to have value ${d} but got shape ${i}.`)}}if(r.shape!=null)for(let i=0;i<r.shape.length;++i){let o=r.shape[i],l=a.shape[i];if(o!=null&&l!=null&&o!==l)throw new H(`Input ${n} is incompatible with layer ${this.name}: expected shape=${r.shape}, found shape=${a.shape}.`)}}}call(e,t){return e}invokeCallHook(e,t){this._callHook!=null&&this._callHook(e,t)}setCallHook(e){this._callHook=e}clearCallHook(){this._callHook=null}apply(e,t){t=t||{},this.assertNotDisposed();let n=vt(e),a=!0;for(let s of n)if(!(s instanceof rr)){a=!1;break}let r=!0;for(let s of n)if(s instanceof rr){r=!1;break}if(a===r)throw new H("Arguments to apply() must be all SymbolicTensors or all Tensors");return mo(this.name,()=>{if(!this.built){this.assertInputCompatibility(e);let s=[];for(let i of vt(e))s.push(i.shape);this.build(Jn(s)),this.built=!0,this.initialWeights&&this.setWeights(this.initialWeights),this._refCount===null&&r&&(this._refCount=1)}if(this.assertInputCompatibility(e),r){let s=this.call(e,t),i=vt(s),o=[];for(let l of i)n.indexOf(l)!==-1&&(l=l.clone()),o.push(l);if(s=Jn(o),this.activityRegularizer!=null)throw new Pe("Layer invocation in the presence of activity regularizer(s) is not supported yet.");return s}else{let s=ez(e),i=this.computeOutputShape(s),o,l=tz(e);if(this.warnOnIncompatibleInputShape(Array.isArray(e)?s[0]:s),i!=null&&i.length>0&&Array.isArray(i[0])?o=i.map((d,u)=>new rr(l,d,this,vt(e),t,this.name,u)):o=new rr(l,i,this,vt(e),t,this.name),this.addInboundNode(e,o,null,null,s,i,t),this._refCount++,this.activityRegularizer!=null)throw new Pe("Layer invocation in the presence of activity regularizer(s) is not supported yet.");return o}})}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,a)=>{n!=null&&e[a]!=null&&e[a]!==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 tr(`You tried to call countParams() on ${this.name}, but the layer is not built yet. Build it first by calling build(batchInputShape).`);return D0(this.weights)}build(e){this.built=!0}getWeights(e=!1){return Ry(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=[],a=Ry(t);for(let r=0;r<a.length;++r){let s=a[r],i=t[r],o=e[r];if(!w.arraysEqual(s.shape,o.shape))throw new H(`Layer weight shape ${s.shape} not compatible with provided weight shape ${o.shape}`);n.push([i,o])}My(n)})}addWeight(e,t,n,a,r,s,i,o){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&&(a=o!=null?o():Ct("zeros"));let l=a.apply(t,n),d=new Mv(l,n,e,s,i);return l.dispose(),r!=null&&this.addLoss(()=>r.apply(d.read())),s==null&&(s=!0),s?this._trainableWeights.push(d):this._nonTrainableWeights.push(d),d}setFastWeightInitDuringBuild(e){this.fastWeightInitDuringBuild=e}addLoss(e){e==null||Array.isArray(e)&&e.length===0||(e=vt(e),this._losses!==void 0&&this._losses!==null&&this.losses.push(...e))}computeOutputShape(e){return e}computeMask(e,t){if(!this.supportsMasking){if(t!=null)if(Array.isArray(t))t.forEach(n=>{if(n!=null)throw new TypeError(`Layer ${this.name} does not support masking, but was passed an inputMask.`)});else throw new TypeError(`Layer ${this.name} does not support masking, but was passed an inputMask.`);return null}return t}addInboundNode(e,t,n,a,r,s,i=null){let o=vt(e);t=vt(t),n=vt(n),a=vt(a),r=F0(r),s=F0(s);let l=[],d=[],u=[];for(let p of o)l.push(p.sourceLayer),d.push(p.nodeIndex),u.push(p.tensorIndex);new $0({outboundLayer:this,inboundLayers:l,nodeIndices:d,tensorIndices:u,inputTensors:o,outputTensors:t,inputMasks:n,outputMasks:a,inputShapes:r,outputShapes:s},i);for(let p=0;p<t.length;p++)t[p].sourceLayer=this,t[p].nodeIndex=this.inboundNodes.length-1,t[p].tensorIndex=p}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 ez(e){e=vt(e);let t=[];for(let n of e)t.push(n.shape);return Jn(t)}function tz(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 a=t.inboundNodes[n];if(a.inboundLayers.length===0)return a.inputTensors;{let r=[];for(let s=0;s<a.inboundLayers.length;s++){let i=a.inputTensors[s],o=a.inboundLayers[s],l=a.nodeIndices[s],d=Fv(i,o,l);for(let u of d)r.indexOf(u)===-1&&r.push(u)}return r}}}var bu=class extends Qe{constructor(e){super({dtype:e.dtype,name:e.name!=null?e.name:M0("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 a=new rr(this.dtype,this.batchInputShape,this,[],{},this.name);a.nodeIndex=0,a.tensorIndex=0,new $0({outboundLayer:this,inboundLayers:[],nodeIndices:[],tensorIndices:[],inputTensors:[a],outputTensors:[a],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}}};bu.className="InputLayer";ue.registerClass(bu);function Dv(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 bu({batchInputShape:t,name:e.name,dtype:n,sparse:e.sparse}).inboundNodes[0].outputTensors[0]}async function Ss(e){if(e==null)return;let t=[],n=[],a=[];for(let r in e){let s=e[r];if(typeof s!="number"){let i=s;t.push(i.data()),n.push(r),a.push(i)}}if(t.length>0){let r=await Promise.all(t);for(let s=0;s<r.length;++s)e[n[s]]=r[s][0];Q(a)}}function $v(e){if(e!=null)for(let t in e){let n=e[t];typeof n!="number"&&n.dispose()}}var Ov;(function(e){e[e.SILENT=0]="SILENT",e[e.VERBOSE=1]="VERBOSE"})(Ov||(Ov={}));var nz=125,vu=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){}},_v=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 vu{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 a in t){let r=t[a];if(typeof r=="number")this.totals.hasOwnProperty(a)||(this.totals[a]=0),this.totals[a]=this.totals[a]+r*n;else{let s;a in this.totals?s=this.totals[a]:this.totals[a]=0;let i=G(()=>le(this.totals[a],L(r,n)));this.totals[a]=i,s!=null&&s.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 a=L(he(1,this.seen),this.totals[n]);t[n]=a,this.totals[n].dispose(),pn(t[n])}))}},Pv=class extends vu{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 s=this.history[r];for(let i=0;i<s.length;++i)if(typeof s[i]!="number"){let o=s[i];e.push(o.data()),t.push(r),n.push(i)}}let a=await Promise.all(e);for(let r=0;r<a.length;++r)this.history[t[r]][n[r]].dispose(),this.history[t[r]][n[r]]=a[r][0]}},zv=class extends vu{constructor(e,t){super();if(this.currentEpoch=0,this.nowFunc=e.nowFunc,this.nextFrameFunc=e.nextFrameFunc||Z3,this.yieldEvery=t||"auto",this.yieldEvery==="auto"&&(this.yieldEvery=nz),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=dP(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 a=[];this.yield!=null&&(await Ss(n),a.push(this.yield(e,t,n))),a.push(this.nextFrameFunc()),await Promise.all(a)}async onEpochBegin(e,t){this.currentEpoch=e,this.epochBegin!=null&&(await Ss(t),await this.epochBegin(e,t))}async onEpochEnd(e,t){let n=[];this.epochEnd!=null&&(await Ss(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 Ss(t),await this.batchBegin(e,t))}async onBatchEnd(e,t){let n=[];this.batchEnd!=null&&(await Ss(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 Ss(e),await this.trainBegin(e))}async onTrainEnd(e){this.trainEnd!=null&&(await Ss(e),await this.trainEnd(e))}};function Lv(e,t){return e==null&&(e={}),e instanceof vu?[e]:Array.isArray(e)&&e[0]instanceof vu?e:vt(e).map(n=>new zv(n,t))}var Va=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}`),Va.checkForDuplicate(t),Va.constructors[e]==null&&(Va.constructors[e]=[]),Va.constructors[e].push(t)}static checkForDuplicate(e){for(let t in Va.constructors)Va.constructors[+t].forEach(n=>{if(n===e)throw new H("Duplicate callback constructor.")})}static clear(){Va.constructors={}}static createCallbacks(e){let t=[];for(let n in Va.constructors){let a=+n;e>=a&&t.push(...Va.constructors[a])}return t.map(n=>new n)}};Va.constructors={};function Wv(e,t,n,a,r,s,i,o,l){let d=new Pv,u=[new az,...Va.createCallbacks(t)];e!=null&&u.push(...e),u.push(d);let p=new _v(u);return p.setParams({epochs:n,initialEpoch:a,samples:r,steps:s,batchSize:i,verbose:t,doValidation:o,metrics:l}),{callbackList:p,history:d}}function sr(e,t={},n=!1){return lp(e,ue.SerializationMap.getMap().classNameMap,t,"layer",n)}function O0(e,t){return G(()=>{e.dtype!=="float32"&&(e=pe(e,"float32"));let n=Ie(cp(e),t,!0),a=uu(n.shape,en()),r=An(Ar(n,a));return he(e,r)})}function yo(e,t){return G(()=>Dt(cp(ge(t,e)),-1))}function _0(e,t){return G(()=>Dt(jt(ge(t,e)),-1))}function wu(e,t){return G(()=>{let n=ge(e,t),a=Zn(jt(e),en(),Number.MAX_VALUE),r=jt(he(n,a));return L(100,Dt(r,-1))})}function rz(e,t){return G(()=>{let n=Zn(t,en(),Number.MAX_VALUE),a=la(le(1,n)),r=Zn(e,en(),Number.MAX_VALUE),s=la(le(1,r));return Dt(cp(ge(a,s)),-1)})}function sz(e,t){return G(()=>{let n=Ar(0,ge(1,L(e,t)));return Dt(cp(n),-1)})}function iz(e,t){return G(()=>{let n=Ar(0,ge(1,L(e,t)));return Dt(n,-1)})}function oz(e,t){return G(()=>{let n=Ie(L(e,t),-1),a=Rn(L(ge(1,e),t),-1);return Ar(0,le(1,ge(a,n)))})}function lz(e,t){return G(()=>{let n=Math.log(2),a=ge(t,e),r=ge(le(a,so(L(-2,a))),n);return Dt(r,-1)})}function fp(e,t,n=!1){return G(()=>{if(n)t=lo(t);else{let a=Ie(t,t.shape.length-1,!0);t=he(t,a)}return t=Zn(t,en(),1-en()),Tt(Ie(L(pe(e,"float32"),la(t)),t.shape.length-1))})}function P0(e,t,n=!1){return G(()=>{let a=pe(du(SP(e)),"int32");t=Zn(t,en(),1-en());let r=t.shape,s=V(tu(a,r[r.length-1]),r);return fp(s,t,n)})}function uz(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=Ja(t),a=Tt(jt(t));return le(ge(n,L(t,e)),Zd(oa(a)))})}function z0(e,t){return G(()=>{let n;return n=Zn(t,en(),1-en()),n=la(he(n,ge(1,n))),Dt(uz(e,n),-1)})}function dz(e,t){return G(()=>{let n=Zn(e,en(),1),a=Zn(t,en(),1);return Ie(L(e,la(he(n,a))),-1)})}function pz(e,t){return G(()=>{let n=la(le(en(),t));return Dt(ge(t,L(e,n)),-1)})}function Fy(e,t){return G(()=>{let n=O0(e,-1),a=O0(t,-1),r=L(n,a);return Tt(Ie(r,-1))})}var L0={meanSquaredError:yo,meanAbsoluteError:_0,meanAbsolutePercentageError:wu,meanSquaredLogarithmicError:rz,squaredHinge:sz,hinge:iz,categoricalHinge:oz,logcosh:lz,categoricalCrossentropy:fp,sparseCategoricalCrossentropy:P0,binaryCrossentropy:z0,kullbackLeiblerDivergence:dz,poisson:pz,cosineProximity:Fy};function Dy(e){if(typeof e=="string"){if(e in L0)return L0[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 $y(e,t){return G(()=>{let n=L(.5,da(t)),a=b0(Yn(t,n),e.dtype);return Dt(ia(e,a),-1)})}function Oy(e,t){return G(()=>b0(ia(ka(e,-1),ka(t,-1)),"float32"))}function Bv(e,t){return G(()=>pe(Ie(La(ia(e,1),ia(t,1))),"float32"))}function cz(e,t){return G(()=>pe(Ie(La(ia(e,1),ia(t,0))),"float32"))}function hz(e,t){return G(()=>pe(Ie(La(ia(e,0),ia(t,1))),"float32"))}function Vv(e,t){return G(()=>{let n=Bv(e,t),a=hz(e,t),r=le(n,a);return pe(Sn(Yn(r,0),he(n,r),0),"float32")})}function fz(e,t){return G(()=>{let n=Bv(e,t),a=cz(e,t),r=le(n,a);return pe(Sn(Yn(r,0),he(n,r),0),"float32")})}function Uv(e,t){return z0(e,t)}function jv(e,t){return e.rank===t.rank&&(e=st(e,[e.rank-1])),t=ka(t,-1),t.dtype!==e.dtype&&(t=pe(t,e.dtype)),pe(ia(e,t),"float32")}var mz=yo,gz=yo,yz=_0,Az=_0,xz=wu,bz=wu,_y=fp,vz=Fy,Gv=P0,W0={binaryAccuracy:$y,categoricalAccuracy:Oy,precision:Vv,categoricalCrossentropy:_y,sparseCategoricalCrossentropy:Gv,mse:mz,MSE:gz,mae:yz,MAE:Az,mape:xz,MAPE:bz,cosine:vz};function wz(e){if(typeof e=="string"&&e in W0)return W0[e];if(typeof e!="string"&&e!=null)return e;throw new H(`Unknown metric ${e}`)}function B0(e){if(br(e!==null,`Unknown LossOrMetricFn ${e}`),typeof e=="string")return e;{let t;for(let n of Object.keys(L0))if(L0[n]===e){t=n;break}if(t!==void 0)return t;for(let n of Object.keys(W0))if(W0[n]===e){t=n;break}return t!==void 0?t:e.name}}function kz(e){let t={Adagrad:()=>po.adagrad(.01),Adadelta:()=>po.adadelta(1,.95,en()),Adam:()=>po.adam(.001,.9,.999,en()),Adamax:()=>po.adamax(.002,.9,.999,en(),0),RMSProp:()=>po.rmsprop(.001,.9,0,en()),SGD:()=>po.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 Hv=1*1024*1024;function qv(e,t,n=!1){if(e==null||typeof e!="object"||Object.getPrototypeOf(e)!==Object.prototype||!Py(e))throw new Error("User-defined metadata is expected to be a JSON object, but is not.");if(n){let a=JSON.stringify(e);a.length>Hv&&console.warn(`User-defined metadata of model "${t}" is too large in size (length=${a.length} when serialized). It is not recommended to store such large objects in user-defined metadata. Please make sure its serialized length is <= ${Hv}.`)}}function Py(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"||!Py(e[n]))return!1;return!0}else if(Array.isArray(e)){for(let t of e)if(!Py(t))return!1;return!0}else return!1;else{let t=typeof e;return t==="string"||t==="number"||t==="boolean"}}function Iz(e,t,n,a=console.log){let r=Nz(e),s=["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 i;if(!r){s.push("Receives inputs"),i=[];for(let u in e.nodesByDepth)i.push(...e.nodesByDepth[u])}a("_".repeat(t)),V0(s,n,a),a("=".repeat(t));let o=e.layers;for(let u=0;u<o.length;++u)r?Tz(o[u],n,a):Cz(o[u],n,i,a),a((u===o.length-1?"=":"_").repeat(t));e.checkTrainableWeightsConsistency();let l=Sz(e),d=D0(e.nonTrainableWeights);a(`Total params: ${l+d}`),a(`Trainable params: ${l}`),a(`Non-trainable params: ${d}`),a("_".repeat(t))}function Sz(e){let t;return e.collectedTrainableWeights!=null?t=D0(e.collectedTrainableWeights):t=D0(e.trainableWeights),t}function Nz(e){let t=!0,n=[],a=[];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}a.push(...r)}if(t)for(let r of e.layers){let s=!1;for(let i of r.inboundNodes)if(a.indexOf(i)!==-1)if(s){t=!1;break}else s=!0;if(!t)break}return t}function V0(e,t,n=console.log){let a="";for(let r=0;r<e.length;++r)r>0&&(a=a.slice(0,a.length-1)+" "),a+=e[r],a=a.slice(0,t[r]),a+=" ".repeat(t[r]-a.length);n(a)}function Tz(e,t,n){let a;try{a=JSON.stringify(e.outputShape)}catch(o){a="multiple"}let r=e.name,s=e.getClassName(),i=[`${r} (${s})`,a,e.countParams().toString()];V0(i,t,n)}function Cz(e,t,n,a){let r;try{r=JSON.stringify(e.outputShape)}catch(u){r="multiple"}let s=[];for(let u of e.inboundNodes)if(!(n!=null&&n.length>0&&n.indexOf(u)===-1))for(let p=0;p<u.inboundLayers.length;++p){let c=u.inboundLayers[p].name,h=u.nodeIndices[p],f=u.tensorIndices[p];s.push(`${c}[${h}][${f}]`)}let i=e.name,o=e.getClassName(),l=s.length===0?"":s[0],d=[`${i} (${o})`,r,e.countParams().toString(),l];V0(d,t,a);for(let u=1;u<s.length;++u)V0(["","","",s[u]],t,a)}function Xv(e,t,n){return(e==="inboundNodes"||e==="outputLayers"||e==="inputLayers")&&t===0&&typeof n=="string"}function mp(e,t){if(e===null)return null;if(typeof e=="string")return ho(e);if(typeof e=="number"||typeof e=="boolean")return e;if(e instanceof Array){let n=[],a=e.length;for(let r=0;r<a;++r){let s=e[r];Xv(t,r,s)?n.push(s):n.push(mp(s,t))}return n}else{let n={};for(let a of Object.keys(e)){let r=e[a];if(a==="name"&&typeof r=="string")n[a]=r;else{let s=ho(a);n[s]=mp(r,s)}}return n}}function zy(e,t){if(e==null)return null;if(typeof e=="string")return Br(e);if(typeof e=="number"||typeof e=="boolean")return e;if(e instanceof Array){let n=[],a=e.length;for(let r=0;r<a;++r){let s=e[r];Xv(t,r,s)?n.push(s):n.push(zy(s,t))}return n}else{let n={};for(let a of Object.keys(e)){let r=e[a],s=Br(a);(a==="name"||a==="className")&&typeof r=="string"?n[s]=r:n[s]=zy(r,a)}return n}}var Ly="3.10.0";function Ez(e,t){if(e.dtype==null||e.dtype===t.dtype)return t;try{return pe(t,e.dtype)}catch(n){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 Ao=class{constructor(e){if(this.id2Value={},this.id2Mask={},this.name2Id={},e instanceof Ao)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]=Ez(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 rr){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 rr){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&&Q(this.id2Mask)}},Wy={},Kv={};function gp(e,t,n,a){let r=n==null?!1:n.training,s=Array.isArray(e),i=s?e:[e],o=i.map(f=>f.name),l=[],d=t.names();for(let f of o)d.indexOf(f)!==-1?l.push(t.getValue(f)):l.push(null);a!=null&&(a.maxNumTensors=-1/0,a.minNumTensors=1/0);let u=o.join(",")+"|"+t.names().join(","),p,c;if(Wy[u]==null){let f=Rz(i,t);p=f.sorted,c=f.recipientCounts,Wy[u]=p,Kv[u]=c}p=Wy[u],c={},r||Object.assign(c,Kv[u]);let h=new Ao(t);for(let f=0;f<p.length;++f){if(a!=null){let D=Dh().numTensors;D>a.maxNumTensors&&(a.maxNumTensors=D),D<a.minNumTensors&&(a.minNumTensors=D)}let m=p[f],g=m.sourceLayer;if(g instanceof bu)continue;let y=[],A=[],x=[],b=!1;for(let D of m.inputs){let O=h.getValue(D),F=h.getMask(D);y.push(O),A.push(F),F!=null&&(b=!0),r||(c[D.name]--,c[D.name]===0&&!t.hasKey(D)&&o.indexOf(D.name)===-1&&!O.isDisposed&&D.sourceLayer.stateful!==!0&&x.push(O))}b&&(n=n||{},n.mask=A[0]);let v=vt(g.apply(y,n)),k=null;g.supportsMasking&&(k=g.computeMask(y,A));let T=Fz(m),C=Array.isArray(T)?T:[T];for(let D=0;D<C.length;++D){h.hasKey(C[D])||h.add(C[D],v[D],Array.isArray(k)?k[0]:k);let O=o.indexOf(C[D].name);O!==-1&&(l[O]=v[D])}r||Q(x)}return h.disposeMasks(),s?l:l[0]}function Rz(e,t){w.assert(e!=null&&e.length>0,()=>"Expected at least one fetch, got none");let n=[],a={};if(e.length===1){let r=Zv(e[0],t);n=r.sorted,a=r.recipientMap}else{let r=new Set;for(let s of e){let{sorted:i,recipientMap:o}=Zv(s,t);for(let l of i)r.has(l.name)||(n.push(l),r.add(l.name));for(let l in o)a[l]==null&&(a[l]=new Set),o[l].forEach(d=>a[l].add(d))}}return{sorted:n,recipientCounts:Mz(a)}}function Mz(e){let t={};for(let n in e)t[n]=e[n].size;return t}function Zv(e,t){let n=new Set,a=[],r={};for(let o of t.names())n.add(o);let s=[],i=[];for(s.push(e);s.length>0;){let o=s[s.length-1];if(n.has(o.name)){s.pop();continue}let l=i[i.length-1]===s.length-1;if(o.inputs.length===0||l)s.pop(),a.push(o),n.add(o.name),l&&i.pop();else{i.push(s.length-1);for(let d of o.inputs)r[d.name]==null&&(r[d.name]=new Set),r[d.name].add(o.name),!n.has(d.name)&&s.push(d)}}return{sorted:a,recipientMap:r}}function Fz(e){let t;if(e.sourceLayer.inboundNodes.length===1)t=e.sourceLayer.output;else{let n=null;for(let a=0;a<e.sourceLayer.inboundNodes.length;++a)for(let r of e.sourceLayer.inboundNodes[a].outputTensors)if(r.id===e.id){n=a;break}t=e.sourceLayer.getOutputAt(n)}return t}var wr=class extends Qe{constructor(e){super({});if(this.containerNodes=new Set,this.name=e.name,this.name==null){let y=this.getClassName().toLowerCase();this.name=M0(y)}if(this.supportsMasking=!1,this.trainable_=!0,Array.isArray(e.inputs)?this.inputs=e.inputs.slice():this.inputs=[e.inputs],Array.isArray(e.outputs)?this.outputs=e.outputs.slice():this.outputs=[e.outputs],ws(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(y=>y.name)}`);ws(this.outputs).length!==this.outputs.length&&console.warn(`The list of outputs passed to the model is redundant. All outputs should only appear once. Found: ${this.outputs.map(y=>y.name)}`),this.inputLayers=[],this.inputLayersNodeIndices=[],this.inputLayersTensorIndices=[],this.outputLayers=[],this.outputLayersNodeIndices=[],this.outputLayersTensorIndices=[],this.layers=[],this.internalContainerRefs=[];for(let y of this.outputs){let A=y.sourceLayer,x=y.nodeIndex,b=y.tensorIndex;this.outputLayers.push(A),this.outputLayersNodeIndices.push(x),this.outputLayersTensorIndices.push(b)}for(let y of this.inputs){let A=y.sourceLayer,x=y.nodeIndex,b=y.tensorIndex;br(x===0,"input layer has >1 nodes"),br(b===0,"input layer has >1 tensors"),this.inputLayers.push(A),this.inputLayersNodeIndices.push(x),this.inputLayersTensorIndices.push(b)}this.inputNames=[],this.outputNames=[],this.feedInputShapes=[],this.feedInputNames=[],this.feedOutputNames=[];for(let y=0;y<this.inputLayers.length;y++){let A=this.inputLayers[y];if(!(A instanceof bu))throw new TypeError(`Input layers to a LayersModel must be InputLayer objects. Received inputs: ${e.inputs}. Input ${y} (0-based) originates from layer type ${A.getClassName()}.`);this.inputNames.push(A.name),this.feedInputShapes.push(A.batchInputShape),this.feedInputNames.push(A.name)}for(let y of this.outputLayers)this.outputNames.push(y.name);this.internalInputShapes=this.inputs.map(y=>y.shape),this.internalOutputShapes=this.outputs.map(y=>y.shape);let t={},n={},a={},r={},s={},i=[],o=(y,A,x,b,v,k)=>{(b==null||v==null||k==null)&&(b=y.sourceLayer,v=y.nodeIndex,k=y.tensorIndex);let T=b.inboundNodes[v];if(x.indexOf(T)!==-1)throw new tr(`The tensor ${y.name} at layer "${b.name}" is part of a cycle.`);if(A.indexOf(T)!==-1)return;this.containerNodes.add(wr.nodeKey(b,v)),b.id in s||(s[b.id]=Object.keys(s).length),x.indexOf(T)===-1&&x.push(T);let C=T.inboundLayers.length;for(let D=0;D<C;D++){let O=T.inputTensors[D],F=T.inboundLayers[D],S=T.nodeIndices[D],P=T.tensorIndices[D];o(O,A,x,F,S,P)}for(A.push(T);x.indexOf(T)>=0;)x.splice(x.indexOf(T),1);i.push(T)},l=[],d=[];for(let y of this.outputs)o(y,l,d);let u=i.slice().reverse();for(let y of u){n[y.id]=y,y.id in t||(t[y.id]=0);let A=t[y.id],x=a[y.outboundLayer.id]==null?0:a[y.outboundLayer.id];A=Math.max(A,x),a[y.outboundLayer.id]=A,r[y.outboundLayer.id]=y.outboundLayer,t[y.id]=A;for(let b=0;b<y.inboundLayers.length;b++){let v=y.inboundLayers[b],k=y.nodeIndices[b],T=v.inboundNodes[k],C=t[T.id]==null?0:t[T.id];t[T.id]=Math.max(A+1,C),n[T.id]=T}}let p={};for(let y in t){let A=t[y];A in p||(p[A]=[]),p[A].push(n[y])}let c={};for(let y in a){let A=a[y];A in c||(c[A]=[]),c[A].push(r[y])}let h=Object.keys(c).map(y=>parseInt(y,10)).sort(x0);this.layers=[];for(let y of h){let A=c[y];A.sort((x,b)=>{let v=s[x.id],k=s[b.id];return v<k?-1:v>k?1:0});for(let x of A)x instanceof wr&&this.internalContainerRefs.push(x),this.layers.push(x)}this.layersByDepth=c,h=Object.keys(p).map(y=>parseInt(y,10)).sort(x0);let f=this.inputs.slice(),m=[];for(let y of h)for(let A of p[y]){let x=A.outboundLayer;if(x!=null){for(let b of A.inputTensors)if(f.indexOf(b)===-1)throw new tr(`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 A.outputTensors)f.push(b);m.push(x.name)}}this.nodesByDepth=p;let g=this.layers.map(y=>y.name);for(let y of g){let A=g.filter(x=>x===y).length;if(A!==1)throw new tr(`The name "${y}" is used ${A} times in the model. All layer names should be unique. Layer names: `+JSON.stringify(g))}this.outboundNodes=[],this.inboundNodes=[],new $0({outboundLayer:this,inboundLayers:[],nodeIndices:[],tensorIndices:[],inputTensors:this.inputs,outputTensors:this.outputs,inputMasks:this.inputs.map(y=>null),outputMasks:this.outputs.map(y=>null),inputShapes:this.inputs.map(y=>y.shape),outputShapes:this.outputs.map(y=>y.shape)}),this.built=!0,this._refCount=1}assertNotDisposed(){if(this._refCount===0)throw new Error(`Container '${this.name}' is already disposed.`)}dispose(){this.assertNotDisposed();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={},a=0;for(let s of this.layers)for(let i of s.weights){if(n[i.originalName]!=null)throw new H(`Duplicate weight name: ${i.originalName}`);n[i.originalName]=i,a++}let r=[];for(let s in e){let i=s;if(n[s]==null){let o=s.split("/");i=o.slice(0,-2).concat([o[o.length-1]]).join("/")}if(n[i]!=null)r.push([n[i],e[s]]);else if(t)throw new H(`Provided weight data has no target variable: ${s}`);delete n[i]}if(t){let s=[];for(let i in n)s.push(i);if(s.length>0)throw new H(`${s.length} of ${a} weights are not set: ${s}`)}My(r)}updatedConfig(){let e=this.getConfig(),t={};return t.className=this.getClassName(),t.config=e,t.kerasVersion=`tfjs-layers ${Ly}`,t.backend="TensorFlow.js",t}toJSON(e,t=!0){let n=zy(this.updatedConfig());return t?JSON.stringify(n):n}call(e,t){return G(()=>{e=vt(e);let n=new Ao;for(let a=0;a<this.inputs.length;++a)n.add(this.inputs[a],e[a]);return gp(this.outputs,n,t)})}computeMask(e,t){return G(()=>{e=vt(e);let n;return t==null?n=co(null,e.length):n=vt(t),this.runInternalGraph(e,n)[1]})}computeOutputShape(e){let t=F0(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 i=0;i<t.length;i++){let o=this.inputLayers[i],l=t[i],d=o.name+"_0_0";n[d]=l}let a=Object.keys(this.nodesByDepth).map(i=>parseInt(i,10)).sort(x0);if(a.length>1)for(let i of a){let o=this.nodesByDepth[i];for(let l of o){let d=l.outboundLayer;if(this.inputLayers.map(f=>f.id).indexOf(d.id)!==-1)continue;let u=[];for(let f=0;f<l.inboundLayers.length;f++){let m=l.inboundLayers[f],g=l.nodeIndices[f],y=l.tensorIndices[f],A=`${m.name}_${g}_${y}`,x=n[A];u.push(x)}let p=d.computeOutputShape(Jn(u)),c=F0(p),h=d.inboundNodes.indexOf(l);for(let f=0;f<c.length;f++){let m=`${d.name}_${h}_${f}`;n[m]=c[f]}}}let r=[],s=[];for(let i=0;i<this.outputLayers.length;i++){let o=this.outputLayers[i],l=this.outputLayersNodeIndices[i],d=this.outputLayersTensorIndices[i],u=`${o.name}_${l}_${d}`;s.push(u)}for(let i=0;i<s.length;i++){let o=s[i];br(o in n),r.push(n[o])}return Jn(r)}runInternalGraph(e,t){t==null&&(t=co(null,e.length));let n={};for(let o=0;o<this.inputs.length;++o){let l=this.inputs[o],d=e[o],u=t[o];n[l.id]=[d,u]}let a=Object.keys(this.nodesByDepth).map(o=>parseInt(o,10)).sort(x0);for(let o of a){let l=this.nodesByDepth[o];for(let d of l){let u=d.outboundLayer,p=d.inputTensors,c=d.outputTensors,h=new Array;for(let f of p)f.id in n&&h.push(n[f.id]);if(h.length===p.length){let f={},m,g,y,A;if(d.callArgs!=null&&(f=d.callArgs),h.length===1){let[x,b]=h[0];f.mask==null&&(f.mask=b),y=vt(u.call(x,f)),A=vt(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),y=vt(u.call(m,f)),A=vt(u.computeMask(m,g));if(u.activityRegularizer)throw new Pe("LayersModel invocation with concrete Tensor value(s) in the presence of activity regularizer(s) is not supported yet.");for(let x=0;x<c.length;++x){let b=c[x],v=y[x],k=A[x];n[b.id]=[v,k]}}}}let r=[],s=[],i=[];for(let o of this.outputs){br(o.id in n,`Could not compute output ${o.name} : ${o.id}`);let[l,d]=n[o.id];i.push(l.shape),r.push(l),s.push(d)}return[r,s,i]}buildNodeConversionMap(e){let t={},n;for(let a of this.layers){n=a instanceof wr?1:0;for(let r=0;r<a.inboundNodes.length;r++){let s=wr.nodeKey(a,r);this.containerNodes.has(s)&&(t[s]=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 a=wr.nodeKey(t,n);this.containerNodes.has(a)&&e.push(...t.calculateLosses())}return e})}getConfig(){let e={name:this.name},t=this.buildNodeConversionMap(this.layers),n=[];for(let s of this.layers){let i=s.getClassName(),o=s.getConfig(),l=[];for(let u=0;u<s.inboundNodes.length;u++){let p=s.inboundNodes[u],c=wr.nodeKey(s,u),h={};if(this.containerNodes.has(c)){if(p.callArgs)try{JSON.stringify(p.callArgs),h=p.callArgs}catch(f){console.warn(`Layer ${s.name} was passed non-serializable keyword arguments: ${p.callArgs}. They will not be included in the serialized model (and thus will be missing at deserialization time).`),h={}}if(p.inboundLayers.length>0){let f=[];for(let m=0;m<p.inboundLayers.length;m++){let g=p.inboundLayers[m],y=p.nodeIndices[m],A=p.tensorIndices[m],x=wr.nodeKey(g,y),b=t[x];b==null&&(b=0),f.push([g.name,b,A,h])}l.push(f)}}}let d={};d.name=s.name,d.className=i,d.config=o,d.inboundNodes=l,n.push(d)}e.layers=n;let a=[];for(let s=0;s<this.inputLayers.length;s++){let i=this.inputLayers[s],o=this.inputLayersNodeIndices[s],l=wr.nodeKey(i,o);if(!this.containerNodes.has(l))continue;let d=t[l];d==null&&(d=0);let u=this.inputLayersTensorIndices[s];a.push([i.name,d,u])}e.inputLayers=a;let r=[];for(let s=0;s<this.outputLayers.length;s++){let i=this.outputLayers[s],o=this.outputLayersNodeIndices[s],l=wr.nodeKey(i,o);if(!this.containerNodes.has(l))continue;let d=t[l];d==null&&(d=0);let u=this.outputLayersTensorIndices[s];r.push([i.name,d,u])}return e.outputLayers=r,e}static fromConfig(e,t,n={},a=!1){let r={},s={};function i(m,g){m.name in s?s[m.name].push(g):s[m.name]=[g]}function o(m,g){let y=[],A;for(let x of g){let b=x[0],v=x[1],k=x[2];if(A=x[3]==null?{}:x[3],!(b in r)){i(m,g);return}let T=r[b];if(T.inboundNodes.length<=v){i(m,g);return}let C=T.inboundNodes[v];y.push(C.outputTensors[k])}y.length>0&&m.apply(Jn(y),A)}function l(m){let g=m.name,y=sr(m,t.customObjects!=null?t.customObjects:{});y.setFastWeightInitDuringBuild(a),r[g]=y,m.inboundNodes.forEach(A=>{if(!(A instanceof Array))throw new H(`Corrupted configuration, expected array for nodeData: ${A}`);i(y,A)})}let d=t.name,u=t.layers;for(let m of u)l(m);for(;!uP(s);)for(let m of u){let g=r[m.name];if(g.name in s){let y=s[g.name];delete s[g.name];for(let A of y)o(g,A)}}let p=[],c=[],h=t.inputLayers;for(let m of h){let g=m[0],y=m[1],A=m[2];br(g in r);let x=r[g].inboundNodes[y].outputTensors;p.push(x[A])}let f=t.outputLayers;for(let m of f){let g=m[0],y=m[1],A=m[2];br(g in r);let x=r[g].inboundNodes[y].outputTensors;c.push(x[A])}return new e({inputs:p,outputs:c,name:d})}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 Dz(e,t,n){let a=t.length;if(e==null||Array.isArray(e)&&e.length===0)return t.map(r=>null);if(a===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!==a)throw new Error(`Provided ${n} is an array of ${e.length} element(s), but the model has ${a} 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(s=>{s in e?r.push(e[s]):r.push(null)}),r}else throw new Error(`The model has multiple (${a}) outputs, so ${n} must be either an array with ${a} elements or an object with ${t} keys. Provided ${n} not understood: ${JSON.stringify(e)}`)}function Yv(e,t){return Dz(e,t,"classWeight")}async function Jv(e,t,n,a){if(t!=null||a!=null)throw new Error("Support sampleWeight is not implemented yet");if(n!=null){let r=G(()=>{if(e.shape.length===1)return Za(e);if(e.shape.length===2){if(e.shape[1]>1)return ka(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.`)}),s=Array.from(await r.data());Q(r);let i=[];return s.forEach(o=>{if(n[o]==null)throw new Error(`classWeight must contain all classes in the training data. The class ${o} exists in the data but not in classWeight`);i.push(n[o])}),Ht(i,"float32")}else return null}function $z(e,t){return L(e,t)}var Oz=32;function Qv(e,t){let n,a,r=t;n=r.xs,a=r.ys,w.assert(n!=null&&a!=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 s=e7("input",e.inputNames,n),i=e7("output",e.outputNames,a),o=s[0].shape[0];w.assert(s.length===e.inputs.length,()=>`LayersModel has ${e.inputs.length} inputs, but the dataset provides ${s.length} inputs. (Expected input keys: ${JSON.stringify(e.inputNames)})`),w.assert(i.length===e.outputs.length,()=>`LayersModel has ${e.outputs.length} outputs, but the dataset provides ${i.length} outputs. (Expected output keys: ${JSON.stringify(e.outputNames)})`);for(let l=0;l<s.length;l++)w.assert(s[l].shape[0]===o,()=>`Batch size mismatch: input ${e.inputNames[l]} has ${s[l].shape[0]}; expected ${o} based on input ${e.inputNames[0]}.`);for(let l=0;l<i.length;l++)w.assert(i[l].shape[0]===o,()=>`Batch size mismatch: output ${e.outputNames[l]} has ${i[l].shape[0]}; expected ${o} based on input ${e.inputNames[0]}.`);return{xs:s,ys:i}}function e7(e,t,n){if(n instanceof je)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 a=[];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}'.`);a.push(n[r])}return a}}function _z(e){if(e.length===3)throw new Pe("Validation with sample weights is not implemented yet.");return{xs:e[0],ys:e[1]}}async function Pz(e,t,n){let a=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(!a||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,s,i;if(r)if(t7(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=_z(n.validationData);s=g.xs,i=g.ys}let o=e.makeTrainFunction(),l=e.getDedupedMetricsNames(),d;r?d=l.slice().concat(l.map(g=>"val_"+g)):d=l.slice();let u=Lv(n.callbacks,n.yieldEvery),p=n.verbose==null?1:n.verbose,{callbackList:c,history:h}=Wv(u,p,n.epochs,null,null,zz(t,n),null,r,d);c.setModel(e),e.history=h,await c.onTrainBegin(),e.stopTraining_=!1;let f=n.initialEpoch==null?0:n.initialEpoch,m=await t.iterator();for(;f<n.epochs;){let g={};await c.onEpochBegin(f);let y=0,A=0;for(a||(m=await t.iterator());a?y<n.batchesPerEpoch:!0;){let x=await m.next();if(a&&x.done){console.warn(`You provided \`batchesPerEpoch\` as ${n.batchesPerEpoch}, but your dataset iterator ran out of data after ${y} 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}=Qv(e,x.value),k={};k.batch=A,k.size=b[0].shape[0],await c.onBatchBegin(A,k);let T=[];if(n.classWeight!=null){let O=Yv(n.classWeight,e.outputNames);for(let F=0;F<O.length;++F)T.push(await Jv(v[F],null,O[F]))}let C=b.concat(v).concat(T),D=o(C);Q(C);for(let O=0;O<l.length;++O){let F=l[O],S=D[O];k[F]=S,pn(S)}await c.onBatchEnd(A,k),$v(k),A++,y++}if(a?y>=n.batchesPerEpoch:x.done){if(r){let b;t7(n.validationData)?b=vt(await e.evaluateDataset(n.validationData,{batches:n.validationBatches})):b=vt(e.evaluate(s,i,{batchSize:n.validationBatchSize==null?Oz: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 c.onEpochEnd(f,g),f++,e.stopTraining_)break}return await c.onTrainEnd(),await e.history.syncData(),e.history}finally{e.isTraining=!1}}function zz(e,t){let n=null;return t.batchesPerEpoch!=null?n=t.batchesPerEpoch:Number.isFinite(e.size)&&(n=e.size),n}function t7(e){return typeof e.iterator=="function"}function Lz(e){return typeof e.next=="function"}async function Wz(e,t,n){n=n||{};let a=n.batches!=null,r=e.testFunction,s=[];if(n.verbose>0)throw new Pe("Verbose mode is not implemented yet.");w.assert(!a||n.batches>0&&Number.isInteger(n.batches),()=>`Test loop expects \`batches\` to be a positive integer, but received ${JSON.stringify(n.batches)}`);let i=Lz(t)?t:await t.iterator(),o=0,l=0;for(;a?l<n.batches:!0;){let d=await i.next();if(s=G(()=>{if(d.value){let{xs:u,ys:p}=Qv(e,d.value),c=u.concat(p),h=G(()=>r(c));if(Q(c),l===0)for(let m=0;m<h.length;++m)s.push(Ce(0));let f=c[0].shape[0];for(let m=0;m<h.length;++m){let g=h[m],y=s[m];s[m]=G(()=>le(s[m],L(f,g))),l>0&&Q(y)}Q(h),o+=f,++l}return s}),d.done){a&&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 d=0;d<s.length;++d){let u=s[d];s[d]=he(s[d],o),Q(u)}return Jn(s)}function By(e){w.assert(e>0&&Number.isInteger(e),()=>`batchSize is required to be a positive integer, but got ${e}`)}function yp(e,t,n){return e==null?[null]:Array.isArray(e)?e.map(a=>go(a,t,n-t)):go(e,t,n-t)}function Vy(e,t){return G(()=>e==null?null:Array.isArray(e)?e.map(n=>Vy(n,t)):Iv(e,t.dtype==="int32"?t:pe(t,"int32")))}function Uy(e,t){let n=[],a=0,r=null;for(;a<e;)r=a+t,r>=e&&(r=e),n.push([a,r]),a=r;return n}async function Bz(e,t,n,a,r,s,i,o,l,d,u,p,c,h,f){r==null&&(r=32),s==null&&(s=1),u==null&&(u=!0),c==null&&(c=0);let m=!1;if(l!=null&&d!=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"),y;g!=null&&(y=nr(0,g)),i==null&&(i=1);let{callbackList:A,history:x}=Wv(o,i,s,c,g,h,r,m,p);A.setModel(e),e.history=x,await A.onTrainBegin(),e.stopTraining_=!1;for(let b=c;b<s;++b){await A.onEpochBegin(b);let v={};if(h!=null)throw new Pe("stepsPerEpoch mode is not implemented yet.");{if(u==="batch")throw new Pe("batch shuffling is not implemneted yet");u&&w.shuffle(y);let k=Ht(y),T=Uy(g,r);for(let C=0;C<T.length;++C){let D={};if(await A.onBatchBegin(C,D),G(()=>{let O=T[C][0],F=T[C][1],S=go(k,O,F-O);D.batch=C,D.size=F-O;let P=Vy(n,S),_=t(P);for(let j=0;j<a.length;++j){let q=a[j],z=_[j];D[q]=z,pn(z)}if(C===T.length-1&&m){let j=e.testLoop(l,d,r);for(let q=0;q<a.length;++q){let z=a[q],X=j[q];pn(X),v["val_"+z]=X}}}),await A.onBatchEnd(C,D),$v(D),e.stopTraining_)break}k.dispose()}if(await A.onEpochEnd(b,v),e.stopTraining_)break}return await A.onTrainEnd(),await e.history.syncData(),e.history}async function Vz(e,t,n,a={}){if(e.isTraining)throw new Error("Cannot start training because another fit() call is ongoing.");e.isTraining=!0;let r,s,i,o,l,d,u;try{let p=a.batchSize==null?32:a.batchSize;By(p);let c=!1,h=await e.standardizeUserData(t,n,a.sampleWeight,a.classWeight,c,p);r=h[0],s=h[1],u=h[2];let f=!1,m;if(a.validationData!=null&&a.validationData.length>0){if(f=!0,a.validationData.length===2)i=a.validationData[0],o=a.validationData[1];else throw a.validationData.length===3?new Pe("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; ${a.validationData} is invalid.`);let k=!0,T=await e.standardizeUserData(i,o,null,null,k,p);l=T[0],d=T[1],m=l.concat(d)}else if(a.validationSplit!=null&&a.validationSplit>0&&a.validationSplit<1){f=!0;let k=Math.floor(r[0].shape[0]*(1-a.validationSplit)),T=r[0].shape[0];l=yp(r,k,T),r=yp(r,0,k),d=yp(s,k,T),s=yp(s,0,k),m=l.concat(d)}else a.validationSteps!=null&&(f=!0);let g=r.concat(s).concat(u);e.checkTrainableWeightsConsistency();let y=e.makeTrainFunction(),A=e.getDedupedMetricsNames(),x,b;f?(e.makeTestFunction(),x=e.testFunction,b=A.slice().concat(A.map(k=>"val_"+k))):(x=null,m=[],b=A.slice());let v=Lv(a.callbacks,a.yieldEvery);return await Bz(e,y,g,A,p,a.epochs,a.verbose,v,x,m,a.shuffle,b,a.initialEpoch,null,null)}finally{e.isTraining=!1,xo(r,t),xo(s,n),xo(l,i),xo(d,o),u!=null&&Q(u)}}function n7(e){let t=[];e instanceof je&&(e=[e]);for(let n=0;n<e.length;++n){let a=e[n];if(a.rank===1)t.push(pp(a,1));else{if(a.rank===0)throw new Error("Expected tensor to be at least 1D, but received a 0D tensor (scalar).");t.push(a)}}return t}function xo(e,t){if(e==null)return;let n=[];if(t instanceof je)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 s=t[r];n.push(s.id)}let a=[];if(e instanceof je)n.indexOf(e.id)===-1&&a.push(e);else if(Array.isArray(e))e.forEach(r=>{n.indexOf(r.id)===-1&&a.push(r)});else if(e!=null)for(let r in e){let s=e[r];n.indexOf(s.id)===-1&&a.push(s)}a.forEach(r=>{r.isDisposed||r.dispose()})}function Uz(e){return e instanceof je}function jy(e){return Array.isArray(e)}function a7(e){return!Uz(e)&&!jy(e)}function r7(e,t,n,a=!0,r=""){if(t==null||t.length===0){if(e!=null){let i=!1;if(jy(e)&&e.length>0)i=!0;else if(a7(e)){for(let o in e)if(e.hasOwnProperty(o)){i=!0;break}}else i=!0;if(i)throw new H(`Error when checking model ${r} expected no data, but got ${e}`)}return[]}if(e==null)return t.map(i=>null);let s;if(a7(e)){e=e,s=[];for(let i of t){if(e[i]==null)throw new H(`No data provided for "${i}". Need data for each key in: ${t}`);s.push(e[i])}}else if(jy(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}`);s=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}`);s=[e]}if(s=n7(s),n!=null)for(let i=0;i<t.length;++i){if(n[i]==null)continue;let o=s[i];if(o.shape.length!==n[i].length)throw new H(`Error when checking ${r}: expected ${t[i]} to have ${n[i].length} dimension(s). but got array with shape ${o.shape}`);for(let l=0;l<n[i].length;++l){if(l===0&&!a)continue;let d=o.shape[l],u=n[i][l];if(u!=null&&u>=0&&d!==u)throw new H(`${r} expected a batch of elements where each example has shape [${n[i].slice(1,n[i].length)}] (i.e.,tensor shape [*,${n[i].slice(1,n[i].length)}]) but the ${r} received an input with ${o.shape[0]} examples, each with shape [${o.shape.slice(1,o.shape.length)}] (tensor shape [${o.shape}])`)}}return s}function jz(e,t,n){let a=ws(e.map(s=>s.shape[0]));a.sort();let r=ws(t.map(s=>s.shape[0]));if(r.sort(),a.length>1)throw new H(`All input Tensors (x) should have the same number of samples. Got array shapes: ${JSON.stringify(e.map(s=>s.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(s=>s.shape))}`);if(a.length>0&&r.length>0&&!w.arraysEqual(a,r))throw new H(`Input Tensors should have the same number of samples as target Tensors. Found ${a[0]} input sample(s) and ${r[0]} target sample(s).`)}function Gz(e,t,n){let a=[yo,z0,fp];for(let r=0;r<e.length;++r){let s=e[r],i=t[r],o=n[r];if(i!=null){if(i===fp&&s.shape[s.shape.length-1]===1)throw new H(`You are passing a target array of shape ${s.shape} while using a loss 'categorical_crossentropy'. 'categorical_crossentropy'expects targets to be binary matrices (1s and 0s) of shape [samples, classes].`);if(a.indexOf(i)!==-1){let l=s.shape.slice(1),d=o.slice(1);for(let u=0;u<l.length;++u){let p=l[u],c=d[u];if(c!=null&&p!==c)throw new H(`A target Tensor with shape ${s.shape} was passed for an output of shape ${o}, while using a loss function that expects targets to have the same shape as the output.`)}}}}}function s7(e,t,n,a=!0,r=""){let s;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).`);s=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)}.`);s=[e]}if(n!=null)for(let i=0;i<t.length;++i){if(n[i]==null)continue;let o=s[i];if(o.shape.length!==n[i].length)throw new H(`Error when checking ${r}: expected ${t[i]} to have ${n[i].length} dimension(s), but got array with shape ${JSON.stringify(o.shape)}`);for(let l=0;l<n[i].length;++l){if(l===0&&!a)continue;let d=o.shape[l],u=n[i][l];if(u!=null&&u!==d)throw new H(`Error when checking ${r}: expected ${t[i]} to have shape ${JSON.stringify(n[i])} but got array with shape ${JSON.stringify(o.shape)}.`)}}}function Hz(e,t){if(e==null||Array.isArray(e)&&e.length===0)return t.map(a=>[]);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(a=>n);{let a=[];for(let r of t){let s=n.hasOwnProperty(r)?n[r]:[];Array.isArray(s)||(s=[s]),a.push(s)}return a}}var qz="layers-model",Vr=class extends wr{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).");Iz(this,e,t,n)}compile(e){if(e.loss==null&&(e.loss=[]),this.loss=e.loss,typeof e.optimizer=="string")this.optimizer_=kz(e.optimizer),this.isOptimizerOwned=!0;else{if(!(e.optimizer instanceof Lr))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 s in e.loss)if(this.outputNames.indexOf(s)===-1)throw new H(`Unknown entry in loss dictionary: "${s}". Only expected the following keys: ${this.outputNames}`);for(let s of this.outputNames)e.loss[s]==null&&console.warn(`Output "${s}" is missing from loss dictionary. We assume this was done on purpose, and we will not be expecting data to be passed to ${s} during training`),t.push(Dy(e.loss[s]))}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(s=>Dy(s))}else{let s=Dy(e.loss);this.outputs.forEach(i=>{t.push(s)})}this.lossFunctions=t,this.feedOutputNames=[],this.feedOutputShapes=[],this.feedLossFns=[];for(let s=0;s<this.outputs.length;++s){let i=this.internalOutputShapes[s],o=this.outputNames[s];this.feedOutputNames.push(o),this.feedOutputShapes.push(i),this.feedLossFns.push(this.lossFunctions[s])}let n=[];this.metrics=e.metrics,this.metricsNames=["loss"],this.metricsTensors=[],mo("loss",()=>{for(let s=0;s<this.outputs.length;++s){if(n.indexOf(s)!==-1)continue;let i=this.lossFunctions[s];this.outputs.length>1&&(this.metricsTensors.push([i,s]),this.metricsNames.push(this.outputNames[s]+"_loss"))}});let a=Hz(e.metrics,this.outputNames),r=(s,i,o)=>{this.outputNames.length>1&&(i=this.outputNames[s]+"_"+i),this.metricsNames.push(i),this.metricsTensors.push([o,s])};mo("metric",()=>{for(let s=0;s<this.outputs.length;++s){if(n.indexOf(s)!==-1)continue;let i=a[s];(o=>{let l="",d,u,p;for(let c of o){if(typeof c=="string"&&["accuracy","acc","crossentropy","ce"].indexOf(c)!==-1){let f=this.internalOutputShapes[s];f[f.length-1]===1||this.lossFunctions[s]===z0?["accuracy","acc"].indexOf(c)!==-1?u=$y:["crossentropy","ce"].indexOf(c)!==-1&&(u=Uv):this.lossFunctions[s]===P0?["accuracy","acc"].indexOf(c)!==-1?u=jv:["crossentropy","ce"].indexOf(c)!==-1&&(u=Gv):["accuracy","acc"].indexOf(c)!==-1?u=Oy:["crossentropy","ce"].indexOf(c)!==-1&&(u=_y);let m;["accuracy","acc"].indexOf(c)!==-1?m="acc":["crossentropy","ce"].indexOf(c)!==-1&&(m="ce"),p=u,d=l+m}else p=wz(c),d=l+B0(c);let h;mo(d,()=>{h=p}),r(s,d,h)}})(i)}}),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 a=n.batchSize==null?32:n.batchSize;By(a);let r=!0,s=this.standardizeUserDataXY(e,t,r,a);try{let i=s[0].concat(s[1]);this.makeTestFunction();let o=this.testFunction,l=this.testLoop(o,i,a,n.verbose,n.steps);return Jn(l)}finally{xo(s[0],e),xo(s[1],t)}}async evaluateDataset(e,t){return this.makeTestFunction(),Wz(this,e,t)}checkNumSamples(e,t,n,a="steps"){let r;if(n!=null){if(r=null,t!=null)throw new H(`If ${a} 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 ${a} 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),a=n?t:[t],r=this.retrieveSymbolicTensors(a),s=new Ao;if(e instanceof je&&(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 o=0;o<this.inputs.length;++o)s.add(this.inputs[o],e[o])}else for(let o of this.inputs){let l=e[o.name];if(l==null)throw new H(`No value is provided for the model's input ${o.name}`);s.add(o,l)}let i=gp(r,s);return n?i:i[0]}retrieveSymbolicTensors(e){let t=co(null,e.length),n=e.length;for(let a of this.layers){let r=Array.isArray(a.output)?a.output:[a.output],s=r.map(i=>i.name);for(let i=0;i<e.length;++i){let o=s.indexOf(e[i]);if(o!==-1&&(t[i]=r[o],n--),n===0)break}if(n===0)break}if(n>0){let a=[];throw t.forEach((r,s)=>{r==null&&a.push(e[s])}),new H(`Cannot find SymbolicTensors for output name(s): ${JSON.stringify(a)}`)}return t}predictLoop(e,t=32,n=!1){return G(()=>{let a=this.checkNumSamples(e);if(n)throw new Pe("Verbose predictLoop() is not implemented yet.");let r=Uy(a,t),s=this.outputs.map(i=>[]);for(let i=0;i<r.length;++i)G(()=>{let o=r[i][0],l=r[i][1],d=yp(e,o,l),u=[];if(Array.isArray(d))for(let c=0;c<d.length;++c)u.push({key:this.inputs[c],value:d[c]});else u.push({key:this.inputs[0],value:d});let p=new Ao(u);return gp(this.outputs,p)}).forEach((o,l)=>s[l].push(o));return Jn(s.map(i=>mt(i,0)))})}predict(e,t={}){let n=n7(e);s7(n,this.inputNames,this.feedInputShapes,!1);try{let a=t.batchSize==null?32:t.batchSize;return By(a),this.predictLoop(n,a)}finally{xo(n,e)}}predictOnBatch(e){s7(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,a){if(this.optimizer_==null)throw new tr("You must compile a model before training/testing. Use LayersModel.compile(modelCompileArgs).");let r=[];for(let s=0;s<this.feedOutputShapes.length;++s){let i=this.feedOutputShapes[s];this.feedLossFns[s]===P0?r.push(i.slice(0,i.length-1).concat([1])):r.push(i)}if(e=r7(e,this.feedInputNames,this.feedInputShapes,!1,"input"),t=r7(t,this.feedOutputNames,r,!1,"target"),jz(e,t,null),Gz(t,this.feedLossFns,this.feedOutputShapes),this.stateful&&a!=null&&a>0&&e[0].shape[0]%a!=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 ${a}. Found: ${e[0].shape[0]} sample(s).`);return[e,t]}async standardizeUserData(e,t,n,a,r=!0,s){let[i,o]=this.standardizeUserDataXY(e,t,r,s);if(n!=null)throw new Error("sample weight is not supported yet.");let l=null;if(a!=null){let d=Yv(a,this.outputNames);l=[];for(let u=0;u<d.length;++u)l.push(await Jv(o[u],null,d[u]))}return[i,o,l]}testLoop(e,t,n,a=0,r){return G(()=>{let s=this.checkNumSamples(t,n,r,"steps"),i=[];if(a>0)throw new Pe("Verbose mode is not implemented yet.");if(r!=null)throw new Pe("steps mode in testLoop() is not implemented yet");{let o=Uy(s,n),l=Ht(nr(0,s));for(let d=0;d<o.length;++d){let u=o[d][0],p=o[d][1],c=go(l,u,p-u),h=Vy(t,c),f=e(h);if(d===0)for(let m=0;m<f.length;++m)i.push(Ce(0));for(let m=0;m<f.length;++m){let g=f[m];i[m]=le(i[m],L(p-u,g))}}for(let d=0;d<i.length;++d)i[d]=he(i[d],s)}return i})}getDedupedMetricsNames(){let e=this.metricsNames,t=[];for(let n=0;n<e.length;++n){let a=e[n],r=a;cv(e,a)>1&&(r+=`_${cv(e.slice(0,n),a)}`),t.push(r)}return t}makeTrainFunction(){return e=>{let t=[],n=e.slice(0,this.inputs.length),a=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),s=[],i=()=>{let d=[];for(let h=0;h<this.inputs.length;++h)d.push({key:this.inputs[h],value:n[h]});let u=new Ao(d),p=gp(this.outputs,u,{training:!0}),c;for(let h=0;h<this.lossFunctions.length;++h){let f=this.lossFunctions[h](a[h],p[h]);r[h]!=null&&(f=$z(f,r[h]));let m=Dt(f);t.push(m),h===0?c=f:c=le(c,f)}for(let h=0;h<this.metricsTensors.length;++h){let f;if(this.outputs.length>1&&h<this.outputs.length)f=t[h];else{let m=this.metricsTensors[h][0],g=this.metricsTensors[h][1];f=Dt(m(a[g],p[g]))}pn(f),s.push(f)}return c=Dt(c),this.calculateLosses().forEach(h=>{c=le(c,h)}),c},o=this.collectedTrainableWeights.map(d=>d.read()),l=!0;return[this.optimizer_.minimize(i,l,o)].concat(s)}}makeTestFunction(){this.testFunction=e=>G(()=>{let t=[],n,a=e.slice(0,this.inputs.length),r=e.slice(this.inputs.length,this.inputs.length+this.outputs.length),s=[];for(let l=0;l<this.inputs.length;++l)s.push({key:this.inputs[l],value:a[l]});let i=new Ao(s),o=gp(this.outputs,i);for(let l=0;l<this.lossFunctions.length;++l){let d=this.lossFunctions[l],u=Dt(d(r[l],o[l]));l===0?n=u:n=le(n,u),t.push(n)}for(let l=0;l<this.metricsTensors.length;++l){let d=this.metricsTensors[l][0],u=this.metricsTensors[l][1],p=Dt(d(r[u],o[u]));t.push(p)}return t})}async fit(e,t,n={}){return Vz(this,e,t,n)}async fitDataset(e,t){return Pz(this,e,t)}async trainOnBatch(e,t){let n=await this.standardizeUserData(e,t),a=n[0],r=n[1],s=this.makeTrainFunction()(a.concat(r)),i=[];for(let o of s){let l=await o.data();i.push(l[0])}return Q(s),Jn(i)}getNamedWeights(e){let t=[],n=e!=null&&e.trainableOnly,a=n?this.trainableWeights:this.weights,r=this.getWeights(n);for(let s=0;s<a.length;++s)n&&!a[s].trainable||t.push({name:a[s].originalName,tensor:r[s]});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=Dh().numTensors;this.optimizer_.dispose(),e.numDisposedVariables+=t-Dh().numTensors}return e}getLossIdentifiers(){let e;if(typeof this.loss=="string")e=Br(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=>Br(t))}else{let t=Object.keys(this.loss);e={};let n=this.loss;for(let a of t)if(typeof n[a]=="string")e[a]=Br(n[a]);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[Br(B0(this.metrics))];if(Array.isArray(this.metrics))return this.metrics.map(e=>Br(B0(e)));{let e={};for(let t in this.metrics)e[t]=Br(B0(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=mp(e.optimizer_config),n=sr(t),a;if(typeof e.loss=="string")a=ho(e.loss);else if(Array.isArray(e.loss))a=e.loss.map(s=>ho(s));else if(e.loss!=null){a={};for(let s in e.loss)a[s]=ho(e.loss[s])}let r;if(Array.isArray(e.metrics))r=e.metrics.map(s=>ho(s));else if(e.metrics!=null){r={};for(let s in e.metrics)r[s]=ho(e.metrics[s])}this.compile({loss:a,metrics:r,optimizer:n})}async save(e,t){if(typeof e=="string"){let i=Xn.getSaveHandlers(e);if(i.length===0)throw new H(`Cannot find any save handlers for URL '${e}'`);if(i.length>1)throw new H(`Found more than one (${i.length}) save handlers for URL '${e}'`);e=i[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 Xn.encodeWeights(this.getNamedWeights(t)),a=!1,r=null,s={modelTopology:this.toJSON(r,a),format:qz,generatedBy:`TensorFlow.js tfjs-layers v${Ly}`,convertedBy:null};if((t==null?!1:t.includeOptimizer)&&this.optimizer!=null){s.trainingConfig=this.getTrainingConfig();let i="optimizer",{data:o,specs:l}=await Xn.encodeWeights(await this.optimizer.getWeights(),i);n.specs.push(...l),n.data=Xn.concatenateArrayBuffers([n.data,o])}if(this.userDefinedMetadata!=null){let i=!0;qv(this.userDefinedMetadata,this.name,i),s.userDefinedMetadata=this.userDefinedMetadata}return s.weightData=n.data,s.weightSpecs=n.specs,e.save(s)}setUserDefinedMetadata(e){qv(e,this.name),this.userDefinedMetadata=e}getUserDefinedMetadata(){return this.userDefinedMetadata}};Vr.className="Model";ue.registerClass(Vr);var i7=class extends Vr{};i7.className="Functional";ue.registerClass(i7);async function Xz(e,t){"modelTopology"in e||(e={modelTopology:e}),e=e;let n=e.modelTopology;n.model_config!=null&&(n=n.model_config);let a=mp(n),r=sr(a,t);if(e.weightsManifest!=null){let s=await Xn.loadWeights(e.weightsManifest,e.pathPrefix,r.weights.map(o=>o.originalName)),i={};for(let o of r.weights)i[o.originalName]=s[o.originalName];r.loadWeights(i),Q(s)}return r}async function Kz(e,t){if(t==null&&(t={}),typeof e=="string"){let n=Xn.getLoadHandlers(e,t);if(n.length===0)n.push(Xn.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 Zz(e,void 0,t)}async function Zz(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 a=await e.load(),r=a.modelTopology;r.model_config!=null&&(r=r.model_config);let s=n.strict==null?!0:n.strict,i=a.weightData!=null&&a.weightSpecs!=null&&s,o=sr(mp(r),t,i),l=a.trainingConfig;if(l!=null&&o.loadTrainingConfig(l),a.userDefinedMetadata!=null&&o.setUserDefinedMetadata(a.userDefinedMetadata),a.weightData!=null){if(a.weightSpecs==null)throw new H("LayersModel artifacts contains weight data, but not weight specs. Therefore loading of weights cannot proceed.");let{modelWeights:d,optimizerWeights:u}=Yz(a.weightData,a.weightSpecs);o.loadWeights(d,s),o.optimizer!=null&&u.length>0&&await o.optimizer.setWeights(u),Q(d),Q(u.map(p=>p.tensor))}return o}function Yz(e,t){let n=Xn.decodeWeights(e,t),a={},r=[];return t.forEach(s=>{s.group==="optimizer"?r.push({name:s.name,tensor:n[s.name]}):a[s.name]=n[s.name]}),{modelWeights:a,optimizerWeights:r}}var ku=class extends Vr{constructor(e){super({inputs:[],outputs:[]});if(e=e||{},this.trainable=!0,this.built=!1,this.name=e.name!=null?e.name:M0("sequential_"),e.layers!=null)for(let t of e.layers)this.add(t)}checkShape(e){if(e.inboundNodes[0].outputTensors[0].shape.some(t=>t<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 ku||e instanceof Vr,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 a=Dv({batchShape:e.batchInputShape,dtype:e.dtype,name:e.name+"_input"});e.apply(a)}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 $0({outboundLayer:this,inboundLayers:[],nodeIndices:[],tensorIndices:[],inputTensors:this.inputs,outputTensors:this.outputs,inputMasks:co(null,this.inputs.length),outputMasks:[null],inputShapes:this.inputs.map(a=>a.shape),outputShapes:this.outputs[0].shape})}else{let a=e.apply(this.outputs[0]);if(Array.isArray(a))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=[a],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(pt(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 Vr({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 tr("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 tr("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 tr("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 tr("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={},a=!1){let r,s={};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,s=t;let i=new e(s);if(!(i instanceof ku))throw new Pe(`Sequential.fromConfig called on non-Sequential input: ${i}`);for(let o of r){let l=sr(o,void 0,a);a&&l.setFastWeightInitDuringBuild(!0),i.add(l)}return i}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}}};ku.className="Sequential";ue.registerClass(ku);function Jz(e){return new Vr(e)}function Qz(e){return new ku(e)}function eL(e,t){return t==null&&(t={}),Kz(e,t)}function o7(e){return Dv(e)}function tL(e,t){Va.registerCallbackConstructor(e,t)}var ea=class extends ue.Serializable{getConfig(){return{}}},l7=class extends ea{apply(e,t=1){return TP(e,t)}};l7.className="elu";ue.registerClass(l7);var u7=class extends ea{apply(e){return Qh(e)}};u7.className="selu";ue.registerClass(u7);var d7=class extends ea{apply(e){return Ja(e)}};d7.className="relu";ue.registerClass(d7);var p7=class extends ea{apply(e){return G(()=>pu(6,Ja(e)))}};p7.className="relu6";ue.registerClass(p7);var c7=class extends ea{apply(e){return e}};c7.className="linear";ue.registerClass(c7);var h7=class extends ea{apply(e){return Kn(e)}};h7.className="sigmoid";ue.registerClass(h7);var f7=class extends ea{apply(e){return EP(e)}};f7.className="hardSigmoid";ue.registerClass(f7);var m7=class extends ea{apply(e){return so(e)}};m7.className="softplus";ue.registerClass(m7);var g7=class extends ea{apply(e){return CP(e)}};g7.className="softsign";ue.registerClass(g7);var y7=class extends ea{apply(e){return no(e)}};y7.className="tanh";ue.registerClass(y7);var Gy=class extends ea{apply(e,t=-1){return lo(e,t)}};Gy.className="softmax";ue.registerClass(Gy);var A7=class extends ea{apply(e,t=-1){return Hh(e,t)}};A7.className="logSoftmax";ue.registerClass(A7);var x7=class extends ea{apply(e,t=1){return G(()=>L(Kn(L(e,t)),e))}};x7.className="swish";ue.registerClass(x7);var b7=class extends ea{apply(e){return G(()=>L(e,no(so(e))))}};b7.className="mish";ue.registerClass(b7);function Ns(e){return e.getClassName()}function Hy(e,t={}){return lp(e,ue.SerializationMap.getMap().classNameMap,t,"activation")}function Ts(e){if(e==null){let t={};return t.className="linear",t.config={},Hy(t)}if(typeof e=="string"){let t={};return t.className=e,t.config={},Hy(t)}else return e instanceof ea?e:Hy(e)}function qy(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 v7=class extends ue.Serializable{},Ap=class extends v7{constructor(e){super();qy(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=Gt([1]);return this.hasL1&&(t=le(t,Ie(L(this.l1,jt(e))))),this.hasL2&&(t=le(t,Ie(L(this.l2,cp(e))))),V(t,[])})}getConfig(){return{l1:this.l1,l2:this.l2}}static fromConfig(e,t){return new e({l1:t.l1,l2:t.l2})}};Ap.className="L1L2";ue.registerClass(Ap);function nL(e){return qy(e),new Ap({l1:e!=null?e.l1:null,l2:0})}function aL(e){return qy(e),new Ap({l2:e!=null?e.l2:null,l1:0})}var w7={l1l2:"L1L2"};function gt(e){return dy(e)}function k7(e,t={}){return lp(e,ue.SerializationMap.getMap().classNameMap,t,"regularizer")}function Et(e){if(e==null)return null;if(typeof e=="string"){let t={className:e in w7?w7[e]:e,config:{}};return k7(t)}else return e instanceof v7?e:k7(e)}var Xy=class extends Qe{constructor(e){super(e==null?{}:e);this.supportsMasking=!0,e!=null&&(this.maxValue=e.maxValue)}call(e,t){e=Le(e);let n=Ja(e);return this.maxValue!=null&&(n=Zn(n,0,this.maxValue)),n}computeOutputShape(e){return e}getConfig(){let e={maxValue:this.maxValue},t=super.getConfig();return Object.assign(e,t),e}};Xy.className="ReLU";ue.registerClass(Xy);var Ky=class extends Qe{constructor(e){super(e==null?{}:e);this.DEFAULT_ALPHA=.3,e==null&&(e={}),this.alpha=e.alpha==null?this.DEFAULT_ALPHA:e.alpha}call(e,t){let n=Le(e);return Kd(n,this.alpha)}computeOutputShape(e){return e}getConfig(){let e={alpha:this.alpha},t=super.getConfig();return Object.assign(e,t),e}};Ky.className="LeakyReLU";ue.registerClass(Ky);var Zy=class extends Qe{constructor(e){super(e==null?{}:e);if(this.DEFAULT_ALPHA_INITIALIZER="zeros",e==null&&(e={}),this.supportsMasking=!0,this.alphaInitializer=Ct(e.alphaInitializer||this.DEFAULT_ALPHA_INITIALIZER),this.alphaRegularizer=Et(e.alphaRegularizer),this.alphaConstraint=nn(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=pt(e);let t=e.slice(1);if(this.sharedAxes!=null)for(let a of this.sharedAxes)t[a-1]=1;this.alpha=this.addWeight("alpha",t,"float32",this.alphaInitializer,this.alphaRegularizer,!0,this.alphaConstraint);let n={};if(this.sharedAxes!=null)for(let a=1;a<e.length;++a)n[a]=e[a];this.inputSpec=[new qt({ndim:e.length,axes:n})],this.built=!0}call(e,t){return e=Le(e),tp(e,this.alpha.read())}getConfig(){let e={alphaInitializer:$t(this.alphaInitializer),alphaRegularizer:gt(this.alphaRegularizer),alphaConstraint:tn(this.alphaConstraint),sharedAxes:this.sharedAxes},t=super.getConfig();return Object.assign(e,t),e}};Zy.className="PReLU";ue.registerClass(Zy);var Yy=class extends Qe{constructor(e){super(e==null?{}:e);if(this.DEFAULT_ALPHA=1,e==null&&(e={}),e.alpha!=null&&e.alpha!==this.DEFAULT_ALPHA)throw new Pe(`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 lu(n)}computeOutputShape(e){return e}getConfig(){let e={alpha:this.alpha},t=super.getConfig();return Object.assign(e,t),e}};Yy.className="ELU";ue.registerClass(Yy);var Jy=class extends Qe{constructor(e){super(e==null?{}:e);this.DEFAULT_THETA=1,e==null&&(e={}),this.theta=e.theta==null?this.DEFAULT_THETA:e.theta}call(e,t){let n=Le(e);return L(n,pe(Yn(n,this.theta),"float32"))}computeOutputShape(e){return e}getConfig(){let e={theta:this.theta},t=super.getConfig();return Object.assign(e,t),e}};Jy.className="ThresholdedReLU";ue.registerClass(Jy);var Qy=class extends Qe{constructor(e){super(e==null?{}:e);this.DEFAULT_AXIS=1,e==null&&(e={}),this.softmax=new Gy().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}};Qy.className="Softmax";ue.registerClass(Qy);function Iu(e,t,n){if(typeof e=="number")return co(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 a=0;a<t;++a){let r=e[a];if(!kP(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 ir(e,t,n,a,r=1){if(e==null)return e;let s=t+(t-1)*(r-1),i;return n==="same"?i=e:i=e-s+1,Math.floor((i+a-1)/a)}function kr(e,t,n,a){if(e==null)return null;if(a==="valid")e=e*t+Is([n-t,0]);else if(a==="same")e=e*t;else throw new H(`Unsupport padding mode: ${a}.`);return e}function eA(e,t){return G(()=>(Bt(t),t==="channelsFirst"?Ze(e,[0,2,3,1]):e))}function I7(e,t){return G(()=>(Bt(t),t==="channelsFirst"?Ze(e,[0,2,3,4,1]):e))}function rL(e,t,n,a=1,r="valid",s,i=1){return G(()=>{if(s==null&&(s=er()),Bt(s),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(s==="channelsFirst"&&(e=Ze(e,[0,2,1])),r==="causal")throw new Pe("The support for CAUSAL padding mode in conv1dWithBias is not implemented yet.");let o=Lh(e,t,a,r==="same"?"same":"valid","NWC",i);return n!=null&&(o=ar(o,n)),o})}function S7(e,t,n,a=[1,1],r="valid",s,i,o=null){return G(()=>{if(s==null&&(s=er()),Bt(s),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=eA(e,s);if(r==="causal")throw new Pe("The support for CAUSAL padding mode in conv1dWithBias is not implemented yet.");return l=vs.conv2d({x:l,filter:t,strides:a,pad:r==="same"?"same":"valid",dilations:i,dataFormat:"NHWC",bias:n,activation:o}),s==="channelsFirst"&&(l=Ze(l,[0,3,1,2])),l})}function sL(e,t,n,a=[1,1,1],r="valid",s,i){return G(()=>{if(s==null&&(s=er()),Bt(s),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 o=I7(e,s);if(r==="causal")throw new Pe("The support for CAUSAL padding mode in conv3dWithBias is not implemented yet.");return o=Mg(o,t,a,r==="same"?"same":"valid","NDHWC",i),n!=null&&(o=ar(o,n)),s==="channelsFirst"&&(o=Ze(o,[0,4,1,2,3])),o})}var tA=class extends Qe{constructor(e,t){super(t);if(this.bias=null,this.DEFAULT_KERNEL_INITIALIZER="glorotNormal",this.DEFAULT_BIAS_INITIALIZER="zeros",tA.verifyArgs(t),this.rank=e,hn(this.rank,"rank"),this.rank!==1&&this.rank!==2&&this.rank!==3)throw new Pe(`Convolution layer for rank other than 1, 2, or 3 (${this.rank}) is not implemented yet.`);if(this.kernelSize=Iu(t.kernelSize,e,"kernelSize"),this.strides=Iu(t.strides==null?1:t.strides,e,"strides"),this.padding=t.padding==null?"valid":t.padding,Na(this.padding),this.dataFormat=t.dataFormat==null?"channelsLast":t.dataFormat,Bt(this.dataFormat),this.activation=Ts(t.activation),this.useBias=t.useBias==null?!0:t.useBias,this.biasInitializer=Ct(t.biasInitializer||this.DEFAULT_BIAS_INITIALIZER),this.biasConstraint=nn(t.biasConstraint),this.biasRegularizer=Et(t.biasRegularizer),this.activityRegularizer=Et(t.activityRegularizer),this.dilationRate=Iu(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(br("kernelSize"in e,"required key 'kernelSize' not in config"),typeof e.kernelSize!="number"&&!cy(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:Ns(this.activation),useBias:this.useBias,biasInitializer:$t(this.biasInitializer),biasRegularizer:gt(this.biasRegularizer),activityRegularizer:gt(this.activityRegularizer),biasConstraint:tn(this.biasConstraint)},t=super.getConfig();return Object.assign(e,t),e}},xp=class extends tA{constructor(e,t){super(e,t);this.kernel=null,xp.verifyArgs(t),this.filters=t.filters,hn(this.filters,"filters"),this.kernelInitializer=Ct(t.kernelInitializer||this.DEFAULT_KERNEL_INITIALIZER),this.kernelConstraint=nn(t.kernelConstraint),this.kernelRegularizer=Et(t.kernelRegularizer)}build(e){e=pt(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],a=this.kernelSize.concat([n,this.filters]);this.kernel=this.addWeight("kernel",a,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,a=this.bias==null?null:this.bias.read(),r=fv(this.activation.getClassName());if(r!=null&&this.rank===2)n=S7(e,this.kernel.read(),a,this.strides,this.padding,this.dataFormat,this.dilationRate,r);else{if(this.rank===1)n=rL(e,this.kernel.read(),a,this.strides[0],this.padding,this.dataFormat,this.dilationRate[0]);else if(this.rank===2)n=S7(e,this.kernel.read(),a,this.strides,this.padding,this.dataFormat,this.dilationRate);else if(this.rank===3)n=sL(e,this.kernel.read(),a,this.strides,this.padding,this.dataFormat,this.dilationRate);else throw new Pe("convolutions greater than 3D are not implemented yet.");this.activation!=null&&(n=this.activation.apply(n))}return n})}computeOutputShape(e){e=pt(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 s=ir(n[r],this.kernelSize[r],this.padding,this.strides[r],typeof this.dilationRate=="number"?this.dilationRate:this.dilationRate[r]);t.push(s)}let a=[e[0]];return this.dataFormat==="channelsLast"?(a=a.concat(t),a.push(this.filters)):(a.push(this.filters),a=a.concat(t)),a}getConfig(){let e={filters:this.filters,kernelInitializer:$t(this.kernelInitializer),kernelRegularizer:gt(this.kernelRegularizer),kernelConstraint:tn(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)}`)}},bp=class extends xp{constructor(e){super(2,e);bp.verifyArgs(e)}getConfig(){let e=super.getConfig();return delete e.rank,e}static verifyArgs(e){if(typeof e.kernelSize!="number"&&!cy(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)}.`)}};bp.className="Conv2D";ue.registerClass(bp);var vp=class extends xp{constructor(e){super(3,e);vp.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)}.`)}};vp.className="Conv3D";ue.registerClass(vp);var nA=class extends bp{constructor(e){super(e);if(this.inputSpec=[new qt({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=pt(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],a=this.kernelSize.concat([this.filters,n]);this.kernel=this.addWeight("kernel",a,"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 qt({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 a=n.shape,r=a[0],s,i;this.dataFormat==="channelsFirst"?(s=2,i=3):(s=1,i=2);let o=a[s],l=a[i],d=this.kernelSize[0],u=this.kernelSize[1],p=this.strides[0],c=this.strides[1],h=kr(o,p,d,this.padding),f=kr(l,c,u,this.padding),m=[r,h,f,this.filters];this.dataFormat!=="channelsLast"&&(n=Ze(n,[0,2,3,1]));let g=Wh(n,this.kernel.read(),m,this.strides,this.padding);return this.dataFormat!=="channelsLast"&&(g=Ze(g,[0,3,1,2])),this.bias!=null&&(g=ar(g,this.bias.read(),this.dataFormat)),this.activation!=null&&(g=this.activation.apply(g)),g})}computeOutputShape(e){e=pt(e);let t=e.slice(),n,a,r;this.dataFormat==="channelsFirst"?(n=1,a=2,r=3):(n=3,a=1,r=2);let s=this.kernelSize[0],i=this.kernelSize[1],o=this.strides[0],l=this.strides[1];return t[n]=this.filters,t[a]=kr(t[a],o,s,this.padding),t[r]=kr(t[r],l,i,this.padding),t}getConfig(){let e=super.getConfig();return delete e.dilationRate,e}};nA.className="Conv2DTranspose";ue.registerClass(nA);var aA=class extends vp{constructor(e){super(e);if(this.inputSpec=[new qt({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=pt(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],a=this.kernelSize.concat([this.filters,n]);this.kernel=this.addWeight("kernel",a,"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 qt({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 a=n.shape,r=a[0],s,i,o;this.dataFormat==="channelsFirst"?(o=2,s=3,i=4):(o=1,s=2,i=3);let l=a[o],d=a[s],u=a[i],p=this.kernelSize[0],c=this.kernelSize[1],h=this.kernelSize[2],f=this.strides[0],m=this.strides[1],g=this.strides[2],y=kr(l,f,p,this.padding),A=kr(d,m,c,this.padding),x=kr(u,g,h,this.padding),b=[r,y,A,x,this.filters];this.dataFormat!=="channelsLast"&&(n=Ze(n,[0,2,3,4,1]));let v=h3(n,this.kernel.read(),b,this.strides,this.padding);return this.dataFormat!=="channelsLast"&&(v=Ze(v,[0,4,1,2,3])),this.bias!==null&&(v=ar(v,this.bias.read(),this.dataFormat)),this.activation!==null&&(v=this.activation.apply(v)),v})}computeOutputShape(e){e=pt(e);let t=e.slice(),n,a,r,s;this.dataFormat==="channelsFirst"?(n=1,a=2,r=3,s=4):(n=4,a=1,r=2,s=3);let i=this.kernelSize[0],o=this.kernelSize[1],l=this.kernelSize[2],d=this.strides[0],u=this.strides[1],p=this.strides[2];return t[n]=this.filters,t[a]=kr(t[a],d,i,this.padding),t[r]=kr(t[r],u,o,this.padding),t[s]=kr(t[s],p,l,this.padding),t}getConfig(){let e=super.getConfig();return delete e.dilationRate,e}};aA.className="Conv3DTranspose";ue.registerClass(aA);var N7=class extends xp{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=Ct(t.depthwiseInitializer||this.DEFAULT_DEPTHWISE_INITIALIZER),this.depthwiseRegularizer=Et(t.depthwiseRegularizer),this.depthwiseConstraint=nn(t.depthwiseConstraint),this.pointwiseInitializer=Ct(t.depthwiseInitializer||this.DEFAULT_POINTWISE_INITIALIZER),this.pointwiseRegularizer=Et(t.pointwiseRegularizer),this.pointwiseConstraint=nn(t.pointwiseConstraint)}build(e){if(e=pt(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],a=this.kernelSize.concat([n,this.depthMultiplier]),r=[];for(let i=0;i<this.rank;++i)r.push(1);r.push(n*this.depthMultiplier,this.filters);let s=!0;this.depthwiseKernel=this.addWeight("depthwise_kernel",a,"float32",this.depthwiseInitializer,this.depthwiseRegularizer,s,this.depthwiseConstraint),this.pointwiseKernel=this.addWeight("pointwise_kernel",r,"float32",this.pointwiseInitializer,this.pointwiseRegularizer,s,this.pointwiseConstraint),this.useBias?this.bias=this.addWeight("bias",[this.filters],"float32",this.biasInitializer,this.biasRegularizer,s,this.biasConstraint):this.bias=null,this.inputSpec=[new qt({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 Pe("1D separable convolution is not implemented yet.");return this.rank===2&&(this.dataFormat==="channelsFirst"&&(e=Ze(e,[0,2,3,1])),n=Kg(e,this.depthwiseKernel.read(),this.pointwiseKernel.read(),this.strides,this.padding,this.dilationRate,"NHWC")),this.useBias&&(n=ar(n,this.bias.read(),this.dataFormat)),this.activation!=null&&(n=this.activation.apply(n)),this.dataFormat==="channelsFirst"&&(n=Ze(n,[0,3,1,2])),n})}getConfig(){let e=super.getConfig();return delete e.rank,delete e.kernelInitializer,delete e.kernelRegularizer,delete e.kernelConstraint,e.depthwiseInitializer=$t(this.depthwiseInitializer),e.pointwiseInitializer=$t(this.pointwiseInitializer),e.depthwiseRegularizer=gt(this.depthwiseRegularizer),e.pointwiseRegularizer=gt(this.pointwiseRegularizer),e.depthwiseConstraint=tn(this.depthwiseConstraint),e.pointwiseConstraint=tn(this.pointwiseConstraint),e}};N7.className="SeparableConv";var rA=class extends N7{constructor(e){super(2,e)}};rA.className="SeparableConv2D";ue.registerClass(rA);var U0=class extends xp{constructor(e){super(1,e);U0.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"&&!cy(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)}.`)}};U0.className="Conv1D";ue.registerClass(U0);var sA=class extends Qe{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=v0(e,this.cropping[0][0],e.shape[1]-this.cropping[0][0]-this.cropping[0][1],2);return v0(n,this.cropping[1][0],e.shape[2]-this.cropping[1][1]-this.cropping[1][0],3)}else{let n=v0(e,this.cropping[0][0],e.shape[2]-this.cropping[0][0]-this.cropping[0][1],3);return v0(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}};sA.className="Cropping2D";ue.registerClass(sA);var iA=class extends Qe{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,bP(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),a=n.shape;if(this.dataFormat==="channelsFirst"){n=Ze(n,[0,2,3,1]);let r=this.size[0]*a[2],s=this.size[1]*a[3],i=this.interpolation==="nearest"?Me.resizeNearestNeighbor(n,[r,s]):Me.resizeBilinear(n,[r,s]);return Ze(i,[0,3,1,2])}else{let r=this.size[0]*a[1],s=this.size[1]*a[2];return this.interpolation==="nearest"?Me.resizeNearestNeighbor(n,[r,s]):Me.resizeBilinear(n,[r,s])}})}getConfig(){let e={size:this.size,dataFormat:this.dataFormat},t=super.getConfig();return Object.assign(e,t),e}};iA.className="UpSampling2D";ue.registerClass(iA);function iL(e,t,n=[1,1],a="valid",r,s){return G(()=>{r==null&&(r=er()),Bt(r);let i=eA(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 i=ou(i,t,n,a==="same"?"same":"valid","NHWC",s),r==="channelsFirst"&&(i=Ze(i,[0,3,1,2])),i})}var oA=class extends tA{constructor(e){super(2,e);this.depthwiseKernel=null,this.depthMultiplier=e.depthMultiplier==null?1:e.depthMultiplier,this.depthwiseInitializer=Ct(e.depthwiseInitializer||this.DEFAULT_KERNEL_INITIALIZER),this.depthwiseConstraint=nn(e.depthwiseConstraint),this.depthwiseRegularizer=Et(e.depthwiseRegularizer)}build(e){if(e=pt(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],a=[this.kernelSize[0],this.kernelSize[1],n,this.depthMultiplier];this.depthwiseKernel=this.addWeight("depthwise_kernel",a,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=iL(e,this.depthwiseKernel.read(),this.strides,this.padding,this.dataFormat,null);return this.useBias&&(n=ar(n,this.bias.read(),this.dataFormat)),this.activation!=null&&(n=this.activation.apply(n)),n})}computeOutputShape(e){e=pt(e);let t=this.dataFormat==="channelsFirst"?e[2]:e[1],n=this.dataFormat==="channelsFirst"?e[3]:e[2],a=this.dataFormat==="channelsFirst"?e[1]*this.depthMultiplier:e[3]*this.depthMultiplier,r=ir(t,this.kernelSize[0],this.padding,this.strides[0]),s=ir(n,this.kernelSize[1],this.padding,this.strides[1]);return this.dataFormat==="channelsFirst"?[e[0],a,r,s]:[e[0],r,s,a]}getConfig(){let e=super.getConfig();return e.depthMultiplier=this.depthMultiplier,e.depthwiseInitializer=$t(this.depthwiseInitializer),e.depthwiseRegularizer=gt(this.depthwiseRegularizer),e.depthwiseConstraint=tn(this.depthwiseRegularizer),e}};oA.className="DepthwiseConv2D";ue.registerClass(oA);function T7(e,t,n,a){if(Array.isArray(e)){if(t!=null||n!=null)throw new H("When inputs is an array, neither initialState or constants should be provided");a!=null&&(n=e.slice(e.length-a,e.length),e=e.slice(0,e.length-a)),e.length>1&&(t=e.slice(1,e.length)),e=e[0]}function r(s){return s==null||Array.isArray(s)?s:[s]}return t=r(t),n=r(n),{inputs:e,initialState:t,constants:n}}function C7(e,t,n,a=!1,r,s,i=!1,o=!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 d=[1,0].concat(nr(2,l));if(t=Ze(t,d),s!=null)throw new Pe("The rnn() functoin of the deeplearn.js backend does not support constants yet.");i&&console.warn("Backend rnn(): the unroll = true option is not applicable to the imperative deeplearn.js backend."),r!=null&&(r=pe(pe(r,"bool"),"float32"),r.rank===l-1&&(r=Wt(r,-1)),r=Ze(r,d)),a&&(t=pa(t,0),r!=null&&(r=pa(r,0)));let u=[],p,c=n,h=t.shape[0],f=Mn(t),m;r!=null&&(m=Mn(r));for(let y=0;y<h;++y){let A=f[y],x=G(()=>e(A,c));if(r==null)p=x[0],c=x[1];else{let b=G(()=>{let v=m[y],k=ge(da(v),v),T=le(L(x[0],v),L(c[0],k)),C=c.map((D,O)=>le(L(x[1][O],v),L(D,k)));return{output:T,newStates:C}});p=b.output,c=b.newStates}o&&u.push(p)}let g;return o&&(g=xn(u,1)),[p,g,c]})}var Ir=class extends Qe{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 H0({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 qt({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 nr(0,e).map(t=>null)}else return this.states_}setStates(e){this.states_=e}computeOutputShape(e){Ey(e)&&(e=e[0]),e=e;let t=this.cell.stateSize;Array.isArray(t)||(t=[t]);let n=t[0],a;if(this.returnSequences?a=[e[0],e[1],n]:a=[e[0],n],this.returnState){let r=[];for(let s of t)r.push([e[0],s]);return[a].concat(r)}else return a}computeMask(e,t){return G(()=>{Array.isArray(t)&&(t=t[0]);let n=this.returnSequences?t:null;if(this.returnState){let a=this.states.map(r=>null);return[n].concat(a)}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 Pe("Constants support is not implemented in RNN yet.");Ey(e)&&(e=e[0]),e=e;let n=this.stateful?e[0]:null,a=e.slice(2);this.inputSpec[0]=new qt({shape:[n,null,...a]});let r=[e[0]].concat(e.slice(2));if(t!=null)throw new Pe("Constants support is not implemented in RNN yet.");this.cell.build(r);let s;if(Array.isArray(this.cell.stateSize)?s=this.cell.stateSize:s=[this.cell.stateSize],this.stateSpec!=null){if(!w.arraysEqual(this.stateSpec.map(i=>i.shape[i.shape.length-1]),s))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=s.map(i=>new qt({shape:[null,i]}));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(a=>Gt([n,a])):this.states_=[Gt([n,this.cell.stateSize])];else if(e==null)Q(this.states_),this.keptStates!=null&&(Q(this.keptStates),this.keptStates=[]),Array.isArray(this.cell.stateSize)?this.states_=this.cell.stateSize.map(a=>Gt([n,a])):this.states_[0]=Gt([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()):Q(this.states_);for(let a=0;a<this.states_.length;++a){let r=e[a],s=Array.isArray(this.cell.stateSize)?this.cell.stateSize[a]:this.cell.stateSize,i=[n,s];if(!w.arraysEqual(r.shape,i))throw new H(`State ${a} is incompatible with layer ${this.name}: expected shape=${i}, received shape=${r.shape}`);this.states_[a]=r}}this.states_=this.states_.map(a=>pn(a.clone()))})}apply(e,t){let n=t==null?null:t.initialState,a=t==null?null:t.constants;t==null&&(t={});let r=T7(e,n,a,this.numConstants);e=r.inputs,n=r.initialState,a=r.constants;let s=[],i=[];if(n!=null){t.initialState=n,s=s.concat(n),this.stateSpec=[];for(let o of n)this.stateSpec.push(new qt({shape:o.shape}));i=i.concat(this.stateSpec)}if(a!=null&&(t.constants=a,s=s.concat(a),this.numConstants=a.length),s[0]instanceof rr){let o=[e].concat(s),l=this.inputSpec.concat(i),d=this.inputSpec;this.inputSpec=l;let u=super.apply(o,t);return this.inputSpec=d,u}else return super.apply(e,t)}call(e,t){return G(()=>{let n=t==null?null:t.mask,a=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 s=Array.isArray(this.cell.stateSize)?this.cell.stateSize.length:1;if(r.length!==s)throw new H(`RNN Layer has ${s} 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 i={training:a},o=C7((c,h)=>{let f=this.cell.call([c].concat(h),i);return[f[0],f.slice(1)]},e,r,this.goBackwards,n,null,this.unroll,this.returnSequences),l=o[0],d=o[1],u=o[2];this.stateful&&this.resetStates(u,a);let p=this.returnSequences?d:l;return this.returnState?[p].concat(u):p})}getInitialState(e){return G(()=>{let t=Gt(e.shape);return t=Ie(t,[1,2]),t=pp(t),Array.isArray(this.cell.stateSize)?this.cell.stateSize.map(n=>n>1?by(t,[1,n]):t):this.cell.stateSize>1?[by(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()===Ir.className&&(t.cell={className:this.cell.getClassName(),config:n}),Object.assign({},n,e,t)}static fromConfig(e,t,n={}){let a=t.cell,r=sr(a,n);return new e(Object.assign(t,{cell:r}))}};Ir.className="RNN";ue.registerClass(Ir);var wp=class extends Qe{},j0=class extends wp{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,hn(this.units,"units"),this.activation=Ts(e.activation==null?this.DEFAULT_ACTIVATION:e.activation),this.useBias=e.useBias==null?!0:e.useBias,this.kernelInitializer=Ct(e.kernelInitializer||this.DEFAULT_KERNEL_INITIALIZER),this.recurrentInitializer=Ct(e.recurrentInitializer||this.DEFAULT_RECURRENT_INITIALIZER),this.biasInitializer=Ct(e.biasInitializer||this.DEFAULT_BIAS_INITIALIZER),this.kernelRegularizer=Et(e.kernelRegularizer),this.recurrentRegularizer=Et(e.recurrentRegularizer),this.biasRegularizer=Et(e.biasRegularizer),this.kernelConstraint=nn(e.kernelConstraint),this.recurrentConstraint=nn(e.recurrentConstraint),this.biasConstraint=nn(e.biasConstraint),this.dropout=xu([1,Is([0,e.dropout==null?0:e.dropout])]),this.recurrentDropout=xu([1,Is([0,e.recurrentDropout==null?0:e.recurrentDropout])]),this.dropoutFunc=e.dropoutFunc,this.stateSize=this.units,this.dropoutMask=null,this.recurrentDropoutMask=null}build(e){e=pt(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 a=t.training==null?!1:t.training;0<this.dropout&&this.dropout<1&&this.dropoutMask==null&&(this.dropoutMask=Cs({ones:()=>da(e),rate:this.dropout,training:a,dropoutFunc:this.dropoutFunc})),0<this.recurrentDropout&&this.recurrentDropout<1&&this.recurrentDropoutMask==null&&(this.recurrentDropoutMask=Cs({ones:()=>da(n),rate:this.recurrentDropout,training:a,dropoutFunc:this.dropoutFunc}));let r,s=this.dropoutMask,i=this.recurrentDropoutMask;s!=null?r=vr(L(e,s),this.kernel.read()):r=vr(e,this.kernel.read()),this.bias!=null&&(r=ar(r,this.bias.read())),i!=null&&(n=L(n,i));let o=le(r,vr(n,this.recurrentKernel.read()));return this.activation!=null&&(o=this.activation.apply(o)),[o,o]})}getConfig(){let e=super.getConfig(),t={units:this.units,activation:Ns(this.activation),useBias:this.useBias,kernelInitializer:$t(this.kernelInitializer),recurrentInitializer:$t(this.recurrentInitializer),biasInitializer:$t(this.biasInitializer),kernelRegularizer:gt(this.kernelRegularizer),recurrentRegularizer:gt(this.recurrentRegularizer),biasRegularizer:gt(this.biasRegularizer),activityRegularizer:gt(this.activityRegularizer),kernelConstraint:tn(this.kernelConstraint),recurrentConstraint:tn(this.recurrentConstraint),biasConstraint:tn(this.biasConstraint),dropout:this.dropout,recurrentDropout:this.recurrentDropout};return Object.assign({},e,t)}};j0.className="SimpleRNNCell";ue.registerClass(j0);var lA=class extends Ir{constructor(e){e.cell=new j0(e);super(e)}call(e,t){return G(()=>{this.cell.dropoutMask!=null&&(Q(this.cell.dropoutMask),this.cell.dropoutMask=null),this.cell.recurrentDropoutMask!=null&&(Q(this.cell.recurrentDropoutMask),this.cell.recurrentDropoutMask=null);let n=t==null?null:t.mask,a=t==null?null:t.training,r=t==null?null:t.initialState;return super.call(e,{mask:n,training:a,initialState:r})})}static fromConfig(e,t){return new e(t)}};lA.className="SimpleRNN";ue.registerClass(lA);var G0=class extends wp{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,hn(this.units,"units"),this.activation=Ts(e.activation===void 0?this.DEFAULT_ACTIVATION:e.activation),this.recurrentActivation=Ts(e.recurrentActivation===void 0?this.DEFAULT_RECURRENT_ACTIVATION:e.recurrentActivation),this.useBias=e.useBias==null?!0:e.useBias,this.kernelInitializer=Ct(e.kernelInitializer||this.DEFAULT_KERNEL_INITIALIZER),this.recurrentInitializer=Ct(e.recurrentInitializer||this.DEFAULT_RECURRENT_INITIALIZER),this.biasInitializer=Ct(e.biasInitializer||this.DEFAULT_BIAS_INITIALIZER),this.kernelRegularizer=Et(e.kernelRegularizer),this.recurrentRegularizer=Et(e.recurrentRegularizer),this.biasRegularizer=Et(e.biasRegularizer),this.kernelConstraint=nn(e.kernelConstraint),this.recurrentConstraint=nn(e.recurrentConstraint),this.biasConstraint=nn(e.biasConstraint),this.dropout=xu([1,Is([0,e.dropout==null?0:e.dropout])]),this.recurrentDropout=xu([1,Is([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=pt(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,a=e[1];e=e[0],0<this.dropout&&this.dropout<1&&this.dropoutMask==null&&(this.dropoutMask=Cs({ones:()=>da(e),rate:this.dropout,training:n,count:3,dropoutFunc:this.dropoutFunc})),0<this.recurrentDropout&&this.recurrentDropout<1&&this.recurrentDropoutMask==null&&(this.recurrentDropoutMask=Cs({ones:()=>da(a),rate:this.recurrentDropout,training:n,count:3,dropoutFunc:this.dropoutFunc}));let r=this.dropoutMask,s=this.recurrentDropoutMask,i,o,l;0<this.dropout&&this.dropout<1&&(e=L(e,r[0]));let d=vr(e,this.kernel.read());this.useBias&&(d=ar(d,this.bias.read())),0<this.recurrentDropout&&this.recurrentDropout<1&&(a=L(a,s[0]));let u=this.recurrentKernel.read(),[p,c]=cn(u,[2*this.units,this.units],u.rank-1),h=vr(a,p),[f,m,g]=cn(d,3,d.rank-1),[y,A]=cn(h,2,h.rank-1);i=this.recurrentActivation.apply(le(f,y)),o=this.recurrentActivation.apply(le(m,A));let x=vr(L(o,a),c);l=this.activation.apply(le(g,x));let b=le(L(i,a),L(le(1,Tt(i)),l));return[b,b]})}getConfig(){let e=super.getConfig(),t={units:this.units,activation:Ns(this.activation),recurrentActivation:Ns(this.recurrentActivation),useBias:this.useBias,kernelInitializer:$t(this.kernelInitializer),recurrentInitializer:$t(this.recurrentInitializer),biasInitializer:$t(this.biasInitializer),kernelRegularizer:gt(this.kernelRegularizer),recurrentRegularizer:gt(this.recurrentRegularizer),biasRegularizer:gt(this.biasRegularizer),activityRegularizer:gt(this.activityRegularizer),kernelConstraint:tn(this.kernelConstraint),recurrentConstraint:tn(this.recurrentConstraint),biasConstraint:tn(this.biasConstraint),dropout:this.dropout,recurrentDropout:this.recurrentDropout,implementation:this.implementation,resetAfter:!1};return Object.assign({},e,t)}};G0.className="GRUCell";ue.registerClass(G0);var uA=class extends Ir{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 G0(e);super(e)}call(e,t){return G(()=>{this.cell.dropoutMask!=null&&(Q(this.cell.dropoutMask),this.cell.dropoutMask=null),this.cell.recurrentDropoutMask!=null&&(Q(this.cell.recurrentDropoutMask),this.cell.recurrentDropoutMask=null);let n=t==null?null:t.mask,a=t==null?null:t.training,r=t==null?null:t.initialState;return super.call(e,{mask:n,training:a,initialState:r})})}static fromConfig(e,t){return t.implmentation===0&&(t.implementation=1),new e(t)}};uA.className="GRU";ue.registerClass(uA);var kp=class extends wp{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,hn(this.units,"units"),this.activation=Ts(e.activation===void 0?this.DEFAULT_ACTIVATION:e.activation),this.recurrentActivation=Ts(e.recurrentActivation===void 0?this.DEFAULT_RECURRENT_ACTIVATION:e.recurrentActivation),this.useBias=e.useBias==null?!0:e.useBias,this.kernelInitializer=Ct(e.kernelInitializer||this.DEFAULT_KERNEL_INITIALIZER),this.recurrentInitializer=Ct(e.recurrentInitializer||this.DEFAULT_RECURRENT_INITIALIZER),this.biasInitializer=Ct(e.biasInitializer||this.DEFAULT_BIAS_INITIALIZER),this.unitForgetBias=e.unitForgetBias,this.kernelRegularizer=Et(e.kernelRegularizer),this.recurrentRegularizer=Et(e.recurrentRegularizer),this.biasRegularizer=Et(e.biasRegularizer),this.kernelConstraint=nn(e.kernelConstraint),this.recurrentConstraint=nn(e.recurrentConstraint),this.biasConstraint=nn(e.biasConstraint),this.dropout=xu([1,Is([0,e.dropout==null?0:e.dropout])]),this.recurrentDropout=xu([1,Is([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=pt(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 a;if(this.useBias){if(this.unitForgetBias){let r=this.biasInitializer,s=this.units;a=new(t=class extends Ba{apply(i,o){let l=r.apply([s]),d=new k0().apply([s]),u=r.apply([s*2]);return kv(kv(l,d),u)}},t.className="CustomInit",t)}else a=this.biasInitializer;this.bias=this.addWeight("bias",[this.units*4],null,a,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 a=e[1],r=e[2];e=e[0],0<this.dropout&&this.dropout<1&&this.dropoutMask==null&&(this.dropoutMask=Cs({ones:()=>da(e),rate:this.dropout,training:n,count:4,dropoutFunc:this.dropoutFunc})),0<this.recurrentDropout&&this.recurrentDropout<1&&this.recurrentDropoutMask==null&&(this.recurrentDropoutMask=Cs({ones:()=>da(a),rate:this.recurrentDropout,training:n,count:4,dropoutFunc:this.dropoutFunc}));let s=this.dropoutMask,i=this.recurrentDropoutMask,o,l,d,u;0<this.dropout&&this.dropout<1&&(e=L(e,s[0]));let p=vr(e,this.kernel.read());0<this.recurrentDropout&&this.recurrentDropout<1&&(a=L(a,i[0])),p=le(p,vr(a,this.recurrentKernel.read())),this.useBias&&(p=ar(p,this.bias.read()));let[c,h,f,m]=cn(p,4,p.rank-1);o=this.recurrentActivation.apply(c),l=this.recurrentActivation.apply(h),d=le(L(l,r),L(o,this.activation.apply(f))),u=this.recurrentActivation.apply(m);let g=L(u,this.activation.apply(d));return[g,g,d]})}getConfig(){let e=super.getConfig(),t={units:this.units,activation:Ns(this.activation),recurrentActivation:Ns(this.recurrentActivation),useBias:this.useBias,kernelInitializer:$t(this.kernelInitializer),recurrentInitializer:$t(this.recurrentInitializer),biasInitializer:$t(this.biasInitializer),unitForgetBias:this.unitForgetBias,kernelRegularizer:gt(this.kernelRegularizer),recurrentRegularizer:gt(this.recurrentRegularizer),biasRegularizer:gt(this.biasRegularizer),activityRegularizer:gt(this.activityRegularizer),kernelConstraint:tn(this.kernelConstraint),recurrentConstraint:tn(this.recurrentConstraint),biasConstraint:tn(this.biasConstraint),dropout:this.dropout,recurrentDropout:this.recurrentDropout,implementation:this.implementation};return Object.assign({},e,t)}};kp.className="LSTMCell";ue.registerClass(kp);var dA=class extends Ir{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 kp(e);super(e)}call(e,t){return G(()=>{this.cell.dropoutMask!=null&&(Q(this.cell.dropoutMask),this.cell.dropoutMask=null),this.cell.recurrentDropoutMask!=null&&(Q(this.cell.recurrentDropoutMask),this.cell.recurrentDropoutMask=null);let n=t==null?null:t.mask,a=t==null?null:t.training,r=t==null?null:t.initialState;return super.call(e,{mask:n,training:a,initialState:r})})}static fromConfig(e,t){return t.implmentation===0&&(t.implementation=1),new e(t)}};dA.className="LSTM";ue.registerClass(dA);var H0=class extends wp{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),a=[];for(let i of this.cells.slice().reverse())Array.isArray(i.stateSize)?a.push(n.splice(0,i.stateSize.length)):a.push(n.splice(0,1));a.reverse();let r=[],s;for(let i=0;i<this.cells.length;++i){let o=this.cells[i];n=a[i],i===0?s=[e[0]].concat(n):s=[s[0]].concat(n),s=o.call(s,t),r.push(s.slice(1))}n=[];for(let i of r.slice().reverse())n.push(...i);return[s[0]].concat(n)})}build(e){Ey(e)&&(e=e[0]),e=e;let t;this.cells.forEach((n,a)=>{mo(`RNNCell_${a}`,()=>{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=a=>({className:a.getClassName(),config:a.getConfig()}),n={cells:this.cells.map(t)};return Object.assign({},e,n)}static fromConfig(e,t,n={}){let a=[];for(let r of t.cells)a.push(sr(r,n));return new e({cells:a})}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 Ry(e)}setWeights(e){let t=[];for(let n of this.cells){let a=n.weights.length,r=e.splice(a);for(let s=0;s<n.weights.length;++s)t.push([n.weights[s],r[s]])}My(t)}};H0.className="StackedRNNCells";ue.registerClass(H0);function Cs(e){let{ones:t,rate:n,training:a=!1,count:r=1,dropoutFunc:s}=e,i=()=>s!=null?s(t(),n):Sv(t(),n),o=()=>hp(i,t,a);return!r||r<=1?pn(o().clone()):Array(r).fill(void 0).map(o).map(l=>pn(l.clone()))}var oL=function(e,t){var n={};for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&t.indexOf(a)<0&&(n[a]=e[a]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,a=Object.getOwnPropertySymbols(e);r<a.length;r++)t.indexOf(a[r])<0&&Object.prototype.propertyIsEnumerable.call(e,a[r])&&(n[a[r]]=e[a[r]]);return n},E7=class extends Ir{constructor(e){if(e.unroll)throw new Pe("Unrolling is not possible with convolutional RNNs.");if(Array.isArray(e.cell))throw new Pe("It is not possible at the moment to stack convolutional cells.");super(e);this.inputSpec=[new qt({ndim:5})]}call(e,t){return G(()=>{if(this.cell.dropoutMask!=null&&(Q(this.cell.dropoutMask),this.cell.dropoutMask=null),this.cell.recurrentDropoutMask!=null&&(Q(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,a=t==null?null:t.training,r=t==null?null:t.initialState;return super.call(e,{mask:n,training:a,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,a=this.computeSingleOutputShape(n),r=[a[0],...a.slice(2)],s=Gt(r);return Array.isArray(t)?Array(t.length).fill(s):[s]})}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,a=this.computeSingleOutputShape(n),r=[a[0],...a.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(()=>Gt(r)):this.states_=[Gt(r)];else if(e==null)Q(this.states_),this.keptStates!=null&&(Q(this.keptStates),this.keptStates=[]),Array.isArray(this.cell.stateSize)?this.states_=this.cell.stateSize.map(()=>Gt(r)):this.states_[0]=Gt(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()):Q(this.states_);for(let s=0;s<this.states_.length;++s){let i=e[s],o=r;if(!w.arraysEqual(i.shape,o))throw new H(`State ${s} is incompatible with layer ${this.name}: expected shape=${o}, received shape=${i.shape}`);this.states_[s]=i}}this.states_=this.states_.map(s=>pn(s.clone()))})}computeSingleOutputShape(e){let{dataFormat:t,filters:n,kernelSize:a,padding:r,strides:s,dilationRate:i}=this.cell,o=t==="channelsFirst",l=e[o?3:2],d=e[o?4:3],u=ir(l,a[0],r,s[0],i[0]),p=ir(d,a[1],r,s[1],i[1]);return[...e.slice(0,2),...o?[n,u,p]:[u,p,n]]}};E7.className="ConvRNN2D";var q0=class extends kp{constructor(e){let{filters:t,kernelSize:n,strides:a,padding:r,dataFormat:s,dilationRate:i}=e;super(Object.assign({},e,{units:t}));this.filters=t,hn(this.filters,"filters"),this.kernelSize=Iu(n,2,"kernelSize"),this.kernelSize.forEach(o=>hn(o,"kernelSize")),this.strides=Iu(a||1,2,"strides"),this.strides.forEach(o=>hn(o,"strides")),this.padding=r||"valid",Na(this.padding),this.dataFormat=s||"channelsLast",Bt(this.dataFormat),this.dilationRate=Iu(i||1,2,"dilationRate"),this.dilationRate.forEach(o=>hn(o,"dilationRate"))}build(e){var t;e=pt(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 a=e[n],r=4,s=this.kernelSize.concat([a,this.filters*r]);this.kernel=this.addWeight("kernel",s,null,this.kernelInitializer,this.kernelRegularizer,!0,this.kernelConstraint);let i=this.kernelSize.concat([this.filters,this.filters*r]);if(this.recurrentKernel=this.addWeight("recurrent_kernel",i,null,this.recurrentInitializer,this.recurrentRegularizer,!0,this.recurrentConstraint),this.useBias){let o;if(this.unitForgetBias){let l=this.biasInitializer,d=this.filters;o=new(t=class extends Ba{apply(u,p){let c=l.apply([d]),h=ua([d]),f=l.apply([d*2]);return xy([c,h,f])}},t.className="CustomInit",t)}else o=this.biasInitializer;this.bias=this.addWeight("bias",[this.filters*r],null,o,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,a=e[0],r=e[1],s=e[2],i=4;0<this.dropout&&this.dropout<1&&this.dropoutMask==null&&(this.dropoutMask=Cs({ones:()=>da(a),rate:this.dropout,training:n,count:i,dropoutFunc:this.dropoutFunc}));let o=this.dropoutMask,l=(Z,te,J)=>!te||!te[J]?Z:L(te[J],Z),d=l(a,o,0),u=l(a,o,1),p=l(a,o,2),c=l(a,o,3);0<this.recurrentDropout&&this.recurrentDropout<1&&this.recurrentDropoutMask==null&&(this.recurrentDropoutMask=Cs({ones:()=>da(r),rate:this.recurrentDropout,training:n,count:i,dropoutFunc:this.dropoutFunc}));let h=this.recurrentDropoutMask,f=l(r,h,0),m=l(r,h,1),g=l(r,h,2),y=l(r,h,3),A=3,[x,b,v,k]=cn(this.kernel.read(),i,A),[T,C,D,O]=this.useBias?cn(this.bias.read(),i):[null,null,null,null];d=this.inputConv(d,x,T,this.padding),u=this.inputConv(u,b,C,this.padding),p=this.inputConv(p,v,D,this.padding),c=this.inputConv(c,k,O,this.padding);let[F,S,P,_]=cn(this.recurrentKernel.read(),i,A);f=this.recurrentConv(f,F),m=this.recurrentConv(m,S),g=this.recurrentConv(g,P),y=this.recurrentConv(y,_);let j=this.recurrentActivation.apply(le(d,f)),q=this.recurrentActivation.apply(le(u,m)),z=le(L(q,s),L(j,this.activation.apply(le(p,g)))),X=L(this.recurrentActivation.apply(le(c,y)),this.activation.apply(z));return[X,X,z]})}getConfig(){let e=super.getConfig(),{units:t}=e,n=oL(e,["units"]),a={filters:this.filters,kernelSize:this.kernelSize,padding:this.padding,dataFormat:this.dataFormat,dilationRate:this.dilationRate,strides:this.strides};return Object.assign({},n,a)}inputConv(e,t,n,a){let r=_r(e,t,this.strides,a||"valid",this.dataFormat==="channelsFirst"?"NCHW":"NHWC",this.dilationRate);return n?ar(r,n,this.dataFormat):r}recurrentConv(e,t){return _r(e,t,1,"same",this.dataFormat==="channelsFirst"?"NCHW":"NHWC")}};q0.className="ConvLSTM2DCell";ue.registerClass(q0);var pA=class extends E7{constructor(e){let t=new q0(e);super(Object.assign({},e,{cell:t}))}static fromConfig(e,t){return new e(t)}};pA.className="ConvLSTM2D";ue.registerClass(pA);var X0=class extends Qe{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 a=0;a<this.noiseShape.length;++a)n.push(this.noiseShape[a]==null?t[a]:this.noiseShape[a]);return n}call(e,t){return G(()=>{this.invokeCallHook(e,t);let n=Le(e);if(0<this.rate&&this.rate<1){let a=t.training==null?!1:t.training,r=this.getNoiseShape(n);return hp(()=>Sv(n,this.rate,r,this.seed),()=>n,a)}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()}};X0.className="Dropout";ue.registerClass(X0);var cA=class extends X0{constructor(e){super(e);this.inputSpec=[{ndim:3}]}getNoiseShape(e){let t=e.shape;return[t[0],1,t[2]]}};cA.className="SpatialDropout1D";ue.registerClass(cA);var hA=class extends Qe{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,hn(this.units,"units"),this.activation=Ts(e.activation),e.useBias!=null&&(this.useBias=e.useBias),this.kernelInitializer=Ct(e.kernelInitializer||this.DEFAULT_KERNEL_INITIALIZER),this.biasInitializer=Ct(e.biasInitializer||this.DEFAULT_BIAS_INITIALIZER),this.kernelConstraint=nn(e.kernelConstraint),this.biasConstraint=nn(e.biasConstraint),this.kernelRegularizer=Et(e.kernelRegularizer),this.biasRegularizer=Et(e.biasRegularizer),this.activityRegularizer=Et(e.activityRegularizer),this.supportsMasking=!0,this.inputSpec=[{minNDim:2}]}build(e){e=pt(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=pt(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),a=fv(this.activation.getClassName()),r;return a!=null?r=vr(n,this.kernel.read(),a,this.bias?this.bias.read():null):(r=vr(n,this.kernel.read()),this.bias!=null&&(r=ar(r,this.bias.read())),this.activation!=null&&(r=this.activation.apply(r))),r})}getConfig(){let e={units:this.units,activation:Ns(this.activation),useBias:this.useBias,kernelInitializer:$t(this.kernelInitializer),biasInitializer:$t(this.biasInitializer),kernelRegularizer:gt(this.kernelRegularizer),biasRegularizer:gt(this.biasRegularizer),activityRegularizer:gt(this.activityRegularizer),kernelConstraint:tn(this.kernelConstraint),biasConstraint:tn(this.biasConstraint)},t=super.getConfig();return Object.assign(e,t),e}};hA.className="Dense";ue.registerClass(hA);var fA=class extends Qe{constructor(e){e=e||{};super(e);this.inputSpec=[{minNDim:3}],this.dataFormat=e.dataFormat}computeOutputShape(e){e=pt(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],ks(e,1)]}call(e,t){return G(()=>{this.invokeCallHook(e,t);let n=Le(e);if(this.dataFormat==="channelsFirst"&&n.rank>1){let a=[0];for(let r=2;r<n.rank;++r)a.push(r);a.push(1),n=Ze(n,a)}return NP(n)})}getConfig(){let e={};this.dataFormat!=null&&(e.dataFormat=this.dataFormat);let t=super.getConfig();return Object.assign(e,t),e}};fA.className="Flatten";ue.registerClass(fA);var mA=class extends Qe{constructor(e){super(e);this.supportsMasking=!0,this.activation=Ts(e.activation)}call(e,t){return G(()=>{this.invokeCallHook(e,t);let n=Le(e);return this.activation.apply(n)})}getConfig(){let e={activation:Ns(this.activation)},t=super.getConfig();return Object.assign(e,t),e}};mA.className="Activation";ue.registerClass(mA);var gA=class extends Qe{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),IP(e,this.n)))}getConfig(){let e={n:this.n},t=super.getConfig();return Object.assign(e,t),e}};gA.className="RepeatVector";ue.registerClass(gA);var yA=class extends Qe{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.",a=t.slice(),r=1,s=null;for(let o=0;o<a.length;++o){let l=a[o];if(this.isUnknown(l))if(s===null)s=o;else throw new H("Can only specifiy one unknown dimension.");else r*=l}let i=ks(e);if(s!==null){if(r===0||i%r!=0)throw new H(n);a[s]=i/r}else if(i!==r)throw new H(n);return a}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),a=n.shape,r=a.slice(0,1).concat(this.fixUnknownDimension(a.slice(1),this.targetShape));return V(n,r)})}getConfig(){let e={targetShape:this.targetShape},t=super.getConfig();return Object.assign(e,t),e}};yA.className="Reshape";ue.registerClass(yA);var AA=class extends Qe{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=nr(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 qt({ndim:this.dims.length+1})]}computeOutputShape(e){e=pt(e);let t=e.slice();return this.dims.forEach((n,a)=>{t[a+1]=e[n]}),t}call(e,t){return Ze(Le(e),this.dimsIncludingBatch)}getConfig(){let e={dims:this.dims},t=super.getConfig();return Object.assign(e,t),e}};AA.className="Permute";ue.registerClass(AA);var xA=class extends Qe{constructor(e){super(e==null?{}:e);this.supportsMasking=!0,e!=null?this.maskValue=e.maskValue==null?0:e.maskValue:this.maskValue=0}computeOutputShape(e){return e}getConfig(){let e=super.getConfig(),t={maskValue:this.maskValue};return Object.assign(t,e),t}computeMask(e,t){let n=Le(e),a=-1;return jd(oo(n,this.maskValue),a)}call(e,t){return G(()=>{this.invokeCallHook(e,t);let n=Le(e),a=-1,r=!0,s=jd(oo(n,this.maskValue),a,r);return L(n,pe(s,n.dtype))})}};xA.className="Masking";ue.registerClass(xA);var bA=class extends Qe{constructor(e){super(e);if(this.embeddings=null,this.DEFAULT_EMBEDDINGS_INITIALIZER="randomUniform",e.batchInputShape==null&&e.inputShape==null){let t=null;e.batchSize!=null&&(t=e.batchSize),e.inputLength==null?this.batchInputShape=[t,null]:this.batchInputShape=[t].concat(vt(e.inputLength))}this.inputDim=e.inputDim,hn(this.inputDim,"inputDim"),this.outputDim=e.outputDim,hn(this.outputDim,"outputDim"),this.embeddingsInitializer=Ct(e.embeddingsInitializer||this.DEFAULT_EMBEDDINGS_INITIALIZER),this.embeddingsRegularizer=Et(e.embeddingsRegularizer),this.activityRegularizer=Et(e.activityRegularizer),this.embeddingsConstraint=nn(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),oo(e,Ye(e))):null)}computeOutputShape(e){if(e=pt(e),this.inputLength==null)return[...e,this.outputDim];let t=vt(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 a=0;a<t.length;++a){let r=t[a],s=e[a+1];if(r!=null&&s!=null&&r!==s)throw new H(`"inputLength" is ${this.inputLength}, but received input shape has shape ${e}`);r==null&&(t[n]=s),n++}}return[e[0],...t,this.outputDim]}call(e,t){return G(()=>{this.invokeCallHook(e,t);let n=Le(e);n.dtype!=="int32"&&(n=b0(n,"int32"));let a=Iv(this.embeddings.read(),V(n,[n.size]));return V(a,pt(this.computeOutputShape(n.shape)))})}getConfig(){let e={inputDim:this.inputDim,outputDim:this.outputDim,embeddingsInitializer:$t(this.embeddingsInitializer),embeddingsRegularizer:gt(this.embeddingsRegularizer),activityRegularizer:gt(this.activityRegularizer),embeddingsConstraint:tn(this.embeddingsConstraint),maskZero:this.maskZero,inputLength:this.inputLength},t=super.getConfig();return Object.assign(e,t),e}};bA.className="Embedding";ue.registerClass(bA);var bo=class extends Qe{constructor(e){super(e||{});this.supportsMasking=!0}mergeFunction(e){throw new Pe}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 a=0;a<t.length;++a){let r=e[e.length-t.length+a],s=t[a];if(r==null||s==null||r<0||s<0)n.push(null);else if(r===1)n.push(s);else if(s===1)n.push(r);else{if(r!==s)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=[pt(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=ws(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 s=e[r]==null?null:e[r].slice(1);n=this.computeElementwiseOpOutputShape(n,s)}let a=e.map(r=>r.length);e.indexOf(null)===-1&&ws(a).length===1?this.reshapeRequired=!1:this.reshapeRequired=!0}call(e,t){return G(()=>{if(e=e,this.reshapeRequired){let n=[],a=e.map(r=>r.rank);if(a.indexOf(null)===-1){let r=Is(a);for(let s of e){let i=s.rank;for(let o=0;o<r-i;++o)s=pp(s,1);n.push(s)}return this.mergeFunction(n)}else{let r=!1;for(let o of e){let l=o.rank;if(l==null){let d=o.shape,u=d[0],p=d.slice(1).concat([u]),c=V(o,[u].concat(ks(d.slice(1))));c=Ze(c,[1,0]),c=V(c,p),n.push(c),r=!0}else if(l>1){let d=nr(1,l).concat([0]);n.push(Ze(o,d)),r=!0}else n.push(o)}let s=this.mergeFunction(n),i=s.rank;if(r){if(i==null){let o=s.shape,l=o.length,d=o[l-1],u=[d].concat(o.slice(0,o.length-1));s=V(Ze(V(s,[-1,d]),[1,0]),u)}else if(i>1){let o=[i-1].concat(nr(0,i-1));s=Ze(s,o)}}return s}}else return this.mergeFunction(e)})}computeOutputShape(e){e=e;let t;e[0]==null?t=null:t=e[0].slice(1);for(let a=1;a<e.length;++a){let r=e[a]==null?null:e[a].slice(1);t=this.computeElementwiseOpOutputShape(t,r)}let n=[];for(let a of e)a!=null&&a[0]!==null&&n.push(a[0]);return n=ws(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(a=>a==null))return null;t=t.map(a=>a==null?a:Wt(a,0));let n=t[0];for(let a=1;a<t.length-1;++a)n=La(n,t[a]);return n})}},vA=class extends bo{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})}};vA.className="Add";ue.registerClass(vA);var wA=class extends bo{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})}};wA.className="Multiply";ue.registerClass(wA);var kA=class extends bo{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)})}};kA.className="Average";ue.registerClass(kA);var IA=class extends bo{constructor(e){super(e)}mergeFunction(e){return G(()=>{let t=e[0];for(let n=1;n<e.length;++n)t=Ar(t,e[n]);return t})}};IA.className="Maximum";ue.registerClass(IA);var SA=class extends bo{constructor(e){super(e)}mergeFunction(e){return G(()=>{let t=e[0];for(let n=1;n<e.length;++n)t=pu(t,e[n]);return t})}};SA.className="Minimum";ue.registerClass(SA);var NA=class extends bo{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 a of e)if(a!=null){t=!1;break}if(t)return;let n=[];for(let a=0;a<e.length;++a){let r=e[a].slice();r.splice(this.axis,1);let s=!1;for(let i of n)if(w.arraysEqual(i,r)){s=!0;break}s||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(()=>xy(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(),a=this.axis<0?n.length+this.axis:this.axis;for(let r of t.slice(1)){if(n[a]==null||r[a]==null){n[a]=null;break}n[a]+=r[a]}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(s=>{if(s!=null){n=!1;return}}),n)return null;let a=[];for(let s=0;s<e.length;++s)t[s]==null?a.push(pe(da(e[s]),"bool")):t[s].rank<e[s].rank?a.push(Wt(t[s],-1)):a.push(t[s]);let r=mt(a,this.axis);return Ph(r,-1,!1)})}getConfig(){let e={axis:this.axis},t=super.getConfig();return Object.assign(e,t),e}};NA.className="Concatenate";ue.registerClass(NA);function Ip(e,t){for(;e<0;)e+=t;return e}function lL(e,t,n){if(e.shape.length>3||t.shape.length>3)throw new Pe("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 Pe("batchDot is not implemented for complex64-type Tensors yet.");let a=e.shape.length,r=t.shape.length;n==null&&(n=[a-1,r-2]);let s=n;return G(()=>{let i;if(a>r){i=a-r;let l=[];for(let d=0;d<i;++d)l.push(1);t=V(t,t.shape.concat(l))}else if(r>a){i=r-a;let l=[];for(let d=0;d<i;++d)l.push(1);e=V(e,e.shape.concat(l))}else i=0;let o;if(e.shape.length===2&&t.shape.length===2)s[0]===s[1]?o=Ie(L(e,t),s[0]):o=Ie(L(Ze(e,[1,0]),t),s[1]);else{let l=s[0]!==e.shape.length-1,d=s[1]===t.shape.length-1;o=Ve(e,t,l,d)}if(i>0){let l;a>r?l=a+r-3:l=a-1;let d=[];for(let u=l;u<l+i;++u)d.push(u);o=st(o,d)}return o.shape.length===1&&(o=Wt(o,1)),o})}var TA=class extends bo{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 Pe("Dot layer does not support tensors of 4D or higher rank yet.");let a=this.interpretAxes(t,n);if(t[a[0]]!==n[a[1]])throw new H(`Dimension incompatibility: ${t[a[0]]} !== ${n[a[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],a;return Array.isArray(this.axes)?a=this.axes.map((r,s)=>Ip(r,e[s].shape.length)):a=[Ip(this.axes,t.shape.length),Ip(this.axes,n.shape.length)],this.normalize&&(t=O0(t,a[0]),n=O0(n,a[1])),lL(t,n,a)}interpretAxes(e,t){let n;return Array.isArray(this.axes)?n=this.axes:n=[Ip(this.axes,e.length),Ip(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 Pe("Dot layer does not support tensors of 4D or higher rank yet.");let a=this.interpretAxes(t,n);t.splice(a[0],1),n.splice(a[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}};TA.className="Dot";ue.registerClass(TA);var CA=class extends Qe{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 hp(()=>le(w0(n.shape,0,this.stddev),n),()=>n,t.training||!1)})}};CA.className="GaussianNoise";ue.registerClass(CA);var EA=class extends Qe{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?hp(()=>{let a=Math.sqrt(this.rate/(1-this.rate));return L(n,w0(n.shape,1,a))},()=>n,t.training||!1):n})}};EA.className="GaussianDropout";ue.registerClass(EA);var RA=class extends Qe{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 hp(()=>{let a=Le(e),r=1.6732632423543772,s=1.0507009873554805,i=-r*s,o=xs(cu(n),this.rate);o=b0(o,"float32");let l=((1-this.rate)*(1+this.rate*i**2))**-.5,d=-l*i*this.rate,u=le(L(a,o),L(le(o,-1),i));return le(L(u,l),d)},()=>Le(e),t.training||!1)}return e})}};RA.className="AlphaDropout";ue.registerClass(RA);function Sp(e,t,n,a,r,s=.001){let i;if(e.rank===2)i=s3(e,t,n,a,r,s);else if(e.rank===3)i=i3(e,t,n,a,r,s);else if(e.rank===4)i=o3(e,t,n,a,r,s);else throw new Pe(`batchNormalization is not implemented for array of rank ${e.rank} yet`);return i}function uL(e,t,n,a,r=.001){return G(()=>{let s=Xh(e,a),i=s.mean,o=s.variance;return[Sp(e,i,o,n,t,r),i,o]})}function dL(e,t,n,a,r=.001){return G(()=>{let s=Xh(e,a),i=s.mean,o=s.variance,l=[];for(let h of nr(0,e.rank))a.indexOf(h)!==-1?l.push(1):l.push(e.shape[h]);let d=V(i,l),u=V(o,l),p=t==null?null:V(t,l),c=n==null?null:V(n,l);return[Sp(e,d,u,c,p,r),i,o]})}function pL(e,t,n,a,r=.001){return w.arraysEqual(a.slice().sort(),nr(0,e.rank-1))?uL(e,t,n,a,r):dL(e,t,n,a,r)}var MA=class extends Qe{constructor(e){e==null&&(e={});super(e);this.supportsMasking=!0,this.axis=e.axis==null?-1:e.axis,this.momentum=e.momentum==null?.99:e.momentum,this.epsilon=e.epsilon==null?.001:e.epsilon,this.center=e.center==null?!0:e.center,this.scale=e.scale==null?!0:e.scale,this.betaInitializer=Ct(e.betaInitializer||"zeros"),this.gammaInitializer=Ct(e.gammaInitializer||"ones"),this.movingMeanInitializer=Ct(e.movingMeanInitializer||"zeros"),this.movingVarianceInitializer=Ct(e.movingVarianceInitializer||"ones"),this.betaConstraint=nn(e.betaConstraint),this.gammaConstraint=nn(e.gammaConstraint),this.betaRegularizer=Et(e.betaRegularizer),this.gammaRegularizer=Et(e.gammaRegularizer)}build(e){e=pt(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 qt({ndim:e.length,axes:{[t]:n}})];let a=[n];this.scale&&(this.gamma=this.addWeight("gamma",a,null,this.gammaInitializer,this.gammaRegularizer,!0,this.gammaConstraint)),this.center&&(this.beta=this.addWeight("beta",a,null,this.betaInitializer,this.betaRegularizer,!0,this.betaConstraint)),this.movingMean=this.addWeight("moving_mean",a,null,this.movingMeanInitializer,null,!1),this.movingVariance=this.addWeight("moving_variance",a,null,this.movingVarianceInitializer,null,!1),this.built=!0}call(e,t){return G(()=>{let n=t.training==null?!1:t.training,a=Le(e),r=a.shape,s=r.length,i=nr(0,s),o=this.axis>=0?this.axis:this.axis+s;i.splice(o,1);let l=co(1,s);l[o]=r[o];let d=i.slice();d.sort();let u=!w.arraysEqual(d,nr(0,s).slice(0,s-1)),p=()=>{if(u){let g=V(this.movingMean.read(),l),y=V(this.movingVariance.read(),l),A=this.center?V(this.beta.read(),l):null,x=this.scale?V(this.gamma.read(),l):null;return Sp(a,g,y,A,x,this.epsilon)}else return Sp(a,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 p();let[c,h,f]=pL(a,this.gamma.read(),this.beta.read(),i,this.epsilon),m=(g,y,A)=>{G(()=>{let x=1-A,b=g.read(),v=L(ge(b,y),x);g.write(ge(b,v))})};return(()=>{m(this.movingMean,h,this.momentum),m(this.movingVariance,f,this.momentum)})(),c})}getConfig(){let e={axis:this.axis,momentum:this.momentum,epsilon:this.epsilon,center:this.center,scale:this.scale,betaInitializer:$t(this.betaInitializer),gammaInitializer:$t(this.gammaInitializer),movingMeanInitializer:$t(this.movingMeanInitializer),movingVarianceInitializer:$t(this.movingVarianceInitializer),betaRegularizer:gt(this.betaRegularizer),gammaRegularizer:gt(this.gammaRegularizer),betaConstraint:tn(this.betaConstraint),gammaConstraint:tn(this.gammaConstraint)},t=super.getConfig();return Object.assign(e,t),e}};MA.className="BatchNormalization";ue.registerClass(MA);var FA=class extends Qe{constructor(e){e==null&&(e={});super(e);if(this.axis=e.axis==null?-1:e.axis,typeof this.axis=="number"){if(!Number.isInteger(this.axis))throw new Error(`Expected axis to be an integer, but received ${this.axis}`)}else if(Array.isArray(this.axis)){for(let t of this.axis)if(!Number.isInteger(t))throw new Error(`Expected axis to be an array of integers, but received ${JSON.stringify(this.axis)}`)}else throw new Error(`Expected axis to be an integer or an array of integers, but received ${JSON.stringify(this.axis)}`);this.epsilon=e.epsilon==null?.001:e.epsilon,this.center=e.center==null?!0:e.center,this.scale=e.scale==null?!0:e.scale,this.betaInitializer=Ct(e.betaInitializer||"zeros"),this.gammaInitializer=Ct(e.gammaInitializer||"ones"),this.betaRegularizer=Et(e.betaRegularizer),this.gammaRegularizer=Et(e.gammaRegularizer),this.supportsMasking=!0}build(e){e=pt(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!==ws(this.axis).length)throw new Error(`Found duplicate axes in: ${this.axis}`);let n=this.axis.map(r=>e[r]),a=!0;this.scale?this.gamma=this.addWeight("gamma",n,"float32",this.gammaInitializer,this.gammaRegularizer,a):this.gamma=null,this.center?this.beta=this.addWeight("beta",n,"float32",this.betaInitializer,this.betaRegularizer,a):this.beta=null,this.built=!0}call(e,t){let n=Le(e),a=n.shape,r=a.length;return G(()=>{let s=!0,{mean:i,variance:o}=Xh(n,this.axis,s),l=co(1,r);for(let f of this.axis)l[f]=a[f];let d=f=>f!=null&&f.shape.length!==r?V(f,l):f,u=d(this.gamma.read()),p=d(this.beta.read()),c=[],h=[];for(let f=0;f<r;++f)this.axis.indexOf(f)!==-1?(c.push(a[f]),h.push(1)):(c.push(1),h.push(a[f]));return i=Ia(i,c),o=Ia(o,c),u=Ia(u,h),p=Ia(p,h),Sp(n,i,o,p,u,this.epsilon)})}getConfig(){let e={axis:this.axis,epsilon:this.epsilon,center:this.center,scale:this.scale,betaInitializer:$t(this.betaInitializer),gammaInitializer:$t(this.gammaInitializer),betaRegularizer:gt(this.betaRegularizer),gammaRegularizer:gt(this.gammaRegularizer)},t=super.getConfig();return Object.assign(e,t),e}};FA.className="LayerNormalization";ue.registerClass(FA);function cL(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=er()),n!=="channelsLast"&&n!=="channelsFirst")throw new H(`Unknown data format: ${n}. Supported data formats are 'channelsLast' and 'channelsFirst.`);let a;return n==="channelsFirst"?a=[[0,0],[0,0],t[0],t[1]]:a=[[0,0],t[0],t[1],[0,0]],Sa(e,a)})}var DA=class extends Qe{constructor(e){e==null&&(e={});super(e);if(this.dataFormat=e.dataFormat==null?er():e.dataFormat,e.padding==null)this.padding=[[1,1],[1,1]];else if(typeof e.padding=="number")this.padding=[[e.padding,e.padding],[e.padding,e.padding]];else{if(e.padding=e.padding,e.padding.length!==2)throw new 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 qt({ndim:4})]}computeOutputShape(e){e=pt(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(()=>cL(Le(e),this.padding,this.dataFormat))}getConfig(){let e={padding:this.padding,dataFormat:this.dataFormat},t=super.getConfig();return Object.assign(e,t),e}};DA.className="ZeroPadding2D";ue.registerClass(DA);function K0(e,t,n,a,r,s){return G(()=>{Bt(r),Av(s),Na(a),n==null&&(n=[1,1]),a==null&&(a="valid"),r==null&&(r=er()),s==null&&(s="max"),e=eA(e,r);let i,o=a==="same"?"same":"valid";return s==="max"?i=Jd(e,t,n,o):i=Hd(e,t,n,o),r==="channelsFirst"&&(i=Ze(i,[0,3,1,2])),i})}function R7(e,t,n,a,r,s){return G(()=>{Bt(r),Av(s),Na(a),n==null&&(n=[1,1,1]),a==null&&(a="valid"),r==null&&(r=er()),s==null&&(s="max"),e=I7(e,r);let i,o=a==="same"?"same":"valid";return s==="max"?i=Ug(e,t,n,o):i=Tg(e,t,n,o),r==="channelsFirst"&&(i=Ze(i,[0,4,1,2,3])),i})}var M7=class extends Qe{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(hn(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)}`);hn(this.strides,"strides"),this.padding=e.padding==null?"valid":e.padding,Na(this.padding),this.inputSpec=[new qt({ndim:3})]}computeOutputShape(e){e=pt(e);let t=ir(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=pp(Le(e),2);let n=this.poolingFunction(Le(e),[this.poolSize[0],1],[this.strides[0],1],this.padding,"channelsLast");return st(n,[2])})}getConfig(){let e={poolSize:this.poolSize,padding:this.padding,strides:this.strides},t=super.getConfig();return Object.assign(e,t),e}},$A=class extends M7{constructor(e){super(e)}poolingFunction(e,t,n,a,r){return Bt(r),Na(a),K0(e,t,n,a,r,"max")}};$A.className="MaxPooling1D";ue.registerClass($A);var OA=class extends M7{constructor(e){super(e)}poolingFunction(e,t,n,a,r){return Bt(r),Na(a),K0(e,t,n,a,r,"avg")}};OA.className="AveragePooling1D";ue.registerClass(OA);var F7=class extends Qe{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];hn(this.poolSize,"poolSize"),hn(this.strides,"strides"),this.padding=e.padding==null?"valid":e.padding,this.dataFormat=e.dataFormat==null?"channelsLast":e.dataFormat,Bt(this.dataFormat),Na(this.padding),this.inputSpec=[new qt({ndim:4})]}computeOutputShape(e){e=pt(e);let t=this.dataFormat==="channelsFirst"?e[2]:e[1],n=this.dataFormat==="channelsFirst"?e[3]:e[2];return t=ir(t,this.poolSize[0],this.padding,this.strides[0]),n=ir(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}},_A=class extends F7{constructor(e){super(e)}poolingFunction(e,t,n,a,r){return Bt(r),Na(a),K0(e,t,n,a,r,"max")}};_A.className="MaxPooling2D";ue.registerClass(_A);var PA=class extends F7{constructor(e){super(e)}poolingFunction(e,t,n,a,r){return Bt(r),Na(a),K0(e,t,n,a,r,"avg")}};PA.className="AveragePooling2D";ue.registerClass(PA);var D7=class extends Qe{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];hn(this.poolSize,"poolSize"),hn(this.strides,"strides"),this.padding=e.padding==null?"valid":e.padding,this.dataFormat=e.dataFormat==null?"channelsLast":e.dataFormat,Bt(this.dataFormat),Na(this.padding),this.inputSpec=[new qt({ndim:5})]}computeOutputShape(e){e=pt(e);let t=this.dataFormat==="channelsFirst"?e[2]:e[1],n=this.dataFormat==="channelsFirst"?e[3]:e[2],a=this.dataFormat==="channelsFirst"?e[4]:e[3];return t=ir(t,this.poolSize[0],this.padding,this.strides[0]),n=ir(n,this.poolSize[1],this.padding,this.strides[1]),a=ir(a,this.poolSize[2],this.padding,this.strides[2]),this.dataFormat==="channelsFirst"?[e[0],e[1],t,n,a]:[e[0],t,n,a,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}},zA=class extends D7{constructor(e){super(e)}poolingFunction(e,t,n,a,r){return Bt(r),Na(a),R7(e,t,n,a,r,"max")}};zA.className="MaxPooling3D";ue.registerClass(zA);var LA=class extends D7{constructor(e){super(e)}poolingFunction(e,t,n,a,r){return Bt(r),Na(a),R7(e,t,n,a,r,"avg")}};LA.className="AveragePooling3D";ue.registerClass(LA);var $7=class extends Qe{constructor(e){super(e);this.inputSpec=[new qt({ndim:3})]}computeOutputShape(e){return[e[0],e[2]]}call(e,t){throw new Pe}},WA=class extends $7{constructor(e){super(e||{})}call(e,t){return G(()=>{let n=Le(e);return Dt(n,1)})}};WA.className="GlobalAveragePooling1D";ue.registerClass(WA);var BA=class extends $7{constructor(e){super(e||{})}call(e,t){return G(()=>{let n=Le(e);return Rn(n,1)})}};BA.className="GlobalMaxPooling1D";ue.registerClass(BA);var O7=class extends Qe{constructor(e){super(e);this.dataFormat=e.dataFormat==null?"channelsLast":e.dataFormat,Bt(this.dataFormat),this.inputSpec=[new qt({ndim:4})]}computeOutputShape(e){return e=e,this.dataFormat==="channelsLast"?[e[0],e[3]]:[e[0],e[1]]}call(e,t){throw new Pe}getConfig(){let e={dataFormat:this.dataFormat},t=super.getConfig();return Object.assign(e,t),e}},VA=class extends O7{call(e,t){return G(()=>{let n=Le(e);return this.dataFormat==="channelsLast"?Dt(n,[1,2]):Dt(n,[2,3])})}};VA.className="GlobalAveragePooling2D";ue.registerClass(VA);var UA=class extends O7{call(e,t){return G(()=>{let n=Le(e);return this.dataFormat==="channelsLast"?Rn(n,[1,2]):Rn(n,[2,3])})}};UA.className="GlobalMaxPooling2D";ue.registerClass(UA);var _7=class extends Qe{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 a=t.layer,r=sr(a,n);delete t.layer;let s={layer:r};return Object.assign(s,t),new e(s)}},jA=class extends _7{constructor(e){super(e);this.supportsMasking=!0}build(e){if(e=pt(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=pt(e);let t=[e[0]].concat(e.slice(2)),n=this.layer.computeOutputShape(t),a=e[1];return[n[0],a].concat(n.slice(1))}call(e,t){return G(()=>(e=Le(e),C7((n,a)=>[Le(this.layer.call(n,t)),[]],e,[],!1,null,null,!1,!0)[1]))}};jA.className="TimeDistributed";ue.registerClass(jA);function hL(e){fo(xP,"BidirectionalMergeMode",e)}var fL="concat",GA=class extends _7{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 a={};if(a.className=e.layer.getClassName(),a.config=t,this.backwardLayer=sr(a),this.forwardLayer.name="forward_"+this.forwardLayer.name,this.backwardLayer.name="backward_"+this.backwardLayer.name,this.mergeMode=e.mergeMode===void 0?fL:e.mergeMode,hL(this.mergeMode),e.weights)throw new Pe("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,a,r;return this.returnState&&(r=t.slice(1)),n=t[0],n=n,this.mergeMode==="concat"?(n[n.length-1]*=2,a=[n]):this.mergeMode==null?a=[n,n.slice()]:a=[n],this.returnState?this.mergeMode==null?a.concat(r).concat(r.slice()):[n].concat(r).concat(r.slice()):Jn(a)}apply(e,t){let n=t==null?null:t.initialState,a=t==null?null:t.constants;t==null&&(t={});let r=T7(e,n,a,this.numConstants);if(e=r.inputs,n=r.initialState,a=r.constants,Array.isArray(e)&&(n=e.slice(1),e=e[0]),(n==null||n.length===0)&&a==null)return super.apply(e,t);let s=[],i=[];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,s.push(...n);let d=n.map(u=>new qt({shape:u.shape}));this.forwardLayer.stateSpec=d.slice(0,l/2),this.backwardLayer.stateSpec=d.slice(l/2),i.push(...d)}if(a!=null)throw new Pe("Support for constants in Bidirectional layers is not implemented yet.");let o=s[0]instanceof rr;for(let l of s)if(l instanceof rr!==o)throw new H("The initial state of a Bidirectional layer cannot be specified as a mix of symbolic and non-symbolic tensors");if(o){let l=[e].concat(s),d=this.inputSpec.concat(i),u=this.inputSpec;this.inputSpec=d;let p=super.apply(l,t);return this.inputSpec=u,p}else return super.apply(e,t)}call(e,t){return G(()=>{let n=t.initialState,a,r;if(n==null)a=this.forwardLayer.call(e,t),r=this.backwardLayer.call(e,t);else{let o=n.slice(0,n.length/2),l=n.slice(n.length/2);a=this.forwardLayer.call(e,Object.assign(t,{initialState:o})),r=this.backwardLayer.call(e,Object.assign(t,{initialState:l}))}let s;this.returnState&&(Array.isArray(a)&&(s=a.slice(1).concat(r.slice(1))),a=a[0],r=r[0]),this.returnSequences&&(r=pa(r,1));let i;return this.mergeMode==="concat"?i=xy([a,r]):this.mergeMode==="sum"?i=le(a,r):this.mergeMode==="ave"?i=L(.5,le(a,r)):this.mergeMode==="mul"?i=L(a,r):this.mergeMode==null&&(i=[a,r]),this.returnState?this.mergeMode==null?i.concat(s):[i].concat(s):i})}resetStates(e){this.forwardLayer.resetStates(),this.backwardLayer.resetStates()}build(e){mo(this.forwardLayer.name,()=>{this.forwardLayer.build(e)}),mo(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 a=this.forwardLayer.states.map(r=>null);return Array.isArray(n)?n.concat(a).concat(a):[n].concat(a).concat(a)}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 Pe("Deserialization of a Bidirectional layer with numConstants present is not supported yet.");let a=t;return a.layer=n,new e(a)}};GA.className="Bidirectional";ue.registerClass(GA);function mL(e){return new bu(e)}function gL(e){return new Yy(e)}function yL(e){return new Xy(e)}function AL(e){return new Ky(e)}function xL(e){return new Zy(e)}function bL(e){return new Qy(e)}function vL(e){return new Jy(e)}function wL(e){return new U0(e)}function kL(e){return new bp(e)}function IL(e){return new nA(e)}function SL(e){return new vp(e)}function NL(e){return new aA(e)}function TL(e){return new rA(e)}function CL(e){return new sA(e)}function EL(e){return new iA(e)}function RL(e){return new oA(e)}function ML(e){return new mA(e)}function FL(e){return new hA(e)}function DL(e){return new X0(e)}function $L(e){return new cA(e)}function OL(e){return new fA(e)}function _L(e){return new gA(e)}function PL(e){return new yA(e)}function zL(e){return new AA(e)}function LL(e){return new bA(e)}function WL(e){return new vA(e)}function BL(e){return new kA(e)}function VL(e){return new NA(e)}function UL(e){return new IA(e)}function jL(e){return new SA(e)}function GL(e){return new wA(e)}function HL(e){return new TA(e)}function qL(e){return new MA(e)}function XL(e){return new FA(e)}function KL(e){return new DA(e)}function HA(e){return new OA(e)}function ZL(e){return HA(e)}function YL(e){return HA(e)}function qA(e){return new PA(e)}function JL(e){return qA(e)}function QL(e){return qA(e)}function XA(e){return new LA(e)}function eW(e){return XA(e)}function tW(e){return XA(e)}function nW(e){return new WA(e)}function aW(e){return new VA(e)}function P7(e){return new BA(e)}function z7(e){return new UA(e)}function L7(e){return new $A(e)}function W7(e){return new _A(e)}function rW(e){return new zA(e)}function sW(e){return new uA(e)}function iW(e){return new G0(e)}function oW(e){return new dA(e)}function lW(e){return new kp(e)}function uW(e){return new lA(e)}function dW(e){return new j0(e)}function pW(e){return new pA(e)}function cW(e){return new q0(e)}function hW(e){return new Ir(e)}function fW(e){return new H0(e)}function mW(e){return new GA(e)}function gW(e){return new jA(e)}var yW=P7,AW=z7,xW=L7,bW=W7;function vW(e){return new CA(e)}function wW(e){return new EA(e)}function kW(e){return new RA(e)}function IW(e){return new xA(e)}var B7={};ze(B7,{MAPE:()=>OW,MSE:()=>zW,binaryAccuracy:()=>SW,binaryCrossentropy:()=>NW,categoricalAccuracy:()=>CW,categoricalCrossentropy:()=>EW,cosineProximity:()=>FW,mape:()=>_W,meanAbsoluteError:()=>DW,meanAbsolutePercentageError:()=>$W,meanSquaredError:()=>PW,mse:()=>LW,precision:()=>RW,recall:()=>MW,sparseCategoricalAccuracy:()=>TW});function SW(e,t){return $y(e,t)}function NW(e,t){return Uv(e,t)}function TW(e,t){return jv(e,t)}function CW(e,t){return Oy(e,t)}function EW(e,t){return _y(e,t)}function RW(e,t){return Vv(e,t)}function MW(e,t){return fz(e,t)}function FW(e,t){return Fy(e,t)}function DW(e,t){return _0(e,t)}function $W(e,t){return wu(e,t)}function OW(e,t){return wu(e,t)}function _W(e,t){return wu(e,t)}function PW(e,t){return yo(e,t)}function zW(e,t){return yo(e,t)}function LW(e,t){return yo(e,t)}var V7={};ze(V7,{modelFromJSON:()=>Xz});var U7={};ze(U7,{l1:()=>BW,l1l2:()=>WW,l2:()=>VW});function WW(e){return new Ap(e)}function BW(e){return nL(e)}function VW(e){return aL(e)}var j7=class extends vu{constructor(){super(...arguments);this.model=null}setModel(e){if(!(e instanceof Vr))throw new Error("model must be a LayersModel, not some other Container");this.model=e}};function Z0(e,t){return e<t}function G7(e,t){return e>t}var H7=class extends j7{constructor(e){super();if(e==null&&(e={}),e.restoreBestWeights)throw new Pe("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=Z0:this.mode==="max"?this.monitorFunc=G7:this.monitor.indexOf("acc")!==-1?this.monitorFunc=G7:this.monitorFunc=Z0,this.monitorFunc===Z0&&(this.minDelta*=-1)}async onTrainBegin(e){this.wait=0,this.stoppedEpoch=0,this.baseline!=null?this.best=this.baseline:this.best=this.monitorFunc===Z0?1/0:-1/0}async onEpochEnd(e,t){await Ss(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 UW(e){return new H7(e)}var jW={earlyStopping:UW},or;(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"})(or||(or={}));var q7;(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={}))})(q7||(q7={}));var KA={};function GW(e,t){let n={tfOpName:e,category:"custom",inputs:[],attrs:[],customExecutor:t};KA[e]=n}function X7(e){return KA[e]}function HW(e){delete KA[e]}function I(e,t,n,a,r){let s=t.inputParams[e];if(s&&s.inputIndexStart!==void 0){let o=s.inputIndexStart,l=s.inputIndexEnd===0?void 0:s.inputIndexEnd===void 0?o+1:s.inputIndexEnd;if(s.type==="tensor")return Dn(t.inputNames[s.inputIndexStart],n,a,r);if(s.type==="tensors")return t.inputNames.slice(o,l).map(p=>Dn(p,n,a,r));let d=Dn(t.inputNames.slice(o)[0],n,a,r),u=d.dataSync();return s.type==="number"?u[0]:w.toNestedArray(d.shape,u)}let i=t.attrParams[e];return i&&i.value}function Dn(e,t,n,a){let[r,s]=ca(e);if(a!=null){let o=a.getHashTableHandleByName(r);if(o!=null)return o}let i=n.currentContextIds.find(o=>!!t[Y0(r,o)]);return i!==void 0?t[Y0(r,i)][s]:void 0}function qW(e,t,n){return t[Y0(e,n.currentContextId)]}function Ur(e,t){let[n,a,r]=ca(e);return[Y0(n,t&&t.currentContextId),a,r]}function Y0(e,t){return t?`${e}-${t}`:e}function ca(e){let t=e.split(":");if(t.length===1)return[e,0,void 0];let n=t[0],a=t.length===3?t[1]:void 0,r=Number(t[t.length-1]);return[n,r,a]}function J0(e,t,n){let a=I("pad",e,t,n);if(a==="explicit"){a=I("explicitPaddings",e,t,n);let r=[[0,0],[0,0],[0,0],[0,0]];for(let s=0;s<4;s++)r[s][0]=a[s*2],r[s][1]=a[s*2+1];return r}return a}function jr(e){return e.kept?e:Za(e)}var K7={};ze(K7,{json:()=>XW});var XW=[{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}]}],Z7={};ze(Z7,{json:()=>KW});var KW=[{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}]}],Y7={};ze(Y7,{json:()=>ZW});var ZW=[{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"}]}],J7={};ze(J7,{json:()=>YW});var YW=[{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"}]}],Q7={};ze(Q7,{json:()=>JW});var JW=[{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"}]}],ew={};ze(ew,{json:()=>QW});var QW=[{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}]}],tw={};ze(tw,{json:()=>eB});var eB=[{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"}]}],nw={};ze(nw,{json:()=>tB});var tB=[{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"}]}],aw={};ze(aw,{json:()=>nB});var nB=[{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"}]}],rw={};ze(rw,{json:()=>aB});var aB=[{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"}]}],sw={};ze(sw,{json:()=>rB});var rB=[{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}]}],iw={};ze(iw,{json:()=>sB});var sB=[{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"}]}],ow={};ze(ow,{json:()=>iB});var iB=[{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}]}],lw={};ze(lw,{json:()=>oB});var oB=[{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"}]}],uw={};ze(uw,{json:()=>lB});var lB=[{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}]}],dw={};ze(dw,{json:()=>uB});var uB=[{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"}]}],pw={};ze(pw,{json:()=>dB});var dB=[{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}]}],cw={};ze(cw,{json:()=>pB});var pB=[{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"}]}],hw={};ze(hw,{json:()=>cB});var cB=[{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:[]}],fw=class{static get Instance(){return this._instance||(this._instance=new this)}constructor(){let e=[K7,Z7,Y7,J7,Q7,ew,tw,nw,aw,rw,sw,iw,ow,lw,uw,dw,pw,cw,hw],t=[].concat(...e.map(n=>n.json));this.opMappers=t.reduce((n,a)=>(n[a.tfOpName]=a,n),{})}transformGraph(e,t={}){let n=e.node,a=[],r=[],s=[],i=n.reduce((f,m)=>(f[m.name]=this.mapNode(m),m.op.startsWith("Placeholder")?a.push(f[m.name]):m.op==="Const"?r.push(f[m.name]):(m.input==null||m.input.length===0)&&s.push(f[m.name]),f),{}),o=[],l=[],d={},u={};t!=null&&(d=this.mapSignatureEntries(t.inputs),u=this.mapSignatureEntries(t.outputs));let p=Object.keys(i);p.forEach(f=>{let m=i[f];m.inputNames.forEach((g,y)=>{let[A,,x]=Ur(g),b=i[A];if(b.outputs!=null){let v=b.outputs.indexOf(x);if(v!==-1){let k=`${A}:${v}`;m.inputNames[y]=k}}m.inputs.push(b),b.children.push(m)})}),Object.keys(u).length===0?p.forEach(f=>{let m=i[f];m.children.length===0&&l.push(m)}):Object.keys(u).forEach(f=>{let[m]=Ur(f),g=i[m];g!=null&&(g.signatureKey=u[f],l.push(g))}),Object.keys(d).length>0?Object.keys(d).forEach(f=>{let[m]=Ur(f),g=i[m];g&&(g.signatureKey=d[f],o.push(g))}):o=a;let c={};e.library!=null&&e.library.function!=null&&(c=e.library.function.reduce((f,m)=>(f[m.signature.name]=this.mapFunction(m),f),{}));let h={nodes:i,inputs:o,outputs:l,weights:r,placeholders:a,signature:t,functions:c};return s.length>0&&(h.initNodes=s),h}mapSignatureEntries(e){return Object.keys(e||{}).reduce((t,n)=>(t[e[n].name]=n,t),{})}mapNode(e){let t=X7(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(a=>a.startsWith("^")?a.substr(1):a),inputs:[],children:[],inputParams:{},attrParams:{},rawAttrs:e.attr,outputs:t.outputs};return t.inputs!=null&&(n.inputParams=t.inputs.reduce((a,r)=>(a[r.name]={type:r.type,inputIndexStart:r.start,inputIndexEnd:r.end},a),{})),t.attrs!=null&&(n.attrParams=t.attrs.reduce((a,r)=>{let s=r.type,i;switch(r.type){case"string":i=ZA(e.attr,r.tfName,r.defaultValue),i===void 0&&!!r.tfDeprecatedName&&(i=ZA(e.attr,r.tfDeprecatedName,r.defaultValue));break;case"string[]":i=r2(e.attr,r.tfName,r.defaultValue),i===void 0&&!!r.tfDeprecatedName&&(i=r2(e.attr,r.tfDeprecatedName,r.defaultValue));break;case"number":i=JA(e.attr,r.tfName,r.defaultValue||0),i===void 0&&!!r.tfDeprecatedName&&(i=JA(e.attr,r.tfDeprecatedName,r.defaultValue));break;case"number[]":i=a2(e.attr,r.tfName,r.defaultValue),i===void 0&&!!r.tfDeprecatedName&&(i=a2(e.attr,r.tfDeprecatedName,r.defaultValue));break;case"bool":i=YA(e.attr,r.tfName,r.defaultValue),i===void 0&&!!r.tfDeprecatedName&&(i=YA(e.attr,r.tfDeprecatedName,r.defaultValue));break;case"bool[]":i=i2(e.attr,r.tfName,r.defaultValue),i===void 0&&!!r.tfDeprecatedName&&(i=i2(e.attr,r.tfDeprecatedName,r.defaultValue));break;case"shape":i=n2(e.attr,r.tfName,r.defaultValue),i===void 0&&!!r.tfDeprecatedName&&(i=n2(e.attr,r.tfDeprecatedName,r.defaultValue));break;case"shape[]":i=s2(e.attr,r.tfName,r.defaultValue),i===void 0&&!!r.tfDeprecatedName&&(i=s2(e.attr,r.tfDeprecatedName,r.defaultValue));break;case"dtype":i=e2(e.attr,r.tfName,r.defaultValue),i===void 0&&!!r.tfDeprecatedName&&(i=e2(e.attr,r.tfDeprecatedName,r.defaultValue));break;case"dtype[]":i=t2(e.attr,r.tfName,r.defaultValue),i===void 0&&!!r.tfDeprecatedName&&(i=t2(e.attr,r.tfDeprecatedName,r.defaultValue));break;case"func":i=gw(e.attr,r.tfName,r.defaultValue),i===void 0&&!!r.tfDeprecatedName&&(i=gw(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 a[r.name]={value:i,type:s},a},{})),n}mapFunction(e){let t=e.nodeDef,n=[],a=[],r={};t!=null&&(r=t.reduce((d,u)=>(d[u.name]=this.mapNode(u),u.op==="Const"&&a.push(d[u.name]),d),{}));let s=[],i=[];e.signature.inputArg.forEach(d=>{let[u]=Ur(d.name),p={name:u,op:"Placeholder",inputs:[],inputNames:[],category:"graph",inputParams:{},attrParams:{dtype:{value:QA(d.type),type:"dtype"}},children:[]};p.signatureKey=d.name,s.push(p),r[u]=p}),Object.keys(r).forEach(d=>{let u=r[d];u.inputNames.forEach((p,c)=>{let[h,,f]=Ur(p),m=r[h];if(m.outputs!=null){let g=m.outputs.indexOf(f);if(g!==-1){let y=`${h}:${g}`;u.inputNames[c]=y}}u.inputs.push(m),m.children.push(u)})});let o=e.ret;e.signature.outputArg.forEach(d=>{let[u,p]=Ur(o[d.name]),c=r[u];c!=null&&(c.defaultOutput=p,i.push(c))});let l=this.mapArgsToSignature(e);return{nodes:r,inputs:s,outputs:i,weights:a,placeholders:n,signature:l}}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 hB(e){let t=ne().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 mw(e,t){let n=Array.isArray(e)?String.fromCharCode.apply(null,e):hB(e);return t?n:n.toLowerCase()}function ZA(e,t,n,a=!1){let r=e[t];return r!=null?mw(r.s,a):n}function YA(e,t,n){let a=e[t];return a?a.b:n}function JA(e,t,n){let a=e[t]||{},r=a.i!=null?a.i:a.f!=null?a.f:n;return typeof r=="number"?r:parseInt(r,10)}function QA(e){switch(typeof e=="string"&&(e=or[e]),e){case or.DT_FLOAT:return"float32";case or.DT_INT32:case or.DT_INT64:case or.DT_INT8:case or.DT_UINT8:return"int32";case or.DT_BOOL:return"bool";case or.DT_DOUBLE:return"float32";case or.DT_STRING:return"string";default:return null}}function gw(e,t,n){let a=e[t];return a&&a.func?a.func.name:n}function e2(e,t,n){let a=e[t];return a&&a.type?QA(a.type):n}function t2(e,t,n){let a=e[t];return a&&a.list&&a.list.type?a.list.type.map(r=>QA(r)):n}function yw(e){if(!e.unknownRank)return e.dim!=null?e.dim.map(t=>typeof t.size=="number"?t.size:parseInt(t.size,10)):[]}function n2(e,t,n){let a=e[t];return a&&a.shape?yw(a.shape):n}function a2(e,t,n){let a=e[t];return a?((a.list.f&&a.list.f.length?a.list.f:a.list.i)||[]).map(r=>typeof r=="number"?r:parseInt(r,10)):n}function r2(e,t,n,a=!1){let r=e[t];return r&&r.list&&r.list.s?r.list.s.map(s=>mw(s,a)):n}function s2(e,t,n){let a=e[t];return a&&a.list&&a.list.shape?a.list.shape.map(r=>yw(r)):n}function i2(e,t,n){let a=e[t];return a&&a.list&&a.list.b?a.list.b:n}var fB=class{constructor(e,t,n){this.node=e,this.tensorMap=t,this.context=n,this.inputs=[],this.attrs={},this.inputs=e.inputNames.map(a=>this.getInput(a)),e.rawAttrs!=null&&(this.attrs=Object.keys(e.rawAttrs).reduce((a,r)=>(a[r]=this.getAttr(r),a),{}))}getInput(e){return Dn(e,this.tensorMap,this.context)}getAttr(e,t){let n=this.node.rawAttrs[e];if(n.tensor!=null)return Dn(e,this.tensorMap,this.context);if(n.i!=null||n.f!=null)return JA(this.node.rawAttrs,e,t);if(n.s!=null)return ZA(this.node.rawAttrs,e,t);if(n.b!=null)return YA(this.node.rawAttrs,e,t);if(n.shape!=null)return n2(this.node.rawAttrs,e,t);if(n.type!=null)return e2(this.node.rawAttrs,e,t);if(n.list!=null){if(n.list.i!=null||n.list.f!=null)return a2(this.node.rawAttrs,e,t);if(n.list.s!=null)return r2(this.node.rawAttrs,e,t);if(n.list.shape!=null)return s2(this.node.rawAttrs,e,t);if(n.list.b!=null)return i2(this.node.rawAttrs,e,t);if(n.list.type!=null)return t2(this.node.rawAttrs,e,t)}return t}},mB=(e,t,n)=>{switch(e.op){case"BiasAdd":case"AddV2":case"Add":return[le(I("a",e,t,n),I("b",e,t,n))];case"AddN":return[_h(I("tensors",e,t,n))];case"FloorMod":case"Mod":return[Gg(I("a",e,t,n),I("b",e,t,n))];case"Mul":return[L(I("a",e,t,n),I("b",e,t,n))];case"RealDiv":case"Div":return[he(I("a",e,t,n),I("b",e,t,n))];case"DivNoNan":return[$g(I("a",e,t,n),I("b",e,t,n))];case"FloorDiv":return[Oh(I("a",e,t,n),I("b",e,t,n))];case"Sub":return[ge(I("a",e,t,n),I("b",e,t,n))];case"Minimum":return[pu(I("a",e,t,n),I("b",e,t,n))];case"Maximum":return[Ar(I("a",e,t,n),I("b",e,t,n))];case"Pow":return[Pr(I("a",e,t,n),I("b",e,t,n))];case"SquaredDifference":return[r0(I("a",e,t,n),I("b",e,t,n))];default:throw TypeError(`Node type ${e.op} is not implemented`)}},gB=(e,t,n)=>{switch(e.op){case"Abs":case"ComplexAbs":return[jt(I("x",e,t,n))];case"Acos":return[yg(I("x",e,t,n))];case"Acosh":return[Ag(I("x",e,t,n))];case"Asin":return[bg(I("x",e,t,n))];case"Asinh":return[vg(I("x",e,t,n))];case"Atan":return[wg(I("x",e,t,n))];case"Atan2":return[kg(I("x",e,t,n),I("y",e,t,n))];case"Atanh":return[Ig(I("x",e,t,n))];case"Ceil":return[Eg(I("x",e,t,n))];case"Complex":return[fs(I("real",e,t,n),I("imag",e,t,n))];case"Cos":return[Xd(I("x",e,t,n))];case"Cosh":return[Bh(I("x",e,t,n))];case"Elu":return[lu(I("x",e,t,n))];case"Erf":return[Og(I("x",e,t,n))];case"Exp":return[oa(I("x",e,t,n))];case"Expm1":return[_g(I("x",e,t,n))];case"Floor":return[du(I("x",e,t,n))];case"Log":return[la(I("x",e,t,n))];case"Log1p":return[Zd(I("x",e,t,n))];case"Imag":return[Uh(I("x",e,t,n))];case"Neg":return[Tt(I("x",e,t,n))];case"Reciprocal":return[Xg(I("x",e,t,n))];case"Real":return[np(I("x",e,t,n))];case"Relu":return[Ja(I("x",e,t,n))];case"Round":return[Yh(I("x",e,t,n))];case"Selu":return[Qh(I("x",e,t,n))];case"Sigmoid":return[Kn(I("x",e,t,n))];case"Sin":return[e0(I("x",e,t,n))];case"Sign":return[Zg(I("x",e,t,n))];case"Sinh":return[t0(I("x",e,t,n))];case"Softplus":return[so(I("x",e,t,n))];case"Sqrt":return[An(I("x",e,t,n))];case"Square":return[ht(I("x",e,t,n))];case"Tanh":return[no(I("x",e,t,n))];case"Tan":return[Qg(I("x",e,t,n))];case"ClipByValue":return[Zn(I("x",e,t,n),I("clipValueMin",e,t,n),I("clipValueMax",e,t,n))];case"Relu6":return[Zh(I("x",e,t,n))];case"Rsqrt":return[Jh(Dn(e.inputNames[0],t,n))];case"Prod":return[Kh(I("x",e,t,n),I("axes",e,t,n))];case"LeakyRelu":return[Kd(I("x",e,t,n),I("alpha",e,t,n))];case"Prelu":return[tp(I("x",e,t,n),I("alpha",e,t,n))];case"IsNan":return[zg(Dn(e.inputNames[0],t,n))];default:throw TypeError(`Node type ${e.op} is not implemented`)}};function Ua(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 a=0;a<e.length;a++){let r=e[a],s=t[a];w.assert(r<0||s<0||r===s,()=>n+` Shapes ${e} and ${t} must match`)}}}function Aw(e){return!(typeof e=="number"||e.some(t=>t<0))}function Np(e,t,n){let a=o2(e,n),r=!Aw(a);if(r&&t.length===0)throw new Error(`Tried to calculate elements of an empty list with non-fully-defined elementShape: ${a}`);if(r&&t.forEach(s=>{a=o2(s.shape,a)}),!Aw(a))throw new Error(`Non-fully-defined elementShape: ${a}`);return a}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 a=0;a<e.length;++a){let r=e[a],s=t[a];if(r>=0&&s>=0&&r!==s)throw new Error(`Incompatible shape during merge: ${e} vs. ${t}`);n[a]=r>=0?r:s}return n}var yB=class{constructor(e,t,n,a,r,s,i){this.name=e,this.dtype=t,this.maxSize=n,this.elementShape=a,this.identicalElementShapes=r,this.dynamicSize=s,this.clearAfterRead=i,this.tensors=[],this.closed_=!1,this.idTensor=Ce(0),pn(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),Ua(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,pn(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,a)=>this.write(n,t[a]))}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 a=0;a<this.size();a++)e.push(a)}if(e.length===0)return Lt([],[0].concat(this.elementShape));let n=this.readMany(e);return Ua(this.elementShape,n[0].shape,"TensorArray shape mismatch: "),xn(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 Lt([],[0].concat(this.elementShape));let t=[];for(let a=0;a<this.size();a++)t.push(a);let n=this.readMany(t);return Ua(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,Mn(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,a=e.map(o=>(n+=o,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,s=[];G(()=>{t=V(t,[1,n,r]);for(let o=0;o<e.length;++o){let l=o===0?0:a[o-1],d=[0,l,0],u=[1,e[o],r];s[o]=V(De(t,d,u),this.elementShape)}return s});let i=[];for(let o=0;o<e.length;o++)i[o]=o;this.writeMany(i,s)}},Tp=class{constructor(e,t,n,a=-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}`);Ua(t,r.shape,"TensorList shape mismatch: "),pn(r)}),this.idTensor=Ce(0),this.maxNumElements=a,pn(this.idTensor)}get id(){return this.idTensor.id}copy(){return new Tp([...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.`);Ua(e,this.elementShape,"TensorList shape mismatch: ");let a=Np(this.elementShape,this.tensors,e);return G(()=>{let r=this.tensors.map(s=>V(s,a));return xn(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=Np(this.elementShape,this.tensors,e),a=this.tensors.pop();return Ua(a.shape,e,"TensorList shape mismatch: "),V(a,n)}pushBack(e){if(e.dtype!==this.elementDtype)throw new Error(`Invalid data types; op elements ${e.dtype}, but list elements ${this.elementDtype}`);if(Ua(e.shape,this.elementShape,"TensorList shape mismatch: "),this.maxNumElements===this.size())throw new Error("Trying to push element into a full list.");pn(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.`);Ua(this.tensors[e].shape,t,"TensorList shape mismatch: ");let a=Np(this.elementShape,this.tensors,t);return V(this.tensors[e],a)}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.`);Ua(this.elementShape,t.shape,"TensorList shape mismatch: "),pn(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}`);Ua(this.elementShape,n,"TensorList shape mismatch: "),e=e.slice(0,this.size());let a=Np(this.elementShape,this.tensors,n);return e.length===0?Lt([],[0].concat(a)):G(()=>{let r=e.map(s=>V(this.tensors[s],a));return xn(r,0)})}concat(e,t){if(!!e&&e!==this.elementDtype)throw new Error(`TensorList dtype is ${this.elementDtype} but concat requested dtype ${e}`);Ua(this.elementShape,t,"TensorList shape mismatch: ");let n=Np(this.elementShape,this.tensors,t);return this.size()===0?Lt([],[0].concat(n)):G(()=>{let a=this.tensors.map(r=>V(r,n));return mt(a,0)})}};function AB(e,t,n){let a=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);Ua(r,t,"TensorList shape mismatch: ");let s=Mn(e);return new Tp(s,t,a)}function xB(e,t,n){return new Tp([],e,t,n)}function bB(e,t,n,a){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(a!=null&&a!==-1&&r>=a)throw new Error(`Max index must be < array size (${r} vs. ${a})`);let s=new Tp([],n,e.dtype,a),i=Mn(e,0);return t.forEach((o,l)=>{s.setItem(o,i[l])}),s}function vB(e,t,n){let a=0,r=t.map(u=>(a+=u,a));if(a!==e.shape[0])throw new Error(`Expected sum of lengths to be equal to
|
|
tensor.shape[0], but sum of lengths is
|
|
${a}, and tensor's shape is: ${e.shape}`);let s=e.shape.slice(1),i=o2(s,n),o=a===0?0:e.size/a,l=G(()=>{let u=[];e=V(e,[1,a,o]);for(let p=0;p<t.length;++p){let c=p===0?0:r[p-1],h=[0,c,0],f=[1,t[p],o];u[p]=V(De(e,h,f),i)}return e.dispose(),u}),d=new Tp([],n,e.dtype,t.length);for(let u=0;u<l.length;u++)d.setItem(u,l[u]);return d}var wB=async(e,t,n)=>{switch(e.op){case"If":case"StatelessIf":{let a=I("thenBranch",e,t,n),r=I("elseBranch",e,t,n),s=I("cond",e,t,n),i=I("args",e,t,n);return(await s.data())[0]?n.functionMap[a].executeFunctionAsync(i,n.tensorArrayMap,n.tensorListMap):n.functionMap[r].executeFunctionAsync(i,n.tensorArrayMap,n.tensorListMap)}case"While":case"StatelessWhile":{let a=I("body",e,t,n),r=I("cond",e,t,n),s=I("args",e,t,n),i=await n.functionMap[r].executeFunctionAsync(s,n.tensorArrayMap,n.tensorListMap),o=s.map(u=>u.id),l=await i[0].data();i.forEach(u=>{!u.kept&&o.indexOf(u.id)===-1&&u.dispose()});let d=s;for(;l[0];){let u=d;d=await n.functionMap[a].executeFunctionAsync(d,n.tensorArrayMap,n.tensorListMap);let p=d.map(h=>h.id);u.forEach(h=>{!h.kept&&o.indexOf(h.id)===-1&&p.indexOf(h.id)===-1&&h.dispose()});let c=await n.functionMap[r].executeFunctionAsync(d,n.tensorArrayMap,n.tensorListMap);l=await c[0].data(),c.forEach(h=>{!h.kept&&o.indexOf(h.id)===-1&&p.indexOf(h.id)===-1&&h.dispose()})}return d}case"LoopCond":{let a=I("pred",e,t,n);return[jr(a)]}case"Switch":{let a=I("pred",e,t,n),r=I("data",e,t,n);return r.kept||(r=jr(r)),(await a.data())[0]?[void 0,r]:[r,void 0]}case"Merge":{let a=e.inputNames.find(r=>Dn(r,t,n)!==void 0);if(a){let r=Dn(a,t,n);return[jr(r)]}return}case"Enter":{let a=I("frameName",e,t,n),r=I("tensor",e,t,n);return n.enterFrame(a),[jr(r)]}case"Exit":{let a=I("tensor",e,t,n);return n.exitFrame(),[jr(a)]}case"NextIteration":{let a=I("tensor",e,t,n);return n.nextIteration(),[jr(a)]}case"TensorArrayV3":{let a=I("size",e,t,n),r=I("dtype",e,t,n),s=I("elementShape",e,t,n),i=I("dynamicSize",e,t,n),o=I("clearAfterRead",e,t,n),l=I("identicalElementShapes",e,t,n),d=I("name",e,t,n),u=new yB(d,r,a,s,l,i,o);return n.addTensorArray(u),[u.idTensor,Ce(1)]}case"TensorArrayWriteV3":{let a=I("tensorArrayId",e,t,n),r=I("index",e,t,n),s=I("tensor",e,t,n),i=n.getTensorArray(a.id);return i.write(r,s),[i.idTensor]}case"TensorArrayReadV3":{let a=I("tensorArrayId",e,t,n),r=I("index",e,t,n);return[n.getTensorArray(a.id).read(r)]}case"TensorArrayGatherV3":{let a=I("tensorArrayId",e,t,n),r=I("indices",e,t,n),s=I("dtype",e,t,n);return[n.getTensorArray(a.id).gather(r,s)]}case"TensorArrayScatterV3":{let a=I("tensorArrayId",e,t,n),r=I("indices",e,t,n),s=I("tensor",e,t,n),i=n.getTensorArray(a.id);return i.scatter(r,s),[i.idTensor]}case"TensorArrayConcatV3":{let a=I("tensorArrayId",e,t,n),r=n.getTensorArray(a.id),s=I("dtype",e,t,n);return[r.concat(s)]}case"TensorArraySplitV3":{let a=I("tensorArrayId",e,t,n),r=I("tensor",e,t,n),s=I("lengths",e,t,n),i=n.getTensorArray(a.id);return i.split(s,r),[i.idTensor]}case"TensorArraySizeV3":{let a=I("tensorArrayId",e,t,n),r=n.getTensorArray(a.id);return[Ce(r.size(),"int32")]}case"TensorArrayCloseV3":{let a=I("tensorArrayId",e,t,n),r=n.getTensorArray(a.id);return r.clearAndClose(),[r.idTensor]}case"TensorListSetItem":{let a=I("tensorListId",e,t,n),r=I("index",e,t,n),s=I("tensor",e,t,n),i=n.getTensorList(a.id);return i.setItem(r,s),[i.idTensor]}case"TensorListGetItem":{let a=I("tensorListId",e,t,n),r=I("index",e,t,n),s=I("elementShape",e,t,n),i=I("elementDType",e,t,n);return[n.getTensorList(a.id).getItem(r,s,i)]}case"TensorListScatterV2":case"TensorListScatter":{let a=I("indices",e,t,n),r=I("tensor",e,t,n),s=I("elementShape",e,t,n),i=I("numElements",e,t,n),o=bB(r,a,s,i);return n.addTensorList(o),[o.idTensor]}case"TensorListReserve":case"EmptyTensorList":{let a=I("elementShape",e,t,n),r=I("elementDType",e,t,n),s;e.op==="TensorListReserve"?s="numElements":s="maxNumElements";let i=I(s,e,t,n),o=xB(a,r,i);return n.addTensorList(o),[o.idTensor]}case"TensorListGather":{let a=I("tensorListId",e,t,n),r=I("indices",e,t,n),s=I("elementShape",e,t,n),i=I("elementDType",e,t,n);return[n.getTensorList(a.id).gather(r,i,s)]}case"TensorListStack":{let a=I("tensorListId",e,t,n),r=I("elementShape",e,t,n),s=I("elementDType",e,t,n),i=I("numElements",e,t,n);return[n.getTensorList(a.id).stack(r,s,i)]}case"TensorListFromTensor":{let a=I("tensor",e,t,n),r=I("elementShape",e,t,n),s=I("elementDType",e,t,n),i=AB(a,r,s);return n.addTensorList(i),[i.idTensor]}case"TensorListConcat":{let a=I("tensorListId",e,t,n),r=n.getTensorList(a.id),s=I("dtype",e,t,n),i=I("elementShape",e,t,n);return[r.concat(s,i)]}case"TensorListPushBack":{let a=I("tensorListId",e,t,n),r=I("tensor",e,t,n),s=n.getTensorList(a.id);return s.pushBack(r),[s.idTensor]}case"TensorListPopBack":{let a=I("tensorListId",e,t,n),r=I("elementShape",e,t,n),s=I("elementDType",e,t,n);return[n.getTensorList(a.id).popBack(r,s)]}case"TensorListSplit":{let a=I("tensor",e,t,n),r=I("elementShape",e,t,n),s=I("lengths",e,t,n),i=vB(a,s,r);return n.addTensorList(i),[i.idTensor]}default:throw TypeError(`Node type ${e.op} is not implemented`)}};function xw(e,t,n){let[a,r]=I("fusedOps",e,t,n),s=a==="biasadd",i=!s,o=r==="prelu",l=a==="fusedbatchnorm",d=I("numArgs",e,t,n);if(s){if(o&&d!==2)throw new Error("FusedConv2d and DepthwiseConv2d with BiasAdd and Prelu must have two extra arguments: bias and alpha.");if(!o&&s&&d!==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=I("strides",e,t,n),p=J0(e,t,n),c=I("dataFormat",e,t,n).toUpperCase(),h=I("dilations",e,t,n),[f,m]=I("args",e,t,n);i&&(m=f,f=void 0);let g=I("leakyreluAlpha",e,t,n);return{stride:u,pad:p,dataFormat:c,dilations:h,biasArg:f,preluArg:m,activationFunc:r,leakyreluAlpha:g}}var kB=(e,t,n)=>{switch(e.op){case"Conv1D":{let a=I("stride",e,t,n),r=I("pad",e,t,n),s=I("dataFormat",e,t,n).toUpperCase(),i=I("dilation",e,t,n);return[Lh(I("x",e,t,n),I("filter",e,t,n),a,r,s,i)]}case"Conv2D":{let a=I("strides",e,t,n),r=J0(e,t,n),s=I("dataFormat",e,t,n).toUpperCase(),i=I("dilations",e,t,n);return[_r(I("x",e,t,n),I("filter",e,t,n),[a[1],a[2]],r,s,[i[1],i[2]])]}case"_FusedConv2D":{let{stride:a,pad:r,dataFormat:s,dilations:i,biasArg:o,preluArg:l,activationFunc:d,leakyreluAlpha:u}=xw(e,t,n);return[vs.conv2d({x:I("x",e,t,n),filter:I("filter",e,t,n),strides:[a[1],a[2]],pad:r,dataFormat:s,dilations:[i[1],i[2]],bias:o,activation:d,preluActivationWeights:l,leakyreluAlpha:u})]}case"FusedDepthwiseConv2dNative":{let{stride:a,pad:r,dataFormat:s,dilations:i,biasArg:o,preluArg:l,activationFunc:d,leakyreluAlpha:u}=xw(e,t,n);return[vs.depthwiseConv2d({x:I("x",e,t,n),filter:I("filter",e,t,n),strides:[a[1],a[2]],pad:r,dataFormat:s,dilations:[i[1],i[2]],bias:o,activation:d,preluActivationWeights:l,leakyreluAlpha:u})]}case"Conv2DBackpropInput":case"Conv2dTranspose":{let a=I("outputShape",e,t,n),r=I("strides",e,t,n),s=J0(e,t,n);return[Wh(I("x",e,t,n),I("filter",e,t,n),a,[r[1],r[2]],s)]}case"DepthwiseConv2dNative":case"DepthwiseConv2d":{let a=I("strides",e,t,n),r=J0(e,t,n),s=I("dilations",e,t,n),i=I("dataFormat",e,t,n).toUpperCase();return[ou(I("input",e,t,n),I("filter",e,t,n),[a[1],a[2]],r,i,[s[1],s[2]])]}case"Conv3D":{let a=I("strides",e,t,n),r=I("pad",e,t,n),s=I("dataFormat",e,t,n).toUpperCase(),i=I("dilations",e,t,n);return[Mg(I("x",e,t,n),I("filter",e,t,n),[a[1],a[2],a[3]],r,s,[i[1],i[2],i[3]])]}case"AvgPool":{let a=I("strides",e,t,n),r=I("pad",e,t,n),s=I("kernelSize",e,t,n);return[Hd(I("x",e,t,n),[s[1],s[2]],[a[1],a[2]],r)]}case"MaxPool":{let a=I("strides",e,t,n),r=I("pad",e,t,n),s=I("kernelSize",e,t,n);return[Jd(I("x",e,t,n),[s[1],s[2]],[a[1],a[2]],r)]}case"MaxPoolWithArgmax":{let a=I("strides",e,t,n),r=I("pad",e,t,n),s=I("kernelSize",e,t,n),i=I("includeBatchInIndex",e,t,n),{result:o,indexes:l}=N3(I("x",e,t,n),[s[1],s[2]],[a[1],a[2]],r,i);return[o,l]}case"AvgPool3D":{let a=I("strides",e,t,n),r=I("pad",e,t,n),s=I("kernelSize",e,t,n);return[Tg(I("x",e,t,n),[s[1],s[2],s[3]],[a[1],a[2],a[3]],r)]}case"MaxPool3D":{let a=I("strides",e,t,n),r=I("pad",e,t,n),s=I("kernelSize",e,t,n);return[Ug(I("x",e,t,n),[s[1],s[2],s[3]],[a[1],a[2],a[3]],r)]}case"Dilation2D":{let a=I("strides",e,t,n),r=I("pad",e,t,n),s=I("dilations",e,t,n),i=a[1],o=a[2],l=s[1],d=s[2];return[Dg(I("x",e,t,n),I("filter",e,t,n),[i,o],r,[l,d],"NHWC")]}default:throw TypeError(`Node type ${e.op} is not implemented`)}},IB=(e,t,n)=>{switch(e.op){case"Fill":{let a=I("shape",e,t,n),r=I("dtype",e,t,n),s=I("value",e,t,n);return[uu(a,s,r)]}case"LinSpace":{let a=I("start",e,t,n),r=I("stop",e,t,n),s=I("num",e,t,n);return[x3(a,r,s)]}case"Multinomial":{let a=I("logits",e,t,n),r=I("numSamples",e,t,n),s=I("seed",e,t,n);return[T3(a,r,s)]}case"OneHot":{let a=I("indices",e,t,n),r=I("depth",e,t,n),s=I("onValue",e,t,n),i=I("offValue",e,t,n);return[tu(a,r,s,i)]}case"Ones":return[ua(I("shape",e,t,n),I("dtype",e,t,n))];case"OnesLike":return[da(I("x",e,t,n))];case"RandomUniform":return[cu(I("shape",e,t,n),I("minval",e,t,n),I("maxval",e,t,n),I("dtype",e,t,n))];case"Range":{let a=I("start",e,t,n),r=I("stop",e,t,n),s=I("step",e,t,n);return[hu(a,r,s,I("dtype",e,t,n))]}case"TruncatedNormal":{let a=I("shape",e,t,n),r=I("mean",e,t,n),s=I("stdDev",e,t,n),i=I("seed",e,t,n);return[s0(a,r,s,I("dtype",e,t,n),i)]}case"Zeros":return[Gt(I("shape",e,t,n),I("dtype",e,t,n))];case"ZerosLike":return[Ye(I("x",e,t,n))];default:throw TypeError(`Node type ${e.op} is not implemented`)}};function l2(e,t,n){let a=I("boxes",e,t,n),r=I("scores",e,t,n),s=I("maxOutputSize",e,t,n),i=I("iouThreshold",e,t,n),o=I("scoreThreshold",e,t,n),l=I("softNmsSigma",e,t,n);return{boxes:a,scores:r,maxOutputSize:s,iouThreshold:i,scoreThreshold:o,softNmsSigma:l}}var SB=async(e,t,n)=>{switch(e.op){case"NonMaxSuppressionV5":{let{boxes:a,scores:r,maxOutputSize:s,iouThreshold:i,scoreThreshold:o,softNmsSigma:l}=l2(e,t,n),d=await Me.nonMaxSuppressionWithScoreAsync(a,r,s,i,o,l);return[d.selectedIndices,d.selectedScores]}case"NonMaxSuppressionV4":{let{boxes:a,scores:r,maxOutputSize:s,iouThreshold:i,scoreThreshold:o}=l2(e,t,n),l=I("padToMaxOutputSize",e,t,n),d=await Me.nonMaxSuppressionPaddedAsync(a,r,s,i,o,l);return[d.selectedIndices,d.validOutputs]}case"NonMaxSuppressionV3":case"NonMaxSuppressionV2":{let{boxes:a,scores:r,maxOutputSize:s,iouThreshold:i,scoreThreshold:o}=l2(e,t,n);return[await Me.nonMaxSuppressionAsync(a,r,s,i,o)]}case"Where":{let a=pe(I("condition",e,t,n),"bool"),r=[await ny(a)];return a.dispose(),r}case"ListDiff":return R3(I("x",e,t,n),I("y",e,t,n));default:throw TypeError(`Node type ${e.op} is not implemented`)}},NB=(e,t,n)=>{switch(e.op){case"TopKV2":{let a=I("x",e,t,n),r=I("k",e,t,n),s=I("sorted",e,t,n),i=ey(a,r,s);return[i.values,i.indices]}case"Unique":{let a=I("x",e,t,n),r=i0(a);return[r.values,r.indices]}case"UniqueV2":{let a=I("x",e,t,n),r=I("axis",e,t,n),s=i0(a,r);return[s.values,s.indices]}default:throw TypeError(`Node type ${e.op} is not implemented`)}},TB=(e,t,n)=>{switch(e.op){case"Const":return t[e.name];case"PlaceholderWithDefault":let a=I("default",e,t,n);return[Dn(e.name,t,n)||a];case"Placeholder":return[Dn(e.name,t,n)];case"Identity":case"StopGradient":case"FakeQuantWithMinMaxVars":{let d=I("x",e,t,n);return[jr(d)]}case"IdentityN":return I("x",e,t,n).map(d=>jr(d));case"Snapshot":let r=I("x",e,t,n);return[jr(r)];case"Shape":return[Ht(I("x",e,t,n).shape,"int32")];case"ShapeN":return I("x",e,t,n).map(d=>Ht(d.shape));case"Size":return[Ce(I("x",e,t,n).size,"int32")];case"Rank":return[Ce(I("x",e,t,n).rank,"int32")];case"NoOp":return[Ce(1)];case"Print":let s=I("x",e,t,n),i=I("data",e,t,n),o=I("message",e,t,n),l=I("summarize",e,t,n);console.warn("The graph has a tf.print() operation,usually used for debugging, which slows down performance."),console.log(o);for(let d=0;d<i.length;d++)console.log(Array.prototype.slice.call(i[d].dataSync()).slice(0,l));return[s];default:throw TypeError(`Node type ${e.op} is not implemented`)}},CB=class{constructor(e,t){this.keyDType=e,this.valueDType=t,this.handle=Ce(0),this.tensorMap=new Map,pn(this.handle)}get id(){return this.handle.id}clearAndClose(){this.tensorMap.forEach(e=>e.dispose()),this.tensorMap.clear(),this.handle.dispose()}size(){return this.tensorMap.size}tensorSize(){return Ce(this.size(),"int32")}async import(e,t){this.checkKeyAndValueTensor(e,t);let n=await e.data();return this.tensorMap.forEach(a=>a.dispose()),this.tensorMap.clear(),G(()=>{let a=Mn(t),r=n.length,s=a.length;w.assert(r===s,()=>`The number of elements doesn't match, keys has ${r} elements, the values has ${s} elements.`);for(let i=0;i<r;i++){let o=n[i],l=a[i];pn(l),this.tensorMap.set(o,l)}return this.handle})}async find(e,t){this.checkKeyAndValueTensor(e,t);let n=await e.data();return G(()=>{let a=[];for(let r=0;r<n.length;r++){let s=n[r],i=this.findWithDefault(s,t);a.push(i)}return xn(a)})}findWithDefault(e,t){let n=this.tensorMap.get(e);return n!=null?n:t}checkKeyAndValueTensor(e,t){if(e.dtype!==this.keyDType)throw new Error(`Expect key dtype ${this.keyDType}, but got ${e.dtype}`);if(t.dtype!==this.valueDType)throw new Error(`Expect value dtype ${this.valueDType}, but got ${t.dtype}`)}},EB=async(e,t,n,a)=>{switch(e.op){case"HashTable":case"HashTableV2":{let r=I("keyDType",e,t,n),s=I("valueDType",e,t,n),i=new CB(r,s);return a.addHashTable(e.name,i),[i.handle]}case"LookupTableImport":case"LookupTableImportV2":{let r=I("tableHandle",e,t,n,a),s=I("keys",e,t,n),i=I("values",e,t,n);return[await a.getHashTableById(r.id).import(s,i)]}case"LookupTableFind":case"LookupTableFindV2":{let r=I("tableHandle",e,t,n,a),s=I("keys",e,t,n),i=I("defaultValue",e,t,n);return[await a.getHashTableById(r.id).find(s,i)]}case"LookupTableSize":case"LookupTableSizeV2":{let r=I("tableHandle",e,t,n,a);return[a.getHashTableById(r.id).tensorSize()]}default:throw TypeError(`Node type ${e.op} is not implemented`)}},RB=(e,t,n)=>{switch(e.op){case"ResizeBilinear":{let a=I("images",e,t,n),r=I("size",e,t,n),s=I("alignCorners",e,t,n),i=I("halfPixelCenters",e,t,n);return[Me.resizeBilinear(a,[r[0],r[1]],s,i)]}case"ResizeNearestNeighbor":{let a=I("images",e,t,n),r=I("size",e,t,n),s=I("alignCorners",e,t,n),i=I("halfPixelCenters",e,t,n);return[Me.resizeNearestNeighbor(a,[r[0],r[1]],s,i)]}case"CropAndResize":{let a=I("image",e,t,n),r=I("boxes",e,t,n),s=I("boxInd",e,t,n),i=I("cropSize",e,t,n),o=I("method",e,t,n),l=I("extrapolationValue",e,t,n);return[Me.cropAndResize(a,r,s,i,o,l)]}default:throw TypeError(`Node type ${e.op} is not implemented`)}},MB=(e,t,n)=>{switch(e.op){case"Equal":return[ia(I("a",e,t,n),I("b",e,t,n))];case"NotEqual":return[oo(I("a",e,t,n),I("b",e,t,n))];case"Greater":return[Yn(I("a",e,t,n),I("b",e,t,n))];case"GreaterEqual":return[xs(I("a",e,t,n),I("b",e,t,n))];case"Less":return[jh(I("a",e,t,n),I("b",e,t,n))];case"LessEqual":return[bs(I("a",e,t,n),I("b",e,t,n))];case"LogicalAnd":return[La(I("a",e,t,n),I("b",e,t,n))];case"LogicalNot":return[Yd(I("a",e,t,n))];case"LogicalOr":return[qh(I("a",e,t,n),I("b",e,t,n))];case"Select":case"SelectV2":return[Sn(I("condition",e,t,n),I("a",e,t,n),I("b",e,t,n))];default:throw TypeError(`Node type ${e.op} is not implemented`)}},FB=(e,t,n)=>{switch(e.op){case"BatchMatMul":case"BatchMatMulV2":case"MatMul":return[Ve(I("a",e,t,n),I("b",e,t,n),I("transposeA",e,t,n),I("transposeB",e,t,n))];case"Einsum":return[g3(I("equation",e,t,n),...I("tensors",e,t,n))];case"Transpose":return[Ze(I("x",e,t,n),I("perm",e,t,n))];case"_FusedMatMul":let[a,r]=I("fusedOps",e,t,n),s=a==="biasadd",i=r==="prelu",o=I("numArgs",e,t,n),l=I("leakyreluAlpha",e,t,n);if(s){if(i&&o!==2)throw new Error("Fused MatMul with BiasAdd and Prelu must have two extra arguments: bias and alpha.");if(!i&&o!==1)throw new Error("Fused MatMul with BiasAdd must have one extra argument: bias.")}let[d,u]=I("args",e,t,n);return[vs.matMul({a:I("a",e,t,n),b:I("b",e,t,n),transposeA:I("transposeA",e,t,n),transposeB:I("transposeB",e,t,n),bias:d,activation:r,preluActivationWeights:u,leakyreluAlpha:l})];default:throw TypeError(`Node type ${e.op} is not implemented`)}},DB=(e,t,n)=>{switch(e.op){case"FusedBatchNorm":case"FusedBatchNormV2":return[ao(I("x",e,t,n),I("mean",e,t,n),I("variance",e,t,n),I("offset",e,t,n),I("scale",e,t,n),I("epsilon",e,t,n))];case"FusedBatchNormV3":return[ao(I("x",e,t,n),I("mean",e,t,n),I("variance",e,t,n),I("offset",e,t,n),I("scale",e,t,n),I("epsilon",e,t,n))];case"LRN":return[Lg(I("x",e,t,n),I("radius",e,t,n),I("bias",e,t,n),I("alpha",e,t,n),I("beta",e,t,n))];case"Softmax":return[lo(I("x",e,t,n))];case"LogSoftmax":return[Hh(I("x",e,t,n))];case"SparseToDense":return[ay(I("sparseIndices",e,t,n),I("outputShape",e,t,n),I("sparseValues",e,t,n),I("defaultValue",e,t,n))];default:throw TypeError(`Node type ${e.op} is not implemented`)}},$B=(e,t,n)=>{switch(e.op){case"Max":{let i=I("axis",e,t,n),o=I("keepDims",e,t,n);return[Rn(I("x",e,t,n),i,o)]}case"Mean":{let i=I("axis",e,t,n),o=I("keepDims",e,t,n);return[Dt(I("x",e,t,n),i,o)]}case"Min":{let i=I("axis",e,t,n),o=I("keepDims",e,t,n);return[Qd(I("x",e,t,n),i,o)]}case"Sum":{let i=I("axis",e,t,n),o=I("keepDims",e,t,n);return[Ie(I("x",e,t,n),i,o)]}case"All":{let i=I("axis",e,t,n),o=I("keepDims",e,t,n);return[Ph(I("x",e,t,n),i,o)]}case"Any":{let i=I("axis",e,t,n),o=I("keepDims",e,t,n);return[jd(I("x",e,t,n),i,o)]}case"ArgMax":{let i=I("axis",e,t,n);return[ka(I("x",e,t,n),i)]}case"ArgMin":{let i=I("axis",e,t,n);return[xg(I("x",e,t,n),i)]}case"Prod":{let i=I("axis",e,t,n),o=I("keepDims",e,t,n);return[Kh(I("x",e,t,n),i,o)]}case"Cumsum":{let i=I("axis",e,t,n),o=I("exclusive",e,t,n),l=I("reverse",e,t,n);return[Vh(I("x",e,t,n),i,o,l)]}case"Bincount":let a=I("x",e,t,n),r=I("weights",e,t,n),s=I("size",e,t,n);return[Cg(a,r,s)];case"DenseBincount":{let i=I("x",e,t,n),o=I("weights",e,t,n),l=I("size",e,t,n),d=I("binaryOutput",e,t,n);return[f3(i,o,l,d)]}default:throw TypeError(`Node type ${e.op} is not implemented`)}},OB=(e,t,n)=>{switch(e.op){case"ConcatV2":case"Concat":{let a=I("n",e,t,n),r=I("axis",e,t,n),s=I("tensors",e,t,n);return s=s.slice(0,a),[mt(s,r)]}case"Gather":{let a=I("x",e,t,n),r=I("indices",e,t,n);return[ro(a,pe(r,"int32"),0)]}case"GatherV2":{let a=I("axis",e,t,n),r=I("batchDims",e,t,n),s=I("x",e,t,n),i=I("indices",e,t,n);return[ro(s,pe(i,"int32"),a,r)]}case"Reverse":{let a=I("dims",e,t,n),r=[];for(let i=0;i<a.length;i++)a[i]&&r.push(i);let s=I("x",e,t,n);return[pa(s,r)]}case"ReverseV2":{let a=I("axis",e,t,n),r=I("x",e,t,n);return[pa(r,a)]}case"Slice":{let a=I("begin",e,t,n),r=I("size",e,t,n);return[De(I("x",e,t,n),a,r)]}case"StridedSlice":{let a=I("begin",e,t,n),r=I("end",e,t,n),s=I("strides",e,t,n),i=I("beginMask",e,t,n),o=I("endMask",e,t,n),l=I("ellipsisMask",e,t,n),d=I("newAxisMask",e,t,n),u=I("shrinkAxisMask",e,t,n),p=I("x",e,t,n);return[Jg(p,a,r,s,i,o,l,d,u)]}case"Pack":return G(()=>{let a=I("axis",e,t,n),r=I("tensors",e,t,n),s=r[0].shape,i=st(r[0]).shape,o=r.map(l=>{let d=w.arraysEqual(l.shape,s);if(!d&&!w.arraysEqual(st(l).shape,i))throw new Error("the input tensors shape does not match");return d?l:V(l,s)});return[xn(o,a)]});case"Unpack":{let a=I("axis",e,t,n),r=I("tensor",e,t,n);return Mn(r,a)}case"Tile":{let a=I("reps",e,t,n);return[Ia(I("x",e,t,n),a)]}case"Split":case"SplitV":{let a=I("axis",e,t,n),r=I("numOrSizeSplits",e,t,n),s=I("x",e,t,n);return cn(s,r,a)}case"ScatterNd":{let a=I("indices",e,t,n),r=I("values",e,t,n),s=I("shape",e,t,n);return[$3(a,r,s)]}case"GatherNd":{let a=I("x",e,t,n),r=I("indices",e,t,n);return[O3(a,r)]}case"SparseToDense":{let a=I("sparseIndices",e,t,n),r=I("outputShape",e,t,n),s=I("sparseValues",e,t,n),i=I("defaultValue",e,t,n);return[ay(a,s,r,s.dtype===i.dtype?i:pe(i,s.dtype))]}default:throw TypeError(`Node type ${e.op} is not implemented`)}},_B=(e,t,n)=>{switch(e.op){case"SparseFillEmptyRows":{let{outputIndices:a,outputValues:r,emptyRowIndicator:s,reverseIndexMap:i}=ip.sparseFillEmptyRows(I("indices",e,t,n),I("values",e,t,n),I("denseShape",e,t,n),I("defaultValue",e,t,n));return[a,r,s,i]}case"SparseReshape":{let{outputIndices:a,outputShape:r}=ip.sparseReshape(I("inputIndices",e,t,n),I("inputShape",e,t,n),I("newShape",e,t,n));return[a,r]}case"SparseSegmentMean":return[ip.sparseSegmentMean(I("data",e,t,n),I("indices",e,t,n),I("segmentIds",e,t,n))];case"SparseSegmentSum":return[ip.sparseSegmentSum(I("data",e,t,n),I("indices",e,t,n),I("segmentIds",e,t,n))];default:throw TypeError(`Node type ${e.op} is not implemented`)}},PB=(e,t,n)=>{switch(e.op){case"FFT":return[rp(I("x",e,t,n))];case"IFFT":return[mu(I("x",e,t,n))];case"RFFT":return[sp(I("x",e,t,n))];case"IRFFT":return[a0(I("x",e,t,n))];default:throw TypeError(`Node type ${e.op} is not implemented`)}},zB=(e,t,n)=>{switch(e.op){case"StringNGrams":{let{nGrams:a,nGramsSplits:r}=c0.stringNGrams(I("data",e,t,n),I("dataSplits",e,t,n),I("separator",e,t,n),I("nGramWidths",e,t,n),I("leftPad",e,t,n),I("rightPad",e,t,n),I("padWidth",e,t,n),I("preserveShortSequences",e,t,n));return[a,r]}case"StringSplit":{let{indices:a,values:r,shape:s}=c0.stringSplit(I("input",e,t,n),I("delimiter",e,t,n),I("skipEmpty",e,t,n));return[a,r,s]}case"StringToHashBucketFast":return[c0.stringToHashBucketFast(I("input",e,t,n),I("numBuckets",e,t,n))];default:throw TypeError(`Node type ${e.op} is not implemented`)}},LB=(e,t,n)=>{switch(e.op){case"Cast":return[pe(I("x",e,t,n),I("dtype",e,t,n))];case"ExpandDims":{let a=I("axis",e,t,n);return[Wt(I("x",e,t,n),a)]}case"Squeeze":{let a=I("axis",e,t,n);return[st(I("x",e,t,n),a)]}case"Reshape":return[V(I("x",e,t,n),I("shape",e,t,n))];case"MirrorPad":return[jg(I("x",e,t,n),I("padding",e,t,n),I("mode",e,t,n))];case"PadV2":case"Pad":return[Sa(I("x",e,t,n),I("padding",e,t,n),I("constantValue",e,t,n))];case"SpaceToBatchND":{let a=I("blockShape",e,t,n),r=I("paddings",e,t,n);return[ep(I("x",e,t,n),a,r)]}case"BatchToSpaceND":{let a=I("blockShape",e,t,n),r=I("crops",e,t,n);return[qd(I("x",e,t,n),a,r)]}case"DepthToSpace":{let a=I("blockSize",e,t,n),r=I("dataFormat",e,t,n).toUpperCase();return[Fg(I("x",e,t,n),a,r)]}case"BroadcastTo":return[su(I("x",e,t,n),I("shape",e,t,n))];case"BroadcastArgs":return[l3(I("s0",e,t,n),I("s1",e,t,n))];default:throw TypeError(`Node type ${e.op} is not implemented`)}};function bw(e,t,n,a){let r=((s,i,o)=>{switch(s.category){case"arithmetic":return G(()=>mB(s,i,o));case"basic_math":return G(()=>gB(s,i,o));case"control":return wB(s,i,o);case"convolution":return G(()=>kB(s,i,o));case"creation":return G(()=>IB(s,i,o));case"dynamic":return SB(s,i,o);case"evaluation":return G(()=>NB(s,i,o));case"image":return G(()=>RB(s,i,o));case"graph":return G(()=>TB(s,i,o));case"logical":return G(()=>MB(s,i,o));case"matrices":return G(()=>FB(s,i,o));case"normalization":return G(()=>DB(s,i,o));case"reduction":return G(()=>$B(s,i,o));case"slice_join":return G(()=>OB(s,i,o));case"sparse":return G(()=>_B(s,i,o));case"spectral":return G(()=>PB(s,i,o));case"string":return G(()=>zB(s,i,o));case"transformation":return G(()=>LB(s,i,o));case"hash_table":return EB(s,i,o,a);case"custom":let l=X7(s.op);if(l&&l.customExecutor)return l.customExecutor(new fB(s,i,o));throw TypeError(`Custom op ${s.op} is not registered.`);default:throw TypeError(`Unknown op '${s.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(s=>[].concat(s)):[].concat(r)}var vw=class{constructor(e={},t={},n={},a={}){this.weightMap=e,this.tensorArrayMap=t,this.tensorListMap=n,this.functionMap=a,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 ww(e,t,n,a){let r=new Set,s=[],i=null,o=null,l=new Set,d=Object.keys(e).map(c=>ca(c)[0]),u=[];a!=null&&(u=a.map(c=>ca(c.name)[0]));let p=[...t];for(;p.length>0;){let c=p.pop();if((kw(c)||jB(c)||GB(c))&&i==null&&(i=c,o=i.children.map(h=>h.name).filter(h=>r.has(h))),r.add(c.name),n[c.name]==null&&d.indexOf(c.name)===-1&&u.indexOf(c.name)===-1){if(c.inputs.length===0){s.push(c.name);continue}c.inputs.forEach(h=>{l.has(h.name)||(l.add(h.name),p.push(h))})}}return{inputs:e,outputs:t,usedNodes:r,missingInputs:s,dynamicNode:i,syncInputs:o}}function WB(e,t,n){let{usedNodes:a,inputs:r}=n,s=[],i=Object.keys(r).map(u=>ca(u)[0]).map(u=>e.nodes[u]),o=e.initNodes;i.forEach(u=>{a.has(u.name)&&s.push(u)}),e.weights.forEach(u=>{a.has(u.name)&&s.push(u)}),o!=null&&o.forEach(u=>{a.has(u.name)&&s.push(u)});let l=new Set,d=[];for(;s.length>0;){let u=s.pop();l.add(u.name),t[u.name]||d.push(u),u.children.forEach(p=>{!l.has(p.name)&&a.has(p.name)&&p.inputs.every(c=>l.has(c.name))&&s.push(p)})}return d}var BB=["Switch","Merge","Enter","Exit","NextIteration","StatelessIf","StatelessWhile","if","While"],VB=["NonMaxSuppressionV2","NonMaxSuppressionV3","NonMaxSuppressionV5","Where"],UB=["HashTable","HashTableV2","LookupTableImport","LookupTableImportV2","LookupTableFind","LookupTableFindV2","LookupTableSize","LookupTableSizeV2"];function kw(e){return BB.indexOf(e.op)>=0}function jB(e){return VB.indexOf(e.op)>=0}function GB(e){return UB.indexOf(e.op)>=0}var u2=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 u2(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(a=>a.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(),a=t.map(r=>r.name).sort();return n.join(this.SEPERATOR)+"--"+a.join(this.SEPERATOR)}compile(e,t){let n=ww(e,t,this.weightMap,this._initNodes),{missingInputs:a,dynamicNode:r,syncInputs:s}=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 [${s}]`);if(a.length>0){let i=t.map(l=>l.name),o=Object.keys(e);throw new Error(`Cannot compute the outputs [${i}] from the provided inputs [${o}]. Missing the following inputs: [${a}]`)}return WB(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 a=n.map(u=>this.graph.nodes[ca(u)[0]]),r=t.map(u=>ca(u)[0]),s=r.map(u=>this.graph.nodes[u]);s.length===0&&(s=this._outputs);let i=this.getCompilationKey(a,s),o=this.compiledMap.get(i);o==null&&(o=this.compile(e,s),this.compiledMap.set(i,o));let l={},d={};return G(()=>{let u=new vw(this.weightMap,l,d,this.functionExecutorMap),p=Object.assign({},this.weightMap);Object.keys(e).forEach(f=>{let[m,g]=ca(f),y=[];y[g]=e[f],p[m]=y});let c=this.getFrozenTensorIds(p),h={};for(let f=0;f<o.length;f++){let m=o[f];if(!p[m.name]){let g=bw(m,p,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.`);p[m.name]=g,this.checkTensorForDisposal(m.name,m,p,u,c,r,h)}}return this.parent==null&&u.dispose(c),t.map(f=>Dn(f,p,u))})}getFrozenTensorIds(e){let t=[].concat.apply([],Object.keys(e).map(n=>e[n]).map(n=>n.map(a=>a.id)));return new Set(t)}checkTensorForDisposal(e,t,n,a,r,s,i){t.category==="control"||s.indexOf(e)!==-1||(n[e].forEach(o=>{o!=null&&(i[o.id]=(i[o.id]||0)+t.children.length)}),t.inputs.forEach(o=>{if(o.category!=="control"){let l=qW(o.name,n,a);l!=null&&l.forEach(d=>{if(d&&!d.kept&&!r.has(d.id)){let u=i[d.id];u===1?(d.dispose(),delete i[d.id]):u!=null&&i[d.id]--}})}}))}async executeAsync(e,t){return this._executeAsync(e,t)}async _executeAsync(e,t,n=!1,a={},r={}){n||(e=this.mapInputs(e),this.checkInputs(e),this.checkInputShapeAndType(e),t=this.mapOutputs(t),this.checkOutputs(t));let s=new vw(this.weightMap,a,r,this.functionExecutorMap),i=await this.executeWithControlFlow(e,s,t,n),o=t.map(p=>Dn(p,i,s)),l=o.map(p=>p.id),d=Object.keys(e).map(p=>e[p].id),u=new Set([...l,...d,...this.weightIds]);return Object.keys(i).forEach(p=>{i[p].forEach(c=>{c&&!c.kept&&!c.isDisposed&&!u.has(c.id)&&c.dispose()})}),this.parent==null&&s.dispose(u),o}async executeFunctionAsync(e,t,n){let a=e.reduce((r,s,i)=>(r[this.inputs[i].name]=s,r),{});return this._executeAsync(a,this.outputNodes,!0,t,n)}async executeWithControlFlow(e,t,n,a){let r=Object.keys(e),s=r.map(A=>this.graph.nodes[ca(A)[0]]),i=n.map(A=>ca(A)[0]),o=i.map(A=>this.graph.nodes[A]);o.length===0&&(o=this._outputs);let{usedNodes:l,missingInputs:d,dynamicNode:u,syncInputs:p}=ww(e,o,this.weightMap,this._initNodes),c=[...s,...this.graph.weights,...this._initNodes||[]].map(A=>({node:A,contexts:t.currentContext})),h=Object.assign({},this.weightMap);Object.keys(e).forEach(A=>{let[x,b]=ca(A),v=[];v[b]=e[A],h[x]=v});let f={},m=this.getFrozenTensorIds(h),g={};for(;c.length>0;){let A=this.processStack(s,c,t,h,g,m,i,f,l);await Promise.all(A)}u==null&&!a&&console.warn("This model execution did not contain any nodes with control flow or dynamic output shapes. You can use model.execute() instead.");let y=o.filter(A=>!kw(A)&&!Dn(A.name,h,t)).map(A=>A.name);if(y.length>0){let A="";throw u!=null&&(A=`Alternatively, to avoid the dynamic ops, use model.execute() and specify the inputs [${p}]`),new Error(`Cannot compute the outputs [${y}] from the provided inputs [${r}]. Consider providing the following inputs: [${d}]. ${A}`)}return h}processStack(e,t,n,a,r,s,i,o,l){let d=[];for(;t.length>0;){let u=t.pop();n.currentContext=u.contexts;let p="";if(u.node.op==="Enter"&&I("isConstant",u.node,a,n)&&([p]=Ur(u.node.name,n)),a[u.node.name]==null){let c=bw(u.node,a,n,this._resourceManager);p||([p]=Ur(u.node.name,n));let h=n.currentContext;w.isPromise(c)?d.push(c.then(f=>(a[p]=f,n.currentContext=h,this.checkTensorForDisposal(p,u.node,a,n,s,i,o),this.processChildNodes(u.node,t,n,a,r,l),f))):(a[p]=c,this.checkTensorForDisposal(p,u.node,a,n,s,i,o),this.processChildNodes(u.node,t,n,a,r,l))}else this.processChildNodes(u.node,t,n,a,r,l)}return d}processChildNodes(e,t,n,a,r,s){e.children.forEach(i=>{let[o]=Ur(i.name,n);r[o]||!s.has(i.name)||(i.op==="Merge"?i.inputNames.some(l=>!!Dn(l,a,n))&&(r[o]=!0,t.push({contexts:n.currentContext,node:i})):i.inputNames.every(l=>!!Dn(l,a,n))&&(r[o]=!0,t.push({contexts:n.currentContext,node:i})))})}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],[a]=ca(t),r=this.graph.nodes[a];if(r.attrParams.shape&&r.attrParams.shape.value){let s=r.attrParams.shape.value,i=s.length===n.shape.length&&n.shape.every((o,l)=>s[l]===-1||s[l]===o);w.assert(i,()=>`The shape of dict['${r.name}'] provided in model.execute(dict) must be [${s}], 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 a=this._signature.inputs[n];t[a.name]=e[n]}else t[n]=e[n];return t}checkInputs(e){let t=Object.keys(e).filter(n=>{let[a]=ca(n);return this.graph.nodes[a]==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]=ca(t);if(!this.graph.nodes[n])throw new Error(`The output '${t}' is not found in the graph`)})}},HB=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]}},qB="?tfjs-format=file",XB="model.json",Iw=class{constructor(e,t={}){this.modelUrl=e,this.loadOptions=t,this.version="n/a",t==null&&(this.loadOptions={}),this.resourceManager=new HB}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=Xn.browserHTTPRequest(e,this.loadOptions);else{let t=Xn.getLoadHandlers(e,this.loadOptions);if(t.length===0)t.push(Xn.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 a=Xn.decodeWeights(this.artifacts.weightData,this.artifacts.weightSpecs);if(this.executor=new u2(fw.Instance.transformGraph(t,this.signature)),this.executor.weightMap=this.convertTensorMapToTensorsMap(a),this.executor.resourceManager=this.resourceManager,e.modelInitializer!=null&&e.modelInitializer.node!=null){let r=fw.Instance.transformGraph(e.modelInitializer);this.initializer=new u2(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=Xn.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 je)&&!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,a)=>(t[n]=e[a],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 et(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}${XB}${qB}`);let n=new Iw(e,t);return await n.load(),n}var KB="3.10.0",Sw={};ze(Sw,{CSVDataset:()=>Pw,Dataset:()=>Nu,FileDataSource:()=>jw,TextLineDataset:()=>$w,URLDataSource:()=>Gw,array:()=>AV,csv:()=>EV,func:()=>RV,generator:()=>MV,microphone:()=>DV,version_data:()=>$V,webcam:()=>FV,zip:()=>xV});var ZB=qs(L5()),YB=qs(L5());function JB(e,t){return Q0(e,t)}function Q0(e,t,n=new Map,a=new Set){if(e==null)return null;if(typeof Blob=="function"&&e instanceof Blob)return e.slice();if(a.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(Su(e)){let s=Array.isArray(e)?[]:{};a.add(e);for(let i in e){let o=e[i],l=Q0(o,t,n,a);s[i]=l}return a.delete(e),e.__proto__&&(s.__proto__=e.__proto__),s}else throw new Error(`Can't recurse into non-iterable type: ${e}`);else return n.set(e,r.value),r.value}function QB(e,t=Tw){return Nw(e,t)}function Nw(e,t,n=new Set){let a=e[0];if(n.has(a))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(Su(a)){let s=Array.isArray(a)?[]:{};n.add(a);for(let i in a){let o=e.map(d=>d[i]),l=Nw(o,t,n);s[i]=l}return n.delete(a),s}else throw new Error(`Can't recurse into non-iterable type: ${a}`);else return r.value}function Tw(e){return e===null?null:Su(e[0])?{value:null,recurse:!0}:{value:e,recurse:!1}}async function Cw(e,t){let n=new Map;Q0(e,t,n);for(let a of Array.from(n.keys())){let r=n.get(a);if(w.isPromise(r)){let s=await r;n.set(a,s)}}return Q0(e,t,n)}function Su(e){let t=!1;if(ne().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 je)&&!(e instanceof Promise)&&!t)}function eV(e){return e==null||tV(e)||Array.isArray(e)||typeof e=="object"&&e instanceof je||w.isTypedArray(e)}function tV(e){return e===null||typeof e!="object"&&typeof e!="function"}function nV(e){return JB(e,aV)}function aV(e){return e instanceof je?{value:e.clone(),recurse:!1}:Su(e)?{value:null,recurse:!0}:{value:e,recurse:!1}}var Ew=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}},d2=class extends Ew{constructor(){super(d2.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 a=0;a<n;a++)t[a]=this.get(this.wrap(this.begin+a));this.data=t,this.capacity=e,this.doubledCapacity=2*this.capacity,this.begin=0,this.end=n}};d2.INITIAL_CAPACITY=32;function Rw(e){return new iV(e)}function p2(e){return new oV(e)}function rV(e,t){return new Fw(e,t)}function sV(e,t=Es.FAIL){return new gV(e,t)}var fn=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 fV(this,e)}filter(e){return new cV(this,e)}map(e){return new hV(this,e)}mapAsync(e){return new Mw(this,e)}serialMapAsync(e){return new Mw(this,e).serial()}flatmap(e){return new mV(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 pV(this,e,t)}columnMajorBatch(e,t=!0,n=Tw){return this.rowMajorBatch(e,t).map(a=>QB(a,n))}concatenate(e,t){return new Fw(Rw([this,e]),t)}take(e){return e<0||e==null?this:new dV(this,e)}skip(e){return e<0||e==null?this:new uV(this,e)}prefetch(e){return new Dw(this,e)}shuffle(e,t){return new yV(this,e,t)}serial(){return new lV(this)}},iV=class extends fn{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:nV(e),done:!1}}},oV=class extends fn{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}}},lV=class extends fn{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()}},uV=class extends fn{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;Q(e.value)}return this.upstream.next()}},dV=class extends fn{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()}},pV=class extends fn{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}}},cV=class extends fn{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;Q(e.value)}}},hV=class extends fn{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=Xa.getTensorsInContainer(e.value),n=this.transform(e.value),a=Xa.getTensorsInContainer(n);for(let r of t)Xa.isTensorInList(r,a)||r.dispose();return{value:n,done:!1}}},fV=class extends fn{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}}}},Mw=class extends fn{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=Xa.getTensorsInContainer(e.value),n=await this.transform(e.value),a=Xa.getTensorsInContainer(n);for(let r of t)Xa.isTensorInList(r,a)||r.dispose();return{value:n,done:!1}}},c2=class extends fn{constructor(){super();this.outputQueue=new d2,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}}},mV=class extends c2{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=Xa.getTensorsInContainer(e.value),n=this.transform(e.value),a=Xa.getTensorsInContainer(n);this.outputQueue.pushAll(n);for(let r of t)Xa.isTensorInList(r,a)||r.dispose();return!0}},Fw=class extends fn{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}},Es;(function(e){e[e.FAIL=0]="FAIL",e[e.SHORTEST=1]="SHORTEST",e[e.LONGEST=2]="LONGEST"})(Es||(Es={}));var gV=class extends fn{constructor(e,t=Es.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 a(s){return s instanceof fn?{value:s.next().then(i=>(t++,i.done&&n++,i.value)),recurse:!1}:{value:null,recurse:!0}}let r=await Cw(this.iterators,a);if(t===n)return{value:null,done:!0};if(n>0)switch(this.mismatchMode){case Es.FAIL:throw new Error(`Zipped streams should have the same length. Mismatched at element ${this.count}.`);case Es.SHORTEST:return{value:null,done:!0};case Es.LONGEST:default:}return this.count++,{value:r,done:!1}}async next(){return this.currentPromise=this.nextState(this.currentPromise),this.currentPromise}},Dw=class extends fn{constructor(e,t){super();this.upstream=e,this.bufferSize=t,this.buffer=new Ew(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()}},yV=class extends Dw{constructor(e,t,n){super(e,t);this.upstream=e,this.windowSize=t,this.upstreamExhausted=!1,this.random=YB.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}}},Nu=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 a;return this.size===1/0||this.size==null?a=this.size:t?a=Math.ceil(this.size/e):a=Math.floor(this.size/e),ha(async()=>(await n.iterator()).columnMajorBatch(e,t,bV),a)}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,ha(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,ha(async()=>(await t.iterator()).filter(a=>G(()=>e(a))),n)}async forEachAsync(e){return(await this.iterator()).forEachAsync(e)}map(e){let t=this;return ha(async()=>(await t.iterator()).map(n=>G(()=>e(n))),this.size)}mapAsync(e){let t=this;return ha(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 ha(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,ha(async()=>{let a=p2(async()=>({value:await t.iterator(),done:!1}));return rV(a.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,ha(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 a=this,r=ZB.alea(t||w.now().toString());return ha(async()=>{let s=r.int32();return n&&(s+=r.int32()),(await a.iterator()).shuffle(e,s.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,ha(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()}};Nu.MAX_BUFFER_SIZE=1e4;function ha(e,t=null){return new class extends Nu{constructor(){super(...arguments);this.size=t}async iterator(){return e()}}}function AV(e){return ha(async()=>Rw(e),e.length)}function xV(e){if(!Su(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 ha(async()=>{let n=await Cw(e,a=>{if(a instanceof Nu)return{value:a.iterator(),recurse:!1};if(Su(a))return{value:null,recurse:!0};throw new Error("Leaves of the structure passed to zip() must be Datasets, not primitives.")});return sV(n,Es.SHORTEST)},t)}function bV(e){if(e===null)return null;let t=e[0];return eV(t)?{value:vV(e),recurse:!1}:{value:null,recurse:!0}}function vV(e){if(e.length===0)throw new Error("Can't make a batch of zero elements.");return e[0]instanceof je?xn(e):Lt(e)}var $w=class extends Nu{constructor(e){super();this.input=e}async iterator(){return(await this.input.iterator()).decodeUTF8().split(`
|
|
`).map(e=>(e.endsWith("\r")&&(e=e.slice(0,-1)),e))}},ef='"',Cp=Symbol("out"),Ow=Symbol("field"),tf=Symbol("quote"),h2=Symbol("quoteafterquote"),_w=Symbol("quoteinquote"),Pw=class extends Nu{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 $w(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((a,r)=>(a[r]=a[r]+1||1,a),{}),n=Object.keys(t).filter(a=>t[a]>1);if(w.assert(n.length===0,()=>"Duplicate column names found: "+n.toString()),this.columnConfigs){for(let a of Object.keys(this.columnConfigs))if(this.fullColumnNames.indexOf(a)===-1)throw new Error('The key "'+a+'" provided in columnConfigs does not match any of the column names ('+this.fullColumnNames.toString()+").")}this.columnNamesValidated=!0}async maybeReadHeaderLine(){if(this.hasHeader){let e=await(await this.base.iterator()).next();if(e.done)throw new Error("No data was found for CSV parsing.");let t=e.value;return this.parseRow(t,!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={},a={};for(let r=0;r<this.fullColumnNames.length;r++){let s=this.fullColumnNames[r],i=this.columnConfigs?this.columnConfigs[s]:null;if(!(this.configuredColumnsOnly&&!i)){let o=t[r],l=null;if(o==="")if(i&&i.default!==void 0)l=i.default;else{if(i&&(i.required||i.isLabel))throw new Error(`Required column ${s} is empty in this line: ${e}`);l=void 0}else{let d=Number(o);if(isNaN(d))i&&i.dtype==="bool"?l=this.getBoolean(o):l=o;else if(!i||!i.dtype)l=d;else switch(i.dtype){case"float32":l=d;break;case"int32":l=Math.floor(d);break;case"bool":l=this.getBoolean(o);break;default:l=d}}i&&i.isLabel?a[s]=l:n[s]=l}}return Object.keys(a).length===0?n:{xs:n,ys:a}}getBoolean(e){return e==="1"||e.toLowerCase()==="true"?1:0}parseRow(e,t=!0){let n=[],a=0,r=e.length,s=Cp;for(let i=0;i<r;i++)switch(s){case Cp:switch(e.charAt(i)){case ef:a=i+1,s=tf;break;case this.delimiter:if(a=i+1,this.delimiter===" "&&this.delimWhitespace)break;n.push(""),s=Cp;break;default:s=Ow,a=i;break}break;case Ow:switch(e.charAt(i)){case this.delimiter:n.push(e.substring(a,i)),s=Cp,a=i+1;break;default:}break;case tf:switch(e.charAt(i)){case ef:s=h2;break;default:}break;case h2:switch(e.charAt(i)){case this.delimiter:n.push(e.substring(a,i-1)),s=Cp,a=i+1;break;case ef:s=tf;break;default:s=_w;break}break;case _w:switch(e.charAt(i)){case ef:s=tf;break;default:}break;default:}if(s===h2?n.push(e.substring(a,r-1)):n.push(e.substring(a)),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}},zw=class extends fn{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(ne().get("IS_NODE"))throw new Error("microphone API is only supported in browser environment.");let t=new zw(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 a=this.flattenQueue(n.freqDataQueue);e=this.getTensorFromAudioDataArray(a,[this.numFrames,this.columnTruncateLength,1])}if(this.includeWaveform){let a=this.flattenQueue(n.timeDataQueue);t=this.getTensorFromAudioDataArray(a,[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(a=>{let r=setInterval(()=>{this.includeSpectrogram&&(this.analyser.getFloatFrequencyData(this.freqData),this.freqData[0]===-1/0&&a({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),a({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((a,r)=>n.set(a,r*t)),n}getTensorFromAudioDataArray(e,t){let n=new Float32Array(w.sizeFromShape(t));return n.set(e,n.length-e.length),Lt(n,t)}},Lw=class extends fn{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=Ht([0],"int32"),this.webcamConfig.centerCrop){let n=this.webcamConfig.resizeWidth*1/this.webcamVideoElement.width,a=this.webcamConfig.resizeHeight*1/this.webcamVideoElement.height,r=(1-n)/2,s=(1-a)/2,i=r+n,o=a+s;this.cropBox=Qa([s,r,o,i],[1,4])}else this.cropBox=Qa([0,0,1,1],[1,4])}summary(){return"webcam"}static async create(e,t={}){if(ne().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 Lw(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=za.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=Wt(pe(e,"float32"),0),n;n=Me.cropAndResize(t,this.cropBox,this.cropBoxInd,this.cropSize,"bilinear");let a=n.shape;return V(n,a.slice(1))})}async capture(){return(await this.next()).value}stop(){this.stream.getTracks().forEach(e=>e.stop());try{this.webcamVideoElement.srcObject=null}catch(e){console.log(e),this.webcamVideoElement.src=null}this.isClosed=!0}toArray(){throw new Error("Can not convert infinite video stream to array.")}},Ww=class{},Bw=class extends fn{split(e){return new wV(this,e)}},wV=class extends Bw{constructor(e,t){super();this.upstream=e,this.impl=new kV(e,t)}summary(){return this.impl.summary()}async next(){return this.impl.next()}},kV=class extends c2{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}},IV=class extends fn{decodeUTF8(){return new SV(this)}},SV=class extends Bw{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 c2{constructor(e){super();if(this.upstream=e,ne().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 ne().get("IS_BROWSER")?n=this.decoder.decode(t,{stream:!0}):n=this.decoder.write(Buffer.from(t.buffer)),this.outputQueue.push(n),!0}},Vw=class extends IV{constructor(e,t={}){super();this.file=e,this.options=t,w.assert(e instanceof Uint8Array||(ne().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((e,t)=>{let n=this.offset+this.chunkSize;if(this.file instanceof Uint8Array)e(new Uint8Array(this.file.slice(this.offset,n)));else{let a=new FileReader;a.onload=s=>{let i=a.result;if(i instanceof ArrayBuffer&&(i=new Uint8Array(i)),!(i instanceof Uint8Array))return t(new TypeError("FileReader returned unknown type."));e(i)},a.onabort=s=>t(new Error("Aborted")),a.onerror=s=>t(new Error(s.type));let r=this.file.slice(this.offset,n);a.readAsArrayBuffer(r)}this.offset=n}),done:!1}}};async function TV(e,t={},n){let a,r;typeof e=="string"?a=e:(a=e.url,r=CV(e));let s=await(n||w.fetch)(a,r);if(s.ok){let i=new Uint8Array(await s.arrayBuffer());return new Vw(i,t)}else throw new Error(s.statusText)}var CV=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 Uw(e){return typeof e=="string"&&e.substr(0,7)==="file://"}var jw=class extends Ww{constructor(e,t={}){super();this.input=e,this.options=t}async iterator(){if(Uw(this.input)&&ne().get("IS_NODE")){let e=Ho("fs");this.input=e.readFileSync(this.input.substr(7))}return new Vw(this.input,this.options)}},Gw=class extends Ww{constructor(e,t={}){super();this.url=e,this.fileOptions=t}async iterator(){return Uw(this.url)?new jw(this.url,this.fileOptions).iterator():TV(this.url,this.fileOptions)}};function EV(e,t={}){return new Pw(new Gw(e),t)}function RV(e){let t=p2(e);return ha(async()=>t)}function MV(e){return ha(async()=>{let t=await e();return p2(()=>t.next())})}async function FV(e,t){return Lw.create(e,t)}async function DV(e){return zw.create(e)}var $V="3.10.0";function Te(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 OV=xr.whereImpl,f2=class extends fd{constructor(){super();this.blockSize=48,this.firstUse=!0,this.data=new Oc(this,sa())}nextDataId(){return f2.nextDataId++}write(e,t,n){this.firstUse&&(this.firstUse=!1,ne().get("IS_NODE")&&E.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 a={id:this.nextDataId()};return this.data.set(a,{values:e,dtype:n,refCount:1}),a}makeTensorInfo(e,t,n){let a;if(t==="string"&&n!=null&&n.length>0&&w.isString(n[0])){let r=n.map(s=>w.encodeString(s));a=this.write(r,e,t)}else a=this.write(n,e,t);return{dataId:a,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,a,r){this.data.set(e,{values:t,dtype:a,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 a=this.readSync(n.real.dataId),r=this.readSync(n.imag.dataId);return E.mergeRealAndImagArrays(a,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(a=>w.decodeString(a))}catch(a){throw new Error("Failed to decode encoded string bytes into utf-8")}return Ge(e.shape,e.dtype,n)}makeOutput(e,t,n){let a=this.write(e,t,n);return sa().makeTensorFromDataId(a,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){Te([e],"where");let t=this.readSync(e.dataId);return OV(e.shape,t)}dispose(){}floatPrecision(){return 32}epsilon(){return super.epsilon()}};f2.nextDataId=0;var Hw={};ze(Hw,{addImpl:()=>Xw,bincountImpl:()=>g2,bincountReduceImpl:()=>Kw,ceilImpl:()=>Zw,concatImpl:()=>y2,equalImpl:()=>Yw,expImpl:()=>Qw,expm1Impl:()=>t6,floorImpl:()=>n6,gatherNdImpl:()=>a6,gatherV2Impl:()=>r6,greaterEqualImpl:()=>i6,greaterImpl:()=>s6,lessEqualImpl:()=>l6,lessImpl:()=>o6,linSpaceImpl:()=>u6,logImpl:()=>d6,maxImpl:()=>p6,maximumImpl:()=>c6,minimumImpl:()=>h6,multiplyImpl:()=>A2,negImpl:()=>f6,notEqualImpl:()=>m6,prodImpl:()=>g6,rangeImpl:()=>b2,rsqrtImpl:()=>y6,sigmoidImpl:()=>kU,simpleAbsImpl:()=>qw,sliceImpl:()=>rf,sparseFillEmptyRowsImpl:()=>x6,sparseReshapeImpl:()=>b6,sparseSegmentReductionImpl:()=>v2,sqrtImpl:()=>NU,squaredDifferenceImpl:()=>v6,stridedSliceImpl:()=>w6,stringNGramsImpl:()=>k6,stringSplitImpl:()=>I6,stringToHashBucketFastImpl:()=>S6,subImpl:()=>N6,tileImpl:()=>T6,topKImpl:()=>E6,transposeImpl:()=>x2,uniqueImpl:()=>R6});function qw(e){let t=new Float32Array(e.length);for(let n=0;n<e.length;++n)t[n]=Math.abs(e[n]);return t}var _V=e=>{let{x:t}=e.inputs,n=e.backend;Te(t,"abs");let a=new Float32Array(w.sizeFromShape(t.shape)),r=n.data.get(t.dataId).values;return a=qw(r),n.makeOutput(a,t.shape,t.dtype)},PV={kernelName:Ko,backendName:"cpu",kernelFunc:_V};function Xt(e){return(t,n,a,r,s)=>{let i=E.assertAndGetBroadcastShape(t,n),o=i.length,l=w.computeStrides(i),d=w.sizeFromShape(i),u=w.getTypedArrayFromDType(s,d),p=t.length,c=n.length,h=w.computeStrides(t),f=w.computeStrides(n),m=E.getBroadcastDims(t,i),g=E.getBroadcastDims(n,i);if(m.length+g.length===0)for(let y=0;y<u.length;++y)u[y]=e(a[y%a.length],r[y%r.length]);else for(let y=0;y<u.length;++y){let A=w.indexToLoc(y,o,l),x=A.slice(-p);m.forEach(T=>x[T]=0);let b=w.locToIndex(x,p,h),v=A.slice(-c);g.forEach(T=>v[T]=0);let k=w.locToIndex(v,c,f);u[y]=e(a[b],r[k])}return[u,i]}}function fa(e){let{inputs:t,backend:n}=e,{real:a,imag:r}=t,s=n.data.get(a.dataId).values,i=n.data.get(r.dataId).values,o=n.makeTensorInfo(a.shape,"complex64"),l=n.data.get(o.dataId);return l.complexTensorInfos={real:n.makeTensorInfo(a.shape,"float32",s),imag:n.makeTensorInfo(r.shape,"float32",i)},o}var zV={kernelName:jc,backendName:"cpu",kernelFunc:fa};function nf(e,t,n="float32"){if(n==="complex64"){let r=nf(e,t,"float32"),s=nf(e,t,"float32");return fa({inputs:{real:r,imag:s},backend:e})}let a=w.makeZerosTypedArray(w.sizeFromShape(t),n);return e.makeTensorInfo(t,n,a)}function Sr(e){let{inputs:t,backend:n}=e,{x:a}=t;return n.incRef(a.dataId),{dataId:a.dataId,shape:a.shape,dtype:a.dtype}}var LV={kernelName:mi,backendName:"cpu",kernelFunc:Sr};function vo(e){let{inputs:t,backend:n}=e,{input:a}=t,r=n.data.get(a.dataId).complexTensorInfos.real,s=n.data.get(r.dataId).values;return n.makeTensorInfo(r.shape,r.dtype,s)}var WV={kernelName:ph,backendName:"cpu",kernelFunc:vo};function Rs(e){let{inputs:t,backend:n,attrs:a}=e,{x:r}=t,{dtype:s}=a;if(s==="complex64"){if(r.dtype==="complex64")return Sr({inputs:{x:r},backend:n});let i=nf(n,r.shape,r.dtype),o=Rs({inputs:{x:r},backend:n,attrs:{dtype:"float32"}}),l=fa({inputs:{real:o,imag:i},backend:n});return n.disposeIntermediateTensorInfo(i),n.disposeIntermediateTensorInfo(o),l}if(r.dtype==="complex64"){let i=vo({inputs:{input:r},backend:n}),o=Rs({inputs:{x:i},backend:n,attrs:{dtype:s}});return n.disposeIntermediateTensorInfo(i),o}if(!w.hasEncodingLoss(r.dtype,s)){let i=Sr({inputs:{x:r},backend:n});return{dataId:i.dataId,shape:i.shape,dtype:s}}if(s==="int32"){let i=n.data.get(r.dataId).values,o=Int32Array.from(i);return n.makeTensorInfo(r.shape,"int32",o)}if(s==="bool"){let i=n.data.get(r.dataId).values,o=w.toTypedArray([0],r.dtype),[l,d]=Xt((u,p)=>u!==p?1:0)(r.shape,[],i,o,"bool");return n.makeTensorInfo(d,"bool",l)}throw new Error(`Error in Cast: failed to cast ${r.dtype} to ${s}`)}var BV={kernelName:ei,backendName:"cpu",kernelFunc:Rs};function mn(e,t,n,a){return n==null?({inputs:r,backend:s})=>{let{a:i,b:o}=r,l=s;Te([i,o],e);let d=l.data.get(i.dataId).values,u=l.data.get(o.dataId).values,p=i.dtype==="string"?E.fromUint8ToStringArray(d):d,c=i.dtype==="string"?E.fromUint8ToStringArray(u):u,h=a||i.dtype,[f,m]=t(i.shape,o.shape,p,c,h);return l.makeTensorInfo(m,h,f)}:({inputs:r,backend:s})=>{let{a:i,b:o}=r,l=s;if(i.dtype==="complex64"||o.dtype==="complex64"){let d=Rs({inputs:{x:i},backend:l,attrs:{dtype:"complex64"}}),u=l.data.get(d.dataId),p=u.complexTensorInfos.real,c=u.complexTensorInfos.imag,h=l.data.get(p.dataId).values,f=l.data.get(c.dataId).values,m=Rs({inputs:{x:o},backend:l,attrs:{dtype:"complex64"}}),g=l.data.get(m.dataId),y=g.complexTensorInfos.real,A=g.complexTensorInfos.imag,x=l.data.get(y.dataId).values,b=l.data.get(A.dataId).values,[v,k,T]=n(i.shape,o.shape,h,f,x,b),C=l.makeTensorInfo(T,"float32",v),D=l.makeTensorInfo(T,"float32",k),O=fa({inputs:{real:C,imag:D},backend:l});return l.disposeIntermediateTensorInfo(d),l.disposeIntermediateTensorInfo(m),l.disposeIntermediateTensorInfo(C),l.disposeIntermediateTensorInfo(D),O}else{let d=l.data.get(i.dataId).values,u=l.data.get(o.dataId).values,p=a||i.dtype,[c,h]=t(i.shape,o.shape,d,u,p);return l.makeTensorInfo(h,p,c)}}}function m2(e){return(t,n,a,r,s,i)=>{let o=E.assertAndGetBroadcastShape(t,n),l=w.sizeFromShape(o),d=o.length,u=w.computeStrides(o),p=w.getTypedArrayFromDType("float32",l),c=w.getTypedArrayFromDType("float32",l),h=E.getBroadcastDims(t,o),f=E.getBroadcastDims(n,o),m=E.mergeRealAndImagArrays(a,r),g=E.mergeRealAndImagArrays(s,i),y=t.length,A=w.computeStrides(t),x=n.length,b=w.computeStrides(n);if(h.length+f.length===0)for(let v=0;v<p.length;v++){let k=v%m.length,T=v%g.length,C=e(m[k*2],m[k*2+1],g[T*2],g[T*2+1]);p[v]=C.real,c[v]=C.imag}else for(let v=0;v<p.length;v++){let k=w.indexToLoc(v,d,u),T=k.slice(-y);h.forEach(S=>T[S]=0);let C=w.locToIndex(T,y,A),D=k.slice(-x);f.forEach(S=>D[S]=0);let O=w.locToIndex(D,x,b),F=e(m[C*2],m[C*2+1],g[O*2],g[O*2+1]);p[v]=F.real,c[v]=F.imag}return[p,c,o]}}var Xw=Xt((e,t)=>e+t),VV=m2((e,t,n,a)=>({real:e+n,imag:t+a})),Ep=mn(ls,Xw,VV),UV={kernelName:ls,backendName:"cpu",kernelFunc:Ep};function g2(e,t,n,a,r){let s=w.sizeFromShape(a),i=w.makeZerosTypedArray(r,n);for(let o=0;o<e.length;o++){let l=e[o];if(l<0)throw new Error("Input x must be non-negative!");l>=r||(s>0?i[l]+=t[o]:i[l]+=1)}return i}function Kw(e,t,n,a=!1){let r=e.shape[0],s=e.shape[1],i=Ge([r,n],t.dtype);for(let o=0;o<r;o++)for(let l=0;l<s;l++){let d=e.get(o,l);if(d<0)throw new Error("Input x must be non-negative!");d>=n||(a?i.set(1,o,d):t.size>0?i.set(i.get(o,d)+t.get(o,l),o,d):i.set(i.get(o,d)+1,o,d))}return i}function Ms(e){return(t,n,a)=>{let r=w.getTypedArrayFromDType(n,t.length);for(let s=0;s<t.length;++s)r[s]=e(t[s],a);return r}}function ct(e,t,n){return({inputs:a,attrs:r,backend:s})=>{let{x:i}=a;if(Te(i,e),i.dtype==="string"||n==="string")throw new Error("unaryKernelFunc does not support string input/output");let o=s,l=o.data.get(i.dataId).values,d=w.sizeFromShape(i.shape),u=n||i.dtype,p=w.getArrayFromDType(u,d);for(let c=0;c<d;++c)p[c]=t(l[c],r);return o.makeTensorInfo(i.shape,u,p)}}function Tu(e,t,n){return({inputs:a,attrs:r,backend:s})=>{let{x:i}=a;if(Te(i,e),i.dtype==="string"||n==="string")throw new Error("unaryKernelFunc does not support string input/output");let o=s,l=o.data.get(i.dataId).values,d=n||i.dtype,u=t(l,d,r);return o.makeTensorInfo(i.shape,d,u)}}var Zw=Ms(e=>Math.ceil(e)),jV=Tu(ti,Zw),GV={kernelName:ti,backendName:"cpu",kernelFunc:jV};function y2(e,t,n,a){let r=w.getArrayFromDType(n,w.sizeFromShape(t));if(a&&n!=="string"){let s=0;e.forEach(i=>{let o=w.sizeFromShape(i.shape);r.set(i.vals,s),s+=o})}else{let s=0;e.forEach(i=>{let o=n==="string"?E.fromUint8ToStringArray(i.vals):i.vals,l=0;for(let d=0;d<i.shape[0];++d){let u=d*t[1]+s;for(let p=0;p<i.shape[1];++p)r[u+p]=o[l++]}s+=i.shape[1]})}return r}var Yw=Xt((e,t)=>e===t?1:0),Jw=mn(dl,Yw,null,"bool"),HV={kernelName:dl,backendName:"cpu",kernelFunc:Jw},Qw=Ms(e=>Math.exp(e)),e6=Tu(di,Qw,"float32"),qV={kernelName:di,backendName:"cpu",kernelFunc:e6},t6=Ms(e=>Math.expm1(e)),XV=Tu(cl,t6),KV={kernelName:cl,backendName:"cpu",kernelFunc:XV},n6=Ms(e=>Math.floor(e)),ZV=Tu(pi,n6),YV={kernelName:pi,backendName:"cpu",kernelFunc:ZV};function a6(e,t,n,a,r,s,i,o,l){let d=Ge([a,s],n);for(let u=0;u<a;u++){let p=[],c=0;for(let h=0;h<r;h++){let f=e[u*r+h];c+=f*i[h],p.push(f)}if(c<0||c>=l/s)throw new Error(`Invalid indices: ${p} does not index into ${o}`);for(let h=0;h<s;h++)d.values[u*s+h]=t.get(...t.indexToLoc(c*s+h))}return d}function r6(e,t,n){let a=Ge(n,e.dtype);for(let r=0;r<a.size;++r){let s=a.indexToLoc(r).slice(),i=s[0],o=s[2],l=t.locToIndex([i,o]);s[2]=t.values[l];let d=e.locToIndex(s);a.values[r]=e.values[d]}return a}var s6=Xt((e,t)=>e>t?1:0),JV=mn(gl,s6,null,"bool"),QV={kernelName:gl,backendName:"cpu",kernelFunc:JV},i6=Xt((e,t)=>e>=t?1:0),eU=mn(fi,i6,null,"bool"),tU={kernelName:fi,backendName:"cpu",kernelFunc:eU},o6=Xt((e,t)=>e<t?1:0),nU=mn(bl,o6,null,"bool"),aU={kernelName:bl,backendName:"cpu",kernelFunc:nU},l6=Xt((e,t)=>e<=t?1:0),rU=mn(vl,l6,null,"bool"),sU={kernelName:vl,backendName:"cpu",kernelFunc:rU};function u6(e,t,n){let a=(t-e)/(n-1),r=w.makeZerosTypedArray(n,"float32");r[0]=e;for(let s=1;s<r.length;s++)r[s]=r[s-1]+a;return r}var d6=Ms(e=>Math.log(e)),iU=Tu(yi,d6),oU={kernelName:yi,backendName:"cpu",kernelFunc:iU};function p6(e,t,n,a){let r=w.getTypedArrayFromDType(a,w.sizeFromShape(n));for(let s=0;s<r.length;++s){let i=s*t,o=e[i];for(let l=0;l<t;++l){let d=e[i+l];(Number.isNaN(d)||d>o)&&(o=d)}r[s]=o}return r}var c6=Xt((e,t)=>Math.max(e,t)),lU=mn(xi,c6),uU={kernelName:xi,backendName:"cpu",kernelFunc:lU},h6=Xt((e,t)=>Math.min(e,t)),dU=mn(ki,h6),pU={kernelName:ki,backendName:"cpu",kernelFunc:dU},A2=Xt((e,t)=>e*t),cU=m2((e,t,n,a)=>({real:e*n-t*a,imag:e*a+t*n})),af=mn(Si,A2,cU),hU={kernelName:Si,backendName:"cpu",kernelFunc:af};function f6(e,t,n){let a=w.createScalarValue(-1,n);return A2([],t,a,e,n)}function fU(e){let{inputs:t,backend:n}=e,{x:a}=t;Te(a,"neg");let r=n.data.get(a.dataId).values,[s,i]=f6(r,a.shape,a.dtype);return n.makeTensorInfo(i,a.dtype,s)}var mU={kernelName:Sl,backendName:"cpu",kernelFunc:fU},m6=Xt((e,t)=>e!==t?1:0),gU=mn(Nl,m6,null,"bool"),yU={kernelName:Nl,backendName:"cpu",kernelFunc:gU};function x2(e,t,n,a,r){let s=t.length,i=w.sizeFromShape(t),o=w.computeStrides(t),l=w.computeStrides(r),d=w.getTypedArrayFromDType(n,w.sizeFromShape(r));for(let u=0;u<i;++u){let p=w.indexToLoc(u,s,o),c=new Array(p.length);for(let f=0;f<c.length;f++)c[f]=p[a[f]];let h=w.locToIndex(c,s,l);d[h]=e[u]}return d}function Ta(e){let{inputs:t,attrs:n,backend:a}=e,{x:r}=t,{perm:s}=n;Te(r,"transpose");let i=r.shape.length,o=new Array(i);for(let u=0;u<o.length;u++)o[u]=r.shape[s[u]];let l=a.data.get(r.dataId).values,d=x2(l,r.shape,r.dtype,s,o);return{dataId:a.write(d,o,r.dtype),shape:o,dtype:r.dtype}}var AU={kernelName:Gi,backendName:"cpu",kernelFunc:Ta};function g6(e,t,n,a){let[r,s]=E.computeOutAndReduceShapes(e,a),i=Pa(t,"int32"),o=w.makeZerosTypedArray(w.sizeFromShape(r),i),l=w.sizeFromShape(s);for(let d=0;d<o.length;++d){let u=d*l,p=1;for(let c=0;c<l;++c)p*=n[u+c];o[d]=p}return{outVals:o,outShape:r,outDtype:i}}function xU(e){let{inputs:t,backend:n,attrs:a}=e,{x:r}=t,{axis:s,keepDims:i}=a;Te(r,"prod");let o=r.shape.length,l=w.parseAxisParam(s,r.shape),d=E.getAxesPermutation(l,o),u=l,p=r,c=[];d!=null&&(p=Ta({inputs:{x:r},backend:n,attrs:{perm:d}}),c.push(p),u=E.getInnerMostAxes(u.length,o));let h=n.data.get(p.dataId).values,{outVals:f,outShape:m,outDtype:g}=g6(p.shape,p.dtype,h,u),y=m;return i&&(y=E.expandShapeToKeepDim(m,l)),c.forEach(A=>n.disposeIntermediateTensorInfo(A)),n.makeTensorInfo(y,g,f)}var bU={kernelName:Fl,backendName:"cpu",kernelFunc:xU};function b2(e,t,n,a){let r=e===t,s=e<t&&n<0,i=t<e&&n>1;if(r||s||i)return w.makeZerosTypedArray(0,a);let o=Math.abs(Math.ceil((t-e)/n)),l=w.makeZerosTypedArray(o,a);t<e&&n===1&&(n=-1),l[0]=e;for(let d=1;d<l.length;d++)l[d]=l[d-1]+n;return l}var y6=Ms(e=>1/Math.sqrt(e)),vU=Tu(Oi,y6),wU={kernelName:Oi,backendName:"cpu",kernelFunc:vU},kU=Ms(e=>1/(1+Math.exp(-e))),A6=ct(Pi,e=>1/(1+Math.exp(-e))),IU={kernelName:Pi,backendName:"cpu",kernelFunc:A6};function rf(e,t,n,a,r){let s=En.isSliceContinous(a,t,n),i=w.sizeFromShape(n),o=w.computeStrides(a);if(s){let p=En.computeFlatOffset(t,o);return r==="string"?e.slice(p,p+i):e.subarray(p,p+i)}let l=r==="string"?E.fromUint8ToStringArray(e):e,d=Ge(a,r,l),u=Ge(n,r);for(let p=0;p<u.size;++p){let c=u.indexToLoc(p),h=c.map((f,m)=>f+t[m]);u.set(d.get(...h),...c)}return r==="string"?E.fromStringArrayToUint8(u.values):u.values}function wo(e){let{inputs:t,backend:n,attrs:a}=e,{x:r}=t,{begin:s,size:i}=a;Te(r,"slice");let[o,l]=En.parseSliceParams(r,s,i);En.assertParamsValid(r,o,l);let d=n.data.get(r.dataId).values,u=rf(d,o,l,r.shape,r.dtype);return n.makeTensorInfo(l,r.dtype,u)}var SU={kernelName:zl,backendName:"cpu",kernelFunc:wo};function x6(e,t,n,a,r,s,i){let o=t[0],l=s[0],d=new Array(l),u=new Array(o),p=t[1];if(l===0){if(o!==0)throw new Error(`Received SparseTensor with denseShape[0] = 0 but
|
|
indices.shape[0] = ${o}`);let g=w.getArrayFromDType(n,0),y=w.getArrayFromDType(r,0);return[g,[0,p],y,d,u]}let c=!0,h=0,f=new Array(l).fill(0);for(let g=0;g<o;++g){let y=e[g*p];if(y<0)throw new Error(`indices(${g}, 0) is invalid: ${y} < 0`);if(y>=l)throw new Error(`indices(${g}, 0) is invalid: ${y} >= ${l}`);++f[y],c=c&&y>=h,h=y}let m=!0;for(let g=0;g<l;++g){let y=f[g]===0;d[g]=y,m=m&&!y,f[g]=Math.max(f[g],1),g>0&&(f[g]+=f[g-1])}if(m&&c){let g=e,y=a;for(let A=0;A<o;++A)u[A]=A;return[g,[o,p],y,d,u]}else{let g=f[l-1],y=w.getArrayFromDType(n,g*p),A=w.getArrayFromDType(r,g),x=new Array(l).fill(0);for(let b=0;b<o;++b){let v=e[b*p],k=x[v],T=(v===0?0:f[v-1])+k;x[v]++;for(let C=0;C<p;++C)y[T*p+C]=e[b*p+C];A[T]=a[b],u[b]=T}for(let b=0;b<l;++b)if(x[b]===0){let v=b===0?0:f[b-1];y[v*p+0]=b;for(let k=1;k<p;++k)y[v*p+k]=0;A[v]=i}return[y,[g,p],A,d,u]}}function b6(e,t,n,a,r){let s=w.sizeFromShape(a),i=t[0],o=r.length,l=[],d=1,u=-1;for(let g=0;g<o;++g){let y=r[g];if(y===-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(y<0)throw new Error(`size ${g} must be non-negative, not ${y}`);d*=y,l.push(y)}}if(u!==-1){if(d<=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(s/d);if(d*g!==s)throw new Error(`Input to reshape is a SparseTensor with ${s}
|
|
dense values, but the requested shape requires a multiple of ${d}. inputShape=${a} outputShape= ${l}`);l[u]=g}let p=w.sizeFromShape(l);if(p!==s)throw new Error(`Input to reshape is a tensor with ${s} dense values, but the requested shape has ${p}. inputShape=${a} outputShape=${l}`);let c=a.length,h=[];if(c>0){h[c-1]=1;for(let g=c-2;g>=0;--g)h[g]=h[g+1]*a[g+1]}let f=[];if(o>0){f[o-1]=1;for(let g=o-2;g>=0;--g)f[g]=f[g+1]*l[g+1]}let m=w.getArrayFromDType(n,i*o);for(let g=0;g<i;++g){let y=0;for(let A=0;A<c;++A)y+=e[g*c+A]*h[A];for(let A=0;A<o;++A)m[g*o+A]=Math.trunc(y/f[A]),y%=f[A]}return[m,[i,o],l]}function v2(e,t,n,a,r,s=!1,i=0){let o=a.length;if(o!==r.length)throw new Error("segmentIds and indices should have same size.");let l=[t[0],e.length/t[0]],d=l[1],u=o>0?r[o-1]+1:0;if(u<0)throw new Error("segment ids must be >= 0");let p=t.slice();p[0]=u;let c=p.reduce((A,x)=>A*x,1),h=w.getArrayFromDType(n,c);if(o===0)return u>0&&h.fill(i),[h,p];if(u<=0)throw new Error("segment ids must be >= 0");let f=0,m=1,g=0,y=r[f];for(;;){let A=0;if(m<o){if(A=r[m],y===A){++m;continue}if(y>=A)throw new Error("segment ids are not increasing")}if(y<0||y>=u)throw new Error(`Segment id ${y} out of range [0, ${u}), possibly because segmentIds input is not sorted.`);y>g&&h.fill(i,g*d,y*d);for(let x=f;x<m;++x){let b=a[x];if(b<0||b>=l[0])throw new Error(`Bad: indices[${x}] == ${a[x]} out of range [0, ${l[0]})`);for(let v=0;v<d;v++)h[y*d+v]+=e[b*d+v]}if(s)for(let x=0;x<d;x++)h[y*d+x]/=m-f;if(f=m,++m,g=y+1,y=A,m>o)break}return g<u&&h.fill(i,g*d,u*d),[h,p]}var NU=Ms(e=>Math.sqrt(e)),TU=ct(zi,e=>Math.sqrt(e)),CU={kernelName:zi,backendName:"cpu",kernelFunc:TU},v6=Xt((e,t)=>{let n=e-t;return n*n}),EU=mn(Bi,v6),RU={kernelName:Bi,backendName:"cpu",kernelFunc:EU};function w6(e,t,n,a){let r=Ge(e,t.dtype);for(let s=0;s<r.size;s++){let i=r.indexToLoc(s),o=new Array(i.length);for(let l=0;l<o.length;l++)o[l]=i[l]*n[l]+a[l];r.set(t.get(...o),...i)}return r}var MU=class{constructor(e,t,n,a,r,s){this.separator=w.encodeString(e),this.nGramWidths=t,this.leftPad=w.encodeString(n),this.rightPad=w.encodeString(a),this.padWidth=r,this.preserveShort=s}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,a,r,s){for(let i=0;i<r;++i){let o=this.getPadWidth(s),l=Math.max(0,o-i),d=Math.max(0,o-(r-(i+1))),u=s-(l+d),p=t+(l>0?0:i-o),c=0;c+=l*this.leftPad.length;for(let g=0;g<u;++g)c+=e[p+g].length;c+=d*this.rightPad.length,c+=(l+d+u-1)*this.separator.length,n[a+i]=new Uint8Array(c);let h=n[a+i],f=0,m=g=>g.forEach(y=>h[f++]=y);for(let g=0;g<l;++g)m(this.leftPad),m(this.separator);for(let g=0;g<u-1;++g)m(e[p+g]),m(this.separator);if(u>0){m(e[p+u-1]);for(let g=0;g<d;++g)m(this.separator),m(this.rightPad)}else{for(let g=0;g<d-1;++g)m(this.rightPad),m(this.separator);m(this.rightPad)}}}compute(e,t){let n=e.length,a=t.length;if(a>0){let o=t[0];if(o!==0)throw new Error(`First split value must be 0, got ${o}`);for(let l=1;l<a;++l){let d=t[l]>=o;if(d=d&&t[l]<=n,!d)throw new Error(`Invalid split value ${t[l]}, must be in [${o}, ${n}]`);o=t[l]}if(o!==n)throw new Error(`Last split value must be data size. Expected ${n}, got ${o}`)}let r=a-1,s=w.getArrayFromDType("int32",a);if(n===0||a===0){let o=new Array(n);for(let l=0;l<=r;++l)s[l]=0;return[o,s]}s[0]=0;for(let o=1;o<=r;++o){let l=t[o]-t[o-1],d=0;this.nGramWidths.forEach(u=>{d+=this.getNumNGrams(l,u)}),this.preserveShort&&l>0&&d===0&&(d=1),s[o]=s[o-1]+d}let i=new Array(s[r]);for(let o=0;o<r;++o){let l=t[o],d=s[o];if(this.nGramWidths.forEach(u=>{let p=t[o+1]-t[o],c=this.getNumNGrams(p,u);this.createNGrams(e,l,i,d,c,u),d+=c}),this.preserveShort&&d===s[o]){let u=t[o+1]-t[o];if(u===0)continue;let p=u+2*this.padWidth,c=1;this.createNGrams(e,l,i,d,c,p)}}return[i,s]}};function k6(e,t,n,a,r,s,i,o){return new MU(n,a,r,s,i,o).compute(e,t)}function FU(e,t,n,a){if(!e.length)return;if(t.length===0){for(let s=0;s<e.length;++s)a.push(e.subarray(s,s+1));return}if(t.length===1){let s=t[0],i=e.indexOf(s);for(;i!==-1;){let o=e.subarray(0,i);(!n||o.length!==0)&&a.push(o),e=e.subarray(i+1),i=e.indexOf(s)}(!n||e.length!==0)&&a.push(e);return}let r=0;for(let s=0;s<e.length+1;s++)if(s===e.length||t.indexOf(e[s])!==-1){let i=e.subarray(r,s);(!n||i.length!==0)&&a.push(i),r=s+1}}function I6(e,t,n){let a=e.length,r=[],s=0,i=0,o=new Array(a);for(let c=0;c<a;++c){let h=r.length;FU(e[c],t,n,r);let f=r.length-h;o[c]=f,s+=f,i=Math.max(i,f)}let l=w.getArrayFromDType("int32",s*2),d=new Array(s),u=[a,i],p=0;for(let c=0;c<a;++c)for(let h=0;h<o[c];++h)l[p*2]=c,l[p*2+1]=h,d[p]=r[p],++p;return[l,d,u]}function S6(e,t){let n=w.getArrayFromDType("int32",e.length);for(let a=0;a<e.length;++a)n[a]=w.fingerPrint64(e[a]).modulo(t).getLowBitsUnsigned();return n}var N6=Xt((e,t)=>e-t),DU=m2((e,t,n,a)=>({real:e-n,imag:t-a})),w2=mn(Vi,N6,DU),$U={kernelName:Vi,backendName:"cpu",kernelFunc:w2};function T6(e,t){let n=new Array(e.rank);for(let r=0;r<n.length;r++)n[r]=e.shape[r]*t[r];let a=Ge(n,e.dtype);for(let r=0;r<a.values.length;++r){let s=a.indexToLoc(r),i=new Array(e.rank);for(let l=0;l<i.length;l++)i[l]=s[l]%e.shape[l];let o=e.locToIndex(i);a.values[r]=e.values[o]}return a}var Rp=(e,t)=>{let n=t.value-e.value;return n===0?e.index-t.index:n};function C6(e,t,n=0,a=e.length-1){for(;a>n;){if(a-n>600){let o=a-n+1,l=t-n+1,d=Math.log(o),u=.5*Math.exp(2*d/3),p=.5*Math.sqrt(d*u*(o-u)/o)*Math.sign(l-o/2),c=Math.max(n,Math.floor(t-l*u/o+p)),h=Math.min(a,Math.floor(t+(o-l)*u/o+p));C6(e,t,c,h)}let r=e[t],s=n,i=a;for(w.swap(e,n,t),Rp(e[a],r)>0&&w.swap(e,n,a);s<i;){for(w.swap(e,s,i),s++,i--;Rp(e[s],r)<0;)s=s+1;for(;Rp(e[i],r)>0;)i=i-1}Rp(e[n],r)===0?w.swap(e,n,i):(i=i+1,w.swap(e,i,a)),i<=t&&(n=i+1),t<=i&&(a=i-1)}}function E6(e,t,n,a,r){let s=t[t.length-1],[i,o]=[e.length/s,s],l=w.getTypedArrayFromDType(n,i*a),d=w.getTypedArrayFromDType("int32",i*a);for(let p=0;p<i;p++){let c=p*o,h=e.subarray(c,c+o),f=new Array(h.length);h.forEach((A,x)=>f[x]={value:A,index:x}),a<f.length&&(C6(f,a),f=f.slice(0,a)),r&&f.sort(Rp);let m=p*a,g=l.subarray(m,m+a),y=d.subarray(m,m+a);for(let A=0;A<a;A++)g[A]=f[A].value,y[A]=f[A].index}let u=t.slice();return u[u.length-1]=a,[Ge(u,n,l),Ge(u,"int32",d)]}function R6(e,t,n,a){let r=w.parseAxisParam(t,n)[0],s=[1,n[0],1];for(let f=0;f<r;f++)s[0]*=n[f];s[1]=n[r];for(let f=r+1;f<n.length;f++)s[2]*=n[f];let i={},o=new Int32Array(n[r]),l=new Jt(s,a,e),d=[],u=s[0]===1&&s[2]===1;for(let f=0;f<n[r];f++){let m;if(u)m=e[f].toString();else{let g=[];for(let y=0;y<s[0];y++)for(let A=0;A<s[2];A++)g.push(l.get(y,f,A));m=g.join(",")}if(i[m]!==void 0)o[f]=i[m];else{let g=Object.keys(i).length;i[m]=g,o[f]=g,d.push(f)}}let p=s.slice();p[1]=Object.keys(i).length;let c=new Jt(p,a);d.forEach((f,m)=>{for(let g=0;g<s[0];g++)for(let y=0;y<s[2];y++)c.set(l.get(g,f,y),g,m,y)});let h=n.slice();return h[r]=p[1],{outputValues:c.values,outputShape:h,indices:o}}au("cpu",()=>new f2,1);var M6=ct(ui,e=>e>=0?e:Math.exp(e)-1),OU={kernelName:ui,backendName:"cpu",kernelFunc:M6};function F6(e){let{inputs:t,backend:n,attrs:a}=e,{x:r}=t,{alpha:s}=a;Te([r],"leakyRelu");let i=w.sizeFromShape(r.shape),o=n.data.get(r.dataId).values,l=w.getTypedArrayFromDType("float32",i);for(let d=0;d<o.length;d++)l[d]=o[d]<0?s*o[d]:o[d];return n.makeTensorInfo(r.shape,"float32",l)}var _U={kernelName:gi,backendName:"cpu",kernelFunc:F6},PU=Xt((e,t)=>e<0?t*e:e);function D6(e){let{inputs:t,backend:n}=e,{x:a,alpha:r}=t;Te([a,r],"prelu");let s=n.data.get(a.dataId).values,i=n.data.get(r.dataId).values,[o,l]=PU(a.shape,r.shape,s,i,"float32");return n.makeTensorInfo(l,"float32",o)}var zU={kernelName:Ei,backendName:"cpu",kernelFunc:D6},$6=ct(Ri,e=>Math.max(0,e)),LU={kernelName:Ri,backendName:"cpu",kernelFunc:$6},O6=ct(Fi,e=>Math.min(Math.max(0,e),6)),WU={kernelName:Fi,backendName:"cpu",kernelFunc:O6};function k2(e,t,n,a,r){if(n==="linear")return Sr({inputs:{x:t},backend:e});if(n==="relu")return $6({inputs:{x:t},backend:e});if(n==="elu")return M6({inputs:{x:t},backend:e});if(n==="relu6")return O6({inputs:{x:t},backend:e});if(n==="prelu")return D6({inputs:{x:t,alpha:a},backend:e});if(n==="leakyrelu")return F6({inputs:{x:t},backend:e,attrs:{alpha:r}});if(n==="sigmoid")return A6({inputs:{x:t},backend:e});throw new Error(`Activation ${n} has not been implemented for the CPU backend.`)}function wt(e){let{inputs:t,backend:n,attrs:a}=e,{x:r}=t,{shape:s}=a,i=w.sizeFromShape(r.shape),o=w.inferFromImplicitShape(s,i),l=w.sizeFromShape(o);w.assert(i===l,()=>`The new shape (${o}) has ${l} elements and the old shape (${r.shape}) has ${i} elements. The new shape and old shape must have the same number of elements.`),n.incRef(r.dataId);let d=n.data.get(r.dataId);if(d.complexTensorInfos!=null){let u=d.complexTensorInfos.real,p=d.complexTensorInfos.imag;u.shape=o,p.shape=o}return{dataId:r.dataId,shape:o,dtype:r.dtype}}var BU={kernelName:$l,backendName:"cpu",kernelFunc:wt};function _6(e){let{inputs:t,backend:n,attrs:a}=e,{a:r,b:s}=t,{transposeA:i,transposeB:o}=a;Te([r,s],"matMul");let l=r.shape.length,d=s.shape.length,u=i?r.shape[l-2]:r.shape[l-1],p=o?s.shape[d-1]:s.shape[d-2],c=i?r.shape[l-1]:r.shape[l-2],h=o?s.shape[d-2]:s.shape[d-1],f=r.shape.slice(0,-2),m=s.shape.slice(0,-2),g=w.sizeFromShape(f),y=w.sizeFromShape(m),A=g===y||g===1||y===1;w.assert(l>=2&&d>=2&&A,()=>`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 x=(g>y?r.shape.slice(0,-2):s.shape.slice(0,-2)).concat([c,h]);w.assert(u===p,()=>`Error in matMul: inner shapes (${u}) and (${p}) of Tensors with shapes ${r.shape} and ${s.shape} and transposeA=${i} and transposeB=${o} must match.`);let b=i?[g,u,c]:[g,c,u],v=o?[y,h,p]:[y,p,h],k=wt({inputs:{x:r},backend:n,attrs:{shape:b}}),T=wt({inputs:{x:s},backend:n,attrs:{shape:v}}),C=i?k.shape[1]:k.shape[2],D=i?k.shape[2]:k.shape[1],O=o?T.shape[1]:T.shape[2],F=Math.max(g,y),S=n.data.get(k.dataId).values,P=n.data.get(T.dataId).values,_=w.computeStrides(k.shape),j=w.computeStrides(T.shape),[q,z,X]=i?[_[0],1,_[1]]:[_[0],_[1],1],[Z,te,J]=o?[1,j[1],j[0]]:[j[1],1,j[0]],re=D*O,Y=Ge([F,D,O],k.dtype),se=Y.values,de=n.blockSize;for(let be=0;be<F;be++)for(let ve=0;ve<D;ve+=de)for(let ke=0;ke<O;ke+=de)for(let Ee=0;Ee<C;Ee+=de){let _e=Math.min(ve+de,D),We=Math.min(ke+de,O),Ue=Math.min(Ee+de,C);for(let Xe=ve;Xe<_e;Xe++)for(let ut=ke;ut<We;ut++){let dt=0;for(let at=Ee;at<Ue;at++){let xt=Math.min(be,g-1)*q,ft=Math.min(be,y-1)*J,It=S[xt+Xe*z+at*X],Mt=P[at*Z+ut*te+ft];dt+=It*Mt}se[be*re+(Xe*O+ut)]+=dt}}return n.disposeIntermediateTensorInfo(k),n.disposeIntermediateTensorInfo(T),n.makeTensorInfo(x,Y.dtype,Y.values)}var VU={kernelName:Qs,backendName:"cpu",kernelFunc:_6};function UU(e){let{inputs:t,backend:n,attrs:a}=e,{a:r,b:s,bias:i,preluActivationWeights:o}=t,{transposeA:l,transposeB:d,activation:u,leakyreluAlpha:p}=a,c,h,f,m=[];c=_6({inputs:{a:r,b:s},attrs:{transposeA:l,transposeB:d},backend:n}),i&&(h=Ep({inputs:{a:c,b:i},backend:n}),m.push(c),c=h),u&&(f=k2(n,c,u,o,p),m.push(c),c=f);for(let g of m)n.disposeIntermediateTensorInfo(g);return c}var jU={kernelName:Hi,backendName:"cpu",kernelFunc:UU},GU=ct(Zo,e=>Math.acos(e)),HU={kernelName:Zo,backendName:"cpu",kernelFunc:GU},qU=ct(Yo,e=>Math.acosh(e)),XU={kernelName:Yo,backendName:"cpu",kernelFunc:qU};function KU(e){let{inputs:t,backend:n}=e,a=t;Te(t,"addN");let r=a.map(o=>n.data.get(o.dataId).values),s=Ge(a[0].shape,a[0].dtype),i=s.values;for(let o=0;o<a.length;o++){let l=r[o];for(let d=0;d<i.length;d++)i[d]+=l[d]}return n.makeTensorInfo(s.shape,s.dtype,s.values)}var ZU={kernelName:Zs,backendName:"cpu",kernelFunc:KU};function YU(e){let{inputs:t,backend:n,attrs:a}=e,{x:r}=t,{axis:s,keepDims:i}=a;Te(r,"all");let o=w.parseAxisParam(s,r.shape),l=o,d=E.getAxesPermutation(l,r.shape.length),u=r;d!=null&&(u=Ta({inputs:{x:r},backend:n,attrs:{perm:d}}),l=E.getInnerMostAxes(l.length,r.shape.length)),E.assertAxesAreInnerMostDims("all",l,u.shape.length);let[p,c]=E.computeOutAndReduceShapes(u.shape,l),h=w.sizeFromShape(c),f=w.makeZerosTypedArray(w.sizeFromShape(p),u.dtype),m=n.data.get(u.dataId).values;for(let y=0;y<f.length;++y){let A=y*h,x=m[A];for(let b=0;b<h;++b){let v=m[A+b];x=x&&v}f[y]=x}d!=null&&n.disposeIntermediateTensorInfo(u);let g=n.makeTensorInfo(p,u.dtype,f);if(i){let y=E.expandShapeToKeepDim(p,o),A=wt({inputs:{x:g},backend:n,attrs:{shape:y}});return n.disposeIntermediateTensorInfo(g),A}return g}var JU={kernelName:Jo,backendName:"cpu",kernelFunc:YU};function QU(e){let{inputs:t,backend:n,attrs:a}=e,{x:r}=t,{axis:s,keepDims:i}=a;Te(r,"any");let o=w.parseAxisParam(s,r.shape),l=o,d=E.getAxesPermutation(l,r.shape.length),u=r;d!=null&&(u=Ta({inputs:{x:r},backend:n,attrs:{perm:d}}),l=E.getInnerMostAxes(l.length,r.shape.length)),E.assertAxesAreInnerMostDims("any",l,u.shape.length);let[p,c]=E.computeOutAndReduceShapes(u.shape,l),h=w.sizeFromShape(c),f=w.makeZerosTypedArray(w.sizeFromShape(p),u.dtype),m=n.data.get(u.dataId).values;for(let y=0;y<f.length;++y){let A=y*h,x=m[A];for(let b=0;b<h;++b){let v=m[A+b];x=x||v}f[y]=x}d!=null&&n.disposeIntermediateTensorInfo(u);let g=n.makeTensorInfo(p,u.dtype,f);if(i){let y=E.expandShapeToKeepDim(p,o),A=wt({inputs:{x:g},backend:n,attrs:{shape:y}});return n.disposeIntermediateTensorInfo(g),A}return g}var ej={kernelName:Qo,backendName:"cpu",kernelFunc:QU};function tj(e){let{inputs:t,backend:n,attrs:a}=e,{x:r}=t,{axis:s}=a;Te(r,"argMax");let i=w.parseAxisParam(s,r.shape),o=E.getAxesPermutation(i,r.shape.length),l=r,d=[];o!=null&&(l=Ta({inputs:{x:r},backend:n,attrs:{perm:o}}),d.push(l),i=E.getInnerMostAxes(i.length,l.shape.length)),i=[i[0]],E.assertAxesAreInnerMostDims("argMax",i,l.shape.length);let[u,p]=E.computeOutAndReduceShapes(l.shape,i),c=w.sizeFromShape(u),h=w.makeZerosTypedArray(c,"int32"),f=w.sizeFromShape(p),m=n.data.get(l.dataId).values;for(let g=0;g<h.length;++g){let y=g*f,A=m[y],x=0;for(let b=0;b<f;++b){let v=m[y+b];v>A&&(A=v,x=b)}h[g]=x}return d.forEach(g=>n.disposeIntermediateTensorInfo(g)),n.makeTensorInfo(u,"int32",h)}var nj={kernelName:Ys,backendName:"cpu",kernelFunc:tj};function aj(e){let{inputs:t,backend:n,attrs:a}=e,{x:r}=t,{axis:s}=a;Te(r,"argMin");let i=w.parseAxisParam(s,r.shape),o=E.getAxesPermutation(i,r.shape.length),l=r,d=[];o!=null&&(l=Ta({inputs:{x:r},backend:n,attrs:{perm:o}}),d.push(l),i=E.getInnerMostAxes(i.length,l.shape.length)),i=[i[0]],E.assertAxesAreInnerMostDims("argMin",i,l.shape.length);let[u,p]=E.computeOutAndReduceShapes(l.shape,i),c=w.sizeFromShape(u),h=w.makeZerosTypedArray(c,"int32"),f=w.sizeFromShape(p),m=n.data.get(l.dataId).values;for(let g=0;g<h.length;++g){let y=g*f,A=m[y],x=0;for(let b=0;b<f;++b){let v=m[y+b];v<A&&(A=v,x=b)}h[g]=x}return d.forEach(g=>n.disposeIntermediateTensorInfo(g)),n.makeTensorInfo(u,"int32",h)}var rj={kernelName:yd,backendName:"cpu",kernelFunc:aj},sj=ct(el,e=>Math.asin(e)),ij={kernelName:el,backendName:"cpu",kernelFunc:sj},oj=ct(tl,e=>Math.asinh(e)),lj={kernelName:tl,backendName:"cpu",kernelFunc:oj},uj=ct(nl,e=>Math.atan(e)),dj={kernelName:nl,backendName:"cpu",kernelFunc:uj},pj=Xt((e,t)=>Math.atan2(e,t)),cj=mn(rl,pj),hj={kernelName:rl,backendName:"cpu",kernelFunc:cj},fj=ct(al,e=>Math.atanh(e)),mj={kernelName:al,backendName:"cpu",kernelFunc:fj};function I2(e,t,n,a,r,s){let i=r.strideHeight,o=r.strideWidth,l=r.dilationHeight,d=r.dilationWidth,u=r.effectiveFilterHeight,p=r.effectiveFilterWidth,c=r.padInfo.top,h=r.padInfo.left,f=s==="max"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,m=Ge(r.outShape,n),g=m.values,y=r.outShape[1]*r.outShape[2]*r.outShape[3],A=r.outShape[2]*r.outShape[3],x=r.outShape[3];for(let b=0;b<r.batchSize;++b){let v=b*y,k=b*a[0];for(let T=0;T<r.inChannels;++T)for(let C=0;C<r.outHeight;++C){let D=C*i-c,O=Math.max(0,D),F=Math.min(r.inHeight,u+D),S=v+C*A;for(let P=0;P<r.outWidth;++P){let _=P*o-h,j=Math.max(0,_),q=Math.min(r.inWidth,p+_),z=f,X=0,Z=0;for(let J=O;J<F;J+=l){let re=k+J*a[1];for(let Y=j;Y<q;Y+=d){let se=re+Y*a[2],de=e[se+T];s==="max"&&de>z?z=de:s==="avg"&&(X+=de,Z++)}if(isNaN(z))break}let te=S+P*x+T;g[te]=s==="avg"?X/Z:z}}}return m}function P6(e,t,n,a,r=!1,s=!1){let i=Ge(a.outShape,"int32"),o=a.strideHeight,l=a.strideWidth,d=a.dilationHeight,u=a.dilationWidth,p=a.effectiveFilterHeight,c=a.effectiveFilterWidth,h=a.padInfo.top,f=a.padInfo.left,m=Ge(t,n,e);for(let g=0;g<a.batchSize;++g)for(let y=0;y<a.inChannels;++y)for(let A=0;A<a.outHeight;++A){let x=A*o-h,b=x;for(;b<0;)b+=d;let v=Math.min(a.inHeight,p+x);for(let k=0;k<a.outWidth;++k){let T=k*l-f,C=T;for(;C<0;)C+=u;let D=Math.min(a.inWidth,c+T),O=Number.NEGATIVE_INFINITY,F=-1;for(let S=b;S<v;S+=d){let P=S-x;for(let _=C;_<D;_+=u){let j=_-T,q=m.get(g,S,_,y);q>O&&(O=q,r?F=s?((g*a.inHeight+S)*a.inWidth+_)*a.inChannels+y:(S*a.inWidth+_)*a.inChannels+y:F=P*c+j)}}i.set(F,g,A,k,y)}}return i}function z6(e,t,n,a,r,s){let i=r.strideDepth,o=r.strideHeight,l=r.strideWidth,d=r.dilationDepth,u=r.dilationHeight,p=r.dilationWidth,c=r.effectiveFilterDepth,h=r.effectiveFilterHeight,f=r.effectiveFilterWidth,m=r.padInfo.front,g=r.padInfo.top,y=r.padInfo.left,A=s==="max"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,x=Ge(r.outShape,n),b=x.values,v=r.outShape[1]*r.outShape[2]*r.outShape[3]*r.outShape[4],k=r.outShape[2]*r.outShape[3]*r.outShape[4],T=r.outShape[3]*r.outShape[4],C=r.outShape[4];for(let D=0;D<r.batchSize;++D){let O=D*v,F=D*a[0];for(let S=0;S<r.inChannels;++S)for(let P=0;P<r.outDepth;++P){let _=P*i-m,j=_;for(;j<0;)j+=d;let q=Math.min(r.inDepth,c+_),z=O+P*k;for(let X=0;X<r.outHeight;++X){let Z=X*o-g,te=Z;for(;te<0;)te+=u;let J=Math.min(r.inHeight,h+Z),re=z+X*T;for(let Y=0;Y<r.outWidth;++Y){let se=Y*l-y,de=se;for(;de<0;)de+=p;let be=Math.min(r.inWidth,f+se),ve=re+Y*C,ke=A,Ee=0,_e=0;for(let Ue=j;Ue<q;Ue+=d){let Xe=F+Ue*a[1];for(let ut=te;ut<J;ut+=u){let dt=Xe+ut*a[2];for(let at=de;at<be;at+=p){let xt=dt+at*a[3],ft=e[xt+S];if(s==="max"&&ft>ke?ke=ft:s==="avg"&&(Ee+=ft,_e++),isNaN(ke))break}if(isNaN(ke))break}if(isNaN(ke))break}let We=ve+S;b[We]=s==="avg"?Ee/_e:ke}}}}return x}function gj(e,t){let n=Ge(t.outShape,"int32"),a=t.strideDepth,r=t.strideHeight,s=t.strideWidth,i=t.dilationDepth,o=t.dilationHeight,l=t.dilationWidth,d=t.effectiveFilterDepth,u=t.effectiveFilterHeight,p=t.effectiveFilterWidth,c=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 y=0;y<t.outDepth;++y){let A=y*a-c,x=A;for(;x<0;)x+=i;let b=Math.min(t.inDepth,d+A);for(let v=0;v<t.outHeight;++v){let k=v*r-h,T=k;for(;T<0;)T+=o;let C=Math.min(t.inHeight,u+k);for(let D=0;D<t.outWidth;++D){let O=D*s-f,F=O;for(;F<0;)F+=l;let S=Math.min(t.inWidth,p+O),P=Number.NEGATIVE_INFINITY,_=-1;for(let j=x;j<b;j+=i){let q=j-A;for(let z=T;z<C;z+=o){let X=z-k;for(let Z=F;Z<S;Z+=l){let te=Z-O,J=e.get(m,j,z,Z,g);J>=P&&(P=J,_=q*u*p+X*u+te)}}}n.set(_,m,y,v,D,g)}}}return n}function yj(e){let{inputs:t,backend:n,attrs:a}=e,{x:r}=t;Te(r,"avgPool");let{filterSize:s,strides:i,pad:o,dimRoundingMode:l}=a,d=1;w.assert(E.eitherStridesOrDilationsAreOne(i,d),()=>`Error in avgPool: Either strides or dilations must be 1. Got strides ${i} and dilations '${d}'`);let u=E.computePool2DInfo(r.shape,s,i,d,o,l),p;if(u.filterWidth===1&&u.filterHeight===1&&w.arraysEqual(u.inShape,u.outShape))p=Sr({inputs:{x:r},backend:n});else{let c=n.data.get(r.dataId).values,h=w.computeStrides(r.shape),f=I2(c,r.shape,r.dtype,h,u,"avg");p=n.makeTensorInfo(u.outShape,r.dtype,f.values)}return p}var Aj={kernelName:Js,backendName:"cpu",kernelFunc:yj};function xj(e){let{inputs:t,backend:n,attrs:a}=e,{x:r}=t,{filterSize:s,strides:i,pad:o,dimRoundingMode:l,dataFormat:d}=a;Te(r,"avgPool3d");let u=E.computePool3DInfo(r.shape,s,i,1,o,l,d),p=n.data.get(r.dataId).values,c=z6(p,r.shape,r.dtype,w.computeStrides(r.shape),u,"avg");return n.makeTensorInfo(c.shape,"float32",c.values)}var bj={kernelName:Ad,backendName:"cpu",kernelFunc:xj};function vj(e){let{inputs:t,backend:n,attrs:a}=e,{dy:r,input:s}=t,{filterSize:i,strides:o,pad:l,dimRoundingMode:d}=a;Te([r,s],"avgPool3DGrad");let u=E.computePool3DInfo(s.shape,i,o,1,l,d),p=u.strideDepth,c=u.strideHeight,h=u.strideWidth,f=u.filterDepth,m=u.filterHeight,g=u.filterWidth,y=u.dilationDepth,A=u.dilationHeight,x=u.dilationWidth,b=u.effectiveFilterDepth,v=u.effectiveFilterHeight,k=u.effectiveFilterWidth,T=b-1-u.padInfo.front,C=k-1-u.padInfo.left,D=v-1-u.padInfo.top,O=Ge(s.shape,"float32"),F=1/(f*m*g),S=n.bufferSync(r);for(let P=0;P<u.batchSize;++P)for(let _=0;_<u.inChannels;++_)for(let j=0;j<u.inDepth;++j)for(let q=0;q<u.inHeight;++q)for(let z=0;z<u.inWidth;++z){let X=j-T,Z=q-D,te=z-C,J=0;for(let re=0;re<b;re+=y){let Y=(X+re)/p;if(!(Y<0||Y>=u.outDepth||Math.floor(Y)!==Y))for(let se=0;se<v;se+=A){let de=(Z+se)/c;if(!(de<0||de>=u.outHeight||Math.floor(de)!==de))for(let be=0;be<k;be+=x){let ve=(te+be)/h;ve<0||ve>=u.outWidth||Math.floor(ve)!==ve||(J+=S.get(P,Y,de,ve,_))}}}O.set(J*F,P,j,q,z,_)}return n.makeTensorInfo(O.shape,O.dtype,O.values)}var wj={kernelName:Bc,backendName:"cpu",kernelFunc:vj};function kj(e){let{inputs:t,backend:n,attrs:a}=e,{dy:r,input:s}=t,i=s;Te([r,s],"avgPoolGrad");let{filterSize:o,strides:l,pad:d}=a,u=E.computePool2DInfo(i.shape,o,l,1,d),p=u.strideHeight,c=u.strideWidth,h=u.filterHeight,f=u.filterWidth,m=u.dilationHeight,g=u.dilationWidth,y=u.effectiveFilterHeight,A=u.effectiveFilterWidth,x=A-1-u.padInfo.left,b=y-1-u.padInfo.top,v=Ge(i.shape,"float32"),k=1/(h*f),T=n.data.get(r.dataId).values,C=Ge(r.shape,"float32",T);for(let D=0;D<u.batchSize;++D)for(let O=0;O<u.inChannels;++O)for(let F=0;F<u.inHeight;++F)for(let S=0;S<u.inWidth;++S){let P=F-b,_=S-x,j=0;for(let q=0;q<y;q+=m){let z=(P+q)/p;if(!(z<0||z>=u.outHeight||Math.floor(z)!==z))for(let X=0;X<A;X+=g){let Z=(_+X)/c;Z<0||Z>=u.outWidth||Math.floor(Z)!==Z||(j+=C.get(D,z,Z,O))}}v.set(j*k,D,F,S,O)}return n.makeTensorInfo(v.shape,v.dtype,v.values)}var Ij={kernelName:Wc,backendName:"cpu",kernelFunc:kj};function Sj(e){let{inputs:t,backend:n,attrs:a}=e,{x:r,scale:s,offset:i,mean:o,variance:l}=t;w.assert(o.shape.length===l.shape.length,()=>"Batch normalization gradient requires mean and variance to have equal ranks."),w.assert(i==null||o.shape.length===i.shape.length,()=>"Batch normalization gradient requires mean and offset to have equal ranks."),w.assert(s==null||o.shape.length===s.shape.length,()=>"Batch normalization gradient requires mean and scale to have equal ranks."),Te([r,o,l,s,i],"batchNorm");let{varianceEpsilon:d}=a;d==null&&(d=.001);let u=n.data.get(r.dataId).values,p=n.data.get(o.dataId).values,c=n.data.get(l.dataId).values,h=s?n.data.get(s.dataId).values:new Float32Array([1]),f=i?n.data.get(i.dataId).values:new Float32Array([0]),m=new Float32Array(u.length),g=f.length,y=h.length,A=c.length,x=p.length,b=0,v=0,k=0,T=0;for(let C=0;C<u.length;++C)m[C]=f[b++]+(u[C]-p[v++])*h[k++]/Math.sqrt(c[T++]+d),b>=g&&(b=0),v>=x&&(v=0),k>=y&&(k=0),T>=A&&(T=0);return n.makeTensorInfo(r.shape,r.dtype,m)}var Nj={kernelName:hi,backendName:"cpu",kernelFunc:Sj};function Tj(e){let{inputs:t,backend:n,attrs:a}=e,{x:r}=t,{blockShape:s,crops:i}=a;Te([r],"batchToSpaceND");let o=s.reduce((y,A)=>y*A),l=E.getReshaped(r.shape,s,o),d=E.getPermuted(l.length,s.length),u=E.getReshapedPermuted(r.shape,s,o),p=E.getSliceBeginCoords(i,s.length),c=E.getSliceSize(u,i,s.length),h=wt({inputs:{x:r},backend:n,attrs:{shape:l}}),f=Ta({inputs:{x:h},backend:n,attrs:{perm:d}}),m=wt({inputs:{x:f},backend:n,attrs:{shape:u}}),g=wo({inputs:{x:m},backend:n,attrs:{begin:p,size:c}});return n.disposeIntermediateTensorInfo(h),n.disposeIntermediateTensorInfo(f),n.disposeIntermediateTensorInfo(m),g}var Cj={kernelName:sl,backendName:"cpu",kernelFunc:Tj};function Ej(e){let{inputs:t,backend:n,attrs:a}=e,{x:r,weights:s}=t,{size:i}=a,o=n.data.get(r.dataId).values,l=n.data.get(s.dataId).values,d=g2(o,l,s.dtype,s.shape,i);return n.makeTensorInfo([i],s.dtype,d)}var Rj={kernelName:Vc,backendName:"cpu",kernelFunc:Ej};function Mj(e){let{inputs:t,backend:n}=e,{s0:a,s1:r}=t,s=n.data.get(a.dataId).values,i=n.data.get(r.dataId).values,o=E.assertAndGetBroadcastShape(Array.from(s),Array.from(i));return n.makeTensorInfo([o.length],"int32",Int32Array.from(o))}var Fj={kernelName:Uc,backendName:"cpu",kernelFunc:Mj},Dj=ct(us,(e,t)=>{let n=t;return e>n.clipValueMax?n.clipValueMax:e<n.clipValueMin?n.clipValueMin:e}),$j={kernelName:us,backendName:"cpu",kernelFunc:Dj},Oj=e=>{let{x:t}=e.inputs,n=e.backend,a=new Float32Array(w.sizeFromShape(t.shape)),r=n.data.get(t.dataId),s=r.complexTensorInfos.real,i=r.complexTensorInfos.imag,o=n.data.get(s.dataId).values,l=n.data.get(i.dataId).values;for(let d=0;d<o.length;d++){let u=o[d],p=l[d];a[d]=Math.hypot(u,p)}return n.makeOutput(a,t.shape,"float32")},_j={kernelName:xd,backendName:"cpu",kernelFunc:Oj};function Cu(e){let{inputs:t,backend:n}=e,{input:a}=t,r=n.data.get(a.dataId).complexTensorInfos.imag,s=n.data.get(r.dataId).values;return n.makeTensorInfo(r.shape,r.dtype,s)}var Pj={kernelName:rh,backendName:"cpu",kernelFunc:Cu};function Eu(e){let{inputs:t,backend:n,attrs:a}=e,{axis:r}=a,s=w.parseAxisParam(r,t[0].shape)[0],i=E.computeOutShape(t.map(m=>m.shape),s);if(w.sizeFromShape(i)===0)return n.makeTensorInfo(i,t[0].dtype,[]);let o=t.filter(m=>w.sizeFromShape(m.shape)>0);if(o.length===1)return Sr({inputs:{x:o[0]},backend:n});let l=o.map(m=>m.shape);if(E.assertParamsConsistent(l,s),o[0].dtype==="complex64"){let m=o.map(b=>vo({inputs:{input:b},backend:n})),g=o.map(b=>Cu({inputs:{input:b},backend:n})),y=Eu({inputs:m,backend:n,attrs:{axis:s}}),A=Eu({inputs:g,backend:n,attrs:{axis:s}}),x=fa({inputs:{real:y,imag:A},backend:n});return m.forEach(b=>n.disposeIntermediateTensorInfo(b)),g.forEach(b=>n.disposeIntermediateTensorInfo(b)),n.disposeIntermediateTensorInfo(y),n.disposeIntermediateTensorInfo(A),x}let d=o.map(m=>{let g=w.sizeFromShape(m.shape.slice(s));return wt({inputs:{x:m},backend:n,attrs:{shape:[-1,g]}})}),u=d.map(m=>({vals:n.data.get(m.dataId).values,shape:m.shape}));i=E.computeOutShape(d.map(m=>m.shape),1);let p=d[0].shape[0]===1,c=y2(u,i,t[0].dtype,p),h=E.computeOutShape(o.map(m=>m.shape),s),f=n.makeTensorInfo(h,t[0].dtype,c);return d.forEach(m=>n.disposeIntermediateTensorInfo(m)),f}var zj={kernelName:il,backendName:"cpu",kernelFunc:Eu};function L6(e){let{inputs:t,backend:n,attrs:a}=e,{x:r,filter:s}=t,{strides:i,pad:o,dataFormat:l,dilations:d,dimRoundingMode:u}=a;Te([r,s],"conv2d");let p=E.convertConv2DDataFormat(l),c=E.computeConv2DInfo(r.shape,s.shape,i,d,o,u,!1,p),h=c.filterHeight,f=c.filterWidth,m=c.dilationHeight,g=c.dilationWidth,y=c.padInfo.left,A=c.padInfo.top,x=c.dataFormat==="channelsLast",b=new Jt(c.outShape,r.dtype),v=w.computeStrides(r.shape),k=w.computeStrides(s.shape),T=v[0],C=x?v[1]:v[2],D=x?v[2]:1,O=x?1:v[1],F=b.strides[0],S=x?b.strides[1]:b.strides[2],P=x?b.strides[2]:1,_=x?1:b.strides[1],j=n.data.get(r.dataId).values,q=n.data.get(s.dataId).values,z=b.values;for(let X=0;X<c.batchSize;++X){let Z=X*T,te=X*F;for(let J=0;J<c.outHeight;++J){let re=te+J*S,Y=J*c.strideHeight-A;for(let se=0;se<h;++se){let de=Y+se*m;if(de<0||de>=c.inHeight)continue;let be=se*k[0],ve=Z+de*C;for(let ke=0;ke<c.outWidth;++ke){let Ee=re+ke*P,_e=ke*c.strideWidth-y;for(let We=0;We<f;++We){let Ue=_e+We*g;if(Ue<0||Ue>=c.inWidth)continue;let Xe=be+We*k[1],ut=ve+Ue*D,dt=Xe;for(let at=0;at<c.inChannels;++at){let xt=j[ut+at*O];for(let ft=0;ft<c.outChannels;++ft)z[Ee+ft*_]+=xt*q[dt+ft];dt+=c.outChannels}}}}}}return n.makeTensorInfo(b.shape,b.dtype,z)}var Lj={kernelName:ni,backendName:"cpu",kernelFunc:L6};function Wj(e){let{inputs:t,backend:n,attrs:a}=e,{x:r,dy:s}=t,{strides:i,pad:o,dataFormat:l,dimRoundingMode:d,filterShape:u}=a;Te([r,s],"conv2dBackpropFilter");let p=E.convertConv2DDataFormat(l),c=E.computeConv2DInfo(r.shape,u,i,1,o,d,!1,p),{strideHeight:h,strideWidth:f,filterHeight:m,filterWidth:g}=c,y=c.dataFormat==="channelsLast",A=new Jt(c.filterShape,"float32"),x=c.padInfo.left,b=c.padInfo.top,v=n.data.get(r.dataId).values,k=n.data.get(s.dataId).values,T=new Jt(r.shape,r.dtype,v),C=new Jt(s.shape,s.dtype,k);for(let D=0;D<m;++D){let O=Math.max(0,Math.ceil((b-D)/h)),F=Math.min(c.outHeight,(c.inHeight+b-D)/h);for(let S=0;S<g;++S){let P=Math.max(0,Math.ceil((x-S)/f)),_=Math.min(c.outWidth,(c.inWidth+x-S)/f);for(let j=0;j<c.inChannels;++j)for(let q=0;q<c.outChannels;++q){let z=0;for(let X=0;X<c.batchSize;++X)for(let Z=O;Z<F;++Z){let te=D+Z*h-b;for(let J=P;J<_;++J){let re=S+J*f-x;y?z+=T.get(X,te,re,j)*C.get(X,Z,J,q):z+=T.get(X,j,te,re)*C.get(X,q,Z,J)}}A.set(z,D,S,j,q)}}}return n.makeTensorInfo(A.shape,A.dtype,A.values)}var Bj={kernelName:Gc,backendName:"cpu",kernelFunc:Wj};function Vj(e){let{inputs:t,backend:n,attrs:a}=e,{dy:r,filter:s}=t,{inputShape:i,strides:o,pad:l,dataFormat:d,dimRoundingMode:u}=a;Te([r,s],"conv2dBackpropInput");let p=w.computeStrides(s.shape),c=w.computeStrides(r.shape),h=E.convertConv2DDataFormat(d),f=E.computeConv2DInfo(i,s.shape,o,1,l,u,!1,h),m=new Jt(f.inShape,"float32"),g=m.values,y=n.data.get(r.dataId).values,A=n.data.get(s.dataId).values,[x,b,v]=p,{batchSize:k,filterHeight:T,filterWidth:C,inChannels:D,inHeight:O,inWidth:F,outChannels:S,outHeight:P,outWidth:_,strideHeight:j,strideWidth:q}=f;h=f.dataFormat;let z=T-1-f.padInfo.top,X=C-1-f.padInfo.left,Z=h==="channelsLast",te=m.strides[0],J=Z?m.strides[1]:m.strides[2],re=Z?m.strides[2]:1,Y=Z?1:m.strides[1],se=c[0],de=Z?c[1]:c[2],be=Z?c[2]:1,ve=Z?1:c[1];for(let ke=0;ke<k;++ke)for(let Ee=0;Ee<D;++Ee)for(let _e=0;_e<O;++_e){let We=_e-z,Ue=Math.max(0,Math.ceil(We/j)),Xe=Math.min(P,(T+We)/j);for(let ut=0;ut<F;++ut){let dt=ut-X,at=Math.max(0,Math.ceil(dt/q)),xt=Math.min(_,(C+dt)/q),ft=0;for(let Mt=Ue;Mt<Xe;++Mt){let aa=Mt*j-We;for(let gn=at;gn<xt;++gn){let ra=gn*q-dt,xa=se*ke+de*Mt+be*gn,Bn=x*(T-1-aa)+b*(C-1-ra)+v*Ee;for(let Vn=0;Vn<S;++Vn){let ba=y[xa+ve*Vn],Un=A[Bn+Vn];ft+=ba*Un}}}let It=te*ke+J*_e+re*ut+Y*Ee;g[It]=ft}}return n.makeTensorInfo(m.shape,m.dtype,m.values)}var Uj={kernelName:ai,backendName:"cpu",kernelFunc:Vj};function jj(e){let{inputs:t,backend:n,attrs:a}=e,{x:r,filter:s}=t,{strides:i,pad:o,dilations:l}=a;Te([r,s],"conv3d");let d=E.computeConv3DInfo(r.shape,s.shape,i,l,o),{filterDepth:u,filterHeight:p,filterWidth:c,dilationDepth:h,dilationHeight:f,dilationWidth:m,padInfo:g}=d,y=g.front,A=g.left,x=g.top,b=new Jt(d.outShape,r.dtype),v=n.data.get(r.dataId).values,k=n.data.get(s.dataId).values,T=b.values,C=w.computeStrides(r.shape),D=w.computeStrides(s.shape);for(let O=0;O<d.batchSize;++O){let F=O*C[0],S=O*b.strides[0];for(let P=0;P<d.outDepth;++P){let _=S+P*b.strides[1],j=P*d.strideDepth-y;for(let q=0;q<u;++q){let z=j+q*h;if(z<0||z>=d.inDepth)continue;let X=q*D[0],Z=F+z*C[1];for(let te=0;te<d.outHeight;++te){let J=_+te*b.strides[2],re=te*d.strideHeight-x;for(let Y=0;Y<p;++Y){let se=re+Y*f;if(se<0||se>=d.inHeight)continue;let de=X+Y*D[1],be=Z+se*C[2];for(let ve=0;ve<d.outWidth;++ve){let ke=J+ve*d.outChannels,Ee=ve*d.strideWidth-A;for(let _e=0;_e<c;++_e){let We=Ee+_e*m;if(We<0||We>=d.inWidth)continue;let Ue=de+_e*D[2],Xe=be+We*d.inChannels,ut=Ue;for(let dt=0;dt<d.inChannels;++dt){let at=v[Xe+dt];for(let xt=0;xt<d.outChannels;++xt)T[ke+xt]+=at*k[ut+xt];ut+=d.outChannels}}}}}}}}return n.makeTensorInfo(b.shape,b.dtype,b.values)}var Gj={kernelName:bd,backendName:"cpu",kernelFunc:jj};function Hj(e){let{inputs:t,backend:n,attrs:a}=e,{x:r,dy:s}=t,{strides:i,pad:o,filterShape:l}=a;Te([r,s],"conv3dBackpropFilterV2");let d=w.computeStrides(r.shape),u=w.computeStrides(s.shape),p=E.computeConv3DInfo(r.shape,l,i,1,o),c=p.strideDepth,h=p.strideHeight,f=p.strideWidth,m=p.filterDepth,g=p.filterHeight,y=p.filterWidth,A=new Jt(p.filterShape,"float32"),x=A.values,[b,v,k,T]=A.strides,C=n.data.get(s.dataId).values,[D,O,F,S]=u,P=n.data.get(r.dataId).values,[_,j,q,z]=d,X=p.padInfo.front,Z=p.padInfo.left,te=p.padInfo.top;for(let J=0;J<m;++J){let re=Math.max(0,Math.ceil((X-J)/c)),Y=Math.min(p.outDepth,(p.inDepth+X-J)/c),se=J*b;for(let de=0;de<g;++de){let be=Math.max(0,Math.ceil((te-de)/h)),ve=Math.min(p.outHeight,(p.inHeight+te-de)/h),ke=de*v+se;for(let Ee=0;Ee<y;++Ee){let _e=Math.max(0,Math.ceil((Z-Ee)/f)),We=Math.min(p.outWidth,(p.inWidth+Z-Ee)/f),Ue=Ee*k+ke;for(let Xe=0;Xe<p.inChannels;++Xe){let ut=Xe*T+Ue;for(let dt=0;dt<p.outChannels;++dt){let at=0;for(let xt=0;xt<p.batchSize;++xt){let ft=xt*_,It=xt*D;for(let Mt=re;Mt<Y;++Mt){let aa=(J+Mt*c-X)*j+ft,gn=Mt*O+It;for(let ra=be;ra<ve;++ra){let xa=(de+ra*h-te)*q+aa,Bn=ra*F+gn;for(let Vn=_e;Vn<We;++Vn){let ba=(Ee+Vn*f-Z)*z+xa,Un=Vn*S+Bn;at+=P[ba+Xe]*C[Un+dt]}}}}x[ut+dt]=at}}}}}return n.makeTensorInfo(A.shape,A.dtype,A.values)}var qj={kernelName:Hc,backendName:"cpu",kernelFunc:Hj};function Xj(e){let{inputs:t,backend:n,attrs:a}=e,{dy:r,filter:s}=t,{pad:i,strides:o,inputShape:l}=a;Te([r],"conv3dBackpropInputV2");let d=w.computeStrides(r.shape),u=w.computeStrides(s.shape),p=E.computeConv3DInfo(l,s.shape,o,1,i),c=new Jt(p.inShape,"float32"),h=c.values,[f,m,g,y]=c.strides,A=n.data.get(r.dataId).values,[x,b,v,k]=d,T=n.data.get(s.dataId).values,[C,D,O,F]=u,{batchSize:S,filterDepth:P,filterHeight:_,filterWidth:j,inChannels:q,inDepth:z,inHeight:X,inWidth:Z,outChannels:te,outDepth:J,outHeight:re,outWidth:Y,strideDepth:se,strideHeight:de,strideWidth:be}=p,ve=P-1-p.padInfo.front,ke=_-1-p.padInfo.top,Ee=j-1-p.padInfo.left;for(let _e=0;_e<S;++_e)for(let We=0;We<q;++We)for(let Ue=0;Ue<z;++Ue){let Xe=Ue-ve,ut=Math.max(0,Math.ceil(Xe/se)),dt=Math.min(J,(P+Xe)/se);for(let at=0;at<X;++at){let xt=at-ke,ft=Math.max(0,Math.ceil(xt/de)),It=Math.min(re,(_+xt)/de);for(let Mt=0;Mt<Z;++Mt){let aa=Mt-Ee,gn=Math.max(0,Math.ceil(aa/be)),ra=Math.min(Y,(j+aa)/be),xa=0;for(let Bn=ut;Bn<dt;++Bn){let Vn=Bn*se-Xe;for(let ba=ft;ba<It;++ba){let Un=ba*de-xt;for(let Er=gn;Er<ra;++Er){let jn=Er*be-aa,Zr=x*_e+b*Bn+v*ba+k*Er,dr=C*(P-1-Vn)+D*(_-1-Un)+O*(j-1-jn)+F*We;for(let Yr=0;Yr<te;++Yr){let Yu=A[Zr+Yr],qa=T[dr+Yr];xa+=Yu*qa}}}}h[f*_e+m*Ue+g*at+y*Mt+We]=xa}}}return n.makeTensorInfo(c.shape,c.dtype,c.values)}var Kj={kernelName:qc,backendName:"cpu",kernelFunc:Xj},Zj=ct(ri,e=>Math.cos(e)),Yj={kernelName:ri,backendName:"cpu",kernelFunc:Zj},Jj=ct(si,e=>Math.cosh(e)),Qj={kernelName:si,backendName:"cpu",kernelFunc:Jj};function eG(e){let{inputs:t,backend:n,attrs:a}=e,{image:r,boxes:s,boxInd:i}=t,{cropSize:o,method:l,extrapolationValue:d}=a,[u,p,c,h]=r.shape,f=s.shape[0],[m,g]=o,y=Ge([f,m,g,h],"float32"),A=n.data.get(s.dataId).values,x=n.data.get(i.dataId).values,b=n.data.get(r.dataId).values,v=w.computeStrides(r.shape),k=w.computeStrides(y.shape);for(let T=0;T<f;T++){let C=T*4,D=A[C],O=A[C+1],F=A[C+2],S=A[C+3],P=x[T];if(P>=u)continue;let _=m>1?(F-D)*(p-1)/(m-1):0,j=g>1?(S-O)*(c-1)/(g-1):0;for(let q=0;q<m;q++){let z=m>1?D*(p-1)+q*_:.5*(D+F)*(p-1);if(z<0||z>p-1){for(let X=0;X<g;X++)for(let Z=0;Z<h;Z++){let te=Z+X*k[2]+q*k[1]+T*k[0];y.values[te]=d}continue}if(l==="bilinear"){let X=Math.floor(z),Z=Math.ceil(z),te=z-X;for(let J=0;J<g;J++){let re=g>1?O*(c-1)+J*j:.5*(O+S)*(c-1);if(re<0||re>c-1){for(let be=0;be<h;be++){let ve=be+J*k[2]+q*k[1]+T*k[0];y.values[ve]=d}continue}let Y=Math.floor(re),se=Math.ceil(re),de=re-Y;for(let be=0;be<h;be++){let ve=be+Y*v[2]+X*v[1]+P*v[0],ke=b[ve];ve=be+se*v[2]+X*v[1]+P*v[0];let Ee=b[ve];ve=be+Y*v[2]+Z*v[1]+P*v[0];let _e=b[ve];ve=be+se*v[2]+Z*v[1]+P*v[0];let We=b[ve],Ue=ke+(Ee-ke)*de,Xe=_e+(We-_e)*de;ve=be+J*k[2]+q*k[1]+T*k[0],y.values[ve]=Ue+(Xe-Ue)*te}}}else for(let X=0;X<g;++X){let Z=g>1?O*(c-1)+X*j:.5*(O+S)*(c-1);if(Z<0||Z>c-1){for(let re=0;re<h;re++){let Y=re+X*k[2]+q*k[1]+T*k[0];y.values[Y]=d}continue}let te=Math.round(Z),J=Math.round(z);for(let re=0;re<h;re++){let Y=re+te*v[2]+J*v[1]+P*v[0],se=re+X*k[2]+q*k[1]+T*k[0];y.values[se]=b[Y]}}}}return n.makeTensorInfo(y.shape,y.dtype,y.values)}var tG={kernelName:ol,backendName:"cpu",kernelFunc:eG};function nG(e){let{inputs:t,backend:n,attrs:a}=e,{x:r}=t,{axis:s,exclusive:i,reverse:o}=a;Te(r,"cumsum");let l=E.getAxesPermutation([s],r.shape.length),d=r;l!=null&&(d=Ta({inputs:{x:r},backend:n,attrs:{perm:l}}));let u=E.getInnerMostAxes(1,r.shape.length)[0];if(u!==d.shape.length-1)throw new Error(`backend.cumsum in CPU expects an inner-most axis=${d.shape.length-1} but got axis=${u}`);let p=Pa(d.dtype,"int32"),c=w.makeZerosTypedArray(w.sizeFromShape(d.shape),p),h=n.data.get(d.dataId).values,f=d.shape[d.shape.length-1],m=o?(y,A)=>y+f-A-1:(y,A)=>y+A;for(let y=0;y<h.length;y+=f)for(let A=0;A<f;A++){let x=m(y,A);if(A===0)c[x]=i?0:h[x];else{let b=m(y,A-1);c[x]=i?h[b]+c[b]:h[x]+c[b]}}let g=n.makeTensorInfo(d.shape,p,c);if(l!=null){let y=E.getUndoAxesPermutation(l),A=Ta({inputs:{x:g},backend:n,attrs:{perm:y}});return n.disposeIntermediateTensorInfo(g),n.disposeIntermediateTensorInfo(d),A}return g}var aG={kernelName:ii,backendName:"cpu",kernelFunc:nG};function rG(e){let{inputs:t,backend:n,attrs:a}=e,{x:r,weights:s}=t,{size:i,binaryOutput:o}=a;if(r.shape.length===1){let l=n.data.get(r.dataId).values,d=n.data.get(s.dataId).values,u=g2(l,d,s.dtype,s.shape,i);return n.makeTensorInfo([i],s.dtype,u)}else if(r.shape.length===2){let l=n.bufferSync(r),d=n.bufferSync(s),u=Kw(l,d,i,o);return n.makeTensorInfo(u.shape,s.dtype,u.values)}throw new Error(`Error in denseBincount: input must be at most rank 2, but got rank${r.shape.length}.`)}var sG={kernelName:Xc,backendName:"cpu",kernelFunc:rG};function iG(e){let{inputs:t,backend:n,attrs:a}=e,{x:r}=t,{blockSize:s,dataFormat:i}=a;w.assert(i==="NHWC",()=>`Only NHWC dataFormat supported on CPU for depthToSpace. Got ${i}`);let o=r.shape[0],l=r.shape[1],d=r.shape[2],u=r.shape[3],p=l*s,c=d*s,h=u/(s*s),f=n.data.get(r.dataId).values,m=new Float32Array(o*p*c*h),g=0;for(let y=0;y<o;++y)for(let A=0;A<p;++A){let x=Math.floor(A/s),b=A%s;for(let v=0;v<c;++v){let k=Math.floor(v/s),T=v%s,C=(b*s+T)*h;for(let D=0;D<h;++D){let O=D+C+u*(k+d*(x+l*y));m[g++]=f[O]}}}return n.makeTensorInfo([o,p,c,h],r.dtype,m)}var oG={kernelName:ll,backendName:"cpu",kernelFunc:iG};function W6(e){let{inputs:t,backend:n,attrs:a}=e,{x:r,filter:s}=t,{strides:i,pad:o,dilations:l,dimRoundingMode:d}=a;Te([r,s],"depthwiseConv2DNative");let u=w.computeStrides(r.shape),p=w.computeStrides(s.shape),c=l;c==null&&(c=[1,1]),w.assert(E.eitherStridesOrDilationsAreOne(i,c),()=>`Error in depthwiseConv2d: Either strides or dilations must be 1. Got strides ${i} and dilations '${c}'`);let h=E.computeConv2DInfo(r.shape,s.shape,i,c,o,d,!0),{filterHeight:f,filterWidth:m,dilationHeight:g,dilationWidth:y,padInfo:A}=h,x=A.left,b=A.top,v=h.outChannels/h.inChannels,k=new Jt(h.outShape,r.dtype),T=n.data.get(r.dataId).values,C=n.data.get(s.dataId).values,D=k.values;for(let O=0;O<h.batchSize;++O){let F=O*u[0],S=O*k.strides[0];for(let P=0;P<h.outHeight;++P){let _=S+P*k.strides[1],j=P*h.strideHeight-b;for(let q=0;q<f;++q){let z=j+q*g;if(z<0||z>=h.inHeight)continue;let X=q*p[0],Z=F+z*u[1];for(let te=0;te<h.outWidth;++te){let J=_+te*k.strides[2],re=te*h.strideWidth-x;for(let Y=0;Y<m;++Y){let se=re+Y*y;if(se<0||se>=h.inWidth)continue;let de=X+Y*p[1],be=Z+se*h.inChannels,ve=J,ke=de;for(let Ee=0;Ee<h.inChannels;++Ee){let _e=T[be+Ee];for(let We=0;We<v;++We)D[ve+We]+=_e*C[ke+We];ve+=v,ke+=v}}}}}}return n.makeTensorInfo(k.shape,k.dtype,k.values)}var lG={kernelName:oi,backendName:"cpu",kernelFunc:W6};function uG(e){let{inputs:t,backend:n,attrs:a}=e,{x:r,dy:s}=t,{strides:i,dilations:o,pad:l,dimRoundingMode:d,filterShape:u}=a;Te([r,s],"depthwiseConv2dNativeBackpropFilter");let p=E.computeConv2DInfo(r.shape,u,i,o,l,d,!0),{strideHeight:c,strideWidth:h,filterHeight:f,filterWidth:m}=p,g=new Jt(p.filterShape,"float32"),y=p.padInfo.left,A=p.padInfo.top,x=p.outChannels/p.inChannels,b=n.data.get(r.dataId).values,v=new Jt(r.shape,r.dtype,b),k=n.data.get(s.dataId).values,T=new Jt(s.shape,s.dtype,k);for(let C=0;C<f;++C){let D=Math.max(0,Math.ceil((A-C)/c)),O=Math.min(p.outHeight,(p.inHeight+A-C)/c);for(let F=0;F<m;++F){let S=Math.max(0,Math.ceil((y-F)/h)),P=Math.min(p.outWidth,(p.inWidth+y-F)/h);for(let _=0;_<p.outChannels;++_){let j=Math.trunc(_/x),q=_%x,z=0;for(let X=0;X<p.batchSize;++X)for(let Z=D;Z<O;++Z){let te=C+Z*c-A;for(let J=S;J<P;++J){let re=F+J*h-y;z+=v.get(X,te,re,j)*T.get(X,Z,J,_)}}g.set(z,C,F,j,q)}}}return n.makeTensorInfo(g.shape,g.dtype,g.values)}var dG={kernelName:Kc,backendName:"cpu",kernelFunc:uG};function pG(e){let{inputs:t,backend:n,attrs:a}=e,{dy:r,filter:s}=t,{strides:i,dilations:o,pad:l,dimRoundingMode:d,inputShape:u}=a;Te([r,s],"depthwiseConv2DNativeBackpropInput");let p=w.computeStrides(r.shape),c=w.computeStrides(s.shape),h=E.computeConv2DInfo(u,s.shape,i,o,l,d,!0),f=new Jt(h.inShape,"float32"),m=f.values,[g,y,A]=f.strides,x=n.data.get(r.dataId).values,[b,v,k]=p,T=n.data.get(s.dataId).values,[C,D,O]=c,{batchSize:F,filterHeight:S,filterWidth:P,inChannels:_,inHeight:j,inWidth:q,outChannels:z,outHeight:X,outWidth:Z,strideHeight:te,strideWidth:J}=h,re=S-1-h.padInfo.top,Y=P-1-h.padInfo.left,se=z/_;for(let de=0;de<F;++de)for(let be=0;be<_;++be)for(let ve=0;ve<j;++ve){let ke=ve-re,Ee=Math.max(0,Math.ceil(ke/te)),_e=Math.min(X,(S+ke)/te);for(let We=0;We<q;++We){let Ue=We-Y,Xe=Math.max(0,Math.ceil(Ue/J)),ut=Math.min(Z,(P+Ue)/J),dt=0;for(let at=Ee;at<_e;++at){let xt=at*te-ke;for(let ft=Xe;ft<ut;++ft){let It=ft*J-Ue,Mt=b*de+v*at+k*ft,aa=C*(S-1-xt)+D*(P-1-It)+O*be;for(let gn=0;gn<se;++gn){let ra=be*se+gn,xa=x[Mt+ra],Bn=T[aa+gn];dt+=xa*Bn}}}m[g*de+y*ve+A*We+be]=dt}}return n.makeTensorInfo(f.shape,f.dtype,f.values)}var cG={kernelName:Zc,backendName:"cpu",kernelFunc:pG};function hG(e){let{inputs:t,backend:n}=e,{x:a}=t,r=w.sizeFromShape(a.shape),s=n.data.get(a.dataId).values,i=Ge([r,r],a.dtype),o=i.values;for(let d=0;d<s.length;d++)o[d*r+d]=s[d];let l=[...a.shape,...a.shape];return n.makeTensorInfo(l,i.dtype,i.values)}var fG={kernelName:Yc,backendName:"cpu",kernelFunc:hG},mG={kernelName:vd,backendName:"cpu",kernelFunc:({inputs:e,backend:t,attrs:n})=>{let{x:a,filter:r}=e,{strides:s,pad:i,dilations:o}=n,l=t,d=l.data.get(a.dataId).values,u=a.shape.length,p=l.data.get(r.dataId).values,c=r.shape.length,{batchSize:h,inHeight:f,inWidth:m,inChannels:g,outHeight:y,outWidth:A,padInfo:x,strideHeight:b,strideWidth:v,filterHeight:k,filterWidth:T,dilationHeight:C,dilationWidth:D,outShape:O}=E.computeDilation2DInfo(a.shape,r.shape,s,i,"NHWC",o),F=w.sizeFromShape(O),S=O.length,P=w.getArrayFromDType(a.dtype,F);for(let _=0;_<h;++_)for(let j=0;j<y;++j){let q=j*b-x.top;for(let z=0;z<A;++z){let X=z*v-x.left;for(let Z=0;Z<g;++Z){let te=Number.MIN_SAFE_INTEGER;for(let re=0;re<k;++re){let Y=q+re*C;if(Y>=0&&Y<f)for(let se=0;se<T;++se){let de=X+se*D;if(de>=0&&de<m){let be=w.locToIndex([_,Y,de,Z],u,w.computeStrides(a.shape)),ve=w.locToIndex([re,se,Z],c,w.computeStrides(r.shape)),ke=d[be]+p[ve];ke>te&&(te=ke)}}}let J=w.locToIndex([_,j,z,Z],S,w.computeStrides(O));P[J]=te}}}return{dataId:l.write(w.toTypedArray(P,a.dtype),O,a.dtype),shape:O,dtype:a.dtype}}},gG={kernelName:Qc,backendName:"cpu",kernelFunc:({inputs:e,backend:t,attrs:n})=>{let{x:a,filter:r,dy:s}=e,{strides:i,pad:o,dilations:l}=n,d=t,u=w.toNestedArray(a.shape,d.data.get(a.dataId).values),p=w.toNestedArray(r.shape,d.data.get(r.dataId).values),{batchSize:c,inHeight:h,inWidth:f,inChannels:m,outHeight:g,outWidth:y,padInfo:A,strideHeight:x,strideWidth:b,filterHeight:v,filterWidth:k,dilationHeight:T,dilationWidth:C,outShape:D}=E.computeDilation2DInfo(a.shape,r.shape,i,o,"NHWC",l);w.assert(s.rank===D.length,()=>`Error in ${Qc}, dy must have the same rank as output ${D.length}, but got ${s.rank}`);let O=w.toNestedArray(D,d.data.get(s.dataId).values),F=w.makeZerosNestedTypedArray(r.shape,r.dtype);for(let S=0;S<c;++S)for(let P=0;P<g;++P){let _=P*x-A.top;for(let j=0;j<y;++j){let q=j*b-A.left;for(let z=0;z<m;++z){let X=Number.MIN_SAFE_INTEGER,Z=0,te=0;for(let J=0;J<v;++J){let re=_+J*T;if(re>=0&&re<h)for(let Y=0;Y<k;++Y){let se=q+Y*C;if(se>=0&&se<f){let de=u[S][re][se][z]+p[J][Y][z];de>X&&(X=de,Z=J,te=Y)}}}F[Z][te][z]+=O[S][P][j][z]}}}return{dataId:d.write(w.toTypedArray(F,a.dtype),r.shape,r.dtype),shape:r.shape,dtype:r.dtype}}},yG={kernelName:Jc,backendName:"cpu",kernelFunc:({inputs:e,backend:t,attrs:n})=>{let{x:a,filter:r,dy:s}=e,{strides:i,pad:o,dilations:l}=n,d=t,u=w.toNestedArray(a.shape,d.data.get(a.dataId).values),p=w.toNestedArray(r.shape,d.data.get(r.dataId).values),{batchSize:c,inHeight:h,inWidth:f,inChannels:m,outHeight:g,outWidth:y,padInfo:A,strideHeight:x,strideWidth:b,filterHeight:v,filterWidth:k,dilationHeight:T,dilationWidth:C,outShape:D}=E.computeDilation2DInfo(a.shape,r.shape,i,o,"NHWC",l);w.assert(s.rank===D.length,()=>`Error in ${Jc}, dy must have the same rank as output ${D.length}, but got ${s.rank}`);let O=w.toNestedArray(D,d.data.get(s.dataId).values),F=w.makeZerosNestedTypedArray(a.shape,a.dtype);for(let S=0;S<c;++S)for(let P=0;P<g;++P){let _=P*x-A.top;for(let j=0;j<y;++j){let q=j*b-A.left;for(let z=0;z<m;++z){let X=Number.MIN_SAFE_INTEGER,Z=_<0?0:_,te=q<0?0:q;for(let J=0;J<v;++J){let re=_+J*T;if(re>=0&&re<h)for(let Y=0;Y<k;++Y){let se=q+Y*C;if(se>=0&&se<f){let de=u[S][re][se][z]+p[J][Y][z];de>X&&(X=de,Z=re,te=se)}}}F[S][Z][te][z]+=O[S][P][j][z]}}}return{dataId:d.write(w.toTypedArray(F,a.dtype),a.shape,a.dtype),shape:a.shape,dtype:a.dtype}}};function Mp(e){let{inputs:t,backend:n,attrs:a}=e,{x:r}=t,{axis:s,keepDims:i}=a;Te(r,"sum");let o;r.dtype==="bool"?o=Rs({inputs:{x:r},backend:n,attrs:{dtype:"int32"}}):o=Sr({inputs:{x:r},backend:n});let l=o.shape.length,d=w.parseAxisParam(s,o.shape),u=E.getAxesPermutation(d,l),p=d,c=o;u!=null&&(c=Ta({inputs:{x:o},backend:n,attrs:{perm:u}}),p=E.getInnerMostAxes(p.length,l)),E.assertAxesAreInnerMostDims("sum",p,c.shape.length);let[h,f]=E.computeOutAndReduceShapes(c.shape,p),m=E.upcastType(c.dtype,"int32"),g=nf(n,h,m),y=w.sizeFromShape(f),A=n.data.get(g.dataId).values,x=n.data.get(c.dataId).values;for(let b=0;b<A.length;++b){let v=b*y,k=0;for(let T=0;T<y;++T)k+=x[v+T];A[b]=k}if(i){let b=E.expandShapeToKeepDim(g.shape,d),v=g;g=wt({inputs:{x:g},backend:n,attrs:{shape:b}}),n.disposeIntermediateTensorInfo(v)}return n.disposeIntermediateTensorInfo(o),u!=null&&n.disposeIntermediateTensorInfo(c),g}var AG={kernelName:Li,backendName:"cpu",kernelFunc:Mp};function xG(e){let{inputs:t,backend:n,attrs:a}=e,{equation:r}=a,s=t,{allDims:i,summedDims:o,idDims:l}=E.decodeEinsumEquation(r,s.length);E.checkEinsumDimSizes(i.length,l,s);let{path:d,steps:u}=E.getEinsumComputePath(o,l),p=u.length,c=null,h=i.length,f=[];for(let m=0;m<p;++m){for(let g of u[m]){let{permutationIndices:y,expandDims:A}=E.getEinsumPermutation(h,l[g]),x;E.isIdentityPermutation(y)?x=s[g]:(x=Ta({inputs:{x:s[g]},backend:n,attrs:{perm:y}}),f.push(x));let b=x.shape.slice();for(let v=0;v<A.length;++v)b.splice(A[v],0,1);w.arraysEqual(x.shape,b)||(x=wt({inputs:{x},backend:n,attrs:{shape:b}}),f.push(x)),c===null?c=x:(c=af({inputs:{a:x,b:c},backend:n}),f.push(c))}m<p-1&&(d[m]>=0&&(c=Mp({inputs:{x:c},backend:n,attrs:{axis:d[m]-(i.length-h),keepDims:!1}}),f.push(c)),h--)}for(let m of f)m!==c&&n.disposeIntermediateTensorInfo(m);return c}var bG={kernelName:eh,backendName:"cpu",kernelFunc:xG};function vG(e){let{inputs:t,backend:n}=e,{dy:a,y:r}=t;Te([a,r],"eluGrad");let s=new Float32Array(w.sizeFromShape(r.shape)),i=n.data.get(r.dataId).values,o=n.data.get(a.dataId).values;for(let l=0;l<i.length;++l){let d=i[l];d>=1?s[l]=o[l]:s[l]=o[l]*(d+1)}return n.makeTensorInfo(r.shape,"float32",s)}var wG={kernelName:th,backendName:"cpu",kernelFunc:vG},kG=E.ERF_P,IG=E.ERF_A1,SG=E.ERF_A2,NG=E.ERF_A3,TG=E.ERF_A4,CG=E.ERF_A5,EG=ct(ul,e=>{let t=Math.sign(e),n=Math.abs(e),a=1/(1+kG*n);return t*(1-((((CG*a+TG)*a+NG)*a+SG)*a+IG)*a*Math.exp(-n*n))}),RG={kernelName:ul,backendName:"cpu",kernelFunc:EG};function sf(e){let{inputs:t,backend:n,attrs:a}=e,{input:r}=t,{dim:s}=a,i=r.shape.length,o=r.shape.slice(),l=s;return s<0&&(w.assert(-(i+1)<=s,()=>`Axis must be in the interval [${-(i+1)}, ${i}]`),l=i+s+1),o.splice(l,0,1),wt({inputs:{x:r},backend:n,attrs:{shape:o}})}var MG={kernelName:pl,backendName:"cpu",kernelFunc:sf},FG=Xt((e,t)=>e/t),S2=mn(li,FG),N2={kernelName:li,backendName:"cpu",kernelFunc:S2};function B6(e,t,n){let a=e.shape,r=a[0],s=a[1],i=n.data.get(e.dataId),o=i.complexTensorInfos.real,l=i.complexTensorInfos.imag,d=[r,s],u=w.sizeFromShape(d),p=w.getTypedArrayFromDType("float32",u),c=w.getTypedArrayFromDType("float32",u);for(let g=0;g<r;g++){let y=wo({inputs:{x:o},backend:n,attrs:{begin:[g,0],size:[1,s]}}),A=wo({inputs:{x:l},backend:n,attrs:{begin:[g,0],size:[1,s]}}),x=fa({inputs:{real:y,imag:A},backend:n}),{real:b,imag:v}=DG(x,t,n),k=E.mergeRealAndImagArrays(b,v);for(let T=0;T<s;T++){let C=E.getComplexWithIndex(k,T);p[g*s+T]=C.real,c[g*s+T]=C.imag}n.disposeIntermediateTensorInfo(y),n.disposeIntermediateTensorInfo(A),n.disposeIntermediateTensorInfo(x)}let h=n.makeTensorInfo(d,"float32",p),f=n.makeTensorInfo(d,"float32",c),m=fa({inputs:{real:h,imag:f},backend:n});return n.disposeIntermediateTensorInfo(h),n.disposeIntermediateTensorInfo(f),m}function DG(e,t,n){let a=w.sizeFromShape(e.shape),r=n.data.get(e.dataId),s=n.data.get(r.complexTensorInfos.real.dataId).values,i=n.data.get(r.complexTensorInfos.imag.dataId).values;if($G(a)){let o=T2(s,i,a,t,n),l=[e.shape[0],e.shape[1]];if(t){let d=n.makeTensorInfo(l,"float32",o.real),u=n.makeTensorInfo(l,"float32",o.imag),p=n.makeTensorInfo([],"float32",w.createScalarValue(a,"float32")),c=Sr({inputs:{x:p},backend:n}),h=N2.kernelFunc({inputs:{a:d,b:p},backend:n}),f=N2.kernelFunc({inputs:{a:u,b:c},backend:n}),m=n.data.get(h.dataId).values,g=n.data.get(f.dataId).values;return n.disposeIntermediateTensorInfo(d),n.disposeIntermediateTensorInfo(u),n.disposeIntermediateTensorInfo(p),n.disposeIntermediateTensorInfo(c),n.disposeIntermediateTensorInfo(h),n.disposeIntermediateTensorInfo(f),{real:m,imag:g}}return o}else{let o=E.mergeRealAndImagArrays(s,i),l=OG(o,a,t);return E.splitRealAndImagArrays(l)}}function $G(e){return(e&e-1)==0}function T2(e,t,n,a,r){if(n===1)return{real:e,imag:t};let s=E.mergeRealAndImagArrays(e,t),i=n/2,o=E.complexWithEvenIndex(s),l=o.real,d=o.imag,u=[l.length],p=r.makeTensorInfo(u,"float32",l),c=r.makeTensorInfo(u,"float32",d),h=fa({inputs:{real:p,imag:c},backend:r}),f=E.complexWithOddIndex(s),m=f.real,g=f.imag,y=[m.length],A=r.makeTensorInfo(y,"float32",m),x=r.makeTensorInfo(y,"float32",g),b=fa({inputs:{real:A,imag:x},backend:r}),v=T2(l,d,i,a,r),k=v.real,T=v.imag,C=[k.length],D=r.makeTensorInfo(C,"float32",k),O=r.makeTensorInfo(C,"float32",T),F=fa({inputs:{real:D,imag:O},backend:r}),S=T2(m,g,i,a,r),P=S.real,_=S.imag,j=[P.length],q=r.makeTensorInfo(j,"float32",P),z=r.makeTensorInfo(j,"float32",_),X=fa({inputs:{real:q,imag:z},backend:r}),Z=E.exponents(n,a),te=[Z.real.length],J=r.makeTensorInfo(te,"float32",Z.real),re=r.makeTensorInfo(te,"float32",Z.imag),Y=fa({inputs:{real:J,imag:re},backend:r}),se=af({inputs:{a:Y,b:X},backend:r}),de=Ep({inputs:{a:F,b:se},backend:r}),be=w2({inputs:{a:F,b:se},backend:r}),ve=vo({inputs:{input:de},backend:r}),ke=vo({inputs:{input:be},backend:r}),Ee=Cu({inputs:{input:de},backend:r}),_e=Cu({inputs:{input:be},backend:r}),We=Eu({inputs:[ve,ke],backend:r,attrs:{axis:0}}),Ue=Eu({inputs:[Ee,_e],backend:r,attrs:{axis:0}}),Xe=r.data.get(We.dataId).values,ut=r.data.get(Ue.dataId).values;return r.disposeIntermediateTensorInfo(p),r.disposeIntermediateTensorInfo(c),r.disposeIntermediateTensorInfo(h),r.disposeIntermediateTensorInfo(A),r.disposeIntermediateTensorInfo(x),r.disposeIntermediateTensorInfo(b),r.disposeIntermediateTensorInfo(D),r.disposeIntermediateTensorInfo(O),r.disposeIntermediateTensorInfo(F),r.disposeIntermediateTensorInfo(q),r.disposeIntermediateTensorInfo(z),r.disposeIntermediateTensorInfo(X),r.disposeIntermediateTensorInfo(J),r.disposeIntermediateTensorInfo(re),r.disposeIntermediateTensorInfo(Y),r.disposeIntermediateTensorInfo(se),r.disposeIntermediateTensorInfo(de),r.disposeIntermediateTensorInfo(be),r.disposeIntermediateTensorInfo(ve),r.disposeIntermediateTensorInfo(Ee),r.disposeIntermediateTensorInfo(ke),r.disposeIntermediateTensorInfo(_e),r.disposeIntermediateTensorInfo(We),r.disposeIntermediateTensorInfo(Ue),{real:Xe,imag:ut}}function OG(e,t,n){let a=new Float32Array(t*2);for(let r=0;r<t;r++){let s=0,i=0;for(let o=0;o<t;o++){let l=E.exponent(r*o,t,n),d=E.getComplexWithIndex(e,o);s+=d.real*l.real-d.imag*l.imag,i+=d.real*l.imag+d.imag*l.real}n&&(s/=t,i/=t),E.assignToTypedArray(a,s,i,r)}return a}function _G(e){let{inputs:t,backend:n}=e,{input:a}=t,r=w.sizeFromShape(a.shape),s=a.shape[a.shape.length-1],i=r/s,o=wt({inputs:{x:a},backend:n,attrs:{shape:[i,s]}}),l=B6(o,!1,n),d=wt({inputs:{x:l},backend:n,attrs:{shape:a.shape}});return n.disposeIntermediateTensorInfo(o),n.disposeIntermediateTensorInfo(l),d}var PG={kernelName:nh,backendName:"cpu",kernelFunc:_G};function C2(e){let{backend:t,attrs:n}=e,{shape:a,value:r,dtype:s}=n,i=s||w.inferDtype(r),o=w.getArrayFromDType(i,w.sizeFromShape(a));return LG(o,r,i),t.makeTensorInfo(a,i,o)}var zG={kernelName:wd,backendName:"cpu",kernelFunc:C2};function LG(e,t,n){e.fill(t)}var WG={kernelName:hl,backendName:"cpu",kernelFunc:({inputs:e,attrs:t,backend:n})=>{let{image:a}=e,r=n,s=w.getTypedArrayFromDType(a.dtype,w.sizeFromShape(a.shape)),[i,o,l,d]=a.shape,u=r.data.get(a.dataId).values;for(let p=0;p<i;p++){let c=p*l*o*d;for(let h=0;h<o;h++){let f=h*(l*d);for(let m=0;m<l;m++){let g=m*d;for(let y=0;y<d;y++){let A=Math.round(l-m-1),x=c+f+g+y,b=u[x];if(A>=0&&A<l){let v=A*d,k=c+f+v+y;b=u[k]}s[x]=b}}}}return{dataId:r.write(s,a.shape,a.dtype),shape:a.shape,dtype:a.dtype}}},BG=Xt((e,t)=>Math.floor(e/t)),VG=mn(ci,BG,null,"int32"),UG={kernelName:ci,backendName:"cpu",kernelFunc:VG};function jG(e){let{inputs:t,backend:n,attrs:a}=e,{x:r,filter:s,bias:i,preluActivationWeights:o}=t,{strides:l,pad:d,dataFormat:u,dilations:p,dimRoundingMode:c,activation:h,leakyreluAlpha:f}=a,m=L6({inputs:{x:r,filter:s},backend:n,attrs:{strides:l,pad:d,dataFormat:u,dilations:p,dimRoundingMode:c}});if(i){let g=m;m=Ep({inputs:{a:m,b:i},backend:n}),n.disposeIntermediateTensorInfo(g)}if(h){let g=m;m=k2(n,m,h,o,f),n.disposeIntermediateTensorInfo(g)}return m}var GG={kernelName:qi,backendName:"cpu",kernelFunc:jG};function HG(e){let{inputs:t,backend:n,attrs:a}=e,{x:r,filter:s,bias:i,preluActivationWeights:o}=t,{strides:l,pad:d,dataFormat:u,dilations:p,dimRoundingMode:c,activation:h,leakyreluAlpha:f}=a,m=W6({inputs:{x:r,filter:s},backend:n,attrs:{strides:l,pad:d,dataFormat:u,dilations:p,dimRoundingMode:c}});if(i){let g=m;m=Ep({inputs:{a:m,b:i},backend:n}),n.disposeIntermediateTensorInfo(g)}if(h){let g=m;m=k2(n,m,h,o,f),n.disposeIntermediateTensorInfo(g)}return m}var qG={kernelName:Xi,backendName:"cpu",kernelFunc:HG};function XG(e){let{inputs:t,backend:n}=e,{params:a,indices:r}=t,s=w.sizeFromShape(a.shape),i=r.shape,o=i[i.length-1],[l,d,u,p]=E.prepareAndValidate(a,r);if(d===0)return n.makeTensorInfo(l,a.dtype,[]);let c=n.data.get(r.dataId).values,h=n.bufferSync(a),f=a6(c,h,a.dtype,d,o,u,p,a.shape,s);return n.makeTensorInfo(l,a.dtype,f.values)}var KG={kernelName:ml,backendName:"cpu",kernelFunc:XG};function ZG(e){let{inputs:t,backend:n,attrs:a}=e,{x:r,indices:s}=t,{axis:i,batchDims:o}=a;Te([r,s],"gatherV2");let l=w.parseAxisParam(i,r.shape)[0],d=n.data.get(s.dataId).values,u=r.shape[l];for(let b=0;b<d.length;++b){let v=d[b];w.assert(v<=u-1&&v>=0,()=>`GatherV2: the index value ${v} is not in [0, ${u-1}]`)}let p=o;o==null&&(p=0);let c=w.sizeFromShape(s.shape),h=E.segment_util.collectGatherOpShapeInfo(r,s,l,p),f=wt({inputs:{x:r},backend:n,attrs:{shape:[h.batchSize,h.outerSize,h.dimSize,h.sliceSize]}}),m=wt({inputs:{x:s},backend:n,attrs:{shape:[h.batchSize,c/h.batchSize]}}),g=[h.batchSize,h.outerSize,c/h.batchSize,h.sliceSize],y=n.bufferSync(m),A=n.bufferSync(f),x=r6(A,y,g);return n.disposeIntermediateTensorInfo(f),n.disposeIntermediateTensorInfo(m),n.makeTensorInfo(h.outputShape,x.dtype,x.values)}var YG={kernelName:fl,backendName:"cpu",kernelFunc:ZG};function JG(e){let{inputs:t,backend:n}=e,{input:a}=t,r=w.sizeFromShape(a.shape),s=a.shape[a.shape.length-1],i=r/s,o=wt({inputs:{x:a},backend:n,attrs:{shape:[i,s]}}),l=B6(o,!0,n),d=wt({inputs:{x:l},backend:n,attrs:{shape:a.shape}});return n.disposeIntermediateTensorInfo(o),n.disposeIntermediateTensorInfo(l),d}var QG={kernelName:ah,backendName:"cpu",kernelFunc:JG},eH=ct(yl,e=>Number.isFinite(e)?1:0,"bool"),tH={kernelName:yl,backendName:"cpu",kernelFunc:eH},nH=ct(Al,e=>Math.abs(e)===1/0?1:0,"bool"),aH={kernelName:Al,backendName:"cpu",kernelFunc:nH},rH=ct(xl,e=>Number.isNaN(e)?1:0,"bool"),sH={kernelName:xl,backendName:"cpu",kernelFunc:rH};function iH(e){let{backend:t,attrs:n}=e,{start:a,stop:r,num:s}=n,i=u6(a,r,s);return t.makeTensorInfo([i.length],"float32",i)}var oH={kernelName:sh,backendName:"cpu",kernelFunc:iH},lH=ct(wl,e=>Math.log1p(e)),uH={kernelName:wl,backendName:"cpu",kernelFunc:lH},dH=Xt((e,t)=>e&&t),pH=mn(kl,dH,null,"bool"),cH={kernelName:kl,backendName:"cpu",kernelFunc:pH},hH=ct(kd,e=>e?0:1,"bool"),fH={kernelName:kd,backendName:"cpu",kernelFunc:hH},mH=Xt((e,t)=>e||t),gH=mn(Id,mH,null,"bool"),yH={kernelName:Id,backendName:"cpu",kernelFunc:gH};function AH(e){let{inputs:t,backend:n,attrs:a}=e,{x:r}=t,{depthRadius:s,bias:i,alpha:o,beta:l}=a;Te(r,"LRN");let d=r.shape[3],u=d-1,p=n.data.get(r.dataId).values,c=w.sizeFromShape(r.shape),h=new Float32Array(c);function f(m){let g=m%d,y=m-g+Math.max(0,g-s),A=m-g+Math.min(g+s,u),x=0;for(;y<=A;y++){let b=p[y];x+=b*b}return x}for(let m=0;m<c;m++){let g=f(m),y=p[m]*Math.pow(i+o*g,-l);h[m]=y}return n.makeTensorInfo(r.shape,r.dtype,h)}var xH={kernelName:Sd,backendName:"cpu",kernelFunc:AH};function bH(e){let{inputs:t,backend:n,attrs:a}=e,{x:r,y:s,dy:i}=t,{depthRadius:o,bias:l,alpha:d,beta:u}=a;Te(i,"LRNGrad");let p=w.sizeFromShape(i.shape),c=i.shape[3],h=n.data.get(i.dataId).values,f=n.data.get(r.dataId).values,m=n.data.get(s.dataId).values,g=new Float32Array(p),y=p;for(let A=0;A<y;A++){let x=A%c,b=A-x+Math.max(0,x-o),v=A-x+Math.min(c,x+o+1),k=0;for(let T=b;T<v;T++)k+=Math.pow(f[T],2);k=d*k+l;for(let T=b;T<v;T++){let C=-2*d*u*f[T]*m[A]/k;A===T&&(C+=Math.pow(k,-u)),C*=h[A],g[T]+=C}}return n.makeTensorInfo(i.shape,r.dtype,g)}var vH={kernelName:ih,backendName:"cpu",kernelFunc:bH};function V6(e){let{inputs:t,backend:n,attrs:a}=e,{x:r}=t,{reductionIndices:s,keepDims:i}=a,o=n,l=r.shape,d=l.length,u=w.parseAxisParam(s,l),p=u,c=E.getAxesPermutation(p,d),h=o.data.get(r.dataId).values;if(c!=null){let b=new Array(d);for(let v=0;v<b.length;v++)b[v]=l[c[v]];h=x2(h,l,r.dtype,c,b),p=E.getInnerMostAxes(p.length,d),l=b}Te(r,"max"),E.assertAxesAreInnerMostDims("max",p,d);let[f,m]=E.computeOutAndReduceShapes(l,p),g=w.sizeFromShape(m),y=p6(h,g,f,r.dtype),A=o.write(y,f,r.dtype),x=f;return i&&(x=E.expandShapeToKeepDim(f,u)),{dataId:A,shape:x,dtype:r.dtype}}var wH={kernelName:Ai,backendName:"cpu",kernelFunc:V6};function kH(e){let{inputs:t,backend:n,attrs:a}=e,{x:r}=t;Te(r,"maxPool");let{filterSize:s,strides:i,pad:o,dimRoundingMode:l}=a,d=1;w.assert(E.eitherStridesOrDilationsAreOne(i,d),()=>`Error in maxPool: Either strides or dilations must be 1. Got strides ${i} and dilations '${d}'`);let u=E.computePool2DInfo(r.shape,s,i,d,o,l),p;if(u.filterWidth===1&&u.filterHeight===1&&w.arraysEqual(u.inShape,u.outShape))p=Sr({inputs:{x:r},backend:n});else{let c=n.data.get(r.dataId).values,h=w.computeStrides(r.shape),f=I2(c,r.shape,r.dtype,h,u,"max");p=n.makeTensorInfo(u.outShape,r.dtype,f.values)}return p}var IH={kernelName:bi,backendName:"cpu",kernelFunc:kH};function SH(e){let{inputs:t,backend:n,attrs:a}=e,{x:r}=t,{filterSize:s,strides:i,pad:o,dimRoundingMode:l,dataFormat:d}=a;Te(r,"maxPool3d");let u=E.computePool3DInfo(r.shape,s,i,1,o,l,d),p=n.data.get(r.dataId).values,c=z6(p,r.shape,r.dtype,w.computeStrides(r.shape),u,"max");return n.makeTensorInfo(c.shape,"float32",c.values)}var NH={kernelName:Nd,backendName:"cpu",kernelFunc:SH};function TH(e){let{inputs:t,backend:n,attrs:a}=e,{dy:r,input:s}=t,{filterSize:i,strides:o,pad:l,dimRoundingMode:d}=a;Te([r,s],"maxPool3DGrad");let u=E.computePool3DInfo(s.shape,i,o,1,l,d),p=n.bufferSync(s),c=gj(p,u),h=u.strideDepth,f=u.strideHeight,m=u.strideWidth,g=u.dilationDepth,y=u.dilationHeight,A=u.dilationWidth,x=u.effectiveFilterDepth,b=u.effectiveFilterHeight,v=u.effectiveFilterWidth,k=x-1-u.padInfo.front,T=v-1-u.padInfo.left,C=b-1-u.padInfo.top,D=Ge(s.shape,"float32"),O=n.bufferSync(r);for(let F=0;F<u.batchSize;++F)for(let S=0;S<u.inChannels;++S)for(let P=0;P<u.inDepth;++P)for(let _=0;_<u.inHeight;++_)for(let j=0;j<u.inWidth;++j){let q=P-k,z=_-C,X=j-T,Z=0;for(let te=0;te<x;te+=g){let J=(q+te)/h;if(!(J<0||J>=u.outDepth||Math.floor(J)!==J))for(let re=0;re<b;re+=y){let Y=(z+re)/f;if(!(Y<0||Y>=u.outHeight||Math.floor(Y)!==Y))for(let se=0;se<v;se+=A){let de=(X+se)/m;if(de<0||de>=u.outWidth||Math.floor(de)!==de)continue;let be=x*b*v-1-c.get(F,J,Y,de,S),ve=te*b*v+re*v+se,ke=be===ve?1:0;ke!==0&&(Z+=O.get(F,J,Y,de,S)*ke)}}}D.set(Z,F,P,_,j,S)}return n.makeTensorInfo(D.shape,D.dtype,D.values)}var CH={kernelName:lh,backendName:"cpu",kernelFunc:TH};function EH(e){let{inputs:t,backend:n,attrs:a}=e,{dy:r,input:s,output:i}=t,o=s;Te([s,i],"maxPoolGrad");let{filterSize:l,strides:d,pad:u,dimRoundingMode:p}=a,c=E.computePool2DInfo(o.shape,l,d,1,u,p),h=n.data.get(o.dataId).values,f=Ge(c.outShape,o.dtype,P6(h,o.shape,o.dtype,c).values),m=c.strideHeight,g=c.strideWidth,y=c.dilationHeight,A=c.dilationWidth,x=c.effectiveFilterHeight,b=c.effectiveFilterWidth,v=b-1-c.padInfo.left,k=x-1-c.padInfo.top,T=Ge(o.shape,"float32"),C=n.data.get(r.dataId).values,D=Ge(r.shape,"float32",C);for(let O=0;O<c.batchSize;++O)for(let F=0;F<c.inChannels;++F)for(let S=0;S<c.inHeight;++S)for(let P=0;P<c.inWidth;++P){let _=S-k,j=P-v,q=0;for(let z=0;z<x;z+=y){let X=(_+z)/m;if(!(X<0||X>=c.outHeight||Math.floor(X)!==X))for(let Z=0;Z<b;Z+=A){let te=(j+Z)/g;if(te<0||te>=c.outWidth||Math.floor(te)!==te)continue;let J=x*b-1-f.get(O,X,te,F),re=z*b+Z,Y=J===re?1:0;Y!==0&&(q+=D.get(O,X,te,F)*Y)}}T.set(q,O,S,P,F)}return n.makeTensorInfo(T.shape,T.dtype,T.values)}var RH={kernelName:oh,backendName:"cpu",kernelFunc:EH};function MH(e,t,n,a,r){let s=w.computeStrides(t),i=I2(e,t,n,s,r,"max"),o=P6(e,t,n,r,!0,a);return[i.values,o.values]}var FH={kernelName:uh,backendName:"cpu",kernelFunc:({inputs:e,attrs:t,backend:n})=>{let{x:a}=e,{filterSize:r,strides:s,pad:i,includeBatchInIndex:o}=t,l=n;Te(a,"MaxPoolWithArgmax");let d=l.data.get(a.dataId).values,u=E.computePool2DInfo(a.shape,r,s,[1,1],i),[p,c]=MH(d,a.shape,a.dtype,o,u),h=l.write(p,u.outShape,a.dtype),f=l.write(c,u.outShape,a.dtype);return[{dataId:h,shape:u.outShape,dtype:a.dtype},{dataId:f,shape:u.outShape,dtype:"int32"}]}};function DH(e){let{inputs:t,backend:n,attrs:a}=e,{x:r}=t,{axis:s,keepDims:i}=a,o=w.parseAxisParam(s,r.shape),l=E.computeOutAndReduceShapes(r.shape,o)[1],d=w.sizeFromShape(l),u=[],p=n.makeTensorInfo([],"float32",new Float32Array([d]));u.push(p);let c=Rs({inputs:{x:r},backend:n,attrs:{dtype:"float32"}});u.push(c);let h=S2({inputs:{a:c,b:p},backend:n});u.push(h);let f=Mp({inputs:{x:h},backend:n,attrs:{axis:s,keepDims:i}});return u.forEach(m=>n.disposeIntermediateTensorInfo(m)),f}var $H={kernelName:vi,backendName:"cpu",kernelFunc:DH};function OH(e){let{inputs:t,backend:n,attrs:a}=e,{x:r}=t,{axis:s,keepDims:i}=a;Te(r,"min");let o=w.parseAxisParam(s,r.shape),l=o,d=E.getAxesPermutation(l,r.shape.length),u=r;d!=null&&(u=Ta({inputs:{x:r},backend:n,attrs:{perm:d}}),l=E.getInnerMostAxes(l.length,r.shape.length)),E.assertAxesAreInnerMostDims("min",l,u.shape.length);let[p,c]=E.computeOutAndReduceShapes(u.shape,l),h=w.sizeFromShape(c),f=w.makeZerosTypedArray(w.sizeFromShape(p),u.dtype),m=n.data.get(u.dataId).values;for(let y=0;y<f.length;++y){let A=y*h,x=m[A];for(let b=0;b<h;++b){let v=m[A+b];(Number.isNaN(v)||v<x)&&(x=v)}f[y]=x}d!=null&&n.disposeIntermediateTensorInfo(u);let g=n.makeTensorInfo(p,u.dtype,f);if(i){let y=E.expandShapeToKeepDim(p,o),A=wt({inputs:{x:g},backend:n,attrs:{shape:y}});return n.disposeIntermediateTensorInfo(g),A}return g}var _H={kernelName:wi,backendName:"cpu",kernelFunc:OH};function PH(e){let{inputs:t,backend:n,attrs:a}=e,{x:r}=t,{paddings:s,mode:i}=a;Te(r,"mirrorPad");let o=s.map((A,x)=>A[0]+r.shape[x]+A[1]),l=s.map(A=>A[0]),d=s.map((A,x)=>A[0]+r.shape[x]),u=i==="reflect"?0:1,p=n.data.get(r.dataId).values,c=r.shape.length,h=w.computeStrides(r.shape),f=w.sizeFromShape(o),m=o.length,g=w.computeStrides(o),y=w.getTypedArrayFromDType(r.dtype,f);for(let A=0;A<f;A++){let x=w.indexToLoc(A,m,g);for(let v=0;v<m;v++)x[v]<l[v]?x[v]=l[v]*2-x[v]-u:x[v]>=d[v]&&(x[v]=(d[v]-1)*2-x[v]+u);x=x.map((v,k)=>v-l[k]);let b=w.locToIndex(x,c,h);y[A]=p[b]}return{dataId:n.write(y,o,r.dtype),shape:o,dtype:r.dtype}}var zH={kernelName:Ii,backendName:"cpu",kernelFunc:PH},LH=Xt((e,t)=>{let n=e%t;return e<0&&t<0||e>=0&&t>=0?n:(n+t)%t}),WH=mn(Il,LH),BH={kernelName:Il,backendName:"cpu",kernelFunc:WH},VH=qs(z5());function U6(e){let{inputs:t,backend:n,attrs:a}=e,{logits:r}=t,{dim:s}=a,i=r.shape.length,o=s;if(o===-1&&(o=i-1),o!==i-1)throw Error(`Softmax along a non-last dimension is not yet supported. Logits was rank ${i} and dim was ${o}`);let l=w.parseAxisParam([o],r.shape),d=V6({inputs:{x:r},backend:n,attrs:{reductionIndices:l,keepDims:!1}}),u=E.expandShapeToKeepDim(d.shape,l),p=wt({inputs:{x:d},backend:n,attrs:{shape:u}}),c=w2({inputs:{a:r,b:p},backend:n}),h=e6({inputs:{x:c},backend:n}),f=Mp({inputs:{x:h},backend:n,attrs:{axis:l,keepDims:!1}}),m=wt({inputs:{x:f},backend:n,attrs:{shape:u}}),g=S2({inputs:{a:h,b:m},backend:n});return n.disposeIntermediateTensorInfo(d),n.disposeIntermediateTensorInfo(p),n.disposeIntermediateTensorInfo(c),n.disposeIntermediateTensorInfo(h),n.disposeIntermediateTensorInfo(f),n.disposeIntermediateTensorInfo(m),g}var UH={kernelName:Wi,backendName:"cpu",kernelFunc:U6};function jH(e){let{inputs:t,backend:n,attrs:a}=e,{logits:r}=t,{numSamples:s,seed:i,normalized:o}=a;Te(r,"multinomial");let l=o?r:U6({inputs:{logits:r},backend:n,attrs:{dim:-1}}),d=l.shape[0],u=l.shape[1],p=n.data.get(l.dataId).values,c=[d,s],h=w.makeZerosTypedArray(w.sizeFromShape(c),"int32");for(let f=0;f<d;++f){let m=f*u,g=new Float32Array(u-1);g[0]=p[m];for(let x=1;x<g.length;++x)g[x]=g[x-1]+p[m+x];let y=VH.alea(i.toString()),A=f*s;for(let x=0;x<s;++x){let b=y();h[A+x]=g.length;for(let v=0;v<g.length;v++)if(b<g[v]){h[A+x]=v;break}}}return o||n.disposeIntermediateTensorInfo(l),n.makeTensorInfo(c,"int32",h)}var GH={kernelName:dh,backendName:"cpu",kernelFunc:jH},HH=xr.nonMaxSuppressionV3Impl;function qH(e){let{inputs:t,backend:n,attrs:a}=e,{boxes:r,scores:s}=t,{maxOutputSize:i,iouThreshold:o,scoreThreshold:l}=a;Te(r,"NonMaxSuppression");let d=n.data.get(r.dataId).values,u=n.data.get(s.dataId).values,{selectedIndices:p}=HH(d,u,i,o,l);return n.makeTensorInfo([p.length],"int32",new Int32Array(p))}var XH={kernelName:Tl,backendName:"cpu",kernelFunc:qH},KH=xr.nonMaxSuppressionV4Impl;function ZH(e){let{inputs:t,backend:n,attrs:a}=e,{boxes:r,scores:s}=t,{maxOutputSize:i,iouThreshold:o,scoreThreshold:l,padToMaxOutputSize:d}=a;Te(r,"NonMaxSuppressionPadded");let u=n.data.get(r.dataId).values,p=n.data.get(s.dataId).values,{selectedIndices:c,validOutputs:h}=KH(u,p,i,o,l,d);return[n.makeTensorInfo([c.length],"int32",new Int32Array(c)),n.makeTensorInfo([],"int32",new Int32Array([h]))]}var YH={kernelName:Cl,backendName:"cpu",kernelFunc:ZH},JH=xr.nonMaxSuppressionV5Impl;function QH(e){let{inputs:t,backend:n,attrs:a}=e,{boxes:r,scores:s}=t,{maxOutputSize:i,iouThreshold:o,scoreThreshold:l,softNmsSigma:d}=a;Te(r,"NonMaxSuppressionWithScore");let u=n.data.get(r.dataId).values,p=n.data.get(s.dataId).values,c=i,h=o,f=l,m=d,{selectedIndices:g,selectedScores:y}=JH(u,p,c,h,f,m);return[n.makeTensorInfo([g.length],"int32",new Int32Array(g)),n.makeTensorInfo([y.length],"float32",new Float32Array(y))]}var eq={kernelName:El,backendName:"cpu",kernelFunc:QH};function tq(e){let{inputs:t,backend:n,attrs:a}=e,{indices:r}=t,{depth:s,onValue:i,offValue:o}=a;Te(r,"oneHot");let l=w.sizeFromShape(r.shape),d=new Float32Array(l*s);d.fill(o);let u=n.data.get(r.dataId).values;for(let p=0;p<l;++p)u[p]>=0&&u[p]<s&&(d[p*s+u[p]]=i);return n.makeTensorInfo([...r.shape,s],"int32",d)}var nq={kernelName:Ni,backendName:"cpu",kernelFunc:tq};function of(e){let{inputs:t,backend:n}=e,{x:a}=t;if(a.dtype==="string")throw new Error("zerosLike is not supported for string tensors");if(a.dtype==="complex64"){let r=vo({inputs:{input:a},backend:n}),s=of({inputs:{x:r},backend:n}),i=Cu({inputs:{input:a},backend:n}),o=of({inputs:{x:i},backend:n}),l=fa({inputs:{real:s,imag:o},backend:n});return n.disposeIntermediateTensorInfo(r),n.disposeIntermediateTensorInfo(s),n.disposeIntermediateTensorInfo(i),n.disposeIntermediateTensorInfo(o),l}else return C2({backend:n,attrs:{shape:a.shape,value:0,dtype:a.dtype}})}var aq={kernelName:Xl,backendName:"cpu",kernelFunc:of};function j6(e){let{inputs:t,backend:n}=e,{x:a}=t;if(a.dtype==="string")throw new Error("onesLike is not supported for string tensors");if(a.dtype==="complex64"){let r=vo({inputs:{input:a},backend:n}),s=j6({inputs:{x:r},backend:n}),i=Cu({inputs:{input:a},backend:n}),o=of({inputs:{x:i},backend:n}),l=fa({inputs:{real:s,imag:o},backend:n});return n.disposeIntermediateTensorInfo(r),n.disposeIntermediateTensorInfo(s),n.disposeIntermediateTensorInfo(i),n.disposeIntermediateTensorInfo(o),l}else return C2({backend:n,attrs:{shape:a.shape,value:1,dtype:a.dtype}})}var rq={kernelName:Rl,backendName:"cpu",kernelFunc:j6};function G6(e){let{inputs:t,backend:n,attrs:a}=e,{axis:r}=a;if(t.length===1)return sf({inputs:{input:t[0]},backend:n,attrs:{dim:r}});let s=t[0].shape,i=t[0].dtype;t.forEach(u=>{w.assertShapesMatch(s,u.shape,"All tensors passed to stack must have matching shapes"),w.assert(i===u.dtype,()=>"All tensors passed to stack must have matching dtypes")});let o=[],l=t.map(u=>{let p=sf({inputs:{input:u},backend:n,attrs:{dim:r}});return o.push(p),p}),d=Eu({inputs:l,backend:n,attrs:{axis:r}});return o.forEach(u=>n.disposeIntermediateTensorInfo(u)),d}var sq={kernelName:Ml,backendName:"cpu",kernelFunc:G6};function iq(e){let{inputs:t,backend:n,attrs:a}=e,{x:r}=t,{paddings:s,constantValue:i}=a;Te(r,"pad");let o=s.map((y,A)=>y[0]+r.shape[A]+y[1]),l=s.map(y=>y[0]),d=n.data.get(r.dataId).values,u=w.sizeFromShape(r.shape),p=r.shape.length,c=w.computeStrides(r.shape),h=w.sizeFromShape(o),f=o.length,m=w.computeStrides(o),g=w.getTypedArrayFromDType(r.dtype,h);i!==0&&g.fill(i);for(let y=0;y<u;y++){let A=w.indexToLoc(y,p,c).map((b,v)=>b+l[v]),x=w.locToIndex(A,f,m);g[x]=d[y]}return{dataId:n.write(g,o,r.dtype),shape:o,dtype:r.dtype}}var H6={kernelName:Ti,backendName:"cpu",kernelFunc:iq},oq=Xt((e,t)=>Math.pow(e,t)),lq=mn(Ci,oq),uq={kernelName:Ci,backendName:"cpu",kernelFunc:lq};function dq(e){let{backend:t,attrs:n}=e,{start:a,stop:r,dtype:s,step:i}=n,o=b2(a,r,i,s);return t.makeTensorInfo([o.length],s,o)}var pq={kernelName:Td,backendName:"cpu",kernelFunc:dq},cq=ct(Dl,e=>1/e),hq={kernelName:Dl,backendName:"cpu",kernelFunc:cq};function fq(e){let{inputs:t,backend:n,attrs:a}=e,{images:r}=t,{alignCorners:s,halfPixelCenters:i,size:o}=a;Te(r,"resizeBilinear");let l=w.computeStrides(r.shape),[d,u]=o,[p,c,h,f]=r.shape,m=n.data.get(r.dataId).values,g=new Float32Array(w.sizeFromShape([p,d,u,f])),y=[s&&d>1?c-1:c,s&&u>1?h-1:h],A=[s&&d>1?d-1:d,s&&u>1?u-1:u],x=0,b=y[0]/A[0],v=y[1]/A[1];for(let k=0;k<p;k++)for(let T=0;T<d;T++){let C;i?C=b*(T+.5)-.5:C=b*T;let D=Math.max(0,Math.floor(C)),O=C-D,F=Math.min(c-1,Math.ceil(C)),S=k*l[0]+D*l[1],P=k*l[0]+F*l[1];for(let _=0;_<u;_++){let j;i?j=v*(_+.5)-.5:j=v*_;let q=Math.max(0,Math.floor(j)),z=j-q,X=Math.min(h-1,Math.ceil(j)),Z=S+q*l[2],te=P+q*l[2],J=S+X*l[2],re=P+X*l[2];for(let Y=0;Y<f;Y++){let se=m[Z+Y],de=m[te+Y],be=m[J+Y],ve=m[re+Y],ke=se+(be-se)*z,Ee=de+(ve-de)*z,_e=ke+(Ee-ke)*O;g[x++]=_e}}}return n.makeTensorInfo([p,d,u,f],"float32",g)}var mq={kernelName:Mi,backendName:"cpu",kernelFunc:fq};function gq(e){let{inputs:t,backend:n,attrs:a}=e,{images:r,dy:s}=t,{alignCorners:i}=a;Te([s,r],"resizeBilinearGrad");let o=w.computeStrides(r.shape),[l,d,u,p]=r.shape,[,c,h]=s.shape,f=new Float32Array(l*d*u*p),m=[i&&c>1?d-1:d,i&&h>1?u-1:u],g=[i&&c>1?c-1:c,i&&h>1?h-1:h],y=m[0]/g[0],A=m[1]/g[1],x=n.data.get(s.dataId).values,b=0;for(let v=0;v<l;v++){let k=v*o[0];for(let T=0;T<c;T++){let C=T*y,D=Math.floor(C),O=Math.min(Math.ceil(C),d-1),F=k+D*o[1],S=k+O*o[1],P=C-D,_=1-P;for(let j=0;j<h;j++){let q=j*A,z=Math.floor(q),X=Math.min(Math.ceil(q),u-1),Z=q-z,te=1-Z,J=F+z*o[2],re=F+X*o[2],Y=S+z*o[2],se=S+X*o[2],de=_*te,be=_*Z,ve=P*te,ke=P*Z;for(let Ee=0;Ee<p;Ee++){let _e=x[b++];f[J+Ee]+=_e*de,f[re+Ee]+=_e*be,f[Y+Ee]+=_e*ve,f[se+Ee]+=_e*ke}}}}return n.makeTensorInfo([l,u,d,p],"float32",f)}var yq={kernelName:hh,backendName:"cpu",kernelFunc:gq};function Aq(e){let{inputs:t,backend:n,attrs:a}=e,{images:r}=t,{alignCorners:s,halfPixelCenters:i,size:o}=a;Te(r,"resizeNearestNeighbor");let l=w.computeStrides(r.shape),[d,u]=o,[p,c,h,f]=r.shape,m=n.data.get(r.dataId).values,g=new Float32Array(p*d*u*f),y=[s&&d>1?c-1:c,s&&u>1?h-1:h],A=[s&&d>1?d-1:d,s&&u>1?u-1:u],x=y[0]/A[0],b=y[1]/A[1],v=0;for(let k=0;k<p;k++){let T=k*l[0];for(let C=0;C<d;C++){let D=i?x*(C+.5):x*C,O=Math.min(c-1,s?Math.round(D):Math.floor(D));i&&(O=Math.max(0,O));let F=T+O*l[1];for(let S=0;S<u;S++){let P=i?b*(S+.5):b*S,_=Math.min(h-1,s?Math.round(P):Math.floor(P));i&&(_=Math.max(0,_));let j=F+_*l[2];for(let q=0;q<f;q++){let z=m[j+q];g[v++]=z}}}}return n.makeTensorInfo([p,d,u,f],r.dtype,g)}var xq={kernelName:Cd,backendName:"cpu",kernelFunc:Aq};function bq(e){let{inputs:t,backend:n,attrs:a}=e,{images:r,dy:s}=t,{alignCorners:i}=a;Te([s,r],"resizeNearestNeighborGrad");let o=w.computeStrides(r.shape),l=w.computeStrides(s.shape),[d,u,p,c]=r.shape,[,h,f]=s.shape,m=new Float32Array(d*u*p*c),g=n.data.get(s.dataId).values,y=[i&&h>1?u-1:u,i&&f>1?p-1:p],A=[i&&h>1?h-1:h,i&&f>1?f-1:f],x=y[0]/A[0],b=y[1]/A[1],v=1/x,k=1/b,T=Math.ceil(v)*2+2,C=Math.ceil(k)*2+2;for(let D=0;D<d;D++){let O=D*o[0];for(let F=0;F<u;F++){let S=O+F*o[1],P=Math.floor(F*v),_=Math.floor(P-T/2);for(let j=0;j<p;j++){let q=S+j*o[2],z=Math.floor(j*k),X=Math.floor(z-C/2);for(let Z=0;Z<c;Z++){let te=0;for(let J=0;J<T;J++){let re=J+_;if(re<0||re>=h)continue;let Y=O+re*l[1],se=re*x,de=Math.min(u-1,i?Math.round(se):Math.floor(se));if(F===de)for(let be=0;be<C;be++){let ve=be+X;if(ve<0||ve>=f)continue;let ke=Y+ve*l[2],Ee=ve*b,_e=Math.min(p-1,i?Math.round(Ee):Math.floor(Ee));j===_e&&(te+=g[ke+Z])}}m[q+Z]=te}}}}return n.makeTensorInfo(r.shape,r.dtype,m)}var vq={kernelName:ch,backendName:"cpu",kernelFunc:bq};function wq(e){let{inputs:t,backend:n,attrs:a}=e,{x:r}=t,{dims:s}=a;Te(r,"reverse");let i=r.shape.length,o=w.parseAxisParam(s,r.shape);if(i===0)return Sr({inputs:{x:r},backend:n});let l=new Jt(r.shape,r.dtype),d=n.bufferSync(r);for(let u=0;u<l.size;u++){let p=l.indexToLoc(u),c=p.slice();o.forEach(h=>c[h]=r.shape[h]-1-c[h]),l.set(d.get(...c),...p)}return n.makeTensorInfo(l.shape,l.dtype,l.values)}var kq={kernelName:Di,backendName:"cpu",kernelFunc:wq},Iq={kernelName:Kl,backendName:"cpu",kernelFunc:({inputs:e,attrs:t,backend:n})=>{let{image:a}=e,{radians:r,fillValue:s,center:i}=t,o=n,l=w.getTypedArrayFromDType(a.dtype,w.sizeFromShape(a.shape)),[d,u,p,c]=a.shape,[h,f]=E.getImageCenter(i,u,p),m=255,g=Math.sin(r),y=Math.cos(r),A=o.data.get(a.dataId).values;for(let x=0;x<d;x++){let b=x*p*u*c;for(let v=0;v<u;v++){let k=v*(p*c);for(let T=0;T<p;T++){let C=T*c;for(let D=0;D<c;D++){let O=[d,v,T,D],F=O[2],S=O[1],P=(F-h)*y-(S-f)*g,_=(F-h)*g+(S-f)*y;P=Math.round(P+h),_=Math.round(_+f);let j=s;if(typeof s!="number"&&(D===3?j=m:j=s[D]),P>=0&&P<p&&_>=0&&_<u){let z=_*(p*c),X=P*c,Z=b+z+X+D;j=A[Z]}let q=b+k+C+D;l[q]=j}}}}return{dataId:o.write(l,a.shape,a.dtype),shape:a.shape,dtype:a.dtype}}},Sq=ct($i,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:$i,backendName:"cpu",kernelFunc:Sq};function q6(e,t,n,a,r,s,i,o,l,d){let u=[a/r,r],p=e.values,c=t.values;if(a===0)return Ge(n,t.dtype);let h=Ge(u,t.dtype);h.values.fill(l);for(let f=0;f<s;f++){let m=[],g=0;for(let y=0;y<i;y++){let A=p[f*i+y];m.push(A),g+=A*o[y]}if(g<0||g>=a/r)throw new Error(`Invalid indices: ${m} does not index into ${n}`);for(let y=0;y<r;y++)d?h.values[g*r+y]+=c[f*r+y]:h.values[g*r+y]=t.rank===0?c[0]:c[f*r+y]}return h}function Tq(e){let{inputs:t,backend:n,attrs:a}=e,{indices:r,updates:s}=t,{shape:i}=a,{sliceRank:o,numUpdates:l,sliceSize:d,strides:u,outputSize:p}=E.calculateShapes(s,r,i),c=!0,h=n.bufferSync(r),f=n.bufferSync(s),m=q6(h,f,i,p,d,l,o,u,0,c);return n.makeTensorInfo(i,m.dtype,m.values)}var Cq={kernelName:Ol,backendName:"cpu",kernelFunc:Tq};function Eq(e){let{inputs:t,backend:n}=e,{condition:a,t:r,e:s}=t;Te([a,r,s],"select");let i=a.shape.length,o=n.data.get(a.dataId).values,l=n.data.get(r.dataId).values,d=n.data.get(s.dataId).values,u=Pa(r.dtype,s.dtype),p=w.makeZerosTypedArray(w.sizeFromShape(r.shape),u),c=0,h=i===0||i>1||r.shape.length===1?1:w.sizeFromShape(r.shape.slice(1));for(let f=0;f<o.length;f++)for(let m=0;m<h;m++)o[f]===1?p[c++]=l[f]:p[c++]=d[f];return n.makeTensorInfo(r.shape,u,p)}var Rq={kernelName:_l,backendName:"cpu",kernelFunc:Eq},Mq=E.SELU_SCALEALPHA,Fq=E.SELU_SCALE,Dq=ct(Pl,e=>e>=0?Fq*e:Mq*(Math.exp(e)-1)),$q={kernelName:Pl,backendName:"cpu",kernelFunc:Dq},Oq=ct(Wl,e=>e<0?-1:e>0?1:0),_q={kernelName:Wl,backendName:"cpu",kernelFunc:Oq},Pq=ct(_i,e=>Math.sin(e)),zq={kernelName:_i,backendName:"cpu",kernelFunc:Pq},Lq=ct(Ll,e=>Math.sinh(e)),Wq={kernelName:Ll,backendName:"cpu",kernelFunc:Lq},Bq=11920928955078125e-23,X6=Math.log(Bq)+2,Vq=ct(Bl,e=>{let t=e>-X6,n=e<X6,a=Math.exp(e),r;return n?r=a:t?r=e:r=Math.log(1+a),r}),Uq={kernelName:Bl,backendName:"cpu",kernelFunc:Vq};function jq(e){let{inputs:t,backend:n,attrs:a}=e,{x:r}=t,{blockShape:s,paddings:i}=a;Te([r],"spaceToBatchND");let o=w.sizeFromShape(s),l=[[0,0]];l.push(...i);for(let g=1+s.length;g<r.shape.length;++g)l.push([0,0]);let d=H6.kernelFunc({inputs:{x:r},backend:n,attrs:{paddings:l,constantValue:0}}),u=E.getReshaped(d.shape,s,o,!1),p=E.getPermuted(u.length,s.length,!1),c=E.getReshapedPermuted(d.shape,s,o,!1),h=wt({inputs:{x:d},backend:n,attrs:{shape:u}}),f=Ta({inputs:{x:h},backend:n,attrs:{perm:p}}),m=wt({inputs:{x:f},backend:n,attrs:{shape:c}});return n.disposeIntermediateTensorInfo(d),n.disposeIntermediateTensorInfo(h),n.disposeIntermediateTensorInfo(f),m}var Gq={kernelName:Vl,backendName:"cpu",kernelFunc:jq};function Hq(e){let{inputs:t,backend:n}=e,{indices:a,values:r,denseShape:s,defaultValue:i}=t;if(s.shape.length!==1)throw new Error(`Dense shape must be a vector, saw:
|
|
${s.shape}`);if(a.shape.length!==2)throw new Error(`Indices must be a matrix, saw:
|
|
${a.shape}`);if(r.shape.length!==1)throw new Error(`Values must be a vector, saw:
|
|
${r.shape}`);if(i.shape.length!==0)throw new Error(`Default value must be a scalar, saw:
|
|
${i.shape}`);let o=n.data.get(a.dataId).values,l=n.data.get(r.dataId).values,d=n.data.get(s.dataId).values,u=n.data.get(i.dataId).values[0],[p,c,h,f,m]=x6(o,a.shape,a.dtype,l,r.dtype,d,u);return[n.makeTensorInfo(c,a.dtype,p),n.makeTensorInfo([c[0]],r.dtype,h),n.makeTensorInfo([f.length],"bool",new Uint8Array(f.map(g=>Number(g)))),n.makeTensorInfo([m.length],a.dtype,new Int32Array(m))]}var qq={kernelName:fh,backendName:"cpu",kernelFunc:Hq};function Xq(e){let{inputs:t,backend:n}=e,{inputIndices:a,inputShape:r,newShape:s}=t;if(a.shape.length!==2)throw new Error(`Input indices should be a matrix but received shape
|
|
${a.shape}`);if(r.shape.length!==1)throw new Error(`Input shape should be a vector but received shape
|
|
${r.shape}`);if(s.shape.length!==1)throw new Error(`Target shape should be a vector but received shape ${s.shape}`);let i=Array.from(n.data.get(r.dataId).values),o=n.data.get(a.dataId).values,l=Array.from(n.data.get(s.dataId).values),[d,u,p]=b6(o,a.shape,a.dtype,i,l);return[n.makeTensorInfo(u,a.dtype,d),n.makeTensorInfo([p.length],s.dtype,new Int32Array(p))]}var Kq={kernelName:mh,backendName:"cpu",kernelFunc:Xq};function Zq(e){let{inputs:t,backend:n}=e,{data:a,indices:r,segmentIds:s}=t;if(a.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(s.shape.length!==1)throw new Error(`Segment ids should be a vector but received shape
|
|
${s.shape}`);let i=n.data.get(a.dataId).values,o=n.data.get(r.dataId).values,l=n.data.get(s.dataId).values,[d,u]=v2(i,a.shape,a.dtype,o,l,!0);return n.makeTensorInfo(u,a.dtype,d)}var Yq={kernelName:gh,backendName:"cpu",kernelFunc:Zq};function Jq(e){let{inputs:t,backend:n}=e,{data:a,indices:r,segmentIds:s}=t;if(a.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(s.shape.length!==1)throw new Error(`Segment ids should be a vector but received shape
|
|
${s.shape}`);let i=n.data.get(a.dataId).values,o=n.data.get(r.dataId).values,l=n.data.get(s.dataId).values,[d,u]=v2(i,a.shape,a.dtype,o,l);return n.makeTensorInfo(u,a.dtype,d)}var Qq={kernelName:yh,backendName:"cpu",kernelFunc:Jq};function eX(e){let{inputs:t,backend:n,attrs:a}=e,{sparseIndices:r,sparseValues:s,defaultValue:i}=t,{outputShape:o}=a,{sliceRank:l,numUpdates:d,sliceSize:u,strides:p,outputSize:c}=E.calculateShapes(s,r,o),h=!1,f=n.bufferSync(r),m=n.bufferSync(s),g=n.data.get(i.dataId).values[0],y=q6(f,m,o,c,u,d,l,p,g,h);return n.makeTensorInfo(o,y.dtype,y.values)}var tX={kernelName:Ah,backendName:"cpu",kernelFunc:eX};function nX(e){let{inputs:t,backend:n,attrs:a}=e,{x:r}=t,{numOrSizeSplits:s,axis:i}=a,o=w.parseAxisParam(i,r.shape)[0],l=E.prepareSplitSize(r,s,o),d=new Array(r.shape.length).fill(0),u=r.shape.slice();return l.map(p=>{let c=[...u];c[o]=p;let h=wo({inputs:{x:r},backend:n,attrs:{begin:d,size:c}});return d[o]+=p,h})}var aX={kernelName:Ul,backendName:"cpu",kernelFunc:nX},rX={kernelName:Ed,backendName:"cpu",kernelFunc:({inputs:e,backend:t})=>{let{x:n}=e,a=t;Te(n,"square");let r=a.data.get(n.dataId).values,s=new Float32Array(r.length);for(let i=0;i<r.length;++i){let o=r[i];s[i]=o*o}return{dataId:a.write(s,n.shape,n.dtype),shape:n.shape,dtype:n.dtype}}},sX=ct(ps,(e,t)=>{let n=t;return isNaN(e)?NaN:e>0?1:n.alpha}),iX={kernelName:ps,backendName:"cpu",kernelFunc:sX};function oX(e){let{inputs:t,backend:n,attrs:a}=e,{x:r}=t,{begin:s,end:i,strides:o,beginMask:l,endMask:d,ellipsisMask:u,newAxisMask:p,shrinkAxisMask:c}=a;Te(r,"stridedSlice");let{nonStrided:h,$begin:f,$strides:m,size:g,newShape:y,outShape:A}=En.sliceInfo(r.shape,s,i,o,l,d,u,p,c),x=wt({inputs:{x:r},backend:n,attrs:{shape:y}}),b;if(h){let k=wo({inputs:{x},backend:n,attrs:{begin:f,size:g}});b=wt({inputs:{x:k},backend:n,attrs:{shape:A}}),n.disposeIntermediateTensorInfo(k)}else if(A.some(k=>k===0))b=n.makeTensorInfo(A,r.dtype,[]);else{let k=n.bufferSync(x),T=w6(A,k,m,f);b=n.makeTensorInfo(T.shape,T.dtype,T.values)}let v=wt({inputs:{x:b},backend:n,attrs:{shape:A}});return n.disposeIntermediateTensorInfo(x),n.disposeIntermediateTensorInfo(b),v}var lX={kernelName:jl,backendName:"cpu",kernelFunc:oX};function uX(e){let{inputs:t,backend:n,attrs:a}=e,{separator:r,nGramWidths:s,leftPad:i,rightPad:o,padWidth:l,preserveShortSequences:d}=a,{data:u,dataSplits:p}=t,c=n.data.get(u.dataId).values,h=n.data.get(p.dataId).values,[f,m]=k6(c,h,r,s,i,o,l,d);return[n.makeTensorInfo([f.length],"string",f),n.makeTensorInfo(p.shape,"int32",m)]}var dX={kernelName:xh,backendName:"cpu",kernelFunc:uX};function pX(e){let{inputs:t,backend:n,attrs:a}=e,{skipEmpty:r}=a,{input:s,delimiter:i}=t;if(s.dtype!=="string")throw new Error("Input must be of datatype string");if(s.shape.length!==1)throw new Error(`Input must be a vector, got shape: ${s.shape}`);if(i.shape.length!==0)throw new Error(`Delimiter must be a scalar, got shape: ${i.shape}`);let o=n.data.get(s.dataId).values,l=n.data.get(i.dataId).values[0],[d,u,p]=I6(o,l,r),c=u.length;return[n.makeTensorInfo([c,2],"int32",d),n.makeTensorInfo([c],"string",u),n.makeTensorInfo([2],"int32",new Int32Array(p))]}var cX={kernelName:bh,backendName:"cpu",kernelFunc:pX};function hX(e){let{inputs:t,backend:n,attrs:a}=e,{numBuckets:r}=a,{input:s}=t;if(s.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 i=n.data.get(s.dataId).values,o=S6(i,r);return n.makeTensorInfo(s.shape,"int32",o)}var fX={kernelName:vh,backendName:"cpu",kernelFunc:hX},mX=ct(Ui,e=>Math.tan(e)),gX={kernelName:Ui,backendName:"cpu",kernelFunc:mX},yX=ct(ji,e=>Math.tanh(e)),AX={kernelName:ji,backendName:"cpu",kernelFunc:yX};function xX(e){let{inputs:t,backend:n,attrs:a}=e,{x:r}=t,{reps:s}=a;Te(r,"tile");let i=T6(n.bufferSync(r),s);return n.makeTensorInfo(i.shape,i.dtype,i.values)}var bX={kernelName:ds,backendName:"cpu",kernelFunc:xX};function vX(e){let{inputs:t,backend:n,attrs:a}=e,{x:r}=t,{k:s,sorted:i}=a;Te(r,"topk");let o=n.data.get(r.dataId).values,[l,d]=E6(o,r.shape,r.dtype,s,i);return[n.makeTensorInfo(l.shape,l.dtype,l.values),n.makeTensorInfo(d.shape,d.dtype,d.values)]}var wX={kernelName:Gl,backendName:"cpu",kernelFunc:vX};function kX(e){let{inputs:t,attrs:n,backend:a}=e,{image:r,transforms:s}=t,{interpolation:i,fillMode:o,fillValue:l,outputShape:d}=n,[u,p,c,h]=r.shape,[f,m]=d!=null?d:[p,c],g=[u,f,m,h],y=w.computeStrides(r.shape),A=y[0],x=y[1],b=y[2],v=w.getTypedArrayFromDType(r.dtype,w.sizeFromShape(g));v.fill(l);let k=a.data.get(r.dataId).values,T=a.data.get(s.dataId).values;for(let C=0;C<u;++C){let D=s.shape[0]===1?T:T.subarray(C*8,C*8+8);for(let O=0;O<f;++O)for(let F=0;F<m;++F)for(let S=0;S<h;++S){let P,_=D[6]*F+D[7]*O+1;if(_===0)continue;let j=(D[0]*F+D[1]*O+D[2])/_,q=(D[3]*F+D[4]*O+D[5])/_,z=K6(j,c,o),X=K6(q,p,o);switch(i){case"nearest":P=EX(k,p,c,A,x,b,C,X,z,S,l);break;case"bilinear":P=RX(k,p,c,A,x,b,C,X,z,S,l);break;default:throw new Error(`Error in Transform: Expect 'nearest' or 'bilinear', but got ${i}`)}let Z=C*A+O*x+F*b+S;v[Z]=P}return a.makeTensorInfo(g,r.dtype,v)}return{dataId:a.write(v,g,r.dtype),shape:r.shape,dtype:r.dtype}}var IX={kernelName:Hl,backendName:"cpu",kernelFunc:kX};function K6(e,t,n){switch(n){case"reflect":return SX(e,t);case"wrap":return NX(e,t);case"nearest":return CX(e,t);case"constant":default:return TX(e,t)}}function SX(e,t){let n=e;if(n<0)if(t<=1)n=0;else{let a=2*t;n<a&&(n=a*Math.trunc(-n/a)+n),n=n<-t?n+a:-n-1}else if(n>t-1)if(t<=1)n=0;else{let a=2*t;n-=a*Math.trunc(n/a),n>=t&&(n=a-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 a=t-1;n+=t*(Math.trunc(-n/a)+1)}else if(n>t-1)if(t<=1)n=0;else{let a=t-1;n-=t*Math.trunc(n/a)}return w.clamp(0,n,t-1)}function TX(e,t){return e}function CX(e,t){return w.clamp(0,e,t-1)}function Fp(e,t,n,a,r,s,i,o,l,d,u){let p=i*a+o*r+l*s+d;return 0<=o&&o<t&&0<=l&&l<n?e[p]:u}function EX(e,t,n,a,r,s,i,o,l,d,u){let p=Math.round(o),c=Math.round(l);return Fp(e,t,n,a,r,s,i,p,c,d,u)}function RX(e,t,n,a,r,s,i,o,l,d,u){let p=Math.floor(o),c=Math.floor(l),h=p+1,f=c+1,m=(f-l)*Fp(e,t,n,a,r,s,i,p,c,d,u)+(l-c)*Fp(e,t,n,a,r,s,i,p,f,d,u),g=(f-l)*Fp(e,t,n,a,r,s,i,h,c,d,u)+(l-c)*Fp(e,t,n,a,r,s,i,h,f,d,u);return(h-o)*m+(o-p)*g}function MX(e){let{inputs:t,attrs:n,backend:a}=e,{axis:r}=n,{x:s}=t;Te(s,"unique");let i=a.data.get(s.dataId).values,{outputValues:o,outputShape:l,indices:d}=R6(i,r,s.shape,s.dtype);return[a.makeTensorInfo(l,s.dtype,o),a.makeTensorInfo([d.length],"int32",d)]}var FX={kernelName:wh,backendName:"cpu",kernelFunc:MX};function DX(e){let{inputs:t,backend:n,attrs:a}=e,{value:r}=t,{axis:s}=a;s<0&&(s+=r.shape.length);let i=r.shape.length,o=r.shape[s],l=new Array(i-1),d=0;for(let h=0;h<i;h++)h!==s&&(l[d++]=r.shape[h]);let u=new Array(i).fill(0),p=r.shape.slice();p[s]=1;let c=new Array(o);for(let h=0;h<c.length;h++){u[s]=h;let f=wo({inputs:{x:r},backend:n,attrs:{begin:u,size:p}});c[h]=wt({inputs:{x:f},backend:n,attrs:{shape:l}}),n.disposeIntermediateTensorInfo(f)}return c}var $X={kernelName:ql,backendName:"cpu",kernelFunc:DX};function OX(e){let{inputs:t,backend:n,attrs:a}=e,{x:r,segmentIds:s}=t,{numSegments:i}=a;Te(r,"unsortedSegmentSum");let o=r.shape.length,l=s.shape.length,d=[],u=[],p=o-l,c=s;for(let f=0;f<p;++f){let m=sf({inputs:{input:c},backend:n,attrs:{dim:f+1}});c=m,u.push(m)}for(let f=0;f<i;++f){let m=w.createScalarValue(f,"int32"),g=n.makeTensorInfo([],"int32",m),y=Jw({inputs:{a:g,b:c},backend:n}),A=Rs({inputs:{x:y},backend:n,attrs:{dtype:"float32"}}),x=af({inputs:{a:A,b:r},backend:n}),b=Mp({inputs:{x},backend:n,attrs:{axis:0,keepDims:!1}});d.push(b),u.push(g),u.push(y),u.push(A),u.push(x),u.push(b)}let h=G6({inputs:d,backend:n,attrs:{axis:0}});return u.forEach(f=>n.disposeIntermediateTensorInfo(f)),h}var _X={kernelName:Rd,backendName:"cpu",kernelFunc:OX},PX=[jU,PV,HU,XU,UV,ZU,JU,ej,nj,rj,ij,lj,dj,hj,mj,Aj,bj,wj,Ij,VU,Nj,Cj,Rj,Fj,BV,GV,$j,zV,_j,zj,Bj,Uj,Lj,qj,Kj,Gj,Yj,Qj,tG,aG,sG,oG,lG,dG,cG,fG,mG,yG,gG,N2,bG,OU,wG,HV,RG,qV,MG,KV,PG,zG,WG,YV,UG,GG,qG,KG,YG,QV,tU,LV,QG,Pj,tH,aH,sH,_U,aU,sU,oH,oU,uH,cH,fH,yH,xH,vH,uU,IH,NH,CH,RH,FH,wH,$H,_H,pU,zH,BH,GH,hU,mU,XH,YH,eq,yU,nq,rq,sq,H6,uq,zU,bU,pq,WV,hq,LU,WU,BU,mq,yq,xq,vq,kq,Iq,Nq,wU,Cq,Rq,$q,IU,_q,zq,Wq,SU,UH,Uq,Gq,qq,Kq,Yq,Qq,tX,aX,CU,rX,RU,iX,lX,dX,cX,fX,$U,AG,gX,AX,bX,wX,AU,IX,FX,$X,_X,aq];for(let e of PX)cs(e);var Z6={};ze(Z6,{assertNotComplex:()=>Mu,bindCanvasToFramebuffer:()=>KX,bindColorTextureToFramebuffer:()=>pf,bindTextureToProgramUniformSampler:()=>p4,bindTextureUnit:()=>l4,bindVertexBufferToProgramAttribute:()=>M2,callAndCheck:()=>Se,canBeRepresented:()=>Y6,createFragmentShader:()=>e4,createFramebuffer:()=>o4,createProgram:()=>t4,createStaticIndexBuffer:()=>r4,createStaticVertexBuffer:()=>a4,createTexture:()=>s4,createVertexShader:()=>Q6,getBatchDim:()=>Io,getExtensionOrThrow:()=>Op,getFramebufferErrorMessage:()=>c4,getMaxTexturesInShader:()=>g4,getNumChannels:()=>qX,getProgramUniformLocation:()=>d4,getProgramUniformLocationOrThrow:()=>u4,getRowsCols:()=>So,getShapeAs3D:()=>cf,getTextureShapeFromLogicalShape:()=>f4,getWebGLDisjointQueryTimerVersion:()=>y4,getWebGLErrorMessage:()=>J6,getWebGLMaxTextureSize:()=>m4,hasExtension:()=>Ea,isCapableOfRenderingToFloatTexture:()=>A4,isDownloadFloatTextureEnabled:()=>x4,isReshapeFree:()=>Pp,isWebGLFenceEnabled:()=>b4,isWebGLVersionEnabled:()=>D2,linkProgram:()=>n4,resetMaxTextureSize:()=>ZX,resetMaxTexturesInShader:()=>YX,unbindColorTextureFromFramebuffer:()=>F2,unbindTextureUnit:()=>XX,validateFramebuffer:()=>_p,validateProgram:()=>df,validateTextureSize:()=>i4});var ko={},E2={alpha:!1,antialias:!1,premultipliedAlpha:!1,preserveDrawingBuffer:!1,depth:!1,stencil:!1,failIfMajorPerformanceCaveat:!0};function lf(e,t){ko[e]=t}function Nr(e){if(!(e in ko)){let n=LX(e);if(n!==null)ko[e]=n;else return console.log("Could not get context for WebGL version",e),null}let t=ko[e];return t.isContextLost()?(delete ko[e],Nr(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),ko[e])}function zX(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 LX(e){if(e!==1&&e!==2)throw new Error("Cannot get WebGL rendering context, WebGL is disabled.");let t=zX(e);return t.addEventListener("webglcontextlost",n=>{n.preventDefault(),delete ko[e]},!1),e===1?t.getContext("webgl",E2)||t.getContext("experimental-webgl",E2):t.getContext("webgl2",E2)}var Dp;(function(e){e[e.DENSE=0]="DENSE",e[e.SHARED_BATCH=1]="SHARED_BATCH"})(Dp||(Dp={}));var Ca;(function(e){e[e.RENDER=0]="RENDER",e[e.UPLOAD=1]="UPLOAD",e[e.PIXELS=2]="PIXELS",e[e.DOWNLOAD=3]="DOWNLOAD"})(Ca||(Ca={}));var bn;(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"})(bn||(bn={}));function $p(e,t){return[t,e]}function WX(e,t){return e*t}function uf(e){let t=w.sizeFromShape(e),n=Math.ceil(t/4);return w.sizeToSquarishShape(n)}function Ru(e,t){return[Math.max(1,Math.ceil(t/2)),Math.max(1,Math.ceil(e/2))]}function BX(e,t){let[n,a]=Ru(e,t);return n*a*4}function R2(e,t){let n=e,a,r,s,i,o,l,d,u,p,c;return ne().getNumber("WEBGL_VERSION")===2?(a=n.R32F,r=n.R16F,s=n.RGBA16F,i=n.RGBA32F,o=n.RED,d=4,u=1,p=n.HALF_FLOAT,c=n.FLOAT):(a=e.RGBA,r=e.RGBA,s=e.RGBA,i=n.RGBA,o=e.RGBA,d=4,u=4,p=t!=null?t.HALF_FLOAT_OES:null,c=e.FLOAT),l=e.RGBA,{internalFormatFloat:a,internalFormatHalfFloat:r,internalFormatPackedHalfFloat:s,internalFormatPackedFloat:i,textureFormatFloat:o,downloadTextureFormat:l,downloadUnpackNumChannels:d,defaultNumChannels:u,textureTypeHalfFloat:p,textureTypeFloat:c}}function Se(e,t){let n=t();return ne().getBool("DEBUG")&&VX(e),n}function VX(e){let t=e.getError();if(t!==e.NO_ERROR)throw new Error("WebGL Error: "+J6(e,t))}var UX=596e-10,jX=65504;function Y6(e){return!!(ne().getBool("WEBGL_RENDER_FLOAT32_ENABLED")||e===0||UX<Math.abs(e)&&Math.abs(e)<jX)}function J6(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 Op(e,t){return Gr(e,()=>e.getExtension(t),'Extension "'+t+'" not supported on this browser.')}function Q6(e,t){let n=Gr(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 e4(e,t){let n=Gr(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 HX(t,e.getShaderInfoLog(n)),new Error("Failed to compile fragment shader.");return n}var GX=/ERROR: [0-9]+:([0-9]+):/g;function HX(e,t){let n=GX.exec(t);if(n==null){console.log(`Couldn't parse line number in error: ${t}`),console.log(e);return}let a=+n[1],r=e.split(`
|
|
`),s=r.length.toString().length+2,i=r.map((p,c)=>w.rightPad((c+1).toString(),s)+p),o=0;for(let p=0;p<i.length;p++)o=Math.max(i[p].length,o);let l=i.slice(0,a-1),d=i.slice(a-1,a),u=i.slice(a);console.log(l.join(`
|
|
`)),console.log(t.split(`
|
|
`)[0]),console.log(`%c ${w.rightPad(d[0],o)}`,"border:1px solid red; background-color:#e3d2d2; color:#a61717"),console.log(u.join(`
|
|
`))}function t4(e){return Gr(e,()=>e.createProgram(),"Unable to create WebGLProgram.")}function n4(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 df(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 a4(e,t){let n=Gr(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 r4(e,t){let n=Gr(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 qX(){return ne().getNumber("WEBGL_VERSION")===2?1:4}function s4(e){return Gr(e,()=>e.createTexture(),"Unable to create WebGLTexture.")}function i4(e,t){let n=ne().getNumber("WEBGL_MAX_TEXTURE_SIZE");if(e<=0||t<=0){let a=`[${e}x${t}]`;throw new Error("Requested texture size "+a+" is invalid.")}if(e>n||t>n){let a=`[${e}x${t}]`,r=`[${n}x${n}]`;throw new Error("Requested texture size "+a+" greater than WebGL maximum on this browser / GPU "+r+".")}}function o4(e){return Gr(e,()=>e.createFramebuffer(),"Unable to create WebGLFramebuffer.")}function M2(e,t,n,a,r,s,i){let o=e.getAttribLocation(t,n);return o===-1?!1:(Se(e,()=>e.bindBuffer(e.ARRAY_BUFFER,a)),Se(e,()=>e.vertexAttribPointer(o,r,e.FLOAT,!1,s,i)),Se(e,()=>e.enableVertexAttribArray(o)),!0)}function l4(e,t,n){h4(e,n),Se(e,()=>e.activeTexture(e.TEXTURE0+n)),Se(e,()=>e.bindTexture(e.TEXTURE_2D,t))}function XX(e,t){h4(e,t),Se(e,()=>e.activeTexture(e.TEXTURE0+t)),Se(e,()=>e.bindTexture(e.TEXTURE_2D,null))}function u4(e,t,n){return Gr(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,a){Se(e,()=>l4(e,t,a)),Se(e,()=>e.uniform1i(n,a))}function KX(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 pf(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 F2(e,t){Se(e,()=>e.bindFramebuffer(e.FRAMEBUFFER,t)),Se(e,()=>e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,null,0))}function _p(e){let t=e.checkFramebufferStatus(e.FRAMEBUFFER);if(t!==e.FRAMEBUFFER_COMPLETE)throw new Error("Error binding framebuffer: "+c4(e,t))}function c4(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 Gr(e,t,n){let a=Se(e,()=>t());if(a==null)throw new Error(n);return a}function h4(e,t){let n=e.MAX_COMBINED_TEXTURE_IMAGE_UNITS-1,a=t+e.TEXTURE0;if(a<e.TEXTURE0||a>n){let r=`[gl.TEXTURE0, gl.TEXTURE${n}]`;throw new Error(`textureUnit must be in ${r}.`)}}function Io(e,t=2){return w.sizeFromShape(e.slice(0,e.length-t))}function So(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 cf(e){let t=[1,1,1];return e.length===0||e.length===1&&e[0]===1||(t=[Io(e),...So(e)]),t}function f4(e,t=!1){let n=ne().getNumber("WEBGL_MAX_TEXTURE_SIZE");t&&(n=n*2,e=e.map((r,s)=>s>=e.length-2?w.nearestLargerEven(e[s]):e[s]),e.length===1&&(e=[2,e[0]])),e.length!==2&&(e=w.squeezeShape(e).newShape);let a=w.sizeFromShape(e);if(e.length<=1&&a<=n)return[1,a];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=Io(e),s=2,i=2;return e.length&&([s,i]=So(e)),a=r*(s/2)*(i/2),w.sizeToSquarishShape(a).map(o=>o*2)}return w.sizeToSquarishShape(a)}function hf(e){return e%2==0}function Pp(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],a=t.slice(-1)[0];if(n===a||hf(n)&&hf(a)&&(e[0]===1||t[0]===1))return!0}return e[1]===t[1]&&hf(e[0])&&hf(t[0])}var ff,mf;function m4(e){if(ff==null){let t=Nr(e);ff=t.getParameter(t.MAX_TEXTURE_SIZE)}return ff}function ZX(){ff=null}function YX(){mf=null}function g4(e){if(mf==null){let t=Nr(e);mf=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS)}return Math.min(16,mf)}function y4(e){if(e===0)return 0;let t,n=Nr(e);return Ea(n,"EXT_disjoint_timer_query_webgl2")&&e===2?t=2:Ea(n,"EXT_disjoint_timer_query")?t=1:t=0,t}function Ea(e,t){return e.getExtension(t)!=null}function D2(e){try{if(Nr(e)!=null)return!0}catch(t){return console.log("Error when getting WebGL context: ",t),!1}return!1}function A4(e){if(e===0)return!1;let t=Nr(e);if(e===1){if(!Ea(t,"OES_texture_float"))return!1}else if(!Ea(t,"EXT_color_buffer_float"))return!1;return $2(t)}function x4(e){if(e===0)return!1;let t=Nr(e);if(e===1){if(!Ea(t,"OES_texture_float")||!Ea(t,"WEBGL_color_buffer_float"))return!1}else{if(Ea(t,"EXT_color_buffer_float"))return $2(t);let n="EXT_color_buffer_half_float";if(Ea(t,n)){let a=t.getExtension(n);return JX(t,a)}return!1}return $2(t)}function $2(e){let t=R2(e),n=e.createTexture();e.bindTexture(e.TEXTURE_2D,n);let a=1,r=1;e.texImage2D(e.TEXTURE_2D,0,t.internalFormatFloat,a,r,0,t.textureFormatFloat,t.textureTypeFloat,null);let s=e.createFramebuffer();e.bindFramebuffer(e.FRAMEBUFFER,s),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,n,0);let i=e.checkFramebufferStatus(e.FRAMEBUFFER)===e.FRAMEBUFFER_COMPLETE;return e.bindTexture(e.TEXTURE_2D,null),e.bindFramebuffer(e.FRAMEBUFFER,null),e.deleteTexture(n),e.deleteFramebuffer(s),i}function JX(e,t){let n=R2(e,t),a=e.createTexture();e.bindTexture(e.TEXTURE_2D,a);let r=1,s=1;e.texImage2D(e.TEXTURE_2D,0,n.internalFormatHalfFloat,r,s,0,n.textureFormatFloat,n.textureTypeHalfFloat,null);let i=e.createFramebuffer();e.bindFramebuffer(e.FRAMEBUFFER,i),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,a,0);let o=e.checkFramebufferStatus(e.FRAMEBUFFER)===e.FRAMEBUFFER_COMPLETE;return e.bindTexture(e.TEXTURE_2D,null),e.bindFramebuffer(e.FRAMEBUFFER,null),e.deleteTexture(a),e.deleteFramebuffer(i),o}function b4(e){return e!==2?!1:Nr(e).fenceSync!=null}function Mu(e,t){Array.isArray(e)||(e=[e]),e.forEach(n=>{n!=null&&w.assert(n.dtype!=="complex64",()=>`${t} does not support complex64 tensors in the WebGL backend.`)})}var $e=ne();$e.registerFlag("HAS_WEBGL",()=>$e.getNumber("WEBGL_VERSION")>0);$e.registerFlag("WEBGL_VERSION",()=>D2(2)?2:D2(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",()=>m4($e.getNumber("WEBGL_VERSION")));$e.registerFlag("WEBGL_MAX_TEXTURES_IN_SHADER",()=>g4($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&&!Wd.isMobile());$e.registerFlag("WEBGL_RENDER_FLOAT32_CAPABLE",()=>A4($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",()=>x4($e.getNumber("WEBGL_VERSION")));$e.registerFlag("WEBGL_FENCE_API_ENABLED",()=>b4($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",()=>Wd.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,a,r,s,i,o,l,d;return ne().getNumber("WEBGL_VERSION")===2?(e="#version 300 es",t="in",n="out",a="in",r="texture",s="outputColor",i="out vec4 outputColor;",o=`
|
|
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="",d=`
|
|
#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",a="varying",r="texture2D",s="gl_FragColor",i="",o=`
|
|
#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));
|
|
}
|
|
`,d=`
|
|
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:a,texture2D:r,output:s,defineOutput:i,defineSpecialNaN:o,defineSpecialInf:l,defineRound:d}}function No(e,t,n="index"){let a=w.computeStrides(t);return a.map((r,s)=>{let i=`int ${e[s]} = ${n} / ${r}`,o=s===a.length-1?`int ${e[s+1]} = ${n} - ${e[s]} * ${r}`:`index -= ${e[s]} * ${r}`;return`${i}; ${o};`}).join("")}function gf(e,t,n="index"){let a=w.computeStrides(t);return a.map((r,s)=>{let i=`int ${e[s]} = ${n} / outShapeStrides[${s}]`,o=s===a.length-1?`int ${e[s+1]} = ${n} - ${e[s]} * outShapeStrides[${s}]`:`index -= ${e[s]} * outShapeStrides[${s}]`;return`${i}; ${o};`}).join("")}function QX(e,t){let n=e.length,a=e.map(s=>`${t}[${s}]`),r=new Array(n-1);r[n-2]=a[n-1];for(let s=n-3;s>=0;--s)r[s]=`(${r[s+1]} * ${a[s+1]})`;return r}function eK(e,t,n="index"){let a=e.map((s,i)=>i),r=QX(a,t);return r.map((s,i)=>{let o=`int ${e[i]} = ${n} / ${r[i]}`,l=i===r.length-1?`int ${e[i+1]} = ${n} - ${e[i]} * ${r[i]}`:`index -= ${e[i]} * ${r[i]}`;return`${o}; ${l};`}).join("")}function O2(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 _2(){return`
|
|
int getFlatIndex(ivec3 coords) {
|
|
return coords.x * outShapeStrides[0] + coords.y * outShapeStrides[1] + coords.z;
|
|
}
|
|
`}var v4=`
|
|
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:w4}=E;function tK(e,t,n){let a=[];if(e.forEach(c=>{let h=w.sizeFromShape(c.shapeInfo.logicalShape);if(c.shapeInfo.isUniform?a.push(`uniform float ${c.name}${h>1?`[${h}]`:""};`):(a.push(`uniform sampler2D ${c.name};`),a.push(`uniform int offset${c.name};`)),n.enableShapeUniforms){let{uniformShape:f}=P2(n.packedInputs,c.shapeInfo.logicalShape,c.shapeInfo.texShape);switch(f.length){case 1:a.push(`uniform int ${c.name}Shape;`);break;case 2:a.push(`uniform ivec2 ${c.name}Shape;`);break;case 3:a.push(`uniform ivec3 ${c.name}Shape;`);break;case 4:a.push(`uniform ivec4 ${c.name}Shape;`);break;default:break}a.push(`uniform ivec2 ${c.name}TexShape;`)}}),n.enableShapeUniforms){switch(t.logicalShape.length){case 1:a.push("uniform int outShape;");break;case 2:a.push("uniform ivec2 outShape;"),a.push("uniform int outShapeStrides;");break;case 3:a.push("uniform ivec3 outShape;"),a.push("uniform ivec2 outShapeStrides;");break;case 4:a.push("uniform ivec4 outShape;"),a.push("uniform ivec3 outShapeStrides;");break;default:break}a.push("uniform ivec2 outTexShape;")}n.customUniforms&&n.customUniforms.forEach(c=>{a.push(`uniform ${c.type} ${c.name}${c.arrayIndex?`[${c.arrayIndex}]`:""};`)});let r=a.join(`
|
|
`),s=e.map(c=>nK(c,t,n.packedInputs,n.enableShapeUniforms)).join(`
|
|
`),i=t.texShape,o=$n(),l=sK(o),d,u,p=lK(o);return t.isPacked?(d=aK(t.logicalShape,i,n.enableShapeUniforms),u=oK(o)):(d=rK(t.logicalShape,i,n.enableShapeUniforms),u=iK(o)),n.packedInputs&&(p+=cK),[p,l,u,r,d,s,n.userCode].join(`
|
|
`)}function Fu(e,t=!1){let n=e.shapeInfo.logicalShape;switch(n.length){case 0:return IK(e,t);case 1:return NK(e,t);case 2:return CK(e,t);case 3:return RK(e,t);case 4:return FK(e,t);case 5:return DK(e);case 6:return $K(e);default:throw new Error(`${n.length}-D input sampling is not yet supported`)}}function k4(e,t){switch(e.shapeInfo.logicalShape.length){case 0:return kK(e);case 1:return SK(e,t);case 2:return TK(e,t);case 3:return EK(e,t);default:return MK(e,t)}}function nK(e,t,n=!1,a){let r="";n?r+=k4(e,a):r+=Fu(e,a);let s=e.shapeInfo.logicalShape,i=t.logicalShape;return s.length<=i.length&&(n?r+=OK(e,t):r+=_K(e,t)),r}function aK(e,t,n){switch(e.length){case 0:return I4();case 1:return hK(e,t,n);case 2:return vK(e,t,n);case 3:return mK(e,t,n);default:return yK(e,t,n)}}function rK(e,t,n){switch(e.length){case 0:return I4();case 1:return fK(e,t,n);case 2:return wK(e,t,n);case 3:return gK(e,t,n);case 4:return AK(e,t,n);case 5:return xK(e,t);case 6:return bK(e,t);default:throw new Error(`${e.length}-D output sampling is not yet supported`)}}function sK(e){return`
|
|
float sampleTexture(sampler2D textureSampler, vec2 uv) {
|
|
return ${e.texture2D}(textureSampler, uv).r;
|
|
}
|
|
`}function iK(e){return`
|
|
void setOutput(float val) {
|
|
${e.output} = vec4(val, 0, 0, 0);
|
|
}
|
|
`}function oK(e){return`
|
|
void setOutput(vec4 val) {
|
|
${e.output} = val;
|
|
}
|
|
`}function lK(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);
|
|
}
|
|
|
|
${uK}
|
|
${dK}
|
|
${pK}
|
|
`}var uK=`
|
|
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);
|
|
}
|
|
`,dK=`
|
|
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);
|
|
}
|
|
`,pK=`
|
|
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);
|
|
}
|
|
`,cK=`
|
|
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 I4(){return`
|
|
int getOutputCoords() {
|
|
return 0;
|
|
}
|
|
`}function hK(e,t,n){let a=[Math.ceil(t[0]/2),Math.ceil(t[1]/2)];return a[0]===1?n?`
|
|
int getOutputCoords() {
|
|
return 2 * int(resultUV.x * ceil(float(outTexShape[1]) / 2.0));
|
|
}
|
|
`:`
|
|
int getOutputCoords() {
|
|
return 2 * int(resultUV.x * ${a[1]}.0);
|
|
}
|
|
`:a[1]===1?n?`
|
|
int getOutputCoords() {
|
|
return 2 * int(resultUV.y * ceil(float(outTexShape[0]) / 2.0));
|
|
}
|
|
`:`
|
|
int getOutputCoords() {
|
|
return 2 * int(resultUV.y * ${a[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(${a[0]}, ${a[1]}));
|
|
return 2 * (resTexRC.x * ${a[1]} + resTexRC.y);
|
|
}
|
|
`}function fK(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 mK(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 a=[Math.ceil(t[0]/2),Math.ceil(t[1]/2)],r=Math.ceil(e[2]/2),s=r*Math.ceil(e[1]/2);return`
|
|
ivec3 getOutputCoords() {
|
|
ivec2 resTexRC = ivec2(resultUV.yx *
|
|
vec2(${a[0]}, ${a[1]}));
|
|
int index = resTexRC.x * ${a[1]} + resTexRC.y;
|
|
|
|
int b = index / ${s};
|
|
index -= b * ${s};
|
|
|
|
int r = 2 * (index / ${r});
|
|
int c = imod(index, ${r}) * 2;
|
|
|
|
return ivec3(b, r, c);
|
|
}
|
|
`}function gK(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;
|
|
${gf(["r","c","d"],e)}
|
|
return ivec3(r, c, d);
|
|
}
|
|
`;let a=No(["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;
|
|
${a}
|
|
return ivec3(r, c, d);
|
|
}
|
|
`}function yK(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 a=[Math.ceil(t[0]/2),Math.ceil(t[1]/2)],r=Math.ceil(e[e.length-1]/2),s=r*Math.ceil(e[e.length-2]/2),i=s,o="",l="b, r, c";for(let d=2;d<e.length-1;d++)i*=e[e.length-d-1],o=`
|
|
int b${d} = index / ${i};
|
|
index -= b${d} * ${i};
|
|
`+o,l=`b${d}, `+l;return`
|
|
ivec${e.length} getOutputCoords() {
|
|
ivec2 resTexRC = ivec2(resultUV.yx *
|
|
vec2(${a[0]}, ${a[1]}));
|
|
int index = resTexRC.x * ${a[1]} + resTexRC.y;
|
|
|
|
${o}
|
|
|
|
int b = index / ${s};
|
|
index -= b * ${s};
|
|
|
|
int r = 2 * (index / ${r});
|
|
int c = imod(index, ${r}) * 2;
|
|
|
|
return ivec${e.length}(${l});
|
|
}
|
|
`}function AK(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;
|
|
${gf(["r","c","d","d2"],e)}
|
|
return ivec4(r, c, d, d2);
|
|
}
|
|
`;let a=No(["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;
|
|
${a}
|
|
return ivec4(r, c, d, d2);
|
|
}
|
|
`}function xK(e,t){let n=No(["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 bK(e,t){let n=No(["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 vK(e,t,n){let a=[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(${a[0]}, ${a[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(${a[0]}, ${a[1]}));
|
|
|
|
int index = resTexRC.x * ${a[1]} + resTexRC.y;
|
|
int r = 2 * (index / ${r});
|
|
int c = imod(index, ${r}) * 2;
|
|
|
|
return ivec2(r, c);
|
|
}
|
|
`}function wK(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 To(e){return`offset${e}`}function kK(e){let t=e.name,n="get"+t.charAt(0).toUpperCase()+t.slice(1),a=$n();return`
|
|
vec4 ${n}() {
|
|
return ${a.texture2D}(${t}, halfCR);
|
|
}
|
|
`}function IK(e,t){let n=e.name,a="get"+n.charAt(0).toUpperCase()+n.slice(1);if(e.shapeInfo.isUniform)return`float ${a}() {return ${n};}`;let[r,s]=e.shapeInfo.texShape;if(r===1&&s===1)return`
|
|
float ${a}() {
|
|
return sampleTexture(${n}, halfCR);
|
|
}
|
|
`;let i=To(n);if(t)return`
|
|
float ${a}() {
|
|
vec2 uv = uvFromFlat(${n}TexShape[0], ${n}TexShape[1], ${i});
|
|
return sampleTexture(${n}, uv);
|
|
}
|
|
`;let[o,l]=e.shapeInfo.texShape;return`
|
|
float ${a}() {
|
|
vec2 uv = uvFromFlat(${o}, ${l}, ${i});
|
|
return sampleTexture(${n}, uv);
|
|
}
|
|
`}function SK(e,t){let n=e.name,a="get"+n.charAt(0).toUpperCase()+n.slice(1),r=e.shapeInfo.texShape,s=$n();if(t)return`
|
|
vec4 ${a}(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 ${s.texture2D}(${n}, uv);
|
|
}
|
|
`;let i=[Math.ceil(r[0]/2),Math.ceil(r[1]/2)];return`
|
|
vec4 ${a}(int index) {
|
|
vec2 uv = packedUVfrom1D(
|
|
${i[0]}, ${i[1]}, index);
|
|
return ${s.texture2D}(${n}, uv);
|
|
}
|
|
`}function NK(e,t){let n=e.name,a="get"+n.charAt(0).toUpperCase()+n.slice(1);if(e.shapeInfo.isUniform)return`
|
|
float ${a}(int index) {
|
|
${Du(e)}
|
|
}
|
|
`;let r=e.shapeInfo.texShape,s=r[0],i=r[1];if(i===1&&s===1)return`
|
|
float ${a}(int index) {
|
|
return sampleTexture(${n}, halfCR);
|
|
}
|
|
`;let o=To(n);return i===1?t?`
|
|
float ${a}(int index) {
|
|
vec2 uv = vec2(0.5, (float(index + ${o}) + 0.5) / float(${n}TexShape[0]));
|
|
return sampleTexture(${n}, uv);
|
|
}
|
|
`:`
|
|
float ${a}(int index) {
|
|
vec2 uv = vec2(0.5, (float(index + ${o}) + 0.5) / ${s}.0);
|
|
return sampleTexture(${n}, uv);
|
|
}
|
|
`:s===1?t?`
|
|
float ${a}(int index) {
|
|
vec2 uv = vec2((float(index + ${o}) + 0.5) / float(${n}TexShape[1]), 0.5);
|
|
return sampleTexture(${n}, uv);
|
|
}
|
|
`:`
|
|
float ${a}(int index) {
|
|
vec2 uv = vec2((float(index + ${o}) + 0.5) / ${i}.0, 0.5);
|
|
return sampleTexture(${n}, uv);
|
|
}
|
|
`:t?`
|
|
float ${a}(int index) {
|
|
vec2 uv = uvFromFlat(${n}TexShape[0], ${n}TexShape[1], index + ${o});
|
|
return sampleTexture(${n}, uv);
|
|
}
|
|
`:`
|
|
float ${a}(int index) {
|
|
vec2 uv = uvFromFlat(${s}, ${i}, index + ${o});
|
|
return sampleTexture(${n}, uv);
|
|
}
|
|
`}function TK(e,t){let n=e.shapeInfo.logicalShape,a=e.name,r="get"+a.charAt(0).toUpperCase()+a.slice(1),s=e.shapeInfo.texShape,i=s[0],o=s[1],l=$n();if(s!=null&&w.arraysEqual(n,s))return t?`
|
|
vec4 ${r}(int row, int col) {
|
|
vec2 uv = (vec2(col, row) + halfCR) / vec2(${a}TexShape[1], ${a}TexShape[0]);
|
|
|
|
return ${l.texture2D}(${a}, uv);
|
|
}
|
|
`:`
|
|
vec4 ${r}(int row, int col) {
|
|
vec2 uv = (vec2(col, row) + halfCR) / vec2(${o}.0, ${i}.0);
|
|
|
|
return ${l.texture2D}(${a}, uv);
|
|
}
|
|
`;if(t)return`
|
|
vec4 ${r}(int row, int col) {
|
|
ivec2 packedTexShape = ivec2(ceil(float(${a}TexShape[0]) / 2.0), ceil(float(${a}TexShape[1]) / 2.0));
|
|
int valuesPerRow = int(ceil(float(${a}Shape[1]) / 2.0));
|
|
vec2 uv = packedUVfrom2D(valuesPerRow, packedTexShape[0], packedTexShape[1], row, col);
|
|
return ${l.texture2D}(${a}, uv);
|
|
}
|
|
`;let d=[Math.ceil(s[0]/2),Math.ceil(s[1]/2)],u=Math.ceil(n[1]/2);return`
|
|
vec4 ${r}(int row, int col) {
|
|
vec2 uv = packedUVfrom2D(${u}, ${d[0]}, ${d[1]}, row, col);
|
|
return ${l.texture2D}(${a}, uv);
|
|
}
|
|
`}function CK(e,t){let n=e.shapeInfo.logicalShape,a=e.name,r="get"+a.charAt(0).toUpperCase()+a.slice(1),s=e.shapeInfo.texShape;if(s!=null&&w.arraysEqual(n,s)){if(t)return`
|
|
float ${r}(int row, int col) {
|
|
vec2 uv = (vec2(col, row) + halfCR) / vec2(${a}TexShape[1], ${a}TexShape[0]);
|
|
return sampleTexture(${a}, uv);
|
|
}
|
|
`;let c=s[0],h=s[1];return`
|
|
float ${r}(int row, int col) {
|
|
vec2 uv = (vec2(col, row) + halfCR) / vec2(${h}.0, ${c}.0);
|
|
return sampleTexture(${a}, uv);
|
|
}
|
|
`}let{newShape:i,keptDims:o}=w.squeezeShape(n),l=i;if(l.length<n.length){let c=$u(e,l),h=["row","col"];return`
|
|
${Fu(c,t)}
|
|
float ${r}(int row, int col) {
|
|
return ${r}(${Ou(h,o)});
|
|
}
|
|
`}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 d=s[0],u=s[1],p=To(a);return u===1?t?`
|
|
float ${r}(int row, int col) {
|
|
float index = dot(vec3(row, col, ${p}), vec3(${a}Shape[1], 1, 1));
|
|
vec2 uv = vec2(0.5, (index + 0.5) / float(${a}TexShape[0]));
|
|
return sampleTexture(${a}, uv);
|
|
}
|
|
`:`
|
|
float ${r}(int row, int col) {
|
|
float index = dot(vec3(row, col, ${p}), vec3(${n[1]}, 1, 1));
|
|
vec2 uv = vec2(0.5, (index + 0.5) / ${d}.0);
|
|
return sampleTexture(${a}, uv);
|
|
}
|
|
`:d===1?t?`
|
|
float ${r}(int row, int col) {
|
|
float index = dot(vec3(row, col, ${p}), vec3(${a}Shape[1], 1, 1));
|
|
vec2 uv = vec2((index + 0.5) / float(${a}TexShape[1]), 0.5);
|
|
return sampleTexture(${a}, uv);
|
|
}
|
|
`:`
|
|
float ${r}(int row, int col) {
|
|
float index = dot(vec3(row, col, ${p}), vec3(${n[1]}, 1, 1));
|
|
vec2 uv = vec2((index + 0.5) / ${u}.0, 0.5);
|
|
return sampleTexture(${a}, uv);
|
|
}
|
|
`:t?`
|
|
float ${r}(int row, int col) {
|
|
// Explicitly use integer operations as dot() only works on floats.
|
|
int index = row * ${a}Shape[1] + col + ${p};
|
|
vec2 uv = uvFromFlat(${a}TexShape[0], ${a}TexShape[1], index);
|
|
return sampleTexture(${a}, uv);
|
|
}
|
|
`:`
|
|
float ${r}(int row, int col) {
|
|
// Explicitly use integer operations as dot() only works on floats.
|
|
int index = row * ${n[1]} + col + ${p};
|
|
vec2 uv = uvFromFlat(${d}, ${u}, index);
|
|
return sampleTexture(${a}, uv);
|
|
}
|
|
`}function EK(e,t){let n=e.shapeInfo.logicalShape,a=e.name,r="get"+a.charAt(0).toUpperCase()+a.slice(1),s=e.shapeInfo.texShape,i=[Math.ceil(s[0]/2),Math.ceil(s[1]/2)];if(n[0]===1){let c=n.slice(1),h=[1,2],f=$u(e,c),m=["b","row","col"];return`
|
|
${k4(f,t)}
|
|
vec4 ${r}(int b, int row, int col) {
|
|
return ${r}(${Ou(m,h)});
|
|
}
|
|
`}let o=$n();if(t)return`
|
|
vec4 ${r}(int b, int row, int col) {
|
|
ivec2 packedTexShape = ivec2(ceil(float(${a}TexShape[0]) / 2.0), ceil(float(${a}TexShape[1]) / 2.0));
|
|
int valuesPerRow = int(ceil(float(${a}Shape[2]) / 2.0));
|
|
int texelsInBatch = valuesPerRow * int(ceil(float(${a}Shape[1]) / 2.0));
|
|
vec2 uv = packedUVfrom3D(
|
|
packedTexShape[0], packedTexShape[1], texelsInBatch, valuesPerRow, b, row, col);
|
|
return ${o.texture2D}(${a}, uv);
|
|
}
|
|
`;let l=i[0],d=i[1],u=Math.ceil(n[2]/2),p=u*Math.ceil(n[1]/2);return`
|
|
vec4 ${r}(int b, int row, int col) {
|
|
vec2 uv = packedUVfrom3D(
|
|
${l}, ${d}, ${p}, ${u}, b, row, col);
|
|
return ${o.texture2D}(${a}, uv);
|
|
}
|
|
`}function RK(e,t){let n=e.shapeInfo.logicalShape,a=e.name,r="get"+a.charAt(0).toUpperCase()+a.slice(1),s=n[1]*n[2],i=n[2],{newShape:o,keptDims:l}=w.squeezeShape(n),d=o;if(d.length<n.length){let m=$u(e,d),g=["row","col","depth"];return`
|
|
${Fu(m,t)}
|
|
float ${r}(int row, int col, int depth) {
|
|
return ${r}(${Ou(g,l)});
|
|
}
|
|
`}if(e.shapeInfo.isUniform)return`
|
|
float ${r}(int row, int col, int depth) {
|
|
int index = round(dot(vec3(row, col, depth),
|
|
vec3(${s}, ${i}, 1)));
|
|
${Du(e)}
|
|
}
|
|
`;let u=e.shapeInfo.texShape,p=u[0],c=u[1],h=e.shapeInfo.flatOffset;if(c===s&&h==null)return t?`
|
|
float ${r}(int row, int col, int depth) {
|
|
int stride1 = ${a}Shape[2];
|
|
float texR = float(row);
|
|
float texC = dot(vec2(col, depth), vec2(stride1, 1));
|
|
vec2 uv = (vec2(texC, texR) + halfCR) /
|
|
vec2(${a}TexShape[1], ${a}TexShape[0]);
|
|
return sampleTexture(${a}, uv);
|
|
}
|
|
`:`
|
|
float ${r}(int row, int col, int depth) {
|
|
float texR = float(row);
|
|
float texC = dot(vec2(col, depth), vec2(${i}, 1));
|
|
vec2 uv = (vec2(texC, texR) + halfCR) /
|
|
vec2(${c}.0, ${p}.0);
|
|
return sampleTexture(${a}, uv);
|
|
}
|
|
`;if(c===i&&h==null)return t?`
|
|
float ${r}(int row, int col, int depth) {
|
|
float texR = dot(vec2(row, col), vec2(${a}Shape[1], 1));
|
|
float texC = float(depth);
|
|
vec2 uv = (vec2(texC, texR) + halfCR) / vec2(${a}TexShape[1], ${a}TexShape[0]);
|
|
return sampleTexture(${a}, 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(${c}.0, ${p}.0);
|
|
return sampleTexture(${a}, uv);
|
|
}
|
|
`;let f=To(a);return t?`
|
|
float ${r}(int row, int col, int depth) {
|
|
// Explicitly use integer operations as dot() only works on floats.
|
|
int stride0 = ${a}Shape[1] * ${a}Shape[2];
|
|
int stride1 = ${a}Shape[2];
|
|
int index = row * ${s} + col * ${i} + depth + ${f};
|
|
vec2 uv = uvFromFlat(${a}TexShape[0], ${a}TexShape[1], index);
|
|
return sampleTexture(${a}, uv);
|
|
}
|
|
`:`
|
|
float ${r}(int row, int col, int depth) {
|
|
// Explicitly use integer operations as dot() only works on floats.
|
|
int index = row * ${s} + col * ${i} + depth + ${f};
|
|
vec2 uv = uvFromFlat(${p}, ${c}, index);
|
|
return sampleTexture(${a}, uv);
|
|
}
|
|
`}function MK(e,t){let n=e.name,a="get"+n.charAt(0).toUpperCase()+n.slice(1),r=$n();if(t)return`
|
|
vec4 ${a}(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 s=e.shapeInfo.logicalShape,i=s.length,o=e.shapeInfo.texShape,l=[Math.ceil(o[0]/2),Math.ceil(o[1]/2)],d=l[0],u=l[1],p=Math.ceil(s[i-1]/2),c=p*Math.ceil(s[i-2]/2),h="int b, int row, int col",f=`b * ${c} + (row / 2) * ${p} + (col / 2)`;for(let m=2;m<i-1;m++)h=`int b${m}, `+h,c*=s[i-m-1],f=`b${m} * ${c} + `+f;return`
|
|
vec4 ${a}(${h}) {
|
|
int index = ${f};
|
|
int texR = index / ${u};
|
|
int texC = index - texR * ${u};
|
|
vec2 uv = (vec2(texC, texR) + halfCR) / vec2(${u}, ${d});
|
|
return ${r.texture2D}(${n}, uv);
|
|
}
|
|
`}function FK(e,t){let n=e.shapeInfo.logicalShape,a=e.name,r="get"+a.charAt(0).toUpperCase()+a.slice(1),s=n[3],i=n[2]*s,o=n[1]*i,{newShape:l,keptDims:d}=w.squeezeShape(n);if(l.length<n.length){let A=$u(e,l),x=["row","col","depth","depth2"];return`
|
|
${Fu(A,t)}
|
|
float ${r}(int row, int col, int depth, int depth2) {
|
|
return ${r}(${Ou(x,d)});
|
|
}
|
|
`}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(${o}, ${i}, ${s}, 1)));
|
|
${Du(e)}
|
|
}
|
|
`;let u=e.shapeInfo.flatOffset,p=e.shapeInfo.texShape,c=p[0],h=p[1],f=`int stride2 = ${a}Shape[3];`,m=`int stride1 = ${a}Shape[2] * stride2;`,g=`int stride0 = ${a}Shape[1] * stride1;`;if(h===o&&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(${a}TexShape[1], ${a}TexShape[0]);
|
|
return sampleTexture(${a}, uv);
|
|
}
|
|
`:`
|
|
float ${r}(int row, int col, int depth, int depth2) {
|
|
float texR = float(row);
|
|
float texC =
|
|
dot(vec3(col, depth, depth2),
|
|
vec3(${i}, ${s}, 1));
|
|
vec2 uv = (vec2(texC, texR) + halfCR) /
|
|
vec2(${h}.0, ${c}.0);
|
|
return sampleTexture(${a}, uv);
|
|
}
|
|
`;if(h===s&&u==null)return t?`
|
|
float ${r}(int row, int col, int depth, int depth2) {
|
|
float texR = dot(vec3(row, col, depth),
|
|
vec3(${a}Shape[1] * ${a}Shape[2], ${a}Shape[2], 1));
|
|
float texC = float(depth2);
|
|
vec2 uv = (vec2(texC, texR) + halfCR) /
|
|
vec2(${a}TexShape[1], ${a}TexShape[0]);
|
|
return sampleTexture(${a}, 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, ${c}.0);
|
|
return sampleTexture(${a}, uv);
|
|
}
|
|
`;let y=To(a);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(${a}TexShape[0], ${a}TexShape[1], index + ${y});
|
|
return sampleTexture(${a}, uv);
|
|
}
|
|
`:`
|
|
float ${r}(int row, int col, int depth, int depth2) {
|
|
// Explicitly use integer operations as dot() only works on floats.
|
|
int index = row * ${o} + col * ${i} +
|
|
depth * ${s} + depth2;
|
|
vec2 uv = uvFromFlat(${c}, ${h}, index + ${y});
|
|
return sampleTexture(${a}, uv);
|
|
}
|
|
`}function DK(e){let t=e.shapeInfo.logicalShape,n=e.name,a="get"+n.charAt(0).toUpperCase()+n.slice(1),r=t[4],s=t[3]*r,i=t[2]*s,o=t[1]*i,{newShape:l,keptDims:d}=w.squeezeShape(t);if(l.length<t.length){let m=$u(e,l),g=["row","col","depth","depth2","depth3"];return`
|
|
${Fu(m)}
|
|
float ${a}(int row, int col, int depth, int depth2, int depth3) {
|
|
return ${a}(${Ou(g,d)});
|
|
}
|
|
`}if(e.shapeInfo.isUniform)return`
|
|
float ${a}(int row, int col, int depth, int depth2, int depth3) {
|
|
float index = dot(
|
|
vec4(row, col, depth, depth2),
|
|
vec4(${o}, ${i}, ${s}, ${r})) +
|
|
depth3;
|
|
${Du(e)}
|
|
}
|
|
`;let u=e.shapeInfo.flatOffset,p=e.shapeInfo.texShape,c=p[0],h=p[1];if(h===o&&u==null)return`
|
|
float ${a}(int row, int col, int depth, int depth2, int depth3) {
|
|
int texR = row;
|
|
float texC = dot(vec4(col, depth, depth2, depth3),
|
|
vec4(${i}, ${s}, ${r}, 1));
|
|
vec2 uv = (vec2(texC, texR) + halfCR) /
|
|
vec2(${h}.0, ${c}.0);
|
|
return sampleTexture(${n}, uv);
|
|
}
|
|
`;if(h===r&&u==null)return`
|
|
float ${a}(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, ${c}.0);
|
|
return sampleTexture(${n}, uv);
|
|
}
|
|
`;let f=To(n);return`
|
|
float ${a}(int row, int col, int depth, int depth2, int depth3) {
|
|
// Explicitly use integer operations as dot() only works on floats.
|
|
int index = row * ${o} + col * ${i} + depth * ${s} +
|
|
depth2 * ${r} + depth3 + ${f};
|
|
vec2 uv = uvFromFlat(${c}, ${h}, index);
|
|
return sampleTexture(${n}, uv);
|
|
}
|
|
`}function $K(e){let t=e.shapeInfo.logicalShape,n=e.name,a="get"+n.charAt(0).toUpperCase()+n.slice(1),{newShape:r,keptDims:s}=w.squeezeShape(t);if(r.length<t.length){let g=$u(e,r),y=["row","col","depth","depth2","depth3","depth4"];return`
|
|
${Fu(g)}
|
|
float ${a}(int row, int col, int depth,
|
|
int depth2, int depth3, int depth4) {
|
|
return ${a}(${Ou(y,s)});
|
|
}
|
|
`}let i=t[5],o=t[4]*i,l=t[3]*o,d=t[2]*l,u=t[1]*d;if(e.shapeInfo.isUniform)return`
|
|
float ${a}(int row, int col, int depth,
|
|
int depth2, int depth3, int depth4) {
|
|
int index = round(dot(
|
|
vec4(row, col, depth, depth2),
|
|
vec4(${u}, ${d}, ${l}, ${o})) +
|
|
dot(
|
|
vec2(depth3, depth4),
|
|
vec2(${i}, 1)));
|
|
${Du(e)}
|
|
}
|
|
`;let p=e.shapeInfo.flatOffset,c=e.shapeInfo.texShape,h=c[0],f=c[1];if(f===u&&p==null)return`
|
|
float ${a}(int row, int col, int depth,
|
|
int depth2, int depth3, int depth4) {
|
|
int texR = row;
|
|
float texC = dot(vec4(col, depth, depth2, depth3),
|
|
vec4(${d}, ${l}, ${o}, ${i})) +
|
|
float(depth4);
|
|
vec2 uv = (vec2(texC, texR) + halfCR) /
|
|
vec2(${f}.0, ${h}.0);
|
|
return sampleTexture(${n}, uv);
|
|
}
|
|
`;if(f===i&&p==null)return`
|
|
float ${a}(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=To(n);return`
|
|
float ${a}(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 * ${d} + depth * ${l} +
|
|
depth2 * ${o} + depth3 * ${i} + 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 OK(e,t){let n=e.name,a=n.charAt(0).toUpperCase()+n.slice(1),r="get"+a+"AtOutCoords",s=e.shapeInfo.logicalShape.length,i=t.logicalShape.length,o=w4(e.shapeInfo.logicalShape,t.logicalShape),l=yt(i),d=i-s,u,p=["x","y","z","w","u","v"];s===0?u="":i<2&&o.length>=1?u="coords = 0;":u=o.map(g=>`coords.${p[g+d]} = 0;`).join(`
|
|
`);let c="";i<2&&s>0?c="coords":c=e.shapeInfo.logicalShape.map((g,y)=>`coords.${p[y+d]}`).join(", ");let h="return outputValue;",f=w.sizeFromShape(e.shapeInfo.logicalShape)===1,m=w.sizeFromShape(t.logicalShape)===1;if(s===1&&!f&&!m)h=`
|
|
return vec4(outputValue.xy, outputValue.xy);
|
|
`;else if(f&&!m)i===1?h=`
|
|
return vec4(outputValue.x, outputValue.x, 0., 0.);
|
|
`:h=`
|
|
return vec4(outputValue.x);
|
|
`;else if(o.length){let g=s-2,y=s-1;o.indexOf(g)>-1&&o.indexOf(y)>-1?h="return vec4(outputValue.x);":o.indexOf(g)>-1?h="return vec4(outputValue.x, outputValue.y, outputValue.x, outputValue.y);":o.indexOf(y)>-1&&(h="return vec4(outputValue.xx, outputValue.zz);")}return`
|
|
vec4 ${r}() {
|
|
${l} coords = getOutputCoords();
|
|
${u}
|
|
vec4 outputValue = get${a}(${c});
|
|
${h}
|
|
}
|
|
`}function _K(e,t){let n=e.name,a=n.charAt(0).toUpperCase()+n.slice(1),r="get"+a+"AtOutCoords",s=t.texShape,i=e.shapeInfo.texShape,o=e.shapeInfo.logicalShape.length,l=t.logicalShape.length;if(!e.shapeInfo.isUniform&&o===l&&e.shapeInfo.flatOffset==null&&w.arraysEqual(i,s))return`
|
|
float ${r}() {
|
|
return sampleTexture(${n}, resultUV);
|
|
}
|
|
`;let d=yt(l),u=w4(e.shapeInfo.logicalShape,t.logicalShape),p=l-o,c,h=["x","y","z","w","u","v"];o===0?c="":l<2&&u.length>=1?c="coords = 0;":c=u.map(m=>`coords.${h[m+p]} = 0;`).join(`
|
|
`);let f="";return l<2&&o>0?f="coords":f=e.shapeInfo.logicalShape.map((m,g)=>`coords.${h[g+p]}`).join(", "),`
|
|
float ${r}() {
|
|
${d} coords = getOutputCoords();
|
|
${c}
|
|
return get${a}(${f});
|
|
}
|
|
`}function yt(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:a,keptDims:r}=w.squeezeShape(t),s=t.length,i=e&&s===3&&t[0]===1,o=i?t.slice(1):a,l=!e&&s>1&&!w.arraysEqual(t,n)&&a.length<s||i;return{useSqueezeShape:l,uniformShape:l?o:t,keptDims:r}}function $u(e,t){let n=JSON.parse(JSON.stringify(e));return n.shapeInfo.logicalShape=t,n}function Ou(e,t){return t.map(n=>e[n]).join(", ")}function PK(e,t,n,a){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}}),s=r.map(x=>x.shapeInfo),i={logicalShape:a.shape,texShape:a.texData.texShape,isUniform:!1,isPacked:a.texData.isPacked,flatOffset:null},o=tK(r,i,t),l=e.createProgram(o),d=null,u=e.getUniformLocation(l,"NAN",!1);ne().getNumber("WEBGL_VERSION")===1&&(d=e.getUniformLocation(l,"INFINITY",!1));let p=!1,c={},h={},f={};for(let x=0;x<t.variableNames.length;x++){let b=t.variableNames[x];c[b]=e.getUniformLocation(l,b,p),c[`offset${b}`]=e.getUniformLocation(l,`offset${b}`,p),t.enableShapeUniforms&&(h[`${b}Shape`]=e.getUniformLocation(l,`${b}Shape`,p),f[`${b}TexShape`]=e.getUniformLocation(l,`${b}TexShape`,p))}let m,g,y;t.enableShapeUniforms&&(m=e.getUniformLocation(l,"outShape",p),y=e.getUniformLocation(l,"outShapeStrides",p),g=e.getUniformLocation(l,"outTexShape",p));let A=[];return t.customUniforms&&t.customUniforms.forEach((x,b)=>{A[b]=e.getUniformLocation(l,x.name,p)}),{program:t,source:o,webGLProgram:l,uniformLocations:c,customUniformLocations:A,inShapeInfos:s,outShapeInfo:i,infLoc:d,nanLoc:u,inShapesLocations:h,inTexShapesLocations:f,outShapeLocation:m,outShapeStridesLocation:y,outTexShapeLocation:g}}function S4(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,a)=>{let r=n.logicalShape,s=t[a],i=s.shape;if(!w.arraysEqual(r,i))throw Error(`Binary was compiled with different shapes than the current args. Shapes ${r} and ${i} must match`);if(n.isUniform&&s.isUniform)return;let o=n.texShape,l=s.isUniform?null:s.texData.texShape;if(!w.arraysEqual(o,l))throw Error(`Binary was compiled with different texture shapes than the current args. Shape ${o} and ${l} must match`)})}function zK(e,t,n,a,r){t.program.enableShapeUniforms||(S4(t.inShapeInfos,n),S4([t.outShapeInfo],[a]));let s=a.texData.texture,i=a.texData.texShape;a.texData.isPacked?e.setOutputPackedMatrixTexture(s,i[0],i[1]):e.setOutputMatrixTexture(s,i[0],i[1]),e.setProgram(t.webGLProgram),ne().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,d)=>{let u=t.program.variableNames[d],p=t.uniformLocations[u],c=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]),p!=null){if(l.isUniform){if(w.sizeFromShape(l.shape)<2)e.gl.uniform1f(p,l.uniformValues[0]);else{let m=l.uniformValues;m instanceof Float32Array||(m=new Float32Array(m)),e.gl.uniform1fv(p,m)}return}l.texData.slice!=null&&c!=null&&e.gl.uniform1i(c,l.texData.slice.flatOffset),e.setInputMatrixTexture(l.texData.texture,p,d)}});let o=t.outShapeLocation;if(o)switch(a.shape.length){case 1:e.gl.uniform1iv(o,new Int32Array(a.shape));break;case 2:e.gl.uniform2iv(o,new Int32Array(a.shape));break;case 3:e.gl.uniform3iv(o,new Int32Array(a.shape));break;case 4:e.gl.uniform4iv(o,new Int32Array(a.shape));break;default:break}if(t.outShapeStridesLocation){let l=w.computeStrides(a.shape);switch(a.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,a.texData.texShape[0],a.texData.texShape[1]),t.program.customUniforms&&r&&t.program.customUniforms.forEach((l,d)=>{let u=t.customUniformLocations[d],p=r[d];if(l.type==="float")e.gl.uniform1fv(u,p);else if(l.type==="vec2")e.gl.uniform2fv(u,p);else if(l.type==="vec3")e.gl.uniform3fv(u,p);else if(l.type==="vec4")e.gl.uniform4fv(u,p);else if(l.type==="int")e.gl.uniform1iv(u,p);else if(l.type==="ivec2")e.gl.uniform2iv(u,p);else if(l.type==="ivec3")e.gl.uniform3iv(u,p);else if(l.type==="ivec4")e.gl.uniform4iv(u,p);else throw Error(`uniform type ${l.type} is not supported yet.`)}),e.executeProgram()}function LK(e,t,n){let a="";t.concat(n).forEach(i=>{let o=i.texData!=null&&i.texData.slice!=null&&i.texData.slice.flatOffset>0;if(e.enableShapeUniforms&&!i.isUniform){let l=i.texData.texShape,{useSqueezeShape:d,uniformShape:u,keptDims:p}=P2(e.packedInputs,i.shape,l),c="",h="",f="";if(u.length===1&&e.packedInputs){let v=[Math.ceil(l[0]/2),Math.ceil(l[1]/2)];c=`${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=i.shape.length,g=u.length===2&&w.arraysEqual(i.shape,l),y=w.sizeFromShape(i.shape)===1,A=E.getBroadcastDims(i.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}`;a+=`${m}_${x}_${d?p:""}_${u.length}_${y}_${A}_${g}_${c}_${h}_${f}_${b}_${o}`}else{let l=i.isUniform?"uniform":i.texData.texShape;a+=`${i.shape}_${l}_${o}`}});let r=e.userCode,s=e.constructor.name;return s+="_"+a+"_"+r+`${ne().getNumber("WEBGL_VERSION")}`,s}function Ra(e){return ne().getBool("WEBGL_USE_SHAPES_UNIFORMS")&&e<=4}var WK=class{constructor(e){this.variableNames=["A"],this.packedInputs=!1,this.packedOutput=!0,this.outPackingScheme=Dp.DENSE,this.customUniforms=[{name:"texShape",type:"ivec2"}];let t=$n();this.outputShape=e,this.enableShapeUniforms=Ra(this.outputShape.length),this.userCode=`
|
|
ivec3 outCoordsFromFlatIndex(int index) {
|
|
${this.enableShapeUniforms?gf(["r","c","d"],e):No(["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;
|
|
}
|
|
`}},BK=class{constructor(e){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outPackingScheme=Dp.DENSE,this.customUniforms=[{name:"texShape",type:"ivec2"}];let t=$n();this.outputShape=e,this.enableShapeUniforms=Ra(this.outputShape.length),this.userCode=`
|
|
ivec3 outCoordsFromFlatIndex(int index) {
|
|
${this.enableShapeUniforms?gf(["r","c","d"],e):No(["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;
|
|
}
|
|
`}},VK=class{constructor(e){this.variableNames=["A"],this.outTexUsage=Ca.DOWNLOAD;let t=$n();this.outputShape=e,this.userCode=`
|
|
${v4}
|
|
|
|
void main() {
|
|
float x = getAAtOutCoords();
|
|
${t.output} = encode_float(x);
|
|
}
|
|
`}},UK=class{constructor(e){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!1,this.outTexUsage=Ca.DOWNLOAD;let t=$n();this.outputShape=e,this.userCode=`
|
|
${v4}
|
|
|
|
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=Ra(this.outputShape.length);let a="result";t&&(a="floor(result * 255. + 0.5)"),this.userCode=`
|
|
${this.enableShapeUniforms?_2():O2(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(${a}, 0., 0., 0.);
|
|
}
|
|
`}},GK=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=Ra(this.outputShape.length);let a="",r="result";t&&(r="floor(result * 255. + 0.5)");for(let s=0;s<=1;s++)for(let i=0;i<=1;i++){let o=s*2+i;a+=`
|
|
localCoords = coords;
|
|
if(localCoords[2] + ${i} < ${this.enableShapeUniforms?"outShape[2]":`${e[2]}`}) {
|
|
localCoords[2] += ${i};
|
|
if (localCoords[1] + ${s} < ${this.enableShapeUniforms?"outShape[1]":`${e[1]}`}) {
|
|
localCoords[1] += ${s};
|
|
|
|
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[${o}] = values[0];
|
|
} else if (offset == 1) {
|
|
result[${o}] = values[1];
|
|
} else if (offset == 2) {
|
|
result[${o}] = values[2];
|
|
} else {
|
|
result[${o}] = values[3];
|
|
}
|
|
}
|
|
}
|
|
`}this.userCode=`
|
|
${this.enableShapeUniforms?_2():O2(e)}
|
|
|
|
void main() {
|
|
ivec3 coords = getOutputCoords();
|
|
|
|
vec4 result = vec4(0.);
|
|
int flatIndex, r, c, offset;
|
|
ivec3 localCoords;
|
|
vec2 uv;
|
|
vec4 values;
|
|
|
|
${a}
|
|
|
|
${n.output} = ${r};
|
|
}
|
|
`}},N4={};ze(N4,{bindVertexProgramAttributeStreams:()=>O4,createBufferFromOutputTexture:()=>z4,createFloat16MatrixTexture:()=>M4,createFloat16PackedMatrixTexture:()=>$4,createFloat32MatrixTexture:()=>R4,createIndexBuffer:()=>E4,createPackedMatrixTexture:()=>D4,createUnsignedBytesMatrixTexture:()=>F4,createVertexBuffer:()=>C4,createVertexShader:()=>T4,downloadByteEncodedFloatMatrixFromOutputTexture:()=>W4,downloadFloat32MatrixFromBuffer:()=>L4,downloadMatrixFromPackedOutputTexture:()=>V4,downloadPackedMatrixFromBuffer:()=>B4,getInternalFormatForFloat16MatrixTexture:()=>L2,getInternalFormatForFloat16PackedMatrixTexture:()=>V2,getInternalFormatForFloat32MatrixTexture:()=>z2,getInternalFormatForPackedMatrixTexture:()=>B2,getInternalFormatForUnsignedBytesMatrixTexture:()=>W2,uploadDenseMatrixToTexture:()=>_4,uploadPixelDataToTexture:()=>P4});function T4(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 Q6(e,n)}function C4(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 a4(e,t)}function E4(e){let t=new Uint16Array([0,1,2,2,1,3]);return r4(e,t)}function zp(e,t,n,a,r,s){i4(t,n);let i=s4(e),o=e.TEXTURE_2D;return Se(e,()=>e.bindTexture(o,i)),Se(e,()=>e.texParameteri(o,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE)),Se(e,()=>e.texParameteri(o,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE)),Se(e,()=>e.texParameteri(o,e.TEXTURE_MIN_FILTER,e.NEAREST)),Se(e,()=>e.texParameteri(o,e.TEXTURE_MAG_FILTER,e.NEAREST)),Se(e,()=>e.texImage2D(o,0,a,t,n,0,r,s,null)),Se(e,()=>e.bindTexture(e.TEXTURE_2D,null)),i}function z2(e){return e.internalFormatFloat}function R4(e,t,n,a){let[r,s]=$p(t,n);return zp(e,r,s,z2(a),a.textureFormatFloat,e.FLOAT)}function L2(e){return e.internalFormatHalfFloat}function M4(e,t,n,a){let[r,s]=$p(t,n);return zp(e,r,s,L2(a),a.textureFormatFloat,a.textureTypeHalfFloat)}function W2(e){return e.downloadTextureFormat}function F4(e,t,n,a){let[r,s]=$p(t,n);return zp(e,r,s,W2(a),e.RGBA,e.UNSIGNED_BYTE)}function B2(e){return e.internalFormatPackedFloat}function D4(e,t,n,a){let[r,s]=Ru(t,n);return zp(e,r,s,B2(a),e.RGBA,e.FLOAT)}function V2(e){return e.internalFormatPackedHalfFloat}function $4(e,t,n,a){let[r,s]=Ru(t,n);return zp(e,r,s,V2(a),e.RGBA,a.textureTypeHalfFloat)}function O4(e,t,n){let a=0,r=3*4,s=3*4+2*4;return Se(e,()=>e.bindBuffer(e.ARRAY_BUFFER,n)),M2(e,t,"clipSpacePos",n,3,s,a)&&M2(e,t,"uv",n,2,s,r)}function _4(e,t,n,a,r,s){Se(e,()=>e.bindTexture(e.TEXTURE_2D,t));let i,o,l;r instanceof Uint8Array?(i=new Uint8Array(n*a*4),o=e.UNSIGNED_BYTE,l=e.RGBA):(i=new Float32Array(n*a*4),o=e.FLOAT,l=s.internalFormatPackedFloat),i.set(r),Se(e,()=>e.texImage2D(e.TEXTURE_2D,0,l,n,a,0,e.RGBA,o,i)),Se(e,()=>e.bindTexture(e.TEXTURE_2D,null))}function P4(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 z4(e,t,n,a){let r=e.createBuffer();Se(e,()=>e.bindBuffer(e.PIXEL_PACK_BUFFER,r));let s=4*4*t*n;return Se(e,()=>e.bufferData(e.PIXEL_PACK_BUFFER,s,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 L4(e,t,n){let a=e,r=new Float32Array(n);return a.bindBuffer(a.PIXEL_PACK_BUFFER,t),a.getBufferSubData(a.PIXEL_PACK_BUFFER,0,r),a.bindBuffer(a.PIXEL_PACK_BUFFER,null),r}function W4(e,t,n,a){let[r,s]=$p(t,n),i=4,o=new Uint8Array(WX(t*n,i));return Se(e,()=>e.readPixels(0,0,r,s,a.downloadTextureFormat,e.UNSIGNED_BYTE,o)),new Float32Array(o.buffer)}function B4(e,t,n,a,r,s,i,o){let l=e,d=new Float32Array(BX(s,i));return l.bindBuffer(l.PIXEL_PACK_BUFFER,t),l.getBufferSubData(l.PIXEL_PACK_BUFFER,0,d),l.bindBuffer(l.PIXEL_PACK_BUFFER,null),d}function V4(e,t,n){let a=new Float32Array(t*n*4);return Se(e,()=>e.readPixels(0,0,n,t,e.RGBA,e.FLOAT,a)),a}var yf=class{constructor(e){this.outputTexture=null,this.program=null,this.disposed=!1,this.vertexAttrsAreBound=!1,this.itemsToPoll=[];let t=ne().getNumber("WEBGL_VERSION");e!=null?(this.gl=e,lf(t,e)):this.gl=Nr(t);let n="WEBGL_color_buffer_float",a="EXT_color_buffer_half_float";if(ne().getNumber("WEBGL_VERSION")===1){let r="OES_texture_float",s="OES_texture_half_float";if(this.textureFloatExtension=Op(this.gl,r),Ea(this.gl,s))this.textureHalfFloatExtension=Op(this.gl,s);else if(ne().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),Ea(this.gl,a))this.colorBufferHalfFloatExtension=Op(this.gl,a);else if(ne().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",Ea(this.gl,n))this.colorBufferFloatExtension=this.gl.getExtension(n);else if(Ea(this.gl,a))this.colorBufferHalfFloatExtension=this.gl.getExtension(a);else throw new Error("GL context does not support color renderable floats");this.vertexBuffer=C4(this.gl),this.indexBuffer=E4(this.gl),this.framebuffer=o4(this.gl),this.textureConfig=R2(this.gl,this.textureHalfFloatExtension)}get debug(){return ne().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(),R4(this.gl,e,t,this.textureConfig)}createFloat16MatrixTexture(e,t){return this.throwIfDisposed(),M4(this.gl,e,t,this.textureConfig)}createUnsignedBytesMatrixTexture(e,t){return this.throwIfDisposed(),F4(this.gl,e,t,this.textureConfig)}uploadPixelDataToTexture(e,t){this.throwIfDisposed(),P4(this.gl,e,t)}uploadDenseMatrixToTexture(e,t,n,a){this.throwIfDisposed(),_4(this.gl,e,t,n,a,this.textureConfig)}createFloat16PackedMatrixTexture(e,t){return this.throwIfDisposed(),$4(this.gl,e,t,this.textureConfig)}createPackedMatrixTexture(e,t){return this.throwIfDisposed(),D4(this.gl,e,t,this.textureConfig)}deleteMatrixTexture(e){this.throwIfDisposed(),this.outputTexture===e&&(F2(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,a,r,s){return B4(this.gl,e,t,n,a,r,s,this.textureConfig)}downloadFloat32MatrixFromBuffer(e,t){return L4(this.gl,e,t)}createBufferFromTexture(e,t,n){this.bindTextureToFrameBuffer(e);let a=z4(this.gl,t,n,this.textureConfig);return this.unbindTextureToFrameBuffer(),a}createAndWaitForFence(){let e=this.createFence(this.gl);return this.pollFence(e)}createFence(e){let t,n;if(ne().getBool("WEBGL_FENCE_API_ENABLED")){let a=e,r=a.fenceSync(a.SYNC_GPU_COMMANDS_COMPLETE,0);e.flush(),n=()=>{let s=a.clientWaitSync(r,0,0);return s===a.ALREADY_SIGNALED||s===a.CONDITION_SATISFIED},t=r}else ne().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")>0?(t=this.beginQuery(),this.endQuery(),n=()=>this.isQueryAvailable(t,ne().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION"))):n=()=>!0;return{query:t,isFencePassed:n}}downloadMatrixFromPackedTexture(e,t,n){return this.downloadMatrixDriver(e,()=>V4(this.gl,t,n))}createProgram(e){this.throwIfDisposed();let t=this.gl,n=e4(t,e);this.vertexShader==null&&(this.vertexShader=T4(t));let a=t4(t);return Se(t,()=>t.attachShader(a,this.vertexShader)),Se(t,()=>t.attachShader(a,n)),n4(t,a),this.debug&&df(t,a),this.vertexAttrsAreBound||(this.setProgram(a),this.vertexAttrsAreBound=O4(t,this.program,this.vertexBuffer)),a}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&&df(this.gl,this.program),Se(this.gl,()=>this.gl.useProgram(e))}getUniformLocation(e,t,n=!0){return this.throwIfDisposed(),n?u4(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[a,r]=Ru(t,n);this.setOutputMatrixTextureDriver(e,a,r)}setOutputMatrixWriteRegion(e,t,n,a){this.setOutputMatrixWriteRegionDriver(n,e,a,t)}setOutputPackedMatrixWriteRegion(e,t,n,a){throw new Error("setOutputPackedMatrixWriteRegion not implemented.")}debugValidate(){this.program!=null&&df(this.gl,this.program),_p(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=Op(this.gl,ne().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(ne().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")===2){let n=this.gl,a=this.getQueryTimerExtensionWebGL2(),r=n.createQuery();return n.beginQuery(a.TIME_ELAPSED_EXT,r),r}let e=this.getQueryTimerExtensionWebGL1(),t=e.createQueryEXT();return e.beginQueryEXT(e.TIME_ELAPSED_EXT,t),t}endQuery(){if(ne().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,ne().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION"))),this.getQueryTime(e,ne().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,a=this.getQueryTimerExtensionWebGL2(),r=n.getQueryParameter(e,n.QUERY_RESULT_AVAILABLE);return this.disjoint==null&&(this.disjoint=this.gl.getParameter(a.GPU_DISJOINT_EXT)),r&&!this.disjoint}else{let n=this.getQueryTimerExtensionWebGL1(),a=n.getQueryObjectEXT(e,n.QUERY_RESULT_AVAILABLE_EXT);return this.disjoint==null&&(this.disjoint=this.gl.getParameter(n.GPU_DISJOINT_EXT)),a&&!this.disjoint}}pollFence(e){return new Promise(t=>{this.addItemToPoll(()=>e.isFencePassed(),()=>t())})}pollItems(){let e=HK(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(),pf(this.gl,e,this.framebuffer),this.debug&&_p(this.gl)}unbindTextureToFrameBuffer(){this.outputTexture!=null?(pf(this.gl,this.outputTexture,this.framebuffer),this.debug&&_p(this.gl)):F2(this.gl,this.framebuffer)}downloadMatrixDriver(e,t){this.bindTextureToFrameBuffer(e);let n=t();return this.unbindTextureToFrameBuffer(),n}setOutputMatrixTextureDriver(e,t,n){this.throwIfDisposed();let a=this.gl;pf(a,e,this.framebuffer),this.debug&&_p(a),this.outputTexture=e,Se(a,()=>a.viewport(0,0,t,n)),Se(a,()=>a.scissor(0,0,t,n))}setOutputMatrixWriteRegionDriver(e,t,n,a){this.throwIfDisposed(),Se(this.gl,()=>this.gl.scissor(e,t,n,a))}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 HK(e){let t=0;for(;t<e.length&&e[t]();++t);return t-1}var{addImpl:qK,bincountImpl:U4,bincountReduceImpl:XK,ceilImpl:KK,concatImpl:ZK,equalImpl:YK,expImpl:JK,expm1Impl:QK,floorImpl:eZ,gatherNdImpl:tZ,gatherV2Impl:nZ,greaterImpl:aZ,greaterEqualImpl:rZ,lessImpl:sZ,lessEqualImpl:iZ,linSpaceImpl:oZ,logImpl:lZ,maxImpl:uZ,maximumImpl:dZ,minimumImpl:pZ,multiplyImpl:cZ,negImpl:hZ,notEqualImpl:fZ,prodImpl:mZ,rangeImpl:gZ,rsqrtImpl:yZ,sigmoidImpl:AZ,simpleAbsImpl:j4,sliceImpl:xZ,sparseFillEmptyRowsImpl:bZ,sparseReshapeImpl:vZ,sparseSegmentReductionImpl:G4,sqrtImpl:wZ,stridedSliceImpl:kZ,stringNGramsImpl:IZ,stringSplitImpl:SZ,stringToHashBucketFastImpl:NZ,subImpl:TZ,tileImpl:CZ,topKImpl:EZ,transposeImpl:U2,uniqueImpl:RZ}=Hw;function H4(e,t){return["x","y","z","w","u","v"].slice(0,t).map(n=>`${e}.${n}`)}function On(e,t){return t===1?[e]:H4(e,t)}function MZ(e,t){if(e===1)return"rc";let n="";for(let a=0;a<e;a++)n+=t[a],a<e-1&&(n+=",");return n}var FZ=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),a=yt(t),r=$Z(t,e,n),s=OZ(t,e[e.length-1],e[e.length-2],n),i=_Z(e,n);this.userCode=`
|
|
void main() {
|
|
${a} rc = getOutputCoords();
|
|
|
|
if(${r}) {
|
|
setOutput(vec4(0));
|
|
} else {
|
|
${s}
|
|
|
|
setOutput(vec4(${i}));
|
|
}
|
|
}
|
|
`}}};function DZ(e,t){let n=[];for(let a=0;a<=1;a++)for(let r=0;r<=1;r++){let s=`${a===0?"r":"rp1"}, ${r===0?"c":"cp1"}`;for(let i=2;i<e;i++)s=`${t[t.length-1-i]},`+s;n.push(s)}return n}function $Z(e,t,n){if(e===1)return`rc > ${t[0]}`;let a="";for(let r=e-2;r<e;r++)a+=`${n[r]} >= ${t[r]}`,r<e-1&&(a+="||");return a}function OZ(e,t,n,a){if(e===1)return"";let r=a.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 _Z(e,t){let n=e.length,a=DZ(n,t);return n===1?`getA(rc),
|
|
rc + 1 >= ${e[0]} ? 0. : getA(rc + 1),
|
|
0, 0`:`getA(${a[0]}),
|
|
cEdge ? 0. : getA(${a[1]}),
|
|
rEdge ? 0. : getA(${a[2]}),
|
|
rEdge || cEdge ? 0. : getA(${a[3]})`}var q4=class{constructor(e,t){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.customUniforms=[{name:"inputShape",type:"ivec3"}],this.outputShape=e,this.enableShapeUniforms=Ra(this.outputShape.length);let n="";for(let a=0;a<4;a++){let r="thisRC = rc;";a%2==1&&(r+="thisRC.z += 1;"),a>1&&(r+="thisRC.y += 1;"),n+=`
|
|
${r}
|
|
${a>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[${a}] =
|
|
getChannel(getA(inputRC.x, inputRC.y, inputRC.z), inputRCInnerDims);
|
|
${a>0?"}":""}
|
|
`}this.userCode=`
|
|
${PZ(t,this.enableShapeUniforms)}
|
|
${this.enableShapeUniforms?_2():O2(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 PZ(e,t){return`
|
|
ivec3 inputCoordsFromReshapedOutCoords(int index) {
|
|
${t?eK(["r","c","d"],"inputShape"):No(["r","c","d"],e)}
|
|
return ivec3(r, c, d);
|
|
}
|
|
`}var zZ=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 a=K4(t,n),r=Z4(e,a,n);r in this.freeTextures||(this.freeTextures[r]=[]),r in this.usedTextures||(this.usedTextures[r]=[]);let s=X4(e,a,this.gpgpu.gl,this.gpgpu.textureConfig,n);if(this.freeTextures[r].length>0){this.numFreeTextures--,this.numUsedTextures++,this._numBytesFree-=s,this.log();let o=this.freeTextures[r].shift();return this.usedTextures[r].push(o),o}let i;return a===bn.PACKED_2X2_FLOAT32?i=this.gpgpu.createPackedMatrixTexture(e[0],e[1]):a===bn.PACKED_2X2_FLOAT16?i=this.gpgpu.createFloat16PackedMatrixTexture(e[0],e[1]):a===bn.UNPACKED_FLOAT32?i=this.gpgpu.createFloat32MatrixTexture(e[0],e[1]):a===bn.UNPACKED_FLOAT16?i=this.gpgpu.createFloat16MatrixTexture(e[0],e[1]):a===bn.PACKED_4X1_UNSIGNED_BYTE&&(i=this.gpgpu.createUnsignedBytesMatrixTexture(e[0],e[1])),this.usedTextures[r].push(i),this.numUsedTextures++,this._numBytesAllocated+=s,this.log(),i}releaseTexture(e,t,n,a){if(this.freeTextures==null)return;let r=K4(n,a),s=Z4(t,r,a);s in this.freeTextures||(this.freeTextures[s]=[]);let i=X4(t,r,this.gpgpu.gl,this.gpgpu.textureConfig,a),o=ne().get("WEBGL_DELETE_TEXTURE_THRESHOLD");o!==-1&&this._numBytesAllocated>o?(this.gpgpu.deleteMatrixTexture(e),this._numBytesAllocated-=i):(this.freeTextures[s].push(e),this.numFreeTextures++,this._numBytesFree+=i),this.numUsedTextures--;let l=this.usedTextures[s],d=l.indexOf(e);if(d<0)throw new Error("Cannot release a texture that was never provided by this texture manager");l.splice(d,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 LZ(e,t){let n=e;if(t===n.R32F)return 4;if(t===n.R16F)return 2;if(t===n.RGBA32F||t===e.RGBA)return 16;if(t===n.RGBA16F)return 8;throw new Error(`Unknown internal format ${t}`)}function X4(e,t,n,a,r){let s=WZ(t,a),i;if(r){let[l,d]=Ru(e[0],e[1]);i=l*d}else{let[l,d]=$p(e[0],e[1]);i=l*d}let o=LZ(n,s);return i*o}function WZ(e,t){switch(e){case bn.PACKED_2X2_FLOAT32:return B2(t);case bn.PACKED_2X2_FLOAT16:return V2(t);case bn.UNPACKED_FLOAT32:return z2(t);case bn.UNPACKED_FLOAT16:return L2(t);case bn.PACKED_4X1_UNSIGNED_BYTE:return W2(t);default:throw new Error(`Unknown physical texture type ${e}`)}}function BZ(e){return ne().getBool("WEBGL_RENDER_FLOAT32_ENABLED")?e?bn.PACKED_2X2_FLOAT32:bn.UNPACKED_FLOAT32:e?bn.PACKED_2X2_FLOAT16:bn.UNPACKED_FLOAT16}function K4(e,t){if(e===Ca.UPLOAD)return bn.PACKED_2X2_FLOAT32;if(e===Ca.RENDER||e==null)return BZ(t);if(e===Ca.DOWNLOAD||e===Ca.PIXELS)return bn.PACKED_4X1_UNSIGNED_BYTE;throw new Error(`Unknown logical texture type ${e}`)}function Z4(e,t,n){return`${e[0]}_${e[1]}_${t}_${n}`}var Fs=class{constructor(e,t){this.variableNames=["A"],this.outputShape=e,this.enableShapeUniforms=Ra(this.outputShape.length),this.userCode=`
|
|
float unaryOperation(float x) {
|
|
${t}
|
|
}
|
|
|
|
void main() {
|
|
float x = getAAtOutCoords();
|
|
float y = unaryOperation(x);
|
|
|
|
setOutput(y);
|
|
}
|
|
`}},lr="if (isnan(x)) return x;",VZ="return x;",Y4="return abs(x);",UZ="return (x >= 0.0) ? x : (exp(x) - 1.0);",jZ=lr+`
|
|
return (x < 0.0) ? 0.0 : x;
|
|
`,GZ=lr+`
|
|
return (x < 0.0) ? 0.0 : min(6.0, x);
|
|
`,Af="return x;",HZ="return 1.0 / (1.0 + exp(-1.0 * x));",qZ="return x;",XZ=`
|
|
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;
|
|
`,KZ=`
|
|
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;
|
|
`,ZZ=`
|
|
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;
|
|
`,YZ="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=Ra(this.outputShape.length),this.userCode=`
|
|
vec4 unaryOperation(vec4 x) {
|
|
${t}
|
|
}
|
|
|
|
void main() {
|
|
vec4 x = getAAtOutCoords();
|
|
vec4 y = unaryOperation(x);
|
|
|
|
setOutput(y);
|
|
}
|
|
`}},JZ=class{constructor(e){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!1,this.outputShape=e;let t=e.length,n=On("rc",t),a=yt(t),r=MZ(t,n),s=n.slice(-2),i=t<=1?"rc":`vec2(${s.join(",")})`;this.userCode=`
|
|
void main() {
|
|
${a} rc = getOutputCoords();
|
|
vec4 packedInput = getA(${r});
|
|
|
|
setOutput(getChannel(packedInput, ${i}));
|
|
}
|
|
`}},QZ=xr.whereImpl,eY=1e-7,tY=1e-4,j2={};function nY(e){return e in j2||(j2[e]={}),j2[e]}var aY=ne().getNumber("CPU_HANDOFF_SIZE_THRESHOLD"),rY=600;function sY(){return ne().global.screen==null?1024:ne().global.screen.height*ne().global.screen.width*window.devicePixelRatio*rY/1024/1024}var Pu=class extends fd{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,!ne().getBool("HAS_WEBGL"))throw new Error("WebGL is not supported on this device");if(e==null){let t=Nr(ne().getNumber("WEBGL_VERSION"));this.binaryCache=nY(ne().getNumber("WEBGL_VERSION")),this.gpgpu=new yf(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 zZ(this.gpgpu),this.numMBBeforeWarning=sY(),this.texData=new Oc(this,sa())}nextDataId(){return Pu.nextDataId++}numDataIds(){return this.texData.numDataIds()-this.pendingDeletes}write(e,t,n){if((ne().getBool("WEBGL_CHECK_NUMERICAL_PROBLEMS")||ne().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 a={id:this.nextDataId()};return this.texData.set(a,{shape:t,dtype:n,values:e,usage:Ca.UPLOAD,refCount:1}),a}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,a,r){if(ne().getBool("DEBUG")&&this.checkNumericalProblems(t),a==="complex64")throw new Error("Cannot write to a complex64 dtype. Please use tf.complex(real, imag).");this.texData.set(e,{shape:n,dtype:a,values:t,usage:Ca.UPLOAD,refCount:r})}disposeIntermediateTensorInfo(e){this.disposeData(e.dataId)}readSync(e){let t=this.texData.get(e),{values:n,dtype:a,complexTensorInfos:r,slice:s,shape:i,isPacked:o}=t;if(s!=null){let p;o?p=new _u(i,Af):p=new Fs(i,Af);let c=this.runWebGLProgram(p,[{dataId:e,shape:i,dtype:a}],a),h=this.readSync(c.dataId);return this.disposeIntermediateTensorInfo(c),h}if(n!=null)return this.convertAndCacheOnCPU(e);if(a==="string")return n;let l=this.activeTimers!=null,d;l&&(d=w.now());let u;if(a==="complex64"){let p=this.readSync(r.real.dataId),c=this.readSync(r.imag.dataId);u=E.mergeRealAndImagArrays(p,c)}else u=this.getValuesFromTexture(e);return l&&(this.downloadWaitMs+=w.now()-d),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:a,slice:r,dtype:s,complexTensorInfos:i,isPacked:o}=t;if(r!=null){let h;o?h=new _u(a,Af):h=new Fs(a,Af);let f=this.runWebGLProgram(h,[{dataId:e,shape:a,dtype:s}],s),m=this.read(f.dataId);return this.disposeIntermediateTensorInfo(f),m}if(n!=null)return this.convertAndCacheOnCPU(e);if(!ne().getBool("WEBGL_DOWNLOAD_FLOAT_ENABLED")&&ne().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,d;if(s!=="complex64"&&ne().get("WEBGL_BUFFER_SUPPORTED")){d=this.decode(e);let h=this.texData.get(d.dataId);l=this.gpgpu.createBufferFromTexture(h.texture,...uf(a))}this.pendingRead.set(e,[]),s!=="complex64"&&await this.gpgpu.createAndWaitForFence();let u;if(s==="complex64"){let h=await Promise.all([this.read(i.real.dataId),this.read(i.imag.dataId)]),f=h[0],m=h[1];u=E.mergeRealAndImagArrays(f,m)}else if(l==null)u=this.getValuesFromTexture(e);else{let h=w.sizeFromShape(a);u=this.gpgpu.downloadFloat32MatrixFromBuffer(l,h)}if(d!=null&&this.disposeIntermediateTensorInfo(d),l!=null){let h=this.gpgpu.gl;Se(h,()=>h.deleteBuffer(l))}let p=this.convertAndCacheOnCPU(e,u),c=this.pendingRead.get(e);return this.pendingRead.delete(e),c.forEach(h=>h(p)),this.pendingDisposal.has(e)&&(this.pendingDisposal.delete(e),this.disposeData(e)&&sa().removeDataId(e,this),this.pendingDeletes--),p}bufferSync(e){let t=this.readSync(e.dataId),n=t;if(e.dtype==="string")try{n=t.map(a=>w.decodeString(a))}catch(a){throw new Error("Failed to decode encoded string bytes into utf-8")}return Ge(e.shape,e.dtype,n)}checkNumericalProblems(e){if(e!=null)for(let t=0;t<e.length;t++){let n=e[t];if(!Y6(n))throw ne().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:a}=this.texData.get(e),r=w.sizeFromShape(t);if(ne().getBool("WEBGL_DOWNLOAD_FLOAT_ENABLED")){let p=this.decode(e),c=this.texData.get(p.dataId),h=this.gpgpu.downloadMatrixFromPackedTexture(c.texture,...uf(t)).subarray(0,r);return this.disposeIntermediateTensorInfo(p),h}let s=ne().getBool("WEBGL_PACK")&&a===!0,i=s?cf(t):t,o=s?new UK(i):new VK(i),l=this.runWebGLProgram(o,[{shape:i,dtype:n,dataId:e}],"float32"),d=this.texData.get(l.dataId),u=this.gpgpu.downloadByteEncodedFloatMatrixFromOutputTexture(d.texture,d.texShape[0],d.texShape[1]).subarray(0,r);return this.disposeIntermediateTensorInfo(l),u}timerAvailable(){return ne().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE")>0}async time(e){let t=this.activeTimers,n=[],a=!1;this.programTimersStack==null?(this.programTimersStack=n,a=!0):this.activeTimers.push(n),this.activeTimers=n,e();let r=w.flatten(this.activeTimers.map(o=>o.query)).filter(o=>o!=null),s=w.flatten(this.activeTimers.map(o=>o.name)).filter(o=>o!=null);this.activeTimers=t,a&&(this.programTimersStack=null);let i={uploadWaitMs:this.uploadWaitMs,downloadWaitMs:this.downloadWaitMs,kernelMs:null,wallMs:null};if(ne().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE")>0){let o=await Promise.all(r);i.kernelMs=w.sum(o),i.getExtraProfileInfo=()=>o.map((l,d)=>({name:s[d],ms:l})).map(l=>`${l.name}: ${l.ms}`).join(", ")}else i.kernelMs={error:"WebGL query timers are not supported in this environment."};return this.uploadWaitMs=0,this.downloadWaitMs=0,i}memory(){return{unreliable:!1,numBytesInGPU:this.numBytesInGPU,numBytesInGPUAllocated:this.textureManager.numBytesAllocated,numBytesInGPUFree:this.textureManager.numBytesFree}}startTimer(){return ne().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE")>0?this.gpgpu.beginQuery():{startMs:w.now(),endMs:null}}endTimer(e){return ne().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE")>0?(this.gpgpu.endQuery(),e):(e.endMs=w.now(),e)}async getQueryTime(e){if(ne().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:a,usage:r,isPacked:s,slice:i}=this.texData.get(e),o=i&&i.origDataId||e,l=this.dataRefCount.get(o);l>1?this.dataRefCount.set(o,l-1):(this.dataRefCount.delete(o),t!=null&&(this.numBytesInGPU-=this.computeBytes(a,n),this.textureManager.releaseTexture(t,a,r,s)));let d=this.texData.get(e);d.texture=null,d.texShape=null,d.isPacked=!1,d.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 ne().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){E.warn("tf.where() in webgl locks the UI thread. Call tf.whereAsync() instead");let t=e.dataSync();return QZ(e.shape,t)}packedUnaryOp(e,t,n){let a=new _u(e.shape,t),r=this.compileAndRun(a,[e],n);return sa().makeTensorFromDataId(r.dataId,r.shape,r.dtype)}abs(e){if(this.shouldExecuteOnCPU([e])&&e.dtype!=="complex64"){let a=j4(this.texData.get(e.dataId).values);return this.makeOutput(e.shape,e.dtype,a)}if(ne().getBool("WEBGL_PACK_UNARY_OPERATIONS"))return this.packedUnaryOp(e,Y4,e.dtype);let t=new Fs(e.shape,Y4),n=this.compileAndRun(t,[e]);return sa().makeTensorFromDataId(n.dataId,n.shape,n.dtype)}makeTensorInfo(e,t,n){let a;if(t==="string"&&n!=null&&n.length>0&&w.isString(n[0])){let r=n.map(s=>w.encodeString(s));a=this.write(r,e,t)}else a=this.write(n,e,t);return this.texData.get(a).usage=null,{dataId:a,shape:e,dtype:t}}makeOutput(e,t,n){let{dataId:a}=this.makeTensorInfo(e,t,n);return sa().makeTensorFromDataId(a,e,t,this)}unpackTensor(e){let t=new JZ(e.shape);return this.runWebGLProgram(t,[e],e.dtype)}packTensor(e){let t=new FZ(e.shape),n=!0;return this.runWebGLProgram(t,[e],e.dtype,null,n)}packedReshape(e,t){let n=[Io(e.shape),...So(e.shape)],a={dtype:e.dtype,shape:n,dataId:e.dataId},r=[Io(t),...So(t)],s=new q4(r,n),i=!0,o=[n],l=this.runWebGLProgram(s,[a],e.dtype,o,i);return{dataId:l.dataId,shape:t,dtype:l.dtype}}decode(e){let t=this.texData.get(e),{isPacked:n,shape:a,dtype:r}=t,s=cf(a),i,o=uf(s);n?i=new BK(s):i=new WK(s);let l=!0,d=[o],u=this.runWebGLProgram(i,[{shape:s,dtype:r,dataId:e}],r,d,l);return{dtype:r,shape:a,dataId:u.dataId}}runWebGLProgram(e,t,n,a,r=!1){let s=this.makeTensorInfo(e.outputShape,n),i=this.texData.get(s.dataId);if(e.packedOutput&&(i.isPacked=!0),e.outPackingScheme===Dp.DENSE){let m=uf(e.outputShape);i.texShape=m.map(g=>g*2)}if(e.outTexUsage!=null&&(i.usage=e.outTexUsage),w.sizeFromShape(s.shape)===0)return i.values=w.getTypedArrayFromDType(s.dtype,0),s;let o=[],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)<=ne().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),o.push(m),g=this.texData.get(m.dataId);else if(g.isPacked&&!Pp(g.shape,m.shape)){let y=m,A=m.shape;m.shape=g.shape,m=this.packedReshape(m,A),o.push(m),g=this.texData.get(m.dataId),y.shape=A}return this.uploadToGPU(m.dataId),{shape:m.shape,texData:g,isUniform:!1}});this.uploadToGPU(s.dataId);let d={shape:s.shape,texData:i,isUniform:!1},u=LK(e,l,d),p=this.getAndSaveBinary(u,()=>PK(this.gpgpu,e,l,d)),c=this.activeTimers!=null,h;c&&(h=this.startTimer()),zK(this.gpgpu,p,l,d,a),o.forEach(m=>this.disposeIntermediateTensorInfo(m)),c&&(h=this.endTimer(h),this.activeTimers.push({name:e.constructor.name,query:this.getQueryTime(h)}));let f=ne().get("WEBGL_FLUSH_THRESHOLD");if(f>0){let m=w.now();m-this.lastGlFlushTime>f&&(this.gpgpu.gl.flush(),this.lastGlFlushTime=m)}if(!ne().getBool("WEBGL_LAZILY_UNPACK")&&i.isPacked&&r===!1){let m=this.unpackTensor(s);return this.disposeIntermediateTensorInfo(s),m}return s}compileAndRun(e,t,n,a,r=!1){return n=n||t[0].dtype,this.runWebGLProgram(e,t,n,a,r)}getAndSaveBinary(e,t){return e in this.binaryCache||(this.binaryCache[e]=t()),this.binaryCache[e]}getTextureManager(){return this.textureManager}dispose(){this.disposed||(ne().getBool("IS_TEST")||Object.keys(this.binaryCache).forEach(e=>{this.gpgpu.deleteProgram(this.binaryCache[e].webGLProgram),delete this.binaryCache[e]}),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(!ne().get("WEBGL_RENDER_FLOAT32_ENABLED")){let e=ne().getBool("DEBUG");ne().set("DEBUG",!1);let t=this.abs(Ce(1e-8)).dataSync()[0];if(ne().set("DEBUG",e),t>0)return 32}return 16})),this.floatPrecisionValue}epsilon(){return this.floatPrecision()===32?eY:tY}uploadToGPU(e){let t=this.texData.get(e),{shape:n,dtype:a,values:r,texture:s,usage:i,isPacked:o}=t;if(s!=null)return;let l=this.activeTimers!=null,d;l&&(d=w.now());let u=t.texShape;if(u==null&&(u=f4(n,o),t.texShape=u),r!=null){let p=cf(n),c,h=u[1],f=u[0],m=r instanceof Uint8Array||r instanceof Uint8ClampedArray;o?([h,f]=Ru(u[0],u[1]),c=new GK(p,m)):c=new jK(p,m);let g=this.makeTensorInfo([f,h],a);m?this.texData.get(g.dataId).usage=Ca.PIXELS:this.texData.get(g.dataId).usage=Ca.UPLOAD,this.gpgpu.uploadDenseMatrixToTexture(this.getTexture(g.dataId),h,f,r);let y=[[f,h]],A=!0,x=this.runWebGLProgram(c,[g],a,y,A),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()-d)}else{let p=this.acquireTexture(u,i,a,o);t.texture=p}}convertAndCacheOnCPU(e,t){let n=this.texData.get(e),{dtype:a}=n;return this.releaseGPUData(e),t!=null&&(n.values=iY(t,a)),n.values}acquireTexture(e,t,n,a){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,a)}computeBytes(e,t){return e[0]*e[1]*w.bytesPerElement(t)}};Pu.nextDataId=0;function iY(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 a=0;a<n.length;++a)n[a]=Math.round(e[a]);return n}else throw new Error(`Unknown dtype ${t}`)}var oY="3.10.0";function J4(){ne().set("WEBGL_FORCE_F16_TEXTURES",!0)}Wd.isBrowser()&&au("webgl",()=>new Pu,2);var lY={forceHalfFloat:J4},Q4=`
|
|
if (isnan(a)) return a;
|
|
if (isnan(b)) return b;
|
|
`,zu=class{constructor(e,t,n){this.variableNames=["A","B"],this.outputShape=E.assertAndGetBroadcastShape(t,n),this.enableShapeUniforms=Ra(this.outputShape.length),this.userCode=`
|
|
float binaryOperation(float a, float b) {
|
|
${e}
|
|
}
|
|
|
|
void main() {
|
|
float a = getAAtOutCoords();
|
|
float b = getBAtOutCoords();
|
|
setOutput(binaryOperation(a, b));
|
|
}
|
|
`}},xf=`
|
|
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;
|
|
`,Lp=class{constructor(e,t,n,a=!1){this.variableNames=["A","B"],this.supportsBroadcasting=!0,this.packedInputs=!0,this.packedOutput=!0,this.outputShape=E.assertAndGetBroadcastShape(t,n);let r=this.outputShape.length;this.enableShapeUniforms=Ra(r);let s="";if(a)if(r===0||w.sizeFromShape(this.outputShape)===1)s=`
|
|
result.y = 0.;
|
|
result.z = 0.;
|
|
result.w = 0.;
|
|
`;else if(s=`
|
|
${yt(r)} coords = getOutputCoords();
|
|
`,r===1)this.enableShapeUniforms?s+=`
|
|
result.y = (coords + 1) >= outShape ? 0. : result.y;
|
|
result.z = 0.;
|
|
result.w = 0.;
|
|
`:s+=`
|
|
result.y = (coords + 1) >= ${this.outputShape[0]} ? 0. : result.y;
|
|
result.z = 0.;
|
|
result.w = 0.;
|
|
`;else{let i=On("coords",r);this.enableShapeUniforms?s+=`
|
|
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;
|
|
`:s+=`
|
|
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);
|
|
${s}
|
|
|
|
setOutput(result);
|
|
}
|
|
`}};function ma(e){let{inputs:t,backend:n}=e,{x:a}=t;return n.incRef(a.dataId),{dataId:a.dataId,shape:a.shape,dtype:a.dtype}}var uY={kernelName:mi,backendName:"webgl",kernelFunc:ma};function Ds(e){let{inputs:t,backend:n}=e,{real:a,imag:r}=t,s=n.makeTensorInfo(a.shape,"complex64"),i=n.texData.get(s.dataId),o=ma({inputs:{x:a},backend:n}),l=ma({inputs:{x:r},backend:n});return i.complexTensorInfos={real:o,imag:l},s}var dY={kernelName:jc,backendName:"webgl",kernelFunc:Ds},ek="return (a < 0.) ? b * a : a;",tk=`
|
|
vec4 aLessThanZero = vec4(lessThan(a, vec4(0.)));
|
|
return (aLessThanZero * (b * a)) + ((vec4(1.0) - aLessThanZero) * a);
|
|
`;function pY(e){let{inputs:t,backend:n,attrs:a}=e,{x:r}=t,{alpha:s}=a,i=n.makeTensorInfo([],"float32",w.createScalarValue(s,"float32")),o=ne().getBool("WEBGL_PACK_BINARY_OPERATIONS")?new Lp(tk,r.shape,i.shape):new zu(ek,r.shape,i.shape),l=n.runWebGLProgram(o,[r,i],"float32");return n.disposeIntermediateTensorInfo(i),l}var cY={kernelName:gi,backendName:"webgl",kernelFunc:pY},nk="return (a < 0.) ? b * a : a;",ak=`
|
|
vec4 aLessThanZero = vec4(lessThan(a, vec4(0.)));
|
|
return (aLessThanZero * (b * a)) + ((vec4(1.0) - aLessThanZero) * a);
|
|
`;function hY(e){let{inputs:t,backend:n}=e,{x:a,alpha:r}=t,s=ne().getBool("WEBGL_PACK_BINARY_OPERATIONS")?new Lp(ak,a.shape,r.shape):new zu(nk,a.shape,r.shape);return n.runWebGLProgram(s,[a,r],"float32")}var fY={kernelName:Ei,backendName:"webgl",kernelFunc:hY},rk="if (isnan(x)) return x;",mY=`
|
|
if (isnan(a)) return a;
|
|
if (isnan(b)) return b;
|
|
`,gY=`
|
|
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:a}){return({inputs:r,backend:s})=>{let{x:i}=r,o=s,l=a||i.dtype;if(o.shouldExecuteOnCPU([i])&&n!=null){let p=o.texData.get(i.dataId),c=n(p.values,l);return o.makeTensorInfo(i.shape,l,c)}let d=ne().getBool("WEBGL_PACK_UNARY_OPERATIONS")&&t!=null,u;return d?u=new _u(i.shape,t):u=new Fs(i.shape,e),o.runWebGLProgram(u,[i],l)}}function vn({opSnippet:e,packedOpSnippet:t,checkOutOfBounds:n=!1,supportsComplex:a=!1,cpuKernelImpl:r,dtype:s}){return({inputs:i,backend:o})=>{let{a:l,b:d}=i,u=o;if(a&&l.dtype==="complex64"){let f=u.texData.get(l.dataId),m=u.texData.get(d.dataId),[g,y]=[[f.complexTensorInfos.real,m.complexTensorInfos.real],[f.complexTensorInfos.imag,m.complexTensorInfos.imag]].map(x=>{let[b,v]=x,k={dataId:b.dataId,dtype:b.dtype,shape:l.shape},T={dataId:v.dataId,dtype:v.dtype,shape:d.shape},C=new zu(e,l.shape,d.shape);return u.runWebGLProgram(C,[k,T],Pa(b.dtype,v.dtype))}),A=Ds({inputs:{real:g,imag:y},backend:u});return u.disposeIntermediateTensorInfo(g),u.disposeIntermediateTensorInfo(y),A}let p=s||Pa(l.dtype,d.dtype);if((l.dtype==="string"||d.dtype==="string"||u.shouldExecuteOnCPU([l,d]))&&r!=null){let f=u.texData.get(l.dataId).values,m=u.texData.get(d.dataId).values,g=l.dtype==="string"?E.fromUint8ToStringArray(f):f,y=l.dtype==="string"?E.fromUint8ToStringArray(m):m,[A,x]=r(l.shape,d.shape,g,y,p),b=u.makeTensorInfo(x,p),v=u.texData.get(b.dataId);return v.values=A,b}let c=ne().getBool("WEBGL_PACK_BINARY_OPERATIONS")&&t!=null,h;return c?h=new Lp(t,l.shape,d.shape,n):h=new zu(e,l.shape,d.shape),u.runWebGLProgram(h,[l,d],p)}}function bf(e,t=!1){if(e==="linear")return t?qZ:VZ;if(e==="relu")return t?KZ:jZ;if(e==="elu")return t?XZ:UZ;if(e==="relu6")return t?ZZ:GZ;if(e==="prelu")return t?ak:nk;if(e==="leakyrelu")return t?tk:ek;if(e==="sigmoid")return t?YZ:HZ;throw new Error(`Activation ${e} has not been implemented for the WebGL backend.`)}var sk=class{constructor(e,t,n,a=!1,r=!1,s=!1,i=null,o=!1,l=!1){this.variableNames=["matrixA","matrixB"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=n,this.enableShapeUniforms=Ra(this.outputShape.length);let d=a?e[1]:e[2],u=Math.ceil(d/2),p=a?"i * 2, rc.y":"rc.y, i * 2",c=r?"rc.z, i * 2":"i * 2, rc.z",h=a?["a.xxyy","a.zzww"]:["a.xxzz","a.yyww"],f=r?["b.xzxz","b.ywyw"]:["b.xyxy","b.zwzw"],m="",g="";i&&(o?m=`vec4 activation(vec4 a) {
|
|
vec4 b = getPreluActivationWeightsAtOutCoords();
|
|
${i}
|
|
}`:l?m=`vec4 activation(vec4 a) {
|
|
vec4 b = getLeakyreluAlphaAtOutCoords();
|
|
${i}
|
|
}`:m=`vec4 activation(vec4 x) {
|
|
${i}
|
|
}`,g="result = activation(result);");let y=s?"result += getBiasAtOutCoords();":"";s&&this.variableNames.push("bias"),o&&this.variableNames.push("preluActivationWeights"),l&&this.variableNames.push("leakyreluAlpha");let A="rc.x",x="rc.x";e[0]<t[0]?A=`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 = ${A};
|
|
int batchB = ${x};
|
|
vec4 a = getMatrixA(batchA, ${p});
|
|
vec4 b = getMatrixB(batchB, ${c});
|
|
|
|
// 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);
|
|
|
|
${y}
|
|
|
|
${g}
|
|
|
|
setOutput(result);
|
|
}
|
|
`}},ik={REAL:"return areal * breal - aimag * bimag;",IMAG:"return areal * bimag + aimag * breal;"},ok=class{constructor(e,t,n){this.variableNames=["AReal","AImag","BReal","BImag"],this.outputShape=E.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));
|
|
}
|
|
`}},lk="return a * b;";function G2(e){let{inputs:t,backend:n}=e,{a,b:r}=t,s=E.upcastType(a.dtype,r.dtype);if(a.dtype==="complex64"){let o=n.texData.get(a.dataId),l=n.texData.get(r.dataId),d=new ok(ik.REAL,a.shape,r.shape),u=new ok(ik.IMAG,a.shape,r.shape),p=[{dataId:o.complexTensorInfos.real.dataId,dtype:o.complexTensorInfos.real.dtype,shape:a.shape},{dataId:o.complexTensorInfos.imag.dataId,dtype:o.complexTensorInfos.imag.dtype,shape:a.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}],c=n.runWebGLProgram(d,p,"float32"),h=n.runWebGLProgram(u,p,"float32"),f=Ds({inputs:{real:c,imag:h},backend:n});return n.disposeIntermediateTensorInfo(c),n.disposeIntermediateTensorInfo(h),f}if(n.shouldExecuteOnCPU([a,r])){let o=n.texData.get(a.dataId),l=n.texData.get(r.dataId),[d,u]=cZ(a.shape,r.shape,o.values,l.values,s),p=n.makeTensorInfo(u,s),c=n.texData.get(p.dataId);return c.values=d,p}let i;return ne().getBool("WEBGL_PACK_BINARY_OPERATIONS")?i=new Lp(lk,a.shape,r.shape):i=new zu(lk,a.shape,r.shape),n.runWebGLProgram(i,[a,r],s)}var yY={kernelName:Si,backendName:"webgl",kernelFunc:G2};function AY(e,t,n){let a=[Io(e.shape),...So(e.shape)],r={dtype:e.dtype,shape:a,dataId:e.dataId},s=[Io(t),...So(t)],i=new q4(s,a),o=!0,l=[a],d=n.runWebGLProgram(i,[r],e.dtype,l,o);return{dataId:d.dataId,shape:t,dtype:d.dtype}}function we(e){let{inputs:t,backend:n,attrs:a}=e,{x:r}=t,{shape:s}=a,i=n,o=w.sizeFromShape(r.shape),l=w.inferFromImplicitShape(s,o),d=w.sizeFromShape(l);w.assert(o===d,()=>`The new shape (${l}) has ${d} elements and the old shape (${r.shape}) has ${o} elements. The new shape and old shape must have the same number of elements.`);let u=i.texData.get(r.dataId);return u.isPacked&&!Pp(r.shape,l)&&!(u.texture!==null&&Pp(u.shape,l))?AY(r,l,i):(i.incRef(r.dataId),{dataId:r.dataId,shape:l,dtype:r.dtype})}var xY={kernelName:$l,backendName:"webgl",kernelFunc:we},uk=class{constructor(e,t){this.variableNames=["x"];let{windowSize:n,batchSize:a,inSize:r,outSize:s}=e;this.outputShape=[a,s];let i=Math.floor(n/4)*4,o=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 d="";r%n>0&&(d=`
|
|
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) {
|
|
${d}
|
|
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 < ${i}; 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 + ${i};
|
|
if (${o===1}) {
|
|
vec4 values = vec4(getValue(batch, inIdx), 0.0, 0.0, 0.0);
|
|
|
|
${l}
|
|
} else if (${o===2}) {
|
|
vec4 values = vec4(
|
|
getValue(batch, inIdx),
|
|
getValue(batch, inIdx + 1), 0.0, 0.0);
|
|
|
|
${l}
|
|
} else if (${o===3}) {
|
|
vec4 values = vec4(
|
|
getValue(batch, inIdx),
|
|
getValue(batch, inIdx + 1),
|
|
getValue(batch, inIdx + 2), 0.0);
|
|
|
|
${l}
|
|
}
|
|
setOutput(sumValue);
|
|
}
|
|
`}},bY=class{constructor(e,t){this.variableNames=["x"];let{windowSize:n,batchSize:a,inSize:r,outSize:s}=e;this.outputShape=[a,s];let i="0.0",o="";t==="prod"?i="1.0":t==="min"?(i="1.0 / 1e-20",o="min"):t==="max"&&(i="-1.0 / 1e-20",o="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 d=Math.floor(n/4)*4,u=n%4,p=`
|
|
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 = ${o}(values, minMaxValue);
|
|
if (${t==="min"} || ${t==="max"}) {
|
|
minMaxValue = ${o}(values, minMaxValue);
|
|
bvec4 isNaN = isnan(values);
|
|
if (isNaN.r || isNaN.g || isNaN.b || isNaN.a) {
|
|
minMaxValue = vec4(NAN);
|
|
}
|
|
}
|
|
}
|
|
`,c="vec4";t==="all"?(i="1.0",p=`
|
|
bool reducedAllValue = all(values);
|
|
float floatedReducedAllValue = float(reducedAllValue);
|
|
allValue = float(allValue >= 1.0 && floatedReducedAllValue >= 1.0);
|
|
`,c="bvec4"):t==="any"&&(i="0.0",p=`
|
|
bool reducedAnyValue = any(values);
|
|
float floatedReducedAnyValue = float(reducedAnyValue);
|
|
anyValue = float(anyValue >= 1.0 || floatedReducedAnyValue >= 1.0);
|
|
`,c="bvec4");let h="";r%n>0&&(h=`
|
|
if (inIdx < 0 || inIdx >= ${r}) {
|
|
return initializationValue;
|
|
}
|
|
`),this.userCode=`
|
|
const float initializationValue = ${i};
|
|
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(${i});
|
|
float prodValue = 1.0;
|
|
float sumValue = 0.0;
|
|
float allValue = 1.0;
|
|
float anyValue = 0.0;
|
|
|
|
for (int i = 0; i < ${d}; i += 4) {
|
|
int inIdx = inOffset + i;
|
|
${c} values = ${c}(
|
|
getValue(batch, inIdx),
|
|
getValue(batch, inIdx + 1),
|
|
getValue(batch, inIdx + 2),
|
|
getValue(batch, inIdx + 3)
|
|
);
|
|
|
|
${p}
|
|
}
|
|
|
|
int inIdx = inOffset + ${d};
|
|
if (${u===1}) {
|
|
${c} values = ${c}(
|
|
getValue(batch, inIdx),
|
|
initializationValue,
|
|
initializationValue,
|
|
initializationValue
|
|
);
|
|
|
|
${p}
|
|
} else if (${u===2}) {
|
|
${c} values = ${c}(
|
|
getValue(batch, inIdx),
|
|
getValue(batch, inIdx + 1),
|
|
initializationValue,
|
|
initializationValue
|
|
);
|
|
|
|
${p}
|
|
} else if (${u===3}) {
|
|
${c} values = ${c}(
|
|
getValue(batch, inIdx),
|
|
getValue(batch, inIdx + 1),
|
|
getValue(batch, inIdx + 2),
|
|
initializationValue
|
|
);
|
|
|
|
${p}
|
|
}
|
|
setOutput(${l});
|
|
}
|
|
`}};function vY(e){let t=[];for(;t.length===0||t[t.length-1].outSize!==1;){let n=t.length?t[t.length-1].outSize:e[1],a=E.computeOptimalWindowSize(n);t.push({inSize:n,windowSize:a,outSize:Math.ceil(n/a)})}return t}function Co(e,t,n,a){let r=vY(e.shape),s=e;for(let i=0;i<r.length;i++){let{inSize:o,windowSize:l,outSize:d}=r[i],u,p;n==="mean"?u=i===0?new uk({windowSize:l,inSize:o,batchSize:e.shape[0],outSize:d},o):new uk({windowSize:l,inSize:o,batchSize:e.shape[0],outSize:d}):u=new bY({windowSize:l,inSize:o,batchSize:e.shape[0],outSize:d},n),p=s,s=a.runWebGLProgram(u,[s],t),p.dataId!==e.dataId&&a.disposeIntermediateTensorInfo(p)}return s}var wY=class{constructor(e,t){this.variableNames=["A"];let n=new Array(e.length);for(let s=0;s<n.length;s++)n[s]=e[t[s]];this.outputShape=n,this.rank=n.length;let a=yt(this.rank),r=kY(t);this.userCode=`
|
|
void main() {
|
|
${a} resRC = getOutputCoords();
|
|
setOutput(getA(${r}));
|
|
}
|
|
`}};function kY(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"],a=new Array(t);for(let r=0;r<e.length;r++)a[e[r]]=n[r];return a.join()}var IY=class{constructor(e,t){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0;let n=new Array(e.length);for(let d=0;d<n.length;d++)n[d]=e[t[d]];if(this.outputShape=n,this.rank=n.length,this.rank>6)throw Error(`Packed transpose for rank ${this.rank} is not yet supported.`);let a=yt(this.rank),r=H4("rc",this.rank),s=new Array(this.rank);for(let d=0;d<t.length;d++)s[t[d]]=r[d];let i=`vec2(${s.slice(-2).join()})`,o=`++${r[this.rank-1]} < ${n[this.rank-1]}`,l=`getChannel(getA(${s.join()}), ${i})`;this.userCode=`
|
|
void main() {
|
|
${a} rc = getOutputCoords();
|
|
vec4 result = vec4(0.);
|
|
result[0] = ${l};
|
|
if(${o}) {
|
|
result[1] = ${l};
|
|
}
|
|
--${r[this.rank-1]};
|
|
if(++${r[this.rank-2]} < ${n[this.rank-2]}) {
|
|
result[2] = ${l};
|
|
if(${o}) {
|
|
result[3] = ${l};
|
|
}
|
|
}
|
|
setOutput(result);
|
|
}
|
|
`}};function vf(e,t,n){let a=ne().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new IY(e.shape,t):new wY(e.shape,t);return n.runWebGLProgram(a,[e],e.dtype)}function SY(e,t,n,a){let r=t,s=e.shape.length,i=w.parseAxisParam(r,e.shape),o=i,l=E.getAxesPermutation(o,s),d=l!=null,u=e;d&&(u=vf(e,l,a),o=E.getInnerMostAxes(o.length,s)),E.assertAxesAreInnerMostDims("sum",o,s);let[p,c]=E.computeOutAndReduceShapes(u.shape,o),h=p;n&&(h=E.expandShapeToKeepDim(p,i));let f=w.sizeFromShape(c),m=w.sizeFromShape(e.shape)/f,g=we({inputs:{x:u},attrs:{shape:[m,f]},backend:a}),y=Eh(e.dtype),A=Co(g,y,"sum",a),x=we({inputs:{x:A},attrs:{shape:h},backend:a});return a.disposeIntermediateTensorInfo(g),a.disposeIntermediateTensorInfo(A),d&&a.disposeIntermediateTensorInfo(u),x}function wf(e){let{inputs:t,backend:n,attrs:a}=e,{x:r}=t,{axis:s,keepDims:i}=a;return SY(r,s,i,n)}var NY={kernelName:Li,backendName:"webgl",kernelFunc:wf};function _n(e){let{inputs:t,backend:n,attrs:a}=e,{x:r}=t,{perm:s}=a,i=n,o=r.shape.length,l=new Array(o);for(let u=0;u<l.length;u++)l[u]=r.shape[s[u]];let d;if(i.shouldExecuteOnCPU([r])){let u=i.texData.get(r.dataId).values,p=U2(u,r.shape,r.dtype,s,l);d=i.makeTensorInfo(l,r.dtype);let c=i.texData.get(d.dataId);c.values=p}else d=vf(r,s,i);return d}var TY={kernelName:Gi,backendName:"webgl",kernelFunc:_n},dk=1e3;function kf({a:e,b:t,transposeA:n,transposeB:a,backend:r,bias:s=null,preluActivationWeights:i=null,leakyreluAlpha:o=0,activation:l=null}){let d=e.shape.length,u=t.shape.length,p=n?e.shape[d-2]:e.shape[d-1],c=a?t.shape[u-1]:t.shape[u-2],h=n?e.shape[d-1]:e.shape[d-2],f=a?t.shape[u-2]:t.shape[u-1],m=e.shape.slice(0,-2),g=t.shape.slice(0,-2),y=w.sizeFromShape(m),A=w.sizeFromShape(g),x=y===A||y===1||A===1;w.assert(d>=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 b=(y>A?e.shape.slice(0,-2):t.shape.slice(0,-2)).concat([h,f]);w.assert(p===c,()=>`Error in matMul: inner shapes (${p}) and (${c}) of Tensors with shapes ${e.shape} and ${t.shape} and transposeA=${n} and transposeB=${a} must match.`);let v=n?[y,p,h]:[y,h,p],k=a?[A,f,c]:[A,c,f],T=we({inputs:{x:e},backend:r,attrs:{shape:v}}),C=we({inputs:{x:t},backend:r,attrs:{shape:k}}),D=[T,C],O=Math.max(y,A),F=n?T.shape[1]:T.shape[2],S=s!=null,P=i!=null,_=l==="leakyrelu",j=l!=null?bf(l,!0):null,q=S||P||_||j!=null,z;if((h===1||f===1)&&F>dk&&q===!1){let Z=T,te=C;n&&(Z=_n({inputs:{x:T},backend:r,attrs:{perm:[0,2,1]}}),D.push(Z)),a&&(te=_n({inputs:{x:C},backend:r,attrs:{perm:[0,2,1]}}),D.push(te));let J=f!==1,re=f===1,Y=Z;J&&(Y=we({inputs:{x:Z},backend:r,attrs:{shape:[O,F,1]}}),D.push(Y));let se=f===1?2:1,de=te;re&&(de=we({inputs:{x:te},backend:r,attrs:{shape:[O,1,F]}}),D.push(de));let be=G2({inputs:{a:Y,b:de},backend:r});z=wf({inputs:{x:be},backend:r,attrs:{axis:se,keepDims:!0}}),D.push(be)}else{let Z=Pa(e.dtype,t.dtype),te=new sk(v,k,[O,h,f],n,a,S,j,P,_),J=[T,C];if(s!=null&&J.push(s),P&&J.push(i),_){let re=r.makeTensorInfo([],"float32",w.createScalarValue(o,"float32"));J.push(re),D.push(re)}z=r.runWebGLProgram(te,J,Z)}let X=we({inputs:{x:z},backend:r,attrs:{shape:b}});D.push(z);for(let Z of D)r.disposeIntermediateTensorInfo(Z);return X}function CY(e){let{inputs:t,backend:n,attrs:a}=e,{a:r,b:s,bias:i,preluActivationWeights:o}=t,{transposeA:l,transposeB:d,activation:u,leakyreluAlpha:p}=a;return kf({a:r,b:s,transposeA:l,transposeB:d,backend:n,bias:i,preluActivationWeights:o,leakyreluAlpha:p,activation:u})}var EY={kernelName:Hi,backendName:"webgl",kernelFunc:CY},pk="return abs(x);";function RY(e){let{inputs:t,backend:n}=e,{x:a}=t;if(n.shouldExecuteOnCPU([a])&&a.dtype!=="complex64"){let s=n.texData.get(a.dataId),i=j4(s.values);return n.makeTensorInfo(a.shape,a.dtype,i)}let r;return ne().getBool("WEBGL_PACK_UNARY_OPERATIONS")?r=new _u(a.shape,pk):r=new Fs(a.shape,pk),n.runWebGLProgram(r,[a],a.dtype)}var MY={kernelName:Ko,backendName:"webgl",kernelFunc:RY},FY=lr+`
|
|
if (abs(x) > 1.) {
|
|
return NAN;
|
|
}
|
|
return acos(x);
|
|
`,DY=nt({opSnippet:FY}),$Y={kernelName:Zo,backendName:"webgl",kernelFunc:DY},OY=lr+`
|
|
if (x < 1.0) return NAN;
|
|
return log(x + sqrt(x * x - 1.0));`,_Y=nt({opSnippet:OY}),PY={kernelName:Yo,backendName:"webgl",kernelFunc:_Y},ck="return a + b;",zY=vn({opSnippet:ck,packedOpSnippet:ck,supportsComplex:!0,cpuKernelImpl:qK}),LY={kernelName:ls,backendName:"webgl",kernelFunc:zY},WY=class{constructor(e,t){this.outputShape=[],this.outputShape=e,this.variableNames=t.map((r,s)=>`T${s}`);let n=[];this.variableNames.forEach(r=>{n.push(`float v${r} = get${r}AtOutCoords();`)});let a=this.variableNames.map(r=>`v${r}`).join(" + ");this.userCode=`
|
|
void main() {
|
|
${n.join(`
|
|
`)}
|
|
|
|
float result = ${a};
|
|
setOutput(result);
|
|
}
|
|
`}},BY=class{constructor(e,t){this.outputShape=[],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=e,this.variableNames=t.map((r,s)=>`T${s}`);let n=[];this.variableNames.forEach(r=>{n.push(`vec4 v${r} = get${r}AtOutCoords();`)});let a=this.variableNames.map(r=>`v${r}`).join(" + ");this.userCode=`
|
|
void main() {
|
|
${n.join(`
|
|
`)}
|
|
|
|
vec4 result = ${a};
|
|
setOutput(result);
|
|
}
|
|
`}};function If(e){let{inputs:t,backend:n}=e,a=t;if(a.length===1)return ma({inputs:{x:a[0]},backend:n});if(a.length>ne().get("WEBGL_MAX_TEXTURES_IN_SHADER")){let o=Math.floor(a.length/2),l=If({inputs:a.slice(0,o),backend:n}),d=If({inputs:a.slice(o),backend:n});return If({inputs:[l,d],backend:n})}let r=a.map(o=>o.dtype).reduce((o,l)=>Pa(o,l)),s=a.map(o=>o.shape),i=ne().getBool("WEBGL_PACK")?new BY(a[0].shape,s):new WY(a[0].shape,s);return n.runWebGLProgram(i,a,r)}var VY={kernelName:Zs,backendName:"webgl",kernelFunc:If};function UY(e){let{inputs:t,backend:n,attrs:a}=e,{x:r}=t,{axis:s,keepDims:i}=a,o=r.shape.length,l=w.parseAxisParam(s,r.shape),d=l,u=E.getAxesPermutation(d,o),p=r;u!=null&&(p=_n({inputs:{x:r},backend:n,attrs:{perm:u}}),d=E.getInnerMostAxes(d.length,o)),E.assertAxesAreInnerMostDims("all",d,o);let[c,h]=E.computeOutAndReduceShapes(p.shape,d),f=w.sizeFromShape(h),m=we({inputs:{x:p},backend:n,attrs:{shape:[-1,f]}}),g=Co(m,m.dtype,"all",n),y;if(i){let A=E.expandShapeToKeepDim(c,l);y=we({inputs:{x:g},backend:n,attrs:{shape:A}})}else y=we({inputs:{x:g},backend:n,attrs:{shape:c}});return n.disposeIntermediateTensorInfo(m),n.disposeIntermediateTensorInfo(g),u!=null&&n.disposeIntermediateTensorInfo(p),y}var jY={kernelName:Jo,backendName:"webgl",kernelFunc:UY};function GY(e){let{inputs:t,backend:n,attrs:a}=e,{x:r}=t,{axis:s,keepDims:i}=a,o=r.shape.length,l=w.parseAxisParam(s,r.shape),d=l,u=E.getAxesPermutation(d,o),p=r;u!=null&&(p=_n({inputs:{x:r},backend:n,attrs:{perm:u}}),d=E.getInnerMostAxes(d.length,o)),E.assertAxesAreInnerMostDims("any",d,o);let[c,h]=E.computeOutAndReduceShapes(p.shape,d),f=w.sizeFromShape(h),m=we({inputs:{x:p},backend:n,attrs:{shape:[-1,f]}}),g=Co(m,m.dtype,"any",n),y;if(i){let A=E.expandShapeToKeepDim(c,l);y=we({inputs:{x:g},backend:n,attrs:{shape:A}})}else y=we({inputs:{x:g},backend:n,attrs:{shape:c}});return n.disposeIntermediateTensorInfo(m),n.disposeIntermediateTensorInfo(g),u!=null&&n.disposeIntermediateTensorInfo(p),y}var HY={kernelName:Qo,backendName:"webgl",kernelFunc:GY},qY=class{constructor(e,t,n){this.variableNames=["A"];let{windowSize:a,batchSize:r,outSize:s}=e;n||this.variableNames.push("bestIndicesA"),this.outputShape=[r,s];let i=t==="max"?">":"<",o=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 * ${a};
|
|
|
|
int bestIndex = inOffset;
|
|
float bestValue = getA(batch, bestIndex);
|
|
|
|
for (int i = 0; i < ${a}; i++) {
|
|
int inIdx = ${o};
|
|
float candidate = getA(batch, inIdx);
|
|
if (candidate ${i} bestValue) {
|
|
bestValue = candidate;
|
|
bestIndex = inIdx;
|
|
}
|
|
}
|
|
setOutput(float(bestIndex));
|
|
}
|
|
`}},XY=class{constructor(e,t,n,a){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],s=Math.ceil(r/t);this.outputShape=e.slice(0,-1),s>1&&this.outputShape.push(s),a||this.variableNames.push("bestIndicesA");let i=this.outputShape,o=i.length,l=yt(o),d=On("coords",o),u,p;if(s===1){p=o+1;let T=yt(p);u=`
|
|
${T} sourceLocR = ${T}(${d.join()}, 0);
|
|
++${d[o-1]};
|
|
${T} sourceLocG = ${T}(${d.join()}, 0);
|
|
++${d[o-2]};
|
|
${T} sourceLocA = ${T}(${d.join()}, 0);
|
|
--${d[o-1]};
|
|
${T} sourceLocB = ${T}(${d.join()}, 0);
|
|
--${d[o-2]};`}else p=o,u=`
|
|
${l} sourceLocR = coords;
|
|
++${d[o-1]};
|
|
${l} sourceLocG = coords;
|
|
++${d[o-2]};
|
|
${l} sourceLocA = coords;
|
|
--${d[o-1]};
|
|
${l} sourceLocB = coords;
|
|
--${d[o-2]};`;let c=["x","y","z","w","u","v"].slice(0,p),h="."+c[p-1],f=c.map(T=>"int "+T),m=On("sourceLocR",p-1).concat("inIdx.r"),g=On("sourceLocG",p-1).concat("inIdx.g"),y=On("sourceLocB",p-1).concat("inIdx.b"),A=On("sourceLocA",p-1).concat("inIdx.a"),x=n==="max"?"greaterThan":"lessThan",b=a?"":`
|
|
inIdx = round(vec4(getBestIndicesAChannel(${m.join()}),
|
|
getBestIndicesAChannel(${g.join()}),
|
|
getBestIndicesAChannel(${y.join()}),
|
|
getBestIndicesAChannel(${A.join()})));`,v=`vec4(
|
|
getAChannel(${m.join()}),
|
|
hasNextCol ? getAChannel(${g.join()}) : 0.,
|
|
hasNextRow ? getAChannel(${y.join()}) : 0.,
|
|
hasNextRow && hasNextCol ? getAChannel(${A.join()}) : 0.)`,k=a?"":`
|
|
float getBestIndicesAChannel(${f.join()}) {
|
|
return getChannel(getBestIndicesA(${c.join()}),
|
|
vec2(${c.slice(-2).join()}));
|
|
}`;this.userCode=`
|
|
float getAChannel(${f.join()}) {
|
|
return getChannel(getA(${c.join()}),
|
|
vec2(${c.slice(-2).join()}));
|
|
}
|
|
${k}
|
|
void main() {
|
|
${l} coords = getOutputCoords();
|
|
bool hasNextCol = ${d[o-1]} < ${i[o-1]-1};
|
|
bool hasNextRow = ${d[o-2]} < ${i[o-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 hk(e,t,n,a=null){let r=t.shape[0],s=t.shape[1];a!=null&&(r=a.shape[0],s=a.shape[1]);let i=E.computeOptimalWindowSize(s),o={windowSize:i,inSize:s,batchSize:r,outSize:Math.ceil(s/i)},l=new qY(o,n,a==null),d=[t];a!=null&&d.push(a);let u=e.runWebGLProgram(l,d,"int32");if(u.shape[1]===1)return u;let p=hk(e,t,n,u);return e.disposeIntermediateTensorInfo(u),p}function fk(e,t,n,a=null){let r=a!=null?a.shape:t.shape,s=r[r.length-1],i=E.computeOptimalWindowSize(s),o=new XY(r,i,n,a==null),l=a==null?[t]:[t,a],d=e.runWebGLProgram(o,l,"int32");if(d.shape.length===t.shape.length){let u=fk(e,t,n,d);return e.disposeIntermediateTensorInfo(d),u}return d}function mk(e,t,n,a){let r=[n];if(E.assertAxesAreInnerMostDims("arg"+a.charAt(0).toUpperCase()+a.slice(1),r,t.shape.length),!ne().getBool("WEBGL_PACK_REDUCE")||t.shape.length<=2){let s=[],i=e.texData.get(t.dataId),o=i!==null&&i.isPacked,l=t;o&&(l=e.unpackTensor(t),s.push(l));let[d,u]=E.computeOutAndReduceShapes(l.shape,r),p=w.sizeFromShape(u),c=we({inputs:{x:l},backend:e,attrs:{shape:[-1,p]}});s.push(c);let h=hk(e,c,a);s.push(h);let f=we({inputs:{x:h},backend:e,attrs:{shape:d}});return s.forEach(m=>e.disposeIntermediateTensorInfo(m)),f}return fk(e,t,a)}function KY(e){let{inputs:t,backend:n,attrs:a}=e,{x:r}=t,{axis:s}=a,i=w.parseAxisParam(s,r.shape),o=E.getAxesPermutation(i,r.shape.length),l=r,d=[];o!=null&&(l=_n({inputs:{x:r},backend:n,attrs:{perm:o}}),d.push(l),i=E.getInnerMostAxes(i.length,l.shape.length)),E.assertAxesAreInnerMostDims("argMax",[i[0]],l.shape.length);let u=mk(n,l,i[0],"max");return d.forEach(p=>n.disposeIntermediateTensorInfo(p)),u}var ZY={kernelName:Ys,backendName:"webgl",kernelFunc:KY};function YY(e){let{inputs:t,backend:n,attrs:a}=e,{x:r}=t,{axis:s}=a,i=w.parseAxisParam(s,r.shape),o=E.getAxesPermutation(i,r.shape.length),l=r,d=[];o!=null&&(l=_n({inputs:{x:r},backend:n,attrs:{perm:o}}),d.push(l),i=E.getInnerMostAxes(i.length,l.shape.length)),E.assertAxesAreInnerMostDims("argMin",[i[0]],l.shape.length);let u=mk(n,l,i[0],"min");return d.forEach(p=>n.disposeIntermediateTensorInfo(p)),u}var JY={kernelName:yd,backendName:"webgl",kernelFunc:YY},QY=lr+`
|
|
if (abs(x) > 1.) {
|
|
return NAN;
|
|
}
|
|
return asin(x);
|
|
`,eJ=nt({opSnippet:QY}),tJ={kernelName:el,backendName:"webgl",kernelFunc:eJ},nJ=lr+"return log(x + sqrt(x * x + 1.0));",aJ=nt({opSnippet:nJ}),rJ={kernelName:tl,backendName:"webgl",kernelFunc:aJ},sJ=lr+`
|
|
return atan(x);
|
|
`,iJ=nt({opSnippet:sJ}),oJ={kernelName:nl,backendName:"webgl",kernelFunc:iJ},lJ=mY+`
|
|
return atan(a, b);
|
|
`,uJ=`
|
|
vec4 result = atan(a, b);
|
|
vec4 isNaN = min(vec4(isnan(a)) + vec4(isnan(b)), vec4(1.0));
|
|
`+gY+`
|
|
return result;
|
|
`,dJ=vn({opSnippet:lJ,packedOpSnippet:uJ}),pJ={kernelName:rl,backendName:"webgl",kernelFunc:dJ},cJ=lr+`
|
|
if ((x < -1.0) || (x > 1.0)) return NAN;
|
|
return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,hJ=nt({opSnippet:cJ}),fJ={kernelName:al,backendName:"webgl",kernelFunc:hJ},Wp=class{constructor(e,t,n,a=!1,r=!1){if(this.variableNames=["x"],t==="avg"&&n)throw new Error("Cannot compute positions for average pool.");let s=e.filterWidth,i=e.strideHeight,o=e.strideWidth,l=e.dilationHeight,d=e.dilationWidth,u=e.effectiveFilterHeight,p=e.effectiveFilterWidth,c=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`,y="0.0";if(f||(y="-1.0 / 1e-20"),n){let T=">=";this.userCode=`
|
|
const ivec2 strides = ivec2(${i}, ${o});
|
|
const ivec2 pads = ivec2(${c}, ${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 < ${p};
|
|
wC += ${d}) {
|
|
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 = ${a?r?m:g:`wR * ${p} + wC`};
|
|
}
|
|
}
|
|
}
|
|
setOutput(float(minMaxPosition));
|
|
}
|
|
`;return}let A="max",x=`${t}(${t}(${t}(minMaxValue[0], minMaxValue[1]), minMaxValue[2]), minMaxValue[3])`;t==="avg"&&(x="avgValue / count");let b=Math.floor(s/4)*4,v=s%4,k=`
|
|
if (${f}) {
|
|
avgValue += dot(values, ones);
|
|
} else {
|
|
minMaxValue = ${A}(values, minMaxValue);
|
|
}
|
|
`;this.userCode=`
|
|
const ivec2 strides = ivec2(${i}, ${o});
|
|
const ivec2 pads = ivec2(${c}, ${h});
|
|
const float initializationValue = ${y};
|
|
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(${y});
|
|
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 * ${d};
|
|
|
|
vec4 values = vec4(
|
|
getValue(batch, xR, xC, d),
|
|
getValue(batch, xR, xC + ${d}, d),
|
|
getValue(batch, xR, xC + 2 * ${d}, d),
|
|
getValue(batch, xR, xC + 3 * ${d}, d)
|
|
);
|
|
|
|
${k}
|
|
}
|
|
|
|
int xC = xCCorner + ${b};
|
|
if (${v===1}) {
|
|
vec4 values = vec4(
|
|
getValue(batch, xR, xC, d),
|
|
initializationValue,
|
|
initializationValue,
|
|
initializationValue
|
|
);
|
|
|
|
${k}
|
|
} else if (${v===2}) {
|
|
vec4 values = vec4(
|
|
getValue(batch, xR, xC, d),
|
|
getValue(batch, xR, xC + ${d}, d),
|
|
initializationValue,
|
|
initializationValue
|
|
);
|
|
|
|
${k}
|
|
} else if (${v===3}) {
|
|
vec4 values = vec4(
|
|
getValue(batch, xR, xC, d),
|
|
getValue(batch, xR, xC + ${d}, d),
|
|
getValue(batch, xR, xC + 2 * ${d}, d),
|
|
initializationValue
|
|
);
|
|
|
|
${k}
|
|
}
|
|
}
|
|
setOutput(${x});
|
|
}
|
|
`}},H2=class{constructor(e,t,n,a=!1,r=!1){if(this.variableNames=["x"],t==="avg"&&n)throw new Error("Cannot compute positions for average pool.");let s=e.filterWidth,i=e.strideDepth,o=e.strideHeight,l=e.strideWidth,d=e.dilationDepth,u=e.dilationHeight,p=e.dilationWidth,c=e.effectiveFilterDepth,h=e.effectiveFilterHeight,f=e.effectiveFilterWidth,m=e.padInfo.front,g=e.padInfo.top,y=e.padInfo.left;this.outputShape=e.outShape;let A=t==="avg",x="0.0";if(A||(x="-1.0 / 1e-20"),n){let D=">=";this.userCode=`
|
|
const ivec3 strides =
|
|
ivec3(${i}, ${o}, ${l});
|
|
const ivec3 pads = ivec3(${m}, ${g}, ${y});
|
|
|
|
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 < ${c};
|
|
wD += ${d}) {
|
|
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 += ${p}) {
|
|
int xC = xCCorner + wC;
|
|
|
|
if (xC < 0 || xC >= ${e.inWidth}) {
|
|
continue;
|
|
}
|
|
|
|
float value = getX(batch, xD, xR, xC, ch);
|
|
|
|
// If a min / max value has already been found, use it. If not,
|
|
// use the current value.
|
|
float currMinMaxValue = mix(
|
|
value, minMaxValue, minMaxValueFound);
|
|
if (value ${D} currMinMaxValue) {
|
|
minMaxValue = value;
|
|
minMaxValueFound = 1.0;
|
|
minMaxPosition = ${a?r?`(((batch * ${e.inDepth} + xD) * ${e.inHeight} + xR) * ${e.inWidth} + xC) * ${e.inChannels} + ch`:`((xD * ${e.inHeight} + xR) * ${e.inWidth} + xC) * ${e.inChannels} + ch`:`wD * ${h} * ${f} +
|
|
wR * ${f} + wC`};
|
|
}
|
|
}
|
|
}
|
|
}
|
|
setOutput(float(minMaxPosition));
|
|
}
|
|
`;return}let b="max",v=`${t}(${t}(${t}(minMaxValue[0], minMaxValue[1]), minMaxValue[2]), minMaxValue[3])`;t==="avg"&&(v="avgValue / count");let k=Math.floor(s/4)*4,T=s%4,C=`
|
|
if (${A}) {
|
|
avgValue += dot(values, ones);
|
|
} else {
|
|
minMaxValue = ${b}(values, minMaxValue);
|
|
}
|
|
`;this.userCode=`
|
|
const ivec3 strides =
|
|
ivec3(${i}, ${o}, ${l});
|
|
const ivec3 pads = ivec3(${m}, ${g}, ${y});
|
|
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 < ${c};
|
|
wD += ${d}) {
|
|
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 < ${k}; wC += 4) {
|
|
int xC = xCCorner + wC * ${p};
|
|
|
|
vec4 values = vec4(
|
|
getValue(batch, xD, xR, xC, ch),
|
|
getValue(batch, xD, xR, xC + ${p}, ch),
|
|
getValue(batch, xD, xR, xC + 2 * ${p}, ch),
|
|
getValue(batch, xD, xR, xC + 3 * ${p}, ch)
|
|
);
|
|
|
|
${C}
|
|
}
|
|
|
|
int xC = xCCorner + ${k};
|
|
if (${T===1}) {
|
|
vec4 values = vec4(
|
|
getValue(batch, xD, xR, xC, ch),
|
|
initializationValue,
|
|
initializationValue,
|
|
initializationValue
|
|
);
|
|
|
|
${C}
|
|
} else if (${T===2}) {
|
|
vec4 values = vec4(
|
|
getValue(batch, xD, xR, xC, ch),
|
|
getValue(batch, xD, xR, xC + ${p}, ch),
|
|
initializationValue,
|
|
initializationValue
|
|
);
|
|
|
|
${C}
|
|
} else if (${T===3}) {
|
|
vec4 values = vec4(
|
|
getValue(batch, xD, xR, xC, ch),
|
|
getValue(batch, xD, xR, xC + ${p}, ch),
|
|
getValue(batch, xD, xR, xC + 2 * ${p}, ch),
|
|
initializationValue
|
|
);
|
|
|
|
${C}
|
|
}
|
|
}
|
|
setOutput(${v});
|
|
}
|
|
}
|
|
`}};function mJ(e){let{inputs:t,backend:n,attrs:a}=e,{x:r}=t;Mu(r,"avgPool");let{filterSize:s,strides:i,pad:o,dimRoundingMode:l}=a,d=1;w.assert(E.eitherStridesOrDilationsAreOne(i,d),()=>`Error in avgPool: Either strides or dilations must be 1. Got strides ${i} and dilations '${d}'`);let u=E.computePool2DInfo(r.shape,s,i,d,o,l);if(u.filterWidth===1&&u.filterHeight===1&&w.arraysEqual(u.inShape,u.outShape))return ma({inputs:{x:r},backend:n});let p=new Wp(u,"avg",!1);return n.runWebGLProgram(p,[r],"float32")}var gJ={kernelName:Js,backendName:"webgl",kernelFunc:mJ};function yJ(e){let{inputs:t,backend:n,attrs:a}=e,{x:r}=t,{filterSize:s,strides:i,pad:o,dimRoundingMode:l,dataFormat:d}=a,u=[1,1,1],p=E.computePool3DInfo(r.shape,s,i,u,o,l,d),c=new H2(p,"avg",!1);return n.runWebGLProgram(c,[r],"float32")}var AJ={kernelName:Ad,backendName:"webgl",kernelFunc:yJ},xJ=class{constructor(e){this.variableNames=["dy"],this.outputShape=e.inShape;let t=e.filterHeight,n=e.filterWidth,a=e.strideHeight,r=e.strideWidth,s=e.dilationHeight,i=e.dilationWidth,o=e.effectiveFilterHeight,l=e.effectiveFilterWidth,d=o-1-e.padInfo.top,u=l-1-e.padInfo.left,p=1/(t*n);this.userCode=`
|
|
const ivec2 pads = ivec2(${d}, ${u});
|
|
const float avgMultiplier = float(${p});
|
|
|
|
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 < ${o};
|
|
wR += ${s}) {
|
|
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 < ${l};
|
|
wC+= ${i}) {
|
|
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);
|
|
}
|
|
`}},bJ=class{constructor(e){this.variableNames=["dy"],this.outputShape=e.inShape;let t=e.filterDepth,n=e.filterHeight,a=e.filterWidth,r=e.strideDepth,s=e.strideHeight,i=e.strideWidth,o=e.dilationDepth,l=e.dilationHeight,d=e.dilationWidth,u=e.effectiveFilterDepth,p=e.effectiveFilterHeight,c=e.effectiveFilterWidth,h=u-1-e.padInfo.front,f=p-1-e.padInfo.top,m=c-1-e.padInfo.left,g=1/(t*n*a);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 += ${o}) {
|
|
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 < ${p};
|
|
wR += ${l}) {
|
|
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 < ${c};
|
|
wC += ${d}) {
|
|
float dyC = float(dyCCorner + wC) / ${i}.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 vJ(e){let{inputs:t,backend:n,attrs:a}=e,{dy:r,input:s}=t,i=s,{filterSize:o,strides:l,pad:d,dimRoundingMode:u}=a,p=[1,1,1],c=E.computePool3DInfo(i.shape,o,l,p,d,u),h=new bJ(c);return n.runWebGLProgram(h,[r],i.dtype)}var wJ={kernelName:Bc,backendName:"webgl",kernelFunc:vJ};function kJ(e){let{inputs:t,backend:n,attrs:a}=e,{dy:r,input:s}=t,i=s;Mu([r,s],"avgPoolGrad");let{filterSize:o,strides:l,pad:d}=a,u=E.computePool2DInfo(i.shape,o,l,1,d),p=new xJ(u);return n.runWebGLProgram(p,[r],i.dtype)}var IJ={kernelName:Wc,backendName:"webgl",kernelFunc:kJ};function SJ(e){let{inputs:t,backend:n,attrs:a}=e,{a:r,b:s}=t,{transposeA:i,transposeB:o}=a;return kf({a:r,b:s,transposeA:i,transposeB:o,backend:n})}var NJ={kernelName:Qs,backendName:"webgl",kernelFunc:SJ},TJ=class{constructor(e,t,n,a,r,s){this.outputShape=[],this.variableNames=["x","mean","variance"],E.assertAndGetBroadcastShape(e,t),E.assertAndGetBroadcastShape(e,n);let i="0.0";a!=null&&(E.assertAndGetBroadcastShape(e,a),this.variableNames.push("offset"),i="getOffsetAtOutCoords()");let o="1.0";r!=null&&(E.assertAndGetBroadcastShape(e,r),this.variableNames.push("scale"),o="getScaleAtOutCoords()"),this.outputShape=e,this.userCode=`
|
|
void main() {
|
|
float x = getXAtOutCoords();
|
|
float mean = getMeanAtOutCoords();
|
|
float variance = getVarianceAtOutCoords();
|
|
float offset = ${i};
|
|
float scale = ${o};
|
|
float inv = scale * inversesqrt(variance + float(${s}));
|
|
setOutput(dot(vec3(x, -mean, offset), vec3(inv, inv, 1)));
|
|
}
|
|
`}},CJ=class{constructor(e,t,n,a,r,s){this.packedInputs=!0,this.packedOutput=!0,this.variableNames=["x","mean","variance"],E.assertAndGetBroadcastShape(e,t),E.assertAndGetBroadcastShape(e,n);let i="vec4(0.0)";a!=null&&(E.assertAndGetBroadcastShape(e,a),this.variableNames.push("offset"),i="getOffsetAtOutCoords()");let o="vec4(1.0)";r!=null&&(E.assertAndGetBroadcastShape(e,r),this.variableNames.push("scale"),o="getScaleAtOutCoords()"),this.outputShape=e,this.userCode=`
|
|
void main() {
|
|
vec4 offset = ${i};
|
|
vec4 scale = ${o};
|
|
|
|
vec4 x = getXAtOutCoords();
|
|
vec4 mean = getMeanAtOutCoords();
|
|
vec4 variance = getVarianceAtOutCoords();
|
|
|
|
vec4 inv = scale * inversesqrt(variance + vec4(${s}));
|
|
|
|
setOutput((x - mean) * inv + offset);
|
|
}
|
|
`}},EJ=({inputs:e,backend:t,attrs:n})=>{let{x:a,mean:r,variance:s,offset:i,scale:o}=e;w.assert(r.shape.length===s.shape.length,()=>"Batch normalization gradient requires mean and variance to have equal ranks."),w.assert(i==null||r.shape.length===i.shape.length,()=>"Batch normalization gradient requires mean and offset to have equal ranks."),w.assert(o==null||r.shape.length===o.shape.length,()=>"Batch normalization gradient requires mean and scale to have equal ranks.");let{varianceEpsilon:l}=n;l==null&&(l=.001);let d=[a,r,s],u=null;i!=null&&(u=i.shape,d.push(i));let p=null;o!=null&&(p=o.shape,d.push(o));let c=ne().getBool("WEBGL_PACK_NORMALIZATION")?new CJ(a.shape,r.shape,s.shape,u,p,l):new TJ(a.shape,r.shape,s.shape,u,p,l);return t.runWebGLProgram(c,d,d[0].dtype)},RJ={kernelName:hi,backendName:"webgl",kernelFunc:EJ},MJ=class{constructor(e){this.variableNames=["source"],this.outputShape=e,this.rank=e.length;let t=yt(this.rank);this.customUniforms=[{name:"start",arrayIndex:this.rank,type:"int"}];let n=FJ(this.rank),a,r=e.map((s,i)=>`sourceLoc.${q2[i]} = start[${i}] + coords.${q2[i]};`);a=`
|
|
${t} sourceLoc;
|
|
${t} coords = getOutputCoords();
|
|
${r.join(`
|
|
`)}
|
|
`,this.userCode=`
|
|
void main() {
|
|
${a}
|
|
setOutput(getSource(${n}));
|
|
}
|
|
`}},q2=["x","y","z","w","u","v"];function FJ(e){if(e===1)return"sourceLoc";if(e<=6)return q2.slice(0,e).map(t=>"sourceLoc."+t).join(",");throw Error(`Slicing for rank ${e} is not yet supported`)}var DJ=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=yt(this.rank),n=On("coords",this.rank),a=On("sourceLoc",this.rank),r=this.rank===1?"sourceLoc":`vec2(${a.slice(-2).join()})`,s=`getChannel(getSource(${a.join()}), ${r})`,i=`
|
|
result.x = ${s};
|
|
if (++${n[this.rank-1]} < ${e[this.rank-1]}) {
|
|
++${a[this.rank-1]};
|
|
result.y = ${s};
|
|
--${a[this.rank-1]};
|
|
}
|
|
`,o=this.rank===1?"":`
|
|
--${n[this.rank-1]};
|
|
if (++${n[this.rank-2]} < ${e[this.rank-2]}) {
|
|
++${a[this.rank-2]};
|
|
result.z = ${s};
|
|
if (++${n[this.rank-1]} < ${e[this.rank-1]}) {
|
|
++${a[this.rank-1]};
|
|
result.w = ${s};
|
|
}
|
|
}
|
|
`,l=this.rank<=4?`sourceLoc = coords +
|
|
${t}(${e.map((d,u)=>`start[${u}]`).join()});`:e.map((d,u)=>`${a[u]} = ${n[u]} + start[${u}];`).join(`
|
|
`);this.userCode=`
|
|
void main() {
|
|
${t} coords = getOutputCoords();
|
|
${t} sourceLoc;
|
|
${l}
|
|
vec4 result = vec4(0.);
|
|
${i}
|
|
${o}
|
|
setOutput(result);
|
|
}
|
|
`}};function $J(e,t,n,a){let r=a.texData.get(e.dataId),s=a.makeTensorInfo(n,e.dtype),i=a.texData.get(s.dataId);Object.assign(i,r),i.refCount=1,i.shape=n,i.dtype=e.dtype;let o=En.computeFlatOffset(t,w.computeStrides(e.shape));r.slice&&(o+=r.slice.flatOffset),i.slice={flatOffset:o,origDataId:r.slice&&r.slice.origDataId||e.dataId};let l=a.dataRefCount.get(i.slice.origDataId)||1;return a.dataRefCount.set(i.slice.origDataId,l+1),s}function Lu(e){let{inputs:t,backend:n,attrs:a}=e,{x:r}=t,{begin:s,size:i}=a,[o,l]=En.parseSliceParams(r,s,i);if(En.assertParamsValid(r,o,l),w.sizeFromShape(l)===0)return n.makeTensorInfo(l,r.dtype,[]);if(n.shouldExecuteOnCPU([r])||r.dtype==="string"){let p=n.texData.get(r.dataId),c=xZ(p.values,o,l,r.shape,r.dtype);return n.makeTensorInfo(l,r.dtype,c)}let{isPacked:d}=n.texData.get(r.dataId),u=En.isSliceContinous(r.shape,o,l);if(d||!u){let p=ne().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new DJ(l):new MJ(l),c=[o];return n.runWebGLProgram(p,[r],r.dtype,c)}return n.uploadToGPU(r.dataId),$J(r,o,l,n)}var OJ={kernelName:zl,backendName:"webgl",kernelFunc:Lu},_J=e=>{let{inputs:t,backend:n,attrs:a}=e,{x:r}=t,{blockShape:s,crops:i}=a;w.assert(r.shape.length<=4,()=>"batchToSpaceND for rank > 4 with a WebGL backend not implemented yet");let o=s.reduce((A,x)=>A*x),l=E.getReshaped(r.shape,s,o),d=E.getPermuted(l.length,s.length),u=E.getReshapedPermuted(r.shape,s,o),p=E.getSliceBeginCoords(i,s.length),c=E.getSliceSize(u,i,s.length),h=[],f=we({inputs:{x:r},backend:n,attrs:{shape:l}}),m=_n({inputs:{x:f},backend:n,attrs:{perm:d}}),g=we({inputs:{x:m},backend:n,attrs:{shape:u}}),y=Lu({inputs:{x:g},backend:n,attrs:{begin:p,size:c}});return h.push(f),h.push(m),h.push(g),h.forEach(A=>n.disposeIntermediateTensorInfo(A)),y},PJ={kernelName:sl,backendName:"webgl",kernelFunc:_J};function zJ(e){let{inputs:t,backend:n,attrs:a}=e,{x:r,weights:s}=t,{size:i}=a,o=n.readSync(r.dataId),l=n.readSync(s.dataId),d=U4(o,l,s.dtype,s.shape,i);return n.makeTensorInfo([i],s.dtype,d)}var LJ={kernelName:Vc,backendName:"webgl",kernelFunc:zJ};function WJ(e){let{inputs:t,backend:n}=e,{s0:a,s1:r}=t,s=n.readSync(a.dataId),i=n.readSync(r.dataId),o=E.assertAndGetBroadcastShape(Array.from(s),Array.from(i));return n.makeTensorInfo([o.length],"int32",Int32Array.from(o))}var BJ={kernelName:Uc,backendName:"webgl",kernelFunc:WJ},VJ="return float(a != b);",gk=vn({opSnippet:VJ,cpuKernelImpl:fZ,dtype:"bool"}),UJ={kernelName:Nl,backendName:"webgl",kernelFunc:gk};function Bp(e){let{inputs:t,backend:n}=e,{input:a}=t,r=n.texData.get(a.dataId);return ma({inputs:{x:r.complexTensorInfos.real},backend:n})}var jJ={kernelName:ph,backendName:"webgl",kernelFunc:Bp},GJ="return float(int(x));";function HJ(e,t){let n=new Fs(e.shape,GJ),a=t.runWebGLProgram(n,[e],"int32");return{dataId:a.dataId,shape:a.shape,dtype:a.dtype}}function X2(e){let{inputs:t,backend:n,attrs:a}=e,{x:r}=t,{dtype:s}=a;if(s==="complex64"){if(r.dtype==="complex64")return ma({inputs:{x:r},backend:n});let i=Gt(r.shape),o=X2({inputs:{x:r},backend:n,attrs:{dtype:"float32"}}),l=Ds({inputs:{real:o,imag:i},backend:n});return i.dispose(),n.disposeIntermediateTensorInfo(o),l}if(r.dtype==="complex64"){let i=Bp({inputs:{input:r},backend:n}),o=X2({inputs:{x:i},backend:n,attrs:{dtype:s}});return n.disposeIntermediateTensorInfo(i),o}if(!w.hasEncodingLoss(r.dtype,s)){let i=ma({inputs:{x:r},backend:n});return{dataId:i.dataId,shape:i.shape,dtype:s}}if(s==="int32")return HJ(r,n);if(s==="bool"){let i=n.makeTensorInfo([],"bool",w.getTypedArrayFromDType("bool",1)),o=gk({inputs:{a:r,b:i},backend:n});return n.disposeIntermediateTensorInfo(i),o}throw new Error(`Error in Cast: failed to cast ${r.dtype} to ${s}`)}var qJ={kernelName:ei,backendName:"webgl",kernelFunc:X2},yk="return ceil(x);",XJ=nt({opSnippet:yk,packedOpSnippet:yk,cpuKernelImpl:KK}),KJ={kernelName:ti,backendName:"webgl",kernelFunc:XJ},ZJ=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));
|
|
}
|
|
`}},YJ=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 JJ(e){let{inputs:t,backend:n,attrs:a}=e,{x:r}=t,{clipValueMin:s,clipValueMax:i}=a,o;ne().getBool("WEBGL_PACK_CLIP")?o=new YJ(r.shape):o=new ZJ(r.shape);let l=[[s],[i]];return n.runWebGLProgram(o,[r],r.dtype,l)}var QJ={kernelName:us,backendName:"webgl",kernelFunc:JJ},eQ=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 Ak(e,t){return{dataId:t.dataId,dtype:t.dtype,shape:e.shape}}function tQ(e){let{inputs:t,backend:n}=e,{x:a}=t,r=n.texData.get(a.dataId),s=new eQ(a.shape),i=[Ak(a,r.complexTensorInfos.real),Ak(a,r.complexTensorInfos.imag)];return n.runWebGLProgram(s,i,i[0].dtype)}var nQ={kernelName:xd,backendName:"webgl",kernelFunc:tQ},aQ=class{constructor(e){this.outputShape=[],this.outputShape=E.computeOutShape(e,1),this.variableNames=e.map((s,i)=>`T${i}`);let t=new Array(e.length-1);t[0]=e[0][1];for(let s=1;s<t.length;s++)t[s]=t[s-1]+e[s][1];let n=[`if (yC < ${t[0]}) setOutput(getT0(yR, yC));`];for(let s=1;s<t.length;s++){let i=t[s-1];n.push(`else if (yC < ${t[s]}) setOutput(getT${s}(yR, yC-${i}));`)}let a=t.length,r=t[t.length-1];n.push(`else setOutput(getT${a}(yR, yC-${r}));`),this.userCode=`
|
|
void main() {
|
|
ivec2 coords = getOutputCoords();
|
|
int yR = coords.x;
|
|
int yC = coords.y;
|
|
|
|
${n.join(`
|
|
`)}
|
|
}
|
|
`}},rQ=class{constructor(e,t){this.packedInputs=!0,this.packedOutput=!0,this.outputShape=[],this.outputShape=E.computeOutShape(e,t);let n=this.outputShape,a=n.length,r=yt(a),s=On("coords",a),i=["x","y","z","w","u","v"].slice(0,a);this.variableNames=e.map((f,m)=>`T${m}`);let o=new Array(e.length-1);o[0]=e[0][t];for(let f=1;f<o.length;f++)o[f]=o[f-1]+e[f][t];let l=i[t],d=i.slice(-2),u=i.join(),p=`if (${l} < ${o[0]}) {
|
|
return getChannel(
|
|
getT0(${u}), vec2(${d.join()}));
|
|
}`;for(let f=1;f<o.length;f++){let m=o[f-1];p+=`
|
|
if (${l} < ${o[f]} && ${l} >= ${o[f-1]}) {
|
|
return getChannel(
|
|
getT${f}(${Sf(i,l,m)}),
|
|
vec2(${Sf(d,l,m)}));
|
|
}`}let c=o.length,h=o[o.length-1];p+=`
|
|
return getChannel(
|
|
getT${c}(${Sf(i,l,h)}),
|
|
vec2(${Sf(d,l,h)}));`,this.userCode=`
|
|
float getValue(${i.map(f=>"int "+f)}) {
|
|
${p}
|
|
}
|
|
|
|
void main() {
|
|
${r} coords = getOutputCoords();
|
|
vec4 result = vec4(getValue(${s}), 0., 0., 0.);
|
|
|
|
${s[a-1]} = ${s[a-1]} + 1;
|
|
if (${s[a-1]} < ${n[a-1]}) {
|
|
result.g = getValue(${s});
|
|
}
|
|
|
|
${s[a-2]} = ${s[a-2]} + 1;
|
|
if (${s[a-2]} < ${n[a-2]}) {
|
|
result.a = getValue(${s});
|
|
}
|
|
|
|
${s[a-1]} = ${s[a-1]} - 1;
|
|
if (${s[a-2]} < ${n[a-2]} &&
|
|
${s[a-1]} < ${n[a-1]}) {
|
|
result.b = getValue(${s});
|
|
}
|
|
setOutput(result);
|
|
}
|
|
`}};function Sf(e,t,n){let a=e.indexOf(t);return e.map((r,s)=>s===a?`${r} - ${n}`:r).join()}function Nf(e){let{inputs:t,backend:n}=e,{input:a}=t,r=n.texData.get(a.dataId);return ma({inputs:{x:r.complexTensorInfos.imag},backend:n})}var sQ={kernelName:rh,backendName:"webgl",kernelFunc:Nf};function Wu(e,t,n){let a=e[0].dtype;if(a==="complex64"){let u=e.map(m=>Bp({inputs:{input:m},backend:n})),p=e.map(m=>Nf({inputs:{input:m},backend:n})),c=Wu(u,t,n),h=Wu(p,t,n),f=Ds({inputs:{real:c,imag:h},backend:n});return u.forEach(m=>n.disposeIntermediateTensorInfo(m)),p.forEach(m=>n.disposeIntermediateTensorInfo(m)),n.disposeIntermediateTensorInfo(c),n.disposeIntermediateTensorInfo(h),f}let r=n.shouldExecuteOnCPU(e);if(a==="string"&&(r=!0),r){let u=e.map(y=>{let A=w.sizeFromShape(y.shape.slice(t));return we({inputs:{x:y},backend:n,attrs:{shape:[-1,A]}})}),p=u.map(y=>({vals:n.readSync(y.dataId),shape:y.shape})),c=E.computeOutShape(u.map(y=>y.shape),1),h=u[0].shape[0]===1,f=ZK(p,c,a,h),m=E.computeOutShape(e.map(y=>y.shape),t),g=n.makeTensorInfo(m,a,f);return u.forEach(y=>n.disposeIntermediateTensorInfo(y)),g}if(e.length>ne().getNumber("WEBGL_MAX_TEXTURES_IN_SHADER")){let u=Math.floor(e.length/2),p=Wu(e.slice(0,u),t,n),c=Wu(e.slice(u),t,n),h=Wu([p,c],t,n);return n.disposeIntermediateTensorInfo(p),n.disposeIntermediateTensorInfo(c),h}if(ne().getBool("WEBGL_PACK_ARRAY_OPERATIONS")&&e[0].shape.length>1){let u=new rQ(e.map(p=>p.shape),t);return n.runWebGLProgram(u,e,a)}let{tensors2D:s,outShape:i}=iQ(e,t,n),o=new aQ(s.map(u=>u.shape)),l=n.runWebGLProgram(o,s,a);s.forEach(u=>n.disposeIntermediateTensorInfo(u));let d=we({inputs:{x:l},attrs:{shape:i},backend:n});return n.disposeIntermediateTensorInfo(l),d}function iQ(e,t,n){let a=E.computeOutShape(e.map(r=>r.shape),t);return{tensors2D:e.map(r=>we({inputs:{x:r},attrs:{shape:[-1,w.sizeFromShape(r.shape.slice(t))]},backend:n})),outShape:a}}function xk(e){let{inputs:t,backend:n,attrs:a}=e,{axis:r}=a,s=w.parseAxisParam(r,t[0].shape)[0],i=E.computeOutShape(t.map(d=>d.shape),s);if(w.sizeFromShape(i)===0)return n.makeTensorInfo(i,t[0].dtype,[]);let o=t.filter(d=>w.sizeFromShape(d.shape)>0);if(o.length===1)return ma({inputs:{x:o[0]},backend:n});let l=o.map(d=>d.shape);return E.assertParamsConsistent(l,s),Wu(o,s,n)}var oQ={kernelName:il,backendName:"webgl",kernelFunc:xk},bk=class{constructor(e,t=!1,n=null,a=!1,r=!1){this.variableNames=["x","W"],this.outputShape=e.outShape;let s=e.padInfo.top,i=e.padInfo.left,o=e.strideHeight,l=e.strideWidth,d=e.dilationHeight,u=e.dilationWidth,p=e.filterHeight,c=e.filterWidth,h=Math.floor(e.inChannels/4)*4,f=e.inChannels%4,m=e.dataFormat==="channelsLast",g=m?1:2,y=m?2:3,A=m?3:1,x="",b="";n&&(a?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"),a&&this.variableNames.push("preluActivationWeights"),r&&this.variableNames.push("leakyreluAlpha"),this.userCode=`
|
|
${x}
|
|
|
|
const ivec2 strides = ivec2(${o}, ${l});
|
|
const ivec2 pads = ivec2(${s}, ${i});
|
|
|
|
void main() {
|
|
ivec4 coords = getOutputCoords();
|
|
int batch = coords[0];
|
|
int d2 = coords[${A}];
|
|
|
|
ivec2 xRCCorner =
|
|
ivec2(coords[${g}], coords[${y}]) * 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 < ${p}; wR++) {
|
|
int xR = xRCorner + wR * ${d};
|
|
|
|
if (xR < 0 || xR >= ${e.inHeight}) {
|
|
continue;
|
|
}
|
|
|
|
for (int wC = 0; wC < ${c}; 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);
|
|
}
|
|
`}},lQ=class{constructor(e){this.variableNames=["x","W"],this.outputShape=e.outShape;let t=e.padInfo.front,n=e.padInfo.top,a=e.padInfo.left,r=e.strideDepth,s=e.strideHeight,i=e.strideWidth,o=e.dilationDepth,l=e.dilationHeight,d=e.dilationWidth,u=e.filterDepth,p=e.filterHeight,c=e.filterWidth,h=Math.floor(e.inChannels/4)*4,f=e.inChannels%4;this.userCode=`
|
|
const ivec3 strides = ivec3(${r}, ${s}, ${i});
|
|
const ivec3 pads = ivec3(${t}, ${n}, ${a});
|
|
|
|
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 * ${o};
|
|
|
|
if (xF < 0 || xF >= ${e.inDepth}) {
|
|
continue;
|
|
}
|
|
|
|
for (int wR = 0; wR < ${p}; wR++) {
|
|
int xR = xRCorner + wR * ${l};
|
|
|
|
if (xR < 0 || xR >= ${e.inHeight}) {
|
|
continue;
|
|
}
|
|
|
|
for (int wC = 0; wC < ${c}; wC++) {
|
|
int xC = xCCorner + wC * ${d};
|
|
|
|
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);
|
|
}
|
|
`}},uQ=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=Ra(this.outputShape.length);let{dataFormat:n}=t,a=$n(),r=n==="channelsLast",s=r?0:1,i=r?1:2,o=this.enableShapeUniforms?"if(blockIndex < outShape[1] && pos < outShape[0]) {":`if(blockIndex < ${e[1]} && pos < ${e[0]}) {`,l="";for(let d=0;d<=1;d++)for(let u=0;u<=1;u++)l+=`
|
|
blockIndex = rc.y + ${u};
|
|
pos = rc.x + ${d};
|
|
|
|
${o}
|
|
offsetY = int(blockIndex / outWidth) * stride[0] - pad[0];
|
|
d0 = offsetY + dilation[0] * (pos / itemsPerBlockRow);
|
|
|
|
if(d0 < inputShape[${s}] && 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[${i}] && d1 >= 0) {
|
|
|
|
ch = imod(pos, inChannels);
|
|
|
|
if (${r}) {
|
|
innerDims = vec2(d1, ch);
|
|
result[${d*2+u}] = getChannel(
|
|
getA(d0, int(innerDims.x),
|
|
int(innerDims.y)), innerDims);
|
|
} else {
|
|
innerDims = vec2(d0, d1);
|
|
result[${d*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}
|
|
|
|
${a.output} = result;
|
|
}
|
|
`}};function vk({x:e,filter:t,convInfo:n,backend:a,bias:r=null,preluActivationWeights:s=null,leakyreluAlpha:i=0,activation:o=null}){let l=e.shape,d=a.texData.get(e.dataId),u=n.inChannels,p=l[0]*l[1]*l[2],c=n.outChannels,h=n.dataFormat==="channelsLast",f=!1,m=!1,g,y=[];if(!((p===1||c===1)&&u>dk)&&d.isPacked&&h&&d.texture!=null&&l[2]%2!=0&&w.arraysEqual(d.shape.slice(-3),l.slice(-3))){let A=l[0]*l[1]*(l[2]+1),x={dataId:e.dataId,shape:[1,A,n.inChannels],dtype:e.dtype},b=d.shape;d.shape=d.shape.slice(),d.shape[d.shape.length-2]++,w.assert(Pp(d.shape,x.shape),()=>`packed reshape ${d.shape} to ${x.shape} isn't free`);let v=we({inputs:{x:t},backend:a,attrs:{shape:[1,n.inChannels,n.outChannels]}});y.push(v);let k=kf({a:x,b:v,backend:a,transposeA:f,transposeB:m,bias:r,activation:o,preluActivationWeights:s,leakyreluAlpha:i}),T=a.texData.get(k.dataId);w.assert(T.isPacked,()=>"batchMatMul result is expected to be packed"),d.shape=b,T.shape=n.outShape,g=ma({inputs:{x:k},backend:a}),g.shape=n.outShape,y.push(k)}else{let A=h?l[0]*l[1]*l[2]:l[0]*l[2]*l[3],x=we({inputs:{x:e},backend:a,attrs:{shape:[1,A,n.inChannels]}}),b=we({inputs:{x:t},backend:a,attrs:{shape:[1,n.inChannels,n.outChannels]}}),v=kf({a:x,b,transposeA:f,transposeB:m,backend:a,bias:r,activation:o,preluActivationWeights:s,leakyreluAlpha:i});g=we({inputs:{x:v},backend:a,attrs:{shape:n.outShape}}),y.push(x),y.push(b),y.push(v)}for(let A of y)a.disposeIntermediateTensorInfo(A);return g}function wk({x:e,filter:t,convInfo:n,backend:a,bias:r=null,preluActivationWeights:s=null,leakyreluAlpha:i=0,activation:o=null}){let{filterWidth:l,filterHeight:d,inChannels:u,outWidth:p,outHeight:c,dataFormat:h}=n,f=h==="channelsLast",m=l*d*u,g=c*p,y=[m,g],A=!0,x=!1,b=[],v=we({inputs:{x:e},backend:a,attrs:{shape:e.shape.slice(1)}}),k=we({inputs:{x:t},backend:a,attrs:{shape:[1,m,w.sizeFromShape(t.shape)/m]}});b.push(v),b.push(k);let T=new uQ(y,n),C=[v.shape,[n.padInfo.top,n.padInfo.left],[n.strideHeight,n.strideWidth],[n.dilationHeight,n.dilationWidth],[n.inChannels],[n.filterWidth*n.inChannels],[n.outWidth]],D=a.runWebGLProgram(T,[v],"float32",C),O=we({inputs:{x:D},backend:a,attrs:{shape:[1,y[0],y[1]]}});b.push(D),b.push(O);let F=r!=null,S=s!=null,P=o==="leakyrelu",_=o?bf(o,!0):null,j=new sk(O.shape,k.shape,[1,g,n.outChannels],A,x,F,_,S,P),q=[O,k];if(r&&q.push(r),S&&q.push(s),P){let te=a.makeTensorInfo([],"float32",w.createScalarValue(i,"float32"));q.push(te),b.push(te)}let z=a.runWebGLProgram(j,q,"float32"),X=f?[1,c,p,n.outChannels]:[1,n.outChannels,c,p],Z=we({inputs:{x:z},backend:a,attrs:{shape:X}});b.push(z);for(let te of b)a.disposeIntermediateTensorInfo(te);return Z}function dQ(e){let{inputs:t,backend:n,attrs:a}=e,{x:r,filter:s}=t,{strides:i,pad:o,dataFormat:l,dilations:d,dimRoundingMode:u}=a,p=E.convertConv2DDataFormat(l),c=E.computeConv2DInfo(r.shape,s.shape,i,d,o,u,!1,p),h;if(c.filterHeight===1&&c.filterWidth===1&&c.dilationHeight===1&&c.dilationWidth===1&&c.strideHeight===1&&c.strideWidth===1&&(c.padInfo.type==="SAME"||c.padInfo.type==="VALID"))h=vk({x:r,filter:s,convInfo:c,backend:n});else if(ne().getBool("WEBGL_CONV_IM2COL")&&r.shape[0]===1)h=wk({x:r,filter:s,convInfo:c,backend:n});else{let m=new bk(c);h=n.runWebGLProgram(m,[r,s],"float32")}let f=we({inputs:{x:h},backend:n,attrs:{shape:c.outShape}});return n.disposeIntermediateTensorInfo(h),f}var pQ={kernelName:ni,backendName:"webgl",kernelFunc:dQ},cQ=class{constructor(e){this.variableNames=["x","dy"],this.outputShape=e.filterShape;let t=e.strideHeight,n=e.strideWidth,a=e.padInfo.top,r=e.padInfo.left,s=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} - ${a};
|
|
|
|
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 (${s}) {
|
|
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);
|
|
}
|
|
`}},hQ=class{constructor(e){this.variableNames=["dy","W"],this.outputShape=e.inShape;let t=e.filterHeight,n=e.filterWidth,a=e.strideHeight,r=e.strideWidth,s=e.dataFormat==="channelsLast",i=t-1-e.padInfo.top,o=n-1-e.padInfo.left,l=s?1:2,d=s?2:3,u=s?3:1;this.userCode=`
|
|
const ivec2 pads = ivec2(${i}, ${o});
|
|
|
|
void main() {
|
|
ivec4 coords = getOutputCoords();
|
|
int batch = coords[0];
|
|
int d1 = coords[${u}];
|
|
|
|
ivec2 dyCorner = ivec2(coords[${l}], coords[${d}]) - 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) / ${a}.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 (${s}) {
|
|
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);
|
|
}
|
|
`}},fQ=class{constructor(e){this.variableNames=["x","dy"],this.outputShape=e.filterShape;let t=e.strideDepth,n=e.strideHeight,a=e.strideWidth,r=e.padInfo.front,s=e.padInfo.top,i=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} - ${s};
|
|
|
|
if (xR < 0 || xR >= ${e.inHeight}) {
|
|
continue;
|
|
}
|
|
|
|
for (int yC = 0; yC < ${e.outWidth}; yC++) {
|
|
int xC = wC + yC * ${a} - ${i};
|
|
|
|
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);
|
|
}
|
|
`}},mQ=class{constructor(e){this.variableNames=["dy","W"],this.outputShape=e.inShape;let t=e.filterDepth,n=e.filterHeight,a=e.filterWidth,r=e.strideDepth,s=e.strideHeight,i=e.strideWidth,o=t-1-e.padInfo.front,l=n-1-e.padInfo.top,d=a-1-e.padInfo.left;this.userCode=`
|
|
const ivec3 pads = ivec3(${o}, ${l}, ${d});
|
|
|
|
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) / ${s}.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 < ${a}; wC++) {
|
|
float dyC = float(dyCCorner + wC) / ${i}.0;
|
|
|
|
if (dyC < 0.0 || dyC >= ${e.outWidth}.0 ||
|
|
fract(dyC) > 0.0) {
|
|
continue;
|
|
}
|
|
int idyC = int(dyC);
|
|
|
|
int wCPerm = ${a} - 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 gQ(e){let{inputs:t,backend:n,attrs:a}=e,{x:r,dy:s}=t,{strides:i,pad:o,dataFormat:l,dimRoundingMode:d,filterShape:u}=a,p=E.convertConv2DDataFormat(l),c=E.computeConv2DInfo(r.shape,u,i,1,o,d,!1,p),h=new cQ(c);return n.runWebGLProgram(h,[r,s],"float32")}var yQ={kernelName:Gc,backendName:"webgl",kernelFunc:gQ};function AQ(e){let{inputs:t,backend:n,attrs:a}=e,{dy:r,filter:s}=t,{inputShape:i,strides:o,pad:l,dataFormat:d,dimRoundingMode:u}=a,p=E.convertConv2DDataFormat(d),c=E.computeConv2DInfo(i,s.shape,o,1,l,u,!1,p),h=new hQ(c);return n.runWebGLProgram(h,[r,s],"float32")}var xQ={kernelName:ai,backendName:"webgl",kernelFunc:AQ};function bQ(e){let{inputs:t,backend:n,attrs:a}=e,{x:r,filter:s}=t,{strides:i,pad:o,dilations:l}=a,d=E.computeConv3DInfo(r.shape,s.shape,i,l,o),u=new lQ(d);return n.runWebGLProgram(u,[r,s],"float32")}var vQ={kernelName:bd,backendName:"webgl",kernelFunc:bQ};function wQ(e){let{inputs:t,backend:n,attrs:a}=e,{x:r,dy:s}=t,{strides:i,pad:o,filterShape:l}=a,d=E.computeConv3DInfo(r.shape,l,i,1,o),u=new fQ(d);return n.runWebGLProgram(u,[r,s],"float32")}var kQ={kernelName:Hc,backendName:"webgl",kernelFunc:wQ};function IQ(e){let{inputs:t,backend:n,attrs:a}=e,{dy:r,filter:s}=t,{pad:i,strides:o,inputShape:l}=a,d=E.computeConv3DInfo(l,s.shape,o,1,i),u=new mQ(d);return n.runWebGLProgram(u,[r,s],"float32")}var SQ={kernelName:qc,backendName:"webgl",kernelFunc:IQ},NQ=rk+`
|
|
return cos(x);
|
|
`,TQ=nt({opSnippet:NQ}),CQ={kernelName:ri,backendName:"webgl",kernelFunc:TQ},EQ=`
|
|
float e2x = exp(-x);
|
|
return (e2x + 1.0 / e2x) / 2.0;
|
|
`,RQ=nt({opSnippet:EQ}),MQ={kernelName:si,backendName:"webgl",kernelFunc:RQ},FQ=class{constructor(e,t,n,a,r){this.variableNames=["Image","Boxes","BoxInd"],this.outputShape=[];let[s,i,o,l]=e,[d]=t,[u,p]=n;this.outputShape=[d,u,p,l];let c=a==="bilinear"?1:0,[h,f]=[`${i-1}.0`,`${o-1}.0`],[m,g,y]=u>1?[`${(i-1)/(u-1)}`,"(y2-y1) * height_ratio",`y1*${h} + float(y)*(height_scale)`]:["0.0","0.0",`0.5 * (y1+y2) * ${h}`],[A,x,b]=p>1?[`${(o-1)/(p-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(${A});
|
|
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 >= ${s}) {
|
|
return;
|
|
}
|
|
|
|
float height_scale = ${g};
|
|
float width_scale = ${x};
|
|
|
|
float in_y = ${y};
|
|
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(${c} == 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);
|
|
}
|
|
}
|
|
`}},DQ=e=>{let{inputs:t,backend:n,attrs:a}=e,{image:r,boxes:s,boxInd:i}=t,{cropSize:o,method:l,extrapolationValue:d}=a,u=new FQ(r.shape,s.shape,o,l,d);return n.runWebGLProgram(u,[r,s,i],"float32")},$Q={kernelName:ol,backendName:"webgl",kernelFunc:DQ},kk=class{constructor(e,t,n){this.variableNames=["x"],this.customUniforms=[{name:"index",type:"float"}],this.outputShape=e;let a=e.length,r=t?"0.0":`getX(${Ik(a,"coords")})`,s=e[e.length-1],i="",o="";t?(i=n?`end != ${s-1}`:"end != 0",o=n?"end + 1":"end - 1"):(i=n?`end + pow2 < ${s}`:"end >= pow2",o=n?"end + pow2":"end - pow2"),this.userCode=`
|
|
void main() {
|
|
${yt(a)} coords = getOutputCoords();
|
|
int end = ${Sk(a,"coords")};
|
|
float val = ${r};
|
|
int pow2 = int(pow(2.0, index));
|
|
if (${i}) {
|
|
int idx = ${o};
|
|
${Sk(a,"coords")} = idx;
|
|
val += getX(${Ik(a,"coords")});
|
|
}
|
|
setOutput(val);
|
|
}
|
|
`}};function Ik(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 Sk(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 OQ(e){let{inputs:t,backend:n,attrs:a}=e,{x:r}=t,{axis:s,exclusive:i,reverse:o}=a,l=r.shape.length,d=E.getAxesPermutation([s],l),u=r;d!=null&&(u=_n({inputs:{x:r},backend:n,attrs:{perm:d}}));let p=E.getInnerMostAxes(1,l)[0];if(p!==l-1)throw new Error(`WebGL cumsum shader expects an inner-most axis=${r.shape.length-1} but got axis=${s}`);let c=u.shape[p],h=ma({inputs:{x:u},backend:n});for(let f=0;f<=Math.ceil(Math.log2(c))-1;f++){let m=new kk(u.shape,!1,o),g=[[f]],y=h;h=n.runWebGLProgram(m,[h],h.dtype,g),n.disposeIntermediateTensorInfo(y)}if(i){let f=new kk(u.shape,i,o),m=h;h=n.runWebGLProgram(f,[h],h.dtype),n.disposeIntermediateTensorInfo(m)}if(d!=null){let f=E.getUndoAxesPermutation(d),m=_n({inputs:{x:h},backend:n,attrs:{perm:f}});return n.disposeIntermediateTensorInfo(h),n.disposeIntermediateTensorInfo(u),m}return h}var _Q={kernelName:ii,backendName:"webgl",kernelFunc:OQ};function PQ(e){let{inputs:t,backend:n,attrs:a}=e,{x:r,weights:s}=t,{size:i,binaryOutput:o}=a;if(r.shape.length===1){let l=n.readSync(r.dataId),d=n.readSync(s.dataId),u=U4(l,d,s.dtype,s.shape,i);return n.makeTensorInfo([i],s.dtype,u)}else if(r.shape.length===2){let l=n.bufferSync(r),d=n.bufferSync(s),u=XK(l,d,i,o);return n.makeTensorInfo(u.shape,s.dtype,u.values)}throw new Error(`Error in denseBincount: input must be at most rank 2, but got rank${r.shape.length}.`)}var zQ={kernelName:Xc,backendName:"webgl",kernelFunc:PQ},LQ=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 WQ(e){let{inputs:t,backend:n,attrs:a}=e,{x:r}=t,{blockSize:s,dataFormat:i}=a,o=r.shape[0],l=i==="NHWC"?r.shape[1]:r.shape[2],d=i==="NHWC"?r.shape[2]:r.shape[3],u=i==="NHWC"?r.shape[3]:r.shape[1],p=l*s,c=d*s,h=u/(s*s),f=i==="NHWC"?[o,p,c,h]:[o,h,p,c],m=new LQ(f,s,i);return n.runWebGLProgram(m,[r],r.dtype)}var BQ={kernelName:ll,backendName:"webgl",kernelFunc:WQ},Nk=class{constructor(e,t=!1,n=null,a=!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=Ra(this.outputShape.length);let s=e.filterHeight,i=e.filterWidth,o=e.outChannels/e.inChannels,l="",d="";n&&(a?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}
|
|
}
|
|
`,d="result = activation(result);");let u=t?"result += getBiasAtOutCoords();":"";t&&this.variableNames.push("bias"),a&&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 / ${o};
|
|
int q = d2 - d1 * ${o};
|
|
|
|
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 < ${s}; wR++) {
|
|
int xR = xRCorner + wR * dilations[0];
|
|
|
|
if (xR < 0 || xR >= inDims[0]) {
|
|
continue;
|
|
}
|
|
|
|
for (int wC = 0; wC < ${i}; 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}
|
|
${d}
|
|
setOutput(result);
|
|
}
|
|
`}},Tk=class{constructor(e,t=!1,n=null,a=!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=Ra(this.outputShape.length);let s=e.outChannels/e.inChannels,i=e.padInfo.left,o=e.strideWidth,l=e.dilationWidth,d=e.filterHeight,u=e.filterWidth,p=u,c=`
|
|
int xR; int xC; int xCOffset;
|
|
vec4 wTexel; vec4 previous; vec4 final;`;for(let g=0;g<u;g++)c+=`
|
|
vec4 xTexelC${g*2};
|
|
int xTexelC${g*2}Ready;
|
|
vec4 xTexelC${g*2+1};
|
|
int xTexelC${g*2+1}Ready;
|
|
vec4 xC${g};`;c+=`
|
|
for (int r = 0; r < ${d}; r++) {
|
|
`;for(let g=0;g<u;g++)c+=`
|
|
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);`;c+=`
|
|
xR = xRCorner + r * dilations[0];
|
|
if (xR >=0 && xR < inDims[0]) {
|
|
`;for(let g=0;g<(p+1)/2;g++){let y=g*2;if(c+=`
|
|
xC = xCCorner + ${y*l};
|
|
`,o===1){if(y<u&&(i%2==1?(c+=`
|
|
xCOffset = xC + 1;
|
|
if (xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${y}Ready == 0) {
|
|
xTexelC${y} = getX(batch, xR, xCOffset, d1);
|
|
|
|
// Need to manually clear unused channels in case
|
|
// we're reading from recycled texture.
|
|
if (xCOffset + 1 >= inDims[1]) {
|
|
xTexelC${y}.zw = vec2(0.0);
|
|
}
|
|
xTexelC${y}Ready = 1;
|
|
}
|
|
`,l===1&&y>0?c+=`
|
|
xC${y} = vec4(xTexelC${y-2}.zw, xTexelC${y}.xy);
|
|
`:c+=`
|
|
xCOffset = xC + 1 - 2;
|
|
|
|
if (xCOffset >= 0 && xCOffset < inDims[1]) {
|
|
previous = getX(batch, xR, xCOffset, d1);
|
|
|
|
// Need to manually clear unused channels in case
|
|
// we're reading from recycled texture.
|
|
if (xCOffset + 1 >= inDims[1]) {
|
|
previous.zw = vec2(0.0);
|
|
}
|
|
|
|
xC${y} = vec4(previous.zw, xTexelC${y}.xy);
|
|
} else {
|
|
xC${y} = vec4(0.0, 0.0, xTexelC${y}.xy);
|
|
}
|
|
`):c+=`
|
|
if (xC >= 0 && xC < inDims[1] && xTexelC${y}Ready == 0) {
|
|
xTexelC${y} = getX(batch, xR, xC, d1);
|
|
if (xC + 1 >= inDims[1]) {
|
|
xTexelC${y}.zw = vec2(0.0);
|
|
}
|
|
xTexelC${y}Ready = 1;
|
|
}
|
|
|
|
xC${y} = xTexelC${y};
|
|
`,y+1<u)){let A=i%2==0?w.nearestLargerEven(l):l;l%2==0&&i%2==1||l%2!=0&&i%2!=1?(c+=`
|
|
xCOffset = xC + imod(pads[1], 2) + ${A};
|
|
|
|
if (xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${y+1}Ready == 0) {
|
|
xTexelC${y+1} = getX(batch, xR, xCOffset, d1);
|
|
|
|
// Need to manually clear unused channels in case
|
|
// we're reading from recycled texture.
|
|
if (xCOffset + 1 >= inDims[1]) {
|
|
xTexelC${y+1}.zw = vec2(0.0);
|
|
}
|
|
xTexelC${y+1}Ready = 1;
|
|
}
|
|
`,l>1&&(c+=`
|
|
xCOffset -= 2;
|
|
if (xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${y}Ready == 0) {
|
|
xTexelC${y} = getX(batch, xR, xCOffset, d1);
|
|
xTexelC${y}Ready = 1;
|
|
}
|
|
`),c+=`
|
|
xC${y+1} = vec4(xTexelC${y}.zw, xTexelC${y+1}.xy);
|
|
`):A===1?c+=`
|
|
xC${y+1} = xTexelC${y};
|
|
`:c+=`
|
|
xCOffset = xC + ${A};
|
|
|
|
if (xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${y+1}Ready == 0) {
|
|
xTexelC${y+1} = getX(batch, xR, xCOffset, d1);
|
|
if (xCOffset + 1 >= inDims[1]) {
|
|
xTexelC${y+1}.zw = vec2(0.0);
|
|
}
|
|
xTexelC${y+1}Ready = 1;
|
|
}
|
|
|
|
xC${y+1} = xTexelC${y+1};
|
|
`}}else y<u&&(i%2==1?(c+=`
|
|
xCOffset = xC + 1 - strides[1];
|
|
if(xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${y}Ready == 0) {
|
|
xTexelC${y} = getX(batch, xR, xCOffset, d1);
|
|
// Need to manually clear unused channels in case
|
|
// we're reading from recycled texture.
|
|
if (xCOffset + 1 >= inDims[1]) {
|
|
xTexelC${y}.zw = vec2(0.0);
|
|
}
|
|
xTexelC${y}Ready = 1;
|
|
}
|
|
|
|
if(xC + 1 >= 0 && xC + 1 < inDims[1] && xTexelC${y+1}Ready == 0) {
|
|
xTexelC${y+1} = getX(batch, xR, xC + 1, d1);
|
|
// Need to manually clear unused channels in case
|
|
// we're reading from recycled texture.
|
|
if (xC + 2 >= inDims[1]) {
|
|
xTexelC${y+1}.zw = vec2(0.0);
|
|
}
|
|
xTexelC${y+1}Ready = 1;
|
|
}
|
|
|
|
xC${y} = vec4(xTexelC${y}.zw, xTexelC${y+1}.zw);
|
|
`,y+1<u&&(c+=`
|
|
final = vec4(0.0);
|
|
xCOffset = xC + 1 + strides[1];
|
|
if(xCOffset >= 0 && xCOffset < inDims[1]) {
|
|
final = getX(batch, xR, xCOffset, d1);
|
|
}
|
|
xC${y+1} = vec4(xTexelC${y+1}.xy, final.xy);
|
|
`)):(c+=`
|
|
if(xC >= 0 && xC < inDims[1] && xTexelC${y}Ready == 0) {
|
|
xTexelC${y} = getX(batch, xR, xC, d1);
|
|
if (xC + 1 >= inDims[1]) {
|
|
xTexelC${y}.zw = vec2(0.0);
|
|
}
|
|
xTexelC${y}Ready = 1;
|
|
}
|
|
|
|
xCOffset = xC + strides[1];
|
|
if(xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${y+1}Ready == 0) {
|
|
xTexelC${y+1} = getX(batch, xR, xCOffset, d1);
|
|
if (xCOffset + 1 >= inDims[1]) {
|
|
xTexelC${y+1}.zw = vec2(0.);
|
|
}
|
|
xTexelC${y+1}Ready = 1;
|
|
}
|
|
|
|
xC${y} = vec4(
|
|
xTexelC${y}.xy, xTexelC${y+1}.xy);
|
|
`,y+1<u&&(c+=`
|
|
xC${y+1} = vec4(xTexelC${y}.zw, xTexelC${y+1}.zw);
|
|
`)));y<u&&(c+=`
|
|
wTexel = getW(r, ${y}, d1, q);
|
|
dotProd += xC${y} * vec4(wTexel.xz, wTexel.xz);
|
|
`,y+1<u&&(c+=`
|
|
wTexel = getW(r, ${y+1}, d1, q);
|
|
dotProd += xC${y+1} * vec4(wTexel.xz, wTexel.xz);
|
|
`))}c+=`
|
|
}
|
|
`,c+=`
|
|
}
|
|
`;let h="",f="";n&&(a?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"),a&&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 / ${s};
|
|
int q = d2 - d1 * ${s};
|
|
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);
|
|
|
|
${c}
|
|
|
|
vec4 result = dotProd - vec4(0.000000000000001);
|
|
${m}
|
|
${f}
|
|
setOutput(result);
|
|
}
|
|
`}};function VQ(e){let{inputs:t,backend:n,attrs:a}=e,{x:r,filter:s}=t,{strides:i,pad:o,dilations:l,dimRoundingMode:d}=a,u=l;u==null&&(u=[1,1]),w.assert(E.eitherStridesOrDilationsAreOne(i,u),()=>`Error in depthwiseConv2d: Either strides or dilations must be 1. Got strides ${i} and dilations '${u}'`);let p=E.computeConv2DInfo(r.shape,s.shape,i,u,o,d,!0),c;ne().getBool("WEBGL_PACK_DEPTHWISECONV")&&p.strideWidth<=2&&p.outChannels/p.inChannels==1?c=new Tk(p):c=new Nk(p);let h=[[p.padInfo.top,p.padInfo.left],[p.strideHeight,p.strideWidth],[p.dilationHeight,p.dilationWidth],[p.inHeight,p.inWidth]];return n.runWebGLProgram(c,[r,s],"float32",h)}var UQ={kernelName:oi,backendName:"webgl",kernelFunc:VQ},jQ=class{constructor(e){this.variableNames=["x","dy"],this.outputShape=e.filterShape;let t=e.strideHeight,n=e.strideWidth,a=e.padInfo.top,r=e.padInfo.left,s=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 * ${s} + 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} - ${a};
|
|
|
|
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);
|
|
}
|
|
`}},GQ=class{constructor(e){this.variableNames=["dy","W"],this.outputShape=e.inShape;let t=e.filterHeight,n=e.filterWidth,a=e.strideHeight,r=e.strideWidth,s=t-1-e.padInfo.top,i=n-1-e.padInfo.left,o=e.outChannels/e.inChannels;this.userCode=`
|
|
const ivec2 pads = ivec2(${s}, ${i});
|
|
|
|
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) / ${a}.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 < ${o}; dm++) {
|
|
int d2 = d1 * ${o} + dm;
|
|
float xValue = getDy(batch, idyR, idyC, d2);
|
|
float wValue = getW(wRPerm, wCPerm, d1, dm);
|
|
dotProd += xValue * wValue;
|
|
}
|
|
}
|
|
}
|
|
setOutput(dotProd);
|
|
}
|
|
`}};function HQ(e){let{inputs:t,backend:n,attrs:a}=e,{x:r,dy:s}=t,{strides:i,dilations:o,pad:l,dimRoundingMode:d,filterShape:u}=a,p=E.computeConv2DInfo(r.shape,u,i,o,l,d,!0),c=new jQ(p);return n.runWebGLProgram(c,[r,s],"float32")}var qQ={kernelName:Kc,backendName:"webgl",kernelFunc:HQ};function XQ(e){let{inputs:t,backend:n,attrs:a}=e,{dy:r,filter:s}=t,{strides:i,dilations:o,pad:l,dimRoundingMode:d,inputShape:u}=a,p=E.computeConv2DInfo(u,s.shape,i,o,l,d,!0),c=new GQ(p);return n.runWebGLProgram(c,[r,s],"float32")}var KQ={kernelName:Zc,backendName:"webgl",kernelFunc:XQ},ZQ=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 YQ(e){let{inputs:t,backend:n}=e,{x:a}=t,r=[...a.shape,...a.shape],s=w.sizeFromShape(a.shape),i=we({inputs:{x:a},backend:n,attrs:{shape:[s]}}),o=new ZQ(s),l=n.runWebGLProgram(o,[i],i.dtype),d=we({inputs:{x:l},backend:n,attrs:{shape:r}});return n.disposeIntermediateTensorInfo(i),n.disposeIntermediateTensorInfo(l),d}var JQ={kernelName:Yc,backendName:"webgl",kernelFunc:YQ},QQ=class{constructor(e){this.variableNames=["x","W"],this.outputShape=e.outShape;let{inHeight:t,inWidth:n,padInfo:a,strideHeight:r,strideWidth:s,filterHeight:i,filterWidth:o,dilationHeight:l,dilationWidth:d}=e,{top:u,left:p}=a;this.userCode=`
|
|
const ivec2 strides = ivec2(${r}, ${s});
|
|
const ivec2 pads = ivec2(${u}, ${p});
|
|
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 < ${i}; h++) {
|
|
int hIn = hBeg + h * ${l};
|
|
|
|
if (hIn >= 0 && hIn < ${t}) {
|
|
for (int w = 0; w < ${o}; w++) {
|
|
int wIn = wBeg + w * ${d};
|
|
|
|
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 eee(e){let{inputs:t,backend:n,attrs:a}=e,{x:r,filter:s}=t,{strides:i,pad:o,dilations:l}=a,d=E.computeDilation2DInfo(r.shape,s.shape,i,o,"NHWC",l),u,p=new QQ(d);u=n.runWebGLProgram(p,[r,s],"float32");let c=we({inputs:{x:u},backend:n,attrs:{shape:d.outShape}});return n.disposeIntermediateTensorInfo(u),c}var tee={kernelName:vd,backendName:"webgl",kernelFunc:eee};function nee(e){let{inputs:t,backend:n,attrs:a}=e,{equation:r}=a,s=t,{allDims:i,summedDims:o,idDims:l}=E.decodeEinsumEquation(r,s.length);E.checkEinsumDimSizes(i.length,l,s);let{path:d,steps:u}=E.getEinsumComputePath(o,l),p=u.length,c=null,h=i.length,f=[];for(let m=0;m<p;++m){for(let g of u[m]){let{permutationIndices:y,expandDims:A}=E.getEinsumPermutation(h,l[g]),x;E.isIdentityPermutation(y)?x=s[g]:(x=_n({inputs:{x:s[g]},backend:n,attrs:{perm:y}}),f.push(x));let b=x.shape.slice();for(let v=0;v<A.length;++v)b.splice(A[v],0,1);w.arraysEqual(x.shape,b)||(x=we({inputs:{x},backend:n,attrs:{shape:b}}),f.push(x)),c===null?c=x:(c=G2({inputs:{a:x,b:c},backend:n}),f.push(c))}m<p-1&&(d[m]>=0&&(c=wf({inputs:{x:c},backend:n,attrs:{axis:d[m]-(i.length-h),keepDims:!1}}),f.push(c)),h--)}for(let m of f)m!==c&&n.disposeIntermediateTensorInfo(m);return c}var aee={kernelName:eh,backendName:"webgl",kernelFunc:nee},ree="return (x >= 0.0) ? x : (exp(x) - 1.0);",see=`
|
|
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;
|
|
`,iee=nt({opSnippet:ree,packedOpSnippet:see}),oee={kernelName:ui,backendName:"webgl",kernelFunc:iee},lee="return (b >= 1.0) ? a : a * (b + 1.0);",uee=`
|
|
vec4 bGTEZero = vec4(greaterThanEqual(b, vec4(0.)));
|
|
return (bGTEZero * a) + ((vec4(1.0) - bGTEZero) * (a * (b + vec4(1.0))));
|
|
`,dee=e=>{let{inputs:t,backend:n}=e,{dy:a,y:r}=t,s=ne().getBool("WEBGL_PACK_BINARY_OPERATIONS")?new Lp(uee,a.shape,r.shape):new zu(lee,a.shape,r.shape);return n.runWebGLProgram(s,[a,r],a.dtype)},pee={kernelName:th,backendName:"webgl",kernelFunc:dee},cee=`
|
|
return vec4(equal(a, b));
|
|
`,hee="return float(a == b);",fee=vn({opSnippet:hee,packedOpSnippet:cee,dtype:"bool",cpuKernelImpl:YK}),mee={kernelName:dl,backendName:"webgl",kernelFunc:fee},gee=`
|
|
// Error function is calculated approximately with elementary function.
|
|
// See "Handbook of Mathematical Functions with Formulas,
|
|
// Graphs, and Mathematical Tables", Abramowitz and Stegun.
|
|
float p = ${E.ERF_P};
|
|
float a1 = ${E.ERF_A1};
|
|
float a2 = ${E.ERF_A2};
|
|
float a3 = ${E.ERF_A3};
|
|
float a4 = ${E.ERF_A4};
|
|
float a5 = ${E.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));
|
|
`,yee=nt({opSnippet:gee}),Aee={kernelName:ul,backendName:"webgl",kernelFunc:yee},Ck="return exp(x);",Ek=nt({opSnippet:Ck,packedOpSnippet:Ck,cpuKernelImpl:JK,dtype:"float32"}),xee={kernelName:di,backendName:"webgl",kernelFunc:Ek};function K2(e){let{inputs:t,attrs:n,backend:a}=e,{dim:r}=n,{input:s}=t,i=s.shape.length,o=s.shape.slice(),l=r;return r<0&&(w.assert(-(i+1)<=r,()=>`Axis must be in the interval [${-(i+1)}, ${i}]`),l=i+r+1),o.splice(l,0,1),we({inputs:{x:s},backend:a,attrs:{shape:o}})}var bee={kernelName:pl,backendName:"webgl",kernelFunc:K2},Rk="return exp(x) - 1.0;",vee=nt({opSnippet:Rk,packedOpSnippet:Rk,cpuKernelImpl:QK}),wee={kernelName:cl,backendName:"webgl",kernelFunc:vee},Mk=class{constructor(e,t,n){this.variableNames=["real","imag"];let a=t[1];this.outputShape=t;let r=n?`2.0 * ${Math.PI}`:`-2.0 * ${Math.PI}`,s=n?`${a}.0`:"1.0",i;if(e==="real")i="return real * expR - imag * expI;";else if(e==="imag")i="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) {
|
|
${i}
|
|
}
|
|
|
|
float mulMatDFT(int batch, int index) {
|
|
float indexRatio = float(index) / float(${a});
|
|
float exponentMultiplierTimesIndexRatio =
|
|
exponentMultiplier * indexRatio;
|
|
|
|
float result = 0.0;
|
|
|
|
for (int i = 0; i < ${a}; 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) / ${s};
|
|
}
|
|
|
|
return result;
|
|
}
|
|
|
|
void main() {
|
|
ivec2 coords = getOutputCoords();
|
|
setOutput(mulMatDFT(coords[0], coords[1]));
|
|
}
|
|
`}};function Fk(e,t,n){let a=n.texData.get(e.dataId),r=w.sizeFromShape(e.shape),s=e.shape[e.shape.length-1],i=r/s,o=we({inputs:{x:e},backend:n,attrs:{shape:[i,s]}}),l=o.shape,d=new Mk("real",l,t),u=new Mk("imag",l,t),p=[{dataId:a.complexTensorInfos.real.dataId,dtype:a.complexTensorInfos.real.dtype,shape:l},{dataId:a.complexTensorInfos.imag.dataId,dtype:a.complexTensorInfos.imag.dtype,shape:l}],c=n.runWebGLProgram(d,p,"float32"),h=n.runWebGLProgram(u,p,"float32"),f=Ds({inputs:{real:c,imag:h},backend:n});n.disposeIntermediateTensorInfo(c),n.disposeIntermediateTensorInfo(h);let m=we({inputs:{x:f},backend:n,attrs:{shape:e.shape}});return n.disposeIntermediateTensorInfo(o),n.disposeIntermediateTensorInfo(f),m}function kee(e){let{inputs:t,backend:n}=e,{input:a}=t;return Fk(a,!1,n)}var Iee={kernelName:nh,backendName:"webgl",kernelFunc:kee},See=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 Vp(e){let{backend:t,attrs:n}=e,{shape:a,value:r}=n,{dtype:s}=n;if(s=s||w.inferDtype(r),s==="string"){let i=w.getArrayFromDType(s,w.sizeFromShape(a));return i.fill(r),t.makeTensorInfo(a,s,i)}else{let i=new See(a,r),o=[[r]];return t.runWebGLProgram(i,[],s,o)}}var Nee={kernelName:wd,backendName:"webgl",kernelFunc:Vp},Tee=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);
|
|
}
|
|
`}},Cee={kernelName:hl,backendName:"webgl",kernelFunc:({inputs:e,backend:t})=>{let{image:n}=e,a=t,r=new Tee(n.shape);return a.runWebGLProgram(r,[n],n.dtype)}},Dk="return floor(x);",Eee=nt({opSnippet:Dk,packedOpSnippet:Dk,cpuKernelImpl:eZ}),Ree={kernelName:pi,backendName:"webgl",kernelFunc:Eee},Mee=`
|
|
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;
|
|
}
|
|
`,Fee=`
|
|
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);
|
|
`,Dee=vn({opSnippet:Mee,packedOpSnippet:Fee,dtype:"int32"}),$ee={kernelName:ci,backendName:"webgl",kernelFunc:Dee},Oee=class{constructor(e){this.variableNames=["A"];let t=$n(),[n,a]=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(${a}.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));
|
|
}
|
|
`}},_ee=class{constructor(e){this.variableNames=["A"],this.packedInputs=!1,this.packedOutput=!0;let t=$n(),[n,a]=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(${a}.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;
|
|
}
|
|
`}},Pee={kernelName:kh,backendName:"webgl",kernelFunc:zee},Bu;function zee(e){let{inputs:t,backend:n,attrs:a}=e,{pixels:r}=t,{numChannels:s}=a,i=typeof HTMLVideoElement!="undefined"&&r instanceof HTMLVideoElement,o=typeof HTMLImageElement!="undefined"&&r instanceof HTMLImageElement,[l,d]=i?[r.videoWidth,r.videoHeight]:[r.width,r.height],u=[d,l],p=[d,l,s];(o||i)&&(Bu==null&&(Bu=document.createElement("canvas").getContext("2d")),Bu.canvas.width=l,Bu.canvas.height=d,Bu.drawImage(r,0,0,l,d),r=Bu.canvas);let c=n.makeTensorInfo(u,"int32");n.texData.get(c.dataId).usage=Ca.PIXELS,n.gpgpu.uploadPixelDataToTexture(n.getTexture(c.dataId),r);let h=ne().getBool("WEBGL_PACK")?new _ee(p):new Oee(p),f=n.runWebGLProgram(h,[c],"int32");return n.disposeData(c.dataId),f}function Lee(e){let{inputs:t,backend:n,attrs:a}=e,{x:r,filter:s,bias:i,preluActivationWeights:o}=t,{strides:l,pad:d,dataFormat:u,dilations:p,dimRoundingMode:c,activation:h,leakyreluAlpha:f}=a,m=E.convertConv2DDataFormat(u),g=E.computeConv2DInfo(r.shape,s.shape,l,p,d,c,!1,m),y,A=[];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"))y=vk({x:r,filter:s,convInfo:g,backend:n,bias:i,activation:h,preluActivationWeights:o,leakyreluAlpha:f});else if(ne().getBool("WEBGL_CONV_IM2COL")&&r.shape[0]===1)y=wk({x:r,filter:s,convInfo:g,backend:n,bias:i,activation:h,preluActivationWeights:o,leakyreluAlpha:f});else{let b=i!=null,v=o!=null,k=h==="leakyrelu",T=h?bf(h,!1):null,C=new bk(g,b,T,v,k),D=[r,s];if(i&&D.push(i),o&&D.push(o),k){let O=n.makeTensorInfo([],"float32",w.createScalarValue(f,"float32"));D.push(O),A.push(O)}y=n.runWebGLProgram(C,D,"float32")}let x=we({inputs:{x:y},backend:n,attrs:{shape:g.outShape}});return A.push(y),A.forEach(b=>n.disposeIntermediateTensorInfo(b)),x}var Wee={kernelName:qi,backendName:"webgl",kernelFunc:Lee};function Bee(e){let{inputs:t,backend:n,attrs:a}=e,{x:r,filter:s,bias:i,preluActivationWeights:o}=t,{strides:l,pad:d,dilations:u,dimRoundingMode:p,activation:c,leakyreluAlpha:h}=a,f=[],m=u;m==null&&(m=[1,1]),w.assert(E.eitherStridesOrDilationsAreOne(l,m),()=>`Error in depthwiseConv2d: Either strides or dilations must be 1. Got strides ${l} and dilations '${m}'`);let g=E.computeConv2DInfo(r.shape,s.shape,l,m,d,p,!0),y=ne().getBool("WEBGL_PACK_DEPTHWISECONV")&&g.strideWidth<=2&&g.outChannels/g.inChannels==1,A=c?bf(c,y):null,x=[r,s],b=i!=null,v=o!=null,k=c==="leakyrelu";if(b&&x.push(i),v&&x.push(o),k){let O=n.makeTensorInfo([],"float32",w.createScalarValue(h,"float32"));x.push(O),f.push(O)}let T;y?T=new Tk(g,b,A,v,k):T=new Nk(g,b,A,v,k);let C=[[g.padInfo.top,g.padInfo.left],[g.strideHeight,g.strideWidth],[g.dilationHeight,g.dilationWidth],[g.inHeight,g.inWidth]],D=n.runWebGLProgram(T,x,"float32",C);return f.forEach(O=>n.disposeIntermediateTensorInfo(O)),D}var Vee={kernelName:Xi,backendName:"webgl",kernelFunc:Bee},Uee=class{constructor(e,t,n){this.sliceDim=e,this.strides=t,this.variableNames=["x","indices"],this.outputShape=n;let a=yt(t.length),r=yt(n.length),s=this.sliceDim>1?"strides[j]":"strides";this.userCode=`
|
|
${a} strides = ${a}(${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 * ${s};
|
|
}
|
|
setOutput(getX(flattenIndex, coords[1]));
|
|
}
|
|
`}};function jee(e){let{inputs:t,backend:n}=e,{params:a,indices:r}=t,s=r.shape,i=s[s.length-1],o=w.sizeFromShape(a.shape),[l,d,u,p]=E.prepareAndValidate(a,r),c=we({inputs:{x:r},backend:n,attrs:{shape:[d,i]}}),h=we({inputs:{x:a},backend:n,attrs:{shape:[w.sizeFromShape(a.shape)/u,u]}});if(n.shouldExecuteOnCPU([a,r])||a.dtype==="string"){let y=n.readSync(r.dataId),A=n.bufferSync(a),x=tZ(y,A,a.dtype,d,i,u,p,a.shape,o);return n.makeTensorInfo(l,a.dtype,x.values)}let f=new Uee(i,p,[d,u]),m=n.runWebGLProgram(f,[h,c],h.dtype),g=we({inputs:{x:m},backend:n,attrs:{shape:l}});return n.disposeIntermediateTensorInfo(c),n.disposeIntermediateTensorInfo(h),n.disposeIntermediateTensorInfo(m),g}var Gee={kernelName:ml,backendName:"webgl",kernelFunc:jee},Hee=class{constructor(e,t){this.variableNames=["A","indices"],this.outputShape=t,this.rank=t.length;let n=yt(this.rank),a=qee(e,2);this.userCode=`
|
|
void main() {
|
|
${n} resRC = getOutputCoords();
|
|
setOutput(getA(${a}));
|
|
}
|
|
`}};function qee(e,t){let n=["resRC.x","resRC.y","resRC.z","resRC.w"],a=[];for(let r=0;r<e.length;r++)r===2?a.push("int(getIndices(resRC.x, resRC.z))"):a.push(`${n[r]}`);return a.join()}function $k(e){let{inputs:t,backend:n,attrs:a}=e,{x:r,indices:s}=t,{axis:i,batchDims:o}=a,l=w.parseAxisParam(i,r.shape)[0],d=n.readSync(s.dataId),u=r.shape[l];for(let b=0;b<d.length;++b){let v=d[b];w.assert(v<=u-1&&v>=0,()=>`GatherV2: the index value ${v} is not in [0, ${u-1}]`)}let p=E.segment_util.collectGatherOpShapeInfo(r,s,l,o),c=w.sizeFromShape(s.shape),h=[],f=we({inputs:{x:r},backend:n,attrs:{shape:[p.batchSize,p.outerSize,p.dimSize,p.sliceSize]}}),m=we({inputs:{x:s},backend:n,attrs:{shape:[p.batchSize,c/p.batchSize]}});h.push(f),h.push(m);let g=[p.batchSize,p.outerSize,c/p.batchSize,p.sliceSize];if(n.shouldExecuteOnCPU([r,s])||r.dtype==="string"){let b=n.bufferSync(m),v=n.bufferSync(f),k=nZ(v,b,g);return h.forEach(T=>n.disposeIntermediateTensorInfo(T)),n.makeTensorInfo(p.outputShape,k.dtype,k.values)}let y=new Hee(f.shape,g),A=n.runWebGLProgram(y,[f,m],f.dtype);h.push(A);let x=we({inputs:{x:A},backend:n,attrs:{shape:p.outputShape}});return h.forEach(b=>n.disposeIntermediateTensorInfo(b)),x}var Xee={kernelName:fl,backendName:"webgl",kernelFunc:$k},Kee="return float(a > b);",Zee=`
|
|
return vec4(greaterThan(a, b));
|
|
`,Yee=vn({opSnippet:Kee,packedOpSnippet:Zee,cpuKernelImpl:aZ,dtype:"bool"}),Jee={kernelName:gl,backendName:"webgl",kernelFunc:Yee},Qee="return float(a >= b);",ete=`
|
|
return vec4(greaterThanEqual(a, b));
|
|
`,tte=vn({opSnippet:Qee,packedOpSnippet:ete,dtype:"bool",cpuKernelImpl:rZ}),nte={kernelName:fi,backendName:"webgl",kernelFunc:tte};function ate(e){let{inputs:t,backend:n}=e,{input:a}=t;return Fk(a,!0,n)}var rte={kernelName:ah,backendName:"webgl",kernelFunc:ate},ste="return float(!isnan(x) && !isinf(x));",ite=nt({opSnippet:ste,dtype:"bool"}),ote={kernelName:yl,backendName:"webgl",kernelFunc:ite},lte="return float(isinf(x));",ute=nt({opSnippet:lte,dtype:"bool"}),dte={kernelName:Al,backendName:"webgl",kernelFunc:ute},pte="return float(isnan(x));",cte=nt({opSnippet:pte,dtype:"bool"}),hte={kernelName:xl,backendName:"webgl",kernelFunc:cte},fte="return float(a < b);",mte=`
|
|
return vec4(lessThan(a, b));
|
|
`,gte=vn({opSnippet:fte,packedOpSnippet:mte,cpuKernelImpl:sZ,dtype:"bool"}),yte={kernelName:bl,backendName:"webgl",kernelFunc:gte},Ate="return float(a <= b);",xte=`
|
|
return vec4(lessThanEqual(a, b));
|
|
`,bte=vn({opSnippet:Ate,packedOpSnippet:xte,cpuKernelImpl:iZ,dtype:"bool"}),vte={kernelName:vl,backendName:"webgl",kernelFunc:bte};function wte(e){let{backend:t,attrs:n}=e,{start:a,stop:r,num:s}=n,i=oZ(a,r,s);return t.makeTensorInfo([i.length],"float32",i)}var kte={kernelName:sh,backendName:"webgl",kernelFunc:wte},Ite=`if (x < 0.0) return NAN;
|
|
return log(x);`,Ste=`
|
|
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:Ite,packedOpSnippet:Ste,cpuKernelImpl:lZ}),Tte={kernelName:yi,backendName:"webgl",kernelFunc:Nte},Cte="return log(1.0 + x);",Ete=nt({opSnippet:Cte}),Rte={kernelName:wl,backendName:"webgl",kernelFunc:Ete},Mte="return float(a >= 1.0 && b >= 1.0);",Fte=`
|
|
return vec4(
|
|
vec4(greaterThanEqual(a, vec4(1.0))) *
|
|
vec4(greaterThanEqual(b, vec4(1.0))));
|
|
`,Dte=vn({opSnippet:Mte,packedOpSnippet:Fte,dtype:"bool"}),$te={kernelName:kl,backendName:"webgl",kernelFunc:Dte},Ote="return float(!(x >= 1.0));",_te=nt({opSnippet:Ote}),Pte={kernelName:kd,backendName:"webgl",kernelFunc:_te},zte="return float(a >= 1.0 || b >= 1.0);",Lte=`
|
|
return min(
|
|
vec4(greaterThanEqual(a, vec4(1.0))) +
|
|
vec4(greaterThanEqual(b, vec4(1.0))),
|
|
vec4(1.0));
|
|
`,Wte=vn({opSnippet:zte,packedOpSnippet:Lte,dtype:"bool"}),Bte={kernelName:Id,backendName:"webgl",kernelFunc:Wte},Vte=class{constructor(e,t,n,a,r){this.variableNames=["x"],this.outputShape=[];let s=t,i=e[3]-1;this.outputShape=e;let o,l=`float(${n}) + float(${a}) * sum`;r===.5?o=`inversesqrt(${l})`:r===1?o=`1.0/(${l})`:o=`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 = -${s}; j <= ${s}; j++) {
|
|
int idx = d + j;
|
|
if (idx >= 0 && idx <= ${i}) {
|
|
float z = getX(b, r, c, idx);
|
|
sum += z * z;
|
|
}
|
|
}
|
|
float val = x * ${o};
|
|
setOutput(val);
|
|
}
|
|
`}},Ute=class{constructor(e,t,n,a,r){this.variableNames=["x"],this.outputShape=[],this.packedInputs=!0,this.packedOutput=!0;let s=t,i=e[3]-1;this.outputShape=e;let o,l=`float(${n}) + float(${a}) * sum`;r===.5?o=`inversesqrt(${l})`:r===1?o=`1.0/(${l})`:o=`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 - ${s};
|
|
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 = - ${s}; j <= ${s}; j++) {
|
|
ivec2 idx = depth + j;
|
|
bvec2 aboveLowerBound = greaterThanEqual(idx, ivec2(0));
|
|
bvec2 belowUpperBound = lessThanEqual(idx, ivec2(${i}));
|
|
|
|
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 * ${o};
|
|
setOutput(result);
|
|
}
|
|
`}},jte=e=>{let{inputs:t,backend:n,attrs:a}=e,{x:r}=t,{depthRadius:s,bias:i,alpha:o,beta:l}=a,d=ne().getBool("WEBGL_PACK_NORMALIZATION")?new Ute(r.shape,s,i,o,l):new Vte(r.shape,s,i,o,l);return n.runWebGLProgram(d,[r],r.dtype)},Gte={kernelName:Sd,backendName:"webgl",kernelFunc:jte},Hte=class{constructor(e,t,n,a,r){this.variableNames=["inputImage","outputImage","dy"],this.outputShape=[],this.outputShape=e,this.depth=e[3],this.depthRadius=t,this.bias=n,this.alpha=a,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(${a}) * 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(${a})
|
|
* 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);
|
|
}
|
|
`}},qte=e=>{let{inputs:t,backend:n,attrs:a}=e,{x:r,y:s,dy:i}=t,{depthRadius:o,bias:l,alpha:d,beta:u}=a,p=new Hte(r.shape,o,l,d,u);return n.runWebGLProgram(p,[r,s,i],r.dtype)},Xte={kernelName:ih,backendName:"webgl",kernelFunc:qte};function Kte(e,t,n,a){let r=w.sizeFromShape(t),s=w.sizeFromShape(e.shape)/r,i=we({inputs:{x:e},attrs:{shape:[s,r]},backend:a}),o=Co(i,e.dtype,"max",a),l=we({inputs:{x:o},attrs:{shape:n},backend:a});return a.disposeIntermediateTensorInfo(i),a.disposeIntermediateTensorInfo(o),l}function Ok(e){let{inputs:t,backend:n,attrs:a}=e,{x:r}=t,{reductionIndices:s,keepDims:i}=a,o=r.shape.length,l=w.parseAxisParam(s,r.shape),d=l,u=E.getAxesPermutation(d,o),p=u!=null,c=n.shouldExecuteOnCPU([r]),h=r;if(p){if(c){let A=n.texData.get(h.dataId).values,x=new Array(o);for(let k=0;k<x.length;k++)x[k]=r.shape[u[k]];let b=U2(A,r.shape,r.dtype,u,x);h=n.makeTensorInfo(x,r.dtype);let v=n.texData.get(h.dataId);v.values=b}else h=vf(r,u,n);d=E.getInnerMostAxes(d.length,o)}E.assertAxesAreInnerMostDims("max",d,o);let[f,m]=E.computeOutAndReduceShapes(h.shape,d),g=f;i&&(g=E.expandShapeToKeepDim(f,l));let y;if(c){let A=n.texData.get(h.dataId).values,x=uZ(A,w.sizeFromShape(m),g,r.dtype);y=n.makeTensorInfo(g,r.dtype);let b=n.texData.get(y.dataId);b.values=x}else y=Kte(h,m,g,n);return p&&n.disposeIntermediateTensorInfo(h),y}var Zte={kernelName:Ai,backendName:"webgl",kernelFunc:Ok},Yte=Q4+`
|
|
return max(a, b);
|
|
`,Jte=`
|
|
vec4 result = vec4(max(a, b));
|
|
vec4 isNaN = min(vec4(isnan(a)) + vec4(isnan(b)), vec4(1.0));
|
|
`+xf+`
|
|
return result;
|
|
`,Qte=vn({opSnippet:Yte,packedOpSnippet:Jte,cpuKernelImpl:dZ}),ene={kernelName:xi,backendName:"webgl",kernelFunc:Qte};function tne(e){let{inputs:t,backend:n,attrs:a}=e,{x:r}=t;Mu(r,"maxPool");let{filterSize:s,strides:i,pad:o,dimRoundingMode:l}=a,d=1;w.assert(E.eitherStridesOrDilationsAreOne(i,d),()=>`Error in maxPool: Either strides or dilations must be 1. Got strides ${i} and dilations '${d}'`);let u=E.computePool2DInfo(r.shape,s,i,d,o,l);if(u.filterWidth===1&&u.filterHeight===1&&w.arraysEqual(u.inShape,u.outShape))return ma({inputs:{x:r},backend:n});let p=new Wp(u,"max",!1);return n.runWebGLProgram(p,[r],r.dtype)}var nne={kernelName:bi,backendName:"webgl",kernelFunc:tne};function ane(e){let{inputs:t,backend:n,attrs:a}=e,{x:r}=t,{filterSize:s,strides:i,pad:o,dataFormat:l,dimRoundingMode:d}=a,u=[1,1,1],p=E.computePool3DInfo(r.shape,s,i,u,o,d,l),c=new H2(p,"max",!1);return n.runWebGLProgram(c,[r],r.dtype)}var rne={kernelName:Nd,backendName:"webgl",kernelFunc:ane},sne=class{constructor(e){this.variableNames=["dy","maxPos"],this.outputShape=e.inShape;let t=e.strideHeight,n=e.strideWidth,a=e.dilationHeight,r=e.effectiveFilterHeight,s=e.effectiveFilterWidth,i=r-1-e.padInfo.top,o=s-1-e.padInfo.left,l=r*s-1;this.userCode=`
|
|
const ivec2 pads = ivec2(${i}, ${o});
|
|
|
|
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 += ${a}) {
|
|
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 < ${s}; 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 * ${s} + wC;
|
|
float mask = float(maxPosValue == curPosValue ? 1.0 : 0.0);
|
|
|
|
dotProd += dyValue * mask;
|
|
}
|
|
}
|
|
setOutput(dotProd);
|
|
}
|
|
`}},ine=class{constructor(e){this.variableNames=["dy","maxPos"],this.outputShape=e.inShape;let t=e.strideDepth,n=e.strideHeight,a=e.strideWidth,r=e.dilationDepth,s=e.dilationHeight,i=e.dilationWidth,o=e.effectiveFilterDepth,l=e.effectiveFilterHeight,d=e.effectiveFilterWidth,u=o-1-e.padInfo.front,p=l-1-e.padInfo.top,c=d-1-e.padInfo.left,h=o*l*d-1;this.userCode=`
|
|
const ivec3 pads = ivec3(${u}, ${p}, ${c});
|
|
|
|
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 < ${o};
|
|
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 += ${s}) {
|
|
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 < ${d};
|
|
wC += ${i}) {
|
|
float dyC = float(dyCCorner + wC) / ${a}.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} * ${d} +
|
|
wR * ${d} + wC;
|
|
float mask = float(maxPosValue == curPosValue ? 1.0 : 0.0);
|
|
|
|
dotProd += dyValue * mask;
|
|
}
|
|
}
|
|
}
|
|
setOutput(dotProd);
|
|
}
|
|
`}};function one(e){let{inputs:t,backend:n,attrs:a}=e,{dy:r,input:s}=t,i=s,{filterSize:o,strides:l,pad:d,dimRoundingMode:u}=a,p=[1,1,1],c=E.computePool3DInfo(i.shape,o,l,p,d,u),h=new H2(c,"max",!0),f=n.runWebGLProgram(h,[i],i.dtype),m=new ine(c),g=n.runWebGLProgram(m,[r,f],i.dtype);return n.disposeIntermediateTensorInfo(f),g}var lne={kernelName:lh,backendName:"webgl",kernelFunc:one};function une(e){let{inputs:t,backend:n,attrs:a}=e,{dy:r,input:s,output:i}=t,o=s;Mu([s,i],"maxPoolGrad");let{filterSize:l,strides:d,pad:u,dimRoundingMode:p}=a,c=E.computePool2DInfo(o.shape,l,d,1,u,p),h=!0,f=new Wp(c,"max",h),m=n.runWebGLProgram(f,[o],o.dtype),g=new sne(c),y=n.runWebGLProgram(g,[r,m],o.dtype);return n.disposeIntermediateTensorInfo(m),y}var dne={kernelName:oh,backendName:"webgl",kernelFunc:une};function pne(e,t,n,a){let r=new Wp(n,"max",!1),s=a.runWebGLProgram(r,[e],"float32");r=new Wp(n,"max",!0,!0,t);let i=a.runWebGLProgram(r,[e],"float32");return[s,i]}var cne={kernelName:uh,backendName:"webgl",kernelFunc:({inputs:e,attrs:t,backend:n})=>{let{x:a}=e,{filterSize:r,strides:s,pad:i,includeBatchInIndex:o}=t,l=n;w.assert(a.shape.length===4,()=>`Error in maxPool: input must be rank 4 but got rank ${a.shape.length}.`);let d=[1,1];w.assert(E.eitherStridesOrDilationsAreOne(s,d),()=>`Error in maxPool: Either strides or dilations must be 1. Got strides ${s} and dilations '${d}'`);let u=E.computePool2DInfo(a.shape,r,s,d,i),[p,c]=pne(a,o,u,l);return[p,c]}};function hne(e,t,n,a){let r=w.sizeFromShape(t),s=w.sizeFromShape(e.shape)/r,i=we({inputs:{x:e},attrs:{shape:[s,r]},backend:a}),o=Co(i,"float32","mean",a),l=we({inputs:{x:o},attrs:{shape:n},backend:a});return a.disposeIntermediateTensorInfo(i),a.disposeIntermediateTensorInfo(o),l}var fne={kernelName:vi,backendName:"webgl",kernelFunc:({inputs:e,attrs:t,backend:n})=>{let{x:a}=e,{keepDims:r,axis:s}=t,i=n,o=a.shape.length,l=w.parseAxisParam(s,a.shape),d=l,u=E.getAxesPermutation(d,o),p=u!=null,c=i.shouldExecuteOnCPU([a]),h=[],f=a;if(p){if(c){let x=i.texData.get(f.dataId).values,b=new Array(o);for(let T=0;T<b.length;T++)b[T]=a.shape[u[T]];let v=U2(x,a.shape,a.dtype,u,b);f=i.makeTensorInfo(b,a.dtype);let k=i.texData.get(f.dataId);k.values=v}else f=vf(a,u,i);h.push(f),d=E.getInnerMostAxes(d.length,o)}E.assertAxesAreInnerMostDims("sum",d,o);let[m,g]=E.computeOutAndReduceShapes(f.shape,d),y=m;r&&(y=E.expandShapeToKeepDim(m,l));let A=hne(f,g,y,i);for(let x of h)i.disposeIntermediateTensorInfo(x);return A}};function mne(e){let{inputs:t,backend:n,attrs:a}=e,{x:r}=t,{axis:s,keepDims:i}=a,o=r.shape.length,l=w.parseAxisParam(s,r.shape),d=l,u=E.getAxesPermutation(d,o),p=r;u!=null&&(p=_n({inputs:{x:r},backend:n,attrs:{perm:u}}),d=E.getInnerMostAxes(d.length,r.shape.length)),E.assertAxesAreInnerMostDims("min",d,o);let[c,h]=E.computeOutAndReduceShapes(p.shape,d),f=w.sizeFromShape(h),m=we({inputs:{x:p},backend:n,attrs:{shape:[-1,f]}}),g=Co(m,m.dtype,"min",n),y;if(i){let A=E.expandShapeToKeepDim(c,l);y=we({inputs:{x:g},backend:n,attrs:{shape:A}})}else y=we({inputs:{x:g},backend:n,attrs:{shape:c}});return n.disposeIntermediateTensorInfo(m),n.disposeIntermediateTensorInfo(g),u!=null&&n.disposeIntermediateTensorInfo(p),y}var gne={kernelName:wi,backendName:"webgl",kernelFunc:mne},yne=Q4+`
|
|
return min(a, b);
|
|
`,Ane=`
|
|
vec4 result = vec4(min(a, b));
|
|
vec4 isNaN = min(vec4(isnan(a)) + vec4(isnan(b)), vec4(1.0));
|
|
`+xf+`
|
|
return result;
|
|
`,xne=vn({opSnippet:yne,packedOpSnippet:Ane,cpuKernelImpl:pZ}),bne={kernelName:ki,backendName:"webgl",kernelFunc:xne},vne=class{constructor(e,t,n){this.variableNames=["x"],this.outputShape=t.map((d,u)=>d[0]+e[u]+d[1]);let a=e.length,r=yt(a),s=t.map(d=>d[0]).join(","),i=t.map((d,u)=>d[0]+e[u]).join(","),o=["coords[0]","coords[1]","coords[2]","coords[3]"].slice(0,a),l=n==="reflect"?0:1;if(a===1){this.userCode=`
|
|
int start = ${s};
|
|
int end = ${i};
|
|
|
|
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}(${s});
|
|
${r} end = ${r}(${i});
|
|
|
|
void main() {
|
|
${r} outC = getOutputCoords();
|
|
for (int i = 0; i < ${a}; 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(${o}));
|
|
}
|
|
`}},wne=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 a=e.length,r=yt(a),s=t.map(h=>h[0]).join(","),i=t.map((h,f)=>h[0]+e[f]).join(","),o=On("rc",a),l=On("source",a),d=`${o[a-1]} < ${this.outputShape[a-1]}`,u=a===1?"source":`vec2(${l.slice(-2).join()})`,p=n==="reflect"?0:1,c="";if(a===1){let h=`
|
|
${r} source = rc;
|
|
if (source < start) {
|
|
source = start * 2 - source - ${p};
|
|
} else if (source >= end) {
|
|
source = (end - 1) * 2 - source + ${p};
|
|
}
|
|
source -= start;
|
|
`;c=`
|
|
${r} rc = outputLoc;
|
|
${h}
|
|
result[0] = getChannel(getX(${l.join()}), ${u});
|
|
${o[a-1]} += 1;
|
|
if(${d}) {
|
|
${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 - ${p}) +
|
|
gte * ((end - 1) * 2 - source + ${p});
|
|
source -= start;
|
|
`;c=`
|
|
${r} rc = outputLoc;
|
|
${h}
|
|
result[0] = getChannel(getX(${l.join()}), ${u});
|
|
${o[a-1]} += 1;
|
|
if(${d}) {
|
|
${h}
|
|
result[1] = getChannel(getX(${l.join()}), ${u});
|
|
}
|
|
rc = outputLoc;
|
|
${o[a-2]} += 1;
|
|
if(${o[a-2]} < ${this.outputShape[a-2]}) {
|
|
${h}
|
|
result[2] = getChannel(getX(${l.join()}), ${u});
|
|
${o[a-1]} += 1;
|
|
if(${d}) {
|
|
${h}
|
|
result[3] = getChannel(getX(${l.join()}), ${u});
|
|
}
|
|
}
|
|
`}this.userCode=`
|
|
const ${r} start = ${r}(${s});
|
|
const ${r} end = ${r}(${i});
|
|
|
|
void main() {
|
|
${r} outputLoc = getOutputCoords();
|
|
vec4 result = vec4(0.);
|
|
${c}
|
|
setOutput(result);
|
|
}
|
|
`}},kne=({inputs:e,backend:t,attrs:n})=>{let{x:a}=e,{paddings:r,mode:s}=n,i=ne().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new wne(a.shape,r,s):new vne(a.shape,r,s);return t.runWebGLProgram(i,[a],a.dtype)},Ine={kernelName:Ii,backendName:"webgl",kernelFunc:kne},Sne=`if (b == 0.0) return NAN;
|
|
return mod(a, b);`,Nne=`
|
|
vec4 result = mod(a, b);
|
|
vec4 isNaN = vec4(equal(b, vec4(0.0)));
|
|
`+xf+`
|
|
return result;
|
|
`,Tne=vn({opSnippet:Sne,packedOpSnippet:Nne}),Cne={kernelName:Il,backendName:"webgl",kernelFunc:Tne},Ene=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}));
|
|
}
|
|
`}},Rne=`
|
|
if (a == b) {
|
|
return 1.0;
|
|
};
|
|
return a / b;`,Mne=`
|
|
// 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;
|
|
`,_k=vn({opSnippet:Rne,packedOpSnippet:Mne,checkOutOfBounds:!0}),Fne={kernelName:li,backendName:"webgl",kernelFunc:_k},Pk="return a - b;",zk=vn({opSnippet:Pk,packedOpSnippet:Pk,supportsComplex:!0,cpuKernelImpl:TZ}),Dne={kernelName:Vi,backendName:"webgl",kernelFunc:zk};function Lk(e){let{inputs:t,backend:n,attrs:a}=e,{logits:r}=t,{dim:s}=a,i=w.parseAxisParam([s],r.shape),o=Ok({inputs:{x:r},backend:n,attrs:{reductionIndices:i,keepDims:!1}}),l=E.expandShapeToKeepDim(o.shape,i),d=we({inputs:{x:o},backend:n,attrs:{shape:l}}),u=zk({inputs:{a:r,b:d},backend:n}),p=Ek({inputs:{x:u},backend:n}),c=wf({inputs:{x:p},backend:n,attrs:{axis:i,keepDims:!1}}),h=we({inputs:{x:c},backend:n,attrs:{shape:l}}),f=_k({inputs:{a:p,b:h},backend:n});return n.disposeIntermediateTensorInfo(o),n.disposeIntermediateTensorInfo(d),n.disposeIntermediateTensorInfo(u),n.disposeIntermediateTensorInfo(p),n.disposeIntermediateTensorInfo(c),n.disposeIntermediateTensorInfo(h),f}var $ne={kernelName:Wi,backendName:"webgl",kernelFunc:Lk};function One(e){let{inputs:t,backend:n,attrs:a}=e,{logits:r}=t,{numSamples:s,seed:i,normalized:o}=a,l=o?r:Lk({inputs:{logits:r},backend:n,attrs:{dim:r.shape.length-1}}),d=l.shape[0],u=l.shape[1],p=new Ene(d,u,s),c=[[i]],h=n.runWebGLProgram(p,[l],"int32",c);return o||n.disposeIntermediateTensorInfo(l),h}var _ne={kernelName:dh,backendName:"webgl",kernelFunc:One},Wk="return -x;";function Pne(e){let{inputs:t,backend:n}=e,{x:a}=t;if(n.shouldExecuteOnCPU([a])){let s=n.texData.get(a.dataId),[i,o]=hZ(s.values,a.shape,a.dtype);return n.makeTensorInfo(o,a.dtype,i)}let r;return ne().getBool("WEBGL_PACK_UNARY_OPERATIONS")?r=new _u(a.shape,Wk):r=new Fs(a.shape,Wk),n.runWebGLProgram(r,[a],a.dtype)}var zne={kernelName:Sl,backendName:"webgl",kernelFunc:Pne},Lne=xr.nonMaxSuppressionV3Impl;function Wne(e){E.warn("tf.nonMaxSuppression() in webgl locks the UI thread. Call tf.nonMaxSuppressionAsync() instead");let{inputs:t,backend:n,attrs:a}=e,{boxes:r,scores:s}=t,{maxOutputSize:i,iouThreshold:o,scoreThreshold:l}=a,d=n.readSync(r.dataId),u=n.readSync(s.dataId),{selectedIndices:p}=Lne(d,u,i,o,l);return n.makeTensorInfo([p.length],"int32",new Int32Array(p))}var Bne={kernelName:Tl,backendName:"webgl",kernelFunc:Wne},Vne=xr.nonMaxSuppressionV4Impl;function Une(e){E.warn("tf.nonMaxSuppression() in webgl locks the UI thread. Call tf.nonMaxSuppressionAsync() instead");let{inputs:t,backend:n,attrs:a}=e,{boxes:r,scores:s}=t,{maxOutputSize:i,iouThreshold:o,scoreThreshold:l,padToMaxOutputSize:d}=a,u=n.readSync(r.dataId),p=n.readSync(s.dataId),{selectedIndices:c,validOutputs:h}=Vne(u,p,i,o,l,d);return[n.makeTensorInfo([c.length],"int32",new Int32Array(c)),n.makeTensorInfo([],"int32",new Int32Array([h]))]}var jne={kernelName:Cl,backendName:"webgl",kernelFunc:Une},Gne=xr.nonMaxSuppressionV5Impl;function Hne(e){E.warn("tf.nonMaxSuppression() in webgl locks the UI thread. Call tf.nonMaxSuppressionAsync() instead");let{inputs:t,backend:n,attrs:a}=e,{boxes:r,scores:s}=t,{maxOutputSize:i,iouThreshold:o,scoreThreshold:l,softNmsSigma:d}=a,u=n.readSync(r.dataId),p=n.readSync(s.dataId),c=i,h=o,f=l,m=d,{selectedIndices:g,selectedScores:y}=Gne(u,p,c,h,f,m);return[n.makeTensorInfo([g.length],"int32",new Int32Array(g)),n.makeTensorInfo([y.length],"float32",new Float32Array(y))]}var qne={kernelName:El,backendName:"webgl",kernelFunc:Hne},Xne=class{constructor(e,t,n,a){this.variableNames=["indices"],this.outputShape=[e,t],this.userCode=`
|
|
void main() {
|
|
ivec2 coords = getOutputCoords();
|
|
int index = round(getIndices(coords.x));
|
|
setOutput(mix(float(${a}), float(${n}),
|
|
float(index == coords.y)));
|
|
}
|
|
`}},Kne=e=>{let{inputs:t,backend:n,attrs:a}=e,{indices:r}=t,{depth:s,onValue:i,offValue:o}=a,l=w.sizeFromShape(r.shape),d=new Xne(l,s,i,o),u=we({inputs:{x:r},backend:n,attrs:{shape:[l]}}),p=n.runWebGLProgram(d,[u],r.dtype);n.disposeIntermediateTensorInfo(u);let c=[...r.shape,s],h=we({inputs:{x:p},backend:n,attrs:{shape:c}});return n.disposeIntermediateTensorInfo(p),h},Zne={kernelName:Ni,backendName:"webgl",kernelFunc:Kne};function Tf(e){let{inputs:t,backend:n}=e,{x:a}=t;if(a.dtype==="complex64"){let r=Bp({inputs:{input:a},backend:n}),s=Tf({inputs:{x:r},backend:n}),i=Nf({inputs:{input:a},backend:n}),o=Tf({inputs:{x:i},backend:n}),l=Ds({inputs:{real:s,imag:o},backend:n});return n.disposeIntermediateTensorInfo(r),n.disposeIntermediateTensorInfo(s),n.disposeIntermediateTensorInfo(i),n.disposeIntermediateTensorInfo(o),l}else return Vp({attrs:{shape:a.shape,dtype:a.dtype,value:a.dtype==="string"?"":0},backend:n})}var Yne={kernelName:Xl,backendName:"webgl",kernelFunc:Tf};function Bk(e){let{inputs:t,backend:n}=e,{x:a}=t;if(a.dtype==="string")throw new Error("onesLike is not supported under string dtype");if(a.dtype==="complex64"){let r=Bp({inputs:{input:a},backend:n}),s=Bk({inputs:{x:r},backend:n}),i=Nf({inputs:{input:a},backend:n}),o=Tf({inputs:{x:i},backend:n}),l=Ds({inputs:{real:s,imag:o},backend:n});return n.disposeIntermediateTensorInfo(r),n.disposeIntermediateTensorInfo(s),n.disposeIntermediateTensorInfo(i),n.disposeIntermediateTensorInfo(o),l}else return Vp({attrs:{shape:a.shape,dtype:a.dtype,value:1},backend:n})}var Jne={kernelName:Rl,backendName:"webgl",kernelFunc:Bk};function Qne(e){let{inputs:t,backend:n,attrs:a}=e,{axis:r}=a;if(t.length===1)return K2({inputs:{input:t[0]},backend:n,attrs:{dim:r}});let s=t[0].shape,i=t[0].dtype;t.forEach(u=>{w.assertShapesMatch(s,u.shape,"All tensors passed to stack must have matching shapes"),w.assert(i===u.dtype,()=>"All tensors passed to stack must have matching dtypes")});let o=[],l=t.map(u=>{let p=K2({inputs:{input:u},backend:n,attrs:{dim:r}});return o.push(p),p}),d=xk({inputs:l,backend:n,attrs:{axis:r}});return o.forEach(u=>n.disposeIntermediateTensorInfo(u)),d}var eae={kernelName:Ml,backendName:"webgl",kernelFunc:Qne},tae=class{constructor(e,t,n){this.variableNames=["x"],this.customUniforms=[{name:"value",type:"float"}],this.outputShape=t.map((l,d)=>l[0]+e[d]+l[1]);let a=e.length,r=yt(a),s=t.map(l=>l[0]).join(","),i=t.map((l,d)=>l[0]+e[d]).join(","),o=["coords[0]","coords[1]","coords[2]","coords[3]"].slice(0,a);if(a===1){this.userCode=`
|
|
int start = ${s};
|
|
int end = ${i};
|
|
|
|
void main() {
|
|
int outC = getOutputCoords();
|
|
if (outC < start || outC >= end) {
|
|
setOutput(value);
|
|
} else {
|
|
setOutput(getX(outC - start));
|
|
}
|
|
}
|
|
`;return}this.userCode=`
|
|
${r} start = ${r}(${s});
|
|
${r} end = ${r}(${i});
|
|
|
|
void main() {
|
|
${r} outC = getOutputCoords();
|
|
if (any(lessThan(outC, start)) || any(greaterThanEqual(outC, end))) {
|
|
setOutput(value);
|
|
} else {
|
|
${r} coords = outC - start;
|
|
setOutput(getX(${o}));
|
|
}
|
|
}
|
|
`}},nae=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 a=e.length,r=yt(a),s=t.map(f=>f[0]).join(","),i=t.map((f,m)=>f[0]+e[m]).join(","),o=On("rc",a),l=On("source",a),d=`${o[a-1]} < ${this.outputShape[a-1]}`,u=a===1?"source":`vec2(${l.slice(-2).join()})`,p=[`${r} rc = outputLoc;`,`${o[a-1]} += 1;
|
|
if(${d}) {
|
|
`,a===1?"":`}
|
|
rc = outputLoc;
|
|
${o[a-2]} += 1;
|
|
if(${o[a-2]} < ${this.outputShape[a-2]}) {`,a===1?"":` ${o[a-1]} += 1;
|
|
if(${d}) {`],c=a===1?"rc < start || rc >= end":"any(lessThan(rc, start)) || any(greaterThanEqual(rc, end))",h="";for(let f=0,m=a===1?2:4;f<m;f++)h+=`
|
|
${p[f]}
|
|
if (${c}) {
|
|
result[${f}] = float(value);
|
|
} else {
|
|
${r} source = rc - start;
|
|
result[${f}] = getChannel(getX(${l.join()}), ${u});
|
|
}
|
|
`;h+=a===1?"} ":"}}",this.userCode=`
|
|
const ${r} start = ${r}(${s});
|
|
const ${r} end = ${r}(${i});
|
|
|
|
void main() {
|
|
${r} outputLoc = getOutputCoords();
|
|
vec4 result = vec4(0.);
|
|
${h}
|
|
setOutput(result);
|
|
}
|
|
`}},Vk=e=>{let{inputs:t,backend:n,attrs:a}=e,{x:r}=t,{paddings:s,constantValue:i}=a;if(w.sizeFromShape(r.shape)===0){let d=s.map((u,p)=>u[0]+r.shape[p]+u[1]);return Vp({backend:n,attrs:{shape:d,value:i,dtype:r.dtype}})}let o=ne().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new nae(r.shape,s,i):new tae(r.shape,s,i),l=[[i]];return n.runWebGLProgram(o,[r],r.dtype,l)},aae={kernelName:Ti,backendName:"webgl",kernelFunc:Vk},rae=`
|
|
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);
|
|
`,sae=`
|
|
// 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));
|
|
`+xf+`
|
|
return result;
|
|
`,iae=vn({opSnippet:rae,packedOpSnippet:sae}),oae={kernelName:Ci,backendName:"webgl",kernelFunc:iae};function lae(e){let{inputs:t,backend:n,attrs:a}=e,{x:r}=t,{axis:s,keepDims:i}=a,o=r.shape.length,l=[],d=w.parseAxisParam(s,r.shape),u=d,p=E.getAxesPermutation(u,o),c=r;p!=null&&(c=_n({inputs:{x:r},backend:n,attrs:{perm:p}}),u=E.getInnerMostAxes(u.length,o),l.push(c)),E.assertAxesAreInnerMostDims("prod",u,o);let h;if(n.shouldExecuteOnCPU([c])){let f=n.texData.get(c.dataId).values,{outVals:m,outShape:g,outDtype:y}=mZ(c.shape,c.dtype,f,u);h=n.makeTensorInfo(g,y,m)}else{let[f,m]=E.computeOutAndReduceShapes(c.shape,u),g=w.sizeFromShape(m),y=we({inputs:{x:c},backend:n,attrs:{shape:[-1,g]}}),A=Eh(r.dtype),x=Co(y,A,"prod",n);h=we({inputs:{x},backend:n,attrs:{shape:f}}),l.push(y),l.push(x)}if(i){l.push(h);let f=E.expandShapeToKeepDim(h.shape,d);h=we({inputs:{x:h},backend:n,attrs:{shape:f}})}return l.forEach(f=>n.disposeIntermediateTensorInfo(f)),h}var uae={kernelName:Fl,backendName:"webgl",kernelFunc:lae},Uk=e=>{let{backend:t,attrs:n}=e,{start:a,stop:r,step:s,dtype:i}=n,o=gZ(a,r,s,i);return t.makeTensorInfo([o.length],i,o)},dae={kernelName:Td,backendName:"webgl",kernelFunc:Uk},pae="return 1.0 / x;",cae=nt({opSnippet:pae}),hae={kernelName:Dl,backendName:"webgl",kernelFunc:cae},fae=lr+`
|
|
return (x < 0.0) ? 0.0 : x;
|
|
`,mae=`
|
|
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;
|
|
`,gae=nt({opSnippet:fae,packedOpSnippet:mae}),yae={kernelName:Ri,backendName:"webgl",kernelFunc:gae},Aae=lr+`
|
|
return (x < 0.0) ? 0.0 : min(6.0, x);
|
|
`,xae=`
|
|
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;
|
|
`,bae=nt({opSnippet:Aae,packedOpSnippet:xae}),vae={kernelName:Fi,backendName:"webgl",kernelFunc:bae},wae=class{constructor(e,t,n,a,r){this.variableNames=["A"],this.outputShape=[];let[s,i,o,l]=e;this.outputShape=[s,t,n,l];let d=[a&&t>1?i-1:i,a&&n>1?o-1:o],u=[a&&t>1?t-1:t,a&&n>1?n-1:n],p;r?p="(vec2(yRC) + vec2(0.5)) * effectiveInputOverOutputRatioRC - vec2(0.5)":p="vec2(yRC) * effectiveInputOverOutputRatioRC",this.userCode=`
|
|
const vec2 effectiveInputOverOutputRatioRC = vec2(
|
|
${d[0]/u[0]},
|
|
${d[1]/u[1]});
|
|
const vec2 inputShapeRC = vec2(${i}.0, ${o}.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 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);
|
|
}
|
|
`}},kae=class{constructor(e,t,n,a,r){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=[];let[s,i,o,l]=e;this.outputShape=[s,t,n,l];let d=[a&&t>1?i-1:i,a&&n>1?o-1:o],u=[a&&t>1?t-1:t,a&&n>1?n-1:n],p;r?p="(vec3(yRC) + vec3(0.5)) * effectiveInputOverOutputRatioRC - vec3(0.5)":p="vec3(yRC) * effectiveInputOverOutputRatioRC",this.userCode=`
|
|
const vec3 effectiveInputOverOutputRatioRC = vec3(
|
|
${d[0]/u[0]},
|
|
${d[1]/u[1]},
|
|
${d[1]/u[1]});
|
|
const vec3 inputShapeRC = vec3(${i}.0, ${o}.0,
|
|
${o}.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 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 Iae(e){let{inputs:t,backend:n,attrs:a}=e,{images:r}=t,{alignCorners:s,halfPixelCenters:i,size:o}=a,[l,d]=o,u=ne().getBool("WEBGL_PACK_IMAGE_OPERATIONS")?new kae(r.shape,l,d,s,i):new wae(r.shape,l,d,s,i);return n.runWebGLProgram(u,[r],"float32")}var Sae={kernelName:Mi,backendName:"webgl",kernelFunc:Iae},Nae=class{constructor(e,t,n){this.variableNames=["dy"],this.outputShape=[],this.outputShape=t;let[,a,r]=t,[,s,i]=e,o=[n&&s>1?a-1:a,n&&i>1?r-1:r],l=[n&&s>1?s-1:s,n&&i>1?i-1:i],d=o[0]/l[0],u=o[1]/l[1],p=1/d,c=1/u,h=Math.ceil(p)*2+2,f=Math.ceil(c)*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(${d});
|
|
const float widthScale = float(${u});
|
|
|
|
const float invHeightScale = float(${p});
|
|
const float invWidthScale = float(${c});
|
|
|
|
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 >= ${s}) {
|
|
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 >= ${i}) {
|
|
continue;
|
|
}
|
|
|
|
float dxR = float(dyR) * heightScale;
|
|
int topDxRIndex = int(floor(dxR));
|
|
int bottomDxRIndex = int(min(ceil(dxR), ${a-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 Tae(e){let{inputs:t,backend:n,attrs:a}=e,{images:r,dy:s}=t,{alignCorners:i}=a,o=new Nae(s.shape,r.shape,i);return n.runWebGLProgram(o,[s],s.dtype)}var Cae={kernelName:hh,backendName:"webgl",kernelFunc:Tae},Eae=class{constructor(e,t,n,a,r){this.variableNames=["A"],this.outputShape=[];let[s,i,o,l]=e;this.outputShape=[s,t,n,l];let d=[a&&t>1?i-1:i,a&&n>1?o-1:o],u=[a&&t>1?t-1:t,a&&n>1?n-1:n],p=a?"0.5":"0.0",c;r?c="max((vec2(yRC) + vec2(0.5)) * effectiveInputOverOutputRatioRC, vec2(0.0))":c="vec2(yRC) * effectiveInputOverOutputRatioRC",this.userCode=`
|
|
const vec2 effectiveInputOverOutputRatioRC = vec2(
|
|
${d[0]/u[0]},
|
|
${d[1]/u[1]});
|
|
const vec2 inputShapeRC = vec2(${i}.0, ${o}.0);
|
|
|
|
void main() {
|
|
ivec4 coords = getOutputCoords();
|
|
int b = coords[0];
|
|
int d = coords[3];
|
|
ivec2 yRC = coords.yz;
|
|
|
|
// Fractional source index.
|
|
vec2 sourceFracIndexRC = ${c};
|
|
|
|
// Compute the coordinators of nearest neighbor point.
|
|
ivec2 sourceNearestRC = ivec2(
|
|
min(inputShapeRC - 1.0, floor(sourceFracIndexRC + ${p})));
|
|
float newValue = getA(b, sourceNearestRC.x, sourceNearestRC.y, d);
|
|
|
|
setOutput(newValue);
|
|
}
|
|
`}},Rae=class{constructor(e,t,n,a,r){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=[];let[s,i,o,l]=e;this.outputShape=[s,t,n,l];let d=[a&&t>1?i-1:i,a&&n>1?o-1:o],u=[a&&t>1?t-1:t,a&&n>1?n-1:n],p=a?"0.5":"0.0",c;r?c="max((vec3(yRC) + vec3(0.5)) * effectiveInputOverOutputRatioRC, vec3(0.0))":c="vec3(yRC) * effectiveInputOverOutputRatioRC",this.userCode=`
|
|
const vec3 effectiveInputOverOutputRatioRC = vec3(
|
|
${d[0]/u[0]},
|
|
${d[1]/u[1]},
|
|
${d[1]/u[1]});
|
|
const vec3 inputShapeRC = vec3(${i}.0, ${o}.0,
|
|
${o}.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 = ${c};
|
|
|
|
// Compute the coordinators of nearest neighbor point.
|
|
ivec3 sourceNearestRC = ivec3(
|
|
min(inputShapeRC - 1.0, floor(sourceFracIndexRC + ${p})));
|
|
|
|
// 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 Mae(e){let{inputs:t,backend:n,attrs:a}=e,{images:r}=t,{alignCorners:s,halfPixelCenters:i,size:o}=a,[l,d]=o,u=ne().getBool("WEBGL_PACK_IMAGE_OPERATIONS")?new Rae(r.shape,l,d,s,i):new Eae(r.shape,l,d,s,i);return n.runWebGLProgram(u,[r],r.dtype)}var Fae={kernelName:Cd,backendName:"webgl",kernelFunc:Mae},Dae=class{constructor(e,t,n){this.variableNames=["dy"],this.outputShape=[],this.outputShape=t;let[,a,r]=t,[,s,i]=e,o=[n&&s>1?a-1:a,n&&i>1?r-1:r],l=[n&&s>1?s-1:s,n&&i>1?i-1:i],d=o[0]/l[0],u=o[1]/l[1],p=1/d,c=1/u,h=Math.ceil(p)*2+2,f=Math.ceil(c)*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(${d});
|
|
const float widthScale = float(${u});
|
|
|
|
const float invHeightScale = float(${p});
|
|
const float invWidthScale = float(${c});
|
|
|
|
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 >= ${s}) {
|
|
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 >= ${i}) {
|
|
continue;
|
|
}
|
|
|
|
float sourceFracRow =
|
|
float(${o[0]}) *
|
|
(float(dyR) / float(${l[0]}));
|
|
|
|
float sourceFracCol =
|
|
float(${o[1]}) *
|
|
(float(dyC) / float(${l[1]}));
|
|
|
|
int sourceNearestRow = int(min(
|
|
float(int(${a}) - 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 $ae(e){let{inputs:t,backend:n,attrs:a}=e,{images:r,dy:s}=t,{alignCorners:i}=a,o=new Dae(s.shape,r.shape,i);return n.runWebGLProgram(o,[s],s.dtype)}var Oae={kernelName:ch,backendName:"webgl",kernelFunc:$ae},_ae=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 a=i=>t.indexOf(i)!==-1&&e[i]!==1?`${e[i]} - coords[${i}] - 1`:`coords[${i}]`,r=e.map((i,o)=>a(o)).join(","),s=yt(n);this.userCode=`
|
|
void main() {
|
|
${s} coords = getOutputCoords();
|
|
setOutput(getX(${r}));
|
|
}
|
|
`}},Pae=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 a=On("rc",n),r=`${a[n-1]} + 1 < ${this.outputShape[n-1]}`,s=`${a[n-2]} + 1 < ${this.outputShape[n-2]}`,i=yt(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() {
|
|
${i} rc = getOutputCoords();
|
|
vec4 result = vec4(0.);
|
|
result.r = ${o(a.slice())};
|
|
if(${r}){
|
|
result.g = ${l(a.slice())};
|
|
}
|
|
if(${s}) {
|
|
result.b = ${d(a.slice())};
|
|
if(${r}) {
|
|
result.a = ${u(a.slice())};
|
|
}
|
|
}
|
|
setOutput(result);
|
|
}
|
|
`;function o(h){return p(h)}function l(h){return h[n-1]="("+h[n-1]+" + 1)",p(h)}function d(h){return h[n-2]="("+h[n-2]+" + 1)",p(h)}function u(h){return h[n-1]="("+h[n-1]+" + 1)",h[n-2]="("+h[n-2]+" + 1)",p(h)}function p(h){let f=e.map((y,A)=>c(A,h)),m=f.join(","),g=f.slice(-2).join(",");return`getChannel(getX(${m}), vec2(${g}))`}function c(h,f){return t.indexOf(h)!==-1&&e[h]!==1?`${e[h]} - ${f[h]} - 1`:`${f[h]}`}}};function zae(e){let{inputs:t,backend:n,attrs:a}=e,{x:r}=t,{dims:s}=a,i=r.shape.length,o=w.parseAxisParam(s,r.shape);if(i===0)return ma({inputs:{x:r},backend:n});let l=ne().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new Pae(r.shape,o):new _ae(r.shape,o);return n.runWebGLProgram(l,[r],r.dtype)}var Lae={kernelName:Di,backendName:"webgl",kernelFunc:zae},Wae=class{constructor(e,t){this.variableNames=["Image"],this.outputShape=[],this.customUniforms=[{name:"params",type:"vec4"}];let n=e[1],a=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 < ${a} && coordY >= 0 && coordY < ${n}) {
|
|
outputValue = getImage(coords[0], coordY, coordX, coords[3]);
|
|
}
|
|
setOutput(outputValue);
|
|
}
|
|
`}},Bae={kernelName:Kl,backendName:"webgl",kernelFunc:({inputs:e,attrs:t,backend:n})=>{let{image:a}=e,{radians:r,fillValue:s,center:i}=t,o=n,l=new Wae(a.shape,s),[d,u]=E.getImageCenter(i,a.shape[1],a.shape[2]),p=[[d,u,Math.sin(r),Math.cos(r)]];return o.runWebGLProgram(l,[a],a.dtype,p)}},Vae=`
|
|
// 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;
|
|
}
|
|
}
|
|
`,Uae=nt({opSnippet:Vae}),jae={kernelName:$i,backendName:"webgl",kernelFunc:Uae},Gae="return inversesqrt(x);",Hae=nt({opSnippet:Gae,cpuKernelImpl:yZ}),qae={kernelName:Oi,backendName:"webgl",kernelFunc:Hae},jk=class{constructor(e,t,n,a,r,s,i=!0){this.variableNames=["updates","indices","defaultValue"],this.outputShape=s;let o=yt(r.length),l=yt(s.length),d="";n===1?d="i":n===2&&(d="i, j");let u=`getIndices(${d})`,p="";a===1?p="i":a===2&&(p="i, coords[1]");let c=`getUpdates(${p})`,h=t>1?"strides[j]":"strides";this.userCode=`
|
|
${o} strides = ${o}(${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 += ${c};
|
|
found = true;
|
|
}
|
|
}
|
|
setOutput(mix(getDefaultValue(), sum, float(found)));
|
|
}
|
|
`}};function Xae(e){let{inputs:t,backend:n,attrs:a}=e,{indices:r,updates:s}=t,{shape:i}=a,{sliceRank:o,numUpdates:l,sliceSize:d,strides:u,outputSize:p}=E.calculateShapes(s,r,i),c=[p/d,d];if(p===0)return n.makeTensorInfo(i,r.dtype);let h=we({inputs:{x:r},backend:n,attrs:{shape:[l,o]}}),f=we({inputs:{x:s},backend:n,attrs:{shape:[l,d]}}),m=n.makeTensorInfo([],"float32",new Float32Array([0])),g=new jk(l,o,h.shape.length,f.shape.length,u,c),y=n.runWebGLProgram(g,[f,h,m],f.dtype),A=we({inputs:{x:y},backend:n,attrs:{shape:i}});return n.disposeIntermediateTensorInfo(h),n.disposeIntermediateTensorInfo(f),n.disposeIntermediateTensorInfo(y),n.disposeIntermediateTensorInfo(m),A}var Kae={kernelName:Ol,backendName:"webgl",kernelFunc:Xae},Zae=class{constructor(e,t,n){this.variableNames=["c","a","b"],this.outputShape=t;let a,r;if(n>4)throw Error(`Where for rank ${n} is not yet supported`);if(n===1)r="resRC",a="resRC";else{let i=["resRC.x","resRC.y","resRC.z","resRC.w"],o=[],l=[];for(let d=0;d<t.length;d++)l.push(`${i[d]}`),d<e&&o.push(`${i[d]}`);a=o.join(),r=l.join()}let s=yt(n);this.userCode=`
|
|
void main() {
|
|
${s} resRC = getOutputCoords();
|
|
float cVal = getC(${a});
|
|
if (cVal >= 1.0) {
|
|
setOutput(getA(${r}));
|
|
} else {
|
|
setOutput(getB(${r}));
|
|
}
|
|
}
|
|
`}};function Yae(e){let{inputs:t,backend:n}=e,{condition:a,t:r,e:s}=t,i=new Zae(a.shape.length,r.shape,r.shape.length);return n.runWebGLProgram(i,[a,r,s],Pa(r.dtype,s.dtype))}var Jae={kernelName:_l,backendName:"webgl",kernelFunc:Yae},Qae=`
|
|
// Stable and Attracting Fixed Point (0, 1) for Normalized Weights.
|
|
// see: https://arxiv.org/abs/1706.02515
|
|
float scaleAlpha = ${E.SELU_SCALEALPHA};
|
|
float scale = ${E.SELU_SCALE};
|
|
return (x >= 0.0) ? scale * x : scaleAlpha * (exp(x) - 1.0);
|
|
`,ere=nt({opSnippet:Qae}),tre={kernelName:Pl,backendName:"webgl",kernelFunc:ere},Gk="return 1.0 / (1.0 + exp(-1.0 * x));",nre=nt({opSnippet:Gk,packedOpSnippet:Gk,cpuKernelImpl:AZ}),are={kernelName:Pi,backendName:"webgl",kernelFunc:nre},rre=`
|
|
if (isnan(x)) { return 0.0; }
|
|
return sign(x);
|
|
`,sre=nt({opSnippet:rre}),ire={kernelName:Wl,backendName:"webgl",kernelFunc:sre},ore=rk+`
|
|
return sin(x);
|
|
`,lre=nt({opSnippet:ore}),ure={kernelName:_i,backendName:"webgl",kernelFunc:lre},dre=`
|
|
float e2x = exp(x);
|
|
return (e2x - 1.0 / e2x) / 2.0;
|
|
`,pre=nt({opSnippet:dre}),cre={kernelName:Ll,backendName:"webgl",kernelFunc:pre},hre=`
|
|
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;
|
|
`,fre=nt({opSnippet:hre}),mre={kernelName:Bl,backendName:"webgl",kernelFunc:fre},gre=e=>{let{inputs:t,backend:n,attrs:a}=e,{x:r}=t,{blockShape:s,paddings:i}=a;w.assert(r.shape.length<=4,()=>"spaceToBatchND for rank > 4 with a WebGL backend not implemented yet");let o=s.reduce((y,A)=>y*A),l=[[0,0]];l.push(...i);for(let y=1+s.length;y<r.shape.length;++y)l.push([0,0]);let d=[],u=Vk({inputs:{x:r},backend:n,attrs:{paddings:l,constantValue:0}}),p=E.getReshaped(u.shape,s,o,!1),c=E.getPermuted(p.length,s.length,!1),h=E.getReshapedPermuted(u.shape,s,o,!1),f=we({inputs:{x:u},backend:n,attrs:{shape:p}}),m=_n({inputs:{x:f},backend:n,attrs:{perm:c}}),g=we({inputs:{x:m},backend:n,attrs:{shape:h}});return d.push(u),d.push(f),d.push(m),d.forEach(y=>n.disposeIntermediateTensorInfo(y)),g},yre={kernelName:Vl,backendName:"webgl",kernelFunc:gre};function Are(e){let{inputs:t,backend:n}=e,{indices:a,values:r,denseShape:s,defaultValue:i}=t;if(s.shape.length!==1)throw new Error(`Dense shape must be a vector, saw:
|
|
${s.shape}`);if(a.shape.length!==2)throw new Error(`Indices must be a matrix, saw:
|
|
${a.shape}`);if(r.shape.length!==1)throw new Error(`Values must be a vector, saw:
|
|
${r.shape}`);if(i.shape.length!==0)throw new Error(`Default value must be a scalar, saw:
|
|
${i.shape}`);let o=n.readSync(a.dataId),l=n.readSync(r.dataId),d=n.readSync(s.dataId),u=n.readSync(i.dataId)[0],[p,c,h,f,m]=bZ(o,a.shape,a.dtype,l,r.dtype,d,u);return[n.makeTensorInfo(c,a.dtype,p),n.makeTensorInfo([c[0]],r.dtype,h),n.makeTensorInfo([f.length],"bool",new Uint8Array(f.map(g=>Number(g)))),n.makeTensorInfo([m.length],a.dtype,new Int32Array(m))]}var xre={kernelName:fh,backendName:"webgl",kernelFunc:Are};function bre(e){let{inputs:t,backend:n}=e,{inputIndices:a,inputShape:r,newShape:s}=t;if(a.shape.length!==2)throw new Error(`Input indices should be a matrix but received shape ${a.shape}`);if(r.shape.length!==1)throw new Error(`Input shape should be a vector but received shape ${r.shape}`);if(s.shape.length!==1)throw new Error(`Target shape should be a vector but received shape ${s.shape}`);let i=Array.from(n.readSync(r.dataId)),o=n.readSync(a.dataId),l=Array.from(n.readSync(s.dataId)),[d,u,p]=vZ(o,a.shape,a.dtype,i,l);return[n.makeTensorInfo(u,a.dtype,d),n.makeTensorInfo([p.length],s.dtype,new Int32Array(p))]}var vre={kernelName:mh,backendName:"webgl",kernelFunc:bre};function wre(e){let{inputs:t,backend:n}=e,{data:a,indices:r,segmentIds:s}=t;if(a.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(s.shape.length!==1)throw new Error(`Segment ids should be a vector but received shape
|
|
${s.shape}`);let i=n.readSync(a.dataId),o=n.readSync(r.dataId),l=n.readSync(s.dataId),[d,u]=G4(i,a.shape,a.dtype,o,l,!0);return n.makeTensorInfo(u,a.dtype,d)}var kre={kernelName:gh,backendName:"webgl",kernelFunc:wre};function Ire(e){let{inputs:t,backend:n}=e,{data:a,indices:r,segmentIds:s}=t;if(a.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(s.shape.length!==1)throw new Error(`Segment ids should be a vector but received shape
|
|
${s.shape}`);let i=n.readSync(a.dataId),o=n.readSync(r.dataId),l=n.readSync(s.dataId),[d,u]=G4(i,a.shape,a.dtype,o,l);return n.makeTensorInfo(u,a.dtype,d)}var Sre={kernelName:yh,backendName:"webgl",kernelFunc:Ire};function Nre(e){let{inputs:t,backend:n,attrs:a}=e,{sparseIndices:r,sparseValues:s,defaultValue:i}=t,{outputShape:o}=a,{sliceRank:l,numUpdates:d,strides:u,outputSize:p}=E.calculateShapes(s,r,o),c=!1,h=new jk(d,l,r.shape.length,s.shape.length,u,[p,1],c),f=n.runWebGLProgram(h,[s,r,i],s.dtype),m=we({inputs:{x:f},backend:n,attrs:{shape:o}});return n.disposeIntermediateTensorInfo(f),m}var Tre={kernelName:Ah,backendName:"webgl",kernelFunc:Nre};function Cre(e){let{inputs:t,backend:n,attrs:a}=e,{x:r}=t,{numOrSizeSplits:s,axis:i}=a,o=w.parseAxisParam(i,r.shape)[0],l=E.prepareSplitSize(r,s,o),d=r.shape.length,u=new Array(d).fill(0),p=r.shape.slice();return l.map(c=>{let h=[...p];h[o]=c;let f=Lu({inputs:{x:r},backend:n,attrs:{begin:u,size:h}});return u[o]+=c,f})}var Ere={kernelName:Ul,backendName:"webgl",kernelFunc:Cre},Hk="return sqrt(x);",Rre=nt({opSnippet:Hk,packedOpSnippet:Hk,cpuKernelImpl:wZ}),Mre={kernelName:zi,backendName:"webgl",kernelFunc:Rre},Fre="return x * x;",Dre=nt({opSnippet:Fre}),$re={kernelName:Ed,backendName:"webgl",kernelFunc:Dre},qk="return (a - b) * (a - b);",Ore=vn({opSnippet:qk,packedOpSnippet:qk}),_re={kernelName:Bi,backendName:"webgl",kernelFunc:Ore};function Pre({inputs:e,attrs:t,backend:n}){let{x:a}=e,r=lr+`
|
|
return x > 0.0 ? 1.0 : float(${t.alpha});
|
|
`,s=new Fs(a.shape,r);return n.runWebGLProgram(s,[a],a.dtype)}var zre={kernelName:ps,backendName:"webgl",kernelFunc:Pre},Lre=class{constructor(e,t,n){this.variableNames=["x"],this.outputShape=n;let a=n.length,r=yt(n.length),s=yt(n.length),i="";if(a===1)i="coords * strides + begin";else{let o=0;i=n.map((l,d)=>(o++,n.length===1?`coords * strides[${d}] + begin[${d}]`:`coords[${o-1}] * strides[${d}] + begin[${d}]`)).join(",")}this.userCode=`
|
|
${r} begin = ${r}(${e});
|
|
${r} strides = ${r}(${t});
|
|
|
|
void main() {
|
|
${s} coords = getOutputCoords();
|
|
setOutput(getX(${i}));
|
|
}
|
|
`}};function Wre(e){let{inputs:t,backend:n,attrs:a}=e,{x:r}=t,{begin:s,end:i,strides:o,beginMask:l,endMask:d,ellipsisMask:u,newAxisMask:p,shrinkAxisMask:c}=a,{nonStrided:h,$begin:f,$strides:m,size:g,newShape:y,outShape:A}=En.sliceInfo(r.shape,s,i,o,l,d,u,p,c),x=we({inputs:{x:r},backend:n,attrs:{shape:y}}),b;if(h){let k=Lu({inputs:{x},backend:n,attrs:{begin:f,size:g}});b=we({inputs:{x:k},backend:n,attrs:{shape:A}}),n.disposeIntermediateTensorInfo(k)}else if(A.some(k=>k===0))b=n.makeTensorInfo(A,r.dtype,[]);else if(n.shouldExecuteOnCPU([x])){let k=n.texData.get(x.dataId).values,T=Ge(x.shape,x.dtype,k),C=kZ(A,T,m,f);b=n.makeTensorInfo(A,x.dtype,C.values)}else{let k=new Lre(f,m,A);b=n.runWebGLProgram(k,[x],x.dtype)}let v=we({inputs:{x:b},backend:n,attrs:{shape:A}});return n.disposeIntermediateTensorInfo(x),n.disposeIntermediateTensorInfo(b),v}var Bre={kernelName:jl,backendName:"webgl",kernelFunc:Wre};function Vre(e){let{inputs:t,backend:n,attrs:a}=e,{separator:r,nGramWidths:s,leftPad:i,rightPad:o,padWidth:l,preserveShortSequences:d}=a,{data:u,dataSplits:p}=t,c=n.readSync(u.dataId),h=n.readSync(p.dataId),[f,m]=IZ(c,h,r,s,i,o,l,d);return[n.makeTensorInfo([f.length],"string",f),n.makeTensorInfo(p.shape,"int32",m)]}var Ure={kernelName:xh,backendName:"webgl",kernelFunc:Vre};function jre(e){let{inputs:t,backend:n,attrs:a}=e,{skipEmpty:r}=a,{input:s,delimiter:i}=t;if(s.dtype!=="string")throw new Error("Input must be of datatype string");if(s.shape.length!==1)throw new Error(`Input must be a vector, got shape: ${s.shape}`);if(i.shape.length!==0)throw new Error(`Delimiter must be a scalar, got shape: ${i.shape}`);let o=n.readSync(s.dataId),l=n.readSync(i.dataId)[0],[d,u,p]=SZ(o,l,r),c=u.length;return[n.makeTensorInfo([c,2],"int32",d),n.makeTensorInfo([c],"string",u),n.makeTensorInfo([2],"int32",new Int32Array(p))]}var Gre={kernelName:bh,backendName:"webgl",kernelFunc:jre};function Hre(e){let{inputs:t,backend:n,attrs:a}=e,{numBuckets:r}=a,{input:s}=t;if(s.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 i=n.readSync(s.dataId),o=NZ(i,r);return n.makeTensorInfo(s.shape,"int32",o)}var qre={kernelName:vh,backendName:"webgl",kernelFunc:Hre},Xre="return tan(x);",Kre=nt({opSnippet:Xre}),Zre={kernelName:Ui,backendName:"webgl",kernelFunc:Kre},Yre=`
|
|
float e2x = exp(-2.0 * abs(x));
|
|
return sign(x) * (1.0 - e2x) / (1.0 + e2x);
|
|
`,Jre=nt({opSnippet:Yre}),Qre={kernelName:ji,backendName:"webgl",kernelFunc:Jre},ese=class{constructor(e,t){this.variableNames=["A"];let n=new Array(e.length);for(let s=0;s<n.length;s++)n[s]=e[s]*t[s];this.outputShape=n,this.rank=n.length;let a=yt(this.rank),r=tse(e);this.userCode=`
|
|
void main() {
|
|
${a} resRC = getOutputCoords();
|
|
setOutput(getA(${r}));
|
|
}
|
|
`}};function tse(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"],a=[];for(let r=0;r<e.length;r++)a.push(`imod(${n[r]}, ${e[r]})`);return a.join()}function Xk(e){let{inputs:t,backend:n,attrs:a}=e,{x:r}=t,{reps:s}=a;if(r.dtype==="string"||r.shape.length>5){let o=n.readSync(r.dataId),l=r.dtype==="string"?o.map(p=>w.decodeString(p)):o,d=Ge(r.shape,r.dtype,l),u=CZ(d,s);return n.makeTensorInfo(u.shape,u.dtype,u.values)}let i=new ese(r.shape,s);return n.runWebGLProgram(i,[r],r.dtype)}var nse={kernelName:ds,backendName:"webgl",kernelFunc:Xk},ase=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));
|
|
}
|
|
}
|
|
`}},rse=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 Eo(e,t){t!==null&&e.disposeIntermediateTensorInfo(t)}function Kk(e){let t=1;for(;t<e;)t*=2;return t}function sse(e){let{inputs:t,backend:n,attrs:a}=e,{x:r}=t,{k:s,sorted:i}=a,o=ne().getNumber("TOPK_LAST_DIM_CPU_HANDOFF_SIZE_THRESHOLD"),l=ne().getNumber("TOPK_K_CPU_HANDOFF_THRESHOLD"),d=r.shape,u=d[d.length-1];if(n.shouldExecuteOnCPU([r])||u<o||s>l){let D=n.readSync(r.dataId),[O,F]=EZ(D,d,r.dtype,s,i);return[n.makeTensorInfo(O.shape,O.dtype,O.values),n.makeTensorInfo(F.shape,F.dtype,F.values)]}if(s===0)return d[d.length-1]=0,[n.makeTensorInfo(d,r.dtype,[]),n.makeTensorInfo(d,"int32",[])];if(u===1)return[r,Vp({attrs:{shape:d,dtype:"int32",value:0},backend:n})];let p=n.texData.get(r.dataId),c=p!==null&&p.isPacked,h=c?n.unpackTensor(r):r,f=w.sizeFromShape(d)/u,m=we({inputs:{x:h},attrs:{shape:[f,u]},backend:n});c&&Eo(n,h);let g=Kk(s),y=Kk(u),A=null,x=()=>A===null?[m,m]:[m,A],b=(D,O,F)=>{let S=x(),P=new ase(F),_=[[u],[A===null?1:0],[Number.NEGATIVE_INFINITY],[D],[O]],j=A;A=n.runWebGLProgram(P,S,"int32",_),Eo(n,j)};for(let D=1;D<g;D*=2){let O=D*2;for(let F=D;F>=1;F/=2)b(O,F,[f,y])}for(let D=y;D>g;D/=2){let O=x(),F=new rse([f,D/2]),S=[[u],[A===null?1:0],[g]],P=A;A=n.runWebGLProgram(F,O,"int32",S),Eo(n,P);let _=g/2,j=_*2;for(let q=_;q>=1;q/=2)b(j,q,A.shape)}let v=A;A=Lu({inputs:{x:A},backend:n,attrs:{begin:0,size:[f,s]}}),Eo(n,v);let k=$k({inputs:{x:m,indices:A},backend:n,attrs:{axis:1,batchDims:1}});Eo(n,m);let T=d.slice(0,-1);T.push(s),v=A,A=we({inputs:{x:A},attrs:{shape:T},backend:n}),Eo(n,v);let C=k;return k=we({inputs:{x:k},attrs:{shape:T},backend:n}),Eo(n,C),[k,A]}var ise={kernelName:Gl,backendName:"webgl",kernelFunc:sse},ose=class{constructor(e,t,n,a,r,s){this.variableNames=["Image","Transforms"],this.outputShape=s;let i=n==="nearest"?1:2,o;switch(a){case"constant":o=1;break;case"reflect":o=2;break;case"wrap":o=3;break;case"nearest":o=4;break;default:o=1;break}this.userCode=`
|
|
float mapCoord(float outCoord, float len) {
|
|
float inCoord = outCoord;
|
|
if(${o} == 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 (${o} == 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 (${o} == 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 (${i} == 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 lse(e){let{inputs:t,backend:n,attrs:a}=e,{image:r,transforms:s}=t,{interpolation:i,fillMode:o,fillValue:l,outputShape:d}=a,[u,p,c,h]=r.shape,[f,m]=d!=null?d:[p,c],g=[u,f,m,h],y=new ose(p,c,i,o,l,g);return n.runWebGLProgram(y,[r,s],"float32")}var use={kernelName:Hl,backendName:"webgl",kernelFunc:lse};function dse(e){let{inputs:t,attrs:n,backend:a}=e,{axis:r}=n,{x:s}=t;Mu(s,"unique"),console.warn("WARNING: ","UI might be locked temporarily as data is being downloaded");let i=a.readSync(s.dataId),{outputValues:o,outputShape:l,indices:d}=RZ(i,r,s.shape,s.dtype);return[a.makeTensorInfo(l,s.dtype,o),a.makeTensorInfo([d.length],"int32",d)]}var pse={kernelName:wh,backendName:"webgl",kernelFunc:dse};function cse(e){let{inputs:t,backend:n,attrs:a}=e,{value:r}=t,{axis:s}=a;s<0&&(s+=r.shape.length);let i=r,o=i.shape.length,l=r.shape[s],d=new Array(o-1),u=0;for(let m=0;m<o;m++)m!==s&&(d[u++]=i.shape[m]);let p=[],c=new Array(o).fill(0),h=i.shape.slice();h[s]=1;let f=new Array(l);for(let m=0;m<f.length;m++){c[s]=m;let g=Lu({inputs:{x:i},backend:n,attrs:{begin:c,size:h}}),y=we({inputs:{x:g},backend:n,attrs:{shape:d}});f[m]=y,p.push(g)}return p.forEach(m=>n.disposeIntermediateTensorInfo(m)),f}var hse={kernelName:ql,backendName:"webgl",kernelFunc:cse},fse=class{constructor(e,t){this.variableNames=["x","segmentIds"];let n=e.windowSize,a=e.batchSize,r=e.inSize,s=e.numSegments,i=s*Math.ceil(r/n);this.outputShape=[a,i];let o="0.0",l="sumValue",d=Math.floor(n/4)*4,u=n%4,p=`
|
|
sumValue += dot(values, segFilter);
|
|
`,c="";r%n>0&&(c=`
|
|
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 = ${o};
|
|
|
|
float getValue(int batch, int inIdx) {
|
|
${c}
|
|
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(
|
|
${s})) * float(${n}));
|
|
int currentSeg = int(mod(float(outIdx), float(${s})));
|
|
|
|
float sumValue = 0.0;
|
|
|
|
for (int i = 0; i < ${d}; 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
|
|
);
|
|
|
|
${p}
|
|
}
|
|
|
|
int inIdx = inOffset + ${d};
|
|
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
|
|
);
|
|
|
|
${p}
|
|
} 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
|
|
);
|
|
|
|
${p}
|
|
} 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
|
|
);
|
|
|
|
${p}
|
|
}
|
|
setOutput(${l});
|
|
}
|
|
`}};function mse(e){let{inputs:t,backend:n,attrs:a}=e,{x:r,segmentIds:s}=t,{numSegments:i}=a,o=r.shape.length,l=[],d=0,u=E.getAxesPermutation([d],o),p=r;u!=null&&(p=_n({inputs:{x:r},backend:n,attrs:{perm:u}}),l.push(p),d=E.getInnerMostAxes(1,o)[0]);let c=E.segment_util.computeOutShape(p.shape,d,i),h=w.sizeFromShape([p.shape[d]]),f=we({inputs:{x:p},backend:n,attrs:{shape:[-1,h]}});l.push(f);let m=Eh(r.dtype),g=(b,v,k,T,C)=>{let D=b.shape[0],O=b.shape[1],F=E.segment_util.segOpComputeOptimalWindowSize(O,C),S={windowSize:F,inSize:O,batchSize:D,numSegments:C},P=new fse(S,v),_=n.compileAndRun(P,[b,k],T);if(l.push(_),_.shape[1]===C)return _;let j=Uk({backend:n,attrs:{start:0,stop:C,step:1,dtype:"float32"}}),q=Xk({inputs:{x:j},backend:n,attrs:{reps:[O/F]}});return l.push(j),l.push(q),g(_,v,q,T,C)},y=g(f,"unsortedSegmentSum",s,m,i),A=we({inputs:{x:y},backend:n,attrs:{shape:c}}),x=A;if(u!=null){l.push(A);let b=E.getUndoAxesPermutation(u);x=_n({inputs:{x},backend:n,attrs:{perm:b}})}return l.forEach(b=>n.disposeIntermediateTensorInfo(b)),x}var gse={kernelName:Rd,backendName:"webgl",kernelFunc:mse},yse=[Gte,Xte,EY,MY,$Y,PY,LY,VY,jY,HY,ZY,JY,tJ,rJ,pJ,oJ,fJ,AJ,gJ,wJ,IJ,NJ,RJ,PJ,LJ,BJ,qJ,KJ,QJ,nQ,dY,oQ,yQ,xQ,pQ,kQ,SQ,vQ,CQ,MQ,$Q,_Q,zQ,BQ,qQ,KQ,UQ,JQ,tee,aee,oee,pee,mee,Aee,xee,bee,wee,Iee,Nee,Cee,Ree,$ee,Pee,Wee,Vee,Gee,Xee,Jee,nte,uY,rte,sQ,ote,dte,hte,cY,yte,vte,kte,Rte,Tte,$te,Pte,Bte,Zte,rne,nne,lne,dne,cne,ene,fne,gne,bne,Ine,Cne,_ne,yY,zne,Bne,jne,qne,UJ,Zne,Jne,eae,aae,oae,fY,uae,dae,jJ,Fne,hae,vae,yae,xY,Sae,Cae,Fae,Oae,Lae,Bae,jae,qae,Kae,Jae,tre,are,ire,ure,cre,OJ,$ne,mre,yre,xre,vre,kre,Sre,Tre,Ere,Mre,$re,_re,zre,Bre,Ure,Gre,qre,Dne,NY,Zre,Qre,nse,ise,use,TY,pse,hse,gse,Yne];for(let e of yse)cs(e);var Kt;(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"})(Kt||(Kt={}));var Up;(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"})(Up||(Up={}));var Zk;function Ase(e){Zk=e.wasm.cwrap(Hi,null,["number","array","number","number","array","number","number","number","number","number","number","number","number"])}function xse(e){let{inputs:t,backend:n,attrs:a}=e,{a:r,b:s,bias:i,preluActivationWeights:o}=t;if(r.dtype!=="float32"||s.dtype!=="float32")throw new Error("_FusedMatMul for non non-float32 tensors not yet supported.");let{transposeA:l,transposeB:d,activation:u,leakyreluAlpha:p}=a,c=n.dataIdMap.get(r.dataId).id,h=n.dataIdMap.get(s.dataId).id,f=0;if(i!=null){let C=n.dataIdMap.get(i.dataId);if(C.shape.length!==1)throw new Error(`_FusedMatMul only supports rank-1 bias but got rank ${C.shape.length}.`);f=C.id}let m=o==null?0:n.dataIdMap.get(o.dataId).id,g=Up[u];if(g==null)throw new Error(`${u} activation not yet supported for FusedConv2D in the wasm backend.`);let y=l?r.shape[2]:r.shape[1],A=d?s.shape[1]:s.shape[2],x=r.shape[0],b=n.makeOutput([x,y,A],r.dtype),v=n.dataIdMap.get(b.dataId).id,k=new Uint8Array(new Int32Array(r.shape).buffer),T=new Uint8Array(new Int32Array(s.shape).buffer);return Zk(c,k,r.shape.length,h,T,s.shape.length,l,d,g,f,m,p||0,v),b}var bse={kernelName:Hi,backendName:"wasm",setupFunc:Ase,kernelFunc:xse};function wn(e,t){let n;function a(s){n=s.wasm.cwrap(e,null,["number","number","number"])}function r(s){let{backend:i,inputs:{x:o}}=s,l=i.dataIdMap.get(o.dataId).id,d=i.makeOutput(o.shape,t||o.dtype),u=i.dataIdMap.get(d.dataId).id;return w.sizeFromShape(d.shape)===0||n(l,Kt[o.dtype],u),d}return{kernelName:e,backendName:"wasm",setupFunc:a,kernelFunc:r}}var vse=wn(Ko);function Pn(e,t,n){let a;function r(i){a=i.wasm.cwrap(e,null,["number","array","number","number","array","number","number","number"])}function s(i){let{backend:o,inputs:l}=i,{a:d,b:u}=l,p=o.dataIdMap.get(d.dataId).id,c=o.dataIdMap.get(u.dataId).id,h=n!=null?n:d.dtype,f=E.assertAndGetBroadcastShape(d.shape,u.shape),m=o.makeOutput(f,h);if(w.sizeFromShape(f)===0)return m;let g=new Uint8Array(new Int32Array(d.shape).buffer),y=new Uint8Array(new Int32Array(u.shape).buffer),A=o.dataIdMap.get(m.dataId).id,x=()=>a(p,g,d.shape.length,c,y,u.shape.length,Kt[d.dtype],A);if(t&&d.dtype==="float32")return x(),m;let b=E.getBroadcastDims(d.shape,f),v=E.getBroadcastDims(u.shape,f),k=b.every((C,D)=>C===D),T=v.every((C,D)=>C===D);if(k&&T)return x(),m;throw new Error(`Broadcasting along outer dims is not yet supported for ${d.dtype} ${e}.`)}return{kernelName:e,backendName:"wasm",setupFunc:r,kernelFunc:s}}var wse=!0,kse=Pn(ls,wse),Yk;function Ise(e){Yk=e.wasm.cwrap(Zs,null,["array","number","number","number"])}function Sse(e){let{inputs:t,backend:n}=e,a=n.makeOutput(t[0].shape,t[0].dtype);if(w.sizeFromShape(a.shape)===0)return a;let r=t.map(o=>n.dataIdMap.get(o.dataId).id),s=new Uint8Array(new Int32Array(r).buffer),i=n.dataIdMap.get(a.dataId).id;return Yk(s,r.length,Kt[a.dtype],i),a}var Nse={kernelName:Zs,backendName:"wasm",setupFunc:Ise,kernelFunc:Sse};function Cf(e){let{inputs:{x:t},backend:n}=e,a=n.makeOutput(t.shape,t.dtype),r=n.typedArrayFromHeap(t);return n.typedArrayFromHeap(a).set(r),a}var Tse={kernelName:mi,backendName:"wasm",kernelFunc:Cf},Jk;function Cse(e){Jk=e.wasm.cwrap(Gi,null,["number","array","number","number","number","array","number"])}function Vu(e){let{inputs:t,backend:n,attrs:a}=e,[r,s]=Rse(t.x.shape,a.perm),i=!0;for(let f=0;f<s.length;f++)s[f]!==f&&(i=!1);let o=Ese(t.x.shape,a.perm),l={dataId:t.x.dataId,shape:r,dtype:t.x.dtype};if(i){let f=Cf({inputs:t,backend:n});return f.shape=o,f}let d=n.makeOutput(o,l.dtype),u=n.dataIdMap.get(l.dataId).id,p=n.dataIdMap.get(d.dataId).id,c=new Uint8Array(new Int32Array(s).buffer),h=new Uint8Array(new Int32Array(l.shape).buffer);return Jk(u,h,l.shape.length,Kt[l.dtype],p,c,s.length),d}function Ese(e,t){let n=new Array(e.length);for(let a=0;a<n.length;a++)n[a]=e[t[a]];return n}function Rse(e,t){let n=[],a=[];for(let r=0;r<e.length;++r)e[r]!==1&&n.push(e[r]),e[t[r]]!==1&&a.push(t[r]);for(let r=0;r<a.length;++r){let s=-1;for(let i=0;i<a.length;++i)a[i]>=r&&(s===-1||a[s]>a[i])&&(s=i);a[s]=r}return[n,a]}var Mse={kernelName:Gi,backendName:"wasm",kernelFunc:Vu,setupFunc:Cse};function $s(e,t,n){let a=e.shape,r=e.shape.length,s=w.parseAxisParam(t,a),i=s,o=E.getAxesPermutation(i,r),l=null,d=!1;if(o!=null){let u=new Array(r);for(let c=0;c<u.length;c++)u[c]=a[o[c]];i=E.getInnerMostAxes(i.length,r),l=Vu({inputs:{x:e},attrs:{perm:o},backend:n});let p=n.dataIdMap.get(e.dataId).id;n.dataIdMap.get(l.dataId).id!==p&&(d=!0)}return{transposed:l,originalAxes:s,axes:i,inputWasTransposed:d}}var Qk;function Fse(e){Qk=e.wasm.cwrap(Jo,null,["number, number, number"])}function Dse(e){let{backend:t,inputs:n,attrs:a}=e,{axis:r,keepDims:s}=a,{x:i}=n,o=t.dataIdMap.get(i.dataId).id,l=i,{transposed:d,axes:u,originalAxes:p,inputWasTransposed:c}=$s(i,r,t);if(c){let A=t.dataIdMap.get(d.dataId).id;l=d,o=A}let h=l.shape.length;E.assertAxesAreInnerMostDims("all",u,h);let[f,m]=E.computeOutAndReduceShapes(l.shape,u),g=w.sizeFromShape(m),y=t.makeOutput(f,i.dtype);if(w.sizeFromShape(l.shape)!==0){let A=t.dataIdMap.get(y.dataId).id;Qk(o,g,A)}if(c&&t.disposeData(d.dataId),s){let A=E.expandShapeToKeepDim(y.shape,p);y.shape=A}return y}var $se={kernelName:Jo,backendName:"wasm",setupFunc:Fse,kernelFunc:Dse},e8;function Ose(e){e8=e.wasm.cwrap(Qo,null,["number, number, number"])}function _se(e){let{backend:t,inputs:n,attrs:a}=e,{axis:r,keepDims:s}=a,{x:i}=n,o=t.dataIdMap.get(i.dataId).id,l=i,{transposed:d,axes:u,originalAxes:p,inputWasTransposed:c}=$s(i,r,t);if(c){let A=t.dataIdMap.get(d.dataId).id;l=d,o=A}let h=l.shape.length;E.assertAxesAreInnerMostDims("any",u,h);let[f,m]=E.computeOutAndReduceShapes(l.shape,u),g=w.sizeFromShape(m),y=t.makeOutput(f,i.dtype);if(w.sizeFromShape(l.shape)!==0){let A=t.dataIdMap.get(y.dataId).id;e8(o,g,A)}if(c&&t.disposeData(d.dataId),s){let A=E.expandShapeToKeepDim(y.shape,p);y.shape=A}return y}var Pse={kernelName:Qo,backendName:"wasm",setupFunc:Ose,kernelFunc:_se},t8;function zse(e){t8=e.wasm.cwrap(Ys,null,["number","number","number","number","number"])}function Lse(e){let{backend:t,inputs:n,attrs:a}=e,{axis:r}=a,{x:s}=n,i=t.dataIdMap.get(s.dataId).id,o=i,l=s,{transposed:d,axes:u,inputWasTransposed:p}=$s(s,r,t);if(p){let y=t.dataIdMap.get(d.dataId).id;y!==i&&(l=d,o=y)}let c=l.shape.slice(0,-1),h=t.makeOutput(c,"int32"),f=t.dataIdMap.get(h.dataId).id,m=w.sizeFromShape(h.shape),g=l.shape[u[0]];return t8(o,Kt[l.dtype],m,g,f),p&&t.disposeData(d.dataId),h}var Wse={kernelName:Ys,backendName:"wasm",kernelFunc:Lse,setupFunc:zse},n8;function Bse(e){n8=e.wasm.cwrap(Js,null,["number","number","number","number","number","number","number","number","number","number","number","number","number","number"])}function Vse(e){let{inputs:t,attrs:n,backend:a}=e,r=t.x,s=a.dataIdMap.get(r.dataId).id,{filterSize:i,strides:o,pad:l,dimRoundingMode:d}=n,u=E.computePool2DInfo(r.shape,i,o,1,l,d),p=u.filterHeight,c=u.filterWidth,h=u.padInfo.top,f=u.padInfo.right,m=u.padInfo.bottom,g=u.padInfo.left,y=u.strideHeight,A=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=a.makeOutput(u.outShape,"float32"),v=a.dataIdMap.get(b.dataId).id;return n8(s,r.shape[0],r.shape[1],r.shape[2],p,c,h,f,m,g,y,A,x,v),b}var Use={kernelName:Js,backendName:"wasm",setupFunc:Bse,kernelFunc:Vse};function ta(e){let{inputs:t,attrs:n}=e,{x:a}=t,{shape:r}=n,s=w.sizeFromShape(a.shape),i=w.inferFromImplicitShape(r,s);return w.assert(s===w.sizeFromShape(i),()=>`new shape: ${i}, old shape: ${a.shape}. New shape and old shape must have the same number of elements.`),e.backend.incRef(a.dataId),{dataId:a.dataId,shape:i,dtype:a.dtype}}var jse={kernelName:$l,backendName:"wasm",kernelFunc:ta},a8;function Gse(e){a8=e.wasm.cwrap(Qs,null,["number","array","number","number","array","number","number","number","number"])}function Hse(e){let{inputs:t,backend:n,attrs:a}=e,{a:r,b:s}=t,{transposeA:i,transposeB:o}=a;if(r.dtype!=="float32"||s.dtype!=="float32")throw new Error("BatchMatMul for non non-float32 tensors not yet supported.");let l=r.shape.length,d=s.shape.length,u=i?r.shape[l-2]:r.shape[l-1],p=o?s.shape[d-1]:s.shape[d-2],c=i?r.shape[l-1]:r.shape[l-2],h=o?s.shape[d-2]:s.shape[d-1],f=r.shape.slice(0,-2),m=s.shape.slice(0,-2),g=w.sizeFromShape(f),y=w.sizeFromShape(m),A=g===y||g===1||y===1;w.assert(l>=2&&d>=2&&A,()=>`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 x=(g>y?r.shape.slice(0,-2):s.shape.slice(0,-2)).concat([c,h]);w.assert(u===p,()=>`Error in matMul: inner shapes (${u}) and (${p}) of Tensors with shapes ${r.shape} and ${s.shape} and transposeA=${i} and transposeB=${o} must match.`);let b=i?[g,u,c]:[g,c,u],v=o?[y,h,p]:[y,p,h],k=ta({inputs:{x:r},backend:n,attrs:{shape:b}}),T=ta({inputs:{x:s},backend:n,attrs:{shape:v}}),C=n.dataIdMap.get(k.dataId).id,D=n.dataIdMap.get(T.dataId).id,O=i?k.shape[2]:k.shape[1],F=o?T.shape[1]:T.shape[2],S=Math.max(g,y),P=n.makeOutput([S,O,F],k.dtype),_=n.dataIdMap.get(P.dataId).id,j=new Uint8Array(new Int32Array(k.shape).buffer),q=new Uint8Array(new Int32Array(T.shape).buffer);return a8(C,j,k.shape.length,D,q,T.shape.length,i,o,_),n.disposeData(k.dataId),n.disposeData(T.dataId),P.shape=x,P}var qse={kernelName:Qs,backendName:"wasm",setupFunc:Gse,kernelFunc:Hse};function jp(e){let{inputs:{x:t},attrs:{begin:n,size:a},backend:r}=e,[s,i]=En.parseSliceParams(t,n,a),o=En.isSliceContinous(t.shape,s,i),l=r.readSync(t.dataId),d=r.makeOutput(i,t.dtype),u=w.computeStrides(t.shape),p=r.dataIdMap.get(d.dataId);if(o){let f=En.computeFlatOffset(s,u);return t.dtype==="string"?p.stringBytes=l.slice(f,f+w.sizeFromShape(i)):r.typedArrayFromHeap(d).set(l.subarray(f,f+w.sizeFromShape(i))),d}if(t.dtype==="string"){let f=rf(l,s,i,t.shape,t.dtype);return p.stringBytes=f,d}let c=r.typedArrayFromHeap(d),h=t.shape.length;if(h===2)Xse(l,u[0],c,s,i);else if(h===3)Kse(l,u[0],u[1],c,s,i);else if(h===4)Zse(l,u[0],u[1],u[2],c,s,i);else{let f=rf(l,s,i,t.shape,t.dtype);c.set(f)}return d}function Xse(e,t,n,a,r){let s=0,i=a[0],o=a[1],l=i+r[0];for(let d=i;d<l;d++){let u=d*t+o;n.set(e.subarray(u,u+r[1]),s),s+=r[1]}}function Kse(e,t,n,a,r,s){let i=0,o=r[0],l=r[1],d=r[2],u=o+s[0],p=l+s[1];for(let c=o;c<u;c++)for(let h=l;h<p;h++){let f=c*t+h*n+d;a.set(e.subarray(f,f+s[2]),i),i+=s[2]}}function Zse(e,t,n,a,r,s,i){let o=0,l=s[0],d=s[1],u=s[2],p=l+i[0],c=d+i[1],h=u+i[2],f=s[3];for(let m=l;m<p;m++)for(let g=d;g<c;g++)for(let y=u;y<h;y++){let A=m*t+g*n+y*a+f;r.set(e.subarray(A,A+i[3]),o),o+=i[3]}}var Yse={kernelName:zl,backendName:"wasm",kernelFunc:jp};function Jse(e){let{inputs:t,backend:n,attrs:a}=e,{x:r}=t,{blockShape:s,crops:i}=a,o=s.reduce((y,A)=>y*A),l=E.getReshaped(r.shape,s,o),d=E.getPermuted(l.length,s.length),u=E.getReshapedPermuted(r.shape,s,o),p=E.getSliceBeginCoords(i,s.length),c=E.getSliceSize(u,i,s.length),h=ta({inputs:{x:r},backend:n,attrs:{shape:l}}),f=Vu({inputs:{x:h},backend:n,attrs:{perm:d}}),m=ta({inputs:{x:f},backend:n,attrs:{shape:u}}),g=jp({inputs:{x:m},backend:n,attrs:{begin:p,size:c}});return n.disposeData(h.dataId),n.disposeData(f.dataId),n.disposeData(h.dataId),g}var Qse={kernelName:sl,backendName:"wasm",kernelFunc:Jse};function Gp(e){let{inputs:{x:t},attrs:{dtype:n},backend:a}=e,r=a.makeOutput(t.shape,n),s=a.typedArrayFromHeap(t);return a.typedArrayFromHeap(r).set(s),r}var eie={kernelName:ei,backendName:"wasm",kernelFunc:Gp},tie=wn(ti),r8;function nie(e){r8=e.wasm.cwrap(us,null,["number","number","number","number"])}function aie(e){let{inputs:t,backend:n,attrs:a}=e,{x:r}=t,{clipValueMin:s,clipValueMax:i}=a,o=n.dataIdMap.get(r.dataId).id,l=n.makeOutput(r.shape,r.dtype),d=n.dataIdMap.get(l.dataId).id;return r8(o,s,i,d),l}var rie={kernelName:us,backendName:"wasm",setupFunc:nie,kernelFunc:aie};function s8(e){let{inputs:t,backend:n}=e,a=w.parseAxisParam(e.attrs.axis,t[0].shape)[0],r=E.computeOutShape(t.map(h=>h.shape),a),s=t.filter(h=>w.sizeFromShape(h.shape)>0);if(s.length===1)return Cf({inputs:{x:s[0]},backend:n});let i=n.makeOutput(r,t[0].dtype);if(w.sizeFromShape(r)===0)return i;let o=s.map(h=>h.shape);if(E.assertParamsConsistent(o,a),s[0].dtype==="string"){let h=s.map(x=>{let b=w.sizeFromShape(x.shape.slice(a));return ta({inputs:{x},backend:n,attrs:{shape:[-1,b]}})}),f=h.map(x=>({vals:n.readSync(x.dataId),shape:x.shape}));r=E.computeOutShape(h.map(x=>x.shape),1);let m=h[0].shape[0]===1,g=y2(f,r,t[0].dtype,m),y=E.computeOutShape(s.map(x=>x.shape),a);i.shape=y;let A=n.dataIdMap.get(i.dataId);return A.stringBytes=E.fromStringArrayToUint8(g),h.forEach(x=>n.disposeData(x.dataId)),i}let l=w.sizeFromShape(s[0].shape.slice(0,a)),d=0,u=s.map(h=>{let f=w.sizeFromShape(h.shape.slice(a));return d+=f,f}),p=s.map(h=>n.typedArrayFromHeap(h)),c=n.typedArrayFromHeap(i);for(let h=0;h<l;h++){let f=h*d;for(let m=0;m<p.length;m++){let g=u[m],y=h*g,A=p[m].subarray(y,y+g);c.set(A,f),f+=g}}return i}var sie={kernelName:il,backendName:"wasm",kernelFunc:s8},i8;function iie(e){i8=e.wasm.cwrap(ni,null,["number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number"])}function oie(e){let{inputs:t,attrs:n,backend:a}=e,{x:r,filter:s}=t,i=a.dataIdMap.get(r.dataId).id,o=a.dataIdMap.get(s.dataId).id,{strides:l,dilations:d,pad:u,dimRoundingMode:p,dataFormat:c}=n,h=E.convertConv2DDataFormat(c),f=E.computeConv2DInfo(r.shape,s.shape,l,d,u,p,!1,h),m=f.filterHeight,g=f.filterWidth,y=f.padInfo.top,A=f.padInfo.right,x=f.padInfo.bottom,b=f.padInfo.left,v=f.dilationHeight,k=f.dilationWidth,T=f.strideHeight,C=f.strideWidth,D=f.inChannels,O=f.outChannels,F=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 S=a.makeOutput(f.outShape,"float32"),P=a.dataIdMap.get(S.dataId).id;return i8(i,r.shape[0],r.shape[1],r.shape[2],o,m,g,y,A,x,b,F,v,k,T,C,D,O,P),S}var lie={kernelName:ni,backendName:"wasm",setupFunc:iie,kernelFunc:oie},o8;function uie(e){o8=e.wasm.cwrap(ai,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 die(e){let{backend:t,inputs:n,attrs:a}=e,{dy:r,filter:s}=n,{strides:i,pad:o,dataFormat:l,dimRoundingMode:d,inputShape:u}=a,p=1,c=E.convertConv2DDataFormat(l),h=E.computeConv2DInfo(u,s.shape,i,p,o,d,!1,c),{batchSize:f,filterHeight:m,filterWidth:g,inChannels:y,inHeight:A,inWidth:x,outChannels:b,outHeight:v,outWidth:k,strideHeight:T,strideWidth:C}=h,D=m-1-h.padInfo.top,O=g-1-h.padInfo.left,F=h.dataFormat==="channelsLast",S=w.computeStrides(h.inShape),P=w.computeStrides(r.shape),[_,j,q]=w.computeStrides(s.shape),z=S[0],X=F?S[1]:S[2],Z=F?S[2]:1,te=F?1:S[1],J=P[0],re=F?P[1]:P[2],Y=F?P[2]:1,se=F?1:P[1],de=t.makeOutput(h.inShape,"float32"),be=t.dataIdMap.get(de.dataId).id,ve=t.dataIdMap.get(r.dataId).id,ke=t.dataIdMap.get(s.dataId).id;return o8(ve,ke,f,m,g,A,x,y,v,k,b,T,C,D,O,_,j,q,z,X,Z,te,J,re,Y,se,be),de}var pie={kernelName:ai,backendName:"wasm",setupFunc:uie,kernelFunc:die},cie=wn(ri),hie=wn(si),Z2;(function(e){e[e.bilinear=0]="bilinear",e[e.nearest=1]="nearest"})(Z2||(Z2={}));var l8;function fie(e){l8=e.wasm.cwrap(ol,null,["number","number","number","number","array","number","number","number","number","number"])}function mie(e){let{backend:t,inputs:n,attrs:a}=e,{method:r,extrapolationValue:s,cropSize:i}=a,{image:o,boxes:l,boxInd:d}=n,u=l.shape[0],[p,c]=i,h=[u,p,c,o.shape[3]],f=t.dataIdMap.get(o.dataId),m;o.dtype!=="float32"&&(m=Gp({backend:t,inputs:{x:o},attrs:{dtype:"float32"}}),f=t.dataIdMap.get(m.dataId));let g=f.id,y=t.dataIdMap.get(l.dataId).id,A=t.dataIdMap.get(d.dataId).id,x=t.makeOutput(h,"float32"),b=t.dataIdMap.get(x.dataId).id,v=new Uint8Array(new Int32Array(o.shape).buffer);return l8(g,y,A,u,v,p,c,Z2[r],s,b),m!=null&&t.disposeData(m.dataId),x}var gie={kernelName:ol,backendName:"wasm",setupFunc:fie,kernelFunc:mie},u8;function yie(e){u8=e.wasm.cwrap(ii,null,["number","number","number","number","number","number"])}function Aie(e){let{inputs:t,backend:n,attrs:a}=e,{x:r}=t,{axis:s,exclusive:i,reverse:o}=a,l=r.shape.length;w.assert(r.dtype==="float32"||r.dtype==="int32",()=>`cumsum does not support ${r.dtype} tensors in the WASM backend`);let d=E.getAxesPermutation([s],l),u=r;d!==null&&(u=Vu({inputs:{x:r},attrs:{perm:d},backend:n}));let p=E.getInnerMostAxes(1,l)[0];E.assertAxesAreInnerMostDims("cumsum",[p],l);let c=n.makeOutput(u.shape,u.dtype),h=u.shape[p],f=n.dataIdMap.get(u.dataId).id,m=n.dataIdMap.get(c.dataId).id;u8(f,i?1:0,o?1:0,h,m,Kt[r.dtype]);let g=c;if(d!==null){let y=E.getUndoAxesPermutation(d);g=Vu({inputs:{x:c},attrs:{perm:y},backend:n}),n.disposeData(u.dataId),n.disposeData(c.dataId)}return g}var xie={kernelName:ii,backendName:"wasm",setupFunc:yie,kernelFunc:Aie},d8;function bie(e){d8=e.wasm.cwrap(ll,null,["number","number","number","array","number","array","array","number","number"])}function vie(e){let{backend:t,inputs:n,attrs:a}=e,{x:r}=n,{blockSize:s,dataFormat:i}=a,o=r.shape[0],l=i==="NHWC"?r.shape[1]:r.shape[2],d=i==="NHWC"?r.shape[2]:r.shape[3],u=i==="NHWC"?r.shape[3]:r.shape[1],p=l*s,c=d*s,h=u/(s*s),f=i==="NHWC"?[o,p,c,h]:[o,h,p,c],m=t.makeOutput(f,"float32"),g=t.dataIdMap.get(r.dataId).id,y=new Uint8Array(new Int32Array(w.computeStrides(r.shape)).buffer),A=new Uint8Array(new Int32Array(f).buffer),x=new Uint8Array(new Int32Array(w.computeStrides(f)).buffer),b=t.dataIdMap.get(m.dataId).id;return d8(g,s,i==="NHWC"?1:0,y,r.shape.length-1,A,x,f.length,b),m}var wie={kernelName:ll,backendName:"wasm",setupFunc:bie,kernelFunc:vie},p8;function kie(e){p8=e.wasm.cwrap(oi,null,["number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number"])}function Iie(e){let{inputs:t,attrs:n,backend:a}=e,{x:r,filter:s}=t,i=a.dataIdMap.get(r.dataId).id,o=a.dataIdMap.get(s.dataId).id,{strides:l,dilations:d,pad:u,dimRoundingMode:p}=n,c=d==null?[1,1]:d,h=E.computeConv2DInfo(r.shape,s.shape,l,c,u,p,!0),f=h.filterHeight,m=h.filterWidth,g=h.padInfo.top,y=h.padInfo.right,A=h.padInfo.bottom,x=h.padInfo.left,b=h.dilationHeight,v=h.dilationWidth,k=h.strideHeight,T=h.strideWidth,C=h.inChannels,D=h.outChannels,O=h.padInfo.type==="SAME"?1:0;if(h.dataFormat!=="channelsLast")throw new Error(`wasm backend DepthwiseConv2dNative does not support dataFormat:'${h.dataFormat}'. Please use 'channelsLast'.`);let F=a.makeOutput(h.outShape,"float32"),S=a.dataIdMap.get(F.dataId).id;return p8(i,r.shape[0],r.shape[1],r.shape[2],o,f,m,g,y,A,x,O,b,v,k,T,C,D,S),F}var Sie={kernelName:oi,backendName:"wasm",setupFunc:kie,kernelFunc:Iie},Nie=wn(ui),Tie=!1,Cie=Pn(dl,Tie,"bool"),Eie=wn(di,"float32");function Y2(e){let{inputs:t,attrs:n,backend:a}=e,{input:r}=t,{dim:s}=n,i=r.shape.length,o=r.shape.slice(),l=s;return s<0&&(w.assert(-(i+1)<=s,()=>`Axis must be in the interval [${-(i+1)}, ${i}]`),l=i+s+1),o.splice(l,0,1),ta({inputs:{x:r},backend:a,attrs:{shape:o}})}var Rie={kernelName:pl,backendName:"wasm",kernelFunc:Y2};function c8(e){let{attrs:{shape:t,value:n,dtype:a},backend:r}=e,s=r.makeOutput(t,a);return r.typedArrayFromHeap(s).fill(n),s}var Mie={kernelName:wd,backendName:"wasm",kernelFunc:c8},h8;function Fie(e){h8=e.wasm.cwrap(hl,null,["number","number","number","number","number","number"])}function Die(e){let{inputs:t,backend:n}=e,{image:a}=t,r=n.makeOutput(a.shape,a.dtype),s=n.dataIdMap.get(a.dataId).id,i=n.dataIdMap.get(r.dataId).id,[o,l,d,u]=a.shape;return h8(s,o,l,d,u,i),r}var $ie={kernelName:hl,backendName:"wasm",kernelFunc:Die,setupFunc:Fie},Oie=wn(pi),_ie=!1,Pie=Pn(ci,_ie),f8;function zie(e){f8=e.wasm.cwrap(hi,null,["number","number","number","number","number","number","number"])}function Lie(e){let{backend:t,inputs:n,attrs:a}=e,{varianceEpsilon:r}=a,{x:s,mean:i,variance:o,offset:l,scale:d}=n,u=t.dataIdMap.get(s.dataId).id,p=t.dataIdMap.get(i.dataId).id,c=t.dataIdMap.get(o.dataId).id,h=l!=null?t.dataIdMap.get(l.dataId).id:0,f=d!=null?t.dataIdMap.get(d.dataId).id:0,m=t.makeOutput(s.shape,s.dtype);if(w.sizeFromShape(s.shape)===0)return m;let g=t.dataIdMap.get(m.dataId).id;return f8(u,p,c,h,f,r,g),m}var Wie={kernelName:hi,backendName:"wasm",setupFunc:zie,kernelFunc:Lie},m8;function Bie(e){m8=e.wasm.cwrap(qi,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 Vie(e){let{inputs:t,attrs:n,backend:a}=e,{x:r,filter:s,bias:i,preluActivationWeights:o}=t,{strides:l,pad:d,dilations:u,dataFormat:p,dimRoundingMode:c,activation:h,leakyreluAlpha:f}=n,m=E.computeConv2DInfo(r.shape,s.shape,l,u,d,c),g=Up[h];if(g==null)throw new Error(`${h} activation not yet supported for FusedConv2D in the wasm backend.`);let y=a.dataIdMap.get(r.dataId).id,A=a.dataIdMap.get(s.dataId).id,x=m.outChannels,b=0;if(i!=null){let Y=a.dataIdMap.get(i.dataId);if(Y.shape.length!==1)throw new Error(`FusedConv2D only supports rank-1 bias but got rank ${Y.shape.length}.`);if(Y.shape[0]!==x)throw new Error(`FusedConv2D bias shape (${Y.shape}) does not match the number of output channels (${x})`);b=Y.id}let v=m.filterHeight,k=m.filterWidth,T=m.padInfo.top,C=m.padInfo.right,D=m.padInfo.bottom,O=m.padInfo.left,F=m.dilationHeight,S=m.dilationWidth,P=m.strideHeight,_=m.strideWidth,j=m.inChannels,q=m.padInfo.type==="SAME"?1:0,z=m.batchSize,X=m.inHeight,Z=m.inWidth;if(p!=="NHWC")throw new Error(`wasm backend FusedConv2D does not support dataFormat:'${p}'. Please use 'NHWC'.`);let te=a.makeOutput(m.outShape,"float32"),J=a.dataIdMap.get(te.dataId).id,re=o==null?0:a.dataIdMap.get(o.dataId).id;return m8(y,z,X,Z,A,v,k,b,T,C,D,O,q,F,S,P,_,j,x,g,re,f||0,J),te}var Uie={kernelName:qi,backendName:"wasm",setupFunc:Bie,kernelFunc:Vie},g8;function jie(e){g8=e.wasm.cwrap(Xi,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 Gie(e){let{inputs:t,attrs:n,backend:a}=e,{x:r,filter:s,bias:i,preluActivationWeights:o}=t,{strides:l,pad:d,dilations:u,dataFormat:p,dimRoundingMode:c,activation:h,leakyreluAlpha:f}=n,m=E.computeConv2DInfo(r.shape,s.shape,l,u,d,c,!0),g=Up[h];if(g==null)throw new Error(`${h} activation not yet supported for FusedDepthwiseConv2D in the wasm backend.`);let y=a.dataIdMap.get(r.dataId).id,A=a.dataIdMap.get(s.dataId).id,x=m.outChannels,b=0;if(i!=null){let Y=a.dataIdMap.get(i.dataId);if(Y.shape.length!==1)throw new Error(`FusedDepthwiseConv2D only supports rank-1 bias but got rank ${Y.shape.length}.`);if(Y.shape[0]!==x)throw new Error(`FusedDepthwiseConv2D bias shape (${Y.shape}) does not match the number of output channels (${x})`);b=Y.id}let v=m.filterHeight,k=m.filterWidth,T=m.padInfo.top,C=m.padInfo.right,D=m.padInfo.bottom,O=m.padInfo.left,F=m.dilationHeight,S=m.dilationWidth,P=m.strideHeight,_=m.strideWidth,j=m.inChannels,q=m.padInfo.type==="SAME"?1:0,z=m.batchSize,X=m.inHeight,Z=m.inWidth;if(p!=="NHWC")throw new Error(`wasm backend FusedDepthwiseConv2D does not support dataFormat:'${p}'. Please use 'NHWC'.`);let te=a.makeOutput(m.outShape,"float32"),J=a.dataIdMap.get(te.dataId).id,re=o==null?0:a.dataIdMap.get(o.dataId).id;return g8(y,z,X,Z,A,v,k,b,T,C,D,O,q,F,S,P,_,j,x,g,re,f||0,J),te}var Hie={kernelName:Xi,backendName:"wasm",setupFunc:jie,kernelFunc:Gie},y8;function qie(e){y8=e.wasm.cwrap(ml,null,["number","number","number","number","number","number","array","number"])}function Xie(e){let{backend:t,inputs:n}=e,{params:a,indices:r}=n,[s,i,o,l]=lg.prepareAndValidate(a,r),d=t.makeOutput(s,a.dtype);if(i===0)return d;let u=r.shape,p=u[u.length-1],c=t.dataIdMap.get(a.dataId).id,h=t.dataIdMap.get(r.dataId).id,f=new Uint8Array(new Int32Array(l).buffer),m=t.dataIdMap.get(d.dataId).id;return y8(c,Kt[a.dtype],h,i,p,o,f,m),d}var Kie={kernelName:ml,backendName:"wasm",setupFunc:qie,kernelFunc:Xie},A8;function Zie(e){A8=e.wasm.cwrap("Gather",null,["number","number","array","number","number","number","array","number"])}function Yie(e){let{backend:t,inputs:n,attrs:a}=e,{x:r,indices:s}=n,{axis:i,batchDims:o}=a,l=w.parseAxisParam(i,r.shape)[0],d=t.readSync(s.dataId),u=r.shape[l];for(let T=0;T<d.length;++T){let C=d[T];w.assert(C<=u-1&&C>=0,()=>`GatherV2: the index value ${C} is not in [0, ${u-1}]`)}let p=E.segment_util.collectGatherOpShapeInfo(r,s,l,o),c=ta({inputs:{x:r},attrs:{shape:[p.batchSize,p.outerSize,p.dimSize,p.sliceSize]},backend:t}),h=w.sizeFromShape(s.shape),f=ta({inputs:{x:s},attrs:{shape:[p.batchSize,h/p.batchSize]},backend:t}),m=[p.batchSize,p.outerSize,h/p.batchSize,p.sliceSize],g=t.makeOutput(m,r.dtype);if(w.sizeFromShape(r.shape)===0)return g;let y=c.shape.length-1,A=t.dataIdMap.get(c.dataId).id,x=t.dataIdMap.get(f.dataId).id,b=t.dataIdMap.get(g.dataId).id,v=new Uint8Array(new Int32Array(w.computeStrides(c.shape)).buffer),k=new Uint8Array(new Int32Array(w.computeStrides(m)).buffer);return A8(A,Kt[r.dtype],v,y,x,p.batchSize,k,b),t.disposeData(c.dataId),t.disposeData(f.dataId),g.shape=p.outputShape,g}var Jie={kernelName:fl,backendName:"wasm",setupFunc:Zie,kernelFunc:Yie},Qie=!1,eoe=Pn(gl,Qie,"bool"),toe=!1,noe=Pn(fi,toe,"bool"),x8;function aoe(e){x8=e.wasm.cwrap(gi,null,["number","number","number","number"])}function roe(e){let{inputs:{x:t},attrs:{alpha:n},backend:a}=e,r=a.dataIdMap.get(t.dataId).id,s=a.makeOutput(t.shape,"float32");if(w.sizeFromShape(t.shape)!==0){let i=a.dataIdMap.get(s.dataId).id;x8(r,Kt[t.dtype],n,i)}return s}var soe={kernelName:gi,backendName:"wasm",setupFunc:aoe,kernelFunc:roe},ioe=!1,ooe=Pn(bl,ioe,"bool"),loe=!1,uoe=Pn(vl,loe,"bool"),doe=wn(yi),poe=!1,coe=Pn(kl,poe,"bool"),b8;function hoe(e){b8=e.wasm.cwrap(Ai,null,["number","number","number","number"])}function foe(e){let{backend:t,inputs:n,attrs:a}=e,{reductionIndices:r,keepDims:s}=a,{x:i}=n,o=t.dataIdMap.get(i.dataId).id,l=i,{transposed:d,axes:u,originalAxes:p,inputWasTransposed:c}=$s(i,r,t);if(c){let A=t.dataIdMap.get(d.dataId).id;l=d,o=A}let h=l.shape.length;E.assertAxesAreInnerMostDims("max",u,h);let[f,m]=E.computeOutAndReduceShapes(l.shape,u),g=w.sizeFromShape(m),y=t.makeOutput(f,i.dtype);if(w.sizeFromShape(l.shape)!==0){let A=t.dataIdMap.get(y.dataId).id;b8(o,Kt[i.dtype],g,A)}if(c&&t.disposeData(d.dataId),s){let A=E.expandShapeToKeepDim(y.shape,p);y.shape=A}return y}var moe={kernelName:Ai,backendName:"wasm",setupFunc:hoe,kernelFunc:foe},goe=!1,yoe=Pn(xi,goe),v8;function Aoe(e){v8=e.wasm.cwrap(bi,null,["number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number"])}function xoe(e){let{inputs:t,attrs:n,backend:a}=e,r=t.x,s=a.dataIdMap.get(r.dataId).id;w.assert(r.dtype==="float32",()=>`Error in MaxPool: only float32 input is supported. Got ${r.dtype}.`);let{filterSize:i,strides:o,pad:l,dimRoundingMode:d}=n,u=E.computePool2DInfo(r.shape,i,o,1,l,d),p=u.filterHeight,c=u.filterWidth,h=u.padInfo.top,f=u.padInfo.right,m=u.padInfo.bottom,g=u.padInfo.left,y=u.dilationHeight,A=u.dilationWidth,x=u.strideHeight,b=u.strideWidth,v=u.inChannels,k=u.outChannels;if(u.dataFormat!=="channelsLast")throw new Error(`wasm backend does not support dataFormat:'${u.dataFormat}'. Please use 'channelsLast'.`);let T=a.makeOutput(u.outShape,"float32"),C=a.dataIdMap.get(T.dataId).id;return v8(s,r.shape[0],r.shape[1],r.shape[2],p,c,h,f,m,g,y,A,x,b,v,k,C),T}var boe={kernelName:bi,backendName:"wasm",setupFunc:Aoe,kernelFunc:xoe},w8;function voe(e){w8=e.wasm.cwrap(vi,null,["number, number, number"])}function woe(e){let{backend:t,inputs:n,attrs:a}=e,{axis:r,keepDims:s}=a,{x:i}=n,o=t.dataIdMap.get(i.dataId).id,l=o,d=i,{transposed:u,axes:p,originalAxes:c,inputWasTransposed:h}=$s(i,r,t),f=p;if(h){let b=t.dataIdMap.get(u.dataId).id;b!==o&&(d=u,l=b,f=E.getInnerMostAxes(f.length,d.shape.length))}E.assertAxesAreInnerMostDims("mean",f,d.shape.length);let[m,g]=E.computeOutAndReduceShapes(d.shape,f),y=w.sizeFromShape(g),A=d;d.dtype!=="float32"&&(A=Gp({backend:t,inputs:{x:d},attrs:{dtype:"float32"}}),l=t.dataIdMap.get(A.dataId).id);let x=t.makeOutput(m,"float32");if(w.sizeFromShape(d.shape)!==0){let b=t.dataIdMap.get(x.dataId).id;w8(l,y,b)}if(h&&t.disposeData(u.dataId),s){let b=E.expandShapeToKeepDim(x.shape,c);x.shape=b}return d.dtype!=="float32"&&t.disposeData(A.dataId),x}var koe={kernelName:vi,backendName:"wasm",setupFunc:voe,kernelFunc:woe},k8;function Ioe(e){k8=e.wasm.cwrap(wi,null,["number","number","number","number"])}function Soe(e){let{backend:t,inputs:n,attrs:a}=e,{axis:r,keepDims:s}=a,{x:i}=n,o=t.dataIdMap.get(i.dataId).id,l=o,d=i,{transposed:u,axes:p,originalAxes:c,inputWasTransposed:h}=$s(i,r,t);if(h){let x=t.dataIdMap.get(u.dataId).id;x!==o&&(d=u,l=x)}let f=d.shape.length;E.assertAxesAreInnerMostDims("min",p,f);let[m,g]=E.computeOutAndReduceShapes(d.shape,p),y=w.sizeFromShape(g),A=t.makeOutput(m,d.dtype);if(w.sizeFromShape(d.shape)!==0){let x=t.dataIdMap.get(A.dataId).id;k8(l,Kt[i.dtype],y,x)}if(h&&t.disposeData(u.dataId),s){let x=E.expandShapeToKeepDim(A.shape,c);A.shape=x}return A}var Noe={kernelName:wi,backendName:"wasm",setupFunc:Ioe,kernelFunc:Soe},Toe=!1,Coe=Pn(ki,Toe),J2;(function(e){e[e.reflect=0]="reflect",e[e.symmetric=1]="symmetric"})(J2||(J2={}));var I8;function Eoe(e){I8=e.wasm.cwrap(Ii,null,["number","array","number","number","array","array","number","number"])}function Roe(e){let{inputs:{x:t},backend:n,attrs:{paddings:a,mode:r}}=e,s=a.map((f,m)=>f[0]+t.shape[m]+f[1]),i=n.dataIdMap.get(t.dataId).id,o=n.makeOutput(s,t.dtype),l=n.dataIdMap.get(o.dataId).id,d=new Uint8Array(new Int32Array(t.shape).buffer),u=a.map(f=>f[0]),p=a.map(f=>f[1]),c=new Uint8Array(new Int32Array(u).buffer),h=new Uint8Array(new Int32Array(p).buffer);return I8(i,d,t.shape.length,Kt[t.dtype],c,h,J2[r],l),o}var Moe={kernelName:Ii,backendName:"wasm",kernelFunc:Roe,setupFunc:Eoe},Foe=!0,Doe=Pn(Si,Foe),$oe=wn(Sl);function Q2(e,t){let n=new Int32Array(e.wasm.HEAPU8.buffer,t,4),a=n[0],r=n[1],s=n[2],i=n[3];return e.wasm._free(t),{pSelectedIndices:a,selectedSize:r,pSelectedScores:s,pValidOutputs:i}}var S8;function Ooe(e){S8=e.wasm.cwrap(Tl,"number",["number","number","number","number","number"])}function _oe(e){let{backend:t,inputs:n,attrs:a}=e,{iouThreshold:r,maxOutputSize:s,scoreThreshold:i}=a,{boxes:o,scores:l}=n,d=t.dataIdMap.get(o.dataId).id,u=t.dataIdMap.get(l.dataId).id,p=S8(d,u,s,r,i),{pSelectedIndices:c,selectedSize:h,pSelectedScores:f,pValidOutputs:m}=Q2(t,p);return t.wasm._free(f),t.wasm._free(m),t.makeOutput([h],"int32",c)}var Poe={kernelName:Tl,backendName:"wasm",setupFunc:Ooe,kernelFunc:_oe},N8;function zoe(e){N8=e.wasm.cwrap(Cl,"number",["number","number","number","number","number","bool"])}function Loe(e){let{backend:t,inputs:n,attrs:a}=e,{iouThreshold:r,maxOutputSize:s,scoreThreshold:i,padToMaxOutputSize:o}=a,{boxes:l,scores:d}=n,u=t.dataIdMap.get(l.dataId).id,p=t.dataIdMap.get(d.dataId).id,c=N8(u,p,s,r,i,o),{pSelectedIndices:h,selectedSize:f,pSelectedScores:m,pValidOutputs:g}=Q2(t,c);t.wasm._free(m);let y=t.makeOutput([f],"int32",h),A=t.makeOutput([],"int32",g);return[y,A]}var Woe={kernelName:Cl,backendName:"wasm",setupFunc:zoe,kernelFunc:Loe},T8;function Boe(e){T8=e.wasm.cwrap(El,"number",["number","number","number","number","number","number"])}function Voe(e){let{backend:t,inputs:n,attrs:a}=e,{iouThreshold:r,maxOutputSize:s,scoreThreshold:i,softNmsSigma:o}=a,{boxes:l,scores:d}=n,u=t.dataIdMap.get(l.dataId).id,p=t.dataIdMap.get(d.dataId).id,c=T8(u,p,s,r,i,o),{pSelectedIndices:h,selectedSize:f,pSelectedScores:m,pValidOutputs:g}=Q2(t,c);t.wasm._free(g);let y=t.makeOutput([f],"int32",h),A=t.makeOutput([f],"float32",m);return[y,A]}var Uoe={kernelName:El,backendName:"wasm",setupFunc:Boe,kernelFunc:Voe},joe=!1,Goe=Pn(Nl,joe,"bool"),C8;function Hoe(e){C8=e.wasm.cwrap(Ni,null,["number","number","number","number","number"])}function qoe(e){let{inputs:t,backend:n,attrs:a}=e,{indices:r}=t,{depth:s,onValue:i,offValue:o}=a,l=n.makeOutput([...r.shape,s],"int32"),d=n.dataIdMap.get(l.dataId).id,u=n.dataIdMap.get(r.dataId).id;return C8(u,s,i,o,d),l}var Xoe={kernelName:Ni,backendName:"wasm",setupFunc:Hoe,kernelFunc:qoe};function Koe(e){let{inputs:{x:t},backend:n}=e,a=n.makeOutput(t.shape,t.dtype);return n.typedArrayFromHeap(a).fill(1),a}var Zoe={kernelName:Rl,backendName:"wasm",kernelFunc:Koe};function Yoe(e){let{inputs:t,backend:n,attrs:a}=e,{axis:r}=a;if(t.length===1)return Y2({inputs:{input:t[0]},backend:n,attrs:{dim:r}});let s=t[0].shape,i=t[0].dtype;t.forEach(u=>{w.assertShapesMatch(s,u.shape,"All tensors passed to stack must have matching shapes"),w.assert(i===u.dtype,()=>"All tensors passed to stack must have matching dtypes")});let o=[],l=t.map(u=>{let p=Y2({inputs:{input:u},backend:n,attrs:{dim:r}});return o.push(p),p}),d=s8({inputs:l,backend:n,attrs:{axis:r}});return o.forEach(u=>n.disposeData(u.dataId)),d}var Joe={kernelName:Ml,backendName:"wasm",kernelFunc:Yoe},E8;function Qoe(e){E8=e.wasm.cwrap(Ti,null,["number","array","number","number","array","array","number","number"])}function ele(e){let{inputs:{x:t},backend:n,attrs:{paddings:a,constantValue:r}}=e,s=a.map((f,m)=>f[0]+t.shape[m]+f[1]);if(w.sizeFromShape(t.shape)===0)return c8({backend:n,attrs:{shape:s,value:r,dtype:t.dtype}});let i=n.dataIdMap.get(t.dataId).id,o=n.makeOutput(s,t.dtype),l=n.dataIdMap.get(o.dataId).id,d=new Uint8Array(new Int32Array(t.shape).buffer),u=a.map(f=>f[0]),p=a.map(f=>f[1]),c=new Uint8Array(new Int32Array(u).buffer),h=new Uint8Array(new Int32Array(p).buffer);return E8(i,d,t.shape.length,Kt[t.dtype],c,h,r,l),o}var R8={kernelName:Ti,backendName:"wasm",kernelFunc:ele,setupFunc:Qoe},tle=!1,nle=Pn(Ci,tle),M8;function ale(e){M8=e.wasm.cwrap(Ei,null,["number","number","number"])}function rle(e){let{inputs:t,backend:n}=e,{x:a,alpha:r}=t,s=n.dataIdMap.get(a.dataId).id,i=n.dataIdMap.get(r.dataId).id,o=s,l=a,d=l;l.dtype!=="float32"&&(d=Gp({backend:n,inputs:{x:a},attrs:{dtype:"float32"}}),o=n.dataIdMap.get(d.dataId).id);let u=n.makeOutput(a.shape,"float32"),p=n.dataIdMap.get(u.dataId).id;return M8(o,i,p),l.dtype!=="float32"&&n.disposeData(d.dataId),u}var sle={kernelName:Ei,backendName:"wasm",setupFunc:ale,kernelFunc:rle},F8;function ile(e){F8=e.wasm.cwrap(Fl,null,["number","number","number","number"])}function ole(e){let{backend:t,inputs:n,attrs:a}=e,{axis:r,keepDims:s}=a,{x:i}=n,o=t.dataIdMap.get(i.dataId).id,l=o,d=i,{transposed:u,axes:p,originalAxes:c,inputWasTransposed:h}=$s(i,r,t),f=p;if(h){let x=t.dataIdMap.get(u.dataId).id;x!==o&&(d=u,l=x,f=E.getInnerMostAxes(f.length,d.shape.length))}E.assertAxesAreInnerMostDims("prod",f,d.shape.length);let[m,g]=E.computeOutAndReduceShapes(d.shape,f),y=w.sizeFromShape(g),A=t.makeOutput(m,d.dtype);if(w.sizeFromShape(d.shape)!==0){let x=t.dataIdMap.get(A.dataId).id;F8(l,y,Kt[A.dtype],x)}if(h&&t.disposeData(u.dataId),s){let x=E.expandShapeToKeepDim(A.shape,c);A.shape=x}return A}var lle={kernelName:Fl,backendName:"wasm",setupFunc:ile,kernelFunc:ole},ule=e=>{let{backend:t,attrs:n}=e,{start:a,stop:r,step:s,dtype:i}=n,o=b2(a,r,s,i),l=t.makeOutput([o.length],i);return t.typedArrayFromHeap(l).set(o),l},dle={kernelName:Td,backendName:"wasm",kernelFunc:ule},ple=!0,cle=Pn(li,ple),hle=wn(Ri),fle=wn(Fi),D8;function mle(e){D8=e.wasm.cwrap(Mi,null,["number","number","number","number","number","number","number","number","number","number"])}function gle(e){let{backend:t,inputs:n,attrs:a}=e,{images:r}=n,{alignCorners:s,halfPixelCenters:i,size:o}=a,[l,d]=o,[u,p,c,h]=r.shape,f=[u,l,d,h],m=t.dataIdMap.get(r.dataId),g;m.dtype!=="float32"&&(g=Gp({backend:t,inputs:{x:r},attrs:{dtype:"float32"}}),m=t.dataIdMap.get(g.dataId));let y=m.id,A=t.makeOutput(f,"float32");if(w.sizeFromShape(r.shape)===0)return A;let x=t.dataIdMap.get(A.dataId).id;return D8(y,u,p,c,h,l,d,s?1:0,i?1:0,x),g!=null&&t.disposeData(g.dataId),A}var yle={kernelName:Mi,backendName:"wasm",setupFunc:mle,kernelFunc:gle},$8;function Ale(e){$8=e.wasm.cwrap(Di,null,["number","array","number","array","number","number"])}function xle(e){let{inputs:t,backend:n,attrs:a}=e,{x:r}=t,{dims:s}=a,i=w.parseAxisParam(s,r.shape);if(r.shape.length===0)return Cf({inputs:{x:r},backend:n});let o=n.makeOutput(r.shape,r.dtype),l=n.dataIdMap.get(r.dataId).id,d=n.dataIdMap.get(o.dataId).id,u=new Uint8Array(new Int32Array(i).buffer),p=new Uint8Array(new Int32Array(r.shape).buffer);$8(l,u,i.length,p,r.shape.length,d);let c=ta({inputs:{x:o},attrs:{shape:r.shape},backend:n});return n.disposeData(o.dataId),c}var ble={kernelName:Di,backendName:"wasm",kernelFunc:xle,setupFunc:Ale},O8;function vle(e){O8=e.wasm.cwrap(Kl,null,["number","number","number","number","number","number","number","number","array","number","number"])}function wle(e){let{inputs:t,backend:n,attrs:a}=e,{image:r}=t,{radians:s,fillValue:i,center:o}=a,l=n.makeOutput(r.shape,r.dtype),d=n.dataIdMap.get(r.dataId).id,u=n.dataIdMap.get(l.dataId).id,[p,c,h,f]=r.shape,[m,g]=E.getImageCenter(o,c,h),y=i===0,A=255,x=typeof i=="number"?[i,i,i,y?0:A]:[...i,A],b=new Uint8Array(new Int32Array(x).buffer);return O8(d,p,c,h,f,s,m,g,b,x.length,u),l}var kle={kernelName:Kl,backendName:"wasm",kernelFunc:wle,setupFunc:vle},Ile=wn($i),Sle=wn(Oi),_8;function Nle(e){_8=e.wasm.cwrap(Ol,null,["number","number","number","number","number","number","array","number","number"])}function Tle(e){let{backend:t,inputs:n,attrs:a}=e,{indices:r,updates:s}=n,{shape:i}=a,o=t.makeOutput(i,s.dtype);if(w.sizeFromShape(i)===0)return o;let{sliceRank:l,numUpdates:d,sliceSize:u,strides:p,outputSize:c}=ug.calculateShapes(s,r,i),h=t.dataIdMap.get(r.dataId).id,f=t.dataIdMap.get(s.dataId).id,m=new Uint8Array(new Int32Array(p).buffer),g=t.dataIdMap.get(o.dataId).id;return _8(h,f,Kt[s.dtype],l,d,u,m,c,g),o}var Cle={kernelName:Ol,backendName:"wasm",setupFunc:Nle,kernelFunc:Tle},P8;function Ele(e){P8=e.wasm.cwrap("SelectV2",null,["number","number","number","number","number"])}function Rle(e){let{inputs:t,backend:n}=e,{condition:a,t:r,e:s}=t,i=n.dataIdMap.get(a.dataId).id,o=n.dataIdMap.get(r.dataId).id,l=n.dataIdMap.get(s.dataId).id,d=n.makeOutput(r.shape,r.dtype),u=n.dataIdMap.get(d.dataId).id,p=a.shape.length,c=r.shape.length,h=p===0||p>1||c===1?1:w.sizeFromShape(r.shape.slice(1));return P8(i,o,l,h,u),d}var Mle={kernelName:_l,backendName:"wasm",kernelFunc:Rle,setupFunc:Ele},z8;function Fle(e){z8=e.wasm.cwrap(Pi,null,["number","number"])}function Dle(e){let{backend:t,inputs:{x:n}}=e,a=t.dataIdMap.get(n.dataId).id,r=t.makeOutput(n.shape,n.dtype),s=t.dataIdMap.get(r.dataId).id;return w.sizeFromShape(r.shape)===0||z8(a,s),r}var $le={kernelName:"Sigmoid",backendName:"wasm",setupFunc:Fle,kernelFunc:Dle},Ole=wn(_i),L8;function _le(e){L8=e.wasm.cwrap(Wi,null,["number","number","number","number"])}function Ple(e){let{backend:t,inputs:{logits:n},attrs:{dim:a}}=e,r=t.dataIdMap.get(n.dataId).id,s=t.makeOutput(n.shape,n.dtype),i=t.dataIdMap.get(s.dataId).id,o=n.shape[a],l=w.sizeFromShape(n.shape)/o;return w.sizeFromShape(s.shape)===0||L8(r,i,o,l),s}var zle={kernelName:Wi,backendName:"wasm",setupFunc:_le,kernelFunc:Ple};function Lle(e){let{inputs:t,backend:n,attrs:a}=e,{x:r}=t,{blockShape:s,paddings:i}=a,o=w.sizeFromShape(s),l=[[0,0]];l.push(...i);for(let g=1+s.length;g<r.shape.length;++g)l.push([0,0]);let d=R8.kernelFunc({inputs:{x:r},backend:n,attrs:{paddings:l,constantValue:0}}),u=E.getReshaped(d.shape,s,o,!1),p=E.getPermuted(u.length,s.length,!1),c=E.getReshapedPermuted(d.shape,s,o,!1),h=ta({inputs:{x:d},backend:n,attrs:{shape:u}}),f=Vu({inputs:{x:h},backend:n,attrs:{perm:p}}),m=ta({inputs:{x:f},backend:n,attrs:{shape:c}});return n.disposeData(d.dataId),n.disposeData(h.dataId),n.disposeData(f.dataId),m}var Wle={kernelName:Vl,backendName:"wasm",kernelFunc:Lle};function Ble(e){let{inputs:t,attrs:n,backend:a}=e,{x:r}=t,{numOrSizeSplits:s,axis:i}=n,o=w.parseAxisParam(i,r.shape)[0],l=E.prepareSplitSize(r,s,o),d=new Array(r.shape.length).fill(0),u=r.shape.slice();return l.map(p=>{let c=[...u];c[o]=p;let h=jp({inputs:{x:r},attrs:{begin:d,size:c},backend:a});return d[o]+=p,h})}var Vle={kernelName:Ul,backendName:"wasm",kernelFunc:Ble},Ule=wn(zi),jle=wn(Ed),Gle=!0,Hle=Pn(Bi,Gle),W8;function qle(e){W8=e.wasm.cwrap(ps,null,["number","number","number","number"])}function Xle(e){let{backend:t,inputs:n,attrs:a}=e,{alpha:r}=a,{x:s}=n,i=t.dataIdMap.get(s.dataId).id,o=t.makeOutput(s.shape,s.dtype),l=t.dataIdMap.get(o.dataId).id;return W8(i,r,Kt[s.dtype],l),o}var Kle={kernelName:ps,backendName:"wasm",setupFunc:qle,kernelFunc:Xle},B8;function Zle(e){B8=e.wasm.cwrap(jl,null,["number","array","number","array","array","array","array","array","number","number"])}function Yle(e){let{backend:t,inputs:n,attrs:a}=e,{x:r}=n,{begin:s,end:i,strides:o}=a;o==null&&(o=new Array(s.length));let{beginMask:l,endMask:d,ellipsisMask:u,newAxisMask:p,shrinkAxisMask:c}=a,h=E.slice_util.maskToAxes(u);if(h.length>1)throw new Error("Multiple ellipses in slice is not allowed.");if(u!==0&&p!==0)throw new Error("Using both ellipsisMask and newAxisMask is not yet supported.");if(u!==0&&c!==0)throw new Error("Using both ellipsisMask and shrinkAxisMask is not yet supported.");let f=r.shape.length-s.length,m=E.slice_util.maskToAxes(p),g=r.shape.slice();m.forEach(O=>{s[O]=0,i[O]=1,g.splice(O,0,1)});let y=ta({inputs:{x:r},attrs:{shape:g},backend:t}),{begin:A,end:x,strides:b}=E.slice_util.getNormalizedAxes(y.shape,h,f,s,i,o,l,d,u);s=A,i=x,o=b;let v=E.slice_util.maskToAxes(c);v.forEach(O=>{i[O]=s[O]+1,o[O]=1});let k=E.slice_util.computeOutShape(s,i,o),T=k.filter((O,F)=>v.indexOf(F)===-1);if(o.every(O=>O===1)){let O=jp({inputs:{x:y},attrs:{begin:s,size:k},backend:t});t.disposeData(y.dataId);let F=ta({inputs:{x:O},attrs:{shape:T},backend:t});return t.disposeData(O.dataId),F}let C=t.makeOutput(T,"float32");if(!T.some(O=>O===0)){let O=t.dataIdMap.get(y.dataId).id,F=new Uint8Array(new Int32Array(w.computeStrides(y.shape)).buffer),S=new Uint8Array(new Int32Array(s).buffer),P=new Uint8Array(new Int32Array(i).buffer),_=new Uint8Array(new Int32Array(o).buffer),j=new Uint8Array(new Int32Array(T).buffer),q=new Uint8Array(new Int32Array(w.computeStrides(T)).buffer),z=t.dataIdMap.get(C.dataId).id;B8(O,F,y.shape.length,S,P,_,j,q,T.length,z)}t.disposeData(y.dataId);let D=ta({inputs:{x:C},attrs:{shape:T},backend:t});return t.disposeData(C.dataId),D}var Jle={kernelName:jl,backendName:"wasm",setupFunc:Zle,kernelFunc:Yle},Qle=!0,eue=Pn(Vi,Qle),V8;function tue(e){V8=e.wasm.cwrap(Li,null,["number","number","number","number"])}function nue(e){let{backend:t,inputs:n,attrs:a}=e,{axis:r,keepDims:s}=a,{x:i}=n,o=t.dataIdMap.get(i.dataId).id,l=o,d=i,{transposed:u,axes:p,originalAxes:c,inputWasTransposed:h}=$s(i,r,t),f=p;if(h){let x=t.dataIdMap.get(u.dataId).id;x!==o&&(d=u,l=x,f=E.getInnerMostAxes(f.length,d.shape.length))}E.assertAxesAreInnerMostDims("sum",f,d.shape.length);let[m,g]=E.computeOutAndReduceShapes(d.shape,f),y=w.sizeFromShape(g),A=t.makeOutput(m,d.dtype);if(w.sizeFromShape(d.shape)!==0){let x=t.dataIdMap.get(A.dataId).id;V8(l,y,Kt[A.dtype],x)}if(h&&t.disposeData(u.dataId),s){let x=E.expandShapeToKeepDim(A.shape,c);A.shape=x}return A}var aue={kernelName:Li,backendName:"wasm",setupFunc:tue,kernelFunc:nue},rue=wn(Ui),sue=wn(ji),U8;function iue(e){U8=e.wasm.cwrap(ds,null,["number","array","number","array","number","number"])}function oue(e){let{inputs:t,backend:n,attrs:a}=e,{x:r}=t,s=n.dataIdMap.get(r.dataId).id,{reps:i}=a,o=new Array(r.shape.length);for(let c=0;c<o.length;c++)o[c]=r.shape[c]*i[c];let l=new Uint8Array(new Int32Array(r.shape).buffer),d=new Uint8Array(new Int32Array(o).buffer),u=n.makeOutput(o,r.dtype),p=n.dataIdMap.get(u.dataId).id;return U8(s,l,r.shape.length,d,o.length,Kt[u.dtype],p),u}var lue={kernelName:ds,backendName:"wasm",setupFunc:iue,kernelFunc:oue},j8;function uue(e){j8=e.wasm.cwrap(Gl,null,["number","array","number","number","number","bool","number","number"])}var due=({inputs:e,backend:t,attrs:n})=>{let{x:a}=e,{k:r,sorted:s}=n,i=t.dataIdMap.get(a.dataId).id,o=new Uint8Array(new Int32Array(a.shape).buffer),l=a.shape.slice();l[l.length-1]=r;let d=t.makeOutput(l,a.dtype),u=t.dataIdMap.get(d.dataId).id,p=t.makeOutput(l,"int32"),c=t.dataIdMap.get(p.dataId).id;return j8(i,o,a.shape.length,Kt[a.dtype],r,s,u,c),[d,p]},pue={kernelName:Gl,backendName:"wasm",setupFunc:uue,kernelFunc:due},G8;function cue(e){G8=e.wasm.cwrap(Hl,null,["number","number","bool","number","number","number","number","number","number","array","number","number","number","number","number"])}function hue(e){let{backend:t,inputs:n,attrs:a}=e,{image:r,transforms:s}=n,{interpolation:i,fillMode:o,fillValue:l,outputShape:d}=a,[u,p,c,h]=r.shape,[f,m]=d!=null?d:[p,c],g=[u,f,m,h],y=new Uint8Array(new Int32Array(w.computeStrides(r.shape)).buffer),A=t.makeOutput(g,r.dtype),x=t.dataIdMap.get(A.dataId).id,b=t.dataIdMap.get(r.dataId).id,v=t.dataIdMap.get(s.dataId).id,k=i==="nearest"?1:2,T;switch(o){case"constant":T=1;break;case"reflect":T=2;break;case"wrap":T=3;break;case"nearest":T=4;break;default:T=1;break}return G8(b,v,s.shape[0]>1,u,f,m,h,c,p,y,r.shape.length-1,k,T,l,x),A}var fue={kernelName:Hl,backendName:"wasm",setupFunc:cue,kernelFunc:hue};function mue(e){let{inputs:t,backend:n,attrs:a}=e,{value:r}=t,{axis:s}=a;s<0&&(s+=r.shape.length);let i=r.shape[s],o=r.shape.length,l=new Array(o-1),d=0;for(let h=0;h<o;h++)h!==s&&(l[d++]=r.shape[h]);let u=new Array(i),p=new Array(o).fill(0),c=r.shape.slice();c[s]=1;for(let h=0;h<u.length;h++)p[s]=h,u[h]=jp({inputs:{x:r},attrs:{begin:p,size:c},backend:n});return u.map(({dataId:h,dtype:f})=>({dataId:h,dtype:f,shape:l}))}var gue={kernelName:ql,backendName:"wasm",kernelFunc:mue};function yue(e){let{inputs:{x:t},backend:n}=e,a=n.makeOutput(t.shape,t.dtype);return n.typedArrayFromHeap(a).fill(0),a}var Aue={kernelName:Xl,backendName:"wasm",kernelFunc:yue},xue=[vse,kse,Nse,$se,Pse,Wse,Use,qse,Qse,eie,tie,rie,sie,lie,pie,cie,hie,gie,xie,wie,Sie,Nie,Cie,Eie,Rie,Mie,$ie,Oie,Pie,bse,Wie,Uie,Hie,Kie,Jie,eoe,noe,Tse,soe,ooe,uoe,doe,coe,moe,yoe,boe,koe,Noe,Coe,Moe,Doe,$oe,Poe,Woe,Uoe,Goe,Xoe,Zoe,Joe,R8,nle,sle,lle,dle,cle,hle,fle,jse,yle,ble,kle,Sle,Ile,Cle,Mle,$le,Ole,Yse,zle,Wle,Vle,Ule,jle,Hle,Kle,Jle,eue,aue,rue,sue,lue,pue,fue,Mse,gue,Aue];for(let e of xue)cs(e);var ex=ne();ex.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])));ex.registerFlag("WASM_HAS_MULTITHREAD_SUPPORT",async()=>{if(ex.get("IS_NODE"))return!1;try{return new MessageChannel().port1.postMessage(new SharedArrayBuffer(1)),WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,5,4,1,3,1,1,10,11,1,9,0,65,0,254,16,2,0,26,11]))}catch(e){return!1}});var H8=qs(AN()),bue='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()}}}}',vue=qs(xN()),q8=class extends fd{constructor(e){super();this.wasm=e,this.dataIdNextNumber=1,this.wasm.tfjs.initWithThreadsCount(Z8),nx=this.wasm.tfjs.getThreadsCount(),this.dataIdMap=new Oc(this,sa())}write(e,t,n){let a={id:this.dataIdNextNumber++};return this.move(a,e,t,n,1),a}numDataIds(){return this.dataIdMap.numDataIds()}async time(e){let t=w.now();return e(),{kernelMs:w.now()-t}}move(e,t,n,a,r){let s=this.dataIdNextNumber++;if(a==="string"){let d=t;this.dataIdMap.set(e,{id:s,stringBytes:d,shape:n,dtype:a,memoryOffset:null,refCount:r});return}let i=w.sizeFromShape(n),o=i*w.bytesPerElement(a),l=this.wasm._malloc(o);this.dataIdMap.set(e,{id:s,memoryOffset:l,shape:n,dtype:a,refCount:r}),this.wasm.tfjs.registerTensor(s,i,l),t!=null&&this.wasm.HEAPU8.set(new Uint8Array(t.buffer,t.byteOffset,o),l)}async read(e){return this.readSync(e)}readSync(e){let{memoryOffset:t,dtype:n,shape:a,stringBytes:r}=this.dataIdMap.get(e);if(n==="string")return r;let s=this.wasm.HEAPU8.slice(t,t+w.sizeFromShape(a)*w.bytesPerElement(n));return Iue(s.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 a;if(n==null)a=this.write(null,e,t);else{let r=this.dataIdNextNumber++;a={id:r},this.dataIdMap.set(a,{id:r,memoryOffset:n,shape:e,dtype:t,refCount:1});let s=w.sizeFromShape(e);this.wasm.tfjs.registerTensor(r,s,n)}return{dataId:a,shape:e,dtype:t}}typedArrayFromHeap({shape:e,dtype:t,dataId:n}){let a=this.wasm.HEAPU8.buffer,{memoryOffset:r}=this.dataIdMap.get(n),s=w.sizeFromShape(e);switch(t){case"float32":return new Float32Array(a,r,s);case"int32":return new Int32Array(a,r,s);case"bool":return new Uint8Array(a,r,s);default:throw new Error(`Unknown dtype ${t}`)}}};function wue(e){return(t,n)=>(w.fetch(e,{credentials:"same-origin"}).then(a=>{a.ok||t.env.a(`failed to load wasm binary file at '${e}'`),a.arrayBuffer().then(r=>{WebAssembly.instantiate(r,t).then(s=>{n(s.instance,s.module)})})}),{})}function X8(e,t,n){if(Ef!=null)return Ef;let a="tfjs-backend-wasm.wasm";return e&&t?a="tfjs-backend-wasm-threaded-simd.wasm":e&&(a="tfjs-backend-wasm-simd.wasm"),qp!=null&&qp[a]!=null?qp[a]:n+a}async function kue(){let[e,t]=await Promise.all([ne().getAsync("WASM_HAS_SIMD_SUPPORT"),ne().getAsync("WASM_HAS_MULTITHREAD_SUPPORT")]);return new Promise((n,a)=>{let r={};r.locateFile=(o,l)=>{if(o.endsWith(".worker.js")){let d=bue,u=new Blob([d],{type:"application/javascript"});return URL.createObjectURL(u)}return o.endsWith(".wasm")?X8(e,t,Hp!=null?Hp:l):l+o},tx&&(r.instantiateWasm=wue(X8(e,t,Hp!=null?Hp:"")));let s=!1;r.onAbort=()=>{s||Xp||(Xp=!0,a({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 i;t&&e&&Ef==null?(r.mainScriptUrlOrBlob=new Blob(["var WasmBackendModuleThreadedSimd = "+H8.default.toString()],{type:"text/javascript"}),i=(0,H8.default)(r)):i=(0,vue.default)(r),i.then(o=>{s=!0,Xp=!1;let l=null;o.tfjs={init:o.cwrap("init",null,[]),initWithThreadsCount:o.cwrap("init_with_threads_count",null,["number"]),getThreadsCount:o.cwrap("get_threads_count","number",[]),registerTensor:o.cwrap("register_tensor",null,["number","number","number"]),disposeData:o.cwrap("dispose_data",l,["number"]),dispose:o.cwrap("dispose",l,[])},n({wasm:o})})})}function Iue(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 Sue=["tfjs-backend-wasm.wasm","tfjs-backend-wasm-simd.wasm","tfjs-backend-wasm-threaded-simd.wasm"],Ef=null,Hp=null,qp={},Xp=!1,tx=!1;function Nue(e,t=!1){if(mg("setWasmPath has been deprecated in favor of setWasmPaths and will be removed in a future release."),Xp)throw new Error("The WASM backend was already initialized. Make sure you call `setWasmPath()` before you call `tf.setBackend()` or `tf.ready()`");Ef=e,tx=t}function K8(e,t=!1){if(Xp)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")Hp=e;else{qp=e;let n=Sue.filter(a=>qp[a]==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.`)}tx=t}var Z8=-1,nx=-1;function Tue(e){Z8=e}function Cue(){if(nx===-1)throw new Error("WASM backend not initialized.");return nx}var Eue="3.10.0",Rue=2;au("wasm",async()=>{let{wasm:e}=await kue();return new q8(e)},Rue);var Mue="3.10.0",Fue="3.10.0",Due="3.10.0",$ue="3.10.0",Oue="3.10.0",_ue="3.10.0",Pue="3.10.0",zue="3.10.0",Lue={tfjs:Mue,"tfjs-core":Fue,"tfjs-data":Due,"tfjs-layers":$ue,"tfjs-converter":Oue,"tfjs-backend-cpu":_ue,"tfjs-backend-webgl":Pue,"tfjs-backend-wasm":zue};var Y8=`
|
|
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 J8=`
|
|
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];
|
|
}
|
|
`,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[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;
|
|
}
|
|
`,e9=`
|
|
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);
|
|
}
|
|
`,t9=`
|
|
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;
|
|
}
|
|
`,n9=`
|
|
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 ax=(e,t,n)=>{let a=new RegExp("\\b"+t+" \\w+ (\\w+)","ig");e.replace(a,(r,s)=>(n[s]=0,r))},a9=class{constructor(t,n,a){ce(this,"uniform",{});ce(this,"attribute",{});ce(this,"gl");ce(this,"id");ce(this,"compile",(t,n)=>{let a=this.gl.createShader(n);if(this.gl.shaderSource(a,t),this.gl.compileShader(a),!this.gl.getShaderParameter(a,this.gl.COMPILE_STATUS))throw new Error(`filter: gl compile failed: ${this.gl.getShaderInfoLog(a)}`);return a});this.gl=t;let r=this.compile(n,this.gl.VERTEX_SHADER),s=this.compile(a,this.gl.FRAGMENT_SHADER);if(this.id=this.gl.createProgram(),this.gl.attachShader(this.id,r),this.gl.attachShader(this.id,s),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),ax(n,"attribute",this.attribute);for(let i in this.attribute)this.attribute[i]=this.gl.getAttribLocation(this.id,i);ax(n,"uniform",this.uniform),ax(a,"uniform",this.uniform);for(let i in this.uniform)this.uniform[i]=this.gl.getUniformLocation(this.id,i)}};function r9(){let e=0,t=null,n=!1,a=-1,r=[null,null],s=[],i=null,o=null,l=zn(100,100),d={},u={INTERMEDIATE:1},p=l.getContext("webgl");if(!p)throw new Error("filter: cannot get webgl context");function c(A,x){if(!(A===l.width&&x===l.height)){if(l.width=A,l.height=x,!i){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]);i=p.createBuffer(),p.bindBuffer(p.ARRAY_BUFFER,i),p.bufferData(p.ARRAY_BUFFER,b,p.STATIC_DRAW),p.pixelStorei(p.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!0)}p.viewport(0,0,l.width,l.height),r=[null,null]}}function h(A,x){let b=p.createFramebuffer();p.bindFramebuffer(p.FRAMEBUFFER,b);let v=p.createRenderbuffer();p.bindRenderbuffer(p.RENDERBUFFER,v);let k=p.createTexture();return p.bindTexture(p.TEXTURE_2D,k),p.texImage2D(p.TEXTURE_2D,0,p.RGBA,A,x,0,p.RGBA,p.UNSIGNED_BYTE,null),p.texParameteri(p.TEXTURE_2D,p.TEXTURE_MAG_FILTER,p.LINEAR),p.texParameteri(p.TEXTURE_2D,p.TEXTURE_MIN_FILTER,p.LINEAR),p.texParameteri(p.TEXTURE_2D,p.TEXTURE_WRAP_S,p.CLAMP_TO_EDGE),p.texParameteri(p.TEXTURE_2D,p.TEXTURE_WRAP_T,p.CLAMP_TO_EDGE),p.framebufferTexture2D(p.FRAMEBUFFER,p.COLOR_ATTACHMENT0,p.TEXTURE_2D,k,0),p.bindTexture(p.TEXTURE_2D,null),p.bindFramebuffer(p.FRAMEBUFFER,null),{fbo:b,texture:k}}function f(A){return r[A]=r[A]||h(l.width,l.height),r[A]}function m(A=0){var k,T;if(!o)return;let x=null,b=null,v=!1;e===0?x=t:x=((k=f(a))==null?void 0:k.texture)||null,e++,n&&!(A&u.INTERMEDIATE)?(b=null,v=e%2==0):(a=(a+1)%2,b=((T=f(a))==null?void 0:T.fbo)||null),p.bindTexture(p.TEXTURE_2D,x),p.bindFramebuffer(p.FRAMEBUFFER,b),p.uniform1f(o.uniform.flipY,v?-1:1),p.drawArrays(p.TRIANGLES,0,6)}function g(A){if(d[A])return o=d[A],p.useProgram((o==null?void 0:o.id)||null),o;o=new a9(p,Y8,A);let x=Float32Array.BYTES_PER_ELEMENT,b=4*x;return p.enableVertexAttribArray(o.attribute.pos),p.vertexAttribPointer(o.attribute.pos,2,p.FLOAT,!1,b,0*x),p.enableVertexAttribArray(o.attribute.uv),p.vertexAttribPointer(o.attribute.uv,2,p.FLOAT,!1,b,2*x),d[A]=o,o}let y={colorMatrix:A=>{let x=new Float32Array(A);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?Q8:J8,v=g(b);p.uniform1fv(v==null?void 0:v.uniform.m,x),m()},brightness:A=>{let x=(A||0)+1;y.colorMatrix([x,0,0,0,0,0,x,0,0,0,0,0,x,0,0,0,0,0,1,0])},saturation:A=>{let x=(A||0)*2/3+1,b=(x-1)*-.5;y.colorMatrix([x,b,b,0,0,b,x,b,0,0,b,b,x,0,0,0,0,0,1,0])},desaturate:()=>{y.saturation(-1)},contrast:A=>{let x=(A||0)+1,b=-128*(x-1);y.colorMatrix([x,0,0,0,b,0,x,0,0,b,0,0,x,0,b,0,0,0,1,0])},negative:()=>{y.contrast(-2)},hue:A=>{A=(A||0)/180*Math.PI;let x=Math.cos(A),b=Math.sin(A),v=.213,k=.715,T=.072;y.colorMatrix([v+x*(1-v)+b*-v,k+x*-k+b*-k,T+x*-T+b*(1-T),0,0,v+x*-v+b*.143,k+x*(1-k)+b*.14,T+x*-T+b*-.283,0,0,v+x*-v+b*-(1-v),k+x*-k+b*k,T+x*(1-T)+b*T,0,0,0,0,0,1,0])},desaturateLuminance:()=>{y.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:()=>{y.colorMatrix([.393,.7689999,.18899999,0,0,.349,.6859999,.16799999,0,0,.272,.5339999,.13099999,0,0,0,0,0,1,0])},brownie:()=>{y.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:()=>{y.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:()=>{y.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:()=>{y.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:()=>{y.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:()=>{y.colorMatrix([0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,1,0])},convolution:A=>{let x=new Float32Array(A),b=1/l.width,v=1/l.height,k=g(n9);p.uniform1fv(k==null?void 0:k.uniform.m,x),p.uniform2f(k==null?void 0:k.uniform.px,b,v),m()},detectEdges:()=>{y.convolution.call(this,[0,1,0,1,-4,1,0,1,0])},sobelX:()=>{y.convolution.call(this,[-1,0,1,-2,0,2,-1,0,1])},sobelY:()=>{y.convolution.call(this,[-1,-2,-1,0,0,0,1,2,1])},sharpen:A=>{let x=A||1;y.convolution.call(this,[0,-1*x,0,-1*x,1+4*x,-1*x,0,-1*x,0])},emboss:A=>{let x=A||1;y.convolution.call(this,[-2*x,-1*x,0,-1*x,1,1*x,0,1*x,2*x])},blur:A=>{let x=A/7/l.width,b=A/7/l.height,v=g(t9);p.uniform2f(v==null?void 0:v.uniform.px,0,b),m(u.INTERMEDIATE),p.uniform2f(v==null?void 0:v.uniform.px,x,0),m()},pixelate:A=>{let x=A/l.width,b=A/l.height,v=g(e9);p.uniform2f(v==null?void 0:v.uniform.size,x,b),m()}};this.add=function(A){let x=Array.prototype.slice.call(arguments,1),b=y[A];s.push({func:b,args:x})},this.reset=function(){s=[]},this.get=function(){return s},this.apply=function(A){c(A.width,A.height),e=0,t||(t=p.createTexture()),p.bindTexture(p.TEXTURE_2D,t),p.texParameteri(p.TEXTURE_2D,p.TEXTURE_WRAP_S,p.CLAMP_TO_EDGE),p.texParameteri(p.TEXTURE_2D,p.TEXTURE_WRAP_T,p.CLAMP_TO_EDGE),p.texParameteri(p.TEXTURE_2D,p.TEXTURE_MIN_FILTER,p.NEAREST),p.texParameteri(p.TEXTURE_2D,p.TEXTURE_MAG_FILTER,p.NEAREST),p.texImage2D(p.TEXTURE_2D,0,p.RGBA,p.RGBA,p.UNSIGNED_BYTE,A);for(let x=0;x<s.length;x++){n=x===s.length-1;let b=s[x];b.func.apply(this,b.args||[])}return l},this.draw=function(A){return this.add("brightness",0),this.apply(A)}}var Rf=2048,it=null,Vt=null,Os=null,Rt;function zn(e,t){let n;if(xe.browser)if(xe.offscreen)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 rx(e,t){let n=t||zn(e.width,e.height);return n.getContext("2d").drawImage(e,0,0),n}function Uu(e,t,n=!0){if(!e)return t.debug&&ie("input is missing"),{tensor:null,canvas:null};if(!(e instanceof je)&&!(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 je){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:Za(e),canvas:t.filter.return?Vt:null}}else{if(typeof e.readyState!="undefined"&&e.readyState<=2)return t.debug&&ie("input stream is not ready"),{tensor:null,canvas:it};let a=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(!a||!r)return t.debug&&ie("cannot determine input dimensions"),{tensor:null,canvas:it};let s=a,i=r;if(s>Rf&&(s=Rf,i=Math.trunc(s*r/a)),i>Rf&&(i=Rf,s=Math.trunc(i*a/r)),(t.filter.width||0)>0?s=t.filter.width:(t.filter.height||0)>0&&(s=a*((t.filter.height||0)/r)),(t.filter.height||0)>0?i=t.filter.height:(t.filter.width||0)>0&&(i=r*((t.filter.width||0)/a)),!s||!i)throw new Error("input cannot determine dimension");(!it||(it==null?void 0:it.width)!==s||(it==null?void 0:it.height)!==i)&&(it=zn(s,i));let o=it.getContext("2d");if(typeof ImageData!="undefined"&&e instanceof ImageData?o.putImageData(e,0,0):t.filter.flip&&typeof o.translate!="undefined"?(o.translate(a,0),o.scale(-1,1),o.drawImage(e,0,0,a,r,0,0,it==null?void 0:it.width,it==null?void 0:it.height),o.setTransform(1,0,0,1,0,0)):o.drawImage(e,0,0,a,r,0,0,it==null?void 0:it.width,it==null?void 0:it.height),(!Vt||it.width!==Vt.width||(it==null?void 0:it.height)!==(Vt==null?void 0:Vt.height))&&(Vt=zn(it.width,it.height)),t.filter.enabled&&xe.webgl.supported){if(Rt||(Rt=xe.browser?new r9:null),xe.filter=!!Rt,!Rt)return{tensor:null,canvas:it};Rt.reset(),t.filter.brightness!==0&&Rt.add("brightness",t.filter.brightness),t.filter.contrast!==0&&Rt.add("contrast",t.filter.contrast),t.filter.sharpness!==0&&Rt.add("sharpen",t.filter.sharpness),t.filter.blur!==0&&Rt.add("blur",t.filter.blur),t.filter.saturation!==0&&Rt.add("saturation",t.filter.saturation),t.filter.hue!==0&&Rt.add("hue",t.filter.hue),t.filter.negative&&Rt.add("negative"),t.filter.sepia&&Rt.add("sepia"),t.filter.vintage&&Rt.add("brownie"),t.filter.sepia&&Rt.add("sepia"),t.filter.kodachrome&&Rt.add("kodachrome"),t.filter.technicolor&&Rt.add("technicolor"),t.filter.polaroid&&Rt.add("polaroid"),t.filter.pixelate!==0&&Rt.add("pixelate",t.filter.pixelate),Rt.get()>0?Vt=Rt.apply(it):Vt=Rt.draw(it)}else rx(it,Vt),Rt&&(Rt=null),xe.filter=!!Rt;if(!n)return{tensor:null,canvas:Vt};if(!Vt)throw new Error("cannot create output canvas");let l,d=3;if(typeof ImageData!="undefined"&&e instanceof ImageData||e.data&&e.width&&e.height)if(xe.browser&&za)l=za?za.fromPixels(e):null;else{d=e.data.length/e.height/e.width;let c=new Uint8Array(e.data.buffer);l=Lt(c,[e.height,e.width,d],"int32")}else if((!Os||Vt.width!==Os.width||(Vt==null?void 0:Vt.height)!==(Os==null?void 0:Os.height))&&(Os=zn(Vt.width,Vt.height)),za&&xe.browser)t.backend==="webgl"||t.backend==="humangl"||t.backend==="webgpu"?l=za.fromPixels(Vt):(Os=rx(Vt),l=za.fromPixels(Os));else{let f=rx(Vt).getContext("2d").getImageData(0,0,s,i);d=f.data.length/s/i;let m=new Uint8Array(f.data.buffer);l=Lt(m,[s,i,d])}if(d===4){let c=fu(l,[0,0,0],[-1,-1,3]);Q(l),l=c}if(!l)throw new Error("cannot create tensor from input");let u=pe(l,"float32"),p=Wt(u,0);return Q([l,u]),{tensor:p,canvas:t.filter.return?Vt:null}}}var sx=0,ix=1,ox=0,Wue=async e=>{let t=48,n=Me.resizeBilinear(e,[Math.trunc((e.shape[1]||1)/t),Math.trunc((e.shape[2]||1)/t)]),a=async()=>{let i=Ie(n),o=await i.data();return Q(i),o[0]},r=async()=>{let i=await n.data(),o=0;for(let l=0;l<i.length/3;l++)o+=i[3*l+2];return o};if(ox===0){let i=Ae();await r();let o=Ae();await a();let l=Ae();ox=o-i<l-o?1:2}let s=ox===1?await r():await a();return Q(n),s};async function s9(e,t){if(e.cacheSensitivity===0)return!1;let n=await Wue(t),a=100*(Math.max(n,sx)/Math.min(n,sx)-1);sx=n;let r=a<Math.max(e.cacheSensitivity,ix);return ix=a>10*e.cacheSensitivity?0:a,r=r&&ix>0,r}var Mf=class{constructor(){ce(this,"browser");ce(this,"node");ce(this,"worker");ce(this,"platform","");ce(this,"agent","");ce(this,"backends",[]);ce(this,"initial");ce(this,"filter");ce(this,"tfjs");ce(this,"offscreen");ce(this,"wasm",{supported:void 0,backend:void 0,simd:void 0,multithread:void 0});ce(this,"webgl",{supported:void 0,backend:void 0,version:void 0,renderer:void 0});ce(this,"webgpu",{supported:void 0,backend:void 0,adapter:void 0});ce(this,"cpu",{model:void 0,flags:[]});ce(this,"kernels",[]);ce(this,"Canvas");ce(this,"Image");ce(this,"ImageData");if(this.browser=typeof navigator!="undefined",this.node=typeof process!="undefined",this.tfjs={version:Ud},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(){var a;this.backends=Object.keys(sa().registryFactory),this.wasm.supported=typeof WebAssembly!="undefined",this.wasm.backend=this.backends.includes("wasm"),this.wasm.supported&&this.wasm.backend&&Ya()==="wasm"&&(this.wasm.simd=await ne().getAsync("WASM_HAS_SIMD_SUPPORT"),this.wasm.multithread=await ne().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&&(Ya()==="webgl"||Ya()==="humangl")){let r=mr().gpgpu!=="undefined"?await mr().getGPGPUContext().gl:null;r&&(this.webgl.version=r.getParameter(r.VERSION),this.webgl.renderer=r.getParameter(r.RENDERER))}this.webgpu.supported=this.browser&&typeof navigator.gpu!="undefined",this.webgpu.backend=this.backends.includes("webgpu"),this.webgpu.supported&&(this.webgpu.adapter=(a=await navigator.gpu.requestAdapter())==null?void 0:a.name),this.kernels=$r(Ya()).map(r=>r.kernelName.toLowerCase())}async updateCPU(){var n;let t={model:"",flags:[]};if(this.node&&((n=this.platform)==null?void 0:n.startsWith("linux"))){let a=rs("fs");try{let r=a.readFileSync("/proc/cpuinfo").toString();for(let s of r.split(`
|
|
`))s.startsWith("model name")&&(t.model=s.match(/:(.*)/g)[0].replace(":","").trim()),s.startsWith("flags")&&(t.flags=s.match(/:(.*)/g)[0].replace(":","").trim().split(" ").sort())}catch(r){}}this.cpu?this.cpu=t:Object.defineProperty(this,"cpu",{value:t})}},xe=new Mf;var lx="2.4.0";var _s;var rpe=Number.MAX_SAFE_INTEGER;async function i9(e){return xe.initial&&(_s=null),_s?e.debug&&ie("cached model:",_s.modelUrl):(_s=await et(tt(e.modelBasePath,e.face.agegenderrace.modelPath)),!_s||!_s.modelUrl?ie("load model failed:",e.face.agegenderrace.modelPath):e.debug&&ie("load model:",_s.modelUrl)),_s}var an,Ff=[],ux=Number.MAX_SAFE_INTEGER,o9=0,l9=0;async function u9(e){var t,n;return xe.initial&&(an=null),an?e.debug&&ie("cached model:",an.modelUrl):(an=await et(tt(e.modelBasePath,((t=e.face.antispoof)==null?void 0:t.modelPath)||"")),!an||!an.modelUrl?ie("load model failed:",(n=e.face.antispoof)==null?void 0:n.modelPath):e.debug&&ie("load model:",an.modelUrl)),an}async function dx(e,t,n,a){var r,s;return an?ux<(((r=t.face.antispoof)==null?void 0:r.skipFrames)||0)&&(((s=t.face.antispoof)==null?void 0:s.skipTime)||0)<=Ae()-l9&&t.skipFrame&&o9===a&&Ff[n]?(ux++,Ff[n]):(ux=0,new Promise(async i=>{let o=Me.resizeBilinear(e,[(an==null?void 0:an.inputs[0].shape)?an.inputs[0].shape[2]:0,(an==null?void 0:an.inputs[0].shape)?an.inputs[0].shape[1]:0],!1),l=an==null?void 0:an.predict(o),d=(await l.data())[0];Ff[n]=Math.round(100*d)/100,o9=a,l9=Ae(),Q([o,l]),i(Ff[n])})):null}var Tr={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]},px={count:468,mouth:13,symmetryLine:[13,Tr.midwayBetweenEyes[0]]},Kp={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]}],Zp=[[.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]],Mo=[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 Vue=[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],Uue=[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],dpe=Vue.map(e=>Zp[e]),ppe=Uue.map(e=>Zp[e]),cpe=jue.map(e=>Zp[e]);var d9=e=>({startPoint:De(e,[0,0],[-1,2]),endPoint:De(e,[0,2],[-1,2])});var Yp=e=>[Math.abs(e.endPoint[0]-e.startPoint[0]),Math.abs(e.endPoint[1]-e.startPoint[1])],Df=e=>[e.startPoint[0]+(e.endPoint[0]-e.startPoint[0])/2,e.startPoint[1]+(e.endPoint[1]-e.startPoint[1])/2],hx=(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],fx=(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],p9=(e,t)=>{let n=[e.startPoint[0]*t[0],e.startPoint[1]*t[1]],a=[e.endPoint[0]*t[0],e.endPoint[1]*t[1]];return{startPoint:n,endPoint:a}},mx=(e,t,n)=>{let a=t.shape[1],r=t.shape[2];return Me.cropAndResize(t,[[e.startPoint[1]/a,e.startPoint[0]/r,e.endPoint[1]/a,e.endPoint[0]/r]],[0],n)},Jp=(e,t=1.5)=>{let n=Df(e),a=Yp(e),r=[t*a[0]/2,t*a[1]/2];return{startPoint:[n[0]-r[0],n[1]-r[1]],endPoint:[n[0]+r[0],n[1]+r[1]],landmarks:e.landmarks}},Qp=e=>{let t=Df(e),n=Yp(e),a=Math.max(...n)/2;return{startPoint:[Math.round(t[0]-a),Math.round(t[1]-a)],endPoint:[Math.round(t[0]+a),Math.round(t[1]+a)],landmarks:e.landmarks}},$f=e=>{let t=e.map(a=>a[0]),n=e.map(a=>a[1]);return{startPoint:[Math.min(...t),Math.min(...n)],endPoint:[Math.max(...t),Math.max(...n)],landmarks:e}},Of=[[1,0,0],[0,1,0],[0,0,1]],Gue=e=>e-2*Math.PI*Math.floor((e+Math.PI)/(2*Math.PI)),Hue=(e,t)=>Gue(Math.PI/2-Math.atan2(-(t[1]-e[1]),t[0]-e[0]));var c9=(e,t)=>[[1,0,e],[0,1,t],[0,0,1]],Fo=(e,t)=>{let n=0;for(let a=0;a<e.length;a++)n+=e[a]*t[a];return n},que=(e,t)=>{let n=[];for(let a=0;a<e.length;a++)n.push(e[a][t]);return n},h9=(e,t)=>{let n=[],a=e.length;for(let r=0;r<a;r++){n.push([]);for(let s=0;s<a;s++)n[r].push(Fo(e[r],que(t,s)))}return n},f9=(e,t)=>{let n=Math.cos(e),a=Math.sin(e),r=[[n,-a,0],[a,n,0],[0,0,1]],s=c9(t[0],t[1]),i=h9(s,r),o=c9(-t[0],-t[1]);return h9(i,o)},Xue=e=>{let t=[[e[0][0],e[1][0]],[e[0][1],e[1][1]]],n=[e[0][2],e[1][2]],a=[-Fo(t[0],n),-Fo(t[1],n)];return[t[0].concat(a[0]),t[1].concat(a[1]),[0,0,1]]},Kue=(e,t)=>[Fo(e,t[0]),Fo(e,t[1])];function m9(e){let t={strides:[e/16,e/8],anchors:[2,6]},n=[];for(let a=0;a<t.strides.length;a++){let r=t.strides[a],s=Math.floor((e+r-1)/r),i=Math.floor((e+r-1)/r),o=t.anchors[a];for(let l=0;l<s;l++){let d=r*(l+.5);for(let u=0;u<i;u++){let p=r*(u+.5);for(let c=0;c<o;c++)n.push([p,d])}}}return n}function g9(e,t,n,a,r){let s=Yp({startPoint:t.startPoint,endPoint:t.endPoint}),i=e.map(p=>[s[0]/r*(p[0]-r/2),s[1]/r*(p[1]-r/2),p[2]||0]),o=n!==0?f9(n,[0,0]):Of,l=n!==0?i.map(p=>[...Kue(p,o),p[2]]):i,d=n!==0?Xue(a):Of,u=[...Df({startPoint:t.startPoint,endPoint:t.endPoint}),1];return l.map(p=>[Math.round(p[0]+Fo(u,d[0])),Math.round(p[1]+Fo(u,d[1])),Math.round(p[2]||0)])}function gx(e,t,n){let a=e.landmarks.length>=px.count?px.symmetryLine:Kp.symmetryLine,r=Hue(e.landmarks[a[0]],e.landmarks[a[1]]),s=Df({startPoint:e.startPoint,endPoint:e.endPoint}),i=[s[0]/t.shape[2],s[1]/t.shape[1]],o=Me.rotateWithOffset(t,r,0,i),l=f9(-r,s),d=mx({startPoint:e.startPoint,endPoint:e.endPoint},o,[n,n]),u=he(d,255);return Q(d),Q(o),[r,l,u]}var y9=6,Ma,yx=[],A9=null,Fa=0,ec=()=>Fa;async function x9(e){var t,n;return xe.initial&&(Ma=null),Ma?e.debug&&ie("cached model:",Ma.modelUrl):(Ma=await et(tt(e.modelBasePath,((t=e.face.detector)==null?void 0:t.modelPath)||"")),!Ma||!Ma.modelUrl?ie("load model failed:",(n=e.face.detector)==null?void 0:n.modelPath):e.debug&&ie("load model:",Ma.modelUrl)),Fa=Ma.inputs[0].shape?Ma.inputs[0].shape[2]:0,Fa===-1&&(Fa=64),yx=m9(Fa),A9=Qa(yx),Ma}function Zue(e){let t=De(e,[0,1],[-1,2]),n=le(t,A9),a=De(e,[0,3],[-1,2]),r=he(a,Fa),s=he(n,Fa),i=he(r,2),o=ge(s,i),l=le(s,i),d=L(o,Fa),u=L(l,Fa);return iu([d,u],1)}async function b9(e,t){var d,u,p,c;if(!e||e.isDisposedInternal||e.shape.length!==4||e.shape[1]<1||e.shape[2]<1)return{boxes:[]};let[n,a,r]=G(()=>{let h=Me.resizeBilinear(e,[Fa,Fa]),f=ge(he(h,127.5),.5),m=Ma==null?void 0:Ma.execute(f),g;if(Array.isArray(m)){let b=m.sort((C,D)=>C.size-D.size),v=mt([b[0],b[2]],2),k=mt([b[1],b[3]],2),T=mt([k,v],1);g=st(T,0)}else g=st(m);let y=Zue(g),A=De(g,[0,0],[-1,1]),x=st(Kn(A));return[g,y,x]}),s=await Me.nonMaxSuppressionAsync(a,r,((d=t.face.detector)==null?void 0:d.maxDetected)||0,((u=t.face.detector)==null?void 0:u.iouThreshold)||0,((p=t.face.detector)==null?void 0:p.minConfidence)||0),i=await s.array();Q(s);let o=[],l=await r.data();for(let h=0;h<i.length;h++){let f=l[i[h]];if(f>(((c=t.face.detector)==null?void 0:c.minConfidence)||0)){let m=De(a,[i[h],0],[1,-1]),g=G(()=>V(st(De(n,[i[h],y9-1],[1,-1])),[y9,-1]));o.push({box:d9(m),landmarks:g,anchor:yx[i[h]],confidence:f}),Q(m)}}return Q(n),Q(a),Q(r),{boxes:o,scaleFactor:[e.shape[2]/Fa,e.shape[1]/Fa]}}var bx={};ud(bx,{connected:()=>xx,kpt:()=>Ax});var Ax=["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"],xx={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 v9={initial:!0},rn=[null,null],Ps=[[0,0],[0,0]],vx=Number.MAX_SAFE_INTEGER,wx,_f=null,zs=[[0,0],[0,0],[0,0],[0,0]],w9=0;async function k9(e){var t,n,a;if(v9.initial&&(rn[0]=null),!rn[0]&&((t=e.body.detector)==null?void 0:t.modelPath)){rn[0]=await et(tt(e.modelBasePath,((n=e.body.detector)==null?void 0:n.modelPath)||""));let r=Object.values(rn[0].modelSignature.inputs);Ps[0][0]=Array.isArray(r)?parseInt(r[0].tensorShape.dim[1].size):0,Ps[0][1]=Array.isArray(r)?parseInt(r[0].tensorShape.dim[2].size):0,!rn[0]||!rn[0].modelUrl?ie("load model failed:",(a=e.body.detector)==null?void 0:a.modelPath):e.debug&&ie("load model:",rn[0].modelUrl)}else e.debug&&rn[0]&&ie("cached model:",rn[0].modelUrl);return rn[0]}async function I9(e){var t;if(v9.initial&&(rn[1]=null),rn[1])e.debug&&ie("cached model:",rn[1].modelUrl);else{rn[1]=await et(tt(e.modelBasePath,e.body.modelPath||""));let n=Object.values(rn[1].modelSignature.inputs);Ps[1][0]=Array.isArray(n)?parseInt(n[0].tensorShape.dim[1].size):0,Ps[1][1]=Array.isArray(n)?parseInt(n[0].tensorShape.dim[2].size):0,((t=e.body.modelPath)==null?void 0:t.includes("lite"))?wx=["ld_3d","output_segmentation","output_heatmap","world_3d","output_poseflag"]:wx=["Identity","Identity_2","Identity_3","Identity_4","Identity_1"],!rn[1]||!rn[1].modelUrl?ie("load model failed:",e.body.modelPath):e.debug&&ie("load model:",rn[1].modelUrl)}return rn[1]}function Yue(e,t){let n=e.map(i=>i.position[0]),a=e.map(i=>i.position[1]),r=[Math.min(...n),Math.min(...a),Math.max(...n)-Math.min(...n),Math.max(...a)-Math.min(...a)],s=[r[0]/t[0],r[1]/t[1],r[2]/t[0],r[3]/t[1]];return{keypointsBox:r,keypointsBoxRaw:s}}async function Jue(e){let t={};if(!e.shape||!e.shape[1]||!e.shape[2])return e;zs=[[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=Sa(e,zs),t.resize=Me.resizeBilinear(t.pad,[Ps[1][0],Ps[1][1]]);let n=he(t.resize,255);return Object.keys(t).forEach(a=>Q(t[a])),n}function Que(e,t){for(let n of e)n.position=[n.position[0]*(t[0]+zs[2][0]+zs[2][1])/t[0]-zs[2][0],n.position[1]*(t[1]+zs[1][0]+zs[1][1])/t[1]-zs[1][0],n.position[2]],n.positionRaw=[n.position[0]/t[0],n.position[1]/t[1],n.position[2]];return e}var S9=e=>1-1/(1+Math.exp(e));async function ede(e,t,n){var h;let a={};a.input=await Jue(e),[a.ld,a.segmentation,a.heatmap,a.world,a.poseflag]=await((h=rn[1])==null?void 0:h.execute(a.input,wx));let r=(await a.poseflag.data())[0],s=Math.max(0,(r-.8)/(1-.8)),i=await a.ld.data(),o=[],l=5;for(let f=0;f<i.length/l;f++){let m=S9(i[l*f+3]),g=S9(i[l*f+4]),y=Math.trunc(100*m*g*s)/100,A=[i[l*f+0]/Ps[1][0],i[l*f+1]/Ps[1][1],i[l*f+2]+0],x=[Math.trunc(n[0]*A[0]),Math.trunc(n[1]*A[1]),A[2]];o.push({part:Ax[f],positionRaw:A,position:x,score:y})}if(s<(t.body.minConfidence||0))return null;let d=Que(o,n),u=Yue(d,[n[0],n[1]]);Object.keys(a).forEach(f=>Q(a[f]));let p={};for(let[f,m]of Object.entries(xx)){let g=[];for(let y=0;y<m.length-1;y++){let A=d.find(b=>b.part===m[y]),x=d.find(b=>b.part===m[y+1]);A&&x&&A.score>(t.body.minConfidence||0)&&x.score>(t.body.minConfidence||0)&&g.push([A.position,x.position])}p[f]=g}return{id:0,score:Math.trunc(100*s)/100,box:u.keypointsBox,boxRaw:u.keypointsBoxRaw,keypoints:d,annotations:p}}async function kx(e,t){let n=[e.shape[2]||0,e.shape[1]||0];return vx<(t.body.skipFrames||0)&&(t.body.skipTime||0)<=Ae()-w9&&t.skipFrame&&_f!==null?vx++:(_f=await ede(e,t,n),w9=Ae(),vx=0),_f?[_f]:[]}var ju=[{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 ja,Do=0,Pf=[],N9=0,Ix=Number.MAX_SAFE_INTEGER;async function T9(e){if(xe.initial&&(ja=null),ja)e.debug&&ie("cached model:",ja.modelUrl);else{Gu(["floormod"],e),ja=await et(tt(e.modelBasePath,e.object.modelPath||""));let t=Object.values(ja.modelSignature.inputs);Do=Array.isArray(t)?parseInt(t[0].tensorShape.dim[2].size):0,!ja||!ja.modelUrl?ie("load model failed:",e.object.modelPath):e.debug&&ie("load model:",ja.modelUrl)}return ja}async function tde(e,t,n){if(!e)return[];let a=[],r=await e.array(),s=st(e);Q(e);let i=cn(s,6,1);Q(s);let o=xn([i[1],i[0],i[3],i[2]],1),l=st(o);Q(o);let d=st(i[4]),u=st(i[5]);i.forEach(f=>Q(f));let p=await Me.nonMaxSuppressionAsync(l,d,n.object.maxDetected,n.object.iouThreshold,n.object.minConfidence);Q(l),Q(d),Q(u);let c=await p.data();Q(p);let h=0;for(let f of c){let m=Math.trunc(100*r[0][f][4])/100,g=r[0][f][5],y=ju[g].label,[A,x]=[r[0][f][0]/Do,r[0][f][1]/Do],b=[A,x,r[0][f][2]/Do-A,r[0][f][3]/Do-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])];a.push({id:h++,score:m,class:g,label:y,box:v,boxRaw:b})}return a}async function Sx(e,t){return Ix<(t.object.skipFrames||0)&&(t.object.skipTime||0)<=Ae()-N9&&t.skipFrame&&Pf.length>0?(Ix++,Pf):(Ix=0,!xe.kernels.includes("mod")||!xe.kernels.includes("sparsetodense")?Pf:new Promise(async n=>{let a=[e.shape[2],e.shape[1]],r=Me.resizeBilinear(e,[Do,Do]),s=t.object.enabled?ja==null?void 0:ja.execute(r,["tower_0/detections"]):null;N9=Ae(),Q(r);let i=await tde(s,a,t);Pf=i,n(i)}))}var Cx={};ud(Cx,{connected:()=>Tx,kpt:()=>Nx});var Nx=["head","neck","rightShoulder","rightElbow","rightWrist","chest","leftShoulder","leftElbow","leftWrist","bodyCenter","rightHip","rightKnee","rightAnkle","leftHip","leftKnee","leftAnkle"],Tx={leftLeg:["leftHip","leftKnee","leftAnkle"],rightLeg:["rightHip","rightKnee","rightAnkle"],torso:["leftShoulder","rightShoulder","rightHip","leftHip","leftShoulder"],leftArm:["leftShoulder","leftElbow","leftWrist"],rightArm:["rightShoulder","rightElbow","rightWrist"],head:[]};var sn,C9=0,Ln={id:0,keypoints:[],box:[0,0,0,0],boxRaw:[0,0,0,0],score:0,annotations:{}},Ex=Number.MAX_SAFE_INTEGER;async function Rx(e){return xe.initial&&(sn=null),sn?e.debug&&ie("cached model:",sn.modelUrl):(sn=await et(tt(e.modelBasePath,e.body.modelPath||"")),!sn||!sn.modelUrl?ie("load model failed:",e.body.modelPath):e.debug&&ie("load model:",sn.modelUrl)),sn}function nde(e,t){let[n,a]=e.shape;return G(()=>{let r=(o,l)=>ge(o,L(he(o,Ce(l,"int32")),Ce(l,"int32"))),s=V(e,[a*n]),i=Rn(s,0).dataSync()[0];if(i>t){let o=ka(s,0),l=r(o,n).dataSync()[0],d=he(o,Ce(n,"int32")).dataSync()[0];return[l,d,i]}return[0,0,i]})}async function Mx(e,t){var n;return Ex<(((n=t.body)==null?void 0:n.skipFrames)||0)&&t.skipFrame&&Object.keys(Ln.keypoints).length>0&&(t.body.skipTime||0)<=Ae()-C9?(Ex++,[Ln]):(Ex=0,new Promise(async a=>{var u;let r=G(()=>{if(!(sn==null?void 0:sn.inputs[0].shape))return null;let p=Me.resizeBilinear(e,[sn.inputs[0].shape[2],sn.inputs[0].shape[1]],!1);return L(p,2).sub(1)}),s;if(t.body.enabled&&(s=await(sn==null?void 0:sn.predict(r))),C9=Ae(),Q(r),s){Ln.keypoints.length=0;let p=s.squeeze();Q(s);let c=p.unstack(2);Q(p);for(let h=0;h<c.length;h++){let[f,m,g]=nde(c[h],t.body.minConfidence);g>(((u=t.body)==null?void 0:u.minConfidence)||0)&&Ln.keypoints.push({score:Math.round(100*g)/100,part:Nx[h],positionRaw:[f/sn.inputs[0].shape[2],m/sn.inputs[0].shape[1]],position:[Math.round(e.shape[2]*f/sn.inputs[0].shape[2]),Math.round(e.shape[1]*m/sn.inputs[0].shape[1])]})}c.forEach(h=>Q(h))}Ln.score=Ln.keypoints.reduce((p,c)=>c.score>p?c.score:p,0);let i=Ln.keypoints.map(p=>p.position[0]),o=Ln.keypoints.map(p=>p.position[1]);Ln.box=[Math.min(...i),Math.min(...o),Math.max(...i)-Math.min(...i),Math.max(...o)-Math.min(...o)];let l=Ln.keypoints.map(p=>p.positionRaw[0]),d=Ln.keypoints.map(p=>p.positionRaw[1]);Ln.boxRaw=[Math.min(...l),Math.min(...d),Math.max(...l)-Math.min(...l),Math.max(...d)-Math.min(...d)];for(let[p,c]of Object.entries(Tx)){let h=[];for(let f=0;f<c.length-1;f++){let m=Ln.keypoints.find(y=>y.part===c[f]),g=Ln.keypoints.find(y=>y.part===c[f+1]);m&&g&&m.score>(t.body.minConfidence||0)&&g.score>(t.body.minConfidence||0)&&h.push([m.position,g.position])}Ln.annotations[p]=h}a([Ln])}))}var ade=["angry","disgust","fear","happy","sad","surprise","neutral"],on,zf=[],E9=0,R9=0,Fx=Number.MAX_SAFE_INTEGER,Dx=[.2989,.587,.114];async function M9(e){var t,n;return xe.initial&&(on=null),on?e.debug&&ie("cached model:",on.modelUrl):(on=await et(tt(e.modelBasePath,((t=e.face.emotion)==null?void 0:t.modelPath)||"")),!on||!on.modelUrl?ie("load model failed:",(n=e.face.emotion)==null?void 0:n.modelPath):e.debug&&ie("load model:",on.modelUrl)),on}async function $x(e,t,n,a){var r,s;return on?Fx<(((r=t.face.emotion)==null?void 0:r.skipFrames)||0)&&(((s=t.face.emotion)==null?void 0:s.skipTime)||0)<=Ae()-R9&&t.skipFrame&&E9===a&&zf[n]&&zf[n].length>0?(Fx++,zf[n]):(Fx=0,new Promise(async i=>{var l,d;let o=[];if((l=t.face.emotion)==null?void 0:l.enabled){let u=Me.resizeBilinear(e,[(on==null?void 0:on.inputs[0].shape)?on.inputs[0].shape[2]:0,(on==null?void 0:on.inputs[0].shape)?on.inputs[0].shape[1]:0],!1),[p,c,h]=cn(u,3,3);Q(u);let f=L(p,Dx[0]),m=L(c,Dx[1]),g=L(h,Dx[2]);Q(p),Q(c),Q(h);let y=_h([f,m,g]);Q(f),Q(m),Q(g);let A=G(()=>L(ge(y,.5),2));Q(y);let x=await(on==null?void 0:on.predict(A));R9=Ae();let b=await x.data();Q(x);for(let v=0;v<b.length;v++)b[v]>(((d=t.face.emotion)==null?void 0:d.minConfidence)||0)&&o.push({score:Math.min(.99,Math.trunc(100*b[v])/100),emotion:ade[v]});o.sort((v,k)=>k.score-v.score),Q(A)}zf[n]=o,E9=a,i(o)})):null}var Ga,Ls=0,rde=2.3,Ox=Tr.leftEyeLower0,_x=Tr.rightEyeLower0,Hu={leftBounds:[Ox[0],Ox[Ox.length-1]],rightBounds:[_x[0],_x[_x.length-1]]},qu={upperCenter:3,lowerCenter:4,index:71,numCoordinates:76};async function F9(e){var t,n;return xe.initial&&(Ga=null),Ga?e.debug&&ie("cached model:",Ga.modelUrl):(Ga=await et(tt(e.modelBasePath,((t=e.face.iris)==null?void 0:t.modelPath)||"")),!Ga||!Ga.modelUrl?ie("load model failed:",(n=e.face.iris)==null?void 0:n.modelPath):e.debug&&ie("load model:",Ga.modelUrl)),Ls=Ga.inputs[0].shape?Ga.inputs[0].shape[2]:0,Ls===-1&&(Ls=64),Ga}function Lf(e,t,n,a){for(let r=0;r<cx.length;r++){let{key:s,indices:i}=cx[r],o=Tr[`${n}${s}`];if(!a||a.includes(s))for(let l=0;l<i.length;l++){let d=i[l];e[o[l]]=[t[d][0],t[d][1],(t[d][2]+e[o[l]][2])/2]}}}var sde=e=>{let t=e[Hu.leftBounds[0]][2],n=e[Hu.rightBounds[0]][2];return t-n},D9=(e,t,n,a,r=!1,s)=>{let i=Qp(Jp($f([e[n],e[a]]),rde)),o=Yp(i),l=Me.cropAndResize(t,[[i.startPoint[1]/s,i.startPoint[0]/s,i.endPoint[1]/s,i.endPoint[0]/s]],[0],[Ls,Ls]);if(r&&xe.kernels.includes("flipleftright")){let d=Me.flipLeftRight(l);Q(l),l=d}return{box:i,boxSize:o,crop:l}},$9=(e,t,n,a=!1)=>{let r=[];for(let s=0;s<qu.numCoordinates;s++){let i=e[s*3],o=e[s*3+1],l=e[s*3+2];r.push([(a?1-i/Ls:i/Ls)*n[0]+t.startPoint[0],o/Ls*n[1]+t.startPoint[1],l])}return{rawCoords:r,iris:r.slice(qu.index)}},O9=(e,t,n)=>{let a=e[Tr[`${n}EyeUpper0`][qu.upperCenter]][2],r=e[Tr[`${n}EyeLower0`][qu.lowerCenter]][2],s=(a+r)/2;return t.map((i,o)=>{let l=s;return o===2?l=a:o===4&&(l=r),[i[0],i[1],l]})};async function _9(e,t,n,a){if(!Ga)return n.debug&&ie("face mesh iris detection requested, but model is not loaded"),e;let{box:r,boxSize:s,crop:i}=D9(e,t,Hu.leftBounds[0],Hu.leftBounds[1],!0,a),{box:o,boxSize:l,crop:d}=D9(e,t,Hu.rightBounds[0],Hu.rightBounds[1],!0,a),u=mt([i,d]);Q(i),Q(d);let p=Ga.predict(u);Q(u);let c=await p.data();Q(p);let h=c.slice(0,qu.numCoordinates*3),{rawCoords:f,iris:m}=$9(h,r,s,!0),g=c.slice(qu.numCoordinates*3),{rawCoords:y,iris:A}=$9(g,o,l),x=sde(e);Math.abs(x)<30?(Lf(e,f,"left",null),Lf(e,y,"right",null)):x<1?Lf(e,f,"left",["EyeUpper0","EyeLower0"]):Lf(e,y,"right",["EyeUpper0","EyeLower0"]);let b=O9(e,m,"left"),v=O9(e,A,"right");return e.concat(b).concat(v)}var Cr=[],Ha=null,ur=0,Px=Number.MAX_SAFE_INTEGER,P9=0,z9=0;async function L9(e,t){var s,i,o,l,d,u,p,c,h,f,m,g,y;if(!t.skipFrame||(z9!==((s=t.face.detector)==null?void 0:s.maxDetected)||!((i=t.face.mesh)==null?void 0:i.enabled))&&Px>(((o=t.face.detector)==null?void 0:o.skipFrames)||0)&&(((l=t.face.description)==null?void 0:l.skipTime)||0)<=Ae()-P9){let A=await b9(e,t);P9=Ae(),Cr=[];for(let x of A.boxes){let b=await x.box.startPoint.data(),v=await x.box.endPoint.data(),k=await x.landmarks.array();Cr.push({startPoint:b,endPoint:v,landmarks:k,confidence:x.confidence})}A.boxes.forEach(x=>Q([x.box.startPoint,x.box.endPoint,x.landmarks]));for(let x=0;x<Cr.length;x++){let b=p9({startPoint:Cr[x].startPoint,endPoint:Cr[x].endPoint},A.scaleFactor),v=Jp(b),k=Qp(v);Cr[x]={...k,confidence:Cr[x].confidence,landmarks:Cr[x].landmarks}}Px=0}else Px++;let n=[],a=[],r=0;for(let A of Cr){let x=0,b,v={id:r++,mesh:[],meshRaw:[],box:[0,0,0,0],boxRaw:[0,0,0,0],score:0,boxScore:0,faceScore:0,annotations:{}};if(((d=t.face.detector)==null?void 0:d.rotation)&&((u=t.face.mesh)==null?void 0:u.enabled)&&xe.kernels.includes("rotatewithoffset"))[x,b,v.tensor]=gx(A,e,ur);else{b=Of;let k=mx({startPoint:A.startPoint,endPoint:A.endPoint},e,((p=t.face.mesh)==null?void 0:p.enabled)?[ur,ur]:[ec(),ec()]);v.tensor=he(k,255),Q(k)}if(v.boxScore=Math.round(100*A.confidence)/100,(c=t.face.mesh)==null?void 0:c.enabled)if(!Ha)t.debug&&ie("face mesh detection requested, but model is not loaded");else{let[k,T,C]=Ha.execute(v.tensor);Q(k);let D=(await T.data())[0];Q(T);let O=V(C,[-1,3]),F=await O.array();if(Q(C),Q(O),D<(((h=t.face.detector)==null?void 0:h.minConfidence)||1))A.confidence=D;else{((f=t.face.iris)==null?void 0:f.enabled)&&(F=await _9(F,v.tensor,t,ur)),v.mesh=g9(F,A,x,b,ur),v.meshRaw=v.mesh.map(S=>[S[0]/(e.shape[2]||0),S[1]/(e.shape[1]||0),(S[2]||0)/ur]),A={...Jp($f(v.mesh),1.5),confidence:A.confidence};for(let S of Object.keys(Tr))v.annotations[S]=Tr[S].map(P=>v.mesh[P]);((m=t.face.detector)==null?void 0:m.rotation)&&t.face.mesh.enabled&&((g=t.face.description)==null?void 0:g.enabled)&&xe.kernels.includes("rotatewithoffset")&&(Q(v.tensor),[x,b,v.tensor]=gx(A,e,ur)),v.box=hx(A,e),v.boxRaw=fx(A,e),v.score=Math.round(100*D||100*A.confidence||0)/100,v.faceScore=Math.round(100*D)/100,A={...Qp(A),confidence:A.confidence,faceConfidence:D}}}else{v.box=hx(A,e),v.boxRaw=fx(A,e),v.score=Math.round(100*A.confidence||0)/100,v.mesh=A.landmarks.map(k=>[(A.startPoint[0]+A.endPoint[0])/2+(A.endPoint[0]+A.startPoint[0])*k[0]/ec(),(A.startPoint[1]+A.endPoint[1])/2+(A.endPoint[1]+A.startPoint[1])*k[1]/ec()]),v.meshRaw=v.mesh.map(k=>[k[0]/(e.shape[2]||0),k[1]/(e.shape[1]||0),(k[2]||0)/ur]);for(let k of Object.keys(Kp))v.annotations[k]=[v.mesh[Kp[k]]]}n.push(v),a.push(A)}return((y=t.face.mesh)==null?void 0:y.enabled)&&(Cr=a.filter(A=>{var x;return A.confidence>(((x=t.face.detector)==null?void 0:x.minConfidence)||0)})),z9=n.length,n}async function W9(e){var t,n;return xe.initial&&(Ha=null),Ha?e.debug&&ie("cached model:",Ha.modelUrl):(Ha=await et(tt(e.modelBasePath,((t=e.face.mesh)==null?void 0:t.modelPath)||"")),!Ha||!Ha.modelUrl?ie("load model failed:",(n=e.face.mesh)==null?void 0:n.modelPath):e.debug&&ie("load model:",Ha.modelUrl)),ur=Ha.inputs[0].shape?Ha.inputs[0].shape[2]:0,ur===-1&&(ur=64),Ha}var B9=Mo,V9=Zp;var Wn,Wf=[],U9=0,j9=0,zx=Number.MAX_SAFE_INTEGER;async function G9(e){var n,a;let t=tt(e.modelBasePath,((n=e.face.description)==null?void 0:n.modelPath)||"");return xe.initial&&(Wn=null),Wn?e.debug&&ie("cached model:",t):(Wn=await et(t),Wn?e.debug&&ie("load model:",t):ie("load model failed:",((a=e.face.description)==null?void 0:a.modelPath)||"")),Wn}function Lx(e){return G(()=>{let n=e.image||e.tensor||e;if(!(n instanceof je))return null;let a=[[.05,.15,.85,.85]];if(!(Wn==null?void 0:Wn.inputs[0].shape))return null;let r=n.shape.length===3?Me.cropAndResize(Wt(n,0),a,[0],[Wn.inputs[0].shape[2],Wn.inputs[0].shape[1]]):Me.cropAndResize(n,a,[0],[Wn.inputs[0].shape[2],Wn.inputs[0].shape[1]]);return L(r,255)})}async function Wx(e,t,n,a){var r,s,i,o;return Wn?zx<(((r=t.face.description)==null?void 0:r.skipFrames)||0)&&(((s=t.face.description)==null?void 0:s.skipTime)||0)<=Ae()-U9&&t.skipFrame&&j9===a&&((i=Wf[n])==null?void 0:i.age)&&((o=Wf[n])==null?void 0:o.age)>0?(zx++,Wf[n]):(zx=0,new Promise(async l=>{var u,p;let d={age:0,gender:"unknown",genderScore:0,descriptor:[]};if((u=t.face.description)==null?void 0:u.enabled){let c=Lx(e),h=await(Wn==null?void 0:Wn.predict(c));U9=Ae(),Q(c);let m=await(await h.find(T=>T.shape[1]===1)).data(),g=Math.trunc(200*Math.abs(m[0]-.5))/100;g>(((p=t.face.description)==null?void 0:p.minConfidence)||0)&&(d.gender=m[0]<=.5?"female":"male",d.genderScore=Math.min(.99,g));let y=ka(h.find(T=>T.shape[1]===100),1),A=(await y.data())[0];Q(y);let b=await h.find(T=>T.shape[1]===100).data();d.age=Math.round(b[A-1]>b[A+1]?10*A-100*b[A-1]:10*A+100*b[A+1])/10;let v=h.find(T=>T.shape[1]===1024),k=v?await v.data():[];d.descriptor=Array.from(k),h.forEach(T=>Q(T))}Wf[n]=d,j9=a,l(d)})):null}function Bf(e){return[Math.abs(e.endPoint[0]-e.startPoint[0]),Math.abs(e.endPoint[1]-e.startPoint[1])]}function tc(e){return[e.startPoint[0]+(e.endPoint[0]-e.startPoint[0])/2,e.startPoint[1]+(e.endPoint[1]-e.startPoint[1])/2]}function H9(e,t,n){let a=t.shape[1],r=t.shape[2],s=[[e.startPoint[1]/a,e.startPoint[0]/r,e.endPoint[1]/a,e.endPoint[0]/r]];return Me.cropAndResize(t,s,[0],n)}function q9(e,t){let n=[e.startPoint[0]*t[0],e.startPoint[1]*t[1]],a=[e.endPoint[0]*t[0],e.endPoint[1]*t[1]],r=e.palmLandmarks.map(s=>[s[0]*t[0],s[1]*t[1]]);return{startPoint:n,endPoint:a,palmLandmarks:r,confidence:e.confidence}}function Vf(e,t=1.5){let n=tc(e),a=Bf(e),r=[t*a[0]/2,t*a[1]/2],s=[n[0]-r[0],n[1]-r[1]],i=[n[0]+r[0],n[1]+r[1]];return{startPoint:s,endPoint:i,palmLandmarks:e.palmLandmarks}}function Uf(e){let t=tc(e),n=Bf(e),r=Math.max(...n)/2,s=[t[0]-r,t[1]-r],i=[t[0]+r,t[1]+r];return{startPoint:s,endPoint:i,palmLandmarks:e.palmLandmarks}}function ide(e){return e-2*Math.PI*Math.floor((e+Math.PI)/(2*Math.PI))}function X9(e,t){let n=Math.PI/2-Math.atan2(-(t[1]-e[1]),t[0]-e[0]);return ide(n)}var K9=(e,t)=>[[1,0,e],[0,1,t],[0,0,1]];function Ws(e,t){let n=0;for(let a=0;a<e.length;a++)n+=e[a]*t[a];return n}function ode(e,t){let n=[];for(let a=0;a<e.length;a++)n.push(e[a][t]);return n}function Z9(e,t){let n=[],a=e.length;for(let r=0;r<a;r++){n.push([]);for(let s=0;s<a;s++)n[r].push(Ws(e[r],ode(t,s)))}return n}function Bx(e,t){let n=Math.cos(e),a=Math.sin(e),r=[[n,-a,0],[a,n,0],[0,0,1]],s=K9(t[0],t[1]),i=Z9(s,r),o=K9(-t[0],-t[1]);return Z9(i,o)}function Y9(e){let t=[[e[0][0],e[1][0]],[e[0][1],e[1][1]]],n=[e[0][2],e[1][2]],a=[-Ws(t[0],n),-Ws(t[1],n)];return[t[0].concat(a[0]),t[1].concat(a[1]),[0,0,1]]}function Vx(e,t){return[Ws(e,t[0]),Ws(e,t[1])]}var J9=[{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 Ux=class{constructor(t){ce(this,"model");ce(this,"anchors");ce(this,"anchorsTensor");ce(this,"inputSize");ce(this,"inputSizeTensor");ce(this,"doubleInputSizeTensor");this.model=t,this.anchors=J9.map(n=>[n.x,n.y]),this.anchorsTensor=Qa(this.anchors),this.inputSize=this.model&&this.model.inputs&&this.model.inputs[0].shape?this.model.inputs[0].shape[2]:0,this.inputSizeTensor=Ht([this.inputSize,this.inputSize]),this.doubleInputSizeTensor=Ht([this.inputSize*2,this.inputSize*2])}normalizeBoxes(t){return G(()=>{let n=De(t,[0,0],[-1,2]),a=De(t,[0,2],[-1,2]),r=le(he(n,this.inputSizeTensor),this.anchorsTensor),s=he(a,this.doubleInputSizeTensor),i=L(ge(r,s),this.inputSizeTensor),o=L(le(r,s),this.inputSizeTensor);return iu([i,o],1)})}normalizeLandmarks(t,n){return G(()=>{let a=le(he(V(t,[-1,7,2]),this.inputSizeTensor),this.anchors[n]);return L(a,this.inputSizeTensor)})}async getBoxes(t,n){let a={};a.batched=this.model.predict(t),a.predictions=st(a.batched),a.scores=G(()=>st(Kn(De(a.predictions,[0,0],[-1,1]))));let r=await a.scores.data();a.boxes=De(a.predictions,[0,1],[-1,4]),a.norm=this.normalizeBoxes(a.boxes),a.nms=await Me.nonMaxSuppressionAsync(a.norm,a.scores,3*n.hand.maxDetected,n.hand.iouThreshold,n.hand.minConfidence);let s=await a.nms.array(),i=[];for(let o of s){let l=De(a.norm,[o,0],[1,-1]),d=G(()=>V(this.normalizeLandmarks(De(a.predictions,[o,5],[1,14]),o),[-1,2]));i.push({box:l,palmLandmarks:d,confidence:r[o]})}for(let o of Object.keys(a))Q(a[o]);return i}async estimateHandBounds(t,n){let a=t.shape[1],r=t.shape[2],s=G(()=>ge(he(Me.resizeBilinear(t,[this.inputSize,this.inputSize]),127.5),1)),i=await this.getBoxes(s,n);Q(s);let o=[];if(!i||i.length===0)return o;for(let l of i){let d=await l.box.data(),u=d.slice(0,2),p=d.slice(2,4),c=await l.palmLandmarks.array();Q(l.box),Q(l.palmLandmarks),o.push(q9({startPoint:u,endPoint:p,palmLandmarks:c,confidence:l.confidence},[r/this.inputSize,a/this.inputSize]))}return o}};var lde=5,Q9=1.65,eI=[0,5,9,13,17,1,2],ude=0,dde=2,tI=0,jx=class{constructor(t,n){ce(this,"handDetector");ce(this,"handPoseModel");ce(this,"inputSize");ce(this,"storedBoxes");ce(this,"skipped");ce(this,"detectedHands");this.handDetector=t,this.handPoseModel=n,this.inputSize=this.handPoseModel&&this.handPoseModel.inputs[0].shape?this.handPoseModel.inputs[0].shape[2]:0,this.storedBoxes=[],this.skipped=0,this.detectedHands=0}calculateLandmarksBoundingBox(t){let n=t.map(i=>i[0]),a=t.map(i=>i[1]),r=[Math.min(...n),Math.min(...a)],s=[Math.max(...n),Math.max(...a)];return{startPoint:r,endPoint:s}}getBoxForPalmLandmarks(t,n){let a=t.map(s=>Vx([...s,1],n)),r=this.calculateLandmarksBoundingBox(a);return Vf(Uf(r),lde)}getBoxForHandLandmarks(t){let n=this.calculateLandmarksBoundingBox(t),a=Vf(Uf(n),Q9);a.palmLandmarks=[];for(let r=0;r<eI.length;r++)a.palmLandmarks.push(t[eI[r]].slice(0,2));return a}transformRawCoords(t,n,a,r){let s=Bf(n),i=[s[0]/this.inputSize,s[1]/this.inputSize,(s[0]+s[1])/this.inputSize/2],o=t.map(h=>[i[0]*(h[0]-this.inputSize/2),i[1]*(h[1]-this.inputSize/2),i[2]*h[2]]),l=Bx(a,[0,0]),d=o.map(h=>[...Vx(h,l),h[2]]),u=Y9(r),p=[...tc(n),1],c=[Ws(p,u[0]),Ws(p,u[1])];return d.map(h=>[Math.trunc(h[0]+c[0]),Math.trunc(h[1]+c[1]),Math.trunc(h[2])])}async estimateHands(t,n){let a=!1,r;(this.skipped===0||this.skipped>n.hand.skipFrames&&(n.hand.skipTime||0)<=Ae()-tI||!n.hand.landmarks||!n.skipFrame)&&(r=await this.handDetector.estimateHandBounds(t,n),this.skipped=0),n.skipFrame&&this.skipped++,r&&r.length>0&&(r.length!==this.detectedHands&&this.detectedHands!==n.hand.maxDetected||!n.hand.landmarks)&&(this.detectedHands=0,this.storedBoxes=[...r],this.storedBoxes.length>0&&(a=!0));let s=[];for(let i=0;i<this.storedBoxes.length;i++){let o=this.storedBoxes[i];if(!!o)if(n.hand.landmarks){let l=n.hand.rotation?X9(o.palmLandmarks[ude],o.palmLandmarks[dde]):0,d=tc(o),u=[d[0]/t.shape[2],d[1]/t.shape[1]],p=n.hand.rotation&&xe.kernels.includes("rotatewithoffset")?Me.rotateWithOffset(t,l,0,u):t.clone(),c=Bx(-l,d),h=a?this.getBoxForPalmLandmarks(o.palmLandmarks,c):o,f=H9(h,p,[this.inputSize,this.inputSize]),m=he(f,255);Q(f),Q(p);let[g,y]=await this.handPoseModel.predict(m);tI=Ae(),Q(m);let A=(await g.data())[0];if(Q(g),A>=n.hand.minConfidence/4){let x=V(y,[-1,3]),b=await x.array();Q(y),Q(x);let v=this.transformRawCoords(b,h,l,c),k=this.getBoxForHandLandmarks(v);this.storedBoxes[i]={...k,confidence:A};let T={landmarks:v,confidence:A,boxConfidence:o.confidence,fingerConfidence:A,box:{topLeft:k.startPoint,bottomRight:k.endPoint}};s.push(T)}else this.storedBoxes[i]=null;Q(y)}else{let l=Vf(Uf(o),Q9),d={confidence:o.confidence,boxConfidence:o.confidence,fingerConfidence:0,box:{topLeft:l.startPoint,bottomRight:l.endPoint},landmarks:[]};s.push(d)}}return this.storedBoxes=this.storedBoxes.filter(i=>i!==null),this.detectedHands=s.length,s.length>n.hand.maxDetected&&(s.length=n.hand.maxDetected),s}};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]},na={none:0,half:1,full:2,nameMapping:{0:"none",1:"half",2:"full"},getName:e=>na.nameMapping[e]},He={verticalUp:0,verticalDown:1,horizontalLeft:2,horizontalRight:3,diagonalUpRight:4,diagonalUpLeft:5,diagonalDownRight:6,diagonalDownLeft:7,nameMapping:{0:"verticalUp",1:"verticalDown",2:"horizontalLeft",3:"horizontalRight",4:"diagonalUpRight",5:"diagonalUpLeft",6:"diagonalDownRight",7:"diagonalDownLeft"},getName:e=>He.nameMapping[e]},jf=class{constructor(t){ce(this,"name");ce(this,"curls");ce(this,"directions");ce(this,"weights");ce(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,a){typeof this.curls[t]=="undefined"&&(this.curls[t]=[]),this.curls[t].push([n,a])}addDirection(t,n,a){this.directions[t]||(this.directions[t]=[]),this.directions[t].push([n,a])}setWeight(t,n){this.weights[t]=n;let a=this.weights.reduce((r,s)=>r+s,0);this.weightsRelative=this.weights.map(r=>r*5/a)}matchAgainst(t,n){let a=0;for(let r in t){let s=t[r],i=this.curls[r];if(typeof i=="undefined"){a+=this.weightsRelative[r];continue}for(let[o,l]of i)if(s===o){a+=l*this.weightsRelative[r];break}}for(let r in n){let s=n[r],i=this.directions[r];if(typeof i=="undefined"){a+=this.weightsRelative[r];continue}for(let[o,l]of i)if(s===o){a+=l*this.weightsRelative[r];break}}return a/10}};var Bs=new jf("thumbs up");Bs.addCurl(qe.thumb,na.none,1);Bs.addDirection(qe.thumb,He.verticalUp,1);Bs.addDirection(qe.thumb,He.diagonalUpLeft,.25);Bs.addDirection(qe.thumb,He.diagonalUpRight,.25);for(let e of[qe.index,qe.middle,qe.ring,qe.pinky])Bs.addCurl(e,na.full,1),Bs.addDirection(e,He.horizontalLeft,1),Bs.addDirection(e,He.horizontalRight,1);var Zt=new jf("victory");Zt.addCurl(qe.thumb,na.half,.5);Zt.addCurl(qe.thumb,na.none,.5);Zt.addDirection(qe.thumb,He.verticalUp,1);Zt.addDirection(qe.thumb,He.diagonalUpLeft,1);Zt.addCurl(qe.index,na.none,1);Zt.addDirection(qe.index,He.verticalUp,.75);Zt.addDirection(qe.index,He.diagonalUpLeft,1);Zt.addCurl(qe.middle,na.none,1);Zt.addDirection(qe.middle,He.verticalUp,1);Zt.addDirection(qe.middle,He.diagonalUpLeft,.75);Zt.addCurl(qe.ring,na.full,1);Zt.addDirection(qe.ring,He.verticalUp,.2);Zt.addDirection(qe.ring,He.diagonalUpLeft,1);Zt.addDirection(qe.ring,He.horizontalLeft,.2);Zt.addCurl(qe.pinky,na.full,1);Zt.addDirection(qe.pinky,He.verticalUp,.2);Zt.addDirection(qe.pinky,He.diagonalUpLeft,1);Zt.addDirection(qe.pinky,He.horizontalLeft,.2);Zt.setWeight(qe.index,2);Zt.setWeight(qe.middle,2);var nI=[Bs,Zt];var pde=.7,$o={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 aI(e,t,n,a){let r=(t-a)/(e-n),s=Math.atan(r)*180/Math.PI;return s<=0?s=-s:s>0&&(s=180-s),s}function rI(e,t){if(!e||!t)return[0,0];let n=aI(e[0],e[1],t[0],t[1]);if(e.length===2)return n;let a=aI(e[1],e[2],t[1],t[2]);return[n,a]}function sI(e,t=1){let n=0,a=0,r=0;return e>=75&&e<=105?n=1*t:e>=25&&e<=155?a=1*t:r=1*t,[n,a,r]}function cde(e,t,n){let a=e[0]-t[0],r=e[0]-n[0],s=t[0]-n[0],i=e[1]-t[1],o=e[1]-n[1],l=t[1]-n[1],d=e[2]-t[2],u=e[2]-n[2],p=t[2]-n[2],c=Math.sqrt(a*a+i*i+d*d),h=Math.sqrt(r*r+o*o+u*u),f=Math.sqrt(s*s+l*l+p*p),m=(f*f+c*c-h*h)/(2*f*c);m>1?m=1:m<-1&&(m=-1);let g=Math.acos(m);g=57.2958*g%180;let y;return g>$o.NO_CURL_START_LIMIT?y=na.none:g>$o.HALF_CURL_START_LIMIT?y=na.half:y=na.full,y}function iI(e,t,n,a){let r;return a===Math.abs(e)?e>0?r=He.horizontalLeft:r=He.horizontalRight:a===Math.abs(t)?t>0?r=He.horizontalLeft:r=He.horizontalRight:n>0?r=He.horizontalLeft:r=He.horizontalRight,r}function oI(e,t,n,a){let r;return a===Math.abs(e)?e<0?r=He.verticalDown:r=He.verticalUp:a===Math.abs(t)?t<0?r=He.verticalDown:r=He.verticalUp:n<0?r=He.verticalDown:r=He.verticalUp,r}function hde(e,t,n,a,r,s,i,o){let l,d=oI(e,t,n,a),u=iI(r,s,i,o);return d===He.verticalUp?u===He.horizontalLeft?l=He.diagonalUpLeft:l=He.diagonalUpRight:u===He.horizontalLeft?l=He.diagonalDownLeft:l=He.diagonalDownRight,l}function fde(e,t,n,a){let r=e[0]-t[0],s=e[0]-n[0],i=t[0]-n[0],o=e[1]-t[1],l=e[1]-n[1],d=t[1]-n[1],u=Math.max(Math.abs(r),Math.abs(s),Math.abs(i)),p=Math.max(Math.abs(o),Math.abs(l),Math.abs(d)),c=0,h=0,f=0,m=p/(u+1e-5);m>1.5?c+=$o.DISTANCE_VOTE_POWER:m>.66?h+=$o.DISTANCE_VOTE_POWER:f+=$o.DISTANCE_VOTE_POWER;let g=Math.sqrt(r*r+o*o),y=Math.sqrt(s*s+l*l),A=Math.sqrt(i*i+d*d),x=Math.max(g,y,A),b=e[0],v=e[1],k=n[0],T=n[1];x===g?(k=n[0],T=n[1]):x===A&&(b=t[0],v=t[1]);let O=rI([b,v],[k,T]),F=sI(O,$o.TOTAL_ANGLE_VOTE_POWER);c+=F[0],h+=F[1],f+=F[2];for(let P of a){let _=sI(P,$o.SINGLE_ANGLE_VOTE_POWER);c+=_[0],h+=_[1],f+=_[2]}let S;return c===Math.max(c,h,f)?S=oI(l,o,d,p):f===Math.max(h,f)?S=iI(s,r,i,u):S=hde(l,o,d,p,s,r,i,u),S}function lI(e){let t=[],n=[],a=[],r=[];if(!e)return{curls:a,directions:r};for(let s of qe.all){let i=qe.getPoints(s),o=[],l=[];for(let d of i){let u=e[d[0]],p=e[d[1]],c=rI(u,p),h=c[0],f=c[1];o.push(h),l.push(f)}t.push(o),n.push(l)}for(let s of qe.all){let i=s===qe.thumb?1:0,o=qe.getPoints(s),l=e[o[i][0]],d=e[o[i+1][1]],u=e[o[3][1]],p=cde(l,d,u),c=fde(l,d,u,t[s].slice(i));a[s]=p,r[s]=c}return{curls:a,directions:r}}function Gf(e){if(!e||e.length===0)return null;let t=lI(e),n={};for(let a of qe.all)n[qe.getName(a)]={curl:na.getName(t.curls[a]),direction:He.getName(t.directions[a])};return n}function uI(e){let t=[];if(!e||e.length===0)return t;let n=lI(e);for(let a of nI){let r=a.matchAgainst(n.curls,n.directions);r>=pde&&t.push({name:a.name,confidence:r})}return t}var dI={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]},Hr,qr,pI;async function Gx(e,t){let n=await pI.estimateHands(e,t);if(!n)return[];let a=[];for(let r=0;r<n.length;r++){let s={};if(n[r].landmarks)for(let u of Object.keys(dI))s[u]=dI[u].map(p=>n[r].landmarks[p]);let i=n[r].landmarks,o=[Number.MAX_SAFE_INTEGER,Number.MAX_SAFE_INTEGER,0,0],l=[0,0,0,0];if(i&&i.length>0){for(let u of i)u[0]<o[0]&&(o[0]=u[0]),u[1]<o[1]&&(o[1]=u[1]),u[0]>o[2]&&(o[2]=u[0]),u[1]>o[3]&&(o[3]=u[1]);o[2]-=o[0],o[3]-=o[1],l=[o[0]/(e.shape[2]||0),o[1]/(e.shape[1]||0),o[2]/(e.shape[2]||0),o[3]/(e.shape[1]||0)]}else o=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 d=Gf(i);a.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:o,boxRaw:l,keypoints:i,annotations:s,landmarks:d})}return a}async function Hx(e){var n,a,r,s,i,o;xe.initial&&(Hr=null,qr=null),!Hr||!qr?([Hr,qr]=await Promise.all([e.hand.enabled?et(tt(e.modelBasePath,((n=e.hand.detector)==null?void 0:n.modelPath)||""),{fromTFHub:(((a=e.hand.detector)==null?void 0:a.modelPath)||"").includes("tfhub.dev")}):null,e.hand.landmarks?et(tt(e.modelBasePath,((r=e.hand.skeleton)==null?void 0:r.modelPath)||""),{fromTFHub:(((s=e.hand.skeleton)==null?void 0:s.modelPath)||"").includes("tfhub.dev")}):null]),e.hand.enabled&&(!Hr||!Hr.modelUrl?ie("load model failed:",((i=e.hand.detector)==null?void 0:i.modelPath)||""):e.debug&&ie("load model:",Hr.modelUrl),!qr||!qr.modelUrl?ie("load model failed:",((o=e.hand.skeleton)==null?void 0:o.modelPath)||""):e.debug&&ie("load model:",qr.modelUrl))):(e.debug&&ie("cached model:",Hr.modelUrl),e.debug&&ie("cached model:",qr.modelUrl));let t=new Ux(Hr);return pI=new jx(t,qr),[Hr,qr]}function Oo(e,t=[1,1]){let n=[e.map(o=>o[0]),e.map(o=>o[1])],a=[Math.min(...n[0]),Math.min(...n[1])],r=[Math.max(...n[0]),Math.max(...n[1])],s=[a[0],a[1],r[0]-a[0],r[1]-a[1]],i=[s[0]/t[0],s[1]/t[1],s[2]/t[0],s[3]/t[1]];return{box:s,boxRaw:i}}function cI(e,t=[1,1]){let n=[e.map(d=>d[0]),e.map(d=>d[1])],a=[Math.min(...n[0]),Math.min(...n[1])],r=[Math.max(...n[0]),Math.max(...n[1])],s=[(a[0]+r[0])/2,(a[1]+r[1])/2],i=Math.max(s[0]-a[0],s[1]-a[1],-s[0]+r[0],-s[1]+r[1]),o=[Math.trunc(s[0]-i),Math.trunc(s[1]-i),Math.trunc(2*i),Math.trunc(2*i)],l=[o[0]/t[0],o[1]/t[1],o[2]/t[0],o[3]/t[1]];return{box:o,boxRaw:l}}function Hf(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 qx(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 kt=[null,null],mde=["StatefulPartitionedCall/Postprocessor/Slice","StatefulPartitionedCall/Postprocessor/ExpandDims_1"],Vs=[[0,0],[0,0]],gde=["hand","fist","pinch","point","face","tip","pinchtip"],hI=4,fI=1.6,yde=512,Ade=1.4,qf=0,Xx=0,Xr=[0,0],Ut={boxes:[],hands:[]},mI={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 gI(e){var t,n;if(xe.initial&&(kt[0]=null),kt[0])e.debug&&ie("cached model:",kt[0].modelUrl);else{Gu(["tensorlistreserve","enter","tensorlistfromtensor","merge","loopcond","switch","exit","tensorliststack","nextiteration","tensorlistsetitem","tensorlistgetitem","reciprocal","shape","split","where"],e),kt[0]=await et(tt(e.modelBasePath,((t=e.hand.detector)==null?void 0:t.modelPath)||""));let a=Object.values(kt[0].modelSignature.inputs);Vs[0][0]=Array.isArray(a)?parseInt(a[0].tensorShape.dim[1].size):0,Vs[0][1]=Array.isArray(a)?parseInt(a[0].tensorShape.dim[2].size):0,!kt[0]||!kt[0].modelUrl?ie("load model failed:",(n=e.hand.detector)==null?void 0:n.modelPath):e.debug&&ie("load model:",kt[0].modelUrl)}return kt[0]}async function yI(e){var t,n;if(xe.initial&&(kt[1]=null),kt[1])e.debug&&ie("cached model:",kt[1].modelUrl);else{kt[1]=await et(tt(e.modelBasePath,((t=e.hand.skeleton)==null?void 0:t.modelPath)||""));let a=Object.values(kt[1].modelSignature.inputs);Vs[1][0]=Array.isArray(a)?parseInt(a[0].tensorShape.dim[1].size):0,Vs[1][1]=Array.isArray(a)?parseInt(a[0].tensorShape.dim[2].size):0,!kt[1]||!kt[1].modelUrl?ie("load model failed:",(n=e.hand.skeleton)==null?void 0:n.modelPath):e.debug&&ie("load model:",kt[1].modelUrl)}return kt[1]}async function xde(e,t){let n=[];if(!e||!kt[0])return n;let a={},r=(e.shape[2]||1)/(e.shape[1]||1),s=Math.min(Math.round((e.shape[1]||0)/8)*8,yde),i=Math.round(s*r/8)*8;a.resize=Me.resizeBilinear(e,[s,i]),a.cast=pe(a.resize,"int32"),[a.rawScores,a.rawBoxes]=await kt[0].executeAsync(a.cast,mde),a.boxes=st(a.rawBoxes,[0,2]),a.scores=st(a.rawScores,[0]);let o=Mn(a.scores,1);Q(o[hI]),o.splice(hI,1),a.filtered=xn(o,1),Q(o),a.max=Rn(a.filtered,1),a.argmax=ka(a.filtered,1);let l=0;a.nms=await Me.nonMaxSuppressionAsync(a.boxes,a.max,t.hand.maxDetected,t.hand.iouThreshold,t.hand.minConfidence);let d=await a.nms.data(),u=await a.max.data(),p=await a.argmax.data();for(let c of Array.from(d)){let h=De(a.boxes,c,1),f=await h.data();Q(h);let m=[f[1],f[0],f[3]-f[1],f[2]-f[0]],g=Hf(m,Ade),y=qx(g),A=[Math.trunc(m[0]*Xr[0]),Math.trunc(m[1]*Xr[1]),Math.trunc(m[2]*Xr[0]),Math.trunc(m[3]*Xr[1])],x=u[c],b=gde[p[c]],v={id:l++,score:x,box:A,boxRaw:g,boxCrop:y,label:b};n.push(v)}return Object.keys(a).forEach(c=>Q(a[c])),n.sort((c,h)=>h.score-c.score),n.length>(t.hand.maxDetected||1)&&(n.length=t.hand.maxDetected||1),n}async function Kx(e,t,n){let a={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&&kt[1]&&n.hand.landmarks&&t.score>(n.hand.minConfidence||0)){let r={};r.crop=Me.cropAndResize(e,[t.boxCrop],[0],[Vs[1][0],Vs[1][1]],"bilinear"),r.cast=pe(r.crop,"float32"),r.div=he(r.cast,255),[r.score,r.keypoints]=kt[1].execute(r.div);let s=(await r.score.data())[0],i=(100-Math.trunc(100/(1+Math.exp(s))))/100;if(i>=(n.hand.minConfidence||0)){a.fingerScore=i,r.reshaped=V(r.keypoints,[-1,3]);let d=(await r.reshaped.array()).map(u=>[u[0]/Vs[1][1],u[1]/Vs[1][0],u[2]||0]).map(u=>[u[0]*t.boxRaw[2],u[1]*t.boxRaw[3],u[2]||0]);a.keypoints=d.map(u=>[Xr[0]*(u[0]+t.boxRaw[0]),Xr[1]*(u[1]+t.boxRaw[1]),u[2]||0]),a.landmarks=Gf(a.keypoints);for(let u of Object.keys(mI))a.annotations[u]=mI[u].map(p=>a.landmarks&&a.keypoints[p]?a.keypoints[p]:null)}Object.keys(r).forEach(o=>Q(r[o]))}return a}async function Zx(e,t){var n,a;return!kt[0]||!kt[1]||!((n=kt[0])==null?void 0:n.inputs[0].shape)||!((a=kt[1])==null?void 0:a.inputs[0].shape)?[]:(Xr=[e.shape[2]||0,e.shape[1]||0],qf++,t.skipFrame&&qf<=(t.hand.skipFrames||0)&&(t.hand.skipTime||0)<=Ae()-Xx?Ut.hands:new Promise(async r=>{t.skipFrame&&Ut.hands.length===t.hand.maxDetected?Ut.hands=await Promise.all(Ut.boxes.map(i=>Kx(e,i,t))):t.skipFrame&&qf<3*(t.hand.skipFrames||0)&&(t.hand.skipTime||0)<=3*(Ae()-Xx)&&Ut.hands.length>0?Ut.hands=await Promise.all(Ut.boxes.map(i=>Kx(e,i,t))):(Ut.boxes=await xde(e,t),Xx=Ae(),Ut.hands=await Promise.all(Ut.boxes.map(i=>Kx(e,i,t))),qf=0);let s=[...Ut.boxes];if(Ut.boxes.length=0,t.cacheSensitivity>0)for(let i=0;i<Ut.hands.length;i++){let o=cI(Ut.hands[i].keypoints,Xr);if(o.box[2]/(e.shape[2]||1)>.05&&o.box[3]/(e.shape[1]||1)>.05&&Ut.hands[i].fingerScore&&Ut.hands[i].fingerScore>(t.hand.minConfidence||0)){let l=Hf(o.box,fI),d=Hf(o.boxRaw,fI),u=qx(d);Ut.boxes.push({...s[i],box:l,boxRaw:d,boxCrop:u})}}for(let i=0;i<Ut.hands.length;i++){let o=Oo(Ut.hands[i].keypoints,Xr);Ut.hands[i].box=o.box,Ut.hands[i].boxRaw=o.boxRaw}r(Ut.hands)}))}var e5={};ud(e5,{connected:()=>Kf,horizontal:()=>Yx,kpt:()=>Xf,relative:()=>Qx,vertical:()=>Jx});var Xf=["nose","leftEye","rightEye","leftEar","rightEar","leftShoulder","rightShoulder","leftElbow","rightElbow","leftWrist","rightWrist","leftHip","rightHip","leftKnee","rightKnee","leftAnkle","rightAnkle"],Yx=[["leftEye","rightEye"],["leftEar","rightEar"],["leftShoulder","rightShoulder"],["leftElbow","rightElbow"],["leftWrist","rightWrist"],["leftHip","rightHip"],["leftKnee","rightKnee"],["leftAnkle","rightAnkle"]],Jx=[["leftKnee","leftShoulder"],["rightKnee","rightShoulder"],["leftAnkle","leftKnee"],["rightAnkle","rightKnee"]],Qx=[[["leftHip","rightHip"],["leftShoulder","rightShoulder"]],[["leftElbow","rightElbow"],["leftShoulder","rightShoulder"]]],Kf={leftLeg:["leftHip","leftKnee","leftAnkle"],rightLeg:["rightHip","rightKnee","rightAnkle"],torso:["leftShoulder","rightShoulder","rightHip","leftHip","leftShoulder"],leftArm:["leftShoulder","leftElbow","leftWrist"],rightArm:["rightShoulder","rightElbow","rightWrist"],head:[]};var AI=.005,ga={keypoints:[],padding:[[0,0],[0,0],[0,0],[0,0]]};function t5(e){for(let t of Yx){let n=e.keypoints.findIndex(r=>r.part===t[0]),a=e.keypoints.findIndex(r=>r.part===t[1]);if(e.keypoints[n]&&e.keypoints[a]&&e.keypoints[n].position[0]<e.keypoints[a].position[0]){let r=e.keypoints[n];e.keypoints[n]=e.keypoints[a],e.keypoints[a]=r}}for(let t of Jx){let n=e.keypoints.findIndex(r=>r&&r.part===t[0]),a=e.keypoints.findIndex(r=>r&&r.part===t[1]);e.keypoints[n]&&e.keypoints[a]&&e.keypoints[n].position[1]<e.keypoints[a].position[1]&&e.keypoints.splice(n,1)}for(let[t,n]of Qx){let a=e.keypoints.findIndex(d=>d&&d.part===t[0]),r=e.keypoints.findIndex(d=>d&&d.part===t[1]),s=e.keypoints.findIndex(d=>d&&d.part===n[0]),i=e.keypoints.findIndex(d=>d&&d.part===n[1]);if(!e.keypoints[s]||!e.keypoints[i])continue;let o=e.keypoints[a]?[Math.abs(e.keypoints[s].position[0]-e.keypoints[a].position[0]),Math.abs(e.keypoints[i].position[0]-e.keypoints[a].position[0])]:[0,0],l=e.keypoints[r]?[Math.abs(e.keypoints[i].position[0]-e.keypoints[r].position[0]),Math.abs(e.keypoints[s].position[0]-e.keypoints[r].position[0])]:[0,0];if(o[0]>o[1]||l[0]>l[1]){let d=e.keypoints[a];e.keypoints[a]=e.keypoints[r],e.keypoints[r]=d}}}function xI(e){for(let t=0;t<e.length;t++)if(e[t]&&ga.keypoints[t]){let n=[Math.abs(e[t].positionRaw[0]-ga.keypoints[t].positionRaw[0]),Math.abs(e[t].positionRaw[1]-ga.keypoints[t].positionRaw[1])];n[0]<AI&&n[1]<AI?e[t]=ga.keypoints[t]:ga.keypoints[t]=e[t]}else ga.keypoints[t]=e[t];return e}function bI(e,t){let n={};if(!e.shape||!e.shape[1]||!e.shape[2])return e;ga.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=Sa(e,ga.padding),n.resize=Me.resizeBilinear(n.pad,[t,t]);let a=pe(n.resize,"int32");return Object.keys(n).forEach(r=>Q(n[r])),a}function vI(e,t){e.keypoints=e.keypoints.filter(a=>a&&a.position);for(let a of e.keypoints)a.position=[a.position[0]*(t[0]+ga.padding[2][0]+ga.padding[2][1])/t[0]-ga.padding[2][0],a.position[1]*(t[1]+ga.padding[1][0]+ga.padding[1][1])/t[1]-ga.padding[1][0]],a.positionRaw=[a.position[0]/t[0],a.position[1]/t[1]];let n=Oo(e.keypoints.map(a=>a.position),t);return e.box=n.box,e.boxRaw=n.boxRaw,e}var Nn,Zf=0,n5=Number.MAX_SAFE_INTEGER,_o={boxes:[],bodies:[],last:0};async function wI(e){return xe.initial&&(Nn=null),Nn?e.debug&&ie("cached model:",Nn.modelUrl):(Gu(["size"],e),Nn=await et(tt(e.modelBasePath,e.body.modelPath||"")),!Nn||!Nn.modelUrl?ie("load model failed:",e.body.modelPath):e.debug&&ie("load model:",Nn.modelUrl)),Zf=Nn.inputs[0].shape?Nn.inputs[0].shape[2]:0,Zf===-1&&(Zf=256),Nn}async function bde(e,t,n,a){let r=e[0][0],s=[],i=0;for(let p=0;p<r.length;p++)if(i=r[p][2],i>t.body.minConfidence){let c=[(a[3]-a[1])*r[p][1]+a[1],(a[2]-a[0])*r[p][0]+a[0]];s.push({score:Math.round(100*i)/100,part:Xf[p],positionRaw:c,position:[Math.round((n.shape[2]||0)*c[0]),Math.round((n.shape[1]||0)*c[1])]})}i=s.reduce((p,c)=>c.score>p?c.score:p,0);let o=[],l=Oo(s.map(p=>p.position),[n.shape[2],n.shape[1]]),d={};for(let[p,c]of Object.entries(Kf)){let h=[];for(let f=0;f<c.length-1;f++){let m=s.find(y=>y.part===c[f]),g=s.find(y=>y.part===c[f+1]);m&&g&&m.score>(t.body.minConfidence||0)&&g.score>(t.body.minConfidence||0)&&h.push([m.position,g.position])}d[p]=h}let u={id:0,score:i,box:l.box,boxRaw:l.boxRaw,keypoints:s,annotations:d};return t5(u),o.push(u),o}async function vde(e,t,n,a){let r=[];for(let s=0;s<e[0].length;s++){let i=e[0][s],o=Math.round(100*i[51+4])/100;if(o>t.body.minConfidence){let l=[];for(let c=0;c<17;c++){let h=i[3*c+2];if(h>t.body.minConfidence){let f=[(a[3]-a[1])*i[3*c+1]+a[1],(a[2]-a[0])*i[3*c+0]+a[0]];l.push({part:Xf[c],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 d=Oo(l.map(c=>c.position),[n.shape[2],n.shape[1]]),u={};for(let[c,h]of Object.entries(Kf)){let f=[];for(let m=0;m<h.length-1;m++){let g=l.find(A=>A.part===h[m]),y=l.find(A=>A.part===h[m+1]);g&&y&&g.score>(t.body.minConfidence||0)&&y.score>(t.body.minConfidence||0)&&f.push([g.position,y.position])}u[c]=f}let p={id:s,score:o,box:d.box,boxRaw:d.boxRaw,keypoints:[...l],annotations:u};t5(p),r.push(p)}}return r.sort((s,i)=>i.score-s.score),r.length>t.body.maxDetected&&(r.length=t.body.maxDetected),r}async function a5(e,t){return!Nn||!(Nn==null?void 0:Nn.inputs[0].shape)?[]:(t.skipFrame||(_o.boxes.length=0),n5++,t.skipFrame&&n5<=(t.body.skipFrames||0)&&(t.body.skipTime||0)<=Ae()-_o.last?_o.bodies:new Promise(async n=>{let a={};n5=0,a.input=bI(e,Zf),a.res=await(Nn==null?void 0:Nn.predict(a.input)),_o.last=Ae();let r=await a.res.array();_o.bodies=a.res.shape[2]===17?await bde(r,t,e,[0,0,1,1]):await vde(r,t,e,[0,0,1,1]);for(let s of _o.bodies)vI(s,[e.shape[2]||1,e.shape[1]||1]),xI(s.keypoints);Object.keys(a).forEach(s=>Q(a[s])),n(_o.bodies)}))}var ya,Yf=[],kI=0,r5=Number.MAX_SAFE_INTEGER,Jf=2.5;async function II(e){if(!ya||xe.initial){ya=await et(tt(e.modelBasePath,e.object.modelPath||""));let t=Object.values(ya.modelSignature.inputs);if(ya.inputSize=Array.isArray(t)?parseInt(t[0].tensorShape.dim[2].size):null,!ya.inputSize)throw new Error(`cannot determine model inputSize: ${e.object.modelPath}`);!ya||!ya.modelUrl?ie("load model failed:",e.object.modelPath):e.debug&&ie("load model:",ya.modelUrl)}else e.debug&&ie("cached model:",ya.modelUrl);return ya}async function wde(e,t,n,a){let r=0,s=[];for(let d of[1,2,4])G(async()=>{var g,y;let u=d*13,p=(g=e.find(A=>A.shape[1]===u**2&&A.shape[2]===ju.length))==null?void 0:g.squeeze(),c=(y=e.find(A=>A.shape[1]===u**2&&A.shape[2]<ju.length))==null?void 0:y.squeeze(),f=await c.reshape([-1,4,c.shape[1]/4]).argMax(2).array(),m=await p.array();for(let A=0;A<p.shape[0];A++)for(let x=0;x<p.shape[1];x++){let b=m[A][x];if(b>a.object.minConfidence&&x!==61){let v=(.5+Math.trunc(A%u))/u,k=(.5+Math.trunc(A/u))/u,T=f[A].map(j=>j*(u/d/t)),[C,D]=[v-Jf/d*T[0],k-Jf/d*T[1]],[O,F]=[v+Jf/d*T[2]-C,k+Jf/d*T[3]-D],S=[C,D,O,F];S=S.map(j=>Math.max(0,Math.min(j,1)));let P=[S[0]*n[0],S[1]*n[1],S[2]*n[0],S[3]*n[1]],_={id:r++,score:Math.round(100*b)/100,class:x+1,label:ju[x].label,box:P.map(j=>Math.trunc(j)),boxRaw:S};s.push(_)}}});e.forEach(d=>Q(d));let i=s.map(d=>[d.boxRaw[1],d.boxRaw[0],d.boxRaw[3],d.boxRaw[2]]),o=s.map(d=>d.score),l=[];if(i&&i.length>0){let d=await Me.nonMaxSuppressionAsync(i,o,a.object.maxDetected,a.object.iouThreshold,a.object.minConfidence);l=await d.data(),Q(d)}return s=s.filter((d,u)=>l.includes(u)).sort((d,u)=>u.score-d.score),s}async function s5(e,t){return r5<(t.object.skipFrames||0)&&(t.object.skipTime||0)<=Ae()-kI&&t.skipFrame&&Yf.length>0?(r5++,Yf):(r5=0,!xe.kernels.includes("mod")||!xe.kernels.includes("sparsetodense")?Yf:new Promise(async n=>{let a=[e.shape[2],e.shape[1]],r=Me.resizeBilinear(e,[ya.inputSize,ya.inputSize],!1),s=he(r,255),i=s.transpose([0,3,1,2]);Q(s),Q(r);let o;t.object.enabled&&(o=await ya.predict(i)),kI=Ae(),Q(i);let l=await wde(o,ya.inputSize,a,t);Yf=l,n(l)}))}var nc=["nose","leftEye","rightEye","leftEar","rightEar","leftShoulder","rightShoulder","leftElbow","rightElbow","leftWrist","rightWrist","leftHip","rightHip","leftKnee","rightKnee","leftAnkle","rightAnkle"],kde=nc.length,ac=nc.reduce((e,t,n)=>(e[t]=n,e),{}),Ide=[["leftHip","leftShoulder"],["leftElbow","leftShoulder"],["leftElbow","leftWrist"],["leftHip","leftKnee"],["leftKnee","leftAnkle"],["rightHip","rightShoulder"],["rightElbow","rightShoulder"],["rightElbow","rightWrist"],["rightHip","rightKnee"],["rightKnee","rightAnkle"],["leftShoulder","rightShoulder"],["leftHip","rightHip"]],nhe=Ide.map(([e,t])=>[ac[e],ac[t]]),SI=[["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 NI(e){let t=e.reduce(({maxX:n,maxY:a,minX:r,minY:s},{position:{x:i,y:o}})=>({maxX:Math.max(n,i),maxY:Math.max(a,o),minX:Math.min(r,i),minY:Math.min(s,o)}),{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 TI(e,[t,n],[a,r]){let s=t/a,i=n/r,o=(d,u)=>({id:u,score:d.score,boxRaw:[d.box[0]/r,d.box[1]/a,d.box[2]/r,d.box[3]/a],box:[Math.trunc(d.box[0]*i),Math.trunc(d.box[1]*s),Math.trunc(d.box[2]*i),Math.trunc(d.box[3]*s)],keypoints:d.keypoints.map(({score:p,part:c,position:h})=>({score:p,part:c,position:[Math.trunc(h.x*i),Math.trunc(h.y*s)],positionRaw:[h.x/a,h.y/a]}))});return e.map((d,u)=>o(d,u))}var i5=class{constructor(t,n){ce(this,"priorityQueue");ce(this,"numberOfElements");ce(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 a=this.priorityQueue[t];this.priorityQueue[t]=this.priorityQueue[n],this.priorityQueue[n]=a}};function o5(e,t,n,a){return{y:a.get(e,t,n),x:a.get(e,t,n+kde)}}function l5(e,t,n){let{heatmapY:a,heatmapX:r,id:s}=e,{y:i,x:o}=o5(a,r,s,n);return{x:e.heatmapX*t+o,y:e.heatmapY*t+i}}function u5(e,t,n){return e<t?t:e>n?n:e}function CI(e,t,n,a){let r=n-e,s=a-t;return r*r+s*s}function d5(e,t){return{x:e.x+t.x,y:e.y+t.y}}var Aa,Sde=["MobilenetV1/offset_2/BiasAdd","MobilenetV1/heatmap_2/BiasAdd","MobilenetV1/displacement_fwd_2/BiasAdd","MobilenetV1/displacement_bwd_2/BiasAdd"],Qf=1,Xu=16,Nde=50**2;function EI(e,t,n,a,r,s,i=2){let o=y=>({y:s.get(y.y,y.x,e),x:s.get(y.y,y.x,s.shape[2]/2+e)}),l=(y,A,x)=>({y:u5(Math.round(y.y/Xu),0,A-1),x:u5(Math.round(y.x/Xu),0,x-1)}),[d,u]=a.shape,p=l(t.position,d,u),c=o(p),f=d5(t.position,c);for(let y=0;y<i;y++){let A=l(f,d,u),x=o5(A.y,A.x,n,r);f=d5({x:A.x*Xu,y:A.y*Xu},{x:x.x,y:x.y})}let m=l(f,d,u),g=a.get(m.y,m.x,n);return{position:f,part:nc[n],score:g}}function Tde(e,t,n,a,r){let s=SI.map(([c,h])=>[ac[c],ac[h]]),i=s.map(([,c])=>c),o=s.map(([c])=>c),l=t.shape[2],d=i.length,u=new Array(l),p=l5(e.part,Xu,n);u[e.part.id]={score:e.score,part:nc[e.part.id],position:p};for(let c=d-1;c>=0;--c){let h=i[c],f=o[c];u[h]&&!u[f]&&(u[f]=EI(c,u[h],f,t,n,r))}for(let c=0;c<d;++c){let h=o[c],f=i[c];u[h]&&!u[f]&&(u[f]=EI(c,u[h],f,t,n,a))}return u}function Cde(e,t,n,a,r){let[s,i]=r.shape,o=!0,l=Math.max(n-Qf,0),d=Math.min(n+Qf+1,s);for(let u=l;u<d;++u){let p=Math.max(a-Qf,0),c=Math.min(a+Qf+1,i);for(let h=p;h<c;++h)if(r.get(u,h,e)>t){o=!1;break}if(!o)break}return o}function Ede(e,t){let[n,a,r]=t.shape,s=new i5(n*a*r,({score:i})=>i);for(let i=0;i<n;++i)for(let o=0;o<a;++o)for(let l=0;l<r;++l){let d=t.get(i,o,l);d<e||Cde(l,d,i,o,t)&&s.enqueue({score:d,part:{heatmapY:i,heatmapX:o,id:l}})}return s}function RI(e,{x:t,y:n},a){return e.some(({keypoints:r})=>{var i;let s=(i=r[a])==null?void 0:i.position;return s?CI(n,t,s.y,s.x)<=Nde:!1})}function Rde(e,t){return t.reduce((a,{position:r,score:s},i)=>(RI(e,r,i)||(a+=s),a),0)/t.length}function Mde(e,t,n,a,r,s){let i=[],o=Ede(s,t);for(;i.length<r&&!o.empty();){let l=o.dequeue(),d=l5(l.part,Xu,e);if(RI(i,d,l.part.id))continue;let u=Tde(l,t,e,n,a);u=u.filter(h=>h.score>s);let p=Rde(i,u),c=NI(u);p>s&&i.push({keypoints:u,box:c,score:Math.round(100*p)/100})}return i}async function p5(e,t){let n=G(()=>{if(!Aa.inputs[0].shape)return[];let i=Me.resizeBilinear(e,[Aa.inputs[0].shape[2],Aa.inputs[0].shape[1]]),o=ge(he(pe(i,"float32"),127.5),1),d=Aa.execute(o,Sde).map(u=>st(u,[0]));return d[1]=d[1].sigmoid(),d}),a=await Promise.all(n.map(i=>i.buffer()));for(let i of n)Q(i);let r=await Mde(a[0],a[1],a[2],a[3],t.body.maxDetected,t.body.minConfidence);return Aa.inputs[0].shape?TI(r,[e.shape[1],e.shape[2]],[Aa.inputs[0].shape[2],Aa.inputs[0].shape[1]]):[]}async function MI(e){return!Aa||xe.initial?(Aa=await et(tt(e.modelBasePath,e.body.modelPath||"")),!Aa||!Aa.modelUrl?ie("load model failed:",e.body.modelPath):e.debug&&ie("load model:",Aa.modelUrl)):e.debug&&ie("cached model:",Aa.modelUrl),Aa}var Da,c5=!1;async function h5(e){return!Da||xe.initial?(Da=await et(tt(e.modelBasePath,e.segmentation.modelPath||"")),!Da||!Da.modelUrl?ie("load model failed:",e.segmentation.modelPath):e.debug&&ie("load model:",Da.modelUrl)):e.debug&&ie("cached model:",Da.modelUrl),Da}async function FI(e,t,n){var m,g;if(c5)return{data:[],canvas:null,alpha:null};c5=!0,Da||await h5(n);let a=Uu(e,n),r=((m=a.canvas)==null?void 0:m.width)||0,s=((g=a.canvas)==null?void 0:g.height)||0;if(!a.tensor)return{data:[],canvas:null,alpha:null};let i={};i.resize=Me.resizeBilinear(a.tensor,[Da.inputs[0].shape?Da.inputs[0].shape[1]:0,Da.inputs[0].shape?Da.inputs[0].shape[2]:0],!1),Q(a.tensor),i.norm=he(i.resize,255),i.res=Da.predict(i.norm),i.squeeze=st(i.res,0),i.squeeze.shape[2]===2?(i.softmax=lo(i.squeeze),[i.bg,i.fg]=Mn(i.softmax,2),i.expand=Wt(i.fg,2),i.pad=Wt(i.expand,0),i.crop=Me.cropAndResize(i.pad,[[0,0,.5,.5]],[0],[r,s]),i.data=st(i.crop,0)):i.data=Me.resizeBilinear(i.squeeze,[s,r]);let o=Array.from(await i.data.data());if(xe.node&&!xe.Canvas&&typeof ImageData=="undefined")return n.debug&&ie("canvas support missing"),Object.keys(i).forEach(y=>Q(i[y])),{data:o,canvas:null,alpha:null};let l=zn(r,s);await za.toPixels(i.data,l);let d=l.getContext("2d");n.segmentation.blur&&n.segmentation.blur>0&&(d.filter=`blur(${n.segmentation.blur}px)`);let u=d.getImageData(0,0,r,s),p=zn(r,s),c=p.getContext("2d");a.canvas&&c.drawImage(a.canvas,0,0),c.globalCompositeOperation="darken",n.segmentation.blur&&n.segmentation.blur>0&&(c.filter=`blur(${n.segmentation.blur}px)`),c.drawImage(l,0,0),c.globalCompositeOperation="source-over",c.filter="none";let h=c.getImageData(0,0,r,s);for(let y=0;y<r*s;y++)h.data[4*y+3]=u.data[4*y+0];c.putImageData(h,0,0);let f=null;if(t&&p){f=zn(r,s);let y=Uu(t,n);Q(y.tensor);let A=f.getContext("2d");A.drawImage(y.canvas,0,0,f.width,f.height),A.drawImage(p,0,0)}return Object.keys(i).forEach(y=>Q(i[y])),c5=!1,{data:o,canvas:f||p,alpha:l}}var rc=class{constructor(){ce(this,"age",null);ce(this,"agegenderrace",null);ce(this,"blazeposedetect",null);ce(this,"blazepose",null);ce(this,"centernet",null);ce(this,"efficientpose",null);ce(this,"embedding",null);ce(this,"emotion",null);ce(this,"facedetect",null);ce(this,"faceiris",null);ce(this,"facemesh",null);ce(this,"faceres",null);ce(this,"gender",null);ce(this,"handpose",null);ce(this,"handskeleton",null);ce(this,"handtrack",null);ce(this,"movenet",null);ce(this,"nanodet",null);ce(this,"posenet",null);ce(this,"segmentation",null);ce(this,"antispoof",null)}};function f5(e){for(let t of Object.keys(e.models))e.models[t]=null}async function DI(e){var t,n,a,r,s,i,o,l,d,u,p,c,h,f,m,g,y,A,x,b,v,k,T,C,D,O,F,S,P,_,j;xe.initial&&f5(e),e.config.hand.enabled&&(!e.models.handpose&&((n=(t=e.config.hand.detector)==null?void 0:t.modelPath)==null?void 0:n.includes("handdetect"))&&([e.models.handpose,e.models.handskeleton]=await Hx(e.config)),!e.models.handskeleton&&e.config.hand.landmarks&&((r=(a=e.config.hand.detector)==null?void 0:a.modelPath)==null?void 0:r.includes("handdetect"))&&([e.models.handpose,e.models.handskeleton]=await Hx(e.config))),e.config.face.enabled&&!e.models.facedetect&&(e.models.facedetect=x9(e.config)),e.config.face.enabled&&((s=e.config.face.mesh)==null?void 0:s.enabled)&&!e.models.facemesh&&(e.models.facemesh=W9(e.config)),e.config.face.enabled&&((i=e.config.face.iris)==null?void 0:i.enabled)&&!e.models.faceiris&&(e.models.faceiris=F9(e.config)),e.config.face.enabled&&((o=e.config.face.antispoof)==null?void 0:o.enabled)&&!e.models.antispoof&&(e.models.antispoof=u9(e.config)),e.config.hand.enabled&&!e.models.handtrack&&((d=(l=e.config.hand.detector)==null?void 0:l.modelPath)==null?void 0:d.includes("handtrack"))&&(e.models.handtrack=gI(e.config)),e.config.hand.enabled&&e.config.hand.landmarks&&!e.models.handskeleton&&((p=(u=e.config.hand.detector)==null?void 0:u.modelPath)==null?void 0:p.includes("handtrack"))&&(e.models.handskeleton=yI(e.config)),e.config.body.enabled&&!e.models.posenet&&((h=(c=e.config.body)==null?void 0:c.modelPath)==null?void 0:h.includes("posenet"))&&(e.models.posenet=MI(e.config)),e.config.body.enabled&&!e.models.efficientpose&&((m=(f=e.config.body)==null?void 0:f.modelPath)==null?void 0:m.includes("efficientpose"))&&(e.models.efficientpose=Rx(e.config)),e.config.body.enabled&&!e.models.blazepose&&((y=(g=e.config.body)==null?void 0:g.modelPath)==null?void 0:y.includes("blazepose"))&&(e.models.blazepose=I9(e.config)),e.config.body.enabled&&!e.models.blazeposedetect&&((A=e.config.body.detector)==null?void 0:A.modelPath)&&((b=(x=e.config.body)==null?void 0:x.modelPath)==null?void 0:b.includes("blazepose"))&&(e.models.blazeposedetect=k9(e.config)),e.config.body.enabled&&!e.models.efficientpose&&((k=(v=e.config.body)==null?void 0:v.modelPath)==null?void 0:k.includes("efficientpose"))&&(e.models.efficientpose=Rx(e.config)),e.config.body.enabled&&!e.models.movenet&&((C=(T=e.config.body)==null?void 0:T.modelPath)==null?void 0:C.includes("movenet"))&&(e.models.movenet=wI(e.config)),e.config.object.enabled&&!e.models.nanodet&&((O=(D=e.config.object)==null?void 0:D.modelPath)==null?void 0:O.includes("nanodet"))&&(e.models.nanodet=II(e.config)),e.config.object.enabled&&!e.models.centernet&&((S=(F=e.config.object)==null?void 0:F.modelPath)==null?void 0:S.includes("centernet"))&&(e.models.centernet=T9(e.config)),e.config.face.enabled&&((P=e.config.face.emotion)==null?void 0:P.enabled)&&!e.models.emotion&&(e.models.emotion=M9(e.config)),e.config.face.enabled&&((_=e.config.face.description)==null?void 0:_.enabled)&&!e.models.faceres&&(e.models.faceres=G9(e.config)),e.config.segmentation.enabled&&!e.models.segmentation&&(e.models.segmentation=h5(e.config)),e.config.face.enabled&&((j=e.config.face.agegenderrace)==null?void 0:j.enabled)&&!e.models.agegenderrace&&(e.models.agegenderrace=i9(e.config));for await(let q of Object.keys(e.models))e.models[q]&&typeof e.models[q]!="undefined"&&(e.models[q]=await e.models[q])}async function $I(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 a=[];Array.isArray(e.models[n])?a=e.models[n].filter(r=>r!==null).map(r=>r&&r.executor?r:r.model):a=[e.models[n]];for(let r of a){if(!r){e.config.debug&&ie("model marked as loaded but not defined:",n);continue}let s=[],i=r==null?void 0:r.executor;if(i&&i.graph.nodes)for(let l of Object.values(i.graph.nodes)){let d=l.op.toLowerCase();s.includes(d)||s.push(d)}else!i&&e.config.debug&&ie("model signature not determined:",n);let o=[];for(let l of s)!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",""))&&o.push(l);o.length>0&&e.config.debug&&ie("model validation:",n,o)}}}var Ot={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 Fde(){let e=Ot.gl;!e||(Ot.extensions=e.getSupportedExtensions())}async function OI(e){var t;if(e.config.backend==="humangl"&&(Ot.name in sa().registry&&(!Ot.gl||!Ot.gl.getParameter(Ot.gl.VERSION))&&(ie("error: humangl backend invalid context"),f5(e)),!gg(Ot.name))){try{Ot.canvas=await zn(100,100)}catch(a){ie("error: cannot create canvas:",a);return}try{Ot.gl=(t=Ot.canvas)==null?void 0:t.getContext("webgl2",Ot.webGLattr),Ot.canvas&&(Ot.canvas.addEventListener("webglcontextlost",async a=>{throw ie("error: humangl:",a.type),ie("possible browser memory leak using webgl or conflict with multiple backend registrations"),e.emit("error"),new Error("browser webgl error")}),Ot.canvas.addEventListener("webglcontextrestored",a=>{ie("error: humangl context restored:",a)}),Ot.canvas.addEventListener("webglcontextcreationerror",a=>{ie("error: humangl context create:",a)}))}catch(a){ie("error: cannot get WebGL context:",a);return}try{lf(2,Ot.gl)}catch(a){ie("error: cannot set WebGL context:",a);return}try{let a=new yf(Ot.gl);au(Ot.name,()=>new Pu(a),Ot.priority)}catch(a){ie("error: cannot register WebGL backend:",a);return}try{$r("webgl").forEach(r=>{let s={...r,backendName:Ot.name};cs(s)})}catch(a){ie("error: cannot update WebGL backend registration:",a);return}let n=mr().getGPGPUContext?mr().getGPGPUContext().gl:null;if(n)ie(`humangl webgl version:${n.getParameter(n.VERSION)} renderer:${n.getParameter(n.RENDERER)}`);else{ie("error: no current gl context:",n,Ot.gl);return}try{cr.set("WEBGL_VERSION",2)}catch(a){ie("error: cannot set WebGL backend flags:",a);return}Fde(),ie("backend registered:",Ot.name)}}async function em(e,t=!1){if(e.state="backend",t||xe.initial||e.config.backend&&e.config.backend.length>0&&Ya()!==e.config.backend){let n=Ae();if(e.config.backend&&e.config.backend.length>0){if(typeof window=="undefined"&&typeof WorkerGlobalScope!="undefined"&&e.config.debug&&e.config.debug&&ie("running inside web worker"),xe.browser&&e.config.backend==="tensorflow"&&(e.config.debug&&ie("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&&ie(`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")ie("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&&ie("enumerated webgpu adapter:",r)}e.config.backend==="humangl"&&await OI(e);let a=Object.keys(sa().registryFactory);if(e.config.debug&&ie("available backends:",a),a.includes(e.config.backend)||(ie(`error: backend ${e.config.backend} not found in registry`),e.config.backend=xe.node?"tensorflow":"webgl",e.config.debug&&ie(`override: setting backend ${e.config.backend}`)),e.config.debug&&ie("setting backend:",e.config.backend),e.config.backend==="wasm"){if(e.config.debug&&ie("wasm path:",e.config.wasmPath),typeof(Ro==null?void 0:Ro.setWasmPaths)!="undefined")await K8(e.config.wasmPath);else throw new Error("wasm backend is not loaded");let r=await ne().getAsync("WASM_HAS_SIMD_SUPPORT"),s=await ne().getAsync("WASM_HAS_MULTITHREAD_SUPPORT");e.config.debug&&ie(`wasm execution: ${r?"SIMD":"no SIMD"} ${s?"multithreaded":"singlethreaded"}`),e.config.debug&&!r&&ie("warning: wasm simd support is not enabled")}try{await t3(e.config.backend),await $h()}catch(r){return ie("error: cannot set backend:",e.config.backend,r),!1}}if(Ya()==="humangl"&&(cr.set("CHECK_COMPUTATION_FOR_ERRORS",!1),cr.set("WEBGL_CPU_FORWARD",!0),cr.set("WEBGL_USE_SHAPES_UNIFORMS",!0),cr.set("CPU_HANDOFF_SIZE_THRESHOLD",256),typeof e.config.deallocate!="undefined"&&e.config.deallocate&&(ie("changing webgl: WEBGL_DELETE_TEXTURE_THRESHOLD:",!0),cr.set("WEBGL_DELETE_TEXTURE_THRESHOLD",0)),mr().getGPGPUContext)){let a=await mr().getGPGPUContext().gl;e.config.debug&&ie(`gl version:${a.getParameter(a.VERSION)} renderer:${a.getParameter(a.RENDERER)}`)}Ya()==="webgpu",e3(),await $h(),e.performance.backend=Math.trunc(Ae()-n),e.config.backend=Ya(),xe.updateBackend()}return!0}function Gu(e,t){for(let n of e){let a={kernelName:n,backendName:t.backend,kernelFunc:()=>{t.debug&&ie("kernelFunc",n,t.backend)}};cs(a)}xe.kernels=$r(Ya()).map(n=>n.kernelName.toLowerCase())}var Kr={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,bufferedOutput:!0},Po=e=>{if(e&&e.getContext)return e.getContext("2d");throw new Error("invalid canvas")},Ku=e=>Math.round(e*180/Math.PI);function m5(e,t,n,a=0,r){e.fillStyle=r.useDepth&&a?`rgba(${127.5+2*a}, ${127.5-2*a}, 255, 0.3)`:r.color,e.beginPath(),e.arc(t,n,r.pointSize,0,2*Math.PI),e.fill()}function sc(e,t,n,a,r,s){if(e.beginPath(),s.useCurves){let i=(t+t+a)/2,o=(n+n+r)/2;e.ellipse(i,o,a/2,r/2,0,0,2*Math.PI)}else e.lineWidth=s.lineWidth,e.moveTo(t+s.roundRect,n),e.lineTo(t+a-s.roundRect,n),e.quadraticCurveTo(t+a,n,t+a,n+s.roundRect),e.lineTo(t+a,n+r-s.roundRect),e.quadraticCurveTo(t+a,n+r,t+a-s.roundRect,n+r),e.lineTo(t+s.roundRect,n+r),e.quadraticCurveTo(t,n+r,t,n+r-s.roundRect),e.lineTo(t,n+s.roundRect),e.quadraticCurveTo(t,n,t+s.roundRect,n),e.closePath();e.stroke()}function _I(e,t=[],n){if(!(t===void 0||t.length===0)){e.beginPath(),e.moveTo(t[0][0],t[0][1]);for(let a of t){let r=a[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(a[0],Math.round(a[1]))}e.stroke(),n.fillPolygons&&(e.closePath(),e.fill())}}function Dde(e,t=[],n){if(!(t===void 0||t.length===0)){if(!n.useCurves||t.length<=2){_I(e,t,n);return}e.moveTo(t[0][0],t[0][1]);for(let a=0;a<t.length-2;a++){let r=(t[a][0]+t[a+1][0])/2,s=(t[a][1]+t[a+1][1])/2;e.quadraticCurveTo(t[a][0],t[a][1],r,s)}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 PI(e,t,n,a=5){let r,s,i;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]),s=a*Math.cos(r)+n[0],i=a*Math.sin(r)+n[1],e.moveTo(s,i),r+=1/3*(2*Math.PI),s=a*Math.cos(r)+n[0],i=a*Math.sin(r)+n[1],e.lineTo(s,i),r+=1/3*(2*Math.PI),s=a*Math.cos(r)+n[0],i=a*Math.sin(r)+n[1],e.lineTo(s,i),e.closePath(),e.stroke(),e.fill()}async function g5(e,t,n){let a=kn(Kr,n);if(!(!t||!e)&&a.drawGestures){let r=Po(e);r.font=a.font,r.fillStyle=a.color;let s=1;for(let i=0;i<t.length;i++){let o=[],l=[];if([o,l]=Object.entries(t[i]),l.length>1&&l[1].length>0){let d=o[1]>0?`#${o[1]}`:"",u=`${o[0]} ${d}: ${l[1]}`;a.shadowColor&&a.shadowColor!==""&&(r.fillStyle=a.shadowColor,r.fillText(u,8,2+s*a.lineHeight)),r.fillStyle=a.labelColor,r.fillText(u,6,0+s*a.lineHeight),s+=1}}}}async function y5(e,t,n){var s,i,o,l,d;let a=kn(Kr,n);if(!t||!e)return;let r=Po(e);for(let u of t){if(r.font=a.font,r.strokeStyle=a.color,r.fillStyle=a.color,a.drawBoxes&&sc(r,u.box[0],u.box[1],u.box[2],u.box[3],a),a.drawLabels){let p=[];if(p.push(`face: ${Math.trunc(100*u.score)}%`),u.genderScore&&p.push(`${u.gender||""} ${Math.trunc(100*u.genderScore)}%`),u.age&&p.push(`age: ${u.age||""}`),u.iris&&p.push(`distance: ${u.iris}`),u.real&&p.push(`real: ${Math.trunc(100*u.real)}%`),u.emotion&&u.emotion.length>0){let c=u.emotion.map(h=>`${Math.trunc(100*h.score)}% ${h.emotion}`);c.length>3&&(c.length=3),p.push(c.join(" "))}u.rotation&&u.rotation.angle&&u.rotation.gaze&&(u.rotation.angle.roll&&p.push(`roll: ${Ku(u.rotation.angle.roll)}\xB0 yaw:${Ku(u.rotation.angle.yaw)}\xB0 pitch:${Ku(u.rotation.angle.pitch)}\xB0`),u.rotation.gaze.bearing&&p.push(`gaze: ${Ku(u.rotation.gaze.bearing)}\xB0`)),p.length===0&&p.push("face"),r.fillStyle=a.color;for(let c=p.length-1;c>=0;c--){let h=Math.max(u.box[0],0),f=c*a.lineHeight+u.box[1];a.shadowColor&&a.shadowColor!==""&&(r.fillStyle=a.shadowColor,r.fillText(p[c],h+5,f+16)),r.fillStyle=a.labelColor,r.fillText(p[c],h+4,f+15)}}if(r.lineWidth=1,u.mesh&&u.mesh.length>0){if(a.drawPoints)for(let p of u.mesh)m5(r,p[0],p[1],p[2],a);if(a.drawPolygons){if(r.lineWidth=1,u.mesh.length>450)for(let p=0;p<Mo.length/3;p++){let c=[Mo[p*3+0],Mo[p*3+1],Mo[p*3+2]].map(h=>u.mesh[h]);_I(r,c,a)}if(u.annotations&&u.annotations.leftEyeIris&&u.annotations.leftEyeIris[0]){r.strokeStyle=a.useDepth?"rgba(255, 200, 255, 0.3)":a.color,r.beginPath();let p=Math.abs(u.annotations.leftEyeIris[3][0]-u.annotations.leftEyeIris[1][0])/2,c=Math.abs(u.annotations.leftEyeIris[4][1]-u.annotations.leftEyeIris[2][1])/2;r.ellipse(u.annotations.leftEyeIris[0][0],u.annotations.leftEyeIris[0][1],p,c,0,0,2*Math.PI),r.stroke(),a.fillPolygons&&(r.fillStyle=a.useDepth?"rgba(255, 255, 200, 0.3)":a.color,r.fill())}if(u.annotations&&u.annotations.rightEyeIris&&u.annotations.rightEyeIris[0]){r.strokeStyle=a.useDepth?"rgba(255, 200, 255, 0.3)":a.color,r.beginPath();let p=Math.abs(u.annotations.rightEyeIris[3][0]-u.annotations.rightEyeIris[1][0])/2,c=Math.abs(u.annotations.rightEyeIris[4][1]-u.annotations.rightEyeIris[2][1])/2;r.ellipse(u.annotations.rightEyeIris[0][0],u.annotations.rightEyeIris[0][1],p,c,0,0,2*Math.PI),r.stroke(),a.fillPolygons&&(r.fillStyle=a.useDepth?"rgba(255, 255, 200, 0.3)":a.color,r.fill())}if(a.drawGaze&&((s=u.rotation)==null?void 0:s.angle)){r.strokeStyle="pink";let p=u.box[0]+u.box[2]/2-u.box[3]*Ku(u.rotation.angle.yaw)/90,c=u.box[1]+u.box[3]/2+u.box[2]*Ku(u.rotation.angle.pitch)/90,h=new Path2D(`
|
|
M ${u.box[0]+u.box[2]/2} ${u.box[1]}
|
|
C
|
|
${p} ${u.box[1]},
|
|
${p} ${u.box[1]+u.box[3]},
|
|
${u.box[0]+u.box[2]/2} ${u.box[1]+u.box[3]}
|
|
`),f=new Path2D(`
|
|
M ${u.box[0]} ${u.box[1]+u.box[3]/2}
|
|
C
|
|
${u.box[0]} ${c},
|
|
${u.box[0]+u.box[2]} ${c},
|
|
${u.box[0]+u.box[2]} ${u.box[1]+u.box[3]/2}
|
|
`);r.stroke(f),r.stroke(h)}if(a.drawGaze&&((o=(i=u.rotation)==null?void 0:i.gaze)==null?void 0:o.strength)&&((d=(l=u.rotation)==null?void 0:l.gaze)==null?void 0:d.bearing)&&u.annotations.leftEyeIris&&u.annotations.rightEyeIris&&u.annotations.leftEyeIris[0]&&u.annotations.rightEyeIris[0]){r.strokeStyle="pink",r.fillStyle="pink";let p=[u.annotations.leftEyeIris[0][0]+Math.sin(u.rotation.gaze.bearing)*u.rotation.gaze.strength*u.box[3],u.annotations.leftEyeIris[0][1]+Math.cos(u.rotation.gaze.bearing)*u.rotation.gaze.strength*u.box[2]];PI(r,[u.annotations.leftEyeIris[0][0],u.annotations.leftEyeIris[0][1]],[p[0],p[1]],4);let c=[u.annotations.rightEyeIris[0][0]+Math.sin(u.rotation.gaze.bearing)*u.rotation.gaze.strength*u.box[3],u.annotations.rightEyeIris[0][1]+Math.cos(u.rotation.gaze.bearing)*u.rotation.gaze.strength*u.box[2]];PI(r,[u.annotations.rightEyeIris[0][0],u.annotations.rightEyeIris[0][1]],[c[0],c[1]],4)}}}}}async function A5(e,t,n){var s;let a=kn(Kr,n);if(!t||!e)return;let r=Po(e);r.lineJoin="round";for(let i=0;i<t.length;i++){if(r.strokeStyle=a.color,r.fillStyle=a.color,r.lineWidth=a.lineWidth,r.font=a.font,a.drawBoxes&&t[i].box&&((s=t[i].box)==null?void 0:s.length)===4&&(sc(r,t[i].box[0],t[i].box[1],t[i].box[2],t[i].box[3],a),a.drawLabels&&(a.shadowColor&&a.shadowColor!==""&&(r.fillStyle=a.shadowColor,r.fillText(`body ${100*t[i].score}%`,t[i].box[0]+3,1+t[i].box[1]+a.lineHeight,t[i].box[2])),r.fillStyle=a.labelColor,r.fillText(`body ${100*t[i].score}%`,t[i].box[0]+2,0+t[i].box[1]+a.lineHeight,t[i].box[2]))),a.drawPoints&&t[i].keypoints)for(let o=0;o<t[i].keypoints.length;o++)r.fillStyle=a.useDepth&&t[i].keypoints[o].position[2]?`rgba(${127.5+2*(t[i].keypoints[o].position[2]||0)}, ${127.5-2*(t[i].keypoints[o].position[2]||0)}, 255, 0.5)`:a.color,m5(r,t[i].keypoints[o].position[0],t[i].keypoints[o].position[1],0,a);if(a.drawLabels&&t[i].keypoints){r.font=a.font;for(let o of t[i].keypoints)r.fillStyle=a.useDepth&&o.position[2]?`rgba(${127.5+2*o.position[2]}, ${127.5-2*o.position[2]}, 255, 0.5)`:a.color,r.fillText(`${o.part} ${Math.trunc(100*o.score)}%`,o.position[0]+4,o.position[1]+4)}if(a.drawPolygons&&t[i].keypoints&&t[i].annotations)for(let o of Object.values(t[i].annotations))for(let l of o)Dde(r,l,a)}}async function x5(e,t,n){let a=kn(Kr,n);if(!t||!e)return;let r=Po(e);r.lineJoin="round",r.font=a.font;for(let s of t){if(a.drawBoxes&&(r.strokeStyle=a.color,r.fillStyle=a.color,sc(r,s.box[0],s.box[1],s.box[2],s.box[3],a),a.drawLabels&&(a.shadowColor&&a.shadowColor!==""&&(r.fillStyle=a.shadowColor,r.fillText(`hand:${Math.trunc(100*s.score)}%`,s.box[0]+3,1+s.box[1]+a.lineHeight,s.box[2])),r.fillStyle=a.labelColor,r.fillText(`hand:${Math.trunc(100*s.score)}%`,s.box[0]+2,0+s.box[1]+a.lineHeight,s.box[2])),r.stroke()),a.drawPoints&&s.keypoints&&s.keypoints.length>0)for(let i of s.keypoints)r.fillStyle=a.useDepth?`rgba(${127.5+2*(i[2]||0)}, ${127.5-2*(i[2]||0)}, 255, 0.5)`:a.color,m5(r,i[0],i[1],0,a);if(a.drawLabels&&s.annotations){let i=(o,l)=>{!o||o.length===0||!o[0]||(r.fillStyle=a.useDepth?`rgba(${127.5+2*o[o.length-1][2]}, ${127.5-2*o[o.length-1][2]}, 255, 0.5)`:a.color,r.fillText(l,o[o.length-1][0]+4,o[o.length-1][1]+4))};r.font=a.font,i(s.annotations.index,"index"),i(s.annotations.middle,"middle"),i(s.annotations.ring,"ring"),i(s.annotations.pinky,"pinky"),i(s.annotations.thumb,"thumb"),i(s.annotations.palm,"palm")}if(a.drawPolygons&&s.annotations){let i=o=>{if(!(!o||o.length===0||!o[0]))for(let l=0;l<o.length;l++)r.beginPath(),r.strokeStyle=a.useDepth?`rgba(${127.5+2*o[l][2]}, ${127.5-2*o[l][2]}, 255, 0.5)`:a.color,r.moveTo(o[l>0?l-1:0][0],o[l>0?l-1:0][1]),r.lineTo(o[l][0],o[l][1]),r.stroke()};r.lineWidth=a.lineWidth,i(s.annotations.index),i(s.annotations.middle),i(s.annotations.ring),i(s.annotations.pinky),i(s.annotations.thumb)}}}async function b5(e,t,n){let a=kn(Kr,n);if(!t||!e)return;let r=Po(e);r.lineJoin="round",r.font=a.font;for(let s of t)if(a.drawBoxes){if(r.strokeStyle=a.color,r.fillStyle=a.color,sc(r,s.box[0],s.box[1],s.box[2],s.box[3],a),a.drawLabels){let i=`${s.label} ${Math.round(100*s.score)}%`;a.shadowColor&&a.shadowColor!==""&&(r.fillStyle=a.shadowColor,r.fillText(i,s.box[0]+3,1+s.box[1]+a.lineHeight,s.box[2])),r.fillStyle=a.labelColor,r.fillText(i,s.box[0]+2,0+s.box[1]+a.lineHeight,s.box[2])}r.stroke()}}async function zI(e,t,n){let a=kn(Kr,n);if(!t||!e)return;let r=Po(e);r.lineJoin="round",r.font=a.font;for(let s=0;s<t.length;s++)if(a.drawBoxes){if(r.strokeStyle=a.color,r.fillStyle=a.color,sc(r,t[s].box[0],t[s].box[1],t[s].box[2],t[s].box[3],a),a.drawLabels){let i=`person #${s}`;a.shadowColor&&a.shadowColor!==""&&(r.fillStyle=a.shadowColor,r.fillText(i,t[s].box[0]+3,1+t[s].box[1]+a.lineHeight,t[s].box[2])),r.fillStyle=a.labelColor,r.fillText(i,t[s].box[0]+2,0+t[s].box[1]+a.lineHeight,t[s].box[2])}r.stroke()}}async function LI(e,t){if(!e||!t)return;Po(t).drawImage(e,0,0)}async function WI(e,t,n){if(!t||!t.performance||!t||!e)return null;let a=Ae(),r=kn(Kr,n),s=Promise.all([y5(e,t.face,r),A5(e,t.body,r),x5(e,t.hand,r),b5(e,t.object,r),g5(e,t.gesture,r)]);return t.performance.draw=Math.trunc(Ae()-a),s}var $de=e=>{let t=(p,c)=>Math.atan2(p[1]-c[1],p[0]-c[0]);if(!e.annotations.rightEyeIris||!e.annotations.leftEyeIris)return{bearing:0,strength:0};let n=[0,-.1],a=1,r=e.mesh[33][2]>e.mesh[263][2],s=r?e.mesh[473]:e.mesh[468],i=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],o=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=[(i[0]-s[0])/o[0]-n[0],a*(s[1]-i[1])/o[1]-n[1]],d=Math.sqrt(l[0]**2+l[1]**2);return d=Math.min(d,e.boxRaw[2]/2,e.boxRaw[3]/2),{bearing:(t([0,0],l)+Math.PI/2)%Math.PI,strength:d}},BI=(e,t)=>{let n=g=>{let y=Math.sqrt(g[0]*g[0]+g[1]*g[1]+g[2]*g[2]);return g[0]/=y,g[1]/=y,g[2]/=y,g},a=(g,y)=>{let A=g[0]-y[0],x=g[1]-y[1],b=g[2]-y[2];return[A,x,b]},r=(g,y)=>{let A=g[1]*y[2]-g[2]*y[1],x=g[2]*y[0]-g[0]*y[2],b=g[0]*y[1]-g[1]*y[0];return[A,x,b]},s=g=>{let[y,A,x,b,v,k,T,C,D]=g,O,F,S;return b<1?b>-1?(S=Math.asin(b),F=Math.atan2(-T,y),O=Math.atan2(-k,v)):(S=-Math.PI/2,F=-Math.atan2(C,D),O=0):(S=Math.PI/2,F=Math.atan2(C,D),O=0),isNaN(O)&&(O=0),isNaN(F)&&(F=0),isNaN(S)&&(S=0),{pitch:2*-O,yaw:2*-F,roll:2*-S}},i=g=>{let y=(x,b,v,k)=>Math.atan2(k-b,v-x);return{pitch:y(g[10][1],g[10][2],g[152][1],g[152][2]),yaw:y(g[33][0],g[33][2],g[263][0],g[263][2]),roll:y(g[33][0],g[33][1],g[263][0],g[263][1])}},o=e.meshRaw;if(!o||o.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,d=[o[10],o[152],o[234],o[454]].map(g=>[g[0]*t[0]/l,g[1]*t[1]/l,g[2]]),u=n(a(d[1],d[0])),p=n(a(d[3],d[2])),c=n(r(p,u));p=r(u,c);let h=[p[0],p[1],p[2],u[0],u[1],u[2],c[0],c[1],c[2]],f=s(h),m=o.length===478?$de(e):{bearing:0,strength:0};return{angle:f,matrix:h,gaze:m}};var v5=async(e,t)=>{var c,h,f,m;let n,a,r,s,i,o,l,d,u=[];e.state="run:face",n=Ae();let p=await L9(t,e.config);if(e.performance.face=Math.trunc(Ae()-n),!t.shape||t.shape.length!==4)return[];if(!p)return[];for(let g=0;g<p.length;g++){if(e.analyze("Get Face"),!p[g].tensor||p[g].tensor.isDisposedInternal){ie("Face object is disposed:",p[g].tensor);continue}let y=BI(p[g],[t.shape[2],t.shape[1]]);e.analyze("Start Emotion:"),e.config.async?i=e.config.face.emotion.enabled?$x(p[g].tensor||Lt([]),e.config,g,p.length):null:(e.state="run:emotion",n=Ae(),i=e.config.face.emotion.enabled?await $x(p[g].tensor||Lt([]),e.config,g,p.length):null,e.performance.emotion=Math.trunc(Ae()-n)),e.analyze("End Emotion:"),e.analyze("Start AntiSpoof:"),e.config.async?l=e.config.face.antispoof.enabled?dx(p[g].tensor||Lt([]),e.config,g,p.length):null:(e.state="run:antispoof",n=Ae(),l=e.config.face.antispoof.enabled?await dx(p[g].tensor||Lt([]),e.config,g,p.length):null,e.performance.antispoof=Math.trunc(Ae()-n)),e.analyze("End AntiSpoof:"),e.analyze("Start Description:"),e.config.async?d=e.config.face.description.enabled?Wx(p[g].tensor||Lt([]),e.config,g,p.length):null:(e.state="run:description",n=Ae(),d=e.config.face.description.enabled?await Wx(p[g].tensor||Lt([]),e.config,g,p.length):null,e.performance.embedding=Math.trunc(Ae()-n)),e.analyze("End Description:"),e.config.async&&([a,s,i,o,d,r,l]=await Promise.all([a,s,i,o,d,r,l])),e.analyze("Finish Face:"),!e.config.face.iris.enabled&&((h=(c=p[g])==null?void 0:c.annotations)==null?void 0:h.leftEyeIris)&&((m=(f=p[g])==null?void 0:f.annotations)==null?void 0:m.rightEyeIris)&&(delete p[g].annotations.leftEyeIris,delete p[g].annotations.rightEyeIris);let A=p[g].annotations&&p[g].annotations.leftEyeIris&&p[g].annotations.leftEyeIris[0]&&p[g].annotations.rightEyeIris&&p[g].annotations.rightEyeIris[0]&&p[g].annotations.leftEyeIris.length>0&&p[g].annotations.rightEyeIris.length>0&&p[g].annotations.leftEyeIris[0]!==null&&p[g].annotations.rightEyeIris[0]!==null?Math.max(Math.abs(p[g].annotations.leftEyeIris[3][0]-p[g].annotations.leftEyeIris[1][0]),Math.abs(p[g].annotations.rightEyeIris[4][1]-p[g].annotations.rightEyeIris[2][1]))/t.shape[2]:0,x=e.config.face.detector.return?st(p[g].tensor):null;Q(p[g].tensor),p[g].tensor&&delete p[g].tensor,u.push({...p[g],id:g,age:d==null?void 0:d.age,gender:d==null?void 0:d.gender,genderScore:d==null?void 0:d.genderScore,embedding:d==null?void 0:d.descriptor,emotion:i,real:l,iris:A!==0?Math.trunc(500/A/11.7)/100:0,rotation:y,tensor:x}),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 VI=e=>{if(!e)return[];let t=[];for(let n=0;n<e.length;n++){let a=e[n].keypoints.find(l=>l.part==="leftWrist"),r=e[n].keypoints.find(l=>l.part==="rightWrist"),s=e[n].keypoints.find(l=>l.part==="nose");s&&a&&r&&a.position[1]<s.position[1]&&r.position[1]<s.position[1]?t.push({body:n,gesture:"i give up"}):s&&a&&a.position[1]<s.position[1]?t.push({body:n,gesture:"raise left hand"}):s&&r&&r.position[1]<s.position[1]&&t.push({body:n,gesture:"raise right hand"});let i=e[n].keypoints.find(l=>l.part==="leftShoulder"),o=e[n].keypoints.find(l=>l.part==="rightShoulder");i&&o&&t.push({body:n,gesture:`leaning ${i.position[1]>o.position[1]?"left":"right"}`})}return t},UI=e=>{if(!e)return[];let t=[];for(let n=0;n<e.length;n++)if(e[n].mesh&&e[n].mesh.length>450){let a=e[n].mesh[33][2]-e[n].mesh[263][2];Math.abs(a)<10?t.push({face:n,gesture:"facing center"}):t.push({face:n,gesture:`facing ${a<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 i=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]));i>10&&t.push({face:n,gesture:`mouth ${Math.trunc(i)}% open`});let o=e[n].mesh[152][2];Math.abs(o)>10&&t.push({face:n,gesture:`head ${o<0?"up":"down"}`})}return t},jI=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 a=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],s=Math.abs(a*r),i=e[n].annotations.rightEyeIris[3][0]-e[n].annotations.rightEyeIris[1][0],o=e[n].annotations.rightEyeIris[4][1]-e[n].annotations.rightEyeIris[2][1],l=Math.abs(i*o),d=!1;Math.abs(s-l)/Math.max(s,l)<.25&&(d=!0,t.push({iris:n,gesture:"facing center"}));let p=Math.abs(e[n].mesh[33][0]-e[n].annotations.rightEyeIris[0][0])/e[n].box[2],c=Math.abs(e[n].mesh[263][0]-e[n].annotations.leftEyeIris[0][0])/e[n].box[2];(c>.06||p>.06)&&(d=!1),c>.06&&t.push({iris:n,gesture:"looking right"}),p>.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)&&(d=!1),(f<.01||h<.01)&&t.push({iris:n,gesture:"looking down"}),(f>.022||h>.022)&&t.push({iris:n,gesture:"looking up"}),d&&t.push({iris:n,gesture:"looking center"})}return t},GI=e=>{if(!e)return[];let t=[];for(let n=0;n<e.length;n++){let a=[];if(e[n].annotations)for(let[r,s]of Object.entries(e[n].annotations))r!=="palmBase"&&Array.isArray(s)&&s[0]&&a.push({name:r.toLowerCase(),position:s[0]});if(a&&a.length>0){let r=a.reduce((i,o)=>i.position[2]<o.position[2]?i:o);t.push({hand:n,gesture:`${r.name} forward`});let s=a.reduce((i,o)=>i.position[1]<o.position[1]?i:o);t.push({hand:n,gesture:`${s.name} up`})}if(e[n].keypoints){let r=uI(e[n].keypoints);for(let s of r)t.push({hand:n,gesture:s.name})}}return t};var Oe={face:[],body:[],hand:[],gesture:[],object:[],persons:[],performance:{},timestamp:0};function HI(e,t){var i,o,l,d,u,p,c,h,f,m,g,y,A,x,b,v,k,T,C,D,O,F,S,P,_,j,q;let n=Ae();if(!e)return{face:[],body:[],hand:[],gesture:[],object:[],persons:[],performance:{},timestamp:0};let a=Date.now()-e.timestamp,r=a<1e3?8-Math.log(a+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 z=0;z<e.body.length;z++){let X=e.body[z].box.map((Y,se)=>((r-1)*Oe.body[z].box[se]+Y)/r),Z=e.body[z].boxRaw.map((Y,se)=>((r-1)*Oe.body[z].boxRaw[se]+Y)/r),te=e.body[z].keypoints.map((Y,se)=>({score:Y.score,part:Y.part,position:[Oe.body[z].keypoints[se]?((r-1)*Oe.body[z].keypoints[se].position[0]+Y.position[0])/r:Y.position[0],Oe.body[z].keypoints[se]?((r-1)*Oe.body[z].keypoints[se].position[1]+Y.position[1])/r:Y.position[1]],positionRaw:[Oe.body[z].keypoints[se]?((r-1)*Oe.body[z].keypoints[se].positionRaw[0]+Y.positionRaw[0])/r:Y.position[0],Oe.body[z].keypoints[se]?((r-1)*Oe.body[z].keypoints[se].positionRaw[1]+Y.positionRaw[1])/r:Y.position[1]]})),J={},re={connected:{}};((o=(i=t.body)==null?void 0:i.modelPath)==null?void 0:o.includes("efficientpose"))?re=Cx:((d=(l=t.body)==null?void 0:l.modelPath)==null?void 0:d.includes("blazepose"))?re=bx:((p=(u=t.body)==null?void 0:u.modelPath)==null?void 0:p.includes("movenet"))&&(re=e5);for(let[Y,se]of Object.entries(re.connected)){let de=[];for(let be=0;be<se.length-1;be++){let ve=te.find(Ee=>Ee.part===se[be]),ke=te.find(Ee=>Ee.part===se[be+1]);ve&&ke&&ve.score>(t.body.minConfidence||0)&&ke.score>(t.body.minConfidence||0)&&de.push([ve.position,ke.position])}J[Y]=de}Oe.body[z]={...e.body[z],box:X,boxRaw:Z,keypoints:te,annotations:J}}if(!Oe.hand||e.hand.length!==Oe.hand.length)Oe.hand=JSON.parse(JSON.stringify(e.hand));else for(let z=0;z<e.hand.length;z++){let X=e.hand[z].box.map((re,Y)=>((r-1)*Oe.hand[z].box[Y]+re)/r),Z=e.hand[z].boxRaw.map((re,Y)=>((r-1)*Oe.hand[z].boxRaw[Y]+re)/r);Oe.hand[z].keypoints.length!==e.hand[z].keypoints.length&&(Oe.hand[z].keypoints=e.hand[z].keypoints);let te=e.hand[z].keypoints&&e.hand[z].keypoints.length>0?e.hand[z].keypoints.map((re,Y)=>re.map((se,de)=>((r-1)*(Oe.hand[z].keypoints[Y][de]||1)+(se||0))/r)):[],J={};if(Object.keys(Oe.hand[z].annotations).length!==Object.keys(e.hand[z].annotations).length)Oe.hand[z].annotations=e.hand[z].annotations,J=Oe.hand[z].annotations;else if(e.hand[z].annotations)for(let re of Object.keys(e.hand[z].annotations))J[re]=e.hand[z].annotations[re]&&e.hand[z].annotations[re][0]?e.hand[z].annotations[re].map((Y,se)=>Y.map((de,be)=>((r-1)*Oe.hand[z].annotations[re][se][be]+de)/r)):null;Oe.hand[z]={...e.hand[z],box:X,boxRaw:Z,keypoints:te,annotations:J}}if(!Oe.face||e.face.length!==Oe.face.length)Oe.face=JSON.parse(JSON.stringify(e.face));else for(let z=0;z<e.face.length;z++){let X=e.face[z].box.map((J,re)=>((r-1)*Oe.face[z].box[re]+J)/r),Z=e.face[z].boxRaw.map((J,re)=>((r-1)*Oe.face[z].boxRaw[re]+J)/r),te={matrix:[0,0,0,0,0,0,0,0,0],angle:{roll:0,yaw:0,pitch:0},gaze:{bearing:0,strength:0}};te.matrix=(c=e.face[z].rotation)==null?void 0:c.matrix,te.angle={roll:((r-1)*(((f=(h=Oe.face[z].rotation)==null?void 0:h.angle)==null?void 0:f.roll)||0)+(((g=(m=e.face[z].rotation)==null?void 0:m.angle)==null?void 0:g.roll)||0))/r,yaw:((r-1)*(((A=(y=Oe.face[z].rotation)==null?void 0:y.angle)==null?void 0:A.yaw)||0)+(((b=(x=e.face[z].rotation)==null?void 0:x.angle)==null?void 0:b.yaw)||0))/r,pitch:((r-1)*(((k=(v=Oe.face[z].rotation)==null?void 0:v.angle)==null?void 0:k.pitch)||0)+(((C=(T=e.face[z].rotation)==null?void 0:T.angle)==null?void 0:C.pitch)||0))/r},te.gaze={bearing:((r-1)*(((O=(D=Oe.face[z].rotation)==null?void 0:D.gaze)==null?void 0:O.bearing)||0)+(((S=(F=e.face[z].rotation)==null?void 0:F.gaze)==null?void 0:S.bearing)||0))/r,strength:((r-1)*(((_=(P=Oe.face[z].rotation)==null?void 0:P.gaze)==null?void 0:_.strength)||0)+(((q=(j=e.face[z].rotation)==null?void 0:j.gaze)==null?void 0:q.strength)||0))/r},Oe.face[z]={...e.face[z],rotation:te,box:X,boxRaw:Z}}if(!Oe.object||e.object.length!==Oe.object.length)Oe.object=JSON.parse(JSON.stringify(e.object));else for(let z=0;z<e.object.length;z++){let X=e.object[z].box.map((te,J)=>((r-1)*Oe.object[z].box[J]+te)/r),Z=e.object[z].boxRaw.map((te,J)=>((r-1)*Oe.object[z].boxRaw[J]+te)/r);Oe.object[z]={...e.object[z],box:X,boxRaw:Z}}if(e.persons){let z=e.persons;if(!Oe.persons||z.length!==Oe.persons.length)Oe.persons=JSON.parse(JSON.stringify(z));else for(let X=0;X<z.length;X++)Oe.persons[X].box=z[X].box.map((Z,te)=>((r-1)*Oe.persons[X].box[te]+Z)/r)}e.gesture&&(Oe.gesture=e.gesture);let s=Ae();return e.performance&&(Oe.performance={...e.performance,interpolate:Math.round(s-n)}),Oe}function tm(e,t,n={order:2}){let a=0;for(let r=0;r<e.length;r++){let s=n.order===2?e[r]-t[r]:Math.abs(e[r]-t[r]);a+=n.order===2?s*s:s**n.order}return a}function qI(e,t,n={order:2}){let a=tm(e,t,n),r=n.order===2?Math.sqrt(a):a**(1/n.order);return Math.max(0,100-r)/100}function XI(e,t,n={order:2,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 a=Number.MAX_SAFE_INTEGER,r=-1;for(let s=0;s<t.length;s++){let i=tm(e,t[s],{order:n.order});if(i<a&&(a=i,r=s),a<n.threshold)break}return a=n.order===2?Math.sqrt(a):a**(1/n.order),{index:r,distance:a,similarity:Math.max(0,100-a)/100}}function KI(e,t,n,a,r){var o,l,d,u,p,c,h,f,m,g,y,A,x,b,v,k;let s=0,i=[];for(let T of e){let C={id:s++,face:T,body:null,hands:{left:null,right:null},gestures:[],box:[0,0,0,0]};for(let _ of t)T.box[0]>_.box[0]&&T.box[0]<_.box[0]+_.box[2]&&T.box[1]+T.box[3]>_.box[1]&&T.box[1]+T.box[3]<_.box[1]+_.box[3]&&(C.body=_);if(C.body)for(let _ of n)_.box[0]+_.box[2]>C.body.box[0]&&_.box[0]+_.box[2]<C.body.box[0]+C.body.box[2]&&_.box[1]+_.box[3]>C.body.box[1]&&_.box[1]+_.box[3]<C.body.box[1]+C.body.box[3]&&C.hands&&(C.hands.left=_),_.box[0]<C.body.box[0]+C.body.box[2]&&_.box[0]>C.body.box[0]&&_.box[1]+_.box[3]>C.body.box[1]&&_.box[1]+_.box[3]<C.body.box[1]+C.body.box[3]&&C.hands&&(C.hands.right=_);for(let _ of a)_.face!==void 0&&_.face===T.id?(o=C.gestures)==null||o.push(_):_.iris!==void 0&&_.iris===T.id?(l=C.gestures)==null||l.push(_):_.body!==void 0&&_.body===((d=C.body)==null?void 0:d.id)?(u=C.gestures)==null||u.push(_):_.hand!==void 0&&_.hand===((c=(p=C.hands)==null?void 0:p.left)==null?void 0:c.id)?(h=C.gestures)==null||h.push(_):_.hand!==void 0&&_.hand===((m=(f=C.hands)==null?void 0:f.right)==null?void 0:m.id)&&((g=C.gestures)==null||g.push(_));let D=[],O=[],F=_=>{_&&_.length===4&&(D.push(_[0],_[0]+_[2]),O.push(_[1],_[1]+_[3]))};F((y=C.face)==null?void 0:y.box),F((A=C.body)==null?void 0:A.box),F((b=(x=C.hands)==null?void 0:x.left)==null?void 0:b.box),F((k=(v=C.hands)==null?void 0:v.right)==null?void 0:k.box);let S=Math.min(...D),P=Math.min(...O);C.box=[S,P,Math.max(...D)-S,Math.max(...O)-P],r&&r[1]&&r[2]&&(C.boxRaw=[C.box[0]/r[2],C.box[1]/r[1],C.box[2]/r[2],C.box[3]/r[1]]),i.push(C)}return i}var nm=`
|
|
/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==`,am=`
|
|
/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 Ode(e){let t=(r,s="application/octet-stream")=>fetch(`data:${s};base64,${r}`).then(i=>i.blob()),n,a;switch(e.config.warmup){case"face":n=await t(nm);break;case"body":case"full":n=await t(am);break;default:n=null}if(n){let r=await createImageBitmap(n);a=await e.detect(r,e.config),r.close()}return a}async function _de(e){return new Promise(t=>{let n;switch(e.config.warmup){case"face":n="data:image/jpeg;base64,"+nm;break;case"full":case"body":n="data:image/jpeg;base64,"+am;break;default:n=null}let a;typeof Image!="undefined"?a=new Image:xe.Image&&(a=new xe.Image),a.onload=async()=>{let r=zn(a.naturalWidth,a.naturalHeight);if(!r)ie("Warmup: Canvas not found"),t({});else{let s=r.getContext("2d");s&&s.drawImage(a,0,0);let i=await e.image(r),o=await e.detect(i.tensor,e.config);t(o)}},n?a.src=n:t(null)})}async function Pde(e){let t=r=>Buffer.from(r,"base64"),n;if(e.config.warmup==="face"&&(n=t(nm)),(e.config.warmup==="body"||e.config.warmup==="full")&&(n=t(am)),!n)return null;let a;if(typeof void 0!="undefined"){let r=(void 0).decodeJpeg(n),s=r.expandDims(0);e.tf.dispose(r),a=await e.detect(s,e.config),e.tf.dispose(s)}else e.config.debug&&ie("Warmup tfjs-node not loaded");return a}async function ZI(e,t){let n=Ae();if(e.state="warmup",t&&(e.config=kn(e.config,t)),!e.config.warmup||e.config.warmup==="none")return{error:"null"};let a;return new Promise(async r=>{typeof createImageBitmap=="function"?a=await Ode(e):typeof Image!="undefined"||xe.Canvas!==void 0?a=await _de(e):a=await Pde(e);let s=Ae();e.config.debug&&ie("Warmup",e.config.warmup,Math.round(s-n),"ms"),e.emit("warmup"),r(a)})}var Zu,ic,oc,rm,JI=class{constructor(t){ce(this,"version");ce(this,"config");ce(this,"result");ce(this,"state");ce(this,"process");ce(this,"tf");ce(this,"env");ce(this,"draw");ce(this,"models");ce(this,"events");ce(this,"faceTriangulation");ce(this,"faceUVMap");ce(this,"performance");pd(this,Zu,void 0);pd(this,ic,void 0);pd(this,oc,void 0);ce(this,"gl");ce(this,"analyze",(...t)=>{if(!dd(this,ic))return;let n=this.tf.engine().state.numTensors,a=dd(this,Zu);cd(this,Zu,n);let r=n-a;r!==0&&ie(...t,r)});pd(this,rm,t=>{if(!dd(this,oc))return null;if(!t)return"input is not defined";if(this.env.node&&!(t instanceof je))return"input must be a tensor";try{this.tf.getBackend()}catch(n){return"backend not loaded"}return null});ce(this,"similarity",qI);ce(this,"distance",tm);ce(this,"match",XI);ce(this,"emit",t=>{var n;this.events&&this.events.dispatchEvent&&((n=this.events)==null||n.dispatchEvent(new Event(t)))});this.env=xe,ss.wasmPath=Ud.includes("-")?"https://vladmandic.github.io/tfjs/dist/":`https://cdn.jsdelivr.net/npm/@tensorflow/tfjs-backend-wasm@${Ud}/dist/`,ss.modelBasePath=xe.browser?"../models/":"file://models/",ss.backend=xe.browser?"humangl":"tensorflow",this.version=lx,Object.defineProperty(this,"version",{value:lx}),this.config=JSON.parse(JSON.stringify(ss)),Object.seal(this.config),t&&(this.config=kn(this.config,t)),this.tf=Ro,this.state="idle",cd(this,Zu,0),cd(this,ic,!1),cd(this,oc,!1),this.performance={backend:0,load:0,image:0,frames:0,cached:0,changed:0,total:0,draw:0},this.events=typeof EventTarget!="undefined"?new EventTarget:void 0,this.models=new rc,this.draw={options:Kr,canvas:(n,a)=>LI(n,a),face:(n,a,r)=>y5(n,a,r),body:(n,a,r)=>A5(n,a,r),hand:(n,a,r)=>x5(n,a,r),gesture:(n,a,r)=>g5(n,a,r),object:(n,a,r)=>b5(n,a,r),person:(n,a,r)=>zI(n,a,r),all:(n,a,r)=>WI(n,a,r)},this.result={face:[],body:[],hand:[],gesture:[],object:[],performance:{},timestamp:0,persons:[]},this.process={tensor:null,canvas:null},this.faceTriangulation=B9,this.faceUVMap=V9,this.gl=Ot,this.emit("create")}reset(){let t=this.config.backend;this.config=JSON.parse(JSON.stringify(ss)),this.config.backend=t}validate(t){return M1(ss,t||this.config)}now(){return Ae()}image(t,n=!0){return Uu(t,this.config,n)}async segmentation(t,n){return FI(t,n,this.config)}enhance(t){return Lx(t)}async init(){await em(this,!0),await this.tf.ready()}async load(t){this.state="load";let n=Ae(),a=Object.values(this.models).filter(i=>i).length;t&&(this.config=kn(this.config,t)),xe.initial&&(this.config.debug&&ie(`version: ${this.version}`),this.config.debug&&ie(`tfjs version: ${this.tf.version_core}`),await em(this)||ie("error: backend check failed"),await $h(),this.env.browser&&(this.config.debug&&ie("configuration:",this.config),this.config.debug&&ie("tf flags:",this.tf.ENV.flags))),await DI(this),xe.initial&&this.config.debug&&ie("tf engine state:",this.tf.engine().state.numBytes,"bytes",this.tf.engine().state.numTensors,"tensors"),xe.initial=!1,Object.values(this.models).filter(i=>i).length!==a&&(await $I(this),this.emit("load"));let s=Math.trunc(Ae()-n);s>(this.performance.load||0)&&(this.performance.load=s)}next(t=this.result){return HI(t,this.config)}async warmup(t){return ZI(this,t)}async detect(t,n){return this.state="detect",new Promise(async a=>{var y,A,x,b,v,k,T,C,D,O,F,S,P,_,j,q,z,X,Z,te,J,re;this.state="config";let r,s;this.config=kn(this.config,n),this.state="check";let i=dd(this,rm).call(this,t);i&&(ie(i,t),a({error:i}));let o=Ae();await em(this),await this.load(),r=Ae(),this.state="image";let l=Uu(t,this.config);if(this.process=l,this.performance.image=Math.trunc(Ae()-r),this.analyze("Get Image:"),!l.tensor){this.config.debug&&ie("could not convert input to tensor"),a({error:"could not convert input to tensor"});return}this.emit("image"),r=Ae(),this.config.skipFrame=await s9(this.config,l.tensor),this.performance.frames||(this.performance.frames=0),this.performance.cached||(this.performance.cached=0),this.performance.frames++,this.config.skipFrame&&this.performance.cached++,this.performance.changed=Math.trunc(Ae()-r),this.analyze("Check Changed:");let d=[],u=[],p=[],c=[];this.state="detect:face",this.config.async?(d=this.config.face.enabled?v5(this,l.tensor):[],this.performance.face&&delete this.performance.face):(r=Ae(),d=this.config.face.enabled?await v5(this,l.tensor):[],s=Math.trunc(Ae()-r),s>0&&(this.performance.face=s)),this.config.async&&(this.config.body.maxDetected===-1||this.config.hand.maxDetected===-1)&&(d=await d),this.analyze("Start Body:"),this.state="detect:body";let h=this.config.body.maxDetected===-1?kn(this.config,{body:{maxDetected:this.config.face.enabled?1*d.length:1}}):this.config;this.config.async?(((y=this.config.body.modelPath)==null?void 0:y.includes("posenet"))?u=this.config.body.enabled?p5(l.tensor,h):[]:((A=this.config.body.modelPath)==null?void 0:A.includes("blazepose"))?u=this.config.body.enabled?kx(l.tensor,h):[]:((x=this.config.body.modelPath)==null?void 0:x.includes("efficientpose"))?u=this.config.body.enabled?Mx(l.tensor,h):[]:((b=this.config.body.modelPath)==null?void 0:b.includes("movenet"))&&(u=this.config.body.enabled?a5(l.tensor,h):[]),this.performance.body&&delete this.performance.body):(r=Ae(),((v=this.config.body.modelPath)==null?void 0:v.includes("posenet"))?u=this.config.body.enabled?await p5(l.tensor,h):[]:((k=this.config.body.modelPath)==null?void 0:k.includes("blazepose"))?u=this.config.body.enabled?await kx(l.tensor,h):[]:((T=this.config.body.modelPath)==null?void 0:T.includes("efficientpose"))?u=this.config.body.enabled?await Mx(l.tensor,h):[]:((C=this.config.body.modelPath)==null?void 0:C.includes("movenet"))&&(u=this.config.body.enabled?await a5(l.tensor,h):[]),s=Math.trunc(Ae()-r),s>0&&(this.performance.body=s)),this.analyze("End Body:"),this.analyze("Start Hand:"),this.state="detect:hand";let f=this.config.hand.maxDetected===-1?kn(this.config,{hand:{maxDetected:this.config.face.enabled?2*d.length:1}}):this.config;this.config.async?(((O=(D=this.config.hand.detector)==null?void 0:D.modelPath)==null?void 0:O.includes("handdetect"))?p=this.config.hand.enabled?Gx(l.tensor,f):[]:((S=(F=this.config.hand.detector)==null?void 0:F.modelPath)==null?void 0:S.includes("handtrack"))&&(p=this.config.hand.enabled?Zx(l.tensor,f):[]),this.performance.hand&&delete this.performance.hand):(r=Ae(),((_=(P=this.config.hand.detector)==null?void 0:P.modelPath)==null?void 0:_.includes("handdetect"))?p=this.config.hand.enabled?await Gx(l.tensor,f):[]:((q=(j=this.config.hand.detector)==null?void 0:j.modelPath)==null?void 0:q.includes("handtrack"))&&(p=this.config.hand.enabled?await Zx(l.tensor,f):[]),s=Math.trunc(Ae()-r),s>0&&(this.performance.hand=s)),this.analyze("End Hand:"),this.analyze("Start Object:"),this.state="detect:object",this.config.async?(((z=this.config.object.modelPath)==null?void 0:z.includes("nanodet"))?c=this.config.object.enabled?s5(l.tensor,this.config):[]:((X=this.config.object.modelPath)==null?void 0:X.includes("centernet"))&&(c=this.config.object.enabled?Sx(l.tensor,this.config):[]),this.performance.object&&delete this.performance.object):(r=Ae(),((Z=this.config.object.modelPath)==null?void 0:Z.includes("nanodet"))?c=this.config.object.enabled?await s5(l.tensor,this.config):[]:((te=this.config.object.modelPath)==null?void 0:te.includes("centernet"))&&(c=this.config.object.enabled?await Sx(l.tensor,this.config):[]),s=Math.trunc(Ae()-r),s>0&&(this.performance.object=s)),this.analyze("End Object:"),this.state="detect:await",this.config.async&&([d,u,p,c]=await Promise.all([d,u,p,c])),this.state="detect:gesture";let m=[];this.config.gesture.enabled&&(r=Ae(),m=[...UI(d),...VI(u),...GI(p),...jI(d)],this.config.async?this.performance.gesture&&delete this.performance.gesture:this.performance.gesture=Math.trunc(Ae()-r)),this.performance.total=Math.trunc(Ae()-o);let g=((re=(J=this.process)==null?void 0:J.tensor)==null?void 0:re.shape)||[];this.result={face:d,body:u,hand:p,gesture:m,object:c,performance:this.performance,canvas:this.process.canvas,timestamp:Date.now(),get persons(){return KI(d,u,p,m,g)}},Q(l.tensor),this.emit("detect"),this.state="idle",a(this.result)})}};Zu=new WeakMap,ic=new WeakMap,oc=new WeakMap,rm=new WeakMap;return zde;})();
|
|
/**
|
|
* @license
|
|
* Copyright 2017 Google LLC. All Rights Reserved.
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
* =============================================================================
|
|
*/
|
|
/**
|
|
* @license
|
|
* Copyright 2018 Google LLC
|
|
*
|
|
* Use of this source code is governed by an MIT-style
|
|
* license that can be found in the LICENSE file or at
|
|
* https://opensource.org/licenses/MIT.
|
|
* =============================================================================
|
|
*/
|
|
/**
|
|
* @license
|
|
* Copyright 2018 Google LLC. All Rights Reserved.
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*
|
|
* =============================================================================
|
|
*/
|
|
/**
|
|
* @license
|
|
* Copyright 2018 Google LLC. All Rights Reserved.
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
* =============================================================================
|
|
*/
|
|
/**
|
|
* @license
|
|
* Copyright 2019 Google LLC
|
|
*
|
|
* Use of this source code is governed by an MIT-style
|
|
* license that can be found in the LICENSE file or at
|
|
* https://opensource.org/licenses/MIT.
|
|
* =============================================================================
|
|
*/
|
|
/**
|
|
* @license
|
|
* Copyright 2019 Google LLC. All Rights Reserved.
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*
|
|
* =============================================================================
|
|
*/
|
|
/**
|
|
* @license
|
|
* Copyright 2019 Google LLC. All Rights Reserved.
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
* =============================================================================
|
|
*/
|
|
/**
|
|
* @license
|
|
* Copyright 2020 Google Inc. All Rights Reserved.
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
* =============================================================================
|
|
*/
|
|
/**
|
|
* @license
|
|
* Copyright 2020 Google LLC
|
|
*
|
|
* Use of this source code is governed by an MIT-style
|
|
* license that can be found in the LICENSE file or at
|
|
* https://opensource.org/licenses/MIT.
|
|
* =============================================================================
|
|
*/
|
|
/**
|
|
* @license
|
|
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
* =============================================================================
|
|
*/
|
|
/**
|
|
* @license
|
|
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
* Licensed under the Apache License, Version 2.0 (the License);
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an AS IS BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
* =============================================================================
|
|
*/
|
|
/**
|
|
* @license
|
|
* Copyright 2021 Google LLC. All Rights Reserved.
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
* =============================================================================
|
|
*/
|
|
/**
|
|
* @license
|
|
* Copyright 2021 Google LLC. All Rights Reserved.
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* https://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
* =============================================================================
|
|
*/
|
|
/**
|
|
* @license
|
|
* Copyright 2018 Google LLC. All Rights Reserved.
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
* =============================================================================
|
|
*/
|
|
/** @license See the LICENSE file. */
|