1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[4072],{884:function(e,t,r){var n;!function(e,a,s){function i(e){var t=this,r="";t.x=0,t.y=0,t.z=0,t.w=0,t.next=function(){var e=t.x^t.x<<11;return t.x=t.y,t.y=t.z,t.z=t.w,t.w^=t.w>>>19^e^e>>>8},e===(0|e)?t.x=e:r+=e;for(var n=0;n<r.length+64;n++)t.x^=r.charCodeAt(n),t.next()}function o(e,t){return t.x=e.x,t.y=e.y,t.z=e.z,t.w=e.w,t}function l(e,t){var r=new i(e),n=t&&t.state,a=function(){return(r.next()>>>0)/0x100000000};return a.double=function(){do var e=((r.next()>>>11)+(r.next()>>>0)/0x100000000)/2097152;while(0===e);return e},a.int32=r.next,a.quick=a,n&&("object"==typeof n&&o(n,r),a.state=function(){return o(r,{})}),a}a&&a.exports?a.exports=l:r.amdD&&r.amdO?void 0===(n=(function(){return l}).call(t,r,t,a))||(a.exports=n):this.xor128=l}(0,e=r.nmd(e),r.amdD)},993:(e,t,r)=>{"use strict";r.d(t,{r:()=>s});var n=r(60218),a=r(76526);function s(e,t="float32",r){return t=t||"float32",a.SA(e),new n.yl(e,t,r)}},1039:(e,t,r)=>{"use strict";r.d(t,{G:()=>a});var n=r(51520);function a(e,t,r){let a=(t-e)/(r-1),s=n.ZSL.makeZerosTypedArray(r,"float32");s[0]=e;for(let e=1;e<s.length;e++)s[e]=s[e-1]+a;return s}},1374:(e,t,r)=>{"use strict";r.d(t,{c:()=>l});var n=r(19041),a=r(48592),s=r(76526),i=r(62176),o=r(68567);let l=(0,i.op)({conv3DBackpropInput_:function(e,t,r,i,l){s.vA(e.length===t.rank,()=>`Length of inShape (${e.length}) and rank of dy (${t.rank}) must match`);let u=e,h=t,p=!1;4===t.rank&&(p=!0,h=(0,o.t)(t,[1,t.shape[0],t.shape[1],t.shape[2],t.shape[3]]),u=[1,e[0],e[1],e[2],e[3]]);let d=u[4],c=h.shape[4];s.vA(5===u.length,()=>`Error in conv3dDerInput: inShape must be length 5, but got length ${u.length}.`),s.vA(5===h.rank,()=>`Error in conv3dDerInput: dy must be rank 5, but got rank ${h.rank}`),s.vA(5===r.rank,()=>`Error in conv3dDerInput: filter must be rank 5, but got rank ${r.rank}`),s.vA(d===r.shape[3],()=>`Error in conv3dDerInput: depth of input (${d}) must match input depth for filter ${r.shape[3]}.`),s.vA(c===r.shape[4],()=>`Error in conv3dDerInput: depth of output (${c}) must match output depth for filter ${r.shape[4]}.`);let f={dy:h,filter:r},m={pad:l,strides:i,inputShape:u},g=n.T2.runKernel(a.gC7,f,m);return p?(0,o.t)(g,[g.shape[1],g.shape[2],g.shape[3],g.shape[4]]):g}})},1560:(e,t,r)=>{"use strict";r.d(t,{FS:()=>s,TT:()=>a,U$:()=>o,un:()=>i});var n=r(97344);function a(e){return Array.isArray(e)&&Array.isArray(e[0])}function s(e){return 0===e.length?[]:Array.isArray(e[0])?e:[e]}function i(e){let t;if(Array.isArray(e)){if(1!==e.length)throw new n.Qp(`Expected Tensor length to be 1; got ${e.length}`);t=e[0]}else t=e;return t}function o(e){if(!(Array.isArray(e)&&Array.isArray(e[0])))return e;if(1===e.length)return e[0];throw new n.Qp(`Expected exactly 1 Shape; got ${e.length}`)}},1930:(e,t,r)=>{"use strict";r.d(t,{_:()=>i});var n=r(19041),a=r(48592),s=r(27924);let i=(0,r(62176).op)({sign_:function(e){let t=(0,s.YT)(e,"x","sign");return n.T2.runKernel(a.YVe,{x:t})}})},1939:(e,t,r)=>{"use strict";r.d(t,{Ez:()=>c,RX:()=>f});var n=r(51520),a=r(8785),s=r(14811),i=r(97344),o=r(96902),l=r(65650),u=r(82692),h=r(77617),p=r(1560);function d(e,t,r,a,s,o=.001){let l;if(2===e.rank)l=n.BFc(e,t,r,a,s,o);else if(3===e.rank)l=n.kSi(e,t,r,a,s,o);else if(4===e.rank)l=n.T5N(e,t,r,a,s,o);else throw new i.EH(`batchNormalization is not implemented for array of rank ${e.rank} yet`);return l}class c extends s.Wd{constructor(e){null==e&&(e={}),super(e),this.supportsMasking=!0,this.axis=null==e.axis?-1:e.axis,this.momentum=null==e.momentum?.99:e.momentum,this.epsilon=null==e.epsilon?.001:e.epsilon,this.center=null==e.center||e.center,this.scale=null==e.scale||e.scale,this.betaInitializer=(0,o.Fe)(e.betaInitializer||"zeros"),this.gammaInitializer=(0,o.Fe)(e.gammaInitializer||"ones"),this.movingMeanInitializer=(0,o.Fe)(e.movingMeanInitializer||"zeros"),this.movingVarianceInitializer=(0,o.Fe)(e.movingVarianceInitializer||"ones"),this.betaConstraint=(0,a.YZ)(e.betaConstraint),this.gammaConstraint=(0,a.YZ)(e.gammaConstraint),this.betaRegularizer=(0,l.Bm)(e.betaRegularizer),this.gammaRegularizer=(0,l.Bm)(e.gammaRegularizer)}build(e){e=(0,p.U$)(e);let t=this.axis>=0?this.axis:this.axis+e.length,r=e[t];if(null==r)throw new i.Qp(`Axis ${t} of input tensor should have a defined dimension but the layer received an input with shape ${JSON.stringify(e)}.`);this.inputSpec=[new s.eO({ndim:e.length,axes:{[t]:r}})];let n=[r];this.scale&&(this.gamma=this.addWeight("gamma",n,null,this.gammaInitializer,this.gammaRegularizer,!0,this.gammaConstraint)),this.center&&(this.beta=this.addWeight("beta",n,null,this.betaInitializer,this.betaRegularizer,!0,this.betaConstraint)),this.movingMean=this.addWeight("moving_mean",n,null,this.movingMeanInitializer,null,!1),this.movingVariance=this.addWeight("moving_variance",n,null,this.movingVarianceInitializer,null,!1),this.built=!0}call(e,t){return(0,n.DZQ)(()=>{let r=null!=t.training&&t.training,a=(0,p.un)(e),s=a.shape,i=s.length,o=h.y1(0,i),l=this.axis>=0?this.axis:this.axis+i;o.splice(l,1);let c=u.fD(1,i);c[l]=s[l];let f=o.slice();f.sort();let m=!n.ZSL.arraysEqual(f,h.y1(0,i).slice(0,i-1));if(!r){if(!m)return d(a,this.movingMean.read(),this.movingVariance.read(),null==this.beta?null:this.beta.read(),null==this.gamma?null:this.gamma.read(),this.epsilon);{let e=(0,n.tQQ)(this.movingMean.read(),c),t=(0,n.tQQ)(this.movingVariance.read(),c);return d(a,e,t,this.center?(0,n.tQQ)(this.beta.read(),c):null,this.scale?(0,n.tQQ)(this.gamma.read(),c):null,this.epsilon)}}let[g,y,b]=function(e,t,r,a,s=.001){return n.ZSL.arraysEqual(a.slice().sort(),h.y1(0,e.rank-1))?function(e,t,r,a,s=.001){return(0,n.DZQ)(()=>{let i=n.Clk(e,a),o=i.mean,l=i.variance;
1return[d(e,o,l,r,t,s),o,l]})}(e,t,r,a,s):function(e,t,r,a,s=.001){return(0,n.DZQ)(()=>{let i=n.Clk(e,a),o=i.mean,l=i.variance,u=[];for(let t of h.y1(0,e.rank))-1!==a.indexOf(t)?u.push(1):u.push(e.shape[t]);let p=(0,n.tQQ)(o,u),c=(0,n.tQQ)(l,u),f=null==t?null:(0,n.tQQ)(t,u);return[d(e,p,c,null==r?null:(0,n.tQQ)(r,u),f,s),o,l]})}(e,t,r,a,s)}(a,this.gamma.read(),this.beta.read(),o,this.epsilon),x=(e,t,r)=>{n.DZQ(()=>{let a=e.read(),s=n.lKK(n.jbE(a,t),1-r);e.write(n.jbE(a,s))})};return x(this.movingMean,y,this.momentum),x(this.movingVariance,b,this.momentum),g})}getConfig(){let e={axis:this.axis,momentum:this.momentum,epsilon:this.epsilon,center:this.center,scale:this.scale,betaInitializer:(0,o.zo)(this.betaInitializer),gammaInitializer:(0,o.zo)(this.gammaInitializer),movingMeanInitializer:(0,o.zo)(this.movingMeanInitializer),movingVarianceInitializer:(0,o.zo)(this.movingVarianceInitializer),betaRegularizer:(0,l.R9)(this.betaRegularizer),gammaRegularizer:(0,l.R9)(this.gammaRegularizer),betaConstraint:(0,a.uH)(this.betaConstraint),gammaConstraint:(0,a.uH)(this.gammaConstraint)};return Object.assign(e,super.getConfig()),e}}c.className="BatchNormalization",n.JFn.registerClass(c);class f extends s.Wd{constructor(e){if(null==e&&(e={}),super(e),this.axis=null==e.axis?-1:e.axis,"number"==typeof this.axis){if(!Number.isInteger(this.axis))throw Error(`Expected axis to be an integer, but received ${this.axis}`)}else if(Array.isArray(this.axis)){for(let e of this.axis)if(!Number.isInteger(e))throw Error(`Expected axis to be an array of integers, but received ${JSON.stringify(this.axis)}`)}else throw Error(`Expected axis to be an integer or an array of integers, but received ${JSON.stringify(this.axis)}`);this.epsilon=null==e.epsilon?.001:e.epsilon,this.center=null==e.center||e.center,this.scale=null==e.scale||e.scale,this.betaInitializer=(0,o.Fe)(e.betaInitializer||"zeros"),this.gammaInitializer=(0,o.Fe)(e.gammaInitializer||"ones"),this.betaRegularizer=(0,l.Bm)(e.betaRegularizer),this.gammaRegularizer=(0,l.Bm)(e.gammaRegularizer),this.supportsMasking=!0}build(e){let t=(e=(0,p.U$)(e)).length;"number"==typeof this.axis&&(this.axis=[this.axis]);for(let e=0;e<this.axis.length;++e)this.axis[e]<0&&(this.axis[e]+=t);for(let e of this.axis)if(e<0||e>=t)throw Error(`Invalid axis: ${e}`);if(this.axis.length!==u.Am(this.axis).length)throw Error(`Found duplicate axes in: ${this.axis}`);let r=this.axis.map(t=>e[t]);this.scale?this.gamma=this.addWeight("gamma",r,"float32",this.gammaInitializer,this.gammaRegularizer,!0):this.gamma=null,this.center?this.beta=this.addWeight("beta",r,"float32",this.betaInitializer,this.betaRegularizer,!0):this.beta=null,this.built=!0}call(e,t){let r=(0,p.un)(e),a=r.shape,s=a.length;return(0,n.DZQ)(()=>{let{mean:e,variance:t}=(0,n.Clk)(r,this.axis,!0),i=u.fD(1,s);for(let e of this.axis)i[e]=a[e];let o=e=>null!=e&&e.shape.length!==s?n.tQQ(e,i):e,l=this.scale?o(this.gamma.read()):null,h=this.center?o(this.beta.read()):null,p=[],c=[];for(let e=0;e<s;++e)-1!==this.axis.indexOf(e)?(p.push(a[e]),c.push(1)):(p.push(1),c.push(a[e]));return e=n.Vsq(e,p),t=n.Vsq(t,p),null!=l&&(l=n.Vsq(l,c)),null!=h&&(h=n.Vsq(h,c)),d(r,e,t,h,l,this.epsilon)})}getConfig(){let e={axis:this.axis,epsilon:this.epsilon,center:this.center,scale:this.scale,betaInitializer:(0,o.zo)(this.betaInitializer),gammaInitializer:(0,o.zo)(this.gammaInitializer),betaRegularizer:(0,l.R9)(this.betaRegularizer),gammaRegularizer:(0,l.R9)(this.gammaRegularizer)};return Object.assign(e,super.getConfig()),e}}f.className="LayerNormalization",n.JFn.registerClass(f)},2774:(e,t,r)=>{"use strict";r.d(t,{z:()=>m});var n=r(76526),a=r(46213),s=r(88527),i=r(14017),o=r(62176),l=r(95791),u=r(68567),h=r(82171),p=r(24361),d=r(59918),c=r(79320),f=r(30824);let m=(0,o.op)({rfft_:function(e,t){let r;(0,n.vA)("float32"===e.dtype,()=>`The dtype for rfft() must be real value but got ${e.dtype}`);let o=e.shape[e.shape.length-1],m=e.size/o;if(null!=t&&t<o){let n=e.shape.map(e=>0),a=e.shape.map(e=>e);a[e.shape.length-1]=t,r=(0,h.d)(e,n,a),o=t}else if(null!=t&&t>o){let n=e.shape.map(e=>e);n[e.shape.length-1]=t-o,r=(0,s.x)([e,(0,d.U)(n)],e.shape.length-1),o=t}else r=e;let g=(0,c.P)(r),y=(0,u.t)((0,a.f)(r,g),[m,o]),b=(0,f.h)(y),x=Math.floor(o/2)+1,v=(0,l.x)(b),w=(0,i.n)(b),T=(0,p.l)(v,[x,o-x],v.shape.length-1),S=(0,p.l)(w,[x,o-x],w.shape.length-1),N=r.shape.slice();return N[r.shape.length-1]=x,(0,u.t)((0,a.f)(T[0],S[0]),N)}})},3024:(e,t,r)=>{"use strict";r.d(t,{Fz:()=>p,GT:()=>C,I9:()=>d,Jc:()=>c,Jt:()=>I,Ol:()=>T,ZY:()=>m,qp:()=>N,qv:()=>f,xM:()=>l,yP:()=>u});var n=r(51520),a=r(90556),s=r(97344),i=r(70796),o=r(82692);function l(e,t){return(0,n.DZQ)(()=>{let r=n.lKK(.5,n.P61(t)),s=a.wg(n.rhj(t,r),e.dtype);return n.i2o(n.LCg(e,s),-1)})}function u(e,t){return(0,n.DZQ)(()=>a.wg(n.LCg(n.FLi(e,-1),n.FLi(t,-1)),"float32"))}function h(e,t){return(0,n.DZQ)(()=>n.wgE(n.czq(n.n76(n.LCg(e,1),n.LCg(t,1))),"float32"))}function p(e,t){return(0,n.DZQ)(()=>{let r=h(e,t),a=(0,n.DZQ)(()=>n.wgE(n.czq(n.n76(n.LCg(e,0),n.LCg(t,1))),"float32")),s=n.WQq(r,a);return n.wgE(n._M9(n.rhj(s,0),n.y4m(r,s),0),"float32")})}function d(e,t){return(0,n.DZQ)(()=>{let r=h(e,t),a=(0,n.DZQ)(()=>n.wgE(n.czq(n.n76(n.LCg(e,1),n.LCg(t,0))),"float32")),s=n.WQq(r,a);return n.wgE(n._M9(n.rhj(s,0),n.y4m(r,s),0),"float32")})}function c(e,t){return(0,i.Jc)(e,t)}
1function f(e,t){return e.rank===t.rank&&(e=n.r2V(e,[e.rank-1])),(t=n.FLi(t,-1)).dtype!==e.dtype&&(t=n.wgE(t,e.dtype)),n.wgE(n.LCg(e,t),"float32")}function m(e,t){return(0,n.DZQ)(()=>{let r=e.sub(t).square().sum(),a=e.sub(e.mean()).square().sum();return n.d_2(1).sub(r.div(a))})}let g=i.bt,y=i.bt,b=i.Xv,x=i.Xv,v=i.VW,w=i.VW,T=i.Ol,S=i.Pg,N=i.qp,k={binaryAccuracy:l,categoricalAccuracy:u,precision:p,categoricalCrossentropy:T,sparseCategoricalCrossentropy:N,mse:g,MSE:y,mae:b,MAE:x,mape:v,MAPE:w,cosine:S};function I(e){if("string"==typeof e&&e in k)return k[e];if("string"!=typeof e&&null!=e)return e;throw new s.Qp(`Unknown metric ${e}`)}function C(e){if(o.vA(null!==e,`Unknown LossOrMetricFn ${e}`),"string"==typeof e)return e;{let t;for(let r of Object.keys(i.SO))if(i.SO[r]===e){t=r;break}if(void 0!==t)return t;for(let r of Object.keys(k))if(k[r]===e){t=r;break}return void 0!==t?t:e.name}}},3047:(e,t,r)=>{"use strict";r.d(t,{j:()=>a,v:()=>i});let n=0;function a(){return n++}let s={};function i(e=""){return e in s||(s[e]=0),s[e]+=1,e+s[e].toString()}},3437:(e,t,r)=>{"use strict";r.d(t,{AQ:()=>w,CY:()=>d,Ej:()=>k,P8:()=>T,Rl:()=>N,Xf:()=>C,aG:()=>p,jf:()=>v,l3:()=>x,oR:()=>I,s5:()=>g,zV:()=>S});var n=r(46213),a=r(22666),s=r(76526),i=r(64756),o=r(36799),l=r(14958),u=r(89215),h=r(44134).hp;async function p(e,t){let r=[],n=[],a=Array.isArray(e)?e.map(e=>e.name):Object.keys(e);for(let s=0;s<a.length;++s){let i=a[s],o=Array.isArray(e)?e[s].tensor:e[i];if("float32"!==o.dtype&&"int32"!==o.dtype&&"bool"!==o.dtype&&"string"!==o.dtype&&"complex64"!==o.dtype)throw Error(`Unsupported dtype in weight '${i}': ${o.dtype}`);let l={name:i,shape:o.shape,dtype:o.dtype};if("string"===o.dtype){let e=new Promise(async e=>{let t=await o.bytes(),r=new Uint8Array(t.reduce((e,t)=>e+t.length,0)+4*t.length),n=0;for(let e=0;e<t.length;e++){let a=t[e],s=new Uint8Array(new Uint32Array([a.length]).buffer);r.set(s,n),n+=4,r.set(a,n),n+=a.length}e(r)});n.push(e)}else n.push(o.data());null!=t&&(l.group=t),r.push(l)}return{data:function(e){if(null===e)throw Error(`Invalid input value: ${JSON.stringify(e)}`);let t=0,r=[];e.forEach(e=>{if(t+=e.byteLength,r.push(e.byteLength===e.buffer.byteLength?e:new e.constructor(e)),!(e instanceof Float32Array||e instanceof Int32Array||e instanceof Uint8Array))throw Error(`Unsupported TypedArray subtype: ${e.constructor.name}`)});let n=new Uint8Array(t),a=0;return r.forEach(e=>{n.set(new Uint8Array(e.buffer),a),a+=e.byteLength}),n.buffer}(await Promise.all(n)),specs:r}}function d(e,t){let r=new o.D(e),n={},a=0;for(let e of t){let t=function(e,t){let r,n=(0,s.Ze)(e.shape);if("quantization"in e){let t=e.quantization;r=i.i[t.dtype]}else if("string"===e.dtype){let e=0;for(let r=0;r<n;r++)e+=4+new Uint32Array(t(e,e+4))[0];return e}else r=i.i[e.dtype];return n*r}(e,(e,t)=>r.slice(a+e,a+t));n[e.name]=f(e,r.slice(a,a+t)),a+=t}return n}async function c(e,t){let r,n=(0,s.Ze)(e.shape);if("quantization"in e){let t=e.quantization;r=i.i[t.dtype]}else if("string"===e.dtype){let e=0;for(let r=0;r<n;r++)e+=4+new Uint32Array(await t(e,e+4))[0];return e}else r=i.i[e.dtype];return n*r}function f(e,t){let r,o=e.name,l=e.dtype,u=e.shape,h=(0,s.Ze)(u),p=0;if("quantization"in e){let n=e.quantization;if("uint8"===n.dtype||"uint16"===n.dtype){if(!("min"in n&&"scale"in n))throw Error(`Weight ${e.name} with quantization ${n.dtype} doesn't have corresponding metadata min and scale.`)}else if("float16"===n.dtype){if("float32"!==l)throw Error(`Weight ${e.name} is quantized with ${n.dtype} which only supports weights of type float32 not ${l}.`)}else throw Error(`Weight ${e.name} has unknown quantization dtype ${n.dtype}. Supported quantization dtypes are: 'uint8', 'uint16', and 'float16'.`);let a=i.i[n.dtype],s="uint8"===n.dtype?new Uint8Array(t):new Uint16Array(t);if("float32"===l)if("uint8"===n.dtype||"uint16"===n.dtype){r=new Float32Array(s.length);for(let e=0;e<s.length;e++){let t=s[e];r[e]=t*n.scale+n.min}}else if("float16"===n.dtype)r=(function(){let e=function(){let e=e=>{let t=e<<13,r=0;for(;(8388608&t)==0;)r-=8388608,t<<=1;return(t&=-8388609)|(r+=0x38800000)},t=new Uint32Array(2048);t[0]=0;for(let r=1;r<1024;r++)t[r]=e(r);for(let e=1024;e<2048;e++)t[e]=0x38000000+(e-1024<<13);return t}(),t=function(){let e=new Uint32Array(64);e[0]=0,e[31]=0x47800000,e[32]=0x80000000,e[63]=0xc7800000;for(let t=1;t<31;t++)e[t]=t<<23;
1for(let t=33;t<63;t++)e[t]=0x80000000+(t-32<<23);return e}(),r=function(){let e=new Uint32Array(64);for(let t=0;t<64;t++)e[t]=1024;return e[0]=e[32]=0,e}();return n=>{let a=new ArrayBuffer(4*n.length),s=new Uint32Array(a);for(let a=0;a<n.length;a++){let i=n[a],o=e[r[i>>10]+(1023&i)]+t[i>>10];s[a]=o}return new Float32Array(a)}})()(s);else throw Error(`Unsupported quantization type ${n.dtype} for weight type float32.`);else if("int32"===l){if("uint8"!==n.dtype&&"uint16"!==n.dtype)throw Error(`Unsupported quantization type ${n.dtype} for weight type int32.`);r=new Int32Array(s.length);for(let e=0;e<s.length;e++){let t=s[e];r[e]=Math.round(t*n.scale+n.min)}}else throw Error(`Unsupported dtype in weight '${o}': ${l}`);p+=h*a}else if("string"===l){let n=(0,s.Ze)(e.shape);r=[];for(let e=0;e<n;e++){let e=new Uint32Array(t.slice(p,p+4))[0];p+=4;let n=new Uint8Array(t.slice(p,p+e));r.push(n),p+=e}}else{let e=i.i[l];if("float32"===l)r=new Float32Array(t);else if("int32"===l)r=new Int32Array(t);else if("bool"===l)r=new Uint8Array(t);else if("complex64"===l){r=new Float32Array(t);let e=new Float32Array(r.length/2),s=new Float32Array(r.length/2);for(let t=0;t<e.length;t++)e[t]=r[2*t],s[t]=r[2*t+1];let i=(0,a.O)(e,u,"float32"),o=(0,a.O)(s,u,"float32"),l=(0,n.f)(i,o);return i.dispose(),o.dispose(),l}else throw Error(`Unsupported dtype in weight '${o}': ${l}`);p+=h*e}return(0,a.O)(r,u,l)}async function m(e,t,r){let n=new Uint8Array(t);for(;n.byteLength<r;){let{done:t,value:a}=await e.read();if(t&&null==a){let e=r-n.byteLength;throw Error(`Reader is done but ${e} bytes are still expected`)}let s=new Uint8Array(n.length+a.byteLength);s.set(n,0),s.set(new Uint8Array(a),n.length),n=s}return n.buffer}async function g(e,t){let r={},n=e.getReader(),a=new ArrayBuffer(0);for(let e of t){let t=await c(e,async(e,t)=>(a=await m(n,a,t)).slice(e,t)),i=(a=await m(n,a,t)).slice(0,t);a=a.slice(t);let o=f(e,i);if(r[e.name]=o,"webgpu"===(0,l.jz)()){let e=(0,l.Hs)();"uploadToGPU"in e&&(0,s.Ze)(o.shape)>=(0,u._K)().get("WEBGPU_CPU_HANDOFF_SIZE_THRESHOLD")&&e.uploadToGPU(o.dataId)}}return r}let y=void 0!==h&&("undefined"==typeof Blob||"undefined"==typeof atob||"undefined"==typeof btoa);function b(e){return y?h.byteLength(e,"utf8"):new Blob([e]).size}function x(e){if(y)return h.from(e).toString("base64");let t=new Uint8Array(e),r="";for(let e=0,n=t.length;e<n;e++)r+=String.fromCharCode(t[e]);return btoa(r)}function v(e){if(y){let t=h.from(e,"base64");return t.buffer.slice(t.byteOffset,t.byteOffset+t.byteLength)}let t=atob(e),r=new Uint8Array(t.length);for(let e=0;e<t.length;++e)r.set([t.charCodeAt(e)],e);return r.buffer}function w(e){return o.D.join(e)}function T(e){for(e=e.trim();e.endsWith("/");)e=e.slice(0,e.length-1);let t=e.split("/");return t[t.length-1]}function S(e,t){let r={modelTopology:e.modelTopology,format:e.format,generatedBy:e.generatedBy,convertedBy:e.convertedBy,weightsManifest:t};return null!=e.signature&&(r.signature=e.signature),null!=e.userDefinedMetadata&&(r.userDefinedMetadata=e.userDefinedMetadata),null!=e.modelInitializer&&(r.modelInitializer=e.modelInitializer),null!=e.initializerSignature&&(r.initializerSignature=e.initializerSignature),null!=e.trainingConfig&&(r.trainingConfig=e.trainingConfig),r}function N(e,t,r){let n={modelTopology:e.modelTopology,format:e.format,generatedBy:e.generatedBy,convertedBy:e.convertedBy};if(null!=e.trainingConfig&&(n.trainingConfig=e.trainingConfig),null!=e.weightsManifest){if(!t)throw Error("modelJSON has weightsManifest but weightSpecs is null");if(!r)throw Error("modelJSON has weightsManifest but weightData is null");n.weightSpecs=t,n.weightData=r}return null!=e.signature&&(n.signature=e.signature),null!=e.userDefinedMetadata&&(n.userDefinedMetadata=e.userDefinedMetadata),null!=e.modelInitializer&&(n.modelInitializer=e.modelInitializer),null!=e.initializerSignature&&(n.initializerSignature=e.initializerSignature),n}async function k(e,t){let r,n;return null!=e.weightsManifest&&([r,n]=await t(e.weightsManifest)),N(e,r,n)}function I(e){if(e.modelTopology instanceof ArrayBuffer)throw Error("Expected JSON model topology, received ArrayBuffer.");return{dateSaved:new Date,modelTopologyType:"JSON",modelTopologyBytes:null==e.modelTopology?0:b(JSON.stringify(e.modelTopology)),weightSpecsBytes:null==e.weightSpecs?0:b(JSON.stringify(e.weightSpecs)),weightDataBytes:null==e.weightData?0:new o.D(e.weightData).byteLength}}function C(e){let t=[];for(let r of e)t.push(...r.weights);return t}},3491:(e,t,r)=>{"use strict";r.d(t,{G:()=>s});var n=r(51520);class a{constructor(e,t,r,a,s,i){this.separator=n.ZSL.encodeString(e),this.nGramWidths=t,this.leftPad=n.ZSL.encodeString(r),this.rightPad=n.ZSL.encodeString(a),this.padWidth=s,this.preserveShort=i}getPadWidth(e){return Math.min(this.padWidth<0?e-1:this.padWidth,e-1)}getNumNGrams(e,t){return Math.max(0,e+2*this.getPadWidth(t)-t+1)}createNGrams(e,t,r,n,a,s){for(let i=0;i<a;++i){let o,l=this.getPadWidth(s),u=Math.max(0,l-i),h=Math.max(0,l-(a-(i+1))),p=s-(u+h),d=t+(u>0?0:i-l);o=0+u*this.leftPad.length;for(let t=0;t<p;++t)o+=e[d+t].length;o+=h*this.rightPad.length,o+=(u+h+p-1)*this.separator.length,r[n+i]=new Uint8Array(o);let c=r[n+i],f=0,m=e=>
1e.forEach(e=>c[f++]=e);for(let e=0;e<u;++e)m(this.leftPad),m(this.separator);for(let t=0;t<p-1;++t)m(e[d+t]),m(this.separator);if(p>0){m(e[d+p-1]);for(let e=0;e<h;++e)m(this.separator),m(this.rightPad)}else{for(let e=0;e<h-1;++e)m(this.rightPad),m(this.separator);m(this.rightPad)}}}compute(e,t){let r=e.length,a=t.length;if(a>0){let e=t[0];if(0!==e)throw Error(`First split value must be 0, got ${e}`);for(let n=1;n<a;++n){let a=t[n]>=e;if(!(a=a&&t[n]<=r))throw Error(`Invalid split value ${t[n]}, must be in [${e}, ${r}]`);e=t[n]}if(e!==r)throw Error(`Last split value must be data size. Expected ${r}, got ${e}`)}let s=a-1,i=n.ZSL.getArrayFromDType("int32",a);if(0===r||0===a){let e=Array(r);for(let e=0;e<=s;++e)i[e]=0;return[e,i]}i[0]=0;for(let e=1;e<=s;++e){let r=t[e]-t[e-1],n=0;this.nGramWidths.forEach(e=>{n+=this.getNumNGrams(r,e)}),this.preserveShort&&r>0&&0===n&&(n=1),i[e]=i[e-1]+n}let o=Array(i[s]);for(let r=0;r<s;++r){let n=t[r],a=i[r];if(this.nGramWidths.forEach(s=>{let i=t[r+1]-t[r],l=this.getNumNGrams(i,s);this.createNGrams(e,n,o,a,l,s),a+=l}),this.preserveShort&&a===i[r]){let s=t[r+1]-t[r];if(0===s)continue;let i=s+2*this.padWidth;this.createNGrams(e,n,o,a,1,i)}}return[o,i]}}function s(e,t,r,n,s,i,o,l){return new a(r,n,s,i,o,l).compute(e,t)}},3751:(e,t,r)=>{"use strict";r.d(t,{Hc:()=>l,vS:()=>i});var n=r(51520),a=r(81600),s=r(87095);let i=(0,a.o)(e=>Math.floor(e)),o=(0,s.F)(n.ZgB,i),l={kernelName:n.ZgB,backendName:"cpu",kernelFunc:o}},3974:(e,t,r)=>{"use strict";r.d(t,{D:()=>a});var n=r(51520);function a(e,t){let r=Array(e.rank);for(let n=0;n<r.length;n++)r[n]=e.shape[n]*t[n];let a=(0,n.ra8)(r,e.dtype);for(let t=0;t<a.values.length;++t){let r=a.indexToLoc(t),n=Array(e.rank);for(let t=0;t<n.length;t++)n[t]=r[t]%e.shape[t];let s=e.locToIndex(n);a.values[t]=e.values[s]}return a}},5051:(e,t,r)=>{"use strict";r.d(t,{z:()=>o});var n=r(19041),a=r(48592),s=r(27924),i=r(76526);let o=(0,r(62176).op)({unsortedSegmentSum_:function(e,t,r){let o=(0,s.YT)(e,"x","unsortedSegmentSum"),l=(0,s.YT)(t,"segmentIds","unsortedSegmentSum","int32");return(0,i.vA)((0,i.E6)(r),()=>"numSegments must be of dtype int"),n.T2.runKernel(a.pPe,{x:o,segmentIds:l},{numSegments:r})}})},5565:(e,t,r)=>{"use strict";r.d(t,{x:()=>g});var n=r(27924),a=r(76526),s=r(13825),i=r(61727),o=r(79459),l=r(61541),u=r(62176),h=r(25351),p=r(68567),d=r(30319),c=r(76125),f=r(20160),m=r(60966);let g=(0,u.op)({norm_:function(e,t="euclidean",r=null,u=!1){let g=function e(t,r,n=null){if(0===t.rank)return(0,s.t)(t);if(1!==t.rank&&null===n)return e((0,p.t)(t,[-1]),r,n);if(1===t.rank||"number"==typeof n||Array.isArray(n)&&1===n.length){if(1===r)return(0,m.c)((0,s.t)(t),n);if(r===1/0)return(0,o.T)((0,s.t)(t),n);if(r===-1/0)return(0,l.j)((0,s.t)(t),n);if("euclidean"===r||2===r)return(0,c.R)((0,m.c)((0,h.n)((0,s.t)(t),(0,d.d)(2,"int32")),n));throw Error(`Error in norm: invalid ord value: ${r}`)}if(Array.isArray(n)&&2===n.length){if(1===r)return(0,o.T)((0,m.c)((0,s.t)(t),n[0]),n[1]-1);if(r===1/0)return(0,o.T)((0,m.c)((0,s.t)(t),n[1]),n[0]);if(r===-1/0)return(0,l.j)((0,m.c)((0,s.t)(t),n[1]),n[0]);if("fro"===r||"euclidean"===r)return(0,c.R)((0,m.c)((0,f.E)(t),n));throw Error(`Error in norm: invalid ord value: ${r}`)}throw Error(`Error in norm: invalid axis: ${n}`)}(e=(0,n.YT)(e,"x","norm"),t,r),y=g.shape;if(u){let t=(0,a.Y6)(r,e.shape);y=i.SM(g.shape,t)}return(0,p.t)(g,y)}})},6025:(e,t,r)=>{"use strict";function n(e){return e instanceof Float32Array||e instanceof Int32Array||e instanceof Uint8Array||e instanceof Uint8ClampedArray}r.d(t,{Y:()=>n})},6053:(e,t,r)=>{"use strict";r.d(t,{y:()=>i});var n=r(19041),a=r(48592),s=r(27924);let i=(0,r(62176).op)({isNaN_:function(e){let t=(0,s.YT)(e,"x","isNaN");return n.T2.runKernel(a.iPs,{x:t})}})},6322:(e,t,r)=>{"use strict";r.d(t,{N:()=>s,X:()=>a});var n=r(51520);function a(e,t,r,a,s){let i=n.ZSL.sizeFromShape(a),o=n.ZSL.makeZerosTypedArray(s,r);for(let r=0;r<e.length;r++){let n=e[r];if(n<0)throw Error("Input x must be non-negative!");n>=s||(i>0?o[n]+=t[r]:o[n]+=1)}return o}function s(e,t,r,a=!1){let i=e.shape[0],o=e.shape[1],l=(0,n.ra8)([i,r],t.dtype);for(let n=0;n<i;n++)for(let s=0;s<o;s++){let i=e.get(n,s);if(i<0)throw Error("Input x must be non-negative!");i>=r||(a?l.set(1,n,i):t.size>0?l.set(l.get(n,i)+t.get(n,s),n,i):l.set(l.get(n,i)+1,n,i))}return l}},6726:(e,t,r)=>{"use strict";r.d(t,{e:()=>h});var n=r(50124),a=r(27924),s=r(13062),i=r(12989),o=r(62176),l=r(82198),u=r(79320);let h=(0,o.op)({divNoNan_:function(e,t){let r=(0,a.YT)(e,"a","div"),o=(0,a.YT)(t,"b","div");[r,o]=(0,n.makeTypesMatch)(r,o);let h=(0,s.y)(r,o),p=(0,u.P)(h),d=(0,i.L)(o,p);return(0,l._)(d,p,h)}})},6843:(e,t,r)=>{"use strict";r.d(t,{m:()=>i});var n=r(71553),a=r(25223),s=r(90670);class i{constructor(e){if(this.variableNames=["A"],this.packedInputs=!1,this.packedOutput=!0,this.outputShape=e,this.rank=e.length,this.enableShapeUniforms=(0,n.ik)(this.outputShape.length),0===this.rank)this.userCode=` 2 void main() { 3 setOutput(vec4(getA(), 0., 0., 0.)); 4 } 5 `;else{let e=(0,a.Jp)("rc",this.rank),t=(0,s.bf)(this.rank),r=this.getOutOfBoundsCondition(e),n=this.getSetup(e),i=this.getOutput(e);this.userCode=` 6 void main() { 7 ${t} rc = getOutputCoords(); 8 9 if(${r}) { 10 setOutput(vec4(0)); 11 } else { 12 ${n} 13 14 setOutput(vec4(${i})); 15 } 16 } 17 `}}getSourceCoordsArr(e){let t=[];for(let r=0;r<=1;r++)for(let n=0;n<=1;n++){let a=`${0===r?"r":"rp1"}, ${0===n?"c":"cp1"}`;for(let t=2;t<this.rank;t++)a=`${e[e.length-1-t]},`+a;t.push(a)}return t}getOutOfBoundsCondition(e){if(1===this.rank)return`rc > ${this.enableShapeUniforms?"outShape":this.outputShape[0]}`;let t="";for(let r=this.rank-2;r<this.rank;r++)t+=`${e[r]} >= ${this.enableShapeUniforms?`outShape[${r}]`:this.outputShape[r]}`,r<this.rank-1&&(t+="||");return t}getSetup(e){if(1===this.rank)return"";let t=e.slice(-2),r=this.enableShapeUniforms?`outShape[${this.rank} - 1]`:this.outputShape[this.rank-1],n=this.enableShapeUniforms?`outShape[${this.rank} - 2]`:this.outputShape[this.rank-2];return` 18 int r = ${t[0]}; 19 int c = ${t[1]}; 20 int rp1 = r + 1; 21 int cp1 = c + 1; 22 23 bool cEdge = cp1 >= ${r}; 24 bool rEdge = rp1 >= ${n}; 25 `}getOutput(e){let t=this.getSourceCoordsArr(e);if(1===this.rank){let e=this.enableShapeUniforms?"outShape":this.outputShape[0];return`getA(rc), (rc + 1 >= ${e} ? 0. : getA(rc + 1)), 0, 0`}return`getA(${t[0]}), 26 cEdge ? 0. : getA(${t[1]}),
27 rEdge ? 0. : getA(${t[2]}), 28 rEdge || cEdge ? 0. : getA(${t[3]})`}}},7487:(e,t,r)=>{"use strict";r.d(t,{U:()=>o});var n=r(19041),a=r(48592),s=r(27924),i=r(76526);let o=(0,r(62176).op)({expandDims_:function(e,t=0){let r=(0,s.YT)(e,"x","expandDims","string_or_numeric");return i.vA(t<=r.rank,()=>"Axis must be <= rank of the tensor"),n.T2.runKernel(a.ybN,{input:r},{dim:t})}})},7917:(e,t,r)=>{"use strict";r.d(t,{DE:()=>function e(t,r){return n.DZQ(()=>null==t?null:Array.isArray(t)?t.map(t=>e(t,r)):(0,a.kg)(t,"int32"===r.dtype?r:n.wgE(r,"int32")))},Ec:()=>u,Pe:()=>i,XX:()=>o,n4:()=>l,yy:()=>s});var n=r(51520),a=r(90556);function s(e){n.ZSL.assert(e>0&&Number.isInteger(e),()=>`batchSize is required to be a positive integer, but got ${e}`)}function i(e,t,r){return null==e?[null]:Array.isArray(e)?e.map(e=>(0,a.Dh)(e,t,r-t)):(0,a.Dh)(e,t,r-t)}function o(e,t){let r=[],n=0,a=null;for(;n<e;)(a=n+t)>=e&&(a=e),r.push([n,a]),n=a;return r}function l(e){let t=[];e instanceof n.qYS&&(e=[e]);for(let r=0;r<e.length;++r){let n=e[r];if(1===n.rank)t.push((0,a.UG)(n,1));else if(0===n.rank)throw Error("Expected tensor to be at least 1D, but received a 0D tensor (scalar).");else t.push(n)}return t}function u(e,t){if(null==e)return;let r=[];if(t instanceof n.qYS)r.push(t.id);else if(Array.isArray(t))t.forEach(e=>r.push(e.id));else if(null!=t)for(let e in t){let n=t[e];r.push(n.id)}let a=[];if(e instanceof n.qYS)-1===r.indexOf(e.id)&&a.push(e);else if(Array.isArray(e))e.forEach(e=>{-1===r.indexOf(e.id)&&a.push(e)});else if(null!=e)for(let t in e){let n=e[t];-1===r.indexOf(n.id)&&a.push(n)}a.forEach(e=>{e.isDisposed||e.dispose()})}},8025:(e,t,r)=>{"use strict";r.d(t,{q:()=>h});var n=r(51520),a=r(1560),s=r(97344),i=r(14811);class o{constructor(e){this.seed=e}next(){if(void 0!==this.seed)return this.seed++}}o.className="RandomSeed";class l extends i.Wd{constructor(e){super(e),this.randomGenerator=new o(e.seed)}getConfig(){let e={seed:this.randomGenerator.seed};return Object.assign(e,super.getConfig()),e}}l.className="BaseRandomLayer";let u=new Set(["bilinear","nearest"]);class h extends l{constructor(e){super(e);let{factor:t,interpolation:r="bilinear"}=e;if(this.factor=t,Array.isArray(this.factor)&&2===this.factor.length)this.widthLower=this.factor[0],this.widthUpper=this.factor[1];else if(!Array.isArray(this.factor)&&this.factor>0)this.widthLower=-this.factor,this.widthUpper=this.factor;else throw new s.Qp(`Invalid factor: ${this.factor}. Must be positive number or tuple of 2 numbers`);if(this.widthLower<-1||this.widthUpper<-1)throw new s.Qp(`factor must have values larger than -1. Got: ${this.factor}`);if(this.widthUpper<this.widthLower)throw new s.Qp(`factor cannot have upper bound less than lower bound. 29 Got upper bound: ${this.widthUpper}. 30 Got lower bound: ${this.widthLower} 31 `);if(r)if(u.has(r))this.interpolation=r;else throw new s.Qp(`Invalid interpolation parameter: ${r} is not implemented`)}getConfig(){let e={factor:this.factor,interpolation:this.interpolation};return Object.assign(e,super.getConfig()),e}computeOutputShape(e){let t=(e=(0,a.U$)(e))[2];return[this.imgHeight,-1,t]}call(e,t){return(0,n.DZQ)(()=>{let t=(0,a.un)(e);this.imgHeight=t.shape[t.shape.length-3];let r=t.shape[t.shape.length-2];this.widthFactor=(0,n.YeY)([1],1+this.widthLower,1+this.widthUpper,"float32",this.randomGenerator.next());let s=this.widthFactor.dataSync()[0]*r;s=Math.round(s);let i=[this.imgHeight,s];switch(this.interpolation){case"bilinear":return n.Slp.resizeBilinear(e,i);case"nearest":return n.Slp.resizeNearestNeighbor(e,i);default:throw Error(`Interpolation is ${this.interpolation} 32 but only ${[...u]} are supported`)}})}}h.className="RandomWidth",n.JFn.registerClass(h)},8319:(e,t,r)=>{"use strict";r.d(t,{b:()=>i});var n=r(19041),a=r(48592),s=r(27924);let i=(0,r(62176).op)({any_:function(e,t=null,r=!1){let i=(0,s.YT)(e,"x","any","bool");return n.T2.runKernel(a.FSt,{x:i},{axis:t,keepDims:r})}})},8341:(e,t,r)=>{"use strict";r.d(t,{Lt:()=>l,Zy:()=>i});var n=r(51520),a=r(81600),s=r(87095);let i=(0,a.o)(e=>1/Math.sqrt(e)),o=(0,s.F)(n.TOR,i),l={kernelName:n.TOR,backendName:"cpu",kernelFunc:o}},8404:(e,t,r)=>{"use strict";r.d(t,{UM:()=>u,eR:()=>o,ex:()=>l});var n=r(51520),a=r(3047),s=r(15034);r(97344);let i="Variable";class o{constructor(e,t="float32",r=i,o=!0,l=null){this.dtype=null==t?"float32":t,this.shape=e.shape,this.id=(0,a.j)(),r=null==r?i:r,this.originalName=(0,s.BC)(r),this.name=(0,s.Uc)(this.originalName),this.trainable_=o,this.constraint=l,this.val=n.bvq(e,this.trainable_,this.name,this.dtype)}read(){return this.assertNotDisposed(),this.val}write(e){return this.assertNotDisposed(),function(e,t){if(e.shape.toString()!==t.shape.toString())throw Error("Shape mismatch: "+JSON.stringify(e.shape)+" vs. "+JSON.stringify(t.shape))}(this.val,e),this.val.id!==e.id&&(this.val.assign(e),null!=this.constraint&&this.val.assign(this.constraint.apply(this.val))),this}dispose(){this.assertNotDisposed(),this.val.dispose()}
32assertNotDisposed(){if(this.val.isDisposed)throw Error(`LayersVariable ${this.name} is already disposed.`)}get trainable(){return this.trainable_}set trainable(e){this.trainable_=e,this.val.trainable=e}}function l(e){return e.map(e=>e.read())}function u(e){e.forEach(e=>{e[0].write(e[1])})}},8785:(e,t,r)=>{"use strict";r.d(t,{DE:()=>l,YZ:()=>m,sQ:()=>h,uH:()=>c,vJ:()=>p,xS:()=>u});var n=r(51520),a=r(73187),s=r(82692);function i(e,t){return(0,n.DZQ)(()=>n.RZD(n.czq(n.lKK(e,e),t,!0)))}class o extends n.JFn.Serializable{getConfig(){return{}}}class l extends o{constructor(e){super(),this.defaultMaxValue=2,this.defaultAxis=0,this.maxValue=null!=e.maxValue?e.maxValue:this.defaultMaxValue,this.axis=null!=e.axis?e.axis:this.defaultAxis}apply(e){return(0,n.DZQ)(()=>{let t=i(e,this.axis),r=n.zQh(t,0,this.maxValue);return n.lKK(e,n.y4m(r,n.WQq((0,a.Ni)(),t)))})}getConfig(){return{maxValue:this.maxValue,axis:this.axis}}}l.className="MaxNorm",n.JFn.registerClass(l);class u extends o{constructor(e){super(),this.defaultAxis=0,this.axis=null!=e.axis?e.axis:this.defaultAxis}apply(e){return(0,n.DZQ)(()=>n.y4m(e,n.WQq((0,a.Ni)(),i(e,this.axis))))}getConfig(){return{axis:this.axis}}}u.className="UnitNorm",n.JFn.registerClass(u);class h extends o{apply(e){return n.VVh(e)}}h.className="NonNeg",n.JFn.registerClass(h);class p extends o{constructor(e){super(),this.defaultMinValue=0,this.defaultMaxValue=1,this.defaultRate=1,this.defaultAxis=0,this.minValue=null!=e.minValue?e.minValue:this.defaultMinValue,this.maxValue=null!=e.maxValue?e.maxValue:this.defaultMaxValue,this.rate=null!=e.rate?e.rate:this.defaultRate,this.axis=null!=e.axis?e.axis:this.defaultAxis}apply(e){return(0,n.DZQ)(()=>{let t=i(e,this.axis),r=n.WQq(n.lKK(this.rate,n.zQh(t,this.minValue,this.maxValue)),n.lKK(1-this.rate,t));return n.lKK(e,n.y4m(r,n.WQq((0,a.Ni)(),t)))})}getConfig(){return{minValue:this.minValue,maxValue:this.maxValue,rate:this.rate,axis:this.axis}}}p.className="MinMaxNorm",n.JFn.registerClass(p);let d={maxNorm:"MaxNorm",minMaxNorm:"MinMaxNorm",nonNeg:"NonNeg",unitNorm:"UnitNorm"};function c(e){return(0,s.k4)(e)}function f(e,t={}){return(0,s.Xv)(e,n.JFn.SerializationMap.getMap().classNameMap,t,"constraint")}function m(e){return null==e?null:"string"==typeof e?f({className:e in d?d[e]:e,config:{}}):e instanceof o?e:f(e)}},9706:(e,t,r)=>{"use strict";r.d(t,{K:()=>o});var n=r(67108),a=r(71553),s=r(82859),i=r(60217);class o{constructor(e){this.variableNames=["A"],this.packedInputs=!1,this.packedOutput=!0,this.outPackingScheme=i.BB.DENSE,this.customUniforms=[{name:"texShape",type:"ivec2"}];let t=(0,n.B)();this.outputShape=e,this.enableShapeUniforms=(0,a.ik)(this.outputShape.length),this.userCode=` 33 ivec3 outCoordsFromFlatIndex(int index) { 34 ${this.enableShapeUniforms?s.WA(["r","c","d"],e):s.UG(["r","c","d"],e)} 35 return ivec3(r, c, d); 36 } 37 38 void main() { 39 ivec2 resTexRC = ivec2(resultUV.yx * vec2(texShape[0], texShape[1])); 40 int index = 4 * (resTexRC.x * texShape[1] + resTexRC.y); 41 42 vec4 result = vec4(0.); 43 44 for (int i=0; i<4; i++) { 45 int flatIndex = index + i; 46 ivec3 rc = outCoordsFromFlatIndex(flatIndex); 47 result[i] = getA(rc.x, rc.y, rc.z); 48 } 49 50 ${t.output} = result; 51 } 52 `}}},10551:(e,t,r)=>{"use strict";r.d(t,{Dv:()=>o,_X:()=>d,jY:()=>u,mu:()=>h,ok:()=>l,y7:()=>p});var n=r(19041),a=r(60218),s=r(27924),i=r(76526);function o(e){return i.vA(i.Tn(e),()=>"The f passed in grad(f) must be a function"),(t,r)=>{let a=(0,s.YT)(t,"x","tf.grad","string_or_numeric"),o=null!=r?(0,s.YT)(r,"dy","tf.grad"):null;return n.T2.tidy(()=>{let{value:t,grads:r}=n.T2.gradients(()=>e(a),[a],o);return null!=o&&i.O3(t.shape,o.shape,"The shape of dy passed in grad(f)(x, dy) must match the shape returned by f(x)"),c(r),r[0]})}}function l(e){return i.vA(i.Tn(e),()=>"The f passed in grads(f) must be a function"),(t,r)=>{i.vA(Array.isArray(t),()=>"The args passed in grads(f)(args) must be an array of `Tensor`s or `TensorLike`s");let a=(0,s.j1)(t,"args","tf.grads","string_or_numeric"),o=null!=r?(0,s.YT)(r,"dy","tf.grads"):null;return n.T2.tidy(()=>{let{value:t,grads:r}=n.T2.gradients(()=>e(...a),a,o);return null!=o&&i.O3(t.shape,o.shape,"The shape of dy passed in grads(f)([x1,...], dy) must match the shape returned by f([x1,...])"),c(r),r})}}function u(e){return i.vA(i.Tn(e),()=>"The f passed in valueAndGrad(f) must be a function"),(t,r)=>{i.vA(t instanceof a.qY,()=>"The x passed in valueAndGrad(f)(x) must be a tensor"),i.vA(null==r||r instanceof a.qY,()=>"The dy passed in valueAndGrad(f)(x, dy) must be a tensor");let{grads:s,value:o}=n.T2.gradients(()=>e(t),[t],r);return c(s),{grad:s[0],value:o}}}function h(e){return i.vA(i.Tn(e),()=>"The f passed in valueAndGrads(f) must be a function"),(t,r)=>{i.vA(Array.isArray(t)&&t.every(e=>e instanceof a.qY),()=>"The args passed in valueAndGrads(f)(args) must be array of tensors"),i.vA(null==r||r instanceof a.qY,()=>"The dy passed in valueAndGrads(f)(args, dy) must be a tensor");let s=n.T2.gradients(()=>e(...t),t,r);return null!=r&&i.O3(s.value.shape,r.shape,"The shape of dy passed in valueAndGrads(f)([x1,...], dy) must match the shape returned by f([x1,...])"),c(s.grads),s}}function p(e,t){i.vA(i.Tn(e),()=>"The f passed in variableGrads(f) must be a function"),i.vA(null==t||Array.isArray(t)&&t.every(e=>e instanceof a.rT),()=>"The varList passed in variableGrads(f, varList) must be an array of variables");let r=null!=t;if(!r)for(let e in t=[],n.T2.registeredVariables)t.push(n.T2.registeredVariables[e]);let s=r?t.filter(e=>!e.trainable):null,o=t.length;t=t.filter(e=>e.trainable),i.vA(t.length>0,()=>`variableGrads() expects at least one of the input variables to be trainable, but none of the ${o} variables is trainable.`);let{value:l,grads:u}=n.T2.gradients(e,t,null,!0);i.vA(u.some(e=>null!=e),()=>"Cannot find a connection between any variable and the result of the loss function y=f(x). Please make sure the operations that use variables are inside the function f passed to minimize()."),i.vA(0===l.rank,()=>`The f passed in variableGrads(f) must return a scalar, but it returned a rank-${l.rank} tensor`);let h={};return t.forEach((e,t)=>{null!=u[t]&&(h[e.name]=u[t])}
52),null!=s&&s.forEach(e=>h[e.name]=null),{value:l,grads:h}}function d(e){return n.T2.customGrad(e)}function c(e){if(e.filter(e=>null==e).length>0)throw Error(`Cannot compute gradient of y=f(x) with respect to x. Make sure that 53 the f you passed encloses all operations that lead from x to y.`)}},10627:(e,t,r)=>{"use strict";function n(e,t){return e>t?1:e<t?-1:0}function a(e,t,r,n,a){return o(e,t,r,n,a,0)}function s(e,t,r,n,a,s){return o(e,t,r,n,a,0,!1,s,!0)}function i(e,t,r,n,a,s){return o(e,t,r,n,a,s,!0)}function o(e,t,r,a,s,i,u=!1,h=!1,p=!1){let d=[];for(let e=0;e<t.length;e++)t[e]>s&&d.push({score:t[e],boxIndex:e,suppressBeginIndex:0});d.sort(l);let c=i>0?-.5/i:0,f=[],m=[];for(;f.length<r&&d.length>0;){let t=d.pop(),{score:r,boxIndex:i,suppressBeginIndex:o}=t;if(r<s)break;let u=!1;for(let r=f.length-1;r>=o;--r){let n=function(e,t,r){let n=e.subarray(4*t,4*t+4),a=e.subarray(4*r,4*r+4),s=Math.min(n[0],n[2]),i=Math.min(n[1],n[3]),o=Math.max(n[0],n[2]),l=Math.max(n[1],n[3]),u=Math.min(a[0],a[2]),h=Math.min(a[1],a[3]),p=Math.max(a[0],a[2]),d=Math.max(a[1],a[3]),c=(o-s)*(l-i),f=(p-u)*(d-h);if(c<=0||f<=0)return 0;let m=Math.max(Math.min(o,p)-Math.max(s,u),0)*Math.max(Math.min(l,d)-Math.max(i,h),0);return m/(c+f-m)}(e,i,f[r]);if(n>=a){u=!0;break}if(t.score=t.score*function(e,t,r){let n=Math.exp(t*r*r);return r<=e?n:0}(a,c,n),t.score<=s)break}t.suppressBeginIndex=f.length,!u&&(t.score===r?(f.push(i),m.push(t.score)):t.score>s&&function(e,t,r){let a=function(e,t,r){let n=0,a=e.length,s=0,i=!1;for(;n<a;){let o=r(t,e[s=n+(a-n>>>1)]);o>0?n=s+1:(a=s,i=!o)}return i?n:-n-1}(e,t,r||n);e.splice(a<0?-(a+1):a,0,t)}(d,t,l))}let g=f.length,y=r-g;h&&y>0&&(f.push(...Array(y).fill(0)),m.push(...Array(y).fill(0)));let b={selectedIndices:f};return u&&(b.selectedScores=m),p&&(b.validOutputs=g),b}function l(e,t){return e.score-t.score||e.score===t.score&&t.boxIndex-e.boxIndex}r.d(t,{c7:()=>a,ZS:()=>s,ut:()=>i})},10874:(e,t,r)=>{"use strict";r.d(t,{p:()=>i});var n=r(51520),a=r(20783),s=r(60217);class i{constructor(e){this.gpgpu=e,this.numUsedTextures=0,this.numFreeTextures=0,this._numBytesAllocated=0,this._numBytesFree=0,this.freeTextures={},this.usedTextures={},this.logEnabled=!1}acquireTexture(e,t,r){let n,a=l(t,r),i=u(e,a,r);i in this.freeTextures||(this.freeTextures[i]=[]),i in this.usedTextures||(this.usedTextures[i]=[]);let h=o(e,a,this.gpgpu.gl,this.gpgpu.textureConfig,r);if(this.freeTextures[i].length>0){this.numFreeTextures--,this.numUsedTextures++,this._numBytesFree-=h,this.log();let e=this.freeTextures[i].pop();return this.usedTextures[i].push(e),e}return a===s.j.PACKED_2X2_FLOAT32?n=this.gpgpu.createPackedMatrixTexture(e[0],e[1]):a===s.j.PACKED_2X2_FLOAT16?n=this.gpgpu.createFloat16PackedMatrixTexture(e[0],e[1]):a===s.j.UNPACKED_FLOAT32?n=this.gpgpu.createFloat32MatrixTexture(e[0],e[1]):a===s.j.UNPACKED_FLOAT16?n=this.gpgpu.createFloat16MatrixTexture(e[0],e[1]):a===s.j.PACKED_4X1_UNSIGNED_BYTE&&(n=this.gpgpu.createUnsignedBytesMatrixTexture(e[0],e[1])),this.usedTextures[i].push(n),this.numUsedTextures++,this._numBytesAllocated+=h,this.log(),n}releaseTexture(e,t,r,a){if(null==this.freeTextures)return;let s=l(r,a),i=u(t,s,a);i in this.freeTextures||(this.freeTextures[i]=[]);let h=o(t,s,this.gpgpu.gl,this.gpgpu.textureConfig,a),p=(0,n._K2)().getNumber("WEBGL_DELETE_TEXTURE_THRESHOLD");-1!==p&&this._numBytesAllocated>p?(this.gpgpu.deleteMatrixTexture(e.texture),this._numBytesAllocated-=h):(this.freeTextures[i].push(e),this.numFreeTextures++,this._numBytesFree+=h),this.numUsedTextures--;let d=this.usedTextures[i],c=d&&d.indexOf(e);if(null==c||c<0)throw Error("Cannot release a texture that was never provided by this texture manager");d[c]=d[d.length-1],d.pop(),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(null!=this.freeTextures){for(let e in this.freeTextures)this.freeTextures[e].forEach(e
53=>{this.gpgpu.deleteMatrixTexture(e.texture)});for(let e in this.usedTextures)this.usedTextures[e].forEach(e=>{this.gpgpu.deleteMatrixTexture(e.texture)});this.freeTextures=null,this.usedTextures=null,this.numUsedTextures=0,this.numFreeTextures=0,this._numBytesAllocated=0,this._numBytesFree=0}}}function o(e,t,r,n,i){let o,l=function(e,t){switch(e){case s.j.PACKED_2X2_FLOAT32:return(0,a.getInternalFormatForPackedMatrixTexture)(t);case s.j.PACKED_2X2_FLOAT16:return(0,a.getInternalFormatForFloat16PackedMatrixTexture)(t);case s.j.UNPACKED_FLOAT32:return(0,a.getInternalFormatForFloat32MatrixTexture)(t);case s.j.UNPACKED_FLOAT16:return(0,a.getInternalFormatForFloat16MatrixTexture)(t);case s.j.PACKED_4X1_UNSIGNED_BYTE:return(0,a.getInternalFormatForUnsignedBytesMatrixTexture)(t);default:throw Error(`Unknown physical texture type ${e}`)}}(t,n);if(i){let[t,r]=(0,s.NO)(e[0],e[1]);o=t*r}else{let[t,r]=(0,s.Qn)(e[0],e[1]);o=t*r}return o*function(e,t){if(t===e.R32F)return 4;if(t===e.R16F)return 2;if(t===e.RGBA32F)return 16;if(t===e.RGBA)return 16;if(t===e.RGBA16F)return 8;else if(t===e.RGBA8)return 4;throw Error(`Unknown internal format ${t}`)}(r,l)}function l(e,t){if(e===s.tT.UPLOAD)return s.j.PACKED_2X2_FLOAT32;if(e===s.tT.RENDER||null==e)return(0,n._K2)().getBool("WEBGL_RENDER_FLOAT32_ENABLED")?t?s.j.PACKED_2X2_FLOAT32:s.j.UNPACKED_FLOAT32:t?s.j.PACKED_2X2_FLOAT16:s.j.UNPACKED_FLOAT16;if(e===s.tT.DOWNLOAD||e===s.tT.PIXELS)return s.j.PACKED_4X1_UNSIGNED_BYTE;throw Error(`Unknown logical texture type ${e}`)}function u(e,t,r){return`${e[0]}_${e[1]}_${t}_${r}`}},12507:(e,t,r)=>{"use strict";r.d(t,{q:()=>a});var n=r(51520);function a(e,t,r,a){let s=e===t,i=e<t&&r<0,o=t<e&&r>1;if(s||i||o)return n.ZSL.makeZerosTypedArray(0,a);let l=Math.abs(Math.ceil((t-e)/r)),u=n.ZSL.makeZerosTypedArray(l,a);t<e&&1===r&&(r=-1),u[0]=e;for(let e=1;e<u.length;e++)u[e]=u[e-1]+r;return u}},12534:(e,t,r)=>{"use strict";let n;r.d(t,{L:()=>s,m:()=>i});var a=r(87358);function s(){if(null==n){let e;if("undefined"!=typeof window)e=window;else if(void 0!==r.g)e=r.g;else if(void 0!==a)e=a;else if("undefined"!=typeof self)e=self;else throw Error("Could not find a global object");n=e}return n}function i(e,t){let r=function(){let e=s();return null==e._tfGlobals&&(e._tfGlobals=new Map),e._tfGlobals}();if(r.has(e))return r.get(e);{let n=t();return r.set(e,n),r.get(e)}}},12550:(e,t,r)=>{"use strict";r.d(t,{H:()=>i});var n=r(19041),a=r(48592),s=r(27924);let i=(0,r(62176).op)({leakyRelu_:function(e,t=.2){let r=(0,s.YT)(e,"x","leakyRelu");return n.T2.runKernel(a.X0$,{x:r},{alpha:t})}})},12989:(e,t,r)=>{"use strict";r.d(t,{L:()=>l});var n=r(19041),a=r(48592),s=r(50124),i=r(27924),o=r(83231);let l=(0,r(62176).op)({equal_:function(e,t){let r=(0,i.YT)(e,"a","equal","string_or_numeric"),l=(0,i.YT)(t,"b","equal","string_or_numeric");[r,l]=(0,s.makeTypesMatch)(r,l),(0,o.assertAndGetBroadcastShape)(r.shape,l.shape);let u={a:r,b:l};return n.T2.runKernel(a.BRl,u)}})},13062:(e,t,r)=>{"use strict";r.d(t,{y:()=>l});var n=r(19041),a=r(48592),s=r(50124),i=r(27924),o=r(81918);let l=(0,r(62176).op)({div_:function(e,t){let r=(0,i.YT)(e,"a","div"),l=(0,i.YT)(t,"b","div");if([r,l]=(0,s.makeTypesMatch)(r,l),"int32"===r.dtype&&"int32"===l.dtype)return(0,o.w)(r,l);let u={a:r,b:l};return n.T2.runKernel(a.sDr,u,{})}})},13825:(e,t,r)=>{"use strict";r.d(t,{t:()=>i});var n=r(19041),a=r(48592),s=r(27924);let i=(0,r(62176).op)({abs_:function(e){let t=(0,s.YT)(e,"x","abs");return"complex64"===t.dtype?n.T2.runKernel(a.$zE,{x:t}):n.T2.runKernel(a.ljI,{x:t})}})},14017:(e,t,r)=>{"use strict";r.d(t,{n:()=>i});var n=r(19041),a=r(48592),s=r(27924);let i=(0,r(62176).op)({imag_:function(e){let t=(0,s.YT)(e,"input","imag");return n.T2.runKernel(a.dv8,{input:t})}})},14027:(e,t,r)=>{"use strict";r.d(t,{V:()=>f});var n=r(27924),a=r(76526),s=r(46842),i=r(61727),o=r(25158),l=r(29659),u=r(79459),h=r(62176),p=r(68567),d=r(92263),c=r(60966);let f=(0,h.op)({logSumExp_:function(e,t=null,r=!1){let h=(0,n.YT)(e,"x","logSumExp"),f=(0,a.Y6)(t,h.shape),m=(0,u.T)(h,f,!0),g=(0,d.j)(h,m),y=(0,o.o)(g),b=(0,c.c)(y,f),x=(0,l.R)(b),v=(0,s.W)((0,p.t)(m,x.shape),x);if(r){let e=(0,i.SM)(v.shape,f);return(0,p.t)(v,e)}return v}})},14600:(e,t,r)=>{"use strict";r.r(t),r.d(t,{assertParamsValid:()=>a,computeFlatOffset:()=>y,computeOutShape:()=>i,getNormalizedAxes:()=>h,isSliceContinous:()=>g,maskToAxes:()=>s,parseSliceParams:()=>b,sliceInfo:()=>x,startForAxis:()=>f,startIndicesWithElidedDims:()=>p,stopForAxis:()=>m,stopIndicesWithElidedDims:()=>d,stridesForAxis:()=>c,stridesWithElidedDims:()=>o});var n=r(76526);function a(e,t,r){let a=e.shape.length;n.vA(a===t.length,()=>`Error in slice${a}D: Length of begin ${t} must match the rank of the array (${a}).`),n.vA(a===r.length,()=>`Error in slice${a}D: Length of size ${r} must match the rank of the array (${a}).`);for(let s=0;s<a;++s)n.vA(t[s]+r[s]<=e.shape[s],()=>`Error in slice${a}D: begin[${s}] + size[${s}] (${t[s]+r[s]}) would overflow input.shape[${s}] (${e.shape[s]})`)}function s(e){let t=[],r=0;for(;e>0;)1&e&&t.push(r),e/=2,r++;return t}function i(e,t,r){let n=[];for(let a=0;a<e.length;a++)n[a]=Math.ceil((t[a]-e[a])/r[a]);return n}function o(e,t,r,n){let a=[...e];for(let e=a.length;e<n.length;e++)a.push(1);for(let e=0;e<r;e++)0===e?a[t]=1:(a.splice(t,0,1),a.pop());return a}function l(e,t,r){return r<=e?r:r-(t-1)}function u(e,t){let r=[];for(let n=0;n<e;n++)r.push(t+n);return r}function h(e,t,r,n,a,s,i,l,u){let h=e.length,g=Array(h),y=Array(h),b=Array(h);if(t.length&&r>0){let u=t[0],h=r+1;g=p(i,u,h,n,e),y=d(l,u,h,a,e),b=o(s,u,h,e)}else for(let t=0;t<h;t++)g[t]=f(i,n,s,e,t,u),y[t]=m(l,a,s,e,t,u),b[t]=c(s,t,u);return{begin:g,end:y,strides:b}}function p(e,t,r,n,a){let s=[...a],i=u(r,t);for(let a=0;a<s.length;a++)if(i.indexOf(a)>-1)s[a]=0;else{var o,l,h;let i=(o=t,l=r,(h=a)<=o?h:h-(l-1)),u=n[i];e&1<<i&&(u=0),s[a]=u}return s}function d(e,t,r,a,s){let i=[...s],o=u(r,t);for(let n=0;n<i.length;n++)if(o.indexOf(n)>-1)i[n]=Number.MAX_SAFE_INTEGER;else{var l,h,p;let s=(l=t,h=r,(p=n)<=l?p:p-(h-1)),o=a[s];e&1<<s&&(o=Number.MAX_SAFE_INTEGER),i[n]=o}for(let e=0;e<i.length;e++){let t=s[e];i[e]<0&&(i[e]+=t),i[e]=n.qE(0,i[e],s[e])}return i}function c(e,t,r){let n=e[t];return(r&1<<t||null==n)&&(n=1),n}function f(e,t,r,a,s,i){let o=t[s],l=r[s]||1;(e&1<<s||i&1<<s||null==o)&&(o=l>0?Number.MIN_SAFE_INTEGER:Number.MAX_SAFE_INTEGER);let u=a[s];return o<0&&(o+=u),o=n.qE(0,o,u-1)}function m(e,t,r,a,s,i){let o=t[s],l=r[s]||1;(e&1<<s||i&1<<s||null==o)&&(o=l>0?Number.MAX_SAFE_INTEGER:Number.MIN_SAFE_INTEGER);let u=a[s];return o<0&&(o+=u),o=l>0?n.qE(0,o,u):n.qE(-1,o,u-1)}function g(e,t,r){let n=r.length;for(let e=0;e<r.length;e++)if(r[e]>1){n=e;break}for(let a=n+1;a<r.length;a++)if(t[a]>0||r[a]!==e[a])return!1;return!0}function y(e,t){let r=e.length>0?e[e.length-1]:1;for(let n=0;n<e.length-1;n++)r+=e[n]*t[n];return r}function b(e,t,r){let a,s,i=e.shape.length;return(a="number"==typeof t?[t,...Array(i-1).fill(0)]:t.length<i?t.concat(Array(i-t.length).fill(0)):t.slice()).forEac
53h(e=>{n.vA(-1!==e,()=>"slice() does not support negative begin indexing.")}),s=(s=null==r?Array(i).fill(-1):"number"==typeof r?[r,...Array(i-1).fill(-1)]:r.length<i?r.concat(Array(i-r.length).fill(-1)):r).map((t,r)=>t>=0?t:(n.vA(-1===t,()=>`Negative size values should be exactly -1 but got ${t} for the slice() size at index ${r}.`),e.shape[r]-a[r])),[a,s]}function x(e,t,r,n,a,s,i,o,l){let u;if(null==n?(u=Array(t.length)).fill(1):u=n,null!=i&&(i&i-1)!=0)throw Error("Multiple ellipses in slice is not allowed.");let h=!1,p={dims:u.length,numAddAxisAfterEllipsis:0,begin:t.slice(),end:r.slice(),strides:u.slice(),beginMask:a,endMask:s,ellipsisMask:i,newAxisMask:o,shrinkAxisMask:l};for(let e=0;e<p.dims;e++)h&&(1<<e&o)!=0&&p.numAddAxisAfterEllipsis++,1<<e&i&&(h=!0);!h&&(p.ellipsisMask|=1<<p.dims,p.dims++);let d={dims:e.length,beginMask:0,endMask:0,beginValid:!1,endValid:!1};var c=p,f=d;f.beginMask=0,f.endMask=0,f.shrinkAxisMask=0;let m=0;f.beginValid=null!=c.begin,f.endValid=null!=c.end,f.begin=Array(f.dims),f.end=Array(f.dims),f.strides=Array(f.dims),f.finalShapeGatherIndices=[],f.finalShapeGatherIndicesSparse=[],f.inputShapeGatherIndicesSparse=Array(f.dims);for(let e=0;e<c.dims;e++)if(1<<e&c.ellipsisMask){let t=Math.min(f.dims-(c.dims-e)+1+c.numAddAxisAfterEllipsis,f.dims);for(;m<t;m++)f.begin[m]=0,f.end[m]=0,f.strides[m]=1,f.beginMask|=1<<m,f.endMask|=1<<m,f.finalShapeGatherIndices.push(m),f.finalShapeGatherIndicesSparse.push(-1),f.inputShapeGatherIndicesSparse[m]=e}else if(1<<e&c.newAxisMask)f.finalShapeGatherIndices.push(-2),f.finalShapeGatherIndicesSparse.push(-1);else{if(m===f.begin.length)throw Error(`Index out of range using input dim ${m}; input has only ${f.dims} dims, ${f.begin.length}.`);null!=c.begin&&(f.begin[m]=c.begin[e]),null!=c.end&&(f.end[m]=c.end[e]),f.strides[m]=c.strides[e],c.beginMask&1<<e&&(f.beginMask|=1<<m),c.endMask&1<<e&&(f.endMask|=1<<m),c.shrinkAxisMask&1<<e?(f.finalShapeGatherIndices.push(-1),f.finalShapeGatherIndicesSparse.push(-1),f.shrinkAxisMask|=1<<m):(f.finalShapeGatherIndices.push(m),f.finalShapeGatherIndicesSparse.push(e)),f.inputShapeGatherIndicesSparse[m]=e,m++}let g=!0,y=!0,b=!0,x=[],w=[];for(let t=0;t<e.length;++t){let r;if(0===d.strides[t])throw Error(`strides[${t}] must be non-zero`);let n=!!(d.shrinkAxisMask&1<<t),a=e[t];if(-1===a){x.push(n?1:-1);continue}let s=[d.beginMask&1<<t,d.endMask&1<<t],i=[d.strides[t]>0?0:-1,d.strides[t]>0?a:a-1];if(n&&d.strides[t]<=0)throw Error("only stride 1 allowed on non-range indexing.");b=b&&1===d.strides[t];let o=!!(d.beginMask&1<<t&&d.endMask&1<<t);if(d.beginValid&&d.endValid){if(n){let e=d.begin[t]<0?a+d.begin[t]:d.begin[t];if(d.begin[t]=e,d.end[t]=d.begin[t]+1,e<0||e>=a)throw Error(`slice index ${d.begin[t]} of dimension ${t} out of bounds.`)}else d.begin[t]=v(d.begin[t],0,d.strides[t],a,s,i),d.end[t]=v(d.end[t],1,d.strides[t],a,s,i);let e=1===d.strides[t]&&0===d.begin[t]&&d.end[t]===a;g=g&&e,y=y&&(0===t&&1===d.strides[t]||e)}else g=g&&1===d.strides[t]&&o,y=y&&(0===t&&1===d.strides[t]||o);let l=!1;if(d.beginValid&&d.endValid?(r=d.end[t]-d.begin[t],l=!0):n?(r=1,l=!0):o&&a>=0&&(r=d.strides[t]<0?-a:a,l=!0),l){let e;e=0===r||r<0!=d.strides[t]<0?0:Math.trunc(r/d.strides[t])+ +(r%d.strides[t]!=0),x.push(e)}else x.push(-1)}for(let e=0;e<d.finalShapeGatherIndices.length;++e){let t=d.finalShapeGatherIndices[e];t>=0?w.push(x[t]):-2===t&&w.push(1)}return{finalShapeSparse:w.filter((e,t)=>-2!==d.finalShapeGatherIndices[t]),finalShape:w,isIdentity:g,sliceDim0:y,isSimpleSlice:b,begin:d.begin,end:d.end,strides:d.strides}}function v(e,t,r,n,a,s){if(a[t])return r>0?s[t]:s[t+1&1];{let t=e<0?n+e:e;return t<s[0]?s[0]:t>s[1]?s[1]:t}}},14811:(e,t,r)=>{"use strict";r.d(t,{Ar:()=>c,Wd:()=>y,X6:()=>function e(t,r,n){if((null==r||null!=n&&n>0)&&(r=t.sourceLayer,n=t.nodeIndex),0===r.inboundNodes.length)return[t];{let t=r.inboundNodes[n];if(0===t.inboundLayers.length)return t.inputTensors;{let r=[];for(let n=0;n<t.inboundLayers.length;n++){let a=t.inputTensors[n];for(let s of e(a,t.inboundLayers[n],t.nodeIndices[n]))-1===r.indexOf(s)&&r.push(s)}return r}}},bP:()=>m,eO:()=>d});var n=r(51520),a=r(3047),s=r(15034),i=r(97344),o=r(96902),l=r(82692),u=r(1560),h=r(72591),p=r(8404);class d{constructor(e){this.dtype=e.dtype,this.shape=e.shape,null!=e.shape?this.ndim=e.shape.length:this.ndim=e.ndim,this.maxNDim=e.maxNDim,this.minNDim=e.minNDim,this.axes=e.axes||{}}}class c{constructor(e,t,r,n,i,o,l){this.dtype=e,this.shape=t,this.sourceLayer=r,this.inputs=n,this.callArgs=i,this.outputTensorIndex=l,this.id=(0,a.j)(),null!=o&&(this.originalName=(0,s.BC)(o),this.name=(0,s.Uc)(this.originalName)),this.rank=t.length}}let f=0;class m{constructor(e,t){for(let r of(this.callArgs=t,this.id=f++,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,e.inboundLayers))null!=r&&r.outboundNodes.push(this);e.outboundLayer.inboundNodes.push(this)}getConfig(){let e=[];for(let t of this.inboundLayers)null!=t?e.push(t.name):e.push(null);return{outboundLayer:this.outboundLayer?this.outboundLayer.name:null,inbou
53ndLayers:e,nodeIndices:this.nodeIndices,tensorIndices:this.tensorIndices}}}let g=0;class y extends n.JFn.Serializable{constructor(e={}){super(),this._callHook=null,this._addedWeightNames=[],this._stateful=!1,this.id=g++,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 e=this.getClassName();t=l.uc(e)+"_"+(0,a.v)(e)}if(this.name=t,this.trainable_=null==e.trainable||e.trainable,null!=e.inputShape||null!=e.batchInputShape){let t;if(null!=e.batchInputShape)t=e.batchInputShape;else if(null!=e.inputShape){let r=null;null!=e.batchSize&&(r=e.batchSize),t=[r].concat(e.inputShape)}this.batchInputShape=t;let r=e.dtype;null==r&&(r=e.inputDType),null==r&&(r="float32"),this.dtype=r}null!=e.weights?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(0===this.inboundNodes.length)throw new i.bu(`The layer has never been called and thus has no defined ${t}.`);if(this.inboundNodes.length<=e)throw new i.Qp(`Asked to get ${t} at node ${e}, but the layer has only ${this.inboundNodes.length} inbound nodes.`);return this.inboundNodes[e]}getInputAt(e){return l.wL(this.getNodeAtIndex(e,"input").inputTensors)}getOutputAt(e){return l.wL(this.getNodeAtIndex(e,"output").outputTensors)}get input(){if(this.inboundNodes.length>1)throw new i.l7(`Layer ${this.name} has multiple inbound nodes, hence the notion of "layer input" is ill-defined. Use \`getInputAt(nodeIndex)\` instead.`);if(0===this.inboundNodes.length)throw new i.l7(`Layer ${this.name} is not connected, no input to return.`);return l.wL(this.getNodeAtIndex(0,"input").inputTensors)}get output(){if(0===this.inboundNodes.length)throw new i.l7(`Layer ${this.name} has no inbound nodes.`);if(this.inboundNodes.length>1)throw new i.l7(`Layer ${this.name} has multiple inbound nodes, hence the notion of "layer output" is ill-defined. Use \`getOutputAt(nodeIndex)\` instead.`);return l.wL(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 Error("Cannot call the resetStates() method of a non-stateful Layer object.")}assertInputCompatibility(e){let t=l.st(e);if(null==this.inputSpec||0===this.inputSpec.length)return;let r=l.st(this.inputSpec);if(t.length!==r.length)throw new i.Qp(`Layer ${this.name} expects ${r.length} inputs, but it received ${t.length} input tensors. Input received: ${e}`);for(let e=0;e<t.length;e++){let n=t[e],a=r[e];if(null==a)continue;let s=n.rank;if(null!=a.ndim&&s!==a.ndim)throw new i.Qp(`Input ${e} is incompatible with layer ${this.name}: expected ndim=${a.ndim}, found ndim=${s}`);if(null!=a.maxNDim&&s>a.maxNDim)throw new i.Qp(`Input ${e} is incompatible with layer ${this.name}: expected max_ndim=${a.maxNDim}, found ndim=${s}`);if(null!=a.minNDim&&s<a.minNDim)throw new i.Qp(`Input ${e} is incompatible with layer ${this.name}: expected min_ndim=${a.minNDim}, found ndim=${s}.`);if(null!=a.dtype&&n.dtype!==a.dtype)throw new i.Qp(`Input ${e} is incompatible with layer ${this.name} : expected dtype=${a.dtype}, found dtype=${n.dtype}.`);if(a.axes){let t=n.shape;for(let r in a.axes){let n=Number(r),s=a.axes[r],o=n>
53=0?t[n]:t[t.length+n];if(null!=s&&-1===[s,null].indexOf(o))throw new i.Qp(`Input ${e} is incompatible with layer ${this.name}: expected axis ${n} of input shape to have value ${s} but got shape ${t}.`)}}if(null!=a.shape)for(let t=0;t<a.shape.length;++t){let r=a.shape[t],s=n.shape[t];if(null!=r&&null!=s&&r!==s)throw new i.Qp(`Input ${e} is incompatible with layer ${this.name}: expected shape=${a.shape}, found shape=${n.shape}.`)}}}call(e,t){return e}invokeCallHook(e,t){null!=this._callHook&&this._callHook(e,t)}setCallHook(e){this._callHook=e}clearCallHook(){this._callHook=null}apply(e,t){t=t||{},this.assertNotDisposed();let r=l.st(e),n=function(e){let t=!0;for(let r of l.st(e))if(!(r instanceof c)){t=!1;break}return t}(e),a=function(e){let t=!0;for(let r of l.st(e))if(r instanceof c){t=!1;break}return t}(e);if(n===a)throw new i.Qp("Arguments to apply() must be all SymbolicTensors or all Tensors");return(0,s.IU)(this.name,()=>{if(!this.built){this.assertInputCompatibility(e);let t=[];for(let r of l.st(e))t.push(r.shape);this.build(l.wL(t)),this.built=!0,this.initialWeights&&this.setWeights(this.initialWeights),null===this._refCount&&a&&(this._refCount=1)}if(this.assertInputCompatibility(e),a){let n=this.call(e,t);this.supportsMasking&&this.setMaskMetadata(e,n);let a=l.st(n),s=[];for(let e of a)-1!==r.indexOf(e)&&(e=e.clone()),s.push(e);if(n=l.wL(s),null!=this.activityRegularizer)throw new i.EH("Layer invocation in the presence of activity regularizer(s) is not supported yet.");return n}{var n;let r,a=function(e){e=l.st(e);let t=[];for(let r of e)t.push(r.shape);return l.wL(t)}(e),s=this.computeOutputShape(a),o=(n=0,"float32");if(this.warnOnIncompatibleInputShape(Array.isArray(e)?a[0]:a),r=null!=s&&s.length>0&&Array.isArray(s[0])?s.map((r,n)=>new c(o,r,this,l.st(e),t,this.name,n)):new c(o,s,this,l.st(e),t,this.name),this.addInboundNode(e,r,null,null,a,s,t),this._refCount++,null!=this.activityRegularizer)throw new i.EH("Layer invocation in the presence of activity regularizer(s) is not supported yet.");return r}})}warnOnIncompatibleInputShape(e){if(null!=this.batchInputShape)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((r,n)=>{null!=r&&null!=e[n]&&e[n]!==r&&(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(null==this.inboundNodes||0===this.inboundNodes.length)throw new i.l7(`The layer ${this.name} has never been called and thus has no defined output shape.`);let e=[];for(let t of this.inboundNodes){let r=JSON.stringify(t.outputShapes);-1===e.indexOf(r)&&e.push(r)}if(1===e.length){let e=this.inboundNodes[0].outputShapes;return Array.isArray(e)&&Array.isArray(e[0])&&1===e.length?e[0]:e}throw new i.l7(`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 i.bu(`You tried to call countParams() on ${this.name}, but the layer is not built yet. Build it first by calling build(batchInputShape).`);return h.Y(this.weights)}build(e){this.built=!0}getWeights(e=!1){return(0,p.ex)(e?this.trainableWeights:this.weights)}setWeights(e){(0,n.DZQ)(()=>{let t=this.weights;if(t.length!==e.length)throw new i.Qp(`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(0===t.length)return;let r=[],a=(0,p.ex)(t);for(let s=0;s<a.length;++s){let o=a[s],l=t[s],u=e[s];if(!n.ZSL.arraysEqual(o.shape,u.shape))throw new i.Qp(`Layer weight shape ${o.shape} not compatible with provided weight shape ${u.shape}`);r.push([l,u])}(0,p.UM)(r)})}addWeight(e,t,r,n,a,s,l,u){if(-1!==this._addedWeightNames.indexOf(e))throw new i.Qp(`Duplicate weight name ${e} for layer ${this.name}`);this._addedWeightNames.push(e),null==r&&(r="float32"),this.fastWeightInitDuringBuild&&(n=null!=u?u():(0,o.Fe)("zeros"));let h=n.apply(t,r),d=new p.eR(h,r,e,s,l);return h.dispose(),null!=a&&this.addLoss(()=>a.apply(d.read())),null==s&&(s=!0),s?this._trainableWeights.push(d):this._nonTrainableWeights.push(d),d}setFastWeightInitDuringBuild(e){this.fastWeightInitDuringBuild=e}addLoss(e){null==e||Array.isArray(e)&&0===e.length||(e=l.st(e),void 0!==this._losses&&null!==this._losses&&this.losses.push(...e))}computeOutputShape(e){return e}computeMask(e,t){if(!this.supportsMasking){if(null!=t)if(Array.isArray(t))t.forEach(e
53=>{if(null!=e)throw TypeError(`Layer ${this.name} does not support masking, but was passed an inputMask.`)});else throw TypeError(`Layer ${this.name} does not support masking, but was passed an inputMask.`);return null}return t}setMaskMetadata(e,t,r){if(!this.supportsMasking)return;let n=this.computeMask(e,r),a=l.st(t),s=l.st(n);if(a.length!==s.length)throw Error(`${this.name} outputs ${a.length} tensors but ${a.length} masks for those tensors`);for(let e=0;e<a.length;e++)a[e].kerasMask=s[e]}addInboundNode(e,t,r,n,a,s,i=null){let o=l.st(e);t=l.st(t),r=l.st(r),n=l.st(n),a=u.FS(a),s=u.FS(s);let h=[],p=[],d=[];for(let e of o)h.push(e.sourceLayer),p.push(e.nodeIndex),d.push(e.tensorIndex);new m({outboundLayer:this,inboundLayers:h,nodeIndices:p,tensorIndices:d,inputTensors:o,outputTensors:t,inputMasks:r,outputMasks:n,inputShapes:a,outputShapes:s},i);for(let e=0;e<t.length;e++)t[e].sourceLayer=this,t[e].nodeIndex=this.inboundNodes.length-1,t[e].tensorIndex=e}getConfig(){let e={name:this.name,trainable:this.trainable};return null!=this.batchInputShape&&(e.batchInputShape=this.batchInputShape),null!=this.dtype&&(e.dtype=this.dtype),e}disposeWeights(){return this.weights.forEach(e=>e.dispose()),this.weights.length}assertNotDisposed(){if(0===this._refCount)throw Error(`Layer '${this.name}' is already disposed.`)}dispose(){if(!this.built)throw Error(`Cannot dispose Layer ${this.name} because it has not been built yet.`);if(null===this._refCount)throw Error(`Cannot dispose Layer ${this.name} because it has not been used yet.`);this.assertNotDisposed();let e=0;return 0==--this._refCount&&(e=this.disposeWeights()),{refCountAfterDispose:this._refCount,numDisposedVariables:e}}}},14958:(e,t,r)=>{"use strict";r.d(t,{AS:()=>g,DZ:()=>m,Gc:()=>v,Hi:()=>d,Hs:()=>I,IS:()=>u,ME:()=>f,Ok:()=>C,Sm:()=>o,W4:()=>N,aC:()=>y,fL:()=>h,gJ:()=>k,gY:()=>l,go:()=>S,jh:()=>x,jz:()=>w,kB:()=>b,m1:()=>c,rE:()=>T,rm:()=>p});var n=r(19041),a=r(89215),s=r(60218),i=r(50124);function o(){(0,a._K)().set("PROD",!0)}function l(){(0,a._K)().set("DEBUG",!0)}function u(){(0,a._K)().set("DEPRECATION_WARNINGS_ENABLED",!1),console.warn("TensorFlow.js deprecation warnings have been disabled.")}function h(e){(0,a._K)().getBool("DEPRECATION_WARNINGS_ENABLED")&&console.warn(e+" You can disable deprecation warnings with tf.disableDeprecationWarnings().")}function p(){n.T2.disposeVariables()}function d(){return n.T2}function c(){return n.T2.memory()}function f(e){return n.T2.profile(e)}function m(e,t){return n.T2.tidy(e,t)}function g(e){(0,i.getTensorsInContainer)(e).forEach(e=>e.dispose())}function y(e){return n.T2.keep(e)}function b(e){return n.T2.time(e)}function x(e){return n.T2.setBackend(e)}function v(){return n.T2.ready()}function w(){return n.T2.backendName}function T(e){n.T2.removeBackend(e)}function S(e){return n.T2.findBackend(e)}function N(e){return n.T2.findBackendFactory(e)}function k(e,t,r=1){return n.T2.registerBackend(e,t,r)}function I(){return n.T2.backend}function C(e,t){(0,a._K)().setPlatform(e,t)}(0,s.B4)(h)},15034:(e,t,r)=>{"use strict";r.d(t,{BC:()=>d,IU:()=>p,Kx:()=>u,Uc:()=>c,tB:()=>l,uM:()=>i,uU:()=>o});var n=r(44309),a=r(82692);let s=new Map;function i(e){(0,a.E6)(n.To,"DataFormat",e)}function o(e){(0,a.E6)(n.ft,"InterpolationFormat",e)}function l(e){(0,a.E6)(n.EY,"PaddingMode",e)}function u(e){(0,a.E6)(n.bb,"PoolMode",e)}let h=[];function p(e,t){h.push(e);try{let e=t();return h.pop(),e}catch(e){throw h.pop(),e}}function d(e){if(!m(e))throw Error("Not a valid tensor name: '"+e+"'");return(0===h.length?"":h.join("/")+"/")+e}function c(e){if(!m(e))throw Error("Not a valid tensor name: '"+e+"'");s.has(e)||s.set(e,0);let t=s.get(e);if(s.set(e,s.get(e)+1),!(t>0))return e;{let r=`${e}_${t}`;return s.set(r,1),r}}let f=new RegExp(/^[A-Za-z0-9][-A-Za-z0-9\._\/]*$/);function m(e){return!!e.match(f)}},15181:(e,t,r)=>{"use strict";r.d(t,{Z:()=>i});var n=r(19041),a=r(48592),s=r(27924);let i=(0,r(62176).op)({rsqrt_:function(e){let t=(0,s.YT)(e,"x","rsqrt","float32");return n.T2.runKernel(a.TOR,{x:t})}})},15348:(e,t,r)=>{"use strict";r.d(t,{GJ:()=>n,uI:()=>a});
53class n{constructor(e,t){this.backend=e,this.dataMover=t,this.data=new WeakMap,this.dataIdsCount=0}get(e){return this.data.has(e)||this.dataMover.moveData(this.backend,e),this.data.get(e)}set(e,t){this.dataIdsCount++,this.data.set(e,t)}has(e){return this.data.has(e)}delete(e){return this.dataIdsCount--,this.data.delete(e)}numDataIds(){return this.dataIdsCount}}class a{refCount(e){return s("refCount")}incRef(e){return s("incRef")}timerAvailable(){return!0}time(e){return s("time")}read(e){return s("read")}readSync(e){return s("readSync")}readToGPU(e,t){return s("readToGPU")}numDataIds(){return s("numDataIds")}disposeData(e,t){return s("disposeData")}write(e,t,r){return s("write")}move(e,t,r,n,a){return s("move")}createTensorFromGPUData(e,t,r){return s("createTensorFromGPUData")}memory(){return s("memory")}floatPrecision(){return s("floatPrecision")}epsilon(){return 32===this.floatPrecision()?1e-7:1e-4}dispose(){return s("dispose")}}function s(e){throw Error(`'${e}' not yet implemented or not found in the registry. This kernel may not be supported by the tfjs backend you have chosen`)}},15401:(e,t,r)=>{"use strict";r.d(t,{$:()=>i});var n=r(27924),a=r(76526),s=r(57290);function i(e,t,r){if((0,a.HO)(e),null!=t&&3!==t.length)throw Error("tensor3d() requires shape to have three numbers");let i=(0,n.MZ)(e,r);if(3!==i.length&&1!==i.length)throw Error("tensor3d() requires values to be number[][][] or flat/TypedArray");if(1===i.length&&null==t)throw Error("tensor3d() requires shape to be provided when `values` are a flat array");return(0,s.Q)(e,t,i,r)}},15565:(e,t,r)=>{"use strict";r.d(t,{q:()=>a});var n=r(51520);function a(e,t,r,a,s,i,o,l,u){let h=(0,n.ra8)([a,i],r);for(let r=0;r<a;r++){let n=[],a=0;for(let t=0;t<s;t++){let i=e[r*s+t];a+=i*o[t],n.push(i)}if(a<0||a>=u/i)throw Error(`Invalid indices: ${n} does not index into ${l}`);for(let e=0;e<i;e++)h.values[r*i+e]=t.get(...t.indexToLoc(a*i+e))}return h}},16041:(e,t,r)=>{"use strict";r.d(t,{dH:()=>s,lO:()=>i});var n=r(51520),a=r(49575);function s(e){let t=new Float32Array(e.length);for(let r=0;r<e.length;++r)t[r]=Math.abs(e[r]);return t}let i={kernelName:n.ljI,backendName:"cpu",kernelFunc:e=>{let{x:t}=e.inputs,r=e.backend;(0,a.C)(t,"abs");let i=new Float32Array(n.ZSL.sizeFromShape(t.shape));return i=s(r.data.get(t.dataId).values),r.makeOutput(i,t.shape,t.dtype)}}},16427:(e,t,r)=>{"use strict";r.d(t,{X:()=>u});var n=r(19041),a=r(48592),s=r(27924),i=r(76526),o=r(62176),l=r(68567);let u=(0,o.op)({dilation2d_:function(e,t,r,o,u=[1,1],h="NHWC"){let p=(0,s.YT)(e,"x","dilation2d"),d=(0,s.YT)(t,"filter","dilation2d");i.vA(3===p.rank||4===p.rank,()=>`Error in dilation2d: input must be rank 3 or 4, but got rank ${p.rank}.`),i.vA(3===d.rank,()=>`Error in dilation2d: filter must be rank 3, but got rank ${d.rank}.`),i.vA("NHWC"===h,()=>`Error in dilation2d: Only NHWC is currently supported, but got dataFormat of ${h}`);let c=p,f=!1;3===p.rank&&(c=(0,l.t)(p,[1,p.shape[0],p.shape[1],p.shape[2]]),f=!0),i.vA(c.shape[3]===d.shape[2],()=>`Error in dilation2d: input and filter must have the same depth: ${c.shape[3]} vs ${d.shape[2]}`);let m={x:c,filter:d},g=n.T2.runKernel(a.jxD,m,{strides:r,pad:o,dilations:u});return f?(0,l.t)(g,[g.shape[1],g.shape[2],g.shape[3]]):g}})},16488:(e,t,r)=>{"use strict";r.d(t,{w:()=>o});var n=r(19041),a=r(48592),s=r(27924),i=r(76526);let o=(0,r(62176).op)({cast_:function(e,t){let r=(0,s.YT)(e,"x","cast");if(!i.xn(t))throw Error(`Failed to cast to unknown dtype ${t}`);if("string"===t&&"string"!==r.dtype||"string"!==t&&"string"===r.dtype)throw Error("Only strings can be casted to strings");return n.T2.runKernel(a.KXH,{x:r},{dtype:t})}})},16986:(e,t,r)=>{"use strict";r.d(t,{Z:()=>a});var n=r(51520);function a(e){return(t,r,a,s,i)=>{let o=n.C0T.assertAndGetBroadcastShape(t,r),l=o.length,u=n.ZSL.computeStrides(o),h=n.ZSL.sizeFromShape(o),p=n.ZSL.getTypedArrayFromDType(i,h),d=t.length,c=r.length,f=n.ZSL.computeStrides(t),m=n.ZSL.computeStrides(r),g=n.C0T.getBroadcastDims(t,o),y=n.C0T.getBroadcastDims(r,o);if(g.length+y.length===0)for(let t=0;t<p.length;++t)p[t]=e(a[t%a.length],s[t%s.length]);else for(let t=0;t<p.length;++t){let r=n.ZSL.indexToLoc(t,l,u),i=r.slice(-d);
53g.forEach(e=>i[e]=0);let o=n.ZSL.locToIndex(i,d,f),h=r.slice(-c);y.forEach(e=>h[e]=0);let b=n.ZSL.locToIndex(h,c,m);p[t]=e(a[o],s[b])}return[p,o]}}},17019:(e,t,r)=>{"use strict";r.d(t,{N:()=>i});var n=r(19041),a=r(48592),s=r(27924);let i=(0,r(62176).op)({prelu_:function(e,t){let r=(0,s.YT)(e,"x","prelu"),i=(0,s.YT)(t,"alpha","prelu");return n.T2.runKernel(a.Ncv,{x:r,alpha:i})}})},17831:(e,t,r)=>{"use strict";var n,a,s,i,o;r.d(t,{Nw:()=>d,Oj:()=>p,Tu:()=>u,ch:()=>h,rg:()=>n}),function(e){e.R0="R0",e.R1="R1",e.R2="R2",e.R3="R3",e.R4="R4",e.R5="R5",e.R6="R6"}(n||(n={})),function(e){e.float32="float32",e.int32="int32",e.bool="int32",e.complex64="complex64"}(a||(a={})),function(e){e.float32="float32",e.int32="int32",e.bool="bool",e.complex64="complex64"}(s||(s={})),function(e){e.float32="float32",e.int32="float32",e.bool="float32",e.complex64="complex64"}(i||(i={})),function(e){e.float32="complex64",e.int32="complex64",e.bool="complex64",e.complex64="complex64"}(o||(o={}));let l={float32:i,int32:a,bool:s,complex64:o};function u(e,t){if("string"===e||"string"===t){if("string"===e&&"string"===t)return"string";throw Error(`Can not upcast ${e} with ${t}`)}return l[e][t]}function h(e){return u(e,"int32")}function p(e){return null!=e&&"object"==typeof e&&"texture"in e&&e.texture instanceof WebGLTexture}function d(e){return"undefined"!=typeof GPUBuffer&&null!=e&&"object"==typeof e&&"buffer"in e&&e.buffer instanceof GPUBuffer}},18313:(e,t,r)=>{"use strict";r.d(t,{M:()=>i});var n=r(19041),a=r(48592),s=r(27924);let i=(0,r(62176).op)({oneHot_:function(e,t,r=1,i=0,o="int32"){if(t<2)throw Error(`Error in oneHot: depth must be >=2, but it is ${t}`);let l=(0,s.YT)(e,"indices","oneHot","int32");return n.T2.runKernel(a.urI,{indices:l},{dtype:o,depth:t,onValue:r,offValue:i})}})},18358:(e,t,r)=>{"use strict";r.d(t,{M:()=>l});var n=r(19041),a=r(48592),s=r(50124),i=r(27924),o=r(83231);let l=(0,r(62176).op)({less_:function(e,t){let r=(0,i.YT)(e,"a","less","string_or_numeric"),l=(0,i.YT)(t,"b","less","string_or_numeric");[r,l]=(0,s.makeTypesMatch)(r,l),(0,o.assertAndGetBroadcastShape)(r.shape,l.shape);let u={a:r,b:l};return n.T2.runKernel(a.mIA,u)}})},18585:(e,t,r)=>{"use strict";r.d(t,{X3:()=>l,ry:()=>o,zv:()=>i});var n=r(51520),a=r(81600),s=r(87095);let i=(0,a.o)(e=>1/(1+Math.exp(-e))),o=(0,s.v)(n.vI1,e=>1/(1+Math.exp(-e))),l={kernelName:n.vI1,backendName:"cpu",kernelFunc:o}},19041:(e,t,r)=>{"use strict";r.d(t,{T2:()=>x,Ye:()=>b});var n=r(15348),a=r(89215),s=r(12534),i=r(48592),o=r(53147),l=r(63048),u=r(47537),h=r(76526);class p{constructor(e,t){this.backendTimer=e,this.logger=t,null==t&&(this.logger=new d)}profileKernel(e,t,r){let n,s,i=()=>{n=r()},o=u.now();if(this.backendTimer.timerAvailable())s=this.backendTimer.time(i);else{for(let e of(i(),n))e.dataSync();s=Promise.resolve({kernelMs:u.now()-o})}if((0,a._K)().getBool("CHECK_COMPUTATION_FOR_ERRORS"))for(let t=0;t<n.length;t++){let r=n[t];r.data().then(t=>{!function(e,t,r){if("float32"===t)for(let t=0;t<e.length;t++){let n=e[t];if(isNaN(n)||!isFinite(n))return console.warn(`Found ${n} in the result of '${r}'`),!0}}(t,r.dtype,e)})}return{kernelName:e,outputs:n,inputs:t,timeMs:s.then(e=>e.kernelMs),extraInfo:s.then(e=>null!=e.getExtraProfileInfo?e.getExtraProfileInfo():"")}}logKernelProfile(e){let{kernelName:t,outputs:r,timeMs:n,inputs:a,extraInfo:s}=e;r.forEach(e=>{Promise.all([e.data(),n,s]).then(r=>{this.logger.logKernelProfile(t,e,r[0],r[1],a,r[2])})})}}class d{logKernelProfile(e,t,r,n,a,s){let i="number"==typeof n?h.av(`${n}ms`,9):n.error,o=h.av(e,25),l=t.rank,u=t.size,p=h.av(t.shape.toString(),14),d="";for(let e in a){let r=a[e];if(null!=r){let n=r.shape||t.shape,a=n.length;d+=`${e}: ${a}D ${a>0?n:""} `}}console.log(`%c${o} %c${i} %c${l}D ${p} %c${u} %c${d} %c${s}`,"font-weight:bold","color:red","color:blue","color: orange","color: green","color: steelblue")}}var c=r(60218),f=r(50124);function m(e){return null!=e.kernelName}class g{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()}}class y{constructor(e){this.ENV=e,this.registry={},this.registryFactory={},this.pendingBackendInitId=0,this.state=new g}async ready(){if(null!=this.pendingBackendInit)return this.pendingBackendInit.then(()=>{});if(null!=this.backendInstance)return;let e=this.getSortedBackends();for(let t=0;t<e.length;t++){let r=e[t];if(await this.initializeBackend(r).success)return void await this.setBackend(r)}throw Error("Could not initialize any backends, all backend initializations failed.")}
53get backend(){if(null!=this.pendingBackendInit)throw Error(`Backend '${this.backendName}' has not yet been initialized. Make sure to await tf.ready() or await tf.setBackend() before calling other methods`);if(null==this.backendInstance){let{name:e,asyncInit:t}=this.initializeBackendsAndReturnBest();if(t)throw Error(`The highest priority backend '${e}' has not yet been initialized. Make sure to await tf.ready() or await tf.setBackend() before calling other methods`);this.setBackend(e)}return this.backendInstance}backendNames(){return Object.keys(this.registryFactory)}findBackend(e){if(!(e in this.registry))if(!(e in this.registryFactory))return null;else{let{asyncInit:t}=this.initializeBackend(e);if(t)return null}return this.registry[e]}findBackendFactory(e){return e in this.registryFactory?this.registryFactory[e].factory:null}registerBackend(e,t,r=1){return e in this.registryFactory?(l.i(`${e} backend was already registered. Reusing existing backend factory.`),!1):(this.registryFactory[e]={factory:t,priority:r},!0)}async setBackend(e){if(null==this.registryFactory[e])throw Error(`Backend name '${e}' not found in registry`);
53if(this.backendName=e,null==this.registry[e]){this.backendInstance=null;let{success:t,asyncInit:r}=this.initializeBackend(e);if(!(r?await t:t))return!1}return this.backendInstance=this.registry[e],this.setupRegisteredKernels(),this.profiler=new p(this.backendInstance),!0}setupRegisteredKernels(){(0,o.Op)(this.backendName).forEach(e=>{null!=e.setupFunc&&e.setupFunc(this.backendInstance)})}disposeRegisteredKernels(e){(0,o.Op)(e).forEach(t=>{null!=t.disposeFunc&&t.disposeFunc(this.registry[e])})}initializeBackend(e){let t=this.registryFactory[e];if(null==t)throw Error(`Cannot initialize backend ${e}, no registration found.`);try{let r=t.factory();if(!r||r instanceof n.uI||"function"!=typeof r.then)return this.registry[e]=r,{success:!0,asyncInit:!1};{let t=++this.pendingBackendInitId,n=r.then(r=>!(t<this.pendingBackendInitId)&&(this.registry[e]=r,this.pendingBackendInit=null,!0)).catch(r=>!(t<this.pendingBackendInitId)&&(this.pendingBackendInit=null,l.i(`Initialization of backend ${e} failed`),l.i(r.stack||r.message),!1));return this.pendingBackendInit=n,{success:n,asyncInit:!0}}}catch(t){return l.i(`Initialization of backend ${e} failed`),l.i(t.stack||t.message),{success:!1,asyncInit:!1}}}removeBackend(e){if(!(e in this.registryFactory))throw Error(`${e} backend not found in registry`);this.backendName===e&&null!=this.pendingBackendInit&&this.pendingBackendInitId++,e in this.registry&&(this.disposeRegisteredKernels(e),this.registry[e].dispose(),delete this.registry[e]),delete this.registryFactory[e],this.backendName===e&&(this.pendingBackendInit=null,this.backendName=null,this.backendInstance=null)}getSortedBackends(){if(0===Object.keys(this.registryFactory).length)throw 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 r=e[t],{success:n,asyncInit:a}=this.initializeBackend(r);if(a||n)return{name:r,asyncInit:a}}throw Error("Could not initialize any backends, all backend initializations failed.")}moveData(e,t){let r=this.state.tensorInfo.get(t),n=r.backend,a=this.readSync(t),s=n.refCount(t);n.disposeData(t,!0),r.backend=e,e.move(t,a,r.shape,r.dtype,s),this.shouldCheckForMemLeaks()&&this.state.numDataMovesStack[this.state.numDataMovesStack.length-1]++}tidy(e,t){let r,n=null;if(null==t){if("function"!=typeof e)throw Error("Please provide a function to tidy()");t=e}else{if("string"!=typeof e&&!(e instanceof String))throw Error("When calling with two arguments, the first argument to tidy() must be a string");if("function"!=typeof t)throw Error("When calling with two arguments, the 2nd argument to tidy() must be a function");n=e}return this.scopedRun(()=>this.startScope(n),()=>this.endScope(r),()=>((r=t())instanceof Promise&&console.error("Cannot return a Promise inside of tidy."),r))}scopedRun(e,t,r){e();try{let e=r();return t(),e}catch(e){throw t(),e}}nextTensorId(){return y.nextTensorId++}nextVariableId(){return y.nextVariableId++}clone(e){let t=x.runKernel(i.lzr,{x:e});return this.addTapeNode(this.state.activeScope.name,{x:e},[t],e=>({x:()=>x.runKernel(i.KXH,{x:e},{dtype:"float32"})}),[],{}),t}runKernel(e,t,r){if(null==this.backendName&&this.backend,null==(0,o._5)(e,this.backendName))throw Error(`Kernel '${e}' not registered for backend '${this.backendName}'`);return this.runKernelFunc({kernelName:e,inputs:t,attrs:r})}shouldCheckForMemLeaks(){return this.ENV.getBool("IS_TEST")}checkKernelForMemLeak(e,t,r){let n=this.backend.numDataIds(),a=0;r.forEach(e=>{a+="complex64"===e.dtype?3:1});let s=this.state.numDataMovesStack[this.state.numDataMovesStack.length-1],i=n-t-a-s;if(i>0)throw Error(`Backend '${this.backendName}' has an internal memory leak (${i} data ids) after running '${e}'`)}runKernelFunc(e){let t,r,n,a,s=[],i=this.isTapeOn(),l=this.state.numBytes,u=this.state.numTensors;this.shouldCheckForMemLeaks()&&this.state.numDataMovesStack.push(0),null==this.backendName&&this.backend;let p=m(e)?e.kernelName:null!=this.state.activeScope?this.state.activeScope.name:"";if(m(e)){let{kernelName:t,inputs:a,attrs:l}=e;null==this.backendName&&this.backend;let u=(0,o._5)(t,this.backendName);h.vA(null!=u,()=>`Cannot find registered kernel '${t}' for backend '${this.backendName}'`),r=()=>{let e=this.backend.numDataIds(),r=Array.isArray(n=u.kernelFunc({input
53s:a,attrs:l,backend:this.backend}))?n:[n];this.shouldCheckForMemLeaks()&&this.checkKernelForMemLeak(t,e,r);let o=r.map(e=>null!=e.rank?e:this.makeTensorFromTensorInfo(e));if(i){let e=this.getTensorsForGradient(t,a,o);s=this.saveTensorsForBackwardMode(e)}return o}}else{let{forwardFunc:t}=e,a=e=>{i&&(s=e.map(e=>this.keep(this.clone(e))))};r=()=>{let e=this.backend.numDataIds(),r=Array.isArray(n=this.tidy(()=>t(this.backend,a)))?n:[n];return this.shouldCheckForMemLeaks()&&this.checkKernelForMemLeak(p,e,r),r}}let{inputs:d,attrs:c}=e,f=m(e)?null:e.backwardsFunc;return this.scopedRun(()=>this.state.kernelDepth++,()=>this.state.kernelDepth--,()=>{this.ENV.getBool("DEBUG")||this.state.profiling?(a=this.profiler.profileKernel(p,d,()=>r()),this.ENV.getBool("DEBUG")&&this.profiler.logKernelProfile(a),t=a.outputs):t=r()}),i&&this.addTapeNode(p,d,t,f,s,c),this.state.profiling&&this.state.activeProfile.kernels.push({name:p,bytesAdded:this.state.numBytes-l,totalBytesSnapshot:this.state.numBytes,tensorsAdded:this.state.numTensors-u,totalTensorsSnapshot:this.state.numTensors,inputShapes:Object.keys(d).map(e=>null!=d[e]?d[e].shape:null),outputShapes:t.map(e=>e.shape),kernelTimeMs:a.timeMs,extraInfo:a.extraInfo}),Array.isArray(n)?t:t[0]}saveTensorsForBackwardMode(e){return e.map(e=>this.keep(this.clone(e)))}getTensorsForGradient(e,t,r){let n=(0,o.vQ)(e);if(null!=n){let e,a=n.inputsToSave||[],s=n.outputsToSave||[];n.saveAllInputs?(h.vA(Array.isArray(t),()=>"saveAllInputs is true, expected inputs to be an array."),e=Object.keys(t).map(e=>t[e])):e=a.map(e=>t[e]);let i=r.filter((e,t)=>s[t]);return e.concat(i)}return[]}makeTensor(e,t,r,n){if(null==e)throw Error("Values passed to engine.makeTensor() are null");r=r||"float32",n=n||this.backend;let a=e;"string"===r&&h.Kg(e[0])&&(a=e.map(e=>u.encodeString(e)));let s=n.write(a,t,r),i=new c.qY(t,r,s,this.nextTensorId());if(this.trackTensor(i,n),"string"===r){let e=this.state.tensorInfo.get(s),t=(0,h.SL)(a);this.state.numBytes+=t-e.bytes,e.bytes=t}return i}makeTensorFromDataId(e,t,r,n){let a={dataId:e,shape:t,dtype:r=r||"float32"};return this.makeTensorFromTensorInfo(a,n)}makeTensorFromTensorInfo(e,t){let{dataId:r,shape:n,dtype:a}=e,s=new c.qY(n,a,r,this.nextTensorId());return this.trackTensor(s,t),s}makeVariable(e,t=!0,r,n){r=r||this.nextVariableId().toString(),null!=n&&n!==e.dtype&&(e=e.cast(n));let a=new c.rT(e,t,r,this.nextTensorId());if(null!=this.state.registeredVariables[a.name])throw Error(`Variable with name ${a.name} was already registered`);return this.state.registeredVariables[a.name]=a,this.incRef(a,this.backend),a}trackTensor(e,t){this.state.numTensors++,"string"===e.dtype&&this.state.numStringTensors++;let r=0;"complex64"!==e.dtype&&"string"!==e.dtype&&(r=e.size*h.jv(e.dtype)),this.state.numBytes+=r,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:r})),e instanceof c.rT||this.track(e)}incRef(e,t){this.trackTensor(e,t),this.backend.incRef(e.dataId)}removeDataId(e,t){this.state.tensorInfo.has(e)&&this.state.tensorInfo.get(e).backend===t&&(this.state.tensorInfo.delete(e),this.state.numDataBuffers--)}disposeTensor(e){if(!this.state.tensorInfo.has(e.dataId))return;let t=this.state.tensorInfo.get(e.dataId);if(this.state.numTensors--,"string"===e.dtype&&(this.state.numStringTensors--,this.state.numBytes-=t.bytes),"complex64"!==e.dtype&&"string"!==e.dtype){let t=e.size*h.jv(e.dtype);this.state.numBytes-=t}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),null!=this.state.registeredVariables[e.name]&&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,null==e.reasons&&(e.reasons=[]),e.reasons.push("Memory usage by string tensors is approximate (2 bytes per character)")),e}async profile(e){this.state.profiling=!0;let t=this.state.numBytes,r=this.state.numTensors;for(let n of(this.state.activeProfile.kernels=[],this.state.activeProfile.result=await e(),this.state.profiling=!1,this.state.activeProfile.peakBytes=Math.max(...this.state.activeProfile.kernels.map(e=>e.totalBytesSnapshot)),this.state.activeProfile.newBytes=this.state.numBytes-t,this.state.activeProfile.newTensors=this.state.numTensors-r,this.state.activeProfile.kernels))n.kernelTimeMs=await n.kernelTimeMs,n.extraInfo=await n.extraInfo;return this.state.activeProfile}isTapeOn(){return this.state.gradientDepth>
530&&0===this.state.kernelDepth}addTapeNode(e,t,r,n,a,s){let i={id:this.state.nextTapeNodeId++,kernelName:e,inputs:t,outputs:r,saved:a},l=(0,o.vQ)(e);null!=l&&(n=l.gradFunc),null!=n&&(i.gradient=e=>(e=e.map((e,t)=>{if(null==e){let e=r[t],n=h.Ty(e.size,e.dtype);return this.makeTensor(n,e.shape,e.dtype)}return e}),n(e.length>1?e:e[0],a,s))),this.state.activeTape.push(i)}keep(e){return e.kept=!0,e}startTape(){0===this.state.gradientDepth&&(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=(0,f.getTensorsInContainer)(e),r=new Set(t.map(e=>e.id));for(let e=0;e<this.state.activeScope.track.length;e++){let t=this.state.activeScope.track[e];t.kept||r.has(t.id)||t.dispose()}let n=this.state.scopeStack.pop();this.state.activeScope=0===this.state.scopeStack.length?null:this.state.scopeStack[this.state.scopeStack.length-1],t.forEach(e=>{e.kept||e.scopeId!==n.id||this.track(e)})}gradients(e,t,r,n=!1){if(h.vA(t.length>0,()=>"gradients() received an empty list of xs."),null!=r&&"float32"!==r.dtype)throw Error(`dy must have 'float32' dtype, but has '${r.dtype}'`);let a=this.scopedRun(()=>this.startTape(),()=>this.endTape(),()=>this.tidy("forward",e));h.vA(a instanceof c.qY,()=>"The result y returned by f() must be a tensor.");let s=function(e,t,r){let n={},a={};for(let e=0;e<t.length;e++)n[t[e].id]=!0;for(let r=0;r<e.length;r++){let s=e[r],i=s.inputs;for(let e in i){let r=i[e],o=!1;for(let e=0;e<t.length;e++)if(n[r.id]){s.outputs.forEach(e=>n[e.id]=!0),o=!0,a[s.id]=!0;break}if(o)break}}let s={};s[r.id]=!0;let i={};for(let t=e.length-1;t>=0;t--){let r=e[t],n=r.inputs;for(let e=0;e<r.outputs.length;e++)if(s[r.outputs[e].id]){for(let e in n)s[n[e].id]=!0,i[r.id]=!0;break}}let o=[];for(let t=0;t<e.length;t++){let r=e[t];if(a[r.id]&&i[r.id]){let e={};for(let t in r.inputs){let a=r.inputs[t];n[a.id]&&(e[t]=a)}let t=Object.assign({},r);t.inputs=e,t.outputs=r.outputs,o.push(t)}}return o}(this.state.activeTape,t,a);if(!n&&0===s.length&&t.length>0)throw 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 e={};e[a.id]=null==r?function(e){let t=(0,h.FZ)((0,h.Ze)(e),"float32");return x.makeTensor(t,e,"float32")}(a.shape):r,function(e,t,r,n){for(let a=t.length-1;a>=0;a--){let s=t[a],i=[];if(s.outputs.forEach(t=>{let r=e[t.id];null!=r?i.push(r):i.push(null)}),null==s.gradient)throw Error(`Cannot compute gradient: gradient function not found for ${s.kernelName}.`);let o=s.gradient(i);for(let t in s.inputs){if(!(t in o))throw Error(`Cannot backprop through input ${t}. Available gradients found: ${Object.keys(o)}.`);let a=r(()=>o[t]());if("float32"!==a.dtype)throw Error(`Error in gradient for op ${s.kernelName}. The gradient of input ${t} must have 'float32' dtype, but has '${a.dtype}'`);let i=s.inputs[t];if(!h.r1(a.shape,i.shape))throw Error(`Error in gradient for op ${s.kernelName}. The gradient of input '${t}' has shape '${a.shape}', which does not match the shape of the input '${i.shape}'`);if(null==e[i.id])e[i.id]=a;else{let t=e[i.id];e[i.id]=n(t,a),t.dispose()}}}}(e,s,e=>this.tidy(e),v);let n=t.map(t=>e[t.id]);return 0===this.state.gradientDepth&&(this.state.activeTape.forEach(e=>{for(let t of e.saved)t.dispose()}),this.state.activeTape=null),{value:a,grads:n}})}customGrad(e){return h.vA(h.Tn(e),()=>"The f passed in customGrad(f) must be a function."),(...t)=>{let r;h.vA(t.every(e=>e instanceof c.qY),()=>"The args passed in customGrad(f)(x1, x2,...) must all be tensors");let n={};return t.forEach((e,t)=>{n[t]=e}),this.runKernelFunc({forwardFunc:(n,a)=>(r=e(...t,a),h.vA(r.value instanceof c.qY,()=>"The function f passed in customGrad(f) must return an object where `obj.value` is a tensor"),h.vA(h.Tn(r.gradFunc),()=>"The function f passed in customGrad(f) must return an object where `obj.gradFunc` is a function."),r.value),backwardsFunc:(e,n)=>{let a=r.gradFunc(e,n),s=Array.isArray(a)?a:[a];h.vA(s.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(...)."),h.vA(s.every(e=>e instanceof c.qY),()=>"The function f passed in customGrad(f) must return an object where `obj.gradFunc` is a function that returns a list of only tensors.");let i={};
53return s.forEach((e,t)=>{i[t]=()=>e}),i},inputs:n})}}readSync(e){return this.state.tensorInfo.get(e).backend.readSync(e)}read(e){return this.state.tensorInfo.get(e).backend.read(e)}readToGPU(e,t){return this.state.tensorInfo.get(e).backend.readToGPU(e,t)}async time(e){let t=(0,u.now)(),r=await this.backend.time(e);return r.wallMs=(0,u.now)()-t,r}track(e){return null!=this.state.activeScope&&(e.scopeId=this.state.activeScope.id,this.state.activeScope.track.push(e)),e}get registeredVariables(){return this.state.registeredVariables}reset(){for(let e in this.pendingBackendInitId++,this.state.dispose(),this.ENV.reset(),this.state=new g,this.registry)this.disposeRegisteredKernels(e),this.registry[e].dispose(),delete this.registry[e];this.backendName=null,this.backendInstance=null,this.pendingBackendInit=null}}function b(){let e=(0,s.L)();if(null==e._tfengine){let t=new a.OH(e);e._tfengine=new y(t)}return(0,a.tj)(e._tfengine.ENV),(0,c.qP)(()=>e._tfengine),e._tfengine}y.nextTensorId=0,y.nextVariableId=0;let x=b();function v(e,t){return x.runKernel(i.OMN,{a:e,b:t})}},19474:(e,t,r)=>{"use strict";r.d(t,{Y:()=>a});var n=r(993);function a(e,t){let r=[];for(let e=0;e<t.length;e++)t[e]&&r.push(e);let a=(0,n.r)(e,"int32"),s=(0,n.r)([r.length,e.length],"int32");for(let t=0;t<r.length;t++){let n=a.indexToLoc(r[t]),i=t*e.length;s.values.set(n,i)}return s.toTensor()}},19770:(e,t,r)=>{"use strict";r.d(t,{x:()=>s});var n=r(51520);let a=(e,t)=>{let r=t.value-e.value;return 0===r?e.index-t.index:r};function s(e,t,r,s,i){let o=t[t.length-1],[l,u]=[e.length/o,o],h=n.ZSL.getTypedArrayFromDType(r,l*s),p=n.ZSL.getTypedArrayFromDType("int32",l*s);for(let t=0;t<l;t++){let r=t*u,o=e.subarray(r,r+u),l=Array(o.length);o.forEach((e,t)=>l[t]={value:e,index:t}),s<l.length&&(!function e(t,r,s=0,i=t.length-1){for(;i>s;){if(i-s>600){let n=i-s+1,a=r-s+1,o=Math.log(n),l=.5*Math.exp(2*o/3),u=.5*Math.sqrt(o*l*(n-l)/n)*Math.sign(a-n/2),h=Math.max(s,Math.floor(r-a*l/n+u)),p=Math.min(i,Math.floor(r+(n-a)*l/n+u));e(t,r,h,p)}let o=t[r],l=s,u=i;for(n.ZSL.swap(t,s,r),a(t[i],o)>0&&n.ZSL.swap(t,s,i);l<u;){for(n.ZSL.swap(t,l,u),l++,u--;0>a(t[l],o);)l+=1;for(;a(t[u],o)>0;)u-=1}0===a(t[s],o)?n.ZSL.swap(t,s,u):(u+=1,n.ZSL.swap(t,u,i)),u<=r&&(s=u+1),r<=u&&(i=u-1)}}(l,s),l=l.slice(0,s)),i&&l.sort(a);let d=t*s,c=h.subarray(d,d+s),f=p.subarray(d,d+s);for(let e=0;e<s;e++)c[e]=l[e].value,f[e]=l[e].index}let d=t.slice();return d[d.length-1]=s,[(0,n.ra8)(d,r,h),(0,n.ra8)(d,"int32",p)]}},20160:(e,t,r)=>{"use strict";r.d(t,{E:()=>s});var n=r(19041),a=r(27924);let s=(0,r(62176).op)({square_:function(e){let t=(0,a.YT)(e,"x","square");return n.T2.runKernel("Square",{x:t},{})}})},20219:(e,t,r)=>{"use strict";r.d(t,{$:()=>l});var n=r(19041),a=r(48592),s=r(27924),i=r(76526),o=r(68567);let l=(0,r(62176).op)({batchNorm_:function(e,t,r,l,u,h){let p,d,c;null==h&&(h=.001);let f=(0,s.YT)(e,"x","batchNorm"),m=(0,s.YT)(t,"mean","batchNorm"),g=(0,s.YT)(r,"variance","batchNorm");null!=u&&(p=(0,s.YT)(u,"scale","batchNorm")),null!=l&&(d=(0,s.YT)(l,"offset","batchNorm")),i.vA(m.rank===g.rank,()=>"Batch normalization gradient requires mean and variance to have equal ranks."),i.vA(null==d||m.rank===d.rank,()=>"Batch normalization gradient requires mean and offset to have equal ranks."),i.vA(null==p||m.rank===p.rank,()=>"Batch normalization gradient requires mean and scale to have equal ranks.");let y={x:0===f.rank||1===f.rank?(0,o.t)(f,[1,1,1,f.size]):2===f.rank?(0,o.t)(f,[1,1,f.shape[0],f.shape[1]]):3===f.rank?(0,o.t)(f,[1,f.shape[0],f.shape[1],f.shape[2]]):f,scale:p,offset:d,mean:m,variance:g},b={varianceEpsilon:h},x=n.T2.runKernel(a.i5R,y,b);return(0,o.t)(x,f.shape)}})},20783:(e,t,r)=>{"use strict";r.r(t),r.d(t,{bindVertexProgramAttributeStreams:()=>w,createBufferFromOutputTexture:()=>N,createFloat16MatrixTexture:()=>f,createFloat16PackedMatrixTexture:()=>v,createFloat32MatrixTexture:()=>d,createIndexBuffer:()=>u,createPackedMatrixTexture:()=>b,createUnsignedBytesMatrixTexture:()=>g,createVertexBuffer:()=>l,createVertexShader:()=>o,downloadByteEncodedFloatMatrixFromOutputTexture:()=>I,downloadFloat32MatrixFromBuffer:()=>k,downloadMatrixFromPackedOutputTexture:()=>E,downloadPackedMatrixFromBuffer:()=>C,getInternalFormatForFloat16MatrixTexture:()=>c,getInternalFormatForFloat16PackedMatrixTexture:()=>x,getInternalFormatForFloat32MatrixTexture:()=>p,getInternalFormatForPackedMatrixTexture:()=>y,getInternalFormatForUnsignedBytesMatrixTexture:()=>m,uploadDenseMatrixToTexture:()=>T,uploadPixelDataToTexture:()=>S});var n=r(51520),a=r(67108),s=r(60217),i=r(26981);function o(e){let t=(0,a.B)(),r=`${t.version} 54 precision highp float; 55 ${t.attribute} vec3 clipSpacePos; 56 ${t.attribute} vec2 uv; 57 ${t.varyingVs} vec2 resultUV; 58 59 void main() { 60 gl_Position = vec4(clipSpacePos, 1); 61 resultUV = uv; 62 }`;return i.createVertexShader(e,r)}function l(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 i.createStaticVertexBuffer(e,t)}function u(e){let t=new Uint16Array([0,1,2,2,1,3]);return i.createStaticIndexBuffer(e,t)}function h(e,t,r,a,s,o){i.validateTextureSize(t,r);let l=i.createTexture(e),u=e.TEXTURE_2D;return i.callAndCheck(e,()=>e.bindTexture(u,l)),i.callAndCheck(e,()=>e.texParameteri(u,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE)),i.callAndCheck(e,()=>e.texParameteri(u,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE)),i.callAndCheck(e,()=>e.texParameteri(u,e.TEXTURE_MIN_FILTER,e.NEAREST)),i.callAndCheck(e,()=>e.texParameteri(u,e.TEXTURE_MAG_FILTER,e.NEAREST)),1===(0,n._K2)().getNumber("WEBGL_VERSION")?i.callAndCheck(e,()=>e.texImage2D(u,0,a,t,r,0,s,o,null)):i.callAndCheck(e,()=>e.texStorage2D(u,1,a,t,r)),i.callAndCheck(e,()=>e.bindTexture(e.TEXTURE_2D,null)),{texture:l,texShape:[r,t]}}function p(e){return e.internalFormatFloat}function d(e,t,r,n){let[a,i]=s.Qn(t,r);return h(e,a,i,p(n),n.textureFormatFloat,e.FLOAT)}function c(e){return e.internalFormatHalfFloat}function f(e,t,r,n){let[a,i]=s.Qn(t,r);return h(e,a,i,c(n),n.textureFormatFloat,n.textureTypeHalfFloat)}function m(e){return e.downloadTextureFormat}function g(e,t,r,n){let[a,i]=s.Qn(t,r);return h(e,a,i,m(n),e.RGBA,e.UNSIGNED_BYTE)}function y(e){return e.internalFormatPackedFloat}function b(e,t,r,n){let[a,i]=s.NO(t,r);return h(e,a,i,y(n),e.RGBA,e.FLOAT)}function x(e){return e.internalFormatPackedHalfFloat}function v(e,t,r,n){let[a,i]=s.NO(t,r);return h(e,a,i,x(n),e.RGBA,n.textureTypeHalfFloat)}function w(e,t,r){return i.callAndCheck(e,()=>e.bindBuffer(e.ARRAY_BUFFER,r)),i.bindVertexBufferToProgramAttribute(e,t,"clipSpacePos",r,3,20,0)&&i.bindVertexBufferToProgramAttribute(e,t,"uv",r,2,20,12)}function T(e,t,r,a,s,o){let l,u,h;i.callAndCheck(e,()=>e.bindTexture(e.TEXTURE_2D,t)),s instanceof Uint8Array?(l=new Uint8Array(r*a*4),u=e.UNSIGNED_BYTE,h=e.RGBA):(l=new Float32Array(r*a*4),u=e.FLOAT,h=o.internalFormatPackedFloat),l.set(s),2===(0,n._K2)().getNumber("WEBGL_VERSION")?i.callAndCheck(e,()=>e.texSubImage2D(e.TEXTURE_2D,0,0,0,r,a,e.RGBA,u,l)):i.callAndCheck(e,()=>e.texImage2D(e.TEXTURE_2D,0,h,r,a,0,e.RGBA,u,l)),i.callAndCheck(e,()=>e.bindTexture(e.TEXTURE_2D,null))}function S(e,t,r){i.callAndCheck(e,()=>e.bindTexture(e.TEXTURE_2D,t)),r.data instanceof Uint8Array?2===(0,n._K2)().getNumber("WEBGL_VERSION")?i.callAndCheck(e,()=>e.texSubImage2D(e.TEXTURE_2D,0,0,0,r.width,r.height,e.RGBA,e.UNSIGNED_BYTE,r.data)):i.callAndCheck(e,()=>e.texImage2D(e.TEXTURE_2D,0,e.RGBA,r.width,r.height,0,e.RGBA,e.UNSIGNED_BYTE,r.data)):2===(0,n._K2)().getNumber("WEBGL_VERSION")?i.callAndCheck(e,()=>e.texSubImage2D(e.TEXTURE_2D,0,0,0,e.RGBA,e.UNSIGNED_BYTE,r)):i.callAndCheck(e,()=>e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,r)),i.callAndCheck(e,()=>e.bindTexture(e.TEXTURE_2D,null))}function N(e,t,r,n){let a=e.createBuffer();i.callAndCheck(e,()=>e.bindBuffer(e.PIXEL_PACK_BUFFER,a));let s=16*t*r;return i.callAndCheck(e,()=>e.bufferData(e.PIXEL_PACK_BUFFER,s,e.STREAM_READ)),i.callAndCheck(e,()=>e.readPixels(0,0,r,t,e.RGBA,e.FLOAT,0)),i.callAndCheck(e,()=>e.bindBuffer(e.PIXEL_PACK_BUFFER,null)),a}function k(e,t,r){let n=new Float32Array(r);return e.bindBuffer(e.PIXEL_PACK_BUFFER,t),e.getBufferSubData(e.PIXEL_PACK_BUFFER,0,n),e.bindBuffer(e.PIXEL_PACK_BUFFER,null),n}function I(e,t,r,n){let[a,o]=s.Qn(t,r),l=new Uint8Array(s.EX(t*r,4));return i.callAndCheck(e,()=>e.readPixels(0,0,a,o,n.downloadTextureFormat,e.UNSIGNED_BYTE,l)),new Float32Array(l.buffer)}function C(e,t,r,n,a,i,o,l){let u=new Float32Array(s.PM(i,o));return e.bindBuffer(e.PIXEL_PACK_BUFFER,t),e.getBufferSubData(e.PIXEL_PACK_BUFFER,0,u),e.bindBuffer(e.PIXEL_PACK_BUFFER,null),u}function E(e,t,r){let n=new Float32Array(t*r*4);return i.callAndCheck(e,()=>e.readPixels(0,0,r,t,e.RGBA,e.FLOAT,n)),n}},20895:(e,t,r)=>{"use strict";r.d(t,{BF:()=>i,lw:()=>l,tJ:()=>u});var n=r(51520),a=r(16986),s=r(75017);let i=(0,a.Z)((e,t)=>e*t),o=(0,s.B)((e,t,r,n)=>({real:e*r-t*n,imag:e*n+t*r})),l=(0,s.j)(n.xu7,i,o),u={kernelName:n.xu7,backendName:"cpu",kernelFunc:l}},21081:(e,t,r)=>{"use strict";r.d(t,{$:()=>i});var n=r(67108),a=r(82859),s=r(60217);class i{constructor(e){this.variableNames=["A"],this.outTexUsage=s.tT.DOWNLOAD;let t=(0,n.B)();this.outputShape=e,this.userCode=` 63 ${a.G2} 64 65 void main() { 66 float x = getAAtOutCoords(); 67 ${t.output} = encode_float(x); 68 } 69 `}}},21364:(e,t,r)=>{"use strict";r.d(t,{Qu:()=>u,UB:()=>o,nV:()=>l});var n=r(51520),a=r(90556),s=r(14811),i=r(1560);class o extends s.Wd{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(0,n.DZQ)(()=>{this.invokeCallHook(e,t);let r=(0,i.un)(e);return a.Ls(()=>(0,n.WQq)(a.FE(r.shape,0,this.stddev),r),()=>r,t.training||!1)})}}o.className="GaussianNoise",n.JFn.registerClass(o);class l extends s.Wd{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(0,n.DZQ)(()=>{this.invokeCallHook(e,t);let r=(0,i.un)(e);return this.rate>0&&this.rate<1?a.Ls(()=>{let e=Math.sqrt(this.rate/(1-this.rate));return(0,n.lKK)(r,a.FE(r.shape,1,e))},()=>r,t.training||!1):r})}}l.className="GaussianDropout",n.JFn.registerClass(l);class u extends s.Wd{constructor(e){super(e),this.supportsMasking=!0,this.rate=e.rate,this.noiseShape=e.noiseShape}_getNoiseShape(e){return this.noiseShape||(0,i.un)(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(0,n.DZQ)(()=>
69{if(this.rate<1&&this.rate>0){let r=this._getNoiseShape(e);return a.Ls(()=>{let t=(0,i.un)(e),s=(0,n.DQN)((0,n.YeY)(r),this.rate);s=a.wg(s,"float32");let o=((1-this.rate)*(1+3.09091329228798*this.rate))**-.5,l=-(-1.7580993408473766*o)*this.rate,u=(0,n.WQq)((0,n.lKK)(t,s),(0,n.lKK)((0,n.WQq)(s,-1),-1.7580993408473766));return(0,n.WQq)((0,n.lKK)(u,o),l)},()=>(0,i.un)(e),t.training||!1)}return e})}}u.className="AlphaDropout",n.JFn.registerClass(u)},22064:(e,t,r)=>{"use strict";r.d(t,{$O:()=>K,AC:()=>v,BC:()=>O,BW:()=>y,CJ:()=>c,Dy:()=>S,E$:()=>p,G3:()=>F,G4:()=>A,Gs:()=>n,J3:()=>M,Kf:()=>o,LF:()=>W,M_:()=>q,Md:()=>l,Og:()=>E,Oy:()=>$,PA:()=>i,PP:()=>h,Q5:()=>Q,QM:()=>m,S6:()=>Z,SF:()=>d,Tm:()=>g,UC:()=>U,UF:()=>f,Xe:()=>k,ad:()=>C,cy:()=>G,dv:()=>u,f8:()=>L,fC:()=>D,fW:()=>j,h:()=>N,h0:()=>s,jm:()=>a,lL:()=>H,mo:()=>x,rI:()=>w,rQ:()=>I,rw:()=>T,sB:()=>P,tc:()=>_,uw:()=>b,vo:()=>z,we:()=>R,xt:()=>Y,yZ:()=>V,zN:()=>B});let{addImpl:n,bincountImpl:a,bincountReduceImpl:s,bitwiseAndImpl:i,castImpl:o,ceilImpl:l,concatImpl:u,equalImpl:h,expImpl:p,expm1Impl:d,floorImpl:c,gatherNdImpl:f,gatherV2Impl:m,greaterImpl:g,greaterEqualImpl:y,lessImpl:b,lessEqualImpl:x,linSpaceImpl:v,logImpl:w,maxImpl:T,maximumImpl:S,minimumImpl:N,multiplyImpl:k,negImpl:I,notEqualImpl:C,prodImpl:E,raggedGatherImpl:A,raggedRangeImpl:$,raggedTensorToTensorImpl:F,rangeImpl:R,rsqrtImpl:_,scatterImpl:D,sigmoidImpl:O,simpleAbsImpl:L,sliceImpl:M,sparseFillEmptyRowsImpl:P,sparseReshapeImpl:z,sparseSegmentReductionImpl:B,sqrtImpl:W,staticRegexReplaceImpl:V,stridedSliceImpl:G,stringNGramsImpl:U,stringSplitImpl:Z,stringToHashBucketFastImpl:j,subImpl:H,tileImpl:K,topKImpl:Y,transposeImpl:Q,uniqueImpl:q}=r(61293)},22148:(e,t,r)=>{"use strict";r.d(t,{o:()=>a});var n=r(72591);function a(e,t,r,i=console.log){var o;let l,u,h=function(e){let t=!0,r=[],n=[];for(let t in e.nodesByDepth)r.push(e.nodesByDepth[t]);for(let e of r){if(e.length>1||1===e.length&&e[0].inboundLayers.length>1){t=!1;break}n.push(...e)}if(t)for(let r of e.layers){let e=!1;for(let a of r.inboundNodes)if(-1!==n.indexOf(a))if(e){t=!1;break}else e=!0;if(!t)break}return t}(e),p=["Layer (type)","Input Shape","Output shape","Param #"];if(h?(t=t||90,r=r||[.32,.61,.89,1]):(t=t||115,r=r||[.24,.48,.7,.8,1]),r[r.length-1]<=1&&(r=r.map(e=>Math.floor(t*e))),!h)for(let t in p.push("Receives inputs"),l=[],e.nodesByDepth)l.push(...e.nodesByDepth[t]);i("_".repeat(t)),s(p,r,i),i("=".repeat(t));let d=e.layers;for(let e=0;e<d.length;++e)h?function(e,t,r){let n,a;try{a=e.inboundNodes.map(e=>JSON.stringify(e.inputShapes)).join(",")}catch(e){a="multiple"}try{n=JSON.stringify(e.outputShape)}catch(e){n="multiple"}let i=e.name,o=e.getClassName();s([`${i} (${o})`,a,n,e.countParams().toString()],t,r)}(d[e],r,i):function(e,t,r,n){let a,i;try{i=e.inboundNodes.map(e=>JSON.stringify(e.inputShapes)).join(",")}catch(e){i="multiple"}try{a=JSON.stringify(e.outputShape)}catch(e){a="multiple"}let o=[];for(let t of e.inboundNodes)if(null==r||!(r.length>0)||-1!==r.indexOf(t))for(let e=0;e<t.inboundLayers.length;++e){let r=t.inboundLayers[e].name,n=t.nodeIndices[e],a=t.tensorIndices[e];o.push(`${r}[${n}][${a}]`)}let l=e.name,u=e.getClassName(),h=0===o.length?"":o[0];s([`${l} (${u})`,i,a,e.countParams().toString(),h],t,n);for(let e=1;e<o.length;++e)s(["","","","",o[e]],t,n)}(d[e],r,l,i),i((e===d.length-1?"=":"_").repeat(t));e.checkTrainableWeightsConsistency();let c=null!=(o=e).collectedTrainableWeights?(0,n.Y)(o.collectedTrainableWeights):(0,n.Y)(o.trainableWeights),f=(0,n.Y)(e.nonTrainableWeights);i(`Total params: ${c+f}`),i(`Trainable params: ${c}`),i(`Non-trainable params: ${f}`),i("_".repeat(t))}function s(e,t,r=console.log){let n="";for(let r=0;r<e.length;++r)r>0&&(n=n.slice(0,n.length-1)+" "),n+=e[r],n=n.slice(0,t[r]),n+=" ".repeat(t[r]-n.length);r(n)}},22176:(e,t,r)=>{"use strict";r.d(t,{q:()=>i});var n=r(19041),a=r(48592),s=r(27924);let i=(0,r(62176).op)({asin_:function(e){let t=(0,s.YT)(e,"x","asin");return n.T2.runKernel(a.QKF,{x:t})}})},22666:(e,t,r)=>{"use strict";r.d(t,{O:()=>s});var n=r(27924),a=r(57290);function s(e,t,r){let s=(0,n.MZ)(e,r);return(0,a.Q)(e,t,s,r)}},22780:(e,t,r)=>{"use strict";r.d(t,{U:()=>function e(t,r,s="float32"){if("complex64"===s){let n=e(t,r,"float32"),s=e(t,r,"float32");
69return(0,a.f)({inputs:{real:n,imag:s},backend:t})}let i=n.ZSL.makeZerosTypedArray(n.ZSL.sizeFromShape(r),s);return t.makeTensorInfo(r,s,i)}});var n=r(51520),a=r(63405)},22934:(e,t,r)=>{"use strict";function n(e,t,r=!1){if(null==e||"object"!=typeof e||Object.getPrototypeOf(e)!==Object.prototype||!function e(t){if(null===t)return!0;if("object"==typeof t)if(Object.getPrototypeOf(t)===Object.prototype){for(let r of Object.keys(t))if("string"!=typeof r||!e(t[r]))return!1;return!0}else{if(!Array.isArray(t))return!1;for(let r of t)if(!e(r))return!1;return!0}{let e=typeof t;return"string"===e||"number"===e||"boolean"===e}}(e))throw Error("User-defined metadata is expected to be a JSON object, but is not.");if(r){let r=JSON.stringify(e);r.length>1048576&&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 <= 1048576.`)}}r.d(t,{Yl:()=>n})},23533:(e,t,r)=>{"use strict";r.d(t,{j:()=>i});var n=r(19041),a=r(48592),s=r(27924);let i=(0,r(62176).op)({relu6_:function(e){let t=(0,s.YT)(e,"x","relu6");return n.T2.runKernel(a.P_L,{x:t})}})},24361:(e,t,r)=>{"use strict";r.d(t,{l:()=>i});var n=r(19041),a=r(48592),s=r(27924);let i=(0,r(62176).op)({split_:function(e,t,r=0){let i=(0,s.YT)(e,"x","split");return n.T2.runKernel(a.Blb,{x:i},{numOrSizeSplits:t,axis:r})}})},24487:(e,t,r)=>{"use strict";r.d(t,{E:()=>l});var n=r(19041),a=r(48592),s=r(50124),i=r(27924),o=r(83231);let l=(0,r(62176).op)({notEqual_:function(e,t){let r=(0,i.YT)(e,"a","notEqual","string_or_numeric"),l=(0,i.YT)(t,"b","notEqual","string_or_numeric");[r,l]=(0,s.makeTypesMatch)(r,l),(0,o.assertAndGetBroadcastShape)(r.shape,l.shape);let u={a:r,b:l};return n.T2.runKernel(a.ylV,u)}})},25158:(e,t,r)=>{"use strict";r.d(t,{o:()=>i});var n=r(19041),a=r(48592),s=r(27924);let i=(0,r(62176).op)({exp_:function(e){let t=(0,s.YT)(e,"x","exp");return n.T2.runKernel(a.ox3,{x:t})}})},25223:(e,t,r)=>{"use strict";function n(e,t){return["x","y","z","w","u","v"].slice(0,t).map(t=>`${e}.${t}`)}function a(e,t){return 1===t?[e]:n(e,t)}function s(e,t){if(1===e)return"rc";let r="";for(let n=0;n<e;n++)r+=t[n],n<e-1&&(r+=",");return r}r.d(t,{Fd:()=>n,Jp:()=>a,kp:()=>s})},25283:(e,t,r)=>{"use strict";r.d(t,{r:()=>l});var n=r(19041),a=r(48592),s=r(50124),i=r(27924),o=r(83231);let l=(0,r(62176).op)({greater_:function(e,t){let r=(0,i.YT)(e,"a","greater","string_or_numeric"),l=(0,i.YT)(t,"b","greater","string_or_numeric");[r,l]=(0,s.makeTypesMatch)(r,l),(0,o.assertAndGetBroadcastShape)(r.shape,l.shape);let u={a:r,b:l};return n.T2.runKernel(a.XhZ,u)}})},25351:(e,t,r)=>{"use strict";r.d(t,{n:()=>o});var n=r(19041),a=r(48592),s=r(50124),i=r(27924);let o=(0,r(62176).op)({pow_:function(e,t){let r=(0,i.YT)(e,"base","pow"),o=(0,i.YT)(t,"exp","pow");[r,o]=(0,s.makeTypesMatch)(r,o);let l={a:r,b:o};return n.T2.runKernel(a.pyJ,l)}})},25612:(e,t,r)=>{"use strict";r.d(t,{r:()=>l});var n=r(27924),a=r(83231),s=r(32428),i=r(83152),o=r(94742);let l=(0,r(62176).op)({logicalXor_:function(e,t){let r=(0,n.YT)(e,"a","logicalXor","bool"),l=(0,n.YT)(t,"b","logicalXor","bool");return(0,a.assertAndGetBroadcastShape)(r.shape,l.shape),(0,s.n)((0,o.z)(e,t),(0,i.N)((0,s.n)(e,t)))}})},25742:(e,t,r)=>{"use strict";r.d(t,{Y:()=>l});var n=r(19041),a=r(48592),s=r(27924),i=r(76526),o=r(16488);let l=(0,r(62176).op)({erf_:function(e){let t=(0,s.YT)(e,"x","erf");i.vA("int32"===t.dtype||"float32"===t.dtype,()=>"Input dtype must be `int32` or `float32`."),"int32"===t.dtype&&(t=(0,o.w)(t,"float32"));let r={x:t};return n.T2.runKernel(a._s9,r)}})},26004:(e,t,r)=>{"use strict";r.d(t,{o:()=>i});var n=r(19041),a=r(48592),s=r(27924);let i=(0,r(62176).op)({clone_:function(e){let t=(0,s.YT)(e,"x","clone","string_or_numeric");return n.T2.runKernel(a.lzr,{x:t})}})},26701:function(e,t,r){var n;!function(e,a,s){function i(e){var t,r=this,n=(t=0xefc8249d,function(e){e=String(e);for(var r=0;r<e.length;r++){var n=.02519603282416938*(t+=e.charCodeAt(r));t=n>>>0,n-=t,n*=t,t=n>>>0,n-=t,t+=0x100000000*n}return(t>>>0)*23283064365386963e-26});r.next=function(){var e=2091639*r.s0+23283064365386963e-26*r.c;return r.s0=r.s1,r.s1=r.s2,r.s2=e-(r.c=0|e)},r.c=1,r.s0=n(" "),r.s1=n(" "),r.s2=n(" "),r.s0-=n(e),r.s0<0&&(r.s0+=1),r.s1-=n(e),r.s1<0&&(r.s1+=1),r.s2-=n(e),r.s2<0&&(r.s2+=1)}function o(e,t){return t.c=e.c,t.s0=e.s0,t.s1=e.s1,t.s2=e.s2,t}function l(e,t){var r=new i(e),n=t&&t.state,a=r.next;return a.int32=function(){return 0x100000000*r.next()|0},a.double=function(){return a()+(2097152*a()|0)*11102230246251565e-32},a.quick=a,n&&("object"==typeof n&&o(n,r),a.state=function(){return o(r,{})}),a}a&&a.exports?a.exports=l:r.amdD&&r.amdO?void 0===(n=(function(){return l}).call(t,r,t,a))||(a.exports=n):this.alea=l}(0,e=r.nmd(e),r.amdD)},26765:(e,t,r)=>{"use strict";r.d(t,{H:()=>i});var n=r(19041),a=r(48592),s=r(27924);let i=(0,r(62176).op)({acos_:function(e){let t=(0,s.YT)(e,"x","acos");return n.T2.runKernel(a.Vvy,{x:t})}})},26777:(e,t,r)=>{"use strict";r.d(t,{y:()=>a});var n=r(51520);function a(e,t,r,a,s,i,o){let l=t[0],u=i[0],h=Array(u),p=Array(l),d=t[1];if(0===u){if(0!==l)throw Error(n.C0T.getSparseFillEmptyRowsIndicesDenseShapeMismatch(l));return[n.ZSL.getArrayFromDType(r,0),[0,d],n.ZSL.getArrayFromDType(s,0),h,p]}let c=!0,f=0,m=Array(u).fill(0);for(let t=0;t<l;++t){let r=e[t*d];if(r<0)throw Error(n.C0T.getSparseFillEmptyRowsNegativeIndexErrorMessage(t,r));if(r>=u)throw Error(n.C0T.getSparseFillEmptyRowsOutOfRangeIndexErrorMessage(t,r,u));
69++m[r],c=c&&r>=f,f=r}let g=!0;for(let e=0;e<u;++e){let t=0===m[e];h[e]=t,g=g&&!t,m[e]=Math.max(m[e],1),e>0&&(m[e]+=m[e-1])}if(g&&c){for(let e=0;e<l;++e)p[e]=e;return[e,[l,d],a,h,p]}{let t=m[u-1],i=n.ZSL.getArrayFromDType(r,t*d),c=n.ZSL.getArrayFromDType(s,t),f=Array(u).fill(0);for(let t=0;t<l;++t){let r=e[t*d],n=f[r],s=(0===r?0:m[r-1])+n;f[r]++;for(let r=0;r<d;++r)i[s*d+r]=e[t*d+r];c[s]=a[t],p[t]=s}for(let e=0;e<u;++e)if(0===f[e]){let t=0===e?0:m[e-1];i[t*d+0]=e;for(let e=1;e<d;++e)i[t*d+e]=0;c[t]=o}return[i,[t,d],c,h,p]}}},26981:(e,t,r)=>{"use strict";let n,a;r.r(t),r.d(t,{assertNotComplex:()=>ee,bindCanvasToFramebuffer:()=>F,bindColorTextureToFramebuffer:()=>R,bindTextureToProgramUniformSampler:()=>$,bindTextureUnit:()=>I,bindVertexBufferToProgramAttribute:()=>k,callAndCheck:()=>l,canBeRepresented:()=>u,createFragmentShader:()=>c,createFramebuffer:()=>N,createProgram:()=>g,createStaticIndexBuffer:()=>v,createStaticVertexBuffer:()=>x,createTexture:()=>T,createVertexShader:()=>d,getBatchDim:()=>P,getExtensionOrThrow:()=>p,getFramebufferErrorMessage:()=>O,getMaxTexturesInShader:()=>j,getNumChannels:()=>w,getProgramUniformLocation:()=>A,getProgramUniformLocationOrThrow:()=>E,getRowsCols:()=>z,getShapeAs3D:()=>B,getTextureShapeFromLogicalShape:()=>W,getWebGLDisjointQueryTimerVersion:()=>H,getWebGLErrorMessage:()=>h,getWebGLMaxTextureSize:()=>G,hasExtension:()=>K,isCapableOfRenderingToFloatTexture:()=>Q,isDownloadFloatTextureEnabled:()=>q,isReshapeFree:()=>V,isWebGLFenceEnabled:()=>J,isWebGLVersionEnabled:()=>Y,linkProgram:()=>y,logShaderSourceAndInfoLog:()=>m,resetMaxTextureSize:()=>U,resetMaxTexturesInShader:()=>Z,unbindColorTextureFromFramebuffer:()=>_,unbindTextureUnit:()=>C,validateFramebuffer:()=>D,validateProgram:()=>b,validateTextureSize:()=>S});var s=r(51520),i=r(47700),o=r(60217);function l(e,t){let r=t();return(0,s._K2)().getBool("DEBUG")&&function(e){let t=e.getError();if(t!==e.NO_ERROR)throw Error("WebGL Error: "+h(e,t))}(e),r}function u(e){return!!((0,s._K2)().getBool("WEBGL_RENDER_FLOAT32_ENABLED")||0===e||596e-10<Math.abs(e)&&65504>Math.abs(e))}function h(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 p(e,t){return L(e,()=>e.getExtension(t),'Extension "'+t+'" not supported on this browser.')}function d(e,t){let r=L(e,()=>e.createShader(e.VERTEX_SHADER),"Unable to create vertex WebGLShader.");if(l(e,()=>e.shaderSource(r,t)),l(e,()=>e.compileShader(r)),!1===e.getShaderParameter(r,e.COMPILE_STATUS))throw console.log(e.getShaderInfoLog(r)),Error("Failed to compile vertex shader.");return r}function c(e,t){let r=L(e,()=>e.createShader(e.FRAGMENT_SHADER),"Unable to create fragment WebGLShader.");if(l(e,()=>e.shaderSource(r,t)),l(e,()=>e.compileShader(r)),(0,s._K2)().get("ENGINE_COMPILE_ONLY"))return r;if(!1===e.getShaderParameter(r,e.COMPILE_STATUS))throw m(t,e.getShaderInfoLog(r)),Error("Failed to compile fragment shader.");return r}let f=/ERROR: [0-9]+:([0-9]+):/g;function m(e,t){let r=f.exec(t);if(null==r){console.log(`Couldn't parse line number in error: ${t}`),console.log(e);return}let n=+r[1],a=e.split("\n"),i=a.length.toString().length+2,o=a.map((e,t)=>s.ZSL.rightPad((t+1).toString(),i)+e),l=0;for(let e=0;e<o.length;e++)l=Math.max(o[e].length,l);let u=o.slice(0,n-1),h=o.slice(n-1,n),p=o.slice(n);console.log(u.join("\n")),console.log(t.split("\n")[0]),console.log(`%c ${s.ZSL.rightPad(h[0],l)}`,"border:1px solid red; background-color:#e3d2d2; color:#a61717"),console.log(p.join("\n"))}function g(e){return L(e,()=>e.createProgram(),"Unable to create WebGLProgram.")}function y(e,t){if(l(e,()=>e.linkProgram(t)),!(0,s._K2)().get("ENGINE_COMPILE_ONLY")&&!1===e.getProgramParameter(t,e.LINK_STATUS))throw console.log(e.getProgramInfoLog(t)),Error("Failed to link vertex and fragment shaders.")}function b(e,t){if(l(e,()=>e.validateProgram(t)),!1===e.getProgramParameter(t,e.VALIDATE_STATUS))throw console.log(e.getProgramInfoLog(t)),Error("Shader program validation failed.")}function x(e,t){let r=L(e,()=>e.createBuffer(),"Unable to create WebGLBuffer");return l(e,()=>e.bindBuffer(e.ARRAY_BUFFER,r)),l(e,()=>e.bufferData(e.ARRAY_BUFFER,t,e.STATIC_DRAW)),r}function v(e,t){let r=L(e,()=>e.createBuffer(),"Unable to create WebGLBuffer");return l(e,()=>e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,r)),l(e,()=>e.bufferData(e.ELEMENT_ARRAY_BUFFER,t,e.STATIC_DRAW)),r}function w(){return 2===(0,s._K2)().getNumber("WEBGL_VERSION")?1:4}function T(e){return L(e,()=>e.createTexture(),"Unable to create WebGLTexture.")}function S(e,t){let r=(0,s._K2)().getNumber("WEBGL_MAX_TEXTURE_SIZE");if(e<=0||t<=0)throw Error(`Requested texture size [${e}x${t}
69] is invalid.`);if(e>r||t>r)throw Error(`Requested texture size [${e}x${t}] greater than WebGL maximum on this browser / GPU [${r}x${r}].`)}function N(e){return L(e,()=>e.createFramebuffer(),"Unable to create WebGLFramebuffer.")}function k(e,t,r,n,a,s,i){let o=e.getAttribLocation(t,r);return -1!==o&&(l(e,()=>e.bindBuffer(e.ARRAY_BUFFER,n)),l(e,()=>e.vertexAttribPointer(o,a,e.FLOAT,!1,s,i)),l(e,()=>e.enableVertexAttribArray(o)),!0)}function I(e,t,r){M(e,r),l(e,()=>e.activeTexture(e.TEXTURE0+r)),l(e,()=>e.bindTexture(e.TEXTURE_2D,t))}function C(e,t){M(e,t),l(e,()=>e.activeTexture(e.TEXTURE0+t)),l(e,()=>e.bindTexture(e.TEXTURE_2D,null))}function E(e,t,r){return L(e,()=>e.getUniformLocation(t,r),'uniform "'+r+'" not present in program.')}function A(e,t,r){return e.getUniformLocation(t,r)}function $(e,t,r,n){l(e,()=>I(e,t,n)),l(e,()=>e.uniform1i(r,n))}function F(e){l(e,()=>e.bindFramebuffer(e.FRAMEBUFFER,null)),l(e,()=>e.viewport(0,0,e.canvas.width,e.canvas.height)),l(e,()=>e.scissor(0,0,e.canvas.width,e.canvas.height))}function R(e,t,r){l(e,()=>e.bindFramebuffer(e.FRAMEBUFFER,r)),l(e,()=>e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,t,0))}function _(e,t){l(e,()=>e.bindFramebuffer(e.FRAMEBUFFER,t)),l(e,()=>e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,null,0))}function D(e){let t=e.checkFramebufferStatus(e.FRAMEBUFFER);if(t!==e.FRAMEBUFFER_COMPLETE)throw Error("Error binding framebuffer: "+O(e,t))}function O(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 L(e,t,r){let n=l(e,()=>t());if(null==n)throw Error(r);return n}function M(e,t){let r=e.MAX_COMBINED_TEXTURE_IMAGE_UNITS-1,n=t+e.TEXTURE0;if(n<e.TEXTURE0||n>r){let e=`[gl.TEXTURE0, gl.TEXTURE${r}]`;throw Error(`textureUnit must be in ${e}.`)}}function P(e,t=2){return s.ZSL.sizeFromShape(e.slice(0,e.length-t))}function z(e){if(0===e.length)throw Error("Cannot get rows and columns of an empty shape array.");return[e.length>1?e[e.length-2]:1,e[e.length-1]]}function B(e){let t=[1,1,1];return 0!==e.length&&(1!==e.length||1!==e[0])&&(t=[P(e),...z(e)]),t}function W(e,t=!1){let r=(0,s._K2)().getNumber("WEBGL_MAX_TEXTURE_SIZE"),n=(0,s._K2)().getNumber("WEBGL_MAX_SIZE_FOR_NARROW_TEXTURE");n===1/0&&(0,s._K2)().getBool("WEBGL_AUTO_SQUARIFY_NARROW_TEXTURE_SHAPE")&&(n=r/2),t&&(r*=2,n*=2,1===(e=e.map((t,r)=>r>=e.length-2?s.ZSL.nearestLargerEven(e[r]):e[r])).length&&(e=[2,e[0]])),2!==e.length&&(e=s.ZSL.squeezeShape(e).newShape);let a=s.ZSL.sizeFromShape(e),i=null;e.length<=1&&a<=r?i=[1,a]:2===e.length&&e[0]<=r&&e[1]<=r?i=e:3===e.length&&e[0]*e[1]<=r&&e[2]<=r?i=[e[0]*e[1],e[2]]:3===e.length&&e[0]<=r&&e[1]*e[2]<=r?i=[e[0],e[1]*e[2]]:4===e.length&&e[0]*e[1]*e[2]<=r&&e[3]<=r?i=[e[0]*e[1]*e[2],e[3]]:4===e.length&&e[0]<=r&&e[1]*e[2]*e[3]<=r&&(i=[e[0],e[1]*e[2]*e[3]]);let o=null!=i&&Math.max(...i)>n&&Math.min(...i)<=(t?2:1)&&Math.min(...i)>0;if(null==i||o)if(t){let t=P(e),r=2,n=2;e.length&&([r,n]=z(e)),a=r/2*t*(n/2),i=s.ZSL.sizeToSquarishShape(a).map(e=>2*e)}else i=s.ZSL.sizeToSquarishShape(a);return i}function V(e,t){if(e=e.slice(-2),t=t.slice(-2),s.ZSL.arraysEqual(e,t)||!e.length||!t.length||0===e[0]||0===e[1]||0===t[0]||0===t[1])return!0;if(e.length!==t.length){let r=e[e.length-1],n=t[t.length-1];if(r===n||r%2==0&&n%2==0&&(1===e[0]||1===t[0]))return!0}return e[1]===t[1]&&e[0]%2==0&&t[0]%2==0}function G(e){if(null==n){let t=(0,i.bU)(e);n=t.getParameter(t.MAX_TEXTURE_SIZE)}return n}function U(){n=null}function Z(){a=null}function j(e){if(null==a){let t=(0,i.bU)(e);a=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS)}return Math.min(16,a)}function H(e){let t;if(0===e)return 0;let r=(0,i.bU)(e);return K(r,"EXT_disjoint_timer_query_webgl2")&&2===e?2:+!!K(r,"EXT_disjoint_timer_query")}function K(e,t){return null!=e.getExtension(t)}function Y(e){try{let t=(0,i.bU)(e);if(null!=t)return!0}catch(e){console.log("Error when getting WebGL context: ",e)}return!1}function Q(e){if(0===e)return!1;let t=(0,i.bU)(e);if(1===e){if(!K(t,"OES_texture_float"))return!1}else if(!K(t,"EXT_color_buffer_float"))return!1;return X(t)}function q(e){if(0===e)return!1;let t=(0,i.bU)(e);if(1===e){if(!K(t,"OES_texture_float")||!K(t,"WEBGL_color_buffer_float"))return!1}else{if(K(t,"EXT_color_buffer_float"))return X(t);let e="EXT_color_buffer_half_float";if(K(t,e)){let a=t.getExtension(e);var r=t,n=a;let s=(0,o.EZ)(r,n),i=r.createTexture();r.bindTexture(r.TEXTURE_2D,i),r.texImage2D(r.TEXTURE_2D,0,s.internalFormatHalfFloat,1,1,0,s.textureFormatFloat,s.textureTypeHalfFloat,null);let l=r.createFramebuffer();r.bindFramebuffer(r.FRAMEBUFFER,l),r.framebufferTexture2D(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0,r.TEXTURE_2D,i,0);let u=r.checkFramebufferStatus(r.FRAMEBUFFER)===r.FRAMEBUFFER_COMPLETE;return r.bindTexture(r.TEXTURE_2D,null),r.bindFramebuffer(r.FRAMEBUFFER,null),r.deleteTexture(i),r.deleteFramebuffer(l),u}return!1}return X(t)}function X(e){let t=(0,o.EZ)(e),r=e.createTexture();e.bindTexture(e.TEXTURE_2D,r),e.texImage2D(e.TEXTURE_2D,0,t.internalFormatFloat,1,1,0,t.textureFormatFloat,t.textureTypeFloat,null);let n=e.createFramebuffer();e.bindFramebuffer(e.FRAMEBUFFER,n),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,r,0);let a=e.checkFramebufferStatus(e.FRAMEBUFFER)===e.FRAMEBUFFER_COMPLETE;return e.bindTexture(e.TEXTURE_2D,null),e.bindFramebuffer(e.FRAMEBUFFER,null),e.deleteTexture(r),e.deleteFramebuffer(n),a}function J(e){return 2===e&&null!=(0,i.bU)(e).fenceSync}
69function ee(e,t){Array.isArray(e)||(e=[e]),e.forEach(e=>{null!=e&&s.ZSL.assert("complex64"!==e.dtype,()=>`${t} does not support complex64 tensors in the WebGL backend.`)})}},27085:(e,t,r)=>{"use strict";r.d(t,{L:()=>i});var n=r(19041),a=r(48592),s=r(27924);let i=(0,r(62176).op)({sinh_:function(e){let t=(0,s.YT)(e,"x","sinh");return n.T2.runKernel(a.J3C,{x:t})}})},27100:(e,t,r)=>{"use strict";r.d(t,{s:()=>d});var n=r(51520),a=r(90556),s=r(8785),i=r(14811),o=r(97344),l=r(96902),u=r(65650),h=r(82692),p=r(1560);class d extends i.Wd{constructor(e){if(super(e),this.embeddings=null,this.DEFAULT_EMBEDDINGS_INITIALIZER="randomUniform",null==e.batchInputShape&&null==e.inputShape){let t=null;null!=e.batchSize&&(t=e.batchSize),null==e.inputLength?this.batchInputShape=[t,null]:this.batchInputShape=[t].concat(h.st(e.inputLength))}this.inputDim=e.inputDim,h.oo(this.inputDim,"inputDim"),this.outputDim=e.outputDim,h.oo(this.outputDim,"outputDim"),this.embeddingsInitializer=(0,l.Fe)(e.embeddingsInitializer||this.DEFAULT_EMBEDDINGS_INITIALIZER),this.embeddingsRegularizer=(0,u.Bm)(e.embeddingsRegularizer),this.activityRegularizer=(0,u.Bm)(e.activityRegularizer),this.embeddingsConstraint=(0,s.YZ)(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(0,n.DZQ)(()=>this.maskZero?(e=(0,p.un)(e),(0,n.Ec)(e,(0,n.POl)(e))):null)}computeOutputShape(e){if(e=(0,p.U$)(e),null==this.inputLength)return[...e,this.outputDim];let t=h.st(this.inputLength);if(t.length!==e.length-1)throw new o.Qp(`"inputLength" is ${this.inputLength}, but received input shape has shape ${e}`);{let r=0;for(let n=0;n<t.length;++n){let a=t[n],s=e[n+1];if(null!=a&&null!=s&&a!==s)throw new o.Qp(`"inputLength" is ${this.inputLength}, but received input shape has shape ${e}`);null==a&&(t[r]=s),r++}}return[e[0],...t,this.outputDim]}call(e,t){return(0,n.DZQ)(()=>{this.invokeCallHook(e,t);let r=(0,p.un)(e);"int32"!==r.dtype&&(r=a.wg(r,"int32"));let s=a.kg(this.embeddings.read(),(0,n.tQQ)(r,[r.size]));return(0,n.tQQ)(s,(0,p.U$)(this.computeOutputShape(r.shape)))})}getConfig(){let e={inputDim:this.inputDim,outputDim:this.outputDim,embeddingsInitializer:(0,l.zo)(this.embeddingsInitializer),embeddingsRegularizer:(0,u.R9)(this.embeddingsRegularizer),activityRegularizer:(0,u.R9)(this.activityRegularizer),embeddingsConstraint:(0,s.uH)(this.embeddingsConstraint),maskZero:this.maskZero,inputLength:this.inputLength};return Object.assign(e,super.getConfig()),e}}d.className="Embedding",n.JFn.registerClass(d)},27463:(e,t,r)=>{"use strict";r.d(t,{Ol:()=>l});var n=r(51520),a=r(73187),s=r(14811),i=r(97344),o=r(1560);class l extends s.Wd{constructor(e){if(null==e&&(e={}),super(e),this.dataFormat=null==e.dataFormat?(0,a.VI)():e.dataFormat,null==e.padding)this.padding=[[1,1],[1,1]];else if("number"==typeof e.padding)this.padding=[[e.padding,e.padding],[e.padding,e.padding]];else{let t,r;if(e.padding=e.padding,2!==e.padding.length)throw new i.Qp(`ZeroPadding2D expects padding to be a length-2 array, but received a length-${e.padding.length} array.`);if("number"==typeof e.padding[0])t=[e.padding[0],e.padding[0]],r=[e.padding[1],e.padding[1]];else{if(e.padding=e.padding,2!==e.padding[0].length)throw new i.Qp(`ZeroPadding2D expects height padding to be a length-2 array, but received a length-${e.padding[0].length} array.`);if(t=e.padding[0],2!==e.padding[1].length)throw new i.Qp(`ZeroPadding2D expects width padding to be a length-2 array, but received a length-${e.padding[1].length} array.`);r=e.padding[1]}this.padding=[t,r]}this.inputSpec=[new s.eO({ndim:4})]}computeOutputShape(e){let t,r;return(e=(0,o.U$)(e),"channelsFirst"===this.dataFormat)?(t=null!=e[2]&&e[2]>=0?e[2]+this.padding[0][0]+this.padding[0][1]:null,r=null!=e[3]&&e[3]>=0?e[3]+this.padding[1][0]+this.padding[1][1]:null,[e[0],e[1],t,r]):(t=null!=e[1]&&e[1]>=0?e[1]+this.padding[0][0]+this.padding[0][1]:null,r=null!=e[2]&&e[2]>=0?e[2]+this.padding[1][0]+this.padding[1][1]:null,[e[0],t,r,e[3]])}call(e,t){return(0,n.DZQ)(()=>{var t,r,s;return t=(0,o.un)(e),r=this.padding,s=this.dataFormat,(0,n.DZQ)(()=>{let e;if(4!==t.rank)throw new i.Qp(`temporalPadding expects input tensor to be 4-D, but received a ${t.rank}-D tensor.`);if(null==r&&(r=[[1,1],[1,1]]),2!==r.length||2!==r[0].length||2!==r[1].length)throw new i.Qp("spatial2dPadding expects `padding` to be an Array of two Arrays, each of which is an Array of two integers.");if(null==s&&(s=(0,a.VI)()),"channelsLast"!==s&&"channelsFirst"!==s)throw new i.Qp(`Unknown data format: ${s}. Supported data formats are 'channelsLast' and 'channelsFirst.`);return e="channelsFirst"===s?[[0,0],[0,0],r[0],r[1]]:[[0,0],r[0],r[1],[0,0]],n.eVF(t,e)})})}getConfig(){let e={padding:this.padding,dataFormat:this.dataFormat};return Object.assign(e,super.getConfig()),e}}l.className="ZeroPadding2D",n.JFn.registerClass(l)},27610:(e,t,r)=>{"use strict";r.d(t,{P:()=>l});var n=r(19041),a=r(48592),s=r(50124),i=r(27924),o=r(83231);let l=(0,r(62176).op)({squaredDifference_:function(e,t){let r=(0,i.YT)(e,"a","squaredDifference"),l=(0,i.YT)(t,"b","squaredDifference");[r,l]=(0,s.makeTypesMatch)(r,l),(0,o.assertAndGetBroadcastShape)(r.shape,l.shape);let u={a:r,b:l};return n.T2.runKernel(a.Ddj,u,{})}})},27924:(e,t,r)=>{"use strict";r.d(t,{MZ:()=>u,YT:()=>p,j1:()=>d});var n=r(19041),a=r(89215),s=r(60218),i=r(17831),o=r(47537),l=r(76526);function u(e,t){let r=e;if((0,o.isTypedArray)(e))return"string"===t?[]:[e.length];if((0,i.Oj)(e)){let t=e.channels||"RGBA";return[e.height,e.width*t.length]}if((0,i.Nw)(e))return[e.buffer.size/(null==t?4:(0,l.jv)(t))];if(!Array.isArray(e))return[];let n=[];for(;Array.isArray(r)||(0,o.isTypedArray)(r)&&"string"!==t;)n.push(r.length),r=r[0];return Array.isArray(e)&&(0,a._K)().getBool("TENSORLIKE_CHECK_SHAPE_CONSISTENCY")&&function e(t,r,n){if(n=n||[],!Array.isArray(t)&&!(0,o.isTypedArray)(t))return void(0,l.vA)(0===r.length,()=>`Element arr[${n.join("][")}] is a primitive, but should be an array/TypedArray of ${r[0]} elements`);(0,l.vA)(r.length>0,()=>`Element arr[${n.join("][")}] should be a primitive, but is an array of ${t.length} elements`),(0,l.vA)(t.length===r[0],()=>`Element arr[${n.join("][")}] should have ${r[0]} elements, but has ${t.length} elements`);let a=r.slice(1);for(let r=0;r<t.length;++r)e(t[r],a,n.concat(r))}(e,n,[]),n}function h(e,t,r,n){if("string_or_numeric"!==e){if(null==e)throw Error("Expected dtype cannot be null.");if("numeric"!==e&&e!==t||"numeric"===e&&"string"===t)throw Error(`Argument '${r}' passed to '${n}' must be ${e} tensor, but got ${t} tensor`)}}function p(e,t,r,a="numeric"){if(e instanceof(0,s.tp)())return h(a,e.dtype,t,r),e;let i=(0,l.X$)(e);if("string"!==i&&["bool","int32","float32"].indexOf(a)>=0&&(i=a),h(a,i,t,r),null==e||!(0,o.isTypedArray)(e)&&!Array.isArray(e)&&"number"!=typeof e&&"boolean"!=typeof e&&"string"!=typeof e){let n=null==e?"null":e.constructor.name;throw Error(`Argument '${t}' passed to '${r}' must be a Tensor or TensorLike, but got '${n}'`)}let d=u(e,i);(0,o.isTypedArray)(e)||Array.isArray(e)||(e=[e]);let c="string"!==i?(0,o.toTypedArray)(e,i):(0,o.flatten)(e,[],!0);return n.T2.makeTensor(c,d,i)}function d(e,t,r,n="numeric"){if(!Array.isArray(e))throw Error(`Argument ${t} passed to ${r} must be a \`Tensor[]\` or \`TensorLike[]\``);return e.map((e,a)=>p(e,`${t}[${a}]`,r,n))}},28235:(e,t,r)=>{"use strict";r.d(t,{H:()=>i});var n=r(19041),a=r(48592),s=r(27924);let i=(0,r(62176).op)({neg_:function(e){let t=(0,s.YT)(e,"x","neg");return n.T2.runKernel(a.l0G,{x:t})}})},28575:(e,t,r)=>{"use strict";r.d(t,{e:()=>a});var n=r(51520);function a(e,t,r,a){let s=(0,n.ra8)(e,t.dtype);for(let e=0;e<s.size;e++){let n=s.indexToLoc(e),i=Array(n.length);for(let e=0;e<i.length;e++)i[e]=n[e]*r[e]+a[e];s.set(t.get(...i),...n)}return s}}
69,29659:(e,t,r)=>{"use strict";r.d(t,{R:()=>i});var n=r(19041),a=r(48592),s=r(27924);let i=(0,r(62176).op)({log_:function(e){let t=(0,s.YT)(e,"x","log","float32");return n.T2.runKernel(a.tG8,{x:t})}})},30051:(e,t,r)=>{"use strict";r.d(t,{He:()=>i,l9:()=>l});var n=r(51520),a=r(16986),s=r(75017);let i=(0,a.Z)((e,t)=>Math.max(e,t)),o=(0,s.j)(n.LDN,i),l={kernelName:n.LDN,backendName:"cpu",kernelFunc:o}},30254:(e,t,r)=>{"use strict";r.d(t,{y:()=>i});var n=r(19041),a=r(48592),s=r(27924);let i=(0,r(62176).op)({tanh_:function(e){let t=(0,s.YT)(e,"x","tanh","float32");return n.T2.runKernel(a.iuW,{x:t})}})},30319:(e,t,r)=>{"use strict";r.d(t,{d:()=>s});var n=r(47537),a=r(57290);function s(e,t){if(((0,n.isTypedArray)(e)&&"string"!==t||Array.isArray(e))&&"complex64"!==t)throw Error("Error creating a new Scalar: value must be a primitive (number|boolean|string)");if("string"===t&&(0,n.isTypedArray)(e)&&!(e instanceof Uint8Array))throw Error("When making a scalar from encoded string, the value must be `Uint8Array`.");return(0,a.Q)(e,[],[],t)}},30464:(e,t,r)=>{"use strict";r.d(t,{F:()=>i});var n=r(19041),a=r(48592),s=r(27924);let i=(0,r(62176).op)({argMax_:function(e,t=0){let r=(0,s.YT)(e,"x","argMax");return n.T2.runKernel(a.Jp_,{x:r},{axis:t})}})},30631:(e,t,r)=>{"use strict";r.d(t,{Do:()=>m,XB:()=>f,f2:()=>g,zE:()=>y});var n=r(83231),a=r(65737),s=r(12550),i=r(48683),o=r(17019),l=r(55865),u=r(23533),h=r(68567),p=r(75761),d=r(71069),c=r(60966);function f(e,t,r){if(null==r||"linear"===r)return e;if("relu"===r)return(0,i.l)(e,(0,d.P)(t));throw Error(`Cannot compute gradient for fused activation ${r}.`)}function m(e,t){let r=t,a=n.getReductionAxes(e.shape,t.shape);return a.length>0&&(r=(0,c.c)(r,a)),(0,h.t)(r,e.shape)}function g(e,t,r,n){if("linear"===t)return e;if("relu"===t)return(0,l.V)(e);if("elu"===t)return(0,a.P)(e);if("relu6"===t)return(0,u.j)(e);if("prelu"===t)return(0,o.N)(e,r);else if("leakyrelu"===t)return(0,s.H)(e,n);else if("sigmoid"===t)return(0,p.r)(e);throw Error(`Unknown fused activation ${t}.`)}let y=(e,t)=>!(e>0)||"linear"===t},30824:(e,t,r)=>{"use strict";r.d(t,{h:()=>i});var n=r(19041),a=r(48592),s=r(76526);let i=(0,r(62176).op)({fft_:function(e){return(0,s.vA)("complex64"===e.dtype,()=>`The dtype for tf.spectral.fft() must be complex64 but got ${e.dtype}.`),n.T2.runKernel(a.rGP,{input:e})}})},31910:(e,t,r)=>{"use strict";r.d(t,{W:()=>o,m:()=>i});var n=r(51520),a=r(49575),s=r(74069);function i(e){let{inputs:t,attrs:r,backend:n}=e,{x:i}=t,{perm:o}=r;(0,a.C)(i,"transpose");let l=Array(i.shape.length);for(let e=0;e<l.length;e++)l[e]=i.shape[o[e]];let u=n.data.get(i.dataId).values,h=(0,s._)(u,i.shape,i.dtype,o,l);return{dataId:n.write(h,l,i.dtype),shape:l,dtype:i.dtype}}let o={kernelName:n.wx0,backendName:"cpu",kernelFunc:i}},32232:(e,t,r)=>{"use strict";r.d(t,{C:()=>l,_:()=>i});var n=r(51520),a=r(81600),s=r(87095);let i=(0,a.o)((e,t)=>{let{pattern:r,replaceGlobal:n,rewrite:a}=t;return e.replace(new RegExp(r,n?"g":""),a)}),o=(0,s.F)(n.GZp,i),l={kernelName:n.GZp,backendName:"cpu",kernelFunc:o}},32259:(e,t,r)=>{"use strict";r.d(t,{Fx:()=>l,px:()=>i});var n=r(51520),a=r(81600),s=r(87095);let i=(0,a.o)(e=>Math.log(e)),o=(0,s.F)(n.tG8,i),l={kernelName:n.tG8,backendName:"cpu",kernelFunc:o}},32294:(e,t,r)=>{"use strict";function n(e,t=!1){console.log(e.toString(t))}r.d(t,{y:()=>n})},32428:(e,t,r)=>{"use strict";r.d(t,{n:()=>o});var n=r(19041),a=r(48592),s=r(27924),i=r(83231);let o=(0,r(62176).op)({logicalAnd_:function(e,t){let r=(0,s.YT)(e,"a","logicalAnd","bool"),o=(0,s.YT)(t,"b","logicalAnd","bool");return(0,i.assertAndGetBroadcastShape)(r.shape,o.shape),n.T2.runKernel(a.RUm,{a:r,b:o})}})},33120:(e,t,r)=>{"use strict";r.d(t,{a:()=>l});var n=r(51520),a=r(14811),s=r(97344),i=r(1560);let o=new Set(["bilinear","nearest"]);class l extends a.Wd{constructor(e){if(super(e),this.height=e.height,this.width=e.width,e.interpolation)if(o.has(e.interpolation))this.interpolation=e.interpolation;else throw new s.Qp(`Invalid interpolation parameter: ${e.interpolation} is not implemented`);else this.interpolation="bilinear";this.cropToAspectRatio=!!e.cropToAspectRatio}computeOutputShape(e){let t=(e=(0,i.U$)(e))[2];return[this.height,this.width,t]}getConfig(){let e={height:this.height,width:this.width,interpolation:this.interpolation,cropToAspectRatio:this.cropToAspectRatio};return Object.assign(e,super.getConfig()),e}call(e,t){return(0,n.DZQ)(()=>{let t=[this.height,this.width];if("bilinear"===this.interpolation)return n.Slp.resizeBilinear(e,t,!this.cropToAspectRatio);if("nearest"===this.interpolation)return n.Slp.resizeNearestNeighbor(e,t,!this.cropToAspectRatio);throw Error(`Interpolation is ${this.interpolation} but only ${[...o]} are supported`)})}}l.className="Resizing",n.JFn.registerClass(l)},33699:(e,t,r)=>{"use strict";r.d(t,{HS:()=>s,di:()=>i,lv:()=>o});var n=r(51520),a=r(49575);function s(e,t,r,a,s){let i=n.Kro.isSliceContinous(a,t,r),o=n.ZSL.sizeFromShape(r),l=n.ZSL.computeStrides(a);if(i){let r=n.Kro.computeFlatOffset(t,l);return"string"===s?e.slice(r,r+o):e.subarray(r,r+o)}let u="string"===s?n.C0T.fromUint8ToStringArray(e):e,h=(0,n.ra8)(a,s,u),p=(0,n.ra8)(r,s);for(let e=0;e<p.size;++e){let r=p.indexToLoc(e),n=r.map((e,r)=>e+t[r]);p.set(h.get(...n),...r)}return"string"===s?n.C0T.fromStringArrayToUint8(p.values):p.values}function i(e){let{inputs:t,backend:r,attrs:i}=e,{x:o}=t,{begin:l,size:u}=i;(0,a.C)(o,"slice");let[h,p]=n.Kro.parseSliceParams(o,l,u);n.Kro.assertParamsValid(o,h,p);let d=s(r.data.get(o.dataId).values,h,p,o.shape,o.dtype);return r.makeTensorInfo(p,o.dtype,d)}let o={kernelName:n.JiE,backendName:"cpu",kernelFunc:i}},34726:(e,t,r)=>{"use strict";r.d(t,{n:()=>l});var n=r(51520),a=r(47700),s=r(20783),i=r(60217),o=r(26981);class l{constructor(e){this.outputTexture=null,this.program=null,this.disposed=!1,this.itemsToPoll=[];let t=(0,n._K2)().getNumber("WEBGL_VERSION");if(null!=e?(this.gl=e,(0,a.lj)(t,e)):this.gl=(0,a.bU)(t),e=this.gl,2===(0,n._K2)().getNumber("WEBGL_VERSION")){let t=e;this.createVertexArray=()=>o.callAndCheck(t,()=>t.createVertexArray()),this.bindVertexArray=e=>o.callAndCheck(t,()=>t.bindVertexArray(e)),this.deleteVertexArray=e=>o.callAndCheck(t,()=>t.deleteVertexArray(e)),this.getVertexArray=()=>o.callAndCheck(t,()=>t.getParameter(t.VERTEX_ARRAY_BINDING))}else if(null!=e){let t=e.getExtension("OES_vertex_array_object");
69if(null==t)throw Error("All WebGL1 implementations are expected to offer OES_vertex_array_object.");this.createVertexArray=()=>o.callAndCheck(e,()=>t.createVertexArrayOES()),this.bindVertexArray=r=>o.callAndCheck(e,()=>t.bindVertexArrayOES(r)),this.deleteVertexArray=r=>o.callAndCheck(e,()=>t.deleteVertexArrayOES(r)),this.getVertexArray=()=>o.callAndCheck(e,()=>e.getParameter(t.VERTEX_ARRAY_BINDING_OES))}let r="WEBGL_color_buffer_float",l="EXT_color_buffer_half_float";if(this.parallelCompilationExtension=this.gl.getExtension("KHR_parallel_shader_compile"),1===(0,n._K2)().getNumber("WEBGL_VERSION")){let e="OES_texture_half_float";if(this.textureFloatExtension=o.getExtensionOrThrow(this.gl,"OES_texture_float"),o.hasExtension(this.gl,e))this.textureHalfFloatExtension=o.getExtensionOrThrow(this.gl,e);else if((0,n._K2)().get("WEBGL_FORCE_F16_TEXTURES"))throw 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(r),o.hasExtension(this.gl,l))this.colorBufferHalfFloatExtension=o.getExtensionOrThrow(this.gl,l);else if((0,n._K2)().get("WEBGL_FORCE_F16_TEXTURES"))throw Error("GL context does not support color renderable half floats, yet the environment flag WEBGL_FORCE_F16_TEXTURES is set to true.")}else if(r="EXT_color_buffer_float",o.hasExtension(this.gl,r))this.colorBufferFloatExtension=this.gl.getExtension(r);else if(o.hasExtension(this.gl,l))this.colorBufferHalfFloatExtension=this.gl.getExtension(l);else throw Error("GL context does not support color renderable floats");this.vertexBuffer=s.createVertexBuffer(this.gl),this.indexBuffer=s.createIndexBuffer(this.gl),this.framebuffer=o.createFramebuffer(this.gl),this.textureConfig=i.EZ(this.gl,this.textureHalfFloatExtension)}get debug(){return(0,n._K2)().getBool("DEBUG")}dispose(){if(this.disposed)return;null!=this.program&&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."),null!=this.outputTexture&&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;o.callAndCheck(e,()=>e.finish()),o.callAndCheck(e,()=>e.bindFramebuffer(e.FRAMEBUFFER,null)),o.callAndCheck(e,()=>e.deleteFramebuffer(this.framebuffer)),o.callAndCheck(e,()=>e.bindBuffer(e.ARRAY_BUFFER,null)),o.callAndCheck(e,()=>e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,null)),o.callAndCheck(e,()=>e.deleteBuffer(this.indexBuffer)),this.disposed=!0}createFloat32MatrixTexture(e,t){return this.throwIfDisposed(),s.createFloat32MatrixTexture(this.gl,e,t,this.textureConfig)}createFloat16MatrixTexture(e,t){return this.throwIfDisposed(),s.createFloat16MatrixTexture(this.gl,e,t,this.textureConfig)}createUnsignedBytesMatrixTexture(e,t){return this.throwIfDisposed(),s.createUnsignedBytesMatrixTexture(this.gl,e,t,this.textureConfig)}uploadPixelDataToTexture(e,t){this.throwIfDisposed(),s.uploadPixelDataToTexture(this.gl,e,t)}uploadDenseMatrixToTexture(e,t,r,n){this.throwIfDisposed(),s.uploadDenseMatrixToTexture(this.gl,e,t,r,n,this.textureConfig)}createFloat16PackedMatrixTexture(e,t){return this.throwIfDisposed(),s.createFloat16PackedMatrixTexture(this.gl,e,t,this.textureConfig)}createPackedMatrixTexture(e,t){return this.throwIfDisposed(),s.createPackedMatrixTexture(this.gl,e,t,this.textureConfig)}deleteMatrixTexture(e){this.throwIfDisposed(),this.outputTexture===e&&(o.unbindColorTextureFromFramebuffer(this.gl,this.framebuffer),this.outputTexture=null),o.callAndCheck(this.gl,()=>this.gl.deleteTexture(e))}downloadByteEncodedFloatMatrixFromOutputTexture(e,t,r){return this.downloadMatrixDriver(e,()=>s.downloadByteEncodedFloatMatrixFromOutputTexture(this.gl,t,r,this.textureConfig))}downloadPackedMatrixFromBuffer(e,t,r,n,a,i){return s.downloadPackedMatrixFromBuffer(this.gl,e,t,r,n,a,i,this.textureConfig)}downloadFloat32MatrixFromBuffer(e,t){return s.downloadFloat32MatrixFromBuffer(this.gl,e,t)}createBufferFromTexture(e,t,r){this.bindTextureToFrameBuffer(e);let n=s.createBufferFromOutputTexture(this.gl,t,r,this.textureConfig);return this.unbindTextureToFrameBuffer(),n}createAndWaitForFence(){let e=this.createFence(this.gl);
69return this.pollFence(e)}createFence(e){let t,r;if((0,n._K2)().getBool("WEBGL_FENCE_API_ENABLED")){let n=e.fenceSync(e.SYNC_GPU_COMMANDS_COMPLETE,0);e.flush(),r=()=>{let t=e.clientWaitSync(n,0,0);return t===e.ALREADY_SIGNALED||t===e.CONDITION_SATISFIED},t=n}else(0,n._K2)().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")>0?(t=this.beginQuery(),this.endQuery(),r=()=>this.isQueryAvailable(t,(0,n._K2)().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION"))):r=()=>!0;return{query:t,isFencePassed:r}}downloadMatrixFromPackedTexture(e,t,r){return this.downloadMatrixDriver(e,()=>s.downloadMatrixFromPackedOutputTexture(this.gl,t,r))}createProgram(e){this.throwIfDisposed();let t=this.gl;null==this.vertexShader&&(this.vertexShader=s.createVertexShader(t));let r=o.createProgram(t);o.callAndCheck(t,()=>t.attachShader(r,this.vertexShader)),o.callAndCheck(t,()=>t.attachShader(r,e)),o.linkProgram(t,r);let n=Object.assign(r,{vao:this.createVertexArray()});return this.debug&&o.validateProgram(t,n),n}buildVao(e){this.setProgram(e),this.bindVertexArray(e.vao);let t=this.gl;o.callAndCheck(t,()=>t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,this.indexBuffer)),s.bindVertexProgramAttributeStreams(t,e,this.vertexBuffer)}deleteProgram(e){this.throwIfDisposed(),e===this.program&&(this.program=null),null!=e&&(o.callAndCheck(this.gl,()=>this.gl.deleteProgram(e)),this.deleteVertexArray(e.vao))}setProgram(e){this.throwIfDisposed(),this.program=e,null!=this.program&&this.debug&&o.validateProgram(this.gl,this.program),o.callAndCheck(this.gl,()=>this.gl.useProgram(e))}getUniformLocation(e,t,r=!0){return(this.throwIfDisposed(),r)?o.getProgramUniformLocationOrThrow(this.gl,e,t):o.getProgramUniformLocation(this.gl,e,t)}getAttributeLocation(e,t){return this.throwIfDisposed(),o.callAndCheck(this.gl,()=>this.gl.getAttribLocation(e,t))}getUniformLocationNoThrow(e,t){return this.throwIfDisposed(),this.gl.getUniformLocation(e,t)}setInputMatrixTexture(e,t,r){this.throwIfDisposed(),this.throwIfNoProgram(),o.bindTextureToProgramUniformSampler(this.gl,e,t,r)}setOutputMatrixTexture(e,t,r){this.setOutputMatrixTextureDriver(e,r,t)}setOutputPackedMatrixTexture(e,t,r){this.throwIfDisposed();let[n,a]=i.NO(t,r);this.setOutputMatrixTextureDriver(e,n,a)}setOutputMatrixWriteRegion(e,t,r,n){this.setOutputMatrixWriteRegionDriver(r,e,n,t)}setOutputPackedMatrixWriteRegion(e,t,r,n){throw Error("setOutputPackedMatrixWriteRegion not implemented.")}debugValidate(){null!=this.program&&o.validateProgram(this.gl,this.program),o.validateFramebuffer(this.gl)}executeProgram(){this.throwIfDisposed(),this.throwIfNoProgram();let e=this.gl;this.debug&&(console.assert(this.getVertexArray()===this.program.vao,"VAO changed between setProgram and executeProgram!"),this.debugValidate()),o.callAndCheck(e,()=>e.drawElements(e.TRIANGLES,6,e.UNSIGNED_SHORT,0))}blockUntilAllProgramsCompleted(){this.throwIfDisposed(),o.callAndCheck(this.gl,()=>this.gl.finish())}getQueryTimerExtension(){return null==this.disjointQueryTimerExtension&&(this.disjointQueryTimerExtension=o.getExtensionOrThrow(this.gl,2===(0,n._K2)().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")?"EXT_disjoint_timer_query_webgl2":"EXT_disjoint_timer_query")),this.disjointQueryTimerExtension}getQueryTimerExtensionWebGL2(){return this.getQueryTimerExtension()}getQueryTimerExtensionWebGL1(){return this.getQueryTimerExtension()}beginQuery(){if(2===(0,n._K2)().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")){let e=this.gl,t=this.getQueryTimerExtensionWebGL2(),r=e.createQuery();return e.beginQuery(t.TIME_ELAPSED_EXT,r),r}let e=this.getQueryTimerExtensionWebGL1(),t=e.createQueryEXT();return e.beginQueryEXT(e.TIME_ELAPSED_EXT,t),t}endQuery(){if(2===(0,n._K2)().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")){let e=this.gl,t=this.getQueryTimerExtensionWebGL2();e.endQuery(t.TIME_ELAPSED_EXT);return}let e=this.getQueryTimerExtensionWebGL1();e.endQueryEXT(e.TIME_ELAPSED_EXT)}async waitForQueryAndGetTime(e){return await n.ZSL.repeatedTry(()=>this.disposed||this.isQueryAvailable(e,(0,n._K2)().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION"))),this.getQueryTime(e,(0,n._K2)().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION"))}getQueryTime(e,t){if(0===t)return null;if(2===t){let t=this.gl;return t.getQueryParameter(e,t.QUERY_RESULT)/1e6}{let t=this.getQueryTimerExtensionWebGL1();return t.getQueryObjectEXT(e,t.QUERY_RESULT_EXT)/1e6}}isQueryAvailable(e,t){if(0===t)return!0;
69if(2===t){let t=this.gl,r=this.getQueryTimerExtensionWebGL2(),n=t.getQueryParameter(e,t.QUERY_RESULT_AVAILABLE);return null==this.disjoint&&(this.disjoint=this.gl.getParameter(r.GPU_DISJOINT_EXT)),n&&!this.disjoint}{let t=this.getQueryTimerExtensionWebGL1(),r=t.getQueryObjectEXT(e,t.QUERY_RESULT_AVAILABLE_EXT);return null==this.disjoint&&(this.disjoint=this.gl.getParameter(t.GPU_DISJOINT_EXT)),r&&!this.disjoint}}pollFence(e){return new Promise(t=>{this.addItemToPoll(()=>e.isFencePassed(),()=>t())})}pollItems(){let e=function(e){let t=0;for(;t<e.length&&e[t]();++t);return t-1}(this.itemsToPoll.map(e=>e.isDoneFn));for(let t=0;t<=e;++t){let{resolveFn:e}=this.itemsToPoll[t];e()}this.itemsToPoll=this.itemsToPoll.slice(e+1)}addItemToPoll(e,t){let r;this.itemsToPoll.push({isDoneFn:e,resolveFn:t}),this.itemsToPoll.length>1||("setTimeoutCustom"in(0,n._K2)().platform&&(r=(0,n._K2)().platform.setTimeoutCustom.bind((0,n._K2)().platform)),n.ZSL.repeatedTry(()=>(this.pollItems(),0===this.itemsToPoll.length),()=>0,null,r))}bindTextureToFrameBuffer(e){this.throwIfDisposed(),o.bindColorTextureToFramebuffer(this.gl,e,this.framebuffer),this.debug&&o.validateFramebuffer(this.gl)}unbindTextureToFrameBuffer(){null!=this.outputTexture?(o.bindColorTextureToFramebuffer(this.gl,this.outputTexture,this.framebuffer),this.debug&&o.validateFramebuffer(this.gl)):o.unbindColorTextureFromFramebuffer(this.gl,this.framebuffer)}downloadMatrixDriver(e,t){this.bindTextureToFrameBuffer(e);let r=t();return this.unbindTextureToFrameBuffer(),r}setOutputMatrixTextureDriver(e,t,r){this.throwIfDisposed();let n=this.gl;o.bindColorTextureToFramebuffer(n,e,this.framebuffer),this.debug&&o.validateFramebuffer(n),this.outputTexture=e,o.callAndCheck(n,()=>n.viewport(0,0,t,r)),o.callAndCheck(n,()=>n.scissor(0,0,t,r))}setOutputMatrixWriteRegionDriver(e,t,r,n){this.throwIfDisposed(),o.callAndCheck(this.gl,()=>this.gl.scissor(e,t,r,n))}throwIfDisposed(){if(this.disposed)throw Error("Attempted to use disposed GPGPUContext.")}throwIfNoProgram(){if(null==this.program)throw Error("No GPU program is currently set.")}}},35003:(e,t,r)=>{"use strict";r.d(t,{LY:()=>l,f6:()=>i});var n=r(51520),a=r(16986),s=r(75017);let i=(0,a.Z)((e,t)=>e&t),o=(0,s.j)(n.HNs,i),l={kernelName:n.HNs,backendName:"cpu",kernelFunc:o}},35981:(e,t,r)=>{"use strict";r.d(t,{t:()=>o});var n=r(19041),a=r(48592),s=r(27924),i=r(76526);let o=(0,r(62176).op)({stack_:function(e,t=0){let r=(0,s.j1)(e,"tensors","stack","string_or_numeric");return i.vA(r.length>=1,()=>"Pass at least one tensor to tf.stack"),r.length>0&&i.vA(t<=r[0].rank,()=>"Axis must be <= rank of the tensor"),n.T2.runKernel(a.mM$,r,{axis:t})}})},36452:(e,t,r)=>{"use strict";r.d(t,{Yp:()=>l,uM:()=>i});var n=r(51520),a=r(81600),s=r(87095);let i=(0,a.o)(e=>Math.expm1(e)),o=(0,s.F)(n.ybj,i),l={kernelName:n.ybj,backendName:"cpu",kernelFunc:o}},36565:(e,t,r)=>{"use strict";r.d(t,{LC:()=>o,RY:()=>l,z3:()=>i});var n=r(51520),a=r(16986),s=r(75017);let i=(0,a.Z)((e,t)=>+(e===t)),o=(0,s.j)(n.BRl,i,null,"bool"),l={kernelName:n.BRl,backendName:"cpu",kernelFunc:o}},36705:(e,t,r)=>{"use strict";r.d(t,{R:()=>o});var n=r(19041),a=r(48592),s=r(27924),i=r(76526);let o=(0,r(62176).op)({depthToSpace_:function(e,t,r="NHWC"){let o=(0,s.YT)(e,"x","depthToSpace","float32"),l="NHWC"===r?o.shape[1]:o.shape[2],u="NHWC"===r?o.shape[2]:o.shape[3],h="NHWC"===r?o.shape[3]:o.shape[1];return i.vA(t>1,()=>`blockSize should be > 1 for depthToSpace, but was: ${t}`),i.vA(l*t>=0,()=>`Negative dimension size caused by overflow when multiplying 70 ${l} and ${t} for depthToSpace with input shape 71 ${o.shape}`),i.vA(u*t>=0,()=>`Negative dimension size caused by overflow when multiplying 72 ${u} and ${t} for depthToSpace with input shape 73 ${o.shape}`),i.vA(h%(t*t)==0,()=>`Dimension size must be evenly divisible by ${t*t} but is ${h} for depthToSpace with input shape ${o.shape}`),n.T2.runKernel(a.TMz,{x:o},{blockSize:t,dataFormat:r})}})},36799:(e,t,r)=>{"use strict";r.d(t,{D:()=>a});var n=r(47537);class a{static join(e){return new a(e).slice()}constructor(e){if(this.shards=[],this.previousShardIndex=0,null==e||(e instanceof Array||(e=[e]),0===(e=e.map(e=>n.isTypedArray(e)?e.buffer:e)).length))return;this.bufferUniformSize=e[0].byteLength;let t=0;for(let r=0;r<e.length;r++){let n=e[r];r!==e.length-1&&n.byteLength!==this.bufferUniformSize&&(this.bufferUniformSize=void 0);let a=t+n.byteLength;this.shards.push({buffer:n,start:t,end:a}),t=a}0===this.shards.length&&(this.byteLength=0),this.byteLength=this.shards[this.shards.length-1].end}slice(e=0,t=this.byteLength){if(0===this.shards.length||(e=isNaN(Number(e))?0:e,t=isNaN(Number(t))?0:t,e=Math.max(0,e),(t=Math.min(this.byteLength,t))<=e))return new ArrayBuffer(0);let r=this.findShardForByte(e);if(-1===r)throw Error(`Could not find start shard for byte ${e}`);let n=new ArrayBuffer(t-e),a=new Uint8Array(n),s=0;for(let n=r;n<this.shards.length;n++){let r=this.shards[n],i=e+s-r.start,o=s,l=Math.min(t,r.end)-r.start,u=new Uint8Array(r.buffer,i,l-i);if(a.set(u,o),s+=u.length,t<r.end)break}return n}findShardForByte(e){if(0===this.shards.length||e<0||e>=this.byteLength)return -1;if(null!=this.bufferUniformSize)return this.previousShardIndex=Math.floor(e/this.bufferUniformSize),this.previousShardIndex;function t(t){return e<t.start?-1:+(e>=t.end)}if(0===t(this.shards[this.previousShardIndex]))return this.previousShardIndex;let r=function(e,t){let r=0,n=e.length;for(;r<=n;){let a=Math.floor((n-r)/2)+r,s=t(e[a]);if(0===s)return a;s<0?n=a:r=a+1}return -1}(this.shards,t);return -1===r?-1:(this.previousShardIndex=r,this.previousShardIndex)}}},36958:(e,t,r)=>{"use strict";r.d(t,{AC:()=>l,oN:()=>o,sG:()=>i});var n=r(51520),a=r(81600),s=r(87095);let i=(0,a.o)(e=>Math.exp(e)),o=(0,s.F)(n.ox3,i,"float32"),l={kernelName:n.ox3,backendName:"cpu",kernelFunc:o}},37095:(e,t,r)=>{"use strict";r.d(t,{g:()=>f});var n=r(51520),a=r(73187),s=r(90556),i=r(15034),o=r(8785),l=r(97344),u=r(96902),h=r(65650),p=r(62041),d=r(1560),c=r(13221);class f extends c.kO{constructor(e){super(2,e),this.depthwiseKernel=null,this.depthMultiplier=null==e.depthMultiplier?1:e.depthMultiplier,this.depthwiseInitializer=(0,u.Fe)(e.depthwiseInitializer||this.DEFAULT_KERNEL_INITIALIZER),this.depthwiseConstraint=(0,o.YZ)(e.depthwiseConstraint),this.depthwiseRegularizer=(0,h.Bm)(e.depthwiseRegularizer)}build(e){if((e=(0,d.U$)(e)).length<4)throw new l.Qp(`Inputs to DepthwiseConv2D should have rank 4. Received input shape: ${JSON.stringify(e)}.`);let t="channelsFirst"===this.dataFormat?1:3;if(null==e[t]||e[t]<0)throw new l.Qp(`The channel dimension of the inputs to DepthwiseConv2D should be defined, but is not (${e[t]}).`);let r=e[t],n=[this.kernelSize[0],this.kernelSize[1],r,this.depthMultiplier];this.depthwiseKernel=this.addWeight("depthwise_kernel",n,null,this.depthwiseInitializer,this.depthwiseRegularizer,!0,this.depthwiseConstraint),this.useBias?this.bias=this.addWeight("bias",[r*this.depthMultiplier],null,this.biasInitializer,this.biasRegularizer,!0,this.biasConstraint):this.bias=null,this.built=!0}call(e,t){return(0,n.DZQ)(()=>
73{let t=function(e,t,r=[1,1],s="valid",o,u){return(0,n.DZQ)(()=>{null==o&&(o=(0,a.VI)()),(0,i.uM)(o);let u=(0,c.RK)(e,o);if(4!==e.rank)throw new l.Qp(`Input for depthwiseConv2d is required to be 4-D, but is instead ${e.rank}-D`);if(4!==t.rank)throw new l.Qp(`depthwiseKernel is required to be 4-D, but is instead ${t.rank}-D`);return u=n.Gl3(u,t,r,"same"===s?"same":"valid","NHWC",null),"channelsFirst"===o&&(u=n.mgz(u,[0,3,1,2])),u})}(e=(0,d.un)(e),this.depthwiseKernel.read(),this.strides,this.padding,this.dataFormat,0);return this.useBias&&(t=s.ni(t,this.bias.read(),this.dataFormat)),null!=this.activation&&(t=this.activation.apply(t)),t})}computeOutputShape(e){e=(0,d.U$)(e);let t="channelsFirst"===this.dataFormat?e[2]:e[1],r="channelsFirst"===this.dataFormat?e[3]:e[2],n="channelsFirst"===this.dataFormat?e[1]*this.depthMultiplier:e[3]*this.depthMultiplier,a=(0,p.Ol)(t,this.kernelSize[0],this.padding,this.strides[0]),s=(0,p.Ol)(r,this.kernelSize[1],this.padding,this.strides[1]);return"channelsFirst"===this.dataFormat?[e[0],n,a,s]:[e[0],a,s,n]}getConfig(){let e=super.getConfig();return e.depthMultiplier=this.depthMultiplier,e.depthwiseInitializer=(0,u.zo)(this.depthwiseInitializer),e.depthwiseRegularizer=(0,h.R9)(this.depthwiseRegularizer),e.depthwiseConstraint=(0,o.uH)(this.depthwiseRegularizer),e}}f.className="DepthwiseConv2D",n.JFn.registerClass(f)},38308:(e,t,r)=>{"use strict";r.d(t,{n:()=>h});var n=r(10551),a=r(27924),s=r(48683),i=r(28235),o=r(62176),l=r(75761),u=r(96247);let h=(0,o.op)({logSigmoid_:function(e){let t=(0,a.YT)(e,"x","logSigmoid");return(0,n._X)(e=>({value:(0,i.H)((0,u.l)((0,i.H)(e))),gradFunc:t=>(0,s.l)(t,(0,l.r)((0,i.H)(e)))}))(t)}})},38773:(e,t,r)=>{"use strict";r.d(t,{G:()=>h});var n=r(19041),a=r(48592),s=r(27924),i=r(76526),o=r(39114),l=r(62176),u=r(68567);let h=(0,l.op)({depthwiseConv2d_:function(e,t,r,l,h="NHWC",p=[1,1],d){let c=(0,s.YT)(e,"x","depthwiseConv2d","float32"),f=(0,s.YT)(t,"filter","depthwiseConv2d","float32"),m=c,g=!1;3===c.rank&&(g=!0,m=(0,u.t)(c,[1,c.shape[0],c.shape[1],c.shape[2]])),i.vA(4===m.rank,()=>`Error in depthwiseConv2d: input must be rank 4, but got rank ${m.rank}.`),i.vA(4===f.rank,()=>`Error in depthwiseConv2d: filter must be rank 4, but got rank ${f.rank}.`);let y="NHWC"===h?m.shape[3]:m.shape[1];i.vA(y===f.shape[2],()=>`Error in depthwiseConv2d: number of input channels (${y}) must match the inChannels dimension in filter ${f.shape[2]}.`),o.s_("depthwiseConv2d",l,d);let b={x:m,filter:f},x=n.T2.runKernel(a.tGH,b,{strides:r,pad:l,dataFormat:h,dilations:p,dimRoundingMode:d});return g?(0,u.t)(x,[x.shape[1],x.shape[2],x.shape[3]]):x}})},39114:(e,t,r)=>{"use strict";r.d(t,{$Q:()=>y,Dh:()=>f,E6:()=>s,G0:()=>m,G8:()=>u,YQ:()=>a,l5:()=>i,p$:()=>l,qk:()=>g,s_:()=>b,uf:()=>o});var n=r(76526);function a(e,t,r,n,s="NHWC",i){let l=[...t,e[3]];return o(e,l,r,i,n,null,null,y(s))}function s(e,t,r,n,a,i,l="channelsLast"){let u,[p,d]=h(t);if("channelsLast"===l)u=[p,d,e[3],e[3]];else if("channelsFirst"===l)u=[p,d,e[1],e[1]];else throw Error(`Unknown dataFormat ${l}`);return o(e,u,r,n,a,i,!1,l)}function i(e,t,r,n,a,s,o="NDHWC"){let u,h,[d,c,f]=p(t);if("NDHWC"===o)h="channelsLast",u=[d,c,f,e[4],e[4]];else if("NCDHW"===o)h="channelsFirst",u=[d,c,f,e[1],e[1]];else throw Error(`Unknown dataFormat ${o}`);return l(e,u,r,n,a,!1,h,s)}function o(e,t,r,n,a,s,i=!1,l="channelsLast"){let p,[f,m,g,y]=[-1,-1,-1,-1];if("channelsLast"===l)[f,m,g,y]=e;else if("channelsFirst"===l)[f,y,m,g]=e;else throw Error(`Unknown dataFormat ${l}`);let[b,x,,v]=t,[w,T]=h(r),[S,N]=h(n),k=d(b,S),I=d(x,N),{padInfo:C,outHeight:E,outWidth:A}=function(e,t,r,n,a,s,i,o,l){let h,p,d;if("number"==typeof e){let a=0===e?"VALID":"NUMBER";h={top:e,bottom:e,left:e,right:e,type:a};let i=function(e,t,r,n,a){null==n&&(n=u(e,t,r));let s=e[0],i=e[1];return[c((s-t+2*n)/r+1,a),c((i-t+2*n)/r+1,a)]}([t,r],s,n,e,o);p=i[0],d=i[1]}else if("same"===e){let e=Math.max(0,((p=Math.ceil(t/n))-1)*n+s-t),o=Math.max(0,((d=Math.ceil(r/a))-1)*a+i-r),l=Math.floor(e/2),u=Math.floor(o/2);h={top:l,bottom:e-l,left:u,right:o-u,type:"SAME"}}else if("valid"===e)h={top:0,bottom:0,left:0,right:0,type:"VALID"},p=Math.ceil((t-s+1)/n),d=Math.ceil((r-i+1)/a);else if("object"==typeof e){let u="channelsLast"===l?e[1][0]:e[2][0],f="channelsLast"===l?e[1][1]:e[2][1],m="channelsLast"===l?e[2][0]:e[3][0],g="channelsLast"===l?e[2][1]:e[3][1];h={top:u,bottom:f,left:m,right:g,type:0===u&&0===f&&0===m&&0===g?"VALID":"EXPLICIT"},p=c((t-s+u+f)/n+1,o),d=c((r-i+m+g)/a+1,o)}else throw Error(`Unknown padding parameter: ${e}`);return{padInfo:h,outHeight:p,outWidth:d}}(a,m,g,w,T,k,I,s,l),$=i?v*y:v;return"channelsFirst"===l?p=[f,$,E,A]:"channelsLast"===l&&(p=[f,E,A,$]),{batchSize:f,dataFormat:l,inHeight:m,inWidth:g,inChannels:y,outHeight:E,outWidth:A,outChannels:$,padInfo:C,strideHeight:w,strideWidth:T,filterHeight:b,filterWidth:x,effectiveFilterHeight:k,effectiveFilterWidth:I,dilationHeight:S,dilationWidth:N,inShape:e,outShape:p,filterShape:t}}function l(e,t,r,n,a,s=!1,i="channelsLast",o){let h,[f,m,g,y,b]=[-1,-1,-1,-1,-1];if("channelsLast"===i)[f,m,g,y,b]=e;else if("channelsFirst"===i)[f,b,m,g,y]=e;else throw Error(`Unknown dataFormat ${i}`);let[x,v,w,,T]=t,[S,N,k]=p(r),[I,C,E]=p(n),A=d(x,I),$=d(v,C),F=d(w,E),{padInfo:R,outDepth:_,outHeight:D,outWidth:O}=function(e,t,r,n,a,s,i,o,l,h,p){let d,f,m,g;if("valid"===e&&(e=0),"number"==typeof e){let y=0===e?"VALID":"NUMBER";d={top:e,bottom:e,left:e,right:e,front:e,back:e,type:y};let b=function(e,t,r,n,a,s){null==a&&(a=u(e,t[0],n[0]));let i=[0,0,0,1];for(let r=0;r<3;r++)e[r]+2*a>=t[r]&&(i[r]=c((e[r]-t[r]+2*a)/n[r]+1,s));return i}([t,r,n,1],[o,l,h],0,[a,s,i],e,p);f=b[0],m=b[1],g=b[2]}
73else if("same"===e){let e=((f=Math.ceil(t/a))-1)*a+o-t,u=((m=Math.ceil(r/s))-1)*s+l-r,p=((g=Math.ceil(n/i))-1)*i+h-n,c=Math.floor(e/2),y=Math.floor(u/2),b=Math.floor(p/2);d={top:y,bottom:u-y,left:b,right:p-b,front:c,back:e-c,type:"SAME"}}else throw Error(`Unknown padding parameter: ${e}`);return{padInfo:d,outDepth:f,outHeight:m,outWidth:g}}(a,m,g,y,S,N,k,A,$,F,o),L=s?T*b:T;return"channelsFirst"===i?h=[f,L,_,D,O]:"channelsLast"===i&&(h=[f,_,D,O,L]),{batchSize:f,dataFormat:i,inDepth:m,inHeight:g,inWidth:y,inChannels:b,outDepth:_,outHeight:D,outWidth:O,outChannels:L,padInfo:R,strideDepth:S,strideHeight:N,strideWidth:k,filterDepth:x,filterHeight:v,filterWidth:w,effectiveFilterDepth:A,effectiveFilterHeight:$,effectiveFilterWidth:F,dilationDepth:I,dilationHeight:C,dilationWidth:E,inShape:e,outShape:h,filterShape:t}}function u(e,t,r,n=1){let a=d(t,n);return Math.floor((e[0]*(r-1)-r+a)/2)}function h(e){return"number"==typeof e?[e,e,e]:2===e.length?[e[0],e[1],1]:e}function p(e){return"number"==typeof e?[e,e,e]:e}function d(e,t){return t<=1?e:e+(e-1)*(t-1)}function c(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 Error(`Unknown roundingMode ${t}`)}}function f(e){let[t,r,n]=h(e);return 1===t&&1===r&&1===n}function m(e,t){return f(e)||f(t)}function g(e){return h(e).every(e=>e>0)}function y(e){if("NHWC"===e)return"channelsLast";if("NCHW"===e)return"channelsFirst";throw Error(`Unknown dataFormat ${e}`)}function b(e,t,r){if(null!=r)if("string"==typeof t)throw Error(`Error in ${e}: pad must be an integer when using dimRoundingMode ${r} but got pad ${t}.`);else if("number"==typeof t)n.vA(n.E6(t),()=>`Error in ${e}: pad must be an integer when using dimRoundingMode ${r} but got pad ${t}.`);else if("object"==typeof t)t.forEach(t=>{t.forEach(t=>{n.vA(n.E6(t),()=>`Error in ${e}: pad must be an integer when using dimRoundingMode ${r} but got pad ${t}.`)})});else throw Error(`Error in ${e}: Unknown padding parameter: ${t}`)}},39500:(e,t,r)=>{"use strict";r.d(t,{W:()=>i});var n=r(19041),a=r(48592),s=r(27924);let i=(0,r(62176).op)({selu_:function(e){let t=(0,s.YT)(e,"x","selu");return n.T2.runKernel(a.u$b,{x:t})}})},39646:(e,t,r)=>{"use strict";r.d(t,{O:()=>l});var n=r(27924),a=r(76526),s=r(67454),i=r(62176),o=r(68567);let l=(0,i.op)({dot_:function(e,t){let r=(0,n.YT)(e,"t1","dot"),i=(0,n.YT)(t,"t2","dot");a.vA((1===r.rank||2===r.rank)&&(1===i.rank||2===i.rank),()=>`Error in dot: inputs must all be rank 1 or 2, but got ranks ${r.rank} and ${i.rank}.`);let l=1===r.rank?r.size:r.shape[1],u=1===i.rank?i.size:i.shape[0];if(a.vA(l===u,()=>`Error in dot: inner dimensions of inputs must match, but got ${l} and ${u}.`),1===r.rank&&1===i.rank){let e=(0,o.t)(r,[1,-1]),t=(0,o.t)(i,[-1,1]),n=(0,s.N)(e,t);return(0,o.t)(n,[])}if(1===r.rank&&2===i.rank){let e=(0,o.t)(r,[1,-1]),t=(0,o.t)(i,[i.shape[0],i.shape[1]]),n=(0,s.N)(e,t);return(0,o.t)(n,[n.size])}if(2===r.rank&&1===i.rank){let e=(0,o.t)(i,[-1,1]),t=(0,s.N)(r,e);return(0,o.t)(t,[t.size])}{let e=(0,o.t)(i,[i.shape[0],i.shape[1]]);return(0,s.N)(r,e)}}})},39758:(e,t,r)=>{"use strict";r.d(t,{v:()=>u});var n=r(19041),a=r(48592),s=r(27924),i=r(76526),o=r(62176),l=r(68567);let u=(0,o.op)({resizeBilinear_:function(e,t,r=!1,o=!1){let u=(0,s.YT)(e,"images","resizeBilinear");i.vA(3===u.rank||4===u.rank,()=>`Error in resizeBilinear: x must be rank 3 or 4, but got rank ${u.rank}.`),i.vA(2===t.length,()=>`Error in resizeBilinear: new shape must 2D, but got shape ${t}.`),i.vA(!1===o||!1===r,()=>"Error in resizeBilinear: If halfPixelCenters is true, alignCorners must be false.");let h=u,p=!1;3===u.rank&&(p=!0,h=(0,l.t)(u,[1,u.shape[0],u.shape[1],u.shape[2]]));let[]=t,d={images:h},c=n.T2.runKernel(a.hgw,d,{alignCorners:r,halfPixelCenters:o,size:t});return p?(0,l.t)(c,[c.shape[1],c.shape[2],c.shape[3]]):c}})},40064:(e,t,r)=>{"use strict";r.d(t,{p:()=>a});var n=r(5565);let a=(0,r(62176).op)({euclideanNorm_:function(e,t=null,r=!1){return(0,n.x)(e,"euclidean",t,r)}})},40459:(e,t,r)=>{"use strict";r.d(t,{G:()=>a});var n=r(51520);function a(e,t,r){let a=(0,n.ra8)(r,e.dtype);for(let r=0;r<a.size;++r){let n=a.indexToLoc(r).slice(),s=n[0],i=n[2],o=t.locToIndex([s,i]);n[2]=t.values[o];let l=e.locToIndex(n);0<=l&&l<e.values.length&&(a.values[r]=e.values[l])}return a}},40953:(e,t,r)=>{"use strict";r.d(t,{H:()=>u});var n=r(19041),a=r(48592),s=r(76526),i=r(39114),o=r(62176),l=r(68567);let u=(0,o.op)({conv2DBackpropFilter_:function(e,t,r,o,u,h="NHWC",p){let d=e;3===e.rank&&(d=(0,l.t)(e,[1,e.shape[0],e.shape[1],e.shape[2]]));let c=t;3===c.rank&&(c=(0,l.t)(t,[1,t.shape[0],t.shape[1],t.shape[2]])),s.vA(4===d.rank,()=>`Error in conv2dDerFilter: input must be rank 4, but got shape ${d.shape}.`),s.vA(4===c.rank,()=>`Error in conv2dDerFilter: dy must be rank 4, but got shape ${c.shape}.`),s.vA(4===r.length,()=>`Error in conv2dDerFilter: filterShape must be length 4, but got ${r}.`);let f="NHWC"===h?d.shape[3]:d.shape[1],m="NHWC"===h?c.shape[3]:c.shape[1];s.vA(f===r[2],()=>`Error in conv2dDerFilter: depth of input ${f}) must match input depth in filter (${r[2]}.`),s.vA(m===r[3],()=>`Error in conv2dDerFilter: depth of dy (${m}) must match output depth for filter (${r[3]}).`),i.s_("conv2dDerFilter",u,p);let g={x:d,dy:c};return n.T2.runKernel(a.rFm,g,{strides:o,pad:u,dataFormat:h,dimRoundingMode:p,filterShape:r})}})},41267:(e,t,r)=>{"use strict";r.d(t,{p:()=>o});var n=r(14811),a=r(51520),s=r(1560),i=r(90556);class o extends n.Wd{constructor(e){super(e),this.scale=e.scale,e.offset?this.offset=e.offset:this.offset=0}getConfig(){let e={scale:this.scale,offset:this.offset};return Object.assign(e,super.getConfig()),e}call(e,t){return(0,a.DZQ)(()=>("float32"!==(e=(0,s.un)(e)).dtype&&(e=i.wg(e,"float32")),(0,a.WQq)((0,a.lKK)(e,this.scale),this.offset)))}}o.className="Rescaling",a.JFn.registerClass(o)}
73,42236:(e,t,r)=>{"use strict";var n=r(51520),a=r(26981);let s=(0,n._K2)();s.registerFlag("HAS_WEBGL",()=>s.getNumber("WEBGL_VERSION")>0),s.registerFlag("WEBGL_VERSION",()=>(0,a.isWebGLVersionEnabled)(2)?2:+!!(0,a.isWebGLVersionEnabled)(1)),s.registerFlag("WEBGL_CHECK_NUMERICAL_PROBLEMS",()=>!1),s.registerFlag("WEBGL_BUFFER_SUPPORTED",()=>2===s.get("WEBGL_VERSION")),s.registerFlag("WEBGL_CPU_FORWARD",()=>!0),s.registerFlag("WEBGL_FORCE_F16_TEXTURES",()=>!1),s.registerFlag("WEBGL_PACK",()=>s.getBool("HAS_WEBGL")),s.registerFlag("WEBGL_PACK_NORMALIZATION",()=>s.getBool("WEBGL_PACK")),s.registerFlag("WEBGL_PACK_CLIP",()=>s.getBool("WEBGL_PACK")),s.registerFlag("WEBGL_PACK_DEPTHWISECONV",()=>s.getBool("WEBGL_PACK")),s.registerFlag("WEBGL_PACK_BINARY_OPERATIONS",()=>s.getBool("WEBGL_PACK")),s.registerFlag("WEBGL_PACK_UNARY_OPERATIONS",()=>s.getBool("WEBGL_PACK")),s.registerFlag("WEBGL_PACK_ARRAY_OPERATIONS",()=>s.getBool("WEBGL_PACK")),s.registerFlag("WEBGL_PACK_IMAGE_OPERATIONS",()=>s.getBool("WEBGL_PACK")),s.registerFlag("WEBGL_PACK_REDUCE",()=>s.getBool("WEBGL_PACK")),s.registerFlag("WEBGL_LAZILY_UNPACK",()=>s.getBool("WEBGL_PACK")),s.registerFlag("WEBGL_CONV_IM2COL",()=>s.getBool("WEBGL_PACK")),s.registerFlag("WEBGL_PACK_CONV2DTRANSPOSE",()=>s.getBool("WEBGL_PACK")),s.registerFlag("WEBGL_MAX_TEXTURE_SIZE",()=>(0,a.getWebGLMaxTextureSize)(s.getNumber("WEBGL_VERSION"))),s.registerFlag("WEBGL_MAX_TEXTURES_IN_SHADER",()=>(0,a.getMaxTexturesInShader)(s.getNumber("WEBGL_VERSION"))),s.registerFlag("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION",()=>{let e=s.getNumber("WEBGL_VERSION");return 0===e?0:(0,a.getWebGLDisjointQueryTimerVersion)(e)}),s.registerFlag("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE",()=>s.getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")>0&&!n.eMq.isMobile()),s.registerFlag("WEBGL_RENDER_FLOAT32_CAPABLE",()=>(0,a.isCapableOfRenderingToFloatTexture)(s.getNumber("WEBGL_VERSION"))),s.registerFlag("WEBGL_RENDER_FLOAT32_ENABLED",()=>!s.getBool("WEBGL_FORCE_F16_TEXTURES")&&s.getBool("WEBGL_RENDER_FLOAT32_CAPABLE")),s.registerFlag("WEBGL_DOWNLOAD_FLOAT_ENABLED",()=>(0,a.isDownloadFloatTextureEnabled)(s.getNumber("WEBGL_VERSION"))),s.registerFlag("WEBGL_FENCE_API_ENABLED",()=>(0,a.isWebGLFenceEnabled)(s.getNumber("WEBGL_VERSION"))),s.registerFlag("WEBGL_SIZE_UPLOAD_UNIFORM",()=>4*!!s.getBool("WEBGL_RENDER_FLOAT32_ENABLED")),s.registerFlag("WEBGL_DELETE_TEXTURE_THRESHOLD",()=>-1,e=>{if("number"!=typeof e)throw Error(`WEBGL_DELETE_TEXTURE_THRESHOLD must be a number but got ${e}.`);if(e<0&&-1!==e)throw Error(`WEBGL_DELETE_TEXTURE_THRESHOLD must be -1 (indicating never delete) or at least 0, but got ${e}.`)}),s.registerFlag("WEBGL_FLUSH_THRESHOLD",()=>n.eMq.isMobile()?1:-1,e=>{if("number"!=typeof e)throw Error(`WEBGL_FLUSH_THRESHOLD must be a number but got ${e}.`);if(e<0&&-1!==e)throw Error(`WEBGL_FLUSH_THRESHOLD must be -1 (indicating never manual flush) or at least 0, but got ${e}.`)}),s.registerFlag("CPU_HANDOFF_SIZE_THRESHOLD",()=>128),s.registerFlag("WEBGL_USE_SHAPES_UNIFORMS",()=>!1),s.registerFlag("TOPK_LAST_DIM_CPU_HANDOFF_SIZE_THRESHOLD",()=>1e5),s.registerFlag("TOPK_K_CPU_HANDOFF_THRESHOLD",()=>128),s.registerFlag("WEBGL_EXP_CONV",()=>!1),s.registerFlag("SOFTWARE_WEBGL_ENABLED",()=>s.getBool("IS_TEST")),s.registerFlag("WEBGL_MAX_SIZE_FOR_NARROW_TEXTURE",()=>1/0),s.registerFlag("WEBGL_AUTO_SQUARIFY_NARROW_TEXTURE_SHAPE",()=>!1),s.registerFlag("WEBGL2_ISNAN_CUSTOM",()=>!1),s.registerFlag("ENGINE_COMPILE_ONLY",()=>!1)},43062:(e,t,r)=>{"use strict";r.d(t,{M:()=>i});var n=r(19041),a=r(48592),s=r(27924);let i=(0,r(62176).op)({tan_:function(e){let t=(0,s.YT)(e,"x","tan","float32");return n.T2.runKernel(a.oFs,{x:t})}})},43182:(e,t,r)=>{"use strict";r.d(t,{h:()=>h});var n=r(19041),a=r(48592),s=r(27924),i=r(76526),o=r(26004),l=r(62176),u=r(68567);let h=(0,l.op)({broadcastTo_:function(e,t){let r=(0,s.YT)(e,"broadcastTo","x"),l=r.shape;if((0,i.SA)(t),t.length<r.rank)throw Error(`broadcastTo(): shape.length=${t.length} < input.rank=${r.rank}.`);if(t.length>r.rank){let e=r.shape.slice();for(;e.length<t.length;)e.unshift(1);r=(0,u.t)(r,e)}let h=r.shape,p=Array.from(t);for(let e=t.length-1;e>=0;e--)if(h[e]===t[e])p[e]=1;else if(1!==r.shape[e])throw Error(`broadcastTo(): [${l}] cannot be broadcast to [${t}].`);if(0===p.map((e,t)=>e>1?t:-1).filter(e=>e>=0).length)return(0,o.o)(r);let d={x:r};return n.T2.runKernel(a.FAs,d,{reps:p})}})},43202:e=>{e.exports=r;var t=null;try{t=new WebAssembly.Instance(new WebAssembly.Module(new Uint8Array([0,97,115,109,1,0,0,0,1,13,2,96,0,1,127,96,4,127,127,127,127,1,127,3,7,6,0,1,1,1,1,1,6,6,1,127,1,65,0,11,7,50,6,3,109,117,108,0,1,5,100,105,118,95,115,0,2,5,100,105,118,95,117,0,3,5,114,101,109,95,115,0,4,5,114,101,109,95,117,0,5,8,103,101,116,95,104,105,103,104,0,0,10,191,1,6,4,0,35,0,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,126,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,127,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,128,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,129,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,130,34,4,66,32,135,167,36,0,32,4,167,11])),{}).exports}catch(e){}function r(e,t,r){this.low=0|e,this.high=0|t,this.unsigned=!!r}function n(e){return!0===(e&&e.__isLong__)}r.prototype.__isLong__,Object.defineProperty(r.prototype,"__isLong__",{value:!0}),r.isLong=n;var a={},s={};function i(e,t){var r,n,i;if(t)return(e>>>=0,(i=0<=e&&e<256)&&(n=s[e]))?n:(r=l(e,(0|e)<0?-1:0,!0),i&&(s[e]=r),r);return(e|=0,(i=-128<=e&&e<128)&&(n=a[e]))?n:(r=l(e,e<0?-1:0,!1),i&&(a[e]=r),r)}function o(e,t){if(isNaN(e))return t?y:g;if(t){if(e<0)return y;if(e>=c)return T}else{if(e<=-f)return S;if(e+1>=f)return w}return e<0?o(-e,t).neg():l(e%d|0,e/d|0,t)}function l(e,t,n){return new r(e,t,n)}r.fromInt=i,r.fromNumber=o,r.fromBits=l;var u=Math.pow;function h(e,t,r){if(0===e.length)throw Error("empty string");if("NaN"===e||"Infinity"===e||"+Infinity"===e||"-Infinity"===e)return g;if("number"==typeof t?(r=t,t=!1):t=!!t,(r=r||10)<2||36<r)throw RangeError("radix");if((n=e.indexOf("-"))>0)throw Error("interior hyphen");if(0===n)return h(e.substring(1),t,r).neg();for(var n,a=o(u(r,8)),s=g,i=0;i<e.length;i+=8){var l=Math.min(8,e.length-i),p=parseInt(e.substring(i,i+l),r);if(l<8){var d=o(u(r,l));s=s.mul(d).add(o(p))}else s=(s=s.mul(a)).add(o(p))}return s.unsigned=t,s}function p(e,t){return"number"==typeof e?o(e,t):"string"==typeof e?h(e,t):l(e.low,e.high,"boolean"==typeof t?t:e.unsigned)}r.fromString=h,r.fromValue=p;var d=0x100000000,c=0xffffffffffffffff,f=0x8000000000000000,m=i(0x1000000),g=i(0);r.ZERO=g;var y=i(0,!0);r.UZERO=y;var b=i(1);r.ONE=b;var x=i(1,!0);r.UONE=x;var v=i(-1);r.NEG_ONE=v;var w=l(-1,0x7fffffff,!1);r.MAX_VALUE=w;var T=l(-1,-1,!0);r.MAX_UNSIGNED_VALUE=T;var S=l(0,-0x80000000,!1);r.MIN_VALUE=S;var N=r.prototype;N.toInt=function(){return this.unsigned?this.low>>>0:this.low},N.toNumber=function(){return this.unsigned?(this.high>>>0)*d+(this.low>>>0):this.high*d+(this.low>>>0)},N.toString=function(e){if((e=e||10)<2||36<e)throw RangeError("radix");if(this.isZero())return"0";if(this.isNegative())if(!this.eq(S))return"-"+this.neg().toString(e);else{var t=o(e),r=this.div(t),n=r.mul(t).sub(this);return r.toString(e)+n.toInt().toString(e)}for(var a=o(u(e,6),this.unsigned),s=this,i="";;
73){var l=s.div(a),h=(s.sub(l.mul(a)).toInt()>>>0).toString(e);if((s=l).isZero())return h+i;for(;h.length<6;)h="0"+h;i=""+h+i}},N.getHighBits=function(){return this.high},N.getHighBitsUnsigned=function(){return this.high>>>0},N.getLowBits=function(){return this.low},N.getLowBitsUnsigned=function(){return this.low>>>0},N.getNumBitsAbs=function(){if(this.isNegative())return this.eq(S)?64:this.neg().getNumBitsAbs();for(var e=0!=this.high?this.high:this.low,t=31;t>0&&(e&1<<t)==0;t--);return 0!=this.high?t+33:t+1},N.isZero=function(){return 0===this.high&&0===this.low},N.eqz=N.isZero,N.isNegative=function(){return!this.unsigned&&this.high<0},N.isPositive=function(){return this.unsigned||this.high>=0},N.isOdd=function(){return(1&this.low)==1},N.isEven=function(){return(1&this.low)==0},N.equals=function(e){return n(e)||(e=p(e)),(this.unsigned===e.unsigned||this.high>>>31!=1||e.high>>>31!=1)&&this.high===e.high&&this.low===e.low},N.eq=N.equals,N.notEquals=function(e){return!this.eq(e)},N.neq=N.notEquals,N.ne=N.notEquals,N.lessThan=function(e){return 0>this.comp(e)},N.lt=N.lessThan,N.lessThanOrEqual=function(e){return 0>=this.comp(e)},N.lte=N.lessThanOrEqual,N.le=N.lessThanOrEqual,N.greaterThan=function(e){return this.comp(e)>0},N.gt=N.greaterThan,N.greaterThanOrEqual=function(e){return this.comp(e)>=0},N.gte=N.greaterThanOrEqual,N.ge=N.greaterThanOrEqual,N.compare=function(e){if(n(e)||(e=p(e)),this.eq(e))return 0;var t=this.isNegative(),r=e.isNegative();return t&&!r?-1:!t&&r?1:this.unsigned?e.high>>>0>this.high>>>0||e.high===this.high&&e.low>>>0>this.low>>>0?-1:1:this.sub(e).isNegative()?-1:1},N.comp=N.compare,N.negate=function(){return!this.unsigned&&this.eq(S)?S:this.not().add(b)},N.neg=N.negate,N.add=function(e){n(e)||(e=p(e));var t,r,a=this.high>>>16,s=65535&this.high,i=this.low>>>16,o=65535&this.low,u=e.high>>>16,h=65535&e.high,d=e.low>>>16,c=65535&e.low,f=0,m=0;return t=0+((r=0+(o+c))>>>16),r&=65535,t+=i+d,m+=t>>>16,t&=65535,m+=s+h,f+=m>>>16,m&=65535,f+=a+u,l(t<<16|r,(f&=65535)<<16|m,this.unsigned)},N.subtract=function(e){return n(e)||(e=p(e)),this.add(e.neg())},N.sub=N.subtract,N.multiply=function(e){if(this.isZero())return g;if(n(e)||(e=p(e)),t)return l(t.mul(this.low,this.high,e.low,e.high),t.get_high(),this.unsigned);if(e.isZero())return g;if(this.eq(S))return e.isOdd()?S:g;if(e.eq(S))return this.isOdd()?S:g;if(this.isNegative())if(e.isNegative())return this.neg().mul(e.neg());else return this.neg().mul(e).neg();if(e.isNegative())return this.mul(e.neg()).neg();if(this.lt(m)&&e.lt(m))return o(this.toNumber()*e.toNumber(),this.unsigned);var r,a,s=this.high>>>16,i=65535&this.high,u=this.low>>>16,h=65535&this.low,d=e.high>>>16,c=65535&e.high,f=e.low>>>16,y=65535&e.low,b=0,x=0;return r=0+((a=0+h*y)>>>16),a&=65535,r+=u*y,x+=r>>>16,r&=65535,r+=h*f,x+=r>>>16,r&=65535,x+=i*y,b+=x>>>16,x&=65535,x+=u*f,b+=x>>>16,x&=65535,x+=h*c,b+=x>>>16,x&=65535,b+=s*y+i*f+u*c+h*d,l(r<<16|a,(b&=65535)<<16|x,this.unsigned)},N.mul=N.multiply,N.divide=function(e){if(n(e)||(e=p(e)),e.isZero())throw Error("division by zero");if(t){var r,a,s;return this.unsigned||-0x80000000!==this.high||-1!==e.low||-1!==e.high?l((this.unsigned?t.div_u:t.div_s)(this.low,this.high,e.low,e.high),t.get_high(),this.unsigned):this}if(this.isZero())return this.unsigned?y:g;if(this.unsigned){if(e.unsigned||(e=e.toUnsigned()),e.gt(this))return y;if(e.gt(this.shru(1)))return x;s=y}else{if(this.eq(S))if(e.eq(b)||e.eq(v))return S;else return e.eq(S)?b:(r=this.shr(1).div(e).shl(1)).eq(g)?e.isNegative()?b:v:(a=this.sub(e.mul(r)),s=r.add(a.div(e)));if(e.eq(S))return this.unsigned?y:g;if(this.isNegative())return e.isNegative()?this.neg().div(e.neg()):this.neg().div(e).neg();if(e.isNegative())return this.div(e.neg()).neg();s=g}for(a=this;a.gte(e);){for(var i=Math.ceil(Math.log(r=Math.max(1,Math.floor(a.toNumber()/e.toNumber())))/Math.LN2),h=i<=48?1:u(2,i-48),d=o(r),c=d.mul(e);c.isNegative()||c.gt(a);)r-=h,c=(d=o(r,this.unsigned)).mul(e);d.isZero()&&(d=b),s=s.add(d),a=a.sub(c)}return s},N.div=N.divide,N.modulo=function(e){return(n(e)||(e=p(e)),t)?l((this.unsigned?t.rem_u:t.rem_s)(this.low,this.high,e.low,e.high),t.get_high(),this.unsigned):this.sub(this.div(e).mul(e))},N.mod=N.modulo,N.rem=N.modulo,N.not=function(){return l(~this.low,~this.high,this.unsigned)},N.and=function(e){return n(e)||(e=p(e)),l(this.low&e.low,this.high&e.high,this.unsigned)},N.or=function(e){return n(e)||(e=p(e)),l(this.low|e.low,this.high|e.high,this.unsigned)},N.xor=function(e){return n(e)||(e=p(e)),l(this.low^e.low,this.high^e.high,this.unsigned)},N.shiftLeft=function(e){return(n(e)&&(e=e.toInt()),0==(e&=63))?this:e<32?l(this.low<<e,this.high<<e|this.low>>>32-e,this.unsigned):l(0,this.low<<e-32,this.unsigned)},N.shl=N.shiftLeft,N.shiftRight=function(e){return(n(e)&&(e=e.toInt()),0==(e&=63))?this:e<32?l(this.low>>>e|this.high<<32-e,this.high>>e,this.unsigned):l(this.high>>e-32,this.high>=0?0:-1,this.unsigned)},N.shr=N.shiftRight,N.shiftRightUnsigned=function(e){if(n(e)&&(e=e.toInt()),0==(e&=63))return this;var t=this.high;return e<32?l(this.low>>>e|t<<32-e,t>>>e,this.unsigned):32===e?l(t,0,this.unsigned):l(t>>>e-32,0,this.unsigned)},N.shru=N.shiftRightUnsigned,N.shr_u=N.shiftRightUnsigned,N.toSigned=function(){return this.unsigned?l(this.low,this.high,!1):this},N.toUnsigned=function(){return this.unsigned?this:l(this.low,this.high,!0)},N.toBytes=function(e){return e?this.toBytesLE():this.toBytesBE()},N.toBytesLE=function(){var e=this.high,t=this.low;return[255&t,t>>>8&255,t>>>16&255,t>>>24,255&e,e>>>8&255,e>>>16&255,e>>>24]},N.toBytesBE=function(){var e=this.high,t=this.low;return[e>>>24,e>>>16&255,e>>>8&255,255&e,t>>>24,t>>>16&255,t>>>8&255,255&t]},r.fromBytes=function(e,t,n){return n?r.fromBytesLE(e,t):r.fromBytesBE(e,t)},r.fromBytesLE=function(e,t){return new r(e[0]|e[1]<<8|e[2]<<16|e[3]<<24,e[4]|e[5]<<8|e[6]<<16|e[7]<<24,t)},r.fromBytesBE=function(e,t){return new r(e[4]<<24|e[5]<<16|e[6]<<8|e[7],e[0]<<24|e[1]<<16|e[2]<<8|e[3],t)}},43239:(e,t,r)=>{"use strict";r.d(t,{V:()=>i});var n=r(19041),a=r(48592),s=r(27924);let i=(0,r(62176).op)({reciprocal_:function(e){let t=(0,s.YT)(e,"x","reciprocal");return n.T2.runKernel(a.huO,{x:t})}})},43398:(e,t,r)=>{"use strict";r.d(t,{M5:()=>i,tP:()=>s,zO:()=>a});var n=r(51520);function a(e,t){var r=e,n=t,a="classWeight";let s=n.length;if(null==r||Array.isArray(r)&&0===r.length)return n.map(e=>null);
73if(1===s)if(Array.isArray(r)&&1===r.length)return r;else if("object"==typeof r&&n[0]in r)return[r[n[0]]];else return[r];if(Array.isArray(r)){if(r.length!==s)throw Error(`Provided ${a} is an array of ${r.length} element(s), but the model has ${s} outputs. Make sure a set of weights is provided for each model output.`);return r}if("object"==typeof r&&Object.keys(r).length>0&&"object"==typeof r[Object.keys(r)[0]]){let e=[];return n.forEach(t=>{t in r?e.push(r[t]):e.push(null)}),e}throw Error(`The model has multiple (${s}) outputs, so ${a} must be either an array with ${s} elements or an object with ${n} keys. Provided ${a} not understood: ${JSON.stringify(r)}`)}async function s(e,t,r,a){if(null!=t||null!=a)throw Error("Support sampleWeight is not implemented yet");if(null==r)return null;{let t=(0,n.DZQ)(()=>{if(1===e.shape.length)return(0,n.o8B)(e);if(2===e.shape.length)if(e.shape[1]>1)return(0,n.FLi)(e,1);else if(1===e.shape[1])return(0,n.tQQ)(e,[e.shape[0]]);else throw Error(`Encountered unexpected last-dimension size (${e.shape[1]}) during handling of class weights. The size is expected to be >= 1.`);throw 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 t.data());(0,n.ASo)(t);let s=[];return a.forEach(e=>{if(null==r[e])throw Error(`classWeight must contain all classes in the training data. The class ${e} exists in the data but not in classWeight`);s.push(r[e])}),(0,n.tGX)(s,"float32")}}function i(e,t){return(0,n.lKK)(e,t)}},44309:(e,t,r)=>{"use strict";r.d(t,{EY:()=>s,To:()=>n,bb:()=>i,ft:()=>a,r$:()=>o});let n=["channelsFirst","channelsLast"],a=["nearest","bilinear"],s=["valid","same","causal"],i=["max","avg"],o=["sum","mul","concat","ave"]},44355:(e,t,r)=>{"use strict";r.d(t,{w:()=>u});var n=r(27924),a=r(76526),s=r(90715),i=r(38773),o=r(62176),l=r(68567);let u=(0,o.op)({separableConv2d_:function(e,t,r,o,u,h=[1,1],p="NHWC"){let d=(0,n.YT)(e,"x","separableConv2d"),c=(0,n.YT)(t,"depthwiseFilter","separableConv2d"),f=(0,n.YT)(r,"pointwiseFilter","separableConv2d"),m=d,g=!1;if(3===d.rank&&(g=!0,m=(0,l.t)(d,[1,d.shape[0],d.shape[1],d.shape[2]])),"NCHW"===p)throw Error("separableConv2d currently does not support dataFormat NCHW; only NHWC is supported");a.vA(4===m.rank,()=>`Error in separableConv2d: input must be rank 4, but got rank ${m.rank}.`),a.vA(4===c.rank,()=>`Error in separableConv2d: depthwise filter must be rank 4, but got rank ${c.rank}.`),a.vA(4===f.rank,()=>`Error in separableConv2d: pointwise filter must be rank 4, but got rank ${c.rank}.`),a.vA(1===f.shape[0],()=>`Error in separableConv2d: the first dimension of pointwise filter must be 1, but got ${f.shape[0]}.`),a.vA(1===f.shape[1],()=>`Error in separableConv2d: the second dimension of pointwise filter must be 1, but got ${f.shape[1]}.`);let y=c.shape[2],b=c.shape[3];a.vA(f.shape[2]===y*b,()=>`Error in separableConv2d: the third dimension of pointwise filter must be ${y*b}, but got ${f.shape[2]}.`);let x=(0,i.G)(m,c,o,u,p,h),v=(0,s.X)(x,f,1,"valid",p);return g?(0,l.t)(v,[v.shape[1],v.shape[2],v.shape[3]]):v}})},44373:(e,t,r)=>{"use strict";r.d(t,{R:()=>s});var n=r(71553),a=r(82859);class s{constructor(e,t){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.customUniforms=[{name:"inputShape",type:"ivec3"}],this.outputShape=e,this.enableShapeUniforms=(0,n.ik)(this.outputShape.length);let r="";for(let e=0;e<4;e++){let t="thisRC = rc;";e%2==1&&(t+="thisRC.z += 1;"),e>1&&(t+="thisRC.y += 1;"),r+=` 74 ${t} 75 ${e>0?"if(thisRC.y < rows && thisRC.z < cols){":""} 76 int flatIndex = getFlatIndex(thisRC); 77 78 ivec3 inputRC = inputCoordsFromReshapedOutCoords(flatIndex); 79 vec2 inputRCInnerDims = vec2(float(inputRC.y),float(inputRC.z)); 80 81 result[${e}] = 82 getChannel(getA(inputRC.x, inputRC.y, inputRC.z), inputRCInnerDims); 83 ${e>0?"}":""} 84 `}this.userCode=` 85 ${function(e,t){let r=t?a.TN(["r","c","d"],"inputShape"):a.UG(["r","c","d"],e);return` 86 ivec3 inputCoordsFromReshapedOutCoords(int index) { 87 ${r} 88 return ivec3(r, c, d); 89 } 90 `}(t,this.enableShapeUniforms)} 91 ${this.enableShapeUniforms?a.Od():a.fM(e)} 92 93 void main() { 94 ivec3 rc = getOutputCoords(); 95 96 vec4 result = vec4(0.); 97 98 ivec3 thisRC; 99 int rows = ${this.enableShapeUniforms?"outShape[1]":e[1]}; 100 int cols = ${this.enableShapeUniforms?"outShape[2]":e[2]}; 101 102 ${r} 103 104 setOutput(result); 105 } 106 `}}},45382:(e,t,r)=>{"use strict";r.d(t,{G:()=>i});var n=r(19041),a=r(48592),s=r(76526);function i(e,t,r){(0,s.SA)(e),r=r||(0,s.X$)(t);let i={shape:e,value:t,dtype:r};return n.T2.runKernel(a.SQl,{},i)}},45700:(e,t,r)=>{"use strict";r.d(t,{k:()=>u});var n=r(27924),a=r(76526),s=r(90715),i=r(39114),o=r(62176),l=r(68567);let u=(0,o.op)({conv1d_:function(e,t,r,o,u="NWC",h=1,p){let d=(0,n.YT)(e,"x","conv1d"),c=(0,n.YT)(t,"filter","conv1d"),f=d,m=!1;2===d.rank&&(m=!0,f=(0,l.t)(d,[1,d.shape[0],d.shape[1]])),a.vA(3===f.rank,()=>`Error in conv1d: input must be rank 3, but got rank ${f.rank}.`),a.vA(3===c.rank,()=>`Error in conv1d: filter must be rank 3, but got rank ${c.rank}
106.`),i.s_("conv1d",o,p),a.vA(f.shape[2]===c.shape[1],()=>`Error in conv1d: depth of input (${f.shape[2]}) must match input depth for filter ${c.shape[1]}.`),a.vA(i.G0(r,h),()=>`Error in conv1D: Either stride or dilation must be 1. Got stride ${r} and dilation '${h}'`),a.vA(i.qk(h),()=>"Error in conv1D: Dilated rates should be larger than 0."),a.vA(i.qk(r),()=>"Error in conv1D: Stride should be larger than 0."),a.vA("NWC"===u,()=>`Error in conv1d: got dataFormat of ${u} but only NWC is currently supported.`);let g=(0,l.t)(c,[1,c.shape[0],c.shape[1],c.shape[2]]),y=(0,l.t)(f,[f.shape[0],1,f.shape[1],f.shape[2]]),b=(0,s.X)(y,g,[1,r],o,"NHWC",[1,h],p);return m?(0,l.t)(b,[b.shape[2],b.shape[3]]):(0,l.t)(b,[b.shape[0],b.shape[2],b.shape[3]])}})},45732:(e,t,r)=>{"use strict";r.d(t,{z:()=>a});var n=r(51520);function a(e,t,r,s,i,o=!1,l=0){let u=s.length,h=[t[0],e.length/t[0]],p=h[1],d=u>0?i[u-1]+1:0;if(d<0)throw Error(n.C0T.getSparseSegmentReductionNegativeSegmentIdsErrorMessage());let c=t.slice();c[0]=d;let f=c.reduce((e,t)=>e*t,1),m=n.ZSL.getArrayFromDType(r,f);if(0===u)return d>0&&m.fill(l),[m,c];if(d<=0)throw Error(n.C0T.getSparseSegmentReductionNegativeSegmentIdsErrorMessage());let g=0,y=1,b=0,x=i[0];for(;;){let t=0;if(y<u){if(x===(t=i[y])){++y;continue}if(x>=t)throw Error(n.C0T.getSparseSegmentReductionNonIncreasingSegmentIdsErrorMessage())}if(x<0||x>=d)throw Error(n.C0T.getSparseSegmentReductionSegmentIdOutOfRangeErrorMessage(x,d));x>b&&m.fill(l,b*p,x*p);for(let t=g;t<y;++t){let r=s[t];if(r<0||r>
106=h[0])throw Error(n.C0T.getSparseSegmentReductionIndicesOutOfRangeErrorMessage(t,s[t],h[0]));for(let t=0;t<p;t++)m[x*p+t]+=e[r*p+t]}if(o)for(let e=0;e<p;e++)m[x*p+e]/=y-g;if(g=y,++y,b=x+1,x=t,y>u)break}return b<d&&m.fill(l,b*p,d*p),[m,c]}},46213:(e,t,r)=>{"use strict";r.d(t,{f:()=>o});var n=r(19041),a=r(48592),s=r(27924),i=r(76526);let o=(0,r(62176).op)({complex_:function(e,t){let r=(0,s.YT)(e,"real","complex"),o=(0,s.YT)(t,"imag","complex");return i.O3(r.shape,o.shape,`real and imag shapes, ${r.shape} and ${o.shape}, must match in call to tf.complex().`),n.T2.runKernel(a.pr3,{real:r,imag:o})}})},46534:(e,t,r)=>{"use strict";r.d(t,{m:()=>i});var n=r(19041),a=r(48592),s=r(27924);let i=(0,r(62176).op)({ceil_:function(e){let t=(0,s.YT)(e,"x","ceil","float32");return n.T2.runKernel(a.QDP,{x:t})}})},46648:function(e,t,r){var n;!function(a,s,i){var o,l=i.pow(256,6),u=i.pow(2,52),h=2*u;function p(e,t,r){var n=[],p=f(function e(t,r){var n,a=[],s=typeof t;if(r&&"object"==s)for(n in t)try{a.push(e(t[n],r-1))}catch(e){}return a.length?a:"string"==s?t:t+"\0"}((t=!0==t?{entropy:!0}:t||{}).entropy?[e,m(s)]:null==e?function(){try{var e;return o&&(e=o.randomBytes)?e=e(256):(e=new Uint8Array(256),(a.crypto||a.msCrypto).getRandomValues(e)),m(e)}catch(e){var t=a.navigator,r=t&&t.plugins;return[+new Date,a,r,a.screen,m(s)]}}():e,3),n),g=new d(n),y=function(){for(var e=g.g(6),t=l,r=0;e<u;)e=(e+r)*256,t*=256,r=g.g(1);for(;e>=h;)e/=2,t/=2,r>>>=1;return(e+r)/t};return y.int32=function(){return 0|g.g(4)},y.quick=function(){return g.g(4)/0x100000000},y.double=y,f(m(g.S),s),(t.pass||r||function(e,t,r,n){return(n&&(n.S&&c(n,g),e.state=function(){return c(g,{})}),r)?(i.random=e,t):e})(y,p,"global"in t?t.global:this==i,t.state)}function d(e){var t,r=e.length,n=this,a=0,s=n.i=n.j=0,i=n.S=[];for(r||(e=[r++]);a<256;)i[a]=a++;for(a=0;a<256;a++)i[a]=i[s=255&s+e[a%r]+(t=i[a])],i[s]=t;(n.g=function(e){for(var t,r=0,a=n.i,s=n.j,i=n.S;e--;)t=i[a=255&a+1],r=256*r+i[255&(i[a]=i[s=255&s+t])+(i[s]=t)];return n.i=a,n.j=s,r})(256)}function c(e,t){return t.i=e.i,t.j=e.j,t.S=e.S.slice(),t}function f(e,t){for(var r,n=e+"",a=0;a<n.length;)t[255&a]=255&(r^=19*t[255&a])+n.charCodeAt(a++);return m(t)}function m(e){return String.fromCharCode.apply(0,e)}if(f(i.random(),s),e.exports){e.exports=p;try{o=r(41234)}catch(e){}}else void 0===(n=(function(){return p}).call(t,r,t,e))||(e.exports=n)}("undefined"!=typeof self?self:this,[],Math)},46660:(e,t,r)=>{"use strict";r.d(t,{L:()=>i});var n=r(19041),a=r(48592),s=r(27924);let i=(0,r(62176).op)({cumprod_:function(e,t=0,r=!1,i=!1){let o=(0,s.YT)(e,"x","cumprod");return n.T2.runKernel(a.jj_,{x:o},{axis:t,exclusive:r,reverse:i})}})},46842:(e,t,r)=>{"use strict";r.d(t,{W:()=>o});var n=r(19041),a=r(48592),s=r(50124),i=r(27924);let o=(0,r(62176).op)({add_:function(e,t){let r=(0,i.YT)(e,"a","add"),o=(0,i.YT)(t,"b","add");[r,o]=(0,s.makeTypesMatch)(r,o);let l={a:r,b:o};return n.T2.runKernel(a.OMN,l)}})},46967:(e,t,r)=>{"use strict";r.d(t,{w:()=>a});var n=r(51520);function a(e,t,r,a){let s=n.ZSL.parseAxisParam(t,r)[0],i=[1,r[0],1];for(let e=0;e<s;e++)i[0]*=r[e];i[1]=r[s];for(let e=s+1;e<r.length;e++)i[2]*=r[e];let o=new Map,l=new Int32Array(r[s]),u=new n.ylz(i,a,e),h=[],p=1===i[0]&&1===i[2];for(let t=0;t<r[s];t++){let r;if(p)r=e[t].toString();else{let e=[];for(let r=0;r<i[0];r++)for(let n=0;n<i[2];n++)e.push(u.get(r,t,n));r=e.join(",")}let n=o.get(r);if(null!=n)l[t]=n;else{let e=o.size;o.set(r,e),l[t]=e,h.push(t)}}let d=i.slice();d[1]=o.size;let c=new n.ylz(d,a);h.forEach((e,t)=>{for(let r=0;r<i[0];r++)for(let n=0;n<i[2];n++)c.set(u.get(r,e,n),r,t,n)});let f=r.slice();return f[s]=d[1],{outputValues:c.values,outputShape:f,indices:l}}},47293:(e,t,r)=>{"use strict";r.d(t,{I:()=>l});var n=r(19041),a=r(48592),s=r(50124),i=r(27924),o=r(83231);let l=(0,r(62176).op)({lessEqual_:function(e,t){let r=(0,i.YT)(e,"a","lessEqual","string_or_numeric"),l=(0,i.YT)(t,"b","lessEqual","string_or_numeric");[r,l]=(0,s.makeTypesMatch)(r,l),(0,o.assertAndGetBroadcastShape)(r.shape,l.shape);let u={a:r,b:l};return n.T2.runKernel(a.CwD,u)}})},47537:(e,t,r)=>{"use strict";r.r(t),r.d(t,{arraysEqual:()=>s.r1,arraysEqualWithNull:()=>s.e_,assert:()=>s.vA,assertNonNegativeIntegerDimensions:()=>s.SA,assertNonNull:()=>s.HO,assertShapesMatch:()=>s.O3,bytesFromStringArray:()=>s.SL,bytesPerElement:()=>s.jv,checkConversionForErrors:()=>s.nd,clamp:()=>s.qE,computeStrides:()=>s.Ur,convertBackendValuesAndArrayBuffer:()=>s.o2,createScalarValue:()=>x,createShuffledIndices:()=>s.P8,decodeString:()=>N,distSquared:()=>s.oO,encodeString:()=>S,fetch:()=>T,fingerPrint64:()=>b,flatten:()=>I,getArrayFromDType:()=>s.Ab,getTypedArrayFromDType:()=>s.ce,hasEncodingLoss:()=>s.BE,hexToLong:()=>l,indexToLoc:()=>s._k,inferDtype:()=>s.X$,inferFromImplicitShape:()=>s.XT,isBoolean:()=>s.Lm,isFunction:()=>s.Tn,isInt:()=>s.E6,isNumber:()=>s.Et,isPromise:()=>s.yL,isScalarShape:()=>s.Sf,isString:()=>s.Kg,isTypedArray:()=>k,isValidDtype:()=>s.xn,locToIndex:()=>s.sX,makeOnesTypedArray:()=>s.FZ,makeZerosNestedTypedArray:()=>s.c7,makeZerosTypedArray:()=>s.Ty,nearestDivisor:()=>s.lK,nearestLargerEven:()=>s.eV,now:()=>w,parseAxisParam:()=>s.Y6,randUniform:()=>s.so,repeatedTry:()=>s._q,rightPad:()=>s.av,shuffle:()=>s.k4,shuffleCombo:()=>s.a0,sizeFromShape:()=>s.Ze,sizeToSquarishShape:()=>s.gS,squeezeShape:()=>s.gx,sum:()=>s.cz,swap:()=>s.wg,tanh:()=>s.ym,toNestedArray:()=>s.yw,toTypedArray:()=>v});var n=r(89215),a=r(6025),s=r(76526),i=r(43202);let o=r.n(i)()||i;function l(e){return o.fromString(e,!0,16)}let u=l("c3a5c85c97cb3127"),h=l("b492b66fbe98f273"),p=l("9ae16a3b2f90404f");function d(e){return e.xor(e.shru(47))}function c(e,t,r){let n=e.slice(t,t+r);return o.fromBytes(Array.from(n),!0,!0)}function f(e,t){return c(e,t,8)}function m(e,t){return 0===t?e:e.shru(t).or(e.shl(64-t))}function g(e,t,r=l("9ddfea08eb382d69")){let n=e.xor(t).mul(r);n=n.xor(n.shru(47));let a=t.xor(n).mul(r);return(a=a.xor(a.shru(47))).mul(r)}function y(e,t,r,n){return function(e,t,r,n,a,s){a=a.add(e),s=m(s.add(a).add(n),21);let i=a;return a=(a=a.add(t)).add(r),s=s.add(m(a,44)),[a.add(n),s.add(i)]}(f(e,t),f(e,t+8),f(e,t+16),f(e,t+24),r,n)}function b(e,t=e.length){let r=o.fromNumber(81,!0);if(t<=32)if(t<=16)return function(e,t=e.length){if(t>=8){let r=p.add(2*t),n=f(e,0).add(p),a=f(e,t-8);return g(m(a,37).mul(r).add(n),m(n,25).add(a).mul(r),r)}if(t>=4){let r=p.add(2*t);return g(c(e,0,4).shl(3).add(t),c(e,t-4,4),r)}if(t>0){let r=e[0],n=e[t>>1],a=e[t-1];return d(p.mul(r+(n<<8)).xor(u.mul(t+(a<<2)))).mul(p)}return p}(e,t);else return function(e,t=e.length){let r=p.add(2*t),n=f(e,0).mul(h),a=f(e,8),s=f(e,t-8).mul(r),i=f(e,t-16).mul(p);return g(m(n.add(a),43).add(m(s,30)).add(i),n.add(m(a.add(p),18)).add(s),r)}(e,t);if(t<=64)return function(e,t=e.length){let r=p.add(2*t),n=f(e,0).mul(p),a=f(e,8),s=f(e,t-8).mul(r),i=f(e,t-16).mul(p),o=m(n.add(a),43).add(m(s,30)).add(i),l=g(o,n.add(m(a.add(p),18)).add(s),r),u=f(e,16).mul(r),h=f(e,24),d=o.add(f(e,t-32)).mul(r),c=l.add(f(e,t-24)).mul(r);return g(m(u.add(h),43).add(m(d,30)).add(c),u.add(m(h.add(n),18)).add(d),r)}(e,t);let n=r,a=r.mul(h).add(113),s=d(a.mul(p).add(113)).mul(p),i=[o.UZERO,o.UZERO],l=[o.UZERO,o.UZERO];n=n.mul(p).add(f(e,0));let x=0,v=(t-1>>6)*64,w=v+(t-1&63)-63;do n=m(n.add(a).add(i[0]).add(f(e,x+8)),37).mul(h),a=m(a.add(i[1]).add(f(e,x+48)),42).mul(h),n=n.xor(l[1]),a=a.add(i[0]).add(f(e,x+40)),s=m(s.add(l[0]),33).mul(h),i=y(e,x,i[1].mul(h),n.add(l[0])),l=y(e,x+32,s.add(l[1]),a.add(f(e,x+16))),[s,n]=[n,s],x+=64;while(x!==v);let T=h.add(s.and(255).shl(1));return x=w,l[0]=l[0].add(t-1&63),i[0]=i[0].add(l[0]),l[0]=l[0].add(i[0]),n=m(n.add(a).add(i[0]).add(f(e,x+8)),37).mul(T),a=m(a.add(i[1]).add(f(e,x+48)),42).mul(T),n=n.xor(l[1].mul(9)),a=a.add(i[0].mul(9).add(f(e,x+40))),s=m(s.add(l[0]),33).mul(T),i=y(e,x,i[1].mul(T),n.add(l[0])),l=y(e,x+32,s.add(l[1]),a.add(f(e,x+16))),[s,n]=[n,s],g(g(i[0],l[0],T).add(d(a).mul(u)).add(s),g(i[1],l[1],T).add(n),T)}function x(e,t){return"string"===t?S(e):v([e],t)}function v(e,t){var r;if("string"===t)throw Error("Cannot convert a string[] to a TypedArray");if(Array.isArray(e)&&(e=I(e)),(0,n._K)().getBool("DEBUG")&&s.nd(e,t),(r=e)instanceof Float32Array&&"float32"===t||r instanceof Int32Array&&"int32"===t||r instanceof Uint8Array&&"bool"===t)return e;if(null==t||"float32"===t||"complex64"===t)return new Float32Array(e);if("int32"===t)return new Int32Array(e);if("bool"===t){let t=new Uint8Array(e.length);for(let r=0;r<t.length;++r)0!==Math.round(e[r])&&(t[r]=1);return t}throw Error(`Unknown data type ${t}`)}function w(){return(0,n._K)().platform.now()}function T(e,t){return(0,n._K)().platform.fetch(e,t)}function S(e,t="utf-8"){return t=t||"utf-8",(0,n._K)().platform.encode(e,t)}function N(e,t="utf-8"){return t=t||"utf-8",(0,n._K)().platform.decode(e,t)}function k(e){return null!=(0,n._K)().platform.isTypedArray?(0,n._K)().platform.isTypedArray(e):(0,a.Y)(e)}function I(e,t=[],r=!1){if(null==t&&(t=[]),"boolean"==typeof e||"number"==typeof e||"string"==typeof e||s.yL(e)||null==e||k(e)&&r)t.push(e);else if(Array.isArray(e)||k(e))for(let n=0;n<e.length;++n)I(e[n],t,r);else{let n=-1;for(let t of Object.keys(e))/^([1-9]+[0-9]*|0)$/.test(t)&&(n=Math.max(n,Number(t)));for(let a=0;a<=n;a++)I(e[a],t,r)}return t}},47700:(e,t,r)=>{"use strict";r.d(t,{bU:()=>function e(t,r){if(!(t in a)||null!=r){let e=function(e,t){if(1!==e&&2!==e)throw Error("Cannot get WebGL rendering context, WebGL is disabled.");let r=null==t?function(e){if(!(0,n._K2)().getBool("IS_SAFARI")&&"undefined"!=typeof OffscreenCanvas&&2===e)return new OffscreenCanvas(300,150);if("undefined"!=typeof document)return document.createElement("canvas");throw Error("Cannot create a canvas in this context")}(e):t;return(r.addEventListener("webglcontextlost",t=>{t.preventDefault(),delete a[e]},!1),(0,n._K2)().getBool("SOFTWARE_WEBGL_ENABLED")&&(s.failIfMajorPerformanceCaveat=!1),1===e)?r.getContext("webgl",s)||r.getContext("experimental-webgl",s):r.getContext("webgl2",s)}(t,r);if(null===e)return console.log("Could not get context for WebGL version",t),null;a[t]=e}let i=a[t];return null==i||i.isContextLost()?(delete a[t],e(t)):(i.disable(i.DEPTH_TEST),i.disable(i.STENCIL_TEST),i.disable(i.BLEND),i.disable(i.DITHER),i.disable(i.POLYGON_OFFSET_FILL),i.disable(i.SAMPLE_COVERAGE),i.enable(i.SCISSOR_TEST),i.enable(i.CULL_FACE),i.cullFace(i.BACK),a[t])},lj:()=>i});var n=r(51520);let a={},s={alpha:!1,antialias:!1,premultipliedAlpha:!1,preserveDrawingBuffer:!1,depth:!1,stencil:!1,failIfMajorPerformanceCaveat:!0};function i(e,t){a[e]=t}},48163:(e,t,r)=>{"use strict";r.d(t,{b:()=>u});var n=r(19041),a=r(48592),s=r(27924),i=r(76526),o=r(62176),l=r(68567);let u=(0,o.op)({resizeNearestNeighbor_:function(e,t,r=!1,o=!1){let u=(0,s.YT)(e,"images","resizeNearestNeighbor");i.vA(3===u.rank||4===u.rank,()=>`Error in resizeNearestNeighbor: x must be rank 3 or 4, but got rank ${u.rank}.`),i.vA(2===t.length,()=>`Error in resizeNearestNeighbor: new shape must 2D, but got shape ${t}.`),i.vA("float32"===u.dtype||"int32"===u.dtype,()=>"`images` must have `int32` or `float32` as dtype"),i.vA(!1===o||!1===r,()=>"Error in resizeNearestNeighbor: If halfPixelCenters is true, alignCorners must be false.");let h=u,p=!1;3===u.rank&&(p=!0,h=(0,l.t)(u,[1,u.shape[0],u.shape[1],u.shape[2]]));let[]=t,d={images:h},c=n.T2.runKernel(a.jOE,d,{alignCorners:r,halfPixelCenters:o,size:t});return p?(0,l.t)(c,[c.shape[1],c.shape[2],c.shape[3]]):c}})},48551:(e,t,r)=>{"use strict";r.d(t,{r:()=>i});var n=r(19041),a=r(48592),s=r(27924);let i=(0,r(62176).op)({atanh_:function(e){let t=(0,s.YT)(e,"x","atanh");return n.T2.runKernel(a.zP9,{x:t})}})},48592:(e,t,r)=>{"use strict";r.d(t,{$dB:()=>R,$jE:()=>tj,$zE:()=>F,A1h:()=>L,A8B:()=>tR,BK4:()=>t7,BLA:()=>eq,BRl:()=>es,Blb:()=>t_,BoJ:()=>tL,BxF:()=>ep,C8s:()=>tO,CQC:()=>ta,Cg$:()=>e$,CwD:()=>eC,D7i:()=>tg,Ddj:()=>tB,Dr:()=>t9,DvZ:()=>tP,E3$:()=>eS,EkD:()=>
106o,ElG:()=>ec,EwU:()=>t0,FAs:()=>tQ,FCQ:()=>tf,FSt:()=>u,Fin:()=>tA,GZp:()=>tV,HNs:()=>N,Ik2:()=>T,J3C:()=>tI,JiE:()=>tN,Jp_:()=>h,KXH:()=>C,L6G:()=>tM,LB5:()=>k,LDN:()=>eW,LG0:()=>eY,LRy:()=>to,LWX:()=>e5,LXA:()=>e_,M6A:()=>tW,MRQ:()=>G,Mn0:()=>z,MnK:()=>B,N4F:()=>S,Ncv:()=>tt,O4G:()=>eg,OAQ:()=>ev,ODT:()=>e9,OMN:()=>i,ORI:()=>Y,PH8:()=>s,P_L:()=>tm,Pah:()=>er,PbM:()=>tH,Q6t:()=>ti,QDP:()=>E,QKF:()=>d,Qgm:()=>et,R23:()=>th,RMm:()=>t3,RUm:()=>eF,RW8:()=>eD,RXX:()=>eG,SDM:()=>e2,SQl:()=>eh,T7M:()=>re,TBb:()=>tq,TL8:()=>ej,TMz:()=>Z,TOR:()=>tb,ToN:()=>eP,TyE:()=>f,UcO:()=>tG,VAI:()=>eB,VCH:()=>b,Vvy:()=>a,WRv:()=>ez,WT3:()=>eX,WuN:()=>tF,X$8:()=>H,X0$:()=>ek,X4r:()=>tv,XQy:()=>td,XhZ:()=>ey,XmO:()=>J,YAb:()=>tU,YVe:()=>tC,ZgB:()=>ed,Zl4:()=>e3,_s9:()=>ea,aAr:()=>t8,awo:()=>t6,bCz:()=>e8,bP9:()=>q,cHb:()=>eZ,cS:()=>x,dFH:()=>t$,dLy:()=>tX,dXR:()=>t1,dv8:()=>ew,e0f:()=>e4,epO:()=>c,fUj:()=>tu,g5A:()=>eH,gC7:()=>P,gIW:()=>eT,hVg:()=>ty,hgw:()=>tc,ho8:()=>y,hql:()=>tk,huO:()=>tl,i5R:()=>ef,iGz:()=>M,iPs:()=>eN,iW0:()=>tZ,iuW:()=>tY,jAQ:()=>w,jM4:()=>eM,jOE:()=>tp,jfg:()=>O,jgd:()=>tz,jj_:()=>W,jxD:()=>Q,kdj:()=>tr,l0G:()=>e0,l6P:()=>tT,lLS:()=>eb,lNG:()=>eK,ljI:()=>n,lxb:()=>g,lzr:()=>ex,mH5:()=>ts,mIA:()=>eI,mM$:()=>e7,mnI:()=>eE,mxL:()=>em,nVu:()=>K,nY8:()=>V,nZd:()=>eR,oFs:()=>tK,oJ2:()=>tn,ox3:()=>ei,p2J:()=>_,pJc:()=>tx,pPe:()=>t2,p_m:()=>p,pk0:()=>X,pnw:()=>t5,pr3:()=>$,pyJ:()=>te,rFG:()=>tD,rFm:()=>D,rGP:()=>eu,rsH:()=>en,sDr:()=>ee,t3d:()=>eV,tG8:()=>eA,tGH:()=>j,u$b:()=>tS,u8Z:()=>l,uWl:()=>tw,urI:()=>e6,vI1:()=>tE,vaV:()=>A,vj7:()=>I,wNW:()=>U,wwC:()=>v,wx0:()=>tJ,x7F:()=>eQ,xJ3:()=>t4,xu7:()=>eJ,yPW:()=>eL,ySp:()=>eU,ybN:()=>eo,ybj:()=>el,ylV:()=>e1,zP9:()=>m,zfU:()=>eO});let n="Abs",a="Acos",s="Acosh",i="Add",o="AddN",l="All",u="Any",h="ArgMax",p="ArgMin",d="Asin",c="Asinh",f="Atan",m="Atanh",g="Atan2",y="AvgPool",b="AvgPoolGrad",x="AvgPool3D",v="AvgPool3DGrad",w="BatchMatMul",T="BatchToSpaceND",S="Bincount",N="BitwiseAnd",k="BroadcastTo",I="BroadcastArgs",C="Cast",E="Ceil",A="ClipByValue",$="Complex",F="ComplexAbs",R="Concat",_="Conv2D",D="Conv2DBackpropFilter",O="Conv2DBackpropInput",L="Conv3D",M="Conv3DBackpropFilterV2",P="Conv3DBackpropInputV2",z="Cos",B="Cosh",W="Cumprod",V="Cumsum",G="CropAndResize",U="DenseBincount",Z="DepthToSpace",j="DepthwiseConv2dNative",H="DepthwiseConv2dNativeBackpropFilter",K="DepthwiseConv2dNativeBackpropInput",Y="Diag",Q="Dilation2D",q="Dilation2DBackpropInput",X="Dilation2DBackpropFilter",J="Draw",ee="RealDiv",et="Einsum",er="Elu",en="EluGrad",ea="Erf",es="Equal",ei="Exp",eo="ExpandDims",el="Expm1",eu="FFT",eh="Fill",ep="FlipLeftRight",ed="Floor",ec="FloorDiv",ef="FusedBatchNorm",em="GatherV2",eg="GatherNd",ey="Greater",eb="GreaterEqual",ex="Identity",ev="IFFT",ew="Imag",eT="IsFinite",eS="IsInf",eN="IsNan",ek="LeakyRelu",eI="Less",eC="LessEqual",eE="LinSpace",eA="Log",e$="Log1p",eF="LogicalAnd",eR="LogicalNot",e_="LogicalOr",eD="LogicalXor",eO="LogSoftmax",eL="LowerBound",eM="LRN",eP="LRNGrad",ez="MatrixBandPart",eB="Max",eW="Maximum",eV="MaxPool",eG="MaxPoolGrad",eU="MaxPool3D",eZ="MaxPool3DGrad",ej="MaxPoolWithArgmax",eH="Mean",eK="Min",eY="Minimum",eQ="MirrorPad",eq="Mod",eX="Multinomial",eJ="Multiply",e0="Neg",e1="NotEqual",e2="NonMaxSuppressionV3",e3="NonMaxSuppressionV4",e4="NonMaxSuppressionV5",e5="OnesLike",e6="OneHot",e7="Pack",e9="PadV2",e8="Pool",te="Pow",tt="Prelu",tr="Prod",tn="RaggedGather",ta="RaggedRange",ts="RaggedTensorToTensor",ti="Range",to="Real",tl="Reciprocal",tu="Relu",th="Reshape",tp="ResizeNearestNeighbor",td="ResizeNearestNeighborGrad",tc="ResizeBilinear",tf="ResizeBilinearGrad",tm="Relu6",tg="Reverse",ty="Round",tb="Rsqrt",tx="ScatterNd",tv="TensorScatterUpdate",tw="SearchSorted",tT="Select",tS="Selu",tN="Slice",tk="Sin",tI="Sinh",tC="Sign",tE="Sigmoid",tA="Softplus",t$="Sqrt",tF="Sum",tR="SpaceToBatchND",t_="SplitV",tD="Softmax",tO="SparseFillEmptyRows",tL="SparseReshape",tM="SparseSegmentMean",tP="SparseSegmentSum",tz="SparseToDense",tB="SquaredDifference",tW="Square",tV="StaticRegexReplace",tG="StridedSlice",tU="StringNGrams",tZ="StringSplit",tj="StringToHashBucketFast",tH="Sub",tK="Tan",tY="Tanh",tQ="Tile",tq="TopK",tX="Transform",tJ="Trans
106pose",t0="Unique",t1="Unpack",t2="UnsortedSegmentSum",t3="UpperBound",t4="ZerosLike",t5="Step",t6="FromPixels",t7="RotateWithOffset",t9="_FusedMatMul",t8="FusedConv2D",re="FusedDepthwiseConv2D"},48683:(e,t,r)=>{"use strict";r.d(t,{l:()=>o});var n=r(19041),a=r(48592),s=r(50124),i=r(27924);let o=(0,r(62176).op)({mul_:function(e,t){let r=(0,i.YT)(e,"a","mul"),o=(0,i.YT)(t,"b","mul");[r,o]=(0,s.makeTypesMatch)(r,o);let l={a:r,b:o};return n.T2.runKernel(a.xu7,l)}})},49044:(e,t,r)=>{"use strict";r.d(t,{$t:()=>S,Gk:()=>g,JJ:()=>I,Mg:()=>T,OA:()=>A,TG:()=>y,XC:()=>E,_M:()=>k,kd:()=>v,nO:()=>x});var n=r(51520),a=r(73187),s=r(90556),i=r(15034),o=r(14811),l=r(97344),u=r(62041),h=r(82692),p=r(1560),d=r(13221);function c(e,t,r,s,o,l){return(0,n.DZQ)(()=>{let u;(0,i.uM)(o),(0,i.Kx)(l),(0,i.tB)(s),null==r&&(r=[1,1]),null==s&&(s="valid"),null==o&&(o=(0,a.VI)()),null==l&&(l="max"),e=(0,d.RK)(e,o);let h="same"===s?"same":"valid";return u="max"===l?n.jgi(e,t,r,h):n.$jT(e,t,r,h),"channelsFirst"===o&&(u=n.mgz(u,[0,3,1,2])),u})}function f(e,t,r,s,o,l){return(0,n.DZQ)(()=>{let u;(0,i.uM)(o),(0,i.Kx)(l),(0,i.tB)(s),null==r&&(r=[1,1,1]),null==s&&(s="valid"),null==o&&(o=(0,a.VI)()),null==l&&(l="max"),e=(0,d.al)(e,o);let h="same"===s?"same":"valid";return u="max"===l?n.NYV(e,t,r,h):n.sub(e,t,r,h),"channelsFirst"===o&&(u=n.mgz(u,[0,4,1,2,3])),u})}class m extends o.Wd{constructor(e){if(null==e.poolSize&&(e.poolSize=2),super(e),"number"==typeof e.poolSize)this.poolSize=[e.poolSize];else if(Array.isArray(e.poolSize)&&1===e.poolSize.length&&"number"==typeof e.poolSize[0])this.poolSize=e.poolSize;else throw new l.Qp(`poolSize for 1D convolutional layer must be a number or an Array of a single number, but received ${JSON.stringify(e.poolSize)}`);if((0,h.oo)(this.poolSize,"poolSize"),null==e.strides)this.strides=this.poolSize;else if("number"==typeof e.strides)this.strides=[e.strides];else if(Array.isArray(e.strides)&&1===e.strides.length&&"number"==typeof e.strides[0])this.strides=e.strides;else throw new l.Qp(`strides for 1D convolutional layer must be a number or an Array of a single number, but received ${JSON.stringify(e.strides)}`);(0,h.oo)(this.strides,"strides"),this.padding=null==e.padding?"valid":e.padding,(0,i.tB)(this.padding),this.inputSpec=[new o.eO({ndim:3})]}computeOutputShape(e){e=(0,p.U$)(e);let t=(0,u.Ol)(e[1],this.poolSize[0],this.padding,this.strides[0]);return[e[0],t,e[2]]}call(e,t){return(0,n.DZQ)(()=>{this.invokeCallHook(e,t),e=s.UG((0,p.un)(e),2);let r=this.poolingFunction((0,p.un)(e),[this.poolSize[0],1],[this.strides[0],1],this.padding,"channelsLast");return n.r2V(r,[2])})}getConfig(){let e={poolSize:this.poolSize,padding:this.padding,strides:this.strides};return Object.assign(e,super.getConfig()),e}}class g extends m{constructor(e){super(e)}poolingFunction(e,t,r,n,a){return(0,i.uM)(a),(0,i.tB)(n),c(e,t,r,n,a,"max")}}g.className="MaxPooling1D",n.JFn.registerClass(g);class y extends m{constructor(e){super(e)}poolingFunction(e,t,r,n,a){return(0,i.uM)(a),(0,i.tB)(n),c(e,t,r,n,a,"avg")}}y.className="AveragePooling1D",n.JFn.registerClass(y);class b extends o.Wd{constructor(e){if(null==e.poolSize&&(e.poolSize=[2,2]),super(e),this.poolSize=Array.isArray(e.poolSize)?e.poolSize:[e.poolSize,e.poolSize],null==e.strides)this.strides=this.poolSize;else if(Array.isArray(e.strides)){if(2!==e.strides.length)throw new l.Qp(`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];(0,h.oo)(this.poolSize,"poolSize"),(0,h.oo)(this.strides,"strides"),this.padding=null==e.padding?"valid":e.padding,this.dataFormat=null==e.dataFormat?"channelsLast":e.dataFormat,(0,i.uM)(this.dataFormat),(0,i.tB)(this.padding),this.inputSpec=[new o.eO({ndim:4})]}computeOutputShape(e){e=(0,p.U$)(e);let t="channelsFirst"===this.dataFormat?e[2]:e[1],r="channelsFirst"===this.dataFormat?e[3]:e[2];return(t=(0,u.Ol)(t,this.poolSize[0],this.padding,this.strides[0]),r=(0,u.Ol)(r,this.poolSize[1],this.padding,this.strides[1]),"channelsFirst"===this.dataFormat)?[e[0],e[1],t,r]:[e[0],t,r,e[3]]}call(e,t){return(0,n.DZQ)(()=>(this.invokeCallHook(e,t),this.poolingFunction((0,p.un)(e),this.poolSize,this.strides,this.padding,this.dataFormat)))}getConfig(){let e={poolSize:this.poolSize,padding:this.padding,strides:this.strides,dataFormat:this.dataFormat};return Object.assign(e,super.getConfig()),e}}class x extends b{constructor(e){super(e)}poolingFunction(e,t,r,n,a){return(0,i.uM)(a),(0,i.tB)(n),c(e,t,r,n,a,"max")}}x.className="MaxPooling2D",n.JFn.registerClass(x);class v extends b{constructor(e){super(e)}poolingFunction(e,t,r,n,a){return(0,i.uM)(a),(0,i.tB)(n),c(e,t,r,n,a,"avg")}}v.className="AveragePooling2D",n.JFn.registerClass(v);class w extends o.Wd{constructor(e){if(null==e.poolSize&&(e.poolSize=[2,2,2]),super(e),this.poolSize=Array.isArray(e.poolSize)?e.poolSize:[e.poolSize,e.poolSize,e.poolSize],null==e.strides)this.strides=this.poolSize;else if(Array.isArray(e.strides)){if(3!==e.strides.length)throw new l.Qp(`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];(0,h.oo)(this.poolSize,"poolSize"),(0,h.oo)(this.strides,"strides"),this.padding=null==e.padding?"valid":e.padding,this.dataFormat=null==e.dataFormat?"channelsLast":e.dataFormat,(0,i.uM)(this.dataFormat),(0,i.tB)(this.padding),this.inputSpec=[new o.eO({ndim:5})]}computeOutputShape(e){e=(0,p.U$)(e);let t="channelsFirst"===this.dataFormat?e[2]:e[1],r="channelsFirst"===this.dataFormat?e[3]:e[2],n="channelsFirst"===this.dataFormat?e[4]:e[3];return(t=(0,u.Ol)(t,this.poolSize[0],this.padding,this.strides[0]),r
106=(0,u.Ol)(r,this.poolSize[1],this.padding,this.strides[1]),n=(0,u.Ol)(n,this.poolSize[2],this.padding,this.strides[2]),"channelsFirst"===this.dataFormat)?[e[0],e[1],t,r,n]:[e[0],t,r,n,e[4]]}call(e,t){return(0,n.DZQ)(()=>(this.invokeCallHook(e,t),this.poolingFunction((0,p.un)(e),this.poolSize,this.strides,this.padding,this.dataFormat)))}getConfig(){let e={poolSize:this.poolSize,padding:this.padding,strides:this.strides,dataFormat:this.dataFormat};return Object.assign(e,super.getConfig()),e}}class T extends w{constructor(e){super(e)}poolingFunction(e,t,r,n,a){return(0,i.uM)(a),(0,i.tB)(n),f(e,t,r,n,a,"max")}}T.className="MaxPooling3D",n.JFn.registerClass(T);class S extends w{constructor(e){super(e)}poolingFunction(e,t,r,n,a){return(0,i.uM)(a),(0,i.tB)(n),f(e,t,r,n,a,"avg")}}S.className="AveragePooling3D",n.JFn.registerClass(S);class N extends o.Wd{constructor(e){super(e),this.inputSpec=[new o.eO({ndim:3})]}computeOutputShape(e){return[e[0],e[2]]}call(e,t){throw new l.EH}}class k extends N{constructor(e){super(e||{})}call(e,t){return(0,n.DZQ)(()=>{let t=(0,p.un)(e);return n.i2o(t,1)})}}k.className="GlobalAveragePooling1D",n.JFn.registerClass(k);class I extends N{constructor(e){super(e||{})}call(e,t){return(0,n.DZQ)(()=>{let t=(0,p.un)(e);return n.T9B(t,1)})}}I.className="GlobalMaxPooling1D",n.JFn.registerClass(I);class C extends o.Wd{constructor(e){super(e),this.dataFormat=null==e.dataFormat?"channelsLast":e.dataFormat,(0,i.uM)(this.dataFormat),this.inputSpec=[new o.eO({ndim:4})]}computeOutputShape(e){return"channelsLast"===this.dataFormat?[e[0],e[3]]:[e[0],e[1]]}call(e,t){throw new l.EH}getConfig(){let e={dataFormat:this.dataFormat};return Object.assign(e,super.getConfig()),e}}class E extends C{call(e,t){return(0,n.DZQ)(()=>{let t=(0,p.un)(e);return"channelsLast"===this.dataFormat?n.i2o(t,[1,2]):n.i2o(t,[2,3])})}}E.className="GlobalAveragePooling2D",n.JFn.registerClass(E);class A extends C{call(e,t){return(0,n.DZQ)(()=>{let t=(0,p.un)(e);return"channelsLast"===this.dataFormat?n.T9B(t,[1,2]):n.T9B(t,[2,3])})}}A.className="GlobalMaxPooling2D",n.JFn.registerClass(A)},49575:(e,t,r)=>{"use strict";r.d(t,{C:()=>a});var n=r(51520);function a(e,t){Array.isArray(e)||(e=[e]),e.forEach(e=>{null!=e&&n.ZSL.assert("complex64"!==e.dtype,()=>`${t} does not support complex64 tensors in the CPU backend.`)})}},49762:(e,t,r)=>{"use strict";r.d(t,{S3:()=>o,_B:()=>i});var n=r(51520),a=r(49575),s=r(31910);function i(e,t,r,a){let[s,i]=n.C0T.computeOutAndReduceShapes(e,a),o=(0,n.TuY)(t,"int32"),l=n.ZSL.makeZerosTypedArray(n.ZSL.sizeFromShape(s),o),u=n.ZSL.sizeFromShape(i);for(let e=0;e<l.length;++e){let t=e*u,n=1;for(let e=0;e<u;++e)n*=r[t+e];l[e]=n}return{outVals:l,outShape:s,outDtype:o}}let o={kernelName:n.kdj,backendName:"cpu",kernelFunc:function(e){let{inputs:t,backend:r,attrs:o}=e,{x:l}=t,{axis:u,keepDims:h}=o;(0,a.C)(l,"prod");let p=l.shape.length,d=n.ZSL.parseAxisParam(u,l.shape),c=n.C0T.getAxesPermutation(d,p),f=d,m=l,g=[];null!=c&&(g.push(m=(0,s.m)({inputs:{x:l},backend:r,attrs:{perm:c}})),f=n.C0T.getInnerMostAxes(f.length,p));let y=r.data.get(m.dataId).values,{outVals:b,outShape:x,outDtype:v}=i(m.shape,m.dtype,y,f),w=x;return h&&(w=n.C0T.expandShapeToKeepDim(x,d)),g.forEach(e=>r.disposeIntermediateTensorInfo(e)),r.makeTensorInfo(w,v,b)}}},50124:(e,t,r)=>{"use strict";r.r(t),r.d(t,{assertTypesMatch:()=>o,getTensorsInContainer:()=>u,isTensorInList:()=>l,makeTypesMatch:()=>i});var n=r(60218),a=r(17831),s=r(76526);function i(e,t){if(e.dtype===t.dtype)return[e,t];let r=(0,a.Tu)(e.dtype,t.dtype);return[e.cast(r),t.cast(r)]}function o(e,t){(0,s.vA)(e.dtype===t.dtype,()=>`The dtypes of the first(${e.dtype}) and second(${t.dtype}) input must match`)}function l(e,t){return t.some(t=>t.id===e.id)}function u(e){let t=[];return function e(t,r,a){var s;if(null!=t){if(t instanceof n.qY)return void r.push(t);if(Array.isArray(s=t)||"object"==typeof s)for(let n in t){let s=t[n];a.has(s)||(a.add(s),e(s,r,a))}}}(e,t,new Set),t}},50494:(e,t,r)=>{"use strict";r.d(t,{b:()=>a});var n=r(51520);function a(e,t,r,a,s,i,o,l,u,h){let p=e.values,d=t.values;if(0===a)return(0,n.ra8)(r,t.dtype);let c=u instanceof n.ylz?u:(0,n.ra8)([a/s,s],t.dtype);"string"==typeof u||"number"==typeof u?c.values.fill(u):"boolean"==typeof u&&c.values.fill(+u);for(let e=0;e<i;e++){let n=[],i=0;for(let t=0;t<o;t++){let r=p[e*o+t];
106n.push(r),i+=r*l[t]}if(i<0||i>=a/s)throw Error(`Invalid indices: ${n} does not index into ${r}`);for(let r=0;r<s;r++)h?c.values[i*s+r]+=d[e*s+r]:c.values[i*s+r]=0===t.rank?d[0]:d[e*s+r]}return c}},50684:(e,t,r)=>{"use strict";r.d(t,{e:()=>i});var n=r(19041),a=r(48592),s=r(27924);let i=(0,r(62176).op)({pad_:function(e,t,r=0){let i=(0,s.YT)(e,"x","pad");if(0===i.rank)throw Error("pad(scalar) is not defined. Pass non-scalar to pad");return n.T2.runKernel(a.ODT,{x:i},{paddings:t,constantValue:r})}})},50943:(e,t,r)=>{"use strict";r.d(t,{F:()=>i});var n=r(19041),a=r(48592),s=r(27924);let i=(0,r(62176).op)({sin_:function(e){let t=(0,s.YT)(e,"x","sin","float32");return n.T2.runKernel(a.hql,{x:t})}})},51006:(e,t,r)=>{"use strict";r.d(t,{j:()=>h});var n=r(19041),a=r(48592),s=r(27924),i=r(76526),o=r(39114),l=r(62176),u=r(68567);let h=(0,l.op)({maxPool_:function(e,t,r,l,h){let p=(0,s.YT)(e,"x","maxPool"),d=p,c=!1;3===p.rank&&(c=!0,d=(0,u.t)(p,[1,p.shape[0],p.shape[1],p.shape[2]])),i.vA(4===d.rank,()=>`Error in maxPool: input must be rank 4 but got rank ${d.rank}.`),i.vA(o.G0(r,1),()=>`Error in maxPool: Either strides or dilations must be 1. Got strides ${r} and dilations '1'`),o.s_("maxPool",l,h);let f={x:d},m=n.T2.runKernel(a.t3d,f,{filterSize:t,strides:r,pad:l,dimRoundingMode:h});return c?(0,u.t)(m,[m.shape[1],m.shape[2],m.shape[3]]):m}})},51097:(e,t,r)=>{"use strict";r.d(t,{e:()=>o});var n=r(19041),a=r(48592),s=r(27924),i=r(76526);let o=(0,r(62176).op)({spaceToBatchND_:function(e,t,r){let o=(0,s.YT)(e,"x","spaceToBatchND");return i.vA(o.rank>=1+t.length,()=>`input rank ${o.rank} should be > than [blockShape] ${t.length}`),i.vA(r.length===t.length,()=>`paddings.shape[0] ${r.length} must be equal to [blockShape] ${t.length}`),i.vA(o.shape.reduce((e,n,a)=>a>0&&a<=t.length?e&&(n+r[a-1][0]+r[a-1][1])%t[a-1]==0:e,!0),()=>`input spatial dimensions ${o.shape.slice(1)} with paddings ${r.toString()} must be divisible by blockShapes ${t.toString()}`),n.T2.runKernel(a.A8B,{x:o},{blockShape:t,paddings:r})}})},51247:(e,t,r)=>{"use strict";r.d(t,{BTT:()=>d.B,tnl:()=>a.t,HQu:()=>s.H,FqL:()=>i.F,WQq:()=>o.W,QiD:()=>c,Q7R:()=>f.Q,bzn:()=>m.b,FLi:()=>g.F,XRg:()=>y.X,qRo:()=>b.q,yHs:()=>x.y,rYl:()=>v.r,FPz:()=>w.F,rfv:()=>T.r,$jT:()=>S.$,sub:()=>C,lZX:()=>D,$v7:()=>L.$,BFc:()=>M,kSi:()=>P,T5N:()=>z,GTe:()=>O.G,HbZ:()=>B,vjT:()=>W,ftb:()=>rD,ROE:()=>V,hOW:()=>G.h,ra8:()=>U.r,wgE:()=>N.w,mkO:()=>Z.m,zQh:()=>j.z,o8B:()=>H.o,faB:()=>K.f,xWs:()=>E.x,I1m:()=>Y,RPU:()=>Q,O5O:()=>q,P1l:()=>X,kA9:()=>J.k,Xtf:()=>ee.X,wX9:()=>et.w,IPL:()=>er,jIJ:()=>ea,gnS:()=>es.g,yIG:()=>ei.y,_jP:()=>rU,Lp0:()=>eo.L,rCv:()=>el.r,aOp:()=>eu,Rj8:()=>eh.R,Gl3:()=>ep.G,smy:()=>ed,X7t:()=>ec.X,y4m:()=>ef.y,ek5:()=>em.e,Omf:()=>eg.O,EZY:()=>rV,_3C:()=>ey,Pqc:()=>eb.P,FJY:()=>rG,QP2:()=>ex,LCg:()=>ev.L,Y12:()=>ew.Y,p4S:()=>eT.p,oNF:()=>eS.o,UG6:()=>eN.U,IYd:()=>ek.I,y5U:()=>eC,hVP:()=>t8.h,GSj:()=>eE.G,RIf:()=>eA.R,wh_:()=>e$.w,cZk:()=>n,kgh:()=>eF.k,SY9:()=>rW,rhj:()=>eR.r,DQN:()=>e_.D,KGM:()=>re.K,ngS:()=>eD.n,Slp:()=>nP,U4u:()=>rZ,ggX:()=>rt.g,MIs:()=>eO.M,EN4:()=>eL.E,yrW:()=>eM.y,H8d:()=>eP.H,M7h:()=>ez.M,InN:()=>eB.I,mPL:()=>nz,mT8:()=>eW,Kgs:()=>eV.K,Rm2:()=>eG.R,Kko:()=>eU.K,nqI:()=>eZ.n,HPB:()=>ej.H,VZ:()=>eH.V,n76:()=>eK.n,NSZ:()=>eY.N,ztW:()=>eQ.z,rxB:()=>eq.r,YYh:()=>nB,yzS:()=>eJ,NoW:()=>A.N,T9B:()=>e0.T,jgi:()=>e1.j,NYV:()=>e2,RO:()=>e3,PhQ:()=>e4.P,i2o:()=>e5.i,OYQ:()=>e9,jkA:()=>e8.j,BpO:()=>te.B,FFZ:()=>tt.F,ziu:()=>tr.z,Clk:()=>ti,CRk:()=>rP,lKK:()=>$.l,YDF:()=>to,OjQ:()=>tl,HZy:()=>tu.H,xbf:()=>rL.x,Ec:()=>th.E,Mw0:()=>tp.M,SaS:()=>e6.S,P61:()=>td.P,op:()=>d.op,X4o:()=>tc,eVF:()=>tf.e,BZs:()=>tm,grY:()=>tg,XHu:()=>ty,WLX:()=>tb,dzn:()=>tx.d,n7C:()=>tv.n,NsG:()=>tw.N,yyV:()=>tT.y,_eU:()=>tS._,whe:()=>tN,iyU:()=>tk,Q0_:()=>tI,_9M:()=>tC,pR9:()=>tR,FE$:()=>t_,m0H:()=>tD,YeY:()=>tO,HYA:()=>tL,y17:()=>tM,xav:()=>tP.x,VOZ:()=>tz.V,VVh:()=>tB.V,j__:()=>tW.j,tQQ:()=>I.t,BEg:()=>tV.B,QD2:()=>tG,LMr:()=>tU,I2l:()=>tZ,JYU:()=>tj,z8$:()=>rr.z,LIG:()=>tH.L,Z$r:()=>tK.Z,d_2:()=>tY.d,NFr:()=>rz,sZg:()=>eX,WfX:()=>tQ.W,wdz:()=>tq.w,F12:()=>tX,ry7:()=>F.r,_SZ:()=>tJ._,vPA:()=>nM,F8e:()=>t0.F,L0l:()=>t1.L,dik:()=>R.d,Q$M:()=>t2,zAd:()=>t3,wck:()=>t4,R0O:()=>t5,Vs9:()=>t6.V,lw0:()=>t7.l,eDJ:()=>t9.e,lMo:()=>nW,Zhr:()=>rB,lOn:()=>nL,lDo:()=>rn.l,RZD:()=>ra.R,EwI:()=>ta.E,Pbu:()=>rs.P,r2V:()=>ri.r,t$z:()=>ro.t,PMw:()=>rl.P,Ym9:()=>ru.Y,YjP:()=>nV,jbE:()=>ts.j,czq:()=>rh.c,Mlm:()=>rp.M,ymU:()=>_.y,OEK:()=>rd.O,tGX:()=>rf,KtR:()=>rm,$_$:()=>rg.$,g9W:()=>ry,Lpo:()=>rb,yxw:()=>rx,NNh:()=>rw,Vsq:()=>eI.V,rfw:()=>rT.r,mgz:()=>rO.m,efE:()=>rS,AmM:()=>rN.A,zAU:()=>rk.z,K$i:()=>rI.K,rni:()=>rC,bvq:()=>rE,_M9:()=>rA._,YJN:()=>rF,Ul9:()=>rR.U,POl:()=>r_.P});var n={};r.r(n),r.d(n,{conv2d:()=>rq,depthwiseConv2d:()=>r0,matMul:()=>r1});var a=r(13825),s=r(26765),i=r(59591),o=r(46842),l=r(19041),u=r(48592),h=r(27924),p=r(76526),d=r(62176);let c=(0,d.op)({addN_:function(e){p.vA(Array.isArray(e),()=>"The argument passed to tf.addN() must be a list of tensors"),p.vA(e.length>=1,()=>`Must pass at least one tensor to tf.addN(), but got ${e.length}`);let t=e.map((e,t)=>(0,h.YT)(e,`tensors${t}`,"addN")),r=t[0];
106return t.forEach(e=>{if(e.dtype!==r.dtype)throw Error("All tensors passed to tf.addN() must have the same dtype")}),t.forEach(e=>{if(!p.r1(e.shape,r.shape))throw Error("All tensors passed to tf.addN() must have the same shape")}),l.T2.runKernel(u.EkD,t)}});var f=r(73546),m=r(8319),g=r(30464),y=r(74346),b=r(22176),x=r(90300),v=r(70477),w=r(79493),T=r(48551),S=r(98932),N=r(16488),k=r(39114),I=r(68567);let C=(0,d.op)({avgPool3d_:function(e,t,r,n,a,s="NDHWC"){let i=(0,h.YT)(e,"x","avgPool3d","float32"),o=i,d=!1;4===i.rank&&(d=!0,o=(0,I.t)(i,[1,i.shape[0],i.shape[1],i.shape[2],i.shape[3]])),p.vA(5===o.rank,()=>`Error in avgPool3d: x must be rank 5 but got rank ${o.rank}.`),p.vA("NDHWC"===s,()=>`Error in avgPool3d: Only NDHWC is currently supported, but got dataFormat of ${s}`),p.vA("number"==typeof r&&r>0||Array.isArray(r)&&r[0]>0&&r[1]>0&&r[2]>0,()=>`Error in avgPool3d: Stride must be > 0, but got '${r}'`),(0,k.s_)("avgPool3d",n,a);let c={x:o},f=l.T2.runKernel(u.cS,c,{filterSize:t,strides:r,pad:n,dimRoundingMode:a,dataFormat:s});return(f=(0,N.w)(f,o.dtype),d)?(0,I.t)(f,[f.shape[1],f.shape[2],f.shape[3],f.shape[4]]):f}});var E=r(88527),A=r(67454),$=r(48683),F=r(75761),R=r(82171),_=r(30254);let D=(0,d.op)({basicLSTMCell_:function(e,t,r,n,a,s){let i=(0,h.YT)(e,"forgetBias","basicLSTMCell"),l=(0,h.YT)(t,"lstmKernel","basicLSTMCell"),u=(0,h.YT)(r,"lstmBias","basicLSTMCell"),p=(0,h.YT)(n,"data","basicLSTMCell"),d=(0,h.YT)(a,"c","basicLSTMCell"),c=(0,h.YT)(s,"h","basicLSTMCell"),f=(0,E.x)([p,c],1),m=(0,A.N)(f,l),g=(0,o.W)(m,u),y=g.shape[0],b=g.shape[1]/4,x=[y,b],v=(0,R.d)(g,[0,0],x),w=(0,R.d)(g,[0,b],x),T=(0,R.d)(g,[0,2*b],x),S=(0,R.d)(g,[0,3*b],x),N=(0,o.W)((0,$.l)((0,F.r)(v),(0,_.y)(w)),(0,$.l)(d,(0,F.r)((0,o.W)(i,T)))),k=(0,$.l)((0,_.y)(N),(0,F.r)(S));return[N,k]}});var O=r(52285),L=r(20219);let M=(0,d.op)({batchNorm2d_:function(e,t,r,n,a,s){let i,o,l=(0,h.YT)(e,"x","batchNorm"),u=(0,h.YT)(t,"mean","batchNorm"),d=(0,h.YT)(r,"variance","batchNorm");return null!=a&&(i=(0,h.YT)(a,"scale","batchNorm")),null!=n&&(o=(0,h.YT)(n,"offset","batchNorm")),p.vA(2===l.rank,()=>`Error in batchNorm2D: x must be rank 2 but got rank ${l.rank}.`),p.vA(2===u.rank||1===u.rank,()=>`Error in batchNorm2D: mean must be rank 2 or rank 1 but got rank ${u.rank}.`),p.vA(2===d.rank||1===d.rank,()=>`Error in batchNorm2D: variance must be rank 2 or rank 1 but got rank ${d.rank}.`),null!=i&&p.vA(2===i.rank||1===i.rank,()=>`Error in batchNorm2D: scale must be rank 2 or rank 1 but got rank ${i.rank}.`),null!=o&&p.vA(2===o.rank||1===o.rank,()=>`Error in batchNorm2D: offset must be rank 2 or rank 1 but got rank ${o.rank}.`),(0,L.$)(l,u,d,o,i,s)}}),P=(0,d.op)({batchNorm3d_:function(e,t,r,n,a,s){let i,o,l=(0,h.YT)(e,"x","batchNorm"),u=(0,h.YT)(t,"mean","batchNorm"),d=(0,h.YT)(r,"variance","batchNorm");return null!=a&&(i=(0,h.YT)(a,"scale","batchNorm")),null!=n&&(o=(0,h.YT)(n,"offset","batchNorm")),p.vA(3===l.rank,()=>`Error in batchNorm3D: x must be rank 3 but got rank ${l.rank}.`),p.vA(3===u.rank||1===u.rank,()=>`Error in batchNorm3D: mean must be rank 3 or rank 1 but got rank ${u.rank}.`),p.vA(3===d.rank||1===d.rank,()=>`Error in batchNorm3D: variance must be rank 3 or rank 1 but got rank ${d.rank}.`),null!=i&&p.vA(3===i.rank||1===i.rank,()=>`Error in batchNorm3D: scale must be rank 3 or rank 1 but got rank ${i.rank}.`),null!=o&&p.vA(3===o.rank||1===o.rank,()=>`Error in batchNorm3D: offset must be rank 3 or rank 1 but got rank ${o.rank}.`),(0,L.$)(l,u,d,o,i,s)}}),z=(0,d.op)({batchNorm4d_:function(e,t,r,n,a,s){let i,o,l=(0,h.YT)(e,"x","batchNorm"),u=(0,h.YT)(t,"mean","batchNorm"),d=(0,h.YT)(r,"variance","batchNorm");return null!=a&&(i=(0,h.YT)(a,"scale","batchNorm")),null!=n&&(o=(0,h.YT)(n,"offset","batchNorm")),p.vA(4===l.rank,()=>`Error in batchNorm4D: x must be rank 4 but got rank ${l.rank}.`),p.vA(4===u.rank||1===u.rank,()=>`Error in batchNorm4D: mean must be rank 4 or rank 1 but got rank ${u.rank}.`),p.vA(4===d.rank||1===d.rank,()=>`Error in batchNorm4D: variance must be rank 4 or rank 1 but got rank ${d.rank}.`),null!=i&&p.vA(4===i.rank||1===i.rank,()=>`Error in batchNorm4D: scale must be rank 4 or rank 1 but got rank ${i.rank}
106.`),null!=o&&p.vA(4===o.rank||1===o.rank,()=>`Error in batchNorm4D: offset must be rank 4 or rank 1 but got rank ${o.rank}.`),(0,L.$)(l,u,d,o,i,s)}}),B=(0,d.op)({bincount_:function(e,t,r){let n=(0,h.YT)(e,"x","bincount"),a=(0,h.YT)(t,"weights","bincount");return p.vA("int32"===n.dtype,()=>`Error in bincount: input dtype must be int32, but got ${n.dtype}`),p.vA(r>=0,()=>`size must be non-negative, but got ${r}.`),p.vA(a.size===n.size||0===a.size,()=>`Error in bincount: weights must have the same size as input or0-length, but got input shape: ${n.shape}, weights shape: ${a.shape}.`),l.T2.runKernel(u.N4F,{x:n,weights:a},{size:r})}}),W=(0,d.op)({bitwiseAnd_:function(e,t){let r=(0,h.YT)(e,"x","bitwiseAnd"),n=(0,h.YT)(t,"y","bitwiseAnd");if(!(0,p.r1)(r.shape,n.shape))throw Error(`BitwiseAnd: Tensors must have the same shape. x: ${r.shape}, y: ${n.shape}`);if("int32"!==r.dtype||"int32"!==n.dtype)throw Error(`BitwiseAnd: Only supports 'int32' values in tensor, found type of x: ${r.dtype} and type of y: ${n.dtype}`);return l.T2.runKernel(u.HNs,{a:r,b:n})}}),V=(0,d.op)({broadcastArgs_:function(e,t){let r=(0,h.YT)(e,"s0","broadcastArgs","int32"),n=(0,h.YT)(t,"s1","broadcastArgs","int32");if(1!==r.rank)throw Error(`broadcastArgs(): first input must be a vector (rank=1). Has rank ${r.rank}`);if(1!==n.rank)throw Error(`broadcastArgs(): second input must be a vector (rank=1). Has rank ${n.rank}`);return l.T2.runKernel(u.vj7,{s0:r,s1:n})}});var G=r(43182),U=r(993),Z=r(46534),j=r(53777),H=r(26004),K=r(46213);let Y=(0,d.op)({concat1d_:function(e){return(0,E.x)(e,0)}}),Q=(0,d.op)({concat2d_:function(e,t){return(0,E.x)(e,t)}}),q=(0,d.op)({concat3d_:function(e,t){return(0,E.x)(e,t)}}),X=(0,d.op)({concat4d_:function(e,t){return(0,E.x)(e,t)}});var J=r(45700),ee=r(90715),et=r(59307);let er=(0,d.op)({conv3d_:function(e,t,r,n,a="NDHWC",s=[1,1,1]){let i=(0,h.YT)(e,"x","conv3d"),o=(0,h.YT)(t,"filter","conv3d"),d=i,c=!1;4===i.rank&&(c=!0,d=(0,I.t)(i,[1,i.shape[0],i.shape[1],i.shape[2],i.shape[3]])),p.vA(5===d.rank,()=>`Error in conv3d: input must be rank 5, but got rank ${d.rank}.`),p.vA(5===o.rank,()=>`Error in conv3d: filter must be rank 5, but got rank ${o.rank}.`),p.vA(d.shape[4]===o.shape[3],()=>`Error in conv3d: depth of input (${d.shape[4]}) must match input depth for filter ${o.shape[3]}.`),p.vA((0,k.G0)(r,s),()=>`Error in conv3D: Either strides or dilations must be 1. Got strides ${r} and dilations '${s}'`),p.vA("NDHWC"===a,()=>`Error in conv3d: got dataFormat of ${a} but only NDHWC is currently supported.`),p.vA((0,k.qk)(s),()=>"Error in conv3D: Dilated rates should be larger than 0."),p.vA((0,k.qk)(r),()=>"Error in conv3D: Strides should be larger than 0.");let f={x:d,filter:o},m=l.T2.runKernel(u.A1h,f,{strides:r,pad:n,dataFormat:a,dilations:s});return c?(0,I.t)(m,[m.shape[1],m.shape[2],m.shape[3],m.shape[4]]):m}});var en=r(1374);let ea=(0,d.op)({conv3dTranspose_:function(e,t,r,n,a){let s=(0,h.YT)(e,"x","conv3dTranspose"),i=(0,h.YT)(t,"filter","conv3dTranspose");return(0,en.c)(r,s,i,n,a)}});var es=r(53858),ei=r(92610),eo=r(46660),el=r(83641);let eu=(0,d.op)({denseBincount_:function(e,t,r,n=!1){let a=(0,h.YT)(e,"x","denseBincount"),s=(0,h.YT)(t,"weights","denseBincount");return p.vA("int32"===a.dtype,()=>`Error in denseBincount: input dtype must be int32, but got ${a.dtype}`),p.vA(a.rank<=2,()=>`Error in denseBincount: input must be at most rank 2, but got rank ${a.rank}.`),p.vA(r>=0,()=>`size must be non-negative, but got ${r}.`),p.vA(s.size===a.size||0===s.size,()=>`Error in denseBincount: weights must have the same shape as x or 0-length, but got x shape: ${a.shape}, weights shape: ${s.shape}.`),l.T2.runKernel(u.wNW,{x:a,weights:s},{size:r,binaryOutput:n})}});var eh=r(36705),ep=r(38773);let ed=(0,d.op)({diag_:function(e){let t=(0,h.YT)(e,"x","diag");return l.T2.runKernel(u.ORI,{x:t})}});var ec=r(16427),ef=r(13062),em=r(6726),eg=r(39646);let ey=(0,d.op)({einsum_:function(e,...t){let r=t.map((e,t)=>(0,h.YT)(e,`tensors${t}`,"einsum"));return l.T2.runKernel(u.Qgm,r,{equation:e})}});var eb=r(65737);let ex=(0,d.op)({ensureShape_:function(e,t){let r=(0,h.YT)(e,"x","ensureShape","string_or_numeric");if(!(0,p.e_)(r.shape,t))throw Error(`EnsureShape: Shape of tensor ${r.shape} is not compatible with expected shape ${t}`);return e}});var ev=r(12989),ew=r(25742),eT=r(40064),eS=r(25158),eN=r(7487),ek=r(85692),eI=r(97651);let eC=(0,d.op)({eye_:function(e,t,r,n="float32"){null==t&&(t=e);let a=(0,U.r)([e,t],n),s=e<=t?e:t;for(let e=0;e<s;++e)a.set(1,e,e);let i=(0,I.t)(a.toTensor(),[e,t]);if(null==r)return i;if(1===r.length)return(0,eI.V)((0,eN.U)(i,0),[r[0],1,1]);if(2===r.length)return(0,eI.V)((0,eN.U)((0,eN.U)(i,0),0),[r[0],r[1],1,1]);if(3===r.length)return(0,eI.V)((0,eN.U)((0,eN.U)((0,eN.U)(i,0),0),0),[r[0],r[1],r[2],1,1]);throw Error(`eye() currently supports only 1D and 2D batchShapes, but received ${r.length}D.`)}});var eE=r(45382),eA=r(91951),e$=r(81918),eF=r(72796),eR=r(25283),e_=r(91104),eD=r(14017),eO=r(79039),eL=r(60631),eM=r(6053),eP=r(12550),ez=r(18358),eB=r(47293);function eW(e,t,r){if(r<=0)throw Error("The number of values should be positive.");return l.T2.runKernel(u.mnI,{},{start:e,stop:t,num:r})}
106var eV=r(67562),eG=r(29659),eU=r(61838),eZ=r(38308),ej=r(95150),eH=r(14027),eK=r(32428),eY=r(83152),eQ=r(94742),eq=r(25612);let eX=(0,d.op)({searchSorted_:function(e,t,r="left"){let n=(0,h.YT)(e,"sortedSequence","searchSorted"),a=(0,h.YT)(t,"values","searchSorted"),s=n.shape[n.shape.length-1],i=a.shape[a.shape.length-1],o=(0,I.t)(n,[-1,s]),d=(0,I.t)(a,[-1,i]);if(o.rank<2)throw Error("Sorted input argument must be at least 2-dimensional");if(o.shape[0]!==d.shape[0])throw Error("Leading dimension of 'sortedSequence' and 'values' must match.");if((0,p.Ze)(d.shape)>=0x80000000)throw Error("values tensor size must less than 2147483648");if(o.shape[1]>=0x80000000)throw Error(`trailing dim_size must less than 2147483648 for int32 output type, was ${o.shape[1]}`);return l.T2.runKernel(u.uWl,{sortedSequence:o,values:d},{side:r})}});function eJ(e,t){return eX(e,t,"left")}var e0=r(79459),e1=r(51006);let e2=(0,d.op)({maxPool3d_:function(e,t=[1,1,1],r,n,a,s="NDHWC"){let i=(0,h.YT)(e,"x","maxPool3d"),o=i,d=!1;4===i.rank&&(d=!0,o=(0,I.t)(i,[1,i.shape[0],i.shape[1],i.shape[2],i.shape[3]])),p.vA(5===o.rank,()=>`Error in maxPool3d: x must be rank 5 but got rank ${o.rank}.`),p.vA("NDHWC"===s,()=>`Error in maxPool3d: Only NDHWC is currently supported, but got dataFormat of ${s}`),(0,k.s_)("maxPool3d",n,a);let c={x:o},f=l.T2.runKernel(u.ySp,c,{filterSize:t,strides:r,pad:n,dimRoundingMode:a,dataFormat:s});return d?(0,I.t)(f,[f.shape[1],f.shape[2],f.shape[3],f.shape[4]]):f}}),e3=(0,d.op)({maxPoolWithArgmax_:function(e,t,r,n,a=!1){let s=(0,h.YT)(e,"x","maxPoolWithArgmax"),i=l.T2.runKernel(u.TL8,{x:s},{filterSize:t,strides:r,pad:n,includeBatchInIndex:a});return{result:i[0],indexes:i[1]}}});var e4=r(80107),e5=r(76506),e6=r(57690),e7=r(60218);function e9(e,t,{indexing:r="xy"}={}){if("xy"!==r&&"ij"!==r)throw TypeError(`${r} is not a valid third argument to meshgrid`);if(void 0===e)return[];let n=(0,h.YT)(e,"x","meshgrid",e instanceof e7.qY?e.dtype:"float32");if(void 0===t)return[n];let a=(0,h.YT)(t,"y","meshgrid",t instanceof e7.qY?t.dtype:"float32"),s=(0,p.Ze)(n.shape),i=(0,p.Ze)(a.shape);return"xy"===r?(n=(0,I.t)(n,[1,-1]),a=(0,I.t)(a,[-1,1]),[(0,A.N)((0,e6.S)([i,1],n.dtype),n),(0,A.N)(a,(0,e6.S)([1,s],a.dtype))]):(n=(0,I.t)(n,[-1,1]),a=(0,I.t)(a,[1,-1]),[(0,A.N)(n,(0,e6.S)([1,i],n.dtype)),(0,A.N)((0,e6.S)([s,1],a.dtype),a)])}var e8=r(61541),te=r(79045),tt=r(86694),tr=r(66025),tn=r(61727),ta=r(20160),ts=r(92263);let ti=(0,d.op)({moments_:function(e,t=null,r=!1){e=(0,h.YT)(e,"x","moments");let n=(0,p.Y6)(t,e.shape),a=(0,e5.i)(e,n,r),s=a.shape;r||(s=(0,tn.SM)(a.shape,n));let i=(0,ta.E)((0,ts.j)((0,N.w)(e,"float32"),(0,I.t)(a,s)));return{mean:a,variance:(0,e5.i)(i,n,r)}}}),to=(0,d.op)({multiRNNCell_:function(e,t,r,n){let a=(0,h.YT)(t,"data","multiRNNCell"),s=(0,h.j1)(r,"c","multiRNNCell"),i=(0,h.j1)(n,"h","multiRNNCell"),o=a,l=[];for(let t=0;t<e.length;t++){let r=e[t](o,s[t],i[t]);l.push(r[0]),l.push(r[1]),o=r[1]}let u=[],p=[];for(let e=0;e<l.length;e+=2)u.push(l[e]),p.push(l[e+1]);return[u,p]}}),tl=(0,d.op)({multinomial_:function(e,t,r,n=!1){let a=(0,h.YT)(e,"logits","multinomial"),s=a.size,i=a.rank;if(s<2)throw Error(`Error in multinomial: you need at least 2 outcomes, but got ${s}.`);if(i>2)throw Error(`Rank of probabilities must be 1 or 2, but is ${i}`);r=r||Math.random();let o=1===i?(0,I.t)(a,[1,-1]):a,p={numSamples:t,seed:r,normalized:n},d=l.T2.runKernel(u.WT3,{logits:o},p);return 1===i?(0,I.t)(d,[d.size]):d}});var tu=r(28235),th=r(24487),tp=r(18313),td=r(80116);let tc=(0,d.op)({outerProduct_:function(e,t){let r=(0,h.YT)(e,"v1","outerProduct"),n=(0,h.YT)(t,"v2","outerProduct");p.vA(1===r.rank&&1===n.rank,()=>`Error in outerProduct: inputs must be rank 1, but got ranks ${r.rank} and ${n.rank}.`);let a=(0,I.t)(r,[-1,1]),s=(0,I.t)(n,[1,-1]);return(0,A.N)(a,s)}});var tf=r(50684);let tm=(0,d.op)({pad1d_:function(e,t,r=0){return(0,p.vA)(2===t.length,()=>"Invalid number of paddings. Must be length of 2."),(0,tf.e)(e,[t],r)}}),tg=(0,d.op)({pad2d_:function(e,t,r=0){return(0,p.vA)(2===t.length&&2===t[0].length&&2===t[1].length,()=>
106"Invalid number of paddings. Must be length of 2 each."),(0,tf.e)(e,t,r)}}),ty=(0,d.op)({pad3d_:function(e,t,r=0){return(0,p.vA)(3===t.length&&2===t[0].length&&2===t[1].length&&2===t[2].length,()=>"Invalid number of paddings. Must be length of 2 each."),(0,tf.e)(e,t,r)}}),tb=(0,d.op)({pad4d_:function(e,t,r=0){return(0,p.vA)(4===t.length&&2===t[0].length&&2===t[1].length&&2===t[2].length&&2===t[3].length,()=>"Invalid number of paddings. Must be length of 2 each."),(0,tf.e)(e,t,r)}});var tx=r(65417),tv=r(25351),tw=r(17019),tT=r(32294),tS=r(60058);let tN=(0,d.op)({raggedGather_:function(e,t,r,n){let a=e.map((e,t)=>(0,h.YT)(e,`tensors${t}`,"raggedGather","int32")),s=(0,h.YT)(t,"paramsDenseValues","raggedGather"),i=(0,h.YT)(r,"indices","raggedGather","int32"),o=l.T2.runKernel(u.oJ2,{paramsNestedSplits:a,paramsDenseValues:s,indices:i},{outputRaggedRank:n});return{outputNestedSplits:o.slice(0,o.length-1),outputDenseValues:o[o.length-1]}}}),tk=(0,d.op)({raggedRange_:function(e,t,r){let n=(0,h.YT)(e,"starts","raggedRange"),a=(0,h.YT)(t,"limits","raggedRange",n.dtype),s=(0,h.YT)(r,"deltas","raggedRange",n.dtype),i=l.T2.runKernel(u.CQC,{starts:n,limits:a,deltas:s});return{rtNestedSplits:i[0],rtDenseValues:i[1]}}}),tI=(0,d.op)({raggedTensorToTensor_:function(e,t,r,n,a){let s=(0,h.YT)(e,"shape","raggedTensorToTensor","int32"),i=(0,h.YT)(t,"values","raggedTensorToTensor"),o=(0,h.YT)(r,"defaultValue","raggedTensorToTensor",i.dtype),p=n.map((e,t)=>(0,h.YT)(e,`tensors${t}`,"raggedTensorToTensor","int32"));return l.T2.runKernel(u.mH5,{shape:s,values:i,defaultValue:o,rowPartitionTensors:p},{rowPartitionTypes:a})}}),tC=(0,d.op)({rand_:function(e,t,r){(0,p.SA)(e);let n=(0,p.Ze)(e),a=null;if(null==r||"float32"===r)a=new Float32Array(n);else if("int32"===r)a=new Int32Array(n);else if("bool"===r)a=new Uint8Array(n);else throw Error(`Unknown data type ${r}`);for(let e=0;e<n;e++)a[e]=t();return l.T2.makeTensor(a,e,r)}});var tE=r(60270);class tA{constructor(e,t,r,n,a){this.mean=e,this.stdDev=t,this.dtype=r,this.nextVal=NaN,this.truncated=n,this.truncated&&(this.upper=this.mean+2*this.stdDev,this.lower=this.mean-2*this.stdDev);let s=a||Math.random();this.random=tE.alea(s.toString())}nextValue(){let e,t;if(!isNaN(this.nextVal)){let e=this.nextVal;return this.nextVal=NaN,e}let r=!1;for(;!r;){let n,a,s;do s=(n=2*this.random()-1)*n+(a=2*this.random()-1)*a;while(s>=1||0===s);let i=Math.sqrt(-2*Math.log(s)/s);e=this.mean+this.stdDev*n*i,t=this.mean+this.stdDev*a*i,(!this.truncated||this.isValidTruncated(e))&&(r=!0)}return(!this.truncated||this.isValidTruncated(t))&&(this.nextVal=this.convertValue(t)),this.convertValue(e)}convertValue(e){return null==this.dtype||"float32"===this.dtype?e:Math.round(e)}isValidTruncated(e){return e<=this.upper&&e>=this.lower}}class t${constructor(e,t,r,n){this.alpha=e,this.beta=1/t,this.dtype=r;let a=n||Math.random();this.randu=tE.alea(a.toString()),this.randn=new tA(0,1,r,!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,r,n,a,s;for(;;){do n=this.randn.nextValue(),s=1+this.c*n;while(s<=0);if(s*=s*s,t=1-.331*(e=n*n)*e,r=.5*e+this.d*(1-s+Math.log(s)),(a=this.randu())<t||Math.log(a)<r)break}return s=1/this.beta*this.d*s,this.alpha<1&&(s*=Math.pow(this.randu(),1/this.alpha)),this.convertValue(s)}convertValue(e){return"float32"===this.dtype?e:Math.round(e)}}class tF{constructor(e=0,t=1,r,n){if(this.canReturnFloat=()=>null==this.dtype||"float32"===this.dtype,this.min=e,this.range=t-e,this.dtype=r,null==n&&(n=Math.random()),"number"==typeof n&&(n=n.toString()),!this.canReturnFloat()&&this.range<=1)throw Error(`The difference between ${e} - ${t} <= 1 and dtype is not float`);this.random=tE.alea(n)}convertValue(e){return this.canReturnFloat()?e:Math.round(e)}nextValue(){return this.convertValue(this.min+this.range*this.random())}}let tR=(0,d.op)({randomGamma_:function(e,t,r=1,n="float32",a){if((0,p.SA)(e),null==r&&(r=1),null==n&&(n="float32"),"float32"!==n&&"int32"!==n)throw Error(`Unsupported data type ${n}`);let s=new t$(t,r,n,a),i=(0,U.r)(e,n);for(let e=0;e<i.values.length;e++)i.values[e]=s.nextValue();return i.toTensor()}}),t_=(0,d.op)({randomNormal_:function(e,t=0,r=1,n,a){if((0,p.SA)(e),null!=n&&"bool"===n)throw Error(`Unsupported data type ${n}`);let s=new tA(t,r,n,!1,a),i=(0,U.r)(e,n);for(let e=0;e<i.values.length;e++)i.values[e]=s.nextValue();return i.toTensor()}}),tD=(0,d.op)({randomStandardNormal_:function(e,t,r){if(null!=t&&"bool"===t)throw Error(`Unsupported data type ${t}`);return t_(e,0,1,t,r)}}),tO=(0,d.op)({randomUniform_:function(e,t=0,r=1,n="float32",a){(0,p.SA)(e);let s=(0,U.r)(e,n),i=new tF(t,r,null,a);for(let e=0;e<s.values.length;e++)s.values[e]=i.nextValue();return s.toTensor()}}),tL=(0,d.op)({randomUniformInt_:function(e,t,r,n){return tO(e,t,r,"int32",n)}});function tM(e,t,r=1,n="float32"){if(0===r)throw Error("Cannot have a step of zero");return l.T2.runKernel(u.Q6t,{},{start:e,stop:t,step:r,dtype:n})}var tP=r(95791),tz=r(43239),tB=r(55865),tW=r(23533),tV=r(63191);let tG=(0,d.op)({reverse1d_:function(e){let t=(0,h.YT)(e,"x","reverse");return p.vA(1===t.rank,()=>`Error in reverse1D: x must be rank 1 but got rank ${t.rank}.`),(0,tV.B)(t,0)}}),tU=(0,d.op)({reverse2d_:function(e,t){let r=(0,h.YT)(e,"x","reverse");return p.vA(2===r.rank,()=>`Error in reverse2D: x must be rank 2 but got rank ${r.rank}.`),(0,tV.B)(r,t)}}),tZ=(0,d.op)({reverse3d_:function(e,t){let r=(0,h.YT)(e,"x","reverse");return p.vA(3===r.rank,()=>`Error in reverse3D: x must be rank 3 but got rank ${r.rank}.`),(0,tV.B)(r,t)}}),tj=(0,d.op)({reverse4d_:function(e,t){let r=(0,h.YT)(e,"x","reverse");return p.vA(4===r.rank,()=>`Error in reverse4D: x must be rank 4 but got rank ${r.rank}.`),(0,tV.B)(r,t)}});var tH=r(67329),tK=r(15181),tY=r(30319),tQ=r(39500),tq=r(44355);let tX=async function(e,t){let r=(0,h.YT)(e,"x","setdiff1d"),n=(0,h.YT)(t,"y","setdiff1d");p.vA(r.dtype===n.dtype,()=>`x and y should have the same dtype, but got x (${r.dtype}) and y (${n.dtype}).`),p.vA(1===r.rank,()=>`x should be 1D tensor, but got x (${r.shape}).`),p.vA(1===n.rank,()=>`y should be 1D tensor, but got y (${n.shape}).`);let a=await r.data(),s=new Set(await n.data()),i=0;for(let e=0;e<a.length;e++)!s.has(a[e])&&i++;let o=new e7.yl([i],r.dtype),l=new e7.yl([i],"int32");for(let e=0,t=0;e<a.length;e++)!s.has(a[e])&&(o.values[t]=a[e],l.values[t]=e,t++);return[o.toTensor(),l.toTensor()]};var tJ=r(1930),t0=r(50943),t1=r(27085);let t2=(0,d.op)({slice1d_:function(e,t,r){let n=(0,h.YT)(e,"x","slice1d");return p.vA(1===n.rank,()=>`slice1d expects a rank-1 tensor, but got a rank-${n.rank} tensor`),(0,R.d)(n,[t],[r])}}),t3=(0,d.op)({slice2d_:function(e,t,r){let n=(0,h.YT)(e,"x","slice2d");return p.vA(2===n.rank,()=>`slice2d expects a rank-2 tensor, but got a rank-${n.rank} tensor`),(0,R.d)(n,t,r)}}),t4=(0,d.op)({slice3d_:function(e,t,r){let n=(0,h.YT)(e,"x","slice3d");return p.vA(3===n.rank,()=>`slice3d expects a rank-3 tensor, but got a rank-${n.rank} tensor`),(0,R.d)(n,t,r)}}),t5=(0,d.op)({slice4d_:function(e,t,r){let n=(0,h.YT)(e,"x","slice4d");return p.vA(4===n.rank,()=>`slice4d expects a rank-4 tensor, but got a rank-${n.rank} tensor`),(0,R.d)(n,t,r)}});var t6=r(83635),t7=r(96247),t9=r(51097),t8=r(30824),re=r(86405),rt=r(66333),rr=r(2774),rn=r(24361),ra=r(76125),rs=r(27610),ri=r(95989),ro=r(35981),rl=r(71069),ru=r(69751),rh=r(60966),rp=r
106(43062),rd=r(22666),rc=r(57290);function rf(e,t){(0,p.HO)(e);let r=(0,h.MZ)(e,t);if(1!==r.length)throw Error("tensor1d() requires values to be a flat/TypedArray");return(0,rc.Q)(e,null,r,t)}function rm(e,t,r){if((0,p.HO)(e),null!=t&&2!==t.length)throw Error("tensor2d() requires shape to have two numbers");let n=(0,h.MZ)(e,r);if(2!==n.length&&1!==n.length)throw Error("tensor2d() requires values to be number[][] or flat/TypedArray");if(1===n.length&&null==t)throw Error("tensor2d() requires shape to be provided when `values` are a flat/TypedArray");return(0,rc.Q)(e,t,n,r)}var rg=r(15401);function ry(e,t,r){if((0,p.HO)(e),null!=t&&4!==t.length)throw Error("tensor4d() requires shape to have four numbers");let n=(0,h.MZ)(e,r);if(4!==n.length&&1!==n.length)throw Error("tensor4d() requires values to be number[][][][] or flat/TypedArray");if(1===n.length&&null==t)throw Error("tensor4d() requires shape to be provided when `values` are a flat array");return(0,rc.Q)(e,t,n,r)}function rb(e,t,r){if((0,p.HO)(e),null!=t&&5!==t.length)throw Error("tensor5d() requires shape to have five numbers");let n=(0,h.MZ)(e,r);if(5!==n.length&&1!==n.length)throw Error("tensor5d() requires values to be number[][][][][] or flat/TypedArray");if(1===n.length&&null==t)throw Error("tensor5d() requires shape to be provided when `values` are a flat array");return(0,rc.Q)(e,t,n,r)}function rx(e,t,r){if((0,p.HO)(e),null!=t&&6!==t.length)throw Error("tensor6d() requires shape to have six numbers");let n=(0,h.MZ)(e,r);if(6!==n.length&&1!==n.length)throw Error("tensor6d() requires values to be number[][][][][][] or flat/TypedArray");if(1===n.length&&null==t)throw Error("tensor6d() requires shape to be provided when `values` are a flat array");return t=t||n,(0,rc.Q)(e,t,n,r)}var rv=r(94915);let rw=(0,d.op)({tensorScatterUpdate_:function(e,t,r){let n=(0,h.YT)(e,"tensor","tensorScatterupdate"),a=(0,h.YT)(t,"indices","tensorScatterupdate","int32"),s=(0,h.YT)(r,"updates","tensorScatterupdate");if(rv.validateInput(s,a,n.shape),n.dtype!==s.dtype)throw Error(`tensor and updates must have the same dtype, instead they are ${n.dtype} and ${s.dtype}.`);return l.T2.runKernel(u.X4r,{tensor:n,indices:a,updates:s},{})}});var rT=r(81031);let rS=(0,d.op)({truncatedNormal_:function(e,t=0,r=1,n,a){if((0,p.SA)(e),null!=n&&"bool"===n)throw Error("Unsupported data type $ { dtype }");let s=new tA(t,r,n,!0,a),i=(0,U.r)(e,n);for(let e=0;e<i.values.length;e++)i.values[e]=s.nextValue();return i.toTensor()}});var rN=r(59744),rk=r(5051),rI=r(64828);function rC(e,t){return eX(e,t,"right")}function rE(e,t=!0,r,n){return l.T2.makeVariable(e,t,r,n)}var rA=r(82198),r$=r(19474);let rF=async function(e){let t=(0,h.YT)(e,"condition","whereAsync","bool"),r=await t.data(),n=(0,r$.Y)(t.shape,r);
106return e!==t&&t.dispose(),n};var rR=r(59918),r_=r(79320);let rD=async function(e,t,r){let n=(0,h.YT)(e,"tensor","boolMask"),a=(0,h.YT)(t,"mask","boolMask","bool"),s=null==r?0:r,i=a.rank,o=n.shape;p.vA(i>0,()=>"mask cannot be scalar"),p.O3(o.slice(s,s+i),a.shape,"mask's shape must match the first K dimensions of tensor's shape,");let l=1;for(let e=s;e<s+i;e++)l*=o[e];let u=o.slice(0,s).concat([l],o.slice(s+i)),d=(0,I.t)(n,u),c=(0,I.t)(a,[-1]),f=await rF(c),m=(0,ri.r)(f,[1]),g=(0,eF.k)(d,m,s);return e!==n&&n.dispose(),t!==a&&a.dispose(),m.dispose(),d.dispose(),c.dispose(),f.dispose(),g};var rO=r(60286),rL=r(5565),rM=r(50124);let rP=(0,d.op)({movingAverage_:function(e,t,r,n,a=!0){let s=(0,h.YT)(e,"v","movingAverage"),i=(0,h.YT)(t,"x","movingAverage"),l=(0,h.YT)(r,"decay","movingAverage");(0,rM.assertTypesMatch)(s,i),p.vA(p.r1(s.shape,i.shape),()=>"Shape mismatch in v and x");let u=(0,tY.d)(1),d=(0,ts.j)(u,l),c=(0,$.l)((0,ts.j)(i,s),d);if(a){p.vA(null!=n,()=>"When using zeroDebias: true, step is required.");let e=(0,h.YT)(n,"step","movingAverage");c=(0,ef.y)(c,(0,ts.j)(u,(0,tv.n)(l,e)))}return(0,o.W)(s,c)}}),rz=(0,d.op)({scatterND_:function(e,t,r){(0,p.SA)(r);let n=(0,h.YT)(e,"indices","scatterND","int32"),a=(0,h.YT)(t,"updates","scatterND");return rv.validateInput(a,n,r),l.T2.runKernel(u.pJc,{indices:n,updates:a},{shape:r})}}),rB=(0,d.op)({sparseToDense_:function(e,t,r,n=0){(0,p.SA)(r);let a=(0,h.YT)(e,"sparseIndices","sparseToDense","int32"),s=(0,h.YT)(t,"sparseValues","sparseToDense","string_or_numeric"),i=(0,h.YT)(n,"defaultValue","sparseToDense",s.dtype);if("int32"!==a.dtype)throw Error(`tf.sparseToDense() expects the indices to be int32 type, but the dtype was ${a.dtype}.`);if(a.rank>2)throw Error(`sparseIndices should be a scalar, vector, or matrix, but got shape ${a.shape}.`);let o=a.rank>0?a.shape[0]:1,d=a.rank>1?a.shape[1]:1;if(r.length!==d)throw Error(`outputShape has incorrect number of elements:, ${r.length}, should be: ${d}.`);let c=s.size;if(0!==s.rank&&(1!==s.rank||c!==o))throw Error(`sparseValues has incorrect shape ${s.shape}, should be [] or [${o}]`);if(s.dtype!==i.dtype)throw Error("sparseValues.dtype must match defaultValues.dtype");return l.T2.runKernel(u.jgd,{sparseIndices:a,sparseValues:s,defaultValue:i},{outputShape:r})}}),rW=(0,d.op)({gatherND_:function(e,t){let r=(0,h.YT)(t,"indices","gatherND","int32"),n=(0,h.YT)(e,"x","gatherND","string_or_numeric");return l.T2.runKernel(u.O4G,{params:n,indices:r})}}),rV=(0,d.op)({dropout_:function(e,t,r,n){let a=(0,h.YT)(e,"x","dropout");if(p.vA("float32"===a.dtype,()=>`x has to be a floating point tensor since it's going to be scaled, but got a ${a.dtype} tensor instead.`),p.vA(t>=0&&t<1,()=>`rate must be a float in the range [0, 1), but got ${t}.`),0===t)return e instanceof e7.qY?a.clone():a;let s=function(e,t){if(null==t)return e.shape.slice();if(p.r1(e.shape,t))return t;if(e.shape.length===t.length){let r=[];for(let n=0;n<e.shape.length;n++)null==t[n]&&null!=e.shape[n]?r.push(e.shape[n]):r.push(t[n]);return r}return t}(a,r),i=1-t,l=(0,ef.y)((0,eA.R)((0,o.W)(tO(s,0,1,"float32",n),i)),i);return(0,$.l)(a,l)}});function rG(e){return Math.floor(Math.pow(2,Math.ceil(Math.log(e)/Math.log(2))))}function rU(e,t,r){let n=1-e%2,a=new Float32Array(e);for(let s=0;s<e;++s){let i=2*Math.PI*s/(e+n-1);a[s]=t-r*Math.cos(i)}return rf(a,"float32")}let rZ=async function(e,t,r=1){let n=(0,h.YT)(e,"predictions","inTopK"),a=(0,h.YT)(t,"targets","inTopK");(0,p.vA)(n.rank>1,()=>`inTopK() expects the predictions to be of rank 2 or higher, but got ${n.rank}`),(0,p.vA)(n.rank-1===a.rank,()=>`predictions rank should be 1 larger than targets rank, but got predictions rank ${n.rank} and targets rank ${a.rank}`),(0,p.O3)(n.shape.slice(0,n.shape.length-1),a.shape,"predictions's shape should be align with the targets' shape, except the last dimension.");let s=n.shape[n.shape.length-1];(0,p.vA)(r>0&&r<=s,()=>`'k' passed to inTopK() must be > 0 && <= the predictions last dimension (${s}), but got ${r}`);let i=await n.data(),o=await a.data(),[l,u]=[i.length/s,s],d=(0,p.ce)("bool",l);for(let e=0;e<l;e++){let t=e*u,n=i.subarray(t,t+u),a=[];for(let e=0;e<n.length;e++)a.push({value:n[e],index:e});a.sort((e,t)=>
106t.value-e.value),d[e]=0;for(let t=0;t<r;t++)if(a[t].index===o[e]){d[e]=1;break}}return e!==n&&n.dispose(),t!==a&&a.dispose(),(0,rd.O)(d,a.shape,"bool")};var rj=r(10551),rH=r(83231),rK=r(40953),rY=r(78213),rQ=r(30631);let rq=(0,d.op)({fusedConv2d_:function({x:e,filter:t,strides:r,pad:n,dataFormat:a="NHWC",dilations:s=[1,1],dimRoundingMode:i,bias:d,activation:c="linear",preluActivationWeights:f,leakyreluAlpha:m}){let g,y;if(c=c||"linear",!1===(0,rQ.zE)(l.T2.state.gradientDepth,c)){p.vA("NHWC"===a,()=>`Error in fused conv2d: got dataFormat of ${a} but only NHWC is currently supported for the case of gradient depth is 0 and the activation is not linear.`);let l=(0,ee.X)(e,t,r,n,a,s,i);return null!=d&&(l=(0,o.W)(l,d)),(0,rQ.f2)(l,c,f,m)}let b=(0,h.YT)(e,"x","conv2d","float32"),x=(0,h.YT)(t,"filter","conv2d","float32"),v=b,w=!1;3===b.rank&&(w=!0,v=(0,I.t)(b,[1,b.shape[0],b.shape[1],b.shape[2]])),p.vA(4===v.rank,()=>`Error in fused conv2d: input must be rank 4, but got rank ${v.rank}.`),p.vA(4===x.rank,()=>`Error in fused conv2d: filter must be rank 4, but got rank ${x.rank}.`),k.s_("fused conv2d",n,i);let T="NHWC"===a?v.shape[3]:v.shape[1];p.vA(x.shape[2]===T,()=>`Error in conv2d: depth of input (${T}) must match input depth for filter ${x.shape[2]}.`),p.vA(k.G0(r,s),()=>`Error in conv2D: Either strides or dilations must be 1. Got strides ${r} and dilations '${s}'`);let S=k.uf(v.shape,x.shape,r,s,n,i);if(null!=d&&(g=(0,h.YT)(d,"bias","fused conv2d"),[g]=(0,rM.makeTypesMatch)(g,b),"NHWC"===a?rH.assertAndGetBroadcastShape(S.outShape,g.shape):(p.vA(g.shape.length<=1,()=>`Error in fused conv2d: only supports scalar or 1-D Tensor bias for NCHW format but got the bias of rank-${g.shape.length}.`),p.vA(0===g.shape.length||g.shape[0]===S.outChannels||1===g.shape[0],()=>`Error in fused conv2d: bias shape (${g.shape}) is not compatible with the number of output channels (${S.outChannels})`))),null!=f){let e=f.shape;if(p.vA(e.length<=1||3===e.length,()=>`Error in fused conv2d: only supports scalar, 1-D Tensor or 3-D Tensor PReLU activation weights but got a tensor of rank-${e.length}
106.`),1===e.length)p.vA(1===e[0]||e[0]===S.outChannels,()=>`Error in fused conv2d: PReLU activation weights (${e}) is not compatible with the number of output channels (${S.outChannels}).`);else if(3===e.length)try{rH.assertAndGetBroadcastShape(e,S.outShape)}catch(t){throw Error(`Error in fused conv2d: PReLU activation weights (${e}) is not compatible with the output shape of the conv2d (${S.outShape}).`)}y=(0,h.YT)(f,"prelu weights","fused conv2d")}let N=(e,t)=>{p.vA("NHWC"===a,()=>`Error in gradient of fused conv2D: got dataFormat of ${a} but only NHWC is currently supported.`);let[i,o,l,u]=t,h=(0,rQ.XB)(e,l,c);p.vA(k.Dh(s),()=>`Error in gradient of fused conv2D: dilation rates greater than 1 are not yet supported in gradients. Got dilations '${s}'`);let d=[(0,rY.v)(o.shape,h,i,r,n),(0,rK.H)(o,h,i.shape,r,n)];if(null!=u){let e=(0,rQ.Do)(u,h);d.push(e)}return d},C={x:v,filter:x,bias:g,preluActivationWeights:y},E={strides:r,pad:n,dataFormat:a,dilations:s,dimRoundingMode:i,activation:c,leakyreluAlpha:m};return null==d?(0,rj._X)((e,t,r)=>{let n=l.T2.runKernel(u.aAr,C,E);return r([t,e,n]),w&&(n=(0,I.t)(n,[n.shape[1],n.shape[2],n.shape[3]])),{value:n,gradFunc:N}})(v,x):(0,rj._X)((e,t,r,n)=>{let a=l.T2.runKernel(u.aAr,C,E);return n([t,e,a,r]),w&&(a=(0,I.t)(a,[a.shape[1],a.shape[2],a.shape[3]])),{value:a,gradFunc:N}})(v,x,g)}});var rX=r(52123),rJ=r(90855);let r0=(0,d.op)({fusedDepthwiseConv2d_:function({x:e,filter:t,strides:r,pad:n,dataFormat:a="NHWC",dilations:s=[1,1],dimRoundingMode:i,bias:d,activation:c="linear",preluActivationWeights:f,leakyreluAlpha:m}){let g,y;if(!1===(0,rQ.zE)(l.T2.state.gradientDepth,c)){let l=(0,ep.G)(e,t,r,n,a,s,i);return null!=d&&(l=(0,o.W)(l,d)),(0,rQ.f2)(l,c,f,m)}let b=(0,h.YT)(e,"x","depthwiseConv2d","float32"),x=(0,h.YT)(t,"filter","depthwiseConv2d","float32"),v=b,w=!1;3===b.rank&&(w=!0,v=(0,I.t)(b,[1,b.shape[0],b.shape[1],b.shape[2]])),p.vA(4===v.rank,()=>`Error in fused depthwiseConv2d: input must be rank 4, but got rank ${v.rank}.`),p.vA(4===x.rank,()=>`Error in fused depthwiseConv2d: filter must be rank 4, but got rank ${x.rank}.`),p.vA(v.shape[3]===x.shape[2],()=>`Error in fused depthwiseConv2d: number of input channels (${v.shape[3]}) must match the inChannels dimension in filter ${x.shape[2]}.`),null==s&&(s=[1,1]),p.vA(k.G0(r,s),()=>`Error in fused depthwiseConv2d: Either strides or dilations must be 1. Got strides ${r} and dilations '${s}'`),k.s_("fused depthwiseConv2d",n,i);let T=k.uf(v.shape,x.shape,r,s,n,i,!0);null!=d&&(g=(0,h.YT)(d,"bias","fused conv2d"),[g]=(0,rM.makeTypesMatch)(g,b),rH.assertAndGetBroadcastShape(T.outShape,g.shape)),null!=f&&(y=(0,h.YT)(f,"prelu weights","fused depthwiseConv2d"));let S=(e,t)=>{p.vA(k.Dh(s),()=>`Error in gradient of fused depthwiseConv2d: dilation rates greater than 1 are not yet supported. Got dilations '${s}'`);let[a,o,l,u]=t,h=(0,rQ.XB)(e,l,c),d=(0,rJ.l)(o.shape,h,a,r,n,s,i),f=(0,rX.x)(o,h,a.shape,r,n,s,i);return null!=u?[d,f,(0,rQ.Do)(g,h)]:[d,f]},N={x:v,filter:x,bias:g,preluActivationWeights:y},C={strides:r,pad:n,dataFormat:a,dilations:s,dimRoundingMode:i,activation:c,leakyreluAlpha:m};return null==d?(0,rj._X)((e,t,r)=>{let n=l.T2.runKernel(u.T7M,N,C);return r([t,e,n]),w&&(n=(0,I.t)(n,[n.shape[1],n.shape[2],n.shape[3]])),{value:n,gradFunc:S}})(v,x):(0,rj._X)((e,t,r,n)=>{let a=l.T2.runKernel(u.T7M,N,C);return n([t,e,a,r]),w&&(a=(0,I.t)(a,[a.shape[1],a.shape[2],a.shape[3]])),{value:a,gradFunc:S}})(v,x,g)}}),r1=(0,d.op)({fusedMatMul_:function({a:e,b:t,transposeA:r=!1,transposeB:n=!1,bias:a,activation:s="linear",preluActivationWeights:i,leakyreluAlpha:d=.2}){let c,f;if(!1===(0,rQ.zE)(l.T2.state.gradientDepth,s)){let l=(0,A.N)(e,t,r,n);return null!=a&&(l=(0,o.W)(l,a)),(0,rQ.f2)(l,s,i,d)}let m=(0,h.YT)(e,"a","fused matMul"),g=(0,h.YT)(t,"b","fused matMul");[m,g]=(0,rM.makeTypesMatch)(m,g);let y=r?m.shape[m.rank-2]:m.shape[m.rank-1],b=n?g.shape[g.rank-1]:g.shape[g.rank-2],x=r?m.shape[m.rank-1]:m.shape[m.rank-2],v=n?g.shape[g.rank-2]:g.shape[g.rank-1],w=m.shape.slice(0,-2),T=g.shape.slice(0,-2),S=p.Ze(w),N=p.Ze(T);p.vA(y===b,()=>`Error in fused matMul: inner shapes (${y}) and (${b}) of Tensors with shapes ${m.shape} and ${g.shape} and transposeA=${r} and transposeB=${n} must match.`);let k=rH.assertAndGetBroadcastShape(m.shape.slice(0,-2),g.shape.slice(0,-2)).c
106oncat([x,v]),C=r?(0,I.t)(m,[S,y,x]):(0,I.t)(m,[S,x,y]),E=n?(0,I.t)(g,[N,v,b]):(0,I.t)(g,[N,b,v]);null!=a&&(c=(0,h.YT)(a,"bias","fused matMul"),[c]=(0,rM.makeTypesMatch)(c,m),rH.assertAndGetBroadcastShape(k,c.shape)),null!=i&&(f=(0,h.YT)(i,"prelu weights","fused matMul"));let $=(e,t)=>{let i,o,[l,u,h,p]=t,d=(0,rQ.XB)((0,I.t)(e,h.shape),h,s);return(r||n?!r&&n?(i=(0,A.N)(d,u,!1,!1),o=(0,A.N)(d,l,!0,!1)):r&&!n?(i=(0,A.N)(u,d,!1,!0),o=(0,A.N)(l,d,!1,!1)):(i=(0,A.N)(u,d,!0,!0),o=(0,A.N)(d,l,!0,!0)):(i=(0,A.N)(d,u,!1,!0),o=(0,A.N)(l,d,!0,!1)),null!=a)?[i,o,(0,rQ.Do)(p,d)]:[i,o]},F={a:C,b:E,bias:c,preluActivationWeights:f},R={transposeA:r,transposeB:n,activation:s,leakyreluAlpha:d};return null==a?(0,rj._X)((e,t,r)=>{let n=l.T2.runKernel(u.Dr,F,R);return r([e,t,n]),{value:(0,I.t)(n,k),gradFunc:$}})(C,E):(0,rj._X)((e,t,r,n)=>{let a=l.T2.runKernel(u.Dr,F,R);return n([e,t,a,r]),{value:(0,I.t)(a,k),gradFunc:$}})(C,E,c)}}),r2=(0,d.op)({hammingWindow_:function(e){return rU(e,.54,.46)}}),r3=(0,d.op)({hannWindow_:function(e){return rU(e,.5,.5)}}),r4=(0,d.op)({frame_:function(e,t,r,n=!1,a=0){let s=0,i=[];for(;s+t<=e.size;)i.push((0,R.d)(e,s,t)),s+=r;if(n)for(;s<e.size;){let n=s+t-e.size,o=(0,E.x)([(0,R.d)(e,s,t-n),(0,eE.G)([n],a)]);i.push(o),s+=r}return 0===i.length?rm([],[0,t]):(0,I.t)((0,E.x)(i),[i.length,t])}}),r5=(0,d.op)({stft_:function(e,t,r,n,a=r3){null==n&&(n=rG(t));let s=r4(e,t,r),i=(0,$.l)(s,a(t));return(0,rr.z)(i,n)}}),r6=(0,d.op)({cropAndResize_:function(e,t,r,n,a="bilinear",s=0){let i=(0,h.YT)(e,"image","cropAndResize"),o=(0,h.YT)(t,"boxes","cropAndResize","float32"),d=(0,h.YT)(r,"boxInd","cropAndResize","int32"),c=o.shape[0];return p.vA(4===i.rank,()=>`Error in cropAndResize: image must be rank 4,but got rank ${i.rank}.`),p.vA(2===o.rank&&4===o.shape[1],()=>`Error in cropAndResize: boxes must be have size [${c},4] but had shape ${o.shape}.`),p.vA(1===d.rank&&d.shape[0]===c,()=>`Error in cropAndResize: boxInd must be have size [${c}] but had shape ${o.shape}.`),p.vA(2===n.length,()=>`Error in cropAndResize: cropSize must be of length 2, but got length ${n.length}.`),p.vA(n[0]>=1&&n[1]>=1,()=>`cropSize must be atleast [1,1], but was ${n}`),p.vA("bilinear"===a||"nearest"===a,()=>`method must be bilinear or nearest, but was ${a}`),l.T2.runKernel(u.MRQ,{image:i,boxes:o,boxInd:d},{method:a,extrapolationValue:s,cropSize:n})}}),r7=(0,d.op)({flipLeftRight_:function(e){let t=(0,h.YT)(e,"image","flipLeftRight","float32");return p.vA(4===t.rank,()=>`Error in flipLeftRight: image must be rank 4,but got rank ${t.rank}.`),l.T2.runKernel(u.BxF,{image:t},{})}}),r9=(0,d.op)({grayscaleToRGB_:function(e){let t=(0,h.YT)(e,"image","grayscaleToRGB"),r=t.rank-1,n=t.shape[r];p.vA(t.rank>=2,()=>`Error in grayscaleToRGB: images must be at least rank 2, but got rank ${t.rank}.`),p.vA(1===n,()=>`Error in grayscaleToRGB: last dimension of a grayscale image should be size 1, but got size ${n}.`);let a=Array(t.rank);return a.fill(1,0,r),a[r]=3,(0,eI.V)(t,a)}}),r8=(0,d.op)({rgbToGrayscale_:function(e){let t,r=(0,h.YT)(e,"image","RGBToGrayscale"),n=r.rank-1,a=r.shape[n];p.vA(r.rank>=2,()=>`Error in RGBToGrayscale: images must be at least rank 2, but got rank ${r.rank}.`),p.vA(3===a,()=>`Error in RGBToGrayscale: last dimension of an RGB image should be size 3, but got size ${a}.`);let s=r.dtype,i=(0,N.w)(r,"float32"),o=rf([.2989,.587,.114]);switch(r.rank){case 2:t=ey("ij,j->i",i,o);break;case 3:t=ey("ijk,k->ij",i,o);break;case 4:t=ey("ijkl,l->ijk",i,o);break;case 5:t=ey("ijklm,m->ijkl",i,o);break;case 6:t=ey("ijklmn,n->ijklm",i,o);break;default:throw Error("Not a valid tensor rank.")}return t=(0,eN.U)(t,-1),(0,N.w)(t,s)}}),ne=(0,d.op)({rotateWithOffset_:function(e,t,r=0,n=.5){let a=(0,h.YT)(e,"image","rotateWithOffset","float32");return p.vA(4===a.rank,()=>`Error in rotateWithOffset: image must be rank 4,but got rank ${a.rank}.`),l.T2.runKernel(u.BK4,{image:a},{radians:t,fillValue:r,center:n})}});function nt(e,t,r,n,a,s){null==n&&(n=.5),null==a&&(a=Number.NEGATIVE_INFINITY),null==s&&(s=0);let i=e.shape[0];return r=Math.min(r,i),p.vA(0<=n&&n<=1,()=>`iouThreshold must be in [0, 1], but was '${n}'`),p.vA(2===e.rank,()=>`boxes must be a 2D tensor, but was of rank '${e.rank}'`),p.vA(4===e.shape[1],()=>`boxes must have 4 columns, but 2nd dimension was ${e.shape[1]}`),p.vA(1===t.rank,()=>"scores must be a 1D tensor"),p.vA(t.shape[0]===i,()=>`scores has incompatible shape with boxes. Expected ${i}, but was ${t.shape[0]}`),p.vA(0<=s&&s<=1,()=>`softNmsSigma must be in [0, 1], but was '${s}'`),{maxOutputSize:r,iouThreshold:n,scoreThreshold:a,softNmsSigma:s}}let nr=(0,d.op)({nonMaxSuppression_:function(e,t,r,n=.5,a=Number.NEGATIVE_INFINITY){let s=(0,h.YT)(e,"boxes","nonMaxSuppression","float32"),i=(0,h.YT)(t,"scores","nonMaxSuppression","float32"),o=nt(s,i,r,n,a);r=o.maxOutputSize;let p={maxOutputSize:r,iouThreshold:n=o.iouThreshold,scoreThreshold:a=o.scoreThreshold};return l.T2.runKernel(u.SDM,{boxes:s,scores:i},p)}});var nn=r(10627);async function na(e,t,r,n=.5,a=Number.NEGATIVE_INFINITY){let s=(0,h.YT)(e,"boxes","nonMaxSuppressionAsync"),i=(0,h.YT)(t,"scores","nonMaxSuppressionAsync"),o=nt(s,i,r,n,a);r=o.maxOutputSize,n=o.iouThreshold,a=o.scoreThreshold;let l=await Promise.all([s.data(),i.data()]),u=l[0],p=l[1],{selectedIndices:d}=(0,nn.c7)(u,p,r,n,a);return s!==e&&s.dispose(),i!==t&&i.dispose(),rf(d,"int32")}let ns=(0,d.op)({nonMaxSuppressionWithScore_:function(e,t,r,n=.5,a=Number.NEGATIVE_INFINITY,s=0){let i=(0,h.YT)(e,"boxes","nonMaxSuppression"),o=(0,h.YT)(t,"scores","nonMaxSuppression"),p=nt(i,o,r,n,a,s);r=p.maxOutputSize,n=p.iouThreshold,a=p.scoreThreshold;let d={maxOutputSize:r,iouThreshold:n,scoreThreshold:a,softNmsSigma:s=p.softNmsSigma},c=l.T2.runKernel(u.e0f,{boxes:i,scores:o},d);return{selectedIndices:c[0],selectedScores:c[1]}}});async function ni(e,t,r,n=.5,a=Number.NEGATIVE_INFINITY,s=0){let i=(0,h.YT)(e,"boxes","nonMaxSuppressionAsync"),o=(0,h.YT)(t,"scores","nonMaxSuppressionAsync"),l=nt(i,o,r,n,a,s);r=l.maxOutputSize,n=l.iouThreshold,a=l.scoreThreshold,s=l.softNmsSigma;let u=await Promise.all([i.data(),o.data()]),p=u[0],d=u[1],{selectedIndices:c,selectedScores:f}=(0,nn.ut)(p,d,r,n,a,s);return i!==e&&i.dispose(),o!==t&&o.dispose(),{selectedIndices:rf(c,"int32"),selectedScores:rf(f)}}let no=(0,d.op)({nonMaxSuppressionPadded_:function(e,t,r,n=.5,a=Number.NEGATIVE_INFINITY,s=!1){let i=(0,h.YT)(e,"boxes","nonMaxSuppression"),o=(0,h.YT)(t,"scores","nonMaxSuppression"),p=nt(i,o,r,n,a,null),d=p.maxOutputSize,c=p.iouThreshold,f=p.scoreThreshold,m=l.T2.runKernel(u.Zl4,{boxes:i,scores:o},{maxOutputSize:d,iouThreshold:c,scoreThreshold:f,padToMaxOutputSize:s});return{selectedIndices:m[0],validOutputs:m[1]}}});async function nl(e,t,r,n=.5,a=Number.NEGATIVE_INFINITY,s=!1){let i=(0,h.YT)(e,"boxes","nonMaxSuppressionAsync"),o=(0,h.YT)(t,"scores","nonMaxSuppressionAsync"),l=nt(i,o,r,n,a,null),u=l.maxOutputSize,p=l.iouThreshold,d=l.scoreThreshold,[c,f]=await Promise.all([i.data(),o.data()]),{selectedIndices:m,validOutputs:g}=(0,nn.ZS)(c,f,u,p,d,s);return i!==e&&i.dispose(),o!==t&&o.dispose(),{selectedIndices:rf(m,"int32"),validOutputs:(0,tY.d)(g,"int32")}}var nu=r(39758),nh=r(48163);let np=(0,d.op)({threshold_:function(e,t="binary",r=!1,n=.5){let a,s,i,l,u=(0,h.YT)(e,"image","threshold"),d=u.shape[0]*u.shape[1],c=(0,$.l)(rf([n]),255);if(p.vA(3===u.rank,()=>`Error in threshold: image must be rank 3,but got rank ${u.rank}.`),p.vA(3===u.shape[2]||1===u.shape[2],()=>`Error in threshold: image color channel must be equal to 3 or 1but got ${u.shape[2]}.`),p.vA("int32"===u.dtype||"float32"===u.dtype,()=>`Error in dtype: image dtype must be int32 or float32,but got dtype ${u.dtype}.`),p.vA("otsu"===t||"binary"===t,()=>`Method must be binary or otsu, but was ${t}`),3===u.shape[2]){[a,s,i]=(0,rn.l)(u,[1,1,1],-1);let e=(0,$.l)(a,.2989),t=(0,$.l)(s,.587),r=(0,$.l)(i,.114);l=(0,o.W)((0,o.W)(e,t),r)}else l=e;"otsu"===t&&(c=function(e,t){let r,n,a,s,i,l,u=rf([-1]),h=rf([0]),p=rf([0]);for(let d=0;d<e.size-1;d++){r=(0,R.d)(e,0,d+1),n=(0,R.d)(e,d+1),i=(0,ef.y)((0,rh.c)(r),t),l=(0,ef.y)((0,rh.c)(n),t);let c=(0,rh.c)((0,$.l)(r,tM(0,r.size)));a=(0,ef.y)(c,(0,rh.c)(r));let f=(0,eE.G)(n.shape,r.size),m=(0,o.W)(tM(0,n.size),f),g=(0,$.l)(n,m);s=(0,ef.y)((0,rh.c)(g),(0,rh.c)(n));let y=(0,ts.j)(a,s),b=(0,ts.j)(a,s),x=(0,$.l)(i,l);p=(0,$.l)((0,$.l)(x,y),b);let v=(0,eR.r)(p,h);h=(0,rA._)(v,p,h),u=(0,rA._)(v,rf([d]),u)}return u}(B((0,N.w)((0,tH.L)(l),"int32"),(0,rd.O)([]),256),d));let f=r?(0,eB.I)(l,c):(0,eR.r)(l,c);return(0,N.w)((0,$.l)(f,255),"int32")}}),nd=(0,d.op)({transform_:function(e,t,r="nearest",n="constant",a=0,s){let i=(0,h.YT)(e,"image","transform","float32"),o=(0,h.YT)(t,"transforms","transform","float32");return p.vA(4===i.rank,()=>`Error in transform: image must be rank 4,but got rank ${i.rank}
106.`),p.vA(2===o.rank&&(o.shape[0]===i.shape[0]||1===o.shape[0])&&8===o.shape[1],()=>"Error in transform: Input transform should be batch x 8 or 1 x 8"),p.vA(null==s||2===s.length,()=>`Error in transform: outputShape must be [height, width] or null, but got ${s}.`),l.T2.runKernel(u.dLy,{image:i,transforms:o},{interpolation:r,fillMode:n,fillValue:a,outputShape:s})}}),nc=(0,d.op)({bandPart_:function(e,t,r){let n,a,s=(0,h.YT)(e,"a","bandPart");(0,p.vA)(s.rank>=2,()=>`bandPart(): Rank must be at least 2, got ${s.rank}.`);let i=s.shape,[o,l]=s.shape.slice(-2);"number"==typeof t?((0,p.vA)(t%1==0,()=>`bandPart(): numLower must be an integer, got ${t}.`),(0,p.vA)(t<=o,()=>`bandPart(): numLower (${t}) must not be greater than the number of rows (${o}).`),n=(0,h.YT)(t<0?o:t,"numLower","bandPart")):((0,p.vA)("int32"===t.dtype,()=>"bandPart(): numLower's dtype must be an int32."),n=(0,rA._)((0,ez.M)(t,0),o,(0,te.B)(t,o))),"number"==typeof r?((0,p.vA)(r%1==0,()=>`bandPart(): numUpper must be an integer, got ${r}.`),(0,p.vA)(r<=l,()=>`bandPart(): numUpper (${r}) must not be greater than the number of columns (${l}).`),a=(0,h.YT)(r<0?l:r,"numUpper","bandPart")):((0,p.vA)("int32"===r.dtype,()=>"bandPart(): numUpper's dtype must be an int32."),a=(0,rA._)((0,ez.M)(r,0),l,(0,te.B)(r,l)));let u=(0,I.t)(tM(0,o,1,"int32"),[-1,1]),d=tM(0,l,1,"int32"),c=(0,ts.j)(u,d),f=(0,eK.n)((0,eB.I)(c,n),(0,e_.D)(c,(0,tu.H)(a))),m=(0,rR.U)([o,l],s.dtype);return(0,I.t)((0,ro.t)((0,rI.K)((0,I.t)(s,[-1,o,l])).map(e=>(0,rA._)(f,e,m))),i)}}),nf=(0,d.op)({gramSchmidt_:function(e){let t;if(Array.isArray(e)){t=!1,(0,p.vA)(null!=e&&e.length>0,()=>"Gram-Schmidt process: input must not be null, undefined, or empty");let r=e[0].shape[0];for(let t=1;t<e.length;++t)(0,p.vA)(e[t].shape[0]===r,()=>`Gram-Schmidt: Non-unique lengths found in the input vectors: (${e[t].shape[0]} vs. ${r})`)}else t=!0,e=(0,rn.l)(e,e.shape[0],0).map(e=>(0,ri.r)(e,[0]));(0,p.vA)(e.length<=e[0].shape[0],()=>`Gram-Schmidt: Number of vectors (${e.length}) exceeds number of dimensions (${e[0].shape[0]}).`);let r=[],n=e;for(let t=0;t<e.length;++t)r.push(l.T2.tidy(()=>{let e=n[t];if(t>0)for(let n=0;n<t;++n){let t=(0,$.l)((0,rh.c)((0,$.l)(r[n],e)),r[n]);e=(0,ts.j)(e,t)}return(0,ef.y)(e,(0,rL.x)(e,"euclidean"))}));return t?(0,ro.t)(r,0):r}});var nm=r(14958);function ng(e,t=!1){return l.T2.tidy(()=>{(0,p.vA)(2===e.shape.length,()=>`qr2d() requires a 2D Tensor, but got a ${e.shape.length}D Tensor.`);let r=e.shape[0],n=e.shape[1],a=eC(r),s=(0,H.o)(e),i=rm([[1]],[1,1]),o=(0,H.o)(i),u=r>=n?n:r;for(let e=0;e<u;++e){let t=s,u=o,h=a;[o,s,a]=l.T2.tidy(()=>{let t=(0,R.d)(s,[e,e],[r-e,1]),l=(0,rL.x)(t),u=(0,R.d)(s,[e,e],[1,1]),h=(0,rA._)((0,eR.r)(u,0),rm([[-1]]),rm([[1]])),p=(0,ts.j)(u,(0,$.l)(h,l)),d=(0,ef.y)(t,p);o=1===d.shape[0]?(0,H.o)(i):(0,E.x)([i,(0,R.d)(d,[1,0],[d.shape[0]-1,d.shape[1]])],0);let c=(0,tu.H)((0,ef.y)((0,A.N)(h,p),l)),f=(0,R.d)(s,[e,0],[r-e,n]),m=(0,$.l)(c,o),g=(0,rO.m)(o);if(0===e)s=(0,ts.j)(f,(0,A.N)(m,(0,A.N)(g,f)));else{let t=(0,ts.j)(f,(0,A.N)(m,(0,A.N)(g,f)));s=(0,E.x)([(0,R.d)(s,[0,0],[e,n]),t],0)}let y=(0,rO.m)(m),b=(0,R.d)(a,[0,e],[r,a.shape[1]-e]);if(0===e)a=(0,ts.j)(b,(0,A.N)((0,A.N)(b,o),y));else{let t=(0,ts.j)(b,(0,A.N)((0,A.N)(b,o),y));a=(0,E.x)([(0,R.d)(a,[0,0],[r,e]),t],1)}return[o,s,a]}),(0,nm.AS)([t,u,h])}return!t&&r>n&&(a=(0,R.d)(a,[0,0],[r,n]),s=(0,R.d)(s,[0,0],[n,n])),[a,s]})}let ny=(0,d.op)({qr_:function(e,t=!1){if((0,p.vA)(e.rank>=2,()=>`qr() requires input tensor to have a rank >= 2, but got rank ${e.rank}`),2===e.rank)return ng(e,t);{let r=e.shape.slice(0,e.shape.length-2).reduce((e,t)=>e*t),n=(0,rI.K)((0,I.t)(e,[r,e.shape[e.shape.length-2],e.shape[e.shape.length-1]]),0),a=[],s=[];return n.forEach(e=>{let[r,n]=ng(e,t);a.push(r),s.push(n)}),[(0,I.t)((0,ro.t)(a,0),e.shape),(0,I.t)((0,ro.t)(s,0),e.shape)]}}});var nb=r(99882);let nx=(0,d.op)({computeWeightedLoss_:function(e,t,r=nb.i.SUM_BY_NONZERO_WEIGHTS){let n=(0,h.YT)(e,"losses","computeWeightedLoss"),a=null;null!=t&&(a=(0,h.YT)(t,"weights","computeWeightedLoss"));let s=null==a?n:(0,$.l)(n,a);if(r===nb.i.NONE)return s;if(r===nb.i.SUM)return(0,rh.c)(s);if(r===nb.i.MEAN)if(null==a)return(0,e5.i)(s);else{let e=n.size/a.size,t=(0,ef.y)((0,rh.c)(s),(0,rh.c)(a));return e>1?(0,ef.y)(t,(0,tY.d)(e)):t}if(r===nb.i.SUM_BY_NONZERO_WEIGHTS)if(null==a)return(0,ef.y)((0,rh.c)(s),(0,tY.d)(n.size));else{let e=(0,$.l)(a,(0,e6.S)(n.shape)),t=(0,N.w)((0,rh.c)((0,th.E)(e,(0,tY.d)(0))),"float32");return(0,ef.y)((0,rh.c)(s),t)}throw Error(`Unknown reduction: ${r}`)}}),nv=(0,d.op)({absoluteDifference_:function(e,t,r,n=nb.i.SUM_BY_NONZERO_WEIGHTS){let s=(0,h.YT)(e,"labels","absoluteDifference"),i=(0,h.YT)(t,"predictions","absoluteDifference"),o=null;return null!=r&&(o=(0,h.YT)(r,"weights","absoluteDifference")),(0,p.O3)(s.shape,i.shape,"Error in absoluteDifference: "),nx((0,a.t)((0,ts.j)(s,i)),o,n)}}),nw=(0,d.op)({cosineDistance_:function(e,t,r,n,a=nb.i.SUM_BY_NONZERO_WEIGHTS){let s=(0,h.YT)(e,"labels","cosineDistance"),i=(0,h.YT)(t,"predictions","cosineDistance"),o=null;null!=n&&(o=(0,h.YT)(n,"weights","cosineDistance")),(0,p.O3)(s.shape,i.shape,"Error in cosineDistance: ");let l=(0,tY.d)(1);return nx((0,ts.j)(l,(0,rh.c)((0,$.l)(s,i),r,!0)),o,a)}}),nT=(0,d.op)({hingeLoss_:function(e,t,r,n=nb.i.SUM_BY_NONZERO_WEIGHTS){let a=(0,h.YT)(e,"labels","hingeLoss"),s=(0,h.YT)(t,"predictions","hingeLoss"),i=null;null!=r&&(i=(0,h.YT)(r,"weights","hingeLoss")),(0,p.O3)(a.shape,s.shape,"Error in hingeLoss: ");let o=(0,tY.d)(1);return a=(0,ts.j)((0,$.l)((0,tY.d)(2),a),o),nx((0,tB.V)((0,ts.j)(o,(0,$.l)(a,s))),i,n)}}),nS=(0,d.op)({huberLoss_:function(e,t,r,n=1,s=nb.i.SUM_BY_NONZERO_WEIGHTS){let i=(0,h.YT)(e,"labels","huberLoss"),l=(0,h.YT)(t,"predictions","huberLoss"),u=null;null!=r&&(u=(0,h.YT)(r,"weights","huberLoss")),(0,p.O3)(i.shape,l.shape,"Error in huberLoss: ");let d=(0,tY.d)(n),c=(0,a.t)((0,ts.j)(l,i)),f=(0,te.B)(c,d),m=(0,ts.j)(c,f);return nx((0,o.W)((0,$.l)((0,tY.d)(.5),(0,ta.E)(f)),(0,$.l)(d,m)),u,s)}}),nN=(0,d.op)({logLoss_:function(e,t,r,n=1e-7,a=nb.i.SUM_BY_NONZERO_WEIGHTS){let s=(0,h.YT)(e,"labels","logLoss"),i=(0,h.YT)(t,"predictions","logLoss"),l=null;null!=r&&(l=(0,h.YT)(r,"weights","logLoss")),(0,p.O3)(s.shape,i.shape,"Error in logLoss: ");let u=(0,tY.d)(1),d=(0,tY.d)(n),c=(0,tu.H)((0,$.l)(s,(0,eG.R)((0,o.W)(i,d)))),f=(0,$.l)((0,ts.j)(u,s),(0,eG.R)((0,o.W)((0,ts.j)(u,i),d)));return nx((0,ts.j)(c,f),l,a)}}),nk=(0,d.op)({meanSquaredError_:function(e,t,r,n=nb.i.SUM_BY_NONZERO_WEIGHTS){let a=(0,h.YT)(e,"labels","meanSquaredError"),s=(0,h.YT)(t,"predictions","meanSquaredError"),i=null;return null!=r&&(i=(0,h.YT)(r,"weights","meanSquaredError")),(0,p.O3)(a.shape,s.shape,"Error in meanSquaredError: "),nx((0,rs.P)(a,s),i,n)}}),nI=(0,d.op)({sigmoidCrossEntropy_:function(e,t,r,n=0,s=nb.i.SUM_BY_NONZERO_WEIGHTS){let i=(0,h.YT)(e,"multiClassLabels","sigmoidCrossEntropy"),l=(0,h.YT)(t,"logits","sigmoidCrossEntropy"),u=null;if(null!=r&&(u=(0,h.YT)(r,"weights","sigmoidCrossEntropy")),(0,p.O3)(i.shape,l.shape,"Error in sigmoidCrossEntropy: "),n>0){let e=(0,tY.d)(n),t=(0,tY.d)(1),r=(0,tY.d)(.5);i=(0,o.W)((0,$.l)(i,(0,ts.j)(t,e)),(0,$.l)(r,e))}return nx(function(e,t){let r=(0,h.YT)(e,"labels","sigmoidCrossEntropyWithLogits"),n=(0,h.YT)(t,"logits","sigmoidCrossEntropyWithLogits");(0,p.O3)(r.shape,n.shape,"Error in sigmoidCrossEntropyWithLogits: ");let s=(0,tB.V)(n),i=(0,$.l)(n,r),l=(0,eU.K)((0,eS.o)((0,tu.H)((0,a.t)(n))
106));return(0,o.W)((0,ts.j)(s,i),l)}(i,l),u,s)}}),nC=(0,d.op)({softmaxCrossEntropy_:function(e,t,r,n=0,a=nb.i.SUM_BY_NONZERO_WEIGHTS){let s=(0,h.YT)(e,"onehotLabels","softmaxCrossEntropy"),i=(0,h.YT)(t,"logits","softmaxCrossEntropy"),l=null;if(null!=r&&(l=(0,h.YT)(r,"weights","softmaxCrossEntropy")),(0,p.O3)(s.shape,i.shape,"Error in softmaxCrossEntropy: "),n>0){let e=(0,tY.d)(n),t=(0,tY.d)(1),r=(0,tY.d)(s.shape[1]);s=(0,o.W)((0,$.l)(s,(0,ts.j)(t,e)),(0,ef.y)(e,r))}return nx(function(e,t,r=-1){if(-1===r&&(r=t.rank-1),r!==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 ${r}`);return(0,rj._X)((e,t,n)=>{let a=(0,eH.V)(t,[r],!0),s=(0,ts.j)((0,N.w)(t,"float32"),a);n([e,s]);let i=(0,tu.H)((0,$.l)(s,e));return{value:(0,rh.c)(i,[r]),gradFunc:(e,t)=>{let[n,a]=t,s=(0,tn.SM)(e.shape,[r]);return[(0,$.l)((0,I.t)(e,s),(0,ts.j)((0,N.w)(n,"float32"),(0,eS.o)(a))),(0,$.l)((0,I.t)(e,s),(0,ts.j)((0,eS.o)(a),(0,N.w)(n,"float32")))]}}})(e,t)}(s,i),l,a)}}),nE=(0,d.op)({sparseFillEmptyRows_:function(e,t,r,n){let a=(0,h.YT)(e,"indices","sparseFillEmptyRows","int32"),s=(0,h.YT)(t,"values","sparseFillEmptyRows"),i=(0,h.YT)(r,"denseShape","sparseFillEmptyRows","int32"),o=(0,h.YT)(n,"defaultValue","sparseFillEmptyRows",s.dtype);if(2!==a.rank)throw Error(`Indices should be Tensor2D but received shape 107 ${a.shape}`);if(1!==s.rank)throw Error(`Values should be Tensor1D but received shape ${s.shape}`);if(1!==i.rank)throw Error(`Dense shape should be Tensor1D but received shape ${i.shape}`);if(0!==o.rank)throw Error(`Default value should be a scalar but received shape ${o.shape}`);let p=l.T2.runKernel(u.C8s,{indices:a,values:s,denseShape:i,defaultValue:o});return{outputIndices:p[0],outputValues:p[1],emptyRowIndicator:p[2],reverseIndexMap:p[3]}}}),nA=(0,d.op)({sparseReshape_:function(e,t,r){let n=(0,h.YT)(e,"inputIndices","sparseReshape","int32"),a=(0,h.YT)(t,"inputShape","sparseReshape","int32"),s=(0,h.YT)(r,"newShape","sparseReshape","int32");if(2!==n.rank)throw Error(`Input indices should be Tensor2D but received shape 108 ${n.shape}`);if(1!==a.rank)throw Error(`Input shape should be Tensor1D but received shape ${a.shape}`);if(1!==s.rank)throw Error(`New shape should be Tensor1D but received shape ${s.shape}`);let i=l.T2.runKernel(u.BoJ,{inputIndices:n,inputShape:a,newShape:s});return{outputIndices:i[0],outputShape:i[1]}}}),n$=(0,d.op)({sparseSegmentMean_:function(e,t,r){let n=(0,h.YT)(e,"data","sparseSegmentMean"),a=(0,h.YT)(t,"indices","sparseSegmentMean","int32"),s=(0,h.YT)(r,"segmentIds","sparseSegmentMean","int32");if(n.rank<1)throw Error("Data should be at least 1 dimensional but received scalar");if(1!==a.rank)throw Error(`Indices should be Tensor1D but received shape 109 ${a.shape}`);if(1!==s.rank)throw Error(`Segment ids should be Tensor1D but received shape 110 ${s.shape}`);return l.T2.runKernel(u.L6G,{data:n,indices:a,segmentIds:s})}}),nF=(0,d.op)({sparseSegmentSum_:function(e,t,r){let n=(0,h.YT)(e,"data","sparseSegmentSum"),a=(0,h.YT)(t,"indices","sparseSegmentSum","int32"),s=(0,h.YT)(r,"segmentIds","sparseSegmentSum","int32");if(n.rank<1)throw Error("Data should be at least 1 dimensional but received scalar");if(1!==a.rank)throw Error(`Indices should be Tensor1D but received shape 111 ${a.shape}`);if(1!==s.rank)throw Error(`Segment ids should be Tensor1D but received shape 112 ${s.shape}`);return l.T2.runKernel(u.DvZ,{data:n,indices:a,segmentIds:s})}}),nR=(0,d.op)({stringNGrams_:function(e,t,r,n,a,s,i,o){let p=(0,h.YT)(e,"data","stringNGrams","string");if("string"!==p.dtype)throw Error("Data must be of datatype string");if(1!==p.shape.length)throw Error(`Data must be a vector, saw: ${p.shape}`);let d=(0,h.YT)(t,"dataSplits","stringNGrams");if("int32"!==d.dtype)throw Error("Data splits must be of datatype int32");let c=l.T2.runKernel(u.YAb,{data:p,dataSplits:d},{separator:r,nGramWidths:n,leftPad:a,rightPad:s,padWidth:i,preserveShortSequences:o});return{nGrams:c[0],nGramsSplits:c[1]}}}),n_=(0,d.op)({stringSplit_:function(e,t,r=!0){let n=(0,h.YT)(e,"input","stringSplit","string"),a=(0,h.YT)(t,"delimiter","stringSplit","string");if(1!==n.rank)throw Error(`Input should be Tensor1D but received shape ${n.shape}`);if(0!==a.rank)throw Error(`Delimiter should be a scalar but received shape ${a.shape}`);let s=l.T2.runKernel(u.iW0,{input:n,delimiter:a},{skipEmpty:r});return{indices:s[0],values:s[1],shape:s[2]}}}),nD=(0,d.op)({stringToHashBucketFast_:function(e,t){let r=(0,h.YT)(e,"input","stringToHashBucketFast","string");if(t<=0)throw Error("Number of buckets must be at least 1");return l.T2.runKernel(u.$jE,{input:r},{numBuckets:t})}}),nO=(0,d.op)({staticRegexReplace_:function(e,t,r,n=!0){let a=(0,h.YT)(e,"input","staticRegexReplace","string");return l.T2.runKernel(u.GZp,{x:a},{pattern:t,rewrite:r,replaceGlobal:n})}}),nL={fft:t8.h,ifft:re.K,rfft:rr.z,irfft:rt.g},nM={hammingWindow:r2,hannWindow:r3,frame:r4,stft:r5},nP={flipLeftRight:r7,grayscaleToRGB:r9,resizeNearestNeighbor:nh.b,resizeBilinear:nu.v,rgbToGrayscale:r8,rotateWithOffset:ne,cropAndResize:r6,nonMaxSuppression:nr,nonMaxSuppressionAsync:na,nonMaxSuppressionWithScore:ns,nonMaxSuppressionWithScoreAsync:ni,nonMaxSuppressionPadded:no,nonMaxSuppressionPaddedAsync:nl,threshold:np,transform:nd},nz={bandPart:nc,gramSchmidt:nf,qr:ny},nB={absoluteDifference:nv,computeWeightedLoss:nx,cosineDistance:nw,hingeLoss:nT,huberLoss:nS,logLoss:nN,meanSquaredError:nk,sigmoidCrossEntropy:nI,softmaxCrossEntropy:nC},nW={sparseFillEmptyRows:nE,sparseReshape:nA,sparseSegmentMean:n$,sparseSegmentSum:nF},nV={stringNGrams:nR,stringSplit:n_,stringToHashBucketFast:nD,staticRegexReplace:nO}},51520:(e,t,r)=>{"use strict";let n,a,s;r.d(t,{ljI:()=>tn.ljI,Vvy:()=>tn.Vvy,PH8:()=>tn.PH8,K$F:()=>eC,ah4:()=>eA,FYc:()=>eR,oC7:()=>eO,OMN:()=>tn.OMN,EkD:()=>tn.EkD,u8Z:()=>tn.u8Z,FSt:()=>tn.FSt,Jp_:()=>tn.Jp_,p_m:()=>tn.p_m,QKF:()=>tn.QKF,epO:()=>tn.epO,TyE:()=>tn.TyE,lxb:()=>tn.lxb,zP9:()=>tn.zP9,ho8:()=>tn.ho8,cS:()=>tn.cS,wwC:()=>tn.wwC,VCH:()=>tn.VCH,jAQ:()=>tn.jAQ,Ik2:()=>tn.Ik2,N4F:()=>tn.N4F,HNs:()=>tn.HNs,vj7:()=>tn.vj7,LB5:()=>tn.LB5,KXH:()=>tn.KXH,QDP:()=>tn.QDP,vaV:()=>tn.vaV,pr3:()=>tn.pr3,$zE:()=>tn.$zE,$dB:()=>tn.$dB,p2J:()=>tn.p2J,rFm:()=>tn.rFm,jfg:()=>tn.jfg,A1h:()=>tn.A1h,iGz:()=>tn.iGz,gC7:()=>tn.gC7,Mn0:()=>tn.Mn0,MnK:()=>tn.MnK,MRQ:()=>tn.MRQ,jj_:()=>tn.jj_,nY8:()=>tn.nY8,GJx:()=>r_.GJ,wNW:()=>tn.wNW,TMz:()=>tn.TMz,tGH:()=>tn.tGH,X$8:()=>tn.X$8,nVu:()=>tn.nVu,ORI:()=>tn.ORI,jxD:()=>tn.jxD,pk0:()=>tn.pk0,bP9:()=>tn.bP9,XmO:()=>tn.XmO,Kmu:()=>w.Km,Qgm:()=>tn.Qgm,Pah:()=>tn.Pah,rsH:()=>tn.rsH,OH$:()=>w.OH,BRl:()=>tn.BRl,_s9:()=>tn._s9,ox3:()=>tn.ox3,ybN:()=>tn.ybN,ybj:()=>tn.ybj,rGP:()=>tn.rGP,SQl:()=>tn.SQl,BxF:()=>tn.BxF,ZgB:()=>tn.ZgB,ElG:()=>tn.ElG,awo:()=>tn.awo,i5R:()=>tn.i5R,aAr:()=>tn.aAr,T7M:()=>tn.T7M,O4G:()=>tn.O4G,mxL:()=>tn.mxL,XhZ:()=>tn.XhZ,lLS:()=>tn.lLS,OAQ:()=>tn.OAQ,lzr:()=>tn.lzr,dv8:()=>tn.dv8,gIW:()=>tn.gIW,E3$:()=>tn.E3$,iPs:()=>tn.iPs,uI_:()=>r_.uI,jM4:()=>tn.jM4,ToN:()=>tn.ToN,X0$:()=>tn.X0$,mIA:()=>tn.mIA,CwD:()=>tn.CwD,mnI:()=>tn.mnI,tG8:()=>tn.tG8,Cg$:()=>tn.Cg$,zfU:()=>tn.zfU,RUm:()=>tn.RUm,nZd:()=>tn.nZd,LXA:()=>tn.LXA,RW8:()=>tn.RW8,yPW:()=>tn.yPW,WRv:()=>tn.WRv,VAI:()=>tn.VAI,t3d:()=>tn.t3d,ySp:()=>tn.ySp,cHb:()=>tn.cHb,RXX:()=>tn.RXX,TL8:()=>tn.TL8,LDN:()=>tn.LDN,g5A:()=>tn.g5A,lNG:()=>tn.lNG,LG0:()=>tn.LG0,x7F:()=>tn.x7F,BLA:()=>tn.BLA,Qu_:()=>eM,WT3:()=>tn.WT3,xu7:()=>tn.xu7,l0G:()=>tn.l0G,SDM:()=>tn.SDM,Zl4:()=>tn.Zl4,e0f:()=>tn.e0f,ylV:()=>tn.ylV,BTT:()=>t_.BTT,urI:()=>tn.urI,LWX:()=>tn.LWX,ELo:()=>eI,L5p:()=>tF,mM$:()=>tn.mM$,ODT:()=>tn.ODT,bCz:()=>tn.bCz,pyJ:()=>tn.pyJ,Ncv:()=>tn.Ncv,kdj:()=>tn.kdj,PS5:()=>eP,oJ2:()=>tn.oJ2,CQC:()=>tn.CQC,mH5:()=>tn.mH5,Q6t:()=>tn.Q6t,rgM:()=>tR.rg,LRy:()=>tn.LRy,sDr:()=>tn.sDr,huO:()=>tn.huO,iDl:()=>tD.i,fUj:()=>tn.fUj,P_L:()=>tn.P_L,R23:()=>tn.R23,hgw:()=>tn.hgw,FCQ:()=>tn.FCQ,jOE:()=>tn.jOE,XQy:()=>tn.XQy,D7i:()=>tn.D7i,BK4:()=>tn.BK4,hVg:()=>tn.hVg,TOR:()=>tn.TOR,SYI:()=>eL,pJc:()=>tn.pJc,uWl:()=>tn.uWl,l6P:()=>tn.l6P,u$b:()=>tn.u$b,vI1:()=>tn.vI1,YVe:()=>tn.YVe,hql:()=>tn.hql,J3C:()=>tn.J3C,JiE:()=>tn.JiE,rFG:()=>tn.rFG,Fin:()=>tn.Fin,A8B:()=>tn.A8B,C8s:()=>tn.C8s,BoJ:()=>tn.BoJ,L6G:()=>tn.L6G,DvZ:()=>tn.DvZ,jgd:()=>tn.jgd,Blb:()=>tn.Blb,dFH:()=>tn.dFH,M6A:()=>tn.M6A,Ddj:()=>tn.Ddj,GZp:()=>tn.GZp,pnw:()=>tn.pnw,UcO:()=>tn.UcO,YAb:()=>tn.YAb,iW0:()=>tn.iW0,$jE:()=>tn.$jE,PbM:()=>tn.PbM,WuN:()=>tn.WuN,oFs:()=>tn.oFs,iuW:()=>tn.iuW,qYS:()=>eu.qY,ylz:()=>eu.yl,X4r:()=>tn.X4r,FAs:()=>tn.FAs,TBb:()=>tn.TBb,dLy:()=>tn.dLy,wx0:()=>tn.wx0,EwU:()=>tn.EwU,dXR:()=>tn.dXR,pPe:()=>tn.pPe,RMm:()=>tn.RMm,rTt:()=>eu.rT,xJ3:()=>tn.xJ3,Dr:()=>tn.Dr,tnl:()=>t_.tnl,HQu:()=>t_.HQu,FqL:()=>t_.FqL,WQq:()=>t_.WQq,QiD:()=>t_.QiD,Q7R:()=>t_.Q7R,bzn:()=>t_.bzn,FLi:()=>t_.FLi,XRg:()=>t_.XRg,qRo:()=>t_.qRo,yHs:()=>t_.yHs,rYl:()=>t_.rYl,FPz:()=>t_.FPz,rfv:()=>t_.rfv,$jT:()=>t_.$jT,sub:()=>t_.sub,Hs:()=>ep.Hs,C0T:()=>m,lZX:()=>t_.lZX,$v7:()=>t_.$v7,BFc:()=>t_.BFc,kSi:()=>t_.kSi,T5N:()=>t_.T5N,GTe:()=>t_.GTe,HbZ:()=>t_.HbZ,vjT:()=>t_.vjT,ftb:()=>t_.ftb,ROE:()=>t_.ROE,hOW:()=>t_.hOW,ZEY:()=>tr,TaL:()=>p,ra8:()=>t_.ra8,wgE:()=>t_.wgE,mkO:()=>t_.mkO,zQh:()=>t_.zQh,o8B:()=>t_.o8B,faB:()=>t_.faB,xWs:()=>t_.xWs,I1m:()=>t_.I1m,RPU:()=>t_.RPU,O5O:()=>t_.O5O,P1l:()=>t_.P1l,kA9:()=>t_.kA9,Xtf:()=>t_.Xtf,wX9:()=>t_.wX9,IPL:()=>t_.IPL,jIJ:()=>t_.jIJ,Cfv:()=>ta.Cf,gnS:()=>t_.gnS,yIG:()=>t_.yIG,_jP:()=>t_._jP,Lp0:()=>t_.Lp0,rCv:()=>t_.rCv,_Xg:()=>
112eb._X,aOp:()=>t_.aOp,fLc:()=>ep.fL,Rj8:()=>t_.Rj8,Gl3:()=>t_.Gl3,eMq:()=>o,smy:()=>t_.smy,X7t:()=>t_.X7t,ISJ:()=>ep.IS,ASo:()=>ep.AS,rm6:()=>ep.rm,y4m:()=>t_.y4m,ek5:()=>t_.ek5,Omf:()=>t_.Omf,EZY:()=>t_.EZY,_3C:()=>t_._3C,Pqc:()=>t_.Pqc,gYU:()=>ep.gY,SmG:()=>ep.Sm,FJY:()=>t_.FJY,Hi9:()=>ep.Hi,QP2:()=>t_.QP2,_K2:()=>w._K,LCg:()=>t_.LCg,Y12:()=>t_.Y12,p4S:()=>t_.p4S,oNF:()=>t_.oNF,UG6:()=>t_.UG6,IYd:()=>t_.IYd,y5U:()=>t_.y5U,hVP:()=>t_.hVP,GSj:()=>t_.GSj,goy:()=>ep.go,W4C:()=>ep.W4,RIf:()=>t_.RIf,wh_:()=>t_.wh_,cZk:()=>t_.cZk,kgh:()=>t_.kgh,SY9:()=>t_.SY9,FJy:()=>d,jz4:()=>ep.jz,vQR:()=>ta.vQ,_5H:()=>ta._5,OpK:()=>ta.Op,Dvk:()=>eb.Dv,ok9:()=>eb.ok,rhj:()=>t_.rhj,DQN:()=>t_.DQN,KGM:()=>t_.KGM,ngS:()=>t_.ngS,Slp:()=>t_.Slp,U4u:()=>t_.U4u,io:()=>u,ggX:()=>t_.ggX,MIs:()=>t_.MIs,EN4:()=>t_.EN4,yrW:()=>t_.yrW,aCs:()=>ep.aC,kpo:()=>g,H8d:()=>t_.H8d,M7h:()=>t_.M7h,InN:()=>t_.InN,mPL:()=>t_.mPL,mT8:()=>t_.mT8,Kgs:()=>t_.Kgs,Rm2:()=>t_.Rm2,Kko:()=>t_.Kko,nqI:()=>t_.nqI,HPB:()=>t_.HPB,VZ:()=>t_.VZ,n76:()=>t_.n76,NSZ:()=>t_.NSZ,ztW:()=>t_.ztW,rxB:()=>t_.rxB,YYh:()=>t_.YYh,yzS:()=>t_.yzS,NoW:()=>t_.NoW,DyF:()=>h,T9B:()=>t_.T9B,jgi:()=>t_.jgi,NYV:()=>t_.NYV,RO:()=>t_.RO,PhQ:()=>t_.PhQ,i2o:()=>t_.i2o,m1Z:()=>ep.m1,OYQ:()=>t_.OYQ,jkA:()=>t_.jkA,BpO:()=>t_.BpO,FFZ:()=>t_.FFZ,ziu:()=>t_.ziu,Clk:()=>t_.Clk,CRk:()=>t_.CRk,lKK:()=>t_.lKK,YDF:()=>t_.YDF,OjQ:()=>t_.OjQ,HZy:()=>t_.HZy,dA1:()=>tM,xbf:()=>t_.xbf,Ec:()=>t_.Ec,Mw0:()=>t_.Mw0,SaS:()=>t_.SaS,P61:()=>t_.P61,op:()=>t_.op,X4o:()=>t_.X4o,eVF:()=>t_.eVF,BZs:()=>t_.BZs,grY:()=>t_.grY,XHu:()=>t_.XHu,WLX:()=>t_.WLX,dzn:()=>t_.dzn,n7C:()=>t_.n7C,NsG:()=>t_.NsG,yyV:()=>t_.yyV,_eU:()=>t_._eU,MEE:()=>ep.ME,whe:()=>t_.whe,iyU:()=>t_.iyU,Q0_:()=>t_.Q0_,_9M:()=>t_._9M,pR9:()=>t_.pR9,FE$:()=>t_.FE$,m0H:()=>t_.m0H,YeY:()=>t_.YeY,HYA:()=>t_.HYA,y17:()=>t_.y17,Gc4:()=>ep.Gc,xav:()=>t_.xav,VOZ:()=>t_.VOZ,gJX:()=>ep.gJ,krJ:()=>ta.kr,tAK:()=>ta.tA,VVh:()=>t_.VVh,j__:()=>t_.j__,rEj:()=>ep.rE,tQQ:()=>t_.tQQ,BEg:()=>t_.BEg,QD2:()=>t_.QD2,LMr:()=>t_.LMr,I2l:()=>t_.I2l,JYU:()=>t_.JYU,z8$:()=>t_.z8$,LIG:()=>t_.LIG,Z$r:()=>t_.Z$r,d_2:()=>t_.d_2,NFr:()=>t_.NFr,g23:()=>tf,sZg:()=>t_.sZg,WfX:()=>t_.WfX,wdz:()=>t_.wdz,JFn:()=>l,jh6:()=>ep.jh,OkC:()=>ep.Ok,F12:()=>t_.F12,ry7:()=>t_.ry7,_SZ:()=>t_._SZ,vPA:()=>t_.vPA,F8e:()=>t_.F8e,L0l:()=>t_.L0l,dik:()=>t_.dik,Q$M:()=>t_.Q$M,zAd:()=>t_.zAd,wck:()=>t_.wck,R0O:()=>t_.R0O,Kro:()=>tm,Vs9:()=>t_.Vs9,lw0:()=>t_.lw0,eDJ:()=>t_.eDJ,lMo:()=>t_.lMo,Zhr:()=>t_.Zhr,lOn:()=>t_.lOn,lDo:()=>t_.lDo,RZD:()=>t_.RZD,EwI:()=>t_.EwI,Pbu:()=>t_.Pbu,r2V:()=>t_.r2V,t$z:()=>t_.t$z,PMw:()=>t_.PMw,Ym9:()=>t_.Ym9,YjP:()=>t_.YjP,jbE:()=>t_.jbE,czq:()=>t_.czq,chL:()=>tR.ch,Mlm:()=>t_.Mlm,ymU:()=>t_.ymU,OEK:()=>t_.OEK,tGX:()=>t_.tGX,KtR:()=>t_.KtR,$_$:()=>t_.$_$,g9W:()=>t_.g9W,Lpo:()=>t_.Lpo,yxw:()=>t_.yxw,NNh:()=>t_.NNh,d_S:()=>tg,Obs:()=>c,DZQ:()=>ep.DZ,Vsq:()=>t_.Vsq,kBw:()=>ep.kB,rfw:()=>t_.rfw,BaG:()=>tO,mgz:()=>t_.mgz,efE:()=>t_.efE,AmM:()=>t_.AmM,rYx:()=>ta.rY,iPt:()=>ta.iP,zAU:()=>t_.zAU,K$i:()=>t_.K$i,TuY:()=>tR.Tu,rni:()=>t_.rni,ZSL:()=>ty,jYt:()=>eb.jY,muS:()=>eb.mu,bvq:()=>t_.bvq,y7e:()=>eb.y7,bgA:()=>t$,_M9:()=>t_._M9,YJN:()=>t_.YJN,Ul9:()=>t_.Ul9,POl:()=>t_.POl});var i,o={};r.r(o),r.d(o,{isBrowser:()=>v,isMobile:()=>x,mockIsMobile:()=>b});var l={};r.r(l),r.d(l,{Serializable:()=>eT,SerializationMap:()=>eS,getRegisteredName:()=>ek,registerClass:()=>eN});var u={};r.r(u),r.d(u,{CompositeArrayBuffer:()=>$.D,browserFiles:()=>eV,browserHTTPRequest:()=>eX,concatenateArrayBuffers:()=>N.AQ,copyModel:()=>X,decodeWeights:()=>N.CY,decodeWeightsStream:()=>N.s5,encodeWeights:()=>N.aG,fromMemory:()=>e2,fromMemorySync:()=>e3,getLoadHandlers:()=>A,getModelArtifactsForJSON:()=>N.Ej,getModelArtifactsForJSONSync:()=>N.Rl,getModelArtifactsInfoForJSON:()=>N.oR,getSaveHandlers:()=>E,getWeightSpecs:()=>N.Xf,http:()=>eq,isHTTPScheme:()=>eY,listModels:()=>Q,loadWeights:()=>ej,moveModel:()=>J,registerLoadRouter:()=>C,registerSaveRouter:()=>I,removeModel:()=>q,weightsLoaderFactory:()=>eH,withSaveHandler:()=>e4,withSaveHandlerSync:()=>e5});var h={};r.r(h),r.d(h,{confusionMatrix:()=>tt});var p={};r.r(p),r.d(p,{draw:()=>tp,fromPixels:()=>td,fromPixelsAsync:()=>tl,toPixels:()=>th});var d={};r.r(d),r.d(d,{prepareAndValidate:()=>tc});var c={};r.r(c),r.d(c,{TEST_EPSILON_FLOAT16:()=>tb,createVideoElement:()=>tE,encodeStrings:()=>function e(t){for(let r=0;r<t.length;r++){let n=t[r];Array.isArray(n)?e(n):t[r]=(0,ty.encodeString)(n)}return t},expectArrayBuffersEqual:()=>tC,expectArraysClose:()=>tx,expectArraysEqual:()=>tS,expectNumbersClose:()=>tN,expectPromiseToFail:()=>tT,expectValuesInRange:()=>tI,play:()=>tA,testEpsilon:()=>tv});var f={};r.r(f),r.d(f,{collectGatherOpShapeInfo:()=>rE,computeOutShape:()=>rC,segOpComputeOptimalWindowSize:()=>rI});var m={};r.r(m),r.d(m,{ERF_A1:()=>t3,ERF_A2:()=>t4,ERF_A3:()=>t5,ERF_A4:()=>t6,ERF_A5:()=>t7,ERF_P:()=>t2,PARALLELIZE_THRESHOLD:()=>tH,RowPartitionType:()=>i,SELU_SCALE:()=>t1.X,SELU_SCALEALPHA:()=>t1.j,applyActivation:()=>tV.f2,assertAndGetBroadcastShape:()=>tr.assertAndGetBroadcastShape,assertAxesAreInnerMostDims:()=>tP.WC,assertParamsConsistent:()=>tz,assignToTypedArray:()=>ra,axesAreInnerMostDims:()=>tP.WH,calculateShapes:()=>tf.calculateShapes,checkEinsumDimSizes:()=>rh,checkPadOnDimRoundingMode:()=>tW.s_,combineLocations:()=>
112tP.aF,combineRaggedTensorToTensorShapes:()=>tG,complexWithEvenIndex:()=>rt,complexWithOddIndex:()=>rr,computeConv2DInfo:()=>tW.uf,computeConv3DInfo:()=>tW.p$,computeDefaultPad:()=>tW.G8,computeDilation2DInfo:()=>tW.YQ,computeOptimalWindowSize:()=>tK,computeOutAndReduceShapes:()=>tP.lb,computeOutShape:()=>tB,computePool2DInfo:()=>tW.E6,computePool3DInfo:()=>tW.l5,convertConv2DDataFormat:()=>tW.$Q,decodeEinsumEquation:()=>rl,eitherStridesOrDilationsAreOne:()=>tW.G0,expandShapeToKeepDim:()=>tP.SM,exponent:()=>ri,exponents:()=>rs,fromStringArrayToUint8:()=>r$,fromUint8ToStringArray:()=>rA,getAxesPermutation:()=>tP.Em,getBroadcastDims:()=>tr.getBroadcastDims,getComplexWithIndex:()=>rn,getEinsumComputePath:()=>rp,getEinsumPermutation:()=>ru,getFusedBiasGradient:()=>tV.Do,getFusedDyActivation:()=>tV.XB,getImageCenter:()=>tY,getInnerMostAxes:()=>tP.fK,getPermuted:()=>tq,getRaggedRank:()=>tZ,getReductionAxes:()=>tr.getReductionAxes,getReshaped:()=>tQ,getReshapedPermuted:()=>tX,getRowPartitionTypesHelper:()=>tU,getSliceBeginCoords:()=>tJ,getSliceSize:()=>t0,getSparseFillEmptyRowsIndicesDenseShapeMismatch:()=>rf,getSparseFillEmptyRowsNegativeIndexErrorMessage:()=>rm,getSparseFillEmptyRowsOutOfRangeIndexErrorMessage:()=>rg,getSparseReshapeEmptyTensorZeroOutputDimErrorMessage:()=>rx,getSparseReshapeInputOutputMismatchErrorMessage:()=>rw,getSparseReshapeInputOutputMultipleErrorMessage:()=>rv,getSparseReshapeMultipleNegativeOneOutputDimErrorMessage:()=>ry,getSparseReshapeNegativeOutputDimErrorMessage:()=>rb,getSparseSegmentReductionIndicesOutOfRangeErrorMessage:()=>rk,getSparseSegmentReductionNegativeSegmentIdsErrorMessage:()=>rT,getSparseSegmentReductionNonIncreasingSegmentIdsErrorMessage:()=>rS,getSparseSegmentReductionSegmentIdOutOfRangeErrorMessage:()=>rN,getUndoAxesPermutation:()=>tP.gx,isIdentityPermutation:()=>rd,log:()=>t9.R,mergeRealAndImagArrays:()=>t8,prepareAndValidate:()=>tc,prepareSplitSize:()=>rc,segment_util:()=>f,shouldFuse:()=>tV.zE,slice_util:()=>tm,splitRealAndImagArrays:()=>re,stridesOrDilationsArePositive:()=>tW.qk,tupleValuesAreOne:()=>tW.Dh,upcastType:()=>tR.Tu,validateDefaultValueShape:()=>tj,validateInput:()=>tf.validateInput,validateUpdateShape:()=>tf.validateUpdateShape,warn:()=>t9.i});var g={};r.r(g),r.d(g,{nonMaxSuppressionV3Impl:()=>rF.c7,nonMaxSuppressionV4Impl:()=>rF.ZS,nonMaxSuppressionV5Impl:()=>rF.ut,whereImpl:()=>rR.Y});var y=r(19041);function b(e){n=e}function x(e){if(void 0!==n)return n;if(e||"undefined"!=typeof navigator&&null!=navigator){if(e||(e=navigator),"ReactNative"===e.product)return!0;let t=e.userAgent||e.vendor||("undefined"!=typeof window?window.opera:"");if(!t){let t=e;return t.userAgentData&&t.userAgentData.mobile}return/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(t)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|
112sy(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 v(){return"undefined"!=typeof window&&null!=window.document||"undefined"!=typeof WorkerGlobalScope}var w=r(89215),T=r(87358);let S=(0,w._K)();S.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.")}),S.registerFlag("IS_BROWSER",()=>v()),S.registerFlag("IS_NODE",()=>void 0!==T&&void 0!==T.versions&&void 0!==T.versions.node),S.registerFlag("IS_CHROME",()=>"undefined"!=typeof navigator&&null!=navigator&&null!=navigator.userAgent&&/Chrome/.test(navigator.userAgent)&&/Google Inc/.test(navigator.vendor)),S.registerFlag("IS_SAFARI",()=>"undefined"!=typeof navigator&&null!=navigator&&null!=navigator.userAgent&&/Safari/.test(navigator.userAgent)&&/Apple/.test(navigator.vendor)),S.registerFlag("PROD",()=>!1),S.registerFlag("TENSORLIKE_CHECK_SHAPE_CONSISTENCY",()=>S.getBool("DEBUG")),S.registerFlag("DEPRECATION_WARNINGS_ENABLED",()=>!0),S.registerFlag("IS_TEST",()=>!1),S.registerFlag("CHECK_COMPUTATION_FOR_ERRORS",()=>S.getBool("DEBUG")),S.registerFlag("WRAP_TO_IMAGEBITMAP",()=>!1),S.registerFlag("CANVAS2D_WILL_READ_FREQUENTLY_FOR_GPU",()=>!1),S.registerFlag("USE_SETTIMEOUTCUSTOM",()=>!1);var N=r(3437);class k{constructor(){this.saveRouters=[],this.loadRouters=[]}static getInstance(){return null==k.instance&&(k.instance=new k),k.instance}static registerSaveRouter(e){k.getInstance().saveRouters.push(e)}static registerLoadRouter(e){k.getInstance().loadRouters.push(e)}static getSaveHandlers(e){return k.getHandlers(e,"save")}static getLoadHandlers(e,t){return k.getHandlers(e,"load",t)}static getHandlers(e,t,r){let n=[];return("load"===t?k.getInstance().loadRouters:k.getInstance().saveRouters).forEach(t=>{let a=t(e,r);null!==a&&n.push(a)}),n}}let I=e=>k.registerSaveRouter(e),C=e=>k.registerLoadRouter(e),E=e=>k.getSaveHandlers(e),A=(e,t)=>
112k.getLoadHandlers(e,t);var $=r(36799);let F="tensorflowjs",R="models_store",_="model_info_store";function D(){if(!(0,w._K)().getBool("IS_BROWSER"))throw Error("Failed to obtain IndexedDB factory because the current environmentis not a web browser.");let e="undefined"==typeof window?self:window,t=e.indexedDB||e.mozIndexedDB||e.webkitIndexedDB||e.msIndexedDB||e.shimIndexedDB;if(null==t)throw Error("The current browser does not appear to support IndexedDB.");return t}function O(e){let t=e.result;t.createObjectStore(R,{keyPath:"modelPath"}),t.createObjectStore(_,{keyPath:"modelPath"})}class L{constructor(e){if(this.indexedDB=D(),null==e||!e)throw Error("For IndexedDB, modelPath must not be null, undefined or empty.");this.modelPath=e}async save(e){if(e.modelTopology instanceof ArrayBuffer)throw Error("BrowserLocalStorage.save() does not support saving model topology in binary formats yet.");return this.databaseAction(this.modelPath,e)}async load(){return this.databaseAction(this.modelPath)}databaseAction(e,t){return new Promise((e,r)=>{let n=this.indexedDB.open(F,1);n.onupgradeneeded=()=>O(n),n.onsuccess=()=>{let a=n.result;if(null==t){let t=a.transaction(R,"readonly"),n=t.objectStore(R).get(this.modelPath);n.onsuccess=()=>{if(null==n.result)return a.close(),r(Error(`Cannot find model with path '${this.modelPath}' in IndexedDB.`));e(n.result.modelArtifacts)},n.onerror=e=>(a.close(),r(n.error)),t.oncomplete=()=>a.close()}else{let n,s;t.weightData=$.D.join(t.weightData);let i=(0,N.oR)(t),o=a.transaction(_,"readwrite"),l=o.objectStore(_);try{n=l.put({modelPath:this.modelPath,modelArtifactsInfo:i})}catch(e){return r(e)}n.onsuccess=()=>{let n,u=(s=a.transaction(R,"readwrite")).objectStore(R);try{n=u.put({modelPath:this.modelPath,modelArtifacts:t,modelArtifactsInfo:i})}catch(e){return r(e)}n.onsuccess=()=>e({modelArtifactsInfo:i}),n.onerror=e=>{let t=(l=o.objectStore(_)).delete(this.modelPath);t.onsuccess=()=>(a.close(),r(n.error)),t.onerror=e=>(a.close(),r(n.error))}},n.onerror=e=>(a.close(),r(n.error)),o.oncomplete=()=>{null==s?a.close():s.oncomplete=()=>a.close()}}},n.onerror=e=>r(n.error)})}}L.URL_SCHEME="indexeddb://";let M=e=>{var t;return(0,w._K)().getBool("IS_BROWSER")&&!Array.isArray(e)&&e.startsWith(L.URL_SCHEME)?(t=e.slice(L.URL_SCHEME.length),new L(t)):null};k.registerSaveRouter(M),k.registerLoadRouter(M);class P{constructor(){this.indexedDB=D()}async listModels(){return new Promise((e,t)=>{let r=this.indexedDB.open(F,1);r.onupgradeneeded=()=>O(r),r.onsuccess=()=>{let n=r.result,a=n.transaction(_,"readonly"),s=a.objectStore(_).getAll();s.onsuccess=()=>{let t={};for(let e of s.result)t[e.modelPath]=e.modelArtifactsInfo;e(t)},s.onerror=e=>(n.close(),t(s.error)),a.oncomplete=()=>n.close()},r.onerror=e=>t(r.error)})}async removeModel(e){var t;return e=(t=e).startsWith(L.URL_SCHEME)?t.slice(L.URL_SCHEME.length):t,new Promise((t,r)=>{let n=this.indexedDB.open(F,1);n.onupgradeneeded=()=>O(n),n.onsuccess=()=>{let a,s=n.result,i=s.transaction(_,"readwrite"),o=i.objectStore(_),l=o.get(e);l.onsuccess=()=>{if(null==l.result)return s.close(),r(Error(`Cannot find model with path '${e}' in IndexedDB.`));{let n=o.delete(e),i=()=>{let n=(a=s.transaction(R,"readwrite")).objectStore(R).delete(e);n.onsuccess=()=>t(l.result.modelArtifactsInfo),n.onerror=e=>r(l.error)};n.onsuccess=i,n.onerror=e=>(i(),s.close(),r(l.error))}},l.onerror=e=>(s.close(),r(l.error)),i.oncomplete=()=>{null==a?s.close():a.oncomplete=()=>s.close()}},n.onerror=e=>r(n.error)})}}var z=r(76526);let B="tensorflowjs_models",W="info";function V(e){return{info:[B,e,W].join("/"),topology:[B,e,"model_topology"].join("/"),weightSpecs:[B,e,"weight_specs"].join("/"),weightData:[B,e,"weight_data"].join("/"),modelMetadata:[B,e,"model_metadata"].join("/")}}function G(e){for(let t of Object.values(e))window.localStorage.removeItem(t)}class U{constructor(e){if(!(0,w._K)().getBool("IS_BROWSER")||"undefined"==typeof window||void 0===window.localStorage)throw Error("The current environment does not support local storage.");if(this.LS=window.localStorage,null==e||!e)throw Error("For local storage, modelPath must not be null, undefined or empty.");this.modelPath=e,this.keys=V(this.modelPath)}async save(e){if(e.modelTopology instanceof ArrayBuffer)throw Error("BrowserLocalStorage.save() does not support saving model topology in binary formats yet.");{let t=JSON.stringify(e.modelTopology),r=JSON.stringify(e.weightSpecs),n=(0,N.oR)(e),a=$.D.join(e.weightData);try{this.LS.setItem(this.keys.info,JSON.stringify(n)),this.LS.setItem(this.keys.topology,t),this.LS.setItem(this.keys.weightSpecs,r),this.LS.setItem(this.keys.weightData,(0,N.l3)(a));let s={format:e.format,generatedBy:e.generatedBy,convertedBy:e.convertedBy,signature:null!=e.signature?e.signature:void 0,userDefinedMetadata:null!=e.userDefinedMetadata?e.userDefinedMetadata:void 0,modelInitializer:null!=e.modelInitializer?e.modelInitializer:void 0,initializerSignature:null!=e.initializerSignature?e.initializerSignature:void 0,trainingConfig:null!=e.trainingConfig?e.trainingConfig:void 0};return this.LS.setItem(this.keys.modelMetadata,JSON.stringify(s)),{modelArtifactsInfo:n}}catch(e){throw G(this.keys),Error(`Failed to save model '${this.modelPath}' to local storage: size quota being exceeded is a possible cause of this failure: modelTopologyBytes=${n.modelTopologyBytes}, weightSpecsBytes=${n.weightSpecsBytes}, weightDataBytes=${n.weightDataBytes}.`)}}}async load(){let e=JSON.parse(this.LS.getItem(this.keys.info));if(null==e)throw Error(`In local storage, there is no model with name '${this.modelPath}'`);if("JSON"!==e.modelTopologyType)throw Error("BrowserLocalStorage does not support loading non-JSON model topology yet.");let t={},r=JSON.parse(this.LS.getItem(this.keys.topology));if(null==r)throw Error(`In local storage, the topology of model '${this.modelPath}' is missing.`);t.modelTopology=r;let n=JSON.parse(this.LS.getItem(this.keys.weightSpecs));if(null==n)throw Error(`In local storage, the weight specs of model '${this.modelPath}' are missing.`);t.weightSpecs=n;let a=this.LS.getItem(this.keys.modelMetadata);if(null!=a){let e=JSON.parse(a);t.format=e.format,t.generatedBy=e.generatedBy,t.convertedBy=e.convertedBy,null!=e.signature&&(t.signature=e.signature),null!=e.userDefinedMetadata&&(t.userDefinedMetadata=e.userDefinedMetadata),null!=e.modelInitializer&&(t.modelInitializer=e.modelInitializer),null!=e.initializerSignature&&(t.initializerSignature=e.initializerSignature),null!=e.trainingConfig&&(t.trainingConfig=e.trainingConfig)}let s=this.LS.getItem(this.keys.weightData);if(null==s)throw Error(`In local storage, the binary weight values of model '${this.modelPath}' are missing.`);return t.weightData=(0,N.jf)(s),t}}U.URL_SCHEME="localstorage://";let Z=e=>{var t;
112return(0,w._K)().getBool("IS_BROWSER")&&!Array.isArray(e)&&e.startsWith(U.URL_SCHEME)?(t=e.slice(U.URL_SCHEME.length),new U(t)):null};k.registerSaveRouter(Z),k.registerLoadRouter(Z);class j{constructor(){(0,z.vA)((0,w._K)().getBool("IS_BROWSER"),()=>"Current environment is not a web browser"),(0,z.vA)("undefined"==typeof window||void 0!==window.localStorage,()=>"Current browser does not appear to support localStorage"),this.LS=window.localStorage}async listModels(){let e={},t=B+"/",r="/"+W;for(let n=0;n<this.LS.length;++n){let a=this.LS.key(n);a.startsWith(t)&&a.endsWith(r)&&(e[function(e){let t=e.split("/");if(t.length<3)throw Error(`Invalid key format: ${e}`);return t.slice(1,t.length-1).join("/")}(a)]=JSON.parse(this.LS.getItem(a)))}return e}async removeModel(e){var t;let r=V(e=(t=e).startsWith(U.URL_SCHEME)?t.slice(U.URL_SCHEME.length):t);if(null==this.LS.getItem(r.info))throw Error(`Cannot find model at path '${e}'`);let n=JSON.parse(this.LS.getItem(r.info));return G(r),n}}class H{constructor(){this.managers={}}static getInstance(){return null==H.instance&&(H.instance=new H),H.instance}static registerManager(e,t){(0,z.vA)(null!=e,()=>"scheme must not be undefined or null."),e.endsWith("://")&&(e=e.slice(0,e.indexOf("://"))),(0,z.vA)(e.length>0,()=>"scheme must not be an empty string.");let r=H.getInstance();(0,z.vA)(null==r.managers[e],()=>`A model store manager is already registered for scheme '${e}'.`),r.managers[e]=t}static getManager(e){let t=H.getInstance().managers[e];if(null==t)throw Error(`Cannot find model manager for scheme '${e}'`);return t}static getSchemes(){return Object.keys(H.getInstance().managers)}}function K(e){if(-1===e.indexOf("://"))throw Error(`The url string provided does not contain a scheme. Supported schemes are: ${H.getSchemes().join(",")}`);return{scheme:e.split("://")[0],path:e.split("://")[1]}}async function Y(e,t,r=!1){(0,z.vA)(e!==t,()=>`Old path and new path are the same: '${e}'`);let n=k.getLoadHandlers(e);(0,z.vA)(n.length>0,()=>`Copying failed because no load handler is found for source URL ${e}.`),(0,z.vA)(n.length<2,()=>`Copying failed because more than one (${n.length}) load handlers for source URL ${e}.`);let a=n[0],s=k.getSaveHandlers(t);(0,z.vA)(s.length>0,()=>`Copying failed because no save handler is found for destination URL ${t}.`),(0,z.vA)(s.length<2,()=>`Copying failed because more than one (${n.length}) save handlers for destination URL ${t}.`);let i=s[0],o=K(e).scheme,l=K(e).path,u=o===K(e).scheme,h=await a.load();r&&u&&await H.getManager(o).removeModel(l);let p=await i.save(h);return r&&!u&&await H.getManager(o).removeModel(l),p.modelArtifactsInfo}async function Q(){let e=H.getSchemes(),t={};for(let r of e){let e=await H.getManager(r).listModels();for(let n in e)t[r+"://"+n]=e[n]}return t}async function q(e){let t=K(e);return H.getManager(t.scheme).removeModel(t.path)}async function X(e,t){return Y(e,t,!1)}async function J(e,t){return Y(e,t,!0)}var ee=r(6025);class et{constructor(){this.messageName="setTimeoutCustom",this.functionRefs=[],this.handledMessageCount=0,this.hasEventListener=!1}fetch(e,t){return fetch(e,t)}now(){return performance.now()}encode(e,t){if("utf-8"!==t&&"utf8"!==t)throw Error(`Browser's encoder only supports utf-8, but got ${t}`);return null==this.textEncoder&&(this.textEncoder=new TextEncoder),this.textEncoder.encode(e)}decode(e,t){return new TextDecoder(t).decode(e)}setTimeoutCustom(e,t){if("undefined"==typeof window||!(0,w._K)().getBool("USE_SETTIMEOUTCUSTOM"))return void setTimeout(e,t);this.functionRefs.push(e),setTimeout(()=>{window.postMessage({name:this.messageName,index:this.functionRefs.length-1},"*")},t),this.hasEventListener||(this.hasEventListener=!0,window.addEventListener("message",e=>{e.source===window&&e.data.name===this.messageName&&(e.stopPropagation(),(0,this.functionRefs[e.data.index])(),this.handledMessageCount++,this.handledMessageCount===this.functionRefs.length&&(this.functionRefs=[],this.handledMessageCount=0))},!0))}isTypedArray(e){return(0,ee.Y)(e)}}if((0,w._K)().get("IS_BROWSER")){(0,w._K)().setPlatform("browser",new et);try{H.registerManager(U.URL_SCHEME,new j)}catch(e){}try{H.registerManager(L.URL_SCHEME,new P)}catch(e){}}var er=r(87358);let en={importFetch:()=>r(85817)};class ea{constructor(){this.util=r(18590),this.textEncoder=new this.util.TextEncoder}fetch(e,t){return null!=(0,w._K)().global.fetch?(0,w._K)().global.fetch(e,t):(null==a&&(a=en.importFetch()),a(e,t))}now(){let e=er.hrtime();return 1e3*e[0]+e[1]/1e6}encode(e,t){if("utf-8"!==t&&"utf8"!==t)throw Error(`Node built-in encoder only supports utf-8, but got ${t}`);return this.textEncoder.encode(e)}decode(e,t){return 0===e.length?"":new this.util.TextDecoder(t).decode(e)}isTypedArray(e){return this.util.types.isFloat32Array(e)||this.util.types.isInt32Array(e)||this.util.types.isUint8Array(e)||this.util.types.isUint8ClampedArray(e)}}
112(0,w._K)().get("IS_NODE")&&!(0,w._K)().get("IS_BROWSER")&&(0,w._K)().setPlatform("node",new ea);var es=r(993),ei=r(16488),eo=r(26004),el=r(32294),eu=r(60218);(0,y.Ye)();let eh={buffer:es.r,cast:ei.w,clone:eo.o,print:el.y};(0,eu.Q5)(eh);var ep=r(14958),ed=r(46842),ec=r(13062),ef=r(48683),em=r(76125),eg=r(20160),ey=r(79320),eb=r(10551),ex=r(30319);let ev=new Map,ew=new Map;class eT{getClassName(){return this.constructor.className}static fromConfig(e,t){return new e(t)}}class eS{constructor(){this.classNameMap={}}static getMap(){return null==eS.instance&&(eS.instance=new eS),eS.instance}static register(e){eS.getMap().classNameMap[e.className]=[e,e.fromConfig]}}function eN(e,t,r){(0,z.vA)(null!=e.className,()=>"Class being registered does not have the static className property defined."),(0,z.vA)("string"==typeof e.className,()=>"className is required to be a string, but got type "+typeof e.className),(0,z.vA)(e.className.length>0,()=>"Class being registered has an empty-string as its className, which is disallowed."),void 0===t&&(t="Custom"),void 0===r&&(r=e.className);let n=t+">"+r;return eS.register(e),ev.set(n,e),ew.set(e,n),e}function ek(e){return ew.has(e)?ew.get(e):e.className}class eI extends eT{minimize(e,t=!1,r){let{value:n,grads:a}=this.computeGradients(e,r);if(null!=r){let e=r.map(e=>({name:e.name,tensor:a[e.name]}));this.applyGradients(e)}else this.applyGradients(a);return((0,ep.AS)(a),t)?n:(n.dispose(),null)}get iterations(){return null==this.iterations_&&(this.iterations_=0),this.iterations_}incrementIterations(){this.iterations_=this.iterations+1}computeGradients(e,t){return(0,eb.y7)(e,t)}dispose(){null!=this.iterations_&&(0,ep.AS)(this.iterations_)}async saveIterations(){return null==this.iterations_&&(this.iterations_=0),{name:"iter",tensor:(0,ex.d)(this.iterations_,"int32")}}async getWeights(){throw Error("getWeights() is not implemented for this optimizer yet.")}async setWeights(e){throw 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(eI,Symbol.hasInstance,{value:e=>null!=e.minimize&&null!=e.computeGradients&&null!=e.applyGradients});class eC extends eI{static get className(){return"Adadelta"}constructor(e,t,r=null){super(),this.learningRate=e,this.rho=t,this.epsilon=r,this.accumulatedGrads=[],this.accumulatedUpdates=[],null==r&&(this.epsilon=y.T2.backend.epsilon())}applyGradients(e){(Array.isArray(e)?e.map(e=>e.name):Object.keys(e)).forEach((t,r)=>{let n=y.T2.registeredVariables[t];null==this.accumulatedGrads[r]&&(this.accumulatedGrads[r]={originalName:`${t}/accum_grad`,variable:(0,ep.DZ)(()=>(0,ey.P)(n).variable(!1))}),null==this.accumulatedUpdates[r]&&(this.accumulatedUpdates[r]={originalName:`${t}/accum_var`,variable:(0,ep.DZ)(()=>(0,ey.P)(n).variable(!1))});let a=Array.isArray(e)?e[r].tensor:e[t];if(null==a)return;let s=this.accumulatedGrads[r].variable,i=this.accumulatedUpdates[r].variable;(0,ep.DZ)(()=>{let e=(0,ed.W)((0,ef.l)(s,this.rho),(0,ef.l)((0,eg.E)(a),1-this.rho)),t=(0,ef.l)((0,ec.y)((0,em.R)((0,ed.W)(i,this.epsilon)),(0,em.R)((0,ed.W)(s,this.epsilon))),a),r=(0,ed.W)((0,ef.l)(i,this.rho),(0,ef.l)((0,eg.E)(t),1-this.rho));s.assign(e),i.assign(r);let o=(0,ed.W)((0,ef.l)(t,-this.learningRate),n);n.assign(o)})}),this.incrementIterations()}dispose(){null!=this.accumulatedUpdates&&((0,ep.AS)(this.accumulatedGrads.map(e=>e.variable)),(0,ep.AS)(this.accumulatedUpdates.map(e=>e.variable)))}async getWeights(){let e=[...this.accumulatedGrads,...this.accumulatedUpdates];return[await this.saveIterations()].concat(e.map(e=>({name:e.originalName,tensor:e.variable})))}async setWeights(e){let t=(e=await this.extractIterations(e)).length/2;this.accumulatedGrads=e.slice(0,t).map(e=>({originalName:e.name,variable:e.tensor.variable(!1)})),this.accumulatedUpdates=e.slice(t,2*t).map(e=>({originalName:e.name,variable:e.tensor.variable(!1)}))}getConfig(){return{learningRate:this.learningRate,rho:this.rho,epsilon:this.epsilon}}static fromConfig(e,t){return new e(t.learningRate,t.rho,t.epsilon)}}var eE=r(45382);class eA extends eI{static get className(){return"Adagrad"}constructor(e,t=.1){super(),this.learningRate=e,this.initialAccumulatorValue=t,this.accumulatedGrads=[]}applyGradients(e){(Array.isArray(e)?e.map(e=>
112e.name):Object.keys(e)).forEach((t,r)=>{let n=y.T2.registeredVariables[t];null==this.accumulatedGrads[r]&&(this.accumulatedGrads[r]={originalName:`${t}/accumulator`,variable:(0,ep.DZ)(()=>(0,eE.G)(n.shape,this.initialAccumulatorValue).variable(!1))});let a=Array.isArray(e)?e[r].tensor:e[t];if(null==a)return;let s=this.accumulatedGrads[r].variable;(0,ep.DZ)(()=>{let e=(0,ed.W)(s,(0,eg.E)(a));s.assign(e);let t=(0,ed.W)((0,ef.l)((0,ec.y)(a,(0,em.R)((0,ed.W)(e,y.T2.backend.epsilon()))),-this.learningRate),n);n.assign(t)})}),this.incrementIterations()}dispose(){null!=this.accumulatedGrads&&(0,ep.AS)(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),this.accumulatedGrads=e.map(e=>({originalName:e.name,variable:e.tensor.variable(!1)}))}getConfig(){return{learningRate:this.learningRate,initialAccumulatorValue:this.initialAccumulatorValue}}static fromConfig(e,t){return new e(t.learningRate,t.initialAccumulatorValue)}}var e$=r(25351),eF=r(92263);class eR extends eI{static get className(){return"Adam"}constructor(e,t,r,n=null){super(),this.learningRate=e,this.beta1=t,this.beta2=r,this.epsilon=n,this.accumulatedFirstMoment=[],this.accumulatedSecondMoment=[],(0,ep.DZ)(()=>{this.accBeta1=(0,ex.d)(t).variable(),this.accBeta2=(0,ex.d)(r).variable()}),null==n&&(this.epsilon=y.T2.backend.epsilon())}applyGradients(e){let t=Array.isArray(e)?e.map(e=>e.name):Object.keys(e);(0,ep.DZ)(()=>{let r=(0,eF.j)(1,this.accBeta1),n=(0,eF.j)(1,this.accBeta2);t.forEach((t,a)=>{let s=y.T2.registeredVariables[t];null==this.accumulatedFirstMoment[a]&&(this.accumulatedFirstMoment[a]={originalName:`${t}/m`,variable:(0,ep.DZ)(()=>(0,ey.P)(s).variable(!1))}),null==this.accumulatedSecondMoment[a]&&(this.accumulatedSecondMoment[a]={originalName:`${t}/v`,variable:(0,ep.DZ)(()=>(0,ey.P)(s).variable(!1))});let i=Array.isArray(e)?e[a].tensor:e[t];if(null==i)return;let o=this.accumulatedFirstMoment[a].variable,l=this.accumulatedSecondMoment[a].variable,u=(0,ed.W)((0,ef.l)(o,this.beta1),(0,ef.l)(i,1-this.beta1)),h=(0,ed.W)((0,ef.l)(l,this.beta2),(0,ef.l)((0,eg.E)(i),1-this.beta2)),p=(0,ec.y)(u,r),d=(0,ec.y)(h,n);o.assign(u),l.assign(h);let c=(0,ed.W)((0,ef.l)((0,ec.y)(p,(0,ed.W)((0,em.R)(d),this.epsilon)),-this.learningRate),s);s.assign(c)}),this.accBeta1.assign((0,ef.l)(this.accBeta1,this.beta1)),this.accBeta2.assign((0,ef.l)(this.accBeta2,this.beta2))}),this.incrementIterations()}dispose(){this.accBeta1.dispose(),this.accBeta2.dispose(),null!=this.accumulatedFirstMoment&&(0,ep.AS)(this.accumulatedFirstMoment.map(e=>e.variable)),null!=this.accumulatedSecondMoment&&(0,ep.AS)(this.accumulatedSecondMoment.map(e=>e.variable))}async getWeights(){let e=[...this.accumulatedFirstMoment,...this.accumulatedSecondMoment];return[await this.saveIterations()].concat(e.map(e=>({name:e.originalName,tensor:e.variable})))}async setWeights(e){e=await this.extractIterations(e),(0,ep.DZ)(()=>{this.accBeta1.assign((0,e$.n)(this.beta1,this.iterations_+1)),this.accBeta2.assign((0,e$.n)(this.beta2,this.iterations_+1))});let t=e.length/2;this.accumulatedFirstMoment=e.slice(0,t).map(e=>({originalName:e.name,variable:e.tensor.variable(!1)})),this.accumulatedSecondMoment=e.slice(t,2*t).map(e=>({originalName:e.name,variable:e.tensor.variable(!1)}))}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)}}var e_=r(13825),eD=r(80107);class eO extends eI{static get className(){return"Adamax"}constructor(e,t,r,n=null,a=0){super(),this.learningRate=e,this.beta1=t,this.beta2=r,this.epsilon=n,this.decay=a,this.accumulatedFirstMoment=[],this.accumulatedWeightedInfNorm=[],(0,ep.DZ)(()=>{this.iteration=(0,ex.d)(0).variable(),this.accBeta1=(0,ex.d)(t).variable()}),null==n&&(this.epsilon=y.T2.backend.epsilon())}applyGradients(e){let t=Array.isArray(e)?e.map(e=>e.name):Object.keys(e);(0,ep.DZ)(()=>{let r=(0,eF.j)(1,this.accBeta1),n=(0,ec.y)(-this.learningRate,(0,ed.W)((0,ef.l)(this.iteration,this.decay),1));t.forEach((t,a)=>{let s=y.T2.registeredVariables[t];null==this.accumulatedFirstMoment[a]&&(this.accumulatedFirstMoment[a]={originalName:`${t}/m`,variable:(0,ey.P)(s).variable(!1)}),null==this.accumulatedWeightedInfNorm[a]&&(this.accumulatedWeightedInfNorm[a]={originalName:`${t}/v`,variable:(0,ey.P)(s).variable(!1)});let i=Array.isArray(e)?e[a].tensor:e[t];if(null==i)return;let o=this.accumulatedFirstMoment[a].variable,l=this.accumulatedWeightedInfNorm[a].variable,u=(0,ed.W)((0,ef.l)(o,this.beta1),(0,ef.l)(i,1-this.beta1)),h=(0,ef.l)(l,this.beta2),p=(0,e_.t)(i),d=(0,eD.P)(h,p);o.assign(u),l.assign(d);let c=(0,ed.W)((0,ef.l)((0,ec.y)(n,r),(0,ec.y)(u,(0,ed.W)(d,this.epsilon))),s);s.assign(c)}),this.iteration.assign((0,ed.W)(this.iteration,1)),this.accBeta1.assign((0,ef.l)(this.accBeta1,this.beta1))}),this.incrementIterations()}dispose(){this.accBeta1.dispose(),this.iteration.dispose(),null!=this.accumulatedFirstMoment&&(0,ep.AS)(this.accumulatedFirstMoment.map(e=>e.variable)),null!=this.accumulatedWeightedInfNorm&&(0,ep.AS)(this.accumulatedWeightedInfNorm.map(e=>e.variable))}async getWeights(){throw Error("getWeights() is not implemented for Adamax yet.")}async setWeights(e){throw 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)}}class eL extends eI{static get className(){return"SGD"}constructor(e){super(),this.learningRate=e,this.setLearningRate(e)}
112applyGradients(e){(Array.isArray(e)?e.map(e=>e.name):Object.keys(e)).forEach((t,r)=>{let n=Array.isArray(e)?e[r].tensor:e[t];if(null==n)return;let a=y.T2.registeredVariables[t];(0,ep.DZ)(()=>{let e=(0,ed.W)((0,ef.l)(this.c,n),a);a.assign(e)})}),this.incrementIterations()}setLearningRate(e){this.learningRate=e,null!=this.c&&this.c.dispose(),this.c=(0,ep.aC)((0,ex.d)(-e))}dispose(){this.c.dispose()}async getWeights(){return[await this.saveIterations()]}async setWeights(e){if(0!==(e=await this.extractIterations(e)).length)throw Error("SGD optimizer does not have settable weights.")}getConfig(){return{learningRate:this.learningRate}}static fromConfig(e,t){return new e(t.learningRate)}}class eM extends eL{static get className(){return"Momentum"}constructor(e,t,r=!1){super(e),this.learningRate=e,this.momentum=t,this.useNesterov=r,this.accumulations=[],this.m=(0,ex.d)(this.momentum)}applyGradients(e){(Array.isArray(e)?e.map(e=>e.name):Object.keys(e)).forEach((t,r)=>{let n=y.T2.registeredVariables[t];null==this.accumulations[r]&&(this.accumulations[r]={originalName:`${t}/momentum`,variable:(0,ep.DZ)(()=>(0,ey.P)(n).variable(!1))});let a=this.accumulations[r].variable,s=Array.isArray(e)?e[r].tensor:e[t];null!=s&&(0,ep.DZ)(()=>{let e,t=(0,ed.W)((0,ef.l)(this.m,a),s);e=this.useNesterov?(0,ed.W)((0,ef.l)(this.c,(0,ed.W)(s,(0,ef.l)(t,this.m))),n):(0,ed.W)((0,ef.l)(this.c,t),n),a.assign(t),n.assign(e)})}),this.incrementIterations()}dispose(){this.m.dispose(),null!=this.accumulations&&(0,ep.AS)(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),this.accumulations=e.map(e=>({originalName:e.name,variable:e.tensor.variable(!1)}))}getConfig(){return{learningRate:this.learningRate,momentum:this.momentum,useNesterov:this.useNesterov}}static fromConfig(e,t){return new e(t.learningRate,t.momentum,t.useNesterov)}}class eP extends eI{static get className(){return"RMSProp"}constructor(e,t=.9,r=0,n=null,a=!1){if(super(),this.learningRate=e,this.decay=t,this.momentum=r,this.epsilon=n,this.accumulatedMeanSquares=[],this.accumulatedMoments=[],this.accumulatedMeanGrads=[],this.centered=a,null==n&&(this.epsilon=y.T2.backend.epsilon()),null==e)throw Error("learningRate for RMSPropOptimizer must be defined.")}applyGradients(e){(Array.isArray(e)?e.map(e=>e.name):Object.keys(e)).forEach((t,r)=>{let n=y.T2.registeredVariables[t];null==this.accumulatedMeanSquares[r]&&(this.accumulatedMeanSquares[r]={originalName:`${t}/rms`,variable:(0,ep.DZ)(()=>(0,ey.P)(n).variable(!1))}),null==this.accumulatedMoments[r]&&(this.accumulatedMoments[r]={originalName:`${t}/momentum`,variable:(0,ep.DZ)(()=>(0,ey.P)(n).variable(!1))}),null==this.accumulatedMeanGrads[r]&&this.centered&&(this.accumulatedMeanGrads[r]={originalName:`${t}/mg`,variable:(0,ep.DZ)(()=>(0,ey.P)(n).variable(!1))});let a=Array.isArray(e)?e[r].tensor:e[t];if(null==a)return;let s=this.accumulatedMeanSquares[r].variable,i=this.accumulatedMoments[r].variable;(0,ep.DZ)(()=>{let e=(0,ed.W)((0,ef.l)(s,this.decay),(0,ef.l)((0,eg.E)(a),1-this.decay));if(this.centered){let t=this.accumulatedMeanGrads[r].variable,o=(0,ed.W)((0,ef.l)(t,this.decay),(0,ef.l)(a,1-this.decay)),l=(0,ec.y)((0,ef.l)(a,this.learningRate),(0,em.R)((0,eF.j)(e,(0,ed.W)((0,eg.E)(o),this.epsilon)))),u=(0,ed.W)((0,ef.l)(i,this.momentum),l);s.assign(e),t.assign(o),i.assign(u);let h=(0,eF.j)(n,u);n.assign(h)}else{let e=(0,ed.W)((0,ef.l)(s,this.decay),(0,ef.l)((0,eg.E)(a),1-this.decay)),t=(0,ed.W)((0,ef.l)(i,this.momentum),(0,ec.y)((0,ef.l)(a,this.learningRate),(0,em.R)((0,ed.W)(e,this.epsilon))));s.assign(e),i.assign(t);let r=(0,eF.j)(n,t);n.assign(r)}})}),this.incrementIterations()}dispose(){null!=this.accumulatedMeanSquares&&(0,ep.AS)(this.accumulatedMeanSquares.map(e=>e.variable)),null!=this.accumulatedMeanGrads&&this.centered&&(0,ep.AS)(this.accumulatedMeanGrads.map(e=>e.variable)),null!=this.accumulatedMoments&&(0,ep.AS)(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(e=>({name:e.originalName,tensor:e.variable}
112)))}async setWeights(e){e=await this.extractIterations(e);let t=this.centered?e.length/3:e.length/2;this.accumulatedMeanSquares=e.slice(0,t).map(e=>({originalName:e.name,variable:e.tensor.variable(!1)})),this.accumulatedMoments=e.slice(t,2*t).map(e=>({originalName:e.name,variable:e.tensor.variable(!1)})),this.centered&&(this.accumulatedMeanGrads=e.slice(2*t,3*t).map(e=>({originalName:e.name,variable:e.tensor.variable(!1)})))}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)}}function ez(e){return new Promise(e=>setTimeout(e)).then(e)}class eB{constructor(e){if(!(0,w._K)().getBool("IS_BROWSER"))throw Error("browserDownloads() cannot proceed because the current environment is not a browser.");e.startsWith(eB.URL_SCHEME)&&(e=e.slice(eB.URL_SCHEME.length)),(null==e||0===e.length)&&(e="model"),this.modelJsonFileName=e+".json",this.weightDataFileName=e+".weights.bin"}async save(e){if("undefined"==typeof document)throw Error("Browser downloads are not supported in this environment since `document` is not present");let t=$.D.join(e.weightData),r=window.URL.createObjectURL(new Blob([t],{type:"application/octet-stream"}));if(e.modelTopology instanceof ArrayBuffer)throw Error("BrowserDownloads.save() does not support saving model topology in binary formats yet.");{let t=[{paths:["./"+this.weightDataFileName],weights:e.weightSpecs}],n=(0,N.zV)(e,t),a=window.URL.createObjectURL(new Blob([JSON.stringify(n)],{type:"application/json"})),s=null==this.modelJsonAnchor?document.createElement("a"):this.modelJsonAnchor;if(s.download=this.modelJsonFileName,s.href=a,await ez(()=>s.dispatchEvent(new MouseEvent("click"))),null!=e.weightData){let e=null==this.weightDataAnchor?document.createElement("a"):this.weightDataAnchor;e.download=this.weightDataFileName,e.href=r,await ez(()=>e.dispatchEvent(new MouseEvent("click")))}return{modelArtifactsInfo:(0,N.oR)(e)}}}}eB.URL_SCHEME="downloads://";class eW{constructor(e){if(null==e||e.length<1)throw Error(`When calling browserFiles, at least 1 file is required, but received ${e}`);this.jsonFile=e[0],this.weightsFiles=e.slice(1)}async load(){return new Promise((e,t)=>{let r=new FileReader;r.onload=r=>{let n=JSON.parse(r.target.result),a=n.modelTopology;return null==a?void t(Error(`modelTopology field is missing from file ${this.jsonFile.name}`)):null==n.weightsManifest?void t(Error(`weightManifest field is missing from file ${this.jsonFile.name}`)):0===this.weightsFiles.length?void e({modelTopology:a}):void e((0,N.Ej)(n,e=>this.loadWeights(e)))},r.onerror=e=>t(`Failed to read model topology and weights manifest JSON from file '${this.jsonFile.name}'. BrowserFiles supports loading Keras-style tf.Model artifacts only.`),r.readAsText(this.jsonFile)})}loadWeights(e){let t=[],r=[];for(let n of e)t.push(...n.weights),r.push(...n.paths);let n=this.checkManifestAndWeightFiles(e);return Promise.all(r.map(e=>this.loadWeightsFile(e,n[e]))).then(e=>[t,e])}loadWeightsFile(e,t){return new Promise((r,n)=>{let a=new FileReader;a.onload=e=>{r(e.target.result)},a.onerror=t=>n(`Failed to weights data from file of path '${e}'.`),a.readAsArrayBuffer(t)})}checkManifestAndWeightFiles(e){let t=[],r=this.weightsFiles.map(e=>(0,N.P8)(e.name)),n={};for(let a of e)a.paths.forEach(e=>{let a=(0,N.P8)(e);if(-1!==t.indexOf(a))throw Error(`Duplicate file basename found in weights manifest: '${a}'`);if(t.push(a),-1===r.indexOf(a))throw Error(`Weight file with basename '${a}' is not provided.`);n[e]=this.weightsFiles[r.indexOf(a)]});if(t.length!==this.weightsFiles.length)throw Error(`Mismatch in the number of files in weights manifest (${t.length}) and the number of weight files provided (${this.weightsFiles.length}).`);return n}}function eV(e){return new eW(e)}function eG(e,t,r,n){var a,s,i;a=e,(0,z.vA)(null!=a&&Array.isArray(a)&&a.length>0,()=>"promises must be a none empty array"),s=r=null==r?0:r,i=n=null==n?1:n,(0,z.vA)(s>=0&&s<=1,()=>`Progress fraction must be in range [0, 1], but got startFraction ${s}
112`),(0,z.vA)(i>=0&&i<=1,()=>`Progress fraction must be in range [0, 1], but got endFraction ${i}`),(0,z.vA)(i>=s,()=>`startFraction must be no more than endFraction, but got startFraction ${s} and endFraction ${i}`);let o=0;return Promise.all(e.map(a=>(a.then(a=>(t(r+ ++o/e.length*(n-r)),a)),a)))}k.registerSaveRouter(e=>(0,w._K)().getBool("IS_BROWSER")&&!Array.isArray(e)&&e.startsWith(eB.URL_SCHEME)?function(e="model"){return new eB(e)}(e.slice(eB.URL_SCHEME.length)):null);var eU=r(64756);async function eZ(e,t){null==t&&(t={});let r=null==t.fetchFunc?(0,w._K)().platform.fetch:t.fetchFunc,n=e.map(e=>r(e,t.requestInit,{isBinary:!0})),a=(null==t.onProgress?await Promise.all(n):await eG(n,t.onProgress,0,.5)).map(e=>e.arrayBuffer());return null==t.onProgress?await Promise.all(a):await eG(a,t.onProgress,.5,1)}async function ej(e,t="",r,n){return eH(e=>eZ(e,{requestInit:n}))(e,t,r)}function eH(e){return async(t,r="",n)=>{let a=t.map(()=>!1),s={},i=null!=n?n.map(()=>!1):[],o=[];if(t.forEach((e,t)=>{let r=0;e.weights.forEach(e=>{let l="quantization"in e?e.quantization.dtype:e.dtype,u=eU.i[l]*z.Ze(e.shape),h=()=>{a[t]=!0,null==s[t]&&(s[t]=[]),s[t].push({manifestEntry:e,groupOffset:r,sizeBytes:u})};null!=n?n.forEach((t,r)=>{t===e.name&&(h(),i[r]=!0)}):h(),o.push(e.name),r+=u})}),!i.every(e=>e)){let e=n.filter((e,t)=>!i[t]);throw Error(`Could not find weights in manifest with names: ${e.join(", ")}. 113Manifest JSON has weights with names: ${o.join(", ")}.`)}let l=a.reduce((e,t,r)=>(t&&e.push(r),e),[]),u=[];l.forEach(e=>{t[e].paths.forEach(e=>{let t=r+(r.endsWith("/")?"":"/")+e;u.push(t)})});let h=await e(u),p={},d=0;return l.forEach(e=>{let r=t[e].paths.length,n=new $.D(h.slice(d,d+r));s[e].forEach(e=>{let t=n.slice(e.groupOffset,e.groupOffset+e.sizeBytes),r=(0,N.CY)(t,[e.manifestEntry]);for(let e in r)p[e]=r[e]}),d+=r}),p}}class eK{constructor(e,t){if(this.DEFAULT_METHOD="POST",null==t&&(t={}),this.weightPathPrefix=t.weightPathPrefix,this.weightUrlConverter=t.weightUrlConverter,null!=t.fetchFunc?((0,z.vA)("function"==typeof t.fetchFunc,()=>"Must pass a function that matches the signature of `fetch` (see https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API)"),this.fetch=t.fetchFunc):this.fetch=(0,w._K)().platform.fetch,(0,z.vA)(null!=e&&e.length>0,()=>"URL path for http must not be null, undefined or empty."),Array.isArray(e)&&(0,z.vA)(2===e.length,()=>`URL paths for http must have a length of 2, (actual length is ${e.length}).`),this.path=e,null!=t.requestInit&&null!=t.requestInit.body)throw Error("requestInit is expected to have no pre-existing body, but has one.");this.requestInit=t.requestInit||{},this.loadOptions=t}async save(e){if(e.modelTopology instanceof ArrayBuffer)throw 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 r=[{paths:["./model.weights.bin"],weights:e.weightSpecs}],n=(0,N.zV)(e,r);if(t.body.append("model.json",new Blob([JSON.stringify(n)],{type:"application/json"}),"model.json"),null!=e.weightData){let r=$.D.join(e.weightData);t.body.append("model.weights.bin",new Blob([r],{type:"application/octet-stream"}),"model.weights.bin")}let a=await this.fetch(this.path,t);if(a.ok)return{modelArtifactsInfo:(0,N.oR)(e),responses:[a]};throw Error(`BrowserHTTPRequest.save() failed due to HTTP response status ${a.status}.`)}async loadModelJSON(){let e,t=await this.fetch(this.path,this.requestInit);if(!t.ok)throw Error(`Request to ${this.path} failed with status code ${t.status}. Please verify this URL points to the model JSON of the model to load.`);try{e=await t.json()}catch(t){let e=`Failed to parse model JSON of response from ${this.path}.`;throw this.path.endsWith(".pb")?e+=" 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.":e+=" Please make sure the server is serving valid JSON for this request.",Error(e)}let r=e.modelTopology,n=e.weightsManifest;if(null==r&&null==n)throw Error(`The JSON from HTTP path ${this.path}
113 contains neither model topology or manifest for weights.`);return e}async load(){if(this.loadOptions.streamWeights)return this.loadStream();let e=await this.loadModelJSON();return(0,N.Ej)(e,e=>this.loadWeights(e))}async loadStream(){let e=await this.loadModelJSON(),t=await this.getWeightUrls(e.weightsManifest),r=(0,N.Xf)(e.weightsManifest);return Object.assign(Object.assign({},e),{weightSpecs:r,getWeightStream:()=>(function(e,t){var r;let n,a=null==t.fetchFunc?(0,w._K)().platform.fetch:t.fetchFunc,s=0;return null==(r=t.onProgress)||r.call(t,0),new ReadableStream({pull:async r=>{for(var i;s<e.length;){n||(n=(await a(e[s],t.requestInit,{isBinary:!0})).body.getReader());let{done:o,value:l}=await n.read();if(o){s++,n=void 0,null==(i=t.onProgress)||i.call(t,s/e.length);continue}r.enqueue(l);return}r.close()}})})(t,this.loadOptions)})}async getWeightUrls(e){let[t,r]=function(e){let t=e.lastIndexOf("/"),r=e.lastIndexOf("?");return[e.substring(0,t)+"/",r>t?e.substring(r):""]}(Array.isArray(this.path)?this.path[1]:this.path),n=this.weightPathPrefix||t,a=[],s=[];for(let t of e)for(let e of t.paths)null!=this.weightUrlConverter?s.push(this.weightUrlConverter(e)):a.push(n+e+r);return this.weightUrlConverter&&a.push(...await Promise.all(s)),a}async loadWeights(e){let t=await this.getWeightUrls(e);return[(0,N.Xf)(e),await eZ(t,this.loadOptions)]}}function eY(e){return null!=e.match(eK.URL_SCHEME_REGEX)}eK.URL_SCHEME_REGEX=/^https?:\/\//;let eQ=(e,t)=>{if("undefined"==typeof fetch&&(null==t||null==t.fetchFunc));else{let r=!0;if(Array.isArray(e)?e.every(e=>eY(e)):eY(e))return eq(e,t)}return null};function eq(e,t){return new eK(e,t)}function eX(e,t){return eq(e,t)}k.registerSaveRouter(eQ),k.registerLoadRouter(eQ);class eJ{constructor(e){this.modelArtifacts=e}load(){return this.modelArtifacts}}class e0{constructor(e){this.saveHandler=e}save(e){return this.saveHandler(e)}}class e1{constructor(e){e.load&&(this.load=()=>Promise.resolve(e.load())),e.save&&(this.save=t=>Promise.resolve(e.save(t)))}}function e2(e,t,r,n){let a=arguments;return new e1(e3(...a))}function e3(e,t,r,n){return 1!=arguments.length?(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 eJ({modelTopology:e,weightSpecs:t,weightData:r,trainingConfig:n})):null!=e.modelTopology||null!=e.weightSpecs?new eJ(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 eJ({modelTopology:e}))}function e4(e){return new e0(e)}function e5(e){return new e0(e)}var e6=r(27924),e7=r(67454),e9=r(18313),e8=r(62176),te=r(60286);let tt=(0,e8.op)({confusionMatrix_:function(e,t,r){let n=(0,e6.YT)(e,"labels","confusionMatrix"),a=(0,e6.YT)(t,"predictions","confusionMatrix");z.vA(null==r||r>0&&Number.isInteger(r),()=>`If provided, numClasses must be a positive integer, but got ${r}`),z.vA(1===n.rank,()=>`Expected the rank of labels to be 1, but got ${n.rank}`),z.vA(1===a.rank,()=>`Expected the rank of predictions to be 1, but got ${a.rank}`),z.vA(n.shape[0]===a.shape[0],()=>`Mismatch in the number of examples: ${n.shape[0]} vs. ${a.shape[0]}. Labels and predictions should have the same number of elements.`),z.vA(r>0&&Number.isInteger(r),()=>`numClasses is required to be a positive integer, but got ${r}`);let s=(0,e9.M)((0,ei.w)(n,"int32"),r),i=(0,e9.M)((0,ei.w)(a,"int32"),r),o=(0,te.m)(s),l=(0,e7.N)(o,i);return(0,ei.w)(l,"int32")}});var tr=r(83231),tn=r(48592),ta=r(53147),ts=r(15401);let ti=!1;function to(e,t=3){let r,n;if(t>4)throw Error("Cannot construct Tensor with more than 4 channels from pixels.");if(null==e)throw Error("pixels passed to tf.browser.fromPixels() can not be null");let a=!1,i=!1,o=!1,l=!1,u=!1,h=!1;if(e.data instanceof Uint8Array)a=!0;else if("undefined"!=typeof ImageData&&e instanceof ImageData)i=!0;else if("undefined"!=typeof HTMLVideoElement&&e instanceof HTMLVideoElement)o=!0;else if("undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement)l=!0;else if(null!=e.getContext)u=!0;else if("undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap)h=!0;else throw 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(null!=(0,ta._5)(tn.awo,y.T2.backendName))return y.T2.runKernel(tn.awo,{pixels:e},{numChannels:t});let[p,d]=o?[e.videoWidth,e.videoHeight]:[e.width,e.height];if(u)r=e.getContext("2d").getImageData(0,0,p,d).data;else if(i||a)r=e.data;else if(l||o||h){if(null==s)if("undefined"==typeof document)if("undefined"!=typeof OffscreenCanvas&&"undefined"!=typeof OffscreenCanvasRenderingContext2D)s=new OffscreenCanvas(1,1).getContext("2d");else throw Error("Cannot parse input in current context. Reason: OffscreenCanvas Context2D rendering is not supported.");else s=document.createElement("canvas").getContext("2d",{willReadFrequently:!0});s.canvas.width=p,s.canvas.height=d,s.drawImage(e,0,0,p,d),r=s.getImageData(0,0,p,d).data}if(4===t)n=new Int32Array(r);else{let e=p*d;n=new Int32Array(e*t);for(let a=0;a<e;a++)for(let e=0;e<t;++e)n[a*t+e]=r[4*a+e]}let c=[d,p,t];return(0,ts.$)(n,c,"int32")}async function tl(e,t=3){var r;let n=null;if((0,w._K)().getBool("WRAP_TO_IMAGEBITMAP")&&"undefined"!=typeof window&&"undefined"!=typeof ImageBitmap&&window.hasOwnProperty("createImageBitmap")&&!(e instanceof ImageBitmap)&&null!=(r=e)&&0!==r.width&&0!==r.height&&!(null!=e&&e.data instanceof Uint8Array)){let t;try{t=await createImageBitmap(e,{premultiplyAlpha:"none"})}catch(e){t=null}n=null!=t&&t.width===e.width&&t.height===e.height?t:e}else n=e;return to(n,t)}
113function tu(e){if(2!==e.rank&&3!==e.rank)throw Error(`toPixels only supports rank 2 or 3 tensors, got rank ${e.rank}.`);let t=2===e.rank?1:e.shape[2];if(t>4||2===t)throw Error(`toPixels only supports depth of size 1, 3 or 4 but got ${t}`);if("float32"!==e.dtype&&"int32"!==e.dtype)throw Error(`Unsupported type for toPixels: ${e.dtype}. Please use float32 or int32 tensors.`)}async function th(e,t){let r=(0,e6.YT)(e,"img","toPixels");if(!(e instanceof eu.qY)){let e=r;r=(0,ei.w)(e,"int32"),e.dispose()}tu(r);let[n,a]=r.shape.slice(0,2),s=2===r.rank?1:r.shape[2],i=await r.data(),o="float32"===r.dtype?255:1,l=new Uint8ClampedArray(a*n*4);for(let e=0;e<n*a;++e){let t=[0,0,0,255];for(let n=0;n<s;n++){let a=i[e*s+n];if("float32"===r.dtype){if(a<0||a>1)throw Error(`Tensor values for a float32 Tensor must be in the range [0 - 1] but encountered ${a}.`)}else if("int32"===r.dtype&&(a<0||a>255))throw Error(`Tensor values for a int32 Tensor must be in the range [0 - 255] but encountered ${a}.`);1===s?(t[0]=a*o,t[1]=a*o,t[2]=a*o):t[n]=a*o}let n=4*e;l[n+0]=Math.round(t[0]),l[n+1]=Math.round(t[1]),l[n+2]=Math.round(t[2]),l[n+3]=Math.round(t[3])}if(null!=t){ti||null!=(0,ta._5)(tn.XmO,y.T2.backendName)&&(console.warn("tf.browser.toPixels is not efficient to draw tensor on canvas. Please try tf.browser.draw instead."),ti=!0),t.width=a,t.height=n;let e=t.getContext("2d"),r=new ImageData(l,a,n);e.putImageData(r,0,0)}return r!==e&&r.dispose(),l}function tp(e,t,r){let n=(0,e6.YT)(e,"img","draw");if(!(e instanceof eu.qY)){let e=n;n=(0,ei.w)(e,"int32"),e.dispose()}tu(n);var a=null==r?void 0:r.imageOptions;let s=(null==a?void 0:a.alpha)||1;if(s>1||s<0)throw Error(`Alpha value ${s} is suppoed to be in range [0 - 1].`);let i={image:n};y.T2.runKernel(tn.XmO,i,{canvas:t,options:r})}let td=(0,e8.op)({fromPixels_:to});function tc(e,t){let r=e.shape.length,n=t.shape.length;if(r<1)throw Error(`tf.gatherND() expects the input to be rank 1 or higher, but the rank was ${r}.`);if(n<1)throw Error(`tf.gatherND() expects the indices to be rank 1 or higher, but the rank was ${n}.`);if("int32"!==t.dtype)throw Error(`tf.gatherND() expects the indices to be int32 type, but the dtype was ${t.dtype}.`);if(t.shape[n-1]>r)throw Error(`index innermost dimension length must be <= tensor rank; saw: ${t.shape[n-1]} vs. ${r}`);if(0===(0,z.Ze)(e.shape))throw Error(`Requested more than 0 entries, but input is empty. Input shape: ${e.shape}.`);let a=t.shape,s=a[a.length-1],i=1;for(let e=0;e<a.length-1;++e)i*=a[e];let o=e.shape,l=a.slice();l.pop();let u=1;for(let e=s;e<r;++e)u*=o[e],l.push(o[e]);let h=[...(0,z.Ur)(e.shape).map(e=>e/u),1].slice(0,s);return[l,i,u,h]}var tf=r(94915),tm=r(14600),tg=r(50124),ty=r(47537);let tb=.1;function tx(e,t,r){return null==r&&(r=tv()),tw(e,t,(e,t)=>tk(e,t,r))}function tv(){return 32===y.T2.backend.floatPrecision()?.001:tb}function tw(e,t,r){let n=!0;if(((0,ty.isTypedArray)(e)||(0,ty.isTypedArray)(t))&&(n=!1),(0,ty.isTypedArray)(e)&&(0,ty.isTypedArray)(t)&&(n=!0),n){let r=e.constructor.name,n=t.constructor.name;if(r!==n)throw Error(`Arrays are of different type. Actual: ${r}. Expected: ${n}`)}if(Array.isArray(e)&&Array.isArray(t)){let r=(0,e6.MZ)(e),n=(0,e6.MZ)(t);if(!(0,z.r1)(r,n))throw Error(`Arrays have different shapes. Actual: [${r}]. Expected: [${n}]`)}let a=(0,ty.isTypedArray)(e)?e:(0,ty.flatten)(e),s=(0,ty.isTypedArray)(t)?t:(0,ty.flatten)(t);if(a.length!==s.length)throw Error(`Arrays have different lengths actual: ${a.length} vs expected: ${s.length}. 114Actual: ${a}. 115Expected: ${s}.`);for(let e=0;e<s.length;++e){let t=a[e],n=s[e];if(!r(t,n))throw Error(`Arrays differ: actual[${e}] = ${t}, expected[${e}] = ${n}. 116Actual: ${a}. 117Expected: ${s}.`)}"undefined"!=typeof expect&&expect().nothing()}function tT(e,t){e().then(()=>t.fail(),()=>t()),"undefined"!=typeof expect&&expect().nothing()}function tS(e,t){let r="string"==typeof t||"number"==typeof t||"boolean"==typeof t?[t]:t;return(0,z.Kg)(e)||(0,z.Kg)(e[0])||(0,z.Kg)(t)||(0,z.Kg)(t[0])?tw(e,r,(e,t)=>e==t):tw(e,t,(e,t)=>tk(e,t,0))}function tN(e,t,r){if(null==r&&(r=tv()),!tk(e,t,r))throw Error(`Numbers differ: actual === ${e}, expected === ${t}`);"undefined"!=typeof expect&&expect().nothing()}function tk(e,t,r){return!(isFinite(e)||isFinite(t))||!(isNaN(e)||isNaN(t)||Math.abs(e-t)>r)}function tI(e,t,r){for(let n=0;n<e.length;n++)if(e[n]<t||e[n]>r)throw Error(`Value out of range:${e[n]} low: ${t}, high: ${r}`)}function tC(e,t){let r=new Float32Array(e),n=new Float32Array(t);if(r.length!==n.length)throw Error(`Expected ArrayBuffer to be of length ${n.length}, but it was ${r.length}`);for(let e=0;e<n.length;e++)if(r[e]!==n[e])throw Error(`Expected ArrayBuffer value at ${e} to be ${n[e]} but got ${r[e]} instead`)}function tE(e){let t=document.createElement("video");
117return"playsInline"in t&&(t.playsInline=!0),t.muted=!0,t.loop=!0,t.style.position="fixed",t.style.left="0px",t.style.top="0px",t.preload="auto",t.appendChild(e),new Promise(e=>{t.addEventListener("loadeddata",r=>e(t)),t.load()})}async function tA(e){await e.play(),"requestVideoFrameCallback"in e&&await new Promise(t=>{e.requestVideoFrameCallback(t)})}let t$="4.22.0";class tF{static sgd(e){return new eL(e)}static momentum(e,t,r=!1){return new eM(e,t,r)}static rmsprop(e,t=.9,r=0,n=null,a=!1){return new eP(e,t,r,n,a)}static adam(e=.001,t=.9,r=.999,n=null){return new eR(e,t,r,n)}static adadelta(e=.001,t=.95,r=null){return new eC(e,t,r)}static adamax(e=.002,t=.9,r=.999,n=null,a=0){return new eO(e,t,r,n,a)}static adagrad(e,t=.1){return new eA(e,t)}}var tR=r(17831),t_=r(51247),tD=r(99882);let tO=tF,tL="undefined"!=typeof requestAnimationFrame?requestAnimationFrame:"undefined"!=typeof setImmediate?setImmediate:e=>e();function tM(){return new Promise(e=>tL(()=>e()))}var tP=r(61727);function tz(e,t){let r=e[0].length;e.forEach((e,t)=>{z.vA(e.length===r,()=>`Error in concat${r}D: rank of tensors[${t}] must be the same as the rank of the rest (${r})`)}),z.vA(t>=0&&t<r,()=>`Error in concat${r}D: axis must be between 0 and ${r-1}.`);let n=e[0];e.forEach((e,a)=>{for(let s=0;s<r;s++)z.vA(s===t||e[s]===n[s],()=>`Error in concat${r}D: Shape of tensors[${a}] (${e}) does not match the shape of the rest (${n}) along the non-concatenated axis ${a}.`)})}function tB(e,t){let r=e[0].slice();for(let n=1;n<e.length;n++)r[t]+=e[n][t];return r}var tW=r(39114),tV=r(30631);function tG(e,t,r){let n=[];if(null==r&&null==t)return n;if(null==t)for(;n.length<e+r.length;)n.push(-1);else n=t.slice();if(null==r)return n;if(e+r.length!==n.length)throw Error(`rt input.shape and shape=${t} are incompatible: rt input.rank = ${e+r.length}, but shape.rank = ${n.length}`);for(let a=1;a<r.length;++a){let s=r[a],i=n[n.length-r.length+a],o=n[i];if(s>=0)if(o>=0){if(o!==s)throw Error(`rt input.shape and shape=${t} are incompatible: rt input.shape[${a+e}] = ${s} but shape[${a+e}] = ${o}`)}else n[i]=s}return n}function tU(e){let t={FIRST_DIM_SIZE:i.FIRST_DIM_SIZE,VALUE_ROWIDS:i.VALUE_ROWIDS,ROW_LENGTHS:i.ROW_LENGTHS,ROW_SPLITS:i.ROW_SPLITS,ROW_LIMITS:i.ROW_LIMITS,ROW_STARTS:i.ROW_STARTS},r=[];for(let n of e)if(n in t)r.push(t[n]);else break;return r}function tZ(e){return 0===e.length?0:e[0]===i.FIRST_DIM_SIZE?e.length-1:e.length}function tj(e,t){if(null==e||null==t)return;let r=e.length,n=t.length;if(r>=n)throw Error(`defaultValue.shape=${e} and ragged tensor flatValues.shape=${t}, are incompatible: defaultValue.rank = ${r} must be less than ragged tensor input flatValues.rank = ${n})`);for(let a=0;a<Math.min(r,n-1);++a){let r=e[a],n=t[a+1];if(r>=0&&n>=0&&1!==r&&r!==n)throw Error(`defaultValue.shape=${e}, and ragged tensor input flatValues.shape=${t} are incompatible: defaultValue.shape[${a-e.length}] = ${r} but ragged tensor input.flatValues.shape[${a-e.length}] = ${n}`)}}!function(e){e[e.FIRST_DIM_SIZE=0]="FIRST_DIM_SIZE",e[e.VALUE_ROWIDS=1]="VALUE_ROWIDS",e[e.ROW_LENGTHS=2]="ROW_LENGTHS",e[e.ROW_SPLITS=3]="ROW_SPLITS",e[e.ROW_LIMITS=4]="ROW_LIMITS",e[e.ROW_STARTS=5]="ROW_STARTS"}(i||(i={}));let tH=30;function tK(e){return e<=tH?e:(0,z.lK)(e,Math.floor(Math.sqrt(e)))}function tY(e,t,r){return[r*("number"==typeof e?e:e[0]),t*("number"==typeof e?e:e[1])]}function tQ(e,t,r,n=!0){let a=[];if(n)(a=a.concat(t.slice(0))).push(e[0]/r),a=a.concat(e.slice(1));else{a=a.concat(e[0]);let r=t.length;for(let n=0;n<r;++n)a=a.concat([e[n+1]/t[n],t[n]]);a=a.concat(e.slice(r+1))}return a}function tq(e,t,r=!0){let n=[];if(r){n.push(t);for(let r=t+1;r<e;++r)r<=2*t?(n.push(r),n.push(r-(t+1))):n.push(r)}else{let r=[],a=[];for(let n=1;n<e;++n)n>=2*t+1||n%2==1?a.push(n):r.push(n);n.push(...r),n.push(0),n.push(...a)}return n}function tX(e,t,r,n=!0){let a=[];n?a.push(e[0]/r):a.push(e[0]*r);for(let r=1;r<e.length;++r)r<=t.length?n?a.push(t[r-1]*e[r]):a.push(e[r]/t[r-1]):a.push(e[r]);return a}function tJ(e,t){let r=[0];for(let n=0;n<t;++n)r.push(e[n][0]);return r}function t0(e,t,r){let n=e.slice(0,1);for(let a=0;a<r;++a)n.push(e[a+1]-t[a][0]-t[a][1]);return n}var t1=r(93473);let t2=.3275911,t3=.254829592,t4=-.284496736,t5=1.421413741,t6=-1.453152027,t7=1.061405429;var t9=r(63048);function t8(e,t){if(e.length!==t.length)throw Error(`Cannot merge real and imag arrays of different lengths. real:${e.length}, imag: ${t.length}.`);let r=new Float32Array(2*e.length);for(let n=0;n<r.length;n+=2)r[n]=e[n/2],r[n+1]=t[n/2];return r}function re(e){let t=new Float32Array(e.length/2),r=new Float32Array(e.length/2);for(let n=0;n<e.length;n+=2)t[n/2]=e[n],r[n/2]=e[n+1];return{real:t,imag:r}}function rt(e){let t=Math.ceil(e.length/4),r=new Float32Array(t),n=new Float32Array(t);for(let t=0;t<e.length;t+=4)r[Math.floor(t/4)]=e[t],n[Math.floor(t/4)]=e[t+1];return{real:r,imag:n}}function rr(e){let t=Math.floor(e.length/4),r=new Float32Array(t),n=new Float32Array(t);for(let t=2;t<e.length;t+=4)r[Math.floor(t/4)]=e[t],n[Math.floor(t/4)]=e[t+1];return{real:r,imag:n}}function rn(e,t){return{real:e[2*t],imag:e[2*t+1]}}function ra(e,t,r,n){e[2*n]=t,e[2*n+1]=r}function rs(e,t){let r=new Float32Array(e/2),n=new Float32Array(e/2);for(let a=0;a<Math.ceil(e/2);a++){let s=(t?2:-2)*Math.PI*(a/e);r[a]=Math.cos(s),n[a]=Math.sin(s)}return{real:r,imag:n}}function ri(e,t,r){let n=(r?2:-2)*Math.PI*(e/t);return{real:Math.cos(n),imag:Math.sin(n)}}let ro=/->/g;function rl(e,t){let r=((e=e.replace(/\s/g,"")).length-e.replace(ro,"").length)/2;if(r<1)throw Error("Equations without an arrow are not supported.");
117if(r>1)throw Error('Equation must contain exactly one arrow ("->").');let[n,a]=e.split("->");(0,z.vA)(-1===n.indexOf("..."),()=>'The ellipsis notation ("...") is not supported yet.');let s=n.split(","),i=s.length;if(t!==i)throw Error(`Expected ${i} input tensors, received ${t}`);if(i>2)throw Error("Support for more than 2 input tensors is not implemented yet.");let o=[];for(let e=0;e<a.length;++e){let t=a[e];if(!s.some(e=>-1!==e.indexOf(t)))throw Error(`Output subscripts contain the label ${t} not present in the input subscripts.`);-1===o.indexOf(t)&&o.push(t)}for(let e=0;e<n.length;++e){let t=n[e];-1===o.indexOf(t)&&","!==t&&o.push(t)}let l=Array(s.length);for(let e=0;e<i;++e){if(new Set(s[e].split("")).size!==s[e].length)throw Error(`Found duplicate axes in input component ${s[e]}. Support for duplicate axes in input is not implemented yet.`);l[e]=[];for(let t=0;t<s[e].length;++t)l[e].push(o.indexOf(s[e][t]))}let u=o.length,h=a.length,p=[];for(let e=h;e<u;++e)p.push(e);return{allDims:o,summedDims:p,idDims:l}}function ru(e,t){let r=Array(e);r.fill(-1);for(let e=0;e<t.length;++e)r[t[e]]=e;let n=[];for(let t=0;t<e;++t)-1===r[t]&&n.push(t);return{permutationIndices:r=r.filter(e=>-1!==e),expandDims:n}}function rh(e,t,r){let n=Array(e);for(let e=0;e<r.length;++e){let a=r[e].shape;for(let r=0;r<t[e].length;++r)void 0===n[t[e][r]]?n[t[e][r]]=a[r]:(0,z.vA)(n[t[e][r]]===a[r],()=>`Expected dimension ${n[t[e][r]]} at axis ${r} of input shaped ${JSON.stringify(a)}, but got dimension ${a[r]}`)}}function rp(e,t){let r=[],n=0;0===e.length&&e.push(-1),n=e.length+1;for(let e=0;e<n;++e)r.push([]);let a=[];for(let n=0;n<e.length;++n)for(let s of function(e,t){let r=[];for(let n=0;n<e.length;++n)(0===e[n].length||-1!==e[n].indexOf(t)||-1===t)&&r.push(n);return r}(t,e[n]))-1===a.indexOf(s)&&(r[n].push(s),a.push(s));return{path:e,steps:r}}function rd(e){return e.every((e,t)=>e===t)}function rc(e,t,r=0){let n=[];if("number"==typeof t)(0,z.vA)(e.shape[r]%t==0,()=>"Number of splits must evenly divide the axis."),n=Array(t).fill(e.shape[r]/t);else{let a=t.reduce((e,t)=>(-1===t&&(e+=1),e),0);(0,z.vA)(a<=1,()=>"There should be only one negative value in split array.");let s=t.indexOf(-1);if(-1!==s){let n=t.reduce((e,t)=>t>0?e+t:e);t[s]=e.shape[r]-n}(0,z.vA)(e.shape[r]===t.reduce((e,t)=>e+t),()=>"The sum of sizes must match the size of the axis dimension."),n=t}return n}function rf(e){return`Received SparseTensor with denseShape[0] = 0 but 118 indices.shape[0] = ${e}`}function rm(e,t){return`indices(${e}, 0) is invalid: ${t} < 0`}function rg(e,t,r){return`indices(${e}, 0) is invalid: ${t} >= ${r}`}function ry(e,t){return`only one output dimension may be -1, not both ${e} and ${t}`}function rb(e,t){return`size ${e} must be non-negative, not ${t}`}function rx(){return"reshape cannot infer the missing input size for an empty tensor unless all specified input sizes are non-zero"}function rv(e,t){let r=(0,z.Ze)(e),n=(0,z.Ze)(t);return`Input to reshape is a SparseTensor with ${r} 119 dense values, but the requested shape requires a multiple of ${n}. inputShape=${e} outputShape= ${t}`}function rw(e,t){let r=(0,z.Ze)(e),n=(0,z.Ze)(t);return`Input to reshape is a tensor with ${r} dense values, but the requested shape has ${n}. inputShape=${e} outputShape=${t}`}function rT(){return"segment ids must be >= 0"}function rS(){return"segment ids are not increasing"}function rN(e,t){return`Segment id ${e} out of range [0, ${t}), possibly because segmentIds input is not sorted.`}function rk(e,t,r){return`Bad: indices[${e}] == ${t} out of range [0, ${r})`}function rI(e,t){let r,n=!1;for(e<=tH?(r=e,n=!0):r=(0,z.lK)(e,Math.floor(Math.sqrt(e)));!n;)r>t||r===e?n=!0:r=(0,z.lK)(e,r+1);return r}function rC(e,t,r){let n=[],a=e.length;for(let s=0;s<a;s++)s!==t?n.push(e[s]):n.push(r);return n}function rE(e,t,r,n){let a=t.shape.length,s=e.shape.length;if(0!==n&&(n<-a||n>a))throw Error(`Expect batchDims in the range of [-${a}, ${a}], but got ${n}`);if(n<0&&(n+=a),n>s)throw Error(`batchDims (${n}) must be less than rank(x) ( 120 ${s}).`);if(r<n)throw Error(`batchDims (${n}) must be less than or equal to axis (${r}).`);for(let r=0;r<n;++r)if(e.shape[r]!==t.shape[r])throw Error(`x.shape[${r}]: ${e.shape[r]} should be equal to indices.shape[${r}]: ${t.shape[r]}.`);let i=e.shape[r],o=[],l=1,u=1,h=1;for(let t=0;t<n;++t)o.push(e.shape[t]),l*=e.shape[t];for(let t=n;t<r;t++)o.push(e.shape[t]),u*=e.shape[t];for(let e=n;e<a;e++)o.push(t.shape[e]);for(let t=r+1;t<s;t++)o.push(e.shape[t]),h*=e.shape[t];return{batchSize:l,sliceSize:h,outerSize:u,dimSize:i,outputShape:o}}function rA(e){try{return e.map(e=>(0,ty.decodeString)(e))}catch(e){throw Error(`Failed to decode encoded string bytes into utf-8, error: ${e}`)}}function r$(e){return e.map(e=>(0,ty.encodeString)(e))}var rF=r(10627),rR=r(19474),r_=r(15348);for(let e of[eC,eA,eR,eO,eM,eP,eL])eN(e)},52123:(e,t,r)=>{"use strict";r.d(t,{x:()=>o});var n=r(19041),a=r(48592),s=r(62176),i=r(68567);let o=(0,s.op)({depthwiseConv2dNativeBackpropFilter_:function(e,t,r,s,o,l=[1,1],u){let h=e;3===e.rank&&(h=(0,i.t)(e,[1,e.shape[0],e.shape[1],e.shape[2]]));let p=t;3===p.rank&&(p=(0,i.t)(t,[1,t.shape[0],t.shape[1],t.shape[2]]));let d={x:h,dy:p};return n.T2.runKernel(a.X$8,d,{strides:s,pad:o,dimRoundingMode:u,dilations:l,filterShape:r})}})},52285:(e,t,r)=>{"use strict";r.d(t,{G:()=>o});var n=r(19041),a=r(48592),s=r(27924),i=r(76526);let o=(0,r(62176).op)({batchToSpaceND_:function(e,t,r){let o=(0,s.YT)(e,"x","batchToSpaceND"),l=t.reduce((e,t)=>
120e*t);return i.vA(o.rank>=1+t.length,()=>`input rank is ${o.rank} but should be > than blockShape.length ${t.length}`),i.vA(r.length===t.length,()=>`crops.length is ${r.length} but should be equal to blockShape.length ${t.length}`),i.vA(o.shape[0]%l==0,()=>`input tensor batch is ${o.shape[0]} but is not divisible by the product of the elements of blockShape ${t.join(" * ")} === ${l}`),n.T2.runKernel(a.Ik2,{x:o},{blockShape:t,crops:r})}})},52536:(e,t,r)=>{"use strict";r.d(t,{m:()=>o,p:()=>l});var n=r(51520),a=r(3047),s=r(97344),i=r(14811);class o extends i.Wd{constructor(e){if(super({dtype:e.dtype,name:null!=e.name?e.name:(0,a.v)("input").toString()}),null==e.batchSize&&(e.batchSize=null),null==e.sparse&&(e.sparse=!1),this.trainable=!1,this.built=!0,this.sparse=e.sparse,null!=e.inputShape&&null!=e.batchInputShape)throw new s.Qp("Only provide the inputShape OR batchInputShape argument to inputLayer, not both at the same time.");let t=e.batchInputShape;if(null==t)if(null==e.inputShape)throw new s.Qp("An InputLayer should be passed either a `batchInputShape` or an `inputShape`.");else t=[e.batchSize].concat(e.inputShape);else if(null!=e.batchSize)throw new s.Qp("Cannot specify batchSize if batchInputShape is specified when creating an InputLayer.");let r=e.dtype||"float32";this.batchInputShape=t,this.dtype=r,this.inputSpec=[{shape:t}];let n=new i.Ar(this.dtype,this.batchInputShape,this,[],{},this.name);n.nodeIndex=0,n.tensorIndex=0,new i.bP({outboundLayer:this,inboundLayers:[],nodeIndices:[],tensorIndices:[],inputTensors:[n],outputTensors:[n],inputMasks:[null],outputMasks:[null],inputShapes:[t],outputShapes:[t]})}apply(e,t){throw new s.Qp(`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}}}function l(e){if(null==e.batchShape&&null==e.shape)throw Error("Please provide to Input either a `shape` or a `batchShape` argument. Note that `shape` does not include the batch dimension.");if(null!=e.batchShape&&null!=e.shape)throw new s.Qp("Please provide either a `shape` or `batchShape` argument to Input, but not both.");let t=e.batchShape;null!=e.shape&&null==t&&(t=[null].concat(e.shape));let r=e.dtype;return null==r&&(r="float32"),new o({batchInputShape:t,name:e.name,dtype:r,sparse:e.sparse}).inboundNodes[0].outputTensors[0]}o.className="InputLayer",n.JFn.registerClass(o)},52745:(e,t,r)=>{"use strict";r.d(t,{M:()=>function e(t,r){if(null==t)return null;if("string"==typeof t)return n.uc(t);if("number"==typeof t||"boolean"==typeof t)return t;if(t instanceof Array){let n=[],s=t.length;for(let i=0;i<s;++i){let s=t[i];a(r,i,s)?n.push(s):n.push(e(s,r))}return n}{let r={};for(let a of Object.keys(t)){let s=t[a],i=n.uc(a);("name"===a||"className"===a)&&"string"==typeof s?r[i]=s:r[i]=e(s,a)}return r}},w:()=>function e(t,r){if(null===t)return null;if("string"==typeof t)return n.Cb(t);if("number"==typeof t||"boolean"==typeof t)return t;if(t instanceof Array){let n=[],s=t.length;for(let i=0;i<s;++i){let s=t[i];a(r,i,s)?n.push(s):n.push(e(s,r))}return n}{let r={};for(let a of Object.keys(t)){let s=t[a];if("name"===a&&"string"==typeof s)r[a]=s;else{let t=n.Cb(a);r[t]=e(s,t)}}return r}}});var n=r(82692);function a(e,t,r){return("inboundNodes"===e||"outputLayers"===e||"inputLayers"===e)&&0===t&&"string"==typeof r}},52949:(e,t,r)=>{"use strict";r.d(t,{u:()=>s});var n=r(51520);function a(e,t){let r=e.slice(0,t);for(;r.length<t;)r.push(1);for(let n=t;n<e.length;n++)r[t-1]*=e[n];return r}function s(e,t,r,s,i,o,l,u){if(0===e.length)throw Error("paramsNestedSplits must be non empty");if(0===t[0].length)throw Error("Split tensors must not be scalars");let h=t[0][0]-1;if(o.forEach((e,t)=>{if(e<0||e>=h){let r=n.ZSL.indexToLoc(t,l.length,n.ZSL.computeStrides(l)).join(",");throw Error(`indices[${r}] = ${e} is not in [0, ${h})`)}}),0===s.length)throw Error("params.rank must be nonzero");let{outSplits:p,valueSlices:d,numValues:c}=function(e,t,r,n){let a=[],s=0,i=Array(t.length-1+r.length).fill(null).map(()=>[0]);for(let e=0;e<r.length;++e){let t=r[e],a=e===r.length-1?n:r[e+1].length;if(0===t.length)throw Error("Ragged splits may not be empty");if(t[0]<0)throw Error("Ragged splits must be non-negative");if(t[t.length-1]>a)throw Error("Ragged splits must not point past values");for(let e=1;e<t.length;++e)if(t[e-1]>t[e])throw Error("Ragged splits must be sorted in ascending order")}let o=1;for(let e=0;e<t.length-1;++e){o*=t[e];let r=t[e+1];for(let t=1;t<o+1;++t)i[e].push(t*r)}
120for(let n=0;n<e.length;++n){let o=e[n],l=e[n]+1;for(let e=0;e<r.length;++e){let n=r[e],a=e+t.length-1;if(a>=0){let e=i[a],t=e[e.length-1]-n[o];for(let e=o;e<l;++e)i[a].push(n[e+1]+t)}o=n[o],l=n[l]}l!==o&&(a.push([o,l]),s+=l-o)}return{outSplits:i,valueSlices:a,numValues:s}}(o,l,e,s[0]),f=function(e){let t=[];for(let r=0;r<e.length;++r){let a=e[r].length,s=n.ZSL.getArrayFromDType("int32",a);t.push(s),e[r].forEach((e,t)=>s[t]=e)}return t}(p),m=function(e,t,r,s,i){let o=t.slice();o[0]=i;let l=n.ZSL.getArrayFromDType(r,n.ZSL.sizeFromShape(o)),u=e.length,h=0===u?0:u/t[0];return!function(e,t,r,n,s,i){let o=a(t,2)[1],l=a(i,2)[1],u=0;for(let t of r)for(let r=t[0];r<t[1];++r){for(let t=0;t<n;++t)s[u*l+t]=e[r*o+t];++u}}(e,t,s,h,l,o),[l,o]}(r,s,i,d,c);return[f,m[0],m[1]]}},53147:(e,t,r)=>{"use strict";r.d(t,{Cf:()=>m,Op:()=>h,_5:()=>l,iP:()=>c,kr:()=>d,rY:()=>f,tA:()=>p,vQ:()=>u});var n=r(89215),a=r(12534),s=r(63048);let i=(0,a.m)("kernelRegistry",()=>new Map),o=(0,a.m)("gradRegistry",()=>new Map);function l(e,t){let r=g(e,t);return i.get(r)}function u(e){return o.get(e)}function h(e){let t=i.entries(),r=[];for(;;){let{done:n,value:a}=t.next();if(n)break;let[s,i]=a,[o]=s.split("_");o===e&&r.push(i)}return r}function p(e){let{kernelName:t,backendName:r}=e,n=g(t,r);i.has(n)&&s.i(`The kernel '${t}' for backend '${r}' is already registered`),i.set(n,e)}function d(e){let{kernelName:t}=e;o.has(t)&&(0,n._K)().getBool("DEBUG")&&s.i(`Overriding the gradient for '${t}'`),o.set(t,e)}function c(e,t){let r=g(e,t);if(!i.has(r))throw Error(`The kernel '${e}' for backend '${t}' is not registered`);i.delete(r)}function f(e){if(!o.has(e))throw Error(`The gradient '${e}' for backend is not registered`);o.delete(e)}function m(e,t){h(e).forEach(e=>{p(Object.assign({},e,{backendName:t}))})}function g(e,t){return`${t}_${e}`}},53777:(e,t,r)=>{"use strict";r.d(t,{z:()=>l});var n=r(19041),a=r(48592),s=r(27924),i=r(76526),o=r(45382);let l=(0,r(62176).op)({clipByValue_:function(e,t,r){let l=(0,s.YT)(e,"x","clipByValue");return(i.vA(t<=r,()=>`Error in clip: min (${t}) must be less than or equal to max (${r}).`),t===r)?(0,o.G)(l.shape,t,l.dtype):n.T2.runKernel(a.vaV,{x:l},{clipValueMin:t,clipValueMax:r})}})},53858:(e,t,r)=>{"use strict";r.d(t,{g:()=>i});var n=r(19041),a=r(48592),s=r(27924);let i=(0,r(62176).op)({cos_:function(e){let t=(0,s.YT)(e,"x","cos","float32");return n.T2.runKernel(a.Mn0,{x:t})}})},55648:(e,t,r)=>{"use strict";r.d(t,{AL:()=>l,cl:()=>i});var n=r(51520),a=r(16986),s=r(75017);let i=(0,a.Z)((e,t)=>+(e!==t)),o=(0,s.j)(n.ylV,i,null,"bool"),l={kernelName:n.ylV,backendName:"cpu",kernelFunc:o}},55865:(e,t,r)=>{"use strict";r.d(t,{V:()=>i});var n=r(19041),a=r(48592),s=r(27924);let i=(0,r(62176).op)({relu_:function(e){let t=(0,s.YT)(e,"x","relu");return n.T2.runKernel(a.fUj,{x:t})}})},56991:(e,t,r)=>{"use strict";r.d(t,{O:()=>p,c:()=>c});var n=r(51520),a=r(70333),s=r(97344),i=r(65952),o=r(82692),l=r(43398);function u(e,t){let r,a;r=t.xs,a=t.ys,n.ZSL.assert(null!=r&&null!=a,()=>`A Dataset iterator for fitDataset() is expected to generate objects of the form \`{xs: xVal, ys: yVal}\`, where the two values may be \`tf.Tensor\`, an array of Tensors, or a map of string to Tensor. The provided Dataset instead generates ${t}`);let s=h("input",e.inputNames,r),i=h("output",e.outputNames,a),o=s[0].shape[0];n.ZSL.assert(s.length===e.inputs.length,()=>`LayersModel has ${e.inputs.length} inputs, but the dataset provides ${s.length} inputs. (Expected input keys: ${JSON.stringify(e.inputNames)})`),n.ZSL.assert(i.length===e.outputs.length,()=>`LayersModel has ${e.outputs.length} outputs, but the dataset provides ${i.length} outputs. (Expected output keys: ${JSON.stringify(e.outputNames)})`);for(let t=0;t<s.length;t++)n.ZSL.assert(s[t].shape[0]===o,()=>`Batch size mismatch: input ${e.inputNames[t]} has ${s[t].shape[0]}; expected ${o} based on input ${e.inputNames[0]}.`);for(let t=0;t<i.length;t++)n.ZSL.assert(i[t].shape[0]===o,()=>`Batch size mismatch: output ${e.outputNames[t]} has ${i[t].shape[0]}; expected ${o} based on input ${e.inputNames[0]}.`);return{xs:s,ys:i}}function h(e,t,r){if(r instanceof n.qYS)return[r];if(Array.isArray(r))return n.ZSL.assert(r.length===t.length,()=>`Received an array of ${r.length} Tensors, but expected ${t.length} to match the ${e} keys ${t}.`),r;{let n=[];for(let a of t){if(null==r[a])throw new s.Qp(`The feature data generated by the dataset lacks the required ${e} key '${a}'.`);n.push(r[a])}return n}}async function p(e,t,r){let h=null!=r.batchesPerEpoch;if(n.ZSL.assert(null!=e.optimizer,()=>"You must compile a model before training/testing. Use LayersModel.compile(modelCompileConfig)."),n.ZSL.assert(null!=r,()=>"For fitDataset(), the 2nd argument (config) is required, but it is not provided in this call."),n.ZSL.assert(null!=r.epochs&&r.epochs>0&&Number.isInteger(r.epochs),()=>`For fitDataset(), config.epochs is expected to be a positive integer, but got ${r.epochs}`),n.ZSL.assert(!h||r.batchesPerEpoch>0&&Number.isInteger(r.batchesPerEpoch),()=>`For fitDataset(), config.batchesPerEpoch is expected to be a positive integer if specified, but got ${r.batchesPerEpoch}`),n.ZSL.assert(null==r.validationSplit,()=>"`validationSplit` is not supported by `fitDataset()`. Use validationData instead."),e.isTraining)throw Error("Cannot start training because another fit() call is ongoing.");e.isTraining=!0;try{var p,c;let f,m,g,y,b=null!=r.validationData;if(b)if(d(r.validationData))n.ZSL.assert(null==r.validationBatches||r.validationBatches>
1200&&Number.isInteger(r.validationBatches),()=>`For fitDataset() with dataset-based validation, config.validationBatches is expected not to be provided, or to be a positive integer, but got ${r.validationBatches}`);else{let e=function(e){if(3===e.length)throw new s.EH("Validation with sample weights is not implemented yet.");return{xs:e[0],ys:e[1]}}(r.validationData);f=e.xs,m=e.ys}let x=e.makeTrainFunction(),v=e.getDedupedMetricsNames();g=b?v.slice().concat(v.map(e=>"val_"+e)):v.slice();let w=(0,a.Eq)(r.callbacks,r.yieldEvery),T=null==r.verbose?1:r.verbose,{callbackList:S,history:N}=(0,a.dY)(w,T,r.epochs,null,null,(p=t,c=r,y=null,null!=c.batchesPerEpoch?y=c.batchesPerEpoch:Number.isFinite(p.size)&&(y=p.size),y),null,b,g);S.setModel(e),e.history=N,await S.onTrainBegin(),e.stopTraining_=!1;let k=null==r.initialEpoch?0:r.initialEpoch,I=await t.iterator();for(;k<r.epochs;){let a={};await S.onEpochBegin(k);let s=0,p=0;for(h||(I=await t.iterator());!h||s<r.batchesPerEpoch;){let t=await I.next();if(h&&t.done){console.warn(`You provided \`batchesPerEpoch\` as ${r.batchesPerEpoch}, but your dataset iterator ran out of data after ${s} batches; interrupting training. Make sure that your dataset can generate at least \`batchesPerEpoch * epochs\` batches (in this case, ${r.batchesPerEpoch*r.epochs} batches). You may need to use the repeat() function when building your dataset.`);break}if(null!=t.value){let{xs:a,ys:o}=u(e,t.value),h={};h.batch=p,h.size=a[0].shape[0],await S.onBatchBegin(p,h);let d=[];if(null!=r.classWeight){let t=(0,l.zO)(r.classWeight,e.outputNames);for(let e=0;e<t.length;++e)d.push(await (0,l.tP)(o[e],null,t[e]))}let c=a.concat(o).concat(d),f=x(c);n.ASo(c);for(let e=0;e<v.length;++e){let t=v[e],r=f[e];h[t]=r,n.aCs(r)}await S.onBatchEnd(p,h),(0,i.i)(h),p++,s++}if(h?s>=r.batchesPerEpoch:t.done){if(b){let t;t=d(r.validationData)?(0,o.st)(await e.evaluateDataset(r.validationData,{batches:r.validationBatches})):(0,o.st)(e.evaluate(f,m,{batchSize:null==r.validationBatchSize?32:r.validationBatchSize,verbose:0}));for(let r=0;r<e.metricsNames.length;++r)a[`val_${e.metricsNames[r]}`]=t[r]}break}if(e.stopTraining_)break}if(await S.onEpochEnd(k,a),k++,e.stopTraining_)break}return await S.onTrainEnd(),await e.history.syncData(),e.history}finally{e.isTraining=!1}}function d(e){return"function"==typeof e.iterator}async function c(e,t,r){let a=null!=(r=r||{}).batches,i=e.testFunction,l=[];if(r.verbose>0)throw new s.EH("Verbose mode is not implemented yet.");n.ZSL.assert(!a||r.batches>0&&Number.isInteger(r.batches),()=>`Test loop expects \`batches\` to be a positive integer, but received ${JSON.stringify(r.batches)}`);let h="function"==typeof t.next?t:await t.iterator(),p=0,d=0;for(;!a||d<r.batches;){let t=await h.next();if(l=n.DZQ(()=>{if(t.value){let{xs:r,ys:a}=u(e,t.value),s=r.concat(a),o=n.DZQ(()=>i(s));if(n.ASo(s),0===d)for(let e=0;e<o.length;++e)l.push((0,n.d_2)(0));let h=s[0].shape[0];for(let e=0;e<o.length;++e){let t=o[e],r=l[e];l[e]=n.DZQ(()=>n.WQq(l[e],n.lKK(h,t))),d>0&&n.ASo(r)}n.ASo(o),p+=h,++d}return l}),t.done){a&&console.warn(`Your dataset iterator ran out of data during evaluateDataset(). Interrupting evalution. Make sure that your dataset can generate at least \`batches\` batches (in this case, ${r.batches} batches). You may need to use the repeat() function when building your dataset.`);break}}for(let e=0;e<l.length;++e){let t=l[e];l[e]=n.y4m(l[e],p),n.ASo(t)}return(0,o.wL)(l)}},57290:(e,t,r)=>{"use strict";r.d(t,{Q:()=>o});var n=r(19041),a=r(17831),s=r(76526),i=r(47537);function o(e,t,r,o){if(null==o)o=(0,s.X$)(e);else if("complex64"===o)throw Error("Cannot construct a complex64 tensor directly. Please use tf.complex(real, imag).");if((0,a.Nw)(e)||(0,a.Oj)(e)){if("float32"!==o&&"int32"!==o)throw Error(`Creating tensor from GPU data only supports 'float32'|'int32' dtype, while the dtype is ${o}.`);return n.T2.backend.createTensorFromGPUData(e,t||r,o)}if(!(0,i.isTypedArray)(e)&&!Array.isArray(e)&&"number"!=typeof e&&"boolean"!=typeof e&&"string"!=typeof e)throw Error("values passed to tensor(values) must be a number/boolean/string or an array of numbers/booleans/strings, or a TypedArray");if(null!=t){(0,s.SA)(t);let e=(0,s.Ze)(t),n=(0,s.Ze)(r);(0,s.vA)(e===n,()=>`Based on the provided shape, [${t}], the tensor should have ${e} values but has ${n}`);for(let e=0;e<r.length;++e){let n=r[e],a=e!==r.length-1||n!==(0,s.Ze)(t.slice(e));(0,s.vA)(r[e]===t[e]||!a,()=>`Error creating a new Tensor. Inferred shape (${r}) does not match the provided shape (${t}). `)}}return(0,i.isTypedArray)(e)||Array.isArray(e)||(e=[e]),t=t||r,e="string"!==o?(0,i.toTypedArray)(e,o):(0,i.flatten)(e,[],!0),n.T2.makeTensor(e,t,o)}},57568:(e,t,r)=>{"use strict";r.d(t,{Ml:()=>p,ct:()=>u,wg:()=>h});var n=r(51520),a=r(16986),s=r(22780),i=r(63405),o=r(88185),l=r(97175);function u(e,t,r,s){if("int32"===s)return[t,"int32",Int32Array.from(e)];if("bool"===s){let s=n.ZSL.toTypedArray([0],r),[i,o]=(0,a.Z)((e,t)=>+(e!==t))(t,[],e,s,"bool");return[o,"bool",i]}throw Error(`Error in Cast: failed to cast ${r} to ${s}`)}function h(e){let{inputs:t,backend:r,attrs:a}=e,{x:p}=t,{dtype:d}=a;if("complex64"===d){if("complex64"===p.dtype)return(0,o.D)({inputs:{x:p},backend:r});let e=(0,s.U)(r,p.shape,p.dtype),t=h({inputs:{x:p},backend:r,attrs:{dtype:"float32"}}
120),n=(0,i.f)({inputs:{real:t,imag:e},backend:r});return r.disposeIntermediateTensorInfo(e),r.disposeIntermediateTensorInfo(t),n}if("complex64"===p.dtype){let e=(0,l.x)({inputs:{input:p},backend:r}),t=h({inputs:{x:e},backend:r,attrs:{dtype:d}});return r.disposeIntermediateTensorInfo(e),t}if(!n.ZSL.hasEncodingLoss(p.dtype,d)){let e=(0,o.D)({inputs:{x:p},backend:r});return{dataId:e.dataId,shape:e.shape,dtype:d}}let[c,f,m]=u(r.data.get(p.dataId).values,p.shape,p.dtype,d);return r.makeTensorInfo(c,f,m)}let p={kernelName:n.KXH,backendName:"cpu",kernelFunc:h}},57690:(e,t,r)=>{"use strict";r.d(t,{S:()=>function e(t,r="float32"){if((0,a.SA)(t),"complex64"===r){let r=e(t,"float32"),n=(0,i.U)(t,"float32");return(0,s.f)(r,n)}let o=(0,a.FZ)((0,a.Ze)(t),r);return n.T2.makeTensor(o,t,r)}});var n=r(19041),a=r(76526),s=r(46213),i=r(59918)},58151:(e,t,r)=>{"use strict";r.d(t,{K:()=>l});var n=r(51520),a=n.C0T.RowPartitionType;class s{constructor(e,t,r,a,s,i,o,l,u,h){this.shape=e,this.shapeShape=t,this.values=r,this.valuesShape=a,this.valuesDType=s,this.defaultValue=i,this.defaultValueShape=o,this.rowPartitionValues=l,this.rowPartitionValuesShapes=u,this.rowPartitionTypes=n.C0T.getRowPartitionTypesHelper(h),this.raggedRank=n.C0T.getRaggedRank(this.rowPartitionTypes)}getRowPartitionTypeByDimension(e){return this.rowPartitionTypes[0]===a.FIRST_DIM_SIZE?this.rowPartitionTypes[e+1]:this.rowPartitionTypes[e]}getRowPartitionTensor(e){return this.rowPartitionTypes[0]===a.FIRST_DIM_SIZE?this.rowPartitionValues[e+1]:this.rowPartitionValues[e]}getMaxWidth(e){let t=this.getRowPartitionTensor(e-1);switch(this.getRowPartitionTypeByDimension(e-1)){case a.VALUE_ROWIDS:return s.getMaxWidthValueRowID(t);case a.ROW_SPLITS:return s.getMaxWidthRowSplit(t);default:throw Error(`Cannot handle partition type ${a[this.getRowPartitionTypeByDimension(e-1)]}`)}}static getMaxWidthRowSplit(e){let t=e.length;if(0===t||1===t)return 0;let r=0;for(let n=0;n<t-1;++n){let t=e[n+1]-e[n];t>r&&(r=t)}return r}static getMaxWidthValueRowID(e){let t=e.length;if(0===t)return 0;let r=0,n=e[0],a=0;for(let s=1;s<t;++s){let t=e[s];t!==n&&(n=t,a=Math.max(s-r,a),r=s)}return Math.max(t-r,a)}tensorShapeFromTensor(e,t,r=!0){if(0===t.length){if(-1===e[0])return[];throw Error("The only valid scalar shape tensor is the fully unknown shape specified as -1.")}return o(e,r)}calculateOutputSize(e){let t=this.valuesShape,r=this.defaultValueShape;n.C0T.validateDefaultValueShape(r,t);let a=this.tensorShapeFromTensor(this.shape,this.shapeShape),s=n.C0T.combineRaggedTensorToTensorShapes(this.raggedRank,a,t);s[0]<0&&(s[0]=e);for(let e=1;e<=this.raggedRank;++e)s[e]<0&&(s[e]=this.getMaxWidth(e));return s}calculateFirstParentOutputIndex(e,t,r){let a=Math.min(e,r),s=[],i=0;for(let e=0;e<a;++e,i+=t)s.push(i);for(let t=a;t<e;++t)s.push(-1);return n.ZSL.assert(s.length===e,()=>"Final length of result must be equal to firstDimension."),s}calculateOutputIndexRowSplit(e,t,r,n){let a=e.length,s=[];for(let i=0;i<a-1;++i){let a=e[i+1]-e[i],o=Math.min(n,a),l=t[i];-1===l&&(o=0);for(let e=0;e<o;++e)s.push(l),l+=r;for(let e=0;e<a-o;++e)s.push(-1)}if(a>0&&s.length!==e[a-1])throw Error("Invalid row split size.");return s}calculateOutputIndexValueRowID(e,t,r,n){let a=e.length,s=[];if(0===a)return[];let i=0,o=e[0];if(o>=t.length)throw Error(`Got currentValueRowId=${o}, which is not less than ${t.length}`);let l=t[o];s.push(l);for(let u=1;u<a;++u){let a=e[u];if(a===o)l>=0&&(++i<n?l+=r:l=-1);else{if(i=0,o=a,a>=t.length)throw Error(`Got nextValueRowId=${a} which is not less than ${t.length}`);l=t[a]}s.push(l)}if(s.length!==e.length)throw Error("Invalid row ids.");return s}calculateOutputIndex(e,t,r,n){let s=this.getRowPartitionTensor(e),i=this.getRowPartitionTypeByDimension(e);switch(i){case a.VALUE_ROWIDS:return this.calculateOutputIndexValueRowID(s,t,r,n);case a.ROW_SPLITS:if(s.length-1>t.length)throw Error(`Row partition size is greater than output size: ${s.length-1} > ${t.length}`);return this.calculateOutputIndexRowSplit(s,t,r,n);default:throw Error(`Unsupported partition type: ${a[i]}`)}}getFirstDimensionSize(){let e=this.rowPartitionValues[0];if(0===this.rowPartitionTypes.length)throw Error("No row_partition_types given.");let t=this.rowPartitionTypes[0];switch(t){case a.FIRST_DIM_SIZE:return e[0];case a.VALUE_ROWIDS:throw Error("Cannot handle VALUE_ROWIDS in first dimension.");case a.ROW_SPLITS:return this.rowPartitionValuesShapes[0][0]-1;default:throw Error(`Cannot handle type ${a[t]}`)}}compute(){if(this.rowPartitionValues[0].length<=0)throw Error("Invalid first partition input. Tensor requires at least one element.");let e=this.getFirstDimensionSize(),t=this.calculateOutputSize(e),r=Array(this.raggedRank+1);r[r.length-1]=1;for(let e=r.length-2;e>=0;--e)r[e]=r[e+1]*t[e+1];let a=o(t,!1),s=n.ZSL.getArrayFromDType(this.valuesDType,n.ZSL.sizeFromShape(a));if(r[0]*t[0]>0){let n=this.calculateFirstParentOutputIndex(e,r[0],t[0]);for(let e=1;e<=this.raggedRank;++e)n=this.calculateOutputIndex(e-1,n,r[e],t[e]);this.setOutput(this.raggedRank,n,s,a)}return[a,s]}setOutput(e,t,r,a){if(0===r.length)return;let s=this.values,o=a.slice();o=o.slice(e+1);let l=n.ZSL.sizeFromShape(o),u=t.length,h=this.defaultValue;if(h.length!==l&&1!==h.length){let e=this.defaultValueShape;(0,n.DZQ)(()=>{let t=(0,n.tQQ)(h,e);h=(0,n.hOW)(t,o).dataSync()})}let p=0,d=0,c=0;for(let e=0;e<=u;++e){let n=e<u?t[e]:-1;if(n===c){++c;continue}if(d<c){let e=s.subarray(p*l);i(r.subarray(d*l),e,(c-d)*l)}if(e>=u&&(n=Math.floor(r.length/l)),n>c)if(1===this.defaultValue.length)r.subarray(c*l,n*l).fill(this.defaultValue[0]),c=n;else for(;n>c;)i(r.slice(c*l),h,l),++c;n<0?(p=e+1,d=c):(p=e,c=(d=c)+1)}}}function i(e,t,r){for(let n=0;n<r;n++)e[n]=t[n]}function o(e,t){let r=[];for(let n of e){if(n<0){if(!t)throw Error(`Dimension ${n} must be >= 0`);if(n<-1)throw Error(`Dimension ${n} must be >= -1`);n=-1}r.push(n)}return r}function l(e,t,r,n,a,i,o,l,u,h){return new s(e,t,r,n,a,i,o,l,u,h).c
120ompute()}},58521:(e,t,r)=>{"use strict";r.d(t,{c:()=>l});var n=r(14811),a=r(51520),s=r(1560),i=r(97344),o=r(90556);class l extends n.Wd{constructor(e){super(e),this.numTokens=e.numTokens,e.outputMode?this.outputMode=e.outputMode:this.outputMode="multiHot"}getConfig(){let e={numTokens:this.numTokens,outputMode:this.outputMode};return Object.assign(e,super.getConfig()),e}computeOutputShape(e){return null==(e=(0,s.U$)(e))?[this.numTokens]:("oneHot"===this.outputMode&&1!==e[e.length-1]?e.push(this.numTokens):e[e.length-1]=this.numTokens,e)}call(e,t){return(0,a.DZQ)(()=>{let r;if("int32"!==(e=(0,s.un)(e)).dtype&&(e=o.wg(e,"int32")),void 0!==t.countWeights){if("count"!==this.outputMode)throw new i.Qp(`countWeights is not used when outputMode !== count. 121 Received countWeights=${t.countWeights}`);r=(0,s.un)(t.countWeights)}let n=(0,a.T9B)(e),l=(0,a.jkA)(e),u=(0,a.rhj)(this.numTokens,n).bufferSync().get(0),h=(0,a.DQN)(l,0).bufferSync().get(0);if(!(u&&h))throw new i.Qp(`Input values must be between 0 < values <= numTokens with numTokens=${this.numTokens}`);return function(e,t,r,n){let l,u=(0,s.un)(e);if("int32"!==u.dtype&&(u=o.wg(u,"int32")),"int"===t)return u;let h=u.shape;if(0===u.rank&&(u=(0,a.UG6)(u,-1)),"oneHot"===t&&1!==u.shape[u.shape.length-1]&&(u=(0,a.UG6)(u,-1)),u.rank>2)throw new i.Qp(`When outputMode is not int, maximum output rank is 2 Received outputMode ${t} and input shape ${h} which would result in output rank ${u.rank}.`);let p=["multiHot","oneHot"].includes(t),d=u;if(l=void 0!==n&&"count"===t?(0,a.aOp)(d,n,r,p):(0,a.aOp)(d,[],r,p),"tfIdf"!==t)return l;if(n)return(0,a.lKK)(l,n);throw new i.Qp("When outputMode is 'tfIdf', weights must be provided.")}(e,this.outputMode,this.numTokens,r)})}}l.className="CategoryEncoding",a.JFn.registerClass(l)},59307:(e,t,r)=>{"use strict";r.d(t,{w:()=>s});var n=r(27924),a=r(78213);let s=(0,r(62176).op)({conv2dTranspose_:function(e,t,r,s,i,o){let l=(0,n.YT)(e,"x","conv2dTranspose"),u=(0,n.YT)(t,"filter","conv2dTranspose");return(0,a.v)(r,l,u,s,i,"NHWC",o)}})},59454:(e,t,r)=>{"use strict";r.d(t,{WR:()=>i,YW:()=>l});var n=r(51520),a=r(16986),s=r(75017);let i=(0,a.Z)((e,t)=>+(e<t)),o=(0,s.j)(n.mIA,i,null,"bool"),l={kernelName:n.mIA,backendName:"cpu",kernelFunc:o}},59591:(e,t,r)=>{"use strict";r.d(t,{F:()=>i});var n=r(19041),a=r(48592),s=r(27924);let i=(0,r(62176).op)({acosh_:function(e){let t=(0,s.YT)(e,"x","acosh");return n.T2.runKernel(a.PH8,{x:t})}})},59744:(e,t,r)=>{"use strict";r.d(t,{A:()=>o});var n=r(19041),a=r(48592),s=r(27924),i=r(76526);let o=(0,r(62176).op)({unique_:function(e,t=0){let r=(0,s.YT)(e,"x","unique","string_or_numeric");(0,i.vA)(r.rank>0,()=>"The input tensor must be at least 1D");let[o,l]=n.T2.runKernel(a.EwU,{x:r},{axis:t});return{values:o,indices:l}}})},59918:(e,t,r)=>{"use strict";r.d(t,{U:()=>function e(t,r="float32"){if((0,a.SA)(t),"complex64"===r){let r=e(t,"float32"),n=e(t,"float32");return(0,s.f)(r,n)}let i=(0,a.Ty)((0,a.Ze)(t),r);return n.T2.makeTensor(i,t,r)}});var n=r(19041),a=r(76526),s=r(46213)},60058:(e,t,r)=>{"use strict";r.d(t,{_:()=>o});var n=r(19041),a=r(48592),s=r(27924),i=r(16488);let o=(0,r(62176).op)({prod_:function(e,t=null,r=!1){let o=(0,s.YT)(e,"x","prod");"bool"===o.dtype&&(o=(0,i.w)(o,"int32"));let l={x:o};return n.T2.runKernel(a.kdj,l,{axis:t,keepDims:r})}})},60217:(e,t,r)=>{"use strict";r.d(t,{BB:()=>n,EX:()=>l,EZ:()=>d,GM:()=>u,NO:()=>h,PM:()=>p,Qn:()=>o,j:()=>s,tT:()=>a});var n,a,s,i=r(51520);function o(e,t){return[t,e]}function l(e,t){return e*t}function u(e){let t=Math.ceil(i.ZSL.sizeFromShape(e)/4);return i.ZSL.sizeToSquarishShape(t)}function h(e,t){return[Math.max(1,Math.ceil(t/2)),Math.max(1,Math.ceil(e/2))]}function p(e,t){let[r,n]=h(e,t);return r*n*4}function d(e,t){let r,n,a,s,o,l,u,h,p,d;return 2===(0,i._K2)().getNumber("WEBGL_VERSION")?(r=e.R32F,n=e.R16F,a=e.RGBA16F,s=e.RGBA32F,o=e.RED,u=4,h=1,p=e.HALF_FLOAT,d=e.FLOAT,l=e.RGBA8):(r=e.RGBA,n=e.RGBA,a=e.RGBA,s=e.RGBA,o=e.RGBA,u=4,h=4,p=null!=t?t.HALF_FLOAT_OES:null,d=e.FLOAT,l=e.RGBA),{internalFormatFloat:r,internalFormatHalfFloat:n,internalFormatPackedHalfFloat:a,internalFormatPackedFloat:s,textureFormatFloat:o,downloadTextureFormat:l,downloadUnpackNumChannels:u,defaultNumChannels:h,textureTypeHalfFloat:p,textureTypeFloat:d}}!function(e){e[e.DENSE=0]="DENSE",e[e.SHARED_BATCH=1]="SHARED_BATCH"}(n||(n={})),function(e){e[e.RENDER=0]="RENDER",e[e.UPLOAD=1]="UPLOAD",e[e.PIXELS=2]="PIXELS",e[e.DOWNLOAD=3]="DOWNLOAD"}(a||(a={})),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"}(s||(s={}))},60218:(e,t,r)=>{"use strict";r.d(t,{qY:()=>m,yl:()=>u,rT:()=>y,tp:()=>g,B4:()=>f,Q5:()=>c,qP:()=>d});var n=r(12534),a=r(76526);function s(e,t,r){let n;return n=Array.isArray(e)?`${parseFloat(e[0].toFixed(7))} + ${parseFloat(e[1].toFixed(7))}j`:(0,a.Kg)(e)?`'${e}'`:"bool"===r?i(e):parseFloat(e.toFixed(7)).toString(),(0,a.av)(n,t)}function i(e){return 0===e?"false":"true"}function o(e){let t=[];for(let r=0;r<e.length;r+=2)t.push([e[r],e[r+1]]);return t}var l=r(47537);class u{constructor(e,t,r){if(this.dtype=t,this.shape=e.slice(),this.size=a.Ze(e),null!=r){let e=r.length;a.vA(e===this.size,()=>`Length of values '${e}' does not match the size inferred by the shape '${this.size}'.`)}if("complex64"===t)throw 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=r||a.Ab(t,this.size),this.strides=(0,a.Ur)(e)}set(e,...t){0===t.length&&(t=[0]),a.vA(t.length===this.rank,()=>`The number of provided coordinates (${t.length}) must match the rank (${this.rank})`);let r=this.locToIndex(t);this.values[r]=e}get(...e){0===e.length&&(e=[0]);let t=0;for(let r of e){if(r<0||r>=this.shape[t])throw Error(`Requested out of range element at ${e}. Buffer shape=${this.shape}`);t++}let r=e[e.length-1];for(let t=0;t<e.length-1;++t)r+=this.strides[t]*e[t];return this.values[r]}locToIndex(e){if(0===this.rank)return 0;if(1===this.rank)return e[0];let t=e[e.length-1];for(let r=0;r<e.length-1;++r)t+=this.strides[r]*e[r];return t}indexToLoc(e){if(0===this.rank)return[];if(1===this.rank)return[e];let t=Array(this.shape.length);for(let r=0;r<t.length-1;++r)t[r]=Math.floor(e/this.strides[r]),e-=t[r]*this.strides[r];return t[t.length-1]=e,t}get rank(){return this.shape.length}toTensor(){return h().makeTensor(this.values,this.shape,this.dtype)}}let h=null,p=null;function d(e){h=e}function c(e){p=e}function f(e){}class m{constructor(e,t,r,n){this.kept=!1,this.isDisposedInternal=!1,this.shape=e.slice(),this.dtype=t||"float32",this.size=a.Ze(e),this.strides=(0,a.Ur)(e),this.dataId=r,this.id=n,this.rankType=this.rank<5?this.rank.toString():"higher"}get rank(){return this.shape.length}async buffer(){let e=await this.data();return p.buffer(this.shape,this.dtype,e)}bufferSync(){return p.buffer(this.shape,this.dtype,this.dataSync())}async array(){let e=await this.data();return(0,a.yw)(this.shape,e,"complex64"===this.dtype)}arraySync(){return(0,a.yw)(this.shape,this.dataSync(),"complex64"===this.dtype)}async data(){this.throwIfDisposed();let e=h().read(this.dataId);if("string"===this.dtype){let t=await e;
121try{return t.map(e=>l.decodeString(e))}catch(e){throw Error("Failed to decode the string bytes into utf-8. To get the original bytes, call tensor.bytes().")}}return e}dataToGPU(e){return this.throwIfDisposed(),h().readToGPU(this.dataId,e)}dataSync(){this.throwIfDisposed();let e=h().readSync(this.dataId);if("string"===this.dtype)try{return e.map(e=>l.decodeString(e))}catch(e){throw 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 h().read(this.dataId);return"string"===this.dtype?e:new Uint8Array(e.buffer)}dispose(){this.isDisposed||(this.kerasMask&&this.kerasMask.dispose(),h().disposeTensor(this),this.isDisposedInternal=!0)}get isDisposed(){return this.isDisposedInternal}throwIfDisposed(){if(this.isDisposed)throw Error("Tensor is disposed.")}print(e=!1){return p.print(this,e)}clone(){return this.throwIfDisposed(),p.clone(this)}toString(e=!1){return function(e,t,r,n){let l=(0,a.Ur)(t),u=function(e,t,r,n){let i=(0,a.Ze)(t),l=n[n.length-1],u=Array(l).fill(0),h=t.length,p="complex64"===r?o(e):e;if(h>1)for(let e=0;e<i/l;e++){let t=e*l;for(let e=0;e<l;e++)u[e]=Math.max(u[e],s(p[t+e],0,r).length)}return u}(e,t,r,l),h=t.length,p=function e(t,r,n,a,l,u=!0){let h="complex64"===n?2:1,p=r[0],d=r.length;if(0===d)return"complex64"===n?[s(o(t)[0],0,n)]:"bool"===n?[i(t[0])]:[t[0].toString()];if(1===d){if(p>20){let e=Array.from(t.slice(0,3*h)),r=Array.from(t.slice((p-3)*h,p*h));return"complex64"===n&&(e=o(e),r=o(r)),["["+e.map((e,t)=>s(e,l[t],n)).join(", ")+", ..., "+r.map((e,t)=>s(e,l[p-3+t],n)).join(", ")+"]"]}return["["+("complex64"===n?o(t):Array.from(t)).map((e,t)=>s(e,l[t],n)).join(", ")+"]"]}let c=r.slice(1),f=a.slice(1),m=a[0]*h,g=[];if(p>20){for(let r=0;r<3;r++){let a=r*m,s=a+m;g.push(...e(t.slice(a,s),c,n,f,l,!1))}g.push("...");for(let r=p-3;r<p;r++){let a=r*m,s=a+m;g.push(...e(t.slice(a,s),c,n,f,l,r===p-1))}}else for(let r=0;r<p;r++){let a=r*m,s=a+m;g.push(...e(t.slice(a,s),c,n,f,l,r===p-1))}let y=2===d?",":"";g[0]="["+(p>0?g[0]+y:"");for(let e=1;e<g.length-1;e++)g[e]=" "+g[e]+y;let b=",\n";for(let e=2;e<d;e++)b+="\n";return g[g.length-1]=" "+g[g.length-1]+"]"+(u?"":b),g}(e,t,r,l,u),d=["Tensor"];return n&&(d.push(` dtype: ${r}`),d.push(` rank: ${h}`),d.push(` shape: [${t}]`),d.push(" values:")),d.push(p.map(e=>" "+e).join("\n")),d.join("\n")}(this.dataSync(),this.shape,this.dtype,e)}cast(e){return this.throwIfDisposed(),p.cast(this,e)}variable(e=!0,t,r){return this.throwIfDisposed(),h().makeVariable(this,e,t,r)}}function g(){return(0,n.m)("Tensor",()=>m)}Object.defineProperty(m,Symbol.hasInstance,{value:e=>!!e&&null!=e.data&&null!=e.dataSync&&null!=e.throwIfDisposed}),g();class y extends m{constructor(e,t,r,n){super(e.shape,e.dtype,e.dataId,n),this.trainable=t,this.name=r}assign(e){if(e.dtype!==this.dtype)throw Error(`dtype of the new value (${e.dtype}) and previous value (${this.dtype}) must match`);if(!a.r1(e.shape,this.shape))throw Error(`shape of the new value (${e.shape}) and previous value (${this.shape}) must match`);h().disposeTensor(this),this.dataId=e.dataId,h().incRef(this,null)}dispose(){h().disposeVariable(this),this.isDisposedInternal=!0}}Object.defineProperty(y,Symbol.hasInstance,{value:e=>e instanceof m&&null!=e.assign&&e.assign instanceof Function})},60270:(e,t,r)=>{var n=r(26701),a=r(884),s=r(63718),i=r(95522),o=r(78736),l=r(75652),u=r(46648);u.alea=n,u.xor128=a,u.xorwow=s,u.xorshift7=i,u.xor4096=o,u.tychei=l,e.exports=u},60286:(e,t,r)=>{"use strict";r.d(t,{m:()=>c});var n=r(19041),a=r(14958),s=r(48592),i=r(27924),o=r(76526),l=r(46213),u=r(14017),h=r(28235),p=r(62176),d=r(95791);let c=(0,p.op)({transpose_:function(e,t,r){let p=(0,i.YT)(e,"x","transpose");if(null==t&&(t=p.shape.map((e,t)=>t).reverse()),o.vA(p.rank===t.length,()=>`Error in transpose: rank of input ${p.rank} must match length of perm ${t}.`),t.forEach(e=>{o.vA(e>=0&&e<p.rank,()=>`All entries in 'perm' must be between 0 and ${p.rank-1} but got ${t}`)}),p.rank<=1)return p.clone();let c={perm:t};return"complex64"===p.dtype?(0,a.DZ)(()=>{let e=(0,d.x)(p),t=(0,u.n)(p);return e=n.T2.runKernel(s.wx0,{x:e},c),t=n.T2.runKernel(s.wx0,{x:t},c),r&&(t=(0,h.H)(t)),(0,l.f)(e,t)}):n.T2.runKernel(s.wx0,{x:p},c)}})},60631:(e,t,r)=>{"use strict";r.d(t,{E:()=>i});var n=r(19041),a=r(48592),s=r(27924);let i=(0,r(62176).op)({isInf_:function(e){let t=(0,s.YT)(e,"x","isInf");return n.T2.runKernel(a.E3$,{x:t})}})},60966:(e,t,r)=>{"use strict";r.d(t,{c:()=>o});var n=r(19041),a=r(48592),s=r(27924),i=r(16488);let o=(0,r(62176).op)({sum_:function(e,t=null,r=!1){let o=(0,s.YT)(e,"x","sum");"bool"===o.dtype&&(o=(0,i.w)(o,"int32"));let l={x:o};return n.T2.runKernel(a.WuN,l,{axis:t,keepDims:r})}})},61293:(e,t,r)=>{"use strict";r.r(t),r.d(t,{addImpl:()=>a.mx,bincountImpl:()=>s.X,bincountReduceImpl:()=>s.N,bitwiseAndImpl:()=>
121i.f6,castImpl:()=>o.ct,ceilImpl:()=>l.YG,concatImpl:()=>u.h,equalImpl:()=>h.z3,expImpl:()=>p.sG,expm1Impl:()=>d.uM,floorDivImpl:()=>f.C1,floorImpl:()=>c.vS,gatherNdImpl:()=>m.q,gatherV2Impl:()=>g.G,greaterEqualImpl:()=>b.lg,greaterImpl:()=>y.rq,lessEqualImpl:()=>v.cu,lessImpl:()=>x.WR,linSpaceImpl:()=>w.G,logImpl:()=>T.px,maxImpl:()=>S.j,maximumImpl:()=>N.He,minimumImpl:()=>k.hE,multiplyImpl:()=>I.BF,negImpl:()=>C.Dk,notEqualImpl:()=>E.cl,prodImpl:()=>A._B,raggedGatherImpl:()=>$.u,raggedRangeImpl:()=>F._,raggedTensorToTensorImpl:()=>R.K,rangeImpl:()=>_.q,rsqrtImpl:()=>D.Zy,scatterImpl:()=>O.b,sigmoidImpl:()=>L.zv,simpleAbsImpl:()=>n.dH,sliceImpl:()=>M.HS,sparseFillEmptyRowsImpl:()=>P.y,sparseReshapeImpl:()=>z.l,sparseSegmentReductionImpl:()=>B.z,sqrtImpl:()=>W.x6,squaredDifferenceImpl:()=>V.RF,staticRegexReplaceImpl:()=>G._,stridedSliceImpl:()=>U.e,stringNGramsImpl:()=>Z.G,stringSplitImpl:()=>j.S,stringToHashBucketFastImpl:()=>H.f,subImpl:()=>K.dl,tileImpl:()=>Y.D,topKImpl:()=>Q.x,transposeImpl:()=>q._,uniqueImpl:()=>X.w});var n=r(16041),a=r(86562),s=r(6322),i=r(35003),o=r(57568),l=r(61438),u=r(84466),h=r(36565),p=r(36958),d=r(36452),c=r(3751),f=r(86070),m=r(15565),g=r(40459),y=r(80427),b=r(86177),x=r(59454),v=r(75542),w=r(1039),T=r(32259),S=r(90534),N=r(30051),k=r(99373),I=r(20895),C=r(88547),E=r(55648),A=r(49762),$=r(52949),F=r(98253),R=r(58151),_=r(12507),D=r(8341),O=r(50494),L=r(18585),M=r(33699),P=r(26777),z=r(91338),B=r(45732),W=r(85205),V=r(99471),G=r(32232),U=r(28575),Z=r(3491),j=r(75373),H=r(63110),K=r(93807),Y=r(3974),Q=r(19770),q=r(74069),X=r(46967)},61438:(e,t,r)=>{"use strict";r.d(t,{YG:()=>i,uf:()=>l});var n=r(51520),a=r(81600),s=r(87095);let i=(0,a.o)(e=>Math.ceil(e)),o=(0,s.F)(n.QDP,i),l={kernelName:n.QDP,backendName:"cpu",kernelFunc:o}},61541:(e,t,r)=>{"use strict";r.d(t,{j:()=>i});var n=r(19041),a=r(48592),s=r(27924);let i=(0,r(62176).op)({min_:function(e,t=null,r=!1){let i=(0,s.YT)(e,"x","min");return n.T2.runKernel(a.lNG,{x:i},{axis:t,keepDims:r})}})},61560:(e,t,r)=>{"use strict";r.d(t,{z:()=>i});var n=r(71553),a=r(25223),s=r(90670);class i{constructor(e){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!1,this.outputShape=e,this.enableShapeUniforms=(0,n.ik)(this.outputShape.length);let t=e.length,r=(0,a.Jp)("rc",t),i=(0,s.bf)(t),o=(0,a.kp)(t,r),l=r.slice(-2),u=t<=1?"rc":`vec2(${l.join(",")})`;this.userCode=` 122 void main() { 123 ${i} rc = getOutputCoords(); 124 vec4 packedInput = getA(${o}); 125 126 setOutput(getChannel(packedInput, ${u})); 127 } 128 `}}},61727:(e,t,r)=>{"use strict";r.d(t,{Em:()=>u,SM:()=>o,WC:()=>l,WH:()=>a,aF:()=>s,fK:()=>p,gx:()=>h,lb:()=>i});var n=r(76526);function a(e,t){for(let r=0;r<e.length;++r)if(e[e.length-r-1]!==t-1-r)return!1;return!0}function s(e,t,r){let n=e.length+t.length,a=[],s=0,i=0;for(let o=0;o<n;o++)-1===r.indexOf(o)?a.push(e[s++]):a.push(t[i++]);return a}function i(e,t){let r=[],n=e.length;for(let a=0;a<n;a++)-1===t.indexOf(a)&&r.push(e[a]);return[r,t.map(t=>e[t])]}function o(e,t){return s(e,t.map(e=>1),t)}function l(e,t,r){n.vA(a(t,r),()=>`${e} supports only inner-most axes for now. Got axes ${t} and rank-${r} input.`)}function u(e,t){if(a(e,t))return null;let r=[];for(let n=0;n<t;++n)-1===e.indexOf(n)&&r.push(n);return e.forEach(e=>r.push(e)),r}function h(e){return e.map((e,t)=>[t,e]).sort((e,t)=>e[1]-t[1]).map(e=>e[0])}function p(e,t){let r=[];for(let n=t-e;n<t;++n)r.push(n);return r}},61838:(e,t,r)=>{"use strict";r.d(t,{K:()=>i});var n=r(19041),a=r(48592),s=r(27924);let i=(0,r(62176).op)({log1p_:function(e){let t=(0,s.YT)(e,"x","log1p");return n.T2.runKernel(a.Cg$,{x:t})}})},62041:(e,t,r)=>{"use strict";r.d(t,{J:()=>i,Ol:()=>o,mW:()=>l});var n=r(97344),a=r(82692),s=r(77617);function i(e,t,r){if("number"==typeof e)return(0,a.fD)(e,t);if(e.length!==t)throw new n.Qp(`The ${r} argument must be an integer or tuple of ${t} integers. Received: ${e.length} elements.`);for(let a=0;a<t;++a){let i=e[a];if(!(0,s.Fq)(i))throw new n.Qp(`The ${r} argument must be an integer or tuple of ${t} integers. Received: ${JSON.stringify(e)} including a non-integer number ${i}`)}return e}function o(e,t,r,n,a=1){let s;return null==e?e:Math.floor((("same"===r?e:e-(t+(t-1)*(a-1))+1)+n-1)/n)}function l(e,t,r,a){if(null==e)return null;if("valid"===a)e=e*t+(0,s.T9)([r-t,0]);else if("same"===a)e*=t;else throw new n.Qp(`Unsupport padding mode: ${a}.`);return e}},62176:(e,t,r)=>{"use strict";r.d(t,{B:()=>s,op:()=>i});var n=r(19041),a=r(76526);let s="__op";function i(e){let t=Object.keys(e);if(1!==t.length)throw Error(`Please provide an object with a single key (operation name) mapping to a function. Got an object with ${t.length} keys.`);let r=t[0],i=e[r];r.endsWith("_")&&(r=r.substring(0,r.length-1));let o=(...e)=>{n.T2.startScope(r);try{let t=i(...e);return(0,a.yL)(t)&&console.error("Cannot return a Promise inside of tidy."),n.T2.endScope(t),t}catch(e){throw n.T2.endScope(null),e}};return Object.defineProperty(o,"name",{value:r+=s,configurable:!0}),o}},63048:(e,t,r)=>{"use strict";r.d(t,{R:()=>s,i:()=>a});var n=r(89215);function a(...e){(0,n._K)().getBool("IS_TEST")||(0,n._K)().getBool("PROD")||console.warn(...e)}function s(...e){(0,n._K)().getBool("IS_TEST")||(0,n._K)().getBool("PROD")||console.log(...e)}},63110:(e,t,r)=>{"use strict";r.d(t,{f:()=>a});var n=r(51520);function a(e,t){let r=n.ZSL.getArrayFromDType("int32",e.length);for(let a=0;a<e.length;++a)r[a]=n.ZSL.fingerPrint64(e[a]).modulo(t).getLowBitsUnsigned();return r}},63191:(e,t,r)=>{"use strict";r.d(t,{B:()=>i});var n=r(19041),a=r(48592),s=r(27924);let i=(0,r(62176).op)({reverse_:function(e,t){let r=(0,s.YT)(e,"x","reverse");return n.T2.runKernel(a.D7i,{x:r},{dims:t})}})},63405:(e,t,r)=>{"use strict";function n(e){let{inputs:t,backend:r}=e,{real:n,imag:a}=t,s=r.data.get(n.dataId).values,i=r.data.get(a.dataId).values,o=r.makeTensorInfo(n.shape,"complex64");return r.data.get(o.dataId).complexTensorInfos={real:r.makeTensorInfo(n.shape,"float32",s),imag:r.makeTensorInfo(a.shape,"float32",i)},o}r.d(t,{f:()=>n,v:()=>a});let a={kernelName:r(51520).pr3,backendName:"cpu",kernelFunc:n}},63718:function(e,t,r){var n;!function(e,a,s){function i(e){var t=this,r="";t.next=function(){var e=t.x^t.x>>>2;return t.x=t.y,t.y=t.z,t.z=t.w,t.w=t.v,(t.d=t.d+362437|0)+(t.v=t.v^t.v<<4^(e^e<<1))|0},t.x=0,t.y=0,t.z=0,t.w=0,t.v=0,e===(0|e)?t.x=e:r+=e;for(var n=0;n<r.length+64;n++)t.x^=r.charCodeAt(n),n==r.length&&(t.d=t.x<<10^t.x>>>4),t.next()}function o(e,t){return t.x=e.x,t.y=e.y,t.z=e.z,t.w=e.w,t.v=e.v,t.d=e.d,t}function l(e,t){var r=new i(e),n=t&&t.state,a=function(){return(r.next()>>>0)/0x100000000};return a.double=function(){do var e=((r.next()>>>11)+(r.next()>>>0)/0x100000000)/2097152;while(0===e);return e},a.int32=r.next,a.quick=a,n&&("object"==typeof n&&o(n,r),a.state=function(){return o(r,{})}),a}a&&a.exports?a.exports=l:r.amdD&&r.amdO?void 0===(n=(function(){return l}).call(t,r,t,a))||(a.exports=n):this.xorwow=l}(0,e=r.nmd(e),r.amdD)},64756:(e,t,r)=>{"use strict";r.d(t,{i:()=>n});let n={float32:4,float16:2,int32:4,uint16:2,uint8:1,bool:1,complex64:8}},64786:(e,t,r)=>{"use strict";r.d(t,{C:()=>o});var n=r(67108),a=r(71553),s=r(82859);let i={R:0,G:1,B:2,A:3};class o{constructor(e,t=!1,r="RGBA"){this.variableNames=["A"],this.customUniforms=[{name:"texShape",type:"ivec2"}];let o=(0,n.B)();this.outputShape=e,this.enableShapeUniforms=(0,a.ik)(this.outputShape.length);let l="result";t&&(l="floor(result * 255. + 0.5)");let u="";for(let e=0;e<r.length;e++){let t=r[e];u+=` 129 if(offset == ${e}) { 130 result = values[${i[t]}]; 131 }`}this.userCode=` 132 ${this.enableShapeUniforms?s.Od():s.fM(e)} 133 134 void main() { 135 ivec3 coords = getOutputCoords(); 136 int flatIndex = getFlatIndex(coords); 137 float result = 0.; 138 int offset = imod(flatIndex, ${r.length}); 139 140 flatIndex = idiv(flatIndex, ${r.length}, 1.); 141 142 int r = flatIndex / texShape[1];
143 if (r < texShape[0]) { 144 int c = imod(flatIndex, texShape[1]); 145 vec2 uv = (vec2(c, r) + halfCR) / vec2(texShape[1], texShape[0]); 146 vec4 values = ${o.texture2D}(A, uv); 147 ${u} 148 } 149 ${o.output} = vec4(${l}, 0., 0., 0.); 150 } 151 `}}},64828:(e,t,r)=>{"use strict";r.d(t,{K:()=>o});var n=r(19041),a=r(48592),s=r(27924),i=r(76526);let o=(0,r(62176).op)({unstack_:function(e,t=0){let r=(0,s.YT)(e,"x","unstack","string_or_numeric");return i.vA(t>=-r.shape.length&&t<r.shape.length,()=>`Axis = ${t} is not in [-${r.shape.length}, ${r.shape.length})`),n.T2.runKernel(a.dXR,{value:r},{axis:t})}})},65211:(e,t,r)=>{"use strict";r.d(t,{Hq:()=>l,Nb:()=>o,X0:()=>s,X8:()=>i,_Q:()=>a,rf:()=>u});var n=r(71553);let a="return x;",s=` 152 vec4 result; 153 154 result.r = (x.r >= 0.0) ? x.r : (exp(x.r) - 1.0); 155 result.g = (x.g >= 0.0) ? x.g : (exp(x.g) - 1.0); 156 result.b = (x.b >= 0.0) ? x.b : (exp(x.b) - 1.0); 157 result.a = (x.a >= 0.0) ? x.a : (exp(x.a) - 1.0); 158 159 return result; 160`,i=` 161 vec4 result = x * vec4(greaterThanEqual(x, vec4(0.0))); 162 bvec4 isNaN = isnan(x); 163 164 result.r = isNaN.r ? x.r : result.r; 165 result.g = isNaN.g ? x.g : result.g; 166 result.b = isNaN.b ? x.b : result.b; 167 result.a = isNaN.a ? x.a : result.a; 168 169 return result; 170`,o=` 171 vec4 result = min(x, vec4(6.)) * vec4(greaterThanEqual(x, vec4(0.0))); 172 bvec4 isNaN = isnan(x); 173 174 result.r = isNaN.r ? x.r : result.r; 175 result.g = isNaN.g ? x.g : result.g; 176 result.b = isNaN.b ? x.b : result.b; 177 result.a = isNaN.a ? x.a : result.a; 178 179 return result; 180`,l="return 1.0 / (1.0 + exp(-1.0 * x));";class u{constructor(e,t){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=e,this.enableShapeUniforms=(0,n.ik)(this.outputShape.length),this.userCode=` 181 vec4 unaryOperation(vec4 x) { 182 ${t} 183 } 184 185 void main() { 186 vec4 x = getAAtOutCoords(); 187 vec4 y = unaryOperation(x); 188 189 setOutput(y); 190 } 191 `}}},65417:(e,t,r)=>{"use strict";r.d(t,{d:()=>d});var n=r(27924),a=r(76526),s=r(98932),i=r(52285),o=r(39114),l=r(51006),u=r(62176),h=r(68567),p=r(51097);let d=(0,u.op)({pool_:function(e,t,r,u,d,c,f){let m;null==d&&(d=[1,1]),null==c&&(c=1),0===u&&(u="valid");let g=(0,n.YT)(e,"x","maxPool"),y=g,b=!1;3===g.rank&&(b=!0,y=(0,h.t)(g,[1,g.shape[0],g.shape[1],g.shape[2]])),a.vA(o.G0(c,d),()=>`Error in pool: Either strides or dilations must be 1. Got strides ${c} and dilations '${d}'`);let x=o.E6(y.shape,t,c,d,u),v=[x.dilationHeight,x.dilationWidth];m="same"===u?function(e,t){let r=e.map((e,r)=>e+(e-1)*(t[r]-1)).map(e=>e-1),n=r.map(e=>Math.floor(e/2)),a=r.map((e,t)=>e-n[t]);return r.map((e,t)=>[n[t],a[t]])}([x.filterHeight,x.filterWidth],v):[[0,0],[0,0]];let w=1===v[0]&&1===v[1],[T,S]=function(e,t,r){let n=r.map(e=>e[0]),a=r.map(e=>e[1]),s=e.concat(n,a),i=t.map((e,t)=>(e-s[t]%e)%e),o=a.map((e,t)=>e+i[t]);return[t.map((e,t)=>[n[t],o[t]]),t.map((e,t)=>[0,i[t]])]}([x.inHeight,x.inWidth],v,m),N=w?u:"valid",k=w?y:(0,p.e)(y,v,T),I=("avg"===r?()=>(0,s.$)(k,t,c,N,f):()=>(0,l.j)(k,t,c,N,f))(),C=w?I:(0,i.G)(I,v,S);return b?(0,h.t)(C,[C.shape[1],C.shape[2],C.shape[3]]):C}})},65519:(e,t,r)=>{"use strict";r.r(t),r.d(t,{Abs:()=>R.ljI,Acos:()=>R.Vvy,Acosh:()=>R.PH8,AdadeltaOptimizer:()=>R.K$F,AdagradOptimizer:()=>R.ah4,AdamOptimizer:()=>R.FYc,AdamaxOptimizer:()=>R.oC7,Add:()=>R.OMN,AddN:()=>R.EkD,All:()=>R.u8Z,Any:()=>R.FSt,ArgMax:()=>R.Jp_,ArgMin:()=>R.p_m,Asin:()=>R.QKF,Asinh:()=>R.epO,Atan:()=>R.TyE,Atan2:()=>R.lxb,Atanh:()=>R.zP9,AvgPool:()=>R.ho8,AvgPool3D:()=>R.cS,AvgPool3DGrad:()=>R.wwC,AvgPoolGrad:()=>R.VCH,BatchMatMul:()=>R.jAQ,BatchToSpaceND:()=>R.Ik2,Bincount:()=>R.N4F,BitwiseAnd:()=>R.HNs,BroadcastArgs:()=>R.vj7,BroadcastTo:()=>R.LB5,Callback:()=>aE,CallbackList:()=>aN.g,Cast:()=>R.KXH,Ceil:()=>R.QDP,ClipByValue:()=>R.vaV,Complex:()=>R.pr3,ComplexAbs:()=>R.$zE,Concat:()=>R.$dB,Conv2D:()=>R.p2J,Conv2DBackpropFilter:()=>R.rFm,Conv2DBackpropInput:()=>R.jfg,Conv3D:()=>R.A1h,Conv3DBackpropFilterV2:()=>R.iGz,Conv3DBackpropInputV2:()=>R.gC7,Cos:()=>R.Mn0,Cosh:()=>R.MnK,CropAndResize:()=>R.MRQ,Cumprod:()=>R.jj_,Cumsum:()=>R.nY8,CustomCallback:()=>aN.H7,DataStorage:()=>R.GJx,DenseBincount:()=>R.wNW,DepthToSpace:()=>R.TMz,DepthwiseConv2dNative:()=>R.tGH,DepthwiseConv2dNativeBackpropFilter:()=>R.X$8,DepthwiseConv2dNativeBackpropInput:()=>R.nVu,Diag:()=>R.ORI,Dilation2D:()=>R.jxD,Dilation2DBackpropFilter:()=>R.pk0,Dilation2DBackpropInput:()=>R.bP9,Draw:()=>R.XmO,ENV:()=>R.Kmu,EarlyStopping:()=>aF,Einsum:()=>R.Qgm,Elu:()=>R.Pah,EluGrad:()=>R.rsH,Environment:()=>R.OH$,Equal:()=>R.BRl,Erf:()=>R._s9,Exp:()=>R.ox3,ExpandDims:()=>R.ybN,Expm1:()=>R.ybj,FFT:()=>R.rGP,Fill:()=>R.SQl,FlipLeftRight:()=>R.BxF,Floor:()=>R.ZgB,FloorDiv:()=>R.ElG,FromPixels:()=>R.awo,FusedBatchNorm:()=>R.i5R,FusedConv2D:()=>R.aAr,FusedDepthwiseConv2D:()=>R.T7M,GPGPUContext:()=>pT.GPGPUContext,GatherNd:()=>R.O4G,GatherV2:()=>R.mxL,GraphModel:()=>s9,Greater:()=>R.XhZ,GreaterEqual:()=>R.lLS,History:()=>aN.BZ,IFFT:()=>R.OAQ,Identity:()=>R.lzr,Imag:()=>R.dv8,InputSpec:()=>a_.eO,IsFinite:()=>R.gIW,IsInf:()=>R.E3$,IsNan:()=>R.iPs,KernelBackend:()=>R.uI_,LRN:()=>R.jM4,LRNGrad:()=>R.ToN,LayerVariable:()=>aL.eR,LayersModel:()=>ak.Gw,LeakyRelu:()=>R.X0$,Less:()=>R.mIA,LessEqual:()=>R.CwD,LinSpace:()=>R.mnI,Log:()=>R.tG8,Log1p:()=>R.Cg$,LogSoftmax:()=>R.zfU,LogicalAnd:()=>R.RUm,LogicalNot:()=>R.nZd,LogicalOr:()=>R.LXA,LogicalXor:()=>R.RW8,LowerBound:()=>
191R.yPW,MathBackendCPU:()=>or,MathBackendWebGL:()=>pT.MathBackendWebGL,MatrixBandPart:()=>R.WRv,Max:()=>R.VAI,MaxPool:()=>R.t3d,MaxPool3D:()=>R.ySp,MaxPool3DGrad:()=>R.cHb,MaxPoolGrad:()=>R.RXX,MaxPoolWithArgmax:()=>R.TL8,Maximum:()=>R.LDN,Mean:()=>R.g5A,Min:()=>R.lNG,Minimum:()=>R.LG0,MirrorPad:()=>R.x7F,Mod:()=>R.BLA,MomentumOptimizer:()=>R.Qu_,Multinomial:()=>R.WT3,Multiply:()=>R.xu7,Neg:()=>R.l0G,NonMaxSuppressionV3:()=>R.SDM,NonMaxSuppressionV4:()=>R.Zl4,NonMaxSuppressionV5:()=>R.e0f,NotEqual:()=>R.ylV,OP_SCOPE_SUFFIX:()=>R.BTT,OneHot:()=>R.urI,OnesLike:()=>R.LWX,Optimizer:()=>R.ELo,OptimizerConstructors:()=>R.L5p,Pack:()=>R.mM$,PadV2:()=>R.ODT,Pool:()=>R.bCz,Pow:()=>R.pyJ,Prelu:()=>R.Ncv,Prod:()=>R.kdj,RMSPropOptimizer:()=>R.PS5,RNN:()=>aO.VS,RaggedGather:()=>R.oJ2,RaggedRange:()=>R.CQC,RaggedTensorToTensor:()=>R.mH5,Range:()=>R.Q6t,Rank:()=>R.rgM,Real:()=>R.LRy,RealDiv:()=>R.sDr,Reciprocal:()=>R.huO,Reduction:()=>R.iDl,Relu:()=>R.fUj,Relu6:()=>R.P_L,Reshape:()=>R.R23,ResizeBilinear:()=>R.hgw,ResizeBilinearGrad:()=>R.FCQ,ResizeNearestNeighbor:()=>R.jOE,ResizeNearestNeighborGrad:()=>R.XQy,Reverse:()=>R.D7i,RotateWithOffset:()=>R.BK4,Round:()=>R.hVg,Rsqrt:()=>R.TOR,SGDOptimizer:()=>R.SYI,ScatterNd:()=>R.pJc,SearchSorted:()=>R.uWl,Select:()=>R.l6P,Selu:()=>R.u$b,Sequential:()=>ax.Gx,Sigmoid:()=>R.vI1,Sign:()=>R.YVe,Sin:()=>R.hql,Sinh:()=>R.J3C,Slice:()=>R.JiE,Softmax:()=>R.rFG,Softplus:()=>R.Fin,SpaceToBatchND:()=>R.A8B,SparseFillEmptyRows:()=>R.C8s,SparseReshape:()=>R.BoJ,SparseSegmentMean:()=>R.L6G,SparseSegmentSum:()=>R.DvZ,SparseToDense:()=>R.jgd,SplitV:()=>R.Blb,Sqrt:()=>R.dFH,Square:()=>R.M6A,SquaredDifference:()=>R.Ddj,StaticRegexReplace:()=>R.GZp,Step:()=>R.pnw,StridedSlice:()=>R.UcO,StringNGrams:()=>R.YAb,StringSplit:()=>R.iW0,StringToHashBucketFast:()=>R.$jE,Sub:()=>R.PbM,Sum:()=>R.WuN,SymbolicTensor:()=>a_.Ar,Tan:()=>R.oFs,Tanh:()=>R.iuW,Tensor:()=>R.qYS,TensorBuffer:()=>R.ylz,TensorScatterUpdate:()=>R.X4r,Tile:()=>R.FAs,TopK:()=>R.TBb,Transform:()=>R.dLy,Transpose:()=>R.wx0,Unique:()=>R.EwU,Unpack:()=>R.dXR,UnsortedSegmentSum:()=>R.pPe,UpperBound:()=>R.RMm,Variable:()=>R.rTt,ZerosLike:()=>R.xJ3,_FusedMatMul:()=>R.Dr,abs:()=>R.tnl,acos:()=>R.HQu,acosh:()=>R.FqL,add:()=>R.WQq,addN:()=>R.QiD,all:()=>R.Q7R,any:()=>R.bzn,argMax:()=>R.FLi,argMin:()=>R.XRg,asin:()=>R.qRo,asinh:()=>R.yHs,atan:()=>R.rYl,atan2:()=>R.FPz,atanh:()=>R.rfv,avgPool:()=>R.$jT,avgPool3d:()=>R.sub,backend:()=>R.Hs,backend_util:()=>R.C0T,basicLSTMCell:()=>R.lZX,batchNorm:()=>R.$v7,batchNorm2d:()=>R.BFc,batchNorm3d:()=>R.kSi,batchNorm4d:()=>R.T5N,batchToSpaceND:()=>R.GTe,bincount:()=>R.HbZ,bitwiseAnd:()=>R.vjT,booleanMaskAsync:()=>R.ftb,broadcastArgs:()=>R.ROE,broadcastTo:()=>R.hOW,broadcast_util:()=>R.ZEY,browser:()=>R.TaL,buffer:()=>R.ra8,callbacks:()=>aR,cast:()=>R.wgE,ceil:()=>R.mkO,clipByValue:()=>R.zQh,clone:()=>R.o8B,complex:()=>R.faB,concat:()=>R.xWs,concat1d:()=>R.I1m,concat2d:()=>R.RPU,concat3d:()=>R.O5O,concat4d:()=>R.P1l,constraints:()=>i,conv1d:()=>R.kA9,conv2d:()=>R.Xtf,conv2dTranspose:()=>R.wX9,conv3d:()=>R.IPL,conv3dTranspose:()=>R.jIJ,copyRegisteredKernels:()=>R.Cfv,cos:()=>R.gnS,cosh:()=>R.yIG,cosineWindow:()=>R._jP,cumprod:()=>R.Lp0,cumsum:()=>R.rCv,customGrad:()=>R._Xg,data:()=>F,denseBincount:()=>R.aOp,deprecationWarn:()=>R.fLc,depthToSpace:()=>R.Rj8,depthwiseConv2d:()=>R.Gl3,deregisterOp:()=>aB,device_util:()=>R.eMq,diag:()=>R.smy,dilation2d:()=>R.X7t,disableDeprecationWarnings:()=>R.ISJ,dispose:()=>R.ASo,disposeVariables:()=>R.rm6,div:()=>R.y4m,divNoNan:()=>R.ek5,dot:()=>R.Omf,dropout:()=>R.EZY,einsum:()=>R._3C,elu:()=>R.Pqc,enableDebugMode:()=>R.gYU,enableProdMode:()=>R.SmG,enclosingPowerOfTwo:()=>R.FJY,engine:()=>R.Hi9,ensureShape:()=>R.QP2,env:()=>R._K2,equal:()=>R.LCg,erf:()=>R.Y12,euclideanNorm:()=>R.p4S,exp:()=>R.oNF,expandDims:()=>R.UG6,expm1:()=>R.IYd,eye:()=>R.y5U,fft:()=>R.hVP,fill:()=>R.GSj,findBackend:()=>R.goy,findBackendFactory:()=>R.W4C,floor:()=>R.RIf,floorDiv:()=>R.wh_,forceHalfFloat:()=>pT.forceHalfFloat,fused:()=>R.cZk,gather:()=>R.kgh,gatherND:()=>R.SY9,gather_util:()=>R.FJy,getBackend:()=>R.jz4,getGradient:()=>R.vQR,getKernel:()=>R._5H,getKernelsForBackend:()=>R.OpK,gpgpu_util:()=>pT.gpgpu_util,grad:()=>R.Dvk,grads:()=>R.ok9,greater:()=>R.rhj,greaterEqual:()=>R.DQN,ifft:()=>R.KGM,imag:()=>R.ngS,image:()=>R.Slp,inTopKAsync:()=>
191R.U4u,initializers:()=>o,input:()=>aD.hF,io:()=>R.io,irfft:()=>R.ggX,isFinite:()=>R.MIs,isInf:()=>R.EN4,isNaN:()=>R.yrW,keep:()=>R.aCs,kernel_impls:()=>R.kpo,layers:()=>ae,leakyRelu:()=>R.H8d,less:()=>R.M7h,lessEqual:()=>R.InN,linalg:()=>R.mPL,linspace:()=>R.mT8,loadGraphModel:()=>s8,loadGraphModelSync:()=>ie,loadLayersModel:()=>aD.O0,localResponseNormalization:()=>R.Kgs,log:()=>R.Rm2,log1p:()=>R.Kko,logSigmoid:()=>R.nqI,logSoftmax:()=>R.HPB,logSumExp:()=>R.VZ,logicalAnd:()=>R.n76,logicalNot:()=>R.NSZ,logicalOr:()=>R.ztW,logicalXor:()=>R.rxB,losses:()=>R.YYh,lowerBound:()=>R.yzS,matMul:()=>R.NoW,math:()=>R.DyF,max:()=>R.T9B,maxPool:()=>R.jgi,maxPool3d:()=>R.NYV,maxPoolWithArgmax:()=>R.RO,maximum:()=>R.PhQ,mean:()=>R.i2o,memory:()=>R.m1Z,meshgrid:()=>R.OYQ,metrics:()=>l,min:()=>R.jkA,minimum:()=>R.BpO,mirrorPad:()=>R.FFZ,mod:()=>R.ziu,model:()=>aD.ge,models:()=>u,moments:()=>R.Clk,movingAverage:()=>R.CRk,mul:()=>R.lKK,multiRNNCell:()=>R.YDF,multinomial:()=>R.OjQ,neg:()=>R.HZy,nextFrame:()=>R.dA1,norm:()=>R.xbf,notEqual:()=>R.Ec,oneHot:()=>R.Mw0,ones:()=>R.SaS,onesLike:()=>R.P61,op:()=>R.op,outerProduct:()=>R.X4o,pad:()=>R.eVF,pad1d:()=>R.BZs,pad2d:()=>R.grY,pad3d:()=>R.XHu,pad4d:()=>R.WLX,pool:()=>R.dzn,pow:()=>R.n7C,prelu:()=>R.NsG,print:()=>R.yyV,prod:()=>R._eU,profile:()=>R.MEE,raggedGather:()=>R.whe,raggedRange:()=>R.iyU,raggedTensorToTensor:()=>R.Q0_,rand:()=>R._9M,randomGamma:()=>R.pR9,randomNormal:()=>R.FE$,randomStandardNormal:()=>R.m0H,randomUniform:()=>R.YeY,randomUniformInt:()=>R.HYA,range:()=>R.y17,ready:()=>R.Gc4,real:()=>R.xav,reciprocal:()=>R.VOZ,registerBackend:()=>R.gJX,registerCallbackConstructor:()=>aD.ZS,registerGradient:()=>R.krJ,registerKernel:()=>R.tAK,registerOp:()=>az,regularizers:()=>h,relu:()=>R.VVh,relu6:()=>R.j__,removeBackend:()=>R.rEj,reshape:()=>R.tQQ,reverse:()=>R.BEg,reverse1d:()=>R.QD2,reverse2d:()=>R.LMr,reverse3d:()=>R.I2l,reverse4d:()=>R.JYU,rfft:()=>R.z8$,round:()=>R.LIG,rsqrt:()=>R.Z$r,scalar:()=>R.d_2,scatterND:()=>R.NFr,scatter_util:()=>R.g23,searchSorted:()=>R.sZg,selu:()=>R.WfX,separableConv2d:()=>R.wdz,sequential:()=>aD.il,serialization:()=>R.JFn,setBackend:()=>R.jh6,setPlatform:()=>R.OkC,setWebGLContext:()=>pT.setWebGLContext,setdiff1dAsync:()=>R.F12,shared:()=>on,sigmoid:()=>R.ry7,sign:()=>R._SZ,signal:()=>R.vPA,sin:()=>R.F8e,sinh:()=>R.L0l,slice:()=>R.dik,slice1d:()=>R.Q$M,slice2d:()=>R.zAd,slice3d:()=>R.wck,slice4d:()=>R.R0O,slice_util:()=>R.Kro,softmax:()=>R.Vs9,softplus:()=>R.lw0,spaceToBatchND:()=>R.eDJ,sparse:()=>R.lMo,sparseToDense:()=>R.Zhr,spectral:()=>R.lOn,split:()=>R.lDo,sqrt:()=>R.RZD,square:()=>R.EwI,squaredDifference:()=>R.Pbu,squeeze:()=>R.r2V,stack:()=>R.t$z,step:()=>R.PMw,stridedSlice:()=>R.Ym9,string:()=>R.YjP,sub:()=>R.jbE,sum:()=>R.czq,sumOutType:()=>R.chL,tan:()=>R.Mlm,tanh:()=>R.ymU,tensor:()=>R.OEK,tensor1d:()=>R.tGX,tensor2d:()=>R.KtR,tensor3d:()=>R.$_$,tensor4d:()=>R.g9W,tensor5d:()=>R.Lpo,tensor6d:()=>R.yxw,tensorScatterUpdate:()=>R.NNh,tensor_util:()=>R.d_S,test_util:()=>R.Obs,tidy:()=>R.DZQ,tile:()=>R.Vsq,time:()=>R.kBw,topk:()=>R.rfw,train:()=>R.BaG,transpose:()=>R.mgz,truncatedNormal:()=>R.efE,unique:()=>R.AmM,unregisterGradient:()=>R.rYx,unregisterKernel:()=>R.iPt,unsortedSegmentSum:()=>R.zAU,unstack:()=>R.K$i,upcastType:()=>R.TuY,upperBound:()=>R.rni,util:()=>R.ZSL,valueAndGrad:()=>R.jYt,valueAndGrads:()=>R.muS,variable:()=>R.bvq,variableGrads:()=>R.y7e,version:()=>pS,version_converter:()=>it,version_core:()=>R.bgA,version_cpu:()=>oa,version_layers:()=>aM.r,version_webgl:()=>pT.version_webgl,webgl:()=>pT.webgl,webgl_util:()=>pT.webgl_util,where:()=>R._M9,whereAsync:()=>R.YJN,zeros:()=>R.Ul9,zerosLike:()=>R.POl});var n,a,s,i={};r.r(i),r.d(i,{maxNorm:()=>nU,minMaxNorm:()=>nH,nonNeg:()=>nj,unitNorm:()=>nZ});var o={};r.r(o),r.d(o,{constant:()=>nq,glorotNormal:()=>n4,glorotUniform:()=>n3,heNormal:()=>n5,heUniform:()=>n6,identity:()=>n1,leCunNormal:()=>n7,leCunUniform:()=>n9,ones:()=>nQ,orthogonal:()=>n8,randomNormal:()=>nJ,randomUniform:()=>nX,truncatedNormal:()=>n0,varianceScaling:()=>n2,zeros:()=>nY});var l={};r.r(l),r.d(l,{MAPE:()=>ac,MSE:()=>ag,binaryAccuracy:()=>an,binaryCrossentropy:()=>aa,categoricalAccuracy:()=>ai,categoricalCrossentropy:()=>ao,cosineProximity:()=>ah,mape:()=>af,meanAbsoluteError:()=>ap,meanAbsolutePercentageError:()=>ad,meanSquaredError:()=>am,mse:()=>ay,precision:()=>al,r2Score:()=>ab,recall:()=>au,sparseCategoricalAccuracy:()=>as});var u={};r.r(u),r.d(u,{modelFromJSON:()=>ax.U3});var h={};r.r(h),r.d(h,{l1:()=>aT,l1l2:()=>aw,l2:()=>aS});var p={};r.r(p),r.d(p,{json:()=>aY});var d={};r.r(d),r.d(d,{json:()=>aQ});var c={};r.r(c),r.d(c,{json:()=>aq});var f={};r.r(f),r.d(f,{json:()=>aX});var m={};r.r(m),r.d(m,{json:()=>aJ});var g={};r.r(g),r.d(g,{json:()=>a0});var y={};r.r(y),r.d(y,{json:()=>a1});var b={};r.r(b),r.d(b,{json:()=>a2});var x={};r.r(x),r.d(x,{json:()=>a3});var v={};r.r(v),r.d(v,{json:()=>a4});var w={};r.r(w),r.d(w,{json:()=>a5});var T={};r.r(T),r.d(T,{json:()=>a6});var S={};r.r(S),r.d(S,{json:()=>a7});var N={};r.r(N),r.d(N,{json:()=>a9});var k={};r.r(k),r.d(k,{json:()=>a8});var I={};r.r(I),r.d(I,{json:()=>se});var C={};r.r(C),r.d(C,{json:()=>st});var E={};r.r(E),r.d(E,{json:()=>sr});var A={};r.r(A),r.d(A,{json:()=>sn});var $={};r.r($),r.d($,{OP_SCOPE_SUFFIX:()=>sw.BTT,abs:()=>sw.tnl,acos:()=>sw.HQu,acosh:()=>sw.FqL,add:()=>sw.WQq,addN:()=>sw.QiD,all:()=>sw.Q7R,any:()=>sw.bzn,argMax:()=>sw.FLi,argMin:()=>sw.XRg,asin:()=>sw.qRo,asinh:()=>sw.yHs,atan:()=>sw.rYl,atan2:()=>sw.FPz,atanh:()=>sw.rfv,avgPool:()=>sw.$jT,avgPool3d:()=>sw.sub,basicLSTMCell:()=>sw.lZX,batchNorm:()=>sw.$v7,batchNorm2d:()=>sw.BFc,batchNorm3d:()=>sw.kSi,batchNorm4d:()=>sw.T5N,batchToSpaceND:()=>sw.GTe,bincount:()=>sw.HbZ,bitwiseAnd:()=>sw.vjT,booleanMaskAsync:()=>sw.ftb,broadcastArgs:()=>sw.ROE,broadcastTo:()=>sw.hOW,buffer:()=>sw.ra8,cast:()=>sw.wgE,ceil:()=>sw.mkO,clipByValue:()=>sw.zQh,clone:()=>sw.o8B,complex:()=>sw.faB,concat:()=>sw.xWs,concat1d:()=>sw.I1m,concat2d:()=>sw.RPU,concat3d:()=>sw.O5O,concat4d:()=>sw.P1l,conv1d:()=>sw.kA9,conv2d:()=>sw.Xtf,conv2dTranspose:()=>sw.wX9,conv3d:()=>sw.IPL,conv3dTranspose:()=>sw.jIJ,cos:()=>sw.gnS,cosh:()=>sw.yIG,cosineWindow:()=>sw._jP,cumprod:()=>sw.Lp0,cumsum:()=>sw.rCv,denseBincount:()=>sw.aOp,depthToSpace:()=>sw.Rj8,depthwiseConv2d:()=>sw.Gl3,diag:()=>sw.smy,dilation2d:()=>sw.X7t,div:()=>sw.y4m,divNoNan:()=>sw.ek5,dot:()=>sw.Omf,dropout:()=>sw.EZY,einsum:()=>sw._3C,elu:()=>sw.Pqc,enclosingPowerOfTwo:()=>sw.FJY,ensureShape:()=>sw.QP2,equal:()=>sw.LCg,erf:()=>sw.Y12,euclideanNorm:()=>sw.p4S,exp:()=>sw.oNF,expandDims:()=>sw.UG6,expm1:()=>sw.IYd,eye:()=>sw.y5U,fft:()=>sw.hVP,fill:()=>sw.GSj,floor:()=>sw.RIf,floorDiv:()=>sw.wh_,fused:()=>sw.cZk,gather:()=>sw.kgh,gatherND:()=>sw.SY9,greater:()=>sw.rhj,greaterEqual:()=>sw.DQN,ifft:()=>sw.KGM,imag:()=>sw.ngS,image:()=>sw.Slp,inTopKAsync:()=>sw.U4u,irfft:()=>sw.ggX,isFinite:()=>sw.MIs,isInf:()=>sw.EN4,isNaN:()=>sw.yrW,leakyRelu:()=>sw.H8d,less:()=>sw.M7h,lessEqual:()=>sw.InN,linalg:()=>sw.mPL,linspace:()=>sw.mT8,localResponseNormalization:()=>sw.Kgs,log:()=>sw.Rm2,log1p:()=>sw.Kko,logSigmoid:()=>sw.nqI,logSoftmax:()=>sw.HPB,logSumExp:()=>sw.VZ,logicalAnd:()=>sw.n76,logicalNot:()=>sw.NSZ,logicalOr:()=>sw.ztW,logicalXor:()=>sw.rxB,losses:()=>sw.YYh,lowerBound:()=>sw.yzS,matMul:()=>sw.NoW,max:()=>sw.T9B,maxPool:()=>sw.jgi,maxPool3d:()=>sw.NYV,maxPoolWithArgmax:()=>sw.RO,maximum:()=>sw.PhQ,mean:()=>sw.i2o,meshgrid:()=>sw.OYQ,min:()=>sw.jkA,minimum:()=>sw.BpO,mirrorPad:()=>sw.FFZ,mod:()=>sw.ziu,moments:()=>sw.Clk,movingAverage:()=>sw.CRk,mul:()=>sw.lKK,multiRNNCell:()=>sw.YDF,multinomial:()=>sw.OjQ,neg:()=>sw.HZy,norm:()=>sw.xbf,notEqual:()=>sw.Ec,oneHot:()=>sw.Mw0,ones:()=>sw.SaS,onesLike:()=>sw.P61,op:()=>sw.op,outerProduct:()=>sw.X4o,pad:()=>sw.eVF,pad1d:()=>sw.BZs,pad2d:()=>sw.grY,pad3d:()=>sw.XHu,pad4d:()=>sw.WLX,pool:()=>sw.dzn,pow:()=>sw.n7C,prelu:()=>sw.NsG,print:()=>sw.yyV,prod:()=>sw._eU,raggedGather:()=>sw.whe,raggedRange:()=>sw.iyU,raggedTensorToTensor:()=>sw.Q0_,rand:()=>sw._9M,randomGamma:()=>sw.pR9,randomNormal:()=>sw.FE$,randomStandardNormal:()=>sw.m0H,randomUniform:()=>sw.YeY,randomUniformInt:()=>sw.HYA,range:()=>sw.y17,real:()=>sw.xav,reciprocal:()=>sw.VOZ,relu:()=>sw.VVh,relu6:()=>sw.j__,reshape:()=>sw.tQQ,reverse:()=>sw.BEg,reverse1d:()=>sw.QD2,reverse2d:()=>sw.LMr,reverse3d:()=>sw.I2l,reverse4d:()=>sw.JYU,rfft:()=>sw.z8$,round:()=>sw.LIG,rsqrt:()=>sw.Z$r,scalar:()=>sw.d_2,scatterND:()=>sw.NFr,searchSorted:()=>sw.sZg,selu:()=>sw.WfX,separableConv2d:()=>sw.wdz,setdiff1dAsync:()=>sw.F12,sigmoid:()=>sw.ry7,sign:()=>sw._SZ,signal:()=>sw.vPA,sin:()=>sw.F8e,sinh:()=>sw.L0l,slice:()=>sw.dik,slice1d:()=>sw.Q$M,slice2d:()=>sw.zAd,slice3d:()=>sw.wck,slice4d:()=>sw.R0O,softmax:()=>sw.Vs9,softplus:()=>sw.lw0,spaceToBatchND:()=>sw.eDJ,sparse:()=>sw.lMo,sparseToDense:()=>sw.Zhr,spectral:()=>sw.lOn,split:()=>sw.lDo,sqrt:()=>sw.RZD,square:()=>sw.EwI,squaredDifference:()=>sw.Pbu,squeeze:()=>sw.r2V,stack:()=>sw.t$z,step:()=>sw.PMw,stridedSlice:()=>sw.Ym9,string:()=>sw.YjP,sub:()=>sw.jbE,sum:()=>sw.czq,tan:()=>sw.Mlm,tanh:()=>sw.ymU,tensor:()=>sw.OEK,tensor1d:()=>sw.tGX,tensor2d:()=>sw.KtR,tensor3d:()=>sw.$_$,tensor4d:()=>sw.g9W,tensor5d:()=>sw.Lpo,tensor6d:()=>sw.yxw,tensorScatterUpdate:()=>sw.NNh,tile:()=>sw.Vsq,topk:()=>sw.rfw,transpose:()=>sw.mgz,truncatedNormal:()=>sw.efE,unique:()=>sw.AmM,unsortedSegmentSum:()=>sw.zAU,unstack:()=>sw.K$i,upperBound:()=>sw.rni,variable:()=>sw.bvq,where:()=>sw._M9,whereAsync:()=>sw.YJN,zeros:()=>sw.Ul9,zerosLike:()=>sw.POl});var F={};r.r(F),r.d(F,{CSVDataset:()=>iW,Dataset:()=>i$,FileDataSource:()=>i2,TextLineDataset:()=>iO,URLDataSource:()=>i3,array:()=>iR,csv:()=>i4,func:()=>i5,generator:()=>i6,microphone:()=>i9,version_data:()=>i8,webcam:()=>i7,zip:()=>i_});var R=r(51520),_=r(48592),D=r(16488),O=r(48683),L=r(71069);let M={kernelName:_.ljI,inputsToSave:["x"],gradFunc:(e,t)=>{let[r]=t;return{x:()=>(0,O.l)(e,(0,L.P)((0,D.w)(r,"float32"),-1))}}};var P=r(13062),z=r(28235),B=r(30319),W=r(76125),V=r(20160),G=r(92263);let U={kernelName:_.Vvy,inputsToSave:["x"],gradFunc:(e,t)=>{let[r]=t;return{x:()=>{let t=(0,V.E)((0,D.w)(r,"float32")),n=(0,W.R)((0,G.j)((0,B.d)(1),t));return(0,z.H)((0,P.y)(e,n))}}}}
191,Z={kernelName:_.PH8,inputsToSave:["x"],gradFunc:(e,t)=>{let[r]=t;return{x:()=>{let t=(0,W.R)((0,G.j)((0,V.E)((0,D.w)(r,"float32")),1));return(0,P.y)(e,t)}}}};var j=r(83231),H=r(68567),K=r(60966);let Y={kernelName:_.OMN,inputsToSave:["a","b"],gradFunc:(e,t)=>{let[r,n]=t,a=j.assertAndGetBroadcastShape(r.shape,n.shape);return{a:()=>{let t=e,n=j.getReductionAxes(r.shape,a);return n.length>0&&(t=(0,K.c)(t,n)),(0,H.t)(t,r.shape)},b:()=>{let t=e,r=j.getReductionAxes(n.shape,a);return r.length>0&&(t=(0,K.c)(t,r)),(0,H.t)(t,n.shape)}}}},Q={kernelName:_.EkD,saveAllInputs:!0,gradFunc:(e,t)=>{let r={};return t.forEach((t,n)=>{r[n]=()=>e.clone()}),r}};var q=r(79320);let X={kernelName:_.Jp_,inputsToSave:["x"],gradFunc:(e,t)=>{let[r]=t;return{x:()=>(0,q.P)(r)}}},J={kernelName:_.p_m,inputsToSave:["x"],gradFunc:(e,t)=>{let[r]=t;return{x:()=>(0,q.P)(r)}}},ee={kernelName:_.QKF,inputsToSave:["x"],gradFunc:(e,t)=>{let[r]=t;return{x:()=>(0,P.y)(e,(0,W.R)((0,G.j)((0,B.d)(1),(0,V.E)((0,D.w)(r,"float32")))))}}};var et=r(46842);let er={kernelName:_.epO,inputsToSave:["x"],gradFunc:(e,t)=>{let[r]=t;return{x:()=>{let t=(0,W.R)((0,et.W)((0,B.d)(1),(0,V.E)((0,D.w)(r,"float32"))));return(0,P.y)(e,t)}}}},en={kernelName:_.lxb,inputsToSave:["a","b"],gradFunc:(e,t)=>{let[r,n]=t,a=(0,j.assertAndGetBroadcastShape)(r.shape,n.shape);return{a:()=>{let t=(0,et.W)((0,V.E)(r),(0,V.E)(n)),s=(0,O.l)(e,(0,P.y)(n,t)),i=(0,j.getReductionAxes)(r.shape,a);return i.length>0&&(s=(0,K.c)(s,i)),(0,H.t)(s,r.shape)},b:()=>{let t=(0,et.W)((0,V.E)(r),(0,V.E)(n)),s=(0,z.H)((0,O.l)(e,(0,P.y)(r,t))),i=(0,j.getReductionAxes)(n.shape,a);return i.length>0&&(s=(0,K.c)(s,i)),(0,H.t)(s,n.shape)}}}},ea={kernelName:_.TyE,inputsToSave:["x"],gradFunc:(e,t)=>{let[r]=t;return{x:()=>(0,P.y)(e,(0,et.W)((0,V.E)((0,D.w)(r,"float32")),1))}}},es={kernelName:_.zP9,inputsToSave:["x"],gradFunc:(e,t)=>{let[r]=t;return{x:()=>(0,P.y)(e,(0,G.j)((0,B.d)(1),(0,V.E)((0,D.w)(r,"float32"))))}}};var ei=r(19041),eo=r(27924),el=r(76526),eu=r(39114),eh=r(62176);let ep=(0,eh.op)({avgPool3dGrad_:function(e,t,r,n,a,s){let i=(0,eo.YT)(e,"dy","avgPool3dGrad"),o=(0,eo.YT)(t,"input","avgPool3dGrad"),l=i,u=o,h=!1;4===o.rank&&(h=!0,l=(0,H.t)(i,[1,i.shape[0],i.shape[1],i.shape[2],i.shape[3]]),u=(0,H.t)(o,[1,o.shape[0],o.shape[1],o.shape[2],o.shape[3]])),el.vA(5===l.rank,()=>`Error in avgPool3dGrad: dy must be rank 5 but got rank ${l.rank}.`),el.vA(5===u.rank,()=>`Error in avgPool3dGrad: input must be rank 5 but got rank ${u.rank}.`),(0,eu.s_)("avgPool3dGrad",a,s);let p={dy:l,input:u},d=ei.T2.runKernel(_.wwC,p,{filterSize:r,strides:n,pad:a,dimRoundingMode:s});return h?(0,H.t)(d,[d.shape[1],d.shape[2],d.shape[3],d.shape[4]]):d}}),ed={kernelName:_.cS,inputsToSave:["x"],gradFunc:(e,t,r)=>
191{let[n]=t,{filterSize:a,strides:s,pad:i,dimRoundingMode:o}=r;return{x:()=>ep(e,n,a,s,i,o)}}},ec=(0,eh.op)({avgPoolGrad_:function(e,t,r,n,a){let s=(0,eo.YT)(e,"dy","avgPoolGrad"),i=(0,eo.YT)(t,"input","avgPoolGrad");el.vA(i.rank===s.rank,()=>`Rank of input (${i.rank}) does not match rank of dy (${s.rank})`);let o=i,l=s,u=!1;3===i.rank&&(u=!0,o=(0,H.t)(i,[1,i.shape[0],i.shape[1],i.shape[2]]),l=(0,H.t)(s,[1,s.shape[0],s.shape[1],s.shape[2]])),el.vA(4===l.rank,()=>`Error in avgPoolGrad: dy must be rank 4 but got rank ${l.rank}.`),el.vA(4===o.rank,()=>`Error in avgPoolGrad: input must be rank 4 but got rank ${o.rank}.`);let h={dy:l,input:o},p=ei.T2.runKernel(_.VCH,h,{filterSize:r,strides:n,pad:a});return u?(0,H.t)(p,[p.shape[1],p.shape[2],p.shape[3]]):p}}),ef={kernelName:_.ho8,inputsToSave:["x"],gradFunc:(e,t,r)=>{let[n]=t,{filterSize:a,strides:s,pad:i}=r;return{x:()=>ec(e,n,a,s,i)}}};var em=r(67454);let eg={kernelName:_.jAQ,inputsToSave:["a","b"],gradFunc:(e,t,r)=>{let[n,a]=t,{transposeA:s,transposeB:i}=r;return s||i?!s&&i?{a:()=>(0,em.N)(e,a,!1,!1),b:()=>(0,em.N)(e,n,!0,!1)}:s&&!i?{a:()=>(0,em.N)(a,e,!1,!0),b:()=>(0,em.N)(n,e,!1,!1)}:{a:()=>(0,em.N)(a,e,!0,!0),b:()=>(0,em.N)(e,n,!0,!0)}:{a:()=>(0,em.N)(e,a,!1,!0),b:()=>(0,em.N)(n,e,!0,!1)}}};var ey=r(51097);let eb={kernelName:_.Ik2,gradFunc:(e,t,r)=>{let{blockShape:n,crops:a}=r;return{x:()=>(0,ey.e)(e,n,a)}}},ex={kernelName:_.LB5,gradFunc:(e,t,r)=>{let n=r.inputShape,a=r.shape,s=Array.from(a);for(let e=n.length-1;e>=0;e--)if(n[e]===a[e])s[e]=1;else if(1!==n[e])throw Error(`broadcastTo(): [${n}] cannot be broadcast to [${a}].`);let i=[];for(let e=0;e<s.length;e++)s[e]>1&&i.push(e);return{x:()=>(0,K.c)(e,i,!0)}}},ev={kernelName:_.KXH,gradFunc:e=>({x:()=>e.clone()})}
191,ew={kernelName:_.QDP,gradFunc:e=>({x:()=>(0,q.P)(e)})};var eT=r(91104),eS=r(47293),eN=r(32428),ek=r(82198);let eI={kernelName:_.vaV,inputsToSave:["x"],gradFunc:(e,t,r)=>{let[n]=t,{clipValueMin:a,clipValueMax:s}=r;return{x:()=>(0,ek._)((0,eN.n)((0,eT.D)(n,a),(0,eS.I)(n,s)),e,(0,q.P)(e))}}},eC={kernelName:_.$zE,inputsToSave:["x"],gradFunc:M.gradFunc};var eE=r(24361);let eA={kernelName:_.$dB,saveAllInputs:!0,gradFunc:(e,t,r)=>{let n=t.map(e=>e.shape),{axis:a}=r,s=(0,el.Y6)(a,t[0].shape)[0],i=n.map(e=>e[s]);return(0,eE.l)(e,i,s).map(e=>()=>e)}};var e$=r(40953),eF=r(78213);let eR={kernelName:_.p2J,inputsToSave:["x","filter"],gradFunc:(e,t,r)=>{let[n,a]=t,{dilations:s,strides:i,pad:o,dataFormat:l}=r;return el.vA(eu.Dh(s),()=>`Error in gradient of conv2D: dilation rates greater than 1 are not yet supported in gradients. Got dilations '${s}'`),{x:()=>(0,eF.v)(n.shape,e,a,i,o,l),filter:()=>(0,e$.H)(n,e,a.shape,i,o,l)}}};var e_=r(90715);let eD={kernelName:_.jfg,inputsToSave:["dy","filter"],gradFunc:(e,t,r)=>{let[n,a]=t,{strides:s,pad:i,dataFormat:o,dimRoundingMode:l}=r;return{dy:()=>(0,e_.X)(e,a,s,i,o,1,l),filter:()=>(0,e$.H)(e,n,a.shape,s,i,o,l)}}},eO=(0,eh.op)({conv3DBackpropFilter_:function(e,t,r,n,a){let s=e;4===e.rank&&(s=(0,H.t)(e,[1,e.shape[0],e.shape[1],e.shape[2],e.shape[3]]));let i=t;4===i.rank&&(i=(0,H.t)(t,[1,t.shape[0],t.shape[1],t.shape[2],t.shape[3]])),el.vA(5===s.rank,()=>`Error in conv3dDerFilter: input must be rank 5, but got shape ${s.shape}.`),el.vA(5===i.rank,()=>`Error in conv3dDerFilter: dy must be rank 5, but got shape ${i.shape}.`),el.vA(5===r.length,()=>`Error in conv3dDerFilter: filterShape must be length 5, but got ${r}.`),el.vA(s.shape[4]===r[3],()=>`Error in conv3dDerFilter: depth of input ${s.shape[4]}) must match input depth in filter (${r[3]}.`),el.vA(i.shape[4]===r[4],()=>`Error in conv3dDerFilter: depth of dy (${i.shape[4]}) must match output depth for filter (${r[4]}).`);let o={x:s,dy:i};return ei.T2.runKernel(_.iGz,o,{strides:n,pad:a,filterShape:r})}});var eL=r(1374);let eM={kernelName:_.A1h,inputsToSave:["x","filter"],gradFunc:(e,t,r)=>{let{dilations:n,strides:a,pad:s}=r;el.vA((0,eu.Dh)(n),()=>`Error in gradient of conv3D: dilation rates greater than 1 are not yet supported in gradients. Got dilations '${n}'`);let[i,o]=t;return{x:()=>(0,eL.c)(i.shape,e,o,a,s),filter:()=>eO(i,e,o.shape,a,s)}}};var eP=r(50943);let ez={kernelName:_.Mn0,inputsToSave:["x"],gradFunc:(e,t)=>{let[r]=t;return{x:()=>(0,O.l)((0,z.H)((0,eP.F)((0,D.w)(r,"float32"))),e)}}};var eB=r(27085);let eW={kernelName:_.MnK,inputsToSave:["x"],gradFunc:(e,t)=>{let[r]=t;return{x:()=>(0,O.l)((0,eB.L)((0,D.w)(r,"float32")),e)}}};var eV=r(61727),eG=r(83641),eU=r(60286);let eZ={kernelName:_.nY8,inputsToSave:["x"],gradFunc:(e,t,r)=>
191{let[n]=t,{axis:a,exclusive:s,reverse:i}=r;return{x:()=>{let t=(0,eV.Em)([a],n.rank),r=(0,eG.r)(e,a,s,!i);return null!=t&&(r=(0,eU.m)(r,t)),r}}}};var ej=r(52123),eH=r(90855);let eK={kernelName:_.tGH,inputsToSave:["x","filter"],gradFunc:(e,t,r)=>{let{dilations:n,strides:a,pad:s,dimRoundingMode:i}=r,o=null==n?[1,1]:n;el.vA(eu.Dh(o),()=>`Error in gradient of depthwiseConv2dNative: dilation rates greater than 1 are not yet supported. Got dilations '${o}'`);let[l,u]=t;return el.vA(4===l.rank,()=>`Error in gradient of depthwiseConv2dNative: input must be rank 4, but got rank ${l.rank}.`),el.vA(4===u.rank,()=>`Error in gradient of depthwiseConv2dNative: filter must be rank 4, but got rank ${u.rank}.`),el.vA(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]}.`),el.vA(eu.G0(a,o),()=>`Error in gradient of depthwiseConv2d: Either strides or dilations must be 1. Got strides ${a} and dilations '${o}'.`),eu.s_("depthwiseConv2d",s,i),{x:()=>(0,eH.l)(l.shape,e,u,a,s,o,i),filter:()=>(0,ej.x)(l,e,u.shape,a,s,o,i)}}},eY={kernelName:_.jxD,inputsToSave:["x","filter"],gradFunc:(e,t,r)=>
191{let[n,a]=t,s={x:n,filter:a,dy:e},i={x:n,filter:a,dy:e};return{x:()=>ei.T2.runKernel(_.bP9,s,r),filter:()=>ei.T2.runKernel(_.pk0,i,r)}}},eQ={kernelName:_.Pah,outputsToSave:[!0],gradFunc:(e,t)=>{let[r]=t,n={dy:e,y:r};return{x:()=>ei.T2.runKernel(_.rsH,n)}}};var eq=r(25158);let eX={kernelName:_._s9,inputsToSave:["x"],gradFunc:(e,t)=>{let[r]=t,n=(0,O.l)((0,eq.o)((0,z.H)((0,V.E)(r))),2/Math.sqrt(Math.PI));return{x:()=>(0,O.l)(e,n)}}},eJ={kernelName:_.ox3,outputsToSave:[!0],gradFunc:(e,t)=>{let[r]=t;return{x:()=>(0,O.l)(e,r)}}},e0={kernelName:_.ybN,inputsToSave:["input"],gradFunc:(e,t)=>{let[r]=t;return{input:()=>(0,H.t)(e,r.shape)}}},e1={kernelName:_.ybj,inputsToSave:["x"],gradFunc:(e,t)=>{let[r]=t;return{x:()=>(0,O.l)(e,(0,eq.o)(r))}}},e2={kernelName:_.ZgB,gradFunc:e=>({x:()=>(0,q.P)(e)})},e3={kernelName:_.ElG,inputsToSave:["a","b"],gradFunc:(e,t)=>{let[r,n]=t,a=(0,j.assertAndGetBroadcastShape)(r.shape,n.shape);return{a:()=>{let t=(0,P.y)(e,(0,D.w)(n,"float32")),s=(0,j.getReductionAxes)(r.shape,a);return s.length>0?(0,H.t)((0,K.c)(t,s),r.shape):t},b:()=>{let t=(0,O.l)(e,(0,D.w)(r,"float32")),s=(0,j.getReductionAxes)(n.shape,a);s.length>0&&(t=(0,H.t)((0,K.c)(t,s),n.shape));let i=(0,V.E)(n);return(0,z.H)((0,P.y)(t,(0,D.w)(i,"float32")))}}}};var e4=r(15181),e5=r(97651);let e6={kernelName:_.i5R,inputsToSave:["x","mean","variance","scale"],gradFunc:(e,t,r)=>{let{varianceEpsilon:n}=r,[a,s,i,o]=t,l=null==o?(0,B.d)(1):o,u=(0,j.getReductionAxes)(s.shape,a.shape),h=[];if(1===s.rank){for(let e=0;e<a.shape.length-1;++e)h.push(a.shape[e]);h.push(1)}let p=(0,G.j)(a,s),d=(0,O.l)(e,l),c=(0,e4.Z)((0,et.W)(i,(0,B.d)(n))),f=(0,O.l)((0,O.l)((0,O.l)(c,c),c),(0,B.d)(-.5));return{x:()=>1===s.rank?(0,H.t)((0,O.l)((0,O.l)(e,(0,e5.V)((0,H.t)(c,[1,1,1,s.shape[0]]),h)),l),a.shape):(0,H.t)((0,O.l)((0,O.l)(e,c),l),a.shape),mean:()=>{let e=(0,O.l)((0,O.l)(c,(0,B.d)(-1)),d);return 1===s.rank&&(e=(0,K.c)(e,u)),(0,H.t)(e,s.shape)},variance:()=>{let e=(0,O.l)((0,O.l)(f,p),d);return 1===s.rank&&(e=(0,K.c)(e,u)),(0,H.t)(e,s.shape)},scale:()=>{let t=(0,O.l)(p,c),r=(0,O.l)(e,t);return 1===s.rank&&(r=(0,K.c)(r,u)),(0,H.t)(r,s.shape)},offset:()=>{let t=e;return 1===s.rank&&(t=(0,K.c)(t,u)),(0,H.t)(t,s.shape)}}}};var e7=r(35981),e9=r(5051);let e8={kernelName:_.mxL,inputsToSave:["x","indices"],gradFunc:(e,t,r)=>
191{let[n,a]=t,{axis:s,batchDims:i}=r,o=(0,el.Y6)(s,n.shape)[0],l=(e,t,r)=>()=>{let n=e.shape,a=t.size,i=n.slice(0,o),l=i.length,u=n.slice(s,n.length).slice(1),h=u.length,p=te(0,l),d=te(l+1,l+1+h),c=tt([i,[a],u]),f=(0,H.t)(r,c),m=(0,H.t)(t,[a]),g=tt([[l],p,d]),y=(0,eU.m)(f,g),b=(0,e9.z)(y,m,e.shape[o]),x=(0,eV.gx)(g);return(0,eU.m)(b,x)};if(1!==i)return{x:l(n,a,e),indices:()=>a};{let t=n.shape[0],r=n.split(t,0);return{x:()=>(0,e7.t)(r.map((t,r)=>l(t,a.slice(r,1),e.slice(r,1))())).reshape(n.shape),indices:()=>a}}}};function te(e,t){let r=[];for(let n=e;n<t;++n)r.push(n);return r}function tt(e){let t=[];for(let r=0;r<e.length;++r)for(let n=0;n<e[r].length;++n)t.push(e[r][n]);return t}let tr={kernelName:_.lLS,inputsToSave:["a","b"],gradFunc:(e,t)=>{let[r,n]=t;return{a:()=>(0,q.P)(r),b:()=>(0,q.P)(n)}}},tn={kernelName:_.lzr,gradFunc:e=>({x:()=>(0,D.w)(e,"float32")})},ta={kernelName:_.gIW,gradFunc:e=>({x:()=>(0,q.P)(e)})},ts={kernelName:_.E3$,gradFunc:e=>({x:()=>(0,q.P)(e)})},ti={kernelName:_.iPs,gradFunc:e=>({x:()=>(0,q.P)(e)})};var to=r(25283);let tl={kernelName:_.X0$,inputsToSave:["x"],gradFunc:(e,t,r)=>
191{let[n]=t,{alpha:a}=r,s=(0,to.r)(n,0);return{x:()=>(0,ek._)(s,e,(0,O.l)(e,a))}}},tu={kernelName:_.Cg$,inputsToSave:["x"],gradFunc:(e,t)=>{let[r]=t;return{x:()=>(0,P.y)(e,(0,et.W)(r,1))}}},th={kernelName:_.tG8,inputsToSave:["x"],gradFunc:(e,t)=>{let[r]=t;return{x:()=>(0,P.y)(e,(0,D.w)(r,"float32"))}}},tp={kernelName:_.zfU,inputsToSave:[],outputsToSave:[!0],gradFunc:(e,t,r)=>{let[n]=t,{axis:a}=r;return{logits:()=>{let t=(0,eq.o)(n);return(0,G.j)(e,(0,O.l)((0,K.c)(e,a,!0),t))}}}},td=(0,eh.op)({localResponseNormalizationBackprop_:function(e,t,r,n=5,a=1,s=1,i=.5){return ei.T2.runKernel(_.ToN,{x:e,y:t,dy:r},{depthRadius:n,bias:a,alpha:s,beta:i})}}),tc={kernelName:_.jM4,inputsToSave:["x"],outputsToSave:[!0],gradFunc:(e,t,r)=>{let[n,a]=t,{depthRadius:s,bias:i,alpha:o,beta:l}=r;return{x:()=>td(n,a,e,s,i,o,l)}}};var tf=r(12989);function tm(e,t,r,n){return t.rank<r.rank&&(t=(0,H.t)(t,eV.SM(t.shape,n))),e.rank<r.rank&&(e=(0,H.t)(e,eV.SM(e.shape,n))),{x:()=>(0,O.l)(e,(0,D.w)((0,tf.L)(r,t),e.dtype))}}let tg={kernelName:_.VAI,inputsToSave:["x"],outputsToSave:[!0],gradFunc:(e,t,r)=>{let{reductionIndices:n}=r,a=t[0],s=t[1],i=el.Y6(n,a.shape),o=tm(e,s,a,i);return{x:()=>o.x()}}};var ty=r(18358);let tb={kernelName:_.LDN,inputsToSave:["a","b"],gradFunc:(e,t)=>{let[r,n]=t;return{a:()=>(0,O.l)(e,(0,D.w)((0,eT.D)(r,n),"float32")),b:()=>(0,O.l)(e,(0,D.w)((0,ty.M)(r,n),"float32"))}}},tx=(0,eh.op)({maxPool3dGrad_:function(e,t,r,n,a,s,i){let o=(0,eo.YT)(e,"dy","maxPool3dGrad"),l=(0,eo.YT)(t,"input","maxPool3dGrad"),u=(0,eo.YT)(r,"output","maxPool3dGrad"),h=o,p=l,d=u,c=!1;4===l.rank&&(c=!0,h=(0,H.t)(o,[1,o.shape[0],o.shape[1],o.shape[2],o.shape[3]]),p=(0,H.t)(l,[1,l.shape[0],l.shape[1],l.shape[2],l.shape[3]]),d=(0,H.t)(u,[1,u.shape[0],u.shape[1],u.shape[2],u.shape[3]])),el.vA(5===h.rank,()=>`Error in maxPool3dGrad: dy must be rank 5 but got rank ${h.rank}.`),el.vA(5===p.rank,()=>`Error in maxPool3dGrad: input must be rank 5 but got rank ${p.rank}.`),el.vA(5===d.rank,()=>`Error in maxPool3dGrad: output must be rank 5 but got rank ${d.rank}.`),(0,eu.s_)("maxPool3dGrad",s,i);let f={dy:h,input:p,output:d},m=ei.T2.runKernel(_.cHb,f,{filterSize:n,strides:a,pad:s,dimRoundingMode:i});return c?(0,H.t)(m,[m.shape[1],m.shape[2],m.shape[3],m.shape[4]]):m}}),tv={kernelName:_.ySp,inputsToSave:["x"],outputsToSave:[!0],gradFunc:(e,t,r)=>
191{let[n,a]=t,{filterSize:s,strides:i,pad:o,dimRoundingMode:l}=r;return{x:()=>tx(e,n,a,s,i,o,l)}}},tw=(0,eh.op)({maxPoolGrad_:function(e,t,r,n,a,s,i){let o=(0,eo.YT)(e,"dy","maxPoolGrad"),l=(0,eo.YT)(t,"input","maxPoolGrad"),u=(0,eo.YT)(r,"output","maxPoolGrad");return el.vA(l.rank===o.rank,()=>`Rank of input (${l.rank}) does not match rank of dy (${o.rank})`),el.vA(4===o.rank,()=>`Error in maxPoolGrad: dy must be rank 4 but got rank ${o.rank}.`),el.vA(4===l.rank,()=>`Error in maxPoolGrad: input must be rank 4 but got rank ${l.rank}.`),eu.s_("maxPoolGrad",s,i),ei.T2.runKernel(_.RXX,{dy:o,input:l,output:u},{filterSize:n,strides:a,pad:s,dimRoundingMode:i})}}),tT={kernelName:_.t3d,inputsToSave:["x"],outputsToSave:[!0],gradFunc:(e,t,r)=>{let[n,a]=t,{filterSize:s,strides:i,pad:o}=r;return{x:()=>tw(e,n,a,s,i,o)}}};var tS=r(57690);let tN={kernelName:_.g5A,inputsToSave:["x"],gradFunc:(e,t,r)=>{let[n]=t,{axis:a}=r,s=el.Y6(a,n.shape),i=(0,eV.lb)(n.shape,s)[1],o=el.Ze(i);return{x:()=>{let t=n.shape.slice();s.forEach(e=>{t[e]=1});let r=(0,H.t)(e,t);return(0,P.y)((0,O.l)(r,(0,tS.S)(n.shape,"float32")),o)}}}},tk={kernelName:_.lNG,inputsToSave:["x"],outputsToSave:[!0],gradFunc:(e,t,r)=>{let{axis:n}=r,[a,s]=t,i=el.Y6(n,a.shape),o=tm(e,s,a,i);return{x:()=>o.x()}}},tI={kernelName:_.LG0,inputsToSave:["a","b"],gradFunc:(e,t)=>{let[r,n]=t;return{a:()=>(0,O.l)(e,(0,D.w)((0,eS.I)(r,n),"float32")),b:()=>(0,O.l)(e,(0,D.w)((0,to.r)(r,n),"float32"))}}};var tC=r(82171);let tE={kernelName:_.x7F,inputsToSave:["x"],gradFunc:(e,t,r)=>{let n=t[0],{paddings:a}=r,s=a.map(e=>e[0]);return{x:()=>(0,tC.d)(e,s,n.shape)}}};var tA=r(91951);let t$={kernelName:_.BLA,inputsToSave:["a","b"],gradFunc:(e,t)=>{let[r,n]=t,a=(0,j.assertAndGetBroadcastShape)(r.shape,n.shape);return{a:()=>{let t=(0,j.getReductionAxes)(r.shape,a);return t.length>0?(0,H.t)((0,K.c)(e,t),r.shape):e},b:()=>{let t=(0,O.l)(e,(0,z.H)((0,tA.R)((0,P.y)(r,n)))),s=(0,j.getReductionAxes)(n.shape,a);return s.length>0?(0,H.t)((0,K.c)(t,s),n.shape):t}}}},tF={kernelName:_.xu7,inputsToSave:["a","b"],gradFunc:(e,t)=>{let[r,n]=t,a=(0,j.assertAndGetBroadcastShape)(r.shape,n.shape);return{a:()=>{let t=(0,O.l)(e,(0,D.w)(n,"float32")),s=(0,j.getReductionAxes)(r.shape,a);return s.length>0?(0,H.t)((0,K.c)(t,s),r.shape):t},b:()=>{let t=(0,O.l)(e,(0,D.w)(r,"float32")),s=(0,j.getReductionAxes)(n.shape,a);return s.length>0?(0,H.t)((0,K.c)(t,s),n.shape):t}}}}
191,tR={kernelName:_.l0G,gradFunc:e=>({x:()=>(0,z.H)(e)})};var t_=r(59918);let tD={kernelName:_.urI,inputsToSave:["indices"],gradFunc:(e,t)=>{let r=t[0];return{indices:()=>(0,t_.U)(r.shape,"float32")}}},tO={kernelName:_.LWX,gradFunc:e=>({x:()=>(0,q.P)(e)})};var tL=r(64828);let tM={kernelName:_.mM$,saveAllInputs:!0,gradFunc:(e,t,r)=>{let{axis:n}=r;return(0,tL.K)(e,n).map(e=>()=>e)}},tP={kernelName:_.ODT,inputsToSave:["x"],gradFunc:(e,t,r)=>{let n=t[0],{paddings:a}=r,s=a.map(e=>e[0]);return{x:()=>(0,tC.d)(e,s,n.shape)}}};var tz=r(29659),tB=r(25351);let tW={kernelName:_.pyJ,inputsToSave:["a","b"],outputsToSave:[!0],gradFunc:(e,t)=>{let[r,n,a]=t,s=j.assertAndGetBroadcastShape(r.shape,n.shape);return{a:()=>{let t=(0,D.w)(n,"float32"),a=(0,O.l)(e,(0,O.l)(t,(0,tB.n)(r,(0,G.j)(t,(0,B.d)(1))))),i=j.getReductionAxes(r.shape,s);return i.length>0&&(a=(0,K.c)(a,i)),(0,H.t)(a,r.shape)},b:()=>{let t=(0,to.r)(r,0),i=(0,ek._)(t,(0,tz.R)(r),(0,q.P)(r)),o=(0,O.l)(e,(0,O.l)(a,i)),l=j.getReductionAxes(n.shape,s);return l.length>0&&(o=(0,K.c)(o,l)),(0,H.t)(o,n.shape)}}}},tV={kernelName:_.Ncv,inputsToSave:["x","alpha"],gradFunc:(e,t)=>{let[r,n]=t,a=(0,to.r)(r,0);return{x:()=>(0,ek._)(a,e,(0,O.l)(e,n)),alpha:()=>{let t=(0,ek._)(a,(0,q.P)(e),(0,O.l)(e,r)),s=(0,j.getReductionAxes)(n.shape,e.shape);return s.length>0&&(t=(0,K.c)(t,s)),(0,H.t)(t,n.shape)}}}};var tG=r(46660);let tU={kernelName:_.kdj,inputsToSave:["x"],gradFunc:(e,t,r)=>
191{let[n]=t,{axis:a}=r,s=[];return s=null==a?n.shape.map((e,t)=>t):"number"==typeof a?[a]:a,{x:()=>(function(e,t,r){let n=e.shape.length,a=n-r.length,s=eV.Em(r,n),i=e;null!=s&&(i=(0,eU.m)(e,s));let o=i.shape.slice(),l=o.splice(n-r.length,r.length).reduce((e,t)=>e*t,1);o.push(l);let u=function(e,t,r){let n=e.shape.slice();n[r]=1;let a=(0,H.t)(t,n),s=(0,tG.L)(e,r,!0,!1),i=(0,tG.L)(e,r,!0,!0),o=(0,O.l)(s,i);return(0,O.l)(a,o)}(i.reshape(o),t,a);if(u=u.reshape(i.shape),null!=s){let e=eV.gx(s);u=(0,eU.m)(u,e)}return u})(n,e,s)}}},tZ={kernelName:_.sDr,inputsToSave:["a","b"],gradFunc:(e,t)=>{let[r,n]=t,a=j.assertAndGetBroadcastShape(r.shape,n.shape);return{a:()=>{let t=(0,P.y)(e,(0,D.w)(n,"float32")),s=j.getReductionAxes(r.shape,a);return s.length>0?(0,H.t)((0,K.c)(t,s),r.shape):t},b:()=>{let t=(0,O.l)(e,(0,D.w)(r,"float32")),s=j.getReductionAxes(n.shape,a);s.length>0&&(t=(0,H.t)((0,K.c)(t,s),n.shape));let i=(0,V.E)(n);return(0,z.H)((0,P.y)(t,(0,D.w)(i,"float32")))}}}},tj={kernelName:_.huO,inputsToSave:["x"],gradFunc:(e,t)=>{let[r]=t;return{x:()=>(0,P.y)(e,(0,z.H)((0,V.E)(r)))}}},tH={kernelName:_.P_L,inputsToSave:["x"],gradFunc:(e,t)=>{let[r]=t,n=(0,O.l)((0,eS.I)(r,6),(0,L.P)(r));return{x:()=>(0,O.l)(e,(0,D.w)(n,"float32"))}}},tK={kernelName:_.fUj,inputsToSave:["x"],gradFunc:(e,t)=>{let[r]=t;return{x:()=>(0,O.l)(e,(0,D.w)((0,L.P)(r),"float32"))}}},tY={kernelName:_.R23,inputsToSave:["x"],gradFunc:(e,t)=>{let[r]=t;return{x:()=>(0,H.t)(e,r.shape)}}},tQ={kernelName:_.hgw,inputsToSave:["images"],gradFunc:(e,t,r)=>
191{let[n]=t,a={dy:e,images:n};return{images:()=>ei.T2.runKernel(_.FCQ,a,r)}}},tq={kernelName:_.jOE,inputsToSave:["images"],gradFunc:(e,t,r)=>{let[n]=t,a={dy:e,images:n};return{images:()=>ei.T2.runKernel(_.XQy,a,r)}}};var tX=r(63191);let tJ={kernelName:_.D7i,gradFunc:(e,t,r)=>{let{dims:n}=r,a=(0,el.Y6)(n,e.shape);return{x:()=>(0,tX.B)(e,a)}}},t0={kernelName:_.hVg,gradFunc:e=>({x:()=>(0,q.P)(e)})},t1={kernelName:_.TOR,inputsToSave:["x"],gradFunc:(e,t)=>{let[r]=t;return{x:()=>(0,z.H)((0,P.y)(e,(0,O.l)((0,tB.n)(r,1.5),2)))}}};var t2=r(83152);let t3={kernelName:_.l6P,inputsToSave:["condition"],gradFunc:(e,t)=>{let[r]=t;return{condition:()=>(0,D.w)((0,q.P)(r),"float32"),t:()=>(0,O.l)(e,(0,D.w)(r,e.dtype)),e:()=>(0,O.l)(e,(0,D.w)((0,t2.N)(r),e.dtype))}}};var t4=r(93473);let t5={kernelName:_.u$b,inputsToSave:["x"],gradFunc:(e,t)=>{let[r]=t;return{x:()=>{let t=(0,to.r)(r,(0,B.d)(0)),n=(0,B.d)(t4.j),a=(0,B.d)(t4.X),s=(0,O.l)(e,a),i=(0,O.l)((0,O.l)(e,n),(0,eq.o)((0,D.w)(r,"float32")));return(0,ek._)(t,s,i)}}}},t6={kernelName:_.vI1,outputsToSave:[!0],gradFunc:(e,t)=>{let[r]=t;return{x:()=>(0,O.l)(e,(0,O.l)(r,(0,G.j)((0,B.d)(1),r)))}}},t7={kernelName:_.YVe,gradFunc:e=>({x:()=>(0,q.P)(e)})};var t9=r(53858);let t8={kernelName:_.hql,inputsToSave:["x"],gradFunc:(e,t)=>{let[r]=t;return{x:()=>(0,O.l)((0,t9.g)((0,D.w)(r,"float32")),e)}}};var re=r(92610);let rt={kernelName:_.J3C,inputsToSave:["x"],gradFunc:(e,t)=>{let[r]=t;return{x:()=>(0,O.l)((0,re.y)((0,D.w)(r,"float32")),e)}}};var rr=r(50684),rn=r(14600);let ra={kernelName:_.JiE,inputsToSave:["x"],gradFunc:(e,t,r)=>
191{let[n]=t,{begin:a,size:s}=r,i=n.shape,[o,l]=(0,rn.parseSliceParams)(n,a,s),u=[];for(let t=0;t<e.rank;t++)u.push([o[t],i[t]-o[t]-l[t]]);return{x:()=>(0,rr.e)(e,u)}}},rs={kernelName:_.rFG,outputsToSave:[!0],gradFunc:(e,t,r)=>{let[n]=t,{dim:a}=r,s=(0,O.l)(e,n);return{logits:()=>(0,G.j)(s,(0,O.l)((0,K.c)(s,[a],!0),n))}}};var ri=r(75761);let ro={kernelName:_.Fin,inputsToSave:["x"],gradFunc:(e,t)=>{let[r]=t;return{x:()=>(0,O.l)(e,(0,ri.r)(r))}}};var rl=r(52285);let ru={kernelName:_.A8B,gradFunc:(e,t,r)=>{let{blockShape:n,paddings:a}=r;return{x:()=>(0,rl.G)(e,n,a)}}};var rh=r(88527);let rp={kernelName:_.Blb,gradFunc:(e,t,r)=>{let{axis:n}=r;return{x:()=>(0,rh.x)(e,n)}}},rd={kernelName:_.dFH,inputsToSave:["x"],gradFunc:(e,t)=>{let[r]=t;return{x:()=>(0,P.y)(e,(0,O.l)((0,W.R)((0,D.w)(r,"float32")),2))}}},rc={kernelName:_.M6A,inputsToSave:["x"],gradFunc:(e,t)=>{let[r]=t;return{x:()=>(0,O.l)(e,(0,O.l)((0,D.w)(r,"float32"),2))}}},rf={kernelName:_.Ddj,inputsToSave:["a","b"],gradFunc:(e,t)=>{let[r,n]=t,a=(0,B.d)(2);return{a:()=>(0,O.l)(e,(0,O.l)(a,(0,G.j)(r,n))),b:()=>(0,O.l)(e,(0,O.l)(a,(0,G.j)(n,r)))}}},rm={kernelName:_.pnw,gradFunc:e=>({x:()=>(0,q.P)(e)})},rg={kernelName:_.PbM,inputsToSave:["a","b"],gradFunc:(e,t)=>{let[r,n]=t,a=j.assertAndGetBroadcastShape(r.shape,n.shape);return{a:()=>{let t=e,n=j.getReductionAxes(r.shape,a);return n.length>0&&(t=(0,K.c)(t,n)),(0,H.t)(t,r.shape)},b:()=>{let t=e,r=j.getReductionAxes(n.shape,a);return r.length>0&&(t=(0,K.c)(t,r)),(0,H.t)((0,z.H)(t),n.shape)}}}},ry={kernelName:_.WuN,inputsToSave:["x"],gradFunc:(e,t,r)=>
191{let[n]=t,a=n.shape.slice(),{axis:s}=r;(0,el.Y6)(s,n.shape).forEach(e=>{a[e]=1});let i=(0,H.t)(e,a),o=(0,O.l)(i,(0,tS.S)(n.shape,"float32"));return{x:()=>o}}},rb={kernelName:_.oFs,inputsToSave:["x"],gradFunc:(e,t)=>{let[r]=t;return{x:()=>(0,P.y)(e,(0,V.E)((0,t9.g)(r)))}}},rx={kernelName:_.iuW,outputsToSave:[!0],gradFunc:(e,t)=>{let[r]=t;return{x:()=>(0,O.l)((0,G.j)((0,B.d)(1),(0,V.E)(r)),e)}}},rv={kernelName:_.FAs,inputsToSave:["x"],gradFunc:(e,t,r)=>{let[n]=t,{reps:a}=r;return{x:()=>{let t=(0,q.P)(n);if(1===n.rank)for(let r=0;r<a[0];++r)t=(0,et.W)(t,(0,tC.d)(e,[r*n.shape[0]],[n.shape[0]]));else if(2===n.rank)for(let r=0;r<a[0];++r)for(let s=0;s<a[1];++s)t=(0,et.W)(t,(0,tC.d)(e,[r*n.shape[0],s*n.shape[1]],[n.shape[0],n.shape[1]]));else if(3===n.rank)for(let r=0;r<a[0];++r)for(let s=0;s<a[1];++s)for(let i=0;i<a[2];++i)t=(0,et.W)(t,(0,tC.d)(e,[r*n.shape[0],s*n.shape[1],i*n.shape[2]],[n.shape[0],n.shape[1],n.shape[2]]));else if(4===n.rank)for(let r=0;r<a[0];++r)for(let s=0;s<a[1];++s)for(let i=0;i<a[2];++i)for(let o=0;o<a[3];++o)t=(0,et.W)(t,(0,tC.d)(e,[r*n.shape[0],s*n.shape[1],i*n.shape[2],o*n.shape[3]],[n.shape[0],n.shape[1],n.shape[2],n.shape[3]]));else throw Error(`Gradient for tile operation is not implemented for rank-${n.rank} tensors yet.`);return t}}}},rw={kernelName:_.wx0,gradFunc:(e,t,r)=>{let{perm:n}=r,a=eV.gx(n);return{x:()=>(0,eU.m)(e,a)}}},rT={kernelName:_.dXR,gradFunc:(e,t,r)=>{let{axis:n}=r;return{value:()=>(0,e7.t)(e,n)}}};var rS=r(7487),rN=r(72796),rk=r(80107);let rI={kernelName:_.pPe,inputsToSave:["segmentIds"],gradFunc:(e,t)=>{let[r]=t;return{x:()=>(function(e,t){let r=(0,rk.P)(t,(0,q.P)(t)),n=(0,rN.k)(e,r),a=(0,eT.D)(t,(0,B.d)(0,"int32")),s=n.rank-a.rank;for(let e=0;e<s;++e)a=(0,rS.U)(a,e+1);a=(0,eN.n)(a,(0,tS.S)(n.shape,"bool"));let i=(0,q.P)(n);return(0,ek._)(a,n,i)})(e,r)}}}
191,rC={kernelName:_.xJ3,gradFunc:e=>({x:()=>(0,q.P)(e)})};var rE=r(53147);for(let e of[M,U,Z,Y,Q,X,J,ee,er,en,ea,es,ed,ef,eg,eb,ex,ev,ew,eI,eC,eA,eD,eR,eM,ez,eW,eZ,eK,eY,tZ,eQ,eX,eJ,e0,e1,e3,e2,e6,e8,tr,tn,ta,ts,ti,tl,tu,th,tp,tc,tg,tg,tb,tv,tT,tN,tk,tI,tE,t$,tF,tR,tD,tO,tM,tP,tP,tW,tV,tU,tj,tH,tK,tY,tQ,tq,tJ,t0,t1,t3,t5,t6,t7,t8,rt,ra,rs,ro,ru,ru,rp,rp,rd,rf,rc,rm,rg,ry,rb,rx,rv,rw,rT,rI,rC])(0,rE.kr)(e);var rA=r(13825),r$=r(60218);(0,r$.tp)().prototype.abs=function(){return this.throwIfDisposed(),(0,rA.t)(this)};var rF=r(26765);(0,r$.tp)().prototype.acos=function(){return this.throwIfDisposed(),(0,rF.H)(this)};var rR=r(59591);(0,r$.tp)().prototype.acosh=function(){return this.throwIfDisposed(),(0,rR.F)(this)},(0,r$.tp)().prototype.add=function(e){return this.throwIfDisposed(),(0,et.W)(this,e)};var r_=r(73546);(0,r$.tp)().prototype.all=function(e,t){return this.throwIfDisposed(),(0,r_.Q)(this,e,t)};var rD=r(8319);(0,r$.tp)().prototype.any=function(e,t){return this.throwIfDisposed(),(0,rD.b)(this,e,t)};var rO=r(30464);(0,r$.tp)().prototype.argMax=function(e){return this.throwIfDisposed(),(0,rO.F)(this,e)};var rL=r(74346);(0,r$.tp)().prototype.argMin=function(e){return this.throwIfDisposed(),(0,rL.X)(this,e)},(0,r$.tp)().prototype.asScalar=function(){return this.throwIfDisposed(),(0,el.vA)(1===this.size,()=>"The array must have only 1 element."),(0,H.t)(this,[])},(0,r$.tp)().prototype.asType=function(e){return this.throwIfDisposed(),(0,D.w)(this,e)},(0,r$.tp)().prototype.as1D=function(){return this.throwIfDisposed(),(0,H.t)(this,[this.size])},(0,r$.tp)().prototype.as2D=function(e,t){return this.throwIfDisposed(),(0,H.t)(this,[e,t])},(0,r$.tp)().prototype.as3D=function(e,t,r){return this.throwIfDisposed(),(0,H.t)(this,[e,t,r])},(0,r$.tp)().prototype.as4D=function(e,t,r,n){return this.throwIfDisposed(),(0,H.t)(this,[e,t,r,n])},(0,r$.tp)().prototype.as5D=function(e,t,r,n,a){return this.throwIfDisposed(),(0,H.t)(this,[e,t,r,n,a])};var rM=r(22176);(0,r$.tp)().prototype.asin=function(){return this.throwIfDisposed(),(0,rM.q)(this)};var rP=r(90300);(0,r$.tp)().prototype.asinh=function(){return this.throwIfDisposed(),(0,rP.y)(this)};var rz=r(70477);(0,r$.tp)().prototype.atan=function(){return this.throwIfDisposed(),(0,rz.r)(this)};var rB=r(79493);(0,r$.tp)().prototype.atan2=function(e){return this.throwIfDisposed(),(0,rB.F)(this,e)};var rW=r(48551);(0,r$.tp)().prototype.atanh=function(){return this.throwIfDisposed(),(0,rW.r)(this)};var rV=r(98932);(0,r$.tp)().prototype.avgPool=function(e,t,r,n){return this.throwIfDisposed(),(0,rV.$)(this,e,t,r,n)},(0,r$.tp)().prototype.batchToSpaceND=function(e,t){return this.throwIfDisposed(),(0,rl.G)(this,e,t)};var rG=r(20219);(0,r$.tp)().prototype.batchNorm=function(e,t,r,n,a){return this.throwIfDisposed(),(0,rG.$)(this,e,t,r,n,a)};var rU=r(43182);(0,r$.tp)().prototype.broadcastTo=function(e){return this.throwIfDisposed(),(0,rU.h)(this,e)},(0,r$.tp)().prototype.cast=function(e){return this.throwIfDisposed(),(0,D.w)(this,e)};var rZ=r(46534);(0,r$.tp)().prototype.ceil=function(){return this.throwIfDisposed(),(0,rZ.m)(this)};var rj=r(53777);(0,r$.tp)().prototype.clipByValue=function(e,t){return this.throwIfDisposed(),(0,rj.z)(this,e,t)},(0,r$.tp)().prototype.concat=function(e,t){return this.throwIfDisposed(),e instanceof r$.qY&&(e=[e]),(0,rh.x)([this,...e],t)};var rH=r(45700);(0,r$.tp)().prototype.conv1d=function(e,t,r,n,a,s){return this.throwIfDisposed(),(0,rH.k)(this,e,t,r,n,a,s)};var rK=r(59307);(0,r$.tp)().prototype.conv2dTranspose=function(e,t,r,n,a){return this.throwIfDisposed(),(0,rK.w)(this,e,t,r,n,a)},(0,r$.tp)().prototype.conv2d=function(e,t,r,n,a,s){return this.throwIfDisposed(),(0,e_.X)(this,e,t,r,n,a,s)},(0,r$.tp)().prototype.cos=function(){return this.throwIfDisposed(),(0,t9.g)(this)},(0,r$.tp)().prototype.cosh=function(){return this.throwIfDisposed(),(0,re.y)(this)},(0,r$.tp)().prototype.cumprod=function(e,t,r){return this.throwIfDisposed(),(0,tG.L)(this,e,t,r)},(0,r$.tp)().prototype.cumsum=function(e,t,r){return this.throwIfDisposed(),(0,eG.r)(this,e,t,r)};var rY=r(36705);(0,r$.tp)().prototype.depthToSpace=function(e,t){return this.throwIfDisposed(),(0,rY.R)(this,e,t)};var rQ=r(38773);(0,r$.tp)().prototype.depthwiseConv2d=function(e,t,r,n,a,s){return this.throwIfDisposed(),(0,rQ.G)(this,e,t,r,n,a,s)};var rq=r(16427);(0,r$.tp)().prototype.dilation2d=function(e,t,r,n,a){return this.throwIfDisposed(),(0,rq.X)(this,e,t,r,n,a)};var rX=r(6726);(0,r$.tp)().prototype.divNoNan=function(e){return this.throwIfDisposed(),(0,rX.e)(this,e)},(0,r$.tp)().prototype.div=function(e){return this.throwIfDisposed(),(0,P.y)(this,e)};var rJ=r(39646);(0,r$.tp)().prototype.dot=function(e){return this.throwIfDisposed(),(0,rJ.O)(this,e)};var r0=r(65737);(0,r$.tp)().prototype.elu=function(){return this.throwIfDisposed(),(0,r0.P)(this)},(0,r$.tp)().prototype.equal=function(e){return this.throwIfDisposed(),(0,tf.L)(this,e)};var r1=r(25742);(0,r$.tp)().prototype.erf=function(){return this.throwIfDisposed(),(0,r1.Y)(this)};var r2=r(40064);(0,r$.tp)().prototype.euclideanNorm=function(e,t){return this.throwIfDisposed(),(0,r2.p)(this,e,t)},(0,r$.tp)().prototype.exp=function(){return this.throwIfDisposed(),(0,eq.o)(this)},(0,r$.tp)().prototype.expandDims=function(e){return this.throwIfDisposed(),(0,rS.U)(this,e)};var r3=r(85692);(0,r$.tp)().prototype.expm1=function(){return this.throwIfDisposed(),(0,r3.I)(this)};var r4=r(30824);(0,r$.tp)().prototype.fft=function(){return this.throwIfDisposed(),(0,r4.h)(this)},(0,r$.tp)().prototype.flatten=function(){return this.throwIfDisposed(),(0,H.t)(this,[this.size])},(0,r$.tp)().prototype.floor=function(){return this.throwIfDisposed(),(0,tA.R)(this)};var r5=r(81918);(0,r$.tp)().prototype.floorDiv=function(e){return this.throwIfDisposed(),(0,r5.w)(this,e)},(0,r$.tp)().prototype.gather=function(e,t,r){return this.throwIfDisposed(),(0,rN.k)(this,e,t,r)},(0,r$.tp)().prototype.greaterEqual=function(e){return this.throwIfDisposed(),(0,eT.D)(this,e)},(0,r$.tp)().prototype.greater=function(e){return this.throwIfDisposed(),(0,to.r)(this,e)};var r6=r(86405);(0,r$.tp)().prototype.ifft=function(){return this.throwIfDisposed(),(0,r6.K)(this)};var r7=r(66333);(0,r$.tp)().prototype.irfft=function(){return this.throwIfDisposed(),(0,r7.g)(this)};var r9=r(79039);(0,r$.tp)().prototype.isFinite=function(){return this.throwIfDisposed(),(0,r9.M)(this)};var r8=r(60631);(0,r$.tp)().prototype.isInf=function(){return this.throwIfDisposed(),(0,r8.E)(this)};var ne=r(6053);(0,r$.tp)().prototype.isNaN=function(){return this.throwIfDisposed(),(0,ne.y)(this)};var nt=r(12550);(0,r$.tp)().prototype.leakyRelu=function(e){return this.throwIfDisposed(),(0,nt.H)(this,e)},(0,r$.tp)().prototype.lessEqual=function(e){return this.throwIfDisposed(),(0,eS.I)(this,e)},(0,r$.tp)().prototype.less=function(e){return this.throwIfDisposed(),(0,ty.M)(this,e)};var nr=r(67562);(0,r$.tp)().prototype.localResponseNormalization=function(e,t,r,n){return this.throwIfDisposed(),(0,nr.K)(this,e,t,r,n)};var nn=r(38308);(0,r$.tp)().prototype.logSigmoid=function(){return this.throwIfDisposed(),(0,nn.n)(this)};var na=r(95150);(0,r$.tp)().prototype.logSoftmax=function(e){return this.throwIfDisposed(),(0,na.H)(this,e)};var ns=r(14027);(0,r$.tp)().prototype.logSumExp=function(e,t){return this.throwIfDisposed(),(0,ns.V)(this,e,t)},(0,r$.tp)().prototype.log=function(){return this.throwIfDisposed(),(0,tz.R)(this)};var ni=r(61838);(0,r$.tp)().prototype.log1p=function(){return this.throwIfDisposed(),(0,ni.K)(this)},(0,r$.tp)().prototype.logicalAnd=function(e){return this.throwIfDisposed(),(0,eN.n)(this,e)},(0,r$.tp)().prototype.logicalNot=function(){return this.throwIfDisposed(),(0,t2.N)(this)};var no=r(94742);(0,r$.tp)().prototype.logicalOr=function(e){return this.throwIfDisposed(),(0,no.z)(this,e)};var nl=r(25612);(0,r$.tp)().prototype.logicalXor=function(e){return this.throwIfDisposed(),(0,nl.r)(this,e)},(0,r$.tp)().prototype.matMul=function(e,t,r){return this.throwIfDisposed(),(0,em.N)(this,e,t,r)};var nu=r(51006);(0,r$.tp)().prototype.maxPool=function(e,t,r,n){return this.throwIfDisposed(),(0,nu.j)(this,e,t,r,n)};var nh=r(79459);(0,r$.tp)().prototype.max=function(e,t){return this.throwIfDisposed(),(0,nh.T)(this,e,t)},(0,r$.tp)().prototype.maximum=function(e){return this.throwIfDisposed(),(0,rk.P)(this,e)};var np=r(76506);(0,r$.tp)().prototype.mean=function(e,t){return this.throwIfDisposed(),(0,np.i)(this,e,t)};var nd=r(61541);(0,r$.tp)().prototype.min=function(e,t){return this.throwIfDisposed(),(0,nd.j)(this,e,t)};var nc=r(79045);(0,r$.tp)().prototype.minimum=function(e){return this.throwIfDisposed(),(0,nc.B)(this,e)};var nf=r(86694);(0,r$.tp)().prototype.mirrorPad=function(e,t){return this.throwIfDisposed(),(0,nf.F)(this,e,t)};var nm=r(66025);(0,r$.tp)().prototype.mod=function(e){return this.throwIfDisposed(),(0,nm.z)(this,e)},(0,r$.tp)().prototype.mul=function(e){return this.throwIfDisposed(),(0,O.l)(this,e)},(0,r$.tp)().prototype.neg=function(){return this.throwIfDisposed(),(0,z.H)(this)};var ng=r(5565);(0,r$.tp)().prototype.norm=function(e,t,r){return this.throwIfDisposed(),(0,ng.x)(this,e,t,r)};var ny=r(24487);(0,r$.tp)().prototype.notEqual=function(e){return this.throwIfDisposed(),(0,ny.E)(this,e)};var nb=r(18313);(0,r$.tp)().prototype.oneHot=function(e,t=1,r=0){return this.throwIfDisposed(),(0,nb.M)(this,e,t,r)};var nx=r(80116);(0,r$.tp)().prototype.onesLike=function(){return this.throwIfDisposed(),(0,nx.P)(this)},(0,r$.tp)().prototype.pad=function(e,t){return this.throwIfDisposed(),(0,rr.e)(this,e,t)};var nv=r(65417);(0,r$.tp)().prototype.pool=function(e,t,r,n,a,s){return this.throwIfDisposed(),(0,nv.d)(this,e,t,r,n,a,s)},(0,r$.tp)().prototype.pow=function(e){return this.throwIfDisposed(),(0,tB.n)(this,e)};var nw=r(17019);(0,r$.tp)().prototype.prelu=function(e){return this.throwIfDisposed(),(0,nw.N)(this,e)};var nT=r(60058);(0,r$.tp)().prototype.prod=function(e,t){return this.throwIfDisposed(),(0,nT._)(this,e,t)};
191var nS=r(43239);(0,r$.tp)().prototype.reciprocal=function(){return this.throwIfDisposed(),(0,nS.V)(this)};var nN=r(55865);(0,r$.tp)().prototype.relu=function(){return this.throwIfDisposed(),(0,nN.V)(this)};var nk=r(23533);(0,r$.tp)().prototype.relu6=function(){return this.throwIfDisposed(),(0,nk.j)(this)},(0,r$.tp)().prototype.reshapeAs=function(e){return this.throwIfDisposed(),(0,H.t)(this,e.shape)},(0,r$.tp)().prototype.reshape=function(e){return this.throwIfDisposed(),(0,H.t)(this,e)};var nI=r(39758);(0,r$.tp)().prototype.resizeBilinear=function(e,t,r){return this.throwIfDisposed(),(0,nI.v)(this,e,t,r)};var nC=r(48163);(0,r$.tp)().prototype.resizeNearestNeighbor=function(e,t,r){return this.throwIfDisposed(),(0,nC.b)(this,e,t,r)},(0,r$.tp)().prototype.reverse=function(e){return this.throwIfDisposed(),(0,tX.B)(this,e)};var nE=r(2774);(0,r$.tp)().prototype.rfft=function(){return this.throwIfDisposed(),(0,nE.z)(this)};var nA=r(67329);(0,r$.tp)().prototype.round=function(){return this.throwIfDisposed(),(0,nA.L)(this)},(0,r$.tp)().prototype.rsqrt=function(){return this.throwIfDisposed(),(0,e4.Z)(this)};var n$=r(39500);(0,r$.tp)().prototype.selu=function(){return this.throwIfDisposed(),(0,n$.W)(this)};var nF=r(44355);(0,r$.tp)().prototype.separableConv2d=function(e,t,r,n,a,s){return this.throwIfDisposed(),(0,nF.w)(this,e,t,r,n,a,s)},(0,r$.tp)().prototype.sigmoid=function(){return this.throwIfDisposed(),(0,ri.r)(this)};var nR=r(1930);(0,r$.tp)().prototype.sign=function(){return this.throwIfDisposed(),(0,nR._)(this)},(0,r$.tp)().prototype.sin=function(){return this.throwIfDisposed(),(0,eP.F)(this)},(0,r$.tp)().prototype.sinh=function(){return this.throwIfDisposed(),(0,eB.L)(this)},(0,r$.tp)().prototype.slice=function(e,t){return this.throwIfDisposed(),(0,tC.d)(this,e,t)};var n_=r(83635);(0,r$.tp)().prototype.softmax=function(e){return this.throwIfDisposed(),(0,n_.V)(this,e)};var nD=r(96247);(0,r$.tp)().prototype.softplus=function(){return this.throwIfDisposed(),(0,nD.l)(this)},(0,r$.tp)().prototype.spaceToBatchND=function(e,t){return this.throwIfDisposed(),(0,ey.e)(this,e,t)},(0,r$.tp)().prototype.split=function(e,t){return this.throwIfDisposed(),(0,eE.l)(this,e,t)},(0,r$.tp)().prototype.sqrt=function(){return this.throwIfDisposed(),(0,W.R)(this)},(0,r$.tp)().prototype.square=function(){return this.throwIfDisposed(),(0,V.E)(this)};var nO=r(27610);(0,r$.tp)().prototype.squaredDifference=function(e){return this.throwIfDisposed(),(0,nO.P)(this,e)};var nL=r(95989);(0,r$.tp)().prototype.squeeze=function(e){return this.throwIfDisposed(),(0,nL.r)(this,e)},(0,r$.tp)().prototype.stack=function(e,t){this.throwIfDisposed();let r=e instanceof r$.qY?[this,e]:[this,...e];return(0,e7.t)(r,t)},(0,r$.tp)().prototype.step=function(e){return this.throwIfDisposed(),(0,L.P)(this,e)};var nM=r(69751);(0,r$.tp)().prototype.stridedSlice=function(e,t,r,n,a,s,i,o){return this.throwIfDisposed(),(0,nM.Y)(this,e,t,r,n,a,s,i,o)},(0,r$.tp)().prototype.sub=function(e){return this.throwIfDisposed(),(0,G.j)(this,e)},(0,r$.tp)().prototype.sum=function(e,t){return this.throwIfDisposed(),(0,K.c)(this,e,t)};var nP=r(43062);(0,r$.tp)().prototype.tan=function(){return this.throwIfDisposed(),(0,nP.M)(this)};var nz=r(30254);(0,r$.tp)().prototype.tanh=function(){return this.throwIfDisposed(),(0,nz.y)(this)},(0,r$.tp)().prototype.tile=function(e){return this.throwIfDisposed(),(0,e5.V)(this,e)},(0,r$.tp)().prototype.toBool=function(){return this.throwIfDisposed(),(0,D.w)(this,"bool")},(0,r$.tp)().prototype.toFloat=function(){return this.throwIfDisposed(),(0,D.w)(this,"float32")},(0,r$.tp)().prototype.toInt=function(){return this.throwIfDisposed(),(0,D.w)(this,"int32")};var nB=r(81031);(0,r$.tp)().prototype.topk=function(e,t){return this.throwIfDisposed(),(0,nB.r)(this,e,t)},(0,r$.tp)().prototype.transpose=function(e){return this.throwIfDisposed(),(0,eU.m)(this,e)};var nW=r(59744);(0,r$.tp)().prototype.unique=function(e){return this.throwIfDisposed(),(0,nW.A)(this,e)},(0,r$.tp)().prototype.unsortedSegmentSum=function(e,t){return this.throwIfDisposed(),(0,e9.z)(this,e,t)},(0,r$.tp)().prototype.unstack=function(e){return this.throwIfDisposed(),(0,tL.K)(this,e)},(0,r$.tp)().prototype.where=function(e,t){return this.throwIfDisposed(),(0,ek._)(e,this,t)},(0,r$.tp)().prototype.zerosLike=function(){return this.throwIfDisposed(),(0,q.P)(this)};var nV=r(75504);(0,R._K2)().registerFlag("TOPOLOGICAL_SORT_CACHE_MAX_ENTRIES",()=>100,nV.oR);var nG=r(8785);function nU(e){return new nG.DE(e)}function nZ(e){return new nG.xS(e)}function nj(){return new nG.sQ}function nH(e){return new nG.vJ(e)}var nK=r(96902);function nY(){return new nK._c}function nQ(){return new nK.sN}function nq(e){return new nK.h8(e)}function nX(e){return new nK.m9(e)}function nJ(e){return new nK.rZ(e)}function n0(e){return new nK.EE(e)}function n1(e){return new nK.lz(e)}function n2(e){return new nK.Lm(e)}function n3(e){return new nK.Ux(e)}function n4(e){return new nK.xd(e)}function n5(e){return new nK.bL(e)}function n6(e){return new nK.KJ(e)}function n7(e){return new nK.TO(e)}function n9(e){return new nK.Gs(e)}function n8(e){return new nK.iv(e)}var ae=r(70581),at=r(70796),ar=r(3024);function an(e,t){return ar.xM(e,t)}function aa(e,t){return ar.Jc(e,t)}function as(e,t){return ar.qv(e,t)}function ai(e,t){return ar.yP(e,t)}function ao(e,t){return ar.Ol(e,t)}function al(e,t){return ar.Fz(e,t)}function au(e,t){return ar.I9(e,t)}function ah(e,t){return at.Pg(e,t)}function ap(e,t){return at.Xv(e,t)}function ad(e,t){return at.VW(e,t)}function ac(e,t){return at.VW(e,t)}function af(e,t){return at.VW(e,t)}function am(e,t){return at.bt(e,t)}function ag(e,t){return at.bt(e,t)}function ay(e,t){return at.bt(e,t)}function ab(e,t){return ar.ZY(e,t)}var ax=r(70481),av=r(65650);function aw(e){return new av.G2(e)}function aT(e){return av.l1(e)}function aS(e){return av.l2(e)}var aN=r(70333),ak=r(25564),aI=r(97344),aC=r(65952);class aE extends aN.J5{constructor(){super(...arguments),this.model=null}setModel(e){if(!(e instanceof ak.Gw))throw Error("model must be a LayersModel, not some other Container");this.model=e}}function aA(e,t){return e<t}function a$(e,t){return e>t}class aF extends aE{constructor(e){if(super(),null==e&&(e={}),e.restoreBestWeights)throw new aI.EH("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,-1===["auto","min","max"].indexOf(this.mode)&&(console.warn(`EarlyStopping mode '${this.mode}
191' is invalid. Falling back to mode 'auto'.`),this.mode="auto"),"min"===this.mode?this.monitorFunc=aA:"max"===this.mode||-1!==this.monitor.indexOf("acc")?this.monitorFunc=a$:this.monitorFunc=aA,this.monitorFunc===aA&&(this.minDelta*=-1)}async onTrainBegin(e){this.wait=0,this.stoppedEpoch=0,null!=this.baseline?this.best=this.baseline:this.best=this.monitorFunc===aA?1/0:-1/0}async onEpochEnd(e,t){await (0,aC.I)(t);let r=this.getMonitorValue(t);null!=r&&(this.monitorFunc(r-this.minDelta,this.best)?(this.best=r,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){null==e&&(e={});let t=e[this.monitor];return null==t&&console.warn(`Metric for EarlyStopping ${this.monitor} is not available. Available metrics are: ${Object.keys(e)}`),t}}let aR={earlyStopping:function(e){return new aF(e)}};var a_=r(14811),aD=r(69950),aO=r(46096),aL=r(8404),aM=r(84613);(0,R._K2)().registerFlag("KEEP_INTERMEDIATE_TENSORS",()=>!1,e=>{e&&console.warn("Keep intermediate tensors is ON. This will print the values of all intermediate tensors during model inference. Not all models support this mode. For details, check e2e/benchmarks/ model_config.js. This significantly impacts performance.")}),function(e){e[e.DT_INVALID=0]="DT_INVALID",e[e.DT_FLOAT=1]="DT_FLOAT",e[e.DT_DOUBLE=2]="DT_DOUBLE",e[e.DT_INT32=3]="DT_INT32",e[e.DT_UINT8=4]="DT_UINT8",e[e.DT_INT16=5]="DT_INT16",e[e.DT_INT8=6]="DT_INT8",e[e.DT_STRING=7]="DT_STRING",e[e.DT_COMPLEX64=8]="DT_COMPLEX64",e[e.DT_INT64=9]="DT_INT64",e[e.DT_BOOL=10]="DT_BOOL",e[e.DT_QINT8=11]="DT_QINT8",e[e.DT_QUINT8=12]="DT_QUINT8",e[e.DT_QINT32=13]="DT_QINT32",e[e.DT_BFLOAT16=14]="DT_BFLOAT16",e[e.DT_QINT16=15]="DT_QINT16",e[e.DT_QUINT16=16]="DT_QUINT16",e[e.DT_UINT16=17]="DT_UINT16",e[e.DT_COMPLEX128=18]="DT_COMPLEX128",e[e.DT_HALF=19]="DT_HALF",e[e.DT_RESOURCE=20]="DT_RESOURCE",e[e.DT_VARIANT=21]="DT_VARIANT",e[e.DT_UINT32=22]="DT_UINT32",e[e.DT_UINT64=23]="DT_UINT64",e[e.DT_FLOAT_REF=101]="DT_FLOAT_REF",e[e.DT_DOUBLE_REF=102]="DT_DOUBLE_REF",e[e.DT_INT32_REF=103]="DT_INT32_REF",e[e.DT_UINT8_REF=104]="DT_UINT8_REF",e[e.DT_INT16_REF=105]="DT_INT16_REF",e[e.DT_INT8_REF=106]="DT_INT8_REF",e[e.DT_STRING_REF=107]="DT_STRING_REF",e[e.DT_COMPLEX64_REF=108]="DT_COMPLEX64_REF",e[e.DT_INT64_REF=109]="DT_INT64_REF",e[e.DT_BOOL_REF=110]="DT_BOOL_REF",e[e.DT_QINT8_REF=111]="DT_QINT8_REF",e[e.DT_QUINT8_REF=112]="DT_QUINT8_REF",e[e.DT_QINT32_REF=113]="DT_QINT32_REF",e[e.DT_BFLOAT16_REF=114]="DT_BFLOAT16_REF",e[e.DT_QINT16_REF=115]="DT_QINT16_REF",e[e.DT_QUINT16_REF=116]="DT_QUINT16_REF",e[e.DT_UINT16_REF=117]="DT_UINT16_REF",e[e.DT_COMPLEX128_REF=118]="DT_COMPLEX128_REF",e[e.DT_HALF_REF=119]="DT_HALF_REF",e[e.DT_RESOURCE_REF=120]="DT_RESOURCE_REF",e[e.DT_VARIANT_REF=121]="DT_VARIANT_REF",e[e.DT_UINT32_REF=122]="DT_UINT32_REF",e[e.DT_UINT64_REF=123]="DT_UINT64_REF"}(n||(n={})),function(e){var t;(t=e.CheckpointFormatVersion||(e.CheckpointFormatVersion={}))[t.LEGACY=0]="LEGACY",t[t.V1=1]="V1",t[t.V2=2]="V2"}(a||(a={}));let aP={};function az(e,t){aP[e]={tfOpName:e,category:"custom",inputs:[],attrs:[],customExecutor:t}}function aB(e){delete aP[e]}function aW(e,t,r,n,a){let s=t.inputParams[e];if(s&&void 0!==s.inputIndexStart){let e=s.inputIndexStart,i=0===s.inputIndexEnd?void 0:void 0===s.inputIndexEnd?e+1:s.inputIndexEnd,o=e<0?t.inputNames.length+e:e;if("tensor"===s.type)return aV(t.inputNames[o],r,n,a);if("tensors"===s.type){let s=t.inputs.slice(e,i);return t.inputNames.slice(e,i).filter((e,t)=>{var r;return(null==(r=s[t])?void 0:r.op)!=="NoOp"}).map(e=>aV(e,r,n,a))}let l=aV(t.inputNames[o],r,n,a),u=l.dataSync();return"number"===s.type?u[0]:R.ZSL.toNestedArray(l.shape,u)}let i=t.attrParams[e];return i&&i.value}function aV(e,t,r,n){let[a,s]=aj(e,r);if(null!=n){let e=n.getHashTableHandleByName(a);if(null!=e)return e}let i=r.currentContextIds.find(e=>!!t[aZ(a,e)]);return void 0!==i?t[aZ(a,i)][s]:void 0}function aG(e,t,r){return t[aZ(e,r.currentContextId)]}function aU(e,t){let[r,n,a]=aj(e,t);return[aZ(r,t&&t.currentContextId),n,a]}function aZ(e,t){return t?`${e}-${t}`:e}function aj(e,t){let r;if(""===e)return["",0,void 0];let n=null!=t&&null!=t.parseNodeNameCache;if(n){let r=t.parseNodeNameCache.get(e);if(null!=r)return r}let a=e.split(":");if(1===a.length)r=[e,0,void 0];else{let e=a[0],t=3===a.length?a[1]:void 0;r=[e,Number(a[a.length-1]),t]}return n&&t.parseNodeNameCache.set(e,r),r}function aH(e,t,r){let n=aW("pad",e,t,r);if("explicit"===n){n=aW("explicitPaddings",e,t,r);let a=[[0,0],[0,0],[0,0],[0,0]];for(let e=0;e<4;e++)a[e][0]=n[2*e],a[e][1]=n[2*e+1];return a}return n}function aK(e){return e.kept?e:(0,R.o8B)(e)}let aY=[{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}
191]},{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}]}],aQ=
vendor: 6,808 bytes, line 191
191[{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:"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}]},{tfOpName:"IsFinite",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"IsInf",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]}]
191,aq
vendor: 7,590 bytes, line 191
191=[{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:"TensorListConcatV2",category:"control",inputs:[{start:0,name:"tensorListId",type:"tensor"}],attrs:[{tfName:"element_shape",name:"elementShape",type:"shape"},{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListPopBack",category:"control",inputs:[{start:0,name:"tensorListId",type:"tensor"},{start:1,name:"elementShape",type:"shape"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListPushBack",category:"control",inputs:[{start:0,name:"tensorListId",type:"tensor"},{start:1,name:"tensor",type:"tensor"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListLength",category:"control",inputs:[{start:0,name:"tensorListId",type:"tensor"}]},{tfOpName:"TensorListResize",category:"control",inputs:[{start:0,name:"tensorListId",type:"tensor"},{start:1,name:"size",type:"number"}]}],
vendor: 4,170 bytes, line 191
191aX=[{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",defaultValue:.2}]},{tfOpName:"Conv2DBackpropInput",category:"convolution",inputs:[{start:2,name:"x",type:"tensor"},{start:1,name:"filter",type:"tensor"},{start:0,name:"outputShape",type:"number[]"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",notSupported:!0}
191,{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"}]}],aJ=[{tfOpName:"Fill",category:"creation",inputs:[{start:0,name:"shape",type:"number[]"},{start:1,name:"value",type:"number"}],attrs:[{tfName:"T",name:"dtype",type:"dtype"}]},{tfOpName:"LinSpace",category:"creation",inputs:[{start:0,name:"start",type:"number"},{start:1,name:"stop",type:"number"},{start:2,name:"num",type:"number"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"OneHot",category:"creation",inputs:[{start:0,name:"indices",type:"tensor"},{start:1,name:"depth",type:"number"},{start:2,name:"onValue",type:"number",defaultValue:1},{start:3,name:"offValue",type:"number",defaultValue:0}],attrs:[{tfName:"axis",name:"axis",type:"number",notSupported:!0},{tfName:"T",name:"dtype",type:"dtype"}]},{tfOpName:"Ones",category:"creation",inputs:[{start:0,name:"shape",type:"number[]"}],attrs:[{tfName:"T",name:"dtype",type:"dtype"}]},{tfOpName:"OnesLike",category:"creation",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"dtype",name:"dtype",type:"dtype"}]},{tfOpName:"RandomStandardNormal",category:"creation",inputs:[{start:0,name:"shape",type:"number[]"}],attrs:[{tfName:"seed",name:"seed",type:"number",defaultValue:0},{tfName:"seed2",name:"seed2",type:"number",defaultValue:0,notSupported:!0},{tfName:"dtype",name:"dtype",type:"dtype"},{tfName:"T",name:"T",type:"number",notSupported:!0}]},{tfOpName:"RandomUniform",category:"creation",inputs:[{start:0,name:"shape",type:"number[]"}],attrs:[{tfName:"minval",name:"minval",type:"number",defaultValue:0},{tfName:"maxval",name:"maxval",type:"number",defaultValue:1},{tfName:"dtype",name:"dtype",type:"dtype"},{tfName:"seed",name:"seed",type:"number",defaultValue:0},{tfName:"seed2",name:"seed2",type:"number",defaultValue:0,notSupported:!0}
191,{tfName:"T",name:"T",type:"number",notSupported:!0}]},{tfOpName:"RandomUniformInt",category:"creation",inputs:[{start:0,name:"shape",type:"number[]"}],attrs:[{tfName:"minval",name:"minval",type:"number"},{tfName:"maxval",name:"maxval",type:"number"},{tfName:"seed",name:"seed",type:"number",defaultValue:0},{tfName:"seed2",name:"seed2",type:"number",defaultValue:0,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"}]}],a0=[{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}]}],a1=[{tfOpName:"LowerBound",category:"evaluation",inputs:[{start:0,name:"sortedSequence",type:"tensor"},{start:1,name:"values",type:"tensor"}]},{tfOpName:"TopKV2",category:"evaluation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"k",type:"number"}],attrs:[{tfName:"sorted",name:"sorted",type:"bool"}]},{tfOpName:"UpperBound",category:"evaluation",inputs:[{start:0,name:"sortedSequence",type:"tensor"},{start:1,name:"values",type:"tensor"}]},{tfOpName:"Unique",category:"evaluation",inputs:[{start:0,name:"x",type:"tensor"}]},{tfOpName:"UniqueV2",category:"evaluation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number"}]}],a2=[{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}
191,{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"}]}],a3=[{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"}]},{tfOpName:"InitializeTable",category:"hash_table",inputs:[{start:0,name:"tableHandle",type:"tensor"},{start:1,name:"keys",type:"tensor"},{start:2,name:"values",type:"tensor"}]},{tfOpName:"InitializeTableV2",category:"hash_table",inputs:[{start:0,name:"tableHandle",type:"tensor"},{start:1,name:"keys",type:"tensor"},{start:2,name:"values",type:"tensor"}]}],a4=[{tfOpName:"ResizeBilinear",category:"image",inputs:[{start:0,name:"images",type:"tensor"},{start:1,name:"size",type:"number[]"}],attrs:[{tfName:"align_corners",name:"alignCorners",type:"bool"},{tfName:"half_pixel_centers",name:"halfPixelCenters",type:"bool"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"ResizeNearestNeighbor",category:"image",inputs:[{start:0,name:"images",type:"tensor"},{start:1,name:"size",type:"number[]"}],attrs:[{tfName:"align_corners",name:"alignCorners",type:"bool"},{tfName:"half_pixel_centers",name:"halfPixelCenters",type:"bool"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"CropAndResize",category:"image",inputs:[{start:0,name:"image",type:"tensor"},{start:1,name:"boxes",type:"tensor"},{start:2,name:"boxInd",type:"tensor"},{start:3,name:"cropSize",type:"number[]"}],attrs:[{tfName:"method",name:"method",type:"string"},{tfName:"extrapolation_value",name:"extrapolationValue",type:"number"}]},{tfOpName:"ImageProjectiveTransformV3",category:"image",inputs:[{start:0,name:"images",type:"tensor"},{start:1,name:"transforms",type:"tensor"},{start:2,name:"outputShape",type:"number[]"},{start:3,name:"fillValue",type:"number"}],attrs:[{tfName:"interpolation",name:"interpolation",type:"string"},{tfName:"fill_mode",name:"fillMode",type:"string"}]}
191],a5=[{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}]},{tfOpName:"BitwiseAnd",category:"logical",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"y",type:"tensor"}]}],a6=[{tfOpName:"_FusedMatMul",category:"matrices",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"},{start:2,end:0,name:"args",type:"tensors"}],attrs:[{tfName:"num_args",name:"numArgs",type:"number"},{tfName:"fused_ops",name:"fusedOps",type:"string[]",defaultValue:[]},{tfName:"epsilon",name:"epsilon",type:"number",defaultValue:1e-4},{tfName:"transpose_a",name:"transposeA",type:"bool",defaultValue:!1},{tfName:"transpose_b",name:"transposeB",type:"bool",defaultValue:!1},{tfName:"leakyrelu_alpha",name:"leakyreluAlpha",type:"number",defaultValue:.2},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"MatMul",category:"matrices",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"transpose_a",name:"transposeA",type:"bool",defaultValue:!1},{tfName:"transpose_b",name:"transposeB",type:"bool",defaultValue:!1},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"BatchMatMul",category:"matrices",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"adj_x",name:"transposeA",type:"bool",defaultValue:!1},{tfName:"adj_y",name:"transposeB",type:"bool",defaultValue:!1},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"BatchMatMulV2",category:"matrices",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"adj_x",name:"transposeA",type:"bool",defaultValue:!1},{tfName:"adj_y",name:"transposeB",type:"bool",defaultValue:!1},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Transpose",category:"matrices",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"perm",type:"number[]"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Einsum",category:"matrices",inputs:[{start:0,end:0,name:"tensors",type:"tensors"}],attrs:[{tfName:"equation",name:"equation",type:"string"},{tfName:"N",name:"n",type:"number",defaultValue:2},{tfName:"T",name:"dtype",type:"dtype"}]},{tfOpName:"MatrixBandPart",category:"matrices",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"numLower",type:"tensor"},{start:1,name:"numUpper",type:"tensor"}]}],a7=[{tfOpName:"EuclideanNorm",category:"normalization",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number[]"}],attrs:[{tfName:"keep_dims",name:"keepDims",type:"bool",defaultValue:!1}]},{tfOpName:"FusedBatchNorm",category:"normalization",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"scale",type:"tensor"},{start:2,name:"offset",type:"tensor"},{start:3,name:"mean",type:"tensor"},{start:4,name:"variance",type:"tensor"}],attrs:[{tfName:"epsilon",name:"epsilon",type:"number",defaultValue:.001},{tfName:"data_format",name:"dataFormat",type:"string",notSupported:!0}
191]},{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"}]}],a9=[{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"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Cumprod",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number"}],attrs:[{tfName:"exclusive",name:"exclusive",type:"bool"},{tfName:"reverse",name:"reverse",type:"bool"}]},{tfOpName:"Cumsum",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number"}],attrs:[{tfName:"exclusive",name:"exclusive",type:"bool"},{tfName:"reverse",name:"reverse",type:"bool"}]}],a8=[{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}
191]},{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}]},{tfOpName:"TensorScatterUpdate",category:"slice_join",inputs:[{start:0,name:"tensor",type:"tensor"},{start:1,name:"indices",type:"tensor"},{start:2,name:"values",type:"tensor"}]}],se=[{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"}]}],st=[{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}]}],sr=[{tfOpName:"StaticRegexReplace",category:"string",inputs:[{start:0,name:"input",type:"tensor"}],attrs:[{tfName:"pattern",name:"pattern",type:"string"},{tfName:"rewrite",name:"rewrite",type:"string"},{tfName:"replace_global",name:"replaceGlobal",type:"bool"}]},{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"}]}
191],sn=[{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:"EnsureShape",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"shape",type:"number[]"}]},{tfOpName:"Squeeze",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"axis",tfDeprecatedName:"squeeze_dims",name:"axis",type:"number[]"}]},{tfOpName:"SpaceToBatchND",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"blockShape",type:"number[]"},{start:2,name:"paddings",type:"number[]"}]},{tfOpName:"BatchToSpaceND",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"blockShape",type:"number[]"},{start:2,name:"crops",type:"number[]"}]},{tfOpName:"DepthToSpace",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"block_size",name:"blockSize",type:"number"},{tfName:"data_format",name:"dataFormat",type:"string"}]},{tfOpName:"BroadcastTo",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"shape",type:"number[]"}],attrs:[]},{tfOpName:"BroadcastArgs",category:"transformation",inputs:[{start:0,name:"s0",type:"tensor"},{start:1,name:"s1",type:"tensor"}],attrs:[]}];var sa=r(44134).hp;class ss{static get Instance(){return this._instance||(this._instance=new this)}constructor(){let e=[].concat(...[p,d,c,f,m,g,y,b,x,v,w,T,S,N,k,I,C,E,A].map(e=>e.json));this.opMappers=e.reduce((e,t)=>(e[t.tfOpName]=t,e),{})}transformGraph(e,t={}){let r=e.node,n=[],a=[],s=[],i=r.reduce((e,t)=>(e[t.name]=this.mapNode(t),t.op.startsWith("Placeholder")?n.push(e[t.name]):"Const"===t.op?a.push(e[t.name]):(null==t.input||0===t.input.length)&&s.push(e[t.name]),e),{}),o=[],l=[],u={},h={};null!=t&&(u=this.mapSignatureEntries(t.inputs),h=this.mapSignatureEntries(t.outputs));let p=Object.keys(i);p.forEach(e=>{let t=i[e];t.inputNames.forEach((e,r)=>
191{let[n,,a]=aU(e),s=i[n];if(null!=s.outputs){let e=s.outputs.indexOf(a);if(-1!==e){let a=`${n}:${e}`;t.inputNames[r]=a}}t.inputs.push(s),s.children.push(t)})}),0===Object.keys(h).length?p.forEach(e=>{let t=i[e];0===t.children.length&&l.push(t)}):Object.keys(h).forEach(e=>{let[t]=aU(e),r=i[t];null!=r&&(r.signatureKey=h[e],l.push(r))}),Object.keys(u).length>0?Object.keys(u).forEach(e=>{let[t]=aU(e),r=i[t];r&&(r.signatureKey=u[e],o.push(r))}):o=n;let d={};null!=e.library&&null!=e.library.function&&(d=e.library.function.reduce((e,t)=>(e[t.signature.name]=this.mapFunction(t),e),{}));let c={nodes:i,inputs:o,outputs:l,weights:a,placeholders:n,signature:t,functions:d};return s.length>0&&(c.initNodes=s),c}mapSignatureEntries(e){return Object.keys(e||{}).reduce((t,r)=>(t[e[r].name]=r,t),{})}mapNode(e){let t=aP[e.op]||this.opMappers[e.op]||{};null==e.attr&&(e.attr={});let r={name:e.name,op:e.op,category:t.category,inputNames:(e.input||[]).map(e=>e.startsWith("^")?e.slice(1):e),inputs:[],children:[],inputParams:{},attrParams:{},rawAttrs:e.attr,outputs:t.outputs};return null!=t.inputs&&(r.inputParams=t.inputs.reduce((e,t)=>(e[t.name]={type:t.type,inputIndexStart:t.start,inputIndexEnd:t.end},e),{})),null!=t.attrs&&(r.attrParams=t.attrs.reduce((t,r)=>{let n,a=r.type;switch(r.type){case"string":void 0===(n=so(e.attr,r.tfName,r.defaultValue))&&r.tfDeprecatedName&&(n=so(e.attr,r.tfDeprecatedName,r.defaultValue));break;case"string[]":void 0===(n=sy(e.attr,r.tfName,r.defaultValue))&&r.tfDeprecatedName&&(n=sy(e.attr,r.tfDeprecatedName,r.defaultValue));break;case"number":void 0===(n=su(e.attr,r.tfName,r.defaultValue||0))&&r.tfDeprecatedName&&(n=su(e.attr,r.tfDeprecatedName,r.defaultValue));break;case"number[]":void 0===(n=sg(e.attr,r.tfName,r.defaultValue))&&r.tfDeprecatedName&&(n=sg(e.attr,r.tfDeprecatedName,r.defaultValue));break;case"bool":void 0===(n=sl(e.attr,r.tfName,r.defaultValue))&&r.tfDeprecatedName&&(n=sl(e.attr,r.tfDeprecatedName,r.defaultValue));break;case"bool[]":void 0===(n=sx(e.attr,r.tfName,r.defaultValue))&&r.tfDeprecatedName&&(n=sx(e.attr,r.tfDeprecatedName,r.defaultValue));break;case"shape":void 0===(n=sm(e.attr,r.tfName,r.defaultValue))&&r.tfDeprecatedName&&(n=sm(e.attr,r.tfDeprecatedName,r.defaultValue));break;case"shape[]":void 0===(n=sb(e.attr,r.tfName,r.defaultValue))&&r.tfDeprecatedName&&(n=sb(e.attr,r.tfDeprecatedName,r.defaultValue));break;case"dtype":void 0===(n=sd(e.attr,r.tfName,r.defaultValue))&&r.tfDeprecatedName&&(n=sd(e.attr,r.tfDeprecatedName,r.defaultValue));break;case"dtype[]":void 0===(n=sc(e.attr,r.tfName,r.defaultValue))&&r.tfDeprecatedName&&(n=sc(e.attr,r.tfDeprecatedName,r.defaultValue));break;case"func":void 0===(n=sp(e.attr,r.tfName,r.defaultValue))&&r.tfDeprecatedName&&(n=sp(e.attr,r.tfDeprecatedName,r.defaultValue));break;case"tensor":case"tensors":break;default:throw Error(`Unsupported param type: ${r.type} for op: ${e.op}`)}return t[r.name]={value:n,type:a},t},{})),r}mapFunction(e){let t=e.nodeDef,r=[],n={};null!=t&&(n=t.reduce((e,t)=>(e[t.name]=this.mapNode(t),"Const"===t.op&&r.push(e[t.name]),e),{}));let a=[],s=[];e.signature.inputArg.forEach(e=>{let[t]=aU(e.name),r={name:t,op:"Placeholder",inputs:[],inputNames:[],category:"graph",inputParams:{},attrParams:{dtype:{value:sh(e.type),type:"dtype"}},children:[]};r.signatureKey=e.name,a.push(r),n[t]=r}),Object.keys(n).forEach(e=>{let t=n[e];t.inputNames.forEach((e,r)=>{let[a,,s]=aU(e),i=n[a];if(null!=i.outputs){let e=i.outputs.indexOf(s);if(-1!==e){let n=`${a}:${e}`;t.inputNames[r]=n}}t.inputs.push(i),i.children.push(t)})});let i=e.ret;e.signature.outputArg.forEach(e=>{let[t,r]=aU(i[e.name]),a=n[t];null!=a&&(a.defaultOutput=r,s.push(a))});let o=this.mapArgsToSignature(e);return{nodes:n,inputs:a,outputs:s,weights:r,placeholders:[],signature:o}}mapArgsToSignature(e){return{methodName:e.signature.name,inputs:e.signature.inputArg.reduce((e,t)=>(e[t.name]=this.mapArgToTensorInfo(t),e),{}),outputs:e.signature.outputArg.reduce((t,r)=>(t[r.name]=this.mapArgToTensorInfo(r,e.ret),t),{})}}mapArgToTensorInfo(e,t){let r=e.name;return null!=t&&(r=t[r]),{name:r,dtype:e.type}}}function si(e,t){let r=Array.isArray(e)?String.fromCharCode.apply(null,e):function(e){let t=(0,R._K2)().global;if(void 0!==t.atob)return t.atob(e);if(void 0!==sa)return new sa(e,"base64").toString();throw Error("Unable to decode base64 in this environment. Missing built-in atob() or Buffer()")}(e);return t?r:r.toLowerCase()}function so(e,t,r,n=!1){let a=e[t];return null!=a?si(a.s,n):r}function sl(e,t,r){let n=e[t];return n?n.b:r}function su(e,t,r){let n=e[t]||{},a=null!=n.i?n.i:null!=n.f?n.f:r;return"number"==typeof a?a:parseInt(a,10)}function sh(e){switch("string"==typeof e&&(e=n[e]),e){case n.DT_FLOAT:case n.DT_HALF:return"float32";case n.DT_INT32:case n.DT_INT64:case n.DT_INT8:case n.DT_UINT8:return"int32";case n.DT_BOOL:return"bool";case n.DT_DOUBLE:return"float32";case n.DT_STRING:return"string";case n.DT_COMPLEX64:case n.DT_COMPLEX128:return"complex64";default:return null}}function sp(e,t,r){let n=e[t];return n&&n.func?n.func.name:r}function sd(e,t,r){let n=e[t];return n&&n.type?sh(n.type):r}function sc(e,t,r){let n=e[t];return n&&n.list&&n.list.type?n.list.type.map(e=>sh(e)):r}function sf(e){if(!e.unknownRank)return null!=e.dim?e.dim.map(e=>"number"==typeof e.size?e.size:parseInt(e.size,10)):[]}function sm(e,t,r){let n=e[t];return n&&n.shape?sf(n.shape):r}function sg(e,t,r){let n=e[t];return n?((n.list.f&&n.list.f.length?n.list.f:n.list.i)||[]).map(e=>"number"==typeof e?e:parseInt(e,10)):r}function sy(e,t,r,n=!1){let a=e[t];return a&&a.list&&a.list.s?a.list.s.map(e=>si(e,n)):r}
191function sb(e,t,r){let n=e[t];return n&&n.list&&n.list.shape?n.list.shape.map(e=>sf(e)):r}function sx(e,t,r){let n=e[t];return n&&n.list&&n.list.b?n.list.b:r}class sv{constructor(e,t,r){this.node=e,this.tensorMap=t,this.context=r,this.inputs=[],this.attrs={},this.inputs=e.inputNames.map(e=>this.getInput(e)),null!=e.rawAttrs&&(this.attrs=Object.keys(e.rawAttrs).reduce((e,t)=>(e[t]=this.getAttr(t),e),{}))}getInput(e){return aV(e,this.tensorMap,this.context)}getAttr(e,t){let r=this.node.rawAttrs[e];if(null!=r.tensor)return aV(e,this.tensorMap,this.context);if(null!=r.i||null!=r.f)return su(this.node.rawAttrs,e,t);if(null!=r.s)return so(this.node.rawAttrs,e,t);if(null!=r.b)return sl(this.node.rawAttrs,e,t);if(null!=r.shape)return sm(this.node.rawAttrs,e,t);if(null!=r.type)return sd(this.node.rawAttrs,e,t);if(null!=r.list){if(null!=r.list.i||null!=r.list.f)return sg(this.node.rawAttrs,e,t);if(null!=r.list.s)return sy(this.node.rawAttrs,e,t);if(null!=r.list.shape)return sb(this.node.rawAttrs,e,t);if(null!=r.list.b)return sx(this.node.rawAttrs,e,t);if(null!=r.list.type)return sc(this.node.rawAttrs,e,t)}return t}}var sw=r(51247);let sT=(e,t,r,n=$)=>{switch(e.op){case"BiasAdd":case"AddV2":case"Add":return[n.add(aW("a",e,t,r),aW("b",e,t,r))];case"AddN":return[n.addN(aW("tensors",e,t,r))];case"FloorMod":case"Mod":return[n.mod(aW("a",e,t,r),aW("b",e,t,r))];case"Mul":return[n.mul(aW("a",e,t,r),aW("b",e,t,r))];case"RealDiv":case"Div":return[n.div(aW("a",e,t,r),aW("b",e,t,r))];case"DivNoNan":return[n.divNoNan(aW("a",e,t,r),aW("b",e,t,r))];case"FloorDiv":return[n.floorDiv(aW("a",e,t,r),aW("b",e,t,r))];case"Sub":return[n.sub(aW("a",e,t,r),aW("b",e,t,r))];case"Minimum":return[n.minimum(aW("a",e,t,r),aW("b",e,t,r))];case"Maximum":return[n.maximum(aW("a",e,t,r),aW("b",e,t,r))];case"Pow":return[n.pow(aW("a",e,t,r),aW("b",e,t,r))];case"SquaredDifference":return[n.squaredDifference(aW("a",e,t,r),aW("b",e,t,r))];default:throw TypeError(`Node type ${e.op} is not implemented`)}},sS=(e,t,r,n=$)=>{switch(e.op){case"Abs":case"ComplexAbs":return[n.abs(aW("x",e,t,r))];case"Acos":return[n.acos(aW("x",e,t,r))];case"Acosh":return[n.acosh(aW("x",e,t,r))];case"Asin":return[n.asin(aW("x",e,t,r))];case"Asinh":return[n.asinh(aW("x",e,t,r))];case"Atan":return[n.atan(aW("x",e,t,r))];case"Atan2":return[n.atan2(aW("x",e,t,r),aW("y",e,t,r))];case"Atanh":return[n.atanh(aW("x",e,t,r))];case"Ceil":return[n.ceil(aW("x",e,t,r))];case"Complex":return[n.complex(aW("real",e,t,r),aW("imag",e,t,r))];case"Cos":return[n.cos(aW("x",e,t,r))];case"Cosh":return[n.cosh(aW("x",e,t,r))];case"Elu":return[n.elu(aW("x",e,t,r))];case"Erf":return[n.erf(aW("x",e,t,r))];case"Exp":return[n.exp(aW("x",e,t,r))];case"Expm1":return[n.expm1(aW("x",e,t,r))];case"Floor":return[n.floor(aW("x",e,t,r))];case"Log":return[n.log(aW("x",e,t,r))];case"Log1p":return[n.log1p(aW("x",e,t,r))];case"Imag":return[n.imag(aW("x",e,t,r))];case"Neg":return[n.neg(aW("x",e,t,r))];case"Reciprocal":return[n.reciprocal(aW("x",e,t,r))];case"Real":return[n.real(aW("x",e,t,r))];case"Relu":return[n.relu(aW("x",e,t,r))];case"Round":return[n.round(aW("x",e,t,r))];case"Selu":return[n.selu(aW("x",e,t,r))];case"Sigmoid":return[n.sigmoid(aW("x",e,t,r))];case"Sin":return[n.sin(aW("x",e,t,r))];case"Sign":return[n.sign(aW("x",e,t,r))];case"Sinh":return[n.sinh(aW("x",e,t,r))];case"Softplus":return[n.softplus(aW("x",e,t,r))];case"Sqrt":return[n.sqrt(aW("x",e,t,r))];case"Square":return[n.square(aW("x",e,t,r))];case"Tanh":return[n.tanh(aW("x",e,t,r))];case"Tan":return[n.tan(aW("x",e,t,r))];case"ClipByValue":return[n.clipByValue(aW("x",e,t,r),aW("clipValueMin",e,t,r),aW("clipValueMax",e,t,r))];case"Relu6":return[n.relu6(aW("x",e,t,r))];case"Rsqrt":return[n.rsqrt(aV(e.inputNames[0],t,r))];case"LeakyRelu":return[n.leakyRelu(aW("x",e,t,r),aW("alpha",e,t,r))];case"Prelu":return[n.prelu(aW("x",e,t,r),aW("alpha",e,t,r))];case"IsNan":return[n.isNaN(aV(e.inputNames[0],t,r))];case"IsInf":return[n.isInf(aV(e.inputNames[0],t,r))];case"IsFinite":return[n.isFinite(aV(e.inputNames[0],t,r))];default:throw TypeError(`Node type ${e.op} is not implemented`)}};function sN(e,t,r=""){if("number"!=typeof e&&"number"!=typeof t){R.ZSL.assert(e.length===t.length,()=>r+` Shapes ${e} and ${t} must match`);for(let n=0;n<e.length;n++){let a=e[n],s=t[n];R.ZSL.assert(a<0||s<0||a===s,()=>r+` Shapes ${e} and ${t} must match`)}}}function sk(e){return!("number"==typeof e||e.some(e=>e<0))}function sI(e,t,r){let n=sC(e,r),a=!sk(n);if(a&&0===t.length)throw Error(`Tried to calculate elements of an empty list with non-fully-defined elementShape: ${n}`);
191if(a&&t.forEach(e=>{n=sC(e.shape,n)}),!sk(n))throw Error(`Non-fully-defined elementShape: ${n}`);return n}function sC(e,t){if("number"==typeof e)return t;if("number"==typeof t)return e;if(e.length!==t.length)throw Error(`Incompatible ranks during merge: ${e} vs. ${t}`);let r=[];for(let n=0;n<e.length;++n){let a=e[n],s=t[n];if(a>=0&&s>=0&&a!==s)throw Error(`Incompatible shape during merge: ${e} vs. ${t}`);r[n]=a>=0?a:s}return r}class sE{constructor(e,t,r,n,a,s,i){this.name=e,this.dtype=t,this.maxSize=r,this.elementShape=n,this.identicalElementShapes=a,this.dynamicSize=s,this.clearAfterRead=i,this.tensors=[],this.closed_=!1,this.idTensor=(0,R.d_2)(0),(0,R.aCs)(this.idTensor)}get id(){return this.idTensor.id}get closed(){return this.closed_}clearAndClose(e){this.tensors.forEach(t=>{null!=e&&e.has(t.tensor.id)||t.tensor.dispose()}),this.tensors=[],this.closed_=!0,this.idTensor.dispose()}size(){return this.tensors.length}read(e){if(this.closed_)throw Error(`TensorArray ${this.name} has already been closed.`);if(e<0||e>=this.size())throw Error(`Tried to read from index ${e}, but array size is: ${this.size()}`);let t=this.tensors[e];if(t.cleared)throw Error(`TensorArray ${this.name}: Could not read index ${e} twice because it was cleared after a previous read (perhaps try setting clear_after_read = false?).`);return this.clearAfterRead&&(t.cleared=!0),t.read=!0,t.tensor}readMany(e){return e.map(e=>this.read(e))}write(e,t){if(this.closed_)throw Error(`TensorArray ${this.name} has already been closed.`);if(e<0||!this.dynamicSize&&e>=this.maxSize)throw Error(`Tried to write to index ${e}, but array is not resizeable and size is: ${this.maxSize}`);let r=this.tensors[e]||{};if(t.dtype!==this.dtype)throw Error(`TensorArray ${this.name}: Could not write to TensorArray index ${e}, 192 because the value dtype is ${t.dtype}, but TensorArray dtype is ${this.dtype}.`);if(0===this.size()&&(null==this.elementShape||0===this.elementShape.length)&&(this.elementShape=t.shape),sN(this.elementShape,t.shape,`TensorArray ${this.name}: Could not write to TensorArray index ${e}.`),r.read)throw Error(`TensorArray ${this.name}: Could not write to TensorArray index ${e}, because it has already been read.`);if(r.written)throw Error(`TensorArray ${this.name}: Could not write to TensorArray index ${e}, because it has already been written.`);r.tensor=t,(0,R.aCs)(t),r.written=!0,this.tensors[e]=r}writeMany(e,t){if(e.length!==t.length)throw Error(`TensorArray ${this.name}: could not write multiple tensors,because the index size: ${e.length} is not the same as tensors size: ${t.length}.`);e.forEach((e,r)=>this.write(e,t[r]))}gather(e,t){if(t&&t!==this.dtype)throw Error(`TensorArray dtype is ${this.dtype} but gather requested dtype ${t}`);if(e)e=e.slice(0,this.size());else{e=[];for(let t=0;t<this.size();t++)e.push(t)}if(0===e.length)return(0,R.OEK)([],[0].concat(this.elementShape));let r=this.readMany(e);return sN(this.elementShape,r[0].shape,"TensorArray shape mismatch: "),(0,R.t$z)(r,0)}concat(e){if(e&&e!==this.dtype)throw Error(`TensorArray dtype is ${this.dtype} but concat requested dtype ${e}`);if(0===this.size())return(0,R.OEK)([],[0].concat(this.elementShape));let t=[];for(let e=0;e<this.size();e++)t.push(e);let r=this.readMany(t);return sN(this.elementShape,r[0].shape,`TensorArray shape mismatch: tensor array shape (${this.elementShape}) vs first tensor shape (${r[0].shape})`),(0,R.xWs)(r,0)}scatter(e,t){if(t.dtype!==this.dtype)throw Error(`TensorArray dtype is ${this.dtype} but tensor has dtype ${t.dtype}`);if(e.length!==t.shape[0])throw Error(`Expected len(indices) == tensor.shape[0], but saw: ${e.length} vs. ${t.shape[0]}`);let r=Math.max(...e);if(!this.dynamicSize&&r>=this.maxSize)throw Error(`Max index must be < array size (${r} vs. ${this.maxSize})`);this.writeMany(e,(0,R.K$i)(t,0))}split(e,t){if(t.dtype!==this.dtype)throw Error(`TensorArray dtype is ${this.dtype} but tensor has dtype ${t.dtype}`);let r=0,n=e.map(e=>r+=e);if(r!==t.shape[0])throw Error(`Expected sum of lengths to be equal to 193 tensor.shape[0], but sum of lengths is 194 ${r}, and tensor's shape is: ${t.shape}`);if(!this.dynamicSize&&e.length!==this.maxSize)throw 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 a=0===r?0:t.size/r,s=[];(0,R.DZQ)(()=>{t=(0,R.tQQ)(t,[1,r,a]);for(let r=0;r<e.length;++r){let i=[0,0===r?0:n[r-1],0],o=[1,e[r],a];s[r]=(0,R.tQQ)((0,R.dik)(t,i,o),this.elementShape)}return s});let i=[];for(let t=0;t<e.length;t++)i[t]=t;this.writeMany(i,s)}}class sA{get id(){return this.idTensor.id}constructor(e,t,r,n=-1){this.tensors=e,this.elementShape=t,this.elementDtype=r,null!=e&&e.forEach(e
194=>{if(r!==e.dtype)throw Error(`Invalid data types; op elements ${r}, but list elements ${e.dtype}`);sN(t,e.shape,"TensorList shape mismatch: "),(0,R.aCs)(e)}),this.idTensor=(0,R.d_2)(0),this.maxNumElements=n,(0,R.aCs)(this.idTensor)}copy(){return new sA([...this.tensors],this.elementShape,this.elementDtype)}clearAndClose(e){this.tensors.forEach(t=>{null!=e&&e.has(t.id)||t.dispose()}),this.tensors.length=0,this.idTensor.dispose()}size(){return this.tensors.length}stack(e,t,r=-1){if(t!==this.elementDtype)throw Error(`Invalid data types; op elements ${t}, but list elements ${this.elementDtype}`);if(-1!==r&&this.tensors.length!==r)throw Error(`Operation expected a list with ${r} elements but got a list with ${this.tensors.length} elements.`);sN(e,this.elementShape,"TensorList shape mismatch: ");let n=sI(this.elementShape,this.tensors,e);return(0,R.DZQ)(()=>{let e=this.tensors.map(e=>(0,R.tQQ)(e,n));return(0,R.t$z)(e,0)})}popBack(e,t){if(t!==this.elementDtype)throw Error(`Invalid data types; op elements ${t}, but list elements ${this.elementDtype}`);if(0===this.size())throw Error("Trying to pop from an empty list.");let r=sI(this.elementShape,this.tensors,e),n=this.tensors.pop();return n.kept=!1,sN(n.shape,e,"TensorList shape mismatch: "),(0,R.tQQ)(n,r)}pushBack(e){if(e.dtype!==this.elementDtype)throw Error(`Invalid data types; op elements ${e.dtype}, but list elements ${this.elementDtype}`);if(sN(e.shape,this.elementShape,"TensorList shape mismatch: "),this.maxNumElements===this.size())throw Error("Trying to push element into a full list.");(0,R.aCs)(e),this.tensors.push(e)}resize(e){if(e<0)throw Error(`TensorListResize expects size to be non-negative. Got: ${e}`);if(-1!==this.maxNumElements&&e>this.maxNumElements)throw Error(`TensorListResize input size ${e} is greater maxNumElement ${this.maxNumElements}.`);let t=new sA([],this.elementShape,this.elementDtype,this.maxNumElements);t.tensors.length=e;for(let r=0;r<Math.min(this.tensors.length,e);++r)t.tensors[r]=this.tensors[r];return t}getItem(e,t,r){if(r!==this.elementDtype)throw Error(`Invalid data types; op elements ${r}, but list elements ${this.elementDtype}`);if(e<0||e>this.tensors.length)throw Error(`Trying to access element ${e} in a list with ${this.tensors.length} elements.`);if(null==this.tensors[e])throw Error(`element at index ${e} is null.`);sN(this.tensors[e].shape,t,"TensorList shape mismatch: ");let n=sI(this.elementShape,this.tensors,t);return(0,R.tQQ)(this.tensors[e],n)}setItem(e,t){if(t.dtype!==this.elementDtype)throw Error(`Invalid data types; op elements ${t.dtype}, but list elements ${this.elementDtype}`);if(e<0||-1!==this.maxNumElements&&e>=this.maxNumElements)throw Error(`Trying to set element ${e} in a list with max ${this.maxNumElements} elements.`);sN(this.elementShape,t.shape,"TensorList shape mismatch: "),(0,R.aCs)(t),null!=this.tensors[e]&&(this.tensors[e].kept=!1),this.tensors[e]=t}gather(e,t,r){if(t!==this.elementDtype)throw Error(`Invalid data types; op elements ${t}, but list elements ${this.elementDtype}`);sN(this.elementShape,r,"TensorList shape mismatch: "),e=e.slice(0,this.size());let n=sI(this.elementShape,this.tensors,r);return 0===e.length?(0,R.OEK)([],[0].concat(n)):(0,R.DZQ)(()=>{let t=e.map(e=>(0,R.tQQ)(this.tensors[e],n));return(0,R.t$z)(t,0)})}concat(e,t){if(e&&e!==this.elementDtype)throw Error(`TensorList dtype is ${this.elementDtype} but concat requested dtype ${e}`);sN(this.elementShape,t,"TensorList shape mismatch: ");let r=sI(this.elementShape,this.tensors,t);return 0===this.size()?(0,R.OEK)([],[0].concat(r)):(0,R.DZQ)(()=>{let e=this.tensors.map(e=>(0,R.tQQ)(e,r));return(0,R.xWs)(e,0)})}}let s$=async(e,t,r)=>{switch(e.op){case"If":case"StatelessIf":{let n=aW("thenBranch",e,t,r),a=aW("elseBranch",e,t,r),s=aW("cond",e,t,r),i=aW("args",e,t,r);if((await s.data())[0])return r.functionMap[n].executeFunctionAsync(i,r.tensorArrayMap,r.tensorListMap);return r.functionMap[a].executeFunctionAsync(i,r.tensorArrayMap,r.tensorListMap)}case"While":case"StatelessWhile":{let n=aW("body",e,t,r),a=aW("cond",e,t,r),s=aW("args",e,t,r),i=await r.functionMap[a].executeFunctionAsync(s,r.tensorArrayMap,r.tensorListMap),o=s.map(e=>e.id),l=await i[0].data();
194i.forEach(e=>{e.kept||-1!==o.indexOf(e.id)||e.dispose()});let u=s;for(;l[0];){let e=u,t=(u=await r.functionMap[n].executeFunctionAsync(u,r.tensorArrayMap,r.tensorListMap)).map(e=>e.id);e.forEach(e=>{e.kept||-1!==o.indexOf(e.id)||-1!==t.indexOf(e.id)||e.dispose()});let s=await r.functionMap[a].executeFunctionAsync(u,r.tensorArrayMap,r.tensorListMap);l=await s[0].data(),s.forEach(e=>{e.kept||-1!==o.indexOf(e.id)||-1!==t.indexOf(e.id)||e.dispose()})}return u}case"LoopCond":return[aK(aW("pred",e,t,r))];case"Switch":{let n=aW("pred",e,t,r),a=aW("data",e,t,r);return a.kept||(a=aK(a)),(await n.data())[0]?[void 0,a]:[a,void 0]}case"Merge":{let n=e.inputNames.find(e=>void 0!==aV(e,t,r));if(n)return[aK(aV(n,t,r))];return}case"Enter":{let n=aW("frameName",e,t,r),a=aW("tensor",e,t,r);return r.enterFrame(n),[aK(a)]}case"Exit":{let n=aW("tensor",e,t,r);return r.exitFrame(),[aK(n)]}case"NextIteration":{let n=aW("tensor",e,t,r);return r.nextIteration(),[aK(n)]}case"TensorArrayV3":{let n=aW("size",e,t,r),a=aW("dtype",e,t,r),s=aW("elementShape",e,t,r),i=aW("dynamicSize",e,t,r),o=aW("clearAfterRead",e,t,r),l=aW("identicalElementShapes",e,t,r),u=new sE(aW("name",e,t,r),a,n,s,l,i,o);return r.addTensorArray(u),[u.idTensor,(0,R.d_2)(1)]}case"TensorArrayWriteV3":{let n=aW("tensorArrayId",e,t,r),a=aW("index",e,t,r),s=aW("tensor",e,t,r),i=r.getTensorArray(n.id);return i.write(a,s),[i.idTensor]}case"TensorArrayReadV3":{let n=aW("tensorArrayId",e,t,r),a=aW("index",e,t,r);return[r.getTensorArray(n.id).read(a)]}case"TensorArrayGatherV3":{let n=aW("tensorArrayId",e,t,r),a=aW("indices",e,t,r),s=aW("dtype",e,t,r);return[r.getTensorArray(n.id).gather(a,s)]}case"TensorArrayScatterV3":{let n=aW("tensorArrayId",e,t,r),a=aW("indices",e,t,r),s=aW("tensor",e,t,r),i=r.getTensorArray(n.id);return i.scatter(a,s),[i.idTensor]}case"TensorArrayConcatV3":{let n=aW("tensorArrayId",e,t,r),a=r.getTensorArray(n.id),s=aW("dtype",e,t,r);return[a.concat(s)]}case"TensorArraySplitV3":{let n=aW("tensorArrayId",e,t,r),a=aW("tensor",e,t,r),s=aW("lengths",e,t,r),i=r.getTensorArray(n.id);return i.split(s,a),[i.idTensor]}case"TensorArraySizeV3":{let n=aW("tensorArrayId",e,t,r),a=r.getTensorArray(n.id);return[(0,R.d_2)(a.size(),"int32")]}case"TensorArrayCloseV3":{let n=aW("tensorArrayId",e,t,r),a=r.getTensorArray(n.id);return a.clearAndClose(),[a.idTensor]}case"TensorListSetItem":{let n=aW("tensorListId",e,t,r),a=aW("index",e,t,r),s=aW("tensor",e,t,r),i=r.getTensorList(n.id);return i.setItem(a,s),[i.idTensor]}case"TensorListGetItem":{let n=aW("tensorListId",e,t,r),a=aW("index",e,t,r),s=aW("elementShape",e,t,r),i=aW("elementDType",e,t,r);return[r.getTensorList(n.id).getItem(a,s,i)]}case"TensorListScatterV2":case"TensorListScatter":{let n=aW("indices",e,t,r),a=aW("tensor",e,t,r),s=function(e,t,r,n){if(t.length!==e.shape[0])throw Error(`Expected len(indices) == tensor.shape[0], but saw: ${t.length} vs. ${e.shape[0]}`);let a=Math.max(...t);if(null!=n&&-1!==n&&a>=n)throw Error(`Max index must be < array size (${a} vs. ${n})`);let s=new sA([],r,e.dtype,n),i=(0,R.K$i)(e,0);return t.forEach((e,t)=>{s.setItem(e,i[t])}),s}(a,n,aW("elementShape",e,t,r),aW("numElements",e,t,r));return r.addTensorList(s),[s.idTensor]}case"TensorListReserve":case"EmptyTensorList":{let n,a=aW("elementShape",e,t,r),s=aW("elementDType",e,t,r),i=aW("TensorListReserve"===e.op?"numElements":"maxNumElements",e,t,r),o=new sA([],a,s,"TensorListReserve"===e.op?-1:i);return r.addTensorList(o),[o.idTensor]}case"TensorListGather":{let n=aW("tensorListId",e,t,r),a=aW("indices",e,t,r),s=aW("elementShape",e,t,r),i=aW("elementDType",e,t,r);return[r.getTensorList(n.id).gather(a,i,s)]}case"TensorListStack":{let n=aW("tensorListId",e,t,r),a=aW("elementShape",e,t,r),s=aW("elementDType",e,t,r),i=aW("numElements",e,t,r);return[r.getTensorList(n.id).stack(a,s,i)]}case"TensorListFromTensor":{let n=aW("tensor",e,t,r),a=function(e,t,r){let n=e.dtype;if(e.shape.length<1)throw Error(`Tensor must be at least a vector, but saw shape: ${e.shape}`);if(e.dtype!==r)throw Error(`Invalid data types; op elements ${e.dtype}, but list elements ${r}`);return sN(e.shape.slice(1),t,"TensorList shape mismatch: "),new sA((0,R.K$i)(e),t,n)}(n,aW("elementShape",e,t,r),aW("elementDType",e,t,r));return r.addTensorList(a),[a.idTensor]}case"TensorListConcat":case"TensorListConcatV2":{let n=aW("tensorListId",e,t,r),a=r.getTensorList(n.id),s=aW("dtype",e,t,r),i=aW("elementShape",e,t,r);return[a.concat(s,i)]}case"TensorListPushBack":{let n=aW("tensorListId",e,t,r),a=aW("tensor",e,t,r),s=r.getTensorList(n.id);return s.pushBack(a),[s.idTensor]}case"TensorListPopBack":{let n=aW("tensorListId",e,t,r),a=aW("elementShape",e,t,r),s=aW("elementDType",e,t,r);return[r.getTensorList(n.id).popBack(a,s)]}case"TensorListSplit":{let n=aW("tensor",e,t,r),a=aW("elementShape",e,t,r),s=function(e,t,r){let n=0,a=t.map(e=>n+=e);if(n!==e.shape[0])throw Error(`Expected sum of lengths to be equal to 195 tensor.shape[0], but sum of lengths is 196 ${n}, and tensor's shape is: ${e.shape}`);let s=sC(e.shape.slice(1),r),i=0===n?0:e.size/n,o=(0,R.DZQ)(()=>{let r=[];e=(0,R.tQQ)(e,[1,n,i]);for(let n=0;n<t.length;++n){let o=[0,0===n?0:a[n-1],0],l=[1,t[n],i];r[n]=(0,R.tQQ)((0,R.dik)(e,o,l),s)}return e.dispose(),r}),l=new sA([],r,e.dtype,t.length);for(let e=0;e<o.length;e++)l.setItem(e,o[e]);return l}(n,aW("lengths",e,t,r),a);return r.addTensorList(s),[s.idTensor]}case"TensorListLength":{let n=aW("tensorListId",e,t,r),a=r.getTensorList(n.id);return[(0,R.d_2)(a.size(),"int32")]}case"TensorListResize":{let n=aW("tensorListId",e,t,r),a=aW("size",e,t,r),s=r.getTensorList(n.id).resize(a);return r.addTensorList(s),[s.idTensor]}default:throw TypeError(`Node type ${e.op} is not implemented`)}};function sF(e,t,r){let[n,a]=aW("fusedOps",e,t,r),s="biasadd"===n,i="prelu"===a,o=aW("numArgs",e,t,r);if(s){if(i&&2!==o)throw Error("FusedConv2d and DepthwiseConv2d with BiasAdd and Prelu must have two extra arguments: bias and alpha.");if(!i&&s&&1!==o)throw Error("FusedConv2d and DepthwiseConv2d with BiasAdd must have one extra argument: bias.")}if("fusedbatchnorm"===n)throw Error("FusedConv2d and DepthwiseConv2d with FusedBatchNorm is not supported");let l=aW("strides",e,t,r),u=aH(e,t,r),h=aW("dataFormat",e,t,r).toUpperCase(),p=aW("dilations",e,t,r),[d,c]=aW("args",e,t,r);return s||(c=d,d=void 0),{stride:l,pad:u,dataFormat:h,dilations:p,biasArg:d,preluArg:c,activationFunc:a,leakyreluAlpha:aW("leakyreluAlpha",e,t,r)}}let sR=(e,t,r,n=$)=>{switch(e.op){case"Conv1D":{let a=aW("stride",e,t,r),s=aW("pad",e,t,r),i=aW("dataFormat",e,t,r).toUpperCase(),o=aW("dilation",e,t,r);return[n.conv1d(aW("x",e,t,r),aW("filter",e,t,r),a,s,i,o)]}case"Conv2D":{let a=aW("strides",e,t,r),s=aH(e,t,r),i=aW("dataFormat",e,t,r).toUpperCase(),o=aW("dilations",e,t,r);return[n.conv2d(aW("x",e,t,r),aW("filter",e,t,r),[a[1],a[2]],s,i,[o[1],o[2]])]}case"_FusedConv2D":{let{stride:a,pad:s,dataFormat:i,dilations:o,biasArg:l,preluArg:u,activationFunc:h,leakyreluAlpha:p}=sF(e,t,r);return[n.fused.conv2d({x:aW("x",e,t,r),filter:aW("filter",e,t,r),strides:[a[1],a[2]],pad:s,dataFormat:i,dilations:[o[1],o[2]],bias:l,activation:h,preluActivationWeights:u,leakyreluAlpha:p})]}case"FusedDepthwiseConv2dNative":{let{stride:a,pad:s,dataFormat:i,dilations:o,biasArg:l,preluArg:u,activationFunc:h,leakyreluAlpha:p}=sF(e,t,r);return[n.fused.depthwiseConv2d({x:aW("x",e,t,r),filter:aW("filter",e,t,r),strides:[a[1],a[2]],pad:s,dataFormat:i,dilations:[o[1],o[2]],bias:l,activation:h,preluActivationWeights:u,leakyreluAlpha:p})]}case"Conv2DBackpropInput":case"Conv2dTranspose":{let a=aW("outputShape",e,t,r),s=aW("strides",e,t,r),i=aH(e,t,r);return[n.conv2dTranspose(aW("x",e,t,r),aW("filter",e,t,r),a,[s[1],s[2]],i)]}case"DepthwiseConv2dNative":case"DepthwiseConv2d":{let a=aW("strides",e,t,r),s=aH(e,t,r),i=aW("dilations",e,t,r),o=aW("dataFormat",e,t,r).toUpperCase();return[n.depthwiseConv2d(aW("input",e,t,r),aW("filter",e,t,r),[a[1],a[2]],s,o,[i[1],i[2]])]}case"Conv3D":{let a=aW("strides",e,t,r),s=aW("pad",e,t,r),i=aW("dataFormat",e,t,r).toUpperCase(),o=aW("dilations",e,t,r);return[n.conv3d(aW("x",e,t,r),aW("filter",e,t,r),[a[1],a[2],a[3]],s,i,[o[1],o[2],o[3]])]}case"AvgPool":{let a=aW("strides",e,t,r),s=aW("pad",e,t,r),i=aW("kernelSize",e,t,r);return[n.avgPool(aW("x",e,t,r),[i[1],i[2]],[a[1],a[2]],s)]}case"MaxPool":{let a=aW("strides",e,t,r),s=aW("pad",e,t,r),i=aW("kernelSize",e,t,r);return[n.maxPool(aW("x",e,t,r),[i[1],i[2]],[a[1],a[2]],s)]}case"MaxPoolWithArgmax":{let a=aW("strides",e,t,r),s=aW("pad",e,t,r),i=aW("kernelSize",e,t,r),o=aW("includeBatchInIndex",e,t,r),{result:l,indexes:u}=n.maxPoolWithArgmax(aW("x",e,t,r),[i[1],i[2]],[a[1],a[2]],s,o);return[l,u]}case"AvgPool3D":{let a=aW("strides",e,t,r),s=aW("pad",e,t,r),i=aW("kernelSize",e,t,r);return[n.avgPool3d(aW("x",e,t,r),[i[1],i[2],i[3]],[a[1],a[2],a[3]],s)]}case"MaxPool3D":{let a=aW("strides",e,t,r),s=aW("pad",e,t,r),i=aW("kernelSize",e,t,r);return[n.maxPool3d(aW("x",e,t,r),[i[1],i[2],i[3]],[a[1],a[2],a[3]],s)]}case"Dilation2D":{let a=aW("strides",e,t,r),s=aW("pad",e,t,r),i=aW("dilations",e,t,r),o=a[1],l=a[2],u=i[1],h=i[2];return[n.dilation2d(aW("x",e,t,r),aW("filter",e,t,r),[o,l],s,[u,h],"NHWC")]}default:throw TypeError(`Node type ${e.op} is not implemented`)}},s_=(e,t,r,n=$)=>{switch(e.op){case"Fill":{let a=aW("shape",e,t,r),s=aW("dtype",e,t,r),i=aW("value",e,t,r);return[n.fill(a,i,s)]}case"LinSpace":{let a=aW("start",e,t,r),s=aW("stop",e,t,r),i=aW("num",e,t,r);return[n.linspace(a,s,i)]}case"Multinomial":{let a=aW("logits",e,t,r),s=aW("numSamples",e,t,r),i=aW("seed",e,t,r);return[n.multinomial(a,s,i)]}case"OneHot":{let a=aW("indices",e,t,r),s=aW("depth",e,t,r),i=aW("onValue",e,t,r),o=aW("offValue",e,t,r),l=aW("dtype",e,t,r);return[n.oneHot(a,s,i,o,l)]}case"Ones":return[n.ones(aW("shape",e,t,r),aW("dtype",e,t,r))];case"OnesLike":return[n.onesLike(aW("x",e,t,r))];case"RandomStandardNormal":return[n.randomStandardNormal(aW("shape",e,t,r),aW("dtype",e,t,r),aW("seed",e,t,r))];case"RandomUniform":return[n.randomUniform(aW("shape",e,t,r),aW("minval",e,t,r),aW("maxval",e,t,r),aW("dtype",e,t,r))];case"RandomUniformInt":return[n.randomUniformInt(aW("shape",e,t,r),aW("minval",e,t,r),aW("maxval",e,t,r),aW("seed",e,t,r))];case"Range":{let a=aW("start",e,t,r),s=aW("stop",e,t,r),i=aW("step",e,t,r);return[n.range(a,s,i,aW("dtype",e,t,r))]}case"TruncatedNormal":{let a=aW("shape",e,t,r),s=aW("mean",e,t,r),i=aW("stdDev",e,t,r),o=aW("seed",e,t,r);return[n.truncatedNormal(a,s,i,aW("dtype",e,t,r),o)]}case"Zeros":return[n.zeros(aW("shape",e,t,r),aW("dtype",e,t,r))];case"ZerosLike":return[n.zerosLike(aW("x",e,t,r))];default:throw TypeError(`Node type ${e.op} is not implemented`)}};function sD(e,t,r){let n=aW("boxes",e,t,r),a=aW("scores",e,t,r),s=aW("maxOutputSize",e,t,r),i=aW("iouThreshold",e,t,r);return{boxes:n,scores:a,maxOutputSize:s,iouThreshold:i,scoreThreshold:aW("scoreThreshold",e,t,r),softNmsSigma:aW("softNmsSigma",e,t,r)}}let sO=async(e,t,r,n,a=$)=>{switch(e.op){case"NonMaxSuppressionV5":{let{boxes:n,scores:s,maxOutputSize:i,iouThreshold:o,scoreThreshold:l,softNmsSigma:u}=sD(e,t,r),h=await a.image.nonMaxSuppressionWithScoreAsync(n,s,i,o,l,u);return[h.selectedIndices,h.selectedScores]}case"NonMaxSuppressionV4":{let{boxes:n,scores:s,maxOutputSize:i,iouThreshold:o,scoreThreshold:l}=sD(e,t,r),u=aW("padToMaxOutputSize",e,t,r),h=await a.image.nonMaxSuppressionPaddedAsync(n,s,i,o,l,u);return[h.selectedIndices,h.validOutputs]}case"NonMaxSuppressionV3":case"NonMaxSuppressionV2":{let{boxes:n,scores:s,maxOutputSize:i,iouThreshold:o,scoreThreshold:l}=sD(e,t,r);return[await a.image.nonMaxSuppressionAsync(n,s,i,o,l)]}case"Where":{let n=a.cast(aW("condition",e,t,r),"bool"),s=[await a.whereAsync(n)];return n.dispose(),s}case"ListDiff":return a.setdiff1dAsync(aW("x",e,t,r),aW("y",e,t,r));default:throw TypeError(`Node type ${e.op} is not implemented`)}},sL=(e,t,r,n=$)=>{switch(e.op){case"LowerBound":{let a=aW("sortedSequence",e,t,r),s=aW("values",e,t,r);return[n.lowerBound(a,s)]}case"TopKV2":{let a=aW("x",e,t,r),s=aW("k",e,t,r),i=aW("sorted",e,t,r),o=n.topk(a,s,i);return[o.values,o.indices]}case"UpperBound":{let a=aW("sortedSequence",e,t,r),s=aW("values",e,t,r);return[n.upperBound(a,s)]}case"Unique":{let a=aW("x",e,t,r),s=n.unique(a);return[s.values,s.indices]}case"UniqueV2":{let a=aW("x",e,t,r),s=aW("axis",e,t,r),i=n.unique(a,s);return[i.values,i.indices]}default:throw TypeError(`Node type ${e.op} is not implemented`)}},sM=(e,t,r,n=$)=>{switch(e.op){case"Const":return t[e.name];case"PlaceholderWithDefault":let a=aW("default",e,t,r);return[aV(e.name,t,r)||a];case"Placeholder":return[aV(e.name,t,r)];case"Identity":case"StopGradient":case"FakeQuantWithMinMaxVars":case"Snapshot":return[aK(aW("x",e,t,r))];case"IdentityN":return aW("x",e,t,r).map(e=>aK(e));case"Shape":return[n.tensor1d(aW("x",e,t,r).shape,"int32")];case"ShapeN":return aW("x",e,t,r).map(e=>n.tensor1d(e.shape));case"Size":return[n.scalar(aW("x",e,t,r).size,"int32")];case"Rank":return[n.scalar(aW("x",e,t,r).rank,"int32")];case"NoOp":return[n.scalar(1)];case"Print":let s=aW("x",e,t,r),i=aW("data",e,t,r),o=aW("message",e,t,r),l=aW("summarize",e,t,r);console.warn("The graph has a tf.print() operation,usually used for debugging, which slows down performance."),console.log(o);for(let e=0;e<i.length;e++)console.log(Array.prototype.slice.call(i[e].dataSync()).slice(0,l));return[s];default:throw TypeError(`Node type ${e.op} is not implemented`)}};class sP{get id(){return this.handle.id}constructor(e,t){this.keyDType=e,this.valueDType=t,this.handle=(0,R.d_2)(0),this.tensorMap=new Map,(0,R.aCs)(this.handle)}
196clearAndClose(){this.tensorMap.forEach(e=>e.dispose()),this.tensorMap.clear(),this.handle.dispose()}size(){return this.tensorMap.size}tensorSize(){return B.d(this.size(),"int32")}async import(e,t){this.checkKeyAndValueTensor(e,t);let r=await e.data();return this.tensorMap.forEach(e=>e.dispose()),this.tensorMap.clear(),(0,R.DZQ)(()=>{let e=(0,R.K$i)(t),n=r.length,a=e.length;R.ZSL.assert(n===a,()=>`The number of elements doesn't match, keys has ${n} elements, the values has ${a} elements.`);for(let t=0;t<n;t++){let n=r[t],a=e[t];(0,R.aCs)(a),this.tensorMap.set(n,a)}return this.handle})}async find(e,t){this.checkKeyAndValueTensor(e,t);let r=await e.data();return(0,R.DZQ)(()=>{let e=[];for(let n=0;n<r.length;n++){let a=r[n],s=this.findWithDefault(a,t);e.push(s)}return(0,R.t$z)(e)})}findWithDefault(e,t){let r=this.tensorMap.get(e);return null!=r?r:t}checkKeyAndValueTensor(e,t){if(e.dtype!==this.keyDType)throw Error(`Expect key dtype ${this.keyDType}, but got ${e.dtype}`);if(t.dtype!==this.valueDType)throw Error(`Expect value dtype ${this.valueDType}, but got ${t.dtype}`)}}let sz=async(e,t,r,n)=>{switch(e.op){case"HashTable":case"HashTableV2":{let a=n.getHashTableHandleByName(e.name);if(null!=a)return[a];{let a=new sP(aW("keyDType",e,t,r),aW("valueDType",e,t,r));return n.addHashTable(e.name,a),[a.handle]}}case"InitializeTable":case"InitializeTableV2":case"LookupTableImport":case"LookupTableImportV2":{let a=aW("tableHandle",e,t,r,n),s=aW("keys",e,t,r),i=aW("values",e,t,r),o=n.getHashTableById(a.id);return[await o.import(s,i)]}case"LookupTableFind":case"LookupTableFindV2":{let a=aW("tableHandle",e,t,r,n),s=aW("keys",e,t,r),i=aW("defaultValue",e,t,r),o=n.getHashTableById(a.id);return[await o.find(s,i)]}case"LookupTableSize":case"LookupTableSizeV2":{let a=aW("tableHandle",e,t,r,n);return[n.getHashTableById(a.id).tensorSize()]}default:throw TypeError(`Node type ${e.op} is not implemented`)}},sB=(e,t,r,n=$)=>{switch(e.op){case"ResizeBilinear":{let a=aW("images",e,t,r),s=aW("size",e,t,r),i=aW("alignCorners",e,t,r),o=aW("halfPixelCenters",e,t,r);return[n.image.resizeBilinear(a,[s[0],s[1]],i,o)]}case"ResizeNearestNeighbor":{let a=aW("images",e,t,r),s=aW("size",e,t,r),i=aW("alignCorners",e,t,r),o=aW("halfPixelCenters",e,t,r);return[n.image.resizeNearestNeighbor(a,[s[0],s[1]],i,o)]}case"CropAndResize":{let a=aW("image",e,t,r),s=aW("boxes",e,t,r),i=aW("boxInd",e,t,r),o=aW("cropSize",e,t,r),l=aW("method",e,t,r),u=aW("extrapolationValue",e,t,r);return[n.image.cropAndResize(a,s,i,o,l,u)]}case"ImageProjectiveTransformV3":{let a=aW("images",e,t,r),s=aW("transforms",e,t,r),i=aW("outputShape",e,t,r),o=aW("fillValue",e,t,r),l=aW("interpolation",e,t,r),u=aW("fillMode",e,t,r);return[n.image.transform(a,s,l.toLowerCase(),u.toLowerCase(),o,i)]}default:throw TypeError(`Node type ${e.op} is not implemented`)}},sW=(e,t,r,n=$)=>{switch(e.op){case"Equal":return[n.equal(aW("a",e,t,r),aW("b",e,t,r))];case"NotEqual":return[n.notEqual(aW("a",e,t,r),aW("b",e,t,r))];case"Greater":return[n.greater(aW("a",e,t,r),aW("b",e,t,r))];case"GreaterEqual":return[n.greaterEqual(aW("a",e,t,r),aW("b",e,t,r))];case"Less":return[n.less(aW("a",e,t,r),aW("b",e,t,r))];case"LessEqual":return[n.lessEqual(aW("a",e,t,r),aW("b",e,t,r))];case"LogicalAnd":return[n.logicalAnd(aW("a",e,t,r),aW("b",e,t,r))];case"LogicalNot":return[n.logicalNot(aW("a",e,t,r))];case"LogicalOr":return[n.logicalOr(aW("a",e,t,r),aW("b",e,t,r))];case"Select":case"SelectV2":return[n.where(aW("condition",e,t,r),aW("a",e,t,r),aW("b",e,t,r))];case"BitwiseAnd":return[n.bitwiseAnd(aW("a",e,t,r),aW("b",e,t,r))];default:throw TypeError(`Node type ${e.op} is not implemented`)}},sV=(e,t,r,n=$)=>{switch(e.op){case"BatchMatMul":case"BatchMatMulV2":case"MatMul":return[n.matMul(aW("a",e,t,r),aW("b",e,t,r),aW("transposeA",e,t,r),aW("transposeB",e,t,r))];case"Einsum":return[n.einsum(aW("equation",e,t,r),...aW("tensors",e,t,r))];case"Transpose":return[n.transpose(aW("x",e,t,r),aW("perm",e,t,r))];case"_FusedMatMul":let[a,s]=aW("fusedOps",e,t,r),i="prelu"===s,o=aW("numArgs",e,t,r),l=aW("leakyreluAlpha",e,t,r);if("biasadd"===a){if(i&&2!==o)throw Error("Fused MatMul with BiasAdd and Prelu must have two extra arguments: bias and alpha.");if(!i&&1!==o)throw Error("Fused MatMul with BiasAdd must have one extra argument: bias.")}let[u,h]=aW("args",e,t,r);return[n.fused.matMul({a:aW("a",e,t,r),b:aW("b",e,t,r),transposeA:aW("transposeA",e,t,r),transposeB:aW("transposeB",e,t,r),bias:u,activation:s,preluActivationWeights:h,leakyreluAlpha:l})];
vendor: 8,655 bytes, line 196
196case"MatrixBandPart":return[n.linalg.bandPart(aW("a",e,t,r),aW("numLower",e,t,r),aW("numUpper",e,t,r))];default:throw TypeError(`Node type ${e.op} is not implemented`)}},sG=(e,t,r,n=$)=>{switch(e.op){case"EuclideanNorm":return[n.euclideanNorm(aW("x",e,t,r),aW("axis",e,t,r),aW("keepDims",e,t,r))];case"FusedBatchNorm":case"FusedBatchNormV2":case"FusedBatchNormV3":return[n.batchNorm(aW("x",e,t,r),aW("mean",e,t,r),aW("variance",e,t,r),aW("offset",e,t,r),aW("scale",e,t,r),aW("epsilon",e,t,r))];case"LRN":return[n.localResponseNormalization(aW("x",e,t,r),aW("radius",e,t,r),aW("bias",e,t,r),aW("alpha",e,t,r),aW("beta",e,t,r))];case"Softmax":return[n.softmax(aW("x",e,t,r))];case"LogSoftmax":return[n.logSoftmax(aW("x",e,t,r))];default:throw TypeError(`Node type ${e.op} is not implemented`)}},sU=(e,t,r,n=$)=>{switch(e.op){case"RaggedGather":{let{outputNestedSplits:a,outputDenseValues:s}=n.raggedGather(aW("paramsNestedSplits",e,t,r),aW("paramsDenseValues",e,t,r),aW("indices",e,t,r),aW("outputRaggedRank",e,t,r));return a.concat(s)}case"RaggedRange":{let{rtNestedSplits:a,rtDenseValues:s}=n.raggedRange(aW("starts",e,t,r),aW("limits",e,t,r),aW("splits",e,t,r));return[a,s]}case"RaggedTensorToTensor":return[n.raggedTensorToTensor(aW("shape",e,t,r),aW("values",e,t,r),aW("defaultValue",e,t,r),aW("rowPartitionTensors",e,t,r),aW("rowPartitionTypes",e,t,r))];default:throw TypeError(`Node type ${e.op} is not implemented`)}},sZ=(e,t,r,n=$)=>{switch(e.op){case"Max":{let a=aW("axis",e,t,r),s=aW("keepDims",e,t,r);return[n.max(aW("x",e,t,r),a,s)]}case"Mean":{let a=aW("axis",e,t,r),s=aW("keepDims",e,t,r);return[n.mean(aW("x",e,t,r),a,s)]}case"Min":{let a=aW("axis",e,t,r),s=aW("keepDims",e,t,r);return[n.min(aW("x",e,t,r),a,s)]}case"Sum":{let a=aW("axis",e,t,r),s=aW("keepDims",e,t,r);return[n.sum(aW("x",e,t,r),a,s)]}case"All":{let a=aW("axis",e,t,r),s=aW("keepDims",e,t,r);return[n.all(aW("x",e,t,r),a,s)]}case"Any":{let a=aW("axis",e,t,r),s=aW("keepDims",e,t,r);return[n.any(aW("x",e,t,r),a,s)]}case"ArgMax":{let a=aW("axis",e,t,r);return[n.argMax(aW("x",e,t,r),a)]}case"ArgMin":{let a=aW("axis",e,t,r);return[n.argMin(aW("x",e,t,r),a)]}case"Prod":{let a=aW("axis",e,t,r),s=aW("keepDims",e,t,r);return[n.prod(aW("x",e,t,r),a,s)]}case"Cumprod":{let a=aW("axis",e,t,r),s=aW("exclusive",e,t,r),i=aW("reverse",e,t,r);return[n.cumprod(aW("x",e,t,r),a,s,i)]}case"Cumsum":{let a=aW("axis",e,t,r),s=aW("exclusive",e,t,r),i=aW("reverse",e,t,r);return[n.cumsum(aW("x",e,t,r),a,s,i)]}case"Bincount":let a=aW("x",e,t,r),s=aW("weights",e,t,r),i=aW("size",e,t,r);return[n.bincount(a,s,i)];case"DenseBincount":{let a=aW("x",e,t,r),s=aW("weights",e,t,r),i=aW("size",e,t,r),o=aW("binaryOutput",e,t,r);return[n.denseBincount(a,s,i,o)]}default:throw TypeError(`Node type ${e.op} is not implemented`)}},sj=(e,t,r,n=$)=>{switch(e.op){case"ConcatV2":case"Concat":{let a=aW("n",e,t,r),s=aW("axis",e,t,r),i=aW("tensors",e,t,r);return i=i.slice(0,a),[n.concat(i,s)]}case"Gather":{let a=aW("x",e,t,r),s=aW("indices",e,t,r);return[n.gather(a,n.cast(s,"int32"),0)]}case"GatherV2":{let a=aW("axis",e,t,r),s=aW("batchDims",e,t,r),i=aW("x",e,t,r),o=aW("indices",e,t,r);return[n.gather(i,n.cast(o,"int32"),a,s)]}case"Reverse":{let a=aW("dims",e,t,r),s=[];for(let e=0;e<a.length;e++)a[e]&&s.push(e);let i=aW("x",e,t,r);return[n.reverse(i,s)]}case"ReverseV2":{let a=aW("axis",e,t,r),s=aW("x",e,t,r);return[n.reverse(s,a)]}case"Slice":{let a=aW("begin",e,t,r),s=aW("size",e,t,r);return[n.slice(aW("x",e,t,r),a,s)]}case"StridedSlice":{let a=aW("begin",e,t,r),s=aW("end",e,t,r),i=aW("strides",e,t,r),o=aW("beginMask",e,t,r),l=aW("endMask",e,t,r),u=aW("ellipsisMask",e,t,r),h=aW("newAxisMask",e,t,r),p=aW("shrinkAxisMask",e,t,r),d=aW("x",e,t,r);return[n.stridedSlice(d,a,s,i,o,l,u,h,p)]}case"Pack":return(0,R.DZQ)(()=>{let a=aW("axis",e,t,r),s=aW("tensors",e,t,r),i=s[0].shape,o=n.squeeze(s[0]).shape,l=s.map(e=>{let t=R.ZSL.arraysEqual(e.shape,i);if(!t&&!R.ZSL.arraysEqual(n.squeeze(e).shape,o))throw Error("the input tensors shape does not match");return t?e:n.reshape(e,i)});return[n.stack(l,a)]});case"Unpack":{let a=aW("axis",e,t,r),s=aW("tensor",e,t,r);return n.unstack(s,a)}case"Tile":{let a=aW("reps",e,t,r);return[n.tile(aW("x",e,t,r),a)]}case"Split":case"SplitV":{let a=aW("axis",e,t,r),s=aW("numOrSizeSplits",e,t,r),i=aW("x",e,t,r);return n.split(i,s,a)}case"ScatterNd":{let a=aW("indices",e,t,r),s=aW("values",e,t,r),i=aW("shape",e,t,r);return[n.scatterND(a,s,i)]}case"GatherNd":{let a=aW("x",e,t,r),s=aW("indices",e,t,r);return[n.gatherND(a,s)]}case"SparseToDense":{let a=aW("sparseIndices",e,t,r),s=aW("outputShape",e,t,r),i=aW("sparseValues",e,t,r),o=aW("defaultValue",e,t,r);return[n.sparseToDense(a,i,s,i.dtype===o.dtype?o:n.cast(o,i.dtype))]}case"TensorScatterUpdate":{let a=aW("indices",e,t,r),s=aW("values",e,t,r),i=aW("tensor",e,t,r);return[n.tensorScatterUpdate(i,a,s)]}default:throw TypeError(`Node type ${e.op} is not implemented`)}},sH=(e,t,r,n=$)=>{switch(e.op){case"SparseFillEmptyRows":{let{outputIndices:a,outputValues:s,emptyRowIndicator:i,reverseIndexMap:o}=n.sparse.sparseFillEmptyRows(aW("indices",e,t,r),aW("values",e,t,r),aW("denseShape",e,t,r),aW("defaultValue",e,t,r));return[a,s,i,o]}case"SparseReshape":{let{outputIndices:a,outputShape:s}=n.sparse.sparseReshape(aW("inputIndices",e,t,r),aW("inputShape",e,t,r),aW("newShape",e,t,r));return[a,s]}case"SparseSegmentMean":return[n.sparse.sparseSegmentMean(aW("data",e,t,r),aW("indices",e,t,r),aW("segmentIds",e,t,r))];case"SparseSegmentSum":return[n.sparse.sparseSegmentSum(aW("data",e,t,r),aW("indices",e,t,r),aW("segmentIds",e,t,r))];default:throw TypeError(`Node type ${e.op} is not implemented`)}},sK=(e,t,r,n=$)=>{switch(e.op){case"FFT":return[n.fft(aW("x",e,t,r))];case"IFFT":return[n.ifft(aW("x",e,t,r))];case"RFFT":return[n.rfft(aW("x",e,t,r))];case"IRFFT":return[n.irfft(aW("x",e,t,r))];default:throw TypeError(`Node type ${e.op} is not implemented`)}},sY=(e,t,r,n=$)=>{switch(e.op){case"StaticRegexReplace":return[n.string.staticRegexReplace(aW("input",e,t,r),aW("pattern",e,t,r),aW("rewrite",e,t,r),aW("replaceGlobal",e,t,r))];case"StringNGrams":{let{nGrams:a,nGramsSplits:s}=n.string.stringNGrams(aW("data",e,t,r),aW("dataSplits",e,t,r),aW("separator",e,t,r),aW("nGramWidths",e,t,r),aW("leftPad",e,t,r),aW("rightPad",e,t,r),aW("padWidth",e,t,r),aW("preserveShortSequences",e,t,r));return[a,s]}case"StringSplit":{let{indices:a,values:s,shape:i}=n.string.stringSplit(aW("input",e,t,r),aW("delimiter",e,t,r),aW("skipEmpty",e,t,r));return[a,s,i]}case"StringToHashBucketFast":return[n.string.stringToHashBucketFast(aW("input",e,t,r),aW("numBuckets",e,t,r))];default:throw TypeError(`Node type ${e.op} is not implemented`)}},sQ=(e,t,r,n=$)=>{switch(e.op){case"Cast":return[n.cast(aW("x",e,t,r),aW("dtype",e,t,r))];case"ExpandDims":{let a=aW("axis",e,t,r);return[n.expandDims(aW("x",e,t,r),a)]}case"Squeeze":{let a=aW("axis",e,t,r);return[n.squeeze(aW("x",e,t,r),a)]}case"Reshape":return[n.reshape(aW("x",e,t,r),aW("shape",e,t,r))];case"EnsureShape":return[n.ensureShape(aW("x",e,t,r),aW("shape",e,t,r))];case"MirrorPad":return[n.mirrorPad(aW("x",e,t,r),aW("padding",e,t,r),aW("mode",e,t,r))];case"PadV2":case"Pad":return[n.pad(aW("x",e,t,r),aW("padding",e,t,r),aW("constantValue",e,t,r))];case"SpaceToBatchND":{let a=aW("blockShape",e,t,r),s=aW("paddings",e,t,r);return[n.spaceToBatchND(aW("x",e,t,r),a,s)]}case"BatchToSpaceND":{let a=aW("blockShape",e,t,r),s=aW("crops",e,t,r);return[n.batchToSpaceND(aW("x",e,t,r),a,s)]}case"DepthToSpace":{let a=aW("blockSize",e,t,r),s=aW("dataFormat",e,t,r).toUpperCase();return[n.depthToSpace(aW("x",e,t,r),a,s)]}case"BroadcastTo":return[n.broadcastTo(aW("x",e,t,r),aW("shape",e,t,r))];case"BroadcastArgs":return[n.broadcastArgs(aW("s0",e,t,r),aW("s1",e,t,r))];default:throw TypeError(`Node type ${e.op} is not implemented`)}};function sq(e,t,r,n,a=R.DZQ){let s=((e,t,r)=>{switch(e.category){case"arithmetic":return a(()=>sT(e,t,r));case"basic_math":return a(()=>sS(e,t,r));case"control":return s$(e,t,r);case"convolution":return a(()=>sR(e,t,r));case"creation":return a(()=>s_(e,t,r));case"dynamic":return sO(e,t,r);case"evaluation":return a(()=>sL(e,t,r));case"image":return a(()=>sB(e,t,r));case"graph":return a(()=>sM(e,t,r));case"logical":return a(()=>sW(e,t,r));case"matrices":return a(()=>sV(e,t,r));case"normalization":return a(()=>sG(e,t,r));case"ragged":return a(()=>sU(e,t,r));case"reduction":return a(()=>sZ(e,t,r));case"slice_join":return a(()=>sj(e,t,r));case"sparse":return a(()=>sH(e,t,r));case"spectral":return a(()=>sK(e,t,r));case"string":return a(()=>sY(e,t,r));case"transformation":return a(()=>sQ(e,t,r));case"hash_table":return sz(e,t,r,n);
196case"custom":let s=aP[e.op];if(s&&s.customExecutor)return s.customExecutor(new sv(e,t,r));throw TypeError(`Custom op ${e.op} is not registered.`);default:throw TypeError(`Unknown op '${e.op}'. File an issue at https://github.com/tensorflow/tfjs/issues so we can add it, or register a custom execution with tf.registerOp()`)}})(e,t,r);return R.ZSL.isPromise(s)?s.then(e=>[].concat(e)):[].concat(s)}class sX{constructor(e={},t={},r={},n={},a){this.weightMap=e,this.tensorArrayMap=t,this.tensorListMap=r,this.functionMap=n,this.parseNodeNameCache=a,this.rootContext={id:0,frameName:"",iterationId:0},this.contexts=[this.rootContext],this.lastId=0,this.generateCurrentContextIds()}newFrame(e,t){return{id:e,frameName:t,iterationId:0}}set currentContext(e){this.contexts!==e&&(this.contexts=e,this.generateCurrentContextIds())}get currentContext(){return this.contexts}get currentContextId(){return this._currentContextIds[0]}get currentContextIds(){return this._currentContextIds}generateCurrentContextIds(){let e=[];for(let t=0;t<this.contexts.length-1;t++){let r=this.contexts.slice(0,this.contexts.length-t);e.push(this.contextIdforContexts(r))}e.push(""),this._currentContextIds=e}contextIdforContexts(e){return e?e.map(e=>0===e.id&&0===e.iterationId?"":`${e.frameName}-${e.iterationId}`).join("/"):""}enterFrame(e){this.contexts&&(this.lastId++,this.contexts=this.contexts.slice(),this.contexts.push(this.newFrame(this.lastId,e)),this._currentContextIds.unshift(this.contextIdforContexts(this.contexts)))}exitFrame(){if(this.contexts&&this.contexts.length>1)this.contexts=this.contexts.slice(),this.contexts.splice(-1),this.currentContextIds.shift();else throw 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 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 sJ(e,t,r,n){let a=new Set,s=[],i=null,o=null,l=new Set,u=new Set(Object.keys(e).map(e=>aj(e)[0])),h=new Set((n=n||[]).map(e=>aj(e.name)[0])),p=[...t];for(;p.length>0;){var d,c;let e=p.pop();if((s4(e)||(d=e,s2.has(d.op))||(c=e,s3.has(c.op)))&&null==i&&(o=(i=e).children.map(e=>e.name).filter(e=>a.has(e))),a.add(e.name),!(null!=r[e.name]||u.has(e.name)||h.has(e.name))){if(0===e.inputs.length){s.push(e.name);continue}e.inputs.forEach(e=>{l.has(e.name)||(l.add(e.name),p.push(e))})}}return{inputs:e,outputs:t,usedNodes:a,missingInputs:s,dynamicNode:i,syncInputs:o}}class s0 extends Error{constructor(e){super(`NodesExecutionOrderError: ${e}`)}}let s1=new Set(["Switch","Merge","Enter","Exit","NextIteration","StatelessIf","StatelessWhile","if","While"]),s2=new Set(["NonMaxSuppressionV2","NonMaxSuppressionV3","NonMaxSuppressionV5","Where"]),s3=new Set(["HashTable","HashTableV2","LookupTableImport","LookupTableImportV2","LookupTableFind","LookupTableFindV2","LookupTableSize","LookupTableSizeV2"]);function s4(e){return s1.has(e.op)}class s5{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(t=>e[t].map(e=>e.id));this._weightIds=[].concat(...t),this._weightMap=e}set resourceManager(e){this._resourceManager=e}get inputs(){return this._inputs.map(e=>({name:e.name,shape:e.attrParams.shape?e.attrParams.shape.value:void 0,dtype:e.attrParams.dtype?e.attrParams.dtype.value:void 0}))}get outputs(){return this._outputs.map(e=>({name:e.name,shape:e.attrParams.shape?e.attrParams.shape.value:void 0,dtype:e.attrParams.dtype?e.attrParams.dtype.value:void 0}))}get inputNodes(){return this._inputs.map(e=>e.signatureKey||e.name)}get outputNodes(){return this._outputs.map(e=>{let t=e.signatureKey||e.name;return e.defaultOutput?`${t}:${e.defaultOutput}`:t})}get functions(){return Object.keys(this._functions).reduce((e,t)=>
196(e[t]=this._functions[t].signature,e),{})}constructor(e,t){this.graph=e,this.parent=t,this.compiledMap=new Map,this.parseNodeNameCache=new Map,this._weightMap={},this.SEPARATOR=",",this._functions={},this._functionExecutorMap={},this.keepIntermediateTensors=!1,this._outputs=e.outputs,this._inputs=e.inputs,this._initNodes=e.initNodes,this._signature=e.signature,this._functions=e.functions,null!=e.functions&&Object.keys(e.functions).forEach(t=>{this._functionExecutorMap[t]=new s5(e.functions[t],this)})}getCompilationKey(e,t){let r=e.map(e=>e.name).sort(),n=t.map(e=>e.name).sort();return r.join(this.SEPARATOR)+"--"+n.join(this.SEPARATOR)}compile(e,t){let r=sJ(e,t,this.weightMap,this._initNodes),{missingInputs:n,dynamicNode:a,syncInputs:s}=r;if(null!=a)throw Error(`This execution contains the node '${a.name}', which has the dynamic op '${a.op}'. Please use model.executeAsync() instead. Alternatively, to avoid the dynamic ops, specify the inputs [${s}]`);if(n.length>0){let r=t.map(e=>e.name),a=Object.keys(e);throw Error(`Cannot compute the outputs [${r}] from the provided inputs [${a}]. Missing the following inputs: [${n}]`)}let i=function(e,t){let{usedNodes:r,inputs:n}=t,a=Object.keys(n).map(e=>aj(e)[0]).map(t=>e.nodes[t]),s=e.initNodes||[],i=e=>r.has("string"==typeof e?e:e.name);function o(e){return[...new Map(e.map(e=>[e.name,e])).values()]}let l=o([...a,...e.weights,...s]).filter(i),u=o([...l,...Object.values(e.nodes)]).filter(i),h=new Map(u.map(e=>[e.name,e])),p={};for(let e of u)for(let t of(p[e.name]=p[e.name]||0,e.children))i(t)||(p[t.name]=Number.POSITIVE_INFINITY),p[t.name]=(p[t.name]||0)+1;let d=Object.entries(p).filter(([,e])=>0===e).map(([e])=>e),c=[...d];for(;d.length>0;){let e=d.pop();for(let t of h.get(e).children.filter(i))0==--p[t.name]&&(c.push(t.name),d.push(t.name))}let f=function(e,t){let r=new Map(e.map(e=>[e.name,e])),n=t.map(e=>e.name),a=new Set(n);for(;n.length>0;){let e=n.pop();for(let t of r.get(e).children)!r.has(t.name)||a.has(t.name)||(a.add(t.name),n.push(t.name))}return e.filter(e=>a.has(e.name))}(c.map(e=>h.get(e)),l);return function(e,t){let r=new Map(e.map((e,t)=>[e.name,t])),n=new Set(t.map(e=>e.name)),a=e=>n.has("string"==typeof e?e:e.name),s=new Set(e.map(e=>e.name)),i=e=>s.has("string"==typeof e?e:e.name);for(let t of e){for(let e of t.children.filter(i)){if(!r.has(e.name))throw new s0(`Child ${e.name} of node ${t.name} is unreachable.`);if(r.get(t.name)>r.get(e.name))throw new s0(`Node ${t.name} is scheduled to run after its child ${e.name}.`)}if(!a(t))for(let e of t.inputs){if(!r.has(e.name))throw new s0(`Input ${e.name} of node ${t.name} is unreachable.`);if(r.get(e.name)>r.get(t.name))throw new s0(`Node ${t.name} is scheduled to run before its input ${e.name}.`)}}}(f,l),f}(this.graph,r),o=function(e){let t=new Map(e.map((e,t)=>[e.name,t])),r=Number.MAX_SAFE_INTEGER,n=e.map((e,t)=>s4(e)?r:t),a=e=>{let r=n[t.get(e.name)];return null==r?-1:r},s=e.map((e,t)=>e.children.map(a).reduce((e,t)=>Math.max(e,t),n[t])),i=new Map;for(let t=0;t<e.length;++t){let n=s[t];if(n===r)continue;let a=e[t],o=e[n];i.has(o.name)||i.set(o.name,[]),i.get(o.name).push(a)}return i}(i);return{orderedNodes:i,nodeLiveUntilMap:o}}cloneAndKeepTensor(e){if(null==e)return null;let t=e.clone();return(0,R.aCs)(t),t}cloneTensorList(e){return e?e.map(e=>this.cloneAndKeepTensor(e)):null}cloneTensorMap(e){return Object.fromEntries(Object.entries(e).map(([e,t])=>[e,this.cloneTensorList(t)]))}execute(e,t){this.disposeIntermediateTensors();let r=Object.keys(e=this.mapInputs(e)).sort();this.checkInputs(e),this.checkInputShapeAndType(e),t=this.mapOutputs(t),this.checkOutputs(t);let n=r.map(e=>this.graph.nodes[aj(e)[0]]),a=t.map(e=>aj(e)[0]),s=new Set(a),i=a.map(e=>this.graph.nodes[e]);0===i.length&&(i=this._outputs);let o=this.getCompilationKey(n,i),l=this.compiledMap.get(o);null==l&&(l=this.compile(e,i),this.compiledMap.set(o,l));try{this.keepIntermediateTensors=(0,R._K2)().getBool("KEEP_INTERMEDIATE_TENSORS")}catch(e){this.keepIntermediateTensors=!1,console.warn(e.message)}let u={},h={};return(0,R.DZQ)(()=>{let r=new sX(this.weightMap,u,h,this.functionExecutorMap,this.parseNodeNameCache),n=Object.assign({},this.weightMap);this.keepIntermediateTensors&&(this.clonedTensorsMap=this.cloneTensorMap(this.weightMap)),Object.keys(e).forEach(t=>{let[a,s]=aj(t,r),i=[];i[s]=e[t],n[a]=i,this.keepIntermediateTensors&&(this.clonedTensorsMap[a]=this.cloneTensorList(i))});let a=this.getFrozenTensorIds(n),{orderedNodes:i,nodeLiveUntilMap:o}=l;for(let e of i){if(n[e.name])continue;let t=sq(e,n,r,this._resourceManager);if(R.ZSL.isPromise(t))throw Error(`The execution of the op '${e.op}' returned a promise. Please use model.executeAsync() instead.`);n[e.name]=t,this.keepIntermediateTensors&&(this.clonedTensorsMap[e.name]=this.cloneTensorList(t)),this.checkTensorForDisposalWithNodeLiveUntilInfo(e,n,r,a,s,o.get(e.name))}return null==this.parent&&r.dispose(a),t.map(e=>aV(e,n,r))})}getFrozenTensorIds(e){return new Set([].concat.apply([],Object.keys(e).map(t=>e[t]).map(e=>e.map(e=>e.id))))}checkTensorForDisposal(e,t,r,n,a,s,i){if(!(s4(t)||s.has(e))){for(let n of r[e])null!=n&&(i[n.id]=(i[n.id]||0)+t.children.length);
196for(let e of t.inputs){if(s4(e))continue;let t=aG(e.name,r,n);if(null!=t)for(let e of t){if(!e||e.kept||a.has(e.id))continue;let t=i[e.id];1===t?(e.dispose(),delete i[e.id]):null!=t&&i[e.id]--}}}}checkTensorForDisposalWithNodeLiveUntilInfo(e,t,r,n,a,s){if(!s4(e)&&null!=s){for(let e of s)if(!(s4(e)||a.has(e.name)))for(let a of aG(e.name,t,r))!a||a.kept||n.has(a.id)||a.dispose()}}async executeAsync(e,t){return this._executeAsync(e,t)}disposeIntermediateTensors(){this.clonedTensorsMap&&(Object.values(this.clonedTensorsMap).forEach(e=>{for(let t of e)t&&!t.isDisposed&&t.dispose()}),this.clonedTensorsMap=null)}getIntermediateTensors(){return this.clonedTensorsMap}async _executeAsync(e,t,r=!1,n={},a={}){this.disposeIntermediateTensors(),r||(e=this.mapInputs(e),this.checkInputs(e),this.checkInputShapeAndType(e),t=this.mapOutputs(t),this.checkOutputs(t));try{this.keepIntermediateTensors=(0,R._K2)().getBool("KEEP_INTERMEDIATE_TENSORS")}catch(e){this.keepIntermediateTensors=!1,console.warn(e.message)}let s=new sX(this.weightMap,n,a,this.functionExecutorMap,this.parseNodeNameCache);this.keepIntermediateTensors&&(this.clonedTensorsMap=this.cloneTensorMap(this.weightMap));let i=await this.executeWithControlFlow(e,s,t,r),o=t.map(e=>aV(e,i,s)),l=new Set([...o.map(e=>e.id),...Object.keys(e).map(t=>e[t].id),...this.weightIds]);return Object.values(i).forEach(e=>{e.forEach(e=>{!e||e.isDisposed||l.has(e.id)||e.dispose()})}),null==this.parent&&s.dispose(l),o}async executeFunctionAsync(e,t,r){let n=e.reduce((e,t,r)=>(e[this.inputs[r].name]=t,e),{});return this._executeAsync(n,this.outputNodes,!0,t,r)}async executeWithControlFlow(e,t,r,n){let a=Object.keys(e),s=a.map(e=>this.graph.nodes[aj(e)[0]]),i=r.map(e=>aj(e)[0]),o=new Set(i),l=i.map(e=>this.graph.nodes[e]);0===l.length&&(l=this._outputs);let{usedNodes:u,missingInputs:h,dynamicNode:p,syncInputs:d}=sJ(e,l,this.weightMap,this._initNodes),c=[...s,...this.graph.weights,...this._initNodes||[]].map(e=>({node:e,contexts:t.currentContext})),f=Object.assign({},this.weightMap);Object.keys(e).forEach(t=>{let[r,n]=aj(t),a=[];a[n]=e[t],f[r]=a});let m={},g=this.getFrozenTensorIds(f),y={};for(;c.length>0;){let e=this.processStack(s,c,t,f,y,g,o,m,u);await Promise.all(e)}null!=p||n||console.warn("This model execution did not contain any nodes with control flow or dynamic output shapes. You can use model.execute() instead.");let b=l.filter(e=>!s4(e)&&!aV(e.name,f,t)).map(e=>e.name);if(b.length>0){let e="";throw null!=p&&(e=`Alternatively, to avoid the dynamic ops, use model.execute() and specify the inputs [${d}]`),Error(`Cannot compute the outputs [${b}] from the provided inputs [${a}]. Consider providing the following inputs: [${h}]. ${e}`)}return f}processStack(e,t,r,n,a,s,i,o,l){let u=[];for(;t.length>0;){let e=t.pop();r.currentContext=e.contexts;let h="";if("Enter"===e.node.op&&aW("isConstant",e.node,n,r)&&([h]=aU(e.node.name,r)),null==n[e.node.name]){let p=sq(e.node,n,r,this._resourceManager);h||([h]=aU(e.node.name,r));let d=r.currentContext;R.ZSL.isPromise(p)?u.push(p.then(u=>(n[h]=u,this.keepIntermediateTensors&&(this.clonedTensorsMap[h]=this.cloneTensorList(u)),r.currentContext=d,this.checkTensorForDisposal(h,e.node,n,r,s,i,o),this.processChildNodes(e.node,t,r,n,a,l),u))):(n[h]=p,this.keepIntermediateTensors&&(this.clonedTensorsMap[h]=this.cloneTensorList(p)),this.checkTensorForDisposal(h,e.node,n,r,s,i,o),this.processChildNodes(e.node,t,r,n,a,l))}else this.processChildNodes(e.node,t,r,n,a,l)}return u}processChildNodes(e,t,r,n,a,s){e.children.forEach(e=>{let[i]=aU(e.name,r);!a[i]&&s.has(e.name)&&("Merge"===e.op?e.inputNames.some(e=>!!aV(e,n,r))&&(a[i]=!0,t.push({contexts:r.currentContext,node:e})):e.inputNames.every(e=>!!aV(e,n,r))&&(a[i]=!0,t.push({contexts:r.currentContext,node:e})))})}dispose(){Object.keys(this.weightMap).forEach(e=>this.weightMap[e].forEach(e=>e.dispose()))}checkInputShapeAndType(e){Object.keys(e).forEach(t=>{let r=e[t],[n]=aj(t),a=this.graph.nodes[n];if(a.attrParams.shape&&a.attrParams.shape.value){let e=a.attrParams.shape.value,t=e.length===r.shape.length&&r.shape.every((t,r)=>-1===e[r]||e[r]===t);R.ZSL.assert(t,()=>`The shape of dict['${a.name}'] provided in model.execute(dict) must be [${e}], but was [${r.shape}]`)}a.attrParams.dtype&&a.attrParams.dtype.value&&R.ZSL.assert(r.dtype===a.attrParams.dtype.value,()=>`The dtype of dict['${a.name}'] provided in model.execute(dict) must be ${a.attrParams.dtype.value}, but was ${r.dtype}`)})}mapInputs(e){var t,r;let n={};for(let a in e){let s=null==(r=null==(t=this._signature)?void 0:t.inputs)?void 0:r[a];null!=s?n[s.name]=e[a]:n[a]=e[a]}return n}checkInputs(e){let t=Object.keys(e).filter(e=>{let[t]=aj(e);return null==this.graph.nodes[t]});if(t.length>0)throw Error(`The dict provided in model.execute(dict) has keys: [${t}] that are not part of graph`)}mapOutputs(e){return e.map(e=>{var t,r;let n=null==(r=null==(t=this._signature)?void 0:t.outputs)?void 0:r[e];return null!=n?n.name:e},{})}
196checkOutputs(e){e.forEach(e=>{let[t]=aj(e);if(!this.graph.nodes[t])throw Error(`The output '${e}' is not found in the graph`)})}}class s6{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]}}var s7=r(3437);class s9{get modelVersion(){return this.version}get inputNodes(){return this.executor.inputNodes}get outputNodes(){return this.executor.outputNodes}get inputs(){return this.executor.inputs}get outputs(){return this.executor.outputs}get weights(){return this.executor.weightMap}get metadata(){return this.artifacts.userDefinedMetadata}get modelSignature(){return this.signature}get modelStructuredOutputKeys(){return this.structuredOutputKeys}constructor(e,t={},r=R.io){this.modelUrl=e,this.loadOptions=t,this.version="n/a",this.io=r,null==t&&(this.loadOptions={}),this.resourceManager=new s6}findIOHandler(){let e=this.modelUrl;if(null!=e.load)this.handler=e;else if(null!=this.loadOptions.requestInit)this.handler=this.io.browserHTTPRequest(e,this.loadOptions);else{let t=this.io.getLoadHandlers(e,this.loadOptions);if(0===t.length)t.push(this.io.browserHTTPRequest(e,this.loadOptions));else if(t.length>1)throw Error(`Found more than one (${t.length}) load handlers for URL '${[e]}'`);this.handler=t[0]}}load(){if(this.findIOHandler(),null==this.handler.load)throw Error("Cannot proceed with model loading because the IOHandler provided does not have the `load` method implemented.");let e=this.handler.load();return R.ZSL.isPromise(e)?e.then(e=>null==e.getWeightStream?this.loadSync(e):this.loadStreaming(e)):this.loadSync(e)}loadSync(e){let t=this.io.decodeWeights(e.weightData,e.weightSpecs);return this.loadWithWeightMap(e,t)}async loadStreaming(e){if(null==e.getWeightStream)throw Error("Model artifacts missing streamWeights function");let t=await (0,s7.s5)(e.getWeightStream(),e.weightSpecs);return this.loadWithWeightMap(e,t)}loadWithWeightMap(e,t){this.artifacts=e;let r=this.artifacts.modelTopology,n=this.artifacts.signature;if(null!=this.artifacts.userDefinedMetadata){let e=this.artifacts.userDefinedMetadata;null!=e.signature&&(n=e.signature),null!=e.structuredOutputKeys&&(this.structuredOutputKeys=e.structuredOutputKeys)}if(this.signature=n,this.version=`${r.versions.producer}.${r.versions.minConsumer}`,this.executor=new s5(ss.Instance.transformGraph(r,this.signature)),this.executor.weightMap=this.convertTensorMapToTensorsMap(t),this.executor.resourceManager=this.resourceManager,null!=e.modelInitializer&&null!=e.modelInitializer.node){let t=ss.Instance.transformGraph(e.modelInitializer);this.initializer=new s5(t),this.initializer.weightMap=this.executor.weightMap,this.initializer.resourceManager=this.resourceManager,this.initializerSignature=e.initializerSignature}return!0}async save(e,t){if("string"==typeof e){let t=this.io.getSaveHandlers(e);if(0===t.length)throw Error(`Cannot find any save handlers for URL '${e}'`);if(t.length>1)throw Error(`Found more than one (${t.length}) save handlers for URL '${e}'`);e=t[0]}if(null==e.save)throw Error("GraphModel.save() cannot proceed because the IOHandler provided does not have the `save` attribute defined.");return e.save(this.artifacts)}addStructuredOutputNames(e){if(this.structuredOutputKeys){let t=e instanceof R.qYS?[e]:e,r={};return t.forEach((e,t)=>r[this.structuredOutputKeys[t]]=e),r}return e}predict(e,t){let r=this.execute(e,this.outputNodes);return this.addStructuredOutputNames(r)}async predictAsync(e,t){let r=await this.executeAsync(e,this.outputNodes);return this.addStructuredOutputNames(r)}normalizeInputs(e){var t;if(!(e instanceof R.qYS)&&!Array.isArray(e)){let r=null==(t=this.signature)?void 0:t.inputs;if(null!=r)for(let t in r){let n=r[t];null!=n.resourceId&&(e[t]=this.resourceIdToCapturedInput[n.resourceId])}return e}e=Array.isArray(e)?e:[e];let r=Object.keys(this.resourceIdToCapturedInput).length;if(e.length+r!==this.inputNodes.length)throw Error(`Input tensor count mismatch, the graph model has ${this.inputNodes.length-r} non-resource placeholders, while there are ${e.length} input tensors provided.`);let n=0;return this.inputNodes.reduce((t,r)=>{var a,s,i;let o=null==(i=null==(s=null==(a=this.signature)?void 0:a.inputs)?void 0:s[r])?void 0:i.resourceId;return null!=o?t[r]=this.resourceIdToCapturedInput[o]:t[r]=e[n++],t},{})}normalizeOutputs(e){return Array.isArray(e=e||this.outputNodes)?e:[e]}executeInitializerGraph(){return null==this.initializer?[]:null==this.initializerSignature?this.initializer.execute({},[]):this.initializer.execute({},Object.keys(this.initializerSignature.outputs))}async executeInitializerGraphAsync(){return null==this.initializer?[]:null==this.initializerSignature?this.initializer.executeAsync({},[]):this.initializer.executeAsync({},Object.keys(this.initializerSignature.outputs))}setResourceIdToCapturedInput(e){if(this.resourceIdToCapturedInput={},this.initializerSignature){let t=this.initializerSignature.outputs,r=Object.keys(t);for(let n=0;n<r.length;n++){let a=t[r[n]];this.resourceIdToCapturedInput[a.resourceId]=e[n]}}}execute(e,t){null==this.resourceIdToCapturedInput&&this.setResourceIdToCapturedInput(this.executeInitializerGraph()),e=this.normalizeInputs(e),t=this.normalizeOutputs(t);let r=this.executor.execute(e,t);return r.length>1?r:r[0]}async executeAsync(e,t){null==this.resourceIdToCapturedInput&&this.setResourceIdToCapturedInput(await this.executeInitializerGraphAsync()),e=this.normalizeInputs(e),t=this.normalizeOutputs(t);let r=await this.executor.executeAsync(e,t);return r.length>1?r:r[0]}getIntermediateTensors(){return this.executor.getIntermediateTensors()}disposeIntermediateTensors(){this.executor.disposeIntermediateTensors()}convertTensorMapToTensorsMap(e){return Object.keys(e).reduce((t,r)=>(t[r]=[e[r]],t),{})}dispose(){this.executor.dispose(),this.initializer&&(this.initializer.dispose(),this.resourceIdToCapturedInput&&(0,R.ASo)(this.resourceIdToCapturedInput)),this.resourceManager.dispose()}}async function s8(e,t={}
196,r=R.io){var n;if(null==e)throw Error("modelUrl in loadGraphModel() cannot be null. Please provide a url or an IOHandler that loads the model");null==t&&(t={}),t.fromTFHub&&"string"==typeof e&&((n=e).endsWith("/")||(n+="/"),e=`${n}model.json?tfjs-format=file`);let a=new s9(e,t,r);return await a.load(),a}function ie(e){let t;if(null==e)throw Error("modelUrl in loadGraphModelSync() cannot be null. Please provide model artifacts or an IOHandler that loads the model");if(e instanceof Array){let[r,n]=e;if(!r)throw Error("modelJSON must be the first element of the array");if(!n||!(n instanceof ArrayBuffer))throw Error("An ArrayBuffer of weights must be the second element of the array");if(!("modelTopology"in r))throw Error("Model JSON is missing 'modelTopology'");if(!("weightsManifest"in r))throw Error("Model JSON is missing 'weightsManifest'");let a=R.io.getWeightSpecs(r.weightsManifest),s=R.io.getModelArtifactsForJSONSync(r,a,n);t=R.io.fromMemorySync(s)}else if("load"in e)t=e;else if("modelTopology"in e&&"weightSpecs"in e&&"weightData"in e)t=R.io.fromMemorySync(e);else throw Error("Unknown model format");let r=new s9(t);return r.load(),r}let it="4.22.0";var ir=r(60270);function ia(e,t,r=new Map,n=new Set){if(null==e)return null;if("function"==typeof Blob&&e instanceof Blob)return e.slice();if(n.has(e))throw Error("Circular references are not supported.");if(r.has(e))return r.get(e);let a=t(e);if(a.recurse&&null!==a.value)throw Error("A deep map function may not return both a value and recurse=true.");if(!a.recurse)return r.set(e,a.value),a.value;if(io(e)){let a=Array.isArray(e)?[]:{};for(let s in n.add(e),e){let i=ia(e[s],t,r,n);a[s]=i}return n.delete(e),e.__proto__&&(a.__proto__=e.__proto__),a}throw Error(`Can't recurse into non-iterable type: ${e}`)}function is(e){return null===e?null:io(e[0])?{value:null,recurse:!0}:{value:e,recurse:!1}}async function ii(e,t){let r=new Map;for(let n of(ia(e,t,r),Array.from(r.keys()))){let e=r.get(n);if(R.ZSL.isPromise(e)){let t=await e;r.set(n,t)}}return ia(e,t,r)}function io(e){let t=!1;if(R._K2().get("IS_BROWSER"))t=e instanceof TextDecoder;else{let{StringDecoder:n}=r(80551);t=e instanceof n}return null!=e&&!ArrayBuffer.isView(e)&&(Array.isArray(e)||"object"==typeof e&&!(e instanceof R.qYS)&&!(e instanceof Promise)&&!t)}function il(e){return e instanceof R.qYS?{value:e.clone(),recurse:!1}:io(e)?{value:null,recurse:!0}:{value:e,recurse:!1}}class iu{constructor(e){if(this.capacity=e,this.begin=0,this.end=0,null==e)throw RangeError("Can't create a ring buffer of unknown capacity.");if(e<1)throw RangeError("Can't create ring buffer of capacity < 1.");this.data=Array(e),this.doubledCapacity=2*e}wrap(e){for(;e<0;)e+=this.doubledCapacity;return e%this.doubledCapacity}get(e){if(e<0)throw RangeError("Can't get item at a negative index.");return this.data[e%this.capacity]}set(e,t){if(e<0)throw 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 0===this.length()}push(e){if(this.isFull())throw 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 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 RangeError("Ring buffer is full.");this.begin=this.wrap(this.begin-1),this.set(this.begin,e)}shift(){if(this.isEmpty())throw 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 RangeError("Ring buffer is empty.");let t=this.wrap(this.begin+e),r=this.get(t);return this.set(t,this.pop()),r}}class ih extends iu{constructor(){super(ih.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=2*this.capacity,t=Array(e),r=this.length();for(let e=0;e<r;e++)t[e]=this.get(this.wrap(this.begin+e));this.data=t,this.capacity=e,this.doubledCapacity=2*this.capacity,this.begin=0,this.end=r}}function ip(e){return new im(e)}ih.INITIAL_CAPACITY=32;class id{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=[],r=await e.next();for(;!r.done;)t.push(r.value),r=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(),r=e(t.value);for(;!t.done&&r;)r=e((t=await this.next()).value)}handleErrors(e){return new iT(this,e)}filter(e){return new iv(this,e)}map(e){return new iw(this,e)}mapAsync(e){return new iS(this,e)}serialMapAsync(e){return new iS(this,e).serial()}flatmap(e){return new ik(this,e)}async forEachAsync(e){return this.map(e).resolveFully()}async serialForEach(e){return this.serialMapAsync(e).resolveWhile(e=>!0===e)}rowMajorBatch(e,t=!0){return new ix(this,e,t)}columnMajorBatch(e,t=!0,r=is){return this.rowMajorBatch(e,t).map(e=>(function(e,t=is){return function e(t,r,n=new Set){let a=t[0];if(n.has(a))throw Error("Circular references are not supported.");let s=r(t);if(s.recurse&&null!==s.value)throw Error("A deep zip function may not return both a value and recurse=true.");if(!s.recurse)return s.value;if(io(a)){let s=Array.isArray(a)?[]:{};for(let i in n.add(a),a){let a=e(t.map(e=>e[i]),r,n);s[i]=a}return n.delete(a),s}throw Error(`Can't recurse into non-iterable type: ${a}`)}(e,t)})(e,r))}concatenate(e,t){return new iI(new ic([this,e]),t)}take(e){return e<0||null==e?this:new ib(this,e)}skip(e){return e<0||null==e?this:new iy(this,e)}prefetch(e){return new iE(this,e)}shuffle(e,t){return new iA(this,e,t)}serial(){return new ig(this)}}class ic extends id{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:ia(e,il),done:!1}}}class im extends id{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}}}class ig extends id{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()}}class iy extends id{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;R.ASo(e.value)}return this.upstream.next()}}class ib extends id{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()}}class ix extends id{constructor(e,t,r=!0){super(),this.upstream=e,this.batchSize=t,this.enableSmallLastBatch=r,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){if(this.enableSmallLastBatch&&e.length>0)return{value:e,done:!1};return{value:null,done:!0}}e.push(t.value)}return{value:e,done:!1}}}class iv extends id{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;R.ASo(e.value)}}}class iw extends id{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=R.d_S.getTensorsInContainer(e.value),r=this.transform(e.value),n=R.d_S.getTensorsInContainer(r);for(let e of t)R.d_S.isTensorInList(e,n)||e.dispose();return{value:r,done:!1}}}class iT extends id{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}}}}class iS extends id{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=R.d_S.getTensorsInContainer(e.value),r=await this.transform(e.value),n=R.d_S.getTensorsInContainer(r);for(let e of t)R.d_S.isTensorInList(e,n)||e.dispose();return{value:r,done:!1}}}class iN extends id{constructor(){super(),this.outputQueue=new ih,this.lastRead=Promise.resolve({value:null,done:!1})}async next(){return this.lastRead=this.lastRead.then(()=>this.serialNext()),this.lastRead}async serialNext(){for(;0===this.outputQueue.length();)if(!await this.pump())return{value:null,done:!0};return{value:this.outputQueue.shift(),done:!1}}}class ik extends iN{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=R.d_S.getTensorsInContainer(e.value),r=this.transform(e.value),n=R.d_S.getTensorsInContainer(r);for(let e of(this.outputQueue.pushAll(r),t))R.d_S.isTensorInList(e,n)||e.dispose();return!0}}class iI extends id{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,null==this.iterator){let e=await this.moreIterators.next();if(e.done)return{value:null,done:!0};this.iterator=e.value,null!=this.baseErrorHandler&&(this.iterator=this.iterator.handleErrors(this.baseErrorHandler))}let t=await this.iterator.next();return t.done?(this.iterator=null,this.readFromChain(e)):t}}
196!function(e){e[e.FAIL=0]="FAIL",e[e.SHORTEST=1]="SHORTEST",e[e.LONGEST=2]="LONGEST"}(s||(s={}));class iC extends id{constructor(e,t=s.FAIL){super(),this.iterators=e,this.mismatchMode=t,this.count=0,this.currentPromise=null}summary(){return"{TODO: fill in upstream of zip summaries} -> Zip"}async nextState(e){await e;let t=0,r=0,n=await ii(this.iterators,function(e){return e instanceof id?{value:e.next().then(e=>(t++,e.done&&r++,e.value)),recurse:!1}:{value:null,recurse:!0}});if(t===r)return{value:null,done:!0};if(r>0)switch(this.mismatchMode){case s.FAIL:throw Error(`Zipped streams should have the same length. Mismatched at element ${this.count}.`);case s.SHORTEST:return{value:null,done:!0};case s.LONGEST:}return this.count++,{value:n,done:!1}}async next(){return this.currentPromise=this.nextState(this.currentPromise),this.currentPromise}}class iE extends id{constructor(e,t){super(),this.upstream=e,this.bufferSize=t,this.buffer=new iu(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()}}class iA extends iE{constructor(e,t,r){super(e,t),this.upstream=e,this.windowSize=t,this.upstreamExhausted=!1,this.random=ir.alea(r||R.ZSL.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)return this.refill(),t;this.upstreamExhausted=!0}return{value:null,done:!0}}}class i${constructor(){this.size=null}batch(e,t=!0){let r,n=this;return R.ZSL.assert(e>0,()=>`batchSize needs to be positive, but it is 197 ${e}`),iF(async()=>(await n.iterator()).columnMajorBatch(e,t,iD),this.size===1/0||null==this.size?this.size:t?Math.ceil(this.size/e):Math.floor(this.size/e))}concatenate(e){let t,r=this;return iF(async()=>(await r.iterator()).concatenate(await e.iterator()),this.size===1/0||e.size===1/0?1/0:null!=this.size&&null!=e.size?this.size+e.size:null)}filter(e){let t,r=this;return iF(async()=>(await r.iterator()).filter(t=>R.DZQ(()=>e(t))),this.size===1/0?1/0:null)}async forEachAsync(e){return(await this.iterator()).forEachAsync(e)}map(e){let t=this;return iF(async()=>(await t.iterator()).map(t=>R.DZQ(()=>e(t))),this.size)}mapAsync(e){let t=this;return iF(async()=>(await t.iterator()).mapAsync(e),this.size)}prefetch(e){if(null==e)throw RangeError("`Dataset.prefetch()` requires bufferSize to be specified.");let t=this;return iF(async()=>(await t.iterator()).prefetch(e),this.size)}repeat(e){let t,r=this;return iF(async()=>new iI(new im(async()=>({value:await r.iterator(),done:!1})).take(e),void 0),null!=this.size&&e>0?this.size*e:0===e?0:null!=this.size&&(void 0===e||e<0)?1/0:null)}skip(e){let t,r=this;return iF(async()=>(await r.iterator()).skip(e),null!=this.size&&e>=0&&this.size>=e?this.size-e:null!=this.size&&(this.size<e||void 0===e||e<0)?0:null)}shuffle(e,t,r=!0){if(null==e||e<0)if(null==this.size)throw RangeError("`Dataset.shuffle()` requires bufferSize to be specified.");else throw 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 n=this,a=ir.alea(t||R.ZSL.now().toString());return iF(async()=>{let t=a.int32();return r&&(t+=a.int32()),(await n.iterator()).shuffle(e,t.toString())},this.size)}take(e){let t,r=this;return iF(async()=>(await r.iterator()).take(e),null!=this.size&&this.size>e?e:null!=this.size&&this.size<=e?this.size:null)}async toArray(){if(this.size===1/0)throw Error("Can not convert infinite data stream to array.");return(await this.iterator()).toArray()}async toArrayForTest(){if(this.size===1/0)throw Error("Can not convert infinite data stream to array.");return(await this.iterator()).toArrayForTest()}}function iF(e,t=null){return new class extends i${constructor(){super(...arguments),this.size=t}async iterator(){return e()}}}function iR(e){return iF(async()=>new ic(e),e.length)}function i_(e){let t;if(!io(e))throw Error("The argument to zip() must be an object or array.");if(Array.isArray(e))for(let r=0;r<e.length;r++)t=null==t?e[r].size:Math.min(t,e[r].size);else if(e instanceof Object)for(let r in e)t=null==t?e[r].size:Math.min(t,e[r].size);return iF(async()=>(function(e,t=s.FAIL){return new iC(e,t)})(await ii(e,e=>{if(e instanceof i$)return{value:e.iterator(),recurse:!1};if(io(e))return{value:null,recurse:!0};throw Error("Leaves of the structure passed to zip() must be Datasets, not primitives.")}),s.SHORTEST),t)}function iD(e){var t,r;if(null===e)return null;return null==(t=e[0])||null===(r=t)||"object"!=typeof r&&"function"!=typeof r||Array.isArray(t)||"object"==typeof t&&t instanceof R.qYS||R.ZSL.isTypedArray(t)?{value:function(e){if(0===e.length)throw Error("Can't make a batch of zero elements.");return e[0]instanceof R.qYS?R.t$z(e):R.OEK(e)}(e),recurse:!1}:{value:null,recurse:!0}}i$.MAX_BUFFER_SIZE=1e4;class iO extends i${constructor(e){super(),this.input=e}async iterator(){return(await this.input.iterator()).decodeUTF8().split("\n").map(e=>(e.endsWith("\r")&&(e=e.slice(0,-1)),e))}}let iL=Symbol("out"),iM=Symbol("field"),iP=Symbol("quote"),iz=Symbol("quoteafterquote"),iB=Symbol("quoteinquote");class iW extends i${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)this.fullColumnNames&&e&&R.ZSL.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()+").");else throw Error("Column names must be provided if there is no header line.");this.fullColumnNames||(this.fullColumnNames=e);let t=this.fullColumnNames.reduce((e,t)=>
197(e[t]=e[t]+1||1,e),{}),r=Object.keys(t).filter(e=>t[e]>1);if(R.ZSL.assert(0===r.length,()=>"Duplicate column names found: "+r.toString()),this.columnConfigs){for(let e of Object.keys(this.columnConfigs))if(-1===this.fullColumnNames.indexOf(e))throw Error('The key "'+e+'" provided in columnConfigs does not match any of the column names ('+this.fullColumnNames.toString()+").")}this.columnNamesValidated=!0}async maybeReadHeaderLine(){if(!this.hasHeader)return null;{let e=await this.base.iterator(),t=await e.next();if(t.done)throw Error("No data was found for CSV parsing.");let r=t.value;return this.parseRow(r,!1)}}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 iO(e),t||(t={}),this.hasHeader=!1!==t.hasHeader,this.fullColumnNames=t.columnNames,this.columnConfigs=t.columnConfigs,this.configuredColumnsOnly=t.configuredColumnsOnly,t.delimWhitespace?(R.ZSL.assert(null==t.delimiter,()=>"Delimiter should not be provided when delimWhitespace is true."),this.delimWhitespace=!0,this.delimiter=" "):this.delimiter=t.delimiter?t.delimiter:","}async iterator(){this.columnNamesValidated||await this.setColumnNames();let e=await this.base.iterator();return this.hasHeader&&(e=e.skip(1)),e.map(e=>this.makeDataElement(e))}makeDataElement(e){let t=this.parseRow(e),r={},n={};for(let a=0;a<this.fullColumnNames.length;a++){let s=this.fullColumnNames[a],i=this.columnConfigs?this.columnConfigs[s]:null;if(!this.configuredColumnsOnly||i){let o=t[a],l=null;if(""===o)if(i&&void 0!==i.default)l=i.default;else if(i&&(i.required||i.isLabel))throw Error(`Required column ${s} is empty in this line: ${e}`);else l=void 0;else{let e=Number(o);if(isNaN(e))l=i&&"bool"===i.dtype?this.getBoolean(o):o;else if(i&&i.dtype)switch(i.dtype){case"float32":default:l=e;break;case"int32":l=Math.floor(e);break;case"bool":l=this.getBoolean(o)}else l=e}i&&i.isLabel?n[s]=l:r[s]=l}}return 0===Object.keys(n).length?r:{xs:r,ys:n}}getBoolean(e){return+("1"===e||"true"===e.toLowerCase())}parseRow(e,t=!0){let r=[],n=0,a=e.length,s=iL;for(let t=0;t<a;t++)switch(s){case iL:switch(e.charAt(t)){case'"':n=t+1,s=iP;break;case this.delimiter:if(n=t+1," "===this.delimiter&&this.delimWhitespace)break;r.push(""),s=iL;break;default:s=iM,n=t}break;case iM:e.charAt(t)===this.delimiter&&(r.push(e.substring(n,t)),s=iL,n=t+1);break;case iP:'"'===e.charAt(t)&&(s=iz);break;case iz:switch(e.charAt(t)){case this.delimiter:r.push(e.substring(n,t-1)),s=iL,n=t+1;break;case'"':s=iP;break;default:s=iB}break;case iB:'"'===e.charAt(t)&&(s=iP)}if(s===iz?r.push(e.substring(n,a-1)):r.push(e.substring(n)),t&&r.length!==this.fullColumnNames.length)throw Error(`Invalid row in csv file. Should have ${this.fullColumnNames.length} elements in a row, but got ${r}`);return r}}class iV extends id{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 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=!1!==e.includeSpectrogram,this.includeWaveform=!0===e.includeWaveform,!this.includeSpectrogram&&!this.includeWaveform)throw Error("Both includeSpectrogram and includeWaveform are false. At least one type of data should be returned.")}summary(){return"microphone"}static async create(e={}){if(!(0,R._K2)().get("IS_BROWSER"))throw Error("microphone API is only supported in browser environment.");let t=new iV(e);return await t.start(),t}async start(){try{this.stream=await navigator.mediaDevices.getUserMedia({audio:null==this.audioTrackConstraints||this.audioTrackConstraints,video:!1})}catch(e){throw Error(`Error thrown while initializing video stream
197: ${e.message}`)}if(!this.stream)throw Error("Could not obtain audio from microphone.");let e=window.AudioContext||window.webkitAudioContext;if(this.audioContext=new e,this.sampleRateHz){if(this.audioContext.sampleRate!==this.sampleRateHz)throw Error(`Mismatch in sampling rate: Expected: ${this.sampleRateHz}; Actual: ${this.audioContext.sampleRate}`)}else this.sampleRateHz=this.audioContext.sampleRate;let t=this.audioContext.createMediaStreamSource(this.stream);this.analyser=this.audioContext.createAnalyser(),this.analyser.fftSize=2*this.fftSize,this.analyser.smoothingTimeConstant=this.smoothingTimeConstant,t.connect(this.analyser),this.freqData=new Float32Array(this.fftSize),this.timeData=new Float32Array(this.fftSize)}async next(){let e,t;if(this.isClosed)return{value:null,done:!0};let r=await this.getAudioData();if(this.includeSpectrogram){let t=this.flattenQueue(r.freqDataQueue);e=this.getTensorFromAudioDataArray(t,[this.numFrames,this.columnTruncateLength,1])}if(this.includeWaveform){let e=this.flattenQueue(r.timeDataQueue);t=this.getTensorFromAudioDataArray(e,[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=[],r=0;return new Promise(n=>{let a=setInterval(()=>{this.includeSpectrogram&&(this.analyser.getFloatFrequencyData(this.freqData),this.freqData[0]===-1/0&&n({freqDataQueue:e,timeDataQueue:t}),e.push(this.freqData.slice(0,this.columnTruncateLength))),this.includeWaveform&&(this.analyser.getFloatTimeDomainData(this.timeData),t.push(this.timeData.slice())),++r===this.numFrames&&(clearInterval(a),n({freqDataQueue:e,timeDataQueue:t}))},this.fftSize/this.sampleRateHz*1e3)})}stop(){!this.isClosed&&(this.isClosed=!0,this.analyser.disconnect(),this.audioContext.close(),null!=this.stream&&this.stream.getTracks().length>0&&this.stream.getTracks()[0].stop())}toArray(){throw Error("Can not convert infinite audio stream to array.")}getSampleRate(){return this.sampleRateHz}flattenQueue(e){let t=e[0].length,r=new Float32Array(e.length*t);return e.forEach((e,n)=>r.set(e,n*t)),r}getTensorFromAudioDataArray(e,t){let r=new Float32Array(R.ZSL.sizeFromShape(t));return r.set(e,r.length-e.length),(0,R.OEK)(r,t)}}class iG extends id{constructor(e,t){if(super(),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=(0,R.tGX)([0],"int32"),this.webcamConfig.centerCrop){let e=this.webcamConfig.resizeWidth/this.webcamVideoElement.width,t=this.webcamConfig.resizeHeight/this.webcamVideoElement.height,r=(1-e)/2,n=(1-t)/2;this.cropBox=(0,R.KtR)([n,r,t+n,r+e],[1,4])}else this.cropBox=(0,R.KtR)([0,0,1,1],[1,4])}summary(){return"webcam"}static async create(e,t={}){if(!(0,R._K2)().get("IS_BROWSER"))throw Error("tf.data.webcam is only supported in browser environment.");if(!e){if(e=document.createElement("video"),!t.resizeWidth||!t.resizeHeight)throw 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 r=new iG(e,t);return await r.start(),r}async start(){this.webcamConfig.facingMode&&R.ZSL.assert("user"===this.webcamConfig.facingMode||"environment"===this.webcamConfig.facingMode,()=>`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 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(){let e;if(this.isClosed)return{value:null,done:!0};try{e=R.TaL.fromPixels(this.webcamVideoElement)}
197catch(e){throw Error(`Error thrown converting video to pixels: ${JSON.stringify(e)}`)}if(!this.resize)return{value:e,done:!1};try{return{value:this.cropAndResizeFrame(e),done:!1}}catch(e){throw Error(`Error thrown cropping the video: ${e.message}`)}finally{e.dispose()}}needToResize(){return!!this.webcamConfig.resizeWidth&&!!this.webcamConfig.resizeHeight&&(this.webcamVideoElement.width!==this.webcamConfig.resizeWidth||this.webcamVideoElement.height!==this.webcamConfig.resizeHeight)}cropAndResizeFrame(e){return(0,R.DZQ)(()=>{let t,r=(0,R.UG6)((0,R.wgE)(e,"float32"),0),n=(t=R.Slp.cropAndResize(r,this.cropBox,this.cropBoxInd,this.cropSize,"bilinear")).shape;return(0,R.tQQ)(t,n.slice(1))})}async capture(){return(await this.next()).value}stop(){this.stream.getTracks().forEach(e=>e.stop());try{this.webcamVideoElement.srcObject=null}catch(e){console.log(e),this.webcamVideoElement.src=null}this.isClosed=!0}toArray(){throw Error("Can not convert infinite video stream to array.")}}class iU{}class iZ extends id{split(e){return new ij(this,e)}}class ij extends iZ{constructor(e,t){super(),this.upstream=e,this.impl=new iH(e,t)}summary(){return this.impl.summary()}async next(){return this.impl.next()}}class iH extends iN{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&&(this.outputQueue.push(this.carryover),this.carryover="",!0);let t=e.value.split(this.separator);for(let e of(t[0]=this.carryover+t[0],t.slice(0,-1)))this.outputQueue.push(e);return this.carryover=t[t.length-1],!0}}var iK=r(44134).hp;class iY extends id{decodeUTF8(){return new iQ(this)}}class iQ extends iZ{constructor(e){super(),this.upstream=e,this.impl=new iq(e)}summary(){return this.impl.summary()}async next(){return this.impl.next()}}class iq extends iN{constructor(e){if(super(),this.upstream=e,(0,R._K2)().get("IS_BROWSER"))this.decoder=new TextDecoder("utf-8");else{let{StringDecoder:e}=r(4530);this.decoder=new e("utf8")}}summary(){return`${this.upstream.summary()} -> Utf8`}async pump(){let e,t,r=await this.upstream.next();return!r.done&&(e=r.value,t=(0,R._K2)().get("IS_BROWSER")?this.decoder.decode(e,{stream:!0}):this.decoder.write(iK.from(e.buffer)),this.outputQueue.push(t),!0)}}class iX extends iY{constructor(e,t={}){super(),this.file=e,this.options=t,R.ZSL.assert(e instanceof Uint8Array||!!(0,R._K2)().get("IS_BROWSER")&&(e instanceof File||e instanceof Blob),()=>"FileChunkIterator only supports File, Blob and Uint8Array right now."),this.offset=t.offset||0,this.chunkSize=t.chunkSize||1048576}summary(){return`FileChunks ${this.file}`}async next(){if(this.offset>=(this.file instanceof Uint8Array?this.file.byteLength:this.file.size))return{value:null,done:!0};let e=new Promise((e,t)=>{let r=this.offset+this.chunkSize;if(this.file instanceof Uint8Array)e(new Uint8Array(this.file.slice(this.offset,r)));else{let n=new FileReader;n.onload=r=>{let a=n.result;if(a instanceof ArrayBuffer&&(a=new Uint8Array(a)),!(a instanceof Uint8Array))return t(TypeError("FileReader returned unknown type."));e(a)},n.onabort=e=>t(Error("Aborted")),n.onerror=e=>t(Error(e.type));let a=this.file.slice(this.offset,r);n.readAsArrayBuffer(a)}this.offset=r});return{value:await e,done:!1}}}async function iJ(e,t={},r){let n,a;"string"==typeof e?n=e:(n=e.url,a=i0(e));let s=await (r||R.ZSL.fetch)(n,a);if(s.ok)return new iX(new Uint8Array(await s.arrayBuffer()),t);throw Error(s.statusText)}let i0=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 i1(e){return"string"==typeof e&&"file://"===e.slice(0,7)}class i2 extends iU{constructor(e,t={}){super(),this.input=e,this.options=t}async iterator(){if(i1(this.input)&&(0,R._K2)().get("IS_NODE")){let e=r(8108);this.input=e.readFileSync(this.input.slice(7))}return new iX(this.input,this.options)}}class i3 extends iU{constructor(e,t={}){super(),this.url=e,this.fileOptions=t}async iterator(){return i1(this.url)?new i2(this.url,this.fileOptions).iterator():iJ(this.url,this.fileOptions)}}function i4(e,t={}){return new iW(new i3(e),t)}function i5(e){let t=new im(e);return iF(async()=>t)}
197function i6(e){return iF(async()=>{let t=await e();return new im(()=>t.next())})}async function i7(e,t){return iG.create(e,t)}async function i9(e){return iV.create(e)}let i8="4.22.0";var oe=r(49575);let ot=R.kpo.whereImpl;class or extends R.uI_{nextDataId(){return or.nextDataId++}constructor(){super(),this.blockSize=48,this.firstUse=!0,this.data=new R.GJx(this,(0,R.Hi9)())}write(e,t,r){this.firstUse&&(this.firstUse=!1,(0,R._K2)().get("IS_NODE")&&R.C0T.warn("\n============================\nHi, looks like you are running TensorFlow.js in Node.js. To speed things up dramatically, install our node backend, visit https://github.com/tensorflow/tfjs-node for more details. \n============================"));let n={id:this.nextDataId()};return this.data.set(n,{values:e,dtype:r,refCount:1}),n}makeTensorInfo(e,t,r){let n;if("string"===t&&null!=r&&r.length>0&&R.ZSL.isString(r[0])){let a=r.map(e=>R.ZSL.encodeString(e));n=this.write(a,e,t)}else n=this.write(r,e,t);return{dataId:n,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,r,n,a){this.data.set(e,{values:t,dtype:n,refCount:a})}numDataIds(){return this.data.numDataIds()}async read(e){return this.readSync(e)}readSync(e){let{dtype:t,complexTensorInfos:r}=this.data.get(e);if("complex64"===t){let e=this.readSync(r.real.dataId),t=this.readSync(r.imag.dataId);return R.C0T.mergeRealAndImagArrays(e,t)}return R.ZSL.convertBackendValuesAndArrayBuffer(this.data.get(e).values,t)}bufferSync(e){let t=this.readSync(e.dataId);if("string"===e.dtype)try{let r=t.map(e=>R.ZSL.decodeString(e));return(0,R.ra8)(e.shape,e.dtype,r)}catch(e){throw Error("Failed to decode encoded string bytes into utf-8")}return(0,R.ra8)(e.shape,e.dtype,t)}makeOutput(e,t,r){return(0,R.Hi9)().makeTensorFromTensorInfo(this.makeTensorInfo(t,r,e),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:r}=this.data.get(e);null!=r&&(this.disposeData(r.real.dataId,!0),this.disposeData(r.imag.dataId,!0)),this.data.delete(e)}return!0}disposeIntermediateTensorInfo(e){this.disposeData(e.dataId)}async time(e){let t=R.ZSL.now();return e(),{kernelMs:R.ZSL.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){(0,oe.C)([e],"where");let t=this.readSync(e.dataId);return ot(e.shape,t)}dispose(){}floatPrecision(){return 32}epsilon(){return super.epsilon()}}or.nextDataId=0;var on=r(61293);let oa="4.22.0";(0,R.gJX)("cpu",()=>new or,1);var os=r(87095);let oi=(0,os.v)(R.Pah,e=>e>=0?e:Math.exp(e)-1),oo={kernelName:R.Pah,backendName:"cpu",kernelFunc:oi};var ol=r(88185);function ou(e){let{inputs:t,backend:r,attrs:n}=e,{x:a}=t,{alpha:s}=n;(0,oe.C)([a],"leakyRelu");let i=R.ZSL.sizeFromShape(a.shape),o=r.data.get(a.dataId).values,l=R.ZSL.getTypedArrayFromDType("float32",i);for(let e=0;e<o.length;e++)l[e]=o[e]<0?s*o[e]:o[e];return r.makeTensorInfo(a.shape,"float32",l)}let oh={kernelName:R.X0$,backendName:"cpu",kernelFunc:ou};var op=r(16986);let od=(0,op.Z)((e,t)=>e<0?t*e:e);function oc(e){let{inputs:t,backend:r}=e,{x:n,alpha:a}=t;(0,oe.C)([n,a],"prelu");let s=r.data.get(n.dataId).values,i=r.data.get(a.dataId).values,[o,l]=od(n.shape,a.shape,s,i,"float32");return r.makeTensorInfo(l,"float32",o)}let of={kernelName:R.Ncv,backendName:"cpu",kernelFunc:oc},om=(0,os.v)(R.fUj,e=>Math.max(0,e)),og={kernelName:R.fUj,backendName:"cpu",kernelFunc:om},oy=(0,os.v)(R.P_L,e=>Math.min(Math.max(0,e),6)),ob={kernelName:R.P_L,backendName:"cpu",kernelFunc:oy};var ox=r(18585);function ov(e,t,r,n,a){if("linear"===r)return(0,ol.D)({inputs:{x:t},backend:e});if("relu"===r)return om({inputs:{x:t},backend:e});
197if("elu"===r)return oi({inputs:{x:t},backend:e});if("relu6"===r)return oy({inputs:{x:t},backend:e});if("prelu"===r)return oc({inputs:{x:t,alpha:n},backend:e});else if("leakyrelu"===r)return ou({inputs:{x:t},backend:e,attrs:{alpha:a}});else if("sigmoid"===r)return(0,ox.ry)({inputs:{x:t},backend:e});throw Error(`Activation ${r} has not been implemented for the CPU backend.`)}var ow=r(86562);function oT(e){let{inputs:t,backend:r,attrs:n}=e,{x:a}=t,{shape:s}=n,i=R.ZSL.sizeFromShape(a.shape),o=R.ZSL.inferFromImplicitShape(s,i),l=R.ZSL.sizeFromShape(o);R.ZSL.assert(i===l,()=>`The new shape (${o}) has ${l} elements and the old shape (${a.shape}) has ${i} elements. The new shape and old shape must have the same number of elements.`),r.incRef(a.dataId);let u=r.data.get(a.dataId);if(null!=u.complexTensorInfos){let e=u.complexTensorInfos.real,t=u.complexTensorInfos.imag;e.shape=o,t.shape=o}return{dataId:a.dataId,shape:o,dtype:a.dtype}}let oS={kernelName:R.R23,backendName:"cpu",kernelFunc:oT};function oN(e){let{inputs:t,backend:r,attrs:n}=e,{a,b:s}=t,{transposeA:i,transposeB:o}=n;(0,oe.C)([a,s],"matMul");let l=a.shape.length,u=s.shape.length,h=i?a.shape[l-2]:a.shape[l-1],p=o?s.shape[u-1]:s.shape[u-2],d=i?a.shape[l-1]:a.shape[l-2],c=o?s.shape[u-2]:s.shape[u-1],f=a.shape.slice(0,-2),m=s.shape.slice(0,-2),g=R.ZSL.sizeFromShape(f),y=R.ZSL.sizeFromShape(m),b=R.ZEY.assertAndGetBroadcastShape(a.shape.slice(0,-2),s.shape.slice(0,-2)).concat([d,c]);R.ZSL.assert(h===p,()=>`Error in matMul: inner shapes (${h}) and (${p}) of Tensors with shapes ${a.shape} and ${s.shape} and transposeA=${i} and transposeB=${o} must match.`);let x=oT({inputs:{x:a},backend:r,attrs:{shape:i?[g,h,d]:[g,d,h]}}),v=oT({inputs:{x:s},backend:r,attrs:{shape:o?[y,c,p]:[y,p,c]}}),w=i?x.shape[1]:x.shape[2],T=i?x.shape[2]:x.shape[1],S=o?v.shape[1]:v.shape[2],N=Math.max(g,y),k=r.data.get(x.dataId).values,I=r.data.get(v.dataId).values,C=R.ZSL.computeStrides(x.shape),E=R.ZSL.computeStrides(v.shape),[A,$,F]=i?[C[0],1,C[1]]:[C[0],C[1],1],[_,D,O]=o?[1,E[1],E[0]]:[E[1],1,E[0]],L=T*S,M=(0,R.ra8)([N,T,S],x.dtype),P=M.values,z=r.blockSize;for(let e=0;e<N;e++){let t=e%g,r=e%y;for(let n=0;n<T;n+=z){let a=Math.min(n+z,T);for(let s=0;s<S;s+=z){let i=Math.min(s+z,S);for(let o=0;o<w;o+=z){let l=Math.min(o+z,w);for(let u=n;u<a;u++)for(let n=s;n<i;n++){let a=0;for(let e=o;e<l;e++)a+=k[t*A+u*$+e*F]*I[e*_+n*D+r*O];P[e*L+(u*S+n)]+=a}}}}}return r.disposeIntermediateTensorInfo(x),r.disposeIntermediateTensorInfo(v),r.makeTensorInfo(b,M.dtype,M.values)}let ok={kernelName:R.jAQ,backendName:"cpu",kernelFunc:oN},oI={kernelName:R.Dr,backendName:"cpu",kernelFunc:function(e){let t,r,n,{inputs:a,backend:s,attrs:i}=e,{a:o,b:l,bias:u,preluActivationWeights:h}=a,{transposeA:p,transposeB:d,activation:c,leakyreluAlpha:f}=i,m=[];for(let e of(t=oN({inputs:{a:o,b:l},attrs:{transposeA:p,transposeB:d},backend:s}),u&&(r=(0,ow.WQ)({inputs:{a:t,b:u},backend:s}),m.push(t),t=r),c&&(n=ov(s,t,c,h,f),m.push(t),t=n),m))s.disposeIntermediateTensorInfo(e);return t}};var oC=r(16041);let oE=(0,os.v)(R.Vvy,e=>Math.acos(e)),oA={kernelName:R.Vvy,backendName:"cpu",kernelFunc:oE},o$=(0,os.v)(R.PH8,e=>Math.acosh(e)),oF={kernelName:R.PH8,backendName:"cpu",kernelFunc:o$},oR={kernelName:R.EkD,backendName:"cpu",kernelFunc:function(e){let{inputs:t,backend:r}=e;(0,oe.C)(t,"addN");let n=t.map(e=>r.data.get(e.dataId).values),a=(0,R.ra8)(t[0].shape,t[0].dtype),s=a.values;for(let e=0;e<t.length;e++){let t=n[e];for(let e=0;e<s.length;e++)s[e]+=t[e]}return r.makeTensorInfo(a.shape,a.dtype,a.values)}};var o_=r(31910);let oD={kernelName:R.u8Z,backendName:"cpu",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{x:a}=t,{axis:s,keepDims:i}=n;(0,oe.C)(a,"all");let o=R.ZSL.parseAxisParam(s,a.shape),l=o,u=R.C0T.getAxesPermutation(l,a.shape.length),h=a;null!=u&&(h=(0,o_.m)({inputs:{x:a},backend:r,attrs:{perm:u}}),l=R.C0T.getInnerMostAxes(l.length,a.shape.length)),R.C0T.assertAxesAreInnerMostDims("all",l,h.shape.length);let[p,d]=R.C0T.computeOutAndReduceShapes(h.shape,l),c=R.ZSL.sizeFromShape(d),f=R.ZSL.makeZerosTypedArray(R.ZSL.sizeFromShape(p),h.dtype),m=r.data.get(h.dataId).values;for(let e=0;e<f.length;++e){let t=e*c,r=m[t];for(let e=0;e<c;++e){let n=m[t+e];r=r&&n}f[e]=r}null!=u&&r.disposeIntermediateTensorInfo(h);let g=r.makeTensorInfo(p,h.dtype,f);if(i){let e=oT({inputs:{x:g},backend:r,attrs:{shape:R.C0T.expandShapeToKeepDim(p,o)}});return r.disposeIntermediateTensorInfo(g),e}return g}},oO={kernelName:R.FSt,backendName:"cpu",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{x:a}=t,{axis:s,keepDims:i}=n;(0,oe.C)(a,"any");let o=R.ZSL.parseAxisParam(s,a.shape),l=o,u=R.C0T.getAxesPermutation(l,a.shape.length),h=a;
197null!=u&&(h=(0,o_.m)({inputs:{x:a},backend:r,attrs:{perm:u}}),l=R.C0T.getInnerMostAxes(l.length,a.shape.length)),R.C0T.assertAxesAreInnerMostDims("any",l,h.shape.length);let[p,d]=R.C0T.computeOutAndReduceShapes(h.shape,l),c=R.ZSL.sizeFromShape(d),f=R.ZSL.makeZerosTypedArray(R.ZSL.sizeFromShape(p),h.dtype),m=r.data.get(h.dataId).values;for(let e=0;e<f.length;++e){let t=e*c,r=m[t];for(let e=0;e<c;++e){let n=m[t+e];r=r||n}f[e]=r}null!=u&&r.disposeIntermediateTensorInfo(h);let g=r.makeTensorInfo(p,h.dtype,f);if(i){let e=oT({inputs:{x:g},backend:r,attrs:{shape:R.C0T.expandShapeToKeepDim(p,o)}});return r.disposeIntermediateTensorInfo(g),e}return g}},oL={kernelName:R.Jp_,backendName:"cpu",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{x:a}=t,{axis:s}=n;(0,oe.C)(a,"argMax");let i=R.ZSL.parseAxisParam(s,a.shape),o=R.C0T.getAxesPermutation(i,a.shape.length),l=a,u=[];null!=o&&(u.push(l=(0,o_.m)({inputs:{x:a},backend:r,attrs:{perm:o}})),i=R.C0T.getInnerMostAxes(i.length,l.shape.length)),i=[i[0]],R.C0T.assertAxesAreInnerMostDims("argMax",i,l.shape.length);let[h,p]=R.C0T.computeOutAndReduceShapes(l.shape,i),d=R.ZSL.sizeFromShape(h),c=R.ZSL.makeZerosTypedArray(d,"int32"),f=R.ZSL.sizeFromShape(p),m=r.data.get(l.dataId).values;for(let e=0;e<c.length;++e){let t=e*f,r=m[t],n=0;for(let e=0;e<f;++e){let a=m[t+e];a>r&&(r=a,n=e)}c[e]=n}return u.forEach(e=>r.disposeIntermediateTensorInfo(e)),r.makeTensorInfo(h,"int32",c)}},oM={kernelName:R.p_m,backendName:"cpu",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{x:a}=t,{axis:s}=n;(0,oe.C)(a,"argMin");let i=R.ZSL.parseAxisParam(s,a.shape),o=R.C0T.getAxesPermutation(i,a.shape.length),l=a,u=[];null!=o&&(u.push(l=(0,o_.m)({inputs:{x:a},backend:r,attrs:{perm:o}})),i=R.C0T.getInnerMostAxes(i.length,l.shape.length)),i=[i[0]],R.C0T.assertAxesAreInnerMostDims("argMin",i,l.shape.length);let[h,p]=R.C0T.computeOutAndReduceShapes(l.shape,i),d=R.ZSL.sizeFromShape(h),c=R.ZSL.makeZerosTypedArray(d,"int32"),f=R.ZSL.sizeFromShape(p),m=r.data.get(l.dataId).values;for(let e=0;e<c.length;++e){let t=e*f,r=m[t],n=0;for(let e=0;e<f;++e){let a=m[t+e];a<r&&(r=a,n=e)}c[e]=n}return u.forEach(e=>r.disposeIntermediateTensorInfo(e)),r.makeTensorInfo(h,"int32",c)}},oP=(0,os.v)(R.QKF,e=>Math.asin(e)),oz={kernelName:R.QKF,backendName:"cpu",kernelFunc:oP},oB=(0,os.v)(R.epO,e=>Math.asinh(e)),oW={kernelName:R.epO,backendName:"cpu",kernelFunc:oB},oV=(0,os.v)(R.TyE,e=>Math.atan(e)),oG={kernelName:R.TyE,backendName:"cpu",kernelFunc:oV};var oU=r(75017);let oZ=(0,op.Z)((e,t)=>Math.atan2(e,t)),oj=(0,oU.j)(R.lxb,oZ),oH={kernelName:R.lxb,backendName:"cpu",kernelFunc:oj},oK=(0,os.v)(R.zP9,e=>Math.atanh(e)),oY={kernelName:R.zP9,backendName:"cpu",kernelFunc:oK};function oQ(e,t,r,n,a,s){let i=a.strideHeight,o=a.strideWidth,l=a.dilationHeight,u=a.dilationWidth,h=a.effectiveFilterHeight,p=a.effectiveFilterWidth,d=a.padInfo.top,c=a.padInfo.left,f="max"===s?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,m=(0,R.ra8)(a.outShape,r),g=m.values,y=a.outShape[1]*a.outShape[2]*a.outShape[3],b=a.outShape[2]*a.outShape[3],x=a.outShape[3];for(let t=0;t<a.batchSize;++t){let r=t*y,m=t*n[0];for(let t=0;t<a.inChannels;++t)for(let y=0;y<a.outHeight;++y){let v=y*i-d,w=Math.max(0,v),T=Math.min(a.inHeight,h+v),S=r+y*b;for(let r=0;r<a.outWidth;++r){let i=r*o-c,h=Math.max(0,i),d=Math.min(a.inWidth,p+i),y=f,b=0,v=0;for(let r=w;r<T;r+=l){let a=m+r*n[1];for(let r=h;r<d;r+=u){let i=e[a+r*n[2]+t];"max"===s&&i>y?y=i:"avg"===s&&(b+=i,v++)}if(isNaN(y))break}g[S+r*x+t]="avg"===s?b/v:y}}}return m}function oq(e,t,r,n,a=!1,s=!1){let i=(0,R.ra8)(n.outShape,"int32"),o=n.strideHeight,l=n.strideWidth,u=n.dilationHeight,h=n.dilationWidth,p=n.effectiveFilterHeight,d=n.effectiveFilterWidth,c=n.padInfo.top,f=n.padInfo.left,m=(0,R.ra8)(t,r,e);for(let e=0;e<n.batchSize;++e)for(let t=0;t<n.inChannels;++t)for(let r=0;r<n.outHeight;++r){let g=r*o-c,y=g;for(;y<0;)y+=u;let b=Math.min(n.inHeight,p+g);for(let o=0;o<n.outWidth;++o){let p=o*l-f,c=p;for(;c<0;)c+=h;let x=Math.min(n.inWidth,d+p),v=Number.NEGATIVE_INFINITY,w=-1;for(let r=y;r<b;r+=u){let i=r-g;for(let o=c;o<x;o+=h){let l=o-p,u=m.get(e,r,o,t);u>v&&(v=u,w=a?s?((e*n.inHeight+r)*n.inWidth+o)*n.inChannels+t:(r*n.inWidth+o)*n.inChannels+t:i*d+l)}}i.set(w,e,r,o,t)}}return i}function oX(e,t,r,n,a,s){let i=a.strideDepth,o=a.strideHeight,l=a.strideWidth,u=a.dilationDepth,h=a.dilationHeight,p=a.dilationWidth,d=a.effectiveFilterDepth,c=a.effectiveFilterHeight,f=a.effectiveFilterWidth,m=a.padInfo.front,g=a.padInfo.top,y=a.padInfo.left,b="max"===s?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,x=(0,R.ra8)(a.outShape,r),v=x.values,w=a.outShape[1]*a.outShape[2]*a.outShape[3]*a.outShape[4],T=a.outShape[2]*a.outShape[3]*a.outShape[4],S=a.outShape[3]*a.outShape[4],N=a.outShape[4];for(let t=0;t<a.batchSize;++t){let r=t*w,x=t*n[0];for(let t=0;t<a.inChannels;++t)for(let w=0;w<a.outDepth;++w){let k=w*i-m,I=k;for(;I<0;)I+=u;let C=Math.min(a.inDepth,d+k),E=r+w*T;for(let r=0;r<a.outHeight;++r){let i=r*o-g,d=i;for(;d<0;)d+=h;let m=Math.min(a.inHeight,c+i),w=E+r*S;for(let r=0;r<a.outWidth;++r){let i=r*l-y,o=i;for(;o<0;
197)o+=p;let c=Math.min(a.inWidth,f+i),g=w+r*N,T=b,S=0,k=0;for(let r=I;r<C;r+=u){let a=x+r*n[1];for(let r=d;r<m;r+=h){let i=a+r*n[2];for(let r=o;r<c;r+=p){let a=e[i+r*n[3]+t];if("max"===s&&a>T?T=a:"avg"===s&&(S+=a,k++),isNaN(T))break}if(isNaN(T))break}if(isNaN(T))break}v[g+t]="avg"===s?S/Math.max(k,1):T}}}}return x}let oJ={kernelName:R.ho8,backendName:"cpu",kernelFunc:function(e){let t,{inputs:r,backend:n,attrs:a}=e,{x:s}=r;(0,oe.C)(s,"avgPool");let{filterSize:i,strides:o,pad:l,dimRoundingMode:u}=a;R.ZSL.assert(R.C0T.eitherStridesOrDilationsAreOne(o,1),()=>`Error in avgPool: Either strides or dilations must be 1. Got strides ${o} and dilations '1'`);let h=R.C0T.computePool2DInfo(s.shape,i,o,1,l,u);if(1===h.filterWidth&&1===h.filterHeight&&R.ZSL.arraysEqual(h.inShape,h.outShape))t=(0,ol.D)({inputs:{x:s},backend:n});else{let e=n.data.get(s.dataId).values,r=R.ZSL.computeStrides(s.shape),a=oQ(e,s.shape,s.dtype,r,h,"avg");t=n.makeTensorInfo(h.outShape,s.dtype,a.values)}return t}},o0={kernelName:R.cS,backendName:"cpu",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{x:a}=t,{filterSize:s,strides:i,pad:o,dimRoundingMode:l,dataFormat:u}=n;(0,oe.C)(a,"avgPool3d");let h=R.C0T.computePool3DInfo(a.shape,s,i,1,o,l,u),p=oX(r.data.get(a.dataId).values,a.shape,a.dtype,R.ZSL.computeStrides(a.shape),h,"avg");return r.makeTensorInfo(p.shape,"float32",p.values)}},o1={kernelName:R.wwC,backendName:"cpu",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{dy:a,input:s}=t,{filterSize:i,strides:o,pad:l,dimRoundingMode:u}=n;(0,oe.C)([a,s],"avgPool3DGrad");let h=R.C0T.computePool3DInfo(s.shape,i,o,1,l,u),p=h.strideDepth,d=h.strideHeight,c=h.strideWidth,f=h.filterDepth,m=h.filterHeight,g=h.filterWidth,y=h.dilationDepth,b=h.dilationHeight,x=h.dilationWidth,v=h.effectiveFilterDepth,w=h.effectiveFilterHeight,T=h.effectiveFilterWidth,S=v-1-h.padInfo.front,N=T-1-h.padInfo.left,k=w-1-h.padInfo.top,I=(0,R.ra8)(s.shape,"float32"),C=1/(f*m*g),E=r.bufferSync(a);for(let e=0;e<h.batchSize;++e)for(let t=0;t<h.inChannels;++t)for(let r=0;r<h.inDepth;++r)for(let n=0;n<h.inHeight;++n)for(let a=0;a<h.inWidth;++a){let s=r-S,i=n-k,o=a-N,l=0;for(let r=0;r<v;r+=y){let n=(s+r)/p;if(!(n<0)&&!(n>=h.outDepth)&&Math.floor(n)===n)for(let r=0;r<w;r+=b){let a=(i+r)/d;if(!(a<0)&&!(a>=h.outHeight)&&Math.floor(a)===a)for(let r=0;r<T;r+=x){let s=(o+r)/c;s<0||s>=h.outWidth||Math.floor(s)!==s||(l+=E.get(e,n,a,s,t))}}}I.set(l*C,e,r,n,a,t)}return r.makeTensorInfo(I.shape,I.dtype,I.values)}},o2={kernelName:R.VCH,backendName:"cpu",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{dy:a,input:s}=t;(0,oe.C)([a,s],"avgPoolGrad");let{filterSize:i,strides:o,pad:l}=n,u=R.C0T.computePool2DInfo(s.shape,i,o,1,l),h=u.strideHeight,p=u.strideWidth,d=u.filterHeight,c=u.filterWidth,f=u.dilationHeight,m=u.dilationWidth,g=u.effectiveFilterHeight,y=u.effectiveFilterWidth,b=y-1-u.padInfo.left,x=g-1-u.padInfo.top,v=(0,R.ra8)(s.shape,"float32"),w=1/(d*c),T=r.data.get(a.dataId).values,S=(0,R.ra8)(a.shape,"float32",T);for(let e=0;e<u.batchSize;++e)for(let t=0;t<u.inChannels;++t)for(let r=0;r<u.inHeight;++r)for(let n=0;n<u.inWidth;++n){let a=r-x,s=n-b,i=0;for(let r=0;r<g;r+=f){let n=(a+r)/h;if(!(n<0)&&!(n>=u.outHeight)&&Math.floor(n)===n)for(let r=0;r<y;r+=m){let a=(s+r)/p;a<0||a>=u.outWidth||Math.floor(a)!==a||(i+=S.get(e,n,a,t))}}v.set(i*w,e,r,n,t)}return r.makeTensorInfo(v.shape,v.dtype,v.values)}},o3={kernelName:R.i5R,backendName:"cpu",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{x:a,scale:s,offset:i,mean:o,variance:l}=t;R.ZSL.assert(o.shape.length===l.shape.length,()=>"Batch normalization gradient requires mean and variance to have equal ranks."),R.ZSL.assert(null==i||o.shape.length===i.shape.length,()=>"Batch normalization gradient requires mean and offset to have equal ranks."),R.ZSL.assert(null==s||o.shape.length===s.shape.length,()=>"Batch normalization gradient requires mean and scale to have equal ranks."),(0,oe.C)([a,o,l,s,i],"batchNorm");let{varianceEpsilon:u}=n;null==u&&(u=.001);let h=r.data.get(a.dataId).values,p=r.data.get(o.dataId).values,d=r.data.get(l.dataId).values,c=s?r.data.get(s.dataId).values:new Float32Array([1]),f=i?r.data.get(i.dataId).values:new Float32Array([0]),m=new Float32Array(h.length),g=f.length,y=c.length,b=d.length,x=p.length,v=0,w=0,T=0,S=0;for(let e=0;e<h.length;++e)m[e]=f[v++]+(h[e]-p[w++])*c[T++]/Math.sqrt(d[S++]+u),v>=g&&(v=0),w>=x&&(w=0),T>=y&&(T=0),S>=b&&(S=0);return r.makeTensorInfo(a.shape,a.dtype,m)}};var o4=r(33699);let o5={kernelName:R.Ik2,backendName:"cpu",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{x:a}
197=t,{blockShape:s,crops:i}=n;(0,oe.C)([a],"batchToSpaceND");let o=s.reduce((e,t)=>e*t),l=R.C0T.getReshaped(a.shape,s,o),u=R.C0T.getPermuted(l.length,s.length),h=R.C0T.getReshapedPermuted(a.shape,s,o),p=R.C0T.getSliceBeginCoords(i,s.length),d=R.C0T.getSliceSize(h,i,s.length),c=oT({inputs:{x:a},backend:r,attrs:{shape:l}}),f=(0,o_.m)({inputs:{x:c},backend:r,attrs:{perm:u}}),m=oT({inputs:{x:f},backend:r,attrs:{shape:h}}),g=(0,o4.di)({inputs:{x:m},backend:r,attrs:{begin:p,size:d}});return r.disposeIntermediateTensorInfo(c),r.disposeIntermediateTensorInfo(f),r.disposeIntermediateTensorInfo(m),g}};var o6=r(6322);let o7={kernelName:R.N4F,backendName:"cpu",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{x:a,weights:s}=t,{size:i}=n,o=r.data.get(a.dataId).values,l=r.data.get(s.dataId).values,u=(0,o6.X)(o,l,s.dtype,s.shape,i);return r.makeTensorInfo([i],s.dtype,u)}};var o9=r(35003);let o8={kernelName:R.vj7,backendName:"cpu",kernelFunc:function(e){let{inputs:t,backend:r}=e,{s0:n,s1:a}=t,s=r.data.get(n.dataId).values,i=r.data.get(a.dataId).values,o=R.C0T.assertAndGetBroadcastShape(Array.from(s),Array.from(i));return r.makeTensorInfo([o.length],"int32",Int32Array.from(o))}};var le=r(57568),lt=r(61438);let lr=(0,os.v)(R.vaV,(e,t)=>e>t.clipValueMax?t.clipValueMax:e<t.clipValueMin?t.clipValueMin:e),ln={kernelName:R.vaV,backendName:"cpu",kernelFunc:lr};var la=r(63405);let ls={kernelName:R.$zE,backendName:"cpu",kernelFunc:e=>{let{x:t}=e.inputs,r=e.backend,n=new Float32Array(R.ZSL.sizeFromShape(t.shape)),a=r.data.get(t.dataId),s=a.complexTensorInfos.real,i=a.complexTensorInfos.imag,o=r.data.get(s.dataId).values,l=r.data.get(i.dataId).values;for(let e=0;e<o.length;e++){let t=o[e],r=l[e];n[e]=Math.hypot(t,r)}return r.makeOutput(n,t.shape,"float32")}};var li=r(84466);function lo(e){let{inputs:t,backend:r}=e,{input:n}=t,a=r.data.get(n.dataId).complexTensorInfos.imag,s=r.data.get(a.dataId).values;return r.makeTensorInfo(a.shape,a.dtype,s)}let ll={kernelName:R.dv8,backendName:"cpu",kernelFunc:lo};var lu=r(97175);function lh(e){let{inputs:t,backend:r,attrs:n}=e,{axis:a}=n,s=R.ZSL.parseAxisParam(a,t[0].shape)[0],i=t.map(e=>e.shape);R.C0T.assertParamsConsistent(i,s);let o=R.C0T.computeOutShape(t.map(e=>e.shape),s);if(0===R.ZSL.sizeFromShape(o))return r.makeTensorInfo(o,t[0].dtype,[]);let l=t.filter(e=>R.ZSL.sizeFromShape(e.shape)>0);if(1===l.length)return(0,ol.D)({inputs:{x:l[0]},backend:r});if("complex64"===l[0].dtype){let e=l.map(e=>(0,lu.x)({inputs:{input:e},backend:r})),t=l.map(e=>lo({inputs:{input:e},backend:r})),n=lh({inputs:e,backend:r,attrs:{axis:s}}),a=lh({inputs:t,backend:r,attrs:{axis:s}}),i=(0,la.f)({inputs:{real:n,imag:a},backend:r});return e.forEach(e=>r.disposeIntermediateTensorInfo(e)),t.forEach(e=>r.disposeIntermediateTensorInfo(e)),r.disposeIntermediateTensorInfo(n),r.disposeIntermediateTensorInfo(a),i}let u=l.map(e=>{let t=R.ZSL.sizeFromShape(e.shape.slice(s));return oT({inputs:{x:e},backend:r,attrs:{shape:[-1,t]}})}),h=u.map(e=>({vals:r.data.get(e.dataId).values,shape:e.shape}));o=R.C0T.computeOutShape(u.map(e=>e.shape),1);let p=1===u[0].shape[0],d=(0,li.h)(h,o,t[0].dtype,p),c=R.C0T.computeOutShape(l.map(e=>e.shape),s),f=r.makeTensorInfo(c,t[0].dtype,d);return u.forEach(e=>r.disposeIntermediateTensorInfo(e)),f}let lp={kernelName:R.$dB,backendName:"cpu",kernelFunc:lh};function ld(e){let{inputs:t,backend:r,attrs:n}=e,{x:a,filter:s}=t,{strides:i,pad:o,dataFormat:l,dilations:u,dimRoundingMode:h}=n;(0,oe.C)([a,s],"conv2d");let p=R.C0T.convertConv2DDataFormat(l),d=R.C0T.computeConv2DInfo(a.shape,s.shape,i,u,o,h,!1,p),c=d.filterHeight,f=d.filterWidth,m=d.dilationHeight,g=d.dilationWidth,y=d.padInfo.left,b=d.padInfo.top,x="channelsLast"===d.dataFormat,v=new R.ylz(d.outShape,a.dtype),w=R.ZSL.computeStrides(a.shape),T=R.ZSL.computeStrides(s.shape),S=w[0],N=x?w[1]:w[2],k=x?w[2]:1,I=x?1:w[1],C=v.strides[0],E=x?v.strides[1]:v.strides[2],A=x?v.strides[2]:1,$=x?1:v.strides[1],F=r.data.get(a.dataId).values,_=r.data.get(s.dataId).values,D=v.values;for(let e=0;e<d.batchSize;++e){let t=e*S,r=e*C;for(let e=0;e<d.outHeight;++e){let n=r+e*E,a=e*d.strideHeight-b;for(let e=0;e<c;++e){let r=a+e*m;if(r<0||r>=d.inHeight)continue;let s=e*T[0],i=t+r*N;for(let e=0;e<d.outWidth;++e){let t=n+e*A,r=e*d.strideWidth-y;for(let e=0;e<f;++e){let n=r+e*g;if(n<0||n>=d.inWidth)continue;let a=s+e*T[1],o=i+n*k,l=a;for(let e=0;e<d.inChannels;++e){let r=F[o+e*I];for(let e=0;e<d.outChannels;++e)D[t+e*$]+=r*_[l+e];l+=d.outChannels}}}}}}return r.makeTensorInfo(v.shape,v.dtype,D)}let lc={kernelName:R.p2J,backendName:"cpu",kernelFunc:ld},lf={kernelName:R.rFm,backendName:"cpu",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{x:a,dy:s}=t,{strides:i,pad:o,dataFormat:l,dimRoundingMode:u,filterShape:h}=n;(0,oe.C)([a,s],"conv2dBackpropFilter");
197let p=R.C0T.convertConv2DDataFormat(l),d=R.C0T.computeConv2DInfo(a.shape,h,i,1,o,u,!1,p),{strideHeight:c,strideWidth:f,filterHeight:m,filterWidth:g}=d,y="channelsLast"===d.dataFormat,b=new R.ylz(d.filterShape,"float32"),x=d.padInfo.left,v=d.padInfo.top,w=r.data.get(a.dataId).values,T=r.data.get(s.dataId).values,S=new R.ylz(a.shape,a.dtype,w),N=new R.ylz(s.shape,s.dtype,T);for(let e=0;e<m;++e){let t=Math.max(0,Math.ceil((v-e)/c)),r=Math.min(d.outHeight,(d.inHeight+v-e)/c);for(let n=0;n<g;++n){let a=Math.max(0,Math.ceil((x-n)/f)),s=Math.min(d.outWidth,(d.inWidth+x-n)/f);for(let i=0;i<d.inChannels;++i)for(let o=0;o<d.outChannels;++o){let l=0;for(let u=0;u<d.batchSize;++u)for(let h=t;h<r;++h){let t=e+h*c-v;for(let e=a;e<s;++e){let r=n+e*f-x;y?l+=S.get(u,t,r,i)*N.get(u,h,e,o):l+=S.get(u,i,t,r)*N.get(u,o,h,e)}}b.set(l,e,n,i,o)}}}return r.makeTensorInfo(b.shape,b.dtype,b.values)}},lm={kernelName:R.jfg,backendName:"cpu",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{dy:a,filter:s}=t,{inputShape:i,strides:o,pad:l,dataFormat:u,dimRoundingMode:h}=n;(0,oe.C)([a,s],"conv2dBackpropInput");let p=R.ZSL.computeStrides(s.shape),d=R.ZSL.computeStrides(a.shape),c=R.C0T.convertConv2DDataFormat(u),f=R.C0T.computeConv2DInfo(i,s.shape,o,1,l,h,!1,c),m=new R.ylz(f.inShape,"float32"),g=m.values,y=r.data.get(a.dataId).values,b=r.data.get(s.dataId).values,[x,v,w]=p,{batchSize:T,filterHeight:S,filterWidth:N,inChannels:k,inHeight:I,inWidth:C,outChannels:E,outHeight:A,outWidth:$,strideHeight:F,strideWidth:_}=f;c=f.dataFormat;let D=S-1-f.padInfo.top,O=N-1-f.padInfo.left,L="channelsLast"===c,M=m.strides[0],P=L?m.strides[1]:m.strides[2],z=L?m.strides[2]:1,B=L?1:m.strides[1],W=d[0],V=L?d[1]:d[2],G=L?d[2]:1,U=L?1:d[1];for(let e=0;e<T;++e)for(let t=0;t<k;++t)for(let r=0;r<I;++r){let n=r-D,a=Math.max(0,Math.ceil(n/F)),s=Math.min(A,(S+n)/F);for(let i=0;i<C;++i){let o=i-O,l=Math.max(0,Math.ceil(o/_)),u=Math.min($,(N+o)/_),h=0;for(let r=a;r<s;++r){let a=r*F-n;for(let n=l;n<u;++n){let s=n*_-o,i=W*e+V*r+G*n,l=x*(S-1-a)+v*(N-1-s)+w*t;for(let e=0;e<E;++e)h+=y[i+U*e]*b[l+e]}}g[M*e+P*r+z*i+B*t]=h}}return r.makeTensorInfo(m.shape,m.dtype,m.values)}},lg={kernelName:R.A1h,backendName:"cpu",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{x:a,filter:s}=t,{strides:i,pad:o,dilations:l}=n;(0,oe.C)([a,s],"conv3d");let u=R.C0T.computeConv3DInfo(a.shape,s.shape,i,l,o),{filterDepth:h,filterHeight:p,filterWidth:d,dilationDepth:c,dilationHeight:f,dilationWidth:m,padInfo:g}=u,y=g.front,b=g.left,x=g.top,v=new R.ylz(u.outShape,a.dtype),w=r.data.get(a.dataId).values,T=r.data.get(s.dataId).values,S=v.values,N=R.ZSL.computeStrides(a.shape),k=R.ZSL.computeStrides(s.shape);for(let e=0;e<u.batchSize;++e){let t=e*N[0],r=e*v.strides[0];for(let e=0;e<u.outDepth;++e){let n=r+e*v.strides[1],a=e*u.strideDepth-y;for(let e=0;e<h;++e){let r=a+e*c;if(r<0||r>=u.inDepth)continue;let s=e*k[0],i=t+r*N[1];for(let e=0;e<u.outHeight;++e){let t=n+e*v.strides[2],r=e*u.strideHeight-x;for(let e=0;e<p;++e){let n=r+e*f;if(n<0||n>=u.inHeight)continue;let a=s+e*k[1],o=i+n*N[2];for(let e=0;e<u.outWidth;++e){let r=t+e*u.outChannels,n=e*u.strideWidth-b;for(let e=0;e<d;++e){let t=n+e*m;if(t<0||t>=u.inWidth)continue;let s=a+e*k[2],i=o+t*u.inChannels,l=s;for(let e=0;e<u.inChannels;++e){let t=w[i+e];for(let e=0;e<u.outChannels;++e)S[r+e]+=t*T[l+e];l+=u.outChannels}}}}}}}}return r.makeTensorInfo(v.shape,v.dtype,v.values)}},ly={kernelName:R.iGz,backendName:"cpu",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{x:a,dy:s}=t,{strides:i,pad:o,filterShape:l}=n;(0,oe.C)([a,s],"conv3dBackpropFilterV2");let u=R.ZSL.computeStrides(a.shape),h=R.ZSL.computeStrides(s.shape),p=R.C0T.computeConv3DInfo(a.shape,l,i,1,o),d=p.strideDepth,c=p.strideHeight,f=p.strideWidth,m=p.filterDepth,g=p.filterHeight,y=p.filterWidth,b=new R.ylz(p.filterShape,"float32"),x=b.values,[v,w,T,S]=b.strides,N=r.data.get(s.dataId).values,[k,I,C,E]=h,A=r.data.get(a.dataId).values,[$,F,_,D]=u,O=p.padInfo.front,L=p.padInfo.left,M=p.padInfo.top;for(let e=0;e<m;++e){let t=Math.max(0,Math.ceil((O-e)/d)),r=Math.min(p.outDepth,(p.inDepth+O-e)/d),n=e*v;for(let a=0;a<g;++a){let s=Math.max(0,Math.ceil((M-a)/c)),i=Math.min(p.outHeight,(p.inHeight+M-a)/c),o=a*w+n;for(let n=0;n<y;++n){let l=Math.max(0,Math.ceil((L-n)/f)),u=Math.min(p.outWidth,(p.inWidth+L-n)/f),h=n*T+o;for(let o=0;o<p.inChannels;++o){let m=o*S+h;for(let h=0;h<p.outChannels;++h){let g=0;for(let m=0;m<p.batchSize;++m){let p=m*$,y=m*k;for(let m=t;m<r;++m){let t=(e+m*d-O)*F+p,r=m*I+y;for(let e=s;e<i;++e){let s=(a+e*c-M)*_+t,i=e*C+r;for(let e=l;e<u;++e){let t=(n+e*f-L)*D+s,r=e*E+i;g+=A[t+o]*N[r+h]}}}}x[m+h]=g}}}}}return r.makeTensorInfo(b.shape,b.dtype,b.values)}},lb={kernelName:R.gC7,backendName:"cpu",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{dy:a,filter:s}=t,{pad:i,strides:o,inputShape:l}=n;(0,oe.C)([a],"conv3dBackpropInputV2");let u=R.ZSL.computeStrides(a.shape),h=R.ZSL.computeStrides(s.shape),p=R.C0T.computeConv3DInfo(l,s.shape,o,1,i),d=new R.ylz(p.inShape,"float32"),c=d.values,[f,m,g,y]=d.strides,b=r.data.get(a.dataId).values,[x,v,w,T]=u,S=r.data.get(s.dataId).values,[N,k,I,C]=h,{batchSize:E,filterDepth:A,filterHeight:$,filterWidth:F,inChannels:_,inDepth:D,inHeight:O,inWidth:L,outChannels:M,outDepth:P,outHeight:z,outWidth:B,strideDepth:W,strideHeight:V,strideWidth:G}=p,U=A-1-p.padInfo.front,Z=$-1-p.padInfo.top,j=F-1-p.padInfo.left;for(let e=0;e<E;++e)for(let t=0;t<_;++t)for(let r=0;r<D;++r){let n=r-U,a=Math.max(0,Math.ceil(n/W)),s=Math.min(P,(A+n)/W);for(let i=0;i<O;++i){let o=i-Z,l=Math.max(0,Math.ceil(o/V)),u=Math.min(z,($+o)/V);for(let h=0;h<L;++h){let p=h-j,d=Math.max(0,Math.ceil(p/G)),E=Math.min(B,(F+p)/G),R=0;for(let r=a;r<s;++r){let a=r*W-n;for(let n=l;n<u;++n){let s=n*V-o;for(let i=d;i<E;++i){let o=i*G-p,l=x*e+v*r+w*n+T*i,u=N*(A-1-a)+k*($-1-s)+I*(F-1-o)+C*t;for(let e=0;e<M;++e)R+=b[l+e]*S[u+e]}}}c[f*e+m*r+g*i+y*h+t]=R}}}return r.makeTensorInfo(d.shape,d.dtype,d.values)}},lx=(0,os.v)(R.Mn0,e=>Math.cos(e)),lv={kernelName:R.Mn0,backendName:"cpu",kernelFunc:lx},lw=(0,os.v)(R.MnK,e=>Math.cosh(e)),lT={kernelName:R.MnK,backendName:"cpu",kernelFunc:lw},lS={kernelName:R.MRQ,backendName:"cpu",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{image:a,boxes:s,boxInd:i}=t,{cropSize:o,method:l,extrapolationValue:u}=n,[h,p,d,c]=a.shape,f=s.shape[0],[m,g]=o,y=(0,R.ra8)([f,m,g,c],"float32"),b=r.data.get(s.dataId).values,x=r.data.get(i.dataId).values,v=r.data.get(a.dataId).values,w=R.ZSL.computeStrides(a.shape),T=R.ZSL.computeStrides(y.shape);for(let e=0;e<f;e++){let t=4*e,r=b[t],n=b[t+1],a=b[t+2],s=b[t+3],i=x[e];if(i>
197=h)continue;let o=m>1?(a-r)*(p-1)/(m-1):0,f=g>1?(s-n)*(d-1)/(g-1):0;for(let t=0;t<m;t++){let h=m>1?r*(p-1)+t*o:.5*(r+a)*(p-1);if(h<0||h>p-1){for(let r=0;r<g;r++)for(let n=0;n<c;n++){let a=n+r*T[2]+t*T[1]+e*T[0];y.values[a]=u}continue}if("bilinear"===l){let r=Math.floor(h),a=Math.ceil(h),o=h-r;for(let l=0;l<g;l++){let h=g>1?n*(d-1)+l*f:.5*(n+s)*(d-1);if(h<0||h>d-1){for(let r=0;r<c;r++){let n=r+l*T[2]+t*T[1]+e*T[0];y.values[n]=u}continue}let p=Math.floor(h),m=Math.ceil(h),b=h-p;for(let n=0;n<c;n++){let s=n+p*w[2]+r*w[1]+i*w[0],u=v[s],h=v[s=n+m*w[2]+r*w[1]+i*w[0]],d=v[s=n+p*w[2]+a*w[1]+i*w[0]],c=v[s=n+m*w[2]+a*w[1]+i*w[0]],f=u+(h-u)*b,g=d+(c-d)*b;s=n+l*T[2]+t*T[1]+e*T[0],y.values[s]=f+(g-f)*o}}}else for(let r=0;r<g;++r){let a=g>1?n*(d-1)+r*f:.5*(n+s)*(d-1);if(a<0||a>d-1){for(let n=0;n<c;n++){let a=n+r*T[2]+t*T[1]+e*T[0];y.values[a]=u}continue}let o=Math.round(a),l=Math.round(h);for(let n=0;n<c;n++){let a=n+o*w[2]+l*w[1]+i*w[0],s=n+r*T[2]+t*T[1]+e*T[0];y.values[s]=v[a]}}}}return r.makeTensorInfo(y.shape,y.dtype,y.values)}},lN={kernelName:R.jj_,backendName:"cpu",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{x:a}=t,{axis:s,exclusive:i,reverse:o}=n;(0,oe.C)(a,"cumprod");let l=R.C0T.getAxesPermutation([s],a.shape.length),u=a;null!=l&&(u=(0,o_.m)({inputs:{x:a},backend:r,attrs:{perm:l}}));let h=R.C0T.getInnerMostAxes(1,a.shape.length)[0];if(h!==u.shape.length-1)throw Error(`backend.cumprod in CPU expects an inner-most axis=${u.shape.length-1} but got axis=${h}`);let p=(0,R.TuY)(u.dtype,"int32"),d=R.ZSL.makeOnesTypedArray(R.ZSL.sizeFromShape(u.shape),p),c=r.data.get(u.dataId).values,f=u.shape[u.shape.length-1],m=o?(e,t)=>e+f-t-1:(e,t)=>e+t;for(let e=0;e<c.length;e+=f)for(let t=0;t<f;t++){let r=m(e,t);if(0===t)d[r]=i?1:c[r];else{let n=m(e,t-1);d[r]=i?c[n]*d[n]:c[r]*d[n]}}let g=r.makeTensorInfo(u.shape,p,d);if(null!=l){let e=R.C0T.getUndoAxesPermutation(l),t=(0,o_.m)({inputs:{x:g},backend:r,attrs:{perm:e}});return r.disposeIntermediateTensorInfo(g),r.disposeIntermediateTensorInfo(u),t}return g}},lk={kernelName:R.nY8,backendName:"cpu",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{x:a}=t,{axis:s,exclusive:i,reverse:o}=n;(0,oe.C)(a,"cumsum");let l=R.C0T.getAxesPermutation([s],a.shape.length),u=a;null!=l&&(u=(0,o_.m)({inputs:{x:a},backend:r,attrs:{perm:l}}));let h=R.C0T.getInnerMostAxes(1,a.shape.length)[0];if(h!==u.shape.length-1)throw Error(`backend.cumsum in CPU expects an inner-most axis=${u.shape.length-1} but got axis=${h}`);let p=(0,R.TuY)(u.dtype,"int32"),d=R.ZSL.makeZerosTypedArray(R.ZSL.sizeFromShape(u.shape),p),c=r.data.get(u.dataId).values,f=u.shape[u.shape.length-1],m=o?(e,t)=>e+f-t-1:(e,t)=>e+t;for(let e=0;e<c.length;e+=f)for(let t=0;t<f;t++){let r=m(e,t);if(0===t)d[r]=i?0:c[r];else{let n=m(e,t-1);d[r]=i?c[n]+d[n]:c[r]+d[n]}}let g=r.makeTensorInfo(u.shape,p,d);if(null!=l){let e=R.C0T.getUndoAxesPermutation(l),t=(0,o_.m)({inputs:{x:g},backend:r,attrs:{perm:e}});return r.disposeIntermediateTensorInfo(g),r.disposeIntermediateTensorInfo(u),t}return g}},lI={kernelName:R.wNW,backendName:"cpu",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{x:a,weights:s}=t,{size:i,binaryOutput:o}=n;if(1===a.shape.length){let e=r.data.get(a.dataId).values,t=r.data.get(s.dataId).values,n=(0,o6.X)(e,t,s.dtype,s.shape,i);return r.makeTensorInfo([i],s.dtype,n)}if(2===a.shape.length){let e=r.bufferSync(a),t=r.bufferSync(s),n=(0,o6.N)(e,t,i,o);return r.makeTensorInfo(n.shape,s.dtype,n.values)}throw Error(`Error in denseBincount: input must be at most rank 2, but got rank${a.shape.length}.`)}},lC={kernelName:R.TMz,backendName:"cpu",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{x:a}=t,{blockSize:s,dataFormat:i}=n;R.ZSL.assert("NHWC"===i,()=>`Only NHWC dataFormat supported on CPU for depthToSpace. Got ${i}`);let o=a.shape[0],l=a.shape[1],u=a.shape[2],h=a.shape[3],p=l*s,d=u*s,c=h/(s*s),f=r.data.get(a.dataId).values,m=new Float32Array(o*p*d*c),g=0;for(let e=0;e<o;++e)for(let t=0;t<p;++t){let r=Math.floor(t/s),n=t%s;for(let t=0;t<d;++t){let a=Math.floor(t/s),i=t%s,o=(n*s+i)*c;for(let t=0;t<c;++t){let n=t+o+h*(a+u*(r+l*e));m[g++]=f[n]}}}return r.makeTensorInfo([o,p,d,c],a.dtype,m)}};function lE(e){let{inputs:t,backend:r,attrs:n}=e,{x:a,filter:s}=t,{strides:i,pad:o,dilations:l,dimRoundingMode:u}=n;(0,oe.C)([a,s],"depthwiseConv2DNative");let h=R.ZSL.computeStrides(a.shape),p=R.ZSL.computeStrides(s.shape),d=l;null==d&&(d=[1,1]),R.ZSL.assert(R.C0T.eitherStridesOrDilationsAreOne(i,d),()=>`Error in depthwiseConv2d: Either strides or dilations must be 1. Got strides ${i} and dilations '${d}'`);let c=R.C0T.computeConv2DInfo(a.shape,s.shape,i,d,o,u,!0),{filterHeight:f,filterWidth:m,dilationHeight:g,dilationWidth:y,padInfo:b}=c,x=b.left,v=b.top,w=c.outChannels/c.inChannels,T=new R.ylz(c.outShape,a.dtype),S=r.data.get(a.dataId).values,N=r.data.get(s.dataId).values,k=T.values;for(let e=0;e<c.batchSize;++e){let t=e*h[0],r=e*T.strides[0];for(let e=0;e<c.outHeight;++e){let n=r+e*T.strides[1],a=e*c.strideHeight-v;for(let e=0;e<f;++e){let r=a+e*g;if(r<0||r>=c.inHeight)continue;let s=e*p[0],i=t+r*h[1];for(let e=0;e<c.outWidth;++e){let t=n+e*T.strides[2],r=e*c.strideWidth-x;for(let e=0;e<m;++e){let n=r+e*y;if(n<0||n>=c.inWidth)continue;let a=s+e*p[1],o=i+n*c.inChannels,l=t,u=a;for(let e=0;e<c.inChannels;++e){let t=S[o+e];for(let e=0;e<w;++e)k[l+e]+=t*N[u+e];l+=w,u+=w}}}}}}return r.makeTensorInfo(T.shape,T.dtype,T.values)}let lA={kernelName:R.tGH,backendName:"cpu",kernelFunc:lE},l$={kernelName:R.X$8,backendName:"cpu",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{x:a,dy:s}=t,{strides:i,dilations:o,pad:l,dimRoundingMode:u,filterShape:h}=n;(0,oe.C)([a,s],"depthwiseConv2dNativeBackpropFilter");let p=R.C0T.computeConv2DInfo(a.shape,h,i,o,l,u,!0),{strideHeight:d,strideWidth:c,filterHeight:f,filterWidth:m}=p,g=new R.ylz(p.filterShape,"float32"),y=p.padInfo.left,b=p.padInfo.top,x=p.outChannels/p.inChannels,v=r.data.get(a.dataId).values,w=new R.ylz(a.shape,a.dtype,v),T=r.data.get(s.dataId).values,S=new R.ylz(s.shape,s.dtype,T);for(let e=0;e<f;++e){let t=Math.max(0,Math.ceil((b-e)/d)),r=Math.min(p.outHeight,(p.inHeight+b-e)/d);for(let n=0;n<m;++n){let a=Math.max(0,Math.ceil((y-n)/c)),s=Math.min(p.outWidth,(p.inWidth+y-n)/c);for(let i=0;i<p.outChannels;++i){let o=Math.trunc(i/x),l=i%x,u=0;for(let l=0;l<p.batchSize;++l)for(let h=t;h<r;++h){let t=e+h*d-b;for(let e=a;
197e<s;++e){let r=n+e*c-y;u+=w.get(l,t,r,o)*S.get(l,h,e,i)}}g.set(u,e,n,o,l)}}}return r.makeTensorInfo(g.shape,g.dtype,g.values)}},lF={kernelName:R.nVu,backendName:"cpu",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{dy:a,filter:s}=t,{strides:i,dilations:o,pad:l,dimRoundingMode:u,inputShape:h}=n;(0,oe.C)([a,s],"depthwiseConv2DNativeBackpropInput");let p=R.ZSL.computeStrides(a.shape),d=R.ZSL.computeStrides(s.shape),c=R.C0T.computeConv2DInfo(h,s.shape,i,o,l,u,!0),f=new R.ylz(c.inShape,"float32"),m=f.values,[g,y,b]=f.strides,x=r.data.get(a.dataId).values,[v,w,T]=p,S=r.data.get(s.dataId).values,[N,k,I]=d,{batchSize:C,filterHeight:E,filterWidth:A,inChannels:$,inHeight:F,inWidth:_,outChannels:D,outHeight:O,outWidth:L,strideHeight:M,strideWidth:P}=c,z=E-1-c.padInfo.top,B=A-1-c.padInfo.left,W=D/$;for(let e=0;e<C;++e)for(let t=0;t<$;++t)for(let r=0;r<F;++r){let n=r-z,a=Math.max(0,Math.ceil(n/M)),s=Math.min(O,(E+n)/M);for(let i=0;i<_;++i){let o=i-B,l=Math.max(0,Math.ceil(o/P)),u=Math.min(L,(A+o)/P),h=0;for(let r=a;r<s;++r){let a=r*M-n;for(let n=l;n<u;++n){let s=n*P-o,i=v*e+w*r+T*n,l=N*(E-1-a)+k*(A-1-s)+I*t;for(let e=0;e<W;++e)h+=x[i+(t*W+e)]*S[l+e]}}m[g*e+y*r+b*i+t]=h}}return r.makeTensorInfo(f.shape,f.dtype,f.values)}},lR={kernelName:R.ORI,backendName:"cpu",kernelFunc:function(e){let{inputs:t,backend:r}=e,{x:n}=t,a=R.ZSL.sizeFromShape(n.shape),s=r.data.get(n.dataId).values,i=(0,R.ra8)([a,a],n.dtype),o=i.values;for(let e=0;e<s.length;e++)o[e*a+e]=s[e];let l=[...n.shape,...n.shape];return r.makeTensorInfo(l,i.dtype,i.values)}},l_={kernelName:R.jxD,backendName:"cpu",kernelFunc:({inputs:e,backend:t,attrs:r})=>{let{x:n,filter:a}=e,{strides:s,pad:i,dilations:o}=r,l=t.data.get(n.dataId).values,u=n.shape.length,h=t.data.get(a.dataId).values,p=a.shape.length,{batchSize:d,inHeight:c,inWidth:f,inChannels:m,outHeight:g,outWidth:y,padInfo:b,strideHeight:x,strideWidth:v,filterHeight:w,filterWidth:T,dilationHeight:S,dilationWidth:N,outShape:k}=R.C0T.computeDilation2DInfo(n.shape,a.shape,s,i,"NHWC",o),I=R.ZSL.sizeFromShape(k),C=k.length,E=R.ZSL.getArrayFromDType(n.dtype,I);for(let e=0;e<d;++e)for(let t=0;t<g;++t){let r=t*x-b.top;for(let s=0;s<y;++s){let i=s*v-b.left;for(let o=0;o<m;++o){let d=Number.MIN_SAFE_INTEGER;for(let t=0;t<w;++t){let s=r+t*S;if(s>=0&&s<c)for(let r=0;r<T;++r){let c=i+r*N;if(c>=0&&c<f){let i=R.ZSL.locToIndex([e,s,c,o],u,R.ZSL.computeStrides(n.shape)),f=R.ZSL.locToIndex([t,r,o],p,R.ZSL.computeStrides(a.shape)),m=l[i]+h[f];m>d&&(d=m)}}}E[R.ZSL.locToIndex([e,t,s,o],C,R.ZSL.computeStrides(k))]=d}}}return{dataId:t.write(R.ZSL.toTypedArray(E,n.dtype),k,n.dtype),shape:k,dtype:n.dtype}}},lD={kernelName:R.pk0,backendName:"cpu",kernelFunc:({inputs:e,backend:t,attrs:r})=>{let{x:n,filter:a,dy:s}=e,{strides:i,pad:o,dilations:l}=r,u=R.ZSL.toNestedArray(n.shape,t.data.get(n.dataId).values),h=R.ZSL.toNestedArray(a.shape,t.data.get(a.dataId).values),{batchSize:p,inHeight:d,inWidth:c,inChannels:f,outHeight:m,outWidth:g,padInfo:y,strideHeight:b,strideWidth:x,filterHeight:v,filterWidth:w,dilationHeight:T,dilationWidth:S,outShape:N}=R.C0T.computeDilation2DInfo(n.shape,a.shape,i,o,"NHWC",l);R.ZSL.assert(s.rank===N.length,()=>`Error in ${R.pk0}, dy must have the same rank as output ${N.length}, but got ${s.rank}`);let k=R.ZSL.toNestedArray(N,t.data.get(s.dataId).values),I=R.ZSL.makeZerosNestedTypedArray(a.shape,a.dtype);for(let e=0;e<p;++e)for(let t=0;t<m;++t){let r=t*b-y.top;for(let n=0;n<g;++n){let a=n*x-y.left;for(let s=0;s<f;++s){let i=Number.MIN_SAFE_INTEGER,o=0,l=0;for(let t=0;t<v;++t){let n=r+t*T;if(n>=0&&n<d)for(let r=0;r<w;++r){let p=a+r*S;if(p>=0&&p<c){let a=u[e][n][p][s]+h[t][r][s];a>i&&(i=a,o=t,l=r)}}}I[o][l][s]+=k[e][t][n][s]}}}return{dataId:t.write(R.ZSL.toTypedArray(I,n.dtype),a.shape,a.dtype),shape:a.shape,dtype:a.dtype}}},lO={kernelName:R.bP9,backendName:"cpu",kernelFunc:({inputs:e,backend:t,attrs:r})=>{let{x:n,filter:a,dy:s}=e,{strides:i,pad:o,dilations:l}=r,u=R.ZSL.toNestedArray(n.shape,t.data.get(n.dataId).values),h=R.ZSL.toNestedArray(a.shape,t.data.get(a.dataId).values),{batchSize:p,inHeight:d,inWidth:c,inChannels:f,outHeight:m,outWidth:g,padInfo:y,strideHeight:b,strideWidth:x,filterHeight:v,filterWidth:w,dilationHeight:T,dilationWidth:S,outShape:N}=R.C0T.computeDilation2DInfo(n.shape,a.shape,i,o,"NHWC",l);R.ZSL.assert(s.rank===N.length,()=>`Error in ${R.bP9}, dy must have the same rank as output ${N.length}, but got ${s.rank}
197`);let k=R.ZSL.toNestedArray(N,t.data.get(s.dataId).values),I=R.ZSL.makeZerosNestedTypedArray(n.shape,n.dtype);for(let e=0;e<p;++e)for(let t=0;t<m;++t){let r=t*b-y.top;for(let n=0;n<g;++n){let a=n*x-y.left;for(let s=0;s<f;++s){let i=Number.MIN_SAFE_INTEGER,o=r<0?0:r,l=a<0?0:a;for(let t=0;t<v;++t){let n=r+t*T;if(n>=0&&n<d)for(let r=0;r<w;++r){let p=a+r*S;if(p>=0&&p<c){let a=u[e][n][p][s]+h[t][r][s];a>i&&(i=a,o=n,l=p)}}}I[e][o][l][s]+=k[e][t][n][s]}}}return{dataId:t.write(R.ZSL.toTypedArray(I,n.dtype),n.shape,n.dtype),shape:n.shape,dtype:n.dtype}}},lL={kernelName:R.XmO,backendName:"cpu",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{image:a}=t,{canvas:s,options:i}=n,{contextOptions:o,imageOptions:l}=i||{},u=(null==l?void 0:l.alpha)||1,h=(null==o?void 0:o.contextType)||"2d";if("2d"!==h)throw Error(`Context type ${o.contextType} is not supported by the CPU backend.`);let p=s.getContext(h,(null==o?void 0:o.contextAttributes)||{});if(null==p)throw Error(`Could not get the context with ${h} type.`);let[d,c]=a.shape.slice(0,2),f=2===a.shape.length?1:a.shape[2],m=r.data.get(a.dataId).values,g="float32"===a.dtype?255:1,y=new Uint8ClampedArray(c*d*4);for(let e=0;e<d*c;++e){let t=[0,0,0,255*u];for(let r=0;r<f;r++){let n=m[e*f+r];if("float32"===a.dtype){if(n<0||n>1)throw Error(`Tensor values for a float32 Tensor must be in the range [0 - 1] but encountered ${n}.`)}else if("int32"===a.dtype&&(n<0||n>255))throw Error(`Tensor values for a int32 Tensor must be in the range [0 - 255] but encountered ${n}.`);1===f?(t[0]=n*g,t[1]=n*g,t[2]=n*g):t[r]=n*g}let r=4*e;y[r+0]=Math.round(t[0]),y[r+1]=Math.round(t[1]),y[r+2]=Math.round(t[2]),y[r+3]=Math.round(t[3])}s.width=c,s.height=d;let b=new ImageData(y,c,d);return p.putImageData(b,0,0),a}};var lM=r(20895),lP=r(22780);function lz(e){let t,{inputs:r,backend:n,attrs:a}=e,{x:s}=r,{axis:i,keepDims:o}=a;(0,oe.C)(s,"sum");let l=(t="bool"===s.dtype?(0,le.wg)({inputs:{x:s},backend:n,attrs:{dtype:"int32"}}):(0,ol.D)({inputs:{x:s},backend:n})).shape.length,u=R.ZSL.parseAxisParam(i,t.shape),h=R.C0T.getAxesPermutation(u,l),p=u,d=t;null!=h&&(d=(0,o_.m)({inputs:{x:t},backend:n,attrs:{perm:h}}),p=R.C0T.getInnerMostAxes(p.length,l)),R.C0T.assertAxesAreInnerMostDims("sum",p,d.shape.length);let[c,f]=R.C0T.computeOutAndReduceShapes(d.shape,p),m=R.C0T.upcastType(d.dtype,"int32"),g=(0,lP.U)(n,c,m),y=R.ZSL.sizeFromShape(f),b=n.data.get(g.dataId).values,x=n.data.get(d.dataId).values;for(let e=0;e<b.length;++e){let t=e*y,r=0;for(let e=0;e<y;++e)r+=x[t+e];b[e]=r}if(o){let e=R.C0T.expandShapeToKeepDim(g.shape,u),t=g;g=oT({inputs:{x:g},backend:n,attrs:{shape:e}}),n.disposeIntermediateTensorInfo(t)}return n.disposeIntermediateTensorInfo(t),null!=h&&n.disposeIntermediateTensorInfo(d),g}let lB={kernelName:R.WuN,backendName:"cpu",kernelFunc:lz},lW={kernelName:R.Qgm,backendName:"cpu",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{equation:a}=n,{allDims:s,summedDims:i,idDims:o}=R.C0T.decodeEinsumEquation(a,t.length);R.C0T.checkEinsumDimSizes(s.length,o,t);let{path:l,steps:u}=R.C0T.getEinsumComputePath(i,o),h=u.length,p=null,d=s.length,c=[];for(let e=0;e<h;++e){for(let n of u[e]){let e,{permutationIndices:a,expandDims:s}=R.C0T.getEinsumPermutation(d,o[n]);R.C0T.isIdentityPermutation(a)?e=t[n]:(e=(0,o_.m)({inputs:{x:t[n]},backend:r,attrs:{perm:a}}),c.push(e));let i=e.shape.slice();for(let e=0;e<s.length;++e)i.splice(s[e],0,1);R.ZSL.arraysEqual(e.shape,i)||(e=oT({inputs:{x:e},backend:r,attrs:{shape:i}}),c.push(e)),null===p?p=e:(p=(0,lM.lw)({inputs:{a:e,b:p},backend:r}),c.push(p))}e<h-1&&(l[e]>=0&&(p=lz({inputs:{x:p},backend:r,attrs:{axis:l[e]-(s.length-d),keepDims:!1}}),c.push(p)),d--)}for(let e of c)e!==p&&r.disposeIntermediateTensorInfo(e);return p}},lV={kernelName:R.rsH,backendName:"cpu",kernelFunc:function(e){let{inputs:t,backend:r}=e,{dy:n,y:a}=t;(0,oe.C)([n,a],"eluGrad");let s=new Float32Array(R.ZSL.sizeFromShape(a.shape)),i=r.data.get(a.dataId).values,o=r.data.get(n.dataId).values;for(let e=0;e<i.length;++e){let t=i[e];t>=0?s[e]=o[e]:s[e]=o[e]*(t+1)}return r.makeTensorInfo(a.shape,"float32",s)}};var lG=r(36565);
197let lU=R.C0T.ERF_P,lZ=R.C0T.ERF_A1,lj=R.C0T.ERF_A2,lH=R.C0T.ERF_A3,lK=R.C0T.ERF_A4,lY=R.C0T.ERF_A5,lQ=(0,os.v)(R._s9,e=>{let t=Math.sign(e),r=Math.abs(e),n=1/(1+lU*r);return t*(1-((((lY*n+lK)*n+lH)*n+lj)*n+lZ)*n*Math.exp(-r*r))}),lq={kernelName:R._s9,backendName:"cpu",kernelFunc:lQ};var lX=r(36958);function lJ(e){let{inputs:t,backend:r,attrs:n}=e,{input:a}=t,{dim:s}=n,i=a.shape.length,o=a.shape.slice(),l=s;return s<0&&(R.ZSL.assert(-(i+1)<=s,()=>`Axis must be in the interval [${-(i+1)}, ${i}]`),l=i+s+1),o.splice(l,0,1),oT({inputs:{x:a},backend:r,attrs:{shape:o}})}let l0={kernelName:R.ybN,backendName:"cpu",kernelFunc:lJ};var l1=r(36452);let l2=(0,op.Z)((e,t)=>e/t),l3=(0,oU.j)(R.sDr,l2),l4={kernelName:R.sDr,backendName:"cpu",kernelFunc:l3};var l5=r(93807);function l6(e,t,r){let n=e.shape,a=n[0],s=n[1],i=r.data.get(e.dataId),o=i.complexTensorInfos.real,l=i.complexTensorInfos.imag,u=[a,s],h=R.ZSL.sizeFromShape(u),p=R.ZSL.getTypedArrayFromDType("float32",h),d=R.ZSL.getTypedArrayFromDType("float32",h);for(let e=0;e<a;e++){let n=(0,o4.di)({inputs:{x:o},backend:r,attrs:{begin:[e,0],size:[1,s]}}),a=(0,o4.di)({inputs:{x:l},backend:r,attrs:{begin:[e,0],size:[1,s]}}),i=(0,la.f)({inputs:{real:n,imag:a},backend:r}),{real:u,imag:h}=function(e,t,r){var n;let a=R.ZSL.sizeFromShape(e.shape),s=r.data.get(e.dataId),i=r.data.get(s.complexTensorInfos.real.dataId).values,o=r.data.get(s.complexTensorInfos.imag.dataId).values;if(((n=a)&n-1)==0){let n=function e(t,r,n,a,s){if(1===n)return{real:t,imag:r};let i=R.C0T.mergeRealAndImagArrays(t,r),o=n/2,l=R.C0T.complexWithEvenIndex(i),u=l.real,h=l.imag,p=[u.length],d=s.makeTensorInfo(p,"float32",u),c=s.makeTensorInfo(p,"float32",h),f=(0,la.f)({inputs:{real:d,imag:c},backend:s}),m=R.C0T.complexWithOddIndex(i),g=m.real,y=m.imag,b=[g.length],x=s.makeTensorInfo(b,"float32",g),v=s.makeTensorInfo(b,"float32",y),w=(0,la.f)({inputs:{real:x,imag:v},backend:s}),T=e(u,h,o,a,s),S=T.real,N=T.imag,k=[S.length],I=s.makeTensorInfo(k,"float32",S),C=s.makeTensorInfo(k,"float32",N),E=(0,la.f)({inputs:{real:I,imag:C},backend:s}),A=e(g,y,o,a,s),$=A.real,F=A.imag,_=[$.length],D=s.makeTensorInfo(_,"float32",$),O=s.makeTensorInfo(_,"float32",F),L=(0,la.f)({inputs:{real:D,imag:O},backend:s}),M=R.C0T.exponents(n,a),P=[M.real.length],z=s.makeTensorInfo(P,"float32",M.real),B=s.makeTensorInfo(P,"float32",M.imag),W=(0,la.f)({inputs:{real:z,imag:B},backend:s}),V=(0,lM.lw)({inputs:{a:W,b:L},backend:s}),G=(0,ow.WQ)({inputs:{a:E,b:V},backend:s}),U=(0,l5.jb)({inputs:{a:E,b:V},backend:s}),Z=(0,lu.x)({inputs:{input:G},backend:s}),j=(0,lu.x)({inputs:{input:U},backend:s}),H=lo({inputs:{input:G},backend:s}
197),K=lo({inputs:{input:U},backend:s}),Y=lh({inputs:[Z,j],backend:s,attrs:{axis:0}}),Q=lh({inputs:[H,K],backend:s,attrs:{axis:0}}),q=s.data.get(Y.dataId).values,X=s.data.get(Q.dataId).values;return s.disposeIntermediateTensorInfo(d),s.disposeIntermediateTensorInfo(c),s.disposeIntermediateTensorInfo(f),s.disposeIntermediateTensorInfo(x),s.disposeIntermediateTensorInfo(v),s.disposeIntermediateTensorInfo(w),s.disposeIntermediateTensorInfo(I),s.disposeIntermediateTensorInfo(C),s.disposeIntermediateTensorInfo(E),s.disposeIntermediateTensorInfo(D),s.disposeIntermediateTensorInfo(O),s.disposeIntermediateTensorInfo(L),s.disposeIntermediateTensorInfo(z),s.disposeIntermediateTensorInfo(B),s.disposeIntermediateTensorInfo(W),s.disposeIntermediateTensorInfo(V),s.disposeIntermediateTensorInfo(G),s.disposeIntermediateTensorInfo(U),s.disposeIntermediateTensorInfo(Z),s.disposeIntermediateTensorInfo(H),s.disposeIntermediateTensorInfo(j),s.disposeIntermediateTensorInfo(K),s.disposeIntermediateTensorInfo(Y),s.disposeIntermediateTensorInfo(Q),{real:q,imag:X}}(i,o,a,t,r),s=[e.shape[0],e.shape[1]];if(t){let e=r.makeTensorInfo(s,"float32",n.real),t=r.makeTensorInfo(s,"float32",n.imag),i=r.makeTensorInfo([],"float32",R.ZSL.createScalarValue(a,"float32")),o=(0,ol.D)({inputs:{x:i},backend:r}),l=l4.kernelFunc({inputs:{a:e,b:i},backend:r}),u=l4.kernelFunc({inputs:{a:t,b:o},backend:r}),h=r.data.get(l.dataId).values,p=r.data.get(u.dataId).values;return r.disposeIntermediateTensorInfo(e),r.disposeIntermediateTensorInfo(t),r.disposeIntermediateTensorInfo(i),r.disposeIntermediateTensorInfo(o),r.disposeIntermediateTensorInfo(l),r.disposeIntermediateTensorInfo(u),{real:h,imag:p}}return n}{let e=function(e,t,r){let n=new Float32Array(2*t);for(let a=0;a<t;a++){let s=0,i=0;for(let n=0;n<t;n++){let o=R.C0T.exponent(a*n,t,r),l=R.C0T.getComplexWithIndex(e,n);s+=l.real*o.real-l.imag*o.imag,i+=l.real*o.imag+l.imag*o.real}r&&(s/=t,i/=t),R.C0T.assignToTypedArray(n,s,i,a)}return n}(R.C0T.mergeRealAndImagArrays(i,o),a,t);return R.C0T.splitRealAndImagArrays(e)}}(i,t,r),c=R.C0T.mergeRealAndImagArrays(u,h);for(let t=0;t<s;t++){let r=R.C0T.getComplexWithIndex(c,t);p[e*s+t]=r.real,d[e*s+t]=r.imag}r.disposeIntermediateTensorInfo(n),r.disposeIntermediateTensorInfo(a),r.disposeIntermediateTensorInfo(i)}let c=r.makeTensorInfo(u,"float32",p),f=r.makeTensorInfo(u,"float32",d),m=(0,la.f)({inputs:{real:c,imag:f},backend:r});return r.disposeIntermediateTensorInfo(c),r.disposeIntermediateTensorInfo(f),m}let l7={kernelName:R.rGP,backendName:"cpu",kernelFunc:function(e){let{inputs:t,backend:r}=e,{input:n}=t,a=R.ZSL.sizeFromShape(n.shape),s=n.shape[n.shape.length-1],i=oT({inputs:{x:n},backend:r,attrs:{shape:[a/s,s]}}),o=l6(i,!1,r),l=oT({inputs:{x:o},backend:r,attrs:{shape:n.shape}});return r.disposeIntermediateTensorInfo(i),r.disposeIntermediateTensorInfo(o),l}};function l9(e){var t,r,n;let{backend:a,attrs:s}=e,{shape:i,value:o,dtype:l}=s,u=l||R.ZSL.inferDtype(o),h=R.ZSL.getArrayFromDType(u,R.ZSL.sizeFromShape(i));return t=h,r=o,n=0,t.fill(r),a.makeTensorInfo(i,u,h)}let l8={kernelName:R.SQl,backendName:"cpu",kernelFunc:l9},ue={kernelName:R.BxF,backendName:"cpu",kernelFunc:({inputs:e,attrs:t,backend:r})=>{let{image:n}=e,a=R.ZSL.getTypedArrayFromDType(n.dtype,R.ZSL.sizeFromShape(n.shape)),[s,i,o,l]=n.shape,u=r.data.get(n.dataId).values;for(let e=0;e<s;e++){let t=e*o*i*l;for(let e=0;e<i;e++){let r=o*l*e;for(let e=0;e<o;e++){let n=e*l;for(let s=0;s<l;s++){let i=Math.round(o-e-1),h=t+r+n+s,p=u[h];i>=0&&i<o&&(p=u[t+r+i*l+s]),a[h]=p}}}}return{dataId:r.write(a,n.shape,n.dtype),shape:n.shape,dtype:n.dtype}}};var ut=r(3751),ur=r(86070);let un={kernelName:R.aAr,backendName:"cpu",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{x:a,filter:s,bias:i,preluActivationWeights:o}=t,{strides:l,pad:u,dataFormat:h,dilations:p,dimRoundingMode:d,activation:c,leakyreluAlpha:f}=n,m=ld({inputs:{x:a,filter:s},backend:r,attrs:{strides:l,pad:u,dataFormat:h,dilations:p,dimRoundingMode:d}});if(i){let e=m;if("NCHW"===h&&1===i.shape.length&&1!==i.shape[0]){let e=oT({inputs:{x:i},backend:r,attrs:{shape:[i.shape[0],1,1]}});m=(0,ow.WQ)({inputs:{a:m,b:e},backend:r}),r.disposeIntermediateTensorInfo(e)}else m=(0,ow.WQ)({inputs:{a:m,b:i},backend:r});r.disposeIntermediateTensorInfo(e)}if(c){let e=m;if("NCHW"===h&&"prelu"===c&&1===o.shape.length&&1!==o.shape[0]){let e=oT({inputs:{x:o},backend:r,attrs:{shape:[o.shape[0],1,1]}});m=ov(r,m,c,e,f),r.disposeIntermediateTensorInfo(e)}else m=ov(r,m,c,o,f);
197r.disposeIntermediateTensorInfo(e)}return m}},ua={kernelName:R.T7M,backendName:"cpu",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{x:a,filter:s,bias:i,preluActivationWeights:o}=t,{strides:l,pad:u,dataFormat:h,dilations:p,dimRoundingMode:d,activation:c,leakyreluAlpha:f}=n,m=lE({inputs:{x:a,filter:s},backend:r,attrs:{strides:l,pad:u,dataFormat:h,dilations:p,dimRoundingMode:d}});if(i){let e=m;m=(0,ow.WQ)({inputs:{a:m,b:i},backend:r}),r.disposeIntermediateTensorInfo(e)}if(c){let e=m;m=ov(r,m,c,o,f),r.disposeIntermediateTensorInfo(e)}return m}};var us=r(15565);let ui={kernelName:R.O4G,backendName:"cpu",kernelFunc:function(e){let{inputs:t,backend:r}=e,{params:n,indices:a}=t,s=R.ZSL.sizeFromShape(n.shape),i=a.shape,o=i[i.length-1],[l,u,h,p]=R.C0T.prepareAndValidate(n,a);if(0===u)return r.makeTensorInfo(l,n.dtype,[]);let d=r.data.get(a.dataId).values,c=r.bufferSync(n),f=(0,us.q)(d,c,n.dtype,u,o,h,p,n.shape,s);return r.makeTensorInfo(l,n.dtype,f.values)}};var uo=r(40459);let ul={kernelName:R.mxL,backendName:"cpu",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{x:a,indices:s}=t,{axis:i,batchDims:o}=n;(0,oe.C)([a,s],"gatherV2");let l=R.ZSL.parseAxisParam(i,a.shape)[0],u=r.data.get(s.dataId).values,h=a.shape[l];for(let e=0;e<u.length;++e){let t=u[e];R.ZSL.assert(t<=h-1&&t>=0,()=>`GatherV2: the index value ${t} is not in [0, ${h-1}]`)}let p=o;null==o&&(p=0);let d=R.ZSL.sizeFromShape(s.shape),c=R.C0T.segment_util.collectGatherOpShapeInfo(a,s,l,p),f=oT({inputs:{x:a},backend:r,attrs:{shape:[c.batchSize,c.outerSize,c.dimSize,c.sliceSize]}}),m=oT({inputs:{x:s},backend:r,attrs:{shape:[c.batchSize,d/c.batchSize]}}),g=[c.batchSize,c.outerSize,d/c.batchSize,c.sliceSize],y=r.bufferSync(m),b=r.bufferSync(f),x=(0,uo.G)(b,y,g);return r.disposeIntermediateTensorInfo(f),r.disposeIntermediateTensorInfo(m),r.makeTensorInfo(c.outputShape,x.dtype,x.values)}};var uu=r(80427),uh=r(86177);let up={kernelName:R.OAQ,backendName:"cpu",kernelFunc:function(e){let{inputs:t,backend:r}=e,{input:n}=t,a=R.ZSL.sizeFromShape(n.shape),s=n.shape[n.shape.length-1],i=oT({inputs:{x:n},backend:r,attrs:{shape:[a/s,s]}}),o=l6(i,!0,r),l=oT({inputs:{x:o},backend:r,attrs:{shape:n.shape}});return r.disposeIntermediateTensorInfo(i),r.disposeIntermediateTensorInfo(o),l}},ud=(0,os.v)(R.gIW,e=>+!!Number.isFinite(e),"bool"),uc={kernelName:R.gIW,backendName:"cpu",kernelFunc:ud},uf=(0,os.v)(R.E3$,e=>+(Math.abs(e)===1/0),"bool"),um={kernelName:R.E3$,backendName:"cpu",kernelFunc:uf},ug=(0,os.v)(R.iPs,e=>+!!Number.isNaN(e),"bool"),uy={kernelName:R.iPs,backendName:"cpu",kernelFunc:ug};var ub=r(59454),ux=r(75542),uv=r(1039);let uw={kernelName:R.mnI,backendName:"cpu",kernelFunc:function(e){let{backend:t,attrs:r}=e,{start:n,stop:a,num:s}=r,i=(0,uv.G)(n,a,s);return t.makeTensorInfo([i.length],"float32",i)}};var uT=r(32259);let uS=(0,os.v)(R.Cg$,e=>Math.log1p(e)),uN={kernelName:R.Cg$,backendName:"cpu",kernelFunc:uS},uk=(0,op.Z)((e,t)=>e&&t),uI=(0,oU.j)(R.RUm,uk,null,"bool"),uC={kernelName:R.RUm,backendName:"cpu",kernelFunc:uI},uE=(0,os.v)(R.nZd,e=>+!e,"bool"),uA={kernelName:R.nZd,backendName:"cpu",kernelFunc:uE},u$=(0,op.Z)((e,t)=>e||t),uF=(0,oU.j)(R.LXA,u$,null,"bool"),uR={kernelName:R.LXA,backendName:"cpu",kernelFunc:uF},u_={kernelName:R.jM4,backendName:"cpu",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{x:a}=t,{depthRadius:s,bias:i,alpha:o,beta:l}=n;(0,oe.C)(a,"LRN");let u=a.shape[3],h=u-1,p=r.data.get(a.dataId).values,d=R.ZSL.sizeFromShape(a.shape),c=new Float32Array(d);for(let e=0;e<d;e++){let t=function(e){let t=e%u,r=e-t+Math.max(0,t-s),n=e-t+Math.min(t+s,h),a=0;for(;r<=n;r++){let e=p[r];a+=e*e}return a}(e),r=p[e]*Math.pow(i+o*t,-l);c[e]=r}return r.makeTensorInfo(a.shape,a.dtype,c)}},uD={kernelName:R.ToN,backendName:"cpu",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{x:a,y:s,dy:i}=t,{depthRadius:o,bias:l,alpha:u,beta:h}=n;(0,oe.C)(i,"LRNGrad");let p=R.ZSL.sizeFromShape(i.shape),d=i.shape[3],c=r.data.get(i.dataId).values,f=r.data.get(a.dataId).values,m=r.data.get(s.dataId).values,g=new Float32Array(p);for(let e=0;e<p;e++){let t=e%d,r=e-t+Math.max(0,t-o),n=e-t+Math.min(d,t+o+1),a=0;for(let e=r;e<n;e++)a+=Math.pow(f[e],2);a=u*a+l;for(let t=r;t<n;t++){let r=-2*u*h*f[t]*m[e]/a;e===t&&(r+=Math.pow(a,-h)),r*=c[e],g[t]+=r}}return r.makeTensorInfo(i.shape,a.dtype,g)}};var uO=r(90534),uL=r(74069);function uM(e){let{inputs:t,backend:r,attrs:n}=e,{x:a}=t,{reductionIndices:s,keepDims:i}=n,o=a.shape,l=o.length,u=R.ZSL.parseAxisParam(s,o),h=u,p=R.C0T.getAxesPermutation(h,l),d=r.data.get(a.dataId).values;if(null!=p){let e=Array(l);for(let t=0;t<e.length;t++)e[t]=o[p[t]];d=(0,uL._)(d,o,a.dtype,p,e),h=R.C0T.getInnerMostAxes(h.length,l),o=e}(0,oe.C)(a,"max"),R.C0T.assertAxesAreInnerMostDims("max",h,l);let[c,f]=R.C0T.computeOutAndReduceShapes(o,h),m=R.ZSL.sizeFromShape(f),g=(0,uO.j)(d,m,c,a.dtype),y=r.write(g,c,a.dtype),b=c;return i&&(b=R.C0T.expandShapeToKeepDim(c,u)),{dataId:y,shape:b,dtype:a.dtype}}let uP={kernelName:R.VAI,backendName:"cpu",kernelFunc:uM};var uz=r(30051);let uB={kernelName:R.t3d,backendName:"cpu",kernelFunc:function(e){let t,{inputs:r,backend:n,attrs:a}=e,{x:s}=r;(0,oe.C)(s,"maxPool");let{filterSize:i,strides:o,pad:l,dimRoundingMode:u}=a;R.ZSL.assert(R.C0T.eitherStridesOrDilationsAreOne(o,1),()=>`Error in maxPool: Either strides or dilations must be 1. Got strides ${o} and dilations '1'`);let h=R.C0T.computePool2DInfo(s.shape,i,o,1,l,u);if(1===h.filterWidth&&1===h.filterHeight&&R.ZSL.arraysEqual(h.inShape,h.outShape))t=(0,ol.D)({inputs:{x:s},backend:n});else{let e=n.data.get(s.dataId).values,r=R.ZSL.computeStrides(s.shape),a=oQ(e,s.shape,s.dtype,r,h,"max");t=n.makeTensorInfo(h.outShape,s.dtype,a.values)}return t}},uW={kernelName:R.ySp,backendName:"cpu",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{x:a}=t,{filterSize:s,strides:i,pad:o,dimRoundingMode:l,dataFormat:u}=n;(0,oe.C)(a,"maxPool3d");let h=R.C0T.computePool3DInfo(a.shape,s,i,1,o,l,u),p=oX(r.data.get(a.dataId).values,a.shape,a.dtype,R.ZSL.computeStrides(a.shape),h,"max");return r.makeTensorInfo(p.shape,"float32",p.values)}},uV={kernelName:R.cHb,backendName:"cpu",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{dy:a,input:s}=t,{filterSize:i,strides:o,pad:l,dimRoundingMode:u}=n;(0,oe.C)([a,s],"maxPool3DGrad");let h=R.C0T.computePool3DInfo(s.shape,i,o,1,l,u),p=function(e,t){let r=(0,R.ra8)(t.outShape,"int32"),n=t.strideDepth,a=t.strideHeight,s=t.strideWidth,i=t.dilationDepth,o=t.dilationHeight,l=t.dilationWidth,u=t.effectiveFilterDepth,h=t.effectiveFilterHeight,p=t.effectiveFilterWidth,d=t.padInfo.front,c=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 b=y*n-d,x=b;
197for(;x<0;)x+=i;let v=Math.min(t.inDepth,u+b);for(let n=0;n<t.outHeight;++n){let u=n*a-c,d=u;for(;d<0;)d+=o;let w=Math.min(t.inHeight,h+u);for(let a=0;a<t.outWidth;++a){let c=a*s-f,T=c;for(;T<0;)T+=l;let S=Math.min(t.inWidth,p+c),N=Number.NEGATIVE_INFINITY,k=-1;for(let t=x;t<v;t+=i){let r=t-b;for(let n=d;n<w;n+=o){let a=n-u;for(let s=T;s<S;s+=l){let i=s-c,o=e.get(m,t,n,s,g);o>=N&&(N=o,k=r*h*p+a*h+i)}}}r.set(k,m,y,n,a,g)}}}return r}(r.bufferSync(s),h),d=h.strideDepth,c=h.strideHeight,f=h.strideWidth,m=h.dilationDepth,g=h.dilationHeight,y=h.dilationWidth,b=h.effectiveFilterDepth,x=h.effectiveFilterHeight,v=h.effectiveFilterWidth,w=b-1-h.padInfo.front,T=v-1-h.padInfo.left,S=x-1-h.padInfo.top,N=(0,R.ra8)(s.shape,"float32"),k=r.bufferSync(a);for(let e=0;e<h.batchSize;++e)for(let t=0;t<h.inChannels;++t)for(let r=0;r<h.inDepth;++r)for(let n=0;n<h.inHeight;++n)for(let a=0;a<h.inWidth;++a){let s=r-w,i=n-S,o=a-T,l=0;for(let r=0;r<b;r+=m){let n=(s+r)/d;if(!(n<0)&&!(n>=h.outDepth)&&Math.floor(n)===n)for(let a=0;a<x;a+=g){let s=(i+a)/c;if(!(s<0)&&!(s>=h.outHeight)&&Math.floor(s)===s)for(let i=0;i<v;i+=y){let u=(o+i)/f;if(u<0||u>=h.outWidth||Math.floor(u)!==u)continue;let d=+(b*x*v-1-p.get(e,n,s,u,t)===r*x*v+a*v+i);0!==d&&(l+=k.get(e,n,s,u,t)*d)}}}N.set(l,e,r,n,a,t)}return r.makeTensorInfo(N.shape,N.dtype,N.values)}},uG={kernelName:R.RXX,backendName:"cpu",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{dy:a,input:s,output:i}=t;(0,oe.C)([s,i],"maxPoolGrad");let{filterSize:o,strides:l,pad:u,dimRoundingMode:h}=n,p=R.C0T.computePool2DInfo(s.shape,o,l,1,u,h),d=r.data.get(s.dataId).values,c=(0,R.ra8)(p.outShape,s.dtype,oq(d,s.shape,s.dtype,p).values),f=p.strideHeight,m=p.strideWidth,g=p.dilationHeight,y=p.dilationWidth,b=p.effectiveFilterHeight,x=p.effectiveFilterWidth,v=x-1-p.padInfo.left,w=b-1-p.padInfo.top,T=(0,R.ra8)(s.shape,"float32"),S=r.data.get(a.dataId).values,N=(0,R.ra8)(a.shape,"float32",S);for(let e=0;e<p.batchSize;++e)for(let t=0;t<p.inChannels;++t)for(let r=0;r<p.inHeight;++r)for(let n=0;n<p.inWidth;++n){let a=r-w,s=n-v,i=0;for(let r=0;r<b;r+=g){let n=(a+r)/f;if(!(n<0)&&!(n>=p.outHeight)&&Math.floor(n)===n)for(let a=0;a<x;a+=y){let o=(s+a)/m;if(o<0||o>=p.outWidth||Math.floor(o)!==o)continue;let l=+(b*x-1-c.get(e,n,o,t)===r*x+a);0!==l&&(i+=N.get(e,n,o,t)*l)}}T.set(i,e,r,n,t)}return r.makeTensorInfo(T.shape,T.dtype,T.values)}},uU={kernelName:R.TL8,backendName:"cpu",kernelFunc:({inputs:e,attrs:t,backend:r})=>{let{x:n}=e,{filterSize:a,strides:s,pad:i,includeBatchInIndex:o}=t;(0,oe.C)(n,"MaxPoolWithArgmax");let l=r.data.get(n.dataId).values,u=R.C0T.computePool2DInfo(n.shape,a,s,[1,1],i),[h,p]=function(e,t,r,n,a){let s=R.ZSL.computeStrides(t),i=oQ(e,t,r,s,a,"max"),o=oq(e,t,r,a,!0,n);return[i.values,o.values]}(l,n.shape,n.dtype,o,u),d=r.write(h,u.outShape,n.dtype),c=r.write(p,u.outShape,n.dtype);return[{dataId:d,shape:u.outShape,dtype:n.dtype},{dataId:c,shape:u.outShape,dtype:"int32"}]}},uZ={kernelName:R.g5A,backendName:"cpu",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{x:a}=t,{axis:s,keepDims:i}=n,o=R.ZSL.parseAxisParam(s,a.shape),l=R.C0T.computeOutAndReduceShapes(a.shape,o)[1],u=R.ZSL.sizeFromShape(l),h=[],p=r.makeTensorInfo([],"float32",new Float32Array([u]));h.push(p);let d=(0,le.wg)({inputs:{x:a},backend:r,attrs:{dtype:"float32"}});h.push(d);let c=l3({inputs:{a:d,b:p},backend:r});h.push(c);let f=lz({inputs:{x:c},backend:r,attrs:{axis:s,keepDims:i}});return h.forEach(e=>r.disposeIntermediateTensorInfo(e)),f}},uj={kernelName:R.lNG,backendName:"cpu",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{x:a}=t,{axis:s,keepDims:i}=n;(0,oe.C)(a,"min");let o=R.ZSL.parseAxisParam(s,a.shape),l=o,u=R.C0T.getAxesPermutation(l,a.shape.length),h=a;null!=u&&(h=(0,o_.m)({inputs:{x:a},backend:r,attrs:{perm:u}}),l=R.C0T.getInnerMostAxes(l.length,a.shape.length)),R.C0T.assertAxesAreInnerMostDims("min",l,h.shape.length);let[p,d]=R.C0T.computeOutAndReduceShapes(h.shape,l),c=R.ZSL.sizeFromShape(d),f=R.ZSL.makeZerosTypedArray(R.ZSL.sizeFromShape(p),h.dtype),m=r.data.get(h.dataId).values;for(let e=0;e<f.length;++e){let t=e*c,r=m[t];for(let e=0;e<c;++e){let n=m[t+e];(Number.isNaN(n)||n<r)&&(r=n)}f[e]=r}null!=u&&r.disposeIntermediateTensorInfo(h);let g=r.makeTensorInfo(p,h.dtype,f);if(i){let e=oT({inputs:{x:g},backend:r,attrs:{shape:R.C0T.expandShapeToKeepDim(p,o)}});return r.disposeIntermediateTensorInfo(g),e}return g}};var uH=r(99373);let uK={kernelName:R.x7F,backendName:"cpu",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{x:a}=t,{paddings:s,mode:i}=n;(0,oe.C)(a,"mirrorPad");let o=s.map((e,t)=>e[0]+a.shape[t]+e[1]),l=s.map(e=>e[0]),u=s.map((e,t)=>e[0]+a.shape[t]),h=+("reflect"!==i),p=r.data.get(a.dataId).values,d=a.shape.length,c=R.ZSL.computeStrides(a.shape),f=R.ZSL.sizeFromShape(o),m=o.length,g=R.ZSL.computeStrides(o),y=R.ZSL.getTypedArrayFromDType(a.dtype,f);for(let e=0;e<f;e++){let t=R.ZSL.indexToLoc(e,m,g);for(let e=0;e<m;e++)t[e]<l[e]?t[e]=2*l[e]-t[e]-h:t[e]>=u[e]&&(t[e]=(u[e]-1)*2-t[e]+h);t=t.map((e,t)=>e-l[t]);let r=R.ZSL.locToIndex(t,d,c);y[e]=p[r]}return{dataId:r.write(y,o,a.dtype),shape:o,dtype:a.dtype}}},uY=(0,op.Z)((e,t)=>{let r=e%t;return e<0&&t<0||e>=0&&t>=0?r:(r+t)%t}),uQ=(0,oU.j)(R.BLA,uY),uq={kernelName:R.BLA,backendName:"cpu",kernelFunc:uQ};function uX(e){let{inputs:t,backend:r,attrs:n}=e,{logits:a}=t,{dim:s}=n,i=a.shape.length,o=s;if(-1===o&&(o=i-1),o!==i-1)throw Error(`Softmax along a non-last dimension is not yet supported. Logits was rank ${i} and dim was ${o}`);
197let l=R.ZSL.parseAxisParam([o],a.shape),u=uM({inputs:{x:a},backend:r,attrs:{reductionIndices:l,keepDims:!1}}),h=R.C0T.expandShapeToKeepDim(u.shape,l),p=oT({inputs:{x:u},backend:r,attrs:{shape:h}}),d=(0,l5.jb)({inputs:{a:a,b:p},backend:r}),c=(0,lX.oN)({inputs:{x:d},backend:r}),f=lz({inputs:{x:c},backend:r,attrs:{axis:l,keepDims:!1}}),m=oT({inputs:{x:f},backend:r,attrs:{shape:h}}),g=l3({inputs:{a:c,b:m},backend:r});return r.disposeIntermediateTensorInfo(u),r.disposeIntermediateTensorInfo(p),r.disposeIntermediateTensorInfo(d),r.disposeIntermediateTensorInfo(c),r.disposeIntermediateTensorInfo(f),r.disposeIntermediateTensorInfo(m),g}let uJ={kernelName:R.rFG,backendName:"cpu",kernelFunc:uX},u0={kernelName:R.WT3,backendName:"cpu",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{logits:a}=t,{numSamples:s,seed:i,normalized:o}=n;(0,oe.C)(a,"multinomial");let l=o?a:uX({inputs:{logits:a},backend:r,attrs:{dim:-1}}),u=l.shape[0],h=l.shape[1],p=r.data.get(l.dataId).values,d=[u,s],c=R.ZSL.makeZerosTypedArray(R.ZSL.sizeFromShape(d),"int32");for(let e=0;e<u;++e){let t=e*h,r=new Float32Array(h-1);r[0]=p[t];for(let e=1;e<r.length;++e)r[e]=r[e-1]+p[t+e];let n=ir.alea(i.toString()),a=e*s;for(let e=0;e<s;++e){let t=n();c[a+e]=r.length;for(let n=0;n<r.length;n++)if(t<r[n]){c[a+e]=n;break}}}return o||r.disposeIntermediateTensorInfo(l),r.makeTensorInfo(d,"int32",c)}};var u1=r(88547);let u2=R.kpo.nonMaxSuppressionV3Impl,u3={kernelName:R.SDM,backendName:"cpu",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{boxes:a,scores:s}=t,{maxOutputSize:i,iouThreshold:o,scoreThreshold:l}=n;(0,oe.C)(a,"NonMaxSuppression");let{selectedIndices:u}=u2(r.data.get(a.dataId).values,r.data.get(s.dataId).values,i,o,l);return r.makeTensorInfo([u.length],"int32",new Int32Array(u))}},u4=R.kpo.nonMaxSuppressionV4Impl,u5={kernelName:R.Zl4,backendName:"cpu",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{boxes:a,scores:s}=t,{maxOutputSize:i,iouThreshold:o,scoreThreshold:l,padToMaxOutputSize:u}=n;(0,oe.C)(a,"NonMaxSuppressionPadded");let{selectedIndices:h,validOutputs:p}=u4(r.data.get(a.dataId).values,r.data.get(s.dataId).values,i,o,l,u);return[r.makeTensorInfo([h.length],"int32",new Int32Array(h)),r.makeTensorInfo([],"int32",new Int32Array([p]))]}},u6=R.kpo.nonMaxSuppressionV5Impl,u7={kernelName:R.e0f,backendName:"cpu",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{boxes:a,scores:s}=t,{maxOutputSize:i,iouThreshold:o,scoreThreshold:l,softNmsSigma:u}=n;(0,oe.C)(a,"NonMaxSuppressionWithScore");let h=r.data.get(a.dataId).values,{selectedIndices:p,selectedScores:d}=u6(h,r.data.get(s.dataId).values,i,o,l,u);return[r.makeTensorInfo([p.length],"int32",new Int32Array(p)),r.makeTensorInfo([d.length],"float32",new Float32Array(d))]}};var u9=r(55648);let u8={kernelName:R.urI,backendName:"cpu",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{indices:a}=t,{dtype:s,depth:i,onValue:o,offValue:l}=n;(0,oe.C)(a,"oneHot");let u=R.ZSL.sizeFromShape(a.shape),h=new Float32Array(u*i);h.fill(l);let p=r.data.get(a.dataId).values;for(let e=0;e<u;++e)p[e]>=0&&p[e]<i&&(h[e*i+p[e]]=o);return r.makeTensorInfo([...a.shape,i],s,h)}};function he(e){let{inputs:t,backend:r}=e,{x:n}=t;if("string"===n.dtype)throw Error("zerosLike is not supported for string tensors");if("complex64"!==n.dtype)return l9({backend:r,attrs:{shape:n.shape,value:0,dtype:n.dtype}});{let e=(0,lu.x)({inputs:{input:n},backend:r}),t=he({inputs:{x:e},backend:r}),a=lo({inputs:{input:n},backend:r}),s=he({inputs:{x:a},backend:r}),i=(0,la.f)({inputs:{real:t,imag:s},backend:r});return r.disposeIntermediateTensorInfo(e),r.disposeIntermediateTensorInfo(t),r.disposeIntermediateTensorInfo(a),r.disposeIntermediateTensorInfo(s),i}}let ht={kernelName:R.xJ3,backendName:"cpu",kernelFunc:he},hr={kernelName:R.LWX,backendName:"cpu",kernelFunc:function e(t){let{inputs:r,backend:n}=t,{x:a}=r;if("string"===a.dtype)throw Error("onesLike is not supported for string tensors");if("complex64"!==a.dtype)return l9({backend:n,attrs:{shape:a.shape,value:1,dtype:a.dtype}});{let t=(0,lu.x)({inputs:{input:a},backend:n}),r=e({inputs:{x:t},backend:n}
197),s=lo({inputs:{input:a},backend:n}),i=he({inputs:{x:s},backend:n}),o=(0,la.f)({inputs:{real:r,imag:i},backend:n});return n.disposeIntermediateTensorInfo(t),n.disposeIntermediateTensorInfo(r),n.disposeIntermediateTensorInfo(s),n.disposeIntermediateTensorInfo(i),o}}};function hn(e){let{inputs:t,backend:r,attrs:n}=e,{axis:a}=n;if(1===t.length)return lJ({inputs:{input:t[0]},backend:r,attrs:{dim:a}});let s=t[0].shape,i=t[0].dtype;t.forEach(e=>{R.ZSL.assertShapesMatch(s,e.shape,"All tensors passed to stack must have matching shapes"),R.ZSL.assert(i===e.dtype,()=>"All tensors passed to stack must have matching dtypes")});let o=[],l=lh({inputs:t.map(e=>{let t=lJ({inputs:{input:e},backend:r,attrs:{dim:a}});return o.push(t),t}),backend:r,attrs:{axis:a}});return o.forEach(e=>r.disposeIntermediateTensorInfo(e)),l}let ha={kernelName:R.mM$,backendName:"cpu",kernelFunc:hn},hs={kernelName:R.ODT,backendName:"cpu",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{x:a}=t,{paddings:s,constantValue:i}=n;(0,oe.C)(a,"pad");let o=s.map((e,t)=>e[0]+a.shape[t]+e[1]),l=s.map(e=>e[0]),u=r.data.get(a.dataId).values,h=R.ZSL.sizeFromShape(a.shape),p=a.shape.length,d=R.ZSL.computeStrides(a.shape),c=R.ZSL.sizeFromShape(o),f=o.length,m=R.ZSL.computeStrides(o),g=R.ZSL.getTypedArrayFromDType(a.dtype,c);0!==i&&g.fill(i);for(let e=0;e<h;e++){let t=R.ZSL.indexToLoc(e,p,d).map((e,t)=>e+l[t]);g[R.ZSL.locToIndex(t,f,m)]=u[e]}return{dataId:r.write(g,o,a.dtype),shape:o,dtype:a.dtype}}},hi=(0,op.Z)((e,t)=>Math.pow(e,t)),ho=(0,oU.j)(R.pyJ,hi),hl={kernelName:R.pyJ,backendName:"cpu",kernelFunc:ho};var hu=r(49762),hh=r(52949);let hp={kernelName:R.oJ2,backendName:"cpu",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{paramsNestedSplits:a,paramsDenseValues:s,indices:i}=t,{outputRaggedRank:o}=n,l=a.map(e=>r.data.get(e.dataId).values),u=a.map(e=>e.shape),h=r.data.get(s.dataId).values,p=r.data.get(i.dataId).values,[d,c,f]=(0,hh.u)(l,u,h,s.shape,s.dtype,p,i.shape,o),m=d.map(e=>r.makeTensorInfo([e.length],"int32",e)),g=r.makeTensorInfo(f,s.dtype,c);return m.concat([g])}};var hd=r(98253);let hc={kernelName:R.CQC,backendName:"cpu",kernelFunc:function(e){let{inputs:t,backend:r}=e,{starts:n,limits:a,deltas:s}=t,i=r.data.get(n.dataId).values,o=r.data.get(a.dataId).values,l=r.data.get(s.dataId).values,[u,h]=(0,hd._)(i,n.shape,n.dtype,o,a.shape,l,s.shape);return[r.makeTensorInfo([u.length],"int32",u),r.makeTensorInfo([h.length],n.dtype,h)]}};var hf=r(58151);let hm={kernelName:R.mH5,backendName:"cpu",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{shape:a,values:s,defaultValue:i,rowPartitionTensors:o}=t,{rowPartitionTypes:l}=n,u=r.data.get(a.dataId).values,h=r.data.get(s.dataId).values,p=r.data.get(i.dataId).values,d=o.map(e=>r.data.get(e.dataId).values),c=o.map(e=>e.shape),[f,m]=(0,hf.K)(u,a.shape,h,s.shape,s.dtype,p,i.shape,d,c,l);return r.makeTensorInfo(f,s.dtype,m)}};var hg=r(12507);let hy={kernelName:R.Q6t,backendName:"cpu",kernelFunc:function(e){let{backend:t,attrs:r}=e,{start:n,stop:a,dtype:s,step:i}=r,o=(0,hg.q)(n,a,i,s);return t.makeTensorInfo([o.length],s,o)}},hb=(0,os.v)(R.huO,e=>1/e),hx={kernelName:R.huO,backendName:"cpu",kernelFunc:hb},hv={kernelName:R.hgw,backendName:"cpu",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{images:a}=t,{alignCorners:s,halfPixelCenters:i,size:o}=n;(0,oe.C)(a,"resizeBilinear");let l=R.ZSL.computeStrides(a.shape),[u,h]=o,[p,d,c,f]=a.shape,m=r.data.get(a.dataId).values,g=new Float32Array(R.ZSL.sizeFromShape([p,u,h,f])),y=[s&&u>1?d-1:d,s&&h>1?c-1:c],b=[s&&u>1?u-1:u,s&&h>1?h-1:h],x=0,v=y[0]/b[0],w=y[1]/b[1];for(let e=0;e<p;e++)for(let t=0;t<u;t++){let r,n=Math.max(0,Math.floor(r=i?v*(t+.5)-.5:v*t)),a=r-n,s=Math.min(d-1,Math.ceil(r)),o=e*l[0]+n*l[1],u=e*l[0]+s*l[1];for(let e=0;e<h;e++){let t,r=Math.max(0,Math.floor(t=i?w*(e+.5)-.5:w*e)),n=t-r,s=Math.min(c-1,Math.ceil(t)),h=o+r*l[2],p=u+r*l[2],d=o+s*l[2],y=u+s*l[2];for(let e=0;e<f;e++){let t=m[h+e],r=m[p+e],s=m[d+e],i=m[y+e],o=t+(s-t)*n,l=o+(r+(i-r)*n-o)*a;g[x++]=l}}}return r.makeTensorInfo([p,u,h,f],"float32",g)}},hw={kernelName:R.FCQ,backendName:"cpu",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{images:a,dy:s}=t,{alignCorners:i}=n;(0,oe.C)([s,a],"resizeBilinearGrad");
197let o=R.ZSL.computeStrides(a.shape),[l,u,h,p]=a.shape,[,d,c]=s.shape,f=new Float32Array(l*u*h*p),m=[i&&d>1?u-1:u,i&&c>1?h-1:h],g=[i&&d>1?d-1:d,i&&c>1?c-1:c],y=m[0]/g[0],b=m[1]/g[1],x=r.data.get(s.dataId).values,v=0;for(let e=0;e<l;e++){let t=e*o[0];for(let e=0;e<d;e++){let r=e*y,n=Math.floor(r),a=Math.min(Math.ceil(r),u-1),s=t+n*o[1],i=t+a*o[1],l=r-n,d=1-l;for(let e=0;e<c;e++){let t=e*b,r=Math.floor(t),n=Math.min(Math.ceil(t),h-1),a=t-r,u=1-a,c=s+r*o[2],m=s+n*o[2],g=i+r*o[2],y=i+n*o[2],w=d*u,T=d*a,S=l*u,N=l*a;for(let e=0;e<p;e++){let t=x[v++];f[c+e]+=t*w,f[m+e]+=t*T,f[g+e]+=t*S,f[y+e]+=t*N}}}}return r.makeTensorInfo([l,h,u,p],"float32",f)}},hT={kernelName:R.jOE,backendName:"cpu",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{images:a}=t,{alignCorners:s,halfPixelCenters:i,size:o}=n;(0,oe.C)(a,"resizeNearestNeighbor");let l=R.ZSL.computeStrides(a.shape),[u,h]=o,[p,d,c,f]=a.shape,m=r.data.get(a.dataId).values,g=new Float32Array(p*u*h*f),y=[s&&u>1?d-1:d,s&&h>1?c-1:c],b=[s&&u>1?u-1:u,s&&h>1?h-1:h],x=y[0]/b[0],v=y[1]/b[1],w=0;for(let e=0;e<p;e++){let t=e*l[0];for(let e=0;e<u;e++){let r=i?x*(e+.5):x*e,n=Math.min(d-1,s?Math.round(r):Math.floor(r));i&&(n=Math.max(0,n));let a=t+n*l[1];for(let e=0;e<h;e++){let t=i?v*(e+.5):v*e,r=Math.min(c-1,s?Math.round(t):Math.floor(t));i&&(r=Math.max(0,r));let n=a+r*l[2];for(let e=0;e<f;e++){let t=m[n+e];g[w++]=t}}}}return r.makeTensorInfo([p,u,h,f],a.dtype,g)}},hS={kernelName:R.XQy,backendName:"cpu",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{images:a,dy:s}=t,{alignCorners:i}=n;(0,oe.C)([s,a],"resizeNearestNeighborGrad");let o=R.ZSL.computeStrides(a.shape),l=R.ZSL.computeStrides(s.shape),[u,h,p,d]=a.shape,[,c,f]=s.shape,m=new Float32Array(u*h*p*d),g=r.data.get(s.dataId).values,y=[i&&c>1?h-1:h,i&&f>1?p-1:p],b=[i&&c>1?c-1:c,i&&f>1?f-1:f],x=y[0]/b[0],v=y[1]/b[1],w=1/x,T=1/v,S=2*Math.ceil(w)+2,N=2*Math.ceil(T)+2;for(let e=0;e<u;e++){let t=e*o[0];for(let e=0;e<h;e++){let r=t+e*o[1],n=Math.floor(Math.floor(e*w)-S/2);for(let a=0;a<p;a++){let s=r+a*o[2],u=Math.floor(Math.floor(a*T)-N/2);for(let r=0;r<d;r++){let o=0;for(let s=0;s<S;s++){let d=s+n;if(d<0||d>=c)continue;let m=t+d*l[1],y=d*x;if(e===Math.min(h-1,i?Math.round(y):Math.floor(y)))for(let e=0;e<N;e++){let t=e+u;if(t<0||t>=f)continue;let n=m+t*l[2],s=t*v;a===Math.min(p-1,i?Math.round(s):Math.floor(s))&&(o+=g[n+r])}}m[s+r]=o}}}}return r.makeTensorInfo(a.shape,a.dtype,m)}},hN={kernelName:R.D7i,backendName:"cpu",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{x:a}=t,{dims:s}=n;(0,oe.C)(a,"reverse");let i=a.shape.length,o=R.ZSL.parseAxisParam(s,a.shape);if(0===i)return(0,ol.D)({inputs:{x:a},backend:r});let l=new R.ylz(a.shape,a.dtype),u=r.bufferSync(a);for(let e=0;e<l.size;e++){let t=l.indexToLoc(e),r=t.slice();o.forEach(e=>r[e]=a.shape[e]-1-r[e]),l.set(u.get(...r),...t)}return r.makeTensorInfo(l.shape,l.dtype,l.values)}},hk={kernelName:R.BK4,backendName:"cpu",kernelFunc:({inputs:e,attrs:t,backend:r})=>{let{image:n}
197=e,{radians:a,fillValue:s,center:i}=t,o=R.ZSL.getTypedArrayFromDType(n.dtype,R.ZSL.sizeFromShape(n.shape)),[l,u,h,p]=n.shape,[d,c]=R.C0T.getImageCenter(i,u,h),f=Math.sin(a),m=Math.cos(a),g=r.data.get(n.dataId).values;for(let e=0;e<l;e++){let t=e*h*u*p;for(let e=0;e<u;e++){let r=h*p*e;for(let n=0;n<h;n++){let a=n*p;for(let i=0;i<p;i++){let y=[l,e,n,i],b=y[2],x=y[1],v=(b-d)*m-(x-c)*f,w=(b-d)*f+(x-c)*m;v=Math.round(v+d),w=Math.round(w+c);let T=s;"number"!=typeof s&&(T=3===i?255:s[i]),v>=0&&v<h&&w>=0&&w<u&&(T=g[t+h*p*w+v*p+i]),o[t+r+a+i]=T}}}}return{dataId:r.write(o,n.shape,n.dtype),shape:n.shape,dtype:n.dtype}}},hI=(0,os.v)(R.hVg,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}),hC={kernelName:R.hVg,backendName:"cpu",kernelFunc:hI};var hE=r(8341),hA=r(50494);let h$={kernelName:R.pJc,backendName:"cpu",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{indices:a,updates:s}=t,{shape:i}=n,{sliceRank:o,numUpdates:l,sliceSize:u,strides:h,outputSize:p}=R.C0T.calculateShapes(s,a,i),d=r.bufferSync(a),c=r.bufferSync(s),f=(0,hA.b)(d,c,i,p,u,l,o,h,0,!0);return r.makeTensorInfo(i,f.dtype,f.values)}},hF={kernelName:R.uWl,backendName:"cpu",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{sortedSequence:a,values:s}=t,{side:i}=n,o=function(e,t,r,n,a,s){let i=R.ZSL.getArrayFromDType("int32",r*a);for(let o=0;o<r;++o){let r=e.slice(o*n,(o+1)*n),l=o*a;for(let e=0;e<a;++e)i[l+e]="left"===s?function(e,t){let r=0,n=e.length,a=0;for(;r<n;)e[a=Math.floor((r+n)/2)]<t?r=a+1:n=a;return n}(r,t[e+l]):function(e,t){let r=0,n=e.length,a=0;for(;r<n;)e[a=Math.floor((r+n)/2)]<=t?r=a+1:n=a;return n}(r,t[e+l])}return i}(r.data.get(a.dataId).values,r.data.get(s.dataId).values,a.shape[0],a.shape[1],s.shape[1],i);return r.makeTensorInfo(s.shape,"int32",o)}},hR={kernelName:R.l6P,backendName:"cpu",kernelFunc:function(e){let{inputs:t,backend:r}=e,{condition:n,t:a,e:s}=t;(0,oe.C)([n,a,s],"select");let i=n.shape.length,o=r.data.get(n.dataId).values,l=r.data.get(a.dataId).values,u=r.data.get(s.dataId).values,h=(0,R.TuY)(a.dtype,s.dtype),p=R.ZSL.makeZerosTypedArray(R.ZSL.sizeFromShape(a.shape),h),d=0,c=0===i||i>1||1===a.shape.length?1:R.ZSL.sizeFromShape(a.shape.slice(1));for(let e=0;e<o.length;e++)for(let t=0;t<c;t++)1===o[e]?p[d++]=l[e]:p[d++]=u[e];return r.makeTensorInfo(a.shape,h,p)}},h_=R.C0T.SELU_SCALEALPHA,hD=R.C0T.SELU_SCALE,hO=(0,os.v)(R.u$b,e=>e>=0?hD*e:h_*(Math.exp(e)-1)),hL={kernelName:R.u$b,backendName:"cpu",kernelFunc:hO},hM=(0,os.v)(R.YVe,e=>e<0?-1:+(e>0)),hP={kernelName:R.YVe,backendName:"cpu",kernelFunc:hM},hz=(0,os.v)(R.hql,e=>Math.sin(e)),hB={kernelName:R.hql,backendName:"cpu",kernelFunc:hz},hW=(0,os.v)(R.J3C,e=>Math.sinh(e)),hV={kernelName:R.J3C,backendName:"cpu",kernelFunc:hW},hG=Math.log(11920928955078125e-23)+2,hU=(0,os.v)(R.Fin,e=>{let t,r=Math.exp(e);return e<hG?r:e>-hG?e:Math.log(1+r)}),hZ={kernelName:R.Fin,backendName:"cpu",kernelFunc:hU},hj={kernelName:R.A8B,backendName:"cpu",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{x:a}=t,{blockShape:s,paddings:i}=n;(0,oe.C)([a],"spaceToBatchND");let o=R.ZSL.sizeFromShape(s),l=[[0,0]];l.push(...i);for(let e=1+s.length;e<a.shape.length;++e)l.push([0,0]);let u=hs.kernelFunc({inputs:{x:a},backend:r,attrs:{paddings:l,constantValue:0}}),h=R.C0T.getReshaped(u.shape,s,o,!1),p=R.C0T.getPermuted(h.length,s.length,!1),d=R.C0T.getReshapedPermuted(u.shape,s,o,!1),c=oT({inputs:{x:u},backend:r,attrs:{shape:h}}),f=(0,o_.m)({inputs:{x:c},backend:r,attrs:{perm:p}}),m=oT({inputs:{x:f},backend:r,attrs:{shape:d}});return r.disposeIntermediateTensorInfo(u),r.disposeIntermediateTensorInfo(c),r.disposeIntermediateTensorInfo(f),m}};var hH=r(26777);let hK={kernelName:R.C8s,backendName:"cpu",kernelFunc:function(e){let{inputs:t,backend:r}=e,{indices:n,values:a,denseShape:s,defaultValue:i}=t;if(1!==s.shape.length)throw Error(`Dense shape must be a vector, saw: 198 ${s.shape}`);if(2!==n.shape.length)throw Error(`Indices must be a matrix, saw: 199 ${n.shape}`);if(1!==a.shape.length)throw Error(`Values must be a vector, saw: 200 ${a.shape}`);if(0!==i.shape.length)throw Error(`Default value must be a scalar, saw: 201 ${i.shape}`);let o=r.data.get(n.dataId).values,l=r.data.get(a.dataId).values,u=r.data.get(s.dataId).values,h=r.data.get(i.dataId).values[0],[p,d,c,f,m]=(0,hH.y)(o,n.shape,n.dtype,l,a.dtype,u,h);return[r.makeTensorInfo(d,n.dtype,p),r.makeTensorInfo([d[0]],a.dtype,c),r.makeTensorInfo([f.length],"bool",new Uint8Array(f.map(e=>Number(e)))),r.makeTensorInfo([m.length],n.dtype,new Int32Array(m))]}};var hY=r(91338);let hQ={kernelName:R.BoJ,backendName:"cpu",kernelFunc:function(e){let{inputs:t,backend:r}=e,{inputIndices:n,inputShape:a,newShape:s}=t;if(2!==n.shape.length)throw Error(`Input indices should be a matrix but received shape 202 ${n.shape}`);if(1!==a.shape.length)throw Error(`Input shape should be a vector but received shape 203 ${a.shape}`);if(1!==s.shape.length)throw Error(`Target shape should be a vector but received shape ${s.shape}`);let i=Array.from(r.data.get(a.dataId).values),o=r.data.get(n.dataId).values,l=Array.from(r.data.get(s.dataId).values),[u,h,p]=(0,hY.l)(o,n.shape,n.dtype,i,l);return[r.makeTensorInfo(h,n.dtype,u),r.makeTensorInfo([p.length],s.dtype,new Int32Array(p))]}};var hq=r(45732);let hX={kernelName:R.L6G,backendName:"cpu",kernelFunc:function(e){let{inputs:t,backend:r}=e,{data:n,indices:a,segmentIds:s}=t;if(n.shape.length<1)throw Error("Data should be at least 1 dimensional but received scalar");
203if(1!==a.shape.length)throw Error(`Indices should be a vector but received shape 204 ${a.shape}`);if(1!==s.shape.length)throw Error(`Segment ids should be a vector but received shape 205 ${s.shape}`);if(a.shape[0]!==s.shape[0])throw Error("segmentIds and indices should have same size.");let i=r.data.get(n.dataId).values,o=r.data.get(a.dataId).values,l=r.data.get(s.dataId).values,[u,h]=(0,hq.z)(i,n.shape,n.dtype,o,l,!0);return r.makeTensorInfo(h,n.dtype,u)}},hJ={kernelName:R.DvZ,backendName:"cpu",kernelFunc:function(e){let{inputs:t,backend:r}=e,{data:n,indices:a,segmentIds:s}=t;if(n.shape.length<1)throw Error("Data should be at least 1 dimensional but received scalar");if(1!==a.shape.length)throw Error(`Indices should be a vector but received shape 206 ${a.shape}`);if(1!==s.shape.length)throw Error(`Segment ids should be a vector but received shape 207 ${s.shape}`);if(a.shape[0]!==s.shape[0])throw Error("segmentIds and indices should have same size.");let i=r.data.get(n.dataId).values,o=r.data.get(a.dataId).values,l=r.data.get(s.dataId).values,[u,h]=(0,hq.z)(i,n.shape,n.dtype,o,l);return r.makeTensorInfo(h,n.dtype,u)}},h0={kernelName:R.jgd,backendName:"cpu",kernelFunc:function(e){let t,{inputs:r,backend:n,attrs:a}=e,{sparseIndices:s,sparseValues:i,defaultValue:o}=r,{outputShape:l}=a,{sliceRank:u,numUpdates:h,sliceSize:p,strides:d,outputSize:c}=R.C0T.calculateShapes(i,s,l),f=n.bufferSync(s);switch(i.dtype){case"bool":{let e=n.bufferSync(i),r=!!n.data.get(o.dataId).values[0];t=(0,hA.b)(f,e,l,c,p,h,u,d,r,!1);break}case"float32":{let e=n.bufferSync(i),r=n.data.get(o.dataId).values[0];t=(0,hA.b)(f,e,l,c,p,h,u,d,r,!1);break}case"int32":{let e=n.bufferSync(i),r=n.data.get(o.dataId).values[0];t=(0,hA.b)(f,e,l,c,p,h,u,d,r,!1);break}case"string":{let e=n.bufferSync(i),r=R.ZSL.decodeString(n.data.get(o.dataId).values[0]);t=(0,hA.b)(f,e,l,c,p,h,u,d,r,!1);break}default:throw Error(`Unsupported type ${i.dtype}`)}return n.makeTensorInfo(l,t.dtype,t.values)}},h1={kernelName:R.Blb,backendName:"cpu",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{x:a}=t,{numOrSizeSplits:s,axis:i}=n,o=R.ZSL.parseAxisParam(i,a.shape)[0],l=R.C0T.prepareSplitSize(a,s,o),u=Array(a.shape.length).fill(0),h=a.shape.slice();return l.map(e=>{let t=[...h];t[o]=e;let n=(0,o4.di)({inputs:{x:a},backend:r,attrs:{begin:u,size:t}});return u[o]+=e,n})}};var h2=r(85205);let h3={kernelName:R.M6A,backendName:"cpu",kernelFunc:({inputs:e,backend:t})=>{let{x:r}=e;(0,oe.C)(r,"square");let n=t.data.get(r.dataId).values,a=new Float32Array(n.length);for(let e=0;e<n.length;++e){let t=n[e];a[e]=t*t}return{dataId:t.write(a,r.shape,r.dtype),shape:r.shape,dtype:r.dtype}}};var h4=r(99471),h5=r(32232);let h6=(0,os.v)(R.pnw,(e,t)=>isNaN(e)?NaN:e>0?1:t.alpha),h7={kernelName:R.pnw,backendName:"cpu",kernelFunc:h6};var h9=r(28575);let h8={kernelName:R.UcO,backendName:"cpu",kernelFunc:function(e){let t,{inputs:r,backend:n,attrs:a}=e,{x:s}=r,{begin:i,end:o,strides:l,beginMask:u,endMask:h,ellipsisMask:p,newAxisMask:d,shrinkAxisMask:c}=a;(0,oe.C)(s,"stridedSlice");let{finalShapeSparse:f,finalShape:m,isIdentity:g,sliceDim0:y,isSimpleSlice:b,begin:x,end:v,strides:w}=R.Kro.sliceInfo(s.shape,i,o,l,u,h,p,d,c);if(g)t=oT({inputs:{x:s},backend:n,attrs:{shape:m}});else if(y||b){R.ZSL.assert(s.shape.length>=1,()=>`Input must have rank at least 1, got: ${s.shape.length}`);let e=R.Kro.computeOutShape(x,v,w),r=(0,o4.di)({inputs:{x:s},backend:n,attrs:{begin:x,size:e}});t=oT({inputs:{x:r},backend:n,attrs:{shape:m}}),n.disposeIntermediateTensorInfo(r)}else{let e=n.bufferSync(s),r=(0,h9.e)(f,e,w,x);t=n.makeTensorInfo(m,r.dtype,r.values)}return t}};var pe=r(3491);let pt={kernelName:R.YAb,backendName:"cpu",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{separator:a,nGramWidths:s,leftPad:i,rightPad:o,padWidth:l,preserveShortSequences:u}=n,{data:h,dataSplits:p}=t,d=r.data.get(h.dataId).values,c=r.data.get(p.dataId).values,[f,m]=(0,pe.G)(d,c,a,s,i,o,l,u);return[r.makeTensorInfo([f.length],"string",f),r.makeTensorInfo(p.shape,"int32",m)]}};var pr=r(75373);let pn={kernelName:R.iW0,backendName:"cpu",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{skipEmpty:a}=n,{input:s,delimiter:i}=t;if("string"!==s.dtype)throw Error("Input must be of datatype string");if(1!==s.shape.length)throw Error(`Input must be a vector, got shape: ${s.shape}`);if(0!==i.shape.length)throw Error(`Delimiter must be a scalar, got shape: ${i.shape}`);let o=r.data.get(s.dataId).values,l=r.data.get(i.dataId).values[0],[u,h,p]=(0,pr.S)(o,l,a),d=h.length;return[r.makeTensorInfo([d,2],"int32",u),r.makeTensorInfo([d],"string",h),r.makeTensorInfo([2],"int32",new Int32Array(p))]}};var pa=r(63110);let ps={kernelName:R.$jE,backendName:"cpu",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{numBuckets:a}=n,{input:s}=t;if("string"!==s.dtype)throw Error("Input must be of datatype string");if(a<=0)throw Error("Number of buckets must be at least 1");let i=r.data.get(s.dataId).values,o=(0,pa.f)(i,a);return r.makeTensorInfo(s.shape,"int32",o)}},pi=(0,os.v)(R.oFs,e=>Math.tan(e)),po={kernelName:R.oFs,backendName:"cpu",kernelFunc:pi},pl=(0,os.v)(R.iuW,e=>Math.tanh(e)),pu={kernelName:R.iuW,backendName:"cpu",kernelFunc:pl},ph={kernelName:R.X4r,backendName:"cpu",kernelFunc:function(e){let{inputs:t,backend:r}=e,{tensor:n,indices:a,updates:s}=t,{sliceRank:i,numUpdates:o,sliceSize:l,strides:u,outputSize:h}=R.C0T.calculateShapes(s,a,n.shape),p=r.bufferSync(a),d=r.bufferSync(s),c=r.bufferSync(n),f=(0,hA.b)(p,d,n.shape,h,l,o,i,u,c,!1);return r.makeTensorInfo(n.shape,f.dtype,f.values)}};var pp=r(3974);let pd={kernelName:R.FAs,backendName:"cpu",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{x:a}=t,{reps:s}=n;(0,oe.C)(a,"tile");let i=(0,pp.D)(r.bufferSync(a),s);return r.makeTensorInfo(i.shape,i.dtype,i.values)}};var pc=r(19770);let pf={kernelName:R.TBb,backendName:"cpu",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{x:a}=t,{k:s,sorted:i}=n;(0,oe.C)(a,"topk");let o=r.data.get(a.dataId).values,[l,u]=(0,pc.x)(o,a.shape,a.dtype,s,i);return[r.makeTensorInfo(l.shape,l.dtype,l.values),r.makeTensorInfo(u.shape,u.dtype,u.values)]}},pm={kernelName:R.dLy,backendName:"cpu",kernelFunc:function(e){let{inputs:t,attrs:r,backend:n}=e,{image:a,transforms:s}=t,{interpolation:i,fillMode:o,fillValue:l,outputShape:u}=r,[h,p,d,c]=a.shape,[f,m]=null!=u?u:[p,d],g=[h,f,m,c],y=R.ZSL.computeStrides(a.shape),b=y[0],x=y[1],v=y[2],w=R.ZSL.computeStrides(g),T=w[0],S=w[1],N=w[2],k=R.ZSL.getTypedArrayFromDType(a.dtype,R.ZSL.sizeFromShape(g));k.fill(l);let I=n.data.get(a.dataId).values,C=n.data.get(s.dataId).values;for(let e=0;e<h;++e){let t=1===s.shape[0]?C:C.subarray(8*e,8*e+8);for(let r=0;r<f;++r)for(let n=0;n<m;++n)for(let a=0;a<c;++a){let s,u=t[6]*n+t[7]*r+1;if(0===u)continue;let h=(t[0]*n+t[1]*r+t[2])/u,c=(t[3]*n+t[4]*r+t[5])/u,f=pg(h,d,o),m=pg(c,p,o);switch(i){case"nearest":s=py(I,p,d,b,x,v,e,Math.round(m),Math.round(f),a,l);break;case"bilinear":s=function(e,t,r,n,a,s,i,o,l,u,h){let p=Math.floor(o),d=Math.floor(l),c=p+1,f=d+1,m=(f-l)*py(e,t,r,n,a,s,i,p,d,u,h)+(l-d)*py(e,t,r,n,a,s,i,p,f,u,h),g=(f-l)*py(e,t,r,n,a,s,i,c,d,u,h)+(l-d)*py(e,t,r,n,a,s,i,c,f,u,h);return(c-o)*m+(o-p)*g}(I,p,d,b,x,v,e,m,f,a,l);break;default:throw Error(`Error in Transform: Expect 'nearest' or 'bilinear', but got ${i}`)}k[e*T+r*S+n*N+a]=s}return n.makeTensorInfo(g,a.dtype,k)}return{dataId:n.write(k,g,a.dtype),shape:a.shape,dtype:a.dtype}}};function pg(e,t,r){switch(r){case"reflect":var n,a,s,i,o,l=e,u=t;let h=l;if(h<0)if(u<=1)h=0;else{let e=2*u;h<e&&(h=e*Math.trunc(-h/e)+h),h=h<-u?h+e:-h-1}else if(h>u-1)if(u<=1)h=0;else{let e=2*u;(h-=e*Math.trunc(h/e))>=u&&(h=e-h-1)}return R.ZSL.clamp(0,h,u-1);case"wrap":let p;return n=e,a=t,(p=n)<0?a<=1?p=0:p+=a*(Math.trunc(-p/(a-1))+1):p>a-1&&(a<=1?p=0:p-=a*Math.trunc(p/(a-1))),R.ZSL.clamp(0,p,a-1);case"nearest":return s=e,i=t,R.ZSL.clamp(0,s,i-1);default:return o=0,e}}function py(e,t,r,n,a,s,i,o,l,u,h){return 0<=o&&o<t&&0<=l&&l<r?e[i*n+o*a+l*s+u]:h}var pb=r(46967);let px={kernelName:R.EwU,backendName:"cpu",kernelFunc:function(e){let{inputs:t,attrs:r,backend:n}=e,{axis:a}=r,{x:s}=t;(0,oe.C)(s,"unique");let i=n.data.get(s.dataId).values,{outputValues:o,outputShape:l,indices:u}=(0,pb.w)(i,a,s.shape,s.dtype);return[n.makeTensorInfo(l,s.dtype,o),n.makeTensorInfo([u.length],"int32",u)]}},pv={kernelName:R.dXR,backendName:"cpu",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{value:a}=t,{axis:s}=n;s<0&&(s+=a.shape.length);let i=a.shape.length,o=a.shape[s],l=Array(i-1),u=0;for(let e=0;e<i;e++)e!==s&&(l[u++]=a.shape[e]);let h=Array(i).fill(0),p=a.shape.slice();p[s]=1;let d=Array(o);for(let e=0;e<d.length;e++){h[s]=e;let t=(0,o4.di)({inputs:{x:a},backend:r,attrs:{begin:h,size:p}});d[e]=oT({inputs:{x:t},backend:r,attrs:{shape:l}}),r.disposeIntermediateTensorInfo(t)}return d}},pw={kernelName:R.pPe,backendName:"cpu",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{x:a,segmentIds:s}=t,{numSegments:i}=n;(0,oe.C)(a,"unsortedSegmentSum");let o=a.shape.length,l=s.shape.length,u=[],h=[],p=o-l,d=s;for(let e=0;e<p;
207++e){let t=lJ({inputs:{input:d},backend:r,attrs:{dim:e+1}});d=t,h.push(t)}for(let e=0;e<i;++e){let t=R.ZSL.createScalarValue(e,"int32"),n=r.makeTensorInfo([],"int32",t),s=(0,lG.LC)({inputs:{a:n,b:d},backend:r}),i=(0,le.wg)({inputs:{x:s},backend:r,attrs:{dtype:"float32"}}),o=(0,lM.lw)({inputs:{a:i,b:a},backend:r}),l=lz({inputs:{x:o},backend:r,attrs:{axis:0,keepDims:!1}});u.push(l),h.push(n),h.push(s),h.push(i),h.push(o),h.push(l)}let c=hn({inputs:u,backend:r,attrs:{axis:0}});return h.forEach(e=>r.disposeIntermediateTensorInfo(e)),c}};for(let e of[oI,oC.lO,oA,oF,ow.UK,oR,oD,oO,oL,oM,oz,oW,oG,oH,oY,oJ,o0,o1,o2,ok,o3,o5,o7,o9.LY,o8,le.Ml,lt.uf,ln,la.v,ls,lp,lc,lf,lm,lg,ly,lb,lv,lT,lS,lN,lk,lI,lC,lA,l$,lF,lR,l_,lD,lO,lL,lW,oo,lV,lG.RY,lq,lX.AC,l0,l1.Yp,l7,l8,ue,ut.Hc,ur.Uc,un,ua,ui,ul,uu.xp,uh.VM,ol.F,up,ll,uc,um,uy,oh,ub.YW,ux.Q,uw,uT.Fx,uN,uC,uA,uR,u_,uD,uP,uz.l9,uB,uW,uV,uG,uU,uZ,uj,uH.Nu,uK,uq,u0,lM.tJ,u1.hd,u3,u5,u7,u9.AL,u8,hr,ha,hs,hl,of,hu.S3,hp,hc,hm,hy,lu.r,l4,hx,og,ob,oS,hv,hw,hT,hS,hN,hk,hC,hE.Lt,h$,hF,hR,hL,ox.X3,hP,hB,hV,o4.lv,uJ,hZ,hj,hK,hQ,hX,hJ,h0,h1,h2.Fu,h3,h4.b2,h5.C,h7,h8,pt,pn,ps,l5.Zl,lB,po,pu,ph,pd,pf,pm,o_.W,px,pv,pw,ht])(0,R.tAK)(e);var pT=r(68484);let pS={"tfjs-core":R.bgA,"tfjs-backend-cpu":oa,"tfjs-backend-webgl":pT.version_webgl,"tfjs-data":i8,"tfjs-layers":aM.r,"tfjs-converter":it,tfjs:"4.22.0"}},65650:(e,t,r)=>{"use strict";r.d(t,{Bm:()=>f,G2:()=>l,R9:()=>d,l1:()=>u,l2:()=>h});var n=r(51520),a=r(90556),s=r(82692);function i(e){if(null!=e&&"object"!=typeof e)throw Error(`Argument to L1L2 regularizer's constructor is expected to be an object, but received: ${e}`)}class o extends n.JFn.Serializable{}class l extends o{constructor(e){super(),i(e),this.l1=null==e||null==e.l1?.01:e.l1,this.l2=null==e||null==e.l2?.01:e.l2,this.hasL1=0!==this.l1,this.hasL2=0!==this.l2}apply(e){return(0,n.DZQ)(()=>{let t=(0,n.Ul9)([1]);return this.hasL1&&(t=(0,n.WQq)(t,(0,n.czq)(n.lKK(this.l1,(0,n.tnl)(e))))),this.hasL2&&(t=(0,n.WQq)(t,(0,n.czq)(n.lKK(this.l2,a.Ew(e))))),n.tQQ(t,[])})}getConfig(){return{l1:this.l1,l2:this.l2}}static fromConfig(e,t){return new e({l1:t.l1,l2:t.l2})}}function u(e){return i(e),new l({l1:null!=e?e.l1:null,l2:0})}function h(e){return i(e),new l({l2:null!=e?e.l2:null,l1:0})}l.className="L1L2",n.JFn.registerClass(l);let p={l1l2:"L1L2"};function d(e){return(0,s.k4)(e)}function c(e,t={}){return(0,s.Xv)(e,n.JFn.SerializationMap.getMap().classNameMap,t,"regularizer")}function f(e){return null==e?null:"string"==typeof e?c({className:e in p?p[e]:e,config:{}}):e instanceof o?e:c(e)}},65737:(e,t,r)=>{"use strict";r.d(t,{P:()=>i});var n=r(19041),a=r(48592),s=r(27924);let i=(0,r(62176).op)({elu_:function(e){let t=(0,s.YT)(e,"x","elu","float32");return n.T2.runKernel(a.Pah,{x:t})}})},65952:(e,t,r)=>{"use strict";r.d(t,{I:()=>a,i:()=>s});var n=r(51520);async function a(e){if(null==e)return;let t=[],r=[],a=[];for(let n in e){let s=e[n];"number"!=typeof s&&(t.push(s.data()),r.push(n),a.push(s))}if(t.length>0){let s=await Promise.all(t);for(let t=0;t<s.length;++t)e[r[t]]=s[t][0];(0,n.ASo)(a)}}function s(e){if(null!=e)for(let t in e){let r=e[t];"number"!=typeof r&&r.dispose()}}},66025:(e,t,r)=>{"use strict";r.d(t,{z:()=>o});var n=r(19041),a=r(48592),s=r(50124),i=r(27924);let o=(0,r(62176).op)({mod_:function(e,t){let r=(0,i.YT)(e,"a","mod"),o=(0,i.YT)(t,"b","mod");[r,o]=(0,s.makeTypesMatch)(r,o);let l={a:r,b:o};return n.T2.runKernel(a.BLA,l)}})},66333:(e,t,r)=>{"use strict";r.d(t,{g:()=>f});var n=r(46213),a=r(88527),s=r(14017),i=r(48683),o=r(62176),l=r(95791),u=r(68567),h=r(63191),p=r(30319),d=r(82171),c=r(86405);let f=(0,o.op)({irfft_:function(e){let t,r=e.shape[e.shape.length-1],o=e.size/r;if(r<=2){let n=(0,u.t)(e,[o,r]);t=(0,c.K)(n)}else{let f=[o,2*(r-1)],m=(0,u.t)((0,l.x)(e),[o,r]),g=(0,u.t)((0,s.n)(e),[o,r]),y=(0,h.B)((0,d.d)(m,[0,1],[o,r-2]),1),b=(0,i.l)((0,h.B)((0,d.d)(g,[0,1],[o,r-2]),1),(0,p.d)(-1)),x=(0,a.x)([m,y],1),v=(0,a.x)([g,b],1),w=(0,u.t)((0,n.f)(x,v),[f[0],f[1]]);t=(0,c.K)(w)}if(t=(0,l.x)(t),3===e.rank&&0!==e.shape[0]){let r=t,n=e.shape[0];t=(0,u.t)(t,[n,t.shape[0]/n,t.shape[1]]),r.dispose()}return t}})},67108:(e,t,r)=>{"use strict";r.d(t,{B:()=>a});var n=r(51520);function a(){let e,t,r,a,s,i,o,l,u,h;return 2===(0,n._K2)().getNumber("WEBGL_VERSION")?(e="#version 300 es",t="in",r="out",a="in",s="texture",i="outputColor",o="out vec4 outputColor;",l=(0,n._K2)().getBool("WEBGL2_ISNAN_CUSTOM")?` 208 bool isnan_custom(float val) { 209 uint floatToUint = floatBitsToUint(val); 210 return (floatToUint & 0x7fffffffu) > 0x7f800000u; 211 } 212 213 bvec4 isnan_custom(vec4 val) { 214 return bvec4(isnan_custom(val.x), 215 isnan_custom(val.y), isnan_custom(val.z), isnan_custom(val.w)); 216 } 217 218 #define isnan(value) isnan_custom(value) 219 `:"",u="",h=` 220 #define round(value) newRound(value) 221 int newRound(float value) { 222 return int(floor(value + 0.5)); 223 } 224 225 ivec4 newRound(vec4 value) { 226 return ivec4(floor(value + vec4(0.5))); 227 } 228 `):(e="",t="attribute",r="varying",a="varying",s="texture2D",i="gl_FragColor",o="",l=` 229 #define isnan(value) isnan_custom(value) 230 bool isnan_custom(float val) { 231 return (val > 0. || val < 1. || val == 0.) ? false : true; 232 } 233 bvec4 isnan_custom(vec4 val) { 234 return bvec4(isnan(val.x), isnan(val.y), isnan(val.z), isnan(val.w)); 235 } 236 `,u=` 237 uniform float INFINITY; 238 239 bool isinf(float val) { 240 return abs(val) == INFINITY; 241 } 242 bvec4 isinf(vec4 val) { 243 return equal(abs(val), vec4(INFINITY)); 244 } 245 `,h=` 246 int round(float value) { 247 return int(floor(value + 0.5)); 248 } 249 250 ivec4 round(vec4 value) { 251 return ivec4(floor(value + vec4(0.5))); 252 } 253 `),{version:e,attribute:t,varyingVs:r,varyingFs:a,texture2D:s,output:i,defineOutput:o,defineSpecialNaN:l,defineSpecialInf:u,defineRound:h}}},67329:(e,t,r)=>{"use strict";r.d(t,{L:()=>i});var n=r(19041),a=r(48592),s=r(27924);let i=(0,r(62176).op)({round_:function(e){let t=(0,s.YT)(e,"x","round");return n.T2.runKernel(a.hVg,{x:t})}})},67454:(e,t,r)=>{"use strict";r.d(t,{N:()=>o});var n=r(19041),a=r(48592),s=r(50124),i=r(27924);let o=(0,r(62176).op)({matMul_:function(e,t,r=!1,o=!1){let l=(0,i.YT)(e,"a","matMul"),u=(0,i.YT)(t,"b","matMul");[l,u]=(0,s.makeTypesMatch)(l,u);let h={a:l,b:u};return n.T2.runKernel(a.jAQ,h,{transposeA:r,transposeB:o})}})},67562:(e,t,r)=>{"use strict";r.d(t,{K:()=>u});var n=r(19041),a=r(48592),s=r(27924),i=r(76526),o=r(62176),l=r(68567);let u=(0,o.op)({localResponseNormalization_:function(e,t=5,r=1,o=1,u=.5){let h=(0,s.YT)(e,"x","localResponseNormalization");i.vA(4===h.rank||3===h.rank,()=>`Error in localResponseNormalization: x must be rank 3 or 4 but got 254 rank ${h.rank}.`),i.vA(i.E6(t),()=>`Error in localResponseNormalization: depthRadius must be an integer but got depthRadius ${t}.`);let p=h,d=!1;3===h.rank&&(d=!0,p=(0,l.t)(h,[1,h.shape[0],h.shape[1],h.shape[2]]));let c={x:p},f=n.T2.runKernel(a.jM4,c,{depthRadius:t,bias:r,alpha:o,beta:u});return d?(0,l.t)(f,[f.shape[1],f.shape[2],f.shape[3]]):f}})},68484:(e,t,r)=>{"use strict";let n;r.r(t),r.d(t,{GPGPUContext:()=>
254p.n,MathBackendWebGL:()=>i.Q6,forceHalfFloat:()=>d,gpgpu_util:()=>l,setWebGLContext:()=>h.lj,version_webgl:()=>o,webgl:()=>c,webgl_util:()=>u});var a,s=r(51520),i=r(68795);let o="4.22.0";var l=r(20783),u=r(26981),h=r(47700),p=r(34726);function d(){(0,s._K2)().set("WEBGL_FORCE_F16_TEXTURES",!0)}s.eMq.isBrowser()&&(0,s.gJX)("webgl",()=>new i.Q6,2);let c={forceHalfFloat:d};var f=r(71553);let m=` 255 if (isnan(a)) return a; 256 if (isnan(b)) return b; 257`;class g{constructor(e,t,r){this.variableNames=["A","B"],this.outputShape=s.C0T.assertAndGetBroadcastShape(t,r),this.enableShapeUniforms=(0,f.ik)(this.outputShape.length),this.userCode=` 258 float binaryOperation(float a, float b) { 259 ${e} 260 } 261 262 void main() { 263 float a = getAAtOutCoords(); 264 float b = getBAtOutCoords(); 265 setOutput(binaryOperation(a, b)); 266 } 267 `}}var y=r(25223),b=r(90670);let x=` 268 result.r = isNaN.r ? NAN : result.r; 269 result.g = isNaN.g ? NAN : result.g; 270 result.b = isNaN.b ? NAN : result.b; 271 result.a = isNaN.a ? NAN : result.a; 272`;class v{constructor(e,t,r,n=!1){this.variableNames=["A","B"],this.supportsBroadcasting=!0,this.packedInputs=!0,this.packedOutput=!0,this.outputShape=s.C0T.assertAndGetBroadcastShape(t,r);let a=this.outputShape.length;this.enableShapeUniforms=(0,f.ik)(a);let i="";if(n)if(0===a||1===s.ZSL.sizeFromShape(this.outputShape))i=` 273 result.y = 0.; 274 result.z = 0.; 275 result.w = 0.; 276 `;else{let e=(0,b.bf)(a);if(i=` 277 ${e} coords = getOutputCoords(); 278 `,1===a)this.enableShapeUniforms?i+=` 279 result.y = (coords + 1) >= outShape ? 0. : result.y; 280 result.z = 0.; 281 result.w = 0.; 282 `:i+=` 283 result.y = (coords + 1) >= ${this.outputShape[0]} ? 0. : result.y; 284 result.z = 0.; 285 result.w = 0.; 286 `;else{let e=(0,y.Jp)("coords",a);this.enableShapeUniforms?i+=` 287 bool nextRowOutOfBounds = 288 (${e[a-2]} + 1) >= outShape[${a} - 2]; 289 bool nextColOutOfBounds = 290 (${e[a-1]} + 1) >= outShape[${a} - 1]; 291 result.y = nextColOutOfBounds ? 0. : result.y; 292 result.z = nextRowOutOfBounds ? 0. : result.z; 293 result.w = nextColOutOfBounds || nextRowOutOfBounds ? 0. : result.w; 294 `:i+=` 295 bool nextRowOutOfBounds = 296 (${e[a-2]} + 1) >= ${this.outputShape[a-2]}; 297 bool nextColOutOfBounds = 298 (${e[a-1]} + 1) >= ${this.outputShape[a-1]}; 299 result.y = nextColOutOfBounds ? 0. : result.y; 300 result.z = nextRowOutOfBounds ? 0. : result.z; 301 result.w = nextColOutOfBounds || nextRowOutOfBounds ? 0. : result.w; 302 `}}this.userCode=` 303 vec4 binaryOperation(vec4 a, vec4 b) { 304 ${e} 305 } 306 307 void main() { 308 vec4 a = getAAtOutCoords(); 309 vec4 b = getBAtOutCoords(); 310 311 vec4 result = binaryOperation(a, b); 312 ${i} 313 314 setOutput(result); 315 } 316 `}}function w(e){let{inputs:t,backend:r}=e,{x:n}=t;return r.incRef(n.dataId),{dataId:n.dataId,shape:n.shape,dtype:n.dtype}}let T={kernelName:s.lzr,backendName:"webgl",kernelFunc:w};function S(e){let{inputs:t,backend:r}=e,{real:n,imag:a}=t,s=r.makeTensorInfo(n.shape,"complex64"),i=r.texData.get(s.dataId);return i.complexTensorInfos={real:w({inputs:{x:n},backend:r}),imag:w({inputs:{x:a},backend:r})},s}let N={kernelName:s.pr3,backendName:"webgl",kernelFunc:S},k="return (a < 0.) ? b * a : a;",I=` 317 vec4 aLessThanZero = vec4(lessThan(a, vec4(0.)));
318 return (aLessThanZero * (b * a)) + ((vec4(1.0) - aLessThanZero) * a); 319`,C={kernelName:s.X0$,backendName:"webgl",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{x:a}=t,{alpha:i}=n,o=r.makeTensorInfo([],"float32",s.ZSL.createScalarValue(i,"float32")),l=(0,s._K2)().getBool("WEBGL_PACK_BINARY_OPERATIONS")?new v(I,a.shape,o.shape):new g(k,a.shape,o.shape),u=r.runWebGLProgram(l,[a,o],"float32");return r.disposeIntermediateTensorInfo(o),u}},E="return (a < 0.) ? b * a : a;",A=` 320 vec4 aLessThanZero = vec4(lessThan(a, vec4(0.))); 321 return (aLessThanZero * (b * a)) + ((vec4(1.0) - aLessThanZero) * a); 322`,$={kernelName:s.Ncv,backendName:"webgl",kernelFunc:function(e){let{inputs:t,backend:r}=e,{x:n,alpha:a}=t,i=(0,s._K2)().getBool("WEBGL_PACK_BINARY_OPERATIONS")?new v(A,n.shape,a.shape):new g(E,n.shape,a.shape);return r.runWebGLProgram(i,[n,a],"float32")}};var F=r(77308),R=r(65211);let _="if (isnan(x)) return x;";function D({opSnippet:e,packedOpSnippet:t,cpuKernelImpl:r,dtype:n}){return({inputs:a,backend:i})=>{let o,{x:l}=a,u=n||l.dtype;if(i.shouldExecuteOnCPU([l])&&null!=r){let e=r(i.texData.get(l.dataId).values,u);return i.makeTensorInfo(l.shape,u,e)}return o=(0,s._K2)().getBool("WEBGL_PACK_UNARY_OPERATIONS")&&null!=t?new R.rf(l.shape,t):new F.hE(l.shape,e),i.runWebGLProgram(o,[l],u)}}function O({opSnippet:e,packedOpSnippet:t,checkOutOfBounds:r=!1,supportsComplex:n=!1,cpuKernelImpl:a,dtype:i}){return({inputs:o,backend:l})=>{let u,{a:h,b:p}=o;if(n&&"complex64"===h.dtype){let t=l.texData.get(h.dataId),r=l.texData.get(p.dataId),[n,a]=[[t.complexTensorInfos.real,r.complexTensorInfos.real],[t.complexTensorInfos.imag,r.complexTensorInfos.imag]].map(t=>{let[r,n]=t,a={dataId:r.dataId,dtype:r.dtype,shape:h.shape},i={dataId:n.dataId,dtype:n.dtype,shape:p.shape},o=new g(e,h.shape,p.shape);return l.runWebGLProgram(o,[a,i],(0,s.TuY)(r.dtype,n.dtype))}
322),i=S({inputs:{real:n,imag:a},backend:l});return l.disposeIntermediateTensorInfo(n),l.disposeIntermediateTensorInfo(a),i}let d=i||(0,s.TuY)(h.dtype,p.dtype);if(("string"===h.dtype||"string"===p.dtype||l.shouldExecuteOnCPU([h,p]))&&null!=a){let e=l.texData.get(h.dataId).values,t=l.texData.get(p.dataId).values,r="string"===h.dtype?s.C0T.fromUint8ToStringArray(e):e,n="string"===h.dtype?s.C0T.fromUint8ToStringArray(t):t,[i,o]=a(h.shape,p.shape,r,n,d),u=l.makeTensorInfo(o,d);return l.texData.get(u.dataId).values=i,u}return u=(0,s._K2)().getBool("WEBGL_PACK_BINARY_OPERATIONS")&&null!=t?new v(t,h.shape,p.shape,r):new g(e,h.shape,p.shape),l.runWebGLProgram(u,[h,p],d)}}function L(e,t=!1){if("linear"===e)return t?R._Q:F._Q;if("relu"===e)return t?R.X8:F.X8;if("elu"===e)return t?R.X0:F.X0;if("relu6"===e)return t?R.Nb:F.Nb;if("prelu"===e)return t?A:E;else if("leakyrelu"===e)return t?I:k;else if("sigmoid"===e)return t?R.Hq:F.Hq;throw Error(`Activation ${e} has not been implemented for the WebGL backend.`)}class M{constructor(e,t,r,n=!1,a=!1,s=!1,i=null,o=!1,l=!1){this.variableNames=["matrixA","matrixB"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=r,this.enableShapeUniforms=(0,f.ik)(this.outputShape.length);let u=Math.ceil((n?e[1]:e[2])/2),h=n?["a.xxyy","a.zzww"]:["a.xxzz","a.yyww"],p=a?["b.xzxz","b.ywyw"]:["b.xyxy","b.zwzw"],d="",c="";i&&(d=o?`vec4 activation(vec4 a) { 323 vec4 b = getPreluActivationWeightsAtOutCoords(); 324 ${i} 325 }`:l?`vec4 activation(vec4 a) { 326 vec4 b = getLeakyreluAlphaAtOutCoords(); 327 ${i} 328 }`:`vec4 activation(vec4 x) { 329 ${i} 330 }`,c="result = activation(result);"),s&&this.variableNames.push("bias"),o&&this.variableNames.push("preluActivationWeights"),l&&this.variableNames.push("leakyreluAlpha");let m="rc.x",g="rc.x";e[0]<t[0]?m=`imod(rc.x, ${e[0]})`:t[0]<e[0]&&(g=`imod(rc.x, ${t[0]})`),this.userCode=` 331 ${d} 332 // Don't use uniform for sharedDimensionPacked for performance. 333 const float sharedDimension = ${u}.0; 334 335 vec4 dot2x2ARowBCol(ivec3 rc) { 336 vec4 result = vec4(0); 337 int batchA = ${m}; 338 int batchB = ${g}; 339 for (int i = 0; i < ${u}; i++) { 340 vec4 a = getMatrixA(batchA, ${n?"i * 2, rc.y":"rc.y, i * 2"}); 341 vec4 b = getMatrixB(batchB, ${a?"rc.z, i * 2":"i * 2, rc.z"}); 342 343 // These swizzled products need to be separately added.
344 // See: https://github.com/tensorflow/tfjs/issues/1735 345 result += (${h[0]} * ${p[0]}); 346 result += (${h[1]} * ${p[1]}); 347 } 348 return result; 349 } 350 351 void main() { 352 ivec3 rc = getOutputCoords(); 353 vec4 result = dot2x2ARowBCol(rc); 354 355 ${s?"result += getBiasAtOutCoords();":""} 356 357 ${c} 358 359 setOutput(result); 360 } 361 `}}let P={REAL:"return areal * breal - aimag * bimag;",IMAG:"return areal * bimag + aimag * breal;"};class z{constructor(e,t,r){this.variableNames=["AReal","AImag","BReal","BImag"],this.outputShape=s.C0T.assertAndGetBroadcastShape(t,r),this.userCode=` 362 float binaryOpComplex( 363 float areal, float aimag, float breal, float bimag) { 364 ${e} 365 } 366 367 void main() { 368 float areal = getARealAtOutCoords(); 369 float aimag = getAImagAtOutCoords(); 370 float breal = getBRealAtOutCoords(); 371 float bimag = getBImagAtOutCoords(); 372 setOutput(binaryOpComplex(areal, aimag, breal, bimag)); 373 } 374 `}}var B=r(22064);let W="return a * b;";function V(e){let t,{inputs:r,backend:n}=e,{a,b:i}=r,o=s.C0T.upcastType(a.dtype,i.dtype);if("complex64"===a.dtype){let e=n.texData.get(a.dataId),t=n.texData.get(i.dataId),r=new z(P.REAL,a.shape,i.shape),s=new z(P.IMAG,a.shape,i.shape),o=[{dataId:e.complexTensorInfos.real.dataId,dtype:e.complexTensorInfos.real.dtype,shape:a.shape},{dataId:e.complexTensorInfos.imag.dataId,dtype:e.complexTensorInfos.imag.dtype,shape:a.shape},{dataId:t.complexTensorInfos.real.dataId,dtype:t.complexTensorInfos.real.dtype,shape:i.shape},{dataId:t.complexTensorInfos.imag.dataId,dtype:t.complexTensorInfos.imag.dtype,shape:i.shape}],l=n.runWebGLProgram(r,o,"float32"),u=n.runWebGLProgram(s,o,"float32"),h=S({inputs:{real:l,imag:u},backend:n});return n.disposeIntermediateTensorInfo(l),n.disposeIntermediateTensorInfo(u),h}if(n.shouldExecuteOnCPU([a,i])){let e=n.texData.get(a.dataId),t=n.texData.get(i.dataId),[r,s]=(0,B.Xe)(a.shape,i.shape,e.values,t.values,o),l=n.makeTensorInfo(s,o);return n.texData.get(l.dataId).values=r,l}return t=(0,s._K2)().getBool("WEBGL_PACK_BINARY_OPERATIONS")?new v(W,a.shape,i.shape):new g(W,a.shape,i.shape),n.runWebGLProgram(t,[a,i],o)}let G={kernelName:s.xu7,backendName:"webgl",kernelFunc:V};var U=r(44373);function Z(e){let{inputs:t,backend:r,attrs:n}=e,{x:a}=t,{shape:i}=n,o=s.ZSL.sizeFromShape(a.shape),l=s.ZSL.inferFromImplicitShape(i,o),h=s.ZSL.sizeFromShape(l);s.ZSL.assert(o===h,()=>`The new shape (${l}) has ${h} elements and the old shape (${a.shape}) has ${o} elements. The new shape and old shape must have the same number of elements.`);let p=r.texData.get(a.dataId);return!p.isPacked||(0,u.isReshapeFree)(a.shape,l)||null!==p.texture&&(0,u.isReshapeFree)(p.shape,l)?(r.incRef(a.dataId),{dataId:a.dataId,shape:l,dtype:a.dtype}):function(e,t,r){let n=[(0,u.getBatchDim)(e.shape),...(0,u.getRowsCols)(e.shape)],a={dtype:e.dtype,shape:n,dataId:e.dataId},s=[(0,u.getBatchDim)(t),...(0,u.getRowsCols)(t)],i=new U.R(s,n),o=r.runWebGLProgram(i,[a],e.dtype,[n],!0);return{dataId:o.dataId,shape:t,dtype:o.dtype}}(a,l,r)}let j={kernelName:s.R23,backendName:"webgl",kernelFunc:Z};class H{constructor(e,t){this.variableNames=["x"];let{windowSize:r,batchSize:n,inSize:a,outSize:i}=e;this.outputShape=[n,i];let o=4*Math.floor(r/4),l=r%4,u="sumValue += dot(values, ones);";if(null!=t){let e=1/t;u=`sumValue += dot(values * ${s.ZSL.isInt(e)?e.toPrecision(2):e}, ones);`}let h="";a%r>0&&(h=` 375 if (inIdx < 0 || inIdx >= ${a}) { 376 return 0.0; 377 } 378 `),this.userCode=` 379 const vec4 ones = vec4(1.0, 1.0, 1.0, 1.0); 380 381 float getValue(int batch, int inIdx) { 382 ${h} 383 return getX(batch, inIdx); 384 } 385 386 void main() { 387 ivec2 coords = getOutputCoords(); 388 int batch = coords[0]; 389 int outIdx = coords[1]; 390 int inOffset = outIdx * ${r}; 391 392 float sumValue = 0.0; 393 394 for (int i = 0; i < ${o}; i += 4) { 395 int inIdx = inOffset + i; 396 vec4 values = vec4( 397 getValue(batch, inIdx), 398 getValue(batch, inIdx + 1), 399 getValue(batch, inIdx + 2), 400 getValue(batch, inIdx + 3) 401 ); 402 403 ${u} 404 } 405 406 int inIdx = inOffset + ${o}; 407 if (${1===l}) { 408 vec4 values = vec4(getValue(batch, inIdx), 0.0, 0.0, 0.0); 409 410 ${u} 411 } else if (${2===l}) { 412 vec4 values = vec4( 413 getValue(batch, inIdx), 414 getValue(batch, inIdx + 1), 0.0, 0.0); 415 416 ${u} 417 } else if (${3===l}) { 418 vec4 values = vec4( 419 getValue(batch, inIdx), 420 getValue(batch, inIdx + 1), 421 getValue(batch, inIdx + 2), 0.0); 422 423 ${u} 424 } 425 setOutput(sumValue); 426 } 427 `}}class K{constructor(e,t){this.variableNames=["x"];let{windowSize:r,batchSize:n,inSize:a,outSize:s}=e;this.outputShape=[n,s];let i="0.0",o="";"prod"===t?i="1.0":"min"===t?(i="1.0 / 1e-20",o="min"):"max"===t&&(i="-1.0 / 1e-20",o="max");let l=`${t}(${t}(${t}(minMaxValue[0], minMaxValue[1]), minMaxValue[2]), minMaxValue[3])`;"sum"===t?l="sumValue":"prod"===t?l="prodValue":"all"===t?l="allValue":"any"===t&&(l="anyValue");let u=4*Math.floor(r/4),h=r%4,p=` 428 if (${"sum"===t}) { 429 sumValue += dot(values, ones); 430 } else if (${"prod"===t}) { 431 vec2 tmp = vec2(values[0], values[1]) * vec2(values[2], values[3]); 432 prodValue *= tmp[0] * tmp[1]; 433 } else { 434 minMaxValue = ${o}(values, minMaxValue); 435 if (${"min"===t} || ${"max"===t}) { 436 minMaxValue = ${o}(values, minMaxValue); 437 bvec4 isNaN = isnan(values); 438 if (isNaN.r || isNaN.g || isNaN.b || isNaN.a) { 439 minMaxValue = vec4(NAN); 440 } 441 } 442 } 443 `,d="vec4";"all"===t?(i="1.0",p=` 444 bool reducedAllValue = all(values); 445 float floatedReducedAllValue = float(reducedAllValue); 446 allValue = float(allValue >= 1.0 && floatedReducedAllValue >= 1.0); 447 `,d="bvec4"):"any"===t&&(i="0.0",p=` 448 bool reducedAnyValue = any(values); 449 float floatedReducedAnyValue = float(reducedAnyValue); 450 anyValue = float(anyValue >= 1.0 || floatedReducedAnyValue >= 1.0); 451 `,d="bvec4");let c="";a%r>0&&(c=` 452 if (inIdx < 0 || inIdx >= ${a}) { 453 return initializationValue; 454 } 455 `),this.userCode=` 456 const float initializationValue = ${i}; 457 const vec4 ones = vec4(1.0, 1.0, 1.0, 1.0); 458 459 float getValue(int batch, int inIdx) { 460 ${c} 461 return getX(batch, inIdx); 462 } 463 464 void main() { 465 ivec2 coords = getOutputCoords(); 466 int batch = coords[0]; 467 int outIdx = coords[1]; 468 int inOffset = outIdx * ${r}; 469 470 vec4 minMaxValue = vec4(${i}); 471 float prodValue = 1.0; 472 float sumValue = 0.0; 473 float allValue = 1.0; 474 float anyValue = 0.0; 475 476 for (int i = 0; i < ${u}; i += 4) { 477 int inIdx = inOffset + i; 478 ${d} values = ${d}( 479 getValue(batch, inIdx), 480 getValue(batch, inIdx + 1), 481 getValue(batch, inIdx + 2), 482 getValue(batch, inIdx + 3) 483 ); 484 485 ${p} 486 } 487 488 int inIdx = inOffset + ${u}; 489 if (${1===h}) { 490 ${d} values = ${d}( 491 getValue(batch, inIdx), 492 initializationValue, 493 initializationValue, 494 initializationValue 495 ); 496 497 ${p} 498 } else if (${2===h}) { 499 ${d} values = ${d}( 500 getValue(batch, inIdx), 501 getValue(batch, inIdx + 1), 502 initializationValue, 503 initializationValue 504 ); 505 506 ${p} 507 } else if (${3===h}) { 508 ${d} values = ${d}( 509 getValue(batch, inIdx), 510 getValue(batch, inIdx + 1), 511 getValue(batch, inIdx + 2), 512 initializationValue 513 ); 514 515 ${p} 516 } 517 setOutput(${l}); 518 } 519 `}}function Y(e,t,r,n){let a=function(e){let t=[];for(;0===t.length||1!==t[t.length-1].outSize;){let r=t.length?t[t.length-1].outSize:e[1],n=s.C0T.computeOptimalWindowSize(r);t.push({inSize:r,windowSize:n,outSize:Math.ceil(r/n)})}return t}(e.shape),i=e;for(let s=0;s<a.length;s++){let o,l,{inSize:u,windowSize:h,outSize:p}=a[s];o="mean"===r?0===s?new H({windowSize:h,inSize:u,batchSize:e.shape[0],outSize:p},u):new H({windowSize:h,inSize:u,batchSize:e.shape[0],outSize:p}):new K({windowSize:h,inSize:u,batchSize:e.shape[0],outSize:p},r),l=i,i=n.runWebGLProgram(o,[i],t),l.dataId!==e.dataId&&n.disposeIntermediateTensorInfo(l)}return i}class Q{constructor(e,t){this.variableNames=["A"];let r=Array(e.length);for(let n=0;n<r.length;n++)r[n]=e[t[n]];this.outputShape=r,this.rank=r.length;let n=(0,b.bf)(this.rank),a=function(e){let t=e.length;if(t>6)throw Error(`Transpose for rank ${t} is not yet supported`);let r=["resRC.x","resRC.y","resRC.z","resRC.w","resRC.u","resRC.v"],n=Array(t);for(let t=0;t<e.length;t++)n[e[t]]=r[t];return n.join()}(t);this.userCode=` 520 void main() { 521 ${n} resRC = getOutputCoords(); 522 setOutput(getA(${a})); 523 } 524 `}}class q{constructor(e,t){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0;let r=Array(e.length);for(let n=0;n<r.length;n++)r[n]=e[t[n]];if(this.outputShape=r,this.rank=r.length,this.rank>6)throw Error(`Packed transpose for rank ${this.rank} is not yet supported.`);let n=(0,b.bf)(this.rank),a=(0,y.Fd)("rc",this.rank),s=Array(this.rank);for(let e=0;e<t.length;e++)s[t[e]]=a[e];let i=`vec2(${s.slice(-2).join()})`,o=`++${a[this.rank-1]} < ${r[this.rank-1]}`,l=`getChannel(getA(${s.join()}), ${i})`;this.userCode=` 525 void main() { 526 ${n} rc = getOutputCoords(); 527 vec4 result = vec4(0.); 528 result[0] = ${l}; 529 if(${o}) { 530 result[1] = ${l}; 531 } 532 --${a[this.rank-1]}; 533 if(++${a[this.rank-2]} < ${r[this.rank-2]}) { 534 result[2] = ${l}; 535 if(${o}) { 536 result[3] = ${l}; 537 } 538 } 539 setOutput(result); 540 } 541 `}}function X(e,t,r){let n=(0,s._K2)().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new q(e.shape,t):new Q(e.shape,t);return r.runWebGLProgram(n,[e],e.dtype)}function J(e){let{inputs:t,backend:r,attrs:n}=e,{x:a}=t,{axis:i,keepDims:o}=n;return function(e,t,r,n){let a=e.shape.length,i=s.ZSL.parseAxisParam(t,e.shape),o=i,l=s.C0T.getAxesPermutation(o,a),u=null!=l,h=e;u&&(h=X(e,l,n),o=s.C0T.getInnerMostAxes(o.length,a)),s.C0T.assertAxesAreInnerMostDims("sum",o,a);let[p,d]=s.C0T.computeOutAndReduceShapes(h.shape,o),c=p;r&&(c=s.C0T.expandShapeToKeepDim(p,i));let f=s.ZSL.sizeFromShape(d),m=Z({inputs:{x:h},attrs:{shape:[s.ZSL.sizeFromShape(e.shape)/f,f]},backend:n}),g=Y(m,(0,s.chL)(e.dtype),"sum",n),y=Z({inputs:{x:g},attrs:{shape:c},backend:n});return n.disposeIntermediateTensorInfo(m),n.disposeIntermediateTensorInfo(g),u&&n.disposeIntermediateTensorInfo(h),y}(a,i,o,r)}let ee={kernelName:s.WuN,backendName:"webgl",kernelFunc:J};function et(e){let t,{inputs:r,backend:n,attrs:a}=e,{x:s}=r,{perm:i}=a,o=Array(s.shape.length);for(let e=0;e<o.length;e++)o[e]=s.shape[i[e]];if(n.shouldExecuteOnCPU([s])){let e=n.texData.get(s.dataId).values,r=(0,B.Q5)(e,s.shape,s.dtype,i,o);t=n.makeTensorInfo(o,s.dtype),n.texData.get(t.dataId).values=r}else t=X(s,i,n);return t}let er={kernelName:s.wx0,backendName:"webgl",kernelFunc:et};function en({a:e,b:t,transposeA:r,transposeB:n,backend:a,bias:i=null,preluActivationWeights:o=null,leakyreluAlpha:l=0,activation:u=null}){let h,p=e.shape.length,d=t.shape.length,c=r?e.shape[p-2]:e.shape[p-1],f=n?t.shape[d-1]:t.shape[d-2],m=r?e.shape[p-1]:e.shape[p-2],g=n?t.shape[d-2]:t.shape[d-1],y=e.shape.slice(0,-2),b=t.shape.slice(0,-2),x=s.ZSL.sizeFromShape(y),v=s.ZSL.sizeFromShape(b),w=s.ZEY.assertAndGetBroadcastShape(e.shape.slice(0,-2),t.shape.slice(0,-2)).c
541oncat([m,g]);s.ZSL.assert(c===f,()=>`Error in matMul: inner shapes (${c}) and (${f}) of Tensors with shapes ${e.shape} and ${t.shape} and transposeA=${r} and transposeB=${n} must match.`);let T=r?[x,c,m]:[x,m,c],S=n?[v,g,f]:[v,f,g],N=Z({inputs:{x:e},backend:a,attrs:{shape:T}}),k=Z({inputs:{x:t},backend:a,attrs:{shape:S}}),I=[N,k],C=Math.max(x,v),E=r?N.shape[1]:N.shape[2],A=null!=i,$=null!=o,F="leakyrelu"===u,R=null!=u?L(u,!0):null,_=A||$||F||null!=R;if((1===m||1===g)&&E>1e3&&!1===_){let e=N,t=k;r&&(e=et({inputs:{x:N},backend:a,attrs:{perm:[0,2,1]}}),I.push(e)),n&&(t=et({inputs:{x:k},backend:a,attrs:{perm:[0,2,1]}}),I.push(t));let s=1!==g,i=1===g,o=e;s&&(o=Z({inputs:{x:e},backend:a,attrs:{shape:[C,E,1]}}),I.push(o));let l=t;i&&(l=Z({inputs:{x:t},backend:a,attrs:{shape:[C,1,E]}}),I.push(l));let u=V({inputs:{a:o,b:l},backend:a});h=J({inputs:{x:u},backend:a,attrs:{axis:1===g?2:1,keepDims:!0}}),I.push(u)}else{let u=(0,s.TuY)(e.dtype,t.dtype),p=new M(T,S,[C,m,g],r,n,A,R,$,F),d=[N,k];if(null!=i&&d.push(i),$&&d.push(o),F){let e=a.makeTensorInfo([],"float32",s.ZSL.createScalarValue(l,"float32"));d.push(e),I.push(e)}h=a.runWebGLProgram(p,d,u)}let D=Z({inputs:{x:h},backend:a,attrs:{shape:w}});for(let e of(I.push(h),I))a.disposeIntermediateTensorInfo(e);return D}let ea={kernelName:s.Dr,backendName:"webgl",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{a,b:s,bias:i,preluActivationWeights:o}=t,{transposeA:l,transposeB:u,activation:h,leakyreluAlpha:p}=n;return en({a,b:s,transposeA:l,transposeB:u,backend:r,bias:i,preluActivationWeights:o,leakyreluAlpha:p,activation:h})}},es="return abs(x);",ei={kernelName:s.ljI,backendName:"webgl",kernelFunc:function(e){let t,{inputs:r,backend:n}=e,{x:a}=r;if(n.shouldExecuteOnCPU([a])&&"complex64"!==a.dtype){let e=n.texData.get(a.dataId),t=(0,B.f8)(e.values);return n.makeTensorInfo(a.shape,a.dtype,t)}return t=(0,s._K2)().getBool("WEBGL_PACK_UNARY_OPERATIONS")?new R.rf(a.shape,es):new F.hE(a.shape,es),n.runWebGLProgram(t,[a],a.dtype)}},eo=D({opSnippet:F.dR+` 542 if (abs(x) > 1.) { 543 return NAN; 544 } 545 return acos(x); 546`}),el={kernelName:s.Vvy,backendName:"webgl",kernelFunc:eo},eu=D({opSnippet:F.dR+` 547 if (x < 1.0) return NAN; 548return log(x + sqrt(x * x - 1.0));`}),eh={kernelName:s.PH8,backendName:"webgl",kernelFunc:eu},ep="return a + b;",ed=O({opSnippet:ep,packedOpSnippet:ep,supportsComplex:!0,cpuKernelImpl:B.Gs}),ec={kernelName:s.OMN,backendName:"webgl",kernelFunc:ed};class ef{constructor(e,t){this.outputShape=[],this.outputShape=e,this.variableNames=t.map((e,t)=>`T${t}`);let r=[];this.variableNames.forEach(e=>{r.push(`float v${e} = get${e}AtOutCoords();`)});let n=this.variableNames.map(e=>`v${e}`).join(" + ");this.userCode=` 549 void main() { 550 ${r.join("\n ")} 551 552 float result = ${n}; 553 setOutput(result); 554 } 555 `}}class em{constructor(e,t){this.outputShape=[],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=e,this.variableNames=t.map((e,t)=>`T${t}`);let r=[];this.variableNames.forEach(e=>{r.push(`vec4 v${e} = get${e}AtOutCoords();`)});let n=this.variableNames.map(e=>`v${e}`).join(" + ");this.userCode=` 556 void main() { 557 ${r.join("\n ")} 558 559 vec4 result = ${n}; 560 setOutput(result); 561 } 562 `}}let eg={kernelName:s.EkD,backendName:"webgl",kernelFunc:function e(t){let{inputs:r,backend:n}=t;if(1===r.length)return w({inputs:{x:r[0]},backend:n});if(r.length>(0,s._K2)().getNumber("WEBGL_MAX_TEXTURES_IN_SHADER")){let t=Math.floor(r.length/2),a=e({inputs:r.slice(0,t),backend:n}),s=e({inputs:r.slice(t),backend:n});return e({inputs:[a,s],backend:n})}let a=r.map(e=>e.dtype).reduce((e,t)=>(0,s.TuY)(e,t)),i=r.map(e=>e.shape),o=(0,s._K2)().getBool("WEBGL_PACK")?new em(r[0].shape,i):new ef(r[0].shape,i);return n.runWebGLProgram(o,r,a)}},ey={kernelName:s.u8Z,backendName:"webgl",kernelFunc:function(e){let t,{inputs:r,backend:n,attrs:a}=e,{x:i}=r,{axis:o,keepDims:l}=a,u=i.shape.length,h=s.ZSL.parseAxisParam(o,i.shape),p=h,d=s.C0T.getAxesPermutation(p,u),c=i;null!=d&&(c=et({inputs:{x:i},backend:n,attrs:{perm:d}}),p=s.C0T.getInnerMostAxes(p.length,u)),s.C0T.assertAxesAreInnerMostDims("all",p,u);let[f,m]=s.C0T.computeOutAndReduceShapes(c.shape,p),g=Z({inputs:{x:c},backend:n,attrs:{shape:[-1,s.ZSL.sizeFromShape(m)]}}),y=Y(g,g.dtype,"all",n);
562return t=l?Z({inputs:{x:y},backend:n,attrs:{shape:s.C0T.expandShapeToKeepDim(f,h)}}):Z({inputs:{x:y},backend:n,attrs:{shape:f}}),n.disposeIntermediateTensorInfo(g),n.disposeIntermediateTensorInfo(y),null!=d&&n.disposeIntermediateTensorInfo(c),t}},eb={kernelName:s.FSt,backendName:"webgl",kernelFunc:function(e){let t,{inputs:r,backend:n,attrs:a}=e,{x:i}=r,{axis:o,keepDims:l}=a,u=i.shape.length,h=s.ZSL.parseAxisParam(o,i.shape),p=h,d=s.C0T.getAxesPermutation(p,u),c=i;null!=d&&(c=et({inputs:{x:i},backend:n,attrs:{perm:d}}),p=s.C0T.getInnerMostAxes(p.length,u)),s.C0T.assertAxesAreInnerMostDims("any",p,u);let[f,m]=s.C0T.computeOutAndReduceShapes(c.shape,p),g=Z({inputs:{x:c},backend:n,attrs:{shape:[-1,s.ZSL.sizeFromShape(m)]}}),y=Y(g,g.dtype,"any",n);return t=l?Z({inputs:{x:y},backend:n,attrs:{shape:s.C0T.expandShapeToKeepDim(f,h)}}):Z({inputs:{x:y},backend:n,attrs:{shape:f}}),n.disposeIntermediateTensorInfo(g),n.disposeIntermediateTensorInfo(y),null!=d&&n.disposeIntermediateTensorInfo(c),t}};class ex{constructor(e,t,r){this.variableNames=["A"];let{windowSize:n,batchSize:a,outSize:s}=e;r||this.variableNames.push("bestIndicesA"),this.outputShape=[a,s],this.userCode=` 563 void main() { 564 ivec2 coords = getOutputCoords(); 565 int batch = coords[0]; 566 int outIdx = coords[1]; 567 int inOffset = outIdx * ${n}; 568 569 int bestIndex = inOffset; 570 float bestValue = getA(batch, bestIndex); 571 572 for (int i = 0; i < ${n}; i++) { 573 int inIdx = ${r?"inOffset + i;":"round(getBestIndicesA(batch, inOffset + i));"}; 574 float candidate = getA(batch, inIdx); 575 if (candidate ${"max"===t?">":"<"} bestValue) { 576 bestValue = candidate; 577 bestIndex = inIdx; 578 } 579 } 580 setOutput(float(bestIndex)); 581 } 582 `}}class ev{constructor(e,t,r,n){let a,i;this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,s.ZSL.assert(e.length>2,()=>`Packed arg${r.charAt(0).toUpperCase()+r.slice(1)} supports only inputs with rank above 2.`);let o=Math.ceil(e[e.length-1]/t);this.outputShape=e.slice(0,-1),o>1&&this.outputShape.push(o),n||this.variableNames.push("bestIndicesA");let l=this.outputShape,u=l.length,h=(0,b.bf)(u),p=(0,y.Jp)("coords",u);if(1===o){i=u+1;let e=(0,b.bf)(i);a=` 583 ${e} sourceLocR = ${e}(${p.join()}, 0); 584 ++${p[u-1]}; 585 ${e} sourceLocG = ${e}(${p.join()}, 0); 586 ++${p[u-2]}; 587 ${e} sourceLocA = ${e}(${p.join()}, 0); 588 --${p[u-1]}; 589 ${e} sourceLocB = ${e}(${p.join()}, 0); 590 --${p[u-2]};`}else i=u,a=` 591 ${h} sourceLocR = coords; 592 ++${p[u-1]}; 593 ${h} sourceLocG = coords; 594 ++${p[u-2]}; 595 ${h} sourceLocA = coords; 596 --${p[u-1]}; 597 ${h} sourceLocB = coords; 598 --${p[u-2]};`;let d=["x","y","z","w","u","v"].slice(0,i),c="."+d[i-1],f=d.map(e=>"int "+e),m=(0,y.Jp)("sourceLocR",i-1).concat("inIdx.r"),g=(0,y.Jp)("sourceLocG",i-1).concat("inIdx.g"),x=(0,y.Jp)("sourceLocB",i-1).concat("inIdx.b"),v=(0,y.Jp)("sourceLocA",i-1).concat("inIdx.a"),w="max"===r?"greaterThan":"lessThan",T=n?"":` 599 inIdx = round(vec4(getBestIndicesAChannel(${m.join()}), 600 getBestIndicesAChannel(${g.join()}), 601 getBestIndicesAChannel(${x.join()}), 602 getBestIndicesAChannel(${v.join()})));`,S=`vec4( 603 getAChannel(${m.join()}), 604 hasNextCol ? getAChannel(${g.join()}) : 0., 605 hasNextRow ? getAChannel(${x.join()}) : 0., 606 hasNextRow && hasNextCol ? getAChannel(${v.join()}) : 0.)`,N=n?"":` 607 float getBestIndicesAChannel(${f.join()}) { 608 return getChannel(getBestIndicesA(${d.join()}), 609 vec2(${d.slice(-2).join()})); 610 }`;this.userCode=` 611 float getAChannel(${f.join()}) { 612 return getChannel(getA(${d.join()}), 613 vec2(${d.slice(-2).join()})); 614 } 615 ${N} 616 void main() { 617 ${h} coords = getOutputCoords(); 618 bool hasNextCol = ${p[u-1]} < ${l[u-1]-1}; 619 bool hasNextRow = ${p[u-2]} < ${l[u-2]-1}; 620 ${a} 621 ivec4 srcIdx = ivec4(sourceLocR${c}, sourceLocG${c}, 622 sourceLocB${c}, sourceLocA${c}) * ${t}; 623 ivec4 inIdx = srcIdx; 624 vec4 bestIndex = vec4(inIdx); 625 vec4 bestValue = ${S}; 626 627 for (int i = 0; i < ${t}; i++) { 628 inIdx = srcIdx; 629 ${T} 630 vec4 candidate = ${S}; 631 bvec4 nan = isnan(candidate); 632 bvec4 replace = bvec4( 633 vec4(${w}(candidate, bestValue)) * (vec4(1.0) - vec4(nan))); 634 635 bestValue = vec4(replace.x ? candidate.x : bestValue.x, 636 replace.y ? candidate.y : bestValue.y, 637 replace.z ? candidate.z : bestValue.z, 638 replace.w ? candidate.w : bestValue.w); 639 bestIndex = mix(bestIndex, vec4(inIdx), vec4(replace)); 640 srcIdx++; 641 } 642 setOutput(bestIndex); 643 } 644 `}}function ew(e,t,r,n){let a=[r];if(s.C0T.assertAxesAreInnerMostDims("arg"+n.charAt(0).toUpperCase()+n.slice(1),a,t.shape.length),!(0,s._K2)().getBool("WEBGL_PACK_REDUCE")||t.shape.length<=2){let r=[],i=e.texData.get(t.dataId),o=null!==i&&i.isPacked,l=t;o&&r.push(l=e.unpackTensor(t));let[u,h]=s.C0T.computeOutAndReduceShapes(l.shape,a),p=Z({inputs:{x:l},backend:e,attrs:{shape:[-1,s.ZSL.sizeFromShape(h)]}});r.push(p);let d=function e(t,r,n,a=null){let i=r.shape[0],o=r.shape[1];null!=a&&(i=a.shape[0],o=a.shape[1]);let l=s.C0T.computeOptimalWindowSize(o),u=new ex({windowSize:l,inSize:o,batchSize:i,outSize:Math.ceil(o/l)},n,null==a),h=[r];null!=a&&h.push(a);let p=t.runWebGLProgram(u,h,"int32");if(1===p.shape[1])return p;let d=e(t,r,n,p);return t.disposeIntermediateTensorInfo(p),d}(e,p,n);r.push(d);let c=Z({inputs:{x:d},backend:e,attrs:{shape:u}});return r.forEach(t=>e.disposeIntermediateTensorInfo(t)),c}return function e(t,r,n,a=null){let i=null!=a?a.shape:r.shape,o=i[i.length-1],l=new ev(i,s.C0T.computeOptimalWindowSize(o),n,null==a),u=null==a?[r]:[r,a],h=t.runWebGLProgram(l,u,"int32");if(h.shape.length===r.shape.length){let a=e(t,r,n,h);return t.disposeIntermediateTensorInfo(h),a}return h}(e,t,n)}let eT={kernelName:s.Jp_,backendName:"webgl",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{x:a}=t,{axis:i}=n,o=s.ZSL.parseAxisParam(i,a.shape),l=s.C0T.getAxesPermutation(o,a.shape.length),u=a,h=[];null!=l&&(h.push(u=et({inputs:{x:a},backend:r,attrs:{perm:l}})),o=s.C0T.getInnerMostAxes(o.length,u.shape.length)),s.C0T.assertAxesAreInnerMostDims("argMax",[o[0]],u.shape.length);let p=ew(r,u,o[0],"max");
644return h.forEach(e=>r.disposeIntermediateTensorInfo(e)),p}},eS={kernelName:s.p_m,backendName:"webgl",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{x:a}=t,{axis:i}=n,o=s.ZSL.parseAxisParam(i,a.shape),l=s.C0T.getAxesPermutation(o,a.shape.length),u=a,h=[];null!=l&&(h.push(u=et({inputs:{x:a},backend:r,attrs:{perm:l}})),o=s.C0T.getInnerMostAxes(o.length,u.shape.length)),s.C0T.assertAxesAreInnerMostDims("argMin",[o[0]],u.shape.length);let p=ew(r,u,o[0],"min");return h.forEach(e=>r.disposeIntermediateTensorInfo(e)),p}},eN=D({opSnippet:F.dR+` 645 if (abs(x) > 1.) { 646 return NAN; 647 } 648 return asin(x); 649`}),ek={kernelName:s.QKF,backendName:"webgl",kernelFunc:eN},eI=D({opSnippet:F.dR+"return log(x + sqrt(x * x + 1.0));"}),eC={kernelName:s.epO,backendName:"webgl",kernelFunc:eI},eE=D({opSnippet:F.dR+` 650 return atan(x); 651`}),eA={kernelName:s.TyE,backendName:"webgl",kernelFunc:eE},e$=O({opSnippet:m+` 652 return atan(a, b); 653`,packedOpSnippet:` 654 vec4 result = atan(a, b); 655 bvec4 isNaNA = isnan(a); 656 bvec4 isNaNB = isnan(b); 657 bvec4 isNaN = bvec4(isNaNA.x || isNaNB.x, isNaNA.y || isNaNB.y, isNaNA.z || isNaNB.z, isNaNA.w || isNaNB.w); 658 `+x+` 659 return result; 660`}),eF={kernelName:s.lxb,backendName:"webgl",kernelFunc:e$},eR=D({opSnippet:F.dR+` 661 if ((x < -1.0) || (x > 1.0)) return NAN; 662return (log(1.0 + x) - log(1.0 - x)) / 2.0;`}),e_={kernelName:s.zP9,backendName:"webgl",kernelFunc:eR};class eD{constructor(e,t,r,n=!1,a=!1){if(this.variableNames=["x"],"avg"===t&&r)throw Error("Cannot compute positions for average pool.");let s=e.filterWidth,i=e.strideHeight,o=e.strideWidth,l=e.dilationHeight,u=e.dilationWidth,h=e.effectiveFilterHeight,p=e.effectiveFilterWidth,d=e.padInfo.top,c=e.padInfo.left;this.outputShape=e.outShape;let f="avg"===t,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"),r){this.userCode=` 663 const ivec2 strides = ivec2(${i}, ${o}); 664 const ivec2 pads = ivec2(${d}, ${c}); 665 666 void main() { 667 ivec4 coords = getOutputCoords(); 668 int batch = coords[0]; 669 int d = coords[3]; 670 671 ivec2 xRCCorner = coords.yz * strides - pads; 672 int xRCorner = xRCCorner.x; 673 int xCCorner = xRCCorner.y; 674 675 // max/min x(?, ?, d) to get y(yR, yC, d). 676 // ? = to be determined 677 float minMaxValue = 0.0; 678 float minMaxValueFound = 0.0; 679 int minMaxPosition = 0; 680 float avgValue = 0.0; 681 682 for (int wR = 0; wR < ${h}; 683 wR += ${l}) { 684 int xR = xRCorner + wR; 685 686 if (xR < 0 || xR >= ${e.inHeight}) { 687 continue; 688 } 689 690 for (int wC = 0; wC < ${p}; 691 wC += ${u}) { 692 int xC = xCCorner + wC; 693 694 if (xC < 0 || xC >= ${e.inWidth}) { 695 continue; 696 } 697 698 float value = getX(batch, xR, xC, d); 699 700 // If a min / max value has already been found, use it. If not, 701 // use the current value. 702 float currMinMaxValue = mix( 703 value, minMaxValue, minMaxValueFound); 704 if (value >= currMinMaxValue) { 705 minMaxValue = value; 706 minMaxValueFound = 1.0; 707 minMaxPosition = ${n?a?m:g:`wR * ${p} + wC`}; 708 } 709 } 710 } 711 setOutput(float(minMaxPosition)); 712 } 713 `;return}let b=`${t}(${t}(${t}(minMaxValue[0], minMaxValue[1]), minMaxValue[2]), minMaxValue[3])`;"avg"===t&&(b="avgValue / max(count, 1.0)");let x=4*Math.floor(s/4),v=s%4,w=` 714 if (${f}) { 715 avgValue += dot(values, ones); 716 } else { 717 minMaxValue = max(values, minMaxValue); 718 } 719 `;this.userCode=` 720 const ivec2 strides = ivec2(${i}, ${o}); 721 const ivec2 pads = ivec2(${d}, ${c}); 722 const float initializationValue = ${y}; 723 const vec4 ones = vec4(1.0, 1.0, 1.0, 1.0); 724 725 float count = 0.0; 726 727 float getValue(int batch, int xR, int xC, int d) { 728 if (xC < 0 || xC >= ${e.inWidth}) { 729 return initializationValue; 730 } 731 count += 1.0; 732 return getX(batch, xR, xC, d); 733 } 734 735 void main() { 736 ivec4 coords = getOutputCoords(); 737 int batch = coords[0]; 738 int d = coords[3]; 739 740 ivec2 xRCCorner = coords.yz * strides - pads; 741 int xRCorner = xRCCorner.x; 742 int xCCorner = xRCCorner.y; 743 744 // max/min x(?, ?, d) to get y(yR, yC, d). 745 // ? = to be determined 746 vec4 minMaxValue = vec4(${y}); 747 float avgValue = 0.0; 748 count = 0.0; 749 750 for (int wR = 0; wR < ${h}; 751 wR += ${l}) { 752 int xR = xRCorner + wR; 753 754 if (xR < 0 || xR >= ${e.inHeight}) { 755 continue; 756 } 757 758 for (int wC = 0; wC < ${x}; wC += 4) { 759 int xC = xCCorner + wC * ${u}; 760 761 vec4 values = vec4( 762 getValue(batch, xR, xC, d), 763 getValue(batch, xR, xC + ${u}, d), 764 getValue(batch, xR, xC + 2 * ${u}, d), 765 getValue(batch, xR, xC + 3 * ${u}, d) 766 ); 767 768 ${w} 769 } 770 771 int xC = xCCorner + ${x}; 772 if (${1===v}) { 773 vec4 values = vec4( 774 getValue(batch, xR, xC, d), 775 initializationValue, 776 initializationValue, 777 initializationValue 778 ); 779 780 ${w} 781 } else if (${2===v}) { 782 vec4 values = vec4( 783 getValue(batch, xR, xC, d), 784 getValue(batch, xR, xC + ${u}, d), 785 initializationValue, 786 initializationValue 787 ); 788 789 ${w} 790 } else if (${3===v}) { 791 vec4 values = vec4( 792 getValue(batch, xR, xC, d), 793 getValue(batch, xR, xC + ${u}, d), 794 getValue(batch, xR, xC + 2 * ${u}, d), 795 initializationValue 796 ); 797 798 ${w} 799 } 800 } 801 setOutput(${b}); 802 } 803 `}}class eO{constructor(e,t,r,n=!1,a=!1){if(this.variableNames=["x"],"avg"===t&&r)throw Error("Cannot compute positions for average pool.");let s=e.filterWidth,i=e.strideDepth,o=e.strideHeight,l=e.strideWidth,u=e.dilationDepth,h=e.dilationHeight,p=e.dilationWidth,d=e.effectiveFilterDepth,c=e.effectiveFilterHeight,f=e.effectiveFilterWidth,m=e.padInfo.front,g=e.padInfo.top,y=e.padInfo.left;this.outputShape=e.outShape;let b="avg"===t,x="0.0";if(b||(x="-1.0 / 1e-20"),r){this.userCode=` 804 const ivec3 strides = 805 ivec3(${i}, ${o}, ${l}); 806 const ivec3 pads = ivec3(${m}, ${g}, ${y}); 807 808 void main() { 809 ivec5 coords = getOutputCoords(); 810 int batch = coords.x; 811 int ch = coords.u; 812 813 ivec3 xCorner = ivec3(coords.y, coords.z, coords.w) * strides - pads; 814 int xDCorner = xCorner.x; 815 int xRCorner = xCorner.y; 816 int xCCorner = xCorner.z; 817 818 // max/min x(?, ?, ?, ch) to get y(yD, yR, yC, ch). 819 // ? = to be determined 820 float minMaxValue = 0.0; 821 float minMaxValueFound = 0.0; 822 int minMaxPosition = 0; 823 824 for (int wD = 0; wD < ${d}; 825 wD += ${u}) { 826 int xD = xDCorner + wD; 827 828 if (xD < 0 || xD >= ${e.inDepth}) { 829 continue; 830 } 831 832 for (int wR = 0; wR < ${c}; 833 wR += ${h}) { 834 int xR = xRCorner + wR; 835 836 if (xR < 0 || xR >= ${e.inHeight}) { 837 continue; 838 } 839 840 for (int wC = 0; wC < ${f}; 841 wC += ${p}) { 842 int xC = xCCorner + wC; 843 844 if (xC < 0 || xC >= ${e.inWidth}) { 845 continue; 846 } 847 848 float value = getX(batch, xD, xR, xC, ch); 849 850 // If a min / max value has already been found, use it. If not, 851 // use the current value. 852 float currMinMaxValue = mix( 853 value, minMaxValue, minMaxValueFound); 854 if (value >= currMinMaxValue) { 855 minMaxValue = value; 856 minMaxValueFound = 1.0; 857 minMaxPosition = ${n?a?`(((batch * ${e.inDepth} + xD) * ${e.inHeight} + xR) * ${e.inWidth} + xC) * ${e.inChannels} + ch`:`((xD * ${e.inHeight} + xR) * ${e.inWidth} + xC) * ${e.inChannels} + ch`:`wD * ${c} * ${f} + 858 wR * ${f} + wC`}; 859 } 860 } 861 } 862 } 863 setOutput(float(minMaxPosition)); 864 } 865 `;return}let v=`${t}(${t}(${t}(minMaxValue[0], minMaxValue[1]), minMaxValue[2]), minMaxValue[3])`;"avg"===t&&(v="avgValue / max(count, 1.0)");let w=4*Math.floor(s/4),T=s%4,S=` 866 if (${b}) { 867 avgValue += dot(values, ones); 868 } else { 869 minMaxValue = max(values, minMaxValue); 870 } 871 `;this.userCode=` 872 const ivec3 strides = 873 ivec3(${i}, ${o}, ${l}); 874 const ivec3 pads = ivec3(${m}, ${g}, ${y}); 875 const float initializationValue = ${x}; 876 const vec4 ones = vec4(1.0, 1.0, 1.0, 1.0); 877 878 float count = 0.0; 879 880 float getValue(int batch, int xD, int xR, int xC, int ch) { 881 if (xC < 0 || xC >= ${e.inWidth}) { 882 return initializationValue; 883 } 884 count += 1.0; 885 return getX(batch, xD, xR, xC, ch); 886 } 887 888 void main() { 889 ivec5 coords = getOutputCoords(); 890 int batch = coords.x; 891 int ch = coords.u; 892 893 ivec3 xCorner = ivec3(coords.y, coords.z, coords.w) * strides - pads; 894 int xDCorner = xCorner.x; 895 int xRCorner = xCorner.y; 896 int xCCorner = xCorner.z; 897 898 // max/min x(?, ?, ?, d) to get y(yD, yR, yC, ch). 899 // ? = to be determined 900 vec4 minMaxValue = vec4(${x}); 901 float avgValue = 0.0; 902 count = 0.0; 903 904 for (int wD = 0; wD < ${d}; 905 wD += ${u}) { 906 int xD = xDCorner + wD; 907 908 if (xD < 0 || xD >= ${e.inDepth}) { 909 continue; 910 } 911 912 for (int wR = 0; wR < ${c}; 913 wR += ${h}) { 914 int xR = xRCorner + wR; 915 916 if (xR < 0 || xR >= ${e.inHeight}) { 917 continue; 918 } 919 920 for (int wC = 0; wC < ${w}; wC += 4) { 921 int xC = xCCorner + wC * ${p}; 922 923 vec4 values = vec4( 924 getValue(batch, xD, xR, xC, ch), 925 getValue(batch, xD, xR, xC + ${p}, ch), 926 getValue(batch, xD, xR, xC + 2 * ${p}, ch), 927 getValue(batch, xD, xR, xC + 3 * ${p}, ch) 928 ); 929 930 ${S} 931 } 932 933 int xC = xCCorner + ${w}; 934 if (${1===T}) { 935 vec4 values = vec4( 936 getValue(batch, xD, xR, xC, ch), 937 initializationValue, 938 initializationValue, 939 initializationValue 940 ); 941 942 ${S} 943 } else if (${2===T}) { 944 vec4 values = vec4( 945 getValue(batch, xD, xR, xC, ch), 946 getValue(batch, xD, xR, xC + ${p}, ch), 947 initializationValue, 948 initializationValue 949 ); 950 951 ${S} 952 } else if (${3===T}) { 953 vec4 values = vec4( 954 getValue(batch, xD, xR, xC, ch), 955 getValue(batch, xD, xR, xC + ${p}, ch), 956 getValue(batch, xD, xR, xC + 2 * ${p}, ch), 957 initializationValue 958 ); 959 960 ${S} 961 } 962 } 963 } 964 setOutput(${v}); 965 } 966 `}}let eL={kernelName:s.ho8,backendName:"webgl",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{x:a}=t;(0,u.assertNotComplex)(a,"avgPool");let{filterSize:i,strides:o,pad:l,dimRoundingMode:h}=n;s.ZSL.assert(s.C0T.eitherStridesOrDilationsAreOne(o,1),()=>`Error in avgPool: Either strides or dilations must be 1. Got strides ${o} and dilations '1'`);let p=s.C0T.computePool2DInfo(a.shape,i,o,1,l,h);if(1===p.filterWidth&&1===p.filterHeight&&s.ZSL.arraysEqual(p.inShape,p.outShape))return w({inputs:{x:a},backend:r});let d=new eD(p,"avg",!1);return r.runWebGLProgram(d,[a],"float32")}},eM={kernelName:s.cS,backendName:"webgl",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{x:a}=t,{filterSize:i,strides:o,pad:l,dimRoundingMode:u,dataFormat:h}=n,p=new eO(s.C0T.computePool3DInfo(a.shape,i,o,[1,1,1],l,u,h),"avg",!1);return r.runWebGLProgram(p,[a],"float32")}};class eP{constructor(e){this.variableNames=["dy"],this.outputShape=e.inShape;let t=e.filterHeight,r=e.filterWidth,n=e.strideHeight,a=e.strideWidth,s=e.dilationHeight,i=e.dilationWidth,o=e.effectiveFilterHeight,l=e.effectiveFilterWidth,u=o-1-e.padInfo.top,h=l-1-e.padInfo.left;this.userCode=` 967 const ivec2 pads = ivec2(${u}, ${h}); 968 const float avgMultiplier = float(${1/(t*r)}); 969 970 void main() { 971 ivec4 coords = getOutputCoords(); 972 int b = coords[0]; 973 int d = coords[3]; 974 975 ivec2 dyRCCorner = coords.yz - pads; 976 int dyRCorner = dyRCCorner.x; 977 int dyCCorner = dyRCCorner.y; 978 979 // Convolve dy(?, ?, d) with pos mask(:, :, d) to get dx(xR, xC, d). 980 // ? = to be determined. : = across all values in that axis. 981 float dotProd = 0.0; 982 for (int wR = 0; wR < ${o}; 983 wR += ${s}) { 984 float dyR = float(dyRCorner + wR) / ${n}.0; 985 986 if (dyR < 0.0 || dyR >= ${e.outHeight}.0 || fract(dyR) > 0.0) { 987 continue; 988 } 989 int idyR = int(dyR); 990 991 for (int wC = 0; wC < ${l}; 992 wC+= ${i}) { 993 float dyC = float(dyCCorner + wC) / ${a}.0; 994 995 if (dyC < 0.0 || dyC >= ${e.outWidth}.0 || 996 fract(dyC) > 0.0) { 997 continue; 998 } 999 int idyC = int(dyC); 1000 1001 float dyValue = getDy(b, idyR, idyC, d); 1002 1003 dotProd += dyValue * avgMultiplier; 1004 } 1005 } 1006 setOutput(dotProd); 1007 } 1008 `}}class ez{constructor(e){this.variableNames=["dy"],this.outputShape=e.inShape;let t=e.filterDepth,r=e.filterHeight,n=e.filterWidth,a=e.strideDepth,s=e.strideHeight,i=e.strideWidth,o=e.dilationDepth,l=e.dilationHeight,u=e.dilationWidth,h=e.effectiveFilterDepth,p=e.effectiveFilterHeight,d=e.effectiveFilterWidth,c=h-1-e.padInfo.front,f=p-1-e.padInfo.top,m=d-1-e.padInfo.left;this.userCode=` 1009 const ivec3 pads = ivec3(${c}, ${f}, ${m}); 1010 const float avgMultiplier = float(${1/(t*r*n)}); 1011 1012 void main() { 1013 ivec5 coords = getOutputCoords(); 1014 int batch = coords.x; 1015 int ch = coords.u; 1016 1017 ivec3 dyCorner = ivec3(coords.y, coords.z, coords.w) - pads; 1018 int dyDCorner = dyCorner.x; 1019 int dyRCorner = dyCorner.y; 1020 int dyCCorner = dyCorner.z; 1021 1022 // Convolve dy(?, ?, ?, d) with pos mask(:, :, :, ch) to get
1023 // dx(xD, xR, xC, ch). 1024 // ? = to be determined. : = across all values in that axis. 1025 float dotProd = 0.0; 1026 1027 for (int wD = 0; wD < ${h}; 1028 wD += ${o}) { 1029 float dyD = float(dyDCorner + wD) / ${a}.0; 1030 1031 if (dyD < 0.0 || dyD >= ${e.outDepth}.0 || fract(dyD) > 0.0) { 1032 continue; 1033 } 1034 int idyD = int(dyD); 1035 1036 for (int wR = 0; wR < ${p}; 1037 wR += ${l}) { 1038 float dyR = float(dyRCorner + wR) / ${s}.0; 1039 1040 if (dyR < 0.0 || dyR >= ${e.outHeight}.0 || 1041 fract(dyR) > 0.0) { 1042 continue; 1043 } 1044 int idyR = int(dyR); 1045 1046 for (int wC = 0; wC < ${d}; 1047 wC += ${u}) { 1048 float dyC = float(dyCCorner + wC) / ${i}.0; 1049 1050 if (dyC < 0.0 || dyC >= ${e.outWidth}.0 || 1051 fract(dyC) > 0.0) { 1052 continue; 1053 } 1054 int idyC = int(dyC); 1055 1056 float dyValue = getDy(batch, idyD, idyR, idyC, ch); 1057 1058 dotProd += dyValue * avgMultiplier; 1059 } 1060 } 1061 } 1062 setOutput(dotProd); 1063 } 1064 `}}let eB={kernelName:s.wwC,backendName:"webgl",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{dy:a,input:i}=t,{filterSize:o,strides:l,pad:u,dimRoundingMode:h}=n,p=new ez(s.C0T.computePool3DInfo(i.shape,o,l,[1,1,1],u,h));return r.runWebGLProgram(p,[a],i.dtype)}},eW={kernelName:s.VCH,backendName:"webgl",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{dy:a,input:i}=t;(0,u.assertNotComplex)([a,i],"avgPoolGrad");let{filterSize:o,strides:l,pad:h}=n,p=new eP(s.C0T.computePool2DInfo(i.shape,o,l,1,h));return r.runWebGLProgram(p,[a],i.dtype)}},eV={kernelName:s.jAQ,backendName:"webgl",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{a,b:s}=t,{transposeA:i,transposeB:o}=n;return en({a,b:s,transposeA:i,transposeB:o,backend:r})}};class eG{constructor(e,t,r,n,a,i){this.outputShape=[],this.variableNames=["x","mean","variance"],s.C0T.assertAndGetBroadcastShape(e,t),s.C0T.assertAndGetBroadcastShape(e,r);let o="0.0";null!=n&&(s.C0T.assertAndGetBroadcastShape(e,n),this.variableNames.push("offset"),o="getOffsetAtOutCoords()");let l="1.0";null!=a&&(s.C0T.assertAndGetBroadcastShape(e,a),this.variableNames.push("scale"),l="getScaleAtOutCoords()"),this.outputShape=e,this.userCode=` 1065 void main() { 1066 float x = getXAtOutCoords(); 1067 float mean = getMeanAtOutCoords(); 1068 float variance = getVarianceAtOutCoords(); 1069 float offset = ${o}; 1070 float scale = ${l}; 1071 float inv = scale * inversesqrt(variance + float(${i})); 1072 setOutput(dot(vec3(x, -mean, offset), vec3(inv, inv, 1))); 1073 } 1074 `}}class eU{constructor(e,t,r,n,a,i){this.packedInputs=!0,this.packedOutput=!0,this.variableNames=["x","mean","variance"],s.C0T.assertAndGetBroadcastShape(e,t),s.C0T.assertAndGetBroadcastShape(e,r);let o="vec4(0.0)";null!=n&&(s.C0T.assertAndGetBroadcastShape(e,n),this.variableNames.push("offset"),o="getOffsetAtOutCoords()");let l="vec4(1.0)";null!=a&&(s.C0T.assertAndGetBroadcastShape(e,a),this.variableNames.push("scale"),l="getScaleAtOutCoords()"),this.outputShape=e,this.userCode=` 1075 void main() { 1076 vec4 offset = ${o}; 1077 vec4 scale = ${l}; 1078 1079 vec4 x = getXAtOutCoords(); 1080 vec4 mean = getMeanAtOutCoords(); 1081 vec4 variance = getVarianceAtOutCoords(); 1082 1083 vec4 inv = scale * inversesqrt(variance + vec4(${i})); 1084 1085 setOutput((x - mean) * inv + offset); 1086 } 1087 `}}let eZ={kernelName:s.i5R,backendName:"webgl",kernelFunc:({inputs:e,backend:t,attrs:r})=>{let{x:n,mean:a,variance:i,offset:o,scale:l}=e;s.ZSL.assert(a.shape.length===i.shape.length,()=>"Batch normalization gradient requires mean and variance to have equal ranks."),s.ZSL.assert(null==o||a.shape.length===o.shape.length,()=>"Batch normalization gradient requires mean and offset to have equal ranks."),s.ZSL.assert(null==l||a.shape.length===l.shape.length,()=>"Batch normalization gradient requires mean and scale to have equal ranks.");let{varianceEpsilon:u}=r;null==u&&(u=.001);let h=[n,a,i],p=null;null!=o&&(p=o.shape,h.push(o));let d=null;null!=l&&(d=l.shape,h.push(l));let c=(0,s._K2)().getBool("WEBGL_PACK_NORMALIZATION")?new eU(n.shape,a.shape,i.shape,p,d,u):new eG(n.shape,a.shape,i.shape,p,d,u);return t.runWebGLProgram(c,h,h[0].dtype)}};class ej{constructor(e){let t;this.variableNames=["source"],this.outputShape=e,this.rank=e.length;let r=(0,b.bf)(this.rank);this.customUniforms=[{name:"start",arrayIndex:this.rank,type:"int"}];let n=function(e){if(1===e)return"sourceLoc";if(e<=6)return eH.slice(0,e).map(e=>"sourceLoc."+e).join(",");throw Error(`Slicing for rank ${e} is not yet supported`)}(this.rank),a=e.map((e,t)=>`sourceLoc.${eH[t]} = start[${t}] + coords.${eH[t]};`);t=` 1088 ${r} sourceLoc; 1089 ${r} coords = getOutputCoords(); 1090 ${a.join("\n")} 1091 `,this.userCode=` 1092 void main() { 1093 ${t} 1094 setOutput(getSource(${n})); 1095 } 1096 `}}let eH=["x","y","z","w","u","v"];class eK{constructor(e){this.variableNames=["source"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=e,this.rank=e.length,this.customUniforms=[{name:"start",arrayIndex:this.rank,type:"int"}];let t=(0,b.bf)(this.rank),r=(0,y.Jp)("coords",this.rank),n=(0,y.Jp)("sourceLoc",this.rank),a=1===this.rank?"sourceLoc":`vec2(${n.slice(-2).join()})`,s=`getChannel(getSource(${n.join()}), ${a})`,i=` 1097 result.x = ${s}; 1098 if (++${r[this.rank-1]} < ${e[this.rank-1]}) { 1099 ++${n[this.rank-1]}; 1100 result.y = ${s}; 1101 --${n[this.rank-1]}; 1102 } 1103 `,o=1===this.rank?"":` 1104 --${r[this.rank-1]}; 1105 if (++${r[this.rank-2]} < ${e[this.rank-2]}) { 1106 ++${n[this.rank-2]}; 1107 result.z = ${s}; 1108 if (++${r[this.rank-1]} < ${e[this.rank-1]}) { 1109 ++${n[this.rank-1]}; 1110 result.w = ${s}; 1111 } 1112 }
1113 `,l=this.rank<=4?`sourceLoc = coords + 1114 ${t}(${e.map((e,t)=>`start[${t}]`).join()});`:e.map((e,t)=>`${n[t]} = ${r[t]} + start[${t}];`).join("\n");this.userCode=` 1115 void main() { 1116 ${t} coords = getOutputCoords(); 1117 ${t} sourceLoc; 1118 ${l} 1119 vec4 result = vec4(0.); 1120 ${i} 1121 ${o} 1122 setOutput(result); 1123 } 1124 `}}function eY(e){let{inputs:t,backend:r,attrs:n}=e,{x:a}=t,{begin:i,size:o}=n,[l,u]=s.Kro.parseSliceParams(a,i,o);if(s.Kro.assertParamsValid(a,l,u),0===s.ZSL.sizeFromShape(u))return r.makeTensorInfo(u,a.dtype,[]);if(r.shouldExecuteOnCPU([a])||"string"===a.dtype){let e=r.texData.get(a.dataId),t=(0,B.J3)(e.values,l,u,a.shape,a.dtype);return r.makeTensorInfo(u,a.dtype,t)}let{isPacked:h}=r.texData.get(a.dataId),p=s.Kro.isSliceContinous(a.shape,l,u);if(h||!p){let e=(0,s._K2)().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new eK(u):new ej(u),t=[l];return r.runWebGLProgram(e,[a],a.dtype,t)}return r.uploadToGPU(a.dataId),function(e,t,r,n){let a=n.texData.get(e.dataId),i=n.makeTensorInfo(r,e.dtype),o=n.texData.get(i.dataId);Object.assign(o,a),o.refCount=1,o.shape=r,o.dtype=e.dtype;let l=s.Kro.computeFlatOffset(t,s.ZSL.computeStrides(e.shape));a.slice&&(l+=a.slice.flatOffset),o.slice={flatOffset:l,origDataId:a.slice&&a.slice.origDataId||e.dataId};let u=n.dataRefCount.get(o.slice.origDataId)||1;return n.dataRefCount.set(o.slice.origDataId,u+1),i}(a,l,u,r)}let eQ={kernelName:s.JiE,backendName:"webgl",kernelFunc:eY},eq={kernelName:s.Ik2,backendName:"webgl",kernelFunc:e=>{let{inputs:t,backend:r,attrs:n}=e,{x:a}=t,{blockShape:i,crops:o}=n;s.ZSL.assert(a.shape.length<=4,()=>"batchToSpaceND for rank > 4 with a WebGL backend not implemented yet");let l=i.reduce((e,t)=>e*t),u=s.C0T.getReshaped(a.shape,i,l),h=s.C0T.getPermuted(u.length,i.length),p=s.C0T.getReshapedPermuted(a.shape,i,l),d=s.C0T.getSliceBeginCoords(o,i.length),c=s.C0T.getSliceSize(p,o,i.length),f=[],m=Z({inputs:{x:a},backend:r,attrs:{shape:u}}),g=et({inputs:{x:m},backend:r,attrs:{perm:h}}),y=Z({inputs:{x:g},backend:r,attrs:{shape:p}}),b=eY({inputs:{x:y},backend:r,attrs:{begin:d,size:c}});return f.push(m),f.push(g),f.push(y),f.forEach(e=>r.disposeIntermediateTensorInfo(e)),b}},eX={kernelName:s.N4F,backendName:"webgl",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{x:a,weights:s}=t,{size:i}=n,o=r.readSync(a.dataId),l=r.readSync(s.dataId),u=(0,B.jm)(o,l,s.dtype,s.shape,i);return r.makeTensorInfo([i],s.dtype,u)}},eJ=` 1125 int r = int(a.r) & int(b.r); 1126 int g = int(a.g) & int(b.g); 1127 int rb = int(a.b) & int(b.b); 1128 int ra = int(a.a) & int(b.a); 1129 return vec4(r, g, rb, ra); 1130`,e0=` 1131 return float(int(a.r) & int(b.r)); 1132`,e1={kernelName:s.HNs,backendName:"webgl",kernelFunc:function(e){let t,{inputs:r,backend:n}=e,{a,b:i}=r,o=(0,s._K2)().getBool("WEBGL_PACK_BINARY_OPERATIONS"),l=(0,s._K2)().getNumber("WEBGL_VERSION");if(n.shouldExecuteOnCPU([a,i])||1===l){let e=n.texData.get(a.dataId).values,t=n.texData.get(i.dataId).values,[r,s]=(0,B.PA)(a.shape,i.shape,e,t,a.dtype),o=n.makeTensorInfo(s,a.dtype);return n.texData.get(o.dataId).values=r,o}return t=o?new v(eJ,a.shape,i.shape,!1):new g(e0,a.shape,i.shape),n.runWebGLProgram(t,[a,i],a.dtype)}},e2={kernelName:s.vj7,backendName:"webgl",kernelFunc:function(e){let{inputs:t,backend:r}=e,{s0:n,s1:a}=t,i=r.readSync(n.dataId),o=r.readSync(a.dataId),l=s.C0T.assertAndGetBroadcastShape(Array.from(i),Array.from(o));return r.makeTensorInfo([l.length],"int32",Int32Array.from(l))}},e3=O({opSnippet:"return float(a != b);",cpuKernelImpl:B.ad,dtype:"bool"}),e4={kernelName:s.ylV,backendName:"webgl",kernelFunc:e3};function e5(e){let{inputs:t,backend:r}=e,{input:n}=t;return w({inputs:{x:r.texData.get(n.dataId).complexTensorInfos.real},backend:r})}let e6={kernelName:s.LRy,backendName:"webgl",kernelFunc:e5},e7={kernelName:s.KXH,backendName:"webgl",kernelFunc:function e(t){let{inputs:r,backend:n,attrs:a}=t,{x:i}=r,{dtype:o}=a;if("complex64"===o){if("complex64"===i.dtype)return w({inputs:{x:i},backend:n});let t=s.Ul9(i.shape),r=e({inputs:{x:i},backend:n,attrs:{dtype:"float32"}}),a=S({inputs:{real:r,imag:t},backend:n});return t.dispose(),n.disposeIntermediateTensorInfo(r),a}
1132if("complex64"===i.dtype){let t=e5({inputs:{input:i},backend:n}),r=e({inputs:{x:t},backend:n,attrs:{dtype:o}});return n.disposeIntermediateTensorInfo(t),r}if(!s.ZSL.hasEncodingLoss(i.dtype,o)){let e=w({inputs:{x:i},backend:n});return{dataId:e.dataId,shape:e.shape,dtype:o}}if(n.shouldExecuteOnCPU([i])){let e=n.texData.get(i.dataId).values,[t,r,a]=(0,B.Kf)(e,i.shape,i.dtype,o);return n.makeTensorInfo(t,r,a)}if("int32"===o){let e=new F.hE(i.shape,"return float(int(x));"),t=n.runWebGLProgram(e,[i],"int32");return{dataId:t.dataId,shape:t.shape,dtype:t.dtype}}if("bool"===o){let e=n.makeTensorInfo([],"bool",s.ZSL.getTypedArrayFromDType("bool",1)),t=e3({inputs:{a:i,b:e},backend:n});return n.disposeIntermediateTensorInfo(e),t}throw Error(`Error in Cast: failed to cast ${i.dtype} to ${o}`)}},e9="return ceil(x);",e8=D({opSnippet:e9,packedOpSnippet:e9,cpuKernelImpl:B.Md}),te={kernelName:s.QDP,backendName:"webgl",kernelFunc:e8};class tt{constructor(e){this.variableNames=["A"],this.customUniforms=[{name:"minVal",type:"float"},{name:"maxVal",type:"float"}],this.outputShape=e,this.userCode=` 1133 1134 void main() { 1135 float value = getAAtOutCoords(); 1136 if (isnan(value)) { 1137 setOutput(value); 1138 return; 1139 } 1140 1141 setOutput(clamp(value, minVal, maxVal)); 1142 } 1143 `}}class tr{constructor(e){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.customUniforms=[{name:"minVal",type:"float"},{name:"maxVal",type:"float"}],this.outputShape=e,this.userCode=` 1144 void main() { 1145 vec4 value = getAAtOutCoords(); 1146 1147 if (any(isnan(value))) { 1148 setOutput(value); 1149 return; 1150 } 1151 1152 setOutput(clamp(value, vec4(minVal), vec4(maxVal))); 1153 } 1154 `}}let tn={kernelName:s.vaV,backendName:"webgl",kernelFunc:function(e){let t,{inputs:r,backend:n,attrs:a}=e,{x:i}=r,{clipValueMin:o,clipValueMax:l}=a;return t=(0,s._K2)().getBool("WEBGL_PACK_CLIP")?new tr(i.shape):new tt(i.shape),n.runWebGLProgram(t,[i],i.dtype,[[o],[l]])}};class ta{constructor(e){this.variableNames=["real","imag"],this.outputShape=e,this.userCode=` 1155 void main() { 1156 float re = abs(getRealAtOutCoords()); 1157 float im = abs(getImagAtOutCoords()); 1158 float mx = max(re, im); 1159 1160 // sadly the length function in glsl is not underflow-safe 1161 // (at least not on Intel GPUs). So the safe solution is 1162 // to ensure underflow-safety in all cases. 1163 setOutput( 1164 mx == 0.0 ? 0.0 : mx * length(vec2(1, min(re, im)/mx)) 1165 ); 1166 } 1167 `}}function ts(e,t){return{dataId:t.dataId,dtype:t.dtype,shape:e.shape}}let ti={kernelName:s.$zE,backendName:"webgl",kernelFunc:function(e){let{inputs:t,backend:r}=e,{x:n}=t,a=r.texData.get(n.dataId),s=new ta(n.shape),i=[ts(n,a.complexTensorInfos.real),ts(n,a.complexTensorInfos.imag)];return r.runWebGLProgram(s,i,i[0].dtype)}};class to{constructor(e){this.outputShape=[],this.outputShape=s.C0T.computeOutShape(e,1),this.variableNames=e.map((e,t)=>`T${t}`);let t=Array(e.length-1);t[0]=e[0][1];for(let r=1;r<t.length;r++)t[r]=t[r-1]+e[r][1];let r=[`if (yC < ${t[0]}) setOutput(getT0(yR, yC));`];for(let e=1;e<t.length;e++){let n=t[e-1];r.push(`else if (yC < ${t[e]}) setOutput(getT${e}(yR, yC-${n}));`)}let n=t.length,a=t[t.length-1];r.push(`else setOutput(getT${n}(yR, yC-${a}));`),this.userCode=` 1168 void main() { 1169 ivec2 coords = getOutputCoords(); 1170 int yR = coords.x; 1171 int yC = coords.y; 1172 1173 ${r.join("\n ")} 1174 } 1175 `}}class tl{constructor(e,t){this.packedInputs=!0,this.packedOutput=!0,this.outputShape=[],this.outputShape=s.C0T.computeOutShape(e,t);let r=this.outputShape,n=r.length,a=(0,b.bf)(n),i=(0,y.Jp)("coords",n),o=["x","y","z","w","u","v"].slice(0,n);this.variableNames=e.map((e,t)=>`T${t}`);let l=Array(e.length-1);l[0]=e[0][t];for(let r=1;r<l.length;r++)l[r]=l[r-1]+e[r][t];let u=o[t],h=o.slice(-2),p=o.join(),d=`if (${u} < ${l[0]}) { 1176 return getChannel( 1177 getT0(${p}), vec2(${h.join()})); 1178 }`;for(let e=1;e<l.length;e++){let t=l[e-1];d+=` 1179 if (${u} < ${l[e]} && ${u} >= ${l[e-1]}) { 1180 return getChannel( 1181 getT${e}(${tu(o,u,t)}), 1182 vec2(${tu(h,u,t)})); 1183 }`}let c=l.length,f=l[l.length-1];d+=` 1184 return getChannel( 1185 getT${c}(${tu(o,u,f)}), 1186 vec2(${tu(h,u,f)}));`,this.userCode=` 1187 float getValue(${o.map(e=>"int "+e)}) { 1188 ${d} 1189 } 1190 1191 void main() { 1192 ${a} coords = getOutputCoords(); 1193 vec4 result = vec4(getValue(${i}), 0., 0., 0.); 1194 1195 ${i[n-1]} = ${i[n-1]} + 1; 1196 if (${i[n-1]} < ${r[n-1]}) { 1197 result.g = getValue(${i}); 1198 } 1199 1200 ${i[n-2]} = ${i[n-2]} + 1; 1201 if (${i[n-2]} < ${r[n-2]}) { 1202 result.a = getValue(${i}); 1203 } 1204 1205 ${i[n-1]} = ${i[n-1]} - 1; 1206 if (${i[n-2]} < ${r[n-2]} && 1207 ${i[n-1]} < ${r[n-1]}) { 1208 result.b = getValue(${i}); 1209 } 1210 setOutput(result); 1211 } 1212 `}}function tu(e,t,r){let n=e.indexOf(t);return e.map((e,t)=>t===n?`${e} - ${r}`:e).join()}function th(e){let{inputs:t,backend:r}
1212=e,{input:n}=t;return w({inputs:{x:r.texData.get(n.dataId).complexTensorInfos.imag},backend:r})}let tp={kernelName:s.dv8,backendName:"webgl",kernelFunc:th};function td(e){let{inputs:t,backend:r,attrs:n}=e,{axis:a}=n,i=s.ZSL.parseAxisParam(a,t[0].shape)[0],o=t.map(e=>e.shape);s.C0T.assertParamsConsistent(o,i);let l=s.C0T.computeOutShape(t.map(e=>e.shape),i);if(0===s.ZSL.sizeFromShape(l))return r.makeTensorInfo(l,t[0].dtype,[]);let u=t.filter(e=>s.ZSL.sizeFromShape(e.shape)>0);return 1===u.length?w({inputs:{x:u[0]},backend:r}):function e(t,r,n){let a=t[0].dtype;if("complex64"===a){let a=t.map(e=>e5({inputs:{input:e},backend:n})),s=t.map(e=>th({inputs:{input:e},backend:n})),i=e(a,r,n),o=e(s,r,n),l=S({inputs:{real:i,imag:o},backend:n});return a.forEach(e=>n.disposeIntermediateTensorInfo(e)),s.forEach(e=>n.disposeIntermediateTensorInfo(e)),n.disposeIntermediateTensorInfo(i),n.disposeIntermediateTensorInfo(o),l}let i=n.shouldExecuteOnCPU(t);if("string"===a&&(i=!0),i){let e=t.map(e=>{let t=s.ZSL.sizeFromShape(e.shape.slice(r));return Z({inputs:{x:e},backend:n,attrs:{shape:[-1,t]}})}),i=e.map(e=>({vals:n.readSync(e.dataId),shape:e.shape})),o=s.C0T.computeOutShape(e.map(e=>e.shape),1),l=1===e[0].shape[0],u=(0,B.dv)(i,o,a,l),h=s.C0T.computeOutShape(t.map(e=>e.shape),r),p=n.makeTensorInfo(h,a,u);return e.forEach(e=>n.disposeIntermediateTensorInfo(e)),p}let o=t.filter(e=>s.ZSL.sizeFromShape(e.shape)>0),l=(0,s._K2)().getBool("WEBGL_PACK_ARRAY_OPERATIONS")&&o[0].shape.length>1;if(1===o.length){let e=l?new F.hE(t[0].shape,F.UC):new R.rf(t[0].shape,F.UC);return n.runWebGLProgram(e,t,a)}let u=(0,s._K2)().getNumber("WEBGL_MAX_TEXTURES_IN_SHADER");if(o.length>u){let t=[];for(let a=0;a<o.length;a+=u){let s=o.slice(a,a+u);t.push(e(s,r,n))}let a=e(t,r,n);for(let e of t)n.disposeIntermediateTensorInfo(e);return a}if(l){let e=new tl(o.map(e=>e.shape),r);return n.runWebGLProgram(e,o,a)}let{tensors2D:h,outShape:p}=function(e,t,r){let n=s.C0T.computeOutShape(e.map(e=>e.shape),t);return{tensors2D:e.map(e=>Z({inputs:{x:e},attrs:{shape:[-1,s.ZSL.sizeFromShape(e.shape.slice(t))]},backend:r})),outShape:n}}(o,r,n),d=new to(h.map(e=>e.shape)),c=n.runWebGLProgram(d,h,a);h.forEach(e=>n.disposeIntermediateTensorInfo(e));let f=Z({inputs:{x:c},attrs:{shape:p},backend:n});return n.disposeIntermediateTensorInfo(c),f}(u,i,r)}let tc={kernelName:s.$dB,backendName:"webgl",kernelFunc:td};class tf{constructor(e,t=!1,r=null,n=!1,a=!1){this.variableNames=["x","W"],this.outputShape=e.outShape;let s=e.padInfo.top,i=e.padInfo.left,o=e.strideHeight,l=e.strideWidth,u=e.dilationHeight,h=e.dilationWidth,p=e.filterHeight,d=e.filterWidth,c=4*Math.floor(e.inChannels/4),f=e.inChannels%4,m="channelsLast"===e.dataFormat,g="",y="";r&&(g=n?`float activation(float a) { 1213 float b = getPreluActivationWeightsAtOutCoords(); 1214 ${r} 1215 }`:a?`float activation(float a) { 1216 float b = getLeakyreluAlphaAtOutCoords(); 1217 ${r} 1218 }`:` 1219 float activation(float x) { 1220 ${r} 1221 } 1222 `,y="result = activation(result);"),t&&this.variableNames.push("bias"),n&&this.variableNames.push("preluActivationWeights"),a&&this.variableNames.push("leakyreluAlpha"),this.userCode=` 1223 ${g} 1224 1225 const ivec2 strides = ivec2(${o}, ${l}); 1226 const ivec2 pads = ivec2(${s}, ${i}); 1227 1228 void main() { 1229 ivec4 coords = getOutputCoords(); 1230 int batch = coords[0]; 1231 int d2 = coords[${m?3:1}]; 1232 1233 ivec2 xRCCorner = 1234 ivec2(coords[${m?1:2}], coords[${m?2:3}]) * strides - pads; 1235 int xRCorner = xRCCorner.x; 1236 int xCCorner = xRCCorner.y; 1237 1238 // Convolve x(?, ?, d1) with w(:, :, d1, d2) to get y(yR, yC, d2). 1239 // ? = to be determined. : = across all values in that axis. 1240 float dotProd = 0.0; 1241 for (int wR = 0; wR < ${p}; wR++) { 1242 int xR = xRCorner + wR * ${u}; 1243 1244 if (xR < 0 || xR >= ${e.inHeight}) { 1245 continue; 1246 } 1247 1248 for (int wC = 0; wC < ${d}; wC++) { 1249 int xC = xCCorner + wC * ${h}; 1250 1251 if (xC < 0 || xC >= ${e.inWidth}) { 1252 continue; 1253 } 1254 1255 for (int d1 = 0; d1 < ${c}; d1 += 4) { 1256 vec4 wValues = vec4( 1257 getW(wR, wC, d1, d2), 1258 getW(wR, wC, d1 + 1, d2), 1259 getW(wR, wC, d1 + 2, d2), 1260 getW(wR, wC, d1 + 3, d2) 1261 ); 1262 1263 if (${m}) { 1264 vec4 xValues = vec4( 1265 getX(batch, xR, xC, d1), 1266 getX(batch, xR, xC, d1 + 1), 1267 getX(batch, xR, xC, d1 + 2), 1268 getX(batch, xR, xC, d1 + 3) 1269 ); 1270 dotProd += dot(xValues, wValues); 1271 } else { 1272 vec4 xValues = vec4( 1273 getX(batch, d1, xR, xC), 1274 getX(batch, d1 + 1, xR, xC), 1275 getX(batch, d1 + 2, xR, xC), 1276 getX(batch, d1 + 3, xR, xC) 1277 ); 1278 dotProd += dot(xValues, wValues); 1279 } 1280 } 1281 1282 if (${1===f}) { 1283 1284 if (${m}) { 1285 dotProd += 1286 getX(batch, xR, xC, ${c}) * 1287 getW(wR, wC, ${c}, d2); 1288 } else { 1289 dotProd += 1290 getX(batch, ${c}, xR, xC) * 1291 getW(wR, wC, ${c}, d2); 1292 } 1293 1294 } else if (${2===f}) { 1295 vec2 wValues = vec2( 1296 getW(wR, wC, ${c}, d2), 1297 getW(wR, wC, ${c} + 1, d2) 1298 ); 1299 1300 if (${m}) { 1301 vec2 xValues = vec2( 1302 getX(batch, xR, xC, ${c}), 1303 getX(batch, xR, xC, ${c} + 1) 1304 ); 1305 dotProd += dot(xValues, wValues); 1306 } else { 1307 vec2 xValues = vec2( 1308 getX(batch, ${c}, xR, xC), 1309 getX(batch, ${c} + 1, xR, xC) 1310 ); 1311 dotProd += dot(xValues, wValues); 1312 } 1313 1314 } else if (${3===f}) { 1315 vec3 wValues = vec3( 1316 getW(wR, wC, ${c}, d2), 1317 getW(wR, wC, ${c} + 1, d2), 1318 getW(wR, wC, ${c} + 2, d2) 1319 ); 1320 1321 if (${m}) { 1322 vec3 xValues = vec3( 1323 getX(batch, xR, xC, ${c}), 1324 getX(batch, xR, xC, ${c} + 1), 1325 getX(batch, xR, xC, ${c} + 2) 1326 ); 1327 dotProd += dot(xValues, wValues); 1328 } else { 1329 vec3 xValues = vec3( 1330 getX(batch, ${c}, xR, xC), 1331 getX(batch, ${c} + 1, xR, xC), 1332 getX(batch, ${c} + 2, xR, xC) 1333 ); 1334 dotProd += dot(xValues, wValues); 1335 } 1336 1337 } 1338 } 1339 } 1340 1341 float result = dotProd; 1342 ${t?"result += getBiasAtOutCoords();":""} 1343 ${y} 1344 setOutput(result); 1345 } 1346 `}}class tm{constructor(e){this.variableNames=["x","W"],this.outputShape=e.outShape;let t=e.padInfo.front,r=e.padInfo.top,n=e.padInfo.left,a=e.strideDepth,s=e.strideHeight,i=e.strideWidth,o=e.dilationDepth,l=e.dilationHeight,u=e.dilationWidth,h=e.filterDepth,p=e.filterHeight,d=e.filterWidth,c=4*Math.floor(e.inChannels/4),f=e.inChannels%4;this.userCode=` 1347 const ivec3 strides = ivec3(${a}, ${s}, ${i}); 1348 const ivec3 pads = ivec3(${t}, ${r}, ${n}); 1349 1350 void main() { 1351 ivec5 coords = getOutputCoords(); 1352 int batch = coords.x; 1353 int d2 = coords.u; 1354 1355 ivec3 xFRCCorner = ivec3(coords.y, coords.z, coords.w) * strides - pads; 1356 int xFCorner = xFRCCorner.x; 1357 int xRCorner = xFRCCorner.y; 1358 int xCCorner = xFRCCorner.z; 1359 1360 // Convolve x(?, ?, ?, d1) with w(:, :, :, d1, d2) to get 1361 // y(yF, yR, yC, d2). ? = to be determined. : = across all 1362 // values in that axis. 1363 float dotProd = 0.0; 1364 for (int wF = 0; wF < ${h}; wF++) { 1365 int xF = xFCorner + wF * ${o}; 1366 1367 if (xF < 0 || xF >= ${e.inDepth}) { 1368 continue; 1369 } 1370 1371 for (int wR = 0; wR < ${p}; wR++) { 1372 int xR = xRCorner + wR * ${l}; 1373 1374 if (xR < 0 || xR >= ${e.inHeight}) { 1375 continue; 1376 } 1377 1378 for (int wC = 0; wC < ${d}; wC++) { 1379 int xC = xCCorner + wC * ${u}; 1380 1381 if (xC < 0 || xC >= ${e.inWidth}) { 1382 continue; 1383 } 1384 1385 for (int d1 = 0; d1 < ${c}; d1 += 4) { 1386 vec4 xValues = vec4( 1387 getX(batch, xF, xR, xC, d1), 1388 getX(batch, xF, xR, xC, d1 + 1), 1389 getX(batch, xF, xR, xC, d1 + 2), 1390 getX(batch, xF, xR, xC, d1 + 3) 1391 ); 1392 vec4 wValues = vec4( 1393 getW(wF, wR, wC, d1, d2), 1394 getW(wF, wR, wC, d1 + 1, d2), 1395 getW(wF, wR, wC, d1 + 2, d2), 1396 getW(wF, wR, wC, d1 + 3, d2) 1397 ); 1398 1399 dotProd += dot(xValues, wValues); 1400 } 1401 1402 if (${1===f}) { 1403 dotProd += 1404 getX(batch, xF, xR, xC, ${c}) * 1405 getW(wF, wR, wC, ${c}, d2); 1406 } else if (${2===f}) { 1407 vec2 xValues = vec2( 1408 getX(batch, xF, xR, xC, ${c}), 1409 getX(batch, xF, xR, xC, ${c} + 1) 1410 ); 1411 vec2 wValues = vec2( 1412 getW(wF, wR, wC, ${c}, d2), 1413 getW(wF, wR, wC, ${c} + 1, d2) 1414 ); 1415 dotProd += dot(xValues, wValues); 1416 } else if (${3===f}) { 1417 vec3 xValues = vec3( 1418 getX(batch, xF, xR, xC, ${c}), 1419 getX(batch, xF, xR, xC, ${c} + 1), 1420 getX(batch, xF, xR, xC, ${c} + 2) 1421 ); 1422 vec3 wValues = vec3( 1423 getW(wF, wR, wC, ${c}, d2), 1424 getW(wF, wR, wC, ${c} + 1, d2), 1425 getW(wF, wR, wC, ${c} + 2, d2) 1426 ); 1427 dotProd += dot(xValues, wValues); 1428 } 1429 } 1430 } 1431 } 1432 setOutput(dotProd); 1433 } 1434 `}}class tg{constructor(e,t=!1,r=null,n=!1,a=!1){this.variableNames=["x","W"],this.packedInputs=!0,this.packedOutput=!0,this.customUniforms=[{name:"pads",type:"ivec2"},{name:"strides",type:"ivec2"},{name:"dilations",type:"ivec2"},{name:"inDims",type:"ivec2"}],this.outputShape=e.outShape,this.enableShapeUniforms=(0,f.ik)(this.outputShape.length);let i=e.padInfo.left,o=e.strideWidth,l=e.dilationWidth,u=e.filterHeight,h=e.filterWidth,p=` 1435 int xR; int xC; int xCOffset; 1436 vec4 wTexel; vec4 previous; vec4 final;`;for(let e=0;e<h;e++)p+=` 1437 vec4 xTexelC${2*e}; 1438 int xTexelC${2*e}Ready; 1439 vec4 xTexelC${2*e+1}; 1440 int xTexelC${2*e+1}Ready; 1441 vec4 xC${e};`;p+=` 1442 for (int r = 0; r < ${u}; r++) { 1443 for (int d1 = 0; d1 < ${e.inChannels}; d1 += 2) { 1444 `;
1444for(let e=0;e<h;e++)p+=` 1445 xTexelC${2*e} = vec4(0.0); 1446 xTexelC${2*e}Ready = 0; 1447 xTexelC${2*e+1} = vec4(0.0); 1448 xTexelC${2*e+1}Ready = 0; 1449 xC${e} = vec4(0.0);`;p+=` 1450 xR = xRCorner + r * dilations[0]; 1451 if (xR >=0 && xR < inDims[0]) { 1452 `;for(let t=0;t<(h+1)/2;t++){let r=2*t;if(p+=` 1453 xC = xCCorner + ${r*l}; 1454 `,1===o){if(r<h&&(i%2==1?(p+=` 1455 xCOffset = xC + 1; 1456 if (xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${r}Ready == 0) { 1457 xTexelC${r} = getX(batch, xR, xCOffset, d1); 1458 1459 // Need to manually clear unused channels in case 1460 // we're reading from recycled texture. 1461 if (xCOffset + 1 >= inDims[1]) { 1462 xTexelC${r}.zw = vec2(0.0); 1463 } 1464 xTexelC${r}Ready = 1; 1465 } 1466 `,1===l&&r>0?p+=` 1467 xC${r} = vec4(xTexelC${r-2}.zw, xTexelC${r}.xy); 1468 `:p+=` 1469 xCOffset = xC + 1 - 2; 1470 1471 if (xCOffset >= 0 && xCOffset < inDims[1]) { 1472 previous = getX(batch, xR, xCOffset, d1); 1473 1474 // Need to manually clear unused channels in case 1475 // we're reading from recycled texture. 1476 if (xCOffset + 1 >= inDims[1]) { 1477 previous.zw = vec2(0.0); 1478 } 1479 1480 xC${r} = vec4(previous.zw, xTexelC${r}.xy); 1481 } else { 1482 xC${r} = vec4(0.0, 0.0, xTexelC${r}.xy); 1483 } 1484 `):p+=` 1485 if (xC >= 0 && xC < inDims[1] && xTexelC${r}Ready == 0) { 1486 xTexelC${r} = getX(batch, xR, xC, d1); 1487 if (xC + 1 >= inDims[1]) { 1488 xTexelC${r}.zw = vec2(0.0); 1489 } 1490 xTexelC${r}Ready = 1; 1491 } 1492 1493 xC${r} = xTexelC${r}; 1494 `,r+1<h)){let e=i%2==0?s.ZSL.nearestLargerEven(l):l;l%2==0&&i%2==1||l%2!=0&&i%2!=1?(p+=` 1495 xCOffset = xC + imod(pads[1], 2) + ${e}; 1496 1497 if (xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${r+1}Ready == 0) { 1498 xTexelC${r+1} = getX(batch, xR, xCOffset, d1); 1499 1500 // Need to manually clear unused channels in case 1501 // we're reading from recycled texture. 1502 if (xCOffset + 1 >= inDims[1]) { 1503 xTexelC${r+1}.zw = vec2(0.0); 1504 } 1505 xTexelC${r+1}Ready = 1; 1506 } 1507 `,l>1?p+=` 1508 xCOffset -= 2; 1509 if (xCOffset >= 0 && xCOffset < inDims[1]) { 1510 previous = getX(batch, xR, xCOffset, d1); 1511 xC${r+1} = vec4(previous.zw, xTexelC${r+1}.xy); 1512 } else { 1513 xC${r+1} = vec4(0.0, 0.0, xTexelC${r+1}.xy); 1514 } 1515 `:p+=` 1516 xC${r+1} = vec4(xTexelC${r}.zw, xTexelC${r+1}.xy); 1517 `):1===e?p+=` 1518 xC${r+1} = xTexelC${r}; 1519 `:p+=` 1520 xCOffset = xC + ${e}; 1521 1522 if (xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${r+1}Ready == 0) { 1523 xTexelC${r+1} = getX(batch, xR, xCOffset, d1); 1524 if (xCOffset + 1 >= inDims[1]) { 1525 xTexelC${r+1}.zw = vec2(0.0); 1526 } 1527 xTexelC${r+1}Ready = 1; 1528 } 1529 1530 xC${r+1} = xTexelC${r+1}; 1531 `}}else r<h&&(i%2==1?(p+=` 1532 xCOffset = xC + 1 - strides[1]; 1533 if(xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${r}Ready == 0) { 1534 xTexelC${r} = getX(batch, xR, xCOffset, d1); 1535 // Need to manually clear unused channels in case 1536 // we're reading from recycled texture. 1537 if (xCOffset + 1 >= inDims[1]) { 1538 xTexelC${r}.zw = vec2(0.0); 1539 } 1540 xTexelC${r}Ready = 1; 1541 } 1542 1543 if(xC + 1 >= 0 && xC + 1 < inDims[1] && xTexelC${r+1}Ready == 0) { 1544 xTexelC${r+1} = getX(batch, xR, xC + 1, d1); 1545 // Need to manually clear unused channels in case 1546 // we're reading from recycled texture. 1547 if (xC + 2 >= inDims[1]) { 1548 xTexelC${r+1}.zw = vec2(0.0); 1549 } 1550 xTexelC${r+1}Ready = 1; 1551 } 1552 1553 xC${r} = vec4(xTexelC${r}.zw, xTexelC${r+1}.zw); 1554 `,r+1<h&&(p+=` 1555 final = vec4(0.0); 1556 xCOffset = xC + 1 + strides[1]; 1557 if(xCOffset >= 0 && xCOffset < inDims[1]) { 1558 final = getX(batch, xR, xCOffset, d1); 1559 } 1560 xC${r+1} = vec4(xTexelC${r+1}.xy, final.xy); 1561 `)):(p+=` 1562 if(xC >= 0 && xC < inDims[1] && xTexelC${r}Ready == 0) { 1563 xTexelC${r} = getX(batch, xR, xC, d1); 1564 if (xC + 1 >= inDims[1]) { 1565 xTexelC${r}.zw = vec2(0.0); 1566 } 1567 xTexelC${r}Ready = 1; 1568 } 1569 1570 xCOffset = xC + strides[1]; 1571 if(xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${r+1}Ready == 0) { 1572 xTexelC${r+1} = getX(batch, xR, xCOffset, d1); 1573 if (xCOffset + 1 >= inDims[1]) { 1574 xTexelC${r+1}.zw = vec2(0.); 1575 } 1576 xTexelC${r+1}Ready = 1; 1577 } 1578 1579 xC${r} = vec4( 1580 xTexelC${r}.xy, xTexelC${r+1}.xy); 1581 `,r+1<h&&(p+=` 1582 xC${r+1} = vec4(xTexelC${r}.zw, xTexelC${r+1}.zw); 1583 `)));r<h&&(p+=` 1584 wTexel = getW(r, ${r}, d1, d2); 1585 dotProd += xC${r}.xxzz * vec4(wTexel.xy, wTexel.xy); 1586 if(d1 + 1 < ${e.inChannels}) { 1587 dotProd += xC${r}.yyww * vec4(wTexel.zw, wTexel.zw); 1588 } 1589 `,r+1<h&&(p+=` 1590 wTexel = getW(r, ${r+1}, d1, d2); 1591 dotProd += xC${r+1}.xxzz * vec4(wTexel.xy, wTexel.xy); 1592 if(d1 + 1 < ${e.inChannels}) { 1593 dotProd += xC${r+1}.yyww * vec4(wTexel.zw, wTexel.zw); 1594 } 1595 `))}p+=` 1596 } 1597 1598 } 1599 1600 } 1601 `;let d="",c="";r&&(d=n?`vec4 activation(vec4 a) { 1602 vec4 b = getPreluActivationWeightsAtOutCoords(); 1603 ${r} 1604 }`:a?`vec4 activation(vec4 a) { 1605 vec4 b = getLeakyreluAlphaAtOutCoords(); 1606 ${r} 1607 }`:`vec4 activation(vec4 x) { 1608 ${r} 1609 }`,c="result = activation(result);"),t&&this.variableNames.push("bias"),n&&this.variableNames.push("preluActivationWeights"),a&&this.variableNames.push("leakyreluAlpha"),this.userCode=` 1610 ${d} 1611 1612 void main() { 1613 ivec4 coords = getOutputCoords(); 1614 int batch = coords.x; 1615 ivec2 xRCCorner = coords.yz * strides - pads; 1616 int d2 = coords.w; 1617 int xRCorner = xRCCorner.x; 1618 int xCCorner = xRCCorner.y; 1619 1620 //intialize dotProd with a small epsilon seems to reduce GPU accuracy loss. 1621 vec4 dotProd = vec4(0.000000000000001); 1622 1623 ${p} 1624 1625 vec4 result = dotProd - vec4(0.000000000000001); 1626 ${t?"result += getBiasAtOutCoords();":""} 1627 ${c} 1628 setOutput(result); 1629 } 1630 `}}var ty=r(67108);class tb{constructor(e,t){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.customUniforms=[{name:"inputShape",type:"ivec4"},{name:"pad",type:"ivec2"},{name:"stride",type:"ivec2"},{name:"dilation",type:"ivec2"},{name:"inChannels",type:"int"},{name:"itemsPerBlockRow",type:"int"},{name:"outWidth",type:"int"}],this.outputShape=e,this.enableShapeUniforms=(0,f.ik)(this.outputShape.length);let{dataFormat:r}=t,n=(0,ty.B)(),a="channelsLast"===r,s=a?1:2,i=a?2:3,o=this.enableShapeUniforms?"if(blockIndex < outShape[2] && pos < outShape[1]) {":`if(blockIndex < ${e[2]} && pos < ${e[1]}) {`,l="";for(let e=0;e<=1;e++)for(let t=0;t<=1;t++)l+=` 1631 blockIndex = rc.z + ${t}; 1632 pos = rc.y + ${e}; 1633 1634 ${o} 1635 offsetY = int(blockIndex / outWidth) * stride[0] - pad[0]; 1636 d0 = offsetY + dilation[0] * (pos / itemsPerBlockRow); 1637 1638 if(d0 < inputShape[${s}] && d0 >= 0) { 1639 // Use custom imod instead mod. On Intel GPU, mod may generate 1640 // unexpected value. 1641 // https://github.com/tensorflow/tfjs/issues/5447 1642 offsetX = imod(blockIndex, outWidth) * stride[1] - pad[
16421]; 1643 d1 = offsetX + dilation[1] * (imod(pos, itemsPerBlockRow) / 1644 inChannels); 1645 1646 if(d1 < inputShape[${i}] && d1 >= 0) { 1647 1648 ch = imod(pos, inChannels); 1649 1650 if (${a}) { 1651 innerDims = vec2(d1, ch); 1652 result[${2*e+t}] = getChannel( 1653 getA(rc.x, d0, int(innerDims.x), 1654 int(innerDims.y)), innerDims); 1655 } else { 1656 innerDims = vec2(d0, d1); 1657 result[${2*e+t}] = getChannel( 1658 getA(rc.x, ch, int(innerDims.x), 1659 int(innerDims.y)), innerDims); 1660 } 1661 } 1662 } 1663 } 1664 `;this.userCode=` 1665 void main() { 1666 ivec3 rc = getOutputCoords(); 1667 1668 vec4 result = vec4(0); 1669 1670 int blockIndex, pos, offsetY, d0, offsetX, d1, ch; 1671 vec2 innerDims; 1672 1673 ${l} 1674 1675 ${n.output} = result; 1676 } 1677 `}}function tx(e,t){let r=e.length;return r>=3?t?[...e.slice(0,-3),e[r-3]*e[r-2],e[r-1]]:[...e.slice(0,-3),e[r-3],e[r-2]*e[r-1]]:!t&&1===r&&e[0]>1?[e[0],1]:null}function tv({x:e,filter:t,convInfo:r,backend:n,bias:a=null,preluActivationWeights:i=null,leakyreluAlpha:o=0,activation:l=null}){let h,p=e.shape,d=n.texData.get(e.dataId),c=r.inChannels,f=p[0]*p[1]*p[2],m=r.outChannels,g="channelsLast"===r.dataFormat,y=[];if(null!=i){let e=tx(i.shape,g);null!=e&&(i=Z({inputs:{x:i},backend:n,attrs:{shape:e}}),y.push(i))}if(null!=a){let e=tx(a.shape,g);null!=e&&(a=Z({inputs:{x:a},backend:n,attrs:{shape:e}}),y.push(a))}if(!((1===f||1===m)&&c>1e3)&&d.isPacked&&g&&null!=d.texture&&p[2]%2!=0&&s.ZSL.arraysEqual(d.shape.slice(-3),p.slice(-3))){let c=p[0]*p[1]*(p[2]+1),f={dataId:e.dataId,shape:[1,c,r.inChannels],dtype:e.dtype},m=d.shape;d.shape=d.shape.slice(),d.shape[d.shape.length-2]++,s.ZSL.assert(u.isReshapeFree(d.shape,f.shape),()=>`packed reshape ${d.shape} to ${f.shape} isn't free`);let g=Z({inputs:{x:t},backend:n,attrs:{shape:[1,r.inChannels,r.outChannels]}});y.push(g);let b=en({a:f,b:g,backend:n,transposeA:!1,transposeB:!1,bias:a,activation:l,preluActivationWeights:i,leakyreluAlpha:o}),x=n.texData.get(b.dataId);s.ZSL.assert(x.isPacked,()=>"batchMatMul result is expected to be packed"),d.shape=m,x.shape=r.outShape,(h=w({inputs:{x:b},backend:n})).shape=r.outShape,y.push(b)}else{let s=r.outHeight*r.outWidth,u=Z({inputs:{x:e},backend:n,attrs:{shape:g?[r.batchSize,s,r.inChannels]:[r.batchSize,r.inChannels,s]}}),p=Z({inputs:{x:t},backend:n,attrs:{shape:[1,r.inChannels,r.outChannels]}}),d=en({a:g?u:p,b:g?p:u,transposeA:!g,transposeB:!1,backend:n,bias:a,activation:l,preluActivationWeights:i,leakyreluAlpha:o});h=Z({inputs:{x:d},backend:n,attrs:{shape:r.outShape}}),y.push(u),y.push(p),y.push(d)}for(let e of y)n.disposeIntermediateTensorInfo(e);return h}function tw({x:e,filter:t,convInfo:r,backend:n,bias:a=null,preluActivationWeights:i=null,leakyreluAlpha:o=0,activation:l=null}){let{filterWidth:u,filterHeight:h,inChannels:p,outWidth:d,outHeight:c,dataFormat:f}=r,m="channelsLast"===f,g=u*h*p,y=c*d,b=[r.batchSize,g,y],x=[];if(null!=i){let e=tx(i.shape,m);null!=e&&(i=Z({inputs:{x:i},backend:n,attrs:{shape:e}}),x.push(i))}if(null!=a){let e=tx(a.shape,m);null!=e&&(a=Z({inputs:{x:a},backend:n,attrs:{shape:e}}),x.push(a))}let v=Z({inputs:{x:t},backend:n,attrs:{shape:[1,g,s.ZSL.sizeFromShape(t.shape)/g]}});x.push(v);let w=new tb(b,r),T=[e.shape,[r.padInfo.top,r.padInfo.left],[r.strideHeight,r.strideWidth],[r.dilationHeight,r.dilationWidth],[r.inChannels],[r.filterWidth*r.inChannels],[r.outWidth]],S=n.runWebGLProgram(w,[e],"float32",T),N=Z({inputs:{x:S},backend:n,attrs:{shape:b}});x.push(S),x.push(N);let k=null!=a,I=null!=i,C="leakyrelu"===l,E=l?L(l,!0):null,A=new M(m?N.shape:v.shape,m?v.shape:N.shape,m?[r.batchSize,y,r.outChannels]:[r.batchSize,r.outChannels,y],!0,!1,k,E,I,C),$=m?[N,v]:[v,N];if(a&&$.push(a),I&&$.push(i),C){let e=n.makeTensorInfo([],"float32",s.ZSL.createScalarValue(o,"float32"));$.push(e),x.push(e)}let F=n.runWebGLProgram(A,$,"float32"),R=Z({inputs:{x:F},backend:n,attrs:{shape:r.outShape}});for(let e of(x.push(F),x))n.disposeIntermediateTensorInfo(e);return R}let tT={kernelName:s.p2J,backendName:"webgl",kernelFunc:function(e){let t,{inputs:r,backend:n,attrs:a}=e,{x:i,filter:o}=r,{strides:l,pad:u,dataFormat:h,dilations:p,dimRoundingMode:d}
1677=a,c=s.C0T.convertConv2DDataFormat(h),f=s.C0T.computeConv2DInfo(i.shape,o.shape,l,p,u,d,!1,c);if(1===f.filterHeight&&1===f.filterWidth&&1===f.dilationHeight&&1===f.dilationWidth&&1===f.strideHeight&&1===f.strideWidth&&("SAME"===f.padInfo.type||"VALID"===f.padInfo.type))t=tv({x:i,filter:o,convInfo:f,backend:n});else if(f.strideWidth<=2&&"channelsLast"===c&&(0,s._K2)().getBool("WEBGL_EXP_CONV")){let e=new tg(f),r=[[f.padInfo.top,f.padInfo.left],[f.strideHeight,f.strideWidth],[f.dilationHeight,f.dilationWidth],[f.inHeight,f.inWidth]];t=n.runWebGLProgram(e,[i,o],"float32",r)}else if((0,s._K2)().getBool("WEBGL_CONV_IM2COL"))t=tw({x:i,filter:o,convInfo:f,backend:n});else{let e=new tf(f);t=n.runWebGLProgram(e,[i,o],"float32")}let m=Z({inputs:{x:t},backend:n,attrs:{shape:f.outShape}});return n.disposeIntermediateTensorInfo(t),m}};class tS{constructor(e){this.variableNames=["x","dy"],this.outputShape=e.filterShape;let t=e.strideHeight,r=e.strideWidth,n=e.padInfo.top,a=e.padInfo.left,s="channelsLast"===e.dataFormat;this.userCode=` 1678 void main() { 1679 ivec4 coords = getOutputCoords(); 1680 int wR = coords.x; 1681 int wC = coords.y; 1682 int d1 = coords.z; 1683 int d2 = coords.w; 1684 1685 // Convolve x(?, ?, d1) with dy(:, :, d2) to get dw(wR, wC, d1, d2). 1686 // ? = to be determined. : = across all values in that axis. 1687 float dotProd = 0.0; 1688 1689 for (int b = 0; b < ${e.batchSize}; b++) { 1690 for (int yR = 0; yR < ${e.outHeight}; yR++) { 1691 int xR = wR + yR * ${t} - ${n}; 1692 1693 if (xR < 0 || xR >= ${e.inHeight}) { 1694 continue; 1695 } 1696 1697 for (int yC = 0; yC < ${e.outWidth}; yC++) { 1698 int xC = wC + yC * ${r} - ${a}; 1699 1700 if (xC < 0 || xC >= ${e.inWidth}) { 1701 continue; 1702 } 1703 1704 ${s?`float dyValue = getDy(b, yR, yC, d2); 1705 float xValue = getX(b, xR, xC, d1); 1706 dotProd += (xValue * dyValue);`:`float dyValue = getDy(b, d2, yR, yC); 1707 float xValue = getX(b, d1, xR, xC); 1708 dotProd += (xValue * dyValue);`} 1709 } 1710 } 1711 } 1712 setOutput(dotProd); 1713 } 1714 `}}class tN{constructor(e){this.variableNames=["dy","W"],this.outputShape=e.inShape;let t=e.filterHeight,r=e.filterWidth,n=e.strideHeight,a=e.strideWidth,s="channelsLast"===e.dataFormat,i=t-1-e.padInfo.top,o=r-1-e.padInfo.left;this.userCode=` 1715 const ivec2 pads = ivec2(${i}, ${o}); 1716 1717 void main() { 1718 ivec4 coords = getOutputCoords(); 1719 int batch = coords[0]; 1720 int d1 = coords[${s?3:1}]; 1721 1722 ivec2 dyCorner = ivec2(coords[${s?1:2}], coords[${s?2:3}]) - pads; 1723 int dyRCorner = dyCorner.x; 1724 int dyCCorner = dyCorner.y; 1725 1726 // Convolve dy(?, ?, d2) with w(:, :, d1, d2) to compute dx(xR, xC, d1). 1727 // ? = to be determined. : = across all values in that axis. 1728 float dotProd = 0.0; 1729 for (int wR = 0; wR < ${t}; wR++) { 1730 float dyR = float(dyRCorner + wR) / ${n}.0; 1731 1732 if (dyR < 0.0 || dyR >= ${e.outHeight}.0 || fract(dyR) > 0.0) { 1733 continue; 1734 } 1735 int idyR = int(dyR); 1736 1737 int wRPerm = ${t} - 1 - wR; 1738 1739 for (int wC = 0; wC < ${r}; wC++) { 1740 float dyC = float(dyCCorner + wC) / ${a}.0; 1741 1742 if (dyC < 0.0 || dyC >= ${e.outWidth}.0 || 1743 fract(dyC) > 0.0) { 1744 continue; 1745 } 1746 int idyC = int(dyC); 1747 1748 int wCPerm = ${r} - 1 - wC; 1749 1750 for (int d2 = 0; d2 < ${e.outChannels}; d2++) { 1751 1752 if (${s}) { 1753 float xValue = getDy(batch, idyR, idyC, d2); 1754 float wValue = getW(wRPerm, wCPerm, d1, d2); 1755 dotProd += xValue * wValue; 1756 } else { 1757 float xValue = getDy(batch, d2, idyR, idyC); 1758 float wValue = getW(wRPerm, wCPerm, d1, d2); 1759 dotProd += xValue * wValue; 1760 } 1761 1762 } 1763 } 1764 } 1765 setOutput(dotProd); 1766 } 1767 `}}class tk{constructor(e){this.variableNames=["x","dy"],this.outputShape=e.filterShape;let t=e.strideDepth,r=e.strideHeight,n=e.strideWidth,a=e.padInfo.front,s=e.padInfo.top,i=e.padInfo.left;this.userCode=` 1768 void main() { 1769 ivec5 coords = getOutputCoords(); 1770 int wF = coords.x; 1771 int wR = coords.y; 1772 int wC = coords.z; 1773 int d1 = coords.w; 1774 int d2 = coords.u; 1775 1776 float dotProd = 0.0; 1777 1778 for (int b = 0; b < ${e.batchSize}; b++) { 1779 for (int yF = 0; yF < ${e.outDepth}; yF++) { 1780 int xF = wF + yF * ${t} - ${a}; 1781 1782 if (xF < 0 || xF >= ${e.inDepth}) { 1783 continue; 1784 } 1785 1786 for (int yR = 0; yR < ${e.outHeight}; yR++) { 1787 int xR = wR + yR * ${r} - ${s}; 1788 1789 if (xR < 0 || xR >= ${e.inHeight}) { 1790 continue; 1791 } 1792 1793 for (int yC = 0; yC < ${e.outWidth}; yC++) { 1794 int xC = wC + yC * ${n} - ${i}; 1795 1796 if (xC < 0 || xC >= ${e.inWidth}) { 1797 continue; 1798 } 1799 1800 float dyValue = getDy(b, yF, yR, yC, d2); 1801 float xValue = getX(b, xF, xR, xC, d1); 1802 dotProd += (xValue * dyValue); 1803 } 1804 } 1805 } 1806 } 1807 setOutput(dotProd); 1808 } 1809 `}}class tI{constructor(e){this.variableNames=["dy","W"],this.outputShape=e.inShape;let t=e.filterDepth,r=e.filterHeight,n=e.filterWidth,a=e.strideDepth,s=e.strideHeight,i=e.strideWidth,o=t-1-e.padInfo.front,l=r-1-e.padInfo.top,u=n-1-e.padInfo.left;this.userCode=` 1810 const ivec3 pads = ivec3(${o}, ${l}, ${u}); 1811 1812 void main() { 1813 ivec5 coords = getOutputCoords(); 1814 int batch = coords.x; 1815 int d1 = coords.u; 1816 1817 1818 ivec3 dyCorner = ivec3(coords.y, coords.z, coords.w) - pads; 1819 int dyFCorner = dyCorner.x; 1820 int dyRCorner = dyCorner.y; 1821 int dyCCorner = dyCorner.z; 1822 1823 float dotProd = 0.0; 1824 for (int wF = 0; wF < ${t}; wF++) { 1825 float dyF = float(dyFCorner + wF) / ${a}.0; 1826 1827 if (dyF < 0.0 || dyF >= ${e.outDepth}.0 || fract(dyF) > 0.0) { 1828 continue; 1829 } 1830 int idyF = int(dyF); 1831 1832 int wFPerm = ${t} - 1 - wF; 1833 1834 for (int wR = 0; wR < ${r}; wR++) { 1835 float dyR = float(dyRCorner + wR) / ${s}.0; 1836 1837 if (dyR < 0.0 || dyR >= ${e.outHeight}.0 || 1838 fract(dyR) > 0.0) { 1839 continue; 1840 } 1841 int idyR = int(dyR); 1842 1843 int wRPerm = ${r} - 1 - wR; 1844 1845 for (int wC = 0; wC < ${n}; wC++) { 1846 float dyC = float(dyCCorner + wC) / ${i}.0; 1847 1848 if (dyC < 0.0 || dyC >= ${e.outWidth}.0 || 1849 fract(dyC) > 0.0) { 1850 continue; 1851 } 1852 int idyC = int(dyC); 1853 1854 int wCPerm = ${n} - 1 - wC; 1855 1856 for (int d2 = 0; d2 < ${e.outChannels}; d2++) { 1857 float xValue = getDy(batch, idyF, idyR, idyC, d2); 1858 float wValue = getW(wFPerm, wRPerm, wCPerm, d1, d2); 1859 dotProd += xValue * wValue; 1860 } 1861 } 1862 } 1863 } 1864 setOutput(dotProd); 1865 } 1866 `}}let tC={kernelName:s.rFm,backendName:"webgl",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{x:a,dy:i}=t,{strides:o,pad:l,dataFormat:u,dimRoundingMode:h,filterShape:p}
1866=n,d=s.C0T.convertConv2DDataFormat(u),c=new tS(s.C0T.computeConv2DInfo(a.shape,p,o,1,l,h,!1,d));return r.runWebGLProgram(c,[a,i],"float32")}};class tE{constructor(e){this.variableNames=["dy","W"],this.packedInputs=!0,this.packedOutput=!0,this.customUniforms=[{name:"strides",type:"vec2"}],this.outputShape=e.inShape,this.enableShapeUniforms=(0,f.ik)(this.outputShape.length);let t=e.filterHeight,r=e.filterWidth,n=t-1-e.padInfo.top,a=r-1-e.padInfo.left;this.userCode=` 1867 const ivec2 pads = ivec2(${n}, ${a}); 1868 1869 void main() { 1870 ivec4 coords = getOutputCoords(); 1871 int batch = coords[0]; 1872 int d1 = coords[3]; 1873 1874 ivec2 dyCorner = ivec2(coords[1], coords[2]) - pads; 1875 int dyRCorner = dyCorner.x; 1876 int dyCCorner = dyCorner.y; 1877 1878 vec4 result = vec4(0.); 1879 for (int wR = 0; wR < ${t}; wR++) { 1880 float dyR = float(dyRCorner + wR) / strides[0]; 1881 if (dyR < 0.0 || dyR >= ${e.outHeight}.0 || fract(dyR) > 0.0) { 1882 continue; 1883 } 1884 int idyR = int(dyR); 1885 int wRPerm = ${t} - 1 - wR; 1886 1887 for (int wC = 0; wC < ${r}; wC++) { 1888 int wCPerm = ${r} - 1 - wC; 1889 1890 float dyC = float(dyCCorner + wC) / strides[1]; 1891 bool idyCVal = (dyC >= 0.0) && (dyC < ${e.outWidth}.0) 1892 && (fract(dyC) == 0.0); 1893 int idyC = int(dyC); 1894 1895 float dyC2 = float(dyCCorner + wC + 1) / strides[1]; 1896 bool idyCVal2 = (dyC2 >= 0.0) && (dyC2 < ${e.outWidth}.0) 1897 && (fract(dyC2) == 0.0); 1898 int idyC2 = int(dyC2); 1899 1900 if (idyCVal && idyCVal2) { 1901 for (int d2 = 0; d2 < ${e.outChannels}; d2 += 2) { 1902 vec4 wValue = getW(wRPerm, wCPerm, d1, d2); 1903 vec4 dySample = getDy(batch, idyR, idyC, d2); 1904 vec4 dySample2 = (idyC / 2 == idyC2 / 2) ? 1905 dySample : getDy(batch, idyR, idyC2, d2); 1906 1907 vec2 dyValue = mod(float(idyC), 2.) == 0. ? 1908 dySample.xy : dySample.zw; 1909 result.xy += vec2(dot(dyValue, wValue.xy), 1910 dot(dyValue, wValue.zw)); 1911 1912 dyValue = mod(float(idyC2), 2.) == 0. ? 1913 dySample2.xy : dySample2.zw; 1914 result.zw += vec2(dot(dyValue, wValue.xy), 1915 dot(dyValue, wValue.zw)); 1916 } 1917 } else if (idyCVal) { 1918 for (int d2 = 0; d2 < ${e.outChannels}; d2 += 2) { 1919 vec4 wValue = getW(wRPerm, wCPerm, d1, d2); 1920 vec4 dySample = getDy(batch, idyR, idyC, d2); 1921 vec2 dyValue = mod(float(idyC), 2.) == 0. ? 1922 dySample.xy : dySample.zw; 1923 result.xy += vec2(dot(dyValue, wValue.xy), 1924 dot(dyValue, wValue.zw)); 1925 } 1926 } else if (idyCVal2) { 1927 for (int d2 = 0; d2 < ${e.outChannels}; d2 += 2) { 1928 vec4 wValue = getW(wRPerm, wCPerm, d1, d2); 1929 vec4 dySample = getDy(batch, idyR, idyC2, d2); 1930 vec2 dyValue = mod(float(idyC2), 2.) == 0. ? 1931 dySample.xy : dySample.zw; 1932 result.zw += vec2(dot(dyValue, wValue.xy), 1933 dot(dyValue, wValue.zw)); 1934 } 1935 } 1936 } 1937 } 1938 setOutput(result); 1939 } 1940 `}}let tA={kernelName:s.jfg,backendName:"webgl",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{dy:a,filter:i}=t,{inputShape:o,strides:l,pad:u,dataFormat:h,dimRoundingMode:p}=n,d=s.C0T.convertConv2DDataFormat(h),c=s.C0T.computeConv2DInfo(o,i.shape,l,1,u,p,!1,d);if((0,s._K2)().getBool("WEBGL_PACK_CONV2DTRANSPOSE")&&"channelsLast"===d){let e=[[c.strideHeight,c.strideWidth]],t=new tE(c);return r.runWebGLProgram(t,[a,i],"float32",e)}{let e=new tN(c);return r.runWebGLProgram(e,[a,i],"float32")}}},t$={kernelName:s.A1h,backendName:"webgl",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{x:a,filter:i}=t,{strides:o,pad:l,dilations:u}=n,h=new tm(s.C0T.computeConv3DInfo(a.shape,i.shape,o,u,l));return r.runWebGLProgram(h,[a,i],"float32")}},tF={kernelName:s.iGz,backendName:"webgl",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{x:a,dy:i}=t,{strides:o,pad:l,filterShape:u}=n,h=new tk(s.C0T.computeConv3DInfo(a.shape,u,o,1,l));return r.runWebGLProgram(h,[a,i],"float32")}},tR={kernelName:s.gC7,backendName:"webgl",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{dy:a,filter:i}
1940=t,{pad:o,strides:l,inputShape:u}=n,h=new tI(s.C0T.computeConv3DInfo(u,i.shape,l,1,o));return r.runWebGLProgram(h,[a,i],"float32")}},t_=D({opSnippet:_+` 1941 return cos(x); 1942`,packedOpSnippet:` 1943 vec4 result = cos(x); 1944 bvec4 isNaN = isnan(x); 1945 ${x} 1946 return result; 1947`}),tD={kernelName:s.Mn0,backendName:"webgl",kernelFunc:t_},tO=D({opSnippet:` 1948 float e2x = exp(-x); 1949 return (e2x + 1.0 / e2x) / 2.0; 1950`}),tL={kernelName:s.MnK,backendName:"webgl",kernelFunc:tO};class tM{constructor(e,t,r,n,a){this.variableNames=["Image","Boxes","BoxInd"],this.outputShape=[];let[s,i,o,l]=e,[u]=t,[h,p]=r;this.outputShape=[u,h,p,l];let[d,c]=[`${i-1}.0`,`${o-1}.0`],[f,m,g]=h>1?[`${(i-1)/(h-1)}`,"(y2-y1) * height_ratio",`y1*${d} + float(y)*(height_scale)`]:["0.0","0.0",`0.5 * (y1+y2) * ${d}`],[y,b,x]=p>1?[`${(o-1)/(p-1)}`,"(x2-x1) * width_ratio",`x1*${c} + float(x)*(width_scale)`]:["0.0","0.0",`0.5 * (x1+x2) * ${c}`];this.userCode=` 1951 const float height_ratio = float(${f}); 1952 const float width_ratio = float(${y}); 1953 void main() { 1954 ivec4 coords = getOutputCoords(); 1955 int b = coords[0]; 1956 int y = coords[1]; 1957 int x = coords[2]; 1958 int d = coords[3]; 1959 1960 // get box vals 1961 float y1 = getBoxes(b,0); 1962 float x1 = getBoxes(b,1); 1963 float y2 = getBoxes(b,2); 1964 float x2 = getBoxes(b,3); 1965 1966 // get image in batch index 1967 int bInd = round(getBoxInd(b)); 1968 if(bInd < 0 || bInd >= ${s}) { 1969 return; 1970 } 1971 1972 float height_scale = ${m}; 1973 float width_scale = ${b}; 1974 1975 float in_y = ${g}; 1976 if( in_y < 0.0 || in_y > ${d} ) { 1977 setOutput(float(${a})); 1978 return; 1979 } 1980 float in_x = ${x}; 1981 if( in_x < 0.0 || in_x > ${c} ) { 1982 setOutput(float(${a})); 1983 return; 1984 } 1985 1986 vec2 sourceFracIndexCR = vec2(in_x,in_y); 1987 if(${+("bilinear"===n)} == 1) { 1988 // Compute the four integer indices. 1989 ivec2 sourceFloorCR = ivec2(sourceFracIndexCR); 1990 ivec2 sourceCeilCR = ivec2(ceil(sourceFracIndexCR)); 1991 1992 float topLeft = getImage(b, sourceFloorCR.y, sourceFloorCR.x, d); 1993 float bottomLeft = getImage(b, sourceCeilCR.y, sourceFloorCR.x, d); 1994 float topRight = getImage(b, sourceFloorCR.y, sourceCeilCR.x, d); 1995 float bottomRight = getImage(b, sourceCeilCR.y, sourceCeilCR.x, d); 1996 1997 vec2 fracCR = sourceFracIndexCR - vec2(sourceFloorCR); 1998 1999 float top = topLeft + (topRight - topLeft) * fracCR.x; 2000 float bottom = bottomLeft + (bottomRight - bottomLeft) * fracCR.x; 2001 float newValue = top + (bottom - top) * fracCR.y; 2002 setOutput(newValue); 2003 } else { 2004 // Compute the coordinators of nearest neighbor point. 2005 ivec2 sourceNearestCR = ivec2(floor( 2006 sourceFracIndexCR + vec2(0.5,0.5))); 2007 float newValue = getImage(b, sourceNearestCR.y, sourceNearestCR.x, d); 2008 setOutput(newValue); 2009 } 2010 } 2011 `}}let tP={kernelName:s.MRQ,backendName:"webgl",kernelFunc:e=>{let{inputs:t,backend:r,attrs:n}=e,{image:a,boxes:s,boxInd:i}=t,{cropSize:o,method:l,extrapolationValue:u}=n,h=new tM(a.shape,s.shape,o,l,u);return r.runWebGLProgram(h,[a,s,i],"float32")}};!function(e){e.Prod="*",e.Sum="+"}(a||(a={}));class tz{constructor(e,t,r,n){this.op=e,this.outputShape=t,this.variableNames=["x"],this.customUniforms=[{name:"index",type:"float"}];let s=this.outputShape.length,i=this.op===a.Prod?"1.0":"0.0",o=r?i:`getX(${tB(s,"coords",this.op)})`,l=this.outputShape[this.outputShape.length-1],u="",h="";r?(u=n?`end != ${l-1}`:"end != 0",h=n?"end + 1":"end - 1"):(u=n?`end + pow2 < ${l}`:"end >= pow2",h=n?"end + pow2":"end - pow2"),this.userCode=` 2012 void main() { 2013 ${(0,b.bf)(s)} coords = getOutputCoords(); 2014 int end = ${tW(s,"coords",this.op)}; 2015 float val = ${o}; 2016 int pow2 = int(pow(2.0, index)); 2017 if (${u}) { 2018 int idx = ${h}; 2019 ${tW(s,"coords",this.op)} = idx; 2020 val ${this.op}= getX(${tB(s,"coords",this.op)}); 2021 } 2022 setOutput(val); 2023 } 2024 `}}function tB(e,t,r){if(1===e)return`${t}`;if(2===e)return`${t}.x, ${t}.y`;if(3===e)return`${t}.x, ${t}.y, ${t}.z`;if(4===e)return`${t}.x, ${t}.y, ${t}.z, ${t}.w`;throw Error(`Cumulative ${r} for rank ${e} is not yet supported`)}function tW(e,t,r){if(1===e)return`${t}`;if(2===e)return`${t}.y`;if(3===e)return`${t}.z`;if(4===e)return`${t}.w`;throw Error(`Cumulative ${r} for rank ${e} is not yet supported`)}function tV(e,t,r,n,a,i){let o=t.shape.length,l=s.C0T.getAxesPermutation([n],o),u=t;null!=l&&(u=et({inputs:{x:t},backend:r,attrs:{perm:l}}));let h=s.C0T.getInnerMostAxes(1,o)[0];if(h!==o-1)throw Error(`WebGL cumprod shader expects an inner-most axis=${t.shape.length-1} but got axis=${n}`);
2024let p=u.shape[h],d=w({inputs:{x:u},backend:r});for(let t=0;t<=Math.ceil(Math.log2(p))-1;t++){let n=new tz(e,u.shape,!1,i),a=[[t]],s=d;d=r.runWebGLProgram(n,[d],d.dtype,a),r.disposeIntermediateTensorInfo(s)}if(a){let t=new tz(e,u.shape,a,i),n=d;d=r.runWebGLProgram(t,[d],d.dtype),r.disposeIntermediateTensorInfo(n)}if(null!=l){let e=et({inputs:{x:d},backend:r,attrs:{perm:s.C0T.getUndoAxesPermutation(l)}});return r.disposeIntermediateTensorInfo(d),r.disposeIntermediateTensorInfo(u),e}return d}let tG={kernelName:s.jj_,backendName:"webgl",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{x:s}=t,{axis:i,exclusive:o,reverse:l}=n;return tV(a.Prod,s,r,i,o,l)}},tU={kernelName:s.nY8,backendName:"webgl",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{x:s}=t,{axis:i,exclusive:o,reverse:l}=n;return tV(a.Sum,s,r,i,o,l)}},tZ={kernelName:s.wNW,backendName:"webgl",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{x:a,weights:s}=t,{size:i,binaryOutput:o}=n;if(1===a.shape.length){let e=r.readSync(a.dataId),t=r.readSync(s.dataId),n=(0,B.jm)(e,t,s.dtype,s.shape,i);return r.makeTensorInfo([i],s.dtype,n)}if(2===a.shape.length){let e=r.bufferSync(a),t=r.bufferSync(s),n=(0,B.h0)(e,t,i,o);return r.makeTensorInfo(n.shape,s.dtype,n.values)}throw Error(`Error in denseBincount: input must be at most rank 2, but got rank${a.shape.length}.`)}};class tj{constructor(e,t,r){this.variableNames=["x"],this.outputShape=[],this.outputShape=e,this.blockSize=t,this.dataFormat=r,this.userCode=` 2025 void main() { 2026 ivec4 coords = getOutputCoords(); 2027 int b = coords[0]; 2028 int h = ${this.getHeightCoordString()}; 2029 int w = ${this.getWidthCoordString()}; 2030 int d = ${this.getDepthCoordString()}; 2031 2032 int in_h = h / ${t}; 2033 int offset_h = imod(h, ${t}); 2034 int in_w = w / ${t}; 2035 int offset_w = imod(w, ${t}); 2036 int offset_d = (offset_h * ${t} + offset_w) * 2037 ${this.getOutputDepthSize()}; 2038 int in_d = d + offset_d; 2039 2040 float result = ${this.getInputSamplingString()}; 2041 setOutput(result); 2042 } 2043 `}
2043getHeightCoordString(){return"NHWC"===this.dataFormat?"coords[1]":"coords[2]"}getWidthCoordString(){return"NHWC"===this.dataFormat?"coords[2]":"coords[3]"}getDepthCoordString(){return"NHWC"===this.dataFormat?"coords[3]":"coords[1]"}getOutputDepthSize(){return"NHWC"===this.dataFormat?this.outputShape[3]:this.outputShape[1]}getInputSamplingString(){return"NHWC"===this.dataFormat?"getX(b, in_h, in_w, in_d)":"getX(b, in_d, in_h, in_w)"}}let tH={kernelName:s.TMz,backendName:"webgl",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{x:a}=t,{blockSize:s,dataFormat:i}=n,o=a.shape[0],l="NHWC"===i?a.shape[1]:a.shape[2],u="NHWC"===i?a.shape[2]:a.shape[3],h="NHWC"===i?a.shape[3]:a.shape[1],p=l*s,d=u*s,c=h/(s*s),f=new tj("NHWC"===i?[o,p,d,c]:[o,c,p,d],s,i);return r.runWebGLProgram(f,[a],a.dtype)}};class tK{constructor(e,t=!1,r=null,n=!1,a=!1){this.variableNames=["x","W"],this.customUniforms=[{name:"pads",type:"ivec2"},{name:"strides",type:"ivec2"},{name:"dilations",type:"ivec2"},{name:"inDims",type:"ivec2"}],this.outputShape=e.outShape,this.enableShapeUniforms=(0,f.ik)(this.outputShape.length);let s=e.filterHeight,i=e.filterWidth,o=e.outChannels/e.inChannels,l="",u="";r&&(l=n?`float activation(float a) { 2044 float b = getPreluActivationWeightsAtOutCoords(); 2045 ${r} 2046 }`:a?`float activation(float a) { 2047 float b = getLeakyreluAlphaAtOutCoords(); 2048 ${r} 2049 }`:` 2050 float activation(float x) { 2051 ${r} 2052 } 2053 `,u="result = activation(result);"),t&&this.variableNames.push("bias"),n&&this.variableNames.push("preluActivationWeights"),a&&this.variableNames.push("leakyreluAlpha"),this.userCode=` 2054 ${l} 2055 2056 void main() { 2057 ivec4 coords = getOutputCoords(); 2058 int batch = coords.x; 2059 ivec2 xRCCorner = coords.yz * strides - pads; 2060 int d2 = coords.w; 2061 int d1 = d2 / ${o}; 2062 int q = d2 - d1 * ${o}; 2063 2064 int xRCorner = xRCCorner.x; 2065 int xCCorner = xRCCorner.y; 2066 2067 // Convolve x(?, ?, d1) with w(:, :, d1, q) to get y(yR, yC, d2). 2068 // ? = to be determined. : = across all values in that axis. 2069 float dotProd = 0.0; 2070 // TO DO(dsmilkov): Flatten the two for loops and vec4 the operations. 2071 for (int wR = 0; wR < ${s}; wR++) { 2072 int xR = xRCorner + wR * dilations[0]; 2073 2074 if (xR < 0 || xR >= inDims[0]) { 2075 continue; 2076 } 2077 2078 for (int wC = 0; wC < ${i}; wC++) { 2079 int xC = xCCorner + wC * dilations[1]; 2080 2081 if (xC < 0 || xC >= inDims[1]) { 2082 continue; 2083 } 2084 2085 float xVal = getX(batch, xR, xC, d1); 2086 float wVal = getW(wR, wC, d1, q); 2087 dotProd += xVal * wVal; 2088 } 2089 } 2090 2091 float result = dotProd; 2092 ${t?"result += getBiasAtOutCoords();":""} 2093 ${u} 2094 setOutput(result); 2095 } 2096 `}}class tY{constructor(e,t=!1,r=null,n=!1,a=!1){this.variableNames=["x","W"],this.packedInputs=!0,this.packedOutput=!0,this.customUniforms=[{name:"pads",type:"ivec2"},{name:"strides",type:"ivec2"},{name:"dilations",type:"ivec2"},{name:"inDims",type:"ivec2"}],this.outputShape=e.outShape,this.enableShapeUniforms=(0,f.ik)(this.outputShape.length);let i=e.outChannels/e.inChannels,o=e.padInfo.left,l=e.strideWidth,u=e.dilationWidth,h=e.filterHeight,p=e.filterWidth,d=` 2097 int xR; int xC; int xCOffset; 2098 vec4 wTexel; vec4 previous; vec4 final;`;for(let e=0;e<p;e++)d+=` 2099 vec4 xTexelC${2*e}; 2100 int xTexelC${2*e}Ready; 2101 vec4 xTexelC${2*e+1}; 2102 int xTexelC${2*e+1}Ready; 2103 vec4 xC${e};`;d+=` 2104 for (int r = 0; r < ${h}; r++) { 2105 `;for(let e=0;e<p;e++)d+=` 2106 xTexelC${2*e} = vec4(0.0); 2107 xTexelC${2*e}Ready = 0; 2108 xTexelC${2*e+1} = vec4(0.0); 2109 xTexelC${2*e+1}Ready = 0; 2110 xC${e} = vec4(0.0);`;d+=` 2111 xR = xRCorner + r * dilations[0]; 2112 if (xR >=0 && xR < inDims[0]) { 2113 `;for(let e=0;e<(p+1)/2;e++){let t=2*e;if(d+=` 2114 xC = xCCorner + ${t*u}; 2115 `,1===l){if(t<p&&(o%2==1?(d+=` 2116 xCOffset = xC + 1; 2117 if (xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${t}Ready == 0) { 2118 xTexelC${t} = getX(batch, xR, xCOffset, d1); 2119 2120 // Need to manually clear unused channels in case 2121 // we're reading from recycled texture. 2122 if (xCOffset + 1 >= inDims[1]) { 2123 xTexelC${t}.zw = vec2(0.0); 2124 } 2125 xTexelC${t}Ready = 1; 2126 } 2127 `,1===u&&t>0?d+=` 2128 xC${t} = vec4(xTexelC${t-2}.zw, xTexelC${t}.xy); 2129 `:d+=` 2130 xCOffset = xC + 1 - 2; 2131 2132 if (xCOffset >= 0 && xCOffset < inDims[1]) { 2133 previous = getX(batch, xR, xCOffset, d1); 2134 2135 // Need to manually clear unused channels in case 2136 // we're reading from recycled texture. 2137 if (xCOffset + 1 >= inDims[1]) { 2138 previous.zw = vec2(0.0); 2139 } 2140 2141 xC${t} = vec4(previous.zw, xTexelC${t}.xy); 2142 } else { 2143 xC${t} = vec4(0.0, 0.0, xTexelC${t}.xy); 2144 } 2145 `):d+=` 2146 if (xC >= 0 && xC < inDims[1] && xTexelC${t}Ready == 0) { 2147 xTexelC${t} = getX(batch, xR, xC, d1); 2148 if (xC + 1 >= inDims[1]) { 2149 xTexelC${t}.zw = vec2(0.0); 2150 } 2151 xTexelC${t}Ready = 1; 2152 } 2153 2154 xC${t} = xTexelC${t}; 2155 `,t+1<p)){let e=o%2==0?s.ZSL.nearestLargerEven(u):u;u%2==0&&o%2==1||u%2!=0&&o%2!=1?(d+=` 2156 xCOffset = xC + imod(pads[1], 2) + ${e}; 2157 2158 if (xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${t+1}Ready == 0) { 2159 xTexelC${t+1} = getX(batch, xR, xCOffset, d1); 2160 2161 // Need to manually clear unused channels in case 2162 // we're reading from recycled texture. 2163 if (xCOffset + 1 >= inDims[1]) { 2164 xTexelC${t+1}.zw = vec2(0.0); 2165 } 2166 xTexelC${t+1}Ready = 1; 2167 } 2168 `,u>1?d+=` 2169 xCOffset -= 2; 2170 if (xCOffset >= 0 && xCOffset < inDims[1]) { 2171 previous = getX(batch, xR, xCOffset, d1); 2172 xC${t+1} = vec4(previous.zw, xTexelC${t+1}.xy); 2173 } else { 2174 xC${t+1} = vec4(0.0, 0.0, xTexelC${t+1}.xy); 2175 } 2176 `:d+=` 2177 xC${t+1} = vec4(xTexelC${t}.zw, xTexelC${t+1}.xy); 2178 `):1===e?d+=` 2179 xC${t+1} = xTexelC${t}; 2180 `:d+=` 2181 xCOffset = xC + ${e}; 2182 2183 if (xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${t+1}Ready == 0) { 2184 xTexelC${t+1} = getX(batch, xR, xCOffset, d1); 2185 if (xCOffset + 1 >= inDims[1]) { 2186 xTexelC${t+1}.zw = vec2(0.0); 2187 } 2188 xTexelC${t+1}Ready = 1; 2189 } 2190 2191 xC${t+1} = xTexelC${t+1}; 2192 `}}else t<p&&(o%2==1?(d+=` 2193 xCOffset = xC + 1 - strides[1]; 2194 if(xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${t}Ready == 0) { 2195 xTexelC${t} = getX(batch, xR, xCOffset, d1); 2196 // Need to manually clear unused channels in case 2197 // we're reading from recycled texture. 2198 if (xCOffset + 1 >= inDims[1]) { 2199 xTexelC${t}.zw = vec2(0.0); 2200 } 2201 xTexelC${t}Ready = 1; 2202 } 2203 2204 if(xC + 1 >= 0 && xC + 1 < inDims[1] && xTexelC${t+1}Ready == 0) { 2205 xTexelC${t+1} = getX(batch, xR, xC + 1, d1); 2206 // Need to manually clear unused channels in case 2207 // we're reading from recycled texture. 2208 if (xC + 2 >= inDims[1]) { 2209 xTexelC${t+1}.zw = vec2(0.0); 2210 } 2211 xTexelC${t+1}Ready = 1; 2212 } 2213 2214 xC${t} = vec4(xTexelC${t}.zw, xTexelC${t+1}.zw); 2215 `,t+1<p&&(d+=` 2216 final = vec4(0.0); 2217 xCOffset = xC + 1 + strides[1]; 2218 if(xCOffset >= 0 && xCOffset < inDims[1]) { 2219 final = getX(batch, xR, xCOffset, d1); 2220 } 2221 xC${t+1} = vec4(xTexelC${t+1}.xy, final.xy); 2222 `)):(d+=` 2223 if(xC >= 0 && xC < inDims[1] && xTexelC${t}Ready == 0) { 2224 xTexelC${t} = getX(batch, xR, xC, d1); 2225 if (xC + 1 >= inDims[1]) { 2226 xTexelC${t}.zw = vec2(0.0); 2227 } 2228 xTexelC${t}Ready = 1; 2229 } 2230 2231 xCOffset = xC + strides[1]; 2232 if(xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${t+1}Ready == 0) { 2233 xTexelC${t+1} = getX(batch, xR, xCOffset, d1); 2234 if (xCOffset + 1 >= inDims[1]) { 2235 xTexelC${t+1}.zw = vec2(0.); 2236 } 2237 xTexelC${t+1}Ready = 1; 2238 } 2239 2240 xC${t} = vec4( 2241 xTexelC${t}.xy, xTexelC${t+1}.xy); 2242 `,t+1<p&&(d+=` 2243 xC${t+1} = vec4(xTexelC${t}.zw, xTexelC${t+1}.zw); 2244 `)));t<p&&(d+=` 2245 wTexel = getW(r, ${t}, d1, q); 2246 dotProd += xC${t} * vec4(wTexel.xz, wTexel.xz); 2247 `,t+1<p&&(d+=` 2248 wTexel = getW(r, ${t+1}, d1, q); 2249 dotProd += xC${t+1} * vec4(wTexel.xz, wTexel.xz); 2250 `))}d+=` 2251 } 2252 2253 } 2254 `;let c="",m="";r&&(c=n?`vec4 activation(vec4 a) { 2255 vec4 b = getPreluActivationWeightsAtOutCoords(); 2256 ${r} 2257 }`:a?`vec4 activation(vec4 a) { 2258 vec4 b = getLeakyreluAlphaAtOutCoords(); 2259 ${r} 2260 }`:`vec4 activation(vec4 x) { 2261 ${r} 2262 }`,m="result = activation(result);"),t&&this.variableNames.push("bias"),n&&this.variableNames.push("preluActivationWeights"),a&&this.variableNames.push("leakyreluAlpha"),this.userCode=` 2263 ${c} 2264 2265 void main() { 2266 ivec4 coords = getOutputCoords(); 2267 int batch = coords.x; 2268 ivec2 xRCCorner = coords.yz * strides - pads; 2269 int d2 = coords.w; 2270 int d1 = d2 / ${i}; 2271 int q = d2 - d1 * ${i}; 2272 int xRCorner = xRCCorner.x; 2273 int xCCorner = xRCCorner.y; 2274 2275 //intialize dotProd with a small epsilon seems to reduce GPU accuracy loss. 2276 vec4 dotProd = vec4(0.000000000000001); 2277 2278 ${d} 2279 2280 vec4 result = dotProd - vec4(0.000000000000001); 2281 ${t?"result += getBiasAtOutCoords();":""} 2282 ${m} 2283 setOutput(result); 2284 } 2285 `}}let tQ={kernelName:s.tGH,backendName:"webgl",kernelFunc:function(e){let t,{inputs:r,backend:n,attrs:a}=e,{x:i,filter:o}=r,{strides:l,pad:u,dilations:h,dimRoundingMode:p}=a,d=h;null==d&&(d=[1,1]),s.ZSL.assert(s.C0T.eitherStridesOrDilationsAreOne(l,d),()=>`Error in depthwiseConv2d: Either strides or dilations must be 1. Got strides ${l} and dilations '${d}'`);let c=s.C0T.computeConv2DInfo(i.shape,o.shape,l,d,u,p,!0);
2285t=(0,s._K2)().getBool("WEBGL_PACK_DEPTHWISECONV")&&c.strideWidth<=2&&c.outChannels/c.inChannels==1?new tY(c):new tK(c);let f=[[c.padInfo.top,c.padInfo.left],[c.strideHeight,c.strideWidth],[c.dilationHeight,c.dilationWidth],[c.inHeight,c.inWidth]];return n.runWebGLProgram(t,[i,o],"float32",f)}};class tq{constructor(e){this.variableNames=["x","dy"],this.outputShape=e.filterShape;let t=e.strideHeight,r=e.strideWidth,n=e.padInfo.top,a=e.padInfo.left,s=e.outChannels/e.inChannels;this.userCode=` 2286 void main() { 2287 ivec4 coords = getOutputCoords(); 2288 int wR = coords.x; 2289 int wC = coords.y; 2290 int d1 = coords.z; 2291 int dm = coords.w; 2292 int d2 = d1 * ${s} + dm; 2293 2294 float dotProd = 0.0; 2295 2296 // TO DO: Vec4 over the batch size 2297 for (int b = 0; b < ${e.batchSize}; b++) { 2298 for (int yR = 0; yR < ${e.outHeight}; yR++) { 2299 int xR = wR + yR * ${t} - ${n}; 2300 2301 if (xR < 0 || xR >= ${e.inHeight}) { 2302 continue; 2303 } 2304 2305 for (int yC = 0; yC < ${e.outWidth}; yC++) { 2306 int xC = wC + yC * ${r} - ${a}; 2307 2308 if (xC < 0 || xC >= ${e.inWidth}) { 2309 continue; 2310 } 2311 2312 float dyValue = getDy(b, yR, yC, d2); 2313 float xValue = getX(b, xR, xC, d1); 2314 dotProd += (xValue * dyValue); 2315 } 2316 } 2317 } 2318 setOutput(dotProd); 2319 } 2320 `}}class tX{constructor(e){this.variableNames=["dy","W"],this.outputShape=e.inShape;let t=e.filterHeight,r=e.filterWidth,n=e.strideHeight,a=e.strideWidth,s=t-1-e.padInfo.top,i=r-1-e.padInfo.left,o=e.outChannels/e.inChannels;this.userCode=` 2321 const ivec2 pads = ivec2(${s}, ${i}); 2322 2323 void main() { 2324 ivec4 coords = getOutputCoords(); 2325 int batch = coords[0]; 2326 int d1 = coords[3]; 2327 ivec2 dyCorner = coords.yz - pads; 2328 int dyRCorner = dyCorner.x; 2329 int dyCCorner = dyCorner.y; 2330 2331 float dotProd = 0.0; 2332 2333 for (int wR = 0; wR < ${t}; wR++) { 2334 float dyR = float(dyRCorner + wR) / ${n}.0; 2335 2336 if (dyR < 0.0 || dyR >= ${e.outHeight}.0 || fract(dyR) > 0.0) { 2337 continue; 2338 } 2339 int idyR = int(dyR); 2340 2341 int wRPerm = ${t} - 1 - wR; 2342 2343 for (int wC = 0; wC < ${r}; wC++) { 2344 float dyC = float(dyCCorner + wC) / ${a}.0; 2345 2346 if (dyC < 0.0 || dyC >= ${e.outWidth}.0 || 2347 fract(dyC) > 0.0) { 2348 continue; 2349 } 2350 int idyC = int(dyC); 2351 2352 int wCPerm = ${r} - 1 - wC; 2353 2354 // TO DO: Vec4 over the channelMul 2355 for (int dm = 0; dm < ${o}; dm++) { 2356 int d2 = d1 * ${o} + dm; 2357 float xValue = getDy(batch, idyR, idyC, d2); 2358 float wValue = getW(wRPerm, wCPerm, d1, dm); 2359 dotProd += xValue * wValue; 2360 } 2361 } 2362 } 2363 setOutput(dotProd); 2364 } 2365 `}}let tJ={kernelName:s.X$8,backendName:"webgl",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{x:a,dy:i}=t,{strides:o,dilations:l,pad:u,dimRoundingMode:h,filterShape:p}=n,d=new tq(s.C0T.computeConv2DInfo(a.shape,p,o,l,u,h,!0));return r.runWebGLProgram(d,[a,i],"float32")}},t0={kernelName:s.nVu,backendName:"webgl",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{dy:a,filter:i}=t,{strides:o,dilations:l,pad:u,dimRoundingMode:h,inputShape:p}=n,d=new tX(s.C0T.computeConv2DInfo(p,i.shape,o,l,u,h,!0));return r.runWebGLProgram(d,[a,i],"float32")}};class t1{constructor(e){this.variableNames=["X"],this.outputShape=[e,e],this.userCode=` 2366 void main() { 2367 ivec2 coords = getOutputCoords(); 2368 float val = coords[0] == coords[1] ? getX(coords[0]) : 0.0; 2369 setOutput(val); 2370 } 2371 `}}let t2={kernelName:s.ORI,backendName:"webgl",kernelFunc:function(e){let{inputs:t,backend:r}=e,{x:n}=t,a=[...n.shape,...n.shape],i=s.ZSL.sizeFromShape(n.shape),o=Z({inputs:{x:n},backend:r,attrs:{shape:[i]}}),l=new t1(i),u=r.runWebGLProgram(l,[o],o.dtype),h=Z({inputs:{x:u},backend:r,attrs:{shape:a}});return r.disposeIntermediateTensorInfo(o),r.disposeIntermediateTensorInfo(u),h}};class t3{constructor(e){this.variableNames=["x","W"],this.outputShape=e.outShape;let{inHeight:t,inWidth:r,padInfo:n,strideHeight:a,strideWidth:s,filterHeight:i,filterWidth:o,dilationHeight:l,dilationWidth:u}=e,{top:h,left:p}=n;this.userCode=` 2372 const ivec2 strides = ivec2(${a}, ${s}); 2373 const ivec2 pads = ivec2(${h}, ${p}); 2374 const float neg_infinity = -3.4e38; 2375 2376 void main() { 2377 ivec4 coords = getOutputCoords(); 2378 int batch = coords.x; 2379 int d1 = coords.w; 2380 ivec2 outTopLeftCorner = 2381 coords.yz * strides - pads; 2382 int hBeg = outTopLeftCorner.x; 2383 int wBeg = outTopLeftCorner.y; 2384 2385 float curVal = neg_infinity; 2386 for (int h = 0; h < ${i}; h++) { 2387 int hIn = hBeg + h * ${l}; 2388 2389 if (hIn >= 0 && hIn < ${t}) { 2390 for (int w = 0; w < ${o}; w++) { 2391 int wIn = wBeg + w * ${u}; 2392 2393 if (wIn >= 0 && wIn < ${r}) { 2394 float xVal = getX(batch, hIn, wIn, d1); 2395 float wVal = getW(h, w, d1); 2396 2397 float val = xVal + wVal; 2398 if (val > curVal) { 2399 curVal = val; 2400 } 2401 } 2402 } 2403 } 2404 } 2405 2406 float result = curVal; 2407 setOutput(result); 2408 } 2409 `}}let t4={kernelName:s.jxD,backendName:"webgl",kernelFunc:function(e){let t,{inputs:r,backend:n,attrs:a}=e,{x:i,filter:o}=r,{strides:l,pad:u,dilations:h}=a,p=s.C0T.computeDilation2DInfo(i.shape,o.shape,l,u,"NHWC",h),d=new t3(p),c=Z({inputs:{x:t=n.runWebGLProgram(d,[i,o],"float32")},backend:n,attrs:{shape:p.outShape}});return n.disposeIntermediateTensorInfo(t),c}},t5={kernelName:s.Qgm,backendName:"webgl",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{equation:a}=n,{allDims:i,summedDims:o,idDims:l}=s.C0T.decodeEinsumEquation(a,t.length);s.C0T.checkEinsumDimSizes(i.length,l,t);let{path:u,steps:h}=s.C0T.getEinsumComputePath(o,l),p=h.length,d=null,c=i.length,f=[];for(let e=0;e<p;++e){for(let n of h[e]){let e,{permutationIndices:a,expandDims:i}=s.C0T.getEinsumPermutation(c,l[n]);s.C0T.isIdentityPermutation(a)?e=t[n]:(e=et({inputs:{x:t[n]},backend:r,attrs:{perm:a}}),f.push(e));let o=e.shape.slice();for(let e=0;e<i.length;++e)o.splice(i[e],0,1);s.ZSL.arraysEqual(e.shape,o)||(e=Z({inputs:{x:e},backend:r,attrs:{shape:o}}
2409),f.push(e)),null===d?d=e:(d=V({inputs:{a:e,b:d},backend:r}),f.push(d))}e<p-1&&(u[e]>=0&&(d=J({inputs:{x:d},backend:r,attrs:{axis:u[e]-(i.length-c),keepDims:!1}}),f.push(d)),c--)}for(let e of f)e!==d&&r.disposeIntermediateTensorInfo(e);return d}},t6=D({opSnippet:"return (x >= 0.0) ? x : (exp(x) - 1.0);",packedOpSnippet:` 2410 vec4 result; 2411 2412 result.r = (x.r >= 0.0) ? x.r : (exp(x.r) - 1.0); 2413 result.g = (x.g >= 0.0) ? x.g : (exp(x.g) - 1.0); 2414 result.b = (x.b >= 0.0) ? x.b : (exp(x.b) - 1.0); 2415 result.a = (x.a >= 0.0) ? x.a : (exp(x.a) - 1.0); 2416 2417 return result; 2418`}),t7={kernelName:s.Pah,backendName:"webgl",kernelFunc:t6},t9=` 2419 vec4 bGTEZero = vec4(greaterThanEqual(b, vec4(0.))); 2420 return (bGTEZero * a) + ((vec4(1.0) - bGTEZero) * (a * (b + vec4(1.0)))); 2421`,t8={kernelName:s.rsH,backendName:"webgl",kernelFunc:e=>{let{inputs:t,backend:r}=e,{dy:n,y:a}=t,i=(0,s._K2)().getBool("WEBGL_PACK_BINARY_OPERATIONS")?new v(t9,n.shape,a.shape):new g("return (b >= 0.0) ? a : a * (b + 1.0);",n.shape,a.shape);return r.runWebGLProgram(i,[n,a],n.dtype)}},re=O({opSnippet:"return float(a == b);",packedOpSnippet:` 2422 return vec4(equal(a, b)); 2423`,dtype:"bool",cpuKernelImpl:B.PP}),rt={kernelName:s.BRl,backendName:"webgl",kernelFunc:re},rr=D({opSnippet:` 2424 // Error function is calculated approximately with elementary function. 2425 // See "Handbook of Mathematical Functions with Formulas, 2426 // Graphs, and Mathematical Tables", Abramowitz and Stegun. 2427 float p = ${s.C0T.ERF_P}; 2428 float a1 = ${s.C0T.ERF_A1}; 2429 float a2 = ${s.C0T.ERF_A2}; 2430 float a3 = ${s.C0T.ERF_A3}; 2431 float a4 = ${s.C0T.ERF_A4};
2432 float a5 = ${s.C0T.ERF_A5}; 2433 2434 float sign = sign(x); 2435 x = abs(x); 2436 float t = 1.0 / (1.0 + p * x); 2437 return sign * (1.0 - (((((a5*t + a4)*t) + a3)*t + a2)*t + a1)*t*exp(-x*x)); 2438`}),rn={kernelName:s._s9,backendName:"webgl",kernelFunc:rr},ra=D({opSnippet:_+` 2439 return exp(x); 2440`,packedOpSnippet:` 2441 vec4 result = exp(x); 2442 bvec4 isNaN = isnan(x); 2443 result.r = isNaN.r ? x.r : result.r; 2444 result.g = isNaN.g ? x.g : result.g; 2445 result.b = isNaN.b ? x.b : result.b; 2446 result.a = isNaN.a ? x.a : result.a; 2447 2448 return result; 2449`,cpuKernelImpl:B.E$,dtype:"float32"}),rs={kernelName:s.ox3,backendName:"webgl",kernelFunc:ra};function ri(e){let{inputs:t,attrs:r,backend:n}=e,{dim:a}=r,{input:i}=t,o=i.shape.length,l=i.shape.slice(),u=a;return a<0&&(s.ZSL.assert(-(o+1)<=a,()=>`Axis must be in the interval [${-(o+1)}, ${o}]`),u=o+a+1),l.splice(u,0,1),Z({inputs:{x:i},backend:n,attrs:{shape:l}})}let ro={kernelName:s.ybN,backendName:"webgl",kernelFunc:ri},rl="return exp(x) - 1.0;",ru=D({opSnippet:rl,packedOpSnippet:rl,cpuKernelImpl:B.SF}),rh={kernelName:s.ybj,backendName:"webgl",kernelFunc:ru};class rp{constructor(e,t,r){let n;this.variableNames=["real","imag"];let a=t[1];this.outputShape=t;let s=r?`2.0 * ${Math.PI}`:`-2.0 * ${Math.PI}`,i=r?`${a}.0`:"1.0";if("real"===e)n="return real * expR - imag * expI;";else if("imag"===e)n="return real * expI + imag * expR;";else throw Error(`FFT component must be either "real" or "imag", got ${e}.`);this.userCode=` 2450 const float exponentMultiplier = ${s}; 2451 2452 float unaryOpComplex(float real, float expR, float imag, float expI) { 2453 ${n} 2454 } 2455 2456 float mulMatDFT(int batch, int index) { 2457 float indexRatio = float(index) / float(${a}); 2458 float exponentMultiplierTimesIndexRatio = 2459 exponentMultiplier * indexRatio; 2460 2461 float result = 0.0; 2462 2463 for (int i = 0; i < ${a}; i++) { 2464 // x = (-2|2 * PI / N) * index * i; 2465 float x = exponentMultiplierTimesIndexRatio * float(i); 2466 float expR = cos(x); 2467 float expI = sin(x); 2468 float real = getReal(batch, i); 2469 float imag = getImag(batch, i); 2470 2471 result += 2472 unaryOpComplex(real, expR, imag, expI) / ${i}; 2473 } 2474 2475 return result; 2476 } 2477 2478 void main() { 2479 ivec2 coords = getOutputCoords(); 2480 setOutput(mulMatDFT(coords[0], coords[1])); 2481 } 2482 `}}function rd(e,t,r){let n=r.texData.get(e.dataId),a=s.ZSL.sizeFromShape(e.shape),i=e.shape[e.shape.length-1],o=Z({inputs:{x:e},backend:r,attrs:{shape:[a/i,i]}}),l=o.shape,u=new rp("real",l,t),h=new rp("imag",l,t),p=[{dataId:n.complexTensorInfos.real.dataId,dtype:n.complexTensorInfos.real.dtype,shape:l},{dataId:n.complexTensorInfos.imag.dataId,dtype:n.complexTensorInfos.imag.dtype,shape:l}],d=r.runWebGLProgram(u,p,"float32"),c=r.runWebGLProgram(h,p,"float32"),f=S({inputs:{real:d,imag:c},backend:r});r.disposeIntermediateTensorInfo(d),r.disposeIntermediateTensorInfo(c);let m=Z({inputs:{x:f},backend:r,attrs:{shape:e.shape}});return r.disposeIntermediateTensorInfo(o),r.disposeIntermediateTensorInfo(f),m}let rc={kernelName:s.rGP,backendName:"webgl",kernelFunc:function(e){let{inputs:t,backend:r}=e,{input:n}=t;return rd(n,!1,r)}};class rf{constructor(e,t){this.outputShape=[],this.customUniforms=[{name:"value",type:"float"}],this.variableNames=["x"],this.outputShape=e,this.userCode=` 2483 void main() { 2484 // Input can be obtained from uniform value. 2485 setOutput(value); 2486 } 2487 `}}function rm(e){let{backend:t,attrs:r}=e,{shape:n,value:a}=r,{dtype:i}=r;if("string"===(i=i||s.ZSL.inferDtype(a))){let e=s.ZSL.getArrayFromDType(i,s.ZSL.sizeFromShape(n));return e.fill(a),t.makeTensorInfo(n,i,e)}{let e=new rf(n,a),r=[[a]];return t.runWebGLProgram(e,[],i,r)}}let rg={kernelName:s.SQl,backendName:"webgl",kernelFunc:rm};class ry{constructor(e){this.variableNames=["Image"],this.outputShape=[];let t=e[2];this.outputShape=e,this.userCode=` 2488 void main() { 2489 ivec4 coords = getOutputCoords(); 2490 int x = coords[2]; 2491 2492 int coordX = ${t} - x - 1; 2493 float outputValue; 2494 if(coordX >= 0 && coordX < ${t}) { 2495 outputValue = getImage(coords[0], coords[1], coordX, coords[3]); 2496 } else { 2497 outputValue = getImage(coords[0], coords[1], coords[2], coords[3]); 2498 } 2499 setOutput(outputValue); 2500 } 2501 `}}
2501let rb={kernelName:s.BxF,backendName:"webgl",kernelFunc:({inputs:e,backend:t})=>{let{image:r}=e,n=new ry(r.shape);return t.runWebGLProgram(n,[r],r.dtype)}},rx="return floor(x);",rv=D({opSnippet:rx,packedOpSnippet:rx,cpuKernelImpl:B.CJ}),rw={kernelName:s.ZgB,backendName:"webgl",kernelFunc:rv},rT=O({opSnippet:` 2502 float s = sign(a) * sign(b); 2503 int ia = round(a); 2504 int ib = round(b); 2505 if (ib != 0) { 2506 // Windows (D3D) wants guaranteed non-zero int division at compile-time. 2507 return float(idiv(ia, ib, s)); 2508 } else { 2509 return NAN; 2510 } 2511`,packedOpSnippet:` 2512 ivec4 ia = round(a); 2513 ivec4 ib = round(b); 2514 bvec4 cond = notEqual(ib, ivec4(0)); 2515 ivec4 result = ivec4(0); 2516 vec4 s = sign(a) * sign(b); 2517 2518 // Windows (D3D) wants guaranteed non-zero int division at compile-time. 2519 if (cond[0]) { 2520 result[0] = idiv(ia[0], ib[0], s[0]); 2521 } 2522 if (cond[1]) { 2523 result[1] = idiv(ia[1], ib[1], s[1]); 2524 } 2525 if (cond[2]) { 2526 result[2] = idiv(ia[2], ib[2], s[2]); 2527 } 2528 if (cond[3]) { 2529 result[3] = idiv(ia[3], ib[3], s[3]); 2530 } 2531 return vec4(result); 2532`,dtype:"int32"}),rS={kernelName:s.ElG,backendName:"webgl",kernelFunc:rT};var rN=r(60217);class rk{constructor(e){this.variableNames=["A"];let t=(0,ty.B)(),[r,n]=e;this.outputShape=e,this.userCode=` 2533 void main() { 2534 ivec3 coords = getOutputCoords(); 2535 int texR = coords[0]; 2536 int texC = coords[1]; 2537 int depth = coords[2]; 2538 vec2 uv = (vec2(texC, texR) + halfCR) / vec2(${n}.0, ${r}.0); 2539 2540 vec4 values = ${t.texture2D}(A, uv); 2541 float value; 2542 if (depth == 0) { 2543 value = values.r; 2544 } else if (depth == 1) { 2545 value = values.g; 2546 } else if (depth == 2) { 2547 value = values.b; 2548 } else if (depth == 3) { 2549 value = values.a; 2550 } 2551 2552 setOutput(floor(value * 255.0 + 0.5)); 2553 } 2554 `}}class rI{constructor(e){this.variableNames=["A"],this.packedInputs=!1,this.packedOutput=!0;let t=(0,ty.B)(),[r,n]=e;this.outputShape=e,this.userCode=` 2555 void main() { 2556 ivec3 coords = getOutputCoords(); 2557 int texR = coords[0]; 2558 int texC = coords[1]; 2559 int depth = coords[2]; 2560 2561 vec4 result = vec4(0.); 2562 2563 for(int row=0; row<=1; row++) { 2564 for(int col=0; col<=1; col++) { 2565 texC = coords[1] + row; 2566 depth = coords[2] + col; 2567 2568 vec2 uv = (vec2(texC, texR) + halfCR) / 2569 vec2(${n}.0, ${r}.0); 2570 vec4 values = ${t.texture2D}(A, uv); 2571 float value; 2572 if (depth == 0) { 2573 value = values.r; 2574 } else if (depth == 1) { 2575 value = values.g; 2576 } else if (depth == 2) { 2577 value = values.b; 2578 } else if (depth == 3) { 2579 value = values.a; 2580 } 2581 2582 result[row * 2 + col] = floor(value * 255.0 + 0.5); 2583 } 2584 } 2585 2586 ${t.output} = result; 2587 } 2588 `}}let rC={kernelName:s.awo,backendName:"webgl",kernelFunc:function(e){let{inputs:t,backend:r,attrs:a}=e,{pixels:i}=t,{numChannels:o}=a,l="undefined"!=typeof HTMLVideoElement&&i instanceof HTMLVideoElement,u="undefined"!=typeof HTMLImageElement&&i instanceof HTMLImageElement,[h,p]=l?[i.videoWidth,i.videoHeight]:[i.width,i.height],d=[p,h],c=[p,h,o];if(u||l){let e=(0,s._K2)().getBool("CANVAS2D_WILL_READ_FREQUENTLY_FOR_GPU");(null==n||e!==rE)&&(rE=e,n=document.createElement("canvas").getContext("2d",{willReadFrequently:rE})),n.canvas.width=h,n.canvas.height=p,n.drawImage(i,0,0,h,p),i=n.canvas}let f=r.makeTensorInfo(d,"int32");r.texData.get(f.dataId).usage=rN.tT.PIXELS,r.gpgpu.uploadPixelDataToTexture(r.getTexture(f.dataId),i);let m=(0,s._K2)().getBool("WEBGL_PACK")?new rI(c):new rk(c),g=r.runWebGLProgram(m,[f],"int32");return r.disposeData(f.dataId),g}},rE=(0,s._K2)().getBool("CANVAS2D_WILL_READ_FREQUENTLY_FOR_GPU"),rA={kernelName:s.aAr,backendName:"webgl",kernelFunc:function(e){let t,{inputs:r,backend:n,attrs:a}=e,{x:i,filter:o,bias:l,preluActivationWeights:u}=r,{strides:h,pad:p,dataFormat:d,dilations:c,dimRoundingMode:f,activation:m,leakyreluAlpha:g}
2588=a,y=s.C0T.convertConv2DDataFormat(d),b=s.C0T.computeConv2DInfo(i.shape,o.shape,h,c,p,f,!1,y),x=[],v=null!=l,w=null!=u,T="leakyrelu"===m,S=()=>{let e=[i,o],t=(e,t)=>{if("NCHW"===t&&1===e.shape.length&&1!==e.shape[0]){let t=Z({inputs:{x:e},backend:n,attrs:{shape:[e.shape[0],1,1]}});return x.push(t),t}return e};if(v&&e.push(t(l,d)),w&&e.push(t(u,d)),T){let t=n.makeTensorInfo([],"float32",s.ZSL.createScalarValue(g,"float32"));e.push(t),x.push(t)}return e};if(1===b.filterHeight&&1===b.filterWidth&&1===b.dilationHeight&&1===b.dilationWidth&&1===b.strideHeight&&1===b.strideWidth&&("SAME"===b.padInfo.type||"VALID"===b.padInfo.type))t=tv({x:i,filter:o,convInfo:b,backend:n,bias:l,activation:m,preluActivationWeights:u,leakyreluAlpha:g});else if(b.strideWidth<=2&&"channelsLast"===y&&(0,s._K2)().getBool("WEBGL_EXP_CONV")){let e=new tg(b,v,m?L(m,!0):null,w,T),r=[[b.padInfo.top,b.padInfo.left],[b.strideHeight,b.strideWidth],[b.dilationHeight,b.dilationWidth],[b.inHeight,b.inWidth]],a=S();t=n.runWebGLProgram(e,a,"float32",r)}else if((0,s._K2)().getBool("WEBGL_CONV_IM2COL"))t=tw({x:i,filter:o,convInfo:b,backend:n,bias:l,activation:m,preluActivationWeights:u,leakyreluAlpha:g});else{let e=new tf(b,v,m?L(m,!1):null,w,T),r=S();t=n.runWebGLProgram(e,r,"float32")}let N=Z({inputs:{x:t},backend:n,attrs:{shape:b.outShape}});return x.push(t),x.forEach(e=>n.disposeIntermediateTensorInfo(e)),N}},r$={kernelName:s.T7M,backendName:"webgl",kernelFunc:function(e){let t,{inputs:r,backend:n,attrs:a}=e,{x:i,filter:o,bias:l,preluActivationWeights:u}=r,{strides:h,pad:p,dilations:d,dimRoundingMode:c,activation:f,leakyreluAlpha:m}=a,g=[],y=d;null==y&&(y=[1,1]),s.ZSL.assert(s.C0T.eitherStridesOrDilationsAreOne(h,y),()=>`Error in depthwiseConv2d: Either strides or dilations must be 1. Got strides ${h} and dilations '${y}'`);let b=s.C0T.computeConv2DInfo(i.shape,o.shape,h,y,p,c,!0),x=(0,s._K2)().getBool("WEBGL_PACK_DEPTHWISECONV")&&b.strideWidth<=2&&b.outChannels/b.inChannels==1,v=f?L(f,x):null,w=[i,o],T=null!=l,S=null!=u,N="leakyrelu"===f;if(T&&w.push(l),S&&w.push(u),N){let e=n.makeTensorInfo([],"float32",s.ZSL.createScalarValue(m,"float32"));w.push(e),g.push(e)}t=x?new tY(b,T,v,S,N):new tK(b,T,v,S,N);let k=[[b.padInfo.top,b.padInfo.left],[b.strideHeight,b.strideWidth],[b.dilationHeight,b.dilationWidth],[b.inHeight,b.inWidth]],I=n.runWebGLProgram(t,w,"float32",k);return g.forEach(e=>n.disposeIntermediateTensorInfo(e)),I}};class rF{constructor(e,t,r,n){this.sliceDim=e,this.strides=t,this.paramsShape=n,this.variableNames=["x","indices"],this.outputShape=r;let a=(0,b.bf)(r.length),s=` 2589 int index;`;for(let e=0;e<this.sliceDim;e++)s+=` 2590 index = round(getIndices(coords[0], ${e})); 2591 out_of_bounds = out_of_bounds || index < 0; 2592 out_of_bounds = out_of_bounds || index >= ${this.paramsShape[e]}; 2593 flattenIndex += index * ${this.strides[e]};`;this.userCode=` 2594 void main() { 2595 ${a} coords = getOutputCoords(); 2596 int flattenIndex = 0; 2597 bool out_of_bounds = false; 2598 2599 ${s} 2600 2601 setOutput(out_of_bounds ? 0.0 : getX(flattenIndex, coords[1])); 2602 } 2603 `}}let rR={kernelName:s.O4G,backendName:"webgl",kernelFunc:function(e){let{inputs:t,backend:r}=e,{params:n,indices:a}=t,i=a.shape,o=i[i.length-1],l=s.ZSL.sizeFromShape(n.shape),[u,h,p,d]=s.C0T.prepareAndValidate(n,a),c=Z({inputs:{x:a},backend:r,attrs:{shape:[h,o]}}),f=Z({inputs:{x:n},backend:r,attrs:{shape:[s.ZSL.sizeFromShape(n.shape)/p,p]}});if(r.shouldExecuteOnCPU([n,a])||"string"===n.dtype){let e=r.readSync(a.dataId),t=r.bufferSync(n),s=(0,B.UF)(e,t,n.dtype,h,o,p,d,n.shape,l);return r.makeTensorInfo(u,n.dtype,s.values)}let m=new rF(o,d,[h,p],n.shape),g=r.runWebGLProgram(m,[f,c],f.dtype),y=Z({inputs:{x:g},backend:r,attrs:{shape:u}});return r.disposeIntermediateTensorInfo(c),r.disposeIntermediateTensorInfo(f),r.disposeIntermediateTensorInfo(g),y}};class r_{constructor(e,t){this.variableNames=["A","indices"],this.outputShape=t,this.rank=t.length;let r=(0,b.bf)(this.rank),n=function(e,t){let r=["resRC.x","resRC.y","resRC.z","resRC.w"],n=[];for(let t=0;t<e.length;t++)2===t?n.push("index"):n.push(`${r[t]}`);return n.join()}(e,0);this.userCode=` 2604 void main() { 2605 ${r} resRC = getOutputCoords(); 2606 int index = int(getIndices(resRC.x, resRC.z)); 2607 float inBounds = (index >= 0) && (index < ${e[2]}) ? 1.0 : 0.0; 2608 setOutput(inBounds * getA(${n})); 2609 } 2610 `}}function rD(e){let{inputs:t,backend:r,attrs:n}=e,{x:a,indices:i}=t,{axis:o,batchDims:l}=n,u=s.ZSL.parseAxisParam(o,a.shape)[0];if((0,s._K2)().get("DEBUG")){let e=r.readSync(i.dataId),t=a.shape[u];for(let r=0;r<e.length;++r){let n=e[r];s.ZSL.assert(n<=t-1&&n>=0,()=>`GatherV2: the index value ${n} is not in [0, ${t-1}]`)}}let h=s.C0T.segment_util.collectGatherOpShapeInfo(a,i,u,l),p=s.ZSL.sizeFromShape(i.shape),d=[],c=Z({inputs:{x:a},backend:r,attrs:{shape:[h.batchSize,h.outerSize,h.dimSize,h.sliceSize]}}),f=Z({inputs:{x:i},backend:r,attrs:{shape:[h.batchSize,p/h.batchSize]}});d.push(c),d.push(f);let m=[h.batchSize,h.outerSize,p/h.batchSize,h.sliceSize];if(r.shouldExecuteOnCPU([a,i])||"string"===a.dtype){let e=r.bufferSync(f),t=r.bufferSync(c),n=(0,B.QM)(t,e,m);
2610return d.forEach(e=>r.disposeIntermediateTensorInfo(e)),r.makeTensorInfo(h.outputShape,n.dtype,n.values)}let g=new r_(c.shape,m),y=r.runWebGLProgram(g,[c,f],c.dtype);d.push(y);let b=Z({inputs:{x:y},backend:r,attrs:{shape:h.outputShape}});return d.forEach(e=>r.disposeIntermediateTensorInfo(e)),b}let rO={kernelName:s.mxL,backendName:"webgl",kernelFunc:rD},rL=O({opSnippet:"return float(a > b);",packedOpSnippet:` 2611 return vec4(greaterThan(a, b)); 2612`,cpuKernelImpl:B.Tm,dtype:"bool"}),rM={kernelName:s.XhZ,backendName:"webgl",kernelFunc:rL},rP=O({opSnippet:"return float(a >= b);",packedOpSnippet:` 2613 return vec4(greaterThanEqual(a, b)); 2614`,dtype:"bool",cpuKernelImpl:B.BW}),rz={kernelName:s.lLS,backendName:"webgl",kernelFunc:rP},rB={kernelName:s.OAQ,backendName:"webgl",kernelFunc:function(e){let{inputs:t,backend:r}=e,{input:n}=t;return rd(n,!0,r)}},rW=D({opSnippet:"return float(!isnan(x) && !isinf(x));",dtype:"bool"}),rV={kernelName:s.gIW,backendName:"webgl",kernelFunc:rW},rG=D({opSnippet:"return float(isinf(x));",dtype:"bool"}),rU={kernelName:s.E3$,backendName:"webgl",kernelFunc:rG},rZ=D({opSnippet:"return float(isnan(x));",dtype:"bool"}),rj={kernelName:s.iPs,backendName:"webgl",kernelFunc:rZ},rH=O({opSnippet:"return float(a < b);",packedOpSnippet:` 2615 return vec4(lessThan(a, b)); 2616`,cpuKernelImpl:B.uw,dtype:"bool"}),rK={kernelName:s.mIA,backendName:"webgl",kernelFunc:rH},rY=O({opSnippet:"return float(a <= b);",packedOpSnippet:` 2617 return vec4(lessThanEqual(a, b)); 2618`,cpuKernelImpl:B.mo,dtype:"bool"}),rQ={kernelName:s.CwD,backendName:"webgl",kernelFunc:rY},rq={kernelName:s.mnI,backendName:"webgl",kernelFunc:function(e){let{backend:t,attrs:r}=e,{start:n,stop:a,num:s}=r,i=(0,B.AC)(n,a,s);return t.makeTensorInfo([i.length],"float32",i)}},rX=D({opSnippet:_+` 2619 return x < 0.0 ? 0./0. : log(x); 2620`,packedOpSnippet:` 2621 vec4 result = log(x); 2622 bvec4 isNaN = isnan(x); 2623 result.r = isNaN.r ? x.r : (x.r < 0.0 ? 0./0. : result.r); 2624 result.g = isNaN.g ? x.g : (x.g < 0.0 ? 0./0. : result.g); 2625 result.b = isNaN.b ? x.b : (x.b < 0.0 ? 0./0. : result.b); 2626 result.a = isNaN.a ? x.a : (x.a < 0.0 ? 0./0. : result.a); 2627 return result; 2628`,cpuKernelImpl:B.rI}),rJ={kernelName:s.tG8,backendName:"webgl",kernelFunc:rX},r0=D({opSnippet:_+` 2629 return log(1.0 + x); 2630`}),r1={kernelName:s.Cg$,backendName:"webgl",kernelFunc:r0},r2=O({opSnippet:"return float(a >= 1.0 && b >= 1.0);",packedOpSnippet:` 2631 return vec4( 2632 vec4(greaterThanEqual(a, vec4(1.0))) * 2633 vec4(greaterThanEqual(b, vec4(1.0)))); 2634`,dtype:"bool"}),r3={kernelName:s.RUm,backendName:"webgl",kernelFunc:r2},r4=D({opSnippet:"return float(!(x >= 1.0));"}),r5={kernelName:s.nZd,backendName:"webgl",kernelFunc:r4},r6=O({opSnippet:"return float(a >= 1.0 || b >= 1.0);",packedOpSnippet:` 2635 return min( 2636 vec4(greaterThanEqual(a, vec4(1.0))) + 2637 vec4(greaterThanEqual(b, vec4(1.0))), 2638 vec4(1.0)); 2639`,dtype:"bool"}),r7={kernelName:s.LXA,backendName:"webgl",kernelFunc:r6};class r9{constructor(e,t,r,n,a){let s;this.variableNames=["x"],this.outputShape=[];let i=e[3]-1;this.outputShape=e;let o=`float(${r}) + float(${n}) * sum`;s=.5===a?`inversesqrt(${o})`:1===a?`1.0/(${o})`:`exp(log(${o}) * float(-${a}));`,this.userCode=` 2640 void main() { 2641 ivec4 coords = getOutputCoords(); 2642 int b = coords[0]; 2643 int r = coords[1]; 2644 int c = coords[2]; 2645 int d = coords[3]; 2646 float x = getX(b, r, c, d); 2647 float sum = 0.0; 2648 for (int j = -${t}; j <= ${t}; j++) { 2649 int idx = d + j; 2650 if (idx >= 0 && idx <= ${i}) { 2651 float z = getX(b, r, c, idx); 2652 sum += z * z; 2653 } 2654 } 2655 float val = x * ${s}; 2656 setOutput(val); 2657 } 2658 `}}class r8{constructor(e,t,r,n,a){let s;this.variableNames=["x"],this.outputShape=[],this.packedInputs=!0,this.packedOutput=!0;let i=e[3]-1;this.outputShape=e;let o=`float(${r}) + float(${n}) * sum`;s=.5===a?`inversesqrt(${o})`:1===a?`1.0/(${o})`:`exp(log(${o}) * float(-${a}));`,this.userCode=` 2659 void main() { 2660 ivec4 coords = getOutputCoords(); 2661 int b = coords.x; 2662 int r = coords.y; 2663 int c = coords.z; 2664 int d = coords.w; 2665 2666 bool hasNextCol = d < ${this.outputShape[3]}; 2667 bool hasNextRow = c < ${this.outputShape[2]}; 2668 2669 vec4 sum = vec4(0.); 2670 vec4 xFragAtOutputCoords = getX(b, r, c, d); 2671 2672 vec4 xAtOutputCoords = vec4( 2673 getChannel(xFragAtOutputCoords, vec2(c, d)), 2674 hasNextCol ? 2675 getChannel(xFragAtOutputCoords, vec2(c, d + 1)) : 0.0, 2676 hasNextRow ? 2677 getChannel(xFragAtOutputCoords , vec2(c + 1, d)) : 0.0, 2678 (hasNextRow && hasNextCol) ? 2679 getChannel(xFragAtOutputCoords, vec2(c + 1, d + 1)) : 0.0 2680 ); 2681 2682 int firstChannel = d - ${t}; 2683 vec2 cache = vec2(0.); 2684 if(firstChannel >= 0){ 2685 vec4 firstChannelFrag = getX(b, r, c, firstChannel); 2686 cache.x = getChannel(firstChannelFrag, vec2(c, firstChannel)); 2687 if(hasNextRow){ 2688 cache.y = getChannel(firstChannelFrag, vec2(c + 1, firstChannel)); 2689 } 2690 } 2691
2692 ivec2 depth = ivec2(d, d + 1); 2693 for (int j = - ${t}; j <= ${t}; j++) { 2694 ivec2 idx = depth + j; 2695 bvec2 aboveLowerBound = greaterThanEqual(idx, ivec2(0)); 2696 bvec2 belowUpperBound = lessThanEqual(idx, ivec2(${i})); 2697 2698 bool depthInRange = aboveLowerBound.x && belowUpperBound.x; 2699 bool depthPlusOneInRange = aboveLowerBound.y && belowUpperBound.y; 2700 2701 if(depthInRange || depthPlusOneInRange){ 2702 vec4 z = vec4(0.); 2703 vec4 xFragAtCurrentDepth; 2704 z.xz = cache.xy; 2705 if(depthPlusOneInRange && hasNextCol){ 2706 xFragAtCurrentDepth = idx.y != d ? 2707 getX(b, r, c, idx.y) : xFragAtOutputCoords; 2708 z.y = getChannel(xFragAtCurrentDepth, vec2(c, idx.y)); 2709 if(hasNextRow){ 2710 z.w = getChannel(xFragAtCurrentDepth, vec2(c + 1, idx.y)); 2711 } 2712 } 2713 cache.xy = z.yw; 2714 sum += z * z; 2715 } 2716 } 2717 vec4 result = xAtOutputCoords * ${s}; 2718 setOutput(result); 2719 } 2720 `}}let ne={kernelName:s.jM4,backendName:"webgl",kernelFunc:e=>{let{inputs:t,backend:r,attrs:n}=e,{x:a}=t,{depthRadius:i,bias:o,alpha:l,beta:u}=n,h=(0,s._K2)().getBool("WEBGL_PACK_NORMALIZATION")?new r8(a.shape,i,o,l,u):new r9(a.shape,i,o,l,u);return r.runWebGLProgram(h,[a],a.dtype)}};class nt{constructor(e,t,r,n,a){this.variableNames=["inputImage","outputImage","dy"],this.outputShape=[],this.outputShape=e,this.depth=e[3],this.depthRadius=t,this.bias=r,this.alpha=n,this.beta=a,this.userCode=` 2721 void main() { 2722 ivec4 coords = getOutputCoords(); 2723 int b = coords[0]; 2724 int r = coords[1]; 2725 int c = coords[2]; 2726 2727 float result = 0.0; 2728 for (int d = 0; d < ${this.depth}; ++d) { 2729 int depthBegin = int(max(0.0, float(d - ${t}))); 2730 int depthEnd = int(min(float(${this.depth}), 2731 float(d + ${t} + 1))); 2732 2733 const int MIN_DEPTH_BEGIN = 0; 2734 const int MAX_DEPTH_END = ${this.depth}; 2735 2736 float norm = 0.0; 2737 for (int k = MIN_DEPTH_BEGIN; k < MAX_DEPTH_END; ++k) { 2738 if (k < depthBegin){ 2739 continue; 2740 } 2741 else if (k >= depthBegin && k < depthEnd) { 2742 norm += getInputImage(b, r, c, k) * getInputImage(b, r, c, k); 2743 } 2744 else { 2745 break; 2746 } 2747 } 2748 2749 norm = float(${n}) * norm + float(${r}); 2750 2751 for(int k = MIN_DEPTH_BEGIN; k < MAX_DEPTH_END; ++k){ 2752 if (k < depthBegin){ 2753 continue; 2754 } 2755 else if (k >= depthBegin && k < depthEnd){ 2756 float dyi = -2.0 * float(${n}) 2757 * float(${a}) 2758 * getInputImage(b, r, c, k) * getOutputImage(b, r, c, d) 2759 / norm; 2760 if (k == d) { 2761 dyi += pow(norm, -1.0 * ${a}); 2762 } 2763 if (k == coords[3]) { 2764 dyi *= getDy(b, r, c, d); 2765 result += dyi; 2766 } 2767 } 2768 else { 2769 break; 2770 } 2771 } 2772 } 2773 setOutput(result); 2774 } 2775 `}}let nr={kernelName:s.ToN,backendName:"webgl",kernelFunc:e=>{let{inputs:t,backend:r,attrs:n}=e,{x:a,y:s,dy:i}=t,{depthRadius:o,bias:l,alpha:u,beta:h}=n,p=new nt(a.shape,o,l,u,h);return r.runWebGLProgram(p,[a,s,i],a.dtype)}};function nn(e){let t,{inputs:r,backend:n,attrs:a}=e,{x:i}=r,{reductionIndices:o,keepDims:l}=a,u=i.shape.length,h=s.ZSL.parseAxisParam(o,i.shape),p=h,d=s.C0T.getAxesPermutation(p,u),c=null!=d,f=n.shouldExecuteOnCPU([i]),m=i;if(c){if(f){let e=n.texData.get(m.dataId).values,t=Array(u);for(let e=0;e<t.length;e++)t[e]=i.shape[d[e]];let r=(0,B.Q5)(e,i.shape,i.dtype,d,t);m=n.makeTensorInfo(t,i.dtype),n.texData.get(m.dataId).values=r}else m=X(i,d,n);p=s.C0T.getInnerMostAxes(p.length,u)}s.C0T.assertAxesAreInnerMostDims("max",p,u);let[g,y]=s.C0T.computeOutAndReduceShapes(m.shape,p),b=g;if(l&&(b=s.C0T.expandShapeToKeepDim(g,h)),f){let e=n.texData.get(m.dataId).values,r=(0,B.rw)(e,s.ZSL.sizeFromShape(y),b,i.dtype);t=n.makeTensorInfo(b,i.dtype),n.texData.get(t.dataId).values=r}else t=function(e,t,r,n){let a=s.ZSL.sizeFromShape(t),i=s.ZSL.sizeFromShape(e.shape),o=Z({inputs:{x:e},attrs:{shape:[i/a,a]},backend:n}),l=Y(o,e.dtype,"max",n),u=Z({inputs:{x:l},attrs:{shape:r},backend:n});return n.disposeIntermediateTensorInfo(o),n.disposeIntermediateTensorInfo(l),u}(m,y,b,n);return c&&n.disposeIntermediateTensorInfo(m),t}let na={kernelName:s.VAI,backendName:"webgl",kernelFunc:nn},ns=O({opSnippet:m+` 2776 return max(a, b); 2777`,packedOpSnippet:` 2778 vec4 result = vec4(max(a, b)); 2779 bvec4 isNaNA = isnan(a); 2780 bvec4 isNaNB = isnan(b); 2781 bvec4 isNaN = bvec4(isNaNA.x || isNaNB.x, isNaNA.y || isNaNB.y, isNaNA.z || isNaNB.z, isNaNA.w || isNaNB.w); 2782 `+x+` 2783 return result; 2784`,cpuKernelImpl:B.Dy}),ni={kernelName:s.LDN,backendName:"webgl",kernelFunc:ns},no={kernelName:s.t3d,backendName:"webgl",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{x:a}=t;(0,u.assertNotComplex)(a,"maxPool");let{filterSize:i,strides:o,pad:l,dimRoundingMode:h}=n;s.ZSL.assert(s.C0T.eitherStridesOrDilationsAreOne(o,1),()=>`Error in maxPool: Either strides or dilations must be 1. Got strides ${o} and dilations '1'`);let p=s.C0T.computePool2DInfo(a.shape,i,o,1,l,h);if(1===p.filterWidth&&1===p.filterHeight&&s.ZSL.arraysEqual(p.inShape,p.outShape))return w({inputs:{x:a},backend:r});let d=new eD(p,"max",!1);return r.runWebGLProgram(d,[a],a.dtype)}},nl={kernelName:s.ySp,backendName:"webgl",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{x:a}=t,{filterSize:i,strides:o,pad:l,dataFormat:u,dimRoundingMode:h}=n,p=new eO(s.C0T.computePool3DInfo(a.shape,i,o,[1,1,1],l,h,u),"max",!1);return r.runWebGLProgram(p,[a],a.dtype)}};
2784class nu{constructor(e){this.variableNames=["dy","maxPos"],this.outputShape=e.inShape;let t=e.strideHeight,r=e.strideWidth,n=e.dilationHeight,a=e.effectiveFilterHeight,s=e.effectiveFilterWidth,i=a-1-e.padInfo.top,o=s-1-e.padInfo.left;this.userCode=` 2785 const ivec2 pads = ivec2(${i}, ${o}); 2786 2787 void main() { 2788 ivec4 coords = getOutputCoords(); 2789 int b = coords[0]; 2790 int d = coords[3]; 2791 2792 ivec2 dyRCCorner = coords.yz - pads; 2793 int dyRCorner = dyRCCorner.x; 2794 int dyCCorner = dyRCCorner.y; 2795 2796 // Convolve dy(?, ?, d) with pos mask(:, :, d) to get dx(xR, xC, d). 2797 // ? = to be determined. : = across all values in that axis. 2798 float dotProd = 0.0; 2799 for (int wR = 0; wR < ${a}; 2800 wR += ${n}) { 2801 float dyR = float(dyRCorner + wR) / ${t}.0; 2802 2803 if (dyR < 0.0 || dyR >= ${e.outHeight}.0 || fract(dyR) > 0.0) { 2804 continue; 2805 } 2806 int idyR = int(dyR); 2807 2808 for (int wC = 0; wC < ${s}; wC++) { 2809 float dyC = float(dyCCorner + wC) / ${r}.0; 2810 2811 if (dyC < 0.0 || dyC >= ${e.outWidth}.0 || 2812 fract(dyC) > 0.0) { 2813 continue; 2814 } 2815 int idyC = int(dyC); 2816 2817 float dyValue = getDy(b, idyR, idyC, d); 2818 int maxPosValue = ${a*s-1} - int(getMaxPos(b, idyR, idyC, d)); 2819 2820 // Get the current value, check it against the value from the 2821 // position matrix. 2822 int curPosValue = wR * ${s} + wC; 2823 float mask = float(maxPosValue == curPosValue ? 1.0 : 0.0); 2824 2825 dotProd += dyValue * mask; 2826 } 2827 } 2828 setOutput(dotProd); 2829 } 2830 `}}class nh{constructor(e){this.variableNames=["dy","maxPos"],this.outputShape=e.inShape;let t=e.strideDepth,r=e.strideHeight,n=e.strideWidth,a=e.dilationDepth,s=e.dilationHeight,i=e.dilationWidth,o=e.effectiveFilterDepth,l=e.effectiveFilterHeight,u=e.effectiveFilterWidth,h=o-1-e.padInfo.front,p=l-1-e.padInfo.top,d=u-1-e.padInfo.left;this.userCode=` 2831 const ivec3 pads = ivec3(${h}, ${p}, ${d}); 2832 2833 void main() { 2834 ivec5 coords = getOutputCoords(); 2835 int batch = coords.x; 2836 int ch = coords.u; 2837 2838 ivec3 dyCorner = ivec3(coords.y, coords.z, coords.w) - pads; 2839 int dyDCorner = dyCorner.x; 2840 int dyRCorner = dyCorner.y; 2841 int dyCCorner = dyCorner.z; 2842 2843 // Convolve dy(?, ?, ?, ch) with pos mask(:, :, :, d) to get 2844 // dx(xD, xR, xC, ch). 2845 // ? = to be determined. : = across all values in that axis. 2846 float dotProd = 0.0; 2847 2848 for (int wD = 0; wD < ${o}; 2849 wD += ${a}) { 2850 float dyD = float(dyDCorner + wD) / ${t}.0; 2851 2852 if (dyD < 0.0 || dyD >= ${e.outDepth}.0 || fract(dyD) > 0.0) { 2853 continue; 2854 } 2855 int idyD = int(dyD); 2856 2857 for (int wR = 0; wR < ${l}; 2858 wR += ${s}) { 2859 float dyR = float(dyRCorner + wR) / ${r}.0; 2860 2861 if (dyR < 0.0 || dyR >= ${e.outHeight}.0 || 2862 fract(dyR) > 0.0) { 2863 continue; 2864 } 2865 int idyR = int(dyR); 2866 2867 for (int wC = 0; wC < ${u}; 2868 wC += ${i}) { 2869 float dyC = float(dyCCorner + wC) / ${n}.0; 2870 2871 if (dyC < 0.0 || dyC >= ${e.outWidth}.0 || 2872 fract(dyC) > 0.0) { 2873 continue; 2874 } 2875 int idyC = int(dyC); 2876 2877 float dyValue = getDy(batch, idyD, idyR, idyC, ch); 2878 int maxPosValue = ${o*l*u-1} - 2879 int(getMaxPos(batch, idyD, idyR, idyC, ch)); 2880 2881 // Get the current value, check it against the value from the 2882 // position matrix. 2883 int curPosValue = 2884 wD * ${l} * ${u} + 2885 wR * ${u} + wC; 2886 float mask = float(maxPosValue == curPosValue ? 1.0 : 0.0); 2887 2888 dotProd += dyValue * mask; 2889 } 2890 } 2891 } 2892 setOutput(dotProd); 2893 } 2894 `}}let np={kernelName:s.cHb,backendName:"webgl",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{dy:a,input:i}=t,{filterSize:o,strides:l,pad:u,dimRoundingMode:h}=n,p=s.C0T.computePool3DInfo(i.shape,o,l,[1,1,1],u,h),d=new eO(p,"max",!0),c=r.runWebGLProgram(d,[i],i.dtype),f=new nh(p),m=r.runWebGLProgram(f,[a,c],i.dtype);return r.disposeIntermediateTensorInfo(c),m}},nd={kernelName:s.RXX,backendName:"webgl",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{dy:a,input:i,output:o}=t;(0,u.assertNotComplex)([i,o],"maxPoolGrad");let{filterSize:l,strides:h,pad:p,dimRoundingMode:d}=n,c=s.C0T.computePool2DInfo(i.shape,l,h,1,p,d),f=new eD(c,"max",!0),m=r.runWebGLProgram(f,[i],i.dtype),g=new nu(c),y=r.runWebGLProgram(g,[a,m],i.dtype);return r.disposeIntermediateTensorInfo(m),y}}
2894,nc={kernelName:s.TL8,backendName:"webgl",kernelFunc:({inputs:e,attrs:t,backend:r})=>{let{x:n}=e,{filterSize:a,strides:i,pad:o,includeBatchInIndex:l}=t;s.ZSL.assert(4===n.shape.length,()=>`Error in maxPool: input must be rank 4 but got rank ${n.shape.length}.`);let u=[1,1];s.ZSL.assert(s.C0T.eitherStridesOrDilationsAreOne(i,u),()=>`Error in maxPool: Either strides or dilations must be 1. Got strides ${i} and dilations '${u}'`);let h=s.C0T.computePool2DInfo(n.shape,a,i,u,o),[p,d]=function(e,t,r,n){let a=new eD(r,"max",!1),s=n.runWebGLProgram(a,[e],"float32");return a=new eD(r,"max",!0,!0,t),[s,n.runWebGLProgram(a,[e],"float32")]}(n,l,h,r);return[p,d]}},nf={kernelName:s.g5A,backendName:"webgl",kernelFunc:({inputs:e,attrs:t,backend:r})=>{let{x:n}=e,{keepDims:a,axis:i}=t,o=n.shape.length,l=s.ZSL.parseAxisParam(i,n.shape),u=l,h=s.C0T.getAxesPermutation(u,o),p=null!=h,d=r.shouldExecuteOnCPU([n]),c=[],f=n;if(p){if(d){let e=r.texData.get(f.dataId).values,t=Array(o);for(let e=0;e<t.length;e++)t[e]=n.shape[h[e]];let a=(0,B.Q5)(e,n.shape,n.dtype,h,t);f=r.makeTensorInfo(t,n.dtype),r.texData.get(f.dataId).values=a}else f=X(n,h,r);c.push(f),u=s.C0T.getInnerMostAxes(u.length,o)}s.C0T.assertAxesAreInnerMostDims("sum",u,o);let[m,g]=s.C0T.computeOutAndReduceShapes(f.shape,u),y=m;a&&(y=s.C0T.expandShapeToKeepDim(m,l));let b=function(e,t,r,n){let a=s.ZSL.sizeFromShape(t),i=s.ZSL.sizeFromShape(e.shape),o=Z({inputs:{x:e},attrs:{shape:[i/a,a]},backend:n}),l=Y(o,"float32","mean",n),u=Z({inputs:{x:l},attrs:{shape:r},backend:n});return n.disposeIntermediateTensorInfo(o),n.disposeIntermediateTensorInfo(l),u}(f,g,y,r);for(let e of c)r.disposeIntermediateTensorInfo(e);return b}},nm={kernelName:s.lNG,backendName:"webgl",kernelFunc:function(e){let t,{inputs:r,backend:n,attrs:a}=e,{x:i}=r,{axis:o,keepDims:l}=a,u=i.shape.length,h=s.ZSL.parseAxisParam(o,i.shape),p=h,d=s.C0T.getAxesPermutation(p,u),c=i;null!=d&&(c=et({inputs:{x:i},backend:n,attrs:{perm:d}}),p=s.C0T.getInnerMostAxes(p.length,i.shape.length)),s.C0T.assertAxesAreInnerMostDims("min",p,u);let[f,m]=s.C0T.computeOutAndReduceShapes(c.shape,p),g=Z({inputs:{x:c},backend:n,attrs:{shape:[-1,s.ZSL.sizeFromShape(m)]}}),y=Y(g,g.dtype,"min",n);return t=l?Z({inputs:{x:y},backend:n,attrs:{shape:s.C0T.expandShapeToKeepDim(f,h)}}):Z({inputs:{x:y},backend:n,attrs:{shape:f}}),n.disposeIntermediateTensorInfo(g),n.disposeIntermediateTensorInfo(y),null!=d&&n.disposeIntermediateTensorInfo(c),t}},ng=O({opSnippet:m+` 2895 return min(a, b); 2896`,packedOpSnippet:` 2897 vec4 result = vec4(min(a, b)); 2898 bvec4 isNaNA = isnan(a); 2899 bvec4 isNaNB = isnan(b); 2900 bvec4 isNaN = bvec4(isNaNA.x || isNaNB.x, isNaNA.y || isNaNB.y, isNaNA.z || isNaNB.z, isNaNA.w || isNaNB.w); 2901 `+x+` 2902 return result; 2903`,cpuKernelImpl:B.h}),ny={kernelName:s.LG0,backendName:"webgl",kernelFunc:ng};class nb{constructor(e,t,r){this.variableNames=["x"],this.outputShape=t.map((t,r)=>t[0]+e[r]+t[1]);let n=e.length,a=(0,b.bf)(n),s=t.map(e=>e[0]).join(","),i=t.map((t,r)=>t[0]+e[r]).join(","),o=["coords[0]","coords[1]","coords[2]","coords[3]"].slice(0,n),l=+("reflect"!==r);if(1===n){this.userCode=` 2904 int start = ${s}; 2905 int end = ${i}; 2906 2907 void main() { 2908 int outC = getOutputCoords(); 2909 if (outC < start) { 2910 outC = start * 2 - outC - ${l}; 2911 } else if(outC >= end) { 2912 outC = (end - 1) * 2 - outC + ${l}; 2913 } 2914 setOutput(getX(outC - start)); 2915 } 2916 `;return}this.userCode=` 2917 ${a} start = ${a}(${s}); 2918 ${a} end = ${a}(${i}); 2919 2920 void main() { 2921 ${a} outC = getOutputCoords(); 2922 for (int i = 0; i < ${n}; i++) { 2923 if (outC[i] < start[i]) { 2924 outC[i] = start[i] * 2 - outC[i] - ${l}; 2925 } else if(outC[i] >= end[i]) { 2926 outC[i] = (end[i] - 1) * 2 - outC[i] + ${l}; 2927 } 2928 } 2929 ${a} coords = outC - start; 2930 setOutput(getX(${o})); 2931 } 2932 `}}class nx{constructor(e,t,r){this.variableNames=["x"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=t.map((t,r)=>t[0]+e[r]+t[1]);let n=e.length,a=(0,b.bf)(n),s=t.map(e=>e[0]).join(","),i=t.map((t,r)=>t[0]+e[r]).join(","),o=(0,y.Jp)("rc",n),l=(0,y.Jp)("source",n),u=`${o[n-1]} < ${this.outputShape[n-1]}`,h=1===n?"source":`vec2(${l.slice(-2).join()})`,p=+("reflect"!==r),d="";if(1===n){let e=` 2933 ${a} source = rc; 2934 if (source < start) { 2935 source = start * 2 - source - ${p}; 2936 } else if (source >= end) {
2937 source = (end - 1) * 2 - source + ${p}; 2938 } 2939 source -= start; 2940 `;d=` 2941 ${a} rc = outputLoc; 2942 ${e} 2943 result[0] = getChannel(getX(${l.join()}), ${h}); 2944 ${o[n-1]} += 1; 2945 if(${u}) { 2946 ${e} 2947 result[1] = getChannel(getX(${l.join()}), ${h}); 2948 } 2949 `}else{let e=` 2950 ${a} source = rc; 2951 ${a} lt = ${a}(lessThan(source, start)); 2952 ${a} gte = ${a}(greaterThanEqual(source, end)); 2953 ${a} orig = 1 - (lt + gte); 2954 source = orig * source + 2955 lt * (start * 2 - source - ${p}) + 2956 gte * ((end - 1) * 2 - source + ${p}); 2957 source -= start; 2958 `;d=` 2959 ${a} rc = outputLoc; 2960 ${e} 2961 result[0] = getChannel(getX(${l.join()}), ${h}); 2962 ${o[n-1]} += 1; 2963 if(${u}) { 2964 ${e} 2965 result[1] = getChannel(getX(${l.join()}), ${h}); 2966 } 2967 rc = outputLoc; 2968 ${o[n-2]} += 1; 2969 if(${o[n-2]} < ${this.outputShape[n-2]}) { 2970 ${e} 2971 result[2] = getChannel(getX(${l.join()}), ${h}); 2972 ${o[n-1]} += 1; 2973 if(${u}) { 2974 ${e} 2975 result[3] = getChannel(getX(${l.join()}), ${h}); 2976 } 2977 } 2978 `}this.userCode=` 2979 const ${a} start = ${a}(${s}); 2980 const ${a} end = ${a}(${i}); 2981 2982 void main() { 2983 ${a} outputLoc = getOutputCoords(); 2984 vec4 result = vec4(0.); 2985 ${d} 2986 setOutput(result); 2987 } 2988 `}}let nv={kernelName:s.x7F,backendName:"webgl",kernelFunc:({inputs:e,backend:t,attrs:r})=>{let{x:n}=e,{paddings:a,mode:i}=r,o=(0,s._K2)().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new nx(n.shape,a,i):new nb(n.shape,a,i);return t.runWebGLProgram(o,[n],n.dtype)}},nw=O({opSnippet:`if (b == 0.0) return NAN; 2989 return mod(a, b);`,packedOpSnippet:` 2990 vec4 result = mod(a, b); 2991 bvec4 isNaN = equal(b, vec4(0.0)); 2992 `+x+` 2993 return result; 2994`}),nT={kernelName:s.BLA,backendName:"webgl",kernelFunc:nw};class nS{constructor(e,t,r){this.variableNames=["probs"],this.customUniforms=[{name:"seed",type:"float"}],this.outputShape=[e,r],this.userCode=` 2995 void main() { 2996 ivec2 coords = getOutputCoords(); 2997 int batch = coords[0]; 2998 2999 float r = random(seed); 3000 float cdf = 0.0; 3001 3002 for (int i = 0; i < ${t-1}; i++) { 3003 cdf += getProbs(batch, i); 3004 3005 if (r < cdf) { 3006 setOutput(float(i)); 3007 return; 3008 } 3009 } 3010 3011 // If no other event happened, last event happened. 3012 setOutput(float(${t-1})); 3013 } 3014 `}}let nN=O({opSnippet:` 3015if (a == b) { 3016 return 1.0; 3017}; 3018return a / b;`,packedOpSnippet:` 3019 // vec4 one = vec4(equal(a, b)); 3020 // return one + (vec4(1.0) - one) * a / b; 3021 vec4 result = a / b; 3022 if(a.x == b.x) { 3023 result.x = 1.; 3024 } 3025 if(a.y == b.y) { 3026 result.y = 1.; 3027 } 3028 if(a.z == b.z) { 3029 result.z = 1.; 3030 } 3031 if(a.w == b.w) { 3032 result.w = 1.; 3033 } 3034 3035 return result; 3036`,checkOutOfBounds:!0}),nk={kernelName:s.sDr,backendName:"webgl",kernelFunc:nN},nI="return a - b;",nC=O({opSnippet:nI,packedOpSnippet:nI,supportsComplex:!0,cpuKernelImpl:B.lL}),nE={kernelName:s.PbM,backendName:"webgl",kernelFunc:nC};function nA(e){let{inputs:t,backend:r,attrs:n}=e,{logits:a}=t,{dim:i}=n,o=s.ZSL.parseAxisParam([i],a.shape),l=nn({inputs:{x:a},backend:r,attrs:{reductionIndices:o,keepDims:!1}}),u=s.C0T.expandShapeToKeepDim(l.shape,o),h=Z({inputs:{x:l},backend:r,attrs:{shape:u}}),p=nC({inputs:{a:a,b:h},backend:r}),d=ra({inputs:{x:p},backend:r}),c=J({inputs:{x:d},backend:r,attrs:{axis:o,keepDims:!1}}),f=Z({inputs:{x:c},backend:r,attrs:{shape:u}}),m=nN({inputs:{a:d,b:f},backend:r});return r.disposeIntermediateTensorInfo(l),r.disposeIntermediateTensorInfo(h),r.disposeIntermediateTensorInfo(p),r.disposeIntermediateTensorInfo(d),r.disposeIntermediateTensorInfo(c),r.disposeIntermediateTensorInfo(f),m}let n$={kernelName:s.rFG,backendName:"webgl",kernelFunc:nA},nF={kernelName:s.WT3,backendName:"webgl",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{logits:a}=t,{numSamples:s,seed:i,normalized:o}=n,l=o?a:nA({inputs:{logits:a},backend:r,attrs:{dim:a.shape.length-1}}),u=new nS(l.shape[0],l.shape[1],s),h=r.runWebGLProgram(u,[l],"int32",[[i]]);return o||r.disposeIntermediateTensorInfo(l),h}},nR=F.dR+` 3037 return -x; 3038`,n_=` 3039 vec4 result = -x; 3040 bvec4 isNaN = isnan(x); 3041 3042 result.r = isNaN.r ? x.r : result.r; 3043 result.g = isNaN.g ? x.g : result.g; 3044 result.b = isNaN.b ? x.b : result.b; 3045 result.a = isNaN.a ? x.a : result.a; 3046 3047 return result; 3048`,nD={kernelName:s.l0G,backendName:"webgl",kernelFunc:function(e){let t,{inputs:r,backend:n}=e,{x:a}=r;if(n.shouldExecuteOnCPU([a])){let e=n.texData.get(a.dataId),[t,r]=(0,B.rQ)(e.values,a.shape,a.dtype);return n.makeTensorInfo(r,a.dtype,t)}return t=(0,s._K2)().getBool("WEBGL_PACK_UNARY_OPERATIONS")?new R.rf(a.shape,n_):new F.hE(a.shape,nR),n.runWebGLProgram(t,[a],a.dtype)}},nO=s.kpo.nonMaxSuppressionV3Impl,nL={kernelName:s.SDM,backendName:"webgl",kernelFunc:function(e){s.C0T.warn("tf.nonMaxSuppression() in webgl locks the UI thread. Call tf.nonMaxSuppressionAsync() instead");let{inputs:t,backend:r,attrs:n}=e,{boxes:a,scores:i}=t,{maxOutputSize:o,iouThreshold:l,scoreThreshold:u}=n,{selectedIndices:h}=nO(r.readSync(a.dataId),r.readSync(i.dataId),o,l,u);return r.makeTensorInfo([h.length],"int32",new Int32Array(h))}},nM=s.kpo.nonMaxSuppressionV4Impl,nP={kernelName:s.Zl4,backendName:"webgl",kernelFunc:function(e){s.C0T.warn("tf.nonMaxSuppression() in webgl locks the UI thread. Call tf.nonMaxSuppressionAsync() instead");let{inputs:t,backend:r,attrs:n}=e,{boxes:a,scores:i}=t,{maxOutputSize:o,iouThreshold:l,scoreThreshold:u,padToMaxOutputSize:h}=n,{selectedIndices:p,validOutputs:d}=nM(r.readSync(a.dataId),r.readSync(i.dataId),o,l,u,h);return[r.makeTensorInfo([p.length],"int32",new Int32Array(p)),r.makeTensorInfo([],"int32",new Int32Array([d]))]}},nz=s.kpo.nonMaxSuppressionV5Impl,nB={kernelName:s.e0f,backendName:"webgl",kernelFunc:function(e){s.C0T.warn("tf.nonMaxSuppression() in webgl locks the UI thread. Call tf.nonMaxSuppressionAsync() instead");let{inputs:t,backend:r,attrs:n}=e,{boxes:a,scores:i}=t,{maxOutputSize:o,iouThreshold:l,scoreThreshold:u,softNmsSigma:h}=n,p=r.readSync(a.dataId),{selectedIndices:d,selectedScores:c}=nz(p,r.readSync(i.dataId),o,l,u,h);return[r.makeTensorInfo([d.length],"int32",new Int32Array(d)),r.makeTensorInfo([c.length],"float32",new Float32Array(c))]}};
3048class nW{constructor(e,t,r,n){this.variableNames=["indices"],this.outputShape=[e,t],this.userCode=` 3049 void main() { 3050 ivec2 coords = getOutputCoords(); 3051 int index = round(getIndices(coords.x)); 3052 setOutput(mix(float(${n}), float(${r}), 3053 float(index == coords.y))); 3054 } 3055 `}}let nV={kernelName:s.urI,backendName:"webgl",kernelFunc:e=>{let{inputs:t,backend:r,attrs:n}=e,{indices:a}=t,{dtype:i,depth:o,onValue:l,offValue:u}=n,h=s.ZSL.sizeFromShape(a.shape),p=new nW(h,o,l,u),d=Z({inputs:{x:a},backend:r,attrs:{shape:[h]}}),c=r.runWebGLProgram(p,[d],i);r.disposeIntermediateTensorInfo(d);let f=Z({inputs:{x:c},backend:r,attrs:{shape:[...a.shape,o]}});return r.disposeIntermediateTensorInfo(c),f}};function nG(e){let{inputs:t,backend:r}=e,{x:n}=t;if("complex64"!==n.dtype)return rm({attrs:{shape:n.shape,dtype:n.dtype,value:"string"===n.dtype?"":0},backend:r});{let e=e5({inputs:{input:n},backend:r}),t=nG({inputs:{x:e},backend:r}),a=th({inputs:{input:n},backend:r}),s=nG({inputs:{x:a},backend:r}
3055),i=S({inputs:{real:t,imag:s},backend:r});return r.disposeIntermediateTensorInfo(e),r.disposeIntermediateTensorInfo(t),r.disposeIntermediateTensorInfo(a),r.disposeIntermediateTensorInfo(s),i}}let nU={kernelName:s.xJ3,backendName:"webgl",kernelFunc:nG},nZ={kernelName:s.LWX,backendName:"webgl",kernelFunc:function e(t){let{inputs:r,backend:n}=t,{x:a}=r;if("string"===a.dtype)throw Error("onesLike is not supported under string dtype");if("complex64"!==a.dtype)return rm({attrs:{shape:a.shape,dtype:a.dtype,value:1},backend:n});{let t=e5({inputs:{input:a},backend:n}),r=e({inputs:{x:t},backend:n}),s=th({inputs:{input:a},backend:n}),i=nG({inputs:{x:s},backend:n}),o=S({inputs:{real:r,imag:i},backend:n});return n.disposeIntermediateTensorInfo(t),n.disposeIntermediateTensorInfo(r),n.disposeIntermediateTensorInfo(s),n.disposeIntermediateTensorInfo(i),o}}},nj={kernelName:s.mM$,backendName:"webgl",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{axis:a}=n;if(1===t.length)return ri({inputs:{input:t[0]},backend:r,attrs:{dim:a}});let i=t[0].shape,o=t[0].dtype;t.forEach(e=>{s.ZSL.assertShapesMatch(i,e.shape,"All tensors passed to stack must have matching shapes"),s.ZSL.assert(o===e.dtype,()=>"All tensors passed to stack must have matching dtypes")});let l=[],u=td({inputs:t.map(e=>{let t=ri({inputs:{input:e},backend:r,attrs:{dim:a}});return l.push(t),t}),backend:r,attrs:{axis:a}});return l.forEach(e=>r.disposeIntermediateTensorInfo(e)),u}};class nH{constructor(e,t,r){this.variableNames=["x"],this.customUniforms=[{name:"value",type:"float"}],this.outputShape=t.map((t,r)=>t[0]+e[r]+t[1]);let n=e.length,a=(0,b.bf)(n),s=t.map(e=>e[0]).join(","),i=t.map((t,r)=>t[0]+e[r]).join(","),o=["coords[0]","coords[1]","coords[2]","coords[3]"].slice(0,n);if(1===n){this.userCode=` 3056 int start = ${s}; 3057 int end = ${i}; 3058 3059 void main() { 3060 int outC = getOutputCoords(); 3061 if (outC < start || outC >= end) { 3062 setOutput(value); 3063 } else { 3064 setOutput(getX(outC - start)); 3065 } 3066 } 3067 `;return}this.userCode=` 3068 ${a} start = ${a}(${s}); 3069 ${a} end = ${a}(${i}); 3070 3071 void main() { 3072 ${a} outC = getOutputCoords(); 3073 if (any(lessThan(outC, start)) || any(greaterThanEqual(outC, end))) { 3074 setOutput(value); 3075 } else { 3076 ${a} coords = outC - start; 3077 setOutput(getX(${o})); 3078 } 3079 } 3080 `}}class nK{constructor(e,t,r){this.variableNames=["x"],this.packedInputs=!0,this.packedOutput=!0,this.customUniforms=[{name:"value",type:"float"}],this.outputShape=t.map((t,r)=>t[0]+e[r]+t[1]);let n=e.length,a=(0,b.bf)(n),s=t.map(e=>e[0]).join(","),i=t.map((t,r)=>t[0]+e[r]).join(","),o=(0,y.Jp)("rc",n),l=(0,y.Jp)("source",n),u=`${o[n-1]} < ${this.outputShape[n-1]}`,h=1===n?"source":`vec2(${l.slice(-2).join()})`,p=[`${a} rc = outputLoc;`,`${o[n-1]} += 1; 3081 if(${u}) { 3082 `,1===n?"":`} 3083 rc = outputLoc; 3084 ${o[n-2]} += 1; 3085 if(${o[n-2]} < ${this.outputShape[n-2]}) {`,1===n?"":` ${o[n-1]} += 1; 3086 if(${u}) {`],d=1===n?"rc < start || rc >= end":"any(lessThan(rc, start)) || any(greaterThanEqual(rc, end))",c="";for(let e=0,t=1===n?2:4;e<t;e++)c+=` 3087 ${p[e]} 3088 if (${d}) { 3089 result[${e}] = float(value); 3090 } else { 3091 ${a} source = rc - start; 3092 result[${e}] = getChannel(getX(${l.join()}), ${h}); 3093 } 3094 `;c+=1===n?"} ":"}}",this.userCode=` 3095 const ${a} start = ${a}(${s}); 3096 const ${a} end = ${a}(${i}); 3097 3098 void main() { 3099 ${a} outputLoc = getOutputCoords(); 3100 vec4 result = vec4(0.); 3101 ${c} 3102 setOutput(result); 3103 } 3104 `}}let nY=e=>{let{inputs:t,backend:r,attrs:n}=e,{x:a}=t,{paddings:i,constantValue:o}=n;if(0===s.ZSL.sizeFromShape(a.shape))return rm({backend:r,attrs:{shape:i.map((e,t)=>e[0]+a.shape[t]+e[1]),value:o,dtype:a.dtype}});let l=(0,s._K2)().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new nK(a.shape,i,o):new nH(a.shape,i,o),u=[[o]];return r.runWebGLProgram(l,[a],a.dtype,u)},nQ={kernelName:s.ODT,backendName:"webgl",kernelFunc:nY},nq=O({opSnippet:` 3105 if(a < 0.0 && floor(b) < b){ 3106 return NAN; 3107 } 3108 if (b == 0.0) { 3109 return 1.0; 3110 } 3111 return (round(mod(b, 2.0)) != 1) ?
3112 pow(abs(a), b) : sign(a) * pow(abs(a), b); 3113`,packedOpSnippet:` 3114 // isModRound1 has 1 for components with round(mod(b, 2.0)) == 1, 0 otherwise. 3115 vec4 isModRound1 = vec4(equal(round(mod(b, 2.0)), ivec4(1))); 3116 vec4 multiplier = sign(a) * isModRound1 + (vec4(1.0) - isModRound1); 3117 vec4 result = multiplier * pow(abs(a), b); 3118 3119 // Ensure that a^0 = 1, including 0^0 = 1 as this correspond to TF and JS 3120 bvec4 isExpZero = equal(b, vec4(0.0)); 3121 result.r = isExpZero.r ? 1.0 : result.r; 3122 result.g = isExpZero.g ? 1.0 : result.g; 3123 result.b = isExpZero.b ? 1.0 : result.b; 3124 result.a = isExpZero.a ? 1.0 : result.a; 3125 3126 bvec4 isNaN1 = lessThan(a, vec4(0.0)); 3127 bvec4 isNaN2 = lessThan(floor(b), b); 3128 bvec4 isNaN = bvec4(isNaN1.x && isNaN2.x, isNaN1.y && isNaN2.y, isNaN1.z && isNaN2.z, isNaN1.w && isNaN2.w); 3129 `+x+` 3130 return result; 3131`}),nX={kernelName:s.pyJ,backendName:"webgl",kernelFunc:nq},nJ={kernelName:s.kdj,backendName:"webgl",kernelFunc:function(e){let t,{inputs:r,backend:n,attrs:a}=e,{x:i}=r,{axis:o,keepDims:l}=a,u=i.shape.length,h=[],p=s.ZSL.parseAxisParam(o,i.shape),d=p,c=s.C0T.getAxesPermutation(d,u),f=i;if(null!=c&&(f=et({inputs:{x:i},backend:n,attrs:{perm:c}}),d=s.C0T.getInnerMostAxes(d.length,u),h.push(f)),s.C0T.assertAxesAreInnerMostDims("prod",d,u),n.shouldExecuteOnCPU([f])){let e=n.texData.get(f.dataId).values,{outVals:r,outShape:a,outDtype:s}=(0,B.Og)(f.shape,f.dtype,e,d);t=n.makeTensorInfo(a,s,r)}else{let[e,r]=s.C0T.computeOutAndReduceShapes(f.shape,d),a=Z({inputs:{x:f},backend:n,attrs:{shape:[-1,s.ZSL.sizeFromShape(r)]}}),o=Y(a,(0,s.chL)(i.dtype),"prod",n);t=Z({inputs:{x:o},backend:n,attrs:{shape:e}}),h.push(a),h.push(o)}if(l){h.push(t);let e=s.C0T.expandShapeToKeepDim(t.shape,p);t=Z({inputs:{x:t},backend:n,attrs:{shape:e}})}return h.forEach(e=>n.disposeIntermediateTensorInfo(e)),t}},n0={kernelName:s.oJ2,backendName:"webgl",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{paramsNestedSplits:a,paramsDenseValues:s,indices:i}=t,{outputRaggedRank:o}=n,l=a.map(e=>r.readSync(e.dataId)),u=a.map(e=>e.shape),h=r.readSync(s.dataId),p=r.readSync(i.dataId),[d,c,f]=(0,B.G4)(l,u,h,s.shape,s.dtype,p,i.shape,o),m=d.map(e=>r.makeTensorInfo([e.length],"int32",e)),g=r.makeTensorInfo(f,s.dtype,c);return m.concat([g])}},n1={kernelName:s.CQC,backendName:"webgl",kernelFunc:function(e){let{inputs:t,backend:r}=e,{starts:n,limits:a,deltas:s}=t,i=r.readSync(n.dataId),o=r.readSync(a.dataId),l=r.readSync(s.dataId),[u,h]=(0,B.Oy)(i,n.shape,n.dtype,o,a.shape,l,s.shape);return[r.makeTensorInfo([u.length],"int32",u),r.makeTensorInfo([h.length],n.dtype,h)]}},n2={kernelName:s.mH5,backendName:"webgl",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{shape:a,values:s,defaultValue:i,rowPartitionTensors:o}=t,{rowPartitionTypes:l}=n,u=r.readSync(a.dataId),h=r.readSync(s.dataId),p=r.readSync(i.dataId),d=o.map(e=>r.readSync(e.dataId)),c=o.map(e=>e.shape),[f,m]=(0,B.G3)(u,a.shape,h,s.shape,s.dtype,p,i.shape,d,c,l);return r.makeTensorInfo(f,s.dtype,m)}},n3=e=>{let{backend:t,attrs:r}=e,{start:n,stop:a,step:s,dtype:i}=r,o=(0,B.we)(n,a,s,i);return t.makeTensorInfo([o.length],i,o)},n4={kernelName:s.Q6t,backendName:"webgl",kernelFunc:n3},n5=D({opSnippet:"return 1.0 / x;"}),n6={kernelName:s.huO,backendName:"webgl",kernelFunc:n5},n7=D({opSnippet:F.dR+` 3132 return (x < 0.0) ? 0.0 : x; 3133`,packedOpSnippet:` 3134 vec4 result = x * vec4(greaterThanEqual(x, vec4(0.0))); 3135 bvec4 isNaN = isnan(x); 3136 3137 result.r = isNaN.r ? x.r : result.r; 3138 result.g = isNaN.g ? x.g : result.g; 3139 result.b = isNaN.b ? x.b : result.b; 3140 result.a = isNaN.a ? x.a : result.a; 3141 3142 return result; 3143`}),n9={kernelName:s.fUj,backendName:"webgl",kernelFunc:n7},n8=D({opSnippet:F.dR+` 3144 return (x < 0.0) ? 0.0 : min(6.0, x); 3145`,packedOpSnippet:` 3146 vec4 result = min(x, vec4(6.)) * vec4(greaterThanEqual(x, vec4(0.0))); 3147 bvec4 isNaN = isnan(x); 3148 3149 result.r = isNaN.r ? x.r : result.r; 3150 result.g = isNaN.g ? x.g : result.g; 3151 result.b = isNaN.b ? x.b : result.b; 3152 result.a = isNaN.a ? x.a : result.a; 3153 3154 return result; 3155`}),ae={kernelName:s.P_L,backendName:"webgl",kernelFunc:n8};class at{constructor(e,t,r,n,a){this.variableNames=["A"],this.outputShape=[];let[s,i,o,l]=e;this.outputShape=[s,t,r,l];let u=[n&&t>1?i-1:i,n&&r>1?o-1:o],h=[n&&t>1?t-1:t,n&&r>1?r-1:r];this.userCode=` 3156 const vec2 effectiveInputOverOutputRatioRC = vec2( 3157 ${u[0]/h[0]}, 3158 ${u[1]/h[1]}); 3159 const vec2 inputShapeRC = vec2(${i}.0, ${o}.0); 3160 3161 void main() { 3162 ivec4 coords = getOutputCoords(); 3163 int b = coords[0]; 3164 int d = coords[3]; 3165 ivec2 yRC = coords.yz; 3166 3167 // Fractional source index. 3168 vec2 sourceFracIndexRC = ${a?"(vec2(yRC) + vec2(0.5)) * effectiveInputOverOutputRatioRC - vec2(0.5)":"vec2(yRC) * effectiveInputOverOutputRatioRC"}; 3169 3170 // Compute the four integer indices. 3171 ivec2 sourceFloorRC = ivec2(max(sourceFracIndexRC, vec2(0.0))); 3172 ivec2 sourceCeilRC = ivec2( 3173 min(inputShapeRC - 1.0, ceil(sourceFracIndexRC))); 3174 3175 float topLeft = getA(b, sourceFloorRC.x, sourceFloorRC.y, d); 3176 float bottomLeft = getA(b, sourceCeilRC.x, sourceFloorRC.y, d); 3177 float topRight = getA(b, sourceFloorRC.x, sourceCeilRC.y, d); 3178 float bottomRight = getA(b, sourceCeilRC.x, sourceCeilRC.y, d); 3179 3180 vec2 fracRC = sourceFracIndexRC - vec2(sourceFloorRC); 3181 3182 float top = topLeft + (topRight - topLeft) * fracRC.y; 3183 float bottom = bottomLeft + (bottomRight - bottomLeft) * fracRC.y; 3184 float newValue = top + (bottom - top) * fracRC.x; 3185 3186 setOutput(newValue); 3187 } 3188 `}}class ar{constructor(e,t,r,n,a){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=[];let[s,i,o,l]=e;this.outputShape=[s,t,r,l];let u=[n&&t>1?i-1:i,n&&r>1?o-1:o],h=[n&&t>1?t-1:t,n&&r>1?r-1:r];this.userCode=` 3189 const vec3 effectiveInputOverOutputRatioRC = vec3( 3190 ${u[0]/h[0]}, 3191 ${u[1]/h[1]}, 3192 ${u[1]/h[1]}); 3193 const vec3 inputShapeRC = vec3(${i}.0, ${o}.0, 3194 ${o}.0); 3195 3196 float getAValue(int b, int r, int c, int d) { 3197 return getChannel(getA(b, r, c, d), vec2(c, d)); 3198 } 3199 3200 void main() { 3201 ivec4 coords = getOutputCoords(); 3202 int b = coords[0]; 3203 int d = coords[3]; 3204 // Calculate values for next column in yRC.z. 3205 ivec3 yRC = coords.yzz + ivec3(0, 0, 1); 3206 3207 // Fractional source index. 3208 vec3 sourceFracIndexRC = ${a?"(vec3(yRC) + vec3(0.5)) * effectiveInputOverOutputRatioRC - vec3(0.5)":"vec3(yRC) * effectiveInputOverOutputRatioRC"}; 3209 3210 // Compute the four integer indices. 3211 ivec3 sourceFloorRC = ivec3(max(sourceFracIndexRC, vec3(0.0))); 3212 ivec3 sourceCeilRC = ivec3( 3213 min(inputShapeRC - 1.0, ceil(sourceFracIndexRC))); 3214 3215 // Should we calculate next column and row elements in 2x2 packed cell. 3216 bool hasNextCol = d < ${l-1}; 3217 bool hasNextRow = coords.z < ${r-1}
vendor: 2,018 bytes, lines 3217-3265
3217; 3218 3219 // In parallel, construct four corners for all four components in 3220 // packed 2x2 cell. 3221 vec4 topLeft = vec4( 3222 getAValue(b, sourceFloorRC.x, sourceFloorRC.y, d), 3223 hasNextCol ? getAValue(b, sourceFloorRC.x, sourceFloorRC.y, d + 1) 3224 : 0.0, 3225 hasNextRow ? getAValue(b, sourceFloorRC.x, sourceFloorRC.z, d) 3226 : 0.0, 3227 (hasNextRow && hasNextCol) ? 3228 getAValue(b, sourceFloorRC.x, sourceFloorRC.z, d + 1) : 0.0); 3229 3230 vec4 bottomLeft = vec4( 3231 getAValue(b, sourceCeilRC.x, sourceFloorRC.y, d), 3232 hasNextCol ? getAValue(b, sourceCeilRC.x, sourceFloorRC.y, d + 1) 3233 : 0.0, 3234 hasNextRow ? getAValue(b, sourceCeilRC.x, sourceFloorRC.z, d) 3235 : 0.0, 3236 (hasNextRow && hasNextCol) ? 3237 getAValue(b, sourceCeilRC.x, sourceFloorRC.z, d + 1) : 0.0); 3238 3239 vec4 topRight = vec4( 3240 getAValue(b, sourceFloorRC.x, sourceCeilRC.y, d), 3241 hasNextCol ? getAValue(b, sourceFloorRC.x, sourceCeilRC.y, d + 1) 3242 : 0.0, 3243 hasNextRow ? getAValue(b, sourceFloorRC.x, sourceCeilRC.z, d) 3244 : 0.0, 3245 (hasNextRow && hasNextCol) ? 3246 getAValue(b, sourceFloorRC.x, sourceCeilRC.z, d + 1) : 0.0); 3247 3248 vec4 bottomRight = vec4( 3249 getAValue(b, sourceCeilRC.x, sourceCeilRC.y, d), 3250 hasNextCol ? getAValue(b, sourceCeilRC.x, sourceCeilRC.y, d + 1) 3251 : 0.0, 3252 hasNextRow ? getAValue(b, sourceCeilRC.x, sourceCeilRC.z, d) 3253 : 0.0, 3254 (hasNextRow && hasNextCol) ? 3255 getAValue(b, sourceCeilRC.x, sourceCeilRC.z, d + 1) : 0.0); 3256 3257 vec3 fracRC = sourceFracIndexRC - vec3(sourceFloorRC); 3258 3259 vec4 top = mix(topLeft, topRight, fracRC.yyzz); 3260 vec4 bottom = mix(bottomLeft, bottomRight, fracRC.yyzz); 3261 vec4 newValue = mix(top, bottom, fracRC.x); 3262 3263 setOutput(newValue); 3264 } 3265 `}
3265}let an={kernelName:s.hgw,backendName:"webgl",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{images:a}=t,{alignCorners:i,halfPixelCenters:o,size:l}=n,[u,h]=l,p=(0,s._K2)().getBool("WEBGL_PACK_IMAGE_OPERATIONS")?new ar(a.shape,u,h,i,o):new at(a.shape,u,h,i,o);return r.runWebGLProgram(p,[a],"float32")}};class aa{constructor(e,t,r){this.variableNames=["dy"],this.outputShape=[],this.outputShape=t;let[,n,a]=t,[,s,i]=e,o=[r&&s>1?n-1:n,r&&i>1?a-1:a],l=[r&&s>1?s-1:s,r&&i>1?i-1:i],u=o[0]/l[0],h=o[1]/l[1],p=1/u,d=1/h,c=2*Math.ceil(p)+2,f=2*Math.ceil(d)+2;this.userCode=` 3266 void main() { 3267 ivec4 coords = getOutputCoords(); 3268 int b = coords[0]; 3269 int d = coords[3]; 3270 int r = coords[1]; 3271 int c = coords[2]; 3272 3273 float accumulator = 0.0; 3274 3275 const float heightScale = float(${u}); 3276 const float widthScale = float(${h}); 3277 3278 const float invHeightScale = float(${p}); 3279 const float invWidthScale = float(${d}); 3280 3281 const int winHeight = int(${c}); 3282 const int winWidth = int(${f}); 3283 3284 // Compute bounds for where in dy we will look 3285 float startRLerp = floor(float(r) * invHeightScale); 3286 int startDyR = int(startRLerp - float(winHeight / 2)); 3287 3288 float startCLerp = floor(float(c) * invWidthScale); 3289 int startDyC = int(startCLerp - float(winWidth / 2)); 3290 3291 // Loop over dy 3292 for (int dyROffset = 0; dyROffset < winHeight; dyROffset++) { 3293 int dyR = dyROffset + startDyR; 3294 3295 // Guard against the window exceeding the bounds of dy 3296 if (dyR < 0 || dyR >= ${s}) { 3297 continue; 3298 } 3299 3300 for (int dyCOffset = 0; dyCOffset < winWidth; dyCOffset++) { 3301 int dyC = dyCOffset + startDyC; 3302 3303 // Guard against the window exceeding the bounds of dy 3304 if (dyC < 0 || dyC >= ${i}) { 3305 continue; 3306 } 3307 3308 float dxR = float(dyR) * heightScale; 3309 int topDxRIndex = int(floor(dxR)); 3310 int bottomDxRIndex = int(min(ceil(dxR), ${n-1}.0)); 3311 float dxRLerp = dxR - float(topDxRIndex); 3312 float inverseDxRLerp = 1.0 - dxRLerp; 3313 3314 float dxC = float(dyC) * widthScale; 3315 int leftDxCIndex = int(floor(dxC)); 3316 int rightDxCIndex = int(min(ceil(dxC), ${a-1}.0)); 3317 float dxCLerp = dxC - float(leftDxCIndex); 3318 float inverseDxCLerp = 1.0 - dxCLerp; 3319 3320 if (r == topDxRIndex && c == leftDxCIndex) { 3321 // topLeft 3322 accumulator += 3323 getDy(b, dyR, dyC, d) * inverseDxRLerp * inverseDxCLerp; 3324 } 3325 3326 if (r == topDxRIndex && c == rightDxCIndex) { 3327 // topRight 3328 accumulator += getDy(b, dyR, dyC, d) * inverseDxRLerp * dxCLerp; 3329 } 3330 3331 if (r == bottomDxRIndex && c == leftDxCIndex) { 3332 // bottomLeft 3333 accumulator += getDy(b, dyR, dyC, d) * dxRLerp * inverseDxCLerp; 3334 } 3335 3336 if (r == bottomDxRIndex && c == rightDxCIndex) { 3337 // bottomRight 3338 accumulator += getDy(b, dyR, dyC, d) * dxRLerp * dxCLerp; 3339 } 3340 } 3341 } 3342 // End loop over dy 3343 3344 setOutput(accumulator); 3345 } 3346 `}}let as={kernelName:s.FCQ,backendName:"webgl",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{images:a,dy:s}=t,{alignCorners:i}=n,o=new aa(s.shape,a.shape,i);return r.runWebGLProgram(o,[s],s.dtype)}};class ai{constructor(e,t,r,n,a){this.variableNames=["A"],this.outputShape=[];let[s,i,o,l]=e;this.outputShape=[s,t,r,l];let u=[n&&t>1?i-1:i,n&&r>1?o-1:o],h=[n&&t>1?t-1:t,n&&r>1?r-1:r];this.userCode=` 3347 const vec2 effectiveInputOverOutputRatioRC = vec2( 3348 ${u[0]/h[0]}, 3349 ${u[1]/h[1]}); 3350 const vec2 inputShapeRC = vec2(${i}.0, ${o}.0); 3351 3352 void main() { 3353 ivec4 coords = getOutputCoords(); 3354 int b = coords[0]; 3355 int d = coords[3]; 3356 ivec2 yRC = coords.yz; 3357 3358 // Fractional source index. 3359 vec2 sourceFracIndexRC = ${a?"max((vec2(yRC) + vec2(0.5)) * effectiveInputOverOutputRatioRC, vec2(0.0))":"vec2(yRC) * effectiveInputOverOutputRatioRC"}; 3360 3361 // Compute the coordinators of nearest neighbor point. 3362 ivec2 sourceNearestRC = ivec2( 3363 min(inputShapeRC - 1.0, floor(sourceFracIndexRC + ${n?"0.5":"0.0"}))); 3364 float newValue = getA(b, sourceNearestRC.x, sourceNearestRC.y, d); 3365 3366 setOutput(newValue); 3367 } 3368 `}}class ao{constructor(e,t,r,n,a){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=[];let[s,i,o,l]=e;this.outputShape=[s,t,r,l];let u=[n&&t>1?i-1:i,n&&r>1?o-1:o],h=[n&&t>1?t-1:t,n&&r>1?r-1:r];this.userCode=` 3369 const vec3 effectiveInputOverOutputRatioRC = vec3( 3370 ${u[0]/h[0]}, 3371 ${u[1]/h[1]}, 3372 ${u[1]/h[1]}); 3373 const vec3 inputShapeRC = vec3(${i}.0, ${o}.0, 3374 ${o}.0); 3375 3376 float getAValue(int b, int r, int c, int d) { 3377 return getChannel(getA(b, r, c, d), vec2(c, d)); 3378 } 3379 3380 void main() { 3381 ivec4 coords = getOutputCoords(); 3382 int b = coords[0]; 3383 int d = coords[3]; 3384 // Calculate values for next column in yRC.z. 3385 ivec3 yRC = coords.yzz + ivec3(0, 0, 1); 3386 3387 // Fractional source index. 3388 vec3 sourceFracIndexRC = ${a?"max((vec3(yRC) + vec3(0.5)) * effectiveInputOverOutputRatioRC, vec3(0.0))":"vec3(yRC) * effectiveInputOverOutputRatioRC"}; 3389 3390 // Compute the coordinators of nearest neighbor point. 3391 ivec3 sourceNearestRC = ivec3( 3392 min(inputShapeRC - 1.0, floor(sourceFracIndexRC + ${n?"0.5":"0.0"}))); 3393 3394 // Should we calculate next column and row elements in 2x2 packed cell. 3395 bool hasNextCol = d < ${l-1}; 3396 bool hasNextRow = coords.z < ${r-1}; 3397 3398 vec4 newValue = vec4(
3399 getAValue(b, sourceNearestRC.x, sourceNearestRC.y, d), 3400 hasNextCol ? getAValue(b, sourceNearestRC.x, sourceNearestRC.y, d + 1) 3401 : 0.0, 3402 hasNextRow ? getAValue(b, sourceNearestRC.x, sourceNearestRC.z, d) 3403 : 0.0, 3404 (hasNextRow && hasNextCol) ? 3405 getAValue(b, sourceNearestRC.x, sourceNearestRC.z, d + 1) : 0.0); 3406 3407 setOutput(newValue); 3408 } 3409 `}}let al={kernelName:s.jOE,backendName:"webgl",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{images:a}=t,{alignCorners:i,halfPixelCenters:o,size:l}=n,[u,h]=l,p=(0,s._K2)().getBool("WEBGL_PACK_IMAGE_OPERATIONS")?new ao(a.shape,u,h,i,o):new ai(a.shape,u,h,i,o);return r.runWebGLProgram(p,[a],a.dtype)}};class au{constructor(e,t,r){this.variableNames=["dy"],this.outputShape=[],this.outputShape=t;let[,n,a]=t,[,s,i]=e,o=[r&&s>1?n-1:n,r&&i>1?a-1:a],l=[r&&s>1?s-1:s,r&&i>1?i-1:i],u=o[0]/l[0],h=o[1]/l[1],p=1/u,d=1/h,c=2*Math.ceil(p)+2,f=2*Math.ceil(d)+2;this.userCode=` 3410 void main() { 3411 ivec4 coords = getOutputCoords(); 3412 int b = coords[0]; 3413 int d = coords[3]; 3414 int r = coords[1]; 3415 int c = coords[2]; 3416 3417 float accumulator = 0.0; 3418 3419 const float heightScale = float(${u}); 3420 const float widthScale = float(${h}); 3421 3422 const float invHeightScale = float(${p}); 3423 const float invWidthScale = float(${d}); 3424 3425 const int winHeight = int(${c}); 3426 const int winWidth = int(${f}); 3427 3428 // Compute bounds for where in dy we will look 3429 float startRLerp = floor(float(r) * invHeightScale); 3430 int startDyR = int(floor(startRLerp - float(winHeight / 2))); 3431 3432 float startCLerp = floor(float(c) * invWidthScale); 3433 int startDyC = int(floor(startCLerp - float(winWidth / 2))); 3434 3435 // Loop over dy 3436 for (int dyROffset = 0; dyROffset < winHeight; dyROffset++) { 3437 int dyR = dyROffset + startDyR; 3438 3439 // Guard against the window exceeding the bounds of dy 3440 if (dyR < 0 || dyR >= ${s}) { 3441 continue; 3442 } 3443 3444 for (int dyCOffset = 0; dyCOffset < winWidth; dyCOffset++) { 3445 int dyC = dyCOffset + startDyC; 3446 3447 // Guard against the window exceeding the bounds of dy 3448 if (dyC < 0 || dyC >= ${i}) { 3449 continue; 3450 } 3451 3452 float sourceFracRow = 3453 float(${o[0]}) * 3454 (float(dyR) / float(${l[0]})); 3455 3456 float sourceFracCol = 3457 float(${o[1]}) * 3458 (float(dyC) / float(${l[1]})); 3459 3460 int sourceNearestRow = int(min( 3461 float(int(${n}) - 1), 3462 ${r} ? float(round(sourceFracRow)) : 3463 float(floor(sourceFracRow)))); 3464 3465 int sourceNearestCol = int(min( 3466 float(int(${a}) - 1), 3467 ${r} ? float(round(sourceFracCol)) : 3468 float(floor(sourceFracCol)))); 3469 3470 if (r == sourceNearestRow && c == sourceNearestCol) { 3471 accumulator += getDy(b, dyR, dyC, d); 3472 } 3473 } 3474 } 3475 // End loop over dy 3476 3477 setOutput(accumulator); 3478 } 3479 `}}let ah={kernelName:s.XQy,backendName:"webgl",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{images:a,dy:s}=t,{alignCorners:i}=n,o=new au(s.shape,a.shape,i);return r.runWebGLProgram(o,[s],s.dtype)}};class ap{constructor(e,t){this.variableNames=["x"];let r=e.length;if(r>4)throw Error(`WebGL backend: Reverse of rank-${r} tensor is not yet supported`);if(this.outputShape=e,1===r){this.userCode=` 3480 void main() { 3481 int coord = getOutputCoords(); 3482 setOutput(getX(${e[0]} - coord - 1)); 3483 } 3484 `;return}let n=r=>-1!==t.indexOf(r)&&1!==e[r]?`${e[r]} - coords[${r}] - 1`:`coords[${r}]`,a=e.map((e,t)=>n(t)).join(","),s=(0,b.bf)(r);this.userCode=` 3485 void main() { 3486 ${s} coords = getOutputCoords(); 3487 setOutput(getX(${a})); 3488 } 3489 `}}class ad{constructor(e,t){this.variableNames=["x"],this.packedInputs=!0,this.packedOutput=!0;let r=e.length;if(r>4)throw Error(`WebGL backend: Reverse of rank-${r} tensor is not yet supported`);this.outputShape=e;let n=(0,y.Jp)("rc",r),a=`${n[r-1]} + 1 < ${this.outputShape[r-1]}`,s=`${n[r-2]} + 1 < ${this.outputShape[r-2]}`,i=(0,b.bf)(r);function o(r){let n=e.map((n,a)=>{var s,i;return s=a,i=r,-1!==t.indexOf(s)&&1!==e[s]?`${e[s]} - ${i[s]} - 1`:`${i[s]}`}),a=n.join(","),s=n.slice(-2).join(",");return`getChannel(getX(${a}), vec2(${s}))`}1===r?this.userCode=` 3490 void main(){ 3491 int rc = getOutputCoords(); 3492 vec4 result = vec4(0.); 3493 result.r = getChannel(getX(${e[0]} - rc - 1), 3494 ${e[0]} - rc - 1); 3495 if(${a}){ 3496 result.g = getChannel(getX(${e[0]} - (rc + 1) - 1), 3497 ${e[0]} - (rc + 1) - 1); 3498 } 3499 setOutput(result); 3500 } 3501 `:this.userCode=` 3502 void main() { 3503 ${i} rc = getOutputCoords(); 3504 vec4 result = vec4(0.); 3505 result.r = ${o(n.slice())}; 3506 if(${a}){ 3507 result.g = ${function(e){return e[r-1]="("+e[r-1]+" + 1)",o(e)}(n.slice())}; 3508 } 3509 if(${s}) { 3510 result.b = ${function(e){return e[r-2]="("+e[r-2]+" + 1)",o(e)}(n.slice())}; 3511 if(${a}) { 3512 result.a = ${function(e){return e[r-1]="("+e[r-1]+" + 1)",e[r-2]="("+e[r-2]+" + 1)",o(e)}(n.slice())}; 3513 } 3514 } 3515 setOutput(result); 3516 } 3517 `}}let ac={kernelName:s.D7i,backendName:"webgl",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{x:a}=t,{dims:i}=n,o=a.shape.length,l=s.ZSL.parseAxisParam(i,a.shape);if(0===o)return w({inputs:{x:a},backend:r});let u=(0,s._K2)().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new ad(a.shape,l):new ap(a.shape,l);return r.runWebGLProgram(u,[a],a.dtype)}};class af{constructor(e,t){this.variableNames=["Image"],this.outputShape=[],this.customUniforms=[{name:"params",type:"vec4"}];let r=e[1],n=e[2];this.outputShape=e;let a="";a="number"==typeof t?`float outputValue = ${t.toFixed(2)};`:` 3518 vec3 fill = vec3(${t.join(",")}); 3519 float outputValue = fill[coords[3]];`,this.userCode=` 3520 void main() { 3521 ivec4 coords = getOutputCoords(); 3522 int x = coords[2]; 3523 int y = coords[1]; 3524 float coordXFloat = (float(x) - params[0]) * params[3] - 3525 (float(y) - params[1]) * params[2]; 3526 float coordYFloat = (float(x) - params[0]) * params[2] + 3527 (float(y) - params[1]) * params[3];
3528 int coordX = int(round(coordXFloat + params[0])); 3529 int coordY = int(round(coordYFloat + params[1])); 3530 ${a} 3531 if(coordX >= 0 && coordX < ${n} && coordY >= 0 && coordY < ${r}) { 3532 outputValue = getImage(coords[0], coordY, coordX, coords[3]); 3533 } 3534 setOutput(outputValue); 3535 } 3536 `}}let am={kernelName:s.BK4,backendName:"webgl",kernelFunc:({inputs:e,attrs:t,backend:r})=>{let{image:n}=e,{radians:a,fillValue:i,center:o}=t,l=new af(n.shape,i),[u,h]=s.C0T.getImageCenter(o,n.shape[1],n.shape[2]),p=[[u,h,Math.sin(a),Math.cos(a)]];return r.runWebGLProgram(l,[n],n.dtype,p)}},ag=D({opSnippet:` 3537 // OpenGL ES does not support round function. 3538 // The algorithm is based on banker's rounding. 3539 float base = floor(x); 3540 if ((x - base) < 0.5) { 3541 return floor(x); 3542 } else if ((x - base) > 0.5) { 3543 return ceil(x); 3544 } else { 3545 if (mod(base, 2.0) == 0.0) { 3546 return base; 3547 } else { 3548 return base + 1.0; 3549 } 3550 } 3551`}),ay={kernelName:s.hVg,backendName:"webgl",kernelFunc:ag},ab=D({opSnippet:"return inversesqrt(x);",cpuKernelImpl:B.tc}),ax={kernelName:s.TOR,backendName:"webgl",kernelFunc:ab};class av{constructor(e,t,r,n,a,s,i=!0,o=!1){this.variableNames=["updates","indices","defaultValue"],this.outputShape=s;let l=(0,b.bf)(a.length),u=(0,b.bf)(s.length),h="";1===r?h="i":2===r&&(h="i, j");let p=`getIndices(${h})`,d="";1===n?d="i":2===n&&(d="i, coords[1]");let c=`getUpdates(${d})`,f="";o&&(f="coords[0], coords[1]");let m=`getDefaultValue(${f})`;this.userCode=` 3552 ${l} strides = ${l}(${a}); 3553 3554 void main() { 3555 ${u} coords = getOutputCoords(); 3556 float sum = 0.0; 3557 bool found = false; 3558 for (int i = 0; i < ${e}; i++) { 3559 int flattenedIndex = 0; 3560 for (int j = 0; j < ${t}; j++) { 3561 int index = round(${p}); 3562 flattenedIndex += index * ${t>1?"strides[j]":"strides"}; 3563 } 3564 if (flattenedIndex == coords[0]) { 3565 sum += ${c}; 3566 found = true; 3567 } 3568 } 3569 setOutput(mix(${m}, sum, float(found))); 3570 } 3571 `}}class aw{constructor(e,t,r,n,a,s,i=!0,o=!1){this.variableNames=["updates","indices","defaultValue"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=s;let l=(0,b.bf)(a.length),u=(0,b.bf)(s.length),h="";1===r?h="i":2===r&&(h="i, j");let p=`getIndices(${h})`,d="";1===n?d="i":2===n&&(d="i, coords[1]");let c=`getUpdates(${d})`,f="";o&&(f="coords[0], coords[1]");let m=`getDefaultValue(${f})`;this.userCode=` 3572 ${l} strides = ${l}(${a}); 3573 3574 void main() { 3575 ${u} coords = getOutputCoords(); 3576 vec4 sum = vec4(0.); 3577 vec4 found = vec4(0.); 3578 for (int i = 0; i < ${e}; i+=2) { 3579 ivec2 flattenedIndex = ivec2(0); 3580 for (int j = 0; j < ${t}; j+=2) { 3581 ivec4 index = round(${p}); 3582 flattenedIndex += index.xz * ${t>1?"strides[j]":"strides"}; 3583 if (j + 1 < ${t}) { 3584 flattenedIndex += index.yw * ${t>1?"strides[j + 1]":"strides"}; 3585 } 3586 } 3587 if (flattenedIndex[0] == coords[0] || flattenedIndex[1] == coords[0] || 3588 flattenedIndex[0] == coords[0] + 1 || flattenedIndex[1] == coords[0] + 1) { 3589 vec4 updVals = ${c}; 3590 if (flattenedIndex[0] == coords[0]) { 3591 sum.xy += updVals.xy; 3592 found.xy = vec2(1.); 3593 } else if (flattenedIndex[0] == coords[0] + 1) { 3594 sum.zw += updVals.xy; 3595 found.zw = vec2(1.); 3596 } 3597 if (flattenedIndex[1] == coords[0]) { 3598 sum.xy += updVals.zw; 3599 found.xy = vec2(1.); 3600 } else if (flattenedIndex[1] == coords[0] + 1) { 3601 sum.zw += updVals.zw; 3602 found.zw = vec2(1.); 3603 } 3604 } 3605 } 3606 setOutput(mix(${m}, sum, found)); 3607 } 3608 `}}let aT={kernelName:s.pJc,backendName:"webgl",kernelFunc:function(e){let t,{inputs:r,backend:n,attrs:a}=e,{indices:i,updates:o}=r,{shape:l}=a,{sliceRank:u,numUpdates:h,sliceSize:p,strides:d,outputSize:c}=s.C0T.calculateShapes(o,i,l),f=[c/p,p];if(0===c)return n.makeTensorInfo(l,i.dtype);let m=Z({inputs:{x:i},backend:n,attrs:{shape:[h,u]}}),g=Z({inputs:{x:o},backend:n,attrs:{shape:[h,p]}}),y=n.makeTensorInfo([],"float32",new Float32Array([0]));t=(0,s._K2)().getBool("WEBGL_PACK")?new aw(h,u,m.shape.length,g.shape.length,d,f):new av(h,u,m.shape.length,g.shape.length,d,f);let b=n.runWebGLProgram(t,[g,m,y],g.dtype),x=Z({inputs:{x:b},backend:n,attrs:{shape:l}});return n.disposeIntermediateTensorInfo(m),n.disposeIntermediateTensorInfo(g),n.disposeIntermediateTensorInfo(b),n.disposeIntermediateTensorInfo(y),x}};class aS{constructor(e,t,r,n){this.variableNames=["sortedSequence","values"],this.customUniforms=[{name:"numInputs",type:"int"}],this.outputShape=[e,r];let a=`for (int i = 0; i < ${Math.ceil(Math.log2(t+1))}; ++i) { if (left >= right) break;`,i=2===(0,s._K2)().getNumber("WEBGL_VERSION")?"while (left < right) {":a;this.userCode=` 3609 int findBound(int batch, float value) { 3610 int left = 0; 3611 int right = numInputs; 3612 int mid; 3613 ${i} 3614 mid = (left + right) / 2;
3615 if (getSortedSequence(batch, mid) ${"left"===n?"<":"<="} value) { 3616 left = mid + 1; 3617 } else { 3618 right = mid; 3619 } 3620 } 3621 return right; 3622 } 3623 3624 void main() { 3625 ivec2 coords = getOutputCoords(); 3626 int batch = coords[0]; 3627 int valueIndex = coords[1]; 3628 3629 float value = getValues(batch, valueIndex); 3630 3631 setOutput(float(findBound(batch, value))); 3632 } 3633 `}}let aN={kernelName:s.uWl,backendName:"webgl",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{sortedSequence:a,values:s}=t,{side:i}=n,o=new aS(a.shape[0],a.shape[1],s.shape[1],i),l=[[a.shape[1]]];return r.runWebGLProgram(o,[a,s],"int32",l)}};class ak{constructor(e,t,r){let n,a;if(this.variableNames=["c","a","b"],this.outputShape=t,r>4)throw Error(`Where for rank ${r} is not yet supported`);if(1===r)a="resRC",n="resRC";else{let r=["resRC.x","resRC.y","resRC.z","resRC.w"],s=[],i=[];for(let n=0;n<t.length;n++)i.push(`${r[n]}`),n<e&&s.push(`${r[n]}`);n=s.join(),a=i.join()}let s=(0,b.bf)(r);this.userCode=` 3634 void main() { 3635 ${s} resRC = getOutputCoords(); 3636 float cVal = getC(${n}); 3637 if (cVal >= 1.0) { 3638 setOutput(getA(${a})); 3639 } else { 3640 setOutput(getB(${a})); 3641 } 3642 } 3643 `}}let aI={kernelName:s.l6P,backendName:"webgl",kernelFunc:function(e){let{inputs:t,backend:r}=e,{condition:n,t:a,e:i}=t,o=new ak(n.shape.length,a.shape,a.shape.length);return r.runWebGLProgram(o,[n,a,i],(0,s.TuY)(a.dtype,i.dtype))}},aC=D({opSnippet:` 3644 // Stable and Attracting Fixed Point (0, 1) for Normalized Weights. 3645 // see: https://arxiv.org/abs/1706.02515 3646 float scaleAlpha = ${s.C0T.SELU_SCALEALPHA}; 3647 float scale = ${s.C0T.SELU_SCALE}; 3648 return (x >= 0.0) ? scale * x : scaleAlpha * (exp(x) - 1.0); 3649`}),aE={kernelName:s.u$b,backendName:"webgl",kernelFunc:aC},aA=D({opSnippet:_+` 3650 return 1.0 / (1.0 + exp(-1.0 * x)); 3651`,packedOpSnippet:` 3652 vec4 result = 1.0 / (1.0 + exp(-1.0 * x)); 3653 bvec4 isNaN = isnan(x); 3654 3655 result.r = isNaN.r ? x.r : result.r; 3656 result.g = isNaN.g ? x.g : result.g; 3657 result.b = isNaN.b ? x.b : result.b; 3658 result.a = isNaN.a ? x.a : result.a; 3659 3660 return result; 3661`,cpuKernelImpl:B.BC}),a$={kernelName:s.vI1,backendName:"webgl",kernelFunc:aA},aF=D({opSnippet:` 3662 if (isnan(x)) { return 0.0; } 3663 return sign(x); 3664`}),aR={kernelName:s.YVe,backendName:"webgl",kernelFunc:aF},a_=D({opSnippet:_+` 3665 return sin(x); 3666`,packedOpSnippet:` 3667 vec4 result = sin(x); 3668 bvec4 isNaN = isnan(x); 3669 ${x} 3670 return result; 3671`}),aD={kernelName:s.hql,backendName:"webgl",kernelFunc:a_},aO=D({opSnippet:` 3672 float e2x = exp(x); 3673 return (e2x - 1.0 / e2x) / 2.0; 3674`}),aL={kernelName:s.J3C,backendName:"webgl",kernelFunc:aO},aM=D({opSnippet:` 3675 float epsilon = 1.1920928955078125e-7; 3676 float threshold = log(epsilon) + 2.0; 3677 3678 bool too_large = x > -threshold; 3679 bool too_small = x < threshold; 3680 3681 float result; 3682 float exp_x = exp(x); 3683 3684 if (too_large){ 3685 result = x; 3686 } 3687 else if (too_small){ 3688 result = exp_x; 3689 } 3690 else{ 3691 result = log(exp_x + 1.0); 3692 } 3693 return result; 3694`}),aP={kernelName:s.Fin,backendName:"webgl",kernelFunc:aM},az={kernelName:s.A8B,backendName:"webgl",kernelFunc:e=>{let{inputs:t,backend:r,attrs:n}=e,{x:a}=t,{blockShape:i,paddings:o}=n;s.ZSL.assert(a.shape.length<=4,()=>"spaceToBatchND for rank > 4 with a WebGL backend not implemented yet");let l=i.reduce((e,t)=>e*t),u=[[0,0]];u.push(...o);for(let e=1+i.length;e<a.shape.length;++e)u.push([0,0]);let h=[],p=nY({inputs:{x:a},backend:r,attrs:{paddings:u,constantValue:0}}),d=s.C0T.getReshaped(p.shape,i,l,!1),c=s.C0T.getPermuted(d.length,i.length,!1),f=s.C0T.getReshapedPermuted(p.shape,i,l,!1),m=Z({inputs:{x:p},backend:r,attrs:{shape:d}}),g=et({inputs:{x:m},backend:r,attrs:{perm:c}}),y=Z({inputs:{x:g},backend:r,attrs:{shape:f}});return h.push(p),h.push(m),h.push(g),h.forEach(e=>r.disposeIntermediateTensorInfo(e)),y}},aB={kernelName:s.C8s,backendName:"webgl",kernelFunc:function(e){let{inputs:t,backend:r}=e,{indices:n,values:a,denseShape:s,defaultValue:i}=t;if(1!==s.shape.length)throw Error(`Dense shape must be a vector, saw: 3695 ${s.shape}`);if(2!==n.shape.length)throw Error(`Indices must be a matrix, saw: 3696 ${n.shape}`);if(1!==a.shape.length)throw Error(`Values must be a vector, saw: 3697 ${a.shape}`);if(0!==i.shape.length)throw Error(`Default value must be a scalar, saw: 3698 ${i.shape}`);let o=r.readSync(n.dataId),l=r.readSync(a.dataId),u=r.readSync(s.dataId),h=r.readSync(i.dataId)[0],[p,d,c,f,m]=(0,B.sB)(o,n.shape,n.dtype,l,a.dtype,u,h);return[r.makeTensorInfo(d,n.dtype,p),r.makeTensorInfo([d[0]],a.dtype,c),r.makeTensorInfo([f.length],"bool",new Uint8Array(f.map(e=>Number(e)))),r.makeTensorInfo([m.length],n.dtype,new Int32Array(m))]}},aW={kernelName:s.BoJ,backendName:"webgl",kernelFunc:function(e){let{inputs:t,backend:r}=e,{inputIndices:n,inputShape:a,newShape:s}=t;if(2!==n.shape.length)throw Error(`Input indices should be a matrix but received shape ${n.shape}`);if(1!==a.shape.length)throw Error(`Input shape should be a vector but received shape ${a.shape}`);if(1!==s.shape.length)throw Error(`Target shape should be a vector but received shape ${s.shape}`);let i=Array.from(r.readSync(a.dataId)),o=r.readSync(n.dataId),l=Array.from(r.readSync(s.dataId)),[u,h,p]=(0,B.vo)(o,n.shape,n.dtype,i,l);return[r.makeTensorInfo(h,n.dtype,u),r.makeTensorInfo([p.length],s.dtype,new Int32Array(p))]}},aV={kernelName:s.L6G,backendName:"webgl",kernelFunc:function(e){let{inputs:t,backend:r}=e,{data:n,indices:a,segmentIds:s}=t;if(n.shape.length<1)throw Error("Data should be at least 1 dimensional but received scalar");
3698if(1!==a.shape.length)throw Error(`Indices should be a vector but received shape 3699 ${a.shape}`);if(1!==s.shape.length)throw Error(`Segment ids should be a vector but received shape 3700 ${s.shape}`);let i=r.readSync(n.dataId),o=r.readSync(a.dataId),l=r.readSync(s.dataId),[u,h]=(0,B.zN)(i,n.shape,n.dtype,o,l,!0);return r.makeTensorInfo(h,n.dtype,u)}},aG={kernelName:s.DvZ,backendName:"webgl",kernelFunc:function(e){let{inputs:t,backend:r}=e,{data:n,indices:a,segmentIds:s}=t;if(n.shape.length<1)throw Error("Data should be at least 1 dimensional but received scalar");if(1!==a.shape.length)throw Error(`Indices should be a vector but received shape 3701 ${a.shape}`);if(1!==s.shape.length)throw Error(`Segment ids should be a vector but received shape 3702 ${s.shape}`);let i=r.readSync(n.dataId),o=r.readSync(a.dataId),l=r.readSync(s.dataId),[u,h]=(0,B.zN)(i,n.shape,n.dtype,o,l);return r.makeTensorInfo(h,n.dtype,u)}},aU={kernelName:s.jgd,backendName:"webgl",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{sparseIndices:a,sparseValues:i,defaultValue:o}=t,{outputShape:l}=n,{sliceRank:u,numUpdates:h,sliceSize:p,strides:d,outputSize:c}=s.C0T.calculateShapes(i,a,l);if("string"===i.dtype){let e=r.bufferSync(a),t=r.bufferSync(i),n=s.ZSL.decodeString(r.readSync(o.dataId)[0]),f=(0,B.fC)(e,t,l,c,p,h,u,d,n,!1);return r.makeTensorInfo(l,f.dtype,f.values)}let f=new av(h,u,a.shape.length,i.shape.length,d,[c,1],!1),m=r.runWebGLProgram(f,[i,a,o],i.dtype),g=Z({inputs:{x:m},backend:r,attrs:{shape:l}});return r.disposeIntermediateTensorInfo(m),g}},aZ={kernelName:s.Blb,backendName:"webgl",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{x:a}=t,{numOrSizeSplits:i,axis:o}=n,l=s.ZSL.parseAxisParam(o,a.shape)[0],u=s.C0T.prepareSplitSize(a,i,l),h=Array(a.shape.length).fill(0),p=a.shape.slice();return u.map(e=>{let t=[...p];t[l]=e;let n=eY({inputs:{x:a},backend:r,attrs:{begin:h,size:t}});return h[l]+=e,n})}},aj="return sqrt(x);",aH=D({opSnippet:aj,packedOpSnippet:aj,cpuKernelImpl:B.LF}),aK={kernelName:s.dFH,backendName:"webgl",kernelFunc:aH},aY=D({opSnippet:"return x * x;"}),aQ={kernelName:s.M6A,backendName:"webgl",kernelFunc:aY},aq="return (a - b) * (a - b);",aX=O({opSnippet:aq,packedOpSnippet:aq}),aJ={kernelName:s.Ddj,backendName:"webgl",kernelFunc:aX},a0={kernelName:s.GZp,backendName:"webgl",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{x:a}=t;if("string"!==a.dtype)throw Error("Input must be of datatype string");let i=r.readSync(a.dataId),o=s.C0T.fromUint8ToStringArray(i),l=(0,B.yZ)(o,"string",n);return r.makeTensorInfo(a.shape,"string",l)}},a1={kernelName:s.pnw,backendName:"webgl",kernelFunc:function({inputs:e,attrs:t,backend:r}){let{x:n}=e,a=F.dR+` 3703 return x > 0.0 ? 1.0 : float(${t.alpha}); 3704 `,s=new F.hE(n.shape,a);return r.runWebGLProgram(s,[n],n.dtype)}};class a2{constructor(e,t,r){this.variableNames=["x"],this.outputShape=r;let n=r.length,a=(0,b.bf)(r.length),s=(0,b.bf)(r.length),i="";if(1===n)i="coords * strides + begin";else{let e=0;i=r.map((t,n)=>(e++,1===r.length?`coords * strides[${n}] + begin[${n}]`:`coords[${e-1}] * strides[${n}] + begin[${n}]`)).join(",")}this.userCode=` 3705 ${a} begin = ${a}(${e}); 3706 ${a} strides = ${a}(${t}); 3707 3708 void main() { 3709 ${s} coords = getOutputCoords(); 3710 setOutput(getX(${i})); 3711 } 3712 `}}let a3={kernelName:s.UcO,backendName:"webgl",kernelFunc:function(e){let t,{inputs:r,backend:n,attrs:a}=e,{x:i}=r,{begin:o,end:l,strides:u,beginMask:h,endMask:p,ellipsisMask:d,newAxisMask:c,shrinkAxisMask:f}=a,{finalShapeSparse:m,finalShape:g,isIdentity:y,sliceDim0:b,isSimpleSlice:x,begin:v,end:w,strides:T}=s.Kro.sliceInfo(i.shape,o,l,u,h,p,d,c,f);if(y)t=Z({inputs:{x:i},backend:n,attrs:{shape:g}});else if(b||x){s.ZSL.assert(i.shape.length>=1,()=>`Input must have rank at least 1, got: ${i.shape.length}`);let e=s.Kro.computeOutShape(v,w,T),r=eY({inputs:{x:i},backend:n,attrs:{begin:v,size:e}});t=Z({inputs:{x:r},backend:n,attrs:{shape:g}}),n.disposeIntermediateTensorInfo(r)}else if(n.shouldExecuteOnCPU([i])){let e=n.readSync(i.dataId),r=(0,s.ra8)(i.shape,i.dtype,e),a=(0,B.cy)(m,r,T,v);t=n.makeTensorInfo(g,i.dtype,a.values)}else{let e=new a2(v,T,m);t=n.runWebGLProgram(e,[i],i.dtype)}let S=Z({inputs:{x:t},backend:n,attrs:{shape:g}});return n.disposeIntermediateTensorInfo(t),S}},a4={kernelName:s.YAb,backendName:"webgl",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}
3712=e,{separator:a,nGramWidths:s,leftPad:i,rightPad:o,padWidth:l,preserveShortSequences:u}=n,{data:h,dataSplits:p}=t,d=r.readSync(h.dataId),c=r.readSync(p.dataId),[f,m]=(0,B.UC)(d,c,a,s,i,o,l,u);return[r.makeTensorInfo([f.length],"string",f),r.makeTensorInfo(p.shape,"int32",m)]}},a5={kernelName:s.iW0,backendName:"webgl",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{skipEmpty:a}=n,{input:s,delimiter:i}=t;if("string"!==s.dtype)throw Error("Input must be of datatype string");if(1!==s.shape.length)throw Error(`Input must be a vector, got shape: ${s.shape}`);if(0!==i.shape.length)throw Error(`Delimiter must be a scalar, got shape: ${i.shape}`);let o=r.readSync(s.dataId),l=r.readSync(i.dataId)[0],[u,h,p]=(0,B.S6)(o,l,a),d=h.length;return[r.makeTensorInfo([d,2],"int32",u),r.makeTensorInfo([d],"string",h),r.makeTensorInfo([2],"int32",new Int32Array(p))]}},a6={kernelName:s.$jE,backendName:"webgl",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{numBuckets:a}=n,{input:s}=t;if("string"!==s.dtype)throw Error("Input must be of datatype string");if(a<=0)throw Error("Number of buckets must be at least 1");let i=r.readSync(s.dataId),o=(0,B.fW)(i,a);return r.makeTensorInfo(s.shape,"int32",o)}},a7=D({opSnippet:"return tan(x);"}),a9={kernelName:s.oFs,backendName:"webgl",kernelFunc:a7},a8=D({opSnippet:` 3713 float e2x = exp(-2.0 * abs(x)); 3714 return sign(x) * (1.0 - e2x) / (1.0 + e2x); 3715`}),se={kernelName:s.iuW,backendName:"webgl",kernelFunc:a8},st={kernelName:s.X4r,backendName:"webgl",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{tensor:a,indices:i,updates:o}=t,{}=n,{sliceRank:l,numUpdates:u,sliceSize:h,strides:p,outputSize:d}=s.C0T.calculateShapes(o,i,a.shape),c=[d/h,h];if(0===d)return r.makeTensorInfo(a.shape,i.dtype);let f=Z({inputs:{x:i},backend:r,attrs:{shape:[u,l]}}),m=Z({inputs:{x:o},backend:r,attrs:{shape:[u,h]}}),g=Z({inputs:{x:a},backend:r,attrs:{shape:c}}),y=new av(u,l,f.shape.length,m.shape.length,p,c,!1,!0),b=r.runWebGLProgram(y,[m,f,g],g.dtype),x=Z({inputs:{x:b},backend:r,attrs:{shape:a.shape}});return r.disposeIntermediateTensorInfo(f),r.disposeIntermediateTensorInfo(m),r.disposeIntermediateTensorInfo(g),r.disposeIntermediateTensorInfo(b),x}};class sr{constructor(e,t){this.variableNames=["A"];let r=Array(e.length);for(let n=0;n<r.length;n++)r[n]=e[n]*t[n];this.outputShape=r,this.rank=r.length;let n=(0,b.bf)(this.rank),a=function(e){let t=e.length;if(t>5)throw Error(`Tile for rank ${t} is not yet supported`);if(1===t)return`imod(resRC, ${e[0]})`;let r=["resRC.x","resRC.y","resRC.z","resRC.w","resRC.u"],n=[];for(let t=0;t<e.length;t++)n.push(`imod(${r[t]}, ${e[t]})`);return n.join()}(e);this.userCode=` 3716 void main() { 3717 ${n} resRC = getOutputCoords(); 3718 setOutput(getA(${a})); 3719 } 3720 `}}function sn(e){let{inputs:t,backend:r,attrs:n}=e,{x:a}=t,{reps:i}=n;if("string"===a.dtype||a.shape.length>5){let e=r.readSync(a.dataId),t="string"===a.dtype?e.map(e=>s.ZSL.decodeString(e)):e,n=(0,s.ra8)(a.shape,a.dtype,t),o=(0,B.$O)(n,i);return r.makeTensorInfo(o.shape,o.dtype,o.values)}let o=new sr(a.shape,i);return r.runWebGLProgram(o,[a],a.dtype)}let sa={kernelName:s.FAs,backendName:"webgl",kernelFunc:sn};class ss{constructor(e){this.variableNames=["x","indices"],this.customUniforms=[{name:"n",type:"int"},{name:"firstPass",type:"int"},{name:"negativeInf",type:"float"},{name:"dir",type:"int"},{name:"inc",type:"int"}],this.outputShape=e,this.userCode=` 3721 void main() { 3722 ivec2 coords = getOutputCoords(); 3723 int batch = coords[0]; 3724 int elemIdx = coords[1]; 3725 3726 // We compare elements pair-wise within a group of size 2 * inc. 3727 // The comparing rule for each group alternates between ascending 3728 // and descending. Within each group, we compare each pair at 3729 // positions i and i+inc. To decide whether an element at position i 3730 // is x0 or x1, we mod it by 2 * inc, if the result is smaller than 3731 // inc, it is in the first half of the group, we denote it as x0, 3732 // otherwise we denote it as x1. 3733 // For example, as shown in the Bitonic top K paper referenced above, 3734 // Figure5(a) shows that element[1] is in the 3735 // second half of the group when group size is 2, but it is in the 3736 // first half of the group when group size is 4. 3737 3738 bool isFirstInPair = imod(elemIdx, 2 * inc) < inc; 3739 int i = isFirstInPair ? elemIdx : elemIdx - inc; 3740 3741 int i0 = firstPass == 1 ? i : int(getIndices(batch, i)); 3742 int i1 = firstPass == 1 ? i + inc : int(getIndices(batch, i + inc)); 3743 float x0 = i0 < n ? getX(batch, i0) : negativeInf; 3744 float x1 = i1 < n ? getX(batch, i1) : negativeInf; 3745
3746 // Denotes which direction indices are in (ascending or descending). 3747 bool reverse = imod(elemIdx, 2 * dir) >= dir; 3748 bool isGreater = x0 > x1 || (x0 == x1 && i1 > i0); 3749 if (reverse == isGreater) { // Elements in opposite order of direction 3750 int iTemp = i0; 3751 i0 = i1; 3752 i1 = iTemp; 3753 } 3754 if (isFirstInPair) { 3755 setOutput(float(i0)); 3756 } else { 3757 setOutput(float(i1)); 3758 } 3759 } 3760 `}}class si{constructor(e){this.variableNames=["x","indices"],this.customUniforms=[{name:"n",type:"int"},{name:"firstPass",type:"int"},{name:"k",type:"int"}],this.outputShape=e,this.userCode=` 3761 void main() { 3762 // Takes max of indices (0, k), (1, k + 1), (2, k + 2) ... 3763 ivec2 coords = getOutputCoords(); 3764 int batch = coords[0]; 3765 int elemIdx = coords[1]; 3766 3767 // The output size is half of the previous size. 3768 // If the previous sequence is | | | | _ _ _ _ | | | | _ _ _ _ (k=4), 3769 // we only need to output the indices at positions |, the indices at 3770 // positions _ can be thrown away, see Figure5(b) After Phase 2 3771 // (Merge phase) in the Bitonic Top K paper referenced above. 3772 // For example, the paper shows we only need to output the orange bars. 3773 // The output sequence should look like this | | | | | | | |. 3774 // Because the sequence is halved, to map the output index back 3775 // to the previous sequence to find the corresponding value, 3776 // we need to double the index. When we double the index, 3777 // we basically interpolate a position, so 2i looks like 3778 // | _ | _ | _ | _ | _ | _ | _. We move the | to the first k position 3779 // of each 2k positions by - elemIdx % k. E.g. for output at 3780 // index 4,5,6,7, we want to get the corresponding element at 3781 // original index 8,9,10,11, for output at index 8,9,10,11, 3782 // we want to get the corresponding element at original index 3783 // 16,17,18,19, so on and so forth. 3784 3785 int i = elemIdx < k ? elemIdx : (elemIdx * 2 - imod(elemIdx, k)); 3786 int i0 = firstPass == 1 ? i : int(getIndices(batch, i)); 3787 int i1 = firstPass == 1 ? i + k : int(getIndices(batch, i + k)); 3788 3789 float x0 = getX(batch, i0); 3790 float x1 = i1 < n ? getX(batch, i1) : x0; 3791 3792 setOutput(x0 >= x1 ? float(i0) : float(i1)); 3793 } 3794 `}}function so(e,t){null!==t&&e.disposeIntermediateTensorInfo(t)}function sl(e){let t=1;for(;t<e;)t*=2;return t}let su={kernelName:s.TBb,backendName:"webgl",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{x:a}=t,{k:i,sorted:o}=n,l=(0,s._K2)().getNumber("TOPK_LAST_DIM_CPU_HANDOFF_SIZE_THRESHOLD"),u=(0,s._K2)().getNumber("TOPK_K_CPU_HANDOFF_THRESHOLD"),h=a.shape,p=h[h.length-1];if(r.shouldExecuteOnCPU([a])||p<l||i>u){let e=r.readSync(a.dataId),[t,n]=(0,B.xt)(e,h,a.dtype,i,o);return[r.makeTensorInfo(t.shape,t.dtype,t.values),r.makeTensorInfo(n.shape,n.dtype,n.values)]}if(0===i)return h[h.length-1]=0,[r.makeTensorInfo(h,a.dtype,[]),r.makeTensorInfo(h,"int32",[])];if(1===p)return[a,rm({attrs:{shape:h,dtype:"int32",value:0},backend:r})];let d=r.texData.get(a.dataId),c=null!==d&&d.isPacked,f=c?r.unpackTensor(a):a,m=s.ZSL.sizeFromShape(h)/p,g=Z({inputs:{x:f},attrs:{shape:[m,p]},backend:r});c&&so(r,f);let y=sl(i),b=sl(p),x=null,v=()=>null===x?[g,g]:[g,x],w=(e,t,n)=>{let a=v(),s=new ss(n),i=[[p],[+(null===x)],[Number.NEGATIVE_INFINITY],[e],[t]],o=x;x=r.runWebGLProgram(s,a,"int32",i),so(r,o)};for(let e=1;e<y;e*=2){let t=2*e;for(let r=e;r>=1;r/=2)w(t,r,[m,b])}for(let e=b;e>y;e/=2){let t=v(),n=new si([m,e/2]),a=[[p],[+(null===x)],[y]],s=x;x=r.runWebGLProgram(n,t,"int32",a),so(r,s);let i=y/2,o=2*i;for(let e=i;e>=1;e/=2)w(o,e,x.shape)}let T=x;x=eY({inputs:{x:x},backend:r,attrs:{begin:0,size:[m,i]}}),so(r,T);let S=rD({inputs:{x:g,indices:x},backend:r,attrs:{axis:1,batchDims:1}});so(r,g);let N=h.slice(0,-1);N.push(i),T=x,x=Z({inputs:{x:x},attrs:{shape:N},backend:r}),so(r,T);let k=S;return S=Z({inputs:{x:S},attrs:{shape:N},backend:r}),so(r,k),[S,x]}};class sh{constructor(e,t,r,n,a,s){let i;switch(this.variableNames=["Image","Transforms"],this.outputShape=s,n){case"constant":default:i=1;break;case"reflect":i=2;break;case"wrap":i=3;break;case"nearest":i=4}this.userCode=` 3795 float mapCoord(float outCoord, float len) { 3796 float inCoord = outCoord; 3797 if(${i} == 2) { 3798 if (inCoord < 0.0) { 3799 if (len <= 1.0) { 3800 inCoord = 0.0; 3801 } else { 3802 float sz2 = 2.0 * len; 3803 if (inCoord < sz2) { 3804 inCoord = sz2 * float(int(float(-inCoord / sz2))) + 3805 inCoord; 3806 } 3807 inCoord = inCoord < -len ? inCoord + sz2 : -inCoord - 1.0; 3808 } 3809 } else if (inCoord > len - 1.0) { 3810 if (len <= 1.0) { 3811 inCoord = 0.0; 3812 } else { 3813 float sz2 = 2.0 * len; 3814 inCoord -= sz2 * float(int(float(inCoord / sz2))); 3815 if (inCoord >= len) { 3816 inCoord = sz2 - inCoord - 1.0; 3817 } 3818 } 3819 } 3820 return clamp(inCoord, 0.0, len - 1.0); 3821 } else if (${i} == 3) { 3822 if (inCoord < 0.0) { 3823 if (len <= 1.0) { 3824 inCoord = 0.0; 3825 } else { 3826 float sz = len - 1.0; 3827 inCoord += len * (float(int(float(-inCoord / sz))) + 1.0); 3828 } 3829 } else if (inCoord > len - 1.0) { 3830 if (len <= 1.0) { 3831 inCoord = 0.0; 3832 } else { 3833 float sz = len - 1.0; 3834 inCoord -= len * float(int(float(inCoord / sz))); 3835 } 3836 } 3837 return clamp(inCoord, 0.0, len - 1.0); 3838 } else if (${i} == 4) { 3839 return clamp(outCoord, 0.0, len - 1.0); 3840 } else { 3841 return outCoord; 3842 } 3843 } 3844 3845 float readWithFillValue(int batch, int coordY, int coordX, 3846 int channel) { 3847 float outputValue; 3848 if (0 <= coordY && coordY < ${e} && 0 <= coordX && coordX < ${t}) { 3849 outputValue = getImage(batch, coordY, coordX, channel); 3850 } else { 3851 outputValue = float(${a}); 3852 } 3853 return outputValue; 3854 } 3855 3856 void main() { 3857 ivec4 coords = getOutputCoords(); 3858 float outputValue; 3859 int batch = coords[0]; 3860 int x = coords[2]; 3861 int y = coords[1]; 3862 int channel = coords[3]; 3863 float xf = float(x); 3864 float yf = float(y); 3865 float a1 = getTransforms(batch, 0); 3866 float a2 = getTransforms(batch, 1); 3867 float a3 = getTransforms(batch, 2); 3868 float b1 = getTransforms(batch, 3); 3869 float b2 = getTransforms(batch, 4); 3870 float b3 = getTransforms(batch, 5); 3871 float c1 = getTransforms(batch, 6); 3872 float c2 = getTransforms(batch, 7); 3873 float projection = c1 * xf + c2 * yf + 1.0; 3874 if (projection == 0.0) { 3875 outputValue = float(${a}); 3876 } else { 3877 float inX = (a1 * xf + a2 * yf + a3) / projection; 3878 float inY = (b1 * xf + b2 * yf + b3) / projection; 3879 float mapX = mapCoord(inX, float(${t})); 3880 float mapY = mapCoord(inY, float(${e})); 3881 3882 if (${"nearest"===r?1:2} == 1) {
3883 int coordY = int(round(mapY)); 3884 int coordX = int(round(mapX)); 3885 outputValue = readWithFillValue(batch, coordY, coordX, 3886 channel); 3887 } else { 3888 float yFloor = floor(mapY); 3889 float xFloor = floor(mapX); 3890 float yCeil = yFloor + 1.0; 3891 float xCeil = xFloor + 1.0; 3892 float valueYFloor = (xCeil - mapX) * 3893 readWithFillValue(batch, int(yFloor), int(xFloor), channel) + 3894 (mapX - xFloor) * 3895 readWithFillValue(batch, int(yFloor), int(xCeil), channel); 3896 float valueYCeil = (xCeil - mapX) * 3897 readWithFillValue(batch, int(yCeil), int(xFloor), channel) + 3898 (mapX - xFloor) * 3899 readWithFillValue(batch, int(yCeil), int(xCeil), channel); 3900 outputValue = (yCeil - mapY) * valueYFloor + 3901 (mapY - yFloor) * valueYCeil; 3902 } 3903 } 3904 setOutput(outputValue); 3905 } 3906 `}}let sp={kernelName:s.dLy,backendName:"webgl",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{image:a,transforms:s}=t,{interpolation:i,fillMode:o,fillValue:l,outputShape:u}=n,[h,p,d,c]=a.shape,[f,m]=null!=u?u:[p,d],g=new sh(p,d,i,o,l,[h,f,m,c]);return r.runWebGLProgram(g,[a,s],"float32")}},sd={kernelName:s.EwU,backendName:"webgl",kernelFunc:function(e){let{inputs:t,attrs:r,backend:n}=e,{axis:a}=r,{x:s}=t;(0,u.assertNotComplex)(s,"unique"),console.warn("WARNING: ","UI might be locked temporarily as data is being downloaded");let i=n.readSync(s.dataId),{outputValues:o,outputShape:l,indices:h}=(0,B.M_)(i,a,s.shape,s.dtype);return[n.makeTensorInfo(l,s.dtype,o),n.makeTensorInfo([h.length],"int32",h)]}},sc={kernelName:s.dXR,backendName:"webgl",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{value:a}=t,{axis:s}=n;s<0&&(s+=a.shape.length);let i=a.shape.length,o=a.shape[s],l=Array(i-1),u=0;for(let e=0;e<i;e++)e!==s&&(l[u++]=a.shape[e]);let h=[],p=Array(i).fill(0),d=a.shape.slice();d[s]=1;let c=Array(o);for(let e=0;e<c.length;e++){p[s]=e;let t=eY({inputs:{x:a},backend:r,attrs:{begin:p,size:d}}),n=Z({inputs:{x:t},backend:r,attrs:{shape:l}});c[e]=n,h.push(t)}return h.forEach(e=>r.disposeIntermediateTensorInfo(e)),c}};class sf{constructor(e,t){this.variableNames=["x","segmentIds"];let r=e.windowSize,n=e.batchSize,a=e.inSize,s=e.numSegments,i=s*Math.ceil(a/r);this.outputShape=[n,i];let o=4*Math.floor(r/4),l=r%4,u=` 3907 sumValue += dot(values, segFilter); 3908 `,h="";a%r>0&&(h=` 3909 if (inIdx < 0 || inIdx >= ${a}) { 3910 return initializationValue; 3911 } 3912 `);let p="";a%r>0&&(p=` 3913 if (inIdx < 0 || inIdx >= ${a}) { 3914 return -1.0; 3915 } 3916 `),this.userCode=` 3917 const float initializationValue = 0.0; 3918 3919 float getValue(int batch, int inIdx) { 3920 ${h} 3921 return getX(batch, inIdx); 3922 } 3923 3924 float getSegmentIdAtIndex(int inIdx) { 3925 ${p} 3926 return getSegmentIds(inIdx); 3927 } 3928 3929 void main() { 3930 ivec2 coords = getOutputCoords(); 3931 int batch = coords[0]; 3932 int outIdx = coords[1]; 3933 int inOffset = int(floor(float(outIdx) / float( 3934 ${s})) * float(${r})); 3935 int currentSeg = int(mod(float(outIdx), float(${s}))); 3936 3937 float sumValue = 0.0; 3938 3939 for (int i = 0; i < ${o}; i += 4) { 3940 int inIdx = inOffset + i; 3941 vec4 values = vec4( 3942 getValue(batch, inIdx), 3943 getValue(batch, inIdx + 1), 3944 getValue(batch, inIdx + 2), 3945 getValue(batch, inIdx + 3) 3946 ); 3947 3948 vec4 segFilter = vec4( 3949 int(getSegmentIdAtIndex(inIdx)) == currentSeg ? 1 : 0, 3950 int(getSegmentIdAtIndex(inIdx + 1)) == currentSeg ? 1 : 0, 3951 int(getSegmentIdAtIndex(inIdx + 2)) == currentSeg ? 1 : 0, 3952 int(getSegmentIdAtIndex(inIdx + 3)) == currentSeg ? 1 : 0 3953 ); 3954 3955 ${u} 3956 } 3957 3958 int inIdx = inOffset + ${o}; 3959 if (${1===l}) { 3960 vec4 values = vec4( 3961 getValue(batch, inIdx), 3962 initializationValue, 3963 initializationValue, 3964 initializationValue 3965 ); 3966 3967 int inIdxSeg = int(getSegmentIdAtIndex(inIdx)); 3968 3969 vec4 segFilter = vec4( 3970 int(getSegmentIdAtIndex(inIdx)) == currentSeg ? 1 : 0, 3971 0, 3972 0, 3973 0 3974 ); 3975 3976 ${u} 3977 } else if (${2===l}) { 3978 vec4 values = vec4( 3979 getValue(batch, inIdx), 3980 getValue(batch, inIdx + 1), 3981 initializationValue, 3982 initializationValue 3983 ); 3984 3985 vec4 segFilter = vec4( 3986 int(getSegmentIdAtIndex(inIdx)) == currentSeg ? 1 : 0, 3987 int(getSegmentIdAtIndex(inIdx + 1)) == currentSeg ? 1 : 0, 3988 0, 3989 0 3990 ); 3991 3992 ${u} 3993 } else if (${3===l}) { 3994 vec4 values = vec4( 3995 getValue(batch, inIdx), 3996 getValue(batch, inIdx + 1), 3997 getValue(batch, inIdx + 2), 3998 initializationValue 3999 ); 4000 4001 vec4 segFilter = vec4( 4002 int(getSegmentIdAtIndex(inIdx)) == currentSeg ? 1 : 0, 4003 int(getSegmentIdAtIndex(inIdx + 1)) == currentSeg ? 1 : 0, 4004 int(getSegmentIdAtIndex(inIdx + 2)) == currentSeg ? 1 : 0, 4005 0 4006 ); 4007 4008 ${u} 4009 } 4010 setOutput(sumValue); 4011 } 4012 `}}for(let e of[ea,ei,el,eh,ec,eg,ey,eb,eT,eS,ek,eC,eA,eF,e_,eL,eM,eB,eW,eV,eZ,eq,eX,e1,e2,e7,te,tn,N,ti,tc,tT,tC,tA,t$,tF,tR,tD,tL,tP,tG,tU,tZ,tH,tQ,tJ,t0,t2,t4,t5,t7,t8,rt,rn,rs,ro,rh,rc,rg,rb,rw,rS,rC,rA,r$,rR,rO,rM,rz,T,rB,tp,rV,rU,rj,C,rK,rQ,rq,rJ,r1,r3,r5,r7,ne,nr,na,ni,no,nl,np,nd,nc,nf,nm,ny,nv,nT,nF,G,nD,nL,nP,nB,e4,nV,nZ,nj,nQ,nX,$,nJ,n0,n1,n2,n4,e6,nk,n6,n9,ae,j,an,as,al,ah,ac,am,ay,ax,aT,aN,aI,aE,a$,aR,aD,aL,eQ,n$,aP,az,aB,aW,aV,aG,aU,aZ,aK,aQ,aJ,a0,a1,a3,a4,a5,a6,nE,ee,a9,se,st,sa,su,sp,er,sd,sc,{kernelName:s.pPe,backendName:"webgl",kernelFunc:function(e){let{inputs:t,backend:r,attrs:n}=e,{x:a,segmentIds:i}=t,{numSegments:o}=n,l=a.shape.length,u=[],h=0,p=s.C0T.getAxesPermutation([h],l),d=a;null!=p&&(d=et({inputs:{x:a},backend:r,attrs:{perm:p}}),u.push(d),h=s.C0T.getInnerMostAxes(1,l)[0]);let c=s.C0T.segment_util.computeOutShape(d.shape,h,o),f=s.ZSL.sizeFromShape([d.shape[h]]),m=Z({inputs:{x:d},backend:r,attrs:{shape:[-1,f]}});u.push(m);let g=(0,s.chL)(a.dtype),y=(e,t,n,a,i)=>{let o=e.shape[0],l=e.shape[1],h=s.C0T.segment_util.segOpComputeOptimalWindowSize(l,i),p=new sf({windowSize:h,inSize:l,batchSize:o,numSegments:i},t),d=r.compileAndRun(p,[e,n],a);if(u.push(d),d.shape[1]===i)return d;let c=n3({backend:r,attrs:{start:0,stop:i,step:1,dtype:"float32"}}
4012),f=sn({inputs:{x:c},backend:r,attrs:{reps:[l/h]}});return u.push(c),u.push(f),y(d,t,f,a,i)},b=Z({inputs:{x:y(m,"unsortedSegmentSum",i,g,o)},backend:r,attrs:{shape:c}}),x=b;return null!=p&&(u.push(b),x=et({inputs:{x:x},backend:r,attrs:{perm:s.C0T.getUndoAxesPermutation(p)}})),u.forEach(e=>r.disposeIntermediateTensorInfo(e)),x}},nU])(0,s.tAK)(e)},68567:(e,t,r)=>{"use strict";r.d(t,{t:()=>i});var n=r(19041),a=r(48592),s=r(27924);let i=(0,r(62176).op)({reshape_:function(e,t){let r=(0,s.YT)(e,"x","reshape","string_or_numeric");return n.T2.runKernel(a.R23,{x:r},{shape:t})}})},68770:(e,t,r)=>{"use strict";r.d(t,{NH:()=>m,P:()=>d,X0:()=>f,b0:()=>p,rF:()=>g,vD:()=>c});var n=r(51520),a=r(82492),s=r(8785),i=r(14811),o=r(97344),l=r(96902),u=r(65650),h=r(1560);class p extends i.Wd{constructor(e){super(null==e?{}:e),this.supportsMasking=!0,null!=e&&(this.maxValue=e.maxValue)}call(e,t){e=(0,h.un)(e);let r=(0,n.VVh)(e);return null!=this.maxValue&&(r=(0,n.zQh)(r,0,this.maxValue)),r}computeOutputShape(e){return e}getConfig(){let e={maxValue:this.maxValue};return Object.assign(e,super.getConfig()),e}}p.className="ReLU",n.JFn.registerClass(p);class d extends i.Wd{constructor(e){super(null==e?{}:e),this.DEFAULT_ALPHA=.3,null==e&&(e={}),this.alpha=null==e.alpha?this.DEFAULT_ALPHA:e.alpha}call(e,t){let r=(0,h.un)(e);return(0,n.H8d)(r,this.alpha)}computeOutputShape(e){return e}getConfig(){let e={alpha:this.alpha};return Object.assign(e,super.getConfig()),e}}d.className="LeakyReLU",n.JFn.registerClass(d);class c extends i.Wd{constructor(e){if(super(null==e?{}:e),this.DEFAULT_ALPHA_INITIALIZER="zeros",null==e&&(e={}),this.supportsMasking=!0,this.alphaInitializer=(0,l.Fe)(e.alphaInitializer||this.DEFAULT_ALPHA_INITIALIZER),this.alphaRegularizer=(0,u.Bm)(e.alphaRegularizer),this.alphaConstraint=(0,s.YZ)(e.alphaConstraint),null==e.sharedAxes)this.sharedAxes=null;else if(Array.isArray(e.sharedAxes))this.sharedAxes=e.sharedAxes;else if("number"==typeof e.sharedAxes)this.sharedAxes=[e.sharedAxes];else throw new o.Qp(`Expected sharedAxes to be a number or an array of numbers, but got ${e.sharedAxes}`)}build(e){let t=(e=(0,h.U$)(e)).slice(1);if(null!=this.sharedAxes)for(let e of this.sharedAxes)t[e-1]=1;this.alpha=this.addWeight("alpha",t,"float32",this.alphaInitializer,this.alphaRegularizer,!0,this.alphaConstraint);let r={};if(null!=this.sharedAxes)for(let t=1;t<e.length;++t)r[t]=e[t];this.inputSpec=[new i.eO({ndim:e.length,axes:r})],this.built=!0}call(e,t){return e=(0,h.un)(e),(0,n.NsG)(e,this.alpha.read())}getConfig(){let e={alphaInitializer:(0,l.zo)(this.alphaInitializer),alphaRegularizer:(0,u.R9)(this.alphaRegularizer),alphaConstraint:(0,s.uH)(this.alphaConstraint),sharedAxes:this.sharedAxes};return Object.assign(e,super.getConfig()),e}}c.className="PReLU",n.JFn.registerClass(c);class f extends i.Wd{constructor(e){if(super(null==e?{}:e),this.DEFAULT_ALPHA=1,null==e&&(e={}),null!=e.alpha&&e.alpha!==this.DEFAULT_ALPHA)throw new o.EH(`Non-default alpha value (${e.alpha}) is not supported by the ELU layer yet.`);this.alpha=null==e.alpha?this.DEFAULT_ALPHA:e.alpha}call(e,t){let r=(0,h.un)(e);return(0,n.Pqc)(r)}computeOutputShape(e){return e}getConfig(){let e={alpha:this.alpha};return Object.assign(e,super.getConfig()),e}}f.className="ELU",n.JFn.registerClass(f);class m extends i.Wd{constructor(e){super(null==e?{}:e),this.DEFAULT_THETA=1,null==e&&(e={}),this.theta=null==e.theta?this.DEFAULT_THETA:e.theta}call(e,t){let r=(0,h.un)(e);return(0,n.lKK)(r,(0,n.wgE)((0,n.rhj)(r,this.theta),"float32"))}computeOutputShape(e){return e}getConfig(){let e={theta:this.theta};return Object.assign(e,super.getConfig()),e}}m.className="ThresholdedReLU",n.JFn.registerClass(m);class g extends i.Wd{constructor(e){super(null==e?{}:e),this.DEFAULT_AXIS=1,null==e&&(e={}),this.softmax=new a.rF().apply,this.axis=null==e.axis?this.DEFAULT_AXIS:e.axis}call(e,t){return(0,n.DZQ)(()=>{let r=(0,h.un)(e),a=t.mask;if(null!=a){let e=(0,n.lKK)((0,n.jbE)((0,n.SaS)(r.shape),(0,n.wgE)(a,r.dtype)),(0,n.d_2)(-1e9));r=(0,n.WQq)(r,e)}if(this.axis instanceof Array)if(this.axis.length>1)return(0,n.oNF)((0,n.jbE)(r,(0,n.VZ)(r,this.axis,!0)));else return this.softmax(r,this.axis[0]);return this.softmax(r,this.axis)})}computeOutputShape(e){return e}getConfig(){let e={axis:this.axis};return Object.assign(e,super.getConfig()),e}}g.className="Softmax",n.JFn.registerClass(g)},69751:(e,t,r)=>{"use strict";r.d(t,{Y:()=>i});var n=r(19041),a=r(48592),s=r(27924);let i=(0,r(62176).op)({stridedSlice_:function(e,t,r,i,o=0,l=0,u=0,h=0,p=0){let d=(0,s.YT)(e,"x","stridedSlice","string_or_numeric");return n.T2.runKernel(a.UcO,{x:d},{begin:t,end:r,strides:i,beginMask:o,endMask:l,ellipsisMask:u,newAxisMask:h,shrinkAxisMask:p})}})},69950:(e,t,r)=>{"use strict";r.d(t,{O0:()=>i.O0,ZS:()=>h,ge:()=>o,hF:()=>u,il:()=>l});var n=r(70333),a=r(52536),s=r(25564),i=r(70481);function o(e){return new s.Gw(e)}function l(e){return new i.Gx(e)}function u(e){return(0,a.p)(e)}function h(e,t){n.t6.registerCallbackConstructor(e,t)}},70333:(e,t,r)=>{"use strict";r.d(t,{BZ:()=>p,Eq:()=>c,H7:()=>d,J5:()=>l,dY:()=>m,g:()=>u,t6:()=>f});
4012var n,a=r(51520),s=r(97344),i=r(65952),o=r(82692);!function(e){e[e.SILENT=0]="SILENT",e[e.VERBOSE=1]="VERBOSE"}(n||(n={}));class l{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){}}class u{constructor(e,t=10){null==e&&(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){for(let r of(null==t&&(t={}),this.callbacks))await r.onEpochBegin(e,t)}async onEpochEnd(e,t){for(let r of(null==t&&(t={}),this.callbacks))await r.onEpochEnd(e,t)}async onBatchBegin(e,t){for(let r of(null==t&&(t={}),this.callbacks))await r.onBatchBegin(e,t)}async onBatchEnd(e,t){for(let r of(null==t&&(t={}),this.callbacks))await r.onBatchEnd(e,t)}async onTrainBegin(e){for(let t of(null==e&&(e={}),this.callbacks))await t.onTrainBegin(e)}async onTrainEnd(e){for(let t of(null==e&&(e={}),this.callbacks))await t.onTrainEnd(e)}}class h extends l{constructor(){super()}async onEpochBegin(e){this.seen=0,this.totals={}}async onBatchEnd(e,t){null==t&&(t={});let r=null==t.size?0:t.size;
4012for(let e in this.seen+=r,t){let n=t[e];if("number"==typeof n)this.totals.hasOwnProperty(e)||(this.totals[e]=0),this.totals[e]=this.totals[e]+n*r;else{let t;e in this.totals?t=this.totals[e]:this.totals[e]=0;let s=(0,a.DZQ)(()=>(0,a.WQq)(this.totals[e],(0,a.lKK)(n,r)));this.totals[e]=s,null!=t&&t.dispose()}}}async onEpochEnd(e,t){if(null!=t)for(let e of this.params.metrics)null!=this.totals[e]&&("number"==typeof this.totals[e]?t[e]=this.totals[e]/this.seen:(0,a.DZQ)(()=>{let r=(0,a.lKK)((0,a.y4m)(1,this.seen),this.totals[e]);t[e]=r,this.totals[e].dispose(),(0,a.aCs)(t[e])}))}}class p extends l{async onTrainBegin(e){this.epoch=[],this.history={}}async onEpochEnd(e,t){for(let r in null==t&&(t={}),this.epoch.push(e),t)null==this.history[r]&&(this.history[r]=[]),this.history[r].push(t[r])}async syncData(){let e=[],t=[],r=[];for(let n in this.history){let a=this.history[n];for(let s=0;s<a.length;++s)if("number"!=typeof a[s]){let i=a[s];e.push(i.data()),t.push(n),r.push(s)}}let n=await Promise.all(e);for(let e=0;e<n.length;++e)this.history[t[e]][r[e]].dispose(),this.history[t[e]][r[e]]=n[e][0]}}class d extends l{constructor(e,t){if(super(),this.currentEpoch=0,this.nowFunc=e.nowFunc,this.nextFrameFunc=e.nextFrameFunc||a.dA1,this.yieldEvery=t||"auto","auto"===this.yieldEvery&&(this.yieldEvery=125),"never"===this.yieldEvery&&null!=e.onYield)throw Error("yieldEvery is `never` but you provided an `onYield` callback. Either change `yieldEvery` or remove the callback");a.ZSL.isNumber(this.yieldEvery)&&(this.maybeWait=o.sg(this.maybeWait.bind(this),this.yieldEvery,this.nowFunc)),this.trainBegin=e.onTrainBegin,this.trainEnd=e.onTrainEnd,this.epochBegin=e.onEpochBegin,this.epochEnd=e.onEpochEnd,this.batchBegin=e.onBatchBegin,this.batchEnd=e.onBatchEnd,this.yield=e.onYield}async maybeWait(e,t,r){let n=[];null!=this.yield&&(await (0,i.I)(r),n.push(this.yield(e,t,r))),n.push(this.nextFrameFunc()),await Promise.all(n)}async onEpochBegin(e,t){this.currentEpoch=e,null!=this.epochBegin&&(await (0,i.I)(t),await this.epochBegin(e,t))}async onEpochEnd(e,t){let r=[];null!=this.epochEnd&&(await (0,i.I)(t),r.push(this.epochEnd(e,t))),"epoch"===this.yieldEvery&&r.push(this.nextFrameFunc()),await Promise.all(r)}async onBatchBegin(e,t){null!=this.batchBegin&&(await (0,i.I)(t),await this.batchBegin(e,t))}async onBatchEnd(e,t){let r=[];null!=this.batchEnd&&(await (0,i.I)(t),r.push(this.batchEnd(e,t))),"batch"===this.yieldEvery?r.push(this.nextFrameFunc()):a.ZSL.isNumber(this.yieldEvery)&&r.push(this.maybeWait(this.currentEpoch,e,t)),await Promise.all(r)}async onTrainBegin(e){null!=this.trainBegin&&(await (0,i.I)(e),await this.trainBegin(e))}async onTrainEnd(e){null!=this.trainEnd&&(await (0,i.I)(e),await this.trainEnd(e))}}function c(e,t){return(null==e&&(e={}),e instanceof l)?[e]:Array.isArray(e)&&e[0]instanceof l?e:o.st(e).map(e=>new d(e,t))}class f{constructor(){}static registerCallbackConstructor(e,t){a.ZSL.assert(e>=0&&Number.isInteger(e),()=>`Verbosity level is expected to be an integer >= 0, but got ${e}`),f.checkForDuplicate(t),null==f.constructors[e]&&(f.constructors[e]=[]),f.constructors[e].push(t)}static checkForDuplicate(e){for(let t in f.constructors)f.constructors[+t].forEach(t=>{if(t===e)throw new s.Qp("Duplicate callback constructor.")})}static clear(){f.constructors={}}static createCallbacks(e){let t=[];for(let r in f.constructors){let n=+r;e>=n&&t.push(...f.constructors[n])}return t.map(e=>new e)}}function m(e,t,r,n,a,s,i,o,l){let d=new p,c=[new h,...f.createCallbacks(t)];null!=e&&c.push(...e),c.push(d);let m=new u(c);return m.setParams({epochs:r,initialEpoch:n,samples:a,steps:s,batchSize:i,verbose:t,doValidation:o,metrics:l}),{callbackList:m,history:d}}f.constructors={}},70477:(e,t,r)=>{"use strict";r.d(t,{r:()=>i});var n=r(19041),a=r(48592),s=r(27924);let i=(0,r(62176).op)({atan_:function(e){let t=(0,s.YT)(e,"x","atan");return n.T2.runKernel(a.TyE,{x:t})}})},70481:(e,t,r)=>{"use strict";r.d(t,{Gx:()=>g,O0:()=>f,U3:()=>c});var n=r(51520),a=r(3047),s=r(52536),i=r(14811),o=r(25564),l=r(97344),u=r(83234),h=r(82692),p=r(52745),d=r(1560);async function c(e,t){"modelTopology"in e||(e={modelTopology:e});let r=e.modelTopology;null!=r.model_config&&(r=r.model_config);let a=(0,p.w)(r),s=(0,u.i)(a,t);
4012if(null!=e.weightsManifest){let t=await n.io.loadWeights(e.weightsManifest,e.pathPrefix,s.weights.map(e=>e.originalName)),r={};for(let e of s.weights)r[e.originalName]=t[e.originalName];s.loadWeights(r),(0,n.ASo)(t)}return s}async function f(e,t){if(null==t&&(t={}),"string"==typeof e){let r=n.io.getLoadHandlers(e,t);if(0===r.length)r.push(n.io.browserHTTPRequest(e,t));else if(r.length>1)throw new l.Qp(`Found more than one (${r.length}) load handlers for URL '${e}'`);e=r[0]}return m(e,void 0,t)}async function m(e,t,r){if(null==r&&(r={}),null==e.load)throw new l.Qp("Cannot proceed with model loading because the IOHandler provided does not have the `load` method implemented.");let a=await e.load(),s=a.modelTopology;null!=s.model_config&&(s=s.model_config);let i=null==r.strict||r.strict,o=null!=a.weightData&&null!=a.weightSpecs&&i,h=(0,u.i)((0,p.w)(s),t,o),d=a.trainingConfig;if(null!=d&&h.loadTrainingConfig(d),null!=a.userDefinedMetadata&&h.setUserDefinedMetadata(a.userDefinedMetadata),null!=a.weightData){if(null==a.weightSpecs)throw new l.Qp("LayersModel artifacts contains weight data, but not weight specs. Therefore loading of weights cannot proceed.");let{modelWeights:e,optimizerWeights:t}=function(e,t){let r=n.io.decodeWeights(e,t),a={},s=[];return t.forEach(e=>{"optimizer"===e.group?s.push({name:e.name,tensor:r[e.name]}):a[e.name]=r[e.name]}),{modelWeights:a,optimizerWeights:s}}(a.weightData,a.weightSpecs);h.loadWeights(e,i),null!=h.optimizer&&t.length>0&&await h.optimizer.setWeights(t),(0,n.ASo)(e),(0,n.ASo)(t.map(e=>e.tensor))}return h}class g extends o.Gw{constructor(e){if(super({inputs:[],outputs:[]}),e=e||{},this.trainable=!0,this.built=!1,this.name=null!=e.name?e.name:(0,a.v)("sequential_"),null!=e.layers)for(let t of e.layers)this.add(t)}checkShape(e){if(e.inboundNodes[0].outputTensors[0].shape.some(e=>e<0))throw new l.Qp(`Negative dimension size caused by adding layer ${e.name} with input shape [${e.inboundNodes[0].inputTensors[0].shape}]`)}add(e){let t,r=e instanceof g||e instanceof o.Gw;if(r){if(1!==(t=e).outputs.length)throw new l.Qp("All layers in a Sequential model should have a single output tensor. For multi-output layers, use the functional API.");if(1!==t.inputs.length)throw new l.Qp("All layers in a Sequential model should have a single input tensor. For multi-input layers, use the functional API.")}if(0===this.outputs.length){if(0===e.inboundNodes.length){if(null==e.batchInputShape)throw new l.Qp("The first layer in a Sequential model must get an `inputShape` or `batchInputShape` argument.");let t=(0,s.p)({batchShape:e.batchInputShape,dtype:e.dtype,name:e.name+"_input"});e.apply(t)}if(r)this.outputs=t.outputs,this.inputs=t.inputs;else{if(1!==e.inboundNodes.length)throw new l.Qp(`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(1!==e.inboundNodes[0].outputTensors.length)throw new l.Qp("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=(0,i.X6)(this.outputs[0])}this.inboundNodes=[],new i.bP({outboundLayer:this,inboundLayers:[],nodeIndices:[],tensorIndices:[],inputTensors:this.inputs,outputTensors:this.outputs,inputMasks:h.fD(null,this.inputs.length),outputMasks:[null],inputShapes:this.inputs.map(e=>e.shape),outputShapes:this.outputs[0].shape})}else{let t=e.apply(this.outputs[0]);if(Array.isArray(t))throw 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=[t],this.inboundNodes[0].outputTensors=this.outputs,this.inboundNodes[0].outputShapes=[this.outputs[0].shape]}this.layers.push(e),this.built=!1}pop(){if(0===this.layers.length)throw TypeError("There are no layers in the model.");if(this.layers.pop(),0===this.layers.length)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 null==this.model&&this.build(),this.model.call(e,t)}build(e){if((0,d.U$)(e),0===this.inputs.length||0===this.outputs.length)throw TypeError("Sequential model cannot be built: model is empty. Add some layers first.");this.model=new o.Gw({inputs:this.inputs,outputs:this.outputs[0],name:this.name+"_model"}),this.model.trainable=this.trainable,this.supportsMasking=this.model.supp
4012ortsMasking,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,r=console.log){this.built||this.build(),super.summary(e,t,r)}setWeights(e){null==this.model&&this.build(),this.model.setWeights(e)}evaluate(e,t,r={}){if(!this.built)throw new l.bu("The model needs to be compiled before being used.");return this.model.evaluate(e,t,r)}async evaluateDataset(e,t){if(!this.built)throw new l.bu("The model needs to be compiled before being used.");return this.model.evaluateDataset(e,t)}predict(e,t={}){return null==this.model&&this.build(),this.model.predict(e,t)}predictOnBatch(e){return null==this.model&&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 null==this.model?void 0:this.model.optimizer}set optimizer(e){this.model.optimizer=e}async fit(e,t,r={}){if(!this.built)throw new l.bu("The model needs to be compiled before being used.");return this.model.fit(e,t,r)}async fitDataset(e,t){if(!this.built)throw new l.bu("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,r={},a=!1){let s,i={};if(t instanceof Array){if(null==t[0].className||"Merge"===t[0].className)throw new l.Qp("Legacy serialization format not supported yet.");s=t}else n.ZSL.assert(null!=t.layers,()=>"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,i=t;let o=new e(i);if(!(o instanceof g))throw new l.EH(`Sequential.fromConfig called on non-Sequential input: ${o}`);for(let e of s){let t=void 0,r=(0,u.i)(e,t,a);a&&r.setFastWeightInitDuringBuild(!0),o.add(r)}return o}set stopTraining(e){if(null==this.model)throw new l.Qp("Cannot set the stopTraining property of a sequential model before it is compiled.");this.model.stopTraining=e}get stopTraining(){if(null==this.model)throw new l.Qp("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 r={};r.className=t.getClassName(),r.config=t.getConfig(),e.push(r)}return{name:this.name,layers:e}}}g.className="Sequential",n.JFn.registerClass(g)},70796:(e,t,r)=>{"use strict";r.d(t,{Jc:()=>c,Jt:()=>g,Ol:()=>p,Pg:()=>f,SO:()=>m,VW:()=>h,Xv:()=>u,Yq:()=>o,bt:()=>l,qp:()=>d});var n=r(51520),a=r(73187),s=r(90556),i=r(97344);function o(e,t){return(0,n.DZQ)(()=>{"float32"!==e.dtype&&(e=n.wgE(e,"float32"));let r=n.czq(s.Ew(e),t,!0),i=n.GSj(r.shape,(0,a.Ni)()),o=n.RZD(n.PhQ(r,i));return n.y4m(e,o)})}function l(e,t){return(0,n.DZQ)(()=>n.i2o(s.Ew(n.jbE(t,e)),-1))}function u(e,t){return(0,n.DZQ)(()=>n.i2o(n.tnl(n.jbE(t,e)),-1))}function h(e,t){return(0,n.DZQ)(()=>{let r=n.jbE(e,t),s=n.zQh(n.tnl(e),(0,a.Ni)(),Number.MAX_VALUE),i=n.tnl(n.y4m(r,s));return n.lKK(100,n.i2o(i,-1))})}function p(e,t,r=!1){return(0,n.DZQ)(()=>{if(r)t=n.Vs9(t);else{let e=n.czq(t,t.shape.length-1,!0);t=n.y4m(t,e)}return t=n.zQh(t,(0,a.Ni)(),1-(0,a.Ni)()),n.HZy(n.czq(n.lKK(n.wgE(e,"float32"),n.Rm2(t)),t.shape.length-1))})}function d(e,t,r=!1){return(0,n.DZQ)(()=>{let i=n.wgE(n.RIf(s.Bq(e)),"int32"),o=(t=n.zQh(t,(0,a.Ni)(),1-(0,a.Ni)())).shape;return p(n.tQQ(n.Mw0(i,o[o.length-1]),o),t,r)})}function c(e,t){return(0,n.DZQ)(()=>{let r;return r=n.zQh(t,(0,a.Ni)(),1-(0,a.Ni)()),r=n.Rm2(n.y4m(r,n.jbE(1,r))),n.i2o(function(e,t){if(!n.ZSL.arraysEqual(e.shape,t.shape))throw new i.Qp(`logits and labels must have the same shape, but got shapes ${JSON.stringify(e.shape)} and ${JSON.stringify(t.shape)}`);return(0,n.DZQ)(()=>{let r=n.VVh(t),a=n.HZy(n.tnl(t));return n.WQq(n.jbE(r,n.lKK(t,e)),n.Kko(n.oNF(a)))})}(e,r),-1)})}function f(e,t){return(0,n.DZQ)(()=>{let r=o(e,-1),a=o(t,-1),s=n.lKK(r,a);return n.HZy(n.czq(s,-1))})}let m={meanSquaredError:l,meanAbsoluteError:u,meanAbsolutePercentageError:h,meanSquaredLogarithmicError:function(e,t){return(0,n.DZQ)(()=>{let r=n.zQh(t,(0,a.Ni)(),Number.MAX_VALUE),i=n.Rm2(n.WQq(1,r)),o=n.zQh(e,(0,a.Ni)(),Number.MAX_VALUE),l=n.Rm2(n.WQq(1,o));return n.i2o(s.Ew(n.jbE(i,l)),-1)})},squaredHinge:function(e,t){return(0,n.DZQ)(()=>{let r=n.PhQ(0,n.jbE(1,n.lKK(e,t)));return n.i2o(s.Ew(r),-1)})},hinge:function(e,t){return(0,n.DZQ)(()=>{let r=n.PhQ(0,n.jbE(1,n.lKK(e,t)));return n.i2o(r,-1)})},categoricalHinge:function(e,t){return(0,n.DZQ)(()=>{let r=n.czq(n.lKK(e,t),-1),a=n.T9B(n.lKK(n.jbE(1,e),t),-1);return n.PhQ(0,n.WQq(1,n.jbE(a,r)))})},logcosh:function(e,t){return(0,n.DZQ)(()=>{let r=Math.log(2),a=n.jbE(t,e),s=n.jbE(n.WQq(a,n.lw0(n.lKK(-2,a))),r);return n.i2o(s,-1)})},categoricalCrossentropy:p,sparseCategoricalCrossentropy:d,binaryCrossentropy:c,kullbackLeiblerDivergence:function(e,t){return(0,n.DZQ)(()=>{let r=n.zQh(e,(0,a.Ni)(),1),s=n.zQh(t,(0,a.Ni)(),1);
4012return n.czq(n.lKK(e,n.Rm2(n.y4m(r,s))),-1)})},poisson:function(e,t){return(0,n.DZQ)(()=>{let r=n.Rm2(n.WQq((0,a.Ni)(),t));return n.i2o(n.jbE(t,n.lKK(e,r)),-1)})},cosineProximity:f};function g(e){if("string"!=typeof e)return e;{if(e in m)return m[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 i.Qp(t)}}},71069:(e,t,r)=>{"use strict";r.d(t,{P:()=>i});var n=r(19041),a=r(48592),s=r(27924);let i=(0,r(62176).op)({step_:function(e,t=0){let r=(0,s.YT)(e,"x","step");return n.T2.runKernel(a.pnw,{x:r},{alpha:t})}})},71553:(e,t,r)=>{"use strict";r.d(t,{Kz:()=>i,Tb:()=>h,Tw:()=>o,ik:()=>p,mB:()=>u});var n=r(51520),a=r(90670),s=r(26981);function i(e,t,r,i){let l=r.map((e,r)=>{let n={logicalShape:e.shape,texShape:e.isUniform?null:e.texData.texShape,isUniform:e.isUniform,isPacked:!e.isUniform&&e.texData.isPacked,flatOffset:null};return null!=e.texData&&null!=e.texData.slice&&e.texData.slice.flatOffset>0&&(n.flatOffset=e.texData.slice.flatOffset),{name:t.variableNames[r],shapeInfo:n}}),u=l.map(e=>e.shapeInfo),h={logicalShape:i.shape,texShape:i.texData.texShape,isUniform:!1,isPacked:i.texData.isPacked,flatOffset:null},p=a.yr(l,h,t),d=(0,s.createFragmentShader)(e.gl,p),c=e.createProgram(d);return(0,n._K2)().get("ENGINE_COMPILE_ONLY")?{program:t,fragmentShader:d,source:p,webGLProgram:c,inShapeInfos:u,outShapeInfo:h,variablesLocations:null,customUniformLocations:null,infLoc:null,nanLoc:null,outShapeLocation:null,outShapeStridesLocation:null,outTexShapeLocation:null}:(e.buildVao(c),Object.assign({program:t,fragmentShader:d,source:p,webGLProgram:c,inShapeInfos:u,outShapeInfo:h},o(e,t,c)))}function o(e,t,r){let a,s,i,o=[],l=[],u=null,h=null;for(let a of(h=e.getUniformLocation(r,"NAN",!1),1===(0,n._K2)().getNumber("WEBGL_VERSION")&&(u=e.getUniformLocation(r,"INFINITY",!1)),t.variableNames)){let n={name:a,uniform:e.getUniformLocation(r,a,!1),offset:e.getUniformLocation(r,`offset${a}`,!1)};t.enableShapeUniforms&&(n.shape=e.getUniformLocation(r,`${a}Shape`,!1),n.texShape=e.getUniformLocation(r,`${a}TexShape`,!1)),o.push(n)}if(t.enableShapeUniforms&&(a=e.getUniformLocation(r,"outShape",!1),i=e.getUniformLocation(r,"outShapeStrides",!1),s=e.getUniformLocation(r,"outTexShape",!1)),t.customUniforms)for(let n of t.customUniforms)l.push(e.getUniformLocation(r,n.name,!1));return{variablesLocations:o,customUniformLocations:l,infLoc:u,nanLoc:h,outShapeLocation:a,outShapeStridesLocation:i,outTexShapeLocation:s}}function l(e,t){if(e.length!==t.length)throw Error(`Binary was compiled with ${e.length} inputs, but was executed with ${t.length} inputs`);e.forEach((e,r)=>{let a=e.logicalShape,s=t[r],i=s.shape;if(!n.ZSL.arraysEqual(a,i))throw Error(`Binary was compiled with different shapes than the current args. Shapes ${a} and ${i} must match`);if(e.isUniform&&s.isUniform)return;let o=e.texShape,l=s.isUniform?null:s.texData.texShape;if(!n.ZSL.arraysEqual(o,l))throw Error(`Binary was compiled with different texture shapes than the current args. Shape ${o} and ${l} must match`)})}function u(e,t,r,s,i){t.program.enableShapeUniforms||(l(t.inShapeInfos,r),l([t.outShapeInfo],[s]));let o=s.texData.texture,u=s.texData.texShape;s.texData.isPacked?e.setOutputPackedMatrixTexture(o.texture,u[0],u[1]):e.setOutputMatrixTexture(o.texture,u[0],u[1]),e.setProgram(t.webGLProgram),e.bindVertexArray(t.webGLProgram.vao),1===(0,n._K2)().getNumber("WEBGL_VERSION")&&null!==t.infLoc&&e.gl.uniform1f(t.infLoc,1/0),null!==t.nanLoc&&e.gl.uniform1f(t.nanLoc,NaN);for(let s=0;s<r.length;++s){let i=r[s],{uniform:o,offset:l,shape:u,texShape:h}=t.variablesLocations[s];if(u){let{uniformShape:r}=a.YE(t.program.packedInputs,i.shape,i.texData.texShape);switch(r.length){case 1:e.gl.uniform1iv(u,new Int32Array(r));break;case 2:e.gl.uniform2iv(u,new Int32Array(r));break;case 3:e.gl.uniform3iv(u,new Int32Array(r));break;case 4:e.gl.uniform4iv(u,new Int32Array(r))}}if(h&&e.gl.uniform2i(h,i.texData.texShape[0],i.texData.texShape[1]),null!=o){if(i.isUniform){if(2>n.ZSL.sizeFromShape(i.shape))e.gl.uniform1f(o,i.uniformValues[0]);else{let t=i.uniformValues;t instanceof Float32Array||(t=new Float32Array(t)),e.gl.uniform1fv(o,t)}continue}null!=i.texData.slice&&null!=l&&e.gl.uniform1i(l,i.texData.slice.flatOffset),e.setInputMatrixTexture(i.texData.texture.texture,o,s)}}let h=t.outShapeLocation;if(h)switch(s.shape.length){case 1:e.gl.uniform1iv(h,new Int32Array(s.shape));break;case 2:e.gl.uniform2iv(h,new Int32Array(s.shape));break;case 3:e.gl.uniform3iv(h,new Int32Array(s.shape));break;case 4:e.gl.uniform4iv(h,new Int32Array(s.shape))}if(t.outShapeStridesLocation){let r=n.ZSL.computeStrides(s.shape);switch(s.shape.length){case 2:e.gl.uniform1iv(t.outShapeStridesLocation,new Int32Array(r));break;case 3:e.gl.uniform2iv(t.outShapeStridesLocation,new Int32Array(r));break;case 4:e.gl.uniform3iv(t.outShapeStridesLocation,new Int32Array(r))}}if(t.outTexShapeLocation&&e.gl.uniform2i(t.outTexShapeLocation,s.texData.texShape[0],s.texData.texShape[1]),t.program.customUniforms&&i)for(let r=0;r<t.program.customUniforms.length;++r){let n=t.program.customUniforms[r],a=t.customUniformLocations[r],s=i[r];if("float"===n.type)e.gl.uniform1fv(a,s);else if("vec2"===n.type)e.gl.uniform2fv(a,s);else if("vec3"===n.type)e.gl.uniform3fv(a,s);else if("vec4"===n.type)e.gl.uniform4fv(a,s);else if("int"===n.type)e.gl.uniform1iv(a,s);else if("ivec2"===n.type)e.gl.uniform2iv(a,s);else if("ivec3"===n.type)e.gl.uniform3iv(a,s);else if("ivec4"===n.type)e.gl.uniform4iv(a,s);else throw Error(`uniform type ${n.type} is not supported yet.`)}e.executeProgram()}function h(e,t,r){let s="";t.concat(r).forEach(t=>{let i=null!=t.texData&&null!=t.texData.slice&&t.texData.slice.flatOffset>0;if(e.enableShapeUniforms&&!t.isUniform){let o=t.texData.texShape,{useSqueezeShape:l,uniformShape:u,keptDims:h}=a.YE(e.packedInputs,t.shape,o),p="",d="",c="";if(1===u.length&&e.packedInputs){let e=[Math.ceil(o[0]/2),Math.ceil(o[1]/2)];p=`${e[0]>1}_${e[1]>1}`}else if(2!==u.length||e.packedInputs){if(u.length>2&&!e.packedInputs){let e=n.ZSL.computeStrides(u);c=`${e[0]===o[1]}_${e[e.length-1]===o[1]}`}}else d=`${u[0]>1}_${u[1]>1}`;let f=t.shape.length,m=2===u.length&&n.ZSL.arraysEqual(t.shape,o),g=1===n.ZSL.sizeFromShape(t.
4012shape),y=n.C0T.getBroadcastDims(t.shape,r.shape),b=!e.packedInputs&&f===r.shape.length&&n.ZSL.arraysEqual(o,r.texData.texShape),x=e.packedInputs||u.length>2?"":`${o[0]>1}_${o[1]>1}`;s+=`${f}_${b}_${l?h:""}_${u.length}_${g}_${y}_${m}_${p}_${d}_${c}_${x}_${i}`}else{let e=t.isUniform?"uniform":t.texData.texShape;s+=`${t.shape}_${e}_${i}`}});let i=e.userCode,o=e.constructor.name;return o+("_"+s+"_"+i+`${(0,n._K2)().getNumber("WEBGL_VERSION")}`)}function p(e){return(0,n._K2)().getBool("WEBGL_USE_SHAPES_UNIFORMS")&&e<=4}},72591:(e,t,r)=>{"use strict";function n(e){let t=0;for(let r of e)0===r.shape.length?t+=1:t+=r.shape.reduce((e,t)=>e*t);return t}r.d(t,{Y:()=>n})},72710:(e,t,r)=>{"use strict";r.d(t,{V2:()=>f,ai:()=>m});var n=r(51520),a=r(90556),s=r(15034),i=r(14811),o=r(97344),l=r(44309),u=r(82692),h=r(1560),p=r(46096),d=r(83234);class c extends i.Wd{constructor(e){super(e),this.layer=e.layer}build(e){this.built=!0}get trainable(){return null!=this.layer&&this.layer.trainable}set trainable(e){null!=this.layer&&(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()}};return Object.assign(e,super.getConfig()),e}setFastWeightInitDuringBuild(e){super.setFastWeightInitDuringBuild(e),null!=this.layer&&this.layer.setFastWeightInitDuringBuild(e)}static fromConfig(e,t,r={}){let n=t.layer,a=(0,d.i)(n,r);delete t.layer;let s={layer:a};return Object.assign(s,t),new e(s)}}class f extends c{constructor(e){super(e),this.supportsMasking=!0}build(e){if((e=(0,h.U$)(e)).length<3)throw new o.Qp(`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){let t=[(e=(0,h.U$)(e))[0]].concat(e.slice(2)),r=this.layer.computeOutputShape(t),n=e[1];return[r[0],n].concat(r.slice(1))}call(e,t){return(0,n.DZQ)(()=>(e=(0,h.un)(e),(0,p.L7)((e,r)=>[(0,h.un)(this.layer.call(e,t)),[]],e,[],!1,null,null,!1,!0)[1]))}}f.className="TimeDistributed",n.JFn.registerClass(f);class m extends c{constructor(e){var t;super(e);let r=e.layer.getConfig(),n={};n.className=e.layer.getClassName(),n.config=r,this.forwardLayer=(0,d.i)(n),r.goBackwards=!0!==r.goBackwards;let a={};if(a.className=e.layer.getClassName(),a.config=r,this.backwardLayer=(0,d.i)(a),this.forwardLayer.name="forward_"+this.forwardLayer.name,this.backwardLayer.name="backward_"+this.backwardLayer.name,this.mergeMode=void 0===e.mergeMode?"concat":e.mergeMode,t=this.mergeMode,u.E6(l.r$,"BidirectionalMergeMode",t),e.weights)throw new o.EH("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,null!=this.forwardLayer&&(this.forwardLayer.trainable=e),null!=this.backwardLayer&&(this.backwardLayer.trainable=e)}getWeights(){return this.forwardLayer.getWeights().concat(this.backwardLayer.getWeights())}setWeights(e){let t=Math.floor(e.length/2);this.forwardLayer.setWeights(e.slice(0,t)),this.backwardLayer.setWeights(e.slice(t))}computeOutputShape(e){let t,r,n,a=this.forwardLayer.computeOutputShape(e);return(Array.isArray(a)&&Array.isArray(a[0])||(a=[a]),this.returnState&&(n=a.slice(1)),t=a[0],"concat"===this.mergeMode?(t[t.length-1]*=2,r=[t]):r=null==this.mergeMode?[t,t.slice()]:[t],this.returnState)?null==this.mergeMode?r.concat(n).concat(n.slice()):[t].concat(n).concat(n.slice()):u.wL(r)}apply(e,t){let r=null==t?null:t.initialState,n=null==t?null:t.constants;null==t&&(t={});let a=(0,p.tL)(e,r,n,this.numConstants);if(e=a.inputs,r=a.initialState,n=a.constants,Array.isArray(e)&&(r=e.slice(1),e=e[0]),(null==r||0===r.length)&&null==n)return super.apply(e,t);let s=[],l=[];
4012if(null!=r){let e=r.length;if(e%2>0)throw new o.Qp("When passing `initialState` to a Bidrectional RNN, the state should be an Array containing the states of the underlying RNNs.");t.initialState=r,s.push(...r);let n=r.map(e=>new i.eO({shape:e.shape}));this.forwardLayer.stateSpec=n.slice(0,e/2),this.backwardLayer.stateSpec=n.slice(e/2),l.push(...n)}if(null!=n)throw new o.EH("Support for constants in Bidirectional layers is not implemented yet.");let u=s[0]instanceof i.Ar;for(let e of s)if(e instanceof i.Ar!==u)throw new o.Qp("The initial state of a Bidirectional layer cannot be specified as a mix of symbolic and non-symbolic tensors");if(!u)return super.apply(e,t);{let r=[e].concat(s),n=this.inputSpec.concat(l),a=this.inputSpec;this.inputSpec=n;let i=super.apply(r,t);return this.inputSpec=a,i}}call(e,t){return(0,n.DZQ)(()=>{let r,s,i,o,l=t.initialState;if(null==l)r=this.forwardLayer.call(e,t),s=this.backwardLayer.call(e,t);else{let n=l.slice(0,l.length/2),a=l.slice(l.length/2);r=this.forwardLayer.call(e,Object.assign(t,{initialState:n})),s=this.backwardLayer.call(e,Object.assign(t,{initialState:a}))}return(this.returnState&&(Array.isArray(r)&&(i=r.slice(1).concat(s.slice(1))),r=r[0],s=s[0]),this.returnSequences&&(s=n.BEg(s,1)),"concat"===this.mergeMode?o=a.u1([r,s]):"sum"===this.mergeMode?o=n.WQq(r,s):"ave"===this.mergeMode?o=n.lKK(.5,n.WQq(r,s)):"mul"===this.mergeMode?o=n.lKK(r,s):null==this.mergeMode&&(o=[r,s]),this.returnState)?null==this.mergeMode?o.concat(i):[o].concat(i):o})}resetStates(e){this.forwardLayer.resetStates(),this.backwardLayer.resetStates()}build(e){(0,s.IU)(this.forwardLayer.name,()=>{this.forwardLayer.build(e)}),(0,s.IU)(this.backwardLayer.name,()=>{this.backwardLayer.build(e)}),this.built=!0}computeMask(e,t){let r;if(Array.isArray(t)&&(t=t[0]),r=this.returnSequences?null==this.mergeMode?[t,t]:t:null==this.mergeMode?[null,null]:null,!this.returnState)return r;{let e=this.forwardLayer.states.map(e=>null);return Array.isArray(r)?r.concat(e).concat(e):[r].concat(e).concat(e)}}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),null!=this.forwardLayer&&this.forwardLayer.setFastWeightInitDuringBuild(e),null!=this.backwardLayer&&this.backwardLayer.setFastWeightInitDuringBuild(e)}getConfig(){let e={mergeMode:this.mergeMode};return Object.assign(e,super.getConfig()),e}static fromConfig(e,t){let r=(0,d.i)(t.layer);if(delete t.layer,null!=t.numConstants)throw new o.EH("Deserialization of a Bidirectional layer with numConstants present is not supported yet.");return t.layer=r,new e(t)}}m.className="Bidirectional",n.JFn.registerClass(m)},72796:(e,t,r)=>{"use strict";r.d(t,{k:()=>i});var n=r(19041),a=r(48592),s=r(27924);let i=(0,r(62176).op)({gather_:function(e,t,r=0,i=0){let o=(0,s.YT)(e,"x","gather"),l=(0,s.YT)(t,"indices","gather","int32");return n.T2.runKernel(a.mxL,{x:o,indices:l},{axis:r,batchDims:i})}})},72946:(e,t,r)=>{"use strict";r.d(t,{LD:()=>m,LG:()=>g,OM:()=>d,Sb:()=>y,Yb:()=>f,cL:()=>x,xu:()=>c});var n=r(51520),a=r(90556),s=r(14811),i=r(97344),o=r(70796),l=r(82692),u=r(77617),h=r(1560);class p extends s.Wd{constructor(e){super(e||{}),this.supportsMasking=!0}mergeFunction(e){throw new i.EH}computeElementwiseOpOutputShape(e,t){if(null==e||null==t)return null;if(e.length<t.length)return this.computeElementwiseOpOutputShape(t,e);if(0===t.length)return e;let r=e.slice(0,e.length-t.length);for(let n=0;n<t.length;++n){let a=e[e.length-t.length+n],s=t[n];if(null==a||null==s||a<0||s<0)r.push(null);else if(1===a)r.push(s);else if(1===s)r.push(a);else{if(a!==s)throw new i.Qp("Operands could not be broadcast together with shapes "+JSON.stringify(e)+" "+JSON.stringify(t));r.push(a)}}return r}build(e){if(Array.isArray(e)&&!Array.isArray(e[0])&&(e=[(0,h.U$)(e)]),e.length<2)throw new i.Qp(`A merge layer should be called on an Array of at least 2 inputs. Got ${e.length} input(s).`);let t=[];for(let r of e)null!=r&&null!==r[0]&&t.push(r[0]);if((t=l.Am(t)).length>1)throw new i.Qp(`Can not merge tensors with different batch sizes. Got tensors with shapes: ${JSON.stringify(e)}.`);let r=null==e[0]?null:e[0].slice(1);for(let t=1;t<e.length;++t){let n=null==e[t]?null:e[t].slice(1);r=this.computeElementwiseOpOutputShape(r,n)}let n=e.map(e=>e.length);-1===e.indexOf(null)&&1===l.Am(n).length?this.reshapeRequired=!1:this.reshapeRequired=!0}call(e,t){return(0,n.DZQ)(()=>
4012{if(!this.reshapeRequired)return this.mergeFunction(e);{let t=[],r=e.map(e=>e.rank);if(-1===r.indexOf(null)){let n=u.T9(r);for(let r of e){let e=r.rank;for(let t=0;t<n-e;++t)r=a.UG(r,1);t.push(r)}return this.mergeFunction(t)}{let r=!1;for(let a of e){let e=a.rank;if(null==e){let e=a.shape,s=e[0],i=e.slice(1).concat([s]),o=n.tQQ(a,[s].concat(u.no(e.slice(1))));o=n.mgz(o,[1,0]),o=n.tQQ(o,i),t.push(o),r=!0}else if(e>1){let s=u.y1(1,e).concat([0]);t.push(n.mgz(a,s)),r=!0}else t.push(a)}let a=this.mergeFunction(t),s=a.rank;if(r){if(null==s){let e=a.shape,t=e.length,r=e[t-1],s=[r].concat(e.slice(0,e.length-1));a=n.tQQ(n.mgz(n.tQQ(a,[-1,r]),[1,0]),s)}else if(s>1){let e=[s-1].concat(u.y1(0,s-1));a=n.mgz(a,e)}}return a}}})}computeOutputShape(e){let t;t=null==e[0]?null:e[0].slice(1);for(let r=1;r<e.length;++r){let n=null==e[r]?null:e[r].slice(1);t=this.computeElementwiseOpOutputShape(t,n)}let r=[];for(let t of e)null!=t&&null!==t[0]&&r.push(t[0]);return 1===(r=l.Am(r)).length?r.concat(t):[null].concat(t)}computeMask(e,t){return n.DZQ(()=>{if(null==t)return null;if(!Array.isArray(t))throw new i.Qp("`mask` should be an Array");if(!Array.isArray(e))throw new i.Qp("`inputs` should be an Array");if(t.length!==e.length)throw new i.Qp(`The Array 'inputs' and 'mask' are expected to have the same length, but have different lengths (${e.length} vs ${t.length})`);if(t.every(e=>null==e))return null;let r=(t=t.map(e=>null==e?e:n.UG6(e,0)))[0];for(let e=1;e<t.length-1;++e)r=n.n76(r,t[e]);return r})}}class d extends p{constructor(e){super(e)}mergeFunction(e){return(0,n.DZQ)(()=>{let t=e[0].clone();for(let r=1;r<e.length;++r)t=n.WQq(t,e[r]);return t})}}d.className="Add",n.JFn.registerClass(d);class c extends p{constructor(e){super(e)}mergeFunction(e){return(0,n.DZQ)(()=>{let t=e[0].clone();for(let r=1;r<e.length;++r)t=n.lKK(t,e[r]);return t})}}c.className="Multiply",n.JFn.registerClass(c);class f extends p{constructor(e){super(e)}mergeFunction(e){return(0,n.DZQ)(()=>{let t=e[0].clone();for(let r=1;r<e.length;++r)t=n.WQq(t,e[r]);return n.lKK(1/e.length,t)})}}f.className="Average",n.JFn.registerClass(f);class m extends p{constructor(e){super(e)}mergeFunction(e){return(0,n.DZQ)(()=>{let t=e[0];for(let r=1;r<e.length;++r)t=n.PhQ(t,e[r]);return t})}}m.className="Maximum",n.JFn.registerClass(m);class g extends p{constructor(e){super(e)}mergeFunction(e){return(0,n.DZQ)(()=>{let t=e[0];for(let r=1;r<e.length;++r)t=n.BpO(t,e[r]);return t})}}g.className="Minimum",n.JFn.registerClass(g);class y extends p{constructor(e){super(e),this.DEFAULT_AXIS=-1,null==e&&(e={}),this.axis=null==e.axis?this.DEFAULT_AXIS:e.axis,this.supportsMasking=!0,this.reshapeRequired=!1}build(e){if(!(Array.isArray(e)&&Array.isArray(e[0]))||1===e.length)throw new i.Qp("A `Concatenate` layer should be called on a list of at least 2 inputs");let t=!0;for(let r of e)if(null!=r){t=!1;break}if(t)return;let r=[];for(let t=0;t<e.length;++t){let a=e[t].slice();a.splice(this.axis,1);let s=!1;for(let e of r)if(n.ZSL.arraysEqual(e,a)){s=!0;break}s||r.push(a)}if(r.length>1)throw new i.Qp("A `Concatenate` layer requires inputs with matching shapes except for the concat axis. Got input shapes: "+JSON.stringify(e))}mergeFunction(e){return(0,n.DZQ)(()=>a.u1(e,this.axis))}computeOutputShape(e){if(!(Array.isArray(e)&&Array.isArray(e[0])))throw new i.Qp("A `Concatenate` layer should be called on a list of inputs.");let t=e[0].slice(),r=this.axis<0?t.length+this.axis:this.axis;for(let n of e.slice(1)){if(null==t[r]||null==n[r]){t[r]=null;break}t[r]+=n[r]}return t}computeMask(e,t){if(null==t)return null;if(!Array.isArray(t))throw new i.Qp("`mask` should be an array for Concatenate");if(!Array.isArray(e))throw new i.Qp("`inputs` should be an array for Concatenate");if(t.length!==e.length)throw new i.Qp(`Mismatch in the length of mask (${t.length}) and the legnth of inputs (${e.length})`);return n.DZQ(()=>{let r=!0;if(t.forEach(e=>{if(null!=e){r=!1;return}}),r)return null;let a=[];for(let r=0;r<e.length;++r)null==t[r]?a.push(n.wgE(n.P61(e[r]),"bool")):t[r].rank<e[r].rank?a.push(n.UG6(t[r],-1)):a.push(t[r]);let s=n.xWs(a,this.axis);return n.Q7R(s,-1,!1)})}getConfig(){let e={axis:this.axis};return Object.assign(e,super.getConfig()),e}}function b(e,t){for(;e<0;)e+=t;return e}y.className="Concatenate",n.JFn.registerClass(y);class x extends p{constructor(e){super(e),this.axes=e.axes,this.normalize=null!=e.normalize&&e.normalize,this.supportsMasking=!0,this.reshapeRequired=!1}build(e){n.ZSL.assert(Array.isArray(e)&&2===e.length&&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],r=e[1];if(t.length>3||r.length>3)throw new i.EH("Dot layer does not support tensors of 4D or higher rank yet.");let a=this.interpretAxes(t,r);if(t[a[0]]!==r[a[1]])throw new i.Qp(`Dimension incompatibility: ${t[a[0]]} !== ${r[a[1]]}`)}mergeFunction(e){let t;if(2!==e.length)throw new i.Qp(`A \`Dot\` layer must be called on exactly 2 inputs, but received ${e.length} input(s).`);let r=e[0],a=e[1];t=Array.isArray(this.axes)?this.axes.map((t,r)=>b(t,e[r].shape.length)):[b(this.axes,r.shape.length),b(this.axes,a.shape.length)],this.normalize&&(r=(0,o.Yq)(r,t[0]),a=(0,o.Yq)(a,t[1]));var s=r,l=a,u=t;if(s.shape.length>3||l.shape.length>3)throw new i.EH("batchDot is not implemented for tensors of 4D or higher rank yet");if(n.ZSL.assert(s.shape.length>=2,()=>`batchDot requires the rank of x to be >= 2, but got ${s.shape.length}`),n.ZSL.assert(s.shape.length>=2,()=>`batchDot requires the rank of y to be >= 2, but got ${l.shape.length}`),"number"==typeof u&&(u=[u,u]),"complex64"===s.dtype||"complex64"===l.dtype)throw new i.EH("batchDot is not implemented for complex64-type Tensors yet.");let h=s.shape.length,p=l.shape.length;null==u&&(u=[h-1,p-2]);let d=u;return n.DZQ(()=>{let e,t;if(h>p){e=h-p;let t=[];for(let r=0;r<e;++r)t.push(1);l=n.tQQ(l,l.shape.concat(t))}else if(p>h){e=p-h;let t=[];for(let r=0;r<e;++r)t.push(1);s=n.tQQ(s,s.shape.concat(t))}else e=0;if(2===s.shape.length&&2===l.shape.length)t=d[0]===d[1]?n.czq(n.lKK(s,l),d[0]):n.czq(n.lKK(n.mgz(s,[1,0]),l),d[1]);else{let e=d[0]!==s.shape.length-1,r=d[1]===l.shape.length-1;t=n.NoW(s,l,e,r)}if(e>0){let r;r=h>p?h+p-3:h-1;let a=[];for(let t=r;t<r+e;++t)a.push(t);t=n.r2V(t,a)}return 1===t.shape.length&&(t=n.UG6(t,1)),t})}interpretAxes(e,t){let r;return Array.isArray(this.axes)?this.axes:[b(this.axes,e.length),b(this.axes,t.length)]}computeOutputShape(e){n.ZSL.assert(Array.isArray(e)&&2===e.length&&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(),r=e[1].slice();if(t.length>3||r.length>3)throw new i.EH("Dot layer does not support tensors of 4D or higher rank yet.");let a=this.interpretAxes(t,r);t.splice(a[0],1),r.splice(a[1],1),r.splice(0,1);let s=t.concat(r);return 1===s.length&&s.push(1),s}computeMask(e,t){return null}getConfig(){let e={axes:this.axes,normalize:this.normalize};return Object.assign(e,super.getConfig()),e}}x.className="Dot",n.JFn.registerClass(x)},73187:(e,t,r)=>{"use strict";let n;r.d(t,{Ni:()=>s,VI:()=>i});var a=r(51520);function s(){return null==n&&(n=(0,a.Hs)().epsilon()),n}function i(){return"channelsLast"}},73546:(e,t,r)=>{"use strict";r.d(t,{Q:()=>i});var n=r(19041),a=r(48592),s=r(27924);let i=(0,r(62176).op)({all_:function(e,t=null,r=!1){let i=(0,s.YT)(e,"x","all","bool");return n.T2.runKernel(a.u8Z,{x:i},{axis:t,keepDims:r})}})},74069:(e,t,r)=>{"use strict";r.d(t,{_:()=>a});var n=r(51520);function a(e,t,r,a,s){let i=t.length,o=n.ZSL.sizeFromShape(t),l=n.ZSL.computeStrides(t),u=n.ZSL.computeStrides(s),h=n.ZSL.getTypedArrayFromDType(r,n.ZSL.sizeFromShape(s));for(let t=0;t<o;++t){let r=n.ZSL.indexToLoc(t,i,l),s=Array(r.length);for(let e=0;e<s.length;e++)s[e]=r[a[e]];h[n.ZSL.locToIndex(s,i,u)]=e[t]}return h}},74346:(e,t,r)=>{"use strict";r.d(t,{X:()=>i});var n=r(19041),a=r(48592),s=r(27924);let i=(0,r(62176).op)({argMin_:function(e,t=0){let r=(0,s.YT)(e,"x","argMin");return n.T2.runKernel(a.p_m,{x:r},{axis:t})}})},75017:(e,t,r)=>{"use strict";r.d(t,{B:()=>l,j:()=>o});var n=r(51520),a=r(49575),s=r(57568),i=r(63405);function o(e,t,r,o){return null==r?({inputs:r,backend:s})=>{let{a:i,b:l}=r;(0,a.C)([i,l],e);let u=s.data.get(i.dataId).values,h=s.data.get(l.dataId).values,p="string"===i.dtype?n.C0T.fromUint8ToStringArray(u):u,d="str
4012ing"===i.dtype?n.C0T.fromUint8ToStringArray(h):h,c=o||i.dtype,[f,m]=t(i.shape,l.shape,p,d,c);return s.makeTensorInfo(m,c,f)}:({inputs:e,backend:n})=>{let{a,b:l}=e;if("complex64"===a.dtype||"complex64"===l.dtype){let e=(0,s.wg)({inputs:{x:a},backend:n,attrs:{dtype:"complex64"}}),t=n.data.get(e.dataId),o=t.complexTensorInfos.real,u=t.complexTensorInfos.imag,h=n.data.get(o.dataId).values,p=n.data.get(u.dataId).values,d=(0,s.wg)({inputs:{x:l},backend:n,attrs:{dtype:"complex64"}}),c=n.data.get(d.dataId),f=c.complexTensorInfos.real,m=c.complexTensorInfos.imag,g=n.data.get(f.dataId).values,y=n.data.get(m.dataId).values,[b,x,v]=r(a.shape,l.shape,h,p,g,y),w=n.makeTensorInfo(v,"float32",b),T=n.makeTensorInfo(v,"float32",x),S=(0,i.f)({inputs:{real:w,imag:T},backend:n});return n.disposeIntermediateTensorInfo(e),n.disposeIntermediateTensorInfo(d),n.disposeIntermediateTensorInfo(w),n.disposeIntermediateTensorInfo(T),S}{let e=n.data.get(a.dataId).values,r=n.data.get(l.dataId).values,s=o||a.dtype,[i,u]=t(a.shape,l.shape,e,r,s);return n.makeTensorInfo(u,s,i)}}}function l(e){return(t,r,a,s,i,o)=>{let l=n.C0T.assertAndGetBroadcastShape(t,r),u=n.ZSL.sizeFromShape(l),h=l.length,p=n.ZSL.computeStrides(l),d=n.ZSL.getTypedArrayFromDType("float32",u),c=n.ZSL.getTypedArrayFromDType("float32",u),f=n.C0T.getBroadcastDims(t,l),m=n.C0T.getBroadcastDims(r,l),g=n.C0T.mergeRealAndImagArrays(a,s),y=n.C0T.mergeRealAndImagArrays(i,o),b=t.length,x=n.ZSL.computeStrides(t),v=r.length,w=n.ZSL.computeStrides(r);if(f.length+m.length===0)for(let t=0;t<d.length;t++){let r=t%g.length,n=t%y.length,a=e(g[2*r],g[2*r+1],y[2*n],y[2*n+1]);d[t]=a.real,c[t]=a.imag}else for(let t=0;t<d.length;t++){let r=n.ZSL.indexToLoc(t,h,p),a=r.slice(-b);f.forEach(e=>a[e]=0);let s=n.ZSL.locToIndex(a,b,x),i=r.slice(-v);m.forEach(e=>i[e]=0);let o=n.ZSL.locToIndex(i,v,w),l=e(g[2*s],g[2*s+1],y[2*o],y[2*o+1]);d[t]=l.real,c[t]=l.imag}return[d,c,l]}}},75373:(e,t,r)=>{"use strict";r.d(t,{S:()=>a});var n=r(51520);function a(e,t,r){let a=e.length,s=[],i=0,o=0,l=Array(a);for(let n=0;n<a;++n){let a=s.length;!function(e,t,r,n){if(!e.length)return;if(0===t.length){for(let t=0;t<e.length;++t)n.push(e.subarray(t,t+1));return}if(1===t.length){let a=t[0],s=e.indexOf(a);for(;-1!==s;){let t=e.subarray(0,s);r&&0===t.length||n.push(t),s=(e=e.subarray(s+1)).indexOf(a)}r&&0===e.length||n.push(e);return}let a=0;for(let s=0;s<e.length+1;s++)if(s===e.length||-1!==t.indexOf(e[s])){let t=e.subarray(a,s);r&&0===t.length||n.push(t),a=s+1}}(e[n],t,r,s);let u=s.length-a;l[n]=u,i+=u,o=Math.max(o,u)}let u=n.ZSL.getArrayFromDType("int32",2*i),h=Array(i),p=[a,o],d=0;for(let e=0;e<a;++e)for(let t=0;t<l[e];++t)u[2*d]=e,u[2*d+1]=t,h[d]=s[d],++d;return[u,h,p]}},75504:(e,t,r)=>{"use strict";r.d(t,{RW:()=>u,g7:()=>c,oR:()=>d});var n=r(51520),a=r(97344);class s{constructor(e){this.maxEntries=e||100,this.cache=new Map}get(e){let t;return this.cache.has(e)&&(t=this.cache.get(e),this.cache.delete(e),this.cache.set(e,t)),t}put(e,t){if(this.cache.has(e))this.cache.delete(e);else if(this.cache.size>=this.maxEntries){let e=this.cache.keys().next().value;this.cache.delete(e)}this.cache.set(e,t)}getMaxEntries(){return this.maxEntries}setMaxEntries(e){if(e<0)throw Error(`The maxEntries of LRU caches must be at least 0, but got ${e}.`);if(this.maxEntries>e)for(let t=0;t<this.maxEntries-e;t++){let e=this.cache.keys().next().value;this.cache.delete(e)}this.maxEntries=e}}var i=r(82692),o=r(52536),l=r(14811);class u{constructor(e){if(this.id2Value={},this.id2Mask={},this.name2Id={},e instanceof u)for(let t in e.id2Value)this.id2Value[t]=e.id2Value[t],t in e.id2Mask&&(this.id2Mask[t]=e.id2Mask[t]);else{if(null==e)return;for(let t of e)this.add(t.key,t.value)}}add(e,t,r){if(null==this.id2Value[e.id])this.id2Value[e.id]=function(e,t){if(null==e.dtype||e.dtype===t.dtype)return t;try{return(0,n.wgE)(t,e.dtype)}catch(r){throw new a.Qp(`The dtype of the feed (${t.dtype}) can not be cast to the dtype of the key '${e.name}' (${e.dtype}).`)}}(e,t),this.name2Id[e.name]=e.id,null!=r&&(this.id2Mask[e.id]=r);else throw new a.Qp(`Duplicate key: name=${e.name}, id=${e.id}`);return this}addFeed(e){this.add(e.key,e.value)}hasKey(e){return null!=this.id2Value[e.id]}names(){return Object.keys(this.name2Id)}getValue(e){if(e instanceof l.Ar)if(null!=this.id2Value[e.id])return this.id2Value[e.id];else throw new a.Qp(`Nonexistent key: ${e.name}`);{let t=this.name2Id[e];if(null==t)throw new a.Qp(`Feed dict has no SymbolicTensor name: ${e}`);return this.id2Value[t]}}getMask(e){if(e instanceof l.Ar)if(null!=this.id2Value[e.id])return this.id2Mask[e.id];else throw new a.Qp(`Nonexistent key: ${e.name}`);{let t=this.name2Id[e];if(null==t)throw new a.Qp(`Feed dict has no SymbolicTensor name: ${e}`);return this.id2Mask[t]}}disposeMasks(){null!=this.id2Mask&&(0,n.ASo)(this.id2Mask)}}let h=new s,p=new s;function d(e){null!=h&&h.setMaxEntries(e),null!=p&&p.setMaxEntries(e)}function c(e,t,r,a){let s,l=null!=r&&r.training,d=Array.isArray(e),c=d?e:[e],m=c.map(e=>e.name),g=[],y=t.names();for(let e of m)-1!==y.indexOf(e)?g.push(t.getValue(e)):g.push(null);null!=a&&(a.maxNumTensors=-1/0,a.minNumTensors=1/0);let b=m.join(",")+"|"+t.names().sort().join(","),x=h.get(b);if(null==x){let e=function(e,t){n.ZSL.assert(null!=e&&e.length>0,()=>"Expected at least one fetch, got none");let r=[],a={};if(1===e.length){let n=f(e[0],t);r=n.sorted,a=n.recipientMap}else{let n=new Set;for(let s of e){let{sorted:e,recipientMap:i}=f(s,t);for(let t of e)n.has(t.name)||(r.push(t),n.add(t.name));for(let e in i)null==a[e]&&(a[e]=new Set),i[e].forEach(t=>a[e].add(t))}}return{sorted:r,recipientCounts:function(e){let t={};for(let r in e)t[r]=e[r].size;return t}(a)}}(c,t);x=e.sorted,s=e.recipientCounts,h.put(b,x),p.put(b,s)}s={},l||Object.assign(s,p.get(b));let v=new u(t);for(let e=0;e<x.length;++e){if(null!=a){let e=(0,n.m1Z)().numTensors;e>a.maxNumTensors&&(a.maxNumTensors=e),e<a.minNumTensors&&(a.minNumTensors=e)}let u=x[e],h=u.sourceLayer;if(h instanceof o.m)continue;let p=[],d=[],c=[],f=!1;for(let e of u.inputs){let r=v.getValue(e),n=v.getMask(e);p.push(r),d.push(n),null!=n&&(f=!0),!l&&(s[e.name]--,0!==s[e.name]||t.hasKey(e)||-1!==m.indexOf(e.name)||r.isDisposed||!0===e.s
4012ourceLayer.stateful||c.push(r))}f&&((r=r||{}).mask=d[0]);let y=(0,i.st)(h.apply(p,r)),b=null;h.supportsMasking&&(b=h.computeMask(p,d));let w=function(e){let t;if(1===e.sourceLayer.inboundNodes.length)t=e.sourceLayer.output;else{let r=null;for(let t=0;t<e.sourceLayer.inboundNodes.length;++t)for(let n of e.sourceLayer.inboundNodes[t].outputTensors)if(n.id===e.id){r=t;break}t=e.sourceLayer.getOutputAt(r)}return t}(u),T=Array.isArray(w)?w:[w];for(let e=0;e<T.length;++e){v.hasKey(T[e])||v.add(T[e],y[e],Array.isArray(b)?b[0]:b);let t=m.indexOf(T[e].name);-1!==t&&(g[t]=y[e])}l||(0,n.ASo)(c)}return v.disposeMasks(),d?g:g[0]}function f(e,t){let r=new Set,n=[],a={};for(let e of t.names())r.add(e);let s=[],i=[];for(s.push(e);s.length>0;){let e=s[s.length-1];if(r.has(e.name)){s.pop();continue}let t=i[i.length-1]===s.length-1;if(0===e.inputs.length||t)s.pop(),n.push(e),r.add(e.name),t&&i.pop();else for(let t of(i.push(s.length-1),e.inputs))null==a[t.name]&&(a[t.name]=new Set),a[t.name].add(e.name),r.has(t.name)||s.push(t)}return{sorted:n,recipientMap:a}}},75542:(e,t,r)=>{"use strict";r.d(t,{Q:()=>l,cu:()=>i});var n=r(51520),a=r(16986),s=r(75017);let i=(0,a.Z)((e,t)=>+(e<=t)),o=(0,s.j)(n.CwD,i,null,"bool"),l={kernelName:n.CwD,backendName:"cpu",kernelFunc:o}},75652:function(e,t,r){var n;!function(e,a,s){function i(e){var t=this,r="";t.next=function(){var e=t.b,r=t.c,n=t.d,a=t.a;return e=e<<25^e>>>7^r,r=r-n|0,n=n<<24^n>>>8^a,a=a-e|0,t.b=e=e<<20^e>>>12^r,t.c=r=r-n|0,t.d=n<<16^r>>>16^a,t.a=a-e|0},t.a=0,t.b=0,t.c=-0x61c88647,t.d=0x517cc1b7,e===Math.floor(e)?(t.a=e/0x100000000|0,t.b=0|e):r+=e;for(var n=0;n<r.length+20;n++)t.b^=r.charCodeAt(n),t.next()}function o(e,t){return t.a=e.a,t.b=e.b,t.c=e.c,t.d=e.d,t}function l(e,t){var r=new i(e),n=t&&t.state,a=function(){return(r.next()>>>0)/0x100000000};return a.double=function(){do var e=((r.next()>>>11)+(r.next()>>>0)/0x100000000)/2097152;while(0===e);return e},a.int32=r.next,a.quick=a,n&&("object"==typeof n&&o(n,r),a.state=function(){return o(r,{})}),a}a&&a.exports?a.exports=l:r.amdD&&r.amdO?void 0===(n=(function(){return l}).call(t,r,t,a))||(a.exports=n):this.tychei=l}(0,e=r.nmd(e),r.amdD)},75761:(e,t,r)=>{"use strict";r.d(t,{r:()=>i});var n=r(19041),a=r(48592),s=r(27924);let i=(0,r(62176).op)({sigmoid_:function(e){let t=(0,s.YT)(e,"x","sigmoid","float32");return n.T2.runKernel(a.vI1,{x:t})}})},76125:(e,t,r)=>{"use strict";r.d(t,{R:()=>i});var n=r(19041),a=r(48592),s=r(27924);let i=(0,r(62176).op)({sqrt_:function(e){let t=(0,s.YT)(e,"x","sqrt","float32");return n.T2.runKernel(a.dFH,{x:t})}})},76506:(e,t,r)=>{"use strict";r.d(t,{i:()=>i});var n=r(19041),a=r(48592),s=r(27924);let i=(0,r(62176).op)({mean_:function(e,t=null,r=!1){let i=(0,s.YT)(e,"x","mean");return n.T2.runKernel(a.g5A,{x:i},{axis:t,keepDims:r})}})},76526:(e,t,r)=>{"use strict";function n(e){let t=e.length,r=0;for(;t>0;)r=Math.random()*t|0,o(e,--t,r)}function a(e,t){if(e.length!==t.length)throw Error(`Array sizes must match to be shuffled together First array length was ${e.length}Second array length was ${t.length}`);let r=e.length,n=0;for(;r>0;)n=Math.random()*r|0,o(e,--r,n),o(t,r,n)}function s(e,t,r){return Math.max(e,Math.min(t,r))}function i(e){return e%2==0?e:e+1}function o(e,t,r){let n=e[t];e[t]=e[r],e[r]=n}function l(e){let t=0;for(let r=0;r<e.length;r++)t+=e[r];return t}function u(e,t){let r=Math.random();return t*r+(1-r)*e}function h(e,t){let r=0;for(let n=0;n<e.length;n++){let a=Number(e[n])-Number(t[n]);r+=a*a}return r}function p(e,t){if(!e)throw Error("string"==typeof t?t:t())}function d(e,t,r=""){p(y(e,t),()=>r+` Shapes ${e} and ${t} must match`)}function c(e){p(null!=e,()=>"The input to the tensor constructor must be a non-null value.")}function f(e){if(0===e.length)return 1;let t=e[0];for(let r=1;r<e.length;r++)t*=e[r];return t}function m(e){return 0===e.length}function g(e,t){if(e===t)return!0;if(null==e||null==t||e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(null!==e[r]&&null!==t[r]&&e[r]!==t[r])return!1;return!0}function y(e,t){if(e===t)return!0;if(null==e||null==t||e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(e[r]!==t[r])return!1;return!0}function b(e){return e%1==0}function x(e){if(null!=Math.tanh)return Math.tanh(e);if(e===1/0)return 1;{if(e===-1/0)return -1;let t=Math.exp(2*e);return(t-1)/(t+1)}}function v(e){let t=Math.ceil(Math.sqrt(e));
4012return[t,Math.ceil(e/t)]}function w(e){let t=new Uint32Array(e);for(let r=0;r<e;++r)t[r]=r;return n(t),t}function T(e,t){return t<=e.length?e:e+" ".repeat(t-e.length)}function S(e,t=e=>0,r,n){return new Promise((a,s)=>{let i=0,o=()=>{if(e())return void a();let l=t(++i);if(null!=r&&i>=r)return void s();null!=n?n(o,l):setTimeout(o,l)};o()})}function N(e,t){let r=1,n=-1;for(let t=0;t<e.length;++t)if(e[t]>=0)r*=e[t];else if(-1===e[t]){if(-1!==n)throw Error(`Shapes can only have 1 implicit size. Found -1 at dim ${n} and dim ${t}`);n=t}else if(e[t]<0)throw Error(`Shapes can not be < 0. Found ${e[t]} at dim ${t}`);if(-1===n){if(t>0&&t!==r)throw Error(`Size(${t}) must match the product of shape ${e}`);return e}if(0===r)throw Error(`Cannot infer the missing size in [${e}] when there are 0 elements`);if(t%r!=0)throw Error(`The implicit shape can't be a fractional number. Got ${t} / ${r}`);let a=e.slice();return a[n]=t/r,a}function k(e,t){let r=t.length;return p((e=null==e?t.map((e,t)=>t):[].concat(e)).every(e=>e>=-r&&e<r),()=>`All values in axis param must be in range [-${r}, ${r}) but got axis ${e}`),p(e.every(e=>b(e)),()=>`All values in axis param must be integers but got axis ${e}`),e.map(e=>e<0?r+e:e)}function I(e,t){let r=[],n=[],a=null!=t&&Array.isArray(t)&&0===t.length,s=null==t||a?null:k(t,e).sort(),i=0;for(let t=0;t<e.length;++t){if(null!=s){if(s[i]===t&&1!==e[t])throw Error(`Can't squeeze axis ${t} since its dim '${e[t]}' is not 1`);(null==s[i]||s[i]>t)&&1===e[t]&&(r.push(e[t]),n.push(t)),s[i]<=t&&i++}1!==e[t]&&(r.push(e[t]),n.push(t))}return{newShape:r,keptDims:n}}function C(e,t){return E(e,t)}function E(e,t){let r=null;if(null==e||"float32"===e)r=new Float32Array(t);else if("int32"===e)r=new Int32Array(t);else if("bool"===e)r=new Uint8Array(t);else if("string"===e)r=Array(t);else throw Error(`Unknown data type ${e}`);return r}function A(e,t){for(let r=0;r<e.length;r++){let n=e[r];if(isNaN(n)||!isFinite(n))throw Error(`A tensor of type ${t} being uploaded contains ${n}.`)}}function $(e){return"bool"===e||"complex64"===e||"float32"===e||"int32"===e||"string"===e}function F(e,t){return"complex64"!==t&&("float32"!==t||"complex64"===e)&&("int32"!==t||"float32"===e||"complex64"===e)&&("bool"!==t||"bool"!==e)}function R(e){if("float32"===e||"int32"===e)return 4;if("complex64"===e)return 8;if("bool"===e)return 1;throw Error(`Unknown dtype ${e}`)}function _(e){if(null==e)return 0;let t=0;return e.forEach(e=>t+=e.length),t}function D(e){return"string"==typeof e||e instanceof String}function O(e){return"boolean"==typeof e}function L(e){return"number"==typeof e}function M(e){return!!(e&&e.constructor&&e.call&&e.apply)}function P(e,t){for(let r=t;r<e;++r)if(e%r==0)return r;return e}function z(e){let t=e.length;if(t<2)return[];let r=Array(t-1);r[t-2]=e[t-1];for(let n=t-3;n>=0;--n)r[n]=r[n+1]*e[n+1];return r}function B(e,t,r=!1){if(0===e.length)return t[0];let n=e.reduce((e,t)=>e*t)*(r?2:1);if(0===n)return[];if(n!==t.length)throw Error(`[${e}] does not match the input size ${t.length}${r?" for a complex tensor":""}.`);return function e(t,r,n,a=!1){let s=[];if(1===r.length){let e=r[0]*(a?2:1);for(let r=0;r<e;r++)s[r]=n[t+r]}else{let i=r[0],o=r.slice(1),l=o.reduce((e,t)=>e*t)*(a?2:1);for(let r=0;r<i;r++)s[r]=e(t+r*l,o,n,a)}return s}(0,e,t,r)}function W(e,t){if(Array.isArray(e))return e;if("float32"===t)return e instanceof Float32Array?e:new Float32Array(e);if("int32"===t)return e instanceof Int32Array?e:new Int32Array(e);if("bool"===t||"string"===t)return Uint8Array.from(new Int32Array(e));throw Error(`Unknown dtype ${t}`)}function V(e,t){let r=G(e,t);for(let e=0;e<r.length;e++)r[e]=1;return r}function G(e,t){if(null==t||"float32"===t||"complex64"===t)return new Float32Array(e);if("int32"===t)return new Int32Array(e);if("bool"===t)return new Uint8Array(e);throw Error(`Unknown data type ${t}`)}function U(e,t){let r=e.reduce((e,t)=>e*t,1);if(null==t||"float32"===t)return B(e,new Float32Array(r));if("int32"===t)return B(e,new Int32Array(r));if("bool"===t)return B(e,new Uint8Array(r));throw Error(`Unknown data type ${t}`)}function Z(e){e.forEach(t=>{p(Number.isInteger(t)&&t>=0,()=>`Tensor must have a shape comprised of positive integers but got shape [${e}].`)})}function j(e,t,r){if(0===t)return 0;if(1===t)return e[0];let n=e[e.length-1];for(let t=0;t<e.length-1;++t)n+=r[t]*e[t];return n}function H(e,t,r){if(0===t)return[];if(1===t)return[e];let n=Array(t);for(let t=0;t<n.length-1;++t)n[t]=Math.floor(e/r[t]),e-=n[t]*r[t];return n[n.length-1]=e,n}function K(e){return e&&e.then&&"function"==typeof e.then}r.d(t,{Ab:()=>E,BE:()=>F,E6:()=>b,Et:()=>L,FZ:()=>V,HO:()=>c,Kg:()=>D,Lm:()=>O,O3:()=>d,P8:()=>w,SA:()=>Z,SL:()=>_,Sf:()=>m,Tn:()=>M,Ty:()=>G,Ur:()=>z,X$:()=>function e(t){if(Array.isArray(t))return e(t[0]);if(t instanceof Float32Array);else if(t instanceof Int32Array||t instanceof Uint8Array||t instanceof Uint8ClampedArray)return"int32";else if(L(t));else if(D(t))return"string";else if(O(t))return"bool";return"float32"},XT:()=>N,Y6:()=>k,Ze:()=>f,_k:()=>H,_q:()=>S,a0:()=>a,av:()=>T,c7:()=>U,ce:()=>C,cz:()=>l,eV:()=>i,e_:()=>g,gS:()=>v,gx:()=>I,jv:()=>R,k4:()=>n,lK:()=>P,nd:()=>A,o2:()=>W,oO:()=>h,qE:()=>s,r1:()=>y,sX:()=>j,so:()=>u,vA:()=>p,wg:()=>o,xn:()=>$,yL:()=>K,ym:()=>x,yw:()=>B})},77268:(e,t,r)=>{"use strict";r.d(t,{Ay:()=>eA});let n=e=>Array.isArray(e),a=e=>
4012n(e)?e[0]:e,s=(({scale:e,name:t,version:r,meta:{architecture:n,...s},path:i})=>{let o=i||`models/x${e}/model.json`;return"rdn"===n?{scale:e,modelType:"layers",_internals:{path:o,name:t,version:r},meta:{architecture:n,...s},inputRange:[0,255],outputRange:[0,255]}:{setup:t=>{let r=t.layers.Layer;class n extends r{beta;constructor(){super({}),this.beta=.2}call(e){return t.mul(a(e),this.beta)}static className="MultiplyBeta"}[n,(n=>{class s extends r{scale=n;constructor(){super({})}computeOutputShape(e){return[e[0],e[1],e[2],3]}call(e){return t.depthToSpace(a(e),this.scale,"NHWC")}static className=`PixelShuffle${e}x`}return s})(e)].forEach(e=>{t.serialization.registerClass(e)})},scale:e,modelType:"layers",_internals:{path:o,name:t,version:r},meta:{architecture:n,...s},inputRange:[0,1],outputRange:[0,1]}})({scale:2,name:"@upscalerjs/default-model",version:"1.0.0-beta.17",path:"models/model.json",meta:{C:1,D:2,G:4,G0:64,T:10,architecture:"rdn",patchSize:128,size:"slim",artifactReducing:!1,sharpening:!1,dataset:"div2k",modelFileName:"rdn-C1-D2-G4-G064-T10-x2-patchsize128-compress100-sharpen0-datadiv2k-vary_cFalse_best-val_loss_epoch494"}});var i,o=r(51520);!function(e){e.UNDEFINED="undefined",e.INVALID_MODEL_TYPE="invalidModelType",e.MISSING_PATH="missingPath"}(i||(i={}));let l=e=>!!e&&!!Array.isArray(e)&&4===e.length&&e.every(e=>null===e||"number"==typeof e),u=e=>l(e)&&null!==e[1]&&null!==e[2]&&e[1]>0&&e[2]>0;function h(e){return function(t){try{return t.shape.length===e}catch(e){}return!1}}let p=h(4),d=h(3),c=e=>e instanceof o.qYS,f=e=>"string"==typeof e,m=e=>"string"==typeof e&&["layers","graph"].includes(e);class g extends Error{type;constructor(e){super(e),this.type=e}}let y=e=>{if(void 0===e)throw new g(i.UNDEFINED);if(!m(e.modelType??"layers"))throw new g(i.INVALID_MODEL_TYPE);if(!e.path&&!e._internals?.path)throw new g(i.MISSING_PATH);return!0},b=e=>"number"==typeof e,x=e=>Array.isArray(e)&&2===e.length&&e.every(b),v=e=>{console.warn(Array.isArray(e)?e.join("\n"):e)};function w(e){return void 0!==e&&"function"==typeof e}let T=(e,t,r)=>!!w(e)&&!(e.length<=1)&&(void 0===r&&"tensor"===t||"tensor"===r),S=e=>!!e&&e.aborted;async function N(e,t){let r;for(r=await e.next();!r.done;r=await e.next())t&&await t(r.value);return r.value}function k(e){return null!=e}function I(e,t,...r){let n=r.filter(k);if(n.length){let r=e.tidy(()=>n.reduce((e,t)=>t(e),t));return t.isDisposed||t===r||t.dispose(),r}return t}let C=e=>e instanceof g,E=e=>`The tensor returned by the model was not a valid rank-4 tensor. It's shape is ${JSON.stringify(e)}.} UpscalerJS only supports models returning valid image-like data in four dimensional form. For more information, see https://upscalerjs.com/documentation/troubleshooting#invalid-predicted-tensor.`,A=Error("No defined tensors were passed to concatTensors");class $ extends Error{message="The upscale request received an abort signal"}let F=e=>`You've provided an invalid model type: ${JSON.stringify(e)}. Accepted types are "layers" and "graph". For more information, see https://upscalerjs.com/documentation/troubleshooting#invalid-model-type.`,R="There is a bug with the upscaler code. Please report this.",_=e=>`Expected model to have a rank-4 compatible input shape. Instead got: ${JSON.stringify(e)}. For more information, see https://upscalerjs.com/documentation/troubleshooting#error-with-model-input-shape.`,D=e=>Error(`Invalid patch size: ${e}. Patch size must be greater than 0.`),O=(e,t)=>Error(`Invalid patch size and padding: ${e} and ${t}. Patch size must be greater than padding * 2.`),L=(e,t,r)=>`Invalid patch size: ${e}. The model has a defined divibility factor of ${t} and patch size must be a multiple of this number. Patch size has been scaled up to ${r}. 4013For more information, see https://upscalerjs.com/documentation/troubleshooting#patch-size-indivisible-by-divisibility-factor.`,M=Error("Model input sizes must be square. If you are using a model with a non-square input size and would like to request support, please file a feature request at https://github.com/thekevinscott/upscalerjs"),P=e=>`Provided model configuration is missing both a "path" and "_internals". A valid path to a model JSON file must be provided. For more information, see https://upscalerjs.com/documentation/troubleshooting#missing-path-and-internals. The model configuration provided was: ${JSON.stringify(e)}`,z=(e,t,r)=>async n=>
4013{if(r&&await e.nextFrame(),S(t))throw Array.isArray(n)?n.forEach(e=>e?.dispose()):c(n)&&n.dispose(),new $},B=e=>!!e&&"object"==typeof e&&"patchSize"in e&&"number"==typeof e.patchSize,W=e=>!!e&&"number"==typeof e&&e>0,V=e=>["Invalid value passed to warmup in warmupSizes:",JSON.stringify(e),"For more information, see https://upscalerjs.com/documentation/troubleshooting#invalid-warmup-value."].join("\n"),G=e=>Error(V(e)),U=e=>{if(B(e)){let{patchSize:t}=e;return t}return e};async function*Z(e,t,r){let{model:n,modelDefinition:a}=await t;for(let t of r){if(!B(t)&&!W(t))throw G(t);let r=U(t),s=e.zeros([1,r,r,3]);for(let t of(yield[s],[a.preprocess,e=>n.predict(e),a.postprocess].filter(Boolean)))s=I(e,s,t),yield[s];s.dispose(),yield}}let j=e=>{if(Array.isArray(e)){for(let t of e)if(!B(t)&&!W(t))throw G(e);return e}if(B(e)||W(e))return[e];throw G(e)},H=async(e,t,r,{signal:n,awaitNextFrame:a=!1}={},s)=>{let i=z(e,n||s.signal,a);await i(),await N(Z(e,t,j(r)),i)},K=(e,t)=>t instanceof e.LayersModel,Y=e=>({...e});async function Q(e,t){var r,n;let a=(r=e,"function"==typeof(n=t)?(v("Passing a model definition as a function is deprecated and will be removed in a future version. To leverage model lifecycle methods, use the setup and teardown methods. For more information, see https://upscalerjs.com/documentation/troubleshooting#deprecated-model-definition-function."),n(r)):n);return a.setup&&await a.setup(e),a}function q(e,t,r){return"graph"===r?e.loadGraphModel(t):e.loadLayersModel(t)}let X=(e,t)=>K(e,t)?t.layers[0].batchInputShape:t.inputs[0].shape,J=(e,{model:t})=>{let r=X(e,t);if(!l(r))throw Error(_(r));return r},ee=(e,t)=>Math.ceil(t/e)*e,et=(e,t,{patchSize:r,padding:n},a)=>{let s=J(e,t);if(void 0!==r){if(r<=0)throw D(r);if(void 0!==n&&2*n>=r)throw O(r,n)}if(u(s)){if(void 0!==r&&v("You have provided a patchSize, but the model definition already includes an input size. Your patchSize will be ignored. For more information, see https://upscalerjs.com/documentation/troubleshooting#input-size-and-patch-size."),s[1]!==s[2])throw M;return{patchSize:s[1],padding:n,modelInputShape:s}}void 0!==r&&void 0===n&&v('"padding" is undefined, but "patchSize" is explicitly defined. Without padding, patches of images often have visible artifacting at the seams. Defining an explicit padding will resolve the artifacting. For more information, see https://upscalerjs.com/documentation/troubleshooting#padding-is-undefined. To hide this warning, pass an explicit padding of "0".');let{divisibilityFactor:i}=t.modelDefinition;if(void 0!==i){if(void 0!==r){let e=ee(i,r);return e!==r&&v(L(r,i,e)),{patchSize:e,padding:n,modelInputShape:[null,e,e,3]}}return{patchSize:void 0,padding:void 0,modelInputShape:[null,ee(i,a[1]),ee(i,a[2]),3]}}return{patchSize:r,padding:n,modelInputShape:void 0}},er=(e,t)=>r=>{let n=r.shape[1],a=r.shape[2];return u(t)&&(t[1]>n||t[2]>a)?e.tidy(()=>{let s=Math.max(n,t[1]),i=Math.max(a,t[2]),o=e.zeros([1,n,i-a,3]),l=e.zeros([1,s-n,i,3]),u=e.concat([r,o],2);return e.concat([u,l],1)}):r},en=(e,t,r)=>n=>{let a=t[1]*r,s=t[2]*r;return a<n.shape[1]||s<n.shape[2]?e.tidy(()=>e.slice(n,[0,0,0],[1,a,s,3])):n},ea=e=>t=>{let r=x(e)?e[1]:255;return t.clipByValue(0,r).mul(1===r?255:1)},es=(e,t)=>r=>x(t)&&1===t[1]?e.mul(r,1/255):r,ei=(e,t)=>e.tidy(()=>{let[r,n]=t.shape,a=e.fill([r,n],255).expandDims(2);return t.clipByValue(0,255).concat([a],2).dataSync()});function eo(e,t,r=0){let n=t.filter(k);if(0===n.length)throw A;let a=e.concat(n,r);return t.forEach(e=>e?.dispose()),a}let el=(e,t,r,n)=>{let a=t,s=0===t||r===e?0:n,i=a+r>e,o=i?r-(e-a):0,l=i||r===e?0:n,u=i?0:s,h=r-(i?o:0);return i&&(a=e-r),{pre:{origin:a-=u,size:r},post:{origin:o+=u,size:h-=u+l},increment:r>e?e:r-s-l}},eu=([e,t],r,n)=>{let a=[],s=0,i=0;for(;i<t;){let{pre:{origin:o,size:l},post:{origin:u,size:h},increment:p}=el(t,i,Math.min(r,t),n),d=[];for(;s<e;){let{pre:{origin:t,size:a},post:{origin:i,size:p},increment:c}=el(e,s,Math.min(r,e),n);d.push({pre:{origin:[o,t],size:[l,a]},post:{origin:[u,i],size:[h,p]}}),s+=c}a.push(d),s=0,i+=p}return a},eh=(e,t,r,n)=>(e*r+t+1)/n,ep=(e,t)=>{let r=e.predict(t);if(!c(r))throw Error("The model output was not a valid tensor. UpscalerJS only supports models returning valid tensors. This is likely an error with the model itself, not UpscalerJS. For more information, see https://upscalerjs.com/documentation/troubleshooting#invali
4013d-model-prediction.");if(p(r))return r;throw Error(E(r.shape))};async function*ed(e,t,{output:r,progress:n,progressOutput:a},s,{originalImageSize:i,patchSize:o,padding:l=0},{tensorAsBase64:u}){let{model:h,modelDefinition:p}=s,d=p.scale??1;if(o){let s,[c,f]=t.shape.slice(1),m=eu([f,c],o,l);yield;let g=m.length*m[0].length;for(let i=0;i<m.length;i++){let o,l=m[i],c=l.length;yield[o,s];for(let f=0;f<c;f++){let{pre:m,post:y}=l[f];yield[s,o];let b=t.slice([0,...m.origin],[-1,...m.size]);yield[s,o,b];let x=ep(h,b);b.dispose(),yield[s,o,x];let v=[0,y.origin[0]*d,y.origin[1]*d],S=[-1,y.size[0]*d,y.size[1]*d],N=x.slice(v,S);x.dispose(),yield[s,o,N];let k=I(e,N,p.postprocess,ea(p.outputRange));if(yield[s,o,k],void 0!==n&&w(n)){let t=eh(i,f,c,g);if(w(n)&&n.length<=1)n(t);else{let s=k.squeeze(),o={row:i,col:f,patchCoordinates:{pre:m,post:y}};if(T(n,r,a))n(t,s,o);else{let r=u(e,s);s.dispose(),n(t,r,o)}}}yield[s,o,k],o=eo(e,[o,k],2),k.dispose(),yield[s,o]}s=eo(e,[s,o],1),o.dispose(),yield[s]}let y=I(e,s.clone(),en(e,i,d));s?.dispose(),yield[y];let b=y.squeeze();return y.dispose(),b}n&&v('The "progress" callback was provided but "patchSize" was not defined. Without a "patchSize", the "progress" callback will never be called. For more information, see https://upscalerjs.com/documentation/troubleshooting#progress-specified-without-patch-size.');let c=ep(h,t);yield[c];let f=I(e,c.clone(),p.postprocess,ea(p.outputRange),en(e,i,d));c.dispose(),yield[f];let m=f.squeeze();return f.dispose(),m}async function*ec(e,t,r,n,{getImageAsTensor:a,tensorAsBase64:s}){let i=c(t)?t.clone():t,o=await a(e,i);yield o;let l=o.shape,{patchSize:u,padding:h,modelInputShape:p}=et(e,n,r,l),d=I(e,o,n.modelDefinition.preprocess,es(e,n.modelDefinition.inputRange),p?er(e,p):void 0);yield d;let f=ed(e,d,{output:r.output,progressOutput:r.progressOutput,progress:r.progress},n,{originalImageSize:l,patchSize:u,padding:h},{tensorAsBase64:s}),m=await f.next();for(yield m.value;!m.done;)Array.isArray((m=await f.next()).value)?yield[...m.value,d]:c(m.value)?yield[m.value,d]:yield d;d.dispose();let g=m.value;if("tensor"===r.output)return g;let y=s(e,g);return g.dispose(),y}async function ef(e,t,{signal:r,awaitNextFrame:n,...a},s,{checkValidEnvironment:i,...o}){i(t,{output:a.output,progressOutput:a.progressOutput});let l=z(e,r||s.signal,n);await l();let u=await N(ec(e,t,a,s,o),l);return await l(),u}var em=r(65519);let eg=e=>"tensor"===e?"tensor":"base64",ey={jsdelivr:(e,t,r)=>`https://cdn.jsdelivr.net/npm/${e}@${t}/${r}`,unpkg:(e,t,r)=>`https://unpkg.com/${e}@${t}/${r}`},eb=["jsdelivr","unpkg"],ex=(e,t,r)=>Error([`Could not resolve URL ${t} for package ${r?.name}@${r?.version}`,"Errors include:",...e.map(([e,t])=>`- ${e}: ${t.message}`)].join("\n"));async function ev(e,t){let{modelType:r,_internals:n,path:a}=t;if(a)return await q(e,a,r);if(!n)throw Error(R);let s=[];for(let t of eb){let a=ey[t];try{let t=a(n.name,n.version,n.path);return await q(e,t,r)}catch(e){s.push([t,e instanceof Error?e:Error(`There was an unknown error: ${JSON.stringify(e)}`)])}}throw ex(s,a||n.path,n)}let ew=()=>Error(`Environment does not support a string URL as an input format. 4014For more information, see https://upscalerjs.com/documentation/troubleshooting#environment-disallows-string-input.`),eT=()=>Error(`Environment does not support base64 as an output format. 4015For more information, see https://upscalerjs.com/documentation/troubleshooting#environment-disallows-base64.`),eS=e=>Error(`Unsupported dimensions for incoming pixels: ${e.shape.length}. 4016Only 3 or 4 rank tensors are supported.`),eN=()=>Error("Failed to load image"),ek=e=>new Promise((t,r)=>{let n=new Image;n.src=e,n.crossOrigin="anonymous",n.onload=()=>t(n),n.onerror=()=>r(eN())}),eI=e=>em.browser.fromPixelsAsync(e),eC=async(e,t)=>c(e)?e:f(e)?eI(await ek(e)):eI(e),eE=e=>{try{if(new Image,"createElement"in document!=!0)throw e()}catch(t){throw e()}},eA=function({tf:e,getUpscaleOptions:t,checkValidEnvironment:r,getImageAsTensor:n,tensorAsBase64:a,loadModel:i}){class o{_opts;_model;ready;_abortController=new AbortController;constructor(t={}){this._opts={...t},this._model=i(e,Q(e,this._opts.model||s)),this.ready=new Promise((t,r)=>{this._model.then(()=>H(e,this._model,this._opts.warmupSizes||[],void 0,{signal:this._abortController.signal}
4016)).then(t).catch(r)})}async execute(s,i){await this.ready;let o=await this._model;return ef(e,s,t(i),{...o,signal:this._abortController.signal},{checkValidEnvironment:r,getImageAsTensor:n,tensorAsBase64:a})}upscale=this.execute.bind(this);warmup=async(t=[],r)=>(await this.ready,H(e,this._model,t,r,{signal:this._abortController.signal}));abort=()=>{this._abortController.abort(),this._abortController=new AbortController};dispose=async()=>{await this.ready;let{model:t,modelDefinition:r}=await this._model;r.teardown&&await r.teardown(e),t.dispose()};getModel=()=>this._model}return o}({tf:em,getUpscaleOptions:({output:e,progressOutput:t,...r}={})=>({...r,output:eg(e),progressOutput:eg(t||e)}),loadModel:async(e,t)=>{let r=await t;try{y(r)}catch(e){if(C(e))throw function(e,t){switch(e){case i.INVALID_MODEL_TYPE:return Error(F(t?.modelType));case i.MISSING_PATH:return Error(P(t));default:return Error(R)}}(e.type,r);throw Error(R)}let n=Y(r);return{model:await ev(e,n),modelDefinition:n}},getImageAsTensor:async(e,t)=>{let r=await eC(t,e);if(d(r)){let e=r.expandDims(0);return r.dispose(),e}if(p(r))return r;throw eS(r)},tensorAsBase64:(e,t)=>{let r=ei(e,t),[n,a]=t.shape,s=new ImageData(a,n);s.data.set(r);let i=document.createElement("canvas");i.width=a,i.height=n;let o=i.getContext("2d");if(!o)throw Error("No context found");return o.putImageData(s,0,0),i.toDataURL()},checkValidEnvironment:(e,{output:t="base64",progressOutput:r})=>{"string"==typeof e&&eE(ew),("base64"===r||"base64"===t)&&eE(eT)}})},77308:(e,t,r)=>{"use strict";r.d(t,{Hq:()=>d,Nb:()=>h,UC:()=>p,X0:()=>l,X8:()=>u,_Q:()=>i,dR:()=>s,hE:()=>a,pd:()=>o});var n=r(71553);class a{constructor(e,t){this.variableNames=["A"],this.outputShape=e,this.enableShapeUniforms=(0,n.ik)(this.outputShape.length),this.userCode=` 4017 float unaryOperation(float x) { 4018 ${t} 4019 } 4020 4021 void main() { 4022 float x = getAAtOutCoords(); 4023 float y = unaryOperation(x); 4024 4025 setOutput(y); 4026 } 4027 `}}let s="if (isnan(x)) return x;",i="return x;",o="return abs(x);",l="return (x >= 0.0) ? x : (exp(x) - 1.0);",u=s+` 4028 return (x < 0.0) ? 0.0 : x; 4029`,h=s+` 4030 return (x < 0.0) ? 0.0 : min(6.0, x); 4031`,p="return x;",d="return 1.0 / (1.0 + exp(-1.0 * x));"},77528:(e,t,r)=>{"use strict";r.d(t,{H:()=>m,j:()=>g});var n=r(51520),a=r(90556),s=r(15034),i=r(14811),o=r(97344),l=r(96902),u=r(62041),h=r(82692),p=r(1560),d=r(46096),c=function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&0>t.indexOf(n)&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols)for(var a=0,n=Object.getOwnPropertySymbols(e);a<n.length;a++)0>t.indexOf(n[a])&&Object.prototype.propertyIsEnumerable.call(e,n[a])&&(r[n[a]]=e[n[a]]);return r};class f extends d.VS{constructor(e){if(e.unroll)throw new o.EH("Unrolling is not possible with convolutional RNNs.");if(Array.isArray(e.cell))throw new o.EH("It is not possible at the moment to stack convolutional cells.");super(e),this.inputSpec=[new i.eO({ndim:5})]}call(e,t){return n.DZQ(()=>{if(null!=this.cell.dropoutMask&&(n.ASo(this.cell.dropoutMask),this.cell.dropoutMask=null),null!=this.cell.recurrentDropoutMask&&(n.ASo(this.cell.recurrentDropoutMask),this.cell.recurrentDropoutMask=null),t&&t.constants)throw new o.Qp("ConvRNN2D cell does not support constants");let r=null==t?null:t.mask,a=null==t?null:t.training,s=null==t?null:t.initialState;return super.call(e,{mask:r,training:a,initialState:s})})}computeOutputShape(e){let t=this.computeSingleOutputShape(e);return this.returnSequences||(t=[t[0],...t.slice(2)]),this.returnState&&(t=[t,...[,,].fill([e[0],...t.slice(-3)])]),t}getInitialState(e){return n.DZQ(()=>{let{stateSize:t}=this.cell,r=e.shape,a=this.computeSingleOutputShape(r),s=[a[0],...a.slice(2)],i=n.Ul9(s);return Array.isArray(t)?Array(t.length).fill(i):[i]})}resetStates(e,t=!1){n.DZQ(()=>{if(!this.stateful)throw new o.l7("Cannot call resetStates() on an RNN Layer that is not stateful.");let r=this.inputSpec[0].shape,a=this.computeSingleOutputShape(r),s=[a[0],...a.slice(2)];if(null==r[0])throw new o.Qp("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(null==this.getStates())Array.isArray(this.cell.stateSize)?this.states_=this.cell.stateSize.map(()=>n.Ul9(s)):this.states_=[n.Ul9(s)];else if(null==e)n.ASo(this.states_),null!=this.keptStates&&(n.ASo(this.keptStates),this.keptStates=[]),Array.isArray(this.cell.stateSize)?this.states_=this.cell.stateSize.map(()=>n.Ul9(s)):this.states_[0]=n.Ul9(s);else{if(Array.isArray(e)||(e=[e]),e.length!==this.states_.length)throw new o.Qp(`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()):n.ASo(this.states_);for(let t=0;t<this.states_.length;++t){let r=e[t];if(!n.ZSL.arraysEqual(r.shape,s))throw new o.Qp(`State ${t} is incompatible with layer ${this.name}: expected shape=${s}, received shape=${r.shape}`);this.states_[t]=r}}this.states_=this.states_.map(e=>n.aCs(e.clone()))})}computeSingleOutputShape(e){let{dataFormat:t,filters:r,kernelSize:n,padding:a,strides:s,dilationRate:i}=this.cell,o="channelsFirst"===t,l=e[o?3:2],h=e[o?4:3],p=(0,u.Ol)(l,n[0],a,s[0],i[0]),d=(0,u.Ol)(h,n[1],a,s[1],i[1]);return[...e.slice(0,2),...o?[r,p,d]:[p,d,r]]}}f.className="ConvRNN2D";class m extends d.Tu{constructor(e){let{filters:t,kernelSize:r,strides:n,padding:a,dataFormat:i,dilationRate:o}=e;super(Object.assign(Object.assign({},e),{units:t})),this.filters=t,(0,h.oo)(this.filters,"filters"),this.kernelSize=(0,u.J)(r,2,"kernelSize"),this.kernelSize.forEach(e
4031=>(0,h.oo)(e,"kernelSize")),this.strides=(0,u.J)(n||1,2,"strides"),this.strides.forEach(e=>(0,h.oo)(e,"strides")),this.padding=a||"valid",(0,s.tB)(this.padding),this.dataFormat=i||"channelsLast",(0,s.uM)(this.dataFormat),this.dilationRate=(0,u.J)(o||1,2,"dilationRate"),this.dilationRate.forEach(e=>(0,h.oo)(e,"dilationRate"))}build(e){var t;e=(0,p.U$)(e);let r="channelsFirst"===this.dataFormat?1:e.length-1;if(null==e[r])throw new o.Qp(`The channel dimension of the input should be defined. Found ${e[r]}`);let s=e[r],i=this.kernelSize.concat([s,4*this.filters]);this.kernel=this.addWeight("kernel",i,null,this.kernelInitializer,this.kernelRegularizer,!0,this.kernelConstraint);let u=this.kernelSize.concat([this.filters,4*this.filters]);if(this.recurrentKernel=this.addWeight("recurrent_kernel",u,null,this.recurrentInitializer,this.recurrentRegularizer,!0,this.recurrentConstraint),this.useBias){let e;if(this.unitForgetBias){let r=this.biasInitializer,s=this.filters;e=new((t=class extends l.H4{apply(e,t){let i=r.apply([s]),o=n.SaS([s]),l=r.apply([2*s]);return a.u1([i,o,l])}}).className="CustomInit",t)}else e=this.biasInitializer;this.bias=this.addWeight("bias",[4*this.filters],null,e,this.biasRegularizer,!0,this.biasConstraint)}this.built=!0}call(e,t){return n.DZQ(()=>{if(3!==e.length)throw new o.Qp(`ConvLSTM2DCell expects 3 input Tensors (inputs, h, c), got ${e.length}.`);let r=t.training||!1,a=e[0],s=e[1],i=e[2];0<this.dropout&&this.dropout<1&&null==this.dropoutMask&&(this.dropoutMask=(0,d.FW)({ones:()=>n.P61(a),rate:this.dropout,training:r,count:4,dropoutFunc:this.dropoutFunc}));let l=this.dropoutMask,u=(e,t,r)=>t&&t[r]?n.lKK(t[r],e):e,h=u(a,l,0),p=u(a,l,1),c=u(a,l,2),f=u(a,l,3);0<this.recurrentDropout&&this.recurrentDropout<1&&null==this.recurrentDropoutMask&&(this.recurrentDropoutMask=(0,d.FW)({ones:()=>n.P61(s),rate:this.recurrentDropout,training:r,count:4,dropoutFunc:this.dropoutFunc}));let m=this.recurrentDropoutMask,g=u(s,m,0),y=u(s,m,1),b=u(s,m,2),x=u(s,m,3),[v,w,T,S]=n.lDo(this.kernel.read(),4,3),[N,k,I,C]=this.useBias?n.lDo(this.bias.read(),4):[null,null,null,null];h=this.inputConv(h,v,N,this.padding),p=this.inputConv(p,w,k,this.padding),c=this.inputConv(c,T,I,this.padding),f=this.inputConv(f,S,C,this.padding);let[E,A,$,F]=n.lDo(this.recurrentKernel.read(),4,3);g=this.recurrentConv(g,E),y=this.recurrentConv(y,A),b=this.recurrentConv(b,$),x=this.recurrentConv(x,F);let R=this.recurrentActivation.apply(n.WQq(h,g)),_=this.recurrentActivation.apply(n.WQq(p,y)),D=n.WQq(n.lKK(_,i),n.lKK(R,this.activation.apply(n.WQq(c,b)))),O=n.lKK(this.recurrentActivation.apply(n.WQq(f,x)),this.activation.apply(D));return[O,O,D]})}getConfig(){let e=super.getConfig(),{units:t}=e,r=c(e,["units"]),n={filters:this.filters,kernelSize:this.kernelSize,padding:this.padding,dataFormat:this.dataFormat,dilationRate:this.dilationRate,strides:this.strides};return Object.assign(Object.assign({},r),n)}inputConv(e,t,r,s){let i=n.Xtf(e,t,this.strides,s||"valid","channelsFirst"===this.dataFormat?"NCHW":"NHWC",this.dilationRate);return r?a.ni(i,r,this.dataFormat):i}recurrentConv(e,t){return n.Xtf(e,t,1,"same","channelsFirst"===this.dataFormat?"NCHW":"NHWC")}}m.className="ConvLSTM2DCell",n.JFn.registerClass(m);class g extends f{constructor(e){super(Object.assign(Object.assign({},e),{cell:new m(e)}))}static fromConfig(e,t){return new e(t)}}g.className="ConvLSTM2D",n.JFn.registerClass(g)},77617:(e,t,r)=>{"use strict";r.d(t,{Fq:()=>a,T9:()=>o,jk:()=>i,no:()=>s,y1:()=>l});var n=r(97344);function a(e){return e===parseInt(e.toString(),10)}function s(e,t,r){null==t&&(t=0),null==r&&(r=e.length);let n=1;for(let a=t;a<r;++a)n*=e[a];return n}function i(e){if(0===e.length)return Number.NaN;let t=Number.POSITIVE_INFINITY;for(let r=0;r<e.length;r++){let n=e[r];n<t&&(t=n)}return t}function o(e){if(0===e.length)return Number.NaN;let t=Number.NEGATIVE_INFINITY;for(let r=0;r<e.length;r++){let n=e[r];n>t&&(t=n)}return t}function l(e,t){if(t<e)throw new n.Qp(`end (${t}) < begin (${e}) is forbidden.`);let r=[];for(let n=e;n<t;++n)r.push(n);return r}},78213:(e,t,r)=>{"use strict";r.d(t,{v:()=>u});var n=r(19041),a=r(48592),s=r(76526),i=r(39114),o=r(62176),l=r(68567);let u=(0,o.op)({conv2DBackpropInput_:function(e,t,r,o,u,h="NHWC",p){s.vA(e.length===t.rank,()=>`Length of inShape (${e.length}) and rank of dy (${t.rank}) must match`);let d=e,c=t,f=!1;3===t.rank&&(f=!0,c=(0,l.t)(t,[1,t.shape[0],t.shape[1],t.shape[2]]),d=[1,e[0],e[1],e[2]]),s.vA(4===d.length,()=>
4031`Error in conv2dDerInput: inShape must be length 4, but got length ${d.length}.`),s.vA(4===c.rank,()=>`Error in conv2dDerInput: dy must be rank 4, but got rank ${c.rank}`),s.vA(4===r.rank,()=>`Error in conv2dDerInput: filter must be rank 4, but got rank ${r.rank}`);let m="NHWC"===h?d[3]:d[1],g="NHWC"===h?c.shape[3]:c.shape[1];s.vA(m===r.shape[2],()=>`Error in conv2dDerInput: depth of input (${m}) must match input depth for filter ${r.shape[2]}.`),s.vA(g===r.shape[3],()=>`Error in conv2dDerInput: depth of output (${g}) must match output depth for filter ${r.shape[3]}.`),i.s_("conv2dDerInput",u,p);let y={dy:c,filter:r},b={strides:o,pad:u,dataFormat:h,dimRoundingMode:p,inputShape:d},x=n.T2.runKernel(a.jfg,y,b);return f?(0,l.t)(x,[x.shape[1],x.shape[2],x.shape[3]]):x}})},78647:(e,t,r)=>{"use strict";r.d(t,{K:()=>i});var n=r(51520),a=r(73187),s=r(97344);function i(e){let t={Adagrad:()=>n.BaG.adagrad(.01),Adadelta:()=>n.BaG.adadelta(1,.95,(0,a.Ni)()),Adam:()=>n.BaG.adam(.001,.9,.999,(0,a.Ni)()),Adamax:()=>n.BaG.adamax(.002,.9,.999,(0,a.Ni)(),0),RMSProp:()=>n.BaG.rmsprop(.001,.9,0,(0,a.Ni)()),SGD:()=>n.BaG.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 s.Qp(`Unknown Optimizer ${e}`)}},78736:function(e,t,r){var n;!function(e,a,s){function i(e){var t=this;t.next=function(){var e,r,n=t.w,a=t.X,s=t.i;return t.w=n=n+0x61c88647|0,r=a[s+34&127],e=a[s=s+1&127],r^=r<<13,e^=e<<17,r^=r>>>15,e^=e>>>12,r=a[s]=r^e,t.i=s,r+(n^n>>>16)|0},!function(e,t){var r,n,a,s,i,o=[],l=128;for(t===(0|t)?(n=t,t=null):(t+="\0",n=0,l=Math.max(l,t.length)),a=0,s=-32;s<l;++s)t&&(n^=t.charCodeAt((s+32)%t.length)),0===s&&(i=n),n^=n<<10,n^=n>>>15,n^=n<<4,n^=n>>>13,s>=0&&(i=i+0x61c88647|0,a=0==(r=o[127&s]^=n+i)?a+1:0);for(a>=128&&(o[127&(t&&t.length||0)]=-1),a=127,s=512;s>0;--s)n=o[a+34&127],r=o[a=a+1&127],n^=n<<13,r^=r<<17,n^=n>>>15,r^=r>>>12,o[a]=n^r;e.w=i,e.X=o,e.i=a}(t,e)}function o(e,t){return t.i=e.i,t.w=e.w,t.X=e.X.slice(),t}function l(e,t){null==e&&(e=+new Date);var r=new i(e),n=t&&t.state,a=function(){return(r.next()>>>0)/0x100000000};return a.double=function(){do var e=((r.next()>>>11)+(r.next()>>>0)/0x100000000)/2097152;while(0===e);return e},a.int32=r.next,a.quick=a,n&&(n.X&&o(n,r),a.state=function(){return o(r,{})}),a}a&&a.exports?a.exports=l:r.amdD&&r.amdO?void 0===(n=(function(){return l}).call(t,r,t,a))||(a.exports=n):this.xor4096=l}(0,e=r.nmd(e),r.amdD)},79039:(e,t,r)=>{"use strict";r.d(t,{M:()=>i});var n=r(19041),a=r(48592),s=r(27924);let i=(0,r(62176).op)({isFinite_:function(e){let t=(0,s.YT)(e,"x","isFinite");return n.T2.runKernel(a.gIW,{x:t})}})},79045:(e,t,r)=>{"use strict";r.d(t,{B:()=>u});var n=r(19041),a=r(48592),s=r(50124),i=r(27924),o=r(83231),l=r(16488);let u=(0,r(62176).op)({minimum_:function(e,t){let r=(0,i.YT)(e,"a","minimum"),u=(0,i.YT)(t,"b","minimum");[r,u]=(0,s.makeTypesMatch)(r,u),"bool"===r.dtype&&(r=(0,l.w)(r,"int32"),u=(0,l.w)(u,"int32")),(0,o.assertAndGetBroadcastShape)(r.shape,u.shape);let h={a:r,b:u};return n.T2.runKernel(a.LG0,h)}})},79320:(e,t,r)=>{"use strict";r.d(t,{P:()=>i});var n=r(19041),a=r(48592),s=r(27924);let i=(0,r(62176).op)({zerosLike_:function(e){let t=(0,s.YT)(e,"x","zerosLike");return n.T2.runKernel(a.xJ3,{x:t})}})},79459:(e,t,r)=>{"use strict";r.d(t,{T:()=>i});var n=r(19041),a=r(48592),s=r(27924);let i=(0,r(62176).op)({max_:function(e,t=null,r=!1){let i=(0,s.YT)(e,"x","max");return n.T2.runKernel(a.VAI,{x:i},{reductionIndices:t,keepDims:r})}})},79493:(e,t,r)=>{"use strict";r.d(t,{F:()=>o});var n=r(19041),a=r(48592),s=r(50124),i=r(27924);let o=(0,r(62176).op)({atan2_:function(e,t){let r=(0,i.YT)(e,"a","atan2"),o=(0,i.YT)(t,"b","atan2");[r,o]=(0,s.makeTypesMatch)(r,o);let l={a:r,b:o};return n.T2.runKernel(a.lxb,l)}})},80107:(e,t,r)=>{"use strict";r.d(t,{P:()=>u});var n=r(19041),a=r(48592),s=r(50124),i=r(27924),o=r(83231),l=r(16488);let u=(0,r(62176).op)({maximum_:function(e,t){let r=(0,i.YT)(e,"a","maximum"),u=(0,i.YT)(t,"b","maximum");[r,u]=(0,s.makeTypesMatch)(r,u),"bool"===r.dtype&&(r=(0,l.w)(r,"int32"),u=(0,l.w)(u,"int32")),(0,o.assertAndGetBroadcastShape)(r.shape,u.shape);let h={a:r,b:u};return n.T2.runKernel(a.LDN,h)}})},80116:(e,t,r)=>{"use strict";r.d(t,{P:()=>i});var n=r(19041),a=r(48592),s=r(27924);let i=(0,r(62176).op)({onesLike_:function(e){let t=(0,s.YT)(e,"x","onesLike");return n.T2.runKernel(a.LWX,{x:t})}})},80427:(e,t,r)=>{"use strict";r.d(t,{rq:()=>i,xp:()=>l});var n=r(51520),a=r(16986),s=r(75017);let i=(0,a.Z)((e,t)=>+(e>t)),o=(0,s.j)(n.XhZ,i,null,"bool"),l={kernelName:n.XhZ,backendName:"cpu",kernelFunc:o}},81031:(e,t,r)=>{"use strict";r.d(t,{r:()=>i});var n=r(19041),a=r(48592),s=r(27924);let i=(0,r(62176).op)({topk_:function(e,t=1,r=!0){let i=(0,s.YT)(e,"x","topk");
4031if(0===i.rank)throw Error("topk() expects the input to be of rank 1 or higher");let o=i.shape[i.shape.length-1];if(t<0)throw Error(`'k' passed to topk() must be >= 0 but got ${t}`);if(t>o)throw Error(`'k' passed to topk() must be <= the last dimension (${o}) but got ${t}`);let[l,u]=n.T2.runKernel(a.TBb,{x:i},{k:t,sorted:r});return{values:l,indices:u}}})},81567:(e,t,r)=>{"use strict";r.d(t,{u:()=>u});var n=r(51520),a=r(1560),s=r(14811),i=r(90556);let{resizeBilinear:o,cropAndResize:l}=n.Slp;class u extends s.Wd{constructor(e){super(e),this.height=e.height,this.width=e.width}centerCrop(e,t,r,s,o,u,h,p){return(0,n.DZQ)(()=>{let d,c=!1,f=[t/u,r/h,(s+t)/u,(o+r)/h],m=[];3===e.rank?(c=!0,d=(0,n.t$z)([e])):d=e;for(let e=0;e<d.shape[0];e++)m.push(f);let g=(0,n.OEK)(m,[m.length,4]),y=l(d,g,(0,n.y17)(0,m.length,1,"int32"),[s,o],"nearest");return c?i.wg((0,a.un)((0,n.K$i)(y)),p):i.wg(y,p)})}upsize(e,t,r,a){return(0,n.DZQ)(()=>{let n=o(e,[t,r]);return i.wg(n,a)})}call(e,t){return(0,n.DZQ)(()=>{let t=(0,a.un)(e),r=t.dtype,n=t.shape,s=n[n.length-3],i=n[n.length-2],o=0;s!==this.height&&(o=Math.floor((s-this.height)/2));let l=0;return(i!==this.width&&0===(l=Math.floor((i-this.width)/2))&&(l=1),o>=0&&l>=0)?this.centerCrop(t,o,l,this.height,this.width,s,i,r):this.upsize(e,this.height,this.width,r)})}getConfig(){let e={height:this.height,width:this.width};return Object.assign(e,super.getConfig()),e}computeOutputShape(e){let t=(e=(0,a.U$)(e)).length-3,r=e.length-2;return e[t]=this.height,e[r]=this.width,e}}u.className="CenterCrop",n.JFn.registerClass(u)},81600:(e,t,r)=>{"use strict";r.d(t,{o:()=>a});var n=r(51520);function a(e){return(t,r,a)=>{let s=n.ZSL.getArrayFromDType(r,t.length);for(let r=0;r<t.length;++r)s[r]=e(t[r],a);return s}}},81918:(e,t,r)=>{"use strict";r.d(t,{w:()=>o});var n=r(19041),a=r(48592),s=r(50124),i=r(27924);let o=(0,r(62176).op)({floorDiv_:function(e,t){let r=(0,i.YT)(e,"a","floorDiv"),o=(0,i.YT)(t,"b","floorDiv");[r,o]=(0,s.makeTypesMatch)(r,o);let l={a:r,b:o};return n.T2.runKernel(a.ElG,l)}})},82171:(e,t,r)=>{"use strict";r.d(t,{d:()=>i});var n=r(19041),a=r(48592),s=r(27924);let i=(0,r(62176).op)({slice_:function(e,t,r){let i=(0,s.YT)(e,"x","slice","string_or_numeric");if(0===i.rank)throw Error("Slicing scalar is not possible");return n.T2.runKernel(a.JiE,{x:i},{begin:t,size:r})}})},82198:(e,t,r)=>{"use strict";r.d(t,{_:()=>l});var n=r(19041),a=r(48592),s=r(27924),i=r(43182),o=r(83231);let l=(0,r(62176).op)({where_:function(e,t,r){let l=(0,s.YT)(t,"a","where"),u=(0,s.YT)(r,"b","where"),h=(0,s.YT)(e,"condition","where","bool"),p=(0,o.assertAndGetBroadcastShape)((0,o.assertAndGetBroadcastShape)(h.shape,l.shape),u.shape),d=(0,i.h)(h,p),c=(0,i.h)(l,p),f=(0,i.h)(u,p);return n.T2.runKernel(a.l6P,{condition:d,t:c,e:f})}})},82492:(e,t,r)=>{"use strict";r.d(t,{Bu:()=>S,b_:()=>k,rF:()=>y});var n=r(51520),a=r(90556),s=r(82692);class i extends n.JFn.Serializable{getConfig(){return{}}}class o extends i{apply(e,t=1){return a.Pq(e,t)}}o.className="elu",n.JFn.registerClass(o);class l extends i{apply(e){return n.WfX(e)}}l.className="selu",n.JFn.registerClass(l);class u extends i{apply(e){return n.VVh(e)}}u.className="relu",n.JFn.registerClass(u);class h extends i{apply(e){return(0,n.DZQ)(()=>n.BpO(6,n.VVh(e)))}}h.className="relu6",n.JFn.registerClass(h);class p extends i{apply(e){return e}}p.className="linear",n.JFn.registerClass(p);class d extends i{apply(e){return n.ry7(e)}}d.className="sigmoid",n.JFn.registerClass(d);class c extends i{apply(e){return a.KK(e)}}c.className="hardSigmoid",n.JFn.registerClass(c);class f extends i{apply(e){return n.lw0(e)}}f.className="softplus",n.JFn.registerClass(f);class m extends i{apply(e){return a.aY(e)}}m.className="softsign",n.JFn.registerClass(m);class g extends i{apply(e){return n.ymU(e)}}g.className="tanh",n.JFn.registerClass(g);class y extends i{apply(e,t=-1){return n.Vs9(e,t)}}y.className="softmax",n.JFn.registerClass(y);class b extends i{apply(e,t=-1){return n.HPB(e,t)}}b.className="logSoftmax",n.JFn.registerClass(b);class x extends i{apply(e){return(0,n.DZQ)(()=>n.DZQ(()=>{let t=Math.sqrt(2),r=n.lKK(.5,n.WQq(1,n.Y12(n.y4m(e,t))));return n.lKK(e,r)}))}}x.className="gelu",n.JFn.registerClass(x);class v extends i{apply(e){return(0,n.DZQ)(()=>n.lKK(.5,n.lKK(e,n.WQq(1,n.ymU(n.lKK(n.RZD(n.y4m(2,Math.PI)),n.WQq(e,n.lKK(.044715,n.n7C(e,3)))))))))}}v.className="gelu_new",n.JFn.registerClass(v);class w extends i{apply(e){return(0,n.DZQ)(()=>
4031n.lKK(e,n.ymU(n.lw0(e))))}}w.className="mish",n.JFn.registerClass(w);class T extends i{apply(e,t=1){return(0,n.DZQ)(()=>n.lKK(n.ry7(n.lKK(e,t)),e))}}function S(e){return e.getClassName()}function N(e,t={}){return(0,s.Xv)(e,n.JFn.SerializationMap.getMap().classNameMap,t,"activation")}function k(e){if(null==e){let e={};return e.className="linear",e.config={},N(e)}if("string"==typeof e){let t={};return t.className=e,t.config={},N(t)}return e instanceof i?e:N(e)}T.className="swish",n.JFn.registerClass(T)},82692:(e,t,r)=>{"use strict";r.d(t,{Am:()=>g,Cb:()=>p,Cd:()=>w,E6:()=>b,HP:()=>x,U9:()=>o,Xv:()=>f,ZF:()=>y,fD:()=>s,k4:()=>c,oo:()=>function e(t,r){Array.isArray(t)?(n.ZSL.assert(t.length>0,()=>`${r} is unexpectedly an empty array.`),t.forEach((t,n)=>e(t,`element ${n+1} of ${r}`))):n.ZSL.assert(Number.isInteger(t)&&t>0,()=>`Expected ${r} to be a positive integer, but got ${function e(t){return null===t?"null":Array.isArray(t)?"["+t.map(t=>e(t)).join(",")+"]":"string"==typeof t?`"${t}"`:`${t}`}(t)}.`)},sg:()=>v,st:()=>u,th:()=>m,uc:()=>h,vA:()=>i,wL:()=>l});var n=r(51520),a=r(97344);function s(e,t){if(Array.isArray(e)){let r=[];for(let n=0;n<t;n++)r=r.concat(e);return r}{let r=Array(t);return r.fill(e),r}}function i(e,t){if(!e)throw new a.pf(t)}function o(e,t){let r=0;for(let n of e)n===t&&r++;return r}function l(e){return 1===e.length?e[0]:e}function u(e){return Array.isArray(e)?e:[e]}function h(e){let t=e.replace(/(.)([A-Z][a-z0-9]+)/g,"$1_$2").replace(/([a-z])([A-Z])/g,"$1_$2").toLowerCase();return"_"!==t[0]?t:"private"+t}function p(e){return e.length<=1||-1===e.indexOf("_")?e:e.replace(/[_]+(\w|$)/g,(e,t)=>t.toUpperCase())}let d={};function c(e){if(null==e)return null;let t={};return t.className=e.getClassName(),t.config=e.getConfig(),t}function f(e,t={},r={},n="object",s=!1){if("string"==typeof e){let s;if(e in r)s=r[e];else if(e in d)s=d[e];else if(null==(s=t[e]))throw new a.Qp(`Unknown ${n}: ${e}. This may be due to one of the following reasons: 40321. The ${n} is defined in Python, in which case it needs to be ported to TensorFlow.js or your JavaScript code. 40332. The custom ${n} is defined in JavaScript, but is not registered properly with tf.serialization.registerClass().`);return s}{let i,o;if(null==e.className||null==e.config)throw new a.Qp(`${n}: Improper config format: ${JSON.stringify(e)}. 4034'className' and 'config' must set.`);let l=e.className;if(l in r?[i,o]=r[l]:l in d?[i,o]=d.className:l in t&&([i,o]=t[l]),null==i)throw new a.Qp(`Unknown ${n}: ${l}. This may be due to one of the following reasons: 40351. The ${n} is defined in Python, in which case it needs to be ported to TensorFlow.js or your JavaScript code. 40362. The custom ${n} is defined in JavaScript, but is not registered properly with tf.serialization.registerClass().`);if(null!=o){let t={};for(let e of Object.keys(d))t[e]=d[e];for(let e of Object.keys(r))t[e]=r[e];e.config.customObjects=t;let n=Object.assign({},d);for(let e of Object.keys(r))d[e]=r[e];!function e(t){if(null!=t&&"object"==typeof t)if(Array.isArray(t))t.forEach(t=>e(t));else for(let r of Object.keys(t)){let n=t[r];null!=n&&"object"==typeof n&&(Array.isArray(n)||"ndarray"!==n.type||"number"!=typeof n.value?e(n):t[r]=n.value)}}(e.config);let a=o(i,e.config,r,s);return d=Object.assign({},n),a}{let t=Object.assign({},d);for(let e of Object.keys(r))d[e]=r[e];let n=new i(e.config);return d=Object.assign({},t),n}}}function m(e,t){return -1*(e<t?-1:+(e>t))}function g(e){if(null==e)return e;let t=[];for(let r of e)-1===t.indexOf(r)&&t.push(r);return t}function y(e){if(null==e)throw new a.Qp(`Invalid value in obj: ${JSON.stringify(e)}`);for(let t in e)if(e.hasOwnProperty(t))return!1;return!0}function b(e,t,r){if(null!=r&&0>e.indexOf(r))throw new a.Qp(`${r} is not a valid ${t}. Valid values are ${e} or null/undefined.`)}function x(e,t,r=0,n=1/0){return i(r>=0),i(n>=r),Array.isArray(e)&&e.length>=r&&e.length<=n&&e.every(e=>typeof e===t)}function v(e,t,r){let a,s=null!=r?r():n.ZSL.now();return(...i)=>{let o=null!=r?r():n.ZSL.now();return o-s<t?a:(s=o,a=e(...i))}}function w(e){return"relu"===e?"relu":"linear"===e?"linear":"elu"===e?"elu":null}},82859:(e,t,r)=>{"use strict";r.d(t,{G2:()=>u,Od:()=>l,TN:()=>i,UG:()=>a,WA:()=>s,fM:()=>o});var n=r(51520);function a(e,t,r="index"){let s=n.ZSL.computeStrides(t);return s.map((t,n)=>{let a=`int ${e[n]} = ${r} / ${t}`,i=n===s.length-1?`int ${e[n+1]} = ${r} - ${e[n]} * ${t}`:`index -= ${e[n]} * ${t}`;return`${a}; ${i};`}).join("")}function s(e,t,r="index"){let a=n.ZSL.computeStrides(t);return a.map((t,n)=>{let s=`int ${e[n]} = ${r} / outShapeStrides[${n}]`,i=n===a.length-1?`int ${e[n+1]} = ${r} - ${e[n]} * outShapeStrides[${n}]`:`index -= ${e[n]} * outShapeStrides[${n}]`;return`${s}; ${i};`}).join("")}function i(e,t,r="index"){let n=function(e,t){let r=e.length,n=e.map(e=>`${t}[${e}]`),a=Array(r-1);a[r-2]=n[r-1];for(let e=r-3;e>=0;--e)a[e]=`(${a[e+1]} * ${n[e+1]})`;return a}(e.map((e,t)=>t),t);return n.map((t,a)=>{let s=`int ${e[a]} = ${r} / ${n[a]}`,i=a===n.length-1?`int ${e[a+1]} = ${r} - ${e[a]} * ${n[a]}`:`index -= ${e[a]} * ${n[a]}`;return`${s}; ${i};`}).join("")}function o(e){let t=n.ZSL.computeStrides(e).map(e=>e.toString());return` 4037 int getFlatIndex(ivec3 coords) { 4038 return coords.x * ${t[0]} + coords.y * ${t[1]} + coords.z; 4039 } 4040`}function l(){return` 4041 int getFlatIndex(ivec3 coords) { 4042 return coords.x * outShapeStrides[0] + coords.y * outShapeStrides[1] + coords.z; 4043 } 4044`}let u=` 4045 const float FLOAT_MAX = 1.70141184e38; 4046 const float FLOAT_MIN = 1.17549435e-38; 4047 4048 lowp vec4 encode_float(highp float v) { 4049 if (isnan(v)) { 4050 return vec4(255, 255, 255, 255); 4051 } 4052 4053 highp float av = abs(v); 4054 4055 if(av < FLOAT_MIN) { 4056 return vec4(0.0, 0.0, 0.0, 0.0); 4057 } else if(v > FLOAT_MAX) { 4058 return vec4(0.0, 0.0, 128.0, 127.0) / 255.0; 4059 } else if(v < -FLOAT_MAX) { 4060 return vec4(0.0, 0.0, 128.0, 255.0) / 255.0; 4061 } 4062 4063 highp vec4 c = vec4(0,0,0,0); 4064 4065 highp float e = floor(log2(av)); 4066 highp float m = exp2(fract(log2(av))) - 1.0; 4067 4068 c[2] = floor(128.0 * m); 4069 m -= c[2] / 128.0; 4070 c[1] = floor(32768.0 * m); 4071 m -= c[1] / 32768.0; 4072 c[0] = floor(8388608.0 * m); 4073 4074 highp float ebias = e + 127.0; 4075 c[3] = floor(ebias / 2.0); 4076 ebias -= c[3] * 2.0; 4077 c[2] += floor(ebias) * 128.0; 4078 4079 c[3] += 128.0 * step(0.0, -v); 4080 4081 return c / 255.0; 4082 } 4083`},83152:(e,t,r)=>{"use strict";r.d(t,{N:()=>i});var n=r(19041),a=r(48592),s=r(27924);let i=(0,r(62176).op)({logicalNot_:function(e){let t=(0,s.YT)(e,"x","logicalNot","bool");return n.T2.runKernel(a.nZd,{x:t})}})},83231:(e,t,r)=>{"use strict";function n(e,t){let r=e.length,n=[];for(let a=0;a<r;a++){let s=r-1-a,i=e[s]||1;(t[t.length-1-a]||1)>1&&1===i&&n.unshift(s)}return n}function a(e,t){let r=[];for(let n=0;n<t.length;n++){let a=e[e.length-n-1],s=t.length-n-1,i=t[s];(null==a||1===a&&i>1)&&r.unshift(s)}return r}function s(e,t){let r=Math.max(e.length,t.length),n=Array(r);for(let a=0;a<r;a++){let s=e[e.length-a-1];null==s&&(s=1);let i=t[t.length-a-1];if(null==i&&(i=1),1===s)n[r-a-1]=i;else if(1===i)n[r-a-1]=s;else if(s!==i)throw Error(`Operands could not be broadcast together with shapes ${e} and ${t}.`);else n[r-a-1]=s}return n}r.r(t),r.d(t,{assertAndGetBroadcastShape:()=>s,getBroadcastDims:()=>n,getReductionAxes:()=>a})},83234:(e,t,r)=>{"use strict";r.d(t,{i:()=>s});var n=r(51520),a=r(82692);function s(e,t={},r=!1){return(0,a.Xv)(e,n.JFn.SerializationMap.getMap().classNameMap,t,"layer",r)}},83635:(e,t,r)=>{"use strict";r.d(t,{V:()=>i});var n=r(19041),a=r(48592),s=r(27924);let i=(0,r(62176).op)({softmax_:function(e,t=-1){let r=(0,s.YT)(e,"logits","softmax","float32");if(-1===t&&(t=r.rank-1),t!==r.rank-1)throw Error(`Softmax along a non-last dimension is not yet supported. Logits was rank ${r.rank} and dim was ${t}`);let i={dim:t};return n.T2.runKernel(a.rFG,{logits:r},i)}})},83641:(e,t,r)=>{"use strict";r.d(t,{r:()=>i});var n=r(19041),a=r(48592),s=r(27924);let i=(0,r(62176).op)({cumsum_:function(e,t=0,r=!1,i=!1){let o=(0,s.YT)(e,"x","cumsum");return n.T2.runKernel(a.nY8,{x:o},{axis:t,exclusive:r,reverse:i}
4083)}})},83881:(e,t,r)=>{"use strict";r.d(t,{S:()=>o});var n=r(67108),a=r(71553),s=r(82859),i=r(60217);class o{constructor(e){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outPackingScheme=i.BB.DENSE,this.customUniforms=[{name:"texShape",type:"ivec2"}];let t=(0,n.B)();this.outputShape=e,this.enableShapeUniforms=(0,a.ik)(this.outputShape.length),this.userCode=` 4084 ivec3 outCoordsFromFlatIndex(int index) { 4085 ${this.enableShapeUniforms?s.WA(["r","c","d"],e):s.UG(["r","c","d"],e)} 4086 return ivec3(r, c, d); 4087 } 4088 4089 void main() { 4090 ivec2 resTexRC = ivec2(resultUV.yx * vec2(texShape[0], texShape[1])); 4091 int index = 4 * (resTexRC.x * texShape[1] + resTexRC.y); 4092 4093 vec4 result = vec4(0.); 4094 4095 for (int i=0; i<4; i++) { 4096 int flatIndex = index + i; 4097 ivec3 rc = outCoordsFromFlatIndex(flatIndex); 4098 result[i] = getChannel(getA(rc.x, rc.y, rc.z), vec2(rc.y, rc.z)); 4099 } 4100 4101 ${t.output} = result; 4102 } 4103 `}}},84466:(e,t,r)=>{"use strict";r.d(t,{h:()=>a});var n=r(51520);function a(e,t,r,a){let s=n.ZSL.getArrayFromDType(r,n.ZSL.sizeFromShape(t));if(a&&"string"!==r){let t=0;e.forEach(e=>{let r=n.ZSL.sizeFromShape(e.shape);s.set(e.vals,t),t+=r})}else{let a=0;e.forEach(e=>{let i="string"===r?n.C0T.fromUint8ToStringArray(e.vals):e.vals,o=0;for(let r=0;r<e.shape[0];++r){let n=r*t[1]+a;for(let t=0;t<e.shape[1];++t)s[n+t]=i[o++]}a+=e.shape[1]})}return s}},84613:(e,t,r)=>{"use strict";r.d(t,{r:()=>n});let n="4.22.0"},85205:(e,t,r)=>{"use strict";r.d(t,{Fu:()=>l,x6:()=>i});var n=r(51520),a=r(81600),s=r(87095);let i=(0,a.o)(e=>Math.sqrt(e)),o=(0,s.v)(n.dFH,e=>Math.sqrt(e)),l={kernelName:n.dFH,backendName:"cpu",kernelFunc:o}},85692:(e,t,r)=>{"use strict";r.d(t,{I:()=>i});var n=r(19041),a=r(48592),s=r(27924);let i=(0,r(62176).op)({expm1_:function(e){let t=(0,s.YT)(e,"x","expm1");return n.T2.runKernel(a.ybj,{x:t})}})},86070:(e,t,r)=>{"use strict";r.d(t,{C1:()=>i,Uc:()=>l});var n=r(51520),a=r(16986),s=r(75017);let i=(0,a.Z)((e,t)=>Math.floor(e/t)),o=(0,s.j)(n.ElG,i,null,"int32"),l={kernelName:n.ElG,backendName:"cpu",kernelFunc:o}},86177:(e,t,r)=>{"use strict";r.d(t,{VM:()=>l,lg:()=>i});var n=r(51520),a=r(16986),s=r(75017);let i=(0,a.Z)((e,t)=>+(e>=t)),o=(0,s.j)(n.lLS,i,null,"bool"),l={kernelName:n.lLS,backendName:"cpu",kernelFunc:o}},86405:(e,t,r)=>{"use strict";r.d(t,{K:()=>i});var n=r(19041),a=r(48592),s=r(76526);let i=(0,r(62176).op)({ifft_:function(e){return(0,s.vA)("complex64"===e.dtype,()=>`The dtype for tf.spectral.ifft() must be complex64 but got ${e.dtype}.`),n.T2.runKernel(a.OAQ,{input:e})}})},86562:(e,t,r)=>{"use strict";r.d(t,{UK:()=>u,WQ:()=>l,mx:()=>i});var n=r(51520),a=r(16986),s=r(75017);let i=(0,a.Z)((e,t)=>e+t),o=(0,s.B)((e,t,r,n)=>({real:e+r,imag:t+n})),l=(0,s.j)(n.OMN,i,o),u={kernelName:n.OMN,backendName:"cpu",kernelFunc:l}},86632:(e,t,r)=>{"use strict";r.d(t,{N:()=>i});var n=r(67108),a=r(82859),s=r(60217);class i{constructor(e){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!1,this.outTexUsage=s.tT.DOWNLOAD;let t=(0,n.B)();this.outputShape=e,this.userCode=` 4104 ${a.G2} 4105 4106 void main() { 4107 ivec3 coords = getOutputCoords(); 4108 float x = getChannel(getAAtOutCoords(), vec2(coords.y, coords.z)); 4109 ${t.output} = encode_float(x); 4110 } 4111 `}}},86694:(e,t,r)=>{"use strict";r.d(t,{F:()=>o});var n=r(19041),a=r(48592),s=r(27924),i=r(76526);let o=(0,r(62176).op)({mirrorPad_:function(e,t,r){i.vA("reflect"===r||"symmetric"===r,()=>`Invalid mode. Mode must be either reflect or symmetric. Got ${r}.`);let o=(0,s.YT)(e,"x","mirrorPad");if(0===o.rank)throw Error("mirrorPad(scalar) is not defined. Pass non-scalar to mirrorPad");i.vA(t.length===o.rank,()=>`Padding doesn't match input. Must be ${o.rank}. Got ${t.length}.`);let l=+("reflect"===r);for(let e=0;e<o.rank;e++)i.vA(2===t[e].length,()=>"Invalid number of paddings. Must be length of 2 each."),i.vA(t[e][0]>=0&&t[e][0]<=o.shape[e]-l&&t[e][1]>=0&&t[e][1]<=o.shape[e]-l,()=>`Padding in dimension ${e} cannot be greater than or equal to ${o.shape[e]-l} or less than 0 for input of shape ${o.shape}`);return n.T2.runKernel(a.x7F,{x:o},{paddings:t,mode:r})}})},87095:(e,t,r)=>{"use strict";r.d(t,{F:()=>o,v:()=>i});var n=r(51520),a=r(49575),s=r(81600);function i(e,t,r){return o(e,(0,s.o)(t),r)}function o(e,t,r){return({inputs:s,attrs:i,backend:o})=>{let l,{x:u}=s;(0,a.C)(u,e);let h=o.data.get(u.dataId).values;if("string"===u.dtype){if(!Array.isArray(h))throw Error("String tensor's value was not an instance of Array");l=n.C0T.fromUint8ToStringArray(h)}else l=h;let p=r||u.dtype,d=t(l,p,i);return o.makeTensorInfo(u.shape,p,d)}}},88185:(e,t,r)=>{"use strict";function n(e){let{inputs:t,backend:r}=e,{x:n}=t;return r.incRef(n.dataId),{dataId:n.dataId,shape:n.shape,dtype:n.dtype}}r.d(t,{D:()=>n,F:()=>a});let a={kernelName:r(51520).lzr,backendName:"cpu",kernelFunc:n}},88527:(e,t,r)=>{"use strict";r.d(t,{x:()=>l});var n=r(19041),a=r(48592),s=r(27924),i=r(76526),o=r(26004);let l=(0,r(62176).op)({concat_:function(e,t=0){(0,i.vA)(e.length>=1,()=>"Pass at least one tensor to concat");let r=(0,s.j1)(e,"tensors","concat","string_or_numeric");
4111return("complex64"===r[0].dtype&&r.forEach(e=>{if("complex64"!==e.dtype)throw Error(`Cannot concatenate complex64 tensors with a tensor 4112 with dtype ${e.dtype}. `)}),1===r.length)?(0,o.o)(r[0]):n.T2.runKernel(a.$dB,r,{axis:t})}})},88547:(e,t,r)=>{"use strict";r.d(t,{Dk:()=>i,hd:()=>o});var n=r(51520),a=r(49575),s=r(20895);function i(e,t,r){let a=n.ZSL.createScalarValue(-1,r);return(0,s.BF)([],t,a,e,r)}let o={kernelName:n.l0G,backendName:"cpu",kernelFunc:function(e){let{inputs:t,backend:r}=e,{x:n}=t;(0,a.C)(n,"neg");let[s,o]=i(r.data.get(n.dataId).values,n.shape,n.dtype);return r.makeTensorInfo(o,n.dtype,s)}}},89215:(e,t,r)=>{"use strict";r.d(t,{Km:()=>l,OH:()=>s,_K:()=>o,tj:()=>u});var n=r(76526);let a="tfjsflags";class s{constructor(e){this.global=e,this.flags={},this.flagRegistry={},this.urlFlags={},this.getQueryParams=i,this.populateURLFlags()}setPlatform(e,t){null==this.platform||l.getBool("IS_TEST")||l.getBool("PROD")||console.warn(`Platform ${this.platformName} has already been set. Overwriting the platform with ${e}.`),this.platformName=e,this.platform=t}registerFlag(e,t,r){if(this.flagRegistry[e]={evaluationFn:t,setHook:r},null!=this.urlFlags[e]){let t=this.urlFlags[e];l.getBool("IS_TEST")||l.getBool("PROD")||console.warn(`Setting feature override from URL ${e}: ${t}.`),this.set(e,t)}}async getAsync(e){return e in this.flags||(this.flags[e]=await this.evaluateFlag(e)),this.flags[e]}get(e){if(e in this.flags)return this.flags[e];let t=this.evaluateFlag(e);if((0,n.yL)(t))throw 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)}getString(e){return this.get(e)}getFlags(){return this.flags}get features(){return this.flags}set(e,t){if(null==this.flagRegistry[e])throw Error(`Cannot set flag ${e} as it has not been registered.`);this.flags[e]=t,null!=this.flagRegistry[e].setHook&&this.flagRegistry[e].setHook(t)}evaluateFlag(e){if(null==this.flagRegistry[e])throw Error(`Cannot evaluate flag '${e}': no evaluation function found.`);return this.flagRegistry[e].evaluationFn()}setFlags(e){this.flags=Object.assign({},e)}reset(){this.flags={},this.urlFlags={},this.populateURLFlags()}populateURLFlags(){if(void 0===this.global||void 0===this.global.location||void 0===this.global.location.search)return;let e=this.getQueryParams(this.global.location.search);a in e&&e[a].split(",").forEach(e=>{let[t,r]=e.split(":");this.urlFlags[t]=function(e,t){let r=t.toLowerCase();return"true"===r||"false"===r?"true"===r:`${+r}`===r?+r:t}(0,r)})}}function i(e){let t={};return e.replace(/[?&]([^=?&]+)(?:=([^&]*))?/g,(e,...r)=>{var n,a,s;return n=t,a=r[0],s=r[1],n[decodeURIComponent(a)]=decodeURIComponent(s||""),r.join("=")}),t}function o(){return l}let l=null;function u(e){l=e}},90300:(e,t,r)=>{"use strict";r.d(t,{y:()=>i});var n=r(19041),a=r(48592),s=r(27924);let i=(0,r(62176).op)({asinh_:function(e){let t=(0,s.YT)(e,"x","asinh");return n.T2.runKernel(a.epO,{x:t})}})},90534:(e,t,r)=>{"use strict";r.d(t,{j:()=>a});var n=r(51520);function a(e,t,r,a){let s=n.ZSL.getTypedArrayFromDType(a,n.ZSL.sizeFromShape(r));for(let r=0;r<s.length;++r){let n=r*t,a=e[n];for(let r=0;r<t;++r){let t=e[n+r];(Number.isNaN(t)||t>a)&&(a=t)}s[r]=a}return s}},90556:(e,t,r)=>{"use strict";r.d(t,{Bq:()=>p,Dh:()=>c,EZ:()=>C,Ew:()=>T,FE:()=>x,KK:()=>E,Ls:()=>A,Om:()=>v,PS:()=>d,Pq:()=>k,UG:()=>u,Vs:()=>b,aY:()=>I,kg:()=>w,ly:()=>y,ni:()=>N,r0:()=>m,u1:()=>g,ux:()=>h,wg:()=>l});var n=r(51520),a=r(15034),s=r(97344),i=r(77617),o=r(73187);function l(e,t){return n.wgE(e,t)}function u(e,t=-1){let r=e.shape.slice();return t<0&&(t=r.length+t+1),r.splice(t,0,1),n.tQQ(e,r)}function h(e,t){return(0,n.DZQ)(()=>{if(2!==e.shape.length)throw new s.Qp(`repeat() expects a rank-2 tensor, but received a rank-${e.shape.length} tensor.`);return b(u(e,1),[1,t,1])})}function p(e){let t=[i.no(e.shape)];return n.tQQ(e,t)}function d(e){if(e.rank<=1)throw new s.Qp(`batchFlatten requires a minimum rank of 2. Got rank: ${e.rank}.`);let t=[e.shape[0],i.no(e.shape,1)];return n.tQQ(e,t)}function c(e,t,r){return(0,n.DZQ)(()=>{switch(e.rank){case 1:return n.Q$M(e,t,r);case 2:return n.zAd(e,[t,0],[r,e.shape[1]]);case 3:return n.wck(e,[t,0,0],[r,e.shape[1],e.shape[2]]);case 4:return n.R0O(e,[t,0,0,0],[r,e.shape[1],e.shape[2],e.shape[3]]);case 5:return n.dik(e,[t,0,0,0,0],[r,e.shape[1],e.shape[2],e.shape[3],e.shape[4]]);case 6:return n.dik(e,[t,0,0,0,0,0],[r,e.shape[1],e.shape[2],e.shape[3],e.shape[4],e.shape[5]]);default:throw new s.Qp(`sliceAlongFirstAxis() received an unsupported tensor rank: ${e.rank}`)}})}function f(e,t,r){return(0,n.DZQ)(()=>{switch(e.rank){case 1:return n.Q$M(e,t,r);case 2:return n.zAd(e,[0,t],[e.shape[0],r]);case 3:return n.wck(e,[0,0,t],[e.shape[0],e.shape[1],r]);case 4:return n.R0O(e,[0,0,0,t],[e.shape[0],e.shape[1],e.shape[2],r]);default:throw new s.Qp(`sliceAlongLastAxis() received an unsupported tensor rank: ${e.rank}`)}})}function m(e,t,r,a){return(0,n.DZQ)(()=>{switch(e.rank){case 1:return n.Q$M(e,t,r);case 2:switch(a){case 1:return c(e,t,r);case 2:return f(e,t,r);default:throw new s.Qp(`The axis is not within the rank of the tensor ${a}`)}case 3:switch(a){case 1:return c(e,t,r);case 2:return n.wck(e,[0,t,0],[e.shape[0],r,e.shape[2]]);case 3:return f(e,t,r);default:throw new s.Qp(`The axis is not within the rank of the tensor ${a}`)}case 4:switch(a){case 1:return c(e,t,r);case 2:return n.R0O(e,[0,t,0,0],[e.shape[0],r,e.shape[2],e.shape[3]]);case 3:return n.R0O(e,[0,0,t,0],[e.shape[0],e.shape[1],r,e.shape[3]]);case 4:return f(e,t,r);default:throw new s.Qp(`The axis is not within the rank of the tensor ${a}`)}default:throw new s.Qp(`sliceAlongLastAxis() received an unsupported tensor rank: ${e.rank}`)}})}function g(e,t=-1){let r;return t<0&&(t=0!==(r=e[0].rank)?r:0),t===e[0].rank&&(t=-1),n.xWs(e,t)}function y(e,t){switch(e.rank){case 1:return n.I1m([e,t]);case 2:return n.RPU([e,t],0);case 3:return n.O5O([e,t],0);case 4:return n.P1l([e,t],0);default:throw new s.Qp(`concatAlongFirstAxis() received an unsupported tensor rank: ${e.rank}`)}}function b(e,t){if(Array.isArray(t)||(t=[t]),e.rank!==t.length)throw new s.Qp(`The length of input n (${t.length}) does not match the number of dimensions in input x (${e.rank})`);return n.Vsq(e,t)}function x(e,t=0,r=1,a,s){return n.FE$(e,t,r,a,s)}function v(e,t,r,a){if(e.rank<2||t.rank<2)throw new s.EH(`dot requires both inputs to be rank >= 2 but got x shape = ${e.shape} and y shape = ${t.shape}`);if(t.rank>=3&&e.shape.slice(-1)[0]!==t.shape.slice(-2)[0])throw new s.EH(`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(2===e.rank&&2===t.rank)return n.cZk.matMul({a:e,b:t,transposeA:!1,transposeB:!1,bias:a?S(e.rank,a,(0,o.VI)()):null,activation:r});{let s=e.shape.slice(),i=s.pop();e=n.tQQ(e,[-1,i]);let l=t.shape.slice(),u=l.pop(),h=l.pop(),p=[...l,u],d=Array.from({length:t.rank},(e,r)=>0===r?t.rank-2:r<=t.rank-2?r-1:r);t=n.tQQ(n.mgz(t,d),[h,-1]);let c=[...s,...p];return n.tQQ(n.cZk.matMul({a:e,b:t,transposeA:!1,transposeB:!1,bias:a?S(e.rank,a,(0,o.VI)()):null,activation:r}),c)}}function w(e,t,r){return(0,n.DZQ)(()=>(t=Array.isArray(t)?(0,n.tGX)(t,"int32"):n.wgE(t,"int32"),n.kgh(e,t,r)))}function T(e){return n.lKK(e,e)}function S(e,t,r){let a=t.shape;if(1!==t.rank&&t.rank!==e)throw new s.Qp(`Unexpected bias dimensions: ${t.rank}; expected it to be 1 or ${e}`);if(5===e){if("channelsFirst"===r)if(1===a.length)return n.tQQ(t,[1,a[0],1,1,1]);else return n.tQQ(t,[1,a[3],a[0],a[1],a[2]]);else if("channelsLast"===r)if(1===a.length)return n.tQQ(t,[1,1,1,1,a[0]]);else return n.tQQ(t,[1].concat(a))}else if(4===e){if("channelsFirst"===r)if(1===a.length)return n.tQQ(t,[1,a[0],1,1]);else return n.tQQ(t,[1,a[2],a[0],a[1]]);else if("channelsLast"===r)if(1===a.length)return n.tQQ(t,[1,1,1,a[0]]);else return n.tQQ(t,[1].concat(a))}else if(3===e){if("channelsFirst"===r)if(1===a.length)return n.tQQ(t,[1,a[0],1]);else return n.tQQ(t,[1,a[1],a[0]]);else if("channelsLast"===r)if(1===a.length)return n.tQQ(t,[1,1,a[0]]);else return n.tQQ(t,[1].concat(a))}else if(e<3)return t;throw new s.Qp(`Unsupported input rank by biasAdd: ${t.rank}`)}function N(e,t,r){return(0,n.DZQ)(()=>(null==r&&(r=(0,o.VI)()),(0,a.uM)(r),n.WQq(e,S(e.rank,t,r))))}function k(e,t=1){if(1!==t)throw new s.EH(`Support for alpha values other than 1 (${t}) is not implemented yet.`);return n.Pqc(e)}function I(e){return(0,n.DZQ)(()=>n.y4m(e,n.WQq(n.tnl(e),1)))}function C(e,t,r,a){return(0,n.DZQ)(()=>n.EZY(e,t,r,a))}function E(e){return(0,n.DZQ)(()=>{let t=n.WQq(.5,n.lKK(.2,e));return n.zQh(t,0,1)})}function A(e,t,r=!1){return r?e():t()}},90715:(e,t,r)=>{"use strict";r.d(t,{X:()=>h});var n=r(19041),a=r(48592),s=r(27924),i=r(76526),o=r(39114),l=r(62176),u=r(68567);let h=(0,l.op)({conv2d_:function(e,t,r,l,h="NHWC",p=[1,1],d){let c=(0,s.YT)(e,"x","conv2d","float32"),f=(0,s.YT)(t,"filter","conv2d","float32"),m=c,g=!1;3===c.rank&&(g=!0,m=(0,u.t)(c,[1,c.shape[0],c.shape[1],c.shape[2]])),i.vA(4===m.rank,()=>`Error in conv2d: input must be rank 4, but got rank ${m.rank}.`),i.vA(4===f.rank,()=>`Error in conv2d: filter must be rank 4, but got rank ${f.rank}.`),o.s_("conv2d",l,d);let y="NHWC"===h?m.shape[3]:m.shape[1];i.vA(y===f.shape[2],()=>`Error in conv2d: depth of input (${y}) must match input depth for filter ${f.shape[2]}.`),i.vA(o.G0(r,p),()=>`Error in conv2D: Either strides or dilations must be 1. Got strides ${r} and dilations '${p}'`),i.vA(o.qk(p),()=>"Error in conv2D: Dilated rates should be larger than 0."),i.vA(o.qk(r),()=>"Error in conv2D: Strides should be larger than 0.");let b={x:m,filter:f},x=n.T2.runKernel(a.p2J,b,{strides:r,pad:l,dataFormat:h,dilations:p,dimRoundingMode:d});return g?(0,u.t)(x,[x.shape[1],x.shape[2],x.shape[3]]):x}})},90855:(e,t,r)=>{"use strict";r.d(t,{l:()=>o});var n=r(19041),a=r(48592),s=r(62176),i=r(68567);let o=(0,s.op)({depthwiseConv2dNativeBackpropInput_:function(e,t,r,s,o,l=[1,1],u){let h=t,p=!1;3===t.rank&&(p=!0,h=(0,i.t)(t,[1,t.shape[0],t.shape[1],t.shape[2]]));let d={dy:h,filter:r},c=n.T2.runKernel(a.nVu,d,{strides:s,pad:o,dimRoundingMode:u,dilations:l,inputShape:e});return p?(0,i.t)(c,[c.shape[1],c.shape[2],c.shape[3]]):c}})},91104:(e,t,r)=>{"use strict";r.d(t,{D:()=>l});var n=r(19041),a=r(48592),s=r(50124),i=r(27924),o=r(83231);let l=(0,r(62176).op)({greaterEqual_:function(e,t){let r=(0,i.YT)(e,"a","greaterEqual","string_or_numeric"),l=(0,i.YT)(t,"b","greaterEqual","string_or_numeric");[r,l]=(0,s.makeTypesMatch)(r,l),(0,o.assertAndGetBroadcastShape)(r.shape,l.shape);let u={a:r,b:l};return n.T2.runKernel(a.lLS,u)}})},91338:(e,t,r)=>{"use strict";r.d(t,{l:()=>a});var n=r(51520);function a(e,t,r,a,s){let i=n.ZSL.sizeFromShape(a),o=t[0],l=s.length,u=[],h=1,p=-1;for(let e=0;e<l;++e){let t=s[e];if(-1===t){if(-1!==p)throw Error(n.C0T.getSparseReshapeMultipleNegativeOneOutputDimErrorMessage(p,e));p=e,u.push(1)}
4112else{if(t<0)throw Error(n.C0T.getSparseReshapeNegativeOutputDimErrorMessage(e,t));h*=t,u.push(t)}}if(-1!==p){if(h<=0)throw Error(n.C0T.getSparseReshapeEmptyTensorZeroOutputDimErrorMessage());let e=Math.trunc(i/h);if(h*e!==i)throw Error(n.C0T.getSparseReshapeInputOutputMultipleErrorMessage(a,u));u[p]=e}if(n.ZSL.sizeFromShape(u)!==i)throw Error(n.C0T.getSparseReshapeInputOutputMismatchErrorMessage(a,u));let d=a.length,c=[];if(d>0){c[d-1]=1;for(let e=d-2;e>=0;--e)c[e]=c[e+1]*a[e+1]}let f=[];if(l>0){f[l-1]=1;for(let e=l-2;e>=0;--e)f[e]=f[e+1]*u[e+1]}let m=n.ZSL.getArrayFromDType(r,o*l);for(let t=0;t<o;++t){let r=0;for(let n=0;n<d;++n)r+=e[t*d+n]*c[n];for(let e=0;e<l;++e)m[t*l+e]=Math.trunc(r/f[e]),r%=f[e]}return[m,[o,l],u]}},91951:(e,t,r)=>{"use strict";r.d(t,{R:()=>i});var n=r(19041),a=r(48592),s=r(27924);let i=(0,r(62176).op)({floor_:function(e){let t=(0,s.YT)(e,"x","floor","float32");return n.T2.runKernel(a.ZgB,{x:t})}})},92263:(e,t,r)=>{"use strict";r.d(t,{j:()=>o});var n=r(19041),a=r(48592),s=r(50124),i=r(27924);let o=(0,r(62176).op)({sub_:function(e,t){let r=(0,i.YT)(e,"a","sub"),o=(0,i.YT)(t,"b","sub");[r,o]=(0,s.makeTypesMatch)(r,o);let l={a:r,b:o};return n.T2.runKernel(a.PbM,l)}})},92610:(e,t,r)=>{"use strict";r.d(t,{y:()=>i});var n=r(19041),a=r(48592),s=r(27924);let i=(0,r(62176).op)({cosh_:function(e){let t=(0,s.YT)(e,"x","cosh","float32");return n.T2.runKernel(a.MnK,{x:t})}})},93473:(e,t,r)=>{"use strict";r.d(t,{X:()=>a,j:()=>n});let n=1.7580993408473768,a=1.0507009873554805},93807:(e,t,r)=>{"use strict";r.d(t,{Zl:()=>u,dl:()=>i,jb:()=>l});var n=r(51520),a=r(16986),s=r(75017);let i=(0,a.Z)((e,t)=>e-t),o=(0,s.B)((e,t,r,n)=>({real:e-r,imag:t-n})),l=(0,s.j)(n.PbM,i,o),u={kernelName:n.PbM,backendName:"cpu",kernelFunc:l}},94317:(e,t,r)=>{"use strict";r.d(t,{C2:()=>f,FA:()=>y,JW:()=>x,L:()=>T,R2:()=>v,XO:()=>m,Yv:()=>g,tg:()=>w,xq:()=>b});var n=r(51520),a=r(82492),s=r(90556),i=r(8785),o=r(14811),l=r(97344),u=r(96902),h=r(65650),p=r(82692),d=r(77617),c=r(1560);class f extends o.Wd{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(null==this.noiseShape)return this.noiseShape;let t=e.shape,r=[];for(let e=0;e<this.noiseShape.length;++e)r.push(null==this.noiseShape[e]?t[e]:this.noiseShape[e]);return r}call(e,t){return(0,n.DZQ)(()=>{this.invokeCallHook(e,t);let r=(0,c.un)(e);if(0<this.rate&&this.rate<1){let e=null!=t.training&&t.training,n=this.getNoiseShape(r);return s.Ls(()=>s.EZ(r,this.rate,n,this.seed),()=>r,e)}return e})}getConfig(){let e={rate:this.rate,noiseShape:this.noiseShape,seed:this.seed};return Object.assign(e,super.getConfig()),e}dispose(){return super.dispose()}}f.className="Dropout",n.JFn.registerClass(f);class m extends f{constructor(e){super(e),this.inputSpec=[{ndim:3}]}getNoiseShape(e){let t=e.shape;return[t[0],1,t[2]]}}m.className="SpatialDropout1D",n.JFn.registerClass(m);class g extends o.Wd{constructor(e){if(super(e),this.activation=null,this.useBias=!0,this.kernel=null,this.bias=null,this.DEFAULT_KERNEL_INITIALIZER="glorotNormal",this.DEFAULT_BIAS_INITIALIZER="zeros",null==e.batchInputShape&&null==e.inputShape&&null!=e.inputDim){let t=null;null!=e.batchSize&&(t=e.batchSize),this.batchInputShape=[t,e.inputDim]}this.units=e.units,(0,p.oo)(this.units,"units"),this.activation=(0,a.b_)(e.activation),null!=e.useBias&&(this.useBias=e.useBias),this.kernelInitializer=(0,u.Fe)(e.kernelInitializer||this.DEFAULT_KERNEL_INITIALIZER),this.biasInitializer=(0,u.Fe)(e.biasInitializer||this.DEFAULT_BIAS_INITIALIZER),this.kernelConstraint=(0,i.YZ)(e.kernelConstraint),this.biasConstraint=(0,i.YZ)(e.biasConstraint),this.kernelRegularizer=(0,h.Bm)(e.kernelRegularizer),this.biasRegularizer=(0,h.Bm)(e.biasRegularizer),this.activityRegularizer=(0,h.Bm)(e.activityRegularizer),this.supportsMasking=!0,this.inputSpec=[{minNDim:2}]}build(e){let t=(e=(0,c.U$)(e))[e.length-1];null==this.kernel&&(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){let t=(e=(0,c.U$)(e)).slice();return t[t.length-1]=this.units,t}call(e,t){return(0,n.DZQ)(()=>{let r;this.invokeCallHook(e,t);let n=(0,c.un)(e),a=(0,p.Cd)(this.activation.getClassName());return null!=a?r=s.Om(n,this.kernel.read(),a,this.bias?this.bias.read():null):(r=s.Om(n,this.kernel.read()),null!=this.bias&&(r=s.ni(r,this.bias.read())),null!=this.activation&&(r=this.activation.apply(r))),r})}getConfig(){let e={units:this.units,activation:(0,a.Bu)(this.activation),useBias:this.useBias,kernelInitializer:(0,u.zo)(this.kernelInitializer),biasInitializer:(0,u.zo)(this.biasInitializer),kernelRegularizer:(0,h.R9)(this.kernelRegularizer),biasRegularizer:(0,h.R9)(this.biasRegularizer),activityRegularizer:(0,h.R9)(this.activityRegularizer),kernelConstraint:(0,i.uH)(this.kernelConstraint),biasConstraint:(0,i.uH)(this.biasConstraint)};return Object.assign(e,super.getConfig()),e}}g.className="Dense",n.JFn.registerClass(g);class y extends o.Wd{constructor(e){super(e=e||{}),this.inputSpec=[{minNDim:3}],this.dataFormat=e.dataFormat}computeOutputShape(e){for(let t of(e=(0,c.U$)(e)).slice(1))if(null==t)throw new l.Qp(`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],(0,d.no)(e,1)]}call(e,t){return(0,n.DZQ)(()=>{this.invokeCallHook(e,t);let r=(0,c.un)(e);if("channelsFirst"===this.dataFormat&&r.rank>1){let e=[0];for(let t=2;t<r.rank;++t)e.push(t);e.push(1),r=(0,n.mgz)(r,e)}return s.PS(r)})}getConfig(){let e={};return null!=this.dataFormat&&(e.dataFormat=this.dataFormat),Object.assign(e,super.getConfig()),e}}y.className="Flatten",n.JFn.registerClass(y);class b extends o.Wd{constructor(e){super(e),this.supportsMasking=!0,this.activation=(0,a.b_)(e.activation)}call(e,t){return(0,n.DZQ)(()=>{this.invokeCallHook(e,t);let r=(0,c.un)(e);return this.activation.apply(r)})}getConfig(){let e={activation:(0,a.Bu)(this.activation)};return Object.assign(e,super.getConfig()),e}}b.className="Activation",n.JFn.registerClass(b);class x extends o.Wd{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(0,n.DZQ)(()=>(e=(0,c.un)(e),s.ux(e,this.n)))}getConfig(){let e={n:this.n};return Object.assign(e,super.getConfig()),e}}x.className="RepeatVector",n.JFn.registerClass(x);class v extends o.Wd{constructor(e){super(e),this.targetShape=e.targetShape;for(let e=0;e<this.targetShape.length;++e)this.isUnknown(this.targetShape[e])&&(this.targetShape[e]=null)}isUnknown(e){return e<0||null==e}fixUnknownDimension(e,t){let r="Total size of new array must be unchanged.",n=t.slice(),a=1,s=null;for(let e=0;e<n.length;++e){let t=n[e];if(this.isUnknown(t))if(null===s)s=e;else throw new l.Qp("Can only specifiy one unknown dimension.");else a*=t}let i=(0,d.no)(e);if(null!==s){if(0===a||i%a!=0)throw new l.Qp(r);n[s]=i/a}else if(i!==a)throw new l.Qp(r);return n}computeOutputShape(e){let t=!1;for(let r=0;r<e.length;++r)if(this.isUnknown(e[r])){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(0,n.DZQ)(()=>{this.invokeCallHook(e,t);let r=(0,c.un)(e),a=r.shape,s=a.slice(0,1).concat(this.fixUnknownDimension(a.slice(1),this.targetShape));return(0,n.tQQ)(r,s)})}getConfig(){let e={targetShape:this.targetShape};return Object.assign(e,super.getConfig()),e}}v.className="Reshape",n.JFn.registerClass(v);class w extends o.Wd{constructor(e){if(super(e),null==e.dims)throw Error("Required configuration field `dims` is missing during Permute constructor call.");if(!Array.isArray(e.dims))throw Error(`Permute constructor requires \`dims\` to be an Array, but received ${e.dims} instead.`);let t=(0,d.y1)(1,e.dims.length+1);if(!n.ZSL.arraysEqual(e.dims.slice().sort(),t))throw 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 o.eO({ndim:this.dims.length+1})]}computeOutputShape(e){let t=(e=(0,c.U$)(e)).slice();
4112return this.dims.forEach((r,n)=>{t[n+1]=e[r]}),t}call(e,t){return(0,n.mgz)((0,c.un)(e),this.dimsIncludingBatch)}getConfig(){let e={dims:this.dims};return Object.assign(e,super.getConfig()),e}}w.className="Permute",n.JFn.registerClass(w);class T extends o.Wd{constructor(e){super(null==e?{}:e),this.supportsMasking=!0,null!=e?this.maskValue=null==e.maskValue?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 r=(0,c.un)(e);return(0,n.bzn)((0,n.Ec)(r,this.maskValue),-1)}call(e,t){return(0,n.DZQ)(()=>{this.invokeCallHook(e,t);let r=(0,c.un)(e),a=(0,n.bzn)((0,n.Ec)(r,this.maskValue),-1,!0);return(0,n.lKK)(r,(0,n.wgE)(a,r.dtype))})}}T.className="Masking",n.JFn.registerClass(T)},94742:(e,t,r)=>{"use strict";r.d(t,{z:()=>o});var n=r(19041),a=r(48592),s=r(27924),i=r(83231);let o=(0,r(62176).op)({logicalOr_:function(e,t){let r=(0,s.YT)(e,"a","logicalOr","bool"),o=(0,s.YT)(t,"b","logicalOr","bool");return(0,i.assertAndGetBroadcastShape)(r.shape,o.shape),n.T2.runKernel(a.LXA,{a:r,b:o})}})},94915:(e,t,r)=>{"use strict";r.r(t),r.d(t,{calculateShapes:()=>i,validateInput:()=>s,validateUpdateShape:()=>a});var n=r(76526);function a(e,t,r){let n=t.rank>1?t.shape[t.rank-1]:1,a=t.rank>1?t.rank-1:1,s=`Must have updates.shape = indices.shape[:batchDim] + shape[sliceDim:], got updates.shape: ${r.shape}, indices.shape: ${t.shape}, shape: ${e}, sliceDim: ${n}, and batchDim: ${a}.`;if(r.rank<a)throw Error(s+` update.rank < ${a}. `);if(e.length<n+(r.rank-a))throw Error(s+` Output shape length < ${n+(r.rank-a)}`);if(r.rank!==a+e.length-n)throw Error(s+` update.rank != ${a+e.length-n}`);for(let e=0;e<a;++e)if(r.shape[e]!==t.shape[e])throw Error(s+` updates.shape[${e}] (${r.shape[e]}) != indices.shape[${e}] (${t.shape[e]}).`);for(let t=0;t<r.rank-a;++t)if(r.shape[t+a]!==e[t+n])throw Error(s+` updates.shape[${t+a}] (${r.shape[t+a]}) != shape[${t+a}] (${e[t+a]})`)}function s(e,t,r){if(t.rank<1)throw Error(`tf.scatterND() expects the indices to be rank 1 or higher, but the rank was ${t.rank}.`);if(e.rank<1)throw Error(`tf.scatterND() expects the updates to be rank 1 or higher, but the rank was ${e.rank}.`);if("int32"!==t.dtype)throw Error(`The dtype of 'indices' should be int32, but got dtype: ${t.dtype}`);if(r.length<1)throw Error(`Output rank must be greater or equal to 1, but got shape: ${r}`);if(0===r.length){if(0===t.size)throw Error(`Indices specified for empty output. indices shape: ${t.shape}`);if(0===e.size)throw Error(`Updates specified for empty output. updates shape: ${e.shape}`)}a(r,t,e)}function i(e,t,r){let a=t.shape.length,s=a>1?t.shape[a-1]:1,i=r.length,o=1;for(let e=s;e<i;++e)o*=r[e];let l=s<1?1:s,u=(0,n.Ze)(t.shape)/l,h=[...(0,n.Ur)(r.slice(0,s)),1];return{sliceRank:s,numUpdates:u,sliceSize:o,strides:h,outputSize:(0,n.Ze)(r)}}},95150:(e,t,r)=>{"use strict";r.d(t,{H:()=>c});var n=r(10551),a=r(27924),s=r(16488),i=r(25158),o=r(29659),l=r(79459),u=r(48683),h=r(62176),p=r(92263),d=r(60966);let c=(0,h.op)({logSoftmax_:function(e,t=-1){let r=(0,a.YT)(e,"logits","logSoftmax");if(-1===t&&(t=r.rank-1),t!==r.rank-1)throw Error(`Log Softmax along a non-last dimension is not yet supported. Logits was rank ${r.rank} and axis was ${t}`);return(0,n._X)((e,r)=>{let n=(0,l.T)(e,t,!0),a=(0,p.j)(e,n),h=(0,p.j)((0,s.w)(a,"float32"),(0,o.R)((0,d.c)((0,i.o)(a),t,!0)));return r([h]),{value:h,gradFunc:(e,r)=>
4112{let[n]=r,a=(0,i.o)(n);return(0,p.j)(e,(0,u.l)((0,d.c)(e,t,!0),a))}}})(r)}})},95522:function(e,t,r){var n;!function(e,a,s){function i(e){var t=this;t.next=function(){var e,r,n=t.x,a=t.i;return e=n[a],e^=e>>>7,r=e^e<<24^((e=n[a+1&7])^e>>>10)^((e=n[a+3&7])^e>>>3)^((e=n[a+4&7])^e<<7),e=n[a+7&7],e^=e<<13,r^=e^e<<9,n[a]=r,t.i=a+1&7,r};var r,n=e,a=[];if(n===(0|n))a[0]=n;else for(r=0,n=""+n;r<n.length;++r)a[7&r]=a[7&r]<<15^n.charCodeAt(r)+a[r+1&7]<<13;for(;a.length<8;)a.push(0);for(r=0;r<8&&0===a[r];++r);for(8==r?a[7]=-1:a[r],t.x=a,t.i=0,r=256;r>0;--r)t.next()}function o(e,t){return t.x=e.x.slice(),t.i=e.i,t}function l(e,t){null==e&&(e=+new Date);var r=new i(e),n=t&&t.state,a=function(){return(r.next()>>>0)/0x100000000};return a.double=function(){do var e=((r.next()>>>11)+(r.next()>>>0)/0x100000000)/2097152;while(0===e);return e},a.int32=r.next,a.quick=a,n&&(n.x&&o(n,r),a.state=function(){return o(r,{})}),a}a&&a.exports?a.exports=l:r.amdD&&r.amdO?void 0===(n=(function(){return l}).call(t,r,t,a))||(a.exports=n):this.xorshift7=l}(0,e=r.nmd(e),r.amdD)},95791:(e,t,r)=>{"use strict";r.d(t,{x:()=>i});var n=r(19041),a=r(48592),s=r(27924);let i=(0,r(62176).op)({real_:function(e){let t=(0,s.YT)(e,"input","real");return n.T2.runKernel(a.LRy,{input:t})}})},95989:(e,t,r)=>{"use strict";r.d(t,{r:()=>o});var n=r(27924),a=r(76526),s=r(62176),i=r(68567);let o=(0,s.op)({squeeze_:function(e,t){let r=(0,n.YT)(e,"x","squeeze","string_or_numeric");return(0,i.t)(r,(0,a.gx)(r.shape,t).newShape)}})},96247:(e,t,r)=>{"use strict";r.d(t,{l:()=>i});var n=r(19041),a=r(48592),s=r(27924);let i=(0,r(62176).op)({softplus_:function(e){let t=(0,s.YT)(e,"x","softplus");return n.T2.runKernel(a.Fin,{x:t})}})},96902:(e,t,r)=>{"use strict";r.d(t,{h8:()=>f,xd:()=>w,Ux:()=>v,bL:()=>T,KJ:()=>S,lz:()=>b,H4:()=>p,TO:()=>N,Gs:()=>k,sN:()=>c,iv:()=>I,rZ:()=>g,m9:()=>m,EE:()=>y,Lm:()=>x,_c:()=>d,Fe:()=>$,zo:()=>A});var n=r(51520),a=r(90556),s=r(15034),i=r(97344);let o=["fanIn","fanOut","fanAvg"],l=["normal","uniform","truncatedNormal"];var u=r(82692),h=r(77617);class p extends n.JFn.Serializable{fromConfigUsesCustomObjects(){return!1}getConfig(){return{}}}class d extends p{apply(e,t){return(0,n.Ul9)(e,t)}}d.className="Zeros",n.JFn.registerClass(d);class c extends p{apply(e,t){return(0,n.SaS)(e,t)}}c.className="Ones",n.JFn.registerClass(c);class f extends p{constructor(e){if(super(),"object"!=typeof e)throw new i.Qp(`Expected argument of type ConstantConfig but got ${e}`);if(void 0===e.value)throw new i.Qp(`config must have value set but got ${e}`);this.value=e.value}apply(e,t){return(0,n.DZQ)(()=>(0,n.lKK)((0,n.d_2)(this.value),(0,n.SaS)(e,t)))}getConfig(){return{value:this.value}}}f.className="Constant",n.JFn.registerClass(f);class m extends p{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(0,n.YeY)(e,this.minval,this.maxval,t,this.seed)}getConfig(){return{minval:this.minval,maxval:this.maxval,seed:this.seed}}}m.className="RandomUniform",n.JFn.registerClass(m);class g extends p{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("float32"!==(t=t||"float32")&&"int32"!==t)throw new i.EH(`randomNormal does not support dType ${t}.`);return a.FE(e,this.mean,this.stddev,t,this.seed)}getConfig(){return{mean:this.mean,stddev:this.stddev,seed:this.seed}}}g.className="RandomNormal",n.JFn.registerClass(g);class y extends p{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("float32"!==(t=t||"float32")&&"int32"!==t)throw new i.EH(`truncatedNormal does not support dType ${t}.`);
4112return(0,n.efE)(e,this.mean,this.stddev,t,this.seed)}getConfig(){return{mean:this.mean,stddev:this.stddev,seed:this.seed}}}y.className="TruncatedNormal",n.JFn.registerClass(y);class b extends p{constructor(e){super(),this.gain=null!=e.gain?e.gain:1}apply(e,t){return(0,n.DZQ)(()=>{if(2===e.length&&e[0]===e[1])return(0,n.lKK)(this.gain,(0,n.y5U)(e[0]));throw new i.Qp("Identity matrix initializer can only be used for 2D square matrices.")})}getConfig(){return{gain:this.gain}}}b.className="Identity",n.JFn.registerClass(b);class x extends p{constructor(e){var t,r;if(super(),e.scale<0)throw new i.Qp(`scale must be a positive float. Got: ${e.scale}`);this.scale=null==e.scale?1:e.scale,this.mode=null==e.mode?"fanIn":e.mode,t=this.mode,(0,u.E6)(o,"FanMode",t),this.distribution=null==e.distribution?"normal":e.distribution,r=this.distribution,(0,u.E6)(l,"Distribution",r),this.seed=e.seed}apply(e,t){let r=function(e,t="channelsLast"){let r,n;if((0,s.uM)(t),2===e.length)r=e[0],n=e[1];else if(-1!==[3,4,5].indexOf(e.length)){if("channelsFirst"===t){let t=(0,h.no)(e,2);r=e[1]*t,n=e[0]*t}else if("channelsLast"===t){let t=(0,h.no)(e,0,e.length-2);r=e[e.length-2]*t,n=e[e.length-1]*t}}else{let t=(0,h.no)(e);r=Math.sqrt(t),n=Math.sqrt(t)}return[r,n]}(e),a=r[0],o=r[1],l=this.scale;if("fanIn"===this.mode?l/=Math.max(1,a):"fanOut"===this.mode?l/=Math.max(1,o):l/=Math.max(1,(a+o)/2),"normal"===this.distribution){let r=Math.sqrt(l);if("float32"!==(t=t||"float32")&&"int32"!==t)throw new i.EH(`${this.getClassName()} does not support dType ${t}.`);
4112return(0,n.efE)(e,0,r,t,this.seed)}{let r=Math.sqrt(3*l);return(0,n.YeY)(e,-r,r,t,this.seed)}}getConfig(){return{scale:this.scale,mode:this.mode,distribution:this.distribution,seed:this.seed}}}x.className="VarianceScaling",n.JFn.registerClass(x);class v extends x{constructor(e){super({scale:1,mode:"fanAvg",distribution:"uniform",seed:null==e?null:e.seed})}getClassName(){return x.className}}v.className="GlorotUniform",n.JFn.registerClass(v);class w extends x{constructor(e){super({scale:1,mode:"fanAvg",distribution:"normal",seed:null==e?null:e.seed})}getClassName(){return x.className}}w.className="GlorotNormal",n.JFn.registerClass(w);class T extends x{constructor(e){super({scale:2,mode:"fanIn",distribution:"normal",seed:null==e?null:e.seed})}getClassName(){return x.className}}T.className="HeNormal",n.JFn.registerClass(T);class S extends x{constructor(e){super({scale:2,mode:"fanIn",distribution:"uniform",seed:null==e?null:e.seed})}getClassName(){return x.className}}S.className="HeUniform",n.JFn.registerClass(S);class N extends x{constructor(e){super({scale:1,mode:"fanIn",distribution:"normal",seed:null==e?null:e.seed})}getClassName(){return x.className}}N.className="LeCunNormal",n.JFn.registerClass(N);class k extends x{constructor(e){super({scale:1,mode:"fanIn",distribution:"uniform",seed:null==e?null:e.seed})}getClassName(){return x.className}}k.className="LeCunUniform",n.JFn.registerClass(k);class I extends p{constructor(e){super(),this.DEFAULT_GAIN=1,this.ELEMENTS_WARN_SLOW=2e3,this.gain=null==e.gain?this.DEFAULT_GAIN:e.gain,this.seed=e.seed}apply(e,t){return(0,n.DZQ)(()=>{if(e.length<2)throw new i.EH("Shape must be at least 2D.");if("int32"!==t&&"float32"!==t&&void 0!==t)throw TypeError(`Unsupported data type ${t}.`);let r=n.ZSL.sizeFromShape(e.slice(0,-1)),s=e[e.length-1],o=r*s;o>this.ELEMENTS_WARN_SLOW&&console.warn(`Orthogonal initializer is being called on a matrix with more than ${this.ELEMENTS_WARN_SLOW} (${o}) elements: Slowness may result.`);let l=[Math.max(s,r),Math.min(s,r)],u=a.FE(l,0,1,t,this.seed),h=n.mPL.qr(u,!1),p=h[0],d=h[1].flatten().stridedSlice([0],[Math.min(s,r)*Math.min(s,r)],[Math.min(s,r)+1]);return p=(0,n.lKK)(p,d.sign()),r<s&&(p=p.transpose()),(0,n.lKK)((0,n.d_2)(this.gain),p.reshape(e))})}getConfig(){return{gain:this.gain,seed:this.seed}}}I.className="Orthogonal",n.JFn.registerClass(I);let C={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 E(e,t={}){return(0,u.Xv)(e,n.JFn.SerializationMap.getMap().classNameMap,t,"initializer")}function A(e){return(0,u.k4)(e)}function $(e){if("string"==typeof e){let t=e in C?C[e]:e;if("GlorotNormal"===t)return new w;{if("GlorotUniform"===t)return new v;if("HeNormal"===t)return new T;if("HeUniform"===t)return new S;if("LeCunNormal"===t)return new N;if("LeCunUniform"===t)return new k;let e={};return e.className=t,e.config={},E(e)}}return e instanceof p?e:E(e)}},97175:(e,t,r)=>{"use strict";function n(e){let{inputs:t,backend:r}=e,{input:n}=t,a=r.data.get(n.dataId).complexTensorInfos.real,s=r.data.get(a.dataId).values;return r.makeTensorInfo(a.shape,a.dtype,s)}r.d(t,{r:()=>a,x:()=>n});let a={kernelName:r(51520).LRy,backendName:"cpu",kernelFunc:n}},97344:(e,t,r)=>{"use strict";r.d(t,{EH:()=>i,Qp:()=>s,bu:()=>a,l7:()=>n,pf:()=>o});
4112class n extends Error{constructor(e){super(e),Object.setPrototypeOf(this,n.prototype)}}class a extends Error{constructor(e){super(e),Object.setPrototypeOf(this,a.prototype)}}class s extends Error{constructor(e){super(e),Object.setPrototypeOf(this,s.prototype)}}class i extends Error{constructor(e){super(e),Object.setPrototypeOf(this,i.prototype)}}class o extends Error{constructor(e){super(e),Object.setPrototypeOf(this,o.prototype)}}},97651:(e,t,r)=>{"use strict";r.d(t,{V:()=>o});var n=r(19041),a=r(48592),s=r(27924),i=r(76526);let o=(0,r(62176).op)({tile_:function(e,t){let r=(0,s.YT)(e,"x","tile","string_or_numeric");return i.vA(r.rank===t.length,()=>`Error in transpose: rank of input ${r.rank} must match length of reps ${t}.`),n.T2.runKernel(a.FAs,{x:r},{reps:t})}})},97953:(e,t,r)=>{"use strict";r.d(t,{A:()=>i});var n=r(67108),a=r(71553),s=r(82859);class i{constructor(e,t=!1){this.variableNames=["A"],this.packedInputs=!1,this.packedOutput=!0,this.customUniforms=[{name:"texShape",type:"ivec2"}];let r=(0,n.B)();this.outputShape=e,this.enableShapeUniforms=(0,a.ik)(this.outputShape.length);let i="",o="result";t&&(o="floor(result * 255. + 0.5)");for(let t=0;t<=1;t++)for(let n=0;n<=1;n++){let a=2*t+n;i+=` 4113 localCoords = coords; 4114 if(localCoords[2] + ${n} < ${this.enableShapeUniforms?"outShape[2]":`${e[2]}`}) { 4115 localCoords[2] += ${n}; 4116 if (localCoords[1] + ${t} < ${this.enableShapeUniforms?"outShape[1]":`${e[1]}`}) { 4117 localCoords[1] += ${t}; 4118 4119 flatIndex = getFlatIndex(localCoords); 4120 offset = imod(flatIndex, 4); 4121 4122 flatIndex = idiv(flatIndex, 4, 1.); 4123 4124 int r = flatIndex / texShape[1]; 4125 int c = imod(flatIndex, texShape[1]); 4126 vec2 uv = (vec2(c, r) + halfCR) / vec2(texShape[1], texShape[0]); 4127 values = ${r.texture2D}(A, uv); 4128 4129 if (offset == 0) { 4130 result[${a}] = values[0]; 4131 } else if (offset == 1) { 4132 result[${a}] = values[1]; 4133 } else if (offset == 2) { 4134 result[${a}] = values[2]; 4135 } else { 4136 result[${a}] = values[3]; 4137 } 4138 } 4139 } 4140 `}this.userCode=` 4141 ${this.enableShapeUniforms?s.Od():s.fM(e)} 4142 4143 void main() { 4144 ivec3 coords = getOutputCoords(); 4145 4146 vec4 result = vec4(0.); 4147 int flatIndex, r, c, offset; 4148 ivec3 localCoords; 4149 vec2 uv; 4150 vec4 values; 4151 4152 ${i} 4153 4154 ${r.output} = ${o}; 4155 } 4156 `}}},98253:(e,t,r)=>{"use strict";r.d(t,{_:()=>a});var n=r(51520);function a(e,t,r,a,s,i,o){if(t.length>1)throw Error("starts must be a scalar or vector");if(s.length>1)throw Error("limits must be a scalar or vector");if(o.length>1)throw Error("deltas must be a scalar or vector");let l=0===t.length,u=0===s.length,h=0===o.length,p=[];l||p.push(t[0]),u||p.push(s[0]),h||p.push(o[0]);for(let e=1;e<p.length;++e)if(p[e]!==p[e-1])throw Error("starts, limits, and deltas must have the same shape");let d=0===p.length?1:p[0],c=n.ZSL.getArrayFromDType("int32",d+1);c[0]=0;for(let t=0;t<d;++t){let r,n=l?e[0]:e[t],s=u?a[0]:a[t],o=h?i[0]:i[t];if(0===o)throw Error("Requires delta != 0");if(o>0&&s<n||o<0&&s>n)r=0;else if((r=Math.ceil(Math.abs((s-n)/o)))>0x7fffffff)throw Error("Requires ((limit - start) / delta) <= 2147483647");c[t+1]=c[t]+r}let f=c[d],m=n.ZSL.getArrayFromDType(r,f),g=0;for(let t=0;t<d;++t){let r=c[t+1]-c[t],n=l?e[0]:e[t],a=h?i[0]:i[t];for(let e=0;e<r;++e)m[g++]=n,n+=a}return[c,m]}},98932:(e,t,r)=>{"use strict";r.d(t,{$:()=>p});var n=r(19041),a=r(48592),s=r(27924),i=r(76526),o=r(16488),l=r(39114),u=r(62176),h=r(68567);let p=(0,u.op)({avgPool_:function(e,t,r,u,p){let d=(0,s.YT)(e,"x","avgPool","float32");i.vA(l.G0(r,1),()=>`Error in avgPool: Either strides or dilations must be 1. Got strides ${r} and dilations '1'`);let c=d,f=!1;3===d.rank&&(f=!0,c=(0,h.t)(d,[1,d.shape[0],d.shape[1],d.shape[2]])),i.vA(4===c.rank,()=>`Error in avgPool: x must be rank 4 but got rank ${c.rank}.`),l.s_("avgPool",u,p);let m={x:c},g=n.T2.runKernel(a.ho8,m,{filterSize:t,strides:r,pad:u,dimRoundingMode:p});return(g=(0,o.w)(g,d.dtype),f)?(0,h.t)(g,[g.shape[1],g.shape[2],g.shape[3]]):g}})},99373:(e,t,r)=>{"use strict";r.d(t,{Nu:()=>l,hE:()=>i});var n=r(51520),a=r(16986),s=r(75017);let i=(0,a.Z)((e,t)=>Math.min(e,t)),o=(0,s.j)(n.LG0,i),l={kernelName:n.LG0,backendName:"cpu",kernelFunc:o}},99471:(e,t,r)=>{"use strict";r.d(t,{RF:()=>i,b2:()=>l});var n=r(51520),a=r(16986),s=r(75017);let i=(0,a.Z)((e,t)=>{let r=e-t;return r*r}),o=(0,s.j)(n.Ddj,i),l={kernelName:n.Ddj,backendName:"cpu",kernelFunc:o}},99882:(e,t,r)=>{"use strict";var n;r.d(t,{i:()=>n}),function(e){e[e.NONE=0]="NONE",e[e.MEAN=1]="MEAN",e[e.SUM=2]="SUM",e[e.SUM_BY_NONZERO_WEIGHTS=3]="SUM_BY_NONZERO_WEIGHTS"}(n||(n={}))}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.