mirror of https://github.com/vladmandic/human
5223 lines
1.5 MiB
5223 lines
1.5 MiB
|
|
/*
|
|
Human library
|
|
homepage: <https://github.com/vladmandic/human>
|
|
author: <https://github.com/vladmandic>'
|
|
*/
|
|
var Q_=Object.defineProperty;var Qg=e=>{if(typeof require!="undefined")return require(e);throw new Error('Dynamic require of "'+e+'" is not supported')};var _3=(e,t)=>{for(var n in t)Q_(e,n,{get:t[n],enumerable:!0})};var R3=(e,t,n)=>{if(!t.has(e))throw TypeError("Cannot "+n)};var Fn=(e,t,n)=>(R3(e,t,"read from private field"),n?n.call(e):t.get(e)),Ir=(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)},Qr=(e,t,n,r)=>(R3(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n);function $t(e,t){let n=e.endsWith("/")?"":"/",s=t.startsWith(".")||t.startsWith("/")||t.startsWith("http:")||t.startsWith("https:")||t.startsWith("file:")?`${t}`:`${e}${n}${t}`;if(!s.toLocaleLowerCase().includes(".json"))throw new Error(`Human: ModelPath Error: ${s} Expecting JSON file`);return s}function me(...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 at=()=>typeof performance!="undefined"?performance.now():parseInt((Number(process.hrtime.bigint())/1e3/1e3).toString());function ir(...e){let t=n=>n&&typeof n=="object";return e.reduce((n,r)=>(Object.keys(r||{}).forEach(s=>{let a=n[s],o=r[s];Array.isArray(a)&&Array.isArray(o)?n[s]=a.concat(...o):t(a)&&t(o)?n[s]=ir(a,o):n[s]=o}),n),{})}var D3={backend:"webgl",modelBasePath:"../models/",wasmPath:"../node_modules/@tensorflow/tfjs-backend-wasm/dist/",debug:!0,async:!0,warmup:"full",cacheSensitivity:.75,skipFrame:!1,filter:{enabled:!0,width:0,height:0,flip:!1,return:!0,brightness:0,contrast:0,sharpness:0,blur:0,saturation:0,hue:0,negative:!1,sepia:!1,vintage:!1,kodachrome:!1,technicolor:!1,polaroid:!1,pixelate:0},gesture:{enabled:!0},face:{enabled:!0,detector:{modelPath:"blazeface.json",rotation:!0,maxDetected:15,skipFrames:15,minConfidence:.2,iouThreshold:.1,return:!1},mesh:{enabled:!0,modelPath:"facemesh.json"},iris:{enabled:!0,modelPath:"iris.json"},description:{enabled:!0,modelPath:"faceres.json",skipFrames:11,minConfidence:.1},emotion:{enabled:!0,minConfidence:.1,skipFrames:17,modelPath:"emotion.json"}},body:{enabled:!0,modelPath:"movenet-lightning.json",maxDetected:1,minConfidence:.2,skipFrames:1},hand:{enabled:!0,rotation:!0,skipFrames:18,minConfidence:.1,iouThreshold:.1,maxDetected:2,landmarks:!0,detector:{modelPath:"handdetect.json"},skeleton:{modelPath:"handskeleton.json"}},object:{enabled:!1,modelPath:"mb3-centernet.json",minConfidence:.2,iouThreshold:.4,maxDetected:10,skipFrames:19},segmentation:{enabled:!1,modelPath:"selfie.json"}};function F3(){let e,t;if(typeof navigator!="undefined"){let n=navigator.userAgent.match(/\(([^()]+)\)/g);if(n&&n[0]){let r=n[0].match(/\(([^()]+)\)/g);e=r?r[0].replace(/\(|\)/g,""):"",t=navigator.userAgent.replace(n[0],""),e[1]&&(t=t.replace(n[1],"")),t=t.replace(/ /g," ")}}else typeof process!="undefined"&&(e=`${process.platform} ${process.arch}`,t=`NodeJS ${process.version}`);return{platform:e,agent:t}}var bh={};_3(bh,{Abs:()=>Q3,Acos:()=>ev,Acosh:()=>tv,AdadeltaOptimizer:()=>Fp,AdagradOptimizer:()=>Mp,AdamOptimizer:()=>Op,AdamaxOptimizer:()=>Pp,Add:()=>i2,AddN:()=>nv,All:()=>rv,Any:()=>sv,ArgMax:()=>av,ArgMin:()=>ov,Asin:()=>iv,Asinh:()=>lv,Atan:()=>uv,Atan2:()=>dv,Atanh:()=>cv,AvgPool:()=>hv,AvgPool3D:()=>pv,AvgPool3DGrad:()=>sD,AvgPoolGrad:()=>rD,BackendWasm:()=>u$,BatchMatMul:()=>fv,BatchToSpaceND:()=>mv,Bincount:()=>gv,BroadcastTo:()=>aD,Callback:()=>z8,CallbackList:()=>TS,Cast:()=>l2,Ceil:()=>yv,ClipByValue:()=>Av,Complex:()=>xv,ComplexAbs:()=>bv,Concat:()=>vv,Conv2D:()=>wv,Conv2DBackpropFilter:()=>kv,Conv2DBackpropInput:()=>Iv,Conv3D:()=>Sv,Conv3DBackpropFilterV2:()=>oD,Conv3DBackpropInputV2:()=>Tv,Cos:()=>Nv,Cosh:()=>Cv,CropAndResize:()=>$v,Cumsum:()=>Ev,CustomCallback:()=>CS,DataStorage:()=>OR,DenseBincount:()=>_v,DepthToSpace:()=>Rv,DepthwiseConv2dNative:()=>Dv,DepthwiseConv2dNativeBackpropFilter:()=>Fv,DepthwiseConv2dNativeBackpropInput:()=>Mv,Diag:()=>Ov,Dilation2D:()=>Pv,Dilation2DBackpropFilter:()=>lD,Dilation2DBackpropInput:()=>iD,ENV:()=>Sr,EarlyStopping:()=>B8,Einsum:()=>Lv,Elu:()=>Bv,EluGrad:()=>uD,Environment:()=>Y3,Equal:()=>Vv,Erf:()=>Wv,Exp:()=>Uv,ExpandDims:()=>Hv,Expm1:()=>Gv,FFT:()=>jv,Fill:()=>qv,FlipLeftRight:()=>Kv,Floor:()=>Xv,FloorDiv:()=>Zv,FromPixels:()=>d2,FusedBatchNorm:()=>Yv,FusedConv2D:()=>p2,FusedDepthwiseConv2D:()=>f2,GPGPUContext:()=>Bm,GatherNd:()=>Qv,GatherV2:()=>Jv,GraphModel:()=>AT,Greater:()=>ew,GreaterEqual:()=>tw,History:()=>NS,IFFT:()=>nw,Identity:()=>u2,Imag:()=>rw,InputSpec:()=>tn,IsFinite:()=>sw,IsInf:()=>aw,IsNan:()=>ow,KernelBackend:()=>L3,LRN:()=>gw,LRNGrad:()=>dD,LayerVariable:()=>vS,LayersModel:()=>pa,LeakyRelu:()=>iw,Less:()=>lw,LessEqual:()=>uw,LinSpace:()=>cw,Log:()=>dw,Log1p:()=>hw,LogSoftmax:()=>cD,LogicalAnd:()=>pw,LogicalNot:()=>fw,LogicalOr:()=>mw,MathBackendCPU:()=>$5,MathBackendWebGL:()=>dh,Max:()=>yw,MaxPool:()=>xw,MaxPool3D:()=>bw,MaxPool3DGrad:()=>pD,MaxPoolGrad:()=>hD,MaxPoolWithArgmax:()=>vw,Maximum:()=>Aw,Mean:()=>ww,Min:()=>kw,Minimum:()=>Iw,MirrorPad:()=>Sw,Mod:()=>Tw,MomentumOptimizer:()=>zp,Multinomial:()=>Nw,Multiply:()=>Cw,Neg:()=>Ew,NonMaxSuppressionV3:()=>_w,NonMaxSuppressionV4:()=>Rw,NonMaxSuppressionV5:()=>Dw,NotEqual:()=>$w,OP_SCOPE_SUFFIX:()=>Z7,OneHot:()=>Mw,OnesLike:()=>Fw,Optimizer:()=>Ra,Pack:()=>Ow,PadV2:()=>Pw,Pool:()=>fD,Pow:()=>zw,Prelu:()=>Lw,Prod:()=>Bw,RMSPropOptimizer:()=>Lp,RNN:()=>fa,Range:()=>Ww,Rank:()=>x2,Real:()=>Vw,RealDiv:()=>zv,Reciprocal:()=>Uw,Reduction:()=>Pn,Relu:()=>Hw,Relu6:()=>Kw,Reshape:()=>Gw,ResizeBilinear:()=>qw,ResizeBilinearGrad:()=>gD,ResizeNearestNeighbor:()=>jw,ResizeNearestNeighborGrad:()=>mD,Reverse:()=>Xw,RotateWithOffset:()=>D7,Round:()=>Zw,Rsqrt:()=>Yw,SGDOptimizer:()=>mc,ScatterNd:()=>Jw,Select:()=>Qw,Selu:()=>e7,Sequential:()=>pm,Sigmoid:()=>a7,Sign:()=>s7,Sin:()=>n7,Sinh:()=>r7,Slice:()=>t7,Softmax:()=>d7,Softplus:()=>o7,SpaceToBatchND:()=>u7,SparseFillEmptyRows:()=>h7,SparseReshape:()=>p7,SparseSegmentMean:()=>f7,SparseSegmentSum:()=>m7,SparseToDense:()=>g7,SplitV:()=>c7,Sqrt:()=>i7,Square:()=>yD,SquaredDifference:()=>y7,Step:()=>R7,StridedSlice:()=>A7,StringNGrams:()=>x7,StringSplit:()=>b7,StringToHashBucketFast:()=>v7,Sub:()=>w7,Sum:()=>l7,SymbolicTensor:()=>ps,Tan:()=>k7,Tanh:()=>I7,Tensor:()=>Tt,TensorBuffer:()=>up,Tile:()=>c2,TopK:()=>S7,Transform:()=>T7,Transpose:()=>N7,Unique:()=>C7,Unpack:()=>E7,UnsortedSegmentSum:()=>$7,Variable:()=>rc,ZerosLike:()=>_7,_FusedMatMul:()=>h2,abs:()=>Nr,acos:()=>PM,acosh:()=>LM,add:()=>Me,addN:()=>X2,all:()=>VM,any:()=>HM,argMax:()=>Z2,argMin:()=>qM,asin:()=>XM,asinh:()=>YM,atan:()=>QM,atan2:()=>tO,atanh:()=>rO,avgPool:()=>Bk,avgPool3d:()=>pO,backend:()=>EM,backend_util:()=>E4,basicLSTMCell:()=>xO,batchNorm:()=>Ap,batchNorm2d:()=>IO,batchNorm3d:()=>TO,batchNorm4d:()=>CO,batchToSpaceND:()=>Wk,bincount:()=>Vk,booleanMaskAsync:()=>PB,broadcastTo:()=>xp,browser:()=>Hr,buffer:()=>Ys,callbacks:()=>_re,cast:()=>Pt,ceil:()=>RO,clipByValue:()=>FO,clone:()=>Js,complex:()=>go,concat:()=>an,concat1d:()=>OO,concat2d:()=>lc,concat3d:()=>LO,concat4d:()=>WO,constraints:()=>eS,conv1d:()=>HO,conv2d:()=>bp,conv2dTranspose:()=>qO,conv3d:()=>XO,conv3dTranspose:()=>QO,copyRegisteredKernels:()=>vD,cos:()=>tP,cosh:()=>rP,cosineWindow:()=>cy,cumsum:()=>aP,customGrad:()=>Ns,data:()=>xT,denseBincount:()=>iP,deprecationWarn:()=>Fk,depthToSpace:()=>uP,depthwiseConv2d:()=>ey,deregisterOp:()=>Dre,device_util:()=>j7,diag:()=>hP,dilation2d:()=>fP,disableDeprecationWarnings:()=>AM,dispose:()=>Ve,disposeVariables:()=>xM,div:()=>Qe,divNoNan:()=>bP,dot:()=>wP,dropout:()=>ZB,einsum:()=>IP,elu:()=>jk,enableDebugMode:()=>yM,enableProdMode:()=>gM,enclosingPowerOfTwo:()=>b4,engine:()=>bM,env:()=>ct,equal:()=>Gk,erf:()=>NP,exp:()=>wo,expandDims:()=>ea,expm1:()=>_P,eye:()=>qk,fft:()=>iy,fill:()=>wp,findBackend:()=>q2,findBackendFactory:()=>CM,floor:()=>Kk,floorDiv:()=>Ok,forceHalfFloat:()=>bE,fused:()=>v4,gather:()=>Xk,gatherND:()=>qB,gather_util:()=>mk,getBackend:()=>TM,getGradient:()=>m2,getKernel:()=>rp,getKernelsForBackend:()=>Li,gpgpu_util:()=>vC,grad:()=>ez,grads:()=>tz,greater:()=>kp,greaterEqual:()=>Zk,ifft:()=>Ep,imag:()=>ty,image:()=>Ye,inTopKAsync:()=>JB,initializers:()=>iS,input:()=>YS,io:()=>ik,irfft:()=>f4,isFinite:()=>BP,isInf:()=>VP,isNaN:()=>HP,keep:()=>Mk,kernel_impls:()=>D4,layers:()=>AS,leakyRelu:()=>Yk,less:()=>qP,lessEqual:()=>ny,linalg:()=>PV,linspace:()=>XP,loadGraphModel:()=>Et,loadLayersModel:()=>Vte,localResponseNormalization:()=>YP,log:()=>uc,log1p:()=>Jk,logSigmoid:()=>iz,logSoftmax:()=>hz,logSumExp:()=>n4,logicalAnd:()=>Sp,logicalNot:()=>r4,logicalOr:()=>s4,logicalXor:()=>kz,losses:()=>zV,matMul:()=>yt,math:()=>pk,max:()=>_a,maxPool:()=>a4,maxPool3d:()=>Tz,maxPoolWithArgmax:()=>Cz,maximum:()=>o4,mean:()=>Tp,memory:()=>vM,meshgrid:()=>_z,metrics:()=>M8,min:()=>sy,minimum:()=>i4,mirrorPad:()=>Mz,mod:()=>Pz,model:()=>Bte,models:()=>O8,moments:()=>Bz,movingAverage:()=>BB,mul:()=>fe,multiRNNCell:()=>Vz,multinomial:()=>Hz,neg:()=>$a,nextFrame:()=>UV,norm:()=>uy,notEqual:()=>l4,oneHot:()=>B2,ones:()=>ko,onesLike:()=>qz,op:()=>H,outerProduct:()=>Xz,pad:()=>dc,pad1d:()=>Jz,pad2d:()=>eL,pad3d:()=>nL,pad4d:()=>sL,pool:()=>uL,pow:()=>hc,prelu:()=>c4,print:()=>ok,prod:()=>pL,profile:()=>wM,rand:()=>mL,randomGamma:()=>xL,randomNormal:()=>vL,randomUniform:()=>d4,range:()=>pc,ready:()=>SM,real:()=>Np,reciprocal:()=>SL,registerBackend:()=>K2,registerCallbackConstructor:()=>Ute,registerGradient:()=>AD,registerKernel:()=>sp,registerOp:()=>Rre,regularizers:()=>P8,relu:()=>Cp,relu6:()=>h4,removeBackend:()=>NM,reshape:()=>ue,reverse:()=>Io,reverse1d:()=>$L,reverse2d:()=>RL,reverse3d:()=>FL,reverse4d:()=>OL,rfft:()=>ly,round:()=>p4,rsqrt:()=>LL,scalar:()=>ut,scatterND:()=>VB,scatter_util:()=>yk,selu:()=>WL,separableConv2d:()=>UL,sequential:()=>Wte,serialization:()=>Ek,setBackend:()=>IM,setPlatform:()=>$M,setWasmPath:()=>Nve,setWasmPaths:()=>Cve,setWebGLContext:()=>Dm,setdiff1dAsync:()=>GL,shared:()=>UT,sigmoid:()=>Ts,sign:()=>qL,signal:()=>OV,sin:()=>XL,sinh:()=>YL,slice:()=>Ze,slice1d:()=>QL,slice2d:()=>tB,slice3d:()=>rB,slice4d:()=>aB,slice_util:()=>U2,softmax:()=>iB,softplus:()=>e4,spaceToBatchND:()=>u4,sparse:()=>LV,sparseToDense:()=>GB,spectral:()=>MV,split:()=>ta,sqrt:()=>na,square:()=>ns,squaredDifference:()=>m4,squeeze:()=>Zn,stack:()=>So,step:()=>g4,stridedSlice:()=>xB,string:()=>BV,sub:()=>He,sum:()=>_t,sumOutType:()=>UD,tan:()=>vB,tanh:()=>Q2,tensor:()=>ts,tensor1d:()=>lr,tensor2d:()=>ra,tensor3d:()=>mp,tensor4d:()=>wB,tensor5d:()=>kB,tensor6d:()=>IB,tensor_util:()=>W7,test_util:()=>_k,tidy:()=>Ue,tile:()=>vp,time:()=>kM,topk:()=>TB,train:()=>WV,transpose:()=>fp,truncatedNormal:()=>CB,unique:()=>$B,unregisterGradient:()=>bD,unregisterKernel:()=>xD,unsortedSegmentSum:()=>RB,unstack:()=>fc,upcastType:()=>cp,util:()=>F7,valueAndGrad:()=>nz,valueAndGrads:()=>rz,variable:()=>FB,variableGrads:()=>Qk,version:()=>_ve,version_converter:()=>Ose,version_core:()=>mM,version_cpu:()=>yoe,version_layers:()=>ex,version_wasm:()=>Eve,version_webgl:()=>pfe,webgl:()=>ffe,webgl_util:()=>XN,where:()=>Gi,whereAsync:()=>A4,zeros:()=>ji,zerosLike:()=>Cr});var eR=Object.create,Qh=Object.defineProperty,tR=Object.getOwnPropertyDescriptor,nR=Object.getOwnPropertyNames,rR=Object.getPrototypeOf,sR=Object.prototype.hasOwnProperty,aR=e=>Qh(e,"__esModule",{value:!0}),co=e=>{if(typeof Qg!="undefined")return Qg(e);throw new Error('Dynamic require of "'+e+'" is not supported')},Ot=(e,t)=>function(){return t||(0,e[Object.keys(e)[0]])((t={exports:{}}).exports,t),t.exports},De=(e,t)=>{for(var n in t)Qh(e,n,{get:t[n],enumerable:!0})},oR=(e,t,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of nR(t))!sR.call(e,r)&&r!=="default"&&Qh(e,r,{get:()=>t[r],enumerable:!(n=tR(t,r))||n.enumerable});return e},Ks=e=>oR(aR(Qh(e!=null?eR(rR(e)):{},"default",e&&e.__esModule&&"default"in e?{get:()=>e.default,enumerable:!0}:{value:e,enumerable:!0})),e),M3=Ot({"node_modules/.pnpm/long@4.0.0/node_modules/long/src/long.js"(e,t){t.exports=r;var n=null;try{n=new WebAssembly.Instance(new WebAssembly.Module(new Uint8Array([0,97,115,109,1,0,0,0,1,13,2,96,0,1,127,96,4,127,127,127,127,1,127,3,7,6,0,1,1,1,1,1,6,6,1,127,1,65,0,11,7,50,6,3,109,117,108,0,1,5,100,105,118,95,115,0,2,5,100,105,118,95,117,0,3,5,114,101,109,95,115,0,4,5,114,101,109,95,117,0,5,8,103,101,116,95,104,105,103,104,0,0,10,191,1,6,4,0,35,0,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,126,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,127,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,128,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,129,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,130,34,4,66,32,135,167,36,0,32,4,167,11])),{}).exports}catch(R){}function r(R,N,F){this.low=R|0,this.high=N|0,this.unsigned=!!F}r.prototype.__isLong__,Object.defineProperty(r.prototype,"__isLong__",{value:!0});function s(R){return(R&&R.__isLong__)===!0}r.isLong=s;var a={},o={};function i(R,N){var F,B,j;return N?(R>>>=0,(j=0<=R&&R<256)&&(B=o[R],B)?B:(F=u(R,(R|0)<0?-1:0,!0),j&&(o[R]=F),F)):(R|=0,(j=-128<=R&&R<128)&&(B=a[R],B)?B:(F=u(R,R<0?-1:0,!1),j&&(a[R]=F),F))}r.fromInt=i;function l(R,N){if(isNaN(R))return N?b:x;if(N){if(R<0)return b;if(R>=g)return C}else{if(R<=-y)return M;if(R+1>=y)return T}return R<0?l(-R,N).neg():u(R%m|0,R/m|0,N)}r.fromNumber=l;function u(R,N,F){return new r(R,N,F)}r.fromBits=u;var c=Math.pow;function d(R,N,F){if(R.length===0)throw Error("empty string");if(R==="NaN"||R==="Infinity"||R==="+Infinity"||R==="-Infinity")return x;if(typeof N=="number"?(F=N,N=!1):N=!!N,F=F||10,F<2||36<F)throw RangeError("radix");var B;if((B=R.indexOf("-"))>0)throw Error("interior hyphen");if(B===0)return d(R.substring(1),N,F).neg();for(var j=l(c(F,8)),X=x,Y=0;Y<R.length;Y+=8){var ee=Math.min(8,R.length-Y),oe=parseInt(R.substring(Y,Y+ee),F);if(ee<8){var se=l(c(F,ee));X=X.mul(se).add(l(oe))}else X=X.mul(j),X=X.add(l(oe))}return X.unsigned=N,X}r.fromString=d;function h(R,N){return typeof R=="number"?l(R,N):typeof R=="string"?d(R,N):u(R.low,R.high,typeof N=="boolean"?N:R.unsigned)}r.fromValue=h;var p=1<<16,f=1<<24,m=p*p,g=m*m,y=g/2,A=i(f),x=i(0);r.ZERO=x;var b=i(0,!0);r.UZERO=b;var v=i(1);r.ONE=v;var w=i(1,!0);r.UONE=w;var I=i(-1);r.NEG_ONE=I;var T=u(4294967295|0,2147483647|0,!1);r.MAX_VALUE=T;var C=u(4294967295|0,4294967295|0,!0);r.MAX_UNSIGNED_VALUE=C;var M=u(0,2147483648|0,!1);r.MIN_VALUE=M;var $=r.prototype;$.toInt=function(){return this.unsigned?this.low>>>0:this.low},$.toNumber=function(){return this.unsigned?(this.high>>>0)*m+(this.low>>>0):this.high*m+(this.low>>>0)},$.toString=function(N){if(N=N||10,N<2||36<N)throw RangeError("radix");if(this.isZero())return"0";if(this.isNegative())if(this.eq(M)){var F=l(N),B=this.div(F),j=B.mul(F).sub(this);return B.toString(N)+j.toInt().toString(N)}else return"-"+this.neg().toString(N);for(var X=l(c(N,6),this.unsigned),Y=this,ee="";;){var oe=Y.div(X),se=Y.sub(oe.mul(X)).toInt()>>>0,ie=se.toString(N);if(Y=oe,Y.isZero())return ie+ee;for(;ie.length<6;)ie="0"+ie;ee=""+ie+ee}},$.getHighBits=function(){return this.high},$.getHighBitsUnsigned=function(){return this.high>>>0},$.getLowBits=function(){return this.low},$.getLowBitsUnsigned=function(){return this.low>>>0},$.getNumBitsAbs=function(){if(this.isNegative())return this.eq(M)?64:this.neg().getNumBitsAbs();for(var N=this.high!=0?this.high:this.low,F=31;F>0&&(N&1<<F)==0;F--);return this.high!=0?F+33:F+1},$.isZero=function(){return this.high===0&&this.low===0},$.eqz=$.isZero,$.isNegative=function(){return!this.unsigned&&this.high<0},$.isPositive=function(){return this.unsigned||this.high>=0},$.isOdd=function(){return(this.low&1)==1},$.isEven=function(){return(this.low&1)==0},$.equals=function(N){return s(N)||(N=h(N)),this.unsigned!==N.unsigned&&this.high>>>31==1&&N.high>>>31==1?!1:this.high===N.high&&this.low===N.low},$.eq=$.equals,$.notEquals=function(N){return!this.eq(N)},$.neq=$.notEquals,$.ne=$.notEquals,$.lessThan=function(N){return this.comp(N)<0},$.lt=$.lessThan,$.lessThanOrEqual=function(N){return this.comp(N)<=0},$.lte=$.lessThanOrEqual,$.le=$.lessThanOrEqual,$.greaterThan=function(N){return this.comp(N)>0},$.gt=$.greaterThan,$.greaterThanOrEqual=function(N){return this.comp(N)>=0},$.gte=$.greaterThanOrEqual,$.ge=$.greaterThanOrEqual,$.compare=function(N){if(s(N)||(N=h(N)),this.eq(N))return 0;var F=this.isNegative(),B=N.isNegative();return F&&!B?-1:!F&&B?1:this.unsigned?N.high>>>0>this.high>>>0||N.high===this.high&&N.low>>>0>this.low>>>0?-1:1:this.sub(N).isNegative()?-1:1},$.comp=$.compare,$.negate=function(){return!this.unsigned&&this.eq(M)?M:this.not().add(v)},$.neg=$.negate,$.add=function(N){s(N)||(N=h(N));var F=this.high>>>16,B=this.high&65535,j=this.low>>>16,X=this.low&65535,Y=N.high>>>16,ee=N.high&65535,oe=N.low>>>16,se=N.low&65535,ie=0,ne=0,de=0,he=0;return he+=X+se,de+=he>>>16,he&=65535,de+=j+oe,ne+=de>>>16,de&=65535,ne+=B+ee,ie+=ne>>>16,ne&=65535,ie+=F+Y,ie&=65535,u(de<<16|he,ie<<16|ne,this.unsigned)},$.subtract=function(N){return s(N)||(N=h(N)),this.add(N.neg())},$.sub=$.subtract,$.multiply=function(N){if(this.isZero())return x;if(s(N)||(N=h(N)),n){var F=n.mul(this.low,this.high,N.low,N.high);return u(F,n.get_high(),this.unsigned)}if(N.isZero())return x;if(this.eq(M))return N.isOdd()?M:x;if(N.eq(M))return this.isOdd()?M:x;if(this.isNegative())return N.isNegative()?this.neg().mul(N.neg()):this.neg().mul(N).neg();if(N.isNegative())return this.mul(N.neg()).neg();if(this.lt(A)&&N.lt(A))return l(this.toNumber()*N.toNumber(),this.unsigned);var B=this.high>>>16,j=this.high&65535,X=this.low>>>16,Y=this.low&65535,ee=N.high>>>16,oe=N.high&65535,se=N.low>>>16,ie=N.low&65535,ne=0,de=0,he=0,ge=0;return ge+=Y*ie,he+=ge>>>16,ge&=65535,he+=X*ie,de+=he>>>16,he&=65535,he+=Y*se,de+=he>>>16,he&=65535,de+=j*ie,ne+=de>>>16,de&=65535,de+=X*se,ne+=de>>>16,de&=65535,de+=Y*oe,ne+=de>>>16,de&=65535,ne+=B*ie+j*se+X*oe+Y*ee,ne&=65535,u(he<<16|ge,ne<<16|de,this.unsigned)},$.mul=$.multiply,$.divide=function(N){if(s(N)||(N=h(N)),N.isZero())throw Error("division by zero");if(n){if(!this.unsigned&&this.high===-2147483648&&N.low===-1&&N.high===-1)return this;var F=(this.unsigned?n.div_u:n.div_s)(this.low,this.high,N.low,N.high);return u(F,n.get_high(),this.unsigned)}if(this.isZero())return this.unsigned?b:x;var B,j,X;if(this.unsigned){if(N.unsigned||(N=N.toUnsigned()),N.gt(this))return b;if(N.gt(this.shru(1)))return w;X=b}else{if(this.eq(M)){if(N.eq(v)||N.eq(I))return M;if(N.eq(M))return v;var Y=this.shr(1);return B=Y.div(N).shl(1),B.eq(x)?N.isNegative()?v:I:(j=this.sub(N.mul(B)),X=B.add(j.div(N)),X)}else if(N.eq(M))return this.unsigned?b:x;if(this.isNegative())return N.isNegative()?this.neg().div(N.neg()):this.neg().div(N).neg();if(N.isNegative())return this.div(N.neg()).neg();X=x}for(j=this;j.gte(N);){B=Math.max(1,Math.floor(j.toNumber()/N.toNumber()));for(var ee=Math.ceil(Math.log(B)/Math.LN2),oe=ee<=48?1:c(2,ee-48),se=l(B),ie=se.mul(N);ie.isNegative()||ie.gt(j);)B-=oe,se=l(B,this.unsigned),ie=se.mul(N);se.isZero()&&(se=v),X=X.add(se),j=j.sub(ie)}return X},$.div=$.divide,$.modulo=function(N){if(s(N)||(N=h(N)),n){var F=(this.unsigned?n.rem_u:n.rem_s)(this.low,this.high,N.low,N.high);return u(F,n.get_high(),this.unsigned)}return this.sub(this.div(N).mul(N))},$.mod=$.modulo,$.rem=$.modulo,$.not=function(){return u(~this.low,~this.high,this.unsigned)},$.and=function(N){return s(N)||(N=h(N)),u(this.low&N.low,this.high&N.high,this.unsigned)},$.or=function(N){return s(N)||(N=h(N)),u(this.low|N.low,this.high|N.high,this.unsigned)},$.xor=function(N){return s(N)||(N=h(N)),u(this.low^N.low,this.high^N.high,this.unsigned)},$.shiftLeft=function(N){return s(N)&&(N=N.toInt()),(N&=63)===0?this:N<32?u(this.low<<N,this.high<<N|this.low>>>32-N,this.unsigned):u(0,this.low<<N-32,this.unsigned)},$.shl=$.shiftLeft,$.shiftRight=function(N){return s(N)&&(N=N.toInt()),(N&=63)===0?this:N<32?u(this.low>>>N|this.high<<32-N,this.high>>N,this.unsigned):u(this.high>>N-32,this.high>=0?0:-1,this.unsigned)},$.shr=$.shiftRight,$.shiftRightUnsigned=function(N){if(s(N)&&(N=N.toInt()),N&=63,N===0)return this;var F=this.high;if(N<32){var B=this.low;return u(B>>>N|F<<32-N,F>>>N,this.unsigned)}else return N===32?u(F,0,this.unsigned):u(F>>>N-32,0,this.unsigned)},$.shru=$.shiftRightUnsigned,$.shr_u=$.shiftRightUnsigned,$.toSigned=function(){return this.unsigned?u(this.low,this.high,!1):this},$.toUnsigned=function(){return this.unsigned?this:u(this.low,this.high,!0)},$.toBytes=function(N){return N?this.toBytesLE():this.toBytesBE()},$.toBytesLE=function(){var N=this.high,F=this.low;return[F&255,F>>>8&255,F>>>16&255,F>>>24,N&255,N>>>8&255,N>>>16&255,N>>>24]},$.toBytesBE=function(){var N=this.high,F=this.low;return[N>>>24,N>>>16&255,N>>>8&255,N&255,F>>>24,F>>>16&255,F>>>8&255,F&255]},r.fromBytes=function(N,F,B){return B?r.fromBytesLE(N,F):r.fromBytesBE(N,F)},r.fromBytesLE=function(N,F){return new r(N[0]|N[1]<<8|N[2]<<16|N[3]<<24,N[4]|N[5]<<8|N[6]<<16|N[7]<<24,F)},r.fromBytesBE=function(N,F){return new r(N[4]<<24|N[5]<<16|N[6]<<8|N[7],N[0]<<24|N[1]<<16|N[2]<<8|N[3],F)}}}),O3=Ot({"(disabled):node_modules/.pnpm/node-fetch@2.6.1/node_modules/node-fetch/browser.js"(){}}),iR=Ot({"node_modules/.pnpm/seedrandom@2.4.3/node_modules/seedrandom/lib/alea.js"(e,t){(function(n,r,s){function a(u){var c=this,d=l();c.next=function(){var h=2091639*c.s0+c.c*23283064365386963e-26;return c.s0=c.s1,c.s1=c.s2,c.s2=h-(c.c=h|0)},c.c=1,c.s0=d(" "),c.s1=d(" "),c.s2=d(" "),c.s0-=d(u),c.s0<0&&(c.s0+=1),c.s1-=d(u),c.s1<0&&(c.s1+=1),c.s2-=d(u),c.s2<0&&(c.s2+=1),d=null}function o(u,c){return c.c=u.c,c.s0=u.s0,c.s1=u.s1,c.s2=u.s2,c}function i(u,c){var d=new a(u),h=c&&c.state,p=d.next;return p.int32=function(){return d.next()*4294967296|0},p.double=function(){return p()+(p()*2097152|0)*11102230246251565e-32},p.quick=p,h&&(typeof h=="object"&&o(h,d),p.state=function(){return o(d,{})}),p}function l(){var u=4022871197,c=function(d){d=d.toString();for(var h=0;h<d.length;h++){u+=d.charCodeAt(h);var p=.02519603282416938*u;u=p>>>0,p-=u,p*=u,u=p>>>0,p-=u,u+=p*4294967296}return(u>>>0)*23283064365386963e-26};return c}r&&r.exports?r.exports=i:s&&s.amd?s(function(){return i}):this.alea=i})(e,typeof t=="object"&&t,typeof define=="function"&&define)}}),lR=Ot({"node_modules/.pnpm/seedrandom@2.4.3/node_modules/seedrandom/lib/xor128.js"(e,t){(function(n,r,s){function a(l){var u=this,c="";u.x=0,u.y=0,u.z=0,u.w=0,u.next=function(){var h=u.x^u.x<<11;return u.x=u.y,u.y=u.z,u.z=u.w,u.w^=u.w>>>19^h^h>>>8},l===(l|0)?u.x=l:c+=l;for(var d=0;d<c.length+64;d++)u.x^=c.charCodeAt(d)|0,u.next()}function o(l,u){return u.x=l.x,u.y=l.y,u.z=l.z,u.w=l.w,u}function i(l,u){var c=new a(l),d=u&&u.state,h=function(){return(c.next()>>>0)/4294967296};return h.double=function(){do var p=c.next()>>>11,f=(c.next()>>>0)/4294967296,m=(p+f)/(1<<21);while(m===0);return m},h.int32=c.next,h.quick=h,d&&(typeof d=="object"&&o(d,c),h.state=function(){return o(c,{})}),h}r&&r.exports?r.exports=i:s&&s.amd?s(function(){return i}):this.xor128=i})(e,typeof t=="object"&&t,typeof define=="function"&&define)}}),uR=Ot({"node_modules/.pnpm/seedrandom@2.4.3/node_modules/seedrandom/lib/xorwow.js"(e,t){(function(n,r,s){function a(l){var u=this,c="";u.next=function(){var h=u.x^u.x>>>2;return u.x=u.y,u.y=u.z,u.z=u.w,u.w=u.v,(u.d=u.d+362437|0)+(u.v=u.v^u.v<<4^(h^h<<1))|0},u.x=0,u.y=0,u.z=0,u.w=0,u.v=0,l===(l|0)?u.x=l:c+=l;for(var d=0;d<c.length+64;d++)u.x^=c.charCodeAt(d)|0,d==c.length&&(u.d=u.x<<10^u.x>>>4),u.next()}function o(l,u){return u.x=l.x,u.y=l.y,u.z=l.z,u.w=l.w,u.v=l.v,u.d=l.d,u}function i(l,u){var c=new a(l),d=u&&u.state,h=function(){return(c.next()>>>0)/4294967296};return h.double=function(){do var p=c.next()>>>11,f=(c.next()>>>0)/4294967296,m=(p+f)/(1<<21);while(m===0);return m},h.int32=c.next,h.quick=h,d&&(typeof d=="object"&&o(d,c),h.state=function(){return o(c,{})}),h}r&&r.exports?r.exports=i:s&&s.amd?s(function(){return i}):this.xorwow=i})(e,typeof t=="object"&&t,typeof define=="function"&&define)}}),cR=Ot({"node_modules/.pnpm/seedrandom@2.4.3/node_modules/seedrandom/lib/xorshift7.js"(e,t){(function(n,r,s){function a(l){var u=this;u.next=function(){var d=u.x,h=u.i,p,f,m;return p=d[h],p^=p>>>7,f=p^p<<24,p=d[h+1&7],f^=p^p>>>10,p=d[h+3&7],f^=p^p>>>3,p=d[h+4&7],f^=p^p<<7,p=d[h+7&7],p=p^p<<13,f^=p^p<<9,d[h]=f,u.i=h+1&7,f};function c(d,h){var p,f,m=[];if(h===(h|0))f=m[0]=h;else for(h=""+h,p=0;p<h.length;++p)m[p&7]=m[p&7]<<15^h.charCodeAt(p)+m[p+1&7]<<13;for(;m.length<8;)m.push(0);for(p=0;p<8&&m[p]===0;++p);for(p==8?f=m[7]=-1:f=m[p],d.x=m,d.i=0,p=256;p>0;--p)d.next()}c(u,l)}function o(l,u){return u.x=l.x.slice(),u.i=l.i,u}function i(l,u){l==null&&(l=+new Date);var c=new a(l),d=u&&u.state,h=function(){return(c.next()>>>0)/4294967296};return h.double=function(){do var p=c.next()>>>11,f=(c.next()>>>0)/4294967296,m=(p+f)/(1<<21);while(m===0);return m},h.int32=c.next,h.quick=h,d&&(d.x&&o(d,c),h.state=function(){return o(c,{})}),h}r&&r.exports?r.exports=i:s&&s.amd?s(function(){return i}):this.xorshift7=i})(e,typeof t=="object"&&t,typeof define=="function"&&define)}}),dR=Ot({"node_modules/.pnpm/seedrandom@2.4.3/node_modules/seedrandom/lib/xor4096.js"(e,t){(function(n,r,s){function a(l){var u=this;u.next=function(){var d=u.w,h=u.X,p=u.i,f,m;return u.w=d=d+1640531527|0,m=h[p+34&127],f=h[p=p+1&127],m^=m<<13,f^=f<<17,m^=m>>>15,f^=f>>>12,m=h[p]=m^f,u.i=p,m+(d^d>>>16)|0};function c(d,h){var p,f,m,g,y,A=[],x=128;for(h===(h|0)?(f=h,h=null):(h=h+"\0",f=0,x=Math.max(x,h.length)),m=0,g=-32;g<x;++g)h&&(f^=h.charCodeAt((g+32)%h.length)),g===0&&(y=f),f^=f<<10,f^=f>>>15,f^=f<<4,f^=f>>>13,g>=0&&(y=y+1640531527|0,p=A[g&127]^=f+y,m=p==0?m+1:0);for(m>=128&&(A[(h&&h.length||0)&127]=-1),m=127,g=4*128;g>0;--g)f=A[m+34&127],p=A[m=m+1&127],f^=f<<13,p^=p<<17,f^=f>>>15,p^=p>>>12,A[m]=f^p;d.w=y,d.X=A,d.i=m}c(u,l)}function o(l,u){return u.i=l.i,u.w=l.w,u.X=l.X.slice(),u}function i(l,u){l==null&&(l=+new Date);var c=new a(l),d=u&&u.state,h=function(){return(c.next()>>>0)/4294967296};return h.double=function(){do var p=c.next()>>>11,f=(c.next()>>>0)/4294967296,m=(p+f)/(1<<21);while(m===0);return m},h.int32=c.next,h.quick=h,d&&(d.X&&o(d,c),h.state=function(){return o(c,{})}),h}r&&r.exports?r.exports=i:s&&s.amd?s(function(){return i}):this.xor4096=i})(e,typeof t=="object"&&t,typeof define=="function"&&define)}}),hR=Ot({"node_modules/.pnpm/seedrandom@2.4.3/node_modules/seedrandom/lib/tychei.js"(e,t){(function(n,r,s){function a(l){var u=this,c="";u.next=function(){var h=u.b,p=u.c,f=u.d,m=u.a;return h=h<<25^h>>>7^p,p=p-f|0,f=f<<24^f>>>8^m,m=m-h|0,u.b=h=h<<20^h>>>12^p,u.c=p=p-f|0,u.d=f<<16^p>>>16^m,u.a=m-h|0},u.a=0,u.b=0,u.c=2654435769|0,u.d=1367130551,l===Math.floor(l)?(u.a=l/4294967296|0,u.b=l|0):c+=l;for(var d=0;d<c.length+20;d++)u.b^=c.charCodeAt(d)|0,u.next()}function o(l,u){return u.a=l.a,u.b=l.b,u.c=l.c,u.d=l.d,u}function i(l,u){var c=new a(l),d=u&&u.state,h=function(){return(c.next()>>>0)/4294967296};return h.double=function(){do var p=c.next()>>>11,f=(c.next()>>>0)/4294967296,m=(p+f)/(1<<21);while(m===0);return m},h.int32=c.next,h.quick=h,d&&(typeof d=="object"&&o(d,c),h.state=function(){return o(c,{})}),h}r&&r.exports?r.exports=i:s&&s.amd?s(function(){return i}):this.tychei=i})(e,typeof t=="object"&&t,typeof define=="function"&&define)}}),P3=Ot({"(disabled):crypto"(){}}),pR=Ot({"node_modules/.pnpm/seedrandom@2.4.3/node_modules/seedrandom/seedrandom.js"(e,t){(function(n,r){var s=this,a=256,o=6,i=52,l="random",u=r.pow(a,o),c=r.pow(2,i),d=c*2,h=a-1,p;function f(v,w,I){var T=[];w=w==!0?{entropy:!0}:w||{};var C=A(y(w.entropy?[v,b(n)]:v==null?x():v,3),T),M=new m(T),$=function(){for(var R=M.g(o),N=u,F=0;R<c;)R=(R+F)*a,N*=a,F=M.g(1);for(;R>=d;)R/=2,N/=2,F>>>=1;return(R+F)/N};return $.int32=function(){return M.g(4)|0},$.quick=function(){return M.g(4)/4294967296},$.double=$,A(b(M.S),n),(w.pass||I||function(R,N,F,B){return B&&(B.S&&g(B,M),R.state=function(){return g(M,{})}),F?(r[l]=R,N):R})($,C,"global"in w?w.global:this==r,w.state)}r["seed"+l]=f;function m(v){var w,I=v.length,T=this,C=0,M=T.i=T.j=0,$=T.S=[];for(I||(v=[I++]);C<a;)$[C]=C++;for(C=0;C<a;C++)$[C]=$[M=h&M+v[C%I]+(w=$[C])],$[M]=w;(T.g=function(R){for(var N,F=0,B=T.i,j=T.j,X=T.S;R--;)N=X[B=h&B+1],F=F*a+X[h&(X[B]=X[j=h&j+N])+(X[j]=N)];return T.i=B,T.j=j,F})(a)}function g(v,w){return w.i=v.i,w.j=v.j,w.S=v.S.slice(),w}function y(v,w){var I=[],T=typeof v,C;if(w&&T=="object")for(C in v)try{I.push(y(v[C],w-1))}catch(M){}return I.length?I:T=="string"?v:v+"\0"}function A(v,w){for(var I=v+"",T,C=0;C<I.length;)w[h&C]=h&(T^=w[h&C]*19)+I.charCodeAt(C++);return b(w)}function x(){try{var v;return p&&(v=p.randomBytes)?v=v(a):(v=new Uint8Array(a),(s.crypto||s.msCrypto).getRandomValues(v)),b(v)}catch(T){var w=s.navigator,I=w&&w.plugins;return[+new Date,s,I,s.screen,b(n)]}}function b(v){return String.fromCharCode.apply(0,v)}if(A(r.random(),n),typeof t=="object"&&t.exports){t.exports=f;try{p=P3()}catch(v){}}else typeof define=="function"&&define.amd&&define(function(){return f})})([],Math)}}),e2=Ot({"node_modules/.pnpm/seedrandom@2.4.3/node_modules/seedrandom/index.js"(e,t){var n=iR(),r=lR(),s=uR(),a=cR(),o=dR(),i=hR(),l=pR();l.alea=n,l.xor128=r,l.xorwow=s,l.xorshift7=a,l.xor4096=o,l.tychei=i,t.exports=l}}),fR=Ot({"node_modules/.pnpm/seedrandom@3.0.5/node_modules/seedrandom/lib/alea.js"(e,t){(function(n,r,s){function a(u){var c=this,d=l();c.next=function(){var h=2091639*c.s0+c.c*23283064365386963e-26;return c.s0=c.s1,c.s1=c.s2,c.s2=h-(c.c=h|0)},c.c=1,c.s0=d(" "),c.s1=d(" "),c.s2=d(" "),c.s0-=d(u),c.s0<0&&(c.s0+=1),c.s1-=d(u),c.s1<0&&(c.s1+=1),c.s2-=d(u),c.s2<0&&(c.s2+=1),d=null}function o(u,c){return c.c=u.c,c.s0=u.s0,c.s1=u.s1,c.s2=u.s2,c}function i(u,c){var d=new a(u),h=c&&c.state,p=d.next;return p.int32=function(){return d.next()*4294967296|0},p.double=function(){return p()+(p()*2097152|0)*11102230246251565e-32},p.quick=p,h&&(typeof h=="object"&&o(h,d),p.state=function(){return o(d,{})}),p}function l(){var u=4022871197,c=function(d){d=String(d);for(var h=0;h<d.length;h++){u+=d.charCodeAt(h);var p=.02519603282416938*u;u=p>>>0,p-=u,p*=u,u=p>>>0,p-=u,u+=p*4294967296}return(u>>>0)*23283064365386963e-26};return c}r&&r.exports?r.exports=i:s&&s.amd?s(function(){return i}):this.alea=i})(e,typeof t=="object"&&t,typeof define=="function"&&define)}}),mR=Ot({"node_modules/.pnpm/seedrandom@3.0.5/node_modules/seedrandom/lib/xor128.js"(e,t){(function(n,r,s){function a(l){var u=this,c="";u.x=0,u.y=0,u.z=0,u.w=0,u.next=function(){var h=u.x^u.x<<11;return u.x=u.y,u.y=u.z,u.z=u.w,u.w^=u.w>>>19^h^h>>>8},l===(l|0)?u.x=l:c+=l;for(var d=0;d<c.length+64;d++)u.x^=c.charCodeAt(d)|0,u.next()}function o(l,u){return u.x=l.x,u.y=l.y,u.z=l.z,u.w=l.w,u}function i(l,u){var c=new a(l),d=u&&u.state,h=function(){return(c.next()>>>0)/4294967296};return h.double=function(){do var p=c.next()>>>11,f=(c.next()>>>0)/4294967296,m=(p+f)/(1<<21);while(m===0);return m},h.int32=c.next,h.quick=h,d&&(typeof d=="object"&&o(d,c),h.state=function(){return o(c,{})}),h}r&&r.exports?r.exports=i:s&&s.amd?s(function(){return i}):this.xor128=i})(e,typeof t=="object"&&t,typeof define=="function"&&define)}}),gR=Ot({"node_modules/.pnpm/seedrandom@3.0.5/node_modules/seedrandom/lib/xorwow.js"(e,t){(function(n,r,s){function a(l){var u=this,c="";u.next=function(){var h=u.x^u.x>>>2;return u.x=u.y,u.y=u.z,u.z=u.w,u.w=u.v,(u.d=u.d+362437|0)+(u.v=u.v^u.v<<4^(h^h<<1))|0},u.x=0,u.y=0,u.z=0,u.w=0,u.v=0,l===(l|0)?u.x=l:c+=l;for(var d=0;d<c.length+64;d++)u.x^=c.charCodeAt(d)|0,d==c.length&&(u.d=u.x<<10^u.x>>>4),u.next()}function o(l,u){return u.x=l.x,u.y=l.y,u.z=l.z,u.w=l.w,u.v=l.v,u.d=l.d,u}function i(l,u){var c=new a(l),d=u&&u.state,h=function(){return(c.next()>>>0)/4294967296};return h.double=function(){do var p=c.next()>>>11,f=(c.next()>>>0)/4294967296,m=(p+f)/(1<<21);while(m===0);return m},h.int32=c.next,h.quick=h,d&&(typeof d=="object"&&o(d,c),h.state=function(){return o(c,{})}),h}r&&r.exports?r.exports=i:s&&s.amd?s(function(){return i}):this.xorwow=i})(e,typeof t=="object"&&t,typeof define=="function"&&define)}}),yR=Ot({"node_modules/.pnpm/seedrandom@3.0.5/node_modules/seedrandom/lib/xorshift7.js"(e,t){(function(n,r,s){function a(l){var u=this;u.next=function(){var d=u.x,h=u.i,p,f,m;return p=d[h],p^=p>>>7,f=p^p<<24,p=d[h+1&7],f^=p^p>>>10,p=d[h+3&7],f^=p^p>>>3,p=d[h+4&7],f^=p^p<<7,p=d[h+7&7],p=p^p<<13,f^=p^p<<9,d[h]=f,u.i=h+1&7,f};function c(d,h){var p,f,m=[];if(h===(h|0))f=m[0]=h;else for(h=""+h,p=0;p<h.length;++p)m[p&7]=m[p&7]<<15^h.charCodeAt(p)+m[p+1&7]<<13;for(;m.length<8;)m.push(0);for(p=0;p<8&&m[p]===0;++p);for(p==8?f=m[7]=-1:f=m[p],d.x=m,d.i=0,p=256;p>0;--p)d.next()}c(u,l)}function o(l,u){return u.x=l.x.slice(),u.i=l.i,u}function i(l,u){l==null&&(l=+new Date);var c=new a(l),d=u&&u.state,h=function(){return(c.next()>>>0)/4294967296};return h.double=function(){do var p=c.next()>>>11,f=(c.next()>>>0)/4294967296,m=(p+f)/(1<<21);while(m===0);return m},h.int32=c.next,h.quick=h,d&&(d.x&&o(d,c),h.state=function(){return o(c,{})}),h}r&&r.exports?r.exports=i:s&&s.amd?s(function(){return i}):this.xorshift7=i})(e,typeof t=="object"&&t,typeof define=="function"&&define)}}),AR=Ot({"node_modules/.pnpm/seedrandom@3.0.5/node_modules/seedrandom/lib/xor4096.js"(e,t){(function(n,r,s){function a(l){var u=this;u.next=function(){var d=u.w,h=u.X,p=u.i,f,m;return u.w=d=d+1640531527|0,m=h[p+34&127],f=h[p=p+1&127],m^=m<<13,f^=f<<17,m^=m>>>15,f^=f>>>12,m=h[p]=m^f,u.i=p,m+(d^d>>>16)|0};function c(d,h){var p,f,m,g,y,A=[],x=128;for(h===(h|0)?(f=h,h=null):(h=h+"\0",f=0,x=Math.max(x,h.length)),m=0,g=-32;g<x;++g)h&&(f^=h.charCodeAt((g+32)%h.length)),g===0&&(y=f),f^=f<<10,f^=f>>>15,f^=f<<4,f^=f>>>13,g>=0&&(y=y+1640531527|0,p=A[g&127]^=f+y,m=p==0?m+1:0);for(m>=128&&(A[(h&&h.length||0)&127]=-1),m=127,g=4*128;g>0;--g)f=A[m+34&127],p=A[m=m+1&127],f^=f<<13,p^=p<<17,f^=f>>>15,p^=p>>>12,A[m]=f^p;d.w=y,d.X=A,d.i=m}c(u,l)}function o(l,u){return u.i=l.i,u.w=l.w,u.X=l.X.slice(),u}function i(l,u){l==null&&(l=+new Date);var c=new a(l),d=u&&u.state,h=function(){return(c.next()>>>0)/4294967296};return h.double=function(){do var p=c.next()>>>11,f=(c.next()>>>0)/4294967296,m=(p+f)/(1<<21);while(m===0);return m},h.int32=c.next,h.quick=h,d&&(d.X&&o(d,c),h.state=function(){return o(c,{})}),h}r&&r.exports?r.exports=i:s&&s.amd?s(function(){return i}):this.xor4096=i})(e,typeof t=="object"&&t,typeof define=="function"&&define)}}),xR=Ot({"node_modules/.pnpm/seedrandom@3.0.5/node_modules/seedrandom/lib/tychei.js"(e,t){(function(n,r,s){function a(l){var u=this,c="";u.next=function(){var h=u.b,p=u.c,f=u.d,m=u.a;return h=h<<25^h>>>7^p,p=p-f|0,f=f<<24^f>>>8^m,m=m-h|0,u.b=h=h<<20^h>>>12^p,u.c=p=p-f|0,u.d=f<<16^p>>>16^m,u.a=m-h|0},u.a=0,u.b=0,u.c=2654435769|0,u.d=1367130551,l===Math.floor(l)?(u.a=l/4294967296|0,u.b=l|0):c+=l;for(var d=0;d<c.length+20;d++)u.b^=c.charCodeAt(d)|0,u.next()}function o(l,u){return u.a=l.a,u.b=l.b,u.c=l.c,u.d=l.d,u}function i(l,u){var c=new a(l),d=u&&u.state,h=function(){return(c.next()>>>0)/4294967296};return h.double=function(){do var p=c.next()>>>11,f=(c.next()>>>0)/4294967296,m=(p+f)/(1<<21);while(m===0);return m},h.int32=c.next,h.quick=h,d&&(typeof d=="object"&&o(d,c),h.state=function(){return o(c,{})}),h}r&&r.exports?r.exports=i:s&&s.amd?s(function(){return i}):this.tychei=i})(e,typeof t=="object"&&t,typeof define=="function"&&define)}}),bR=Ot({"node_modules/.pnpm/seedrandom@3.0.5/node_modules/seedrandom/seedrandom.js"(e,t){(function(n,r,s){var a=256,o=6,i=52,l="random",u=s.pow(a,o),c=s.pow(2,i),d=c*2,h=a-1,p;function f(v,w,I){var T=[];w=w==!0?{entropy:!0}:w||{};var C=A(y(w.entropy?[v,b(r)]:v==null?x():v,3),T),M=new m(T),$=function(){for(var R=M.g(o),N=u,F=0;R<c;)R=(R+F)*a,N*=a,F=M.g(1);for(;R>=d;)R/=2,N/=2,F>>>=1;return(R+F)/N};return $.int32=function(){return M.g(4)|0},$.quick=function(){return M.g(4)/4294967296},$.double=$,A(b(M.S),r),(w.pass||I||function(R,N,F,B){return B&&(B.S&&g(B,M),R.state=function(){return g(M,{})}),F?(s[l]=R,N):R})($,C,"global"in w?w.global:this==s,w.state)}function m(v){var w,I=v.length,T=this,C=0,M=T.i=T.j=0,$=T.S=[];for(I||(v=[I++]);C<a;)$[C]=C++;for(C=0;C<a;C++)$[C]=$[M=h&M+v[C%I]+(w=$[C])],$[M]=w;(T.g=function(R){for(var N,F=0,B=T.i,j=T.j,X=T.S;R--;)N=X[B=h&B+1],F=F*a+X[h&(X[B]=X[j=h&j+N])+(X[j]=N)];return T.i=B,T.j=j,F})(a)}function g(v,w){return w.i=v.i,w.j=v.j,w.S=v.S.slice(),w}function y(v,w){var I=[],T=typeof v,C;if(w&&T=="object")for(C in v)try{I.push(y(v[C],w-1))}catch(M){}return I.length?I:T=="string"?v:v+"\0"}function A(v,w){for(var I=v+"",T,C=0;C<I.length;)w[h&C]=h&(T^=w[h&C]*19)+I.charCodeAt(C++);return b(w)}function x(){try{var v;return p&&(v=p.randomBytes)?v=v(a):(v=new Uint8Array(a),(n.crypto||n.msCrypto).getRandomValues(v)),b(v)}catch(T){var w=n.navigator,I=w&&w.plugins;return[+new Date,n,I,n.screen,b(r)]}}function b(v){return String.fromCharCode.apply(0,v)}if(A(s.random(),r),typeof t=="object"&&t.exports){t.exports=f;try{p=P3()}catch(v){}}else typeof define=="function"&&define.amd?define(function(){return f}):s["seed"+l]=f})(typeof self!="undefined"?self:e,[],Math)}}),z3=Ot({"node_modules/.pnpm/seedrandom@3.0.5/node_modules/seedrandom/index.js"(e,t){var n=fR(),r=mR(),s=gR(),a=yR(),o=AR(),i=xR(),l=bR();l.alea=n,l.xor128=r,l.xorwow=s,l.xorshift7=a,l.xor4096=o,l.tychei=i,t.exports=l}}),vR=Ot({"(disabled):node_modules/.pnpm/string_decoder@1.1.1/node_modules/string_decoder/lib/string_decoder.js"(){}}),ju=Ot({"(disabled):path"(){}}),wR=Ot({"(disabled):worker_threads"(){}}),kR=Ot({"(disabled):perf_hooks"(){}}),IR=Ot({"node_modules/.pnpm/@tensorflow+tfjs-backend-wasm@3.7.0_@tensorflow+tfjs-core@3.7.0/node_modules/@tensorflow/tfjs-backend-wasm/wasm-out/tfjs-backend-wasm-threaded-simd.js"(e,t){var n=function(){var r=typeof document!="undefined"&&document.currentScript?document.currentScript.src:void 0;return typeof __filename!="undefined"&&(r=r||__filename),function(s){s=s||{};function a(){return ne.buffer!=Je&&wn(ne.buffer),jn}function o(){return ne.buffer!=Je&&wn(ne.buffer),Wt}function i(){return ne.buffer!=Je&&wn(ne.buffer),Vr}function l(){return ne.buffer!=Je&&wn(ne.buffer),Rn}function u(){return ne.buffer!=Je&&wn(ne.buffer),vr}var c=typeof s!="undefined"?s:{},d,h;c.ready=new Promise(function(E,D){d=E,h=D});var p={},f;for(f in c)c.hasOwnProperty(f)&&(p[f]=c[f]);var m=[],g="./this.program",y=function(E,D){throw D},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 w=c.ENVIRONMENT_IS_PTHREAD||!1;w&&(Je=c.buffer);var I="";function T(E){return c.locateFile?c.locateFile(E,I):I+E}var C,M,$,R,N,F;if(b){x?I=ju().dirname(I)+"/":I=__dirname+"/",C=function(D,W){return N||(N=co("fs")),F||(F=ju()),D=F.normalize(D),N.readFileSync(D,W?null:"utf8")},$=function(D){var W=C(D,!0);return W.buffer||(W=new Uint8Array(W)),be(W.buffer),W},process.argv.length>1&&(g=process.argv[1].replace(/\\/g,"/")),m=process.argv.slice(2),process.on("uncaughtException",function(E){if(!(E instanceof Gu))throw E}),process.on("unhandledRejection",Gs),y=function(E){process.exit(E)},c.inspect=function(){return"[Emscripten Module object]"};var B;try{B=wR()}catch(E){throw console.error('The "worker_threads" module is not supported in this node.js build - perhaps a newer version is needed?'),E}global.Worker=B.Worker}else v?(typeof read!="undefined"&&(C=function(D){return read(D)}),$=function(D){var W;return typeof readbuffer=="function"?new Uint8Array(readbuffer(D)):(W=read(D,"binary"),be(typeof W=="object"),W)},typeof scriptArgs!="undefined"?m=scriptArgs:typeof arguments!="undefined"&&(m=arguments),typeof quit=="function"&&(y=function(E){quit(E)}),typeof print!="undefined"&&(typeof console=="undefined"&&(console={}),console.log=print,console.warn=console.error=typeof printErr!="undefined"?printErr:print)):(A||x)&&(x?I=self.location.href:typeof document!="undefined"&&document.currentScript&&(I=document.currentScript.src),typeof r!="undefined"&&r&&(I=r),I.indexOf("blob:")!==0?I=I.substr(0,I.lastIndexOf("/")+1):I="",b?(C=function(D,W){return N||(N=co("fs")),F||(F=ju()),D=F.normalize(D),N.readFileSync(D,W?null:"utf8")},$=function(D){var W=C(D,!0);return W.buffer||(W=new Uint8Array(W)),be(W.buffer),W}):(C=function(E){var D=new XMLHttpRequest;return D.open("GET",E,!1),D.send(null),D.responseText},x&&($=function(E){var D=new XMLHttpRequest;return D.open("GET",E,!1),D.responseType="arraybuffer",D.send(null),new Uint8Array(D.response)}),M=function(E,D,W){var Q=new XMLHttpRequest;Q.open("GET",E,!0),Q.responseType="arraybuffer",Q.onload=function(){if(Q.status==200||Q.status==0&&Q.response){D(Q.response);return}W()},Q.onerror=W,Q.send(null)}),R=function(E){document.title=E});b&&typeof performance=="undefined"&&(global.performance=kR().performance);var j=c.print||console.log.bind(console),X=c.printErr||console.warn.bind(console);for(f in p)p.hasOwnProperty(f)&&(c[f]=p[f]);p=null,c.arguments&&(m=c.arguments),c.thisProgram&&(g=c.thisProgram),c.quit&&(y=c.quit);var Y=Atomics.load,ee=Atomics.store,oe=Atomics.compareExchange,se;c.wasmBinary&&(se=c.wasmBinary);var ie=c.noExitRuntime||!0;typeof WebAssembly!="object"&&Gs("no native wasm support detected");var ne,de,he=!1,ge;function be(E,D){E||Gs("Assertion failed: "+D)}function Ee(E){var D=c["_"+E];return be(D,"Cannot call unknown function "+E+", make sure it is exported"),D}function $e(E,D,W,Q,xe){var ye={string:function(Dn){var Mi=0;if(Dn!=null&&Dn!==0){var $3=(Dn.length<<2)+1;Mi=Ri($3),ft(Dn,Mi,$3)}return Mi},array:function(Dn){var Mi=Ri(Dn.length);return dt(Dn,Mi),Mi}};function Ae(Dn){return D==="string"?We(Dn):D==="boolean"?Boolean(Dn):Dn}var Se=Ee(E),gt=[],pn=0;if(Q)for(var sn=0;sn<Q.length;sn++){var ka=ye[W[sn]];ka?(pn===0&&(pn=Hu()),gt[sn]=ka(Q[sn])):gt[sn]=Q[sn]}var Fi=Se.apply(null,gt);return Fi=Ae(Fi),pn!==0&&_i(pn),Fi}function ze(E,D,W,Q){W=W||[];var xe=W.every(function(Ae){return Ae==="number"}),ye=D!=="string";return ye&&xe&&!Q?Ee(E):function(){return $e(E,D,W,arguments,Q)}}function qe(E,D,W){for(var Q=D+W,xe="";!(D>=Q);){var ye=E[D++];if(!ye)return xe;if(!(ye&128)){xe+=String.fromCharCode(ye);continue}var Ae=E[D++]&63;if((ye&224)==192){xe+=String.fromCharCode((ye&31)<<6|Ae);continue}var Se=E[D++]&63;if((ye&240)==224?ye=(ye&15)<<12|Ae<<6|Se:ye=(ye&7)<<18|Ae<<12|Se<<6|E[D++]&63,ye<65536)xe+=String.fromCharCode(ye);else{var gt=ye-65536;xe+=String.fromCharCode(55296|gt>>10,56320|gt&1023)}}return xe}function We(E,D){return E?qe(o(),E,D):""}function vt(E,D,W,Q){if(!(Q>0))return 0;for(var xe=W,ye=W+Q-1,Ae=0;Ae<E.length;++Ae){var Se=E.charCodeAt(Ae);if(Se>=55296&&Se<=57343){var gt=E.charCodeAt(++Ae);Se=65536+((Se&1023)<<10)|gt&1023}if(Se<=127){if(W>=ye)break;D[W++]=Se}else if(Se<=2047){if(W+1>=ye)break;D[W++]=192|Se>>6,D[W++]=128|Se&63}else if(Se<=65535){if(W+2>=ye)break;D[W++]=224|Se>>12,D[W++]=128|Se>>6&63,D[W++]=128|Se&63}else{if(W+3>=ye)break;D[W++]=240|Se>>18,D[W++]=128|Se>>12&63,D[W++]=128|Se>>6&63,D[W++]=128|Se&63}}return D[W]=0,W-xe}function ft(E,D,W){return vt(E,o(),D,W)}function mt(E){for(var D=0,W=0;W<E.length;++W){var Q=E.charCodeAt(W);Q>=55296&&Q<=57343&&(Q=65536+((Q&1023)<<10)|E.charCodeAt(++W)&1023),Q<=127?++D:Q<=2047?D+=2:Q<=65535?D+=3:D+=4}return D}function dt(E,D){a().set(E,D)}function bt(E,D){return E%D>0&&(E+=D-E%D),E}var Je,jn,Wt,sr,vn,Vr,Rn,br,vr;function wn(E){Je=E,c.HEAP8=jn=new Int8Array(E),c.HEAP16=sr=new Int16Array(E),c.HEAP32=Vr=new Int32Array(E),c.HEAPU8=Wt=new Uint8Array(E),c.HEAPU16=vn=new Uint16Array(E),c.HEAPU32=Rn=new Uint32Array(E),c.HEAPF32=br=new Float32Array(E),c.HEAPF64=vr=new Float64Array(E)}var wr=c.INITIAL_MEMORY||16777216;if(w)ne=c.wasmMemory,Je=c.buffer;else if(c.wasmMemory)ne=c.wasmMemory;else if(ne=new WebAssembly.Memory({initial:wr/65536,maximum:2147483648/65536,shared:!0}),!(ne.buffer instanceof SharedArrayBuffer))throw X("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");ne&&(Je=ne.buffer),wr=Je.byteLength,wn(Je);var kr,ar=[],ws=[],Us=[],Aa=[],Si=[],ks=!1,_h=!1;w||ws.push({func:function(){jh()}});function E0(){if(!w){if(c.preRun)for(typeof c.preRun=="function"&&(c.preRun=[c.preRun]);c.preRun.length;)Dh(c.preRun.shift());Ni(ar)}}function Mu(){ks=!0,!w&&Ni(ws)}function $0(){w||Ni(Us)}function Rh(){w||(_h=!0)}function qn(){if(!w){if(c.postRun)for(typeof c.postRun=="function"&&(c.postRun=[c.postRun]);c.postRun.length;)_0(c.postRun.shift());Ni(Si)}}function Dh(E){ar.unshift(E)}function _0(E){Si.unshift(E)}var Hs=0,xa=null,io=null;function R0(E){be(!w,"addRunDependency cannot be used in a pthread worker"),Hs++,c.monitorRunDependencies&&c.monitorRunDependencies(Hs)}function D0(E){if(Hs--,c.monitorRunDependencies&&c.monitorRunDependencies(Hs),Hs==0&&(xa!==null&&(clearInterval(xa),xa=null),io)){var D=io;io=null,D()}}c.preloadedImages={},c.preloadedAudios={};function Gs(E){c.onAbort&&c.onAbort(E),w&&console.error("Pthread aborting at "+new Error().stack),E+="",X(E),he=!0,ge=1,E="abort("+E+"). Build with -s ASSERTIONS=1 for more info.";var D=new WebAssembly.RuntimeError(E);throw h(D),D}function Fh(E,D){return String.prototype.startsWith?E.startsWith(D):E.indexOf(D)===0}var Ti="data:application/octet-stream;base64,";function Mh(E){return Fh(E,Ti)}var F0="file://";function Oh(E){return Fh(E,F0)}var Kn="tfjs-backend-wasm-threaded-simd.wasm";Mh(Kn)||(Kn=T(Kn));function Ph(E){try{if(E==Kn&&se)return new Uint8Array(se);if($)return $(E);throw"both async and sync fetching of the wasm failed"}catch(D){Gs(D)}}function M0(){if(!se&&(A||x)){if(typeof fetch=="function"&&!Oh(Kn))return fetch(Kn,{credentials:"same-origin"}).then(function(E){if(!E.ok)throw"failed to load wasm binary file at '"+Kn+"'";return E.arrayBuffer()}).catch(function(){return Ph(Kn)});if(M)return new Promise(function(E,D){M(Kn,function(W){E(new Uint8Array(W))},D)})}return Promise.resolve().then(function(){return Ph(Kn)})}function O0(){var E={a:Tg};function D(Ae,Se){var gt=Ae.exports;if(c.asm=gt,kr=c.asm.F,de=Se,!w){var pn=Ce.unusedWorkers.length;Ce.unusedWorkers.forEach(function(sn){Ce.loadWasmModuleToWorker(sn,function(){--pn||D0("wasm-instantiate")})})}}w||R0("wasm-instantiate");function W(Ae){D(Ae.instance,Ae.module)}function Q(Ae){return M0().then(function(Se){return WebAssembly.instantiate(Se,E)}).then(Ae,function(Se){X("failed to asynchronously prepare wasm: "+Se),Gs(Se)})}function xe(){return!se&&typeof WebAssembly.instantiateStreaming=="function"&&!Mh(Kn)&&!Oh(Kn)&&typeof fetch=="function"?fetch(Kn,{credentials:"same-origin"}).then(function(Ae){var Se=WebAssembly.instantiateStreaming(Ae,E);return Se.then(W,function(gt){return X("wasm streaming compile failed: "+gt),X("falling back to ArrayBuffer instantiation"),Q(W)})}):Q(W)}if(c.instantiateWasm)try{var ye=c.instantiateWasm(E,D);return ye}catch(Ae){return X("Module.instantiateWasm callback failed with error: "+Ae),!1}return xe().catch(h),{}}var P0={9816:function(){throw"Canceled!"},9834:function(E,D){setTimeout(function(){I3(E,D)},0)}};function zh(){Ce.initRuntime()}function Ni(E){for(;E.length>0;){var D=E.shift();if(typeof D=="function"){D(c);continue}var W=D.func;typeof W=="number"?D.arg===void 0?kr.get(W)():kr.get(W)(D.arg):W(D.arg===void 0?null:D.arg)}}function Ou(E,D){if(E<=0||E>a().length||E&!0||D<0)return-28;if(D==0)return 0;D>=2147483647&&(D=Infinity);var W=Atomics.load(i(),Di>>2),Q=0;if(W==E){var xe=Atomics.compareExchange(i(),Di>>2,W,0);if(xe==W&&(--D,Q=1,D<=0))return 1}var ye=Atomics.notify(i(),E>>2,D);if(ye>=0)return ye+Q;throw"Atomics.notify returned an unexpected value "+ye}c._emscripten_futex_wake=Ou;function z0(E){if(w)throw"Internal Error! killThread() can only ever be called from main application thread!";if(!E)throw"Internal Error! Null pthread_ptr in killThread!";i()[E+12>>2]=0;var D=Ce.pthreads[E];D.worker.terminate(),Ce.freeThreadData(D),Ce.runningWorkers.splice(Ce.runningWorkers.indexOf(D.worker),1),D.worker.pthread=void 0}function L0(E){if(w)throw"Internal Error! cancelThread() can only ever be called from main application thread!";if(!E)throw"Internal Error! Null pthread_ptr in cancelThread!";var D=Ce.pthreads[E];D.worker.postMessage({cmd:"cancel"})}function B0(E){if(w)throw"Internal Error! cleanupThread() can only ever be called from main application thread!";if(!E)throw"Internal Error! Null pthread_ptr in cleanupThread!";var D=Ce.pthreads[E];if(D){i()[E+12>>2]=0;var W=D.worker;Ce.returnWorkerToPool(W)}}var Ce={unusedWorkers:[],runningWorkers:[],initMainThreadBlock:function(){for(var E=Math.min(4,Math.max(1,(navigator.hardwareConcurrency||1)/2)),D=0;D<E;++D)Ce.allocateUnusedWorker()},initRuntime:function(){for(var E=uo(228),D=0;D<228/4;++D)l()[E/4+D]=0;i()[E+12>>2]=E;var W=E+152;i()[W>>2]=W;for(var Q=uo(512),D=0;D<128;++D)l()[Q/4+D]=0;Atomics.store(l(),E+100>>2,Q),Atomics.store(l(),E+40>>2,E),Yg(E,!x,1),k3(E)},initWorker:function(){},pthreads:{},threadExitHandlers:[],setThreadStatus:function(){},runExitHandlers:function(){for(;Ce.threadExitHandlers.length>0;)Ce.threadExitHandlers.pop()();w&&$i()&&w3()},runExitHandlersAndDeinitThread:function(E,D){Atomics.store(l(),E+56>>2,1),Atomics.store(l(),E+60>>2,0),Ce.runExitHandlers(),Atomics.store(l(),E+4>>2,D),Atomics.store(l(),E+0>>2,1),Ou(E+0,2147483647),Yg(0,0,0)},threadExit:function(E){var D=$i();D&&(Ce.runExitHandlersAndDeinitThread(D,E),w&&postMessage({cmd:"exit"}))},threadCancel:function(){Ce.runExitHandlersAndDeinitThread($i(),-1),postMessage({cmd:"cancelDone"})},terminateAllThreads:function(){for(var E in Ce.pthreads){var D=Ce.pthreads[E];D&&D.worker&&Ce.returnWorkerToPool(D.worker)}Ce.pthreads={};for(var W=0;W<Ce.unusedWorkers.length;++W){var Q=Ce.unusedWorkers[W];Q.terminate()}Ce.unusedWorkers=[];for(var W=0;W<Ce.runningWorkers.length;++W){var Q=Ce.runningWorkers[W],D=Q.pthread;Ce.freeThreadData(D),Q.terminate()}Ce.runningWorkers=[]},freeThreadData:function(E){if(!!E){if(E.threadInfoStruct){var D=i()[E.threadInfoStruct+100>>2];i()[E.threadInfoStruct+100>>2]=0,Uu(D),Uu(E.threadInfoStruct)}E.threadInfoStruct=0,E.allocatedOwnStack&&E.stackBase&&Uu(E.stackBase),E.stackBase=0,E.worker&&(E.worker.pthread=null)}},returnWorkerToPool:function(E){Ce.runWithoutMainThreadQueuedCalls(function(){delete Ce.pthreads[E.pthread.threadInfoStruct],Ce.unusedWorkers.push(E),Ce.runningWorkers.splice(Ce.runningWorkers.indexOf(E),1),Ce.freeThreadData(E.pthread),E.pthread=void 0})},runWithoutMainThreadQueuedCalls:function(E){i()[E3>>2]=0;try{E()}finally{i()[E3>>2]=1}},receiveObjectTransfer:function(E){},loadWasmModuleToWorker:function(E,D){E.onmessage=function(W){var Q=W.data,xe=Q.cmd;if(E.pthread&&(Ce.currentProxiedOperationCallerThread=E.pthread.threadInfoStruct),Q.targetThread&&Q.targetThread!=$i()){var ye=Ce.pthreads[Q.targetThread];ye?ye.worker.postMessage(W.data,Q.transferList):console.error('Internal error! Worker sent a message "'+xe+'" to target pthread '+Q.targetThread+", but that thread no longer exists!"),Ce.currentProxiedOperationCallerThread=void 0;return}if(xe==="processQueuedMainThreadWork")Xg();else if(xe==="spawnThread")Hh(W.data);else if(xe==="cleanupThread")B0(Q.thread);else if(xe==="killThread")z0(Q.thread);else if(xe==="cancelThread")L0(Q.thread);else if(xe==="loaded")E.loaded=!0,D&&D(E),E.runPthread&&(E.runPthread(),delete E.runPthread);else if(xe==="print")j("Thread "+Q.threadId+": "+Q.text);else if(xe==="printErr")X("Thread "+Q.threadId+": "+Q.text);else if(xe==="alert")alert("Thread "+Q.threadId+": "+Q.text);else if(xe==="exit"){var Ae=E.pthread&&Atomics.load(l(),E.pthread.threadInfoStruct+64>>2);Ae&&Ce.returnWorkerToPool(E)}else if(xe==="exitProcess")try{J_(Q.returnCode)}catch(Se){if(Se instanceof Gu)return;throw Se}else xe==="cancelDone"?Ce.returnWorkerToPool(E):xe==="objectTransfer"?Ce.receiveObjectTransfer(W.data):W.data.target==="setimmediate"?E.postMessage(W.data):X("worker sent an unknown command "+xe);Ce.currentProxiedOperationCallerThread=void 0},E.onerror=function(W){X("pthread sent an error! "+W.filename+":"+W.lineno+": "+W.message)},b&&(E.on("message",function(W){E.onmessage({data:W})}),E.on("error",function(W){E.onerror(W)}),E.on("exit",function(W){})),E.postMessage({cmd:"load",urlOrBlob:c.mainScriptUrlOrBlob||r,wasmMemory:ne,wasmModule:de})},allocateUnusedWorker:function(){var E=T("tfjs-backend-wasm-threaded-simd.worker.js");Ce.unusedWorkers.push(new Worker(E))},getNewWorker:function(){return Ce.unusedWorkers.length==0&&(Ce.allocateUnusedWorker(),Ce.loadWasmModuleToWorker(Ce.unusedWorkers[0])),Ce.unusedWorkers.length>0?Ce.unusedWorkers.pop():null},busySpinWait:function(E){for(var D=performance.now()+E;performance.now()<D;);}};function W0(E,D){N3(E,D),_i(E)}c.establishStackSpace=W0;function V0(){return ie}c.getNoExitRuntime=V0;function U0(E,D){return kr.get(E)(D)}c.invokeEntryPoint=U0;function H0(E,D,W,Q){Gs("Assertion failed: "+We(E)+", at: "+[D?We(D):"unknown filename",W,Q?We(Q):"unknown function"])}function G0(E,D){var W=_main(E,D)}var lo;b?lo=function(){var E=process.hrtime();return E[0]*1e3+E[1]/1e6}:w?lo=function(){return performance.now()-c.__performance_now_clock_drift}:typeof dateNow!="undefined"?lo=dateNow:lo=function(){return performance.now()};function j0(E){return i()[b3()>>2]=E,E}function q0(E,D){if(w)return ba(1,1,E,D)}function K0(E,D){if(E==D)postMessage({cmd:"processQueuedMainThreadWork"});else if(w)postMessage({targetThread:E,cmd:"processThreadQueue"});else{var W=Ce.pthreads[E],Q=W&&W.worker;if(!Q)return;Q.postMessage({cmd:"processThreadQueue"})}return 1}function X0(){Gs()}function Z0(E,D,W){var Q=tg(D,W);return P0[E].apply(null,Q)}function Y0(E,D){}function J0(E,D,W){if(E<=0||E>a().length||E&!0)return-28;if(A){if(Atomics.load(i(),E>>2)!=D)return-6;for(var xe=performance.now(),ye=xe+W,Ae=Atomics.exchange(i(),Di>>2,E);;){if(xe=performance.now(),xe>ye)return Ae=Atomics.exchange(i(),Di>>2,0),-73;if(Ae=Atomics.exchange(i(),Di>>2,0),Ae==0)break;if(Xg(),Atomics.load(i(),E>>2)!=D)return-6;Ae=Atomics.exchange(i(),Di>>2,E)}return 0}else{var Q=Atomics.wait(i(),E>>2,D,W);if(Q==="timed-out")return-73;if(Q==="not-equal")return-6;if(Q==="ok")return 0;throw"Atomics.wait returned an unexpected value "+Q}}function Q0(E,D,W){o().copyWithin(E,D,D+W)}function eg(){return b?co("os").cpus().length:navigator.hardwareConcurrency}function ba(E,D){for(var W=arguments.length-2,Q=Hu(),xe=W,ye=Ri(xe*8),Ae=ye>>3,Se=0;Se<W;Se++){var gt=arguments[2+Se];u()[Ae+Se]=gt}var pn=T3(E,xe,ye,D);return _i(Q),pn}var Pu=[],zu=[];function tg(E,D){zu.length=0;var W;for(D>>=2;W=o()[E++];){var Q=W<105;Q&&D&1&&D++,zu.push(Q?u()[D++>>1]:i()[D]),++D}return zu}function ng(E,D,W){Pu.length=D;for(var Q=W>>3,xe=0;xe<D;xe++)Pu[xe]=u()[Q+xe];var ye=E<0,Ae=ye?P0[-E-1]:Sg[E];return Ae.apply(null,Pu)}function rg(){return o().length}function sg(E){try{return ne.grow(E-Je.byteLength+65535>>>16),wn(ne.buffer),1}catch(D){}}function ag(E){var D=rg();if(E<=D)return!1;var W=2147483648;if(E>W)return!1;for(var Q=1;Q<=4;Q*=2){var xe=D*(1+.2/Q);xe=Math.min(xe,E+100663296);var ye=Math.min(W,bt(Math.max(E,xe),65536)),Ae=sg(ye);if(Ae)return!0}return!1}var Xe={inEventHandler:0,removeAllEventListeners:function(){for(var E=Xe.eventHandlers.length-1;E>=0;--E)Xe._removeHandler(E);Xe.eventHandlers=[],Xe.deferredCalls=[]},registerRemoveEventListeners:function(){Xe.removeEventListenersRegistered||(Aa.push(Xe.removeAllEventListeners),Xe.removeEventListenersRegistered=!0)},deferredCalls:[],deferCall:function(E,D,W){function Q(Ae,Se){if(Ae.length!=Se.length)return!1;for(var gt in Ae)if(Ae[gt]!=Se[gt])return!1;return!0}for(var xe in Xe.deferredCalls){var ye=Xe.deferredCalls[xe];if(ye.targetFunction==E&&Q(ye.argsList,W))return}Xe.deferredCalls.push({targetFunction:E,precedence:D,argsList:W}),Xe.deferredCalls.sort(function(Ae,Se){return Ae.precedence<Se.precedence})},removeDeferredCalls:function(E){for(var D=0;D<Xe.deferredCalls.length;++D)Xe.deferredCalls[D].targetFunction==E&&(Xe.deferredCalls.splice(D,1),--D)},canPerformEventHandlerRequests:function(){return Xe.inEventHandler&&Xe.currentEventHandler.allowsDeferredCalls},runDeferredCalls:function(){if(!!Xe.canPerformEventHandlerRequests())for(var E=0;E<Xe.deferredCalls.length;++E){var D=Xe.deferredCalls[E];Xe.deferredCalls.splice(E,1),--E,D.targetFunction.apply(null,D.argsList)}},eventHandlers:[],removeAllHandlersOnTarget:function(E,D){for(var W=0;W<Xe.eventHandlers.length;++W)Xe.eventHandlers[W].target==E&&(!D||D==Xe.eventHandlers[W].eventTypeString)&&Xe._removeHandler(W--)},_removeHandler:function(E){var D=Xe.eventHandlers[E];D.target.removeEventListener(D.eventTypeString,D.eventListenerFunc,D.useCapture),Xe.eventHandlers.splice(E,1)},registerOrRemoveHandler:function(E){var D=function(xe){++Xe.inEventHandler,Xe.currentEventHandler=E,Xe.runDeferredCalls(),E.handlerFunc(xe),Xe.runDeferredCalls(),--Xe.inEventHandler};if(E.callbackfunc)E.eventListenerFunc=D,E.target.addEventListener(E.eventTypeString,D,E.useCapture),Xe.eventHandlers.push(E),Xe.registerRemoveEventListeners();else for(var W=0;W<Xe.eventHandlers.length;++W)Xe.eventHandlers[W].target==E.target&&Xe.eventHandlers[W].eventTypeString==E.eventTypeString&&Xe._removeHandler(W--)},queueEventHandlerOnThread_iiii:function(E,D,W,Q,xe){var ye=Hu(),Ae=Ri(12);i()[Ae>>2]=W,i()[Ae+4>>2]=Q,i()[Ae+8>>2]=xe,Zg(0,E,637534208,D,Q,Ae),_i(ye)},getTargetThreadForEventCallback:function(E){switch(E){case 1:return 0;case 2:return Ce.currentProxiedOperationCallerThread;default:return E}},getNodeNameForTarget:function(E){return E?E==window?"#window":E==screen?"#screen":E&&E.nodeName?E.nodeName:"":""},fullscreenEnabled:function(){return document.fullscreenEnabled||document.webkitFullscreenEnabled}};function og(E){var D=mt(E)+1,W=uo(D);return ft(E,W,D),W}function ig(E,D,W,Q){var xe=Hu(),ye=Ri(12),Ae=0;D&&(Ae=og(D)),i()[ye>>2]=Ae,i()[ye+4>>2]=W,i()[ye+8>>2]=Q,Zg(0,E,657457152,0,Ae,ye),_i(xe)}function lg(E,D,W,Q){D=D?We(D):"",ig(E,D,W,Q)}function ug(E){return E>2?We(E):E}var cg=[0,typeof document!="undefined"?document:0,typeof window!="undefined"?window:0];function dg(E){E=ug(E);var D=cg[E]||(typeof document!="undefined"?document.querySelector(E):void 0);return D}function Lu(E){return dg(E)}function Lh(E,D,W){var Q=Lu(E);if(!Q)return-4;if(Q.canvasSharedPtr&&(i()[Q.canvasSharedPtr>>2]=D,i()[Q.canvasSharedPtr+4>>2]=W),Q.offscreenCanvas||!Q.controlTransferredOffscreen){Q.offscreenCanvas&&(Q=Q.offscreenCanvas);var xe=!1;if(Q.GLctxObject&&Q.GLctxObject.GLctx){var ye=Q.GLctxObject.GLctx.getParameter(2978);xe=ye[0]===0&&ye[1]===0&&ye[2]===Q.width&&ye[3]===Q.height}Q.width=D,Q.height=W,xe&&Q.GLctxObject.GLctx.viewport(0,0,D,W)}else if(Q.canvasSharedPtr){var Ae=i()[Q.canvasSharedPtr+8>>2];return lg(Ae,E,D,W),1}else return-4;return 0}function Bh(E,D,W){return w?ba(2,1,E,D,W):Lh(E,D,W)}function hg(E,D,W){var Q=Lu(E);return Q?Lh(E,D,W):Bh(E,D,W)}function pg(E){}function fg(E,D){}function mg(E){var D=E.getExtension("ANGLE_instanced_arrays");if(D)return E.vertexAttribDivisor=function(W,Q){D.vertexAttribDivisorANGLE(W,Q)},E.drawArraysInstanced=function(W,Q,xe,ye){D.drawArraysInstancedANGLE(W,Q,xe,ye)},E.drawElementsInstanced=function(W,Q,xe,ye,Ae){D.drawElementsInstancedANGLE(W,Q,xe,ye,Ae)},1}function gg(E){var D=E.getExtension("OES_vertex_array_object");if(D)return E.createVertexArray=function(){return D.createVertexArrayOES()},E.deleteVertexArray=function(W){D.deleteVertexArrayOES(W)},E.bindVertexArray=function(W){D.bindVertexArrayOES(W)},E.isVertexArray=function(W){return D.isVertexArrayOES(W)},1}function yg(E){var D=E.getExtension("WEBGL_draw_buffers");if(D)return E.drawBuffers=function(W,Q){D.drawBuffersWEBGL(W,Q)},1}function Ag(E){return!!(E.multiDrawWebgl=E.getExtension("WEBGL_multi_draw"))}var ht={counter:1,buffers:[],programs:[],framebuffers:[],renderbuffers:[],textures:[],uniforms:[],shaders:[],vaos:[],contexts:{},offscreenCanvases:{},timerQueriesEXT:[],programInfos:{},stringCache:{},unpackAlignment:4,recordError:function(D){ht.lastError||(ht.lastError=D)},getNewId:function(E){for(var D=ht.counter++,W=E.length;W<D;W++)E[W]=null;return D},getSource:function(E,D,W,Q){for(var xe="",ye=0;ye<D;++ye){var Ae=Q?i()[Q+ye*4>>2]:-1;xe+=We(i()[W+ye*4>>2],Ae<0?void 0:Ae)}return xe},createContext:function(E,D){var W=E.getContext("webgl",D);if(!W)return 0;var Q=ht.registerContext(W,D);return Q},registerContext:function(E,D){var W=uo(8);i()[W+4>>2]=$i();var Q={handle:W,attributes:D,version:D.majorVersion,GLctx:E};return E.canvas&&(E.canvas.GLctxObject=Q),ht.contexts[W]=Q,(typeof D.enableExtensionsByDefault=="undefined"||D.enableExtensionsByDefault)&&ht.initExtensions(Q),W},makeContextCurrent:function(E){return ht.currentContext=ht.contexts[E],c.ctx=va=ht.currentContext&&ht.currentContext.GLctx,!(E&&!va)},getContext:function(E){return ht.contexts[E]},deleteContext:function(E){ht.currentContext===ht.contexts[E]&&(ht.currentContext=null),typeof Xe=="object"&&Xe.removeAllHandlersOnTarget(ht.contexts[E].GLctx.canvas),ht.contexts[E]&&ht.contexts[E].GLctx.canvas&&(ht.contexts[E].GLctx.canvas.GLctxObject=void 0),Uu(ht.contexts[E].handle),ht.contexts[E]=null},initExtensions:function(E){if(E||(E=ht.currentContext),!E.initExtensionsDone){E.initExtensionsDone=!0;var D=E.GLctx;mg(D),gg(D),yg(D),D.disjointTimerQueryExt=D.getExtension("EXT_disjoint_timer_query"),Ag(D);var W=D.getSupportedExtensions()||[];W.forEach(function(Q){Q.indexOf("lose_context")<0&&Q.indexOf("debug")<0&&D.getExtension(Q)})}},populateUniformTable:function(E){for(var D=ht.programs[E],W=ht.programInfos[E]={uniforms:{},maxUniformLength:0,maxAttributeLength:-1,maxUniformBlockNameLength:-1},Q=W.uniforms,xe=va.getProgramParameter(D,35718),ye=0;ye<xe;++ye){var Ae=va.getActiveUniform(D,ye),Se=Ae.name;W.maxUniformLength=Math.max(W.maxUniformLength,Se.length+1),Se.slice(-1)=="]"&&(Se=Se.slice(0,Se.lastIndexOf("[")));var gt=va.getUniformLocation(D,Se);if(gt){var pn=ht.getNewId(ht.uniforms);Q[Se]=[Ae.size,pn],ht.uniforms[pn]=gt;for(var sn=1;sn<Ae.size;++sn){var ka=Se+"["+sn+"]";gt=va.getUniformLocation(D,ka),pn=ht.getNewId(ht.uniforms),ht.uniforms[pn]=gt}}}}},xg=["default","low-power","high-performance"];function bg(E,D){var W=D>>2,Q=i()[W+(24>>2)],xe={alpha:!!i()[W+(0>>2)],depth:!!i()[W+(4>>2)],stencil:!!i()[W+(8>>2)],antialias:!!i()[W+(12>>2)],premultipliedAlpha:!!i()[W+(16>>2)],preserveDrawingBuffer:!!i()[W+(20>>2)],powerPreference:xg[Q],failIfMajorPerformanceCaveat:!!i()[W+(28>>2)],majorVersion:i()[W+(32>>2)],minorVersion:i()[W+(36>>2)],enableExtensionsByDefault:i()[W+(40>>2)],explicitSwapControl:i()[W+(44>>2)],proxyContextToMainThread:i()[W+(48>>2)],renderViaOffscreenBackBuffer:i()[W+(52>>2)]},ye=Lu(E);if(!ye||xe.explicitSwapControl)return 0;var Ae=ht.createContext(ye,xe);return Ae}function vg(E,D){return bg(E,D)}var Ci={mappings:{},buffers:[null,[],[]],printChar:function(E,D){var W=Ci.buffers[E];D===0||D===10?((E===1?j:X)(qe(W,0)),W.length=0):W.push(D)},varargs:void 0,get:function(){Ci.varargs+=4;var E=i()[Ci.varargs-4>>2];return E},getStr:function(E){var D=We(E);return D},get64:function(E,D){return E}};function Wh(E){return w?ba(3,1,E):0}function Vh(E,D,W,Q,xe){if(w)return ba(4,1,E,D,W,Q,xe)}function Uh(E,D,W,Q){if(w)return ba(5,1,E,D,W,Q);for(var xe=0,ye=0;ye<W;ye++){for(var Ae=i()[D+ye*8>>2],Se=i()[D+(ye*8+4)>>2],gt=0;gt<Se;gt++)Ci.printChar(E,o()[Ae+gt]);xe+=Se}return i()[Q>>2]=xe,0}function wg(E){var D=Ce.threadExitHandlers.pop();E&&D()}function kg(E,D){Ce.threadExitHandlers.push(function(){kr.get(E)(D)})}function Hh(E){if(w)throw"Internal Error! spawnThread() can only ever be called from main application thread!";var D=Ce.getNewWorker();if(D.pthread!==void 0)throw"Internal error!";if(!E.pthread_ptr)throw"Internal error, no pthread ptr!";Ce.runningWorkers.push(D);for(var W=uo(128*4),Q=0;Q<128;++Q)i()[W+Q*4>>2]=0;var xe=E.stackBase+E.stackSize,ye=Ce.pthreads[E.pthread_ptr]={worker:D,stackBase:E.stackBase,stackSize:E.stackSize,allocatedOwnStack:E.allocatedOwnStack,threadInfoStruct:E.pthread_ptr},Ae=ye.threadInfoStruct>>2;Atomics.store(l(),Ae+(64>>2),E.detached),Atomics.store(l(),Ae+(100>>2),W),Atomics.store(l(),Ae+(40>>2),ye.threadInfoStruct),Atomics.store(l(),Ae+(80>>2),E.stackSize),Atomics.store(l(),Ae+(76>>2),xe),Atomics.store(l(),Ae+(104>>2),E.stackSize),Atomics.store(l(),Ae+(104+8>>2),xe),Atomics.store(l(),Ae+(104+12>>2),E.detached);var Se=v3(),gt=Se+40;Atomics.store(l(),Ae+(172>>2),gt),D.pthread=ye;var pn={cmd:"run",start_routine:E.startRoutine,arg:E.arg,threadInfoStruct:E.pthread_ptr,stackBase:E.stackBase,stackSize:E.stackSize};D.runPthread=function(){pn.time=performance.now(),D.postMessage(pn,E.transferList)},D.loaded&&(D.runPthread(),delete D.runPthread)}function Ig(E,D,W,Q){if(typeof SharedArrayBuffer=="undefined")return X("Current environment does not support SharedArrayBuffer, pthreads are not available!"),6;if(!E)return X("pthread_create called with a null thread pointer!"),28;var xe=[],ye=0;if(w&&(xe.length===0||ye))return S3(687865856,E,D,W,Q);if(ye)return ye;var Ae=0,Se=0,gt=0;D&&D!=-1?(Ae=i()[D>>2],Ae+=81920,Se=i()[D+8>>2],gt=i()[D+12>>2]!==0):Ae=2097152;var pn=Se==0;pn?Se=C3(16,Ae):(Se-=Ae,be(Se>0));for(var sn=uo(228),ka=0;ka<228>>2;++ka)l()[(sn>>2)+ka]=0;i()[E>>2]=sn,i()[sn+12>>2]=sn;var Fi=sn+152;i()[Fi>>2]=Fi;var Dn={stackBase:Se,stackSize:Ae,allocatedOwnStack:pn,detached:gt,startRoutine:W,pthread_ptr:sn,arg:Q,transferList:xe};return w?(Dn.cmd="spawnThread",postMessage(Dn,xe)):Hh(Dn),0}function Gh(E){if(w)return ba(6,1,E);switch(E){case 30:return 16384;case 85:var D=2147483648;return D/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 j0(28),-1}w||Ce.initMainThreadBlock();var va,Sg=[null,q0,Bh,Wh,Vh,Uh,Gh],Tg={e:H0,r:G0,x:K0,b:X0,y:Z0,j:Y0,c:J0,d:Ou,f:lo,p:Q0,z:eg,u:ng,q:ag,v:hg,i:pg,t:fg,w:vg,m:Wh,n:Vh,g:Uh,o:zh,a:ne||c.wasmMemory,k:wg,l:kg,h:Ig,s:Gh},x3=O0(),jh=c.___wasm_call_ctors=function(){return(jh=c.___wasm_call_ctors=c.asm.A).apply(null,arguments)},Ng=c._init=function(){return(Ng=c._init=c.asm.B).apply(null,arguments)},Cg=c._register_tensor=function(){return(Cg=c._register_tensor=c.asm.C).apply(null,arguments)},Eg=c._dispose_data=function(){return(Eg=c._dispose_data=c.asm.D).apply(null,arguments)},$g=c._dispose=function(){return($g=c._dispose=c.asm.E).apply(null,arguments)},_g=c._Abs=function(){return(_g=c._Abs=c.asm.G).apply(null,arguments)},Rg=c._Add=function(){return(Rg=c._Add=c.asm.H).apply(null,arguments)},Dg=c._AddN=function(){return(Dg=c._AddN=c.asm.I).apply(null,arguments)},Fg=c._All=function(){return(Fg=c._All=c.asm.J).apply(null,arguments)},Mg=c._Any=function(){return(Mg=c._Any=c.asm.K).apply(null,arguments)},Og=c._ArgMax=function(){return(Og=c._ArgMax=c.asm.L).apply(null,arguments)},Pg=c._AvgPool=function(){return(Pg=c._AvgPool=c.asm.M).apply(null,arguments)},zg=c._BatchMatMul=function(){return(zg=c._BatchMatMul=c.asm.N).apply(null,arguments)},Lg=c._Ceil=function(){return(Lg=c._Ceil=c.asm.O).apply(null,arguments)},Bg=c._ClipByValue=function(){return(Bg=c._ClipByValue=c.asm.P).apply(null,arguments)},Wg=c._Conv2D=function(){return(Wg=c._Conv2D=c.asm.Q).apply(null,arguments)},Vg=c._Conv2DBackpropInput=function(){return(Vg=c._Conv2DBackpropInput=c.asm.R).apply(null,arguments)},Ug=c._Cos=function(){return(Ug=c._Cos=c.asm.S).apply(null,arguments)},Hg=c._CropAndResize=function(){return(Hg=c._CropAndResize=c.asm.T).apply(null,arguments)},Gg=c._Cumsum=function(){return(Gg=c._Cumsum=c.asm.U).apply(null,arguments)},jg=c._DepthToSpace=function(){return(jg=c._DepthToSpace=c.asm.V).apply(null,arguments)},qg=c._DepthwiseConv2dNative=function(){return(qg=c._DepthwiseConv2dNative=c.asm.W).apply(null,arguments)},qh=c._Equal=function(){return(qh=c._Equal=c.asm.X).apply(null,arguments)},Kh=c._Exp=function(){return(Kh=c._Exp=c.asm.Y).apply(null,arguments)},Xh=c._FlipLeftRight=function(){return(Xh=c._FlipLeftRight=c.asm.Z).apply(null,arguments)},Bu=c._Floor=function(){return(Bu=c._Floor=c.asm._).apply(null,arguments)},Ei=c._FloorDiv=function(){return(Ei=c._FloorDiv=c.asm.$).apply(null,arguments)},Kg=c._FusedBatchNorm=function(){return(Kg=c._FusedBatchNorm=c.asm.aa).apply(null,arguments)},Wu=c._FusedConv2D=function(){return(Wu=c._FusedConv2D=c.asm.ba).apply(null,arguments)},te=c._FusedDepthwiseConv2D=function(){return(te=c._FusedDepthwiseConv2D=c.asm.ca).apply(null,arguments)},le=c._Gather=function(){return(le=c._Gather=c.asm.da).apply(null,arguments)},we=c._GatherNd=function(){return(we=c._GatherNd=c.asm.ea).apply(null,arguments)},lt=c._Greater=function(){return(lt=c._Greater=c.asm.fa).apply(null,arguments)},Gt=c._GreaterEqual=function(){return(Gt=c._GreaterEqual=c.asm.ga).apply(null,arguments)},Mt=c._LeakyRelu=function(){return(Mt=c._LeakyRelu=c.asm.ha).apply(null,arguments)},et=c._Less=function(){return(et=c._Less=c.asm.ia).apply(null,arguments)},tt=c._LessEqual=function(){return(tt=c._LessEqual=c.asm.ja).apply(null,arguments)},kn=c._Log=function(){return(kn=c._Log=c.asm.ka).apply(null,arguments)},js=c._LogicalAnd=function(){return(js=c._LogicalAnd=c.asm.la).apply(null,arguments)},qs=c._Max=function(){return(qs=c._Max=c.asm.ma).apply(null,arguments)},Zh=c._MaxPool=function(){return(Zh=c._MaxPool=c.asm.na).apply(null,arguments)},Vu=c._Maximum=function(){return(Vu=c._Maximum=c.asm.oa).apply(null,arguments)},or=c._Mean=function(){return(or=c._Mean=c.asm.pa).apply(null,arguments)},wa=c._Min=function(){return(wa=c._Min=c.asm.qa).apply(null,arguments)},Yh=c._Minimum=function(){return(Yh=c._Minimum=c.asm.ra).apply(null,arguments)},d_=c._MirrorPad=function(){return(d_=c._MirrorPad=c.asm.sa).apply(null,arguments)},h_=c._Multiply=function(){return(h_=c._Multiply=c.asm.ta).apply(null,arguments)},p_=c._Neg=function(){return(p_=c._Neg=c.asm.ua).apply(null,arguments)},f_=c._NonMaxSuppressionV3=function(){return(f_=c._NonMaxSuppressionV3=c.asm.va).apply(null,arguments)},m_=c._NonMaxSuppressionV4=function(){return(m_=c._NonMaxSuppressionV4=c.asm.wa).apply(null,arguments)},g_=c._NonMaxSuppressionV5=function(){return(g_=c._NonMaxSuppressionV5=c.asm.xa).apply(null,arguments)},y_=c._NotEqual=function(){return(y_=c._NotEqual=c.asm.ya).apply(null,arguments)},A_=c._OneHot=function(){return(A_=c._OneHot=c.asm.za).apply(null,arguments)},x_=c._PadV2=function(){return(x_=c._PadV2=c.asm.Aa).apply(null,arguments)},b_=c._Pow=function(){return(b_=c._Pow=c.asm.Ba).apply(null,arguments)},v_=c._Prelu=function(){return(v_=c._Prelu=c.asm.Ca).apply(null,arguments)},w_=c._Prod=function(){return(w_=c._Prod=c.asm.Da).apply(null,arguments)},k_=c._RealDiv=function(){return(k_=c._RealDiv=c.asm.Ea).apply(null,arguments)},I_=c._Relu=function(){return(I_=c._Relu=c.asm.Fa).apply(null,arguments)},S_=c._Relu6=function(){return(S_=c._Relu6=c.asm.Ga).apply(null,arguments)},T_=c._ResizeBilinear=function(){return(T_=c._ResizeBilinear=c.asm.Ha).apply(null,arguments)},N_=c._Reverse=function(){return(N_=c._Reverse=c.asm.Ia).apply(null,arguments)},C_=c._RotateWithOffset=function(){return(C_=c._RotateWithOffset=c.asm.Ja).apply(null,arguments)},E_=c._Round=function(){return(E_=c._Round=c.asm.Ka).apply(null,arguments)},$_=c._Rsqrt=function(){return($_=c._Rsqrt=c.asm.La).apply(null,arguments)},__=c._ScatterNd=function(){return(__=c._ScatterNd=c.asm.Ma).apply(null,arguments)},R_=c._SelectV2=function(){return(R_=c._SelectV2=c.asm.Na).apply(null,arguments)},D_=c._Sigmoid=function(){return(D_=c._Sigmoid=c.asm.Oa).apply(null,arguments)},F_=c._Sin=function(){return(F_=c._Sin=c.asm.Pa).apply(null,arguments)},M_=c._Softmax=function(){return(M_=c._Softmax=c.asm.Qa).apply(null,arguments)},O_=c._Sqrt=function(){return(O_=c._Sqrt=c.asm.Ra).apply(null,arguments)},P_=c._Square=function(){return(P_=c._Square=c.asm.Sa).apply(null,arguments)},z_=c._SquaredDifference=function(){return(z_=c._SquaredDifference=c.asm.Ta).apply(null,arguments)},L_=c._Step=function(){return(L_=c._Step=c.asm.Ua).apply(null,arguments)},B_=c._StridedSlice=function(){return(B_=c._StridedSlice=c.asm.Va).apply(null,arguments)},W_=c._Sub=function(){return(W_=c._Sub=c.asm.Wa).apply(null,arguments)},V_=c._Sum=function(){return(V_=c._Sum=c.asm.Xa).apply(null,arguments)},U_=c._Tan=function(){return(U_=c._Tan=c.asm.Ya).apply(null,arguments)},H_=c._Tanh=function(){return(H_=c._Tanh=c.asm.Za).apply(null,arguments)},G_=c._Tile=function(){return(G_=c._Tile=c.asm._a).apply(null,arguments)},j_=c._TopK=function(){return(j_=c._TopK=c.asm.$a).apply(null,arguments)},q_=c._Transform=function(){return(q_=c._Transform=c.asm.ab).apply(null,arguments)},K_=c._Transpose=function(){return(K_=c._Transpose=c.asm.bb).apply(null,arguments)},X_=c.__FusedMatMul=function(){return(X_=c.__FusedMatMul=c.asm.cb).apply(null,arguments)},uo=c._malloc=function(){return(uo=c._malloc=c.asm.db).apply(null,arguments)},Uu=c._free=function(){return(Uu=c._free=c.asm.eb).apply(null,arguments)},b3=c.___errno_location=function(){return(b3=c.___errno_location=c.asm.fb).apply(null,arguments)},v3=c._emscripten_get_global_libc=function(){return(v3=c._emscripten_get_global_libc=c.asm.gb).apply(null,arguments)},$i=c._pthread_self=function(){return($i=c._pthread_self=c.asm.hb).apply(null,arguments)},w3=c.___pthread_tsd_run_dtors=function(){return(w3=c.___pthread_tsd_run_dtors=c.asm.ib).apply(null,arguments)},Xg=c._emscripten_main_thread_process_queued_calls=function(){return(Xg=c._emscripten_main_thread_process_queued_calls=c.asm.jb).apply(null,arguments)},Z_=c._emscripten_current_thread_process_queued_calls=function(){return(Z_=c._emscripten_current_thread_process_queued_calls=c.asm.kb).apply(null,arguments)},k3=c._emscripten_register_main_browser_thread_id=function(){return(k3=c._emscripten_register_main_browser_thread_id=c.asm.lb).apply(null,arguments)},I3=c.__emscripten_do_dispatch_to_thread=function(){return(I3=c.__emscripten_do_dispatch_to_thread=c.asm.mb).apply(null,arguments)},S3=c._emscripten_sync_run_in_main_thread_4=function(){return(S3=c._emscripten_sync_run_in_main_thread_4=c.asm.nb).apply(null,arguments)},T3=c._emscripten_run_in_main_runtime_thread_js=function(){return(T3=c._emscripten_run_in_main_runtime_thread_js=c.asm.ob).apply(null,arguments)},Zg=c.__emscripten_call_on_thread=function(){return(Zg=c.__emscripten_call_on_thread=c.asm.pb).apply(null,arguments)},Y_=c._emscripten_tls_init=function(){return(Y_=c._emscripten_tls_init=c.asm.qb).apply(null,arguments)},Yg=c.__emscripten_thread_init=function(){return(Yg=c.__emscripten_thread_init=c.asm.rb).apply(null,arguments)},Hu=c.stackSave=function(){return(Hu=c.stackSave=c.asm.sb).apply(null,arguments)},_i=c.stackRestore=function(){return(_i=c.stackRestore=c.asm.tb).apply(null,arguments)},Ri=c.stackAlloc=function(){return(Ri=c.stackAlloc=c.asm.ub).apply(null,arguments)},N3=c._emscripten_stack_set_limits=function(){return(N3=c._emscripten_stack_set_limits=c.asm.vb).apply(null,arguments)},C3=c._memalign=function(){return(C3=c._memalign=c.asm.wb).apply(null,arguments)},E3=c.__emscripten_allow_main_runtime_queued_calls=9808,Di=c.__emscripten_main_thread_futex=11432;c.cwrap=ze,c.PThread=Ce,c.PThread=Ce,c.wasmMemory=ne,c.ExitStatus=Gu;var Jh;function Gu(E){this.name="ExitStatus",this.message="Program terminated with exit("+E+")",this.status=E}io=function E(){Jh||Jg(),Jh||(io=E)};function Jg(E){if(E=E||m,Hs>0)return;if(w){d(c),Mu(),postMessage({cmd:"loaded"});return}if(E0(),Hs>0)return;function D(){Jh||(Jh=!0,c.calledRun=!0,!he&&(Mu(),$0(),d(c),c.onRuntimeInitialized&&c.onRuntimeInitialized(),qn()))}c.setStatus?(c.setStatus("Running..."),setTimeout(function(){setTimeout(function(){c.setStatus("")},1),D()},1)):D()}c.run=Jg;function J_(E,D){if(!(D&&ie&&E===0)){if(!D&&w)throw postMessage({cmd:"exitProcess",returnCode:E}),new Gu(E);ie||(Ce.terminateAllThreads(),ge=E,Rh(),c.onExit&&c.onExit(E),he=!0),y(E,new Gu(E))}}if(c.preInit)for(typeof c.preInit=="function"&&(c.preInit=[c.preInit]);c.preInit.length>0;)c.preInit.pop()();return w&&(ie=!1,Ce.initWorker()),Jg(),s.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)}}),SR=Ot({"node_modules/.pnpm/@tensorflow+tfjs-backend-wasm@3.7.0_@tensorflow+tfjs-core@3.7.0/node_modules/@tensorflow/tfjs-backend-wasm/wasm-out/tfjs-backend-wasm.js"(e,t){var n=function(){var r=typeof document!="undefined"&&document.currentScript?document.currentScript.src:void 0;return typeof __filename!="undefined"&&(r=r||__filename),function(s){s=s||{};var a=typeof s!="undefined"?s:{},o,i;a.ready=new Promise(function(te,le){o=te,i=le});var l={},u;for(u in a)a.hasOwnProperty(u)&&(l[u]=a[u]);var c=[],d="./this.program",h=function(te,le){throw le},p=!1,f=!1,m=!1,g=!1;p=typeof window=="object",f=typeof importScripts=="function",m=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string",g=!p&&!m&&!f;var y="";function A(te){return a.locateFile?a.locateFile(te,y):y+te}var x,b,v,w,I,T;m?(f?y=ju().dirname(y)+"/":y=__dirname+"/",x=function(le,we){return I||(I=co("fs")),T||(T=ju()),le=T.normalize(le),I.readFileSync(le,we?null:"utf8")},v=function(le){var we=x(le,!0);return we.buffer||(we=new Uint8Array(we)),j(we.buffer),we},process.argv.length>1&&(d=process.argv[1].replace(/\\/g,"/")),c=process.argv.slice(2),process.on("uncaughtException",function(te){if(!(te instanceof Kg))throw te}),process.on("unhandledRejection",ks),h=function(te){process.exit(te)},a.inspect=function(){return"[Emscripten Module object]"}):g?(typeof read!="undefined"&&(x=function(le){return read(le)}),v=function(le){var we;return typeof readbuffer=="function"?new Uint8Array(readbuffer(le)):(we=read(le,"binary"),j(typeof we=="object"),we)},typeof scriptArgs!="undefined"?c=scriptArgs:typeof arguments!="undefined"&&(c=arguments),typeof quit=="function"&&(h=function(te){quit(te)}),typeof print!="undefined"&&(typeof console=="undefined"&&(console={}),console.log=print,console.warn=console.error=typeof printErr!="undefined"?printErr:print)):(p||f)&&(f?y=self.location.href:typeof document!="undefined"&&document.currentScript&&(y=document.currentScript.src),r&&(y=r),y.indexOf("blob:")!==0?y=y.substr(0,y.lastIndexOf("/")+1):y="",x=function(te){var le=new XMLHttpRequest;return le.open("GET",te,!1),le.send(null),le.responseText},f&&(v=function(te){var le=new XMLHttpRequest;return le.open("GET",te,!1),le.responseType="arraybuffer",le.send(null),new Uint8Array(le.response)}),b=function(te,le,we){var lt=new XMLHttpRequest;lt.open("GET",te,!0),lt.responseType="arraybuffer",lt.onload=function(){if(lt.status==200||lt.status==0&<.response){le(lt.response);return}we()},lt.onerror=we,lt.send(null)},w=function(te){document.title=te});var C=a.print||console.log.bind(console),M=a.printErr||console.warn.bind(console);for(u in l)l.hasOwnProperty(u)&&(a[u]=l[u]);l=null,a.arguments&&(c=a.arguments),a.thisProgram&&(d=a.thisProgram),a.quit&&(h=a.quit);var $;a.wasmBinary&&($=a.wasmBinary);var R=a.noExitRuntime||!0;typeof WebAssembly!="object"&&ks("no native wasm support detected");var N,F=!1,B;function j(te,le){te||ks("Assertion failed: "+le)}function X(te){var le=a["_"+te];return j(le,"Cannot call unknown function "+te+", make sure it is exported"),le}function Y(te,le,we,lt,Gt){var Mt={string:function(or){var wa=0;if(or!=null&&or!==0){var Yh=(or.length<<2)+1;wa=Bu(Yh),de(or,wa,Yh)}return wa},array:function(or){var wa=Bu(or.length);return he(or,wa),wa}};function et(or){return le==="string"?ie(or):le==="boolean"?Boolean(or):or}var tt=X(te),kn=[],js=0;if(lt)for(var qs=0;qs<lt.length;qs++){var Zh=Mt[we[qs]];Zh?(js===0&&(js=Kh()),kn[qs]=Zh(lt[qs])):kn[qs]=lt[qs]}var Vu=tt.apply(null,kn);return Vu=et(Vu),js!==0&&Xh(js),Vu}function ee(te,le,we,lt){we=we||[];var Gt=we.every(function(et){return et==="number"}),Mt=le!=="string";return Mt&&Gt&&!lt?X(te):function(){return Y(te,le,we,arguments,lt)}}var oe=typeof TextDecoder!="undefined"?new TextDecoder("utf8"):void 0;function se(te,le,we){for(var lt=le+we,Gt=le;te[Gt]&&!(Gt>=lt);)++Gt;if(Gt-le>16&&te.subarray&&oe)return oe.decode(te.subarray(le,Gt));for(var Mt="";le<Gt;){var et=te[le++];if(!(et&128)){Mt+=String.fromCharCode(et);continue}var tt=te[le++]&63;if((et&224)==192){Mt+=String.fromCharCode((et&31)<<6|tt);continue}var kn=te[le++]&63;if((et&240)==224?et=(et&15)<<12|tt<<6|kn:et=(et&7)<<18|tt<<12|kn<<6|te[le++]&63,et<65536)Mt+=String.fromCharCode(et);else{var js=et-65536;Mt+=String.fromCharCode(55296|js>>10,56320|js&1023)}}return Mt}function ie(te,le){return te?se($e,te,le):""}function ne(te,le,we,lt){if(!(lt>0))return 0;for(var Gt=we,Mt=we+lt-1,et=0;et<te.length;++et){var tt=te.charCodeAt(et);if(tt>=55296&&tt<=57343){var kn=te.charCodeAt(++et);tt=65536+((tt&1023)<<10)|kn&1023}if(tt<=127){if(we>=Mt)break;le[we++]=tt}else if(tt<=2047){if(we+1>=Mt)break;le[we++]=192|tt>>6,le[we++]=128|tt&63}else if(tt<=65535){if(we+2>=Mt)break;le[we++]=224|tt>>12,le[we++]=128|tt>>6&63,le[we++]=128|tt&63}else{if(we+3>=Mt)break;le[we++]=240|tt>>18,le[we++]=128|tt>>12&63,le[we++]=128|tt>>6&63,le[we++]=128|tt&63}}return le[we]=0,we-Gt}function de(te,le,we){return ne(te,$e,le,we)}function he(te,le){Ee.set(te,le)}function ge(te,le){return te%le>0&&(te+=le-te%le),te}var be,Ee,$e,ze,qe,We,vt,ft,mt;function dt(te){be=te,a.HEAP8=Ee=new Int8Array(te),a.HEAP16=ze=new Int16Array(te),a.HEAP32=We=new Int32Array(te),a.HEAPU8=$e=new Uint8Array(te),a.HEAPU16=qe=new Uint16Array(te),a.HEAPU32=vt=new Uint32Array(te),a.HEAPF32=ft=new Float32Array(te),a.HEAPF64=mt=new Float64Array(te)}var bt=a.INITIAL_MEMORY||16777216,Je,jn=[],Wt=[],sr=[],vn=[],Vr=!1;Wt.push({func:function(){zh()}});function Rn(){if(a.preRun)for(typeof a.preRun=="function"&&(a.preRun=[a.preRun]);a.preRun.length;)wr(a.preRun.shift());xa(jn)}function br(){Vr=!0,xa(Wt)}function vr(){xa(sr)}function wn(){if(a.postRun)for(typeof a.postRun=="function"&&(a.postRun=[a.postRun]);a.postRun.length;)kr(a.postRun.shift());xa(vn)}function wr(te){jn.unshift(te)}function kr(te){vn.unshift(te)}var ar=0,ws=null,Us=null;function Aa(te){ar++,a.monitorRunDependencies&&a.monitorRunDependencies(ar)}function Si(te){if(ar--,a.monitorRunDependencies&&a.monitorRunDependencies(ar),ar==0&&(ws!==null&&(clearInterval(ws),ws=null),Us)){var le=Us;Us=null,le()}}a.preloadedImages={},a.preloadedAudios={};function ks(te){a.onAbort&&a.onAbort(te),te+="",M(te),F=!0,B=1,te="abort("+te+"). Build with -s ASSERTIONS=1 for more info.";var le=new WebAssembly.RuntimeError(te);throw i(le),le}function _h(te,le){return String.prototype.startsWith?te.startsWith(le):te.indexOf(le)===0}var E0="data:application/octet-stream;base64,";function Mu(te){return _h(te,E0)}var $0="file://";function Rh(te){return _h(te,$0)}var qn="tfjs-backend-wasm.wasm";Mu(qn)||(qn=A(qn));function Dh(te){try{if(te==qn&&$)return new Uint8Array($);if(v)return v(te);throw"both async and sync fetching of the wasm failed"}catch(le){ks(le)}}function _0(){if(!$&&(p||f)){if(typeof fetch=="function"&&!Rh(qn))return fetch(qn,{credentials:"same-origin"}).then(function(te){if(!te.ok)throw"failed to load wasm binary file at '"+qn+"'";return te.arrayBuffer()}).catch(function(){return Dh(qn)});if(b)return new Promise(function(te,le){b(qn,function(we){te(new Uint8Array(we))},le)})}return Promise.resolve().then(function(){return Dh(qn)})}function Hs(){var te={a:O0};function le(et,tt){var kn=et.exports;a.asm=kn,N=a.asm.i,dt(N.buffer),Je=a.asm.o,Si("wasm-instantiate")}Aa("wasm-instantiate");function we(et){le(et.instance)}function lt(et){return _0().then(function(tt){return WebAssembly.instantiate(tt,te)}).then(et,function(tt){M("failed to asynchronously prepare wasm: "+tt),ks(tt)})}function Gt(){return!$&&typeof WebAssembly.instantiateStreaming=="function"&&!Mu(qn)&&!Rh(qn)&&typeof fetch=="function"?fetch(qn,{credentials:"same-origin"}).then(function(et){var tt=WebAssembly.instantiateStreaming(et,te);return tt.then(we,function(kn){return M("wasm streaming compile failed: "+kn),M("falling back to ArrayBuffer instantiation"),lt(we)})}):lt(we)}if(a.instantiateWasm)try{var Mt=a.instantiateWasm(te,le);return Mt}catch(et){return M("Module.instantiateWasm callback failed with error: "+et),!1}return Gt().catch(i),{}}function xa(te){for(;te.length>0;){var le=te.shift();if(typeof le=="function"){le(a);continue}var we=le.func;typeof we=="number"?le.arg===void 0?Je.get(we)():Je.get(we)(le.arg):we(le.arg===void 0?null:le.arg)}}function io(){ks()}function R0(te,le,we){$e.copyWithin(te,le,le+we)}function D0(){return $e.length}function Gs(te){try{return N.grow(te-be.byteLength+65535>>>16),dt(N.buffer),1}catch(le){}}function Fh(te){var le=D0(),we=2147483648;if(te>we)return!1;for(var lt=1;lt<=4;lt*=2){var Gt=le*(1+.2/lt);Gt=Math.min(Gt,te+100663296);var Mt=Math.min(we,ge(Math.max(te,Gt),65536)),et=Gs(Mt);if(et)return!0}return!1}var Ti={mappings:{},buffers:[null,[],[]],printChar:function(te,le){var we=Ti.buffers[te];le===0||le===10?((te===1?C:M)(se(we,0)),we.length=0):we.push(le)},varargs:void 0,get:function(){Ti.varargs+=4;var te=We[Ti.varargs-4>>2];return te},getStr:function(te){var le=ie(te);return le},get64:function(te,le){return te}};function Mh(te){return 0}function F0(te,le,we,lt,Gt){}function Oh(te,le,we,lt){for(var Gt=0,Mt=0;Mt<we;Mt++){for(var et=We[le+Mt*8>>2],tt=We[le+(Mt*8+4)>>2],kn=0;kn<tt;kn++)Ti.printChar(te,$e[et+kn]);Gt+=tt}return We[lt>>2]=Gt,0}function Kn(){return 6}function Ph(te){return We[qh()>>2]=te,te}function M0(te){switch(te){case 30:return 16384;case 85:var le=2147483648;return le/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 Ph(28),-1}var O0={a:io,d:R0,e:Fh,f:Mh,c:F0,b:Oh,g:Kn,h:M0},P0=Hs(),zh=a.___wasm_call_ctors=function(){return(zh=a.___wasm_call_ctors=a.asm.j).apply(null,arguments)},Ni=a._init=function(){return(Ni=a._init=a.asm.k).apply(null,arguments)},Ou=a._register_tensor=function(){return(Ou=a._register_tensor=a.asm.l).apply(null,arguments)},z0=a._dispose_data=function(){return(z0=a._dispose_data=a.asm.m).apply(null,arguments)},L0=a._dispose=function(){return(L0=a._dispose=a.asm.n).apply(null,arguments)},B0=a._Abs=function(){return(B0=a._Abs=a.asm.p).apply(null,arguments)},Ce=a._Add=function(){return(Ce=a._Add=a.asm.q).apply(null,arguments)},W0=a._AddN=function(){return(W0=a._AddN=a.asm.r).apply(null,arguments)},V0=a._All=function(){return(V0=a._All=a.asm.s).apply(null,arguments)},U0=a._Any=function(){return(U0=a._Any=a.asm.t).apply(null,arguments)},H0=a._ArgMax=function(){return(H0=a._ArgMax=a.asm.u).apply(null,arguments)},G0=a._AvgPool=function(){return(G0=a._AvgPool=a.asm.v).apply(null,arguments)},lo=a._BatchMatMul=function(){return(lo=a._BatchMatMul=a.asm.w).apply(null,arguments)},j0=a._Ceil=function(){return(j0=a._Ceil=a.asm.x).apply(null,arguments)},q0=a._ClipByValue=function(){return(q0=a._ClipByValue=a.asm.y).apply(null,arguments)},K0=a._Conv2D=function(){return(K0=a._Conv2D=a.asm.z).apply(null,arguments)},X0=a._Conv2DBackpropInput=function(){return(X0=a._Conv2DBackpropInput=a.asm.A).apply(null,arguments)},Z0=a._Cos=function(){return(Z0=a._Cos=a.asm.B).apply(null,arguments)},Y0=a._CropAndResize=function(){return(Y0=a._CropAndResize=a.asm.C).apply(null,arguments)},J0=a._Cumsum=function(){return(J0=a._Cumsum=a.asm.D).apply(null,arguments)},Q0=a._DepthToSpace=function(){return(Q0=a._DepthToSpace=a.asm.E).apply(null,arguments)},eg=a._DepthwiseConv2dNative=function(){return(eg=a._DepthwiseConv2dNative=a.asm.F).apply(null,arguments)},ba=a._Equal=function(){return(ba=a._Equal=a.asm.G).apply(null,arguments)},Pu=a._Exp=function(){return(Pu=a._Exp=a.asm.H).apply(null,arguments)},zu=a._FlipLeftRight=function(){return(zu=a._FlipLeftRight=a.asm.I).apply(null,arguments)},tg=a._Floor=function(){return(tg=a._Floor=a.asm.J).apply(null,arguments)},ng=a._FloorDiv=function(){return(ng=a._FloorDiv=a.asm.K).apply(null,arguments)},rg=a._FusedBatchNorm=function(){return(rg=a._FusedBatchNorm=a.asm.L).apply(null,arguments)},sg=a._FusedConv2D=function(){return(sg=a._FusedConv2D=a.asm.M).apply(null,arguments)},ag=a._FusedDepthwiseConv2D=function(){return(ag=a._FusedDepthwiseConv2D=a.asm.N).apply(null,arguments)},Xe=a._Gather=function(){return(Xe=a._Gather=a.asm.O).apply(null,arguments)},og=a._GatherNd=function(){return(og=a._GatherNd=a.asm.P).apply(null,arguments)},ig=a._Greater=function(){return(ig=a._Greater=a.asm.Q).apply(null,arguments)},lg=a._GreaterEqual=function(){return(lg=a._GreaterEqual=a.asm.R).apply(null,arguments)},ug=a._LeakyRelu=function(){return(ug=a._LeakyRelu=a.asm.S).apply(null,arguments)},cg=a._Less=function(){return(cg=a._Less=a.asm.T).apply(null,arguments)},dg=a._LessEqual=function(){return(dg=a._LessEqual=a.asm.U).apply(null,arguments)},Lu=a._Log=function(){return(Lu=a._Log=a.asm.V).apply(null,arguments)},Lh=a._LogicalAnd=function(){return(Lh=a._LogicalAnd=a.asm.W).apply(null,arguments)},Bh=a._Max=function(){return(Bh=a._Max=a.asm.X).apply(null,arguments)},hg=a._MaxPool=function(){return(hg=a._MaxPool=a.asm.Y).apply(null,arguments)},pg=a._Maximum=function(){return(pg=a._Maximum=a.asm.Z).apply(null,arguments)},fg=a._Mean=function(){return(fg=a._Mean=a.asm._).apply(null,arguments)},mg=a._Min=function(){return(mg=a._Min=a.asm.$).apply(null,arguments)},gg=a._Minimum=function(){return(gg=a._Minimum=a.asm.aa).apply(null,arguments)},yg=a._MirrorPad=function(){return(yg=a._MirrorPad=a.asm.ba).apply(null,arguments)},Ag=a._Multiply=function(){return(Ag=a._Multiply=a.asm.ca).apply(null,arguments)},ht=a._Neg=function(){return(ht=a._Neg=a.asm.da).apply(null,arguments)},xg=a._NonMaxSuppressionV3=function(){return(xg=a._NonMaxSuppressionV3=a.asm.ea).apply(null,arguments)},bg=a._NonMaxSuppressionV4=function(){return(bg=a._NonMaxSuppressionV4=a.asm.fa).apply(null,arguments)},vg=a._NonMaxSuppressionV5=function(){return(vg=a._NonMaxSuppressionV5=a.asm.ga).apply(null,arguments)},Ci=a._NotEqual=function(){return(Ci=a._NotEqual=a.asm.ha).apply(null,arguments)},Wh=a._OneHot=function(){return(Wh=a._OneHot=a.asm.ia).apply(null,arguments)},Vh=a._PadV2=function(){return(Vh=a._PadV2=a.asm.ja).apply(null,arguments)},Uh=a._Pow=function(){return(Uh=a._Pow=a.asm.ka).apply(null,arguments)},wg=a._Prelu=function(){return(wg=a._Prelu=a.asm.la).apply(null,arguments)},kg=a._Prod=function(){return(kg=a._Prod=a.asm.ma).apply(null,arguments)},Hh=a._RealDiv=function(){return(Hh=a._RealDiv=a.asm.na).apply(null,arguments)},Ig=a._Relu=function(){return(Ig=a._Relu=a.asm.oa).apply(null,arguments)},Gh=a._Relu6=function(){return(Gh=a._Relu6=a.asm.pa).apply(null,arguments)},va=a._ResizeBilinear=function(){return(va=a._ResizeBilinear=a.asm.qa).apply(null,arguments)},Sg=a._Reverse=function(){return(Sg=a._Reverse=a.asm.ra).apply(null,arguments)},Tg=a._RotateWithOffset=function(){return(Tg=a._RotateWithOffset=a.asm.sa).apply(null,arguments)},x3=a._Round=function(){return(x3=a._Round=a.asm.ta).apply(null,arguments)},jh=a._Rsqrt=function(){return(jh=a._Rsqrt=a.asm.ua).apply(null,arguments)},Ng=a._ScatterNd=function(){return(Ng=a._ScatterNd=a.asm.va).apply(null,arguments)},Cg=a._SelectV2=function(){return(Cg=a._SelectV2=a.asm.wa).apply(null,arguments)},Eg=a._Sigmoid=function(){return(Eg=a._Sigmoid=a.asm.xa).apply(null,arguments)},$g=a._Sin=function(){return($g=a._Sin=a.asm.ya).apply(null,arguments)},_g=a._Softmax=function(){return(_g=a._Softmax=a.asm.za).apply(null,arguments)},Rg=a._Sqrt=function(){return(Rg=a._Sqrt=a.asm.Aa).apply(null,arguments)},Dg=a._Square=function(){return(Dg=a._Square=a.asm.Ba).apply(null,arguments)},Fg=a._SquaredDifference=function(){return(Fg=a._SquaredDifference=a.asm.Ca).apply(null,arguments)},Mg=a._Step=function(){return(Mg=a._Step=a.asm.Da).apply(null,arguments)},Og=a._StridedSlice=function(){return(Og=a._StridedSlice=a.asm.Ea).apply(null,arguments)},Pg=a._Sub=function(){return(Pg=a._Sub=a.asm.Fa).apply(null,arguments)},zg=a._Sum=function(){return(zg=a._Sum=a.asm.Ga).apply(null,arguments)},Lg=a._Tan=function(){return(Lg=a._Tan=a.asm.Ha).apply(null,arguments)},Bg=a._Tanh=function(){return(Bg=a._Tanh=a.asm.Ia).apply(null,arguments)},Wg=a._Tile=function(){return(Wg=a._Tile=a.asm.Ja).apply(null,arguments)},Vg=a._TopK=function(){return(Vg=a._TopK=a.asm.Ka).apply(null,arguments)},Ug=a._Transform=function(){return(Ug=a._Transform=a.asm.La).apply(null,arguments)},Hg=a._Transpose=function(){return(Hg=a._Transpose=a.asm.Ma).apply(null,arguments)},Gg=a.__FusedMatMul=function(){return(Gg=a.__FusedMatMul=a.asm.Na).apply(null,arguments)},jg=a._malloc=function(){return(jg=a._malloc=a.asm.Oa).apply(null,arguments)},qg=a._free=function(){return(qg=a._free=a.asm.Pa).apply(null,arguments)},qh=a.___errno_location=function(){return(qh=a.___errno_location=a.asm.Qa).apply(null,arguments)},Kh=a.stackSave=function(){return(Kh=a.stackSave=a.asm.Ra).apply(null,arguments)},Xh=a.stackRestore=function(){return(Xh=a.stackRestore=a.asm.Sa).apply(null,arguments)},Bu=a.stackAlloc=function(){return(Bu=a.stackAlloc=a.asm.Ta).apply(null,arguments)};a.cwrap=ee;var Ei;function Kg(te){this.name="ExitStatus",this.message="Program terminated with exit("+te+")",this.status=te}Us=function te(){Ei||Wu(),Ei||(Us=te)};function Wu(te){if(te=te||c,ar>0||(Rn(),ar>0))return;function le(){Ei||(Ei=!0,a.calledRun=!0,!F&&(br(),vr(),o(a),a.onRuntimeInitialized&&a.onRuntimeInitialized(),wn()))}a.setStatus?(a.setStatus("Running..."),setTimeout(function(){setTimeout(function(){a.setStatus("")},1),le()},1)):le()}if(a.run=Wu,a.preInit)for(typeof a.preInit=="function"&&(a.preInit=[a.preInit]);a.preInit.length>0;)a.preInit.pop()();return Wu(),s.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)}}),TR="3.7.0",NR="3.7.0",CR="3.7.0",ER="3.7.0",$R="3.7.0",_R="3.7.0",RR="3.7.0",DR="3.7.0",FR=1e-7,MR=1e-4,OR=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}},L3=class{refCount(e){return Ur("refCount")}incRef(e){return Ur("incRef")}timerAvailable(){return!0}time(e){return Ur("time")}read(e){return Ur("read")}readSync(e){return Ur("readSync")}numDataIds(){return Ur("numDataIds")}disposeData(e,t){return Ur("disposeData")}write(e,t,n){return Ur("write")}move(e,t,n,r,s){return Ur("move")}memory(){return Ur("memory")}floatPrecision(){return Ur("floatPrecision")}epsilon(){return this.floatPrecision()===32?FR:MR}dispose(){return Ur("dispose")}};function Ur(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 B3(e){let t=e.length,n=0,r=0;for(;t>0;)r=Math.random()*t|0,t--,n=e[t],e[t]=e[r],e[r]=n}function PR(e,t){if(e.length!==t.length)throw new Error(`Array sizes must match to be shuffled together First array length was ${e.length}Second array length was ${t.length}`);let n=e.length,r,s,a=0;for(;n>0;)a=Math.random()*n|0,n--,r=e[n],s=t[n],e[n]=e[a],t[n]=t[a],e[a]=r,t[a]=s}function qu(e,t,n){return Math.max(e,Math.min(t,n))}function zR(e){return e%2==0?e:e+1}function LR(e){let t=0;for(let n=0;n<e.length;n++)t+=e[n];return t}function BR(e,t){let n=Math.random();return t*n+(1-n)*e}function WR(e,t){let n=0;for(let r=0;r<e.length;r++){let s=Number(e[r])-Number(t[r]);n+=s*s}return n}function L(e,t){if(!e)throw new Error(typeof t=="string"?t:t())}function Mn(e,t,n=""){L(Xs(e,t),()=>n+` Shapes ${e} and ${t} must match`)}function ho(e){L(e!=null,()=>"The input to the tensor constructor must be a non-null value.")}function po(e,t=[],n=!1){if(t==null&&(t=[]),Array.isArray(e)||Cn(e)&&!n)for(let r=0;r<e.length;++r)po(e[r],t,n);else t.push(e);return t}function Jt(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 VR(e){return e.length===0}function Xs(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 Xn(e){return e%1==0}function UR(e){if(Math.tanh!=null)return Math.tanh(e);if(e===Infinity)return 1;if(e===-Infinity)return-1;{let t=Math.exp(2*e);return(t-1)/(t+1)}}function HR(e){let t=Math.ceil(Math.sqrt(e));return[t,Math.ceil(e/t)]}function GR(e){let t=new Uint32Array(e);for(let n=0;n<e;++n)t[n]=n;return B3(t),t}function Ku(e,t){return t<=e.length?e:e+" ".repeat(t-e.length)}function jR(e,t=r=>0,n){return new Promise((r,s)=>{let a=0,o=()=>{if(e()){r();return}a++;let i=t(a);if(n!=null&&a>=n){s();return}setTimeout(o,i)};o()})}function qR(e,t){let n=1,r=-1;for(let a=0;a<e.length;++a)if(e[a]>=0)n*=e[a];else if(e[a]===-1){if(r!==-1)throw Error(`Shapes can only have 1 implicit size. Found -1 at dim ${r} and dim ${a}`);r=a}else if(e[a]<0)throw Error(`Shapes can not be < 0. Found ${e[a]} at dim ${a}`);if(r===-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 s=e.slice();return s[r]=t/n,s}function Xu(e,t){let n=t.length;return e=e==null?t.map((r,s)=>s):[].concat(e),L(e.every(r=>r>=-n&&r<n),()=>`All values in axis param must be in range [-${n}, ${n}) but got axis ${e}`),L(e.every(r=>Xn(r)),()=>`All values in axis param must be integers but got axis ${e}`),e.map(r=>r<0?n+r:r)}function W3(e,t){let n=[],r=[],s=t!=null&&Array.isArray(t)&&t.length===0,a=t==null||s?null:Xu(t,e).sort(),o=0;for(let i=0;i<e.length;++i){if(a!=null){if(a[o]===i&&e[i]!==1)throw new Error(`Can't squeeze axis ${i} since its dim '${e[i]}' is not 1`);(a[o]==null||a[o]>i)&&e[i]===1&&(n.push(e[i]),r.push(i)),a[o]<=i&&o++}e[i]!==1&&(n.push(e[i]),r.push(i))}return{newShape:n,keptDims:r}}function V3(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 U3(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 H3(e,t){for(let n=0;n<e.length;n++){let r=e[n];if(isNaN(r)||!isFinite(r))throw Error(`A tensor of type ${t} being uploaded contains ${r}.`)}}function G3(e){return e==="bool"||e==="complex64"||e==="float32"||e==="int32"||e==="string"}function KR(e,t){return!(t==="complex64"||t==="float32"&&e!=="complex64"||t==="int32"&&e!=="float32"&&e!=="complex64"||t==="bool"&&e==="bool")}function Cn(e){return e instanceof Float32Array||e instanceof Int32Array||e instanceof Uint8Array}function t2(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 j3(e){if(e==null)return 0;let t=0;return e.forEach(n=>t+=n.length),t}function Ia(e){return typeof e=="string"||e instanceof String}function q3(e){return typeof e=="boolean"}function K3(e){return typeof e=="number"}function ep(e){return Array.isArray(e)?ep(e[0]):e instanceof Float32Array?"float32":e instanceof Int32Array||e instanceof Uint8Array?"int32":K3(e)?"float32":Ia(e)?"string":q3(e)?"bool":"float32"}function Sa(e){return!!(e&&e.constructor&&e.call&&e.apply)}function tp(e,t){for(let n=t;n<e;++n)if(e%n==0)return n;return e}function Oi(e){let t=e.length;if(t<2)return[];let n=new Array(t-1);n[t-2]=e[t-1];for(let r=t-3;r>=0;--r)n[r]=n[r+1]*e[r+1];return n}function X3(e,t,n,r=!1){let s=new Array;if(t.length===1){let a=t[0]*(r?2:1);for(let o=0;o<a;o++)s[o]=n[e+o]}else{let a=t[0],o=t.slice(1),i=o.reduce((l,u)=>l*u)*(r?2:1);for(let l=0;l<a;l++)s[l]=X3(e+l*i,o,n,r)}return s}function Pi(e,t,n=!1){if(e.length===0)return t[0];let r=e.reduce((s,a)=>s*a)*(n?2:1);if(r===0)return[];if(r!==t.length)throw new Error(`[${e}] does not match the input size ${t.length}${n?" for a complex tensor":""}.`);return X3(0,e,t,n)}function n2(e,t){let n=np(e,t);for(let r=0;r<n.length;r++)n[r]=1;return n}function np(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 XR(e,t){let n=e.reduce((r,s)=>r*s,1);if(t==null||t==="float32")return Pi(e,new Float32Array(n));if(t==="int32")return Pi(e,new Int32Array(n));if(t==="bool")return Pi(e,new Uint8Array(n));throw new Error(`Unknown data type ${t}`)}function r2(e){e.forEach(t=>{L(Number.isInteger(t)&&t>=0,()=>`Tensor must have a shape comprised of positive integers but got shape [${e}].`)})}function ZR(e,t,n){if(t===0)return 0;if(t===1)return e[0];let r=e[e.length-1];for(let s=0;s<e.length-1;++s)r+=n[s]*e[s];return r}function YR(e,t,n){if(t===0)return[];if(t===1)return[e];let r=new Array(t);for(let s=0;s<r.length-1;++s)r[s]=Math.floor(e/n[s]),e-=r[s]*n[s];return r[r.length-1]=e,r}function s2(e){return e&&e.then&&typeof e.then=="function"}var Z3="tfjsflags",Y3=class{constructor(e){this.global=e,this.flags={},this.flagRegistry={},this.urlFlags={},this.getQueryParams=JR,this.populateURLFlags()}setPlatform(e,t){this.platform!=null&&console.warn(`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 r=this.urlFlags[e];console.warn(`Setting feature override from URL ${e}: ${r}.`),this.set(e,r)}}async getAsync(e){return e in this.flags?this.flags[e]:(this.flags[e]=await this.evaluateFlag(e),this.flags[e])}get(e){if(e in this.flags)return this.flags[e];let t=this.evaluateFlag(e);if(s2(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);Z3 in e&&e[Z3].split(",").forEach(n=>{let[r,s]=n.split(":");this.urlFlags[r]=eD(r,s)})}};function JR(e){let t={};return e.replace(/[?&]([^=?&]+)(?:=([^&]*))?/g,(n,...r)=>(QR(t,r[0],r[1]),r.join("="))),t}function QR(e,t,n){e[decodeURIComponent(t)]=decodeURIComponent(n||"")}function eD(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 ct(){return Sr}var Sr=null;function tD(e){Sr=e}var a2;function J3(){if(a2==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");a2=e}return a2}function nD(){let e=J3();return e._tfGlobals==null&&(e._tfGlobals=new Map),e._tfGlobals}function o2(e,t){let n=nD();if(n.has(e))return n.get(e);{let r=t();return n.set(e,r),n.get(e)}}var Q3="Abs",ev="Acos",tv="Acosh",i2="Add",nv="AddN",rv="All",sv="Any",av="ArgMax",ov="ArgMin",iv="Asin",lv="Asinh",uv="Atan",cv="Atanh",dv="Atan2",hv="AvgPool",rD="AvgPoolGrad",pv="AvgPool3D",sD="AvgPool3DGrad",fv="BatchMatMul",mv="BatchToSpaceND",gv="Bincount",aD="BroadcastTo",l2="Cast",yv="Ceil",Av="ClipByValue",xv="Complex",bv="ComplexAbs",vv="Concat",wv="Conv2D",kv="Conv2DBackpropFilter",Iv="Conv2DBackpropInput",Sv="Conv3D",oD="Conv3DBackpropFilterV2",Tv="Conv3DBackpropInputV2",Nv="Cos",Cv="Cosh",Ev="Cumsum",$v="CropAndResize",_v="DenseBincount",Rv="DepthToSpace",Dv="DepthwiseConv2dNative",Fv="DepthwiseConv2dNativeBackpropFilter",Mv="DepthwiseConv2dNativeBackpropInput",Ov="Diag",Pv="Dilation2D",iD="Dilation2DBackpropInput",lD="Dilation2DBackpropFilter",zv="RealDiv",Lv="Einsum",Bv="Elu",uD="EluGrad",Wv="Erf",Vv="Equal",Uv="Exp",Hv="ExpandDims",Gv="Expm1",jv="FFT",qv="Fill",Kv="FlipLeftRight",Xv="Floor",Zv="FloorDiv",Yv="FusedBatchNorm",Jv="GatherV2",Qv="GatherNd",ew="Greater",tw="GreaterEqual",u2="Identity",nw="IFFT",rw="Imag",sw="IsFinite",aw="IsInf",ow="IsNan",iw="LeakyRelu",lw="Less",uw="LessEqual",cw="LinSpace",dw="Log",hw="Log1p",pw="LogicalAnd",fw="LogicalNot",mw="LogicalOr",cD="LogSoftmax",gw="LRN",dD="LRNGrad",yw="Max",Aw="Maximum",xw="MaxPool",hD="MaxPoolGrad",bw="MaxPool3D",pD="MaxPool3DGrad",vw="MaxPoolWithArgmax",ww="Mean",kw="Min",Iw="Minimum",Sw="MirrorPad",Tw="Mod",Nw="Multinomial",Cw="Multiply",Ew="Neg",$w="NotEqual",_w="NonMaxSuppressionV3",Rw="NonMaxSuppressionV4",Dw="NonMaxSuppressionV5",Fw="OnesLike",Mw="OneHot",Ow="Pack",Pw="PadV2",fD="Pool",zw="Pow",Lw="Prelu",Bw="Prod",Ww="Range",Vw="Real",Uw="Reciprocal",Hw="Relu",Gw="Reshape",jw="ResizeNearestNeighbor",mD="ResizeNearestNeighborGrad",qw="ResizeBilinear",gD="ResizeBilinearGrad",Kw="Relu6",Xw="Reverse",Zw="Round",Yw="Rsqrt",Jw="ScatterNd",Qw="Select",e7="Selu",t7="Slice",n7="Sin",r7="Sinh",s7="Sign",a7="Sigmoid",o7="Softplus",i7="Sqrt",l7="Sum",u7="SpaceToBatchND",c7="SplitV",d7="Softmax",h7="SparseFillEmptyRows",p7="SparseReshape",f7="SparseSegmentMean",m7="SparseSegmentSum",g7="SparseToDense",y7="SquaredDifference",yD="Square",A7="StridedSlice",x7="StringNGrams",b7="StringSplit",v7="StringToHashBucketFast",w7="Sub",k7="Tan",I7="Tanh",c2="Tile",S7="TopK",T7="Transform",N7="Transpose",C7="Unique",E7="Unpack",$7="UnsortedSegmentSum",_7="ZerosLike",R7="Step",d2="FromPixels",D7="RotateWithOffset",h2="_FusedMatMul",p2="FusedConv2D",f2="FusedDepthwiseConv2D",zi=o2("kernelRegistry",()=>new Map),Zu=o2("gradRegistry",()=>new Map);function rp(e,t){let n=g2(e,t);return zi.get(n)}function m2(e){return Zu.get(e)}function Li(e){let t=zi.entries(),n=[];for(;;){let{done:r,value:s}=t.next();if(r)break;let[a,o]=s,[i]=a.split("_");i===e&&n.push(o)}return n}function sp(e){let{kernelName:t,backendName:n}=e,r=g2(t,n);zi.has(r)&&console.warn(`The kernel '${t}' for backend '${n}' is already registered`),zi.set(r,e)}function AD(e){let{kernelName:t}=e;Zu.has(t)&&ct().getBool("DEBUG")&&console.warn(`Overriding the gradient for '${t}'`),Zu.set(t,e)}function xD(e,t){let n=g2(e,t);if(!zi.has(n))throw new Error(`The kernel '${e}' for backend '${t}' is not registered`);zi.delete(n)}function bD(e){if(!Zu.has(e))throw new Error(`The gradient '${e}' for backend is not registered`);Zu.delete(e)}function vD(e,t){Li(e).forEach(r=>{let s=Object.assign({},r,{backendName:t});sp(s)})}function g2(e,t){return`${t}_${e}`}var F7={};De(F7,{arraysEqual:()=>Xs,assert:()=>L,assertNonNegativeIntegerDimensions:()=>r2,assertNonNull:()=>ho,assertShapesMatch:()=>Mn,bytesFromStringArray:()=>j3,bytesPerElement:()=>t2,checkConversionForErrors:()=>H3,clamp:()=>qu,computeStrides:()=>Oi,createScalarValue:()=>ND,createShuffledIndices:()=>GR,decodeString:()=>ip,distSquared:()=>WR,encodeString:()=>Qu,fetch:()=>ED,fingerPrint64:()=>TD,flatten:()=>po,getArrayFromDType:()=>U3,getTypedArrayFromDType:()=>V3,hasEncodingLoss:()=>KR,hexToLong:()=>Yu,indexToLoc:()=>YR,inferDtype:()=>ep,inferFromImplicitShape:()=>qR,isBoolean:()=>q3,isFunction:()=>Sa,isInt:()=>Xn,isNumber:()=>K3,isPromise:()=>s2,isScalarShape:()=>VR,isString:()=>Ia,isTypedArray:()=>Cn,isValidDtype:()=>G3,locToIndex:()=>ZR,makeOnesTypedArray:()=>n2,makeZerosNestedTypedArray:()=>XR,makeZerosTypedArray:()=>np,nearestDivisor:()=>tp,nearestLargerEven:()=>zR,now:()=>Ju,parseAxisParam:()=>Xu,randUniform:()=>BR,repeatedTry:()=>jR,rightPad:()=>Ku,shuffle:()=>B3,shuffleCombo:()=>PR,sizeFromShape:()=>Jt,sizeToSquarishShape:()=>HR,squeezeShape:()=>W3,sum:()=>LR,tanh:()=>UR,toNestedArray:()=>Pi,toTypedArray:()=>op});var M7=Ks(M3()),fo=M7.default||M7;function Yu(e){return fo.fromString(e,!0,16)}var O7=Yu("c3a5c85c97cb3127"),mo=Yu("b492b66fbe98f273"),On=Yu("9ae16a3b2f90404f");function y2(e){return e.xor(e.shru(47))}function P7(e,t,n){let r=e.slice(t,t+n);return fo.fromBytes(Array.from(r),!0,!0)}function St(e,t){return P7(e,t,8)}function z7(e,t){return P7(e,t,4)}function fn(e,t){return t===0?e:e.shru(t).or(e.shl(64-t))}function Ta(e,t,n=Yu("9ddfea08eb382d69")){let r=e.xor(t).mul(n);r=r.xor(r.shru(47));let s=t.xor(r).mul(n);return s=s.xor(s.shru(47)),s=s.mul(n),s}function wD(e,t,n,r,s,a){s=s.add(e),a=fn(a.add(s).add(r),21);let o=s;return s=s.add(t),s=s.add(n),a=a.add(fn(s,44)),[s.add(r),a.add(o)]}function ap(e,t,n,r){return wD(St(e,t),St(e,t+8),St(e,t+16),St(e,t+24),n,r)}function kD(e,t=e.length){if(t>=8){let n=On.add(t*2),r=St(e,0).add(On),s=St(e,t-8),a=fn(s,37).mul(n).add(r),o=fn(r,25).add(s).mul(n);return Ta(a,o,n)}if(t>=4){let n=On.add(t*2),r=z7(e,0);return Ta(r.shl(3).add(t),z7(e,t-4),n)}if(t>0){let n=e[0],r=e[t>>1],s=e[t-1],a=n+(r<<8),o=t+(s<<2);return y2(On.mul(a).xor(O7.mul(o))).mul(On)}return On}function ID(e,t=e.length){let n=On.add(t*2),r=St(e,0).mul(mo),s=St(e,8),a=St(e,t-8).mul(n),o=St(e,t-16).mul(On);return Ta(fn(r.add(s),43).add(fn(a,30)).add(o),r.add(fn(s.add(On),18)).add(a),n)}function SD(e,t=e.length){let n=On.add(t*2),r=St(e,0).mul(On),s=St(e,8),a=St(e,t-8).mul(n),o=St(e,t-16).mul(On),i=fn(r.add(s),43).add(fn(a,30)).add(o),l=Ta(i,r.add(fn(s.add(On),18)).add(a),n),u=St(e,16).mul(n),c=St(e,24),d=i.add(St(e,t-32)).mul(n),h=l.add(St(e,t-24)).mul(n);return Ta(fn(u.add(c),43).add(fn(d,30)).add(h),u.add(fn(c.add(r),18)).add(d),n)}function TD(e,t=e.length){let n=fo.fromNumber(81,!0);if(t<=32)return t<=16?kD(e,t):ID(e,t);if(t<=64)return SD(e,t);let r=n,s=n.mul(mo).add(113),a=y2(s.mul(On).add(113)).mul(On),o=[fo.UZERO,fo.UZERO],i=[fo.UZERO,fo.UZERO];r=r.mul(On).add(St(e,0));let l=0,u=(t-1>>6)*64,c=u+(t-1&63)-63;do r=fn(r.add(s).add(o[0]).add(St(e,l+8)),37).mul(mo),s=fn(s.add(o[1]).add(St(e,l+48)),42).mul(mo),r=r.xor(i[1]),s=s.add(o[0]).add(St(e,l+40)),a=fn(a.add(i[0]),33).mul(mo),o=ap(e,l,o[1].mul(mo),r.add(i[0])),i=ap(e,l+32,a.add(i[1]),s.add(St(e,l+16))),[a,r]=[r,a],l+=64;while(l!==u);let d=mo.add(a.and(255).shl(1));return l=c,i[0]=i[0].add(t-1&63),o[0]=o[0].add(i[0]),i[0]=i[0].add(o[0]),r=fn(r.add(s).add(o[0]).add(St(e,l+8)),37).mul(d),s=fn(s.add(o[1]).add(St(e,l+48)),42).mul(d),r=r.xor(i[1].mul(9)),s=s.add(o[0].mul(9).add(St(e,l+40))),a=fn(a.add(i[0]),33).mul(d),o=ap(e,l,o[1].mul(d),r.add(i[0])),i=ap(e,l+32,a.add(i[1]),s.add(St(e,l+16))),[a,r]=[r,a],Ta(Ta(o[0],i[0],d).add(y2(s).mul(O7)).add(a),Ta(o[1],i[1],d).add(r),d)}function ND(e,t){return t==="string"?Qu(e):op([e],t)}function CD(e,t){return e instanceof Float32Array&&t==="float32"||e instanceof Int32Array&&t==="int32"||e instanceof Uint8Array&&t==="bool"}function op(e,t){if(t==="string")throw new Error("Cannot convert a string[] to a TypedArray");if(Array.isArray(e)&&(e=po(e)),ct().getBool("DEBUG")&&H3(e,t),CD(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 r=0;r<n.length;++r)Math.round(e[r])!==0&&(n[r]=1);return n}else throw new Error(`Unknown data type ${t}`)}function Ju(){return ct().platform.now()}function ED(e,t){return ct().platform.fetch(e,t)}function Qu(e,t="utf-8"){return t=t||"utf-8",ct().platform.encode(e,t)}function ip(e,t="utf-8"){return t=t||"utf-8",ct().platform.decode(e,t)}var $D=class{constructor(e,t){this.backendTimer=e,this.logger=t,t==null&&(this.logger=new RD)}profileKernel(e,t,n){let r,s=()=>{r=n()},a,o=Ju();if(this.backendTimer.timerAvailable())a=this.backendTimer.time(s);else{s();for(let l of r)l.dataSync();a=Promise.resolve({kernelMs:Ju()-o})}if(ct().getBool("CHECK_COMPUTATION_FOR_ERRORS"))for(let l=0;l<r.length;l++){let u=r[l];u.data().then(c=>{_D(c,u.dtype,e)})}return{kernelName:e,outputs:r,inputs:t,timeMs:a.then(l=>l.kernelMs),extraInfo:a.then(l=>l.getExtraProfileInfo!=null?l.getExtraProfileInfo():"")}}logKernelProfile(e){let{kernelName:t,outputs:n,timeMs:r,inputs:s,extraInfo:a}=e;n.forEach(o=>{Promise.all([o.data(),r,a]).then(i=>{this.logger.logKernelProfile(t,o,i[0],i[1],s,i[2])})})}};function _D(e,t,n){if(t!=="float32")return!1;for(let r=0;r<e.length;r++){let s=e[r];if(isNaN(s)||!isFinite(s))return console.warn(`Found ${s} in the result of '${n}'`),!0}return!1}var RD=class{logKernelProfile(e,t,n,r,s,a){let o=typeof r=="number"?Ku(`${r}ms`,9):r.error,i=Ku(e,25),l=t.rank,u=t.size,c=Ku(t.shape.toString(),14),d="";for(let h in s){let p=s[h];if(p!=null){let f=p.shape||t.shape,m=f.length;d+=`${h}: ${m}D ${m>0?f:""} `}}console.log(`%c${i} %c${o} %c${l}D ${c} %c${u} %c${d} %c${a}`,"font-weight:bold","color:red","color:blue","color: orange","color: green","color: steelblue")}};function DD(e,t,n){let r={},s={};for(let l=0;l<t.length;l++)r[t[l].id]=!0;for(let l=0;l<e.length;l++){let u=e[l],c=u.inputs;for(let d in c){let h=c[d],p=!1;for(let f=0;f<t.length;f++)if(r[h.id]){u.outputs.forEach(m=>r[m.id]=!0),p=!0,s[u.id]=!0;break}if(p)break}}let a={};a[n.id]=!0;let o={};for(let l=e.length-1;l>=0;l--){let u=e[l],c=u.inputs;for(let d=0;d<u.outputs.length;d++)if(a[u.outputs[d].id]){for(let h in c)a[c[h].id]=!0,o[u.id]=!0;break}}let i=[];for(let l=0;l<e.length;l++){let u=e[l];if(s[u.id]&&o[u.id]){let c={};for(let h in u.inputs){let p=u.inputs[h];r[p.id]&&(c[h]=p)}let d=Object.assign({},u);d.inputs=c,d.outputs=u.outputs,i.push(d)}}return i}function FD(e,t,n,r){for(let s=t.length-1;s>=0;s--){let a=t[s],o=[];if(a.outputs.forEach(l=>{let u=e[l.id];u!=null?o.push(u):o.push(null)}),a.gradient==null)throw new Error(`Cannot compute gradient: gradient function not found for ${a.kernelName}.`);let i=a.gradient(o);for(let l in a.inputs){if(!(l in i))throw new Error(`Cannot backprop through input ${l}. Available gradients found: ${Object.keys(i)}.`);let u=n(()=>i[l]());if(u.dtype!=="float32")throw new Error(`Error in gradient for op ${a.kernelName}. The gradient of input ${l} must have 'float32' dtype, but has '${u.dtype}'`);let c=a.inputs[l];if(!Xs(u.shape,c.shape))throw new Error(`Error in gradient for op ${a.kernelName}. The gradient of input '${l}' has shape '${u.shape}', which does not match the shape of the input '${c.shape}'`);if(e[c.id]==null)e[c.id]=u;else{let d=e[c.id];e[c.id]=r(d,u),d.dispose()}}}}var L7=20,ec=3,A2=7;function MD(e,t,n,r){let s=Oi(t),a=OD(e,t,n,s),o=t.length,i=lp(e,t,n,s,a),l=["Tensor"];return r&&(l.push(` dtype: ${n}`),l.push(` rank: ${o}`),l.push(` shape: [${t}]`),l.push(" values:")),l.push(i.map(u=>" "+u).join(`
|
|
`)),l.join(`
|
|
`)}function OD(e,t,n,r){let s=Jt(t),a=r[r.length-1],o=new Array(a).fill(0),i=t.length,l=n==="complex64"?nc(e):e;if(i>1)for(let u=0;u<s/a;u++){let c=u*a;for(let d=0;d<a;d++)o[d]=Math.max(o[d],tc(l[c+d],0,n).length)}return o}function tc(e,t,n){let r;return Array.isArray(e)?r=`${parseFloat(e[0].toFixed(A2))} + ${parseFloat(e[1].toFixed(A2))}j`:Ia(e)?r=`'${e}'`:n==="bool"?r=B7(e):r=parseFloat(e.toFixed(A2)).toString(),Ku(r,t)}function B7(e){return e===0?"false":"true"}function lp(e,t,n,r,s,a=!0){let o=n==="complex64"?2:1,i=t[0],l=t.length;if(l===0){if(n==="complex64"){let m=nc(e);return[tc(m[0],0,n)]}return n==="bool"?[B7(e[0])]:[e[0].toString()]}if(l===1){if(i>L7){let g=ec*o,y=Array.from(e.slice(0,g)),A=Array.from(e.slice((i-ec)*o,i*o));return n==="complex64"&&(y=nc(y),A=nc(A)),["["+y.map((x,b)=>tc(x,s[b],n)).join(", ")+", ..., "+A.map((x,b)=>tc(x,s[i-ec+b],n)).join(", ")+"]"]}let m=n==="complex64"?nc(e):Array.from(e);return["["+m.map((g,y)=>tc(g,s[y],n)).join(", ")+"]"]}let u=t.slice(1),c=r.slice(1),d=r[0]*o,h=[];if(i>L7){for(let m=0;m<ec;m++){let g=m*d,y=g+d;h.push(...lp(e.slice(g,y),u,n,c,s,!1))}h.push("...");for(let m=i-ec;m<i;m++){let g=m*d,y=g+d;h.push(...lp(e.slice(g,y),u,n,c,s,m===i-1))}}else for(let m=0;m<i;m++){let g=m*d,y=g+d;h.push(...lp(e.slice(g,y),u,n,c,s,m===i-1))}let p=l===2?",":"";h[0]="["+h[0]+p;for(let m=1;m<h.length-1;m++)h[m]=" "+h[m]+p;let f=`,
|
|
`;for(let m=2;m<l;m++)f+=`
|
|
`;return h[h.length-1]=" "+h[h.length-1]+"]"+(a?"":f),h}function nc(e){let t=[];for(let n=0;n<e.length;n+=2)t.push([e[n],e[n+1]]);return t}var up=class{constructor(e,t,n){if(this.dtype=t,this.shape=e.slice(),this.size=Jt(e),n!=null){let r=n.length;L(r===this.size,()=>`Length of values '${r}' 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||U3(t,this.size),this.strides=Oi(e)}set(e,...t){t.length===0&&(t=[0]),L(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 r of e){if(r<0||r>=this.shape[t]){let s=`Requested out of range element at ${e}. Buffer shape=${this.shape}`;throw new Error(s)}t++}let n=e[e.length-1];for(let r=0;r<e.length-1;++r)n+=this.strides[r]*e[r];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 Is().makeTensor(this.values,this.shape,this.dtype)}},Is=null,Bi=null,PD=null;function zD(e){Is=e}function LD(e){Bi=e}function BD(e){PD=e}var Tt=class{constructor(e,t,n,r){this.kept=!1,this.isDisposedInternal=!1,this.shape=e.slice(),this.dtype=t||"float32",this.size=Jt(e),this.strides=Oi(e),this.dataId=n,this.id=r,this.rankType=this.rank<5?this.rank.toString():"higher"}get rank(){return this.shape.length}async buffer(){let e=await this.data();return Bi.buffer(this.shape,this.dtype,e)}bufferSync(){return Bi.buffer(this.shape,this.dtype,this.dataSync())}async array(){let e=await this.data();return Pi(this.shape,e,this.dtype==="complex64")}arraySync(){return Pi(this.shape,this.dataSync(),this.dtype==="complex64")}async data(){this.throwIfDisposed();let e=Is().read(this.dataId);if(this.dtype==="string"){let t=await e;try{return t.map(n=>ip(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=Is().readSync(this.dataId);if(this.dtype==="string")try{return e.map(t=>ip(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 Is().read(this.dataId);return this.dtype==="string"?e:new Uint8Array(e.buffer)}dispose(){this.isDisposed||(Is().disposeTensor(this),this.isDisposedInternal=!0)}get isDisposed(){return this.isDisposedInternal}throwIfDisposed(){if(this.isDisposed)throw new Error("Tensor is disposed.")}print(e=!1){return Bi.print(this,e)}clone(){return this.throwIfDisposed(),Bi.clone(this)}toString(e=!1){let t=this.dataSync();return MD(t,this.shape,this.dtype,e)}cast(e){return this.throwIfDisposed(),Bi.cast(this,e)}variable(e=!0,t,n){return this.throwIfDisposed(),Is().makeVariable(this,e,t,n)}};Object.defineProperty(Tt,Symbol.hasInstance,{value:e=>!!e&&e.data!=null&&e.dataSync!=null&&e.throwIfDisposed!=null});function WD(){return o2("Tensor",()=>Tt)}WD();var rc=class extends Tt{constructor(e,t,n,r){super(e.shape,e.dtype,e.dataId,r);this.trainable=t,this.name=n}assign(e){if(e.dtype!==this.dtype)throw new Error(`dtype of the new value (${e.dtype}) and previous value (${this.dtype}) must match`);if(!Xs(e.shape,this.shape))throw new Error(`shape of the new value (${e.shape}) and previous value (${this.shape}) must match`);Is().disposeTensor(this),this.dataId=e.dataId,Is().incRef(this,null)}dispose(){Is().disposeVariable(this),this.isDisposedInternal=!0}};Object.defineProperty(rc,Symbol.hasInstance,{value:e=>e instanceof Tt&&e.assign!=null&&e.assign instanceof Function});var W7={};De(W7,{assertTypesMatch:()=>V7,getTensorsInContainer:()=>I2,isTensorInList:()=>HD,makeTypesMatch:()=>Vt});var x2;(function(e){e.R0="R0",e.R1="R1",e.R2="R2",e.R3="R3",e.R4="R4",e.R5="R5",e.R6="R6"})(x2||(x2={}));var b2;(function(e){e.float32="float32",e.int32="int32",e.bool="int32",e.complex64="complex64"})(b2||(b2={}));var v2;(function(e){e.float32="float32",e.int32="int32",e.bool="bool",e.complex64="complex64"})(v2||(v2={}));var w2;(function(e){e.float32="float32",e.int32="float32",e.bool="float32",e.complex64="complex64"})(w2||(w2={}));var k2;(function(e){e.float32="complex64",e.int32="complex64",e.bool="complex64",e.complex64="complex64"})(k2||(k2={}));var VD={float32:w2,int32:b2,bool:v2,complex64:k2};function cp(e,t){if(e==="string"||t==="string"){if(e==="string"&&t==="string")return"string";throw new Error(`Can not upcast ${e} with ${t}`)}return VD[e][t]}function UD(e){return cp(e,"int32")}function Vt(e,t){if(e.dtype===t.dtype)return[e,t];let n=cp(e.dtype,t.dtype);return[e.cast(n),t.cast(n)]}function V7(e,t){L(e.dtype===t.dtype,()=>`The dtypes of the first(${e.dtype}) and second(${t.dtype}) input must match`)}function HD(e,t){return t.some(n=>n.id===e.id)}function I2(e){let t=[],n=new Set;return U7(e,t,n),t}function U7(e,t,n){if(e==null)return;if(e instanceof Tt){t.push(e);return}if(!GD(e))return;let r=e;for(let s in r){let a=r[s];n.has(a)||(n.add(a),U7(a,t,n))}}function GD(e){return Array.isArray(e)||typeof e=="object"}function S2(e){return e.kernelName!=null}var H7=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()}},T2=class{constructor(e){this.ENV=e,this.registry={},this.registryFactory={},this.pendingBackendInitId=0,this.state=new H7}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?(console.warn(`${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 $D(this.backendInstance),!0}setupRegisteredKernels(){Li(this.backendName).forEach(t=>{t.setupFunc!=null&&t.setupFunc(this.backendInstance)})}disposeRegisteredKernels(e){Li(e).forEach(n=>{n.disposeFunc!=null&&n.disposeFunc(this.registry[e])})}initializeBackend(e){let t=this.registryFactory[e];if(t==null)throw new Error(`Cannot initialize backend ${e}, no registration found.`);try{let n=t.factory();if(n&&!(n instanceof L3)&&typeof n.then=="function"){let r=++this.pendingBackendInitId,s=n.then(a=>r<this.pendingBackendInitId?!1:(this.registry[e]=a,this.pendingBackendInit=null,!0)).catch(a=>(r<this.pendingBackendInitId||(this.pendingBackendInit=null,console.warn(`Initialization of backend ${e} failed`),console.warn(a.stack||a.message)),!1));return this.pendingBackendInit=s,{success:s,asyncInit:!0}}else return this.registry[e]=n,{success:!0,asyncInit:!1}}catch(n){return console.warn(`Initialization of backend ${e} failed`),console.warn(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:r,asyncInit:s}=this.initializeBackend(n);if(s||r)return{name:n,asyncInit:s}}throw new Error("Could not initialize any backends, all backend initializations failed.")}moveData(e,t){let n=this.state.tensorInfo.get(t),r=n.backend,s=this.readSync(t),a=r.refCount(t);r.disposeData(t,!0),n.backend=e,e.move(t,s,n.shape,n.dtype,a),this.shouldCheckForMemLeaks()&&this.state.numDataMovesStack[this.state.numDataMovesStack.length-1]++}tidy(e,t){let n=null;if(t==null){if(typeof e!="function")throw new Error("Please provide a function to tidy()");t=e}else{if(typeof e!="string"&&!(e instanceof String))throw new Error("When calling with two arguments, the first argument to tidy() must be a string");if(typeof t!="function")throw new Error("When calling with two arguments, the 2nd argument to tidy() must be a function");n=e}let r;return this.scopedRun(()=>this.startScope(n),()=>this.endScope(r),()=>(r=t(),r instanceof Promise&&console.error("Cannot return a Promise inside of tidy."),r))}scopedRun(e,t,n){e();try{let r=n();return t(),r}catch(r){throw t(),r}}nextTensorId(){return T2.nextTensorId++}nextVariableId(){return T2.nextVariableId++}clone(e){let t=U.runKernel(u2,{x:e}),n={x:e},r=a=>({x:()=>{let o="float32",i={x:a},l={dtype:o};return U.runKernel(l2,i,l)}}),s=[];return this.addTapeNode(this.state.activeScope.name,n,[t],r,s,{}),t}runKernel(e,t,n){if(!(rp(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 r=this.backend.numDataIds(),s=0;n.forEach(i=>{s+=i.dtype==="complex64"?3:1});let a=this.state.numDataMovesStack[this.state.numDataMovesStack.length-1],o=r-t-s-a;if(o>0)throw new Error(`Backend '${this.backendName}' has an internal memory leak (${o} data ids) after running '${e}'`)}runKernelFunc(e){let t,n=[],r=this.isTapeOn(),s=this.state.numBytes,a=this.state.numTensors;this.shouldCheckForMemLeaks()&&this.state.numDataMovesStack.push(0);let o;this.backendName==null&&this.backend;let i,l=S2(e)?e.kernelName:this.state.activeScope!=null?this.state.activeScope.name:"";if(S2(e)){let{kernelName:p,inputs:f,attrs:m}=e;this.backendName==null&&this.backend;let g=rp(p,this.backendName);L(g!=null,()=>`Cannot find registered kernel '${p}' for backend '${this.backendName}'`),o=()=>{let y=this.backend.numDataIds();i=g.kernelFunc({inputs:f,attrs:m,backend:this.backend});let A=Array.isArray(i)?i:[i];this.shouldCheckForMemLeaks()&&this.checkKernelForMemLeak(p,y,A);let x=A.map(b=>{if(b.rank!=null)return b;let{dataId:v,shape:w,dtype:I}=b;return this.makeTensorFromDataId(v,w,I)});if(r){let b=this.getTensorsForGradient(p,f,x);n=this.saveTensorsForBackwardMode(b)}return x}}else{let{forwardFunc:p}=e,f=m=>{!r||(n=m.map(g=>this.keep(this.clone(g))))};o=()=>{let m=this.backend.numDataIds();i=this.tidy(()=>p(this.backend,f));let g=Array.isArray(i)?i:[i];return this.shouldCheckForMemLeaks()&&this.checkKernelForMemLeak(l,m,g),g}}let{inputs:u,attrs:c}=e,d=S2(e)?null:e.backwardsFunc,h;return this.scopedRun(()=>this.state.kernelDepth++,()=>this.state.kernelDepth--,()=>{!this.ENV.getBool("DEBUG")&&!this.state.profiling?t=o():(h=this.profiler.profileKernel(l,u,()=>o()),this.ENV.getBool("DEBUG")&&this.profiler.logKernelProfile(h),t=h.outputs)}),r&&this.addTapeNode(l,u,t,d,n,c),this.state.profiling&&this.state.activeProfile.kernels.push({name:l,bytesAdded:this.state.numBytes-s,totalBytesSnapshot:this.state.numBytes,tensorsAdded:this.state.numTensors-a,totalTensorsSnapshot:this.state.numTensors,inputShapes:Object.keys(u).map(p=>u[p]!=null?u[p].shape:null),outputShapes:t.map(p=>p.shape),kernelTimeMs:h.timeMs,extraInfo:h.extraInfo}),Array.isArray(i)?t:t[0]}saveTensorsForBackwardMode(e){return e.map(n=>this.keep(this.clone(n)))}getTensorsForGradient(e,t,n){let r=m2(e);if(r!=null){let s=r.inputsToSave||[],a=r.outputsToSave||[],o;r.saveAllInputs?(L(Array.isArray(t),()=>"saveAllInputs is true, expected inputs to be an array."),o=Object.keys(t).map(l=>t[l])):o=s.map(l=>t[l]);let i=n.filter((l,u)=>a[u]);return o.concat(i)}return[]}makeTensor(e,t,n,r){if(e==null)throw new Error("Values passed to engine.makeTensor() are null");n=n||"float32",r=r||this.backend;let s=e;n==="string"&&Ia(e[0])&&(s=e.map(i=>Qu(i)));let a=r.write(s,t,n),o=new Tt(t,n,a,this.nextTensorId());if(this.trackTensor(o,r),n==="string"){let i=this.state.tensorInfo.get(a),l=j3(s);this.state.numBytes+=l-i.bytes,i.bytes=l}return o}makeTensorFromDataId(e,t,n,r){n=n||"float32";let s=new Tt(t,n,e,this.nextTensorId());return this.trackTensor(s,r),s}makeVariable(e,t=!0,n,r){n=n||this.nextVariableId().toString(),r!=null&&r!==e.dtype&&(e=e.cast(r));let s=new rc(e,t,n,this.nextTensorId());if(this.state.registeredVariables[s.name]!=null)throw new Error(`Variable with name ${s.name} was already registered`);return this.state.registeredVariables[s.name]=s,this.incRef(s,this.backend),s}trackTensor(e,t){this.state.numTensors++,e.dtype==="string"&&this.state.numStringTensors++;let n=0;e.dtype!=="complex64"&&e.dtype!=="string"&&(n=e.size*t2(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 rc||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*t2(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(r=>r.totalBytesSnapshot)),this.state.activeProfile.newBytes=this.state.numBytes-t,this.state.activeProfile.newTensors=this.state.numTensors-n;for(let r of this.state.activeProfile.kernels)r.kernelTimeMs=await r.kernelTimeMs,r.extraInfo=await r.extraInfo;return this.state.activeProfile}isTapeOn(){return this.state.gradientDepth>0&&this.state.kernelDepth===0}addTapeNode(e,t,n,r,s,a){let o={id:this.state.nextTapeNodeId++,kernelName:e,inputs:t,outputs:n,saved:s},i=m2(e);i!=null&&(r=i.gradFunc),r!=null&&(o.gradient=l=>(l=l.map((u,c)=>{if(u==null){let d=n[c],h=np(d.size,d.dtype);return this.makeTensor(h,d.shape,d.dtype)}return u}),r(l.length>1?l:l[0],s,a))),this.state.activeTape.push(o)}keep(e){return e.kept=!0,e}startTape(){this.state.gradientDepth===0&&(this.state.activeTape=[]),this.state.gradientDepth++}endTape(){this.state.gradientDepth--}startScope(e){let t={track:[],name:"unnamed scope",id:this.state.nextScopeId++};e&&(t.name=e),this.state.scopeStack.push(t),this.state.activeScope=t}endScope(e){let t=I2(e),n=new Set(t.map(s=>s.id));for(let s=0;s<this.state.activeScope.track.length;s++){let a=this.state.activeScope.track[s];!a.kept&&!n.has(a.id)&&a.dispose()}let r=this.state.scopeStack.pop();this.state.activeScope=this.state.scopeStack.length===0?null:this.state.scopeStack[this.state.scopeStack.length-1],t.forEach(s=>{!s.kept&&s.scopeId===r.id&&this.track(s)})}gradients(e,t,n,r=!1){if(L(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 s=this.scopedRun(()=>this.startTape(),()=>this.endTape(),()=>this.tidy("forward",e));L(s instanceof Tt,()=>"The result y returned by f() must be a tensor.");let a=DD(this.state.activeTape,t,s);if(!r&&a.length===0&&t.length>0)throw new Error("Cannot compute gradient of y=f(x) with respect to x. Make sure that the f you passed encloses all operations that lead from x to y.");return this.tidy("backward",()=>{let o={};o[s.id]=n==null?jD(s.shape):n,FD(o,a,l=>this.tidy(l),qD);let i=t.map(l=>o[l.id]);return this.state.gradientDepth===0&&(this.state.activeTape.forEach(l=>{for(let u of l.saved)u.dispose()}),this.state.activeTape=null),{value:s,grads:i}})}customGrad(e){return L(Sa(e),()=>"The f passed in customGrad(f) must be a function."),(...t)=>{L(t.every(o=>o instanceof Tt),()=>"The args passed in customGrad(f)(x1, x2,...) must all be tensors");let n,r={};t.forEach((o,i)=>{r[i]=o});let s=(o,i)=>(n=e(...t,i),L(n.value instanceof Tt,()=>"The function f passed in customGrad(f) must return an object where `obj.value` is a tensor"),L(Sa(n.gradFunc),()=>"The function f passed in customGrad(f) must return an object where `obj.gradFunc` is a function."),n.value),a=(o,i)=>{let l=n.gradFunc(o,i),u=Array.isArray(l)?l:[l];L(u.length===t.length,()=>"The function f passed in customGrad(f) must return an object where `obj.gradFunc` is a function that returns the same number of tensors as inputs passed to f(...)."),L(u.every(d=>d instanceof Tt),()=>"The function f passed in customGrad(f) must return an object where `obj.gradFunc` is a function that returns a list of only tensors.");let c={};return u.forEach((d,h)=>{c[h]=()=>d}),c};return this.runKernelFunc({forwardFunc:s,backwardsFunc:a,inputs:r})}}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=Ju(),n=await this.backend.time(e);return n.wallMs=Ju()-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 H7;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}},N2=T2;N2.nextTensorId=0;N2.nextVariableId=0;function jD(e){let t=n2(Jt(e),"float32");return U.makeTensor(t,e,"float32")}function G7(){let e=J3();if(e._tfengine==null){let t=new Y3(e);e._tfengine=new N2(t)}return tD(e._tfengine.ENV),zD(()=>e._tfengine),e._tfengine}var U=G7();function qD(e,t){let n={a:e,b:t};return U.runKernel(i2,n)}var j7={};De(j7,{isBrowser:()=>q7,isMobile:()=>XD});function KD(){return typeof navigator!="undefined"&&navigator!=null}function XD(e){if(e||KD()){if(e||(e=navigator),e.product==="ReactNative")return!0;let t=e.userAgent||e.vendor||window.opera;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 q7(){return typeof window!="undefined"&&window.document!=null||typeof WorkerGlobalScope!="undefined"}var es=ct();es.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.")});es.registerFlag("IS_BROWSER",()=>q7());es.registerFlag("IS_NODE",()=>typeof process!="undefined"&&typeof process.versions!="undefined"&&typeof process.versions.node!="undefined");es.registerFlag("IS_CHROME",()=>typeof navigator!="undefined"&&navigator!=null&&navigator.userAgent!=null&&/Chrome/.test(navigator.userAgent)&&/Google Inc/.test(navigator.vendor));es.registerFlag("PROD",()=>!1);es.registerFlag("TENSORLIKE_CHECK_SHAPE_CONSISTENCY",()=>es.getBool("DEBUG"));es.registerFlag("DEPRECATION_WARNINGS_ENABLED",()=>!0);es.registerFlag("IS_TEST",()=>!1);es.registerFlag("CHECK_COMPUTATION_FOR_ERRORS",()=>!0);es.registerFlag("WRAP_TO_IMAGEBITMAP",()=>!1);function Ss(e,t){let n=e;if(Cn(e))return t==="string"?[]:[e.length];if(!Array.isArray(e))return[];let r=[];for(;Array.isArray(n)||Cn(n)&&t!=="string";)r.push(n.length),n=n[0];return Array.isArray(e)&&ct().getBool("TENSORLIKE_CHECK_SHAPE_CONSISTENCY")&&K7(e,r,[]),r}function K7(e,t,n){if(n=n||[],!Array.isArray(e)&&!Cn(e)){L(t.length===0,()=>`Element arr[${n.join("][")}] is a primitive, but should be an array/TypedArray of ${t[0]} elements`);return}L(t.length>0,()=>`Element arr[${n.join("][")}] should be a primitive, but is an array of ${e.length} elements`),L(e.length===t[0],()=>`Element arr[${n.join("][")}] should have ${t[0]} elements, but has ${e.length} elements`);let r=t.slice(1);for(let s=0;s<e.length;++s)K7(e[s],r,n.concat(s))}function X7(e,t,n,r){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 '${r}' must be ${e} tensor, but got ${t} tensor`)}}function P(e,t,n,r="numeric"){if(e instanceof Tt)return X7(r,e.dtype,t,n),e;let s=ep(e);if(s!=="string"&&["bool","int32","float32"].indexOf(r)>=0&&(s=r),X7(r,s,t,n),e==null||!Cn(e)&&!Array.isArray(e)&&typeof e!="number"&&typeof e!="boolean"&&typeof e!="string"){let l=e==null?"null":e.constructor.name;throw new Error(`Argument '${t}' passed to '${n}' must be a Tensor or TensorLike, but got '${l}'`)}let a=Ss(e,s);!Cn(e)&&!Array.isArray(e)&&(e=[e]);let i=s!=="string"?op(e,s):po(e,[],!0);return U.makeTensor(i,a,s)}function sc(e,t,n,r="numeric"){if(!Array.isArray(e))throw new Error(`Argument ${t} passed to ${n} must be a \`Tensor[]\` or \`TensorLike[]\``);return e.map((a,o)=>P(a,`${t}[${o}]`,n,r))}var Z7="__op";function H(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],r=e[n];n.endsWith("_")&&(n=n.substring(0,n.length-1)),n=n+Z7;let s=(...a)=>{U.startScope(n);try{let o=r(...a);return s2(o)&&console.error("Cannot return a Promise inside of tidy."),U.endScope(o),o}catch(o){throw U.endScope(null),o}};return Object.defineProperty(s,"name",{value:n,configurable:!0}),s}function ZD(e,t){let n=P(e,"real","complex"),r=P(t,"imag","complex");Mn(n.shape,r.shape,`real and imag shapes, ${n.shape} and ${r.shape}, must match in call to tf.complex().`);let s={real:n,imag:r};return U.runKernel(xv,s)}var go=H({complex_:ZD});function Na(e,t,n,r){if(r==null&&(r=ep(e)),r==="complex64")throw new Error("Cannot construct a complex64 tensor directly. Please use tf.complex(real, imag).");if(!Cn(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){r2(t);let s=Jt(t),a=Jt(n);L(s===a,()=>`Based on the provided shape, [${t}], the tensor should have ${s} values but has ${a}`);for(let o=0;o<n.length;++o){let i=n[o],l=o===n.length-1?i!==Jt(t.slice(o)):!0;L(n[o]===t[o]||!l,()=>`Error creating a new Tensor. Inferred shape (${n}) does not match the provided shape (${t}). `)}}return!Cn(e)&&!Array.isArray(e)&&(e=[e]),t=t||n,e=r!=="string"?op(e,r):po(e,[],!0),U.makeTensor(e,t,r)}function ts(e,t,n){let r=Ss(e,n);return Na(e,t,r,n)}var C2={float32:4,float16:2,int32:4,uint16:2,uint8:1,bool:1,complex64:8},dp=4;async function YD(e,t){let n=[],r=[],s=Array.isArray(e)?e.map(o=>o.name):Object.keys(e);for(let o=0;o<s.length;++o){let i=s[o],l=Array.isArray(e)?e[o].tensor:e[i];if(l.dtype!=="float32"&&l.dtype!=="int32"&&l.dtype!=="bool"&&l.dtype!=="string"&&l.dtype!=="complex64")throw new Error(`Unsupported dtype in weight '${i}': ${l.dtype}`);let u={name:i,shape:l.shape,dtype:l.dtype};if(l.dtype==="string"){let c=new Promise(async d=>{let h=await l.bytes(),p=h.reduce((g,y)=>g+y.length,0)+dp*h.length,f=new Uint8Array(p),m=0;for(let g=0;g<h.length;g++){let y=h[g],A=new Uint8Array(new Uint32Array([y.length]).buffer);f.set(A,m),m+=dp,f.set(y,m),m+=y.length}d(f)});r.push(c)}else r.push(l.data());t!=null&&(u.group=t),n.push(u)}let a=await Promise.all(r);return{data:JD(a),specs:n}}function Y7(e,t){let n={},r,s=0;for(let a of t){let o=a.name,i=a.dtype,l=a.shape,u=Jt(l),c;if("quantization"in a){let d=a.quantization;if(d.dtype==="uint8"||d.dtype==="uint16"){if(!("min"in d&&"scale"in d))throw new Error(`Weight ${a.name} with quantization ${d.dtype} doesn't have corresponding metadata min and scale.`)}else if(d.dtype==="float16"){if(i!=="float32")throw new Error(`Weight ${a.name} is quantized with ${d.dtype} which only supports weights of type float32 not ${i}.`)}else throw new Error(`Weight ${a.name} has unknown quantization dtype ${d.dtype}. Supported quantization dtypes are: 'uint8', 'uint16', and 'float16'.`);let h=C2[d.dtype],p=e.slice(s,s+u*h),f=d.dtype==="uint8"?new Uint8Array(p):new Uint16Array(p);if(i==="float32")if(d.dtype==="uint8"||d.dtype==="uint16"){c=new Float32Array(f.length);for(let m=0;m<f.length;m++){let g=f[m];c[m]=g*d.scale+d.min}}else if(d.dtype==="float16")r===void 0&&(r=sF()),c=r(f);else throw new Error(`Unsupported quantization type ${d.dtype} for weight type float32.`);else if(i==="int32"){if(d.dtype!=="uint8"&&d.dtype!=="uint16")throw new Error(`Unsupported quantization type ${d.dtype} for weight type int32.`);c=new Int32Array(f.length);for(let m=0;m<f.length;m++){let g=f[m];c[m]=Math.round(g*d.scale+d.min)}}else throw new Error(`Unsupported dtype in weight '${o}': ${i}`);s+=u*h}else if(i==="string"){let d=Jt(a.shape);c=[];for(let h=0;h<d;h++){let p=new Uint32Array(e.slice(s,s+dp))[0];s+=dp;let f=new Uint8Array(e.slice(s,s+p));c.push(f),s+=p}}else{let d=C2[i],h=e.slice(s,s+u*d);if(i==="float32")c=new Float32Array(h);else if(i==="int32")c=new Int32Array(h);else if(i==="bool")c=new Uint8Array(h);else if(i==="complex64"){c=new Float32Array(h);let p=new Float32Array(c.length/2),f=new Float32Array(c.length/2);for(let y=0;y<p.length;y++)p[y]=c[y*2],f[y]=c[y*2+1];let m=ts(p,l,"float32"),g=ts(f,l,"float32");n[o]=go(m,g),m.dispose(),g.dispose()}else throw new Error(`Unsupported dtype in weight '${o}': ${i}`);s+=u*d}i!=="complex64"&&(n[o]=ts(c,l,i))}return n}function JD(e){if(e===null)throw new Error(`Invalid input value: ${JSON.stringify(e)}`);let t=0,n=[];e.forEach(a=>{if(t+=a.byteLength,n.push(a.byteLength===a.buffer.byteLength?a:new a.constructor(a)),!(a instanceof Float32Array||a instanceof Int32Array||a instanceof Uint8Array))throw new Error(`Unsupported TypedArray subtype: ${a.constructor.name}`)});let r=new Uint8Array(t),s=0;return n.forEach(a=>{r.set(new Uint8Array(a.buffer),s),s+=a.byteLength}),r.buffer}var E2=typeof Buffer!="undefined"&&(typeof Blob=="undefined"||typeof atob=="undefined"||typeof btoa=="undefined");function J7(e){return E2?Buffer.byteLength(e):new Blob([e]).size}function QD(e){if(E2)return Buffer.from(e).toString("base64");let t=new Uint8Array(e),n="";for(let r=0,s=t.length;r<s;r++)n+=String.fromCharCode(t[r]);return btoa(n)}function eF(e){if(E2){let r=Buffer.from(e,"base64");return r.buffer.slice(r.byteOffset,r.byteOffset+r.byteLength)}let t=atob(e),n=new Uint8Array(t.length);for(let r=0;r<t.length;++r)n.set([t.charCodeAt(r)],r);return n.buffer}function $2(e){if(e.length===1)return e[0];let t=0;e.forEach(s=>{t+=s.byteLength});let n=new Uint8Array(t),r=0;return e.forEach(s=>{n.set(new Uint8Array(s),r),r+=s.byteLength}),n.buffer}function Q7(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 ac(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:J7(JSON.stringify(e.modelTopology)),weightSpecsBytes:e.weightSpecs==null?0:J7(JSON.stringify(e.weightSpecs)),weightDataBytes:e.weightData==null?0:e.weightData.byteLength}}function tF(){let e=n=>{let r=n<<13,s=0;for(;(r&8388608)==0;)s-=8388608,r<<=1;return r&=~8388608,s+=947912704,r|s},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 nF(){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 rF(){let e=new Uint32Array(64);for(let t=0;t<64;t++)e[t]=1024;return e[0]=e[32]=0,e}function sF(){let e=tF(),t=nF(),n=rF();return r=>{let s=new ArrayBuffer(4*r.length),a=new Uint32Array(s);for(let o=0;o<r.length;o++){let i=r[o],l=e[n[i>>10]+(i&1023)]+t[i>>10];a[o]=l}return new Float32Array(s)}}var jt=class{constructor(){this.saveRouters=[],this.loadRouters=[]}static getInstance(){return jt.instance==null&&(jt.instance=new jt),jt.instance}static registerSaveRouter(e){jt.getInstance().saveRouters.push(e)}static registerLoadRouter(e){jt.getInstance().loadRouters.push(e)}static getSaveHandlers(e){return jt.getHandlers(e,"save")}static getLoadHandlers(e,t){return jt.getHandlers(e,"load",t)}static getHandlers(e,t,n){let r=[];return(t==="load"?jt.getInstance().loadRouters:jt.getInstance().saveRouters).forEach(a=>{let o=a(e,n);o!==null&&r.push(o)}),r}},aF=e=>jt.registerSaveRouter(e),oF=e=>jt.registerLoadRouter(e),iF=e=>jt.getSaveHandlers(e),lF=(e,t)=>jt.getLoadHandlers(e,t),_2="tensorflowjs",R2=1,yo="models_store",Ca="model_info_store";function ek(){if(!ct().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 D2(e){let t=e.result;t.createObjectStore(yo,{keyPath:"modelPath"}),t.createObjectStore(Ca,{keyPath:"modelPath"})}var Ao=class{constructor(e){if(this.indexedDB=ek(),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,r)=>{let s=this.indexedDB.open(_2,R2);s.onupgradeneeded=()=>D2(s),s.onsuccess=()=>{let a=s.result;if(t==null){let o=a.transaction(yo,"readonly"),l=o.objectStore(yo).get(this.modelPath);l.onsuccess=()=>{if(l.result==null)return a.close(),r(new Error(`Cannot find model with path '${this.modelPath}' in IndexedDB.`));n(l.result.modelArtifacts)},l.onerror=u=>(a.close(),r(l.error)),o.oncomplete=()=>a.close()}else{let o=ac(t),i=a.transaction(Ca,"readwrite"),l=i.objectStore(Ca),u=l.put({modelPath:this.modelPath,modelArtifactsInfo:o}),c;u.onsuccess=()=>{c=a.transaction(yo,"readwrite");let h=c.objectStore(yo).put({modelPath:this.modelPath,modelArtifacts:t,modelArtifactsInfo:o});h.onsuccess=()=>n({modelArtifactsInfo:o}),h.onerror=p=>{l=i.objectStore(Ca);let f=l.delete(this.modelPath);f.onsuccess=()=>(a.close(),r(h.error)),f.onerror=m=>(a.close(),r(h.error))}},u.onerror=d=>(a.close(),r(u.error)),i.oncomplete=()=>{c==null?a.close():c.oncomplete=()=>a.close()}}},s.onerror=a=>r(s.error)})}};Ao.URL_SCHEME="indexeddb://";var tk=e=>ct().getBool("IS_BROWSER")&&!Array.isArray(e)&&e.startsWith(Ao.URL_SCHEME)?uF(e.slice(Ao.URL_SCHEME.length)):null;jt.registerSaveRouter(tk);jt.registerLoadRouter(tk);function uF(e){return new Ao(e)}function cF(e){return e.startsWith(Ao.URL_SCHEME)?e.slice(Ao.URL_SCHEME.length):e}var dF=class{constructor(){this.indexedDB=ek()}async listModels(){return new Promise((e,t)=>{let n=this.indexedDB.open(_2,R2);n.onupgradeneeded=()=>D2(n),n.onsuccess=()=>{let r=n.result,s=r.transaction(Ca,"readonly"),o=s.objectStore(Ca).getAll();o.onsuccess=()=>{let i={};for(let l of o.result)i[l.modelPath]=l.modelArtifactsInfo;e(i)},o.onerror=i=>(r.close(),t(o.error)),s.oncomplete=()=>r.close()},n.onerror=r=>t(n.error)})}async removeModel(e){return e=cF(e),new Promise((t,n)=>{let r=this.indexedDB.open(_2,R2);r.onupgradeneeded=()=>D2(r),r.onsuccess=()=>{let s=r.result,a=s.transaction(Ca,"readwrite"),o=a.objectStore(Ca),i=o.get(e),l;i.onsuccess=()=>{if(i.result==null)return s.close(),n(new Error(`Cannot find model with path '${e}' in IndexedDB.`));{let u=o.delete(e),c=()=>{l=s.transaction(yo,"readwrite");let h=l.objectStore(yo).delete(e);h.onsuccess=()=>t(i.result.modelArtifactsInfo),h.onerror=p=>n(i.error)};u.onsuccess=c,u.onerror=d=>(c(),s.close(),n(i.error))}},i.onerror=u=>(s.close(),n(i.error)),a.oncomplete=()=>{l==null?s.close():l.oncomplete=()=>s.close()}},r.onerror=s=>n(r.error)})}},Zs="/",Wi="tensorflowjs_models",nk="info",hF="model_topology",pF="weight_specs",fF="weight_data",mF="model_metadata";function rk(e){return{info:[Wi,e,nk].join(Zs),topology:[Wi,e,hF].join(Zs),weightSpecs:[Wi,e,pF].join(Zs),weightData:[Wi,e,fF].join(Zs),modelMetadata:[Wi,e,mF].join(Zs)}}function gF(e){let t=e.split(Zs);if(t.length<3)throw new Error(`Invalid key format: ${e}`);return t.slice(1,t.length-1).join(Zs)}function yF(e){return e.startsWith(xo.URL_SCHEME)?e.slice(xo.URL_SCHEME.length):e}var xo=class{constructor(e){if(!ct().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=rk(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),r=ac(e);try{this.LS.setItem(this.keys.info,JSON.stringify(r)),this.LS.setItem(this.keys.topology,t),this.LS.setItem(this.keys.weightSpecs,n),this.LS.setItem(this.keys.weightData,QD(e.weightData));let s={format:e.format,generatedBy:e.generatedBy,convertedBy:e.convertedBy};return e.signature!=null&&(s.signature=e.signature),e.userDefinedMetadata!=null&&(s.userDefinedMetadata=e.userDefinedMetadata),e.modelInitializer!=null&&(s.modelInitializer=e.modelInitializer),this.LS.setItem(this.keys.modelMetadata,JSON.stringify(s)),{modelArtifactsInfo:r}}catch(s){throw this.LS.removeItem(this.keys.info),this.LS.removeItem(this.keys.topology),this.LS.removeItem(this.keys.weightSpecs),this.LS.removeItem(this.keys.weightData),this.LS.removeItem(this.keys.modelMetadata),new Error(`Failed to save model '${this.modelPath}' to local storage: size quota being exceeded is a possible cause of this failure: modelTopologyBytes=${r.modelTopologyBytes}, weightSpecsBytes=${r.weightSpecsBytes}, weightDataBytes=${r.weightDataBytes}.`)}}}async load(){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 r=JSON.parse(this.LS.getItem(this.keys.weightSpecs));if(r==null)throw new Error(`In local storage, the weight specs of model '${this.modelPath}' are missing.`);t.weightSpecs=r;let s=this.LS.getItem(this.keys.modelMetadata);if(s!=null){let o=JSON.parse(s);t.format=o.format,t.generatedBy=o.generatedBy,t.convertedBy=o.convertedBy,o.signature!=null&&(t.signature=o.signature),o.userDefinedMetadata!=null&&(t.userDefinedMetadata=o.userDefinedMetadata),o.modelInitializer!=null&&(t.modelInitializer=o.modelInitializer)}let a=this.LS.getItem(this.keys.weightData);if(a==null)throw new Error(`In local storage, the binary weight values of model '${this.modelPath}' are missing.`);return t.weightData=eF(a),t}};xo.URL_SCHEME="localstorage://";var sk=e=>ct().getBool("IS_BROWSER")&&!Array.isArray(e)&&e.startsWith(xo.URL_SCHEME)?AF(e.slice(xo.URL_SCHEME.length)):null;jt.registerSaveRouter(sk);jt.registerLoadRouter(sk);function AF(e){return new xo(e)}var xF=class{constructor(){L(ct().getBool("IS_BROWSER"),()=>"Current environment is not a web browser"),L(typeof window=="undefined"||typeof window.localStorage!="undefined",()=>"Current browser does not appear to support localStorage"),this.LS=window.localStorage}async listModels(){let e={},t=Wi+Zs,n=Zs+nk;for(let r=0;r<this.LS.length;++r){let s=this.LS.key(r);if(s.startsWith(t)&&s.endsWith(n)){let a=gF(s);e[a]=JSON.parse(this.LS.getItem(s))}}return e}async removeModel(e){e=yF(e);let t=rk(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 this.LS.removeItem(t.info),this.LS.removeItem(t.topology),this.LS.removeItem(t.weightSpecs),this.LS.removeItem(t.weightData),n}},Vi="://",Tr=class{constructor(){this.managers={}}static getInstance(){return Tr.instance==null&&(Tr.instance=new Tr),Tr.instance}static registerManager(e,t){L(e!=null,()=>"scheme must not be undefined or null."),e.endsWith(Vi)&&(e=e.slice(0,e.indexOf(Vi))),L(e.length>0,()=>"scheme must not be an empty string.");let n=Tr.getInstance();L(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 hp(e){if(e.indexOf(Vi)===-1)throw new Error(`The url string provided does not contain a scheme. Supported schemes are: ${Tr.getSchemes().join(",")}`);return{scheme:e.split(Vi)[0],path:e.split(Vi)[1]}}async function ak(e,t,n=!1){L(e!==t,()=>`Old path and new path are the same: '${e}'`);let r=jt.getLoadHandlers(e);L(r.length>0,()=>`Copying failed because no load handler is found for source URL ${e}.`),L(r.length<2,()=>`Copying failed because more than one (${r.length}) load handlers for source URL ${e}.`);let s=r[0],a=jt.getSaveHandlers(t);L(a.length>0,()=>`Copying failed because no save handler is found for destination URL ${t}.`),L(a.length<2,()=>`Copying failed because more than one (${r.length}) save handlers for destination URL ${t}.`);let o=a[0],i=hp(e).scheme,l=hp(e).path,u=i===hp(e).scheme,c=await s.load();n&&u&&await Tr.getManager(i).removeModel(l);let d=await o.save(c);return n&&!u&&await Tr.getManager(i).removeModel(l),d.modelArtifactsInfo}async function bF(){let e=Tr.getSchemes(),t={};for(let n of e){let r=await Tr.getManager(n).listModels();for(let s in r){let a=n+Vi+s;t[a]=r[s]}}return t}async function vF(e){let t=hp(e);return Tr.getManager(t.scheme).removeModel(t.path)}async function wF(e,t){return ak(e,t,!1)}async function kF(e,t){return ak(e,t,!0)}var IF=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(ct().get("IS_BROWSER")){ct().setPlatform("browser",new IF);try{Tr.registerManager(xo.URL_SCHEME,new xF)}catch(e){}try{Tr.registerManager(Ao.URL_SCHEME,new dF)}catch(e){}}var SF={importFetch:()=>O3()},F2,TF=class{constructor(){this.util=co("util"),this.textEncoder=new this.util.TextEncoder}fetch(e,t){return ct().global.fetch!=null?ct().global.fetch(e,t):(F2==null&&(F2=SF.importFetch()),F2(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)}};ct().get("IS_NODE")&&ct().setPlatform("node",new TF);function Ys(e,t="float32",n){return t=t||"float32",r2(e),new up(e,t,n)}function NF(e,t){let n=P(e,"x","cast");if(!G3(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 r={x:n},s={dtype:t};return U.runKernel(l2,r,s)}var Pt=H({cast_:NF});function CF(e){let n={x:P(e,"x","clone","string_or_numeric")};return U.runKernel(u2,n)}var Js=H({clone_:CF});function ok(e,t=!1){console.log(e.toString(t))}G7();var EF={buffer:Ys,cast:Pt,clone:Js,print:ok};LD(EF);var ik={};De(ik,{browserFiles:()=>OF,browserHTTPRequest:()=>WF,concatenateArrayBuffers:()=>$2,copyModel:()=>wF,decodeWeights:()=>Y7,encodeWeights:()=>YD,fromMemory:()=>UF,getLoadHandlers:()=>lF,getModelArtifactsInfoForJSON:()=>ac,getSaveHandlers:()=>iF,http:()=>z2,isHTTPScheme:()=>P2,listModels:()=>bF,loadWeights:()=>PF,moveModel:()=>kF,registerLoadRouter:()=>oF,registerSaveRouter:()=>aF,removeModel:()=>vF,weightsLoaderFactory:()=>dk,withSaveHandler:()=>HF});var $F="model",_F=".json",RF=".weights.bin";function lk(e){return new Promise(t=>setTimeout(t)).then(e)}var M2=class{constructor(e){if(!ct().getBool("IS_BROWSER"))throw new Error("browserDownloads() cannot proceed because the current environment is not a browser.");e.startsWith(M2.URL_SCHEME)&&(e=e.slice(M2.URL_SCHEME.length)),(e==null||e.length===0)&&(e=$F),this.modelTopologyFileName=e+_F,this.weightDataFileName=e+RF}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}],r={modelTopology:e.modelTopology,format:e.format,generatedBy:e.generatedBy,convertedBy:e.convertedBy,weightsManifest:n};e.signature!=null&&(r.signature=e.signature),e.userDefinedMetadata!=null&&(r.userDefinedMetadata=e.userDefinedMetadata),e.modelInitializer!=null&&(r.modelInitializer=e.modelInitializer);let s=window.URL.createObjectURL(new Blob([JSON.stringify(r)],{type:"application/json"})),a=this.jsonAnchor==null?document.createElement("a"):this.jsonAnchor;if(a.download=this.modelTopologyFileName,a.href=s,await lk(()=>a.dispatchEvent(new MouseEvent("click"))),e.weightData!=null){let o=this.weightDataAnchor==null?document.createElement("a"):this.weightDataAnchor;o.download=this.weightDataFileName,o.href=t,await lk(()=>o.dispatchEvent(new MouseEvent("click")))}return{modelArtifactsInfo:ac(e)}}}},pp=M2;pp.URL_SCHEME="downloads://";var DF=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.files=e}async load(){let e=this.files[0],t=this.files.slice(1);return new Promise((n,r)=>{let s=new FileReader;s.onload=a=>{let o=JSON.parse(a.target.result),i=o.modelTopology;if(i==null){r(new Error(`modelTopology field is missing from file ${e.name}`));return}t.length===0&&n({modelTopology:i});let l=o.weightsManifest;if(l==null){r(new Error(`weightManifest field is missing from file ${e.name}`));return}let u;try{u=this.checkManifestAndWeightFiles(l,t)}catch(p){r(p);return}let c=[],d=[],h=[];l.forEach(p=>{p.paths.forEach(f=>{d.push(f),h.push(null)}),c.push(...p.weights)}),l.forEach(p=>{p.paths.forEach(f=>{let m=new FileReader;m.onload=g=>{let y=g.target.result,A=d.indexOf(f);if(h[A]=y,h.indexOf(null)===-1){let x={modelTopology:i,weightSpecs:c,weightData:$2(h),format:o.format,generatedBy:o.generatedBy,convertedBy:o.convertedBy};o.signature!=null&&(x.signature=o.signature),o.userDefinedMetadata!=null&&(x.userDefinedMetadata=o.userDefinedMetadata),o.modelInitializer!=null&&(x.modelInitializer=o.modelInitializer),n(x)}},m.onerror=g=>r(`Failed to weights data from file of path '${f}'.`),m.readAsArrayBuffer(u[f])})})},s.onerror=a=>r(`Failed to read model topology and weights manifest JSON from file '${e.name}'. BrowserFiles supports loading Keras-style tf.Model artifacts only.`),s.readAsText(e)})}checkManifestAndWeightFiles(e,t){let n=[],r=t.map(a=>Q7(a.name)),s={};for(let a of e)a.paths.forEach(o=>{let i=Q7(o);if(n.indexOf(i)!==-1)throw new Error(`Duplicate file basename found in weights manifest: '${i}'`);if(n.push(i),r.indexOf(i)===-1)throw new Error(`Weight file with basename '${i}' is not provided.`);s[o]=t[r.indexOf(i)]});if(n.length!==t.length)throw new Error(`Mismatch in the number of files in weights manifest (${n.length}) and the number of weight files provided (${t.length}).`);return s}},FF=e=>ct().getBool("IS_BROWSER")&&!Array.isArray(e)&&e.startsWith(pp.URL_SCHEME)?MF(e.slice(pp.URL_SCHEME.length)):null;jt.registerSaveRouter(FF);function MF(e="model"){return new pp(e)}function OF(e){return new DF(e)}function uk(e,t,n,r){o(e),n=n==null?0:n,r=r==null?1:r,i(n,r);let s=0,a=l=>(l.then(u=>{let c=n+ ++s/e.length*(r-n);return t(c),u}),l);function o(l){L(l!=null&&Array.isArray(l)&&l.length>0,()=>"promises must be a none empty array")}function i(l,u){L(l>=0&&l<=1,()=>`Progress fraction must be in range [0, 1], but got startFraction ${l}`),L(u>=0&&u<=1,()=>`Progress fraction must be in range [0, 1], but got endFraction ${u}`),L(u>=l,()=>`startFraction must be no more than endFraction, but got startFraction ${l} and endFraction ${u}`)}return Promise.all(e.map(a))}async function ck(e,t){t==null&&(t={});let n=t.fetchFunc==null?ct().platform.fetch:t.fetchFunc,r=e.map(d=>n(d,t.requestInit,{isBinary:!0})),s=0,a=.5,i=(t.onProgress==null?await Promise.all(r):await uk(r,t.onProgress,s,a)).map(d=>d.arrayBuffer()),l=.5,u=1;return t.onProgress==null?await Promise.all(i):await uk(i,t.onProgress,l,u)}async function PF(e,t="",n,r){return dk(o=>ck(o,{requestInit:r}))(e,t,n)}function dk(e){return async(t,n="",r)=>{let s=t.map(()=>!1),a={},o=r!=null?r.map(()=>!1):[],i=[];if(t.forEach((p,f)=>{let m=0;p.weights.forEach(g=>{let y="quantization"in g?g.quantization.dtype:g.dtype,A=C2[y]*Jt(g.shape),x=()=>{s[f]=!0,a[f]==null&&(a[f]=[]),a[f].push({manifestEntry:g,groupOffset:m,sizeBytes:A})};r!=null?r.forEach((b,v)=>{b===g.name&&(x(),o[v]=!0)}):x(),i.push(g.name),m+=A})}),!o.every(p=>p)){let p=r.filter((f,m)=>!o[m]);throw new Error(`Could not find weights in manifest with names: ${p.join(", ")}.
|
|
Manifest JSON has weights with names: ${i.join(", ")}.`)}let l=s.reduce((p,f,m)=>(f&&p.push(m),p),[]),u=[];l.forEach(p=>{t[p].paths.forEach(f=>{let m=n+(n.endsWith("/")?"":"/")+f;u.push(m)})});let c=await e(u),d={},h=0;return l.forEach(p=>{let f=t[p].paths.length,m=0;for(let b=0;b<f;b++)m+=c[h+b].byteLength;let g=new ArrayBuffer(m),y=new Uint8Array(g),A=0;for(let b=0;b<f;b++){let v=new Uint8Array(c[h+b]);y.set(v,A),A+=v.byteLength}a[p].forEach(b=>{let v=g.slice(b.groupOffset,b.groupOffset+b.sizeBytes),w=Y7(v,[b.manifestEntry]);for(let I in w)d[I]=w[I]}),h+=f}),d}}var zF="application/octet-stream",LF="application/json",O2=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?(L(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=ct().platform.fetch,L(e!=null&&e.length>0,()=>"URL path for http must not be null, undefined or empty."),Array.isArray(e)&&L(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}],r={modelTopology:e.modelTopology,format:e.format,generatedBy:e.generatedBy,convertedBy:e.convertedBy,weightsManifest:n};e.signature!=null&&(r.signature=e.signature),e.userDefinedMetadata!=null&&(r.userDefinedMetadata=e.userDefinedMetadata),e.modelInitializer!=null&&(r.modelInitializer=e.modelInitializer),t.body.append("model.json",new Blob([JSON.stringify(r)],{type:LF}),"model.json"),e.weightData!=null&&t.body.append("model.weights.bin",new Blob([e.weightData],{type:zF}),"model.weights.bin");let s=await this.fetch(this.path,t);if(s.ok)return{modelArtifactsInfo:ac(e),responses:[s]};throw new Error(`BrowserHTTPRequest.save() failed due to HTTP response status ${s.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(p){let f=`Failed to parse model JSON of response from ${this.path}.`;throw this.path.endsWith(".pb")?f+=" 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.":f+=" Please make sure the server is serving valid JSON for this request.",new Error(f)}let n=t.modelTopology,r=t.weightsManifest,s=t.generatedBy,a=t.convertedBy,o=t.format,i=t.signature,l=t.userDefinedMetadata;if(n==null&&r==null)throw new Error(`The JSON from HTTP path ${this.path} contains neither model topology or manifest for weights.`);let u,c;r!=null&&([u,c]=await this.loadWeights(r));let d={modelTopology:n,weightSpecs:u,weightData:c,generatedBy:s,convertedBy:a,format:o};i!=null&&(d.signature=i),l!=null&&(d.userDefinedMetadata=l);let h=t.modelInitializer;return h&&(d.modelInitializer=h),d}async loadWeights(e){let t=Array.isArray(this.path)?this.path[1]:this.path,[n,r]=BF(t),s=this.weightPathPrefix||n,a=[];for(let u of e)a.push(...u.weights);let o=[],i=[];for(let u of e)for(let c of u.paths)this.weightUrlConverter!=null?i.push(this.weightUrlConverter(c)):o.push(s+c+r);this.weightUrlConverter&&o.push(...await Promise.all(i));let l=await ck(o,{requestInit:this.requestInit,fetchFunc:this.fetch,onProgress:this.onProgress});return[a,$2(l)]}};O2.URL_SCHEME_REGEX=/^https?:\/\//;function BF(e){let t=e.lastIndexOf("/"),n=e.lastIndexOf("?"),r=e.substring(0,t),s=n>t?e.substring(n):"";return[r+"/",s]}function P2(e){return e.match(O2.URL_SCHEME_REGEX)!=null}var hk=(e,t)=>{if(typeof fetch=="undefined"&&(t==null||t.fetchFunc==null))return null;{let n=!0;if(Array.isArray(e)?n=e.every(r=>P2(r)):n=P2(e),n)return z2(e,t)}return null};jt.registerSaveRouter(hk);jt.registerLoadRouter(hk);function z2(e,t){return new O2(e,t)}function WF(e,t){return z2(e,t)}var L2=class{constructor(e){this.modelArtifacts=e}async load(){return this.modelArtifacts}},VF=class{constructor(e){this.saveHandler=e}async save(e){return this.saveHandler(e)}};function UF(e,t,n,r){return arguments.length===1?e.modelTopology!=null||e.weightSpecs!=null?new L2(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 L2({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 L2({modelTopology:e,weightSpecs:t,weightData:n,trainingConfig:r}))}function HF(e){return new VF(e)}var pk={};De(pk,{confusionMatrix:()=>XF});function GF(e,t,n=!1,r=!1){let s=P(e,"a","matMul"),a=P(t,"b","matMul");[s,a]=Vt(s,a);let o={a:s,b:a},i={transposeA:n,transposeB:r};return U.runKernel(fv,o,i)}var yt=H({matMul_:GF});function jF(e,t,n=1,r=0){if(t<2)throw new Error(`Error in oneHot: depth must be >=2, but it is ${t}`);let a={indices:P(e,"indices","oneHot","int32")},o={depth:t,onValue:n,offValue:r};return U.runKernel(Mw,a,o)}var B2=H({oneHot_:jF});function qF(e,t){let n=P(e,"x","transpose");if(t==null&&(t=n.shape.map((a,o)=>o).reverse()),L(n.rank===t.length,()=>`Error in transpose: rank of input ${n.rank} must match length of perm ${t}.`),t.forEach(a=>{L(a>=0&&a<n.rank,()=>`All entries in 'perm' must be between 0 and ${n.rank-1} but got ${t}`)}),n.rank<=1)return n.clone();let r={x:n},s={perm:t};return U.runKernel(N7,r,s)}var fp=H({transpose_:qF});function KF(e,t,n){let r=P(e,"labels","confusionMatrix"),s=P(t,"predictions","confusionMatrix");L(n==null||n>0&&Number.isInteger(n),()=>`If provided, numClasses must be a positive integer, but got ${n}`),L(r.rank===1,()=>`Expected the rank of labels to be 1, but got ${r.rank}`),L(s.rank===1,()=>`Expected the rank of predictions to be 1, but got ${s.rank}`),L(r.shape[0]===s.shape[0],()=>`Mismatch in the number of examples: ${r.shape[0]} vs. ${s.shape[0]}. Labels and predictions should have the same number of elements.`),L(n>0&&Number.isInteger(n),()=>`numClasses is required to be a positive integer, but got ${n}`);let a=B2(Pt(r,"int32"),n),o=B2(Pt(s,"int32"),n),i=fp(a),l=yt(i,o);return Pt(l,"int32")}var XF=H({confusionMatrix_:KF}),Hr={};De(Hr,{fromPixels:()=>nM,fromPixelsAsync:()=>eM,toPixels:()=>tM});function mp(e,t,n){if(ho(e),t!=null&&t.length!==3)throw new Error("tensor3d() requires shape to have three numbers");let r=Ss(e,n);if(r.length!==3&&r.length!==1)throw new Error("tensor3d() requires values to be number[][][] or flat/TypedArray");if(r.length===1&&t==null)throw new Error("tensor3d() requires shape to be provided when `values` are a flat array");return Na(e,t,r,n)}var Ui;function fk(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,r=!1,s=!1,a=!1,o=!1,i=!1;if(e.data instanceof Uint8Array)n=!0;else if(typeof ImageData!="undefined"&&e instanceof ImageData)r=!0;else if(typeof HTMLVideoElement!="undefined"&&e instanceof HTMLVideoElement)s=!0;else if(typeof HTMLImageElement!="undefined"&&e instanceof HTMLImageElement)a=!0;else if(e.getContext!=null)o=!0;else if(typeof ImageBitmap!="undefined"&&e instanceof ImageBitmap)i=!0;else throw new Error(`pixels passed to tf.browser.fromPixels() must be either an HTMLVideoElement, HTMLImageElement, HTMLCanvasElement, ImageData in browser, or OffscreenCanvas, ImageData in webworker or {data: Uint32Array, width: number, height: number}, but was ${e.constructor.name}`);if(s){let f=2;if(s&&e.readyState<f)throw new Error("The video element has not loaded data yet. Please wait for `loadeddata` event on the <video> element.")}if(rp(d2,U.backendName)!=null){let f={pixels:e},m={numChannels:t};return U.runKernel(d2,f,m)}let[u,c]=s?[e.videoWidth,e.videoHeight]:[e.width,e.height],d;o?d=e.getContext("2d").getImageData(0,0,u,c).data:r||n?d=e.data:(a||s||i)&&(Ui==null&&(Ui=document.createElement("canvas").getContext("2d")),Ui.canvas.width=u,Ui.canvas.height=c,Ui.drawImage(e,0,0,u,c),d=Ui.getImageData(0,0,u,c).data);let h;if(t===4)h=new Int32Array(d);else{let f=u*c;h=new Int32Array(f*t);for(let m=0;m<f;m++)for(let g=0;g<t;++g)h[m*t+g]=d[m*4+g]}return mp(h,[c,u,t],"int32")}function ZF(e){return e!=null&&e.data instanceof Uint8Array}function YF(){return typeof window!="undefined"&&typeof ImageBitmap!="undefined"&&window.hasOwnProperty("createImageBitmap")}function JF(e){return e!=null&&e.width!==0&&e.height!==0}function QF(e){return YF()&&!(e instanceof ImageBitmap)&&JF(e)&&!ZF(e)}async function eM(e,t=3){let n=null;if(ct().getBool("WRAP_TO_IMAGEBITMAP")&&QF(e)){let r;try{r=await createImageBitmap(e,{premultiplyAlpha:"none"})}catch(s){r=null}r!=null&&r.width===e.width&&r.height===e.height?n=r:n=e}else n=e;return fk(n,t)}async function tM(e,t){let n=P(e,"img","toPixels");if(!(e instanceof Tt)){let u=n;n=Pt(u,"int32"),u.dispose()}if(n.rank!==2&&n.rank!==3)throw new Error(`toPixels only supports rank 2 or 3 tensors, got rank ${n.rank}.`);let[r,s]=n.shape.slice(0,2),a=n.rank===2?1:n.shape[2];if(a>4||a===2)throw new Error(`toPixels only supports depth of size 1, 3 or 4 but got ${a}`);if(n.dtype!=="float32"&&n.dtype!=="int32")throw new Error(`Unsupported type for toPixels: ${n.dtype}. Please use float32 or int32 tensors.`);let o=await n.data(),i=n.dtype==="float32"?255:1,l=new Uint8ClampedArray(s*r*4);for(let u=0;u<r*s;++u){let c=[0,0,0,255];for(let h=0;h<a;h++){let p=o[u*a+h];if(n.dtype==="float32"){if(p<0||p>1)throw new Error(`Tensor values for a float32 Tensor must be in the range [0 - 1] but encountered ${p}.`)}else if(n.dtype==="int32"&&(p<0||p>255))throw new Error(`Tensor values for a int32 Tensor must be in the range [0 - 255] but encountered ${p}.`);a===1?(c[0]=p*i,c[1]=p*i,c[2]=p*i):c[h]=p*i}let d=u*4;l[d+0]=Math.round(c[0]),l[d+1]=Math.round(c[1]),l[d+2]=Math.round(c[2]),l[d+3]=Math.round(c[3])}if(t!=null){t.width=s,t.height=r;let u=t.getContext("2d"),c=new ImageData(l,s,r);u.putImageData(c,0,0)}return n!==e&&n.dispose(),l}var nM=H({fromPixels_:fk}),mk={};De(mk,{prepareAndValidate:()=>gk});function gk(e,t){let n=e.shape.length,r=t.shape.length;if(n<1)throw new Error(`tf.gatherND() expects the input to be rank 1 or higher, but the rank was ${n}.`);if(r<1)throw new Error(`tf.gatherND() expects the indices to be rank 1 or higher, but the rank was ${r}.`);if(t.dtype!=="int32")throw new Error(`tf.gatherND() expects the indices to be int32 type, but the dtype was ${t.dtype}.`);if(t.shape[r-1]>n)throw new Error(`index innermost dimension length must be <= tensor rank; saw: ${t.shape[r-1]} vs. ${n}`);if(Jt(e.shape)===0)throw new Error(`Requested more than 0 entries, but input is empty. Input shape: ${e.shape}.`);let s=t.shape,a=s[s.length-1],o=1;for(let d=0;d<s.length-1;++d)o*=s[d];let i=e.shape,l=s.slice();l.pop();let u=1;for(let d=a;d<n;++d)u*=i[d],l.push(i[d]);let c=[...Oi(e.shape).map(d=>d/u),1].slice(0,a);return[l,o,u,c]}var yk={};De(yk,{calculateShapes:()=>Ak,validateInput:()=>V2,validateUpdateShape:()=>W2});function W2(e,t,n){let r=t.rank>1?t.shape[t.rank-1]:1,s=t.rank>1?t.rank-1:1,a=`Must have updates.shape = indices.shape[:batchDim] + shape[sliceDim:], got updates.shape: ${n.shape}, indices.shape: ${t.shape}, shape: ${e}, sliceDim: ${r}, and batchDim: ${s}.`;if(n.rank<s)throw new Error(a+` update.rank < ${s}. `);if(e.length<r+(n.rank-s))throw new Error(a+` Output shape length < ${r+(n.rank-s)}`);if(n.rank!==s+e.length-r)throw new Error(a+` update.rank != ${s+e.length-r}`);for(let o=0;o<s;++o)if(n.shape[o]!==t.shape[o])throw new Error(a+` updates.shape[${o}] (${n.shape[o]}) != indices.shape[${o}] (${t.shape[o]}).`);for(let o=0;o<n.rank-s;++o)if(n.shape[o+s]!==e[o+r])throw new Error(a+` updates.shape[${o+s}] (${n.shape[o+s]}) != shape[${o+s}] (${e[o+s]})`)}function V2(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}`)}W2(n,t,e)}function Ak(e,t,n){let r=t.shape.length,s=r>1?t.shape[r-1]:1,a=n.length,o=1;for(let d=s;d<a;++d)o*=n[d];let i=s<1?1:s,l=Jt(t.shape)/i,u=[...Oi(n.slice(0,s)),1],c=Jt(n);return{sliceRank:s,numUpdates:l,sliceSize:o,strides:u,outputSize:c}}var U2={};De(U2,{assertParamsValid:()=>rM,computeFlatOffset:()=>aM,computeOutShape:()=>xk,getNormalizedAxes:()=>kk,isSliceContinous:()=>sM,maskToAxes:()=>gp,parseSliceParams:()=>oM,sliceInfo:()=>iM,startForAxis:()=>Nk,startIndicesWithElidedDims:()=>Ik,stopForAxis:()=>Ck,stopIndicesWithElidedDims:()=>Sk,stridesForAxis:()=>Tk,stridesWithElidedDims:()=>bk});function rM(e,t,n){let r=e.shape.length;L(r===t.length,()=>`Error in slice${r}D: Length of begin ${t} must match the rank of the array (${r}).`),L(r===n.length,()=>`Error in slice${r}D: Length of size ${n} must match the rank of the array (${r}).`);for(let s=0;s<r;++s)L(t[s]+n[s]<=e.shape[s],()=>`Error in slice${r}D: begin[${s}] + size[${s}] (${t[s]+n[s]}) would overflow input.shape[${s}] (${e.shape[s]})`)}function gp(e){let t=[],n=0;for(;e>0;)e&1&&t.push(n),e/=2,n++;return t}function xk(e,t,n){let r=[];for(let s=0;s<e.length;s++)r[s]=Math.ceil((t[s]-e[s])/n[s]);return r}function bk(e,t,n,r){let s=[...e];for(let a=s.length;a<r.length;a++)s.push(1);for(let a=0;a<n;a++)a===0?s[t]=1:(s.splice(t,0,1),s.pop());return s}function vk(e,t,n){return n<=e?n:n-(t-1)}function wk(e,t){let n=[];for(let r=0;r<e;r++)n.push(t+r);return n}function kk(e,t,n,r,s,a,o,i,l){let u=e.length,c=new Array(u),d=new Array(u),h=new Array(u);if(t.length&&n>0){let p=t[0],f=n+1;c=Ik(o,p,f,r,e),d=Sk(i,p,f,s,e),h=bk(a,p,f,e)}else for(let p=0;p<u;p++)c[p]=Nk(o,r,a,e,p,l),d[p]=Ck(i,s,a,e,p,l),h[p]=Tk(a,p,l);return{begin:c,end:d,strides:h}}function Ik(e,t,n,r,s){let a=[...s],o=wk(n,t);for(let i=0;i<a.length;i++)if(o.indexOf(i)>-1)a[i]=0;else{let l=vk(t,n,i),u=r[l];e&1<<l&&(u=0),a[i]=u}return a}function Sk(e,t,n,r,s){let a=[...s],o=wk(n,t);for(let i=0;i<a.length;i++)if(o.indexOf(i)>-1)a[i]=Number.MAX_SAFE_INTEGER;else{let l=vk(t,n,i),u=r[l];e&1<<l&&(u=Number.MAX_SAFE_INTEGER),a[i]=u}for(let i=0;i<a.length;i++){let l=s[i];a[i]<0&&(a[i]+=l),a[i]=qu(0,a[i],s[i])}return a}function Tk(e,t,n){let r=e[t];return(n&1<<t||r==null)&&(r=1),r}function Nk(e,t,n,r,s,a){let o=t[s],i=n[s]||1;(e&1<<s||a&1<<s||o==null)&&(i>0?o=Number.MIN_SAFE_INTEGER:o=Number.MAX_SAFE_INTEGER);let l=r[s];return o<0&&(o+=l),o=qu(0,o,l-1),o}function Ck(e,t,n,r,s,a){let o=t[s],i=n[s]||1;(e&1<<s||a&1<<s||o==null)&&(i>0?o=Number.MAX_SAFE_INTEGER:o=Number.MIN_SAFE_INTEGER);let l=r[s];return o<0&&(o+=l),i>0?o=qu(0,o,l):o=qu(-1,o,l-1),o}function sM(e,t,n){let r=n.length;for(let s=0;s<n.length;s++)if(n[s]>1){r=s;break}for(let s=r+1;s<n.length;s++)if(t[s]>0||n[s]!==e[s])return!1;return!0}function aM(e,t){let n=e.length>0?e[e.length-1]:1;for(let r=0;r<e.length-1;r++)n+=e[r]*t[r];return n}function oM(e,t,n){let r,s=e.shape.length;typeof t=="number"?r=[t,...new Array(s-1).fill(0)]:t.length<s?r=t.concat(new Array(s-t.length).fill(0)):r=t.slice(),r.forEach(o=>{L(o!==-1,()=>"slice() does not support negative begin indexing.")});let a;return n==null?a=new Array(s).fill(-1):typeof n=="number"?a=[n,...new Array(s-1).fill(-1)]:n.length<s?a=n.concat(new Array(s-n.length).fill(-1)):a=n,a=a.map((o,i)=>o>=0?o:(L(o===-1,()=>`Negative size values should be exactly -1 but got ${o} for the slice() size at index ${i}.`),e.shape[i]-r[i])),[r,a]}function iM(e,t,n,r,s,a,o,i,l){let u=t.slice(),c=n.slice(),d=r;r==null&&(d=new Array(u.length));let h=gp(o);if(h.length>1)throw new Error("Multiple ellipses in slice is not allowed.");if(o!==0&&i!==0)throw new Error("Using both ellipsisMask and newAxisMask is not yet supported.");if(o!==0&&l!==0)throw new Error("Using both ellipsisMask and shrinkAxisMask is not yet supported.");let p=e.length-u.length,f=gp(i),m=e.slice();f.forEach(I=>{u[I]=0,c[I]=1,m.splice(I,0,1)});let{begin:g,end:y,strides:A}=kk(m,h,p,u,c,d,s,a,o);u=g,c=y,d=A;let x=gp(l);x.forEach(I=>{c[I]=u[I]+1,d[I]=1});let b=xk(u,c,d),v=b.filter((I,T)=>x.indexOf(T)===-1);return{nonStrided:d.every(I=>I===1),$begin:u,$end:c,$strides:d,size:b,newShape:m,outShape:v}}var Ek={};De(Ek,{Serializable:()=>$k,SerializationMap:()=>bo,registerClass:()=>Ea});var $k=class{getClassName(){return this.constructor.className}static fromConfig(e,t){return new e(t)}},bo=class{constructor(){this.classNameMap={}}static getMap(){return bo.instance==null&&(bo.instance=new bo),bo.instance}static register(e){bo.getMap().classNameMap[e.className]=[e,e.fromConfig]}};function Ea(e){L(e.className!=null,()=>"Class being registered does not have the static className property defined."),L(typeof e.className=="string",()=>"className is required to be a string, but got type "+typeof e.className),L(e.className.length>0,()=>"Class being registered has an empty-string as its className, which is disallowed."),bo.register(e)}var _k={};De(_k,{TEST_EPSILON_FLOAT16:()=>Rk,encodeStrings:()=>Dk,expectArrayBuffersEqual:()=>fM,expectArraysClose:()=>uM,expectArraysEqual:()=>dM,expectNumbersClose:()=>hM,expectPromiseToFail:()=>cM,expectValuesInRange:()=>pM,testEpsilon:()=>H2});var lM=.001,Rk=.1;function uM(e,t,n){return n==null&&(n=H2()),G2(e,t,(r,s)=>j2(r,s,n))}function H2(){return U.backend.floatPrecision()===32?lM:Rk}function G2(e,t,n){let r=!0;if((Cn(e)||Cn(t))&&(r=!1),Cn(e)&&Cn(t)&&(r=!0),r){let o=e.constructor.name,i=t.constructor.name;if(o!==i)throw new Error(`Arrays are of different type. Actual: ${o}. Expected: ${i}`)}if(Array.isArray(e)&&Array.isArray(t)){let o=Ss(e),i=Ss(t);if(!Xs(o,i))throw new Error(`Arrays have different shapes. Actual: [${o}]. Expected: [${i}]`)}let s=Cn(e)?e:po(e),a=Cn(t)?t:po(t);if(s.length!==a.length)throw new Error(`Arrays have different lengths actual: ${s.length} vs expected: ${a.length}.
|
|
Actual: ${s}.
|
|
Expected: ${a}.`);for(let o=0;o<a.length;++o){let i=s[o],l=a[o];if(!n(i,l))throw new Error(`Arrays differ: actual[${o}] = ${i}, expected[${o}] = ${l}.
|
|
Actual: ${s}.
|
|
Expected: ${a}.`)}}function cM(e,t){e().then(()=>t.fail(),()=>t())}function dM(e,t){let n=typeof t=="string"||typeof t=="number"||typeof t=="boolean"?[t]:t;return Ia(e)||Ia(e[0])||Ia(t)||Ia(t[0])?G2(e,n,(r,s)=>r==s):G2(e,t,(r,s)=>j2(r,s,0))}function hM(e,t,n){if(n==null&&(n=H2()),!j2(e,t,n))throw new Error(`Numbers differ: actual === ${e}, expected === ${t}`)}function j2(e,t,n){return!isFinite(e)&&!isFinite(t)?!0:!(isNaN(e)||isNaN(t)||Math.abs(e-t)>n)}function pM(e,t,n){for(let r=0;r<e.length;r++)if(e[r]<t||e[r]>n)throw new Error(`Value out of range:${e[r]} low: ${t}, high: ${n}`)}function fM(e,t){expect(new Float32Array(e)).toEqual(new Float32Array(t))}function Dk(e){for(let t=0;t<e.length;t++){let n=e[t];Array.isArray(n)?Dk(n):e[t]=Qu(n)}return e}var mM="3.7.0";function gM(){ct().set("PROD",!0)}function yM(){ct().set("DEBUG",!0)}function AM(){ct().set("DEPRECATION_WARNINGS_ENABLED",!1),console.warn("TensorFlow.js deprecation warnings have been disabled.")}function Fk(e){ct().getBool("DEPRECATION_WARNINGS_ENABLED")&&console.warn(e+" You can disable deprecation warnings with tf.disableDeprecationWarnings().")}BD(Fk);function xM(){U.disposeVariables()}function bM(){return U}function vM(){return U.memory()}function wM(e){return U.profile(e)}function Ue(e,t){return U.tidy(e,t)}function Ve(e){I2(e).forEach(n=>n.dispose())}function Mk(e){return U.keep(e)}function kM(e){return U.time(e)}function IM(e){return U.setBackend(e)}function SM(){return U.ready()}function TM(){return U.backendName}function NM(e){U.removeBackend(e)}function q2(e){return U.findBackend(e)}function CM(e){return U.findBackendFactory(e)}function K2(e,t,n=1){return U.registerBackend(e,t,n)}function EM(){return U.backend}function $M(e,t){ct().setPlatform(e,t)}function _M(e,t){let n=P(e,"a","add"),r=P(t,"b","add");[n,r]=Vt(n,r);let s={a:n,b:r};return U.runKernel(i2,s)}var Me=H({add_:_M});function RM(e,t){let n=P(e,"a","floorDiv"),r=P(t,"b","floorDiv");[n,r]=Vt(n,r);let s={a:n,b:r};return U.runKernel(Zv,s)}var Ok=H({floorDiv_:RM});function DM(e,t){let n=P(e,"a","div"),r=P(t,"b","div");if([n,r]=Vt(n,r),n.dtype==="int32"&&r.dtype==="int32")return Ok(n,r);let s={a:n,b:r},a={};return U.runKernel(zv,s,a)}var Qe=H({div_:DM});function FM(e,t){let n=P(e,"a","mul"),r=P(t,"b","mul");[n,r]=Vt(n,r);let s={a:n,b:r};return U.runKernel(Cw,s)}var fe=H({mul_:FM});function MM(e){let t=P(e,"x","abs");if(t.dtype==="complex64"){let n={x:t};return U.runKernel(bv,n)}else{let n={x:t};return U.runKernel(Q3,n)}}var Nr=H({abs_:MM});function OM(e){let n={x:P(e,"x","acos")};return U.runKernel(ev,n)}var PM=H({acos_:OM});function zM(e){let n={x:P(e,"x","acosh")};return U.runKernel(tv,n)}var LM=H({acosh_:zM});function BM(e){L(Array.isArray(e),()=>"The argument passed to tf.addN() must be a list of tensors"),L(e.length>=1,()=>`Must pass at least one tensor to tf.addN(), but got ${e.length}`);let t=e.map((s,a)=>P(s,`tensors${a}`,"addN")),n=t[0];t.forEach(s=>{if(s.dtype!==n.dtype)throw new Error("All tensors passed to tf.addN() must have the same dtype")}),t.forEach(s=>{if(!Xs(s.shape,n.shape))throw new Error("All tensors passed to tf.addN() must have the same shape")});let r=t;return U.runKernel(nv,r)}var X2=H({addN_:BM});function WM(e,t=null,n=!1){let s={x:P(e,"x","all","bool")},a={axis:t,keepDims:n};return U.runKernel(rv,s,a)}var VM=H({all_:WM});function UM(e,t=null,n=!1){let s={x:P(e,"x","any","bool")},a={axis:t,keepDims:n};return U.runKernel(sv,s,a)}var HM=H({any_:UM});function GM(e,t=0){let r={x:P(e,"x","argMax")},s={axis:t};return U.runKernel(av,r,s)}var Z2=H({argMax_:GM});function jM(e,t=0){let r={x:P(e,"x","argMin")},s={axis:t};return U.runKernel(ov,r,s)}var qM=H({argMin_:jM});function KM(e){let n={x:P(e,"x","asin")};return U.runKernel(iv,n)}var XM=H({asin_:KM});function ZM(e){let n={x:P(e,"x","asinh")};return U.runKernel(lv,n)}var YM=H({asinh_:ZM});function JM(e){let n={x:P(e,"x","atan")};return U.runKernel(uv,n)}var QM=H({atan_:JM});function eO(e,t){let n=P(e,"a","atan2"),r=P(t,"b","atan2");[n,r]=Vt(n,r);let s={a:n,b:r};return U.runKernel(dv,s)}var tO=H({atan2_:eO});function nO(e){let n={x:P(e,"x","atanh")};return U.runKernel(cv,n)}var rO=H({atanh_:nO});function sO(e,t,n,r,s="NHWC",a){let o=e[3],i=[...t,o],l=Lk(s);return oc(e,i,n,a,r,null,null,l)}function Pk(e,t,n,r,s,a,o="channelsLast"){let[i,l]=yp(t),u;if(o==="channelsLast")u=[i,l,e[3],e[3]];else if(o==="channelsFirst")u=[i,l,e[1],e[1]];else throw new Error(`Unknown dataFormat ${o}`);return oc(e,u,n,r,s,a,!1,o)}function aO(e,t,n,r,s,a,o="NDHWC"){let[i,l,u]=J2(t),c,d;if(o==="NDHWC")d="channelsLast",c=[i,l,u,e[4],e[4]];else if(o==="NCDHW")d="channelsFirst",c=[i,l,u,e[1],e[1]];else throw new Error(`Unknown dataFormat ${o}`);return zk(e,c,n,r,s,!1,d,a)}function oc(e,t,n,r,s,a,o=!1,i="channelsLast"){let[l,u,c,d]=[-1,-1,-1,-1];if(i==="channelsLast")[l,u,c,d]=e;else if(i==="channelsFirst")[l,d,u,c]=e;else throw new Error(`Unknown dataFormat ${i}`);let[h,p,,f]=t,[m,g]=yp(n),[y,A]=yp(r),x=Hi(h,y),b=Hi(p,A),{padInfo:v,outHeight:w,outWidth:I}=lO(s,u,c,m,g,x,b,a,i),T=o?f*d:f,C;return i==="channelsFirst"?C=[l,T,w,I]:i==="channelsLast"&&(C=[l,w,I,T]),{batchSize:l,dataFormat:i,inHeight:u,inWidth:c,inChannels:d,outHeight:w,outWidth:I,outChannels:T,padInfo:v,strideHeight:m,strideWidth:g,filterHeight:h,filterWidth:p,effectiveFilterHeight:x,effectiveFilterWidth:b,dilationHeight:y,dilationWidth:A,inShape:e,outShape:C,filterShape:t}}function zk(e,t,n,r,s,a=!1,o="channelsLast",i){let[l,u,c,d,h]=[-1,-1,-1,-1,-1];if(o==="channelsLast")[l,u,c,d,h]=e;else if(o==="channelsFirst")[l,h,u,c,d]=e;else throw new Error(`Unknown dataFormat ${o}`);let[p,f,m,,g]=t,[y,A,x]=J2(n),[b,v,w]=J2(r),I=Hi(p,b),T=Hi(f,v),C=Hi(m,w),{padInfo:M,outDepth:$,outHeight:R,outWidth:N}=uO(s,u,c,d,y,A,x,I,T,C,i),F=a?g*h:g,B;return o==="channelsFirst"?B=[l,F,$,R,N]:o==="channelsLast"&&(B=[l,$,R,N,F]),{batchSize:l,dataFormat:o,inDepth:u,inHeight:c,inWidth:d,inChannels:h,outDepth:$,outHeight:R,outWidth:N,outChannels:F,padInfo:M,strideDepth:y,strideHeight:A,strideWidth:x,filterDepth:p,filterHeight:f,filterWidth:m,effectiveFilterDepth:I,effectiveFilterHeight:T,effectiveFilterWidth:C,dilationDepth:b,dilationHeight:v,dilationWidth:w,inShape:e,outShape:B,filterShape:t}}function oO(e,t,n,r,s){r==null&&(r=Y2(e,t,n));let a=e[0],o=e[1],i=vo((a-t+2*r)/n+1,s),l=vo((o-t+2*r)/n+1,s);return[i,l]}function iO(e,t,n,r,s,a){s==null&&(s=Y2(e,t,r));let o=e[0],i=e[1],l=e[2],u=vo((o-t+2*s)/r+1,a),c=vo((i-t+2*s)/r+1,a),d=vo((l-t+2*s)/r+1,a);return[u,c,d,n]}function Y2(e,t,n,r=1){let s=Hi(t,r);return Math.floor((e[0]*(n-1)-n+s)/2)}function yp(e){return typeof e=="number"?[e,e,e]:e.length===2?[e[0],e[1],1]:e}function J2(e){return typeof e=="number"?[e,e,e]:e}function Hi(e,t){return t<=1?e:e+(e-1)*(t-1)}function lO(e,t,n,r,s,a,o,i,l){let u,c,d;if(typeof e=="number"){u={top:e,bottom:e,left:e,right:e,type:e===0?"VALID":"NUMBER"};let p=oO([t,n],a,r,e,i);c=p[0],d=p[1]}else if(e==="same"){c=Math.ceil(t/r),d=Math.ceil(n/s);let h=Math.max(0,(c-1)*r+a-t),p=Math.max(0,(d-1)*s+o-n),f=Math.floor(h/2),m=h-f,g=Math.floor(p/2),y=p-g;u={top:f,bottom:m,left:g,right:y,type:"SAME"}}else if(e==="valid")u={top:0,bottom:0,left:0,right:0,type:"VALID"},c=Math.ceil((t-a+1)/r),d=Math.ceil((n-o+1)/s);else if(typeof e=="object"){let h=l==="channelsLast"?e[1][0]:e[2][0],p=l==="channelsLast"?e[1][1]:e[2][1],f=l==="channelsLast"?e[2][0]:e[3][0],m=l==="channelsLast"?e[2][1]:e[3][1];u={top:h,bottom:p,left:f,right:m,type:h===0&&p===0&&f===0&&m===0?"VALID":"EXPLICIT"},c=vo((t-a+h+p)/r+1,i),d=vo((n-o+f+m)/s+1,i)}else throw Error(`Unknown padding parameter: ${e}`);return{padInfo:u,outHeight:c,outWidth:d}}function uO(e,t,n,r,s,a,o,i,l,u,c){let d,h,p,f;if(typeof e=="number"){d={top:e,bottom:e,left:e,right:e,front:e,back:e,type:e===0?"VALID":"NUMBER"};let g=iO([t,n,r,1],i,1,s,e,c);h=g[0],p=g[1],f=g[2]}else if(e==="same"){h=Math.ceil(t/s),p=Math.ceil(n/a),f=Math.ceil(r/o);let m=(h-1)*s+i-t,g=(p-1)*a+l-n,y=(f-1)*o+u-r,A=Math.floor(m/2),x=m-A,b=Math.floor(g/2),v=g-b,w=Math.floor(y/2),I=y-w;d={top:b,bottom:v,left:w,right:I,front:A,back:x,type:"SAME"}}else if(e==="valid")d={top:0,bottom:0,left:0,right:0,front:0,back:0,type:"VALID"},h=Math.ceil((t-i+1)/s),p=Math.ceil((n-l+1)/a),f=Math.ceil((r-u+1)/o);else throw Error(`Unknown padding parameter: ${e}`);return{padInfo:d,outDepth:h,outHeight:p,outWidth:f}}function vo(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 ic(e){let[t,n,r]=yp(e);return t===1&&n===1&&r===1}function Qs(e,t){return ic(e)||ic(t)}function Lk(e){if(e==="NHWC")return"channelsLast";if(e==="NCHW")return"channelsFirst";throw new Error(`Unknown dataFormat ${e}`)}function cO(e,t){let r={x:P(e,"x","reshape","string_or_numeric")},s={shape:t};return U.runKernel(Gw,r,s)}var ue=H({reshape_:cO});function dO(e,t,n,r,s){let a=P(e,"x","avgPool","float32"),o=1;L(Qs(n,o),()=>`Error in avgPool: Either strides or dilations must be 1. Got strides ${n} and dilations '${o}'`);let i=a,l=!1;a.rank===3&&(l=!0,i=ue(a,[1,a.shape[0],a.shape[1],a.shape[2]])),L(i.rank===4,()=>`Error in avgPool: x must be rank 4 but got rank ${i.rank}.`),s!=null&&L(Xn(r),()=>`Error in avgPool: pad must be an integer when using, dimRoundingMode ${s} but got pad ${r}.`);let u={x:i},c={filterSize:t,strides:n,pad:r,dimRoundingMode:s},d=U.runKernel(hv,u,c);return d=Pt(d,a.dtype),l?ue(d,[d.shape[1],d.shape[2],d.shape[3]]):d}var Bk=H({avgPool_:dO});function hO(e,t,n,r,s,a="NDHWC"){let o=P(e,"x","avgPool3d","float32"),i=o,l=!1;o.rank===4&&(l=!0,i=ue(o,[1,o.shape[0],o.shape[1],o.shape[2],o.shape[3]])),L(i.rank===5,()=>`Error in avgPool3d: x must be rank 5 but got rank ${i.rank}.`),L(a==="NDHWC",()=>`Error in avgPool3d: Only NDHWC is currently supported, but got dataFormat of ${a}`),s!=null&&L(Xn(r),()=>`Error in avgPool3d: pad must be an integer when using, dimRoundingMode ${s} but got pad ${r}.`);let u={x:i},c={filterSize:t,strides:n,pad:r,dimRoundingMode:s,dataFormat:a},d=U.runKernel(pv,u,c);return d=Pt(d,i.dtype),l?ue(d,[d.shape[1],d.shape[2],d.shape[3],d.shape[4]]):d}var pO=H({avgPool3d_:hO});function fO(e,t=0){L(e.length>=1,()=>"Pass at least one tensor to concat");let n=sc(e,"tensors","concat","string_or_numeric");if(n[0].dtype==="complex64"&&n.forEach(a=>{if(a.dtype!=="complex64")throw new Error(`Cannot concatenate complex64 tensors with a tensor
|
|
with dtype ${a.dtype}. `)}),n.length===1)return Js(n[0]);let r=n,s={axis:t};return U.runKernel(vv,r,s)}var an=H({concat_:fO});function mO(e){let n={x:P(e,"x","sigmoid")};return U.runKernel(a7,n)}var Ts=H({sigmoid_:mO});function gO(e,t,n){let r=P(e,"x","slice","string_or_numeric");if(r.rank===0)throw new Error("Slicing scalar is not possible");let s={x:r},a={begin:t,size:n};return U.runKernel(t7,s,a)}var Ze=H({slice_:gO});function yO(e){let n={x:P(e,"x","tanh")};return U.runKernel(I7,n)}var Q2=H({tanh_:yO});function AO(e,t,n,r,s,a){let o=P(e,"forgetBias","basicLSTMCell"),i=P(t,"lstmKernel","basicLSTMCell"),l=P(n,"lstmBias","basicLSTMCell"),u=P(r,"data","basicLSTMCell"),c=P(s,"c","basicLSTMCell"),d=P(a,"h","basicLSTMCell"),h=an([u,d],1),p=yt(h,i),f=Me(p,l),m=f.shape[0],g=f.shape[1]/4,y=[m,g],A=Ze(f,[0,0],y),x=Ze(f,[0,g],y),b=Ze(f,[0,g*2],y),v=Ze(f,[0,g*3],y),w=Me(fe(Ts(A),Q2(x)),fe(c,Ts(Me(o,b)))),I=fe(Q2(w),Ts(v));return[w,I]}var xO=H({basicLSTMCell_:AO});function bO(e,t,n){let r=P(e,"x","batchToSpaceND"),s=t.reduce((i,l)=>i*l);L(r.rank>=1+t.length,()=>`input rank is ${r.rank} but should be > than blockShape.length ${t.length}`),L(n.length===t.length,()=>`crops.length is ${n.length} but should be equal to blockShape.length ${t.length}`),L(r.shape[0]%s==0,()=>`input tensor batch is ${r.shape[0]} but is not divisible by the product of the elements of blockShape ${t.join(" * ")} === ${s}`);let a={x:r},o={blockShape:t,crops:n};return U.runKernel(mv,a,o)}var Wk=H({batchToSpaceND_:bO});function vO(e){let t;return e.rank===0||e.rank===1?t=ue(e,[1,1,1,e.size]):e.rank===2?t=ue(e,[1,1,e.shape[0],e.shape[1]]):e.rank===3?t=ue(e,[1,e.shape[0],e.shape[1],e.shape[2]]):t=e,t}function wO(e,t,n,r,s,a){a==null&&(a=.001);let o=P(e,"x","batchNorm"),i=P(t,"mean","batchNorm"),l=P(n,"variance","batchNorm"),u;s!=null&&(u=P(s,"scale","batchNorm"));let c;r!=null&&(c=P(r,"offset","batchNorm")),L(i.rank===l.rank,()=>"Batch normalization gradient requires mean and variance to have equal ranks."),L(c==null||i.rank===c.rank,()=>"Batch normalization gradient requires mean and offset to have equal ranks."),L(u==null||i.rank===u.rank,()=>"Batch normalization gradient requires mean and scale to have equal ranks.");let h={x:vO(o),scale:u,offset:c,mean:i,variance:l},p={varianceEpsilon:a},f=U.runKernel(Yv,h,p);return ue(f,o.shape)}var Ap=H({batchNorm_:wO});function kO(e,t,n,r,s,a){let o=P(e,"x","batchNorm"),i=P(t,"mean","batchNorm"),l=P(n,"variance","batchNorm"),u;s!=null&&(u=P(s,"scale","batchNorm"));let c;return r!=null&&(c=P(r,"offset","batchNorm")),L(o.rank===2,()=>`Error in batchNorm2D: x must be rank 2 but got rank ${o.rank}.`),L(i.rank===2||i.rank===1,()=>`Error in batchNorm2D: mean must be rank 2 or rank 1 but got rank ${i.rank}.`),L(l.rank===2||l.rank===1,()=>`Error in batchNorm2D: variance must be rank 2 or rank 1 but got rank ${l.rank}.`),u!=null&&L(u.rank===2||u.rank===1,()=>`Error in batchNorm2D: scale must be rank 2 or rank 1 but got rank ${u.rank}.`),c!=null&&L(c.rank===2||c.rank===1,()=>`Error in batchNorm2D: offset must be rank 2 or rank 1 but got rank ${c.rank}.`),Ap(o,i,l,c,u,a)}var IO=H({batchNorm2d_:kO});function SO(e,t,n,r,s,a){let o=P(e,"x","batchNorm"),i=P(t,"mean","batchNorm"),l=P(n,"variance","batchNorm"),u;s!=null&&(u=P(s,"scale","batchNorm"));let c;return r!=null&&(c=P(r,"offset","batchNorm")),L(o.rank===3,()=>`Error in batchNorm3D: x must be rank 3 but got rank ${o.rank}.`),L(i.rank===3||i.rank===1,()=>`Error in batchNorm3D: mean must be rank 3 or rank 1 but got rank ${i.rank}.`),L(l.rank===3||l.rank===1,()=>`Error in batchNorm3D: variance must be rank 3 or rank 1 but got rank ${l.rank}.`),u!=null&&L(u.rank===3||u.rank===1,()=>`Error in batchNorm3D: scale must be rank 3 or rank 1 but got rank ${u.rank}.`),c!=null&&L(c.rank===3||c.rank===1,()=>`Error in batchNorm3D: offset must be rank 3 or rank 1 but got rank ${c.rank}.`),Ap(o,i,l,c,u,a)}var TO=H({batchNorm3d_:SO});function NO(e,t,n,r,s,a){let o=P(e,"x","batchNorm"),i=P(t,"mean","batchNorm"),l=P(n,"variance","batchNorm"),u;s!=null&&(u=P(s,"scale","batchNorm"));let c;return r!=null&&(c=P(r,"offset","batchNorm")),L(o.rank===4,()=>`Error in batchNorm4D: x must be rank 4 but got rank ${o.rank}.`),L(i.rank===4||i.rank===1,()=>`Error in batchNorm4D: mean must be rank 4 or rank 1 but got rank ${i.rank}.`),L(l.rank===4||l.rank===1,()=>`Error in batchNorm4D: variance must be rank 4 or rank 1 but got rank ${l.rank}.`),u!=null&&L(u.rank===4||u.rank===1,()=>`Error in batchNorm4D: scale must be rank 4 or rank 1 but got rank ${u.rank}.`),c!=null&&L(c.rank===4||c.rank===1,()=>`Error in batchNorm4D: offset must be rank 4 or rank 1 but got rank ${c.rank}.`),Ap(o,i,l,c,u,a)}var CO=H({batchNorm4d_:NO});function EO(e,t,n){let r=P(e,"x","bincount"),s=P(t,"weights","bincount");L(r.dtype==="int32",()=>`Error in bincount: input dtype must be int32, but got ${r.dtype}`),L(n>=0,()=>`size must be non-negative, but got ${n}.`),L(s.size===r.size||s.size===0,()=>`Error in bincount: weights must have the same size as input or0-length, but got input shape: ${r.shape}, weights shape: ${s.shape}.`);let a={x:r,weights:s},o={size:n};return U.runKernel(gv,a,o)}var Vk=H({bincount_:EO});function $O(e,t){let n=P(e,"broadcastTo","x"),r=n.shape;if(t.some(u=>!(u>0)||u%1!=0))throw new Error(`broadcastTo(): Invalid broadcast shape [${t}].`);if(t.length<n.rank)throw new Error(`broadcastTo(): shape.length=${t.length} < input.rank=${n.rank}.`);if(t.length>n.rank){let u=n.shape.slice();for(;u.length<t.length;)u.unshift(1);n=ue(n,u)}let s=n.shape,a=Array.from(t);for(let u=t.length-1;u>=0;u--)if(s[u]===t[u])a[u]=1;else if(n.shape[u]!==1)throw new Error(`broadcastTo(): [${r}] cannot be broadcast to [${t}].`);if(a.map((u,c)=>u>1?c:-1).filter(u=>u>=0).length===0)return Js(n);let i={x:n},l={reps:a};return U.runKernel(c2,i,l)}var xp=H({broadcastTo_:$O});function _O(e){let n={x:P(e,"x","ceil")};return U.runKernel(yv,n)}var RO=H({ceil_:_O});function DO(e,t,n){let r=P(e,"x","clipByValue");L(t<=n,()=>`Error in clip: min (${t}) must be less than or equal to max (${n}).`);let s={x:r},a={clipValueMin:t,clipValueMax:n};return U.runKernel(Av,s,a)}var FO=H({clipByValue_:DO});function MO(e){return an(e,0)}var OO=H({concat1d_:MO});function PO(e,t){return an(e,t)}var lc=H({concat2d_:PO});function zO(e,t){return an(e,t)}var LO=H({concat3d_:zO});function BO(e,t){return an(e,t)}var WO=H({concat4d_:BO});function VO(e,t,n,r,s="NHWC",a=[1,1],o){let i=P(e,"x","conv2d"),l=P(t,"filter","conv2d"),u=i,c=!1;i.rank===3&&(c=!0,u=ue(i,[1,i.shape[0],i.shape[1],i.shape[2]])),L(u.rank===4,()=>`Error in conv2d: input must be rank 4, but got rank ${u.rank}.`),L(l.rank===4,()=>`Error in conv2d: filter must be rank 4, but got rank ${l.rank}.`),o!=null&&L(Xn(r),()=>`Error in conv2d: pad must be an integer when using, dimRoundingMode ${o} but got pad ${r}.`);let d=s==="NHWC"?u.shape[3]:u.shape[1];L(d===l.shape[2],()=>`Error in conv2d: depth of input (${d}) must match input depth for filter ${l.shape[2]}.`),L(Qs(n,a),()=>`Error in conv2D: Either strides or dilations must be 1. Got strides ${n} and dilations '${a}'`);let h={x:u,filter:l},p={strides:n,pad:r,dataFormat:s,dilations:a,dimRoundingMode:o},f=U.runKernel(wv,h,p);return c?ue(f,[f.shape[1],f.shape[2],f.shape[3]]):f}var bp=H({conv2d_:VO});function UO(e,t,n,r,s="NWC",a=1,o){let i=P(e,"x","conv1d"),l=P(t,"filter","conv1d"),u=i,c=!1;i.rank===2&&(c=!0,u=ue(i,[1,i.shape[0],i.shape[1]])),L(u.rank===3,()=>`Error in conv1d: input must be rank 3, but got rank ${u.rank}.`),L(l.rank===3,()=>`Error in conv1d: filter must be rank 3, but got rank ${l.rank}.`),o!=null&&L(Xn(r),()=>`Error in conv1d: pad must be an integer when using, dimRoundingMode ${o} but got pad ${r}.`),L(u.shape[2]===l.shape[1],()=>`Error in conv1d: depth of input (${u.shape[2]}) must match input depth for filter ${l.shape[1]}.`),L(Qs(n,a),()=>`Error in conv1D: Either stride or dilation must be 1. Got stride ${n} and dilation '${a}'`),L(s==="NWC",()=>`Error in conv1d: got dataFormat of ${s} but only NWC is currently supported.`);let d=ue(l,[1,l.shape[0],l.shape[1],l.shape[2]]),h=ue(u,[u.shape[0],1,u.shape[1],u.shape[2]]),g=bp(h,d,[1,n],r,"NHWC",[1,a],o);return c?ue(g,[g.shape[2],g.shape[3]]):ue(g,[g.shape[0],g.shape[2],g.shape[3]])}var HO=H({conv1d_:UO});function GO(e,t,n,r,s,a="NHWC",o){L(e.length===t.rank,()=>`Length of inShape (${e.length}) and rank of dy (${t.rank}) must match`);let i=e,l=t,u=!1;t.rank===3&&(u=!0,l=ue(t,[1,t.shape[0],t.shape[1],t.shape[2]]),i=[1,e[0],e[1],e[2]]),L(i.length===4,()=>`Error in conv2dDerInput: inShape must be length 4, but got length ${i.length}.`),L(l.rank===4,()=>`Error in conv2dDerInput: dy must be rank 4, but got rank ${l.rank}`),L(n.rank===4,()=>`Error in conv2dDerInput: filter must be rank 4, but got rank ${n.rank}`);let c=a==="NHWC"?i[3]:i[1],d=a==="NHWC"?l.shape[3]:l.shape[1];L(c===n.shape[2],()=>`Error in conv2dDerInput: depth of input (${c}) must match input depth for filter ${n.shape[2]}.`),L(d===n.shape[3],()=>`Error in conv2dDerInput: depth of output (${d}) must match output depth for filter ${n.shape[3]}.`),o!=null&&L(Xn(s),()=>`Error in conv2dDerInput: pad must be an integer when using, dimRoundingMode ${o} but got pad ${s}.`);let h={dy:l,filter:n},p={strides:r,pad:s,dataFormat:a,dimRoundingMode:o,inputShape:i},f=U.runKernel(Iv,h,p);return u?ue(f,[f.shape[1],f.shape[2],f.shape[3]]):f}var Uk=H({conv2DBackpropInput_:GO});function jO(e,t,n,r,s,a){let o=P(e,"x","conv2dTranspose"),i=P(t,"filter","conv2dTranspose");return Uk(n,o,i,r,s,"NHWC",a)}var qO=H({conv2dTranspose_:jO});function KO(e,t,n,r,s="NDHWC",a=[1,1,1]){let o=P(e,"x","conv3d"),i=P(t,"filter","conv3d"),l=o,u=!1;o.rank===4&&(u=!0,l=ue(o,[1,o.shape[0],o.shape[1],o.shape[2],o.shape[3]])),L(l.rank===5,()=>`Error in conv3d: input must be rank 5, but got rank ${l.rank}.`),L(i.rank===5,()=>`Error in conv3d: filter must be rank 5, but got rank ${i.rank}.`),L(l.shape[4]===i.shape[3],()=>`Error in conv3d: depth of input (${l.shape[4]}) must match input depth for filter ${i.shape[3]}.`),L(Qs(n,a),()=>`Error in conv3D: Either strides or dilations must be 1. Got strides ${n} and dilations '${a}'`),L(s==="NDHWC",()=>`Error in conv3d: got dataFormat of ${s} but only NDHWC is currently supported.`);let c={x:l,filter:i},d={strides:n,pad:r,dataFormat:s,dilations:a},h=U.runKernel(Sv,c,d);return u?ue(h,[h.shape[1],h.shape[2],h.shape[3],h.shape[4]]):h}var XO=H({conv3d_:KO});function ZO(e,t,n,r,s){L(e.length===t.rank,()=>`Length of inShape (${e.length}) and rank of dy (${t.rank}) must match`);let a=e,o=t,i=!1;t.rank===4&&(i=!0,o=ue(t,[1,t.shape[0],t.shape[1],t.shape[2],t.shape[3]]),a=[1,e[0],e[1],e[2],e[3]]);let l=a[4],u=o.shape[4];L(a.length===5,()=>`Error in conv3dDerInput: inShape must be length 5, but got length ${a.length}.`),L(o.rank===5,()=>`Error in conv3dDerInput: dy must be rank 5, but got rank ${o.rank}`),L(n.rank===5,()=>`Error in conv3dDerInput: filter must be rank 5, but got rank ${n.rank}`),L(l===n.shape[3],()=>`Error in conv3dDerInput: depth of input (${l}) must match input depth for filter ${n.shape[3]}.`),L(u===n.shape[4],()=>`Error in conv3dDerInput: depth of output (${u}) must match output depth for filter ${n.shape[4]}.`);let c={dy:o,filter:n},d={pad:s,strides:r,inputShape:a},h=U.runKernel(Tv,c,d);return i?ue(h,[h.shape[1],h.shape[2],h.shape[3],h.shape[4]]):h}var YO=H({conv3DBackpropInput_:ZO});function JO(e,t,n,r,s){let a=P(e,"x","conv3dTranspose"),o=P(t,"filter","conv3dTranspose");return YO(n,a,o,r,s)}var QO=H({conv3dTranspose_:JO});function eP(e){let n={x:P(e,"x","cos")};return U.runKernel(Nv,n)}var tP=H({cos_:eP});function nP(e){let n={x:P(e,"x","cosh")};return U.runKernel(Cv,n)}var rP=H({cosh_:nP});function sP(e,t=0,n=!1,r=!1){let a={x:P(e,"x","cumsum")},o={axis:t,exclusive:n,reverse:r};return U.runKernel(Ev,a,o)}var aP=H({cumsum_:sP});function oP(e,t,n,r=!1){let s=P(e,"x","denseBincount"),a=P(t,"weights","denseBincount");L(s.dtype==="int32",()=>`Error in denseBincount: input dtype must be int32, but got ${s.dtype}`),L(s.rank<=2,()=>`Error in denseBincount: input must be at most rank 2, but got rank ${s.rank}.`),L(n>=0,()=>`size must be non-negative, but got ${n}.`),L(a.size===s.size||a.size===0,()=>`Error in denseBincount: weights must have the same shape as x or 0-length, but got x shape: ${s.shape}, weights shape: ${a.shape}.`);let o={x:s,weights:a},i={size:n,binaryOutput:r};return U.runKernel(_v,o,i)}var iP=H({denseBincount_:oP});function lP(e,t,n="NHWC"){let r=P(e,"x","depthToSpace"),s=n==="NHWC"?r.shape[1]:r.shape[2],a=n==="NHWC"?r.shape[2]:r.shape[3],o=n==="NHWC"?r.shape[3]:r.shape[1];L(s*t>=0,()=>`Negative dimension size caused by overflow when multiplying
|
|
${s} and ${t} for depthToSpace with input shape
|
|
${r.shape}`),L(a*t>=0,()=>`Negative dimension size caused by overflow when multiplying
|
|
${a} and ${t} for depthToSpace with input shape
|
|
${r.shape}`),L(o%(t*t)==0,()=>`Dimension size must be evenly divisible by ${t*t} but is ${o} for depthToSpace with input shape ${r.shape}`);let i={x:r},l={blockSize:t,dataFormat:n};return U.runKernel(Rv,i,l)}var uP=H({depthToSpace_:lP});function cP(e,t,n,r,s="NHWC",a=[1,1],o){let i=P(e,"x","depthwiseConv2d"),l=P(t,"filter","depthwiseConv2d"),u=i,c=!1;i.rank===3&&(c=!0,u=ue(i,[1,i.shape[0],i.shape[1],i.shape[2]])),L(u.rank===4,()=>`Error in depthwiseConv2d: input must be rank 4, but got rank ${u.rank}.`),L(l.rank===4,()=>`Error in depthwiseConv2d: filter must be rank 4, but got rank ${l.rank}.`),L(u.shape[3]===l.shape[2],()=>`Error in depthwiseConv2d: number of input channels (${u.shape[3]}) must match the inChannels dimension in filter ${l.shape[2]}.`),o!=null&&L(Xn(r),()=>`Error in depthwiseConv2d: pad must be an integer when using, dimRoundingMode ${o} but got pad ${r}.`);let d={x:u,filter:l},h={strides:n,pad:r,dataFormat:s,dilations:a,dimRoundingMode:o},p=U.runKernel(Dv,d,h);return c?ue(p,[p.shape[1],p.shape[2],p.shape[3]]):p}var ey=H({depthwiseConv2d_:cP});function dP(e){let n={x:P(e,"x","diag")};return U.runKernel(Ov,n)}var hP=H({diag_:dP});function pP(e,t,n,r,s=[1,1],a="NHWC"){let o=P(e,"x","dilation2d"),i=P(t,"filter","dilation2d");L(o.rank===3||o.rank===4,()=>`Error in dilation2d: input must be rank 3 or 4, but got rank ${o.rank}.`),L(i.rank===3,()=>`Error in dilation2d: filter must be rank 3, but got rank ${i.rank}.`),L(a==="NHWC",()=>`Error in dilation2d: Only NHWC is currently supported, but got dataFormat of ${a}`);let l=o,u=!1;o.rank===3&&(l=ue(o,[1,o.shape[0],o.shape[1],o.shape[2]]),u=!0);let c={x:l,filter:i},d={strides:n,pad:r,dilations:s},h=U.runKernel(Pv,c,d);return u?ue(h,[h.shape[1],h.shape[2],h.shape[3]]):h}var fP=H({dilation2d_:pP});function mP(e,t){let n=e.length,r=[];for(let s=0;s<n;s++){let a=n-1-s,o=e[a]||1;(t[t.length-1-s]||1)>1&&o===1&&r.unshift(a)}return r}function Hk(e,t){let n=[];for(let r=0;r<t.length;r++){let s=e[e.length-r-1],a=t.length-r-1,o=t[a];(s==null||s===1&&o>1)&&n.unshift(a)}return n}function In(e,t){let n=[],r=Math.max(e.length,t.length);for(let s=0;s<r;s++){let a=e[e.length-s-1];a==null&&(a=1);let o=t[t.length-s-1];if(o==null&&(o=1),a===1)n.unshift(o);else if(o===1)n.unshift(a);else if(a!==o){let i=`Operands could not be broadcast together with shapes ${e} and ${t}.`;throw Error(i)}else n.unshift(a)}return n}function gP(e,t){let n=P(e,"a","equal","string_or_numeric"),r=P(t,"b","equal","string_or_numeric");[n,r]=Vt(n,r),In(n.shape,r.shape);let s={a:n,b:r};return U.runKernel(Vv,s)}var Gk=H({equal_:gP});function yP(e,t,n){let r=P(t,"a","where"),s=P(n,"b","where"),a=P(e,"condition","where","bool"),o=In(In(a.shape,r.shape),s.shape),i=xp(a,o),l=xp(r,o),u=xp(s,o),c={condition:i,t:l,e:u};return U.runKernel(Qw,c)}var Gi=H({where_:yP});function AP(e){let n={x:P(e,"x","zerosLike")};return U.runKernel(_7,n)}var Cr=H({zerosLike_:AP});function xP(e,t){let n=P(e,"a","div"),r=P(t,"b","div");[n,r]=Vt(n,r);let s=Qe(n,r),a=Cr(s),o=Gk(r,a);return Gi(o,a,s)}var bP=H({divNoNan_:xP});function vP(e,t){let n=P(e,"t1","dot"),r=P(t,"t2","dot");L((n.rank===1||n.rank===2)&&(r.rank===1||r.rank===2),()=>`Error in dot: inputs must all be rank 1 or 2, but got ranks ${n.rank} and ${r.rank}.`);let s=n.rank===1?n.size:n.shape[1],a=r.rank===1?r.size:r.shape[0];if(L(s===a,()=>`Error in dot: inner dimensions of inputs must match, but got ${s} and ${a}.`),n.rank===1&&r.rank===1){let o=ue(n,[1,-1]),i=ue(r,[-1,1]),l=yt(o,i);return ue(l,[])}else if(n.rank===1&&r.rank===2){let o=ue(n,[1,-1]),i=ue(r,[r.shape[0],r.shape[1]]),l=yt(o,i);return ue(l,[l.size])}else if(n.rank===2&&r.rank===1){let o=ue(r,[-1,1]),i=yt(n,o);return ue(i,[i.size])}else{let o=ue(r,[r.shape[0],r.shape[1]]);return yt(n,o)}}var wP=H({dot_:vP});function kP(e,...t){let n=t.map((s,a)=>P(s,`tensors${a}`,"einsum")),r={equation:e};return U.runKernel(Lv,n,r)}var IP=H({einsum_:kP});function SP(e){let n={x:P(e,"x","elu")};return U.runKernel(Bv,n)}var jk=H({elu_:SP});function TP(e){let t=P(e,"x","erf");L(t.dtype==="int32"||t.dtype==="float32",()=>"Input dtype must be `int32` or `float32`."),t.dtype==="int32"&&(t=Pt(t,"float32"));let n={x:t};return U.runKernel(Wv,n)}var NP=H({erf_:TP});function CP(e){let n={x:P(e,"x","exp")};return U.runKernel(Uv,n)}var wo=H({exp_:CP});function EP(e,t=0){let n=P(e,"x","expandDims","string_or_numeric");L(t<=n.rank,()=>"Axis must be <= rank of the tensor");let r={input:n},s={dim:t};return U.runKernel(Hv,r,s)}var ea=H({expandDims_:EP});function $P(e){let n={x:P(e,"x","expm1")};return U.runKernel(Gv,n)}var _P=H({expm1_:$P});function RP(e,t){let n=P(e,"x","tile","string_or_numeric");L(n.rank===t.length,()=>`Error in transpose: rank of input ${n.rank} must match length of reps ${t}.`);let r={x:n},s={reps:t};return U.runKernel(c2,r,s)}var vp=H({tile_:RP});function DP(e,t,n,r="float32"){t==null&&(t=e);let s=Ys([e,t],r),a=e<=t?e:t;for(let i=0;i<a;++i)s.set(1,i,i);let o=ue(s.toTensor(),[e,t]);if(n==null)return o;if(n.length===1)return vp(ea(o,0),[n[0],1,1]);if(n.length===2)return vp(ea(ea(o,0),0),[n[0],n[1],1,1]);if(n.length===3)return vp(ea(ea(ea(o,0),0),0),[n[0],n[1],n[2],1,1]);throw new Error(`eye() currently supports only 1D and 2D batchShapes, but received ${n.length}D.`)}var qk=H({eye_:DP});function wp(e,t,n){let r={shape:e,value:t,dtype:n};return U.runKernel(qv,{},r)}function FP(e){let n={x:P(e,"x","floor")};return U.runKernel(Xv,n)}var Kk=H({floor_:FP});function MP(e,t,n=0,r=0){let s=P(e,"x","gather"),a=P(t,"indices","gather","int32"),o={x:s,indices:a},i={axis:n,batchDims:r};return U.runKernel(Jv,o,i)}var Xk=H({gather_:MP});function OP(e,t){let n=P(e,"a","greater","string_or_numeric"),r=P(t,"b","greater","string_or_numeric");[n,r]=Vt(n,r),In(n.shape,r.shape);let s={a:n,b:r};return U.runKernel(ew,s)}var kp=H({greater_:OP});function PP(e,t){let n=P(e,"a","greaterEqual","string_or_numeric"),r=P(t,"b","greaterEqual","string_or_numeric");[n,r]=Vt(n,r),In(n.shape,r.shape);let s={a:n,b:r};return U.runKernel(tw,s)}var Zk=H({greaterEqual_:PP});function zP(e){let n={input:P(e,"input","imag")};return U.runKernel(rw,n)}var ty=H({imag_:zP});function LP(e){let n={x:P(e,"x","isFinite")};return U.runKernel(sw,n)}var BP=H({isFinite_:LP});function WP(e){let n={x:P(e,"x","isInf")};return U.runKernel(aw,n)}var VP=H({isInf_:WP});function UP(e){let n={x:P(e,"x","isNaN")};return U.runKernel(ow,n)}var HP=H({isNaN_:UP});function GP(e,t=.2){let r={x:P(e,"x","leakyRelu")},s={alpha:t};return U.runKernel(iw,r,s)}var Yk=H({leakyRelu_:GP});function jP(e,t){let n=P(e,"a","less","string_or_numeric"),r=P(t,"b","less","string_or_numeric");[n,r]=Vt(n,r),In(n.shape,r.shape);let s={a:n,b:r};return U.runKernel(lw,s)}var qP=H({less_:jP});function KP(e,t){let n=P(e,"a","lessEqual","string_or_numeric"),r=P(t,"b","lessEqual","string_or_numeric");[n,r]=Vt(n,r),In(n.shape,r.shape);let s={a:n,b:r};return U.runKernel(uw,s)}var ny=H({lessEqual_:KP});function XP(e,t,n){if(n<=0)throw new Error("The number of values should be positive.");let r={start:e,stop:t,num:n};return U.runKernel(cw,{},r)}function ZP(e,t=5,n=1,r=1,s=.5){let a=P(e,"x","localResponseNormalization");L(a.rank===4||a.rank===3,()=>`Error in localResponseNormalization: x must be rank 3 or 4 but got
|
|
rank ${a.rank}.`),L(Xn(t),()=>`Error in localResponseNormalization: depthRadius must be an integer but got depthRadius ${t}.`);let o=a,i=!1;a.rank===3&&(i=!0,o=ue(a,[1,a.shape[0],a.shape[1],a.shape[2]]));let l={x:o},u={depthRadius:t,bias:n,alpha:r,beta:s},c=U.runKernel(gw,l,u);return i?ue(c,[c.shape[1],c.shape[2],c.shape[3]]):c}var YP=H({localResponseNormalization_:ZP});function JP(e){let n={x:P(e,"x","log")};return U.runKernel(dw,n)}var uc=H({log_:JP});function QP(e){let n={x:P(e,"x","log1p")};return U.runKernel(hw,n)}var Jk=H({log1p_:QP});function ez(e){return L(Sa(e),()=>"The f passed in grad(f) must be a function"),(t,n)=>{let r=P(t,"x","tf.grad","string_or_numeric"),s=n!=null?P(n,"dy","tf.grad"):null;return U.tidy(()=>{let{value:a,grads:o}=U.gradients(()=>e(r),[r],s);return s!=null&&Mn(a.shape,s.shape,"The shape of dy passed in grad(f)(x, dy) must match the shape returned by f(x)"),Ip(o),o[0]})}}function tz(e){return L(Sa(e),()=>"The f passed in grads(f) must be a function"),(t,n)=>{L(Array.isArray(t),()=>"The args passed in grads(f)(args) must be an array of `Tensor`s or `TensorLike`s");let r=sc(t,"args","tf.grads","string_or_numeric"),s=n!=null?P(n,"dy","tf.grads"):null;return U.tidy(()=>{let{value:a,grads:o}=U.gradients(()=>e(...r),r,s);return s!=null&&Mn(a.shape,s.shape,"The shape of dy passed in grads(f)([x1,...], dy) must match the shape returned by f([x1,...])"),Ip(o),o})}}function nz(e){return L(Sa(e),()=>"The f passed in valueAndGrad(f) must be a function"),(t,n)=>{L(t instanceof Tt,()=>"The x passed in valueAndGrad(f)(x) must be a tensor"),L(n==null||n instanceof Tt,()=>"The dy passed in valueAndGrad(f)(x, dy) must be a tensor");let{grads:r,value:s}=U.gradients(()=>e(t),[t],n);return Ip(r),{grad:r[0],value:s}}}function rz(e){return L(Sa(e),()=>"The f passed in valueAndGrads(f) must be a function"),(t,n)=>{L(Array.isArray(t)&&t.every(s=>s instanceof Tt),()=>"The args passed in valueAndGrads(f)(args) must be array of tensors"),L(n==null||n instanceof Tt,()=>"The dy passed in valueAndGrads(f)(args, dy) must be a tensor");let r=U.gradients(()=>e(...t),t,n);return n!=null&&Mn(r.value.shape,n.shape,"The shape of dy passed in valueAndGrads(f)([x1,...], dy) must match the shape returned by f([x1,...])"),Ip(r.grads),r}}function Qk(e,t){L(Sa(e),()=>"The f passed in variableGrads(f) must be a function"),L(t==null||Array.isArray(t)&&t.every(u=>u instanceof rc),()=>"The varList passed in variableGrads(f, varList) must be an array of variables");let n=t!=null;if(!n){t=[];for(let u in U.registeredVariables)t.push(U.registeredVariables[u])}let r=n?t.filter(u=>!u.trainable):null,s=t.length;t=t.filter(u=>u.trainable),L(t.length>0,()=>`variableGrads() expects at least one of the input variables to be trainable, but none of the ${s} variables is trainable.`);let a=!0,{value:o,grads:i}=U.gradients(e,t,null,a);L(i.some(u=>u!=null),()=>"Cannot find a connection between any variable and the result of the loss function y=f(x). Please make sure the operations that use variables are inside the function f passed to minimize()."),L(o.rank===0,()=>`The f passed in variableGrads(f) must return a scalar, but it returned a rank-${o.rank} tensor`);let l={};return t.forEach((u,c)=>{i[c]!=null&&(l[u.name]=i[c])}),r!=null&&r.forEach(u=>l[u.name]=null),{value:o,grads:l}}function Ns(e){return U.customGrad(e)}function Ip(e){if(e.filter(n=>n==null).length>0)throw new Error(`Cannot compute gradient of y=f(x) with respect to x. Make sure that
|
|
the f you passed encloses all operations that lead from x to y.`)}function sz(e){let n={x:P(e,"x","neg")};return U.runKernel(Ew,n)}var $a=H({neg_:sz});function az(e){let n={x:P(e,"x","softplus")};return U.runKernel(o7,n)}var e4=H({softplus_:az});function oz(e){let t=P(e,"x","logSigmoid");return Ns(r=>({value:$a(e4($a(r))),gradFunc:o=>fe(o,Ts($a(r)))}))(t)}var iz=H({logSigmoid_:oz});function lz(e,t=null,n=!1){let s={x:P(e,"x","max")},a={reductionIndices:t,keepDims:n};return U.runKernel(yw,s,a)}var _a=H({max_:lz});function uz(e,t){let n=P(e,"a","sub"),r=P(t,"b","sub");[n,r]=Vt(n,r);let s={a:n,b:r};return U.runKernel(w7,s)}var He=H({sub_:uz});function cz(e,t=null,n=!1){let r=P(e,"x","sum");r.dtype==="bool"&&(r=Pt(r,"int32"));let s={x:r},a={axis:t,keepDims:n};return U.runKernel(l7,s,a)}var _t=H({sum_:cz});function dz(e,t=-1){let n=P(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 Ns((s,a)=>{let o=!0,i=_a(s,t,!0),l=He(s,i),u=He(Pt(l,"float32"),uc(_t(wo(l),t,o)));return a([u]),{value:u,gradFunc:(d,h)=>{let[p]=h,f=!0,m=wo(p);return He(d,fe(_t(d,t,f),m))}}})(n)}var hz=H({logSoftmax_:dz});function ry(e,t){for(let n=0;n<e.length;++n)if(e[e.length-n-1]!==t-1-n)return!1;return!0}function t4(e,t,n){let r=e.length+t.length,s=[],a=0,o=0;for(let i=0;i<r;i++)n.indexOf(i)===-1?s.push(e[a++]):s.push(t[o++]);return s}function pz(e,t){let n=[],r=e.length;for(let a=0;a<r;a++)t.indexOf(a)===-1&&n.push(e[a]);let s=t.map(a=>e[a]);return[n,s]}function cc(e,t){let n=t.map(r=>1);return t4(e,n,t)}function fz(e,t,n){L(ry(t,n),()=>`${e} supports only inner-most axes for now. Got axes ${t} and rank-${n} input.`)}function mz(e,t){if(ry(e,t))return null;let n=[];for(let r=0;r<t;++r)e.indexOf(r)===-1&&n.push(r);return e.forEach(r=>n.push(r)),n}function gz(e){return e.map((t,n)=>[n,t]).sort((t,n)=>t[1]-n[1]).map(t=>t[0])}function yz(e,t){let n=[];for(let r=t-e;r<t;++r)n.push(r);return n}function Az(e,t=null,n=!1){let r=P(e,"x","logSumExp"),s=Xu(t,r.shape),a=_a(r,s,!0),o=He(r,a),i=wo(o),l=_t(i,s),u=uc(l),c=Me(ue(a,u.shape),u);if(n){let d=cc(c.shape,s);return ue(c,d)}return c}var n4=H({logSumExp_:Az});function xz(e,t){let n=P(e,"a","logicalAnd","bool"),r=P(t,"b","logicalAnd","bool");In(n.shape,r.shape);let s={a:n,b:r};return U.runKernel(pw,s)}var Sp=H({logicalAnd_:xz});function bz(e){let n={x:P(e,"x","logicalNot","bool")};return U.runKernel(fw,n)}var r4=H({logicalNot_:bz});function vz(e,t){let n=P(e,"a","logicalOr","bool"),r=P(t,"b","logicalOr","bool");In(n.shape,r.shape);let s={a:n,b:r};return U.runKernel(mw,s)}var s4=H({logicalOr_:vz});function wz(e,t){let n=P(e,"a","logicalXor","bool"),r=P(t,"b","logicalXor","bool");return In(n.shape,r.shape),Sp(s4(e,t),r4(Sp(e,t)))}var kz=H({logicalXor_:wz});function Iz(e,t,n,r,s){let a=P(e,"x","maxPool"),o=1,i=a,l=!1;a.rank===3&&(l=!0,i=ue(a,[1,a.shape[0],a.shape[1],a.shape[2]])),L(i.rank===4,()=>`Error in maxPool: input must be rank 4 but got rank ${i.rank}.`),L(Qs(n,o),()=>`Error in maxPool: Either strides or dilations must be 1. Got strides ${n} and dilations '${o}'`),s!=null&&L(Xn(r),()=>`Error in maxPool: pad must be an integer when using, dimRoundingMode ${s} but got pad ${r}.`);let u={x:i},c={filterSize:t,strides:n,pad:r,dimRoundingMode:s},d=U.runKernel(xw,u,c);return l?ue(d,[d.shape[1],d.shape[2],d.shape[3]]):d}var a4=H({maxPool_:Iz});function Sz(e,t=[1,1,1],n,r,s,a="NDHWC"){let o=P(e,"x","maxPool3d"),i=o,l=!1;o.rank===4&&(l=!0,i=ue(o,[1,o.shape[0],o.shape[1],o.shape[2],o.shape[3]])),L(i.rank===5,()=>`Error in maxPool3d: x must be rank 5 but got rank ${i.rank}.`),L(a==="NDHWC",()=>`Error in maxPool3d: Only NDHWC is currently supported, but got dataFormat of ${a}`),s!=null&&L(Xn(r),()=>`Error in maxPool3d: pad must be an integer when using, dimRoundingMode ${s} but got pad ${r}.`);let u={x:i},c={filterSize:t,strides:n,pad:r,dimRoundingMode:s,dataFormat:a},d=U.runKernel(bw,u,c);return l?ue(d,[d.shape[1],d.shape[2],d.shape[3],d.shape[4]]):d}var Tz=H({maxPool3d_:Sz});function Nz(e,t,n,r,s=!1){let o={x:P(e,"x","maxPoolWithArgmax")},i={filterSize:t,strides:n,pad:r,includeBatchInIndex:s},l=U.runKernel(vw,o,i);return{result:l[0],indexes:l[1]}}var Cz=H({maxPoolWithArgmax_:Nz});function Ez(e,t){let n=P(e,"a","maximum"),r=P(t,"b","maximum");[n,r]=Vt(n,r),n.dtype==="bool"&&(n=Pt(n,"int32"),r=Pt(r,"int32")),In(n.shape,r.shape);let s={a:n,b:r};return U.runKernel(Aw,s)}var o4=H({maximum_:Ez});function $z(e,t=null,n=!1){let s={x:P(e,"x","mean")},a={axis:t,keepDims:n};return U.runKernel(ww,s,a)}var Tp=H({mean_:$z});function ji(e,t="float32"){if(t==="complex64"){let r=ji(e,"float32"),s=ji(e,"float32");return go(r,s)}let n=np(Jt(e),t);return U.makeTensor(n,e,t)}function ko(e,t="float32"){if(t==="complex64"){let r=ko(e,"float32"),s=ji(e,"float32");return go(r,s)}let n=n2(Jt(e),t);return U.makeTensor(n,e,t)}function _z(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 r=P(e,"x","meshgrid",e instanceof Tt?e.dtype:"float32");if(t===void 0)return[r];let s=P(t,"y","meshgrid",t instanceof Tt?t.dtype:"float32"),a=Jt(r.shape),o=Jt(s.shape);return n==="xy"?(r=ue(r,[1,-1]),s=ue(s,[-1,1]),[yt(ko([o,1],r.dtype),r),yt(s,ko([1,a],s.dtype))]):(r=ue(r,[-1,1]),s=ue(s,[1,-1]),[yt(r,ko([1,o],r.dtype)),yt(ko([a,1],s.dtype),s)])}function Rz(e,t=null,n=!1){let s={x:P(e,"x","min")},a={axis:t,keepDims:n};return U.runKernel(kw,s,a)}var sy=H({min_:Rz});function Dz(e,t){let n=P(e,"a","minimum"),r=P(t,"b","minimum");[n,r]=Vt(n,r),n.dtype==="bool"&&(n=Pt(n,"int32"),r=Pt(r,"int32")),In(n.shape,r.shape);let s={a:n,b:r};return U.runKernel(Iw,s)}var i4=H({minimum_:Dz});function Fz(e,t,n){L(n==="reflect"||n==="symmetric",()=>`Invalid mode. Mode must be either reflect or symmetric. Got ${n}.`);let r=P(e,"x","mirrorPad");if(r.rank===0)throw new Error("mirrorPad(scalar) is not defined. Pass non-scalar to mirrorPad");L(t.length===r.rank,()=>`Padding doesn't match input. Must be ${r.rank}. Got ${t.length}.`);let s=n==="reflect"?1:0;for(let i=0;i<r.rank;i++)L(t[i].length===2,()=>"Invalid number of paddings. Must be length of 2 each."),L(t[i][0]>=0&&t[i][0]<=r.shape[i]-s&&t[i][1]>=0&&t[i][1]<=r.shape[i]-s,()=>`Padding in dimension ${i} cannot be greater than or equal to ${r.shape[i]-s} or less than 0 for input of shape ${r.shape}`);let a={paddings:t,mode:n},o={x:r};return U.runKernel(Sw,o,a)}var Mz=H({mirrorPad_:Fz});function Oz(e,t){let n=P(e,"a","mod"),r=P(t,"b","mod");[n,r]=Vt(n,r);let s={a:n,b:r};return U.runKernel(Tw,s)}var Pz=H({mod_:Oz});function zz(e){let t=P(e,"x","square"),n={};return U.runKernel("Square",{x:t},n)}var ns=H({square_:zz});function Lz(e,t=null,n=!1){e=P(e,"x","moments");let r=Xu(t,e.shape),s=Tp(e,r,n),a=s.shape;n||(a=cc(s.shape,r));let o=ns(He(Pt(e,"float32"),ue(s,a))),i=Tp(o,r,n);return{mean:s,variance:i}}var Bz=H({moments_:Lz});function Wz(e,t,n,r){let s=P(t,"data","multiRNNCell"),a=sc(n,"c","multiRNNCell"),o=sc(r,"h","multiRNNCell"),i=s,l=[];for(let d=0;d<e.length;d++){let h=e[d](i,a[d],o[d]);l.push(h[0]),l.push(h[1]),i=h[1]}let u=[],c=[];for(let d=0;d<l.length;d+=2)u.push(l[d]),c.push(l[d+1]);return[u,c]}var Vz=H({multiRNNCell_:Wz});function Uz(e,t,n,r=!1){let s=P(e,"logits","multinomial"),a=s.size,o=s.rank;if(a<2)throw new Error(`Error in multinomial: you need at least 2 outcomes, but got ${a}.`);if(o>2)throw new Error(`Rank of probabilities must be 1 or 2, but is ${o}`);n=n||Math.random();let l={logits:o===1?ue(s,[1,-1]):s},u={numSamples:t,seed:n,normalized:r},c=U.runKernel(Nw,l,u);return o===1?ue(c,[c.size]):c}var Hz=H({multinomial_:Uz});function Gz(e,t){let n=P(e,"a","notEqual","string_or_numeric"),r=P(t,"b","notEqual","string_or_numeric");[n,r]=Vt(n,r),In(n.shape,r.shape);let s={a:n,b:r};return U.runKernel($w,s)}var l4=H({notEqual_:Gz});function jz(e){let n={x:P(e,"x","onesLike")};return U.runKernel(Fw,n)}var qz=H({onesLike_:jz});function Kz(e,t){let n=P(e,"v1","outerProduct"),r=P(t,"v2","outerProduct");L(n.rank===1&&r.rank===1,()=>`Error in outerProduct: inputs must be rank 1, but got ranks ${n.rank} and ${r.rank}.`);let s=ue(n,[-1,1]),a=ue(r,[1,-1]);return yt(s,a)}var Xz=H({outerProduct_:Kz});function Zz(e,t,n=0){let r=P(e,"x","pad");if(r.rank===0)throw new Error("pad(scalar) is not defined. Pass non-scalar to pad");let s={paddings:t,constantValue:n},a={x:r};return U.runKernel(Pw,a,s)}var dc=H({pad_:Zz});function Yz(e,t,n=0){return L(t.length===2,()=>"Invalid number of paddings. Must be length of 2."),dc(e,[t],n)}var Jz=H({pad1d_:Yz});function Qz(e,t,n=0){return L(t.length===2&&t[0].length===2&&t[1].length===2,()=>"Invalid number of paddings. Must be length of 2 each."),dc(e,t,n)}var eL=H({pad2d_:Qz});function tL(e,t,n=0){return L(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."),dc(e,t,n)}var nL=H({pad3d_:tL});function rL(e,t,n=0){return L(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."),dc(e,t,n)}var sL=H({pad4d_:rL});function aL(e,t,n){let r=P(e,"x","spaceToBatchND");L(r.rank>=1+t.length,()=>`input rank ${r.rank} should be > than [blockShape] ${t.length}`),L(n.length===t.length,()=>`paddings.shape[0] ${n.length} must be equal to [blockShape] ${t.length}`),L(r.shape.reduce((o,i,l)=>l>0&&l<=t.length?o&&(i+n[l-1][0]+n[l-1][1])%t[l-1]==0:o,!0),()=>`input spatial dimensions ${r.shape.slice(1)} with paddings ${n.toString()} must be divisible by blockShapes ${t.toString()}`);let s={x:r},a={blockShape:t,paddings:n};return U.runKernel(u7,s,a)}var u4=H({spaceToBatchND_:aL});function oL(e,t,n,r,s,a){s==null&&(s=[1,1]),a==null&&(a=1),r===0&&(r="valid");let o=P(e,"x","maxPool"),i=o,l=!1;o.rank===3&&(l=!0,i=ue(o,[1,o.shape[0],o.shape[1],o.shape[2]])),L(Qs(a,s),()=>`Error in pool: Either strides or dilations must be 1. Got strides ${a} and dilations '${s}'`);let u=Pk(i.shape,t,a,s,r),c=[u.dilationHeight,u.dilationWidth],d;r==="same"?d=lL([u.filterHeight,u.filterWidth],c):d=[[0,0],[0,0]];let h=c[0]===1&&c[1]===1,[p,f]=iL([u.inHeight,u.inWidth],c,d),m=h?r:"valid",g=h?i:u4(i,c,p),A=(n==="avg"?()=>Bk(g,t,a,m):()=>a4(g,t,a,m))(),x=h?A:Wk(A,c,f);return l?ue(x,[x.shape[1],x.shape[2],x.shape[3]]):x}function iL(e,t,n){let r=n.map(c=>c[0]),s=n.map(c=>c[1]),a=e.concat(r,s),o=t.map((c,d)=>(c-a[d]%c)%c),i=s.map((c,d)=>c+o[d]),l=t.map((c,d)=>[r[d],i[d]]),u=t.map((c,d)=>[0,o[d]]);return[l,u]}function lL(e,t){let r=e.map((o,i)=>o+(o-1)*(t[i]-1)).map(o=>o-1),s=r.map(o=>Math.floor(o/2)),a=r.map((o,i)=>o-s[i]);return r.map((o,i)=>[s[i],a[i]])}var uL=H({pool_:oL});function cL(e,t){let n=P(e,"base","pow"),r=P(t,"exp","pow");[n,r]=Vt(n,r);let s={a:n,b:r};return U.runKernel(zw,s)}var hc=H({pow_:cL});function dL(e,t){let n=P(e,"x","prelu"),r=P(t,"alpha","prelu"),s={x:n,alpha:r};return U.runKernel(Lw,s)}var c4=H({prelu_:dL});function hL(e,t=null,n=!1){let r=P(e,"x","prod");r.dtype==="bool"&&(r=Pt(r,"int32"));let s={x:r},a={axis:t,keepDims:n};return U.runKernel(Bw,s,a)}var pL=H({prod_:hL});function fL(e,t,n){let r=Jt(e),s=null;if(n==null||n==="float32")s=new Float32Array(r);else if(n==="int32")s=new Int32Array(r);else if(n==="bool")s=new Uint8Array(r);else throw new Error(`Unknown data type ${n}`);for(let a=0;a<r;a++)s[a]=t();return U.makeTensor(s,e,n)}var mL=H({rand_:fL}),ay=Ks(e2()),oy=class{constructor(e,t,n,r,s){this.mean=e,this.stdDev=t,this.dtype=n,this.nextVal=NaN,this.truncated=r,this.truncated&&(this.upper=this.mean+this.stdDev*2,this.lower=this.mean-this.stdDev*2);let a=s||Math.random();this.random=ay.alea(a.toString())}nextValue(){if(!isNaN(this.nextVal)){let r=this.nextVal;return this.nextVal=NaN,r}let e,t,n=!1;for(;!n;){let r,s,a;do r=2*this.random()-1,s=2*this.random()-1,a=r*r+s*s;while(a>=1||a===0);let o=Math.sqrt(-2*Math.log(a)/a);e=this.mean+this.stdDev*r*o,t=this.mean+this.stdDev*s*o,(!this.truncated||this.isValidTruncated(e))&&(n=!0)}return(!this.truncated||this.isValidTruncated(t))&&(this.nextVal=this.convertValue(t)),this.convertValue(e)}convertValue(e){return this.dtype==null||this.dtype==="float32"?e:Math.round(e)}isValidTruncated(e){return e<=this.upper&&e>=this.lower}},gL=class{constructor(e,t,n,r){this.alpha=e,this.beta=1/t,this.dtype=n;let s=r||Math.random();this.randu=ay.alea(s.toString()),this.randn=new oy(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,r,s,a;for(;;){do r=this.randn.nextValue(),a=1+this.c*r;while(a<=0);if(a*=a*a,e=r*r,t=1-.331*e*e,n=.5*e+this.d*(1-a+Math.log(a)),s=this.randu(),s<t||Math.log(s)<n)break}return a=1/this.beta*this.d*a,this.alpha<1&&(a*=Math.pow(this.randu(),1/this.alpha)),this.convertValue(a)}convertValue(e){return this.dtype==="float32"?e:Math.round(e)}},yL=class{constructor(e=0,t=1,n,r){if(this.canReturnFloat=()=>this.dtype==null||this.dtype==="float32",this.min=e,this.range=t-e,this.dtype=n,r==null&&(r=Math.random()),typeof r=="number"&&(r=r.toString()),!this.canReturnFloat()&&this.range<=1)throw new Error(`The difference between ${e} - ${t} <= 1 and dtype is not float`);this.random=ay.alea(r)}convertValue(e){return this.canReturnFloat()?e:Math.round(e)}nextValue(){return this.convertValue(this.min+this.range*this.random())}};function AL(e,t,n=1,r="float32",s){if(n==null&&(n=1),r==null&&(r="float32"),r!=="float32"&&r!=="int32")throw new Error(`Unsupported data type ${r}`);let a=new gL(t,n,r,s),o=Ys(e,r);for(let i=0;i<o.values.length;i++)o.values[i]=a.nextValue();return o.toTensor()}var xL=H({randomGamma_:AL});function bL(e,t=0,n=1,r,s){if(r!=null&&r==="bool")throw new Error(`Unsupported data type ${r}`);let a=new oy(t,n,r,!1,s),o=Ys(e,r);for(let i=0;i<o.values.length;i++)o.values[i]=a.nextValue();return o.toTensor()}var vL=H({randomNormal_:bL});function wL(e,t=0,n=1,r="float32",s){let a=Ys(e,r),o=new yL(t,n,null,s);for(let i=0;i<a.values.length;i++)a.values[i]=o.nextValue();return a.toTensor()}var d4=H({randomUniform_:wL});function pc(e,t,n=1,r="float32"){if(n===0)throw new Error("Cannot have a step of zero");let s={start:e,stop:t,step:n,dtype:r};return U.runKernel(Ww,{},s)}function kL(e){let n={input:P(e,"input","real")};return U.runKernel(Vw,n)}var Np=H({real_:kL});function IL(e){let n={x:P(e,"x","reciprocal")};return U.runKernel(Uw,n)}var SL=H({reciprocal_:IL});function TL(e){let n={x:P(e,"x","relu")};return U.runKernel(Hw,n)}var Cp=H({relu_:TL});function NL(e){let n={x:P(e,"x","relu6")};return U.runKernel(Kw,n)}var h4=H({relu6_:NL});function CL(e,t){let r={x:P(e,"x","reverse")},s={dims:t};return U.runKernel(Xw,r,s)}var Io=H({reverse_:CL});function EL(e){let t=P(e,"x","reverse");return L(t.rank===1,()=>`Error in reverse1D: x must be rank 1 but got rank ${t.rank}.`),Io(t,0)}var $L=H({reverse1d_:EL});function _L(e,t){let n=P(e,"x","reverse");return L(n.rank===2,()=>`Error in reverse2D: x must be rank 2 but got rank ${n.rank}.`),Io(n,t)}var RL=H({reverse2d_:_L});function DL(e,t){let n=P(e,"x","reverse");return L(n.rank===3,()=>`Error in reverse3D: x must be rank 3 but got rank ${n.rank}.`),Io(n,t)}var FL=H({reverse3d_:DL});function ML(e,t){let n=P(e,"x","reverse");return L(n.rank===4,()=>`Error in reverse4D: x must be rank 4 but got rank ${n.rank}.`),Io(n,t)}var OL=H({reverse4d_:ML});function PL(e){let n={x:P(e,"x","round")};return U.runKernel(Zw,n)}var p4=H({round_:PL});function zL(e){let n={x:P(e,"x","rsqrt")};return U.runKernel(Yw,n)}var LL=H({rsqrt_:zL});function ut(e,t){if((Cn(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"&&Cn(e)&&!(e instanceof Uint8Array))throw new Error("When making a scalar from encoded string, the value must be `Uint8Array`.");return Na(e,[],[],t)}function BL(e){let n={x:P(e,"x","selu")};return U.runKernel(e7,n)}var WL=H({selu_:BL});function VL(e,t,n,r,s,a=[1,1],o="NHWC"){let i=P(e,"x","separableConv2d"),l=P(t,"depthwiseFilter","separableConv2d"),u=P(n,"pointwiseFilter","separableConv2d"),c=i,d=!1;if(i.rank===3&&(d=!0,c=ue(i,[1,i.shape[0],i.shape[1],i.shape[2]])),o==="NCHW")throw new Error("separableConv2d currently does not support dataFormat NCHW; only NHWC is supported");L(c.rank===4,()=>`Error in separableConv2d: input must be rank 4, but got rank ${c.rank}.`),L(l.rank===4,()=>`Error in separableConv2d: depthwise filter must be rank 4, but got rank ${l.rank}.`),L(u.rank===4,()=>`Error in separableConv2d: pointwise filter must be rank 4, but got rank ${l.rank}.`),L(u.shape[0]===1,()=>`Error in separableConv2d: the first dimension of pointwise filter must be 1, but got ${u.shape[0]}.`),L(u.shape[1]===1,()=>`Error in separableConv2d: the second dimension of pointwise filter must be 1, but got ${u.shape[1]}.`);let h=l.shape[2],p=l.shape[3];L(u.shape[2]===h*p,()=>`Error in separableConv2d: the third dimension of pointwise filter must be ${h*p}, but got ${u.shape[2]}.`);let f=ey(c,l,r,s,o,a),g=bp(f,u,1,"valid",o);return d?ue(g,[g.shape[1],g.shape[2],g.shape[3]]):g}var UL=H({separableConv2d_:VL});async function HL(e,t){let n=P(e,"x","setdiff1d"),r=P(t,"y","setdiff1d");L(n.dtype===r.dtype,()=>`x and y should have the same dtype, but got x (${n.dtype}) and y (${r.dtype}).`),L(n.rank===1,()=>`x should be 1D tensor, but got x (${n.shape}).`),L(r.rank===1,()=>`y should be 1D tensor, but got y (${r.shape}).`);let s=await n.data(),a=await r.data(),o=new Set(a),i=0;for(let c=0;c<s.length;c++)o.has(s[c])||i++;let l=new up([i],n.dtype),u=new up([i],"int32");for(let c=0,d=0;c<s.length;c++)o.has(s[c])||(l.values[d]=s[c],u.values[d]=c,d++);return[l.toTensor(),u.toTensor()]}var GL=HL;function jL(e){let n={x:P(e,"x","sign")};return U.runKernel(s7,n)}var qL=H({sign_:jL});function KL(e){let n={x:P(e,"x","sin")};return U.runKernel(n7,n)}var XL=H({sin_:KL});function ZL(e){let n={x:P(e,"x","sinh")};return U.runKernel(r7,n)}var YL=H({sinh_:ZL});function JL(e,t,n){let r=P(e,"x","slice1d");return L(r.rank===1,()=>`slice1d expects a rank-1 tensor, but got a rank-${r.rank} tensor`),Ze(r,[t],[n])}var QL=H({slice1d_:JL});function eB(e,t,n){let r=P(e,"x","slice2d");return L(r.rank===2,()=>`slice2d expects a rank-2 tensor, but got a rank-${r.rank} tensor`),Ze(r,t,n)}var tB=H({slice2d_:eB});function nB(e,t,n){let r=P(e,"x","slice3d");return L(r.rank===3,()=>`slice3d expects a rank-3 tensor, but got a rank-${r.rank} tensor`),Ze(r,t,n)}var rB=H({slice3d_:nB});function sB(e,t,n){let r=P(e,"x","slice4d");return L(r.rank===4,()=>`slice4d expects a rank-4 tensor, but got a rank-${r.rank} tensor`),Ze(r,t,n)}var aB=H({slice4d_:sB});function oB(e,t=-1){let n=P(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 r={logits:n},s={dim:t};return U.runKernel(d7,r,s)}var iB=H({softmax_:oB});function lB(e){L(e.dtype==="complex64",()=>`The dtype for tf.spectral.fft() must be complex64 but got ${e.dtype}.`);let t={input:e};return U.runKernel(jv,t)}var iy=H({fft_:lB});function uB(e){L(e.dtype==="complex64",()=>`The dtype for tf.spectral.ifft() must be complex64 but got ${e.dtype}.`);let t={input:e};return U.runKernel(nw,t)}var Ep=H({ifft_:uB});function cB(e){let t=e.shape[e.shape.length-1],n=e.size/t,r;if(t<=2){let s=ue(e,[n,t]);r=Ep(s)}else{let s=[n,2*(t-1)],a=ue(Np(e),[n,t]),o=ue(ty(e),[n,t]),i=Io(Ze(a,[0,1],[n,t-2]),1),l=fe(Io(Ze(o,[0,1],[n,t-2]),1),ut(-1)),u=an([a,i],1),c=an([o,l],1),d=ue(go(u,c),[s[0],s[1]]);r=Ep(d)}if(r=Np(r),e.rank===3&&e.shape[0]!==0){let s=r,a=e.shape[0];r=ue(r,[a,r.shape[0]/a,r.shape[1]]),s.dispose()}return r}var f4=H({irfft_:cB});function dB(e,t,n=0){let s={x:P(e,"x","split")},a={numOrSizeSplits:t,axis:n};return U.runKernel(c7,s,a)}var ta=H({split_:dB});function hB(e,t){L(e.dtype==="float32",()=>`The dtype for rfft() must be real value but got ${e.dtype}`);let n=e.shape[e.shape.length-1],r=e.size/n,s;if(t!=null&&t<n){let f=e.shape.map(g=>0),m=e.shape.map(g=>g);m[e.shape.length-1]=t,s=Ze(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,s=an([e,ji(f)],e.shape.length-1),n=t}else s=e;let a=Cr(s),o=ue(go(s,a),[r,n]),i=iy(o),l=Math.floor(n/2)+1,u=Np(i),c=ty(i),d=ta(u,[l,n-l],u.shape.length-1),h=ta(c,[l,n-l],c.shape.length-1),p=s.shape.slice();return p[s.shape.length-1]=l,ue(go(d[0],h[0]),p)}var ly=H({rfft_:hB});function pB(e){let n={x:P(e,"x","sqrt")};return U.runKernel(i7,n)}var na=H({sqrt_:pB});function fB(e,t){let n=P(e,"a","squaredDifference"),r=P(t,"b","squaredDifference");[n,r]=Vt(n,r),In(n.shape,r.shape);let s={a:n,b:r},a={};return U.runKernel(y7,s,a)}var m4=H({squaredDifference_:fB});function mB(e,t){let n=P(e,"x","squeeze");return ue(n,W3(n.shape,t).newShape)}var Zn=H({squeeze_:mB});function gB(e,t=0){let n=sc(e,"tensors","stack","string_or_numeric");L(n.length>=1,()=>"Pass at least one tensor to tf.stack"),n.length>0&&L(t<=n[0].rank,()=>"Axis must be <= rank of the tensor");let r=n,s={axis:t};return U.runKernel(Ow,r,s)}var So=H({stack_:gB});function yB(e,t=0){let r={x:P(e,"x","step")},s={alpha:t};return U.runKernel(R7,r,s)}var g4=H({step_:yB});function AB(e,t,n,r,s=0,a=0,o=0,i=0,l=0){let c={x:P(e,"x","stridedSlice","string_or_numeric")},d={begin:t,end:n,strides:r,beginMask:s,endMask:a,ellipsisMask:o,newAxisMask:i,shrinkAxisMask:l};return U.runKernel(A7,c,d)}var xB=H({stridedSlice_:AB});function bB(e){let n={x:P(e,"x","tan")};return U.runKernel(k7,n)}var vB=H({tan_:bB});function lr(e,t){ho(e);let n=Ss(e,t);if(n.length!==1)throw new Error("tensor1d() requires values to be a flat/TypedArray");return Na(e,null,n,t)}function ra(e,t,n){if(ho(e),t!=null&&t.length!==2)throw new Error("tensor2d() requires shape to have two numbers");let r=Ss(e,n);if(r.length!==2&&r.length!==1)throw new Error("tensor2d() requires values to be number[][] or flat/TypedArray");if(r.length===1&&t==null)throw new Error("tensor2d() requires shape to be provided when `values` are a flat/TypedArray");return Na(e,t,r,n)}function wB(e,t,n){if(ho(e),t!=null&&t.length!==4)throw new Error("tensor4d() requires shape to have four numbers");let r=Ss(e,n);if(r.length!==4&&r.length!==1)throw new Error("tensor4d() requires values to be number[][][][] or flat/TypedArray");if(r.length===1&&t==null)throw new Error("tensor4d() requires shape to be provided when `values` are a flat array");return Na(e,t,r,n)}function kB(e,t,n){if(ho(e),t!=null&&t.length!==5)throw new Error("tensor5d() requires shape to have five numbers");let r=Ss(e,n);if(r.length!==5&&r.length!==1)throw new Error("tensor5d() requires values to be number[][][][][] or flat/TypedArray");if(r.length===1&&t==null)throw new Error("tensor5d() requires shape to be provided when `values` are a flat array");return Na(e,t,r,n)}function IB(e,t,n){if(ho(e),t!=null&&t.length!==6)throw new Error("tensor6d() requires shape to have six numbers");let r=Ss(e,n);if(r.length!==6&&r.length!==1)throw new Error("tensor6d() requires values to be number[][][][][][] or flat/TypedArray");if(r.length===1&&t==null)throw new Error("tensor6d() requires shape to be provided when `values` are a flat array");return t=t||r,Na(e,t,r,n)}function SB(e,t=1,n=!0){let r=P(e,"x","topk");if(r.rank===0)throw new Error("topk() expects the input to be of rank 1 or higher");let s=r.shape[r.shape.length-1];if(t>s)throw new Error(`'k' passed to topk() must be <= the last dimension (${s}) but got ${t}`);let a={x:r},o={k:t,sorted:n},[i,l]=U.runKernel(S7,a,o);return{values:i,indices:l}}var TB=H({topk_:SB});function NB(e,t=0,n=1,r,s){if(r!=null&&r==="bool")throw new Error("Unsupported data type $ { dtype }");let a=new oy(t,n,r,!0,s),o=Ys(e,r);for(let i=0;i<o.values.length;i++)o.values[i]=a.nextValue();return o.toTensor()}var CB=H({truncatedNormal_:NB});function EB(e,t=0){let n=P(e,"x","unique","string_or_numeric");L(n.rank>0,()=>"The input tensor must be at least 1D");let r={x:n},s={axis:t},[a,o]=U.runKernel(C7,r,s);return{values:a,indices:o}}var $B=H({unique_:EB});function _B(e,t,n){let r=P(e,"x","unsortedSegmentSum"),s=P(t,"segmentIds","unsortedSegmentSum","int32");L(Xn(n),()=>"numSegments must be of dtype int");let a={x:r,segmentIds:s},o={numSegments:n};return U.runKernel($7,a,o)}var RB=H({unsortedSegmentSum_:_B});function DB(e,t=0){let n=P(e,"x","unstack","string_or_numeric");L(t>=-n.shape.length&&t<n.shape.length,()=>`Axis = ${t} is not in [-${n.shape.length}, ${n.shape.length})`);let r={value:n},s={axis:t};return U.runKernel(E7,r,s)}var fc=H({unstack_:DB});function FB(e,t=!0,n,r){return U.makeVariable(e,t,n,r)}function y4(e,t){let n=[];for(let a=0;a<t.length;a++)t[a]&&n.push(a);let r=Ys(e,"int32"),s=Ys([n.length,e.length],"int32");for(let a=0;a<n.length;a++){let o=r.indexToLoc(n[a]),i=a*e.length;s.values.set(o,i)}return s.toTensor()}async function MB(e){let t=P(e,"condition","whereAsync","bool"),n=await t.data(),r=y4(t.shape,n);return e!==t&&t.dispose(),r}var A4=MB;async function OB(e,t,n){let r=P(e,"tensor","boolMask"),s=P(t,"mask","boolMask","bool"),a=n==null?0:n,o=s.rank,i=r.shape;L(o>0,()=>"mask cannot be scalar"),Mn(i.slice(a,a+o),s.shape,"mask's shape must match the first K dimensions of tensor's shape,");let l=1;for(let m=a;m<a+o;m++)l*=i[m];let u=i.slice(0,a).concat([l],i.slice(a+o)),c=ue(r,u),d=ue(s,[-1]),h=await A4(d),p=Zn(h,[1]),f=Xk(c,p,a);return e!==r&&r.dispose(),t!==s&&s.dispose(),p.dispose(),c.dispose(),d.dispose(),h.dispose(),f}var PB=OB;function zB(e,t="euclidean",n=null,r=!1){e=P(e,"x","norm");let s=x4(e,t,n),a=s.shape;if(r){let o=Xu(n,e.shape);a=cc(s.shape,o)}return ue(s,a)}function x4(e,t,n=null){if(e.rank===0)return Nr(e);if(e.rank!==1&&n===null)return x4(ue(e,[-1]),t,n);if(e.rank===1||typeof n=="number"||Array.isArray(n)&&n.length===1){if(t===1)return _t(Nr(e),n);if(t===Infinity)return _a(Nr(e),n);if(t===-Infinity)return sy(Nr(e),n);if(t==="euclidean"||t===2)return na(_t(hc(Nr(e),ut(2,"int32")),n));throw new Error(`Error in norm: invalid ord value: ${t}`)}if(Array.isArray(n)&&n.length===2){if(t===1)return _a(_t(Nr(e),n[0]),n[1]-1);if(t===Infinity)return _a(_t(Nr(e),n[1]),n[0]);if(t===-Infinity)return sy(_t(Nr(e),n[1]),n[0]);if(t==="fro"||t==="euclidean")return na(_t(ns(e),n));throw new Error(`Error in norm: invalid ord value: ${t}`)}throw new Error(`Error in norm: invalid axis: ${n}`)}var uy=H({norm_:zB});function LB(e,t,n,r,s=!0){let a=P(e,"v","movingAverage"),o=P(t,"x","movingAverage"),i=P(n,"decay","movingAverage");V7(a,o),L(Xs(a.shape,o.shape),()=>"Shape mismatch in v and x");let l=ut(1),u=He(l,i),c=fe(He(o,a),u);if(s){L(r!=null,()=>"When using zeroDebias: true, step is required.");let d=P(r,"step","movingAverage");c=Qe(c,He(l,hc(i,d)))}return Me(a,c)}var BB=H({movingAverage_:LB});function WB(e,t,n){let r=P(e,"indices","scatterND","int32"),s=P(t,"updates","scatterND");V2(s,r,n);let a={indices:r,updates:s},o={shape:n};return U.runKernel(Jw,a,o)}var VB=H({scatterND_:WB});function UB(e,t,n,r){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 s=e.rank>0?e.shape[0]:1,a=e.rank>1?e.shape[1]:1;if(n.length!==a)throw new Error(`outputShape has incorrect number of elements:, ${n.length}, should be: ${a}.`);let o=t.size;if(!(t.rank===0||t.rank===1&&o===s))throw new Error(`sparseValues has incorrect shape ${t.shape}, should be [] or [${s}]`);if(t.dtype!==r.dtype)throw new Error("sparseValues.dtype must match defaultValues.dtype")}function HB(e,t,n,r=0){let s=P(e,"sparseIndices","sparseToDense","int32"),a=P(t,"sparseValues","sparseToDense"),o=P(r,"defaultValue","sparseToDense",a.dtype);UB(s,a,n,o);let i={sparseIndices:s,sparseValues:a,defaultValue:o},l={outputShape:n};return U.runKernel(g7,i,l)}var GB=H({sparseToDense_:HB});function jB(e,t){let n=P(t,"indices","gatherND","int32"),s={params:P(e,"x","gatherND","string_or_numeric"),indices:n};return U.runKernel(Qv,s)}var qB=H({gatherND_:jB});function KB(e,t){if(t==null)return e.shape.slice();if(Xs(e.shape,t))return t;if(e.shape.length===t.length){let n=[];for(let r=0;r<e.shape.length;r++)t[r]==null&&e.shape[r]!=null?n.push(e.shape[r]):n.push(t[r]);return n}return t}function XB(e,t,n,r){let s=P(e,"x","dropout");if(L(s.dtype==="float32",()=>`x has to be a floating point tensor since it's going to be scaled, but got a ${s.dtype} tensor instead.`),L(t>=0&&t<1,()=>`rate must be a float in the range [0, 1), but got ${t}.`),t===0)return e instanceof Tt?s.clone():s;let a=KB(s,n),o=1-t,i=Qe(Kk(Me(d4(a,0,1,"float32",r),o)),o);return fe(s,i)}var ZB=H({dropout_:XB});function b4(e){return Math.floor(Math.pow(2,Math.ceil(Math.log(e)/Math.log(2))))}function cy(e,t,n){let r=1-e%2,s=new Float32Array(e);for(let a=0;a<e;++a){let o=2*Math.PI*a/(e+r-1);s[a]=t-n*Math.cos(o)}return lr(s,"float32")}async function YB(e,t,n=1){let r=P(e,"predictions","inTopK"),s=P(t,"targets","inTopK");L(r.rank>1,()=>`inTopK() expects the predictions to be of rank 2 or higher, but got ${r.rank}`),L(r.rank-1===s.rank,()=>`predictions rank should be 1 larger than targets rank, but got predictions rank ${r.rank} and targets rank ${s.rank}`),Mn(r.shape.slice(0,r.shape.length-1),s.shape,"predictions's shape should be align with the targets' shape, except the last dimension.");let a=r.shape[r.shape.length-1];L(n>0&&n<=a,()=>`'k' passed to inTopK() must be > 0 && <= the predictions last dimension (${a}), but got ${n}`);let o=await r.data(),i=await s.data(),[l,u]=[o.length/a,a],c=V3("bool",l);for(let d=0;d<l;d++){let h=d*u,p=o.subarray(h,h+u),f=[];for(let m=0;m<p.length;m++)f.push({value:p[m],index:m});f.sort((m,g)=>g.value-m.value),c[d]=0;for(let m=0;m<n;m++)if(f[m].index===i[d]){c[d]=1;break}}return e!==r&&r.dispose(),t!==s&&s.dispose(),ts(c,s.shape,"bool")}var JB=YB,v4={};De(v4,{conv2d:()=>nW,depthwiseConv2d:()=>lW,matMul:()=>cW});function QB(e,t,n,r,s,a="NHWC",o){let i=e;e.rank===3&&(i=ue(e,[1,e.shape[0],e.shape[1],e.shape[2]]));let l=t;l.rank===3&&(l=ue(t,[1,t.shape[0],t.shape[1],t.shape[2]])),L(i.rank===4,()=>`Error in conv2dDerFilter: input must be rank 4, but got shape ${i.shape}.`),L(l.rank===4,()=>`Error in conv2dDerFilter: dy must be rank 4, but got shape ${l.shape}.`),L(n.length===4,()=>`Error in conv2dDerFilter: filterShape must be length 4, but got ${n}.`);let u=a==="NHWC"?i.shape[3]:i.shape[1],c=a==="NHWC"?l.shape[3]:l.shape[1];L(u===n[2],()=>`Error in conv2dDerFilter: depth of input ${u}) must match input depth in filter (${n[2]}.`),L(c===n[3],()=>`Error in conv2dDerFilter: depth of dy (${c}) must match output depth for filter (${n[3]}).`),o!=null&&L(Xn(s),()=>`Error in conv2dDerFilter: pad must be an integer when using, dimRoundingMode ${o} but got pad ${s}.`);let d={x:i,dy:l},h={strides:r,pad:s,dataFormat:a,dimRoundingMode:o,filterShape:n};return U.runKernel(kv,d,h)}var eW=H({conv2DBackpropFilter_:QB});function $p(e,t,n){if(n==null||n==="linear")return e;if(n==="relu")return fe(e,g4(t));throw new Error(`Cannot compute gradient for fused activation ${n}.`)}function _p(e,t){let n=t,r=Hk(e.shape,t.shape);return r.length>0&&(n=_t(n,r)),ue(n,e.shape)}function Rp(e,t,n,r){if(t==="linear")return e;if(t==="relu")return Cp(e);if(t==="elu")return jk(e);if(t==="relu6")return h4(e);if(t==="prelu")return c4(e,n);if(t==="leakyrelu")return Yk(e,r);if(t==="sigmoid")return Ts(e);throw new Error(`Unknown fused activation ${t}.`)}var Dp=(e,t)=>!(e>0)||t==="linear";function tW({x:e,filter:t,strides:n,pad:r,dataFormat:s="NHWC",dilations:a=[1,1],dimRoundingMode:o,bias:i,activation:l="linear",preluActivationWeights:u,leakyreluAlpha:c}){if(l=l||"linear",Dp(U.state.gradientDepth,l)===!1){let v=bp(e,t,n,r,s,a,o);return i!=null&&(v=Me(v,i)),Rp(v,l,u,c)}let d=P(e,"x","conv2d"),h=P(t,"filter","conv2d"),p=d,f=!1;d.rank===3&&(f=!0,p=ue(d,[1,d.shape[0],d.shape[1],d.shape[2]])),L(p.rank===4,()=>`Error in fused conv2d: input must be rank 4, but got rank ${p.rank}.`),L(h.rank===4,()=>`Error in fused conv2d: filter must be rank 4, but got rank ${h.rank}.`),o!=null&&L(Xn(r),()=>`Error in fused conv2d: pad must be an integer when using, dimRoundingMode ${o} but got pad ${r}.`),L(p.shape[3]===h.shape[2],()=>`Error in conv2d: depth of input (${p.shape[3]}) must match input depth for filter ${h.shape[2]}.`),L(Qs(n,a),()=>`Error in conv2D: Either strides or dilations must be 1. Got strides ${n} and dilations '${a}'`),L(s==="NHWC",()=>`Error in conv2d: got dataFormat of ${s} but only NHWC is currently supported.`);let m=oc(p.shape,h.shape,n,a,r,o),g;i!=null&&(g=P(i,"bias","fused conv2d"),[g]=Vt(g,d),In(m.outShape,g.shape));let y;u!=null&&(y=P(u,"prelu weights","fused conv2d"));let A=(v,w)=>{let[I,T,C,M]=w,$=$p(v,C,l);L(ic(a),()=>`Error in gradient of fused conv2D: dilation rates greater than 1 are not yet supported in gradients. Got dilations '${a}'`);let R=Uk(T.shape,$,I,n,r),N=eW(T,$,I.shape,n,r),F=[R,N];if(M!=null){let B=_p(M,$);F.push(B)}return F},x={x:p,filter:h,bias:g,preluActivationWeights:y},b={strides:n,pad:r,dataFormat:s,dilations:a,dimRoundingMode:o,activation:l,leakyreluAlpha:c};return i==null?Ns((w,I,T)=>{let C=U.runKernel(p2,x,b);return T([I,w,C]),f&&(C=ue(C,[C.shape[1],C.shape[2],C.shape[3]])),{value:C,gradFunc:A}})(p,h):Ns((w,I,T,C)=>{let M=U.runKernel(p2,x,b);return C([I,w,M,T]),f&&(M=ue(M,[M.shape[1],M.shape[2],M.shape[3]])),{value:M,gradFunc:A}})(p,h,g)}var nW=H({fusedConv2d_:tW});function rW(e,t,n,r,s,a=[1,1],o){let i=e;e.rank===3&&(i=ue(e,[1,e.shape[0],e.shape[1],e.shape[2]]));let l=t;l.rank===3&&(l=ue(t,[1,t.shape[0],t.shape[1],t.shape[2]]));let u={x:i,dy:l},c={strides:r,pad:s,dimRoundingMode:o,dilations:a,filterShape:n};return U.runKernel(Fv,u,c)}var sW=H({depthwiseConv2dNativeBackpropFilter_:rW});function aW(e,t,n,r,s,a=[1,1],o){let i=t,l=!1;t.rank===3&&(l=!0,i=ue(t,[1,t.shape[0],t.shape[1],t.shape[2]]));let u={dy:i,filter:n},c={strides:r,pad:s,dimRoundingMode:o,dilations:a,inputShape:e},d=U.runKernel(Mv,u,c);return l?ue(d,[d.shape[1],d.shape[2],d.shape[3]]):d}var oW=H({depthwiseConv2dNativeBackpropInput_:aW});function iW({x:e,filter:t,strides:n,pad:r,dataFormat:s="NHWC",dilations:a=[1,1],dimRoundingMode:o,bias:i,activation:l="linear",preluActivationWeights:u,leakyreluAlpha:c}){if(Dp(U.state.gradientDepth,l)===!1){let v=ey(e,t,n,r,s,a,o);return i!=null&&(v=Me(v,i)),Rp(v,l,u,c)}let d=P(e,"x","depthwiseConv2d"),h=P(t,"filter","depthwiseConv2d"),p=d,f=!1;d.rank===3&&(f=!0,p=ue(d,[1,d.shape[0],d.shape[1],d.shape[2]])),L(p.rank===4,()=>`Error in fused depthwiseConv2d: input must be rank 4, but got rank ${p.rank}.`),L(h.rank===4,()=>`Error in fused depthwiseConv2d: filter must be rank 4, but got rank ${h.rank}.`),L(p.shape[3]===h.shape[2],()=>`Error in fused depthwiseConv2d: number of input channels (${p.shape[3]}) must match the inChannels dimension in filter ${h.shape[2]}.`),a==null&&(a=[1,1]),L(Qs(n,a),()=>`Error in fused depthwiseConv2d: Either strides or dilations must be 1. Got strides ${n} and dilations '${a}'`),o!=null&&L(Xn(r),()=>`Error in fused depthwiseConv2d: pad must be an integer when using dimRoundingMode ${o} but got pad ${r}.`);let m=oc(p.shape,h.shape,n,a,r,o,!0),g;i!=null&&(g=P(i,"bias","fused conv2d"),[g]=Vt(g,d),In(m.outShape,g.shape));let y;u!=null&&(y=P(u,"prelu weights","fused depthwiseConv2d"));let A=(v,w)=>{L(ic(a),()=>`Error in gradient of fused depthwiseConv2d: dilation rates greater than 1 are not yet supported. Got dilations '${a}'`);let[I,T,C,M]=w,$=$p(v,C,l),R=oW(T.shape,$,I,n,r,a,o),N=sW(T,$,I.shape,n,r,a,o);if(M!=null){let F=_p(g,$);return[R,N,F]}return[R,N]},x={x:p,filter:h,bias:g,preluActivationWeights:y},b={strides:n,pad:r,dataFormat:s,dilations:a,dimRoundingMode:o,activation:l,leakyreluAlpha:c};return i==null?Ns((w,I,T)=>{let C=U.runKernel(f2,x,b);return T([I,w,C]),f&&(C=ue(C,[C.shape[1],C.shape[2],C.shape[3]])),{value:C,gradFunc:A}})(p,h):Ns((w,I,T,C)=>{let M=U.runKernel(f2,x,b);return C([I,w,M,T]),f&&(M=ue(M,[M.shape[1],M.shape[2],M.shape[3]])),{value:M,gradFunc:A}})(p,h,g)}var lW=H({fusedDepthwiseConv2d_:iW});function uW({a:e,b:t,transposeA:n=!1,transposeB:r=!1,bias:s,activation:a="linear",preluActivationWeights:o,leakyreluAlpha:i}){if(Dp(U.state.gradientDepth,a)===!1){let M=yt(e,t,n,r);return s!=null&&(M=Me(M,s)),Rp(M,a,o,i)}let l=P(e,"a","fused matMul"),u=P(t,"b","fused matMul");[l,u]=Vt(l,u);let c=n?l.shape[l.rank-2]:l.shape[l.rank-1],d=r?u.shape[u.rank-1]:u.shape[u.rank-2],h=n?l.shape[l.rank-1]:l.shape[l.rank-2],p=r?u.shape[u.rank-2]:u.shape[u.rank-1],f=l.shape.slice(0,-2),m=u.shape.slice(0,-2),g=Jt(f),y=Jt(m);L(l.rank>=2&&u.rank>=2&&l.rank===u.rank,()=>`Error in fused matMul: inputs must have the same rank of at least 2, got ranks ${l.rank} and ${u.rank}.`),L(Xs(f,m),()=>`Error in fused matMul: outer dimensions (${f}) and (${m}) of Tensors with shapes ${l.shape} and ${u.shape} must match.`),L(c===d,()=>`Error in fused matMul: inner shapes (${c}) and (${d}) of Tensors with shapes ${l.shape} and ${u.shape} and transposeA=${n} and transposeB=${r} must match.`);let A=l.shape.slice(0,-2).concat([h,p]),x=n?ue(l,[g,c,h]):ue(l,[g,h,c]),b=r?ue(u,[y,p,d]):ue(u,[y,d,p]),v;s!=null&&(v=P(s,"bias","fused matMul"),[v]=Vt(v,l),In(A,v.shape));let w;o!=null&&(w=P(o,"prelu weights","fused matMul"));let I=(M,$)=>{let[R,N,F,B]=$,j=$p(ue(M,F.shape),F,a),X,Y;if(!n&&!r?(X=yt(j,N,!1,!0),Y=yt(R,j,!0,!1)):!n&&r?(X=yt(j,N,!1,!1),Y=yt(j,R,!0,!1)):n&&!r?(X=yt(N,j,!1,!0),Y=yt(R,j,!1,!1)):(X=yt(N,j,!0,!0),Y=yt(j,R,!0,!0)),s!=null){let ee=_p(B,j);return[X,Y,ee]}else return[X,Y]},T={a:x,b,bias:v,preluActivationWeights:w},C={transposeA:n,transposeB:r,activation:a,leakyreluAlpha:i};return s==null?Ns(($,R,N)=>{let F=U.runKernel(h2,T,C);return N([$,R,F]),{value:ue(F,A),gradFunc:I}})(x,b):Ns(($,R,N,F)=>{let B=U.runKernel(h2,T,C);return F([$,R,B,N]),{value:ue(B,A),gradFunc:I}})(x,b,v)}var cW=H({fusedMatMul_:uW});function dW(e){return cy(e,.54,.46)}var hW=H({hammingWindow_:dW});function pW(e){return cy(e,.5,.5)}var w4=H({hannWindow_:pW});function fW(e,t,n,r=!1,s=0){let a=0,o=[];for(;a+t<=e.size;)o.push(Ze(e,a,t)),a+=n;if(r)for(;a<e.size;){let i=a+t-e.size,l=an([Ze(e,a,t-i),wp([i],s)]);o.push(l),a+=n}return o.length===0?ra([],[0,t]):ue(an(o),[o.length,t])}var k4=H({frame_:fW});function mW(e,t,n,r,s=w4){r==null&&(r=b4(t));let a=k4(e,t,n),o=fe(a,s(t));return ly(o,r)}var gW=H({stft_:mW});function yW(e,t,n,r,s="bilinear",a=0){let o=P(e,"image","cropAndResize"),i=P(t,"boxes","cropAndResize","float32"),l=P(n,"boxInd","cropAndResize","int32"),u=i.shape[0];L(o.rank===4,()=>`Error in cropAndResize: image must be rank 4,but got rank ${o.rank}.`),L(i.rank===2&&i.shape[1]===4,()=>`Error in cropAndResize: boxes must be have size [${u},4] but had shape ${i.shape}.`),L(l.rank===1&&l.shape[0]===u,()=>`Error in cropAndResize: boxInd must be have size [${u}] but had shape ${i.shape}.`),L(r.length===2,()=>`Error in cropAndResize: cropSize must be of length 2, but got length ${r.length}.`),L(r[0]>=1&&r[1]>=1,()=>`cropSize must be atleast [1,1], but was ${r}`),L(s==="bilinear"||s==="nearest",()=>`method must be bilinear or nearest, but was ${s}`);let c={image:o,boxes:i,boxInd:l},d={method:s,extrapolationValue:a,cropSize:r};return U.runKernel($v,c,d)}var AW=H({cropAndResize_:yW});function xW(e){let t=P(e,"image","flipLeftRight","float32");L(t.rank===4,()=>`Error in flipLeftRight: image must be rank 4,but got rank ${t.rank}.`);let n={image:t};return U.runKernel(Kv,n,{})}var bW=H({flipLeftRight_:xW});function vW(e,t,n=0,r=.5){let s=P(e,"image","rotateWithOffset","float32");L(s.rank===4,()=>`Error in rotateWithOffset: image must be rank 4,but got rank ${s.rank}.`);let a={image:s},o={radians:t,fillValue:n,center:r};return U.runKernel(D7,a,o)}var wW=H({rotateWithOffset_:vW});function qi(e,t,n,r,s,a){r==null&&(r=.5),s==null&&(s=Number.NEGATIVE_INFINITY),a==null&&(a=0);let o=e.shape[0];return n=Math.min(n,o),L(0<=r&&r<=1,()=>`iouThreshold must be in [0, 1], but was '${r}'`),L(e.rank===2,()=>`boxes must be a 2D tensor, but was of rank '${e.rank}'`),L(e.shape[1]===4,()=>`boxes must have 4 columns, but 2nd dimension was ${e.shape[1]}`),L(t.rank===1,()=>"scores must be a 1D tensor"),L(t.shape[0]===o,()=>`scores has incompatible shape with boxes. Expected ${o}, but was ${t.shape[0]}`),L(0<=a&&a<=1,()=>`softNmsSigma must be in [0, 1], but was '${a}'`),{maxOutputSize:n,iouThreshold:r,scoreThreshold:s,softNmsSigma:a}}function kW(e,t,n,r=.5,s=Number.NEGATIVE_INFINITY){let a=P(e,"boxes","nonMaxSuppression"),o=P(t,"scores","nonMaxSuppression"),i=qi(a,o,n,r,s);n=i.maxOutputSize,r=i.iouThreshold,s=i.scoreThreshold;let l={maxOutputSize:n,iouThreshold:r,scoreThreshold:s};return U.runKernel(_w,{boxes:a,scores:o},l)}var IW=H({nonMaxSuppression_:kW});function SW(e,t,n){let r=TW(e,t,n),s=r<0?-(r+1):r;e.splice(s,0,t)}function TW(e,t,n){return CW(e,t,n||NW)}function NW(e,t){return e>t?1:e<t?-1:0}function CW(e,t,n){let r=0,s=e.length,a=0,o=!1;for(;r<s;){a=r+(s-r>>>1);let i=n(t,e[a]);i>0?r=a+1:(s=a,o=!i)}return o?r:-r-1}function I4(e,t,n,r,s){return dy(e,t,n,r,s,0)}function S4(e,t,n,r,s,a){return dy(e,t,n,r,s,0,!1,a,!0)}function T4(e,t,n,r,s,a){return dy(e,t,n,r,s,a,!0)}function dy(e,t,n,r,s,a,o=!1,i=!1,l=!1){let u=[];for(let g=0;g<t.length;g++)t[g]>s&&u.push({score:t[g],boxIndex:g,suppressBeginIndex:0});u.sort(N4);let c=a>0?-.5/a:0,d=[],h=[];for(;d.length<n&&u.length>0;){let g=u.pop(),{score:y,boxIndex:A,suppressBeginIndex:x}=g;if(y<s)break;let b=!1;for(let v=d.length-1;v>=x;--v){let w=EW(e,A,d[v]);if(w>=r){b=!0;break}if(g.score=g.score*$W(r,c,w),g.score<=s)break}g.suppressBeginIndex=d.length,b||(g.score===y?(d.push(A),h.push(g.score)):g.score>s&&SW(u,g,N4))}let p=d.length,f=n-p;i&&f>0&&(d.push(...new Array(f).fill(0)),h.push(...new Array(f).fill(0)));let m={selectedIndices:d};return o&&(m.selectedScores=h),l&&(m.validOutputs=p),m}function EW(e,t,n){let r=e.subarray(t*4,t*4+4),s=e.subarray(n*4,n*4+4),a=Math.min(r[0],r[2]),o=Math.min(r[1],r[3]),i=Math.max(r[0],r[2]),l=Math.max(r[1],r[3]),u=Math.min(s[0],s[2]),c=Math.min(s[1],s[3]),d=Math.max(s[0],s[2]),h=Math.max(s[1],s[3]),p=(i-a)*(l-o),f=(d-u)*(h-c);if(p<=0||f<=0)return 0;let m=Math.max(a,u),g=Math.max(o,c),y=Math.min(i,d),A=Math.min(l,h),x=Math.max(y-m,0)*Math.max(A-g,0);return x/(p+f-x)}function $W(e,t,n){let r=Math.exp(t*n*n);return n<=e?r:0}function N4(e,t){return e.score-t.score||e.score===t.score&&t.boxIndex-e.boxIndex}async function _W(e,t,n,r=.5,s=Number.NEGATIVE_INFINITY){let a=P(e,"boxes","nonMaxSuppressionAsync"),o=P(t,"scores","nonMaxSuppressionAsync"),i=qi(a,o,n,r,s);n=i.maxOutputSize,r=i.iouThreshold,s=i.scoreThreshold;let l=await Promise.all([a.data(),o.data()]),u=l[0],c=l[1],{selectedIndices:d}=I4(u,c,n,r,s);return a!==e&&a.dispose(),o!==t&&o.dispose(),lr(d,"int32")}var RW=_W;function DW(e,t,n,r=.5,s=Number.NEGATIVE_INFINITY,a=0){let o=P(e,"boxes","nonMaxSuppression"),i=P(t,"scores","nonMaxSuppression"),l=qi(o,i,n,r,s,a);n=l.maxOutputSize,r=l.iouThreshold,s=l.scoreThreshold,a=l.softNmsSigma;let u={boxes:o,scores:i},c={maxOutputSize:n,iouThreshold:r,scoreThreshold:s,softNmsSigma:a},d=U.runKernel(Dw,u,c);return{selectedIndices:d[0],selectedScores:d[1]}}var FW=H({nonMaxSuppressionWithScore_:DW});async function MW(e,t,n,r=.5,s=Number.NEGATIVE_INFINITY,a=0){let o=P(e,"boxes","nonMaxSuppressionAsync"),i=P(t,"scores","nonMaxSuppressionAsync"),l=qi(o,i,n,r,s,a);n=l.maxOutputSize,r=l.iouThreshold,s=l.scoreThreshold,a=l.softNmsSigma;let u=await Promise.all([o.data(),i.data()]),c=u[0],d=u[1],{selectedIndices:h,selectedScores:p}=T4(c,d,n,r,s,a);return o!==e&&o.dispose(),i!==t&&i.dispose(),{selectedIndices:lr(h,"int32"),selectedScores:lr(p)}}var OW=MW;function PW(e,t,n,r=.5,s=Number.NEGATIVE_INFINITY,a=!1){let o=P(e,"boxes","nonMaxSuppression"),i=P(t,"scores","nonMaxSuppression"),l=qi(o,i,n,r,s,null),u=l.maxOutputSize,c=l.iouThreshold,d=l.scoreThreshold,h={boxes:o,scores:i},p={maxOutputSize:u,iouThreshold:c,scoreThreshold:d,padToMaxOutputSize:a},f=U.runKernel(Rw,h,p);return{selectedIndices:f[0],validOutputs:f[1]}}var zW=H({nonMaxSuppressionPadded_:PW});async function LW(e,t,n,r=.5,s=Number.NEGATIVE_INFINITY,a=!1){let o=P(e,"boxes","nonMaxSuppressionAsync"),i=P(t,"scores","nonMaxSuppressionAsync"),l=qi(o,i,n,r,s,null),u=l.maxOutputSize,c=l.iouThreshold,d=l.scoreThreshold,[h,p]=await Promise.all([o.data(),i.data()]),{selectedIndices:f,validOutputs:m}=S4(h,p,u,c,d,a);return o!==e&&o.dispose(),i!==t&&i.dispose(),{selectedIndices:lr(f,"int32"),validOutputs:ut(m,"int32")}}var BW=LW;function WW(e,t,n=!1,r=!1){let s=P(e,"images","resizeBilinear");L(s.rank===3||s.rank===4,()=>`Error in resizeBilinear: x must be rank 3 or 4, but got rank ${s.rank}.`),L(t.length===2,()=>`Error in resizeBilinear: new shape must 2D, but got shape ${t}.`),L(r===!1||n===!1,()=>"Error in resizeBilinear: If halfPixelCenters is true, alignCorners must be false.");let a=s,o=!1;s.rank===3&&(o=!0,a=ue(s,[1,s.shape[0],s.shape[1],s.shape[2]]));let[]=t,i={images:a},l={alignCorners:n,halfPixelCenters:r,size:t},u=U.runKernel(qw,i,l);return o?ue(u,[u.shape[1],u.shape[2],u.shape[3]]):u}var VW=H({resizeBilinear_:WW});function UW(e,t,n=!1,r=!1){let s=P(e,"images","resizeNearestNeighbor");L(s.rank===3||s.rank===4,()=>`Error in resizeNearestNeighbor: x must be rank 3 or 4, but got rank ${s.rank}.`),L(t.length===2,()=>`Error in resizeNearestNeighbor: new shape must 2D, but got shape ${t}.`),L(s.dtype==="float32"||s.dtype==="int32",()=>"`images` must have `int32` or `float32` as dtype"),L(r===!1||n===!1,()=>"Error in resizeNearestNeighbor: If halfPixelCenters is true, alignCorners must be false.");let a=s,o=!1;s.rank===3&&(o=!0,a=ue(s,[1,s.shape[0],s.shape[1],s.shape[2]]));let[]=t,i={images:a},l={alignCorners:n,halfPixelCenters:r,size:t},u=U.runKernel(jw,i,l);return o?ue(u,[u.shape[1],u.shape[2],u.shape[3]]):u}var HW=H({resizeNearestNeighbor_:UW});function GW(e,t="binary",n=!1,r=.5){let s=P(e,"image","threshold"),a=.2989,o=.587,i=.114,l=s.shape[0]*s.shape[1],u=fe(lr([r]),255),c,d,h,p;if(L(s.rank===3,()=>`Error in threshold: image must be rank 3,but got rank ${s.rank}.`),L(s.shape[2]===3||s.shape[2]===1,()=>`Error in threshold: image color channel must be equal to 3 or 1but got ${s.shape[2]}.`),L(s.dtype==="int32"||s.dtype==="float32",()=>`Error in dtype: image dtype must be int32 or float32,but got dtype ${s.dtype}.`),L(t==="otsu"||t==="binary",()=>`Method must be binary or otsu, but was ${t}`),s.shape[2]===3){[c,d,h]=ta(s,[1,1,1],-1);let g=fe(c,a),y=fe(d,o),A=fe(h,i);p=Me(Me(g,y),A)}else p=e;if(t==="otsu"){let g=Vk(Pt(p4(p),"int32"),ts([]),256);u=jW(g,l)}let f=n?ny(p,u):kp(p,u);return Pt(fe(f,255),"int32")}function jW(e,t){let n=lr([-1]),r=lr([0]),s=lr([0]),a,o,i,l,u,c;for(let d=0;d<e.size-1;d++){a=Ze(e,0,d+1),o=Ze(e,d+1),u=Qe(_t(a),t),c=Qe(_t(o),t);let h=_t(fe(a,pc(0,a.size)));i=Qe(h,_t(a));let p=wp(o.shape,a.size),f=Me(pc(0,o.size),p),m=fe(o,f);l=Qe(_t(m),_t(o));let g=He(i,l),y=He(i,l),A=fe(u,c);s=fe(fe(A,g),y);let x=kp(s,r);r=Gi(x,s,r),n=Gi(x,lr([d]),n)}return n}var qW=H({threshold_:GW});function KW(e,t,n="nearest",r="constant",s=0,a){let o=P(e,"image","transform","float32"),i=P(t,"transforms","transform","float32");L(o.rank===4,()=>`Error in transform: image must be rank 4,but got rank ${o.rank}.`),L(i.rank===2&&(i.shape[0]===o.shape[0]||i.shape[0]===1)&&i.shape[1]===8,()=>"Error in transform: Input transform should be batch x 8 or 1 x 8"),L(a==null||a.length===2,()=>`Error in transform: outputShape must be [height, width] or null, but got ${a}.`);let l={image:o,transforms:i},u={interpolation:n,fillMode:r,fillValue:s,outputShape:a};return U.runKernel(T7,l,u)}var XW=H({transform_:KW});function ZW(e,t,n){L(t%1==0,()=>`bandPart(): numLower must be an integer, got ${t}.`),L(n%1==0,()=>`bandPart(): numUpper must be an integer, got ${n}.`);let r=P(e,"a","bandPart");L(r.rank>=2,()=>`bandPart(): Rank must be at least 2, got ${r.rank}.`);let s=r.shape,[a,o]=r.shape.slice(-2);if(!(t<=a))throw new Error(`bandPart(): numLower (${t}) must not be greater than the number of rows (${a}).`);if(!(n<=o))throw new Error(`bandPart(): numUpper (${n}) must not be greater than the number of columns (${o}).`);t<0&&(t=a),n<0&&(n=o);let i=ue(pc(0,a,1,"int32"),[-1,1]),l=pc(0,o,1,"int32"),u=He(i,l),c=Sp(ny(u,ut(+t,"int32")),Zk(u,ut(-n,"int32"))),d=ji([a,o],r.dtype);return ue(So(fc(ue(r,[-1,a,o])).map(h=>Gi(c,h,d))),s)}var YW=H({bandPart_:ZW});function JW(e){let t;if(Array.isArray(e)){t=!1,L(e!=null&&e.length>0,()=>"Gram-Schmidt process: input must not be null, undefined, or empty");let s=e[0].shape[0];for(let a=1;a<e.length;++a)L(e[a].shape[0]===s,()=>`Gram-Schmidt: Non-unique lengths found in the input vectors: (${e[a].shape[0]} vs. ${s})`)}else t=!0,e=ta(e,e.shape[0],0).map(s=>Zn(s,[0]));L(e.length<=e[0].shape[0],()=>`Gram-Schmidt: Number of vectors (${e.length}) exceeds number of dimensions (${e[0].shape[0]}).`);let n=[],r=e;for(let s=0;s<e.length;++s)n.push(U.tidy(()=>{let a=r[s];if(s>0)for(let o=0;o<s;++o){let i=fe(_t(fe(n[o],a)),n[o]);a=He(a,i)}return Qe(a,uy(a,"euclidean"))}));return t?So(n,0):n}var QW=H({gramSchmidt_:JW});function eV(e,t=!1){if(L(e.rank>=2,()=>`qr() requires input tensor to have a rank >= 2, but got rank ${e.rank}`),e.rank===2)return C4(e,t);{let n=e.shape.slice(0,e.shape.length-2).reduce((l,u)=>l*u),r=fc(ue(e,[n,e.shape[e.shape.length-2],e.shape[e.shape.length-1]]),0),s=[],a=[];r.forEach(l=>{let[u,c]=C4(l,t);s.push(u),a.push(c)});let o=ue(So(s,0),e.shape),i=ue(So(a,0),e.shape);return[o,i]}}function C4(e,t=!1){return U.tidy(()=>{L(e.shape.length===2,()=>`qr2d() requires a 2D Tensor, but got a ${e.shape.length}D Tensor.`);let n=e.shape[0],r=e.shape[1],s=qk(n),a=Js(e),o=ra([[1]],[1,1]),i=Js(o),l=n>=r?r:n;for(let u=0;u<l;++u){let c=a,d=i,h=s;[i,a,s]=U.tidy(()=>{let p=Ze(a,[u,u],[n-u,1]),f=uy(p),m=Ze(a,[u,u],[1,1]),g=Gi(kp(m,0),ra([[-1]]),ra([[1]])),y=He(m,fe(g,f)),A=Qe(p,y);A.shape[0]===1?i=Js(o):i=an([o,Ze(A,[1,0],[A.shape[0]-1,A.shape[1]])],0);let x=$a(Qe(yt(g,y),f)),b=Ze(a,[u,0],[n-u,r]),v=fe(x,i),w=fp(i);if(u===0)a=He(b,yt(v,yt(w,b)));else{let C=He(b,yt(v,yt(w,b)));a=an([Ze(a,[0,0],[u,r]),C],0)}let I=fp(v),T=Ze(s,[0,u],[n,s.shape[1]-u]);if(u===0)s=He(T,yt(yt(T,i),I));else{let C=He(T,yt(yt(T,i),I));s=an([Ze(s,[0,0],[n,u]),C],1)}return[i,a,s]}),Ve([c,d,h])}return!t&&n>r&&(s=Ze(s,[0,0],[n,r]),a=Ze(a,[0,0],[r,r])),[s,a]})}var tV=H({qr_:eV}),Pn;(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"})(Pn||(Pn={}));function nV(e,t,n=Pn.SUM_BY_NONZERO_WEIGHTS){let r=P(e,"losses","computeWeightedLoss"),s=null;t!=null&&(s=P(t,"weights","computeWeightedLoss"));let a=s==null?r:fe(r,s);if(n===Pn.NONE)return a;if(n===Pn.SUM)return _t(a);if(n===Pn.MEAN){if(s==null)return Tp(a);{let o=r.size/s.size,i=Qe(_t(a),_t(s));return o>1?Qe(i,ut(o)):i}}if(n===Pn.SUM_BY_NONZERO_WEIGHTS){if(s==null)return Qe(_t(a),ut(r.size));{let o=fe(s,ko(r.shape)),i=Pt(_t(l4(o,ut(0))),"float32");return Qe(_t(a),i)}}throw Error(`Unknown reduction: ${n}`)}var sa=H({computeWeightedLoss_:nV});function rV(e,t,n,r=Pn.SUM_BY_NONZERO_WEIGHTS){let s=P(e,"labels","absoluteDifference"),a=P(t,"predictions","absoluteDifference"),o=null;n!=null&&(o=P(n,"weights","absoluteDifference")),Mn(s.shape,a.shape,"Error in absoluteDifference: ");let i=Nr(He(s,a));return sa(i,o,r)}var sV=H({absoluteDifference_:rV});function aV(e,t,n,r,s=Pn.SUM_BY_NONZERO_WEIGHTS){let a=P(e,"labels","cosineDistance"),o=P(t,"predictions","cosineDistance"),i=null;r!=null&&(i=P(r,"weights","cosineDistance")),Mn(a.shape,o.shape,"Error in cosineDistance: ");let l=ut(1),u=He(l,_t(fe(a,o),n,!0));return sa(u,i,s)}var oV=H({cosineDistance_:aV});function iV(e,t,n,r=Pn.SUM_BY_NONZERO_WEIGHTS){let s=P(e,"labels","hingeLoss"),a=P(t,"predictions","hingeLoss"),o=null;n!=null&&(o=P(n,"weights","hingeLoss")),Mn(s.shape,a.shape,"Error in hingeLoss: ");let i=ut(1);s=He(fe(ut(2),s),i);let l=Cp(He(i,fe(s,a)));return sa(l,o,r)}var lV=H({hingeLoss_:iV});function uV(e,t,n,r=1,s=Pn.SUM_BY_NONZERO_WEIGHTS){let a=P(e,"labels","huberLoss"),o=P(t,"predictions","huberLoss"),i=null;n!=null&&(i=P(n,"weights","huberLoss")),Mn(a.shape,o.shape,"Error in huberLoss: ");let l=ut(r),u=Nr(He(o,a)),c=i4(u,l),d=He(u,c),h=Me(fe(ut(.5),ns(c)),fe(l,d));return sa(h,i,s)}var cV=H({huberLoss_:uV});function dV(e,t,n,r=1e-7,s=Pn.SUM_BY_NONZERO_WEIGHTS){let a=P(e,"labels","logLoss"),o=P(t,"predictions","logLoss"),i=null;n!=null&&(i=P(n,"weights","logLoss")),Mn(a.shape,o.shape,"Error in logLoss: ");let l=ut(1),u=ut(r),c=$a(fe(a,uc(Me(o,u)))),d=fe(He(l,a),uc(Me(He(l,o),u))),h=He(c,d);return sa(h,i,s)}var hV=H({logLoss_:dV});function pV(e,t,n,r=Pn.SUM_BY_NONZERO_WEIGHTS){let s=P(e,"labels","meanSquaredError"),a=P(t,"predictions","meanSquaredError"),o=null;n!=null&&(o=P(n,"weights","meanSquaredError")),Mn(s.shape,a.shape,"Error in meanSquaredError: ");let i=m4(s,a);return sa(i,o,r)}var fV=H({meanSquaredError_:pV});function mV(e,t){let n=P(e,"labels","sigmoidCrossEntropyWithLogits"),r=P(t,"logits","sigmoidCrossEntropyWithLogits");Mn(n.shape,r.shape,"Error in sigmoidCrossEntropyWithLogits: ");let s=Cp(r),a=fe(r,n),o=Jk(wo($a(Nr(r))));return Me(He(s,a),o)}function gV(e,t,n,r=0,s=Pn.SUM_BY_NONZERO_WEIGHTS){let a=P(e,"multiClassLabels","sigmoidCrossEntropy"),o=P(t,"logits","sigmoidCrossEntropy"),i=null;if(n!=null&&(i=P(n,"weights","sigmoidCrossEntropy")),Mn(a.shape,o.shape,"Error in sigmoidCrossEntropy: "),r>0){let u=ut(r),c=ut(1),d=ut(.5);a=Me(fe(a,He(c,u)),fe(d,u))}let l=mV(a,o);return sa(l,i,s)}var yV=H({sigmoidCrossEntropy_:gV});function AV(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 Ns((s,a,o)=>{let l=n4(a,[n],!0),u=He(Pt(a,"float32"),l);o([s,u]);let c=$a(fe(u,s));return{value:_t(c,[n]),gradFunc:(p,f)=>{let[m,g]=f,y=cc(p.shape,[n]);return[fe(ue(p,y),He(Pt(m,"float32"),wo(g))),fe(ue(p,y),He(wo(g),Pt(m,"float32")))]}}})(e,t)}function xV(e,t,n,r=0,s=Pn.SUM_BY_NONZERO_WEIGHTS){let a=P(e,"onehotLabels","softmaxCrossEntropy"),o=P(t,"logits","softmaxCrossEntropy"),i=null;if(n!=null&&(i=P(n,"weights","softmaxCrossEntropy")),Mn(a.shape,o.shape,"Error in softmaxCrossEntropy: "),r>0){let u=ut(r),c=ut(1),d=ut(a.shape[1]);a=Me(fe(a,He(c,u)),Qe(u,d))}let l=AV(a,o);return sa(l,i,s)}var bV=H({softmaxCrossEntropy_:xV});function vV(e,t,n,r){let s=P(e,"indices","sparseFillEmptyRows"),a=P(t,"values","sparseFillEmptyRows"),o=P(n,"denseShape","sparseFillEmptyRows"),i=P(r,"defaultValue","sparseFillEmptyRows",a.dtype);if(s.rank!==2)throw new Error(`Indices should be Tensor2D but received shape
|
|
${s.shape}`);if(a.rank!==1)throw new Error(`Values should be Tensor1D but received shape ${a.shape}`);if(o.rank!==1)throw new Error(`Dense shape should be Tensor1D but received shape ${o.shape}`);if(i.rank!==0)throw new Error(`Default value should be a scalar but received shape ${i.shape}`);let l={indices:s,values:a,denseShape:o,defaultValue:i},u=U.runKernel(h7,l);return{outputIndices:u[0],outputValues:u[1],emptyRowIndicator:u[2],reverseIndexMap:u[3]}}var wV=H({sparseFillEmptyRows_:vV});function kV(e,t,n){let r=P(e,"inputIndices","sparseReshape"),s=P(t,"inputShape","sparseReshape"),a=P(n,"newShape","sparseReshape");if(r.rank!==2)throw new Error(`Input indices should be Tensor2D but received shape
|
|
${r.shape}`);if(s.rank!==1)throw new Error(`Input shape should be Tensor1D but received shape ${s.shape}`);if(a.rank!==1)throw new Error(`New shape should be Tensor1D but received shape ${a.shape}`);let o={inputIndices:r,inputShape:s,newShape:a},i=U.runKernel(p7,o);return{outputIndices:i[0],outputShape:i[1]}}var IV=H({sparseReshape_:kV});function SV(e,t,n){let r=P(e,"data","sparseSegmentMean"),s=P(t,"indices","sparseSegmentMean"),a=P(n,"segmentIds","sparseSegmentMean");if(r.rank<1)throw new Error("Data should be at least 1 dimensional but received scalar");if(s.rank!==1)throw new Error(`Indices should be Tensor1D but received shape
|
|
${s.shape}`);if(a.rank!==1)throw new Error(`Segment ids should be Tensor1D but received shape
|
|
${a.shape}`);let o={data:r,indices:s,segmentIds:a};return U.runKernel(f7,o)}var TV=H({sparseSegmentMean_:SV});function NV(e,t,n){let r=P(e,"data","sparseSegmentSum"),s=P(t,"indices","sparseSegmentSum"),a=P(n,"segmentIds","sparseSegmentSum");if(r.rank<1)throw new Error("Data should be at least 1 dimensional but received scalar");if(s.rank!==1)throw new Error(`Indices should be Tensor1D but received shape
|
|
${s.shape}`);if(a.rank!==1)throw new Error(`Segment ids should be Tensor1D but received shape
|
|
${a.shape}`);let o={data:r,indices:s,segmentIds:a};return U.runKernel(m7,o)}var CV=H({sparseSegmentSum_:NV});function EV(e,t,n,r,s,a,o,i){let l=P(e,"data","stringNGrams","string");if(l.dtype!=="string")throw new Error("Data must be of datatype string");if(l.shape.length!==1)throw new Error(`Data must be a vector, saw: ${l.shape}`);let u=P(t,"dataSplits","stringNGrams");if(u.dtype!=="int32")throw new Error("Data splits must be of datatype int32");let c={separator:n,nGramWidths:r,leftPad:s,rightPad:a,padWidth:o,preserveShortSequences:i},d={data:l,dataSplits:u},h=U.runKernel(x7,d,c);return{nGrams:h[0],nGramsSplits:h[1]}}var $V=H({stringNGrams_:EV});function _V(e,t,n=!0){let r=P(e,"input","stringSplit","string"),s=P(t,"delimiter","stringSplit","string");if(r.rank!==1)throw new Error(`Input should be Tensor1D but received shape ${r.shape}`);if(s.rank!==0)throw new Error(`Delimiter should be a scalar but received shape ${s.shape}`);let a={skipEmpty:n},o={input:r,delimiter:s},i=U.runKernel(b7,o,a);return{indices:i[0],values:i[1],shape:i[2]}}var RV=H({stringSplit_:_V});function DV(e,t){let n=P(e,"input","stringToHashBucketFast","string"),r={numBuckets:t};if(t<=0)throw new Error("Number of buckets must be at least 1");let s={input:n};return U.runKernel(v7,s,r)}var FV=H({stringToHashBucketFast_:DV}),MV={fft:iy,ifft:Ep,rfft:ly,irfft:f4},OV={hammingWindow:hW,hannWindow:w4,frame:k4,stft:gW},Ye={flipLeftRight:bW,resizeNearestNeighbor:HW,resizeBilinear:VW,rotateWithOffset:wW,cropAndResize:AW,nonMaxSuppression:IW,nonMaxSuppressionAsync:RW,nonMaxSuppressionWithScore:FW,nonMaxSuppressionWithScoreAsync:OW,nonMaxSuppressionPadded:zW,nonMaxSuppressionPaddedAsync:BW,threshold:qW,transform:XW},PV={bandPart:YW,gramSchmidt:QW,qr:tV},zV={absoluteDifference:sV,computeWeightedLoss:sa,cosineDistance:oV,hingeLoss:lV,huberLoss:cV,logLoss:hV,meanSquaredError:fV,sigmoidCrossEntropy:yV,softmaxCrossEntropy:bV},LV={sparseFillEmptyRows:wV,sparseReshape:IV,sparseSegmentMean:TV,sparseSegmentSum:CV},BV={stringNGrams:$V,stringSplit:RV,stringToHashBucketFast:FV},Ra=class extends $k{minimize(e,t=!1,n){let{value:r,grads:s}=this.computeGradients(e,n);if(n!=null){let a=n.map(o=>({name:o.name,tensor:s[o.name]}));this.applyGradients(a)}else this.applyGradients(s);return Ve(s),t?r:(r.dispose(),null)}get iterations(){return this.iterations_==null&&(this.iterations_=0),this.iterations_}incrementIterations(){this.iterations_=this.iterations+1}computeGradients(e,t){return Qk(e,t)}dispose(){this.iterations_!=null&&Ve(this.iterations_)}async saveIterations(){return this.iterations_==null&&(this.iterations_=0),{name:"iter",tensor:ut(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(Ra,Symbol.hasInstance,{value:e=>e.minimize!=null&&e.computeGradients!=null&&e.applyGradients!=null});var Fp=class extends Ra{constructor(e,t,n=null){super();this.learningRate=e,this.rho=t,this.epsilon=n,this.accumulatedGrads=[],this.accumulatedUpdates=[],n==null&&(this.epsilon=U.backend.epsilon())}applyGradients(e){(Array.isArray(e)?e.map(n=>n.name):Object.keys(e)).forEach((n,r)=>{let s=U.registeredVariables[n],a=!1;this.accumulatedGrads[r]==null&&(this.accumulatedGrads[r]={originalName:`${n}/accum_grad`,variable:Ue(()=>Cr(s).variable(a))}),this.accumulatedUpdates[r]==null&&(this.accumulatedUpdates[r]={originalName:`${n}/accum_var`,variable:Ue(()=>Cr(s).variable(a))});let o=Array.isArray(e)?e[r].tensor:e[n];if(o==null)return;let i=this.accumulatedGrads[r].variable,l=this.accumulatedUpdates[r].variable;Ue(()=>{let u=Me(fe(i,this.rho),fe(ns(o),1-this.rho)),c=fe(Qe(na(Me(l,this.epsilon)),na(Me(i,this.epsilon))),o),d=Me(fe(l,this.rho),fe(ns(c),1-this.rho));i.assign(u),l.assign(d);let h=Me(fe(c,-this.learningRate),s);s.assign(h)})}),this.incrementIterations()}dispose(){this.accumulatedUpdates!=null&&(Ve(this.accumulatedGrads.map(e=>e.variable)),Ve(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(r=>({originalName:r.name,variable:r.tensor.variable(n)})),this.accumulatedUpdates=e.slice(t,t*2).map(r=>({originalName:r.name,variable:r.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)}};Fp.className="Adadelta";Ea(Fp);var Mp=class extends Ra{constructor(e,t=.1){super();this.learningRate=e,this.initialAccumulatorValue=t,this.accumulatedGrads=[]}applyGradients(e){(Array.isArray(e)?e.map(n=>n.name):Object.keys(e)).forEach((n,r)=>{let s=U.registeredVariables[n];if(this.accumulatedGrads[r]==null){let i=!1;this.accumulatedGrads[r]={originalName:`${n}/accumulator`,variable:Ue(()=>wp(s.shape,this.initialAccumulatorValue).variable(i))}}let a=Array.isArray(e)?e[r].tensor:e[n];if(a==null)return;let o=this.accumulatedGrads[r].variable;Ue(()=>{let i=Me(o,ns(a));o.assign(i);let l=Me(fe(Qe(a,na(Me(i,U.backend.epsilon()))),-this.learningRate),s);s.assign(l)})}),this.incrementIterations()}dispose(){this.accumulatedGrads!=null&&Ve(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)}};Mp.className="Adagrad";Ea(Mp);var Op=class extends Ra{constructor(e,t,n,r=null){super();this.learningRate=e,this.beta1=t,this.beta2=n,this.epsilon=r,this.accumulatedFirstMoment=[],this.accumulatedSecondMoment=[],Ue(()=>{this.accBeta1=ut(t).variable(),this.accBeta2=ut(n).variable()}),r==null&&(this.epsilon=U.backend.epsilon())}applyGradients(e){let t=Array.isArray(e)?e.map(n=>n.name):Object.keys(e);Ue(()=>{let n=He(1,this.accBeta1),r=He(1,this.accBeta2);t.forEach((s,a)=>{let o=U.registeredVariables[s],i=!1;this.accumulatedFirstMoment[a]==null&&(this.accumulatedFirstMoment[a]={originalName:`${s}/m`,variable:Ue(()=>Cr(o).variable(i))}),this.accumulatedSecondMoment[a]==null&&(this.accumulatedSecondMoment[a]={originalName:`${s}/v`,variable:Ue(()=>Cr(o).variable(i))});let l=Array.isArray(e)?e[a].tensor:e[s];if(l==null)return;let u=this.accumulatedFirstMoment[a].variable,c=this.accumulatedSecondMoment[a].variable,d=Me(fe(u,this.beta1),fe(l,1-this.beta1)),h=Me(fe(c,this.beta2),fe(ns(l),1-this.beta2)),p=Qe(d,n),f=Qe(h,r);u.assign(d),c.assign(h);let m=Me(fe(Qe(p,Me(na(f),this.epsilon)),-this.learningRate),o);o.assign(m)}),this.accBeta1.assign(fe(this.accBeta1,this.beta1)),this.accBeta2.assign(fe(this.accBeta2,this.beta2))}),this.incrementIterations()}dispose(){this.accBeta1.dispose(),this.accBeta2.dispose(),this.accumulatedFirstMoment!=null&&Ve(this.accumulatedFirstMoment.map(e=>e.variable)),this.accumulatedSecondMoment!=null&&Ve(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),Ue(()=>{this.accBeta1.assign(hc(this.beta1,this.iterations_+1)),this.accBeta2.assign(hc(this.beta2,this.iterations_+1))});let t=e.length/2,n=!1;this.accumulatedFirstMoment=e.slice(0,t).map(r=>({originalName:r.name,variable:r.tensor.variable(n)})),this.accumulatedSecondMoment=e.slice(t,t*2).map(r=>({originalName:r.name,variable:r.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)}};Op.className="Adam";Ea(Op);var Pp=class extends Ra{constructor(e,t,n,r=null,s=0){super();this.learningRate=e,this.beta1=t,this.beta2=n,this.epsilon=r,this.decay=s,this.accumulatedFirstMoment=[],this.accumulatedWeightedInfNorm=[],Ue(()=>{this.iteration=ut(0).variable(),this.accBeta1=ut(t).variable()}),r==null&&(this.epsilon=U.backend.epsilon())}applyGradients(e){let t=Array.isArray(e)?e.map(n=>n.name):Object.keys(e);Ue(()=>{let n=He(1,this.accBeta1),r=Qe(-this.learningRate,Me(fe(this.iteration,this.decay),1));t.forEach((s,a)=>{let o=U.registeredVariables[s],i=!1;this.accumulatedFirstMoment[a]==null&&(this.accumulatedFirstMoment[a]={originalName:`${s}/m`,variable:Cr(o).variable(i)}),this.accumulatedWeightedInfNorm[a]==null&&(this.accumulatedWeightedInfNorm[a]={originalName:`${s}/v`,variable:Cr(o).variable(i)});let l=Array.isArray(e)?e[a].tensor:e[s];if(l==null)return;let u=this.accumulatedFirstMoment[a].variable,c=this.accumulatedWeightedInfNorm[a].variable,d=Me(fe(u,this.beta1),fe(l,1-this.beta1)),h=fe(c,this.beta2),p=Nr(l),f=o4(h,p);u.assign(d),c.assign(f);let m=Me(fe(Qe(r,n),Qe(d,Me(f,this.epsilon))),o);o.assign(m)}),this.iteration.assign(Me(this.iteration,1)),this.accBeta1.assign(fe(this.accBeta1,this.beta1))}),this.incrementIterations()}dispose(){this.accBeta1.dispose(),this.iteration.dispose(),this.accumulatedFirstMoment!=null&&Ve(this.accumulatedFirstMoment.map(e=>e.variable)),this.accumulatedWeightedInfNorm!=null&&Ve(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)}};Pp.className="Adamax";Ea(Pp);var mc=class extends Ra{constructor(e){super();this.learningRate=e,this.setLearningRate(e)}applyGradients(e){(Array.isArray(e)?e.map(n=>n.name):Object.keys(e)).forEach((n,r)=>{let s=Array.isArray(e)?e[r].tensor:e[n];if(s==null)return;let a=U.registeredVariables[n];Ue(()=>{let o=Me(fe(this.c,s),a);a.assign(o)})}),this.incrementIterations()}setLearningRate(e){this.learningRate=e,this.c!=null&&this.c.dispose(),this.c=Mk(ut(-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)}};mc.className="SGD";Ea(mc);var zp=class extends mc{constructor(e,t,n=!1){super(e);this.learningRate=e,this.momentum=t,this.useNesterov=n,this.accumulations=[],this.m=ut(this.momentum)}applyGradients(e){(Array.isArray(e)?e.map(n=>n.name):Object.keys(e)).forEach((n,r)=>{let s=U.registeredVariables[n];if(this.accumulations[r]==null){let i=!1;this.accumulations[r]={originalName:`${n}/momentum`,variable:Ue(()=>Cr(s).variable(i))}}let a=this.accumulations[r].variable,o=Array.isArray(e)?e[r].tensor:e[n];o!=null&&Ue(()=>{let i,l=Me(fe(this.m,a),o);this.useNesterov?i=Me(fe(this.c,Me(o,fe(l,this.m))),s):i=Me(fe(this.c,l),s),a.assign(l),s.assign(i)})}),this.incrementIterations()}dispose(){this.m.dispose(),this.accumulations!=null&&Ve(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)}};zp.className="Momentum";Ea(zp);var Lp=class extends Ra{constructor(e,t=.9,n=0,r=null,s=!1){super();if(this.learningRate=e,this.decay=t,this.momentum=n,this.epsilon=r,this.accumulatedMeanSquares=[],this.accumulatedMoments=[],this.accumulatedMeanGrads=[],this.centered=s,r==null&&(this.epsilon=U.backend.epsilon()),e==null)throw new Error("learningRate for RMSPropOptimizer must be defined.")}applyGradients(e){(Array.isArray(e)?e.map(n=>n.name):Object.keys(e)).forEach((n,r)=>{let s=U.registeredVariables[n],a=!1;this.accumulatedMeanSquares[r]==null&&(this.accumulatedMeanSquares[r]={originalName:`${n}/rms`,variable:Ue(()=>Cr(s).variable(a))}),this.accumulatedMoments[r]==null&&(this.accumulatedMoments[r]={originalName:`${n}/momentum`,variable:Ue(()=>Cr(s).variable(a))}),this.accumulatedMeanGrads[r]==null&&this.centered&&(this.accumulatedMeanGrads[r]={originalName:`${n}/mg`,variable:Ue(()=>Cr(s).variable(a))});let o=Array.isArray(e)?e[r].tensor:e[n];if(o==null)return;let i=this.accumulatedMeanSquares[r].variable,l=this.accumulatedMoments[r].variable;Ue(()=>{let u=Me(fe(i,this.decay),fe(ns(o),1-this.decay));if(this.centered){let c=this.accumulatedMeanGrads[r].variable,d=Me(fe(c,this.decay),fe(o,1-this.decay)),h=Qe(fe(o,this.learningRate),na(He(u,Me(ns(d),this.epsilon)))),p=Me(fe(l,this.momentum),h);i.assign(u),c.assign(d),l.assign(p);let f=He(s,p);s.assign(f)}else{let c=Me(fe(i,this.decay),fe(ns(o),1-this.decay)),d=Me(fe(l,this.momentum),Qe(fe(o,this.learningRate),na(Me(c,this.epsilon))));i.assign(c),l.assign(d);let h=He(s,d);s.assign(h)}})}),this.incrementIterations()}dispose(){this.accumulatedMeanSquares!=null&&Ve(this.accumulatedMeanSquares.map(e=>e.variable)),this.accumulatedMeanGrads!=null&&this.centered&&Ve(this.accumulatedMeanGrads.map(e=>e.variable)),this.accumulatedMoments!=null&&Ve(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(r=>({originalName:r.name,variable:r.tensor.variable(n)})),this.accumulatedMoments=e.slice(t,t*2).map(r=>({originalName:r.name,variable:r.tensor.variable(n)})),this.centered&&(this.accumulatedMeanGrads=e.slice(t*2,t*3).map(r=>({originalName:r.name,variable:r.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)}};Lp.className="RMSProp";Ea(Lp);var To=class{static sgd(e){return new mc(e)}static momentum(e,t,n=!1){return new zp(e,t,n)}static rmsprop(e,t=.9,n=0,r=null,s=!1){return new Lp(e,t,n,r,s)}static adam(e=.001,t=.9,n=.999,r=null){return new Op(e,t,n,r)}static adadelta(e=.001,t=.95,n=null){return new Fp(e,t,n)}static adamax(e=.002,t=.9,n=.999,r=null,s=0){return new Pp(e,t,n,r,s)}static adagrad(e,t=.1){return new Mp(e,t)}},WV={sgd:To.sgd,momentum:To.momentum,adadelta:To.adadelta,adagrad:To.adagrad,rmsprop:To.rmsprop,adamax:To.adamax,adam:To.adam},VV=(()=>typeof requestAnimationFrame!="undefined"?requestAnimationFrame:typeof setImmediate!="undefined"?setImmediate:e=>e())();function UV(){return new Promise(e=>VV(()=>e()))}var E4={};De(E4,{ERF_A1:()=>nU,ERF_A2:()=>rU,ERF_A3:()=>sU,ERF_A4:()=>aU,ERF_A5:()=>oU,ERF_P:()=>tU,PARALLELIZE_THRESHOLD:()=>hy,SELU_SCALE:()=>eU,SELU_SCALEALPHA:()=>QV,applyActivation:()=>Rp,assertAndGetBroadcastShape:()=>In,assertAxesAreInnerMostDims:()=>fz,assertParamsConsistent:()=>HV,assignToTypedArray:()=>fU,axesAreInnerMostDims:()=>ry,calculateShapes:()=>Ak,checkEinsumDimSizes:()=>bU,combineLocations:()=>t4,complexWithEvenIndex:()=>dU,complexWithOddIndex:()=>hU,computeConv2DInfo:()=>oc,computeConv3DInfo:()=>zk,computeDefaultPad:()=>Y2,computeDilation2DInfo:()=>sO,computeOptimalWindowSize:()=>jV,computeOutAndReduceShapes:()=>pz,computeOutShape:()=>GV,computePool2DInfo:()=>Pk,computePool3DInfo:()=>aO,convertConv2DDataFormat:()=>Lk,decodeEinsumEquation:()=>AU,eitherStridesOrDilationsAreOne:()=>Qs,expandShapeToKeepDim:()=>cc,exponent:()=>gU,exponents:()=>mU,fromStringArrayToUint8:()=>EU,fromUint8ToStringArray:()=>CU,getAxesPermutation:()=>mz,getBroadcastDims:()=>mP,getComplexWithIndex:()=>pU,getEinsumComputePath:()=>vU,getEinsumPermutation:()=>xU,getFusedBiasGradient:()=>_p,getFusedDyActivation:()=>$p,getImageCenter:()=>qV,getInnerMostAxes:()=>yz,getPermuted:()=>XV,getReductionAxes:()=>Hk,getReshaped:()=>KV,getReshapedPermuted:()=>ZV,getSliceBeginCoords:()=>YV,getSliceSize:()=>JV,getUndoAxesPermutation:()=>gz,isIdentityPermutation:()=>wU,log:()=>lU,mergeRealAndImagArrays:()=>uU,prepareAndValidate:()=>gk,prepareSplitSize:()=>IU,segment_util:()=>R4,shouldFuse:()=>Dp,slice_util:()=>U2,splitRealAndImagArrays:()=>cU,tupleValuesAreOne:()=>ic,upcastType:()=>cp,validateInput:()=>V2,validateUpdateShape:()=>W2,warn:()=>iU});function HV(e,t){let n=e[0].length;e.forEach((s,a)=>{L(s.length===n,()=>`Error in concat${n}D: rank of tensors[${a}] must be the same as the rank of the rest (${n})`)}),L(t>=0&&t<n,()=>`Error in concat${n}D: axis must be between 0 and ${n-1}.`);let r=e[0];e.forEach((s,a)=>{for(let o=0;o<n;o++)L(o===t||s[o]===r[o],()=>`Error in concat${n}D: Shape of tensors[${a}] (${s}) does not match the shape of the rest (${r}) along the non-concatenated axis ${a}.`)})}function GV(e,t){let n=e[0].slice();for(let r=1;r<e.length;r++)n[t]+=e[r][t];return n}var hy=30;function jV(e){return e<=hy?e:tp(e,Math.floor(Math.sqrt(e)))}function qV(e,t,n){let r=n*(typeof e=="number"?e:e[0]),s=t*(typeof e=="number"?e:e[1]);return[r,s]}function KV(e,t,n,r=!0){let s=[];if(r)s=s.concat(t.slice(0)),s.push(e[0]/n),s=s.concat(e.slice(1));else{s=s.concat(e[0]);let a=t.length;for(let o=0;o<a;++o)s=s.concat([e[o+1]/t[o],t[o]]);s=s.concat(e.slice(a+1))}return s}function XV(e,t,n=!0){let r=[];if(n){r.push(t);for(let s=t+1;s<e;++s)s<=2*t?(r.push(s),r.push(s-(t+1))):r.push(s)}else{let s=[],a=[];for(let o=1;o<e;++o)o>=t*2+1||o%2==1?a.push(o):s.push(o);r.push(...s),r.push(0),r.push(...a)}return r}function ZV(e,t,n,r=!0){let s=[];r?s.push(e[0]/n):s.push(e[0]*n);for(let a=1;a<e.length;++a)a<=t.length?r?s.push(t[a-1]*e[a]):s.push(e[a]/t[a-1]):s.push(e[a]);return s}function YV(e,t){let n=[0];for(let r=0;r<t;++r)n.push(e[r][0]);return n}function JV(e,t,n){let r=e.slice(0,1);for(let s=0;s<n;++s)r.push(e[s+1]-t[s][0]-t[s][1]);return r}var QV=1.7580993408473768,eU=1.0507009873554805,tU=.3275911,nU=.254829592,rU=-.284496736,sU=1.421413741,aU=-1.453152027,oU=1.061405429;function iU(...e){ct().getBool("IS_TEST")||console.warn(...e)}function lU(...e){ct().getBool("IS_TEST")||console.log(...e)}function uU(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 r=0;r<n.length;r+=2)n[r]=e[r/2],n[r+1]=t[r/2];return n}function cU(e){let t=new Float32Array(e.length/2),n=new Float32Array(e.length/2);for(let r=0;r<e.length;r+=2)t[r/2]=e[r],n[r/2]=e[r+1];return{real:t,imag:n}}function dU(e){let t=Math.ceil(e.length/4),n=new Float32Array(t),r=new Float32Array(t);for(let s=0;s<e.length;s+=4)n[Math.floor(s/4)]=e[s],r[Math.floor(s/4)]=e[s+1];return{real:n,imag:r}}function hU(e){let t=Math.floor(e.length/4),n=new Float32Array(t),r=new Float32Array(t);for(let s=2;s<e.length;s+=4)n[Math.floor(s/4)]=e[s],r[Math.floor(s/4)]=e[s+1];return{real:n,imag:r}}function pU(e,t){let n=e[t*2],r=e[t*2+1];return{real:n,imag:r}}function fU(e,t,n,r){e[r*2]=t,e[r*2+1]=n}function mU(e,t){let n=new Float32Array(e/2),r=new Float32Array(e/2);for(let s=0;s<Math.ceil(e/2);s++){let a=(t?2:-2)*Math.PI*(s/e);n[s]=Math.cos(a),r[s]=Math.sin(a)}return{real:n,imag:r}}function gU(e,t,n){let r=(n?2:-2)*Math.PI*(e/t),s=Math.cos(r),a=Math.sin(r);return{real:s,imag:a}}var py="->",yU=/->/g,$4=",",_4="...";function AU(e,t){e=e.replace(/\s/g,"");let n=(e.length-e.replace(yU,"").length)/py.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 ("${py}").`);let[r,s]=e.split(py);L(r.indexOf(_4)===-1,()=>`The ellipsis notation ("${_4}") is not supported yet.`);let a=r.split($4),o=a.length;if(t!==o)throw new Error(`Expected ${o} input tensors, received ${t}`);if(o>2)throw new Error("Support for more than 2 input tensors is not implemented yet.");let i=[];for(let h=0;h<s.length;++h){let p=s[h];if(!a.some(f=>f.indexOf(p)!==-1))throw new Error(`Output subscripts contain the label ${p} not present in the input subscripts.`);i.indexOf(p)===-1&&i.push(p)}for(let h=0;h<r.length;++h){let p=r[h];i.indexOf(p)===-1&&p!==$4&&i.push(p)}let l=new Array(a.length);for(let h=0;h<o;++h){if(new Set(a[h].split("")).size!==a[h].length)throw new Error(`Found duplicate axes in input component ${a[h]}. Support for duplicate axes in input is not implemented yet.`);l[h]=[];for(let p=0;p<a[h].length;++p)l[h].push(i.indexOf(a[h][p]))}let u=i.length,c=s.length,d=[];for(let h=c;h<u;++h)d.push(h);return{allDims:i,summedDims:d,idDims:l}}function xU(e,t){let n=new Array(e);n.fill(-1);for(let s=0;s<t.length;++s)n[t[s]]=s;let r=[];for(let s=0;s<e;++s)n[s]===-1&&r.push(s);return n=n.filter(s=>s!==-1),{permutationIndices:n,expandDims:r}}function bU(e,t,n){let r=new Array(e);for(let s=0;s<n.length;++s){let a=n[s].shape;for(let o=0;o<t[s].length;++o)r[t[s][o]]===void 0?r[t[s][o]]=a[o]:L(r[t[s][o]]===a[o],()=>`Expected dimension ${r[t[s][o]]} at axis ${o} of input shaped ${JSON.stringify(a)}, but got dimension ${a[o]}`)}}function vU(e,t){let n=e,r=[],s=0;e.length===0&&n.push(-1),s=e.length+1;for(let o=0;o<s;++o)r.push([]);let a=[];for(let o=0;o<n.length;++o){let i=n[o],l=kU(t,i);for(let u of l)a.indexOf(u)===-1&&(r[o].push(u),a.push(u))}return{path:n,steps:r}}function wU(e){return e.every((t,n)=>t===n)}function kU(e,t){let n=[];for(let r=0;r<e.length;++r)(e[r].length===0||e[r].indexOf(t)!==-1||t===-1)&&n.push(r);return n}function IU(e,t,n=0){let r=[];if(typeof t=="number")L(e.shape[n]%t==0,()=>"Number of splits must evenly divide the axis."),r=new Array(t).fill(e.shape[n]/t);else{let s=t.reduce((o,i)=>(i===-1&&(o+=1),o),0);L(s<=1,()=>"There should be only one negative value in split array.");let a=t.indexOf(-1);if(a!==-1){let o=t.reduce((i,l)=>l>0?i+l:i);t[a]=e.shape[n]-o}L(e.shape[n]===t.reduce((o,i)=>o+i),()=>"The sum of sizes must match the size of the axis dimension."),r=t}return r}var R4={};De(R4,{collectGatherOpShapeInfo:()=>NU,computeOutShape:()=>TU,segOpComputeOptimalWindowSize:()=>SU});function SU(e,t){let n=!1,r;for(e<=hy?(r=e,n=!0):r=tp(e,Math.floor(Math.sqrt(e)));!n;)r>t||r===e?n=!0:r=tp(e,r+1);return r}function TU(e,t,n){let r=[],s=e.length;for(let a=0;a<s;a++)a!==t?r.push(e[a]):r.push(n);return r}function NU(e,t,n,r){let s=t.shape.length,a=e.shape.length;if(r!==0&&(r<-s||r>s))throw new Error(`Expect batchDims in the range of [-${s}, ${s}], but got ${r}`);if(r<0&&(r+=s),r>a)throw new Error(`batchDims (${r}) must be less than rank(x) (
|
|
${a}).`);if(n<r)throw new Error(`batchDims (${r}) must be less than or equal to axis (${n}).`);for(let d=0;d<r;++d)if(e.shape[d]!==t.shape[d])throw new Error(`x.shape[${d}]: ${e.shape[d]} should be equal to indices.shape[${d}]: ${t.shape[d]}.`);let o=e.shape[n],i=[],l=1,u=1,c=1;for(let d=0;d<r;++d)i.push(e.shape[d]),l*=e.shape[d];for(let d=r;d<n;d++)i.push(e.shape[d]),u*=e.shape[d];for(let d=r;d<s;d++)i.push(t.shape[d]);for(let d=n+1;d<a;d++)i.push(e.shape[d]),c*=e.shape[d];return{batchSize:l,sliceSize:c,outerSize:u,dimSize:o,outputShape:i}}function CU(e){try{return e.map(t=>ip(t))}catch(t){throw new Error(`Failed to decode encoded string bytes into utf-8, error: ${t}`)}}function EU(e){return e.map(t=>Qu(t))}var D4={};De(D4,{nonMaxSuppressionV3Impl:()=>I4,nonMaxSuppressionV4Impl:()=>S4,nonMaxSuppressionV5Impl:()=>T4,whereImpl:()=>y4});var $U=1e-7,_U=1e-4,fy=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}},Bp=class{refCount(e){return Gr("refCount")}incRef(e){return Gr("incRef")}timerAvailable(){return!0}time(e){return Gr("time")}read(e){return Gr("read")}readSync(e){return Gr("readSync")}numDataIds(){return Gr("numDataIds")}disposeData(e,t){return Gr("disposeData")}write(e,t,n){return Gr("write")}move(e,t,n,r,s){return Gr("move")}memory(){return Gr("memory")}floatPrecision(){return Gr("floatPrecision")}epsilon(){return this.floatPrecision()===32?$U:_U}dispose(){return Gr("dispose")}};function Gr(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 F4(e){let t=e.length,n=0,r=0;for(;t>0;)r=Math.random()*t|0,t--,n=e[t],e[t]=e[r],e[r]=n}function RU(e,t){if(e.length!==t.length)throw new Error(`Array sizes must match to be shuffled together First array length was ${e.length}Second array length was ${t.length}`);let n=e.length,r,s,a=0;for(;n>0;)a=Math.random()*n|0,n--,r=e[n],s=t[n],e[n]=e[a],t[n]=t[a],e[a]=r,t[a]=s}function gc(e,t,n){return Math.max(e,Math.min(t,n))}function DU(e){return e%2==0?e:e+1}function FU(e){let t=0;for(let n=0;n<e.length;n++)t+=e[n];return t}function MU(e,t){let n=Math.random();return t*n+(1-n)*e}function OU(e,t){let n=0;for(let r=0;r<e.length;r++){let s=Number(e[r])-Number(t[r]);n+=s*s}return n}function z(e,t){if(!e)throw new Error(typeof t=="string"?t:t())}function rs(e,t,n=""){z(Da(e,t),()=>n+` Shapes ${e} and ${t} must match`)}function Wp(e){z(e!=null,()=>"The input to the tensor constructor must be a non-null value.")}function yc(e,t=[],n=!1){if(t==null&&(t=[]),Array.isArray(e)||ss(e)&&!n)for(let r=0;r<e.length;++r)yc(e[r],t,n);else t.push(e);return t}function on(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 PU(e){return e.length===0}function Da(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 mn(e){return e%1==0}function zU(e){if(Math.tanh!=null)return Math.tanh(e);if(e===Infinity)return 1;if(e===-Infinity)return-1;{let t=Math.exp(2*e);return(t-1)/(t+1)}}function LU(e){let t=Math.ceil(Math.sqrt(e));return[t,Math.ceil(e/t)]}function BU(e){let t=new Uint32Array(e);for(let n=0;n<e;++n)t[n]=n;return F4(t),t}function Ac(e,t){return t<=e.length?e:e+" ".repeat(t-e.length)}function WU(e,t=r=>0,n){return new Promise((r,s)=>{let a=0,o=()=>{if(e()){r();return}a++;let i=t(a);if(n!=null&&a>=n){s();return}setTimeout(o,i)};o()})}function VU(e,t){let n=1,r=-1;for(let a=0;a<e.length;++a)if(e[a]>=0)n*=e[a];else if(e[a]===-1){if(r!==-1)throw Error(`Shapes can only have 1 implicit size. Found -1 at dim ${r} and dim ${a}`);r=a}else if(e[a]<0)throw Error(`Shapes can not be < 0. Found ${e[a]} at dim ${a}`);if(r===-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 s=e.slice();return s[r]=t/n,s}function jr(e,t){let n=t.length;return e=e==null?t.map((r,s)=>s):[].concat(e),z(e.every(r=>r>=-n&&r<n),()=>`All values in axis param must be in range [-${n}, ${n}) but got axis ${e}`),z(e.every(r=>mn(r)),()=>`All values in axis param must be integers but got axis ${e}`),e.map(r=>r<0?n+r:r)}function M4(e,t){let n=[],r=[],s=t!=null&&Array.isArray(t)&&t.length===0,a=t==null||s?null:jr(t,e).sort(),o=0;for(let i=0;i<e.length;++i){if(a!=null){if(a[o]===i&&e[i]!==1)throw new Error(`Can't squeeze axis ${i} since its dim '${e[i]}' is not 1`);(a[o]==null||a[o]>i)&&e[i]===1&&(n.push(e[i]),r.push(i)),a[o]<=i&&o++}e[i]!==1&&(n.push(e[i]),r.push(i))}return{newShape:n,keptDims:r}}function UU(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 O4(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 P4(e,t){for(let n=0;n<e.length;n++){let r=e[n];if(isNaN(r)||!isFinite(r))throw Error(`A tensor of type ${t} being uploaded contains ${r}.`)}}function z4(e){return e==="bool"||e==="complex64"||e==="float32"||e==="int32"||e==="string"}function HU(e,t){return!(t==="complex64"||t==="float32"&&e!=="complex64"||t==="int32"&&e!=="float32"&&e!=="complex64"||t==="bool"&&e==="bool")}function ss(e){return e instanceof Float32Array||e instanceof Int32Array||e instanceof Uint8Array}function my(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 L4(e){if(e==null)return 0;let t=0;return e.forEach(n=>t+=n.length),t}function Vp(e){return typeof e=="string"||e instanceof String}function B4(e){return typeof e=="boolean"}function W4(e){return typeof e=="number"}function Up(e){return Array.isArray(e)?Up(e[0]):e instanceof Float32Array?"float32":e instanceof Int32Array||e instanceof Uint8Array?"int32":W4(e)?"float32":Vp(e)?"string":B4(e)?"bool":"float32"}function Hp(e){return!!(e&&e.constructor&&e.call&&e.apply)}function Gp(e,t){for(let n=t;n<e;++n)if(e%n==0)return n;return e}function Ki(e){let t=e.length;if(t<2)return[];let n=new Array(t-1);n[t-2]=e[t-1];for(let r=t-3;r>=0;--r)n[r]=n[r+1]*e[r+1];return n}function V4(e,t,n,r=!1){let s=new Array;if(t.length===1){let a=t[0]*(r?2:1);for(let o=0;o<a;o++)s[o]=n[e+o]}else{let a=t[0],o=t.slice(1),i=o.reduce((l,u)=>l*u)*(r?2:1);for(let l=0;l<a;l++)s[l]=V4(e+l*i,o,n,r)}return s}function Xi(e,t,n=!1){if(e.length===0)return t[0];let r=e.reduce((s,a)=>s*a)*(n?2:1);if(r===0)return[];if(r!==t.length)throw new Error(`[${e}] does not match the input size ${t.length}${n?" for a complex tensor":""}.`);return V4(0,e,t,n)}function gy(e,t){let n=jp(e,t);for(let r=0;r<n.length;r++)n[r]=1;return n}function jp(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 GU(e,t){let n=e.reduce((r,s)=>r*s,1);if(t==null||t==="float32")return Xi(e,new Float32Array(n));if(t==="int32")return Xi(e,new Int32Array(n));if(t==="bool")return Xi(e,new Uint8Array(n));throw new Error(`Unknown data type ${t}`)}function yy(e){e.forEach(t=>{z(Number.isInteger(t)&&t>=0,()=>`Tensor must have a shape comprised of positive integers but got shape [${e}].`)})}function jU(e,t,n){if(t===0)return 0;if(t===1)return e[0];let r=e[e.length-1];for(let s=0;s<e.length-1;++s)r+=n[s]*e[s];return r}function qU(e,t,n){if(t===0)return[];if(t===1)return[e];let r=new Array(t);for(let s=0;s<r.length-1;++s)r[s]=Math.floor(e/n[s]),e-=r[s]*n[s];return r[r.length-1]=e,r}function Ay(e){return e&&e.then&&typeof e.then=="function"}var U4="tfjsflags",KU=class{constructor(e){this.global=e,this.flags={},this.flagRegistry={},this.urlFlags={},this.getQueryParams=XU,this.populateURLFlags()}setPlatform(e,t){this.platform!=null&&console.warn(`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 r=this.urlFlags[e];console.warn(`Setting feature override from URL ${e}: ${r}.`),this.set(e,r)}}async getAsync(e){return e in this.flags?this.flags[e]:(this.flags[e]=await this.evaluateFlag(e),this.flags[e])}get(e){if(e in this.flags)return this.flags[e];let t=this.evaluateFlag(e);if(Ay(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);U4 in e&&e[U4].split(",").forEach(n=>{let[r,s]=n.split(":");this.urlFlags[r]=YU(r,s)})}};function XU(e){let t={};return e.replace(/[?&]([^=?&]+)(?:=([^&]*))?/g,(n,...r)=>(ZU(t,r[0],r[1]),r.join("="))),t}function ZU(e,t,n){e[decodeURIComponent(t)]=decodeURIComponent(n||"")}function YU(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 ae(){return H4}var H4=null;function JU(e){H4=e}var xy;function G4(){if(xy==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");xy=e}return xy}function QU(){let e=G4();return e._tfGlobals==null&&(e._tfGlobals=new Map),e._tfGlobals}function by(e,t){let n=QU();if(n.has(e))return n.get(e);{let r=t();return n.set(e,r),n.get(e)}}var xc="Abs",bc="Acos",vc="Acosh",Fa="Add",Zi="AddN",wc="All",kc="Any",Yi="ArgMax",qp="ArgMin",Ic="Asin",Sc="Asinh",Tc="Atan",Nc="Atanh",Cc="Atan2",Ji="AvgPool",vy="AvgPoolGrad",Kp="AvgPool3D",wy="AvgPool3DGrad",Qi="BatchMatMul",Xp="BatchToSpaceND",ky="Bincount",eH="BroadcastTo",el="Cast",No="Ceil",Co="ClipByValue",Iy="Complex",Zp="ComplexAbs",Ec="Concat",tl="Conv2D",Sy="Conv2DBackpropFilter",nl="Conv2DBackpropInput",Yp="Conv3D",Ty="Conv3DBackpropFilterV2",Ny="Conv3DBackpropInputV2",rl="Cos",$c="Cosh",sl="Cumsum",_c="CropAndResize",Cy="DenseBincount",Rc="DepthToSpace",al="DepthwiseConv2dNative",Ey="DepthwiseConv2dNativeBackpropFilter",$y="DepthwiseConv2dNativeBackpropInput",_y="Diag",Jp="Dilation2D",Ry="Dilation2DBackpropInput",Dy="Dilation2DBackpropFilter",ol="RealDiv",Fy="Einsum",Dc="Elu",My="EluGrad",Fc="Erf",il="Equal",Eo="Exp",Mc="ExpandDims",ll="Expm1",Oy="FFT",Qp="Fill",Oc="FlipLeftRight",$o="Floor",ul="FloorDiv",cl="FusedBatchNorm",Pc="GatherV2",zc="GatherNd",dl="Greater",_o="GreaterEqual",hl="Identity",Py="IFFT",zy="Imag",Lc="IsFinite",Bc="IsInf",Wc="IsNan",pl="LeakyRelu",fl="Less",ml="LessEqual",Ly="LinSpace",Ro="Log",Vc="Log1p",Uc="LogicalAnd",ef="LogicalNot",tf="LogicalOr",tH="LogSoftmax",nf="LRN",By="LRNGrad",gl="Max",Do="Maximum",yl="MaxPool",Wy="MaxPoolGrad",rf="MaxPool3D",Vy="MaxPool3DGrad",Uy="MaxPoolWithArgmax",Al="Mean",xl="Min",Fo="Minimum",bl="MirrorPad",Hc="Mod",Hy="Multinomial",Mo="Multiply",Gc="Neg",vl="NotEqual",jc="NonMaxSuppressionV3",qc="NonMaxSuppressionV4",Kc="NonMaxSuppressionV5",Xc="OnesLike",wl="OneHot",Zc="Pack",kl="PadV2",Il="Pow",Sl="Prelu",Yc="Prod",sf="Range",Gy="Real",Jc="Reciprocal",Tl="Relu",Qc="Reshape",af="ResizeNearestNeighbor",jy="ResizeNearestNeighborGrad",Nl="ResizeBilinear",qy="ResizeBilinearGrad",Cl="Relu6",El="Reverse",$l="Round",Oo="Rsqrt",ed="ScatterNd",td="Select",nd="Selu",rd="Slice",_l="Sin",sd="Sinh",ad="Sign",Rl="Sigmoid",od="Softplus",Dl="Sqrt",Fl="Sum",of="SpaceToBatchND",id="SplitV",Ml="Softmax",Ky="SparseFillEmptyRows",Xy="SparseReshape",Zy="SparseSegmentMean",Yy="SparseSegmentSum",Jy="SparseToDense",Po="SquaredDifference",lf="Square",ld="StridedSlice",Qy="StringNGrams",eA="StringSplit",tA="StringToHashBucketFast",zo="Sub",Ol="Tan",Pl="Tanh",Lo="Tile",ud="TopK",cd="Transform",zl="Transpose",nA="Unique",dd="Unpack",uf="UnsortedSegmentSum",hd="ZerosLike",Bo="Step",rA="FromPixels",pd="RotateWithOffset",Ll="_FusedMatMul",Bl="FusedConv2D",Wl="FusedDepthwiseConv2D",cf=by("kernelRegistry",()=>new Map),sA=by("gradRegistry",()=>new Map);function aA(e,t){let n=K4(e,t);return cf.get(n)}function j4(e){return sA.get(e)}function q4(e){let t=cf.entries(),n=[];for(;;){let{done:r,value:s}=t.next();if(r)break;let[a,o]=s,[i]=a.split("_");i===e&&n.push(o)}return n}function oA(e){let{kernelName:t,backendName:n}=e,r=K4(t,n);cf.has(r)&&console.warn(`The kernel '${t}' for backend '${n}' is already registered`),cf.set(r,e)}function nH(e){let{kernelName:t}=e;sA.has(t)&&ae().getBool("DEBUG")&&console.warn(`Overriding the gradient for '${t}'`),sA.set(t,e)}function K4(e,t){return`${t}_${e}`}var k={};De(k,{arraysEqual:()=>Da,assert:()=>z,assertNonNegativeIntegerDimensions:()=>yy,assertNonNull:()=>Wp,assertShapesMatch:()=>rs,bytesFromStringArray:()=>L4,bytesPerElement:()=>my,checkConversionForErrors:()=>P4,clamp:()=>gc,computeStrides:()=>Ki,createScalarValue:()=>lH,createShuffledIndices:()=>BU,decodeString:()=>ff,distSquared:()=>OU,encodeString:()=>pf,fetch:()=>cH,fingerPrint64:()=>iH,flatten:()=>yc,getArrayFromDType:()=>O4,getTypedArrayFromDType:()=>UU,hasEncodingLoss:()=>HU,hexToLong:()=>fd,indexToLoc:()=>qU,inferDtype:()=>Up,inferFromImplicitShape:()=>VU,isBoolean:()=>B4,isFunction:()=>Hp,isInt:()=>mn,isNumber:()=>W4,isPromise:()=>Ay,isScalarShape:()=>PU,isString:()=>Vp,isTypedArray:()=>ss,isValidDtype:()=>z4,locToIndex:()=>jU,makeOnesTypedArray:()=>gy,makeZerosNestedTypedArray:()=>GU,makeZerosTypedArray:()=>jp,nearestDivisor:()=>Gp,nearestLargerEven:()=>DU,now:()=>md,parseAxisParam:()=>jr,randUniform:()=>MU,repeatedTry:()=>WU,rightPad:()=>Ac,shuffle:()=>F4,shuffleCombo:()=>RU,sizeFromShape:()=>on,sizeToSquarishShape:()=>LU,squeezeShape:()=>M4,sum:()=>FU,tanh:()=>zU,toNestedArray:()=>Xi,toTypedArray:()=>hf});var X4=Ks(M3()),Wo=X4.default||X4;function fd(e){return Wo.fromString(e,!0,16)}var Z4=fd("c3a5c85c97cb3127"),Vo=fd("b492b66fbe98f273"),zn=fd("9ae16a3b2f90404f");function iA(e){return e.xor(e.shru(47))}function Y4(e,t,n){let r=e.slice(t,t+n);return Wo.fromBytes(Array.from(r),!0,!0)}function Nt(e,t){return Y4(e,t,8)}function J4(e,t){return Y4(e,t,4)}function gn(e,t){return t===0?e:e.shru(t).or(e.shl(64-t))}function Ma(e,t,n=fd("9ddfea08eb382d69")){let r=e.xor(t).mul(n);r=r.xor(r.shru(47));let s=t.xor(r).mul(n);return s=s.xor(s.shru(47)),s=s.mul(n),s}function rH(e,t,n,r,s,a){s=s.add(e),a=gn(a.add(s).add(r),21);let o=s;return s=s.add(t),s=s.add(n),a=a.add(gn(s,44)),[s.add(r),a.add(o)]}function df(e,t,n,r){return rH(Nt(e,t),Nt(e,t+8),Nt(e,t+16),Nt(e,t+24),n,r)}function sH(e,t=e.length){if(t>=8){let n=zn.add(t*2),r=Nt(e,0).add(zn),s=Nt(e,t-8),a=gn(s,37).mul(n).add(r),o=gn(r,25).add(s).mul(n);return Ma(a,o,n)}if(t>=4){let n=zn.add(t*2),r=J4(e,0);return Ma(r.shl(3).add(t),J4(e,t-4),n)}if(t>0){let n=e[0],r=e[t>>1],s=e[t-1],a=n+(r<<8),o=t+(s<<2);return iA(zn.mul(a).xor(Z4.mul(o))).mul(zn)}return zn}function aH(e,t=e.length){let n=zn.add(t*2),r=Nt(e,0).mul(Vo),s=Nt(e,8),a=Nt(e,t-8).mul(n),o=Nt(e,t-16).mul(zn);return Ma(gn(r.add(s),43).add(gn(a,30)).add(o),r.add(gn(s.add(zn),18)).add(a),n)}function oH(e,t=e.length){let n=zn.add(t*2),r=Nt(e,0).mul(zn),s=Nt(e,8),a=Nt(e,t-8).mul(n),o=Nt(e,t-16).mul(zn),i=gn(r.add(s),43).add(gn(a,30)).add(o),l=Ma(i,r.add(gn(s.add(zn),18)).add(a),n),u=Nt(e,16).mul(n),c=Nt(e,24),d=i.add(Nt(e,t-32)).mul(n),h=l.add(Nt(e,t-24)).mul(n);return Ma(gn(u.add(c),43).add(gn(d,30)).add(h),u.add(gn(c.add(r),18)).add(d),n)}function iH(e,t=e.length){let n=Wo.fromNumber(81,!0);if(t<=32)return t<=16?sH(e,t):aH(e,t);if(t<=64)return oH(e,t);let r=n,s=n.mul(Vo).add(113),a=iA(s.mul(zn).add(113)).mul(zn),o=[Wo.UZERO,Wo.UZERO],i=[Wo.UZERO,Wo.UZERO];r=r.mul(zn).add(Nt(e,0));let l=0,u=(t-1>>6)*64,c=u+(t-1&63)-63;do r=gn(r.add(s).add(o[0]).add(Nt(e,l+8)),37).mul(Vo),s=gn(s.add(o[1]).add(Nt(e,l+48)),42).mul(Vo),r=r.xor(i[1]),s=s.add(o[0]).add(Nt(e,l+40)),a=gn(a.add(i[0]),33).mul(Vo),o=df(e,l,o[1].mul(Vo),r.add(i[0])),i=df(e,l+32,a.add(i[1]),s.add(Nt(e,l+16))),[a,r]=[r,a],l+=64;while(l!==u);let d=Vo.add(a.and(255).shl(1));return l=c,i[0]=i[0].add(t-1&63),o[0]=o[0].add(i[0]),i[0]=i[0].add(o[0]),r=gn(r.add(s).add(o[0]).add(Nt(e,l+8)),37).mul(d),s=gn(s.add(o[1]).add(Nt(e,l+48)),42).mul(d),r=r.xor(i[1].mul(9)),s=s.add(o[0].mul(9).add(Nt(e,l+40))),a=gn(a.add(i[0]),33).mul(d),o=df(e,l,o[1].mul(d),r.add(i[0])),i=df(e,l+32,a.add(i[1]),s.add(Nt(e,l+16))),[a,r]=[r,a],Ma(Ma(o[0],i[0],d).add(iA(s).mul(Z4)).add(a),Ma(o[1],i[1],d).add(r),d)}function lH(e,t){return t==="string"?pf(e):hf([e],t)}function uH(e,t){return e instanceof Float32Array&&t==="float32"||e instanceof Int32Array&&t==="int32"||e instanceof Uint8Array&&t==="bool"}function hf(e,t){if(t==="string")throw new Error("Cannot convert a string[] to a TypedArray");if(Array.isArray(e)&&(e=yc(e)),ae().getBool("DEBUG")&&P4(e,t),uH(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 r=0;r<n.length;++r)Math.round(e[r])!==0&&(n[r]=1);return n}else throw new Error(`Unknown data type ${t}`)}function md(){return ae().platform.now()}function cH(e,t){return ae().platform.fetch(e,t)}function pf(e,t="utf-8"){return t=t||"utf-8",ae().platform.encode(e,t)}function ff(e,t="utf-8"){return t=t||"utf-8",ae().platform.decode(e,t)}var dH=class{constructor(e,t){this.backendTimer=e,this.logger=t,t==null&&(this.logger=new pH)}profileKernel(e,t,n){let r,s=()=>{r=n()},a,o=md();if(this.backendTimer.timerAvailable())a=this.backendTimer.time(s);else{s();for(let l of r)l.dataSync();a=Promise.resolve({kernelMs:md()-o})}if(ae().getBool("CHECK_COMPUTATION_FOR_ERRORS"))for(let l=0;l<r.length;l++){let u=r[l];u.data().then(c=>{hH(c,u.dtype,e)})}return{kernelName:e,outputs:r,inputs:t,timeMs:a.then(l=>l.kernelMs),extraInfo:a.then(l=>l.getExtraProfileInfo!=null?l.getExtraProfileInfo():"")}}logKernelProfile(e){let{kernelName:t,outputs:n,timeMs:r,inputs:s,extraInfo:a}=e;n.forEach(o=>{Promise.all([o.data(),r,a]).then(i=>{this.logger.logKernelProfile(t,o,i[0],i[1],s,i[2])})})}};function hH(e,t,n){if(t!=="float32")return!1;for(let r=0;r<e.length;r++){let s=e[r];if(isNaN(s)||!isFinite(s))return console.warn(`Found ${s} in the result of '${n}'`),!0}return!1}var pH=class{logKernelProfile(e,t,n,r,s,a){let o=typeof r=="number"?Ac(`${r}ms`,9):r.error,i=Ac(e,25),l=t.rank,u=t.size,c=Ac(t.shape.toString(),14),d="";for(let h in s){let p=s[h];if(p!=null){let f=p.shape||t.shape,m=f.length;d+=`${h}: ${m}D ${m>0?f:""} `}}console.log(`%c${i} %c${o} %c${l}D ${c} %c${u} %c${d} %c${a}`,"font-weight:bold","color:red","color:blue","color: orange","color: green","color: steelblue")}};function fH(e,t,n){let r={},s={};for(let l=0;l<t.length;l++)r[t[l].id]=!0;for(let l=0;l<e.length;l++){let u=e[l],c=u.inputs;for(let d in c){let h=c[d],p=!1;for(let f=0;f<t.length;f++)if(r[h.id]){u.outputs.forEach(m=>r[m.id]=!0),p=!0,s[u.id]=!0;break}if(p)break}}let a={};a[n.id]=!0;let o={};for(let l=e.length-1;l>=0;l--){let u=e[l],c=u.inputs;for(let d=0;d<u.outputs.length;d++)if(a[u.outputs[d].id]){for(let h in c)a[c[h].id]=!0,o[u.id]=!0;break}}let i=[];for(let l=0;l<e.length;l++){let u=e[l];if(s[u.id]&&o[u.id]){let c={};for(let h in u.inputs){let p=u.inputs[h];r[p.id]&&(c[h]=p)}let d=Object.assign({},u);d.inputs=c,d.outputs=u.outputs,i.push(d)}}return i}function mH(e,t,n,r){for(let s=t.length-1;s>=0;s--){let a=t[s],o=[];if(a.outputs.forEach(l=>{let u=e[l.id];u!=null?o.push(u):o.push(null)}),a.gradient==null)throw new Error(`Cannot compute gradient: gradient function not found for ${a.kernelName}.`);let i=a.gradient(o);for(let l in a.inputs){if(!(l in i))throw new Error(`Cannot backprop through input ${l}. Available gradients found: ${Object.keys(i)}.`);let u=n(()=>i[l]());if(u.dtype!=="float32")throw new Error(`Error in gradient for op ${a.kernelName}. The gradient of input ${l} must have 'float32' dtype, but has '${u.dtype}'`);let c=a.inputs[l];if(!Da(u.shape,c.shape))throw new Error(`Error in gradient for op ${a.kernelName}. The gradient of input '${l}' has shape '${u.shape}', which does not match the shape of the input '${c.shape}'`);if(e[c.id]==null)e[c.id]=u;else{let d=e[c.id];e[c.id]=r(d,u),d.dispose()}}}}var Q4=20,gd=3,lA=7;function gH(e,t,n,r){let s=Ki(t),a=yH(e,t,n,s),o=t.length,i=mf(e,t,n,s,a),l=["Tensor"];return r&&(l.push(` dtype: ${n}`),l.push(` rank: ${o}`),l.push(` shape: [${t}]`),l.push(" values:")),l.push(i.map(u=>" "+u).join(`
|
|
`)),l.join(`
|
|
`)}function yH(e,t,n,r){let s=on(t),a=r[r.length-1],o=new Array(a).fill(0),i=t.length,l=n==="complex64"?Ad(e):e;if(i>1)for(let u=0;u<s/a;u++){let c=u*a;for(let d=0;d<a;d++)o[d]=Math.max(o[d],yd(l[c+d],0,n).length)}return o}function yd(e,t,n){let r;return Array.isArray(e)?r=`${parseFloat(e[0].toFixed(lA))} + ${parseFloat(e[1].toFixed(lA))}j`:Vp(e)?r=`'${e}'`:n==="bool"?r=e6(e):r=parseFloat(e.toFixed(lA)).toString(),Ac(r,t)}function e6(e){return e===0?"false":"true"}function mf(e,t,n,r,s,a=!0){let o=n==="complex64"?2:1,i=t[0],l=t.length;if(l===0){if(n==="complex64"){let m=Ad(e);return[yd(m[0],0,n)]}return n==="bool"?[e6(e[0])]:[e[0].toString()]}if(l===1){if(i>Q4){let g=gd*o,y=Array.from(e.slice(0,g)),A=Array.from(e.slice((i-gd)*o,i*o));return n==="complex64"&&(y=Ad(y),A=Ad(A)),["["+y.map((x,b)=>yd(x,s[b],n)).join(", ")+", ..., "+A.map((x,b)=>yd(x,s[i-gd+b],n)).join(", ")+"]"]}let m=n==="complex64"?Ad(e):Array.from(e);return["["+m.map((g,y)=>yd(g,s[y],n)).join(", ")+"]"]}let u=t.slice(1),c=r.slice(1),d=r[0]*o,h=[];if(i>Q4){for(let m=0;m<gd;m++){let g=m*d,y=g+d;h.push(...mf(e.slice(g,y),u,n,c,s,!1))}h.push("...");for(let m=i-gd;m<i;m++){let g=m*d,y=g+d;h.push(...mf(e.slice(g,y),u,n,c,s,m===i-1))}}else for(let m=0;m<i;m++){let g=m*d,y=g+d;h.push(...mf(e.slice(g,y),u,n,c,s,m===i-1))}let p=l===2?",":"";h[0]="["+h[0]+p;for(let m=1;m<h.length-1;m++)h[m]=" "+h[m]+p;let f=`,
|
|
`;for(let m=2;m<l;m++)f+=`
|
|
`;return h[h.length-1]=" "+h[h.length-1]+"]"+(a?"":f),h}function Ad(e){let t=[];for(let n=0;n<e.length;n+=2)t.push([e[n],e[n+1]]);return t}var Qt=class{constructor(e,t,n){if(this.dtype=t,this.shape=e.slice(),this.size=on(e),n!=null){let r=n.length;z(r===this.size,()=>`Length of values '${r}' 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||O4(t,this.size),this.strides=Ki(e)}set(e,...t){t.length===0&&(t=[0]),z(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 r of e){if(r<0||r>=this.shape[t]){let s=`Requested out of range element at ${e}. Buffer shape=${this.shape}`;throw new Error(s)}t++}let n=e[e.length-1];for(let r=0;r<e.length-1;++r)n+=this.strides[r]*e[r];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 Cs().makeTensor(this.values,this.shape,this.dtype)}},Cs=null,Vl=null,AH=null;function xH(e){Cs=e}function bH(e){Vl=e}function vH(e){AH=e}var Ct=class{constructor(e,t,n,r){this.kept=!1,this.isDisposedInternal=!1,this.shape=e.slice(),this.dtype=t||"float32",this.size=on(e),this.strides=Ki(e),this.dataId=n,this.id=r,this.rankType=this.rank<5?this.rank.toString():"higher"}get rank(){return this.shape.length}async buffer(){let e=await this.data();return Vl.buffer(this.shape,this.dtype,e)}bufferSync(){return Vl.buffer(this.shape,this.dtype,this.dataSync())}async array(){let e=await this.data();return Xi(this.shape,e,this.dtype==="complex64")}arraySync(){return Xi(this.shape,this.dataSync(),this.dtype==="complex64")}async data(){this.throwIfDisposed();let e=Cs().read(this.dataId);if(this.dtype==="string"){let t=await e;try{return t.map(n=>ff(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=Cs().readSync(this.dataId);if(this.dtype==="string")try{return e.map(t=>ff(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 Cs().read(this.dataId);return this.dtype==="string"?e:new Uint8Array(e.buffer)}dispose(){this.isDisposed||(Cs().disposeTensor(this),this.isDisposedInternal=!0)}get isDisposed(){return this.isDisposedInternal}throwIfDisposed(){if(this.isDisposed)throw new Error("Tensor is disposed.")}print(e=!1){return Vl.print(this,e)}clone(){return this.throwIfDisposed(),Vl.clone(this)}toString(e=!1){let t=this.dataSync();return gH(t,this.shape,this.dtype,e)}cast(e){return this.throwIfDisposed(),Vl.cast(this,e)}variable(e=!0,t,n){return this.throwIfDisposed(),Cs().makeVariable(this,e,t,n)}};Object.defineProperty(Ct,Symbol.hasInstance,{value:e=>!!e&&e.data!=null&&e.dataSync!=null&&e.throwIfDisposed!=null});function re(){return by("Tensor",()=>Ct)}re();var gf=class extends Ct{constructor(e,t,n,r){super(e.shape,e.dtype,e.dataId,r);this.trainable=t,this.name=n}assign(e){if(e.dtype!==this.dtype)throw new Error(`dtype of the new value (${e.dtype}) and previous value (${this.dtype}) must match`);if(!Da(e.shape,this.shape))throw new Error(`shape of the new value (${e.shape}) and previous value (${this.shape}) must match`);Cs().disposeTensor(this),this.dataId=e.dataId,Cs().incRef(this,null)}dispose(){Cs().disposeVariable(this),this.isDisposedInternal=!0}};Object.defineProperty(gf,Symbol.hasInstance,{value:e=>e instanceof Ct&&e.assign!=null&&e.assign instanceof Function});var Es={};De(Es,{assertTypesMatch:()=>n6,getTensorsInContainer:()=>fA,isTensorInList:()=>kH,makeTypesMatch:()=>Ut});var t6;(function(e){e.R0="R0",e.R1="R1",e.R2="R2",e.R3="R3",e.R4="R4",e.R5="R5",e.R6="R6"})(t6||(t6={}));var uA;(function(e){e.float32="float32",e.int32="int32",e.bool="int32",e.complex64="complex64"})(uA||(uA={}));var cA;(function(e){e.float32="float32",e.int32="int32",e.bool="bool",e.complex64="complex64"})(cA||(cA={}));var dA;(function(e){e.float32="float32",e.int32="float32",e.bool="float32",e.complex64="complex64"})(dA||(dA={}));var hA;(function(e){e.float32="complex64",e.int32="complex64",e.bool="complex64",e.complex64="complex64"})(hA||(hA={}));var wH={float32:dA,int32:uA,bool:cA,complex64:hA};function qr(e,t){if(e==="string"||t==="string"){if(e==="string"&&t==="string")return"string";throw new Error(`Can not upcast ${e} with ${t}`)}return wH[e][t]}function pA(e){return qr(e,"int32")}function Ut(e,t){if(e.dtype===t.dtype)return[e,t];let n=qr(e.dtype,t.dtype);return[e.cast(n),t.cast(n)]}function n6(e,t){z(e.dtype===t.dtype,()=>`The dtypes of the first(${e.dtype}) and second(${t.dtype}) input must match`)}function kH(e,t){return t.some(n=>n.id===e.id)}function fA(e){let t=[],n=new Set;return r6(e,t,n),t}function r6(e,t,n){if(e==null)return;if(e instanceof Ct){t.push(e);return}if(!IH(e))return;let r=e;for(let s in r){let a=r[s];n.has(a)||(n.add(a),r6(a,t,n))}}function IH(e){return Array.isArray(e)||typeof e=="object"}function mA(e){return e.kernelName!=null}var s6=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()}},xd=class{constructor(e){this.ENV=e,this.registry={},this.registryFactory={},this.pendingBackendInitId=0,this.state=new s6}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?(console.warn(`${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 dH(this.backendInstance),!0}setupRegisteredKernels(){q4(this.backendName).forEach(t=>{t.setupFunc!=null&&t.setupFunc(this.backendInstance)})}disposeRegisteredKernels(e){q4(e).forEach(n=>{n.disposeFunc!=null&&n.disposeFunc(this.registry[e])})}initializeBackend(e){let t=this.registryFactory[e];if(t==null)throw new Error(`Cannot initialize backend ${e}, no registration found.`);try{let n=t.factory();if(n&&!(n instanceof Bp)&&typeof n.then=="function"){let r=++this.pendingBackendInitId,s=n.then(a=>r<this.pendingBackendInitId?!1:(this.registry[e]=a,this.pendingBackendInit=null,!0)).catch(a=>(r<this.pendingBackendInitId||(this.pendingBackendInit=null,console.warn(`Initialization of backend ${e} failed`),console.warn(a.stack||a.message)),!1));return this.pendingBackendInit=s,{success:s,asyncInit:!0}}else return this.registry[e]=n,{success:!0,asyncInit:!1}}catch(n){return console.warn(`Initialization of backend ${e} failed`),console.warn(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:r,asyncInit:s}=this.initializeBackend(n);if(s||r)return{name:n,asyncInit:s}}throw new Error("Could not initialize any backends, all backend initializations failed.")}moveData(e,t){let n=this.state.tensorInfo.get(t),r=n.backend,s=this.readSync(t),a=r.refCount(t);r.disposeData(t,!0),n.backend=e,e.move(t,s,n.shape,n.dtype,a),this.shouldCheckForMemLeaks()&&this.state.numDataMovesStack[this.state.numDataMovesStack.length-1]++}tidy(e,t){let n=null;if(t==null){if(typeof e!="function")throw new Error("Please provide a function to tidy()");t=e}else{if(typeof e!="string"&&!(e instanceof String))throw new Error("When calling with two arguments, the first argument to tidy() must be a string");if(typeof t!="function")throw new Error("When calling with two arguments, the 2nd argument to tidy() must be a function");n=e}let r;return this.scopedRun(()=>this.startScope(n),()=>this.endScope(r),()=>(r=t(),r instanceof Promise&&console.error("Cannot return a Promise inside of tidy."),r))}scopedRun(e,t,n){e();try{let r=n();return t(),r}catch(r){throw t(),r}}nextTensorId(){return xd.nextTensorId++}nextVariableId(){return xd.nextVariableId++}clone(e){let t=G.runKernel(hl,{x:e}),n={x:e},r=a=>({x:()=>{let o="float32",i={x:a},l={dtype:o};return G.runKernel(el,i,l)}}),s=[];return this.addTapeNode(this.state.activeScope.name,n,[t],r,s,{}),t}runKernel(e,t,n){if(!(aA(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 r=this.backend.numDataIds(),s=0;n.forEach(i=>{s+=i.dtype==="complex64"?3:1});let a=this.state.numDataMovesStack[this.state.numDataMovesStack.length-1],o=r-t-s-a;if(o>0)throw new Error(`Backend '${this.backendName}' has an internal memory leak (${o} data ids) after running '${e}'`)}runKernelFunc(e){let t,n=[],r=this.isTapeOn(),s=this.state.numBytes,a=this.state.numTensors;this.shouldCheckForMemLeaks()&&this.state.numDataMovesStack.push(0);let o;this.backendName==null&&this.backend;let i,l=mA(e)?e.kernelName:this.state.activeScope!=null?this.state.activeScope.name:"";if(mA(e)){let{kernelName:p,inputs:f,attrs:m}=e;this.backendName==null&&this.backend;let g=aA(p,this.backendName);z(g!=null,()=>`Cannot find registered kernel '${p}' for backend '${this.backendName}'`),o=()=>{let y=this.backend.numDataIds();i=g.kernelFunc({inputs:f,attrs:m,backend:this.backend});let A=Array.isArray(i)?i:[i];this.shouldCheckForMemLeaks()&&this.checkKernelForMemLeak(p,y,A);let x=A.map(b=>{if(b.rank!=null)return b;let{dataId:v,shape:w,dtype:I}=b;return this.makeTensorFromDataId(v,w,I)});if(r){let b=this.getTensorsForGradient(p,f,x);n=this.saveTensorsForBackwardMode(b)}return x}}else{let{forwardFunc:p}=e,f=m=>{!r||(n=m.map(g=>this.keep(this.clone(g))))};o=()=>{let m=this.backend.numDataIds();i=this.tidy(()=>p(this.backend,f));let g=Array.isArray(i)?i:[i];return this.shouldCheckForMemLeaks()&&this.checkKernelForMemLeak(l,m,g),g}}let{inputs:u,attrs:c}=e,d=mA(e)?null:e.backwardsFunc,h;return this.scopedRun(()=>this.state.kernelDepth++,()=>this.state.kernelDepth--,()=>{!this.ENV.getBool("DEBUG")&&!this.state.profiling?t=o():(h=this.profiler.profileKernel(l,u,()=>o()),this.ENV.getBool("DEBUG")&&this.profiler.logKernelProfile(h),t=h.outputs)}),r&&this.addTapeNode(l,u,t,d,n,c),this.state.profiling&&this.state.activeProfile.kernels.push({name:l,bytesAdded:this.state.numBytes-s,totalBytesSnapshot:this.state.numBytes,tensorsAdded:this.state.numTensors-a,totalTensorsSnapshot:this.state.numTensors,inputShapes:Object.keys(u).map(p=>u[p]!=null?u[p].shape:null),outputShapes:t.map(p=>p.shape),kernelTimeMs:h.timeMs,extraInfo:h.extraInfo}),Array.isArray(i)?t:t[0]}saveTensorsForBackwardMode(e){return e.map(n=>this.keep(this.clone(n)))}getTensorsForGradient(e,t,n){let r=j4(e);if(r!=null){let s=r.inputsToSave||[],a=r.outputsToSave||[],o;r.saveAllInputs?(z(Array.isArray(t),()=>"saveAllInputs is true, expected inputs to be an array."),o=Object.keys(t).map(l=>t[l])):o=s.map(l=>t[l]);let i=n.filter((l,u)=>a[u]);return o.concat(i)}return[]}makeTensor(e,t,n,r){if(e==null)throw new Error("Values passed to engine.makeTensor() are null");n=n||"float32",r=r||this.backend;let s=e;n==="string"&&Vp(e[0])&&(s=e.map(i=>pf(i)));let a=r.write(s,t,n),o=new Ct(t,n,a,this.nextTensorId());if(this.trackTensor(o,r),n==="string"){let i=this.state.tensorInfo.get(a),l=L4(s);this.state.numBytes+=l-i.bytes,i.bytes=l}return o}makeTensorFromDataId(e,t,n,r){n=n||"float32";let s=new Ct(t,n,e,this.nextTensorId());return this.trackTensor(s,r),s}makeVariable(e,t=!0,n,r){n=n||this.nextVariableId().toString(),r!=null&&r!==e.dtype&&(e=e.cast(r));let s=new gf(e,t,n,this.nextTensorId());if(this.state.registeredVariables[s.name]!=null)throw new Error(`Variable with name ${s.name} was already registered`);return this.state.registeredVariables[s.name]=s,this.incRef(s,this.backend),s}trackTensor(e,t){this.state.numTensors++,e.dtype==="string"&&this.state.numStringTensors++;let n=0;e.dtype!=="complex64"&&e.dtype!=="string"&&(n=e.size*my(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 gf||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*my(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(r=>r.totalBytesSnapshot)),this.state.activeProfile.newBytes=this.state.numBytes-t,this.state.activeProfile.newTensors=this.state.numTensors-n;for(let r of this.state.activeProfile.kernels)r.kernelTimeMs=await r.kernelTimeMs,r.extraInfo=await r.extraInfo;return this.state.activeProfile}isTapeOn(){return this.state.gradientDepth>0&&this.state.kernelDepth===0}addTapeNode(e,t,n,r,s,a){let o={id:this.state.nextTapeNodeId++,kernelName:e,inputs:t,outputs:n,saved:s},i=j4(e);i!=null&&(r=i.gradFunc),r!=null&&(o.gradient=l=>(l=l.map((u,c)=>{if(u==null){let d=n[c],h=jp(d.size,d.dtype);return this.makeTensor(h,d.shape,d.dtype)}return u}),r(l.length>1?l:l[0],s,a))),this.state.activeTape.push(o)}keep(e){return e.kept=!0,e}startTape(){this.state.gradientDepth===0&&(this.state.activeTape=[]),this.state.gradientDepth++}endTape(){this.state.gradientDepth--}startScope(e){let t={track:[],name:"unnamed scope",id:this.state.nextScopeId++};e&&(t.name=e),this.state.scopeStack.push(t),this.state.activeScope=t}endScope(e){let t=fA(e),n=new Set(t.map(s=>s.id));for(let s=0;s<this.state.activeScope.track.length;s++){let a=this.state.activeScope.track[s];!a.kept&&!n.has(a.id)&&a.dispose()}let r=this.state.scopeStack.pop();this.state.activeScope=this.state.scopeStack.length===0?null:this.state.scopeStack[this.state.scopeStack.length-1],t.forEach(s=>{!s.kept&&s.scopeId===r.id&&this.track(s)})}gradients(e,t,n,r=!1){if(z(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 s=this.scopedRun(()=>this.startTape(),()=>this.endTape(),()=>this.tidy("forward",e));z(s instanceof Ct,()=>"The result y returned by f() must be a tensor.");let a=fH(this.state.activeTape,t,s);if(!r&&a.length===0&&t.length>0)throw new Error("Cannot compute gradient of y=f(x) with respect to x. Make sure that the f you passed encloses all operations that lead from x to y.");return this.tidy("backward",()=>{let o={};o[s.id]=n==null?SH(s.shape):n,mH(o,a,l=>this.tidy(l),TH);let i=t.map(l=>o[l.id]);return this.state.gradientDepth===0&&(this.state.activeTape.forEach(l=>{for(let u of l.saved)u.dispose()}),this.state.activeTape=null),{value:s,grads:i}})}customGrad(e){return z(Hp(e),()=>"The f passed in customGrad(f) must be a function."),(...t)=>{z(t.every(o=>o instanceof Ct),()=>"The args passed in customGrad(f)(x1, x2,...) must all be tensors");let n,r={};t.forEach((o,i)=>{r[i]=o});let s=(o,i)=>(n=e(...t,i),z(n.value instanceof Ct,()=>"The function f passed in customGrad(f) must return an object where `obj.value` is a tensor"),z(Hp(n.gradFunc),()=>"The function f passed in customGrad(f) must return an object where `obj.gradFunc` is a function."),n.value),a=(o,i)=>{let l=n.gradFunc(o,i),u=Array.isArray(l)?l:[l];z(u.length===t.length,()=>"The function f passed in customGrad(f) must return an object where `obj.gradFunc` is a function that returns the same number of tensors as inputs passed to f(...)."),z(u.every(d=>d instanceof Ct),()=>"The function f passed in customGrad(f) must return an object where `obj.gradFunc` is a function that returns a list of only tensors.");let c={};return u.forEach((d,h)=>{c[h]=()=>d}),c};return this.runKernelFunc({forwardFunc:s,backwardsFunc:a,inputs:r})}}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=md(),n=await this.backend.time(e);return n.wallMs=md()-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 s6;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}};xd.nextTensorId=0;xd.nextVariableId=0;function SH(e){let t=gy(on(e),"float32");return G.makeTensor(t,e,"float32")}function a6(){let e=G4();if(e._tfengine==null){let t=new KU(e);e._tfengine=new xd(t)}return JU(e._tfengine.ENV),xH(()=>e._tfengine),e._tfengine}var G=a6();function TH(e,t){let n={a:e,b:t};return G.runKernel(Fa,n)}var yf={};De(yf,{isBrowser:()=>o6,isMobile:()=>CH});function NH(){return typeof navigator!="undefined"&&navigator!=null}function CH(e){if(e||NH()){if(e||(e=navigator),e.product==="ReactNative")return!0;let t=e.userAgent||e.vendor||window.opera;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 o6(){return typeof window!="undefined"&&window.document!=null||typeof WorkerGlobalScope!="undefined"}var as=ae();as.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.")});as.registerFlag("IS_BROWSER",()=>o6());as.registerFlag("IS_NODE",()=>typeof process!="undefined"&&typeof process.versions!="undefined"&&typeof process.versions.node!="undefined");as.registerFlag("IS_CHROME",()=>typeof navigator!="undefined"&&navigator!=null&&navigator.userAgent!=null&&/Chrome/.test(navigator.userAgent)&&/Google Inc/.test(navigator.vendor));as.registerFlag("PROD",()=>!1);as.registerFlag("TENSORLIKE_CHECK_SHAPE_CONSISTENCY",()=>as.getBool("DEBUG"));as.registerFlag("DEPRECATION_WARNINGS_ENABLED",()=>!0);as.registerFlag("IS_TEST",()=>!1);as.registerFlag("CHECK_COMPUTATION_FOR_ERRORS",()=>!0);as.registerFlag("WRAP_TO_IMAGEBITMAP",()=>!1);function bd(e,t){let n=e;if(ss(e))return t==="string"?[]:[e.length];if(!Array.isArray(e))return[];let r=[];for(;Array.isArray(n)||ss(n)&&t!=="string";)r.push(n.length),n=n[0];return Array.isArray(e)&&ae().getBool("TENSORLIKE_CHECK_SHAPE_CONSISTENCY")&&i6(e,r,[]),r}function i6(e,t,n){if(n=n||[],!Array.isArray(e)&&!ss(e)){z(t.length===0,()=>`Element arr[${n.join("][")}] is a primitive, but should be an array/TypedArray of ${t[0]} elements`);return}z(t.length>0,()=>`Element arr[${n.join("][")}] should be a primitive, but is an array of ${e.length} elements`),z(e.length===t[0],()=>`Element arr[${n.join("][")}] should have ${t[0]} elements, but has ${e.length} elements`);let r=t.slice(1);for(let s=0;s<e.length;++s)i6(e[s],r,n.concat(s))}function l6(e,t,n,r){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 '${r}' must be ${e} tensor, but got ${t} tensor`)}}function O(e,t,n,r="numeric"){if(e instanceof Ct)return l6(r,e.dtype,t,n),e;let s=Up(e);if(s!=="string"&&["bool","int32","float32"].indexOf(r)>=0&&(s=r),l6(r,s,t,n),e==null||!ss(e)&&!Array.isArray(e)&&typeof e!="number"&&typeof e!="boolean"&&typeof e!="string"){let l=e==null?"null":e.constructor.name;throw new Error(`Argument '${t}' passed to '${n}' must be a Tensor or TensorLike, but got '${l}'`)}let a=bd(e,s);!ss(e)&&!Array.isArray(e)&&(e=[e]);let i=s!=="string"?hf(e,s):yc(e,[],!0);return G.makeTensor(i,a,s)}function Af(e,t,n,r="numeric"){if(!Array.isArray(e))throw new Error(`Argument ${t} passed to ${n} must be a \`Tensor[]\` or \`TensorLike[]\``);return e.map((a,o)=>O(a,`${t}[${o}]`,n,r))}var EH="__op";function V(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],r=e[n];n.endsWith("_")&&(n=n.substring(0,n.length-1)),n=n+EH;let s=(...a)=>{G.startScope(n);try{let o=r(...a);return Ay(o)&&console.error("Cannot return a Promise inside of tidy."),G.endScope(o),o}catch(o){throw G.endScope(null),o}};return Object.defineProperty(s,"name",{value:n,configurable:!0}),s}function $H(e,t){let n=O(e,"real","complex"),r=O(t,"imag","complex");rs(n.shape,r.shape,`real and imag shapes, ${n.shape} and ${r.shape}, must match in call to tf.complex().`);let s={real:n,imag:r};return G.runKernel(Iy,s)}var Uo=V({complex_:$H});function vd(e,t,n,r){if(r==null&&(r=Up(e)),r==="complex64")throw new Error("Cannot construct a complex64 tensor directly. Please use tf.complex(real, imag).");if(!ss(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){yy(t);let s=on(t),a=on(n);z(s===a,()=>`Based on the provided shape, [${t}], the tensor should have ${s} values but has ${a}`);for(let o=0;o<n.length;++o){let i=n[o],l=o===n.length-1?i!==on(t.slice(o)):!0;z(n[o]===t[o]||!l,()=>`Error creating a new Tensor. Inferred shape (${n}) does not match the provided shape (${t}). `)}}return!ss(e)&&!Array.isArray(e)&&(e=[e]),t=t||n,e=r!=="string"?hf(e,r):yc(e,[],!0),G.makeTensor(e,t,r)}function $s(e,t,n){let r=bd(e,n);return vd(e,t,r,n)}var gA={float32:4,float16:2,int32:4,uint16:2,uint8:1,bool:1,complex64:8},xf=4;async function _H(e,t){let n=[],r=[],s=Array.isArray(e)?e.map(o=>o.name):Object.keys(e);for(let o=0;o<s.length;++o){let i=s[o],l=Array.isArray(e)?e[o].tensor:e[i];if(l.dtype!=="float32"&&l.dtype!=="int32"&&l.dtype!=="bool"&&l.dtype!=="string"&&l.dtype!=="complex64")throw new Error(`Unsupported dtype in weight '${i}': ${l.dtype}`);let u={name:i,shape:l.shape,dtype:l.dtype};if(l.dtype==="string"){let c=new Promise(async d=>{let h=await l.bytes(),p=h.reduce((g,y)=>g+y.length,0)+xf*h.length,f=new Uint8Array(p),m=0;for(let g=0;g<h.length;g++){let y=h[g],A=new Uint8Array(new Uint32Array([y.length]).buffer);f.set(A,m),m+=xf,f.set(y,m),m+=y.length}d(f)});r.push(c)}else r.push(l.data());t!=null&&(u.group=t),n.push(u)}let a=await Promise.all(r);return{data:RH(a),specs:n}}function u6(e,t){let n={},r,s=0;for(let a of t){let o=a.name,i=a.dtype,l=a.shape,u=on(l),c;if("quantization"in a){let d=a.quantization;if(d.dtype==="uint8"||d.dtype==="uint16"){if(!("min"in d&&"scale"in d))throw new Error(`Weight ${a.name} with quantization ${d.dtype} doesn't have corresponding metadata min and scale.`)}else if(d.dtype==="float16"){if(i!=="float32")throw new Error(`Weight ${a.name} is quantized with ${d.dtype} which only supports weights of type float32 not ${i}.`)}else throw new Error(`Weight ${a.name} has unknown quantization dtype ${d.dtype}. Supported quantization dtypes are: 'uint8', 'uint16', and 'float16'.`);let h=gA[d.dtype],p=e.slice(s,s+u*h),f=d.dtype==="uint8"?new Uint8Array(p):new Uint16Array(p);if(i==="float32")if(d.dtype==="uint8"||d.dtype==="uint16"){c=new Float32Array(f.length);for(let m=0;m<f.length;m++){let g=f[m];c[m]=g*d.scale+d.min}}else if(d.dtype==="float16")r===void 0&&(r=zH()),c=r(f);else throw new Error(`Unsupported quantization type ${d.dtype} for weight type float32.`);else if(i==="int32"){if(d.dtype!=="uint8"&&d.dtype!=="uint16")throw new Error(`Unsupported quantization type ${d.dtype} for weight type int32.`);c=new Int32Array(f.length);for(let m=0;m<f.length;m++){let g=f[m];c[m]=Math.round(g*d.scale+d.min)}}else throw new Error(`Unsupported dtype in weight '${o}': ${i}`);s+=u*h}else if(i==="string"){let d=on(a.shape);c=[];for(let h=0;h<d;h++){let p=new Uint32Array(e.slice(s,s+xf))[0];s+=xf;let f=new Uint8Array(e.slice(s,s+p));c.push(f),s+=p}}else{let d=gA[i],h=e.slice(s,s+u*d);if(i==="float32")c=new Float32Array(h);else if(i==="int32")c=new Int32Array(h);else if(i==="bool")c=new Uint8Array(h);else if(i==="complex64"){c=new Float32Array(h);let p=new Float32Array(c.length/2),f=new Float32Array(c.length/2);for(let y=0;y<p.length;y++)p[y]=c[y*2],f[y]=c[y*2+1];let m=$s(p,l,"float32"),g=$s(f,l,"float32");n[o]=Uo(m,g),m.dispose(),g.dispose()}else throw new Error(`Unsupported dtype in weight '${o}': ${i}`);s+=u*d}i!=="complex64"&&(n[o]=$s(c,l,i))}return n}function RH(e){if(e===null)throw new Error(`Invalid input value: ${JSON.stringify(e)}`);let t=0,n=[];e.forEach(a=>{if(t+=a.byteLength,n.push(a.byteLength===a.buffer.byteLength?a:new a.constructor(a)),!(a instanceof Float32Array||a instanceof Int32Array||a instanceof Uint8Array))throw new Error(`Unsupported TypedArray subtype: ${a.constructor.name}`)});let r=new Uint8Array(t),s=0;return n.forEach(a=>{r.set(new Uint8Array(a.buffer),s),s+=a.byteLength}),r.buffer}var yA=typeof Buffer!="undefined"&&(typeof Blob=="undefined"||typeof atob=="undefined"||typeof btoa=="undefined");function c6(e){return yA?Buffer.byteLength(e):new Blob([e]).size}function DH(e){if(yA)return Buffer.from(e).toString("base64");let t=new Uint8Array(e),n="";for(let r=0,s=t.length;r<s;r++)n+=String.fromCharCode(t[r]);return btoa(n)}function FH(e){if(yA){let r=Buffer.from(e,"base64");return r.buffer.slice(r.byteOffset,r.byteOffset+r.byteLength)}let t=atob(e),n=new Uint8Array(t.length);for(let r=0;r<t.length;++r)n.set([t.charCodeAt(r)],r);return n.buffer}function AA(e){if(e.length===1)return e[0];let t=0;e.forEach(s=>{t+=s.byteLength});let n=new Uint8Array(t),r=0;return e.forEach(s=>{n.set(new Uint8Array(s),r),r+=s.byteLength}),n.buffer}function d6(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 wd(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:c6(JSON.stringify(e.modelTopology)),weightSpecsBytes:e.weightSpecs==null?0:c6(JSON.stringify(e.weightSpecs)),weightDataBytes:e.weightData==null?0:e.weightData.byteLength}}function MH(){let e=n=>{let r=n<<13,s=0;for(;(r&8388608)==0;)s-=8388608,r<<=1;return r&=~8388608,s+=947912704,r|s},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 OH(){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 PH(){let e=new Uint32Array(64);for(let t=0;t<64;t++)e[t]=1024;return e[0]=e[32]=0,e}function zH(){let e=MH(),t=OH(),n=PH();return r=>{let s=new ArrayBuffer(4*r.length),a=new Uint32Array(s);for(let o=0;o<r.length;o++){let i=r[o],l=e[n[i>>10]+(i&1023)]+t[i>>10];a[o]=l}return new Float32Array(s)}}var qt=class{constructor(){this.saveRouters=[],this.loadRouters=[]}static getInstance(){return qt.instance==null&&(qt.instance=new qt),qt.instance}static registerSaveRouter(e){qt.getInstance().saveRouters.push(e)}static registerLoadRouter(e){qt.getInstance().loadRouters.push(e)}static getSaveHandlers(e){return qt.getHandlers(e,"save")}static getLoadHandlers(e,t){return qt.getHandlers(e,"load",t)}static getHandlers(e,t,n){let r=[];return(t==="load"?qt.getInstance().loadRouters:qt.getInstance().saveRouters).forEach(a=>{let o=a(e,n);o!==null&&r.push(o)}),r}},LH=e=>qt.registerSaveRouter(e),BH=e=>qt.registerLoadRouter(e),WH=e=>qt.getSaveHandlers(e),VH=(e,t)=>qt.getLoadHandlers(e,t),xA="tensorflowjs",bA=1,Ho="models_store",Oa="model_info_store";function h6(){if(!ae().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 vA(e){let t=e.result;t.createObjectStore(Ho,{keyPath:"modelPath"}),t.createObjectStore(Oa,{keyPath:"modelPath"})}var Go=class{constructor(e){if(this.indexedDB=h6(),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,r)=>{let s=this.indexedDB.open(xA,bA);s.onupgradeneeded=()=>vA(s),s.onsuccess=()=>{let a=s.result;if(t==null){let o=a.transaction(Ho,"readonly"),l=o.objectStore(Ho).get(this.modelPath);l.onsuccess=()=>{if(l.result==null)return a.close(),r(new Error(`Cannot find model with path '${this.modelPath}' in IndexedDB.`));n(l.result.modelArtifacts)},l.onerror=u=>(a.close(),r(l.error)),o.oncomplete=()=>a.close()}else{let o=wd(t),i=a.transaction(Oa,"readwrite"),l=i.objectStore(Oa),u=l.put({modelPath:this.modelPath,modelArtifactsInfo:o}),c;u.onsuccess=()=>{c=a.transaction(Ho,"readwrite");let h=c.objectStore(Ho).put({modelPath:this.modelPath,modelArtifacts:t,modelArtifactsInfo:o});h.onsuccess=()=>n({modelArtifactsInfo:o}),h.onerror=p=>{l=i.objectStore(Oa);let f=l.delete(this.modelPath);f.onsuccess=()=>(a.close(),r(h.error)),f.onerror=m=>(a.close(),r(h.error))}},u.onerror=d=>(a.close(),r(u.error)),i.oncomplete=()=>{c==null?a.close():c.oncomplete=()=>a.close()}}},s.onerror=a=>r(s.error)})}};Go.URL_SCHEME="indexeddb://";var p6=e=>ae().getBool("IS_BROWSER")&&!Array.isArray(e)&&e.startsWith(Go.URL_SCHEME)?UH(e.slice(Go.URL_SCHEME.length)):null;qt.registerSaveRouter(p6);qt.registerLoadRouter(p6);function UH(e){return new Go(e)}function HH(e){return e.startsWith(Go.URL_SCHEME)?e.slice(Go.URL_SCHEME.length):e}var GH=class{constructor(){this.indexedDB=h6()}async listModels(){return new Promise((e,t)=>{let n=this.indexedDB.open(xA,bA);n.onupgradeneeded=()=>vA(n),n.onsuccess=()=>{let r=n.result,s=r.transaction(Oa,"readonly"),o=s.objectStore(Oa).getAll();o.onsuccess=()=>{let i={};for(let l of o.result)i[l.modelPath]=l.modelArtifactsInfo;e(i)},o.onerror=i=>(r.close(),t(o.error)),s.oncomplete=()=>r.close()},n.onerror=r=>t(n.error)})}async removeModel(e){return e=HH(e),new Promise((t,n)=>{let r=this.indexedDB.open(xA,bA);r.onupgradeneeded=()=>vA(r),r.onsuccess=()=>{let s=r.result,a=s.transaction(Oa,"readwrite"),o=a.objectStore(Oa),i=o.get(e),l;i.onsuccess=()=>{if(i.result==null)return s.close(),n(new Error(`Cannot find model with path '${e}' in IndexedDB.`));{let u=o.delete(e),c=()=>{l=s.transaction(Ho,"readwrite");let h=l.objectStore(Ho).delete(e);h.onsuccess=()=>t(i.result.modelArtifactsInfo),h.onerror=p=>n(i.error)};u.onsuccess=c,u.onerror=d=>(c(),s.close(),n(i.error))}},i.onerror=u=>(s.close(),n(i.error)),a.oncomplete=()=>{l==null?s.close():l.oncomplete=()=>s.close()}},r.onerror=s=>n(r.error)})}},aa="/",Ul="tensorflowjs_models",f6="info",jH="model_topology",qH="weight_specs",KH="weight_data",XH="model_metadata";function m6(e){return{info:[Ul,e,f6].join(aa),topology:[Ul,e,jH].join(aa),weightSpecs:[Ul,e,qH].join(aa),weightData:[Ul,e,KH].join(aa),modelMetadata:[Ul,e,XH].join(aa)}}function ZH(e){let t=e.split(aa);if(t.length<3)throw new Error(`Invalid key format: ${e}`);return t.slice(1,t.length-1).join(aa)}function YH(e){return e.startsWith(jo.URL_SCHEME)?e.slice(jo.URL_SCHEME.length):e}var jo=class{constructor(e){if(!ae().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=m6(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),r=wd(e);try{this.LS.setItem(this.keys.info,JSON.stringify(r)),this.LS.setItem(this.keys.topology,t),this.LS.setItem(this.keys.weightSpecs,n),this.LS.setItem(this.keys.weightData,DH(e.weightData));let s={format:e.format,generatedBy:e.generatedBy,convertedBy:e.convertedBy};return e.signature!=null&&(s.signature=e.signature),e.userDefinedMetadata!=null&&(s.userDefinedMetadata=e.userDefinedMetadata),e.modelInitializer!=null&&(s.modelInitializer=e.modelInitializer),this.LS.setItem(this.keys.modelMetadata,JSON.stringify(s)),{modelArtifactsInfo:r}}catch(s){throw this.LS.removeItem(this.keys.info),this.LS.removeItem(this.keys.topology),this.LS.removeItem(this.keys.weightSpecs),this.LS.removeItem(this.keys.weightData),this.LS.removeItem(this.keys.modelMetadata),new Error(`Failed to save model '${this.modelPath}' to local storage: size quota being exceeded is a possible cause of this failure: modelTopologyBytes=${r.modelTopologyBytes}, weightSpecsBytes=${r.weightSpecsBytes}, weightDataBytes=${r.weightDataBytes}.`)}}}async load(){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 r=JSON.parse(this.LS.getItem(this.keys.weightSpecs));if(r==null)throw new Error(`In local storage, the weight specs of model '${this.modelPath}' are missing.`);t.weightSpecs=r;let s=this.LS.getItem(this.keys.modelMetadata);if(s!=null){let o=JSON.parse(s);t.format=o.format,t.generatedBy=o.generatedBy,t.convertedBy=o.convertedBy,o.signature!=null&&(t.signature=o.signature),o.userDefinedMetadata!=null&&(t.userDefinedMetadata=o.userDefinedMetadata),o.modelInitializer!=null&&(t.modelInitializer=o.modelInitializer)}let a=this.LS.getItem(this.keys.weightData);if(a==null)throw new Error(`In local storage, the binary weight values of model '${this.modelPath}' are missing.`);return t.weightData=FH(a),t}};jo.URL_SCHEME="localstorage://";var g6=e=>ae().getBool("IS_BROWSER")&&!Array.isArray(e)&&e.startsWith(jo.URL_SCHEME)?JH(e.slice(jo.URL_SCHEME.length)):null;qt.registerSaveRouter(g6);qt.registerLoadRouter(g6);function JH(e){return new jo(e)}var QH=class{constructor(){z(ae().getBool("IS_BROWSER"),()=>"Current environment is not a web browser"),z(typeof window=="undefined"||typeof window.localStorage!="undefined",()=>"Current browser does not appear to support localStorage"),this.LS=window.localStorage}async listModels(){let e={},t=Ul+aa,n=aa+f6;for(let r=0;r<this.LS.length;++r){let s=this.LS.key(r);if(s.startsWith(t)&&s.endsWith(n)){let a=ZH(s);e[a]=JSON.parse(this.LS.getItem(s))}}return e}async removeModel(e){e=YH(e);let t=m6(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 this.LS.removeItem(t.info),this.LS.removeItem(t.topology),this.LS.removeItem(t.weightSpecs),this.LS.removeItem(t.weightData),n}},Hl="://",Er=class{constructor(){this.managers={}}static getInstance(){return Er.instance==null&&(Er.instance=new Er),Er.instance}static registerManager(e,t){z(e!=null,()=>"scheme must not be undefined or null."),e.endsWith(Hl)&&(e=e.slice(0,e.indexOf(Hl))),z(e.length>0,()=>"scheme must not be an empty string.");let n=Er.getInstance();z(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 bf(e){if(e.indexOf(Hl)===-1)throw new Error(`The url string provided does not contain a scheme. Supported schemes are: ${Er.getSchemes().join(",")}`);return{scheme:e.split(Hl)[0],path:e.split(Hl)[1]}}async function y6(e,t,n=!1){z(e!==t,()=>`Old path and new path are the same: '${e}'`);let r=qt.getLoadHandlers(e);z(r.length>0,()=>`Copying failed because no load handler is found for source URL ${e}.`),z(r.length<2,()=>`Copying failed because more than one (${r.length}) load handlers for source URL ${e}.`);let s=r[0],a=qt.getSaveHandlers(t);z(a.length>0,()=>`Copying failed because no save handler is found for destination URL ${t}.`),z(a.length<2,()=>`Copying failed because more than one (${r.length}) save handlers for destination URL ${t}.`);let o=a[0],i=bf(e).scheme,l=bf(e).path,u=i===bf(e).scheme,c=await s.load();n&&u&&await Er.getManager(i).removeModel(l);let d=await o.save(c);return n&&!u&&await Er.getManager(i).removeModel(l),d.modelArtifactsInfo}async function eG(){let e=Er.getSchemes(),t={};for(let n of e){let r=await Er.getManager(n).listModels();for(let s in r){let a=n+Hl+s;t[a]=r[s]}}return t}async function tG(e){let t=bf(e);return Er.getManager(t.scheme).removeModel(t.path)}async function nG(e,t){return y6(e,t,!1)}async function rG(e,t){return y6(e,t,!0)}var sG=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(ae().get("IS_BROWSER")){ae().setPlatform("browser",new sG);try{Er.registerManager(jo.URL_SCHEME,new QH)}catch(e){}try{Er.registerManager(Go.URL_SCHEME,new GH)}catch(e){}}var aG={importFetch:()=>O3()},wA,oG=class{constructor(){this.util=co("util"),this.textEncoder=new this.util.TextEncoder}fetch(e,t){return ae().global.fetch!=null?ae().global.fetch(e,t):(wA==null&&(wA=aG.importFetch()),wA(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)}};ae().get("IS_NODE")&&ae().setPlatform("node",new oG);function Le(e,t="float32",n){return t=t||"float32",yy(e),new Qt(e,t,n)}function iG(e,t){let n=O(e,"x","cast");if(!z4(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 r={x:n},s={dtype:t};return G.runKernel(el,r,s)}var ke=V({cast_:iG});function lG(e){let n={x:O(e,"x","clone","string_or_numeric")};return G.runKernel(hl,n)}var qo=V({clone_:lG});function uG(e,t=!1){console.log(e.toString(t))}a6();var cG={buffer:Le,cast:ke,clone:qo,print:uG};bH(cG);var ur={};De(ur,{browserFiles:()=>yG,browserHTTPRequest:()=>wG,concatenateArrayBuffers:()=>AA,copyModel:()=>nG,decodeWeights:()=>u6,encodeWeights:()=>_H,fromMemory:()=>IG,getLoadHandlers:()=>VH,getModelArtifactsInfoForJSON:()=>wd,getSaveHandlers:()=>WH,http:()=>SA,isHTTPScheme:()=>IA,listModels:()=>eG,loadWeights:()=>AG,moveModel:()=>rG,registerLoadRouter:()=>BH,registerSaveRouter:()=>LH,removeModel:()=>tG,weightsLoaderFactory:()=>v6,withSaveHandler:()=>SG});var dG="model",hG=".json",pG=".weights.bin";function A6(e){return new Promise(t=>setTimeout(t)).then(e)}var Gl=class{constructor(e){if(!ae().getBool("IS_BROWSER"))throw new Error("browserDownloads() cannot proceed because the current environment is not a browser.");e.startsWith(Gl.URL_SCHEME)&&(e=e.slice(Gl.URL_SCHEME.length)),(e==null||e.length===0)&&(e=dG),this.modelTopologyFileName=e+hG,this.weightDataFileName=e+pG}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}],r={modelTopology:e.modelTopology,format:e.format,generatedBy:e.generatedBy,convertedBy:e.convertedBy,weightsManifest:n};e.signature!=null&&(r.signature=e.signature),e.userDefinedMetadata!=null&&(r.userDefinedMetadata=e.userDefinedMetadata),e.modelInitializer!=null&&(r.modelInitializer=e.modelInitializer);let s=window.URL.createObjectURL(new Blob([JSON.stringify(r)],{type:"application/json"})),a=this.jsonAnchor==null?document.createElement("a"):this.jsonAnchor;if(a.download=this.modelTopologyFileName,a.href=s,await A6(()=>a.dispatchEvent(new MouseEvent("click"))),e.weightData!=null){let o=this.weightDataAnchor==null?document.createElement("a"):this.weightDataAnchor;o.download=this.weightDataFileName,o.href=t,await A6(()=>o.dispatchEvent(new MouseEvent("click")))}return{modelArtifactsInfo:wd(e)}}}};Gl.URL_SCHEME="downloads://";var fG=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.files=e}async load(){let e=this.files[0],t=this.files.slice(1);return new Promise((n,r)=>{let s=new FileReader;s.onload=a=>{let o=JSON.parse(a.target.result),i=o.modelTopology;if(i==null){r(new Error(`modelTopology field is missing from file ${e.name}`));return}t.length===0&&n({modelTopology:i});let l=o.weightsManifest;if(l==null){r(new Error(`weightManifest field is missing from file ${e.name}`));return}let u;try{u=this.checkManifestAndWeightFiles(l,t)}catch(p){r(p);return}let c=[],d=[],h=[];l.forEach(p=>{p.paths.forEach(f=>{d.push(f),h.push(null)}),c.push(...p.weights)}),l.forEach(p=>{p.paths.forEach(f=>{let m=new FileReader;m.onload=g=>{let y=g.target.result,A=d.indexOf(f);if(h[A]=y,h.indexOf(null)===-1){let x={modelTopology:i,weightSpecs:c,weightData:AA(h),format:o.format,generatedBy:o.generatedBy,convertedBy:o.convertedBy};o.signature!=null&&(x.signature=o.signature),o.userDefinedMetadata!=null&&(x.userDefinedMetadata=o.userDefinedMetadata),o.modelInitializer!=null&&(x.modelInitializer=o.modelInitializer),n(x)}},m.onerror=g=>r(`Failed to weights data from file of path '${f}'.`),m.readAsArrayBuffer(u[f])})})},s.onerror=a=>r(`Failed to read model topology and weights manifest JSON from file '${e.name}'. BrowserFiles supports loading Keras-style tf.Model artifacts only.`),s.readAsText(e)})}checkManifestAndWeightFiles(e,t){let n=[],r=t.map(a=>d6(a.name)),s={};for(let a of e)a.paths.forEach(o=>{let i=d6(o);if(n.indexOf(i)!==-1)throw new Error(`Duplicate file basename found in weights manifest: '${i}'`);if(n.push(i),r.indexOf(i)===-1)throw new Error(`Weight file with basename '${i}' is not provided.`);s[o]=t[r.indexOf(i)]});if(n.length!==t.length)throw new Error(`Mismatch in the number of files in weights manifest (${n.length}) and the number of weight files provided (${t.length}).`);return s}},mG=e=>ae().getBool("IS_BROWSER")&&!Array.isArray(e)&&e.startsWith(Gl.URL_SCHEME)?gG(e.slice(Gl.URL_SCHEME.length)):null;qt.registerSaveRouter(mG);function gG(e="model"){return new Gl(e)}function yG(e){return new fG(e)}function x6(e,t,n,r){o(e),n=n==null?0:n,r=r==null?1:r,i(n,r);let s=0,a=l=>(l.then(u=>{let c=n+ ++s/e.length*(r-n);return t(c),u}),l);function o(l){z(l!=null&&Array.isArray(l)&&l.length>0,()=>"promises must be a none empty array")}function i(l,u){z(l>=0&&l<=1,()=>`Progress fraction must be in range [0, 1], but got startFraction ${l}`),z(u>=0&&u<=1,()=>`Progress fraction must be in range [0, 1], but got endFraction ${u}`),z(u>=l,()=>`startFraction must be no more than endFraction, but got startFraction ${l} and endFraction ${u}`)}return Promise.all(e.map(a))}async function b6(e,t){t==null&&(t={});let n=t.fetchFunc==null?ae().platform.fetch:t.fetchFunc,r=e.map(d=>n(d,t.requestInit,{isBinary:!0})),s=0,a=.5,i=(t.onProgress==null?await Promise.all(r):await x6(r,t.onProgress,s,a)).map(d=>d.arrayBuffer()),l=.5,u=1;return t.onProgress==null?await Promise.all(i):await x6(i,t.onProgress,l,u)}async function AG(e,t="",n,r){return v6(o=>b6(o,{requestInit:r}))(e,t,n)}function v6(e){return async(t,n="",r)=>{let s=t.map(()=>!1),a={},o=r!=null?r.map(()=>!1):[],i=[];if(t.forEach((p,f)=>{let m=0;p.weights.forEach(g=>{let y="quantization"in g?g.quantization.dtype:g.dtype,A=gA[y]*on(g.shape),x=()=>{s[f]=!0,a[f]==null&&(a[f]=[]),a[f].push({manifestEntry:g,groupOffset:m,sizeBytes:A})};r!=null?r.forEach((b,v)=>{b===g.name&&(x(),o[v]=!0)}):x(),i.push(g.name),m+=A})}),!o.every(p=>p)){let p=r.filter((f,m)=>!o[m]);throw new Error(`Could not find weights in manifest with names: ${p.join(", ")}.
|
|
Manifest JSON has weights with names: ${i.join(", ")}.`)}let l=s.reduce((p,f,m)=>(f&&p.push(m),p),[]),u=[];l.forEach(p=>{t[p].paths.forEach(f=>{let m=n+(n.endsWith("/")?"":"/")+f;u.push(m)})});let c=await e(u),d={},h=0;return l.forEach(p=>{let f=t[p].paths.length,m=0;for(let b=0;b<f;b++)m+=c[h+b].byteLength;let g=new ArrayBuffer(m),y=new Uint8Array(g),A=0;for(let b=0;b<f;b++){let v=new Uint8Array(c[h+b]);y.set(v,A),A+=v.byteLength}a[p].forEach(b=>{let v=g.slice(b.groupOffset,b.groupOffset+b.sizeBytes),w=u6(v,[b.manifestEntry]);for(let I in w)d[I]=w[I]}),h+=f}),d}}var xG="application/octet-stream",bG="application/json",kA=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?(z(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=ae().platform.fetch,z(e!=null&&e.length>0,()=>"URL path for http must not be null, undefined or empty."),Array.isArray(e)&&z(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}],r={modelTopology:e.modelTopology,format:e.format,generatedBy:e.generatedBy,convertedBy:e.convertedBy,weightsManifest:n};e.signature!=null&&(r.signature=e.signature),e.userDefinedMetadata!=null&&(r.userDefinedMetadata=e.userDefinedMetadata),e.modelInitializer!=null&&(r.modelInitializer=e.modelInitializer),t.body.append("model.json",new Blob([JSON.stringify(r)],{type:bG}),"model.json"),e.weightData!=null&&t.body.append("model.weights.bin",new Blob([e.weightData],{type:xG}),"model.weights.bin");let s=await this.fetch(this.path,t);if(s.ok)return{modelArtifactsInfo:wd(e),responses:[s]};throw new Error(`BrowserHTTPRequest.save() failed due to HTTP response status ${s.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(p){let f=`Failed to parse model JSON of response from ${this.path}.`;throw this.path.endsWith(".pb")?f+=" 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.":f+=" Please make sure the server is serving valid JSON for this request.",new Error(f)}let n=t.modelTopology,r=t.weightsManifest,s=t.generatedBy,a=t.convertedBy,o=t.format,i=t.signature,l=t.userDefinedMetadata;if(n==null&&r==null)throw new Error(`The JSON from HTTP path ${this.path} contains neither model topology or manifest for weights.`);let u,c;r!=null&&([u,c]=await this.loadWeights(r));let d={modelTopology:n,weightSpecs:u,weightData:c,generatedBy:s,convertedBy:a,format:o};i!=null&&(d.signature=i),l!=null&&(d.userDefinedMetadata=l);let h=t.modelInitializer;return h&&(d.modelInitializer=h),d}async loadWeights(e){let t=Array.isArray(this.path)?this.path[1]:this.path,[n,r]=vG(t),s=this.weightPathPrefix||n,a=[];for(let u of e)a.push(...u.weights);let o=[],i=[];for(let u of e)for(let c of u.paths)this.weightUrlConverter!=null?i.push(this.weightUrlConverter(c)):o.push(s+c+r);this.weightUrlConverter&&o.push(...await Promise.all(i));let l=await b6(o,{requestInit:this.requestInit,fetchFunc:this.fetch,onProgress:this.onProgress});return[a,AA(l)]}};kA.URL_SCHEME_REGEX=/^https?:\/\//;function vG(e){let t=e.lastIndexOf("/"),n=e.lastIndexOf("?"),r=e.substring(0,t),s=n>t?e.substring(n):"";return[r+"/",s]}function IA(e){return e.match(kA.URL_SCHEME_REGEX)!=null}var w6=(e,t)=>{if(typeof fetch=="undefined"&&(t==null||t.fetchFunc==null))return null;{let n=!0;if(Array.isArray(e)?n=e.every(r=>IA(r)):n=IA(e),n)return SA(e,t)}return null};qt.registerSaveRouter(w6);qt.registerLoadRouter(w6);function SA(e,t){return new kA(e,t)}function wG(e,t){return SA(e,t)}var TA=class{constructor(e){this.modelArtifacts=e}async load(){return this.modelArtifacts}},kG=class{constructor(e){this.saveHandler=e}async save(e){return this.saveHandler(e)}};function IG(e,t,n,r){return arguments.length===1?e.modelTopology!=null||e.weightSpecs!=null?new TA(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 TA({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 TA({modelTopology:e,weightSpecs:t,weightData:n,trainingConfig:r}))}function SG(e){return new kG(e)}function TG(e,t,n=!1,r=!1){let s=O(e,"a","matMul"),a=O(t,"b","matMul");[s,a]=Ut(s,a);let o={a:s,b:a},i={transposeA:n,transposeB:r};return G.runKernel(Qi,o,i)}var ot=V({matMul_:TG});function NG(e,t,n=1,r=0){if(t<2)throw new Error(`Error in oneHot: depth must be >=2, but it is ${t}`);let a={indices:O(e,"indices","oneHot","int32")},o={depth:t,onValue:n,offValue:r};return G.runKernel(wl,a,o)}var kd=V({oneHot_:NG});function CG(e,t){let n=O(e,"x","transpose");if(t==null&&(t=n.shape.map((a,o)=>o).reverse()),z(n.rank===t.length,()=>`Error in transpose: rank of input ${n.rank} must match length of perm ${t}.`),t.forEach(a=>{z(a>=0&&a<n.rank,()=>`All entries in 'perm' must be between 0 and ${n.rank-1} but got ${t}`)}),n.rank<=1)return n.clone();let r={x:n},s={perm:t};return G.runKernel(zl,r,s)}var pt=V({transpose_:CG});function EG(e,t,n){let r=O(e,"labels","confusionMatrix"),s=O(t,"predictions","confusionMatrix");z(n==null||n>0&&Number.isInteger(n),()=>`If provided, numClasses must be a positive integer, but got ${n}`),z(r.rank===1,()=>`Expected the rank of labels to be 1, but got ${r.rank}`),z(s.rank===1,()=>`Expected the rank of predictions to be 1, but got ${s.rank}`),z(r.shape[0]===s.shape[0],()=>`Mismatch in the number of examples: ${r.shape[0]} vs. ${s.shape[0]}. Labels and predictions should have the same number of elements.`),z(n>0&&Number.isInteger(n),()=>`numClasses is required to be a positive integer, but got ${n}`);let a=kd(ke(r,"int32"),n),o=kd(ke(s,"int32"),n),i=pt(a),l=ot(i,o);return ke(l,"int32")}var mwe=V({confusionMatrix_:EG}),k6={};De(k6,{fromPixels:()=>PG,fromPixelsAsync:()=>MG,toPixels:()=>OG});function $G(e,t,n){if(Wp(e),t!=null&&t.length!==3)throw new Error("tensor3d() requires shape to have three numbers");let r=bd(e,n);if(r.length!==3&&r.length!==1)throw new Error("tensor3d() requires values to be number[][][] or flat/TypedArray");if(r.length===1&&t==null)throw new Error("tensor3d() requires shape to be provided when `values` are a flat array");return vd(e,t,r,n)}var jl;function I6(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,r=!1,s=!1,a=!1,o=!1,i=!1;if(e.data instanceof Uint8Array)n=!0;else if(typeof ImageData!="undefined"&&e instanceof ImageData)r=!0;else if(typeof HTMLVideoElement!="undefined"&&e instanceof HTMLVideoElement)s=!0;else if(typeof HTMLImageElement!="undefined"&&e instanceof HTMLImageElement)a=!0;else if(e.getContext!=null)o=!0;else if(typeof ImageBitmap!="undefined"&&e instanceof ImageBitmap)i=!0;else throw new Error(`pixels passed to tf.browser.fromPixels() must be either an HTMLVideoElement, HTMLImageElement, HTMLCanvasElement, ImageData in browser, or OffscreenCanvas, ImageData in webworker or {data: Uint32Array, width: number, height: number}, but was ${e.constructor.name}`);if(s){let f=2;if(s&&e.readyState<f)throw new Error("The video element has not loaded data yet. Please wait for `loadeddata` event on the <video> element.")}if(aA(rA,G.backendName)!=null){let f={pixels:e},m={numChannels:t};return G.runKernel(rA,f,m)}let[u,c]=s?[e.videoWidth,e.videoHeight]:[e.width,e.height],d;o?d=e.getContext("2d").getImageData(0,0,u,c).data:r||n?d=e.data:(a||s||i)&&(jl==null&&(jl=document.createElement("canvas").getContext("2d")),jl.canvas.width=u,jl.canvas.height=c,jl.drawImage(e,0,0,u,c),d=jl.getImageData(0,0,u,c).data);let h;if(t===4)h=new Int32Array(d);else{let f=u*c;h=new Int32Array(f*t);for(let m=0;m<f;m++)for(let g=0;g<t;++g)h[m*t+g]=d[m*4+g]}return $G(h,[c,u,t],"int32")}function _G(e){return e!=null&&e.data instanceof Uint8Array}function RG(){return typeof window!="undefined"&&typeof ImageBitmap!="undefined"&&window.hasOwnProperty("createImageBitmap")}function DG(e){return e!=null&&e.width!==0&&e.height!==0}function FG(e){return RG()&&!(e instanceof ImageBitmap)&&DG(e)&&!_G(e)}async function MG(e,t=3){let n=null;if(ae().getBool("WRAP_TO_IMAGEBITMAP")&&FG(e)){let r;try{r=await createImageBitmap(e,{premultiplyAlpha:"none"})}catch(s){r=null}r!=null&&r.width===e.width&&r.height===e.height?n=r:n=e}else n=e;return I6(n,t)}async function OG(e,t){let n=O(e,"img","toPixels");if(!(e instanceof Ct)){let u=n;n=ke(u,"int32"),u.dispose()}if(n.rank!==2&&n.rank!==3)throw new Error(`toPixels only supports rank 2 or 3 tensors, got rank ${n.rank}.`);let[r,s]=n.shape.slice(0,2),a=n.rank===2?1:n.shape[2];if(a>4||a===2)throw new Error(`toPixels only supports depth of size 1, 3 or 4 but got ${a}`);if(n.dtype!=="float32"&&n.dtype!=="int32")throw new Error(`Unsupported type for toPixels: ${n.dtype}. Please use float32 or int32 tensors.`);let o=await n.data(),i=n.dtype==="float32"?255:1,l=new Uint8ClampedArray(s*r*4);for(let u=0;u<r*s;++u){let c=[0,0,0,255];for(let h=0;h<a;h++){let p=o[u*a+h];if(n.dtype==="float32"){if(p<0||p>1)throw new Error(`Tensor values for a float32 Tensor must be in the range [0 - 1] but encountered ${p}.`)}else if(n.dtype==="int32"&&(p<0||p>255))throw new Error(`Tensor values for a int32 Tensor must be in the range [0 - 255] but encountered ${p}.`);a===1?(c[0]=p*i,c[1]=p*i,c[2]=p*i):c[h]=p*i}let d=u*4;l[d+0]=Math.round(c[0]),l[d+1]=Math.round(c[1]),l[d+2]=Math.round(c[2]),l[d+3]=Math.round(c[3])}if(t!=null){t.width=s,t.height=r;let u=t.getContext("2d"),c=new ImageData(l,s,r);u.putImageData(c,0,0)}return n!==e&&n.dispose(),l}var PG=V({fromPixels_:I6}),S6={};De(S6,{prepareAndValidate:()=>T6});function T6(e,t){let n=e.shape.length,r=t.shape.length;if(n<1)throw new Error(`tf.gatherND() expects the input to be rank 1 or higher, but the rank was ${n}.`);if(r<1)throw new Error(`tf.gatherND() expects the indices to be rank 1 or higher, but the rank was ${r}.`);if(t.dtype!=="int32")throw new Error(`tf.gatherND() expects the indices to be int32 type, but the dtype was ${t.dtype}.`);if(t.shape[r-1]>n)throw new Error(`index innermost dimension length must be <= tensor rank; saw: ${t.shape[r-1]} vs. ${n}`);if(on(e.shape)===0)throw new Error(`Requested more than 0 entries, but input is empty. Input shape: ${e.shape}.`);let s=t.shape,a=s[s.length-1],o=1;for(let d=0;d<s.length-1;++d)o*=s[d];let i=e.shape,l=s.slice();l.pop();let u=1;for(let d=a;d<n;++d)u*=i[d],l.push(i[d]);let c=[...Ki(e.shape).map(d=>d/u),1].slice(0,a);return[l,o,u,c]}var N6={};De(N6,{calculateShapes:()=>C6,validateInput:()=>CA,validateUpdateShape:()=>NA});function NA(e,t,n){let r=t.rank>1?t.shape[t.rank-1]:1,s=t.rank>1?t.rank-1:1,a=`Must have updates.shape = indices.shape[:batchDim] + shape[sliceDim:], got updates.shape: ${n.shape}, indices.shape: ${t.shape}, shape: ${e}, sliceDim: ${r}, and batchDim: ${s}.`;if(n.rank<s)throw new Error(a+` update.rank < ${s}. `);if(e.length<r+(n.rank-s))throw new Error(a+` Output shape length < ${r+(n.rank-s)}`);if(n.rank!==s+e.length-r)throw new Error(a+` update.rank != ${s+e.length-r}`);for(let o=0;o<s;++o)if(n.shape[o]!==t.shape[o])throw new Error(a+` updates.shape[${o}] (${n.shape[o]}) != indices.shape[${o}] (${t.shape[o]}).`);for(let o=0;o<n.rank-s;++o)if(n.shape[o+s]!==e[o+r])throw new Error(a+` updates.shape[${o+s}] (${n.shape[o+s]}) != shape[${o+s}] (${e[o+s]})`)}function CA(e,t,n){if(t.rank<1)throw new Error(`tf.scatterND() expects the indices to be rank 1 or higher, but the rank was ${t.rank}.`);if(e.rank<1)throw new Error(`tf.scatterND() expects the updates to be rank 1 or higher, but the rank was ${e.rank}.`);if(t.dtype!=="int32")throw new Error(`The dtype of 'indices' should be int32, but got dtype: ${t.dtype}`);if(n.length<1)throw new Error(`Output rank must be greater or equal to 1, but got shape: ${n}`);if(n.length===0){if(t.size===0)throw new Error(`Indices specified for empty output. indices shape: ${t.shape}`);if(e.size===0)throw new Error(`Updates specified for empty output. updates shape: ${e.shape}`)}NA(n,t,e)}function C6(e,t,n){let r=t.shape.length,s=r>1?t.shape[r-1]:1,a=n.length,o=1;for(let d=s;d<a;++d)o*=n[d];let i=s<1?1:s,l=on(t.shape)/i,u=[...Ki(n.slice(0,s)),1],c=on(n);return{sliceRank:s,numUpdates:l,sliceSize:o,strides:u,outputSize:c}}var En={};De(En,{assertParamsValid:()=>zG,computeFlatOffset:()=>BG,computeOutShape:()=>E6,getNormalizedAxes:()=>D6,isSliceContinous:()=>LG,maskToAxes:()=>vf,parseSliceParams:()=>L6,sliceInfo:()=>WG,startForAxis:()=>P6,startIndicesWithElidedDims:()=>F6,stopForAxis:()=>z6,stopIndicesWithElidedDims:()=>M6,stridesForAxis:()=>O6,stridesWithElidedDims:()=>$6});function zG(e,t,n){let r=e.shape.length;z(r===t.length,()=>`Error in slice${r}D: Length of begin ${t} must match the rank of the array (${r}).`),z(r===n.length,()=>`Error in slice${r}D: Length of size ${n} must match the rank of the array (${r}).`);for(let s=0;s<r;++s)z(t[s]+n[s]<=e.shape[s],()=>`Error in slice${r}D: begin[${s}] + size[${s}] (${t[s]+n[s]}) would overflow input.shape[${s}] (${e.shape[s]})`)}function vf(e){let t=[],n=0;for(;e>0;)e&1&&t.push(n),e/=2,n++;return t}function E6(e,t,n){let r=[];for(let s=0;s<e.length;s++)r[s]=Math.ceil((t[s]-e[s])/n[s]);return r}function $6(e,t,n,r){let s=[...e];for(let a=s.length;a<r.length;a++)s.push(1);for(let a=0;a<n;a++)a===0?s[t]=1:(s.splice(t,0,1),s.pop());return s}function _6(e,t,n){return n<=e?n:n-(t-1)}function R6(e,t){let n=[];for(let r=0;r<e;r++)n.push(t+r);return n}function D6(e,t,n,r,s,a,o,i,l){let u=e.length,c=new Array(u),d=new Array(u),h=new Array(u);if(t.length&&n>0){let p=t[0],f=n+1;c=F6(o,p,f,r,e),d=M6(i,p,f,s,e),h=$6(a,p,f,e)}else for(let p=0;p<u;p++)c[p]=P6(o,r,a,e,p,l),d[p]=z6(i,s,a,e,p,l),h[p]=O6(a,p,l);return{begin:c,end:d,strides:h}}function F6(e,t,n,r,s){let a=[...s],o=R6(n,t);for(let i=0;i<a.length;i++)if(o.indexOf(i)>-1)a[i]=0;else{let l=_6(t,n,i),u=r[l];e&1<<l&&(u=0),a[i]=u}return a}function M6(e,t,n,r,s){let a=[...s],o=R6(n,t);for(let i=0;i<a.length;i++)if(o.indexOf(i)>-1)a[i]=Number.MAX_SAFE_INTEGER;else{let l=_6(t,n,i),u=r[l];e&1<<l&&(u=Number.MAX_SAFE_INTEGER),a[i]=u}for(let i=0;i<a.length;i++){let l=s[i];a[i]<0&&(a[i]+=l),a[i]=gc(0,a[i],s[i])}return a}function O6(e,t,n){let r=e[t];return(n&1<<t||r==null)&&(r=1),r}function P6(e,t,n,r,s,a){let o=t[s],i=n[s]||1;(e&1<<s||a&1<<s||o==null)&&(i>0?o=Number.MIN_SAFE_INTEGER:o=Number.MAX_SAFE_INTEGER);let l=r[s];return o<0&&(o+=l),o=gc(0,o,l-1),o}function z6(e,t,n,r,s,a){let o=t[s],i=n[s]||1;(e&1<<s||a&1<<s||o==null)&&(i>0?o=Number.MAX_SAFE_INTEGER:o=Number.MIN_SAFE_INTEGER);let l=r[s];return o<0&&(o+=l),i>0?o=gc(0,o,l):o=gc(-1,o,l-1),o}function LG(e,t,n){let r=n.length;for(let s=0;s<n.length;s++)if(n[s]>1){r=s;break}for(let s=r+1;s<n.length;s++)if(t[s]>0||n[s]!==e[s])return!1;return!0}function BG(e,t){let n=e.length>0?e[e.length-1]:1;for(let r=0;r<e.length-1;r++)n+=e[r]*t[r];return n}function L6(e,t,n){let r,s=e.shape.length;typeof t=="number"?r=[t,...new Array(s-1).fill(0)]:t.length<s?r=t.concat(new Array(s-t.length).fill(0)):r=t.slice(),r.forEach(o=>{z(o!==-1,()=>"slice() does not support negative begin indexing.")});let a;return n==null?a=new Array(s).fill(-1):typeof n=="number"?a=[n,...new Array(s-1).fill(-1)]:n.length<s?a=n.concat(new Array(s-n.length).fill(-1)):a=n,a=a.map((o,i)=>o>=0?o:(z(o===-1,()=>`Negative size values should be exactly -1 but got ${o} for the slice() size at index ${i}.`),e.shape[i]-r[i])),[r,a]}function WG(e,t,n,r,s,a,o,i,l){let u=t.slice(),c=n.slice(),d=r;r==null&&(d=new Array(u.length));let h=vf(o);if(h.length>1)throw new Error("Multiple ellipses in slice is not allowed.");if(o!==0&&i!==0)throw new Error("Using both ellipsisMask and newAxisMask is not yet supported.");if(o!==0&&l!==0)throw new Error("Using both ellipsisMask and shrinkAxisMask is not yet supported.");let p=e.length-u.length,f=vf(i),m=e.slice();f.forEach(I=>{u[I]=0,c[I]=1,m.splice(I,0,1)});let{begin:g,end:y,strides:A}=D6(m,h,p,u,c,d,s,a,o);u=g,c=y,d=A;let x=vf(l);x.forEach(I=>{c[I]=u[I]+1,d[I]=1});let b=E6(u,c,d),v=b.filter((I,T)=>x.indexOf(T)===-1);return{nonStrided:d.every(I=>I===1),$begin:u,$end:c,$strides:d,size:b,newShape:m,outShape:v}}var ce={};De(ce,{Serializable:()=>B6,SerializationMap:()=>Ko,registerClass:()=>Pa});var B6=class{getClassName(){return this.constructor.className}static fromConfig(e,t){return new e(t)}},Ko=class{constructor(){this.classNameMap={}}static getMap(){return Ko.instance==null&&(Ko.instance=new Ko),Ko.instance}static register(e){Ko.getMap().classNameMap[e.className]=[e,e.fromConfig]}};function Pa(e){z(e.className!=null,()=>"Class being registered does not have the static className property defined."),z(typeof e.className=="string",()=>"className is required to be a string, but got type "+typeof e.className),z(e.className.length>0,()=>"Class being registered has an empty-string as its className, which is disallowed."),Ko.register(e)}function W6(e){ae().getBool("DEPRECATION_WARNINGS_ENABLED")&&console.warn(e+" You can disable deprecation warnings with tf.disableDeprecationWarnings().")}vH(W6);function za(){return G}function EA(){return G.memory()}function Z(e,t){return G.tidy(e,t)}function je(e){fA(e).forEach(n=>n.dispose())}function Sn(e){return G.keep(e)}function $A(e,t,n=1){return G.registerBackend(e,t,n)}function VG(){return G.backend}function UG(e,t){let n=O(e,"a","add"),r=O(t,"b","add");[n,r]=Ut(n,r);let s={a:n,b:r};return G.runKernel(Fa,s)}var pe=V({add_:UG});function HG(e,t){let n=O(e,"a","floorDiv"),r=O(t,"b","floorDiv");[n,r]=Ut(n,r);let s={a:n,b:r};return G.runKernel(ul,s)}var _A=V({floorDiv_:HG});function GG(e,t){let n=O(e,"a","div"),r=O(t,"b","div");if([n,r]=Ut(n,r),n.dtype==="int32"&&r.dtype==="int32")return _A(n,r);let s={a:n,b:r},a={};return G.runKernel(ol,s,a)}var Re=V({div_:GG});function jG(e,t){let n=O(e,"a","mul"),r=O(t,"b","mul");[n,r]=Ut(n,r);let s={a:n,b:r};return G.runKernel(Mo,s)}var K=V({mul_:jG});function qG(e){let t=O(e,"x","abs");if(t.dtype==="complex64"){let n={x:t};return G.runKernel(Zp,n)}else{let n={x:t};return G.runKernel(xc,n)}}var yn=V({abs_:qG});function KG(e){let n={x:O(e,"x","acos")};return G.runKernel(bc,n)}var V6=V({acos_:KG});function XG(e){let n={x:O(e,"x","acosh")};return G.runKernel(vc,n)}var U6=V({acosh_:XG});function ZG(e){z(Array.isArray(e),()=>"The argument passed to tf.addN() must be a list of tensors"),z(e.length>=1,()=>`Must pass at least one tensor to tf.addN(), but got ${e.length}`);let t=e.map((s,a)=>O(s,`tensors${a}`,"addN")),n=t[0];t.forEach(s=>{if(s.dtype!==n.dtype)throw new Error("All tensors passed to tf.addN() must have the same dtype")}),t.forEach(s=>{if(!Da(s.shape,n.shape))throw new Error("All tensors passed to tf.addN() must have the same shape")});let r=t;return G.runKernel(Zi,r)}var YG=V({addN_:ZG});function JG(e,t=null,n=!1){let s={x:O(e,"x","all","bool")},a={axis:t,keepDims:n};return G.runKernel(wc,s,a)}var RA=V({all_:JG});function QG(e,t=null,n=!1){let s={x:O(e,"x","any","bool")},a={axis:t,keepDims:n};return G.runKernel(kc,s,a)}var wf=V({any_:QG});function ej(e,t=0){let r={x:O(e,"x","argMax")},s={axis:t};return G.runKernel(Yi,r,s)}var kf=V({argMax_:ej});function tj(e,t=0){let r={x:O(e,"x","argMin")},s={axis:t};return G.runKernel(qp,r,s)}var H6=V({argMin_:tj});function nj(e){let n={x:O(e,"x","asin")};return G.runKernel(Ic,n)}var G6=V({asin_:nj});function rj(e){let n={x:O(e,"x","asinh")};return G.runKernel(Sc,n)}var j6=V({asinh_:rj});function sj(e){let n={x:O(e,"x","atan")};return G.runKernel(Tc,n)}var q6=V({atan_:sj});function aj(e,t){let n=O(e,"a","atan2"),r=O(t,"b","atan2");[n,r]=Ut(n,r);let s={a:n,b:r};return G.runKernel(Cc,s)}var K6=V({atan2_:aj});function oj(e){let n={x:O(e,"x","atanh")};return G.runKernel(Nc,n)}var X6=V({atanh_:oj});function ij(e,t,n,r,s="NHWC",a){let o=e[3],i=[...t,o],l=J6(s);return Id(e,i,n,a,r,null,null,l)}function Z6(e,t,n,r,s,a,o="channelsLast"){let[i,l]=If(t),u;if(o==="channelsLast")u=[i,l,e[3],e[3]];else if(o==="channelsFirst")u=[i,l,e[1],e[1]];else throw new Error(`Unknown dataFormat ${o}`);return Id(e,u,n,r,s,a,!1,o)}function lj(e,t,n,r,s,a,o="NDHWC"){let[i,l,u]=FA(t),c,d;if(o==="NDHWC")d="channelsLast",c=[i,l,u,e[4],e[4]];else if(o==="NCDHW")d="channelsFirst",c=[i,l,u,e[1],e[1]];else throw new Error(`Unknown dataFormat ${o}`);return Y6(e,c,n,r,s,!1,d,a)}function Id(e,t,n,r,s,a,o=!1,i="channelsLast"){let[l,u,c,d]=[-1,-1,-1,-1];if(i==="channelsLast")[l,u,c,d]=e;else if(i==="channelsFirst")[l,d,u,c]=e;else throw new Error(`Unknown dataFormat ${i}`);let[h,p,,f]=t,[m,g]=If(n),[y,A]=If(r),x=ql(h,y),b=ql(p,A),{padInfo:v,outHeight:w,outWidth:I}=dj(s,u,c,m,g,x,b,a,i),T=o?f*d:f,C;return i==="channelsFirst"?C=[l,T,w,I]:i==="channelsLast"&&(C=[l,w,I,T]),{batchSize:l,dataFormat:i,inHeight:u,inWidth:c,inChannels:d,outHeight:w,outWidth:I,outChannels:T,padInfo:v,strideHeight:m,strideWidth:g,filterHeight:h,filterWidth:p,effectiveFilterHeight:x,effectiveFilterWidth:b,dilationHeight:y,dilationWidth:A,inShape:e,outShape:C,filterShape:t}}function Y6(e,t,n,r,s,a=!1,o="channelsLast",i){let[l,u,c,d,h]=[-1,-1,-1,-1,-1];if(o==="channelsLast")[l,u,c,d,h]=e;else if(o==="channelsFirst")[l,h,u,c,d]=e;else throw new Error(`Unknown dataFormat ${o}`);let[p,f,m,,g]=t,[y,A,x]=FA(n),[b,v,w]=FA(r),I=ql(p,b),T=ql(f,v),C=ql(m,w),{padInfo:M,outDepth:$,outHeight:R,outWidth:N}=hj(s,u,c,d,y,A,x,I,T,C,i),F=a?g*h:g,B;return o==="channelsFirst"?B=[l,F,$,R,N]:o==="channelsLast"&&(B=[l,$,R,N,F]),{batchSize:l,dataFormat:o,inDepth:u,inHeight:c,inWidth:d,inChannels:h,outDepth:$,outHeight:R,outWidth:N,outChannels:F,padInfo:M,strideDepth:y,strideHeight:A,strideWidth:x,filterDepth:p,filterHeight:f,filterWidth:m,effectiveFilterDepth:I,effectiveFilterHeight:T,effectiveFilterWidth:C,dilationDepth:b,dilationHeight:v,dilationWidth:w,inShape:e,outShape:B,filterShape:t}}function uj(e,t,n,r,s){r==null&&(r=DA(e,t,n));let a=e[0],o=e[1],i=Xo((a-t+2*r)/n+1,s),l=Xo((o-t+2*r)/n+1,s);return[i,l]}function cj(e,t,n,r,s,a){s==null&&(s=DA(e,t,r));let o=e[0],i=e[1],l=e[2],u=Xo((o-t+2*s)/r+1,a),c=Xo((i-t+2*s)/r+1,a),d=Xo((l-t+2*s)/r+1,a);return[u,c,d,n]}function DA(e,t,n,r=1){let s=ql(t,r);return Math.floor((e[0]*(n-1)-n+s)/2)}function If(e){return typeof e=="number"?[e,e,e]:e.length===2?[e[0],e[1],1]:e}function FA(e){return typeof e=="number"?[e,e,e]:e}function ql(e,t){return t<=1?e:e+(e-1)*(t-1)}function dj(e,t,n,r,s,a,o,i,l){let u,c,d;if(typeof e=="number"){u={top:e,bottom:e,left:e,right:e,type:e===0?"VALID":"NUMBER"};let p=uj([t,n],a,r,e,i);c=p[0],d=p[1]}else if(e==="same"){c=Math.ceil(t/r),d=Math.ceil(n/s);let h=Math.max(0,(c-1)*r+a-t),p=Math.max(0,(d-1)*s+o-n),f=Math.floor(h/2),m=h-f,g=Math.floor(p/2),y=p-g;u={top:f,bottom:m,left:g,right:y,type:"SAME"}}else if(e==="valid")u={top:0,bottom:0,left:0,right:0,type:"VALID"},c=Math.ceil((t-a+1)/r),d=Math.ceil((n-o+1)/s);else if(typeof e=="object"){let h=l==="channelsLast"?e[1][0]:e[2][0],p=l==="channelsLast"?e[1][1]:e[2][1],f=l==="channelsLast"?e[2][0]:e[3][0],m=l==="channelsLast"?e[2][1]:e[3][1];u={top:h,bottom:p,left:f,right:m,type:h===0&&p===0&&f===0&&m===0?"VALID":"EXPLICIT"},c=Xo((t-a+h+p)/r+1,i),d=Xo((n-o+f+m)/s+1,i)}else throw Error(`Unknown padding parameter: ${e}`);return{padInfo:u,outHeight:c,outWidth:d}}function hj(e,t,n,r,s,a,o,i,l,u,c){let d,h,p,f;if(typeof e=="number"){d={top:e,bottom:e,left:e,right:e,front:e,back:e,type:e===0?"VALID":"NUMBER"};let g=cj([t,n,r,1],i,1,s,e,c);h=g[0],p=g[1],f=g[2]}else if(e==="same"){h=Math.ceil(t/s),p=Math.ceil(n/a),f=Math.ceil(r/o);let m=(h-1)*s+i-t,g=(p-1)*a+l-n,y=(f-1)*o+u-r,A=Math.floor(m/2),x=m-A,b=Math.floor(g/2),v=g-b,w=Math.floor(y/2),I=y-w;d={top:b,bottom:v,left:w,right:I,front:A,back:x,type:"SAME"}}else if(e==="valid")d={top:0,bottom:0,left:0,right:0,front:0,back:0,type:"VALID"},h=Math.ceil((t-i+1)/s),p=Math.ceil((n-l+1)/a),f=Math.ceil((r-u+1)/o);else throw Error(`Unknown padding parameter: ${e}`);return{padInfo:d,outDepth:h,outHeight:p,outWidth:f}}function Xo(e,t){if(!t)return Math.trunc(e);switch(t){case"round":return Math.round(e);case"ceil":return Math.ceil(e);case"floor":return Math.floor(e);default:throw new Error(`Unknown roundingMode ${t}`)}}function La(e){let[t,n,r]=If(e);return t===1&&n===1&&r===1}function _s(e,t){return La(e)||La(t)}function J6(e){if(e==="NHWC")return"channelsLast";if(e==="NCHW")return"channelsFirst";throw new Error(`Unknown dataFormat ${e}`)}function pj(e,t){let r={x:O(e,"x","reshape","string_or_numeric")},s={shape:t};return G.runKernel(Qc,r,s)}var J=V({reshape_:pj});function fj(e,t,n,r,s){let a=O(e,"x","avgPool","float32"),o=1;z(_s(n,o),()=>`Error in avgPool: Either strides or dilations must be 1. Got strides ${n} and dilations '${o}'`);let i=a,l=!1;a.rank===3&&(l=!0,i=J(a,[1,a.shape[0],a.shape[1],a.shape[2]])),z(i.rank===4,()=>`Error in avgPool: x must be rank 4 but got rank ${i.rank}.`),s!=null&&z(mn(r),()=>`Error in avgPool: pad must be an integer when using, dimRoundingMode ${s} but got pad ${r}.`);let u={x:i},c={filterSize:t,strides:n,pad:r,dimRoundingMode:s},d=G.runKernel(Ji,u,c);return d=ke(d,a.dtype),l?J(d,[d.shape[1],d.shape[2],d.shape[3]]):d}var Sf=V({avgPool_:fj});function mj(e,t,n,r,s,a="NDHWC"){let o=O(e,"x","avgPool3d","float32"),i=o,l=!1;o.rank===4&&(l=!0,i=J(o,[1,o.shape[0],o.shape[1],o.shape[2],o.shape[3]])),z(i.rank===5,()=>`Error in avgPool3d: x must be rank 5 but got rank ${i.rank}.`),z(a==="NDHWC",()=>`Error in avgPool3d: Only NDHWC is currently supported, but got dataFormat of ${a}`),s!=null&&z(mn(r),()=>`Error in avgPool3d: pad must be an integer when using, dimRoundingMode ${s} but got pad ${r}.`);let u={x:i},c={filterSize:t,strides:n,pad:r,dimRoundingMode:s,dataFormat:a},d=G.runKernel(Kp,u,c);return d=ke(d,i.dtype),l?J(d,[d.shape[1],d.shape[2],d.shape[3],d.shape[4]]):d}var Q6=V({avgPool3d_:mj});function gj(e,t=0){z(e.length>=1,()=>"Pass at least one tensor to concat");let n=Af(e,"tensors","concat","string_or_numeric");if(n[0].dtype==="complex64"&&n.forEach(a=>{if(a.dtype!=="complex64")throw new Error(`Cannot concatenate complex64 tensors with a tensor
|
|
with dtype ${a.dtype}. `)}),n.length===1)return qo(n[0]);let r=n,s={axis:t};return G.runKernel(Ec,r,s)}var en=V({concat_:gj});function yj(e){let n={x:O(e,"x","sigmoid")};return G.runKernel(Rl,n)}var Rs=V({sigmoid_:yj});function Aj(e,t,n){let r=O(e,"x","slice","string_or_numeric");if(r.rank===0)throw new Error("Slicing scalar is not possible");let s={x:r},a={begin:t,size:n};return G.runKernel(rd,s,a)}var nt=V({slice_:Aj});function xj(e){let n={x:O(e,"x","tanh")};return G.runKernel(Pl,n)}var Kl=V({tanh_:xj});function bj(e,t,n,r,s,a){let o=O(e,"forgetBias","basicLSTMCell"),i=O(t,"lstmKernel","basicLSTMCell"),l=O(n,"lstmBias","basicLSTMCell"),u=O(r,"data","basicLSTMCell"),c=O(s,"c","basicLSTMCell"),d=O(a,"h","basicLSTMCell"),h=en([u,d],1),p=ot(h,i),f=pe(p,l),m=f.shape[0],g=f.shape[1]/4,y=[m,g],A=nt(f,[0,0],y),x=nt(f,[0,g],y),b=nt(f,[0,g*2],y),v=nt(f,[0,g*3],y),w=pe(K(Rs(A),Kl(x)),K(c,Rs(pe(o,b)))),I=K(Kl(w),Rs(v));return[w,I]}var gwe=V({basicLSTMCell_:bj});function vj(e,t,n){let r=O(e,"x","batchToSpaceND"),s=t.reduce((i,l)=>i*l);z(r.rank>=1+t.length,()=>`input rank is ${r.rank} but should be > than blockShape.length ${t.length}`),z(n.length===t.length,()=>`crops.length is ${n.length} but should be equal to blockShape.length ${t.length}`),z(r.shape[0]%s==0,()=>`input tensor batch is ${r.shape[0]} but is not divisible by the product of the elements of blockShape ${t.join(" * ")} === ${s}`);let a={x:r},o={blockShape:t,crops:n};return G.runKernel(Xp,a,o)}var Tf=V({batchToSpaceND_:vj});function wj(e){let t;return e.rank===0||e.rank===1?t=J(e,[1,1,1,e.size]):e.rank===2?t=J(e,[1,1,e.shape[0],e.shape[1]]):e.rank===3?t=J(e,[1,e.shape[0],e.shape[1],e.shape[2]]):t=e,t}function kj(e,t,n,r,s,a){a==null&&(a=.001);let o=O(e,"x","batchNorm"),i=O(t,"mean","batchNorm"),l=O(n,"variance","batchNorm"),u;s!=null&&(u=O(s,"scale","batchNorm"));let c;r!=null&&(c=O(r,"offset","batchNorm")),z(i.rank===l.rank,()=>"Batch normalization gradient requires mean and variance to have equal ranks."),z(c==null||i.rank===c.rank,()=>"Batch normalization gradient requires mean and offset to have equal ranks."),z(u==null||i.rank===u.rank,()=>"Batch normalization gradient requires mean and scale to have equal ranks.");let h={x:wj(o),scale:u,offset:c,mean:i,variance:l},p={varianceEpsilon:a},f=G.runKernel(cl,h,p);return J(f,o.shape)}var Xl=V({batchNorm_:kj});function Ij(e,t,n,r,s,a){let o=O(e,"x","batchNorm"),i=O(t,"mean","batchNorm"),l=O(n,"variance","batchNorm"),u;s!=null&&(u=O(s,"scale","batchNorm"));let c;return r!=null&&(c=O(r,"offset","batchNorm")),z(o.rank===2,()=>`Error in batchNorm2D: x must be rank 2 but got rank ${o.rank}.`),z(i.rank===2||i.rank===1,()=>`Error in batchNorm2D: mean must be rank 2 or rank 1 but got rank ${i.rank}.`),z(l.rank===2||l.rank===1,()=>`Error in batchNorm2D: variance must be rank 2 or rank 1 but got rank ${l.rank}.`),u!=null&&z(u.rank===2||u.rank===1,()=>`Error in batchNorm2D: scale must be rank 2 or rank 1 but got rank ${u.rank}.`),c!=null&&z(c.rank===2||c.rank===1,()=>`Error in batchNorm2D: offset must be rank 2 or rank 1 but got rank ${c.rank}.`),Xl(o,i,l,c,u,a)}var Sj=V({batchNorm2d_:Ij});function Tj(e,t,n,r,s,a){let o=O(e,"x","batchNorm"),i=O(t,"mean","batchNorm"),l=O(n,"variance","batchNorm"),u;s!=null&&(u=O(s,"scale","batchNorm"));let c;return r!=null&&(c=O(r,"offset","batchNorm")),z(o.rank===3,()=>`Error in batchNorm3D: x must be rank 3 but got rank ${o.rank}.`),z(i.rank===3||i.rank===1,()=>`Error in batchNorm3D: mean must be rank 3 or rank 1 but got rank ${i.rank}.`),z(l.rank===3||l.rank===1,()=>`Error in batchNorm3D: variance must be rank 3 or rank 1 but got rank ${l.rank}.`),u!=null&&z(u.rank===3||u.rank===1,()=>`Error in batchNorm3D: scale must be rank 3 or rank 1 but got rank ${u.rank}.`),c!=null&&z(c.rank===3||c.rank===1,()=>`Error in batchNorm3D: offset must be rank 3 or rank 1 but got rank ${c.rank}.`),Xl(o,i,l,c,u,a)}var Nj=V({batchNorm3d_:Tj});function Cj(e,t,n,r,s,a){let o=O(e,"x","batchNorm"),i=O(t,"mean","batchNorm"),l=O(n,"variance","batchNorm"),u;s!=null&&(u=O(s,"scale","batchNorm"));let c;return r!=null&&(c=O(r,"offset","batchNorm")),z(o.rank===4,()=>`Error in batchNorm4D: x must be rank 4 but got rank ${o.rank}.`),z(i.rank===4||i.rank===1,()=>`Error in batchNorm4D: mean must be rank 4 or rank 1 but got rank ${i.rank}.`),z(l.rank===4||l.rank===1,()=>`Error in batchNorm4D: variance must be rank 4 or rank 1 but got rank ${l.rank}.`),u!=null&&z(u.rank===4||u.rank===1,()=>`Error in batchNorm4D: scale must be rank 4 or rank 1 but got rank ${u.rank}.`),c!=null&&z(c.rank===4||c.rank===1,()=>`Error in batchNorm4D: offset must be rank 4 or rank 1 but got rank ${c.rank}.`),Xl(o,i,l,c,u,a)}var Ej=V({batchNorm4d_:Cj});function $j(e,t,n){let r=O(e,"x","bincount"),s=O(t,"weights","bincount");z(r.dtype==="int32",()=>`Error in bincount: input dtype must be int32, but got ${r.dtype}`),z(n>=0,()=>`size must be non-negative, but got ${n}.`),z(s.size===r.size||s.size===0,()=>`Error in bincount: weights must have the same size as input or0-length, but got input shape: ${r.shape}, weights shape: ${s.shape}.`);let a={x:r,weights:s},o={size:n};return G.runKernel(ky,a,o)}var eI=V({bincount_:$j});function _j(e,t){let n=O(e,"broadcastTo","x"),r=n.shape;if(t.some(u=>!(u>0)||u%1!=0))throw new Error(`broadcastTo(): Invalid broadcast shape [${t}].`);if(t.length<n.rank)throw new Error(`broadcastTo(): shape.length=${t.length} < input.rank=${n.rank}.`);if(t.length>n.rank){let u=n.shape.slice();for(;u.length<t.length;)u.unshift(1);n=J(n,u)}let s=n.shape,a=Array.from(t);for(let u=t.length-1;u>=0;u--)if(s[u]===t[u])a[u]=1;else if(n.shape[u]!==1)throw new Error(`broadcastTo(): [${r}] cannot be broadcast to [${t}].`);if(a.map((u,c)=>u>1?c:-1).filter(u=>u>=0).length===0)return qo(n);let i={x:n},l={reps:a};return G.runKernel(Lo,i,l)}var Sd=V({broadcastTo_:_j});function Rj(e){let n={x:O(e,"x","ceil")};return G.runKernel(No,n)}var tI=V({ceil_:Rj});function Dj(e,t,n){let r=O(e,"x","clipByValue");z(t<=n,()=>`Error in clip: min (${t}) must be less than or equal to max (${n}).`);let s={x:r},a={clipValueMin:t,clipValueMax:n};return G.runKernel(Co,s,a)}var cr=V({clipByValue_:Dj});function Fj(e){return en(e,0)}var Mj=V({concat1d_:Fj});function Oj(e,t){return en(e,t)}var Pj=V({concat2d_:Oj});function zj(e,t){return en(e,t)}var Lj=V({concat3d_:zj});function Bj(e,t){return en(e,t)}var Wj=V({concat4d_:Bj});function Vj(e,t,n,r,s="NHWC",a=[1,1],o){let i=O(e,"x","conv2d"),l=O(t,"filter","conv2d"),u=i,c=!1;i.rank===3&&(c=!0,u=J(i,[1,i.shape[0],i.shape[1],i.shape[2]])),z(u.rank===4,()=>`Error in conv2d: input must be rank 4, but got rank ${u.rank}.`),z(l.rank===4,()=>`Error in conv2d: filter must be rank 4, but got rank ${l.rank}.`),o!=null&&z(mn(r),()=>`Error in conv2d: pad must be an integer when using, dimRoundingMode ${o} but got pad ${r}.`);let d=s==="NHWC"?u.shape[3]:u.shape[1];z(d===l.shape[2],()=>`Error in conv2d: depth of input (${d}) must match input depth for filter ${l.shape[2]}.`),z(_s(n,a),()=>`Error in conv2D: Either strides or dilations must be 1. Got strides ${n} and dilations '${a}'`);let h={x:u,filter:l},p={strides:n,pad:r,dataFormat:s,dilations:a,dimRoundingMode:o},f=G.runKernel(tl,h,p);return c?J(f,[f.shape[1],f.shape[2],f.shape[3]]):f}var Ba=V({conv2d_:Vj});function Uj(e,t,n,r,s="NWC",a=1,o){let i=O(e,"x","conv1d"),l=O(t,"filter","conv1d"),u=i,c=!1;i.rank===2&&(c=!0,u=J(i,[1,i.shape[0],i.shape[1]])),z(u.rank===3,()=>`Error in conv1d: input must be rank 3, but got rank ${u.rank}.`),z(l.rank===3,()=>`Error in conv1d: filter must be rank 3, but got rank ${l.rank}.`),o!=null&&z(mn(r),()=>`Error in conv1d: pad must be an integer when using, dimRoundingMode ${o} but got pad ${r}.`),z(u.shape[2]===l.shape[1],()=>`Error in conv1d: depth of input (${u.shape[2]}) must match input depth for filter ${l.shape[1]}.`),z(_s(n,a),()=>`Error in conv1D: Either stride or dilation must be 1. Got stride ${n} and dilation '${a}'`),z(s==="NWC",()=>`Error in conv1d: got dataFormat of ${s} but only NWC is currently supported.`);let d=J(l,[1,l.shape[0],l.shape[1],l.shape[2]]),h=J(u,[u.shape[0],1,u.shape[1],u.shape[2]]),g=Ba(h,d,[1,n],r,"NHWC",[1,a],o);return c?J(g,[g.shape[2],g.shape[3]]):J(g,[g.shape[0],g.shape[2],g.shape[3]])}var MA=V({conv1d_:Uj});function Hj(e,t,n,r,s,a="NHWC",o){z(e.length===t.rank,()=>`Length of inShape (${e.length}) and rank of dy (${t.rank}) must match`);let i=e,l=t,u=!1;t.rank===3&&(u=!0,l=J(t,[1,t.shape[0],t.shape[1],t.shape[2]]),i=[1,e[0],e[1],e[2]]),z(i.length===4,()=>`Error in conv2dDerInput: inShape must be length 4, but got length ${i.length}.`),z(l.rank===4,()=>`Error in conv2dDerInput: dy must be rank 4, but got rank ${l.rank}`),z(n.rank===4,()=>`Error in conv2dDerInput: filter must be rank 4, but got rank ${n.rank}`);let c=a==="NHWC"?i[3]:i[1],d=a==="NHWC"?l.shape[3]:l.shape[1];z(c===n.shape[2],()=>`Error in conv2dDerInput: depth of input (${c}) must match input depth for filter ${n.shape[2]}.`),z(d===n.shape[3],()=>`Error in conv2dDerInput: depth of output (${d}) must match output depth for filter ${n.shape[3]}.`),o!=null&&z(mn(s),()=>`Error in conv2dDerInput: pad must be an integer when using, dimRoundingMode ${o} but got pad ${s}.`);let h={dy:l,filter:n},p={strides:r,pad:s,dataFormat:a,dimRoundingMode:o,inputShape:i},f=G.runKernel(nl,h,p);return u?J(f,[f.shape[1],f.shape[2],f.shape[3]]):f}var OA=V({conv2DBackpropInput_:Hj});function Gj(e,t,n,r,s,a){let o=O(e,"x","conv2dTranspose"),i=O(t,"filter","conv2dTranspose");return OA(n,o,i,r,s,"NHWC",a)}var PA=V({conv2dTranspose_:Gj});function jj(e,t,n,r,s="NDHWC",a=[1,1,1]){let o=O(e,"x","conv3d"),i=O(t,"filter","conv3d"),l=o,u=!1;o.rank===4&&(u=!0,l=J(o,[1,o.shape[0],o.shape[1],o.shape[2],o.shape[3]])),z(l.rank===5,()=>`Error in conv3d: input must be rank 5, but got rank ${l.rank}.`),z(i.rank===5,()=>`Error in conv3d: filter must be rank 5, but got rank ${i.rank}.`),z(l.shape[4]===i.shape[3],()=>`Error in conv3d: depth of input (${l.shape[4]}) must match input depth for filter ${i.shape[3]}.`),z(_s(n,a),()=>`Error in conv3D: Either strides or dilations must be 1. Got strides ${n} and dilations '${a}'`),z(s==="NDHWC",()=>`Error in conv3d: got dataFormat of ${s} but only NDHWC is currently supported.`);let c={x:l,filter:i},d={strides:n,pad:r,dataFormat:s,dilations:a},h=G.runKernel(Yp,c,d);return u?J(h,[h.shape[1],h.shape[2],h.shape[3],h.shape[4]]):h}var nI=V({conv3d_:jj});function qj(e,t,n,r,s){z(e.length===t.rank,()=>`Length of inShape (${e.length}) and rank of dy (${t.rank}) must match`);let a=e,o=t,i=!1;t.rank===4&&(i=!0,o=J(t,[1,t.shape[0],t.shape[1],t.shape[2],t.shape[3]]),a=[1,e[0],e[1],e[2],e[3]]);let l=a[4],u=o.shape[4];z(a.length===5,()=>`Error in conv3dDerInput: inShape must be length 5, but got length ${a.length}.`),z(o.rank===5,()=>`Error in conv3dDerInput: dy must be rank 5, but got rank ${o.rank}`),z(n.rank===5,()=>`Error in conv3dDerInput: filter must be rank 5, but got rank ${n.rank}`),z(l===n.shape[3],()=>`Error in conv3dDerInput: depth of input (${l}) must match input depth for filter ${n.shape[3]}.`),z(u===n.shape[4],()=>`Error in conv3dDerInput: depth of output (${u}) must match output depth for filter ${n.shape[4]}.`);let c={dy:o,filter:n},d={pad:s,strides:r,inputShape:a},h=G.runKernel(Ny,c,d);return i?J(h,[h.shape[1],h.shape[2],h.shape[3],h.shape[4]]):h}var rI=V({conv3DBackpropInput_:qj});function Kj(e,t,n,r,s){let a=O(e,"x","conv3dTranspose"),o=O(t,"filter","conv3dTranspose");return rI(n,a,o,r,s)}var Xj=V({conv3dTranspose_:Kj});function Zj(e){let n={x:O(e,"x","cos")};return G.runKernel(rl,n)}var Nf=V({cos_:Zj});function Yj(e){let n={x:O(e,"x","cosh")};return G.runKernel($c,n)}var zA=V({cosh_:Yj});function Jj(e,t=0,n=!1,r=!1){let a={x:O(e,"x","cumsum")},o={axis:t,exclusive:n,reverse:r};return G.runKernel(sl,a,o)}var LA=V({cumsum_:Jj});function Qj(e,t,n,r=!1){let s=O(e,"x","denseBincount"),a=O(t,"weights","denseBincount");z(s.dtype==="int32",()=>`Error in denseBincount: input dtype must be int32, but got ${s.dtype}`),z(s.rank<=2,()=>`Error in denseBincount: input must be at most rank 2, but got rank ${s.rank}.`),z(n>=0,()=>`size must be non-negative, but got ${n}.`),z(a.size===s.size||a.size===0,()=>`Error in denseBincount: weights must have the same shape as x or 0-length, but got x shape: ${s.shape}, weights shape: ${a.shape}.`);let o={x:s,weights:a},i={size:n,binaryOutput:r};return G.runKernel(Cy,o,i)}var eq=V({denseBincount_:Qj});function tq(e,t,n="NHWC"){let r=O(e,"x","depthToSpace"),s=n==="NHWC"?r.shape[1]:r.shape[2],a=n==="NHWC"?r.shape[2]:r.shape[3],o=n==="NHWC"?r.shape[3]:r.shape[1];z(s*t>=0,()=>`Negative dimension size caused by overflow when multiplying
|
|
${s} and ${t} for depthToSpace with input shape
|
|
${r.shape}`),z(a*t>=0,()=>`Negative dimension size caused by overflow when multiplying
|
|
${a} and ${t} for depthToSpace with input shape
|
|
${r.shape}`),z(o%(t*t)==0,()=>`Dimension size must be evenly divisible by ${t*t} but is ${o} for depthToSpace with input shape ${r.shape}`);let i={x:r},l={blockSize:t,dataFormat:n};return G.runKernel(Rc,i,l)}var sI=V({depthToSpace_:tq});function nq(e,t,n,r,s="NHWC",a=[1,1],o){let i=O(e,"x","depthwiseConv2d"),l=O(t,"filter","depthwiseConv2d"),u=i,c=!1;i.rank===3&&(c=!0,u=J(i,[1,i.shape[0],i.shape[1],i.shape[2]])),z(u.rank===4,()=>`Error in depthwiseConv2d: input must be rank 4, but got rank ${u.rank}.`),z(l.rank===4,()=>`Error in depthwiseConv2d: filter must be rank 4, but got rank ${l.rank}.`),z(u.shape[3]===l.shape[2],()=>`Error in depthwiseConv2d: number of input channels (${u.shape[3]}) must match the inChannels dimension in filter ${l.shape[2]}.`),o!=null&&z(mn(r),()=>`Error in depthwiseConv2d: pad must be an integer when using, dimRoundingMode ${o} but got pad ${r}.`);let d={x:u,filter:l},h={strides:n,pad:r,dataFormat:s,dilations:a,dimRoundingMode:o},p=G.runKernel(al,d,h);return c?J(p,[p.shape[1],p.shape[2],p.shape[3]]):p}var Td=V({depthwiseConv2d_:nq});function rq(e){let n={x:O(e,"x","diag")};return G.runKernel(_y,n)}var ywe=V({diag_:rq});function sq(e,t,n,r,s=[1,1],a="NHWC"){let o=O(e,"x","dilation2d"),i=O(t,"filter","dilation2d");z(o.rank===3||o.rank===4,()=>`Error in dilation2d: input must be rank 3 or 4, but got rank ${o.rank}.`),z(i.rank===3,()=>`Error in dilation2d: filter must be rank 3, but got rank ${i.rank}.`),z(a==="NHWC",()=>`Error in dilation2d: Only NHWC is currently supported, but got dataFormat of ${a}`);let l=o,u=!1;o.rank===3&&(l=J(o,[1,o.shape[0],o.shape[1],o.shape[2]]),u=!0);let c={x:l,filter:i},d={strides:n,pad:r,dilations:s},h=G.runKernel(Jp,c,d);return u?J(h,[h.shape[1],h.shape[2],h.shape[3]]):h}var aI=V({dilation2d_:sq});function aq(e,t){let n=e.length,r=[];for(let s=0;s<n;s++){let a=n-1-s,o=e[a]||1;(t[t.length-1-s]||1)>1&&o===1&&r.unshift(a)}return r}function ln(e,t){let n=[];for(let r=0;r<t.length;r++){let s=e[e.length-r-1],a=t.length-r-1,o=t[a];(s==null||s===1&&o>1)&&n.unshift(a)}return n}function Rt(e,t){let n=[],r=Math.max(e.length,t.length);for(let s=0;s<r;s++){let a=e[e.length-s-1];a==null&&(a=1);let o=t[t.length-s-1];if(o==null&&(o=1),a===1)n.unshift(o);else if(o===1)n.unshift(a);else if(a!==o){let i=`Operands could not be broadcast together with shapes ${e} and ${t}.`;throw Error(i)}else n.unshift(a)}return n}function oq(e,t){let n=O(e,"a","equal","string_or_numeric"),r=O(t,"b","equal","string_or_numeric");[n,r]=Ut(n,r),Rt(n.shape,r.shape);let s={a:n,b:r};return G.runKernel(il,s)}var Zo=V({equal_:oq});function iq(e,t,n){let r=O(t,"a","where"),s=O(n,"b","where"),a=O(e,"condition","where","bool"),o=Rt(Rt(a.shape,r.shape),s.shape),i=Sd(a,o),l=Sd(r,o),u=Sd(s,o),c={condition:i,t:l,e:u};return G.runKernel(td,c)}var Ln=V({where_:iq});function lq(e){let n={x:O(e,"x","zerosLike")};return G.runKernel(hd,n)}var rt=V({zerosLike_:lq});function uq(e,t){let n=O(e,"a","div"),r=O(t,"b","div");[n,r]=Ut(n,r);let s=Re(n,r),a=rt(s),o=Zo(r,a);return Ln(o,a,s)}var oI=V({divNoNan_:uq});function cq(e,t){let n=O(e,"t1","dot"),r=O(t,"t2","dot");z((n.rank===1||n.rank===2)&&(r.rank===1||r.rank===2),()=>`Error in dot: inputs must all be rank 1 or 2, but got ranks ${n.rank} and ${r.rank}.`);let s=n.rank===1?n.size:n.shape[1],a=r.rank===1?r.size:r.shape[0];if(z(s===a,()=>`Error in dot: inner dimensions of inputs must match, but got ${s} and ${a}.`),n.rank===1&&r.rank===1){let o=J(n,[1,-1]),i=J(r,[-1,1]),l=ot(o,i);return J(l,[])}else if(n.rank===1&&r.rank===2){let o=J(n,[1,-1]),i=J(r,[r.shape[0],r.shape[1]]),l=ot(o,i);return J(l,[l.size])}else if(n.rank===2&&r.rank===1){let o=J(r,[-1,1]),i=ot(n,o);return J(i,[i.size])}else{let o=J(r,[r.shape[0],r.shape[1]]);return ot(n,o)}}var dq=V({dot_:cq});function hq(e,...t){let n=t.map((s,a)=>O(s,`tensors${a}`,"einsum")),r={equation:e};return G.runKernel(Fy,n,r)}var pq=V({einsum_:hq});function fq(e){let n={x:O(e,"x","elu")};return G.runKernel(Dc,n)}var Nd=V({elu_:fq});function mq(e){let t=O(e,"x","erf");z(t.dtype==="int32"||t.dtype==="float32",()=>"Input dtype must be `int32` or `float32`."),t.dtype==="int32"&&(t=ke(t,"float32"));let n={x:t};return G.runKernel(Fc,n)}var iI=V({erf_:mq});function gq(e){let n={x:O(e,"x","exp")};return G.runKernel(Eo,n)}var Kr=V({exp_:gq});function yq(e,t=0){let n=O(e,"x","expandDims","string_or_numeric");z(t<=n.rank,()=>"Axis must be <= rank of the tensor");let r={input:n},s={dim:t};return G.runKernel(Mc,r,s)}var $r=V({expandDims_:yq});function Aq(e){let n={x:O(e,"x","expm1")};return G.runKernel(ll,n)}var lI=V({expm1_:Aq});function xq(e,t){let n=O(e,"x","tile","string_or_numeric");z(n.rank===t.length,()=>`Error in transpose: rank of input ${n.rank} must match length of reps ${t}.`);let r={x:n},s={reps:t};return G.runKernel(Lo,r,s)}var Yo=V({tile_:xq});function bq(e,t,n,r="float32"){t==null&&(t=e);let s=Le([e,t],r),a=e<=t?e:t;for(let i=0;i<a;++i)s.set(1,i,i);let o=J(s.toTensor(),[e,t]);if(n==null)return o;if(n.length===1)return Yo($r(o,0),[n[0],1,1]);if(n.length===2)return Yo($r($r(o,0),0),[n[0],n[1],1,1]);if(n.length===3)return Yo($r($r($r(o,0),0),0),[n[0],n[1],n[2],1,1]);throw new Error(`eye() currently supports only 1D and 2D batchShapes, but received ${n.length}D.`)}var uI=V({eye_:bq});function Cd(e,t,n){let r={shape:e,value:t,dtype:n};return G.runKernel(Qp,{},r)}function vq(e){let n={x:O(e,"x","floor")};return G.runKernel($o,n)}var Ed=V({floor_:vq});function wq(e,t,n=0,r=0){let s=O(e,"x","gather"),a=O(t,"indices","gather","int32"),o={x:s,indices:a},i={axis:n,batchDims:r};return G.runKernel(Pc,o,i)}var $d=V({gather_:wq});function kq(e,t){let n=O(e,"a","greater","string_or_numeric"),r=O(t,"b","greater","string_or_numeric");[n,r]=Ut(n,r),Rt(n.shape,r.shape);let s={a:n,b:r};return G.runKernel(dl,s)}var _r=V({greater_:kq});function Iq(e,t){let n=O(e,"a","greaterEqual","string_or_numeric"),r=O(t,"b","greaterEqual","string_or_numeric");[n,r]=Ut(n,r),Rt(n.shape,r.shape);let s={a:n,b:r};return G.runKernel(_o,s)}var Jo=V({greaterEqual_:Iq});function Sq(e){let n={input:O(e,"input","imag")};return G.runKernel(zy,n)}var BA=V({imag_:Sq});function Tq(e){let n={x:O(e,"x","isFinite")};return G.runKernel(Lc,n)}var Nq=V({isFinite_:Tq});function Cq(e){let n={x:O(e,"x","isInf")};return G.runKernel(Bc,n)}var Eq=V({isInf_:Cq});function $q(e){let n={x:O(e,"x","isNaN")};return G.runKernel(Wc,n)}var cI=V({isNaN_:$q});function _q(e,t=.2){let r={x:O(e,"x","leakyRelu")},s={alpha:t};return G.runKernel(pl,r,s)}var Cf=V({leakyRelu_:_q});function Rq(e,t){let n=O(e,"a","less","string_or_numeric"),r=O(t,"b","less","string_or_numeric");[n,r]=Ut(n,r),Rt(n.shape,r.shape);let s={a:n,b:r};return G.runKernel(fl,s)}var WA=V({less_:Rq});function Dq(e,t){let n=O(e,"a","lessEqual","string_or_numeric"),r=O(t,"b","lessEqual","string_or_numeric");[n,r]=Ut(n,r),Rt(n.shape,r.shape);let s={a:n,b:r};return G.runKernel(ml,s)}var Qo=V({lessEqual_:Dq});function Fq(e,t,n){if(n<=0)throw new Error("The number of values should be positive.");let r={start:e,stop:t,num:n};return G.runKernel(Ly,{},r)}function Mq(e,t=5,n=1,r=1,s=.5){let a=O(e,"x","localResponseNormalization");z(a.rank===4||a.rank===3,()=>`Error in localResponseNormalization: x must be rank 3 or 4 but got
|
|
rank ${a.rank}.`),z(mn(t),()=>`Error in localResponseNormalization: depthRadius must be an integer but got depthRadius ${t}.`);let o=a,i=!1;a.rank===3&&(i=!0,o=J(a,[1,a.shape[0],a.shape[1],a.shape[2]]));let l={x:o},u={depthRadius:t,bias:n,alpha:r,beta:s},c=G.runKernel(nf,l,u);return i?J(c,[c.shape[1],c.shape[2],c.shape[3]]):c}var dI=V({localResponseNormalization_:Mq});function Oq(e){let n={x:O(e,"x","log")};return G.runKernel(Ro,n)}var Rr=V({log_:Oq});function Pq(e){let n={x:O(e,"x","log1p")};return G.runKernel(Vc,n)}var VA=V({log1p_:Pq});function zq(e,t){z(Hp(e),()=>"The f passed in variableGrads(f) must be a function"),z(t==null||Array.isArray(t)&&t.every(u=>u instanceof gf),()=>"The varList passed in variableGrads(f, varList) must be an array of variables");let n=t!=null;if(!n){t=[];for(let u in G.registeredVariables)t.push(G.registeredVariables[u])}let r=n?t.filter(u=>!u.trainable):null,s=t.length;t=t.filter(u=>u.trainable),z(t.length>0,()=>`variableGrads() expects at least one of the input variables to be trainable, but none of the ${s} variables is trainable.`);let a=!0,{value:o,grads:i}=G.gradients(e,t,null,a);z(i.some(u=>u!=null),()=>"Cannot find a connection between any variable and the result of the loss function y=f(x). Please make sure the operations that use variables are inside the function f passed to minimize()."),z(o.rank===0,()=>`The f passed in variableGrads(f) must return a scalar, but it returned a rank-${o.rank} tensor`);let l={};return t.forEach((u,c)=>{i[c]!=null&&(l[u.name]=i[c])}),r!=null&&r.forEach(u=>l[u.name]=null),{value:o,grads:l}}function oa(e){return G.customGrad(e)}function Lq(e){let n={x:O(e,"x","neg")};return G.runKernel(Gc,n)}var Kt=V({neg_:Lq});function Bq(e){let n={x:O(e,"x","softplus")};return G.runKernel(od,n)}var Zl=V({softplus_:Bq});function Wq(e){let t=O(e,"x","logSigmoid");return oa(r=>({value:Kt(Zl(Kt(r))),gradFunc:o=>K(o,Rs(Kt(r)))}))(t)}var Vq=V({logSigmoid_:Wq});function Uq(e,t=null,n=!1){let s={x:O(e,"x","max")},a={reductionIndices:t,keepDims:n};return G.runKernel(gl,s,a)}var os=V({max_:Uq});function Hq(e,t){let n=O(e,"a","sub"),r=O(t,"b","sub");[n,r]=Ut(n,r);let s={a:n,b:r};return G.runKernel(zo,s)}var Ne=V({sub_:Hq});function Gq(e,t=null,n=!1){let r=O(e,"x","sum");r.dtype==="bool"&&(r=ke(r,"int32"));let s={x:r},a={axis:t,keepDims:n};return G.runKernel(Fl,s,a)}var _e=V({sum_:Gq});function jq(e,t=-1){let n=O(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 oa((s,a)=>{let o=!0,i=os(s,t,!0),l=Ne(s,i),u=Ne(ke(l,"float32"),Rr(_e(Kr(l),t,o)));return a([u]),{value:u,gradFunc:(d,h)=>{let[p]=h,f=!0,m=Kr(p);return Ne(d,K(_e(d,t,f),m))}}})(n)}var UA=V({logSoftmax_:jq});function HA(e,t){for(let n=0;n<e.length;++n)if(e[e.length-n-1]!==t-1-n)return!1;return!0}function hI(e,t,n){let r=e.length+t.length,s=[],a=0,o=0;for(let i=0;i<r;i++)n.indexOf(i)===-1?s.push(e[a++]):s.push(t[o++]);return s}function pI(e,t){let n=[],r=e.length;for(let a=0;a<r;a++)t.indexOf(a)===-1&&n.push(e[a]);let s=t.map(a=>e[a]);return[n,s]}function ei(e,t){let n=t.map(r=>1);return hI(e,n,t)}function qq(e,t,n){z(HA(t,n),()=>`${e} supports only inner-most axes for now. Got axes ${t} and rank-${n} input.`)}function fI(e,t){if(HA(e,t))return null;let n=[];for(let r=0;r<t;++r)e.indexOf(r)===-1&&n.push(r);return e.forEach(r=>n.push(r)),n}function GA(e){return e.map((t,n)=>[n,t]).sort((t,n)=>t[1]-n[1]).map(t=>t[0])}function Kq(e,t){let n=[];for(let r=t-e;r<t;++r)n.push(r);return n}function Xq(e,t=null,n=!1){let r=O(e,"x","logSumExp"),s=jr(t,r.shape),a=os(r,s,!0),o=Ne(r,a),i=Kr(o),l=_e(i,s),u=Rr(l),c=pe(J(a,u.shape),u);if(n){let d=ei(c.shape,s);return J(c,d)}return c}var mI=V({logSumExp_:Xq});function Zq(e,t){let n=O(e,"a","logicalAnd","bool"),r=O(t,"b","logicalAnd","bool");Rt(n.shape,r.shape);let s={a:n,b:r};return G.runKernel(Uc,s)}var is=V({logicalAnd_:Zq});function Yq(e){let n={x:O(e,"x","logicalNot","bool")};return G.runKernel(ef,n)}var Ef=V({logicalNot_:Yq});function Jq(e,t){let n=O(e,"a","logicalOr","bool"),r=O(t,"b","logicalOr","bool");Rt(n.shape,r.shape);let s={a:n,b:r};return G.runKernel(tf,s)}var jA=V({logicalOr_:Jq});function Qq(e,t){let n=O(e,"a","logicalXor","bool"),r=O(t,"b","logicalXor","bool");return Rt(n.shape,r.shape),is(jA(e,t),Ef(is(e,t)))}var eK=V({logicalXor_:Qq});function tK(e,t,n,r,s){let a=O(e,"x","maxPool"),o=1,i=a,l=!1;a.rank===3&&(l=!0,i=J(a,[1,a.shape[0],a.shape[1],a.shape[2]])),z(i.rank===4,()=>`Error in maxPool: input must be rank 4 but got rank ${i.rank}.`),z(_s(n,o),()=>`Error in maxPool: Either strides or dilations must be 1. Got strides ${n} and dilations '${o}'`),s!=null&&z(mn(r),()=>`Error in maxPool: pad must be an integer when using, dimRoundingMode ${s} but got pad ${r}.`);let u={x:i},c={filterSize:t,strides:n,pad:r,dimRoundingMode:s},d=G.runKernel(yl,u,c);return l?J(d,[d.shape[1],d.shape[2],d.shape[3]]):d}var $f=V({maxPool_:tK});function nK(e,t=[1,1,1],n,r,s,a="NDHWC"){let o=O(e,"x","maxPool3d"),i=o,l=!1;o.rank===4&&(l=!0,i=J(o,[1,o.shape[0],o.shape[1],o.shape[2],o.shape[3]])),z(i.rank===5,()=>`Error in maxPool3d: x must be rank 5 but got rank ${i.rank}.`),z(a==="NDHWC",()=>`Error in maxPool3d: Only NDHWC is currently supported, but got dataFormat of ${a}`),s!=null&&z(mn(r),()=>`Error in maxPool3d: pad must be an integer when using, dimRoundingMode ${s} but got pad ${r}.`);let u={x:i},c={filterSize:t,strides:n,pad:r,dimRoundingMode:s,dataFormat:a},d=G.runKernel(rf,u,c);return l?J(d,[d.shape[1],d.shape[2],d.shape[3],d.shape[4]]):d}var gI=V({maxPool3d_:nK});function rK(e,t,n,r,s=!1){let o={x:O(e,"x","maxPoolWithArgmax")},i={filterSize:t,strides:n,pad:r,includeBatchInIndex:s},l=G.runKernel(Uy,o,i);return{result:l[0],indexes:l[1]}}var sK=V({maxPoolWithArgmax_:rK});function aK(e,t){let n=O(e,"a","maximum"),r=O(t,"b","maximum");[n,r]=Ut(n,r),n.dtype==="bool"&&(n=ke(n,"int32"),r=ke(r,"int32")),Rt(n.shape,r.shape);let s={a:n,b:r};return G.runKernel(Do,s)}var ia=V({maximum_:aK});function oK(e,t=null,n=!1){let s={x:O(e,"x","mean")},a={axis:t,keepDims:n};return G.runKernel(Al,s,a)}var Xt=V({mean_:oK});function un(e,t="float32"){if(t==="complex64"){let r=un(e,"float32"),s=un(e,"float32");return Uo(r,s)}let n=jp(on(e),t);return G.makeTensor(n,e,t)}function la(e,t="float32"){if(t==="complex64"){let r=la(e,"float32"),s=un(e,"float32");return Uo(r,s)}let n=gy(on(e),t);return G.makeTensor(n,e,t)}function iK(e,t=null,n=!1){let s={x:O(e,"x","min")},a={axis:t,keepDims:n};return G.runKernel(xl,s,a)}var _f=V({min_:iK});function lK(e,t){let n=O(e,"a","minimum"),r=O(t,"b","minimum");[n,r]=Ut(n,r),n.dtype==="bool"&&(n=ke(n,"int32"),r=ke(r,"int32")),Rt(n.shape,r.shape);let s={a:n,b:r};return G.runKernel(Fo,s)}var _d=V({minimum_:lK});function uK(e,t,n){z(n==="reflect"||n==="symmetric",()=>`Invalid mode. Mode must be either reflect or symmetric. Got ${n}.`);let r=O(e,"x","mirrorPad");if(r.rank===0)throw new Error("mirrorPad(scalar) is not defined. Pass non-scalar to mirrorPad");z(t.length===r.rank,()=>`Padding doesn't match input. Must be ${r.rank}. Got ${t.length}.`);let s=n==="reflect"?1:0;for(let i=0;i<r.rank;i++)z(t[i].length===2,()=>"Invalid number of paddings. Must be length of 2 each."),z(t[i][0]>=0&&t[i][0]<=r.shape[i]-s&&t[i][1]>=0&&t[i][1]<=r.shape[i]-s,()=>`Padding in dimension ${i} cannot be greater than or equal to ${r.shape[i]-s} or less than 0 for input of shape ${r.shape}`);let a={paddings:t,mode:n},o={x:r};return G.runKernel(bl,o,a)}var yI=V({mirrorPad_:uK});function cK(e,t){let n=O(e,"a","mod"),r=O(t,"b","mod");[n,r]=Ut(n,r);let s={a:n,b:r};return G.runKernel(Hc,s)}var AI=V({mod_:cK});function dK(e){let t=O(e,"x","square"),n={};return G.runKernel("Square",{x:t},n)}var wt=V({square_:dK});function hK(e,t=null,n=!1){e=O(e,"x","moments");let r=jr(t,e.shape),s=Xt(e,r,n),a=s.shape;n||(a=ei(s.shape,r));let o=wt(Ne(ke(e,"float32"),J(s,a))),i=Xt(o,r,n);return{mean:s,variance:i}}var qA=V({moments_:hK});function pK(e,t,n,r){let s=O(t,"data","multiRNNCell"),a=Af(n,"c","multiRNNCell"),o=Af(r,"h","multiRNNCell"),i=s,l=[];for(let d=0;d<e.length;d++){let h=e[d](i,a[d],o[d]);l.push(h[0]),l.push(h[1]),i=h[1]}let u=[],c=[];for(let d=0;d<l.length;d+=2)u.push(l[d]),c.push(l[d+1]);return[u,c]}var Awe=V({multiRNNCell_:pK});function fK(e,t,n,r=!1){let s=O(e,"logits","multinomial"),a=s.size,o=s.rank;if(a<2)throw new Error(`Error in multinomial: you need at least 2 outcomes, but got ${a}.`);if(o>2)throw new Error(`Rank of probabilities must be 1 or 2, but is ${o}`);n=n||Math.random();let l={logits:o===1?J(s,[1,-1]):s},u={numSamples:t,seed:n,normalized:r},c=G.runKernel(Hy,l,u);return o===1?J(c,[c.size]):c}var mK=V({multinomial_:fK});function gK(e,t){let n=O(e,"a","notEqual","string_or_numeric"),r=O(t,"b","notEqual","string_or_numeric");[n,r]=Ut(n,r),Rt(n.shape,r.shape);let s={a:n,b:r};return G.runKernel(vl,s)}var Yl=V({notEqual_:gK});function yK(e){let n={x:O(e,"x","onesLike")};return G.runKernel(Xc,n)}var Dr=V({onesLike_:yK});function AK(e,t){let n=O(e,"v1","outerProduct"),r=O(t,"v2","outerProduct");z(n.rank===1&&r.rank===1,()=>`Error in outerProduct: inputs must be rank 1, but got ranks ${n.rank} and ${r.rank}.`);let s=J(n,[-1,1]),a=J(r,[1,-1]);return ot(s,a)}var xwe=V({outerProduct_:AK});function xK(e,t,n=0){let r=O(e,"x","pad");if(r.rank===0)throw new Error("pad(scalar) is not defined. Pass non-scalar to pad");let s={paddings:t,constantValue:n},a={x:r};return G.runKernel(kl,a,s)}var Wa=V({pad_:xK});function bK(e,t,n=0){return z(t.length===2,()=>"Invalid number of paddings. Must be length of 2."),Wa(e,[t],n)}var bwe=V({pad1d_:bK});function vK(e,t,n=0){return z(t.length===2&&t[0].length===2&&t[1].length===2,()=>"Invalid number of paddings. Must be length of 2 each."),Wa(e,t,n)}var vwe=V({pad2d_:vK});function wK(e,t,n=0){return z(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."),Wa(e,t,n)}var wwe=V({pad3d_:wK});function kK(e,t,n=0){return z(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."),Wa(e,t,n)}var kwe=V({pad4d_:kK});function IK(e,t,n){let r=O(e,"x","spaceToBatchND");z(r.rank>=1+t.length,()=>`input rank ${r.rank} should be > than [blockShape] ${t.length}`),z(n.length===t.length,()=>`paddings.shape[0] ${n.length} must be equal to [blockShape] ${t.length}`),z(r.shape.reduce((o,i,l)=>l>0&&l<=t.length?o&&(i+n[l-1][0]+n[l-1][1])%t[l-1]==0:o,!0),()=>`input spatial dimensions ${r.shape.slice(1)} with paddings ${n.toString()} must be divisible by blockShapes ${t.toString()}`);let s={x:r},a={blockShape:t,paddings:n};return G.runKernel(of,s,a)}var Rf=V({spaceToBatchND_:IK});function SK(e,t,n,r,s,a){s==null&&(s=[1,1]),a==null&&(a=1),r===0&&(r="valid");let o=O(e,"x","maxPool"),i=o,l=!1;o.rank===3&&(l=!0,i=J(o,[1,o.shape[0],o.shape[1],o.shape[2]])),z(_s(a,s),()=>`Error in pool: Either strides or dilations must be 1. Got strides ${a} and dilations '${s}'`);let u=Z6(i.shape,t,a,s,r),c=[u.dilationHeight,u.dilationWidth],d;r==="same"?d=NK([u.filterHeight,u.filterWidth],c):d=[[0,0],[0,0]];let h=c[0]===1&&c[1]===1,[p,f]=TK([u.inHeight,u.inWidth],c,d),m=h?r:"valid",g=h?i:Rf(i,c,p),A=(n==="avg"?()=>Sf(g,t,a,m):()=>$f(g,t,a,m))(),x=h?A:Tf(A,c,f);return l?J(x,[x.shape[1],x.shape[2],x.shape[3]]):x}function TK(e,t,n){let r=n.map(c=>c[0]),s=n.map(c=>c[1]),a=e.concat(r,s),o=t.map((c,d)=>(c-a[d]%c)%c),i=s.map((c,d)=>c+o[d]),l=t.map((c,d)=>[r[d],i[d]]),u=t.map((c,d)=>[0,o[d]]);return[l,u]}function NK(e,t){let r=e.map((o,i)=>o+(o-1)*(t[i]-1)).map(o=>o-1),s=r.map(o=>Math.floor(o/2)),a=r.map((o,i)=>o-s[i]);return r.map((o,i)=>[s[i],a[i]])}var CK=V({pool_:SK});function EK(e,t){let n=O(e,"base","pow"),r=O(t,"exp","pow");[n,r]=Ut(n,r);let s={a:n,b:r};return G.runKernel(Il,s)}var Va=V({pow_:EK});function $K(e,t){let n=O(e,"x","prelu"),r=O(t,"alpha","prelu"),s={x:n,alpha:r};return G.runKernel(Sl,s)}var Df=V({prelu_:$K});function _K(e,t=null,n=!1){let r=O(e,"x","prod");r.dtype==="bool"&&(r=ke(r,"int32"));let s={x:r},a={axis:t,keepDims:n};return G.runKernel(Yc,s,a)}var KA=V({prod_:_K});function RK(e,t,n){let r=on(e),s=null;if(n==null||n==="float32")s=new Float32Array(r);else if(n==="int32")s=new Int32Array(r);else if(n==="bool")s=new Uint8Array(r);else throw new Error(`Unknown data type ${n}`);for(let a=0;a<r;a++)s[a]=t();return G.makeTensor(s,e,n)}var Iwe=V({rand_:RK}),XA=Ks(e2()),ZA=class{constructor(e,t,n,r,s){this.mean=e,this.stdDev=t,this.dtype=n,this.nextVal=NaN,this.truncated=r,this.truncated&&(this.upper=this.mean+this.stdDev*2,this.lower=this.mean-this.stdDev*2);let a=s||Math.random();this.random=XA.alea(a.toString())}nextValue(){if(!isNaN(this.nextVal)){let r=this.nextVal;return this.nextVal=NaN,r}let e,t,n=!1;for(;!n;){let r,s,a;do r=2*this.random()-1,s=2*this.random()-1,a=r*r+s*s;while(a>=1||a===0);let o=Math.sqrt(-2*Math.log(a)/a);e=this.mean+this.stdDev*r*o,t=this.mean+this.stdDev*s*o,(!this.truncated||this.isValidTruncated(e))&&(n=!0)}return(!this.truncated||this.isValidTruncated(t))&&(this.nextVal=this.convertValue(t)),this.convertValue(e)}convertValue(e){return this.dtype==null||this.dtype==="float32"?e:Math.round(e)}isValidTruncated(e){return e<=this.upper&&e>=this.lower}},DK=class{constructor(e,t,n,r){this.alpha=e,this.beta=1/t,this.dtype=n;let s=r||Math.random();this.randu=XA.alea(s.toString()),this.randn=new ZA(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,r,s,a;for(;;){do r=this.randn.nextValue(),a=1+this.c*r;while(a<=0);if(a*=a*a,e=r*r,t=1-.331*e*e,n=.5*e+this.d*(1-a+Math.log(a)),s=this.randu(),s<t||Math.log(s)<n)break}return a=1/this.beta*this.d*a,this.alpha<1&&(a*=Math.pow(this.randu(),1/this.alpha)),this.convertValue(a)}convertValue(e){return this.dtype==="float32"?e:Math.round(e)}},FK=class{constructor(e=0,t=1,n,r){if(this.canReturnFloat=()=>this.dtype==null||this.dtype==="float32",this.min=e,this.range=t-e,this.dtype=n,r==null&&(r=Math.random()),typeof r=="number"&&(r=r.toString()),!this.canReturnFloat()&&this.range<=1)throw new Error(`The difference between ${e} - ${t} <= 1 and dtype is not float`);this.random=XA.alea(r)}convertValue(e){return this.canReturnFloat()?e:Math.round(e)}nextValue(){return this.convertValue(this.min+this.range*this.random())}};function MK(e,t,n=1,r="float32",s){if(n==null&&(n=1),r==null&&(r="float32"),r!=="float32"&&r!=="int32")throw new Error(`Unsupported data type ${r}`);let a=new DK(t,n,r,s),o=Le(e,r);for(let i=0;i<o.values.length;i++)o.values[i]=a.nextValue();return o.toTensor()}var Swe=V({randomGamma_:MK});function OK(e,t=0,n=1,r,s){if(r!=null&&r==="bool")throw new Error(`Unsupported data type ${r}`);let a=new ZA(t,n,r,!1,s),o=Le(e,r);for(let i=0;i<o.values.length;i++)o.values[i]=a.nextValue();return o.toTensor()}var PK=V({randomNormal_:OK});function zK(e,t=0,n=1,r="float32",s){let a=Le(e,r),o=new FK(t,n,null,s);for(let i=0;i<a.values.length;i++)a.values[i]=o.nextValue();return a.toTensor()}var Rd=V({randomUniform_:zK});function Dd(e,t,n=1,r="float32"){if(n===0)throw new Error("Cannot have a step of zero");let s={start:e,stop:t,step:n,dtype:r};return G.runKernel(sf,{},s)}function LK(e){let n={input:O(e,"input","real")};return G.runKernel(Gy,n)}var Ff=V({real_:LK});function BK(e){let n={x:O(e,"x","reciprocal")};return G.runKernel(Jc,n)}var xI=V({reciprocal_:BK});function WK(e){let n={x:O(e,"x","relu")};return G.runKernel(Tl,n)}var ua=V({relu_:WK});function VK(e){let n={x:O(e,"x","relu6")};return G.runKernel(Cl,n)}var YA=V({relu6_:VK});function UK(e,t){let r={x:O(e,"x","reverse")},s={dims:t};return G.runKernel(El,r,s)}var Fr=V({reverse_:UK});function HK(e){let t=O(e,"x","reverse");return z(t.rank===1,()=>`Error in reverse1D: x must be rank 1 but got rank ${t.rank}.`),Fr(t,0)}var Twe=V({reverse1d_:HK});function GK(e,t){let n=O(e,"x","reverse");return z(n.rank===2,()=>`Error in reverse2D: x must be rank 2 but got rank ${n.rank}.`),Fr(n,t)}var Nwe=V({reverse2d_:GK});function jK(e,t){let n=O(e,"x","reverse");return z(n.rank===3,()=>`Error in reverse3D: x must be rank 3 but got rank ${n.rank}.`),Fr(n,t)}var Cwe=V({reverse3d_:jK});function qK(e,t){let n=O(e,"x","reverse");return z(n.rank===4,()=>`Error in reverse4D: x must be rank 4 but got rank ${n.rank}.`),Fr(n,t)}var Ewe=V({reverse4d_:qK});function KK(e){let n={x:O(e,"x","round")};return G.runKernel($l,n)}var JA=V({round_:KK});function XK(e){let n={x:O(e,"x","rsqrt")};return G.runKernel(Oo,n)}var QA=V({rsqrt_:XK});function Fe(e,t){if((ss(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"&&ss(e)&&!(e instanceof Uint8Array))throw new Error("When making a scalar from encoded string, the value must be `Uint8Array`.");return vd(e,[],[],t)}function ZK(e){let n={x:O(e,"x","selu")};return G.runKernel(nd,n)}var e1=V({selu_:ZK});function YK(e,t,n,r,s,a=[1,1],o="NHWC"){let i=O(e,"x","separableConv2d"),l=O(t,"depthwiseFilter","separableConv2d"),u=O(n,"pointwiseFilter","separableConv2d"),c=i,d=!1;if(i.rank===3&&(d=!0,c=J(i,[1,i.shape[0],i.shape[1],i.shape[2]])),o==="NCHW")throw new Error("separableConv2d currently does not support dataFormat NCHW; only NHWC is supported");z(c.rank===4,()=>`Error in separableConv2d: input must be rank 4, but got rank ${c.rank}.`),z(l.rank===4,()=>`Error in separableConv2d: depthwise filter must be rank 4, but got rank ${l.rank}.`),z(u.rank===4,()=>`Error in separableConv2d: pointwise filter must be rank 4, but got rank ${l.rank}.`),z(u.shape[0]===1,()=>`Error in separableConv2d: the first dimension of pointwise filter must be 1, but got ${u.shape[0]}.`),z(u.shape[1]===1,()=>`Error in separableConv2d: the second dimension of pointwise filter must be 1, but got ${u.shape[1]}.`);let h=l.shape[2],p=l.shape[3];z(u.shape[2]===h*p,()=>`Error in separableConv2d: the third dimension of pointwise filter must be ${h*p}, but got ${u.shape[2]}.`);let f=Td(c,l,r,s,o,a),g=Ba(f,u,1,"valid",o);return d?J(g,[g.shape[1],g.shape[2],g.shape[3]]):g}var bI=V({separableConv2d_:YK});async function JK(e,t){let n=O(e,"x","setdiff1d"),r=O(t,"y","setdiff1d");z(n.dtype===r.dtype,()=>`x and y should have the same dtype, but got x (${n.dtype}) and y (${r.dtype}).`),z(n.rank===1,()=>`x should be 1D tensor, but got x (${n.shape}).`),z(r.rank===1,()=>`y should be 1D tensor, but got y (${r.shape}).`);let s=await n.data(),a=await r.data(),o=new Set(a),i=0;for(let c=0;c<s.length;c++)o.has(s[c])||i++;let l=new Qt([i],n.dtype),u=new Qt([i],"int32");for(let c=0,d=0;c<s.length;c++)o.has(s[c])||(l.values[d]=s[c],u.values[d]=c,d++);return[l.toTensor(),u.toTensor()]}var QK=JK;function eX(e){let n={x:O(e,"x","sign")};return G.runKernel(ad,n)}var vI=V({sign_:eX});function tX(e){let n={x:O(e,"x","sin")};return G.runKernel(_l,n)}var t1=V({sin_:tX});function nX(e){let n={x:O(e,"x","sinh")};return G.runKernel(sd,n)}var n1=V({sinh_:nX});function rX(e,t,n){let r=O(e,"x","slice1d");return z(r.rank===1,()=>`slice1d expects a rank-1 tensor, but got a rank-${r.rank} tensor`),nt(r,[t],[n])}var r1=V({slice1d_:rX});function sX(e,t,n){let r=O(e,"x","slice2d");return z(r.rank===2,()=>`slice2d expects a rank-2 tensor, but got a rank-${r.rank} tensor`),nt(r,t,n)}var wI=V({slice2d_:sX});function aX(e,t,n){let r=O(e,"x","slice3d");return z(r.rank===3,()=>`slice3d expects a rank-3 tensor, but got a rank-${r.rank} tensor`),nt(r,t,n)}var s1=V({slice3d_:aX});function oX(e,t,n){let r=O(e,"x","slice4d");return z(r.rank===4,()=>`slice4d expects a rank-4 tensor, but got a rank-${r.rank} tensor`),nt(r,t,n)}var Mf=V({slice4d_:oX});function iX(e,t=-1){let n=O(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 r={logits:n},s={dim:t};return G.runKernel(Ml,r,s)}var Of=V({softmax_:iX});function lX(e){z(e.dtype==="complex64",()=>`The dtype for tf.spectral.fft() must be complex64 but got ${e.dtype}.`);let t={input:e};return G.runKernel(Oy,t)}var a1=V({fft_:lX});function uX(e){z(e.dtype==="complex64",()=>`The dtype for tf.spectral.ifft() must be complex64 but got ${e.dtype}.`);let t={input:e};return G.runKernel(Py,t)}var Pf=V({ifft_:uX});function cX(e){let t=e.shape[e.shape.length-1],n=e.size/t,r;if(t<=2){let s=J(e,[n,t]);r=Pf(s)}else{let s=[n,2*(t-1)],a=J(Ff(e),[n,t]),o=J(BA(e),[n,t]),i=Fr(nt(a,[0,1],[n,t-2]),1),l=K(Fr(nt(o,[0,1],[n,t-2]),1),Fe(-1)),u=en([a,i],1),c=en([o,l],1),d=J(Uo(u,c),[s[0],s[1]]);r=Pf(d)}if(r=Ff(r),e.rank===3&&e.shape[0]!==0){let s=r,a=e.shape[0];r=J(r,[a,r.shape[0]/a,r.shape[1]]),s.dispose()}return r}var kI=V({irfft_:cX});function dX(e,t,n=0){let s={x:O(e,"x","split")},a={numOrSizeSplits:t,axis:n};return G.runKernel(id,s,a)}var dr=V({split_:dX});function hX(e,t){z(e.dtype==="float32",()=>`The dtype for rfft() must be real value but got ${e.dtype}`);let n=e.shape[e.shape.length-1],r=e.size/n,s;if(t!=null&&t<n){let f=e.shape.map(g=>0),m=e.shape.map(g=>g);m[e.shape.length-1]=t,s=nt(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,s=en([e,un(f)],e.shape.length-1),n=t}else s=e;let a=rt(s),o=J(Uo(s,a),[r,n]),i=a1(o),l=Math.floor(n/2)+1,u=Ff(i),c=BA(i),d=dr(u,[l,n-l],u.shape.length-1),h=dr(c,[l,n-l],c.shape.length-1),p=s.shape.slice();return p[s.shape.length-1]=l,J(Uo(d[0],h[0]),p)}var o1=V({rfft_:hX});function pX(e){let n={x:O(e,"x","sqrt")};return G.runKernel(Dl,n)}var $n=V({sqrt_:pX});function fX(e,t){let n=O(e,"a","squaredDifference"),r=O(t,"b","squaredDifference");[n,r]=Ut(n,r),Rt(n.shape,r.shape);let s={a:n,b:r},a={};return G.runKernel(Po,s,a)}var i1=V({squaredDifference_:fX});function mX(e,t){let n=O(e,"x","squeeze");return J(n,M4(n.shape,t).newShape)}var Jl=V({squeeze_:mX});function gX(e,t=0){let n=Af(e,"tensors","stack","string_or_numeric");z(n.length>=1,()=>"Pass at least one tensor to tf.stack"),n.length>0&&z(t<=n[0].rank,()=>"Axis must be <= rank of the tensor");let r=n,s={axis:t};return G.runKernel(Zc,r,s)}var Mr=V({stack_:gX});function yX(e,t=0){let r={x:O(e,"x","step")},s={alpha:t};return G.runKernel(Bo,r,s)}var Fd=V({step_:yX});function AX(e,t,n,r,s=0,a=0,o=0,i=0,l=0){let c={x:O(e,"x","stridedSlice","string_or_numeric")},d={begin:t,end:n,strides:r,beginMask:s,endMask:a,ellipsisMask:o,newAxisMask:i,shrinkAxisMask:l};return G.runKernel(ld,c,d)}var II=V({stridedSlice_:AX});function xX(e){let n={x:O(e,"x","tan")};return G.runKernel(Ol,n)}var SI=V({tan_:xX});function _n(e,t){Wp(e);let n=bd(e,t);if(n.length!==1)throw new Error("tensor1d() requires values to be a flat/TypedArray");return vd(e,null,n,t)}function Ql(e,t,n){if(Wp(e),t!=null&&t.length!==2)throw new Error("tensor2d() requires shape to have two numbers");let r=bd(e,n);if(r.length!==2&&r.length!==1)throw new Error("tensor2d() requires values to be number[][] or flat/TypedArray");if(r.length===1&&t==null)throw new Error("tensor2d() requires shape to be provided when `values` are a flat/TypedArray");return vd(e,t,r,n)}function bX(e,t=1,n=!0){let r=O(e,"x","topk");if(r.rank===0)throw new Error("topk() expects the input to be of rank 1 or higher");let s=r.shape[r.shape.length-1];if(t>s)throw new Error(`'k' passed to topk() must be <= the last dimension (${s}) but got ${t}`);let a={x:r},o={k:t,sorted:n},[i,l]=G.runKernel(ud,a,o);return{values:i,indices:l}}var TI=V({topk_:bX});function vX(e,t=0,n=1,r,s){if(r!=null&&r==="bool")throw new Error("Unsupported data type $ { dtype }");let a=new ZA(t,n,r,!0,s),o=Le(e,r);for(let i=0;i<o.values.length;i++)o.values[i]=a.nextValue();return o.toTensor()}var l1=V({truncatedNormal_:vX});function wX(e,t=0){let n=O(e,"x","unique","string_or_numeric");z(n.rank>0,()=>"The input tensor must be at least 1D");let r={x:n},s={axis:t},[a,o]=G.runKernel(nA,r,s);return{values:a,indices:o}}var u1=V({unique_:wX});function kX(e,t,n){let r=O(e,"x","unsortedSegmentSum"),s=O(t,"segmentIds","unsortedSegmentSum","int32");z(mn(n),()=>"numSegments must be of dtype int");let a={x:r,segmentIds:s},o={numSegments:n};return G.runKernel(uf,a,o)}var NI=V({unsortedSegmentSum_:kX});function IX(e,t=0){let n=O(e,"x","unstack","string_or_numeric");z(t>=-n.shape.length&&t<n.shape.length,()=>`Axis = ${t} is not in [-${n.shape.length}, ${n.shape.length})`);let r={value:n},s={axis:t};return G.runKernel(dd,r,s)}var ls=V({unstack_:IX});function SX(e,t=!0,n,r){return G.makeVariable(e,t,n,r)}function CI(e,t){let n=[];for(let a=0;a<t.length;a++)t[a]&&n.push(a);let r=Le(e,"int32"),s=Le([n.length,e.length],"int32");for(let a=0;a<n.length;a++){let o=r.indexToLoc(n[a]),i=a*e.length;s.values.set(o,i)}return s.toTensor()}async function TX(e){let t=O(e,"condition","whereAsync","bool"),n=await t.data(),r=CI(t.shape,n);return e!==t&&t.dispose(),r}var NX=TX;function CX(e,t="euclidean",n=null,r=!1){e=O(e,"x","norm");let s=EI(e,t,n),a=s.shape;if(r){let o=jr(n,e.shape);a=ei(s.shape,o)}return J(s,a)}function EI(e,t,n=null){if(e.rank===0)return yn(e);if(e.rank!==1&&n===null)return EI(J(e,[-1]),t,n);if(e.rank===1||typeof n=="number"||Array.isArray(n)&&n.length===1){if(t===1)return _e(yn(e),n);if(t===Infinity)return os(yn(e),n);if(t===-Infinity)return _f(yn(e),n);if(t==="euclidean"||t===2)return $n(_e(Va(yn(e),Fe(2,"int32")),n));throw new Error(`Error in norm: invalid ord value: ${t}`)}if(Array.isArray(n)&&n.length===2){if(t===1)return os(_e(yn(e),n[0]),n[1]-1);if(t===Infinity)return os(_e(yn(e),n[1]),n[0]);if(t===-Infinity)return _f(_e(yn(e),n[1]),n[0]);if(t==="fro"||t==="euclidean")return $n(_e(wt(e),n));throw new Error(`Error in norm: invalid ord value: ${t}`)}throw new Error(`Error in norm: invalid axis: ${n}`)}var c1=V({norm_:CX});function EX(e,t,n,r,s=!0){let a=O(e,"v","movingAverage"),o=O(t,"x","movingAverage"),i=O(n,"decay","movingAverage");n6(a,o),z(Da(a.shape,o.shape),()=>"Shape mismatch in v and x");let l=Fe(1),u=Ne(l,i),c=K(Ne(o,a),u);if(s){z(r!=null,()=>"When using zeroDebias: true, step is required.");let d=O(r,"step","movingAverage");c=Re(c,Ne(l,Va(i,d)))}return pe(a,c)}var $we=V({movingAverage_:EX});function $X(e,t,n){let r=O(e,"indices","scatterND","int32"),s=O(t,"updates","scatterND");CA(s,r,n);let a={indices:r,updates:s},o={shape:n};return G.runKernel(ed,a,o)}var _X=V({scatterND_:$X});function RX(e,t,n,r){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 s=e.rank>0?e.shape[0]:1,a=e.rank>1?e.shape[1]:1;if(n.length!==a)throw new Error(`outputShape has incorrect number of elements:, ${n.length}, should be: ${a}.`);let o=t.size;if(!(t.rank===0||t.rank===1&&o===s))throw new Error(`sparseValues has incorrect shape ${t.shape}, should be [] or [${s}]`);if(t.dtype!==r.dtype)throw new Error("sparseValues.dtype must match defaultValues.dtype")}function DX(e,t,n,r=0){let s=O(e,"sparseIndices","sparseToDense","int32"),a=O(t,"sparseValues","sparseToDense"),o=O(r,"defaultValue","sparseToDense",a.dtype);RX(s,a,n,o);let i={sparseIndices:s,sparseValues:a,defaultValue:o},l={outputShape:n};return G.runKernel(Jy,i,l)}var $I=V({sparseToDense_:DX});function FX(e,t){let n=O(t,"indices","gatherND","int32"),s={params:O(e,"x","gatherND","string_or_numeric"),indices:n};return G.runKernel(zc,s)}var MX=V({gatherND_:FX});function OX(e,t){if(t==null)return e.shape.slice();if(Da(e.shape,t))return t;if(e.shape.length===t.length){let n=[];for(let r=0;r<e.shape.length;r++)t[r]==null&&e.shape[r]!=null?n.push(e.shape[r]):n.push(t[r]);return n}return t}function PX(e,t,n,r){let s=O(e,"x","dropout");if(z(s.dtype==="float32",()=>`x has to be a floating point tensor since it's going to be scaled, but got a ${s.dtype} tensor instead.`),z(t>=0&&t<1,()=>`rate must be a float in the range [0, 1), but got ${t}.`),t===0)return e instanceof Ct?s.clone():s;let a=OX(s,n),o=1-t,i=Re(Ed(pe(Rd(a,0,1,"float32",r),o)),o);return K(s,i)}var zX=V({dropout_:PX});function LX(e){return Math.floor(Math.pow(2,Math.ceil(Math.log(e)/Math.log(2))))}function _I(e,t,n){let r=1-e%2,s=new Float32Array(e);for(let a=0;a<e;++a){let o=2*Math.PI*a/(e+r-1);s[a]=t-n*Math.cos(o)}return _n(s,"float32")}var ti={};De(ti,{conv2d:()=>VX,depthwiseConv2d:()=>jX,matMul:()=>KX});function BX(e,t,n,r,s,a="NHWC",o){let i=e;e.rank===3&&(i=J(e,[1,e.shape[0],e.shape[1],e.shape[2]]));let l=t;l.rank===3&&(l=J(t,[1,t.shape[0],t.shape[1],t.shape[2]])),z(i.rank===4,()=>`Error in conv2dDerFilter: input must be rank 4, but got shape ${i.shape}.`),z(l.rank===4,()=>`Error in conv2dDerFilter: dy must be rank 4, but got shape ${l.shape}.`),z(n.length===4,()=>`Error in conv2dDerFilter: filterShape must be length 4, but got ${n}.`);let u=a==="NHWC"?i.shape[3]:i.shape[1],c=a==="NHWC"?l.shape[3]:l.shape[1];z(u===n[2],()=>`Error in conv2dDerFilter: depth of input ${u}) must match input depth in filter (${n[2]}.`),z(c===n[3],()=>`Error in conv2dDerFilter: depth of dy (${c}) must match output depth for filter (${n[3]}).`),o!=null&&z(mn(s),()=>`Error in conv2dDerFilter: pad must be an integer when using, dimRoundingMode ${o} but got pad ${s}.`);let d={x:i,dy:l},h={strides:r,pad:s,dataFormat:a,dimRoundingMode:o,filterShape:n};return G.runKernel(Sy,d,h)}var d1=V({conv2DBackpropFilter_:BX});function zf(e,t,n){if(n==null||n==="linear")return e;if(n==="relu")return K(e,Fd(t));throw new Error(`Cannot compute gradient for fused activation ${n}.`)}function Lf(e,t){let n=t,r=ln(e.shape,t.shape);return r.length>0&&(n=_e(n,r)),J(n,e.shape)}function Bf(e,t,n,r){if(t==="linear")return e;if(t==="relu")return ua(e);if(t==="elu")return Nd(e);if(t==="relu6")return YA(e);if(t==="prelu")return Df(e,n);if(t==="leakyrelu")return Cf(e,r);if(t==="sigmoid")return Rs(e);throw new Error(`Unknown fused activation ${t}.`)}var Wf=(e,t)=>!(e>0)||t==="linear";function WX({x:e,filter:t,strides:n,pad:r,dataFormat:s="NHWC",dilations:a=[1,1],dimRoundingMode:o,bias:i,activation:l="linear",preluActivationWeights:u,leakyreluAlpha:c}){if(l=l||"linear",Wf(G.state.gradientDepth,l)===!1){let v=Ba(e,t,n,r,s,a,o);return i!=null&&(v=pe(v,i)),Bf(v,l,u,c)}let d=O(e,"x","conv2d"),h=O(t,"filter","conv2d"),p=d,f=!1;d.rank===3&&(f=!0,p=J(d,[1,d.shape[0],d.shape[1],d.shape[2]])),z(p.rank===4,()=>`Error in fused conv2d: input must be rank 4, but got rank ${p.rank}.`),z(h.rank===4,()=>`Error in fused conv2d: filter must be rank 4, but got rank ${h.rank}.`),o!=null&&z(mn(r),()=>`Error in fused conv2d: pad must be an integer when using, dimRoundingMode ${o} but got pad ${r}.`),z(p.shape[3]===h.shape[2],()=>`Error in conv2d: depth of input (${p.shape[3]}) must match input depth for filter ${h.shape[2]}.`),z(_s(n,a),()=>`Error in conv2D: Either strides or dilations must be 1. Got strides ${n} and dilations '${a}'`),z(s==="NHWC",()=>`Error in conv2d: got dataFormat of ${s} but only NHWC is currently supported.`);let m=Id(p.shape,h.shape,n,a,r,o),g;i!=null&&(g=O(i,"bias","fused conv2d"),[g]=Ut(g,d),Rt(m.outShape,g.shape));let y;u!=null&&(y=O(u,"prelu weights","fused conv2d"));let A=(v,w)=>{let[I,T,C,M]=w,$=zf(v,C,l);z(La(a),()=>`Error in gradient of fused conv2D: dilation rates greater than 1 are not yet supported in gradients. Got dilations '${a}'`);let R=OA(T.shape,$,I,n,r),N=d1(T,$,I.shape,n,r),F=[R,N];if(M!=null){let B=Lf(M,$);F.push(B)}return F},x={x:p,filter:h,bias:g,preluActivationWeights:y},b={strides:n,pad:r,dataFormat:s,dilations:a,dimRoundingMode:o,activation:l,leakyreluAlpha:c};return i==null?oa((w,I,T)=>{let C=G.runKernel(Bl,x,b);return T([I,w,C]),f&&(C=J(C,[C.shape[1],C.shape[2],C.shape[3]])),{value:C,gradFunc:A}})(p,h):oa((w,I,T,C)=>{let M=G.runKernel(Bl,x,b);return C([I,w,M,T]),f&&(M=J(M,[M.shape[1],M.shape[2],M.shape[3]])),{value:M,gradFunc:A}})(p,h,g)}var VX=V({fusedConv2d_:WX});function UX(e,t,n,r,s,a=[1,1],o){let i=e;e.rank===3&&(i=J(e,[1,e.shape[0],e.shape[1],e.shape[2]]));let l=t;l.rank===3&&(l=J(t,[1,t.shape[0],t.shape[1],t.shape[2]]));let u={x:i,dy:l},c={strides:r,pad:s,dimRoundingMode:o,dilations:a,filterShape:n};return G.runKernel(Ey,u,c)}var RI=V({depthwiseConv2dNativeBackpropFilter_:UX});function HX(e,t,n,r,s,a=[1,1],o){let i=t,l=!1;t.rank===3&&(l=!0,i=J(t,[1,t.shape[0],t.shape[1],t.shape[2]]));let u={dy:i,filter:n},c={strides:r,pad:s,dimRoundingMode:o,dilations:a,inputShape:e},d=G.runKernel($y,u,c);return l?J(d,[d.shape[1],d.shape[2],d.shape[3]]):d}var DI=V({depthwiseConv2dNativeBackpropInput_:HX});function GX({x:e,filter:t,strides:n,pad:r,dataFormat:s="NHWC",dilations:a=[1,1],dimRoundingMode:o,bias:i,activation:l="linear",preluActivationWeights:u,leakyreluAlpha:c}){if(Wf(G.state.gradientDepth,l)===!1){let v=Td(e,t,n,r,s,a,o);return i!=null&&(v=pe(v,i)),Bf(v,l,u,c)}let d=O(e,"x","depthwiseConv2d"),h=O(t,"filter","depthwiseConv2d"),p=d,f=!1;d.rank===3&&(f=!0,p=J(d,[1,d.shape[0],d.shape[1],d.shape[2]])),z(p.rank===4,()=>`Error in fused depthwiseConv2d: input must be rank 4, but got rank ${p.rank}.`),z(h.rank===4,()=>`Error in fused depthwiseConv2d: filter must be rank 4, but got rank ${h.rank}.`),z(p.shape[3]===h.shape[2],()=>`Error in fused depthwiseConv2d: number of input channels (${p.shape[3]}) must match the inChannels dimension in filter ${h.shape[2]}.`),a==null&&(a=[1,1]),z(_s(n,a),()=>`Error in fused depthwiseConv2d: Either strides or dilations must be 1. Got strides ${n} and dilations '${a}'`),o!=null&&z(mn(r),()=>`Error in fused depthwiseConv2d: pad must be an integer when using dimRoundingMode ${o} but got pad ${r}.`);let m=Id(p.shape,h.shape,n,a,r,o,!0),g;i!=null&&(g=O(i,"bias","fused conv2d"),[g]=Ut(g,d),Rt(m.outShape,g.shape));let y;u!=null&&(y=O(u,"prelu weights","fused depthwiseConv2d"));let A=(v,w)=>{z(La(a),()=>`Error in gradient of fused depthwiseConv2d: dilation rates greater than 1 are not yet supported. Got dilations '${a}'`);let[I,T,C,M]=w,$=zf(v,C,l),R=DI(T.shape,$,I,n,r,a,o),N=RI(T,$,I.shape,n,r,a,o);if(M!=null){let F=Lf(g,$);return[R,N,F]}return[R,N]},x={x:p,filter:h,bias:g,preluActivationWeights:y},b={strides:n,pad:r,dataFormat:s,dilations:a,dimRoundingMode:o,activation:l,leakyreluAlpha:c};return i==null?oa((w,I,T)=>{let C=G.runKernel(Wl,x,b);return T([I,w,C]),f&&(C=J(C,[C.shape[1],C.shape[2],C.shape[3]])),{value:C,gradFunc:A}})(p,h):oa((w,I,T,C)=>{let M=G.runKernel(Wl,x,b);return C([I,w,M,T]),f&&(M=J(M,[M.shape[1],M.shape[2],M.shape[3]])),{value:M,gradFunc:A}})(p,h,g)}var jX=V({fusedDepthwiseConv2d_:GX});function qX({a:e,b:t,transposeA:n=!1,transposeB:r=!1,bias:s,activation:a="linear",preluActivationWeights:o,leakyreluAlpha:i}){if(Wf(G.state.gradientDepth,a)===!1){let M=ot(e,t,n,r);return s!=null&&(M=pe(M,s)),Bf(M,a,o,i)}let l=O(e,"a","fused matMul"),u=O(t,"b","fused matMul");[l,u]=Ut(l,u);let c=n?l.shape[l.rank-2]:l.shape[l.rank-1],d=r?u.shape[u.rank-1]:u.shape[u.rank-2],h=n?l.shape[l.rank-1]:l.shape[l.rank-2],p=r?u.shape[u.rank-2]:u.shape[u.rank-1],f=l.shape.slice(0,-2),m=u.shape.slice(0,-2),g=on(f),y=on(m);z(l.rank>=2&&u.rank>=2&&l.rank===u.rank,()=>`Error in fused matMul: inputs must have the same rank of at least 2, got ranks ${l.rank} and ${u.rank}.`),z(Da(f,m),()=>`Error in fused matMul: outer dimensions (${f}) and (${m}) of Tensors with shapes ${l.shape} and ${u.shape} must match.`),z(c===d,()=>`Error in fused matMul: inner shapes (${c}) and (${d}) of Tensors with shapes ${l.shape} and ${u.shape} and transposeA=${n} and transposeB=${r} must match.`);let A=l.shape.slice(0,-2).concat([h,p]),x=n?J(l,[g,c,h]):J(l,[g,h,c]),b=r?J(u,[y,p,d]):J(u,[y,d,p]),v;s!=null&&(v=O(s,"bias","fused matMul"),[v]=Ut(v,l),Rt(A,v.shape));let w;o!=null&&(w=O(o,"prelu weights","fused matMul"));let I=(M,$)=>{let[R,N,F,B]=$,j=zf(J(M,F.shape),F,a),X,Y;if(!n&&!r?(X=ot(j,N,!1,!0),Y=ot(R,j,!0,!1)):!n&&r?(X=ot(j,N,!1,!1),Y=ot(j,R,!0,!1)):n&&!r?(X=ot(N,j,!1,!0),Y=ot(R,j,!1,!1)):(X=ot(N,j,!0,!0),Y=ot(j,R,!0,!0)),s!=null){let ee=Lf(B,j);return[X,Y,ee]}else return[X,Y]},T={a:x,b,bias:v,preluActivationWeights:w},C={transposeA:n,transposeB:r,activation:a,leakyreluAlpha:i};return s==null?oa(($,R,N)=>{let F=G.runKernel(Ll,T,C);return N([$,R,F]),{value:J(F,A),gradFunc:I}})(x,b):oa(($,R,N,F)=>{let B=G.runKernel(Ll,T,C);return F([$,R,B,N]),{value:J(B,A),gradFunc:I}})(x,b,v)}var KX=V({fusedMatMul_:qX});function XX(e){return _I(e,.54,.46)}var _we=V({hammingWindow_:XX});function ZX(e){return _I(e,.5,.5)}var YX=V({hannWindow_:ZX});function JX(e,t,n,r=!1,s=0){let a=0,o=[];for(;a+t<=e.size;)o.push(nt(e,a,t)),a+=n;if(r)for(;a<e.size;){let i=a+t-e.size,l=en([nt(e,a,t-i),Cd([i],s)]);o.push(l),a+=n}return o.length===0?Ql([],[0,t]):J(en(o),[o.length,t])}var QX=V({frame_:JX});function eZ(e,t,n,r,s=YX){r==null&&(r=LX(t));let a=QX(e,t,n),o=K(a,s(t));return o1(o,r)}var Rwe=V({stft_:eZ});function tZ(e,t,n,r,s="bilinear",a=0){let o=O(e,"image","cropAndResize"),i=O(t,"boxes","cropAndResize","float32"),l=O(n,"boxInd","cropAndResize","int32"),u=i.shape[0];z(o.rank===4,()=>`Error in cropAndResize: image must be rank 4,but got rank ${o.rank}.`),z(i.rank===2&&i.shape[1]===4,()=>`Error in cropAndResize: boxes must be have size [${u},4] but had shape ${i.shape}.`),z(l.rank===1&&l.shape[0]===u,()=>`Error in cropAndResize: boxInd must be have size [${u}] but had shape ${i.shape}.`),z(r.length===2,()=>`Error in cropAndResize: cropSize must be of length 2, but got length ${r.length}.`),z(r[0]>=1&&r[1]>=1,()=>`cropSize must be atleast [1,1], but was ${r}`),z(s==="bilinear"||s==="nearest",()=>`method must be bilinear or nearest, but was ${s}`);let c={image:o,boxes:i,boxInd:l},d={method:s,extrapolationValue:a,cropSize:r};return G.runKernel(_c,c,d)}var nZ=V({cropAndResize_:tZ});function rZ(e){let t=O(e,"image","flipLeftRight","float32");z(t.rank===4,()=>`Error in flipLeftRight: image must be rank 4,but got rank ${t.rank}.`);let n={image:t};return G.runKernel(Oc,n,{})}var sZ=V({flipLeftRight_:rZ});function aZ(e,t,n=0,r=.5){let s=O(e,"image","rotateWithOffset","float32");z(s.rank===4,()=>`Error in rotateWithOffset: image must be rank 4,but got rank ${s.rank}.`);let a={image:s},o={radians:t,fillValue:n,center:r};return G.runKernel(pd,a,o)}var oZ=V({rotateWithOffset_:aZ});function eu(e,t,n,r,s,a){r==null&&(r=.5),s==null&&(s=Number.NEGATIVE_INFINITY),a==null&&(a=0);let o=e.shape[0];return n=Math.min(n,o),z(0<=r&&r<=1,()=>`iouThreshold must be in [0, 1], but was '${r}'`),z(e.rank===2,()=>`boxes must be a 2D tensor, but was of rank '${e.rank}'`),z(e.shape[1]===4,()=>`boxes must have 4 columns, but 2nd dimension was ${e.shape[1]}`),z(t.rank===1,()=>"scores must be a 1D tensor"),z(t.shape[0]===o,()=>`scores has incompatible shape with boxes. Expected ${o}, but was ${t.shape[0]}`),z(0<=a&&a<=1,()=>`softNmsSigma must be in [0, 1], but was '${a}'`),{maxOutputSize:n,iouThreshold:r,scoreThreshold:s,softNmsSigma:a}}function iZ(e,t,n,r=.5,s=Number.NEGATIVE_INFINITY){let a=O(e,"boxes","nonMaxSuppression"),o=O(t,"scores","nonMaxSuppression"),i=eu(a,o,n,r,s);n=i.maxOutputSize,r=i.iouThreshold,s=i.scoreThreshold;let l={maxOutputSize:n,iouThreshold:r,scoreThreshold:s};return G.runKernel(jc,{boxes:a,scores:o},l)}var lZ=V({nonMaxSuppression_:iZ});function uZ(e,t,n){let r=cZ(e,t,n),s=r<0?-(r+1):r;e.splice(s,0,t)}function cZ(e,t,n){return hZ(e,t,n||dZ)}function dZ(e,t){return e>t?1:e<t?-1:0}function hZ(e,t,n){let r=0,s=e.length,a=0,o=!1;for(;r<s;){a=r+(s-r>>>1);let i=n(t,e[a]);i>0?r=a+1:(s=a,o=!i)}return o?r:-r-1}function FI(e,t,n,r,s){return h1(e,t,n,r,s,0)}function MI(e,t,n,r,s,a){return h1(e,t,n,r,s,0,!1,a,!0)}function OI(e,t,n,r,s,a){return h1(e,t,n,r,s,a,!0)}function h1(e,t,n,r,s,a,o=!1,i=!1,l=!1){let u=[];for(let g=0;g<t.length;g++)t[g]>s&&u.push({score:t[g],boxIndex:g,suppressBeginIndex:0});u.sort(PI);let c=a>0?-.5/a:0,d=[],h=[];for(;d.length<n&&u.length>0;){let g=u.pop(),{score:y,boxIndex:A,suppressBeginIndex:x}=g;if(y<s)break;let b=!1;for(let v=d.length-1;v>=x;--v){let w=pZ(e,A,d[v]);if(w>=r){b=!0;break}if(g.score=g.score*fZ(r,c,w),g.score<=s)break}g.suppressBeginIndex=d.length,b||(g.score===y?(d.push(A),h.push(g.score)):g.score>s&&uZ(u,g,PI))}let p=d.length,f=n-p;i&&f>0&&(d.push(...new Array(f).fill(0)),h.push(...new Array(f).fill(0)));let m={selectedIndices:d};return o&&(m.selectedScores=h),l&&(m.validOutputs=p),m}function pZ(e,t,n){let r=e.subarray(t*4,t*4+4),s=e.subarray(n*4,n*4+4),a=Math.min(r[0],r[2]),o=Math.min(r[1],r[3]),i=Math.max(r[0],r[2]),l=Math.max(r[1],r[3]),u=Math.min(s[0],s[2]),c=Math.min(s[1],s[3]),d=Math.max(s[0],s[2]),h=Math.max(s[1],s[3]),p=(i-a)*(l-o),f=(d-u)*(h-c);if(p<=0||f<=0)return 0;let m=Math.max(a,u),g=Math.max(o,c),y=Math.min(i,d),A=Math.min(l,h),x=Math.max(y-m,0)*Math.max(A-g,0);return x/(p+f-x)}function fZ(e,t,n){let r=Math.exp(t*n*n);return n<=e?r:0}function PI(e,t){return e.score-t.score||e.score===t.score&&t.boxIndex-e.boxIndex}async function mZ(e,t,n,r=.5,s=Number.NEGATIVE_INFINITY){let a=O(e,"boxes","nonMaxSuppressionAsync"),o=O(t,"scores","nonMaxSuppressionAsync"),i=eu(a,o,n,r,s);n=i.maxOutputSize,r=i.iouThreshold,s=i.scoreThreshold;let l=await Promise.all([a.data(),o.data()]),u=l[0],c=l[1],{selectedIndices:d}=FI(u,c,n,r,s);return a!==e&&a.dispose(),o!==t&&o.dispose(),_n(d,"int32")}var gZ=mZ;function yZ(e,t,n,r=.5,s=Number.NEGATIVE_INFINITY,a=0){let o=O(e,"boxes","nonMaxSuppression"),i=O(t,"scores","nonMaxSuppression"),l=eu(o,i,n,r,s,a);n=l.maxOutputSize,r=l.iouThreshold,s=l.scoreThreshold,a=l.softNmsSigma;let u={boxes:o,scores:i},c={maxOutputSize:n,iouThreshold:r,scoreThreshold:s,softNmsSigma:a},d=G.runKernel(Kc,u,c);return{selectedIndices:d[0],selectedScores:d[1]}}var AZ=V({nonMaxSuppressionWithScore_:yZ});async function xZ(e,t,n,r=.5,s=Number.NEGATIVE_INFINITY,a=0){let o=O(e,"boxes","nonMaxSuppressionAsync"),i=O(t,"scores","nonMaxSuppressionAsync"),l=eu(o,i,n,r,s,a);n=l.maxOutputSize,r=l.iouThreshold,s=l.scoreThreshold,a=l.softNmsSigma;let u=await Promise.all([o.data(),i.data()]),c=u[0],d=u[1],{selectedIndices:h,selectedScores:p}=OI(c,d,n,r,s,a);return o!==e&&o.dispose(),i!==t&&i.dispose(),{selectedIndices:_n(h,"int32"),selectedScores:_n(p)}}var bZ=xZ;function vZ(e,t,n,r=.5,s=Number.NEGATIVE_INFINITY,a=!1){let o=O(e,"boxes","nonMaxSuppression"),i=O(t,"scores","nonMaxSuppression"),l=eu(o,i,n,r,s,null),u=l.maxOutputSize,c=l.iouThreshold,d=l.scoreThreshold,h={boxes:o,scores:i},p={maxOutputSize:u,iouThreshold:c,scoreThreshold:d,padToMaxOutputSize:a},f=G.runKernel(qc,h,p);return{selectedIndices:f[0],validOutputs:f[1]}}var wZ=V({nonMaxSuppressionPadded_:vZ});async function kZ(e,t,n,r=.5,s=Number.NEGATIVE_INFINITY,a=!1){let o=O(e,"boxes","nonMaxSuppressionAsync"),i=O(t,"scores","nonMaxSuppressionAsync"),l=eu(o,i,n,r,s,null),u=l.maxOutputSize,c=l.iouThreshold,d=l.scoreThreshold,[h,p]=await Promise.all([o.data(),i.data()]),{selectedIndices:f,validOutputs:m}=MI(h,p,u,c,d,a);return o!==e&&o.dispose(),i!==t&&i.dispose(),{selectedIndices:_n(f,"int32"),validOutputs:Fe(m,"int32")}}var IZ=kZ;function SZ(e,t,n=!1,r=!1){let s=O(e,"images","resizeBilinear");z(s.rank===3||s.rank===4,()=>`Error in resizeBilinear: x must be rank 3 or 4, but got rank ${s.rank}.`),z(t.length===2,()=>`Error in resizeBilinear: new shape must 2D, but got shape ${t}.`),z(r===!1||n===!1,()=>"Error in resizeBilinear: If halfPixelCenters is true, alignCorners must be false.");let a=s,o=!1;s.rank===3&&(o=!0,a=J(s,[1,s.shape[0],s.shape[1],s.shape[2]]));let[]=t,i={images:a},l={alignCorners:n,halfPixelCenters:r,size:t},u=G.runKernel(Nl,i,l);return o?J(u,[u.shape[1],u.shape[2],u.shape[3]]):u}var zI=V({resizeBilinear_:SZ});function TZ(e,t,n=!1,r=!1){let s=O(e,"images","resizeNearestNeighbor");z(s.rank===3||s.rank===4,()=>`Error in resizeNearestNeighbor: x must be rank 3 or 4, but got rank ${s.rank}.`),z(t.length===2,()=>`Error in resizeNearestNeighbor: new shape must 2D, but got shape ${t}.`),z(s.dtype==="float32"||s.dtype==="int32",()=>"`images` must have `int32` or `float32` as dtype"),z(r===!1||n===!1,()=>"Error in resizeNearestNeighbor: If halfPixelCenters is true, alignCorners must be false.");let a=s,o=!1;s.rank===3&&(o=!0,a=J(s,[1,s.shape[0],s.shape[1],s.shape[2]]));let[]=t,i={images:a},l={alignCorners:n,halfPixelCenters:r,size:t},u=G.runKernel(af,i,l);return o?J(u,[u.shape[1],u.shape[2],u.shape[3]]):u}var LI=V({resizeNearestNeighbor_:TZ});function NZ(e,t="binary",n=!1,r=.5){let s=O(e,"image","threshold"),a=.2989,o=.587,i=.114,l=s.shape[0]*s.shape[1],u=K(_n([r]),255),c,d,h,p;if(z(s.rank===3,()=>`Error in threshold: image must be rank 3,but got rank ${s.rank}.`),z(s.shape[2]===3||s.shape[2]===1,()=>`Error in threshold: image color channel must be equal to 3 or 1but got ${s.shape[2]}.`),z(s.dtype==="int32"||s.dtype==="float32",()=>`Error in dtype: image dtype must be int32 or float32,but got dtype ${s.dtype}.`),z(t==="otsu"||t==="binary",()=>`Method must be binary or otsu, but was ${t}`),s.shape[2]===3){[c,d,h]=dr(s,[1,1,1],-1);let g=K(c,a),y=K(d,o),A=K(h,i);p=pe(pe(g,y),A)}else p=e;if(t==="otsu"){let g=eI(ke(JA(p),"int32"),$s([]),256);u=CZ(g,l)}let f=n?Qo(p,u):_r(p,u);return ke(K(f,255),"int32")}function CZ(e,t){let n=_n([-1]),r=_n([0]),s=_n([0]),a,o,i,l,u,c;for(let d=0;d<e.size-1;d++){a=nt(e,0,d+1),o=nt(e,d+1),u=Re(_e(a),t),c=Re(_e(o),t);let h=_e(K(a,Dd(0,a.size)));i=Re(h,_e(a));let p=Cd(o.shape,a.size),f=pe(Dd(0,o.size),p),m=K(o,f);l=Re(_e(m),_e(o));let g=Ne(i,l),y=Ne(i,l),A=K(u,c);s=K(K(A,g),y);let x=_r(s,r);r=Ln(x,s,r),n=Ln(x,_n([d]),n)}return n}var EZ=V({threshold_:NZ});function $Z(e,t,n="nearest",r="constant",s=0,a){let o=O(e,"image","transform","float32"),i=O(t,"transforms","transform","float32");z(o.rank===4,()=>`Error in transform: image must be rank 4,but got rank ${o.rank}.`),z(i.rank===2&&(i.shape[0]===o.shape[0]||i.shape[0]===1)&&i.shape[1]===8,()=>"Error in transform: Input transform should be batch x 8 or 1 x 8"),z(a==null||a.length===2,()=>`Error in transform: outputShape must be [height, width] or null, but got ${a}.`);let l={image:o,transforms:i},u={interpolation:n,fillMode:r,fillValue:s,outputShape:a};return G.runKernel(cd,l,u)}var _Z=V({transform_:$Z});function RZ(e,t,n){z(t%1==0,()=>`bandPart(): numLower must be an integer, got ${t}.`),z(n%1==0,()=>`bandPart(): numUpper must be an integer, got ${n}.`);let r=O(e,"a","bandPart");z(r.rank>=2,()=>`bandPart(): Rank must be at least 2, got ${r.rank}.`);let s=r.shape,[a,o]=r.shape.slice(-2);if(!(t<=a))throw new Error(`bandPart(): numLower (${t}) must not be greater than the number of rows (${a}).`);if(!(n<=o))throw new Error(`bandPart(): numUpper (${n}) must not be greater than the number of columns (${o}).`);t<0&&(t=a),n<0&&(n=o);let i=J(Dd(0,a,1,"int32"),[-1,1]),l=Dd(0,o,1,"int32"),u=Ne(i,l),c=is(Qo(u,Fe(+t,"int32")),Jo(u,Fe(-n,"int32"))),d=un([a,o],r.dtype);return J(Mr(ls(J(r,[-1,a,o])).map(h=>Ln(c,h,d))),s)}var DZ=V({bandPart_:RZ});function FZ(e){let t;if(Array.isArray(e)){t=!1,z(e!=null&&e.length>0,()=>"Gram-Schmidt process: input must not be null, undefined, or empty");let s=e[0].shape[0];for(let a=1;a<e.length;++a)z(e[a].shape[0]===s,()=>`Gram-Schmidt: Non-unique lengths found in the input vectors: (${e[a].shape[0]} vs. ${s})`)}else t=!0,e=dr(e,e.shape[0],0).map(s=>Jl(s,[0]));z(e.length<=e[0].shape[0],()=>`Gram-Schmidt: Number of vectors (${e.length}) exceeds number of dimensions (${e[0].shape[0]}).`);let n=[],r=e;for(let s=0;s<e.length;++s)n.push(G.tidy(()=>{let a=r[s];if(s>0)for(let o=0;o<s;++o){let i=K(_e(K(n[o],a)),n[o]);a=Ne(a,i)}return Re(a,c1(a,"euclidean"))}));return t?Mr(n,0):n}var MZ=V({gramSchmidt_:FZ});function OZ(e,t=!1){if(z(e.rank>=2,()=>`qr() requires input tensor to have a rank >= 2, but got rank ${e.rank}`),e.rank===2)return BI(e,t);{let n=e.shape.slice(0,e.shape.length-2).reduce((l,u)=>l*u),r=ls(J(e,[n,e.shape[e.shape.length-2],e.shape[e.shape.length-1]]),0),s=[],a=[];r.forEach(l=>{let[u,c]=BI(l,t);s.push(u),a.push(c)});let o=J(Mr(s,0),e.shape),i=J(Mr(a,0),e.shape);return[o,i]}}function BI(e,t=!1){return G.tidy(()=>{z(e.shape.length===2,()=>`qr2d() requires a 2D Tensor, but got a ${e.shape.length}D Tensor.`);let n=e.shape[0],r=e.shape[1],s=uI(n),a=qo(e),o=Ql([[1]],[1,1]),i=qo(o),l=n>=r?r:n;for(let u=0;u<l;++u){let c=a,d=i,h=s;[i,a,s]=G.tidy(()=>{let p=nt(a,[u,u],[n-u,1]),f=c1(p),m=nt(a,[u,u],[1,1]),g=Ln(_r(m,0),Ql([[-1]]),Ql([[1]])),y=Ne(m,K(g,f)),A=Re(p,y);A.shape[0]===1?i=qo(o):i=en([o,nt(A,[1,0],[A.shape[0]-1,A.shape[1]])],0);let x=Kt(Re(ot(g,y),f)),b=nt(a,[u,0],[n-u,r]),v=K(x,i),w=pt(i);if(u===0)a=Ne(b,ot(v,ot(w,b)));else{let C=Ne(b,ot(v,ot(w,b)));a=en([nt(a,[0,0],[u,r]),C],0)}let I=pt(v),T=nt(s,[0,u],[n,s.shape[1]-u]);if(u===0)s=Ne(T,ot(ot(T,i),I));else{let C=Ne(T,ot(ot(T,i),I));s=en([nt(s,[0,0],[n,u]),C],1)}return[i,a,s]}),je([c,d,h])}return!t&&n>r&&(s=nt(s,[0,0],[n,r]),a=nt(a,[0,0],[r,r])),[s,a]})}var PZ=V({qr_:OZ}),Yn;(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"})(Yn||(Yn={}));function zZ(e,t,n=Yn.SUM_BY_NONZERO_WEIGHTS){let r=O(e,"losses","computeWeightedLoss"),s=null;t!=null&&(s=O(t,"weights","computeWeightedLoss"));let a=s==null?r:K(r,s);if(n===Yn.NONE)return a;if(n===Yn.SUM)return _e(a);if(n===Yn.MEAN){if(s==null)return Xt(a);{let o=r.size/s.size,i=Re(_e(a),_e(s));return o>1?Re(i,Fe(o)):i}}if(n===Yn.SUM_BY_NONZERO_WEIGHTS){if(s==null)return Re(_e(a),Fe(r.size));{let o=K(s,la(r.shape)),i=ke(_e(Yl(o,Fe(0))),"float32");return Re(_e(a),i)}}throw Error(`Unknown reduction: ${n}`)}var Ua=V({computeWeightedLoss_:zZ});function LZ(e,t,n,r=Yn.SUM_BY_NONZERO_WEIGHTS){let s=O(e,"labels","absoluteDifference"),a=O(t,"predictions","absoluteDifference"),o=null;n!=null&&(o=O(n,"weights","absoluteDifference")),rs(s.shape,a.shape,"Error in absoluteDifference: ");let i=yn(Ne(s,a));return Ua(i,o,r)}var Dwe=V({absoluteDifference_:LZ});function BZ(e,t,n,r,s=Yn.SUM_BY_NONZERO_WEIGHTS){let a=O(e,"labels","cosineDistance"),o=O(t,"predictions","cosineDistance"),i=null;r!=null&&(i=O(r,"weights","cosineDistance")),rs(a.shape,o.shape,"Error in cosineDistance: ");let l=Fe(1),u=Ne(l,_e(K(a,o),n,!0));return Ua(u,i,s)}var Fwe=V({cosineDistance_:BZ});function WZ(e,t,n,r=Yn.SUM_BY_NONZERO_WEIGHTS){let s=O(e,"labels","hingeLoss"),a=O(t,"predictions","hingeLoss"),o=null;n!=null&&(o=O(n,"weights","hingeLoss")),rs(s.shape,a.shape,"Error in hingeLoss: ");let i=Fe(1);s=Ne(K(Fe(2),s),i);let l=ua(Ne(i,K(s,a)));return Ua(l,o,r)}var Mwe=V({hingeLoss_:WZ});function VZ(e,t,n,r=1,s=Yn.SUM_BY_NONZERO_WEIGHTS){let a=O(e,"labels","huberLoss"),o=O(t,"predictions","huberLoss"),i=null;n!=null&&(i=O(n,"weights","huberLoss")),rs(a.shape,o.shape,"Error in huberLoss: ");let l=Fe(r),u=yn(Ne(o,a)),c=_d(u,l),d=Ne(u,c),h=pe(K(Fe(.5),wt(c)),K(l,d));return Ua(h,i,s)}var Owe=V({huberLoss_:VZ});function UZ(e,t,n,r=1e-7,s=Yn.SUM_BY_NONZERO_WEIGHTS){let a=O(e,"labels","logLoss"),o=O(t,"predictions","logLoss"),i=null;n!=null&&(i=O(n,"weights","logLoss")),rs(a.shape,o.shape,"Error in logLoss: ");let l=Fe(1),u=Fe(r),c=Kt(K(a,Rr(pe(o,u)))),d=K(Ne(l,a),Rr(pe(Ne(l,o),u))),h=Ne(c,d);return Ua(h,i,s)}var Pwe=V({logLoss_:UZ});function HZ(e,t,n,r=Yn.SUM_BY_NONZERO_WEIGHTS){let s=O(e,"labels","meanSquaredError"),a=O(t,"predictions","meanSquaredError"),o=null;n!=null&&(o=O(n,"weights","meanSquaredError")),rs(s.shape,a.shape,"Error in meanSquaredError: ");let i=i1(s,a);return Ua(i,o,r)}var zwe=V({meanSquaredError_:HZ});function GZ(e,t){let n=O(e,"labels","sigmoidCrossEntropyWithLogits"),r=O(t,"logits","sigmoidCrossEntropyWithLogits");rs(n.shape,r.shape,"Error in sigmoidCrossEntropyWithLogits: ");let s=ua(r),a=K(r,n),o=VA(Kr(Kt(yn(r))));return pe(Ne(s,a),o)}function jZ(e,t,n,r=0,s=Yn.SUM_BY_NONZERO_WEIGHTS){let a=O(e,"multiClassLabels","sigmoidCrossEntropy"),o=O(t,"logits","sigmoidCrossEntropy"),i=null;if(n!=null&&(i=O(n,"weights","sigmoidCrossEntropy")),rs(a.shape,o.shape,"Error in sigmoidCrossEntropy: "),r>0){let u=Fe(r),c=Fe(1),d=Fe(.5);a=pe(K(a,Ne(c,u)),K(d,u))}let l=GZ(a,o);return Ua(l,i,s)}var Lwe=V({sigmoidCrossEntropy_:jZ});function qZ(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 oa((s,a,o)=>{let l=mI(a,[n],!0),u=Ne(ke(a,"float32"),l);o([s,u]);let c=Kt(K(u,s));return{value:_e(c,[n]),gradFunc:(p,f)=>{let[m,g]=f,y=ei(p.shape,[n]);return[K(J(p,y),Ne(ke(m,"float32"),Kr(g))),K(J(p,y),Ne(Kr(g),ke(m,"float32")))]}}})(e,t)}function KZ(e,t,n,r=0,s=Yn.SUM_BY_NONZERO_WEIGHTS){let a=O(e,"onehotLabels","softmaxCrossEntropy"),o=O(t,"logits","softmaxCrossEntropy"),i=null;if(n!=null&&(i=O(n,"weights","softmaxCrossEntropy")),rs(a.shape,o.shape,"Error in softmaxCrossEntropy: "),r>0){let u=Fe(r),c=Fe(1),d=Fe(a.shape[1]);a=pe(K(a,Ne(c,u)),Re(u,d))}let l=qZ(a,o);return Ua(l,i,s)}var Bwe=V({softmaxCrossEntropy_:KZ});function XZ(e,t,n,r){let s=O(e,"indices","sparseFillEmptyRows"),a=O(t,"values","sparseFillEmptyRows"),o=O(n,"denseShape","sparseFillEmptyRows"),i=O(r,"defaultValue","sparseFillEmptyRows",a.dtype);if(s.rank!==2)throw new Error(`Indices should be Tensor2D but received shape
|
|
${s.shape}`);if(a.rank!==1)throw new Error(`Values should be Tensor1D but received shape ${a.shape}`);if(o.rank!==1)throw new Error(`Dense shape should be Tensor1D but received shape ${o.shape}`);if(i.rank!==0)throw new Error(`Default value should be a scalar but received shape ${i.shape}`);let l={indices:s,values:a,denseShape:o,defaultValue:i},u=G.runKernel(Ky,l);return{outputIndices:u[0],outputValues:u[1],emptyRowIndicator:u[2],reverseIndexMap:u[3]}}var ZZ=V({sparseFillEmptyRows_:XZ});function YZ(e,t,n){let r=O(e,"inputIndices","sparseReshape"),s=O(t,"inputShape","sparseReshape"),a=O(n,"newShape","sparseReshape");if(r.rank!==2)throw new Error(`Input indices should be Tensor2D but received shape
|
|
${r.shape}`);if(s.rank!==1)throw new Error(`Input shape should be Tensor1D but received shape ${s.shape}`);if(a.rank!==1)throw new Error(`New shape should be Tensor1D but received shape ${a.shape}`);let o={inputIndices:r,inputShape:s,newShape:a},i=G.runKernel(Xy,o);return{outputIndices:i[0],outputShape:i[1]}}var JZ=V({sparseReshape_:YZ});function QZ(e,t,n){let r=O(e,"data","sparseSegmentMean"),s=O(t,"indices","sparseSegmentMean"),a=O(n,"segmentIds","sparseSegmentMean");if(r.rank<1)throw new Error("Data should be at least 1 dimensional but received scalar");if(s.rank!==1)throw new Error(`Indices should be Tensor1D but received shape
|
|
${s.shape}`);if(a.rank!==1)throw new Error(`Segment ids should be Tensor1D but received shape
|
|
${a.shape}`);let o={data:r,indices:s,segmentIds:a};return G.runKernel(Zy,o)}var eY=V({sparseSegmentMean_:QZ});function tY(e,t,n){let r=O(e,"data","sparseSegmentSum"),s=O(t,"indices","sparseSegmentSum"),a=O(n,"segmentIds","sparseSegmentSum");if(r.rank<1)throw new Error("Data should be at least 1 dimensional but received scalar");if(s.rank!==1)throw new Error(`Indices should be Tensor1D but received shape
|
|
${s.shape}`);if(a.rank!==1)throw new Error(`Segment ids should be Tensor1D but received shape
|
|
${a.shape}`);let o={data:r,indices:s,segmentIds:a};return G.runKernel(Yy,o)}var nY=V({sparseSegmentSum_:tY});function rY(e,t,n,r,s,a,o,i){let l=O(e,"data","stringNGrams","string");if(l.dtype!=="string")throw new Error("Data must be of datatype string");if(l.shape.length!==1)throw new Error(`Data must be a vector, saw: ${l.shape}`);let u=O(t,"dataSplits","stringNGrams");if(u.dtype!=="int32")throw new Error("Data splits must be of datatype int32");let c={separator:n,nGramWidths:r,leftPad:s,rightPad:a,padWidth:o,preserveShortSequences:i},d={data:l,dataSplits:u},h=G.runKernel(Qy,d,c);return{nGrams:h[0],nGramsSplits:h[1]}}var sY=V({stringNGrams_:rY});function aY(e,t,n=!0){let r=O(e,"input","stringSplit","string"),s=O(t,"delimiter","stringSplit","string");if(r.rank!==1)throw new Error(`Input should be Tensor1D but received shape ${r.shape}`);if(s.rank!==0)throw new Error(`Delimiter should be a scalar but received shape ${s.shape}`);let a={skipEmpty:n},o={input:r,delimiter:s},i=G.runKernel(eA,o,a);return{indices:i[0],values:i[1],shape:i[2]}}var oY=V({stringSplit_:aY});function iY(e,t){let n=O(e,"input","stringToHashBucketFast","string"),r={numBuckets:t};if(t<=0)throw new Error("Number of buckets must be at least 1");let s={input:n};return G.runKernel(tA,s,r)}var lY=V({stringToHashBucketFast_:iY}),ni={flipLeftRight:sZ,resizeNearestNeighbor:LI,resizeBilinear:zI,rotateWithOffset:oZ,cropAndResize:nZ,nonMaxSuppression:lZ,nonMaxSuppressionAsync:gZ,nonMaxSuppressionWithScore:AZ,nonMaxSuppressionWithScoreAsync:bZ,nonMaxSuppressionPadded:wZ,nonMaxSuppressionPaddedAsync:IZ,threshold:EZ,transform:_Z},uY={bandPart:DZ,gramSchmidt:MZ,qr:PZ},Vf={sparseFillEmptyRows:ZZ,sparseReshape:JZ,sparseSegmentMean:eY,sparseSegmentSum:nY},p1={stringNGrams:sY,stringSplit:oY,stringToHashBucketFast:lY},Ha=class extends B6{minimize(e,t=!1,n){let{value:r,grads:s}=this.computeGradients(e,n);if(n!=null){let a=n.map(o=>({name:o.name,tensor:s[o.name]}));this.applyGradients(a)}else this.applyGradients(s);return je(s),t?r:(r.dispose(),null)}get iterations(){return this.iterations_==null&&(this.iterations_=0),this.iterations_}incrementIterations(){this.iterations_=this.iterations+1}computeGradients(e,t){return zq(e,t)}dispose(){this.iterations_!=null&&je(this.iterations_)}async saveIterations(){return this.iterations_==null&&(this.iterations_=0),{name:"iter",tensor:Fe(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(Ha,Symbol.hasInstance,{value:e=>e.minimize!=null&&e.computeGradients!=null&&e.applyGradients!=null});var f1=class extends Ha{constructor(e,t,n=null){super();this.learningRate=e,this.rho=t,this.epsilon=n,this.accumulatedGrads=[],this.accumulatedUpdates=[],n==null&&(this.epsilon=G.backend.epsilon())}applyGradients(e){(Array.isArray(e)?e.map(n=>n.name):Object.keys(e)).forEach((n,r)=>{let s=G.registeredVariables[n],a=!1;this.accumulatedGrads[r]==null&&(this.accumulatedGrads[r]={originalName:`${n}/accum_grad`,variable:Z(()=>rt(s).variable(a))}),this.accumulatedUpdates[r]==null&&(this.accumulatedUpdates[r]={originalName:`${n}/accum_var`,variable:Z(()=>rt(s).variable(a))});let o=Array.isArray(e)?e[r].tensor:e[n];if(o==null)return;let i=this.accumulatedGrads[r].variable,l=this.accumulatedUpdates[r].variable;Z(()=>{let u=pe(K(i,this.rho),K(wt(o),1-this.rho)),c=K(Re($n(pe(l,this.epsilon)),$n(pe(i,this.epsilon))),o),d=pe(K(l,this.rho),K(wt(c),1-this.rho));i.assign(u),l.assign(d);let h=pe(K(c,-this.learningRate),s);s.assign(h)})}),this.incrementIterations()}dispose(){this.accumulatedUpdates!=null&&(je(this.accumulatedGrads.map(e=>e.variable)),je(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(r=>({originalName:r.name,variable:r.tensor.variable(n)})),this.accumulatedUpdates=e.slice(t,t*2).map(r=>({originalName:r.name,variable:r.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)}};f1.className="Adadelta";Pa(f1);var m1=class extends Ha{constructor(e,t=.1){super();this.learningRate=e,this.initialAccumulatorValue=t,this.accumulatedGrads=[]}applyGradients(e){(Array.isArray(e)?e.map(n=>n.name):Object.keys(e)).forEach((n,r)=>{let s=G.registeredVariables[n];if(this.accumulatedGrads[r]==null){let i=!1;this.accumulatedGrads[r]={originalName:`${n}/accumulator`,variable:Z(()=>Cd(s.shape,this.initialAccumulatorValue).variable(i))}}let a=Array.isArray(e)?e[r].tensor:e[n];if(a==null)return;let o=this.accumulatedGrads[r].variable;Z(()=>{let i=pe(o,wt(a));o.assign(i);let l=pe(K(Re(a,$n(pe(i,G.backend.epsilon()))),-this.learningRate),s);s.assign(l)})}),this.incrementIterations()}dispose(){this.accumulatedGrads!=null&&je(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)}};m1.className="Adagrad";Pa(m1);var g1=class extends Ha{constructor(e,t,n,r=null){super();this.learningRate=e,this.beta1=t,this.beta2=n,this.epsilon=r,this.accumulatedFirstMoment=[],this.accumulatedSecondMoment=[],Z(()=>{this.accBeta1=Fe(t).variable(),this.accBeta2=Fe(n).variable()}),r==null&&(this.epsilon=G.backend.epsilon())}applyGradients(e){let t=Array.isArray(e)?e.map(n=>n.name):Object.keys(e);Z(()=>{let n=Ne(1,this.accBeta1),r=Ne(1,this.accBeta2);t.forEach((s,a)=>{let o=G.registeredVariables[s],i=!1;this.accumulatedFirstMoment[a]==null&&(this.accumulatedFirstMoment[a]={originalName:`${s}/m`,variable:Z(()=>rt(o).variable(i))}),this.accumulatedSecondMoment[a]==null&&(this.accumulatedSecondMoment[a]={originalName:`${s}/v`,variable:Z(()=>rt(o).variable(i))});let l=Array.isArray(e)?e[a].tensor:e[s];if(l==null)return;let u=this.accumulatedFirstMoment[a].variable,c=this.accumulatedSecondMoment[a].variable,d=pe(K(u,this.beta1),K(l,1-this.beta1)),h=pe(K(c,this.beta2),K(wt(l),1-this.beta2)),p=Re(d,n),f=Re(h,r);u.assign(d),c.assign(h);let m=pe(K(Re(p,pe($n(f),this.epsilon)),-this.learningRate),o);o.assign(m)}),this.accBeta1.assign(K(this.accBeta1,this.beta1)),this.accBeta2.assign(K(this.accBeta2,this.beta2))}),this.incrementIterations()}dispose(){this.accBeta1.dispose(),this.accBeta2.dispose(),this.accumulatedFirstMoment!=null&&je(this.accumulatedFirstMoment.map(e=>e.variable)),this.accumulatedSecondMoment!=null&&je(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),Z(()=>{this.accBeta1.assign(Va(this.beta1,this.iterations_+1)),this.accBeta2.assign(Va(this.beta2,this.iterations_+1))});let t=e.length/2,n=!1;this.accumulatedFirstMoment=e.slice(0,t).map(r=>({originalName:r.name,variable:r.tensor.variable(n)})),this.accumulatedSecondMoment=e.slice(t,t*2).map(r=>({originalName:r.name,variable:r.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)}};g1.className="Adam";Pa(g1);var y1=class extends Ha{constructor(e,t,n,r=null,s=0){super();this.learningRate=e,this.beta1=t,this.beta2=n,this.epsilon=r,this.decay=s,this.accumulatedFirstMoment=[],this.accumulatedWeightedInfNorm=[],Z(()=>{this.iteration=Fe(0).variable(),this.accBeta1=Fe(t).variable()}),r==null&&(this.epsilon=G.backend.epsilon())}applyGradients(e){let t=Array.isArray(e)?e.map(n=>n.name):Object.keys(e);Z(()=>{let n=Ne(1,this.accBeta1),r=Re(-this.learningRate,pe(K(this.iteration,this.decay),1));t.forEach((s,a)=>{let o=G.registeredVariables[s],i=!1;this.accumulatedFirstMoment[a]==null&&(this.accumulatedFirstMoment[a]={originalName:`${s}/m`,variable:rt(o).variable(i)}),this.accumulatedWeightedInfNorm[a]==null&&(this.accumulatedWeightedInfNorm[a]={originalName:`${s}/v`,variable:rt(o).variable(i)});let l=Array.isArray(e)?e[a].tensor:e[s];if(l==null)return;let u=this.accumulatedFirstMoment[a].variable,c=this.accumulatedWeightedInfNorm[a].variable,d=pe(K(u,this.beta1),K(l,1-this.beta1)),h=K(c,this.beta2),p=yn(l),f=ia(h,p);u.assign(d),c.assign(f);let m=pe(K(Re(r,n),Re(d,pe(f,this.epsilon))),o);o.assign(m)}),this.iteration.assign(pe(this.iteration,1)),this.accBeta1.assign(K(this.accBeta1,this.beta1))}),this.incrementIterations()}dispose(){this.accBeta1.dispose(),this.iteration.dispose(),this.accumulatedFirstMoment!=null&&je(this.accumulatedFirstMoment.map(e=>e.variable)),this.accumulatedWeightedInfNorm!=null&&je(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)}};y1.className="Adamax";Pa(y1);var Uf=class extends Ha{constructor(e){super();this.learningRate=e,this.setLearningRate(e)}applyGradients(e){(Array.isArray(e)?e.map(n=>n.name):Object.keys(e)).forEach((n,r)=>{let s=Array.isArray(e)?e[r].tensor:e[n];if(s==null)return;let a=G.registeredVariables[n];Z(()=>{let o=pe(K(this.c,s),a);a.assign(o)})}),this.incrementIterations()}setLearningRate(e){this.learningRate=e,this.c!=null&&this.c.dispose(),this.c=Sn(Fe(-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)}};Uf.className="SGD";Pa(Uf);var A1=class extends Uf{constructor(e,t,n=!1){super(e);this.learningRate=e,this.momentum=t,this.useNesterov=n,this.accumulations=[],this.m=Fe(this.momentum)}applyGradients(e){(Array.isArray(e)?e.map(n=>n.name):Object.keys(e)).forEach((n,r)=>{let s=G.registeredVariables[n];if(this.accumulations[r]==null){let i=!1;this.accumulations[r]={originalName:`${n}/momentum`,variable:Z(()=>rt(s).variable(i))}}let a=this.accumulations[r].variable,o=Array.isArray(e)?e[r].tensor:e[n];o!=null&&Z(()=>{let i,l=pe(K(this.m,a),o);this.useNesterov?i=pe(K(this.c,pe(o,K(l,this.m))),s):i=pe(K(this.c,l),s),a.assign(l),s.assign(i)})}),this.incrementIterations()}dispose(){this.m.dispose(),this.accumulations!=null&&je(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)}};A1.className="Momentum";Pa(A1);var x1=class extends Ha{constructor(e,t=.9,n=0,r=null,s=!1){super();if(this.learningRate=e,this.decay=t,this.momentum=n,this.epsilon=r,this.accumulatedMeanSquares=[],this.accumulatedMoments=[],this.accumulatedMeanGrads=[],this.centered=s,r==null&&(this.epsilon=G.backend.epsilon()),e==null)throw new Error("learningRate for RMSPropOptimizer must be defined.")}applyGradients(e){(Array.isArray(e)?e.map(n=>n.name):Object.keys(e)).forEach((n,r)=>{let s=G.registeredVariables[n],a=!1;this.accumulatedMeanSquares[r]==null&&(this.accumulatedMeanSquares[r]={originalName:`${n}/rms`,variable:Z(()=>rt(s).variable(a))}),this.accumulatedMoments[r]==null&&(this.accumulatedMoments[r]={originalName:`${n}/momentum`,variable:Z(()=>rt(s).variable(a))}),this.accumulatedMeanGrads[r]==null&&this.centered&&(this.accumulatedMeanGrads[r]={originalName:`${n}/mg`,variable:Z(()=>rt(s).variable(a))});let o=Array.isArray(e)?e[r].tensor:e[n];if(o==null)return;let i=this.accumulatedMeanSquares[r].variable,l=this.accumulatedMoments[r].variable;Z(()=>{let u=pe(K(i,this.decay),K(wt(o),1-this.decay));if(this.centered){let c=this.accumulatedMeanGrads[r].variable,d=pe(K(c,this.decay),K(o,1-this.decay)),h=Re(K(o,this.learningRate),$n(Ne(u,pe(wt(d),this.epsilon)))),p=pe(K(l,this.momentum),h);i.assign(u),c.assign(d),l.assign(p);let f=Ne(s,p);s.assign(f)}else{let c=pe(K(i,this.decay),K(wt(o),1-this.decay)),d=pe(K(l,this.momentum),Re(K(o,this.learningRate),$n(pe(c,this.epsilon))));i.assign(c),l.assign(d);let h=Ne(s,d);s.assign(h)}})}),this.incrementIterations()}dispose(){this.accumulatedMeanSquares!=null&&je(this.accumulatedMeanSquares.map(e=>e.variable)),this.accumulatedMeanGrads!=null&&this.centered&&je(this.accumulatedMeanGrads.map(e=>e.variable)),this.accumulatedMoments!=null&&je(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(r=>({originalName:r.name,variable:r.tensor.variable(n)})),this.accumulatedMoments=e.slice(t,t*2).map(r=>({originalName:r.name,variable:r.tensor.variable(n)})),this.centered&&(this.accumulatedMeanGrads=e.slice(t*2,t*3).map(r=>({originalName:r.name,variable:r.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)}};x1.className="RMSProp";Pa(x1);var ri=class{static sgd(e){return new Uf(e)}static momentum(e,t,n=!1){return new A1(e,t,n)}static rmsprop(e,t=.9,n=0,r=null,s=!1){return new x1(e,t,n,r,s)}static adam(e=.001,t=.9,n=.999,r=null){return new g1(e,t,n,r)}static adadelta(e=.001,t=.95,n=null){return new f1(e,t,n)}static adamax(e=.002,t=.9,n=.999,r=null,s=0){return new y1(e,t,n,r,s)}static adagrad(e,t=.1){return new m1(e,t)}},tu={sgd:ri.sgd,momentum:ri.momentum,adadelta:ri.adadelta,adagrad:ri.adagrad,rmsprop:ri.rmsprop,adamax:ri.adamax,adam:ri.adam},cY=(()=>typeof requestAnimationFrame!="undefined"?requestAnimationFrame:typeof setImmediate!="undefined"?setImmediate:e=>e())();function b1(){return new Promise(e=>cY(()=>e()))}var _={};De(_,{ERF_A1:()=>vY,ERF_A2:()=>wY,ERF_A3:()=>kY,ERF_A4:()=>IY,ERF_A5:()=>SY,ERF_P:()=>bY,PARALLELIZE_THRESHOLD:()=>v1,SELU_SCALE:()=>VI,SELU_SCALEALPHA:()=>WI,applyActivation:()=>Bf,assertAndGetBroadcastShape:()=>Rt,assertAxesAreInnerMostDims:()=>qq,assertParamsConsistent:()=>dY,assignToTypedArray:()=>DY,axesAreInnerMostDims:()=>HA,calculateShapes:()=>C6,checkEinsumDimSizes:()=>LY,combineLocations:()=>hI,complexWithEvenIndex:()=>$Y,complexWithOddIndex:()=>_Y,computeConv2DInfo:()=>Id,computeConv3DInfo:()=>Y6,computeDefaultPad:()=>DA,computeDilation2DInfo:()=>ij,computeOptimalWindowSize:()=>pY,computeOutAndReduceShapes:()=>pI,computeOutShape:()=>hY,computePool2DInfo:()=>Z6,computePool3DInfo:()=>lj,convertConv2DDataFormat:()=>J6,decodeEinsumEquation:()=>PY,eitherStridesOrDilationsAreOne:()=>_s,expandShapeToKeepDim:()=>ei,exponent:()=>MY,exponents:()=>FY,fromStringArrayToUint8:()=>KY,fromUint8ToStringArray:()=>qY,getAxesPermutation:()=>fI,getBroadcastDims:()=>aq,getComplexWithIndex:()=>RY,getEinsumComputePath:()=>BY,getEinsumPermutation:()=>zY,getFusedBiasGradient:()=>Lf,getFusedDyActivation:()=>zf,getImageCenter:()=>fY,getInnerMostAxes:()=>Kq,getPermuted:()=>gY,getReductionAxes:()=>ln,getReshaped:()=>mY,getReshapedPermuted:()=>yY,getSliceBeginCoords:()=>AY,getSliceSize:()=>xY,getUndoAxesPermutation:()=>GA,isIdentityPermutation:()=>WY,log:()=>NY,mergeRealAndImagArrays:()=>CY,prepareAndValidate:()=>T6,prepareSplitSize:()=>UY,segment_util:()=>GI,shouldFuse:()=>Wf,slice_util:()=>En,splitRealAndImagArrays:()=>EY,tupleValuesAreOne:()=>La,upcastType:()=>qr,validateInput:()=>CA,validateUpdateShape:()=>NA,warn:()=>TY});function dY(e,t){let n=e[0].length;e.forEach((s,a)=>{z(s.length===n,()=>`Error in concat${n}D: rank of tensors[${a}] must be the same as the rank of the rest (${n})`)}),z(t>=0&&t<n,()=>`Error in concat${n}D: axis must be between 0 and ${n-1}.`);let r=e[0];e.forEach((s,a)=>{for(let o=0;o<n;o++)z(o===t||s[o]===r[o],()=>`Error in concat${n}D: Shape of tensors[${a}] (${s}) does not match the shape of the rest (${r}) along the non-concatenated axis ${a}.`)})}function hY(e,t){let n=e[0].slice();for(let r=1;r<e.length;r++)n[t]+=e[r][t];return n}var v1=30;function pY(e){return e<=v1?e:Gp(e,Math.floor(Math.sqrt(e)))}function fY(e,t,n){let r=n*(typeof e=="number"?e:e[0]),s=t*(typeof e=="number"?e:e[1]);return[r,s]}function mY(e,t,n,r=!0){let s=[];if(r)s=s.concat(t.slice(0)),s.push(e[0]/n),s=s.concat(e.slice(1));else{s=s.concat(e[0]);let a=t.length;for(let o=0;o<a;++o)s=s.concat([e[o+1]/t[o],t[o]]);s=s.concat(e.slice(a+1))}return s}function gY(e,t,n=!0){let r=[];if(n){r.push(t);for(let s=t+1;s<e;++s)s<=2*t?(r.push(s),r.push(s-(t+1))):r.push(s)}else{let s=[],a=[];for(let o=1;o<e;++o)o>=t*2+1||o%2==1?a.push(o):s.push(o);r.push(...s),r.push(0),r.push(...a)}return r}function yY(e,t,n,r=!0){let s=[];r?s.push(e[0]/n):s.push(e[0]*n);for(let a=1;a<e.length;++a)a<=t.length?r?s.push(t[a-1]*e[a]):s.push(e[a]/t[a-1]):s.push(e[a]);return s}function AY(e,t){let n=[0];for(let r=0;r<t;++r)n.push(e[r][0]);return n}function xY(e,t,n){let r=e.slice(0,1);for(let s=0;s<n;++s)r.push(e[s+1]-t[s][0]-t[s][1]);return r}var WI=1.7580993408473768,VI=1.0507009873554805,bY=.3275911,vY=.254829592,wY=-.284496736,kY=1.421413741,IY=-1.453152027,SY=1.061405429;function TY(...e){ae().getBool("IS_TEST")||console.warn(...e)}function NY(...e){ae().getBool("IS_TEST")||console.log(...e)}function CY(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 r=0;r<n.length;r+=2)n[r]=e[r/2],n[r+1]=t[r/2];return n}function EY(e){let t=new Float32Array(e.length/2),n=new Float32Array(e.length/2);for(let r=0;r<e.length;r+=2)t[r/2]=e[r],n[r/2]=e[r+1];return{real:t,imag:n}}function $Y(e){let t=Math.ceil(e.length/4),n=new Float32Array(t),r=new Float32Array(t);for(let s=0;s<e.length;s+=4)n[Math.floor(s/4)]=e[s],r[Math.floor(s/4)]=e[s+1];return{real:n,imag:r}}function _Y(e){let t=Math.floor(e.length/4),n=new Float32Array(t),r=new Float32Array(t);for(let s=2;s<e.length;s+=4)n[Math.floor(s/4)]=e[s],r[Math.floor(s/4)]=e[s+1];return{real:n,imag:r}}function RY(e,t){let n=e[t*2],r=e[t*2+1];return{real:n,imag:r}}function DY(e,t,n,r){e[r*2]=t,e[r*2+1]=n}function FY(e,t){let n=new Float32Array(e/2),r=new Float32Array(e/2);for(let s=0;s<Math.ceil(e/2);s++){let a=(t?2:-2)*Math.PI*(s/e);n[s]=Math.cos(a),r[s]=Math.sin(a)}return{real:n,imag:r}}function MY(e,t,n){let r=(n?2:-2)*Math.PI*(e/t),s=Math.cos(r),a=Math.sin(r);return{real:s,imag:a}}var w1="->",OY=/->/g,UI=",",HI="...";function PY(e,t){e=e.replace(/\s/g,"");let n=(e.length-e.replace(OY,"").length)/w1.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 ("${w1}").`);let[r,s]=e.split(w1);z(r.indexOf(HI)===-1,()=>`The ellipsis notation ("${HI}") is not supported yet.`);let a=r.split(UI),o=a.length;if(t!==o)throw new Error(`Expected ${o} input tensors, received ${t}`);if(o>2)throw new Error("Support for more than 2 input tensors is not implemented yet.");let i=[];for(let h=0;h<s.length;++h){let p=s[h];if(!a.some(f=>f.indexOf(p)!==-1))throw new Error(`Output subscripts contain the label ${p} not present in the input subscripts.`);i.indexOf(p)===-1&&i.push(p)}for(let h=0;h<r.length;++h){let p=r[h];i.indexOf(p)===-1&&p!==UI&&i.push(p)}let l=new Array(a.length);for(let h=0;h<o;++h){if(new Set(a[h].split("")).size!==a[h].length)throw new Error(`Found duplicate axes in input component ${a[h]}. Support for duplicate axes in input is not implemented yet.`);l[h]=[];for(let p=0;p<a[h].length;++p)l[h].push(i.indexOf(a[h][p]))}let u=i.length,c=s.length,d=[];for(let h=c;h<u;++h)d.push(h);return{allDims:i,summedDims:d,idDims:l}}function zY(e,t){let n=new Array(e);n.fill(-1);for(let s=0;s<t.length;++s)n[t[s]]=s;let r=[];for(let s=0;s<e;++s)n[s]===-1&&r.push(s);return n=n.filter(s=>s!==-1),{permutationIndices:n,expandDims:r}}function LY(e,t,n){let r=new Array(e);for(let s=0;s<n.length;++s){let a=n[s].shape;for(let o=0;o<t[s].length;++o)r[t[s][o]]===void 0?r[t[s][o]]=a[o]:z(r[t[s][o]]===a[o],()=>`Expected dimension ${r[t[s][o]]} at axis ${o} of input shaped ${JSON.stringify(a)}, but got dimension ${a[o]}`)}}function BY(e,t){let n=e,r=[],s=0;e.length===0&&n.push(-1),s=e.length+1;for(let o=0;o<s;++o)r.push([]);let a=[];for(let o=0;o<n.length;++o){let i=n[o],l=VY(t,i);for(let u of l)a.indexOf(u)===-1&&(r[o].push(u),a.push(u))}return{path:n,steps:r}}function WY(e){return e.every((t,n)=>t===n)}function VY(e,t){let n=[];for(let r=0;r<e.length;++r)(e[r].length===0||e[r].indexOf(t)!==-1||t===-1)&&n.push(r);return n}function UY(e,t,n=0){let r=[];if(typeof t=="number")z(e.shape[n]%t==0,()=>"Number of splits must evenly divide the axis."),r=new Array(t).fill(e.shape[n]/t);else{let s=t.reduce((o,i)=>(i===-1&&(o+=1),o),0);z(s<=1,()=>"There should be only one negative value in split array.");let a=t.indexOf(-1);if(a!==-1){let o=t.reduce((i,l)=>l>0?i+l:i);t[a]=e.shape[n]-o}z(e.shape[n]===t.reduce((o,i)=>o+i),()=>"The sum of sizes must match the size of the axis dimension."),r=t}return r}var GI={};De(GI,{collectGatherOpShapeInfo:()=>jY,computeOutShape:()=>GY,segOpComputeOptimalWindowSize:()=>HY});function HY(e,t){let n=!1,r;for(e<=v1?(r=e,n=!0):r=Gp(e,Math.floor(Math.sqrt(e)));!n;)r>t||r===e?n=!0:r=Gp(e,r+1);return r}function GY(e,t,n){let r=[],s=e.length;for(let a=0;a<s;a++)a!==t?r.push(e[a]):r.push(n);return r}function jY(e,t,n,r){let s=t.shape.length,a=e.shape.length;if(r!==0&&(r<-s||r>s))throw new Error(`Expect batchDims in the range of [-${s}, ${s}], but got ${r}`);if(r<0&&(r+=s),r>a)throw new Error(`batchDims (${r}) must be less than rank(x) (
|
|
${a}).`);if(n<r)throw new Error(`batchDims (${r}) must be less than or equal to axis (${n}).`);for(let d=0;d<r;++d)if(e.shape[d]!==t.shape[d])throw new Error(`x.shape[${d}]: ${e.shape[d]} should be equal to indices.shape[${d}]: ${t.shape[d]}.`);let o=e.shape[n],i=[],l=1,u=1,c=1;for(let d=0;d<r;++d)i.push(e.shape[d]),l*=e.shape[d];for(let d=r;d<n;d++)i.push(e.shape[d]),u*=e.shape[d];for(let d=r;d<s;d++)i.push(t.shape[d]);for(let d=n+1;d<a;d++)i.push(e.shape[d]),c*=e.shape[d];return{batchSize:l,sliceSize:c,outerSize:u,dimSize:o,outputShape:i}}function qY(e){try{return e.map(t=>ff(t))}catch(t){throw new Error(`Failed to decode encoded string bytes into utf-8, error: ${t}`)}}function KY(e){return e.map(t=>pf(t))}var ca={};De(ca,{nonMaxSuppressionV3Impl:()=>FI,nonMaxSuppressionV4Impl:()=>MI,nonMaxSuppressionV5Impl:()=>OI,whereImpl:()=>CI});re().prototype.abs=function(){return this.throwIfDisposed(),yn(this)};re().prototype.acos=function(){return this.throwIfDisposed(),V6(this)};re().prototype.acosh=function(){return this.throwIfDisposed(),U6(this)};re().prototype.add=function(e){return this.throwIfDisposed(),pe(this,e)};re().prototype.all=function(e,t){return this.throwIfDisposed(),RA(this,e,t)};re().prototype.any=function(e,t){return this.throwIfDisposed(),wf(this,e,t)};re().prototype.argMax=function(e){return this.throwIfDisposed(),kf(this,e)};re().prototype.argMin=function(e){return this.throwIfDisposed(),H6(this,e)};re().prototype.asScalar=function(){return this.throwIfDisposed(),z(this.size===1,()=>"The array must have only 1 element."),J(this,[])};re().prototype.asType=function(e){return this.throwIfDisposed(),ke(this,e)};re().prototype.as1D=function(){return this.throwIfDisposed(),J(this,[this.size])};re().prototype.as2D=function(e,t){return this.throwIfDisposed(),J(this,[e,t])};re().prototype.as3D=function(e,t,n){return this.throwIfDisposed(),J(this,[e,t,n])};re().prototype.as4D=function(e,t,n,r){return this.throwIfDisposed(),J(this,[e,t,n,r])};re().prototype.as5D=function(e,t,n,r,s){return this.throwIfDisposed(),J(this,[e,t,n,r,s])};re().prototype.asin=function(){return this.throwIfDisposed(),G6(this)};re().prototype.asinh=function(){return this.throwIfDisposed(),j6(this)};re().prototype.atan=function(){return this.throwIfDisposed(),q6(this)};re().prototype.atan2=function(e){return this.throwIfDisposed(),K6(this,e)};re().prototype.atanh=function(){return this.throwIfDisposed(),X6(this)};re().prototype.avgPool=function(e,t,n,r){return this.throwIfDisposed(),Sf(this,e,t,n,r)};re().prototype.batchToSpaceND=function(e,t){return this.throwIfDisposed(),Tf(this,e,t)};re().prototype.batchNorm=function(e,t,n,r,s){return this.throwIfDisposed(),Xl(this,e,t,n,r,s)};re().prototype.broadcastTo=function(e){return this.throwIfDisposed(),Sd(this,e)};re().prototype.cast=function(e){return this.throwIfDisposed(),ke(this,e)};re().prototype.ceil=function(){return this.throwIfDisposed(),tI(this)};re().prototype.clipByValue=function(e,t){return this.throwIfDisposed(),cr(this,e,t)};re().prototype.concat=function(e,t){return this.throwIfDisposed(),e instanceof Ct&&(e=[e]),en([this,...e],t)};re().prototype.conv1d=function(e,t,n,r,s,a){return this.throwIfDisposed(),MA(this,e,t,n,r,s,a)};re().prototype.conv2dTranspose=function(e,t,n,r,s){return this.throwIfDisposed(),PA(this,e,t,n,r,s)};re().prototype.conv2d=function(e,t,n,r,s,a){return this.throwIfDisposed(),Ba(this,e,t,n,r,s,a)};re().prototype.cos=function(){return this.throwIfDisposed(),Nf(this)};re().prototype.cosh=function(){return this.throwIfDisposed(),zA(this)};re().prototype.cumsum=function(e,t,n){return this.throwIfDisposed(),LA(this,e,t,n)};re().prototype.depthToSpace=function(e,t){return this.throwIfDisposed(),sI(this,e,t)};re().prototype.depthwiseConv2d=function(e,t,n,r,s,a){return this.throwIfDisposed(),Td(this,e,t,n,r,s,a)};re().prototype.dilation2d=function(e,t,n,r,s){return this.throwIfDisposed(),aI(this,e,t,n,r,s)};re().prototype.divNoNan=function(e){return this.throwIfDisposed(),oI(this,e)};re().prototype.div=function(e){return this.throwIfDisposed(),Re(this,e)};re().prototype.dot=function(e){return this.throwIfDisposed(),dq(this,e)};re().prototype.elu=function(){return this.throwIfDisposed(),Nd(this)};re().prototype.equal=function(e){return this.throwIfDisposed(),Zo(this,e)};re().prototype.erf=function(){return this.throwIfDisposed(),iI(this)};re().prototype.exp=function(){return this.throwIfDisposed(),Kr(this)};re().prototype.expandDims=function(e){return this.throwIfDisposed(),$r(this,e)};re().prototype.expm1=function(){return this.throwIfDisposed(),lI(this)};re().prototype.fft=function(){return this.throwIfDisposed(),a1(this)};re().prototype.flatten=function(){return this.throwIfDisposed(),J(this,[this.size])};re().prototype.floor=function(){return this.throwIfDisposed(),Ed(this)};re().prototype.floorDiv=function(e){return this.throwIfDisposed(),_A(this,e)};re().prototype.gather=function(e,t){return this.throwIfDisposed(),$d(this,e,t)};re().prototype.greaterEqual=function(e){return this.throwIfDisposed(),Jo(this,e)};re().prototype.greater=function(e){return this.throwIfDisposed(),_r(this,e)};re().prototype.ifft=function(){return this.throwIfDisposed(),Pf(this)};re().prototype.irfft=function(){return this.throwIfDisposed(),kI(this)};re().prototype.isFinite=function(){return this.throwIfDisposed(),Nq(this)};re().prototype.isInf=function(){return this.throwIfDisposed(),Eq(this)};re().prototype.isNaN=function(){return this.throwIfDisposed(),cI(this)};re().prototype.leakyRelu=function(e){return this.throwIfDisposed(),Cf(this,e)};re().prototype.lessEqual=function(e){return this.throwIfDisposed(),Qo(this,e)};re().prototype.less=function(e){return this.throwIfDisposed(),WA(this,e)};re().prototype.localResponseNormalization=function(e,t,n,r){return this.throwIfDisposed(),dI(this,e,t,n,r)};re().prototype.logSigmoid=function(){return this.throwIfDisposed(),Vq(this)};re().prototype.logSoftmax=function(e){return this.throwIfDisposed(),UA(this,e)};re().prototype.logSumExp=function(e,t){return this.throwIfDisposed(),mI(this,e,t)};re().prototype.log=function(){return this.throwIfDisposed(),Rr(this)};re().prototype.log1p=function(){return this.throwIfDisposed(),VA(this)};re().prototype.logicalAnd=function(e){return this.throwIfDisposed(),is(this,e)};re().prototype.logicalNot=function(){return this.throwIfDisposed(),Ef(this)};re().prototype.logicalOr=function(e){return this.throwIfDisposed(),jA(this,e)};re().prototype.logicalXor=function(e){return this.throwIfDisposed(),eK(this,e)};re().prototype.matMul=function(e,t,n){return this.throwIfDisposed(),ot(this,e,t,n)};re().prototype.maxPool=function(e,t,n,r){return this.throwIfDisposed(),$f(this,e,t,n,r)};re().prototype.max=function(e,t){return this.throwIfDisposed(),os(this,e,t)};re().prototype.maximum=function(e){return this.throwIfDisposed(),ia(this,e)};re().prototype.mean=function(e,t){return this.throwIfDisposed(),Xt(this,e,t)};re().prototype.min=function(e,t){return this.throwIfDisposed(),_f(this,e,t)};re().prototype.minimum=function(e){return this.throwIfDisposed(),_d(this,e)};re().prototype.mirrorPad=function(e,t){return this.throwIfDisposed(),yI(this,e,t)};re().prototype.mod=function(e){return this.throwIfDisposed(),AI(this,e)};re().prototype.mul=function(e){return this.throwIfDisposed(),K(this,e)};re().prototype.neg=function(){return this.throwIfDisposed(),Kt(this)};re().prototype.norm=function(e,t,n){return this.throwIfDisposed(),c1(this,e,t,n)};re().prototype.notEqual=function(e){return this.throwIfDisposed(),Yl(this,e)};re().prototype.oneHot=function(e,t=1,n=0){return this.throwIfDisposed(),kd(this,e,t,n)};re().prototype.onesLike=function(){return this.throwIfDisposed(),Dr(this)};re().prototype.pad=function(e,t){return this.throwIfDisposed(),Wa(this,e,t)};re().prototype.pool=function(e,t,n,r,s){return this.throwIfDisposed(),CK(this,e,t,n,r,s)};re().prototype.pow=function(e){return this.throwIfDisposed(),Va(this,e)};re().prototype.prelu=function(e){return this.throwIfDisposed(),Df(this,e)};re().prototype.prod=function(e,t){return this.throwIfDisposed(),KA(this,e,t)};re().prototype.reciprocal=function(){return this.throwIfDisposed(),xI(this)};re().prototype.relu=function(){return this.throwIfDisposed(),ua(this)};re().prototype.relu6=function(){return this.throwIfDisposed(),YA(this)};re().prototype.reshapeAs=function(e){return this.throwIfDisposed(),J(this,e.shape)};re().prototype.reshape=function(e){return this.throwIfDisposed(),J(this,e)};re().prototype.resizeBilinear=function(e,t,n){return this.throwIfDisposed(),zI(this,e,t,n)};re().prototype.resizeNearestNeighbor=function(e,t,n){return this.throwIfDisposed(),LI(this,e,t,n)};re().prototype.reverse=function(e){return this.throwIfDisposed(),Fr(this,e)};re().prototype.rfft=function(){return this.throwIfDisposed(),o1(this)};re().prototype.round=function(){return this.throwIfDisposed(),JA(this)};re().prototype.rsqrt=function(){return this.throwIfDisposed(),QA(this)};re().prototype.selu=function(){return this.throwIfDisposed(),e1(this)};re().prototype.separableConv2d=function(e,t,n,r,s,a){return this.throwIfDisposed(),bI(this,e,t,n,r,s,a)};re().prototype.sigmoid=function(){return this.throwIfDisposed(),Rs(this)};re().prototype.sign=function(){return this.throwIfDisposed(),vI(this)};re().prototype.sin=function(){return this.throwIfDisposed(),t1(this)};re().prototype.sinh=function(){return this.throwIfDisposed(),n1(this)};re().prototype.slice=function(e,t){return this.throwIfDisposed(),nt(this,e,t)};re().prototype.softmax=function(e){return this.throwIfDisposed(),Of(this,e)};re().prototype.softplus=function(){return this.throwIfDisposed(),Zl(this)};re().prototype.spaceToBatchND=function(e,t){return this.throwIfDisposed(),Rf(this,e,t)};re().prototype.split=function(e,t){return this.throwIfDisposed(),dr(this,e,t)};re().prototype.sqrt=function(){return this.throwIfDisposed(),$n(this)};re().prototype.square=function(){return this.throwIfDisposed(),wt(this)};re().prototype.squaredDifference=function(e){return this.throwIfDisposed(),i1(this,e)};re().prototype.squeeze=function(e){return this.throwIfDisposed(),Jl(this,e)};re().prototype.stack=function(e,t){this.throwIfDisposed();let n=e instanceof Ct?[this,e]:[this,...e];return Mr(n,t)};re().prototype.step=function(e){return this.throwIfDisposed(),Fd(this,e)};re().prototype.stridedSlice=function(e,t,n,r,s,a,o,i){return this.throwIfDisposed(),II(this,e,t,n,r,s,a,o,i)};re().prototype.sub=function(e){return this.throwIfDisposed(),Ne(this,e)};re().prototype.sum=function(e,t){return this.throwIfDisposed(),_e(this,e,t)};re().prototype.tan=function(){return this.throwIfDisposed(),SI(this)};re().prototype.tanh=function(){return this.throwIfDisposed(),Kl(this)};re().prototype.tile=function(e){return this.throwIfDisposed(),Yo(this,e)};re().prototype.toBool=function(){return this.throwIfDisposed(),ke(this,"bool")};re().prototype.toFloat=function(){return this.throwIfDisposed(),ke(this,"float32")};re().prototype.toInt=function(){return this.throwIfDisposed(),ke(this,"int32")};re().prototype.topk=function(e,t){return this.throwIfDisposed(),TI(this,e,t)};re().prototype.transpose=function(e){return this.throwIfDisposed(),pt(this,e)};re().prototype.unique=function(e){return this.throwIfDisposed(),u1(this,e)};re().prototype.unsortedSegmentSum=function(e,t){return this.throwIfDisposed(),NI(this,e,t)};re().prototype.unstack=function(e){return this.throwIfDisposed(),ls(this,e)};re().prototype.where=function(e,t){return this.throwIfDisposed(),Ln(e,this,t)};re().prototype.zerosLike=function(){return this.throwIfDisposed(),rt(this)};var jI={kernelName:xc,inputsToSave:["x"],gradFunc:(e,t)=>{let[n]=t;return{x:()=>K(e,Fd(ke(n,"float32"),-1))}}},XY={kernelName:bc,inputsToSave:["x"],gradFunc:(e,t)=>{let[n]=t;return{x:()=>{let r=wt(ke(n,"float32")),s=$n(Ne(Fe(1),r));return Kt(Re(e,s))}}}},ZY={kernelName:vc,inputsToSave:["x"],gradFunc:(e,t)=>{let[n]=t;return{x:()=>{let r=$n(Ne(wt(ke(n,"float32")),1));return Re(e,r)}}}},YY={kernelName:Fa,inputsToSave:["a","b"],gradFunc:(e,t)=>{let[n,r]=t,s=Rt(n.shape,r.shape);return{a:()=>{let i=e,l=ln(n.shape,s);return l.length>0&&(i=_e(i,l)),J(i,n.shape)},b:()=>{let i=e,l=ln(r.shape,s);return l.length>0&&(i=_e(i,l)),J(i,r.shape)}}}},JY={kernelName:Zi,saveAllInputs:!0,gradFunc:(e,t)=>{let n={};return t.forEach((r,s)=>{n[s]=()=>e.clone()}),n}},QY={kernelName:Yi,inputsToSave:["x"],gradFunc:(e,t)=>{let[n]=t;return{x:()=>rt(n)}}},eJ={kernelName:qp,inputsToSave:["x"],gradFunc:(e,t)=>{let[n]=t;return{x:()=>rt(n)}}},tJ={kernelName:Ic,inputsToSave:["x"],gradFunc:(e,t)=>{let[n]=t;return{x:()=>Re(e,$n(Ne(Fe(1),wt(ke(n,"float32")))))}}},nJ={kernelName:Sc,inputsToSave:["x"],gradFunc:(e,t)=>{let[n]=t;return{x:()=>{let r=$n(pe(Fe(1),wt(ke(n,"float32"))));return Re(e,r)}}}},rJ={kernelName:Cc,inputsToSave:["a","b"],gradFunc:(e,t)=>{let[n,r]=t,s=Rt(n.shape,r.shape);return{a:()=>{let i=pe(wt(n),wt(r)),l=K(e,Re(r,i)),u=ln(n.shape,s);return u.length>0&&(l=_e(l,u)),J(l,n.shape)},b:()=>{let i=pe(wt(n),wt(r)),l=Kt(K(e,Re(n,i))),u=ln(r.shape,s);return u.length>0&&(l=_e(l,u)),J(l,r.shape)}}}},sJ={kernelName:Tc,inputsToSave:["x"],gradFunc:(e,t)=>{let[n]=t;return{x:()=>Re(e,pe(wt(ke(n,"float32")),1))}}},aJ={kernelName:Nc,inputsToSave:["x"],gradFunc:(e,t)=>{let[n]=t;return{x:()=>Re(e,Ne(Fe(1),wt(ke(n,"float32"))))}}};function oJ(e,t,n,r,s,a){let o=O(e,"dy","avgPool3dGrad"),i=O(t,"input","avgPool3dGrad"),l=o,u=i,c=!1;i.rank===4&&(c=!0,l=J(o,[1,o.shape[0],o.shape[1],o.shape[2],o.shape[3]]),u=J(i,[1,i.shape[0],i.shape[1],i.shape[2],i.shape[3]])),z(l.rank===5,()=>`Error in avgPool3dGrad: dy must be rank 5 but got rank ${l.rank}.`),z(u.rank===5,()=>`Error in avgPool3dGrad: input must be rank 5 but got rank ${u.rank}.`),a!=null&&z(mn(s),()=>`Error in avgPool3dGrad: pad must be an integer when using, dimRoundingMode ${a} but got pad ${s}.`);let d={dy:l,input:u},h={filterSize:n,strides:r,pad:s,dimRoundingMode:a},p=G.runKernel(wy,d,h);return c?J(p,[p.shape[1],p.shape[2],p.shape[3],p.shape[4]]):p}var iJ=V({avgPool3dGrad_:oJ}),lJ={kernelName:Kp,inputsToSave:["x"],gradFunc:(e,t,n)=>{let[r]=t,{filterSize:s,strides:a,pad:o,dimRoundingMode:i}=n;return{x:()=>iJ(e,r,s,a,o,i)}}};function uJ(e,t,n,r,s){let a=O(e,"dy","avgPoolGrad"),o=O(t,"input","avgPoolGrad");z(o.rank===a.rank,()=>`Rank of input (${o.rank}) does not match rank of dy (${a.rank})`);let i=o,l=a,u=!1;o.rank===3&&(u=!0,i=J(o,[1,o.shape[0],o.shape[1],o.shape[2]]),l=J(a,[1,a.shape[0],a.shape[1],a.shape[2]])),z(l.rank===4,()=>`Error in avgPoolGrad: dy must be rank 4 but got rank ${l.rank}.`),z(i.rank===4,()=>`Error in avgPoolGrad: input must be rank 4 but got rank ${i.rank}.`);let c={dy:l,input:i},d={filterSize:n,strides:r,pad:s},h=G.runKernel(vy,c,d);return u?J(h,[h.shape[1],h.shape[2],h.shape[3]]):h}var cJ=V({avgPoolGrad_:uJ}),dJ={kernelName:Ji,inputsToSave:["x"],gradFunc:(e,t,n)=>{let[r]=t,{filterSize:s,strides:a,pad:o}=n;return{x:()=>cJ(e,r,s,a,o)}}},hJ={kernelName:Qi,inputsToSave:["a","b"],gradFunc:(e,t,n)=>{let[r,s]=t,{transposeA:a,transposeB:o}=n;return!a&&!o?{a:()=>ot(e,s,!1,!0),b:()=>ot(r,e,!0,!1)}:!a&&o?{a:()=>ot(e,s,!1,!1),b:()=>ot(e,r,!0,!1)}:a&&!o?{a:()=>ot(s,e,!1,!0),b:()=>ot(r,e,!1,!1)}:{a:()=>ot(s,e,!0,!0),b:()=>ot(e,r,!0,!0)}}},pJ={kernelName:Xp,gradFunc:(e,t,n)=>{let{blockShape:r,crops:s}=n;return{x:()=>Rf(e,r,s)}}},fJ={kernelName:eH,gradFunc:(e,t,n)=>{let r=n,s=r.inputShape,a=r.shape,o=Array.from(a);for(let l=s.length-1;l>=0;l--)if(s[l]===a[l])o[l]=1;else if(s[l]!==1)throw new Error(`broadcastTo(): [${s}] cannot be broadcast to [${a}].`);let i=[];for(let l=0;l<o.length;l++)o[l]>1&&i.push(l);return{x:()=>_e(e,i,!0)}}},mJ={kernelName:el,gradFunc:e=>({x:()=>e.clone()})},gJ={kernelName:No,gradFunc:e=>({x:()=>rt(e)})},yJ={kernelName:Co,inputsToSave:["x"],gradFunc:(e,t,n)=>{let[r]=t,{clipValueMin:s,clipValueMax:a}=n;return{x:()=>Ln(is(Jo(r,s),Qo(r,a)),e,rt(e))}}},AJ={kernelName:Zp,inputsToSave:["x"],gradFunc:jI.gradFunc},xJ={kernelName:Ec,saveAllInputs:!0,gradFunc:(e,t,n)=>{let r=t.map(l=>l.shape),{axis:s}=n,a=jr(s,t[0].shape)[0],o=r.map(l=>l[a]);return dr(e,o,a).map(l=>()=>l)}},bJ={kernelName:tl,inputsToSave:["x","filter"],gradFunc:(e,t,n)=>{let[r,s]=t,{dilations:a,strides:o,pad:i,dataFormat:l}=n;return z(La(a),()=>`Error in gradient of conv2D: dilation rates greater than 1 are not yet supported in gradients. Got dilations '${a}'`),{x:()=>OA(r.shape,e,s,o,i,l),filter:()=>d1(r,e,s.shape,o,i,l)}}},vJ={kernelName:nl,inputsToSave:["dy","filter"],gradFunc:(e,t,n)=>{let[r,s]=t,{strides:a,pad:o,dataFormat:i,dimRoundingMode:l}=n;return{dy:()=>Ba(e,s,a,o,i,1,l),filter:()=>d1(e,r,s.shape,a,o,i,l)}}};function wJ(e,t,n,r,s){let a=e;e.rank===4&&(a=J(e,[1,e.shape[0],e.shape[1],e.shape[2],e.shape[3]]));let o=t;o.rank===4&&(o=J(t,[1,t.shape[0],t.shape[1],t.shape[2],t.shape[3]])),z(a.rank===5,()=>`Error in conv3dDerFilter: input must be rank 5, but got shape ${a.shape}.`),z(o.rank===5,()=>`Error in conv3dDerFilter: dy must be rank 5, but got shape ${o.shape}.`),z(n.length===5,()=>`Error in conv3dDerFilter: filterShape must be length 5, but got ${n}.`),z(a.shape[4]===n[3],()=>`Error in conv3dDerFilter: depth of input ${a.shape[4]}) must match input depth in filter (${n[3]}.`),z(o.shape[4]===n[4],()=>`Error in conv3dDerFilter: depth of dy (${o.shape[4]}) must match output depth for filter (${n[4]}).`);let i={x:a,dy:o},l={strides:r,pad:s,filterShape:n};return G.runKernel(Ty,i,l)}var kJ=V({conv3DBackpropFilter_:wJ}),IJ={kernelName:Yp,inputsToSave:["x","filter"],gradFunc:(e,t,n)=>{let{dilations:r,strides:s,pad:a}=n;z(La(r),()=>`Error in gradient of conv3D: dilation rates greater than 1 are not yet supported in gradients. Got dilations '${r}'`);let[o,i]=t;return{x:()=>rI(o.shape,e,i,s,a),filter:()=>kJ(o,e,i.shape,s,a)}}},SJ={kernelName:rl,inputsToSave:["x"],gradFunc:(e,t)=>{let[n]=t;return{x:()=>K(Kt(t1(ke(n,"float32"))),e)}}},TJ={kernelName:$c,inputsToSave:["x"],gradFunc:(e,t)=>{let[n]=t;return{x:()=>K(n1(ke(n,"float32")),e)}}},NJ={kernelName:sl,inputsToSave:["x"],gradFunc:(e,t,n)=>{let[r]=t,{axis:s,exclusive:a,reverse:o}=n;return{x:()=>{let i=fI([s],r.rank),l=LA(e,s,a,!o);return i!=null&&(l=pt(l,i)),l}}}},CJ={kernelName:al,inputsToSave:["x","filter"],gradFunc:(e,t,n)=>{let{dilations:r,strides:s,pad:a,dimRoundingMode:o}=n,i=r==null?[1,1]:r;z(La(i),()=>`Error in gradient of depthwiseConv2dNative: dilation rates greater than 1 are not yet supported. Got dilations '${i}'`);let[l,u]=t;return z(l.rank===4,()=>`Error in gradient of depthwiseConv2dNative: input must be rank 4, but got rank ${l.rank}.`),z(u.rank===4,()=>`Error in gradient of depthwiseConv2dNative: filter must be rank 4, but got rank ${u.rank}.`),z(l.shape[3]===u.shape[2],()=>`Error in gradient of depthwiseConv2d: number of input channels (${l.shape[3]}) must match the inChannels dimension in filter ${u.shape[2]}.`),z(_s(s,i),()=>`Error in gradient of depthwiseConv2d: Either strides or dilations must be 1. Got strides ${s} and dilations '${i}'.`),o!=null&&z(mn(a),()=>`Error in depthwiseConv2d: pad must be an integer when using, dimRoundingMode ${o} but got pad ${a}.`),{x:()=>DI(l.shape,e,u,s,a,r,o),filter:()=>RI(l,e,u.shape,s,a,r,o)}}},EJ={kernelName:Jp,inputsToSave:["x","filter"],gradFunc:(e,t,n)=>{let[r,s]=t,a={x:r,filter:s,dy:e},o={x:r,filter:s,dy:e};return{x:()=>G.runKernel(Ry,a,n),filter:()=>G.runKernel(Dy,o,n)}}},$J={kernelName:Dc,outputsToSave:[!0],gradFunc:(e,t)=>{let[n]=t,r={dy:e,y:n};return{x:()=>G.runKernel(My,r)}}},_J={kernelName:Fc,inputsToSave:["x"],gradFunc:(e,t)=>{let[n]=t,r=K(Kr(Kt(wt(n))),2/Math.sqrt(Math.PI));return{x:()=>K(e,r)}}},RJ={kernelName:Eo,outputsToSave:[!0],gradFunc:(e,t)=>{let[n]=t;return{x:()=>K(e,n)}}},DJ={kernelName:Mc,inputsToSave:["input"],gradFunc:(e,t)=>{let[n]=t;return{input:()=>J(e,n.shape)}}},FJ={kernelName:ll,inputsToSave:["x"],gradFunc:(e,t)=>{let[n]=t;return{x:()=>K(e,Kr(n))}}},MJ={kernelName:$o,gradFunc:e=>({x:()=>rt(e)})},OJ={kernelName:ul,inputsToSave:["a","b"],gradFunc:(e,t)=>{let[n,r]=t,s=Rt(n.shape,r.shape);return{a:()=>{let i=Re(e,ke(r,"float32")),l=ln(n.shape,s);return l.length>0?J(_e(i,l),n.shape):i},b:()=>{let i=K(e,ke(n,"float32")),l=ln(r.shape,s);l.length>0&&(i=J(_e(i,l),r.shape));let u=wt(r);return Kt(Re(i,ke(u,"float32")))}}}},PJ={kernelName:cl,inputsToSave:["x","mean","variance","scale"],gradFunc:(e,t,n)=>{let{varianceEpsilon:r}=n,[s,a,o,i]=t,l=i==null?Fe(1):i,u=ln(a.shape,s.shape),c=[];if(a.rank===1){for(let b=0;b<s.shape.length-1;++b)c.push(s.shape[b]);c.push(1)}let d=Ne(s,a),h=K(e,l),p=QA(pe(o,Fe(r))),f=K(K(K(p,p),p),Fe(-.5));return{x:()=>a.rank===1?J(K(K(e,Yo(J(p,[1,1,1,a.shape[0]]),c)),l),s.shape):J(K(K(e,p),l),s.shape),mean:()=>{let b=K(K(p,Fe(-1)),h);return a.rank===1&&(b=_e(b,u)),J(b,a.shape)},variance:()=>{let b=K(K(f,d),h);return a.rank===1&&(b=_e(b,u)),J(b,a.shape)},scale:()=>{let b=K(d,p),v=K(e,b);return a.rank===1&&(v=_e(v,u)),J(v,a.shape)},offset:()=>{let b=e;return a.rank===1&&(b=_e(b,u)),J(b,a.shape)}}}},zJ={kernelName:Pc,inputsToSave:["x","indices"],gradFunc:(e,t,n)=>{let[r,s]=t,{axis:a}=n,o=jr(a,r.shape)[0];return{x:()=>{let l=r.shape,u=s.size,c=l.slice(0,o),d=c.length,h=l.slice(a,l.length).slice(1),p=h.length,f=qI(0,d),m=qI(d+1,d+1+p),g=KI([c,[u],h]),y=J(e,g),A=J(s,[u]),x=KI([[d],f,m]),b=pt(y,x),v=NI(b,A,r.shape[o]),w=GA(x);return v=pt(v,w),v},indices:()=>s}}};function qI(e,t){let n=[];for(let r=e;r<t;++r)n.push(r);return n}function KI(e){let t=[];for(let n=0;n<e.length;++n)for(let r=0;r<e[n].length;++r)t.push(e[n][r]);return t}var LJ={kernelName:_o,inputsToSave:["a","b"],gradFunc:(e,t)=>{let[n,r]=t;return{a:()=>rt(n),b:()=>rt(r)}}},BJ={kernelName:hl,gradFunc:e=>({x:()=>ke(e,"float32")})},WJ={kernelName:Lc,gradFunc:e=>({x:()=>rt(e)})},VJ={kernelName:Bc,gradFunc:e=>({x:()=>rt(e)})},UJ={kernelName:Wc,gradFunc:e=>({x:()=>rt(e)})},HJ={kernelName:pl,inputsToSave:["x"],gradFunc:(e,t,n)=>{let[r]=t,{alpha:s}=n,a=_r(r,0);return{x:()=>Ln(a,e,K(e,s))}}},GJ={kernelName:Vc,inputsToSave:["x"],gradFunc:(e,t)=>{let[n]=t;return{x:()=>Re(e,pe(n,1))}}},jJ={kernelName:Ro,inputsToSave:["x"],gradFunc:(e,t)=>{let[n]=t;return{x:()=>Re(e,ke(n,"float32"))}}},qJ={kernelName:tH,inputsToSave:[],outputsToSave:[!0],gradFunc:(e,t,n)=>{let[r]=t,{axis:s}=n;return{logits:()=>{let a=!0,o=Kr(r);return Ne(e,K(_e(e,s,a),o))}}}};function KJ(e,t,n,r=5,s=1,a=1,o=.5){let i={x:e,y:t,dy:n},l={depthRadius:r,bias:s,alpha:a,beta:o};return G.runKernel(By,i,l)}var XJ=V({localResponseNormalizationBackprop_:KJ}),ZJ={kernelName:nf,inputsToSave:["x"],outputsToSave:[!0],gradFunc:(e,t,n)=>{let[r,s]=t,{depthRadius:a,bias:o,alpha:i,beta:l}=n;return{x:()=>XJ(r,s,e,a,o,i,l)}}};function XI(e,t,n,r){return t.rank<n.rank&&(t=J(t,ei(t.shape,r))),e.rank<n.rank&&(e=J(e,ei(e.shape,r))),{x:()=>K(e,ke(Zo(n,t),e.dtype))}}var ZI={kernelName:gl,inputsToSave:["x"],outputsToSave:[!0],gradFunc:(e,t,n)=>{let r=n,{reductionIndices:s}=r,a=t[0],o=t[1],i=jr(s,a.shape),l=XI(e,o,a,i);return{x:()=>l.x()}}},YJ={kernelName:Do,inputsToSave:["a","b"],gradFunc:(e,t)=>{let[n,r]=t;return{a:()=>K(e,ke(Jo(n,r),"float32")),b:()=>K(e,ke(WA(n,r),"float32"))}}};function JJ(e,t,n,r,s,a,o){let i=O(e,"dy","maxPool3dGrad"),l=O(t,"input","maxPool3dGrad"),u=O(n,"output","maxPool3dGrad"),c=i,d=l,h=u,p=!1;l.rank===4&&(p=!0,c=J(i,[1,i.shape[0],i.shape[1],i.shape[2],i.shape[3]]),d=J(l,[1,l.shape[0],l.shape[1],l.shape[2],l.shape[3]]),h=J(u,[1,u.shape[0],u.shape[1],u.shape[2],u.shape[3]])),z(c.rank===5,()=>`Error in maxPool3dGrad: dy must be rank 5 but got rank ${c.rank}.`),z(d.rank===5,()=>`Error in maxPool3dGrad: input must be rank 5 but got rank ${d.rank}.`),z(h.rank===5,()=>`Error in maxPool3dGrad: output must be rank 5 but got rank ${h.rank}.`),o!=null&&z(mn(a),()=>`Error in maxPool3dGrad: pad must be an integer when using, dimRoundingMode ${o} but got pad ${a}.`);let f={dy:c,input:d,output:h},m={filterSize:r,strides:s,pad:a,dimRoundingMode:o},g=G.runKernel(Vy,f,m);return p?J(g,[g.shape[1],g.shape[2],g.shape[3],g.shape[4]]):g}var QJ=V({maxPool3dGrad_:JJ}),eQ={kernelName:rf,inputsToSave:["x"],outputsToSave:[!0],gradFunc:(e,t,n)=>{let[r,s]=t,{filterSize:a,strides:o,pad:i,dimRoundingMode:l}=n;return{x:()=>QJ(e,r,s,a,o,i,l)}}};function tQ(e,t,n,r,s,a,o){let i=O(e,"dy","maxPoolGrad"),l=O(t,"input","maxPoolGrad"),u=O(n,"output","maxPoolGrad");z(l.rank===i.rank,()=>`Rank of input (${l.rank}) does not match rank of dy (${i.rank})`),z(i.rank===4,()=>`Error in maxPoolGrad: dy must be rank 4 but got rank ${i.rank}.`),z(l.rank===4,()=>`Error in maxPoolGrad: input must be rank 4 but got rank ${l.rank}.`),o!=null&&z(mn(a),()=>`Error in maxPoolGrad: pad must be an integer when using, dimRoundingMode ${o} but got pad ${a}.`);let c={dy:i,input:l,output:u},d={filterSize:r,strides:s,pad:a,dimRoundingMode:o};return G.runKernel(Wy,c,d)}var nQ=V({maxPoolGrad_:tQ}),rQ={kernelName:yl,inputsToSave:["x"],outputsToSave:[!0],gradFunc:(e,t,n)=>{let[r,s]=t,{filterSize:a,strides:o,pad:i}=n;return{x:()=>nQ(e,r,s,a,o,i)}}},sQ={kernelName:Al,inputsToSave:["x"],gradFunc:(e,t,n)=>{let[r]=t,{axis:s}=n,a=jr(s,r.shape),i=pI(r.shape,a)[1],l=on(i);return{x:()=>{let c=r.shape.slice();a.forEach(p=>{c[p]=1});let d=J(e,c);return Re(K(d,la(r.shape,"float32")),l)}}}},aQ={kernelName:xl,inputsToSave:["x"],outputsToSave:[!0],gradFunc:(e,t,n)=>{let r=n,{axis:s}=r,[a,o]=t,i=jr(s,a.shape),l=XI(e,o,a,i);return{x:()=>l.x()}}},oQ={kernelName:Fo,inputsToSave:["a","b"],gradFunc:(e,t)=>{let[n,r]=t;return{a:()=>K(e,ke(Qo(n,r),"float32")),b:()=>K(e,ke(_r(n,r),"float32"))}}},iQ={kernelName:bl,inputsToSave:["x"],gradFunc:(e,t,n)=>{let r=t[0],{paddings:s}=n,a=s.map(o=>o[0]);return{x:()=>nt(e,a,r.shape)}}},lQ={kernelName:Hc,inputsToSave:["a","b"],gradFunc:(e,t)=>{let[n,r]=t,s=Rt(n.shape,r.shape);return{a:()=>{let i=ln(n.shape,s);return i.length>0?J(_e(e,i),n.shape):e},b:()=>{let i=K(e,Kt(Ed(Re(n,r)))),l=ln(r.shape,s);return l.length>0?J(_e(i,l),r.shape):i}}}},uQ={kernelName:Mo,inputsToSave:["a","b"],gradFunc:(e,t)=>{let[n,r]=t,s=Rt(n.shape,r.shape);return{a:()=>{let i=K(e,ke(r,"float32")),l=ln(n.shape,s);return l.length>0?J(_e(i,l),n.shape):i},b:()=>{let i=K(e,ke(n,"float32")),l=ln(r.shape,s);return l.length>0?J(_e(i,l),r.shape):i}}}},cQ={kernelName:Gc,gradFunc:e=>({x:()=>Kt(e)})},dQ={kernelName:wl,inputsToSave:["indices"],gradFunc:(e,t)=>{let n=t[0];return{indices:()=>un(n.shape,"float32")}}},hQ={kernelName:Xc,gradFunc:e=>({x:()=>rt(e)})},pQ={kernelName:Zc,saveAllInputs:!0,gradFunc:(e,t,n)=>{let{axis:r}=n;return ls(e,r).map(a=>()=>a)}},YI={kernelName:kl,inputsToSave:["x"],gradFunc:(e,t,n)=>{let r=t[0],{paddings:s}=n,a=s.map(o=>o[0]);return{x:()=>nt(e,a,r.shape)}}},fQ={kernelName:Il,inputsToSave:["a","b"],outputsToSave:[!0],gradFunc:(e,t)=>{let[n,r,s]=t,a=n,o=r,i=Rt(a.shape,o.shape);return{a:()=>{let c=ke(o,"float32"),d=K(e,K(c,Va(a,Ne(c,Fe(1))))),h=ln(a.shape,i);return h.length>0&&(d=_e(d,h)),J(d,a.shape)},b:()=>{let c=_r(a,0),d=Ln(c,Rr(a),rt(a)),h=K(e,K(s,d)),p=ln(o.shape,i);return p.length>0&&(h=_e(h,p)),J(h,o.shape)}}}},mQ={kernelName:Sl,inputsToSave:["x","alpha"],gradFunc:(e,t)=>{let[n,r]=t,s=_r(n,0);return{x:()=>Ln(s,e,K(e,r)),alpha:()=>{let a=Ln(s,rt(e),K(e,n)),o=ln(r.shape,e.shape);return o.length>0&&(a=_e(a,o)),J(a,r.shape)}}}},gQ={kernelName:ol,inputsToSave:["a","b"],gradFunc:(e,t)=>{let[n,r]=t,s=Rt(n.shape,r.shape);return{a:()=>{let i=Re(e,ke(r,"float32")),l=ln(n.shape,s);return l.length>0?J(_e(i,l),n.shape):i},b:()=>{let i=K(e,ke(n,"float32")),l=ln(r.shape,s);l.length>0&&(i=J(_e(i,l),r.shape));let u=wt(r);return Kt(Re(i,ke(u,"float32")))}}}},yQ={kernelName:Jc,inputsToSave:["x"],gradFunc:(e,t)=>{let[n]=t;return{x:()=>Re(e,Kt(wt(n)))}}},AQ={kernelName:Cl,inputsToSave:["x"],gradFunc:(e,t)=>{let[n]=t,r=K(Qo(n,6),Fd(n));return{x:()=>K(e,ke(r,"float32"))}}},xQ={kernelName:Tl,inputsToSave:["x"],gradFunc:(e,t)=>{let[n]=t;return{x:()=>K(e,ke(Fd(n),"float32"))}}},bQ={kernelName:Qc,inputsToSave:["x"],gradFunc:(e,t)=>{let[n]=t;return{x:()=>J(e,n.shape)}}},vQ={kernelName:Nl,inputsToSave:["images"],gradFunc:(e,t,n)=>{let[r]=t,s={dy:e,images:r};return{images:()=>G.runKernel(qy,s,n)}}},wQ={kernelName:af,inputsToSave:["images"],gradFunc:(e,t,n)=>{let[r]=t,s={dy:e,images:r};return{images:()=>G.runKernel(jy,s,n)}}},kQ={kernelName:El,gradFunc:(e,t,n)=>{let{dims:r}=n,s=jr(r,e.shape);return{x:()=>Fr(e,s)}}},IQ={kernelName:$l,gradFunc:e=>({x:()=>rt(e)})},SQ={kernelName:Oo,inputsToSave:["x"],gradFunc:(e,t)=>{let[n]=t;return{x:()=>Kt(Re(e,K(Va(n,1.5),2)))}}},TQ={kernelName:td,inputsToSave:["condition"],gradFunc:(e,t)=>{let[n]=t;return{condition:()=>ke(rt(n),"float32"),t:()=>K(e,ke(n,e.dtype)),e:()=>K(e,ke(Ef(n),e.dtype))}}},NQ={kernelName:nd,inputsToSave:["x"],gradFunc:(e,t)=>{let[n]=t;return{x:()=>{let r=_r(n,Fe(0)),s=Fe(WI),a=Fe(VI),o=K(e,a),i=K(K(e,s),Kr(ke(n,"float32")));return Ln(r,o,i)}}}},CQ={kernelName:Rl,outputsToSave:[!0],gradFunc:(e,t)=>{let[n]=t;return{x:()=>K(e,K(n,Ne(Fe(1),n)))}}},EQ={kernelName:ad,gradFunc:e=>({x:()=>rt(e)})},$Q={kernelName:_l,inputsToSave:["x"],gradFunc:(e,t)=>{let[n]=t;return{x:()=>K(Nf(ke(n,"float32")),e)}}},_Q={kernelName:sd,inputsToSave:["x"],gradFunc:(e,t)=>{let[n]=t;return{x:()=>K(zA(ke(n,"float32")),e)}}},RQ={kernelName:rd,inputsToSave:["x"],gradFunc:(e,t,n)=>{let[r]=t,{begin:s,size:a}=n,o=r.shape,[i,l]=L6(r,s,a),u=[];for(let c=0;c<e.rank;c++)u.push([i[c],o[c]-i[c]-l[c]]);return{x:()=>Wa(e,u)}}},DQ={kernelName:Ml,outputsToSave:[!0],gradFunc:(e,t,n)=>{let[r]=t,{dim:s}=n,a=!0,o=K(e,r);return{logits:()=>Ne(o,K(_e(o,[s],a),r))}}},FQ={kernelName:od,inputsToSave:["x"],gradFunc:(e,t)=>{let[n]=t;return{x:()=>K(e,Rs(n))}}},JI={kernelName:of,gradFunc:(e,t,n)=>{let{blockShape:r,paddings:s}=n;return{x:()=>Tf(e,r,s)}}},QI={kernelName:id,gradFunc:(e,t,n)=>{let{axis:r}=n;return{x:()=>en(e,r)}}},MQ={kernelName:Dl,inputsToSave:["x"],gradFunc:(e,t)=>{let[n]=t;return{x:()=>Re(e,K($n(ke(n,"float32")),2))}}},OQ={kernelName:lf,inputsToSave:["x"],gradFunc:(e,t)=>{let[n]=t;return{x:()=>K(e,K(ke(n,"float32"),2))}}},PQ={kernelName:Po,inputsToSave:["a","b"],gradFunc:(e,t)=>{let[n,r]=t,s=Fe(2);return{a:()=>K(e,K(s,Ne(n,r))),b:()=>K(e,K(s,Ne(r,n)))}}},zQ={kernelName:Bo,gradFunc:e=>({x:()=>rt(e)})},LQ={kernelName:zo,inputsToSave:["a","b"],gradFunc:(e,t)=>{let[n,r]=t,s=Rt(n.shape,r.shape);return{a:()=>{let i=e,l=ln(n.shape,s);return l.length>0&&(i=_e(i,l)),J(i,n.shape)},b:()=>{let i=e,l=ln(r.shape,s);return l.length>0&&(i=_e(i,l)),J(Kt(i),r.shape)}}}},BQ={kernelName:Fl,inputsToSave:["x"],gradFunc:(e,t,n)=>{let[r]=t,s=r.shape.slice(),{axis:a}=n;jr(a,r.shape).forEach(u=>{s[u]=1});let i=J(e,s),l=K(i,la(r.shape,"float32"));return{x:()=>l}}},WQ={kernelName:Ol,inputsToSave:["x"],gradFunc:(e,t)=>{let[n]=t;return{x:()=>Re(e,wt(Nf(n)))}}},VQ={kernelName:Pl,outputsToSave:[!0],gradFunc:(e,t)=>{let[n]=t;return{x:()=>K(Ne(Fe(1),wt(n)),e)}}},UQ={kernelName:Lo,inputsToSave:["x"],gradFunc:(e,t,n)=>{let[r]=t,{reps:s}=n;return{x:()=>{let o=rt(r);if(r.rank===1)for(let i=0;i<s[0];++i)o=pe(o,nt(e,[i*r.shape[0]],[r.shape[0]]));else if(r.rank===2)for(let i=0;i<s[0];++i)for(let l=0;l<s[1];++l)o=pe(o,nt(e,[i*r.shape[0],l*r.shape[1]],[r.shape[0],r.shape[1]]));else if(r.rank===3)for(let i=0;i<s[0];++i)for(let l=0;l<s[1];++l)for(let u=0;u<s[2];++u)o=pe(o,nt(e,[i*r.shape[0],l*r.shape[1],u*r.shape[2]],[r.shape[0],r.shape[1],r.shape[2]]));else if(r.rank===4)for(let i=0;i<s[0];++i)for(let l=0;l<s[1];++l)for(let u=0;u<s[2];++u)for(let c=0;c<s[3];++c)o=pe(o,nt(e,[i*r.shape[0],l*r.shape[1],u*r.shape[2],c*r.shape[3]],[r.shape[0],r.shape[1],r.shape[2],r.shape[3]]));else throw new Error(`Gradient for tile operation is not implemented for rank-${r.rank} tensors yet.`);return o}}}},HQ={kernelName:zl,gradFunc:(e,t,n)=>{let r=n,{perm:s}=r,a=GA(s);return{x:()=>pt(e,a)}}},GQ={kernelName:dd,gradFunc:(e,t,n)=>{let r=n,{axis:s}=r;return{value:()=>Mr(e,s)}}},jQ={kernelName:uf,inputsToSave:["segmentIds"],gradFunc:(e,t)=>{let[n]=t;return{x:()=>qQ(e,n)}}};function qQ(e,t){let n=ia(t,rt(t)),r=$d(e,n),s=Jo(t,Fe(0,"int32")),a=r.rank-s.rank;for(let i=0;i<a;++i)s=$r(s,i+1);s=is(s,la(r.shape,"bool"));let o=rt(r);return Ln(s,r,o)}var KQ={kernelName:hd,gradFunc:e=>({x:()=>rt(e)})},XQ=[jI,XY,ZY,YY,JY,QY,eJ,tJ,nJ,rJ,sJ,aJ,lJ,dJ,hJ,pJ,fJ,mJ,gJ,yJ,AJ,xJ,vJ,bJ,IJ,SJ,TJ,NJ,CJ,EJ,gQ,$J,_J,RJ,DJ,FJ,OJ,MJ,PJ,zJ,LJ,BJ,WJ,VJ,UJ,HJ,GJ,jJ,qJ,ZJ,ZI,ZI,YJ,eQ,rQ,sQ,aQ,oQ,iQ,lQ,uQ,cQ,dQ,hQ,pQ,YI,YI,fQ,mQ,yQ,AQ,xQ,bQ,vQ,wQ,kQ,IQ,SQ,TQ,NQ,CQ,EQ,$Q,_Q,RQ,DQ,FQ,JI,JI,QI,QI,MQ,PQ,OQ,zQ,LQ,BQ,WQ,VQ,UQ,HQ,GQ,jQ,KQ];for(let e of XQ)nH(e);var eS={};De(eS,{maxNorm:()=>QQ,minMaxNorm:()=>nee,nonNeg:()=>tee,unitNorm:()=>eee});var k1;function cn(){return k1==null&&(k1=VG().epsilon()),k1}function us(){return"channelsLast"}var da=class extends Error{constructor(e){super(e);Object.setPrototypeOf(this,da.prototype)}},cs=class extends Error{constructor(e){super(e);Object.setPrototypeOf(this,cs.prototype)}},q=class extends Error{constructor(e){super(e);Object.setPrototypeOf(this,q.prototype)}},Ge=class extends Error{constructor(e){super(e);Object.setPrototypeOf(this,Ge.prototype)}},tS=class extends Error{constructor(e){super(e);Object.setPrototypeOf(this,tS.prototype)}};function si(e,t){if(Array.isArray(e)){let n=[];for(let r=0;r<t;r++)n=n.concat(e);return n}else{let n=new Array(t);return n.fill(e),n}}function Ds(e,t){if(!e)throw new tS(t)}function nS(e,t){let n=0;for(let r of e)r===t&&n++;return n}function Jn(e){return e.length===1?e[0]:e}function Dt(e){return Array.isArray(e)?e:[e]}function ha(e){let n=e.replace(/(.)([A-Z][a-z0-9]+)/g,"$1_$2").replace(/([a-z])([A-Z])/g,"$1_$2").toLowerCase();return n[0]!=="_"?n:"private"+n}function ai(e){return e.length<=1||e.indexOf("_")===-1?e:e.replace(/[_]+(\w|$)/g,(t,n)=>n.toUpperCase())}var Xr={};function I1(e){if(e==null)return null;let t={};return t.className=e.getClassName(),t.config=e.getConfig(),t}function S1(e){if(!(e==null||typeof e!="object"))if(Array.isArray(e))e.forEach(t=>S1(t));else{let t=Object.keys(e);for(let n of t){let r=e[n];r!=null&&typeof r=="object"&&(!Array.isArray(r)&&r.type==="ndarray"&&typeof r.value=="number"?e[n]=r.value:S1(r))}}}function Md(e,t={},n={},r="object",s=!1){if(typeof e=="string"){let a=e,o;if(a in n)o=n[a];else if(a in Xr)o=Xr[a];else if(o=t[a],o==null)throw new q(`Unknown ${r}: ${e}. This may be due to one of the following reasons:
|
|
1. The ${r} is defined in Python, in which case it needs to be ported to TensorFlow.js or your JavaScript code.
|
|
2. The custom ${r} is defined in JavaScript, but is not registered properly with tf.serialization.registerClass().`);return o}else{let a=e;if(a.className==null||a.config==null)throw new q(`${r}: Improper config format: ${JSON.stringify(a)}.
|
|
'className' and 'config' must set.`);let o=a.className,i,l;if(o in n?[i,l]=n[o]:o in Xr?[i,l]=Xr.className:o in t&&([i,l]=t[o]),i==null)throw new q(`Unknown ${r}: ${o}. This may be due to one of the following reasons:
|
|
1. The ${r} is defined in Python, in which case it needs to be ported to TensorFlow.js or your JavaScript code.
|
|
2. The custom ${r} is defined in JavaScript, but is not registered properly with tf.serialization.registerClass().`);if(l!=null){let u={};for(let p of Object.keys(Xr))u[p]=Xr[p];for(let p of Object.keys(n))u[p]=n[p];let c=a.config;c.customObjects=u;let d={...Xr};for(let p of Object.keys(n))Xr[p]=n[p];S1(a.config);let h=l(i,a.config,n,s);return Xr={...d},h}else{let u={...Xr};for(let d of Object.keys(n))Xr[d]=n[d];let c=new i(a.config);return Xr={...u},c}}}function ZQ(e,t){return e<t?-1:e>t?1:0}function Hf(e,t){return-1*ZQ(e,t)}function Ga(e){if(e==null)return e;let t=[];for(let n of e)t.indexOf(n)===-1&&t.push(n);return t}function YQ(e){if(e==null)throw new q(`Invalid value in obj: ${JSON.stringify(e)}`);for(let t in e)if(e.hasOwnProperty(t))return!1;return!0}function oi(e,t,n){if(n!=null&&e.indexOf(n)<0)throw new q(`${n} is not a valid ${t}. Valid values are ${e} or null/undefined.`)}function T1(e,t,n=0,r=Infinity){return Ds(n>=0),Ds(r>=n),Array.isArray(e)&&e.length>=n&&e.length<=r&&e.every(s=>typeof s===t)}function An(e,t){Array.isArray(e)?(k.assert(e.length>0,()=>`${t} is unexpectedly an empty array.`),e.forEach((n,r)=>An(n,`element ${r+1} of ${t}`))):k.assert(Number.isInteger(e)&&e>0,()=>`Expected ${t} to be a positive integer, but got ${rS(e)}.`)}function rS(e){return e===null?"null":Array.isArray(e)?"["+e.map(t=>rS(t)).join(",")+"]":typeof e=="string"?`"${e}"`:`${e}`}function JQ(e,t){let n=k.now(),r;return(...a)=>{let o=k.now();return o-n<t||(n=o,r=e(...a)),r}}function sS(e){return e==="relu"?"relu":e==="linear"?"linear":e==="elu"?"elu":null}function N1(e,t){return Z(()=>$n(_e(K(e,e),t,!0)))}var Od=class extends ce.Serializable{getConfig(){return{}}},C1=class extends Od{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 Z(()=>{let t=N1(e,this.axis),n=cr(t,0,this.maxValue);return K(e,Re(n,pe(cn(),t)))})}getConfig(){return{maxValue:this.maxValue,axis:this.axis}}};C1.className="MaxNorm";ce.registerClass(C1);var E1=class extends Od{constructor(e){super();this.defaultAxis=0,this.axis=e.axis!=null?e.axis:this.defaultAxis}apply(e){return Z(()=>Re(e,pe(cn(),N1(e,this.axis))))}getConfig(){return{axis:this.axis}}};E1.className="UnitNorm";ce.registerClass(E1);var $1=class extends Od{apply(e){return ua(e)}};$1.className="NonNeg";ce.registerClass($1);var _1=class extends Od{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 Z(()=>{let t=N1(e,this.axis),n=pe(K(this.rate,cr(t,this.minValue,this.maxValue)),K(1-this.rate,t));return K(e,Re(n,pe(cn(),t)))})}getConfig(){return{minValue:this.minValue,maxValue:this.maxValue,rate:this.rate,axis:this.axis}}};_1.className="MinMaxNorm";ce.registerClass(_1);var aS={maxNorm:"MaxNorm",minMaxNorm:"MinMaxNorm",nonNeg:"NonNeg",unitNorm:"UnitNorm"};function dn(e){return I1(e)}function oS(e,t={}){return Md(e,ce.SerializationMap.getMap().classNameMap,t,"constraint")}function hn(e){if(e==null)return null;if(typeof e=="string"){let n={className:e in aS?aS[e]:e,config:{}};return oS(n)}else return e instanceof Od?e:oS(e)}function QQ(e){return new C1(e)}function eee(e){return new E1(e)}function tee(){return new $1}function nee(e){return new _1(e)}var iS={};De(iS,{constant:()=>See,glorotNormal:()=>Ree,glorotUniform:()=>_ee,heNormal:()=>Dee,heUniform:()=>Fee,identity:()=>Eee,leCunNormal:()=>Mee,leCunUniform:()=>Oee,ones:()=>Iee,orthogonal:()=>Pee,randomNormal:()=>Nee,randomUniform:()=>Tee,truncatedNormal:()=>Cee,varianceScaling:()=>$ee,zeros:()=>kee});var ree=["channelsFirst","channelsLast"],see=["nearest","bilinear"],aee=["valid","same","causal"],oee=["max","avg"],iee=["sum","mul","concat","ave"],nu=new Map;function Yt(e){oi(ree,"DataFormat",e)}function lee(e){oi(see,"InterpolationFormat",e)}function Or(e){oi(aee,"PaddingMode",e)}function lS(e){oi(oee,"PoolMode",e)}var Pd=[],uS="/";function ii(e,t){Pd.push(e);try{let n=t();return Pd.pop(),n}catch(n){throw Pd.pop(),n}}function uee(){return Pd.length===0?"":Pd.join(uS)+uS}function cS(e){if(!hS(e))throw new Error("Not a valid tensor name: '"+e+"'");return uee()+e}function dS(e){if(!hS(e))throw new Error("Not a valid tensor name: '"+e+"'");nu.has(e)||nu.set(e,0);let t=nu.get(e);if(nu.set(e,nu.get(e)+1),t>0){let n=`${e}_${t}`;return nu.set(n,1),n}else return e}var cee=new RegExp(/^[A-Za-z0-9][-A-Za-z0-9\._\/]*$/);function hS(e){return!!e.match(cee)}function dee(e){return e===parseInt(e.toString(),10)}function ja(e,t,n){t==null&&(t=0),n==null&&(n=e.length);let r=1;for(let s=t;s<n;++s)r*=e[s];return r}function ru(e){if(e.length===0)return Number.NaN;let t=Number.POSITIVE_INFINITY;for(let n=0;n<e.length;n++){let r=e[n];r<t&&(t=r)}return t}function qa(e){if(e.length===0)return Number.NaN;let t=Number.NEGATIVE_INFINITY;for(let n=0;n<e.length;n++){let r=e[n];r>t&&(t=r)}return t}function ds(e,t){if(t<e)throw new q(`end (${t}) < begin (${e}) is forbidden.`);let n=[];for(let r=e;r<t;++r)n.push(r);return n}function zd(e,t){return e.asType(t)}function Ld(e,t=-1){let n=e.shape.slice();return t<0&&(t=n.length+t+1),n.splice(t,0,1),e.reshape(n)}function hee(e,t){return Z(()=>{if(e.shape.length!==2)throw new q(`repeat() expects a rank-2 tensor, but received a rank-${e.shape.length} tensor.`);let n=Ld(e,1);return F1(n,[1,t,1])})}function pee(e){let t=[ja(e.shape)];return e.reshape(t)}function fee(e){if(e.rank<=1)throw new q(`batchFlatten requires a minimum rank of 2. Got rank: ${e.rank}.`);let t=[e.shape[0],ja(e.shape,1)];return e.reshape(t)}function li(e,t,n){return Z(()=>{switch(e.rank){case 1:return r1(e,t,n);case 2:return wI(e,[t,0],[n,e.shape[1]]);case 3:return s1(e,[t,0,0],[n,e.shape[1],e.shape[2]]);case 4:return Mf(e,[t,0,0,0],[n,e.shape[1],e.shape[2],e.shape[3]]);case 5:return nt(e,[t,0,0,0,0],[n,e.shape[1],e.shape[2],e.shape[3],e.shape[4]]);case 6:return nt(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 q(`sliceAlongFirstAxis() received an unsupported tensor rank: ${e.rank}`)}})}function R1(e,t,n){return Z(()=>{switch(e.rank){case 1:return r1(e,t,n);case 2:return wI(e,[0,t],[e.shape[0],n]);case 3:return s1(e,[0,0,t],[e.shape[0],e.shape[1],n]);case 4:return Mf(e,[0,0,0,t],[e.shape[0],e.shape[1],e.shape[2],n]);default:throw new q(`sliceAlongLastAxis() received an unsupported tensor rank: ${e.rank}`)}})}function Gf(e,t,n,r){return Z(()=>{switch(e.rank){case 1:return r1(e,t,n);case 2:switch(r){case 1:return li(e,t,n);case 2:return R1(e,t,n);default:throw new q(`The axis is not within the rank of the tensor ${r}`)}case 3:switch(r){case 1:return li(e,t,n);case 2:return s1(e,[0,t,0],[e.shape[0],n,e.shape[2]]);case 3:return R1(e,t,n);default:throw new q(`The axis is not within the rank of the tensor ${r}`)}case 4:switch(r){case 1:return li(e,t,n);case 2:return Mf(e,[0,t,0,0],[e.shape[0],n,e.shape[2],e.shape[3]]);case 3:return Mf(e,[0,0,t,0],[e.shape[0],e.shape[1],n,e.shape[3]]);case 4:return R1(e,t,n);default:throw new q(`The axis is not within the rank of the tensor ${r}`)}default:throw new q(`sliceAlongLastAxis() received an unsupported tensor rank: ${e.rank}`)}})}function D1(e,t=-1){let n;return t<0&&(n=e[0].rank,n!==0?t=n:t=0),t===e[0].rank&&(t=-1),en(e,t)}function pS(e,t){switch(e.rank){case 1:return Mj([e,t]);case 2:return Pj([e,t],0);case 3:return Lj([e,t],0);case 4:return Wj([e,t],0);default:throw new q(`concatAlongFirstAxis() received an unsupported tensor rank: ${e.rank}`)}}function F1(e,t){if(Array.isArray(t)||(t=[t]),e.rank!==t.length)throw new q(`The length of input n (${t.length}) does not match the number of dimensions in input x (${e.rank})`);return Yo(e,t)}function jf(e,t=0,n=1,r,s){return PK(e,t,n,r,s)}function Fs(e,t,n,r){if(e.rank<2||t.rank<2)throw new Ge(`dot requires both inputs to be rank >= 2 but got x shape = ${e.shape} and y shape = ${t.shape}`);if(t.rank>=3){let s=e.shape.slice(-1)[0],a=t.shape.slice(-2)[0];if(s!==a)throw new Ge(`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 s=!1,a=!1;return ti.matMul({a:e,b:t,transposeA:s,transposeB:a,bias:r?M1(e.rank,r,us()):null,activation:n})}else{let s=e.shape.slice(),a=s.pop();e=e.reshape([-1,a]);let o=t.shape.slice(),i=o.pop(),l=o.pop(),u=[...o,i],c=Array.from({length:t.rank},(f,m)=>m===0?t.rank-2:m<=t.rank-2?m-1:m);t=t.transpose(c).reshape([l,-1]);let d=[...s,...u],h=!1,p=!1;return ti.matMul({a:e,b:t,transposeA:h,transposeB:p,bias:r?M1(e.rank,r,us()):null,activation:n}).reshape(d)}}function fS(e,t,n){return Z(()=>(Array.isArray(t)?t=_n(t,"int32"):t=t.toInt(),$d(e,t,n)))}function Bd(e){return K(e,e)}function M1(e,t,n){let r=t.shape;if(t.rank!==1&&t.rank!==e)throw new q(`Unexpected bias dimensions: ${t.rank}; expected it to be 1 or ${e}`);if(e===5){if(n==="channelsFirst")return r.length===1?t.reshape([1,r[0],1,1,1]):t.reshape([1,r[3],r[0],r[1],r[2]]);if(n==="channelsLast")return r.length===1?t.reshape([1,1,1,1,r[0]]):t.reshape([1].concat(r))}else if(e===4){if(n==="channelsFirst")return r.length===1?t.reshape([1,r[0],1,1]):t.reshape([1,r[2],r[0],r[1]]);if(n==="channelsLast")return r.length===1?t.reshape([1,1,1,r[0]]):t.reshape([1].concat(r))}else if(e===3){if(n==="channelsFirst")return r.length===1?t.reshape([1,r[0],1]):t.reshape([1,r[1],r[0]]);if(n==="channelsLast")return r.length===1?t.reshape([1,1,r[0]]):t.reshape([1].concat(r))}else if(e<3)return t;throw new q(`Unsupported input rank by biasAdd: ${t.rank}`)}function hs(e,t,n){return Z(()=>(n==null&&(n=us()),Yt(n),e.add(M1(e.rank,t,n))))}function mee(e,t=1){if(t!==1)throw new Ge(`Support for alpha values other than 1 (${t}) is not implemented yet.`);return Nd(e)}function gee(e){return Z(()=>Re(e,yn(e).add(1)))}function mS(e,t,n,r){return Z(()=>zX(e,t,n,r))}function yee(e){return Z(()=>{let t=pe(.5,K(.2,e));return cr(t,0,1)})}function Wd(e,t,n=!1){return n?e():t()}var Aee=["fanIn","fanOut","fanAvg"],xee=["normal","uniform","truncatedNormal"];function bee(e){oi(Aee,"FanMode",e)}function vee(e){oi(xee,"Distribution",e)}var Zr=class extends ce.Serializable{fromConfigUsesCustomObjects(){return!1}getConfig(){return{}}},O1=class extends Zr{apply(e,t){return un(e,t)}};O1.className="Zeros";ce.registerClass(O1);var qf=class extends Zr{apply(e,t){return la(e,t)}};qf.className="Ones";ce.registerClass(qf);var P1=class extends Zr{constructor(e){super();if(typeof e!="object")throw new q(`Expected argument of type ConstantConfig but got ${e}`);if(e.value===void 0)throw new q(`config must have value set but got ${e}`);this.value=e.value}apply(e,t){return Z(()=>K(Fe(this.value),la(e,t)))}getConfig(){return{value:this.value}}};P1.className="Constant";ce.registerClass(P1);var z1=class extends Zr{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 Rd(e,this.minval,this.maxval,t)}getConfig(){return{minval:this.minval,maxval:this.maxval,seed:this.seed}}};z1.className="RandomUniform";ce.registerClass(z1);var L1=class extends Zr{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 Ge(`randomNormal does not support dType ${t}.`);return jf(e,this.mean,this.stddev,t,this.seed)}getConfig(){return{mean:this.mean,stddev:this.stddev,seed:this.seed}}};L1.className="RandomNormal";ce.registerClass(L1);var B1=class extends Zr{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 Ge(`truncatedNormal does not support dType ${t}.`);return l1(e,this.mean,this.stddev,t,this.seed)}getConfig(){return{mean:this.mean,stddev:this.stddev,seed:this.seed}}};B1.className="TruncatedNormal";ce.registerClass(B1);var W1=class extends Zr{constructor(e){super();this.gain=e.gain!=null?e.gain:1}apply(e,t){return Z(()=>{if(e.length!==2||e[0]!==e[1])throw new q("Identity matrix initializer can only be used for 2D square matrices.");return K(this.gain,uI(e[0]))})}getConfig(){return{gain:this.gain}}};W1.className="Identity";ce.registerClass(W1);function wee(e,t="channelsLast"){let n,r;if(Yt(t),e.length===2)n=e[0],r=e[1];else if([3,4,5].indexOf(e.length)!==-1){if(t==="channelsFirst"){let s=ja(e,2);n=e[1]*s,r=e[0]*s}else if(t==="channelsLast"){let s=ja(e,0,e.length-2);n=e[e.length-2]*s,r=e[e.length-1]*s}}else{let s=ja(e);n=Math.sqrt(s),r=Math.sqrt(s)}return[n,r]}var Qn=class extends Zr{constructor(e){super();if(e.scale<0)throw new q(`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,bee(this.mode),this.distribution=e.distribution==null?"normal":e.distribution,vee(this.distribution),this.seed=e.seed}apply(e,t){let n=wee(e),r=n[0],s=n[1],a=this.scale;if(this.mode==="fanIn"?a/=Math.max(1,r):this.mode==="fanOut"?a/=Math.max(1,s):a/=Math.max(1,(r+s)/2),this.distribution==="normal"){let o=Math.sqrt(a);if(t=t||"float32",t!=="float32"&&t!=="int32")throw new Ge(`${this.getClassName()} does not support dType ${t}.`);return l1(e,0,o,t,this.seed)}else{let o=Math.sqrt(3*a);return Rd(e,-o,o,t)}}getConfig(){return{scale:this.scale,mode:this.mode,distribution:this.distribution,seed:this.seed}}};Qn.className="VarianceScaling";ce.registerClass(Qn);var Kf=class extends Qn{constructor(e){super({scale:1,mode:"fanAvg",distribution:"uniform",seed:e==null?null:e.seed})}getClassName(){return Qn.className}};Kf.className="GlorotUniform";ce.registerClass(Kf);var Xf=class extends Qn{constructor(e){super({scale:1,mode:"fanAvg",distribution:"normal",seed:e==null?null:e.seed})}getClassName(){return Qn.className}};Xf.className="GlorotNormal";ce.registerClass(Xf);var Zf=class extends Qn{constructor(e){super({scale:2,mode:"fanIn",distribution:"normal",seed:e==null?null:e.seed})}getClassName(){return Qn.className}};Zf.className="HeNormal";ce.registerClass(Zf);var Yf=class extends Qn{constructor(e){super({scale:2,mode:"fanIn",distribution:"uniform",seed:e==null?null:e.seed})}getClassName(){return Qn.className}};Yf.className="HeUniform";ce.registerClass(Yf);var Jf=class extends Qn{constructor(e){super({scale:1,mode:"fanIn",distribution:"normal",seed:e==null?null:e.seed})}getClassName(){return Qn.className}};Jf.className="LeCunNormal";ce.registerClass(Jf);var Qf=class extends Qn{constructor(e){super({scale:1,mode:"fanIn",distribution:"uniform",seed:e==null?null:e.seed})}getClassName(){return Qn.className}};Qf.className="LeCunNormal";ce.registerClass(Qf);var V1=class extends Zr{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 Ge("Random seed is not implemented for Orthogonal Initializer yet.")}apply(e,t){return Z(()=>{if(e.length<2)throw new Ge("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,r=jf(n,0,1,"float32"),s=uY.gramSchmidt(r);return e[0]>e[1]&&(s=s.transpose()),K(this.gain,s)})}getConfig(){return{gain:this.gain,seed:this.seed}}};V1.className="Orthogonal";ce.registerClass(V1);var gS={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 yS(e,t={}){return Md(e,ce.SerializationMap.getMap().classNameMap,t,"initializer")}function Ht(e){return I1(e)}function zt(e){if(typeof e=="string"){let t=e in gS?gS[e]:e;if(t==="GlorotNormal")return new Xf;if(t==="GlorotUniform")return new Kf;if(t==="HeNormal")return new Zf;if(t==="HeUniform")return new Yf;if(t==="LeCunNormal")return new Jf;if(t==="LeCunUniform")return new Qf;{let n={};return n.className=t,n.config={},yS(n)}}else return e instanceof Zr?e:yS(e)}function kee(){return new O1}function Iee(){return new qf}function See(e){return new P1(e)}function Tee(e){return new z1(e)}function Nee(e){return new L1(e)}function Cee(e){return new B1(e)}function Eee(e){return new W1(e)}function $ee(e){return new Qn(e)}function _ee(e){return new Kf(e)}function Ree(e){return new Xf(e)}function Dee(e){return new Zf(e)}function Fee(e){return new Yf(e)}function Mee(e){return new Jf(e)}function Oee(e){return new Qf(e)}function Pee(e){return new V1(e)}var AS={};De(AS,{Layer:()=>st,RNN:()=>fa,RNNCell:()=>Kd,activation:()=>Ane,add:()=>Nne,alphaDropout:()=>cre,average:()=>Cne,averagePooling1d:()=>u5,averagePooling2d:()=>c5,averagePooling3d:()=>d5,avgPool1d:()=>Pne,avgPool2d:()=>Lne,avgPool3d:()=>Wne,avgPooling1d:()=>zne,avgPooling2d:()=>Bne,avgPooling3d:()=>Vne,batchNormalization:()=>Fne,bidirectional:()=>nre,concatenate:()=>Ene,conv1d:()=>une,conv2d:()=>cne,conv2dTranspose:()=>dne,conv3d:()=>hne,conv3dTranspose:()=>pne,convLstm2d:()=>Jne,convLstm2dCell:()=>Qne,cropping2D:()=>mne,dense:()=>xne,depthwiseConv2d:()=>yne,dot:()=>Dne,dropout:()=>bne,elu:()=>rne,embedding:()=>Tne,flatten:()=>wne,gaussianDropout:()=>ure,gaussianNoise:()=>lre,globalAveragePooling1d:()=>Une,globalAveragePooling2d:()=>Hne,globalMaxPool1d:()=>sre,globalMaxPool2d:()=>are,globalMaxPooling1d:()=>_8,globalMaxPooling2d:()=>R8,gru:()=>jne,gruCell:()=>qne,input:()=>YS,inputLayer:()=>nne,layerNormalization:()=>Mne,leakyReLU:()=>ane,lstm:()=>Kne,lstmCell:()=>Xne,masking:()=>dre,maxPool1d:()=>ore,maxPool2d:()=>ire,maxPooling1d:()=>D8,maxPooling2d:()=>F8,maxPooling3d:()=>Gne,maximum:()=>$ne,minimum:()=>_ne,multiply:()=>Rne,permute:()=>Sne,prelu:()=>one,reLU:()=>sne,repeatVector:()=>kne,reshape:()=>Ine,rnn:()=>ere,separableConv2d:()=>fne,simpleRNN:()=>Zne,simpleRNNCell:()=>Yne,softmax:()=>ine,spatialDropout1d:()=>vne,stackedRNNCells:()=>tre,thresholdedReLU:()=>lne,timeDistributed:()=>rre,upSampling2d:()=>gne,zeroPadding2d:()=>One});var zee=0;function xS(){return zee++}var em={};function tm(e=""){return e in em||(em[e]=0),em[e]+=1,e+em[e].toString()}function U1(e){return Array.isArray(e)&&Array.isArray(e[0])}function nm(e){return e.length===0?[]:Array.isArray(e[0])?e:[e]}function Ke(e){let t;if(Array.isArray(e)){if(e.length!==1)throw new q(`Expected Tensor length to be 1; got ${e.length}`);t=e[0]}else t=e;return t}function At(e){if(Array.isArray(e)&&Array.isArray(e[0])){if(e.length===1)return e=e,e[0];throw new q(`Expected exactly 1 Shape; got ${e.length}`)}else return e}function rm(e){let t=0;for(let n of e)n.shape.length===0?t+=1:t+=n.shape.reduce((r,s)=>r*s);return t}var bS="Variable",vS=class{constructor(e,t="float32",n=bS,r=!0,s=null){this.dtype=t==null?"float32":t,this.shape=e.shape,this.id=xS(),n=n==null?bS:n,this.originalName=cS(n),this.name=dS(this.originalName),this.trainable_=r,this.constraint=s,this.val=SX(e,this.trainable_,this.name,this.dtype)}read(){return this.assertNotDisposed(),this.val}write(e){return this.assertNotDisposed(),Lee(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 Lee(e,t){if(e.shape.toString()!==t.shape.toString())throw new Error("Shape mismatch: "+JSON.stringify(e.shape)+" vs. "+JSON.stringify(t.shape))}function H1(e){return e.map(t=>t.read())}function G1(e){e.forEach(t=>{t[0].write(t[1])})}var tn=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||{}}},ps=class{constructor(e,t,n,r,s,a,o){this.dtype=e,this.shape=t,this.sourceLayer=n,this.inputs=r,this.callArgs=s,this.outputTensorIndex=o,this.id=xS(),a!=null&&(this.originalName=cS(a),this.name=dS(this.originalName)),this.rank=t.length}},Bee=0,sm=class{constructor(e,t){this.callArgs=t,this.id=Bee++,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}}},Wee=0,st=class extends ce.Serializable{constructor(e={}){super();this._callHook=null,this._addedWeightNames=[],this._stateful=!1,this.id=Wee++,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=ha(n)+"_"+tm(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 s=null;e.batchSize!=null&&(s=e.batchSize),n=[s].concat(e.inputShape)}this.batchInputShape=n;let r=e.dtype;r==null&&(r=e.inputDType),r==null&&(r="float32"),this.dtype=r}e.weights!=null?this.initialWeights=e.weights:this.initialWeights=null,this._refCount=null,this.fastWeightInitDuringBuild=!1}static nodeKey(e,t){return e.name+"_ib-"+t.toString()}getNodeAtIndex(e,t){if(this.inboundNodes.length===0)throw new cs(`The layer has never been called and thus has no defined ${t}.`);if(this.inboundNodes.length<=e)throw new q(`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 da(`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 da(`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 da(`Layer ${this.name} has no inbound nodes.`);if(this.inboundNodes.length>1)throw new da(`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=Dt(e),this.inputSpec==null||this.inputSpec.length===0)return;let t=Dt(this.inputSpec);if(e.length!==t.length)throw new q(`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 r=e[n],s=t[n];if(s==null)continue;let a=r.rank;if(s.ndim!=null&&a!==s.ndim)throw new q(`Input ${n} is incompatible with layer ${this.name}: expected ndim=${s.ndim}, found ndim=${a}`);if(s.maxNDim!=null&&a>s.maxNDim)throw new q(`Input ${n} is incompatible with layer ${this.name}: expected max_ndim=${s.maxNDim}, found ndim=${a}`);if(s.minNDim!=null&&a<s.minNDim)throw new q(`Input ${n} is incompatible with layer ${this.name}: expected min_ndim=${s.minNDim}, found ndim=${a}.`);if(s.dtype!=null&&r.dtype!==s.dtype)throw new q(`Input ${n} is incompatible with layer ${this.name} : expected dtype=${s.dtype}, found dtype=${r.dtype}.`);if(s.axes){let o=r.shape;for(let i in s.axes){let l=Number(i),u=s.axes[i],c=l>=0?o[l]:o[o.length+l];if(u!=null&&[u,null].indexOf(c)===-1)throw new q(`Input ${n} is incompatible with layer ${this.name}: expected axis ${l} of input shape to have value ${u} but got shape ${o}.`)}}if(s.shape!=null)for(let o=0;o<s.shape.length;++o){let i=s.shape[o],l=r.shape[o];if(i!=null&&l!=null&&i!==l)throw new q(`Input ${n} is incompatible with layer ${this.name}: expected shape=${s.shape}, found shape=${r.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=Dt(e),r=!0;for(let a of n)if(!(a instanceof ps)){r=!1;break}let s=!0;for(let a of n)if(a instanceof ps){s=!1;break}if(r===s)throw new q("Arguments to apply() must be all SymbolicTensors or all Tensors");return ii(this.name,()=>{if(!this.built){this.assertInputCompatibility(e);let a=[];for(let o of Dt(e))a.push(o.shape);this.build(Jn(a)),this.built=!0,this.initialWeights&&this.setWeights(this.initialWeights),this._refCount===null&&s&&(this._refCount=1)}if(this.assertInputCompatibility(e),s){let a=this.call(e,t),o=Dt(a),i=[];for(let l of o)n.indexOf(l)!==-1&&(l=l.clone()),i.push(l);if(a=Jn(i),this.activityRegularizer!=null)throw new Ge("Layer invocation in the presence of activity regularizer(s) is not supported yet.");return a}else{let a=Vee(e),o=this.computeOutputShape(a),i,l=Uee(e);if(this.warnOnIncompatibleInputShape(Array.isArray(e)?a[0]:a),o!=null&&o.length>0&&Array.isArray(o[0])?i=o.map((u,c)=>new ps(l,u,this,Dt(e),t,this.name,c)):i=new ps(l,o,this,Dt(e),t,this.name),this.addInboundNode(e,i,null,null,a,o,t),this._refCount++,this.activityRegularizer!=null)throw new Ge("Layer invocation in the presence of activity regularizer(s) is not supported yet.");return i}})}warnOnIncompatibleInputShape(e){if(this.batchInputShape!=null)if(e.length!==this.batchInputShape.length)console.warn(`The rank of the input tensor provided (shape: ${JSON.stringify(e)}) does not match that of the batchInputShape (${JSON.stringify(this.batchInputShape)}) of the layer ${this.name}`);else{let t=!1;this.batchInputShape.forEach((n,r)=>{n!=null&&e[r]!=null&&e[r]!==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 da(`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 da(`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 cs(`You tried to call countParams() on ${this.name}, but the layer is not built yet. Build it first by calling build(batchInputShape).`);return rm(this.weights)}build(e){this.built=!0}getWeights(e=!1){return H1(e?this.trainableWeights:this.weights)}setWeights(e){Z(()=>{let t=this.weights;if(t.length!==e.length)throw new q(`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=[],r=H1(t);for(let s=0;s<r.length;++s){let a=r[s],o=t[s],i=e[s];if(!k.arraysEqual(a.shape,i.shape))throw new q(`Layer weight shape ${a.shape} not compatible with provided weight shape ${i.shape}`);n.push([o,i])}G1(n)})}addWeight(e,t,n,r,s,a,o){if(this._addedWeightNames.indexOf(e)!==-1)throw new q(`Duplicate weight name ${e} for layer ${this.name}`);this._addedWeightNames.push(e),n==null&&(n="float32"),this.fastWeightInitDuringBuild&&(r=zt("zeros"));let i=r.apply(t,n),l=new vS(i,n,e,a,o);return i.dispose(),s!=null&&this.addLoss(()=>s.apply(l.read())),a==null&&(a=!0),a?this._trainableWeights.push(l):this._nonTrainableWeights.push(l),l}setFastWeightInitDuringBuild(e){this.fastWeightInitDuringBuild=e}addLoss(e){e==null||Array.isArray(e)&&e.length===0||(e=Dt(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,r,s,a,o=null){let i=Dt(e);t=Dt(t),n=Dt(n),r=Dt(r),s=nm(s),a=nm(a);let l=[],u=[],c=[];for(let d of i)l.push(d.sourceLayer),u.push(d.nodeIndex),c.push(d.tensorIndex);new sm({outboundLayer:this,inboundLayers:l,nodeIndices:u,tensorIndices:c,inputTensors:i,outputTensors:t,inputMasks:n,outputMasks:r,inputShapes:s,outputShapes:a},o);for(let d=0;d<t.length;d++)t[d].sourceLayer=this,t[d].nodeIndex=this.inboundNodes.length-1,t[d].tensorIndex=d}getConfig(){let e={name:this.name,trainable:this.trainable};return this.batchInputShape!=null&&(e.batchInputShape=this.batchInputShape),this.dtype!=null&&(e.dtype=this.dtype),e}disposeWeights(){return this.weights.forEach(e=>e.dispose()),this.weights.length}assertNotDisposed(){if(this._refCount===0)throw new Error(`Layer '${this.name}' is already disposed.`)}dispose(){if(!this.built)throw new Error(`Cannot dispose Layer ${this.name} because it has not been built yet.`);if(this._refCount===null)throw new Error(`Cannot dispose Layer ${this.name} because it has not been used yet.`);this.assertNotDisposed();let e=0;return--this._refCount==0&&(e=this.disposeWeights()),{refCountAfterDispose:this._refCount,numDisposedVariables:e}}};function Vee(e){e=Dt(e);let t=[];for(let n of e)t.push(n.shape);return Jn(t)}function Uee(e){return"float32"}function wS(e,t,n){if((t==null||n!=null&&n>0)&&(t=e.sourceLayer,n=e.nodeIndex),t.inboundNodes.length===0)return[e];{let r=t.inboundNodes[n];if(r.inboundLayers.length===0)return r.inputTensors;{let s=[];for(let a=0;a<r.inboundLayers.length;a++){let o=r.inputTensors[a],i=r.inboundLayers[a],l=r.nodeIndices[a],u=wS(o,i,l);for(let c of u)s.indexOf(c)===-1&&s.push(c)}return s}}}var su=class extends st{constructor(e){super({dtype:e.dtype,name:e.name!=null?e.name:tm("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 q("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 q("An InputLayer should be passed either a `batchInputShape` or an `inputShape`.");t=[e.batchSize].concat(e.inputShape)}else if(e.batchSize!=null)throw new q("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 r=new ps(this.dtype,this.batchInputShape,this,[],{},this.name);r.nodeIndex=0,r.tensorIndex=0,new sm({outboundLayer:this,inboundLayers:[],nodeIndices:[],tensorIndices:[],inputTensors:[r],outputTensors:[r],inputMasks:[null],outputMasks:[null],inputShapes:[t],outputShapes:[t]})}apply(e,t){throw new q(`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}}};su.className="InputLayer";ce.registerClass(su);function kS(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 q("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 su({batchInputShape:t,name:e.name,dtype:n,sparse:e.sparse}).inboundNodes[0].outputTensors[0]}async function Ka(e){if(e==null)return;let t=[],n=[],r=[];for(let s in e){let a=e[s];if(typeof a!="number"){let o=a;t.push(o.data()),n.push(s),r.push(o)}}if(t.length>0){let s=await Promise.all(t);for(let a=0;a<s.length;++a)e[n[a]]=s[a][0];je(r)}}function IS(e){if(e!=null)for(let t in e){let n=e[t];typeof n!="number"&&n.dispose()}}var SS;(function(e){e[e.SILENT=0]="SILENT",e[e.VERBOSE=1]="VERBOSE"})(SS||(SS={}));var Hee=125,au=class{constructor(){this.validationData=null}setParams(e){this.params=e}async onEpochBegin(e,t){}async onEpochEnd(e,t){}async onBatchBegin(e,t){}async onBatchEnd(e,t){}async onTrainBegin(e){}async onTrainEnd(e){}setModel(e){}},TS=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)}},Gee=class extends au{constructor(){super()}async onEpochBegin(e){this.seen=0,this.totals={}}async onBatchEnd(e,t){t==null&&(t={});let n=t.size==null?0:t.size;this.seen+=n;for(let r in t){let s=t[r];if(typeof s=="number")this.totals.hasOwnProperty(r)||(this.totals[r]=0),this.totals[r]=this.totals[r]+s*n;else{let a;r in this.totals?a=this.totals[r]:this.totals[r]=0;let o=Z(()=>pe(this.totals[r],K(s,n)));this.totals[r]=o,a!=null&&a.dispose()}}}async onEpochEnd(e,t){if(t!=null)for(let n of this.params.metrics)this.totals[n]!=null&&(typeof this.totals[n]=="number"?t[n]=this.totals[n]/this.seen:Z(()=>{let r=K(Re(1,this.seen),this.totals[n]);t[n]=r,this.totals[n].dispose(),Sn(t[n])}))}},NS=class extends au{async onTrainBegin(e){this.epoch=[],this.history={}}async onEpochEnd(e,t){t==null&&(t={}),this.epoch.push(e);for(let n in t)this.history[n]==null&&(this.history[n]=[]),this.history[n].push(t[n])}async syncData(){let e=[],t=[],n=[];for(let s in this.history){let a=this.history[s];for(let o=0;o<a.length;++o)if(typeof a[o]!="number"){let i=a[o];e.push(i.data()),t.push(s),n.push(o)}}let r=await Promise.all(e);for(let s=0;s<r.length;++s)this.history[t[s]][n[s]].dispose(),this.history[t[s]][n[s]]=r[s][0]}},CS=class extends au{constructor(e,t){super();if(this.currentEpoch=0,this.yieldEvery=t||"auto",this.yieldEvery==="auto"&&(this.yieldEvery=Hee),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");k.isNumber(this.yieldEvery)&&(this.maybeWait=JQ(this.maybeWait.bind(this),this.yieldEvery)),this.trainBegin=e.onTrainBegin,this.trainEnd=e.onTrainEnd,this.epochBegin=e.onEpochBegin,this.epochEnd=e.onEpochEnd,this.batchBegin=e.onBatchBegin,this.batchEnd=e.onBatchEnd,this.yield=e.onYield}async maybeWait(e,t,n){let r=[];this.yield!=null&&(await Ka(n),r.push(this.yield(e,t,n))),r.push(b1()),await Promise.all(r)}async onEpochBegin(e,t){this.currentEpoch=e,this.epochBegin!=null&&(await Ka(t),await this.epochBegin(e,t))}async onEpochEnd(e,t){let n=[];this.epochEnd!=null&&(await Ka(t),n.push(this.epochEnd(e,t))),this.yieldEvery==="epoch"&&n.push(b1()),await Promise.all(n)}async onBatchBegin(e,t){this.batchBegin!=null&&(await Ka(t),await this.batchBegin(e,t))}async onBatchEnd(e,t){let n=[];this.batchEnd!=null&&(await Ka(t),n.push(this.batchEnd(e,t))),this.yieldEvery==="batch"?n.push(b1()):k.isNumber(this.yieldEvery)&&n.push(this.maybeWait(this.currentEpoch,e,t)),await Promise.all(n)}async onTrainBegin(e){this.trainBegin!=null&&(await Ka(e),await this.trainBegin(e))}async onTrainEnd(e){this.trainEnd!=null&&(await Ka(e),await this.trainEnd(e))}};function ES(e,t){return e==null&&(e={}),e instanceof au?[e]:Array.isArray(e)&&e[0]instanceof au?e:Dt(e).map(r=>new CS(r,t))}var Ms=class{constructor(){}static registerCallbackConstructor(e,t){k.assert(e>=0&&Number.isInteger(e),()=>`Verbosity level is expected to be an integer >= 0, but got ${e}`),Ms.checkForDuplicate(t),Ms.constructors[e]==null&&(Ms.constructors[e]=[]),Ms.constructors[e].push(t)}static checkForDuplicate(e){for(let t in Ms.constructors)Ms.constructors[+t].forEach(r=>{if(r===e)throw new q("Duplicate callback constructor.")})}static clear(){Ms.constructors={}}static createCallbacks(e){let t=[];for(let n in Ms.constructors){let r=+n;e>=r&&t.push(...Ms.constructors[r])}return t.map(n=>new n)}},j1=Ms;j1.constructors={};function $S(e,t,n,r,s,a,o,i,l){let u=new NS,c=[new Gee,...j1.createCallbacks(t)];e!=null&&c.push(...e),c.push(u);let d=new TS(c);return d.setParams({epochs:n,initialEpoch:r,samples:s,steps:a,batchSize:o,verbose:t,doValidation:i,metrics:l}),{callbackList:d,history:u}}function fs(e,t={},n=!1){return Md(e,ce.SerializationMap.getMap().classNameMap,t,"layer",n)}function am(e,t){return Z(()=>{e.dtype!=="float32"&&(e=e.asType("float32"));let n=_e(Bd(e),t,!0),r=Cd(n.shape,cn()),s=$n(ia(n,r));return Re(e,s)})}function ui(e,t){return Z(()=>Xt(Bd(Ne(t,e)),-1))}function om(e,t){return Z(()=>Xt(yn(Ne(t,e)),-1))}function ou(e,t){return Z(()=>{let n=Ne(e,t),r=cr(yn(e),cn(),Number.MAX_VALUE),s=yn(Re(n,r));return K(100,Xt(s,-1))})}function jee(e,t){return Z(()=>{let n=cr(t,cn(),Number.MAX_VALUE),r=Rr(pe(1,n)),s=cr(e,cn(),Number.MAX_VALUE),a=Rr(pe(1,s));return Xt(Bd(Ne(r,a)),-1)})}function qee(e,t){return Z(()=>{let n=ia(0,Ne(1,K(e,t)));return Xt(Bd(n),-1)})}function Kee(e,t){return Z(()=>{let n=ia(0,Ne(1,K(e,t)));return Xt(n,-1)})}function Xee(e,t){return Z(()=>{let n=_e(K(e,t),-1),r=os(K(Ne(1,e),t),-1);return ia(0,pe(1,Ne(r,n)))})}function Zee(e,t){return Z(()=>{let n=Math.log(2),r=Ne(t,e),s=Ne(pe(r,Zl(K(-2,r))),n);return Xt(s,-1)})}function Vd(e,t,n=!1){return Z(()=>{if(n)t=Of(t);else{let r=_e(t,t.shape.length-1,!0);t=Re(t,r)}return t=cr(t,cn(),1-cn()),Kt(_e(K(e.toFloat(),Rr(t)),t.shape.length-1))})}function im(e,t,n=!1){return Z(()=>{let r=Ed(pee(e)).toInt();t=cr(t,cn(),1-cn());let s=t.shape,a=kd(r,s[s.length-1]).reshape(s);return Vd(a,t,n)})}function Yee(e,t){if(!k.arraysEqual(e.shape,t.shape))throw new q(`logits and labels must have the same shape, but got shapes ${JSON.stringify(e.shape)} and ${JSON.stringify(t.shape)}`);return Z(()=>{let n=t.relu(),r=t.abs().neg();return n.sub(t.mul(e)).add(r.exp().log1p())})}function lm(e,t){return Z(()=>{let n;return n=cr(t,cn(),1-cn()),n=Rr(Re(n,Ne(1,n))),Xt(Yee(e,n),-1)})}function Jee(e,t){return Z(()=>{let n=cr(e,cn(),1),r=cr(t,cn(),1);return _e(K(e,Rr(Re(n,r))),-1)})}function Qee(e,t){return Z(()=>{let n=Rr(pe(cn(),t));return Xt(Ne(t,K(e,n)),-1)})}function q1(e,t){return Z(()=>{let n=am(e,-1),r=am(t,-1),s=K(n,r);return Kt(_e(s,-1))})}var um={meanSquaredError:ui,meanAbsoluteError:om,meanAbsolutePercentageError:ou,meanSquaredLogarithmicError:jee,squaredHinge:qee,hinge:Kee,categoricalHinge:Xee,logcosh:Zee,categoricalCrossentropy:Vd,sparseCategoricalCrossentropy:im,binaryCrossentropy:lm,kullbackLeiblerDivergence:Jee,poisson:Qee,cosineProximity:q1};function K1(e){if(typeof e=="string"){if(e in um)return um[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 q(t)}else return e}function X1(e,t){return Z(()=>{let n=K(.5,Dr(t)),r=zd(_r(t,n),e.dtype);return Xt(Zo(e,r),-1)})}function Z1(e,t){return Z(()=>zd(Zo(kf(e,-1),kf(t,-1)),"float32"))}function _S(e,t){return Z(()=>is(e.equal(1),t.equal(1)).sum().cast("float32"))}function ete(e,t){return Z(()=>is(e.equal(1),t.equal(0)).sum().cast("float32"))}function tte(e,t){return Z(()=>is(e.equal(0),t.equal(1)).sum().cast("float32"))}function RS(e,t){return Z(()=>{let n=_S(e,t),r=tte(e,t),s=n.add(r);return Ln(_r(s,0),n.div(s),0).cast("float32")})}function nte(e,t){return Z(()=>{let n=_S(e,t),r=ete(e,t),s=n.add(r);return Ln(_r(s,0),n.div(s),0).cast("float32")})}function DS(e,t){return lm(e,t)}function FS(e,t){return e.rank===t.rank&&(e=e.squeeze([e.rank-1])),t=t.argMax(-1),t.dtype!==e.dtype&&(t=t.asType(e.dtype)),Zo(e,t).asType("float32")}var rte=ui,ste=ui,ate=om,ote=om,ite=ou,lte=ou,Y1=Vd,ute=q1,MS=im,cm={binaryAccuracy:X1,categoricalAccuracy:Z1,precision:RS,categoricalCrossentropy:Y1,sparseCategoricalCrossentropy:MS,mse:rte,MSE:ste,mae:ate,MAE:ote,mape:ite,MAPE:lte,cosine:ute};function cte(e){if(typeof e=="string"&&e in cm)return cm[e];if(typeof e!="string"&&e!=null)return e;throw new q(`Unknown metric ${e}`)}function dm(e){if(Ds(e!==null,`Unknown LossOrMetricFn ${e}`),typeof e=="string")return e;{let t;for(let n of Object.keys(um))if(um[n]===e){t=n;break}if(t!==void 0)return t;for(let n of Object.keys(cm))if(cm[n]===e){t=n;break}return t!==void 0?t:e.name}}function dte(e){let t={Adagrad:()=>tu.adagrad(.01),Adadelta:()=>tu.adadelta(1,.95,cn()),Adam:()=>tu.adam(.001,.9,.999,cn()),Adamax:()=>tu.adamax(.002,.9,.999,cn(),0),RMSProp:()=>tu.rmsprop(.001,.9,0,cn()),SGD:()=>tu.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 q(`Unknown Optimizer ${e}`)}var OS=1*1024*1024;function PS(e,t,n=!1){if(e==null||typeof e!="object"||Object.getPrototypeOf(e)!==Object.prototype||!J1(e))throw new Error("User-defined metadata is expected to be a JSON object, but is not.");if(n){let r=JSON.stringify(e);r.length>OS&&console.warn(`User-defined metadata of model "${t}" is too large in size (length=${r.length} when serialized). It is not recommended to store such large objects in user-defined metadata. Please make sure its serialized length is <= ${OS}.`)}}function J1(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"||!J1(e[n]))return!1;return!0}else if(Array.isArray(e)){for(let t of e)if(!J1(t))return!1;return!0}else return!1;else{let t=typeof e;return t==="string"||t==="number"||t==="boolean"}}function hte(e,t,n,r=console.log){let s=fte(e),a=["Layer (type)","Output shape","Param #"];s?(t=t||65,n=n||[.45,.85,1]):(t=t||98,n=n||[.33,.55,.67,1]),n[n.length-1]<=1&&(n=n.map(c=>Math.floor(t*c)));let o;if(!s){a.push("Receives inputs"),o=[];for(let c in e.nodesByDepth)o.push(...e.nodesByDepth[c])}r("_".repeat(t)),hm(a,n,r),r("=".repeat(t));let i=e.layers;for(let c=0;c<i.length;++c)s?mte(i[c],n,r):gte(i[c],n,o,r),r((c===i.length-1?"=":"_").repeat(t));e.checkTrainableWeightsConsistency();let l=pte(e),u=rm(e.nonTrainableWeights);r(`Total params: ${l+u}`),r(`Trainable params: ${l}`),r(`Non-trainable params: ${u}`),r("_".repeat(t))}function pte(e){let t;return e.collectedTrainableWeights!=null?t=rm(e.collectedTrainableWeights):t=rm(e.trainableWeights),t}function fte(e){let t=!0,n=[],r=[];for(let s in e.nodesByDepth)n.push(e.nodesByDepth[s]);for(let s of n){if(s.length>1||s.length===1&&s[0].inboundLayers.length>1){t=!1;break}r.push(...s)}if(t)for(let s of e.layers){let a=!1;for(let o of s.inboundNodes)if(r.indexOf(o)!==-1)if(a){t=!1;break}else a=!0;if(!t)break}return t}function hm(e,t,n=console.log){let r="";for(let s=0;s<e.length;++s)s>0&&(r=r.slice(0,r.length-1)+" "),r+=e[s],r=r.slice(0,t[s]),r+=" ".repeat(t[s]-r.length);n(r)}function mte(e,t,n){let r;try{r=JSON.stringify(e.outputShape)}catch(i){r="multiple"}let s=e.name,a=e.getClassName(),o=[`${s} (${a})`,r,e.countParams().toString()];hm(o,t,n)}function gte(e,t,n,r){let s;try{s=JSON.stringify(e.outputShape)}catch(c){s="multiple"}let a=[];for(let c of e.inboundNodes)if(!(n!=null&&n.length>0&&n.indexOf(c)===-1))for(let d=0;d<c.inboundLayers.length;++d){let h=c.inboundLayers[d].name,p=c.nodeIndices[d],f=c.tensorIndices[d];a.push(`${h}[${p}][${f}]`)}let o=e.name,i=e.getClassName(),l=a.length===0?"":a[0],u=[`${o} (${i})`,s,e.countParams().toString(),l];hm(u,t,r);for(let c=1;c<a.length;++c)hm(["","","",a[c]],t,r)}function zS(e,t,n){return(e==="inboundNodes"||e==="outputLayers"||e==="inputLayers")&&t===0&&typeof n=="string"}function Ud(e,t){if(e===null)return null;if(typeof e=="string")return ai(e);if(typeof e=="number"||typeof e=="boolean")return e;if(e instanceof Array){let n=[],r=e.length;for(let s=0;s<r;++s){let a=e[s];zS(t,s,a)?n.push(a):n.push(Ud(a,t))}return n}else{let n={};for(let r of Object.keys(e)){let s=e[r];if(r==="name"&&typeof s=="string")n[r]=s;else{let a=ai(r);n[a]=Ud(s,a)}}return n}}function Q1(e,t){if(e==null)return null;if(typeof e=="string")return ha(e);if(typeof e=="number"||typeof e=="boolean")return e;if(e instanceof Array){let n=[],r=e.length;for(let s=0;s<r;++s){let a=e[s];zS(t,s,a)?n.push(a):n.push(Q1(a,t))}return n}else{let n={};for(let r of Object.keys(e)){let s=e[r],a=ha(r);(r==="name"||r==="className")&&typeof s=="string"?n[a]=s:n[a]=Q1(s,r)}return n}}var ex="3.7.0";function yte(e,t){if(e.dtype==null||e.dtype===t.dtype)return t;try{return ke(t,e.dtype)}catch(n){throw new q(`The dtype of the feed (${t.dtype}) can not be cast to the dtype of the key '${e.name}' (${e.dtype}).`)}}var ci=class{constructor(e){if(this.id2Value={},this.id2Mask={},this.name2Id={},e instanceof ci)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]=yte(e,t),this.name2Id[e.name]=e.id,n!=null&&(this.id2Mask[e.id]=n);else throw new q(`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 ps){if(this.id2Value[e.id]==null)throw new q(`Nonexistent key: ${e.name}`);return this.id2Value[e.id]}else{let t=this.name2Id[e];if(t==null)throw new q(`Feed dict has no SymbolicTensor name: ${e}`);return this.id2Value[t]}}getMask(e){if(e instanceof ps){if(this.id2Value[e.id]==null)throw new q(`Nonexistent key: ${e.name}`);return this.id2Mask[e.id]}else{let t=this.name2Id[e];if(t==null)throw new q(`Feed dict has no SymbolicTensor name: ${e}`);return this.id2Mask[t]}}disposeMasks(){this.id2Mask!=null&&je(this.id2Mask)}},tx={},LS={};function Hd(e,t,n,r){let s=n==null?!1:n.training,a=Array.isArray(e),o=a?e:[e],i=o.map(f=>f.name),l=[],u=t.names();for(let f of i)u.indexOf(f)!==-1?l.push(t.getValue(f)):l.push(null);r!=null&&(r.maxNumTensors=-Infinity,r.minNumTensors=Infinity);let c=i.join(",")+"|"+t.names().join(","),d,h;if(tx[c]==null){let f=Ate(o,t);d=f.sorted,h=f.recipientCounts,tx[c]=d,LS[c]=h}d=tx[c],h={},s||Object.assign(h,LS[c]);let p=new ci(t);for(let f=0;f<d.length;++f){if(r!=null){let C=EA().numTensors;C>r.maxNumTensors&&(r.maxNumTensors=C),C<r.minNumTensors&&(r.minNumTensors=C)}let m=d[f],g=m.sourceLayer;if(g instanceof su)continue;let y=[],A=[],x=[],b=!1;for(let C of m.inputs){let M=p.getValue(C),$=p.getMask(C);y.push(M),A.push($),$!=null&&(b=!0),s||(h[C.name]--,h[C.name]===0&&!t.hasKey(C)&&i.indexOf(C.name)===-1&&!M.isDisposed&&C.sourceLayer.stateful!==!0&&x.push(M))}b&&(n=n||{},n.mask=A[0]);let v=Dt(g.apply(y,n)),w=null;g.supportsMasking&&(w=g.computeMask(y,A));let I=bte(m),T=Array.isArray(I)?I:[I];for(let C=0;C<T.length;++C){p.hasKey(T[C])||p.add(T[C],v[C],Array.isArray(w)?w[0]:w);let M=i.indexOf(T[C].name);M!==-1&&(l[M]=v[C])}s||je(x)}return p.disposeMasks(),a?l:l[0]}function Ate(e,t){k.assert(e!=null&&e.length>0,()=>"Expected at least one fetch, got none");let n=[],r={};if(e.length===1){let s=BS(e[0],t);n=s.sorted,r=s.recipientMap}else{let s=new Set;for(let a of e){let{sorted:o,recipientMap:i}=BS(a,t);for(let l of o)s.has(l.name)||(n.push(l),s.add(l.name));for(let l in i)r[l]==null&&(r[l]=new Set),i[l].forEach(u=>r[l].add(u))}}return{sorted:n,recipientCounts:xte(r)}}function xte(e){let t={};for(let n in e)t[n]=e[n].size;return t}function BS(e,t){let n=new Set,r=[],s={};for(let i of t.names())n.add(i);let a=[],o=[];for(a.push(e);a.length>0;){let i=a[a.length-1];if(n.has(i.name)){a.pop();continue}let l=o[o.length-1]===a.length-1;if(i.inputs.length===0||l)a.pop(),r.push(i),n.add(i.name),l&&o.pop();else{o.push(a.length-1);for(let u of i.inputs)s[u.name]==null&&(s[u.name]=new Set),s[u.name].add(i.name),!n.has(u.name)&&a.push(u)}}return{sorted:r,recipientMap:s}}function bte(e){let t;if(e.sourceLayer.inboundNodes.length===1)t=e.sourceLayer.output;else{let n=null;for(let r=0;r<e.sourceLayer.inboundNodes.length;++r)for(let s of e.sourceLayer.inboundNodes[r].outputTensors)if(s.id===e.id){n=r;break}t=e.sourceLayer.getOutputAt(n)}return t}var Os=class extends st{constructor(e){super({});if(this.containerNodes=new Set,this.name=e.name,this.name==null){let y=this.getClassName().toLowerCase();this.name=tm(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],Ga(this.inputs).length!==this.inputs.length)throw new q(`The list of inputs passed to the model is redundant. All inputs should only appear once. Found: ${this.inputs.map(y=>y.name)}`);Ga(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;Ds(x===0,"input layer has >1 nodes"),Ds(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 su))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={},r={},s={},a={},o=[],i=(y,A,x,b,v,w)=>{(b==null||v==null||w==null)&&(b=y.sourceLayer,v=y.nodeIndex,w=y.tensorIndex);let I=b.inboundNodes[v];if(x.indexOf(I)!==-1)throw new cs(`The tensor ${y.name} at layer "${b.name}" is part of a cycle.`);if(A.indexOf(I)!==-1)return;this.containerNodes.add(Os.nodeKey(b,v)),b.id in a||(a[b.id]=Object.keys(a).length),x.indexOf(I)===-1&&x.push(I);let T=I.inboundLayers.length;for(let C=0;C<T;C++){let M=I.inputTensors[C],$=I.inboundLayers[C],R=I.nodeIndices[C],N=I.tensorIndices[C];i(M,A,x,$,R,N)}for(A.push(I);x.indexOf(I)>=0;)x.splice(x.indexOf(I),1);o.push(I)},l=[],u=[];for(let y of this.outputs)i(y,l,u);let c=o.slice().reverse();for(let y of c){n[y.id]=y,y.id in t||(t[y.id]=0);let A=t[y.id],x=r[y.outboundLayer.id]==null?0:r[y.outboundLayer.id];A=Math.max(A,x),r[y.outboundLayer.id]=A,s[y.outboundLayer.id]=y.outboundLayer,t[y.id]=A;for(let b=0;b<y.inboundLayers.length;b++){let v=y.inboundLayers[b],w=y.nodeIndices[b],I=v.inboundNodes[w],T=t[I.id]==null?0:t[I.id];t[I.id]=Math.max(A+1,T),n[I.id]=I}}let d={};for(let y in t){let A=t[y];A in d||(d[A]=[]),d[A].push(n[y])}let h={};for(let y in r){let A=r[y];A in h||(h[A]=[]),h[A].push(s[y])}let p=Object.keys(h).map(y=>parseInt(y,10)).sort(Hf);this.layers=[];for(let y of p){let A=h[y];A.sort((x,b)=>{let v=a[x.id],w=a[b.id];return v<w?-1:v>w?1:0});for(let x of A)x instanceof Os&&this.internalContainerRefs.push(x),this.layers.push(x)}this.layersByDepth=h,p=Object.keys(d).map(y=>parseInt(y,10)).sort(Hf);let f=this.inputs.slice(),m=[];for(let y of p)for(let A of d[y]){let x=A.outboundLayer;if(x!=null){for(let b of A.inputTensors)if(f.indexOf(b)===-1)throw new cs(`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=d;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 cs(`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 sm({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 q("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={},r=0;for(let a of this.layers)for(let o of a.weights){if(n[o.originalName]!=null)throw new q(`Duplicate weight name: ${o.originalName}`);n[o.originalName]=o,r++}let s=[];for(let a in e){let o=a;if(n[a]==null){let i=a.split("/");o=i.slice(0,-2).concat([i[i.length-1]]).join("/")}if(n[o]!=null)s.push([n[o],e[a]]);else if(t)throw new q(`Provided weight data has no target variable: ${a}`);delete n[o]}if(t){let a=[];for(let o in n)a.push(o);if(a.length>0)throw new q(`${a.length} of ${r} weights are not set: ${a}`)}G1(s)}updatedConfig(){let e=this.getConfig(),t={};return t.className=this.getClassName(),t.config=e,t.kerasVersion=`tfjs-layers ${ex}`,t.backend="TensorFlow.js",t}toJSON(e,t=!0){let n=Q1(this.updatedConfig());return t?JSON.stringify(n):n}call(e,t){return Z(()=>{e=Dt(e);let n=new ci;for(let r=0;r<this.inputs.length;++r)n.add(this.inputs[r],e[r]);return Hd(this.outputs,n,t)})}computeMask(e,t){return Z(()=>{e=Dt(e);let n;return t==null?n=si(null,e.length):n=Dt(t),this.runInternalGraph(e,n)[1]})}computeOutputShape(e){let t=nm(e);if(t.length!==this.inputLayers.length)throw new q(`Invalid inputShape argument ${e}: model has ${this.inputLayers.length} tensor inputs.`);let n={};for(let o=0;o<t.length;o++){let i=this.inputLayers[o],l=t[o],u=i.name+"_0_0";n[u]=l}let r=Object.keys(this.nodesByDepth).map(o=>parseInt(o,10)).sort(Hf);if(r.length>1)for(let o of r){let i=this.nodesByDepth[o];for(let l of i){let u=l.outboundLayer;if(this.inputLayers.map(f=>f.id).indexOf(u.id)!==-1)continue;let c=[];for(let f=0;f<l.inboundLayers.length;f++){let m=l.inboundLayers[f],g=l.nodeIndices[f],y=l.tensorIndices[f],A=`${m.name}_${g}_${y}`,x=n[A];c.push(x)}let d=u.computeOutputShape(Jn(c)),h=nm(d),p=u.inboundNodes.indexOf(l);for(let f=0;f<h.length;f++){let m=`${u.name}_${p}_${f}`;n[m]=h[f]}}}let s=[],a=[];for(let o=0;o<this.outputLayers.length;o++){let i=this.outputLayers[o],l=this.outputLayersNodeIndices[o],u=this.outputLayersTensorIndices[o],c=`${i.name}_${l}_${u}`;a.push(c)}for(let o=0;o<a.length;o++){let i=a[o];Ds(i in n),s.push(n[i])}return Jn(s)}runInternalGraph(e,t){t==null&&(t=si(null,e.length));let n={};for(let i=0;i<this.inputs.length;++i){let l=this.inputs[i],u=e[i],c=t[i];n[l.id]=[u,c]}let r=Object.keys(this.nodesByDepth).map(i=>parseInt(i,10)).sort(Hf);for(let i of r){let l=this.nodesByDepth[i];for(let u of l){let c=u.outboundLayer,d=u.inputTensors,h=u.outputTensors,p=new Array;for(let f of d)f.id in n&&p.push(n[f.id]);if(p.length===d.length){let f={},m,g,y,A;if(u.callArgs!=null&&(f=u.callArgs),p.length===1){let[x,b]=p[0];f.mask==null&&(f.mask=b),y=Dt(c.call(x,f)),A=Dt(c.computeMask(x,b)),m=[x],g=[b]}else m=p.map(x=>x[0]),g=p.map(x=>x[1]),f.mask==null&&(f.mask=g),y=Dt(c.call(m,f)),A=Dt(c.computeMask(m,g));if(c.activityRegularizer)throw new Ge("LayersModel invocation with concrete Tensor value(s) in the presence of activity regularizer(s) is not supported yet.");for(let x=0;x<h.length;++x){let b=h[x],v=y[x],w=A[x];n[b.id]=[v,w]}}}}let s=[],a=[],o=[];for(let i of this.outputs){Ds(i.id in n,`Could not compute output ${i.name} : ${i.id}`);let[l,u]=n[i.id];o.push(l.shape),s.push(l),a.push(u)}return[s,a,o]}buildNodeConversionMap(e){let t={},n;for(let r of this.layers){n=r instanceof Os?1:0;for(let s=0;s<r.inboundNodes.length;s++){let a=Os.nodeKey(r,s);this.containerNodes.has(a)&&(t[a]=n,n+=1)}}return t}getLayer(e,t){if(t!=null){if(this.layers.length<=t)throw new q(`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 q("Provide either a layer name or layer index");for(let n of this.layers)if(n.name===e)return n;throw new q(`No such layer: ${e}`)}calculateLosses(){return Z(()=>{let e=[];for(let t of this.layers)for(let n=0;n<t.inboundNodes.length;++n){let r=Os.nodeKey(t,n);this.containerNodes.has(r)&&e.push(...t.calculateLosses())}return e})}getConfig(){let e={name:this.name},t=this.buildNodeConversionMap(this.layers),n=[];for(let a of this.layers){let o=a.getClassName(),i=a.getConfig(),l=[];for(let c=0;c<a.inboundNodes.length;c++){let d=a.inboundNodes[c],h=Os.nodeKey(a,c),p={};if(this.containerNodes.has(h)){if(d.callArgs)try{JSON.stringify(d.callArgs),p=d.callArgs}catch(f){console.warn(`Layer ${a.name} was passed non-serializable keyword arguments: ${d.callArgs}. They will not be included in the serialized model (and thus will be missing at deserialization time).`),p={}}if(d.inboundLayers.length>0){let f=[];for(let m=0;m<d.inboundLayers.length;m++){let g=d.inboundLayers[m],y=d.nodeIndices[m],A=d.tensorIndices[m],x=Os.nodeKey(g,y),b=t[x];b==null&&(b=0),f.push([g.name,b,A,p])}l.push(f)}}}let u={};u.name=a.name,u.className=o,u.config=i,u.inboundNodes=l,n.push(u)}e.layers=n;let r=[];for(let a=0;a<this.inputLayers.length;a++){let o=this.inputLayers[a],i=this.inputLayersNodeIndices[a],l=Os.nodeKey(o,i);if(!this.containerNodes.has(l))continue;let u=t[l];u==null&&(u=0);let c=this.inputLayersTensorIndices[a];r.push([o.name,u,c])}e.inputLayers=r;let s=[];for(let a=0;a<this.outputLayers.length;a++){let o=this.outputLayers[a],i=this.outputLayersNodeIndices[a],l=Os.nodeKey(o,i);if(!this.containerNodes.has(l))continue;let u=t[l];u==null&&(u=0);let c=this.outputLayersTensorIndices[a];s.push([o.name,u,c])}return e.outputLayers=s,e}static fromConfig(e,t,n={},r=!1){let s={},a={};function o(m,g){m.name in a?a[m.name].push(g):a[m.name]=[g]}function i(m,g){let y=[],A;for(let x of g){let b=x[0],v=x[1],w=x[2];if(A=x[3]==null?{}:x[3],!(b in s)){o(m,g);return}let I=s[b];if(I.inboundNodes.length<=v){o(m,g);return}let T=I.inboundNodes[v];y.push(T.outputTensors[w])}y.length>0&&m.apply(Jn(y),A)}function l(m){let g=m.name,y=fs(m,t.customObjects!=null?t.customObjects:{});y.setFastWeightInitDuringBuild(r),s[g]=y,m.inboundNodes.forEach(x=>{if(!(x instanceof Array))throw new q(`Corrupted configuration, expected array for nodeData: ${x}`);o(y,x)})}let u=t.name,c=t.layers;for(let m of c)l(m);for(;!YQ(a);)for(let m of c){let g=s[m.name];if(g.name in a){let y=a[g.name];delete a[g.name];for(let A of y)i(g,A)}}let d=[],h=[],p=t.inputLayers;for(let m of p){let g=m[0],y=m[1],A=m[2];Ds(g in s);let b=s[g].inboundNodes[y].outputTensors;d.push(b[A])}let f=t.outputLayers;for(let m of f){let g=m[0],y=m[1],A=m[2];Ds(g in s);let b=s[g].inboundNodes[y].outputTensors;h.push(b[A])}return new e({inputs:d,outputs:h,name:u})}get stateful(){if(this._stateful)throw new q("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(){Z(()=>{this.layers.forEach(e=>{e.stateful&&e.resetStates()})})}};function vte(e,t,n){let r=t.length;if(e==null||Array.isArray(e)&&e.length===0)return t.map(s=>null);if(r===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!==r)throw new Error(`Provided ${n} is an array of ${e.length} element(s), but the model has ${r} 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 s=[];return t.forEach(a=>{a in e?s.push(e[a]):s.push(null)}),s}else throw new Error(`The model has multiple (${r}) outputs, so ${n} must be either an array with ${r} elements or an object with ${t} keys. Provided ${n} not understood: ${JSON.stringify(e)}`)}function WS(e,t){return vte(e,t,"classWeight")}async function VS(e,t,n,r){if(t!=null||r!=null)throw new Error("Support sampleWeight is not implemented yet");if(n!=null){let s=Z(()=>{if(e.shape.length===1)return e.clone();if(e.shape.length===2)if(e.shape[1]>1){let i=1;return e.argMax(i)}else{if(e.shape[1]===1)return e.reshape([e.shape[0]]);throw new Error(`Encountered unexpected last-dimension size (${e.shape[1]}) during handling of class weights. The size is expected to be >= 1.`)}else throw new Error(`Unexpected rank of target (y) tensor (${e.rank}) during handling of class weights. The rank is expected to be 1 or 2.`)}),a=Array.from(await s.data());je(s);let o=[];return a.forEach(i=>{if(n[i]==null)throw new Error(`classWeight must contain all classes in the training data. The class ${i} exists in the data but not in classWeight`);o.push(n[i])}),_n(o,"float32")}else return null}function wte(e,t){return K(e,t)}var kte=32;function US(e,t){let n,r,s=t;n=s.xs,r=s.ys,k.assert(n!=null&&r!=null,()=>`A Dataset iterator for fitDataset() is expected to generate objects of the form \`{xs: xVal, ys: yVal}\`, where the two values may be \`tf.Tensor\`, an array of Tensors, or a map of string to Tensor. The provided Dataset instead generates ${t}`);let a=HS("input",e.inputNames,n),o=HS("output",e.outputNames,r),i=a[0].shape[0];k.assert(a.length===e.inputs.length,()=>`LayersModel has ${e.inputs.length} inputs, but the dataset provides ${a.length} inputs. (Expected input keys: ${JSON.stringify(e.inputNames)})`),k.assert(o.length===e.outputs.length,()=>`LayersModel has ${e.outputs.length} outputs, but the dataset provides ${o.length} outputs. (Expected output keys: ${JSON.stringify(e.outputNames)})`);for(let l=0;l<a.length;l++)k.assert(a[l].shape[0]===i,()=>`Batch size mismatch: input ${e.inputNames[l]} has ${a[l].shape[0]}; expected ${i} based on input ${e.inputNames[0]}.`);for(let l=0;l<o.length;l++)k.assert(o[l].shape[0]===i,()=>`Batch size mismatch: output ${e.outputNames[l]} has ${o[l].shape[0]}; expected ${i} based on input ${e.inputNames[0]}.`);return{xs:a,ys:o}}function HS(e,t,n){if(n instanceof Ct)return[n];if(Array.isArray(n))return k.assert(n.length===t.length,()=>`Received an array of ${n.length} Tensors, but expected ${t.length} to match the ${e} keys ${t}.`),n;{let r=[];for(let s of t){if(n[s]==null)throw new q(`The feature data generated by the dataset lacks the required ${e} key '${s}'.`);r.push(n[s])}return r}}function Ite(e){if(e.length===3)throw new Ge("Validation with sample weights is not implemented yet.");return{xs:e[0],ys:e[1]}}async function Ste(e,t,n){let r=n.batchesPerEpoch!=null;if(k.assert(e.optimizer!=null,()=>"You must compile a model before training/testing. Use LayersModel.compile(modelCompileConfig)."),k.assert(n!=null,()=>"For fitDataset(), the 2nd argument (config) is required, but it is not provided in this call."),k.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}`),k.assert(!r||n.batchesPerEpoch>0&&Number.isInteger(n.batchesPerEpoch),()=>`For fitDataset(), config.batchesPerEpoch is expected to be a positive integer if specified, but got ${n.batchesPerEpoch}`),k.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 s=n.validationData!=null,a,o;if(s)if(GS(n.validationData))k.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=Ite(n.validationData);a=g.xs,o=g.ys}let i=e.makeTrainFunction(),l=e.getDedupedMetricsNames(),u;s?u=l.slice().concat(l.map(g=>"val_"+g)):u=l.slice();let c=ES(n.callbacks,n.yieldEvery),d=n.verbose==null?1:n.verbose,{callbackList:h,history:p}=$S(c,d,n.epochs,null,null,Tte(t,n),null,s,u);h.setModel(e),e.history=p,await h.onTrainBegin(),e.stopTraining_=!1;let f=n.initialEpoch==null?0:n.initialEpoch,m=await t.iterator();for(;f<n.epochs;){let g={};await h.onEpochBegin(f);let y=0,A=0;for(r||(m=await t.iterator());r?y<n.batchesPerEpoch:!0;){let x=await m.next();if(r&&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}=US(e,x.value),w={};w.batch=A,w.size=b[0].shape[0],await h.onBatchBegin(A,w);let I=[];if(n.classWeight!=null){let M=WS(n.classWeight,e.outputNames);for(let $=0;$<M.length;++$)I.push(await VS(v[$],null,M[$]))}let T=b.concat(v).concat(I),C=i(T);je(T);for(let M=0;M<l.length;++M){let $=l[M],R=C[M];w[$]=R,Sn(R)}await h.onBatchEnd(A,w),IS(w),A++,y++}if(r?y>=n.batchesPerEpoch:x.done){if(s){let b;GS(n.validationData)?b=Dt(await e.evaluateDataset(n.validationData,{batches:n.validationBatches})):b=Dt(e.evaluate(a,o,{batchSize:n.validationBatchSize==null?kte: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 h.onEpochEnd(f,g),f++,e.stopTraining_)break}return await h.onTrainEnd(),await e.history.syncData(),e.history}finally{e.isTraining=!1}}function Tte(e,t){let n=null;return t.batchesPerEpoch!=null?n=t.batchesPerEpoch:Number.isFinite(e.size)&&(n=e.size),n}function GS(e){return typeof e.iterator=="function"}function Nte(e){return typeof e.next=="function"}async function Cte(e,t,n){n=n||{};let r=n.batches!=null,s=e.testFunction,a=[];if(n.verbose>0)throw new Ge("Verbose mode is not implemented yet.");k.assert(!r||n.batches>0&&Number.isInteger(n.batches),()=>`Test loop expects \`batches\` to be a positive integer, but received ${JSON.stringify(n.batches)}`);let o=Nte(t)?t:await t.iterator(),i=0,l=0;for(;r?l<n.batches:!0;){let u=await o.next();if(a=Z(()=>{if(u.value){let{xs:c,ys:d}=US(e,u.value),h=c.concat(d),p=Z(()=>s(h));if(je(h),l===0)for(let m=0;m<p.length;++m)a.push(Fe(0));let f=h[0].shape[0];for(let m=0;m<p.length;++m){let g=p[m],y=a[m];a[m]=Z(()=>pe(a[m],K(f,g))),l>0&&je(y)}je(p),i+=f,++l}return a}),u.done){r&&console.warn(`Your dataset iterator ran out of data during evaluateDataset(). Interrupting evalution. Make sure that your dataset can generate at least \`batches\` batches (in this case, ${n.batches} batches). You may need to use the repeat() function when building your dataset.`);break}}for(let u=0;u<a.length;++u){let c=a[u];a[u]=Re(a[u],i),je(c)}return Jn(a)}function nx(e){k.assert(e>0&&Number.isInteger(e),()=>`batchSize is required to be a positive integer, but got ${e}`)}function Gd(e,t,n){return e==null?[null]:Array.isArray(e)?e.map(r=>li(r,t,n-t)):li(e,t,n-t)}function rx(e,t){return Z(()=>e==null?null:Array.isArray(e)?e.map(n=>rx(n,t)):fS(e,t.dtype==="int32"?t:t.toInt()))}function sx(e,t){let n=[],r=0,s=null;for(;r<e;)s=r+t,s>=e&&(s=e),n.push([r,s]),r=s;return n}async function Ete(e,t,n,r,s,a,o,i,l,u,c,d,h,p,f){s==null&&(s=32),a==null&&(a=1),c==null&&(c=!0),h==null&&(h=0);let m=!1;if(l!=null&&u!=null&&(m=!0),f!=null&&(m=!0,p==null))throw new q("Can only use `validationSteps` when doing step-wise training, i.e., `stepsPerEpoch` must be set.");let g=e.checkNumSamples(n,s,p,"steps_per_epoch"),y;g!=null&&(y=ds(0,g)),o==null&&(o=1);let{callbackList:A,history:x}=$S(i,o,a,h,g,p,s,m,d);A.setModel(e),e.history=x,await A.onTrainBegin(),e.stopTraining_=!1;for(let b=h;b<a;++b){await A.onEpochBegin(b);let v={};if(p!=null)throw new Ge("stepsPerEpoch mode is not implemented yet.");{if(c==="batch")throw new Ge("batch shuffling is not implemneted yet");c&&k.shuffle(y);let w=_n(y),I=sx(g,s);for(let T=0;T<I.length;++T){let C={};if(await A.onBatchBegin(T,C),Z(()=>{let M=I[T][0],$=I[T][1],R=li(w,M,$-M);C.batch=T,C.size=$-M;let N=rx(n,R),F=t(N);for(let B=0;B<r.length;++B){let j=r[B],X=F[B];C[j]=X,Sn(X)}if(T===I.length-1&&m){let B=e.testLoop(l,u,s);for(let j=0;j<r.length;++j){let X=r[j],Y=B[j];Sn(Y),v["val_"+X]=Y}}}),await A.onBatchEnd(T,C),IS(C),e.stopTraining_)break}w.dispose()}if(await A.onEpochEnd(b,v),e.stopTraining_)break}return await A.onTrainEnd(),await e.history.syncData(),e.history}async function $te(e,t,n,r={}){if(e.isTraining)throw new Error("Cannot start training because another fit() call is ongoing.");e.isTraining=!0;let s,a,o,i,l,u,c;try{let d=r.batchSize==null?32:r.batchSize;nx(d);let h=!1,p=await e.standardizeUserData(t,n,r.sampleWeight,r.classWeight,h,d);s=p[0],a=p[1],c=p[2];let f=!1,m;if(r.validationData!=null&&r.validationData.length>0){if(f=!0,r.validationData.length===2)o=r.validationData[0],i=r.validationData[1];else throw r.validationData.length===3?new Ge("validationData including sample weights is not supported yet."):new q(`When passing validation data, it must contain 2 (valX, valY) or 3 (valX, valY, valSampleWeight) items; ${r.validationData} is invalid.`);let I=!0,T=await e.standardizeUserData(o,i,null,null,I,d);l=T[0],u=T[1],m=l.concat(u)}else if(r.validationSplit!=null&&r.validationSplit>0&&r.validationSplit<1){f=!0;let I=Math.floor(s[0].shape[0]*(1-r.validationSplit)),T=s[0].shape[0];l=Gd(s,I,T),s=Gd(s,0,I),u=Gd(a,I,T),a=Gd(a,0,I),m=l.concat(u)}else r.validationSteps!=null&&(f=!0);let g=s.concat(a).concat(c);e.checkTrainableWeightsConsistency();let y=e.makeTrainFunction(),A=e.getDedupedMetricsNames(),x,b;f?(e.makeTestFunction(),x=e.testFunction,b=A.slice().concat(A.map(I=>"val_"+I))):(x=null,m=[],b=A.slice());let v=ES(r.callbacks,r.yieldEvery);return await Ete(e,y,g,A,d,r.epochs,r.verbose,v,x,m,r.shuffle,b,r.initialEpoch,null,null)}finally{e.isTraining=!1,di(s,t),di(a,n),di(l,o),di(u,i),c!=null&&je(c)}}function jS(e){let t=[];e instanceof Ct&&(e=[e]);for(let n=0;n<e.length;++n){let r=e[n];if(r.rank===1)t.push(Ld(r,1));else{if(r.rank===0)throw new Error("Expected tensor to be at least 1D, but received a 0D tensor (scalar).");t.push(r)}}return t}function di(e,t){if(e==null)return;let n=[];if(t instanceof Ct)n.push(t.id);else if(Array.isArray(t))t.forEach(s=>n.push(s.id));else if(t!=null)for(let s in t){let a=t[s];n.push(a.id)}let r=[];if(e instanceof Ct)n.indexOf(e.id)===-1&&r.push(e);else if(Array.isArray(e))e.forEach(s=>{n.indexOf(s.id)===-1&&r.push(s)});else if(e!=null)for(let s in e){let a=e[s];n.indexOf(a.id)===-1&&r.push(a)}r.forEach(s=>{s.isDisposed||s.dispose()})}function _te(e){return e instanceof Ct}function ax(e){return Array.isArray(e)}function qS(e){return!_te(e)&&!ax(e)}function KS(e,t,n,r=!0,s=""){if(t==null||t.length===0){if(e!=null){let o=!1;if(ax(e)&&e.length>0)o=!0;else if(qS(e)){for(let i in e)if(e.hasOwnProperty(i)){o=!0;break}}else o=!0;if(o)throw new q(`Error when checking model ${s} expected no data, but got ${e}`)}return[]}if(e==null)return t.map(o=>null);let a;if(qS(e)){e=e,a=[];for(let o of t){if(e[o]==null)throw new q(`No data provided for "${o}". Need data for each key in: ${t}`);a.push(e[o])}}else if(ax(e)){if(e=e,e.length!==t.length)throw new q(`Error when checking model ${s}: the Array of Tensors that you are passing to your model is not the size the model expected. Expected to see ${t.length} Tensor(s), but instead got the following list of Tensor(s): ${e}`);a=e}else{if(e=e,t.length>1)throw new q(`The model ${s} expects ${t.length} Tensor(s), but only received one Tensor. Found: Tensor with shape ${e.shape}`);a=[e]}if(a=jS(a),n!=null)for(let o=0;o<t.length;++o){if(n[o]==null)continue;let i=a[o];if(i.shape.length!==n[o].length)throw new q(`Error when checking ${s}: expected ${t[o]} to have ${n[o].length} dimension(s). but got array with shape ${i.shape}`);for(let l=0;l<n[o].length;++l){if(l===0&&!r)continue;let u=i.shape[l],c=n[o][l];if(c!=null&&c>=0&&u!==c)throw new q(`Error when checking ${s}: expected ${t[o]} to have shape [${n[o]}], but got array with shape [${i.shape}].`)}}return a}function Rte(e,t,n){let r=Ga(e.map(a=>a.shape[0]));r.sort();let s=Ga(t.map(a=>a.shape[0]));if(s.sort(),r.length>1)throw new q(`All input Tensors (x) should have the same number of samples. Got array shapes: ${JSON.stringify(e.map(a=>a.shape))}`);if(s.length>1)throw new q(`All target Tensors (y) should have the same number of samples. Got array shapes: ${JSON.stringify(t.map(a=>a.shape))}`);if(r.length>0&&s.length>0&&!k.arraysEqual(r,s))throw new q(`Input Tensors should have the same number of samples as target Tensors. Found ${r[0]} input sample(s) and ${s[0]} target sample(s).`)}function Dte(e,t,n){let r=[ui,lm,Vd];for(let s=0;s<e.length;++s){let a=e[s],o=t[s],i=n[s];if(o!=null){if(o===Vd&&a.shape[a.shape.length-1]===1)throw new q(`You are passing a target array of shape ${a.shape} while using a loss 'categorical_crossentropy'. 'categorical_crossentropy'expects targets to be binary matrices (1s and 0s) of shape [samples, classes].`);if(r.indexOf(o)!==-1){let l=a.shape.slice(1),u=i.slice(1);for(let c=0;c<l.length;++c){let d=l[c],h=u[c];if(h!=null&&d!==h)throw new q(`A target Tensor with shape ${a.shape} was passed for an output of shape ${i}, while using a loss function that expects targets to have the same shape as the output.`)}}}}}function XS(e,t,n,r=!0,s=""){let a;if(Array.isArray(e)){if(e.length!==t.length)throw new q(`Error when checking model ${s}: the Array of Tensors that you are passing to your model is not the size the the model expected. Expected to see ${t.length} Tensor(s), but instead got ${e.length} Tensors(s).`);a=e}else{if(t.length>1)throw new q(`The model expects ${t.length} ${s} Tensors, but only received one Tensor. Found: array with shape ${JSON.stringify(e.shape)}.`);a=[e]}if(n!=null)for(let o=0;o<t.length;++o){if(n[o]==null)continue;let i=a[o];if(i.shape.length!==n[o].length)throw new q(`Error when checking ${s}: expected ${t[o]} to have ${n[o].length} dimension(s), but got array with shape ${JSON.stringify(i.shape)}`);for(let l=0;l<n[o].length;++l){if(l===0&&!r)continue;let u=i.shape[l],c=n[o][l];if(c!=null&&c!==u)throw new q(`Error when checking ${s}: expected ${t[o]} to have shape ${JSON.stringify(n[o])} but got array with shape ${JSON.stringify(i.shape)}.`)}}}function Fte(e,t){if(e==null||Array.isArray(e)&&e.length===0)return t.map(r=>[]);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(r=>n);{let r=[];for(let s of t){let a=n.hasOwnProperty(s)?n[s]:[];Array.isArray(a)||(a=[a]),r.push(a)}return r}}var Mte="layers-model",pa=class extends Os{constructor(e){super(e);this.isTraining=!1}summary(e,t,n=console.log){if(!this.built)throw new q("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).");hte(this,e,t,n)}compile(e){if(e.loss==null&&(e.loss=[]),this.loss=e.loss,typeof e.optimizer=="string")this.optimizer_=dte(e.optimizer),this.isOptimizerOwned=!0;else{if(!(e.optimizer instanceof Ha))throw new q("User-defined optimizer must be an instance of tf.Optimizer.");this.optimizer_=e.optimizer,this.isOptimizerOwned=!1}let t=[];if(!Array.isArray(e.loss)&&typeof e.loss!="string"&&typeof e.loss!="function"){e.loss=e.loss;for(let a in e.loss)if(this.outputNames.indexOf(a)===-1)throw new q(`Unknown entry in loss dictionary: "${a}". Only expected the following keys: ${this.outputNames}`);for(let a of this.outputNames)e.loss[a]==null&&console.warn(`Output "${a}" is missing from loss dictionary. We assume this was done on purpose, and we will not be expecting data to be passed to ${a} during training`),t.push(K1(e.loss[a]))}else if(Array.isArray(e.loss)){if(e.loss.length!==this.outputs.length)throw new q(`When passing an Array as loss, it should have one entry per model output. The model has ${this.outputs.length} output(s), but you passed loss=${e.loss}.`);t=e.loss.map(o=>K1(o))}else{let a=K1(e.loss);this.outputs.forEach(o=>{t.push(a)})}this.lossFunctions=t,this.feedOutputNames=[],this.feedOutputShapes=[],this.feedLossFns=[];for(let a=0;a<this.outputs.length;++a){let o=this.internalOutputShapes[a],i=this.outputNames[a];this.feedOutputNames.push(i),this.feedOutputShapes.push(o),this.feedLossFns.push(this.lossFunctions[a])}let n=[];this.metrics=e.metrics,this.metricsNames=["loss"],this.metricsTensors=[],ii("loss",()=>{for(let a=0;a<this.outputs.length;++a){if(n.indexOf(a)!==-1)continue;let o=this.lossFunctions[a];this.outputs.length>1&&(this.metricsTensors.push([o,a]),this.metricsNames.push(this.outputNames[a]+"_loss"))}});let r=Fte(e.metrics,this.outputNames),s=(a,o,i)=>{this.outputNames.length>1&&(o=this.outputNames[a]+"_"+o),this.metricsNames.push(o),this.metricsTensors.push([i,a])};ii("metric",()=>{for(let a=0;a<this.outputs.length;++a){if(n.indexOf(a)!==-1)continue;let o=r[a];(l=>{let u="",c,d,h;for(let p of l){if(typeof p=="string"&&["accuracy","acc","crossentropy","ce"].indexOf(p)!==-1){let m=this.internalOutputShapes[a];m[m.length-1]===1||this.lossFunctions[a]===lm?["accuracy","acc"].indexOf(p)!==-1?d=X1:["crossentropy","ce"].indexOf(p)!==-1&&(d=DS):this.lossFunctions[a]===im?["accuracy","acc"].indexOf(p)!==-1?d=FS:["crossentropy","ce"].indexOf(p)!==-1&&(d=MS):["accuracy","acc"].indexOf(p)!==-1?d=Z1:["crossentropy","ce"].indexOf(p)!==-1&&(d=Y1);let g;["accuracy","acc"].indexOf(p)!==-1?g="acc":["crossentropy","ce"].indexOf(p)!==-1&&(g="ce"),h=d,c=u+g}else h=cte(p),c=u+dm(p);let f;ii(c,()=>{f=h}),s(a,c,f)}})(o)}}),this.collectedTrainableWeights=this.trainableWeights}checkTrainableWeightsConsistency(){this.collectedTrainableWeights!=null&&this.trainableWeights.length!==this.collectedTrainableWeights.length&&console.warn("Discrepancy between trainableweights and collected trainable weights. Did you set `model.trainable` without calling `model.compile()` afterwards?")}evaluate(e,t,n={}){let r=n.batchSize==null?32:n.batchSize;nx(r);let s=!0,a=this.standardizeUserDataXY(e,t,s,r);try{let o=a[0].concat(a[1]);this.makeTestFunction();let i=this.testFunction,l=this.testLoop(i,o,r,n.verbose,n.steps);return Jn(l)}finally{di(a[0],e),di(a[1],t)}}async evaluateDataset(e,t){return this.makeTestFunction(),Cte(this,e,t)}checkNumSamples(e,t,n,r="steps"){let s;if(n!=null){if(s=null,t!=null)throw new q(`If ${r} is set, batchSize must be null or undefined.Got batchSize = ${t}`)}else if(e!=null)Array.isArray(e)?s=e[0].shape[0]:s=e.shape[0];else throw new q(`Either the input data should have a defined shape, or ${r} shoud be specified.`);return s}execute(e,t){if(Array.isArray(t)&&t.length===0)throw new q("`outputs` is an empty Array, which is not allowed.");let n=Array.isArray(t),r=n?t:[t],s=this.retrieveSymbolicTensors(r),a=new ci;if(e instanceof Ct&&(e=[e]),Array.isArray(e)){if(e.length!==this.inputs.length)throw new q(`The number of inputs provided (${e.length}) does not match the number of inputs of this model (${this.inputs.length}).`);for(let i=0;i<this.inputs.length;++i)a.add(this.inputs[i],e[i])}else for(let i of this.inputs){let l=e[i.name];if(l==null)throw new q(`No value is provided for the model's input ${i.name}`);a.add(i,l)}let o=Hd(s,a);return n?o:o[0]}retrieveSymbolicTensors(e){let t=si(null,e.length),n=e.length;for(let r of this.layers){let s=Array.isArray(r.output)?r.output:[r.output],a=s.map(o=>o.name);for(let o=0;o<e.length;++o){let i=a.indexOf(e[o]);if(i!==-1&&(t[o]=s[i],n--),n===0)break}if(n===0)break}if(n>0){let r=[];throw t.forEach((s,a)=>{s==null&&r.push(e[a])}),new q(`Cannot find SymbolicTensors for output name(s): ${JSON.stringify(r)}`)}return t}predictLoop(e,t=32,n=!1){return Z(()=>{let r=this.checkNumSamples(e);if(n)throw new Ge("Verbose predictLoop() is not implemented yet.");let s=sx(r,t),a=this.outputs.map(o=>[]);for(let o=0;o<s.length;++o)Z(()=>{let l=s[o][0],u=s[o][1],c=Gd(e,l,u),d=[];if(Array.isArray(c))for(let p=0;p<c.length;++p)d.push({key:this.inputs[p],value:c[p]});else d.push({key:this.inputs[0],value:c});let h=new ci(d);return Hd(this.outputs,h)}).forEach((l,u)=>a[u].push(l));return Jn(a.map(o=>en(o,0)))})}predict(e,t={}){let n=jS(e);XS(n,this.inputNames,this.feedInputShapes,!1);try{let r=t.batchSize==null?32:t.batchSize;return nx(r),this.predictLoop(n,r)}finally{di(n,e)}}predictOnBatch(e){XS(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,r){if(this.optimizer_==null)throw new cs("You must compile a model before training/testing. Use LayersModel.compile(modelCompileArgs).");let s=[];for(let a=0;a<this.feedOutputShapes.length;++a){let o=this.feedOutputShapes[a];this.feedLossFns[a]===im?s.push(o.slice(0,o.length-1).concat([1])):s.push(o)}if(e=KS(e,this.feedInputNames,this.feedInputShapes,!1,"input"),t=KS(t,this.feedOutputNames,s,!1,"target"),Rte(e,t,null),Dte(t,this.feedLossFns,this.feedOutputShapes),this.stateful&&r!=null&&r>0&&e[0].shape[0]%r!=0)throw new q(`In a stateful network, you should only pass inputs with a number of samples that is divisible by the batch size ${r}. Found: ${e[0].shape[0]} sample(s).`);return[e,t]}async standardizeUserData(e,t,n,r,s=!0,a){let[o,i]=this.standardizeUserDataXY(e,t,s,a);if(n!=null)throw new Error("sample weight is not supported yet.");let l=null;if(r!=null){let u=WS(r,this.outputNames);l=[];for(let c=0;c<u.length;++c)l.push(await VS(i[c],null,u[c]))}return[o,i,l]}testLoop(e,t,n,r=0,s){return Z(()=>{let a=this.checkNumSamples(t,n,s,"steps"),o=[];if(r>0)throw new Ge("Verbose mode is not implemented yet.");if(s!=null)throw new Ge("steps mode in testLoop() is not implemented yet");{let i=sx(a,n),l=_n(ds(0,a));for(let u=0;u<i.length;++u){let c=i[u][0],d=i[u][1],h=li(l,c,d-c),p=rx(t,h),f=e(p);if(u===0)for(let m=0;m<f.length;++m)o.push(Fe(0));for(let m=0;m<f.length;++m){let g=f[m];o[m]=pe(o[m],K(d-c,g))}}for(let u=0;u<o.length;++u)o[u]=Re(o[u],a)}return o})}getDedupedMetricsNames(){let e=this.metricsNames,t=[];for(let n=0;n<e.length;++n){let r=e[n],s=r;nS(e,r)>1&&(s+=`_${nS(e.slice(0,n),r)}`),t.push(s)}return t}makeTrainFunction(){return e=>{let t=[],n=e.slice(0,this.inputs.length),r=e.slice(this.inputs.length,this.inputs.length+this.outputs.length),s=e.slice(this.inputs.length+this.outputs.length,this.inputs.length+this.outputs.length*2),a=[],o=()=>{let c=[];for(let f=0;f<this.inputs.length;++f)c.push({key:this.inputs[f],value:n[f]});let d=new ci(c),h=Hd(this.outputs,d,{training:!0}),p;for(let f=0;f<this.lossFunctions.length;++f){let g=this.lossFunctions[f](r[f],h[f]);s[f]!=null&&(g=wte(g,s[f]));let y=Xt(g);t.push(y),f===0?p=g:p=pe(p,g)}for(let f=0;f<this.metricsTensors.length;++f){let m;if(this.outputs.length>1&&f<this.outputs.length)m=t[f];else{let g=this.metricsTensors[f][0],y=this.metricsTensors[f][1];m=Xt(g(r[y],h[y]))}Sn(m),a.push(m)}return p=Xt(p),this.calculateLosses().forEach(f=>{p=pe(p,f)}),p},i=this.collectedTrainableWeights.map(c=>c.read()),l=!0;return[this.optimizer_.minimize(o,l,i)].concat(a)}}makeTestFunction(){this.testFunction=e=>Z(()=>{let t=[],n,r=e.slice(0,this.inputs.length),s=e.slice(this.inputs.length,this.inputs.length+this.outputs.length),a=[];for(let l=0;l<this.inputs.length;++l)a.push({key:this.inputs[l],value:r[l]});let o=new ci(a),i=Hd(this.outputs,o);for(let l=0;l<this.lossFunctions.length;++l){let u=this.lossFunctions[l],c=Xt(u(s[l],i[l]));l===0?n=c:n=pe(n,c),t.push(n)}for(let l=0;l<this.metricsTensors.length;++l){let u=this.metricsTensors[l][0],c=this.metricsTensors[l][1],d=Xt(u(s[c],i[c]));t.push(d)}return t})}async fit(e,t,n={}){return $te(this,e,t,n)}async fitDataset(e,t){return Ste(this,e,t)}async trainOnBatch(e,t){let n=await this.standardizeUserData(e,t),r=n[0],s=n[1],o=this.makeTrainFunction()(r.concat(s)),i=[];for(let l of o){let u=await l.data();i.push(u[0])}return je(o),Jn(i)}getNamedWeights(e){let t=[],n=e!=null&&e.trainableOnly,r=n?this.trainableWeights:this.weights,s=this.getWeights(n);for(let a=0;a<r.length;++a)n&&!r[a].trainable||t.push({name:r[a].originalName,tensor:s[a]});return t}set stopTraining(e){this.stopTraining_=e}get stopTraining(){return this.stopTraining_}get optimizer(){return this.optimizer_}set optimizer(e){this.optimizer_!==e&&(this.optimizer_=e,this.isOptimizerOwned=!1)}dispose(){let e=super.dispose();if(e.refCountAfterDispose===0&&this.optimizer!=null&&this.isOptimizerOwned){let t=EA().numTensors;this.optimizer_.dispose(),e.numDisposedVariables+=t-EA().numTensors}return e}getLossIdentifiers(){let e;if(typeof this.loss=="string")e=ha(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=>ha(t))}else{let t=Object.keys(this.loss);e={};let n=this.loss;for(let r of t)if(typeof n[r]=="string")e[r]=ha(n[r]);else throw new Error("Serialization of non-string loss is not supported.")}return e}getMetricIdentifiers(){if(typeof this.metrics=="string"||typeof this.metrics=="function")return[ha(dm(this.metrics))];if(Array.isArray(this.metrics))return this.metrics.map(e=>ha(dm(e)));{let e={};for(let t in this.metrics)e[t]=ha(dm(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=Ud(e.optimizer_config),n=fs(t),r;if(typeof e.loss=="string")r=ai(e.loss);else if(Array.isArray(e.loss))r=e.loss.map(a=>ai(a));else if(e.loss!=null){r={};for(let a in e.loss)r[a]=ai(e.loss[a])}let s;if(Array.isArray(e.metrics))s=e.metrics.map(a=>ai(a));else if(e.metrics!=null){s={};for(let a in e.metrics)s[a]=ai(e.metrics[a])}this.compile({loss:r,metrics:s,optimizer:n})}async save(e,t){if(typeof e=="string"){let l=ur.getSaveHandlers(e);if(l.length===0)throw new q(`Cannot find any save handlers for URL '${e}'`);if(l.length>1)throw new q(`Found more than one (${l.length}) save handlers for URL '${e}'`);e=l[0]}if(e.save==null)throw new q("LayersModel.save() cannot proceed because the IOHandler provided does not have the `save` attribute defined.");let n=await ur.encodeWeights(this.getNamedWeights(t)),r=!1,s=null,o={modelTopology:this.toJSON(s,r),format:Mte,generatedBy:`TensorFlow.js tfjs-layers v${ex}`,convertedBy:null};if((t==null?!1:t.includeOptimizer)&&this.optimizer!=null){o.trainingConfig=this.getTrainingConfig();let l="optimizer",{data:u,specs:c}=await ur.encodeWeights(await this.optimizer.getWeights(),l);n.specs.push(...c),n.data=ur.concatenateArrayBuffers([n.data,u])}if(this.userDefinedMetadata!=null){let l=!0;PS(this.userDefinedMetadata,this.name,l),o.userDefinedMetadata=this.userDefinedMetadata}return o.weightData=n.data,o.weightSpecs=n.specs,e.save(o)}setUserDefinedMetadata(e){PS(e,this.name),this.userDefinedMetadata=e}getUserDefinedMetadata(){return this.userDefinedMetadata}};pa.className="Model";ce.registerClass(pa);var ZS=class extends pa{};ZS.className="Functional";ce.registerClass(ZS);async function Ote(e,t){"modelTopology"in e||(e={modelTopology:e}),e=e;let n=e.modelTopology;n.model_config!=null&&(n=n.model_config);let r=Ud(n),s=fs(r,t);if(e.weightsManifest!=null){let a=await ur.loadWeights(e.weightsManifest,e.pathPrefix,s.weights.map(i=>i.originalName)),o={};for(let i of s.weights)o[i.originalName]=a[i.originalName];s.loadWeights(o),je(a)}return s}async function Pte(e,t){if(t==null&&(t={}),typeof e=="string"){let n=ur.getLoadHandlers(e,t);if(n.length===0)n.push(ur.browserHTTPRequest(e,t));else if(n.length>1)throw new q(`Found more than one (${n.length}) load handlers for URL '${e}'`);e=n[0]}return zte(e,void 0,t)}async function zte(e,t,n){if(n==null&&(n={}),e.load==null)throw new q("Cannot proceed with model loading because the IOHandler provided does not have the `load` method implemented.");let r=await e.load(),s=r.modelTopology;s.model_config!=null&&(s=s.model_config);let a=n.strict==null?!0:n.strict,o=r.weightData!=null&&r.weightSpecs!=null&&a,i=fs(Ud(s),t,o),l=r.trainingConfig;if(l!=null&&i.loadTrainingConfig(l),r.userDefinedMetadata!=null&&i.setUserDefinedMetadata(r.userDefinedMetadata),r.weightData!=null){if(r.weightSpecs==null)throw new q("LayersModel artifacts contains weight data, but not weight specs. Therefore loading of weights cannot proceed.");let{modelWeights:u,optimizerWeights:c}=Lte(r.weightData,r.weightSpecs);i.loadWeights(u,a),i.optimizer!=null&&c.length>0&&await i.optimizer.setWeights(c),je(u),je(c.map(d=>d.tensor))}return i}function Lte(e,t){let n=ur.decodeWeights(e,t),r={},s=[];return t.forEach(a=>{a.group==="optimizer"?s.push({name:a.name,tensor:n[a.name]}):r[a.name]=n[a.name]}),{modelWeights:r,optimizerWeights:s}}var ox=class extends pa{constructor(e){super({inputs:[],outputs:[]});if(e=e||{},this.trainable=!0,this.built=!1,this.name=e.name!=null?e.name:tm("sequential_"),e.layers!=null)for(let t of e.layers)this.add(t)}checkShape(e){if(e.inboundNodes[0].outputTensors[0].shape.some(n=>n<0))throw new q(`Negative dimension size caused by adding layer ${e.name} with input shape [${e.inboundNodes[0].inputTensors[0].shape}]`)}add(e){let t=e instanceof ox||e instanceof pa,n;if(t){if(n=e,n.outputs.length!==1)throw new q("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 q("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 q("The first layer in a Sequential model must get an `inputShape` or `batchInputShape` argument.");let r=kS({batchShape:e.batchInputShape,dtype:e.dtype,name:e.name+"_input"});e.apply(r)}if(t)this.outputs=n.outputs,this.inputs=n.inputs;else{if(e.inboundNodes.length!==1)throw new q(`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 q("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=wS(this.outputs[0])}this.inboundNodes=[],new sm({outboundLayer:this,inboundLayers:[],nodeIndices:[],tensorIndices:[],inputTensors:this.inputs,outputTensors:this.outputs,inputMasks:si(null,this.inputs.length),outputMasks:[null],inputShapes:this.inputs.map(r=>r.shape),outputShapes:this.outputs[0].shape})}else{let r=e.apply(this.outputs[0]);if(Array.isArray(r))throw new TypeError("All layers in a Sequential model should have a single output tensor. For multi-output layers, use the functional API.");this.checkShape(e),this.outputs=[r],this.inboundNodes[0].outputTensors=this.outputs,this.inboundNodes[0].outputShapes=[this.outputs[0].shape]}this.layers.push(e),this.built=!1}pop(){if(this.layers.length===0)throw new TypeError("There are no layers in the model.");if(this.layers.pop(),this.layers.length===0)this.outputs=[],this.inboundNodes=[],this.outboundNodes=[];else{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(At(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 pa({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 cs("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 cs("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 cs("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 cs("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={},r=!1){let s,a={};if(t instanceof Array){if(t[0].className==null||t[0].className==="Merge")throw new q("Legacy serialization format not supported yet.");s=t}else k.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."),s=t.layers,delete t.layers,a=t;let o=new e(a);if(!(o instanceof ox))throw new Ge(`Sequential.fromConfig called on non-Sequential input: ${o}`);for(let i of s){let u=fs(i,void 0,r);r&&u.setFastWeightInitDuringBuild(!0),o.add(u)}return o}set stopTraining(e){if(this.model==null)throw new q("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 q("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}}},pm=ox;pm.className="Sequential";ce.registerClass(pm);function Bte(e){return new pa(e)}function Wte(e){return new pm(e)}function Vte(e,t){return t==null&&(t={}),Pte(e,t)}function YS(e){return kS(e)}function Ute(e,t){j1.registerCallbackConstructor(e,t)}var er=class extends ce.Serializable{getConfig(){return{}}},JS=class extends er{apply(e,t=1){return mee(e,t)}};JS.className="elu";ce.registerClass(JS);var QS=class extends er{apply(e){return e1(e)}};QS.className="selu";ce.registerClass(QS);var e8=class extends er{apply(e){return ua(e)}};e8.className="relu";ce.registerClass(e8);var t8=class extends er{apply(e){return Z(()=>_d(6,ua(e)))}};t8.className="relu6";ce.registerClass(t8);var n8=class extends er{apply(e){return e}};n8.className="linear";ce.registerClass(n8);var r8=class extends er{apply(e){return Rs(e)}};r8.className="sigmoid";ce.registerClass(r8);var s8=class extends er{apply(e){return yee(e)}};s8.className="hardSigmoid";ce.registerClass(s8);var a8=class extends er{apply(e){return Zl(e)}};a8.className="softplus";ce.registerClass(a8);var o8=class extends er{apply(e){return gee(e)}};o8.className="softsign";ce.registerClass(o8);var i8=class extends er{apply(e){return Kl(e)}};i8.className="tanh";ce.registerClass(i8);var ix=class extends er{apply(e,t=-1){return Of(e,t)}};ix.className="softmax";ce.registerClass(ix);var l8=class extends er{apply(e,t=-1){return UA(e,t)}};l8.className="logSoftmax";ce.registerClass(l8);var u8=class extends er{apply(e,t=1){return Z(()=>Rs(e.mul(t)).mul(e))}};u8.className="swish";ce.registerClass(u8);var c8=class extends er{apply(e){return Z(()=>K(e,Kl(Zl(e))))}};c8.className="mish";ce.registerClass(c8);function Xa(e){return e.getClassName()}function lx(e,t={}){return Md(e,ce.SerializationMap.getMap().classNameMap,t,"activation")}function Za(e){if(e==null){let t={};return t.className="linear",t.config={},lx(t)}if(typeof e=="string"){let t={};return t.className=e,t.config={},lx(t)}else return e instanceof er?e:lx(e)}function ux(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 d8=class extends ce.Serializable{},jd=class extends d8{constructor(e){super();ux(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 Z(()=>{let t=un([1]);return this.hasL1&&(t=pe(t,_e(K(this.l1,yn(e))))),this.hasL2&&(t=pe(t,_e(K(this.l2,Bd(e))))),t.asScalar()})}getConfig(){return{l1:this.l1,l2:this.l2}}static fromConfig(e,t){return new e({l1:t.l1,l2:t.l2})}};jd.className="L1L2";ce.registerClass(jd);function Hte(e){return ux(e),new jd({l1:e!=null?e.l1:null,l2:0})}function Gte(e){return ux(e),new jd({l2:e!=null?e.l2:null,l1:0})}var h8={l1l2:"L1L2"};function kt(e){return I1(e)}function p8(e,t={}){return Md(e,ce.SerializationMap.getMap().classNameMap,t,"regularizer")}function Lt(e){if(e==null)return null;if(typeof e=="string"){let n={className:e in h8?h8[e]:e,config:{}};return p8(n)}else return e instanceof d8?e:p8(e)}var cx=class extends st{constructor(e){super(e==null?{}:e);this.supportsMasking=!0,e!=null&&(this.maxValue=e.maxValue)}call(e,t){e=Ke(e);let n=ua(e);return this.maxValue!=null&&(n=cr(n,0,this.maxValue)),n}computeOutputShape(e){return e}getConfig(){let e={maxValue:this.maxValue},t=super.getConfig();return Object.assign(e,t),e}};cx.className="ReLU";ce.registerClass(cx);var dx=class extends st{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=Ke(e);return Cf(n,this.alpha)}computeOutputShape(e){return e}getConfig(){let e={alpha:this.alpha},t=super.getConfig();return Object.assign(e,t),e}};dx.className="LeakyReLU";ce.registerClass(dx);var hx=class extends st{constructor(e){super(e==null?{}:e);if(this.DEFAULT_ALPHA_INITIALIZER="zeros",e==null&&(e={}),this.supportsMasking=!0,this.alphaInitializer=zt(e.alphaInitializer||this.DEFAULT_ALPHA_INITIALIZER),this.alphaRegularizer=Lt(e.alphaRegularizer),this.alphaConstraint=hn(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 q(`Expected sharedAxes to be a number or an array of numbers, but got ${e.sharedAxes}`)}build(e){e=At(e);let t=e.slice(1);if(this.sharedAxes!=null)for(let r of this.sharedAxes)t[r-1]=1;this.alpha=this.addWeight("alpha",t,"float32",this.alphaInitializer,this.alphaRegularizer,!0,this.alphaConstraint);let n={};if(this.sharedAxes!=null)for(let r=1;r<e.length;++r)n[r]=e[r];this.inputSpec=[new tn({ndim:e.length,axes:n})],this.built=!0}call(e,t){return e=Ke(e),Df(e,this.alpha.read())}getConfig(){let e={alphaInitializer:Ht(this.alphaInitializer),alphaRegularizer:kt(this.alphaRegularizer),alphaConstraint:dn(this.alphaConstraint),sharedAxes:this.sharedAxes},t=super.getConfig();return Object.assign(e,t),e}};hx.className="PReLU";ce.registerClass(hx);var px=class extends st{constructor(e){super(e==null?{}:e);if(this.DEFAULT_ALPHA=1,e==null&&(e={}),e.alpha!=null&&e.alpha!==this.DEFAULT_ALPHA)throw new Ge(`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=Ke(e);return Nd(n)}computeOutputShape(e){return e}getConfig(){let e={alpha:this.alpha},t=super.getConfig();return Object.assign(e,t),e}};px.className="ELU";ce.registerClass(px);var fx=class extends st{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=Ke(e);return n.mul(zd(n.greater(this.theta),"float32"))}computeOutputShape(e){return e}getConfig(){let e={theta:this.theta},t=super.getConfig();return Object.assign(e,t),e}};fx.className="ThresholdedReLU";ce.registerClass(fx);var mx=class extends st{constructor(e){super(e==null?{}:e);this.DEFAULT_AXIS=1,e==null&&(e={}),this.softmax=new ix().apply,this.axis=e.axis==null?this.DEFAULT_AXIS:e.axis}call(e,t){let n=Ke(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}};mx.className="Softmax";ce.registerClass(mx);function iu(e,t,n){if(typeof e=="number")return si(e,t);if(e.length!==t)throw new q(`The ${n} argument must be an integer or tuple of ${t} integers. Received: ${e.length} elements.`);for(let r=0;r<t;++r){let s=e[r];if(!dee(s))throw new q(`The ${n} argument must be an integer or tuple of ${t} integers. Received: ${JSON.stringify(e)} including a non-integer number ${s}`)}return e}function ms(e,t,n,r,s=1){if(e==null)return e;let a=t+(t-1)*(s-1),o;return n==="same"?o=e:o=e-a+1,Math.floor((o+r-1)/r)}function Ps(e,t,n,r){if(e==null)return null;if(r==="valid")e=e*t+qa([n-t,0]);else if(r==="same")e=e*t;else throw new q(`Unsupport padding mode: ${r}.`);return e}function gx(e,t){return Z(()=>(Yt(t),t==="channelsFirst"?pt(e,[0,2,3,1]):e))}function f8(e,t){return Z(()=>(Yt(t),t==="channelsFirst"?pt(e,[0,2,3,4,1]):e))}function jte(e,t,n,r=1,s="valid",a,o=1){return Z(()=>{if(a==null&&(a=us()),Yt(a),e.shape.length!==3)throw new q(`The input of a conv1dWithBias operation should be 3, but is ${e.shape.length} instead.`);if(t.shape.length!==3)throw new q(`The kernel for a conv1dWithBias operation should be 3, but is ${t.shape.length} instead`);if(n!=null&&n.shape.length!==1)throw new q(`The bias for a conv1dWithBias operation should be 1, but is ${t.shape.length} instead`);if(a==="channelsFirst"&&(e=pt(e,[0,2,1])),s==="causal")throw new Ge("The support for CAUSAL padding mode in conv1dWithBias is not implemented yet.");let i=MA(e,t,r,s==="same"?"same":"valid","NWC",o);return n!=null&&(i=hs(i,n)),i})}function m8(e,t,n,r=[1,1],s="valid",a,o,i=null){return Z(()=>{if(a==null&&(a=us()),Yt(a),e.rank!==3&&e.rank!==4)throw new q(`conv2dWithBiasActivation expects input to be of rank 3 or 4, but received ${e.rank}.`);if(t.rank!==3&&t.rank!==4)throw new q(`conv2dWithBiasActivation expects kernel to be of rank 3 or 4, but received ${e.rank}.`);let l=gx(e,a);if(s==="causal")throw new Ge("The support for CAUSAL padding mode in conv1dWithBias is not implemented yet.");return l=ti.conv2d({x:l,filter:t,strides:r,pad:s==="same"?"same":"valid",dilations:o,dataFormat:"NHWC",bias:n,activation:i}),a==="channelsFirst"&&(l=pt(l,[0,3,1,2])),l})}function qte(e,t,n,r=[1,1,1],s="valid",a,o){return Z(()=>{if(a==null&&(a=us()),Yt(a),e.rank!==4&&e.rank!==5)throw new q(`conv3dWithBias expects input to be of rank 4 or 5, but received ${e.rank}.`);if(t.rank!==4&&t.rank!==5)throw new q(`conv3dWithBias expects kernel to be of rank 4 or 5, but received ${e.rank}.`);let i=f8(e,a);if(s==="causal")throw new Ge("The support for CAUSAL padding mode in conv3dWithBias is not implemented yet.");return i=nI(i,t,r,s==="same"?"same":"valid","NDHWC",o),n!=null&&(i=hs(i,n)),a==="channelsFirst"&&(i=pt(i,[0,4,1,2,3])),i})}var yx=class extends st{constructor(e,t){super(t);if(this.bias=null,this.DEFAULT_KERNEL_INITIALIZER="glorotNormal",this.DEFAULT_BIAS_INITIALIZER="zeros",yx.verifyArgs(t),this.rank=e,An(this.rank,"rank"),this.rank!==1&&this.rank!==2&&this.rank!==3)throw new Ge(`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,Or(this.padding),this.dataFormat=t.dataFormat==null?"channelsLast":t.dataFormat,Yt(this.dataFormat),this.activation=Za(t.activation),this.useBias=t.useBias==null?!0:t.useBias,this.biasInitializer=zt(t.biasInitializer||this.DEFAULT_BIAS_INITIALIZER),this.biasConstraint=hn(t.biasConstraint),this.biasRegularizer=Lt(t.biasRegularizer),this.activityRegularizer=Lt(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 q(`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 q(`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 q(`dilationRate must be a number or array of three numbers for 3D convolution, but received ${JSON.stringify(this.dilationRate)}`)}}static verifyArgs(e){if(Ds("kernelSize"in e,"required key 'kernelSize' not in config"),typeof e.kernelSize!="number"&&!T1(e.kernelSize,"number",1,3))throw new q(`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:Xa(this.activation),useBias:this.useBias,biasInitializer:Ht(this.biasInitializer),biasRegularizer:kt(this.biasRegularizer),activityRegularizer:kt(this.activityRegularizer),biasConstraint:dn(this.biasConstraint)},t=super.getConfig();return Object.assign(e,t),e}},qd=class extends yx{constructor(e,t){super(e,t);this.kernel=null,qd.verifyArgs(t),this.filters=t.filters,An(this.filters,"filters"),this.kernelInitializer=zt(t.kernelInitializer||this.DEFAULT_KERNEL_INITIALIZER),this.kernelConstraint=hn(t.kernelConstraint),this.kernelRegularizer=Lt(t.kernelRegularizer)}build(e){e=At(e);let t=this.dataFormat==="channelsFirst"?1:e.length-1;if(e[t]==null)throw new q(`The channel dimension of the input should be defined. Found ${e[t]}`);let n=e[t],r=this.kernelSize.concat([n,this.filters]);this.kernel=this.addWeight("kernel",r,null,this.kernelInitializer,this.kernelRegularizer,!0,this.kernelConstraint),this.useBias&&(this.bias=this.addWeight("bias",[this.filters],null,this.biasInitializer,this.biasRegularizer,!0,this.biasConstraint)),this.inputSpec=[{ndim:this.rank+2,axes:{[t]:n}}],this.built=!0}call(e,t){return Z(()=>{e=Ke(e);let n,r=this.bias==null?null:this.bias.read(),s=sS(this.activation.getClassName());if(s!=null&&this.rank===2)n=m8(e,this.kernel.read(),r,this.strides,this.padding,this.dataFormat,this.dilationRate,s);else{if(this.rank===1)n=jte(e,this.kernel.read(),r,this.strides[0],this.padding,this.dataFormat,this.dilationRate[0]);else if(this.rank===2)n=m8(e,this.kernel.read(),r,this.strides,this.padding,this.dataFormat,this.dilationRate);else if(this.rank===3)n=qte(e,this.kernel.read(),r,this.strides,this.padding,this.dataFormat,this.dilationRate);else throw new Ge("convolutions greater than 3D are not implemented yet.");this.activation!=null&&(n=this.activation.apply(n))}return n})}computeOutputShape(e){e=At(e);let t=[],n=this.dataFormat==="channelsLast"?e.slice(1,e.length-1):e.slice(2);for(let s=0;s<n.length;++s){let a=ms(n[s],this.kernelSize[s],this.padding,this.strides[s],typeof this.dilationRate=="number"?this.dilationRate:this.dilationRate[s]);t.push(a)}let r=[e[0]];return this.dataFormat==="channelsLast"?(r=r.concat(t),r.push(this.filters)):(r.push(this.filters),r=r.concat(t)),r}getConfig(){let e={filters:this.filters,kernelInitializer:Ht(this.kernelInitializer),kernelRegularizer:kt(this.kernelRegularizer),kernelConstraint:dn(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 q(`Convolution layer expected config.filters to be a 'number' > 0 but got ${JSON.stringify(e.filters)}`)}},g8=class extends qd{constructor(e){super(2,e);g8.verifyArgs(e)}getConfig(){let e=super.getConfig();return delete e.rank,e}static verifyArgs(e){if(typeof e.kernelSize!="number"&&!T1(e.kernelSize,"number",1,2))throw new q(`Conv2D expects config.kernelSize to be number or number[] with length 1 or 2, but received ${JSON.stringify(e.kernelSize)}.`)}},fm=g8;fm.className="Conv2D";ce.registerClass(fm);var y8=class extends qd{constructor(e){super(3,e);y8.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 q(`Conv3D expects config.kernelSize to be number or [number, number, number], but received ${JSON.stringify(e.kernelSize)}.`)}},mm=y8;mm.className="Conv3D";ce.registerClass(mm);var Ax=class extends fm{constructor(e){super(e);if(this.inputSpec=[new tn({ndim:4})],this.padding!=="same"&&this.padding!=="valid")throw new q(`Conv2DTranspose currently supports only padding modes 'same' and 'valid', but received padding mode ${this.padding}`)}build(e){if(e=At(e),e.length!==4)throw new q("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 q("The channel dimension of the inputs should be defined. Found `None`.");let n=e[t],r=this.kernelSize.concat([this.filters,n]);this.kernel=this.addWeight("kernel",r,"float32",this.kernelInitializer,this.kernelRegularizer,!0,this.kernelConstraint),this.useBias&&(this.bias=this.addWeight("bias",[this.filters],"float32",this.biasInitializer,this.biasRegularizer,!0,this.biasConstraint)),this.inputSpec=[new tn({ndim:4,axes:{[t]:n}})],this.built=!0}call(e,t){return Z(()=>{let n=Ke(e);if(n.shape.length!==4)throw new q(`Conv2DTranspose.call() expects input tensor to be rank-4, but received a tensor of rank-${n.shape.length}`);let r=n.shape,s=r[0],a,o;this.dataFormat==="channelsFirst"?(a=2,o=3):(a=1,o=2);let i=r[a],l=r[o],u=this.kernelSize[0],c=this.kernelSize[1],d=this.strides[0],h=this.strides[1],p=Ps(i,d,u,this.padding),f=Ps(l,h,c,this.padding),m=[s,p,f,this.filters];this.dataFormat!=="channelsLast"&&(n=pt(n,[0,2,3,1]));let g=PA(n,this.kernel.read(),m,this.strides,this.padding);return this.dataFormat!=="channelsLast"&&(g=pt(g,[0,3,1,2])),this.bias!=null&&(g=hs(g,this.bias.read(),this.dataFormat)),this.activation!=null&&(g=this.activation.apply(g)),g})}computeOutputShape(e){e=At(e);let t=e.slice(),n,r,s;this.dataFormat==="channelsFirst"?(n=1,r=2,s=3):(n=3,r=1,s=2);let a=this.kernelSize[0],o=this.kernelSize[1],i=this.strides[0],l=this.strides[1];return t[n]=this.filters,t[r]=Ps(t[r],i,a,this.padding),t[s]=Ps(t[s],l,o,this.padding),t}getConfig(){let e=super.getConfig();return delete e.dilationRate,e}};Ax.className="Conv2DTranspose";ce.registerClass(Ax);var xx=class extends mm{constructor(e){super(e);if(this.inputSpec=[new tn({ndim:5})],this.padding!=="same"&&this.padding!=="valid")throw new q(`Conv3DTranspose currently supports only padding modes 'same' and 'valid', but received padding mode ${this.padding}`)}build(e){if(e=At(e),e.length!==5)throw new q("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 q("The channel dimension of the inputs should be defined. Found `None`.");let n=e[t],r=this.kernelSize.concat([this.filters,n]);this.kernel=this.addWeight("kernel",r,"float32",this.kernelInitializer,this.kernelRegularizer,!0,this.kernelConstraint),this.useBias&&(this.bias=this.addWeight("bias",[this.filters],"float32",this.biasInitializer,this.biasRegularizer,!0,this.biasConstraint)),this.inputSpec=[new tn({ndim:5,axes:{[t]:n}})],this.built=!0}call(e,t){return Z(()=>{let n=Ke(e);if(n.shape.length!==5)throw new q(`Conv3DTranspose.call() expects input tensor to be rank-4, but received a tensor of rank-${n.shape.length}`);let r=n.shape,s=r[0],a,o,i;this.dataFormat==="channelsFirst"?(i=2,a=3,o=4):(i=1,a=2,o=3);let l=r[i],u=r[a],c=r[o],d=this.kernelSize[0],h=this.kernelSize[1],p=this.kernelSize[2],f=this.strides[0],m=this.strides[1],g=this.strides[2],y=Ps(l,f,d,this.padding),A=Ps(u,m,h,this.padding),x=Ps(c,g,p,this.padding),b=[s,y,A,x,this.filters];this.dataFormat!=="channelsLast"&&(n=pt(n,[0,2,3,4,1]));let v=Xj(n,this.kernel.read(),b,this.strides,this.padding);return this.dataFormat!=="channelsLast"&&(v=pt(v,[0,4,1,2,3])),this.bias!==null&&(v=hs(v,this.bias.read(),this.dataFormat)),this.activation!==null&&(v=this.activation.apply(v)),v})}computeOutputShape(e){e=At(e);let t=e.slice(),n,r,s,a;this.dataFormat==="channelsFirst"?(n=1,r=2,s=3,a=4):(n=4,r=1,s=2,a=3);let o=this.kernelSize[0],i=this.kernelSize[1],l=this.kernelSize[2],u=this.strides[0],c=this.strides[1],d=this.strides[2];return t[n]=this.filters,t[r]=Ps(t[r],u,o,this.padding),t[s]=Ps(t[s],c,i,this.padding),t[a]=Ps(t[a],d,l,this.padding),t}getConfig(){let e=super.getConfig();return delete e.dilationRate,e}};xx.className="Conv3DTranspose";ce.registerClass(xx);var A8=class extends qd{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 q("The `filters` configuration field is required by SeparableConv, but is unspecified.");if(t.kernelInitializer!=null||t.kernelRegularizer!=null||t.kernelConstraint!=null)throw new q("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 q(`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=zt(t.depthwiseInitializer||this.DEFAULT_DEPTHWISE_INITIALIZER),this.depthwiseRegularizer=Lt(t.depthwiseRegularizer),this.depthwiseConstraint=hn(t.depthwiseConstraint),this.pointwiseInitializer=zt(t.depthwiseInitializer||this.DEFAULT_POINTWISE_INITIALIZER),this.pointwiseRegularizer=Lt(t.pointwiseRegularizer),this.pointwiseConstraint=hn(t.pointwiseConstraint)}build(e){if(e=At(e),e.length<this.rank+2)throw new q(`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 q(`The channel dimension of the inputs should be defined, but found ${JSON.stringify(e[t])}`);let n=e[t],r=this.kernelSize.concat([n,this.depthMultiplier]),s=[];for(let o=0;o<this.rank;++o)s.push(1);s.push(n*this.depthMultiplier,this.filters);let a=!0;this.depthwiseKernel=this.addWeight("depthwise_kernel",r,"float32",this.depthwiseInitializer,this.depthwiseRegularizer,a,this.depthwiseConstraint),this.pointwiseKernel=this.addWeight("pointwise_kernel",s,"float32",this.pointwiseInitializer,this.pointwiseRegularizer,a,this.pointwiseConstraint),this.useBias?this.bias=this.addWeight("bias",[this.filters],"float32",this.biasInitializer,this.biasRegularizer,a,this.biasConstraint):this.bias=null,this.inputSpec=[new tn({ndim:this.rank+2,axes:{[t]:n}})],this.built=!0}call(e,t){return Z(()=>{e=Ke(e);let n;if(this.rank===1)throw new Ge("1D separable convolution is not implemented yet.");return this.rank===2&&(this.dataFormat==="channelsFirst"&&(e=pt(e,[0,2,3,1])),n=bI(e,this.depthwiseKernel.read(),this.pointwiseKernel.read(),this.strides,this.padding,this.dilationRate,"NHWC")),this.useBias&&(n=hs(n,this.bias.read(),this.dataFormat)),this.activation!=null&&(n=this.activation.apply(n)),this.dataFormat==="channelsFirst"&&(n=pt(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=Ht(this.depthwiseInitializer),e.pointwiseInitializer=Ht(this.pointwiseInitializer),e.depthwiseRegularizer=kt(this.depthwiseRegularizer),e.pointwiseRegularizer=kt(this.pointwiseRegularizer),e.depthwiseConstraint=dn(this.depthwiseConstraint),e.pointwiseConstraint=dn(this.pointwiseConstraint),e}};A8.className="SeparableConv";var bx=class extends A8{constructor(e){super(2,e)}};bx.className="SeparableConv2D";ce.registerClass(bx);var x8=class extends qd{constructor(e){super(1,e);x8.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"&&!T1(e.kernelSize,"number",1,1))throw new q(`Conv1D expects config.kernelSize to be number or number[] with length 1, but received ${JSON.stringify(e.kernelSize)}.`)}},vx=x8;vx.className="Conv1D";ce.registerClass(vx);var wx=class extends st{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 Z(()=>{if(e=Ke(e),this.dataFormat==="channelsLast"){let n=Gf(e,this.cropping[0][0],e.shape[1]-this.cropping[0][0]-this.cropping[0][1],2);return Gf(n,this.cropping[1][0],e.shape[2]-this.cropping[1][1]-this.cropping[1][0],3)}else{let n=Gf(e,this.cropping[0][0],e.shape[2]-this.cropping[0][0]-this.cropping[0][1],3);return Gf(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}};wx.className="Cropping2D";ce.registerClass(wx);var kx=class extends st{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,Yt(this.dataFormat),this.interpolation=e.interpolation==null?"nearest":e.interpolation,lee(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 Z(()=>{let n=Ke(e),r=n.shape;if(this.dataFormat==="channelsFirst"){n=pt(n,[0,2,3,1]);let s=this.size[0]*r[2],a=this.size[1]*r[3],o=this.interpolation==="nearest"?n.resizeNearestNeighbor([s,a]):n.resizeBilinear([s,a]);return pt(o,[0,3,1,2])}else{let s=this.size[0]*r[1],a=this.size[1]*r[2];return this.interpolation==="nearest"?n.resizeNearestNeighbor([s,a]):n.resizeBilinear([s,a])}})}getConfig(){let e={size:this.size,dataFormat:this.dataFormat},t=super.getConfig();return Object.assign(e,t),e}};kx.className="UpSampling2D";ce.registerClass(kx);function Kte(e,t,n=[1,1],r="valid",s,a){return Z(()=>{s==null&&(s=us()),Yt(s);let o=gx(e,s);if(e.rank!==4)throw new q(`Input for depthwiseConv2d is required to be 4-D, but is instead ${e.rank}-D`);if(t.rank!==4)throw new q(`depthwiseKernel is required to be 4-D, but is instead ${t.rank}-D`);return o=Td(o,t,n,r==="same"?"same":"valid","NHWC",a),s==="channelsFirst"&&(o=pt(o,[0,3,1,2])),o})}var Ix=class extends yx{constructor(e){super(2,e);this.depthwiseKernel=null,this.depthMultiplier=e.depthMultiplier==null?1:e.depthMultiplier,this.depthwiseInitializer=zt(e.depthwiseInitializer||this.DEFAULT_KERNEL_INITIALIZER),this.depthwiseConstraint=hn(e.depthwiseConstraint),this.depthwiseRegularizer=Lt(e.depthwiseRegularizer)}build(e){if(e=At(e),e.length<4)throw new q(`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 q(`The channel dimension of the inputs to DepthwiseConv2D should be defined, but is not (${e[t]}).`);let n=e[t],r=[this.kernelSize[0],this.kernelSize[1],n,this.depthMultiplier];this.depthwiseKernel=this.addWeight("depthwise_kernel",r,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 Z(()=>{e=Ke(e);let n=Kte(e,this.depthwiseKernel.read(),this.strides,this.padding,this.dataFormat,null);return this.useBias&&(n=hs(n,this.bias.read(),this.dataFormat)),this.activation!=null&&(n=this.activation.apply(n)),n})}computeOutputShape(e){e=At(e);let t=this.dataFormat==="channelsFirst"?e[2]:e[1],n=this.dataFormat==="channelsFirst"?e[3]:e[2],r=this.dataFormat==="channelsFirst"?e[1]*this.depthMultiplier:e[3]*this.depthMultiplier,s=ms(t,this.kernelSize[0],this.padding,this.strides[0]),a=ms(n,this.kernelSize[1],this.padding,this.strides[1]);return this.dataFormat==="channelsFirst"?[e[0],r,s,a]:[e[0],s,a,r]}getConfig(){let e=super.getConfig();return e.depthMultiplier=this.depthMultiplier,e.depthwiseInitializer=Ht(this.depthwiseInitializer),e.depthwiseRegularizer=kt(this.depthwiseRegularizer),e.depthwiseConstraint=dn(this.depthwiseRegularizer),e}};Ix.className="DepthwiseConv2D";ce.registerClass(Ix);function b8(e,t,n,r){if(Array.isArray(e)){if(t!=null||n!=null)throw new q("When inputs is an array, neither initialState or constants should be provided");r!=null&&(n=e.slice(e.length-r,e.length),e=e.slice(0,e.length-r)),e.length>1&&(t=e.slice(1,e.length)),e=e[0]}function s(a){return a==null||Array.isArray(a)?a:[a]}return t=s(t),n=s(n),{inputs:e,initialState:t,constants:n}}function v8(e,t,n,r=!1,s,a,o=!1,i=!1){return Z(()=>{let l=t.shape.length;if(l<3)throw new q(`Input should be at least 3D, but is ${l}D.`);let u=[1,0].concat(ds(2,l));if(t=pt(t,u),a!=null)throw new Ge("The rnn() functoin of the deeplearn.js backend does not support constants yet.");o&&console.warn("Backend rnn(): the unroll = true option is not applicable to the imperative deeplearn.js backend."),s!=null&&(s=s.asType("bool").asType("float32"),s.rank===l-1&&(s=$r(s,-1)),s=pt(s,u)),r&&(t=Fr(t,0),s!=null&&(s=Fr(s,0)));let c=[],d,h=n,p=t.shape[0],f=ls(t),m;s!=null&&(m=ls(s));for(let y=0;y<p;++y){let A=f[y],x=Z(()=>e(A,h));if(s==null)d=x[0],h=x[1];else{let b=Z(()=>{let v=m[y],w=Dr(v).sub(v),I=x[0].mul(v).add(h[0].mul(w)),T=h.map((C,M)=>x[1][M].mul(v).add(C.mul(w)));return{output:I,newStates:T}});d=b.output,h=b.newStates}i&&c.push(d)}let g;return i&&(g=Mr(c,1)),[d,g,h]})}var w8=class extends st{constructor(e){super(e);let t;if(e.cell==null)throw new q("cell property is missing for the constructor of RNN.");if(Array.isArray(e.cell)?t=new Am({cells:e.cell}):t=e.cell,t.stateSize==null)throw new q("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 tn({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 ds(0,e).map(t=>null)}else return this.states_}setStates(e){this.states_=e}computeOutputShape(e){U1(e)&&(e=e[0]),e=e;let t=this.cell.stateSize;Array.isArray(t)||(t=[t]);let n=t[0],r;if(this.returnSequences?r=[e[0],e[1],n]:r=[e[0],n],this.returnState){let s=[];for(let a of t)s.push([e[0],a]);return[r].concat(s)}else return r}computeMask(e,t){return Z(()=>{Array.isArray(t)&&(t=t[0]);let n=this.returnSequences?t:null;if(this.returnState){let r=this.states.map(s=>null);return[n].concat(r)}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 Ge("Constants support is not implemented in RNN yet.");U1(e)&&(e=e[0]),e=e;let n=this.stateful?e[0]:null,r=e.slice(2);this.inputSpec[0]=new tn({shape:[n,null,...r]});let s=[e[0]].concat(e.slice(2));if(t!=null)throw new Ge("Constants support is not implemented in RNN yet.");this.cell.build(s);let a;if(Array.isArray(this.cell.stateSize)?a=this.cell.stateSize:a=[this.cell.stateSize],this.stateSpec!=null){if(!k.arraysEqual(this.stateSpec.map(o=>o.shape[o.shape.length-1]),a))throw new q(`An initialState was passed that is not compatible with cell.stateSize. Received stateSpec=${this.stateSpec}; However cell.stateSize is ${this.cell.stateSize}`)}else this.stateSpec=a.map(o=>new tn({shape:[null,o]}));this.stateful&&this.resetStates()}resetStates(e,t=!1){Z(()=>{if(!this.stateful)throw new da("Cannot call resetStates() on an RNN Layer that is not stateful.");let n=this.inputSpec[0].shape[0];if(n==null)throw new q("If an RNN is stateful, it needs to know its batch size. Specify the batch size of your input tensors: \n- If using a Sequential model, specify the batch size by passing a `batchInputShape` option to your first layer.\n- If using the functional API, specify the batch size by passing a `batchShape` option to your Input layer.");if(this.states_==null)Array.isArray(this.cell.stateSize)?this.states_=this.cell.stateSize.map(r=>un([n,r])):this.states_=[un([n,this.cell.stateSize])];else if(e==null)je(this.states_),this.keptStates!=null&&(je(this.keptStates),this.keptStates=[]),Array.isArray(this.cell.stateSize)?this.states_=this.cell.stateSize.map(r=>un([n,r])):this.states_[0]=un([n,this.cell.stateSize]);else{if(Array.isArray(e)||(e=[e]),e.length!==this.states_.length)throw new q(`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()):je(this.states_);for(let r=0;r<this.states_.length;++r){let s=e[r],a=Array.isArray(this.cell.stateSize)?this.cell.stateSize[r]:this.cell.stateSize,o=[n,a];if(!k.arraysEqual(s.shape,o))throw new q(`State ${r} is incompatible with layer ${this.name}: expected shape=${o}, received shape=${s.shape}`);this.states_[r]=s}}this.states_=this.states_.map(r=>Sn(r.clone()))})}apply(e,t){let n=t==null?null:t.initialState,r=t==null?null:t.constants;t==null&&(t={});let s=b8(e,n,r,this.numConstants);e=s.inputs,n=s.initialState,r=s.constants;let a=[],o=[];if(n!=null){t.initialState=n,a=a.concat(n),this.stateSpec=[];for(let l of n)this.stateSpec.push(new tn({shape:l.shape}));o=o.concat(this.stateSpec)}if(r!=null&&(t.constants=r,a=a.concat(r),this.numConstants=r.length),a[0]instanceof ps){let l=[e].concat(a),u=this.inputSpec.concat(o),c=this.inputSpec;this.inputSpec=u;let d=super.apply(l,t);return this.inputSpec=c,d}else return super.apply(e,t)}call(e,t){return Z(()=>{let n=t==null?null:t.mask,r=t==null?null:t.training,s=t==null?null:t.initialState;e=Ke(e),s==null&&(this.stateful?s=this.states_:s=this.getInitialState(e));let a=Array.isArray(this.cell.stateSize)?this.cell.stateSize.length:1;if(s.length!==a)throw new q(`RNN Layer has ${a} state(s) but was passed ${s.length} initial state(s).`);this.unroll&&console.warn("Ignoring unroll = true for RNN layer, due to imperative backend.");let o={training:r},l=v8((p,f)=>{let m=this.cell.call([p].concat(f),o);return[m[0],m.slice(1)]},e,s,this.goBackwards,n,null,this.unroll,this.returnSequences),u=l[0],c=l[1],d=l[2];this.stateful&&this.resetStates(d,r);let h=this.returnSequences?c:u;return this.returnState?[h].concat(d):h})}getInitialState(e){return Z(()=>{let t=un(e.shape);return t=_e(t,[1,2]),t=Ld(t),Array.isArray(this.cell.stateSize)?this.cell.stateSize.map(n=>n>1?F1(t,[1,n]):t):this.cell.stateSize>1?[F1(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()===w8.className&&(t.cell={className:this.cell.getClassName(),config:n}),{...n,...e,...t}}static fromConfig(e,t,n={}){let r=t.cell,s=fs(r,n);return new e(Object.assign(t,{cell:s}))}},fa=w8;fa.className="RNN";ce.registerClass(fa);var Kd=class extends st{},gm=class extends Kd{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,An(this.units,"units"),this.activation=Za(e.activation==null?this.DEFAULT_ACTIVATION:e.activation),this.useBias=e.useBias==null?!0:e.useBias,this.kernelInitializer=zt(e.kernelInitializer||this.DEFAULT_KERNEL_INITIALIZER),this.recurrentInitializer=zt(e.recurrentInitializer||this.DEFAULT_RECURRENT_INITIALIZER),this.biasInitializer=zt(e.biasInitializer||this.DEFAULT_BIAS_INITIALIZER),this.kernelRegularizer=Lt(e.kernelRegularizer),this.recurrentRegularizer=Lt(e.recurrentRegularizer),this.biasRegularizer=Lt(e.biasRegularizer),this.kernelConstraint=hn(e.kernelConstraint),this.recurrentConstraint=hn(e.recurrentConstraint),this.biasConstraint=hn(e.biasConstraint),this.dropout=ru([1,qa([0,e.dropout==null?0:e.dropout])]),this.recurrentDropout=ru([1,qa([0,e.recurrentDropout==null?0:e.recurrentDropout])]),this.stateSize=this.units,this.dropoutMask=null,this.recurrentDropoutMask=null}build(e){e=At(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 Z(()=>{if(e=e,e.length!==2)throw new q(`SimpleRNNCell expects 2 input Tensors, got ${e.length}.`);let n=e[1];e=e[0];let r=t.training==null?!1:t.training;0<this.dropout&&this.dropout<1&&this.dropoutMask==null&&(this.dropoutMask=Ya({ones:()=>Dr(e),rate:this.dropout,training:r})),0<this.recurrentDropout&&this.recurrentDropout<1&&this.recurrentDropoutMask==null&&(this.recurrentDropoutMask=Ya({ones:()=>Dr(n),rate:this.recurrentDropout,training:r}));let s,a=this.dropoutMask,o=this.recurrentDropoutMask;a!=null?s=Fs(K(e,a),this.kernel.read()):s=Fs(e,this.kernel.read()),this.bias!=null&&(s=hs(s,this.bias.read())),o!=null&&(n=K(n,o));let i=pe(s,Fs(n,this.recurrentKernel.read()));return this.activation!=null&&(i=this.activation.apply(i)),[i,i]})}getConfig(){let e=super.getConfig(),t={units:this.units,activation:Xa(this.activation),useBias:this.useBias,kernelInitializer:Ht(this.kernelInitializer),recurrentInitializer:Ht(this.recurrentInitializer),biasInitializer:Ht(this.biasInitializer),kernelRegularizer:kt(this.kernelRegularizer),recurrentRegularizer:kt(this.recurrentRegularizer),biasRegularizer:kt(this.biasRegularizer),activityRegularizer:kt(this.activityRegularizer),kernelConstraint:dn(this.kernelConstraint),recurrentConstraint:dn(this.recurrentConstraint),biasConstraint:dn(this.biasConstraint),dropout:this.dropout,recurrentDropout:this.recurrentDropout};return{...e,...t}}};gm.className="SimpleRNNCell";ce.registerClass(gm);var Sx=class extends fa{constructor(e){e.cell=new gm(e),super(e)}call(e,t){return Z(()=>{this.cell.dropoutMask!=null&&(je(this.cell.dropoutMask),this.cell.dropoutMask=null),this.cell.recurrentDropoutMask!=null&&(je(this.cell.recurrentDropoutMask),this.cell.recurrentDropoutMask=null);let n=t==null?null:t.mask,r=t==null?null:t.training,s=t==null?null:t.initialState;return super.call(e,{mask:n,training:r,initialState:s})})}static fromConfig(e,t){return new e(t)}};Sx.className="SimpleRNN";ce.registerClass(Sx);var ym=class extends Kd{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 q("GRUCell does not support reset_after parameter set to true.");this.units=e.units,An(this.units,"units"),this.activation=Za(e.activation===void 0?this.DEFAULT_ACTIVATION:e.activation),this.recurrentActivation=Za(e.recurrentActivation===void 0?this.DEFAULT_RECURRENT_ACTIVATION:e.recurrentActivation),this.useBias=e.useBias==null?!0:e.useBias,this.kernelInitializer=zt(e.kernelInitializer||this.DEFAULT_KERNEL_INITIALIZER),this.recurrentInitializer=zt(e.recurrentInitializer||this.DEFAULT_RECURRENT_INITIALIZER),this.biasInitializer=zt(e.biasInitializer||this.DEFAULT_BIAS_INITIALIZER),this.kernelRegularizer=Lt(e.kernelRegularizer),this.recurrentRegularizer=Lt(e.recurrentRegularizer),this.biasRegularizer=Lt(e.biasRegularizer),this.kernelConstraint=hn(e.kernelConstraint),this.recurrentConstraint=hn(e.recurrentConstraint),this.biasConstraint=hn(e.biasConstraint),this.dropout=ru([1,qa([0,e.dropout==null?0:e.dropout])]),this.recurrentDropout=ru([1,qa([0,e.recurrentDropout==null?0:e.recurrentDropout])]),this.implementation=e.implementation,this.stateSize=this.units,this.dropoutMask=null,this.recurrentDropoutMask=null}build(e){e=At(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 Z(()=>{if(e=e,e.length!==2)throw new q(`GRUCell expects 2 input Tensors (inputs, h, c), got ${e.length}.`);let n=t.training==null?!1:t.training,r=e[1];e=e[0],0<this.dropout&&this.dropout<1&&this.dropoutMask==null&&(this.dropoutMask=Ya({ones:()=>Dr(e),rate:this.dropout,training:n,count:3})),0<this.recurrentDropout&&this.recurrentDropout<1&&this.recurrentDropoutMask==null&&(this.recurrentDropoutMask=Ya({ones:()=>Dr(r),rate:this.recurrentDropout,training:n,count:3}));let s=this.dropoutMask,a=this.recurrentDropoutMask,o,i,l;0<this.dropout&&this.dropout<1&&(e=K(e,s[0]));let u=Fs(e,this.kernel.read());this.useBias&&(u=hs(u,this.bias.read())),0<this.recurrentDropout&&this.recurrentDropout<1&&(r=K(r,a[0]));let c=this.recurrentKernel.read(),[d,h]=dr(c,[2*this.units,this.units],c.rank-1),p=Fs(r,d),[f,m,g]=dr(u,3,u.rank-1),[y,A]=dr(p,2,p.rank-1);o=this.recurrentActivation.apply(pe(f,y)),i=this.recurrentActivation.apply(pe(m,A));let x=Fs(K(i,r),h);l=this.activation.apply(pe(g,x));let b=pe(K(o,r),K(pe(1,Kt(o)),l));return[b,b]})}getConfig(){let e=super.getConfig(),t={units:this.units,activation:Xa(this.activation),recurrentActivation:Xa(this.recurrentActivation),useBias:this.useBias,kernelInitializer:Ht(this.kernelInitializer),recurrentInitializer:Ht(this.recurrentInitializer),biasInitializer:Ht(this.biasInitializer),kernelRegularizer:kt(this.kernelRegularizer),recurrentRegularizer:kt(this.recurrentRegularizer),biasRegularizer:kt(this.biasRegularizer),activityRegularizer:kt(this.activityRegularizer),kernelConstraint:dn(this.kernelConstraint),recurrentConstraint:dn(this.recurrentConstraint),biasConstraint:dn(this.biasConstraint),dropout:this.dropout,recurrentDropout:this.recurrentDropout,implementation:this.implementation,resetAfter:!1};return{...e,...t}}};ym.className="GRUCell";ce.registerClass(ym);var Tx=class extends fa{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 ym(e),super(e)}call(e,t){return Z(()=>{this.cell.dropoutMask!=null&&(je(this.cell.dropoutMask),this.cell.dropoutMask=null),this.cell.recurrentDropoutMask!=null&&(je(this.cell.recurrentDropoutMask),this.cell.recurrentDropoutMask=null);let n=t==null?null:t.mask,r=t==null?null:t.training,s=t==null?null:t.initialState;return super.call(e,{mask:n,training:r,initialState:s})})}static fromConfig(e,t){return t.implmentation===0&&(t.implementation=1),new e(t)}};Tx.className="GRU";ce.registerClass(Tx);var Xd=class extends Kd{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,An(this.units,"units"),this.activation=Za(e.activation===void 0?this.DEFAULT_ACTIVATION:e.activation),this.recurrentActivation=Za(e.recurrentActivation===void 0?this.DEFAULT_RECURRENT_ACTIVATION:e.recurrentActivation),this.useBias=e.useBias==null?!0:e.useBias,this.kernelInitializer=zt(e.kernelInitializer||this.DEFAULT_KERNEL_INITIALIZER),this.recurrentInitializer=zt(e.recurrentInitializer||this.DEFAULT_RECURRENT_INITIALIZER),this.biasInitializer=zt(e.biasInitializer||this.DEFAULT_BIAS_INITIALIZER),this.unitForgetBias=e.unitForgetBias,this.kernelRegularizer=Lt(e.kernelRegularizer),this.recurrentRegularizer=Lt(e.recurrentRegularizer),this.biasRegularizer=Lt(e.biasRegularizer),this.kernelConstraint=hn(e.kernelConstraint),this.recurrentConstraint=hn(e.recurrentConstraint),this.biasConstraint=hn(e.biasConstraint),this.dropout=ru([1,qa([0,e.dropout==null?0:e.dropout])]),this.recurrentDropout=ru([1,qa([0,e.recurrentDropout==null?0:e.recurrentDropout])]),this.implementation=e.implementation,this.stateSize=[this.units,this.units],this.dropoutMask=null,this.recurrentDropoutMask=null}build(e){var t;e=At(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 r;if(this.useBias){if(this.unitForgetBias){let s=this.biasInitializer,a=this.units;r=new(t=class extends Zr{apply(o,i){let l=s.apply([a]),u=new qf().apply([a]),c=s.apply([a*2]);return pS(pS(l,u),c)}},t.className="CustomInit",t)}else r=this.biasInitializer;this.bias=this.addWeight("bias",[this.units*4],null,r,this.biasRegularizer,!0,this.biasConstraint)}else this.bias=null;this.built=!0}call(e,t){return Z(()=>{let n=t.training==null?!1:t.training;if(e=e,e.length!==3)throw new q(`LSTMCell expects 3 input Tensors (inputs, h, c), got ${e.length}.`);let r=e[1],s=e[2];e=e[0],0<this.dropout&&this.dropout<1&&this.dropoutMask==null&&(this.dropoutMask=Ya({ones:()=>Dr(e),rate:this.dropout,training:n,count:4})),0<this.recurrentDropout&&this.recurrentDropout<1&&this.recurrentDropoutMask==null&&(this.recurrentDropoutMask=Ya({ones:()=>Dr(r),rate:this.recurrentDropout,training:n,count:4}));let a=this.dropoutMask,o=this.recurrentDropoutMask,i,l,u,c;0<this.dropout&&this.dropout<1&&(e=K(e,a[0]));let d=Fs(e,this.kernel.read());0<this.recurrentDropout&&this.recurrentDropout<1&&(r=K(r,o[0])),d=pe(d,Fs(r,this.recurrentKernel.read())),this.useBias&&(d=hs(d,this.bias.read()));let[h,p,f,m]=dr(d,4,d.rank-1);i=this.recurrentActivation.apply(h),l=this.recurrentActivation.apply(p),u=pe(K(l,s),K(i,this.activation.apply(f))),c=this.recurrentActivation.apply(m);let g=K(c,this.activation.apply(u));return[g,g,u]})}getConfig(){let e=super.getConfig(),t={units:this.units,activation:Xa(this.activation),recurrentActivation:Xa(this.recurrentActivation),useBias:this.useBias,kernelInitializer:Ht(this.kernelInitializer),recurrentInitializer:Ht(this.recurrentInitializer),biasInitializer:Ht(this.biasInitializer),unitForgetBias:this.unitForgetBias,kernelRegularizer:kt(this.kernelRegularizer),recurrentRegularizer:kt(this.recurrentRegularizer),biasRegularizer:kt(this.biasRegularizer),activityRegularizer:kt(this.activityRegularizer),kernelConstraint:dn(this.kernelConstraint),recurrentConstraint:dn(this.recurrentConstraint),biasConstraint:dn(this.biasConstraint),dropout:this.dropout,recurrentDropout:this.recurrentDropout,implementation:this.implementation};return{...e,...t}}};Xd.className="LSTMCell";ce.registerClass(Xd);var Nx=class extends fa{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 Xd(e),super(e)}call(e,t){return Z(()=>{this.cell.dropoutMask!=null&&(je(this.cell.dropoutMask),this.cell.dropoutMask=null),this.cell.recurrentDropoutMask!=null&&(je(this.cell.recurrentDropoutMask),this.cell.recurrentDropoutMask=null);let n=t==null?null:t.mask,r=t==null?null:t.training,s=t==null?null:t.initialState;return super.call(e,{mask:n,training:r,initialState:s})})}static fromConfig(e,t){return t.implmentation===0&&(t.implementation=1),new e(t)}};Nx.className="LSTM";ce.registerClass(Nx);var Am=class extends Kd{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 Z(()=>{e=e;let n=e.slice(1),r=[];for(let o of this.cells.slice().reverse())Array.isArray(o.stateSize)?r.push(n.splice(0,o.stateSize.length)):r.push(n.splice(0,1));r.reverse();let s=[],a;for(let o=0;o<this.cells.length;++o){let i=this.cells[o];n=r[o],o===0?a=[e[0]].concat(n):a=[a[0]].concat(n),a=i.call(a,t),s.push(a.slice(1))}n=[];for(let o of s.slice().reverse())n.push(...o);return[a[0]].concat(n)})}build(e){U1(e)&&(e=e[0]),e=e;let t;this.cells.forEach((n,r)=>{ii(`RNNCell_${r}`,()=>{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=s=>({className:s.getClassName(),config:s.getConfig()}),r={cells:this.cells.map(t)};return{...e,...r}}static fromConfig(e,t,n={}){let r=[];for(let s of t.cells)r.push(fs(s,n));return new e({cells:r})}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 H1(e)}setWeights(e){let t=[];for(let n of this.cells){let r=n.weights.length,s=e.splice(r);for(let a=0;a<n.weights.length;++a)t.push([n.weights[a],s[a]])}G1(t)}};Am.className="StackedRNNCells";ce.registerClass(Am);function Ya(e){let{ones:t,rate:n,training:r=!1,count:s=1}=e,a=()=>mS(t(),n),o=()=>Wd(a,t,r);return!s||s<=1?Sn(o().clone()):Array(s).fill(void 0).map(o).map(l=>Sn(l.clone()))}var k8=class extends fa{constructor(e){if(e.unroll)throw new Ge("Unrolling is not possible with convolutional RNNs.");if(Array.isArray(e.cell))throw new Ge("It is not possible at the moment to stack convolutional cells.");super(e);this.inputSpec=[new tn({ndim:5})]}call(e,t){return Z(()=>{if(this.cell.dropoutMask!=null&&(je(this.cell.dropoutMask),this.cell.dropoutMask=null),this.cell.recurrentDropoutMask!=null&&(je(this.cell.recurrentDropoutMask),this.cell.recurrentDropoutMask=null),t&&t.constants)throw new q("ConvRNN2D cell does not support constants");let n=t==null?null:t.mask,r=t==null?null:t.training,s=t==null?null:t.initialState;return super.call(e,{mask:n,training:r,initialState:s})})}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 Z(()=>{let{stateSize:t}=this.cell,n=e.shape,r=this.computeSingleOutputShape(n),s=[r[0],...r.slice(2)],a=un(s);return Array.isArray(t)?Array(t.length).fill(a):[a]})}resetStates(e,t=!1){Z(()=>{if(!this.stateful)throw new da("Cannot call resetStates() on an RNN Layer that is not stateful.");let n=this.inputSpec[0].shape,r=this.computeSingleOutputShape(n),s=[r[0],...r.slice(2)];if(n[0]==null)throw new q("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(()=>un(s)):this.states_=[un(s)];else if(e==null)je(this.states_),this.keptStates!=null&&(je(this.keptStates),this.keptStates=[]),Array.isArray(this.cell.stateSize)?this.states_=this.cell.stateSize.map(()=>un(s)):this.states_[0]=un(s);else{if(Array.isArray(e)||(e=[e]),e.length!==this.states_.length)throw new q(`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()):je(this.states_);for(let o=0;o<this.states_.length;++o){let i=e[o],l=s;if(!k.arraysEqual(i.shape,l))throw new q(`State ${o} is incompatible with layer ${this.name}: expected shape=${l}, received shape=${i.shape}`);this.states_[o]=i}}this.states_=this.states_.map(o=>Sn(o.clone()))})}computeSingleOutputShape(e){let{dataFormat:t,filters:n,kernelSize:r,padding:s,strides:a,dilationRate:o}=this.cell,i=t==="channelsFirst",l=e[i?3:2],u=e[i?4:3],c=ms(l,r[0],s,a[0],o[0]),d=ms(u,r[1],s,a[1],o[1]);return[...e.slice(0,2),...i?[n,c,d]:[c,d,n]]}};k8.className="ConvRNN2D";var xm=class extends Xd{constructor(e){let{filters:t,kernelSize:n,strides:r,padding:s,dataFormat:a,dilationRate:o}=e;super({...e,units:t});this.filters=t,An(this.filters,"filters"),this.kernelSize=iu(n,2,"kernelSize"),this.kernelSize.forEach(i=>An(i,"kernelSize")),this.strides=iu(r||1,2,"strides"),this.strides.forEach(i=>An(i,"strides")),this.padding=s||"valid",Or(this.padding),this.dataFormat=a||"channelsLast",Yt(this.dataFormat),this.dilationRate=iu(o||1,2,"dilationRate"),this.dilationRate.forEach(i=>An(i,"dilationRate"))}build(e){var t;e=At(e);let n=this.dataFormat==="channelsFirst"?1:e.length-1;if(e[n]==null)throw new q(`The channel dimension of the input should be defined. Found ${e[n]}`);let r=e[n],s=4,a=this.kernelSize.concat([r,this.filters*s]);this.kernel=this.addWeight("kernel",a,null,this.kernelInitializer,this.kernelRegularizer,!0,this.kernelConstraint);let o=this.kernelSize.concat([this.filters,this.filters*s]);if(this.recurrentKernel=this.addWeight("recurrent_kernel",o,null,this.recurrentInitializer,this.recurrentRegularizer,!0,this.recurrentConstraint),this.useBias){let i;if(this.unitForgetBias){let l=this.biasInitializer,u=this.filters;i=new(t=class extends Zr{apply(c,d){let h=l.apply([u]),p=la([u]),f=l.apply([u*2]);return D1([h,p,f])}},t.className="CustomInit",t)}else i=this.biasInitializer;this.bias=this.addWeight("bias",[this.filters*s],null,i,this.biasRegularizer,!0,this.biasConstraint)}this.built=!0}call(e,t){return Z(()=>{if(e.length!==3)throw new q(`ConvLSTM2DCell expects 3 input Tensors (inputs, h, c), got ${e.length}.`);let n=t.training||!1,r=e[0],s=e[1],a=e[2],o=4;0<this.dropout&&this.dropout<1&&this.dropoutMask==null&&(this.dropoutMask=Ya({ones:()=>Dr(r),rate:this.dropout,training:n,count:o}));let i=this.dropoutMask,l=(ee,oe,se)=>!oe||!oe[se]?ee:K(oe[se],ee),u=l(r,i,0),c=l(r,i,1),d=l(r,i,2),h=l(r,i,3);0<this.recurrentDropout&&this.recurrentDropout<1&&this.recurrentDropoutMask==null&&(this.recurrentDropoutMask=Ya({ones:()=>Dr(s),rate:this.recurrentDropout,training:n,count:o}));let p=this.recurrentDropoutMask,f=l(s,p,0),m=l(s,p,1),g=l(s,p,2),y=l(s,p,3),A=3,[x,b,v,w]=dr(this.kernel.read(),o,A),[I,T,C,M]=this.useBias?dr(this.bias.read(),o):[null,null,null,null];u=this.inputConv(u,x,I,this.padding),c=this.inputConv(c,b,T,this.padding),d=this.inputConv(d,v,C,this.padding),h=this.inputConv(h,w,M,this.padding);let[$,R,N,F]=dr(this.recurrentKernel.read(),o,A);f=this.recurrentConv(f,$),m=this.recurrentConv(m,R),g=this.recurrentConv(g,N),y=this.recurrentConv(y,F);let B=this.recurrentActivation.apply(pe(u,f)),j=this.recurrentActivation.apply(pe(c,m)),X=pe(K(j,a),K(B,this.activation.apply(pe(d,g)))),Y=K(this.recurrentActivation.apply(pe(h,y)),this.activation.apply(X));return[Y,Y,X]})}getConfig(){let{units:e,...t}=super.getConfig(),n={filters:this.filters,kernelSize:this.kernelSize,padding:this.padding,dataFormat:this.dataFormat,dilationRate:this.dilationRate,strides:this.strides};return{...t,...n}}inputConv(e,t,n,r){let s=Ba(e,t,this.strides,r||"valid",this.dataFormat==="channelsFirst"?"NCHW":"NHWC",this.dilationRate);return n?hs(s,n,this.dataFormat):s}recurrentConv(e,t){return Ba(e,t,1,"same",this.dataFormat==="channelsFirst"?"NCHW":"NHWC")}};xm.className="ConvLSTM2DCell";ce.registerClass(xm);var Cx=class extends k8{constructor(e){let t=new xm(e);super({...e,cell:t})}static fromConfig(e,t){return new e(t)}};Cx.className="ConvLSTM2D";ce.registerClass(Cx);var bm=class extends st{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 r=0;r<this.noiseShape.length;++r)n.push(this.noiseShape[r]==null?t[r]:this.noiseShape[r]);return n}call(e,t){return Z(()=>{this.invokeCallHook(e,t);let n=Ke(e);if(0<this.rate&&this.rate<1){let r=t.training==null?!1:t.training,s=this.getNoiseShape(n);return Wd(()=>mS(n,this.rate,s,this.seed),()=>n,r)}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()}};bm.className="Dropout";ce.registerClass(bm);var Ex=class extends bm{constructor(e){super(e);this.inputSpec=[{ndim:3}]}getNoiseShape(e){let t=e.shape;return[t[0],1,t[2]]}};Ex.className="SpatialDropout1D";ce.registerClass(Ex);var $x=class extends st{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,An(this.units,"units"),this.activation=Za(e.activation),e.useBias!=null&&(this.useBias=e.useBias),this.kernelInitializer=zt(e.kernelInitializer||this.DEFAULT_KERNEL_INITIALIZER),this.biasInitializer=zt(e.biasInitializer||this.DEFAULT_BIAS_INITIALIZER),this.kernelConstraint=hn(e.kernelConstraint),this.biasConstraint=hn(e.biasConstraint),this.kernelRegularizer=Lt(e.kernelRegularizer),this.biasRegularizer=Lt(e.biasRegularizer),this.activityRegularizer=Lt(e.activityRegularizer),this.supportsMasking=!0,this.inputSpec=[{minNDim:2}]}build(e){e=At(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=At(e);let t=e.slice();return t[t.length-1]=this.units,t}call(e,t){return Z(()=>{this.invokeCallHook(e,t);let n=Ke(e),r=sS(this.activation.getClassName()),s;return r!=null?s=Fs(n,this.kernel.read(),r,this.bias?this.bias.read():null):(s=Fs(n,this.kernel.read()),this.bias!=null&&(s=hs(s,this.bias.read())),this.activation!=null&&(s=this.activation.apply(s))),s})}getConfig(){let e={units:this.units,activation:Xa(this.activation),useBias:this.useBias,kernelInitializer:Ht(this.kernelInitializer),biasInitializer:Ht(this.biasInitializer),kernelRegularizer:kt(this.kernelRegularizer),biasRegularizer:kt(this.biasRegularizer),activityRegularizer:kt(this.activityRegularizer),kernelConstraint:dn(this.kernelConstraint),biasConstraint:dn(this.biasConstraint)},t=super.getConfig();return Object.assign(e,t),e}};$x.className="Dense";ce.registerClass($x);var _x=class extends st{constructor(e){e=e||{},super(e),this.inputSpec=[{minNDim:3}],this.dataFormat=e.dataFormat}computeOutputShape(e){e=At(e);for(let t of e.slice(1))if(t==null)throw new q(`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],ja(e,1)]}call(e,t){return Z(()=>{this.invokeCallHook(e,t);let n=Ke(e);if(this.dataFormat==="channelsFirst"&&n.rank>1){let r=[0];for(let s=2;s<n.rank;++s)r.push(s);r.push(1),n=n.transpose(r)}return fee(n)})}getConfig(){let e={};this.dataFormat!=null&&(e.dataFormat=this.dataFormat);let t=super.getConfig();return Object.assign(e,t),e}};_x.className="Flatten";ce.registerClass(_x);var Rx=class extends st{constructor(e){super(e);this.supportsMasking=!0,this.activation=Za(e.activation)}call(e,t){return Z(()=>{this.invokeCallHook(e,t);let n=Ke(e);return this.activation.apply(n)})}getConfig(){let e={activation:Xa(this.activation)},t=super.getConfig();return Object.assign(e,t),e}};Rx.className="Activation";ce.registerClass(Rx);var Dx=class extends st{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 Z(()=>(e=Ke(e),hee(e,this.n)))}getConfig(){let e={n:this.n},t=super.getConfig();return Object.assign(e,t),e}};Dx.className="RepeatVector";ce.registerClass(Dx);var Fx=class extends st{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.",r=t.slice(),s=1,a=null;for(let i=0;i<r.length;++i){let l=r[i];if(this.isUnknown(l))if(a===null)a=i;else throw new q("Can only specifiy one unknown dimension.");else s*=l}let o=ja(e);if(a!==null){if(s===0||o%s!=0)throw new q(n);r[a]=o/s}else if(o!==s)throw new q(n);return r}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 Z(()=>{this.invokeCallHook(e,t);let n=Ke(e),r=n.shape,s=r.slice(0,1).concat(this.fixUnknownDimension(r.slice(1),this.targetShape));return n.reshape(s)})}getConfig(){let e={targetShape:this.targetShape},t=super.getConfig();return Object.assign(e,t),e}};Fx.className="Reshape";ce.registerClass(Fx);var Mx=class extends st{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=ds(1,e.dims.length+1);if(!k.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 tn({ndim:this.dims.length+1})]}computeOutputShape(e){e=At(e);let t=e.slice();return this.dims.forEach((n,r)=>{t[r+1]=e[n]}),t}call(e,t){return pt(Ke(e),this.dimsIncludingBatch)}getConfig(){let e={dims:this.dims},t=super.getConfig();return Object.assign(e,t),e}};Mx.className="Permute";ce.registerClass(Mx);var Ox=class extends st{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=Ke(e),r=-1;return wf(Yl(n,this.maskValue),r)}call(e,t){return Z(()=>{this.invokeCallHook(e,t);let n=Ke(e),r=-1,s=!0,a=wf(Yl(n,this.maskValue),r,s);return n.mul(a.asType(n.dtype))})}};Ox.className="Masking";ce.registerClass(Ox);var Px=class extends st{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(Dt(e.inputLength))}this.inputDim=e.inputDim,An(this.inputDim,"inputDim"),this.outputDim=e.outputDim,An(this.outputDim,"outputDim"),this.embeddingsInitializer=zt(e.embeddingsInitializer||this.DEFAULT_EMBEDDINGS_INITIALIZER),this.embeddingsRegularizer=Lt(e.embeddingsRegularizer),this.activityRegularizer=Lt(e.activityRegularizer),this.embeddingsConstraint=hn(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 Z(()=>this.maskZero?(e=Ke(e),Yl(e,rt(e))):null)}computeOutputShape(e){if(e=At(e),this.inputLength==null)return[...e,this.outputDim];let t=Dt(this.inputLength);if(t.length!==e.length-1)throw new q(`"inputLength" is ${this.inputLength}, but received input shape has shape ${e}`);{let n=0;for(let r=0;r<t.length;++r){let s=t[r],a=e[r+1];if(s!=null&&a!=null&&s!==a)throw new q(`"inputLength" is ${this.inputLength}, but received input shape has shape ${e}`);s==null&&(t[n]=a),n++}}return[e[0],...t,this.outputDim]}call(e,t){return Z(()=>{this.invokeCallHook(e,t);let n=Ke(e);return n.dtype!=="int32"&&(n=zd(n,"int32")),fS(this.embeddings.read(),n.as1D()).reshape(At(this.computeOutputShape(n.shape)))})}getConfig(){let e={inputDim:this.inputDim,outputDim:this.outputDim,embeddingsInitializer:Ht(this.embeddingsInitializer),embeddingsRegularizer:kt(this.embeddingsRegularizer),activityRegularizer:kt(this.activityRegularizer),embeddingsConstraint:dn(this.embeddingsConstraint),maskZero:this.maskZero,inputLength:this.inputLength},t=super.getConfig();return Object.assign(e,t),e}};Px.className="Embedding";ce.registerClass(Px);var hi=class extends st{constructor(e){super(e||{});this.supportsMasking=!0}mergeFunction(e){throw new Ge}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 r=0;r<t.length;++r){let s=e[e.length-t.length+r],a=t[r];if(s==null||a==null||s<0||a<0)n.push(null);else if(s===1)n.push(a);else if(a===1)n.push(s);else{if(s!==a)throw new q("Operands could not be broadcast together with shapes "+JSON.stringify(e)+" "+JSON.stringify(t));n.push(s)}}return n}build(e){if(Array.isArray(e)&&!Array.isArray(e[0])&&(e=[At(e)]),e=e,e.length<2)throw new q(`A merge layer should be called on an Array of at least 2 inputs. Got ${e.length} input(s).`);let t=[];for(let s of e)s!=null&&s[0]!==null&&t.push(s[0]);if(t=Ga(t),t.length>1)throw new q(`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 s=1;s<e.length;++s){let a=e[s]==null?null:e[s].slice(1);n=this.computeElementwiseOpOutputShape(n,a)}let r=e.map(s=>s.length);e.indexOf(null)===-1&&Ga(r).length===1?this.reshapeRequired=!1:this.reshapeRequired=!0}call(e,t){return Z(()=>{if(e=e,this.reshapeRequired){let n=[],r=e.map(s=>s.rank);if(r.indexOf(null)===-1){let s=qa(r);for(let a of e){let o=a.rank;for(let i=0;i<s-o;++i)a=Ld(a,1);n.push(a)}return this.mergeFunction(n)}else{let s=!1;for(let i of e){let l=i.rank;if(l==null){let u=i.shape,c=u[0],d=u.slice(1).concat([c]),h=i.reshape([c].concat(ja(u.slice(1))));h=pt(h,[1,0]),h=h.reshape(d),n.push(h),s=!0}else if(l>1){let u=ds(1,l).concat([0]);n.push(pt(i,u)),s=!0}else n.push(i)}let a=this.mergeFunction(n),o=a.rank;if(s){if(o==null){let i=a.shape,l=i.length,u=i[l-1],c=[u].concat(i.slice(0,i.length-1));a=pt(a.reshape([-1,u]),[1,0]).reshape(c)}else if(o>1){let i=[o-1].concat(ds(0,o-1));a=pt(a,i)}}return a}}else return this.mergeFunction(e)})}computeOutputShape(e){e=e;let t;e[0]==null?t=null:t=e[0].slice(1);for(let r=1;r<e.length;++r){let s=e[r]==null?null:e[r].slice(1);t=this.computeElementwiseOpOutputShape(t,s)}let n=[];for(let r of e)r!=null&&r[0]!==null&&n.push(r[0]);return n=Ga(n),n.length===1?t=n.concat(t):t=[null].concat(t),t}computeMask(e,t){return Z(()=>{if(t==null)return null;if(!Array.isArray(t))throw new q("`mask` should be an Array");if(!Array.isArray(e))throw new q("`inputs` should be an Array");if(t.length!==e.length)throw new q(`The Array 'inputs' and 'mask' are expected to have the same length, but have different lengths (${e.length} vs ${t.length})`);if(t.every(r=>r==null))return null;t=t.map(r=>r==null?r:$r(r,0));let n=t[0];for(let r=1;r<t.length-1;++r)n=is(n,t[r]);return n})}},zx=class extends hi{constructor(e){super(e)}mergeFunction(e){return Z(()=>{let t=e[0].clone();for(let n=1;n<e.length;++n)t=pe(t,e[n]);return t})}};zx.className="Add";ce.registerClass(zx);var Lx=class extends hi{constructor(e){super(e)}mergeFunction(e){return Z(()=>{let t=e[0].clone();for(let n=1;n<e.length;++n)t=K(t,e[n]);return t})}};Lx.className="Multiply";ce.registerClass(Lx);var Bx=class extends hi{constructor(e){super(e)}mergeFunction(e){return Z(()=>{let t=e[0].clone();for(let n=1;n<e.length;++n)t=pe(t,e[n]);return K(1/e.length,t)})}};Bx.className="Average";ce.registerClass(Bx);var Wx=class extends hi{constructor(e){super(e)}mergeFunction(e){return Z(()=>{let t=e[0];for(let n=1;n<e.length;++n)t=ia(t,e[n]);return t})}};Wx.className="Maximum";ce.registerClass(Wx);var Vx=class extends hi{constructor(e){super(e)}mergeFunction(e){return Z(()=>{let t=e[0];for(let n=1;n<e.length;++n)t=_d(t,e[n]);return t})}};Vx.className="Minimum";ce.registerClass(Vx);var Ux=class extends hi{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 q("A `Concatenate` layer should be called on a list of at least 2 inputs");e=e;let t=!0;for(let r of e)if(r!=null){t=!1;break}if(t)return;let n=[];for(let r=0;r<e.length;++r){let s=e[r].slice();s.splice(this.axis,1);let a=!1;for(let o of n)if(k.arraysEqual(o,s)){a=!0;break}a||n.push(s)}if(n.length>1)throw new q("A `Concatenate` layer requires inputs with matching shapes except for the concat axis. Got input shapes: "+JSON.stringify(e))}mergeFunction(e){return Z(()=>D1(e,this.axis))}computeOutputShape(e){if(!(Array.isArray(e)&&Array.isArray(e[0])))throw new q("A `Concatenate` layer should be called on a list of inputs.");let t=e,n=t[0].slice(),r=this.axis<0?n.length+this.axis:this.axis;for(let s of t.slice(1)){if(n[r]==null||s[r]==null){n[r]=null;break}n[r]+=s[r]}return n}computeMask(e,t){if(t==null)return null;if(!Array.isArray(t))throw new q("`mask` should be an array for Concatenate");if(!Array.isArray(e))throw new q("`inputs` should be an array for Concatenate");if(t.length!==e.length)throw new q(`Mismatch in the length of mask (${t.length}) and the legnth of inputs (${e.length})`);return Z(()=>{let n=!0;if(t.forEach(a=>{if(a!=null){n=!1;return}}),n)return null;let r=[];for(let a=0;a<e.length;++a)t[a]==null?r.push(Dr(e[a]).asType("bool")):t[a].rank<e[a].rank?r.push($r(t[a],-1)):r.push(t[a]);let s=en(r,this.axis);return RA(s,-1,!1)})}getConfig(){let e={axis:this.axis},t=super.getConfig();return Object.assign(e,t),e}};Ux.className="Concatenate";ce.registerClass(Ux);function Zd(e,t){for(;e<0;)e+=t;return e}function Xte(e,t,n){if(e.shape.length>3||t.shape.length>3)throw new Ge("batchDot is not implemented for tensors of 4D or higher rank yet");if(k.assert(e.shape.length>=2,()=>`batchDot requires the rank of x to be >= 2, but got ${e.shape.length}`),k.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 Ge("batchDot is not implemented for complex64-type Tensors yet.");let r=e.shape.length,s=t.shape.length;n==null&&(n=[r-1,s-2]);let a=n;return Z(()=>{let o;if(r>s){o=r-s;let l=[];for(let u=0;u<o;++u)l.push(1);t=t.reshape(t.shape.concat(l))}else if(s>r){o=s-r;let l=[];for(let u=0;u<o;++u)l.push(1);e=e.reshape(e.shape.concat(l))}else o=0;let i;if(e.shape.length===2&&t.shape.length===2)a[0]===a[1]?i=e.mul(t).sum(a[0]):i=e.transpose([1,0]).mul(t).sum(a[1]);else{let l=a[0]!==e.shape.length-1,u=a[1]===t.shape.length-1;i=e.matMul(t,l,u)}if(o>0){let l;r>s?l=r+s-3:l=r-1;let u=[];for(let c=l;c<l+o;++c)u.push(c);i=i.squeeze(u)}return i.shape.length===1&&(i=i.expandDims(1)),i})}var Hx=class extends hi{constructor(e){super(e);this.axes=e.axes,this.normalize=e.normalize==null?!1:e.normalize,this.supportsMasking=!0,this.reshapeRequired=!1}build(e){k.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 Ge("Dot layer does not support tensors of 4D or higher rank yet.");let r=this.interpretAxes(t,n);if(t[r[0]]!==n[r[1]])throw new q(`Dimension incompatibility: ${t[r[0]]} !== ${n[r[1]]}`)}mergeFunction(e){if(e.length!==2)throw new q(`A \`Dot\` layer must be called on exactly 2 inputs, but received ${e.length} input(s).`);let t=e[0],n=e[1],r;return Array.isArray(this.axes)?r=this.axes.map((s,a)=>Zd(s,e[a].shape.length)):r=[Zd(this.axes,t.shape.length),Zd(this.axes,n.shape.length)],this.normalize&&(t=am(t,r[0]),n=am(n,r[1])),Xte(t,n,r)}interpretAxes(e,t){let n;return Array.isArray(this.axes)?n=this.axes:n=[Zd(this.axes,e.length),Zd(this.axes,t.length)],n}computeOutputShape(e){k.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 Ge("Dot layer does not support tensors of 4D or higher rank yet.");let r=this.interpretAxes(t,n);t.splice(r[0],1),n.splice(r[1],1),n.splice(0,1);let s=t.concat(n);return s.length===1&&s.push(1),s}computeMask(e,t){return null}getConfig(){let e={axes:this.axes,normalize:this.normalize},t=super.getConfig();return Object.assign(e,t),e}};Hx.className="Dot";ce.registerClass(Hx);var Gx=class extends st{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 Z(()=>{this.invokeCallHook(e,t);let n=Ke(e);return Wd(()=>jf(n.shape,0,this.stddev).add(n),()=>n,t.training||!1)})}};Gx.className="GaussianNoise";ce.registerClass(Gx);var jx=class extends st{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 Z(()=>{this.invokeCallHook(e,t);let n=Ke(e);return this.rate>0&&this.rate<1?Wd(()=>{let s=Math.sqrt(this.rate/(1-this.rate));return n.mul(jf(n.shape,1,s))},()=>n,t.training||!1):n})}};jx.className="GaussianDropout";ce.registerClass(jx);var qx=class extends st{constructor(e){super(e);this.supportsMasking=!0,this.rate=e.rate,this.noiseShape=e.noiseShape}_getNoiseShape(e){return this.noiseShape||Ke(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 Z(()=>{if(this.rate<1&&this.rate>0){let n=this._getNoiseShape(e);return Wd(()=>{let s=Ke(e),a=1.6732632423543772,o=1.0507009873554805,i=-a*o,l=Jo(Rd(n),this.rate);l=zd(l,"float32");let u=((1-this.rate)*(1+this.rate*i**2))**-.5,c=-u*i*this.rate;return s.mul(l).add(l.add(-1).mul(i)).mul(u).add(c)},()=>Ke(e),t.training||!1)}return e})}};qx.className="AlphaDropout";ce.registerClass(qx);function Yd(e,t,n,r,s,a=.001){let o;if(e.rank===2)o=Sj(e,t,n,r,s,a);else if(e.rank===3)o=Nj(e,t,n,r,s,a);else if(e.rank===4)o=Ej(e,t,n,r,s,a);else throw new Ge(`batchNormalization is not implemented for array of rank ${e.rank} yet`);return o}function Zte(e,t,n,r,s=.001){return Z(()=>{let a=qA(e,r),o=a.mean,i=a.variance;return[Yd(e,o,i,n,t,s),o,i]})}function Yte(e,t,n,r,s=.001){return Z(()=>{let a=qA(e,r),o=a.mean,i=a.variance,l=[];for(let f of ds(0,e.rank))r.indexOf(f)!==-1?l.push(1):l.push(e.shape[f]);let u=o.reshape(l),c=i.reshape(l),d=t==null?null:t.reshape(l),h=n==null?null:n.reshape(l);return[Yd(e,u,c,h,d,s),o,i]})}function Jte(e,t,n,r,s=.001){return k.arraysEqual(r.slice().sort(),ds(0,e.rank-1))?Zte(e,t,n,r,s):Yte(e,t,n,r,s)}var Kx=class extends st{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=zt(e.betaInitializer||"zeros"),this.gammaInitializer=zt(e.gammaInitializer||"ones"),this.movingMeanInitializer=zt(e.movingMeanInitializer||"zeros"),this.movingVarianceInitializer=zt(e.movingVarianceInitializer||"ones"),this.betaConstraint=hn(e.betaConstraint),this.gammaConstraint=hn(e.gammaConstraint),this.betaRegularizer=Lt(e.betaRegularizer),this.gammaRegularizer=Lt(e.gammaRegularizer)}build(e){e=At(e);let t=this.axis>=0?this.axis:this.axis+e.length,n=e[t];if(n==null)throw new q(`Axis ${t} of input tensor should have a defined dimension but the layer received an input with shape ${JSON.stringify(e)}.`);this.inputSpec=[new tn({ndim:e.length,axes:{[t]:n}})];let r=[n];this.scale&&(this.gamma=this.addWeight("gamma",r,null,this.gammaInitializer,this.gammaRegularizer,!0,this.gammaConstraint)),this.center&&(this.beta=this.addWeight("beta",r,null,this.betaInitializer,this.betaRegularizer,!0,this.betaConstraint)),this.movingMean=this.addWeight("moving_mean",r,null,this.movingMeanInitializer,null,!1),this.movingVariance=this.addWeight("moving_variance",r,null,this.movingVarianceInitializer,null,!1),this.built=!0}call(e,t){return Z(()=>{let n=t.training==null?!1:t.training,r=Ke(e),s=r.shape,a=s.length,o=ds(0,a),i=this.axis>=0?this.axis:this.axis+a;o.splice(i,1);let l=si(1,a);l[i]=s[i];let u=o.slice();u.sort();let c=!k.arraysEqual(u,ds(0,a).slice(0,a-1)),d=()=>{if(c){let y=this.movingMean.read().reshape(l),A=this.movingVariance.read().reshape(l),x=this.center?this.beta.read().reshape(l):null,b=this.scale?this.gamma.read().reshape(l):null;return Yd(r,y,A,x,b,this.epsilon)}else return Yd(r,this.movingMean.read(),this.movingVariance.read(),this.beta==null?null:this.beta.read(),this.gamma==null?null:this.gamma.read(),this.epsilon)};if(!n)return d();let[h,p,f]=Jte(r,this.gamma.read(),this.beta.read(),o,this.epsilon),m=(y,A,x)=>{Z(()=>{let b=1-x,v=y.read(),w=v.sub(A).mul(b);y.write(v.sub(w))})};return(()=>{m(this.movingMean,p,this.momentum),m(this.movingVariance,f,this.momentum)})(),h})}getConfig(){let e={axis:this.axis,momentum:this.momentum,epsilon:this.epsilon,center:this.center,scale:this.scale,betaInitializer:Ht(this.betaInitializer),gammaInitializer:Ht(this.gammaInitializer),movingMeanInitializer:Ht(this.movingMeanInitializer),movingVarianceInitializer:Ht(this.movingVarianceInitializer),betaRegularizer:kt(this.betaRegularizer),gammaRegularizer:kt(this.gammaRegularizer),betaConstraint:dn(this.betaConstraint),gammaConstraint:dn(this.gammaConstraint)},t=super.getConfig();return Object.assign(e,t),e}};Kx.className="BatchNormalization";ce.registerClass(Kx);var Xx=class extends st{constructor(e){if(e==null&&(e={}),super(e),this.axis=e.axis==null?-1:e.axis,typeof this.axis=="number"){if(!Number.isInteger(this.axis))throw new Error(`Expected axis to be an integer, but received ${this.axis}`)}else if(Array.isArray(this.axis)){for(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=zt(e.betaInitializer||"zeros"),this.gammaInitializer=zt(e.gammaInitializer||"ones"),this.betaRegularizer=Lt(e.betaRegularizer),this.gammaRegularizer=Lt(e.gammaRegularizer),this.supportsMasking=!0}build(e){e=At(e);let t=e.length;typeof this.axis=="number"&&(this.axis=[this.axis]);for(let s=0;s<this.axis.length;++s)this.axis[s]<0&&(this.axis[s]+=t);for(let s of this.axis)if(s<0||s>=t)throw new Error(`Invalid axis: ${s}`);if(this.axis.length!==Ga(this.axis).length)throw new Error(`Found duplicate axes in: ${this.axis}`);let n=this.axis.map(s=>e[s]),r=!0;this.scale?this.gamma=this.addWeight("gamma",n,"float32",this.gammaInitializer,this.gammaRegularizer,r):this.gamma=null,this.center?this.beta=this.addWeight("beta",n,"float32",this.betaInitializer,this.betaRegularizer,r):this.beta=null,this.built=!0}call(e,t){let n=Ke(e),r=n.shape,s=r.length;return Z(()=>{let a=!0,{mean:o,variance:i}=qA(n,this.axis,a),l=si(1,s);for(let f of this.axis)l[f]=r[f];let u=f=>f!=null&&f.shape.length!==s&&this.axis!==[s-1]?f.reshape(l):f,c=u(this.gamma.read()),d=u(this.beta.read()),h=[],p=[];for(let f=0;f<s;++f)this.axis.indexOf(f)!==-1?(h.push(r[f]),p.push(1)):(h.push(1),p.push(r[f]));return o=o.tile(h),i=i.tile(h),c=c.tile(p),d=d.tile(p),Yd(n,o,i,d,c,this.epsilon)})}getConfig(){let e={axis:this.axis,epsilon:this.epsilon,center:this.center,scale:this.scale,betaInitializer:Ht(this.betaInitializer),gammaInitializer:Ht(this.gammaInitializer),betaRegularizer:kt(this.betaRegularizer),gammaRegularizer:kt(this.gammaRegularizer)},t=super.getConfig();return Object.assign(e,t),e}};Xx.className="LayerNormalization";ce.registerClass(Xx);function Qte(e,t,n){return Z(()=>{if(e.rank!==4)throw new q(`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 q("spatial2dPadding expects `padding` to be an Array of two Arrays, each of which is an Array of two integers.");if(n==null&&(n=us()),n!=="channelsLast"&&n!=="channelsFirst")throw new q(`Unknown data format: ${n}. Supported data formats are 'channelsLast' and 'channelsFirst.`);let r;return n==="channelsFirst"?r=[[0,0],[0,0],t[0],t[1]]:r=[[0,0],t[0],t[1],[0,0]],Wa(e,r)})}var Zx=class extends st{constructor(e){if(e==null&&(e={}),super(e),this.dataFormat=e.dataFormat==null?us():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 q(`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 q(`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 q(`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 tn({ndim:4})]}computeOutputShape(e){e=At(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 Z(()=>Qte(Ke(e),this.padding,this.dataFormat))}getConfig(){let e={padding:this.padding,dataFormat:this.dataFormat},t=super.getConfig();return Object.assign(e,t),e}};Zx.className="ZeroPadding2D";ce.registerClass(Zx);function vm(e,t,n,r,s,a){return Z(()=>{Yt(s),lS(a),Or(r),n==null&&(n=[1,1]),r==null&&(r="valid"),s==null&&(s=us()),a==null&&(a="max"),e=gx(e,s);let o,i=r==="same"?"same":"valid";return a==="max"?o=$f(e,t,n,i):o=Sf(e,t,n,i),s==="channelsFirst"&&(o=pt(o,[0,3,1,2])),o})}function I8(e,t,n,r,s,a){return Z(()=>{Yt(s),lS(a),Or(r),n==null&&(n=[1,1,1]),r==null&&(r="valid"),s==null&&(s=us()),a==null&&(a="max"),e=f8(e,s);let o,i=r==="same"?"same":"valid";return a==="max"?o=gI(e,t,n,i):o=Q6(e,t,n,i),s==="channelsFirst"&&(o=pt(o,[0,4,1,2,3])),o})}var S8=class extends st{constructor(e){if(e.poolSize==null&&(e.poolSize=2),super(e),typeof e.poolSize=="number")this.poolSize=[e.poolSize];else if(Array.isArray(e.poolSize)&&e.poolSize.length===1&&typeof e.poolSize[0]=="number")this.poolSize=e.poolSize;else throw new q(`poolSize for 1D convolutional layer must be a number or an Array of a single number, but received ${JSON.stringify(e.poolSize)}`);if(An(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 q(`strides for 1D convolutional layer must be a number or an Array of a single number, but received ${JSON.stringify(e.strides)}`);An(this.strides,"strides"),this.padding=e.padding==null?"valid":e.padding,Or(this.padding),this.inputSpec=[new tn({ndim:3})]}computeOutputShape(e){e=At(e);let t=ms(e[1],this.poolSize[0],this.padding,this.strides[0]);return[e[0],t,e[2]]}call(e,t){return Z(()=>{this.invokeCallHook(e,t),e=Ld(Ke(e),2);let n=this.poolingFunction(Ke(e),[this.poolSize[0],1],[this.strides[0],1],this.padding,"channelsLast");return Jl(n,[2])})}getConfig(){let e={poolSize:this.poolSize,padding:this.padding,strides:this.strides},t=super.getConfig();return Object.assign(e,t),e}},Yx=class extends S8{constructor(e){super(e)}poolingFunction(e,t,n,r,s){return Yt(s),Or(r),vm(e,t,n,r,s,"max")}};Yx.className="MaxPooling1D";ce.registerClass(Yx);var Jx=class extends S8{constructor(e){super(e)}poolingFunction(e,t,n,r,s){return Yt(s),Or(r),vm(e,t,n,r,s,"avg")}};Jx.className="AveragePooling1D";ce.registerClass(Jx);var T8=class extends st{constructor(e){if(e.poolSize==null&&(e.poolSize=[2,2]),super(e),this.poolSize=Array.isArray(e.poolSize)?e.poolSize:[e.poolSize,e.poolSize],e.strides==null)this.strides=this.poolSize;else if(Array.isArray(e.strides)){if(e.strides.length!==2)throw new q(`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];An(this.poolSize,"poolSize"),An(this.strides,"strides"),this.padding=e.padding==null?"valid":e.padding,this.dataFormat=e.dataFormat==null?"channelsLast":e.dataFormat,Yt(this.dataFormat),Or(this.padding),this.inputSpec=[new tn({ndim:4})]}computeOutputShape(e){e=At(e);let t=this.dataFormat==="channelsFirst"?e[2]:e[1],n=this.dataFormat==="channelsFirst"?e[3]:e[2];return t=ms(t,this.poolSize[0],this.padding,this.strides[0]),n=ms(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 Z(()=>(this.invokeCallHook(e,t),this.poolingFunction(Ke(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}},Qx=class extends T8{constructor(e){super(e)}poolingFunction(e,t,n,r,s){return Yt(s),Or(r),vm(e,t,n,r,s,"max")}};Qx.className="MaxPooling2D";ce.registerClass(Qx);var e5=class extends T8{constructor(e){super(e)}poolingFunction(e,t,n,r,s){return Yt(s),Or(r),vm(e,t,n,r,s,"avg")}};e5.className="AveragePooling2D";ce.registerClass(e5);var N8=class extends st{constructor(e){if(e.poolSize==null&&(e.poolSize=[2,2,2]),super(e),this.poolSize=Array.isArray(e.poolSize)?e.poolSize:[e.poolSize,e.poolSize,e.poolSize],e.strides==null)this.strides=this.poolSize;else if(Array.isArray(e.strides)){if(e.strides.length!==3)throw new q(`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];An(this.poolSize,"poolSize"),An(this.strides,"strides"),this.padding=e.padding==null?"valid":e.padding,this.dataFormat=e.dataFormat==null?"channelsLast":e.dataFormat,Yt(this.dataFormat),Or(this.padding),this.inputSpec=[new tn({ndim:5})]}computeOutputShape(e){e=At(e);let t=this.dataFormat==="channelsFirst"?e[2]:e[1],n=this.dataFormat==="channelsFirst"?e[3]:e[2],r=this.dataFormat==="channelsFirst"?e[4]:e[3];return t=ms(t,this.poolSize[0],this.padding,this.strides[0]),n=ms(n,this.poolSize[1],this.padding,this.strides[1]),r=ms(r,this.poolSize[2],this.padding,this.strides[2]),this.dataFormat==="channelsFirst"?[e[0],e[1],t,n,r]:[e[0],t,n,r,e[4]]}call(e,t){return Z(()=>(this.invokeCallHook(e,t),this.poolingFunction(Ke(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}},t5=class extends N8{constructor(e){super(e)}poolingFunction(e,t,n,r,s){return Yt(s),Or(r),I8(e,t,n,r,s,"max")}};t5.className="MaxPooling3D";ce.registerClass(t5);var n5=class extends N8{constructor(e){super(e)}poolingFunction(e,t,n,r,s){return Yt(s),Or(r),I8(e,t,n,r,s,"avg")}};n5.className="AveragePooling3D";ce.registerClass(n5);var C8=class extends st{constructor(e){super(e);this.inputSpec=[new tn({ndim:3})]}computeOutputShape(e){return[e[0],e[2]]}call(e,t){throw new Ge}},r5=class extends C8{constructor(e){super(e||{})}call(e,t){return Z(()=>{let n=Ke(e);return Xt(n,1)})}};r5.className="GlobalAveragePooling1D";ce.registerClass(r5);var s5=class extends C8{constructor(e){super(e||{})}call(e,t){return Z(()=>{let n=Ke(e);return os(n,1)})}};s5.className="GlobalMaxPooling1D";ce.registerClass(s5);var E8=class extends st{constructor(e){super(e);this.dataFormat=e.dataFormat==null?"channelsLast":e.dataFormat,Yt(this.dataFormat),this.inputSpec=[new tn({ndim:4})]}computeOutputShape(e){return e=e,this.dataFormat==="channelsLast"?[e[0],e[3]]:[e[0],e[1]]}call(e,t){throw new Ge}getConfig(){let e={dataFormat:this.dataFormat},t=super.getConfig();return Object.assign(e,t),e}},a5=class extends E8{call(e,t){return Z(()=>{let n=Ke(e);return this.dataFormat==="channelsLast"?Xt(n,[1,2]):Xt(n,[2,3])})}};a5.className="GlobalAveragePooling2D";ce.registerClass(a5);var o5=class extends E8{call(e,t){return Z(()=>{let n=Ke(e);return this.dataFormat==="channelsLast"?os(n,[1,2]):os(n,[2,3])})}};o5.className="GlobalMaxPooling2D";ce.registerClass(o5);var $8=class extends st{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 r=t.layer,s=fs(r,n);delete t.layer;let a={layer:s};return Object.assign(a,t),new e(a)}},i5=class extends $8{constructor(e){super(e);this.supportsMasking=!0}build(e){if(e=At(e),e.length<3)throw new q(`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=At(e);let t=[e[0]].concat(e.slice(2)),n=this.layer.computeOutputShape(t),r=e[1];return[n[0],r].concat(n.slice(1))}call(e,t){return Z(()=>(e=Ke(e),v8((a,o)=>[Ke(this.layer.call(a,t)),[]],e,[],!1,null,null,!1,!0)[1]))}};i5.className="TimeDistributed";ce.registerClass(i5);function ene(e){oi(iee,"BidirectionalMergeMode",e)}var tne="concat",l5=class extends $8{constructor(e){super(e);let t=e.layer.getConfig(),n={};n.className=e.layer.getClassName(),n.config=t,this.forwardLayer=fs(n),t.goBackwards=t.goBackwards!==!0;let r={};if(r.className=e.layer.getClassName(),r.config=t,this.backwardLayer=fs(r),this.forwardLayer.name="forward_"+this.forwardLayer.name,this.backwardLayer.name="backward_"+this.backwardLayer.name,this.mergeMode=e.mergeMode===void 0?tne:e.mergeMode,ene(this.mergeMode),e.weights)throw new Ge("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,r,s;return this.returnState&&(s=t.slice(1)),n=t[0],n=n,this.mergeMode==="concat"?(n[n.length-1]*=2,r=[n]):this.mergeMode==null?r=[n,n.slice()]:r=[n],this.returnState?this.mergeMode==null?r.concat(s).concat(s.slice()):[n].concat(s).concat(s.slice()):Jn(r)}apply(e,t){let n=t==null?null:t.initialState,r=t==null?null:t.constants;t==null&&(t={});let s=b8(e,n,r,this.numConstants);if(e=s.inputs,n=s.initialState,r=s.constants,Array.isArray(e)&&(n=e.slice(1),e=e[0]),(n==null||n.length===0)&&r==null)return super.apply(e,t);let a=[],o=[];if(n!=null){let l=n.length;if(l%2>0)throw new q("When passing `initialState` to a Bidrectional RNN, the state should be an Array containing the states of the underlying RNNs.");t.initialState=n,a.push(...n);let u=n.map(c=>new tn({shape:c.shape}));this.forwardLayer.stateSpec=u.slice(0,l/2),this.backwardLayer.stateSpec=u.slice(l/2),o.push(...u)}if(r!=null)throw new Ge("Support for constants in Bidirectional layers is not implemented yet.");let i=a[0]instanceof ps;for(let l of a)if(l instanceof ps!==i)throw new q("The initial state of a Bidirectional layer cannot be specified as a mix of symbolic and non-symbolic tensors");if(i){let l=[e].concat(a),u=this.inputSpec.concat(o),c=this.inputSpec;this.inputSpec=u;let d=super.apply(l,t);return this.inputSpec=c,d}else return super.apply(e,t)}call(e,t){return Z(()=>{let n=t.initialState,r,s;if(n==null)r=this.forwardLayer.call(e,t),s=this.backwardLayer.call(e,t);else{let i=n.slice(0,n.length/2),l=n.slice(n.length/2);r=this.forwardLayer.call(e,Object.assign(t,{initialState:i})),s=this.backwardLayer.call(e,Object.assign(t,{initialState:l}))}let a;this.returnState&&(Array.isArray(r)&&(a=r.slice(1).concat(s.slice(1))),r=r[0],s=s[0]),this.returnSequences&&(s=Fr(s,1));let o;return this.mergeMode==="concat"?o=D1([r,s]):this.mergeMode==="sum"?o=pe(r,s):this.mergeMode==="ave"?o=K(.5,pe(r,s)):this.mergeMode==="mul"?o=K(r,s):this.mergeMode==null&&(o=[r,s]),this.returnState?this.mergeMode==null?o.concat(a):[o].concat(a):o})}resetStates(e){this.forwardLayer.resetStates(),this.backwardLayer.resetStates()}build(e){ii(this.forwardLayer.name,()=>{this.forwardLayer.build(e)}),ii(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 s=this.forwardLayer.states.map(a=>null);return Array.isArray(n)?n.concat(s).concat(s):[n].concat(s).concat(s)}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=fs(t.layer);if(delete t.layer,t.numConstants!=null)throw new Ge("Deserialization of a Bidirectional layer with numConstants present is not supported yet.");let r=t;return r.layer=n,new e(r)}};l5.className="Bidirectional";ce.registerClass(l5);function nne(e){return new su(e)}function rne(e){return new px(e)}function sne(e){return new cx(e)}function ane(e){return new dx(e)}function one(e){return new hx(e)}function ine(e){return new mx(e)}function lne(e){return new fx(e)}function une(e){return new vx(e)}function cne(e){return new fm(e)}function dne(e){return new Ax(e)}function hne(e){return new mm(e)}function pne(e){return new xx(e)}function fne(e){return new bx(e)}function mne(e){return new wx(e)}function gne(e){return new kx(e)}function yne(e){return new Ix(e)}function Ane(e){return new Rx(e)}function xne(e){return new $x(e)}function bne(e){return new bm(e)}function vne(e){return new Ex(e)}function wne(e){return new _x(e)}function kne(e){return new Dx(e)}function Ine(e){return new Fx(e)}function Sne(e){return new Mx(e)}function Tne(e){return new Px(e)}function Nne(e){return new zx(e)}function Cne(e){return new Bx(e)}function Ene(e){return new Ux(e)}function $ne(e){return new Wx(e)}function _ne(e){return new Vx(e)}function Rne(e){return new Lx(e)}function Dne(e){return new Hx(e)}function Fne(e){return new Kx(e)}function Mne(e){return new Xx(e)}function One(e){return new Zx(e)}function u5(e){return new Jx(e)}function Pne(e){return u5(e)}function zne(e){return u5(e)}function c5(e){return new e5(e)}function Lne(e){return c5(e)}function Bne(e){return c5(e)}function d5(e){return new n5(e)}function Wne(e){return d5(e)}function Vne(e){return d5(e)}function Une(e){return new r5(e)}function Hne(e){return new a5(e)}function _8(e){return new s5(e)}function R8(e){return new o5(e)}function D8(e){return new Yx(e)}function F8(e){return new Qx(e)}function Gne(e){return new t5(e)}function jne(e){return new Tx(e)}function qne(e){return new ym(e)}function Kne(e){return new Nx(e)}function Xne(e){return new Xd(e)}function Zne(e){return new Sx(e)}function Yne(e){return new gm(e)}function Jne(e){return new Cx(e)}function Qne(e){return new xm(e)}function ere(e){return new fa(e)}function tre(e){return new Am(e)}function nre(e){return new l5(e)}function rre(e){return new i5(e)}var sre=_8,are=R8,ore=D8,ire=F8;function lre(e){return new Gx(e)}function ure(e){return new jx(e)}function cre(e){return new qx(e)}function dre(e){return new Ox(e)}var M8={};De(M8,{MAPE:()=>wre,MSE:()=>Sre,binaryAccuracy:()=>hre,binaryCrossentropy:()=>pre,categoricalAccuracy:()=>mre,categoricalCrossentropy:()=>gre,cosineProximity:()=>xre,mape:()=>kre,meanAbsoluteError:()=>bre,meanAbsolutePercentageError:()=>vre,meanSquaredError:()=>Ire,mse:()=>Tre,precision:()=>yre,recall:()=>Are,sparseCategoricalAccuracy:()=>fre});function hre(e,t){return X1(e,t)}function pre(e,t){return DS(e,t)}function fre(e,t){return FS(e,t)}function mre(e,t){return Z1(e,t)}function gre(e,t){return Y1(e,t)}function yre(e,t){return RS(e,t)}function Are(e,t){return nte(e,t)}function xre(e,t){return q1(e,t)}function bre(e,t){return om(e,t)}function vre(e,t){return ou(e,t)}function wre(e,t){return ou(e,t)}function kre(e,t){return ou(e,t)}function Ire(e,t){return ui(e,t)}function Sre(e,t){return ui(e,t)}function Tre(e,t){return ui(e,t)}var O8={};De(O8,{modelFromJSON:()=>Ote});var P8={};De(P8,{l1:()=>Cre,l1l2:()=>Nre,l2:()=>Ere});function Nre(e){return new jd(e)}function Cre(e){return Hte(e)}function Ere(e){return Gte(e)}var z8=class extends au{constructor(){super(...arguments);this.model=null}setModel(e){if(!(e instanceof pa))throw new Error("model must be a LayersModel, not some other Container");this.model=e}};function wm(e,t){return e<t}function L8(e,t){return e>t}var B8=class extends z8{constructor(e){super();if(e==null&&(e={}),e.restoreBestWeights)throw new Ge("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=wm:this.mode==="max"?this.monitorFunc=L8:this.monitor.indexOf("acc")!==-1?this.monitorFunc=L8:this.monitorFunc=wm,this.monitorFunc===wm&&(this.minDelta*=-1)}async onTrainBegin(e){this.wait=0,this.stoppedEpoch=0,this.baseline!=null?this.best=this.baseline:this.best=this.monitorFunc===wm?Infinity:-Infinity}async onEpochEnd(e,t){await Ka(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 $re(e){return new B8(e)}var _re={earlyStopping:$re},gs;(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"})(gs||(gs={}));var W8;(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={}))})(W8||(W8={}));var h5={};function Rre(e,t){let n={tfOpName:e,category:"custom",inputs:[],attrs:[],customExecutor:t};h5[e]=n}function V8(e){return h5[e]}function Dre(e){delete h5[e]}function S(e,t,n,r,s){let a=t.inputParams[e];if(a&&a.inputIndexStart!==void 0){let i=a.inputIndexStart,l=a.inputIndexEnd===0?void 0:a.inputIndexEnd===void 0?i+1:a.inputIndexEnd;if(a.type==="tensor")return Bn(t.inputNames[a.inputIndexStart],n,r,s);if(a.type==="tensors")return t.inputNames.slice(i,l).map(h=>Bn(h,n,r,s));let u=Bn(t.inputNames.slice(i)[0],n,r,s),c=u.dataSync();return a.type==="number"?c[0]:k.toNestedArray(u.shape,c)}let o=t.attrParams[e];return o&&o.value}function Bn(e,t,n,r){let[s,a]=hr(e);if(r!=null){let i=r.getHashTableHandleByName(s);if(i!=null)return i}let o=n.currentContextIds.find(i=>!!t[km(s,i)]);return o!==void 0?t[km(s,o)][a]:void 0}function Fre(e,t,n){return t[km(e,n.currentContextId)]}function ma(e,t){let[n,r,s]=hr(e);return[km(n,t&&t.currentContextId),r,s]}function km(e,t){return t?`${e}-${t}`:e}function hr(e){let t=e.split(":");if(t.length===1)return[e,0,void 0];let n=t[0],r=t.length===3?t[1]:void 0,s=Number(t[t.length-1]);return[n,s,r]}function Im(e,t,n){let r=S("pad",e,t,n);if(r==="explicit"){r=S("explicitPaddings",e,t,n);let s=[[0,0],[0,0],[0,0],[0,0]];for(let a=0;a<4;a++)s[a][0]=r[a*2],s[a][1]=r[a*2+1];return s}return r}function ga(e){return e.kept?e:qo(e)}var U8={};De(U8,{json:()=>Mre});var Mre=[{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}]}],H8={};De(H8,{json:()=>Ore});var Ore=[{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}]}],G8={};De(G8,{json:()=>Pre});var Pre=[{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"}]}],j8={};De(j8,{json:()=>zre});var zre=[{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"}]}],q8={};De(q8,{json:()=>Lre});var Lre=[{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"}]}],K8={};De(K8,{json:()=>Bre});var Bre=[{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}]}],X8={};De(X8,{json:()=>Wre});var Wre=[{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"}]}],Z8={};De(Z8,{json:()=>Vre});var Vre=[{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"}]}],Y8={};De(Y8,{json:()=>Ure});var Ure=[{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"}]}],J8={};De(J8,{json:()=>Hre});var Hre=[{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"}]}],Q8={};De(Q8,{json:()=>Gre});var Gre=[{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}]}],eT={};De(eT,{json:()=>jre});var jre=[{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"}]}],tT={};De(tT,{json:()=>qre});var qre=[{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}]}],nT={};De(nT,{json:()=>Kre});var Kre=[{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"}]}],rT={};De(rT,{json:()=>Xre});var Xre=[{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}]}],sT={};De(sT,{json:()=>Zre});var Zre=[{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"}]}],aT={};De(aT,{json:()=>Yre});var Yre=[{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}]}],oT={};De(oT,{json:()=>Jre});var Jre=[{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"}]}],iT={};De(iT,{json:()=>Qre});var Qre=[{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:[]}],lT=class{static get Instance(){return this._instance||(this._instance=new this)}constructor(){let e=[U8,H8,G8,j8,q8,K8,X8,Z8,Y8,J8,Q8,eT,tT,nT,rT,sT,aT,oT,iT],t=[].concat(...e.map(n=>n.json));this.opMappers=t.reduce((n,r)=>(n[r.tfOpName]=r,n),{})}transformGraph(e,t={}){let n=e.node,r=[],s=[],a=[],o=n.reduce((f,m)=>(f[m.name]=this.mapNode(m),m.op.startsWith("Placeholder")?r.push(f[m.name]):m.op==="Const"?s.push(f[m.name]):(m.input==null||m.input.length===0)&&a.push(f[m.name]),f),{}),i=[],l=[],u={},c={};t!=null&&(u=this.mapSignatureEntries(t.inputs),c=this.mapSignatureEntries(t.outputs));let d=Object.keys(o);d.forEach(f=>{let m=o[f];m.inputNames.forEach((g,y)=>{let[A,,x]=ma(g),b=o[A];if(b.outputs!=null){let v=b.outputs.indexOf(x);if(v!==-1){let w=`${A}:${v}`;m.inputNames[y]=w}}m.inputs.push(b),b.children.push(m)})}),Object.keys(c).length===0?d.forEach(f=>{let m=o[f];m.children.length===0&&l.push(m)}):Object.keys(c).forEach(f=>{let[m]=ma(f),g=o[m];g!=null&&(g.signatureKey=c[f],l.push(g))}),Object.keys(u).length>0?Object.keys(u).forEach(f=>{let[m]=ma(f),g=o[m];g&&(g.signatureKey=u[f],i.push(g))}):i=r;let h={};e.library!=null&&e.library.function!=null&&(h=e.library.function.reduce((f,m)=>(f[m.signature.name]=this.mapFunction(m),f),{}));let p={nodes:o,inputs:i,outputs:l,weights:s,placeholders:r,signature:t,functions:h};return a.length>0&&(p.initNodes=a),p}mapSignatureEntries(e){return Object.keys(e||{}).reduce((t,n)=>(t[e[n].name]=n,t),{})}mapNode(e){let t=V8(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(r=>r.startsWith("^")?r.substr(1):r),inputs:[],children:[],inputParams:{},attrParams:{},rawAttrs:e.attr,outputs:t.outputs};return t.inputs!=null&&(n.inputParams=t.inputs.reduce((r,s)=>(r[s.name]={type:s.type,inputIndexStart:s.start,inputIndexEnd:s.end},r),{})),t.attrs!=null&&(n.attrParams=t.attrs.reduce((r,s)=>{let a=s.type,o;switch(s.type){case"string":o=p5(e.attr,s.tfName,s.defaultValue),o===void 0&&!!s.tfDeprecatedName&&(o=p5(e.attr,s.tfDeprecatedName,s.defaultValue));break;case"string[]":o=v5(e.attr,s.tfName,s.defaultValue),o===void 0&&!!s.tfDeprecatedName&&(o=v5(e.attr,s.tfDeprecatedName,s.defaultValue));break;case"number":o=m5(e.attr,s.tfName,s.defaultValue||0),o===void 0&&!!s.tfDeprecatedName&&(o=m5(e.attr,s.tfDeprecatedName,s.defaultValue));break;case"number[]":o=b5(e.attr,s.tfName,s.defaultValue),o===void 0&&!!s.tfDeprecatedName&&(o=b5(e.attr,s.tfDeprecatedName,s.defaultValue));break;case"bool":o=f5(e.attr,s.tfName,s.defaultValue),o===void 0&&!!s.tfDeprecatedName&&(o=f5(e.attr,s.tfDeprecatedName,s.defaultValue));break;case"bool[]":o=k5(e.attr,s.tfName,s.defaultValue),o===void 0&&!!s.tfDeprecatedName&&(o=k5(e.attr,s.tfDeprecatedName,s.defaultValue));break;case"shape":o=x5(e.attr,s.tfName,s.defaultValue),o===void 0&&!!s.tfDeprecatedName&&(o=x5(e.attr,s.tfDeprecatedName,s.defaultValue));break;case"shape[]":o=w5(e.attr,s.tfName,s.defaultValue),o===void 0&&!!s.tfDeprecatedName&&(o=w5(e.attr,s.tfDeprecatedName,s.defaultValue));break;case"dtype":o=y5(e.attr,s.tfName,s.defaultValue),o===void 0&&!!s.tfDeprecatedName&&(o=y5(e.attr,s.tfDeprecatedName,s.defaultValue));break;case"dtype[]":o=A5(e.attr,s.tfName,s.defaultValue),o===void 0&&!!s.tfDeprecatedName&&(o=A5(e.attr,s.tfDeprecatedName,s.defaultValue));break;case"func":o=cT(e.attr,s.tfName,s.defaultValue),o===void 0&&!!s.tfDeprecatedName&&(o=cT(e.attr,s.tfDeprecatedName,s.defaultValue));break;case"tensor":case"tensors":break;default:throw new Error(`Unsupported param type: ${s.type} for op: ${e.op}`)}return r[s.name]={value:o,type:a},r},{})),n}mapFunction(e){let t=e.nodeDef,n=[],r=[],s={};t!=null&&(s=t.reduce((c,d)=>(c[d.name]=this.mapNode(d),d.op==="Const"&&r.push(c[d.name]),c),{}));let a=[],o=[];e.signature.inputArg.forEach(c=>{let[d]=ma(c.name),h={name:d,op:"Placeholder",inputs:[],inputNames:[],category:"graph",inputParams:{},attrParams:{dtype:{value:g5(c.type),type:"dtype"}},children:[]};h.signatureKey=c.name,a.push(h),s[d]=h}),Object.keys(s).forEach(c=>{let d=s[c];d.inputNames.forEach((h,p)=>{let[f,,m]=ma(h),g=s[f];if(g.outputs!=null){let y=g.outputs.indexOf(m);if(y!==-1){let A=`${f}:${y}`;d.inputNames[p]=A}}d.inputs.push(g),g.children.push(d)})});let l=e.ret;e.signature.outputArg.forEach(c=>{let[d,h]=ma(l[c.name]),p=s[d];p!=null&&(p.defaultOutput=h,o.push(p))});let u=this.mapArgsToSignature(e);return{nodes:s,inputs:a,outputs:o,weights:r,placeholders:n,signature:u}}mapArgsToSignature(e){return{methodName:e.signature.name,inputs:e.signature.inputArg.reduce((t,n)=>(t[n.name]=this.mapArgToTensorInfo(n),t),{}),outputs:e.signature.outputArg.reduce((t,n)=>(t[n.name]=this.mapArgToTensorInfo(n,e.ret),t),{})}}mapArgToTensorInfo(e,t){let n=e.name;return t!=null&&(n=t[n]),{name:n,dtype:e.type}}};function ese(e){let t=ae().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 uT(e,t){let n=Array.isArray(e)?String.fromCharCode.apply(null,e):ese(e);return t?n:n.toLowerCase()}function p5(e,t,n,r=!1){let s=e[t];return s!=null?uT(s.s,r):n}function f5(e,t,n){let r=e[t];return r?r.b:n}function m5(e,t,n){let r=e[t]||{},s=r.i!=null?r.i:r.f!=null?r.f:n;return typeof s=="number"?s:parseInt(s,10)}function g5(e){switch(typeof e=="string"&&(e=gs[e]),e){case gs.DT_FLOAT:return"float32";case gs.DT_INT32:case gs.DT_INT64:case gs.DT_INT8:case gs.DT_UINT8:return"int32";case gs.DT_BOOL:return"bool";case gs.DT_DOUBLE:return"float32";case gs.DT_STRING:return"string";default:return null}}function cT(e,t,n){let r=e[t];return r&&r.func?r.func.name:n}function y5(e,t,n){let r=e[t];return r&&r.type?g5(r.type):n}function A5(e,t,n){let r=e[t];return r&&r.list&&r.list.type?r.list.type.map(s=>g5(s)):n}function dT(e){if(!e.unknownRank)return e.dim!=null?e.dim.map(t=>typeof t.size=="number"?t.size:parseInt(t.size,10)):[]}function x5(e,t,n){let r=e[t];return r&&r.shape?dT(r.shape):n}function b5(e,t,n){let r=e[t];return r?((r.list.f&&r.list.f.length?r.list.f:r.list.i)||[]).map(s=>typeof s=="number"?s:parseInt(s,10)):n}function v5(e,t,n,r=!1){let s=e[t];return s&&s.list&&s.list.s?s.list.s.map(a=>uT(a,r)):n}function w5(e,t,n){let r=e[t];return r&&r.list&&r.list.shape?r.list.shape.map(s=>dT(s)):n}function k5(e,t,n){let r=e[t];return r&&r.list&&r.list.b?r.list.b:n}var tse=class{constructor(e,t,n){this.node=e,this.tensorMap=t,this.context=n,this.inputs=[],this.attrs={},this.inputs=e.inputNames.map(r=>this.getInput(r)),e.rawAttrs!=null&&(this.attrs=Object.keys(e.rawAttrs).reduce((r,s)=>(r[s]=this.getAttr(s),r),{}))}getInput(e){return Bn(e,this.tensorMap,this.context)}getAttr(e,t){let n=this.node.rawAttrs[e];if(n.tensor!=null)return Bn(e,this.tensorMap,this.context);if(n.i!=null||n.f!=null)return m5(this.node.rawAttrs,e,t);if(n.s!=null)return p5(this.node.rawAttrs,e,t);if(n.b!=null)return f5(this.node.rawAttrs,e,t);if(n.shape!=null)return x5(this.node.rawAttrs,e,t);if(n.type!=null)return y5(this.node.rawAttrs,e,t);if(n.list!=null){if(n.list.i!=null||n.list.f!=null)return b5(this.node.rawAttrs,e,t);if(n.list.s!=null)return v5(this.node.rawAttrs,e,t);if(n.list.shape!=null)return w5(this.node.rawAttrs,e,t);if(n.list.b!=null)return k5(this.node.rawAttrs,e,t);if(n.list.type!=null)return A5(this.node.rawAttrs,e,t)}return t}},nse=(e,t,n)=>{switch(e.op){case"BiasAdd":case"AddV2":case"Add":return[pe(S("a",e,t,n),S("b",e,t,n))];case"AddN":return[YG(S("tensors",e,t,n))];case"FloorMod":case"Mod":return[AI(S("a",e,t,n),S("b",e,t,n))];case"Mul":return[K(S("a",e,t,n),S("b",e,t,n))];case"RealDiv":case"Div":return[Re(S("a",e,t,n),S("b",e,t,n))];case"DivNoNan":return[oI(S("a",e,t,n),S("b",e,t,n))];case"FloorDiv":return[_A(S("a",e,t,n),S("b",e,t,n))];case"Sub":return[Ne(S("a",e,t,n),S("b",e,t,n))];case"Minimum":return[_d(S("a",e,t,n),S("b",e,t,n))];case"Maximum":return[ia(S("a",e,t,n),S("b",e,t,n))];case"Pow":return[Va(S("a",e,t,n),S("b",e,t,n))];case"SquaredDifference":return[i1(S("a",e,t,n),S("b",e,t,n))];default:throw TypeError(`Node type ${e.op} is not implemented`)}},rse=(e,t,n)=>{switch(e.op){case"Abs":case"ComplexAbs":return[yn(S("x",e,t,n))];case"Acos":return[V6(S("x",e,t,n))];case"Acosh":return[U6(S("x",e,t,n))];case"Asin":return[G6(S("x",e,t,n))];case"Asinh":return[j6(S("x",e,t,n))];case"Atan":return[q6(S("x",e,t,n))];case"Atan2":return[K6(S("x",e,t,n),S("y",e,t,n))];case"Atanh":return[X6(S("x",e,t,n))];case"Ceil":return[tI(S("x",e,t,n))];case"Complex":return[Uo(S("real",e,t,n),S("imag",e,t,n))];case"Cos":return[Nf(S("x",e,t,n))];case"Cosh":return[zA(S("x",e,t,n))];case"Elu":return[Nd(S("x",e,t,n))];case"Erf":return[iI(S("x",e,t,n))];case"Exp":return[Kr(S("x",e,t,n))];case"Expm1":return[lI(S("x",e,t,n))];case"Floor":return[Ed(S("x",e,t,n))];case"Log":return[Rr(S("x",e,t,n))];case"Log1p":return[VA(S("x",e,t,n))];case"Imag":return[BA(S("x",e,t,n))];case"Neg":return[Kt(S("x",e,t,n))];case"Reciprocal":return[xI(S("x",e,t,n))];case"Real":return[Ff(S("x",e,t,n))];case"Relu":return[ua(S("x",e,t,n))];case"Round":return[JA(S("x",e,t,n))];case"Selu":return[e1(S("x",e,t,n))];case"Sigmoid":return[Rs(S("x",e,t,n))];case"Sin":return[t1(S("x",e,t,n))];case"Sign":return[vI(S("x",e,t,n))];case"Sinh":return[n1(S("x",e,t,n))];case"Softplus":return[Zl(S("x",e,t,n))];case"Sqrt":return[$n(S("x",e,t,n))];case"Square":return[wt(S("x",e,t,n))];case"Tanh":return[Kl(S("x",e,t,n))];case"Tan":return[SI(S("x",e,t,n))];case"ClipByValue":return[cr(S("x",e,t,n),S("clipValueMin",e,t,n),S("clipValueMax",e,t,n))];case"Relu6":return[YA(S("x",e,t,n))];case"Rsqrt":return[QA(Bn(e.inputNames[0],t,n))];case"Prod":return[KA(S("x",e,t,n),S("axes",e,t,n))];case"LeakyRelu":return[Cf(S("x",e,t,n),S("alpha",e,t,n))];case"Prelu":return[Df(S("x",e,t,n),S("alpha",e,t,n))];case"IsNan":return[cI(Bn(e.inputNames[0],t,n))];default:throw TypeError(`Node type ${e.op} is not implemented`)}};function Yr(e,t,n=""){if(!(typeof e=="number"||typeof t=="number")){k.assert(e.length===t.length,()=>n+` Shapes ${e} and ${t} must match`);for(let r=0;r<e.length;r++){let s=e[r],a=t[r];k.assert(s<0||a<0||s===a,()=>n+` Shapes ${e} and ${t} must match`)}}}function hT(e){return!(typeof e=="number"||e.some(t=>t<0))}function Jd(e,t,n){let r=I5(e,n),s=!hT(r);if(s&&t.length===0)throw new Error(`Tried to calculate elements of an empty list with non-fully-defined elementShape: ${r}`);if(s&&t.forEach(a=>{r=I5(a.shape,r)}),!hT(r))throw new Error(`Non-fully-defined elementShape: ${r}`);return r}function I5(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 r=0;r<e.length;++r){let s=e[r],a=t[r];if(s>=0&&a>=0&&s!==a)throw new Error(`Incompatible shape during merge: ${e} vs. ${t}`);n[r]=s>=0?s:a}return n}var sse=class{constructor(e,t,n,r,s,a,o){this.name=e,this.dtype=t,this.maxSize=n,this.elementShape=r,this.identicalElementShapes=s,this.dynamicSize=a,this.clearAfterRead=o,this.tensors=[],this.closed_=!1,this.idTensor=Fe(0),Sn(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),Yr(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,Sn(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,r)=>this.write(n,t[r]))}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 r=0;r<this.size();r++)e.push(r)}if(e.length===0)return $s([],[0].concat(this.elementShape));let n=this.readMany(e);return Yr(this.elementShape,n[0].shape,"TensorArray shape mismatch: "),Mr(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 $s([],[0].concat(this.elementShape));let t=[];for(let r=0;r<this.size();r++)t.push(r);let n=this.readMany(t);return Yr(this.elementShape,n[0].shape,`TensorArray shape mismatch: tensor array shape (${this.elementShape}) vs first tensor shape (${n[0].shape})`),en(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,ls(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,r=e.map(i=>(n+=i,n));if(n!==t.shape[0])throw new Error(`Expected sum of lengths to be equal to
|
|
tensor.shape[0], but sum of lengths is
|
|
${n}, and tensor's shape is: ${t.shape}`);if(!this.dynamicSize&&e.length!==this.maxSize)throw new Error(`TensorArray's size is not equal to the size of lengths (${this.maxSize} vs. ${e.length}), and the TensorArray is not marked as dynamically resizeable`);let s=n===0?0:t.size/n,a=[];Z(()=>{t=J(t,[1,n,s]);for(let i=0;i<e.length;++i){let l=i===0?0:r[i-1],u=[0,l,0],c=[1,e[i],s];a[i]=J(nt(t,u,c),this.elementShape)}return a});let o=[];for(let i=0;i<e.length;i++)o[i]=i;this.writeMany(o,a)}},Qd=class{constructor(e,t,n,r=-1){this.tensors=e,this.elementShape=t,this.elementDtype=n,e!=null&&e.forEach(s=>{if(n!==s.dtype)throw new Error(`Invalid data types; op elements ${n}, but list elements ${s.dtype}`);Yr(t,s.shape,"TensorList shape mismatch: "),Sn(s)}),this.idTensor=Fe(0),this.maxNumElements=r,Sn(this.idTensor)}get id(){return this.idTensor.id}copy(){return new Qd([...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.`);Yr(e,this.elementShape,"TensorList shape mismatch: ");let r=Jd(this.elementShape,this.tensors,e);return Z(()=>{let s=this.tensors.map(a=>J(a,r));return Mr(s,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=Jd(this.elementShape,this.tensors,e),r=this.tensors.pop();return Yr(r.shape,e,"TensorList shape mismatch: "),J(r,n)}pushBack(e){if(e.dtype!==this.elementDtype)throw new Error(`Invalid data types; op elements ${e.dtype}, but list elements ${this.elementDtype}`);if(Yr(e.shape,this.elementShape,"TensorList shape mismatch: "),this.maxNumElements===this.size())throw new Error("Trying to push element into a full list.");Sn(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.`);Yr(this.tensors[e].shape,t,"TensorList shape mismatch: ");let r=Jd(this.elementShape,this.tensors,t);return J(this.tensors[e],r)}setItem(e,t){if(t.dtype!==this.elementDtype)throw new Error(`Invalid data types; op elements ${t.dtype}, but list elements ${this.elementDtype}`);if(e<0||this.maxNumElements!==-1&&e>=this.maxNumElements)throw new Error(`Trying to set element ${e} in a list with max ${this.maxNumElements} elements.`);Yr(this.elementShape,t.shape,"TensorList shape mismatch: "),Sn(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}`);Yr(this.elementShape,n,"TensorList shape mismatch: "),e=e.slice(0,this.size());let r=Jd(this.elementShape,this.tensors,n);return e.length===0?$s([],[0].concat(r)):Z(()=>{let s=e.map(a=>J(this.tensors[a],r));return Mr(s,0)})}concat(e,t){if(!!e&&e!==this.elementDtype)throw new Error(`TensorList dtype is ${this.elementDtype} but concat requested dtype ${e}`);Yr(this.elementShape,t,"TensorList shape mismatch: ");let n=Jd(this.elementShape,this.tensors,t);return this.size()===0?$s([],[0].concat(n)):Z(()=>{let r=this.tensors.map(s=>J(s,n));return en(r,0)})}};function ase(e,t,n){let r=e.dtype;if(e.shape.length<1)throw new Error(`Tensor must be at least a vector, but saw shape: ${e.shape}`);if(e.dtype!==n)throw new Error(`Invalid data types; op elements ${e.dtype}, but list elements ${n}`);let s=e.shape.slice(1);Yr(s,t,"TensorList shape mismatch: ");let a=ls(e);return new Qd(a,t,r)}function ose(e,t,n){return new Qd([],e,t,n)}function ise(e,t,n,r){if(t.length!==e.shape[0])throw new Error(`Expected len(indices) == tensor.shape[0], but saw: ${t.length} vs. ${e.shape[0]}`);let s=Math.max(...t);if(r!=null&&r!==-1&&s>=r)throw new Error(`Max index must be < array size (${s} vs. ${r})`);let a=new Qd([],n,e.dtype,r),o=ls(e,0);return t.forEach((i,l)=>{a.setItem(i,o[l])}),a}function lse(e,t,n){let r=0,s=t.map(c=>(r+=c,r));if(r!==e.shape[0])throw new Error(`Expected sum of lengths to be equal to
|
|
tensor.shape[0], but sum of lengths is
|
|
${r}, and tensor's shape is: ${e.shape}`);let a=e.shape.slice(1),o=I5(a,n),i=r===0?0:e.size/r,l=Z(()=>{let c=[];e=J(e,[1,r,i]);for(let d=0;d<t.length;++d){let h=d===0?0:s[d-1],p=[0,h,0],f=[1,t[d],i];c[d]=J(nt(e,p,f),o)}return e.dispose(),c}),u=new Qd([],n,e.dtype,t.length);for(let c=0;c<l.length;c++)u.setItem(c,l[c]);return u}var use=async(e,t,n)=>{switch(e.op){case"If":case"StatelessIf":{let r=S("thenBranch",e,t,n),s=S("elseBranch",e,t,n),a=S("cond",e,t,n),o=S("args",e,t,n);return(await a.data())[0]?n.functionMap[r].executeFunctionAsync(o,n.tensorArrayMap,n.tensorListMap):n.functionMap[s].executeFunctionAsync(o,n.tensorArrayMap,n.tensorListMap)}case"While":case"StatelessWhile":{let r=S("body",e,t,n),s=S("cond",e,t,n),a=S("args",e,t,n),o=await n.functionMap[s].executeFunctionAsync(a,n.tensorArrayMap,n.tensorListMap),i=a.map(c=>c.id),l=await o[0].data();o.forEach(c=>{!c.kept&&i.indexOf(c.id)===-1&&c.dispose()});let u=a;for(;l[0];){let c=u;u=await n.functionMap[r].executeFunctionAsync(u,n.tensorArrayMap,n.tensorListMap);let d=u.map(p=>p.id);c.forEach(p=>{!p.kept&&i.indexOf(p.id)===-1&&d.indexOf(p.id)===-1&&p.dispose()});let h=await n.functionMap[s].executeFunctionAsync(u,n.tensorArrayMap,n.tensorListMap);l=await h[0].data(),h.forEach(p=>{!p.kept&&i.indexOf(p.id)===-1&&d.indexOf(p.id)===-1&&p.dispose()})}return u}case"LoopCond":{let r=S("pred",e,t,n);return[ga(r)]}case"Switch":{let r=S("pred",e,t,n),s=S("data",e,t,n);return s.kept||(s=ga(s)),(await r.data())[0]?[void 0,s]:[s,void 0]}case"Merge":{let r=e.inputNames.find(s=>Bn(s,t,n)!==void 0);if(r){let s=Bn(r,t,n);return[ga(s)]}return}case"Enter":{let r=S("frameName",e,t,n),s=S("tensor",e,t,n);return n.enterFrame(r),[ga(s)]}case"Exit":{let r=S("tensor",e,t,n);return n.exitFrame(),[ga(r)]}case"NextIteration":{let r=S("tensor",e,t,n);return n.nextIteration(),[ga(r)]}case"TensorArrayV3":{let r=S("size",e,t,n),s=S("dtype",e,t,n),a=S("elementShape",e,t,n),o=S("dynamicSize",e,t,n),i=S("clearAfterRead",e,t,n),l=S("identicalElementShapes",e,t,n),u=S("name",e,t,n),c=new sse(u,s,r,a,l,o,i);return n.addTensorArray(c),[c.idTensor,Fe(1)]}case"TensorArrayWriteV3":{let r=S("tensorArrayId",e,t,n),s=S("index",e,t,n),a=S("tensor",e,t,n),o=n.getTensorArray(r.id);return o.write(s,a),[o.idTensor]}case"TensorArrayReadV3":{let r=S("tensorArrayId",e,t,n),s=S("index",e,t,n);return[n.getTensorArray(r.id).read(s)]}case"TensorArrayGatherV3":{let r=S("tensorArrayId",e,t,n),s=S("indices",e,t,n),a=S("dtype",e,t,n);return[n.getTensorArray(r.id).gather(s,a)]}case"TensorArrayScatterV3":{let r=S("tensorArrayId",e,t,n),s=S("indices",e,t,n),a=S("tensor",e,t,n),o=n.getTensorArray(r.id);return o.scatter(s,a),[o.idTensor]}case"TensorArrayConcatV3":{let r=S("tensorArrayId",e,t,n),s=n.getTensorArray(r.id),a=S("dtype",e,t,n);return[s.concat(a)]}case"TensorArraySplitV3":{let r=S("tensorArrayId",e,t,n),s=S("tensor",e,t,n),a=S("lengths",e,t,n),o=n.getTensorArray(r.id);return o.split(a,s),[o.idTensor]}case"TensorArraySizeV3":{let r=S("tensorArrayId",e,t,n),s=n.getTensorArray(r.id);return[Fe(s.size(),"int32")]}case"TensorArrayCloseV3":{let r=S("tensorArrayId",e,t,n),s=n.getTensorArray(r.id);return s.clearAndClose(),[s.idTensor]}case"TensorListSetItem":{let r=S("tensorListId",e,t,n),s=S("index",e,t,n),a=S("tensor",e,t,n),o=n.getTensorList(r.id);return o.setItem(s,a),[o.idTensor]}case"TensorListGetItem":{let r=S("tensorListId",e,t,n),s=S("index",e,t,n),a=S("elementShape",e,t,n),o=S("elementDType",e,t,n);return[n.getTensorList(r.id).getItem(s,a,o)]}case"TensorListScatterV2":case"TensorListScatter":{let r=S("indices",e,t,n),s=S("tensor",e,t,n),a=S("elementShape",e,t,n),o=S("numElements",e,t,n),i=ise(s,r,a,o);return n.addTensorList(i),[i.idTensor]}case"TensorListReserve":case"EmptyTensorList":{let r=S("elementShape",e,t,n),s=S("elementDType",e,t,n),a;e.op==="TensorListReserve"?a="numElements":a="maxNumElements";let o=S(a,e,t,n),i=ose(r,s,o);return n.addTensorList(i),[i.idTensor]}case"TensorListGather":{let r=S("tensorListId",e,t,n),s=S("indices",e,t,n),a=S("elementShape",e,t,n),o=S("elementDType",e,t,n);return[n.getTensorList(r.id).gather(s,o,a)]}case"TensorListStack":{let r=S("tensorListId",e,t,n),s=S("elementShape",e,t,n),a=S("elementDType",e,t,n),o=S("numElements",e,t,n);return[n.getTensorList(r.id).stack(s,a,o)]}case"TensorListFromTensor":{let r=S("tensor",e,t,n),s=S("elementShape",e,t,n),a=S("elementDType",e,t,n),o=ase(r,s,a);return n.addTensorList(o),[o.idTensor]}case"TensorListConcat":{let r=S("tensorListId",e,t,n),s=n.getTensorList(r.id),a=S("dtype",e,t,n),o=S("elementShape",e,t,n);return[s.concat(a,o)]}case"TensorListPushBack":{let r=S("tensorListId",e,t,n),s=S("tensor",e,t,n),a=n.getTensorList(r.id);return a.pushBack(s),[a.idTensor]}case"TensorListPopBack":{let r=S("tensorListId",e,t,n),s=S("elementShape",e,t,n),a=S("elementDType",e,t,n);return[n.getTensorList(r.id).popBack(s,a)]}case"TensorListSplit":{let r=S("tensor",e,t,n),s=S("elementShape",e,t,n),a=S("lengths",e,t,n),o=lse(r,a,s);return n.addTensorList(o),[o.idTensor]}default:throw TypeError(`Node type ${e.op} is not implemented`)}};function pT(e,t,n){let[r,s]=S("fusedOps",e,t,n),a=r==="biasadd",o=!a,i=s==="prelu",l=r==="fusedbatchnorm",u=S("numArgs",e,t,n);if(a){if(i&&u!==2)throw new Error("FusedConv2d and DepthwiseConv2d with BiasAdd and Prelu must have two extra arguments: bias and alpha.");if(!i&&a&&u!==1)throw new Error("FusedConv2d and DepthwiseConv2d with BiasAdd must have one extra argument: bias.")}if(l)throw new Error("FusedConv2d and DepthwiseConv2d with FusedBatchNorm is not supported");let c=S("strides",e,t,n),d=Im(e,t,n),h=S("dataFormat",e,t,n).toUpperCase(),p=S("dilations",e,t,n),[f,m]=S("args",e,t,n);o&&(m=f,f=void 0);let g=S("leakyreluAlpha",e,t,n);return{stride:c,pad:d,dataFormat:h,dilations:p,biasArg:f,preluArg:m,activationFunc:s,leakyreluAlpha:g}}var cse=(e,t,n)=>{switch(e.op){case"Conv1D":{let r=S("stride",e,t,n),s=S("pad",e,t,n),a=S("dataFormat",e,t,n).toUpperCase(),o=S("dilation",e,t,n);return[MA(S("x",e,t,n),S("filter",e,t,n),r,s,a,o)]}case"Conv2D":{let r=S("strides",e,t,n),s=Im(e,t,n),a=S("dataFormat",e,t,n).toUpperCase(),o=S("dilations",e,t,n);return[Ba(S("x",e,t,n),S("filter",e,t,n),[r[1],r[2]],s,a,[o[1],o[2]])]}case"_FusedConv2D":{let{stride:r,pad:s,dataFormat:a,dilations:o,biasArg:i,preluArg:l,activationFunc:u,leakyreluAlpha:c}=pT(e,t,n);return[ti.conv2d({x:S("x",e,t,n),filter:S("filter",e,t,n),strides:[r[1],r[2]],pad:s,dataFormat:a,dilations:[o[1],o[2]],bias:i,activation:u,preluActivationWeights:l,leakyreluAlpha:c})]}case"FusedDepthwiseConv2dNative":{let{stride:r,pad:s,dataFormat:a,dilations:o,biasArg:i,preluArg:l,activationFunc:u,leakyreluAlpha:c}=pT(e,t,n);return[ti.depthwiseConv2d({x:S("x",e,t,n),filter:S("filter",e,t,n),strides:[r[1],r[2]],pad:s,dataFormat:a,dilations:[o[1],o[2]],bias:i,activation:u,preluActivationWeights:l,leakyreluAlpha:c})]}case"Conv2DBackpropInput":case"Conv2dTranspose":{let r=S("outputShape",e,t,n),s=S("strides",e,t,n),a=Im(e,t,n);return[PA(S("x",e,t,n),S("filter",e,t,n),r,[s[1],s[2]],a)]}case"DepthwiseConv2dNative":case"DepthwiseConv2d":{let r=S("strides",e,t,n),s=Im(e,t,n),a=S("dilations",e,t,n),o=S("dataFormat",e,t,n).toUpperCase();return[Td(S("input",e,t,n),S("filter",e,t,n),[r[1],r[2]],s,o,[a[1],a[2]])]}case"Conv3D":{let r=S("strides",e,t,n),s=S("pad",e,t,n),a=S("dataFormat",e,t,n).toUpperCase(),o=S("dilations",e,t,n);return[nI(S("x",e,t,n),S("filter",e,t,n),[r[1],r[2],r[3]],s,a,[o[1],o[2],o[3]])]}case"AvgPool":{let r=S("strides",e,t,n),s=S("pad",e,t,n),a=S("kernelSize",e,t,n);return[Sf(S("x",e,t,n),[a[1],a[2]],[r[1],r[2]],s)]}case"MaxPool":{let r=S("strides",e,t,n),s=S("pad",e,t,n),a=S("kernelSize",e,t,n);return[$f(S("x",e,t,n),[a[1],a[2]],[r[1],r[2]],s)]}case"MaxPoolWithArgmax":{let r=S("strides",e,t,n),s=S("pad",e,t,n),a=S("kernelSize",e,t,n),o=S("includeBatchInIndex",e,t,n),{result:i,indexes:l}=sK(S("x",e,t,n),[a[1],a[2]],[r[1],r[2]],s,o);return[i,l]}case"AvgPool3D":{let r=S("strides",e,t,n),s=S("pad",e,t,n),a=S("kernelSize",e,t,n);return[Q6(S("x",e,t,n),[a[1],a[2],a[3]],[r[1],r[2],r[3]],s)]}case"MaxPool3D":{let r=S("strides",e,t,n),s=S("pad",e,t,n),a=S("kernelSize",e,t,n);return[gI(S("x",e,t,n),[a[1],a[2],a[3]],[r[1],r[2],r[3]],s)]}case"Dilation2D":{let r=S("strides",e,t,n),s=S("pad",e,t,n),a=S("dilations",e,t,n),o=r[1],i=r[2],l=a[1],u=a[2];return[aI(S("x",e,t,n),S("filter",e,t,n),[o,i],s,[l,u],"NHWC")]}default:throw TypeError(`Node type ${e.op} is not implemented`)}},dse=(e,t,n)=>{switch(e.op){case"Fill":{let r=S("shape",e,t,n),s=S("dtype",e,t,n),a=S("value",e,t,n);return[Cd(r,a,s)]}case"LinSpace":{let r=S("start",e,t,n),s=S("stop",e,t,n),a=S("num",e,t,n);return[Fq(r,s,a)]}case"Multinomial":{let r=S("logits",e,t,n),s=S("numSamples",e,t,n),a=S("seed",e,t,n);return[mK(r,s,a)]}case"OneHot":{let r=S("indices",e,t,n),s=S("depth",e,t,n),a=S("onValue",e,t,n),o=S("offValue",e,t,n);return[kd(r,s,a,o)]}case"Ones":return[la(S("shape",e,t,n),S("dtype",e,t,n))];case"OnesLike":return[Dr(S("x",e,t,n))];case"RandomUniform":return[Rd(S("shape",e,t,n),S("minval",e,t,n),S("maxval",e,t,n),S("dtype",e,t,n))];case"Range":{let r=S("start",e,t,n),s=S("stop",e,t,n),a=S("step",e,t,n);return[Dd(r,s,a,S("dtype",e,t,n))]}case"TruncatedNormal":{let r=S("shape",e,t,n),s=S("mean",e,t,n),a=S("stdDev",e,t,n),o=S("seed",e,t,n);return[l1(r,s,a,S("dtype",e,t,n),o)]}case"Zeros":return[un(S("shape",e,t,n),S("dtype",e,t,n))];case"ZerosLike":return[rt(S("x",e,t,n))];default:throw TypeError(`Node type ${e.op} is not implemented`)}};function S5(e,t,n){let r=S("boxes",e,t,n),s=S("scores",e,t,n),a=S("maxOutputSize",e,t,n),o=S("iouThreshold",e,t,n),i=S("scoreThreshold",e,t,n),l=S("softNmsSigma",e,t,n);return{boxes:r,scores:s,maxOutputSize:a,iouThreshold:o,scoreThreshold:i,softNmsSigma:l}}var hse=async(e,t,n)=>{switch(e.op){case"NonMaxSuppressionV5":{let{boxes:r,scores:s,maxOutputSize:a,iouThreshold:o,scoreThreshold:i,softNmsSigma:l}=S5(e,t,n),u=await ni.nonMaxSuppressionWithScoreAsync(r,s,a,o,i,l);return[u.selectedIndices,u.selectedScores]}case"NonMaxSuppressionV4":{let{boxes:r,scores:s,maxOutputSize:a,iouThreshold:o,scoreThreshold:i}=S5(e,t,n),l=S("padToMaxOutputSize",e,t,n),u=await ni.nonMaxSuppressionPaddedAsync(r,s,a,o,i,l);return[u.selectedIndices,u.validOutputs]}case"NonMaxSuppressionV3":case"NonMaxSuppressionV2":{let{boxes:r,scores:s,maxOutputSize:a,iouThreshold:o,scoreThreshold:i}=S5(e,t,n);return[await ni.nonMaxSuppressionAsync(r,s,a,o,i)]}case"Where":{let r=ke(S("condition",e,t,n),"bool"),s=[await NX(r)];return r.dispose(),s}case"ListDiff":return QK(S("x",e,t,n),S("y",e,t,n));default:throw TypeError(`Node type ${e.op} is not implemented`)}},pse=(e,t,n)=>{switch(e.op){case"TopKV2":{let r=S("x",e,t,n),s=S("k",e,t,n),a=S("sorted",e,t,n),o=TI(r,s,a);return[o.values,o.indices]}case"Unique":{let r=S("x",e,t,n),s=u1(r);return[s.values,s.indices]}case"UniqueV2":{let r=S("x",e,t,n),s=S("axis",e,t,n),a=u1(r,s);return[a.values,a.indices]}default:throw TypeError(`Node type ${e.op} is not implemented`)}},fse=(e,t,n)=>{switch(e.op){case"Const":return t[e.name];case"PlaceholderWithDefault":let r=S("default",e,t,n);return[Bn(e.name,t,n)||r];case"Placeholder":return[Bn(e.name,t,n)];case"Identity":case"StopGradient":case"FakeQuantWithMinMaxVars":{let u=S("x",e,t,n);return[ga(u)]}case"IdentityN":return S("x",e,t,n).map(u=>ga(u));case"Snapshot":let s=S("x",e,t,n);return[ga(s)];case"Shape":return[_n(S("x",e,t,n).shape,"int32")];case"ShapeN":return S("x",e,t,n).map(u=>_n(u.shape));case"Size":return[Fe(S("x",e,t,n).size,"int32")];case"Rank":return[Fe(S("x",e,t,n).rank,"int32")];case"NoOp":return[Fe(1)];case"Print":let a=S("x",e,t,n),o=S("data",e,t,n),i=S("message",e,t,n),l=S("summarize",e,t,n);console.warn("The graph has a tf.print() operation,usually used for debugging, which slows down performance."),console.log(i);for(let u=0;u<o.length;u++)console.log(Array.prototype.slice.call(o[u].dataSync()).slice(0,l));return[a];default:throw TypeError(`Node type ${e.op} is not implemented`)}},mse=class{constructor(e,t){this.keyDType=e,this.valueDType=t,this.handle=Fe(0),this.tensorMap=new Map,Sn(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 Fe(this.size(),"int32")}async import(e,t){this.checkKeyAndValueTensor(e,t);let n=await e.data();return this.tensorMap.forEach(r=>r.dispose()),this.tensorMap.clear(),Z(()=>{let r=ls(t),s=n.length,a=r.length;k.assert(s===a,()=>`The number of elements doesn't match, keys has ${s} elements, the values has ${a} elements.`);for(let o=0;o<s;o++){let i=n[o],l=r[o];Sn(l),this.tensorMap.set(i,l)}return this.handle})}async find(e,t){this.checkKeyAndValueTensor(e,t);let n=await e.data();return Z(()=>{let r=[];for(let s=0;s<n.length;s++){let a=n[s],o=this.findWithDefault(a,t);r.push(o)}return Mr(r)})}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}`)}},gse=async(e,t,n,r)=>{switch(e.op){case"HashTable":case"HashTableV2":{let s=S("keyDType",e,t,n),a=S("valueDType",e,t,n),o=new mse(s,a);return r.addHashTable(e.name,o),[o.handle]}case"LookupTableImport":case"LookupTableImportV2":{let s=S("tableHandle",e,t,n,r),a=S("keys",e,t,n),o=S("values",e,t,n);return[await r.getHashTableById(s.id).import(a,o)]}case"LookupTableFind":case"LookupTableFindV2":{let s=S("tableHandle",e,t,n,r),a=S("keys",e,t,n),o=S("defaultValue",e,t,n);return[await r.getHashTableById(s.id).find(a,o)]}case"LookupTableSize":case"LookupTableSizeV2":{let s=S("tableHandle",e,t,n,r);return[r.getHashTableById(s.id).tensorSize()]}default:throw TypeError(`Node type ${e.op} is not implemented`)}},yse=(e,t,n)=>{switch(e.op){case"ResizeBilinear":{let r=S("images",e,t,n),s=S("size",e,t,n),a=S("alignCorners",e,t,n),o=S("halfPixelCenters",e,t,n);return[ni.resizeBilinear(r,[s[0],s[1]],a,o)]}case"ResizeNearestNeighbor":{let r=S("images",e,t,n),s=S("size",e,t,n),a=S("alignCorners",e,t,n),o=S("halfPixelCenters",e,t,n);return[ni.resizeNearestNeighbor(r,[s[0],s[1]],a,o)]}case"CropAndResize":{let r=S("image",e,t,n),s=S("boxes",e,t,n),a=S("boxInd",e,t,n),o=S("cropSize",e,t,n),i=S("method",e,t,n),l=S("extrapolationValue",e,t,n);return[ni.cropAndResize(r,s,a,o,i,l)]}default:throw TypeError(`Node type ${e.op} is not implemented`)}},Ase=(e,t,n)=>{switch(e.op){case"Equal":return[Zo(S("a",e,t,n),S("b",e,t,n))];case"NotEqual":return[Yl(S("a",e,t,n),S("b",e,t,n))];case"Greater":return[_r(S("a",e,t,n),S("b",e,t,n))];case"GreaterEqual":return[Jo(S("a",e,t,n),S("b",e,t,n))];case"Less":return[WA(S("a",e,t,n),S("b",e,t,n))];case"LessEqual":return[Qo(S("a",e,t,n),S("b",e,t,n))];case"LogicalAnd":return[is(S("a",e,t,n),S("b",e,t,n))];case"LogicalNot":return[Ef(S("a",e,t,n))];case"LogicalOr":return[jA(S("a",e,t,n),S("b",e,t,n))];case"Select":case"SelectV2":return[Ln(S("condition",e,t,n),S("a",e,t,n),S("b",e,t,n))];default:throw TypeError(`Node type ${e.op} is not implemented`)}},xse=(e,t,n)=>{switch(e.op){case"BatchMatMul":case"BatchMatMulV2":case"MatMul":return[ot(S("a",e,t,n),S("b",e,t,n),S("transposeA",e,t,n),S("transposeB",e,t,n))];case"Einsum":return[pq(S("equation",e,t,n),...S("tensors",e,t,n))];case"Transpose":return[pt(S("x",e,t,n),S("perm",e,t,n))];case"_FusedMatMul":let[r,s]=S("fusedOps",e,t,n),a=r==="biasadd",o=s==="prelu",i=S("numArgs",e,t,n),l=S("leakyreluAlpha",e,t,n);if(a){if(o&&i!==2)throw new Error("Fused MatMul with BiasAdd and Prelu must have two extra arguments: bias and alpha.");if(!o&&i!==1)throw new Error("Fused MatMul with BiasAdd must have one extra argument: bias.")}let[u,c]=S("args",e,t,n);return[ti.matMul({a:S("a",e,t,n),b:S("b",e,t,n),transposeA:S("transposeA",e,t,n),transposeB:S("transposeB",e,t,n),bias:u,activation:s,preluActivationWeights:c,leakyreluAlpha:l})];default:throw TypeError(`Node type ${e.op} is not implemented`)}},bse=(e,t,n)=>{switch(e.op){case"FusedBatchNorm":case"FusedBatchNormV2":return[Xl(S("x",e,t,n),S("mean",e,t,n),S("variance",e,t,n),S("offset",e,t,n),S("scale",e,t,n),S("epsilon",e,t,n))];case"FusedBatchNormV3":return[Xl(S("x",e,t,n),S("mean",e,t,n),S("variance",e,t,n),S("offset",e,t,n),S("scale",e,t,n),S("epsilon",e,t,n))];case"LRN":return[dI(S("x",e,t,n),S("radius",e,t,n),S("bias",e,t,n),S("alpha",e,t,n),S("beta",e,t,n))];case"Softmax":return[Of(S("x",e,t,n))];case"LogSoftmax":return[UA(S("x",e,t,n))];case"SparseToDense":return[$I(S("sparseIndices",e,t,n),S("outputShape",e,t,n),S("sparseValues",e,t,n),S("defaultValue",e,t,n))];default:throw TypeError(`Node type ${e.op} is not implemented`)}},vse=(e,t,n)=>{switch(e.op){case"Max":{let o=S("axis",e,t,n),i=S("keepDims",e,t,n);return[os(S("x",e,t,n),o,i)]}case"Mean":{let o=S("axis",e,t,n),i=S("keepDims",e,t,n);return[Xt(S("x",e,t,n),o,i)]}case"Min":{let o=S("axis",e,t,n),i=S("keepDims",e,t,n);return[_f(S("x",e,t,n),o,i)]}case"Sum":{let o=S("axis",e,t,n),i=S("keepDims",e,t,n);return[_e(S("x",e,t,n),o,i)]}case"All":{let o=S("axis",e,t,n),i=S("keepDims",e,t,n);return[RA(S("x",e,t,n),o,i)]}case"Any":{let o=S("axis",e,t,n),i=S("keepDims",e,t,n);return[wf(S("x",e,t,n),o,i)]}case"ArgMax":{let o=S("axis",e,t,n);return[kf(S("x",e,t,n),o)]}case"ArgMin":{let o=S("axis",e,t,n);return[H6(S("x",e,t,n),o)]}case"Prod":{let o=S("axis",e,t,n),i=S("keepDims",e,t,n);return[KA(S("x",e,t,n),o,i)]}case"Cumsum":{let o=S("axis",e,t,n),i=S("exclusive",e,t,n),l=S("reverse",e,t,n);return[LA(S("x",e,t,n),o,i,l)]}case"Bincount":let r=S("x",e,t,n),s=S("weights",e,t,n),a=S("size",e,t,n);return[eI(r,s,a)];case"DenseBincount":{let o=S("x",e,t,n),i=S("weights",e,t,n),l=S("size",e,t,n),u=S("binaryOutput",e,t,n);return[eq(o,i,l,u)]}default:throw TypeError(`Node type ${e.op} is not implemented`)}},wse=(e,t,n)=>{switch(e.op){case"ConcatV2":case"Concat":{let r=S("n",e,t,n),s=S("axis",e,t,n),a=S("tensors",e,t,n);return a=a.slice(0,r),[en(a,s)]}case"Gather":{let r=S("x",e,t,n),s=S("indices",e,t,n);return[$d(r,ke(s,"int32"),0)]}case"GatherV2":{let r=S("axis",e,t,n),s=S("batchDims",e,t,n),a=S("x",e,t,n),o=S("indices",e,t,n);return[$d(a,ke(o,"int32"),r,s)]}case"Reverse":{let r=S("dims",e,t,n),s=[];for(let o=0;o<r.length;o++)r[o]&&s.push(o);let a=S("x",e,t,n);return[Fr(a,s)]}case"ReverseV2":{let r=S("axis",e,t,n),s=S("x",e,t,n);return[Fr(s,r)]}case"Slice":{let r=S("begin",e,t,n),s=S("size",e,t,n);return[nt(S("x",e,t,n),r,s)]}case"StridedSlice":{let r=S("begin",e,t,n),s=S("end",e,t,n),a=S("strides",e,t,n),o=S("beginMask",e,t,n),i=S("endMask",e,t,n),l=S("ellipsisMask",e,t,n),u=S("newAxisMask",e,t,n),c=S("shrinkAxisMask",e,t,n),d=S("x",e,t,n);return[II(d,r,s,a,o,i,l,u,c)]}case"Pack":return Z(()=>{let r=S("axis",e,t,n),s=S("tensors",e,t,n),a=s[0].shape,o=Jl(s[0]).shape,i=s.map(l=>{let u=k.arraysEqual(l.shape,a);if(!u&&!k.arraysEqual(Jl(l).shape,o))throw new Error("the input tensors shape does not match");return u?l:J(l,a)});return[Mr(i,r)]});case"Unpack":{let r=S("axis",e,t,n),s=S("tensor",e,t,n);return ls(s,r)}case"Tile":{let r=S("reps",e,t,n);return[Yo(S("x",e,t,n),r)]}case"Split":case"SplitV":{let r=S("axis",e,t,n),s=S("numOrSizeSplits",e,t,n),a=S("x",e,t,n);return dr(a,s,r)}case"ScatterNd":{let r=S("indices",e,t,n),s=S("values",e,t,n),a=S("shape",e,t,n);return[_X(r,s,a)]}case"GatherNd":{let r=S("x",e,t,n),s=S("indices",e,t,n);return[MX(r,s)]}case"SparseToDense":{let r=S("sparseIndices",e,t,n),s=S("outputShape",e,t,n),a=S("sparseValues",e,t,n),o=S("defaultValue",e,t,n);return[$I(r,a,s,a.dtype===o.dtype?o:ke(o,a.dtype))]}default:throw TypeError(`Node type ${e.op} is not implemented`)}},kse=(e,t,n)=>{switch(e.op){case"SparseFillEmptyRows":{let{outputIndices:r,outputValues:s,emptyRowIndicator:a,reverseIndexMap:o}=Vf.sparseFillEmptyRows(S("indices",e,t,n),S("values",e,t,n),S("denseShape",e,t,n),S("defaultValue",e,t,n));return[r,s,a,o]}case"SparseReshape":{let{outputIndices:r,outputShape:s}=Vf.sparseReshape(S("inputIndices",e,t,n),S("inputShape",e,t,n),S("newShape",e,t,n));return[r,s]}case"SparseSegmentMean":return[Vf.sparseSegmentMean(S("data",e,t,n),S("indices",e,t,n),S("segmentIds",e,t,n))];case"SparseSegmentSum":return[Vf.sparseSegmentSum(S("data",e,t,n),S("indices",e,t,n),S("segmentIds",e,t,n))];default:throw TypeError(`Node type ${e.op} is not implemented`)}},Ise=(e,t,n)=>{switch(e.op){case"FFT":return[a1(S("x",e,t,n))];case"IFFT":return[Pf(S("x",e,t,n))];case"RFFT":return[o1(S("x",e,t,n))];case"IRFFT":return[kI(S("x",e,t,n))];default:throw TypeError(`Node type ${e.op} is not implemented`)}},Sse=(e,t,n)=>{switch(e.op){case"StringNGrams":{let{nGrams:r,nGramsSplits:s}=p1.stringNGrams(S("data",e,t,n),S("dataSplits",e,t,n),S("separator",e,t,n),S("nGramWidths",e,t,n),S("leftPad",e,t,n),S("rightPad",e,t,n),S("padWidth",e,t,n),S("preserveShortSequences",e,t,n));return[r,s]}case"StringSplit":{let{indices:r,values:s,shape:a}=p1.stringSplit(S("input",e,t,n),S("delimiter",e,t,n),S("skipEmpty",e,t,n));return[r,s,a]}case"StringToHashBucketFast":return[p1.stringToHashBucketFast(S("input",e,t,n),S("numBuckets",e,t,n))];default:throw TypeError(`Node type ${e.op} is not implemented`)}},Tse=(e,t,n)=>{switch(e.op){case"Cast":return[ke(S("x",e,t,n),S("dtype",e,t,n))];case"ExpandDims":{let r=S("axis",e,t,n);return[$r(S("x",e,t,n),r)]}case"Squeeze":{let r=S("axis",e,t,n);return[Jl(S("x",e,t,n),r)]}case"Reshape":return[J(S("x",e,t,n),S("shape",e,t,n))];case"MirrorPad":return[yI(S("x",e,t,n),S("padding",e,t,n),S("mode",e,t,n))];case"PadV2":case"Pad":return[Wa(S("x",e,t,n),S("padding",e,t,n),S("constantValue",e,t,n))];case"SpaceToBatchND":{let r=S("blockShape",e,t,n),s=S("paddings",e,t,n);return[Rf(S("x",e,t,n),r,s)]}case"BatchToSpaceND":{let r=S("blockShape",e,t,n),s=S("crops",e,t,n);return[Tf(S("x",e,t,n),r,s)]}case"DepthToSpace":{let r=S("blockSize",e,t,n),s=S("dataFormat",e,t,n).toUpperCase();return[sI(S("x",e,t,n),r,s)]}case"BroadcastTo":return[Sd(S("x",e,t,n),S("shape",e,t,n))];default:throw TypeError(`Node type ${e.op} is not implemented`)}};function fT(e,t,n,r){let s=((a,o,i)=>{switch(a.category){case"arithmetic":return Z(()=>nse(a,o,i));case"basic_math":return Z(()=>rse(a,o,i));case"control":return use(a,o,i);case"convolution":return Z(()=>cse(a,o,i));case"creation":return Z(()=>dse(a,o,i));case"dynamic":return hse(a,o,i);case"evaluation":return Z(()=>pse(a,o,i));case"image":return Z(()=>yse(a,o,i));case"graph":return Z(()=>fse(a,o,i));case"logical":return Z(()=>Ase(a,o,i));case"matrices":return Z(()=>xse(a,o,i));case"normalization":return Z(()=>bse(a,o,i));case"reduction":return Z(()=>vse(a,o,i));case"slice_join":return Z(()=>wse(a,o,i));case"sparse":return Z(()=>kse(a,o,i));case"spectral":return Z(()=>Ise(a,o,i));case"string":return Z(()=>Sse(a,o,i));case"transformation":return Z(()=>Tse(a,o,i));case"hash_table":return gse(a,o,i,r);case"custom":let l=V8(a.op);if(l&&l.customExecutor)return l.customExecutor(new tse(a,o,i));throw TypeError(`Custom op ${a.op} is not registered.`);default:throw TypeError(`Unknown op '${a.op}'. File an issue at https://github.com/tensorflow/tfjs/issues so we can add it, or register a custom execution with tf.registerOp()`)}})(e,t,n);return k.isPromise(s)?s.then(a=>[].concat(a)):[].concat(s)}var mT=class{constructor(e={},t={},n={},r={}){this.weightMap=e,this.tensorArrayMap=t,this.tensorListMap=n,this.functionMap=r,this.rootContext={id:0,frameName:"",iterationId:0},this.contexts=[this.rootContext],this.lastId=0,this.generateCurrentContextIds()}newFrame(e,t){return{id:e,frameName:t,iterationId:0}}set currentContext(e){this.contexts!==e&&(this.contexts=e,this.generateCurrentContextIds())}get currentContext(){return this.contexts}get currentContextId(){return this._currentContextIds[0]}get currentContextIds(){return this._currentContextIds}generateCurrentContextIds(){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 gT(e,t,n,r){let s=new Set,a=[],o=null,i=null,l=new Set,u=Object.keys(e).map(h=>hr(h)[0]),c=[];r!=null&&(c=r.map(h=>hr(h.name)[0]));let d=[...t];for(;d.length>0;){let h=d.pop();if((yT(h)||_se(h)||Rse(h))&&o==null&&(o=h,i=o.children.map(p=>p.name).filter(p=>s.has(p))),s.add(h.name),n[h.name]==null&&u.indexOf(h.name)===-1&&c.indexOf(h.name)===-1){if(h.inputs.length===0){a.push(h.name);continue}h.inputs.forEach(p=>{l.has(p.name)||(l.add(p.name),d.push(p))})}}return{inputs:e,outputs:t,usedNodes:s,missingInputs:a,dynamicNode:o,syncInputs:i}}function Nse(e,t,n){let{usedNodes:r,inputs:s}=n,a=[],o=Object.keys(s).map(c=>hr(c)[0]).map(c=>e.nodes[c]),i=e.initNodes;o.forEach(c=>{r.has(c.name)&&a.push(c)}),e.weights.forEach(c=>{r.has(c.name)&&a.push(c)}),i!=null&&i.forEach(c=>{r.has(c.name)&&a.push(c)});let l=new Set,u=[];for(;a.length>0;){let c=a.pop();l.add(c.name),t[c.name]||u.push(c),c.children.forEach(d=>{!l.has(d.name)&&r.has(d.name)&&d.inputs.every(h=>l.has(h.name))&&a.push(d)})}return u}var Cse=["Switch","Merge","Enter","Exit","NextIteration","StatelessIf","StatelessWhile","if","While"],Ese=["NonMaxSuppressionV2","NonMaxSuppressionV3","NonMaxSuppressionV5","Where"],$se=["HashTable","HashTableV2","LookupTableImport","LookupTableImportV2","LookupTableFind","LookupTableFindV2","LookupTableSize","LookupTableSizeV2"];function yT(e){return Cse.indexOf(e.op)>=0}function _se(e){return Ese.indexOf(e.op)>=0}function Rse(e){return $se.indexOf(e.op)>=0}var T5=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 T5(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(r=>r.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(s=>s.name).sort(),r=t.map(s=>s.name).sort();return n.join(this.SEPERATOR)+"--"+r.join(this.SEPERATOR)}compile(e,t){let n=gT(e,t,this.weightMap,this._initNodes),{missingInputs:r,dynamicNode:s,syncInputs:a}=n;if(s!=null)throw new Error(`This execution contains the node '${s.name}', which has the dynamic op '${s.op}'. Please use model.executeAsync() instead. Alternatively, to avoid the dynamic ops, specify the inputs [${a}]`);if(r.length>0){let o=t.map(l=>l.name),i=Object.keys(e);throw new Error(`Cannot compute the outputs [${o}] from the provided inputs [${i}]. Missing the following inputs: [${r}]`)}return Nse(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 r=n.map(c=>this.graph.nodes[hr(c)[0]]),s=t.map(c=>hr(c)[0]),a=s.map(c=>this.graph.nodes[c]);a.length===0&&(a=this._outputs);let o=this.getCompilationKey(r,a),i=this.compiledMap.get(o);i==null&&(i=this.compile(e,a),this.compiledMap.set(o,i));let l={},u={};return Z(()=>{let c=new mT(this.weightMap,l,u,this.functionExecutorMap),d={...this.weightMap};Object.keys(e).forEach(f=>{let[m,g]=hr(f),y=[];y[g]=e[f],d[m]=y});let h=this.getFrozenTensorIds(d),p={};for(let f=0;f<i.length;f++){let m=i[f];if(!d[m.name]){let g=fT(m,d,c,this._resourceManager);if(k.isPromise(g))throw new Error(`The execution of the op '${m.op}' returned a promise. Please use model.executeAsync() instead.`);d[m.name]=g,this.checkTensorForDisposal(m.name,m,d,c,h,s,p)}}return this.parent==null&&c.dispose(h),t.map(f=>Bn(f,d,c))})}getFrozenTensorIds(e){let t=[].concat.apply([],Object.keys(e).map(n=>e[n]).map(n=>n.map(r=>r.id)));return new Set(t)}checkTensorForDisposal(e,t,n,r,s,a,o){t.category==="control"||a.indexOf(e)!==-1||(n[e].forEach(i=>{i!=null&&(o[i.id]=(o[i.id]||0)+t.children.length)}),t.inputs.forEach(i=>{if(i.category!=="control"){let l=Fre(i.name,n,r);l!=null&&l.forEach(u=>{if(u&&!u.kept&&!s.has(u.id)){let c=o[u.id];c===1?(u.dispose(),delete o[u.id]):c!=null&&o[u.id]--}})}}))}async executeAsync(e,t){return this._executeAsync(e,t)}async _executeAsync(e,t,n=!1,r={},s={}){n||(e=this.mapInputs(e),this.checkInputs(e),this.checkInputShapeAndType(e),t=this.mapOutputs(t),this.checkOutputs(t));let a=new mT(this.weightMap,r,s,this.functionExecutorMap),o=await this.executeWithControlFlow(e,a,t,n),i=t.map(d=>Bn(d,o,a)),l=i.map(d=>d.id),u=Object.keys(e).map(d=>e[d].id),c=new Set([...l,...u,...this.weightIds]);return Object.keys(o).forEach(d=>{o[d].forEach(p=>{p&&!p.kept&&!p.isDisposed&&!c.has(p.id)&&p.dispose()})}),this.parent==null&&a.dispose(c),i}async executeFunctionAsync(e,t,n){let r=e.reduce((s,a,o)=>(s[this.inputs[o].name]=a,s),{});return this._executeAsync(r,this.outputNodes,!0,t,n)}async executeWithControlFlow(e,t,n,r){let s=Object.keys(e),a=s.map(A=>this.graph.nodes[hr(A)[0]]),o=n.map(A=>hr(A)[0]),i=o.map(A=>this.graph.nodes[A]);i.length===0&&(i=this._outputs);let{usedNodes:l,missingInputs:u,dynamicNode:c,syncInputs:d}=gT(e,i,this.weightMap,this._initNodes),h=[...a,...this.graph.weights,...this._initNodes||[]].map(A=>({node:A,contexts:t.currentContext})),p={...this.weightMap};Object.keys(e).forEach(A=>{let[x,b]=hr(A),v=[];v[b]=e[A],p[x]=v});let f={},m=this.getFrozenTensorIds(p),g={};for(;h.length>0;){let A=this.processStack(a,h,t,p,g,m,o,f,l);await Promise.all(A)}c==null&&!r&&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=i.filter(A=>!yT(A)&&!Bn(A.name,p,t)).map(A=>A.name);if(y.length>0){let A="";throw c!=null&&(A=`Alternatively, to avoid the dynamic ops, use model.execute() and specify the inputs [${d}]`),new Error(`Cannot compute the outputs [${y}] from the provided inputs [${s}]. Consider providing the following inputs: [${u}]. ${A}`)}return p}processStack(e,t,n,r,s,a,o,i,l){let u=[];for(;t.length>0;){let c=t.pop();n.currentContext=c.contexts;let d="";if(c.node.op==="Enter"&&S("isConstant",c.node,r,n)&&([d]=ma(c.node.name,n)),r[c.node.name]==null){let h=fT(c.node,r,n,this._resourceManager);d||([d]=ma(c.node.name,n));let p=n.currentContext;k.isPromise(h)?u.push(h.then(f=>(r[d]=f,n.currentContext=p,this.checkTensorForDisposal(d,c.node,r,n,a,o,i),this.processChildNodes(c.node,t,n,r,s,l),f))):(r[d]=h,this.checkTensorForDisposal(d,c.node,r,n,a,o,i),this.processChildNodes(c.node,t,n,r,s,l))}else this.processChildNodes(c.node,t,n,r,s,l)}return u}processChildNodes(e,t,n,r,s,a){e.children.forEach(o=>{let[i]=ma(o.name,n);s[i]||!a.has(o.name)||(o.op==="Merge"?o.inputNames.some(l=>!!Bn(l,r,n))&&(s[i]=!0,t.push({contexts:n.currentContext,node:o})):o.inputNames.every(l=>!!Bn(l,r,n))&&(s[i]=!0,t.push({contexts:n.currentContext,node:o})))})}dispose(){Object.keys(this.weightMap).forEach(e=>this.weightMap[e].forEach(t=>t.dispose()))}checkInputShapeAndType(e){Object.keys(e).forEach(t=>{let n=e[t],[r]=hr(t),s=this.graph.nodes[r];if(s.attrParams.shape&&s.attrParams.shape.value){let a=s.attrParams.shape.value,o=a.length===n.shape.length&&n.shape.every((i,l)=>a[l]===-1||a[l]===i);k.assert(o,()=>`The shape of dict['${s.name}'] provided in model.execute(dict) must be [${a}], but was [${n.shape}]`)}s.attrParams.dtype&&s.attrParams.dtype.value&&k.assert(n.dtype===s.attrParams.dtype.value,()=>`The dtype of dict['${s.name}'] provided in model.execute(dict) must be ${s.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 r=this._signature.inputs[n];t[r.name]=e[n]}else t[n]=e[n];return t}checkInputs(e){let t=Object.keys(e).filter(n=>{let[r]=hr(n);return this.graph.nodes[r]==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]=hr(t);if(!this.graph.nodes[n])throw new Error(`The output '${t}' is not found in the graph`)})}},Dse=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]}},Fse="?tfjs-format=file",Mse="model.json",AT=class{constructor(e,t={}){this.modelUrl=e,this.loadOptions=t,this.version="n/a",t==null&&(this.loadOptions={}),this.resourceManager=new Dse}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=ur.browserHTTPRequest(e,this.loadOptions);else{let t=ur.getLoadHandlers(e,this.loadOptions);if(t.length===0)t.push(ur.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 r=ur.decodeWeights(this.artifacts.weightData,this.artifacts.weightSpecs);if(this.executor=new T5(lT.Instance.transformGraph(t,this.signature)),this.executor.weightMap=this.convertTensorMapToTensorsMap(r),this.executor.resourceManager=this.resourceManager,e.modelInitializer!=null&&e.modelInitializer.node!=null){let s=lT.Instance.transformGraph(e.modelInitializer);this.initializer=new T5(s),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=ur.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 Ct)&&!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,r)=>(t[n]=e[r],t),{})}normalizeOutputs(e){return e=e||this.outputNodes,Array.isArray(e)?e:[e]}execute(e,t){e=this.normalizeInputs(e),t=this.normalizeOutputs(t);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}${Mse}${Fse}`);let n=new AT(e,t);return await n.load(),n}var Ose="3.7.0",xT={};De(xT,{CSVDataset:()=>DT,Dataset:()=>uu,FileDataSource:()=>BT,TextLineDataset:()=>$T,URLDataSource:()=>WT,array:()=>aae,csv:()=>gae,func:()=>yae,generator:()=>Aae,microphone:()=>bae,version_data:()=>vae,webcam:()=>xae,zip:()=>oae});var Pse=Ks(z3()),zse=Ks(z3());function Lse(e,t){return Sm(e,t)}function Sm(e,t,n=new Map,r=new Set){if(e==null)return null;if(r.has(e))throw new Error("Circular references are not supported.");if(n.has(e))return n.get(e);let s=t(e);if(s.recurse&&s.value!==null)throw new Error("A deep map function may not return both a value and recurse=true.");if(s.recurse)if(lu(e)){let a=Array.isArray(e)?[]:{};r.add(e);for(let o in e){let i=e[o],l=Sm(i,t,n,r);a[o]=l}return r.delete(e),a}else throw new Error(`Can't recurse into non-iterable type: ${e}`);else return n.set(e,s.value),s.value}function Bse(e,t=vT){return bT(e,t)}function bT(e,t,n=new Set){let r=e[0];if(n.has(r))throw new Error("Circular references are not supported.");let s=t(e);if(s.recurse&&s.value!==null)throw new Error("A deep zip function may not return both a value and recurse=true.");if(s.recurse)if(lu(r)){let a=Array.isArray(r)?[]:{};n.add(r);for(let o in r){let i=e.map(u=>u[o]),l=bT(i,t,n);a[o]=l}return n.delete(r),a}else throw new Error(`Can't recurse into non-iterable type: ${r}`);else return s.value}function vT(e){return e===null?null:lu(e[0])?{value:null,recurse:!0}:{value:e,recurse:!1}}async function wT(e,t){let n=new Map;Sm(e,t,n);for(let s of Array.from(n.keys())){let a=n.get(s);if(k.isPromise(a)){let o=await a;n.set(s,o)}}return Sm(e,t,n)}function lu(e){return e!=null&&!ArrayBuffer.isView(e)&&(Array.isArray(e)||typeof e=="object"&&!(e instanceof Ct))}function Wse(e){return e==null||Vse(e)||Array.isArray(e)||typeof e=="object"&&e instanceof Ct||k.isTypedArray(e)}function Vse(e){return e===null||typeof e!="object"&&typeof e!="function"}function Use(e){return Lse(e,Hse)}function Hse(e){return e instanceof Ct?{value:e.clone(),recurse:!1}:lu(e)?{value:null,recurse:!0}:{value:e,recurse:!1}}var kT=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}},IT=class extends kT{constructor(){super(IT.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 r=0;r<n;r++)t[r]=this.get(this.wrap(this.begin+r));this.data=t,this.capacity=e,this.doubledCapacity=2*this.capacity,this.begin=0,this.end=n}},ST=IT;ST.INITIAL_CAPACITY=32;function TT(e){return new qse(e)}function N5(e){return new Kse(e)}function Gse(e,t){return new CT(e,t)}function jse(e,t=Tm.FAIL){return new rae(e,t)}var xn=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 tae(this,e)}filter(e){return new Qse(this,e)}map(e){return new eae(this,e)}mapAsync(e){return new NT(this,e)}serialMapAsync(e){return new NT(this,e).serial()}flatmap(e){return new nae(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 Jse(this,e,t)}columnMajorBatch(e,t=!0,n=vT){return this.rowMajorBatch(e,t).map(s=>Bse(s,n))}concatenate(e,t){return new CT(TT([this,e]),t)}take(e){return e<0||e==null?this:new Yse(this,e)}skip(e){return e<0||e==null?this:new Zse(this,e)}prefetch(e){return new ET(this,e)}shuffle(e,t){return new sae(this,e,t)}serial(){return new Xse(this)}},qse=class extends xn{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:Use(e),done:!1}}},Kse=class extends xn{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}}},Xse=class extends xn{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()}},Zse=class extends xn{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;je(e.value)}return this.upstream.next()}},Yse=class extends xn{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()}},Jse=class extends xn{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}}},Qse=class extends xn{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;je(e.value)}}},eae=class extends xn{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=Es.getTensorsInContainer(e.value),n=this.transform(e.value),r=Es.getTensorsInContainer(n);for(let s of t)Es.isTensorInList(s,r)||s.dispose();return{value:n,done:!1}}},tae=class extends xn{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}}}},NT=class extends xn{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=Es.getTensorsInContainer(e.value),n=await this.transform(e.value),r=Es.getTensorsInContainer(n);for(let s of t)Es.isTensorInList(s,r)||s.dispose();return{value:n,done:!1}}},C5=class extends xn{constructor(){super();this.outputQueue=new ST,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}}},nae=class extends C5{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=Es.getTensorsInContainer(e.value),n=this.transform(e.value),r=Es.getTensorsInContainer(n);this.outputQueue.pushAll(n);for(let s of t)Es.isTensorInList(s,r)||s.dispose();return!0}},CT=class extends xn{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}},Tm;(function(e){e[e.FAIL=0]="FAIL",e[e.SHORTEST=1]="SHORTEST",e[e.LONGEST=2]="LONGEST"})(Tm||(Tm={}));var rae=class extends xn{constructor(e,t=0){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 r(a){return a instanceof xn?{value:a.next().then(i=>(t++,i.done&&n++,i.value)),recurse:!1}:{value:null,recurse:!0}}let s=await wT(this.iterators,r);if(t===n)return{value:null,done:!0};if(n>0)switch(this.mismatchMode){case 0:throw new Error(`Zipped streams should have the same length. Mismatched at element ${this.count}.`);case 1:return{value:null,done:!0};case 2:default:}return this.count++,{value:s,done:!1}}async next(){return this.currentPromise=this.nextState(this.currentPromise),this.currentPromise}},ET=class extends xn{constructor(e,t){super();this.upstream=e,this.bufferSize=t,this.buffer=new kT(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()}},sae=class extends ET{constructor(e,t,n){super(e,t);this.upstream=e,this.windowSize=t,this.upstreamExhausted=!1,this.random=zse.alea(n||k.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}}},uu=class{constructor(){this.size=null}batch(e,t=!0){let n=this;k.assert(e>0,()=>`batchSize needs to be positive, but it is
|
|
${e}`);let r;return this.size===Infinity||this.size==null?r=this.size:t?r=Math.ceil(this.size/e):r=Math.floor(this.size/e),pr(async()=>(await n.iterator()).columnMajorBatch(e,t,iae),r)}concatenate(e){let t=this,n;return this.size===Infinity||e.size===Infinity?n=Infinity:this.size!=null&&e.size!=null?n=this.size+e.size:n=null,pr(async()=>(await t.iterator()).concatenate(await e.iterator()),n)}filter(e){let t=this,n;return this.size===Infinity?n=Infinity:n=null,pr(async()=>(await t.iterator()).filter(r=>Z(()=>e(r))),n)}async forEachAsync(e){return(await this.iterator()).forEachAsync(e)}map(e){let t=this;return pr(async()=>(await t.iterator()).map(n=>Z(()=>e(n))),this.size)}mapAsync(e){let t=this;return pr(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 pr(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=Infinity:n=null,pr(async()=>{let r=N5(async()=>({value:await t.iterator(),done:!1}));return Gse(r.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,pr(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 r=this,s=Pse.alea(t||k.now().toString());return pr(async()=>{let a=s.int32();return n&&(a+=s.int32()),(await r.iterator()).shuffle(e,a.toString())},this.size)}take(e){let t=this,n;return this.size!=null&&this.size>e?n=e:this.size!=null&&this.size<=e?n=this.size:n=null,pr(async()=>(await t.iterator()).take(e),n)}async toArray(){if(this.size===Infinity)throw new Error("Can not convert infinite data stream to array.");return(await this.iterator()).toArray()}async toArrayForTest(){if(this.size===Infinity)throw new Error("Can not convert infinite data stream to array.");return(await this.iterator()).toArrayForTest()}};uu.MAX_BUFFER_SIZE=1e4;function pr(e,t=null){return new class extends uu{constructor(){super(...arguments);this.size=t}async iterator(){return e()}}}function aae(e){return pr(async()=>TT(e),e.length)}function oae(e){if(!lu(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 pr(async()=>{let n=await wT(e,r=>{if(r instanceof uu)return{value:r.iterator(),recurse:!1};if(lu(r))return{value:null,recurse:!0};throw new Error("Leaves of the structure passed to zip() must be Datasets, not primitives.")});return jse(n,Tm.SHORTEST)},t)}function iae(e){if(e===null)return null;let t=e[0];return Wse(t)?{value:lae(e),recurse:!1}:{value:null,recurse:!0}}function lae(e){if(e.length===0)throw new Error("Can't make a batch of zero elements.");return e[0]instanceof Ct?Mr(e):$s(e)}var $T=class extends uu{constructor(e){super();this.input=e}async iterator(){return(await this.input.iterator()).decodeUTF8().split(`
|
|
`).map(r=>(r.endsWith("\r")&&(r=r.slice(0,-1)),r))}},Nm='"',eh=Symbol("out"),_T=Symbol("field"),Cm=Symbol("quote"),E5=Symbol("quoteafterquote"),RT=Symbol("quoteinquote"),DT=class extends uu{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 $T(e),t||(t={}),this.hasHeader=t.hasHeader!==!1,this.fullColumnNames=t.columnNames,this.columnConfigs=t.columnConfigs,this.configuredColumnsOnly=t.configuredColumnsOnly,t.delimWhitespace?(k.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&&k.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((r,s)=>(r[s]=r[s]+1||1,r),{}),n=Object.keys(t).filter(r=>t[r]>1);if(k.assert(n.length===0,()=>"Duplicate column names found: "+n.toString()),this.columnConfigs){for(let r of Object.keys(this.columnConfigs))if(this.fullColumnNames.indexOf(r)===-1)throw new Error('The key "'+r+'" provided in columnConfigs does not match any of the column names ('+this.fullColumnNames.toString()+").")}this.columnNamesValidated=!0}async maybeReadHeaderLine(){if(this.hasHeader){let t=await(await this.base.iterator()).next();if(t.done)throw new Error("No data was found for CSV parsing.");let n=t.value;return this.parseRow(n,!1)}else return null}async iterator(){this.columnNamesValidated||await this.setColumnNames();let e=await this.base.iterator();return this.hasHeader&&(e=e.skip(1)),e.map(t=>this.makeDataElement(t))}makeDataElement(e){let t=this.parseRow(e),n={},r={};for(let s=0;s<this.fullColumnNames.length;s++){let a=this.fullColumnNames[s],o=this.columnConfigs?this.columnConfigs[a]:null;if(!(this.configuredColumnsOnly&&!o)){let i=t[s],l=null;if(i==="")if(o&&o.default!==void 0)l=o.default;else{if(o&&(o.required||o.isLabel))throw new Error(`Required column ${a} is empty in this line: ${e}`);l=void 0}else{let u=Number(i);if(isNaN(u))o&&o.dtype==="bool"?l=this.getBoolean(i):l=i;else if(!o||!o.dtype)l=u;else switch(o.dtype){case"float32":l=u;break;case"int32":l=Math.floor(u);break;case"bool":l=this.getBoolean(i);break;default:l=u}}o&&o.isLabel?r[a]=l:n[a]=l}}return Object.keys(r).length===0?n:{xs:n,ys:r}}getBoolean(e){return e==="1"||e.toLowerCase()==="true"?1:0}parseRow(e,t=!0){let n=[],r=0,s=e.length,a=eh;for(let o=0;o<s;o++)switch(a){case eh:switch(e.charAt(o)){case Nm:r=o+1,a=Cm;break;case this.delimiter:if(r=o+1,this.delimiter===" "&&this.delimWhitespace)break;n.push(""),a=eh;break;default:a=_T,r=o;break}break;case _T:switch(e.charAt(o)){case this.delimiter:n.push(e.substring(r,o)),a=eh,r=o+1;break;default:}break;case Cm:switch(e.charAt(o)){case Nm:a=E5;break;default:}break;case E5:switch(e.charAt(o)){case this.delimiter:n.push(e.substring(r,o-1)),a=eh,r=o+1;break;case Nm:a=Cm;break;default:a=RT;break}break;case RT:switch(e.charAt(o)){case Nm:a=Cm;break;default:}break;default:}if(a===E5?n.push(e.substring(r,s-1)):n.push(e.substring(r)),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}},FT=class extends xn{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(ae().get("IS_NODE"))throw new Error("microphone API is only supported in browser environment.");let t=new FT(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 r=this.flattenQueue(n.freqDataQueue);e=this.getTensorFromAudioDataArray(r,[this.numFrames,this.columnTruncateLength,1])}if(this.includeWaveform){let r=this.flattenQueue(n.timeDataQueue);t=this.getTensorFromAudioDataArray(r,[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(r=>{let s=setInterval(()=>{this.includeSpectrogram&&(this.analyser.getFloatFrequencyData(this.freqData),this.freqData[0]===-Infinity&&r({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(s),r({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((r,s)=>n.set(r,s*t)),n}getTensorFromAudioDataArray(e,t){let n=new Float32Array(k.sizeFromShape(t));return n.set(e,n.length-e.length),$s(n,t)}},MT=class extends xn{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=_n([0],"int32"),this.webcamConfig.centerCrop){let n=this.webcamConfig.resizeWidth*1/this.webcamVideoElement.width,r=this.webcamConfig.resizeHeight*1/this.webcamVideoElement.height,s=(1-n)/2,a=(1-r)/2,o=s+n,i=r+a;this.cropBox=Ql([a,s,i,o],[1,4])}else this.cropBox=Ql([0,0,1,1],[1,4])}summary(){return"webcam"}static async create(e,t={}){if(ae().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 MT(e,t);return await n.start(),n}async start(){this.webcamConfig.facingMode&&k.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=k6.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 Z(()=>{let t=$r(ke(e,"float32"),0),n;n=ni.cropAndResize(t,this.cropBox,this.cropBoxInd,this.cropSize,"bilinear");let r=n.shape;return J(n,r.slice(1))})}async capture(){return(await this.next()).value}stop(){this.stream.getTracks().forEach(t=>t.stop());try{this.webcamVideoElement.srcObject=null}catch(t){console.log(t),this.webcamVideoElement.src=null}this.isClosed=!0}toArray(){throw new Error("Can not convert infinite video stream to array.")}},OT=class{},PT=class extends xn{split(e){return new uae(this,e)}},uae=class extends PT{constructor(e,t){super();this.upstream=e,this.impl=new cae(e,t)}summary(){return this.impl.summary()}async next(){return this.impl.next()}},cae=class extends C5{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}},dae=class extends xn{decodeUTF8(){return new hae(this)}},hae=class extends PT{constructor(e){super();this.upstream=e,this.impl=new pae(e)}summary(){return this.impl.summary()}async next(){return this.impl.next()}},pae=class extends C5{constructor(e){super();if(this.upstream=e,ae().get("IS_BROWSER"))this.decoder=new TextDecoder("utf-8");else{let{StringDecoder:t}=vR();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 ae().get("IS_BROWSER")?n=this.decoder.decode(t,{stream:!0}):n=this.decoder.write(Buffer.from(t.buffer)),this.outputQueue.push(n),!0}},zT=class extends dae{constructor(e,t={}){super();this.file=e,this.options=t,k.assert(e instanceof Uint8Array||(ae().get("IS_BROWSER")?e instanceof File||e instanceof Blob:!1),()=>"FileChunkIterator only supports File, Blob and Uint8Array right now."),this.offset=t.offset||0,this.chunkSize=t.chunkSize||1024*1024}summary(){return`FileChunks ${this.file}`}async next(){return this.offset>=(this.file instanceof Uint8Array?this.file.byteLength:this.file.size)?{value:null,done:!0}:{value:await new Promise((t,n)=>{let r=this.offset+this.chunkSize;if(this.file instanceof Uint8Array)t(new Uint8Array(this.file.slice(this.offset,r)));else{let s=new FileReader;s.onload=o=>{let i=s.result;if(i instanceof ArrayBuffer&&(i=new Uint8Array(i)),!(i instanceof Uint8Array))return n(new TypeError("FileReader returned unknown type."));t(i)},s.onabort=o=>n(new Error("Aborted")),s.onerror=o=>n(new Error(o.type));let a=this.file.slice(this.offset,r);s.readAsArrayBuffer(a)}this.offset=r}),done:!1}}};async function fae(e,t={}){let n,r;typeof e=="string"?n=e:(n=e.url,r=mae(e));let s=await k.fetch(n,r);if(s.ok){let a=new Uint8Array(await s.arrayBuffer());return new zT(a,t)}else throw new Error(s.statusText)}var mae=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 LT(e){return typeof e=="string"&&e.substr(0,7)==="file://"}var BT=class extends OT{constructor(e,t={}){super();this.input=e,this.options=t}async iterator(){if(LT(this.input)&&ae().get("IS_NODE")){let e=co("fs");this.input=e.readFileSync(this.input.substr(7))}return new zT(this.input,this.options)}},WT=class extends OT{constructor(e,t={}){super();this.url=e,this.fileOptions=t}async iterator(){return LT(this.url)?new BT(this.url,this.fileOptions).iterator():fae(this.url,this.fileOptions)}};function gae(e,t={}){return new DT(new WT(e),t)}function yae(e){let t=N5(e);return pr(async()=>t)}function Aae(e){return pr(async()=>{let t=await e();return N5(()=>t.next())})}async function xae(e,t){return MT.create(e,t)}async function bae(e){return FT.create(e)}var vae="3.7.0";function Te(e,t){Array.isArray(e)||(e=[e]),e.forEach(n=>{n!=null&&k.assert(n.dtype!=="complex64",()=>`${t} does not support complex64 tensors in the CPU backend.`)})}var wae=ca.whereImpl,VT=class extends Bp{constructor(){super();this.blockSize=48,this.firstUse=!0,this.data=new fy(this,za())}nextDataId(){return VT.nextDataId++}write(e,t,n){this.firstUse&&(this.firstUse=!1,ae().get("IS_NODE")&&_.warn(`
|
|
============================
|
|
Hi there \u{1F44B}. Looks like you are running TensorFlow.js in Node.js. To speed things up dramatically, install our node backend, which binds to TensorFlow C++, by running npm i @tensorflow/tfjs-node, or npm i @tensorflow/tfjs-node-gpu if you have CUDA. Then call require('@tensorflow/tfjs-node'); (-gpu suffix for CUDA) at the start of your program. Visit https://github.com/tensorflow/tfjs-node for more details.
|
|
============================`));let r={id:this.nextDataId()};return this.data.set(r,{values:e,dtype:n,refCount:1}),r}makeTensorInfo(e,t,n){let r;if(t==="string"&&n!=null&&n.length>0&&k.isString(n[0])){let s=n.map(a=>k.encodeString(a));r=this.write(s,e,t)}else r=this.write(n,e,t);return{dataId:r,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,r,s){this.data.set(e,{values:t,dtype:r,refCount:s})}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 r=this.readSync(n.real.dataId),s=this.readSync(n.imag.dataId);return _.mergeRealAndImagArrays(r,s)}return this.data.get(e).values}bufferSync(e){let t=this.readSync(e.dataId),n=t;if(e.dtype==="string")try{n=t.map(r=>k.decodeString(r))}catch(r){throw new Error("Failed to decode encoded string bytes into utf-8")}return Le(e.shape,e.dtype,n)}makeOutput(e,t,n){let r=this.write(e,t,n);return za().makeTensorFromDataId(r,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=k.now();return e(),{kernelMs:k.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 wae(e.shape,t)}dispose(){}floatPrecision(){return 32}epsilon(){return super.epsilon()}},$5=VT;$5.nextDataId=0;var UT={};De(UT,{addImpl:()=>GT,bincountImpl:()=>R5,bincountReduceImpl:()=>jT,ceilImpl:()=>qT,concatImpl:()=>KT,equalImpl:()=>XT,expImpl:()=>YT,expm1Impl:()=>QT,floorImpl:()=>eN,gatherNdImpl:()=>tN,gatherV2Impl:()=>nN,greaterEqualImpl:()=>sN,greaterImpl:()=>rN,lessEqualImpl:()=>oN,lessImpl:()=>aN,linSpaceImpl:()=>iN,logImpl:()=>lN,maxImpl:()=>uN,maximumImpl:()=>cN,minimumImpl:()=>dN,multiplyImpl:()=>D5,negImpl:()=>hN,notEqualImpl:()=>pN,prodImpl:()=>fN,rangeImpl:()=>mN,rsqrtImpl:()=>gN,simpleAbsImpl:()=>HT,sliceImpl:()=>yN,sparseFillEmptyRowsImpl:()=>AN,sparseReshapeImpl:()=>xN,sparseSegmentReductionImpl:()=>M5,squaredDifferenceImpl:()=>bN,stridedSliceImpl:()=>vN,stringNGramsImpl:()=>wN,stringSplitImpl:()=>kN,stringToHashBucketFastImpl:()=>IN,subImpl:()=>SN,tileImpl:()=>TN,topKImpl:()=>NN,transposeImpl:()=>F5,uniqueImpl:()=>CN});function HT(e){let t=new Float32Array(e.length);for(let n=0;n<e.length;++n)t[n]=Math.abs(e[n]);return t}var kae=e=>{let{x:t}=e.inputs,n=e.backend;Te(t,"abs");let r=new Float32Array(k.sizeFromShape(t.shape)),s=n.data.get(t.dataId).values;return r=HT(s),n.makeOutput(r,t.shape,"float32")},Iae={kernelName:xc,backendName:"cpu",kernelFunc:kae};function nn(e){return(t,n,r,s,a)=>{let o=_.assertAndGetBroadcastShape(t,n),i=o.length,l=k.computeStrides(o),u=k.sizeFromShape(o),c=k.getTypedArrayFromDType(a,u),d=t.length,h=n.length,p=k.computeStrides(t),f=k.computeStrides(n),m=_.getBroadcastDims(t,o),g=_.getBroadcastDims(n,o);if(m.length+g.length===0)for(let y=0;y<c.length;++y)c[y]=e(r[y%r.length],s[y%s.length]);else for(let y=0;y<c.length;++y){let A=k.indexToLoc(y,i,l),x=A.slice(-d);m.forEach(I=>x[I]=0);let b=k.locToIndex(x,d,p),v=A.slice(-h);g.forEach(I=>v[I]=0);let w=k.locToIndex(v,h,f);c[y]=e(r[b],s[w])}return[c,o]}}function fr(e){let{inputs:t,backend:n}=e,{real:r,imag:s}=t,a=n.data.get(r.dataId).values,o=n.data.get(s.dataId).values,i=n.makeTensorInfo(r.shape,"complex64"),l=n.data.get(i.dataId);return l.complexTensorInfos={real:n.makeTensorInfo(r.shape,"float32",a),imag:n.makeTensorInfo(s.shape,"float32",o)},i}var Sae={kernelName:Iy,backendName:"cpu",kernelFunc:fr};function Em(e,t,n="float32"){if(n==="complex64"){let s=Em(e,t,"float32"),a=Em(e,t,"float32");return fr({inputs:{real:s,imag:a},backend:e})}let r=k.makeZerosTypedArray(k.sizeFromShape(t),n);return e.makeTensorInfo(t,n,r)}function zs(e){let{inputs:t,backend:n}=e,{x:r}=t;return n.incRef(r.dataId),{dataId:r.dataId,shape:r.shape,dtype:r.dtype}}var Tae={kernelName:hl,backendName:"cpu",kernelFunc:zs};function pi(e){let{inputs:t,backend:n}=e,{input:r}=t,s=n.data.get(r.dataId).complexTensorInfos.real,a=n.data.get(s.dataId).values;return n.makeTensorInfo(s.shape,s.dtype,a)}var Nae={kernelName:Gy,backendName:"cpu",kernelFunc:pi};function Ja(e){let{inputs:t,backend:n,attrs:r}=e,{x:s}=t,{dtype:a}=r;if(a==="complex64"){if(s.dtype==="complex64")return zs({inputs:{x:s},backend:n});let o=Em(n,s.shape,s.dtype),i=Ja({inputs:{x:s},backend:n,attrs:{dtype:"float32"}}),l=fr({inputs:{real:i,imag:o},backend:n});return n.disposeIntermediateTensorInfo(o),n.disposeIntermediateTensorInfo(i),l}if(s.dtype==="complex64"){let o=pi({inputs:{input:s},backend:n}),i=Ja({inputs:{x:o},backend:n,attrs:{dtype:a}});return n.disposeIntermediateTensorInfo(o),i}if(!k.hasEncodingLoss(s.dtype,a)){let o=zs({inputs:{x:s},backend:n});return{dataId:o.dataId,shape:o.shape,dtype:a}}if(a==="int32"){let o=n.data.get(s.dataId).values,i=Int32Array.from(o);return n.makeTensorInfo(s.shape,"int32",i)}if(a==="bool"){let o=n.data.get(s.dataId).values,i=k.toTypedArray([0],s.dtype),[l,u]=nn((c,d)=>c!==d?1:0)(s.shape,[],o,i,"bool");return n.makeTensorInfo(u,"bool",l)}throw new Error(`Error in Cast: failed to cast ${s.dtype} to ${a}`)}var Cae={kernelName:el,backendName:"cpu",kernelFunc:Ja};function bn(e,t,n,r){return n==null?({inputs:s,backend:a})=>{let{a:o,b:i}=s,l=a;Te([o,i],e);let u=l.data.get(o.dataId).values,c=l.data.get(i.dataId).values,d=o.dtype==="string"?_.fromUint8ToStringArray(u):u,h=o.dtype==="string"?_.fromUint8ToStringArray(c):c,p=r||o.dtype,[f,m]=t(o.shape,i.shape,d,h,p);return l.makeTensorInfo(m,p,f)}:({inputs:s,backend:a})=>{let{a:o,b:i}=s,l=a;if(o.dtype==="complex64"||i.dtype==="complex64"){let u=Ja({inputs:{x:o},backend:l,attrs:{dtype:"complex64"}}),c=l.data.get(u.dataId),d=c.complexTensorInfos.real,h=c.complexTensorInfos.imag,p=l.data.get(d.dataId).values,f=l.data.get(h.dataId).values,m=Ja({inputs:{x:i},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,w,I]=n(o.shape,i.shape,p,f,x,b),T=l.makeTensorInfo(I,"float32",v),C=l.makeTensorInfo(I,"float32",w),M=fr({inputs:{real:T,imag:C},backend:l});return l.disposeIntermediateTensorInfo(u),l.disposeIntermediateTensorInfo(m),l.disposeIntermediateTensorInfo(T),l.disposeIntermediateTensorInfo(C),M}else{let u=l.data.get(o.dataId).values,c=l.data.get(i.dataId).values,d=r||o.dtype,[h,p]=t(o.shape,i.shape,u,c,d);return l.makeTensorInfo(p,d,h)}}}function _5(e){return(t,n,r,s,a,o)=>{let i=_.assertAndGetBroadcastShape(t,n),l=k.sizeFromShape(i),u=i.length,c=k.computeStrides(i),d=k.getTypedArrayFromDType("float32",l),h=k.getTypedArrayFromDType("float32",l),p=_.getBroadcastDims(t,i),f=_.getBroadcastDims(n,i),m=_.mergeRealAndImagArrays(r,s),g=_.mergeRealAndImagArrays(a,o),y=t.length,A=k.computeStrides(t),x=n.length,b=k.computeStrides(n);if(p.length+f.length===0)for(let v=0;v<d.length;v++){let w=v%m.length,I=v%g.length,T=e(m[w*2],m[w*2+1],g[I*2],g[I*2+1]);d[v]=T.real,h[v]=T.imag}else for(let v=0;v<d.length;v++){let w=k.indexToLoc(v,u,c),I=w.slice(-y);p.forEach(R=>I[R]=0);let T=k.locToIndex(I,y,A),C=w.slice(-x);f.forEach(R=>C[R]=0);let M=k.locToIndex(C,x,b),$=e(m[T*2],m[T*2+1],g[M*2],g[M*2+1]);d[v]=$.real,h[v]=$.imag}return[d,h,i]}}var GT=nn((e,t)=>e+t),Eae=_5((e,t,n,r)=>({real:e+n,imag:t+r})),th=bn(Fa,GT,Eae),$ae={kernelName:Fa,backendName:"cpu",kernelFunc:th};function R5(e,t,n,r,s){let a=k.sizeFromShape(r),o=k.makeZerosTypedArray(s,n);for(let i=0;i<e.length;i++){let l=e[i];if(l<0)throw new Error("Input x must be non-negative!");l>=s||(a>0?o[l]+=t[i]:o[l]+=1)}return o}function jT(e,t,n,r=!1){let s=e.shape[0],a=e.shape[1],o=Le([s,n],t.dtype);for(let i=0;i<s;i++)for(let l=0;l<a;l++){let u=e.get(i,l);if(u<0)throw new Error("Input x must be non-negative!");u>=n||(r?o.set(1,i,u):t.size>0?o.set(o.get(i,u)+t.get(i,l),i,u):o.set(o.get(i,u)+1,i,u))}return o}function cu(e){return(t,n,r)=>{let s=k.getTypedArrayFromDType(n,t.length);for(let a=0;a<t.length;++a)s[a]=e(t[a],r);return s}}function xt(e,t,n){return({inputs:r,attrs:s,backend:a})=>{let{x:o}=r;if(Te(o,e),o.dtype==="string"||n==="string")throw new Error("unaryKernelFunc does not support string input/output");let i=a,l=i.data.get(o.dataId).values,u=k.sizeFromShape(o.shape),c=n||o.dtype,d=k.getArrayFromDType(c,u);for(let h=0;h<u;++h)d[h]=t(l[h],s);return i.makeTensorInfo(o.shape,c,d)}}function du(e,t,n){return({inputs:r,attrs:s,backend:a})=>{let{x:o}=r;if(Te(o,e),o.dtype==="string"||n==="string")throw new Error("unaryKernelFunc does not support string input/output");let i=a,l=i.data.get(o.dataId).values,u=n||o.dtype,c=t(l,u,s);return i.makeTensorInfo(o.shape,u,c)}}var qT=cu(e=>Math.ceil(e)),_ae=du(No,qT),Rae={kernelName:No,backendName:"cpu",kernelFunc:_ae};function KT(e,t,n,r){let s=k.getArrayFromDType(n,k.sizeFromShape(t));if(r&&n!=="string"){let a=0;e.forEach(o=>{let i=k.sizeFromShape(o.shape);s.set(o.vals,a),a+=i})}else{let a=0;e.forEach(o=>{let i=n==="string"?_.fromUint8ToStringArray(o.vals):o.vals,l=0;for(let u=0;u<o.shape[0];++u){let c=u*t[1]+a;for(let d=0;d<o.shape[1];++d)s[c+d]=i[l++]}a+=o.shape[1]})}return s}var XT=nn((e,t)=>e===t?1:0),ZT=bn(il,XT,null,"bool"),Dae={kernelName:il,backendName:"cpu",kernelFunc:ZT},YT=cu(e=>Math.exp(e)),JT=du(Eo,YT),Fae={kernelName:Eo,backendName:"cpu",kernelFunc:JT},QT=cu(e=>Math.expm1(e)),Mae=du(ll,QT),Oae={kernelName:ll,backendName:"cpu",kernelFunc:Mae},eN=cu(e=>Math.floor(e)),Pae=du($o,eN),zae={kernelName:$o,backendName:"cpu",kernelFunc:Pae};function tN(e,t,n,r,s,a,o,i,l){let u=Le([r,a],n);for(let c=0;c<r;c++){let d=[],h=0;for(let p=0;p<s;p++){let f=e[c*s+p];h+=f*o[p],d.push(f)}if(h<0||h>=l/a)throw new Error(`Invalid indices: ${d} does not index into ${i}`);for(let p=0;p<a;p++)u.values[c*a+p]=t.get(...t.indexToLoc(h*a+p))}return u}function nN(e,t,n){let r=Le(n,e.dtype);for(let s=0;s<r.size;++s){let o=r.indexToLoc(s).slice(),i=o[0],l=o[2],u=t.locToIndex([i,l]);o[2]=t.values[u];let c=e.locToIndex(o);r.values[s]=e.values[c]}return r}var rN=nn((e,t)=>e>t?1:0),Lae=bn(dl,rN,null,"bool"),Bae={kernelName:dl,backendName:"cpu",kernelFunc:Lae},sN=nn((e,t)=>e>=t?1:0),Wae=bn(_o,sN,null,"bool"),Vae={kernelName:_o,backendName:"cpu",kernelFunc:Wae},aN=nn((e,t)=>e<t?1:0),Uae=bn(fl,aN,null,"bool"),Hae={kernelName:fl,backendName:"cpu",kernelFunc:Uae},oN=nn((e,t)=>e<=t?1:0),Gae=bn(ml,oN,null,"bool"),jae={kernelName:ml,backendName:"cpu",kernelFunc:Gae};function iN(e,t,n){let r=(t-e)/(n-1),s=k.makeZerosTypedArray(n,"float32");s[0]=e;for(let a=1;a<s.length;a++)s[a]=s[a-1]+r;return s}var lN=cu(e=>Math.log(e)),qae=du(Ro,lN),Kae={kernelName:Ro,backendName:"cpu",kernelFunc:qae};function uN(e,t,n,r){let s=k.getTypedArrayFromDType(r,k.sizeFromShape(n));for(let a=0;a<s.length;++a){let o=a*t,i=e[o];for(let l=0;l<t;++l){let u=e[o+l];(Number.isNaN(u)||u>i)&&(i=u)}s[a]=i}return s}var cN=nn((e,t)=>Math.max(e,t)),Xae=bn(Do,cN),Zae={kernelName:Do,backendName:"cpu",kernelFunc:Xae},dN=nn((e,t)=>Math.min(e,t)),Yae=bn(Fo,dN),Jae={kernelName:Fo,backendName:"cpu",kernelFunc:Yae},D5=nn((e,t)=>e*t),Qae=_5((e,t,n,r)=>({real:e*n-t*r,imag:e*r+t*n})),$m=bn(Mo,D5,Qae),eoe={kernelName:Mo,backendName:"cpu",kernelFunc:$m};function hN(e,t,n){let r=k.createScalarValue(-1,n);return D5([],t,r,e,n)}function toe(e){let{inputs:t,backend:n}=e,{x:r}=t;Te(r,"neg");let s=n.data.get(r.dataId).values,[a,o]=hN(s,r.shape,r.dtype);return n.makeTensorInfo(o,r.dtype,a)}var noe={kernelName:Gc,backendName:"cpu",kernelFunc:toe},pN=nn((e,t)=>e!==t?1:0),roe=bn(vl,pN,null,"bool"),soe={kernelName:vl,backendName:"cpu",kernelFunc:roe};function F5(e,t,n,r,s){let a=t.length,o=k.sizeFromShape(t),i=k.computeStrides(t),l=k.computeStrides(s),u=k.getTypedArrayFromDType(n,k.sizeFromShape(s));for(let c=0;c<o;++c){let d=k.indexToLoc(c,a,i),h=new Array(d.length);for(let f=0;f<h.length;f++)h[f]=d[r[f]];let p=k.locToIndex(h,a,l);u[p]=e[c]}return u}function Pr(e){let{inputs:t,attrs:n,backend:r}=e,{x:s}=t,{perm:a}=n;Te(s,"transpose");let o=s.shape.length,i=new Array(o);for(let d=0;d<i.length;d++)i[d]=s.shape[a[d]];let l=r.data.get(s.dataId).values,u=F5(l,s.shape,s.dtype,a,i);return{dataId:r.write(u,i,s.dtype),shape:i,dtype:s.dtype}}var aoe={kernelName:zl,backendName:"cpu",kernelFunc:Pr};function fN(e,t,n,r){let[s,a]=_.computeOutAndReduceShapes(e,r),o=qr(t,"int32"),i=k.makeZerosTypedArray(k.sizeFromShape(s),o),l=k.sizeFromShape(a);for(let u=0;u<i.length;++u){let c=u*l,d=1;for(let h=0;h<l;++h)d*=n[c+h];i[u]=d}return{outVals:i,outShape:s,outDtype:o}}function ooe(e){let{inputs:t,backend:n,attrs:r}=e,{x:s}=t,{axis:a,keepDims:o}=r;Te(s,"prod");let i=s.shape.length,l=k.parseAxisParam(a,s.shape),u=_.getAxesPermutation(l,i),c=l,d=s,h=[];u!=null&&(d=Pr({inputs:{x:s},backend:n,attrs:{perm:u}}),h.push(d),c=_.getInnerMostAxes(c.length,i));let p=n.data.get(d.dataId).values,{outVals:f,outShape:m,outDtype:g}=fN(d.shape,d.dtype,p,c),y=m;return o&&(y=_.expandShapeToKeepDim(m,l)),h.forEach(A=>n.disposeIntermediateTensorInfo(A)),n.makeTensorInfo(y,g,f)}var ioe={kernelName:Yc,backendName:"cpu",kernelFunc:ooe};function mN(e,t,n,r){let s=e===t,a=e<t&&n<0,o=t<e&&n>1;if(s||a||o)return k.makeZerosTypedArray(0,r);let i=Math.abs(Math.ceil((t-e)/n)),l=k.makeZerosTypedArray(i,r);t<e&&n===1&&(n=-1),l[0]=e;for(let u=1;u<l.length;u++)l[u]=l[u-1]+n;return l}var gN=cu(e=>1/Math.sqrt(e)),loe=du(Oo,gN),uoe={kernelName:Oo,backendName:"cpu",kernelFunc:loe};function yN(e,t,n,r,s){let a=En.isSliceContinous(r,t,n),o=k.sizeFromShape(n),i=k.computeStrides(r);if(a){let d=En.computeFlatOffset(t,i);return s==="string"?e.slice(d,d+o):e.subarray(d,d+o)}let l=s==="string"?_.fromUint8ToStringArray(e):e,u=Le(r,s,l),c=Le(n,s);for(let d=0;d<c.size;++d){let h=c.indexToLoc(d),p=h.map((f,m)=>f+t[m]);c.set(u.get(...p),...h)}return s==="string"?_.fromStringArrayToUint8(c.values):c.values}function fi(e){let{inputs:t,backend:n,attrs:r}=e,{x:s}=t,{begin:a,size:o}=r;Te(s,"slice");let[i,l]=En.parseSliceParams(s,a,o);En.assertParamsValid(s,i,l);let u=n.data.get(s.dataId).values,c=yN(u,i,l,s.shape,s.dtype);return n.makeTensorInfo(l,s.dtype,c)}var coe={kernelName:rd,backendName:"cpu",kernelFunc:fi};function AN(e,t,n,r,s,a,o){let i=t[0],l=a[0],u=new Array(l),c=new Array(i),d=t[1];if(l===0){if(i!==0)throw new Error(`Received SparseTensor with denseShape[0] = 0 but
|
|
indices.shape[0] = ${i}`);let g=k.getArrayFromDType(n,0),y=k.getArrayFromDType(s,0);return[g,[0,d],y,u,c]}let h=!0,p=0,f=new Array(l).fill(0);for(let g=0;g<i;++g){let y=e[g*d];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],h=h&&y>=p,p=y}let m=!0;for(let g=0;g<l;++g){let y=f[g]===0;u[g]=y,m=m&&!y,f[g]=Math.max(f[g],1),g>0&&(f[g]+=f[g-1])}if(m&&h){let g=e,y=r;for(let A=0;A<i;++A)c[A]=A;return[g,[i,d],y,u,c]}else{let g=f[l-1],y=k.getArrayFromDType(n,g*d),A=k.getArrayFromDType(s,g),x=new Array(l).fill(0);for(let b=0;b<i;++b){let v=e[b*d],w=x[v],I=(v===0?0:f[v-1])+w;x[v]++;for(let T=0;T<d;++T)y[I*d+T]=e[b*d+T];A[I]=r[b],c[b]=I}for(let b=0;b<l;++b)if(x[b]===0){let w=b===0?0:f[b-1];y[w*d+0]=b;for(let I=1;I<d;++I)y[w*d+I]=0;A[w]=o}return[y,[g,d],A,u,c]}}function xN(e,t,n,r,s){let a=k.sizeFromShape(r),o=t[0],i=s.length,l=[],u=1,c=-1;for(let g=0;g<i;++g){let y=s[g];if(y===-1){if(c!==-1)throw new Error(`only one output dimension may be -1, not both ${c} and ${g}`);c=g,l.push(1)}else{if(y<0)throw new Error(`size ${g} must be non-negative, not ${y}`);u*=y,l.push(y)}}if(c!==-1){if(u<=0)throw new Error("reshape cannot infer the missing input size for an empty tensor unless all specified input sizes are non-zero");let g=Math.trunc(a/u);if(u*g!==a)throw new Error(`Input to reshape is a SparseTensor with ${a}
|
|
dense values, but the requested shape requires a multiple of ${u}. inputShape=${r} outputShape= ${l}`);l[c]=g}let d=k.sizeFromShape(l);if(d!==a)throw new Error(`Input to reshape is a tensor with ${a} dense values, but the requested shape has ${d}. inputShape=${r} outputShape=${l}`);let h=r.length,p=[];if(h>0){p[h-1]=1;for(let g=h-2;g>=0;--g)p[g]=p[g+1]*r[g+1]}let f=[];if(i>0){f[i-1]=1;for(let g=i-2;g>=0;--g)f[g]=f[g+1]*l[g+1]}let m=k.getArrayFromDType(n,o*i);for(let g=0;g<o;++g){let y=0;for(let A=0;A<h;++A)y+=e[g*h+A]*p[A];for(let A=0;A<i;++A)m[g*i+A]=Math.trunc(y/f[A]),y%=f[A]}return[m,[o,i],l]}function M5(e,t,n,r,s,a=!1,o=0){let i=r.length;if(i!==s.length)throw new Error("segmentIds and indices should have same size.");let l=[t[0],e.length/t[0]],u=l[1],d=i>0?s[i-1]+1:0;if(d<0)throw new Error("segment ids must be >= 0");let h=t.slice();h[0]=d;let p=h.reduce((x,b)=>x*b,1),f=k.getArrayFromDType(n,p);if(i===0)return d>0&&f.fill(o),[f,h];if(d<=0)throw new Error("segment ids must be >= 0");let m=0,g=1,y=0,A=s[m];for(;;){let x=0;if(g<i){if(x=s[g],A===x){++g;continue}if(A>=x)throw new Error("segment ids are not increasing")}if(A<0||A>=d)throw new Error(`Segment id ${A} out of range [0, ${d}), possibly because segmentIds input is not sorted.`);A>y&&f.fill(o,y*u,A*u);for(let b=m;b<g;++b){let v=r[b];if(v<0||v>=l[0])throw new Error(`Bad: indices[${b}] == ${r[b]} out of range [0, ${l[0]})`);for(let w=0;w<u;w++)f[A*u+w]+=e[v*u+w]}if(a)for(let b=0;b<u;b++)f[A*u+b]/=g-m;if(m=g,++g,y=A+1,A=x,g>i)break}return y<d&&f.fill(o,y*u,d*u),[f,h]}var bN=nn((e,t)=>{let n=e-t;return n*n}),doe=bn(Po,bN),hoe={kernelName:Po,backendName:"cpu",kernelFunc:doe};function vN(e,t,n,r){let s=Le(e,t.dtype);for(let a=0;a<s.size;a++){let o=s.indexToLoc(a),i=new Array(o.length);for(let l=0;l<i.length;l++)i[l]=o[l]*n[l]+r[l];s.set(t.get(...i),...o)}return s}var poe=class{constructor(e,t,n,r,s,a){this.separator=k.encodeString(e),this.nGramWidths=t,this.leftPad=k.encodeString(n),this.rightPad=k.encodeString(r),this.padWidth=s,this.preserveShort=a}getPadWidth(e){return Math.min(this.padWidth<0?e-1:this.padWidth,e-1)}getNumNGrams(e,t){let n=this.getPadWidth(t);return Math.max(0,e+2*n-t+1)}createNGrams(e,t,n,r,s,a){for(let o=0;o<s;++o){let i=this.getPadWidth(a),l=Math.max(0,i-o),u=Math.max(0,i-(s-(o+1))),c=a-(l+u),d=t+(l>0?0:o-i),h=0;h+=l*this.leftPad.length;for(let y=0;y<c;++y)h+=e[d+y].length;h+=u*this.rightPad.length,h+=(l+u+c-1)*this.separator.length,n[r+o]=new Uint8Array(h);let f=n[r+o],m=0,g=y=>y.forEach(A=>f[m++]=A);for(let y=0;y<l;++y)g(this.leftPad),g(this.separator);for(let y=0;y<c-1;++y)g(e[d+y]),g(this.separator);if(c>0){g(e[d+c-1]);for(let y=0;y<u;++y)g(this.separator),g(this.rightPad)}else{for(let y=0;y<u-1;++y)g(this.rightPad),g(this.separator);g(this.rightPad)}}}compute(e,t){let n=e.length,r=t.length;if(r>0){let i=t[0];if(i!==0)throw new Error(`First split value must be 0, got ${i}`);for(let l=1;l<r;++l){let u=t[l]>=i;if(u=u&&t[l]<=n,!u)throw new Error(`Invalid split value ${t[l]}, must be in [${i}, ${n}]`);i=t[l]}if(i!==n)throw new Error(`Last split value must be data size. Expected ${n}, got ${i}`)}let s=r-1,a=k.getArrayFromDType("int32",r);if(n===0||r===0){let i=new Array(n);for(let l=0;l<=s;++l)a[l]=0;return[i,a]}a[0]=0;for(let i=1;i<=s;++i){let l=t[i]-t[i-1],u=0;this.nGramWidths.forEach(c=>{u+=this.getNumNGrams(l,c)}),this.preserveShort&&l>0&&u===0&&(u=1),a[i]=a[i-1]+u}let o=new Array(a[s]);for(let i=0;i<s;++i){let l=t[i],u=a[i];if(this.nGramWidths.forEach(c=>{let d=t[i+1]-t[i],h=this.getNumNGrams(d,c);this.createNGrams(e,l,o,u,h,c),u+=h}),this.preserveShort&&u===a[i]){let c=t[i+1]-t[i];if(c===0)continue;let d=c+2*this.padWidth,h=1;this.createNGrams(e,l,o,u,h,d)}}return[o,a]}};function wN(e,t,n,r,s,a,o,i){return new poe(n,r,s,a,o,i).compute(e,t)}function foe(e,t,n){if(!e.length)return[];if(t.length===0){let a=new Array(e.length);for(let o=0;o<e.length;++o)a[o]=e.subarray(o,o+1);return a}if(t.length===1){let a=t[0],o=[],i=e.indexOf(a);for(;i!==-1;){let l=e.subarray(0,i);(!n||l.length!==0)&&o.push(l),e=e.subarray(i+1),i=e.indexOf(a)}return(!n||e.length!==0)&&o.push(e),o}let r=[],s=0;for(let a=0;a<e.length+1;a++)if(a===e.length||t.indexOf(e[a])!==-1){let o=e.subarray(s,a);(!n||o.length!==0)&&r.push(o),s=a+1}return r}function kN(e,t,n){let r=e.length,s=[],a=0,o=0,i=new Array(r);for(let h=0;h<r;++h){let p=foe(e[h],t,n),f=p.length;i[h]=f,a+=f,o=Math.max(o,f),s.push(...p)}let l=k.getArrayFromDType("int32",a*2),u=new Array(a),c=[r,o],d=0;for(let h=0;h<r;++h)for(let p=0;p<i[h];++p)l[d*2]=h,l[d*2+1]=p,u[d]=s[d],++d;return[l,u,c]}function IN(e,t){let n=k.getArrayFromDType("int32",e.length);for(let r=0;r<e.length;++r)n[r]=k.fingerPrint64(e[r]).modulo(t).getLowBitsUnsigned();return n}var SN=nn((e,t)=>e-t),moe=_5((e,t,n,r)=>({real:e-n,imag:t-r})),O5=bn(zo,SN,moe),goe={kernelName:zo,backendName:"cpu",kernelFunc:O5};function TN(e,t){let n=new Array(e.rank);for(let s=0;s<n.length;s++)n[s]=e.shape[s]*t[s];let r=Le(n,e.dtype);for(let s=0;s<r.values.length;++s){let a=r.indexToLoc(s),o=new Array(e.rank);for(let l=0;l<o.length;l++)o[l]=a[l]%e.shape[l];let i=e.locToIndex(o);r.values[s]=e.values[i]}return r}function NN(e,t,n,r,s){let a=t[t.length-1],[o,i]=[e.length/a,a],l=k.getTypedArrayFromDType(n,o*r),u=k.getTypedArrayFromDType("int32",o*r);for(let d=0;d<o;d++){let h=d*i,p=e.subarray(h,h+i),f=[];for(let A=0;A<p.length;A++)f.push({value:p[A],index:A});f.sort((A,x)=>x.value-A.value);let m=d*r,g=l.subarray(m,m+r),y=u.subarray(m,m+r);for(let A=0;A<r;A++)g[A]=f[A].value,y[A]=f[A].index}let c=t.slice();return c[c.length-1]=r,[Le(c,n,l),Le(c,"int32",u)]}function CN(e,t,n,r){let s=k.parseAxisParam(t,n)[0],a=[1,n[0],1];for(let f=0;f<s;f++)a[0]*=n[f];a[1]=n[s];for(let f=s+1;f<n.length;f++)a[2]*=n[f];let o={},i=new Int32Array(n[s]),l=new Qt(a,r,e),u=[],c=a[0]===1&&a[2]===1;for(let f=0;f<n[s];f++){let m;if(c)m=e[f].toString();else{let g=[];for(let y=0;y<a[0];y++)for(let A=0;A<a[2];A++)g.push(l.get(y,f,A));m=g.join(",")}if(o[m]!==void 0)i[f]=o[m];else{let g=Object.keys(o).length;o[m]=g,i[f]=g,u.push(f)}}let d=a.slice();d[1]=Object.keys(o).length;let h=new Qt(d,r);u.forEach((f,m)=>{for(let g=0;g<a[0];g++)for(let y=0;y<a[2];y++)h.set(l.get(g,f,y),g,m,y)});let p=n.slice();return p[s]=d[1],{outputValues:h.values,outputShape:p,indices:i}}var yoe="3.7.0";$A("cpu",()=>new $5,1);var EN=xt(Dc,e=>e>=0?e:Math.exp(e)-1),Aoe={kernelName:Dc,backendName:"cpu",kernelFunc:EN};function $N(e){let{inputs:t,backend:n,attrs:r}=e,{x:s}=t,{alpha:a}=r;Te([s],"leakyRelu");let o=k.sizeFromShape(s.shape),i=n.data.get(s.dataId).values,l=k.getTypedArrayFromDType("float32",o);for(let u=0;u<i.length;u++)l[u]=i[u]<0?a*i[u]:i[u];return n.makeTensorInfo(s.shape,"float32",l)}var xoe={kernelName:pl,backendName:"cpu",kernelFunc:$N},boe=nn((e,t)=>e<0?t*e:e);function _N(e){let{inputs:t,backend:n}=e,{x:r,alpha:s}=t;Te([r,s],"prelu");let a=n.data.get(r.dataId).values,o=n.data.get(s.dataId).values,[i,l]=boe(r.shape,s.shape,a,o,r.dtype);return n.makeTensorInfo(l,r.dtype,i)}var voe={kernelName:Sl,backendName:"cpu",kernelFunc:_N},RN=xt(Tl,e=>Math.max(0,e)),woe={kernelName:Tl,backendName:"cpu",kernelFunc:RN},DN=xt(Cl,e=>Math.min(Math.max(0,e),6)),koe={kernelName:Cl,backendName:"cpu",kernelFunc:DN},FN=xt(Rl,e=>1/(1+Math.exp(-e))),Ioe={kernelName:Rl,backendName:"cpu",kernelFunc:FN};function P5(e,t,n,r,s){if(n==="linear")return zs({inputs:{x:t},backend:e});if(n==="relu")return RN({inputs:{x:t},backend:e});if(n==="elu")return EN({inputs:{x:t},backend:e});if(n==="relu6")return DN({inputs:{x:t},backend:e});if(n==="prelu")return _N({inputs:{x:t,alpha:r},backend:e});if(n==="leakyrelu")return $N({inputs:{x:t},backend:e,attrs:{alpha:s}});if(n==="sigmoid")return FN({inputs:{x:t},backend:e});throw new Error(`Activation ${n} has not been implemented for the CPU backend.`)}function Ft(e){let{inputs:t,backend:n,attrs:r}=e,{x:s}=t,{shape:a}=r,o=k.sizeFromShape(s.shape),i=k.inferFromImplicitShape(a,o),l=k.sizeFromShape(i);k.assert(o===l,()=>`The new shape (${i}) has ${l} elements and the old shape (${s.shape}) has ${o} elements. The new shape and old shape must have the same number of elements.`),n.incRef(s.dataId);let u=n.data.get(s.dataId);if(u.complexTensorInfos!=null){let c=u.complexTensorInfos.real,d=u.complexTensorInfos.imag;c.shape=i,d.shape=i}return{dataId:s.dataId,shape:i,dtype:s.dtype}}var Soe={kernelName:Qc,backendName:"cpu",kernelFunc:Ft};function MN(e){let{inputs:t,backend:n,attrs:r}=e,{a:s,b:a}=t,{transposeA:o,transposeB:i}=r;Te([s,a],"matMul");let l=s.shape.length,u=a.shape.length,c=o?s.shape[l-2]:s.shape[l-1],d=i?a.shape[u-1]:a.shape[u-2],h=o?s.shape[l-1]:s.shape[l-2],p=i?a.shape[u-2]:a.shape[u-1],f=s.shape.slice(0,-2),m=a.shape.slice(0,-2),g=k.sizeFromShape(f),y=k.sizeFromShape(m),A=g===y||g===1||y===1;k.assert(l>=2&&u>=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 b=(g>y?s.shape.slice(0,-2):a.shape.slice(0,-2)).concat([h,p]);k.assert(c===d,()=>`Error in matMul: inner shapes (${c}) and (${d}) of Tensors with shapes ${s.shape} and ${a.shape} and transposeA=${o} and transposeB=${i} must match.`);let v=o?[g,c,h]:[g,h,c],w=i?[y,p,d]:[y,d,p],I=Ft({inputs:{x:s},backend:n,attrs:{shape:v}}),T=Ft({inputs:{x:a},backend:n,attrs:{shape:w}}),C=o?I.shape[1]:I.shape[2],M=o?I.shape[2]:I.shape[1],$=i?T.shape[1]:T.shape[2],R=Math.max(g,y),N=n.data.get(I.dataId).values,F=n.data.get(T.dataId).values,B=k.computeStrides(I.shape),j=k.computeStrides(T.shape),[X,Y,ee]=o?[B[0],1,B[1]]:[B[0],B[1],1],[oe,se,ie]=i?[1,j[1],j[0]]:[j[1],1,j[0]],ne=M*$,de=Le([R,M,$],I.dtype),he=de.values,ge=n.blockSize;for(let be=0;be<R;be++)for(let Ee=0;Ee<M;Ee+=ge)for(let $e=0;$e<$;$e+=ge)for(let ze=0;ze<C;ze+=ge){let qe=Math.min(Ee+ge,M),We=Math.min($e+ge,$),vt=Math.min(ze+ge,C);for(let ft=Ee;ft<qe;ft++)for(let mt=$e;mt<We;mt++){let dt=0;for(let bt=ze;bt<vt;bt++){let Je=Math.min(be,g-1)*X,jn=Math.min(be,y-1)*ie,Wt=N[Je+ft*Y+bt*ee],sr=F[bt*oe+mt*se+jn];dt+=Wt*sr}he[be*ne+(ft*$+mt)]+=dt}}return n.disposeIntermediateTensorInfo(I),n.disposeIntermediateTensorInfo(T),n.makeTensorInfo(b,de.dtype,de.values)}var Toe={kernelName:Qi,backendName:"cpu",kernelFunc:MN};function Noe(e){let{inputs:t,backend:n,attrs:r}=e,{a:s,b:a,bias:o,preluActivationWeights:i}=t,{transposeA:l,transposeB:u,activation:c,leakyreluAlpha:d}=r,h,p,f,m=[];h=MN({inputs:{a:s,b:a},attrs:{transposeA:l,transposeB:u},backend:n}),o&&(p=th({inputs:{a:h,b:o},backend:n}),m.push(h),h=p),c&&(f=P5(n,h,c,i,d),m.push(h),h=f);for(let y of m)n.disposeIntermediateTensorInfo(y);return h}var Coe={kernelName:Ll,backendName:"cpu",kernelFunc:Noe},Eoe=xt(bc,e=>Math.acos(e)),$oe={kernelName:bc,backendName:"cpu",kernelFunc:Eoe},_oe=xt(vc,e=>Math.acosh(e)),Roe={kernelName:vc,backendName:"cpu",kernelFunc:_oe};function Doe(e){let{inputs:t,backend:n}=e,r=t;Te(t,"addN");let s=r.map(i=>n.data.get(i.dataId).values),a=Le(r[0].shape,r[0].dtype),o=a.values;for(let i=0;i<r.length;i++){let l=s[i];for(let u=0;u<o.length;u++)o[u]+=l[u]}return n.makeTensorInfo(a.shape,a.dtype,a.values)}var Foe={kernelName:Zi,backendName:"cpu",kernelFunc:Doe};function Moe(e){let{inputs:t,backend:n,attrs:r}=e,{x:s}=t,{axis:a,keepDims:o}=r;Te(s,"all");let i=k.parseAxisParam(a,s.shape),l=i,u=_.getAxesPermutation(l,s.shape.length),c=s;u!=null&&(c=Pr({inputs:{x:s},backend:n,attrs:{perm:u}}),l=_.getInnerMostAxes(l.length,s.shape.length)),_.assertAxesAreInnerMostDims("all",l,c.shape.length);let[d,h]=_.computeOutAndReduceShapes(c.shape,l),p=k.sizeFromShape(h),f=k.makeZerosTypedArray(k.sizeFromShape(d),c.dtype),m=n.data.get(c.dataId).values;for(let y=0;y<f.length;++y){let A=y*p,x=m[A];for(let b=0;b<p;++b){let v=m[A+b];x=x&&v}f[y]=x}u!=null&&n.disposeIntermediateTensorInfo(c);let g=n.makeTensorInfo(d,c.dtype,f);if(o){let y=_.expandShapeToKeepDim(d,i),A=Ft({inputs:{x:g},backend:n,attrs:{shape:y}});return n.disposeIntermediateTensorInfo(g),A}return g}var Ooe={kernelName:wc,backendName:"cpu",kernelFunc:Moe};function Poe(e){let{inputs:t,backend:n,attrs:r}=e,{x:s}=t,{axis:a,keepDims:o}=r;Te(s,"any");let i=k.parseAxisParam(a,s.shape),l=i,u=_.getAxesPermutation(l,s.shape.length),c=s;u!=null&&(c=Pr({inputs:{x:s},backend:n,attrs:{perm:u}}),l=_.getInnerMostAxes(l.length,s.shape.length)),_.assertAxesAreInnerMostDims("any",l,c.shape.length);let[d,h]=_.computeOutAndReduceShapes(c.shape,l),p=k.sizeFromShape(h),f=k.makeZerosTypedArray(k.sizeFromShape(d),c.dtype),m=n.data.get(c.dataId).values;for(let y=0;y<f.length;++y){let A=y*p,x=m[A];for(let b=0;b<p;++b){let v=m[A+b];x=x||v}f[y]=x}u!=null&&n.disposeIntermediateTensorInfo(c);let g=n.makeTensorInfo(d,c.dtype,f);if(o){let y=_.expandShapeToKeepDim(d,i),A=Ft({inputs:{x:g},backend:n,attrs:{shape:y}});return n.disposeIntermediateTensorInfo(g),A}return g}var zoe={kernelName:kc,backendName:"cpu",kernelFunc:Poe};function Loe(e){let{inputs:t,backend:n,attrs:r}=e,{x:s}=t,{axis:a}=r;Te(s,"argMax");let o=k.parseAxisParam(a,s.shape),i=_.getAxesPermutation(o,s.shape.length),l=s,u=[];i!=null&&(l=Pr({inputs:{x:s},backend:n,attrs:{perm:i}}),u.push(l),o=_.getInnerMostAxes(o.length,l.shape.length)),o=[o[0]],_.assertAxesAreInnerMostDims("argMax",o,l.shape.length);let[c,d]=_.computeOutAndReduceShapes(l.shape,o),h=k.sizeFromShape(c),p=k.makeZerosTypedArray(h,"int32"),f=k.sizeFromShape(d),m=n.data.get(l.dataId).values;for(let g=0;g<p.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)}p[g]=x}return u.forEach(g=>n.disposeIntermediateTensorInfo(g)),n.makeTensorInfo(c,"int32",p)}var Boe={kernelName:Yi,backendName:"cpu",kernelFunc:Loe};function Woe(e){let{inputs:t,backend:n,attrs:r}=e,{x:s}=t,{axis:a}=r;Te(s,"argMin");let o=k.parseAxisParam(a,s.shape),i=_.getAxesPermutation(o,s.shape.length),l=s,u=[];i!=null&&(l=Pr({inputs:{x:s},backend:n,attrs:{perm:i}}),u.push(l),o=_.getInnerMostAxes(o.length,l.shape.length)),o=[o[0]],_.assertAxesAreInnerMostDims("argMin",o,l.shape.length);let[c,d]=_.computeOutAndReduceShapes(l.shape,o),h=k.sizeFromShape(c),p=k.makeZerosTypedArray(h,"int32"),f=k.sizeFromShape(d),m=n.data.get(l.dataId).values;for(let g=0;g<p.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)}p[g]=x}return u.forEach(g=>n.disposeIntermediateTensorInfo(g)),n.makeTensorInfo(c,"int32",p)}var Voe={kernelName:qp,backendName:"cpu",kernelFunc:Woe},Uoe=xt(Ic,e=>Math.asin(e)),Hoe={kernelName:Ic,backendName:"cpu",kernelFunc:Uoe},Goe=xt(Sc,e=>Math.asinh(e)),joe={kernelName:Sc,backendName:"cpu",kernelFunc:Goe},qoe=xt(Tc,e=>Math.atan(e)),Koe={kernelName:Tc,backendName:"cpu",kernelFunc:qoe},Xoe=nn((e,t)=>Math.atan2(e,t)),Zoe=bn(Cc,Xoe),Yoe={kernelName:Cc,backendName:"cpu",kernelFunc:Zoe},Joe=xt(Nc,e=>Math.atanh(e)),Qoe={kernelName:Nc,backendName:"cpu",kernelFunc:Joe};function z5(e,t,n,r,s,a){let o=s.strideHeight,i=s.strideWidth,l=s.dilationHeight,u=s.dilationWidth,c=s.effectiveFilterHeight,d=s.effectiveFilterWidth,h=s.padInfo.top,p=s.padInfo.left,f=a==="max"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,m=Le(s.outShape,n),g=m.values,y=s.outShape[1]*s.outShape[2]*s.outShape[3],A=s.outShape[2]*s.outShape[3],x=s.outShape[3];for(let b=0;b<s.batchSize;++b){let v=b*y,w=b*r[0];for(let I=0;I<s.inChannels;++I)for(let T=0;T<s.outHeight;++T){let C=T*o-h,M=Math.max(0,C),$=Math.min(s.inHeight,c+C),R=v+T*A;for(let N=0;N<s.outWidth;++N){let F=N*i-p,B=Math.max(0,F),j=Math.min(s.inWidth,d+F),X=f,Y=0,ee=0;for(let se=M;se<$;se+=l){let ie=w+se*r[1];for(let ne=B;ne<j;ne+=u){let de=ie+ne*r[2],he=e[de+I];a==="max"&&he>X?X=he:a==="avg"&&(Y+=he,ee++)}if(isNaN(X))break}let oe=R+N*x+I;g[oe]=a==="avg"?Y/ee:X}}}return m}function ON(e,t,n,r,s=!1,a=!1){let o=Le(r.outShape,"int32"),i=r.strideHeight,l=r.strideWidth,u=r.dilationHeight,c=r.dilationWidth,d=r.effectiveFilterHeight,h=r.effectiveFilterWidth,p=r.padInfo.top,f=r.padInfo.left,m=Le(t,n,e);for(let g=0;g<r.batchSize;++g)for(let y=0;y<r.inChannels;++y)for(let A=0;A<r.outHeight;++A){let x=A*i-p,b=x;for(;b<0;)b+=u;let v=Math.min(r.inHeight,d+x);for(let w=0;w<r.outWidth;++w){let I=w*l-f,T=I;for(;T<0;)T+=c;let C=Math.min(r.inWidth,h+I),M=Number.NEGATIVE_INFINITY,$=-1;for(let R=b;R<v;R+=u){let N=R-x;for(let F=T;F<C;F+=c){let B=F-I,j=m.get(g,R,F,y);j>M&&(M=j,s?$=a?((g*r.inHeight+R)*r.inWidth+F)*r.inChannels+y:(R*r.inWidth+F)*r.inChannels+y:$=N*h+B)}}o.set($,g,A,w,y)}}return o}function PN(e,t,n,r,s,a){let o=s.strideDepth,i=s.strideHeight,l=s.strideWidth,u=s.dilationDepth,c=s.dilationHeight,d=s.dilationWidth,h=s.effectiveFilterDepth,p=s.effectiveFilterHeight,f=s.effectiveFilterWidth,m=s.padInfo.front,g=s.padInfo.top,y=s.padInfo.left,A=a==="max"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,x=Le(s.outShape,n),b=x.values,v=s.outShape[1]*s.outShape[2]*s.outShape[3]*s.outShape[4],w=s.outShape[2]*s.outShape[3]*s.outShape[4],I=s.outShape[3]*s.outShape[4],T=s.outShape[4];for(let C=0;C<s.batchSize;++C){let M=C*v,$=C*r[0];for(let R=0;R<s.inChannels;++R)for(let N=0;N<s.outDepth;++N){let F=N*o-m,B=F;for(;B<0;)B+=u;let j=Math.min(s.inDepth,h+F),X=M+N*w;for(let Y=0;Y<s.outHeight;++Y){let ee=Y*i-g,oe=ee;for(;oe<0;)oe+=c;let se=Math.min(s.inHeight,p+ee),ie=X+Y*I;for(let ne=0;ne<s.outWidth;++ne){let de=ne*l-y,he=de;for(;he<0;)he+=d;let ge=Math.min(s.inWidth,f+de),be=ie+ne*T,Ee=A,$e=0,ze=0;for(let We=B;We<j;We+=u){let vt=$+We*r[1];for(let ft=oe;ft<se;ft+=c){let mt=vt+ft*r[2];for(let dt=he;dt<ge;dt+=d){let bt=mt+dt*r[3],Je=e[bt+R];if(a==="max"&&Je>Ee?Ee=Je:a==="avg"&&($e+=Je,ze++),isNaN(Ee))break}if(isNaN(Ee))break}if(isNaN(Ee))break}let qe=be+R;b[qe]=a==="avg"?$e/ze:Ee}}}}return x}function eie(e,t){let n=Le(t.outShape,"int32"),r=t.strideDepth,s=t.strideHeight,a=t.strideWidth,o=t.dilationDepth,i=t.dilationHeight,l=t.dilationWidth,u=t.effectiveFilterDepth,c=t.effectiveFilterHeight,d=t.effectiveFilterWidth,h=t.padInfo.front,p=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*r-h,x=A;for(;x<0;)x+=o;let b=Math.min(t.inDepth,u+A);for(let v=0;v<t.outHeight;++v){let w=v*s-p,I=w;for(;I<0;)I+=i;let T=Math.min(t.inHeight,c+w);for(let C=0;C<t.outWidth;++C){let M=C*a-f,$=M;for(;$<0;)$+=l;let R=Math.min(t.inWidth,d+M),N=Number.NEGATIVE_INFINITY,F=-1;for(let B=x;B<b;B+=o){let j=B-A;for(let X=I;X<T;X+=i){let Y=X-w;for(let ee=$;ee<R;ee+=l){let oe=ee-M,se=e.get(m,B,X,ee,g);se>=N&&(N=se,F=j*c*d+Y*c+oe)}}}n.set(F,m,y,v,C,g)}}}return n}function tie(e){let{inputs:t,backend:n,attrs:r}=e,{x:s}=t;Te(s,"avgPool");let{filterSize:a,strides:o,pad:i,dimRoundingMode:l}=r,u=1;k.assert(_.eitherStridesOrDilationsAreOne(o,u),()=>`Error in avgPool: Either strides or dilations must be 1. Got strides ${o} and dilations '${u}'`);let c=_.computePool2DInfo(s.shape,a,o,u,i,l),d;if(c.filterWidth===1&&c.filterHeight===1&&k.arraysEqual(c.inShape,c.outShape))d=zs({inputs:{x:s},backend:n});else{let h=n.data.get(s.dataId).values,p=k.computeStrides(s.shape),f=z5(h,s.shape,s.dtype,p,c,"avg");d=n.makeTensorInfo(c.outShape,s.dtype,f.values)}return d}var nie={kernelName:Ji,backendName:"cpu",kernelFunc:tie};function rie(e){let{inputs:t,backend:n,attrs:r}=e,{x:s}=t,{filterSize:a,strides:o,pad:i,dimRoundingMode:l,dataFormat:u}=r;Te(s,"avgPool3d");let c=_.computePool3DInfo(s.shape,a,o,1,i,l,u),d=n.data.get(s.dataId).values,h=PN(d,s.shape,s.dtype,k.computeStrides(s.shape),c,"avg");return n.makeTensorInfo(h.shape,"float32",h.values)}var sie={kernelName:Kp,backendName:"cpu",kernelFunc:rie};function aie(e){let{inputs:t,backend:n,attrs:r}=e,{dy:s,input:a}=t,{filterSize:o,strides:i,pad:l,dimRoundingMode:u}=r;Te([s,a],"avgPool3DGrad");let c=_.computePool3DInfo(a.shape,o,i,1,l,u),d=c.strideDepth,h=c.strideHeight,p=c.strideWidth,f=c.filterDepth,m=c.filterHeight,g=c.filterWidth,y=c.dilationDepth,A=c.dilationHeight,x=c.dilationWidth,b=c.effectiveFilterDepth,v=c.effectiveFilterHeight,w=c.effectiveFilterWidth,I=b-1-c.padInfo.front,T=w-1-c.padInfo.left,C=v-1-c.padInfo.top,M=Le(a.shape,"float32"),$=1/(f*m*g),R=n.bufferSync(s);for(let N=0;N<c.batchSize;++N)for(let F=0;F<c.inChannels;++F)for(let B=0;B<c.inDepth;++B)for(let j=0;j<c.inHeight;++j)for(let X=0;X<c.inWidth;++X){let Y=B-I,ee=j-C,oe=X-T,se=0;for(let ie=0;ie<b;ie+=y){let ne=(Y+ie)/d;if(!(ne<0||ne>=c.outDepth||Math.floor(ne)!==ne))for(let de=0;de<v;de+=A){let he=(ee+de)/h;if(!(he<0||he>=c.outHeight||Math.floor(he)!==he))for(let ge=0;ge<w;ge+=x){let be=(oe+ge)/p;if(be<0||be>=c.outWidth||Math.floor(be)!==be)continue;se+=R.get(N,ne,he,be,F)}}}M.set(se*$,N,B,j,X,F)}return n.makeTensorInfo(M.shape,M.dtype,M.values)}var oie={kernelName:wy,backendName:"cpu",kernelFunc:aie};function iie(e){let{inputs:t,backend:n,attrs:r}=e,{dy:s,input:a}=t,o=a;Te([s,a],"avgPoolGrad");let{filterSize:i,strides:l,pad:u}=r,c=_.computePool2DInfo(o.shape,i,l,1,u),d=c.strideHeight,h=c.strideWidth,p=c.filterHeight,f=c.filterWidth,m=c.dilationHeight,g=c.dilationWidth,y=c.effectiveFilterHeight,A=c.effectiveFilterWidth,x=A-1-c.padInfo.left,b=y-1-c.padInfo.top,v=Le(o.shape,"float32"),w=1/(p*f),I=n.data.get(s.dataId).values,T=Le(s.shape,"float32",I);for(let C=0;C<c.batchSize;++C)for(let M=0;M<c.inChannels;++M)for(let $=0;$<c.inHeight;++$)for(let R=0;R<c.inWidth;++R){let N=$-b,F=R-x,B=0;for(let j=0;j<y;j+=m){let X=(N+j)/d;if(!(X<0||X>=c.outHeight||Math.floor(X)!==X))for(let Y=0;Y<A;Y+=g){let ee=(F+Y)/h;if(ee<0||ee>=c.outWidth||Math.floor(ee)!==ee)continue;B+=T.get(C,X,ee,M)}}v.set(B*w,C,$,R,M)}return n.makeTensorInfo(v.shape,v.dtype,v.values)}var lie={kernelName:vy,backendName:"cpu",kernelFunc:iie};function uie(e){let{inputs:t,backend:n,attrs:r}=e,{x:s,scale:a,offset:o,mean:i,variance:l}=t;k.assert(i.shape.length===l.shape.length,()=>"Batch normalization gradient requires mean and variance to have equal ranks."),k.assert(o==null||i.shape.length===o.shape.length,()=>"Batch normalization gradient requires mean and offset to have equal ranks."),k.assert(a==null||i.shape.length===a.shape.length,()=>"Batch normalization gradient requires mean and scale to have equal ranks."),Te([s,i,l,a,o],"batchNorm");let{varianceEpsilon:u}=r;u==null&&(u=.001);let c=n.data.get(s.dataId).values,d=n.data.get(i.dataId).values,h=n.data.get(l.dataId).values,p=a?n.data.get(a.dataId).values:new Float32Array([1]),f=o?n.data.get(o.dataId).values:new Float32Array([0]),m=new Float32Array(c.length),g=f.length,y=p.length,A=h.length,x=d.length,b=0,v=0,w=0,I=0;for(let T=0;T<c.length;++T)m[T]=f[b++]+(c[T]-d[v++])*p[w++]/Math.sqrt(h[I++]+u),b>=g&&(b=0),v>=x&&(v=0),w>=y&&(w=0),I>=A&&(I=0);return n.makeTensorInfo(s.shape,s.dtype,m)}var cie={kernelName:cl,backendName:"cpu",kernelFunc:uie};function die(e){let{inputs:t,backend:n,attrs:r}=e,{x:s}=t,{blockShape:a,crops:o}=r;Te([s],"batchToSpaceND");let i=a.reduce((y,A)=>y*A),l=_.getReshaped(s.shape,a,i),u=_.getPermuted(l.length,a.length),c=_.getReshapedPermuted(s.shape,a,i),d=_.getSliceBeginCoords(o,a.length),h=_.getSliceSize(c,o,a.length),p=Ft({inputs:{x:s},backend:n,attrs:{shape:l}}),f=Pr({inputs:{x:p},backend:n,attrs:{perm:u}}),m=Ft({inputs:{x:f},backend:n,attrs:{shape:c}}),g=fi({inputs:{x:m},backend:n,attrs:{begin:d,size:h}});return n.disposeIntermediateTensorInfo(p),n.disposeIntermediateTensorInfo(f),n.disposeIntermediateTensorInfo(m),g}var hie={kernelName:Xp,backendName:"cpu",kernelFunc:die};function pie(e){let{inputs:t,backend:n,attrs:r}=e,{x:s,weights:a}=t,{size:o}=r,i=n.data.get(s.dataId).values,l=n.data.get(a.dataId).values,u=R5(i,l,a.dtype,a.shape,o);return n.makeTensorInfo([o],a.dtype,u)}var fie={kernelName:ky,backendName:"cpu",kernelFunc:pie},mie=xt(Co,(e,t)=>{let n=t;return e>n.clipValueMax?n.clipValueMax:e<n.clipValueMin?n.clipValueMin:e}),gie={kernelName:Co,backendName:"cpu",kernelFunc:mie},yie=e=>{let{x:t}=e.inputs,n=e.backend,r=new Float32Array(k.sizeFromShape(t.shape)),s=n.data.get(t.dataId),a=s.complexTensorInfos.real,o=s.complexTensorInfos.imag,i=n.data.get(a.dataId).values,l=n.data.get(o.dataId).values;for(let u=0;u<i.length;u++){let c=i[u],d=l[u];r[u]=Math.hypot(c,d)}return n.makeOutput(r,t.shape,"float32")},Aie={kernelName:Zp,backendName:"cpu",kernelFunc:yie};function hu(e){let{inputs:t,backend:n}=e,{input:r}=t,s=n.data.get(r.dataId).complexTensorInfos.imag,a=n.data.get(s.dataId).values;return n.makeTensorInfo(s.shape,s.dtype,a)}var xie={kernelName:zy,backendName:"cpu",kernelFunc:hu};function pu(e){let{inputs:t,backend:n,attrs:r}=e,{axis:s}=r,a=k.parseAxisParam(s,t[0].shape)[0],o=_.computeOutShape(t.map(m=>m.shape),a);if(k.sizeFromShape(o)===0)return n.makeTensorInfo(o,t[0].dtype,[]);let i=t.filter(m=>k.sizeFromShape(m.shape)>0);if(i.length===1)return zs({inputs:{x:i[0]},backend:n});let l=i.map(m=>m.shape);if(_.assertParamsConsistent(l,a),i[0].dtype==="complex64"){let m=i.map(b=>pi({inputs:{input:b},backend:n})),g=i.map(b=>hu({inputs:{input:b},backend:n})),y=pu({inputs:m,backend:n,attrs:{axis:a}}),A=pu({inputs:g,backend:n,attrs:{axis:a}}),x=fr({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 u=i.map(m=>{let g=k.sizeFromShape(m.shape.slice(a));return Ft({inputs:{x:m},backend:n,attrs:{shape:[-1,g]}})}),c=u.map(m=>({vals:n.data.get(m.dataId).values,shape:m.shape}));o=_.computeOutShape(u.map(m=>m.shape),1);let d=u[0].shape[0]===1,h=KT(c,o,t[0].dtype,d),p=_.computeOutShape(i.map(m=>m.shape),a),f=n.makeTensorInfo(p,t[0].dtype,h);return u.forEach(m=>n.disposeIntermediateTensorInfo(m)),f}var bie={kernelName:Ec,backendName:"cpu",kernelFunc:pu};function zN(e){let{inputs:t,backend:n,attrs:r}=e,{x:s,filter:a}=t,{strides:o,pad:i,dataFormat:l,dilations:u,dimRoundingMode:c}=r;Te([s,a],"conv2d");let d=_.convertConv2DDataFormat(l),h=_.computeConv2DInfo(s.shape,a.shape,o,u,i,c,!1,d),p=h.filterHeight,f=h.filterWidth,m=h.dilationHeight,g=h.dilationWidth,y=h.padInfo.left,A=h.padInfo.top,x=h.dataFormat==="channelsLast",b=new Qt(h.outShape,s.dtype),v=k.computeStrides(s.shape),w=k.computeStrides(a.shape),I=v[0],T=x?v[1]:v[2],C=x?v[2]:1,M=x?1:v[1],$=b.strides[0],R=x?b.strides[1]:b.strides[2],N=x?b.strides[2]:1,F=x?1:b.strides[1],B=n.data.get(s.dataId).values,j=n.data.get(a.dataId).values,X=b.values;for(let Y=0;Y<h.batchSize;++Y){let ee=Y*I,oe=Y*$;for(let se=0;se<h.outHeight;++se){let ie=oe+se*R,ne=se*h.strideHeight-A;for(let de=0;de<p;++de){let he=ne+de*m;if(he<0||he>=h.inHeight)continue;let ge=de*w[0],be=ee+he*T;for(let Ee=0;Ee<h.outWidth;++Ee){let $e=ie+Ee*N,ze=Ee*h.strideWidth-y;for(let qe=0;qe<f;++qe){let We=ze+qe*g;if(We<0||We>=h.inWidth)continue;let vt=ge+qe*w[1],ft=be+We*C,mt=vt;for(let dt=0;dt<h.inChannels;++dt){let bt=B[ft+dt*M];for(let Je=0;Je<h.outChannels;++Je)X[$e+Je*F]+=bt*j[mt+Je];mt+=h.outChannels}}}}}}return n.makeTensorInfo(b.shape,b.dtype,X)}var vie={kernelName:tl,backendName:"cpu",kernelFunc:zN};function wie(e){let{inputs:t,backend:n,attrs:r}=e,{x:s,dy:a}=t,{strides:o,pad:i,dataFormat:l,dimRoundingMode:u,filterShape:c}=r;Te([s,a],"conv2dBackpropFilter");let d=_.convertConv2DDataFormat(l),h=_.computeConv2DInfo(s.shape,c,o,1,i,u,!1,d),{strideHeight:p,strideWidth:f,filterHeight:m,filterWidth:g}=h,y=h.dataFormat==="channelsLast",A=new Qt(h.filterShape,"float32"),x=h.padInfo.left,b=h.padInfo.top,v=n.data.get(s.dataId).values,w=n.data.get(a.dataId).values,I=new Qt(s.shape,s.dtype,v),T=new Qt(a.shape,a.dtype,w);for(let C=0;C<m;++C){let M=Math.max(0,Math.ceil((b-C)/p)),$=Math.min(h.outHeight,(h.inHeight+b-C)/p);for(let R=0;R<g;++R){let N=Math.max(0,Math.ceil((x-R)/f)),F=Math.min(h.outWidth,(h.inWidth+x-R)/f);for(let B=0;B<h.inChannels;++B)for(let j=0;j<h.outChannels;++j){let X=0;for(let Y=0;Y<h.batchSize;++Y)for(let ee=M;ee<$;++ee){let oe=C+ee*p-b;for(let se=N;se<F;++se){let ie=R+se*f-x;y?X+=I.get(Y,oe,ie,B)*T.get(Y,ee,se,j):X+=I.get(Y,B,oe,ie)*T.get(Y,j,ee,se)}}A.set(X,C,R,B,j)}}}return n.makeTensorInfo(A.shape,A.dtype,A.values)}var kie={kernelName:Sy,backendName:"cpu",kernelFunc:wie};function Iie(e){let{inputs:t,backend:n,attrs:r}=e,{dy:s,filter:a}=t,{inputShape:o,strides:i,pad:l,dataFormat:u,dimRoundingMode:c}=r;Te([s,a],"conv2dBackpropInput");let d=k.computeStrides(a.shape),h=k.computeStrides(s.shape),p=_.convertConv2DDataFormat(u),f=_.computeConv2DInfo(o,a.shape,i,1,l,c,!1,p),m=new Qt(f.inShape,"float32"),g=m.values,y=n.data.get(s.dataId).values,A=n.data.get(a.dataId).values,[x,b,v]=d,{batchSize:w,filterHeight:I,filterWidth:T,inChannels:C,inHeight:M,inWidth:$,outChannels:R,outHeight:N,outWidth:F,strideHeight:B,strideWidth:j}=f;p=f.dataFormat;let X=I-1-f.padInfo.top,Y=T-1-f.padInfo.left,ee=p==="channelsLast",oe=m.strides[0],se=ee?m.strides[1]:m.strides[2],ie=ee?m.strides[2]:1,ne=ee?1:m.strides[1],de=h[0],he=ee?h[1]:h[2],ge=ee?h[2]:1,be=ee?1:h[1];for(let Ee=0;Ee<w;++Ee)for(let $e=0;$e<C;++$e)for(let ze=0;ze<M;++ze){let qe=ze-X,We=Math.max(0,Math.ceil(qe/B)),vt=Math.min(N,(I+qe)/B);for(let ft=0;ft<$;++ft){let mt=ft-Y,dt=Math.max(0,Math.ceil(mt/j)),bt=Math.min(F,(T+mt)/j),Je=0;for(let Wt=We;Wt<vt;++Wt){let sr=Wt*B-qe;for(let vn=dt;vn<bt;++vn){let Vr=vn*j-mt,Rn=de*Ee+he*Wt+ge*vn,br=x*(I-1-sr)+b*(T-1-Vr)+v*$e;for(let vr=0;vr<R;++vr){let wn=y[Rn+be*vr],wr=A[br+vr];Je+=wn*wr}}}let jn=oe*Ee+se*ze+ie*ft+ne*$e;g[jn]=Je}}return n.makeTensorInfo(m.shape,m.dtype,m.values)}var Sie={kernelName:nl,backendName:"cpu",kernelFunc:Iie};function Tie(e){let{inputs:t,backend:n,attrs:r}=e,{x:s,filter:a}=t,{strides:o,pad:i,dilations:l}=r;Te([s,a],"conv3d");let u=_.computeConv3DInfo(s.shape,a.shape,o,l,i),{filterDepth:c,filterHeight:d,filterWidth:h,dilationDepth:p,dilationHeight:f,dilationWidth:m,padInfo:g}=u,y=g.front,A=g.left,x=g.top,b=new Qt(u.outShape,s.dtype),v=n.data.get(s.dataId).values,w=n.data.get(a.dataId).values,I=b.values,T=k.computeStrides(s.shape),C=k.computeStrides(a.shape);for(let M=0;M<u.batchSize;++M){let $=M*T[0],R=M*b.strides[0];for(let N=0;N<u.outDepth;++N){let F=R+N*b.strides[1],B=N*u.strideDepth-y;for(let j=0;j<c;++j){let X=B+j*p;if(X<0||X>=u.inDepth)continue;let Y=j*C[0],ee=$+X*T[1];for(let oe=0;oe<u.outHeight;++oe){let se=F+oe*b.strides[2],ie=oe*u.strideHeight-x;for(let ne=0;ne<d;++ne){let de=ie+ne*f;if(de<0||de>=u.inHeight)continue;let he=Y+ne*C[1],ge=ee+de*T[2];for(let be=0;be<u.outWidth;++be){let Ee=se+be*u.outChannels,$e=be*u.strideWidth-A;for(let ze=0;ze<h;++ze){let qe=$e+ze*m;if(qe<0||qe>=u.inWidth)continue;let We=he+ze*C[2],vt=ge+qe*u.inChannels,ft=We;for(let mt=0;mt<u.inChannels;++mt){let dt=v[vt+mt];for(let bt=0;bt<u.outChannels;++bt)I[Ee+bt]+=dt*w[ft+bt];ft+=u.outChannels}}}}}}}}return n.makeTensorInfo(b.shape,b.dtype,b.values)}var Nie={kernelName:Yp,backendName:"cpu",kernelFunc:Tie};function Cie(e){let{inputs:t,backend:n,attrs:r}=e,{x:s,dy:a}=t,{strides:o,pad:i,filterShape:l}=r;Te([s,a],"conv3dBackpropFilterV2");let u=k.computeStrides(s.shape),c=k.computeStrides(a.shape),d=_.computeConv3DInfo(s.shape,l,o,1,i),h=d.strideDepth,p=d.strideHeight,f=d.strideWidth,m=d.filterDepth,g=d.filterHeight,y=d.filterWidth,A=new Qt(d.filterShape,"float32"),x=A.values,[b,v,w,I]=A.strides,T=n.data.get(a.dataId).values,[C,M,$,R]=c,N=n.data.get(s.dataId).values,[F,B,j,X]=u,Y=d.padInfo.front,ee=d.padInfo.left,oe=d.padInfo.top;for(let se=0;se<m;++se){let ie=Math.max(0,Math.ceil((Y-se)/h)),ne=Math.min(d.outDepth,(d.inDepth+Y-se)/h),de=se*b;for(let he=0;he<g;++he){let ge=Math.max(0,Math.ceil((oe-he)/p)),be=Math.min(d.outHeight,(d.inHeight+oe-he)/p),Ee=he*v+de;for(let $e=0;$e<y;++$e){let ze=Math.max(0,Math.ceil((ee-$e)/f)),qe=Math.min(d.outWidth,(d.inWidth+ee-$e)/f),We=$e*w+Ee;for(let vt=0;vt<d.inChannels;++vt){let ft=vt*I+We;for(let mt=0;mt<d.outChannels;++mt){let dt=0;for(let bt=0;bt<d.batchSize;++bt){let Je=bt*F,jn=bt*C;for(let Wt=ie;Wt<ne;++Wt){let vn=(se+Wt*h-Y)*B+Je,Vr=Wt*M+jn;for(let Rn=ge;Rn<be;++Rn){let vr=(he+Rn*p-oe)*j+vn,wn=Rn*$+Vr;for(let wr=ze;wr<qe;++wr){let ar=($e+wr*f-ee)*X+vr,ws=wr*R+wn;dt+=N[ar+vt]*T[ws+mt]}}}}x[ft+mt]=dt}}}}}return n.makeTensorInfo(A.shape,A.dtype,A.values)}var Eie={kernelName:Ty,backendName:"cpu",kernelFunc:Cie};function $ie(e){let{inputs:t,backend:n,attrs:r}=e,{dy:s,filter:a}=t,{pad:o,strides:i,inputShape:l}=r;Te([s],"conv3dBackpropInputV2");let u=k.computeStrides(s.shape),c=k.computeStrides(a.shape),d=_.computeConv3DInfo(l,a.shape,i,1,o),h=new Qt(d.inShape,"float32"),p=h.values,[f,m,g,y]=h.strides,A=n.data.get(s.dataId).values,[x,b,v,w]=u,I=n.data.get(a.dataId).values,[T,C,M,$]=c,{batchSize:R,filterDepth:N,filterHeight:F,filterWidth:B,inChannels:j,inDepth:X,inHeight:Y,inWidth:ee,outChannels:oe,outDepth:se,outHeight:ie,outWidth:ne,strideDepth:de,strideHeight:he,strideWidth:ge}=d,be=N-1-d.padInfo.front,Ee=F-1-d.padInfo.top,$e=B-1-d.padInfo.left;for(let ze=0;ze<R;++ze)for(let qe=0;qe<j;++qe)for(let We=0;We<X;++We){let vt=We-be,ft=Math.max(0,Math.ceil(vt/de)),mt=Math.min(se,(N+vt)/de);for(let dt=0;dt<Y;++dt){let bt=dt-Ee,Je=Math.max(0,Math.ceil(bt/he)),jn=Math.min(ie,(F+bt)/he);for(let Wt=0;Wt<ee;++Wt){let sr=Wt-$e,vn=Math.max(0,Math.ceil(sr/ge)),Vr=Math.min(ne,(B+sr)/ge),Rn=0;for(let br=ft;br<mt;++br){let vr=br*de-vt;for(let wn=Je;wn<jn;++wn){let wr=wn*he-bt;for(let kr=vn;kr<Vr;++kr){let ar=kr*ge-sr,ws=x*ze+b*br+v*wn+w*kr,Us=T*(N-1-vr)+C*(F-1-wr)+M*(B-1-ar)+$*qe;for(let Aa=0;Aa<oe;++Aa){let Si=A[ws+Aa],ks=I[Us+Aa];Rn+=Si*ks}}}}p[f*ze+m*We+g*dt+y*Wt+qe]=Rn}}}return n.makeTensorInfo(h.shape,h.dtype,h.values)}var _ie={kernelName:Ny,backendName:"cpu",kernelFunc:$ie},Rie=xt(rl,e=>Math.cos(e)),Die={kernelName:rl,backendName:"cpu",kernelFunc:Rie},Fie=xt($c,e=>Math.cosh(e)),Mie={kernelName:$c,backendName:"cpu",kernelFunc:Fie};function Oie(e){let{inputs:t,backend:n,attrs:r}=e,{image:s,boxes:a,boxInd:o}=t,{cropSize:i,method:l,extrapolationValue:u}=r,[c,d,h,p]=s.shape,f=a.shape[0],[m,g]=i,y=Le([f,m,g,p],"float32"),A=n.data.get(a.dataId).values,x=n.data.get(o.dataId).values,b=n.data.get(s.dataId).values,v=k.computeStrides(s.shape),w=k.computeStrides(y.shape);for(let I=0;I<f;I++){let T=I*4,C=A[T],M=A[T+1],$=A[T+2],R=A[T+3],N=x[I];if(N>=c)continue;let F=m>1?($-C)*(d-1)/(m-1):0,B=g>1?(R-M)*(h-1)/(g-1):0;for(let j=0;j<m;j++){let X=m>1?C*(d-1)+j*F:.5*(C+$)*(d-1);if(X<0||X>d-1){for(let Y=0;Y<g;Y++)for(let ee=0;ee<p;ee++){let oe=ee+Y*w[2]+j*w[1]+I*w[0];y.values[oe]=u}continue}if(l==="bilinear"){let Y=Math.floor(X),ee=Math.ceil(X),oe=X-Y;for(let se=0;se<g;se++){let ie=g>1?M*(h-1)+se*B:.5*(M+R)*(h-1);if(ie<0||ie>h-1){for(let ge=0;ge<p;ge++){let be=ge+se*w[2]+j*w[1]+I*w[0];y.values[be]=u}continue}let ne=Math.floor(ie),de=Math.ceil(ie),he=ie-ne;for(let ge=0;ge<p;ge++){let be=ge+ne*v[2]+Y*v[1]+N*v[0],Ee=b[be];be=ge+de*v[2]+Y*v[1]+N*v[0];let $e=b[be];be=ge+ne*v[2]+ee*v[1]+N*v[0];let ze=b[be];be=ge+de*v[2]+ee*v[1]+N*v[0];let qe=b[be],We=Ee+($e-Ee)*he,vt=ze+(qe-ze)*he;be=ge+se*w[2]+j*w[1]+I*w[0],y.values[be]=We+(vt-We)*oe}}}else for(let Y=0;Y<g;++Y){let ee=g>1?M*(h-1)+Y*B:.5*(M+R)*(h-1);if(ee<0||ee>h-1){for(let ie=0;ie<p;ie++){let ne=ie+Y*w[2]+j*w[1]+I*w[0];y.values[ne]=u}continue}let oe=Math.round(ee),se=Math.round(X);for(let ie=0;ie<p;ie++){let ne=ie+oe*v[2]+se*v[1]+N*v[0],de=ie+Y*w[2]+j*w[1]+I*w[0];y.values[de]=b[ne]}}}}return n.makeTensorInfo(y.shape,y.dtype,y.values)}var Pie={kernelName:_c,backendName:"cpu",kernelFunc:Oie};function zie(e){let{inputs:t,backend:n,attrs:r}=e,{x:s}=t,{axis:a,exclusive:o,reverse:i}=r;Te(s,"cumsum");let l=_.getAxesPermutation([a],s.shape.length),u=s;l!=null&&(u=Pr({inputs:{x:s},backend:n,attrs:{perm:l}}));let c=_.getInnerMostAxes(1,s.shape.length)[0];if(c!==u.shape.length-1)throw new Error(`backend.cumsum in CPU expects an inner-most axis=${u.shape.length-1} but got axis=${c}`);let d=qr(u.dtype,"int32"),h=k.makeZerosTypedArray(k.sizeFromShape(u.shape),d),p=n.data.get(u.dataId).values,f=u.shape[u.shape.length-1],m=i?(y,A)=>y+f-A-1:(y,A)=>y+A;for(let y=0;y<p.length;y+=f)for(let A=0;A<f;A++){let x=m(y,A);if(A===0)h[x]=o?0:p[x];else{let b=m(y,A-1);h[x]=o?p[b]+h[b]:p[x]+h[b]}}let g=n.makeTensorInfo(u.shape,d,h);if(l!=null){let y=_.getUndoAxesPermutation(l),A=Pr({inputs:{x:g},backend:n,attrs:{perm:y}});return n.disposeIntermediateTensorInfo(g),n.disposeIntermediateTensorInfo(u),A}return g}var Lie={kernelName:sl,backendName:"cpu",kernelFunc:zie};function Bie(e){let{inputs:t,backend:n,attrs:r}=e,{x:s,weights:a}=t,{size:o,binaryOutput:i}=r;if(s.shape.length===1){let l=n.data.get(s.dataId).values,u=n.data.get(a.dataId).values,c=R5(l,u,a.dtype,a.shape,o);return n.makeTensorInfo([o],a.dtype,c)}else if(s.shape.length===2){let l=n.bufferSync(s),u=n.bufferSync(a),c=jT(l,u,o,i);return n.makeTensorInfo(c.shape,a.dtype,c.values)}throw new Error(`Error in denseBincount: input must be at most rank 2, but got rank${s.shape.length}.`)}var Wie={kernelName:Cy,backendName:"cpu",kernelFunc:Bie};function Vie(e){let{inputs:t,backend:n,attrs:r}=e,{x:s}=t,{blockSize:a,dataFormat:o}=r;k.assert(o==="NHWC",()=>`Only NHWC dataFormat supported on CPU for depthToSpace. Got ${o}`),k.assert(a>1,()=>`blockSize should be > 1 for depthToSpace, but was: ${a}`);let i=s.shape[0],l=s.shape[1],u=s.shape[2],c=s.shape[3],d=l*a,h=u*a,p=c/(a*a),f=n.data.get(s.dataId).values,m=new Float32Array(i*d*h*p),g=0;for(let y=0;y<i;++y)for(let A=0;A<d;++A){let x=Math.floor(A/a),b=A%a;for(let v=0;v<h;++v){let w=Math.floor(v/a),I=v%a,T=(b*a+I)*p;for(let C=0;C<p;++C){let $=C+T+c*(w+u*(x+l*y));m[g++]=f[$]}}}return n.makeTensorInfo([i,d,h,p],s.dtype,m)}var Uie={kernelName:Rc,backendName:"cpu",kernelFunc:Vie};function LN(e){let{inputs:t,backend:n,attrs:r}=e,{x:s,filter:a}=t,{strides:o,pad:i,dilations:l,dimRoundingMode:u}=r;Te([s,a],"depthwiseConv2DNative");let c=k.computeStrides(s.shape),d=k.computeStrides(a.shape),h=l;h==null&&(h=[1,1]),k.assert(_.eitherStridesOrDilationsAreOne(o,h),()=>`Error in depthwiseConv2d: Either strides or dilations must be 1. Got strides ${o} and dilations '${h}'`);let p=_.computeConv2DInfo(s.shape,a.shape,o,h,i,u,!0),{filterHeight:f,filterWidth:m,dilationHeight:g,dilationWidth:y,padInfo:A}=p,x=A.left,b=A.top,v=p.outChannels/p.inChannels,w=new Qt(p.outShape,s.dtype),I=n.data.get(s.dataId).values,T=n.data.get(a.dataId).values,C=w.values;for(let M=0;M<p.batchSize;++M){let $=M*c[0],R=M*w.strides[0];for(let N=0;N<p.outHeight;++N){let F=R+N*w.strides[1],B=N*p.strideHeight-b;for(let j=0;j<f;++j){let X=B+j*g;if(X<0||X>=p.inHeight)continue;let Y=j*d[0],ee=$+X*c[1];for(let oe=0;oe<p.outWidth;++oe){let se=F+oe*w.strides[2],ie=oe*p.strideWidth-x;for(let ne=0;ne<m;++ne){let de=ie+ne*y;if(de<0||de>=p.inWidth)continue;let he=Y+ne*d[1],ge=ee+de*p.inChannels,be=se,Ee=he;for(let $e=0;$e<p.inChannels;++$e){let ze=I[ge+$e];for(let qe=0;qe<v;++qe)C[be+qe]+=ze*T[Ee+qe];be+=v,Ee+=v}}}}}}return n.makeTensorInfo(w.shape,w.dtype,w.values)}var Hie={kernelName:al,backendName:"cpu",kernelFunc:LN};function Gie(e){let{inputs:t,backend:n,attrs:r}=e,{x:s,dy:a}=t,{strides:o,dilations:i,pad:l,dimRoundingMode:u,filterShape:c}=r;Te([s,a],"depthwiseConv2dNativeBackpropFilter");let d=_.computeConv2DInfo(s.shape,c,o,i,l,u,!0),{strideHeight:h,strideWidth:p,filterHeight:f,filterWidth:m}=d,g=new Qt(d.filterShape,"float32"),y=d.padInfo.left,A=d.padInfo.top,x=d.outChannels/d.inChannels,b=n.data.get(s.dataId).values,v=new Qt(s.shape,s.dtype,b),w=n.data.get(a.dataId).values,I=new Qt(a.shape,a.dtype,w);for(let T=0;T<f;++T){let C=Math.max(0,Math.ceil((A-T)/h)),M=Math.min(d.outHeight,(d.inHeight+A-T)/h);for(let $=0;$<m;++$){let R=Math.max(0,Math.ceil((y-$)/p)),N=Math.min(d.outWidth,(d.inWidth+y-$)/p);for(let F=0;F<d.outChannels;++F){let B=Math.trunc(F/x),j=F%x,X=0;for(let Y=0;Y<d.batchSize;++Y)for(let ee=C;ee<M;++ee){let oe=T+ee*h-A;for(let se=R;se<N;++se){let ie=$+se*p-y;X+=v.get(Y,oe,ie,B)*I.get(Y,ee,se,F)}}g.set(X,T,$,B,j)}}}return n.makeTensorInfo(g.shape,g.dtype,g.values)}var jie={kernelName:Ey,backendName:"cpu",kernelFunc:Gie};function qie(e){let{inputs:t,backend:n,attrs:r}=e,{dy:s,filter:a}=t,{strides:o,dilations:i,pad:l,dimRoundingMode:u,inputShape:c}=r;Te([s,a],"depthwiseConv2DNativeBackpropInput");let d=k.computeStrides(s.shape),h=k.computeStrides(a.shape),p=_.computeConv2DInfo(c,a.shape,o,i,l,u,!0),f=new Qt(p.inShape,"float32"),m=f.values,[g,y,A]=f.strides,x=n.data.get(s.dataId).values,[b,v,w]=d,I=n.data.get(a.dataId).values,[T,C,M]=h,{batchSize:$,filterHeight:R,filterWidth:N,inChannels:F,inHeight:B,inWidth:j,outChannels:X,outHeight:Y,outWidth:ee,strideHeight:oe,strideWidth:se}=p,ie=R-1-p.padInfo.top,ne=N-1-p.padInfo.left,de=X/F;for(let he=0;he<$;++he)for(let ge=0;ge<F;++ge)for(let be=0;be<B;++be){let Ee=be-ie,$e=Math.max(0,Math.ceil(Ee/oe)),ze=Math.min(Y,(R+Ee)/oe);for(let qe=0;qe<j;++qe){let We=qe-ne,vt=Math.max(0,Math.ceil(We/se)),ft=Math.min(ee,(N+We)/se),mt=0;for(let dt=$e;dt<ze;++dt){let bt=dt*oe-Ee;for(let Je=vt;Je<ft;++Je){let jn=Je*se-We,Wt=b*he+v*dt+w*Je,sr=T*(R-1-bt)+C*(N-1-jn)+M*ge;for(let vn=0;vn<de;++vn){let Vr=ge*de+vn,Rn=x[Wt+Vr],br=I[sr+vn];mt+=Rn*br}}}m[g*he+y*be+A*qe+ge]=mt}}return n.makeTensorInfo(f.shape,f.dtype,f.values)}var Kie={kernelName:$y,backendName:"cpu",kernelFunc:qie};function Xie(e){let{inputs:t,backend:n}=e,{x:r}=t,s=k.sizeFromShape(r.shape),a=n.data.get(r.dataId).values,o=Le([s,s],r.dtype),i=o.values;for(let u=0;u<a.length;u++)i[u*s+u]=a[u];let l=[...r.shape,...r.shape];return n.makeTensorInfo(l,o.dtype,o.values)}var Zie={kernelName:_y,backendName:"cpu",kernelFunc:Xie},Yie={kernelName:Jp,backendName:"cpu",kernelFunc:({inputs:e,backend:t,attrs:n})=>{let{x:r,filter:s}=e,{strides:a,pad:o,dilations:i}=n,l=t,u=l.data.get(r.dataId).values,c=r.shape.length,d=l.data.get(s.dataId).values,h=s.shape.length,{batchSize:p,inHeight:f,inWidth:m,inChannels:g,outHeight:y,outWidth:A,padInfo:x,strideHeight:b,strideWidth:v,filterHeight:w,filterWidth:I,dilationHeight:T,dilationWidth:C,outShape:M}=_.computeDilation2DInfo(r.shape,s.shape,a,o,"NHWC",i),$=k.sizeFromShape(M),R=M.length,N=k.getArrayFromDType(r.dtype,$);for(let B=0;B<p;++B)for(let j=0;j<y;++j){let X=j*b-x.top;for(let Y=0;Y<A;++Y){let ee=Y*v-x.left;for(let oe=0;oe<g;++oe){let se=Number.MIN_SAFE_INTEGER;for(let ne=0;ne<w;++ne){let de=X+ne*T;if(de>=0&&de<f)for(let he=0;he<I;++he){let ge=ee+he*C;if(ge>=0&&ge<m){let be=k.locToIndex([B,de,ge,oe],c,k.computeStrides(r.shape)),Ee=k.locToIndex([ne,he,oe],h,k.computeStrides(s.shape)),$e=u[be]+d[Ee];$e>se&&(se=$e)}}}let ie=k.locToIndex([B,j,Y,oe],R,k.computeStrides(M));N[ie]=se}}}return{dataId:l.write(k.toTypedArray(N,r.dtype),M,r.dtype),shape:M,dtype:r.dtype}}},Jie={kernelName:Dy,backendName:"cpu",kernelFunc:({inputs:e,backend:t,attrs:n})=>{let{x:r,filter:s,dy:a}=e,{strides:o,pad:i,dilations:l}=n,u=t,c=k.toNestedArray(r.shape,u.data.get(r.dataId).values),d=k.toNestedArray(s.shape,u.data.get(s.dataId).values),{batchSize:h,inHeight:p,inWidth:f,inChannels:m,outHeight:g,outWidth:y,padInfo:A,strideHeight:x,strideWidth:b,filterHeight:v,filterWidth:w,dilationHeight:I,dilationWidth:T,outShape:C}=_.computeDilation2DInfo(r.shape,s.shape,o,i,"NHWC",l);k.assert(a.rank===C.length,()=>`Error in ${Dy}, dy must have the same rank as output ${C.length}, but got ${a.rank}`);let M=k.toNestedArray(C,u.data.get(a.dataId).values),$=k.makeZerosNestedTypedArray(s.shape,s.dtype);for(let N=0;N<h;++N)for(let F=0;F<g;++F){let B=F*x-A.top;for(let j=0;j<y;++j){let X=j*b-A.left;for(let Y=0;Y<m;++Y){let ee=Number.MIN_SAFE_INTEGER,oe=0,se=0;for(let ie=0;ie<v;++ie){let ne=B+ie*I;if(ne>=0&&ne<p)for(let de=0;de<w;++de){let he=X+de*T;if(he>=0&&he<f){let ge=c[N][ne][he][Y]+d[ie][de][Y];ge>ee&&(ee=ge,oe=ie,se=de)}}}$[oe][se][Y]+=M[N][F][j][Y]}}}return{dataId:u.write(k.toTypedArray($,r.dtype),s.shape,s.dtype),shape:s.shape,dtype:s.dtype}}},Qie={kernelName:Ry,backendName:"cpu",kernelFunc:({inputs:e,backend:t,attrs:n})=>{let{x:r,filter:s,dy:a}=e,{strides:o,pad:i,dilations:l}=n,u=t,c=k.toNestedArray(r.shape,u.data.get(r.dataId).values),d=k.toNestedArray(s.shape,u.data.get(s.dataId).values),{batchSize:h,inHeight:p,inWidth:f,inChannels:m,outHeight:g,outWidth:y,padInfo:A,strideHeight:x,strideWidth:b,filterHeight:v,filterWidth:w,dilationHeight:I,dilationWidth:T,outShape:C}=_.computeDilation2DInfo(r.shape,s.shape,o,i,"NHWC",l);k.assert(a.rank===C.length,()=>`Error in ${Ry}, dy must have the same rank as output ${C.length}, but got ${a.rank}`);let M=k.toNestedArray(C,u.data.get(a.dataId).values),$=k.makeZerosNestedTypedArray(r.shape,r.dtype);for(let N=0;N<h;++N)for(let F=0;F<g;++F){let B=F*x-A.top;for(let j=0;j<y;++j){let X=j*b-A.left;for(let Y=0;Y<m;++Y){let ee=Number.MIN_SAFE_INTEGER,oe=B<0?0:B,se=X<0?0:X;for(let ie=0;ie<v;++ie){let ne=B+ie*I;if(ne>=0&&ne<p)for(let de=0;de<w;++de){let he=X+de*T;if(he>=0&&he<f){let ge=c[N][ne][he][Y]+d[ie][de][Y];ge>ee&&(ee=ge,oe=ne,se=he)}}}$[N][oe][se][Y]+=M[N][F][j][Y]}}}return{dataId:u.write(k.toTypedArray($,r.dtype),r.shape,r.dtype),shape:r.shape,dtype:r.dtype}}};function nh(e){let{inputs:t,backend:n,attrs:r}=e,{x:s}=t,{axis:a,keepDims:o}=r;Te(s,"sum");let i;s.dtype==="bool"?i=Ja({inputs:{x:s},backend:n,attrs:{dtype:"int32"}}):i=zs({inputs:{x:s},backend:n});let l=i.shape.length,u=k.parseAxisParam(a,i.shape),c=_.getAxesPermutation(u,l),d=u,h=i;c!=null&&(h=Pr({inputs:{x:i},backend:n,attrs:{perm:c}}),d=_.getInnerMostAxes(d.length,l)),_.assertAxesAreInnerMostDims("sum",d,h.shape.length);let[p,f]=_.computeOutAndReduceShapes(h.shape,d),m=_.upcastType(h.dtype,"int32"),g=Em(n,p,m),y=k.sizeFromShape(f),A=n.data.get(g.dataId).values,x=n.data.get(h.dataId).values;for(let b=0;b<A.length;++b){let v=b*y,w=0;for(let I=0;I<y;++I)w+=x[v+I];A[b]=w}if(o){let b=_.expandShapeToKeepDim(g.shape,u),v=g;g=Ft({inputs:{x:g},backend:n,attrs:{shape:b}}),n.disposeIntermediateTensorInfo(v)}return n.disposeIntermediateTensorInfo(i),c!=null&&n.disposeIntermediateTensorInfo(h),g}var ele={kernelName:Fl,backendName:"cpu",kernelFunc:nh};function tle(e){let{inputs:t,backend:n,attrs:r}=e,{equation:s}=r,a=t,{allDims:o,summedDims:i,idDims:l}=_.decodeEinsumEquation(s,a.length);_.checkEinsumDimSizes(o.length,l,a);let{path:u,steps:c}=_.getEinsumComputePath(i,l),d=c.length,h=null,p=o.length,f=[];for(let m=0;m<d;++m){for(let g of c[m]){let{permutationIndices:y,expandDims:A}=_.getEinsumPermutation(p,l[g]),x;_.isIdentityPermutation(y)?x=a[g]:(x=Pr({inputs:{x:a[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);k.arraysEqual(x.shape,b)||(x=Ft({inputs:{x},backend:n,attrs:{shape:b}}),f.push(x)),h===null?h=x:(h=$m({inputs:{a:x,b:h},backend:n}),f.push(h))}m<d-1&&(u[m]>=0&&(h=nh({inputs:{x:h},backend:n,attrs:{axis:u[m]-(o.length-p),keepDims:!1}}),f.push(h)),p--)}for(let m of f)m!==h&&n.disposeIntermediateTensorInfo(m);return h}var nle={kernelName:Fy,backendName:"cpu",kernelFunc:tle};function rle(e){let{inputs:t,backend:n}=e,{dy:r,y:s}=t;Te([r,s],"eluGrad");let a=new Float32Array(k.sizeFromShape(s.shape)),o=n.data.get(s.dataId).values,i=n.data.get(r.dataId).values;for(let l=0;l<o.length;++l){let u=o[l];u>=1?a[l]=i[l]:a[l]=i[l]*(u+1)}return n.makeTensorInfo(s.shape,"float32",a)}var sle={kernelName:My,backendName:"cpu",kernelFunc:rle},ale=_.ERF_P,ole=_.ERF_A1,ile=_.ERF_A2,lle=_.ERF_A3,ule=_.ERF_A4,cle=_.ERF_A5,dle=xt(Fc,e=>{let t=Math.sign(e),n=Math.abs(e),r=1/(1+ale*n);return t*(1-((((cle*r+ule)*r+lle)*r+ile)*r+ole)*r*Math.exp(-n*n))}),hle={kernelName:Fc,backendName:"cpu",kernelFunc:dle};function _m(e){let{inputs:t,backend:n,attrs:r}=e,{input:s}=t,{dim:a}=r,o=s.shape.length,i=s.shape.slice(),l=a;return a<0&&(k.assert(-(o+1)<=a,()=>`Axis must be in the interval [${-(o+1)}, ${o}]`),l=o+a+1),i.splice(l,0,1),Ft({inputs:{x:s},backend:n,attrs:{shape:i}})}var ple={kernelName:Mc,backendName:"cpu",kernelFunc:_m},fle=nn((e,t)=>e/t),L5=bn(ol,fle),B5={kernelName:ol,backendName:"cpu",kernelFunc:L5};function BN(e,t,n){let r=e.shape,s=r[0],a=r[1],o=n.data.get(e.dataId),i=o.complexTensorInfos.real,l=o.complexTensorInfos.imag,u=[s,a],c=k.sizeFromShape(u),d=k.getTypedArrayFromDType("float32",c),h=k.getTypedArrayFromDType("float32",c);for(let g=0;g<s;g++){let y=fi({inputs:{x:i},backend:n,attrs:{begin:[g,0],size:[1,a]}}),A=fi({inputs:{x:l},backend:n,attrs:{begin:[g,0],size:[1,a]}}),x=fr({inputs:{real:y,imag:A},backend:n}),{real:b,imag:v}=mle(x,t,n),w=_.mergeRealAndImagArrays(b,v);for(let I=0;I<a;I++){let T=_.getComplexWithIndex(w,I);d[g*a+I]=T.real,h[g*a+I]=T.imag}n.disposeIntermediateTensorInfo(y),n.disposeIntermediateTensorInfo(A),n.disposeIntermediateTensorInfo(x)}let p=n.makeTensorInfo(u,"float32",d),f=n.makeTensorInfo(u,"float32",h),m=fr({inputs:{real:p,imag:f},backend:n});return n.disposeIntermediateTensorInfo(p),n.disposeIntermediateTensorInfo(f),m}function mle(e,t,n){let r=k.sizeFromShape(e.shape),s=n.data.get(e.dataId),a=n.data.get(s.complexTensorInfos.real.dataId).values,o=n.data.get(s.complexTensorInfos.imag.dataId).values;if(gle(r)){let i=W5(a,o,r,t,n),l=[e.shape[0],e.shape[1]];if(t){let u=n.makeTensorInfo(l,"float32",i.real),c=n.makeTensorInfo(l,"float32",i.imag),d=n.makeTensorInfo([],"float32",k.createScalarValue(r,"float32")),h=zs({inputs:{x:d},backend:n}),p=B5.kernelFunc({inputs:{a:u,b:d},backend:n}),f=B5.kernelFunc({inputs:{a:c,b:h},backend:n}),m=n.data.get(p.dataId).values,g=n.data.get(f.dataId).values;return n.disposeIntermediateTensorInfo(u),n.disposeIntermediateTensorInfo(c),n.disposeIntermediateTensorInfo(d),n.disposeIntermediateTensorInfo(h),n.disposeIntermediateTensorInfo(p),n.disposeIntermediateTensorInfo(f),{real:m,imag:g}}return i}else{let i=_.mergeRealAndImagArrays(a,o),l=yle(i,r,t);return _.splitRealAndImagArrays(l)}}function gle(e){return(e&e-1)==0}function W5(e,t,n,r,s){if(n===1)return{real:e,imag:t};let a=_.mergeRealAndImagArrays(e,t),o=n/2,i=_.complexWithEvenIndex(a),l=i.real,u=i.imag,c=[l.length],d=s.makeTensorInfo(c,"float32",l),h=s.makeTensorInfo(c,"float32",u),p=fr({inputs:{real:d,imag:h},backend:s}),f=_.complexWithOddIndex(a),m=f.real,g=f.imag,y=[m.length],A=s.makeTensorInfo(y,"float32",m),x=s.makeTensorInfo(y,"float32",g),b=fr({inputs:{real:A,imag:x},backend:s}),v=W5(l,u,o,r,s),w=v.real,I=v.imag,T=[w.length],C=s.makeTensorInfo(T,"float32",w),M=s.makeTensorInfo(T,"float32",I),$=fr({inputs:{real:C,imag:M},backend:s}),R=W5(m,g,o,r,s),N=R.real,F=R.imag,B=[N.length],j=s.makeTensorInfo(B,"float32",N),X=s.makeTensorInfo(B,"float32",F),Y=fr({inputs:{real:j,imag:X},backend:s}),ee=_.exponents(n,r),oe=[ee.real.length],se=s.makeTensorInfo(oe,"float32",ee.real),ie=s.makeTensorInfo(oe,"float32",ee.imag),ne=fr({inputs:{real:se,imag:ie},backend:s}),de=$m({inputs:{a:ne,b:Y},backend:s}),he=th({inputs:{a:$,b:de},backend:s}),ge=O5({inputs:{a:$,b:de},backend:s}),be=pi({inputs:{input:he},backend:s}),Ee=pi({inputs:{input:ge},backend:s}),$e=hu({inputs:{input:he},backend:s}),ze=hu({inputs:{input:ge},backend:s}),qe=pu({inputs:[be,Ee],backend:s,attrs:{axis:0}}),We=pu({inputs:[$e,ze],backend:s,attrs:{axis:0}}),vt=s.data.get(qe.dataId).values,ft=s.data.get(We.dataId).values;return s.disposeIntermediateTensorInfo(d),s.disposeIntermediateTensorInfo(h),s.disposeIntermediateTensorInfo(p),s.disposeIntermediateTensorInfo(A),s.disposeIntermediateTensorInfo(x),s.disposeIntermediateTensorInfo(b),s.disposeIntermediateTensorInfo(C),s.disposeIntermediateTensorInfo(M),s.disposeIntermediateTensorInfo($),s.disposeIntermediateTensorInfo(j),s.disposeIntermediateTensorInfo(X),s.disposeIntermediateTensorInfo(Y),s.disposeIntermediateTensorInfo(se),s.disposeIntermediateTensorInfo(ie),s.disposeIntermediateTensorInfo(ne),s.disposeIntermediateTensorInfo(de),s.disposeIntermediateTensorInfo(he),s.disposeIntermediateTensorInfo(ge),s.disposeIntermediateTensorInfo(be),s.disposeIntermediateTensorInfo($e),s.disposeIntermediateTensorInfo(Ee),s.disposeIntermediateTensorInfo(ze),s.disposeIntermediateTensorInfo(qe),s.disposeIntermediateTensorInfo(We),{real:vt,imag:ft}}function yle(e,t,n){let r=new Float32Array(t*2);for(let s=0;s<t;s++){let a=0,o=0;for(let i=0;i<t;i++){let l=_.exponent(s*i,t,n),u=_.getComplexWithIndex(e,i);a+=u.real*l.real-u.imag*l.imag,o+=u.real*l.imag+u.imag*l.real}n&&(a/=t,o/=t),_.assignToTypedArray(r,a,o,s)}return r}function Ale(e){let{inputs:t,backend:n}=e,{input:r}=t,s=k.sizeFromShape(r.shape),a=r.shape[r.shape.length-1],o=s/a,i=Ft({inputs:{x:r},backend:n,attrs:{shape:[o,a]}}),l=BN(i,!1,n),u=Ft({inputs:{x:l},backend:n,attrs:{shape:r.shape}});return n.disposeIntermediateTensorInfo(i),n.disposeIntermediateTensorInfo(l),u}var xle={kernelName:Oy,backendName:"cpu",kernelFunc:Ale};function V5(e){let{backend:t,attrs:n}=e,{shape:r,value:s,dtype:a}=n,o=a||k.inferDtype(s),i=k.getArrayFromDType(o,k.sizeFromShape(r));return vle(i,s,o),t.makeTensorInfo(r,o,i)}var ble={kernelName:Qp,backendName:"cpu",kernelFunc:V5};function vle(e,t,n){e.fill(t)}var wle={kernelName:Oc,backendName:"cpu",kernelFunc:({inputs:e,attrs:t,backend:n})=>{let{image:r}=e,s=n,a=k.getTypedArrayFromDType(r.dtype,k.sizeFromShape(r.shape)),[o,i,l,u]=r.shape,c=s.data.get(r.dataId).values;for(let h=0;h<o;h++){let p=h*l*i*u;for(let f=0;f<i;f++){let m=f*(l*u);for(let g=0;g<l;g++){let y=g*u;for(let A=0;A<u;A++){let b=[o,f,g,A][2],v=Math.round(l-b),w=p+m+y+A,I=c[w];if(v>=0&&v<l){let T=v*u,C=p+m+T+A;I=c[C]}a[w]=I}}}}return{dataId:s.write(a,r.shape,r.dtype),shape:r.shape,dtype:r.dtype}}},kle=nn((e,t)=>Math.floor(e/t)),Ile=bn(ul,kle,null,"int32"),Sle={kernelName:ul,backendName:"cpu",kernelFunc:Ile};function Tle(e){let{inputs:t,backend:n,attrs:r}=e,{x:s,filter:a,bias:o,preluActivationWeights:i}=t,{strides:l,pad:u,dataFormat:c,dilations:d,dimRoundingMode:h,activation:p,leakyreluAlpha:f}=r,m=zN({inputs:{x:s,filter:a},backend:n,attrs:{strides:l,pad:u,dataFormat:c,dilations:d,dimRoundingMode:h}});if(o){let g=m;m=th({inputs:{a:m,b:o},backend:n}),n.disposeIntermediateTensorInfo(g)}if(p){let g=m;m=P5(n,m,p,i,f),n.disposeIntermediateTensorInfo(g)}return m}var Nle={kernelName:Bl,backendName:"cpu",kernelFunc:Tle};function Cle(e){let{inputs:t,backend:n,attrs:r}=e,{x:s,filter:a,bias:o,preluActivationWeights:i}=t,{strides:l,pad:u,dataFormat:c,dilations:d,dimRoundingMode:h,activation:p,leakyreluAlpha:f}=r,m=LN({inputs:{x:s,filter:a},backend:n,attrs:{strides:l,pad:u,dataFormat:c,dilations:d,dimRoundingMode:h}});if(o){let g=m;m=th({inputs:{a:m,b:o},backend:n}),n.disposeIntermediateTensorInfo(g)}if(p){let g=m;m=P5(n,m,p,i,f),n.disposeIntermediateTensorInfo(g)}return m}var Ele={kernelName:Wl,backendName:"cpu",kernelFunc:Cle};function $le(e){let{inputs:t,backend:n}=e,{params:r,indices:s}=t,a=k.sizeFromShape(r.shape),o=s.shape,i=o[o.length-1],[l,u,c,d]=_.prepareAndValidate(r,s);if(u===0)return n.makeTensorInfo(l,r.dtype,[]);let h=n.data.get(s.dataId).values,p=n.bufferSync(r),f=tN(h,p,r.dtype,u,i,c,d,r.shape,a);return n.makeTensorInfo(l,r.dtype,f.values)}var _le={kernelName:zc,backendName:"cpu",kernelFunc:$le};function Rle(e){let{inputs:t,backend:n,attrs:r}=e,{x:s,indices:a}=t,{axis:o,batchDims:i}=r;Te([s,a],"gatherV2");let l=i;i==null&&(l=0);let u=k.sizeFromShape(a.shape),c=k.parseAxisParam(o,s.shape)[0],d=_.segment_util.collectGatherOpShapeInfo(s,a,c,l),h=Ft({inputs:{x:s},backend:n,attrs:{shape:[d.batchSize,d.outerSize,d.dimSize,d.sliceSize]}}),p=Ft({inputs:{x:a},backend:n,attrs:{shape:[d.batchSize,u/d.batchSize]}}),f=[d.batchSize,d.outerSize,u/d.batchSize,d.sliceSize],m=n.bufferSync(p),g=n.bufferSync(h),y=nN(g,m,f);return n.disposeIntermediateTensorInfo(h),n.disposeIntermediateTensorInfo(p),n.makeTensorInfo(d.outputShape,y.dtype,y.values)}var Dle={kernelName:Pc,backendName:"cpu",kernelFunc:Rle};function Fle(e){let{inputs:t,backend:n}=e,{input:r}=t,s=k.sizeFromShape(r.shape),a=r.shape[r.shape.length-1],o=s/a,i=Ft({inputs:{x:r},backend:n,attrs:{shape:[o,a]}}),l=BN(i,!0,n),u=Ft({inputs:{x:l},backend:n,attrs:{shape:r.shape}});return n.disposeIntermediateTensorInfo(i),n.disposeIntermediateTensorInfo(l),u}var Mle={kernelName:Py,backendName:"cpu",kernelFunc:Fle},Ole=xt(Lc,e=>Number.isFinite(e)?1:0,"bool"),Ple={kernelName:Lc,backendName:"cpu",kernelFunc:Ole},zle=xt(Bc,e=>Math.abs(e)===Infinity?1:0,"bool"),Lle={kernelName:Bc,backendName:"cpu",kernelFunc:zle},Ble=xt(Wc,e=>Number.isNaN(e)?1:0,"bool"),Wle={kernelName:Wc,backendName:"cpu",kernelFunc:Ble};function Vle(e){let{backend:t,attrs:n}=e,{start:r,stop:s,num:a}=n,o=iN(r,s,a);return t.makeTensorInfo([o.length],"float32",o)}var Ule={kernelName:Ly,backendName:"cpu",kernelFunc:Vle},Hle=xt(Vc,e=>Math.log1p(e)),Gle={kernelName:Vc,backendName:"cpu",kernelFunc:Hle},jle=nn((e,t)=>e&&t),qle=bn(Uc,jle,null,"bool"),Kle={kernelName:Uc,backendName:"cpu",kernelFunc:qle},Xle=xt(ef,e=>e?0:1,"bool"),Zle={kernelName:ef,backendName:"cpu",kernelFunc:Xle},Yle=nn((e,t)=>e||t),Jle=bn(tf,Yle,null,"bool"),Qle={kernelName:tf,backendName:"cpu",kernelFunc:Jle};function eue(e){let{inputs:t,backend:n,attrs:r}=e,{x:s}=t,{depthRadius:a,bias:o,alpha:i,beta:l}=r;Te(s,"LRN");let u=s.shape[3],c=u-1,d=n.data.get(s.dataId).values,h=k.sizeFromShape(s.shape),p=new Float32Array(h);function f(m){let g=m%u,y=m-g+Math.max(0,g-a),A=m-g+Math.min(g+a,c),x=0;for(;y<=A;y++){let b=d[y];x+=b*b}return x}for(let m=0;m<h;m++){let g=f(m),y=d[m]*Math.pow(o+i*g,-l);p[m]=y}return n.makeTensorInfo(s.shape,s.dtype,p)}var tue={kernelName:nf,backendName:"cpu",kernelFunc:eue};function nue(e){let{inputs:t,backend:n,attrs:r}=e,{x:s,y:a,dy:o}=t,{depthRadius:i,bias:l,alpha:u,beta:c}=r;Te(o,"LRNGrad");let d=k.sizeFromShape(o.shape),h=o.shape[3],p=n.data.get(o.dataId).values,f=n.data.get(s.dataId).values,m=n.data.get(a.dataId).values,g=new Float32Array(d),y=d;for(let A=0;A<y;A++){let x=A%h,b=A-x+Math.max(0,x-i),v=A-x+Math.min(h,x+i+1),w=0;for(let I=b;I<v;I++)w+=Math.pow(f[I],2);w=u*w+l;for(let I=b;I<v;I++){let T=-2*u*c*f[I]*m[A]/w;A===I&&(T+=Math.pow(w,-c)),T*=p[A],g[I]+=T}}return n.makeTensorInfo(o.shape,s.dtype,g)}var rue={kernelName:By,backendName:"cpu",kernelFunc:nue};function WN(e){let{inputs:t,backend:n,attrs:r}=e,{x:s}=t,{reductionIndices:a,keepDims:o}=r,i=n,l=s.shape,u=l.length,c=k.parseAxisParam(a,l),d=c,h=_.getAxesPermutation(d,u),p=i.data.get(s.dataId).values;if(h!=null){let b=new Array(u);for(let v=0;v<b.length;v++)b[v]=l[h[v]];p=F5(p,l,s.dtype,h,b),d=_.getInnerMostAxes(d.length,u),l=b}Te(s,"max"),_.assertAxesAreInnerMostDims("max",d,u);let[f,m]=_.computeOutAndReduceShapes(l,d),g=k.sizeFromShape(m),y=uN(p,g,f,s.dtype),A=i.write(y,f,s.dtype),x=f;return o&&(x=_.expandShapeToKeepDim(f,c)),{dataId:A,shape:x,dtype:s.dtype}}var sue={kernelName:gl,backendName:"cpu",kernelFunc:WN};function aue(e){let{inputs:t,backend:n,attrs:r}=e,{x:s}=t;Te(s,"maxPool");let{filterSize:a,strides:o,pad:i,dimRoundingMode:l}=r,u=1;k.assert(_.eitherStridesOrDilationsAreOne(o,u),()=>`Error in maxPool: Either strides or dilations must be 1. Got strides ${o} and dilations '${u}'`);let c=_.computePool2DInfo(s.shape,a,o,u,i,l),d;if(c.filterWidth===1&&c.filterHeight===1&&k.arraysEqual(c.inShape,c.outShape))d=zs({inputs:{x:s},backend:n});else{let h=n.data.get(s.dataId).values,p=k.computeStrides(s.shape),f=z5(h,s.shape,s.dtype,p,c,"max");d=n.makeTensorInfo(c.outShape,s.dtype,f.values)}return d}var oue={kernelName:yl,backendName:"cpu",kernelFunc:aue};function iue(e){let{inputs:t,backend:n,attrs:r}=e,{x:s}=t,{filterSize:a,strides:o,pad:i,dimRoundingMode:l,dataFormat:u}=r;Te(s,"maxPool3d");let c=_.computePool3DInfo(s.shape,a,o,1,i,l,u),d=n.data.get(s.dataId).values,h=PN(d,s.shape,s.dtype,k.computeStrides(s.shape),c,"max");return n.makeTensorInfo(h.shape,"float32",h.values)}var lue={kernelName:rf,backendName:"cpu",kernelFunc:iue};function uue(e){let{inputs:t,backend:n,attrs:r}=e,{dy:s,input:a}=t,{filterSize:o,strides:i,pad:l,dimRoundingMode:u}=r;Te([s,a],"maxPool3DGrad");let c=_.computePool3DInfo(a.shape,o,i,1,l,u),d=n.bufferSync(a),h=eie(d,c),p=c.strideDepth,f=c.strideHeight,m=c.strideWidth,g=c.dilationDepth,y=c.dilationHeight,A=c.dilationWidth,x=c.effectiveFilterDepth,b=c.effectiveFilterHeight,v=c.effectiveFilterWidth,w=x-1-c.padInfo.front,I=v-1-c.padInfo.left,T=b-1-c.padInfo.top,C=Le(a.shape,"float32"),M=n.bufferSync(s);for(let $=0;$<c.batchSize;++$)for(let R=0;R<c.inChannels;++R)for(let N=0;N<c.inDepth;++N)for(let F=0;F<c.inHeight;++F)for(let B=0;B<c.inWidth;++B){let j=N-w,X=F-T,Y=B-I,ee=0;for(let oe=0;oe<x;oe+=g){let se=(j+oe)/p;if(!(se<0||se>=c.outDepth||Math.floor(se)!==se))for(let ie=0;ie<b;ie+=y){let ne=(X+ie)/f;if(!(ne<0||ne>=c.outHeight||Math.floor(ne)!==ne))for(let de=0;de<v;de+=A){let he=(Y+de)/m;if(he<0||he>=c.outWidth||Math.floor(he)!==he)continue;let ge=x*b*v-1-h.get($,se,ne,he,R),be=oe*b*v+ie*v+de,Ee=ge===be?1:0;if(Ee===0)continue;ee+=M.get($,se,ne,he,R)*Ee}}}C.set(ee,$,N,F,B,R)}return n.makeTensorInfo(C.shape,C.dtype,C.values)}var cue={kernelName:Vy,backendName:"cpu",kernelFunc:uue};function due(e){let{inputs:t,backend:n,attrs:r}=e,{dy:s,input:a,output:o}=t,i=a;Te([a,o],"maxPoolGrad");let{filterSize:l,strides:u,pad:c,dimRoundingMode:d}=r,h=_.computePool2DInfo(i.shape,l,u,1,c,d),p=n.data.get(i.dataId).values,f=Le(h.outShape,i.dtype,ON(p,i.shape,i.dtype,h).values),m=h.strideHeight,g=h.strideWidth,y=h.dilationHeight,A=h.dilationWidth,x=h.effectiveFilterHeight,b=h.effectiveFilterWidth,v=b-1-h.padInfo.left,w=x-1-h.padInfo.top,I=Le(i.shape,"float32"),T=n.data.get(s.dataId).values,C=Le(s.shape,"float32",T);for(let M=0;M<h.batchSize;++M)for(let $=0;$<h.inChannels;++$)for(let R=0;R<h.inHeight;++R)for(let N=0;N<h.inWidth;++N){let F=R-w,B=N-v,j=0;for(let X=0;X<x;X+=y){let Y=(F+X)/m;if(!(Y<0||Y>=h.outHeight||Math.floor(Y)!==Y))for(let ee=0;ee<b;ee+=A){let oe=(B+ee)/g;if(oe<0||oe>=h.outWidth||Math.floor(oe)!==oe)continue;let se=x*b-1-f.get(M,Y,oe,$),ie=X*b+ee,ne=se===ie?1:0;if(ne===0)continue;j+=C.get(M,Y,oe,$)*ne}}I.set(j,M,R,N,$)}return n.makeTensorInfo(I.shape,I.dtype,I.values)}var hue={kernelName:Wy,backendName:"cpu",kernelFunc:due};function pue(e,t,n,r,s){let a=k.computeStrides(t),o=z5(e,t,n,a,s,"max"),i=ON(e,t,n,s,!0,r);return[o.values,i.values]}var fue={kernelName:Uy,backendName:"cpu",kernelFunc:({inputs:e,attrs:t,backend:n})=>{let{x:r}=e,{filterSize:s,strides:a,pad:o,includeBatchInIndex:i}=t,l=n;Te(r,"MaxPoolWithArgmax");let u=l.data.get(r.dataId).values,c=_.computePool2DInfo(r.shape,s,a,[1,1],o),[d,h]=pue(u,r.shape,r.dtype,i,c),p=l.write(d,c.outShape,r.dtype),f=l.write(h,c.outShape,r.dtype);return[{dataId:p,shape:c.outShape,dtype:r.dtype},{dataId:f,shape:c.outShape,dtype:"int32"}]}};function mue(e){let{inputs:t,backend:n,attrs:r}=e,{x:s}=t,{axis:a,keepDims:o}=r,i=k.parseAxisParam(a,s.shape),u=_.computeOutAndReduceShapes(s.shape,i)[1],c=k.sizeFromShape(u),d=[],h=n.makeTensorInfo([],"float32",new Float32Array([c]));d.push(h);let p=Ja({inputs:{x:s},backend:n,attrs:{dtype:"float32"}});d.push(p);let f=L5({inputs:{a:p,b:h},backend:n});d.push(f);let m=nh({inputs:{x:f},backend:n,attrs:{axis:a,keepDims:o}});return d.forEach(g=>n.disposeIntermediateTensorInfo(g)),m}var gue={kernelName:Al,backendName:"cpu",kernelFunc:mue};function yue(e){let{inputs:t,backend:n,attrs:r}=e,{x:s}=t,{axis:a,keepDims:o}=r;Te(s,"min");let i=k.parseAxisParam(a,s.shape),l=i,u=_.getAxesPermutation(l,s.shape.length),c=s;u!=null&&(c=Pr({inputs:{x:s},backend:n,attrs:{perm:u}}),l=_.getInnerMostAxes(l.length,s.shape.length)),_.assertAxesAreInnerMostDims("min",l,c.shape.length);let[d,h]=_.computeOutAndReduceShapes(c.shape,l),p=k.sizeFromShape(h),f=k.makeZerosTypedArray(k.sizeFromShape(d),c.dtype),m=n.data.get(c.dataId).values;for(let y=0;y<f.length;++y){let A=y*p,x=m[A];for(let b=0;b<p;++b){let v=m[A+b];(Number.isNaN(v)||v<x)&&(x=v)}f[y]=x}u!=null&&n.disposeIntermediateTensorInfo(c);let g=n.makeTensorInfo(d,c.dtype,f);if(o){let y=_.expandShapeToKeepDim(d,i),A=Ft({inputs:{x:g},backend:n,attrs:{shape:y}});return n.disposeIntermediateTensorInfo(g),A}return g}var Aue={kernelName:xl,backendName:"cpu",kernelFunc:yue};function xue(e){let{inputs:t,backend:n,attrs:r}=e,{x:s}=t,{paddings:a,mode:o}=r;Te(s,"mirrorPad");let i=a.map((x,b)=>x[0]+s.shape[b]+x[1]),l=a.map(x=>x[0]),u=a.map((x,b)=>x[0]+s.shape[b]),c=o==="reflect"?0:1,d=n.data.get(s.dataId).values,h=s.shape.length,p=k.computeStrides(s.shape),f=k.sizeFromShape(i),m=i.length,g=k.computeStrides(i),y=k.getTypedArrayFromDType(s.dtype,f);for(let x=0;x<f;x++){let b=k.indexToLoc(x,m,g);for(let w=0;w<m;w++)b[w]<l[w]?b[w]=l[w]*2-b[w]-c:b[w]>=u[w]&&(b[w]=(u[w]-1)*2-b[w]+c);b=b.map((w,I)=>w-l[I]);let v=k.locToIndex(b,h,p);y[x]=d[v]}return{dataId:n.write(y,i,s.dtype),shape:i,dtype:s.dtype}}var bue={kernelName:bl,backendName:"cpu",kernelFunc:xue},vue=nn((e,t)=>{let n=e%t;return e<0&&t<0||e>=0&&t>=0?n:(n+t)%t}),wue=bn(Hc,vue),kue={kernelName:Hc,backendName:"cpu",kernelFunc:wue},Iue=Ks(e2());function VN(e){let{inputs:t,backend:n,attrs:r}=e,{logits:s}=t,{dim:a}=r,o=s.shape.length,i=a;if(i===-1&&(i=o-1),i!==o-1)throw Error(`Softmax along a non-last dimension is not yet supported. Logits was rank ${o} and dim was ${i}`);let l=k.parseAxisParam([i],s.shape),u=WN({inputs:{x:s},backend:n,attrs:{reductionIndices:l,keepDims:!1}}),c=_.expandShapeToKeepDim(u.shape,l),d=Ft({inputs:{x:u},backend:n,attrs:{shape:c}}),h=O5({inputs:{a:s,b:d},backend:n}),p=JT({inputs:{x:h},backend:n}),f=nh({inputs:{x:p},backend:n,attrs:{axis:l,keepDims:!1}}),m=Ft({inputs:{x:f},backend:n,attrs:{shape:c}}),g=L5({inputs:{a:p,b:m},backend:n});return n.disposeIntermediateTensorInfo(u),n.disposeIntermediateTensorInfo(d),n.disposeIntermediateTensorInfo(h),n.disposeIntermediateTensorInfo(p),n.disposeIntermediateTensorInfo(f),n.disposeIntermediateTensorInfo(m),g}var Sue={kernelName:Ml,backendName:"cpu",kernelFunc:VN};function Tue(e){let{inputs:t,backend:n,attrs:r}=e,{logits:s}=t,{numSamples:a,seed:o,normalized:i}=r;Te(s,"multinomial");let l=i?s:VN({inputs:{logits:s},backend:n,attrs:{dim:-1}}),u=l.shape[0],c=l.shape[1],d=n.data.get(l.dataId).values,h=[u,a],p=k.makeZerosTypedArray(k.sizeFromShape(h),"int32");for(let f=0;f<u;++f){let m=f*c,g=new Float32Array(c-1);g[0]=d[m];for(let x=1;x<g.length;++x)g[x]=g[x-1]+d[m+x];let y=Iue.alea(o.toString()),A=f*a;for(let x=0;x<a;++x){let b=y();p[A+x]=g.length;for(let v=0;v<g.length;v++)if(b<g[v]){p[A+x]=v;break}}}return i||n.disposeIntermediateTensorInfo(l),n.makeTensorInfo(h,"int32",p)}var Nue={kernelName:Hy,backendName:"cpu",kernelFunc:Tue},Cue=ca.nonMaxSuppressionV3Impl;function Eue(e){let{inputs:t,backend:n,attrs:r}=e,{boxes:s,scores:a}=t,{maxOutputSize:o,iouThreshold:i,scoreThreshold:l}=r;Te(s,"NonMaxSuppression");let u=n.data.get(s.dataId).values,c=n.data.get(a.dataId).values,{selectedIndices:d}=Cue(u,c,o,i,l);return n.makeTensorInfo([d.length],"int32",new Int32Array(d))}var $ue={kernelName:jc,backendName:"cpu",kernelFunc:Eue},_ue=ca.nonMaxSuppressionV4Impl;function Rue(e){let{inputs:t,backend:n,attrs:r}=e,{boxes:s,scores:a}=t,{maxOutputSize:o,iouThreshold:i,scoreThreshold:l,padToMaxOutputSize:u}=r;Te(s,"NonMaxSuppressionPadded");let c=n.data.get(s.dataId).values,d=n.data.get(a.dataId).values,{selectedIndices:h,validOutputs:p}=_ue(c,d,o,i,l,u);return[n.makeTensorInfo([h.length],"int32",new Int32Array(h)),n.makeTensorInfo([],"int32",new Int32Array([p]))]}var Due={kernelName:qc,backendName:"cpu",kernelFunc:Rue},Fue=ca.nonMaxSuppressionV5Impl;function Mue(e){let{inputs:t,backend:n,attrs:r}=e,{boxes:s,scores:a}=t,{maxOutputSize:o,iouThreshold:i,scoreThreshold:l,softNmsSigma:u}=r;Te(s,"NonMaxSuppressionWithScore");let c=n.data.get(s.dataId).values,d=n.data.get(a.dataId).values,h=o,p=i,f=l,m=u,{selectedIndices:g,selectedScores:y}=Fue(c,d,h,p,f,m);return[n.makeTensorInfo([g.length],"int32",new Int32Array(g)),n.makeTensorInfo([y.length],"float32",new Float32Array(y))]}var Oue={kernelName:Kc,backendName:"cpu",kernelFunc:Mue};function Pue(e){let{inputs:t,backend:n,attrs:r}=e,{indices:s}=t,{depth:a,onValue:o,offValue:i}=r;Te(s,"oneHot");let l=k.sizeFromShape(s.shape),u=new Float32Array(l*a);u.fill(i);let c=n.data.get(s.dataId).values;for(let d=0;d<l;++d)c[d]>=0&&c[d]<a&&(u[d*a+c[d]]=o);return n.makeTensorInfo([...s.shape,a],"int32",u)}var zue={kernelName:wl,backendName:"cpu",kernelFunc:Pue};function Rm(e){let{inputs:t,backend:n}=e,{x:r}=t;if(r.dtype==="string")throw new Error("zerosLike is not supported for string tensors");if(r.dtype==="complex64"){let s=pi({inputs:{input:r},backend:n}),a=Rm({inputs:{x:s},backend:n}),o=hu({inputs:{input:r},backend:n}),i=Rm({inputs:{x:o},backend:n}),l=fr({inputs:{real:a,imag:i},backend:n});return n.disposeIntermediateTensorInfo(s),n.disposeIntermediateTensorInfo(a),n.disposeIntermediateTensorInfo(o),n.disposeIntermediateTensorInfo(i),l}else return V5({backend:n,attrs:{shape:r.shape,value:0,dtype:r.dtype}})}var Lue={kernelName:hd,backendName:"cpu",kernelFunc:Rm};function UN(e){let{inputs:t,backend:n}=e,{x:r}=t;if(r.dtype==="string")throw new Error("onesLike is not supported for string tensors");if(r.dtype==="complex64"){let s=pi({inputs:{input:r},backend:n}),a=UN({inputs:{x:s},backend:n}),o=hu({inputs:{input:r},backend:n}),i=Rm({inputs:{x:o},backend:n}),l=fr({inputs:{real:a,imag:i},backend:n});return n.disposeIntermediateTensorInfo(s),n.disposeIntermediateTensorInfo(a),n.disposeIntermediateTensorInfo(o),n.disposeIntermediateTensorInfo(i),l}else return V5({backend:n,attrs:{shape:r.shape,value:1,dtype:r.dtype}})}var Bue={kernelName:Xc,backendName:"cpu",kernelFunc:UN};function HN(e){let{inputs:t,backend:n,attrs:r}=e,{axis:s}=r;if(t.length===1)return _m({inputs:{input:t[0]},backend:n,attrs:{dim:s}});let a=t[0].shape,o=t[0].dtype;t.forEach(c=>{k.assertShapesMatch(a,c.shape,"All tensors passed to stack must have matching shapes"),k.assert(o===c.dtype,()=>"All tensors passed to stack must have matching dtypes")});let i=[],l=t.map(c=>{let d=_m({inputs:{input:c},backend:n,attrs:{dim:s}});return i.push(d),d}),u=pu({inputs:l,backend:n,attrs:{axis:s}});return i.forEach(c=>n.disposeIntermediateTensorInfo(c)),u}var Wue={kernelName:Zc,backendName:"cpu",kernelFunc:HN};function Vue(e){let{inputs:t,backend:n,attrs:r}=e,{x:s}=t,{paddings:a,constantValue:o}=r;Te(s,"pad");let i=a.map((A,x)=>A[0]+s.shape[x]+A[1]),l=a.map(A=>A[0]),u=n.data.get(s.dataId).values,c=k.sizeFromShape(s.shape),d=s.shape.length,h=k.computeStrides(s.shape),p=k.sizeFromShape(i),f=i.length,m=k.computeStrides(i),g=k.getTypedArrayFromDType(s.dtype,p);o!==0&&g.fill(o);for(let A=0;A<c;A++){let b=k.indexToLoc(A,d,h).map((w,I)=>w+l[I]),v=k.locToIndex(b,f,m);g[v]=u[A]}return{dataId:n.write(g,i,s.dtype),shape:i,dtype:s.dtype}}var GN={kernelName:kl,backendName:"cpu",kernelFunc:Vue},Uue=nn((e,t)=>Math.pow(e,t)),Hue=bn(Il,Uue),Gue={kernelName:Il,backendName:"cpu",kernelFunc:Hue};function jue(e){let{backend:t,attrs:n}=e,{start:r,stop:s,dtype:a,step:o}=n,i=mN(r,s,o,a);return t.makeTensorInfo([i.length],a,i)}var que={kernelName:sf,backendName:"cpu",kernelFunc:jue},Kue=xt(Jc,e=>1/e),Xue={kernelName:Jc,backendName:"cpu",kernelFunc:Kue};function Zue(e){let{inputs:t,backend:n,attrs:r}=e,{images:s}=t,{alignCorners:a,halfPixelCenters:o,size:i}=r;Te(s,"resizeBilinear");let l=k.computeStrides(s.shape),[u,c]=i,[d,h,p,f]=s.shape,m=n.data.get(s.dataId).values,g=new Float32Array(k.sizeFromShape([d,u,c,f])),y=[a&&u>1?h-1:h,a&&c>1?p-1:p],A=[a&&u>1?u-1:u,a&&c>1?c-1:c],x=0,b=y[0]/A[0],v=y[1]/A[1];for(let w=0;w<d;w++)for(let I=0;I<u;I++){let T;o?T=b*(I+.5)-.5:T=b*I;let C=Math.max(0,Math.floor(T)),M=T-C,$=Math.min(h-1,Math.ceil(T)),R=w*l[0]+C*l[1],N=w*l[0]+$*l[1];for(let F=0;F<c;F++){let B;o?B=v*(F+.5)-.5:B=v*F;let j=Math.max(0,Math.floor(B)),X=B-j,Y=Math.min(p-1,Math.ceil(B)),ee=R+j*l[2],oe=N+j*l[2],se=R+Y*l[2],ie=N+Y*l[2];for(let ne=0;ne<f;ne++){let de=m[ee+ne],he=m[oe+ne],ge=m[se+ne],be=m[ie+ne],Ee=de+(ge-de)*X,$e=he+(be-he)*X,ze=Ee+($e-Ee)*M;g[x++]=ze}}}return n.makeTensorInfo([d,u,c,f],"float32",g)}var Yue={kernelName:Nl,backendName:"cpu",kernelFunc:Zue};function Jue(e){let{inputs:t,backend:n,attrs:r}=e,{images:s,dy:a}=t,{alignCorners:o}=r;Te([a,s],"resizeBilinearGrad");let i=k.computeStrides(s.shape),[l,u,c,d]=s.shape,[,h,p]=a.shape,f=new Float32Array(l*u*c*d),m=[o&&h>1?u-1:u,o&&p>1?c-1:c],g=[o&&h>1?h-1:h,o&&p>1?p-1:p],y=m[0]/g[0],A=m[1]/g[1],x=n.data.get(a.dataId).values,b=0;for(let v=0;v<l;v++){let w=v*i[0];for(let I=0;I<h;I++){let T=I*y,C=Math.floor(T),M=Math.min(Math.ceil(T),u-1),$=w+C*i[1],R=w+M*i[1],N=T-C,F=1-N;for(let B=0;B<p;B++){let j=B*A,X=Math.floor(j),Y=Math.min(Math.ceil(j),c-1),ee=j-X,oe=1-ee,se=$+X*i[2],ie=$+Y*i[2],ne=R+X*i[2],de=R+Y*i[2],he=F*oe,ge=F*ee,be=N*oe,Ee=N*ee;for(let $e=0;$e<d;$e++){let ze=x[b++];f[se+$e]+=ze*he,f[ie+$e]+=ze*ge,f[ne+$e]+=ze*be,f[de+$e]+=ze*Ee}}}}return n.makeTensorInfo([l,c,u,d],"float32",f)}var Que={kernelName:qy,backendName:"cpu",kernelFunc:Jue};function ece(e){let{inputs:t,backend:n,attrs:r}=e,{images:s}=t,{alignCorners:a,halfPixelCenters:o,size:i}=r;Te(s,"resizeNearestNeighbor");let l=k.computeStrides(s.shape),[u,c]=i,[d,h,p,f]=s.shape,m=n.data.get(s.dataId).values,g=new Float32Array(d*u*c*f),y=[a&&u>1?h-1:h,a&&c>1?p-1:p],A=[a&&u>1?u-1:u,a&&c>1?c-1:c],x=y[0]/A[0],b=y[1]/A[1],v=0;for(let w=0;w<d;w++){let I=w*l[0];for(let T=0;T<u;T++){let C=o?x*(T+.5):x*T,M=Math.min(h-1,a?Math.round(C):Math.floor(C));o&&(M=Math.max(0,M));let $=I+M*l[1];for(let R=0;R<c;R++){let N=o?b*(R+.5):b*R,F=Math.min(p-1,a?Math.round(N):Math.floor(N));o&&(F=Math.max(0,F));let B=$+F*l[2];for(let j=0;j<f;j++){let X=m[B+j];g[v++]=X}}}}return n.makeTensorInfo([d,u,c,f],s.dtype,g)}var tce={kernelName:af,backendName:"cpu",kernelFunc:ece};function nce(e){let{inputs:t,backend:n,attrs:r}=e,{images:s,dy:a}=t,{alignCorners:o}=r;Te([a,s],"resizeNearestNeighborGrad");let i=k.computeStrides(s.shape),l=k.computeStrides(a.shape),[u,c,d,h]=s.shape,[,p,f]=a.shape,m=new Float32Array(u*c*d*h),g=n.data.get(a.dataId).values,y=[o&&p>1?c-1:c,o&&f>1?d-1:d],A=[o&&p>1?p-1:p,o&&f>1?f-1:f],x=y[0]/A[0],b=y[1]/A[1],v=1/x,w=1/b,I=Math.ceil(v)*2+2,T=Math.ceil(w)*2+2;for(let C=0;C<u;C++){let M=C*i[0];for(let $=0;$<c;$++){let R=M+$*i[1],N=Math.floor($*v),F=Math.floor(N-I/2);for(let B=0;B<d;B++){let j=R+B*i[2],X=Math.floor(B*w),Y=Math.floor(X-T/2);for(let ee=0;ee<h;ee++){let oe=0;for(let se=0;se<I;se++){let ie=se+F;if(ie<0||ie>=p)continue;let ne=M+ie*l[1],de=ie*x,he=Math.min(c-1,o?Math.round(de):Math.floor(de));if($===he)for(let ge=0;ge<T;ge++){let be=ge+Y;if(be<0||be>=f)continue;let Ee=ne+be*l[2],$e=be*b,ze=Math.min(d-1,o?Math.round($e):Math.floor($e));B===ze&&(oe+=g[Ee+ee])}}m[j+ee]=oe}}}}return n.makeTensorInfo(s.shape,s.dtype,m)}var rce={kernelName:jy,backendName:"cpu",kernelFunc:nce};function sce(e){let{inputs:t,backend:n,attrs:r}=e,{x:s}=t,{dims:a}=r;Te(s,"reverse");let o=s.shape.length,i=k.parseAxisParam(a,s.shape);if(o===0)return zs({inputs:{x:s},backend:n});let l=new Qt(s.shape,s.dtype),u=n.bufferSync(s);for(let c=0;c<l.size;c++){let d=l.indexToLoc(c),h=d.slice();i.forEach(p=>h[p]=s.shape[p]-1-h[p]),l.set(u.get(...h),...d)}return n.makeTensorInfo(l.shape,l.dtype,l.values)}var ace={kernelName:El,backendName:"cpu",kernelFunc:sce},oce={kernelName:pd,backendName:"cpu",kernelFunc:({inputs:e,attrs:t,backend:n})=>{let{image:r}=e,{radians:s,fillValue:a,center:o}=t,i=n,l=k.getTypedArrayFromDType(r.dtype,k.sizeFromShape(r.shape)),[u,c,d,h]=r.shape,[p,f]=_.getImageCenter(o,c,d),m=255,g=Math.sin(s),y=Math.cos(s),A=i.data.get(r.dataId).values;for(let b=0;b<u;b++){let v=b*d*c*h;for(let w=0;w<c;w++){let I=w*(d*h);for(let T=0;T<d;T++){let C=T*h;for(let M=0;M<h;M++){let $=[u,w,T,M],R=$[2],N=$[1],F=(R-p)*y-(N-f)*g,B=(R-p)*g+(N-f)*y;F=Math.round(F+p),B=Math.round(B+f);let j=a;if(typeof a!="number"&&(M===3?j=m:j=a[M]),F>=0&&F<d&&B>=0&&B<c){let Y=B*(d*h),ee=F*h,oe=v+Y+ee+M;j=A[oe]}let X=v+I+C+M;l[X]=j}}}}return{dataId:i.write(l,r.shape,r.dtype),shape:r.shape,dtype:r.dtype}}},ice=xt($l,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}),lce={kernelName:$l,backendName:"cpu",kernelFunc:ice};function jN(e,t,n,r,s,a,o,i,l,u){let c=[r/s,s],d=e.values,h=t.values;if(r===0)return Le(n,t.dtype);let p=Le(c,t.dtype);p.values.fill(l);for(let f=0;f<a;f++){let m=[],g=0;for(let y=0;y<o;y++){let A=d[f*o+y];m.push(A),g+=A*i[y]}if(g<0||g>=r/s)throw new Error(`Invalid indices: ${m} does not index into ${n}`);for(let y=0;y<s;y++)u?p.values[g*s+y]+=h[f*s+y]:p.values[g*s+y]=t.rank===0?h[0]:h[f*s+y]}return p}function uce(e){let{inputs:t,backend:n,attrs:r}=e,{indices:s,updates:a}=t,{shape:o}=r,{sliceRank:i,numUpdates:l,sliceSize:u,strides:c,outputSize:d}=_.calculateShapes(a,s,o),h=!0,p=n.bufferSync(s),f=n.bufferSync(a),m=jN(p,f,o,d,u,l,i,c,0,h);return n.makeTensorInfo(o,m.dtype,m.values)}var cce={kernelName:ed,backendName:"cpu",kernelFunc:uce};function dce(e){let{inputs:t,backend:n}=e,{condition:r,t:s,e:a}=t;Te([r,s,a],"select");let o=r.shape.length,i=n.data.get(r.dataId).values,l=n.data.get(s.dataId).values,u=n.data.get(a.dataId).values,c=qr(s.dtype,a.dtype),d=k.makeZerosTypedArray(k.sizeFromShape(s.shape),c),h=0,p=o===0||o>1||s.shape.length===1?1:k.sizeFromShape(s.shape.slice(1));for(let f=0;f<i.length;f++)for(let m=0;m<p;m++)i[f]===1?d[h++]=l[f]:d[h++]=u[f];return n.makeTensorInfo(s.shape,c,d)}var hce={kernelName:td,backendName:"cpu",kernelFunc:dce},pce=_.SELU_SCALEALPHA,fce=_.SELU_SCALE,mce=xt(nd,e=>e>=0?fce*e:pce*(Math.exp(e)-1)),gce={kernelName:nd,backendName:"cpu",kernelFunc:mce},yce=xt(ad,e=>e<0?-1:e>0?1:0),Ace={kernelName:ad,backendName:"cpu",kernelFunc:yce},xce=xt(_l,e=>Math.sin(e)),bce={kernelName:_l,backendName:"cpu",kernelFunc:xce},vce=xt(sd,e=>Math.sinh(e)),wce={kernelName:sd,backendName:"cpu",kernelFunc:vce},kce=11920928955078125e-23,qN=Math.log(kce)+2,Ice=xt(od,e=>{let t=e>-qN,n=e<qN,r=Math.exp(e),s;return n?s=r:t?s=e:s=Math.log(1+r),s}),Sce={kernelName:od,backendName:"cpu",kernelFunc:Ice};function Tce(e){let{inputs:t,backend:n,attrs:r}=e,{x:s}=t,{blockShape:a,paddings:o}=r;Te([s],"spaceToBatchND");let i=k.sizeFromShape(a),l=[[0,0]];l.push(...o);for(let w=1+a.length;w<s.shape.length;++w)l.push([0,0]);let u=GN.kernelFunc({inputs:{x:s},backend:n,attrs:{paddings:l,constantValue:0}}),c=_.getReshaped(u.shape,a,i,!1),d=_.getPermuted(c.length,a.length,!1),h=_.getReshapedPermuted(u.shape,a,i,!1),m=Ft({inputs:{x:u},backend:n,attrs:{shape:c}}),A=Pr({inputs:{x:m},backend:n,attrs:{perm:d}}),v=Ft({inputs:{x:A},backend:n,attrs:{shape:h}});return n.disposeIntermediateTensorInfo(u),n.disposeIntermediateTensorInfo(m),n.disposeIntermediateTensorInfo(A),v}var Nce={kernelName:of,backendName:"cpu",kernelFunc:Tce};function Cce(e){let{inputs:t,backend:n}=e,{indices:r,values:s,denseShape:a,defaultValue:o}=t;if(a.shape.length!==1)throw new Error(`Dense shape must be a vector, saw:
|
|
${a.shape}`);if(r.shape.length!==2)throw new Error(`Indices must be a matrix, saw:
|
|
${r.shape}`);if(s.shape.length!==1)throw new Error(`Values must be a vector, saw:
|
|
${s.shape}`);if(o.shape.length!==0)throw new Error(`Default value must be a scalar, saw:
|
|
${o.shape}`);let i=n.data.get(r.dataId).values,l=n.data.get(s.dataId).values,u=n.data.get(a.dataId).values,c=n.data.get(o.dataId).values[0],[d,h,p,f,m]=AN(i,r.shape,r.dtype,l,s.dtype,u,c);return[n.makeTensorInfo(h,r.dtype,d),n.makeTensorInfo([h[0]],s.dtype,p),n.makeTensorInfo([f.length],"bool",new Uint8Array(f.map(g=>Number(g)))),n.makeTensorInfo([m.length],r.dtype,new Int32Array(m))]}var Ece={kernelName:Ky,backendName:"cpu",kernelFunc:Cce};function $ce(e){let{inputs:t,backend:n}=e,{inputIndices:r,inputShape:s,newShape:a}=t;if(r.shape.length!==2)throw new Error(`Input indices should be a matrix but received shape
|
|
${r.shape}`);if(s.shape.length!==1)throw new Error(`Input shape should be a vector but received shape
|
|
${s.shape}`);if(a.shape.length!==1)throw new Error(`Target shape should be a vector but received shape ${a.shape}`);let o=Array.from(n.data.get(s.dataId).values),i=n.data.get(r.dataId).values,l=Array.from(n.data.get(a.dataId).values),[u,c,d]=xN(i,r.shape,r.dtype,o,l);return[n.makeTensorInfo(c,r.dtype,u),n.makeTensorInfo([d.length],a.dtype,new Int32Array(d))]}var _ce={kernelName:Xy,backendName:"cpu",kernelFunc:$ce};function Rce(e){let{inputs:t,backend:n}=e,{data:r,indices:s,segmentIds:a}=t;if(r.shape.length<1)throw new Error("Data should be at least 1 dimensional but received scalar");if(s.shape.length!==1)throw new Error(`Indices should be a vector but received shape
|
|
${s.shape}`);if(a.shape.length!==1)throw new Error(`Segment ids should be a vector but received shape
|
|
${a.shape}`);let o=n.data.get(r.dataId).values,i=n.data.get(s.dataId).values,l=n.data.get(a.dataId).values,[u,c]=M5(o,r.shape,r.dtype,i,l,!0);return n.makeTensorInfo(c,r.dtype,u)}var Dce={kernelName:Zy,backendName:"cpu",kernelFunc:Rce};function Fce(e){let{inputs:t,backend:n}=e,{data:r,indices:s,segmentIds:a}=t;if(r.shape.length<1)throw new Error("Data should be at least 1 dimensional but received scalar");if(s.shape.length!==1)throw new Error(`Indices should be a vector but received shape
|
|
${s.shape}`);if(a.shape.length!==1)throw new Error(`Segment ids should be a vector but received shape
|
|
${a.shape}`);let o=n.data.get(r.dataId).values,i=n.data.get(s.dataId).values,l=n.data.get(a.dataId).values,[u,c]=M5(o,r.shape,r.dtype,i,l);return n.makeTensorInfo(c,r.dtype,u)}var Mce={kernelName:Yy,backendName:"cpu",kernelFunc:Fce};function Oce(e){let{inputs:t,backend:n,attrs:r}=e,{sparseIndices:s,sparseValues:a,defaultValue:o}=t,{outputShape:i}=r,{sliceRank:l,numUpdates:u,sliceSize:c,strides:d,outputSize:h}=_.calculateShapes(a,s,i),p=!1,f=n.bufferSync(s),m=n.bufferSync(a),g=n.data.get(o.dataId).values[0],y=jN(f,m,i,h,c,u,l,d,g,p);return n.makeTensorInfo(i,y.dtype,y.values)}var Pce={kernelName:Jy,backendName:"cpu",kernelFunc:Oce};function zce(e){let{inputs:t,backend:n,attrs:r}=e,{x:s}=t,{numOrSizeSplits:a,axis:o}=r,i=k.parseAxisParam(o,s.shape)[0],l=_.prepareSplitSize(s,a,i),u=new Array(s.shape.length).fill(0),c=s.shape.slice();return l.map(d=>{let h=[...c];h[i]=d;let p=fi({inputs:{x:s},backend:n,attrs:{begin:u,size:h}});return u[i]+=d,p})}var Lce={kernelName:id,backendName:"cpu",kernelFunc:zce},Bce=xt(Dl,e=>Math.sqrt(e)),Wce={kernelName:Dl,backendName:"cpu",kernelFunc:Bce},Vce={kernelName:lf,backendName:"cpu",kernelFunc:({inputs:e,backend:t})=>{let{x:n}=e,r=t;Te(n,"square");let s=r.data.get(n.dataId).values,a=new Float32Array(s.length);for(let i=0;i<s.length;++i){let l=s[i];a[i]=l*l}return{dataId:r.write(a,n.shape,n.dtype),shape:n.shape,dtype:n.dtype}}},Uce=xt(Bo,(e,t)=>{let n=t;return isNaN(e)?NaN:e>0?1:n.alpha}),Hce={kernelName:Bo,backendName:"cpu",kernelFunc:Uce};function Gce(e){let{inputs:t,backend:n,attrs:r}=e,{x:s}=t,{begin:a,end:o,strides:i,beginMask:l,endMask:u,ellipsisMask:c,newAxisMask:d,shrinkAxisMask:h}=r;Te(s,"stridedSlice");let{nonStrided:p,$begin:f,$strides:m,size:g,newShape:y,outShape:A}=En.sliceInfo(s.shape,a,o,i,l,u,c,d,h),x=Ft({inputs:{x:s},backend:n,attrs:{shape:y}}),b;if(p){let w=fi({inputs:{x},backend:n,attrs:{begin:f,size:g}});b=Ft({inputs:{x:w},backend:n,attrs:{shape:A}}),n.disposeIntermediateTensorInfo(w)}else if(A.some(w=>w===0))b=n.makeTensorInfo(A,s.dtype,[]);else{let w=n.bufferSync(x),I=vN(A,w,m,f);b=n.makeTensorInfo(I.shape,I.dtype,I.values)}let v=Ft({inputs:{x:b},backend:n,attrs:{shape:A}});return n.disposeIntermediateTensorInfo(x),n.disposeIntermediateTensorInfo(b),v}var jce={kernelName:ld,backendName:"cpu",kernelFunc:Gce};function qce(e){let{inputs:t,backend:n,attrs:r}=e,{separator:s,nGramWidths:a,leftPad:o,rightPad:i,padWidth:l,preserveShortSequences:u}=r,{data:c,dataSplits:d}=t,h=n.data.get(c.dataId).values,p=n.data.get(d.dataId).values,[f,m]=wN(h,p,s,a,o,i,l,u);return[n.makeTensorInfo([f.length],"string",f),n.makeTensorInfo(d.shape,"int32",m)]}var Kce={kernelName:Qy,backendName:"cpu",kernelFunc:qce};function Xce(e){let{inputs:t,backend:n,attrs:r}=e,{skipEmpty:s}=r,{input:a,delimiter:o}=t;if(a.dtype!=="string")throw new Error("Input must be of datatype string");if(a.shape.length!==1)throw new Error(`Input must be a vector, got shape: ${a.shape}`);if(o.shape.length!==0)throw new Error(`Delimiter must be a scalar, got shape: ${o.shape}`);let i=n.data.get(a.dataId).values,l=n.data.get(o.dataId).values[0],[u,c,d]=kN(i,l,s),h=c.length;return[n.makeTensorInfo([h,2],"int32",u),n.makeTensorInfo([h],"string",c),n.makeTensorInfo([2],"int32",new Int32Array(d))]}var Zce={kernelName:eA,backendName:"cpu",kernelFunc:Xce};function Yce(e){let{inputs:t,backend:n,attrs:r}=e,{numBuckets:s}=r,{input:a}=t;if(a.dtype!=="string")throw new Error("Input must be of datatype string");if(s<=0)throw new Error("Number of buckets must be at least 1");let o=n.data.get(a.dataId).values,i=IN(o,s);return n.makeTensorInfo(a.shape,"int32",i)}var Jce={kernelName:tA,backendName:"cpu",kernelFunc:Yce},Qce=xt(Ol,e=>Math.tan(e)),ede={kernelName:Ol,backendName:"cpu",kernelFunc:Qce},tde=xt(Pl,e=>Math.tanh(e)),nde={kernelName:Pl,backendName:"cpu",kernelFunc:tde};function rde(e){let{inputs:t,backend:n,attrs:r}=e,{x:s}=t,{reps:a}=r;Te(s,"tile");let o=TN(n.bufferSync(s),a);return n.makeTensorInfo(o.shape,o.dtype,o.values)}var sde={kernelName:Lo,backendName:"cpu",kernelFunc:rde};function ade(e){let{inputs:t,backend:n,attrs:r}=e,{x:s}=t,{k:a,sorted:o}=r;Te(s,"topk");let i=n.data.get(s.dataId).values,[l,u]=NN(i,s.shape,s.dtype,a,o);return[n.makeTensorInfo(l.shape,l.dtype,l.values),n.makeTensorInfo(u.shape,u.dtype,u.values)]}var ode={kernelName:ud,backendName:"cpu",kernelFunc:ade};function ide(e){let{inputs:t,attrs:n,backend:r}=e,{image:s,transforms:a}=t,{interpolation:o,fillMode:i,fillValue:l,outputShape:u}=n,[c,d,h,p]=s.shape,[f,m]=u!=null?u:[d,h],g=[c,f,m,p],y=k.computeStrides(s.shape),A=y[0],x=y[1],b=y[2],v=k.getTypedArrayFromDType(s.dtype,k.sizeFromShape(g));v.fill(l);let w=r.data.get(s.dataId).values,I=r.data.get(a.dataId).values;for(let C=0;C<c;++C){let M=a.shape[0]===1?I:I.subarray(C*8,C*8+8);for(let $=0;$<f;++$)for(let R=0;R<m;++R)for(let N=0;N<p;++N){let F,B=M[6]*R+M[7]*$+1;if(B===0)continue;let j=(M[0]*R+M[1]*$+M[2])/B,X=(M[3]*R+M[4]*$+M[5])/B,Y=KN(j,h,i),ee=KN(X,d,i);switch(o){case"nearest":F=pde(w,d,h,A,x,b,C,ee,Y,N,l);break;case"bilinear":F=fde(w,d,h,A,x,b,C,ee,Y,N,l);break;default:throw new Error(`Error in Transform: Expect 'nearest' or 'bilinear', but got ${o}`)}let oe=C*A+$*x+R*b+N;v[oe]=F}return r.makeTensorInfo(g,s.dtype,v)}return{dataId:r.write(v,g,s.dtype),shape:s.shape,dtype:s.dtype}}var lde={kernelName:cd,backendName:"cpu",kernelFunc:ide};function KN(e,t,n){switch(n){case"reflect":return ude(e,t);case"wrap":return cde(e,t);case"nearest":return hde(e,t);case"constant":default:return dde(e,t)}}function ude(e,t){let n=e;if(n<0)if(t<=1)n=0;else{let r=2*t;n<r&&(n=r*Math.trunc(-n/r)+n),n=n<-t?n+r:-n-1}else if(n>t-1)if(t<=1)n=0;else{let r=2*t;n-=r*Math.trunc(n/r),n>=t&&(n=r-n-1)}return k.clamp(0,n,t-1)}function cde(e,t){let n=e;if(n<0)if(t<=1)n=0;else{let r=t-1;n+=t*(Math.trunc(-n/r)+1)}else if(n>t-1)if(t<=1)n=0;else{let r=t-1;n-=t*Math.trunc(n/r)}return k.clamp(0,n,t-1)}function dde(e,t){return e}function hde(e,t){return k.clamp(0,e,t-1)}function rh(e,t,n,r,s,a,o,i,l,u,c){let d=o*r+i*s+l*a+u;return 0<=i&&i<t&&0<=l&&l<n?e[d]:c}function pde(e,t,n,r,s,a,o,i,l,u,c){let d=Math.round(i),h=Math.round(l);return rh(e,t,n,r,s,a,o,d,h,u,c)}function fde(e,t,n,r,s,a,o,i,l,u,c){let d=Math.floor(i),h=Math.floor(l),p=d+1,f=h+1,m=(f-l)*rh(e,t,n,r,s,a,o,d,h,u,c)+(l-h)*rh(e,t,n,r,s,a,o,d,f,u,c),g=(f-l)*rh(e,t,n,r,s,a,o,p,h,u,c)+(l-h)*rh(e,t,n,r,s,a,o,p,f,u,c);return(p-i)*m+(i-d)*g}function mde(e){let{inputs:t,attrs:n,backend:r}=e,{axis:s}=n,{x:a}=t;Te(a,"unique");let o=r.data.get(a.dataId).values,{outputValues:i,outputShape:l,indices:u}=CN(o,s,a.shape,a.dtype);return[r.makeTensorInfo(l,a.dtype,i),r.makeTensorInfo([u.length],"int32",u)]}var gde={kernelName:nA,backendName:"cpu",kernelFunc:mde};function yde(e){let{inputs:t,backend:n,attrs:r}=e,{value:s}=t,{axis:a}=r;a<0&&(a+=s.shape.length);let o=s.shape.length,i=s.shape[a],l=new Array(o-1),u=0;for(let p=0;p<o;p++)p!==a&&(l[u++]=s.shape[p]);let c=new Array(o).fill(0),d=s.shape.slice();d[a]=1;let h=new Array(i);for(let p=0;p<h.length;p++){c[a]=p;let f=fi({inputs:{x:s},backend:n,attrs:{begin:c,size:d}});h[p]=Ft({inputs:{x:f},backend:n,attrs:{shape:l}}),n.disposeIntermediateTensorInfo(f)}return h}var Ade={kernelName:dd,backendName:"cpu",kernelFunc:yde};function xde(e){let{inputs:t,backend:n,attrs:r}=e,{x:s,segmentIds:a}=t,{numSegments:o}=r;Te(s,"unsortedSegmentSum");let i=s.shape.length,l=a.shape.length,u=[],c=[],d=i-l,h=a;for(let f=0;f<d;++f){let m=_m({inputs:{input:h},backend:n,attrs:{dim:f+1}});h=m,c.push(m)}for(let f=0;f<o;++f){let m=k.createScalarValue(f,"int32"),g=n.makeTensorInfo([],"int32",m),y=ZT({inputs:{a:g,b:h},backend:n}),A=Ja({inputs:{x:y},backend:n,attrs:{dtype:"float32"}}),x=$m({inputs:{a:A,b:s},backend:n}),b=nh({inputs:{x},backend:n,attrs:{axis:0,keepDims:!1}});u.push(b),c.push(g),c.push(y),c.push(A),c.push(x),c.push(b)}let p=HN({inputs:u,backend:n,attrs:{axis:0}});return c.forEach(f=>n.disposeIntermediateTensorInfo(f)),p}var bde={kernelName:uf,backendName:"cpu",kernelFunc:xde},vde=[Coe,Iae,$oe,Roe,$ae,Foe,Ooe,zoe,Boe,Voe,Hoe,joe,Koe,Yoe,Qoe,nie,sie,oie,lie,Toe,cie,hie,fie,Cae,Rae,gie,Sae,Aie,bie,kie,Sie,vie,Eie,_ie,Nie,Die,Mie,Pie,Lie,Wie,Uie,Hie,jie,Kie,Zie,Yie,Qie,Jie,B5,nle,Aoe,sle,Dae,hle,Fae,ple,Oae,xle,ble,wle,zae,Sle,Nle,Ele,_le,Dle,Bae,Vae,Tae,Mle,xie,Ple,Lle,Wle,xoe,Hae,jae,Ule,Kae,Gle,Kle,Zle,Qle,tue,rue,Zae,oue,lue,cue,hue,fue,sue,gue,Aue,Jae,bue,kue,Nue,eoe,noe,$ue,Due,Oue,soe,zue,Bue,Wue,GN,Gue,voe,ioe,que,Nae,Xue,woe,koe,Soe,Yue,Que,tce,rce,ace,oce,lce,uoe,cce,hce,gce,Ioe,Ace,bce,wce,coe,Sue,Sce,Nce,Ece,_ce,Dce,Mce,Pce,Lce,Wce,Vce,hoe,Hce,jce,Kce,Zce,Jce,goe,ele,ede,nde,sde,ode,aoe,lde,gde,Ade,bde,Lue];for(let e of vde)oA(e);var XN={};De(XN,{assertNotComplex:()=>mu,bindCanvasToFramebuffer:()=>Dde,bindColorTextureToFramebuffer:()=>Mm,bindTextureToProgramUniformSampler:()=>cC,bindTextureUnit:()=>iC,bindVertexBufferToProgramAttribute:()=>G5,callAndCheck:()=>Ie,canBeRepresented:()=>ZN,createFragmentShader:()=>QN,createFramebuffer:()=>oC,createProgram:()=>eC,createStaticIndexBuffer:()=>rC,createStaticVertexBuffer:()=>nC,createTexture:()=>sC,createVertexShader:()=>JN,getBatchDim:()=>gi,getExtensionOrThrow:()=>ih,getFramebufferErrorMessage:()=>dC,getMaxTexturesInShader:()=>mC,getNumChannels:()=>_de,getProgramUniformLocation:()=>uC,getProgramUniformLocationOrThrow:()=>lC,getRowsCols:()=>yi,getShapeAs3D:()=>Om,getTextureShapeFromLogicalShape:()=>pC,getWebGLDisjointQueryTimerVersion:()=>gC,getWebGLErrorMessage:()=>YN,getWebGLMaxTextureSize:()=>fC,hasExtension:()=>Lr,isCapableOfRenderingToFloatTexture:()=>yC,isDownloadFloatTextureEnabled:()=>AC,isReshapeFree:()=>uh,isWebGLFenceEnabled:()=>xC,isWebGLVersionEnabled:()=>q5,linkProgram:()=>tC,resetMaxTextureSize:()=>Fde,resetMaxTexturesInShader:()=>Mde,unbindColorTextureFromFramebuffer:()=>j5,unbindTextureUnit:()=>Rde,validateFramebuffer:()=>lh,validateProgram:()=>Fm,validateTextureSize:()=>aC});var mi={},U5={alpha:!1,antialias:!1,premultipliedAlpha:!1,preserveDrawingBuffer:!1,depth:!1,stencil:!1,failIfMajorPerformanceCaveat:!0};function Dm(e,t){mi[e]=t}function Ls(e){if(!(e in mi)){let n=kde(e);if(n!==null)mi[e]=n;else return console.log("Could not get context for WebGL version",e),null}let t=mi[e];return t.isContextLost()?(delete mi[e],Ls(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),mi[e])}function wde(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 kde(e){if(e!==1&&e!==2)throw new Error("Cannot get WebGL rendering context, WebGL is disabled.");let t=wde(e);return t.addEventListener("webglcontextlost",n=>{n.preventDefault(),delete mi[e]},!1),e===1?t.getContext("webgl",U5)||t.getContext("experimental-webgl",U5):t.getContext("webgl2",U5)}var sh;(function(e){e[e.DENSE=0]="DENSE",e[e.SHARED_BATCH=1]="SHARED_BATCH"})(sh||(sh={}));var zr;(function(e){e[e.RENDER=0]="RENDER",e[e.UPLOAD=1]="UPLOAD",e[e.PIXELS=2]="PIXELS",e[e.DOWNLOAD=3]="DOWNLOAD"})(zr||(zr={}));var Tn;(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"})(Tn||(Tn={}));function ah(e,t){return[t,e]}function Ide(e,t){return e*t}function oh(e){let t=k.sizeFromShape(e),n=Math.ceil(t/4);return k.sizeToSquarishShape(n)}function fu(e,t){return[Math.max(1,Math.ceil(t/2)),Math.max(1,Math.ceil(e/2))]}function Sde(e,t){let[n,r]=fu(e,t);return n*r*4}function H5(e,t){let n=e,r,s,a,o,i,l,u,c,d,h;return ae().getNumber("WEBGL_VERSION")===2?(r=n.R32F,s=n.R16F,a=n.RGBA16F,o=n.RGBA32F,i=n.RED,u=4,c=1,d=n.HALF_FLOAT,h=n.FLOAT):(r=e.RGBA,s=e.RGBA,a=e.RGBA,o=n.RGBA,i=e.RGBA,u=4,c=4,d=t!=null?t.HALF_FLOAT_OES:null,h=e.FLOAT),l=e.RGBA,{internalFormatFloat:r,internalFormatHalfFloat:s,internalFormatPackedHalfFloat:a,internalFormatPackedFloat:o,textureFormatFloat:i,downloadTextureFormat:l,downloadUnpackNumChannels:u,defaultNumChannels:c,textureTypeHalfFloat:d,textureTypeFloat:h}}function Ie(e,t){let n=t();return ae().getBool("DEBUG")&&Tde(e),n}function Tde(e){let t=e.getError();if(t!==e.NO_ERROR)throw new Error("WebGL Error: "+YN(e,t))}var Nde=596e-10,Cde=65504;function ZN(e){return!!(ae().getBool("WEBGL_RENDER_FLOAT32_ENABLED")||e===0||Nde<Math.abs(e)&&Math.abs(e)<Cde)}function YN(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 ih(e,t){return ya(e,()=>e.getExtension(t),'Extension "'+t+'" not supported on this browser.')}function JN(e,t){let n=ya(e,()=>e.createShader(e.VERTEX_SHADER),"Unable to create vertex WebGLShader.");if(Ie(e,()=>e.shaderSource(n,t)),Ie(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 QN(e,t){let n=ya(e,()=>e.createShader(e.FRAGMENT_SHADER),"Unable to create fragment WebGLShader.");if(Ie(e,()=>e.shaderSource(n,t)),Ie(e,()=>e.compileShader(n)),e.getShaderParameter(n,e.COMPILE_STATUS)===!1)throw $de(t,e.getShaderInfoLog(n)),new Error("Failed to compile fragment shader.");return n}var Ede=/ERROR: [0-9]+:([0-9]+):/g;function $de(e,t){let n=Ede.exec(t);if(n==null){console.log(`Couldn't parse line number in error: ${t}`),console.log(e);return}let r=+n[1],s=e.split(`
|
|
`),a=s.length.toString().length+2,o=s.map((d,h)=>k.rightPad((h+1).toString(),a)+d),i=0;for(let d=0;d<o.length;d++)i=Math.max(o[d].length,i);let l=o.slice(0,r-1),u=o.slice(r-1,r),c=o.slice(r);console.log(l.join(`
|
|
`)),console.log(t.split(`
|
|
`)[0]),console.log(`%c ${k.rightPad(u[0],i)}`,"border:1px solid red; background-color:#e3d2d2; color:#a61717"),console.log(c.join(`
|
|
`))}function eC(e){return ya(e,()=>e.createProgram(),"Unable to create WebGLProgram.")}function tC(e,t){if(Ie(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 Fm(e,t){if(Ie(e,()=>e.validateProgram(t)),e.getProgramParameter(t,e.VALIDATE_STATUS)===!1)throw console.log(e.getProgramInfoLog(t)),new Error("Shader program validation failed.")}function nC(e,t){let n=ya(e,()=>e.createBuffer(),"Unable to create WebGLBuffer");return Ie(e,()=>e.bindBuffer(e.ARRAY_BUFFER,n)),Ie(e,()=>e.bufferData(e.ARRAY_BUFFER,t,e.STATIC_DRAW)),n}function rC(e,t){let n=ya(e,()=>e.createBuffer(),"Unable to create WebGLBuffer");return Ie(e,()=>e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,n)),Ie(e,()=>e.bufferData(e.ELEMENT_ARRAY_BUFFER,t,e.STATIC_DRAW)),n}function _de(){return ae().getNumber("WEBGL_VERSION")===2?1:4}function sC(e){return ya(e,()=>e.createTexture(),"Unable to create WebGLTexture.")}function aC(e,t){let n=ae().getNumber("WEBGL_MAX_TEXTURE_SIZE");if(e<=0||t<=0){let r=`[${e}x${t}]`;throw new Error("Requested texture size "+r+" is invalid.")}if(e>n||t>n){let r=`[${e}x${t}]`,s=`[${n}x${n}]`;throw new Error("Requested texture size "+r+" greater than WebGL maximum on this browser / GPU "+s+".")}}function oC(e){return ya(e,()=>e.createFramebuffer(),"Unable to create WebGLFramebuffer.")}function G5(e,t,n,r,s,a,o){let i=e.getAttribLocation(t,n);return i===-1?!1:(Ie(e,()=>e.bindBuffer(e.ARRAY_BUFFER,r)),Ie(e,()=>e.vertexAttribPointer(i,s,e.FLOAT,!1,a,o)),Ie(e,()=>e.enableVertexAttribArray(i)),!0)}function iC(e,t,n){hC(e,n),Ie(e,()=>e.activeTexture(e.TEXTURE0+n)),Ie(e,()=>e.bindTexture(e.TEXTURE_2D,t))}function Rde(e,t){hC(e,t),Ie(e,()=>e.activeTexture(e.TEXTURE0+t)),Ie(e,()=>e.bindTexture(e.TEXTURE_2D,null))}function lC(e,t,n){return ya(e,()=>e.getUniformLocation(t,n),'uniform "'+n+'" not present in program.')}function uC(e,t,n){return e.getUniformLocation(t,n)}function cC(e,t,n,r){Ie(e,()=>iC(e,t,r)),Ie(e,()=>e.uniform1i(n,r))}function Dde(e){Ie(e,()=>e.bindFramebuffer(e.FRAMEBUFFER,null)),Ie(e,()=>e.viewport(0,0,e.canvas.width,e.canvas.height)),Ie(e,()=>e.scissor(0,0,e.canvas.width,e.canvas.height))}function Mm(e,t,n){Ie(e,()=>e.bindFramebuffer(e.FRAMEBUFFER,n)),Ie(e,()=>e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,t,0))}function j5(e,t){Ie(e,()=>e.bindFramebuffer(e.FRAMEBUFFER,t)),Ie(e,()=>e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,null,0))}function lh(e){let t=e.checkFramebufferStatus(e.FRAMEBUFFER);if(t!==e.FRAMEBUFFER_COMPLETE)throw new Error("Error binding framebuffer: "+dC(e,t))}function dC(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 ya(e,t,n){let r=Ie(e,()=>t());if(r==null)throw new Error(n);return r}function hC(e,t){let n=e.MAX_COMBINED_TEXTURE_IMAGE_UNITS-1,r=t+e.TEXTURE0;if(r<e.TEXTURE0||r>n){let s=`[gl.TEXTURE0, gl.TEXTURE${n}]`;throw new Error(`textureUnit must be in ${s}.`)}}function gi(e,t=2){return k.sizeFromShape(e.slice(0,e.length-t))}function yi(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 Om(e){let t=[1,1,1];return e.length===0||e.length===1&&e[0]===1||(t=[gi(e),...yi(e)]),t}function pC(e,t=!1){let n=ae().getNumber("WEBGL_MAX_TEXTURE_SIZE");t&&(n=n*2,e=e.map((s,a)=>a>=e.length-2?k.nearestLargerEven(e[a]):e[a]),e.length===1&&(e=[2,e[0]])),e.length!==2&&(e=k.squeezeShape(e).newShape);let r=k.sizeFromShape(e);if(e.length<=1&&r<=n)return[1,r];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 s=gi(e),a=2,o=2;return e.length&&([a,o]=yi(e)),r=s*(a/2)*(o/2),k.sizeToSquarishShape(r).map(i=>i*2)}return k.sizeToSquarishShape(r)}function Pm(e){return e%2==0}function uh(e,t){if(e=e.slice(-2),t=t.slice(-2),k.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],r=t.slice(-1)[0];if(n===r||Pm(n)&&Pm(r)&&(e[0]===1||t[0]===1))return!0}return e[1]===t[1]&&Pm(e[0])&&Pm(t[0])}var zm,Lm;function fC(e){if(zm==null){let t=Ls(e);zm=t.getParameter(t.MAX_TEXTURE_SIZE)}return zm}function Fde(){zm=null}function Mde(){Lm=null}function mC(e){if(Lm==null){let t=Ls(e);Lm=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS)}return Math.min(16,Lm)}function gC(e){if(e===0)return 0;let t,n=Ls(e);return Lr(n,"EXT_disjoint_timer_query_webgl2")&&e===2?t=2:Lr(n,"EXT_disjoint_timer_query")?t=1:t=0,t}function Lr(e,t){return e.getExtension(t)!=null}function q5(e){try{if(Ls(e)!=null)return!0}catch(t){return console.log("Error when getting WebGL context: ",t),!1}return!1}function yC(e){if(e===0)return!1;let t=Ls(e);if(e===1){if(!Lr(t,"OES_texture_float"))return!1}else if(!Lr(t,"EXT_color_buffer_float"))return!1;return K5(t)}function AC(e){if(e===0)return!1;let t=Ls(e);if(e===1){if(!Lr(t,"OES_texture_float")||!Lr(t,"WEBGL_color_buffer_float"))return!1}else{if(Lr(t,"EXT_color_buffer_float"))return K5(t);let r="EXT_color_buffer_half_float";if(Lr(t,r)){let s=t.getExtension(r);return Ode(t,s)}return!1}return K5(t)}function K5(e){let t=H5(e),n=e.createTexture();e.bindTexture(e.TEXTURE_2D,n);let r=1,s=1;e.texImage2D(e.TEXTURE_2D,0,t.internalFormatFloat,r,s,0,t.textureFormatFloat,t.textureTypeFloat,null);let a=e.createFramebuffer();e.bindFramebuffer(e.FRAMEBUFFER,a),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,n,0);let o=e.checkFramebufferStatus(e.FRAMEBUFFER)===e.FRAMEBUFFER_COMPLETE;return e.bindTexture(e.TEXTURE_2D,null),e.bindFramebuffer(e.FRAMEBUFFER,null),e.deleteTexture(n),e.deleteFramebuffer(a),o}function Ode(e,t){let n=H5(e,t),r=e.createTexture();e.bindTexture(e.TEXTURE_2D,r);let s=1,a=1;e.texImage2D(e.TEXTURE_2D,0,n.internalFormatHalfFloat,s,a,0,n.textureFormatFloat,n.textureTypeHalfFloat,null);let o=e.createFramebuffer();e.bindFramebuffer(e.FRAMEBUFFER,o),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,r,0);let i=e.checkFramebufferStatus(e.FRAMEBUFFER)===e.FRAMEBUFFER_COMPLETE;return e.bindTexture(e.TEXTURE_2D,null),e.bindFramebuffer(e.FRAMEBUFFER,null),e.deleteTexture(r),e.deleteFramebuffer(o),i}function xC(e){return e!==2?!1:Ls(e).fenceSync!=null}function mu(e,t){Array.isArray(e)||(e=[e]),e.forEach(n=>{n!=null&&k.assert(n.dtype!=="complex64",()=>`${t} does not support complex64 tensors in the WebGL backend.`)})}var Pe=ae();Pe.registerFlag("HAS_WEBGL",()=>Pe.getNumber("WEBGL_VERSION")>0);Pe.registerFlag("WEBGL_VERSION",()=>q5(2)?2:q5(1)?1:0);Pe.registerFlag("WEBGL_CHECK_NUMERICAL_PROBLEMS",()=>!1);Pe.registerFlag("WEBGL_BUFFER_SUPPORTED",()=>Pe.get("WEBGL_VERSION")===2);Pe.registerFlag("WEBGL_CPU_FORWARD",()=>!0);Pe.registerFlag("WEBGL_FORCE_F16_TEXTURES",()=>!1);Pe.registerFlag("WEBGL_PACK",()=>Pe.getBool("HAS_WEBGL"));Pe.registerFlag("WEBGL_PACK_NORMALIZATION",()=>Pe.getBool("WEBGL_PACK"));Pe.registerFlag("WEBGL_PACK_CLIP",()=>Pe.getBool("WEBGL_PACK"));Pe.registerFlag("WEBGL_PACK_DEPTHWISECONV",()=>Pe.getBool("WEBGL_PACK"));Pe.registerFlag("WEBGL_PACK_BINARY_OPERATIONS",()=>Pe.getBool("WEBGL_PACK"));Pe.registerFlag("WEBGL_PACK_UNARY_OPERATIONS",()=>Pe.getBool("WEBGL_PACK"));Pe.registerFlag("WEBGL_PACK_ARRAY_OPERATIONS",()=>Pe.getBool("WEBGL_PACK"));Pe.registerFlag("WEBGL_PACK_IMAGE_OPERATIONS",()=>Pe.getBool("WEBGL_PACK"));Pe.registerFlag("WEBGL_PACK_REDUCE",()=>Pe.getBool("WEBGL_PACK"));Pe.registerFlag("WEBGL_LAZILY_UNPACK",()=>Pe.getBool("WEBGL_PACK"));Pe.registerFlag("WEBGL_CONV_IM2COL",()=>Pe.getBool("WEBGL_PACK"));Pe.registerFlag("WEBGL_MAX_TEXTURE_SIZE",()=>fC(Pe.getNumber("WEBGL_VERSION")));Pe.registerFlag("WEBGL_MAX_TEXTURES_IN_SHADER",()=>mC(Pe.getNumber("WEBGL_VERSION")));Pe.registerFlag("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION",()=>{let e=Pe.getNumber("WEBGL_VERSION");return e===0?0:gC(e)});Pe.registerFlag("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE",()=>Pe.getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")>0&&!yf.isMobile());Pe.registerFlag("WEBGL_RENDER_FLOAT32_CAPABLE",()=>yC(Pe.getNumber("WEBGL_VERSION")));Pe.registerFlag("WEBGL_RENDER_FLOAT32_ENABLED",()=>Pe.getBool("WEBGL_FORCE_F16_TEXTURES")?!1:Pe.getBool("WEBGL_RENDER_FLOAT32_CAPABLE"));Pe.registerFlag("WEBGL_DOWNLOAD_FLOAT_ENABLED",()=>AC(Pe.getNumber("WEBGL_VERSION")));Pe.registerFlag("WEBGL_FENCE_API_ENABLED",()=>xC(Pe.getNumber("WEBGL_VERSION")));Pe.registerFlag("WEBGL_SIZE_UPLOAD_UNIFORM",()=>Pe.getBool("WEBGL_RENDER_FLOAT32_ENABLED")?4:0);Pe.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}.`)});Pe.registerFlag("WEBGL_FLUSH_THRESHOLD",()=>yf.isMobile()&&Pe.getBool("IS_CHROME")?1:-1,e=>{if(e<0&&e!==-1)throw new Error(`WEBGL_FLUSH_THRESHOLD must be -1 (indicating never manual flush) or at least 0, but got ${e}.`)});Pe.registerFlag("CPU_HANDOFF_SIZE_THRESHOLD",()=>128);function Wn(){let e,t,n,r,s,a,o,i,l,u;return ae().getNumber("WEBGL_VERSION")===2?(e="#version 300 es",t="in",n="out",r="in",s="texture",a="outputColor",o="out vec4 outputColor;",i=`
|
|
bool isnan_custom(float val) {
|
|
return (val > 0.0 || val < 0.0) ? false : val != 0.0;
|
|
}
|
|
|
|
bvec4 isnan_custom(vec4 val) {
|
|
return bvec4(isnan_custom(val.x),
|
|
isnan_custom(val.y), isnan_custom(val.z), isnan_custom(val.w));
|
|
}
|
|
|
|
#define isnan(value) isnan_custom(value)
|
|
`,l="",u=`
|
|
#define round(value) newRound(value)
|
|
int newRound(float value) {
|
|
return int(floor(value + 0.5));
|
|
}
|
|
|
|
ivec4 newRound(vec4 value) {
|
|
return ivec4(floor(value + vec4(0.5)));
|
|
}
|
|
`):(e="",t="attribute",n="varying",r="varying",s="texture2D",a="gl_FragColor",o="",i=`
|
|
#define isnan(value) isnan_custom(value)
|
|
bool isnan_custom(float val) {
|
|
return (val > 0. || val < 1. || val == 0.) ? false : true;
|
|
}
|
|
bvec4 isnan_custom(vec4 val) {
|
|
return bvec4(isnan(val.x), isnan(val.y), isnan(val.z), isnan(val.w));
|
|
}
|
|
`,l=`
|
|
uniform float INFINITY;
|
|
|
|
bool isinf(float val) {
|
|
return abs(val) == INFINITY;
|
|
}
|
|
bvec4 isinf(vec4 val) {
|
|
return equal(abs(val), vec4(INFINITY));
|
|
}
|
|
`,u=`
|
|
int round(float value) {
|
|
return int(floor(value + 0.5));
|
|
}
|
|
|
|
ivec4 round(vec4 value) {
|
|
return ivec4(floor(value + vec4(0.5)));
|
|
}
|
|
`),{version:e,attribute:t,varyingVs:n,varyingFs:r,texture2D:s,output:a,defineOutput:o,defineSpecialNaN:i,defineSpecialInf:l,defineRound:u}}function Ai(e,t,n="index"){let r=k.computeStrides(t);return r.map((s,a)=>{let o=`int ${e[a]} = ${n} / ${s}`,i=a===r.length-1?`int ${e[a+1]} = ${n} - ${e[a]} * ${s}`:`index -= ${e[a]} * ${s}`;return`${o}; ${i};`}).join("")}function X5(e){let t=k.computeStrides(e).map(n=>n.toString());return`
|
|
int getFlatIndex(ivec3 coords) {
|
|
return coords.x * ${t[0]} + coords.y * ${t[1]} + coords.z;
|
|
}
|
|
`}var bC=`
|
|
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;
|
|
}
|
|
`,Pde=class{constructor(e){this.variableNames=["A"],this.packedInputs=!1,this.packedOutput=!0,this.outPackingScheme=sh.DENSE;let t=oh(e),n=Wn();this.outputShape=e,this.userCode=`
|
|
ivec3 outCoordsFromFlatIndex(int index) {
|
|
${Ai(["r","c","d"],e)}
|
|
return ivec3(r, c, d);
|
|
}
|
|
|
|
void main() {
|
|
ivec2 resTexRC = ivec2(resultUV.yx *
|
|
vec2(${t[0]}, ${t[1]}));
|
|
int index = 4 * (resTexRC.x * ${t[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);
|
|
}
|
|
|
|
${n.output} = result;
|
|
}
|
|
`}},zde=class{constructor(e){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outPackingScheme=sh.DENSE;let t=oh(e),n=Wn();this.outputShape=e,this.userCode=`
|
|
ivec3 outCoordsFromFlatIndex(int index) {
|
|
${Ai(["r","c","d"],e)}
|
|
return ivec3(r, c, d);
|
|
}
|
|
|
|
void main() {
|
|
ivec2 resTexRC = ivec2(resultUV.yx *
|
|
vec2(${t[0]}, ${t[1]}));
|
|
int index = 4 * (resTexRC.x * ${t[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));
|
|
}
|
|
|
|
${n.output} = result;
|
|
}
|
|
`}},Lde=class{constructor(e){this.variableNames=["A"],this.outTexUsage=zr.DOWNLOAD;let t=Wn();this.outputShape=e,this.userCode=`
|
|
${bC}
|
|
|
|
void main() {
|
|
float x = getAAtOutCoords();
|
|
${t.output} = encode_float(x);
|
|
}
|
|
`}},Bde=class{constructor(e){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!1,this.outTexUsage=zr.DOWNLOAD;let t=Wn();this.outputShape=e,this.userCode=`
|
|
${bC}
|
|
|
|
void main() {
|
|
ivec3 coords = getOutputCoords();
|
|
float x = getChannel(getAAtOutCoords(), vec2(coords.y, coords.z));
|
|
${t.output} = encode_float(x);
|
|
}
|
|
`}},Wde=class{constructor(e,t,n=!1){this.variableNames=["A"];let r=Wn(),[s,a]=t;this.outputShape=e;let o="result";n&&(o="floor(result * 255. + 0.5)"),this.userCode=`
|
|
${X5(e)}
|
|
|
|
void main() {
|
|
ivec3 coords = getOutputCoords();
|
|
|
|
int flatIndex = getFlatIndex(coords);
|
|
int offset = imod(flatIndex, 4);
|
|
|
|
flatIndex = idiv(flatIndex, 4, 1.);
|
|
|
|
int r = flatIndex / ${a};
|
|
int c = imod(flatIndex, ${a});
|
|
vec2 uv = (vec2(c, r) + halfCR) / vec2(${a}.0, ${s}.0);
|
|
vec4 values = ${r.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];
|
|
}
|
|
|
|
${r.output} = vec4(${o}, 0., 0., 0.);
|
|
}
|
|
`}},Vde=class{constructor(e,t,n=!1){this.variableNames=["A"],this.packedInputs=!1,this.packedOutput=!0;let r=Wn(),[s,a]=t;this.outputShape=e;let o="",i="result";n&&(i="floor(result * 255. + 0.5)");for(let l=0;l<=1;l++)for(let u=0;u<=1;u++){let c=l*2+u;o+=`
|
|
localCoords = coords;
|
|
if(localCoords[2] + ${u} < ${e[2]}) {
|
|
localCoords[2] += ${u};
|
|
if(localCoords[1] + ${l} < ${e[1]}) {
|
|
localCoords[1] += ${l};
|
|
|
|
flatIndex = getFlatIndex(localCoords);
|
|
offset = imod(flatIndex, 4);
|
|
|
|
flatIndex = idiv(flatIndex, 4, 1.);
|
|
|
|
r = flatIndex / ${a};
|
|
c = imod(flatIndex, ${a});
|
|
uv = (vec2(c, r) + halfCR) / vec2(${a}.0, ${s}.0);
|
|
values = ${r.texture2D}(A, uv);
|
|
|
|
if(offset == 0) {
|
|
result[${c}] = values[0];
|
|
} else if(offset == 1) {
|
|
result[${c}] = values[1];
|
|
} else if(offset == 2) {
|
|
result[${c}] = values[2];
|
|
} else {
|
|
result[${c}] = values[3];
|
|
}
|
|
}
|
|
}
|
|
`}this.userCode=`
|
|
${X5(e)}
|
|
|
|
void main() {
|
|
ivec3 coords = getOutputCoords();
|
|
|
|
vec4 result = vec4(0.);
|
|
int flatIndex, r, c, offset;
|
|
ivec3 localCoords;
|
|
vec2 uv;
|
|
vec4 values;
|
|
|
|
${o}
|
|
|
|
${r.output} = ${i};
|
|
}
|
|
`}},vC={};De(vC,{bindVertexProgramAttributeStreams:()=>$C,createBufferFromOutputTexture:()=>DC,createFloat16MatrixTexture:()=>TC,createFloat16PackedMatrixTexture:()=>EC,createFloat32MatrixTexture:()=>SC,createIndexBuffer:()=>IC,createPackedMatrixTexture:()=>CC,createUnsignedBytesMatrixTexture:()=>NC,createVertexBuffer:()=>kC,createVertexShader:()=>wC,downloadByteEncodedFloatMatrixFromOutputTexture:()=>MC,downloadFloat32MatrixFromBuffer:()=>FC,downloadMatrixFromPackedOutputTexture:()=>PC,downloadPackedMatrixFromBuffer:()=>OC,getInternalFormatForFloat16MatrixTexture:()=>Y5,getInternalFormatForFloat16PackedMatrixTexture:()=>eb,getInternalFormatForFloat32MatrixTexture:()=>Z5,getInternalFormatForPackedMatrixTexture:()=>Q5,getInternalFormatForUnsignedBytesMatrixTexture:()=>J5,uploadDenseMatrixToTexture:()=>_C,uploadPixelDataToTexture:()=>RC});function wC(e){let t=Wn(),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 JN(e,n)}function kC(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 nC(e,t)}function IC(e){let t=new Uint16Array([0,1,2,2,1,3]);return rC(e,t)}function ch(e,t,n,r,s,a){aC(t,n);let o=sC(e),i=e.TEXTURE_2D;return Ie(e,()=>e.bindTexture(i,o)),Ie(e,()=>e.texParameteri(i,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE)),Ie(e,()=>e.texParameteri(i,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE)),Ie(e,()=>e.texParameteri(i,e.TEXTURE_MIN_FILTER,e.NEAREST)),Ie(e,()=>e.texParameteri(i,e.TEXTURE_MAG_FILTER,e.NEAREST)),Ie(e,()=>e.texImage2D(i,0,r,t,n,0,s,a,null)),Ie(e,()=>e.bindTexture(e.TEXTURE_2D,null)),o}function Z5(e){return e.internalFormatFloat}function SC(e,t,n,r){let[s,a]=ah(t,n);return ch(e,s,a,Z5(r),r.textureFormatFloat,e.FLOAT)}function Y5(e){return e.internalFormatHalfFloat}function TC(e,t,n,r){let[s,a]=ah(t,n);return ch(e,s,a,Y5(r),r.textureFormatFloat,r.textureTypeHalfFloat)}function J5(e){return e.downloadTextureFormat}function NC(e,t,n,r){let[s,a]=ah(t,n);return ch(e,s,a,J5(r),e.RGBA,e.UNSIGNED_BYTE)}function Q5(e){return e.internalFormatPackedFloat}function CC(e,t,n,r){let[s,a]=fu(t,n);return ch(e,s,a,Q5(r),e.RGBA,e.FLOAT)}function eb(e){return e.internalFormatPackedHalfFloat}function EC(e,t,n,r){let[s,a]=fu(t,n);return ch(e,s,a,eb(r),e.RGBA,r.textureTypeHalfFloat)}function $C(e,t,n){let r=0,s=3*4,a=3*4+2*4;return Ie(e,()=>e.bindBuffer(e.ARRAY_BUFFER,n)),G5(e,t,"clipSpacePos",n,3,a,r)&&G5(e,t,"uv",n,2,a,s)}function _C(e,t,n,r,s,a){Ie(e,()=>e.bindTexture(e.TEXTURE_2D,t));let o,i,l;s instanceof Uint8Array?(o=new Uint8Array(n*r*4),i=e.UNSIGNED_BYTE,l=e.RGBA):(o=new Float32Array(n*r*4),i=e.FLOAT,l=a.internalFormatPackedFloat),o.set(s),Ie(e,()=>e.texImage2D(e.TEXTURE_2D,0,l,n,r,0,e.RGBA,i,o)),Ie(e,()=>e.bindTexture(e.TEXTURE_2D,null))}function RC(e,t,n){Ie(e,()=>e.bindTexture(e.TEXTURE_2D,t)),n.data instanceof Uint8Array?Ie(e,()=>e.texImage2D(e.TEXTURE_2D,0,e.RGBA,n.width,n.height,0,e.RGBA,e.UNSIGNED_BYTE,n.data)):Ie(e,()=>e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,n)),Ie(e,()=>e.bindTexture(e.TEXTURE_2D,null))}function DC(e,t,n,r){let s=e.createBuffer();Ie(e,()=>e.bindBuffer(e.PIXEL_PACK_BUFFER,s));let i=4*4*t*n;return Ie(e,()=>e.bufferData(e.PIXEL_PACK_BUFFER,i,e.STREAM_READ)),Ie(e,()=>e.readPixels(0,0,n,t,e.RGBA,e.FLOAT,0)),Ie(e,()=>e.bindBuffer(e.PIXEL_PACK_BUFFER,null)),s}function FC(e,t,n){let r=e,s=new Float32Array(n);return r.bindBuffer(r.PIXEL_PACK_BUFFER,t),r.getBufferSubData(r.PIXEL_PACK_BUFFER,0,s),r.bindBuffer(r.PIXEL_PACK_BUFFER,null),s}function MC(e,t,n,r){let[s,a]=ah(t,n),o=4,i=new Uint8Array(Ide(t*n,o));return Ie(e,()=>e.readPixels(0,0,s,a,r.downloadTextureFormat,e.UNSIGNED_BYTE,i)),new Float32Array(i.buffer)}function OC(e,t,n,r,s,a,o,i){let l=e,u=new Float32Array(Sde(a,o));return l.bindBuffer(l.PIXEL_PACK_BUFFER,t),l.getBufferSubData(l.PIXEL_PACK_BUFFER,0,u),l.bindBuffer(l.PIXEL_PACK_BUFFER,null),u}function PC(e,t,n){let r=new Float32Array(t*n*4);return Ie(e,()=>e.readPixels(0,0,n,t,e.RGBA,e.FLOAT,r)),r}var Bm=class{constructor(e){this.outputTexture=null,this.program=null,this.disposed=!1,this.vertexAttrsAreBound=!1,this.itemsToPoll=[];let t=ae().getNumber("WEBGL_VERSION");e!=null?(this.gl=e,Dm(t,e)):this.gl=Ls(t);let n="WEBGL_color_buffer_float",r="EXT_color_buffer_half_float";if(ae().getNumber("WEBGL_VERSION")===1){let s="OES_texture_float",a="OES_texture_half_float";if(this.textureFloatExtension=ih(this.gl,s),Lr(this.gl,a))this.textureHalfFloatExtension=ih(this.gl,a);else if(ae().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),Lr(this.gl,r))this.colorBufferHalfFloatExtension=ih(this.gl,r);else if(ae().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",Lr(this.gl,n))this.colorBufferFloatExtension=this.gl.getExtension(n);else if(Lr(this.gl,r))this.colorBufferHalfFloatExtension=this.gl.getExtension(r);else throw new Error("GL context does not support color renderable floats");this.vertexBuffer=kC(this.gl),this.indexBuffer=IC(this.gl),this.framebuffer=oC(this.gl),this.textureConfig=H5(this.gl,this.textureHalfFloatExtension)}get debug(){return ae().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;Ie(e,()=>e.finish()),Ie(e,()=>e.bindFramebuffer(e.FRAMEBUFFER,null)),Ie(e,()=>e.deleteFramebuffer(this.framebuffer)),Ie(e,()=>e.bindBuffer(e.ARRAY_BUFFER,null)),Ie(e,()=>e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,null)),Ie(e,()=>e.deleteBuffer(this.indexBuffer)),this.disposed=!0}createFloat32MatrixTexture(e,t){return this.throwIfDisposed(),SC(this.gl,e,t,this.textureConfig)}createFloat16MatrixTexture(e,t){return this.throwIfDisposed(),TC(this.gl,e,t,this.textureConfig)}createUnsignedBytesMatrixTexture(e,t){return this.throwIfDisposed(),NC(this.gl,e,t,this.textureConfig)}uploadPixelDataToTexture(e,t){this.throwIfDisposed(),RC(this.gl,e,t)}uploadDenseMatrixToTexture(e,t,n,r){this.throwIfDisposed(),_C(this.gl,e,t,n,r,this.textureConfig)}createFloat16PackedMatrixTexture(e,t){return this.throwIfDisposed(),EC(this.gl,e,t,this.textureConfig)}createPackedMatrixTexture(e,t){return this.throwIfDisposed(),CC(this.gl,e,t,this.textureConfig)}deleteMatrixTexture(e){this.throwIfDisposed(),this.outputTexture===e&&(j5(this.gl,this.framebuffer),this.outputTexture=null),Ie(this.gl,()=>this.gl.deleteTexture(e))}downloadByteEncodedFloatMatrixFromOutputTexture(e,t,n){return this.downloadMatrixDriver(e,()=>MC(this.gl,t,n,this.textureConfig))}downloadPackedMatrixFromBuffer(e,t,n,r,s,a){return OC(this.gl,e,t,n,r,s,a,this.textureConfig)}downloadFloat32MatrixFromBuffer(e,t){return FC(this.gl,e,t)}createBufferFromTexture(e,t,n){this.bindTextureToFrameBuffer(e);let r=DC(this.gl,t,n,this.textureConfig);return this.unbindTextureToFrameBuffer(),r}createAndWaitForFence(){let e=this.createFence(this.gl);return this.pollFence(e)}createFence(e){let t,n;if(ae().getBool("WEBGL_FENCE_API_ENABLED")){let r=e,s=r.fenceSync(r.SYNC_GPU_COMMANDS_COMPLETE,0);e.flush(),n=()=>{let a=r.clientWaitSync(s,0,0);return a===r.ALREADY_SIGNALED||a===r.CONDITION_SATISFIED},t=s}else ae().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")>0?(t=this.beginQuery(),this.endQuery(),n=()=>this.isQueryAvailable(t,ae().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION"))):n=()=>!0;return{query:t,isFencePassed:n}}downloadMatrixFromPackedTexture(e,t,n){return this.downloadMatrixDriver(e,()=>PC(this.gl,t,n))}createProgram(e){this.throwIfDisposed();let t=this.gl,n=QN(t,e);this.vertexShader==null&&(this.vertexShader=wC(t));let r=eC(t);return Ie(t,()=>t.attachShader(r,this.vertexShader)),Ie(t,()=>t.attachShader(r,n)),tC(t,r),this.debug&&Fm(t,r),this.vertexAttrsAreBound||(this.setProgram(r),this.vertexAttrsAreBound=$C(t,this.program,this.vertexBuffer)),r}deleteProgram(e){this.throwIfDisposed(),e===this.program&&(this.program=null),e!=null&&Ie(this.gl,()=>this.gl.deleteProgram(e))}setProgram(e){this.throwIfDisposed(),this.program=e,this.program!=null&&this.debug&&Fm(this.gl,this.program),Ie(this.gl,()=>this.gl.useProgram(e))}getUniformLocation(e,t,n=!0){return this.throwIfDisposed(),n?lC(this.gl,e,t):uC(this.gl,e,t)}getAttributeLocation(e,t){return this.throwIfDisposed(),Ie(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(),cC(this.gl,e,t,n)}setOutputMatrixTexture(e,t,n){this.setOutputMatrixTextureDriver(e,n,t)}setOutputPackedMatrixTexture(e,t,n){this.throwIfDisposed();let[r,s]=fu(t,n);this.setOutputMatrixTextureDriver(e,r,s)}setOutputMatrixWriteRegion(e,t,n,r){this.setOutputMatrixWriteRegionDriver(n,e,r,t)}setOutputPackedMatrixWriteRegion(e,t,n,r){throw new Error("setOutputPackedMatrixWriteRegion not implemented.")}debugValidate(){this.program!=null&&Fm(this.gl,this.program),lh(this.gl)}executeProgram(){this.throwIfDisposed(),this.throwIfNoProgram();let e=this.gl;this.debug&&this.debugValidate(),Ie(e,()=>e.drawElements(e.TRIANGLES,6,e.UNSIGNED_SHORT,0))}blockUntilAllProgramsCompleted(){this.throwIfDisposed(),Ie(this.gl,()=>this.gl.finish())}getQueryTimerExtension(){return this.disjointQueryTimerExtension==null&&(this.disjointQueryTimerExtension=ih(this.gl,ae().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(ae().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")===2){let n=this.gl,r=this.getQueryTimerExtensionWebGL2(),s=n.createQuery();return n.beginQuery(r.TIME_ELAPSED_EXT,s),s}let e=this.getQueryTimerExtensionWebGL1(),t=e.createQueryEXT();return e.beginQueryEXT(e.TIME_ELAPSED_EXT,t),t}endQuery(){if(ae().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 k.repeatedTry(()=>this.disposed||this.isQueryAvailable(e,ae().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION"))),this.getQueryTime(e,ae().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,r=this.getQueryTimerExtensionWebGL2(),s=n.getQueryParameter(e,n.QUERY_RESULT_AVAILABLE);return this.disjoint==null&&(this.disjoint=this.gl.getParameter(r.GPU_DISJOINT_EXT)),s&&!this.disjoint}else{let n=this.getQueryTimerExtensionWebGL1(),r=n.getQueryObjectEXT(e,n.QUERY_RESULT_AVAILABLE_EXT);return this.disjoint==null&&(this.disjoint=this.gl.getParameter(n.GPU_DISJOINT_EXT)),r&&!this.disjoint}}pollFence(e){return new Promise(t=>{this.addItemToPoll(()=>e.isFencePassed(),()=>t())})}pollItems(){let e=Ude(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)&&k.repeatedTry(()=>(this.pollItems(),this.itemsToPoll.length===0))}bindTextureToFrameBuffer(e){this.throwIfDisposed(),Mm(this.gl,e,this.framebuffer),this.debug&&lh(this.gl)}unbindTextureToFrameBuffer(){this.outputTexture!=null?(Mm(this.gl,this.outputTexture,this.framebuffer),this.debug&&lh(this.gl)):j5(this.gl,this.framebuffer)}downloadMatrixDriver(e,t){this.bindTextureToFrameBuffer(e);let n=t();return this.unbindTextureToFrameBuffer(),n}setOutputMatrixTextureDriver(e,t,n){this.throwIfDisposed();let r=this.gl;Mm(r,e,this.framebuffer),this.debug&&lh(r),this.outputTexture=e,Ie(r,()=>r.viewport(0,0,t,n)),Ie(r,()=>r.scissor(0,0,t,n))}setOutputMatrixWriteRegionDriver(e,t,n,r){this.throwIfDisposed(),Ie(this.gl,()=>this.gl.scissor(e,t,n,r))}throwIfDisposed(){if(this.disposed)throw new Error("Attempted to use disposed GPGPUContext.")}throwIfNoProgram(){if(this.program==null)throw new Error("No GPU program is currently set.")}};function Ude(e){let t=0;for(;t<e.length&&e[t]();++t);return t-1}var{getBroadcastDims:zC}=_;function Hde(e,t,n,r){let s=[];e.forEach(f=>{let m=k.sizeFromShape(f.shapeInfo.logicalShape);f.shapeInfo.isUniform?s.push(`uniform float ${f.name}${m>1?`[${m}]`:""};`):(s.push(`uniform sampler2D ${f.name};`),s.push(`uniform int offset${f.name};`))});let a=s.join(`
|
|
`),o=e.map(f=>Gde(f,t,r)).join(`
|
|
`),i=t.texShape,l=Wn(),u=Kde(l),c,d,h=Yde(l);return t.isPacked?(c=jde(t.logicalShape,i),d=Zde(l)):(c=qde(t.logicalShape,i),d=Xde(l)),r&&(h+=the),[h,u,d,a,c,o,n].join(`
|
|
`)}function gu(e){let t=e.shapeInfo.logicalShape;switch(t.length){case 0:return phe(e);case 1:return mhe(e);case 2:return yhe(e);case 3:return xhe(e);case 4:return vhe(e);case 5:return whe(e);case 6:return khe(e);default:throw new Error(`${t.length}-D input sampling is not yet supported`)}}function LC(e){switch(e.shapeInfo.logicalShape.length){case 0:return hhe(e);case 1:return fhe(e);case 2:return ghe(e);case 3:return Ahe(e);default:return bhe(e)}}function Gde(e,t,n=!1){let r="";n?r+=LC(e):r+=gu(e);let s=e.shapeInfo.logicalShape,a=t.logicalShape;return s.length<=a.length&&(n?r+=Ihe(e,t):r+=She(e,t)),r}function jde(e,t){switch(e.length){case 0:return BC();case 1:return nhe(e,t);case 2:return che(e,t);case 3:return she(e,t);default:return ohe(e,t)}}function qde(e,t){switch(e.length){case 0:return BC();case 1:return rhe(e,t);case 2:return dhe(e,t);case 3:return ahe(e,t);case 4:return ihe(e,t);case 5:return lhe(e,t);case 6:return uhe(e,t);default:throw new Error(`${e.length}-D output sampling is not yet supported`)}}function Kde(e){return`
|
|
float sampleTexture(sampler2D textureSampler, vec2 uv) {
|
|
return ${e.texture2D}(textureSampler, uv).r;
|
|
}
|
|
`}function Xde(e){return`
|
|
void setOutput(float val) {
|
|
${e.output} = vec4(val, 0, 0, 0);
|
|
}
|
|
`}function Zde(e){return`
|
|
void setOutput(vec4 val) {
|
|
${e.output} = val;
|
|
}
|
|
`}function Yde(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);
|
|
}
|
|
|
|
${Jde}
|
|
${Qde}
|
|
${ehe}
|
|
`}var Jde=`
|
|
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);
|
|
}
|
|
`,Qde=`
|
|
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);
|
|
}
|
|
`,ehe=`
|
|
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);
|
|
}
|
|
`,the=`
|
|
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 BC(){return`
|
|
int getOutputCoords() {
|
|
return 0;
|
|
}
|
|
`}function nhe(e,t){let n=[Math.ceil(t[0]/2),Math.ceil(t[1]/2)];return n[0]===1?`
|
|
int getOutputCoords() {
|
|
return 2 * int(resultUV.x * ${n[1]}.0);
|
|
}
|
|
`:n[1]===1?`
|
|
int getOutputCoords() {
|
|
return 2 * int(resultUV.y * ${n[0]}.0);
|
|
}
|
|
`:`
|
|
int getOutputCoords() {
|
|
ivec2 resTexRC = ivec2(resultUV.yx *
|
|
vec2(${n[0]}, ${n[1]}));
|
|
return 2 * (resTexRC.x * ${n[1]} + resTexRC.y);
|
|
}
|
|
`}function rhe(e,t){return t[0]===1?`
|
|
int getOutputCoords() {
|
|
return int(resultUV.x * ${t[1]}.0);
|
|
}
|
|
`:t[1]===1?`
|
|
int getOutputCoords() {
|
|
return int(resultUV.y * ${t[0]}.0);
|
|
}
|
|
`:`
|
|
int getOutputCoords() {
|
|
ivec2 resTexRC = ivec2(resultUV.yx *
|
|
vec2(${t[0]}, ${t[1]}));
|
|
return resTexRC.x * ${t[1]} + resTexRC.y;
|
|
}
|
|
`}function she(e,t){let n=[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(${n[0]}, ${n[1]}));
|
|
int index = resTexRC.x * ${n[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 ahe(e,t){let n=Ai(["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;
|
|
${n}
|
|
return ivec3(r, c, d);
|
|
}
|
|
`}function ohe(e,t){let n=[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),a=s,o="",i="b, r, c";for(let l=2;l<e.length-1;l++)a*=e[e.length-l-1],o=`
|
|
int b${l} = index / ${a};
|
|
index -= b${l} * ${a};
|
|
`+o,i=`b${l}, `+i;return`
|
|
ivec${e.length} getOutputCoords() {
|
|
ivec2 resTexRC = ivec2(resultUV.yx *
|
|
vec2(${n[0]}, ${n[1]}));
|
|
int index = resTexRC.x * ${n[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}(${i});
|
|
}
|
|
`}function ihe(e,t){let n=Ai(["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;
|
|
${n}
|
|
return ivec4(r, c, d, d2);
|
|
}
|
|
`}function lhe(e,t){let n=Ai(["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 uhe(e,t){let n=Ai(["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 che(e,t){let n=[Math.ceil(t[0]/2),Math.ceil(t[1]/2)];if(k.arraysEqual(e,t))return`
|
|
ivec2 getOutputCoords() {
|
|
return 2 * ivec2(resultUV.yx * vec2(${n[0]}, ${n[1]}));
|
|
}
|
|
`;let r=Math.ceil(e[1]/2);return`
|
|
ivec2 getOutputCoords() {
|
|
ivec2 resTexRC = ivec2(resultUV.yx *
|
|
vec2(${n[0]}, ${n[1]}));
|
|
|
|
int index = resTexRC.x * ${n[1]} + resTexRC.y;
|
|
int r = 2 * (index / ${r});
|
|
int c = imod(index, ${r}) * 2;
|
|
|
|
return ivec2(r, c);
|
|
}
|
|
`}function dhe(e,t){return k.arraysEqual(e,t)?`
|
|
ivec2 getOutputCoords() {
|
|
return ivec2(resultUV.yx * vec2(${t[0]}, ${t[1]}));
|
|
}
|
|
`:e[1]===1?`
|
|
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?`
|
|
ivec2 getOutputCoords() {
|
|
ivec2 resTexRC = ivec2(resultUV.yx *
|
|
vec2(${t[0]}, ${t[1]}));
|
|
int index = resTexRC.x * ${t[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;
|
|
int r = index / ${e[1]};
|
|
int c = index - r * ${e[1]};
|
|
return ivec2(r, c);
|
|
}
|
|
`}function xi(e){return`offset${e}`}function hhe(e){let t=e.name,n="get"+t.charAt(0).toUpperCase()+t.slice(1),r=Wn();return`
|
|
vec4 ${n}() {
|
|
return ${r.texture2D}(${t}, halfCR);
|
|
}
|
|
`}function phe(e){let t=e.name,n="get"+t.charAt(0).toUpperCase()+t.slice(1);if(e.shapeInfo.isUniform)return`float ${n}() {return ${t};}`;let[r,s]=e.shapeInfo.texShape;if(r===1&&s===1)return`
|
|
float ${n}() {
|
|
return sampleTexture(${t}, halfCR);
|
|
}
|
|
`;let[a,o]=e.shapeInfo.texShape,i=xi(t);return`
|
|
float ${n}() {
|
|
vec2 uv = uvFromFlat(${a}, ${o}, ${i});
|
|
return sampleTexture(${t}, uv);
|
|
}
|
|
`}function fhe(e){let t=e.name,n="get"+t.charAt(0).toUpperCase()+t.slice(1),r=e.shapeInfo.texShape,s=[Math.ceil(r[0]/2),Math.ceil(r[1]/2)],a=Wn();return`
|
|
vec4 ${n}(int index) {
|
|
vec2 uv = packedUVfrom1D(
|
|
${s[0]}, ${s[1]}, index);
|
|
return ${a.texture2D}(${t}, uv);
|
|
}
|
|
`}function mhe(e){let t=e.name,n="get"+t.charAt(0).toUpperCase()+t.slice(1);if(e.shapeInfo.isUniform)return`
|
|
float ${n}(int index) {
|
|
${yu(e)}
|
|
}
|
|
`;let r=e.shapeInfo.texShape,s=r[0],a=r[1];if(a===1&&s===1)return`
|
|
float ${n}(int index) {
|
|
return sampleTexture(${t}, halfCR);
|
|
}
|
|
`;let o=xi(t);return a===1?`
|
|
float ${n}(int index) {
|
|
vec2 uv = vec2(0.5, (float(index + ${o}) + 0.5) / ${s}.0);
|
|
return sampleTexture(${t}, uv);
|
|
}
|
|
`:s===1?`
|
|
float ${n}(int index) {
|
|
vec2 uv = vec2((float(index + ${o}) + 0.5) / ${a}.0, 0.5);
|
|
return sampleTexture(${t}, uv);
|
|
}
|
|
`:`
|
|
float ${n}(int index) {
|
|
vec2 uv = uvFromFlat(${s}, ${a}, index + ${o});
|
|
return sampleTexture(${t}, uv);
|
|
}
|
|
`}function ghe(e){let t=e.shapeInfo.logicalShape,n=e.name,r="get"+n.charAt(0).toUpperCase()+n.slice(1),s=e.shapeInfo.texShape,a=s[0],o=s[1],i=Wn();if(s!=null&&k.arraysEqual(t,s))return`
|
|
vec4 ${r}(int row, int col) {
|
|
vec2 uv = (vec2(col, row) + halfCR) / vec2(${o}.0, ${a}.0);
|
|
|
|
return ${i.texture2D}(${n}, uv);
|
|
}
|
|
`;let l=[Math.ceil(s[0]/2),Math.ceil(s[1]/2)],u=Math.ceil(t[1]/2);return`
|
|
vec4 ${r}(int row, int col) {
|
|
vec2 uv = packedUVfrom2D(${u}, ${l[0]}, ${l[1]}, row, col);
|
|
return ${i.texture2D}(${n}, uv);
|
|
}
|
|
`}function yhe(e){let t=e.shapeInfo.logicalShape,n=e.name,r="get"+n.charAt(0).toUpperCase()+n.slice(1),s=e.shapeInfo.texShape;if(s!=null&&k.arraysEqual(t,s)){let d=s[0],h=s[1];return`
|
|
float ${r}(int row, int col) {
|
|
vec2 uv = (vec2(col, row) + halfCR) / vec2(${h}.0, ${d}.0);
|
|
return sampleTexture(${n}, uv);
|
|
}
|
|
`}let{newShape:a,keptDims:o}=k.squeezeShape(t),i=a;if(i.length<t.length){let d=Au(e,i),h=["row","col"];return`
|
|
${gu(d)}
|
|
float ${r}(int row, int col) {
|
|
return ${r}(${xu(h,o)});
|
|
}
|
|
`}if(e.shapeInfo.isUniform)return`
|
|
float ${r}(int row, int col) {
|
|
int index = round(dot(vec2(row, col), vec2(${t[1]}, 1)));
|
|
${yu(e)}
|
|
}
|
|
`;let l=s[0],u=s[1],c=xi(n);return u===1?`
|
|
float ${r}(int row, int col) {
|
|
float index = dot(vec3(row, col, ${c}), vec3(${t[1]}, 1, 1));
|
|
vec2 uv = vec2(0.5, (index + 0.5) / ${l}.0);
|
|
return sampleTexture(${n}, uv);
|
|
}
|
|
`:l===1?`
|
|
float ${r}(int row, int col) {
|
|
float index = dot(vec3(row, col, ${c}), vec3(${t[1]}, 1, 1));
|
|
vec2 uv = vec2((index + 0.5) / ${u}.0, 0.5);
|
|
return sampleTexture(${n}, uv);
|
|
}
|
|
`:`
|
|
float ${r}(int row, int col) {
|
|
// Explicitly use integer operations as dot() only works on floats.
|
|
int index = row * ${t[1]} + col + ${c};
|
|
vec2 uv = uvFromFlat(${l}, ${u}, index);
|
|
return sampleTexture(${n}, uv);
|
|
}
|
|
`}function Ahe(e){let t=e.shapeInfo.logicalShape,n=e.name,r="get"+n.charAt(0).toUpperCase()+n.slice(1),s=e.shapeInfo.texShape,a=[Math.ceil(s[0]/2),Math.ceil(s[1]/2)];if(t[0]===1){let d=t.slice(1),h=[1,2],p=Au(e,d),f=["b","row","col"];return`
|
|
${LC(p)}
|
|
vec4 ${r}(int b, int row, int col) {
|
|
return ${r}(${xu(f,h)});
|
|
}
|
|
`}let o=a[0],i=a[1],l=Math.ceil(t[2]/2),u=l*Math.ceil(t[1]/2),c=Wn();return`
|
|
vec4 ${r}(int b, int row, int col) {
|
|
vec2 uv = packedUVfrom3D(
|
|
${o}, ${i}, ${u}, ${l}, b, row, col);
|
|
return ${c.texture2D}(${n}, uv);
|
|
}
|
|
`}function xhe(e){let t=e.shapeInfo.logicalShape,n=e.name,r="get"+n.charAt(0).toUpperCase()+n.slice(1),s=t[1]*t[2],a=t[2],{newShape:o,keptDims:i}=k.squeezeShape(t),l=o;if(l.length<t.length){let f=Au(e,l),m=["row","col","depth"];return`
|
|
${gu(f)}
|
|
float ${r}(int row, int col, int depth) {
|
|
return ${r}(${xu(m,i)});
|
|
}
|
|
`}if(e.shapeInfo.isUniform)return`
|
|
float ${r}(int row, int col, int depth) {
|
|
int index = round(dot(vec3(row, col, depth),
|
|
vec3(${s}, ${a}, 1)));
|
|
${yu(e)}
|
|
}
|
|
`;let u=e.shapeInfo.texShape,c=u[0],d=u[1],h=e.shapeInfo.flatOffset;if(d===s&&h==null)return`
|
|
float ${r}(int row, int col, int depth) {
|
|
float texR = float(row);
|
|
float texC = dot(vec2(col, depth), vec2(${a}, 1));
|
|
vec2 uv = (vec2(texC, texR) + halfCR) /
|
|
vec2(${d}.0, ${c}.0);
|
|
return sampleTexture(${n}, uv);
|
|
}
|
|
`;if(d===a&&h==null)return`
|
|
float ${r}(int row, int col, int depth) {
|
|
float texR = dot(vec2(row, col), vec2(${t[1]}, 1));
|
|
float texC = float(depth);
|
|
vec2 uv = (vec2(texC, texR) + halfCR) / vec2(${d}.0, ${c}.0);
|
|
return sampleTexture(${n}, uv);
|
|
}
|
|
`;let p=xi(n);return`
|
|
float ${r}(int row, int col, int depth) {
|
|
// Explicitly use integer operations as dot() only works on floats.
|
|
int index = row * ${s} + col * ${a} + depth + ${p};
|
|
vec2 uv = uvFromFlat(${c}, ${d}, index);
|
|
return sampleTexture(${n}, uv);
|
|
}
|
|
`}function bhe(e){let t=e.shapeInfo.logicalShape,n=t.length,r=e.name,s="get"+r.charAt(0).toUpperCase()+r.slice(1),a=e.shapeInfo.texShape,o=[Math.ceil(a[0]/2),Math.ceil(a[1]/2)],i=o[0],l=o[1],u=Math.ceil(t[n-1]/2),c=u*Math.ceil(t[n-2]/2),d="int b, int row, int col",h=`b * ${c} + (row / 2) * ${u} + (col / 2)`;for(let f=2;f<n-1;f++)d=`int b${f}, `+d,c*=t[n-f-1],h=`b${f} * ${c} + `+h;let p=Wn();return`
|
|
vec4 ${s}(${d}) {
|
|
int index = ${h};
|
|
int texR = index / ${l};
|
|
int texC = index - texR * ${l};
|
|
vec2 uv = (vec2(texC, texR) + halfCR) / vec2(${l}, ${i});
|
|
return ${p.texture2D}(${r}, uv);
|
|
}
|
|
`}function vhe(e){let t=e.shapeInfo.logicalShape,n=e.name,r="get"+n.charAt(0).toUpperCase()+n.slice(1),s=t[3],a=t[2]*s,o=t[1]*a,{newShape:i,keptDims:l}=k.squeezeShape(t);if(i.length<t.length){let f=Au(e,i),m=["row","col","depth","depth2"];return`
|
|
${gu(f)}
|
|
float ${r}(int row, int col, int depth, int depth2) {
|
|
return ${r}(${xu(m,l)});
|
|
}
|
|
`}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}, ${a}, ${s}, 1)));
|
|
${yu(e)}
|
|
}
|
|
`;let u=e.shapeInfo.flatOffset,c=e.shapeInfo.texShape,d=c[0],h=c[1];if(h===o&&u==null)return`
|
|
float ${r}(int row, int col, int depth, int depth2) {
|
|
float texR = float(row);
|
|
float texC =
|
|
dot(vec3(col, depth, depth2),
|
|
vec3(${a}, ${s}, 1));
|
|
vec2 uv = (vec2(texC, texR) + halfCR) /
|
|
vec2(${h}.0, ${d}.0);
|
|
return sampleTexture(${n}, uv);
|
|
}
|
|
`;if(h===s&&u==null)return`
|
|
float ${r}(int row, int col, int depth, int depth2) {
|
|
float texR = dot(vec3(row, col, depth),
|
|
vec3(${t[1]*t[2]}, ${t[2]}, 1));
|
|
float texC = float(depth2);
|
|
vec2 uv = (vec2(texC, texR) + halfCR) /
|
|
vec2(${h}.0, ${d}.0);
|
|
return sampleTexture(${n}, uv);
|
|
}
|
|
`;let p=xi(n);return`
|
|
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 * ${a} +
|
|
depth * ${s} + depth2;
|
|
vec2 uv = uvFromFlat(${d}, ${h}, index + ${p});
|
|
return sampleTexture(${n}, uv);
|
|
}
|
|
`}function whe(e){let t=e.shapeInfo.logicalShape,n=e.name,r="get"+n.charAt(0).toUpperCase()+n.slice(1),s=t[4],a=t[3]*s,o=t[2]*a,i=t[1]*o,{newShape:l,keptDims:u}=k.squeezeShape(t);if(l.length<t.length){let m=Au(e,l),g=["row","col","depth","depth2","depth3"];return`
|
|
${gu(m)}
|
|
float ${r}(int row, int col, int depth, int depth2, int depth3) {
|
|
return ${r}(${xu(g,u)});
|
|
}
|
|
`}if(e.shapeInfo.isUniform)return`
|
|
float ${r}(int row, int col, int depth, int depth2, int depth3) {
|
|
float index = dot(
|
|
vec4(row, col, depth, depth2),
|
|
vec4(${i}, ${o}, ${a}, ${s})) +
|
|
depth3;
|
|
${yu(e)}
|
|
}
|
|
`;let c=e.shapeInfo.flatOffset,d=e.shapeInfo.texShape,h=d[0],p=d[1];if(p===i&&c==null)return`
|
|
float ${r}(int row, int col, int depth, int depth2, int depth3) {
|
|
int texR = row;
|
|
float texC = dot(vec4(col, depth, depth2, depth3),
|
|
vec4(${o}, ${a}, ${s}, 1));
|
|
vec2 uv = (vec2(texC, texR) + halfCR) /
|
|
vec2(${p}.0, ${h}.0);
|
|
return sampleTexture(${n}, uv);
|
|
}
|
|
`;if(p===s&&c==null)return`
|
|
float ${r}(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(${p}.0, ${h}.0);
|
|
return sampleTexture(${n}, uv);
|
|
}
|
|
`;let f=xi(n);return`
|
|
float ${r}(int row, int col, int depth, int depth2, int depth3) {
|
|
// Explicitly use integer operations as dot() only works on floats.
|
|
int index = row * ${i} + col * ${o} + depth * ${a} +
|
|
depth2 * ${s} + depth3 + ${f};
|
|
vec2 uv = uvFromFlat(${h}, ${p}, index);
|
|
return sampleTexture(${n}, uv);
|
|
}
|
|
`}function khe(e){let t=e.shapeInfo.logicalShape,n=e.name,r="get"+n.charAt(0).toUpperCase()+n.slice(1),{newShape:s,keptDims:a}=k.squeezeShape(t);if(s.length<t.length){let g=Au(e,s),y=["row","col","depth","depth2","depth3","depth4"];return`
|
|
${gu(g)}
|
|
float ${r}(int row, int col, int depth,
|
|
int depth2, int depth3, int depth4) {
|
|
return ${r}(${xu(y,a)});
|
|
}
|
|
`}let o=t[5],i=t[4]*o,l=t[3]*i,u=t[2]*l,c=t[1]*u;if(e.shapeInfo.isUniform)return`
|
|
float ${r}(int row, int col, int depth,
|
|
int depth2, int depth3, int depth4) {
|
|
int index = round(dot(
|
|
vec4(row, col, depth, depth2),
|
|
vec4(${c}, ${u}, ${l}, ${i})) +
|
|
dot(
|
|
vec2(depth3, depth4),
|
|
vec2(${o}, 1)));
|
|
${yu(e)}
|
|
}
|
|
`;let d=e.shapeInfo.flatOffset,h=e.shapeInfo.texShape,p=h[0],f=h[1];if(f===c&&d==null)return`
|
|
float ${r}(int row, int col, int depth,
|
|
int depth2, int depth3, int depth4) {
|
|
int texR = row;
|
|
float texC = dot(vec4(col, depth, depth2, depth3),
|
|
vec4(${u}, ${l}, ${i}, ${o})) +
|
|
float(depth4);
|
|
vec2 uv = (vec2(texC, texR) + halfCR) /
|
|
vec2(${f}.0, ${p}.0);
|
|
return sampleTexture(${n}, uv);
|
|
}
|
|
`;if(f===o&&d==null)return`
|
|
float ${r}(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, ${p}.0);
|
|
return sampleTexture(${n}, uv);
|
|
}
|
|
`;let m=xi(n);return`
|
|
float ${r}(int row, int col, int depth,
|
|
int depth2, int depth3, int depth4) {
|
|
// Explicitly use integer operations as dot() only works on floats.
|
|
int index = row * ${c} + col * ${u} + depth * ${l} +
|
|
depth2 * ${i} + depth3 * ${o} + depth4 + ${m};
|
|
vec2 uv = uvFromFlat(${p}, ${f}, index);
|
|
return sampleTexture(${n}, uv);
|
|
}
|
|
`}function yu(e){let t=e.name,n=k.sizeFromShape(e.shapeInfo.logicalShape);return n<2?`return ${t};`:`
|
|
for (int i = 0; i < ${n}; i++) {
|
|
if (i == index) {
|
|
return ${t}[i];
|
|
}
|
|
}
|
|
`}function Ihe(e,t){let n=e.name,r=n.charAt(0).toUpperCase()+n.slice(1),s="get"+r+"AtOutCoords",a=e.shapeInfo.logicalShape.length,o=t.logicalShape.length,i=zC(e.shapeInfo.logicalShape,t.logicalShape),l=It(o),u=o-a,c,d=["x","y","z","w","u","v"];a===0?c="":o<2&&i.length>=1?c="coords = 0;":c=i.map(A=>`coords.${d[A+u]} = 0;`).join(`
|
|
`);let h="";o<2&&a>0?h="coords":h=e.shapeInfo.logicalShape.map((A,x)=>`coords.${d[x+u]}`).join(", ");let p="return outputValue;",m=k.sizeFromShape(e.shapeInfo.logicalShape)===1,y=k.sizeFromShape(t.logicalShape)===1;if(a===1&&!m&&!y)p=`
|
|
return vec4(outputValue.xy, outputValue.xy);
|
|
`;else if(m&&!y)o===1?p=`
|
|
return vec4(outputValue.x, outputValue.x, 0., 0.);
|
|
`:p=`
|
|
return vec4(outputValue.x);
|
|
`;else if(i.length){let A=a-2,x=a-1;i.indexOf(A)>-1&&i.indexOf(x)>-1?p="return vec4(outputValue.x);":i.indexOf(A)>-1?p="return vec4(outputValue.x, outputValue.y, outputValue.x, outputValue.y);":i.indexOf(x)>-1&&(p="return vec4(outputValue.xx, outputValue.zz);")}return`
|
|
vec4 ${s}() {
|
|
${l} coords = getOutputCoords();
|
|
${c}
|
|
vec4 outputValue = get${r}(${h});
|
|
${p}
|
|
}
|
|
`}function She(e,t){let n=e.name,r=n.charAt(0).toUpperCase()+n.slice(1),s="get"+r+"AtOutCoords",a=t.texShape,o=e.shapeInfo.texShape,i=e.shapeInfo.logicalShape.length,l=t.logicalShape.length;if(!e.shapeInfo.isUniform&&i===l&&e.shapeInfo.flatOffset==null&&k.arraysEqual(o,a))return`
|
|
float ${s}() {
|
|
return sampleTexture(${n}, resultUV);
|
|
}
|
|
`;let u=It(l),c=zC(e.shapeInfo.logicalShape,t.logicalShape),d=l-i,h,p=["x","y","z","w","u","v"];i===0?h="":l<2&&c.length>=1?h="coords = 0;":h=c.map(m=>`coords.${p[m+d]} = 0;`).join(`
|
|
`);let f="";return l<2&&i>0?f="coords":f=e.shapeInfo.logicalShape.map((m,g)=>`coords.${p[g+d]}`).join(", "),`
|
|
float ${s}() {
|
|
${u} coords = getOutputCoords();
|
|
${h}
|
|
return get${r}(${f});
|
|
}
|
|
`}function It(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 Au(e,t){let n=JSON.parse(JSON.stringify(e));return n.shapeInfo.logicalShape=t,n}function xu(e,t){return t.map(n=>e[n]).join(", ")}function The(e,t,n,r){let s=t.userCode,a=n.map((p,f)=>{let m={logicalShape:p.shape,texShape:p.isUniform?null:p.texData.texShape,isUniform:p.isUniform,isPacked:p.isUniform?!1:p.texData.isPacked,flatOffset:null};return p.texData!=null&&p.texData.slice!=null&&p.texData.slice.flatOffset>0&&(m.flatOffset=p.texData.slice.flatOffset),{name:t.variableNames[f],shapeInfo:m}}),o=a.map(p=>p.shapeInfo),i={logicalShape:r.shape,texShape:r.texData.texShape,isUniform:!1,isPacked:r.texData.isPacked,flatOffset:null},l=Hde(a,i,s,t.packedInputs),u=e.createProgram(l),c=null,d=e.getUniformLocation(u,"NAN",!1);ae().getNumber("WEBGL_VERSION")===1&&(c=e.getUniformLocation(u,"INFINITY",!1));let h={};for(let p=0;p<t.variableNames.length;p++){let f=t.variableNames[p],m=!1;h[f]=e.getUniformLocation(u,f,m),h[`offset${f}`]=e.getUniformLocation(u,`offset${f}`,m)}return{program:t,source:l,webGLProgram:u,uniformLocations:h,inShapeInfos:o,outShapeInfo:i,infLoc:c,nanLoc:d}}function WC(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,r)=>{let s=n.logicalShape,a=t[r],o=a.shape;if(!k.arraysEqual(s,o))throw Error(`Binary was compiled with different shapes than the current args. Shapes ${s} and ${o} must match`);if(n.isUniform&&a.isUniform)return;let i=n.texShape,l=a.isUniform?null:a.texData.texShape;if(!k.arraysEqual(i,l))throw Error(`Binary was compiled with different texture shapes than the current args. Shape ${i} and ${l} must match`)})}function Nhe(e,t,n,r,s){WC(t.inShapeInfos,n),WC([t.outShapeInfo],[r]);let a=r.texData.texture,o=r.texData.texShape;r.texData.isPacked?e.setOutputPackedMatrixTexture(a,o[0],o[1]):e.setOutputMatrixTexture(a,o[0],o[1]),e.setProgram(t.webGLProgram),ae().getNumber("WEBGL_VERSION")===1&&t.infLoc!==null&&e.gl.uniform1f(t.infLoc,Infinity),t.nanLoc!==null&&e.gl.uniform1f(t.nanLoc,NaN),n.forEach((i,l)=>{let u=t.program.variableNames[l],c=t.uniformLocations[u],d=t.uniformLocations[`offset${u}`];if(c!=null){if(i.isUniform){if(k.sizeFromShape(i.shape)<2)e.gl.uniform1f(c,i.uniformValues[0]);else{let h=i.uniformValues;h instanceof Float32Array||(h=new Float32Array(h)),e.gl.uniform1fv(c,h)}return}i.texData.slice!=null&&d!=null&&e.gl.uniform1i(d,i.texData.slice.flatOffset),e.setInputMatrixTexture(i.texData.texture,c,l)}}),s!=null&&s(e,t.webGLProgram),e.executeProgram()}function Che(e,t,n){let r="";t.concat(n).forEach(o=>{let i=o.texData!=null&&o.texData.slice!=null&&o.texData.slice.flatOffset>0,l=o.isUniform?"uniform":o.texData.texShape;r+=`${o.shape}_${l}_${i}`});let s=e.userCode,a=e.constructor.name;return a+="_"+r+"_"+s,a}var VC={};De(VC,{addImpl:()=>GC,bincountImpl:()=>Rhe,bincountReduceImpl:()=>Dhe,ceilImpl:()=>jC,concatImpl:()=>qC,equalImpl:()=>KC,expImpl:()=>XC,expm1Impl:()=>ZC,floorImpl:()=>YC,gatherNdImpl:()=>Fhe,gatherV2Impl:()=>Mhe,greaterEqualImpl:()=>QC,greaterImpl:()=>JC,lessEqualImpl:()=>tE,lessImpl:()=>eE,linSpaceImpl:()=>Ohe,logImpl:()=>nE,maxImpl:()=>Phe,maximumImpl:()=>rE,minimumImpl:()=>sE,multiplyImpl:()=>sb,negImpl:()=>Lhe,notEqualImpl:()=>aE,prodImpl:()=>Whe,rangeImpl:()=>oE,rsqrtImpl:()=>iE,simpleAbsImpl:()=>Ehe,sliceImpl:()=>ab,sparseFillEmptyRowsImpl:()=>Vhe,sparseReshapeImpl:()=>Uhe,sparseSegmentReductionImpl:()=>Hhe,squaredDifferenceImpl:()=>lE,stridedSliceImpl:()=>Ghe,stringNGramsImpl:()=>qhe,stringSplitImpl:()=>Xhe,stringToHashBucketFastImpl:()=>Zhe,subImpl:()=>uE,tileImpl:()=>Jhe,topKImpl:()=>Qhe,transposeImpl:()=>Bhe,uniqueImpl:()=>epe});function UC(e,t){Array.isArray(e)||(e=[e]),e.forEach(n=>{n!=null&&k.assert(n.dtype!=="complex64",()=>`${t} does not support complex64 tensors in the CPU backend.`)})}function Ehe(e){let t=new Float32Array(e.length);for(let n=0;n<e.length;++n)t[n]=Math.abs(e[n]);return t}function Br(e){return(t,n,r,s,a)=>{let o=_.assertAndGetBroadcastShape(t,n),i=o.length,l=k.computeStrides(o),u=k.sizeFromShape(o),c=k.getTypedArrayFromDType(a,u),d=t.length,h=n.length,p=k.computeStrides(t),f=k.computeStrides(n),m=_.getBroadcastDims(t,o),g=_.getBroadcastDims(n,o);if(m.length+g.length===0)for(let y=0;y<c.length;++y)c[y]=e(r[y%r.length],s[y%s.length]);else for(let y=0;y<c.length;++y){let A=k.indexToLoc(y,i,l),x=A.slice(-d);m.forEach(I=>x[I]=0);let b=k.locToIndex(x,d,p),v=A.slice(-h);g.forEach(I=>v[I]=0);let w=k.locToIndex(v,h,f);c[y]=e(r[b],s[w])}return[c,o]}}function tb(e){let{inputs:t,backend:n}=e,{real:r,imag:s}=t,a=n.data.get(r.dataId).values,o=n.data.get(s.dataId).values,i=n.makeTensorInfo(r.shape,"complex64"),l=n.data.get(i.dataId);return l.complexTensorInfos={real:n.makeTensorInfo(r.shape,"float32",a),imag:n.makeTensorInfo(s.shape,"float32",o)},i}function nb(e,t,n="float32"){if(n==="complex64"){let s=nb(e,t,"float32"),a=nb(e,t,"float32");return tb({inputs:{real:s,imag:a},backend:e})}let r=k.makeZerosTypedArray(k.sizeFromShape(t),n);return e.makeTensorInfo(t,n,r)}function HC(e){let{inputs:t,backend:n}=e,{x:r}=t;return n.incRef(r.dataId),{dataId:r.dataId,shape:r.shape,dtype:r.dtype}}function $he(e){let{inputs:t,backend:n}=e,{input:r}=t,s=n.data.get(r.dataId).complexTensorInfos.real,a=n.data.get(s.dataId).values;return n.makeTensorInfo(s.shape,s.dtype,a)}function Wm(e){let{inputs:t,backend:n,attrs:r}=e,{x:s}=t,{dtype:a}=r;if(a==="complex64"){if(s.dtype==="complex64")return HC({inputs:{x:s},backend:n});let o=nb(n,s.shape,s.dtype),i=Wm({inputs:{x:s},backend:n,attrs:{dtype:"float32"}}),l=tb({inputs:{real:i,imag:o},backend:n});return n.disposeIntermediateTensorInfo(o),n.disposeIntermediateTensorInfo(i),l}if(s.dtype==="complex64"){let o=$he({inputs:{input:s},backend:n}),i=Wm({inputs:{x:o},backend:n,attrs:{dtype:a}});return n.disposeIntermediateTensorInfo(o),i}if(!k.hasEncodingLoss(s.dtype,a)){let o=HC({inputs:{x:s},backend:n});return{dataId:o.dataId,shape:o.shape,dtype:a}}if(a==="int32"){let o=n.data.get(s.dataId).values,i=Int32Array.from(o);return n.makeTensorInfo(s.shape,"int32",i)}if(a==="bool"){let o=n.data.get(s.dataId).values,i=k.toTypedArray([0],s.dtype),[l,u]=Br((c,d)=>c!==d?1:0)(s.shape,[],o,i,"bool");return n.makeTensorInfo(u,"bool",l)}throw new Error(`Error in Cast: failed to cast ${s.dtype} to ${a}`)}function Jr(e,t,n,r){return n==null?({inputs:s,backend:a})=>{let{a:o,b:i}=s,l=a;UC([o,i],e);let u=l.data.get(o.dataId).values,c=l.data.get(i.dataId).values,d=o.dtype==="string"?_.fromUint8ToStringArray(u):u,h=o.dtype==="string"?_.fromUint8ToStringArray(c):c,p=r||o.dtype,[f,m]=t(o.shape,i.shape,d,h,p);return l.makeTensorInfo(m,p,f)}:({inputs:s,backend:a})=>{let{a:o,b:i}=s,l=a;if(o.dtype==="complex64"||i.dtype==="complex64"){let u=Wm({inputs:{x:o},backend:l,attrs:{dtype:"complex64"}}),c=l.data.get(u.dataId),d=c.complexTensorInfos.real,h=c.complexTensorInfos.imag,p=l.data.get(d.dataId).values,f=l.data.get(h.dataId).values,m=Wm({inputs:{x:i},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,w,I]=n(o.shape,i.shape,p,f,x,b),T=l.makeTensorInfo(I,"float32",v),C=l.makeTensorInfo(I,"float32",w),M=tb({inputs:{real:T,imag:C},backend:l});return l.disposeIntermediateTensorInfo(u),l.disposeIntermediateTensorInfo(m),l.disposeIntermediateTensorInfo(T),l.disposeIntermediateTensorInfo(C),M}else{let u=l.data.get(o.dataId).values,c=l.data.get(i.dataId).values,d=r||o.dtype,[h,p]=t(o.shape,i.shape,u,c,d);return l.makeTensorInfo(p,d,h)}}}function rb(e){return(t,n,r,s,a,o)=>{let i=_.assertAndGetBroadcastShape(t,n),l=k.sizeFromShape(i),u=i.length,c=k.computeStrides(i),d=k.getTypedArrayFromDType("float32",l),h=k.getTypedArrayFromDType("float32",l),p=_.getBroadcastDims(t,i),f=_.getBroadcastDims(n,i),m=_.mergeRealAndImagArrays(r,s),g=_.mergeRealAndImagArrays(a,o),y=t.length,A=k.computeStrides(t),x=n.length,b=k.computeStrides(n);if(p.length+f.length===0)for(let v=0;v<d.length;v++){let w=v%m.length,I=v%g.length,T=e(m[w*2],m[w*2+1],g[I*2],g[I*2+1]);d[v]=T.real,h[v]=T.imag}else for(let v=0;v<d.length;v++){let w=k.indexToLoc(v,u,c),I=w.slice(-y);p.forEach(R=>I[R]=0);let T=k.locToIndex(I,y,A),C=w.slice(-x);f.forEach(R=>C[R]=0);let M=k.locToIndex(C,x,b),$=e(m[T*2],m[T*2+1],g[M*2],g[M*2+1]);d[v]=$.real,h[v]=$.imag}return[d,h,i]}}var GC=Br((e,t)=>e+t),_he=rb((e,t,n,r)=>({real:e+n,imag:t+r})),Wwe=Jr(Fa,GC,_he);function Rhe(e,t,n,r,s){let a=k.sizeFromShape(r),o=k.makeZerosTypedArray(s,n);for(let i=0;i<e.length;i++){let l=e[i];if(l<0)throw new Error("Input x must be non-negative!");l>=s||(a>0?o[l]+=t[i]:o[l]+=1)}return o}function Dhe(e,t,n,r=!1){let s=e.shape[0],a=e.shape[1],o=Le([s,n],t.dtype);for(let i=0;i<s;i++)for(let l=0;l<a;l++){let u=e.get(i,l);if(u<0)throw new Error("Input x must be non-negative!");u>=n||(r?o.set(1,i,u):t.size>0?o.set(o.get(i,u)+t.get(i,l),i,u):o.set(o.get(i,u)+1,i,u))}return o}function bu(e){return(t,n,r)=>{let s=k.getTypedArrayFromDType(n,t.length);for(let a=0;a<t.length;++a)s[a]=e(t[a],r);return s}}function vu(e,t,n){return({inputs:r,attrs:s,backend:a})=>{let{x:o}=r;if(UC(o,e),o.dtype==="string"||n==="string")throw new Error("unaryKernelFunc does not support string input/output");let i=a,l=i.data.get(o.dataId).values,u=n||o.dtype,c=t(l,u,s);return i.makeTensorInfo(o.shape,u,c)}}var jC=bu(e=>Math.ceil(e)),Vwe=vu(No,jC);function qC(e,t,n,r){let s=k.getArrayFromDType(n,k.sizeFromShape(t));if(r&&n!=="string"){let a=0;e.forEach(o=>{let i=k.sizeFromShape(o.shape);s.set(o.vals,a),a+=i})}else{let a=0;e.forEach(o=>{let i=n==="string"?_.fromUint8ToStringArray(o.vals):o.vals,l=0;for(let u=0;u<o.shape[0];++u){let c=u*t[1]+a;for(let d=0;d<o.shape[1];++d)s[c+d]=i[l++]}a+=o.shape[1]})}return s}var KC=Br((e,t)=>e===t?1:0),Uwe=Jr(il,KC,null,"bool"),XC=bu(e=>Math.exp(e)),Hwe=vu(Eo,XC),ZC=bu(e=>Math.expm1(e)),Gwe=vu(ll,ZC),YC=bu(e=>Math.floor(e)),jwe=vu($o,YC);function Fhe(e,t,n,r,s,a,o,i,l){let u=Le([r,a],n);for(let c=0;c<r;c++){let d=[],h=0;for(let p=0;p<s;p++){let f=e[c*s+p];h+=f*o[p],d.push(f)}if(h<0||h>=l/a)throw new Error(`Invalid indices: ${d} does not index into ${i}`);for(let p=0;p<a;p++)u.values[c*a+p]=t.get(...t.indexToLoc(h*a+p))}return u}function Mhe(e,t,n){let r=Le(n,e.dtype);for(let s=0;s<r.size;++s){let o=r.indexToLoc(s).slice(),i=o[0],l=o[2],u=t.locToIndex([i,l]);o[2]=t.values[u];let c=e.locToIndex(o);r.values[s]=e.values[c]}return r}var JC=Br((e,t)=>e>t?1:0),qwe=Jr(dl,JC,null,"bool"),QC=Br((e,t)=>e>=t?1:0),Kwe=Jr(_o,QC,null,"bool"),eE=Br((e,t)=>e<t?1:0),Xwe=Jr(fl,eE,null,"bool"),tE=Br((e,t)=>e<=t?1:0),Zwe=Jr(ml,tE,null,"bool");function Ohe(e,t,n){let r=(t-e)/(n-1),s=k.makeZerosTypedArray(n,"float32");s[0]=e;for(let a=1;a<s.length;a++)s[a]=s[a-1]+r;return s}var nE=bu(e=>Math.log(e)),Ywe=vu(Ro,nE);function Phe(e,t,n,r){let s=k.getTypedArrayFromDType(r,k.sizeFromShape(n));for(let a=0;a<s.length;++a){let o=a*t,i=e[o];for(let l=0;l<t;++l){let u=e[o+l];(Number.isNaN(u)||u>i)&&(i=u)}s[a]=i}return s}var rE=Br((e,t)=>Math.max(e,t)),Jwe=Jr(Do,rE),sE=Br((e,t)=>Math.min(e,t)),Qwe=Jr(Fo,sE),sb=Br((e,t)=>e*t),zhe=rb((e,t,n,r)=>({real:e*n-t*r,imag:e*r+t*n})),e7e=Jr(Mo,sb,zhe);function Lhe(e,t,n){let r=k.createScalarValue(-1,n);return sb([],t,r,e,n)}var aE=Br((e,t)=>e!==t?1:0),t7e=Jr(vl,aE,null,"bool");function Bhe(e,t,n,r,s){let a=t.length,o=k.sizeFromShape(t),i=k.computeStrides(t),l=k.computeStrides(s),u=k.getTypedArrayFromDType(n,k.sizeFromShape(s));for(let c=0;c<o;++c){let d=k.indexToLoc(c,a,i),h=new Array(d.length);for(let f=0;f<h.length;f++)h[f]=d[r[f]];let p=k.locToIndex(h,a,l);u[p]=e[c]}return u}function Whe(e,t,n,r){let[s,a]=_.computeOutAndReduceShapes(e,r),o=qr(t,"int32"),i=k.makeZerosTypedArray(k.sizeFromShape(s),o),l=k.sizeFromShape(a);for(let u=0;u<i.length;++u){let c=u*l,d=1;for(let h=0;h<l;++h)d*=n[c+h];i[u]=d}return{outVals:i,outShape:s,outDtype:o}}function oE(e,t,n,r){let s=e===t,a=e<t&&n<0,o=t<e&&n>1;if(s||a||o)return k.makeZerosTypedArray(0,r);let i=Math.abs(Math.ceil((t-e)/n)),l=k.makeZerosTypedArray(i,r);t<e&&n===1&&(n=-1),l[0]=e;for(let u=1;u<l.length;u++)l[u]=l[u-1]+n;return l}var iE=bu(e=>1/Math.sqrt(e)),n7e=vu(Oo,iE);function ab(e,t,n,r,s){let a=En.isSliceContinous(r,t,n),o=k.sizeFromShape(n),i=k.computeStrides(r);if(a){let d=En.computeFlatOffset(t,i);return s==="string"?e.slice(d,d+o):e.subarray(d,d+o)}let l=s==="string"?_.fromUint8ToStringArray(e):e,u=Le(r,s,l),c=Le(n,s);for(let d=0;d<c.size;++d){let h=c.indexToLoc(d),p=h.map((f,m)=>f+t[m]);c.set(u.get(...p),...h)}return s==="string"?_.fromStringArrayToUint8(c.values):c.values}function Vhe(e,t,n,r,s,a,o){let i=t[0],l=a[0],u=new Array(l),c=new Array(i),d=t[1];if(l===0){if(i!==0)throw new Error(`Received SparseTensor with denseShape[0] = 0 but
|
|
indices.shape[0] = ${i}`);let g=k.getArrayFromDType(n,0),y=k.getArrayFromDType(s,0);return[g,[0,d],y,u,c]}let h=!0,p=0,f=new Array(l).fill(0);for(let g=0;g<i;++g){let y=e[g*d];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],h=h&&y>=p,p=y}let m=!0;for(let g=0;g<l;++g){let y=f[g]===0;u[g]=y,m=m&&!y,f[g]=Math.max(f[g],1),g>0&&(f[g]+=f[g-1])}if(m&&h){let g=e,y=r;for(let A=0;A<i;++A)c[A]=A;return[g,[i,d],y,u,c]}else{let g=f[l-1],y=k.getArrayFromDType(n,g*d),A=k.getArrayFromDType(s,g),x=new Array(l).fill(0);for(let b=0;b<i;++b){let v=e[b*d],w=x[v],I=(v===0?0:f[v-1])+w;x[v]++;for(let T=0;T<d;++T)y[I*d+T]=e[b*d+T];A[I]=r[b],c[b]=I}for(let b=0;b<l;++b)if(x[b]===0){let w=b===0?0:f[b-1];y[w*d+0]=b;for(let I=1;I<d;++I)y[w*d+I]=0;A[w]=o}return[y,[g,d],A,u,c]}}function Uhe(e,t,n,r,s){let a=k.sizeFromShape(r),o=t[0],i=s.length,l=[],u=1,c=-1;for(let g=0;g<i;++g){let y=s[g];if(y===-1){if(c!==-1)throw new Error(`only one output dimension may be -1, not both ${c} and ${g}`);c=g,l.push(1)}else{if(y<0)throw new Error(`size ${g} must be non-negative, not ${y}`);u*=y,l.push(y)}}if(c!==-1){if(u<=0)throw new Error("reshape cannot infer the missing input size for an empty tensor unless all specified input sizes are non-zero");let g=Math.trunc(a/u);if(u*g!==a)throw new Error(`Input to reshape is a SparseTensor with ${a}
|
|
dense values, but the requested shape requires a multiple of ${u}. inputShape=${r} outputShape= ${l}`);l[c]=g}let d=k.sizeFromShape(l);if(d!==a)throw new Error(`Input to reshape is a tensor with ${a} dense values, but the requested shape has ${d}. inputShape=${r} outputShape=${l}`);let h=r.length,p=[];if(h>0){p[h-1]=1;for(let g=h-2;g>=0;--g)p[g]=p[g+1]*r[g+1]}let f=[];if(i>0){f[i-1]=1;for(let g=i-2;g>=0;--g)f[g]=f[g+1]*l[g+1]}let m=k.getArrayFromDType(n,o*i);for(let g=0;g<o;++g){let y=0;for(let A=0;A<h;++A)y+=e[g*h+A]*p[A];for(let A=0;A<i;++A)m[g*i+A]=Math.trunc(y/f[A]),y%=f[A]}return[m,[o,i],l]}function Hhe(e,t,n,r,s,a=!1,o=0){let i=r.length;if(i!==s.length)throw new Error("segmentIds and indices should have same size.");let l=[t[0],e.length/t[0]],u=l[1],d=i>0?s[i-1]+1:0;if(d<0)throw new Error("segment ids must be >= 0");let h=t.slice();h[0]=d;let p=h.reduce((x,b)=>x*b,1),f=k.getArrayFromDType(n,p);if(i===0)return d>0&&f.fill(o),[f,h];if(d<=0)throw new Error("segment ids must be >= 0");let m=0,g=1,y=0,A=s[m];for(;;){let x=0;if(g<i){if(x=s[g],A===x){++g;continue}if(A>=x)throw new Error("segment ids are not increasing")}if(A<0||A>=d)throw new Error(`Segment id ${A} out of range [0, ${d}), possibly because segmentIds input is not sorted.`);A>y&&f.fill(o,y*u,A*u);for(let b=m;b<g;++b){let v=r[b];if(v<0||v>=l[0])throw new Error(`Bad: indices[${b}] == ${r[b]} out of range [0, ${l[0]})`);for(let w=0;w<u;w++)f[A*u+w]+=e[v*u+w]}if(a)for(let b=0;b<u;b++)f[A*u+b]/=g-m;if(m=g,++g,y=A+1,A=x,g>i)break}return y<d&&f.fill(o,y*u,d*u),[f,h]}var lE=Br((e,t)=>{let n=e-t;return n*n}),r7e=Jr(Po,lE);function Ghe(e,t,n,r){let s=Le(e,t.dtype);for(let a=0;a<s.size;a++){let o=s.indexToLoc(a),i=new Array(o.length);for(let l=0;l<i.length;l++)i[l]=o[l]*n[l]+r[l];s.set(t.get(...i),...o)}return s}var jhe=class{constructor(e,t,n,r,s,a){this.separator=k.encodeString(e),this.nGramWidths=t,this.leftPad=k.encodeString(n),this.rightPad=k.encodeString(r),this.padWidth=s,this.preserveShort=a}getPadWidth(e){return Math.min(this.padWidth<0?e-1:this.padWidth,e-1)}getNumNGrams(e,t){let n=this.getPadWidth(t);return Math.max(0,e+2*n-t+1)}createNGrams(e,t,n,r,s,a){for(let o=0;o<s;++o){let i=this.getPadWidth(a),l=Math.max(0,i-o),u=Math.max(0,i-(s-(o+1))),c=a-(l+u),d=t+(l>0?0:o-i),h=0;h+=l*this.leftPad.length;for(let y=0;y<c;++y)h+=e[d+y].length;h+=u*this.rightPad.length,h+=(l+u+c-1)*this.separator.length,n[r+o]=new Uint8Array(h);let f=n[r+o],m=0,g=y=>y.forEach(A=>f[m++]=A);for(let y=0;y<l;++y)g(this.leftPad),g(this.separator);for(let y=0;y<c-1;++y)g(e[d+y]),g(this.separator);if(c>0){g(e[d+c-1]);for(let y=0;y<u;++y)g(this.separator),g(this.rightPad)}else{for(let y=0;y<u-1;++y)g(this.rightPad),g(this.separator);g(this.rightPad)}}}compute(e,t){let n=e.length,r=t.length;if(r>0){let i=t[0];if(i!==0)throw new Error(`First split value must be 0, got ${i}`);for(let l=1;l<r;++l){let u=t[l]>=i;if(u=u&&t[l]<=n,!u)throw new Error(`Invalid split value ${t[l]}, must be in [${i}, ${n}]`);i=t[l]}if(i!==n)throw new Error(`Last split value must be data size. Expected ${n}, got ${i}`)}let s=r-1,a=k.getArrayFromDType("int32",r);if(n===0||r===0){let i=new Array(n);for(let l=0;l<=s;++l)a[l]=0;return[i,a]}a[0]=0;for(let i=1;i<=s;++i){let l=t[i]-t[i-1],u=0;this.nGramWidths.forEach(c=>{u+=this.getNumNGrams(l,c)}),this.preserveShort&&l>0&&u===0&&(u=1),a[i]=a[i-1]+u}let o=new Array(a[s]);for(let i=0;i<s;++i){let l=t[i],u=a[i];if(this.nGramWidths.forEach(c=>{let d=t[i+1]-t[i],h=this.getNumNGrams(d,c);this.createNGrams(e,l,o,u,h,c),u+=h}),this.preserveShort&&u===a[i]){let c=t[i+1]-t[i];if(c===0)continue;let d=c+2*this.padWidth,h=1;this.createNGrams(e,l,o,u,h,d)}}return[o,a]}};function qhe(e,t,n,r,s,a,o,i){return new jhe(n,r,s,a,o,i).compute(e,t)}function Khe(e,t,n){if(!e.length)return[];if(t.length===0){let a=new Array(e.length);for(let o=0;o<e.length;++o)a[o]=e.subarray(o,o+1);return a}if(t.length===1){let a=t[0],o=[],i=e.indexOf(a);for(;i!==-1;){let l=e.subarray(0,i);(!n||l.length!==0)&&o.push(l),e=e.subarray(i+1),i=e.indexOf(a)}return(!n||e.length!==0)&&o.push(e),o}let r=[],s=0;for(let a=0;a<e.length+1;a++)if(a===e.length||t.indexOf(e[a])!==-1){let o=e.subarray(s,a);(!n||o.length!==0)&&r.push(o),s=a+1}return r}function Xhe(e,t,n){let r=e.length,s=[],a=0,o=0,i=new Array(r);for(let h=0;h<r;++h){let p=Khe(e[h],t,n),f=p.length;i[h]=f,a+=f,o=Math.max(o,f),s.push(...p)}let l=k.getArrayFromDType("int32",a*2),u=new Array(a),c=[r,o],d=0;for(let h=0;h<r;++h)for(let p=0;p<i[h];++p)l[d*2]=h,l[d*2+1]=p,u[d]=s[d],++d;return[l,u,c]}function Zhe(e,t){let n=k.getArrayFromDType("int32",e.length);for(let r=0;r<e.length;++r)n[r]=k.fingerPrint64(e[r]).modulo(t).getLowBitsUnsigned();return n}var uE=Br((e,t)=>e-t),Yhe=rb((e,t,n,r)=>({real:e-n,imag:t-r})),s7e=Jr(zo,uE,Yhe);function Jhe(e,t){let n=new Array(e.rank);for(let s=0;s<n.length;s++)n[s]=e.shape[s]*t[s];let r=Le(n,e.dtype);for(let s=0;s<r.values.length;++s){let a=r.indexToLoc(s),o=new Array(e.rank);for(let l=0;l<o.length;l++)o[l]=a[l]%e.shape[l];let i=e.locToIndex(o);r.values[s]=e.values[i]}return r}function Qhe(e,t,n,r,s){let a=t[t.length-1],[o,i]=[e.length/a,a],l=k.getTypedArrayFromDType(n,o*r),u=k.getTypedArrayFromDType("int32",o*r);for(let d=0;d<o;d++){let h=d*i,p=e.subarray(h,h+i),f=[];for(let A=0;A<p.length;A++)f.push({value:p[A],index:A});f.sort((A,x)=>x.value-A.value);let m=d*r,g=l.subarray(m,m+r),y=u.subarray(m,m+r);for(let A=0;A<r;A++)g[A]=f[A].value,y[A]=f[A].index}let c=t.slice();return c[c.length-1]=r,[Le(c,n,l),Le(c,"int32",u)]}function epe(e,t,n,r){let s=k.parseAxisParam(t,n)[0],a=[1,n[0],1];for(let f=0;f<s;f++)a[0]*=n[f];a[1]=n[s];for(let f=s+1;f<n.length;f++)a[2]*=n[f];let o={},i=new Int32Array(n[s]),l=new Qt(a,r,e),u=[],c=a[0]===1&&a[2]===1;for(let f=0;f<n[s];f++){let m;if(c)m=e[f].toString();else{let g=[];for(let y=0;y<a[0];y++)for(let A=0;A<a[2];A++)g.push(l.get(y,f,A));m=g.join(",")}if(o[m]!==void 0)i[f]=o[m];else{let g=Object.keys(o).length;o[m]=g,i[f]=g,u.push(f)}}let d=a.slice();d[1]=Object.keys(o).length;let h=new Qt(d,r);u.forEach((f,m)=>{for(let g=0;g<a[0];g++)for(let y=0;y<a[2];y++)h.set(l.get(g,f,y),g,m,y)});let p=n.slice();return p[s]=d[1],{outputValues:h.values,outputShape:p,indices:i}}var{addImpl:tpe,bincountImpl:cE,bincountReduceImpl:npe,ceilImpl:rpe,concatImpl:spe,equalImpl:ape,expImpl:ope,expm1Impl:ipe,floorImpl:lpe,gatherNdImpl:upe,gatherV2Impl:cpe,greaterImpl:dpe,greaterEqualImpl:hpe,lessImpl:ppe,lessEqualImpl:fpe,linSpaceImpl:mpe,logImpl:gpe,maxImpl:ype,maximumImpl:Ape,minimumImpl:xpe,multiplyImpl:bpe,negImpl:vpe,notEqualImpl:wpe,prodImpl:kpe,rangeImpl:Ipe,rsqrtImpl:Spe,simpleAbsImpl:dE,sliceImpl:Tpe,sparseFillEmptyRowsImpl:Npe,sparseReshapeImpl:Cpe,sparseSegmentReductionImpl:hE,stridedSliceImpl:Epe,stringNGramsImpl:$pe,stringSplitImpl:_pe,stringToHashBucketFastImpl:Rpe,subImpl:Dpe,tileImpl:Fpe,topKImpl:Mpe,transposeImpl:ob,uniqueImpl:Ope}=VC;function pE(e,t){return["x","y","z","w","u","v"].slice(0,t).map(n=>`${e}.${n}`)}function Vn(e,t){return t===1?[e]:pE(e,t)}function Ppe(e,t){if(e===1)return"rc";let n="";for(let r=0;r<e;r++)n+=t[r],r<e-1&&(n+=",");return n}var zpe=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=Vn("rc",t),r=It(t),s=Bpe(t,e,n),a=Wpe(t,e[e.length-1],e[e.length-2],n),o=Vpe(e,n);this.userCode=`
|
|
void main() {
|
|
${r} rc = getOutputCoords();
|
|
|
|
if(${s}) {
|
|
setOutput(vec4(0));
|
|
} else {
|
|
${a}
|
|
|
|
setOutput(vec4(${o}));
|
|
}
|
|
}
|
|
`}}};function Lpe(e,t){let n=[];for(let r=0;r<=1;r++)for(let s=0;s<=1;s++){let a=`${r===0?"r":"rp1"}, ${s===0?"c":"cp1"}`;for(let o=2;o<e;o++)a=`${t[t.length-1-o]},`+a;n.push(a)}return n}function Bpe(e,t,n){if(e===1)return`rc > ${t[0]}`;let r="";for(let s=e-2;s<e;s++)r+=`${n[s]} >= ${t[s]}`,s<e-1&&(r+="||");return r}function Wpe(e,t,n,r){if(e===1)return"";let s=r.slice(-2);return`
|
|
int r = ${s[0]};
|
|
int c = ${s[1]};
|
|
int rp1 = r + 1;
|
|
int cp1 = c + 1;
|
|
|
|
bool cEdge = cp1 >= ${t};
|
|
bool rEdge = rp1 >= ${n};
|
|
`}function Vpe(e,t){let n=e.length,r=Lpe(n,t);return n===1?`getA(rc),
|
|
rc + 1 >= ${e[0]} ? 0. : getA(rc + 1),
|
|
0, 0`:`getA(${r[0]}),
|
|
cEdge ? 0. : getA(${r[1]}),
|
|
rEdge ? 0. : getA(${r[2]}),
|
|
rEdge || cEdge ? 0. : getA(${r[3]})`}var fE=class{constructor(e,t){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=e;let n="";for(let r=0;r<4;r++){let s="thisRC = rc;";r%2==1&&(s+="thisRC.z += 1;"),r>1&&(s+="thisRC.y += 1;"),n+=`
|
|
${s}
|
|
${r>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[${r}] =
|
|
getChannel(getA(inputRC.x, inputRC.y, inputRC.z), inputRCInnerDims);
|
|
${r>0?"}":""}
|
|
`}this.userCode=`
|
|
${Upe(t)}
|
|
${X5(e)}
|
|
|
|
void main() {
|
|
ivec3 rc = getOutputCoords();
|
|
|
|
vec4 result = vec4(0.);
|
|
|
|
ivec3 thisRC;
|
|
int rows = ${e[1]};
|
|
int cols = ${e[2]};
|
|
|
|
${n}
|
|
|
|
setOutput(result);
|
|
}
|
|
`}};function Upe(e){return`
|
|
ivec3 inputCoordsFromReshapedOutCoords(int index) {
|
|
${Ai(["r","c","d"],e)}
|
|
return ivec3(r, c, d);
|
|
}
|
|
`}var Hpe=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 r=gE(t,n),s=yE(e,r,n);s in this.freeTextures||(this.freeTextures[s]=[]),s in this.usedTextures||(this.usedTextures[s]=[]);let a=mE(e,r,this.gpgpu.gl,this.gpgpu.textureConfig,n);if(this.freeTextures[s].length>0){this.numFreeTextures--,this.numUsedTextures++,this._numBytesFree-=a,this.log();let i=this.freeTextures[s].shift();return this.usedTextures[s].push(i),i}let o;return r===Tn.PACKED_2X2_FLOAT32?o=this.gpgpu.createPackedMatrixTexture(e[0],e[1]):r===Tn.PACKED_2X2_FLOAT16?o=this.gpgpu.createFloat16PackedMatrixTexture(e[0],e[1]):r===Tn.UNPACKED_FLOAT32?o=this.gpgpu.createFloat32MatrixTexture(e[0],e[1]):r===Tn.UNPACKED_FLOAT16?o=this.gpgpu.createFloat16MatrixTexture(e[0],e[1]):r===Tn.PACKED_4X1_UNSIGNED_BYTE&&(o=this.gpgpu.createUnsignedBytesMatrixTexture(e[0],e[1])),this.usedTextures[s].push(o),this.numUsedTextures++,this._numBytesAllocated+=a,this.log(),o}releaseTexture(e,t,n,r){if(this.freeTextures==null)return;let s=gE(n,r),a=yE(t,s,r);a in this.freeTextures||(this.freeTextures[a]=[]);let o=mE(t,s,this.gpgpu.gl,this.gpgpu.textureConfig,r),i=ae().get("WEBGL_DELETE_TEXTURE_THRESHOLD");i!==-1&&this._numBytesAllocated>i?(this.gpgpu.deleteMatrixTexture(e),this._numBytesAllocated-=o):(this.freeTextures[a].push(e),this.numFreeTextures++,this._numBytesFree+=o),this.numUsedTextures--;let l=this.usedTextures[a],u=l.indexOf(e);if(u<0)throw new Error("Cannot release a texture that was never provided by this texture manager");l.splice(u,1),this.log()}log(){if(!this.logEnabled)return;let e=this.numFreeTextures+this.numUsedTextures;console.log("Free/Used",`${this.numFreeTextures} / ${this.numUsedTextures}`,`(${e})`);let t=this._numBytesFree/this._numBytesAllocated;console.log(`Bytes allocated: ${this._numBytesAllocated}`),console.log(`Bytes unused: ${this._numBytesFree} (${Math.round(100*t)}%)`)}get numBytesAllocated(){return this._numBytesAllocated}get numBytesFree(){return this._numBytesFree}getNumUsedTextures(){return this.numUsedTextures}getNumFreeTextures(){return this.numFreeTextures}dispose(){if(this.freeTextures!=null){for(let e in this.freeTextures)this.freeTextures[e].forEach(t=>{this.gpgpu.deleteMatrixTexture(t)});for(let e in this.usedTextures)this.usedTextures[e].forEach(t=>{this.gpgpu.deleteMatrixTexture(t)});this.freeTextures=null,this.usedTextures=null,this.numUsedTextures=0,this.numFreeTextures=0,this._numBytesAllocated=0,this._numBytesFree=0}}};function Gpe(e,t){let n=e;if(t===n.R32F)return 4;if(t===n.R16F)return 2;if(t===n.RGBA32F)return 16;if(t===e.RGBA)return 16;if(t===n.RGBA16F)return 8;throw new Error(`Unknown internal format ${t}`)}function mE(e,t,n,r,s){let a=jpe(t,r),o;if(s){let[l,u]=fu(e[0],e[1]);o=l*u}else{let[l,u]=ah(e[0],e[1]);o=l*u}let i=Gpe(n,a);return o*i}function jpe(e,t){switch(e){case Tn.PACKED_2X2_FLOAT32:return Q5(t);case Tn.PACKED_2X2_FLOAT16:return eb(t);case Tn.UNPACKED_FLOAT32:return Z5(t);case Tn.UNPACKED_FLOAT16:return Y5(t);case Tn.PACKED_4X1_UNSIGNED_BYTE:return J5(t);default:throw new Error(`Unknown physical texture type ${e}`)}}function qpe(e){return ae().getBool("WEBGL_RENDER_FLOAT32_ENABLED")?e?Tn.PACKED_2X2_FLOAT32:Tn.UNPACKED_FLOAT32:e?Tn.PACKED_2X2_FLOAT16:Tn.UNPACKED_FLOAT16}function gE(e,t){if(e===zr.UPLOAD)return Tn.PACKED_2X2_FLOAT32;if(e===zr.RENDER||e==null)return qpe(t);if(e===zr.DOWNLOAD||e===zr.PIXELS)return Tn.PACKED_4X1_UNSIGNED_BYTE;throw new Error(`Unknown logical texture type ${e}`)}function yE(e,t,n){return`${e[0]}_${e[1]}_${t}_${n}`}var Qa=class{constructor(e,t){this.variableNames=["A"],this.outputShape=e,this.userCode=`
|
|
float unaryOperation(float x) {
|
|
${t}
|
|
}
|
|
|
|
void main() {
|
|
float x = getAAtOutCoords();
|
|
float y = unaryOperation(x);
|
|
|
|
setOutput(y);
|
|
}
|
|
`}},ys="if (isnan(x)) return x;",Kpe="return x;",AE="return abs(x);",Xpe="return (x >= 0.0) ? x : (exp(x) - 1.0);",Zpe=ys+`
|
|
return (x < 0.0) ? 0.0 : x;
|
|
`,Ype=ys+`
|
|
return (x < 0.0) ? 0.0 : min(6.0, x);
|
|
`,Vm="return x;",Jpe="return 1.0 / (1.0 + exp(-1.0 * x));",Qpe="return x;",efe=`
|
|
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;
|
|
`,tfe=`
|
|
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;
|
|
`,nfe=`
|
|
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;
|
|
`,rfe="return 1.0 / (1.0 + exp(-1.0 * x));",wu=class{constructor(e,t){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=e,this.userCode=`
|
|
vec4 unaryOperation(vec4 x) {
|
|
${t}
|
|
}
|
|
|
|
void main() {
|
|
vec4 x = getAAtOutCoords();
|
|
vec4 y = unaryOperation(x);
|
|
|
|
setOutput(y);
|
|
}
|
|
`}},sfe=class{constructor(e){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!1,this.outputShape=e;let t=e.length,n=Vn("rc",t),r=It(t),s=Ppe(t,n),a=n.slice(-2),o=t<=1?"rc":`vec2(${a.join(",")})`;this.userCode=`
|
|
void main() {
|
|
${r} rc = getOutputCoords();
|
|
vec4 packedInput = getA(${s});
|
|
|
|
setOutput(getChannel(packedInput, ${o}));
|
|
}
|
|
`}},afe=ca.whereImpl,ofe=1e-7,ife=1e-4,Um={};function lfe(e){return e in Um||(Um[e]={}),Um[e]}var ufe=ae().getNumber("CPU_HANDOFF_SIZE_THRESHOLD"),cfe=600;function dfe(){return ae().global.screen==null?1024:ae().global.screen.height*ae().global.screen.width*window.devicePixelRatio*cfe/1024/1024}var xE=class extends Bp{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,!ae().getBool("HAS_WEBGL"))throw new Error("WebGL is not supported on this device");if(e==null){let t=Ls(ae().getNumber("WEBGL_VERSION"));this.binaryCache=lfe(ae().getNumber("WEBGL_VERSION")),this.gpgpu=new Bm(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 Hpe(this.gpgpu),this.numMBBeforeWarning=dfe(),this.texData=new fy(this,za())}nextDataId(){return xE.nextDataId++}numDataIds(){return this.texData.numDataIds()-this.pendingDeletes}write(e,t,n){if((ae().getBool("WEBGL_CHECK_NUMERICAL_PROBLEMS")||ae().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 r={id:this.nextDataId()};return this.texData.set(r,{shape:t,dtype:n,values:e,usage:zr.UPLOAD,refCount:1}),r}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,r,s){if(ae().getBool("DEBUG")&&this.checkNumericalProblems(t),r==="complex64")throw new Error("Cannot write to a complex64 dtype. Please use tf.complex(real, imag).");this.texData.set(e,{shape:n,dtype:r,values:t,usage:zr.UPLOAD,refCount:s})}disposeIntermediateTensorInfo(e){this.disposeData(e.dataId)}readSync(e){let t=this.texData.get(e),{values:n,dtype:r,complexTensorInfos:s,slice:a,shape:o,isPacked:i}=t;if(a!=null){let d;i?d=new wu(o,Vm):d=new Qa(o,Vm);let h=this.runWebGLProgram(d,[{dataId:e,shape:o,dtype:r}],r),p=this.readSync(h.dataId);return this.disposeIntermediateTensorInfo(h),p}if(n!=null)return this.convertAndCacheOnCPU(e);if(r==="string")return n;let l=this.activeTimers!=null,u;l&&(u=k.now());let c;if(r==="complex64"){let d=this.readSync(s.real.dataId),h=this.readSync(s.imag.dataId);c=_.mergeRealAndImagArrays(d,h)}else c=this.getValuesFromTexture(e);return l&&(this.downloadWaitMs+=k.now()-u),this.convertAndCacheOnCPU(e,c)}async read(e){if(this.pendingRead.has(e)){let p=this.pendingRead.get(e);return new Promise(f=>p.push(f))}let t=this.texData.get(e),{values:n,shape:r,slice:s,dtype:a,complexTensorInfos:o,isPacked:i}=t;if(s!=null){let p;i?p=new wu(r,Vm):p=new Qa(r,Vm);let f=this.runWebGLProgram(p,[{dataId:e,shape:r,dtype:a}],a),m=this.read(f.dataId);return this.disposeIntermediateTensorInfo(f),m}if(n!=null)return this.convertAndCacheOnCPU(e);if(!ae().getBool("WEBGL_DOWNLOAD_FLOAT_ENABLED")&&ae().getNumber("WEBGL_VERSION")===2)throw new Error("tensor.data() with WEBGL_DOWNLOAD_FLOAT_ENABLED=false and WEBGL_VERSION=2 not yet supported.");let l=null,u;if(a!=="complex64"&&ae().get("WEBGL_BUFFER_SUPPORTED")){u=this.decode(e);let p=this.texData.get(u.dataId);l=this.gpgpu.createBufferFromTexture(p.texture,...oh(r))}this.pendingRead.set(e,[]),a!=="complex64"&&await this.gpgpu.createAndWaitForFence();let c;if(a==="complex64"){let p=await Promise.all([this.read(o.real.dataId),this.read(o.imag.dataId)]),f=p[0],m=p[1];c=_.mergeRealAndImagArrays(f,m)}else if(l==null)c=this.getValuesFromTexture(e);else{let p=k.sizeFromShape(r);c=this.gpgpu.downloadFloat32MatrixFromBuffer(l,p)}u!=null&&this.disposeIntermediateTensorInfo(u);let d=this.convertAndCacheOnCPU(e,c),h=this.pendingRead.get(e);return this.pendingRead.delete(e),h.forEach(p=>p(d)),this.pendingDisposal.has(e)&&(this.pendingDisposal.delete(e),this.disposeData(e)&&za().removeDataId(e,this),this.pendingDeletes--),d}bufferSync(e){let t=this.readSync(e.dataId),n=t;if(e.dtype==="string")try{n=t.map(r=>k.decodeString(r))}catch(r){throw new Error("Failed to decode encoded string bytes into utf-8")}return Le(e.shape,e.dtype,n)}checkNumericalProblems(e){if(e!=null)for(let t=0;t<e.length;t++){let n=e[t];if(!ZN(n))throw ae().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:r}=this.texData.get(e),s=k.sizeFromShape(t);if(ae().getBool("WEBGL_DOWNLOAD_FLOAT_ENABLED")){let d=this.decode(e),h=this.texData.get(d.dataId),p=this.gpgpu.downloadMatrixFromPackedTexture(h.texture,...oh(t)).subarray(0,s);return this.disposeIntermediateTensorInfo(d),p}let a=ae().getBool("WEBGL_PACK")&&r===!0,o=a?Om(t):t,i=a?new Bde(o):new Lde(o),l=this.runWebGLProgram(i,[{shape:o,dtype:n,dataId:e}],"float32"),u=this.texData.get(l.dataId),c=this.gpgpu.downloadByteEncodedFloatMatrixFromOutputTexture(u.texture,u.texShape[0],u.texShape[1]).subarray(0,s);return this.disposeIntermediateTensorInfo(l),c}timerAvailable(){return ae().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE")>0}async time(e){let t=this.activeTimers,n=[],r=!1;this.programTimersStack==null?(this.programTimersStack=n,r=!0):this.activeTimers.push(n),this.activeTimers=n,e();let s=k.flatten(this.activeTimers.map(i=>i.query)).filter(i=>i!=null),a=k.flatten(this.activeTimers.map(i=>i.name)).filter(i=>i!=null);this.activeTimers=t,r&&(this.programTimersStack=null);let o={uploadWaitMs:this.uploadWaitMs,downloadWaitMs:this.downloadWaitMs,kernelMs:null,wallMs:null};if(ae().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE")>0){let i=await Promise.all(s);o.kernelMs=k.sum(i),o.getExtraProfileInfo=()=>i.map((l,u)=>({name:a[u],ms:l})).map(l=>`${l.name}: ${l.ms}`).join(", ")}else o.kernelMs={error:"WebGL query timers are not supported in this environment."};return this.uploadWaitMs=0,this.downloadWaitMs=0,o}memory(){return{unreliable:!1,numBytesInGPU:this.numBytesInGPU,numBytesInGPUAllocated:this.textureManager.numBytesAllocated,numBytesInGPUFree:this.textureManager.numBytesFree}}startTimer(){return ae().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE")>0?this.gpgpu.beginQuery():{startMs:k.now(),endMs:null}}endTimer(e){return ae().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE")>0?(this.gpgpu.endQuery(),e):(e.endMs=k.now(),e)}async getQueryTime(e){if(ae().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:r,usage:s,isPacked:a,slice:o}=this.texData.get(e),i=o&&o.origDataId||e,l=this.dataRefCount.get(i);l>1?this.dataRefCount.set(i,l-1):(this.dataRefCount.delete(i),t!=null&&(this.numBytesInGPU-=this.computeBytes(r,n),this.textureManager.releaseTexture(t,r,s,a)));let u=this.texData.get(e);u.texture=null,u.texShape=null,u.isPacked=!1,u.slice=null}getTexture(e){return this.uploadToGPU(e),this.texData.get(e).texture}getDataInfo(e){return this.texData.get(e)}shouldExecuteOnCPU(e,t=ufe){return ae().getBool("WEBGL_CPU_FORWARD")&&e.every(n=>this.texData.get(n.dataId).texture==null&&k.sizeFromShape(n.shape)<t)}getGPGPUContext(){return this.gpgpu}where(e){_.warn("tf.where() in webgl locks the UI thread. Call tf.whereAsync() instead");let t=e.dataSync();return afe(e.shape,t)}packedUnaryOp(e,t,n){let r=new wu(e.shape,t),s=this.compileAndRun(r,[e],n);return za().makeTensorFromDataId(s.dataId,s.shape,s.dtype)}abs(e){if(this.shouldExecuteOnCPU([e])&&e.dtype!=="complex64"){let r=dE(this.texData.get(e.dataId).values);return this.makeOutput(e.shape,e.dtype,r)}if(ae().getBool("WEBGL_PACK_UNARY_OPERATIONS"))return this.packedUnaryOp(e,AE,e.dtype);let t=new Qa(e.shape,AE),n=this.compileAndRun(t,[e]);return za().makeTensorFromDataId(n.dataId,n.shape,n.dtype)}makeTensorInfo(e,t,n){let r;if(t==="string"&&n!=null&&n.length>0&&k.isString(n[0])){let s=n.map(a=>k.encodeString(a));r=this.write(s,e,t)}else r=this.write(n,e,t);return this.texData.get(r).usage=null,{dataId:r,shape:e,dtype:t}}makeOutput(e,t,n){let{dataId:r}=this.makeTensorInfo(e,t,n);return za().makeTensorFromDataId(r,e,t,this)}unpackTensor(e){let t=new sfe(e.shape);return this.runWebGLProgram(t,[e],e.dtype)}packTensor(e){let t=new zpe(e.shape),n=!0;return this.runWebGLProgram(t,[e],e.dtype,null,n)}packedReshape(e,t){let n=[gi(e.shape),...yi(e.shape)],r={dtype:e.dtype,shape:n,dataId:e.dataId},s=[gi(t),...yi(t)],a=new fE(s,n),o=!0,i=this.runWebGLProgram(a,[r],e.dtype,null,o);return{dataId:i.dataId,shape:t,dtype:i.dtype}}decode(e){let t=this.texData.get(e),{isPacked:n,shape:r,dtype:s}=t,a=Om(r),o;n?o=new zde(a):o=new Pde(a);let i=!0,l=this.runWebGLProgram(o,[{shape:a,dtype:s,dataId:e}],s,null,i);return{dtype:s,shape:r,dataId:l.dataId}}runWebGLProgram(e,t,n,r,s=!1){let a=this.makeTensorInfo(e.outputShape,n),o=this.texData.get(a.dataId);if(e.packedOutput&&(o.isPacked=!0),e.outPackingScheme===sh.DENSE){let m=oh(e.outputShape);o.texShape=m.map(g=>g*2)}if(e.outTexUsage!=null&&(o.usage=e.outTexUsage),k.sizeFromShape(a.shape)===0)return o.values=k.getTypedArrayFromDType(a.dtype,0),a;let i=[],l=t.map(m=>{if(m.dtype==="complex64")throw new Error("GPGPUProgram does not support complex64 input. For complex64 dtypes, please separate the program into real and imaginary parts.");let g=this.texData.get(m.dataId);if(g.texture==null){if(!e.packedInputs&&k.sizeFromShape(m.shape)<=ae().getNumber("WEBGL_SIZE_UPLOAD_UNIFORM"))return{shape:m.shape,texData:null,isUniform:!0,uniformValues:g.values};e.packedInputs&&(g.isPacked=!0,g.shape=m.shape)}else if(!!g.isPacked!=!!e.packedInputs)m=g.isPacked?this.unpackTensor(m):this.packTensor(m),i.push(m),g=this.texData.get(m.dataId);else if(g.isPacked&&!uh(g.shape,m.shape)){let y=m,A=m.shape;m.shape=g.shape,m=this.packedReshape(m,A),i.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(a.dataId);let u={shape:a.shape,texData:o,isUniform:!1},c=Che(e,l,u),d=this.getAndSaveBinary(c,()=>The(this.gpgpu,e,l,u)),h=this.activeTimers!=null,p;h&&(p=this.startTimer()),Nhe(this.gpgpu,d,l,u,r),i.forEach(m=>this.disposeIntermediateTensorInfo(m)),h&&(p=this.endTimer(p),this.activeTimers.push({name:e.constructor.name,query:this.getQueryTime(p)}));let f=ae().get("WEBGL_FLUSH_THRESHOLD");if(f>0){let m=k.now();m-this.lastGlFlushTime>f&&(this.gpgpu.gl.flush(),this.lastGlFlushTime=m)}if(!ae().getBool("WEBGL_LAZILY_UNPACK")&&o.isPacked&&s===!1){let m=this.unpackTensor(a);return this.disposeIntermediateTensorInfo(a),m}return a}compileAndRun(e,t,n,r,s=!1){return n=n||t[0].dtype,this.runWebGLProgram(e,t,n,r,s)}getAndSaveBinary(e,t){return e in this.binaryCache||(this.binaryCache[e]=t()),this.binaryCache[e]}getTextureManager(){return this.textureManager}dispose(){this.disposed||(ae().getBool("IS_TEST")||Object.keys(this.binaryCache).forEach(t=>{this.gpgpu.deleteProgram(this.binaryCache[t].webGLProgram),delete this.binaryCache[t]}),this.textureManager.dispose(),this.canvas!=null&&typeof HTMLCanvasElement!="undefined"&&this.canvas instanceof HTMLCanvasElement?this.canvas.remove():this.canvas=null,this.gpgpuCreatedLocally&&(this.gpgpu.program=null,this.gpgpu.dispose()),this.disposed=!0)}floatPrecision(){return this.floatPrecisionValue==null&&(this.floatPrecisionValue=Z(()=>{if(!ae().get("WEBGL_RENDER_FLOAT32_ENABLED")){let e=ae().getBool("DEBUG");ae().set("DEBUG",!1);let t=this.abs(Fe(1e-8)).dataSync()[0];if(ae().set("DEBUG",e),t>0)return 32}return 16})),this.floatPrecisionValue}epsilon(){return this.floatPrecision()===32?ofe:ife}uploadToGPU(e){let t=this.texData.get(e),{shape:n,dtype:r,values:s,texture:a,usage:o,isPacked:i}=t;if(a!=null)return;let l=this.activeTimers!=null,u;l&&(u=k.now());let c=t.texShape;if(c==null&&(c=pC(n,i),t.texShape=c),s!=null){let d=Om(n),h,p=c[1],f=c[0],m=s instanceof Uint8Array;i?([p,f]=fu(c[0],c[1]),h=new Vde(d,[f,p],m)):h=new Wde(d,[f,p],m);let g=this.makeTensorInfo([f,p],r);m?this.texData.get(g.dataId).usage=zr.PIXELS:this.texData.get(g.dataId).usage=zr.UPLOAD,this.gpgpu.uploadDenseMatrixToTexture(this.getTexture(g.dataId),p,f,s);let y=!0,A=this.runWebGLProgram(h,[g],r,null,y),x=this.texData.get(A.dataId);t.texture=x.texture,t.texShape=x.texShape,t.isPacked=x.isPacked,t.usage=x.usage,this.disposeIntermediateTensorInfo(g),this.texData.delete(A.dataId),t.values=null,l&&(this.uploadWaitMs+=k.now()-u)}else{let d=this.acquireTexture(c,o,r,i);t.texture=d}}convertAndCacheOnCPU(e,t){let n=this.texData.get(e),{dtype:r}=n;return this.releaseGPUData(e),t!=null&&(n.values=hfe(t,r)),n.values}acquireTexture(e,t,n,r){if(this.numBytesInGPU+=this.computeBytes(e,n),!this.warnedAboutMemory&&this.numBytesInGPU>this.numMBBeforeWarning*1024*1024){let s=(this.numBytesInGPU/1024/1024).toFixed(2);this.warnedAboutMemory=!0,console.warn(`High memory usage in GPU: ${s} MB, most likely due to a memory leak`)}return this.textureManager.acquireTexture(e,t,r)}computeBytes(e,t){return e[0]*e[1]*k.bytesPerElement(t)}},dh=xE;dh.nextDataId=0;function hfe(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 r=0;r<n.length;++r)n[r]=Math.round(e[r]);return n}else throw new Error(`Unknown dtype ${t}`)}var pfe="3.7.0";function bE(){ae().set("WEBGL_FORCE_F16_TEXTURES",!0)}yf.isBrowser()&&$A("webgl",()=>new dh,2);var ffe={forceHalfFloat:bE},vE=`
|
|
if (isnan(a)) return a;
|
|
if (isnan(b)) return b;
|
|
`,ku=class{constructor(e,t,n){this.variableNames=["A","B"],this.outputShape=_.assertAndGetBroadcastShape(t,n),this.userCode=`
|
|
float binaryOperation(float a, float b) {
|
|
${e}
|
|
}
|
|
|
|
void main() {
|
|
float a = getAAtOutCoords();
|
|
float b = getBAtOutCoords();
|
|
setOutput(binaryOperation(a, b));
|
|
}
|
|
`}},Hm=`
|
|
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;
|
|
`,hh=class{constructor(e,t,n,r=!1){this.variableNames=["A","B"],this.supportsBroadcasting=!0,this.packedInputs=!0,this.packedOutput=!0,this.outputShape=_.assertAndGetBroadcastShape(t,n);let s=this.outputShape.length,a="";if(r)if(s===0||k.sizeFromShape(this.outputShape)===1)a=`
|
|
result.y = 0.;
|
|
result.z = 0.;
|
|
result.w = 0.;
|
|
`;else if(a=`
|
|
${It(s)} coords = getOutputCoords();
|
|
`,s===1)a+=`
|
|
result.y = (coords + 1) >= ${this.outputShape[0]} ? 0. : result.y;
|
|
result.z = 0.;
|
|
result.w = 0.;
|
|
`;else{let i=Vn("coords",s);a+=`
|
|
bool nextRowOutOfBounds =
|
|
(${i[s-2]} + 1) >= ${this.outputShape[s-2]};
|
|
bool nextColOutOfBounds =
|
|
(${i[s-1]} + 1) >= ${this.outputShape[s-1]};
|
|
result.y = nextColOutOfBounds ? 0. : result.y;
|
|
result.z = nextRowOutOfBounds ? 0. : result.z;
|
|
result.w = nextColOutOfBounds || nextRowOutOfBounds ? 0. : result.w;
|
|
`}this.userCode=`
|
|
vec4 binaryOperation(vec4 a, vec4 b) {
|
|
${e}
|
|
}
|
|
|
|
void main() {
|
|
vec4 a = getAAtOutCoords();
|
|
vec4 b = getBAtOutCoords();
|
|
|
|
vec4 result = binaryOperation(a, b);
|
|
${a}
|
|
|
|
setOutput(result);
|
|
}
|
|
`}};function mr(e){let{inputs:t,backend:n}=e,{x:r}=t;return n.incRef(r.dataId),{dataId:r.dataId,shape:r.shape,dtype:r.dtype}}var mfe={kernelName:hl,backendName:"webgl",kernelFunc:mr};function eo(e){let{inputs:t,backend:n}=e,{real:r,imag:s}=t,a=n.makeTensorInfo(r.shape,"complex64"),o=n.texData.get(a.dataId),i=mr({inputs:{x:r},backend:n}),l=mr({inputs:{x:s},backend:n});return o.complexTensorInfos={real:i,imag:l},a}var gfe={kernelName:Iy,backendName:"webgl",kernelFunc:eo},wE="return (a < 0.) ? b * a : a;",kE=`
|
|
vec4 aLessThanZero = vec4(lessThan(a, vec4(0.)));
|
|
return (aLessThanZero * (b * a)) + ((vec4(1.0) - aLessThanZero) * a);
|
|
`;function yfe(e){let{inputs:t,backend:n,attrs:r}=e,{x:s}=t,{alpha:a}=r,o=n.makeTensorInfo([],"float32",k.createScalarValue(a,"float32")),i=ae().getBool("WEBGL_PACK_BINARY_OPERATIONS")?new hh(kE,s.shape,o.shape):new ku(wE,s.shape,o.shape),l=n.runWebGLProgram(i,[s,o],s.dtype);return n.disposeIntermediateTensorInfo(o),l}var Afe={kernelName:pl,backendName:"webgl",kernelFunc:yfe},IE="return (a < 0.) ? b * a : a;",SE=`
|
|
vec4 aLessThanZero = vec4(lessThan(a, vec4(0.)));
|
|
return (aLessThanZero * (b * a)) + ((vec4(1.0) - aLessThanZero) * a);
|
|
`;function xfe(e){let{inputs:t,backend:n}=e,{x:r,alpha:s}=t,a=ae().getBool("WEBGL_PACK_BINARY_OPERATIONS")?new hh(SE,r.shape,s.shape):new ku(IE,r.shape,s.shape);return n.runWebGLProgram(a,[r,s],r.dtype)}var bfe={kernelName:Sl,backendName:"webgl",kernelFunc:xfe},TE="if (isnan(x)) return x;",vfe=`
|
|
if (isnan(a)) return a;
|
|
if (isnan(b)) return b;
|
|
`,wfe=`
|
|
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 it({opSnippet:e,packedOpSnippet:t,cpuKernelImpl:n,dtype:r}){return({inputs:s,backend:a})=>{let{x:o}=s,i=a,l=r||o.dtype;if(i.shouldExecuteOnCPU([o])&&n!=null){let d=i.texData.get(o.dataId),h=n(d.values,l);return i.makeTensorInfo(o.shape,l,h)}let u=ae().getBool("WEBGL_PACK_UNARY_OPERATIONS")&&t!=null,c;return u?c=new wu(o.shape,t):c=new Qa(o.shape,e),i.runWebGLProgram(c,[o],l)}}function Nn({opSnippet:e,packedOpSnippet:t,checkOutOfBounds:n=!1,supportsComplex:r=!1,cpuKernelImpl:s,dtype:a}){return({inputs:o,backend:i})=>{let{a:l,b:u}=o,c=i;if(r&&l.dtype==="complex64"){let f=c.texData.get(l.dataId),m=c.texData.get(u.dataId),[g,y]=[[f.complexTensorInfos.real,m.complexTensorInfos.real],[f.complexTensorInfos.imag,m.complexTensorInfos.imag]].map(x=>{let[b,v]=x,w={dataId:b.dataId,dtype:b.dtype,shape:l.shape},I={dataId:v.dataId,dtype:v.dtype,shape:u.shape},T=new ku(e,l.shape,u.shape);return c.runWebGLProgram(T,[w,I],qr(b.dtype,v.dtype))}),A=eo({inputs:{real:g,imag:y},backend:c});return c.disposeIntermediateTensorInfo(g),c.disposeIntermediateTensorInfo(y),A}let d=a||qr(l.dtype,u.dtype);if((l.dtype==="string"||u.dtype==="string"||c.shouldExecuteOnCPU([l,u]))&&s!=null){let f=c.texData.get(l.dataId).values,m=c.texData.get(u.dataId).values,g=l.dtype==="string"?_.fromUint8ToStringArray(f):f,y=l.dtype==="string"?_.fromUint8ToStringArray(m):m,[A,x]=s(l.shape,u.shape,g,y,d),b=c.makeTensorInfo(x,d),v=c.texData.get(b.dataId);return v.values=A,b}let h=ae().getBool("WEBGL_PACK_BINARY_OPERATIONS")&&t!=null,p;return h?p=new hh(t,l.shape,u.shape,n):p=new ku(e,l.shape,u.shape),c.runWebGLProgram(p,[l,u],d)}}function Gm(e,t=!1){if(e==="linear")return t?Qpe:Kpe;if(e==="relu")return t?tfe:Zpe;if(e==="elu")return t?efe:Xpe;if(e==="relu6")return t?nfe:Ype;if(e==="prelu")return t?SE:IE;if(e==="leakyrelu")return t?kE:wE;if(e==="sigmoid")return t?rfe:Jpe;throw new Error(`Activation ${e} has not been implemented for the WebGL backend.`)}var NE=class{constructor(e,t,n,r=!1,s=!1,a=!1,o=null,i=!1,l=!1){this.variableNames=["matrixA","matrixB"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=n;let u=r?e[1]:e[2],c=Math.ceil(u/2),d=r?"i * 2, rc.y":"rc.y, i * 2",h=s?"rc.z, i * 2":"i * 2, rc.z",p=r?["a.xxyy","a.zzww"]:["a.xxzz","a.yyww"],f=s?["b.xzxz","b.ywyw"]:["b.xyxy","b.zwzw"],m="",g="";o&&(i?m=`vec4 activation(vec4 a) {
|
|
vec4 b = getPreluActivationWeightsAtOutCoords();
|
|
${o}
|
|
}`:l?m=`vec4 activation(vec4 a) {
|
|
vec4 b = getLeakyreluAlphaAtOutCoords();
|
|
${o}
|
|
}`:m=`vec4 activation(vec4 x) {
|
|
${o}
|
|
}`,g="result = activation(result);");let y=a?"result += getBiasAtOutCoords();":"";a&&this.variableNames.push("bias"),i&&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}
|
|
|
|
const float sharedDimension = ${c}.0;
|
|
|
|
vec4 dot2x2ARowBCol(ivec3 rc) {
|
|
vec4 result = vec4(0);
|
|
for (int i = 0; i < ${c}; i++) {
|
|
int batchA = ${A};
|
|
int batchB = ${x};
|
|
vec4 a = getMatrixA(batchA, ${d});
|
|
vec4 b = getMatrixB(batchB, ${h});
|
|
|
|
// These swizzled products need to be separately added.
|
|
// See: https://github.com/tensorflow/tfjs/issues/1735
|
|
result += (${p[0]} * ${f[0]});
|
|
result += (${p[1]} * ${f[1]});
|
|
}
|
|
return result;
|
|
}
|
|
|
|
void main() {
|
|
ivec3 rc = getOutputCoords();
|
|
vec4 result = dot2x2ARowBCol(rc);
|
|
|
|
${y}
|
|
|
|
${g}
|
|
|
|
setOutput(result);
|
|
}
|
|
`}},CE={REAL:"return areal * breal - aimag * bimag;",IMAG:"return areal * bimag + aimag * breal;"},EE=class{constructor(e,t,n){this.variableNames=["AReal","AImag","BReal","BImag"],this.outputShape=_.assertAndGetBroadcastShape(t,n),this.userCode=`
|
|
float binaryOpComplex(
|
|
float areal, float aimag, float breal, float bimag) {
|
|
${e}
|
|
}
|
|
|
|
void main() {
|
|
float areal = getARealAtOutCoords();
|
|
float aimag = getAImagAtOutCoords();
|
|
float breal = getBRealAtOutCoords();
|
|
float bimag = getBImagAtOutCoords();
|
|
setOutput(binaryOpComplex(areal, aimag, breal, bimag));
|
|
}
|
|
`}},$E="return a * b;";function ib(e){let{inputs:t,backend:n}=e,{a:r,b:s}=t,a=_.upcastType(r.dtype,s.dtype);if(r.dtype==="complex64"){let i=n.texData.get(r.dataId),l=n.texData.get(s.dataId),u=new EE(CE.REAL,r.shape,s.shape),c=new EE(CE.IMAG,r.shape,s.shape),d=[{dataId:i.complexTensorInfos.real.dataId,dtype:i.complexTensorInfos.real.dtype,shape:r.shape},{dataId:i.complexTensorInfos.imag.dataId,dtype:i.complexTensorInfos.imag.dtype,shape:r.shape},{dataId:l.complexTensorInfos.real.dataId,dtype:l.complexTensorInfos.real.dtype,shape:s.shape},{dataId:l.complexTensorInfos.imag.dataId,dtype:l.complexTensorInfos.imag.dtype,shape:s.shape}],h=n.runWebGLProgram(u,d,"float32"),p=n.runWebGLProgram(c,d,"float32"),f=eo({inputs:{real:h,imag:p},backend:n});return n.disposeIntermediateTensorInfo(h),n.disposeIntermediateTensorInfo(p),f}if(n.shouldExecuteOnCPU([r,s])){let i=n.texData.get(r.dataId),l=n.texData.get(s.dataId),[u,c]=bpe(r.shape,s.shape,i.values,l.values,a),d=n.makeTensorInfo(c,a),h=n.texData.get(d.dataId);return h.values=u,d}let o;return ae().getBool("WEBGL_PACK_BINARY_OPERATIONS")?o=new hh($E,r.shape,s.shape):o=new ku($E,r.shape,s.shape),n.runWebGLProgram(o,[r,s],a)}var kfe={kernelName:Mo,backendName:"webgl",kernelFunc:ib};function Ife(e,t,n){let r=[gi(e.shape),...yi(e.shape)],s={dtype:e.dtype,shape:r,dataId:e.dataId},a=[gi(t),...yi(t)],o=new fE(a,r),i=!0,l=n.runWebGLProgram(o,[s],e.dtype,null,i);return{dataId:l.dataId,shape:t,dtype:l.dtype}}function ve(e){let{inputs:t,backend:n,attrs:r}=e,{x:s}=t,{shape:a}=r,o=n,i=k.sizeFromShape(s.shape),l=k.inferFromImplicitShape(a,i),u=k.sizeFromShape(l);k.assert(i===u,()=>`The new shape (${l}) has ${u} elements and the old shape (${s.shape}) has ${i} elements. The new shape and old shape must have the same number of elements.`);let c=o.texData.get(s.dataId);return c.isPacked&&!uh(s.shape,l)&&!(c.texture!==null&&uh(c.shape,l))?Ife(s,l,o):(o.incRef(s.dataId),{dataId:s.dataId,shape:l,dtype:s.dtype})}var Sfe={kernelName:Qc,backendName:"webgl",kernelFunc:ve},_E=class{constructor(e,t){this.variableNames=["x"];let{windowSize:n,batchSize:r,inSize:s,outSize:a}=e;this.outputShape=[r,a];let o=Math.floor(n/4)*4,i=n%4,l="sumValue += dot(values, ones);";if(t!=null){let c=1/t;l=`sumValue += dot(values * ${k.isInt(c)?c.toPrecision(2):c}, ones);`}let u="";s%n>0&&(u=`
|
|
if (inIdx < 0 || inIdx >= ${s}) {
|
|
return 0.0;
|
|
}
|
|
`),this.userCode=`
|
|
const vec4 ones = vec4(1.0, 1.0, 1.0, 1.0);
|
|
|
|
float getValue(int batch, int inIdx) {
|
|
${u}
|
|
return getX(batch, inIdx);
|
|
}
|
|
|
|
void main() {
|
|
ivec2 coords = getOutputCoords();
|
|
int batch = coords[0];
|
|
int outIdx = coords[1];
|
|
int inOffset = outIdx * ${n};
|
|
|
|
float sumValue = 0.0;
|
|
|
|
for (int i = 0; i < ${o}; i += 4) {
|
|
int inIdx = inOffset + i;
|
|
vec4 values = vec4(
|
|
getValue(batch, inIdx),
|
|
getValue(batch, inIdx + 1),
|
|
getValue(batch, inIdx + 2),
|
|
getValue(batch, inIdx + 3)
|
|
);
|
|
|
|
${l}
|
|
}
|
|
|
|
int inIdx = inOffset + ${o};
|
|
if (${i===1}) {
|
|
vec4 values = vec4(getValue(batch, inIdx), 0.0, 0.0, 0.0);
|
|
|
|
${l}
|
|
} else if (${i===2}) {
|
|
vec4 values = vec4(
|
|
getValue(batch, inIdx),
|
|
getValue(batch, inIdx + 1), 0.0, 0.0);
|
|
|
|
${l}
|
|
} else if (${i===3}) {
|
|
vec4 values = vec4(
|
|
getValue(batch, inIdx),
|
|
getValue(batch, inIdx + 1),
|
|
getValue(batch, inIdx + 2), 0.0);
|
|
|
|
${l}
|
|
}
|
|
setOutput(sumValue);
|
|
}
|
|
`}},Tfe=class{constructor(e,t){this.variableNames=["x"];let{windowSize:n,batchSize:r,inSize:s,outSize:a}=e;this.outputShape=[r,a];let o="0.0",i="";t==="prod"?o="1.0":t==="min"?(o="1.0 / 1e-20",i="min"):t==="max"&&(o="-1.0 / 1e-20",i="max");let l=`${t}(${t}(${t}(minMaxValue[0], minMaxValue[1]), minMaxValue[2]), minMaxValue[3])`;t==="sum"?l="sumValue":t==="prod"?l="prodValue":t==="all"?l="allValue":t==="any"&&(l="anyValue");let u=Math.floor(n/4)*4,c=n%4,d=`
|
|
if (${t==="sum"}) {
|
|
sumValue += dot(values, ones);
|
|
} else if (${t==="prod"}) {
|
|
vec2 tmp = vec2(values[0], values[1]) * vec2(values[2], values[3]);
|
|
prodValue *= tmp[0] * tmp[1];
|
|
} else {
|
|
minMaxValue = ${i}(values, minMaxValue);
|
|
if (${t==="min"} || ${t==="max"}) {
|
|
minMaxValue = ${i}(values, minMaxValue);
|
|
bvec4 isNaN = isnan(values);
|
|
if (isNaN.r || isNaN.g || isNaN.b || isNaN.a) {
|
|
minMaxValue = vec4(NAN);
|
|
}
|
|
}
|
|
}
|
|
`,h="vec4";t==="all"?(o="1.0",d=`
|
|
bool reducedAllValue = all(values);
|
|
float floatedReducedAllValue = float(reducedAllValue);
|
|
allValue = float(allValue >= 1.0 && floatedReducedAllValue >= 1.0);
|
|
`,h="bvec4"):t==="any"&&(o="0.0",d=`
|
|
bool reducedAnyValue = any(values);
|
|
float floatedReducedAnyValue = float(reducedAnyValue);
|
|
anyValue = float(anyValue >= 1.0 || floatedReducedAnyValue >= 1.0);
|
|
`,h="bvec4");let p="";s%n>0&&(p=`
|
|
if (inIdx < 0 || inIdx >= ${s}) {
|
|
return initializationValue;
|
|
}
|
|
`),this.userCode=`
|
|
const float initializationValue = ${o};
|
|
const vec4 ones = vec4(1.0, 1.0, 1.0, 1.0);
|
|
|
|
float getValue(int batch, int inIdx) {
|
|
${p}
|
|
return getX(batch, inIdx);
|
|
}
|
|
|
|
void main() {
|
|
ivec2 coords = getOutputCoords();
|
|
int batch = coords[0];
|
|
int outIdx = coords[1];
|
|
int inOffset = outIdx * ${n};
|
|
|
|
vec4 minMaxValue = vec4(${o});
|
|
float prodValue = 1.0;
|
|
float sumValue = 0.0;
|
|
float allValue = 1.0;
|
|
float anyValue = 0.0;
|
|
|
|
for (int i = 0; i < ${u}; i += 4) {
|
|
int inIdx = inOffset + i;
|
|
${h} values = ${h}(
|
|
getValue(batch, inIdx),
|
|
getValue(batch, inIdx + 1),
|
|
getValue(batch, inIdx + 2),
|
|
getValue(batch, inIdx + 3)
|
|
);
|
|
|
|
${d}
|
|
}
|
|
|
|
int inIdx = inOffset + ${u};
|
|
if (${c===1}) {
|
|
${h} values = ${h}(
|
|
getValue(batch, inIdx),
|
|
initializationValue,
|
|
initializationValue,
|
|
initializationValue
|
|
);
|
|
|
|
${d}
|
|
} else if (${c===2}) {
|
|
${h} values = ${h}(
|
|
getValue(batch, inIdx),
|
|
getValue(batch, inIdx + 1),
|
|
initializationValue,
|
|
initializationValue
|
|
);
|
|
|
|
${d}
|
|
} else if (${c===3}) {
|
|
${h} values = ${h}(
|
|
getValue(batch, inIdx),
|
|
getValue(batch, inIdx + 1),
|
|
getValue(batch, inIdx + 2),
|
|
initializationValue
|
|
);
|
|
|
|
${d}
|
|
}
|
|
setOutput(${l});
|
|
}
|
|
`}};function Nfe(e){let t=[];for(;t.length===0||t[t.length-1].outSize!==1;){let n=t.length?t[t.length-1].outSize:e[1],r=_.computeOptimalWindowSize(n);t.push({inSize:n,windowSize:r,outSize:Math.ceil(n/r)})}return t}function bi(e,t,n,r){let s=Nfe(e.shape),a=e;for(let o=0;o<s.length;o++){let{inSize:i,windowSize:l,outSize:u}=s[o],c,d;n==="mean"?c=o===0?new _E({windowSize:l,inSize:i,batchSize:e.shape[0],outSize:u},i):new _E({windowSize:l,inSize:i,batchSize:e.shape[0],outSize:u}):c=new Tfe({windowSize:l,inSize:i,batchSize:e.shape[0],outSize:u},n),d=a,a=r.runWebGLProgram(c,[a],t),d.dataId!==e.dataId&&r.disposeIntermediateTensorInfo(d)}return a}var Cfe=class{constructor(e,t){this.variableNames=["A"];let n=new Array(e.length);for(let a=0;a<n.length;a++)n[a]=e[t[a]];this.outputShape=n,this.rank=n.length;let r=It(this.rank),s=Efe(t);this.userCode=`
|
|
void main() {
|
|
${r} resRC = getOutputCoords();
|
|
setOutput(getA(${s}));
|
|
}
|
|
`}};function Efe(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"],r=new Array(t);for(let s=0;s<e.length;s++)r[e[s]]=n[s];return r.join()}var $fe=class{constructor(e,t){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0;let n=new Array(e.length);for(let u=0;u<n.length;u++)n[u]=e[t[u]];if(this.outputShape=n,this.rank=n.length,this.rank>6)throw Error(`Packed transpose for rank ${this.rank} is not yet supported.`);let r=It(this.rank),s=pE("rc",this.rank),a=new Array(this.rank);for(let u=0;u<t.length;u++)a[t[u]]=s[u];let o=`vec2(${a.slice(-2).join()})`,i=`++${s[this.rank-1]} < ${n[this.rank-1]}`,l=`getChannel(getA(${a.join()}), ${o})`;this.userCode=`
|
|
void main() {
|
|
${r} rc = getOutputCoords();
|
|
vec4 result = vec4(0.);
|
|
result[0] = ${l};
|
|
if(${i}) {
|
|
result[1] = ${l};
|
|
}
|
|
--${s[this.rank-1]};
|
|
if(++${s[this.rank-2]} < ${n[this.rank-2]}) {
|
|
result[2] = ${l};
|
|
if(${i}) {
|
|
result[3] = ${l};
|
|
}
|
|
}
|
|
setOutput(result);
|
|
}
|
|
`}};function jm(e,t,n){let r=ae().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new $fe(e.shape,t):new Cfe(e.shape,t);return n.runWebGLProgram(r,[e],e.dtype)}function _fe(e,t,n,r){let s=t,a=e.shape.length,o=k.parseAxisParam(s,e.shape),i=o,l=_.getAxesPermutation(i,a),u=l!=null,c=e;u&&(c=jm(e,l,r),i=_.getInnerMostAxes(i.length,a)),_.assertAxesAreInnerMostDims("sum",i,a);let[d,h]=_.computeOutAndReduceShapes(c.shape,i),p=d;n&&(p=_.expandShapeToKeepDim(d,o));let f=k.sizeFromShape(h),g=k.sizeFromShape(e.shape)/f,y=ve({inputs:{x:c},attrs:{shape:[g,f]},backend:r}),A=pA(e.dtype),x=bi(y,A,"sum",r),b=ve({inputs:{x},attrs:{shape:p},backend:r});return r.disposeIntermediateTensorInfo(y),r.disposeIntermediateTensorInfo(x),u&&r.disposeIntermediateTensorInfo(c),b}function qm(e){let{inputs:t,backend:n,attrs:r}=e,{x:s}=t,{axis:a,keepDims:o}=r;return _fe(s,a,o,n)}var Rfe={kernelName:Fl,backendName:"webgl",kernelFunc:qm};function Un(e){let{inputs:t,backend:n,attrs:r}=e,{x:s}=t,{perm:a}=r,o=n,i=s.shape.length,l=new Array(i);for(let c=0;c<l.length;c++)l[c]=s.shape[a[c]];let u;if(o.shouldExecuteOnCPU([s])){let d=o.texData.get(s.dataId).values,h=ob(d,s.shape,s.dtype,a,l);u=o.makeTensorInfo(l,s.dtype);let p=o.texData.get(u.dataId);p.values=h}else u=jm(s,a,o);return u}var Dfe={kernelName:zl,backendName:"webgl",kernelFunc:Un},RE=1e3;function Km({a:e,b:t,transposeA:n,transposeB:r,backend:s,bias:a=null,preluActivationWeights:o=null,leakyreluAlpha:i=0,activation:l=null}){let u=e.shape.length,c=t.shape.length,d=n?e.shape[u-2]:e.shape[u-1],h=r?t.shape[c-1]:t.shape[c-2],p=n?e.shape[u-1]:e.shape[u-2],f=r?t.shape[c-2]:t.shape[c-1],m=e.shape.slice(0,-2),g=t.shape.slice(0,-2),y=k.sizeFromShape(m),A=k.sizeFromShape(g),x=y===A||y===1||A===1;k.assert(u>=2&&c>=2&&x,()=>`Error in matMul: the input batch dimensions must either be the same or at least one input batch dimension must be 1. Got input batch dimensions of (${m}) and (${g}).`);let v=(y>A?e.shape.slice(0,-2):t.shape.slice(0,-2)).concat([p,f]);k.assert(d===h,()=>`Error in matMul: inner shapes (${d}) and (${h}) of Tensors with shapes ${e.shape} and ${t.shape} and transposeA=${n} and transposeB=${r} must match.`);let w=n?[y,d,p]:[y,p,d],I=r?[A,f,h]:[A,h,f],T=ve({inputs:{x:e},backend:s,attrs:{shape:w}}),C=ve({inputs:{x:t},backend:s,attrs:{shape:I}}),M=[T,C],$=Math.max(y,A),R=n?T.shape[1]:T.shape[2],N=a!=null,F=o!=null,B=l==="leakyrelu",j=l!=null?Gm(l,!0):null,X=N||F||B||j!=null,Y;if((p===1||f===1)&&R>RE&&X===!1){let oe=T,se=C;n&&(oe=Un({inputs:{x:T},backend:s,attrs:{perm:[0,2,1]}}),M.push(oe)),r&&(se=Un({inputs:{x:C},backend:s,attrs:{perm:[0,2,1]}}),M.push(se));let ie=f!==1,ne=f===1,de=oe;ie&&(de=ve({inputs:{x:oe},backend:s,attrs:{shape:[$,R,1]}}),M.push(de));let he=f===1?2:1,ge=se;ne&&(ge=ve({inputs:{x:se},backend:s,attrs:{shape:[$,1,R]}}),M.push(ge));let be=ib({inputs:{a:de,b:ge},backend:s});Y=qm({inputs:{x:be},backend:s,attrs:{axis:he,keepDims:!0}}),M.push(be)}else{let oe=qr(e.dtype,t.dtype),se=new NE(w,I,[$,p,f],n,r,N,j,F,B),ie=[T,C];if(a!=null&&ie.push(a),F&&ie.push(o),B){let ne=s.makeTensorInfo([],"float32",k.createScalarValue(i,"float32"));ie.push(ne),M.push(ne)}Y=s.runWebGLProgram(se,ie,oe)}let ee=ve({inputs:{x:Y},backend:s,attrs:{shape:v}});M.push(Y);for(let oe of M)s.disposeIntermediateTensorInfo(oe);return ee}function Ffe(e){let{inputs:t,backend:n,attrs:r}=e,{a:s,b:a,bias:o,preluActivationWeights:i}=t,{transposeA:l,transposeB:u,activation:c,leakyreluAlpha:d}=r;return Km({a:s,b:a,transposeA:l,transposeB:u,backend:n,bias:o,preluActivationWeights:i,leakyreluAlpha:d,activation:c})}var Mfe={kernelName:Ll,backendName:"webgl",kernelFunc:Ffe},DE="return abs(x);";function Ofe(e){let{inputs:t,backend:n}=e,{x:r}=t;if(n.shouldExecuteOnCPU([r])&&r.dtype!=="complex64"){let a=n.texData.get(r.dataId),o=dE(a.values);return n.makeTensorInfo(r.shape,r.dtype,o)}let s;return ae().getBool("WEBGL_PACK_UNARY_OPERATIONS")?s=new wu(r.shape,DE):s=new Qa(r.shape,DE),n.runWebGLProgram(s,[r],r.dtype)}var Pfe={kernelName:xc,backendName:"webgl",kernelFunc:Ofe},zfe=ys+`
|
|
if (abs(x) > 1.) {
|
|
return NAN;
|
|
}
|
|
return acos(x);
|
|
`,Lfe=it({opSnippet:zfe}),Bfe={kernelName:bc,backendName:"webgl",kernelFunc:Lfe},Wfe=ys+`
|
|
if (x < 1.0) return NAN;
|
|
return log(x + sqrt(x * x - 1.0));`,Vfe=it({opSnippet:Wfe}),Ufe={kernelName:vc,backendName:"webgl",kernelFunc:Vfe},FE="return a + b;",Hfe=Nn({opSnippet:FE,packedOpSnippet:FE,supportsComplex:!0,cpuKernelImpl:tpe}),Gfe={kernelName:Fa,backendName:"webgl",kernelFunc:Hfe},jfe=class{constructor(e,t){this.outputShape=[],this.outputShape=e,this.variableNames=t.map((s,a)=>`T${a}`);let n=[];this.variableNames.forEach(s=>{n.push(`float v${s} = get${s}AtOutCoords();`)});let r=this.variableNames.map(s=>`v${s}`).join(" + ");this.userCode=`
|
|
void main() {
|
|
${n.join(`
|
|
`)}
|
|
|
|
float result = ${r};
|
|
setOutput(result);
|
|
}
|
|
`}},qfe=class{constructor(e,t){this.outputShape=[],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=e,this.variableNames=t.map((s,a)=>`T${a}`);let n=[];this.variableNames.forEach(s=>{n.push(`vec4 v${s} = get${s}AtOutCoords();`)});let r=this.variableNames.map(s=>`v${s}`).join(" + ");this.userCode=`
|
|
void main() {
|
|
${n.join(`
|
|
`)}
|
|
|
|
vec4 result = ${r};
|
|
setOutput(result);
|
|
}
|
|
`}};function Xm(e){let{inputs:t,backend:n}=e,r=t;if(r.length===1)return mr({inputs:{x:r[0]},backend:n});if(r.length>ae().get("WEBGL_MAX_TEXTURES_IN_SHADER")){let l=Math.floor(r.length/2),u=Xm({inputs:r.slice(0,l),backend:n}),c=Xm({inputs:r.slice(l),backend:n});return Xm({inputs:[u,c],backend:n})}let s=r.map(l=>l.dtype).reduce((l,u)=>qr(l,u)),a=r.map(l=>l.shape),i=ae().getBool("WEBGL_PACK")?new qfe(r[0].shape,a):new jfe(r[0].shape,a);return n.runWebGLProgram(i,r,s)}var Kfe={kernelName:Zi,backendName:"webgl",kernelFunc:Xm};function Xfe(e){let{inputs:t,backend:n,attrs:r}=e,{x:s}=t,{axis:a,keepDims:o}=r,i=s.shape.length,l=k.parseAxisParam(a,s.shape),u=l,c=_.getAxesPermutation(u,i),d=s;c!=null&&(d=Un({inputs:{x:s},backend:n,attrs:{perm:c}}),u=_.getInnerMostAxes(u.length,i)),_.assertAxesAreInnerMostDims("all",u,i);let[h,p]=_.computeOutAndReduceShapes(d.shape,u),f=k.sizeFromShape(p),m=ve({inputs:{x:d},backend:n,attrs:{shape:[-1,f]}}),g=bi(m,m.dtype,"all",n),y;if(o){let A=_.expandShapeToKeepDim(h,l);y=ve({inputs:{x:g},backend:n,attrs:{shape:A}})}else y=ve({inputs:{x:g},backend:n,attrs:{shape:h}});return n.disposeIntermediateTensorInfo(m),n.disposeIntermediateTensorInfo(g),c!=null&&n.disposeIntermediateTensorInfo(d),y}var Zfe={kernelName:wc,backendName:"webgl",kernelFunc:Xfe};function Yfe(e){let{inputs:t,backend:n,attrs:r}=e,{x:s}=t,{axis:a,keepDims:o}=r,i=s.shape.length,l=k.parseAxisParam(a,s.shape),u=l,c=_.getAxesPermutation(u,i),d=s;c!=null&&(d=Un({inputs:{x:s},backend:n,attrs:{perm:c}}),u=_.getInnerMostAxes(u.length,i)),_.assertAxesAreInnerMostDims("any",u,i);let[h,p]=_.computeOutAndReduceShapes(d.shape,u),f=k.sizeFromShape(p),m=ve({inputs:{x:d},backend:n,attrs:{shape:[-1,f]}}),g=bi(m,m.dtype,"any",n),y;if(o){let A=_.expandShapeToKeepDim(h,l);y=ve({inputs:{x:g},backend:n,attrs:{shape:A}})}else y=ve({inputs:{x:g},backend:n,attrs:{shape:h}});return n.disposeIntermediateTensorInfo(m),n.disposeIntermediateTensorInfo(g),c!=null&&n.disposeIntermediateTensorInfo(d),y}var Jfe={kernelName:kc,backendName:"webgl",kernelFunc:Yfe},Qfe=class{constructor(e,t,n){this.variableNames=["A"];let{windowSize:r,batchSize:s,outSize:a}=e;n||this.variableNames.push("bestIndicesA"),this.outputShape=[s,a];let o=t==="max"?">":"<",i=n?"inOffset + i;":"round(getBestIndicesA(batch, inOffset + i));";this.userCode=`
|
|
void main() {
|
|
ivec2 coords = getOutputCoords();
|
|
int batch = coords[0];
|
|
int outIdx = coords[1];
|
|
int inOffset = outIdx * ${r};
|
|
|
|
int bestIndex = inOffset;
|
|
float bestValue = getA(batch, bestIndex);
|
|
|
|
for (int i = 0; i < ${r}; i++) {
|
|
int inIdx = ${i};
|
|
float candidate = getA(batch, inIdx);
|
|
if (candidate ${o} bestValue) {
|
|
bestValue = candidate;
|
|
bestIndex = inIdx;
|
|
}
|
|
}
|
|
setOutput(float(bestIndex));
|
|
}
|
|
`}},eme=class{constructor(e,t,n,r){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,k.assert(e.length>2,()=>`Packed arg${n.charAt(0).toUpperCase()+n.slice(1)} supports only inputs with rank above 2.`);let s=e[e.length-1],a=Math.ceil(s/t);this.outputShape=e.slice(0,-1),a>1&&this.outputShape.push(a),r||this.variableNames.push("bestIndicesA");let o=this.outputShape,i=o.length,l=It(i),u=Vn("coords",i),c,d;if(a===1){d=i+1;let I=It(d);c=`
|
|
${I} sourceLocR = ${I}(${u.join()}, 0);
|
|
++${u[i-1]};
|
|
${I} sourceLocG = ${I}(${u.join()}, 0);
|
|
++${u[i-2]};
|
|
${I} sourceLocA = ${I}(${u.join()}, 0);
|
|
--${u[i-1]};
|
|
${I} sourceLocB = ${I}(${u.join()}, 0);
|
|
--${u[i-2]};`}else d=i,c=`
|
|
${l} sourceLocR = coords;
|
|
++${u[i-1]};
|
|
${l} sourceLocG = coords;
|
|
++${u[i-2]};
|
|
${l} sourceLocA = coords;
|
|
--${u[i-1]};
|
|
${l} sourceLocB = coords;
|
|
--${u[i-2]};`;let h=["x","y","z","w","u","v"].slice(0,d),p="."+h[d-1],f=h.map(I=>"int "+I),m=Vn("sourceLocR",d-1).concat("inIdx.r"),g=Vn("sourceLocG",d-1).concat("inIdx.g"),y=Vn("sourceLocB",d-1).concat("inIdx.b"),A=Vn("sourceLocA",d-1).concat("inIdx.a"),x=n==="max"?"greaterThan":"lessThan",b=r?"":`
|
|
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.)`,w=r?"":`
|
|
float getBestIndicesAChannel(${f.join()}) {
|
|
return getChannel(getBestIndicesA(${h.join()}),
|
|
vec2(${h.slice(-2).join()}));
|
|
}`;this.userCode=`
|
|
float getAChannel(${f.join()}) {
|
|
return getChannel(getA(${h.join()}),
|
|
vec2(${h.slice(-2).join()}));
|
|
}
|
|
${w}
|
|
void main() {
|
|
${l} coords = getOutputCoords();
|
|
bool hasNextCol = ${u[i-1]} < ${o[i-1]-1};
|
|
bool hasNextRow = ${u[i-2]} < ${o[i-2]-1};
|
|
${c}
|
|
ivec4 srcIdx = ivec4(sourceLocR${p}, sourceLocG${p},
|
|
sourceLocB${p}, sourceLocA${p}) * ${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 ME(e,t,n,r=null){let s=t.shape[0],a=t.shape[1];r!=null&&(s=r.shape[0],a=r.shape[1]);let o=_.computeOptimalWindowSize(a),i={windowSize:o,inSize:a,batchSize:s,outSize:Math.ceil(a/o)},l=new Qfe(i,n,r==null),u=[t];r!=null&&u.push(r);let c=e.runWebGLProgram(l,u,"int32");if(c.shape[1]===1)return c;let d=ME(e,t,n,c);return e.disposeIntermediateTensorInfo(c),d}function OE(e,t,n,r=null){let s=r!=null?r.shape:t.shape,a=s[s.length-1],o=_.computeOptimalWindowSize(a),i=new eme(s,o,n,r==null),l=r==null?[t]:[t,r],u=e.runWebGLProgram(i,l,"int32");if(u.shape.length===t.shape.length){let c=OE(e,t,n,u);return e.disposeIntermediateTensorInfo(u),c}return u}function PE(e,t,n,r){let s=[n];if(_.assertAxesAreInnerMostDims("arg"+r.charAt(0).toUpperCase()+r.slice(1),s,t.shape.length),!ae().getBool("WEBGL_PACK_REDUCE")||t.shape.length<=2){let a=[],[o,i]=_.computeOutAndReduceShapes(t.shape,s),l=k.sizeFromShape(i),u=ve({inputs:{x:t},backend:e,attrs:{shape:[-1,l]}});a.push(u);let c=ME(e,u,r);a.push(c);let d=ve({inputs:{x:c},backend:e,attrs:{shape:o}});return a.forEach(h=>e.disposeIntermediateTensorInfo(h)),d}return OE(e,t,r)}function tme(e){let{inputs:t,backend:n,attrs:r}=e,{x:s}=t,{axis:a}=r,o=k.parseAxisParam(a,s.shape),i=_.getAxesPermutation(o,s.shape.length),l=s,u=[];i!=null&&(l=Un({inputs:{x:s},backend:n,attrs:{perm:i}}),u.push(l),o=_.getInnerMostAxes(o.length,l.shape.length)),_.assertAxesAreInnerMostDims("argMax",[o[0]],l.shape.length);let c=PE(n,l,o[0],"max");return u.forEach(d=>n.disposeIntermediateTensorInfo(d)),c}var nme={kernelName:Yi,backendName:"webgl",kernelFunc:tme};function rme(e){let{inputs:t,backend:n,attrs:r}=e,{x:s}=t,{axis:a}=r,o=k.parseAxisParam(a,s.shape),i=_.getAxesPermutation(o,s.shape.length),l=s,u=[];i!=null&&(l=Un({inputs:{x:s},backend:n,attrs:{perm:i}}),u.push(l),o=_.getInnerMostAxes(o.length,l.shape.length)),_.assertAxesAreInnerMostDims("argMin",[o[0]],l.shape.length);let c=PE(n,l,o[0],"min");return u.forEach(d=>n.disposeIntermediateTensorInfo(d)),c}var sme={kernelName:qp,backendName:"webgl",kernelFunc:rme},ame=ys+`
|
|
if (abs(x) > 1.) {
|
|
return NAN;
|
|
}
|
|
return asin(x);
|
|
`,ome=it({opSnippet:ame}),ime={kernelName:Ic,backendName:"webgl",kernelFunc:ome},lme=ys+"return log(x + sqrt(x * x + 1.0));",ume=it({opSnippet:lme}),cme={kernelName:Sc,backendName:"webgl",kernelFunc:ume},dme=ys+`
|
|
return atan(x);
|
|
`,hme=it({opSnippet:dme}),pme={kernelName:Tc,backendName:"webgl",kernelFunc:hme},fme=vfe+`
|
|
return atan(a, b);
|
|
`,mme=`
|
|
vec4 result = atan(a, b);
|
|
vec4 isNaN = min(vec4(isnan(a)) + vec4(isnan(b)), vec4(1.0));
|
|
`+wfe+`
|
|
return result;
|
|
`,gme=Nn({opSnippet:fme,packedOpSnippet:mme}),yme={kernelName:Cc,backendName:"webgl",kernelFunc:gme},Ame=ys+`
|
|
if ((x < -1.0) || (x > 1.0)) return NAN;
|
|
return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,xme=it({opSnippet:Ame}),bme={kernelName:Nc,backendName:"webgl",kernelFunc:xme},ph=class{constructor(e,t,n,r=!1,s=!1){if(this.variableNames=["x"],t==="avg"&&n)throw new Error("Cannot compute positions for average pool.");let a=e.filterWidth,o=e.strideHeight,i=e.strideWidth,l=e.dilationHeight,u=e.dilationWidth,c=e.effectiveFilterHeight,d=e.effectiveFilterWidth,h=e.padInfo.top,p=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 I=">=";this.userCode=`
|
|
const ivec2 strides = ivec2(${o}, ${i});
|
|
const ivec2 pads = ivec2(${h}, ${p});
|
|
|
|
void main() {
|
|
ivec4 coords = getOutputCoords();
|
|
int batch = coords[0];
|
|
int d = coords[3];
|
|
|
|
ivec2 xRCCorner = coords.yz * strides - pads;
|
|
int xRCorner = xRCCorner.x;
|
|
int xCCorner = xRCCorner.y;
|
|
|
|
// max/min x(?, ?, d) to get y(yR, yC, d).
|
|
// ? = to be determined
|
|
float minMaxValue = 0.0;
|
|
float minMaxValueFound = 0.0;
|
|
int minMaxPosition = 0;
|
|
float avgValue = 0.0;
|
|
|
|
for (int wR = 0; wR < ${c};
|
|
wR += ${l}) {
|
|
int xR = xRCorner + wR;
|
|
|
|
if (xR < 0 || xR >= ${e.inHeight}) {
|
|
continue;
|
|
}
|
|
|
|
for (int wC = 0; wC < ${d};
|
|
wC += ${u}) {
|
|
int xC = xCCorner + wC;
|
|
|
|
if (xC < 0 || xC >= ${e.inWidth}) {
|
|
continue;
|
|
}
|
|
|
|
float value = getX(batch, xR, xC, d);
|
|
|
|
// If a min / max value has already been found, use it. If not,
|
|
// use the current value.
|
|
float currMinMaxValue = mix(
|
|
value, minMaxValue, minMaxValueFound);
|
|
if (value ${I} currMinMaxValue) {
|
|
minMaxValue = value;
|
|
minMaxValueFound = 1.0;
|
|
minMaxPosition = ${r?s?m:g:`wR * ${d} + 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(a/4)*4,v=a%4,w=`
|
|
if (${f}) {
|
|
avgValue += dot(values, ones);
|
|
} else {
|
|
minMaxValue = ${A}(values, minMaxValue);
|
|
}
|
|
`;this.userCode=`
|
|
const ivec2 strides = ivec2(${o}, ${i});
|
|
const ivec2 pads = ivec2(${h}, ${p});
|
|
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 < ${c};
|
|
wR += ${l}) {
|
|
int xR = xRCorner + wR;
|
|
|
|
if (xR < 0 || xR >= ${e.inHeight}) {
|
|
continue;
|
|
}
|
|
|
|
for (int wC = 0; wC < ${b}; wC += 4) {
|
|
int xC = xCCorner + wC * ${u};
|
|
|
|
vec4 values = vec4(
|
|
getValue(batch, xR, xC, d),
|
|
getValue(batch, xR, xC + ${u}, d),
|
|
getValue(batch, xR, xC + 2 * ${u}, d),
|
|
getValue(batch, xR, xC + 3 * ${u}, d)
|
|
);
|
|
|
|
${w}
|
|
}
|
|
|
|
int xC = xCCorner + ${b};
|
|
if (${v===1}) {
|
|
vec4 values = vec4(
|
|
getValue(batch, xR, xC, d),
|
|
initializationValue,
|
|
initializationValue,
|
|
initializationValue
|
|
);
|
|
|
|
${w}
|
|
} else if (${v===2}) {
|
|
vec4 values = vec4(
|
|
getValue(batch, xR, xC, d),
|
|
getValue(batch, xR, xC + ${u}, d),
|
|
initializationValue,
|
|
initializationValue
|
|
);
|
|
|
|
${w}
|
|
} else if (${v===3}) {
|
|
vec4 values = vec4(
|
|
getValue(batch, xR, xC, d),
|
|
getValue(batch, xR, xC + ${u}, d),
|
|
getValue(batch, xR, xC + 2 * ${u}, d),
|
|
initializationValue
|
|
);
|
|
|
|
${w}
|
|
}
|
|
}
|
|
setOutput(${x});
|
|
}
|
|
`}},lb=class{constructor(e,t,n,r=!1,s=!1){if(this.variableNames=["x"],t==="avg"&&n)throw new Error("Cannot compute positions for average pool.");let a=e.filterWidth,o=e.strideDepth,i=e.strideHeight,l=e.strideWidth,u=e.dilationDepth,c=e.dilationHeight,d=e.dilationWidth,h=e.effectiveFilterDepth,p=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 C=">=";this.userCode=`
|
|
const ivec3 strides =
|
|
ivec3(${o}, ${i}, ${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 < ${h};
|
|
wD += ${u}) {
|
|
int xD = xDCorner + wD;
|
|
|
|
if (xD < 0 || xD >= ${e.inDepth}) {
|
|
continue;
|
|
}
|
|
|
|
for (int wR = 0; wR < ${p};
|
|
wR += ${c}) {
|
|
int xR = xRCorner + wR;
|
|
|
|
if (xR < 0 || xR >= ${e.inHeight}) {
|
|
continue;
|
|
}
|
|
|
|
for (int wC = 0; wC < ${f};
|
|
wC += ${d}) {
|
|
int xC = xCCorner + wC;
|
|
|
|
if (xC < 0 || xC >= ${e.inWidth}) {
|
|
continue;
|
|
}
|
|
|
|
float value = getX(batch, xD, xR, xC, ch);
|
|
|
|
// If a min / max value has already been found, use it. If not,
|
|
// use the current value.
|
|
float currMinMaxValue = mix(
|
|
value, minMaxValue, minMaxValueFound);
|
|
if (value ${C} currMinMaxValue) {
|
|
minMaxValue = value;
|
|
minMaxValueFound = 1.0;
|
|
minMaxPosition = ${r?s?`(((batch * ${e.inDepth} + xD) * ${e.inHeight} + xR) * ${e.inWidth} + xC) * ${e.inChannels} + ch`:`((xD * ${e.inHeight} + xR) * ${e.inWidth} + xC) * ${e.inChannels} + ch`:`wD * ${p} * ${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 w=Math.floor(a/4)*4,I=a%4,T=`
|
|
if (${A}) {
|
|
avgValue += dot(values, ones);
|
|
} else {
|
|
minMaxValue = ${b}(values, minMaxValue);
|
|
}
|
|
`;this.userCode=`
|
|
const ivec3 strides =
|
|
ivec3(${o}, ${i}, ${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 < ${h};
|
|
wD += ${u}) {
|
|
int xD = xDCorner + wD;
|
|
|
|
if (xD < 0 || xD >= ${e.inDepth}) {
|
|
continue;
|
|
}
|
|
|
|
for (int wR = 0; wR < ${p};
|
|
wR += ${c}) {
|
|
int xR = xRCorner + wR;
|
|
|
|
if (xR < 0 || xR >= ${e.inHeight}) {
|
|
continue;
|
|
}
|
|
|
|
for (int wC = 0; wC < ${w}; wC += 4) {
|
|
int xC = xCCorner + wC * ${d};
|
|
|
|
vec4 values = vec4(
|
|
getValue(batch, xD, xR, xC, ch),
|
|
getValue(batch, xD, xR, xC + ${d}, ch),
|
|
getValue(batch, xD, xR, xC + 2 * ${d}, ch),
|
|
getValue(batch, xD, xR, xC + 3 * ${d}, ch)
|
|
);
|
|
|
|
${T}
|
|
}
|
|
|
|
int xC = xCCorner + ${w};
|
|
if (${I===1}) {
|
|
vec4 values = vec4(
|
|
getValue(batch, xD, xR, xC, ch),
|
|
initializationValue,
|
|
initializationValue,
|
|
initializationValue
|
|
);
|
|
|
|
${T}
|
|
} else if (${I===2}) {
|
|
vec4 values = vec4(
|
|
getValue(batch, xD, xR, xC, ch),
|
|
getValue(batch, xD, xR, xC + ${d}, ch),
|
|
initializationValue,
|
|
initializationValue
|
|
);
|
|
|
|
${T}
|
|
} else if (${I===3}) {
|
|
vec4 values = vec4(
|
|
getValue(batch, xD, xR, xC, ch),
|
|
getValue(batch, xD, xR, xC + ${d}, ch),
|
|
getValue(batch, xD, xR, xC + 2 * ${d}, ch),
|
|
initializationValue
|
|
);
|
|
|
|
${T}
|
|
}
|
|
}
|
|
setOutput(${v});
|
|
}
|
|
}
|
|
`}};function vme(e){let{inputs:t,backend:n,attrs:r}=e,{x:s}=t;mu(s,"avgPool");let{filterSize:a,strides:o,pad:i,dimRoundingMode:l}=r,u=1;k.assert(_.eitherStridesOrDilationsAreOne(o,u),()=>`Error in avgPool: Either strides or dilations must be 1. Got strides ${o} and dilations '${u}'`);let c=_.computePool2DInfo(s.shape,a,o,u,i,l);if(c.filterWidth===1&&c.filterHeight===1&&k.arraysEqual(c.inShape,c.outShape))return mr({inputs:{x:s},backend:n});let d=new ph(c,"avg",!1);return n.runWebGLProgram(d,[s],"float32")}var wme={kernelName:Ji,backendName:"webgl",kernelFunc:vme};function kme(e){let{inputs:t,backend:n,attrs:r}=e,{x:s}=t,{filterSize:a,strides:o,pad:i,dimRoundingMode:l,dataFormat:u}=r,c=[1,1,1],d=_.computePool3DInfo(s.shape,a,o,c,i,l,u),h=new lb(d,"avg",!1);return n.runWebGLProgram(h,[s],"float32")}var Ime={kernelName:Kp,backendName:"webgl",kernelFunc:kme},Sme=class{constructor(e){this.variableNames=["dy"],this.outputShape=e.inShape;let t=e.filterHeight,n=e.filterWidth,r=e.strideHeight,s=e.strideWidth,a=e.dilationHeight,o=e.dilationWidth,i=e.effectiveFilterHeight,l=e.effectiveFilterWidth,u=i-1-e.padInfo.top,c=l-1-e.padInfo.left,d=1/(t*n);this.userCode=`
|
|
const ivec2 pads = ivec2(${u}, ${c});
|
|
const float avgMultiplier = float(${d});
|
|
|
|
void main() {
|
|
ivec4 coords = getOutputCoords();
|
|
int b = coords[0];
|
|
int d = coords[3];
|
|
|
|
ivec2 dyRCCorner = coords.yz - pads;
|
|
int dyRCorner = dyRCCorner.x;
|
|
int dyCCorner = dyRCCorner.y;
|
|
|
|
// Convolve dy(?, ?, d) with pos mask(:, :, d) to get dx(xR, xC, d).
|
|
// ? = to be determined. : = across all values in that axis.
|
|
float dotProd = 0.0;
|
|
for (int wR = 0; wR < ${i};
|
|
wR += ${a}) {
|
|
float dyR = float(dyRCorner + wR) / ${r}.0;
|
|
|
|
if (dyR < 0.0 || dyR >= ${e.outHeight}.0 || fract(dyR) > 0.0) {
|
|
continue;
|
|
}
|
|
int idyR = int(dyR);
|
|
|
|
for (int wC = 0; wC < ${l};
|
|
wC+= ${o}) {
|
|
float dyC = float(dyCCorner + wC) / ${s}.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);
|
|
}
|
|
`}},Tme=class{constructor(e){this.variableNames=["dy"],this.outputShape=e.inShape;let t=e.filterDepth,n=e.filterHeight,r=e.filterWidth,s=e.strideDepth,a=e.strideHeight,o=e.strideWidth,i=e.dilationDepth,l=e.dilationHeight,u=e.dilationWidth,c=e.effectiveFilterDepth,d=e.effectiveFilterHeight,h=e.effectiveFilterWidth,p=c-1-e.padInfo.front,f=d-1-e.padInfo.top,m=h-1-e.padInfo.left,g=1/(t*n*r);this.userCode=`
|
|
const ivec3 pads = ivec3(${p}, ${f}, ${m});
|
|
const float avgMultiplier = float(${g});
|
|
|
|
void main() {
|
|
ivec5 coords = getOutputCoords();
|
|
int batch = coords.x;
|
|
int ch = coords.u;
|
|
|
|
ivec3 dyCorner = ivec3(coords.y, coords.z, coords.w) - pads;
|
|
int dyDCorner = dyCorner.x;
|
|
int dyRCorner = dyCorner.y;
|
|
int dyCCorner = dyCorner.z;
|
|
|
|
// Convolve dy(?, ?, ?, d) with pos mask(:, :, :, ch) to get
|
|
// dx(xD, xR, xC, ch).
|
|
// ? = to be determined. : = across all values in that axis.
|
|
float dotProd = 0.0;
|
|
|
|
for (int wD = 0; wD < ${c};
|
|
wD += ${i}) {
|
|
float dyD = float(dyDCorner + wD) / ${s}.0;
|
|
|
|
if (dyD < 0.0 || dyD >= ${e.outDepth}.0 || fract(dyD) > 0.0) {
|
|
continue;
|
|
}
|
|
int idyD = int(dyD);
|
|
|
|
for (int wR = 0; wR < ${d};
|
|
wR += ${l}) {
|
|
float dyR = float(dyRCorner + wR) / ${a}.0;
|
|
|
|
if (dyR < 0.0 || dyR >= ${e.outHeight}.0 ||
|
|
fract(dyR) > 0.0) {
|
|
continue;
|
|
}
|
|
int idyR = int(dyR);
|
|
|
|
for (int wC = 0; wC < ${h};
|
|
wC += ${u}) {
|
|
float dyC = float(dyCCorner + wC) / ${o}.0;
|
|
|
|
if (dyC < 0.0 || dyC >= ${e.outWidth}.0 ||
|
|
fract(dyC) > 0.0) {
|
|
continue;
|
|
}
|
|
int idyC = int(dyC);
|
|
|
|
float dyValue = getDy(batch, idyD, idyR, idyC, ch);
|
|
|
|
dotProd += dyValue * avgMultiplier;
|
|
}
|
|
}
|
|
}
|
|
setOutput(dotProd);
|
|
}
|
|
`}};function Nme(e){let{inputs:t,backend:n,attrs:r}=e,{dy:s,input:a}=t,o=a,{filterSize:i,strides:l,pad:u,dimRoundingMode:c}=r,d=[1,1,1],h=_.computePool3DInfo(o.shape,i,l,d,u,c),p=new Tme(h);return n.runWebGLProgram(p,[s],o.dtype)}var Cme={kernelName:wy,backendName:"webgl",kernelFunc:Nme};function Eme(e){let{inputs:t,backend:n,attrs:r}=e,{dy:s,input:a}=t,o=a;mu([s,a],"avgPoolGrad");let{filterSize:i,strides:l,pad:u}=r,c=_.computePool2DInfo(o.shape,i,l,1,u),d=new Sme(c);return n.runWebGLProgram(d,[s],o.dtype)}var $me={kernelName:vy,backendName:"webgl",kernelFunc:Eme};function _me(e){let{inputs:t,backend:n,attrs:r}=e,{a:s,b:a}=t,{transposeA:o,transposeB:i}=r;return Km({a:s,b:a,transposeA:o,transposeB:i,backend:n})}var Rme={kernelName:Qi,backendName:"webgl",kernelFunc:_me},Dme=class{constructor(e,t,n,r,s,a){this.outputShape=[],this.variableNames=["x","mean","variance"],_.assertAndGetBroadcastShape(e,t),_.assertAndGetBroadcastShape(e,n);let o="0.0";r!=null&&(_.assertAndGetBroadcastShape(e,r),this.variableNames.push("offset"),o="getOffsetAtOutCoords()");let i="1.0";s!=null&&(_.assertAndGetBroadcastShape(e,s),this.variableNames.push("scale"),i="getScaleAtOutCoords()"),this.outputShape=e,this.userCode=`
|
|
void main() {
|
|
float x = getXAtOutCoords();
|
|
float mean = getMeanAtOutCoords();
|
|
float variance = getVarianceAtOutCoords();
|
|
float offset = ${o};
|
|
float scale = ${i};
|
|
float inv = scale * inversesqrt(variance + float(${a}));
|
|
setOutput(dot(vec3(x, -mean, offset), vec3(inv, inv, 1)));
|
|
}
|
|
`}},Fme=class{constructor(e,t,n,r,s,a){this.packedInputs=!0,this.packedOutput=!0,this.variableNames=["x","mean","variance"],_.assertAndGetBroadcastShape(e,t),_.assertAndGetBroadcastShape(e,n);let o="vec4(0.0)";r!=null&&(_.assertAndGetBroadcastShape(e,r),this.variableNames.push("offset"),o="getOffsetAtOutCoords()");let i="vec4(1.0)";s!=null&&(_.assertAndGetBroadcastShape(e,s),this.variableNames.push("scale"),i="getScaleAtOutCoords()"),this.outputShape=e,this.userCode=`
|
|
void main() {
|
|
vec4 offset = ${o};
|
|
vec4 scale = ${i};
|
|
|
|
vec4 x = getXAtOutCoords();
|
|
vec4 mean = getMeanAtOutCoords();
|
|
vec4 variance = getVarianceAtOutCoords();
|
|
|
|
vec4 inv = scale * inversesqrt(variance + vec4(${a}));
|
|
|
|
setOutput((x - mean) * inv + offset);
|
|
}
|
|
`}},Mme=({inputs:e,backend:t,attrs:n})=>{let{x:r,mean:s,variance:a,offset:o,scale:i}=e;k.assert(s.shape.length===a.shape.length,()=>"Batch normalization gradient requires mean and variance to have equal ranks."),k.assert(o==null||s.shape.length===o.shape.length,()=>"Batch normalization gradient requires mean and offset to have equal ranks."),k.assert(i==null||s.shape.length===i.shape.length,()=>"Batch normalization gradient requires mean and scale to have equal ranks.");let{varianceEpsilon:l}=n;l==null&&(l=.001);let u=[r,s,a],c=null;o!=null&&(c=o.shape,u.push(o));let d=null;i!=null&&(d=i.shape,u.push(i));let h=ae().getBool("WEBGL_PACK_NORMALIZATION")?new Fme(r.shape,s.shape,a.shape,c,d,l):new Dme(r.shape,s.shape,a.shape,c,d,l);return t.runWebGLProgram(h,u,u[0].dtype)},Ome={kernelName:cl,backendName:"webgl",kernelFunc:Mme},Pme=class{constructor(e){this.variableNames=["source"],this.outputShape=e,this.rank=e.length;let t=It(this.rank),n=`uniform int start[${this.rank}];`,r=zme(this.rank),s,a=e.map((o,i)=>`sourceLoc.${ub[i]} = start[${i}] + coords.${ub[i]};`);s=`
|
|
${t} sourceLoc;
|
|
${t} coords = getOutputCoords();
|
|
${a.join(`
|
|
`)}
|
|
`,this.userCode=`
|
|
${n}
|
|
void main() {
|
|
${s}
|
|
setOutput(getSource(${r}));
|
|
}
|
|
`}getCustomSetupFunc(e){if(e.length!==this.rank)throw Error(`The rank (${this.rank}) of the program must match the length of start (${e.length})`);return(t,n)=>{this.startLoc==null&&(this.startLoc=t.getUniformLocationNoThrow(n,"start"),this.startLoc==null)||t.gl.uniform1iv(this.startLoc,e)}}},ub=["x","y","z","w","u","v"];function zme(e){if(e===1)return"sourceLoc";if(e<=6)return ub.slice(0,e).map(t=>"sourceLoc."+t).join(",");throw Error(`Slicing for rank ${e} is not yet supported`)}var Lme=class{constructor(e){this.variableNames=["source"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=e,this.rank=e.length;let t=It(this.rank),n=Vn("coords",this.rank),r=Vn("sourceLoc",this.rank),s=this.rank===1?"sourceLoc":`vec2(${r.slice(-2).join()})`,a=`getChannel(getSource(${r.join()}), ${s})`,o=`
|
|
result.x = ${a};
|
|
if (++${n[this.rank-1]} < ${e[this.rank-1]}) {
|
|
++${r[this.rank-1]};
|
|
result.y = ${a};
|
|
--${r[this.rank-1]};
|
|
}
|
|
`,i=this.rank===1?"":`
|
|
--${n[this.rank-1]};
|
|
if (++${n[this.rank-2]} < ${e[this.rank-2]}) {
|
|
++${r[this.rank-2]};
|
|
result.z = ${a};
|
|
if (++${n[this.rank-1]} < ${e[this.rank-1]}) {
|
|
++${r[this.rank-1]};
|
|
result.w = ${a};
|
|
}
|
|
}
|
|
`,l=this.rank<=4?`sourceLoc = coords +
|
|
${t}(${e.map((u,c)=>`start[${c}]`).join()});`:e.map((u,c)=>`${r[c]} = ${n[c]} + start[${c}];`).join(`
|
|
`);this.userCode=`
|
|
uniform int start[${this.rank}];
|
|
void main() {
|
|
${t} coords = getOutputCoords();
|
|
${t} sourceLoc;
|
|
${l}
|
|
vec4 result = vec4(0.);
|
|
${o}
|
|
${i}
|
|
setOutput(result);
|
|
}
|
|
`}getCustomSetupFunc(e){if(e.length!==this.rank)throw Error(`The rank (${this.rank}) of the program must match the length of start (${e.length})`);return(t,n)=>{this.startLoc==null&&(this.startLoc=t.getUniformLocationNoThrow(n,"start"),this.startLoc==null)||t.gl.uniform1iv(this.startLoc,e)}}};function Bme(e,t,n,r){let s=r.texData.get(e.dataId),a=r.makeTensorInfo(n,e.dtype),o=r.texData.get(a.dataId);Object.assign(o,s),o.refCount=1,o.shape=n,o.dtype=e.dtype;let i=En.computeFlatOffset(t,k.computeStrides(e.shape));s.slice&&(i+=s.slice.flatOffset),o.slice={flatOffset:i,origDataId:s.slice&&s.slice.origDataId||e.dataId};let l=r.dataRefCount.get(o.slice.origDataId)||1;return r.dataRefCount.set(o.slice.origDataId,l+1),a}function fh(e){let{inputs:t,backend:n,attrs:r}=e,{x:s}=t,{begin:a,size:o}=r,[i,l]=En.parseSliceParams(s,a,o);if(En.assertParamsValid(s,i,l),k.sizeFromShape(l)===0)return n.makeTensorInfo(l,s.dtype,[]);if(n.shouldExecuteOnCPU([s])||s.dtype==="string"){let d=n.texData.get(s.dataId),h=Tpe(d.values,i,l,s.shape,s.dtype);return n.makeTensorInfo(l,s.dtype,h)}let{isPacked:u}=n.texData.get(s.dataId),c=En.isSliceContinous(s.shape,i,l);if(u||!c){let d=ae().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new Lme(l):new Pme(l),h=d.getCustomSetupFunc(i);return n.runWebGLProgram(d,[s],s.dtype,h)}return n.uploadToGPU(s.dataId),Bme(s,i,l,n)}var Wme={kernelName:rd,backendName:"webgl",kernelFunc:fh},Vme=e=>{let{inputs:t,backend:n,attrs:r}=e,{x:s}=t,{blockShape:a,crops:o}=r;k.assert(s.shape.length<=4,()=>"batchToSpaceND for rank > 4 with a WebGL backend not implemented yet");let i=a.reduce((A,x)=>A*x),l=_.getReshaped(s.shape,a,i),u=_.getPermuted(l.length,a.length),c=_.getReshapedPermuted(s.shape,a,i),d=_.getSliceBeginCoords(o,a.length),h=_.getSliceSize(c,o,a.length),p=[],f=ve({inputs:{x:s},backend:n,attrs:{shape:l}}),m=Un({inputs:{x:f},backend:n,attrs:{perm:u}}),g=ve({inputs:{x:m},backend:n,attrs:{shape:c}}),y=fh({inputs:{x:g},backend:n,attrs:{begin:d,size:h}});return p.push(f),p.push(m),p.push(g),p.forEach(A=>n.disposeIntermediateTensorInfo(A)),y},Ume={kernelName:Xp,backendName:"webgl",kernelFunc:Vme};function Hme(e){let{inputs:t,backend:n,attrs:r}=e,{x:s,weights:a}=t,{size:o}=r,i=n.readSync(s.dataId),l=n.readSync(a.dataId),u=cE(i,l,a.dtype,a.shape,o);return n.makeTensorInfo([o],a.dtype,u)}var Gme={kernelName:ky,backendName:"webgl",kernelFunc:Hme},jme="return float(a != b);",zE=Nn({opSnippet:jme,cpuKernelImpl:wpe,dtype:"bool"}),qme={kernelName:vl,backendName:"webgl",kernelFunc:zE};function mh(e){let{inputs:t,backend:n}=e,{input:r}=t,s=n.texData.get(r.dataId);return mr({inputs:{x:s.complexTensorInfos.real},backend:n})}var Kme={kernelName:Gy,backendName:"webgl",kernelFunc:mh},Xme="return float(int(x));";function Zme(e,t){let n=new Qa(e.shape,Xme),r=t.runWebGLProgram(n,[e],"int32");return{dataId:r.dataId,shape:r.shape,dtype:r.dtype}}function cb(e){let{inputs:t,backend:n,attrs:r}=e,{x:s}=t,{dtype:a}=r;if(a==="complex64"){if(s.dtype==="complex64")return mr({inputs:{x:s},backend:n});let o=un(s.shape),i=cb({inputs:{x:s},backend:n,attrs:{dtype:"float32"}}),l=eo({inputs:{real:i,imag:o},backend:n});return o.dispose(),n.disposeIntermediateTensorInfo(i),l}if(s.dtype==="complex64"){let o=mh({inputs:{input:s},backend:n}),i=cb({inputs:{x:o},backend:n,attrs:{dtype:a}});return n.disposeIntermediateTensorInfo(o),i}if(!k.hasEncodingLoss(s.dtype,a)){let o=mr({inputs:{x:s},backend:n});return{dataId:o.dataId,shape:o.shape,dtype:a}}if(a==="int32")return Zme(s,n);if(a==="bool"){let o=n.makeTensorInfo([],"bool",k.getTypedArrayFromDType("bool",1)),l=zE({inputs:{a:s,b:o},backend:n});return n.disposeIntermediateTensorInfo(o),l}throw new Error(`Error in Cast: failed to cast ${s.dtype} to ${a}`)}var Yme={kernelName:el,backendName:"webgl",kernelFunc:cb},LE="return ceil(x);",Jme=it({opSnippet:LE,packedOpSnippet:LE,cpuKernelImpl:rpe}),Qme={kernelName:No,backendName:"webgl",kernelFunc:Jme},e0e=class{constructor(e){this.variableNames=["A"],this.outputShape=e,this.userCode=`
|
|
uniform float minVal;
|
|
uniform float maxVal;
|
|
|
|
void main() {
|
|
float value = getAAtOutCoords();
|
|
if (isnan(value)) {
|
|
setOutput(value);
|
|
return;
|
|
}
|
|
|
|
setOutput(clamp(value, minVal, maxVal));
|
|
}
|
|
`}getCustomSetupFunc(e,t){return(n,r)=>{this.minLoc==null&&(this.minLoc=n.getUniformLocationNoThrow(r,"minVal"),this.maxLoc=n.getUniformLocationNoThrow(r,"maxVal")),n.gl.uniform1f(this.minLoc,e),n.gl.uniform1f(this.maxLoc,t)}}},t0e=class{constructor(e){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=e,this.userCode=`
|
|
uniform float minVal;
|
|
uniform float maxVal;
|
|
|
|
void main() {
|
|
vec4 value = getAAtOutCoords();
|
|
|
|
if (any(isnan(value))) {
|
|
setOutput(value);
|
|
return;
|
|
}
|
|
|
|
setOutput(clamp(value, vec4(minVal), vec4(maxVal)));
|
|
}
|
|
`}getCustomSetupFunc(e,t){return(n,r)=>{this.minLoc==null&&(this.minLoc=n.getUniformLocationNoThrow(r,"minVal"),this.maxLoc=n.getUniformLocationNoThrow(r,"maxVal")),n.gl.uniform1f(this.minLoc,e),n.gl.uniform1f(this.maxLoc,t)}}};function n0e(e){let{inputs:t,backend:n,attrs:r}=e,{x:s}=t,{clipValueMin:a,clipValueMax:o}=r,i;ae().getBool("WEBGL_PACK_CLIP")?i=new t0e(s.shape):i=new e0e(s.shape);let l=i.getCustomSetupFunc(a,o);return n.runWebGLProgram(i,[s],s.dtype,l)}var r0e={kernelName:Co,backendName:"webgl",kernelFunc:n0e},s0e=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 BE(e,t){return{dataId:t.dataId,dtype:t.dtype,shape:e.shape}}function a0e(e){let{inputs:t,backend:n}=e,{x:r}=t,s=n.texData.get(r.dataId),a=new s0e(r.shape),o=[BE(r,s.complexTensorInfos.real),BE(r,s.complexTensorInfos.imag)];return n.runWebGLProgram(a,o,o[0].dtype)}var o0e={kernelName:Zp,backendName:"webgl",kernelFunc:a0e},i0e=class{constructor(e){this.outputShape=[],this.outputShape=_.computeOutShape(e,1),this.variableNames=e.map((a,o)=>`T${o}`);let t=new Array(e.length-1);t[0]=e[0][1];for(let a=1;a<t.length;a++)t[a]=t[a-1]+e[a][1];let n=[`if (yC < ${t[0]}) setOutput(getT0(yR, yC));`];for(let a=1;a<t.length;a++){let o=t[a-1];n.push(`else if (yC < ${t[a]}) setOutput(getT${a}(yR, yC-${o}));`)}let r=t.length,s=t[t.length-1];n.push(`else setOutput(getT${r}(yR, yC-${s}));`),this.userCode=`
|
|
void main() {
|
|
ivec2 coords = getOutputCoords();
|
|
int yR = coords.x;
|
|
int yC = coords.y;
|
|
|
|
${n.join(`
|
|
`)}
|
|
}
|
|
`}},l0e=class{constructor(e,t){this.packedInputs=!0,this.packedOutput=!0,this.outputShape=[],this.outputShape=_.computeOutShape(e,t);let n=this.outputShape,r=n.length,s=It(r),a=Vn("coords",r),o=["x","y","z","w","u","v"].slice(0,r);this.variableNames=e.map((f,m)=>`T${m}`);let i=new Array(e.length-1);i[0]=e[0][t];for(let f=1;f<i.length;f++)i[f]=i[f-1]+e[f][t];let l=o[t],u=o.slice(-2),c=o.join(),d=`if (${l} < ${i[0]}) {
|
|
return getChannel(
|
|
getT0(${c}), vec2(${u.join()}));
|
|
}`;for(let f=1;f<i.length;f++){let m=i[f-1];d+=`
|
|
if (${l} < ${i[f]} && ${l} >= ${i[f-1]}) {
|
|
return getChannel(
|
|
getT${f}(${Zm(o,l,m)}),
|
|
vec2(${Zm(u,l,m)}));
|
|
}`}let h=i.length,p=i[i.length-1];d+=`
|
|
return getChannel(
|
|
getT${h}(${Zm(o,l,p)}),
|
|
vec2(${Zm(u,l,p)}));`,this.userCode=`
|
|
float getValue(${o.map(f=>"int "+f)}) {
|
|
${d}
|
|
}
|
|
|
|
void main() {
|
|
${s} coords = getOutputCoords();
|
|
vec4 result = vec4(getValue(${a}), 0., 0., 0.);
|
|
|
|
${a[r-1]} = ${a[r-1]} + 1;
|
|
if (${a[r-1]} < ${n[r-1]}) {
|
|
result.g = getValue(${a});
|
|
}
|
|
|
|
${a[r-2]} = ${a[r-2]} + 1;
|
|
if (${a[r-2]} < ${n[r-2]}) {
|
|
result.a = getValue(${a});
|
|
}
|
|
|
|
${a[r-1]} = ${a[r-1]} - 1;
|
|
if (${a[r-2]} < ${n[r-2]} &&
|
|
${a[r-1]} < ${n[r-1]}) {
|
|
result.b = getValue(${a});
|
|
}
|
|
setOutput(result);
|
|
}
|
|
`}};function Zm(e,t,n){let r=e.indexOf(t);return e.map((a,o)=>o===r?`${a} - ${n}`:a).join()}function Ym(e){let{inputs:t,backend:n}=e,{input:r}=t,s=n.texData.get(r.dataId);return mr({inputs:{x:s.complexTensorInfos.imag},backend:n})}var u0e={kernelName:zy,backendName:"webgl",kernelFunc:Ym};function Iu(e,t,n){let r=e[0].dtype;if(r==="complex64"){let c=e.map(m=>mh({inputs:{input:m},backend:n})),d=e.map(m=>Ym({inputs:{input:m},backend:n})),h=Iu(c,t,n),p=Iu(d,t,n),f=eo({inputs:{real:h,imag:p},backend:n});return c.forEach(m=>n.disposeIntermediateTensorInfo(m)),d.forEach(m=>n.disposeIntermediateTensorInfo(m)),n.disposeIntermediateTensorInfo(h),n.disposeIntermediateTensorInfo(p),f}let s=n.shouldExecuteOnCPU(e);if(r==="string"&&(s=!0),s){let c=e.map(y=>{let A=k.sizeFromShape(y.shape.slice(t));return ve({inputs:{x:y},backend:n,attrs:{shape:[-1,A]}})}),d=c.map(y=>({vals:n.readSync(y.dataId),shape:y.shape})),h=_.computeOutShape(c.map(y=>y.shape),1),p=c[0].shape[0]===1,f=spe(d,h,r,p),m=_.computeOutShape(e.map(y=>y.shape),t),g=n.makeTensorInfo(m,r,f);return c.forEach(y=>n.disposeIntermediateTensorInfo(y)),g}if(e.length>ae().getNumber("WEBGL_MAX_TEXTURES_IN_SHADER")){let c=Math.floor(e.length/2),d=Iu(e.slice(0,c),t,n),h=Iu(e.slice(c),t,n),p=Iu([d,h],t,n);return n.disposeIntermediateTensorInfo(d),n.disposeIntermediateTensorInfo(h),p}if(ae().getBool("WEBGL_PACK_ARRAY_OPERATIONS")&&e[0].shape.length>1){let c=new l0e(e.map(d=>d.shape),t);return n.runWebGLProgram(c,e,r)}let{tensors2D:a,outShape:o}=c0e(e,t,n),i=new i0e(a.map(c=>c.shape)),l=n.runWebGLProgram(i,a,r);a.forEach(c=>n.disposeIntermediateTensorInfo(c));let u=ve({inputs:{x:l},attrs:{shape:o},backend:n});return n.disposeIntermediateTensorInfo(l),u}function c0e(e,t,n){let r=_.computeOutShape(e.map(a=>a.shape),t);return{tensors2D:e.map(a=>ve({inputs:{x:a},attrs:{shape:[-1,k.sizeFromShape(a.shape.slice(t))]},backend:n})),outShape:r}}function WE(e){let{inputs:t,backend:n,attrs:r}=e,{axis:s}=r,a=k.parseAxisParam(s,t[0].shape)[0],o=_.computeOutShape(t.map(u=>u.shape),a);if(k.sizeFromShape(o)===0)return n.makeTensorInfo(o,t[0].dtype,[]);let i=t.filter(u=>k.sizeFromShape(u.shape)>0);if(i.length===1)return mr({inputs:{x:i[0]},backend:n});let l=i.map(u=>u.shape);return _.assertParamsConsistent(l,a),Iu(i,a,n)}var d0e={kernelName:Ec,backendName:"webgl",kernelFunc:WE},VE=class{constructor(e,t=!1,n=null,r=!1,s=!1){this.variableNames=["x","W"],this.outputShape=e.outShape;let a=e.padInfo.top,o=e.padInfo.left,i=e.strideHeight,l=e.strideWidth,u=e.dilationHeight,c=e.dilationWidth,d=e.filterHeight,h=e.filterWidth,p=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&&(r?x=`float activation(float a) {
|
|
float b = getPreluActivationWeightsAtOutCoords();
|
|
${n}
|
|
}`:s?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"),r&&this.variableNames.push("preluActivationWeights"),s&&this.variableNames.push("leakyreluAlpha"),this.userCode=`
|
|
${x}
|
|
|
|
const ivec2 strides = ivec2(${i}, ${l});
|
|
const ivec2 pads = ivec2(${a}, ${o});
|
|
|
|
void main() {
|
|
ivec4 coords = getOutputCoords();
|
|
int batch = coords[0];
|
|
int d2 = coords[${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 < ${d}; wR++) {
|
|
int xR = xRCorner + wR * ${u};
|
|
|
|
if (xR < 0 || xR >= ${e.inHeight}) {
|
|
continue;
|
|
}
|
|
|
|
for (int wC = 0; wC < ${h}; wC++) {
|
|
int xC = xCCorner + wC * ${c};
|
|
|
|
if (xC < 0 || xC >= ${e.inWidth}) {
|
|
continue;
|
|
}
|
|
|
|
for (int d1 = 0; d1 < ${p}; 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, ${p}) *
|
|
getW(wR, wC, ${p}, d2);
|
|
} else {
|
|
dotProd +=
|
|
getX(batch, ${p}, xR, xC) *
|
|
getW(wR, wC, ${p}, d2);
|
|
}
|
|
|
|
} else if (${f===2}) {
|
|
vec2 wValues = vec2(
|
|
getW(wR, wC, ${p}, d2),
|
|
getW(wR, wC, ${p} + 1, d2)
|
|
);
|
|
|
|
if (${m}) {
|
|
vec2 xValues = vec2(
|
|
getX(batch, xR, xC, ${p}),
|
|
getX(batch, xR, xC, ${p} + 1)
|
|
);
|
|
dotProd += dot(xValues, wValues);
|
|
} else {
|
|
vec2 xValues = vec2(
|
|
getX(batch, ${p}, xR, xC),
|
|
getX(batch, ${p} + 1, xR, xC)
|
|
);
|
|
dotProd += dot(xValues, wValues);
|
|
}
|
|
|
|
} else if (${f===3}) {
|
|
vec3 wValues = vec3(
|
|
getW(wR, wC, ${p}, d2),
|
|
getW(wR, wC, ${p} + 1, d2),
|
|
getW(wR, wC, ${p} + 2, d2)
|
|
);
|
|
|
|
if (${m}) {
|
|
vec3 xValues = vec3(
|
|
getX(batch, xR, xC, ${p}),
|
|
getX(batch, xR, xC, ${p} + 1),
|
|
getX(batch, xR, xC, ${p} + 2)
|
|
);
|
|
dotProd += dot(xValues, wValues);
|
|
} else {
|
|
vec3 xValues = vec3(
|
|
getX(batch, ${p}, xR, xC),
|
|
getX(batch, ${p} + 1, xR, xC),
|
|
getX(batch, ${p} + 2, xR, xC)
|
|
);
|
|
dotProd += dot(xValues, wValues);
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|
|
|
|
float result = dotProd;
|
|
${v}
|
|
${b}
|
|
setOutput(result);
|
|
}
|
|
`}},h0e=class{constructor(e){this.variableNames=["x","W"],this.outputShape=e.outShape;let t=e.padInfo.front,n=e.padInfo.top,r=e.padInfo.left,s=e.strideDepth,a=e.strideHeight,o=e.strideWidth,i=e.dilationDepth,l=e.dilationHeight,u=e.dilationWidth,c=e.filterDepth,d=e.filterHeight,h=e.filterWidth,p=Math.floor(e.inChannels/4)*4,f=e.inChannels%4;this.userCode=`
|
|
const ivec3 strides = ivec3(${s}, ${a}, ${o});
|
|
const ivec3 pads = ivec3(${t}, ${n}, ${r});
|
|
|
|
void main() {
|
|
ivec5 coords = getOutputCoords();
|
|
int batch = coords.x;
|
|
int d2 = coords.u;
|
|
|
|
ivec3 xFRCCorner = ivec3(coords.y, coords.z, coords.w) * strides - pads;
|
|
int xFCorner = xFRCCorner.x;
|
|
int xRCorner = xFRCCorner.y;
|
|
int xCCorner = xFRCCorner.z;
|
|
|
|
// Convolve x(?, ?, ?, d1) with w(:, :, :, d1, d2) to get
|
|
// y(yF, yR, yC, d2). ? = to be determined. : = across all
|
|
// values in that axis.
|
|
float dotProd = 0.0;
|
|
for (int wF = 0; wF < ${c}; wF++) {
|
|
int xF = xFCorner + wF * ${i};
|
|
|
|
if (xF < 0 || xF >= ${e.inDepth}) {
|
|
continue;
|
|
}
|
|
|
|
for (int wR = 0; wR < ${d}; wR++) {
|
|
int xR = xRCorner + wR * ${l};
|
|
|
|
if (xR < 0 || xR >= ${e.inHeight}) {
|
|
continue;
|
|
}
|
|
|
|
for (int wC = 0; wC < ${h}; wC++) {
|
|
int xC = xCCorner + wC * ${u};
|
|
|
|
if (xC < 0 || xC >= ${e.inWidth}) {
|
|
continue;
|
|
}
|
|
|
|
for (int d1 = 0; d1 < ${p}; 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, ${p}) *
|
|
getW(wF, wR, wC, ${p}, d2);
|
|
} else if (${f===2}) {
|
|
vec2 xValues = vec2(
|
|
getX(batch, xF, xR, xC, ${p}),
|
|
getX(batch, xF, xR, xC, ${p} + 1)
|
|
);
|
|
vec2 wValues = vec2(
|
|
getW(wF, wR, wC, ${p}, d2),
|
|
getW(wF, wR, wC, ${p} + 1, d2)
|
|
);
|
|
dotProd += dot(xValues, wValues);
|
|
} else if (${f===3}) {
|
|
vec3 xValues = vec3(
|
|
getX(batch, xF, xR, xC, ${p}),
|
|
getX(batch, xF, xR, xC, ${p} + 1),
|
|
getX(batch, xF, xR, xC, ${p} + 2)
|
|
);
|
|
vec3 wValues = vec3(
|
|
getW(wF, wR, wC, ${p}, d2),
|
|
getW(wF, wR, wC, ${p} + 1, d2),
|
|
getW(wF, wR, wC, ${p} + 2, d2)
|
|
);
|
|
dotProd += dot(xValues, wValues);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
setOutput(dotProd);
|
|
}
|
|
`}},p0e=class{constructor(e,t,n){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=e;let{filterWidth:r,inChannels:s,strideWidth:a,strideHeight:o,padInfo:i,outWidth:l,dilationWidth:u,dilationHeight:c,dataFormat:d}=n,{left:h,top:p}=i,f=s*r,m=Wn(),g=d==="channelsLast",y=g?0:1,A=g?1:2,x="";for(let b=0;b<=1;b++)for(let v=0;v<=1;v++)x+=`
|
|
blockIndex = rc.y + ${v};
|
|
pos = rc.x + ${b};
|
|
|
|
if(blockIndex < ${e[1]} && pos < ${e[0]}) {
|
|
offsetY = int(blockIndex / (${l})) * ${o} - ${p};
|
|
d0 = offsetY + ${c} * (pos / ${f});
|
|
|
|
if(d0 < ${t[y]} && d0 >= 0) {
|
|
|
|
offsetX = int(mod(float(blockIndex), ${l}.) * ${a}. - ${h}.);
|
|
d1 = offsetX + ${u} * (int(mod(float(pos), ${f}.) / ${s}.));
|
|
|
|
if(d1 < ${t[A]} && d1 >= 0) {
|
|
|
|
ch = int(mod(float(pos), ${s}.));
|
|
|
|
if (${g}) {
|
|
innerDims = vec2(d1, ch);
|
|
result[${b*2+v}] = getChannel(
|
|
getA(d0, int(innerDims.x),
|
|
int(innerDims.y)), innerDims);
|
|
} else {
|
|
innerDims = vec2(d0, d1);
|
|
result[${b*2+v}] = 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;
|
|
|
|
${x}
|
|
|
|
${m.output} = result;
|
|
}
|
|
`}};function UE({x:e,filter:t,convInfo:n,backend:r,bias:s=null,preluActivationWeights:a=null,leakyreluAlpha:o=0,activation:i=null}){let l=e.shape,u=r.texData.get(e.dataId),c=n.inChannels,d=l[0]*l[1]*l[2],h=n.outChannels,p=n.dataFormat==="channelsLast",f=!1,m=!1,g,y=[],A=(d===1||h===1)&&c>RE,x=l[2]%2!=0&&!!u.isPacked;if(A||!ae().getBool("WEBGL_LAZILY_UNPACK")||!ae().getBool("WEBGL_PACK_BINARY_OPERATIONS")||!x){let b=p?l[0]*l[1]*l[2]:l[0]*l[2]*l[3],v=ve({inputs:{x:e},backend:r,attrs:{shape:[1,b,n.inChannels]}}),w=ve({inputs:{x:t},backend:r,attrs:{shape:[1,n.inChannels,n.outChannels]}}),I=Km({a:v,b:w,transposeA:f,transposeB:m,backend:r,bias:s,activation:i,preluActivationWeights:a,leakyreluAlpha:o});g=ve({inputs:{x:I},backend:r,attrs:{shape:n.outShape}}),y.push(v),y.push(w),y.push(I)}else{let b=p?l[0]*l[1]*(l[2]+1):l[0]*l[2]*(l[3]+1),v={dataId:e.dataId,shape:[1,b,n.inChannels],dtype:e.dtype},w=u.shape;u.shape=u.shape.slice(),u.shape[u.shape.length-2]++,k.assert(uh(u.shape,v.shape),()=>`packed reshape ${u.shape} to ${v.shape} isn't free`);let I=ve({inputs:{x:t},backend:r,attrs:{shape:[1,n.inChannels,n.outChannels]}});y.push(I);let T=Km({a:v,b:I,backend:r,transposeA:f,transposeB:m,bias:s,activation:i,preluActivationWeights:a,leakyreluAlpha:o}),C=r.texData.get(T.dataId);k.assert(C.isPacked,()=>"batchMatMul result is expected to be packed"),u.shape=w,C.shape=n.outShape,g=mr({inputs:{x:T},backend:r}),g.shape=n.outShape,y.push(T)}for(let b of y)r.disposeIntermediateTensorInfo(b);return g}function HE({x:e,filter:t,convInfo:n,backend:r,bias:s=null,preluActivationWeights:a=null,leakyreluAlpha:o=0,activation:i=null}){let{filterWidth:l,filterHeight:u,inChannels:c,outWidth:d,outHeight:h,dataFormat:p}=n,f=p==="channelsLast",m=l*u*c,g=h*d,y=[m,g],A=!0,x=!1,b=[],v=ve({inputs:{x:e},backend:r,attrs:{shape:e.shape.slice(1)}}),w=ve({inputs:{x:t},backend:r,attrs:{shape:[1,m,k.sizeFromShape(t.shape)/m]}});b.push(v),b.push(w);let I=new p0e(y,v.shape,n),T=r.runWebGLProgram(I,[v],"float32"),C=ve({inputs:{x:T},backend:r,attrs:{shape:[1,y[0],y[1]]}});b.push(T),b.push(C);let M=s!=null,$=a!=null,R=i==="leakyrelu",N=i?Gm(i,!0):null,F=new NE(C.shape,w.shape,[1,g,n.outChannels],A,x,M,N,$,R),B=[C,w];if(s&&B.push(s),$&&B.push(a),R){let ee=r.makeTensorInfo([],"float32",k.createScalarValue(o,"float32"));B.push(ee),b.push(ee)}let j=r.runWebGLProgram(F,B,"float32"),X=f?[1,h,d,n.outChannels]:[1,n.outChannels,h,d],Y=ve({inputs:{x:j},backend:r,attrs:{shape:X}});b.push(j);for(let ee of b)r.disposeIntermediateTensorInfo(ee);return Y}function f0e(e){let{inputs:t,backend:n,attrs:r}=e,{x:s,filter:a}=t,{strides:o,pad:i,dataFormat:l,dilations:u,dimRoundingMode:c}=r,d=_.convertConv2DDataFormat(l),h=_.computeConv2DInfo(s.shape,a.shape,o,u,i,c,!1,d),p;if(h.filterHeight===1&&h.filterWidth===1&&h.dilationHeight===1&&h.dilationWidth===1&&h.strideHeight===1&&h.strideWidth===1&&(h.padInfo.type==="SAME"||h.padInfo.type==="VALID"))p=UE({x:s,filter:a,convInfo:h,backend:n});else if(ae().getBool("WEBGL_CONV_IM2COL")&&s.shape[0]===1)p=HE({x:s,filter:a,convInfo:h,backend:n});else{let m=new VE(h);p=n.runWebGLProgram(m,[s,a],"float32")}let f=ve({inputs:{x:p},backend:n,attrs:{shape:h.outShape}});return n.disposeIntermediateTensorInfo(p),f}var m0e={kernelName:tl,backendName:"webgl",kernelFunc:f0e},g0e=class{constructor(e){this.variableNames=["x","dy"],this.outputShape=e.filterShape;let t=e.strideHeight,n=e.strideWidth,r=e.padInfo.top,s=e.padInfo.left,a=e.dataFormat==="channelsLast";this.userCode=`
|
|
void main() {
|
|
ivec4 coords = getOutputCoords();
|
|
int wR = coords.x;
|
|
int wC = coords.y;
|
|
int d1 = coords.z;
|
|
int d2 = coords.w;
|
|
|
|
// Convolve x(?, ?, d1) with dy(:, :, d2) to get dw(wR, wC, d1, d2).
|
|
// ? = to be determined. : = across all values in that axis.
|
|
float dotProd = 0.0;
|
|
|
|
for (int b = 0; b < ${e.batchSize}; b++) {
|
|
for (int yR = 0; yR < ${e.outHeight}; yR++) {
|
|
int xR = wR + yR * ${t} - ${r};
|
|
|
|
if (xR < 0 || xR >= ${e.inHeight}) {
|
|
continue;
|
|
}
|
|
|
|
for (int yC = 0; yC < ${e.outWidth}; yC++) {
|
|
int xC = wC + yC * ${n} - ${s};
|
|
|
|
if (xC < 0 || xC >= ${e.inWidth}) {
|
|
continue;
|
|
}
|
|
|
|
if (${a}) {
|
|
float dyValue = getDy(b, yR, yC, d2);
|
|
float xValue = getX(b, xR, xC, d1);
|
|
dotProd += (xValue * dyValue);
|
|
} else {
|
|
float dyValue = getDy(b, d2, yR, yC);
|
|
float xValue = getX(b, d1, xR, xC);
|
|
dotProd += (xValue * dyValue);
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|
|
setOutput(dotProd);
|
|
}
|
|
`}},y0e=class{constructor(e){this.variableNames=["dy","W"],this.outputShape=e.inShape;let t=e.filterHeight,n=e.filterWidth,r=e.strideHeight,s=e.strideWidth,a=e.dataFormat==="channelsLast",o=t-1-e.padInfo.top,i=n-1-e.padInfo.left,l=a?1:2,u=a?2:3,c=a?3:1;this.userCode=`
|
|
const ivec2 pads = ivec2(${o}, ${i});
|
|
|
|
void main() {
|
|
ivec4 coords = getOutputCoords();
|
|
int batch = coords[0];
|
|
int d1 = coords[${c}];
|
|
|
|
ivec2 dyCorner = ivec2(coords[${l}], coords[${u}]) - pads;
|
|
int dyRCorner = dyCorner.x;
|
|
int dyCCorner = dyCorner.y;
|
|
|
|
// Convolve dy(?, ?, d2) with w(:, :, d1, d2) to compute dx(xR, xC, d1).
|
|
// ? = to be determined. : = across all values in that axis.
|
|
float dotProd = 0.0;
|
|
for (int wR = 0; wR < ${t}; wR++) {
|
|
float dyR = float(dyRCorner + wR) / ${r}.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) / ${s}.0;
|
|
|
|
if (dyC < 0.0 || dyC >= ${e.outWidth}.0 ||
|
|
fract(dyC) > 0.0) {
|
|
continue;
|
|
}
|
|
int idyC = int(dyC);
|
|
|
|
int wCPerm = ${n} - 1 - wC;
|
|
|
|
for (int d2 = 0; d2 < ${e.outChannels}; d2++) {
|
|
|
|
if (${a}) {
|
|
float xValue = getDy(batch, idyR, idyC, d2);
|
|
float wValue = getW(wRPerm, wCPerm, d1, d2);
|
|
dotProd += xValue * wValue;
|
|
} else {
|
|
float xValue = getDy(batch, d2, idyR, idyC);
|
|
float wValue = getW(wRPerm, wCPerm, d1, d2);
|
|
dotProd += xValue * wValue;
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|
|
setOutput(dotProd);
|
|
}
|
|
`}},A0e=class{constructor(e){this.variableNames=["x","dy"],this.outputShape=e.filterShape;let t=e.strideDepth,n=e.strideHeight,r=e.strideWidth,s=e.padInfo.front,a=e.padInfo.top,o=e.padInfo.left;this.userCode=`
|
|
void main() {
|
|
ivec5 coords = getOutputCoords();
|
|
int wF = coords.x;
|
|
int wR = coords.y;
|
|
int wC = coords.z;
|
|
int d1 = coords.w;
|
|
int d2 = coords.u;
|
|
|
|
float dotProd = 0.0;
|
|
|
|
for (int b = 0; b < ${e.batchSize}; b++) {
|
|
for (int yF = 0; yF < ${e.outDepth}; yF++) {
|
|
int xF = wF + yF * ${t} - ${s};
|
|
|
|
if (xF < 0 || xF >= ${e.inDepth}) {
|
|
continue;
|
|
}
|
|
|
|
for (int yR = 0; yR < ${e.outHeight}; yR++) {
|
|
int xR = wR + yR * ${n} - ${a};
|
|
|
|
if (xR < 0 || xR >= ${e.inHeight}) {
|
|
continue;
|
|
}
|
|
|
|
for (int yC = 0; yC < ${e.outWidth}; yC++) {
|
|
int xC = wC + yC * ${r} - ${o};
|
|
|
|
if (xC < 0 || xC >= ${e.inWidth}) {
|
|
continue;
|
|
}
|
|
|
|
float dyValue = getDy(b, yF, yR, yC, d2);
|
|
float xValue = getX(b, xF, xR, xC, d1);
|
|
dotProd += (xValue * dyValue);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
setOutput(dotProd);
|
|
}
|
|
`}},x0e=class{constructor(e){this.variableNames=["dy","W"],this.outputShape=e.inShape;let t=e.filterDepth,n=e.filterHeight,r=e.filterWidth,s=e.strideDepth,a=e.strideHeight,o=e.strideWidth,i=t-1-e.padInfo.front,l=n-1-e.padInfo.top,u=r-1-e.padInfo.left;this.userCode=`
|
|
const ivec3 pads = ivec3(${i}, ${l}, ${u});
|
|
|
|
void main() {
|
|
ivec5 coords = getOutputCoords();
|
|
int batch = coords.x;
|
|
int d1 = coords.u;
|
|
|
|
|
|
ivec3 dyCorner = ivec3(coords.y, coords.z, coords.w) - pads;
|
|
int dyFCorner = dyCorner.x;
|
|
int dyRCorner = dyCorner.y;
|
|
int dyCCorner = dyCorner.z;
|
|
|
|
float dotProd = 0.0;
|
|
for (int wF = 0; wF < ${t}; wF++) {
|
|
float dyF = float(dyFCorner + wF) / ${s}.0;
|
|
|
|
if (dyF < 0.0 || dyF >= ${e.outDepth}.0 || fract(dyF) > 0.0) {
|
|
continue;
|
|
}
|
|
int idyF = int(dyF);
|
|
|
|
int wFPerm = ${t} - 1 - wF;
|
|
|
|
for (int wR = 0; wR < ${n}; wR++) {
|
|
float dyR = float(dyRCorner + wR) / ${a}.0;
|
|
|
|
if (dyR < 0.0 || dyR >= ${e.outHeight}.0 ||
|
|
fract(dyR) > 0.0) {
|
|
continue;
|
|
}
|
|
int idyR = int(dyR);
|
|
|
|
int wRPerm = ${n} - 1 - wR;
|
|
|
|
for (int wC = 0; wC < ${r}; wC++) {
|
|
float dyC = float(dyCCorner + wC) / ${o}.0;
|
|
|
|
if (dyC < 0.0 || dyC >= ${e.outWidth}.0 ||
|
|
fract(dyC) > 0.0) {
|
|
continue;
|
|
}
|
|
int idyC = int(dyC);
|
|
|
|
int wCPerm = ${r} - 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 b0e(e){let{inputs:t,backend:n,attrs:r}=e,{x:s,dy:a}=t,{strides:o,pad:i,dataFormat:l,dimRoundingMode:u,filterShape:c}=r,d=_.convertConv2DDataFormat(l),h=_.computeConv2DInfo(s.shape,c,o,1,i,u,!1,d),p=new g0e(h);return n.runWebGLProgram(p,[s,a],"float32")}var v0e={kernelName:Sy,backendName:"webgl",kernelFunc:b0e};function w0e(e){let{inputs:t,backend:n,attrs:r}=e,{dy:s,filter:a}=t,{inputShape:o,strides:i,pad:l,dataFormat:u,dimRoundingMode:c}=r,d=_.convertConv2DDataFormat(u),h=_.computeConv2DInfo(o,a.shape,i,1,l,c,!1,d),p=new y0e(h);return n.runWebGLProgram(p,[s,a],"float32")}var k0e={kernelName:nl,backendName:"webgl",kernelFunc:w0e};function I0e(e){let{inputs:t,backend:n,attrs:r}=e,{x:s,filter:a}=t,{strides:o,pad:i,dilations:l}=r,u=_.computeConv3DInfo(s.shape,a.shape,o,l,i),c=new h0e(u);return n.runWebGLProgram(c,[s,a],"float32")}var S0e={kernelName:Yp,backendName:"webgl",kernelFunc:I0e};function T0e(e){let{inputs:t,backend:n,attrs:r}=e,{x:s,dy:a}=t,{strides:o,pad:i,filterShape:l}=r,u=_.computeConv3DInfo(s.shape,l,o,1,i),c=new A0e(u);return n.runWebGLProgram(c,[s,a],"float32")}var N0e={kernelName:Ty,backendName:"webgl",kernelFunc:T0e};function C0e(e){let{inputs:t,backend:n,attrs:r}=e,{dy:s,filter:a}=t,{pad:o,strides:i,inputShape:l}=r,u=_.computeConv3DInfo(l,a.shape,i,1,o),c=new x0e(u);return n.runWebGLProgram(c,[s,a],"float32")}var E0e={kernelName:Ny,backendName:"webgl",kernelFunc:C0e},$0e=TE+`
|
|
return cos(x);
|
|
`,_0e=it({opSnippet:$0e}),R0e={kernelName:rl,backendName:"webgl",kernelFunc:_0e},D0e=`
|
|
float e2x = exp(-x);
|
|
return (e2x + 1.0 / e2x) / 2.0;
|
|
`,F0e=it({opSnippet:D0e}),M0e={kernelName:$c,backendName:"webgl",kernelFunc:F0e},O0e=class{constructor(e,t,n,r,s){this.variableNames=["Image","Boxes","BoxInd"],this.outputShape=[];let[a,o,i,l]=e,[u]=t,[c,d]=n;this.outputShape=[u,c,d,l];let h=r==="bilinear"?1:0,[p,f]=[`${o-1}.0`,`${i-1}.0`],[m,g,y]=c>1?[`${(o-1)/(c-1)}`,"(y2-y1) * height_ratio",`y1*${p} + float(y)*(height_scale)`]:["0.0","0.0",`0.5 * (y1+y2) * ${p}`],[A,x,b]=d>1?[`${(i-1)/(d-1)}`,"(x2-x1) * width_ratio",`x1*${f} + float(x)*(width_scale)`]:["0.0","0.0",`0.5 * (x1+x2) * ${f}`];this.userCode=`
|
|
const float height_ratio = float(${m});
|
|
const float width_ratio = float(${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 >= ${a}) {
|
|
return;
|
|
}
|
|
|
|
float height_scale = ${g};
|
|
float width_scale = ${x};
|
|
|
|
float in_y = ${y};
|
|
if( in_y < 0.0 || in_y > ${p} ) {
|
|
setOutput(float(${s}));
|
|
return;
|
|
}
|
|
float in_x = ${b};
|
|
if( in_x < 0.0 || in_x > ${f} ) {
|
|
setOutput(float(${s}));
|
|
return;
|
|
}
|
|
|
|
vec2 sourceFracIndexCR = vec2(in_x,in_y);
|
|
if(${h} == 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);
|
|
}
|
|
}
|
|
`}},P0e=e=>{let{inputs:t,backend:n,attrs:r}=e,{image:s,boxes:a,boxInd:o}=t,{cropSize:i,method:l,extrapolationValue:u}=r,c=new O0e(s.shape,a.shape,i,l,u);return n.runWebGLProgram(c,[s,a,o],"float32")},z0e={kernelName:_c,backendName:"webgl",kernelFunc:P0e},GE=class{constructor(e,t,n){this.variableNames=["x"],this.outputShape=e;let r=e.length,s=t?"0.0":`getX(${jE(r,"coords")})`,a=e[e.length-1],o="",i="";t?(o=n?`end != ${a-1}`:"end != 0",i=n?"end + 1":"end - 1"):(o=n?`end + pow2 < ${a}`:"end >= pow2",i=n?"end + pow2":"end - pow2"),this.userCode=`
|
|
uniform float index;
|
|
void main() {
|
|
${It(r)} coords = getOutputCoords();
|
|
int end = ${qE(r,"coords")};
|
|
float val = ${s};
|
|
int pow2 = int(pow(2.0, index));
|
|
if (${o}) {
|
|
int idx = ${i};
|
|
${qE(r,"coords")} = idx;
|
|
val += getX(${jE(r,"coords")});
|
|
}
|
|
setOutput(val);
|
|
}
|
|
`}getCustomSetupFunc(e){return(t,n)=>{this.index==null&&(this.index=t.getUniformLocation(n,"index")),t.gl.uniform1f(this.index,e)}}};function jE(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 qE(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 L0e(e){let{inputs:t,backend:n,attrs:r}=e,{x:s}=t,{axis:a,exclusive:o,reverse:i}=r,l=s.shape.length,u=_.getAxesPermutation([a],l),c=s;u!=null&&(c=Un({inputs:{x:s},backend:n,attrs:{perm:u}}));let d=_.getInnerMostAxes(1,l)[0];if(d!==l-1)throw new Error(`WebGL cumsum shader expects an inner-most axis=${s.shape.length-1} but got axis=${a}`);let h=c.shape[d],p=mr({inputs:{x:c},backend:n});for(let f=0;f<=Math.ceil(Math.log2(h))-1;f++){let m=new GE(c.shape,!1,i),g=m.getCustomSetupFunc(f),y=p;p=n.runWebGLProgram(m,[p],p.dtype,g),n.disposeIntermediateTensorInfo(y)}if(o){let f=new GE(c.shape,o,i),m=p;p=n.runWebGLProgram(f,[p],p.dtype),n.disposeIntermediateTensorInfo(m)}if(u!=null){let f=_.getUndoAxesPermutation(u),m=Un({inputs:{x:p},backend:n,attrs:{perm:f}});return n.disposeIntermediateTensorInfo(p),n.disposeIntermediateTensorInfo(c),m}return p}var B0e={kernelName:sl,backendName:"webgl",kernelFunc:L0e};function W0e(e){let{inputs:t,backend:n,attrs:r}=e,{x:s,weights:a}=t,{size:o,binaryOutput:i}=r;if(s.shape.length===1){let l=n.readSync(s.dataId),u=n.readSync(a.dataId),c=cE(l,u,a.dtype,a.shape,o);return n.makeTensorInfo([o],a.dtype,c)}else if(s.shape.length===2){let l=n.bufferSync(s),u=n.bufferSync(a),c=npe(l,u,o,i);return n.makeTensorInfo(c.shape,a.dtype,c.values)}throw new Error(`Error in denseBincount: input must be at most rank 2, but got rank${s.shape.length}.`)}var V0e={kernelName:Cy,backendName:"webgl",kernelFunc:W0e},U0e=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 H0e(e){let{inputs:t,backend:n,attrs:r}=e,{x:s}=t,{blockSize:a,dataFormat:o}=r;k.assert(a>1,()=>`blockSize should be > 1 for depthToSpace, but was: ${a}`);let i=s.shape[0],l=o==="NHWC"?s.shape[1]:s.shape[2],u=o==="NHWC"?s.shape[2]:s.shape[3],c=o==="NHWC"?s.shape[3]:s.shape[1],d=l*a,h=u*a,p=c/(a*a),f=o==="NHWC"?[i,d,h,p]:[i,p,d,h],m=new U0e(f,a,o);return n.runWebGLProgram(m,[s],s.dtype)}var G0e={kernelName:Rc,backendName:"webgl",kernelFunc:H0e},KE=class{constructor(e,t=!1,n=null,r=!1,s=!1){this.variableNames=["x","W"],this.outputShape=e.outShape;let a=e.inHeight,o=e.inWidth,i=e.padInfo.top,l=e.padInfo.left,u=e.strideHeight,c=e.strideWidth,d=e.dilationHeight,h=e.dilationWidth,p=e.filterHeight,f=e.filterWidth,m=e.outChannels/e.inChannels,g="",y="";n&&(r?g=`float activation(float a) {
|
|
float b = getPreluActivationWeightsAtOutCoords();
|
|
${n}
|
|
}`:s?g=`float activation(float a) {
|
|
float b = getLeakyreluAlphaAtOutCoords();
|
|
${n}
|
|
}`:g=`
|
|
float activation(float x) {
|
|
${n}
|
|
}
|
|
`,y="result = activation(result);");let A=t?"result += getBiasAtOutCoords();":"";t&&this.variableNames.push("bias"),r&&this.variableNames.push("preluActivationWeights"),s&&this.variableNames.push("leakyreluAlpha"),this.userCode=`
|
|
${g}
|
|
|
|
const ivec2 strides = ivec2(${u}, ${c});
|
|
const ivec2 pads = ivec2(${i}, ${l});
|
|
|
|
void main() {
|
|
ivec4 coords = getOutputCoords();
|
|
int batch = coords.x;
|
|
ivec2 xRCCorner = coords.yz * strides - pads;
|
|
int d2 = coords.w;
|
|
int d1 = d2 / ${m};
|
|
int q = d2 - d1 * ${m};
|
|
|
|
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 < ${p}; wR++) {
|
|
int xR = xRCorner + wR * ${d};
|
|
|
|
if (xR < 0 || xR >= ${a}) {
|
|
continue;
|
|
}
|
|
|
|
for (int wC = 0; wC < ${f}; wC++) {
|
|
int xC = xCCorner + wC * ${h};
|
|
|
|
if (xC < 0 || xC >= ${o}) {
|
|
continue;
|
|
}
|
|
|
|
float xVal = getX(batch, xR, xC, d1);
|
|
float wVal = getW(wR, wC, d1, q);
|
|
dotProd += xVal * wVal;
|
|
}
|
|
}
|
|
|
|
float result = dotProd;
|
|
${A}
|
|
${y}
|
|
setOutput(result);
|
|
}
|
|
`}},XE=class{constructor(e,t=!1,n=null,r=!1,s=!1){this.variableNames=["x","W"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=e.outShape;let a=e.outChannels/e.inChannels,o=e.inHeight,i=e.inWidth,l=e.padInfo.top,u=e.padInfo.left,c=e.strideHeight,d=e.strideWidth,h=e.dilationHeight,p=e.dilationWidth,f=e.filterHeight,m=e.filterWidth,g=m,y=`
|
|
int xR; int xC; int xCOffset;
|
|
vec4 wTexel; vec4 previous; vec4 final;`;for(let v=0;v<m;v++)y+=`
|
|
vec4 xTexelC${v*2};
|
|
int xTexelC${v*2}Ready;
|
|
vec4 xC${v};`;for(let v=0;v<f;v++){for(let w=0;w<m;w++)y+=`
|
|
xTexelC${w*2} = vec4(0.0);
|
|
xTexelC${w*2}Ready = 0;
|
|
xC${w} = vec4(0.0);`;y+=`
|
|
xR = xRCorner + ${v*h};
|
|
if (xR >=0 && xR < ${o}) {
|
|
`;for(let w=0;w<(g+1)/2;w++){let I=w*2,T=I*p;if(y+=`
|
|
xC = xCCorner + ${T};
|
|
`,d===1){if(I<m&&(u%2==1?(y+=`
|
|
xCOffset = xC + 1;
|
|
if (xCOffset >= 0 && xCOffset < ${i} && xTexelC${T}Ready == 0) {
|
|
xTexelC${T} = getX(batch, xR, xCOffset, d1);
|
|
|
|
// Need to manually clear unused channels in case
|
|
// we're reading from recycled texture.
|
|
if (xCOffset + 1 >= ${i}) {
|
|
xTexelC${T}.zw = vec2(0.0);
|
|
}
|
|
xTexelC${T}Ready = 1;
|
|
}
|
|
`,p===1&&T>0?y+=`
|
|
xC${I} = vec4(xTexelC${T-2}.zw, xTexelC${T}.xy);
|
|
`:y+=`
|
|
xCOffset = xC + 1 - 2;
|
|
|
|
if (xCOffset >= 0 && xCOffset < ${i}) {
|
|
previous = getX(batch, xR, xCOffset, d1);
|
|
|
|
// Need to manually clear unused channels in case
|
|
// we're reading from recycled texture.
|
|
if (xCOffset + 1 >= ${i}) {
|
|
previous.zw = vec2(0.0);
|
|
}
|
|
|
|
xC${I} = vec4(previous.zw, xTexelC${T}.xy);
|
|
} else {
|
|
xC${I} = vec4(0.0, 0.0, xTexelC${T}.xy);
|
|
}
|
|
`):y+=`
|
|
if (xC >= 0 && xC < ${i} && xTexelC${T}Ready == 0) {
|
|
xTexelC${T} = getX(batch, xR, xC, d1);
|
|
if (xC + 1 >= ${i}) {
|
|
xTexelC${T}.zw = vec2(0.0);
|
|
}
|
|
xTexelC${T}Ready = 1;
|
|
}
|
|
|
|
xC${I} = xTexelC${T};
|
|
`,T+1<m)){let C=u%2==0?k.nearestLargerEven(p):p;p%2==0&&u%2==1||p%2!=0&&u%2!=1?(y+=`
|
|
xCOffset = xC + ${u%2} + ${C};
|
|
|
|
if (xCOffset >= 0 && xCOffset < ${i} && xTexelC${T+2}Ready == 0) {
|
|
xTexelC${T+2} = getX(batch, xR, xCOffset, d1);
|
|
|
|
// Need to manually clear unused channels in case
|
|
// we're reading from recycled texture.
|
|
if (xCOffset + 1 >= ${i}) {
|
|
xTexelC${T+2}.zw = vec2(0.0);
|
|
}
|
|
xTexelC${T+2}Ready = 1;
|
|
}
|
|
`,p>1&&(y+=`
|
|
xCOffset -= 2;
|
|
if (xCOffset >= 0 && xCOffset < ${i} && xTexelC${T}Ready == 0) {
|
|
xTexelC${T} = getX(batch, xR, xCOffset, d1);
|
|
xTexelC${T}Ready = 1;
|
|
}
|
|
`),y+=`
|
|
xC${I+1} = vec4(xTexelC${T}.zw, xTexelC${T+2}.xy);
|
|
`):C===1?y+=`
|
|
xC${I+1} = xTexelC${T};
|
|
`:y+=`
|
|
xCOffset = xC + ${C};
|
|
|
|
if (xCOffset >= 0 && xCOffset < ${i} && xTexelC${T+2}Ready == 0) {
|
|
xTexelC${T+2} = getX(batch, xR, xCOffset, d1);
|
|
if (xCOffset + 1 >= ${i}) {
|
|
xTexelC${T+2}.zw = vec2(0.0);
|
|
}
|
|
xTexelC${T+2}Ready = 1;
|
|
}
|
|
|
|
xC${I+1} = xTexelC${T+2};
|
|
`}}else T<m&&(u%2==1?(y+=`
|
|
xCOffset = xC + 1 - ${d};
|
|
if(xCOffset >= 0 && xCOffset < ${i} && xTexelC${T}Ready == 0) {
|
|
xTexelC${T} = getX(batch, xR, xCOffset, d1);
|
|
// Need to manually clear unused channels in case
|
|
// we're reading from recycled texture.
|
|
if (xCOffset + 1 >= ${i}) {
|
|
xTexelC${T}.zw = vec2(0.0);
|
|
}
|
|
xTexelC${T}Ready = 1;
|
|
}
|
|
|
|
if(xC + 1 >= 0 && xC + 1 < ${i} && xTexelC${T+2}Ready == 0) {
|
|
xTexelC${T+2} = getX(batch, xR, xC + 1, d1);
|
|
// Need to manually clear unused channels in case
|
|
// we're reading from recycled texture.
|
|
if (xC + 2 >= ${i}) {
|
|
xTexelC${T+2}.zw = vec2(0.0);
|
|
}
|
|
xTexelC${T+2}Ready = 1;
|
|
}
|
|
|
|
xC${I} = vec4(xTexelC${T}.zw, xTexelC${T+2}.zw);
|
|
`,T+1<m&&(y+=`
|
|
final = vec4(0.0);
|
|
xCOffset = xC + 1 + ${d};
|
|
if(xCOffset >= 0 && xCOffset < ${i}) {
|
|
final = getX(batch, xR, xCOffset, d1);
|
|
}
|
|
xC${I+1} = vec4(xTexelC${T+2}.xy, final.xy);
|
|
`)):(y+=`
|
|
if(xC >= 0 && xC < ${i} && xTexelC${T}Ready == 0) {
|
|
xTexelC${T} = getX(batch, xR, xC, d1);
|
|
if (xC + 1 >= ${i}) {
|
|
xTexelC${T}.zw = vec2(0.0);
|
|
}
|
|
xTexelC${T}Ready = 1;
|
|
}
|
|
|
|
xCOffset = xC + ${d};
|
|
if(xCOffset >= 0 && xCOffset < ${i} && xTexelC${T+2}Ready == 0) {
|
|
xTexelC${T+2} = getX(batch, xR, xCOffset, d1);
|
|
if (xCOffset + 1 >= ${i}) {
|
|
xTexelC${T+2}.zw = vec2(0.);
|
|
}
|
|
xTexelC${T+2}Ready = 1;
|
|
}
|
|
|
|
xC${I} = vec4(
|
|
xTexelC${T}.xy, xTexelC${T+2}.xy);
|
|
`,T+1<m&&(y+=`
|
|
xC${I+1} = vec4(xTexelC${T}.zw, xTexelC${T+2}.zw);
|
|
`)));I<m&&(y+=`
|
|
wTexel = getW(${v}, ${T}, d1, q);
|
|
dotProd += xC${I} * vec4(wTexel.xz, wTexel.xz);
|
|
`,T+1<m&&(y+=`
|
|
wTexel = getW(${v}, ${T+1}, d1, q);
|
|
dotProd += xC${I+1} * vec4(wTexel.xz, wTexel.xz);
|
|
`))}y+=`
|
|
}
|
|
`}let A="",x="";n&&(r?A=`vec4 activation(vec4 a) {
|
|
vec4 b = getPreluActivationWeightsAtOutCoords();
|
|
${n}
|
|
}`:s?A=`vec4 activation(vec4 a) {
|
|
vec4 b = getLeakyreluAlphaAtOutCoords();
|
|
${n}
|
|
}`:A=`vec4 activation(vec4 x) {
|
|
${n}
|
|
}`,x="result = activation(result);");let b=t?"result += getBiasAtOutCoords();":"";t&&this.variableNames.push("bias"),r&&this.variableNames.push("preluActivationWeights"),s&&this.variableNames.push("leakyreluAlpha"),this.userCode=`
|
|
${A}
|
|
|
|
const ivec2 strides = ivec2(${c}, ${d});
|
|
const ivec2 pads = ivec2(${l}, ${u});
|
|
|
|
void main() {
|
|
|
|
ivec4 coords = getOutputCoords();
|
|
int batch = coords.x;
|
|
ivec2 xRCCorner = coords.yz * strides - pads;
|
|
int d2 = coords.w;
|
|
int d1 = d2 / ${a};
|
|
int q = d2 - d1 * ${a};
|
|
int xRCorner = xRCCorner.x;
|
|
int xCCorner = xRCCorner.y;
|
|
|
|
//intialize dotProd with a small epsilon seems to reduce GPU accuracy loss.
|
|
vec4 dotProd = vec4(0.000000000000001);
|
|
|
|
${y}
|
|
|
|
vec4 result = dotProd - vec4(0.000000000000001);
|
|
${b}
|
|
${x}
|
|
setOutput(result);
|
|
}
|
|
`}};function j0e(e){let{inputs:t,backend:n,attrs:r}=e,{x:s,filter:a}=t,{strides:o,pad:i,dilations:l,dimRoundingMode:u}=r,c=l;c==null&&(c=[1,1]),k.assert(_.eitherStridesOrDilationsAreOne(o,c),()=>`Error in depthwiseConv2d: Either strides or dilations must be 1. Got strides ${o} and dilations '${c}'`);let d=_.computeConv2DInfo(s.shape,a.shape,o,c,i,u,!0),h;return ae().getBool("WEBGL_PACK_DEPTHWISECONV")&&d.strideWidth<=2&&d.outChannels/d.inChannels==1?h=new XE(d):h=new KE(d),n.runWebGLProgram(h,[s,a],"float32")}var q0e={kernelName:al,backendName:"webgl",kernelFunc:j0e},K0e=class{constructor(e){this.variableNames=["x","dy"],this.outputShape=e.filterShape;let t=e.strideHeight,n=e.strideWidth,r=e.padInfo.top,s=e.padInfo.left,a=e.outChannels/e.inChannels;this.userCode=`
|
|
void main() {
|
|
ivec4 coords = getOutputCoords();
|
|
int wR = coords.x;
|
|
int wC = coords.y;
|
|
int d1 = coords.z;
|
|
int dm = coords.w;
|
|
int d2 = d1 * ${a} + dm;
|
|
|
|
float dotProd = 0.0;
|
|
|
|
// TO DO: Vec4 over the batch size
|
|
for (int b = 0; b < ${e.batchSize}; b++) {
|
|
for (int yR = 0; yR < ${e.outHeight}; yR++) {
|
|
int xR = wR + yR * ${t} - ${r};
|
|
|
|
if (xR < 0 || xR >= ${e.inHeight}) {
|
|
continue;
|
|
}
|
|
|
|
for (int yC = 0; yC < ${e.outWidth}; yC++) {
|
|
int xC = wC + yC * ${n} - ${s};
|
|
|
|
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);
|
|
}
|
|
`}},X0e=class{constructor(e){this.variableNames=["dy","W"],this.outputShape=e.inShape;let t=e.filterHeight,n=e.filterWidth,r=e.strideHeight,s=e.strideWidth,a=t-1-e.padInfo.top,o=n-1-e.padInfo.left,i=e.outChannels/e.inChannels;this.userCode=`
|
|
const ivec2 pads = ivec2(${a}, ${o});
|
|
|
|
void main() {
|
|
ivec4 coords = getOutputCoords();
|
|
int batch = coords[0];
|
|
int d1 = coords[3];
|
|
ivec2 dyCorner = coords.yz - pads;
|
|
int dyRCorner = dyCorner.x;
|
|
int dyCCorner = dyCorner.y;
|
|
|
|
float dotProd = 0.0;
|
|
|
|
for (int wR = 0; wR < ${t}; wR++) {
|
|
float dyR = float(dyRCorner + wR) / ${r}.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) / ${s}.0;
|
|
|
|
if (dyC < 0.0 || dyC >= ${e.outWidth}.0 ||
|
|
fract(dyC) > 0.0) {
|
|
continue;
|
|
}
|
|
int idyC = int(dyC);
|
|
|
|
int wCPerm = ${n} - 1 - wC;
|
|
|
|
// TO DO: Vec4 over the channelMul
|
|
for (int dm = 0; dm < ${i}; dm++) {
|
|
int d2 = d1 * ${i} + dm;
|
|
float xValue = getDy(batch, idyR, idyC, d2);
|
|
float wValue = getW(wRPerm, wCPerm, d1, dm);
|
|
dotProd += xValue * wValue;
|
|
}
|
|
}
|
|
}
|
|
setOutput(dotProd);
|
|
}
|
|
`}};function Z0e(e){let{inputs:t,backend:n,attrs:r}=e,{x:s,dy:a}=t,{strides:o,dilations:i,pad:l,dimRoundingMode:u,filterShape:c}=r,d=_.computeConv2DInfo(s.shape,c,o,i,l,u,!0),h=new K0e(d);return n.runWebGLProgram(h,[s,a],"float32")}var Y0e={kernelName:Ey,backendName:"webgl",kernelFunc:Z0e};function J0e(e){let{inputs:t,backend:n,attrs:r}=e,{dy:s,filter:a}=t,{strides:o,dilations:i,pad:l,dimRoundingMode:u,inputShape:c}=r,d=_.computeConv2DInfo(c,a.shape,o,i,l,u,!0),h=new X0e(d);return n.runWebGLProgram(h,[s,a],"float32")}var Q0e={kernelName:$y,backendName:"webgl",kernelFunc:J0e},ege=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 tge(e){let{inputs:t,backend:n}=e,{x:r}=t,s=[...r.shape,...r.shape],a=k.sizeFromShape(r.shape),o=ve({inputs:{x:r},backend:n,attrs:{shape:[a]}}),i=new ege(a),l=n.runWebGLProgram(i,[o],o.dtype),u=ve({inputs:{x:l},backend:n,attrs:{shape:s}});return n.disposeIntermediateTensorInfo(o),n.disposeIntermediateTensorInfo(l),u}var nge={kernelName:_y,backendName:"webgl",kernelFunc:tge},rge=class{constructor(e){this.variableNames=["x","W"],this.outputShape=e.outShape;let{inHeight:t,inWidth:n,padInfo:r,strideHeight:s,strideWidth:a,filterHeight:o,filterWidth:i,dilationHeight:l,dilationWidth:u}=e,{top:c,left:d}=r;this.userCode=`
|
|
const ivec2 strides = ivec2(${s}, ${a});
|
|
const ivec2 pads = ivec2(${c}, ${d});
|
|
const float neg_infinity = -3.4e38;
|
|
|
|
void main() {
|
|
ivec4 coords = getOutputCoords();
|
|
int batch = coords.x;
|
|
int d1 = coords.w;
|
|
ivec2 outTopLeftCorner =
|
|
coords.yz * strides - pads;
|
|
int hBeg = outTopLeftCorner.x;
|
|
int wBeg = outTopLeftCorner.y;
|
|
|
|
float curVal = neg_infinity;
|
|
for (int h = 0; h < ${o}; h++) {
|
|
int hIn = hBeg + h * ${l};
|
|
|
|
if (hIn >= 0 && hIn < ${t}) {
|
|
for (int w = 0; w < ${i}; w++) {
|
|
int wIn = wBeg + w * ${u};
|
|
|
|
if (wIn >= 0 && wIn < ${n}) {
|
|
float xVal = getX(batch, hIn, wIn, d1);
|
|
float wVal = getW(h, w, d1);
|
|
|
|
float val = xVal + wVal;
|
|
if (val > curVal) {
|
|
curVal = val;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
float result = curVal;
|
|
setOutput(result);
|
|
}
|
|
`}};function sge(e){let{inputs:t,backend:n,attrs:r}=e,{x:s,filter:a}=t,{strides:o,pad:i,dilations:l}=r,u=_.computeDilation2DInfo(s.shape,a.shape,o,i,"NHWC",l),c,d=new rge(u);c=n.runWebGLProgram(d,[s,a],"float32");let h=ve({inputs:{x:c},backend:n,attrs:{shape:u.outShape}});return n.disposeIntermediateTensorInfo(c),h}var age={kernelName:Jp,backendName:"webgl",kernelFunc:sge};function oge(e){let{inputs:t,backend:n,attrs:r}=e,{equation:s}=r,a=t,{allDims:o,summedDims:i,idDims:l}=_.decodeEinsumEquation(s,a.length);_.checkEinsumDimSizes(o.length,l,a);let{path:u,steps:c}=_.getEinsumComputePath(i,l),d=c.length,h=null,p=o.length,f=[];for(let m=0;m<d;++m){for(let g of c[m]){let{permutationIndices:y,expandDims:A}=_.getEinsumPermutation(p,l[g]),x;_.isIdentityPermutation(y)?x=a[g]:(x=Un({inputs:{x:a[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);k.arraysEqual(x.shape,b)||(x=ve({inputs:{x},backend:n,attrs:{shape:b}}),f.push(x)),h===null?h=x:(h=ib({inputs:{a:x,b:h},backend:n}),f.push(h))}m<d-1&&(u[m]>=0&&(h=qm({inputs:{x:h},backend:n,attrs:{axis:u[m]-(o.length-p),keepDims:!1}}),f.push(h)),p--)}for(let m of f)m!==h&&n.disposeIntermediateTensorInfo(m);return h}var ige={kernelName:Fy,backendName:"webgl",kernelFunc:oge},lge="return (x >= 0.0) ? x : (exp(x) - 1.0);",uge=`
|
|
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;
|
|
`,cge=it({opSnippet:lge,packedOpSnippet:uge}),dge={kernelName:Dc,backendName:"webgl",kernelFunc:cge},hge="return (b >= 1.0) ? a : a * (b + 1.0);",pge=`
|
|
vec4 bGTEZero = vec4(greaterThanEqual(b, vec4(0.)));
|
|
return (bGTEZero * a) + ((vec4(1.0) - bGTEZero) * (a * (b + vec4(1.0))));
|
|
`,fge=e=>{let{inputs:t,backend:n}=e,{dy:r,y:s}=t,a=ae().getBool("WEBGL_PACK_BINARY_OPERATIONS")?new hh(pge,r.shape,s.shape):new ku(hge,r.shape,s.shape);return n.runWebGLProgram(a,[r,s],r.dtype)},mge={kernelName:My,backendName:"webgl",kernelFunc:fge},gge=`
|
|
return vec4(equal(a, b));
|
|
`,yge="return float(a == b);",Age=Nn({opSnippet:yge,packedOpSnippet:gge,dtype:"bool",cpuKernelImpl:ape}),xge={kernelName:il,backendName:"webgl",kernelFunc:Age},bge=`
|
|
// Error function is calculated approximately with elementary function.
|
|
// See "Handbook of Mathematical Functions with Formulas,
|
|
// Graphs, and Mathematical Tables", Abramowitz and Stegun.
|
|
float p = ${_.ERF_P};
|
|
float a1 = ${_.ERF_A1};
|
|
float a2 = ${_.ERF_A2};
|
|
float a3 = ${_.ERF_A3};
|
|
float a4 = ${_.ERF_A4};
|
|
float a5 = ${_.ERF_A5};
|
|
|
|
float sign = sign(x);
|
|
x = abs(x);
|
|
float t = 1.0 / (1.0 + p * x);
|
|
return sign * (1.0 - (((((a5*t + a4)*t) + a3)*t + a2)*t + a1)*t*exp(-x*x));
|
|
`,vge=it({opSnippet:bge}),wge={kernelName:Fc,backendName:"webgl",kernelFunc:vge},ZE="return exp(x);",YE=it({opSnippet:ZE,packedOpSnippet:ZE,cpuKernelImpl:ope}),kge={kernelName:Eo,backendName:"webgl",kernelFunc:YE};function db(e){let{inputs:t,attrs:n,backend:r}=e,{dim:s}=n,{input:a}=t,o=a.shape.length,i=a.shape.slice(),l=s;return s<0&&(k.assert(-(o+1)<=s,()=>`Axis must be in the interval [${-(o+1)}, ${o}]`),l=o+s+1),i.splice(l,0,1),ve({inputs:{x:a},backend:r,attrs:{shape:i}})}var Ige={kernelName:Mc,backendName:"webgl",kernelFunc:db},JE="return exp(x) - 1.0;",Sge=it({opSnippet:JE,packedOpSnippet:JE,cpuKernelImpl:ipe}),Tge={kernelName:ll,backendName:"webgl",kernelFunc:Sge},QE=class{constructor(e,t,n){this.variableNames=["real","imag"];let r=t[1];this.outputShape=t;let s=n?`2.0 * ${Math.PI}`:`-2.0 * ${Math.PI}`,a=n?`${r}.0`:"1.0",o;if(e==="real")o="return real * expR - imag * expI;";else if(e==="imag")o="return real * expI + imag * expR;";else throw new Error(`FFT component must be either "real" or "imag", got ${e}.`);this.userCode=`
|
|
const float exponentMultiplier = ${s};
|
|
|
|
float unaryOpComplex(float real, float expR, float imag, float expI) {
|
|
${o}
|
|
}
|
|
|
|
float mulMatDFT(int batch, int index) {
|
|
float indexRatio = float(index) / float(${r});
|
|
float exponentMultiplierTimesIndexRatio =
|
|
exponentMultiplier * indexRatio;
|
|
|
|
float result = 0.0;
|
|
|
|
for (int i = 0; i < ${r}; i++) {
|
|
// x = (-2|2 * PI / N) * index * i;
|
|
float x = exponentMultiplierTimesIndexRatio * float(i);
|
|
float expR = cos(x);
|
|
float expI = sin(x);
|
|
float real = getReal(batch, i);
|
|
float imag = getImag(batch, i);
|
|
|
|
result +=
|
|
unaryOpComplex(real, expR, imag, expI) / ${a};
|
|
}
|
|
|
|
return result;
|
|
}
|
|
|
|
void main() {
|
|
ivec2 coords = getOutputCoords();
|
|
setOutput(mulMatDFT(coords[0], coords[1]));
|
|
}
|
|
`}};function e9(e,t,n){let r=n.texData.get(e.dataId),s=k.sizeFromShape(e.shape),a=e.shape[e.shape.length-1],o=s/a,i=ve({inputs:{x:e},backend:n,attrs:{shape:[o,a]}}),l=i.shape,u=new QE("real",l,t),c=new QE("imag",l,t),d=[{dataId:r.complexTensorInfos.real.dataId,dtype:r.complexTensorInfos.real.dtype,shape:l},{dataId:r.complexTensorInfos.imag.dataId,dtype:r.complexTensorInfos.imag.dtype,shape:l}],h=n.runWebGLProgram(u,d,"float32"),p=n.runWebGLProgram(c,d,"float32"),f=eo({inputs:{real:h,imag:p},backend:n});n.disposeIntermediateTensorInfo(h),n.disposeIntermediateTensorInfo(p);let m=ve({inputs:{x:f},backend:n,attrs:{shape:e.shape}});return n.disposeIntermediateTensorInfo(i),n.disposeIntermediateTensorInfo(f),m}function Nge(e){let{inputs:t,backend:n}=e,{input:r}=t;return e9(r,!1,n)}var Cge={kernelName:Oy,backendName:"webgl",kernelFunc:Nge},Ege=class{constructor(e,t){this.outputShape=[],this.variableNames=["x"],this.outputShape=e,this.userCode=`
|
|
uniform float value;
|
|
void main() {
|
|
// Input can be obtained from uniform value.
|
|
setOutput(value);
|
|
}
|
|
`}getCustomSetupFunc(e){return(t,n)=>{this.valueLoc==null&&(this.valueLoc=t.getUniformLocationNoThrow(n,"value")),t.gl.uniform1f(this.valueLoc,e)}}};function hb(e){let{backend:t,attrs:n}=e,{shape:r,value:s}=n,{dtype:a}=n;if(a=a||k.inferDtype(s),a==="string"){let o=k.getArrayFromDType(a,k.sizeFromShape(r));return o.fill(s),t.makeTensorInfo(r,a,o)}else{let o=new Ege(r,s),i=o.getCustomSetupFunc(s);return t.runWebGLProgram(o,[],a,i)}}var $ge={kernelName:Qp,backendName:"webgl",kernelFunc:hb},_ge=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;
|
|
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);
|
|
}
|
|
`}},Rge={kernelName:Oc,backendName:"webgl",kernelFunc:({inputs:e,backend:t})=>{let{image:n}=e,r=t,s=new _ge(n.shape);return r.runWebGLProgram(s,[n],n.dtype)}},t9="return floor(x);",Dge=it({opSnippet:t9,packedOpSnippet:t9,cpuKernelImpl:lpe}),Fge={kernelName:$o,backendName:"webgl",kernelFunc:Dge},Mge=`
|
|
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;
|
|
}
|
|
`,Oge=`
|
|
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);
|
|
`,Pge=Nn({opSnippet:Mge,packedOpSnippet:Oge,dtype:"int32"}),zge={kernelName:ul,backendName:"webgl",kernelFunc:Pge},Lge=class{constructor(e){this.variableNames=["A"];let t=Wn(),[n,r]=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(${r}.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));
|
|
}
|
|
`}},Bge=class{constructor(e){this.variableNames=["A"],this.packedInputs=!1,this.packedOutput=!0;let t=Wn(),[n,r]=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(${r}.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;
|
|
}
|
|
`}},Wge={kernelName:rA,backendName:"webgl",kernelFunc:Vge},Su;function Vge(e){let{inputs:t,backend:n,attrs:r}=e,{pixels:s}=t,{numChannels:a}=r,o=typeof HTMLVideoElement!="undefined"&&s instanceof HTMLVideoElement,i=typeof HTMLImageElement!="undefined"&&s instanceof HTMLImageElement,[l,u]=o?[s.videoWidth,s.videoHeight]:[s.width,s.height],c=[u,l],d=[u,l,a];(i||o)&&(Su==null&&(Su=document.createElement("canvas").getContext("2d")),Su.canvas.width=l,Su.canvas.height=u,Su.drawImage(s,0,0,l,u),s=Su.canvas);let h=n.makeTensorInfo(c,"int32");n.texData.get(h.dataId).usage=zr.PIXELS,n.gpgpu.uploadPixelDataToTexture(n.getTexture(h.dataId),s);let p=ae().getBool("WEBGL_PACK")?new Bge(d):new Lge(d),f=n.runWebGLProgram(p,[h],"int32");return n.disposeData(h.dataId),f}function Uge(e){let{inputs:t,backend:n,attrs:r}=e,{x:s,filter:a,bias:o,preluActivationWeights:i}=t,{strides:l,pad:u,dataFormat:c,dilations:d,dimRoundingMode:h,activation:p,leakyreluAlpha:f}=r,m=_.convertConv2DDataFormat(c),g=_.computeConv2DInfo(s.shape,a.shape,l,d,u,h,!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=UE({x:s,filter:a,convInfo:g,backend:n,bias:o,activation:p,preluActivationWeights:i,leakyreluAlpha:f});else if(ae().getBool("WEBGL_CONV_IM2COL")&&s.shape[0]===1)y=HE({x:s,filter:a,convInfo:g,backend:n,bias:o,activation:p,preluActivationWeights:i,leakyreluAlpha:f});else{let b=o!=null,v=i!=null,w=p==="leakyrelu",I=p?Gm(p,!1):null,T=new VE(g,b,I,v,w),C=[s,a];if(o&&C.push(o),i&&C.push(i),w){let M=n.makeTensorInfo([],"float32",k.createScalarValue(f,"float32"));C.push(M),A.push(M)}y=n.runWebGLProgram(T,C,"float32")}let x=ve({inputs:{x:y},backend:n,attrs:{shape:g.outShape}});return A.push(y),A.forEach(b=>n.disposeIntermediateTensorInfo(b)),x}var Hge={kernelName:Bl,backendName:"webgl",kernelFunc:Uge};function Gge(e){let{inputs:t,backend:n,attrs:r}=e,{x:s,filter:a,bias:o,preluActivationWeights:i}=t,{strides:l,pad:u,dilations:c,dimRoundingMode:d,activation:h,leakyreluAlpha:p}=r,f=[],m=c;m==null&&(m=[1,1]),k.assert(_.eitherStridesOrDilationsAreOne(l,m),()=>`Error in depthwiseConv2d: Either strides or dilations must be 1. Got strides ${l} and dilations '${m}'`);let g=_.computeConv2DInfo(s.shape,a.shape,l,m,u,d,!0),y=ae().getBool("WEBGL_PACK_DEPTHWISECONV")&&g.strideWidth<=2&&g.outChannels/g.inChannels==1,A=h?Gm(h,y):null,x=[s,a],b=o!=null,v=i!=null,w=h==="leakyrelu";if(b&&x.push(o),v&&x.push(i),w){let C=n.makeTensorInfo([],"float32",k.createScalarValue(p,"float32"));x.push(C),f.push(C)}let I;y?I=new XE(g,b,A,v,w):I=new KE(g,b,A,v,w);let T=n.runWebGLProgram(I,x,"float32");return f.forEach(C=>n.disposeIntermediateTensorInfo(C)),T}var jge={kernelName:Wl,backendName:"webgl",kernelFunc:Gge},qge=class{constructor(e,t,n){this.sliceDim=e,this.strides=t,this.variableNames=["x","indices"],this.outputShape=n;let r=It(t.length),s=It(n.length),a=this.sliceDim>1?"strides[j]":"strides";this.userCode=`
|
|
${r} strides = ${r}(${this.strides});
|
|
void main() {
|
|
${s} coords = getOutputCoords();
|
|
int flattenIndex = 0;
|
|
for (int j = 0; j < ${this.sliceDim}; j++) {
|
|
int index = round(getIndices(coords[0], j));
|
|
flattenIndex += index * ${a};
|
|
}
|
|
setOutput(getX(flattenIndex, coords[1]));
|
|
}
|
|
`}};function Kge(e){let{inputs:t,backend:n}=e,{params:r,indices:s}=t,a=s.shape,o=a[a.length-1],i=k.sizeFromShape(r.shape),[l,u,c,d]=_.prepareAndValidate(r,s),h=ve({inputs:{x:s},backend:n,attrs:{shape:[u,o]}}),p=ve({inputs:{x:r},backend:n,attrs:{shape:[k.sizeFromShape(r.shape)/c,c]}});if(n.shouldExecuteOnCPU([r,s])||r.dtype==="string"){let y=n.readSync(s.dataId),A=n.bufferSync(r),x=upe(y,A,r.dtype,u,o,c,d,r.shape,i);return n.makeTensorInfo(l,r.dtype,x.values)}let f=new qge(o,d,[u,c]),m=n.runWebGLProgram(f,[p,h],p.dtype),g=ve({inputs:{x:m},backend:n,attrs:{shape:l}});return n.disposeIntermediateTensorInfo(h),n.disposeIntermediateTensorInfo(p),n.disposeIntermediateTensorInfo(m),g}var Xge={kernelName:zc,backendName:"webgl",kernelFunc:Kge},Zge=class{constructor(e,t){this.variableNames=["A","indices"],this.outputShape=t,this.rank=t.length;let n=It(this.rank),r=Yge(e,2);this.userCode=`
|
|
void main() {
|
|
${n} resRC = getOutputCoords();
|
|
setOutput(getA(${r}));
|
|
}
|
|
`}};function Yge(e,t){let n=["resRC.x","resRC.y","resRC.z","resRC.w"],r=[];for(let s=0;s<e.length;s++)s===2?r.push("int(getIndices(resRC.x, resRC.z))"):r.push(`${n[s]}`);return r.join()}function Jge(e){let{inputs:t,backend:n,attrs:r}=e,{x:s,indices:a}=t,{axis:o,batchDims:i}=r,l=k.parseAxisParam(o,s.shape)[0],u=_.segment_util.collectGatherOpShapeInfo(s,a,l,i),c=k.sizeFromShape(a.shape),d=[],h=ve({inputs:{x:s},backend:n,attrs:{shape:[u.batchSize,u.outerSize,u.dimSize,u.sliceSize]}}),p=ve({inputs:{x:a},backend:n,attrs:{shape:[u.batchSize,c/u.batchSize]}});d.push(h),d.push(p);let f=[u.batchSize,u.outerSize,c/u.batchSize,u.sliceSize];if(n.shouldExecuteOnCPU([s,a])||s.dtype==="string"){let A=n.bufferSync(p),x=n.bufferSync(h),b=cpe(x,A,f);return d.forEach(v=>n.disposeIntermediateTensorInfo(v)),n.makeTensorInfo(u.outputShape,b.dtype,b.values)}let m=new Zge(h.shape,f),g=n.runWebGLProgram(m,[h,p],h.dtype);d.push(g);let y=ve({inputs:{x:g},backend:n,attrs:{shape:u.outputShape}});return d.forEach(A=>n.disposeIntermediateTensorInfo(A)),y}var Qge={kernelName:Pc,backendName:"webgl",kernelFunc:Jge},e2e="return float(a > b);",t2e=`
|
|
return vec4(greaterThan(a, b));
|
|
`,n2e=Nn({opSnippet:e2e,packedOpSnippet:t2e,cpuKernelImpl:dpe,dtype:"bool"}),r2e={kernelName:dl,backendName:"webgl",kernelFunc:n2e},s2e="return float(a >= b);",a2e=`
|
|
return vec4(greaterThanEqual(a, b));
|
|
`,o2e=Nn({opSnippet:s2e,packedOpSnippet:a2e,dtype:"bool",cpuKernelImpl:hpe}),i2e={kernelName:_o,backendName:"webgl",kernelFunc:o2e};function l2e(e){let{inputs:t,backend:n}=e,{input:r}=t;return e9(r,!0,n)}var u2e={kernelName:Py,backendName:"webgl",kernelFunc:l2e},c2e="return float(!isnan(x) && !isinf(x));",d2e=it({opSnippet:c2e,dtype:"bool"}),h2e={kernelName:Lc,backendName:"webgl",kernelFunc:d2e},p2e="return float(isinf(x));",f2e=it({opSnippet:p2e,dtype:"bool"}),m2e={kernelName:Bc,backendName:"webgl",kernelFunc:f2e},g2e="return float(isnan(x));",y2e=it({opSnippet:g2e,dtype:"bool"}),A2e={kernelName:Wc,backendName:"webgl",kernelFunc:y2e},x2e="return float(a < b);",b2e=`
|
|
return vec4(lessThan(a, b));
|
|
`,v2e=Nn({opSnippet:x2e,packedOpSnippet:b2e,cpuKernelImpl:ppe,dtype:"bool"}),w2e={kernelName:fl,backendName:"webgl",kernelFunc:v2e},k2e="return float(a <= b);",I2e=`
|
|
return vec4(lessThanEqual(a, b));
|
|
`,S2e=Nn({opSnippet:k2e,packedOpSnippet:I2e,cpuKernelImpl:fpe,dtype:"bool"}),T2e={kernelName:ml,backendName:"webgl",kernelFunc:S2e};function N2e(e){let{backend:t,attrs:n}=e,{start:r,stop:s,num:a}=n,o=mpe(r,s,a);return t.makeTensorInfo([o.length],"float32",o)}var C2e={kernelName:Ly,backendName:"webgl",kernelFunc:N2e},E2e=`if (x < 0.0) return NAN;
|
|
return log(x);`,$2e=`
|
|
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;
|
|
`,_2e=it({opSnippet:E2e,packedOpSnippet:$2e,cpuKernelImpl:gpe}),R2e={kernelName:Ro,backendName:"webgl",kernelFunc:_2e},D2e="return log(1.0 + x);",F2e=it({opSnippet:D2e}),M2e={kernelName:Vc,backendName:"webgl",kernelFunc:F2e},O2e="return float(a >= 1.0 && b >= 1.0);",P2e=`
|
|
return vec4(
|
|
vec4(greaterThanEqual(a, vec4(1.0))) *
|
|
vec4(greaterThanEqual(b, vec4(1.0))));
|
|
`,z2e=Nn({opSnippet:O2e,packedOpSnippet:P2e,dtype:"bool"}),L2e={kernelName:Uc,backendName:"webgl",kernelFunc:z2e},B2e="return float(!(x >= 1.0));",W2e=it({opSnippet:B2e}),V2e={kernelName:ef,backendName:"webgl",kernelFunc:W2e},U2e="return float(a >= 1.0 || b >= 1.0);",H2e=`
|
|
return min(
|
|
vec4(greaterThanEqual(a, vec4(1.0))) +
|
|
vec4(greaterThanEqual(b, vec4(1.0))),
|
|
vec4(1.0));
|
|
`,G2e=Nn({opSnippet:U2e,packedOpSnippet:H2e,dtype:"bool"}),j2e={kernelName:tf,backendName:"webgl",kernelFunc:G2e},q2e=class{constructor(e,t,n,r,s){this.variableNames=["x"],this.outputShape=[];let a=t,o=e[3]-1;this.outputShape=e;let i,l=`float(${n}) + float(${r}) * sum`;s===.5?i=`inversesqrt(${l})`:s===1?i=`1.0/(${l})`:i=`exp(log(${l}) * float(-${s}));`,this.userCode=`
|
|
void main() {
|
|
ivec4 coords = getOutputCoords();
|
|
int b = coords[0];
|
|
int r = coords[1];
|
|
int c = coords[2];
|
|
int d = coords[3];
|
|
float x = getX(b, r, c, d);
|
|
float sum = 0.0;
|
|
for (int j = -${a}; j <= ${a}; j++) {
|
|
int idx = d + j;
|
|
if (idx >= 0 && idx <= ${o}) {
|
|
float z = getX(b, r, c, idx);
|
|
sum += z * z;
|
|
}
|
|
}
|
|
float val = x * ${i};
|
|
setOutput(val);
|
|
}
|
|
`}},K2e=class{constructor(e,t,n,r,s){this.variableNames=["x"],this.outputShape=[],this.packedInputs=!0,this.packedOutput=!0;let a=t,o=e[3]-1;this.outputShape=e;let i,l=`float(${n}) + float(${r}) * sum`;s===.5?i=`inversesqrt(${l})`:s===1?i=`1.0/(${l})`:i=`exp(log(${l}) * float(-${s}));`,this.userCode=`
|
|
void main() {
|
|
ivec4 coords = getOutputCoords();
|
|
int b = coords.x;
|
|
int r = coords.y;
|
|
int c = coords.z;
|
|
int d = coords.w;
|
|
|
|
bool hasNextCol = d < ${this.outputShape[3]};
|
|
bool hasNextRow = c < ${this.outputShape[2]};
|
|
|
|
vec4 sum = vec4(0.);
|
|
vec4 xFragAtOutputCoords = getX(b, r, c, d);
|
|
|
|
vec4 xAtOutputCoords = vec4(
|
|
getChannel(xFragAtOutputCoords, vec2(c, d)),
|
|
hasNextCol ?
|
|
getChannel(xFragAtOutputCoords, vec2(c, d + 1)) : 0.0,
|
|
hasNextRow ?
|
|
getChannel(xFragAtOutputCoords , vec2(c + 1, d)) : 0.0,
|
|
(hasNextRow && hasNextCol) ?
|
|
getChannel(xFragAtOutputCoords, vec2(c + 1, d + 1)) : 0.0
|
|
);
|
|
|
|
int firstChannel = d - ${a};
|
|
vec2 cache = vec2(0.);
|
|
if(firstChannel >= 0){
|
|
vec4 firstChannelFrag = getX(b, r, c, firstChannel);
|
|
cache.x = getChannel(firstChannelFrag, vec2(c, firstChannel));
|
|
if(hasNextRow){
|
|
cache.y = getChannel(firstChannelFrag, vec2(c + 1, firstChannel));
|
|
}
|
|
}
|
|
|
|
ivec2 depth = ivec2(d, d + 1);
|
|
for (int j = - ${a}; j <= ${a}; j++) {
|
|
ivec2 idx = depth + j;
|
|
bvec2 aboveLowerBound = greaterThanEqual(idx, ivec2(0));
|
|
bvec2 belowUpperBound = lessThanEqual(idx, ivec2(${o}));
|
|
|
|
bool depthInRange = aboveLowerBound.x && belowUpperBound.x;
|
|
bool depthPlusOneInRange = aboveLowerBound.y && belowUpperBound.y;
|
|
|
|
if(depthInRange || depthPlusOneInRange){
|
|
vec4 z = vec4(0.);
|
|
vec4 xFragAtCurrentDepth;
|
|
z.xz = cache.xy;
|
|
if(depthPlusOneInRange && hasNextCol){
|
|
xFragAtCurrentDepth = idx.y != d ?
|
|
getX(b, r, c, idx.y) : xFragAtOutputCoords;
|
|
z.y = getChannel(xFragAtCurrentDepth, vec2(c, idx.y));
|
|
if(hasNextRow){
|
|
z.w = getChannel(xFragAtCurrentDepth, vec2(c + 1, idx.y));
|
|
}
|
|
}
|
|
cache.xy = z.yw;
|
|
sum += z * z;
|
|
}
|
|
}
|
|
vec4 result = xAtOutputCoords * ${i};
|
|
setOutput(result);
|
|
}
|
|
`}},X2e=e=>{let{inputs:t,backend:n,attrs:r}=e,{x:s}=t,{depthRadius:a,bias:o,alpha:i,beta:l}=r,u=ae().getBool("WEBGL_PACK_NORMALIZATION")?new K2e(s.shape,a,o,i,l):new q2e(s.shape,a,o,i,l);return n.runWebGLProgram(u,[s],s.dtype)},Z2e={kernelName:nf,backendName:"webgl",kernelFunc:X2e},Y2e=class{constructor(e,t,n,r,s){this.variableNames=["inputImage","outputImage","dy"],this.outputShape=[],this.outputShape=e,this.depth=e[3],this.depthRadius=t,this.bias=n,this.alpha=r,this.beta=s,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(${r}) * 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(${r})
|
|
* float(${s})
|
|
* getInputImage(b ,r ,c, k) * getOutputImage(b, r, c, d)
|
|
/ norm;
|
|
if (k == d) {
|
|
dyi += pow(norm, -1.0 * ${s});
|
|
}
|
|
if (k == coords[3]) {
|
|
dyi *= getDy(b, r, c, d);
|
|
result += dyi;
|
|
}
|
|
}
|
|
else {
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
setOutput(result);
|
|
}
|
|
`}},J2e=e=>{let{inputs:t,backend:n,attrs:r}=e,{x:s,y:a,dy:o}=t,{depthRadius:i,bias:l,alpha:u,beta:c}=r,d=new Y2e(s.shape,i,l,u,c);return n.runWebGLProgram(d,[s,a,o],s.dtype)},Q2e={kernelName:By,backendName:"webgl",kernelFunc:J2e};function eye(e,t,n,r){let s=k.sizeFromShape(t),o=k.sizeFromShape(e.shape)/s,i=ve({inputs:{x:e},attrs:{shape:[o,s]},backend:r}),l=bi(i,e.dtype,"max",r),u=ve({inputs:{x:l},attrs:{shape:n},backend:r});return r.disposeIntermediateTensorInfo(i),r.disposeIntermediateTensorInfo(l),u}function n9(e){let{inputs:t,backend:n,attrs:r}=e,{x:s}=t,{reductionIndices:a,keepDims:o}=r,i=s.shape.length,l=k.parseAxisParam(a,s.shape),u=l,c=_.getAxesPermutation(u,i),d=c!=null,h=n.shouldExecuteOnCPU([s]),p=s;if(d){if(h){let x=n.texData.get(p.dataId).values,b=new Array(i);for(let I=0;I<b.length;I++)b[I]=s.shape[c[I]];let v=ob(x,s.shape,s.dtype,c,b);p=n.makeTensorInfo(b,s.dtype);let w=n.texData.get(p.dataId);w.values=v}else p=jm(s,c,n);u=_.getInnerMostAxes(u.length,i)}_.assertAxesAreInnerMostDims("max",u,i);let[f,m]=_.computeOutAndReduceShapes(p.shape,u),g=f;o&&(g=_.expandShapeToKeepDim(f,l));let y;if(h){let x=n.texData.get(p.dataId).values,b=ype(x,k.sizeFromShape(m),g,s.dtype);y=n.makeTensorInfo(g,s.dtype);let v=n.texData.get(y.dataId);v.values=b}else y=eye(p,m,g,n);return d&&n.disposeIntermediateTensorInfo(p),y}var tye={kernelName:gl,backendName:"webgl",kernelFunc:n9},nye=vE+`
|
|
return max(a, b);
|
|
`,rye=`
|
|
vec4 result = vec4(max(a, b));
|
|
vec4 isNaN = min(vec4(isnan(a)) + vec4(isnan(b)), vec4(1.0));
|
|
`+Hm+`
|
|
return result;
|
|
`,sye=Nn({opSnippet:nye,packedOpSnippet:rye,cpuKernelImpl:Ape}),aye={kernelName:Do,backendName:"webgl",kernelFunc:sye};function oye(e){let{inputs:t,backend:n,attrs:r}=e,{x:s}=t;mu(s,"maxPool");let{filterSize:a,strides:o,pad:i,dimRoundingMode:l}=r,u=1;k.assert(_.eitherStridesOrDilationsAreOne(o,u),()=>`Error in maxPool: Either strides or dilations must be 1. Got strides ${o} and dilations '${u}'`);let c=_.computePool2DInfo(s.shape,a,o,u,i,l);if(c.filterWidth===1&&c.filterHeight===1&&k.arraysEqual(c.inShape,c.outShape))return mr({inputs:{x:s},backend:n});let d=new ph(c,"max",!1);return n.runWebGLProgram(d,[s],s.dtype)}var iye={kernelName:yl,backendName:"webgl",kernelFunc:oye};function lye(e){let{inputs:t,backend:n,attrs:r}=e,{x:s}=t,{filterSize:a,strides:o,pad:i,dataFormat:l,dimRoundingMode:u}=r,c=[1,1,1],d=_.computePool3DInfo(s.shape,a,o,c,i,u,l),h=new lb(d,"max",!1);return n.runWebGLProgram(h,[s],s.dtype)}var uye={kernelName:rf,backendName:"webgl",kernelFunc:lye},cye=class{constructor(e){this.variableNames=["dy","maxPos"],this.outputShape=e.inShape;let t=e.strideHeight,n=e.strideWidth,r=e.dilationHeight,s=e.effectiveFilterHeight,a=e.effectiveFilterWidth,o=s-1-e.padInfo.top,i=a-1-e.padInfo.left,l=s*a-1;this.userCode=`
|
|
const ivec2 pads = ivec2(${o}, ${i});
|
|
|
|
void main() {
|
|
ivec4 coords = getOutputCoords();
|
|
int b = coords[0];
|
|
int d = coords[3];
|
|
|
|
ivec2 dyRCCorner = coords.yz - pads;
|
|
int dyRCorner = dyRCCorner.x;
|
|
int dyCCorner = dyRCCorner.y;
|
|
|
|
// Convolve dy(?, ?, d) with pos mask(:, :, d) to get dx(xR, xC, d).
|
|
// ? = to be determined. : = across all values in that axis.
|
|
float dotProd = 0.0;
|
|
for (int wR = 0; wR < ${s};
|
|
wR += ${r}) {
|
|
float dyR = float(dyRCorner + wR) / ${t}.0;
|
|
|
|
if (dyR < 0.0 || dyR >= ${e.outHeight}.0 || fract(dyR) > 0.0) {
|
|
continue;
|
|
}
|
|
int idyR = int(dyR);
|
|
|
|
for (int wC = 0; wC < ${a}; wC++) {
|
|
float dyC = float(dyCCorner + wC) / ${n}.0;
|
|
|
|
if (dyC < 0.0 || dyC >= ${e.outWidth}.0 ||
|
|
fract(dyC) > 0.0) {
|
|
continue;
|
|
}
|
|
int idyC = int(dyC);
|
|
|
|
float dyValue = getDy(b, idyR, idyC, d);
|
|
int maxPosValue = ${l} - int(getMaxPos(b, idyR, idyC, d));
|
|
|
|
// Get the current value, check it against the value from the
|
|
// position matrix.
|
|
int curPosValue = wR * ${a} + wC;
|
|
float mask = float(maxPosValue == curPosValue ? 1.0 : 0.0);
|
|
|
|
dotProd += dyValue * mask;
|
|
}
|
|
}
|
|
setOutput(dotProd);
|
|
}
|
|
`}},dye=class{constructor(e){this.variableNames=["dy","maxPos"],this.outputShape=e.inShape;let t=e.strideDepth,n=e.strideHeight,r=e.strideWidth,s=e.dilationDepth,a=e.dilationHeight,o=e.dilationWidth,i=e.effectiveFilterDepth,l=e.effectiveFilterHeight,u=e.effectiveFilterWidth,c=i-1-e.padInfo.front,d=l-1-e.padInfo.top,h=u-1-e.padInfo.left,p=i*l*u-1;this.userCode=`
|
|
const ivec3 pads = ivec3(${c}, ${d}, ${h});
|
|
|
|
void main() {
|
|
ivec5 coords = getOutputCoords();
|
|
int batch = coords.x;
|
|
int ch = coords.u;
|
|
|
|
ivec3 dyCorner = ivec3(coords.y, coords.z, coords.w) - pads;
|
|
int dyDCorner = dyCorner.x;
|
|
int dyRCorner = dyCorner.y;
|
|
int dyCCorner = dyCorner.z;
|
|
|
|
// Convolve dy(?, ?, ?, ch) with pos mask(:, :, :, d) to get
|
|
// dx(xD, xR, xC, ch).
|
|
// ? = to be determined. : = across all values in that axis.
|
|
float dotProd = 0.0;
|
|
|
|
for (int wD = 0; wD < ${i};
|
|
wD += ${s}) {
|
|
float dyD = float(dyDCorner + wD) / ${t}.0;
|
|
|
|
if (dyD < 0.0 || dyD >= ${e.outDepth}.0 || fract(dyD) > 0.0) {
|
|
continue;
|
|
}
|
|
int idyD = int(dyD);
|
|
|
|
for (int wR = 0; wR < ${l};
|
|
wR += ${a}) {
|
|
float dyR = float(dyRCorner + wR) / ${n}.0;
|
|
|
|
if (dyR < 0.0 || dyR >= ${e.outHeight}.0 ||
|
|
fract(dyR) > 0.0) {
|
|
continue;
|
|
}
|
|
int idyR = int(dyR);
|
|
|
|
for (int wC = 0; wC < ${u};
|
|
wC += ${o}) {
|
|
float dyC = float(dyCCorner + wC) / ${r}.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 = ${p} -
|
|
int(getMaxPos(batch, idyD, idyR, idyC, ch));
|
|
|
|
// Get the current value, check it against the value from the
|
|
// position matrix.
|
|
int curPosValue =
|
|
wD * ${l} * ${u} +
|
|
wR * ${u} + wC;
|
|
float mask = float(maxPosValue == curPosValue ? 1.0 : 0.0);
|
|
|
|
dotProd += dyValue * mask;
|
|
}
|
|
}
|
|
}
|
|
setOutput(dotProd);
|
|
}
|
|
`}};function hye(e){let{inputs:t,backend:n,attrs:r}=e,{dy:s,input:a}=t,o=a,{filterSize:i,strides:l,pad:u,dimRoundingMode:c}=r,d=[1,1,1],h=_.computePool3DInfo(o.shape,i,l,d,u,c),p=new lb(h,"max",!0),f=n.runWebGLProgram(p,[o],o.dtype),m=new dye(h),g=n.runWebGLProgram(m,[s,f],o.dtype);return n.disposeIntermediateTensorInfo(f),g}var pye={kernelName:Vy,backendName:"webgl",kernelFunc:hye};function fye(e){let{inputs:t,backend:n,attrs:r}=e,{dy:s,input:a,output:o}=t,i=a;mu([a,o],"maxPoolGrad");let{filterSize:l,strides:u,pad:c,dimRoundingMode:d}=r,h=_.computePool2DInfo(i.shape,l,u,1,c,d),p=!0,f=new ph(h,"max",p),m=n.runWebGLProgram(f,[i],i.dtype),g=new cye(h),y=n.runWebGLProgram(g,[s,m],i.dtype);return n.disposeIntermediateTensorInfo(m),y}var mye={kernelName:Wy,backendName:"webgl",kernelFunc:fye};function gye(e,t,n,r){let s=new ph(n,"max",!1),a=r.runWebGLProgram(s,[e],"float32");s=new ph(n,"max",!0,!0,t);let o=r.runWebGLProgram(s,[e],"float32");return[a,o]}var yye={kernelName:Uy,backendName:"webgl",kernelFunc:({inputs:e,attrs:t,backend:n})=>{let{x:r}=e,{filterSize:s,strides:a,pad:o,includeBatchInIndex:i}=t,l=n;k.assert(r.shape.length===4,()=>`Error in maxPool: input must be rank 4 but got rank ${r.shape.length}.`);let u=[1,1];k.assert(_.eitherStridesOrDilationsAreOne(a,u),()=>`Error in maxPool: Either strides or dilations must be 1. Got strides ${a} and dilations '${u}'`);let c=_.computePool2DInfo(r.shape,s,a,u,o),[d,h]=gye(r,i,c,l);return[d,h]}};function Aye(e,t,n,r){let s=k.sizeFromShape(t),o=k.sizeFromShape(e.shape)/s,i=ve({inputs:{x:e},attrs:{shape:[o,s]},backend:r}),l=bi(i,"float32","mean",r),u=ve({inputs:{x:l},attrs:{shape:n},backend:r});return r.disposeIntermediateTensorInfo(i),r.disposeIntermediateTensorInfo(l),u}var xye={kernelName:Al,backendName:"webgl",kernelFunc:({inputs:e,attrs:t,backend:n})=>{let{x:r}=e,{keepDims:s,axis:a}=t,o=n,i=r.shape.length,l=k.parseAxisParam(a,r.shape),u=l,c=_.getAxesPermutation(u,i),d=c!=null,h=o.shouldExecuteOnCPU([r]),p=[],f=r;if(d){if(h){let b=o.texData.get(f.dataId).values,v=new Array(i);for(let T=0;T<v.length;T++)v[T]=r.shape[c[T]];let w=ob(b,r.shape,r.dtype,c,v);f=o.makeTensorInfo(v,r.dtype);let I=o.texData.get(f.dataId);I.values=w}else f=jm(r,c,o);p.push(f),u=_.getInnerMostAxes(u.length,i)}_.assertAxesAreInnerMostDims("sum",u,i);let[m,g]=_.computeOutAndReduceShapes(f.shape,u),y=m;s&&(y=_.expandShapeToKeepDim(m,l));let A=Aye(f,g,y,o);for(let x of p)o.disposeIntermediateTensorInfo(x);return A}};function bye(e){let{inputs:t,backend:n,attrs:r}=e,{x:s}=t,{axis:a,keepDims:o}=r,i=s.shape.length,l=k.parseAxisParam(a,s.shape),u=l,c=_.getAxesPermutation(u,i),d=s;c!=null&&(d=Un({inputs:{x:s},backend:n,attrs:{perm:c}}),u=_.getInnerMostAxes(u.length,s.shape.length)),_.assertAxesAreInnerMostDims("min",u,i);let[h,p]=_.computeOutAndReduceShapes(d.shape,u),f=k.sizeFromShape(p),m=ve({inputs:{x:d},backend:n,attrs:{shape:[-1,f]}}),g=bi(m,m.dtype,"min",n),y;if(o){let A=_.expandShapeToKeepDim(h,l);y=ve({inputs:{x:g},backend:n,attrs:{shape:A}})}else y=ve({inputs:{x:g},backend:n,attrs:{shape:h}});return n.disposeIntermediateTensorInfo(m),n.disposeIntermediateTensorInfo(g),c!=null&&n.disposeIntermediateTensorInfo(d),y}var vye={kernelName:xl,backendName:"webgl",kernelFunc:bye},wye=vE+`
|
|
return min(a, b);
|
|
`,kye=`
|
|
vec4 result = vec4(min(a, b));
|
|
vec4 isNaN = min(vec4(isnan(a)) + vec4(isnan(b)), vec4(1.0));
|
|
`+Hm+`
|
|
return result;
|
|
`,Iye=Nn({opSnippet:wye,packedOpSnippet:kye,cpuKernelImpl:xpe}),Sye={kernelName:Fo,backendName:"webgl",kernelFunc:Iye},Tye=class{constructor(e,t,n){this.variableNames=["x"],this.outputShape=t.map((u,c)=>u[0]+e[c]+u[1]);let r=e.length,s=It(r),a=t.map(u=>u[0]).join(","),o=t.map((u,c)=>u[0]+e[c]).join(","),i=["coords[0]","coords[1]","coords[2]","coords[3]"].slice(0,r),l=n==="reflect"?0:1;if(r===1){this.userCode=`
|
|
int start = ${a};
|
|
int end = ${o};
|
|
|
|
void main() {
|
|
int outC = getOutputCoords();
|
|
if (outC < start) {
|
|
outC = start * 2 - outC - ${l};
|
|
} else if(outC >= end) {
|
|
outC = (end - 1) * 2 - outC + ${l};
|
|
}
|
|
setOutput(getX(outC - start));
|
|
}
|
|
`;return}this.userCode=`
|
|
${s} start = ${s}(${a});
|
|
${s} end = ${s}(${o});
|
|
|
|
void main() {
|
|
${s} outC = getOutputCoords();
|
|
for (int i = 0; i < ${r}; 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};
|
|
}
|
|
}
|
|
${s} coords = outC - start;
|
|
setOutput(getX(${i}));
|
|
}
|
|
`}},Nye=class{constructor(e,t,n){this.variableNames=["x"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=t.map((p,f)=>p[0]+e[f]+p[1]);let r=e.length,s=It(r),a=t.map(p=>p[0]).join(","),o=t.map((p,f)=>p[0]+e[f]).join(","),i=Vn("rc",r),l=Vn("source",r),u=`${i[r-1]} < ${this.outputShape[r-1]}`,c=r===1?"source":`vec2(${l.slice(-2).join()})`,d=n==="reflect"?0:1,h="";if(r===1){let p=`
|
|
${s} source = rc;
|
|
if (source < start) {
|
|
source = start * 2 - source - ${d};
|
|
} else if (source >= end) {
|
|
source = (end - 1) * 2 - source + ${d};
|
|
}
|
|
source -= start;
|
|
`;h=`
|
|
${s} rc = outputLoc;
|
|
${p}
|
|
result[0] = getChannel(getX(${l.join()}), ${c});
|
|
${i[r-1]} += 1;
|
|
if(${u}) {
|
|
${p}
|
|
result[1] = getChannel(getX(${l.join()}), ${c});
|
|
}
|
|
`}else{let p=`
|
|
${s} source = rc;
|
|
${s} lt = ${s}(lessThan(source, start));
|
|
${s} gte = ${s}(greaterThanEqual(source, end));
|
|
${s} orig = 1 - (lt + gte);
|
|
source = orig * source +
|
|
lt * (start * 2 - source - ${d}) +
|
|
gte * ((end - 1) * 2 - source + ${d});
|
|
source -= start;
|
|
`;h=`
|
|
${s} rc = outputLoc;
|
|
${p}
|
|
result[0] = getChannel(getX(${l.join()}), ${c});
|
|
${i[r-1]} += 1;
|
|
if(${u}) {
|
|
${p}
|
|
result[1] = getChannel(getX(${l.join()}), ${c});
|
|
}
|
|
rc = outputLoc;
|
|
${i[r-2]} += 1;
|
|
if(${i[r-2]} < ${this.outputShape[r-2]}) {
|
|
${p}
|
|
result[2] = getChannel(getX(${l.join()}), ${c});
|
|
${i[r-1]} += 1;
|
|
if(${u}) {
|
|
${p}
|
|
result[3] = getChannel(getX(${l.join()}), ${c});
|
|
}
|
|
}
|
|
`}this.userCode=`
|
|
const ${s} start = ${s}(${a});
|
|
const ${s} end = ${s}(${o});
|
|
|
|
void main() {
|
|
${s} outputLoc = getOutputCoords();
|
|
vec4 result = vec4(0.);
|
|
${h}
|
|
setOutput(result);
|
|
}
|
|
`}},Cye=({inputs:e,backend:t,attrs:n})=>{let{x:r}=e,{paddings:s,mode:a}=n,o=ae().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new Nye(r.shape,s,a):new Tye(r.shape,s,a);return t.runWebGLProgram(o,[r],r.dtype)},Eye={kernelName:bl,backendName:"webgl",kernelFunc:Cye},$ye=`if (b == 0.0) return NAN;
|
|
return mod(a, b);`,_ye=`
|
|
vec4 result = mod(a, b);
|
|
vec4 isNaN = vec4(equal(b, vec4(0.0)));
|
|
`+Hm+`
|
|
return result;
|
|
`,Rye=Nn({opSnippet:$ye,packedOpSnippet:_ye}),Dye={kernelName:Hc,backendName:"webgl",kernelFunc:Rye},Fye=class{constructor(e,t,n){this.variableNames=["probs"],this.outputShape=[e,n],this.userCode=`
|
|
uniform float seed;
|
|
|
|
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}));
|
|
}
|
|
`}getCustomSetupFunc(e){return(t,n)=>{this.seedLoc==null&&(this.seedLoc=t.getUniformLocation(n,"seed")),t.gl.uniform1f(this.seedLoc,e)}}},Mye=`
|
|
if (a == b) {
|
|
return 1.0;
|
|
};
|
|
return a / b;`,Oye=`
|
|
// 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;
|
|
`,r9=Nn({opSnippet:Mye,packedOpSnippet:Oye,checkOutOfBounds:!0}),Pye={kernelName:ol,backendName:"webgl",kernelFunc:r9},s9="return a - b;",a9=Nn({opSnippet:s9,packedOpSnippet:s9,supportsComplex:!0,cpuKernelImpl:Dpe}),zye={kernelName:zo,backendName:"webgl",kernelFunc:a9};function o9(e){let{inputs:t,backend:n,attrs:r}=e,{logits:s}=t,{dim:a}=r,o=k.parseAxisParam([a],s.shape),i=n9({inputs:{x:s},backend:n,attrs:{reductionIndices:o,keepDims:!1}}),l=_.expandShapeToKeepDim(i.shape,o),u=ve({inputs:{x:i},backend:n,attrs:{shape:l}}),c=a9({inputs:{a:s,b:u},backend:n}),d=YE({inputs:{x:c},backend:n}),h=qm({inputs:{x:d},backend:n,attrs:{axis:o,keepDims:!1}}),p=ve({inputs:{x:h},backend:n,attrs:{shape:l}}),f=r9({inputs:{a:d,b:p},backend:n});return n.disposeIntermediateTensorInfo(i),n.disposeIntermediateTensorInfo(u),n.disposeIntermediateTensorInfo(c),n.disposeIntermediateTensorInfo(d),n.disposeIntermediateTensorInfo(h),n.disposeIntermediateTensorInfo(p),f}var Lye={kernelName:Ml,backendName:"webgl",kernelFunc:o9};function Bye(e){let{inputs:t,backend:n,attrs:r}=e,{logits:s}=t,{numSamples:a,seed:o,normalized:i}=r,l=i?s:o9({inputs:{logits:s},backend:n,attrs:{dim:s.shape.length-1}}),u=l.shape[0],c=l.shape[1],d=new Fye(u,c,a),h=d.getCustomSetupFunc(o),p=n.runWebGLProgram(d,[l],"int32",h);return i||n.disposeIntermediateTensorInfo(l),p}var Wye={kernelName:Hy,backendName:"webgl",kernelFunc:Bye},i9="return -x;";function Vye(e){let{inputs:t,backend:n}=e,{x:r}=t;if(n.shouldExecuteOnCPU([r])){let a=n.texData.get(r.dataId),[o,i]=vpe(a.values,r.shape,r.dtype);return n.makeTensorInfo(i,r.dtype,o)}let s;return ae().getBool("WEBGL_PACK_UNARY_OPERATIONS")?s=new wu(r.shape,i9):s=new Qa(r.shape,i9),n.runWebGLProgram(s,[r],r.dtype)}var Uye={kernelName:Gc,backendName:"webgl",kernelFunc:Vye},Hye=ca.nonMaxSuppressionV3Impl;function Gye(e){_.warn("tf.nonMaxSuppression() in webgl locks the UI thread. Call tf.nonMaxSuppressionAsync() instead");let{inputs:t,backend:n,attrs:r}=e,{boxes:s,scores:a}=t,{maxOutputSize:o,iouThreshold:i,scoreThreshold:l}=r,u=n.readSync(s.dataId),c=n.readSync(a.dataId),{selectedIndices:d}=Hye(u,c,o,i,l);return n.makeTensorInfo([d.length],"int32",new Int32Array(d))}var jye={kernelName:jc,backendName:"webgl",kernelFunc:Gye},qye=ca.nonMaxSuppressionV4Impl;function Kye(e){_.warn("tf.nonMaxSuppression() in webgl locks the UI thread. Call tf.nonMaxSuppressionAsync() instead");let{inputs:t,backend:n,attrs:r}=e,{boxes:s,scores:a}=t,{maxOutputSize:o,iouThreshold:i,scoreThreshold:l,padToMaxOutputSize:u}=r,c=n.readSync(s.dataId),d=n.readSync(a.dataId),{selectedIndices:h,validOutputs:p}=qye(c,d,o,i,l,u);return[n.makeTensorInfo([h.length],"int32",new Int32Array(h)),n.makeTensorInfo([],"int32",new Int32Array([p]))]}var Xye={kernelName:qc,backendName:"webgl",kernelFunc:Kye},Zye=ca.nonMaxSuppressionV5Impl;function Yye(e){_.warn("tf.nonMaxSuppression() in webgl locks the UI thread. Call tf.nonMaxSuppressionAsync() instead");let{inputs:t,backend:n,attrs:r}=e,{boxes:s,scores:a}=t,{maxOutputSize:o,iouThreshold:i,scoreThreshold:l,softNmsSigma:u}=r,c=n.readSync(s.dataId),d=n.readSync(a.dataId),h=o,p=i,f=l,m=u,{selectedIndices:g,selectedScores:y}=Zye(c,d,h,p,f,m);return[n.makeTensorInfo([g.length],"int32",new Int32Array(g)),n.makeTensorInfo([y.length],"float32",new Float32Array(y))]}var Jye={kernelName:Kc,backendName:"webgl",kernelFunc:Yye},Qye=class{constructor(e,t,n,r){this.variableNames=["indices"],this.outputShape=[e,t],this.userCode=`
|
|
void main() {
|
|
ivec2 coords = getOutputCoords();
|
|
int index = round(getIndices(coords.x));
|
|
setOutput(mix(float(${r}), float(${n}),
|
|
float(index == coords.y)));
|
|
}
|
|
`}},eAe=e=>{let{inputs:t,backend:n,attrs:r}=e,{indices:s}=t,{depth:a,onValue:o,offValue:i}=r,l=k.sizeFromShape(s.shape),u=new Qye(l,a,o,i),c=ve({inputs:{x:s},backend:n,attrs:{shape:[l]}}),d=n.runWebGLProgram(u,[c],s.dtype);n.disposeIntermediateTensorInfo(c);let h=[...s.shape,a],p=ve({inputs:{x:d},backend:n,attrs:{shape:h}});return n.disposeIntermediateTensorInfo(d),p},tAe={kernelName:wl,backendName:"webgl",kernelFunc:eAe};function Jm(e){let{inputs:t,backend:n}=e,{x:r}=t;if(r.dtype==="complex64"){let s=mh({inputs:{input:r},backend:n}),a=Jm({inputs:{x:s},backend:n}),o=Ym({inputs:{input:r},backend:n}),i=Jm({inputs:{x:o},backend:n}),l=eo({inputs:{real:a,imag:i},backend:n});return n.disposeIntermediateTensorInfo(s),n.disposeIntermediateTensorInfo(a),n.disposeIntermediateTensorInfo(o),n.disposeIntermediateTensorInfo(i),l}else return hb({attrs:{shape:r.shape,dtype:r.dtype,value:r.dtype==="string"?"":0},backend:n})}var nAe={kernelName:hd,backendName:"webgl",kernelFunc:Jm};function l9(e){let{inputs:t,backend:n}=e,{x:r}=t;if(r.dtype==="string")throw new Error("onesLike is not supported under string dtype");if(r.dtype==="complex64"){let s=mh({inputs:{input:r},backend:n}),a=l9({inputs:{x:s},backend:n}),o=Ym({inputs:{input:r},backend:n}),i=Jm({inputs:{x:o},backend:n}),l=eo({inputs:{real:a,imag:i},backend:n});return n.disposeIntermediateTensorInfo(s),n.disposeIntermediateTensorInfo(a),n.disposeIntermediateTensorInfo(o),n.disposeIntermediateTensorInfo(i),l}else return hb({attrs:{shape:r.shape,dtype:r.dtype,value:1},backend:n})}var rAe={kernelName:Xc,backendName:"webgl",kernelFunc:l9};function sAe(e){let{inputs:t,backend:n,attrs:r}=e,{axis:s}=r;if(t.length===1)return db({inputs:{input:t[0]},backend:n,attrs:{dim:s}});let a=t[0].shape,o=t[0].dtype;t.forEach(c=>{k.assertShapesMatch(a,c.shape,"All tensors passed to stack must have matching shapes"),k.assert(o===c.dtype,()=>"All tensors passed to stack must have matching dtypes")});let i=[],l=t.map(c=>{let d=db({inputs:{input:c},backend:n,attrs:{dim:s}});return i.push(d),d}),u=WE({inputs:l,backend:n,attrs:{axis:s}});return i.forEach(c=>n.disposeIntermediateTensorInfo(c)),u}var aAe={kernelName:Zc,backendName:"webgl",kernelFunc:sAe},oAe=class{constructor(e,t,n){this.variableNames=["x"],this.outputShape=t.map((l,u)=>l[0]+e[u]+l[1]);let r=e.length,s=It(r),a=t.map(l=>l[0]).join(","),o=t.map((l,u)=>l[0]+e[u]).join(","),i=["coords[0]","coords[1]","coords[2]","coords[3]"].slice(0,r);if(r===1){this.userCode=`
|
|
int start = ${a};
|
|
int end = ${o};
|
|
uniform float value;
|
|
|
|
void main() {
|
|
int outC = getOutputCoords();
|
|
if (outC < start || outC >= end) {
|
|
setOutput(value);
|
|
} else {
|
|
setOutput(getX(outC - start));
|
|
}
|
|
}
|
|
`;return}this.userCode=`
|
|
${s} start = ${s}(${a});
|
|
${s} end = ${s}(${o});
|
|
uniform float value;
|
|
|
|
void main() {
|
|
${s} outC = getOutputCoords();
|
|
if (any(lessThan(outC, start)) || any(greaterThanEqual(outC, end))) {
|
|
setOutput(value);
|
|
} else {
|
|
${s} coords = outC - start;
|
|
setOutput(getX(${i}));
|
|
}
|
|
}
|
|
`}getCustomSetupFunc(e){return(t,n)=>{this.valueLoc==null&&(this.valueLoc=t.getUniformLocationNoThrow(n,"value")),t.gl.uniform1f(this.valueLoc,e)}}},iAe=class{constructor(e,t,n){this.variableNames=["x"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=t.map((f,m)=>f[0]+e[m]+f[1]);let r=e.length,s=It(r),a=t.map(f=>f[0]).join(","),o=t.map((f,m)=>f[0]+e[m]).join(","),i=Vn("rc",r),l=Vn("source",r),u=`${i[r-1]} < ${this.outputShape[r-1]}`,c=r===1?"source":`vec2(${l.slice(-2).join()})`,d=[`${s} rc = outputLoc;`,`${i[r-1]} += 1;
|
|
if(${u}) {
|
|
`,r===1?"":`}
|
|
rc = outputLoc;
|
|
${i[r-2]} += 1;
|
|
if(${i[r-2]} < ${this.outputShape[r-2]}) {`,r===1?"":` ${i[r-1]} += 1;
|
|
if(${u}) {`],h=r===1?"rc < start || rc >= end":"any(lessThan(rc, start)) || any(greaterThanEqual(rc, end))",p="";for(let f=0,m=r===1?2:4;f<m;f++)p+=`
|
|
${d[f]}
|
|
if (${h}) {
|
|
result[${f}] = float(value);
|
|
} else {
|
|
${s} source = rc - start;
|
|
result[${f}] = getChannel(getX(${l.join()}), ${c});
|
|
}
|
|
`;p+=r===1?"} ":"}}",this.userCode=`
|
|
const ${s} start = ${s}(${a});
|
|
const ${s} end = ${s}(${o});
|
|
uniform float value;
|
|
|
|
void main() {
|
|
${s} outputLoc = getOutputCoords();
|
|
vec4 result = vec4(0.);
|
|
${p}
|
|
setOutput(result);
|
|
}
|
|
`}getCustomSetupFunc(e){return(t,n)=>{this.valueLoc==null&&(this.valueLoc=t.getUniformLocationNoThrow(n,"value")),t.gl.uniform1f(this.valueLoc,e)}}},u9=e=>{let{inputs:t,backend:n,attrs:r}=e,{x:s}=t,{paddings:a,constantValue:o}=r,i=ae().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new iAe(s.shape,a,o):new oAe(s.shape,a,o),l=i.getCustomSetupFunc(o);return n.runWebGLProgram(i,[s],s.dtype,l)},lAe={kernelName:kl,backendName:"webgl",kernelFunc:u9},uAe=`
|
|
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);
|
|
`,cAe=`
|
|
// 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));
|
|
`+Hm+`
|
|
return result;
|
|
`,dAe=Nn({opSnippet:uAe,packedOpSnippet:cAe}),hAe={kernelName:Il,backendName:"webgl",kernelFunc:dAe};function pAe(e){let{inputs:t,backend:n,attrs:r}=e,{x:s}=t,{axis:a,keepDims:o}=r,i=s.shape.length,l=[],u=k.parseAxisParam(a,s.shape),c=u,d=_.getAxesPermutation(c,i),h=s;d!=null&&(h=Un({inputs:{x:s},backend:n,attrs:{perm:d}}),c=_.getInnerMostAxes(c.length,i),l.push(h)),_.assertAxesAreInnerMostDims("prod",c,i);let p;if(n.shouldExecuteOnCPU([h])){let f=n.texData.get(h.dataId).values,{outVals:m,outShape:g,outDtype:y}=kpe(h.shape,h.dtype,f,c);p=n.makeTensorInfo(g,y,m)}else{let[f,m]=_.computeOutAndReduceShapes(h.shape,c),g=k.sizeFromShape(m),y=ve({inputs:{x:h},backend:n,attrs:{shape:[-1,g]}}),A=pA(s.dtype),x=bi(y,A,"prod",n);p=ve({inputs:{x},backend:n,attrs:{shape:f}}),l.push(y),l.push(x)}if(o){l.push(p);let f=_.expandShapeToKeepDim(p.shape,u);p=ve({inputs:{x:p},backend:n,attrs:{shape:f}})}return l.forEach(f=>n.disposeIntermediateTensorInfo(f)),p}var fAe={kernelName:Yc,backendName:"webgl",kernelFunc:pAe},c9=e=>{let{backend:t,attrs:n}=e,{start:r,stop:s,step:a,dtype:o}=n,i=Ipe(r,s,a,o);return t.makeTensorInfo([i.length],o,i)},mAe={kernelName:sf,backendName:"webgl",kernelFunc:c9},gAe="return 1.0 / x;",yAe=it({opSnippet:gAe}),AAe={kernelName:Jc,backendName:"webgl",kernelFunc:yAe},xAe=ys+`
|
|
return (x < 0.0) ? 0.0 : x;
|
|
`,bAe=`
|
|
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;
|
|
`,vAe=it({opSnippet:xAe,packedOpSnippet:bAe}),wAe={kernelName:Tl,backendName:"webgl",kernelFunc:vAe},kAe=ys+`
|
|
return (x < 0.0) ? 0.0 : min(6.0, x);
|
|
`,IAe=`
|
|
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;
|
|
`,SAe=it({opSnippet:kAe,packedOpSnippet:IAe}),TAe={kernelName:Cl,backendName:"webgl",kernelFunc:SAe},NAe=class{constructor(e,t,n,r,s){this.variableNames=["A"],this.outputShape=[];let[a,o,i,l]=e;this.outputShape=[a,t,n,l];let u=[r&&t>1?o-1:o,r&&n>1?i-1:i],c=[r&&t>1?t-1:t,r&&n>1?n-1:n],d;s?d="(vec2(yRC) + vec2(0.5)) * effectiveInputOverOutputRatioRC - vec2(0.5)":d="vec2(yRC) * effectiveInputOverOutputRatioRC",this.userCode=`
|
|
const vec2 effectiveInputOverOutputRatioRC = vec2(
|
|
${u[0]/c[0]},
|
|
${u[1]/c[1]});
|
|
const vec2 inputShapeRC = vec2(${o}.0, ${i}.0);
|
|
|
|
void main() {
|
|
ivec4 coords = getOutputCoords();
|
|
int b = coords[0];
|
|
int d = coords[3];
|
|
ivec2 yRC = coords.yz;
|
|
|
|
// Fractional source index.
|
|
vec2 sourceFracIndexRC = ${d};
|
|
|
|
// Compute the four integer indices.
|
|
ivec2 sourceFloorRC = ivec2(max(sourceFracIndexRC, vec2(0.0)));
|
|
ivec2 sourceCeilRC = ivec2(
|
|
min(inputShapeRC - 1.0, ceil(sourceFracIndexRC)));
|
|
|
|
float topLeft = getA(b, sourceFloorRC.x, sourceFloorRC.y, d);
|
|
float bottomLeft = getA(b, sourceCeilRC.x, sourceFloorRC.y, d);
|
|
float topRight = getA(b, sourceFloorRC.x, sourceCeilRC.y, d);
|
|
float bottomRight = getA(b, sourceCeilRC.x, sourceCeilRC.y, d);
|
|
|
|
vec2 fracRC = sourceFracIndexRC - vec2(sourceFloorRC);
|
|
|
|
float top = topLeft + (topRight - topLeft) * fracRC.y;
|
|
float bottom = bottomLeft + (bottomRight - bottomLeft) * fracRC.y;
|
|
float newValue = top + (bottom - top) * fracRC.x;
|
|
|
|
setOutput(newValue);
|
|
}
|
|
`}},CAe=class{constructor(e,t,n,r,s){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=[];let[a,o,i,l]=e;this.outputShape=[a,t,n,l];let u=[r&&t>1?o-1:o,r&&n>1?i-1:i],c=[r&&t>1?t-1:t,r&&n>1?n-1:n],d;s?d="(vec3(yRC) + vec3(0.5)) * effectiveInputOverOutputRatioRC - vec3(0.5)":d="vec3(yRC) * effectiveInputOverOutputRatioRC",this.userCode=`
|
|
const vec3 effectiveInputOverOutputRatioRC = vec3(
|
|
${u[0]/c[0]},
|
|
${u[1]/c[1]},
|
|
${u[1]/c[1]});
|
|
const vec3 inputShapeRC = vec3(${o}.0, ${i}.0,
|
|
${i}.0);
|
|
|
|
float getAValue(int b, int r, int c, int d) {
|
|
return getChannel(getA(b, r, c, d), vec2(c, d));
|
|
}
|
|
|
|
void main() {
|
|
ivec4 coords = getOutputCoords();
|
|
int b = coords[0];
|
|
int d = coords[3];
|
|
// Calculate values for next column in yRC.z.
|
|
ivec3 yRC = coords.yzz + ivec3(0, 0, 1);
|
|
|
|
// Fractional source index.
|
|
vec3 sourceFracIndexRC = ${d};
|
|
|
|
// Compute the four integer indices.
|
|
ivec3 sourceFloorRC = ivec3(max(sourceFracIndexRC, vec3(0.0)));
|
|
ivec3 sourceCeilRC = ivec3(
|
|
min(inputShapeRC - 1.0, ceil(sourceFracIndexRC)));
|
|
|
|
// Should we calculate next column and row elements in 2x2 packed cell.
|
|
bool hasNextCol = d < ${l-1};
|
|
bool hasNextRow = coords.z < ${n-1};
|
|
|
|
// In parallel, construct four corners for all four components in
|
|
// packed 2x2 cell.
|
|
vec4 topLeft = vec4(
|
|
getAValue(b, sourceFloorRC.x, sourceFloorRC.y, d),
|
|
hasNextCol ? getAValue(b, sourceFloorRC.x, sourceFloorRC.y, d + 1)
|
|
: 0.0,
|
|
hasNextRow ? getAValue(b, sourceFloorRC.x, sourceFloorRC.z, d)
|
|
: 0.0,
|
|
(hasNextRow && hasNextCol) ?
|
|
getAValue(b, sourceFloorRC.x, sourceFloorRC.z, d + 1) : 0.0);
|
|
|
|
vec4 bottomLeft = vec4(
|
|
getAValue(b, sourceCeilRC.x, sourceFloorRC.y, d),
|
|
hasNextCol ? getAValue(b, sourceCeilRC.x, sourceFloorRC.y, d + 1)
|
|
: 0.0,
|
|
hasNextRow ? getAValue(b, sourceCeilRC.x, sourceFloorRC.z, d)
|
|
: 0.0,
|
|
(hasNextRow && hasNextCol) ?
|
|
getAValue(b, sourceCeilRC.x, sourceFloorRC.z, d + 1) : 0.0);
|
|
|
|
vec4 topRight = vec4(
|
|
getAValue(b, sourceFloorRC.x, sourceCeilRC.y, d),
|
|
hasNextCol ? getAValue(b, sourceFloorRC.x, sourceCeilRC.y, d + 1)
|
|
: 0.0,
|
|
hasNextRow ? getAValue(b, sourceFloorRC.x, sourceCeilRC.z, d)
|
|
: 0.0,
|
|
(hasNextRow && hasNextCol) ?
|
|
getAValue(b, sourceFloorRC.x, sourceCeilRC.z, d + 1) : 0.0);
|
|
|
|
vec4 bottomRight = vec4(
|
|
getAValue(b, sourceCeilRC.x, sourceCeilRC.y, d),
|
|
hasNextCol ? getAValue(b, sourceCeilRC.x, sourceCeilRC.y, d + 1)
|
|
: 0.0,
|
|
hasNextRow ? getAValue(b, sourceCeilRC.x, sourceCeilRC.z, d)
|
|
: 0.0,
|
|
(hasNextRow && hasNextCol) ?
|
|
getAValue(b, sourceCeilRC.x, sourceCeilRC.z, d + 1) : 0.0);
|
|
|
|
vec3 fracRC = sourceFracIndexRC - vec3(sourceFloorRC);
|
|
|
|
vec4 top = mix(topLeft, topRight, fracRC.yyzz);
|
|
vec4 bottom = mix(bottomLeft, bottomRight, fracRC.yyzz);
|
|
vec4 newValue = mix(top, bottom, fracRC.x);
|
|
|
|
setOutput(newValue);
|
|
}
|
|
`}};function EAe(e){let{inputs:t,backend:n,attrs:r}=e,{images:s}=t,{alignCorners:a,halfPixelCenters:o,size:i}=r,[l,u]=i,c=ae().getBool("WEBGL_PACK_IMAGE_OPERATIONS")?new CAe(s.shape,l,u,a,o):new NAe(s.shape,l,u,a,o);return n.runWebGLProgram(c,[s],"float32")}var $Ae={kernelName:Nl,backendName:"webgl",kernelFunc:EAe},_Ae=class{constructor(e,t,n){this.variableNames=["dy"],this.outputShape=[],this.outputShape=t;let[,r,s]=t,[,a,o]=e,i=[n&&a>1?r-1:r,n&&o>1?s-1:s],l=[n&&a>1?a-1:a,n&&o>1?o-1:o],u=i[0]/l[0],c=i[1]/l[1],d=1/u,h=1/c,p=Math.ceil(d)*2+2,f=Math.ceil(h)*2+2;this.userCode=`
|
|
void main() {
|
|
ivec4 coords = getOutputCoords();
|
|
int b = coords[0];
|
|
int d = coords[3];
|
|
int r = coords[1];
|
|
int c = coords[2];
|
|
|
|
float accumulator = 0.0;
|
|
|
|
const float heightScale = float(${u});
|
|
const float widthScale = float(${c});
|
|
|
|
const float invHeightScale = float(${d});
|
|
const float invWidthScale = float(${h});
|
|
|
|
const int winHeight = int(${p});
|
|
const int winWidth = int(${f});
|
|
|
|
// Compute bounds for where in dy we will look
|
|
float startRLerp = floor(float(r) * invHeightScale);
|
|
int startDyR = int(startRLerp - float(winHeight / 2));
|
|
|
|
float startCLerp = floor(float(c) * invWidthScale);
|
|
int startDyC = int(startCLerp - float(winWidth / 2));
|
|
|
|
// Loop over dy
|
|
for (int dyROffset = 0; dyROffset < winHeight; dyROffset++) {
|
|
int dyR = dyROffset + startDyR;
|
|
|
|
// Guard against the window exceeding the bounds of dy
|
|
if (dyR < 0 || dyR >= ${a}) {
|
|
continue;
|
|
}
|
|
|
|
for (int dyCOffset = 0; dyCOffset < winWidth; dyCOffset++) {
|
|
int dyC = dyCOffset + startDyC;
|
|
|
|
// Guard against the window exceeding the bounds of dy
|
|
if (dyC < 0 || dyC >= ${o}) {
|
|
continue;
|
|
}
|
|
|
|
float dxR = float(dyR) * heightScale;
|
|
int topDxRIndex = int(floor(dxR));
|
|
int bottomDxRIndex = int(min(ceil(dxR), ${r-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), ${s-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 RAe(e){let{inputs:t,backend:n,attrs:r}=e,{images:s,dy:a}=t,{alignCorners:o}=r,i=new _Ae(a.shape,s.shape,o);return n.runWebGLProgram(i,[a],a.dtype)}var DAe={kernelName:qy,backendName:"webgl",kernelFunc:RAe},FAe=class{constructor(e,t,n,r,s){this.variableNames=["A"],this.outputShape=[];let[a,o,i,l]=e;this.outputShape=[a,t,n,l];let u=[r&&t>1?o-1:o,r&&n>1?i-1:i],c=[r&&t>1?t-1:t,r&&n>1?n-1:n],d=r?"0.5":"0.0",h;s?h="max((vec2(yRC) + vec2(0.5)) * effectiveInputOverOutputRatioRC, vec2(0.0))":h="vec2(yRC) * effectiveInputOverOutputRatioRC",this.userCode=`
|
|
const vec2 effectiveInputOverOutputRatioRC = vec2(
|
|
${u[0]/c[0]},
|
|
${u[1]/c[1]});
|
|
const vec2 inputShapeRC = vec2(${o}.0, ${i}.0);
|
|
|
|
void main() {
|
|
ivec4 coords = getOutputCoords();
|
|
int b = coords[0];
|
|
int d = coords[3];
|
|
ivec2 yRC = coords.yz;
|
|
|
|
// Fractional source index.
|
|
vec2 sourceFracIndexRC = ${h};
|
|
|
|
// Compute the coordinators of nearest neighbor point.
|
|
ivec2 sourceNearestRC = ivec2(
|
|
min(inputShapeRC - 1.0, floor(sourceFracIndexRC + ${d})));
|
|
float newValue = getA(b, sourceNearestRC.x, sourceNearestRC.y, d);
|
|
|
|
setOutput(newValue);
|
|
}
|
|
`}},MAe=class{constructor(e,t,n,r,s){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=[];let[a,o,i,l]=e;this.outputShape=[a,t,n,l];let u=[r&&t>1?o-1:o,r&&n>1?i-1:i],c=[r&&t>1?t-1:t,r&&n>1?n-1:n],d=r?"0.5":"0.0",h;s?h="max((vec3(yRC) + vec3(0.5)) * effectiveInputOverOutputRatioRC, vec3(0.0))":h="vec3(yRC) * effectiveInputOverOutputRatioRC",this.userCode=`
|
|
const vec3 effectiveInputOverOutputRatioRC = vec3(
|
|
${u[0]/c[0]},
|
|
${u[1]/c[1]},
|
|
${u[1]/c[1]});
|
|
const vec3 inputShapeRC = vec3(${o}.0, ${i}.0,
|
|
${i}.0);
|
|
|
|
float getAValue(int b, int r, int c, int d) {
|
|
return getChannel(getA(b, r, c, d), vec2(c, d));
|
|
}
|
|
|
|
void main() {
|
|
ivec4 coords = getOutputCoords();
|
|
int b = coords[0];
|
|
int d = coords[3];
|
|
// Calculate values for next column in yRC.z.
|
|
ivec3 yRC = coords.yzz + ivec3(0, 0, 1);
|
|
|
|
// Fractional source index.
|
|
vec3 sourceFracIndexRC = ${h};
|
|
|
|
// Compute the coordinators of nearest neighbor point.
|
|
ivec3 sourceNearestRC = ivec3(
|
|
min(inputShapeRC - 1.0, floor(sourceFracIndexRC + ${d})));
|
|
|
|
// Should we calculate next column and row elements in 2x2 packed cell.
|
|
bool hasNextCol = d < ${l-1};
|
|
bool hasNextRow = coords.z < ${n-1};
|
|
|
|
vec4 newValue = vec4(
|
|
getAValue(b, sourceNearestRC.x, sourceNearestRC.y, d),
|
|
hasNextCol ? getAValue(b, sourceNearestRC.x, sourceNearestRC.y, d + 1)
|
|
: 0.0,
|
|
hasNextRow ? getAValue(b, sourceNearestRC.x, sourceNearestRC.z, d)
|
|
: 0.0,
|
|
(hasNextRow && hasNextCol) ?
|
|
getAValue(b, sourceNearestRC.x, sourceNearestRC.z, d + 1) : 0.0);
|
|
|
|
setOutput(newValue);
|
|
}
|
|
`}};function OAe(e){let{inputs:t,backend:n,attrs:r}=e,{images:s}=t,{alignCorners:a,halfPixelCenters:o,size:i}=r,[l,u]=i,c=ae().getBool("WEBGL_PACK_IMAGE_OPERATIONS")?new MAe(s.shape,l,u,a,o):new FAe(s.shape,l,u,a,o);return n.runWebGLProgram(c,[s],s.dtype)}var PAe={kernelName:af,backendName:"webgl",kernelFunc:OAe},zAe=class{constructor(e,t,n){this.variableNames=["dy"],this.outputShape=[],this.outputShape=t;let[,r,s]=t,[,a,o]=e,i=[n&&a>1?r-1:r,n&&o>1?s-1:s],l=[n&&a>1?a-1:a,n&&o>1?o-1:o],u=i[0]/l[0],c=i[1]/l[1],d=1/u,h=1/c,p=Math.ceil(d)*2+2,f=Math.ceil(h)*2+2;this.userCode=`
|
|
void main() {
|
|
ivec4 coords = getOutputCoords();
|
|
int b = coords[0];
|
|
int d = coords[3];
|
|
int r = coords[1];
|
|
int c = coords[2];
|
|
|
|
float accumulator = 0.0;
|
|
|
|
const float heightScale = float(${u});
|
|
const float widthScale = float(${c});
|
|
|
|
const float invHeightScale = float(${d});
|
|
const float invWidthScale = float(${h});
|
|
|
|
const int winHeight = int(${p});
|
|
const int winWidth = int(${f});
|
|
|
|
// Compute bounds for where in dy we will look
|
|
float startRLerp = floor(float(r) * invHeightScale);
|
|
int startDyR = int(floor(startRLerp - float(winHeight / 2)));
|
|
|
|
float startCLerp = floor(float(c) * invWidthScale);
|
|
int startDyC = int(floor(startCLerp - float(winWidth / 2)));
|
|
|
|
// Loop over dy
|
|
for (int dyROffset = 0; dyROffset < winHeight; dyROffset++) {
|
|
int dyR = dyROffset + startDyR;
|
|
|
|
// Guard against the window exceeding the bounds of dy
|
|
if (dyR < 0 || dyR >= ${a}) {
|
|
continue;
|
|
}
|
|
|
|
for (int dyCOffset = 0; dyCOffset < winWidth; dyCOffset++) {
|
|
int dyC = dyCOffset + startDyC;
|
|
|
|
// Guard against the window exceeding the bounds of dy
|
|
if (dyC < 0 || dyC >= ${o}) {
|
|
continue;
|
|
}
|
|
|
|
float sourceFracRow =
|
|
float(${i[0]}) *
|
|
(float(dyR) / float(${l[0]}));
|
|
|
|
float sourceFracCol =
|
|
float(${i[1]}) *
|
|
(float(dyC) / float(${l[1]}));
|
|
|
|
int sourceNearestRow = int(min(
|
|
float(int(${r}) - 1),
|
|
${n} ? float(round(sourceFracRow)) :
|
|
float(floor(sourceFracRow))));
|
|
|
|
int sourceNearestCol = int(min(
|
|
float(int(${s}) - 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 LAe(e){let{inputs:t,backend:n,attrs:r}=e,{images:s,dy:a}=t,{alignCorners:o}=r,i=new zAe(a.shape,s.shape,o);return n.runWebGLProgram(i,[a],a.dtype)}var BAe={kernelName:jy,backendName:"webgl",kernelFunc:LAe},WAe=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 r=o=>t.indexOf(o)!==-1&&e[o]!==1?`${e[o]} - coords[${o}] - 1`:`coords[${o}]`,s=e.map((o,i)=>r(i)).join(","),a=It(n);this.userCode=`
|
|
void main() {
|
|
${a} coords = getOutputCoords();
|
|
setOutput(getX(${s}));
|
|
}
|
|
`}},VAe=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 r=Vn("rc",n),s=`${r[n-1]} + 1 < ${this.outputShape[n-1]}`,a=`${r[n-2]} + 1 < ${this.outputShape[n-2]}`,o=It(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(${s}){
|
|
result.g = getChannel(getX(${e[0]} - (rc + 1) - 1),
|
|
${e[0]} - (rc + 1) - 1);
|
|
}
|
|
setOutput(result);
|
|
}
|
|
`:this.userCode=`
|
|
void main() {
|
|
${o} rc = getOutputCoords();
|
|
vec4 result = vec4(0.);
|
|
result.r = ${i(r.slice())};
|
|
if(${s}){
|
|
result.g = ${l(r.slice())};
|
|
}
|
|
if(${a}) {
|
|
result.b = ${u(r.slice())};
|
|
if(${s}) {
|
|
result.a = ${c(r.slice())};
|
|
}
|
|
}
|
|
setOutput(result);
|
|
}
|
|
`;function i(p){return d(p)}function l(p){return p[n-1]="("+p[n-1]+" + 1)",d(p)}function u(p){return p[n-2]="("+p[n-2]+" + 1)",d(p)}function c(p){return p[n-1]="("+p[n-1]+" + 1)",p[n-2]="("+p[n-2]+" + 1)",d(p)}function d(p){let f=e.map((y,A)=>h(A,p)),m=f.join(","),g=f.slice(-2).join(",");return`getChannel(getX(${m}), vec2(${g}))`}function h(p,f){return t.indexOf(p)!==-1&&e[p]!==1?`${e[p]} - ${f[p]} - 1`:`${f[p]}`}}};function UAe(e){let{inputs:t,backend:n,attrs:r}=e,{x:s}=t,{dims:a}=r,o=s.shape.length,i=k.parseAxisParam(a,s.shape);if(o===0)return mr({inputs:{x:s},backend:n});let l=ae().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new VAe(s.shape,i):new WAe(s.shape,i);return n.runWebGLProgram(l,[s],s.dtype)}var HAe={kernelName:El,backendName:"webgl",kernelFunc:UAe},GAe=class{constructor(e,t){this.variableNames=["Image"],this.outputShape=[];let n=e[1],r=e[2];this.outputShape=e;let s="";typeof t=="number"?s=`float outputValue = ${t.toFixed(2)};`:s=`
|
|
vec3 fill = vec3(${t.join(",")});
|
|
float outputValue = fill[coords[3]];`,this.userCode=`
|
|
uniform vec4 params;
|
|
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]));
|
|
${s}
|
|
if(coordX >= 0 && coordX < ${r} && coordY >= 0 && coordY < ${n}) {
|
|
outputValue = getImage(coords[0], coordY, coordX, coords[3]);
|
|
}
|
|
setOutput(outputValue);
|
|
}
|
|
`}getCustomSetupFunc(e,t,n,r){return(s,a)=>{this.paramsLoc==null&&(this.paramsLoc=s.getUniformLocationNoThrow(a,"params")),s.gl.uniform4f(this.paramsLoc,e,t,n,r)}}},jAe={kernelName:pd,backendName:"webgl",kernelFunc:({inputs:e,attrs:t,backend:n})=>{let{image:r}=e,{radians:s,fillValue:a,center:o}=t,i=n,l=new GAe(r.shape,a),[u,c]=_.getImageCenter(o,r.shape[1],r.shape[2]),d=l.getCustomSetupFunc(u,c,Math.sin(s),Math.cos(s));return i.runWebGLProgram(l,[r],r.dtype,d)}},qAe=`
|
|
// 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;
|
|
}
|
|
}
|
|
`,KAe=it({opSnippet:qAe}),XAe={kernelName:$l,backendName:"webgl",kernelFunc:KAe},ZAe="return inversesqrt(x);",YAe=it({opSnippet:ZAe,cpuKernelImpl:Spe}),JAe={kernelName:Oo,backendName:"webgl",kernelFunc:YAe},d9=class{constructor(e,t,n,r,s,a,o=!0){this.variableNames=["updates","indices","defaultValue"],this.outputShape=a;let i=It(s.length),l=It(a.length),u="";n===1?u="i":n===2&&(u="i, j");let c=`getIndices(${u})`,d="";r===1?d="i":r===2&&(d="i, coords[1]");let h=`getUpdates(${d})`,p=t>1?"strides[j]":"strides";this.userCode=`
|
|
${i} strides = ${i}(${s});
|
|
|
|
void main() {
|
|
${l} coords = getOutputCoords();
|
|
float sum = 0.0;
|
|
bool found = false;
|
|
for (int i = 0; i < ${e}; i++) {
|
|
int flattenedIndex = 0;
|
|
for (int j = 0; j < ${t}; j++) {
|
|
int index = round(${c});
|
|
flattenedIndex += index * ${p};
|
|
}
|
|
if (flattenedIndex == coords[0]) {
|
|
sum += ${h};
|
|
found = true;
|
|
}
|
|
}
|
|
setOutput(mix(getDefaultValue(), sum, float(found)));
|
|
}
|
|
`}};function QAe(e){let{inputs:t,backend:n,attrs:r}=e,{indices:s,updates:a}=t,{shape:o}=r,{sliceRank:i,numUpdates:l,sliceSize:u,strides:c,outputSize:d}=_.calculateShapes(a,s,o),h=[d/u,u];if(d===0)return n.makeTensorInfo(o,s.dtype);let p=ve({inputs:{x:s},backend:n,attrs:{shape:[l,i]}}),f=ve({inputs:{x:a},backend:n,attrs:{shape:[l,u]}}),m=n.makeTensorInfo([],"float32",new Float32Array([0])),g=new d9(l,i,p.shape.length,f.shape.length,c,h),y=n.runWebGLProgram(g,[f,p,m],f.dtype),A=ve({inputs:{x:y},backend:n,attrs:{shape:o}});return n.disposeIntermediateTensorInfo(p),n.disposeIntermediateTensorInfo(f),n.disposeIntermediateTensorInfo(y),n.disposeIntermediateTensorInfo(m),A}var e1e={kernelName:ed,backendName:"webgl",kernelFunc:QAe},t1e=class{constructor(e,t,n){this.variableNames=["c","a","b"],this.outputShape=t;let r,s;if(n>4)throw Error(`Where for rank ${n} is not yet supported`);if(n===1)s="resRC",r="resRC";else{let o=["resRC.x","resRC.y","resRC.z","resRC.w"],i=[],l=[];for(let u=0;u<t.length;u++)l.push(`${o[u]}`),u<e&&i.push(`${o[u]}`);r=i.join(),s=l.join()}let a=It(n);this.userCode=`
|
|
void main() {
|
|
${a} resRC = getOutputCoords();
|
|
float cVal = getC(${r});
|
|
if (cVal >= 1.0) {
|
|
setOutput(getA(${s}));
|
|
} else {
|
|
setOutput(getB(${s}));
|
|
}
|
|
}
|
|
`}};function n1e(e){let{inputs:t,backend:n}=e,{condition:r,t:s,e:a}=t,o=new t1e(r.shape.length,s.shape,s.shape.length);return n.runWebGLProgram(o,[r,s,a],qr(s.dtype,a.dtype))}var r1e={kernelName:td,backendName:"webgl",kernelFunc:n1e},s1e=`
|
|
// Stable and Attracting Fixed Point (0, 1) for Normalized Weights.
|
|
// see: https://arxiv.org/abs/1706.02515
|
|
float scaleAlpha = ${_.SELU_SCALEALPHA};
|
|
float scale = ${_.SELU_SCALE};
|
|
return (x >= 0.0) ? scale * x : scaleAlpha * (exp(x) - 1.0);
|
|
`,a1e=it({opSnippet:s1e}),o1e={kernelName:nd,backendName:"webgl",kernelFunc:a1e},i1e="return 1.0 / (1.0 + exp(-1.0 * x));",l1e=it({opSnippet:i1e}),u1e={kernelName:Rl,backendName:"webgl",kernelFunc:l1e},c1e=`
|
|
if (isnan(x)) { return 0.0; }
|
|
return sign(x);
|
|
`,d1e=it({opSnippet:c1e}),h1e={kernelName:ad,backendName:"webgl",kernelFunc:d1e},p1e=TE+`
|
|
return sin(x);
|
|
`,f1e=it({opSnippet:p1e}),m1e={kernelName:_l,backendName:"webgl",kernelFunc:f1e},g1e=`
|
|
float e2x = exp(x);
|
|
return (e2x - 1.0 / e2x) / 2.0;
|
|
`,y1e=it({opSnippet:g1e}),A1e={kernelName:sd,backendName:"webgl",kernelFunc:y1e},x1e=`
|
|
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;
|
|
`,b1e=it({opSnippet:x1e}),v1e={kernelName:od,backendName:"webgl",kernelFunc:b1e},w1e=e=>{let{inputs:t,backend:n,attrs:r}=e,{x:s}=t,{blockShape:a,paddings:o}=r;k.assert(s.shape.length<=4,()=>"spaceToBatchND for rank > 4 with a WebGL backend not implemented yet");let i=a.reduce((y,A)=>y*A),l=[[0,0]];l.push(...o);for(let y=1+a.length;y<s.shape.length;++y)l.push([0,0]);let u=[],c=u9({inputs:{x:s},backend:n,attrs:{paddings:l,constantValue:0}}),d=_.getReshaped(c.shape,a,i,!1),h=_.getPermuted(d.length,a.length,!1),p=_.getReshapedPermuted(c.shape,a,i,!1),f=ve({inputs:{x:c},backend:n,attrs:{shape:d}}),m=Un({inputs:{x:f},backend:n,attrs:{perm:h}}),g=ve({inputs:{x:m},backend:n,attrs:{shape:p}});return u.push(c),u.push(f),u.push(m),u.forEach(y=>n.disposeIntermediateTensorInfo(y)),g},k1e={kernelName:of,backendName:"webgl",kernelFunc:w1e};function I1e(e){let{inputs:t,backend:n}=e,{indices:r,values:s,denseShape:a,defaultValue:o}=t;if(a.shape.length!==1)throw new Error(`Dense shape must be a vector, saw:
|
|
${a.shape}`);if(r.shape.length!==2)throw new Error(`Indices must be a matrix, saw:
|
|
${r.shape}`);if(s.shape.length!==1)throw new Error(`Values must be a vector, saw:
|
|
${s.shape}`);if(o.shape.length!==0)throw new Error(`Default value must be a scalar, saw:
|
|
${o.shape}`);let i=n.readSync(r.dataId),l=n.readSync(s.dataId),u=n.readSync(a.dataId),c=n.readSync(o.dataId)[0],[d,h,p,f,m]=Npe(i,r.shape,r.dtype,l,s.dtype,u,c);return[n.makeTensorInfo(h,r.dtype,d),n.makeTensorInfo([h[0]],s.dtype,p),n.makeTensorInfo([f.length],"bool",new Uint8Array(f.map(g=>Number(g)))),n.makeTensorInfo([m.length],r.dtype,new Int32Array(m))]}var S1e={kernelName:Ky,backendName:"webgl",kernelFunc:I1e};function T1e(e){let{inputs:t,backend:n}=e,{inputIndices:r,inputShape:s,newShape:a}=t;if(r.shape.length!==2)throw new Error(`Input indices should be a matrix but received shape ${r.shape}`);if(s.shape.length!==1)throw new Error(`Input shape should be a vector but received shape ${s.shape}`);if(a.shape.length!==1)throw new Error(`Target shape should be a vector but received shape ${a.shape}`);let o=Array.from(n.readSync(s.dataId)),i=n.readSync(r.dataId),l=Array.from(n.readSync(a.dataId)),[u,c,d]=Cpe(i,r.shape,r.dtype,o,l);return[n.makeTensorInfo(c,r.dtype,u),n.makeTensorInfo([d.length],a.dtype,new Int32Array(d))]}var N1e={kernelName:Xy,backendName:"webgl",kernelFunc:T1e};function C1e(e){let{inputs:t,backend:n}=e,{data:r,indices:s,segmentIds:a}=t;if(r.shape.length<1)throw new Error("Data should be at least 1 dimensional but received scalar");if(s.shape.length!==1)throw new Error(`Indices should be a vector but received shape
|
|
${s.shape}`);if(a.shape.length!==1)throw new Error(`Segment ids should be a vector but received shape
|
|
${a.shape}`);let o=n.readSync(r.dataId),i=n.readSync(s.dataId),l=n.readSync(a.dataId),[u,c]=hE(o,r.shape,r.dtype,i,l,!0);return n.makeTensorInfo(c,r.dtype,u)}var E1e={kernelName:Zy,backendName:"webgl",kernelFunc:C1e};function $1e(e){let{inputs:t,backend:n}=e,{data:r,indices:s,segmentIds:a}=t;if(r.shape.length<1)throw new Error("Data should be at least 1 dimensional but received scalar");if(s.shape.length!==1)throw new Error(`Indices should be a vector but received shape
|
|
${s.shape}`);if(a.shape.length!==1)throw new Error(`Segment ids should be a vector but received shape
|
|
${a.shape}`);let o=n.readSync(r.dataId),i=n.readSync(s.dataId),l=n.readSync(a.dataId),[u,c]=hE(o,r.shape,r.dtype,i,l);return n.makeTensorInfo(c,r.dtype,u)}var _1e={kernelName:Yy,backendName:"webgl",kernelFunc:$1e};function R1e(e){let{inputs:t,backend:n,attrs:r}=e,{sparseIndices:s,sparseValues:a,defaultValue:o}=t,{outputShape:i}=r,{sliceRank:l,numUpdates:u,strides:c,outputSize:d}=_.calculateShapes(a,s,i),h=!1,p=new d9(u,l,s.shape.length,a.shape.length,c,[d,1],h),f=n.runWebGLProgram(p,[a,s,o],a.dtype),m=ve({inputs:{x:f},backend:n,attrs:{shape:i}});return n.disposeIntermediateTensorInfo(f),m}var D1e={kernelName:Jy,backendName:"webgl",kernelFunc:R1e};function F1e(e){let{inputs:t,backend:n,attrs:r}=e,{x:s}=t,{numOrSizeSplits:a,axis:o}=r,i=k.parseAxisParam(o,s.shape)[0],l=_.prepareSplitSize(s,a,i),u=s.shape.length,c=new Array(u).fill(0),d=s.shape.slice();return l.map(h=>{let p=[...d];p[i]=h;let f=fh({inputs:{x:s},backend:n,attrs:{begin:c,size:p}});return c[i]+=h,f})}var M1e={kernelName:id,backendName:"webgl",kernelFunc:F1e},O1e="return sqrt(x);",P1e=it({opSnippet:O1e}),z1e={kernelName:Dl,backendName:"webgl",kernelFunc:P1e},L1e="return x * x;",B1e=it({opSnippet:L1e}),W1e={kernelName:lf,backendName:"webgl",kernelFunc:B1e},h9="return (a - b) * (a - b);",V1e=Nn({opSnippet:h9,packedOpSnippet:h9}),U1e={kernelName:Po,backendName:"webgl",kernelFunc:V1e};function H1e({inputs:e,attrs:t,backend:n}){let{x:r}=e,s=ys+`
|
|
return x > 0.0 ? 1.0 : float(${t.alpha});
|
|
`,a=new Qa(r.shape,s);return n.runWebGLProgram(a,[r],r.dtype)}var G1e={kernelName:Bo,backendName:"webgl",kernelFunc:H1e},j1e=class{constructor(e,t,n){this.variableNames=["x"],this.outputShape=n;let r=n.length,s=It(n.length),a=It(n.length),o="";if(r===1)o="coords * strides + begin";else{let i=0;o=n.map((l,u)=>(i++,n.length===1?`coords * strides[${u}] + begin[${u}]`:`coords[${i-1}] * strides[${u}] + begin[${u}]`)).join(",")}this.userCode=`
|
|
${s} begin = ${s}(${e});
|
|
${s} strides = ${s}(${t});
|
|
|
|
void main() {
|
|
${a} coords = getOutputCoords();
|
|
setOutput(getX(${o}));
|
|
}
|
|
`}};function q1e(e){let{inputs:t,backend:n,attrs:r}=e,{x:s}=t,{begin:a,end:o,strides:i,beginMask:l,endMask:u,ellipsisMask:c,newAxisMask:d,shrinkAxisMask:h}=r,{nonStrided:p,$begin:f,$strides:m,size:g,newShape:y,outShape:A}=En.sliceInfo(s.shape,a,o,i,l,u,c,d,h),x=ve({inputs:{x:s},backend:n,attrs:{shape:y}}),b;if(p){let w=fh({inputs:{x},backend:n,attrs:{begin:f,size:g}});b=ve({inputs:{x:w},backend:n,attrs:{shape:A}}),n.disposeIntermediateTensorInfo(w)}else if(A.some(w=>w===0))b=n.makeTensorInfo(A,s.dtype,[]);else if(n.shouldExecuteOnCPU([x])){let T=n.texData.get(x.dataId).values,C=Le(x.shape,x.dtype,T),M=Epe(A,C,m,f);b=n.makeTensorInfo(A,x.dtype,M.values)}else{let I=new j1e(f,m,A);b=n.runWebGLProgram(I,[x],x.dtype)}let v=ve({inputs:{x:b},backend:n,attrs:{shape:A}});return n.disposeIntermediateTensorInfo(x),n.disposeIntermediateTensorInfo(b),v}var K1e={kernelName:ld,backendName:"webgl",kernelFunc:q1e};function X1e(e){let{inputs:t,backend:n,attrs:r}=e,{separator:s,nGramWidths:a,leftPad:o,rightPad:i,padWidth:l,preserveShortSequences:u}=r,{data:c,dataSplits:d}=t,h=n.readSync(c.dataId),p=n.readSync(d.dataId),[f,m]=$pe(h,p,s,a,o,i,l,u);return[n.makeTensorInfo([f.length],"string",f),n.makeTensorInfo(d.shape,"int32",m)]}var Z1e={kernelName:Qy,backendName:"webgl",kernelFunc:X1e};function Y1e(e){let{inputs:t,backend:n,attrs:r}=e,{skipEmpty:s}=r,{input:a,delimiter:o}=t;if(a.dtype!=="string")throw new Error("Input must be of datatype string");if(a.shape.length!==1)throw new Error(`Input must be a vector, got shape: ${a.shape}`);if(o.shape.length!==0)throw new Error(`Delimiter must be a scalar, got shape: ${o.shape}`);let i=n.readSync(a.dataId),l=n.readSync(o.dataId)[0],[u,c,d]=_pe(i,l,s),h=c.length;return[n.makeTensorInfo([h,2],"int32",u),n.makeTensorInfo([h],"string",c),n.makeTensorInfo([2],"int32",new Int32Array(d))]}var J1e={kernelName:eA,backendName:"webgl",kernelFunc:Y1e};function Q1e(e){let{inputs:t,backend:n,attrs:r}=e,{numBuckets:s}=r,{input:a}=t;if(a.dtype!=="string")throw new Error("Input must be of datatype string");if(s<=0)throw new Error("Number of buckets must be at least 1");let o=n.readSync(a.dataId),i=Rpe(o,s);return n.makeTensorInfo(a.shape,"int32",i)}var exe={kernelName:tA,backendName:"webgl",kernelFunc:Q1e},txe="return tan(x);",nxe=it({opSnippet:txe}),rxe={kernelName:Ol,backendName:"webgl",kernelFunc:nxe},sxe=`
|
|
float e2x = exp(-2.0 * abs(x));
|
|
return sign(x) * (1.0 - e2x) / (1.0 + e2x);
|
|
`,axe=it({opSnippet:sxe}),oxe={kernelName:Pl,backendName:"webgl",kernelFunc:axe},ixe=class{constructor(e,t){this.variableNames=["A"];let n=new Array(e.length);for(let a=0;a<n.length;a++)n[a]=e[a]*t[a];this.outputShape=n,this.rank=n.length;let r=It(this.rank),s=lxe(e);this.userCode=`
|
|
void main() {
|
|
${r} resRC = getOutputCoords();
|
|
setOutput(getA(${s}));
|
|
}
|
|
`}};function lxe(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"],r=[];for(let s=0;s<e.length;s++)r.push(`imod(${n[s]}, ${e[s]})`);return r.join()}function p9(e){let{inputs:t,backend:n,attrs:r}=e,{x:s}=t,{reps:a}=r;if(s.dtype==="string"||s.shape.length>5){let l=n.readSync(s.dataId),u=s.dtype==="string"?l.map(h=>k.decodeString(h)):l,c=Le(s.shape,s.dtype,u),d=Fpe(c,a);return n.makeTensorInfo(d.shape,d.dtype,d.values)}let o=new ixe(s.shape,a);return n.runWebGLProgram(o,[s],s.dtype)}var uxe={kernelName:Lo,backendName:"webgl",kernelFunc:p9};function cxe(e){let{inputs:t,backend:n,attrs:r}=e,{x:s}=t,{k:a,sorted:o}=r,i=n.readSync(s.dataId),[l,u]=Mpe(i,s.shape,s.dtype,a,o);return[n.makeTensorInfo(l.shape,l.dtype,l.values),n.makeTensorInfo(u.shape,u.dtype,u.values)]}var dxe={kernelName:ud,backendName:"webgl",kernelFunc:cxe},hxe=class{constructor(e,t,n,r,s,a){this.variableNames=["Image","Transforms"],this.outputShape=a;let o=n==="nearest"?1:2,i;switch(r){case"constant":i=1;break;case"reflect":i=2;break;case"wrap":i=3;break;case"nearest":i=4;break;default:i=1;break}this.userCode=`
|
|
float mapCoord(float outCoord, float len) {
|
|
float inCoord = outCoord;
|
|
if(${i} == 2) {
|
|
if (inCoord < 0.0) {
|
|
if (len <= 1.0) {
|
|
inCoord = 0.0;
|
|
} else {
|
|
float sz2 = 2.0 * len;
|
|
if (inCoord < sz2) {
|
|
inCoord = sz2 * float(int(float(-inCoord / sz2))) +
|
|
inCoord;
|
|
}
|
|
inCoord = inCoord < -len ? inCoord + sz2 : -inCoord - 1.0;
|
|
}
|
|
} else if (inCoord > len - 1.0) {
|
|
if (len <= 1.0) {
|
|
inCoord = 0.0;
|
|
} else {
|
|
float sz2 = 2.0 * len;
|
|
inCoord -= sz2 * float(int(float(inCoord / sz2)));
|
|
if (inCoord >= len) {
|
|
inCoord = sz2 - inCoord - 1.0;
|
|
}
|
|
}
|
|
}
|
|
return clamp(inCoord, 0.0, len - 1.0);
|
|
} else if (${i} == 3) {
|
|
if (inCoord < 0.0) {
|
|
if (len <= 1.0) {
|
|
inCoord = 0.0;
|
|
} else {
|
|
float sz = len - 1.0;
|
|
inCoord += len * (float(int(float(-inCoord / sz))) + 1.0);
|
|
}
|
|
} else if (inCoord > len - 1.0) {
|
|
if (len <= 1.0) {
|
|
inCoord = 0.0;
|
|
} else {
|
|
float sz = len - 1.0;
|
|
inCoord -= len * float(int(float(inCoord / sz)));
|
|
}
|
|
}
|
|
return clamp(inCoord, 0.0, len - 1.0);
|
|
} else if (${i} == 4) {
|
|
return clamp(outCoord, 0.0, len - 1.0);
|
|
} else {
|
|
return outCoord;
|
|
}
|
|
}
|
|
|
|
float readWithFillValue(int batch, int coordY, int coordX,
|
|
int channel) {
|
|
float outputValue;
|
|
if (0 <= coordY && coordY < ${e} && 0 <= coordX && coordX < ${t}) {
|
|
outputValue = getImage(batch, coordY, coordX, channel);
|
|
} else {
|
|
outputValue = float(${s});
|
|
}
|
|
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(${s});
|
|
} else {
|
|
float inX = (a1 * xf + a2 * yf + a3) / projection;
|
|
float inY = (b1 * xf + b2 * yf + b3) / projection;
|
|
float mapX = mapCoord(inX, float(${t}));
|
|
float mapY = mapCoord(inY, float(${e}));
|
|
|
|
if (${o} == 1) {
|
|
int coordY = int(round(mapY));
|
|
int coordX = int(round(mapX));
|
|
outputValue = readWithFillValue(batch, coordY, coordX,
|
|
channel);
|
|
} else {
|
|
float yFloor = floor(mapY);
|
|
float xFloor = floor(mapX);
|
|
float yCeil = yFloor + 1.0;
|
|
float xCeil = xFloor + 1.0;
|
|
float valueYFloor = (xCeil - mapX) *
|
|
readWithFillValue(batch, int(yFloor), int(xFloor), channel) +
|
|
(mapX - xFloor) *
|
|
readWithFillValue(batch, int(yFloor), int(xCeil), channel);
|
|
float valueYCeil = (xCeil - mapX) *
|
|
readWithFillValue(batch, int(yCeil), int(xFloor), channel) +
|
|
(mapX - xFloor) *
|
|
readWithFillValue(batch, int(yCeil), int(xCeil), channel);
|
|
outputValue = (yCeil - mapY) * valueYFloor +
|
|
(mapY - yFloor) * valueYCeil;
|
|
}
|
|
}
|
|
setOutput(outputValue);
|
|
}
|
|
`}};function pxe(e){let{inputs:t,backend:n,attrs:r}=e,{image:s,transforms:a}=t,{interpolation:o,fillMode:i,fillValue:l,outputShape:u}=r,[c,d,h,p]=s.shape,[f,m]=u!=null?u:[d,h],g=[c,f,m,p],y=new hxe(d,h,o,i,l,g);return n.runWebGLProgram(y,[s,a],"float32")}var fxe={kernelName:cd,backendName:"webgl",kernelFunc:pxe};function mxe(e){let{inputs:t,attrs:n,backend:r}=e,{axis:s}=n,{x:a}=t;mu(a,"unique"),console.warn("WARNING: ","UI might be locked temporarily as data is being downloaded");let o=r.readSync(a.dataId),{outputValues:i,outputShape:l,indices:u}=Ope(o,s,a.shape,a.dtype);return[r.makeTensorInfo(l,a.dtype,i),r.makeTensorInfo([u.length],"int32",u)]}var gxe={kernelName:nA,backendName:"webgl",kernelFunc:mxe};function yxe(e){let{inputs:t,backend:n,attrs:r}=e,{value:s}=t,{axis:a}=r;a<0&&(a+=s.shape.length);let o=s,i=o.shape.length,l=s.shape[a],u=new Array(i-1),c=0;for(let m=0;m<i;m++)m!==a&&(u[c++]=o.shape[m]);let d=[],h=new Array(i).fill(0),p=o.shape.slice();p[a]=1;let f=new Array(l);for(let m=0;m<f.length;m++){h[a]=m;let g=fh({inputs:{x:o},backend:n,attrs:{begin:h,size:p}}),y=ve({inputs:{x:g},backend:n,attrs:{shape:u}});f[m]=y,d.push(g)}return d.forEach(m=>n.disposeIntermediateTensorInfo(m)),f}var Axe={kernelName:dd,backendName:"webgl",kernelFunc:yxe},xxe=class{constructor(e,t){this.variableNames=["x","segmentIds"];let n=e.windowSize,r=e.batchSize,s=e.inSize,a=e.numSegments,o=a*Math.ceil(s/n);this.outputShape=[r,o];let i="0.0",l="sumValue",u=Math.floor(n/4)*4,c=n%4,d=`
|
|
sumValue += dot(values, segFilter);
|
|
`,h="";s%n>0&&(h=`
|
|
if (inIdx < 0 || inIdx >= ${s}) {
|
|
return initializationValue;
|
|
}
|
|
`);let p="";s%n>0&&(p=`
|
|
if (inIdx < 0 || inIdx >= ${s}) {
|
|
return -1.0;
|
|
}
|
|
`),this.userCode=`
|
|
const float initializationValue = ${i};
|
|
|
|
float getValue(int batch, int inIdx) {
|
|
${h}
|
|
return getX(batch, inIdx);
|
|
}
|
|
|
|
float getSegmentIdAtIndex(int inIdx) {
|
|
${p}
|
|
return getSegmentIds(inIdx);
|
|
}
|
|
|
|
void main() {
|
|
ivec2 coords = getOutputCoords();
|
|
int batch = coords[0];
|
|
int outIdx = coords[1];
|
|
int inOffset = int(floor(float(outIdx) / float(
|
|
${a})) * float(${n}));
|
|
int currentSeg = int(mod(float(outIdx), float(${a})));
|
|
|
|
float sumValue = 0.0;
|
|
|
|
for (int i = 0; i < ${u}; i += 4) {
|
|
int inIdx = inOffset + i;
|
|
vec4 values = vec4(
|
|
getValue(batch, inIdx),
|
|
getValue(batch, inIdx + 1),
|
|
getValue(batch, inIdx + 2),
|
|
getValue(batch, inIdx + 3)
|
|
);
|
|
|
|
vec4 segFilter = vec4(
|
|
int(getSegmentIdAtIndex(inIdx)) == currentSeg ? 1 : 0,
|
|
int(getSegmentIdAtIndex(inIdx + 1)) == currentSeg ? 1 : 0,
|
|
int(getSegmentIdAtIndex(inIdx + 2)) == currentSeg ? 1 : 0,
|
|
int(getSegmentIdAtIndex(inIdx + 3)) == currentSeg ? 1 : 0
|
|
);
|
|
|
|
${d}
|
|
}
|
|
|
|
int inIdx = inOffset + ${u};
|
|
if (${c===1}) {
|
|
vec4 values = vec4(
|
|
getValue(batch, inIdx),
|
|
initializationValue,
|
|
initializationValue,
|
|
initializationValue
|
|
);
|
|
|
|
int inIdxSeg = int(getSegmentIdAtIndex(inIdx));
|
|
|
|
vec4 segFilter = vec4(
|
|
int(getSegmentIdAtIndex(inIdx)) == currentSeg ? 1 : 0,
|
|
0,
|
|
0,
|
|
0
|
|
);
|
|
|
|
${d}
|
|
} else if (${c===2}) {
|
|
vec4 values = vec4(
|
|
getValue(batch, inIdx),
|
|
getValue(batch, inIdx + 1),
|
|
initializationValue,
|
|
initializationValue
|
|
);
|
|
|
|
vec4 segFilter = vec4(
|
|
int(getSegmentIdAtIndex(inIdx)) == currentSeg ? 1 : 0,
|
|
int(getSegmentIdAtIndex(inIdx + 1)) == currentSeg ? 1 : 0,
|
|
0,
|
|
0
|
|
);
|
|
|
|
${d}
|
|
} else if (${c===3}) {
|
|
vec4 values = vec4(
|
|
getValue(batch, inIdx),
|
|
getValue(batch, inIdx + 1),
|
|
getValue(batch, inIdx + 2),
|
|
initializationValue
|
|
);
|
|
|
|
vec4 segFilter = vec4(
|
|
int(getSegmentIdAtIndex(inIdx)) == currentSeg ? 1 : 0,
|
|
int(getSegmentIdAtIndex(inIdx + 1)) == currentSeg ? 1 : 0,
|
|
int(getSegmentIdAtIndex(inIdx + 2)) == currentSeg ? 1 : 0,
|
|
0
|
|
);
|
|
|
|
${d}
|
|
}
|
|
setOutput(${l});
|
|
}
|
|
`}};function bxe(e){let{inputs:t,backend:n,attrs:r}=e,{x:s,segmentIds:a}=t,{numSegments:o}=r,i=s.shape.length,l=[],u=0,c=_.getAxesPermutation([u],i),d=s;c!=null&&(d=Un({inputs:{x:s},backend:n,attrs:{perm:c}}),l.push(d),u=_.getInnerMostAxes(1,i)[0]);let h=_.segment_util.computeOutShape(d.shape,u,o),p=k.sizeFromShape([d.shape[u]]),f=ve({inputs:{x:d},backend:n,attrs:{shape:[-1,p]}});l.push(f);let m=pA(s.dtype),g=(b,v,w,I,T)=>{let C=b.shape[0],M=b.shape[1],$=_.segment_util.segOpComputeOptimalWindowSize(M,T),R={windowSize:$,inSize:M,batchSize:C,numSegments:T},N=new xxe(R,v),F=n.compileAndRun(N,[b,w],I);if(l.push(F),F.shape[1]===T)return F;let B=c9({backend:n,attrs:{start:0,stop:T,step:1,dtype:"float32"}}),j=p9({inputs:{x:B},backend:n,attrs:{reps:[M/$]}});return l.push(B),l.push(j),g(F,v,j,I,T)},y=g(f,"unsortedSegmentSum",a,m,o),A=ve({inputs:{x:y},backend:n,attrs:{shape:h}}),x=A;if(c!=null){l.push(A);let b=_.getUndoAxesPermutation(c);x=Un({inputs:{x},backend:n,attrs:{perm:b}})}return l.forEach(b=>n.disposeIntermediateTensorInfo(b)),x}var vxe={kernelName:uf,backendName:"webgl",kernelFunc:bxe},wxe=[Z2e,Q2e,Mfe,Pfe,Bfe,Ufe,Gfe,Kfe,Zfe,Jfe,nme,sme,ime,cme,yme,pme,bme,Ime,wme,Cme,$me,Rme,Ome,Ume,Gme,Yme,Qme,r0e,o0e,gfe,d0e,v0e,k0e,m0e,N0e,E0e,S0e,R0e,M0e,z0e,B0e,V0e,G0e,Y0e,Q0e,q0e,nge,age,ige,dge,mge,xge,wge,kge,Ige,Tge,Cge,$ge,Rge,Fge,zge,Wge,Hge,jge,Xge,Qge,r2e,i2e,mfe,u2e,u0e,h2e,m2e,A2e,Afe,w2e,T2e,C2e,M2e,R2e,L2e,V2e,j2e,tye,uye,iye,pye,mye,yye,aye,xye,vye,Sye,Eye,Dye,Wye,kfe,Uye,jye,Xye,Jye,qme,tAe,rAe,aAe,lAe,hAe,bfe,fAe,mAe,Kme,Pye,AAe,TAe,wAe,Sfe,$Ae,DAe,PAe,BAe,HAe,jAe,XAe,JAe,e1e,r1e,o1e,u1e,h1e,m1e,A1e,Wme,Lye,v1e,k1e,S1e,N1e,E1e,_1e,D1e,M1e,z1e,W1e,U1e,G1e,K1e,Z1e,J1e,exe,zye,Rfe,rxe,oxe,uxe,dxe,fxe,Dfe,gxe,Axe,vxe,nAe];for(let e of wxe)oA(e);var tr;(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"})(tr||(tr={}));var gh;(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"})(gh||(gh={}));var f9;function kxe(e){f9=e.wasm.cwrap(Ll,null,["number","array","number","number","array","number","number","number","number","number","number","number","number"])}function Ixe(e){let{inputs:t,backend:n,attrs:r}=e,{a:s,b:a,bias:o,preluActivationWeights:i}=t;if(s.dtype!=="float32"||a.dtype!=="float32")throw new Error("_FusedMatMul for non non-float32 tensors not yet supported.");let{transposeA:l,transposeB:u,activation:c,leakyreluAlpha:d}=r,h=n.dataIdMap.get(s.dataId).id,p=n.dataIdMap.get(a.dataId).id,f=0;if(o!=null){let T=n.dataIdMap.get(o.dataId);if(T.shape.length!==1)throw new Error(`_FusedMatMul only supports rank-1 bias but got rank ${T.shape.length}.`);f=T.id}let m=i==null?0:n.dataIdMap.get(i.dataId).id,g=gh[c];if(g==null)throw new Error(`${c} activation not yet supported for FusedConv2D in the wasm backend.`);let y=l?s.shape[2]:s.shape[1],A=u?a.shape[1]:a.shape[2],x=s.shape[0],b=n.makeOutput([x,y,A],s.dtype),v=n.dataIdMap.get(b.dataId).id,w=new Uint8Array(new Int32Array(s.shape).buffer),I=new Uint8Array(new Int32Array(a.shape).buffer);return f9(h,w,s.shape.length,p,I,a.shape.length,l,u,g,f,m,d||0,v),b}var Sxe={kernelName:Ll,backendName:"wasm",setupFunc:kxe,kernelFunc:Ixe};function Hn(e){let t;function n(s){t=s.wasm.cwrap(e,null,["number","number"])}function r(s){let{backend:a,inputs:{x:o}}=s,i=a.dataIdMap.get(o.dataId).id,l=a.makeOutput(o.shape,o.dtype),u=a.dataIdMap.get(l.dataId).id;return k.sizeFromShape(l.shape)===0||t(i,u),l}return{kernelName:e,backendName:"wasm",setupFunc:n,kernelFunc:r}}var Txe=Hn(xc);function Gn(e,t,n){let r;function s(o){r=o.wasm.cwrap(e,null,["number","array","number","number","array","number","number","number"])}function a(o){let{backend:i,inputs:l}=o,{a:u,b:c}=l,d=i.dataIdMap.get(u.dataId).id,h=i.dataIdMap.get(c.dataId).id,p=n!=null?n:u.dtype,f=_.assertAndGetBroadcastShape(u.shape,c.shape),m=i.makeOutput(f,p);if(k.sizeFromShape(f)===0)return m;let g=new Uint8Array(new Int32Array(u.shape).buffer),y=new Uint8Array(new Int32Array(c.shape).buffer),A=i.dataIdMap.get(m.dataId).id,x=()=>r(d,g,u.shape.length,h,y,c.shape.length,tr[u.dtype],A);if(t&&u.dtype==="float32")return x(),m;let b=_.getBroadcastDims(u.shape,f),v=_.getBroadcastDims(c.shape,f),w=b.every((T,C)=>T===C),I=v.every((T,C)=>T===C);if(w&&I)return x(),m;throw new Error(`Broadcasting along outer dims is not yet supported for ${u.dtype} ${e}.`)}return{kernelName:e,backendName:"wasm",setupFunc:s,kernelFunc:a}}var Nxe=!0,Cxe=Gn(Fa,Nxe),m9;function Exe(e){m9=e.wasm.cwrap(Zi,null,["array","number","number","number"])}function $xe(e){let{inputs:t,backend:n}=e,r=n.makeOutput(t[0].shape,t[0].dtype);if(k.sizeFromShape(r.shape)===0)return r;let s=t.map(i=>n.dataIdMap.get(i.dataId).id),a=new Uint8Array(new Int32Array(s).buffer),o=n.dataIdMap.get(r.dataId).id;return m9(a,s.length,tr[r.dtype],o),r}var _xe={kernelName:Zi,backendName:"wasm",setupFunc:Exe,kernelFunc:$xe};function Qm(e){let{inputs:{x:t},backend:n}=e,r=n.makeOutput(t.shape,t.dtype),s=n.typedArrayFromHeap(t);return n.typedArrayFromHeap(r).set(s),r}var Rxe={kernelName:hl,backendName:"wasm",kernelFunc:Qm},g9;function Dxe(e){g9=e.wasm.cwrap(zl,null,["number","array","number","number","number","array","number"])}function e0(e){let{inputs:t,backend:n,attrs:r}=e,[s,a]=Mxe(t.x.shape,r.perm),o=!0;for(let f=0;f<a.length;f++)a[f]!==f&&(o=!1);let i=Fxe(t.x.shape,r.perm),l={dataId:t.x.dataId,shape:s,dtype:t.x.dtype};if(o){let f=Qm({inputs:t,backend:n});return f.shape=i,f}let u=n.makeOutput(i,l.dtype),c=n.dataIdMap.get(l.dataId).id,d=n.dataIdMap.get(u.dataId).id,h=new Uint8Array(new Int32Array(a).buffer),p=new Uint8Array(new Int32Array(l.shape).buffer);return g9(c,p,l.shape.length,tr[l.dtype],d,h,a.length),u}function Fxe(e,t){let n=new Array(e.length);for(let r=0;r<n.length;r++)n[r]=e[t[r]];return n}function Mxe(e,t){let n=[],r=[];for(let s=0;s<e.length;++s)e[s]!==1&&n.push(e[s]),e[t[s]]!==1&&r.push(t[s]);for(let s=0;s<r.length;++s){let a=-1;for(let o=0;o<r.length;++o)r[o]>=s&&(a===-1||r[a]>r[o])&&(a=o);r[a]=s}return[n,r]}var Oxe={kernelName:zl,backendName:"wasm",kernelFunc:e0,setupFunc:Dxe};function to(e,t,n){let r=e.shape,s=e.shape.length,a=k.parseAxisParam(t,r),o=a,i=_.getAxesPermutation(o,s),l=null,u=!1;if(i!=null){let c=new Array(s);for(let p=0;p<c.length;p++)c[p]=r[i[p]];o=_.getInnerMostAxes(o.length,s),l=e0({inputs:{x:e},attrs:{perm:i},backend:n});let d=n.dataIdMap.get(e.dataId).id;n.dataIdMap.get(l.dataId).id!==d&&(u=!0)}return{transposed:l,originalAxes:a,axes:o,inputWasTransposed:u}}var y9;function Pxe(e){y9=e.wasm.cwrap(wc,null,["number, number, number"])}function zxe(e){let{backend:t,inputs:n,attrs:r}=e,{axis:s,keepDims:a}=r,{x:o}=n,l=t.dataIdMap.get(o.dataId).id,u=o,{transposed:c,axes:d,originalAxes:h,inputWasTransposed:p}=to(o,s,t);if(p){let x=t.dataIdMap.get(c.dataId).id;u=c,l=x}let f=u.shape.length;_.assertAxesAreInnerMostDims("all",d,f);let[m,g]=_.computeOutAndReduceShapes(u.shape,d),y=k.sizeFromShape(g),A=t.makeOutput(m,o.dtype);if(k.sizeFromShape(u.shape)!==0){let x=t.dataIdMap.get(A.dataId).id;y9(l,y,x)}if(p&&t.disposeData(c.dataId),a){let x=_.expandShapeToKeepDim(A.shape,h);A.shape=x}return A}var Lxe={kernelName:wc,backendName:"wasm",setupFunc:Pxe,kernelFunc:zxe},A9;function Bxe(e){A9=e.wasm.cwrap(kc,null,["number, number, number"])}function Wxe(e){let{backend:t,inputs:n,attrs:r}=e,{axis:s,keepDims:a}=r,{x:o}=n,l=t.dataIdMap.get(o.dataId).id,u=o,{transposed:c,axes:d,originalAxes:h,inputWasTransposed:p}=to(o,s,t);if(p){let x=t.dataIdMap.get(c.dataId).id;u=c,l=x}let f=u.shape.length;_.assertAxesAreInnerMostDims("any",d,f);let[m,g]=_.computeOutAndReduceShapes(u.shape,d),y=k.sizeFromShape(g),A=t.makeOutput(m,o.dtype);if(k.sizeFromShape(u.shape)!==0){let x=t.dataIdMap.get(A.dataId).id;A9(l,y,x)}if(p&&t.disposeData(c.dataId),a){let x=_.expandShapeToKeepDim(A.shape,h);A.shape=x}return A}var Vxe={kernelName:kc,backendName:"wasm",setupFunc:Bxe,kernelFunc:Wxe},x9;function Uxe(e){x9=e.wasm.cwrap(Yi,null,["number","number","number","number","number"])}function Hxe(e){let{backend:t,inputs:n,attrs:r}=e,{axis:s}=r,{x:a}=n,o=t.dataIdMap.get(a.dataId).id,i=o,l=a,{transposed:u,axes:c,inputWasTransposed:d}=to(a,s,t);if(d){let y=t.dataIdMap.get(u.dataId).id;y!==o&&(l=u,i=y)}let h=l.shape.slice(0,-1),p=t.makeOutput(h,"int32"),f=t.dataIdMap.get(p.dataId).id,m=k.sizeFromShape(p.shape),g=l.shape[c[0]];return x9(i,tr[l.dtype],m,g,f),d&&t.disposeData(u.dataId),p}var Gxe={kernelName:Yi,backendName:"wasm",kernelFunc:Hxe,setupFunc:Uxe},b9;function jxe(e){b9=e.wasm.cwrap(Ji,null,["number","number","number","number","number","number","number","number","number","number","number","number","number","number"])}function qxe(e){let{inputs:t,attrs:n,backend:r}=e,s=t.x,a=r.dataIdMap.get(s.dataId).id,{filterSize:o,strides:i,pad:l,dimRoundingMode:u}=n,c=_.computePool2DInfo(s.shape,o,i,1,l,u),d=c.filterHeight,h=c.filterWidth,p=c.padInfo.top,f=c.padInfo.right,m=c.padInfo.bottom,g=c.padInfo.left,y=c.strideHeight,A=c.strideWidth,x=c.inChannels;if(c.dataFormat!=="channelsLast")throw new Error(`wasm backend does not support dataFormat:'${c.dataFormat}'. Please use 'channelsLast'.`);if(c.dilationWidth!==1||c.dilationHeight!==1)throw new Error(`was backend only supports average pooling with dilation = [1, 1], got [${c.dilationHeight}, ${c.dilationWidth}].`);let b=r.makeOutput(c.outShape,"float32"),v=r.dataIdMap.get(b.dataId).id;return b9(a,s.shape[0],s.shape[1],s.shape[2],d,h,p,f,m,g,y,A,x,v),b}var Kxe={kernelName:Ji,backendName:"wasm",setupFunc:jxe,kernelFunc:qxe};function As(e){let{inputs:t,attrs:n}=e,{x:r}=t,{shape:s}=n,a=k.sizeFromShape(r.shape),o=k.inferFromImplicitShape(s,a);return k.assert(a===k.sizeFromShape(o),()=>`new shape: ${o}, old shape: ${r.shape}. New shape and old shape must have the same number of elements.`),e.backend.incRef(r.dataId),{dataId:r.dataId,shape:o,dtype:r.dtype}}var Xxe={kernelName:Qc,backendName:"wasm",kernelFunc:As},v9;function Zxe(e){v9=e.wasm.cwrap(Qi,null,["number","array","number","number","array","number","number","number","number"])}function Yxe(e){let{inputs:t,backend:n,attrs:r}=e,{a:s,b:a}=t,{transposeA:o,transposeB:i}=r;if(s.dtype!=="float32"||a.dtype!=="float32")throw new Error("BatchMatMul for non non-float32 tensors not yet supported.");let l=s.shape.length,u=a.shape.length,c=o?s.shape[l-2]:s.shape[l-1],d=i?a.shape[u-1]:a.shape[u-2],h=o?s.shape[l-1]:s.shape[l-2],p=i?a.shape[u-2]:a.shape[u-1],f=s.shape.slice(0,-2),m=a.shape.slice(0,-2),g=k.sizeFromShape(f),y=k.sizeFromShape(m),A=g===y||g===1||y===1;k.assert(l>=2&&u>=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 b=(g>y?s.shape.slice(0,-2):a.shape.slice(0,-2)).concat([h,p]);k.assert(c===d,()=>`Error in matMul: inner shapes (${c}) and (${d}) of Tensors with shapes ${s.shape} and ${a.shape} and transposeA=${o} and transposeB=${i} must match.`);let v=o?[g,c,h]:[g,h,c],w=i?[y,p,d]:[y,d,p],I=As({inputs:{x:s},backend:n,attrs:{shape:v}}),T=As({inputs:{x:a},backend:n,attrs:{shape:w}}),C=n.dataIdMap.get(I.dataId).id,M=n.dataIdMap.get(T.dataId).id,$=o?I.shape[2]:I.shape[1],R=i?T.shape[1]:T.shape[2],N=Math.max(g,y),F=n.makeOutput([N,$,R],I.dtype),B=n.dataIdMap.get(F.dataId).id,j=new Uint8Array(new Int32Array(I.shape).buffer),X=new Uint8Array(new Int32Array(T.shape).buffer);return v9(C,j,I.shape.length,M,X,T.shape.length,o,i,B),n.disposeData(I.dataId),n.disposeData(T.dataId),F.shape=b,F}var Jxe={kernelName:Qi,backendName:"wasm",setupFunc:Zxe,kernelFunc:Yxe};function t0(e){let{inputs:{x:t},attrs:{dtype:n},backend:r}=e,s=r.makeOutput(t.shape,n),a=r.typedArrayFromHeap(t);return r.typedArrayFromHeap(s).set(a),s}var Qxe={kernelName:el,backendName:"wasm",kernelFunc:t0},e5e=Hn(No),w9;function t5e(e){w9=e.wasm.cwrap(Co,null,["number","number","number","number"])}function n5e(e){let{inputs:t,backend:n,attrs:r}=e,{x:s}=t,{clipValueMin:a,clipValueMax:o}=r,i=n.dataIdMap.get(s.dataId).id,l=n.makeOutput(s.shape,s.dtype),u=n.dataIdMap.get(l.dataId).id;return w9(i,a,o,u),l}var r5e={kernelName:Co,backendName:"wasm",setupFunc:t5e,kernelFunc:n5e};function k9(e){let{inputs:t,backend:n}=e,r=k.parseAxisParam(e.attrs.axis,t[0].shape)[0],s=_.computeOutShape(t.map(p=>p.shape),r),a=t.filter(p=>k.sizeFromShape(p.shape)>0);if(a.length===1)return Qm({inputs:{x:a[0]},backend:n});let o=n.makeOutput(s,t[0].dtype);if(k.sizeFromShape(s)===0)return o;let i=a.map(p=>p.shape);if(_.assertParamsConsistent(i,r),a[0].dtype==="string"){let p=a.map(x=>{let b=k.sizeFromShape(x.shape.slice(r));return As({inputs:{x},backend:n,attrs:{shape:[-1,b]}})}),f=p.map(x=>({vals:n.readSync(x.dataId),shape:x.shape}));s=_.computeOutShape(p.map(x=>x.shape),1);let m=p[0].shape[0]===1,g=qC(f,s,t[0].dtype,m),y=_.computeOutShape(a.map(x=>x.shape),r);o.shape=y;let A=n.dataIdMap.get(o.dataId);return A.stringBytes=_.fromStringArrayToUint8(g),p.forEach(x=>n.disposeData(x.dataId)),o}let l=k.sizeFromShape(a[0].shape.slice(0,r)),u=0,c=a.map(p=>{let f=k.sizeFromShape(p.shape.slice(r));return u+=f,f}),d=a.map(p=>n.typedArrayFromHeap(p)),h=n.typedArrayFromHeap(o);for(let p=0;p<l;p++){let f=p*u;for(let m=0;m<d.length;m++){let g=c[m],y=p*g,A=d[m].subarray(y,y+g);h.set(A,f),f+=g}}return o}var s5e={kernelName:Ec,backendName:"wasm",kernelFunc:k9},I9;function a5e(e){I9=e.wasm.cwrap(tl,null,["number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number"])}function o5e(e){let{inputs:t,attrs:n,backend:r}=e,{x:s,filter:a}=t,o=r.dataIdMap.get(s.dataId).id,i=r.dataIdMap.get(a.dataId).id,{strides:l,dilations:u,pad:c,dimRoundingMode:d,dataFormat:h}=n,p=_.convertConv2DDataFormat(h),f=_.computeConv2DInfo(s.shape,a.shape,l,u,c,d,!1,p),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,w=f.dilationWidth,I=f.strideHeight,T=f.strideWidth,C=f.inChannels,M=f.outChannels,$=f.padInfo.type==="SAME"?1:0;if(f.dataFormat!=="channelsLast")throw new Error(`wasm backend Conv2D does not support dataFormat:'${f.dataFormat}'. Please use 'channelsLast'.`);let R=r.makeOutput(f.outShape,"float32"),N=r.dataIdMap.get(R.dataId).id;return I9(o,s.shape[0],s.shape[1],s.shape[2],i,m,g,y,A,x,b,$,v,w,I,T,C,M,N),R}var i5e={kernelName:tl,backendName:"wasm",setupFunc:a5e,kernelFunc:o5e},S9;function l5e(e){S9=e.wasm.cwrap(nl,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 u5e(e){let{backend:t,inputs:n,attrs:r}=e,{dy:s,filter:a}=n,{strides:o,pad:i,dataFormat:l,dimRoundingMode:u,inputShape:c}=r,d=1,h=_.convertConv2DDataFormat(l),p=_.computeConv2DInfo(c,a.shape,o,d,i,u,!1,h),{batchSize:f,filterHeight:m,filterWidth:g,inChannels:y,inHeight:A,inWidth:x,outChannels:b,outHeight:v,outWidth:w,strideHeight:I,strideWidth:T}=p,C=m-1-p.padInfo.top,M=g-1-p.padInfo.left,$=p.dataFormat==="channelsLast",R=k.computeStrides(p.inShape),N=k.computeStrides(s.shape),[F,B,j]=k.computeStrides(a.shape),X=R[0],Y=$?R[1]:R[2],ee=$?R[2]:1,oe=$?1:R[1],se=N[0],ie=$?N[1]:N[2],ne=$?N[2]:1,de=$?1:N[1],he=t.makeOutput(p.inShape,"float32"),ge=t.dataIdMap.get(he.dataId).id,be=t.dataIdMap.get(s.dataId).id,Ee=t.dataIdMap.get(a.dataId).id;return S9(be,Ee,f,m,g,A,x,y,v,w,b,I,T,C,M,F,B,j,X,Y,ee,oe,se,ie,ne,de,ge),he}var c5e={kernelName:nl,backendName:"wasm",setupFunc:l5e,kernelFunc:u5e},d5e=Hn(rl),pb;(function(e){e[e.bilinear=0]="bilinear",e[e.nearest=1]="nearest"})(pb||(pb={}));var T9;function h5e(e){T9=e.wasm.cwrap(_c,null,["number","number","number","number","array","number","number","number","number","number"])}function p5e(e){let{backend:t,inputs:n,attrs:r}=e,{method:s,extrapolationValue:a,cropSize:o}=r,{image:i,boxes:l,boxInd:u}=n,c=l.shape[0],[d,h]=o,p=[c,d,h,i.shape[3]],f=t.dataIdMap.get(i.dataId),m;i.dtype!=="float32"&&(m=t0({backend:t,inputs:{x:i},attrs:{dtype:"float32"}}),f=t.dataIdMap.get(m.dataId));let g=f.id,y=t.dataIdMap.get(l.dataId).id,A=t.dataIdMap.get(u.dataId).id,x=t.makeOutput(p,"float32"),b=t.dataIdMap.get(x.dataId).id,v=new Uint8Array(new Int32Array(i.shape).buffer);return T9(g,y,A,c,v,d,h,pb[s],a,b),m!=null&&t.disposeData(m.dataId),x}var f5e={kernelName:_c,backendName:"wasm",setupFunc:h5e,kernelFunc:p5e},N9;function m5e(e){N9=e.wasm.cwrap(sl,null,["number","number","number","number","number","number"])}function g5e(e){let{inputs:t,backend:n,attrs:r}=e,{x:s}=t,{axis:a,exclusive:o,reverse:i}=r,l=s.shape.length;k.assert(s.dtype==="float32"||s.dtype==="int32",()=>`cumsum does not support ${s.dtype} tensors in the WASM backend`);let u=_.getAxesPermutation([a],l),c=s;u!==null&&(c=e0({inputs:{x:s},attrs:{perm:u},backend:n}));let d=_.getInnerMostAxes(1,l)[0];_.assertAxesAreInnerMostDims("cumsum",[d],l);let h=n.makeOutput(c.shape,c.dtype),p=c.shape[d],f=n.dataIdMap.get(c.dataId).id,m=n.dataIdMap.get(h.dataId).id;N9(f,o?1:0,i?1:0,p,m,tr[s.dtype]);let g=h;if(u!==null){let y=_.getUndoAxesPermutation(u);g=e0({inputs:{x:h},attrs:{perm:y},backend:n}),n.disposeData(c.dataId),n.disposeData(h.dataId)}return g}var y5e={kernelName:sl,backendName:"wasm",setupFunc:m5e,kernelFunc:g5e},C9;function A5e(e){C9=e.wasm.cwrap(Rc,null,["number","number","number","array","number","array","array","number","number"])}function x5e(e){let{backend:t,inputs:n,attrs:r}=e,{x:s}=n,{blockSize:a,dataFormat:o}=r;k.assert(a>1,()=>`blockSize should be > 1 for depthToSpace, but was: ${a}`);let i=s.shape[0],l=o==="NHWC"?s.shape[1]:s.shape[2],u=o==="NHWC"?s.shape[2]:s.shape[3],c=o==="NHWC"?s.shape[3]:s.shape[1],d=l*a,h=u*a,p=c/(a*a),f=o==="NHWC"?[i,d,h,p]:[i,p,d,h],m=t.makeOutput(f,"float32"),y=t.dataIdMap.get(s.dataId).id,A=new Uint8Array(new Int32Array(k.computeStrides(s.shape)).buffer),x=new Uint8Array(new Int32Array(f).buffer),b=new Uint8Array(new Int32Array(k.computeStrides(f)).buffer),v=t.dataIdMap.get(m.dataId).id;return C9(y,a,o==="NHWC"?1:0,A,s.shape.length-1,x,b,f.length,v),m}var b5e={kernelName:Rc,backendName:"wasm",setupFunc:A5e,kernelFunc:x5e},E9;function v5e(e){E9=e.wasm.cwrap(al,null,["number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number"])}function w5e(e){let{inputs:t,attrs:n,backend:r}=e,{x:s,filter:a}=t,o=r.dataIdMap.get(s.dataId).id,i=r.dataIdMap.get(a.dataId).id,{strides:l,dilations:u,pad:c,dimRoundingMode:d}=n,h=u==null?[1,1]:u,p=_.computeConv2DInfo(s.shape,a.shape,l,h,c,d,!0),f=p.filterHeight,m=p.filterWidth,g=p.padInfo.top,y=p.padInfo.right,A=p.padInfo.bottom,x=p.padInfo.left,b=p.dilationHeight,v=p.dilationWidth,w=p.strideHeight,I=p.strideWidth,T=p.inChannels,C=p.outChannels,M=p.padInfo.type==="SAME"?1:0;if(p.dataFormat!=="channelsLast")throw new Error(`wasm backend DepthwiseConv2dNative does not support dataFormat:'${p.dataFormat}'. Please use 'channelsLast'.`);let $=r.makeOutput(p.outShape,"float32"),R=r.dataIdMap.get($.dataId).id;return E9(o,s.shape[0],s.shape[1],s.shape[2],i,f,m,g,y,A,x,M,b,v,w,I,T,C,R),$}var k5e={kernelName:al,backendName:"wasm",setupFunc:v5e,kernelFunc:w5e},I5e=!1,S5e=Gn(il,I5e,"bool"),T5e=Hn(Eo);function fb(e){let{inputs:t,attrs:n,backend:r}=e,{input:s}=t,{dim:a}=n,o=s.shape.length,i=s.shape.slice(),l=a;return a<0&&(k.assert(-(o+1)<=a,()=>`Axis must be in the interval [${-(o+1)}, ${o}]`),l=o+a+1),i.splice(l,0,1),As({inputs:{x:s},backend:r,attrs:{shape:i}})}var N5e={kernelName:Mc,backendName:"wasm",kernelFunc:fb};function C5e(e){let{attrs:{shape:t,value:n,dtype:r},backend:s}=e,a=s.makeOutput(t,r);return s.typedArrayFromHeap(a).fill(n),a}var E5e={kernelName:Qp,backendName:"wasm",kernelFunc:C5e},$9;function $5e(e){$9=e.wasm.cwrap(Oc,null,["number","number","number","number","number","number"])}function _5e(e){let{inputs:t,backend:n}=e,{image:r}=t,s=n.makeOutput(r.shape,r.dtype),a=n.dataIdMap.get(r.dataId).id,o=n.dataIdMap.get(s.dataId).id,[i,l,u,c]=r.shape;return $9(a,i,l,u,c,o),s}var R5e={kernelName:Oc,backendName:"wasm",kernelFunc:_5e,setupFunc:$5e},D5e=Hn($o),F5e=!1,M5e=Gn(ul,F5e),_9;function O5e(e){_9=e.wasm.cwrap(cl,null,["number","number","number","number","number","number","number"])}function P5e(e){let{backend:t,inputs:n,attrs:r}=e,{varianceEpsilon:s}=r,{x:a,mean:o,variance:i,offset:l,scale:u}=n,c=t.dataIdMap.get(a.dataId).id,d=t.dataIdMap.get(o.dataId).id,h=t.dataIdMap.get(i.dataId).id,p=l!=null?t.dataIdMap.get(l.dataId).id:0,f=u!=null?t.dataIdMap.get(u.dataId).id:0,m=t.makeOutput(a.shape,a.dtype);if(k.sizeFromShape(a.shape)===0)return m;let g=t.dataIdMap.get(m.dataId).id;return _9(c,d,h,p,f,s,g),m}var z5e={kernelName:cl,backendName:"wasm",setupFunc:O5e,kernelFunc:P5e},R9;function L5e(e){R9=e.wasm.cwrap(Bl,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 B5e(e){let{inputs:t,attrs:n,backend:r}=e,{x:s,filter:a,bias:o,preluActivationWeights:i}=t,{strides:l,pad:u,dilations:c,dataFormat:d,dimRoundingMode:h,activation:p,leakyreluAlpha:f}=n,m=_.computeConv2DInfo(s.shape,a.shape,l,c,u,h),g=gh[p];if(g==null)throw new Error(`${p} activation not yet supported for FusedConv2D in the wasm backend.`);let y=r.dataIdMap.get(s.dataId).id,A=r.dataIdMap.get(a.dataId).id,x=m.outChannels,b=0;if(o!=null){let ne=r.dataIdMap.get(o.dataId);if(ne.shape.length!==1)throw new Error(`FusedConv2D only supports rank-1 bias but got rank ${ne.shape.length}.`);if(ne.shape[0]!==x)throw new Error(`FusedConv2D bias shape (${ne.shape}) does not match the number of output channels (${x})`);b=ne.id}let v=m.filterHeight,w=m.filterWidth,I=m.padInfo.top,T=m.padInfo.right,C=m.padInfo.bottom,M=m.padInfo.left,$=m.dilationHeight,R=m.dilationWidth,N=m.strideHeight,F=m.strideWidth,B=m.inChannels,j=m.padInfo.type==="SAME"?1:0,X=m.batchSize,Y=m.inHeight,ee=m.inWidth;if(d!=="NHWC")throw new Error(`wasm backend FusedConv2D does not support dataFormat:'${d}'. Please use 'NHWC'.`);let oe=r.makeOutput(m.outShape,"float32"),se=r.dataIdMap.get(oe.dataId).id,ie=i==null?0:r.dataIdMap.get(i.dataId).id;return R9(y,X,Y,ee,A,v,w,b,I,T,C,M,j,$,R,N,F,B,x,g,ie,f||0,se),oe}var W5e={kernelName:Bl,backendName:"wasm",setupFunc:L5e,kernelFunc:B5e},D9;function V5e(e){D9=e.wasm.cwrap(Wl,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 U5e(e){let{inputs:t,attrs:n,backend:r}=e,{x:s,filter:a,bias:o,preluActivationWeights:i}=t,{strides:l,pad:u,dilations:c,dataFormat:d,dimRoundingMode:h,activation:p,leakyreluAlpha:f}=n,m=_.computeConv2DInfo(s.shape,a.shape,l,c,u,h,!0),g=gh[p];if(g==null)throw new Error(`${p} activation not yet supported for FusedDepthwiseConv2D in the wasm backend.`);let y=r.dataIdMap.get(s.dataId).id,A=r.dataIdMap.get(a.dataId).id,x=m.outChannels,b=0;if(o!=null){let ne=r.dataIdMap.get(o.dataId);if(ne.shape.length!==1)throw new Error(`FusedDepthwiseConv2D only supports rank-1 bias but got rank ${ne.shape.length}.`);if(ne.shape[0]!==x)throw new Error(`FusedDepthwiseConv2D bias shape (${ne.shape}) does not match the number of output channels (${x})`);b=ne.id}let v=m.filterHeight,w=m.filterWidth,I=m.padInfo.top,T=m.padInfo.right,C=m.padInfo.bottom,M=m.padInfo.left,$=m.dilationHeight,R=m.dilationWidth,N=m.strideHeight,F=m.strideWidth,B=m.inChannels,j=m.padInfo.type==="SAME"?1:0,X=m.batchSize,Y=m.inHeight,ee=m.inWidth;if(d!=="NHWC")throw new Error(`wasm backend FusedDepthwiseConv2D does not support dataFormat:'${d}'. Please use 'NHWC'.`);let oe=r.makeOutput(m.outShape,"float32"),se=r.dataIdMap.get(oe.dataId).id,ie=i==null?0:r.dataIdMap.get(i.dataId).id;return D9(y,X,Y,ee,A,v,w,b,I,T,C,M,j,$,R,N,F,B,x,g,ie,f||0,se),oe}var H5e={kernelName:Wl,backendName:"wasm",setupFunc:V5e,kernelFunc:U5e},F9;function G5e(e){F9=e.wasm.cwrap(zc,null,["number","number","number","number","number","number","array","number"])}function j5e(e){let{backend:t,inputs:n}=e,{params:r,indices:s}=n,[a,o,i,l]=S6.prepareAndValidate(r,s),u=t.makeOutput(a,r.dtype);if(o===0)return u;let c=s.shape,d=c[c.length-1],p=t.dataIdMap.get(r.dataId).id,m=t.dataIdMap.get(s.dataId).id,g=new Uint8Array(new Int32Array(l).buffer),y=t.dataIdMap.get(u.dataId).id;return F9(p,tr[r.dtype],m,o,d,i,g,y),u}var q5e={kernelName:zc,backendName:"wasm",setupFunc:G5e,kernelFunc:j5e},M9;function K5e(e){M9=e.wasm.cwrap("Gather",null,["number","number","array","number","number","number","array","number"])}function X5e(e){let{backend:t,inputs:n,attrs:r}=e,{x:s,indices:a}=n,{axis:o,batchDims:i}=r,l=k.parseAxisParam(o,s.shape)[0],u=_.segment_util.collectGatherOpShapeInfo(s,a,l,i),c=As({inputs:{x:s},attrs:{shape:[u.batchSize,u.outerSize,u.dimSize,u.sliceSize]},backend:t}),d=k.sizeFromShape(a.shape),h=As({inputs:{x:a},attrs:{shape:[u.batchSize,d/u.batchSize]},backend:t}),p=[u.batchSize,u.outerSize,d/u.batchSize,u.sliceSize],f=t.makeOutput(p,s.dtype);if(k.sizeFromShape(s.shape)===0)return f;let m=c.shape.length-1,y=t.dataIdMap.get(c.dataId).id,x=t.dataIdMap.get(h.dataId).id,b=t.dataIdMap.get(f.dataId).id,v=new Uint8Array(new Int32Array(k.computeStrides(c.shape)).buffer),w=new Uint8Array(new Int32Array(k.computeStrides(p)).buffer);return M9(y,tr[s.dtype],v,m,x,u.batchSize,w,b),t.disposeData(c.dataId),t.disposeData(h.dataId),f.shape=u.outputShape,f}var Z5e={kernelName:Pc,backendName:"wasm",setupFunc:K5e,kernelFunc:X5e},Y5e=!1,J5e=Gn(dl,Y5e,"bool"),Q5e=!1,ebe=Gn(_o,Q5e,"bool"),O9;function tbe(e){O9=e.wasm.cwrap(pl,null,["number","number","number"])}function nbe(e){let{inputs:{x:t},attrs:{alpha:n},backend:r}=e,s=r.dataIdMap.get(t.dataId).id,a=r.makeOutput(t.shape,t.dtype);if(k.sizeFromShape(t.shape)!==0){let o=r.dataIdMap.get(a.dataId).id;O9(s,n,o)}return a}var rbe={kernelName:pl,backendName:"wasm",setupFunc:tbe,kernelFunc:nbe},sbe=!1,abe=Gn(fl,sbe,"bool"),obe=!1,ibe=Gn(ml,obe,"bool"),lbe=Hn(Ro),ube=!1,cbe=Gn(Uc,ube,"bool"),P9;function dbe(e){P9=e.wasm.cwrap(gl,null,["number, number, number"])}function hbe(e){let{backend:t,inputs:n,attrs:r}=e,{reductionIndices:s,keepDims:a}=r,{x:o}=n,l=t.dataIdMap.get(o.dataId).id,u=o,{transposed:c,axes:d,originalAxes:h,inputWasTransposed:p}=to(o,s,t);if(p){let x=t.dataIdMap.get(c.dataId).id;u=c,l=x}let f=u.shape.length;_.assertAxesAreInnerMostDims("max",d,f);let[m,g]=_.computeOutAndReduceShapes(u.shape,d),y=k.sizeFromShape(g),A=t.makeOutput(m,o.dtype);if(k.sizeFromShape(u.shape)!==0){let x=t.dataIdMap.get(A.dataId).id;P9(l,y,x)}if(p&&t.disposeData(c.dataId),a){let x=_.expandShapeToKeepDim(A.shape,h);A.shape=x}return A}var pbe={kernelName:gl,backendName:"wasm",setupFunc:dbe,kernelFunc:hbe},fbe=!1,mbe=Gn(Do,fbe),z9;function gbe(e){z9=e.wasm.cwrap(yl,null,["number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number"])}function ybe(e){let{inputs:t,attrs:n,backend:r}=e,s=t.x,a=r.dataIdMap.get(s.dataId).id,{filterSize:o,strides:i,pad:l,dimRoundingMode:u}=n,c=_.computePool2DInfo(s.shape,o,i,1,l,u),d=c.filterHeight,h=c.filterWidth,p=c.padInfo.top,f=c.padInfo.right,m=c.padInfo.bottom,g=c.padInfo.left,y=c.dilationHeight,A=c.dilationWidth,x=c.strideHeight,b=c.strideWidth,v=c.inChannels,w=c.outChannels;if(c.dataFormat!=="channelsLast")throw new Error(`wasm backend does not support dataFormat:'${c.dataFormat}'. Please use 'channelsLast'.`);let I=r.makeOutput(c.outShape,"float32"),T=r.dataIdMap.get(I.dataId).id;return z9(a,s.shape[0],s.shape[1],s.shape[2],d,h,p,f,m,g,y,A,x,b,v,w,T),I}var Abe={kernelName:yl,backendName:"wasm",setupFunc:gbe,kernelFunc:ybe},L9;function xbe(e){L9=e.wasm.cwrap(Al,null,["number, number, number"])}function bbe(e){let{backend:t,inputs:n,attrs:r}=e,{axis:s,keepDims:a}=r,{x:o}=n,i=t.dataIdMap.get(o.dataId).id,l=i,u=o,{transposed:c,axes:d,originalAxes:h,inputWasTransposed:p}=to(o,s,t),f=d;if(p){let b=t.dataIdMap.get(c.dataId).id;b!==i&&(u=c,l=b,f=_.getInnerMostAxes(f.length,u.shape.length))}_.assertAxesAreInnerMostDims("mean",f,u.shape.length);let[m,g]=_.computeOutAndReduceShapes(u.shape,f),y=k.sizeFromShape(g),A=u;u.dtype!=="float32"&&(A=t0({backend:t,inputs:{x:u},attrs:{dtype:"float32"}}),l=t.dataIdMap.get(A.dataId).id);let x=t.makeOutput(m,"float32");if(k.sizeFromShape(u.shape)!==0){let b=t.dataIdMap.get(x.dataId).id;L9(l,y,b)}if(p&&t.disposeData(c.dataId),a){let b=_.expandShapeToKeepDim(x.shape,h);x.shape=b}return u.dtype!=="float32"&&t.disposeData(A.dataId),x}var vbe={kernelName:Al,backendName:"wasm",setupFunc:xbe,kernelFunc:bbe},B9;function wbe(e){B9=e.wasm.cwrap(xl,null,["number, number, number"])}function kbe(e){let{backend:t,inputs:n,attrs:r}=e,{axis:s,keepDims:a}=r,{x:o}=n,i=t.dataIdMap.get(o.dataId).id,l=i,u=o,{transposed:c,axes:d,originalAxes:h,inputWasTransposed:p}=to(o,s,t);if(p){let x=t.dataIdMap.get(c.dataId).id;x!==i&&(u=c,l=x)}let f=u.shape.length;_.assertAxesAreInnerMostDims("min",d,f);let[m,g]=_.computeOutAndReduceShapes(u.shape,d),y=k.sizeFromShape(g),A=t.makeOutput(m,u.dtype);if(k.sizeFromShape(u.shape)!==0){let x=t.dataIdMap.get(A.dataId).id;B9(l,y,x)}if(p&&t.disposeData(c.dataId),a){let x=_.expandShapeToKeepDim(A.shape,h);A.shape=x}return A}var Ibe={kernelName:xl,backendName:"wasm",setupFunc:wbe,kernelFunc:kbe},Sbe=!1,Tbe=Gn(Fo,Sbe),mb;(function(e){e[e.reflect=0]="reflect",e[e.symmetric=1]="symmetric"})(mb||(mb={}));var W9;function Nbe(e){W9=e.wasm.cwrap(bl,null,["number","array","number","number","array","array","number","number"])}function Cbe(e){let{inputs:{x:t},backend:n,attrs:{paddings:r,mode:s}}=e,a=r.map((f,m)=>f[0]+t.shape[m]+f[1]),o=n.dataIdMap.get(t.dataId).id,i=n.makeOutput(a,t.dtype),l=n.dataIdMap.get(i.dataId).id,u=new Uint8Array(new Int32Array(t.shape).buffer),c=r.map(f=>f[0]),d=r.map(f=>f[1]),h=new Uint8Array(new Int32Array(c).buffer),p=new Uint8Array(new Int32Array(d).buffer);return W9(o,u,t.shape.length,tr[t.dtype],h,p,mb[s],l),i}var Ebe={kernelName:bl,backendName:"wasm",kernelFunc:Cbe,setupFunc:Nbe},$be=!0,_be=Gn(Mo,$be),Rbe=Hn(Gc);function gb(e,t){let n=new Int32Array(e.wasm.HEAPU8.buffer,t,4),r=n[0],s=n[1],a=n[2],o=n[3];return e.wasm._free(t),{pSelectedIndices:r,selectedSize:s,pSelectedScores:a,pValidOutputs:o}}var V9;function Dbe(e){V9=e.wasm.cwrap(jc,"number",["number","number","number","number","number"])}function Fbe(e){let{backend:t,inputs:n,attrs:r}=e,{iouThreshold:s,maxOutputSize:a,scoreThreshold:o}=r,{boxes:i,scores:l}=n,u=t.dataIdMap.get(i.dataId).id,c=t.dataIdMap.get(l.dataId).id,d=V9(u,c,a,s,o),{pSelectedIndices:h,selectedSize:p,pSelectedScores:f,pValidOutputs:m}=gb(t,d);return t.wasm._free(f),t.wasm._free(m),t.makeOutput([p],"int32",h)}var Mbe={kernelName:jc,backendName:"wasm",setupFunc:Dbe,kernelFunc:Fbe},U9;function Obe(e){U9=e.wasm.cwrap(qc,"number",["number","number","number","number","number","bool"])}function Pbe(e){let{backend:t,inputs:n,attrs:r}=e,{iouThreshold:s,maxOutputSize:a,scoreThreshold:o,padToMaxOutputSize:i}=r,{boxes:l,scores:u}=n,c=t.dataIdMap.get(l.dataId).id,d=t.dataIdMap.get(u.dataId).id,h=U9(c,d,a,s,o,i),{pSelectedIndices:p,selectedSize:f,pSelectedScores:m,pValidOutputs:g}=gb(t,h);t.wasm._free(m);let y=t.makeOutput([f],"int32",p),A=t.makeOutput([],"int32",g);return[y,A]}var zbe={kernelName:qc,backendName:"wasm",setupFunc:Obe,kernelFunc:Pbe},H9;function Lbe(e){H9=e.wasm.cwrap(Kc,"number",["number","number","number","number","number","number"])}function Bbe(e){let{backend:t,inputs:n,attrs:r}=e,{iouThreshold:s,maxOutputSize:a,scoreThreshold:o,softNmsSigma:i}=r,{boxes:l,scores:u}=n,c=t.dataIdMap.get(l.dataId).id,d=t.dataIdMap.get(u.dataId).id,h=H9(c,d,a,s,o,i),{pSelectedIndices:p,selectedSize:f,pSelectedScores:m,pValidOutputs:g}=gb(t,h);t.wasm._free(g);let y=t.makeOutput([f],"int32",p),A=t.makeOutput([f],"float32",m);return[y,A]}var Wbe={kernelName:Kc,backendName:"wasm",setupFunc:Lbe,kernelFunc:Bbe},Vbe=!1,Ube=Gn(vl,Vbe,"bool"),G9;function Hbe(e){G9=e.wasm.cwrap(wl,null,["number","number","number","number","number"])}function Gbe(e){let{inputs:t,backend:n,attrs:r}=e,{indices:s}=t,{depth:a,onValue:o,offValue:i}=r,l=n.makeOutput([...s.shape,a],"int32"),u=n.dataIdMap.get(l.dataId).id,d=n.dataIdMap.get(s.dataId).id;return G9(d,a,o,i,u),l}var jbe={kernelName:wl,backendName:"wasm",setupFunc:Hbe,kernelFunc:Gbe};function qbe(e){let{inputs:{x:t},backend:n}=e,r=n.makeOutput(t.shape,t.dtype);return n.typedArrayFromHeap(r).fill(1),r}var Kbe={kernelName:Xc,backendName:"wasm",kernelFunc:qbe};function Xbe(e){let{inputs:t,backend:n,attrs:r}=e,{axis:s}=r;if(t.length===1)return fb({inputs:{input:t[0]},backend:n,attrs:{dim:s}});let a=t[0].shape,o=t[0].dtype;t.forEach(c=>{k.assertShapesMatch(a,c.shape,"All tensors passed to stack must have matching shapes"),k.assert(o===c.dtype,()=>"All tensors passed to stack must have matching dtypes")});let i=[],l=t.map(c=>{let d=fb({inputs:{input:c},backend:n,attrs:{dim:s}});return i.push(d),d}),u=k9({inputs:l,backend:n,attrs:{axis:s}});return i.forEach(c=>n.disposeData(c.dataId)),u}var Zbe={kernelName:Zc,backendName:"wasm",kernelFunc:Xbe},j9;function Ybe(e){j9=e.wasm.cwrap(kl,null,["number","array","number","number","array","array","number","number"])}function Jbe(e){let{inputs:{x:t},backend:n,attrs:{paddings:r,constantValue:s}}=e,a=r.map((f,m)=>f[0]+t.shape[m]+f[1]),o=n.dataIdMap.get(t.dataId).id,i=n.makeOutput(a,t.dtype),l=n.dataIdMap.get(i.dataId).id,u=new Uint8Array(new Int32Array(t.shape).buffer),c=r.map(f=>f[0]),d=r.map(f=>f[1]),h=new Uint8Array(new Int32Array(c).buffer),p=new Uint8Array(new Int32Array(d).buffer);return j9(o,u,t.shape.length,tr[t.dtype],h,p,s,l),i}var Qbe={kernelName:kl,backendName:"wasm",kernelFunc:Jbe,setupFunc:Ybe},e3e=!1,t3e=Gn(Il,e3e),q9;function n3e(e){q9=e.wasm.cwrap(Sl,null,["number","number","number"])}function r3e(e){let{inputs:t,backend:n}=e,{x:r,alpha:s}=t,a=n.dataIdMap.get(r.dataId).id,o=n.dataIdMap.get(s.dataId).id,i=n.makeOutput(r.shape,"float32"),l=n.dataIdMap.get(i.dataId).id;return q9(a,o,l),i}var s3e={kernelName:Sl,backendName:"wasm",setupFunc:n3e,kernelFunc:r3e},K9;function a3e(e){K9=e.wasm.cwrap(Yc,null,["number","number","number","number"])}function o3e(e){let{backend:t,inputs:n,attrs:r}=e,{axis:s,keepDims:a}=r,{x:o}=n,i=t.dataIdMap.get(o.dataId).id,l=i,u=o,{transposed:c,axes:d,originalAxes:h,inputWasTransposed:p}=to(o,s,t),f=d;if(p){let x=t.dataIdMap.get(c.dataId).id;x!==i&&(u=c,l=x,f=_.getInnerMostAxes(f.length,u.shape.length))}_.assertAxesAreInnerMostDims("prod",f,u.shape.length);let[m,g]=_.computeOutAndReduceShapes(u.shape,f),y=k.sizeFromShape(g),A=t.makeOutput(m,u.dtype);if(k.sizeFromShape(u.shape)!==0){let x=t.dataIdMap.get(A.dataId).id;K9(l,y,tr[A.dtype],x)}if(p&&t.disposeData(c.dataId),a){let x=_.expandShapeToKeepDim(A.shape,h);A.shape=x}return A}var i3e={kernelName:Yc,backendName:"wasm",setupFunc:a3e,kernelFunc:o3e},l3e=e=>{let{backend:t,attrs:n}=e,{start:r,stop:s,step:a,dtype:o}=n,i=oE(r,s,a,o),l=t.makeOutput([i.length],o);return t.typedArrayFromHeap(l).set(i),l},u3e={kernelName:sf,backendName:"wasm",kernelFunc:l3e},c3e=!0,d3e=Gn(ol,c3e),h3e=Hn(Tl),p3e=Hn(Cl),X9;function f3e(e){X9=e.wasm.cwrap(Nl,null,["number","number","number","number","number","number","number","number","number","number"])}function m3e(e){let{backend:t,inputs:n,attrs:r}=e,{images:s}=n,{alignCorners:a,halfPixelCenters:o,size:i}=r,[l,u]=i,[c,d,h,p]=s.shape,f=[c,l,u,p],m=t.dataIdMap.get(s.dataId),g;m.dtype!=="float32"&&(g=t0({backend:t,inputs:{x:s},attrs:{dtype:"float32"}}),m=t.dataIdMap.get(g.dataId));let y=m.id,A=t.makeOutput(f,"float32");if(k.sizeFromShape(s.shape)===0)return A;let x=t.dataIdMap.get(A.dataId).id;return X9(y,c,d,h,p,l,u,a?1:0,o?1:0,x),g!=null&&t.disposeData(g.dataId),A}var g3e={kernelName:Nl,backendName:"wasm",setupFunc:f3e,kernelFunc:m3e},Z9;function y3e(e){Z9=e.wasm.cwrap(El,null,["number","array","number","array","number","number"])}function A3e(e){let{inputs:t,backend:n,attrs:r}=e,{x:s}=t,{dims:a}=r,o=k.parseAxisParam(a,s.shape);if(s.shape.length===0)return Qm({inputs:{x:s},backend:n});let i=n.makeOutput(s.shape,s.dtype),l=n.dataIdMap.get(s.dataId).id,u=n.dataIdMap.get(i.dataId).id,c=new Uint8Array(new Int32Array(o).buffer),d=new Uint8Array(new Int32Array(s.shape).buffer);Z9(l,c,o.length,d,s.shape.length,u);let h=As({inputs:{x:i},attrs:{shape:s.shape},backend:n});return n.disposeData(i.dataId),h}var x3e={kernelName:El,backendName:"wasm",kernelFunc:A3e,setupFunc:y3e},Y9;function b3e(e){Y9=e.wasm.cwrap(pd,null,["number","number","number","number","number","number","number","number","array","number","number"])}function v3e(e){let{inputs:t,backend:n,attrs:r}=e,{image:s}=t,{radians:a,fillValue:o,center:i}=r,l=n.makeOutput(s.shape,s.dtype),u=n.dataIdMap.get(s.dataId).id,c=n.dataIdMap.get(l.dataId).id,[d,h,p,f]=s.shape,[m,g]=_.getImageCenter(i,h,p),y=o===0,A=255,x=typeof o=="number"?[o,o,o,y?0:A]:[...o,A],b=new Uint8Array(new Int32Array(x).buffer);return Y9(u,d,h,p,f,a,m,g,b,x.length,c),l}var w3e={kernelName:pd,backendName:"wasm",kernelFunc:v3e,setupFunc:b3e},k3e=Hn($l),I3e=Hn(Oo),J9;function S3e(e){J9=e.wasm.cwrap(ed,null,["number","number","number","number","number","number","array","number","number"])}function T3e(e){let{backend:t,inputs:n,attrs:r}=e,{indices:s,updates:a}=n,{shape:o}=r,i=t.makeOutput(o,a.dtype);if(k.sizeFromShape(o)===0)return i;let{sliceRank:l,numUpdates:u,sliceSize:c,strides:d,outputSize:h}=N6.calculateShapes(a,s,o),f=t.dataIdMap.get(s.dataId).id,g=t.dataIdMap.get(a.dataId).id,y=new Uint8Array(new Int32Array(d).buffer),A=t.dataIdMap.get(i.dataId).id;return J9(f,g,tr[a.dtype],l,u,c,y,h,A),i}var N3e={kernelName:ed,backendName:"wasm",setupFunc:S3e,kernelFunc:T3e},Q9;function C3e(e){Q9=e.wasm.cwrap("SelectV2",null,["number","number","number","number","number"])}function E3e(e){let{inputs:t,backend:n}=e,{condition:r,t:s,e:a}=t,o=n.dataIdMap.get(r.dataId).id,i=n.dataIdMap.get(s.dataId).id,l=n.dataIdMap.get(a.dataId).id,u=n.makeOutput(s.shape,s.dtype),c=n.dataIdMap.get(u.dataId).id,d=r.shape.length,h=s.shape.length,p=d===0||d>1||h===1?1:k.sizeFromShape(s.shape.slice(1));return Q9(o,i,l,p,c),u}var $3e={kernelName:td,backendName:"wasm",kernelFunc:E3e,setupFunc:C3e},e$;function _3e(e){e$=e.wasm.cwrap(Rl,null,["number","number"])}function R3e(e){let{backend:t,inputs:{x:n}}=e,r=t.dataIdMap.get(n.dataId).id,s=t.makeOutput(n.shape,n.dtype),a=t.dataIdMap.get(s.dataId).id;return k.sizeFromShape(s.shape)===0||e$(r,a),s}var D3e={kernelName:"Sigmoid",backendName:"wasm",setupFunc:_3e,kernelFunc:R3e},F3e=Hn(_l);function n0(e){let{inputs:{x:t},attrs:{begin:n,size:r},backend:s}=e,[a,o]=En.parseSliceParams(t,n,r),i=En.isSliceContinous(t.shape,a,o),l=s.readSync(t.dataId),u=s.makeOutput(o,t.dtype),c=k.computeStrides(t.shape),d=s.dataIdMap.get(u.dataId);if(i){let f=En.computeFlatOffset(a,c);return t.dtype==="string"?d.stringBytes=l.slice(f,f+k.sizeFromShape(o)):s.typedArrayFromHeap(u).set(l.subarray(f,f+k.sizeFromShape(o))),u}if(t.dtype==="string"){let f=ab(l,a,o,t.shape,t.dtype);return d.stringBytes=f,u}let h=s.typedArrayFromHeap(u),p=t.shape.length;if(p===2)M3e(l,c[0],h,a,o);else if(p===3)O3e(l,c[0],c[1],h,a,o);else if(p===4)P3e(l,c[0],c[1],c[2],h,a,o);else{let f=ab(l,a,o,t.shape,t.dtype);h.set(f)}return u}function M3e(e,t,n,r,s){let a=0,o=r[0],i=r[1],l=o+s[0];for(let u=o;u<l;u++){let c=u*t+i;n.set(e.subarray(c,c+s[1]),a),a+=s[1]}}function O3e(e,t,n,r,s,a){let o=0,i=s[0],l=s[1],u=s[2],c=i+a[0],d=l+a[1];for(let h=i;h<c;h++)for(let p=l;p<d;p++){let f=h*t+p*n+u;r.set(e.subarray(f,f+a[2]),o),o+=a[2]}}function P3e(e,t,n,r,s,a,o){let i=0,l=a[0],u=a[1],c=a[2],d=l+o[0],h=u+o[1],p=c+o[2],f=a[3];for(let m=l;m<d;m++)for(let g=u;g<h;g++)for(let y=c;y<p;y++){let A=m*t+g*n+y*r+f;s.set(e.subarray(A,A+o[3]),i),i+=o[3]}}var z3e={kernelName:rd,backendName:"wasm",kernelFunc:n0},t$;function L3e(e){t$=e.wasm.cwrap(Ml,null,["number","number","number","number"])}function B3e(e){let{backend:t,inputs:{logits:n},attrs:{dim:r}}=e,s=t.dataIdMap.get(n.dataId).id,a=t.makeOutput(n.shape,n.dtype),o=t.dataIdMap.get(a.dataId).id,i=n.shape[r],l=k.sizeFromShape(n.shape)/i;return k.sizeFromShape(a.shape)===0||t$(s,o,i,l),a}var W3e={kernelName:Ml,backendName:"wasm",setupFunc:L3e,kernelFunc:B3e};function V3e(e){let{inputs:t,attrs:n,backend:r}=e,{x:s}=t,{numOrSizeSplits:a,axis:o}=n,i=k.parseAxisParam(o,s.shape)[0],l=_.prepareSplitSize(s,a,i),u=new Array(s.shape.length).fill(0),c=s.shape.slice();return l.map(d=>{let h=[...c];h[i]=d;let p=n0({inputs:{x:s},attrs:{begin:u,size:h},backend:r});return u[i]+=d,p})}var U3e={kernelName:id,backendName:"wasm",kernelFunc:V3e},H3e=Hn(Dl),G3e=Hn(lf),j3e=!0,q3e=Gn(Po,j3e),n$;function K3e(e){n$=e.wasm.cwrap(Bo,null,["number","number","number"])}function X3e(e){let{backend:t,inputs:n,attrs:r}=e,{alpha:s}=r,{x:a}=n,o=t.dataIdMap.get(a.dataId).id,i=t.makeOutput(a.shape,a.dtype),l=t.dataIdMap.get(i.dataId).id;return n$(o,s,l),i}var Z3e={kernelName:Bo,backendName:"wasm",setupFunc:K3e,kernelFunc:X3e},r$;function Y3e(e){r$=e.wasm.cwrap(ld,null,["number","array","number","array","array","array","array","array","number","number"])}function J3e(e){let{backend:t,inputs:n,attrs:r}=e,{x:s}=n,{begin:a,end:o,strides:i}=r;i==null&&(i=new Array(a.length));let{beginMask:l,endMask:u,ellipsisMask:c,newAxisMask:d,shrinkAxisMask:h}=r,p=_.slice_util.maskToAxes(c);if(p.length>1)throw new Error("Multiple ellipses in slice is not allowed.");if(c!==0&&d!==0)throw new Error("Using both ellipsisMask and newAxisMask is not yet supported.");if(c!==0&&h!==0)throw new Error("Using both ellipsisMask and shrinkAxisMask is not yet supported.");let f=s.shape.length-a.length,m=_.slice_util.maskToAxes(d),g=s.shape.slice();m.forEach($=>{a[$]=0,o[$]=1,g.splice($,0,1)});let y=As({inputs:{x:s},attrs:{shape:g},backend:t}),{begin:A,end:x,strides:b}=_.slice_util.getNormalizedAxes(y.shape,p,f,a,o,i,l,u,c);a=A,o=x,i=b;let v=_.slice_util.maskToAxes(h);v.forEach($=>{o[$]=a[$]+1,i[$]=1});let w=_.slice_util.computeOutShape(a,o,i),I=w.filter(($,R)=>v.indexOf(R)===-1);if(i.every($=>$===1)){let $=n0({inputs:{x:y},attrs:{begin:a,size:w},backend:t});t.disposeData(y.dataId);let R=As({inputs:{x:$},attrs:{shape:I},backend:t});return t.disposeData($.dataId),R}let C=t.makeOutput(I,"float32");if(!I.some($=>$===0)){let $=t.dataIdMap.get(y.dataId).id,R=new Uint8Array(new Int32Array(k.computeStrides(y.shape)).buffer),N=new Uint8Array(new Int32Array(a).buffer),F=new Uint8Array(new Int32Array(o).buffer),B=new Uint8Array(new Int32Array(i).buffer),j=new Uint8Array(new Int32Array(I).buffer),X=new Uint8Array(new Int32Array(k.computeStrides(I)).buffer),Y=t.dataIdMap.get(C.dataId).id;r$($,R,y.shape.length,N,F,B,j,X,I.length,Y)}t.disposeData(y.dataId);let M=As({inputs:{x:C},attrs:{shape:I},backend:t});return t.disposeData(C.dataId),M}var Q3e={kernelName:ld,backendName:"wasm",setupFunc:Y3e,kernelFunc:J3e},eve=!0,tve=Gn(zo,eve),s$;function nve(e){s$=e.wasm.cwrap(Fl,null,["number, number, number"])}function rve(e){let{backend:t,inputs:n,attrs:r}=e,{axis:s,keepDims:a}=r,{x:o}=n,i=t.dataIdMap.get(o.dataId).id,l=i,u=o,{transposed:c,axes:d,originalAxes:h,inputWasTransposed:p}=to(o,s,t),f=d;if(p){let x=t.dataIdMap.get(c.dataId).id;x!==i&&(u=c,l=x,f=_.getInnerMostAxes(f.length,u.shape.length))}_.assertAxesAreInnerMostDims("sum",f,u.shape.length);let[m,g]=_.computeOutAndReduceShapes(u.shape,f),y=k.sizeFromShape(g),A=t.makeOutput(m,u.dtype);if(k.sizeFromShape(u.shape)!==0){let x=t.dataIdMap.get(A.dataId).id;s$(l,y,x)}if(p&&t.disposeData(c.dataId),a){let x=_.expandShapeToKeepDim(A.shape,h);A.shape=x}return A}var sve={kernelName:Fl,backendName:"wasm",setupFunc:nve,kernelFunc:rve},ave=Hn(Ol),ove=Hn(Pl),a$;function ive(e){a$=e.wasm.cwrap(Lo,null,["number","array","number","array","number","number"])}function lve(e){let{inputs:t,backend:n,attrs:r}=e,{x:s}=t,a=n.dataIdMap.get(s.dataId).id,{reps:o}=r,i=new Array(s.shape.length);for(let h=0;h<i.length;h++)i[h]=s.shape[h]*o[h];let l=new Uint8Array(new Int32Array(s.shape).buffer),u=new Uint8Array(new Int32Array(i).buffer),c=n.makeOutput(i,s.dtype),d=n.dataIdMap.get(c.dataId).id;return a$(a,l,s.shape.length,u,i.length,tr[c.dtype],d),c}var uve={kernelName:Lo,backendName:"wasm",setupFunc:ive,kernelFunc:lve},o$;function cve(e){o$=e.wasm.cwrap(ud,null,["number","array","number","number","number","bool","number","number"])}var dve=({inputs:e,backend:t,attrs:n})=>{let{x:r}=e,{k:s,sorted:a}=n,o=t.dataIdMap.get(r.dataId).id,i=new Uint8Array(new Int32Array(r.shape).buffer),l=r.shape.slice();l[l.length-1]=s;let u=t.makeOutput(l,r.dtype),c=t.dataIdMap.get(u.dataId).id,d=t.makeOutput(l,"int32"),h=t.dataIdMap.get(d.dataId).id;return o$(o,i,r.shape.length,tr[r.dtype],s,a,c,h),[u,d]},hve={kernelName:ud,backendName:"wasm",setupFunc:cve,kernelFunc:dve},i$;function pve(e){i$=e.wasm.cwrap(cd,null,["number","number","bool","number","number","number","number","number","number","array","number","number","number","number","number"])}function fve(e){let{backend:t,inputs:n,attrs:r}=e,{image:s,transforms:a}=n,{interpolation:o,fillMode:i,fillValue:l,outputShape:u}=r,[c,d,h,p]=s.shape,[f,m]=u!=null?u:[d,h],g=[c,f,m,p],y=new Uint8Array(new Int32Array(k.computeStrides(s.shape)).buffer),A=t.makeOutput(g,s.dtype),x=t.dataIdMap.get(A.dataId).id,v=t.dataIdMap.get(s.dataId).id,I=t.dataIdMap.get(a.dataId).id,T=o==="nearest"?1:2,C;switch(i){case"constant":C=1;break;case"reflect":C=2;break;case"wrap":C=3;break;case"nearest":C=4;break;default:C=1;break}return i$(v,I,a.shape[0]>1,c,f,m,p,h,d,y,s.shape.length-1,T,C,l,x),A}var mve={kernelName:cd,backendName:"wasm",setupFunc:pve,kernelFunc:fve};function gve(e){let{inputs:t,backend:n,attrs:r}=e,{value:s}=t,{axis:a}=r;a<0&&(a+=s.shape.length);let o=s.shape[a],i=s.shape.length,l=new Array(i-1),u=0;for(let p=0;p<i;p++)p!==a&&(l[u++]=s.shape[p]);let c=new Array(o),d=new Array(i).fill(0),h=s.shape.slice();h[a]=1;for(let p=0;p<c.length;p++)d[a]=p,c[p]=n0({inputs:{x:s},attrs:{begin:d,size:h},backend:n});return c.map(({dataId:p,dtype:f})=>({dataId:p,dtype:f,shape:l}))}var yve={kernelName:dd,backendName:"wasm",kernelFunc:gve};function Ave(e){let{inputs:{x:t},backend:n}=e,r=n.makeOutput(t.shape,t.dtype);return n.typedArrayFromHeap(r).fill(0),r}var xve={kernelName:hd,backendName:"wasm",kernelFunc:Ave},bve=[Txe,Cxe,_xe,Lxe,Vxe,Gxe,Kxe,Jxe,Qxe,e5e,r5e,s5e,i5e,c5e,d5e,f5e,y5e,b5e,k5e,S5e,T5e,N5e,E5e,R5e,D5e,M5e,Sxe,z5e,W5e,H5e,q5e,Z5e,J5e,ebe,Rxe,rbe,abe,ibe,lbe,cbe,pbe,mbe,Abe,vbe,Ibe,Tbe,Ebe,_be,Rbe,Mbe,zbe,Wbe,Ube,jbe,Kbe,Zbe,Qbe,t3e,s3e,i3e,u3e,d3e,h3e,p3e,Xxe,g3e,x3e,w3e,I3e,k3e,N3e,$3e,D3e,F3e,z3e,W3e,U3e,H3e,G3e,q3e,Z3e,Q3e,tve,sve,ave,ove,uve,hve,mve,Oxe,yve,xve];for(let e of bve)oA(e);var yb=ae();yb.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])));yb.registerFlag("WASM_HAS_MULTITHREAD_SUPPORT",async()=>{if(yb.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 l$=Ks(IR()),vve='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()}}}}',wve=Ks(SR()),u$=class extends Bp{constructor(e){super();this.wasm=e,this.dataIdNextNumber=1,this.wasm.tfjs.init(),this.dataIdMap=new fy(this,za())}write(e,t,n){let r={id:this.dataIdNextNumber++};return this.move(r,e,t,n,1),r}numDataIds(){return this.dataIdMap.numDataIds()}async time(e){let t=k.now();return e(),{kernelMs:k.now()-t}}move(e,t,n,r,s){let a=this.dataIdNextNumber++;if(r==="string"){let u=t;this.dataIdMap.set(e,{id:a,stringBytes:u,shape:n,dtype:r,memoryOffset:null,refCount:s});return}let o=k.sizeFromShape(n),i=o*k.bytesPerElement(r),l=this.wasm._malloc(i);this.dataIdMap.set(e,{id:a,memoryOffset:l,shape:n,dtype:r,refCount:s}),this.wasm.tfjs.registerTensor(a,o,l),t!=null&&this.wasm.HEAPU8.set(new Uint8Array(t.buffer,t.byteOffset,i),l)}async read(e){return this.readSync(e)}readSync(e){let{memoryOffset:t,dtype:n,shape:r,stringBytes:s}=this.dataIdMap.get(e);if(n==="string")return s;let a=this.wasm.HEAPU8.slice(t,t+k.sizeFromShape(r)*k.bytesPerElement(n));return Sve(a.buffer,n)}disposeData(e,t=!1){if(this.dataIdMap.has(e)){let n=this.dataIdMap.get(e);if(n.refCount--,!t&&n.refCount>0)return!1;this.wasm._free(n.memoryOffset),this.wasm.tfjs.disposeData(n.id),this.dataIdMap.delete(e)}return!0}refCount(e){return this.dataIdMap.has(e)?this.dataIdMap.get(e).refCount:0}incRef(e){let t=this.dataIdMap.get(e);t!=null&&t.refCount++}floatPrecision(){return 32}getMemoryOffset(e){return this.dataIdMap.get(e).memoryOffset}dispose(){this.wasm.tfjs.dispose(),"PThread"in this.wasm&&this.wasm.PThread.terminateAllThreads(),this.wasm=null}memory(){return{unreliable:!1}}makeOutput(e,t,n){let r;if(n==null)r=this.write(null,e,t);else{let s=this.dataIdNextNumber++;r={id:s},this.dataIdMap.set(r,{id:s,memoryOffset:n,shape:e,dtype:t,refCount:1});let a=k.sizeFromShape(e);this.wasm.tfjs.registerTensor(s,a,n)}return{dataId:r,shape:e,dtype:t}}typedArrayFromHeap({shape:e,dtype:t,dataId:n}){let r=this.wasm.HEAPU8.buffer,{memoryOffset:s}=this.dataIdMap.get(n),a=k.sizeFromShape(e);switch(t){case"float32":return new Float32Array(r,s,a);case"int32":return new Int32Array(r,s,a);case"bool":return new Uint8Array(r,s,a);default:throw new Error(`Unknown dtype ${t}`)}}};function kve(e){return(t,n)=>(k.fetch(e,{credentials:"same-origin"}).then(r=>{r.ok||t.env.a(`failed to load wasm binary file at '${e}'`),r.arrayBuffer().then(s=>{WebAssembly.instantiate(s,t).then(a=>{n(a.instance,a.module)})})}),{})}function c$(e,t,n){if(r0!=null)return r0;let r="tfjs-backend-wasm.wasm";return e&&t?r="tfjs-backend-wasm-threaded-simd.wasm":e&&(r="tfjs-backend-wasm-simd.wasm"),Ah!=null&&Ah[r]!=null?Ah[r]:n+r}async function Ive(){let[e,t]=await Promise.all([ae().getAsync("WASM_HAS_SIMD_SUPPORT"),ae().getAsync("WASM_HAS_MULTITHREAD_SUPPORT")]);return new Promise((n,r)=>{let s={};s.locateFile=(i,l)=>{if(i.endsWith(".worker.js")){let u=vve,c=new Blob([u],{type:"application/javascript"});return URL.createObjectURL(c)}return i.endsWith(".wasm")?c$(e,t,yh!=null?yh:l):l+i},Ab&&(s.instantiateWasm=kve(c$(e,t,yh!=null?yh:"")));let a=!1;s.onAbort=()=>{if(a||xh)return;xh=!0,r({message:"Make sure the server can serve the `.wasm` file relative to the bundled js file. For more details see https://github.com/tensorflow/tfjs/blob/master/tfjs-backend-wasm/README.md#using-bundlers"})};let o;t&&e&&r0==null?(s.mainScriptUrlOrBlob=new Blob(["var WasmBackendModuleThreadedSimd = "+l$.default.toString()],{type:"text/javascript"}),o=(0,l$.default)(s)):o=(0,wve.default)(s),o.then(i=>{a=!0,xh=!1;let l=null;i.tfjs={init:i.cwrap("init",null,[]),registerTensor:i.cwrap("register_tensor",null,["number","number","number"]),disposeData:i.cwrap("dispose_data",l,["number"]),dispose:i.cwrap("dispose",l,[])},n({wasm:i})})})}function Sve(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 Tve=["tfjs-backend-wasm.wasm","tfjs-backend-wasm-simd.wasm","tfjs-backend-wasm-threaded-simd.wasm"],r0=null,yh=null,Ah={},xh=!1,Ab=!1;function Nve(e,t=!1){if(W6("setWasmPath has been deprecated in favor of setWasmPaths and will be removed in a future release."),xh)throw new Error("The WASM backend was already initialized. Make sure you call `setWasmPath()` before you call `tf.setBackend()` or `tf.ready()`");r0=e,Ab=t}function Cve(e,t=!1){if(xh)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")yh=e;else{Ah=e;let n=Tve.filter(r=>Ah[r]==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.`)}Ab=t}var Eve="3.7.0",$ve=2;$A("wasm",async()=>{let{wasm:e}=await Ive();return new u$(e)},$ve);var _ve={tfjs:TR,"tfjs-core":NR,"tfjs-data":CR,"tfjs-layers":ER,"tfjs-converter":$R,"tfjs-backend-cpu":_R,"tfjs-backend-webgl":RR,"tfjs-backend-wasm":DR};var gr={name:"humangl",priority:99,canvas:null,gl:null,width:1024,height:1024,webGLattr:{alpha:!1,antialias:!1,premultipliedAlpha:!1,preserveDrawingBuffer:!1,depth:!1,stencil:!1,failIfMajorPerformanceCaveat:!1,desynchronized:!0}};function d$(){if(!q2(gr.name)){me("backend registration:",gr.name);try{gr.canvas=typeof OffscreenCanvas!="undefined"?new OffscreenCanvas(gr.width,gr.height):document.createElement("canvas")}catch(e){me("error: cannot create canvas:",e);return}try{gr.gl=gr.canvas.getContext("webgl2",gr.webGLattr)}catch(e){me("error: cannot get WebGL2 context:",e);return}try{Dm(2,gr.gl)}catch(e){me("error: cannot set WebGL2 context:",e);return}try{let e=new Bm(gr.gl);K2(gr.name,()=>new dh(e),gr.priority)}catch(e){me("error: cannot register WebGL backend:",e);return}try{Li("webgl").forEach(t=>{let n={...t,backendName:gr.name};sp(n)})}catch(e){me("error: cannot update WebGL backend registration:",e);return}try{Sr.set("WEBGL_VERSION",2)}catch(e){me("error: cannot set WebGL backend flags:",e);return}me("backend registered:",gr.name)}}function h$(e,t){let n=[e.startPoint[0]*t[0],e.startPoint[1]*t[1]],r=[e.endPoint[0]*t[0],e.endPoint[1]*t[1]];return{startPoint:n,endPoint:r}}function vh(e){return[Math.abs(e.endPoint[0]-e.startPoint[0]),Math.abs(e.endPoint[1]-e.startPoint[1])]}function Tu(e){return[e.startPoint[0]+(e.endPoint[0]-e.startPoint[0])/2,e.startPoint[1]+(e.endPoint[1]-e.startPoint[1])/2]}function Nu(e,t,n){let r=t.shape[1],s=t.shape[2],a=[[e.startPoint[1]/r,e.startPoint[0]/s,e.endPoint[1]/r,e.endPoint[0]/s]];return Ye.cropAndResize(t,a,[0],n)}function s0(e,t=1.5){let n=Tu(e),r=vh(e),s=[t*r[0]/2,t*r[1]/2],a=[n[0]-s[0],n[1]-s[1]],o=[n[0]+s[0],n[1]+s[1]];return{startPoint:a,endPoint:o,landmarks:e.landmarks}}function a0(e){let t=Tu(e),n=vh(e),s=Math.max(...n)/2,a=[Math.round(t[0]-s),Math.round(t[1]-s)],o=[Math.round(t[0]+s),Math.round(t[1]+s)];return{startPoint:a,endPoint:o,landmarks:e.landmarks}}function xb(e){let t=e.map(a=>a[0]),n=e.map(a=>a[1]),r=[Math.min(...t),Math.min(...n)],s=[Math.max(...t),Math.max(...n)];return{startPoint:r,endPoint:s,landmarks:e}}var p$=e=>({startPoint:Ze(e,[0,0],[-1,2]),endPoint:Ze(e,[0,2],[-1,2])});var o0=[[1,0,0],[0,1,0],[0,0,1]];function Rve(e){return e-2*Math.PI*Math.floor((e+Math.PI)/(2*Math.PI))}function bb(e,t){let n=Math.PI/2-Math.atan2(-(t[1]-e[1]),t[0]-e[0]);return Rve(n)}function f$(e,t){return[[1,0,e],[0,1,t],[0,0,1]]}function no(e,t){let n=0;for(let r=0;r<e.length;r++)n+=e[r]*t[r];return n}function Dve(e,t){let n=[];for(let r=0;r<e.length;r++)n.push(e[r][t]);return n}function m$(e,t){let n=[],r=e.length;for(let s=0;s<r;s++){n.push([]);for(let a=0;a<r;a++)n[s].push(no(e[s],Dve(t,a)))}return n}function i0(e,t){let n=Math.cos(e),r=Math.sin(e),s=[[n,-r,0],[r,n,0],[0,0,1]],a=f$(t[0],t[1]),o=m$(a,s),i=f$(-t[0],-t[1]);return m$(o,i)}function g$(e){let t=[[e[0][0],e[1][0]],[e[0][1],e[1][1]]],n=[e[0][2],e[1][2]],r=[-no(t[0],n),-no(t[1],n)];return[t[0].concat(r[0]),t[1].concat(r[1]),[0,0,1]]}function y$(e,t){return[no(e,t[0]),no(e,t[1])]}function A$(e){let t={strides:[e/16,e/8],anchors:[2,6]},n=[];for(let r=0;r<t.strides.length;r++){let s=t.strides[r],a=Math.floor((e+s-1)/s),o=Math.floor((e+s-1)/s),i=t.anchors[r];for(let l=0;l<a;l++){let u=s*(l+.5);for(let c=0;c<o;c++){let d=s*(c+.5);for(let h=0;h<i;h++)n.push([d,u])}}}return n}var x$=6;function Fve(e,t,n){let r=Ze(e,[0,1],[-1,2]),s=Me(r,t),a=Ze(e,[0,3],[-1,2]),o=Qe(a,n),i=Qe(s,n),l=Qe(o,2),u=He(i,l),c=Me(i,l),d=fe(u,n),h=fe(c,n);return lc([d,h],1)}var b$=class{constructor(t,n){this.model=t,this.anchorsData=A$(t.inputs[0].shape[1]),this.anchors=ra(this.anchorsData),this.inputSize=t.inputs[0].shape[2],this.config=n}async getBoundingBoxes(t){if(!t||t.isDisposedInternal||t.shape.length!==4||t.shape[1]<1||t.shape[2]<1)return null;let[n,r,s]=Ue(()=>{let u=Ye.resizeBilinear(t,[this.inputSize,this.inputSize]).div(127.5).sub(.5),c=this.model.execute(u),d;if(Array.isArray(c)){let m=c.sort((x,b)=>x.size-b.size),g=an([m[0],m[2]],2),y=an([m[1],m[3]],2);d=an([y,g],1).squeeze(0)}else d=Zn(c);let h=Fve(d,this.anchors,[this.inputSize,this.inputSize]),p=Ze(d,[0,0],[-1,1]),f=Ts(p).squeeze().dataSync();return[d,h,f]}),a=await Ye.nonMaxSuppressionAsync(r,s,this.config.face.detector.maxDetected,this.config.face.detector.iouThreshold,this.config.face.detector.minConfidence),o=a.arraySync();a.dispose();let i=[];for(let l=0;l<o.length;l++){let u=s[o[l]];if(u>this.config.face.detector.minConfidence){let c=Ze(r,[o[l],0],[1,-1]),d=p$(c);c.dispose();let h=this.anchorsData[o[l]],p=Ue(()=>Ze(n,[o[l],x$-1],[1,-1]).squeeze().reshape([x$,-1]));i.push({box:d,landmarks:p,anchor:h,confidence:u})}}return n.dispose(),r.dispose(),{boxes:i,scaleFactor:[t.shape[2]/this.inputSize,t.shape[1]/this.inputSize]}}};async function v$(e){let t=await Et($t(e.modelBasePath,e.face.detector.modelPath),{fromTFHub:e.face.detector.modelPath.includes("tfhub.dev")}),n=new b$(t,e);return!t||!t.modelUrl?me("load model failed:",e.face.detector.modelPath):e.debug&&me("load model:",t.modelUrl),n}var Bs={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]},vb=[{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]}],wh=[[.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]],vi=[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 Mve=[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],Ove=[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],Pve=[33,133,362,263,1,78,308],g7e=Mve.map(e=>wh[e]),y7e=Ove.map(e=>wh[e]),A7e=Pve.map(e=>wh[e]);var wb=Bs.leftEyeLower0,kb=Bs.rightEyeLower0,Cu={leftBounds:[wb[0],wb[wb.length-1]],rightBounds:[kb[0],kb[kb.length-1]]},l0={count:468,mouth:13,symmetryLine:[13,Bs.midwayBetweenEyes[0]]},w$={leftEye:0,rightEye:1,nose:2,mouth:3,leftEar:4,rightEar:5,symmetryLine:[3,2]},Eu={upperCenter:3,lowerCenter:4,index:71,numCoordinates:76};function u0(e,t,n,r){for(let s=0;s<vb.length;s++){let{key:a,indices:o}=vb[s],i=Bs[`${n}${a}`];if(!r||r.includes(a))for(let l=0;l<o.length;l++){let u=o[l];e[i[l]]=[t[u][0],t[u][1],(t[u][2]+e[i[l]][2])/2]}}}var Ib=class{constructor(t,n,r){var s,a;this.storedBoxes=[],this.boundingBoxDetector=t,this.meshDetector=n,this.irisModel=r,this.boxSize=((s=t==null?void 0:t.model)==null?void 0:s.inputs[0].shape[2])||0,this.meshSize=(n==null?void 0:n.inputs[0].shape[2])||((a=t==null?void 0:t.model)==null?void 0:a.inputs[0].shape[2]),this.irisSize=(r==null?void 0:r.inputs[0].shape[1])||0,this.irisEnlarge=2.3,this.skipped=0,this.detectedFaces=0}transformRawCoords(t,n,r,s){let a=vh({startPoint:n.startPoint,endPoint:n.endPoint}),o=t.map(d=>[a[0]/this.meshSize*(d[0]-this.meshSize/2),a[1]/this.meshSize*(d[1]-this.meshSize/2),d[2]]),i=r!==0?i0(r,[0,0]):o0,l=r!==0?o.map(d=>[...y$(d,i),d[2]]):o,u=r!==0?g$(s):o0,c=[...Tu({startPoint:n.startPoint,endPoint:n.endPoint}),1];return l.map(d=>[Math.round(d[0]+no(c,u[0])),Math.round(d[1]+no(c,u[1])),Math.round(d[2])])}getLeftToRightEyeDepthDifference(t){let n=t[Cu.leftBounds[0]][2],r=t[Cu.rightBounds[0]][2];return n-r}getEyeBox(t,n,r,s,a=!1){let o=a0(s0(xb([t[r],t[s]]),this.irisEnlarge)),i=vh(o),l=Ye.cropAndResize(n,[[o.startPoint[1]/this.meshSize,o.startPoint[0]/this.meshSize,o.endPoint[1]/this.meshSize,o.endPoint[0]/this.meshSize]],[0],[this.irisSize,this.irisSize]);return a&&Sr.flags.IS_BROWSER&&(l=Ye.flipLeftRight(l)),{box:o,boxSize:i,crop:l}}getEyeCoords(t,n,r,s=!1){let a=[];for(let o=0;o<Eu.numCoordinates;o++){let i=t[o*3],l=t[o*3+1],u=t[o*3+2];a.push([(s?1-i/this.irisSize:i/this.irisSize)*r[0]+n.startPoint[0],l/this.irisSize*r[1]+n.startPoint[1],u])}return{rawCoords:a,iris:a.slice(Eu.index)}}getAdjustedIrisCoords(t,n,r){let s=t[Bs[`${r}EyeUpper0`][Eu.upperCenter]][2],a=t[Bs[`${r}EyeLower0`][Eu.lowerCenter]][2],o=(s+a)/2;return n.map((i,l)=>{let u=o;return l===2?u=s:l===4&&(u=a),[i[0],i[1],u]})}async predict(t,n){let r=!1,s;if((this.skipped===0||this.skipped>n.face.detector.skipFrames||!n.face.mesh.enabled||!n.skipFrame)&&(s=await this.boundingBoxDetector.getBoundingBoxes(t),this.skipped=0),n.skipFrame&&this.skipped++,!n.skipFrame||s&&s.boxes&&(!n.face.mesh.enabled||s.boxes.length!==this.detectedFaces&&this.detectedFaces!==n.face.detector.maxDetected)){this.storedBoxes=[],this.detectedFaces=0;for(let o of s.boxes)this.storedBoxes.push({startPoint:o.box.startPoint.dataSync(),endPoint:o.box.endPoint.dataSync(),landmarks:o.landmarks.arraySync(),confidence:o.confidence});this.storedBoxes.length>0&&(r=!0)}if(r){if(!s||!s.boxes||s.boxes.length===0)return this.storedBoxes=[],this.detectedFaces=0,null;for(let o=0;o<this.storedBoxes.length;o++){let i=h$({startPoint:this.storedBoxes[o].startPoint,endPoint:this.storedBoxes[o].endPoint},s.scaleFactor),l=s0(i),u=a0(l),c=this.storedBoxes[o].landmarks,d=this.storedBoxes[o].confidence;this.storedBoxes[o]={...u,confidence:d,landmarks:c}}}s&&s.boxes&&s.boxes.forEach(o=>{o.box.startPoint.dispose(),o.box.endPoint.dispose(),o.landmarks.dispose()});let a=Ue(()=>this.storedBoxes.map((o,i)=>{let l,u=0,c;if(n.face.detector.rotation&&n.face.mesh.enabled&&Sr.flags.IS_BROWSER){let[x,b]=o.landmarks.length>=l0.count?l0.symmetryLine:w$.symmetryLine;u=bb(o.landmarks[x],o.landmarks[b]);let v=Tu({startPoint:o.startPoint,endPoint:o.endPoint}),w=[v[0]/t.shape[2],v[1]/t.shape[1]],I=Ye.rotateWithOffset(t,u,0,w);c=i0(-u,v),n.face.mesh.enabled?l=Nu({startPoint:o.startPoint,endPoint:o.endPoint},I,[this.meshSize,this.meshSize]).div(255):l=Nu({startPoint:o.startPoint,endPoint:o.endPoint},I,[this.boxSize,this.boxSize]).div(255)}else{c=o0;let x=t.clone();n.face.mesh.enabled?l=Nu({startPoint:o.startPoint,endPoint:o.endPoint},x,[this.meshSize,this.meshSize]).div(255):l=Nu({startPoint:o.startPoint,endPoint:o.endPoint},x,[this.boxSize,this.boxSize]).div(255)}if(!n.face.mesh.enabled)return{mesh:[],box:o,faceConfidence:null,boxConfidence:o.confidence,confidence:o.confidence,image:l};let[,d,h]=this.meshDetector.execute(l),p=d.dataSync()[0];if(p<n.face.detector.minConfidence)return this.storedBoxes[i].confidence=p,null;let m=ue(h,[-1,3]).arraySync();if(n.face.iris.enabled){let{box:x,boxSize:b,crop:v}=this.getEyeBox(m,l,Cu.leftBounds[0],Cu.leftBounds[1],!0),{box:w,boxSize:I,crop:T}=this.getEyeBox(m,l,Cu.rightBounds[0],Cu.rightBounds[1]),M=this.irisModel.predict(an([v,T])).dataSync(),$=M.slice(0,Eu.numCoordinates*3),{rawCoords:R,iris:N}=this.getEyeCoords($,x,b,!0),F=M.slice(Eu.numCoordinates*3),{rawCoords:B,iris:j}=this.getEyeCoords(F,w,I),X=this.getLeftToRightEyeDepthDifference(m);Math.abs(X)<30?(u0(m,R,"left",null),u0(m,B,"right",null)):X<1?u0(m,R,"left",["EyeUpper0","EyeLower0"]):u0(m,B,"right",["EyeUpper0","EyeLower0"]);let Y=this.getAdjustedIrisCoords(m,N,"left"),ee=this.getAdjustedIrisCoords(m,j,"right");m=m.concat(Y).concat(ee)}let g=this.transformRawCoords(m,o,u,c),y=o.confidence;if(o=s0(xb(g),1.5),o.confidence=y,n.face.detector.rotation&&n.face.mesh.enabled&&n.face.description.enabled&&Sr.flags.IS_BROWSER){let[x,b]=o.landmarks.length>=l0.count?l0.symmetryLine:w$.symmetryLine;u=bb(o.landmarks[x],o.landmarks[b]);let v=Tu({startPoint:o.startPoint,endPoint:o.endPoint}),w=[v[0]/t.shape[2],v[1]/t.shape[1]],I=Ye.rotateWithOffset(t.toFloat(),u,0,w);c=i0(-u,v),l=Nu({startPoint:o.startPoint,endPoint:o.endPoint},I,[this.meshSize,this.meshSize]).div(255)}let A={mesh:g,box:o,faceConfidence:p,boxConfidence:o.confidence,image:l};return this.storedBoxes[i]={...a0(o),confidence:o.confidence,faceConfidence:p},A}));return n.face.mesh.enabled&&(this.storedBoxes=this.storedBoxes.filter(o=>o.confidence>n.face.detector.minConfidence)),this.detectedFaces=a.length,a}};var Zt=[null,null,null],Sb;async function k$(e,t){let n=await Sb.predict(e,t),r=[],s=0;for(let a of n||[]){if(!a||a.isDisposedInternal)continue;let o=a.mesh.map(c=>[c[0]/(e.shape[2]||0),c[1]/(e.shape[1]||0),c[2]/Sb.meshSize]),i={};if(a.mesh&&a.mesh.length>0)for(let c of Object.keys(Bs))i[c]=Bs[c].map(d=>a.mesh[d]);let l=a.box?[Math.trunc(Math.max(0,a.box.startPoint[0])),Math.trunc(Math.max(0,a.box.startPoint[1])),Math.trunc(Math.min(e.shape[2]||0,a.box.endPoint[0])-Math.max(0,a.box.startPoint[0])),Math.trunc(Math.min(e.shape[1]||0,a.box.endPoint[1])-Math.max(0,a.box.startPoint[1]))]:[0,0,0,0],u=a.box?[a.box.startPoint[0]/(e.shape[2]||0),a.box.startPoint[1]/(e.shape[1]||0),(a.box.endPoint[0]-a.box.startPoint[0])/(e.shape[2]||0),(a.box.endPoint[1]-a.box.startPoint[1])/(e.shape[1]||0)]:[0,0,0,0];r.push({id:s++,score:Math.round(100*a.faceConfidence||100*a.boxConfidence||0)/100,boxScore:Math.round(100*a.boxConfidence)/100,faceScore:Math.round(100*a.faceConfidence)/100,box:l,boxRaw:u,mesh:a.mesh,meshRaw:o,annotations:i,image:a.image,tensor:a.image}),a.coords&&a.coords.dispose()}return r}async function Tb(e){return!Zt[0]&&e.face.enabled||!Zt[1]&&e.face.mesh.enabled||!Zt[2]&&e.face.iris.enabled?(Zt=await Promise.all([!Zt[0]&&e.face.enabled?v$(e):null,!Zt[1]&&e.face.mesh.enabled?Et($t(e.modelBasePath,e.face.mesh.modelPath),{fromTFHub:e.face.mesh.modelPath.includes("tfhub.dev")}):null,!Zt[2]&&e.face.iris.enabled?Et($t(e.modelBasePath,e.face.iris.modelPath),{fromTFHub:e.face.iris.modelPath.includes("tfhub.dev")}):null]),e.face.mesh.enabled&&(!Zt[1]||!Zt[1].modelUrl?me("load model failed:",e.face.mesh.modelPath):e.debug&&me("load model:",Zt[1].modelUrl)),e.face.iris.enabled&&(!Zt[2]||!Zt[2].modelUrl?me("load model failed:",e.face.iris.modelPath):e.debug&&me("load model:",Zt[2].modelUrl))):e.debug&&(Zt[0]&&me("cached model:",Zt[0].model.modelUrl),Zt[1]&&me("cached model:",Zt[1].modelUrl),Zt[2]&&me("cached model:",Zt[2].modelUrl)),Sb=new Ib(Zt[0],Zt[1],Zt[2]),Zt}var I$=vi,S$=wh;var zve=["angry","disgust","fear","happy","sad","surprise","neutral"],xs,c0=[],T$=0,Nb=Number.MAX_SAFE_INTEGER,Cb=[.2989,.587,.114];async function Eb(e){return xs?e.debug&&me("cached model:",xs.modelUrl):(xs=await Et($t(e.modelBasePath,e.face.emotion.modelPath)),!xs||!xs.modelUrl?me("load model failed:",e.face.emotion.modelPath):e.debug&&me("load model:",xs.modelUrl)),xs}async function $b(e,t,n,r){return xs?Nb<t.face.emotion.skipFrames&&t.skipFrame&&T$===r&&c0[n]&&c0[n].length>0?(Nb++,c0[n]):(Nb=0,new Promise(async s=>{let a=Ye.resizeBilinear(e,[xs.inputs[0].shape[2],xs.inputs[0].shape[1]],!1),[o,i,l]=ta(a,3,3);a.dispose();let u=fe(o,Cb[0]),c=fe(i,Cb[1]),d=fe(l,Cb[2]);o.dispose(),i.dispose(),l.dispose();let h=X2([u,c,d]);u.dispose(),c.dispose(),d.dispose();let p=Ue(()=>h.sub(.5).mul(2));h.dispose();let f=[];if(t.face.emotion.enabled){let m=await xs.predict(p),g=m.dataSync();Ve(m);for(let y=0;y<g.length;y++)g[y]>t.face.emotion.minConfidence&&f.push({score:Math.min(.99,Math.trunc(100*g[y])/100),emotion:zve[y]});f.sort((y,A)=>A.score-y.score)}p.dispose(),c0[n]=f,T$=r,s(f)})):null}var bs,d0=[],N$=0,_b=Number.MAX_SAFE_INTEGER;async function Rb(e){let t=$t(e.modelBasePath,e.face.description.modelPath);return bs?e.debug&&me("cached model:",t):(bs=await Et(t),bs?e.debug&&me("load model:",t):me("load model failed:",e.face.description.modelPath)),bs}function Db(e,t,n=2){if(!e||!t||(e==null?void 0:e.length)===0||(t==null?void 0:t.length)===0||(e==null?void 0:e.length)!==(t==null?void 0:t.length))return 0;let r=5*e.map((a,o)=>Math.abs(e[o]-t[o])**n).reduce((a,o)=>a+o,0)**(1/n);return Math.max(0,100-r)/100}function C$(e,t,n=0){let r={similarity:0,name:"",source:"",embedding:[]};if(!e||!t||!Array.isArray(e)||!Array.isArray(t))return r;for(let s of t)if(s.embedding&&s.name){let a=Db(e,s.embedding);a>n&&a>r.similarity&&(r={...s,similarity:a})}return r}function Fb(e){return Ue(()=>{let n=e.image||e.tensor||e;if(!(n instanceof Tt))return null;let r=[[.05,.15,.85,.85]];return bs.inputs[0].shape?(n.shape.length===3?Ye.cropAndResize(ea(n,0),r,[0],[bs.inputs[0].shape[2],bs.inputs[0].shape[1]]):Ye.cropAndResize(n,r,[0],[bs.inputs[0].shape[2],bs.inputs[0].shape[1]])).mul(255):null})}async function Mb(e,t,n,r){var s,a;return bs?_b<t.face.description.skipFrames&&t.skipFrame&&N$===r&&((s=d0[n])==null?void 0:s.age)&&((a=d0[n])==null?void 0:a.age)>0?(_b++,d0[n]):(_b=0,new Promise(async o=>{let i=Fb(e),l,u={age:0,gender:"unknown",genderScore:0,descriptor:[]};t.face.description.enabled&&(l=await bs.predict(i)),Ve(i),l&&(Ue(()=>{let c=l.find(m=>m.shape[1]===1).dataSync(),d=Math.trunc(200*Math.abs(c[0]-.5))/100;d>t.face.description.minConfidence&&(u.gender=c[0]<=.5?"female":"male",u.genderScore=Math.min(.99,d));let h=l.find(m=>m.shape[1]===100).argMax(1).dataSync()[0],p=l.find(m=>m.shape[1]===100).dataSync();u.age=Math.round(p[h-1]>p[h+1]?10*h-100*p[h-1]:10*h+100*p[h+1])/10;let f=l.find(m=>m.shape[1]===1024);u.descriptor=[...f.dataSync()]}),l.forEach(c=>Ve(c))),d0[n]=u,N$=r,o(u)})):null}var Lve=e=>{let t=(d,h)=>Math.atan2(d[1]-h[1],d[0]-h[0]);if(!e.annotations.rightEyeIris||!e.annotations.leftEyeIris)return{bearing:0,strength:0};let n=[0,-.1],r=1,s=e.mesh[33][2]>e.mesh[263][2],a=s?e.mesh[473]:e.mesh[468],o=s?[(e.mesh[133][0]+e.mesh[33][0])/2,(e.mesh[133][1]+e.mesh[33][1])/2]:[(e.mesh[263][0]+e.mesh[362][0])/2,(e.mesh[263][1]+e.mesh[362][1])/2],i=s?[e.mesh[133][0]-e.mesh[33][0],e.mesh[23][1]-e.mesh[27][1]]:[e.mesh[263][0]-e.mesh[362][0],e.mesh[253][1]-e.mesh[257][1]],l=[(o[0]-a[0])/i[0]-n[0],r*(a[1]-o[1])/i[1]-n[1]],u=Math.sqrt(l[0]**2+l[1]**2);return u=Math.min(u,e.boxRaw[2]/2,e.boxRaw[3]/2),{bearing:(t([0,0],l)+Math.PI/2)%Math.PI,strength:u}},Bve=(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},r=(g,y)=>{let A=g[0]-y[0],x=g[1]-y[1],b=g[2]-y[2];return[A,x,b]},s=(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]},a=g=>{let[y,A,x,b,v,w,I,T,C]=g,M,$,R;return b<1?b>-1?(R=Math.asin(b),$=Math.atan2(-I,y),M=Math.atan2(-w,v)):(R=-Math.PI/2,$=-Math.atan2(T,C),M=0):(R=Math.PI/2,$=Math.atan2(T,C),M=0),{pitch:2*-M,yaw:2*-$,roll:2*-R}},o=g=>{let y=(x,b,v,w)=>Math.atan2(w-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])}},i=e.meshRaw;if(!i||i.length<300)return{angle:{pitch:0,yaw:0,roll:0},matrix:[1,0,0,0,1,0,0,0,1],gaze:{bearing:0,strength:0}};let l=Math.max(e.boxRaw[2]*t[0],e.boxRaw[3]*t[1])/1.5,u=[i[10],i[152],i[234],i[454]].map(g=>[g[0]*t[0]/l,g[1]*t[1]/l,g[2]]),c=n(r(u[1],u[0])),d=n(r(u[3],u[2])),h=n(s(d,c));d=s(c,h);let p=[d[0],d[1],d[2],c[0],c[1],c[2],h[0],h[1],h[2]],f=a(p),m=i.length===478?Lve(e):{bearing:0,strength:0};return{angle:f,matrix:p,gaze:m}},Ob=async(e,t)=>{var c,d,h,p,f,m;let n,r,s,a,o,i,l=[];e.state="run:face",n=at();let u=await k$(t,e.config);if(e.performance.face=Math.trunc(at()-n),!t.shape||t.shape.length!==4)return[];if(!u)return[];for(let g=0;g<u.length;g++){if(e.analyze("Get Face"),!u[g].image||u[g].image.isDisposedInternal){me("Face object is disposed:",u[g].image);continue}let y=Bve(u[g],[t.shape[2],t.shape[1]]);e.analyze("Start Emotion:"),e.config.async?a=e.config.face.emotion.enabled?$b(u[g].image||ts([]),e.config,g,u.length):{}:(e.state="run:emotion",n=at(),a=e.config.face.emotion.enabled?await $b(u[g].image||ts([]),e.config,g,u.length):{},e.performance.emotion=Math.trunc(at()-n)),e.analyze("End Emotion:"),e.analyze("Start Description:"),e.config.async?i=e.config.face.description.enabled?Mb(u[g].image||ts([]),e.config,g,u.length):[]:(e.state="run:description",n=at(),i=e.config.face.description.enabled?await Mb(u[g].image||ts([]),e.config,g,u.length):[],e.performance.embedding=Math.trunc(at()-n)),e.analyze("End Description:"),e.config.async&&([r,s,a,o,i]=await Promise.all([r,s,a,o,i])),e.analyze("Finish Face:"),!e.config.face.iris.enabled&&((d=(c=u[g])==null?void 0:c.annotations)==null?void 0:d.leftEyeIris)&&((p=(h=u[g])==null?void 0:h.annotations)==null?void 0:p.rightEyeIris)&&(delete u[g].annotations.leftEyeIris,delete u[g].annotations.rightEyeIris);let A=((f=u[g].annotations)==null?void 0:f.leftEyeIris)&&((m=u[g].annotations)==null?void 0:m.rightEyeIris)?Math.max(Math.abs(u[g].annotations.leftEyeIris[3][0]-u[g].annotations.leftEyeIris[1][0]),Math.abs(u[g].annotations.rightEyeIris[4][1]-u[g].annotations.rightEyeIris[2][1]))/t.shape[2]:0;l.push({...u[g],id:g,age:i.age,gender:i.gender,genderScore:i.genderScore,embedding:i.descriptor,emotion:a,iris:A!==0?Math.trunc(500/A/11.7)/100:0,rotation:y,tensor:e.config.face.detector.return?Zn(u[g].image):null}),Ve(u[g].image),u[g].image&&delete u[g].image,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),l};var kh=["nose","leftEye","rightEye","leftEar","rightEar","leftShoulder","rightShoulder","leftElbow","rightElbow","leftWrist","rightWrist","leftHip","rightHip","leftKnee","rightKnee","leftAnkle","rightAnkle"],E$=kh.length,Ih=kh.reduce((e,t,n)=>(e[t]=n,e),{}),Wve=[["leftHip","leftShoulder"],["leftElbow","leftShoulder"],["leftElbow","leftWrist"],["leftHip","leftKnee"],["leftKnee","leftAnkle"],["rightHip","rightShoulder"],["rightElbow","rightShoulder"],["rightElbow","rightWrist"],["rightHip","rightKnee"],["rightKnee","rightAnkle"],["leftShoulder","rightShoulder"],["leftHip","rightHip"]],Vve=Wve.map(([e,t])=>[Ih[e],Ih[t]]),$$=[["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 _$(e){let t=e.reduce(({maxX:n,maxY:r,minX:s,minY:a},{position:{x:o,y:i}})=>({maxX:Math.max(n,o),maxY:Math.max(r,i),minX:Math.min(s,o),minY:Math.min(a,i)}),{maxX:Number.NEGATIVE_INFINITY,maxY:Number.NEGATIVE_INFINITY,minX:Number.POSITIVE_INFINITY,minY:Number.POSITIVE_INFINITY});return[t.minX,t.minY,t.maxX-t.minX,t.maxY-t.minY]}function R$(e,[t,n],[r,s]){let a=t/r,o=n/s,i=(u,c)=>({id:c,score:u.score,boxRaw:[u.box[0]/s,u.box[1]/r,u.box[2]/s,u.box[3]/r],box:[Math.trunc(u.box[0]*o),Math.trunc(u.box[1]*a),Math.trunc(u.box[2]*o),Math.trunc(u.box[3]*a)],keypoints:u.keypoints.map(({score:d,part:h,position:p})=>({score:d,part:h,position:[Math.trunc(p.x*o),Math.trunc(p.y*a)],positionRaw:[p.x/r,p.y/r]}))});return e.map((u,c)=>i(u,c))}var Pb=class{constructor(t,n){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 r=this.priorityQueue[t];this.priorityQueue[t]=this.priorityQueue[n],this.priorityQueue[n]=r}};function zb(e,t,n,r){return{y:r.get(e,t,n),x:r.get(e,t,n+E$)}}function Lb(e,t,n){let{heatmapY:r,heatmapX:s,id:a}=e,{y:o,x:i}=zb(r,s,a,n);return{x:e.heatmapX*t+i,y:e.heatmapY*t+o}}function Bb(e,t,n){return e<t?t:e>n?n:e}function D$(e,t,n,r){let s=n-e,a=r-t;return s*s+a*a}function Wb(e,t){return{x:e.x+t.x,y:e.y+t.y}}var h0=1,$u=16,Uve=50**2;function F$(e,t,n,r,s,a,o=2){let i=y=>({y:a.get(y.y,y.x,e),x:a.get(y.y,y.x,a.shape[2]/2+e)}),l=(y,A,x)=>({y:Bb(Math.round(y.y/$u),0,A-1),x:Bb(Math.round(y.x/$u),0,x-1)}),[u,c]=r.shape,d=l(t.position,u,c),h=i(d),f=Wb(t.position,h);for(let y=0;y<o;y++){let A=l(f,u,c),x=zb(A.y,A.x,n,s);f=Wb({x:A.x*$u,y:A.y*$u},{x:x.x,y:x.y})}let m=l(f,u,c),g=r.get(m.y,m.x,n);return{position:f,part:kh[n],score:g}}function Hve(e,t,n,r,s){let a=$$.map(([h,p])=>[Ih[h],Ih[p]]),o=a.map(([,h])=>h),i=a.map(([h])=>h),l=t.shape[2],u=o.length,c=new Array(l),d=Lb(e.part,$u,n);c[e.part.id]={score:e.score,part:kh[e.part.id],position:d};for(let h=u-1;h>=0;--h){let p=o[h],f=i[h];c[p]&&!c[f]&&(c[f]=F$(h,c[p],f,t,n,s))}for(let h=0;h<u;++h){let p=i[h],f=o[h];c[p]&&!c[f]&&(c[f]=F$(h,c[p],f,t,n,r))}return c}function Gve(e,t,n,r,s){let[a,o]=s.shape,i=!0,l=Math.max(n-h0,0),u=Math.min(n+h0+1,a);for(let c=l;c<u;++c){let d=Math.max(r-h0,0),h=Math.min(r+h0+1,o);for(let p=d;p<h;++p)if(s.get(c,p,e)>t){i=!1;break}if(!i)break}return i}function jve(e,t){let[n,r,s]=t.shape,a=new Pb(n*r*s,({score:o})=>o);for(let o=0;o<n;++o)for(let i=0;i<r;++i)for(let l=0;l<s;++l){let u=t.get(o,i,l);u<e||Gve(l,u,o,i,t)&&a.enqueue({score:u,part:{heatmapY:o,heatmapX:i,id:l}})}return a}function M$(e,{x:t,y:n},r){return e.some(({keypoints:s})=>{var o;let a=(o=s[r])==null?void 0:o.position;return a?D$(n,t,a.y,a.x)<=Uve:!1})}function qve(e,t){return t.reduce((r,{position:s,score:a},o)=>(M$(e,s,o)||(r+=a),r),0)/t.length}function O$(e,t,n,r,s,a){let o=[],i=jve(a,t);for(;o.length<s&&!i.empty();){let l=i.dequeue(),u=Lb(l.part,$u,e);if(M$(o,u,l.part.id))continue;let c=Hve(l,t,e,n,r);c=c.filter(p=>p.score>a);let d=qve(o,c),h=_$(c);d>a&&o.push({keypoints:c,box:h,score:Math.round(100*d)/100})}return o}var yr,Kve=["MobilenetV1/offset_2/BiasAdd","MobilenetV1/heatmap_2/BiasAdd","MobilenetV1/displacement_fwd_2/BiasAdd","MobilenetV1/displacement_bwd_2/BiasAdd"];async function Vb(e,t){let n=Ue(()=>{if(!yr.inputs[0].shape)return[];let i=Ye.resizeBilinear(e,[yr.inputs[0].shape[2],yr.inputs[0].shape[1]]).toFloat().div(127.5).sub(1),u=yr.execute(i,Kve).map(c=>Zn(c,[0]));return u[1]=u[1].sigmoid(),u}),r=await Promise.all(n.map(o=>o.buffer()));for(let o of n)o.dispose();let s=await O$(r[0],r[1],r[2],r[3],t.body.maxDetected,t.body.minConfidence);return yr.inputs[0].shape?R$(s,[e.shape[1],e.shape[2]],[yr.inputs[0].shape[2],yr.inputs[0].shape[1]]):[]}async function Ub(e){return yr?e.debug&&me("cached model:",yr.modelUrl):(yr=await Et($t(e.modelBasePath,e.body.modelPath)),!yr||!yr.modelUrl?me("load model failed:",e.body.modelPath):e.debug&&me("load model:",yr.modelUrl)),yr}function p0(e){return[Math.abs(e.endPoint[0]-e.startPoint[0]),Math.abs(e.endPoint[1]-e.startPoint[1])]}function Sh(e){return[e.startPoint[0]+(e.endPoint[0]-e.startPoint[0])/2,e.startPoint[1]+(e.endPoint[1]-e.startPoint[1])/2]}function P$(e,t,n){let r=t.shape[1],s=t.shape[2],a=[[e.startPoint[1]/r,e.startPoint[0]/s,e.endPoint[1]/r,e.endPoint[0]/s]];return Ye.cropAndResize(t,a,[0],n)}function z$(e,t){let n=[e.startPoint[0]*t[0],e.startPoint[1]*t[1]],r=[e.endPoint[0]*t[0],e.endPoint[1]*t[1]],s=e.palmLandmarks.map(a=>[a[0]*t[0],a[1]*t[1]]);return{startPoint:n,endPoint:r,palmLandmarks:s,confidence:e.confidence}}function f0(e,t=1.5){let n=Sh(e),r=p0(e),s=[t*r[0]/2,t*r[1]/2],a=[n[0]-s[0],n[1]-s[1]],o=[n[0]+s[0],n[1]+s[1]];return{startPoint:a,endPoint:o,palmLandmarks:e.palmLandmarks}}function m0(e){let t=Sh(e),n=p0(e),s=Math.max(...n)/2,a=[t[0]-s,t[1]-s],o=[t[0]+s,t[1]+s];return{startPoint:a,endPoint:o,palmLandmarks:e.palmLandmarks}}var L$=[{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 Hb=class{constructor(t){var n;this.model=t,this.anchors=L$.map(r=>[r.x,r.y]),this.anchorsTensor=ra(this.anchors),this.inputSize=(n=this.model)==null?void 0:n.inputs[0].shape[2],this.inputSizeTensor=lr([this.inputSize,this.inputSize]),this.doubleInputSizeTensor=lr([this.inputSize*2,this.inputSize*2])}normalizeBoxes(t){return Ue(()=>{let n=Ze(t,[0,0],[-1,2]),r=Ze(t,[0,2],[-1,2]),s=Me(Qe(n,this.inputSizeTensor),this.anchorsTensor),a=Qe(r,this.doubleInputSizeTensor),o=fe(He(s,a),this.inputSizeTensor),i=fe(Me(s,a),this.inputSizeTensor);return lc([o,i],1)})}normalizeLandmarks(t,n){return Ue(()=>{let r=Me(Qe(t.reshape([-1,7,2]),this.inputSizeTensor),this.anchors[n]);return fe(r,this.inputSizeTensor)})}async getBoxes(t,n){let r=this.model.predict(t),s=Zn(r);r.dispose();let a=Ue(()=>Ts(Ze(s,[0,0],[-1,1])).squeeze()),o=a.dataSync(),i=Ze(s,[0,1],[-1,4]),l=this.normalizeBoxes(i);i.dispose();let u=await Ye.nonMaxSuppressionAsync(l,o,n.hand.maxDetected,n.hand.iouThreshold,n.hand.minConfidence),c=u.arraySync();a.dispose(),u.dispose();let d=[];for(let h of c)if(o[h]>=n.hand.minConfidence){let p=Ze(l,[h,0],[1,-1]),f=Ze(s,[h,5],[1,14]),m=Ue(()=>this.normalizeLandmarks(f,h).reshape([-1,2]));f.dispose(),d.push({box:p,palmLandmarks:m,confidence:o[h]})}return s.dispose(),l.dispose(),d}async estimateHandBounds(t,n){let r=t.shape[1],s=t.shape[2],a=Ue(()=>t.resizeBilinear([this.inputSize,this.inputSize]).div(127.5).sub(1)),o=await this.getBoxes(a,n);a.dispose();let i=[];if(!o||o.length===0)return i;for(let l of o){let u=l.box.dataSync(),c=u.slice(0,2),d=u.slice(2,4),h=l.palmLandmarks.arraySync();l.box.dispose(),l.palmLandmarks.dispose(),i.push(z$({startPoint:c,endPoint:d,palmLandmarks:h,confidence:l.confidence},[s/this.inputSize,r/this.inputSize]))}return i}};function Xve(e){return e-2*Math.PI*Math.floor((e+Math.PI)/(2*Math.PI))}function B$(e,t){let n=Math.PI/2-Math.atan2(-(t[1]-e[1]),t[0]-e[0]);return Xve(n)}var W$=(e,t)=>[[1,0,e],[0,1,t],[0,0,1]];function ro(e,t){let n=0;for(let r=0;r<e.length;r++)n+=e[r]*t[r];return n}function Zve(e,t){let n=[];for(let r=0;r<e.length;r++)n.push(e[r][t]);return n}function V$(e,t){let n=[],r=e.length;for(let s=0;s<r;s++){n.push([]);for(let a=0;a<r;a++)n[s].push(ro(e[s],Zve(t,a)))}return n}function Gb(e,t){let n=Math.cos(e),r=Math.sin(e),s=[[n,-r,0],[r,n,0],[0,0,1]],a=W$(t[0],t[1]),o=V$(a,s),i=W$(-t[0],-t[1]);return V$(o,i)}function U$(e){let t=[[e[0][0],e[1][0]],[e[0][1],e[1][1]]],n=[e[0][2],e[1][2]],r=[-ro(t[0],n),-ro(t[1],n)];return[t[0].concat(r[0]),t[1].concat(r[1]),[0,0,1]]}function jb(e,t){return[ro(e,t[0]),ro(e,t[1])]}var Yve=5,H$=1.65,G$=[0,5,9,13,17,1,2],Jve=0,Qve=2,qb=class{constructor(t,n){var r;this.handDetector=t,this.handPoseModel=n,this.inputSize=(r=this.handPoseModel)==null?void 0:r.inputs[0].shape[2],this.storedBoxes=[],this.skipped=0,this.detectedHands=0}calculateLandmarksBoundingBox(t){let n=t.map(o=>o[0]),r=t.map(o=>o[1]),s=[Math.min(...n),Math.min(...r)],a=[Math.max(...n),Math.max(...r)];return{startPoint:s,endPoint:a}}getBoxForPalmLandmarks(t,n){let r=t.map(a=>jb([...a,1],n)),s=this.calculateLandmarksBoundingBox(r);return f0(m0(s),Yve)}getBoxForHandLandmarks(t){let n=this.calculateLandmarksBoundingBox(t),r=f0(m0(n),H$);r.palmLandmarks=[];for(let s=0;s<G$.length;s++)r.palmLandmarks.push(t[G$[s]].slice(0,2));return r}transformRawCoords(t,n,r,s){let a=p0(n),o=[a[0]/this.inputSize,a[1]/this.inputSize,(a[0]+a[1])/this.inputSize/2],i=t.map(p=>[o[0]*(p[0]-this.inputSize/2),o[1]*(p[1]-this.inputSize/2),o[2]*p[2]]),l=Gb(r,[0,0]),u=i.map(p=>[...jb(p,l),p[2]]),c=U$(s),d=[...Sh(n),1],h=[ro(d,c[0]),ro(d,c[1])];return u.map(p=>[Math.trunc(p[0]+h[0]),Math.trunc(p[1]+h[1]),Math.trunc(p[2])])}async estimateHands(t,n){let r=!1,s;(this.skipped===0||this.skipped>n.hand.skipFrames||!n.hand.landmarks||!n.skipFrame)&&(s=await this.handDetector.estimateHandBounds(t,n),this.skipped=0),n.skipFrame&&this.skipped++,s&&s.length>0&&(s.length!==this.detectedHands&&this.detectedHands!==n.hand.maxDetected||!n.hand.landmarks)&&(this.detectedHands=0,this.storedBoxes=[...s],this.storedBoxes.length>0&&(r=!0));let a=[];for(let o=0;o<this.storedBoxes.length;o++){let i=this.storedBoxes[o];if(!!i)if(n.hand.landmarks){let l=n.hand.rotation?B$(i.palmLandmarks[Jve],i.palmLandmarks[Qve]):0,u=Sh(i),c=[u[0]/t.shape[2],u[1]/t.shape[1]],d=n.hand.rotation&&Sr.flags.IS_BROWSER?Ye.rotateWithOffset(t,l,0,c):t.clone(),h=Gb(-l,u),p=r?this.getBoxForPalmLandmarks(i.palmLandmarks,h):i,f=P$(p,d,[this.inputSize,this.inputSize]),m=f.div(255);f.dispose(),d.dispose();let[g,y]=await this.handPoseModel.predict(m);m.dispose();let A=g.dataSync()[0];if(g.dispose(),A>=n.hand.minConfidence){let x=ue(y,[-1,3]),b=x.arraySync();y.dispose(),x.dispose();let v=this.transformRawCoords(b,p,l,h),w=this.getBoxForHandLandmarks(v);this.storedBoxes[o]={...w,confidence:A};let I={landmarks:v,confidence:A,box:{topLeft:w.startPoint,bottomRight:w.endPoint}};a.push(I)}else this.storedBoxes[o]=null;y.dispose()}else{let l=f0(m0(i),H$),u={confidence:i.confidence,box:{topLeft:l.startPoint,bottomRight:l.endPoint}};a.push(u)}}return this.storedBoxes=this.storedBoxes.filter(o=>o!==null),this.detectedHands=a.length,a}};var j$={thumb:[1,2,3,4],indexFinger:[5,6,7,8],middleFinger:[9,10,11,12],ringFinger:[13,14,15,16],pinky:[17,18,19,20],palmBase:[0]},so,ao,q$;async function Kb(e,t){let n=await q$.estimateHands(e,t);if(!n)return[];let r=[];for(let s=0;s<n.length;s++){let a={};if(n[s].landmarks)for(let u of Object.keys(j$))a[u]=j$[u].map(c=>n[s].landmarks[c]);let o=n[s].landmarks,i=[Number.MAX_SAFE_INTEGER,Number.MAX_SAFE_INTEGER,0,0],l=[0,0,0,0];if(o&&o.length>0){for(let u of o)u[0]<i[0]&&(i[0]=u[0]),u[1]<i[1]&&(i[1]=u[1]),u[0]>i[2]&&(i[2]=u[0]),u[1]>i[3]&&(i[3]=u[1]);i[2]-=i[0],i[3]-=i[1],l=[i[0]/(e.shape[2]||0),i[1]/(e.shape[1]||0),i[2]/(e.shape[2]||0),i[3]/(e.shape[1]||0)]}else i=n[s].box?[Math.trunc(Math.max(0,n[s].box.topLeft[0])),Math.trunc(Math.max(0,n[s].box.topLeft[1])),Math.trunc(Math.min(e.shape[2]||0,n[s].box.bottomRight[0])-Math.max(0,n[s].box.topLeft[0])),Math.trunc(Math.min(e.shape[1]||0,n[s].box.bottomRight[1])-Math.max(0,n[s].box.topLeft[1]))]:[0,0,0,0],l=[n[s].box.topLeft[0]/(e.shape[2]||0),n[s].box.topLeft[1]/(e.shape[1]||0),(n[s].box.bottomRight[0]-n[s].box.topLeft[0])/(e.shape[2]||0),(n[s].box.bottomRight[1]-n[s].box.topLeft[1])/(e.shape[1]||0)];r.push({id:s,score:Math.round(100*n[s].confidence)/100,box:i,boxRaw:l,keypoints:o,annotations:a})}return r}async function Xb(e){!so||!ao?([so,ao]=await Promise.all([e.hand.enabled?Et($t(e.modelBasePath,e.hand.detector.modelPath),{fromTFHub:e.hand.detector.modelPath.includes("tfhub.dev")}):null,e.hand.landmarks?Et($t(e.modelBasePath,e.hand.skeleton.modelPath),{fromTFHub:e.hand.skeleton.modelPath.includes("tfhub.dev")}):null]),e.hand.enabled&&(!so||!so.modelUrl?me("load model failed:",e.hand.detector.modelPath):e.debug&&me("load model:",so.modelUrl),!ao||!ao.modelUrl?me("load model failed:",e.hand.skeleton.modelPath):e.debug&&me("load model:",ao.modelUrl))):(e.debug&&me("cached model:",so.modelUrl),e.debug&&me("cached model:",ao.modelUrl));let t=new Hb(so);return q$=new qb(t,ao),[so,ao]}var K$=["nose","leftEyeInside","leftEye","leftEyeOutside","rightEyeInside","rightEye","rightEyeOutside","leftEar","rightEar","leftMouth","rightMouth","leftShoulder","rightShoulder","leftElbow","rightElbow","leftWrist","rightWrist","leftPalm","rightPalm","leftIndex","rightIndex","leftPinky","rightPinky","leftHip","rightHip","leftKnee","rightKnee","leftAnkle","rightAnkle","leftHeel","rightHeel","leftFoot","rightFoot","midHip","forehead","leftThumb","leftHand","rightThumb","rightHand"],X$=["nose","leftEyeInside","leftEye","leftEyeOutside","rightEyeInside","rightEye","rightEyeOutside","leftEar","rightEar","leftMouth","rightMouth","leftShoulder","rightShoulder","leftElbow","rightElbow","left:15","right:16","left:17","right:18","left:19","right:20","left:21","right:22","leftChest","rightChest","neck","forehead","left:27","right:28","left:29","right:30"];var nr;async function g0(e){return nr?e.debug&&me("cached model:",nr.modelUrl):(nr=await Et($t(e.modelBasePath,e.body.modelPath)),nr.width=parseInt(nr.signature.inputs["input_1:0"].tensorShape.dim[2].size),nr.height=parseInt(nr.signature.inputs["input_1:0"].tensorShape.dim[1].size),!nr||!nr.modelUrl?me("load model failed:",e.body.modelPath):e.debug&&me("load model:",nr.modelUrl)),nr}async function Zb(e,t){var m;if(!nr)return[];if(!t.body.enabled)return[];let n={width:e.shape[2]||0,height:e.shape[1]||0},r=Ye.resizeBilinear(e,[nr.width,nr.height],!1),s=Qe(r,[255]);r.dispose();let a=await nr.predict(s),o=((m=a.find(g=>g.size===195||g.size===155))==null?void 0:m.dataSync())||[];a.forEach(g=>g.dispose()),s.dispose();let i=[],l=(o==null?void 0:o.length)===195?K$:X$,u=5;for(let g=0;g<o.length/u;g++)i.push({id:g,part:l[g],position:[Math.trunc(n.width*o[u*g+0]/255),Math.trunc(n.height*o[u*g+1]/255),Math.trunc(o[u*g+2])+0],positionRaw:[o[u*g+0]/255,o[u*g+1]/255,o[u*g+2]+0],score:(100-Math.trunc(100/(1+Math.exp(o[u*g+3]))))/100,presence:(100-Math.trunc(100/(1+Math.exp(o[u*g+4]))))/100});let c=i.map(g=>g.position[0]),d=i.map(g=>g.position[1]),h=[Math.min(...c),Math.min(...d),Math.max(...c)-Math.min(...c),Math.max(...d)-Math.min(...c)],p=[0,0,0,0],f=i.reduce((g,y)=>y.score>g?y.score:g,0);return[{id:0,score:f,box:h,boxRaw:p,keypoints:i}]}var rr,Ws=[],Yb=[0,0,0,0],Jb=[0,0,0,0],y0=0,Qb=Number.MAX_SAFE_INTEGER,ewe=["head","neck","rightShoulder","rightElbow","rightWrist","chest","leftShoulder","leftElbow","leftWrist","pelvis","rightHip","rightKnee","rightAnkle","leftHip","leftKnee","leftAnkle"];async function Z$(e){return rr?e.debug&&me("cached model:",rr.modelUrl):(rr=await Et($t(e.modelBasePath,e.body.modelPath)),!rr||!rr.modelUrl?me("load model failed:",e.body.modelPath):e.debug&&me("load model:",rr.modelUrl)),rr}function twe(e,t){let[n,r]=e.shape;return Ue(()=>{let s=(i,l)=>He(i,fe(Qe(i,ut(l,"int32")),ut(l,"int32"))),a=ue(e,[r*n]),o=_a(a,0).dataSync()[0];if(o>t){let i=Z2(a,0),l=s(i,n).dataSync()[0],u=Qe(i,ut(n,"int32")).dataSync()[0];return[l,u,o]}return[0,0,o]})}async function e3(e,t){return Qb<t.body.skipFrames&&t.skipFrame&&Object.keys(Ws).length>0?(Qb++,[{id:0,score:y0,box:Yb,boxRaw:Jb,keypoints:Ws}]):(Qb=0,new Promise(async n=>{let r=Ue(()=>{if(!rr.inputs[0].shape)return null;let u=Ye.resizeBilinear(e,[rr.inputs[0].shape[2],rr.inputs[0].shape[1]],!1);return fe(u,2).sub(1)}),s;if(t.body.enabled&&(s=await rr.predict(r)),r.dispose(),s){Ws.length=0;let u=s.squeeze();Ve(s);let c=u.unstack(2);Ve(u);for(let d=0;d<c.length;d++){let[h,p,f]=twe(c[d],t.body.minConfidence);y0>t.body.minConfidence&&Ws.push({score:Math.round(100*f)/100,part:ewe[d],positionRaw:[h/rr.inputs[0].shape[2],p/rr.inputs[0].shape[1]],position:[Math.round(e.shape[2]*h/rr.inputs[0].shape[2]),Math.round(e.shape[1]*p/rr.inputs[0].shape[1])]})}c.forEach(d=>Ve(d))}y0=Ws.reduce((u,c)=>c.score>u?c.score:u,0);let a=Ws.map(u=>u.position[0]),o=Ws.map(u=>u.position[1]);Yb=[Math.min(...a),Math.min(...o),Math.max(...a)-Math.min(...a),Math.max(...o)-Math.min(...o)];let i=Ws.map(u=>u.positionRaw[0]),l=Ws.map(u=>u.positionRaw[1]);Jb=[Math.min(...i),Math.min(...l),Math.max(...i)-Math.min(...i),Math.max(...l)-Math.min(...l)],n([{id:0,score:y0,box:Yb,boxRaw:Jb,keypoints:Ws}])}))}var vs,Vs=[],t3=[0,0,0,0],n3=[0,0,0,0],_u=0,r3=Number.MAX_SAFE_INTEGER,nwe=["nose","leftEye","rightEye","leftEar","rightEar","leftShoulder","rightShoulder","leftElbow","rightElbow","leftWrist","rightWrist","leftHip","rightHip","leftKnee","rightKnee","leftAnkle","rightAnkle"];async function s3(e){return vs?e.debug&&me("cached model:",vs.modelUrl):(vs=await Et($t(e.modelBasePath,e.body.modelPath)),!vs||!vs.modelUrl?me("load model failed:",e.body.modelPath):e.debug&&me("load model:",vs.modelUrl)),vs}async function a3(e,t){return r3<t.body.skipFrames&&t.skipFrame&&Object.keys(Vs).length>0?(r3++,[{id:0,score:_u,box:t3,boxRaw:n3,keypoints:Vs}]):(r3=0,new Promise(async n=>{let r=Ue(()=>{if(!vs.inputs[0].shape)return null;let u=Ye.resizeBilinear(e,[vs.inputs[0].shape[2],vs.inputs[0].shape[1]],!1);return Pt(u,"int32")}),s;if(t.body.enabled&&(s=await vs.predict(r)),r.dispose(),s){Vs.length=0;let u=s.arraySync();Ve(s);let c=u[0][0];for(let d=0;d<c.length;d++)_u=c[d][2],_u>t.body.minConfidence&&Vs.push({score:Math.round(100*_u)/100,part:nwe[d],positionRaw:[c[d][1],c[d][0]],position:[Math.round((e.shape[2]||0)*c[d][1]),Math.round((e.shape[1]||0)*c[d][0])]})}_u=Vs.reduce((u,c)=>c.score>u?c.score:u,0);let a=Vs.map(u=>u.position[0]),o=Vs.map(u=>u.position[1]);t3=[Math.min(...a),Math.min(...o),Math.max(...a)-Math.min(...a),Math.max(...o)-Math.min(...o)];let i=Vs.map(u=>u.positionRaw[0]),l=Vs.map(u=>u.positionRaw[1]);n3=[Math.min(...i),Math.min(...l),Math.max(...i)-Math.min(...i),Math.max(...l)-Math.min(...l)],n([{id:0,score:_u,box:t3,boxRaw:n3,keypoints:Vs}])}))}var Ru=[{class:1,label:"person"},{class:2,label:"bicycle"},{class:3,label:"car"},{class:4,label:"motorcycle"},{class:5,label:"airplane"},{class:6,label:"bus"},{class:7,label:"train"},{class:8,label:"truck"},{class:9,label:"boat"},{class:10,label:"traffic light"},{class:11,label:"fire hydrant"},{class:12,label:"stop sign"},{class:13,label:"parking meter"},{class:14,label:"bench"},{class:15,label:"bird"},{class:16,label:"cat"},{class:17,label:"dog"},{class:18,label:"horse"},{class:19,label:"sheep"},{class:20,label:"cow"},{class:21,label:"elephant"},{class:22,label:"bear"},{class:23,label:"zebra"},{class:24,label:"giraffe"},{class:25,label:"backpack"},{class:26,label:"umbrella"},{class:27,label:"handbag"},{class:28,label:"tie"},{class:29,label:"suitcase"},{class:30,label:"frisbee"},{class:31,label:"skis"},{class:32,label:"snowboard"},{class:33,label:"sports ball"},{class:34,label:"kite"},{class:35,label:"baseball bat"},{class:36,label:"baseball glove"},{class:37,label:"skateboard"},{class:38,label:"surfboard"},{class:39,label:"tennis racket"},{class:40,label:"bottle"},{class:41,label:"wine glass"},{class:42,label:"cup"},{class:43,label:"fork"},{class:44,label:"knife"},{class:45,label:"spoon"},{class:46,label:"bowl"},{class:47,label:"banana"},{class:48,label:"apple"},{class:49,label:"sandwich"},{class:50,label:"orange"},{class:51,label:"broccoli"},{class:52,label:"carrot"},{class:53,label:"hot dog"},{class:54,label:"pizza"},{class:55,label:"donut"},{class:56,label:"cake"},{class:57,label:"chair"},{class:58,label:"couch"},{class:59,label:"potted plant"},{class:60,label:"bed"},{class:61,label:"dining table"},{class:62,label:"toilet"},{class:63,label:"tv"},{class:64,label:"laptop"},{class:65,label:"mouse"},{class:66,label:"remote"},{class:67,label:"keyboard"},{class:68,label:"cell phone"},{class:69,label:"microwave"},{class:70,label:"oven"},{class:71,label:"toaster"},{class:72,label:"sink"},{class:73,label:"refrigerator"},{class:74,label:"book"},{class:75,label:"clock"},{class:76,label:"vase"},{class:77,label:"scissors"},{class:78,label:"teddy bear"},{class:79,label:"hair drier"},{class:80,label:"toothbrush"}];var Ar,o3=[],i3=Number.MAX_SAFE_INTEGER,A0=2.5;async function l3(e){if(Ar)e.debug&&me("cached model:",Ar.modelUrl);else{Ar=await Et($t(e.modelBasePath,e.object.modelPath));let t=Object.values(Ar.modelSignature.inputs);if(Ar.inputSize=Array.isArray(t)?parseInt(t[0].tensorShape.dim[2].size):null,!Ar.inputSize)throw new Error(`Human: Cannot determine model inputSize: ${e.object.modelPath}`);!Ar||!Ar.modelUrl?me("load model failed:",e.object.modelPath):e.debug&&me("load model:",Ar.modelUrl)}return Ar}async function rwe(e,t,n,r){let s=0,a=[];for(let u of[1,2,4])Ue(()=>{var g,y;let c=u*13,d=(g=e.find(A=>A.shape[1]===c**2&&A.shape[2]===Ru.length))==null?void 0:g.squeeze(),h=(y=e.find(A=>A.shape[1]===c**2&&A.shape[2]<Ru.length))==null?void 0:y.squeeze(),f=h.reshape([-1,4,h.shape[1]/4]).argMax(2).arraySync(),m=d.arraySync();for(let A=0;A<d.shape[0];A++)for(let x=0;x<d.shape[1];x++){let b=m[A][x];if(b>r.object.minConfidence&&x!==61){let v=(.5+Math.trunc(A%c))/c,w=(.5+Math.trunc(A/c))/c,I=f[A].map(B=>B*(c/u/t)),[T,C]=[v-A0/u*I[0],w-A0/u*I[1]],[M,$]=[v+A0/u*I[2]-T,w+A0/u*I[3]-C],R=[T,C,M,$];R=R.map(B=>Math.max(0,Math.min(B,1)));let N=[R[0]*n[0],R[1]*n[1],R[2]*n[0],R[3]*n[1]],F={id:s++,score:Math.round(100*b)/100,class:x+1,label:Ru[x].label,box:N.map(B=>Math.trunc(B)),boxRaw:R};a.push(F)}}});e.forEach(u=>Ve(u));let o=a.map(u=>[u.boxRaw[1],u.boxRaw[0],u.boxRaw[3],u.boxRaw[2]]),i=a.map(u=>u.score),l=[];if(o&&o.length>0){let u=await Ye.nonMaxSuppressionAsync(o,i,r.object.maxDetected,r.object.iouThreshold,r.object.minConfidence);l=u.dataSync(),Ve(u)}return a=a.filter((u,c)=>l.includes(c)).sort((u,c)=>c.score-u.score),a}async function u3(e,t){return i3<t.object.skipFrames&&t.skipFrame&&o3.length>0?(i3++,o3):(i3=0,new Promise(async n=>{let r=[e.shape[2],e.shape[1]],s=Ye.resizeBilinear(e,[Ar.inputSize,Ar.inputSize],!1),a=s.div(255),o=a.transpose([0,3,1,2]);a.dispose(),s.dispose();let i;t.object.enabled&&(i=await Ar.predict(o)),o.dispose();let l=await rwe(i,Ar.inputSize,r,t);o3=l,n(l)}))}var xr,c3=[],d3=Number.MAX_SAFE_INTEGER;async function h3(e){if(xr)e.debug&&me("cached model:",xr.modelUrl);else{xr=await Et($t(e.modelBasePath,e.object.modelPath));let t=Object.values(xr.modelSignature.inputs);if(xr.inputSize=Array.isArray(t)?parseInt(t[0].tensorShape.dim[2].size):null,!xr.inputSize)throw new Error(`Human: Cannot determine model inputSize: ${e.object.modelPath}`);!xr||!xr.modelUrl?me("load model failed:",e.object.modelPath):e.debug&&me("load model:",xr.modelUrl)}return xr}async function swe(e,t,n,r){if(!e)return[];let s=[],a=e.arraySync(),o=Zn(e);e.dispose();let i=ta(o,6,1);o.dispose();let u=So([i[1],i[0],i[3],i[2]],1).squeeze(),c=i[4].squeeze(),d=i[5].squeeze();i.forEach(m=>m.dispose());let h=await Ye.nonMaxSuppressionAsync(u,c,r.object.maxDetected,r.object.iouThreshold,r.object.minConfidence);u.dispose(),c.dispose(),d.dispose();let p=h.dataSync();h.dispose();let f=0;for(let m of p){let g=Math.trunc(100*a[0][m][4])/100,y=a[0][m][5],A=Ru[y].label,x=[a[0][m][0]/t,a[0][m][1]/t,a[0][m][2]/t,a[0][m][3]/t],b=[Math.trunc(x[0]*n[0]),Math.trunc(x[1]*n[1]),Math.trunc(x[2]*n[0]),Math.trunc(x[3]*n[1])];s.push({id:f++,score:g,class:y,label:A,box:b,boxRaw:x})}return s}async function p3(e,t){return d3<t.object.skipFrames&&t.skipFrame&&c3.length>0?(d3++,c3):(d3=0,new Promise(async n=>{let r=[e.shape[2],e.shape[1]],s=Ye.resizeBilinear(e,[xr.inputSize,xr.inputSize]),a=t.object.enabled?xr.execute(s,["tower_0/detections"]):null;s.dispose();let o=await swe(a,xr.inputSize,r,t);c3=o,n(o)}))}var Y$=e=>{if(!e)return[];let t=[];for(let n=0;n<e.length;n++){let r=e[n].keypoints.find(l=>l.part==="leftWrist"),s=e[n].keypoints.find(l=>l.part==="rightWrist"),a=e[n].keypoints.find(l=>l.part==="nose");a&&r&&s&&r.position.y<a.position.y&&s.position.y<a.position.y?t.push({body:n,gesture:"i give up"}):a&&r&&r.position.y<a.position.y?t.push({body:n,gesture:"raise left hand"}):a&&s&&s.position.y<a.position.y&&t.push({body:n,gesture:"raise right hand"});let o=e[n].keypoints.find(l=>l.part==="leftShoulder"),i=e[n].keypoints.find(l=>l.part==="rightShoulder");o&&i&&t.push({body:n,gesture:`leaning ${o.position.y>i.position.y?"left":"right"}`})}return t},J$=e=>{if(!e)return[];let t=[];for(let n=0;n<e.length;n++)if(e[n].mesh&&e[n].mesh.length>0){let r=e[n].mesh[33][2]-e[n].mesh[263][2];Math.abs(r)<10?t.push({face:n,gesture:"facing center"}):t.push({face:n,gesture:`facing ${r<0?"left":"right"}`}),Math.abs(e[n].mesh[374][1]-e[n].mesh[386][1])/Math.abs(e[n].mesh[443][1]-e[n].mesh[450][1])<.2&&t.push({face:n,gesture:"blink left eye"}),Math.abs(e[n].mesh[145][1]-e[n].mesh[159][1])/Math.abs(e[n].mesh[223][1]-e[n].mesh[230][1])<.2&&t.push({face:n,gesture:"blink right eye"});let o=Math.min(100,500*Math.abs(e[n].mesh[13][1]-e[n].mesh[14][1])/Math.abs(e[n].mesh[10][1]-e[n].mesh[152][1]));o>10&&t.push({face:n,gesture:`mouth ${Math.trunc(o)}% open`});let i=e[n].mesh[152][2];Math.abs(i)>10&&t.push({face:n,gesture:`head ${i<0?"up":"down"}`})}return t},Q$=e=>{if(!e)return[];let t=[];for(let n=0;n<e.length;n++){if(!e[n].annotations||!e[n].annotations.leftEyeIris||!e[n].annotations.rightEyeIris)continue;let r=e[n].annotations.leftEyeIris[3][0]-e[n].annotations.leftEyeIris[1][0],s=e[n].annotations.leftEyeIris[4][1]-e[n].annotations.leftEyeIris[2][1],a=Math.abs(r*s),o=e[n].annotations.rightEyeIris[3][0]-e[n].annotations.rightEyeIris[1][0],i=e[n].annotations.rightEyeIris[4][1]-e[n].annotations.rightEyeIris[2][1],l=Math.abs(o*i),u=!1;Math.abs(a-l)/Math.max(a,l)<.25&&(u=!0,t.push({iris:n,gesture:"facing center"}));let d=Math.abs(e[n].mesh[33][0]-e[n].annotations.rightEyeIris[0][0])/e[n].box[2],h=Math.abs(e[n].mesh[263][0]-e[n].annotations.leftEyeIris[0][0])/e[n].box[2];(h>.06||d>.06)&&(u=!1),h>.06&&t.push({iris:n,gesture:"looking right"}),d>.06&&t.push({iris:n,gesture:"looking left"});let p=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||p<.01||f>.022||p>.022)&&(u=!1),(f<.01||p<.01)&&t.push({iris:n,gesture:"looking down"}),(f>.022||p>.022)&&t.push({iris:n,gesture:"looking up"}),u&&t.push({iris:n,gesture:"looking center"})}return t},e_=e=>{if(!e)return[];let t=[];for(let n=0;n<e.length;n++){let r=[];for(let[s,a]of Object.entries(e[n].annotations))s!=="palmBase"&&Array.isArray(a)&&r.push({name:s.toLowerCase(),position:a[0]});if(r&&r.length>0){let s=r.reduce((o,i)=>o.position[2]<i.position[2]?o:i),a=r.reduce((o,i)=>o.position[1]<i.position[1]?o:i);t.push({hand:n,gesture:`${s.name} forward ${a.name} up`})}}return t};function awe(e,t,n){let r=function(i,l,u){let c=new RegExp("\\b"+l+" \\w+ (\\w+)","ig");i.replace(c,(d,h)=>(u[h]=0,d))},s=function(i,l){let u=e.createShader(l);if(e.shaderSource(u,i),e.compileShader(u),!e.getShaderParameter(u,e.COMPILE_STATUS))throw new Error("Filter: GL compile failed",e.getShaderInfoLog(u));return u};this.uniform={},this.attribute={};let a=s(t,e.VERTEX_SHADER),o=s(n,e.FRAGMENT_SHADER);if(this.id=e.createProgram(),e.attachShader(this.id,a),e.attachShader(this.id,o),e.linkProgram(this.id),!e.getProgramParameter(this.id,e.LINK_STATUS))throw new Error("Filter: GL link failed",e.getProgramInfoLog(this.id));e.useProgram(this.id),r(t,"attribute",this.attribute);for(let i in this.attribute)this.attribute[i]=e.getAttribLocation(this.id,i);r(t,"uniform",this.uniform),r(n,"uniform",this.uniform);for(let i in this.uniform)this.uniform[i]=e.getUniformLocation(this.id,i)}function t_(e){e||(e={});let t=0,n=null,r=!1,s=-1,a=[null,null],o=[],i=-1,l=-1,u=null,c=null,d={},h=e.canvas||document.createElement("canvas"),p={},f={INTERMEDIATE:1},m=h.getContext("webgl");if(!m)throw new Error("Filter: getContext() failed");this.addFilter=function(v){let w=Array.prototype.slice.call(arguments,1),I=d[v];o.push({func:I,args:w})},this.reset=function(){o=[]};let g=function(v,w){if(!(v===i&&w===l)){if(h.width=v,i=v,h.height=w,l=w,!u){let I=new Float32Array([-1,-1,0,1,1,-1,1,1,-1,1,0,0,-1,1,0,0,1,-1,1,1,1,1,1,0]);u=m.createBuffer(),m.bindBuffer(m.ARRAY_BUFFER,u),m.bufferData(m.ARRAY_BUFFER,I,m.STATIC_DRAW),m.pixelStorei(m.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!0)}m.viewport(0,0,i,l),a=[null,null]}},y=function(v,w){let I=m.createFramebuffer();m.bindFramebuffer(m.FRAMEBUFFER,I);let T=m.createRenderbuffer();m.bindRenderbuffer(m.RENDERBUFFER,T);let C=m.createTexture();return m.bindTexture(m.TEXTURE_2D,C),m.texImage2D(m.TEXTURE_2D,0,m.RGBA,v,w,0,m.RGBA,m.UNSIGNED_BYTE,null),m.texParameteri(m.TEXTURE_2D,m.TEXTURE_MAG_FILTER,m.LINEAR),m.texParameteri(m.TEXTURE_2D,m.TEXTURE_MIN_FILTER,m.LINEAR),m.texParameteri(m.TEXTURE_2D,m.TEXTURE_WRAP_S,m.CLAMP_TO_EDGE),m.texParameteri(m.TEXTURE_2D,m.TEXTURE_WRAP_T,m.CLAMP_TO_EDGE),m.framebufferTexture2D(m.FRAMEBUFFER,m.COLOR_ATTACHMENT0,m.TEXTURE_2D,C,0),m.bindTexture(m.TEXTURE_2D,null),m.bindFramebuffer(m.FRAMEBUFFER,null),{fbo:I,texture:C}},A=function(v){return a[v]=a[v]||y(i,l),a[v]},x=function(v=null){var C,M;let w=null,I=null,T=!1;t===0?w=n:w=(C=A(s))==null?void 0:C.texture,t++,r&&!(v&f.INTERMEDIATE)?(I=null,T=t%2==0):(s=(s+1)%2,I=(M=A(s))==null?void 0:M.fbo),m.bindTexture(m.TEXTURE_2D,w),m.bindFramebuffer(m.FRAMEBUFFER,I),m.uniform1f(c.uniform.flipY,T?-1:1),m.drawArrays(m.TRIANGLES,0,6)};this.apply=function(v){if(g(v.width,v.height),t=0,n||(n=m.createTexture()),m.bindTexture(m.TEXTURE_2D,n),m.texParameteri(m.TEXTURE_2D,m.TEXTURE_WRAP_S,m.CLAMP_TO_EDGE),m.texParameteri(m.TEXTURE_2D,m.TEXTURE_WRAP_T,m.CLAMP_TO_EDGE),m.texParameteri(m.TEXTURE_2D,m.TEXTURE_MIN_FILTER,m.NEAREST),m.texParameteri(m.TEXTURE_2D,m.TEXTURE_MAG_FILTER,m.NEAREST),m.texImage2D(m.TEXTURE_2D,0,m.RGBA,m.RGBA,m.UNSIGNED_BYTE,v),o.length===0)return x(),h;for(let w=0;w<o.length;w++){r=w===o.length-1;let I=o[w];I.func.apply(this,I.args||[])}return h};let b=function(v){if(p[v])return c=p[v],m.useProgram(c.id),c;let w={};w.VERTEX_IDENTITY=["precision highp float;","attribute vec2 pos;","attribute vec2 uv;","varying vec2 vUv;","uniform float flipY;","void main(void) {","vUv = uv;","gl_Position = vec4(pos.x, pos.y*flipY, 0.0, 1.);","}"].join(`
|
|
`),w.FRAGMENT_IDENTITY=["precision highp float;","varying vec2 vUv;","uniform sampler2D texture;","void main(void) {","gl_FragColor = texture2D(texture, vUv);","}"].join(`
|
|
`),c=new awe(m,w.VERTEX_IDENTITY,v);let I=Float32Array.BYTES_PER_ELEMENT,T=4*I;return m.enableVertexAttribArray(c.attribute.pos),m.vertexAttribPointer(c.attribute.pos,2,m.FLOAT,!1,T,0*I),m.enableVertexAttribArray(c.attribute.uv),m.vertexAttribPointer(c.attribute.uv,2,m.FLOAT,!1,T,2*I),p[v]=c,c};d.colorMatrix=function(v){let w=new Float32Array(v);w[4]/=255,w[9]/=255,w[14]/=255,w[19]/=255;let I=w[18]===1&&w[3]===0&&w[8]===0&&w[13]===0&&w[15]===0&&w[16]===0&&w[17]===0&&w[19]===0?d.colorMatrix.SHADER.WITHOUT_ALPHA:d.colorMatrix.SHADER.WITH_ALPHA,T=b(I);m.uniform1fv(T.uniform.m,w),x()},d.colorMatrix.SHADER={},d.colorMatrix.SHADER.WITH_ALPHA=["precision highp float;","varying vec2 vUv;","uniform sampler2D texture;","uniform float m[20];","void main(void) {","vec4 c = texture2D(texture, vUv);","gl_FragColor.r = m[0] * c.r + m[1] * c.g + m[2] * c.b + m[3] * c.a + m[4];","gl_FragColor.g = m[5] * c.r + m[6] * c.g + m[7] * c.b + m[8] * c.a + m[9];","gl_FragColor.b = m[10] * c.r + m[11] * c.g + m[12] * c.b + m[13] * c.a + m[14];","gl_FragColor.a = m[15] * c.r + m[16] * c.g + m[17] * c.b + m[18] * c.a + m[19];","}"].join(`
|
|
`),d.colorMatrix.SHADER.WITHOUT_ALPHA=["precision highp float;","varying vec2 vUv;","uniform sampler2D texture;","uniform float m[20];","void main(void) {","vec4 c = texture2D(texture, vUv);","gl_FragColor.r = m[0] * c.r + m[1] * c.g + m[2] * c.b + m[4];","gl_FragColor.g = m[5] * c.r + m[6] * c.g + m[7] * c.b + m[9];","gl_FragColor.b = m[10] * c.r + m[11] * c.g + m[12] * c.b + m[14];","gl_FragColor.a = c.a;","}"].join(`
|
|
`),d.brightness=function(v){let w=(v||0)+1;d.colorMatrix([w,0,0,0,0,0,w,0,0,0,0,0,w,0,0,0,0,0,1,0])},d.saturation=function(v){let w=(v||0)*2/3+1,I=(w-1)*-.5;d.colorMatrix([w,I,I,0,0,I,w,I,0,0,I,I,w,0,0,0,0,0,1,0])},d.desaturate=function(){d.saturation(-1)},d.contrast=function(v){let w=(v||0)+1,I=-128*(w-1);d.colorMatrix([w,0,0,0,I,0,w,0,0,I,0,0,w,0,I,0,0,0,1,0])},d.negative=function(){d.contrast(-2)},d.hue=function(v){v=(v||0)/180*Math.PI;let w=Math.cos(v),I=Math.sin(v),T=.213,C=.715,M=.072;d.colorMatrix([T+w*(1-T)+I*-T,C+w*-C+I*-C,M+w*-M+I*(1-M),0,0,T+w*-T+I*.143,C+w*(1-C)+I*.14,M+w*-M+I*-.283,0,0,T+w*-T+I*-(1-T),C+w*-C+I*C,M+w*(1-M)+I*M,0,0,0,0,0,1,0])},d.desaturateLuminance=function(){d.colorMatrix([.2764723,.929708,.0938197,0,-37.1,.2764723,.929708,.0938197,0,-37.1,.2764723,.929708,.0938197,0,-37.1,0,0,0,1,0])},d.sepia=function(){d.colorMatrix([.393,.7689999,.18899999,0,0,.349,.6859999,.16799999,0,0,.272,.5339999,.13099999,0,0,0,0,0,1,0])},d.brownie=function(){d.colorMatrix([.5997023498159715,.34553243048391263,-.2708298674538042,0,47.43192855600873,-.037703249837783157,.8609577587992641,.15059552388459913,0,-36.96841498319127,.24113635128153335,-.07441037908422492,.44972182064877153,0,-7.562075277591283,0,0,0,1,0])},d.vintagePinhole=function(){d.colorMatrix([.6279345635605994,.3202183420819367,-.03965408211312453,0,9.651285835294123,.02578397704808868,.6441188644374771,.03259127616149294,0,7.462829176470591,.0466055556782719,-.0851232987247891,.5241648018700465,0,5.159190588235296,0,0,0,1,0])},d.kodachrome=function(){d.colorMatrix([1.1285582396593525,-.3967382283601348,-.03992559172921793,0,63.72958762196502,-.16404339962244616,1.0835251566291304,-.05498805115633132,0,24.732407896706203,-.16786010706155763,-.5603416277695248,1.6014850761964943,0,35.62982807460946,0,0,0,1,0])},d.technicolor=function(){d.colorMatrix([1.9125277891456083,-.8545344976951645,-.09155508482755585,0,11.793603434377337,-.3087833385928097,1.7658908555458428,-.10601743074722245,0,-70.35205161461398,-.231103377548616,-.7501899197440212,1.847597816108189,0,30.950940869491138,0,0,0,1,0])},d.polaroid=function(){d.colorMatrix([1.438,-.062,-.062,0,0,-.122,1.378,-.122,0,0,-.016,-.016,1.483,0,0,0,0,0,1,0])},d.shiftToBGR=function(){d.colorMatrix([0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,1,0])},d.convolution=function(v){let w=new Float32Array(v),I=1/i,T=1/l,C=b(d.convolution.SHADER);m.uniform1fv(C.uniform.m,w),m.uniform2f(C.uniform.px,I,T),x()},d.convolution.SHADER=["precision highp float;","varying vec2 vUv;","uniform sampler2D texture;","uniform vec2 px;","uniform float m[9];","void main(void) {","vec4 c11 = texture2D(texture, vUv - px);","vec4 c12 = texture2D(texture, vec2(vUv.x, vUv.y - px.y));","vec4 c13 = texture2D(texture, vec2(vUv.x + px.x, vUv.y - px.y));","vec4 c21 = texture2D(texture, vec2(vUv.x - px.x, vUv.y) );","vec4 c22 = texture2D(texture, vUv);","vec4 c23 = texture2D(texture, vec2(vUv.x + px.x, vUv.y) );","vec4 c31 = texture2D(texture, vec2(vUv.x - px.x, vUv.y + px.y) );","vec4 c32 = texture2D(texture, vec2(vUv.x, vUv.y + px.y) );","vec4 c33 = texture2D(texture, vUv + px );","gl_FragColor = ","c11 * m[0] + c12 * m[1] + c22 * m[2] +","c21 * m[3] + c22 * m[4] + c23 * m[5] +","c31 * m[6] + c32 * m[7] + c33 * m[8];","gl_FragColor.a = c22.a;","}"].join(`
|
|
`),d.detectEdges=function(){d.convolution.call(this,[0,1,0,1,-4,1,0,1,0])},d.sobelX=function(){d.convolution.call(this,[-1,0,1,-2,0,2,-1,0,1])},d.sobelY=function(){d.convolution.call(this,[-1,-2,-1,0,0,0,1,2,1])},d.sharpen=function(v){let w=v||1;d.convolution.call(this,[0,-1*w,0,-1*w,1+4*w,-1*w,0,-1*w,0])},d.emboss=function(v){let w=v||1;d.convolution.call(this,[-2*w,-1*w,0,-1*w,1,1*w,0,1*w,2*w])},d.blur=function(v){let w=v/7/i,I=v/7/l,T=b(d.blur.SHADER);m.uniform2f(T.uniform.px,0,I),x(f.INTERMEDIATE),m.uniform2f(T.uniform.px,w,0),x()},d.blur.SHADER=["precision highp float;","varying vec2 vUv;","uniform sampler2D texture;","uniform vec2 px;","void main(void) {","gl_FragColor = vec4(0.0);","gl_FragColor += texture2D(texture, vUv + vec2(-7.0*px.x, -7.0*px.y))*0.0044299121055113265;","gl_FragColor += texture2D(texture, vUv + vec2(-6.0*px.x, -6.0*px.y))*0.00895781211794;","gl_FragColor += texture2D(texture, vUv + vec2(-5.0*px.x, -5.0*px.y))*0.0215963866053;","gl_FragColor += texture2D(texture, vUv + vec2(-4.0*px.x, -4.0*px.y))*0.0443683338718;","gl_FragColor += texture2D(texture, vUv + vec2(-3.0*px.x, -3.0*px.y))*0.0776744219933;","gl_FragColor += texture2D(texture, vUv + vec2(-2.0*px.x, -2.0*px.y))*0.115876621105;","gl_FragColor += texture2D(texture, vUv + vec2(-1.0*px.x, -1.0*px.y))*0.147308056121;","gl_FragColor += texture2D(texture, vUv )*0.159576912161;","gl_FragColor += texture2D(texture, vUv + vec2( 1.0*px.x, 1.0*px.y))*0.147308056121;","gl_FragColor += texture2D(texture, vUv + vec2( 2.0*px.x, 2.0*px.y))*0.115876621105;","gl_FragColor += texture2D(texture, vUv + vec2( 3.0*px.x, 3.0*px.y))*0.0776744219933;","gl_FragColor += texture2D(texture, vUv + vec2( 4.0*px.x, 4.0*px.y))*0.0443683338718;","gl_FragColor += texture2D(texture, vUv + vec2( 5.0*px.x, 5.0*px.y))*0.0215963866053;","gl_FragColor += texture2D(texture, vUv + vec2( 6.0*px.x, 6.0*px.y))*0.00895781211794;","gl_FragColor += texture2D(texture, vUv + vec2( 7.0*px.x, 7.0*px.y))*0.0044299121055113265;","}"].join(`
|
|
`),d.pixelate=function(v){let w=v/i,I=v/l,T=b(d.pixelate.SHADER);m.uniform2f(T.uniform.size,w,I),x()},d.pixelate.SHADER=["precision highp float;","varying vec2 vUv;","uniform vec2 size;","uniform sampler2D texture;","vec2 pixelate(vec2 coord, vec2 size) {","return floor( coord / size ) * size;","}","void main(void) {","gl_FragColor = vec4(0.0);","vec2 coord = pixelate(vUv, size);","gl_FragColor += texture2D(texture, coord);","}"].join(`
|
|
`)}var x0=2048,Oe,Bt,rn;function wi(e,t){let n;if(!e)throw new Error("Human: Input is missing");if(!(e instanceof Tt)&&!(typeof Image!="undefined"&&e instanceof Image)&&!(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("Human: Input type is not recognized");if(e instanceof Tt)if(e.shape&&e.shape.length===4&&e.shape[0]===1&&e.shape[3]===3)n=Js(e);else throw new Error(`Human: Input tensor shape must be [1, height, width, 3] and instead was ${e.shape}`);else{let s=e.naturalWidth||e.videoWidth||e.width||e.shape&&e.shape[1]>0,a=e.naturalHeight||e.videoHeight||e.height||e.shape&&e.shape[2]>0;if(!s||!a)return{tensor:null,canvas:Oe};let o=s,i=a;if(o>x0&&(o=x0,i=o*a/s),i>x0&&(i=x0,o=i*s/a),t.filter.width>0?o=t.filter.width:t.filter.height>0&&(o=s*(t.filter.height/a)),t.filter.height>0?i=t.filter.height:t.filter.width>0&&(i=a*(t.filter.width/s)),!o||!i)throw new Error("Human: Input cannot determine dimension");(!Oe||(Oe==null?void 0:Oe.width)!==o||(Oe==null?void 0:Oe.height)!==i)&&(Oe=typeof OffscreenCanvas!="undefined"?new OffscreenCanvas(o,i):document.createElement("canvas"),(Oe==null?void 0:Oe.width)!==o&&(Oe.width=o),(Oe==null?void 0:Oe.height)!==i&&(Oe.height=i));let l=Oe.getContext("2d");if(e instanceof ImageData?l.putImageData(e,0,0):t.filter.flip&&typeof l.translate!="undefined"?(l.translate(s,0),l.scale(-1,1),l.drawImage(e,0,0,s,a,0,0,Oe==null?void 0:Oe.width,Oe==null?void 0:Oe.height),l.setTransform(1,0,0,1,0,0)):l.drawImage(e,0,0,s,a,0,0,Oe==null?void 0:Oe.width,Oe==null?void 0:Oe.height),t.filter.enabled){if((!rn||!Bt||Oe.width!==Bt.width||(Oe==null?void 0:Oe.height)!==(Bt==null?void 0:Bt.height))&&(Bt=typeof OffscreenCanvas!="undefined"?new OffscreenCanvas(Oe==null?void 0:Oe.width,Oe==null?void 0:Oe.height):document.createElement("canvas"),(Bt==null?void 0:Bt.width)!==(Oe==null?void 0:Oe.width)&&(Bt.width=Oe==null?void 0:Oe.width),(Bt==null?void 0:Bt.height)!==(Oe==null?void 0:Oe.height)&&(Bt.height=Oe==null?void 0:Oe.height),rn=Sr.flags.IS_BROWSER?new t_({canvas:Bt}):null),!rn)return{tensor:null,canvas:Oe};rn.reset(),rn.addFilter("brightness",t.filter.brightness),t.filter.contrast!==0&&rn.addFilter("contrast",t.filter.contrast),t.filter.sharpness!==0&&rn.addFilter("sharpen",t.filter.sharpness),t.filter.blur!==0&&rn.addFilter("blur",t.filter.blur),t.filter.saturation!==0&&rn.addFilter("saturation",t.filter.saturation),t.filter.hue!==0&&rn.addFilter("hue",t.filter.hue),t.filter.negative&&rn.addFilter("negative"),t.filter.sepia&&rn.addFilter("sepia"),t.filter.vintage&&rn.addFilter("brownie"),t.filter.sepia&&rn.addFilter("sepia"),t.filter.kodachrome&&rn.addFilter("kodachrome"),t.filter.technicolor&&rn.addFilter("technicolor"),t.filter.polaroid&&rn.addFilter("polaroid"),t.filter.pixelate!==0&&rn.addFilter("pixelate",t.filter.pixelate),rn.apply(Oe)}else Bt=Oe,rn&&(rn=null);let u;if(Bt.data){let c=[Bt.height,Bt.width,3];u=mp(Bt.data,c,"int32")}else if(Bt instanceof ImageData)u=Hr?Hr.fromPixels(Bt):null;else if(t.backend==="webgl"||t.backend==="humangl"){let c=typeof OffscreenCanvas!="undefined"?new OffscreenCanvas(o,i):document.createElement("canvas");c.width=o,c.height=i;let d=c.getContext("2d");d==null||d.drawImage(Bt,0,0),u=Hr?Hr.fromPixels(c):null}else{let c=typeof OffscreenCanvas!="undefined"?new OffscreenCanvas(o,i):document.createElement("canvas");c.width=o,c.height=i;let d=c.getContext("2d");d==null||d.drawImage(Bt,0,0);let h=d==null?void 0:d.getImageData(0,0,o,i);u=Hr?Hr.fromPixels(h):null}if(u){let c=u.toFloat();n=c.expandDims(0),u.dispose(),c.dispose()}}let r=t.filter.return?Bt:null;return{tensor:n,canvas:r}}var g3={};_3(g3,{all:()=>lwe,body:()=>s_,canvas:()=>iwe,face:()=>r_,gesture:()=>n_,hand:()=>a_,object:()=>o_,options:()=>oo,person:()=>owe});var oo={color:"rgba(173, 216, 230, 0.6)",labelColor:"rgba(173, 216, 230, 1)",shadowColor:"black",font:'small-caps 14px "Segoe UI"',lineHeight:24,lineWidth:6,pointSize:2,roundRect:28,drawPoints:!1,drawLabels:!0,drawBoxes:!0,drawPolygons:!0,drawGaze:!0,fillPolygons:!1,useDepth:!0,useCurves:!1,bufferedOutput:!0},b0=e=>Math.round(e*180/Math.PI);function f3(e,t,n,r=0,s){e.fillStyle=s.useDepth&&r?`rgba(${127.5+2*r}, ${127.5-2*r}, 255, 0.3)`:s.color,e.beginPath(),e.arc(t,n,s.pointSize,0,2*Math.PI),e.fill()}function Th(e,t,n,r,s,a){if(e.beginPath(),a.useCurves){let o=(t+t+r)/2,i=(n+n+s)/2;e.ellipse(o,i,r/2,s/2,0,0,2*Math.PI)}else e.lineWidth=a.lineWidth,e.moveTo(t+a.roundRect,n),e.lineTo(t+r-a.roundRect,n),e.quadraticCurveTo(t+r,n,t+r,n+a.roundRect),e.lineTo(t+r,n+s-a.roundRect),e.quadraticCurveTo(t+r,n+s,t+r-a.roundRect,n+s),e.lineTo(t+a.roundRect,n+s),e.quadraticCurveTo(t,n+s,t,n+s-a.roundRect),e.lineTo(t,n+a.roundRect),e.quadraticCurveTo(t,n,t+a.roundRect,n),e.closePath();e.stroke()}function m3(e,t=[],n){if(!(t===void 0||t.length===0)){e.beginPath(),e.moveTo(t[0][0],t[0][1]);for(let r of t){let s=r[2]||0;e.strokeStyle=n.useDepth&&s?`rgba(${127.5+2*s}, ${127.5-2*s}, 255, 0.3)`:n.color,e.fillStyle=n.useDepth&&s?`rgba(${127.5+2*s}, ${127.5-2*s}, 255, 0.3)`:n.color,e.lineTo(r[0],Math.round(r[1]))}e.stroke(),n.fillPolygons&&(e.closePath(),e.fill())}}function Nh(e,t=[],n){if(!(t===void 0||t.length===0)){if(!n.useCurves||t.length<=2){m3(e,t,n);return}e.moveTo(t[0][0],t[0][1]);for(let r=0;r<t.length-2;r++){let s=(t[r][0]+t[r+1][0])/2,a=(t[r][1]+t[r+1][1])/2;e.quadraticCurveTo(t[r][0],t[r][1],s,a)}e.quadraticCurveTo(t[t.length-2][0],t[t.length-2][1],t[t.length-1][0],t[t.length-1][1]),e.stroke(),n.fillPolygons&&(e.closePath(),e.fill())}}async function n_(e,t,n){let r=ir(oo,n);if(!t||!e||!(e instanceof HTMLCanvasElement))return;let s=e.getContext("2d");if(!s)return;s.font=r.font,s.fillStyle=r.color;let a=1;for(let o=0;o<t.length;o++){let i=[],l=[];if([i,l]=Object.entries(t[o]),l.length>1&&l[1].length>0){let u=i[1]>0?`#${i[1]}`:"",c=`${i[0]} ${u}: ${l[1]}`;r.shadowColor&&r.shadowColor!==""&&(s.fillStyle=r.shadowColor,s.fillText(c,8,2+a*r.lineHeight)),s.fillStyle=r.labelColor,s.fillText(c,6,0+a*r.lineHeight),a+=1}}}async function r_(e,t,n){var a,o,i,l;let r=ir(oo,n);if(!t||!e||!(e instanceof HTMLCanvasElement))return;let s=e.getContext("2d");if(!!s)for(let u of t){s.font=r.font,s.strokeStyle=r.color,s.fillStyle=r.color,r.drawBoxes&&Th(s,u.box[0],u.box[1],u.box[2],u.box[3],r);let c=[];if(c.push(`face: ${Math.trunc(100*u.score)}%`),u.genderScore&&c.push(`${u.gender||""} ${Math.trunc(100*u.genderScore)}%`),u.age&&c.push(`age: ${u.age||""}`),u.iris&&c.push(`distance: ${u.iris}`),u.emotion&&u.emotion.length>0){let d=u.emotion.map(h=>`${Math.trunc(100*h.score)}% ${h.emotion}`);d.length>3&&(d.length=3),c.push(d.join(" "))}u.rotation&&u.rotation.angle&&u.rotation.gaze&&(u.rotation.angle.roll&&c.push(`roll: ${b0(u.rotation.angle.roll)}\xB0 yaw:${b0(u.rotation.angle.yaw)}\xB0 pitch:${b0(u.rotation.angle.pitch)}\xB0`),u.rotation.gaze.bearing&&c.push(`gaze: ${b0(u.rotation.gaze.bearing)}\xB0`)),c.length===0&&c.push("face"),s.fillStyle=r.color;for(let d=c.length-1;d>=0;d--){let h=Math.max(u.box[0],0),p=d*r.lineHeight+u.box[1];r.shadowColor&&r.shadowColor!==""&&(s.fillStyle=r.shadowColor,s.fillText(c[d],h+5,p+16)),s.fillStyle=r.labelColor,s.fillText(c[d],h+4,p+15)}if(s.lineWidth=1,u.mesh&&u.mesh.length>0){if(r.drawPoints)for(let d of u.mesh)f3(s,d[0],d[1],d[2],r);if(r.drawPolygons){s.lineWidth=1;for(let d=0;d<vi.length/3;d++){let h=[vi[d*3+0],vi[d*3+1],vi[d*3+2]].map(p=>u.mesh[p]);m3(s,h,r)}if(u.annotations&&u.annotations.leftEyeIris){s.strokeStyle=r.useDepth?"rgba(255, 200, 255, 0.3)":r.color,s.beginPath();let d=Math.abs(u.annotations.leftEyeIris[3][0]-u.annotations.leftEyeIris[1][0])/2,h=Math.abs(u.annotations.leftEyeIris[4][1]-u.annotations.leftEyeIris[2][1])/2;s.ellipse(u.annotations.leftEyeIris[0][0],u.annotations.leftEyeIris[0][1],d,h,0,0,2*Math.PI),s.stroke(),r.fillPolygons&&(s.fillStyle=r.useDepth?"rgba(255, 255, 200, 0.3)":r.color,s.fill())}if(u.annotations&&u.annotations.rightEyeIris){s.strokeStyle=r.useDepth?"rgba(255, 200, 255, 0.3)":r.color,s.beginPath();let d=Math.abs(u.annotations.rightEyeIris[3][0]-u.annotations.rightEyeIris[1][0])/2,h=Math.abs(u.annotations.rightEyeIris[4][1]-u.annotations.rightEyeIris[2][1])/2;s.ellipse(u.annotations.rightEyeIris[0][0],u.annotations.rightEyeIris[0][1],d,h,0,0,2*Math.PI),s.stroke(),r.fillPolygons&&(s.fillStyle=r.useDepth?"rgba(255, 255, 200, 0.3)":r.color,s.fill())}if(r.drawGaze&&((o=(a=u.rotation)==null?void 0:a.gaze)==null?void 0:o.strength)&&((l=(i=u.rotation)==null?void 0:i.gaze)==null?void 0:l.bearing)&&u.annotations.leftEyeIris&&u.annotations.rightEyeIris&&u.annotations.leftEyeIris[0]&&u.annotations.rightEyeIris[0]){s.strokeStyle="pink",s.beginPath();let d=[u.annotations.leftEyeIris[0][0]+Math.sin(u.rotation.gaze.bearing)*u.rotation.gaze.strength*u.box[3],u.annotations.leftEyeIris[0][1]+Math.cos(u.rotation.gaze.bearing)*u.rotation.gaze.strength*u.box[2]];s.moveTo(u.annotations.leftEyeIris[0][0],u.annotations.leftEyeIris[0][1]),s.lineTo(d[0],d[1]);let h=[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]];s.moveTo(u.annotations.rightEyeIris[0][0],u.annotations.rightEyeIris[0][1]),s.lineTo(h[0],h[1]),s.stroke()}}}}}async function s_(e,t,n){var a;let r=ir(oo,n);if(!t||!e||!(e instanceof HTMLCanvasElement))return;let s=e.getContext("2d");if(!!s){s.lineJoin="round";for(let o=0;o<t.length;o++){if(s.strokeStyle=r.color,s.fillStyle=r.color,s.lineWidth=r.lineWidth,s.font=r.font,r.drawBoxes&&t[o].box&&((a=t[o].box)==null?void 0:a.length)===4&&(Th(s,t[o].box[0],t[o].box[1],t[o].box[2],t[o].box[3],r),r.drawLabels&&(r.shadowColor&&r.shadowColor!==""&&(s.fillStyle=r.shadowColor,s.fillText(`body ${100*t[o].score}%`,t[o].box[0]+3,1+t[o].box[1]+r.lineHeight,t[o].box[2])),s.fillStyle=r.labelColor,s.fillText(`body ${100*t[o].score}%`,t[o].box[0]+2,0+t[o].box[1]+r.lineHeight,t[o].box[2]))),r.drawPoints)for(let i=0;i<t[o].keypoints.length;i++)s.fillStyle=r.useDepth&&t[o].keypoints[i].position[2]?`rgba(${127.5+2*(t[o].keypoints[i].position[2]||0)}, ${127.5-2*(t[o].keypoints[i].position[2]||0)}, 255, 0.5)`:r.color,f3(s,t[o].keypoints[i].position[0],t[o].keypoints[i].position[1],0,r);if(r.drawLabels&&(s.font=r.font,t[o].keypoints))for(let i of t[o].keypoints)s.fillStyle=r.useDepth&&i.position[2]?`rgba(${127.5+2*i.position[2]}, ${127.5-2*i.position[2]}, 255, 0.5)`:r.color,s.fillText(`${i.part} ${Math.trunc(100*i.score)}%`,i.position[0]+4,i.position[1]+4);if(r.drawPolygons&&t[o].keypoints){let i,l=[];l.length=0,i=t[o].keypoints.find(u=>u.part==="leftShoulder"),i&&l.push([i.position[0],i.position[1]]),i=t[o].keypoints.find(u=>u.part==="rightShoulder"),i&&l.push([i.position[0],i.position[1]]),Nh(s,l,r),l.length=0,i=t[o].keypoints.find(u=>u.part==="rightShoulder"),i&&l.push([i.position[0],i.position[1]]),i=t[o].keypoints.find(u=>u.part==="rightHip"),i&&l.push([i.position[0],i.position[1]]),i=t[o].keypoints.find(u=>u.part==="leftHip"),i&&l.push([i.position[0],i.position[1]]),i=t[o].keypoints.find(u=>u.part==="leftShoulder"),i&&l.push([i.position[0],i.position[1]]),l.length===4&&m3(s,l,r),l.length=0,i=t[o].keypoints.find(u=>u.part==="leftHip"),i&&l.push([i.position[0],i.position[1]]),i=t[o].keypoints.find(u=>u.part==="leftKnee"),i&&l.push([i.position[0],i.position[1]]),i=t[o].keypoints.find(u=>u.part==="leftAnkle"),i&&l.push([i.position[0],i.position[1]]),i=t[o].keypoints.find(u=>u.part==="leftHeel"),i&&l.push([i.position[0],i.position[1]]),i=t[o].keypoints.find(u=>u.part==="leftFoot"),i&&l.push([i.position[0],i.position[1]]),Nh(s,l,r),l.length=0,i=t[o].keypoints.find(u=>u.part==="rightHip"),i&&l.push([i.position[0],i.position[1]]),i=t[o].keypoints.find(u=>u.part==="rightKnee"),i&&l.push([i.position[0],i.position[1]]),i=t[o].keypoints.find(u=>u.part==="rightAnkle"),i&&l.push([i.position[0],i.position[1]]),i=t[o].keypoints.find(u=>u.part==="rightHeel"),i&&l.push([i.position[0],i.position[1]]),i=t[o].keypoints.find(u=>u.part==="rightFoot"),i&&l.push([i.position[0],i.position[1]]),Nh(s,l,r),l.length=0,i=t[o].keypoints.find(u=>u.part==="leftShoulder"),i&&l.push([i.position[0],i.position[1]]),i=t[o].keypoints.find(u=>u.part==="leftElbow"),i&&l.push([i.position[0],i.position[1]]),i=t[o].keypoints.find(u=>u.part==="leftWrist"),i&&l.push([i.position[0],i.position[1]]),i=t[o].keypoints.find(u=>u.part==="leftPalm"),i&&l.push([i.position[0],i.position[1]]),Nh(s,l,r),l.length=0,i=t[o].keypoints.find(u=>u.part==="rightShoulder"),i&&l.push([i.position[0],i.position[1]]),i=t[o].keypoints.find(u=>u.part==="rightElbow"),i&&l.push([i.position[0],i.position[1]]),i=t[o].keypoints.find(u=>u.part==="rightWrist"),i&&l.push([i.position[0],i.position[1]]),i=t[o].keypoints.find(u=>u.part==="rightPalm"),i&&l.push([i.position[0],i.position[1]]),Nh(s,l,r)}}}}async function a_(e,t,n){let r=ir(oo,n);if(!t||!e||!(e instanceof HTMLCanvasElement))return;let s=e.getContext("2d");if(!!s){s.lineJoin="round",s.font=r.font;for(let a of t){if(r.drawBoxes&&(s.strokeStyle=r.color,s.fillStyle=r.color,Th(s,a.box[0],a.box[1],a.box[2],a.box[3],r),r.drawLabels&&(r.shadowColor&&r.shadowColor!==""&&(s.fillStyle=r.shadowColor,s.fillText("hand",a.box[0]+3,1+a.box[1]+r.lineHeight,a.box[2])),s.fillStyle=r.labelColor,s.fillText("hand",a.box[0]+2,0+a.box[1]+r.lineHeight,a.box[2])),s.stroke()),r.drawPoints&&a.keypoints&&a.keypoints.length>0)for(let o of a.keypoints)s.fillStyle=r.useDepth?`rgba(${127.5+2*o[2]}, ${127.5-2*o[2]}, 255, 0.5)`:r.color,f3(s,o[0],o[1],0,r);if(r.drawLabels){let o=(i,l)=>{s.fillStyle=r.useDepth?`rgba(${127.5+2*i[i.length-1][2]}, ${127.5-2*i[i.length-1][2]}, 255, 0.5)`:r.color,s.fillText(l,i[i.length-1][0]+4,i[i.length-1][1]+4)};s.font=r.font,o(a.annotations.indexFinger,"index"),o(a.annotations.middleFinger,"middle"),o(a.annotations.ringFinger,"ring"),o(a.annotations.pinky,"pinky"),o(a.annotations.thumb,"thumb"),o(a.annotations.palmBase,"palm")}if(r.drawPolygons){let o=i=>{if(!!i)for(let l=0;l<i.length;l++)s.beginPath(),s.strokeStyle=r.useDepth?`rgba(${127.5+2*i[l][2]}, ${127.5-2*i[l][2]}, 255, 0.5)`:r.color,s.moveTo(i[l>0?l-1:0][0],i[l>0?l-1:0][1]),s.lineTo(i[l][0],i[l][1]),s.stroke()};s.lineWidth=r.lineWidth,o(a.annotations.indexFinger),o(a.annotations.middleFinger),o(a.annotations.ringFinger),o(a.annotations.pinky),o(a.annotations.thumb)}}}}async function o_(e,t,n){let r=ir(oo,n);if(!t||!e||!(e instanceof HTMLCanvasElement))return;let s=e.getContext("2d");if(!!s){s.lineJoin="round",s.font=r.font;for(let a of t)if(r.drawBoxes){if(s.strokeStyle=r.color,s.fillStyle=r.color,Th(s,a.box[0],a.box[1],a.box[2],a.box[3],r),r.drawLabels){let o=`${Math.round(100*a.score)}% ${a.label}`;r.shadowColor&&r.shadowColor!==""&&(s.fillStyle=r.shadowColor,s.fillText(o,a.box[0]+3,1+a.box[1]+r.lineHeight,a.box[2])),s.fillStyle=r.labelColor,s.fillText(o,a.box[0]+2,0+a.box[1]+r.lineHeight,a.box[2])}s.stroke()}}}async function owe(e,t,n){let r=ir(oo,n);if(!t||!e||!(e instanceof HTMLCanvasElement))return;let s=e.getContext("2d");if(!!s){s.lineJoin="round",s.font=r.font;for(let a=0;a<t.length;a++)if(r.drawBoxes){if(s.strokeStyle=r.color,s.fillStyle=r.color,Th(s,t[a].box[0],t[a].box[1],t[a].box[2],t[a].box[3],r),r.drawLabels){let o=`person #${a}`;r.shadowColor&&r.shadowColor!==""&&(s.fillStyle=r.shadowColor,s.fillText(o,t[a].box[0]+3,1+t[a].box[1]+r.lineHeight,t[a].box[2])),s.fillStyle=r.labelColor,s.fillText(o,t[a].box[0]+2,0+t[a].box[1]+r.lineHeight,t[a].box[2])}s.stroke()}}}async function iwe(e,t){if(!e||!t||!(e instanceof HTMLCanvasElement)||!(t instanceof HTMLCanvasElement))return;let n=e.getContext("2d");n==null||n.drawImage(e,0,0)}async function lwe(e,t,n){let r=at(),s=ir(oo,n);!t||!e||e instanceof HTMLCanvasElement&&(r_(e,t.face,s),s_(e,t.body,s),a_(e,t.hand,s),o_(e,t.object,s),n_(e,t.gesture,s),t.performance.draw=Math.trunc(at()-r))}function i_(e,t,n,r,s){var i,l,u,c,d,h,p,f,m,g,y,A,x,b,v,w;let a=0,o=[];for(let I of e){let T={id:a++,face:I,body:null,hands:{left:null,right:null},gestures:[],box:[0,0,0,0]};for(let F of t)I.box[0]>F.box[0]&&I.box[0]<F.box[0]+F.box[2]&&I.box[1]+I.box[3]>F.box[1]&&I.box[1]+I.box[3]<F.box[1]+F.box[3]&&(T.body=F);if(T.body)for(let F of n)F.box[0]+F.box[2]>T.body.box[0]&&F.box[0]+F.box[2]<T.body.box[0]+T.body.box[2]&&F.box[1]+F.box[3]>T.body.box[1]&&F.box[1]+F.box[3]<T.body.box[1]+T.body.box[3]&&T.hands&&(T.hands.left=F),F.box[0]<T.body.box[0]+T.body.box[2]&&F.box[0]>T.body.box[0]&&F.box[1]+F.box[3]>T.body.box[1]&&F.box[1]+F.box[3]<T.body.box[1]+T.body.box[3]&&T.hands&&(T.hands.right=F);for(let F of r)F.face!==void 0&&F.face===I.id?(i=T.gestures)==null||i.push(F):F.iris!==void 0&&F.iris===I.id?(l=T.gestures)==null||l.push(F):F.body!==void 0&&F.body===((u=T.body)==null?void 0:u.id)?(c=T.gestures)==null||c.push(F):F.hand!==void 0&&F.hand===((h=(d=T.hands)==null?void 0:d.left)==null?void 0:h.id)?(p=T.gestures)==null||p.push(F):F.hand!==void 0&&F.hand===((m=(f=T.hands)==null?void 0:f.right)==null?void 0:m.id)&&((g=T.gestures)==null||g.push(F));let C=[],M=[],$=F=>{F&&F.length===4&&(C.push(F[0],F[0]+F[2]),M.push(F[1],F[1]+F[3]))};$((y=T.face)==null?void 0:y.box),$((A=T.body)==null?void 0:A.box),$((b=(x=T.hands)==null?void 0:x.left)==null?void 0:b.box),$((w=(v=T.hands)==null?void 0:v.right)==null?void 0:w.box);let R=Math.min(...C),N=Math.min(...M);T.box=[R,N,Math.max(...C)-R,Math.max(...M)-N],s&&s.length===4&&(T.boxRaw=[T.box[0]/s[2],T.box[1]/s[1],T.box[2]/s[2],T.box[3]/s[1]]),o.push(T)}return o}var Be={face:[],body:[],hand:[],gesture:[],object:[],persons:[],performance:{},timestamp:0};function l_(e){var s,a,o,i,l,u,c,d,h,p,f,m,g,y,A,x,b,v,w,I,T;let t=Date.now()-e.timestamp,n=t<1e3?8-Math.log(t):1;if(Be.canvas=e.canvas,!Be.body||e.body.length!==Be.body.length)Be.body=JSON.parse(JSON.stringify(e.body));else for(let C=0;C<e.body.length;C++){let M=e.body[C].box.map((N,F)=>((n-1)*Be.body[C].box[F]+N)/n),$=e.body[C].boxRaw.map((N,F)=>((n-1)*Be.body[C].boxRaw[F]+N)/n),R=e.body[C].keypoints.map((N,F)=>({score:N.score,part:N.part,position:[Be.body[C].keypoints[F]?((n-1)*Be.body[C].keypoints[F].position[0]+N.position[0])/n:N.position[0],Be.body[C].keypoints[F]?((n-1)*Be.body[C].keypoints[F].position[1]+N.position[1])/n:N.position[1]],positionRaw:[Be.body[C].keypoints[F]?((n-1)*Be.body[C].keypoints[F].positionRaw[0]+N.positionRaw[0])/n:N.position[0],Be.body[C].keypoints[F]?((n-1)*Be.body[C].keypoints[F].positionRaw[1]+N.positionRaw[1])/n:N.position[1]]}));Be.body[C]={...e.body[C],box:M,boxRaw:$,keypoints:R}}if(!Be.hand||e.hand.length!==Be.hand.length)Be.hand=JSON.parse(JSON.stringify(e.hand));else for(let C=0;C<e.hand.length;C++){let M=e.hand[C].box.map((B,j)=>((n-1)*Be.hand[C].box[j]+B)/n),$=e.hand[C].boxRaw.map((B,j)=>((n-1)*Be.hand[C].boxRaw[j]+B)/n),R=e.hand[C].keypoints.map((B,j)=>B.map((X,Y)=>((n-1)*Be.hand[C].keypoints[j][Y]+X)/n)),N=Object.keys(e.hand[C].annotations),F={};for(let B of N)F[B]=e.hand[C].annotations[B].map((j,X)=>j.map((Y,ee)=>((n-1)*Be.hand[C].annotations[B][X][ee]+Y)/n));Be.hand[C]={...e.hand[C],box:M,boxRaw:$,keypoints:R,annotations:F}}if(!Be.face||e.face.length!==Be.face.length)Be.face=JSON.parse(JSON.stringify(e.face));else for(let C=0;C<e.face.length;C++){let M=e.face[C].box.map((N,F)=>((n-1)*Be.face[C].box[F]+N)/n),$=e.face[C].boxRaw.map((N,F)=>((n-1)*Be.face[C].boxRaw[F]+N)/n),R={matrix:[0,0,0,0,0,0,0,0,0],angle:{roll:0,yaw:0,pitch:0},gaze:{bearing:0,strength:0}};R.matrix=(s=e.face[C].rotation)==null?void 0:s.matrix,R.angle={roll:((n-1)*(((o=(a=Be.face[C].rotation)==null?void 0:a.angle)==null?void 0:o.roll)||0)+(((l=(i=e.face[C].rotation)==null?void 0:i.angle)==null?void 0:l.roll)||0))/n,yaw:((n-1)*(((c=(u=Be.face[C].rotation)==null?void 0:u.angle)==null?void 0:c.yaw)||0)+(((h=(d=e.face[C].rotation)==null?void 0:d.angle)==null?void 0:h.yaw)||0))/n,pitch:((n-1)*(((f=(p=Be.face[C].rotation)==null?void 0:p.angle)==null?void 0:f.pitch)||0)+(((g=(m=e.face[C].rotation)==null?void 0:m.angle)==null?void 0:g.pitch)||0))/n},R.gaze={bearing:((n-1)*(((A=(y=Be.face[C].rotation)==null?void 0:y.gaze)==null?void 0:A.bearing)||0)+(((b=(x=e.face[C].rotation)==null?void 0:x.gaze)==null?void 0:b.bearing)||0))/n,strength:((n-1)*(((w=(v=Be.face[C].rotation)==null?void 0:v.gaze)==null?void 0:w.strength)||0)+(((T=(I=e.face[C].rotation)==null?void 0:I.gaze)==null?void 0:T.strength)||0))/n},Be.face[C]={...e.face[C],rotation:R,box:M,boxRaw:$}}if(!Be.object||e.object.length!==Be.object.length)Be.object=JSON.parse(JSON.stringify(e.object));else for(let C=0;C<e.object.length;C++){let M=e.object[C].box.map((R,N)=>((n-1)*Be.object[C].box[N]+R)/n),$=e.object[C].boxRaw.map((R,N)=>((n-1)*Be.object[C].boxRaw[N]+R)/n);Be.object[C]={...e.object[C],box:M,boxRaw:$}}let r=e.persons;if(!Be.persons||r.length!==Be.persons.length)Be.persons=JSON.parse(JSON.stringify(r));else for(let C=0;C<r.length;C++)Be.persons[C].box=r[C].box.map((M,$)=>((n-1)*Be.persons[C].box[$]+M)/n);return Be.gesture=e.gesture,Be.performance=e.performance,Be}var Wr,y3=!1;async function v0(e){return Wr?e.debug&&me("cached model:",Wr.modelUrl):(Wr=await Et($t(e.modelBasePath,e.segmentation.modelPath)),!Wr||!Wr.modelUrl?me("load model failed:",e.segmentation.modelPath):e.debug&&me("load model:",Wr.modelUrl)),Wr}async function A3(e){var f,m;let t=((f=e.tensor)==null?void 0:f.shape[1])||0,n=((m=e.tensor)==null?void 0:m.shape[2])||0;if(!e.tensor||!Wr||!Wr.inputs[0].shape)return null;let r=Ye.resizeBilinear(e.tensor,[Wr.inputs[0].shape[1],Wr.inputs[0].shape[2]],!1),s=r.div(255),a=Wr.predict(s);Ve(r),Ve(s);let o=Zn(a,0),i;if(o.shape[2]===2){let g=o.softmax(),[y,A]=fc(g,2),x=A.expandDims(2),b=x.expandDims(0);Ve(g),Ve(y),Ve(A);let v=Ye.cropAndResize(b,[[0,0,.5,.5]],[0],[t,n]);i=v.squeeze(0),Ve(v),Ve(x),Ve(b)}else i=Ye.resizeBilinear(o,[t,n]);if(typeof document=="undefined")return i.dataSync();let l=typeof OffscreenCanvas!="undefined"?new OffscreenCanvas(t,n):document.createElement("canvas");l.width=t,l.height=n,Hr&&await Hr.toPixels(i,l),Ve(i),Ve(o),Ve(a);let u=typeof OffscreenCanvas!="undefined"?new OffscreenCanvas(t,n):document.createElement("canvas");u.width=t,u.height=n;let c=u.getContext("2d");c.filter="blur(8px",await c.drawImage(l,0,0);let d=c.getImageData(0,0,t,n).data,h=typeof OffscreenCanvas!="undefined"?new OffscreenCanvas(t,n):document.createElement("canvas");h.width=t,h.height=n;let p=h.getContext("2d");return e.canvas&&await p.drawImage(e.canvas,0,0),p.globalCompositeOperation="darken",p.filter="blur(8px)",await p.drawImage(l,0,0),p.globalCompositeOperation="source-over",p.filter="none",e.canvas=h,d}async function u_(e,t,n){var a;if(y3)return null;y3=!0,Wr||await v0(n);let r=wi(e,n),s=await A3(r);if(Ve(r.tensor),t&&s){let o=wi(t,n),i=o.canvas;Ve(o.tensor);let l=r.canvas,u=(a=l.getContext("2d"))==null?void 0:a.getImageData(0,0,l.width,l.height).data,c=typeof OffscreenCanvas!="undefined"?new OffscreenCanvas(l.width,l.height):document.createElement("canvas");c.width=l.width,c.height=l.height;let d=c.getContext("2d");d.globalCompositeOperation="copy",d.drawImage(i,0,0,c.width,c.height);let h=d.getImageData(0,0,c.width,c.height);for(let p=0;p<c.width*c.height;p++)h.data[4*p+0]=(255-s[4*p+0])/255*h.data[4*p+0]+s[4*p+0]/255*u[4*p+0],h.data[4*p+1]=(255-s[4*p+1])/255*h.data[4*p+1]+s[4*p+1]/255*u[4*p+1],h.data[4*p+2]=(255-s[4*p+2])/255*h.data[4*p+2]+s[4*p+2]/255*u[4*p+2],h.data[4*p+3]=(255-s[4*p+3])/255*h.data[4*p+3]+s[4*p+3]/255*u[4*p+3];d.putImageData(h,0,0),r.canvas=c}return y3=!1,r.canvas}var w0=`
|
|
/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==`,k0=`
|
|
/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==`;var c_="2.0.0";var Du,Ch,Eh,ki,Ii,Fu,I0,$h,S0,T0,N0,C0,cwe=class{constructor(t){Ir(this,Du,void 0);Ir(this,Ch,void 0);Ir(this,Eh,void 0);Ir(this,ki,void 0);Ir(this,Ii,void 0);Ir(this,Fu,void 0);this.analyze=(...t)=>{if(!Fn(this,Ch))return;let n=this.tf.engine().state.numTensors,r=Fn(this,Du);Qr(this,Du,n);let s=n-r;s!==0&&me(...t,s)};Ir(this,I0,t=>{if(!Fn(this,Eh))return null;if(!t)return"input is not defined";if(this.tf.ENV.flags.IS_NODE&&!(t instanceof Tt))return"input must be a tensor";try{this.tf.getBackend()}catch(n){return"backend not loaded"}return null});Ir(this,$h,async(t=!1)=>{var n;if(this.config.backend&&this.config.backend.length>0&&t||this.tf.getBackend()!==this.config.backend){let r=at();if(this.state="backend",this.config.backend&&this.config.backend.length>0){if(typeof window=="undefined"&&typeof WorkerGlobalScope!="undefined"&&this.config.debug&&me("running inside web worker"),this.tf.ENV.flags.IS_BROWSER&&this.config.backend==="tensorflow"&&(this.config.backend="webgl"),this.tf.ENV.flags.IS_NODE&&(this.config.backend==="webgl"||this.config.backend==="humangl")&&(this.config.backend="tensorflow"),this.config.debug&&me("setting backend:",this.config.backend),this.config.backend==="wasm"){if(this.config.debug&&me("wasm path:",this.config.wasmPath),typeof((n=this.tf)==null?void 0:n.setWasmPaths)!="undefined")this.tf.setWasmPaths(this.config.wasmPath);else throw new Error("Human: WASM backend is not loaded");let s=await this.tf.env().getAsync("WASM_HAS_SIMD_SUPPORT"),a=await this.tf.env().getAsync("WASM_HAS_MULTITHREAD_SUPPORT");this.config.debug&&me(`wasm execution: ${s?"SIMD":"no SIMD"} ${a?"multithreaded":"singlethreaded"}`),this.config.debug&&!s&&me("warning: wasm simd support is not enabled")}this.config.backend==="humangl"&&d$();try{await this.tf.setBackend(this.config.backend)}catch(s){me("error: cannot set backend:",this.config.backend,s)}}if(this.tf.enableProdMode(),this.tf.getBackend()==="webgl"||this.tf.getBackend()==="humangl"){this.tf.ENV.set("CHECK_COMPUTATION_FOR_ERRORS",!1),this.tf.ENV.set("WEBGL_CPU_FORWARD",!0),this.tf.ENV.set("WEBGL_PACK_DEPTHWISECONV",!0),typeof this.config.deallocate!="undefined"&&this.config.deallocate&&(me("changing webgl: WEBGL_DELETE_TEXTURE_THRESHOLD:",!0),this.tf.ENV.set("WEBGL_DELETE_TEXTURE_THRESHOLD",0));let s=await this.tf.backend().getGPGPUContext().gl;this.config.debug&&me(`gl version:${s.getParameter(s.VERSION)} renderer:${s.getParameter(s.RENDERER)}`)}await this.tf.ready(),this.performance.backend=Math.trunc(at()-r)}});this.next=t=>l_(t||this.result);Ir(this,S0,async t=>{if(this.config.cacheSensitivity===0)return!1;let n=32,r=t.resizeBilinear([Math.trunc(t.shape[1]/n),Math.trunc(t.shape[2]/n)]),s=r.dataSync(),a=0;for(let l=0;l<s.length/3;l++)a+=s[3*l+2];r.dispose();let o=100*(Math.max(a,Fn(this,Ii))/Math.min(a,Fn(this,Ii))-1);Qr(this,Ii,a);let i=o<Math.max(this.config.cacheSensitivity,Fn(this,Fu));return Qr(this,Fu,o>10*this.config.cacheSensitivity?0:o),i});Ir(this,T0,async()=>{let t=(s,a="application/octet-stream")=>fetch(`data:${a};base64,${s}`).then(o=>o.blob()),n,r;switch(this.config.warmup){case"face":n=await t(w0);break;case"full":n=await t(k0);break;default:n=null}if(n){let s=await createImageBitmap(n);r=await this.detect(s,this.config),s.close()}return r});Ir(this,N0,async()=>new Promise(t=>{let n,r=0;switch(this.config.warmup){case"face":r=256,n="data:image/jpeg;base64,"+w0;break;case"full":case"body":r=1200,n="data:image/jpeg;base64,"+k0;break;default:n=null}let s=new Image;s.onload=async()=>{let a=typeof OffscreenCanvas!="undefined"?new OffscreenCanvas(r,r):document.createElement("canvas");a.width=s.naturalWidth,a.height=s.naturalHeight;let o=a.getContext("2d");o==null||o.drawImage(s,0,0);let i=await this.detect(a,this.config);t(i)},n?s.src=n:t(null)}));Ir(this,C0,async()=>{let t=s=>Buffer.from(s,"base64"),n;if(this.config.warmup==="face"&&(n=t(w0)),(this.config.warmup==="body"||this.config.warmup==="full")&&(n=t(k0)),!n)return null;let r;if(typeof void 0!="undefined"){let s=(void 0).decodeJpeg(n),a=s.expandDims(0);this.tf.dispose(s),r=await this.detect(a,this.config),this.tf.dispose(a)}else this.config.debug&&me("Warmup tfjs-node not loaded");return r});this.config=ir(D3,t||{}),this.tf=bh,this.draw=g3,this.version=c_,this.state="idle",Qr(this,Du,0),Qr(this,Ch,!1),Qr(this,Eh,!1),Qr(this,ki,!0),Qr(this,Fu,0),this.performance={backend:0,load:0,image:0,frames:0,cached:0,changed:0,total:0,draw:0},this.models={face:null,posenet:null,blazepose:null,efficientpose:null,movenet:null,handpose:null,age:null,gender:null,emotion:null,embedding:null,nanodet:null,centernet:null,faceres:null,segmentation:null},this.image=n=>wi(n,this.config),this.faceTriangulation=I$,this.faceUVMap=S$,this.sysinfo=F3(),Qr(this,Ii,1)}similarity(t,n){return Db(t,n)}segmentation(t,n){return u_(t,n,this.config)}enhance(t){return Fb(t)}match(t,n,r=0){return C$(t,n,r)}async load(t){this.state="load";let n=at();t&&(this.config=ir(this.config,t)),Fn(this,ki)&&(this.config.debug&&me(`version: ${this.version}`),this.config.debug&&me(`tfjs version: ${this.tf.version_core}`),this.config.debug&&me("platform:",this.sysinfo.platform),this.config.debug&&me("agent:",this.sysinfo.agent),await Fn(this,$h).call(this,!0),this.tf.ENV.flags.IS_BROWSER&&(this.config.debug&&me("configuration:",this.config),this.config.debug&&me("tf flags:",this.tf.ENV.flags))),this.config.async?[this.models.face,this.models.emotion,this.models.handpose,this.models.posenet,this.models.blazepose,this.models.efficientpose,this.models.movenet,this.models.nanodet,this.models.centernet,this.models.faceres,this.models.segmentation]=await Promise.all([this.models.face||(this.config.face.enabled?Tb(this.config):null),this.models.emotion||(this.config.face.enabled&&this.config.face.emotion.enabled?Eb(this.config):null),this.models.handpose||(this.config.hand.enabled?Xb(this.config):null),this.models.posenet||(this.config.body.enabled&&this.config.body.modelPath.includes("posenet")?Ub(this.config):null),this.models.blazepose||(this.config.body.enabled&&this.config.body.modelPath.includes("blazepose")?g0(this.config):null),this.models.efficientpose||(this.config.body.enabled&&this.config.body.modelPath.includes("efficientpose")?Z$(this.config):null),this.models.movenet||(this.config.body.enabled&&this.config.body.modelPath.includes("movenet")?s3(this.config):null),this.models.nanodet||(this.config.object.enabled&&this.config.object.modelPath.includes("nanodet")?l3(this.config):null),this.models.centernet||(this.config.object.enabled&&this.config.object.modelPath.includes("centernet")?h3(this.config):null),this.models.faceres||(this.config.face.enabled&&this.config.face.description.enabled?Rb(this.config):null),this.models.segmentation||(this.config.segmentation.enabled?v0(this.config):null)]):(this.config.face.enabled&&!this.models.face&&(this.models.face=await Tb(this.config)),this.config.face.enabled&&this.config.face.emotion.enabled&&!this.models.emotion&&(this.models.emotion=await Eb(this.config)),this.config.hand.enabled&&!this.models.handpose&&(this.models.handpose=await Xb(this.config)),this.config.body.enabled&&!this.models.posenet&&this.config.body.modelPath.includes("posenet")&&(this.models.posenet=await Ub(this.config)),this.config.body.enabled&&!this.models.blazepose&&this.config.body.modelPath.includes("blazepose")&&(this.models.blazepose=await g0(this.config)),this.config.body.enabled&&!this.models.efficientpose&&this.config.body.modelPath.includes("efficientpose")&&(this.models.efficientpose=await g0(this.config)),this.config.body.enabled&&!this.models.movenet&&this.config.body.modelPath.includes("movenet")&&(this.models.movenet=await s3(this.config)),this.config.object.enabled&&!this.models.nanodet&&this.config.object.modelPath.includes("nanodet")&&(this.models.nanodet=await l3(this.config)),this.config.object.enabled&&!this.models.centernet&&this.config.object.modelPath.includes("centernet")&&(this.models.centernet=await h3(this.config)),this.config.face.enabled&&this.config.face.description.enabled&&!this.models.faceres&&(this.models.faceres=await Rb(this.config)),this.config.segmentation.enabled&&!this.models.segmentation&&(this.models.segmentation=await v0(this.config))),Fn(this,ki)&&(this.config.debug&&me("tf engine state:",this.tf.engine().state.numBytes,"bytes",this.tf.engine().state.numTensors,"tensors"),Qr(this,ki,!1));let r=Math.trunc(at()-n);r>(this.performance.load||0)&&(this.performance.load=r)}async detect(t,n){return new Promise(async r=>{this.state="config";let s,a;this.config=ir(this.config,n),this.state="check";let o=Fn(this,I0).call(this,t);o&&(me(o,t),r({error:o}));let i=at();await Fn(this,$h).call(this),await this.load(),s=at();let l=wi(t,this.config);if(this.performance.image=Math.trunc(at()-s),this.analyze("Get Image:"),this.config.segmentation.enabled&&l&&l.tensor&&(this.analyze("Start Segmentation:"),this.state="run:segmentation",s=at(),await A3(l),a=Math.trunc(at()-s),a>0&&(this.performance.segmentation=a),l.canvas&&(l.tensor.dispose(),l=wi(l.canvas,this.config)),this.analyze("End Segmentation:")),!l||!l.tensor){me("could not convert input to tensor"),r({error:"could not convert input to tensor"});return}s=at(),this.config.skipFrame=await Fn(this,S0).call(this,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(at()-s),this.analyze("Check Changed:");let u,c,d,h;this.config.async?(u=this.config.face.enabled?Ob(this,l.tensor):[],this.performance.face&&delete this.performance.face):(this.state="run:face",s=at(),u=this.config.face.enabled?await Ob(this,l.tensor):[],a=Math.trunc(at()-s),a>0&&(this.performance.face=a)),this.analyze("Start Body:"),this.config.async?(this.config.body.modelPath.includes("posenet")?c=this.config.body.enabled?Vb(l.tensor,this.config):[]:this.config.body.modelPath.includes("blazepose")?c=this.config.body.enabled?Zb(l.tensor,this.config):[]:this.config.body.modelPath.includes("efficientpose")?c=this.config.body.enabled?e3(l.tensor,this.config):[]:this.config.body.modelPath.includes("movenet")&&(c=this.config.body.enabled?a3(l.tensor,this.config):[]),this.performance.body&&delete this.performance.body):(this.state="run:body",s=at(),this.config.body.modelPath.includes("posenet")?c=this.config.body.enabled?await Vb(l.tensor,this.config):[]:this.config.body.modelPath.includes("blazepose")?c=this.config.body.enabled?await Zb(l.tensor,this.config):[]:this.config.body.modelPath.includes("efficientpose")?c=this.config.body.enabled?await e3(l.tensor,this.config):[]:this.config.body.modelPath.includes("movenet")&&(c=this.config.body.enabled?await a3(l.tensor,this.config):[]),a=Math.trunc(at()-s),a>0&&(this.performance.body=a)),this.analyze("End Body:"),this.analyze("Start Hand:"),this.config.async?(d=this.config.hand.enabled?Kb(l.tensor,this.config):[],this.performance.hand&&delete this.performance.hand):(this.state="run:hand",s=at(),d=this.config.hand.enabled?await Kb(l.tensor,this.config):[],a=Math.trunc(at()-s),a>0&&(this.performance.hand=a)),this.analyze("End Hand:"),this.analyze("Start Object:"),this.config.async?(this.config.object.modelPath.includes("nanodet")?h=this.config.object.enabled?u3(l.tensor,this.config):[]:this.config.object.modelPath.includes("centernet")&&(h=this.config.object.enabled?p3(l.tensor,this.config):[]),this.performance.object&&delete this.performance.object):(this.state="run:object",s=at(),this.config.object.modelPath.includes("nanodet")?h=this.config.object.enabled?await u3(l.tensor,this.config):[]:this.config.object.modelPath.includes("centernet")&&(h=this.config.object.enabled?await p3(l.tensor,this.config):[]),a=Math.trunc(at()-s),a>0&&(this.performance.object=a)),this.analyze("End Object:"),this.config.async&&([u,c,d,h]=await Promise.all([u,c,d,h]));let p=[];this.config.gesture.enabled&&(s=at(),p=[...J$(u),...Y$(c),...e_(d),...Q$(u)],this.config.async?this.performance.gesture&&delete this.performance.gesture:this.performance.gesture=Math.trunc(at()-s)),this.performance.total=Math.trunc(at()-i),this.state="idle",this.result={face:u,body:c,hand:d,gesture:p,object:h,performance:this.performance,canvas:l.canvas,timestamp:Date.now(),get persons(){var f;return i_(u,c,d,p,(f=l==null?void 0:l.tensor)==null?void 0:f.shape)}},Ve(l.tensor),r(this.result)})}async warmup(t){let n=at();if(t&&(this.config=ir(this.config,t)),!this.config.warmup||this.config.warmup==="none")return{error:"null"};let r;typeof createImageBitmap=="function"?r=await Fn(this,T0).call(this):typeof Image!="undefined"?r=await Fn(this,N0).call(this):r=await Fn(this,C0).call(this);let s=at();return this.config.debug&&me("Warmup",this.config.warmup,Math.round(s-n),"ms",r),r}};Du=new WeakMap,Ch=new WeakMap,Eh=new WeakMap,ki=new WeakMap,Ii=new WeakMap,Fu=new WeakMap,I0=new WeakMap,$h=new WeakMap,S0=new WeakMap,T0=new WeakMap,N0=new WeakMap,C0=new WeakMap;export{cwe as Human,cwe as default};
|
|
/**
|
|
* @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. */
|
|
//# sourceMappingURL=human.esm.js.map
|