2021-09-11 03:21:29 +02:00
/ *
Human
homepage : < https : //github.com/vladmandic/human>
author : < https : //github.com/vladmandic>'
* /
2021-03-10 00:32:35 +01:00
2021-10-22 22:09:52 +02:00
var Human = ( ( ) => { var R1 = Object . defineProperty ; var HS = ( e , t , n ) => t in e ? R1 ( e , t , { enumerable : ! 0 , configurable : ! 0 , writable : ! 0 , value : n } ) : e [ t ] = n ; var qS = e => R1 ( e , "__esModule" , { value : ! 0 } ) ; var rs = ( e => typeof require != "undefined" ? require : typeof Proxy != "undefined" ? new Proxy ( e , { get : ( t , n ) => ( typeof require != "undefined" ? require : t ) [ n ] } ) : e ) ( function ( e ) { if ( typeof require != "undefined" ) return require . apply ( this , arguments ) ; throw new Error ( 'Dynamic require of "' + e + '" is not supported' ) } ) ; var ud = ( e , t ) => { qS ( e ) ; for ( var n in t ) R1 ( e , n , { get : t [ n ] , enumerable : ! 0 } ) } ; var ce = ( e , t , n ) => ( HS ( e , typeof t != "symbol" ? t + "" : t , n ) , n ) , O5 = ( e , t , n ) => { if ( ! t . has ( e ) ) throw TypeError ( "Cannot " + n ) } ; var dd = ( e , t , n ) => ( O5 ( e , t , "read from private field" ) , n ? n . call ( e ) : t . get ( e ) ) , pd = ( e , t , n ) => { if ( t . has ( e ) ) throw TypeError ( "Cannot add the same private member more than once" ) ; t instanceof WeakSet ? t . add ( e ) : t . set ( e , n ) } , cd = ( e , t , n , a ) => ( O5 ( e , t , "write to private field" ) , a ? a . call ( e , n ) : t . set ( e , n ) , n ) ; var zde = { } ; ud ( zde , { Env : ( ) => Mf , Human : ( ) => JI , Models : ( ) => rc , default : ( ) => JI , defaults : ( ) => ss , env : ( ) => xe } ) ; function tt ( e , t ) { let n = e . endsWith ( "/" ) ? "" : "/" , r = t . startsWith ( "." ) || t . startsWith ( "/" ) || t . startsWith ( "http:" ) || t . startsWith ( "https:" ) || t . startsWith ( "file:" ) ? ` ${ t } ` : ` ${ e } ${ n } ${ t } ` ; if ( ! r . toLocaleLowerCase ( ) . includes ( ".json" ) ) throw new Error ( ` modelpath error: ${ r } expecting json file ` ) ; return r } function ie ( ... e ) { let t = new Date , n = ` ${ t . getHours ( ) . toString ( ) . padStart ( 2 , "0" ) } : ${ t . getMinutes ( ) . toString ( ) . padStart ( 2 , "0" ) } : ${ t . getSeconds ( ) . toString ( ) . padStart ( 2 , "0" ) } . ${ t . getMilliseconds ( ) . toString ( ) . padStart ( 3 , "0" ) } ` ; e && console . log ( n , "Human:" , ... e ) } var Ae = ( ) => typeof performance != "undefined" ? performance . now ( ) : parseInt ( ( Number ( process . hrtime . bigint ( ) ) / 1e3 / 1e3 ) . toString ( ) ) ; function M1 ( e , t , n = "config" , a = [ ] ) { for ( let r of Object . keys ( t ) ) if ( typeof t [ r ] == "object" ) M1 ( e [ r ] , t [ r ] , r , a ) ; else { let s = e && typeof e [ r ] != "undefined" ; s || a . push ( { reason : "unknown property" , where : ` ${ n } . ${ r } = ${ t [ r ] } ` } ) ; let i = e && typeof e [ r ] == typeof t [ r ] ; s && ! i && a . push ( { reason : "property type mismatch" , where : ` ${ n } . ${ r } = ${ t [ r ] } ` , expected : typeof e [ r ] } ) } return t . debug && n === "config" && a . length > 0 && ie ( "invalid configuration" , a ) , a } function kn ( ... e ) { let t = n => n && typeof n == "object" ; return e . reduce ( ( n , a ) => ( Object . keys ( a || { } ) . forEach ( r => { let s = n [ r ] , i = a [ r ] ; Array . isArray ( s ) && Array . isArray ( i ) ? n [ r ] = s . concat ( ... i ) : t ( s ) && t ( i ) ? n [ r ] = kn ( s , i ) : n [ r ] = i } ) , n ) , { } ) } var ss = { backend : "" , modelBasePath : "" , wasmPath : "" , debug : ! 0 , async : ! 0 , warmup : "full" , cacheSensitivity : . 75 , skipFrame : ! 1 , filter : { enabled : ! 0 , width : 0 , height : 0 , flip : ! 1 , return : ! 0 , brightness : 0 , contrast : 0 , sharpness : 0 , blur : 0 , saturation : 0 , hue : 0 , negative : ! 1 , sepia : ! 1 , vintage : ! 1 , kodachrome : ! 1 , technicolor : ! 1 , polaroid : ! 1 , pixelate : 0 } , gesture : { enabled : ! 0 } , face : { enabled : ! 0 , detector : { modelPath : "blazeface.json" , rotation : ! 0 , maxDetected : 1 , skipFrames : 11 , skipTime : 2e3 , minConfidence : . 2 , iouThreshold : . 1 , return : ! 1 } , mesh : { enabled : ! 0 , modelPath : "facemesh.json" } , iris : { enabled : ! 0 , modelPath : "iris.json" } , emotion : { enabled : ! 0 , minConfidence : . 1 , skipFrames : 12 , skipTime : 2e3 , modelPath : "emotion.json" } , description : { enabled : ! 0 , modelPath : "faceres.json" , skipFrames : 13 , skipTime : 2e3 , minConfidence : . 1 } , antispoof : { enabled : ! 1 , skipFrames : 14 , skipTime : 2e3 , modelPath : "antispoof.json" } } , body : { enabled : ! 0 , modelPath : "movenet-lightning.json" , detector : { modelPath : "" } , maxDetected : - 1 , minConfidence : . 3 , skipFrames : 1 , skipTime : 2e3 } , hand : { enabled : ! 0 , rotation : ! 0 , skipFrames : 2 , skipTime : 2e3 , minConfidence : . 5 , iouThreshold : . 2 , maxDetected : - 1 , landmarks : ! 0 , detector : { modelPath : "handtrack.json" } , skeleton : { modelPath : "handskeleton.json" } } , object : { enabled : ! 1 , modelPath : "mb3-centernet.json" , minConfidence : . 2 , iouThreshold : . 4 , maxDetected : 10 , skipFrames : 15 , skipTime : 2e3 } , segmentation : { enabled : ! 1 , modelPath : "selfie.json" , blur : 8 } } ; var Ro = { } ; ud ( Ro , { Abs : ( ) => Ko , Acos : ( ) => Zo , Acosh : ( ) => Yo , AdadeltaOptimizer : ( ) => h0 , AdagradOptimizer : ( ) => f0 , AdamOptimizer : ( ) => m0 , AdamaxOptimizer : ( ) => g0 , Add : ( ) => ls , AddN : ( ) => Zs , All : ( ) => Jo , Any : ( ) => Qo , ArgMax : ( ) => Ys , ArgMin : ( ) => yd , Asin : ( ) => el , Asinh : ( ) => tl , Atan : ( ) => nl , Atan2 : ( ) => rl , Atanh : ( ) => al , AvgPool : ( ) => Js , AvgPool3D : ( ) => Ad , AvgPool3DGrad : ( ) => Bc , AvgPoolGrad : ( ) => Wc , BackendWasm : ( ) => q8 , BatchMatMul : ( ) => Qs , BatchToSpaceND : ( ) => sl , Bi
2021-09-11 16:29:31 +02:00
` )),l.join( `
2021-10-22 22:09:52 +02:00
` )}function oT(e,t,n,a){let r=zt(t),s=a[a.length-1],i=new Array(s).fill(0),o=t.length,l=n==="complex64"?Pd(e):e;if(o>1)for(let d=0;d<r/s;d++){let u=d*s;for(let p=0;p<s;p++)i[p]=Math.max(i[p],_d(l[u+p],0,n).length)}return i}function _d(e,t,n){let a;return Array.isArray(e)?a= ` $ { parseFloat ( e [ 0 ] . toFixed ( B1 ) ) } + $ { parseFloat ( e [ 1 ] . toFixed ( B1 ) ) } j ` :is(e)?a= ` '${e}' ` :n==="bool"?a=lb(e):a=parseFloat(e.toFixed(B1)).toString(),gd(a,t)}function lb(e){return e===0?"false":"true"}function Ch(e,t,n,a,r,s=!0){let i=n==="complex64"?2:1,o=t[0],l=t.length;if(l===0){if(n==="complex64"){let m=Pd(e);return[_d(m[0],0,n)]}return n==="bool"?[lb(e[0])]:[e[0].toString()]}if(l===1){if(o>ob){let g=Od*i,y=Array.from(e.slice(0,g)),A=Array.from(e.slice((o-Od)*i,o*i));return n==="complex64"&&(y=Pd(y),A=Pd(A)),["["+y.map((x,b)=>_d(x,r[b],n)).join(", ")+", ..., "+A.map((x,b)=>_d(x,r[o-Od+b],n)).join(", ")+"]"]}let m=n==="complex64"?Pd(e):Array.from(e);return["["+m.map((g,y)=>_d(g,r[y],n)).join(", ")+"]"]}let d=t.slice(1),u=a.slice(1),p=a[0]*i,c=[];if(o>ob){for(let m=0;m<Od;m++){let g=m*p,y=g+p;c.push(...Ch(e.slice(g,y),d,n,u,r,!1))}c.push("...");for(let m=o-Od;m<o;m++){let g=m*p,y=g+p;c.push(...Ch(e.slice(g,y),d,n,u,r,m===o-1))}}else for(let m=0;m<o;m++){let g=m*p,y=g+p;c.push(...Ch(e.slice(g,y),d,n,u,r,m===o-1))}let h=l===2?",":"";c[0]="["+c[0]+h;for(let m=1;m<c.length-1;m++)c[m]=" "+c[m]+h;let f= ` ,
2021-10-07 16:33:10 +02:00
` ;for(let m=2;m<l;m++)f+= `
2021-10-22 22:09:52 +02:00
` ;return c[c.length-1]=" "+c[c.length-1]+"]"+(s?"":f),c}function Pd(e){let t=[];for(let n=0;n<e.length;n+=2)t.push([e[n],e[n+1]]);return t}var Jt=class{constructor(e,t,n){if(this.dtype=t,this.shape=e.slice(),this.size=zt(e),n!=null){let a=n.length; $ (a===this.size,()=> ` Length of values '${a}' does not match the size inferred by the shape '${this.size}' . ` )}if(t==="complex64")throw new Error("complex64 dtype TensorBuffers are not supported. Please create a TensorBuffer for the real and imaginary parts separately and call tf.complex(real, imag).");this.values=n||j5(t,this.size),this.strides=qo(e)}set(e,...t){t.length===0&&(t=[0]), $ (t.length===this.rank,()=> ` The number of provided coordinates ( $ { t . length } ) must match the rank ( $ { this . rank } ) ` );let n=this.locToIndex(t);this.values[n]=e}get(...e){e.length===0&&(e=[0]);let t=0;for(let a of e){if(a<0||a>=this.shape[t]){let r= ` Requested out of range element at $ { e } . Buffer shape = $ { this . shape } ` ;throw new Error(r)}t++}let n=e[e.length-1];for(let a=0;a<e.length-1;++a)n+=this.strides[a]*e[a];return this.values[n]}locToIndex(e){if(this.rank===0)return 0;if(this.rank===1)return e[0];let t=e[e.length-1];for(let n=0;n<e.length-1;++n)t+=this.strides[n]*e[n];return t}indexToLoc(e){if(this.rank===0)return[];if(this.rank===1)return[e];let t=new Array(this.shape.length);for(let n=0;n<t.length-1;++n)t[n]=Math.floor(e/this.strides[n]),e-=t[n]*this.strides[n];return t[t.length-1]=e,t}get rank(){return this.shape.length}toTensor(){return hr().makeTensor(this.values,this.shape,this.dtype)}},hr=null,Yl=null,lT=null;function uT(e){hr=e}function dT(e){Yl=e}function pT(e){lT=e}var je=class{constructor(e,t,n,a){this.kept=!1,this.isDisposedInternal=!1,this.shape=e.slice(),this.dtype=t||"float32",this.size=zt(e),this.strides=qo(e),this.dataId=n,this.id=a,this.rankType=this.rank<5?this.rank.toString():"higher"}get rank(){return this.shape.length}async buffer(){let e=await this.data();return Yl.buffer(this.shape,this.dtype,e)}bufferSync(){return Yl.buffer(this.shape,this.dtype,this.dataSync())}async array(){let e=await this.data();return Xo(this.shape,e,this.dtype==="complex64")}arraySync(){return Xo(this.shape,this.dataSync(),this.dtype==="complex64")}async data(){this.throwIfDisposed();let e=hr().read(this.dataId);if(this.dtype==="string"){let t=await e;try{return t.map(n=>Th(n))}catch(n){throw new Error("Failed to decode the string bytes into utf-8. To get the original bytes, call tensor.bytes().")}}return e}dataSync(){this.throwIfDisposed();let e=hr().readSync(this.dataId);if(this.dtype==="string")try{return e.map(t=>Th(t))}catch(t){throw new Error("Failed to decode the string bytes into utf-8. To get the original bytes, call tensor.bytes().")}return e}async bytes(){this.throwIfDisposed();let e=await hr().read(this.dataId);return this.dtype==="string"?e:new Uint8Array(e.buffer)}dispose(){this.isDisposed||(hr().disposeTensor(this),this.isDisposedInternal=!0)}get isDisposed(){return this.isDisposedInternal}throwIfDisposed(){if(this.isDisposed)throw new Error("Tensor is disposed.")}print(e=!1){return Yl.print(this,e)}clone(){return this.throwIfDisposed(),Yl.clone(this)}toString(e=!1){let t=this.dataSync();return iT(t,this.shape,this.dtype,e)}cast(e){return this.throwIfDisposed(),Yl.cast(this,e)}variable(e=!0,t,n){return this.throwIfDisposed(),hr().makeVariable(this,e,t,n)}};Object.defineProperty(je,Symbol.hasInstance,{value:e=>!!e&&e.data!=null&&e.dataSync!=null&&e.throwIfDisposed!=null});function ae(){return P1("Tensor",()=>je)}ae();var zd=class extends je{constructor(e,t,n,a){super(e.shape,e.dtype,e.dataId,a);this.trainable=t,this.name=n}assign(e){if(e.dtype!==this.dtype)throw new Error( ` dtype of the new value ( $ { e . dtype } ) and previous value ( $ { this . dtype } ) must match ` );if(!Dr(e.shape,this.shape))throw new Error( ` shape of the new value ( $ { e . shape } ) and previous value ( $ { this . shape } ) must match ` );hr().disposeTensor(this),this.dataId=e.dataId,hr().incRef(this,null)}dispose(){hr().disposeVariable(this),this.isDisposedInternal=!0}};Object.defineProperty(zd,Symbol.hasInstance,{value:e=>e instanceof je&&e.as
Manifest JSON has weights with names : $ { o . join ( ", " ) } . ` )}let l=r.reduce((h,f,m)=>(f&&h.push(m),h),[]),d=[];l.forEach(h=>{t[h].paths.forEach(f=>{let m=n+(n.endsWith("/")?"":"/")+f;d.push(m)})});let u=await e(d),p={},c=0;return l.forEach(h=>{let f=t[h].paths.length,m=0;for(let x=0;x<f;x++)m+=u[c+x].byteLength;let g=new ArrayBuffer(m),y=new Uint8Array(g),A=0;for(let x=0;x<f;x++){let b=new Uint8Array(u[c+x]);y.set(b,A),A+=b.byteLength}s[h].forEach(x=>{let b=g.slice(x.groupOffset,x.groupOffset+x.sizeBytes),v=yb(b,[x.manifestEntry]);for(let k in v)p[k]=v[k]}),c+=f}),p}}var lC="application/octet-stream",uC="application/json",rg=class{constructor(e,t){if(this.DEFAULT_METHOD="POST",t==null&&(t={}),this.weightPathPrefix=t.weightPathPrefix,this.onProgress=t.onProgress,this.weightUrlConverter=t.weightUrlConverter,t.fetchFunc!=null?( $ (typeof t.fetchFunc=="function",()=>"Must pass a function that matches the signature of ` fetch ` (see https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API)"),this.fetch=t.fetchFunc):this.fetch=ne().platform.fetch, $ (e!=null&&e.length>0,()=>"URL path for http must not be null, undefined or empty."),Array.isArray(e)&& $ (e.length===2,()=> ` URL paths for http must have a length of 2 , ( actual length is $ { e . length } ) . ` ),this.path=e,t.requestInit!=null&&t.requestInit.body!=null)throw new Error("requestInit is expected to have no pre-existing body, but has one.");this.requestInit=t.requestInit||{}}async save(e){if(e.modelTopology instanceof ArrayBuffer)throw new Error("BrowserHTTPRequest.save() does not support saving model topology in binary formats yet.");let t=Object.assign({method:this.DEFAULT_METHOD},this.requestInit);t.body=new FormData;let n=[{paths:["./model.weights.bin"],weights:e.weightSpecs}],a=bb(e,n);t.body.append("model.json",new Blob([JSON.stringify(a)],{type:uC}),"model.json"),e.weightData!=null&&t.body.append("model.weights.bin",new Blob([e.weightData],{type:lC}),"model.weights.bin");let r=await this.fetch(this.path,t);if(r.ok)return{modelArtifactsInfo:Vd(e),responses:[r]};throw new Error( ` BrowserHTTPRequest . save ( ) failed due to HTTP response status $ { r . status } . ` )}async load(){let e=await this.fetch(this.path,this.requestInit);if(!e.ok)throw new Error( ` Request to $ { this . path } failed with status code $ { e . status } . Please verify this URL points to the model JSON of the model to load . ` );let t;try{t=await e.json()}catch(r){let s= ` Failed to parse model JSON of response from $ { this . path } . ` ;throw this.path.endsWith(".pb")?s+=" Your path contains a .pb file extension. Support for .pb models have been removed in TensorFlow.js 1.0 in favor of .json models. You can re-convert your Python TensorFlow model using the TensorFlow.js 1.0 conversion scripts or you can convert your.pb models with the 'pb2json'NPM script in the tensorflow/tfjs-converter repository.":s+=" Please make sure the server is serving valid JSON for this request.",new Error(s)}let n=t.modelTopology,a=t.weightsManifest;if(n==null&&a==null)throw new Error( ` The JSON from HTTP path $ { this . path } contains neither model topology or manifest for weights . ` );return Q1(t,r=>this.loadWeights(r))}async loadWeights(e){let t=Array.isArray(this.path)?this.path[1]:this.path,[n,a]=dC(t),r=this.weightPathPrefix||n,s=[];for(let d of e)s.push(...d.weights);let i=[],o=[];for(let d of e)for(let u of d.paths)this.weightUrlConverter!=null?o.push(this.weightUrlConverter(u)):i.push(r+u+a);this.weightUrlConverter&&i.push(...await Promise.all(o));let l=await Mb(i,{requestInit:this.requestInit,fetchFunc:this.fetch,onProgress:this.onProgress});return[s,J1(l)]}};rg.URL_SCHEME_REGEX=/^https?: \/ \/ /;function dC(e){let t=e.lastIndexOf("/"),n=e.lastIndexOf("?"),a=e.substring(0,t),r=n>t?e.substring(n):"";return[a+"/",r]}function sg(e){return e.match(rg.URL_SCHEME_REGEX)!=null}var Db=(e,t)=>{if(typeof fetch=="undefined"&&(t==null||t.fetchFunc==null))return null;{let n=!0;if(Array.isArray(e)?n=e.every(a=>sg(a)):n=sg(e),n)return ig(e,t)}return null};Pt.registerSaveRouter(Db);Pt.registerLoadRouter(Db);function ig(e,t){return new rg(e,t)}function pC(e,t){return ig(e,t)}var og=class
2021-10-04 23:03:36 +02:00
Actual : $ { r } .
2021-10-22 22:09:52 +02:00
Expected : $ { s } . ` );for(let i=0;i<s.length;++i){let o=r[i],l=s[i];if(!n(o,l))throw new Error( ` Arrays differ : actual [ $ { i } ] = $ { o } , expected [ $ { i } ] = $ { l } .
2021-10-04 23:03:36 +02:00
Actual : $ { r } .
2021-10-22 22:09:52 +02:00
Expected : $ { s } . ` )}}function DC(e,t){e().then(()=>t.fail(),()=>t())}function $ C(e,t){let n=typeof t=="string"||typeof t=="number"||typeof t=="boolean"?[t]:t;return is(e)||is(e[0])||is(t)||is(t[0])?hg(e,n,(a,r)=>a==r):hg(e,t,(a,r)=>fg(a,r,0))}function OC(e,t,n){if(n==null&&(n=cg()),!fg(e,t,n))throw new Error( ` Numbers differ : actual === $ { e } , expected === $ { t } ` )}function fg(e,t,n){return!isFinite(e)&&!isFinite(t)?!0:!(isNaN(e)||isNaN(t)||Math.abs(e-t)>n)}function _C(e,t,n){for(let a=0;a<e.length;a++)if(e[a]<t||e[a]>n)throw new Error( ` Value out of range : $ { e [ a ] } low : $ { t } , high : $ { n } ` )}function PC(e,t){expect(new Float32Array(e)).toEqual(new Float32Array(t))}function Qb(e){for(let t=0;t<e.length;t++){let n=e[t];Array.isArray(n)?Qb(n):e[t]= $ d(n)}return e}var Ud="3.10.0";function e3(){ne().set("PROD",!0)}function zC(){ne().set("DEBUG",!0)}function LC(){ne().set("DEPRECATION_WARNINGS_ENABLED",!1),console.warn("TensorFlow.js deprecation warnings have been disabled.")}function mg(e){ne().getBool("DEPRECATION_WARNINGS_ENABLED")&&console.warn(e+" You can disable deprecation warnings with tf.disableDeprecationWarnings().")}pT(mg);function WC(){W.disposeVariables()}function sa(){return W}function Dh(){return W.memory()}function BC(e){return W.profile(e)}function G(e,t){return W.tidy(e,t)}function Q(e){q1(e).forEach(t=>t.dispose())}function pn(e){return W.keep(e)}function VC(e){return W.time(e)}function t3(e){return W.setBackend(e)}function $ h(){return W.ready()}function Ya(){return W.backendName}function UC(e){W.removeBackend(e)}function gg(e){return W.findBackend(e)}function jC(e){return W.findBackendFactory(e)}function au(e,t,n=1){return W.registerBackend(e,t,n)}function mr(){return W.backend}function GC(e,t){ne().setPlatform(e,t)}function HC(e,t){let n=M(e,"a","add"),a=M(t,"b","add");[n,a]=Ft(n,a);let r={a:n,b:a};return W.runKernel(ls,r)}var le=B({add_:HC});function qC(e,t){let n=M(e,"a","floorDiv"),a=M(t,"b","floorDiv");[n,a]=Ft(n,a);let r={a:n,b:a};return W.runKernel(ci,r)}var Oh=B({floorDiv_:qC});function XC(e,t){let n=M(e,"a","div"),a=M(t,"b","div");if([n,a]=Ft(n,a),n.dtype==="int32"&&a.dtype==="int32")return Oh(n,a);let r={a:n,b:a},s={};return W.runKernel(li,r,s)}var he=B({div_:XC});function KC(e,t){let n=M(e,"a","mul"),a=M(t,"b","mul");[n,a]=Ft(n,a);let r={a:n,b:a};return W.runKernel(Si,r)}var L=B({mul_:KC});function ZC(e){let t=M(e,"x","abs");if(t.dtype==="complex64"){let n={x:t};return W.runKernel(xd,n)}else{let n={x:t};return W.runKernel(Ko,n)}}var jt=B({abs_:ZC});function YC(e){let t={x:M(e,"x","acos")};return W.runKernel(Zo,t)}var yg=B({acos_:YC});function JC(e){let t={x:M(e,"x","acosh")};return W.runKernel(Yo,t)}var Ag=B({acosh_:JC});function QC(e){ $ (Array.isArray(e),()=>"The argument passed to tf.addN() must be a list of tensors"), $ (e.length>=1,()=> ` Must pass at least one tensor to tf . addN ( ) , but got $ { e . length } ` );let t=e.map((r,s)=>M(r, ` tensors$ { s } ` ,"addN")),n=t[0];t.forEach(r=>{if(r.dtype!==n.dtype)throw new Error("All tensors passed to tf.addN() must have the same dtype")}),t.forEach(r=>{if(!Dr(r.shape,n.shape))throw new Error("All tensors passed to tf.addN() must have the same shape")});let a=t;return W.runKernel(Zs,a)}var _h=B({addN_:QC});function eE(e,t=null,n=!1){let a={x:M(e,"x","all","bool")},r={axis:t,keepDims:n};return W.runKernel(Jo,a,r)}var Ph=B({all_:eE});function tE(e,t=null,n=!1){let a={x:M(e,"x","any","bool")},r={axis:t,keepDims:n};return W.runKernel(Qo,a,r)}var jd=B({any_:tE});function nE(e,t=0){let n={x:M(e,"x","argMax")},a={axis:t};return W.runKernel(Ys,n,a)}var ka=B({argMax_:nE});function aE(e,t=0){let n={x:M(e,"x","argMin")},a={axis:t};return W.runKernel(yd,n,a)}var xg=B({argMin_:aE});function rE(e){let t={x:M(e,"x","asin")};return W.runKernel(el,t)}var bg=B({asin_:rE});function sE(e){let t={x:M(e,"x","asinh")};return W.runKernel(tl,t)}var vg=B({asinh_:sE});function iE(e){let t={x:M(e,"x","atan")};return W.runKernel(nl,t)}var wg=B({atan_:iE});function oE(e,t){let n=M(e,"a","atan2"),a=M(t,"b","atan2");[n,a]=Ft(n,a);let r={a:n,b:a};return W.runKernel(rl,r)}var kg=B({atan2_:oE});function lE(e){let t
with dtype $ { s . dtype } . ` )}),n.length===1)return Za(n[0]);let a=n,r={axis:t};return W.runKernel(il,a,r)}var mt=B({concat_:AE});function xE(e){let t={x:M(e,"x","sigmoid","float32")};return W.runKernel(Pi,t)}var Kn=B({sigmoid_:xE});function bE(e,t,n){let a=M(e,"x","slice","string_or_numeric");if(a.rank===0)throw new Error("Slicing scalar is not possible");let r={x:a},s={begin:t,size:n};return W.runKernel(zl,r,s)}var De=B({slice_:bE});function vE(e){let t={x:M(e,"x","tanh","float32")};return W.runKernel(ji,t)}var no=B({tanh_:vE});function wE(e,t,n,a,r,s){let i=M(e,"forgetBias","basicLSTMCell"),o=M(t,"lstmKernel","basicLSTMCell"),l=M(n,"lstmBias","basicLSTMCell"),d=M(a,"data","basicLSTMCell"),u=M(r,"c","basicLSTMCell"),p=M(s,"h","basicLSTMCell"),c=mt([d,p],1),h=Ve(c,o),f=le(h,l),m=f.shape[0],g=f.shape[1]/4,y=[m,g],A=De(f,[0,0],y),x=De(f,[0,g],y),b=De(f,[0,g*2],y),v=De(f,[0,g*3],y),k=le(L(Kn(A),no(x)),L(u,Kn(le(i,b)))),T=L(no(k),Kn(v));return[k,T]}var kE=B({basicLSTMCell_:wE});function IE(e,t,n){let a=M(e,"x","batchToSpaceND"),r=t.reduce((o,l)=>o*l); $ (a.rank>=1+t.length,()=> ` input rank is $ { a . rank } but should be > than blockShape . length $ { t . length } ` ), $ (n.length===t.length,()=> ` crops . length is $ { n . length } but should be equal to blockShape . length $ { t . length } ` ), $ (a.shape[0]%r==0,()=> ` input tensor batch is $ { a . shape [ 0 ] } but is not divisible by the product of the elements of blockShape $ { t . join ( " * " ) } === $ { r } ` );let s={x:a},i={blockShape:t,crops:n};return W.runKernel(sl,s,i)}var qd=B({batchToSpaceND_:IE});function SE(e){let t;return e.rank===0||e.rank===1?t=V(e,[1,1,1,e.size]):e.rank===2?t=V(e,[1,1,e.shape[0],e.shape[1]]):e.rank===3?t=V(e,[1,e.shape[0],e.shape[1],e.shape[2]]):t=e,t}function NE(e,t,n,a,r,s){s==null&&(s=.001);let i=M(e,"x","batchNorm"),o=M(t,"mean","batchNorm"),l=M(n,"variance","batchNorm"),d;r!=null&&(d=M(r,"scale","batchNorm"));let u;a!=null&&(u=M(a,"offset","batchNorm")), $ (o.rank===l.rank,()=>"Batch normalization gradient requires mean and variance to have equal ranks."), $ (u==null||o.rank===u.rank,()=>"Batch normalization gradient requires mean and offset to have equal ranks."), $ (d==null||o.rank===d.rank,()=>"Batch normalization gradient requires mean and scale to have equal ranks.");let p={x:SE(i),scale:d,offset:u,mean:o,variance:l},c={varianceEpsilon:s},h=W.runKernel(hi,p,c);return V(h,i.shape)}var ao=B({batchNorm_:NE});function TE(e,t,n,a,r,s){let i=M(e,"x","batchNorm"),o=M(t,"mean","batchNorm"),l=M(n,"variance","batchNorm"),d;r!=null&&(d=M(r,"scale","batchNorm"));let u;return a!=null&&(u=M(a,"offset","batchNorm")), $ (i.rank===2,()=> ` Error in batchNorm2D : x must be rank 2 but got rank $ { i . rank } . ` ), $ (o.rank===2||o.rank===1,()=> ` Error in batchNorm2D : mean must be rank 2 or rank 1 but got rank $ { o . rank } . ` ), $ (l.rank===2||l.rank===1,()=> ` Error in batchNorm2D : variance must be rank 2 or rank 1 but got rank $ { l . rank } . ` ),d!=null&& $ (d.rank===2||d.rank===1,()=> ` Error in batchNorm2D : scale must be rank 2 or rank 1 but got rank $ { d . rank } . ` ),u!=null&& $ (u.rank===2||u.rank===1,()=> ` Error in batchNorm2D : offset must be rank 2 or rank 1 but got rank $ { u . rank } . ` ),ao(i,o,l,u,d,s)}var s3=B({batchNorm2d_:TE});function CE(e,t,n,a,r,s){let i=M(e,"x","batchNorm"),o=M(t,"mean","batchNorm"),l=M(n,"variance","batchNorm"),d;r!=null&&(d=M(r,"scale","batchNorm"));let u;return a!=null&&(u=M(a,"offset","batchNorm")), $ (i.rank===3,()=> ` Error in batchNorm3D : x must be rank 3 but got rank $ { i . rank } . ` ), $ (o.rank===3||o.rank===1,()=> ` Error in batchNorm3D : mean must be rank 3 or rank 1 but got rank $ { o . rank } . ` ), $ (l.rank===3||l.rank===1,()=> ` Error in batchNorm3D : variance must be rank 3 or rank 1 but got rank $ { l . rank } . ` ),d!=null&& $ (d.rank===3||d.rank===1,()=> ` Error in batchNorm3D : scale must be rank 3 or rank 1 but got rank $ { d . rank } . ` ),u!=null&& $ (u.rank===3||u.rank===1,()=> ` Error in batchNorm3D : offset must be rank 3 or rank 1 but got rank $ { u . rank } . ` ),ao(i,o,l,u,d,s)}var i3=B({batchNorm3d_:CE});function EE(e,t,n,a,r,s){let i=M(e,"x","batchNorm"),o=M(t,"mean","batchNorm"),l=M(n,"variance","batchNorm"),d;r!=null&&(d=M(r,"scale","batchNorm
2021-10-04 23:03:36 +02:00
$ { r } and $ { t } for depthToSpace with input shape
2021-10-22 22:09:52 +02:00
$ { a . shape } ` ), $ (s*t>=0,()=> ` Negative dimension size caused by overflow when multiplying
$ { s } and $ { t } for depthToSpace with input shape
$ { a . shape } ` ), $ (i%(t*t)==0,()=> ` Dimension size must be evenly divisible by $ { t * t } but is $ { i } for depthToSpace with input shape $ { a . shape } ` );let o={x:a},l={blockSize:t,dataFormat:n};return W.runKernel(ll,o,l)}var Fg=B({depthToSpace_:ZE});function YE(e,t,n,a,r="NHWC",s=[1,1],i){let o=M(e,"x","depthwiseConv2d","float32"),l=M(t,"filter","depthwiseConv2d","float32"),d=o,u=!1;o.rank===3&&(u=!0,d=V(o,[1,o.shape[0],o.shape[1],o.shape[2]])), $ (d.rank===4,()=> ` Error in depthwiseConv2d : input must be rank 4 , but got rank $ { d . rank } . ` ), $ (l.rank===4,()=> ` Error in depthwiseConv2d : filter must be rank 4 , but got rank $ { l . rank } . ` ), $ (d.shape[3]===l.shape[2],()=> ` Error in depthwiseConv2d : number of input channels ( $ { d . shape [ 3 ] } ) must match the inChannels dimension in filter $ { l . shape [ 2 ] } . ` ),i!=null&& $ (un(a),()=> ` Error in depthwiseConv2d : pad must be an integer when using , dimRoundingMode $ { i } but got pad $ { a } . ` );let p={x:d,filter:l},c={strides:n,pad:a,dataFormat:r,dilations:s,dimRoundingMode:i},h=W.runKernel(oi,p,c);return u?V(h,[h.shape[1],h.shape[2],h.shape[3]]):h}var ou=B({depthwiseConv2d_:YE});function JE(e){let t={x:M(e,"x","diag")};return W.runKernel(Yc,t)}var QE=B({diag_:JE});function eR(e,t,n,a,r=[1,1],s="NHWC"){let i=M(e,"x","dilation2d"),o=M(t,"filter","dilation2d"); $ (i.rank===3||i.rank===4,()=> ` Error in dilation2d : input must be rank 3 or 4 , but got rank $ { i . rank } . ` ), $ (o.rank===3,()=> ` Error in dilation2d : filter must be rank 3 , but got rank $ { o . rank } . ` ), $ (s==="NHWC",()=> ` Error in dilation2d : Only NHWC is currently supported , but got dataFormat of $ { s } ` );let l=i,d=!1;i.rank===3&&(l=V(i,[1,i.shape[0],i.shape[1],i.shape[2]]),d=!0);let u={x:l,filter:o},p={strides:n,pad:a,dilations:r},c=W.runKernel(vd,u,p);return d?V(c,[c.shape[1],c.shape[2],c.shape[3]]):c}var Dg=B({dilation2d_:eR});function tR(e,t){let n=e.length,a=[];for(let r=0;r<n;r++){let s=n-1-r,i=e[s]||1;(t[t.length-1-r]||1)>1&&i===1&&a.unshift(s)}return a}function Qt(e,t){let n=[];for(let a=0;a<t.length;a++){let r=e[e.length-a-1],s=t.length-a-1,i=t[s];(r==null||r===1&&i>1)&&n.unshift(s)}return n}function bt(e,t){let n=[],a=Math.max(e.length,t.length);for(let r=0;r<a;r++){let s=e[e.length-r-1];s==null&&(s=1);let i=t[t.length-r-1];if(i==null&&(i=1),s===1)n.unshift(i);else if(i===1)n.unshift(s);else if(s!==i){let o= ` Operands could not be broadcast together with shapes $ { e } and $ { t } . ` ;throw Error(o)}else n.unshift(s)}return n}function nR(e,t){let n=M(e,"a","equal","string_or_numeric"),a=M(t,"b","equal","string_or_numeric");[n,a]=Ft(n,a),bt(n.shape,a.shape);let r={a:n,b:a};return W.runKernel(dl,r)}var ia=B({equal_:nR});function aR(e,t,n){let a=M(t,"a","where"),r=M(n,"b","where"),s=M(e,"condition","where","bool"),i=bt(bt(s.shape,a.shape),r.shape),o=su(s,i),l=su(a,i),d=su(r,i),u={condition:o,t:l,e:d};return W.runKernel(_l,u)}var Sn=B({where_:aR});function rR(e){let t={x:M(e,"x","zerosLike")};return W.runKernel(Xl,t)}var Ye=B({zerosLike_:rR});function sR(e,t){let n=M(e,"a","div"),a=M(t,"b","div");[n,a]=Ft(n,a);let r=he(n,a),s=Ye(r),i=ia(a,s);return Sn(i,s,r)}var $ g=B({divNoNan_:sR});function iR(e,t){let n=M(e,"t1","dot"),a=M(t,"t2","dot"); $ ((n.rank===1||n.rank===2)&&(a.rank===1||a.rank===2),()=> ` Error in dot : inputs must all be rank 1 or 2 , but got ranks $ { n . rank } and $ { a . rank } . ` );let r=n.rank===1?n.size:n.shape[1],s=a.rank===1?a.size:a.shape[0];if( $ (r===s,()=> ` Error in dot : inner dimensions of inputs must match , but got $ { r } and $ { s } . ` ),n.rank===1&&a.rank===1){let i=V(n,[1,-1]),o=V(a,[-1,1]),l=Ve(i,o);return V(l,[])}else if(n.rank===1&&a.rank===2){let i=V(n,[1,-1]),o=V(a,[a.shape[0],a.shape[1]]),l=Ve(i,o);return V(l,[l.size])}else if(n.rank===2&&a.rank===1){let i=V(a,[-1,1]),o=Ve(n,i);return V(o,[o.size])}else{let i=V(a,[a.shape[0],a.shape[1]]);return Ve(n,i)}}var m3=B({dot_:iR});function oR(e,...t){let n=t.map((r,s)=>M(r, ` tensors$ { s } ` ,"einsum")),a={equation:e};return W.runKernel(eh,n,a)}var g3=B({einsum_:oR});function lR(e){let t={x:M(e,"x","elu","float32")};return W.runKernel(ui,t)}var lu=B({elu_:lR});function uR(e){let t=M(e,"x","erf"); $ (t.dtype==="int32"||t.dtype==="floa
rank $ { s . rank } . ` ), $ (un(t),()=> ` Error in localResponseNormalization : depthRadius must be an integer but got depthRadius $ { t } . ` );let i=s,o=!1;s.rank===3&&(o=!0,i=V(s,[1,s.shape[0],s.shape[1],s.shape[2]]));let l={x:i},d={depthRadius:t,bias:n,alpha:a,beta:r},u=W.runKernel(Sd,l,d);return o?V(u,[u.shape[1],u.shape[2],u.shape[3]]):u}var Lg=B({localResponseNormalization_:NR});function TR(e){let t={x:M(e,"x","log","float32")};return W.runKernel(yi,t)}var la=B({log_:TR});function CR(e){let t={x:M(e,"x","log1p")};return W.runKernel(wl,t)}var Zd=B({log1p_:CR});function ER(e){return $ (os(e),()=>"The f passed in grad(f) must be a function"),(t,n)=>{let a=M(t,"x","tf.grad","string_or_numeric"),r=n!=null?M(n,"dy","tf.grad"):null;return W.tidy(()=>{let{value:s,grads:i}=W.gradients(()=>e(a),[a],r);return r!=null&&Tn(s.shape,r.shape,"The shape of dy passed in grad(f)(x, dy) must match the shape returned by f(x)"),Gh(i),i[0]})}}function RR(e){return $ (os(e),()=>"The f passed in grads(f) must be a function"),(t,n)=>{ $ (Array.isArray(t),()=>"The args passed in grads(f)(args) must be an array of ` Tensor ` s or ` TensorLike ` s");let a=Bd(t,"args","tf.grads","string_or_numeric"),r=n!=null?M(n,"dy","tf.grads"):null;return W.tidy(()=>{let{value:s,grads:i}=W.gradients(()=>e(...a),a,r);return r!=null&&Tn(s.shape,r.shape,"The shape of dy passed in grads(f)([x1,...], dy) must match the shape returned by f([x1,...])"),Gh(i),i})}}function MR(e){return $ (os(e),()=>"The f passed in valueAndGrad(f) must be a function"),(t,n)=>{ $ (t instanceof je,()=>"The x passed in valueAndGrad(f)(x) must be a tensor"), $ (n==null||n instanceof je,()=>"The dy passed in valueAndGrad(f)(x, dy) must be a tensor");let{grads:a,value:r}=W.gradients(()=>e(t),[t],n);return Gh(a),{grad:a[0],value:r}}}function FR(e){return $ (os(e),()=>"The f passed in valueAndGrads(f) must be a function"),(t,n)=>{ $ (Array.isArray(t)&&t.every(r=>r instanceof je),()=>"The args passed in valueAndGrads(f)(args) must be array of tensors"), $ (n==null||n instanceof je,()=>"The dy passed in valueAndGrads(f)(args, dy) must be a tensor");let a=W.gradients(()=>e(...t),t,n);return n!=null&&Tn(a.value.shape,n.shape,"The shape of dy passed in valueAndGrads(f)([x1,...], dy) must match the shape returned by f([x1,...])"),Gh(a.grads),a}}function b3(e,t){ $ (os(e),()=>"The f passed in variableGrads(f) must be a function"), $ (t==null||Array.isArray(t)&&t.every(d=>d instanceof zd),()=>"The varList passed in variableGrads(f, varList) must be an array of variables");let n=t!=null;if(!n){t=[];for(let d in W.registeredVariables)t.push(W.registeredVariables[d])}let a=n?t.filter(d=>!d.trainable):null,r=t.length;t=t.filter(d=>d.trainable), $ (t.length>0,()=> ` variableGrads ( ) expects at least one of the input variables to be trainable , but none of the $ { r } variables is trainable . ` );let s=!0,{value:i,grads:o}=W.gradients(e,t,null,s); $ (o.some(d=>d!=null),()=>"Cannot find a connection between any variable and the result of the loss function y=f(x). Please make sure the operations that use variables are inside the function f passed to minimize()."), $ (i.rank===0,()=> ` The f passed in variableGrads ( f ) must return a scalar , but it returned a rank - $ { i . rank } tensor ` );let l={};return t.forEach((d,u)=>{o[u]!=null&&(l[d.name]=o[u])}),a!=null&&a.forEach(d=>l[d.name]=null),{value:i,grads:l}}function yr(e){return W.customGrad(e)}function Gh(e){if(e.filter(t=>t==null).length>0)throw new Error( ` Cannot compute gradient of y = f ( x ) with respect to x . Make sure that
the f you passed encloses all operations that lead from x to y . ` )}function DR(e){let t={x:M(e,"x","neg")};return W.runKernel(Sl,t)}var Tt=B({neg_:DR});function $ R(e){let t={x:M(e,"x","softplus")};return W.runKernel(Bl,t)}var so=B({softplus_: $ R});function OR(e){let t=M(e,"x","logSigmoid");return yr(n=>({value:Tt(so(Tt(n))),gradFunc:a=>L(a,Kn(Tt(n)))}))(t)}var v3=B({logSigmoid_:OR});function _R(e,t=null,n=!1){let a={x:M(e,"x","max")},r={reductionIndices:t,keepDims:n};return W.runKernel(Ai,a,r)}var Rn=B({max_:_R});function PR(e,t){let n=M(e,"a","sub"),a=M(t,"b","sub");[n,a]=Ft(n,a);let r={a:n,b:a};return W.runKernel(Vi,r)}var ge=B({sub_:PR});function zR(e,t=null,n=!1){let a=M(e,"x","sum");a.dtype==="bool"&&(a=pe(a,"int32"));let r={x:a},s={axis:t,keepDims:n};return W.runKernel(Li,r,s)}var Ie=B({sum_:zR});function LR(e,t=-1){let n=M(e,"logits","logSoftmax");if(t===-1&&(t=n.rank-1),t!==n.rank-1)throw Error( ` Log Softmax along a non - last dimension is not yet supported . Logits was rank $ { n . rank } and axis was $ { t } ` );return yr((a,r)=>{let s=!0,i=Rn(a,t,!0),o=ge(a,i),l=ge(pe(o,"float32"),la(Ie(oa(o),t,s)));return r([l]),{value:l,gradFunc:(d,u)=>{let[p]=u,c=!0,h=oa(p);return ge(d,L(Ie(d,t,c),h))}}})(n)}var Hh=B({logSoftmax_:LR});function Wg(e,t){for(let n=0;n<e.length;++n)if(e[e.length-n-1]!==t-1-n)return!1;return!0}function w3(e,t,n){let a=e.length+t.length,r=[],s=0,i=0;for(let o=0;o<a;o++)n.indexOf(o)===-1?r.push(e[s++]):r.push(t[i++]);return r}function k3(e,t){let n=[],a=e.length;for(let s=0;s<a;s++)t.indexOf(s)===-1&&n.push(e[s]);let r=t.map(s=>e[s]);return[n,r]}function io(e,t){let n=t.map(a=>1);return w3(e,n,t)}function WR(e,t,n){ $ (Wg(t,n),()=> ` $ { e } supports only inner - most axes for now . Got axes $ { t } and rank - $ { n } input . ` )}function I3(e,t){if(Wg(e,t))return null;let n=[];for(let a=0;a<t;++a)e.indexOf(a)===-1&&n.push(a);return e.forEach(a=>n.push(a)),n}function Bg(e){return e.map((t,n)=>[n,t]).sort((t,n)=>t[1]-n[1]).map(t=>t[0])}function BR(e,t){let n=[];for(let a=t-e;a<t;++a)n.push(a);return n}function VR(e,t=null,n=!1){let a=M(e,"x","logSumExp"),r=_a(t,a.shape),s=Rn(a,r,!0),i=ge(a,s),o=oa(i),l=Ie(o,r),d=la(l),u=le(V(s,d.shape),d);if(n){let p=io(u.shape,r);return V(u,p)}return u}var Vg=B({logSumExp_:VR});function UR(e,t){let n=M(e,"a","logicalAnd","bool"),a=M(t,"b","logicalAnd","bool");bt(n.shape,a.shape);let r={a:n,b:a};return W.runKernel(kl,r)}var La=B({logicalAnd_:UR});function jR(e){let t={x:M(e,"x","logicalNot","bool")};return W.runKernel(kd,t)}var Yd=B({logicalNot_:jR});function GR(e,t){let n=M(e,"a","logicalOr","bool"),a=M(t,"b","logicalOr","bool");bt(n.shape,a.shape);let r={a:n,b:a};return W.runKernel(Id,r)}var qh=B({logicalOr_:GR});function HR(e,t){let n=M(e,"a","logicalXor","bool"),a=M(t,"b","logicalXor","bool");return bt(n.shape,a.shape),La(qh(e,t),Yd(La(e,t)))}var S3=B({logicalXor_:HR});function qR(e,t,n,a,r){let s=M(e,"x","maxPool"),i=1,o=s,l=!1;s.rank===3&&(l=!0,o=V(s,[1,s.shape[0],s.shape[1],s.shape[2]])), $ (o.rank===4,()=> ` Error in maxPool : input must be rank 4 but got rank $ { o . rank } . ` ), $ (gr(n,i),()=> ` Error in maxPool : Either strides or dilations must be 1. Got strides $ { n } and dilations '${i}' ` ),r!=null&& $ (un(a),()=> ` Error in maxPool : pad must be an integer when using , dimRoundingMode $ { r } but got pad $ { a } . ` );let d={x:o},u={filterSize:t,strides:n,pad:a,dimRoundingMode:r},p=W.runKernel(bi,d,u);return l?V(p,[p.shape[1],p.shape[2],p.shape[3]]):p}var Jd=B({maxPool_:qR});function XR(e,t=[1,1,1],n,a,r,s="NDHWC"){let i=M(e,"x","maxPool3d"),o=i,l=!1;i.rank===4&&(l=!0,o=V(i,[1,i.shape[0],i.shape[1],i.shape[2],i.shape[3]])), $ (o.rank===5,()=> ` Error in maxPool3d : x must be rank 5 but got rank $ { o . rank } . ` ), $ (s==="NDHWC",()=> ` Error in maxPool3d : Only NDHWC is currently supported , but got dataFormat of $ { s } ` ),r!=null&& $ (un(a),()=> ` Error in maxPool3d : pad must be an integer when using , dimRoundingMode $ { r } but got pad $ { a } . ` );let d={x:o},u={filterSize:t,strides:n,pad:a,dimRoundingMode:r,dataFormat:s},p=W.runKernel(Nd,d,u);return l?V(p,[p.shape[1],p.shape[2],p.shape[3],p.shape[4]]):p}var Ug=B({maxPool3d_:XR});function KR(e
$ { r . shape } ` );if(s.rank!==1)throw new Error( ` Values should be Tensor1D but received shape $ { s . shape } ` );if(i.rank!==1)throw new Error( ` Dense shape should be Tensor1D but received shape $ { i . shape } ` );if(o.rank!==0)throw new Error( ` Default value should be a scalar but received shape $ { o . shape } ` );let l={indices:r,values:s,denseShape:i,defaultValue:o},d=W.runKernel(fh,l);return{outputIndices:d[0],outputValues:d[1],emptyRowIndicator:d[2],reverseIndexMap:d[3]}}var l $ =B({sparseFillEmptyRows_:o $ });function u $ (e,t,n){let a=M(e,"inputIndices","sparseReshape"),r=M(t,"inputShape","sparseReshape"),s=M(n,"newShape","sparseReshape");if(a.rank!==2)throw new Error( ` Input indices should be Tensor2D but received shape
$ { a . shape } ` );if(r.rank!==1)throw new Error( ` Input shape should be Tensor1D but received shape $ { r . shape } ` );if(s.rank!==1)throw new Error( ` New shape should be Tensor1D but received shape $ { s . shape } ` );let i={inputIndices:a,inputShape:r,newShape:s},o=W.runKernel(mh,i);return{outputIndices:o[0],outputShape:o[1]}}var d $ =B({sparseReshape_:u $ });function p $ (e,t,n){let a=M(e,"data","sparseSegmentMean"),r=M(t,"indices","sparseSegmentMean"),s=M(n,"segmentIds","sparseSegmentMean");if(a.rank<1)throw new Error("Data should be at least 1 dimensional but received scalar");if(r.rank!==1)throw new Error( ` Indices should be Tensor1D but received shape
$ { r . shape } ` );if(s.rank!==1)throw new Error( ` Segment ids should be Tensor1D but received shape
$ { s . shape } ` );let i={data:a,indices:r,segmentIds:s};return W.runKernel(gh,i)}var c $ =B({sparseSegmentMean_:p $ });function h $ (e,t,n){let a=M(e,"data","sparseSegmentSum"),r=M(t,"indices","sparseSegmentSum"),s=M(n,"segmentIds","sparseSegmentSum");if(a.rank<1)throw new Error("Data should be at least 1 dimensional but received scalar");if(r.rank!==1)throw new Error( ` Indices should be Tensor1D but received shape
$ { r . shape } ` );if(s.rank!==1)throw new Error( ` Segment ids should be Tensor1D but received shape
$ { s . shape } ` );let i={data:a,indices:r,segmentIds:s};return W.runKernel(yh,i)}var f $ =B({sparseSegmentSum_:h $ });function m $ (e,t,n,a,r,s,i,o){let l=M(e,"data","stringNGrams","string");if(l.dtype!=="string")throw new Error("Data must be of datatype string");if(l.shape.length!==1)throw new Error( ` Data must be a vector , saw : $ { l . shape } ` );let d=M(t,"dataSplits","stringNGrams");if(d.dtype!=="int32")throw new Error("Data splits must be of datatype int32");let u={separator:n,nGramWidths:a,leftPad:r,rightPad:s,padWidth:i,preserveShortSequences:o},p={data:l,dataSplits:d},c=W.runKernel(xh,p,u);return{nGrams:c[0],nGramsSplits:c[1]}}var g $ =B({stringNGrams_:m $ });function y $ (e,t,n=!0){let a=M(e,"input","stringSplit","string"),r=M(t,"delimiter","stringSplit","string");if(a.rank!==1)throw new Error( ` Input should be Tensor1D but received shape $ { a . shape } ` );if(r.rank!==0)throw new Error( ` Delimiter should be a scalar but received shape $ { r . shape } ` );let s={skipEmpty:n},i={input:a,delimiter:r},o=W.runKernel(bh,i,s);return{indices:o[0],values:o[1],shape:o[2]}}var A $ =B({stringSplit_:y $ });function x $ (e,t){let n=M(e,"input","stringToHashBucketFast","string"),a={numBuckets:t};if(t<=0)throw new Error("Number of buckets must be at least 1");let r={input:n};return W.runKernel(vh,r,a)}var b $ =B({stringToHashBucketFast_:x $ }),v $ ={fft:rp,ifft:mu,rfft:sp,irfft:a0},w $ ={hammingWindow:JF,hannWindow:W3,frame:B3,stft:nD},Me={flipLeftRight:iD,grayscaleToRGB:lD,resizeNearestNeighbor:q3,resizeBilinear:H3,rotateWithOffset:dD,cropAndResize:rD,nonMaxSuppression:cD,nonMaxSuppressionAsync:bD,nonMaxSuppressionWithScore:wD,nonMaxSuppressionWithScoreAsync:ID,nonMaxSuppressionPadded:ND,nonMaxSuppressionPaddedAsync:CD,threshold:DD,transform:OD},K3={bandPart:PD,gramSchmidt:LD,qr:BD},k $ ={absoluteDifference:jD,computeWeightedLoss:zr,cosineDistance:HD,hingeLoss:XD,huberLoss:ZD,logLoss:JD,meanSquaredError:e $ ,sigmoidCrossEntropy:a $ ,softmaxCrossEntropy:i $ },ip={sparseFillEmptyRows:l $ ,sparseReshape:d $ ,sparseSegmentMean:c $ ,sparseSegmentSum:f $ },c0={stringNGrams:g $ ,stringSplit:A $ ,stringToHashBucketFast:b $ },Lr=class extends Zb{minimize(e,t=!1,n){let{value:a,grads:r}=this.computeGradients(e,n);if(n!=null){let s=n.map(i=>({name:i.name,tensor:r[i.name]}));this.applyGradients(s)}else this.applyGradients(r);return Q(r),t?a:(a.dispose(),null)}get iterations(){return this.iterations_==null&&(this.iterations_=0),this.iterations_}incrementIterations(){this.iterations_=this.iterations+1}computeGradients(e,t){return b3(e,t)}dispose(){this.iterations_!=null&&Q(this.iterations_)}async saveIterations(){return this.iterations_==null&&(this.iterations_=0),{name:"iter",tensor:Ce(this.iterations_,"int32")}}async getWeights(){throw new Error("getWeights() is not implemented for this optimizer yet.")}async setWeights(e){throw new Error( ` setWeights ( ) is not implemented for this optimizer class $ { this . getClassName ( ) } ` )}async extractIterations(e){return this.iterations_=(await e[0].tensor.data())[0],e.slice(1)}};Object.defineProperty(Lr,Symbol.hasInstance,{value:e=>e.minimize!=null&&e.computeGradients!=null&&e.applyGradients!=null});var h0=class extends Lr{constructor(e,t,n=null){super();this.learningRate=e,this.rho=t,this.epsilon=n,this.accumulatedGrads=[],this.accumulatedUpdates=[],n==null&&(this.epsilon=W.backend.epsilon())}applyGradients(e){(Array.isArray(e)?e.map(t=>t.name):Object.keys(e)).forEach((t,n)=>{let a=W.registeredVariables[t],r=!1;this.accumulatedGrads[n]==null&&(this.accumulatedGrads[n]={originalName: ` $ { t } / accum _grad ` ,variable:G(()=>Ye(a).variable(r))}),this.accumulatedUpdates[n]==null&&(this.accumulatedUpdates[n]={originalName: ` $ { t } / accum _var ` ,variable:G(()=>Ye(a).variable(r))});let s=Array.isArray(e)?e[n].tensor:e[t];if(s==null)return;let i=this.accumulatedGrads[n].variable,o=this.accumulatedUpdates[n].variable;G(()=>{let l=le(L(i,this.rho),L(ht(s),1-this.rho)),d=L(he(An(le(o,this.epsilon)),An(le(i,this.epsilon))),s),u=le(L(o,this.rho),L(ht(d),1-this.rho));i.assign(l),o.assign(u);let p=le(L(d,-this.learningRate),a);a.assign(p)})}),this.incrementIterations()}dispose(){this.accumulatedU
$ { s } ) . ` );if(n<a)throw new Error( ` batchDims ( $ { a } ) must be less than or equal to axis ( $ { n } ) . ` );for(let p=0;p<a;++p)if(e.shape[p]!==t.shape[p])throw new Error( ` x . shape [ $ { p } ] : $ { e . shape [ p ] } should be equal to indices . shape [ $ { p } ] : $ { t . shape [ p ] } . ` );let i=e.shape[n],o=[],l=1,d=1,u=1;for(let p=0;p<a;++p)o.push(e.shape[p]),l*=e.shape[p];for(let p=a;p<n;p++)o.push(e.shape[p]),d*=e.shape[p];for(let p=a;p<r;p++)o.push(t.shape[p]);for(let p=n+1;p<s;p++)o.push(e.shape[p]),u*=e.shape[p];return{batchSize:l,sliceSize:u,outerSize:d,dimSize:i,outputShape:o}}function sO(e){try{return e.map(t=>Th(t))}catch(t){throw new Error( ` Failed to decode encoded string bytes into utf - 8 , error : $ { t } ` )}}function iO(e){return e.map(t=> $ d(t))}var xr={};ze(xr,{nonMaxSuppressionV3Impl:()=>V3,nonMaxSuppressionV4Impl:()=>U3,nonMaxSuppressionV5Impl:()=>j3,whereImpl:()=>F3});var nv={kernelName:Ko,inputsToSave:["x"],gradFunc:(e,t)=>{let[n]=t;return{x:()=>L(e,gu(pe(n,"float32"),-1))}}},oO={kernelName:Zo,inputsToSave:["x"],gradFunc:(e,t)=>{let[n]=t;return{x:()=>{let a=ht(pe(n,"float32")),r=An(ge(Ce(1),a));return Tt(he(e,r))}}}},lO={kernelName:Yo,inputsToSave:["x"],gradFunc:(e,t)=>{let[n]=t;return{x:()=>{let a=An(ge(ht(pe(n,"float32")),1));return he(e,a)}}}},uO={kernelName:ls,inputsToSave:["a","b"],gradFunc:(e,t)=>{let[n,a]=t,r=bt(n.shape,a.shape);return{a:()=>{let s=e,i=Qt(n.shape,r);return i.length>0&&(s=Ie(s,i)),V(s,n.shape)},b:()=>{let s=e,i=Qt(a.shape,r);return i.length>0&&(s=Ie(s,i)),V(s,a.shape)}}}},dO={kernelName:Zs,saveAllInputs:!0,gradFunc:(e,t)=>{let n={};return t.forEach((a,r)=>{n[r]=()=>e.clone()}),n}},pO={kernelName:Ys,inputsToSave:["x"],gradFunc:(e,t)=>{let[n]=t;return{x:()=>Ye(n)}}},cO={kernelName:yd,inputsToSave:["x"],gradFunc:(e,t)=>{let[n]=t;return{x:()=>Ye(n)}}},hO={kernelName:el,inputsToSave:["x"],gradFunc:(e,t)=>{let[n]=t;return{x:()=>he(e,An(ge(Ce(1),ht(pe(n,"float32")))))}}},fO={kernelName:tl,inputsToSave:["x"],gradFunc:(e,t)=>{let[n]=t;return{x:()=>{let a=An(le(Ce(1),ht(pe(n,"float32"))));return he(e,a)}}}},mO={kernelName:rl,inputsToSave:["a","b"],gradFunc:(e,t)=>{let[n,a]=t,r=bt(n.shape,a.shape);return{a:()=>{let s=le(ht(n),ht(a)),i=L(e,he(a,s)),o=Qt(n.shape,r);return o.length>0&&(i=Ie(i,o)),V(i,n.shape)},b:()=>{let s=le(ht(n),ht(a)),i=Tt(L(e,he(n,s))),o=Qt(a.shape,r);return o.length>0&&(i=Ie(i,o)),V(i,a.shape)}}}},gO={kernelName:nl,inputsToSave:["x"],gradFunc:(e,t)=>{let[n]=t;return{x:()=>he(e,le(ht(pe(n,"float32")),1))}}},yO={kernelName:al,inputsToSave:["x"],gradFunc:(e,t)=>{let[n]=t;return{x:()=>he(e,ge(Ce(1),ht(pe(n,"float32"))))}}};function AO(e,t,n,a,r,s){let i=M(e,"dy","avgPool3dGrad"),o=M(t,"input","avgPool3dGrad"),l=i,d=o,u=!1;o.rank===4&&(u=!0,l=V(i,[1,i.shape[0],i.shape[1],i.shape[2],i.shape[3]]),d=V(o,[1,o.shape[0],o.shape[1],o.shape[2],o.shape[3]])), $ (l.rank===5,()=> ` Error in avgPool3dGrad : dy must be rank 5 but got rank $ { l . rank } . ` ), $ (d.rank===5,()=> ` Error in avgPool3dGrad : input must be rank 5 but got rank $ { d . rank } . ` ),s!=null&& $ (un(r),()=> ` Error in avgPool3dGrad : pad must be an integer when using , dimRoundingMode $ { s } but got pad $ { r } . ` );let p={dy:l,input:d},c={filterSize:n,strides:a,pad:r,dimRoundingMode:s},h=W.runKernel(Bc,p,c);return u?V(h,[h.shape[1],h.shape[2],h.shape[3],h.shape[4]]):h}var xO=B({avgPool3dGrad_:AO}),bO={kernelName:Ad,inputsToSave:["x"],gradFunc:(e,t,n)=>{let[a]=t,{filterSize:r,strides:s,pad:i,dimRoundingMode:o}=n;return{x:()=>xO(e,a,r,s,i,o)}}};function vO(e,t,n,a,r){let s=M(e,"dy","avgPoolGrad"),i=M(t,"input","avgPoolGrad"); $ (i.rank===s.rank,()=> ` Rank of input ( $ { i . rank } ) does not match rank of dy ( $ { s . rank } ) ` );let o=i,l=s,d=!1;i.rank===3&&(d=!0,o=V(i,[1,i.shape[0],i.shape[1],i.shape[2]]),l=V(s,[1,s.shape[0],s.shape[1],s.shape[2]])), $ (l.rank===4,()=> ` Error in avgPoolGrad : dy must be rank 4 but got rank $ { l . rank } . ` ), $ (o.rank===4,()=> ` Error in avgPoolGrad : input must be rank 4 but got rank $ { o . rank } . ` );let u={dy:l,input:o},p={filterSize:n,strides:a,pad:r},c=W.runKernel(Wc,u,p);return d?V(c,[c.shape[1],c.shape[2],c.shape[3]]):c}var wO=B({avgPoolGrad_:vO}),kO={kernelName:Js,inputsToSave:["x"],gradFunc
1. The $ { a } is defined in Python , in which case it needs to be ported to TensorFlow . js or your JavaScript code .
2. The custom $ { a } is defined in JavaScript , but is not registered properly with tf . serialization . registerClass ( ) . ` );return i}else{let s=e;if(s.className==null||s.config==null)throw new H( ` $ { a } : Improper config format : $ { JSON . stringify ( s ) } .
'className' and 'config' must set . ` );let i=s.className,o,l;if(i in n?[o,l]=n[i]:i in Wa?[o,l]=Wa.className:i in t&&([o,l]=t[i]),o==null)throw new H( ` Unknown $ { a } : $ { i } . This may be due to one of the following reasons :
1. The $ { a } is defined in Python , in which case it needs to be ported to TensorFlow . js or your JavaScript code .
2. The custom $ { a } is defined in JavaScript , but is not registered properly with tf . serialization . registerClass ( ) . ` );if(l!=null){let d={};for(let h of Object.keys(Wa))d[h]=Wa[h];for(let h of Object.keys(n))d[h]=n[h];let u=s.config;u.customObjects=d;let p=Object.assign({},Wa);for(let h of Object.keys(n))Wa[h]=n[h];py(s.config);let c=l(o,s.config,n,r);return Wa=Object.assign({},p),c}else{let d=Object.assign({},Wa);for(let p of Object.keys(n))Wa[p]=n[p];let u=new o(s.config);return Wa=Object.assign({},d),u}}}function lP(e,t){return e<t?-1:e>t?1:0}function x0(e,t){return-1*lP(e,t)}function ws(e){if(e==null)return e;let t=[];for(let n of e)t.indexOf(n)===-1&&t.push(n);return t}function uP(e){if(e==null)throw new H( ` Invalid value in obj : $ { JSON . stringify ( e ) } ` );for(let t in e)if(e.hasOwnProperty(t))return!1;return!0}function fo(e,t,n){if(n!=null&&e.indexOf(n)<0)throw new H( ` $ { n } is not a valid $ { t } . Valid values are $ { e } or null / undefined . ` )}function cy(e,t,n=0,a=1/0){return br(n>=0),br(a>=n),Array.isArray(e)&&e.length>=n&&e.length<=a&&e.every(r=>typeof r===t)}function hn(e,t){Array.isArray(e)?(w.assert(e.length>0,()=> ` $ { t } is unexpectedly an empty array . ` ),e.forEach((n,a)=>hn(n, ` element $ { a + 1 } of $ { t } ` ))):w.assert(Number.isInteger(e)&&e>0,()=> ` Expected $ { t } to be a positive integer , but got $ { hv ( e ) } . ` )}function hv(e){return e===null?"null":Array.isArray(e)?"["+e.map(t=>hv(t)).join(",")+"]":typeof e=="string"? ` "${e}" ` : ` $ { e } ` }function dP(e,t,n){let a=n!=null?n():w.now(),r;return(...s)=>{let i=n!=null?n():w.now();return i-a<t||(a=i,r=e(...s)),r}}function fv(e){return e==="relu"?"relu":e==="linear"?"linear":e==="elu"?"elu":null}function hy(e,t){return G(()=>An(Ie(L(e,e),t,!0)))}var up=class extends ue.Serializable{getConfig(){return{}}},fy=class extends up{constructor(e){super();this.defaultMaxValue=2,this.defaultAxis=0,this.maxValue=e.maxValue!=null?e.maxValue:this.defaultMaxValue,this.axis=e.axis!=null?e.axis:this.defaultAxis}apply(e){return G(()=>{let t=hy(e,this.axis),n=Zn(t,0,this.maxValue);return L(e,he(n,le(en(),t)))})}getConfig(){return{maxValue:this.maxValue,axis:this.axis}}};fy.className="MaxNorm";ue.registerClass(fy);var my=class extends up{constructor(e){super();this.defaultAxis=0,this.axis=e.axis!=null?e.axis:this.defaultAxis}apply(e){return G(()=>he(e,le(en(),hy(e,this.axis))))}getConfig(){return{axis:this.axis}}};my.className="UnitNorm";ue.registerClass(my);var gy=class extends up{apply(e){return Ja(e)}};gy.className="NonNeg";ue.registerClass(gy);var yy=class extends up{constructor(e){super();this.defaultMinValue=0,this.defaultMaxValue=1,this.defaultRate=1,this.defaultAxis=0,this.minValue=e.minValue!=null?e.minValue:this.defaultMinValue,this.maxValue=e.maxValue!=null?e.maxValue:this.defaultMaxValue,this.rate=e.rate!=null?e.rate:this.defaultRate,this.axis=e.axis!=null?e.axis:this.defaultAxis}apply(e){return G(()=>{let t=hy(e,this.axis),n=le(L(this.rate,Zn(t,this.minValue,this.maxValue)),L(1-this.rate,t));return L(e,he(n,le(en(),t)))})}getConfig(){return{minValue:this.minValue,maxValue:this.maxValue,rate:this.rate,axis:this.axis}}};yy.className="MinMaxNorm";ue.registerClass(yy);var mv={maxNorm:"MaxNorm",minMaxNorm:"MinMaxNorm",nonNeg:"NonNeg",unitNorm:"UnitNorm"};function tn(e){return dy(e)}function gv(e,t={}){return lp(e,ue.SerializationMap.getMap().classNameMap,t,"constraint")}function nn(e){if(e==null)return null;if(typeof e=="string"){let t={className:e in mv?mv[e]:e,config:{}};return gv(t)}else return e instanceof up?e:gv(e)}function pP(e){return new fy(e)}function cP(e){return new my(e)}function hP(){return new gy}function fP(e){return new yy(e)}var yv={};ze(yv,{constant:()=>PP,glorotNormal:()=>jP,glorotUniform:()=>UP,heNormal:()=>GP,heUniform:()=>HP,identity:()=>BP,leCunNormal:()=>qP,leCunUniform:()=>XP,ones:()=>_P,orthogonal:()=>KP,randomNormal:()=>LP,randomUniform:()=>zP,truncatedNormal:()=>WP,varianceScaling:()=>VP,zeros:()=>OP});var mP=["channelsFirst","channelsLast"],gP=["nearest","bilinear"],yP=["valid","same","causal"],AP=["max","avg"],xP=["sum","mul","concat","ave"],Au=new Map;function Bt(e){fo(mP,"Da
because the value dtype is $ { t . dtype } , but TensorArray dtype is $ { this . dtype } . ` );if(this.size()===0&&(this.elementShape==null||this.elementShape.length===0)&&(this.elementShape=t.shape),Ua(this.elementShape,t.shape, ` TensorArray $ { this . name } : Could not write to TensorArray index $ { e } . ` ),n.read)throw new Error( ` TensorArray $ { this . name } : Could not write to TensorArray index $ { e } , because it has already been read . ` );if(n.written)throw new Error( ` TensorArray $ { this . name } : Could not write to TensorArray index $ { e } , because it has already been written . ` );n.tensor=t,pn(t),n.written=!0,this.tensors[e]=n}writeMany(e,t){if(e.length!==t.length)throw new Error( ` TensorArray $ { this . name } : could not write multiple tensors , because the index size : $ { e . length } is not the same as tensors size : $ { t . length } . ` );e.forEach((n,a)=>this.write(n,t[a]))}gather(e,t){if(!!t&&t!==this.dtype)throw new Error( ` TensorArray dtype is $ { this . dtype } but gather requested dtype $ { t } ` );if(e)e=e.slice(0,this.size());else{e=[];for(let a=0;a<this.size();a++)e.push(a)}if(e.length===0)return Lt([],[0].concat(this.elementShape));let n=this.readMany(e);return Ua(this.elementShape,n[0].shape,"TensorArray shape mismatch: "),xn(n,0)}concat(e){if(!!e&&e!==this.dtype)throw new Error( ` TensorArray dtype is $ { this . dtype } but concat requested dtype $ { e } ` );if(this.size()===0)return Lt([],[0].concat(this.elementShape));let t=[];for(let a=0;a<this.size();a++)t.push(a);let n=this.readMany(t);return Ua(this.elementShape,n[0].shape, ` TensorArray shape mismatch : tensor array shape ( $ { this . elementShape } ) vs first tensor shape ( $ { n [ 0 ] . shape } ) ` ),mt(n,0)}scatter(e,t){if(t.dtype!==this.dtype)throw new Error( ` TensorArray dtype is $ { this . dtype } but tensor has dtype $ { t . dtype } ` );if(e.length!==t.shape[0])throw new Error( ` Expected len ( indices ) == tensor . shape [ 0 ] , but saw : $ { e . length } vs . $ { t . shape [ 0 ] } ` );let n=Math.max(...e);if(!this.dynamicSize&&n>=this.maxSize)throw new Error( ` Max index must be < array size ( $ { n } vs . $ { this . maxSize } ) ` );this.writeMany(e,Mn(t,0))}split(e,t){if(t.dtype!==this.dtype)throw new Error( ` TensorArray dtype is $ { this . dtype } but tensor has dtype $ { t . dtype } ` );let n=0,a=e.map(o=>(n+=o,n));if(n!==t.shape[0])throw new Error( ` Expected sum of lengths to be equal to
2021-09-11 16:29:31 +02:00
tensor . shape [ 0 ] , but sum of lengths is
2021-10-22 22:09:52 +02:00
$ { n } , and tensor 's shape is: ${t.shape}`);if(!this.dynamicSize&&e.length!==this.maxSize)throw new Error(`TensorArray' s size is not equal to the size of lengths ( $ { this . maxSize } vs . $ { e . length } ) , and the TensorArray is not marked as dynamically resizeable ` );let r=n===0?0:t.size/n,s=[];G(()=>{t=V(t,[1,n,r]);for(let o=0;o<e.length;++o){let l=o===0?0:a[o-1],d=[0,l,0],u=[1,e[o],r];s[o]=V(De(t,d,u),this.elementShape)}return s});let i=[];for(let o=0;o<e.length;o++)i[o]=o;this.writeMany(i,s)}},Tp=class{constructor(e,t,n,a=-1){this.tensors=e,this.elementShape=t,this.elementDtype=n,e!=null&&e.forEach(r=>{if(n!==r.dtype)throw new Error( ` Invalid data types ; op elements $ { n } , but list elements $ { r . dtype } ` );Ua(t,r.shape,"TensorList shape mismatch: "),pn(r)}),this.idTensor=Ce(0),this.maxNumElements=a,pn(this.idTensor)}get id(){return this.idTensor.id}copy(){return new Tp([...this.tensors],this.elementShape,this.elementDtype)}clearAndClose(e){this.tensors.forEach(t=>{(e==null||!e.has(t.id))&&t.dispose()}),this.tensors.length=0,this.idTensor.dispose()}size(){return this.tensors.length}stack(e,t,n=-1){if(t!==this.elementDtype)throw new Error( ` Invalid data types ; op elements $ { t } , but list elements $ { this . elementDtype } ` );if(n!==-1&&this.tensors.length!==n)throw new Error( ` Operation expected a list with $ { n } elements but got a list with $ { this . tensors . length } elements . ` );Ua(e,this.elementShape,"TensorList shape mismatch: ");let a=Np(this.elementShape,this.tensors,e);return G(()=>{let r=this.tensors.map(s=>V(s,a));return xn(r,0)})}popBack(e,t){if(t!==this.elementDtype)throw new Error( ` Invalid data types ; op elements $ { t } , but list elements $ { this . elementDtype } ` );if(this.size()===0)throw new Error("Trying to pop from an empty list.");let n=Np(this.elementShape,this.tensors,e),a=this.tensors.pop();return Ua(a.shape,e,"TensorList shape mismatch: "),V(a,n)}pushBack(e){if(e.dtype!==this.elementDtype)throw new Error( ` Invalid data types ; op elements $ { e . dtype } , but list elements $ { this . elementDtype } ` );if(Ua(e.shape,this.elementShape,"TensorList shape mismatch: "),this.maxNumElements===this.size())throw new Error("Trying to push element into a full list.");pn(e),this.tensors.push(e)}resize(e){if(e<0)throw new Error( ` TensorListResize expects size to be non - negative . Got : $ { e } ` );if(this.maxNumElements!==-1&&e>this.maxNumElements)throw new Error( ` TensorListResize input size $ { e } is greater maxNumElement $ { this . maxNumElements } . ` );this.tensors.length=e}getItem(e,t,n){if(n!==this.elementDtype)throw new Error( ` Invalid data types ; op elements $ { n } , but list elements $ { this . elementDtype } ` );if(e<0||e>this.tensors.length)throw new Error( ` Trying to access element $ { e } in a list with $ { this . tensors . length } elements . ` );if(this.tensors[e]==null)throw new Error( ` element at index $ { e } is null . ` );Ua(this.tensors[e].shape,t,"TensorList shape mismatch: ");let a=Np(this.elementShape,this.tensors,t);return V(this.tensors[e],a)}setItem(e,t){if(t.dtype!==this.elementDtype)throw new Error( ` Invalid data types ; op elements $ { t . dtype } , but list elements $ { this . elementDtype } ` );if(e<0||this.maxNumElements!==-1&&e>=this.maxNumElements)throw new Error( ` Trying to set element $ { e } in a list with max $ { this . maxNumElements } elements . ` );Ua(this.elementShape,t.shape,"TensorList shape mismatch: "),pn(t),this.tensors[e]=t}gather(e,t,n){if(t!==this.elementDtype)throw new Error( ` Invalid data types ; op elements $ { t } , but list elements $ { this . elementDtype } ` );Ua(this.elementShape,n,"TensorList shape mismatch: "),e=e.slice(0,this.size());let a=Np(this.elementShape,this.tensors,n);return e.length===0?Lt([],[0].concat(a)):G(()=>{let r=e.map(s=>V(this.tensors[s],a));return xn(r,0)})}concat(e,t){if(!!e&&e!==this.elementDtype)throw new Error( ` TensorList dtype is $ { this . elementDtype } but concat requested dtype $ { e } ` );Ua(this.elementShape,t,"TensorList shape mismatch: ");let n=Np(this.elementShape,this.tensors,t);return this.size()===0?Lt([],[0].concat(n)):G(()=>{let a=this.tensors.map(r=>V(r,n));return mt(a,0)})}};function AB(e,t,n){let a=e.dtype;if(e.shape.length<1)throw new Error( ` Tensor m
2021-09-11 16:29:31 +02:00
tensor . shape [ 0 ] , but sum of lengths is
2021-10-22 22:09:52 +02:00
$ { a } , and tensor ' s shape is : $ { e . shape } ` );let s=e.shape.slice(1),i=o2(s,n),o=a===0?0:e.size/a,l=G(()=>{let u=[];e=V(e,[1,a,o]);for(let p=0;p<t.length;++p){let c=p===0?0:r[p-1],h=[0,c,0],f=[1,t[p],o];u[p]=V(De(e,h,f),i)}return e.dispose(),u}),d=new Tp([],n,e.dtype,t.length);for(let u=0;u<l.length;u++)d.setItem(u,l[u]);return d}var wB=async(e,t,n)=>{switch(e.op){case"If":case"StatelessIf":{let a=I("thenBranch",e,t,n),r=I("elseBranch",e,t,n),s=I("cond",e,t,n),i=I("args",e,t,n);return(await s.data())[0]?n.functionMap[a].executeFunctionAsync(i,n.tensorArrayMap,n.tensorListMap):n.functionMap[r].executeFunctionAsync(i,n.tensorArrayMap,n.tensorListMap)}case"While":case"StatelessWhile":{let a=I("body",e,t,n),r=I("cond",e,t,n),s=I("args",e,t,n),i=await n.functionMap[r].executeFunctionAsync(s,n.tensorArrayMap,n.tensorListMap),o=s.map(u=>u.id),l=await i[0].data();i.forEach(u=>{!u.kept&&o.indexOf(u.id)===-1&&u.dispose()});let d=s;for(;l[0];){let u=d;d=await n.functionMap[a].executeFunctionAsync(d,n.tensorArrayMap,n.tensorListMap);let p=d.map(h=>h.id);u.forEach(h=>{!h.kept&&o.indexOf(h.id)===-1&&p.indexOf(h.id)===-1&&h.dispose()});let c=await n.functionMap[r].executeFunctionAsync(d,n.tensorArrayMap,n.tensorListMap);l=await c[0].data(),c.forEach(h=>{!h.kept&&o.indexOf(h.id)===-1&&p.indexOf(h.id)===-1&&h.dispose()})}return d}case"LoopCond":{let a=I("pred",e,t,n);return[jr(a)]}case"Switch":{let a=I("pred",e,t,n),r=I("data",e,t,n);return r.kept||(r=jr(r)),(await a.data())[0]?[void 0,r]:[r,void 0]}case"Merge":{let a=e.inputNames.find(r=>Dn(r,t,n)!==void 0);if(a){let r=Dn(a,t,n);return[jr(r)]}return}case"Enter":{let a=I("frameName",e,t,n),r=I("tensor",e,t,n);return n.enterFrame(a),[jr(r)]}case"Exit":{let a=I("tensor",e,t,n);return n.exitFrame(),[jr(a)]}case"NextIteration":{let a=I("tensor",e,t,n);return n.nextIteration(),[jr(a)]}case"TensorArrayV3":{let a=I("size",e,t,n),r=I("dtype",e,t,n),s=I("elementShape",e,t,n),i=I("dynamicSize",e,t,n),o=I("clearAfterRead",e,t,n),l=I("identicalElementShapes",e,t,n),d=I("name",e,t,n),u=new yB(d,r,a,s,l,i,o);return n.addTensorArray(u),[u.idTensor,Ce(1)]}case"TensorArrayWriteV3":{let a=I("tensorArrayId",e,t,n),r=I("index",e,t,n),s=I("tensor",e,t,n),i=n.getTensorArray(a.id);return i.write(r,s),[i.idTensor]}case"TensorArrayReadV3":{let a=I("tensorArrayId",e,t,n),r=I("index",e,t,n);return[n.getTensorArray(a.id).read(r)]}case"TensorArrayGatherV3":{let a=I("tensorArrayId",e,t,n),r=I("indices",e,t,n),s=I("dtype",e,t,n);return[n.getTensorArray(a.id).gather(r,s)]}case"TensorArrayScatterV3":{let a=I("tensorArrayId",e,t,n),r=I("indices",e,t,n),s=I("tensor",e,t,n),i=n.getTensorArray(a.id);return i.scatter(r,s),[i.idTensor]}case"TensorArrayConcatV3":{let a=I("tensorArrayId",e,t,n),r=n.getTensorArray(a.id),s=I("dtype",e,t,n);return[r.concat(s)]}case"TensorArraySplitV3":{let a=I("tensorArrayId",e,t,n),r=I("tensor",e,t,n),s=I("lengths",e,t,n),i=n.getTensorArray(a.id);return i.split(s,r),[i.idTensor]}case"TensorArraySizeV3":{let a=I("tensorArrayId",e,t,n),r=n.getTensorArray(a.id);return[Ce(r.size(),"int32")]}case"TensorArrayCloseV3":{let a=I("tensorArrayId",e,t,n),r=n.getTensorArray(a.id);return r.clearAndClose(),[r.idTensor]}case"TensorListSetItem":{let a=I("tensorListId",e,t,n),r=I("index",e,t,n),s=I("tensor",e,t,n),i=n.getTensorList(a.id);return i.setItem(r,s),[i.idTensor]}case"TensorListGetItem":{let a=I("tensorListId",e,t,n),r=I("index",e,t,n),s=I("elementShape",e,t,n),i=I("elementDType",e,t,n);return[n.getTensorList(a.id).getItem(r,s,i)]}case"TensorListScatterV2":case"TensorListScatter":{let a=I("indices",e,t,n),r=I("tensor",e,t,n),s=I("elementShape",e,t,n),i=I("numElements",e,t,n),o=bB(r,a,s,i);return n.addTensorList(o),[o.idTensor]}case"TensorListReserve":case"EmptyTensorList":{let a=I("elementShape",e,t,n),r=I("elementDType",e,t,n),s;e.op==="TensorListReserve"?s="numElements":s="maxNumElements";let i=I(s,e,t,n),o=xB(a,r,i);return n.addTensorList(o),[o.idTensor]}case"TensorListGather":{let a=I("tensorListId",e,t,n),r=I("indices",e,t,n),s=I("elementShape",e,t,n),i=I("elementDType",e,t,n);return[n.getTensor
$ { e } ` );let a;return this.size===1/0||this.size==null?a=this.size:t?a=Math.ceil(this.size/e):a=Math.floor(this.size/e),ha(async()=>(await n.iterator()).columnMajorBatch(e,t,bV),a)}concatenate(e){let t=this,n;return this.size===1/0||e.size===1/0?n=1/0:this.size!=null&&e.size!=null?n=this.size+e.size:n=null,ha(async()=>(await t.iterator()).concatenate(await e.iterator()),n)}filter(e){let t=this,n;return this.size===1/0?n=1/0:n=null,ha(async()=>(await t.iterator()).filter(a=>G(()=>e(a))),n)}async forEachAsync(e){return(await this.iterator()).forEachAsync(e)}map(e){let t=this;return ha(async()=>(await t.iterator()).map(n=>G(()=>e(n))),this.size)}mapAsync(e){let t=this;return ha(async()=>(await t.iterator()).mapAsync(e),this.size)}prefetch(e){if(e==null)throw new RangeError(" ` Dataset . prefetch ( ) ` requires bufferSize to be specified.");let t=this;return ha(async()=>(await t.iterator()).prefetch(e),this.size)}repeat(e){let t=this,n;return this.size!=null&&e>0?n=this.size*e:e===0?n=0:this.size!=null&&(e===void 0||e<0)?n=1/0:n=null,ha(async()=>{let a=p2(async()=>({value:await t.iterator(),done:!1}));return rV(a.take(e))},n)}skip(e){let t=this,n;return this.size!=null&&e>=0&&this.size>=e?n=this.size-e:this.size!=null&&(this.size<e||e===void 0||e<0)?n=0:n=null,ha(async()=>(await t.iterator()).skip(e),n)}shuffle(e,t,n=!0){if(e==null||e<0)throw this.size==null?new RangeError(" ` Dataset . shuffle ( ) ` requires bufferSize to be specified."):new RangeError( ` \ ` Dataset.shuffle() \` requires bufferSize to be specified. If your data fits in main memory (for regular JS objects), and/or GPU memory (for \` tf.Tensor \` s), consider setting bufferSize to the dataset size ( ${ this . size } elements) ` ) ; let a = this , r = ZB . alea ( t || w . now ( ) . toString ( ) ) ; return ha ( async ( ) => { let s = r . int32 ( ) ; return n && ( s += r . int32 ( ) ) , ( await a . iterator ( ) ) . shuffle ( e , s . toString ( ) ) } , this . size ) } take ( e ) { let t = this , n ; return this . size != null && this . size > e ? n = e : this . size != null && this . size <= e ? n = this . size : n = null , ha ( async ( ) => ( await t . iterator ( ) ) . take ( e ) , n ) } async toArray ( ) { if ( this . size === 1 / 0 ) throw new Error ( "Can not convert infinite data stream to array." ) ; return ( await this . iterator ( ) ) . toArray ( ) } async toArrayForTest ( ) { if ( this . size === 1 / 0 ) throw new Error ( "Can not convert infinite data stream to array." ) ; return ( await this . iterator ( ) ) . toArrayForTest ( ) } } ; Nu . MAX _BUFFER _SIZE = 1e4 ; function ha ( e , t = null ) { return new class extends Nu { constructor ( ) { super ( ... arguments ) ; this . size = t } async iterator ( ) { return e ( ) } } } function AV ( e ) { return ha ( async ( ) => Rw ( e ) , e . length ) } function xV ( e ) { if ( ! Su ( e ) ) throw new Error ( "The argument to zip() must be an object or array." ) ; let t ; if ( Array . isArray ( e ) ) for ( let n = 0 ; n < e . length ; n ++ ) t = t == null ? e [ n ] . size : Math . min ( t , e [ n ] . size ) ; else if ( e instanceof Object ) for ( let n in e ) t = t == null ? e [ n ] . size : Math . min ( t , e [ n ] . size ) ; return ha ( async ( ) => { let n = await Cw ( e , a => { if ( a instanceof Nu ) return { value : a . iterator ( ) , recurse : ! 1 } ; if ( Su ( a ) ) return { value : null , recurse : ! 0 } ; throw new Error ( "Leaves of the structure passed to zip() must be Datasets, not primitives." ) } ) ; return sV ( n , Es . SHORTEST ) } , t ) } function bV ( e ) { if ( e === null ) return null ; let t = e [ 0 ] ; return eV ( t ) ? { value : vV ( e ) , recurse : ! 1 } : { value : null , recurse : ! 0 } } function vV ( e ) { if ( e . length === 0 ) throw new Error ( "Can't make a batch of zero elements." ) ; return e [ 0 ] instanceof je ? xn ( e ) : Lt ( e ) } var $w = class extends Nu { constructor ( e ) { super ( ) ; this . input = e } async iterator ( ) { return ( await this . input . iterator ( ) ) . decodeUTF8 ( ) . split ( `
` ).map(e=>(e.endsWith(" \r ")&&(e=e.slice(0,-1)),e))}},ef='"',Cp=Symbol("out"),Ow=Symbol("field"),tf=Symbol("quote"),h2=Symbol("quoteafterquote"),_w=Symbol("quoteinquote"),Pw=class extends Nu{constructor(e,t){super();this.input=e,this.hasHeader=!0,this.fullColumnNames=null,this.columnNamesValidated=!1,this.columnConfigs=null,this.configuredColumnsOnly=!1,this.delimiter=",",this.delimWhitespace=!1,this.base=new $ w(e),t||(t={}),this.hasHeader=t.hasHeader!==!1,this.fullColumnNames=t.columnNames,this.columnConfigs=t.columnConfigs,this.configuredColumnsOnly=t.configuredColumnsOnly,t.delimWhitespace?(w.assert(t.delimiter==null,()=>"Delimiter should not be provided when delimWhitespace is true."),this.delimWhitespace=!0,this.delimiter=" "):this.delimiter=t.delimiter?t.delimiter:","}async columnNames(){return this.columnNamesValidated||await this.setColumnNames(),this.configuredColumnsOnly?Object.keys(this.columnConfigs):this.fullColumnNames}async setColumnNames(){let e=await this.maybeReadHeaderLine();if(!this.fullColumnNames&&!e)throw new Error("Column names must be provided if there is no header line.");this.fullColumnNames&&e&&w.assert(e.length===this.fullColumnNames.length,()=>"The length of provided columnNames ("+this.fullColumnNames.length.toString()+") does not match the length of the header line read from file ("+e.length.toString()+")."),this.fullColumnNames||(this.fullColumnNames=e);let t=this.fullColumnNames.reduce((a,r)=>(a[r]=a[r]+1||1,a),{}),n=Object.keys(t).filter(a=>t[a]>1);if(w.assert(n.length===0,()=>"Duplicate column names found: "+n.toString()),this.columnConfigs){for(let a of Object.keys(this.columnConfigs))if(this.fullColumnNames.indexOf(a)===-1)throw new Error('The key "'+a+'" provided in columnConfigs does not match any of the column names ('+this.fullColumnNames.toString()+").")}this.columnNamesValidated=!0}async maybeReadHeaderLine(){if(this.hasHeader){let e=await(await this.base.iterator()).next();if(e.done)throw new Error("No data was found for CSV parsing.");let t=e.value;return this.parseRow(t,!1)}else return null}async iterator(){this.columnNamesValidated||await this.setColumnNames();let e=await this.base.iterator();return this.hasHeader&&(e=e.skip(1)),e.map(t=>this.makeDataElement(t))}makeDataElement(e){let t=this.parseRow(e),n={},a={};for(let r=0;r<this.fullColumnNames.length;r++){let s=this.fullColumnNames[r],i=this.columnConfigs?this.columnConfigs[s]:null;if(!(this.configuredColumnsOnly&&!i)){let o=t[r],l=null;if(o==="")if(i&&i.default!==void 0)l=i.default;else{if(i&&(i.required||i.isLabel))throw new Error( ` Required column $ { s } is empty in this line : $ { e } ` );l=void 0}else{let d=Number(o);if(isNaN(d))i&&i.dtype==="bool"?l=this.getBoolean(o):l=o;else if(!i||!i.dtype)l=d;else switch(i.dtype){case"float32":l=d;break;case"int32":l=Math.floor(d);break;case"bool":l=this.getBoolean(o);break;default:l=d}}i&&i.isLabel?a[s]=l:n[s]=l}}return Object.keys(a).length===0?n:{xs:n,ys:a}}getBoolean(e){return e==="1"||e.toLowerCase()==="true"?1:0}parseRow(e,t=!0){let n=[],a=0,r=e.length,s=Cp;for(let i=0;i<r;i++)switch(s){case Cp:switch(e.charAt(i)){case ef:a=i+1,s=tf;break;case this.delimiter:if(a=i+1,this.delimiter===" "&&this.delimWhitespace)break;n.push(""),s=Cp;break;default:s=Ow,a=i;break}break;case Ow:switch(e.charAt(i)){case this.delimiter:n.push(e.substring(a,i)),s=Cp,a=i+1;break;default:}break;case tf:switch(e.charAt(i)){case ef:s=h2;break;default:}break;case h2:switch(e.charAt(i)){case this.delimiter:n.push(e.substring(a,i-1)),s=Cp,a=i+1;break;case ef:s=tf;break;default:s=_w;break}break;case _w:switch(e.charAt(i)){case ef:s=tf;break;default:}break;default:}if(s===h2?n.push(e.substring(a,r-1)):n.push(e.substring(a)),t&&n.length!==this.fullColumnNames.length)throw new Error( ` Invalid row in csv file . Should have $ { this . fullColumnNames . length } elements in a row , but got $ { n } ` );return n}},zw=class extends fn{constructor(e){super();this.microphoneConfig=e,this.isClosed=!1,this.fftSize=e.fftSize||1024;let t=Math.log2(this.fftSize);if(this.fftSize<0||t<4||t>14||!Number.isInteger(t))throw new Error( ` Invalid fftSi
2021-09-11 16:29:31 +02:00
=== === === === === === === === === =
Hi there \ u { 1 F44B } . Looks like you are running TensorFlow . js in Node . js . To speed things up dramatically , install our node backend , which binds to TensorFlow C ++ , by running npm i @ tensorflow / tfjs - node , or npm i @ tensorflow / tfjs - node - gpu if you have CUDA . Then call require ( '@tensorflow/tfjs-node' ) ; ( - gpu suffix for CUDA ) at the start of your program . Visit https : //github.com/tensorflow/tfjs-node for more details.
2021-10-22 22:09:52 +02:00
=== === === === === === === === === = ` ));let a={id:this.nextDataId()};return this.data.set(a,{values:e,dtype:n,refCount:1}),a}makeTensorInfo(e,t,n){let a;if(t==="string"&&n!=null&&n.length>0&&w.isString(n[0])){let r=n.map(s=>w.encodeString(s));a=this.write(r,e,t)}else a=this.write(n,e,t);return{dataId:a,shape:e,dtype:t}}refCount(e){return this.data.has(e)?this.data.get(e).refCount:0}incRef(e){let t=this.data.get(e);t.refCount++}decRef(e){if(this.data.has(e)){let t=this.data.get(e);t.refCount--}}move(e,t,n,a,r){this.data.set(e,{values:t,dtype:a,refCount:r})}numDataIds(){return this.data.numDataIds()}async read(e){return this.readSync(e)}readSync(e){let{dtype:t,complexTensorInfos:n}=this.data.get(e);if(t==="complex64"){let a=this.readSync(n.real.dataId),r=this.readSync(n.imag.dataId);return E.mergeRealAndImagArrays(a,r)}return this.data.get(e).values}bufferSync(e){let t=this.readSync(e.dataId),n=t;if(e.dtype==="string")try{n=t.map(a=>w.decodeString(a))}catch(a){throw new Error("Failed to decode encoded string bytes into utf-8")}return Ge(e.shape,e.dtype,n)}makeOutput(e,t,n){let a=this.write(e,t,n);return sa().makeTensorFromDataId(a,t,n,this)}disposeData(e,t=!1){if(this.data.has(e)){if(this.data.get(e).refCount--,!t&&this.data.get(e).refCount>0)return!1;let{complexTensorInfos:n}=this.data.get(e);n!=null&&(this.disposeData(n.real.dataId,!0),this.disposeData(n.imag.dataId,!0)),this.data.delete(e)}return!0}disposeIntermediateTensorInfo(e){this.disposeData(e.dataId)}async time(e){let t=w.now();return e(),{kernelMs:w.now()-t}}memory(){return{unreliable:!0,reasons:["The reported memory is an upper bound. Due to automatic garbage collection, the true allocated memory may be less."]}}where(e){Te([e],"where");let t=this.readSync(e.dataId);return OV(e.shape,t)}dispose(){}floatPrecision(){return 32}epsilon(){return super.epsilon()}};f2.nextDataId=0;var Hw={};ze(Hw,{addImpl:()=>Xw,bincountImpl:()=>g2,bincountReduceImpl:()=>Kw,ceilImpl:()=>Zw,concatImpl:()=>y2,equalImpl:()=>Yw,expImpl:()=>Qw,expm1Impl:()=>t6,floorImpl:()=>n6,gatherNdImpl:()=>a6,gatherV2Impl:()=>r6,greaterEqualImpl:()=>i6,greaterImpl:()=>s6,lessEqualImpl:()=>l6,lessImpl:()=>o6,linSpaceImpl:()=>u6,logImpl:()=>d6,maxImpl:()=>p6,maximumImpl:()=>c6,minimumImpl:()=>h6,multiplyImpl:()=>A2,negImpl:()=>f6,notEqualImpl:()=>m6,prodImpl:()=>g6,rangeImpl:()=>b2,rsqrtImpl:()=>y6,sigmoidImpl:()=>kU,simpleAbsImpl:()=>qw,sliceImpl:()=>rf,sparseFillEmptyRowsImpl:()=>x6,sparseReshapeImpl:()=>b6,sparseSegmentReductionImpl:()=>v2,sqrtImpl:()=>NU,squaredDifferenceImpl:()=>v6,stridedSliceImpl:()=>w6,stringNGramsImpl:()=>k6,stringSplitImpl:()=>I6,stringToHashBucketFastImpl:()=>S6,subImpl:()=>N6,tileImpl:()=>T6,topKImpl:()=>E6,transposeImpl:()=>x2,uniqueImpl:()=>R6});function qw(e){let t=new Float32Array(e.length);for(let n=0;n<e.length;++n)t[n]=Math.abs(e[n]);return t}var _V=e=>{let{x:t}=e.inputs,n=e.backend;Te(t,"abs");let a=new Float32Array(w.sizeFromShape(t.shape)),r=n.data.get(t.dataId).values;return a=qw(r),n.makeOutput(a,t.shape,t.dtype)},PV={kernelName:Ko,backendName:"cpu",kernelFunc:_V};function Xt(e){return(t,n,a,r,s)=>{let i=E.assertAndGetBroadcastShape(t,n),o=i.length,l=w.computeStrides(i),d=w.sizeFromShape(i),u=w.getTypedArrayFromDType(s,d),p=t.length,c=n.length,h=w.computeStrides(t),f=w.computeStrides(n),m=E.getBroadcastDims(t,i),g=E.getBroadcastDims(n,i);if(m.length+g.length===0)for(let y=0;y<u.length;++y)u[y]=e(a[y%a.length],r[y%r.length]);else for(let y=0;y<u.length;++y){let A=w.indexToLoc(y,o,l),x=A.slice(-p);m.forEach(T=>x[T]=0);let b=w.locToIndex(x,p,h),v=A.slice(-c);g.forEach(T=>v[T]=0);let k=w.locToIndex(v,c,f);u[y]=e(a[b],r[k])}return[u,i]}}function fa(e){let{inputs:t,backend:n}=e,{real:a,imag:r}=t,s=n.data.get(a.dataId).values,i=n.data.get(r.dataId).values,o=n.makeTensorInfo(a.shape,"complex64"),l=n.data.get(o.dataId);return l.complexTensorInfos={real:n.makeTensorInfo(a.shape,"float32",s),imag:n.makeTensorInfo(r.shape,"float32",i)},o}var zV={kernelName:jc,backendName:"cpu",kernelFunc:fa};function nf(e,t,n="float32"){if(n==="complex64"){let r=nf(e,t,"float32"),s=nf(e,t,"float32")
indices . shape [ 0 ] = $ { o } ` );let g=w.getArrayFromDType(n,0),y=w.getArrayFromDType(r,0);return[g,[0,p],y,d,u]}let c=!0,h=0,f=new Array(l).fill(0);for(let g=0;g<o;++g){let y=e[g*p];if(y<0)throw new Error( ` indices ( $ { g } , 0 ) is invalid : $ { y } < 0 ` );if(y>=l)throw new Error( ` indices ( $ { g } , 0 ) is invalid : $ { y } >= $ { l } ` );++f[y],c=c&&y>=h,h=y}let m=!0;for(let g=0;g<l;++g){let y=f[g]===0;d[g]=y,m=m&&!y,f[g]=Math.max(f[g],1),g>0&&(f[g]+=f[g-1])}if(m&&c){let g=e,y=a;for(let A=0;A<o;++A)u[A]=A;return[g,[o,p],y,d,u]}else{let g=f[l-1],y=w.getArrayFromDType(n,g*p),A=w.getArrayFromDType(r,g),x=new Array(l).fill(0);for(let b=0;b<o;++b){let v=e[b*p],k=x[v],T=(v===0?0:f[v-1])+k;x[v]++;for(let C=0;C<p;++C)y[T*p+C]=e[b*p+C];A[T]=a[b],u[b]=T}for(let b=0;b<l;++b)if(x[b]===0){let v=b===0?0:f[b-1];y[v*p+0]=b;for(let k=1;k<p;++k)y[v*p+k]=0;A[v]=i}return[y,[g,p],A,d,u]}}function b6(e,t,n,a,r){let s=w.sizeFromShape(a),i=t[0],o=r.length,l=[],d=1,u=-1;for(let g=0;g<o;++g){let y=r[g];if(y===-1){if(u!==-1)throw new Error( ` only one output dimension may be - 1 , not both $ { u } and $ { g } ` );u=g,l.push(1)}else{if(y<0)throw new Error( ` size $ { g } must be non - negative , not $ { y } ` );d*=y,l.push(y)}}if(u!==-1){if(d<=0)throw new Error("reshape cannot infer the missing input size for an empty tensor unless all specified input sizes are non-zero");let g=Math.trunc(s/d);if(d*g!==s)throw new Error( ` Input to reshape is a SparseTensor with $ { s }
dense values , but the requested shape requires a multiple of $ { d } . inputShape = $ { a } outputShape = $ { l } ` );l[u]=g}let p=w.sizeFromShape(l);if(p!==s)throw new Error( ` Input to reshape is a tensor with $ { s } dense values , but the requested shape has $ { p } . inputShape = $ { a } outputShape = $ { l } ` );let c=a.length,h=[];if(c>0){h[c-1]=1;for(let g=c-2;g>=0;--g)h[g]=h[g+1]*a[g+1]}let f=[];if(o>0){f[o-1]=1;for(let g=o-2;g>=0;--g)f[g]=f[g+1]*l[g+1]}let m=w.getArrayFromDType(n,i*o);for(let g=0;g<i;++g){let y=0;for(let A=0;A<c;++A)y+=e[g*c+A]*h[A];for(let A=0;A<o;++A)m[g*o+A]=Math.trunc(y/f[A]),y%=f[A]}return[m,[i,o],l]}function v2(e,t,n,a,r,s=!1,i=0){let o=a.length;if(o!==r.length)throw new Error("segmentIds and indices should have same size.");let l=[t[0],e.length/t[0]],d=l[1],u=o>0?r[o-1]+1:0;if(u<0)throw new Error("segment ids must be >= 0");let p=t.slice();p[0]=u;let c=p.reduce((A,x)=>A*x,1),h=w.getArrayFromDType(n,c);if(o===0)return u>0&&h.fill(i),[h,p];if(u<=0)throw new Error("segment ids must be >= 0");let f=0,m=1,g=0,y=r[f];for(;;){let A=0;if(m<o){if(A=r[m],y===A){++m;continue}if(y>=A)throw new Error("segment ids are not increasing")}if(y<0||y>=u)throw new Error( ` Segment id $ { y } out of range [ 0 , $ { u } ) , possibly because segmentIds input is not sorted . ` );y>g&&h.fill(i,g*d,y*d);for(let x=f;x<m;++x){let b=a[x];if(b<0||b>=l[0])throw new Error( ` Bad : indices [ $ { x } ] == $ { a [ x ] } out of range [ 0 , $ { l [ 0 ] } ) ` );for(let v=0;v<d;v++)h[y*d+v]+=e[b*d+v]}if(s)for(let x=0;x<d;x++)h[y*d+x]/=m-f;if(f=m,++m,g=y+1,y=A,m>o)break}return g<u&&h.fill(i,g*d,u*d),[h,p]}var NU=Ms(e=>Math.sqrt(e)),TU=ct(zi,e=>Math.sqrt(e)),CU={kernelName:zi,backendName:"cpu",kernelFunc:TU},v6=Xt((e,t)=>{let n=e-t;return n*n}),EU=mn(Bi,v6),RU={kernelName:Bi,backendName:"cpu",kernelFunc:EU};function w6(e,t,n,a){let r=Ge(e,t.dtype);for(let s=0;s<r.size;s++){let i=r.indexToLoc(s),o=new Array(i.length);for(let l=0;l<o.length;l++)o[l]=i[l]*n[l]+a[l];r.set(t.get(...o),...i)}return r}var MU=class{constructor(e,t,n,a,r,s){this.separator=w.encodeString(e),this.nGramWidths=t,this.leftPad=w.encodeString(n),this.rightPad=w.encodeString(a),this.padWidth=r,this.preserveShort=s}getPadWidth(e){return Math.min(this.padWidth<0?e-1:this.padWidth,e-1)}getNumNGrams(e,t){let n=this.getPadWidth(t);return Math.max(0,e+2*n-t+1)}createNGrams(e,t,n,a,r,s){for(let i=0;i<r;++i){let o=this.getPadWidth(s),l=Math.max(0,o-i),d=Math.max(0,o-(r-(i+1))),u=s-(l+d),p=t+(l>0?0:i-o),c=0;c+=l*this.leftPad.length;for(let g=0;g<u;++g)c+=e[p+g].length;c+=d*this.rightPad.length,c+=(l+d+u-1)*this.separator.length,n[a+i]=new Uint8Array(c);let h=n[a+i],f=0,m=g=>g.forEach(y=>h[f++]=y);for(let g=0;g<l;++g)m(this.leftPad),m(this.separator);for(let g=0;g<u-1;++g)m(e[p+g]),m(this.separator);if(u>0){m(e[p+u-1]);for(let g=0;g<d;++g)m(this.separator),m(this.rightPad)}else{for(let g=0;g<d-1;++g)m(this.rightPad),m(this.separator);m(this.rightPad)}}}compute(e,t){let n=e.length,a=t.length;if(a>0){let o=t[0];if(o!==0)throw new Error( ` First split value must be 0 , got $ { o } ` );for(let l=1;l<a;++l){let d=t[l]>=o;if(d=d&&t[l]<=n,!d)throw new Error( ` Invalid split value $ { t [ l ] } , must be in [ $ { o } , $ { n } ] ` );o=t[l]}if(o!==n)throw new Error( ` Last split value must be data size . Expected $ { n } , got $ { o } ` )}let r=a-1,s=w.getArrayFromDType("int32",a);if(n===0||a===0){let o=new Array(n);for(let l=0;l<=r;++l)s[l]=0;return[o,s]}s[0]=0;for(let o=1;o<=r;++o){let l=t[o]-t[o-1],d=0;this.nGramWidths.forEach(u=>{d+=this.getNumNGrams(l,u)}),this.preserveShort&&l>0&&d===0&&(d=1),s[o]=s[o-1]+d}let i=new Array(s[r]);for(let o=0;o<r;++o){let l=t[o],d=s[o];if(this.nGramWidths.forEach(u=>{let p=t[o+1]-t[o],c=this.getNumNGrams(p,u);this.createNGrams(e,l,i,d,c,u),d+=c}),this.preserveShort&&d===s[o]){let u=t[o+1]-t[o];if(u===0)continue;let p=u+2*this.padWidth,c=1;this.createNGrams(e,l,i,d,c,p)}}return[i,s]}};function k6(e,t,n,a,r,s,i,o){return new MU(n,a,r,s,i,o).compute(e,t)}function FU(e,t,n,a){if(!e.length)return;if(t.length===0){for(let s=0;s<e.length;++s)a.push(e.subarray(s,s+1));return}if(t.length===1){let s=t[0],i=e.indexOf(s);for(;i!==-1;){let o=e.subarray(0,i);(!n|
$ { s . shape } ` );if(a.shape.length!==2)throw new Error( ` Indices must be a matrix , saw :
$ { a . shape } ` );if(r.shape.length!==1)throw new Error( ` Values must be a vector , saw :
$ { r . shape } ` );if(i.shape.length!==0)throw new Error( ` Default value must be a scalar , saw :
$ { i . shape } ` );let o=n.data.get(a.dataId).values,l=n.data.get(r.dataId).values,d=n.data.get(s.dataId).values,u=n.data.get(i.dataId).values[0],[p,c,h,f,m]=x6(o,a.shape,a.dtype,l,r.dtype,d,u);return[n.makeTensorInfo(c,a.dtype,p),n.makeTensorInfo([c[0]],r.dtype,h),n.makeTensorInfo([f.length],"bool",new Uint8Array(f.map(g=>Number(g)))),n.makeTensorInfo([m.length],a.dtype,new Int32Array(m))]}var qq={kernelName:fh,backendName:"cpu",kernelFunc:Hq};function Xq(e){let{inputs:t,backend:n}=e,{inputIndices:a,inputShape:r,newShape:s}=t;if(a.shape.length!==2)throw new Error( ` Input indices should be a matrix but received shape
$ { a . shape } ` );if(r.shape.length!==1)throw new Error( ` Input shape should be a vector but received shape
$ { r . shape } ` );if(s.shape.length!==1)throw new Error( ` Target shape should be a vector but received shape $ { s . shape } ` );let i=Array.from(n.data.get(r.dataId).values),o=n.data.get(a.dataId).values,l=Array.from(n.data.get(s.dataId).values),[d,u,p]=b6(o,a.shape,a.dtype,i,l);return[n.makeTensorInfo(u,a.dtype,d),n.makeTensorInfo([p.length],s.dtype,new Int32Array(p))]}var Kq={kernelName:mh,backendName:"cpu",kernelFunc:Xq};function Zq(e){let{inputs:t,backend:n}=e,{data:a,indices:r,segmentIds:s}=t;if(a.shape.length<1)throw new Error("Data should be at least 1 dimensional but received scalar");if(r.shape.length!==1)throw new Error( ` Indices should be a vector but received shape
$ { r . shape } ` );if(s.shape.length!==1)throw new Error( ` Segment ids should be a vector but received shape
$ { s . shape } ` );let i=n.data.get(a.dataId).values,o=n.data.get(r.dataId).values,l=n.data.get(s.dataId).values,[d,u]=v2(i,a.shape,a.dtype,o,l,!0);return n.makeTensorInfo(u,a.dtype,d)}var Yq={kernelName:gh,backendName:"cpu",kernelFunc:Zq};function Jq(e){let{inputs:t,backend:n}=e,{data:a,indices:r,segmentIds:s}=t;if(a.shape.length<1)throw new Error("Data should be at least 1 dimensional but received scalar");if(r.shape.length!==1)throw new Error( ` Indices should be a vector but received shape
$ { r . shape } ` );if(s.shape.length!==1)throw new Error( ` Segment ids should be a vector but received shape
$ { s . shape } ` );let i=n.data.get(a.dataId).values,o=n.data.get(r.dataId).values,l=n.data.get(s.dataId).values,[d,u]=v2(i,a.shape,a.dtype,o,l);return n.makeTensorInfo(u,a.dtype,d)}var Qq={kernelName:yh,backendName:"cpu",kernelFunc:Jq};function eX(e){let{inputs:t,backend:n,attrs:a}=e,{sparseIndices:r,sparseValues:s,defaultValue:i}=t,{outputShape:o}=a,{sliceRank:l,numUpdates:d,sliceSize:u,strides:p,outputSize:c}=E.calculateShapes(s,r,o),h=!1,f=n.bufferSync(r),m=n.bufferSync(s),g=n.data.get(i.dataId).values[0],y=q6(f,m,o,c,u,d,l,p,g,h);return n.makeTensorInfo(o,y.dtype,y.values)}var tX={kernelName:Ah,backendName:"cpu",kernelFunc:eX};function nX(e){let{inputs:t,backend:n,attrs:a}=e,{x:r}=t,{numOrSizeSplits:s,axis:i}=a,o=w.parseAxisParam(i,r.shape)[0],l=E.prepareSplitSize(r,s,o),d=new Array(r.shape.length).fill(0),u=r.shape.slice();return l.map(p=>{let c=[...u];c[o]=p;let h=wo({inputs:{x:r},backend:n,attrs:{begin:d,size:c}});return d[o]+=p,h})}var aX={kernelName:Ul,backendName:"cpu",kernelFunc:nX},rX={kernelName:Ed,backendName:"cpu",kernelFunc:({inputs:e,backend:t})=>{let{x:n}=e,a=t;Te(n,"square");let r=a.data.get(n.dataId).values,s=new Float32Array(r.length);for(let i=0;i<r.length;++i){let o=r[i];s[i]=o*o}return{dataId:a.write(s,n.shape,n.dtype),shape:n.shape,dtype:n.dtype}}},sX=ct(ps,(e,t)=>{let n=t;return isNaN(e)?NaN:e>0?1:n.alpha}),iX={kernelName:ps,backendName:"cpu",kernelFunc:sX};function oX(e){let{inputs:t,backend:n,attrs:a}=e,{x:r}=t,{begin:s,end:i,strides:o,beginMask:l,endMask:d,ellipsisMask:u,newAxisMask:p,shrinkAxisMask:c}=a;Te(r,"stridedSlice");let{nonStrided:h, $ begin:f, $ strides:m,size:g,newShape:y,outShape:A}=En.sliceInfo(r.shape,s,i,o,l,d,u,p,c),x=wt({inputs:{x:r},backend:n,attrs:{shape:y}}),b;if(h){let k=wo({inputs:{x},backend:n,attrs:{begin:f,size:g}});b=wt({inputs:{x:k},backend:n,attrs:{shape:A}}),n.disposeIntermediateTensorInfo(k)}else if(A.some(k=>k===0))b=n.makeTensorInfo(A,r.dtype,[]);else{let k=n.bufferSync(x),T=w6(A,k,m,f);b=n.makeTensorInfo(T.shape,T.dtype,T.values)}let v=wt({inputs:{x:b},backend:n,attrs:{shape:A}});return n.disposeIntermediateTensorInfo(x),n.disposeIntermediateTensorInfo(b),v}var lX={kernelName:jl,backendName:"cpu",kernelFunc:oX};function uX(e){let{inputs:t,backend:n,attrs:a}=e,{separator:r,nGramWidths:s,leftPad:i,rightPad:o,padWidth:l,preserveShortSequences:d}=a,{data:u,dataSplits:p}=t,c=n.data.get(u.dataId).values,h=n.data.get(p.dataId).values,[f,m]=k6(c,h,r,s,i,o,l,d);return[n.makeTensorInfo([f.length],"string",f),n.makeTensorInfo(p.shape,"int32",m)]}var dX={kernelName:xh,backendName:"cpu",kernelFunc:uX};function pX(e){let{inputs:t,backend:n,attrs:a}=e,{skipEmpty:r}=a,{input:s,delimiter:i}=t;if(s.dtype!=="string")throw new Error("Input must be of datatype string");if(s.shape.length!==1)throw new Error( ` Input must be a vector , got shape : $ { s . shape } ` );if(i.shape.length!==0)throw new Error( ` Delimiter must be a scalar , got shape : $ { i . shape } ` );let o=n.data.get(s.dataId).values,l=n.data.get(i.dataId).values[0],[d,u,p]=I6(o,l,r),c=u.length;return[n.makeTensorInfo([c,2],"int32",d),n.makeTensorInfo([c],"string",u),n.makeTensorInfo([2],"int32",new Int32Array(p))]}var cX={kernelName:bh,backendName:"cpu",kernelFunc:pX};function hX(e){let{inputs:t,backend:n,attrs:a}=e,{numBuckets:r}=a,{input:s}=t;if(s.dtype!=="string")throw new Error("Input must be of datatype string");if(r<=0)throw new Error("Number of buckets must be at least 1");let i=n.data.get(s.dataId).values,o=S6(i,r);return n.makeTensorInfo(s.shape,"int32",o)}var fX={kernelName:vh,backendName:"cpu",kernelFunc:hX},mX=ct(Ui,e=>Math.tan(e)),gX={kernelName:Ui,backendName:"cpu",kernelFunc:mX},yX=ct(ji,e=>Math.tanh(e)),AX={kernelName:ji,backendName:"cpu",kernelFunc:yX};function xX(e){let{inputs:t,backend:n,attrs:a}=e,{x:r}=t,{reps:s}=a;Te(r,"tile");let i=T6(n.bufferSync(r),s);return n.makeTensorInfo(i.shape,i.dtype,i.values)}var bX={kernelName:ds,backendName:"cpu",kernelFunc:xX};function vX(e){let{inputs:t,backend:n,attrs:a}=e,{x:r}=t,{k:s,sorted:i}=a;Te(r,"topk");let o=n.data.get(r.dataId).values,[l,d]=E6(o,r.shape,r.dtype,s,i);return
` ),s=r.length.toString().length+2,i=r.map((p,c)=>w.rightPad((c+1).toString(),s)+p),o=0;for(let p=0;p<i.length;p++)o=Math.max(i[p].length,o);let l=i.slice(0,a-1),d=i.slice(a-1,a),u=i.slice(a);console.log(l.join( `
2021-09-11 16:29:31 +02:00
` )),console.log(t.split( `
2021-10-22 22:09:52 +02:00
` )[0]),console.log( ` % c $ { w . rightPad ( d [ 0 ] , o ) } ` ,"border:1px solid red; background-color:#e3d2d2; color:#a61717"),console.log(u.join( `
` ))}function t4(e){return Gr(e,()=>e.createProgram(),"Unable to create WebGLProgram.")}function n4(e,t){if(Se(e,()=>e.linkProgram(t)),e.getProgramParameter(t,e.LINK_STATUS)===!1)throw console.log(e.getProgramInfoLog(t)),new Error("Failed to link vertex and fragment shaders.")}function df(e,t){if(Se(e,()=>e.validateProgram(t)),e.getProgramParameter(t,e.VALIDATE_STATUS)===!1)throw console.log(e.getProgramInfoLog(t)),new Error("Shader program validation failed.")}function a4(e,t){let n=Gr(e,()=>e.createBuffer(),"Unable to create WebGLBuffer");return Se(e,()=>e.bindBuffer(e.ARRAY_BUFFER,n)),Se(e,()=>e.bufferData(e.ARRAY_BUFFER,t,e.STATIC_DRAW)),n}function r4(e,t){let n=Gr(e,()=>e.createBuffer(),"Unable to create WebGLBuffer");return Se(e,()=>e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,n)),Se(e,()=>e.bufferData(e.ELEMENT_ARRAY_BUFFER,t,e.STATIC_DRAW)),n}function qX(){return ne().getNumber("WEBGL_VERSION")===2?1:4}function s4(e){return Gr(e,()=>e.createTexture(),"Unable to create WebGLTexture.")}function i4(e,t){let n=ne().getNumber("WEBGL_MAX_TEXTURE_SIZE");if(e<=0||t<=0){let a= ` [ $ { e } x$ { t } ] ` ;throw new Error("Requested texture size "+a+" is invalid.")}if(e>n||t>n){let a= ` [ $ { e } x$ { t } ] ` ,r= ` [ $ { n } x$ { n } ] ` ;throw new Error("Requested texture size "+a+" greater than WebGL maximum on this browser / GPU "+r+".")}}function o4(e){return Gr(e,()=>e.createFramebuffer(),"Unable to create WebGLFramebuffer.")}function M2(e,t,n,a,r,s,i){let o=e.getAttribLocation(t,n);return o===-1?!1:(Se(e,()=>e.bindBuffer(e.ARRAY_BUFFER,a)),Se(e,()=>e.vertexAttribPointer(o,r,e.FLOAT,!1,s,i)),Se(e,()=>e.enableVertexAttribArray(o)),!0)}function l4(e,t,n){h4(e,n),Se(e,()=>e.activeTexture(e.TEXTURE0+n)),Se(e,()=>e.bindTexture(e.TEXTURE_2D,t))}function XX(e,t){h4(e,t),Se(e,()=>e.activeTexture(e.TEXTURE0+t)),Se(e,()=>e.bindTexture(e.TEXTURE_2D,null))}function u4(e,t,n){return Gr(e,()=>e.getUniformLocation(t,n),'uniform "'+n+'" not present in program.')}function d4(e,t,n){return e.getUniformLocation(t,n)}function p4(e,t,n,a){Se(e,()=>l4(e,t,a)),Se(e,()=>e.uniform1i(n,a))}function KX(e){Se(e,()=>e.bindFramebuffer(e.FRAMEBUFFER,null)),Se(e,()=>e.viewport(0,0,e.canvas.width,e.canvas.height)),Se(e,()=>e.scissor(0,0,e.canvas.width,e.canvas.height))}function pf(e,t,n){Se(e,()=>e.bindFramebuffer(e.FRAMEBUFFER,n)),Se(e,()=>e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,t,0))}function F2(e,t){Se(e,()=>e.bindFramebuffer(e.FRAMEBUFFER,t)),Se(e,()=>e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,null,0))}function _p(e){let t=e.checkFramebufferStatus(e.FRAMEBUFFER);if(t!==e.FRAMEBUFFER_COMPLETE)throw new Error("Error binding framebuffer: "+c4(e,t))}function c4(e,t){switch(t){case e.FRAMEBUFFER_INCOMPLETE_ATTACHMENT:return"FRAMEBUFFER_INCOMPLETE_ATTACHMENT";case e.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT:return"FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT";case e.FRAMEBUFFER_INCOMPLETE_DIMENSIONS:return"FRAMEBUFFER_INCOMPLETE_DIMENSIONS";case e.FRAMEBUFFER_UNSUPPORTED:return"FRAMEBUFFER_UNSUPPORTED";default:return ` unknown error $ { t } ` }}function Gr(e,t,n){let a=Se(e,()=>t());if(a==null)throw new Error(n);return a}function h4(e,t){let n=e.MAX_COMBINED_TEXTURE_IMAGE_UNITS-1,a=t+e.TEXTURE0;if(a<e.TEXTURE0||a>n){let r= ` [ gl . TEXTURE0 , gl . TEXTURE$ { n } ] ` ;throw new Error( ` textureUnit must be in $ { r } . ` )}}function Io(e,t=2){return w.sizeFromShape(e.slice(0,e.length-t))}function So(e){if(e.length===0)throw Error("Cannot get rows and columns of an empty shape array.");return[e.length>1?e[e.length-2]:1,e[e.length-1]]}function cf(e){let t=[1,1,1];return e.length===0||e.length===1&&e[0]===1||(t=[Io(e),...So(e)]),t}function f4(e,t=!1){let n=ne().getNumber("WEBGL_MAX_TEXTURE_SIZE");t&&(n=n*2,e=e.map((r,s)=>s>=e.length-2?w.nearestLargerEven(e[s]):e[s]),e.length===1&&(e=[2,e[0]])),e.length!==2&&(e=w.squeezeShape(e).newShape);let a=w.sizeFromShape(e);if(e.length<=1&&a<=n)return[1,a];if(e.length===2&&e[0]<=n&&e[1]<=n)return e;if(e.length===3&&e[0]*e[1]<=n&&e[2]<=n)return[e[0]*e[1],e[2]];if(e.length===3&&e[0]<=n&&e[1]*e[2]<=n)return[e[0],e[1]*e[2]];if(e.length===4&&e[0]*e
2021-09-11 16:29:31 +02:00
bool isnan _custom ( float val ) {
return ( val > 0.0 || val < 0.0 ) ? false : val != 0.0 ;
}
bvec4 isnan _custom ( vec4 val ) {
return bvec4 ( isnan _custom ( val . x ) ,
isnan _custom ( val . y ) , isnan _custom ( val . z ) , isnan _custom ( val . w ) ) ;
}
# define isnan ( value ) isnan _custom ( value )
2021-10-22 22:09:52 +02:00
` ,l="",d= `
2021-09-11 16:29:31 +02:00
# define round ( value ) newRound ( value )
int newRound ( float value ) {
return int ( floor ( value + 0.5 ) ) ;
}
ivec4 newRound ( vec4 value ) {
return ivec4 ( floor ( value + vec4 ( 0.5 ) ) ) ;
}
2021-10-22 22:09:52 +02:00
` ):(e="",t="attribute",n="varying",a="varying",r="texture2D",s="gl_FragColor",i="",o= `
2021-09-11 16:29:31 +02:00
# define isnan ( value ) isnan _custom ( value )
bool isnan _custom ( float val ) {
return ( val > 0. || val < 1. || val == 0. ) ? false : true ;
}
bvec4 isnan _custom ( vec4 val ) {
return bvec4 ( isnan ( val . x ) , isnan ( val . y ) , isnan ( val . z ) , isnan ( val . w ) ) ;
}
` ,l= `
uniform float INFINITY ;
bool isinf ( float val ) {
return abs ( val ) == INFINITY ;
}
bvec4 isinf ( vec4 val ) {
return equal ( abs ( val ) , vec4 ( INFINITY ) ) ;
}
2021-10-22 22:09:52 +02:00
` ,d= `
2021-09-11 16:29:31 +02:00
int round ( float value ) {
return int ( floor ( value + 0.5 ) ) ;
}
2021-07-29 22:35:16 +02:00
2021-09-11 16:29:31 +02:00
ivec4 round ( vec4 value ) {
return ivec4 ( floor ( value + vec4 ( 0.5 ) ) ) ;
}
2021-10-22 22:09:52 +02:00
` ),{version:e,attribute:t,varyingVs:n,varyingFs:a,texture2D:r,output:s,defineOutput:i,defineSpecialNaN:o,defineSpecialInf:l,defineRound:d}}function No(e,t,n="index"){let a=w.computeStrides(t);return a.map((r,s)=>{let i= ` int $ { e [ s ] } = $ { n } / $ { r } ` ,o=s===a.length-1? ` int $ { e [ s + 1 ] } = $ { n } - $ { e [ s ] } * $ { r } ` : ` index -= $ { e [ s ] } * $ { r } ` ;return ` $ { i } ; $ { o } ; ` }).join("")}function gf(e,t,n="index"){let a=w.computeStrides(t);return a.map((r,s)=>{let i= ` int $ { e [ s ] } = $ { n } / outShapeStrides [ $ { s } ] ` ,o=s===a.length-1? ` int $ { e [ s + 1 ] } = $ { n } - $ { e [ s ] } * outShapeStrides [ $ { s } ] ` : ` index -= $ { e [ s ] } * outShapeStrides [ $ { s } ] ` ;return ` $ { i } ; $ { o } ; ` }).join("")}function QX(e,t){let n=e.length,a=e.map(s=> ` $ { t } [ $ { s } ] ` ),r=new Array(n-1);r[n-2]=a[n-1];for(let s=n-3;s>=0;--s)r[s]= ` ( $ { r [ s + 1 ] } * $ { a [ s + 1 ] } ) ` ;return r}function eK(e,t,n="index"){let a=e.map((s,i)=>i),r=QX(a,t);return r.map((s,i)=>{let o= ` int $ { e [ i ] } = $ { n } / $ { r [ i ] } ` ,l=i===r.length-1? ` int $ { e [ i + 1 ] } = $ { n } - $ { e [ i ] } * $ { r [ i ] } ` : ` index -= $ { e [ i ] } * $ { r [ i ] } ` ;return ` $ { o } ; $ { l } ; ` }).join("")}function O2(e){let t=w.computeStrides(e).map(n=>n.toString());return `
2021-09-11 16:29:31 +02:00
int getFlatIndex ( ivec3 coords ) {
return coords . x * $ { t [ 0 ] } + coords . y * $ { t [ 1 ] } + coords . z ;
2021-08-14 17:16:26 +02:00
}
2021-10-22 22:09:52 +02:00
` }function _2(){return `
2021-09-11 16:29:31 +02:00
int getFlatIndex ( ivec3 coords ) {
return coords . x * outShapeStrides [ 0 ] + coords . y * outShapeStrides [ 1 ] + coords . z ;
2021-08-31 19:00:06 +02:00
}
2021-10-22 22:09:52 +02:00
` }var v4= `
2021-09-11 16:29:31 +02:00
const float FLOAT _MAX = 1.70141184 e38 ;
const float FLOAT _MIN = 1.17549435 e - 38 ;
lowp vec4 encode _float ( highp float v ) {
if ( isnan ( v ) ) {
return vec4 ( 255 , 255 , 255 , 255 ) ;
}
highp float av = abs ( v ) ;
if ( av < FLOAT _MIN ) {
return vec4 ( 0.0 , 0.0 , 0.0 , 0.0 ) ;
} else if ( v > FLOAT _MAX ) {
return vec4 ( 0.0 , 0.0 , 128.0 , 127.0 ) / 255.0 ;
} else if ( v < - FLOAT _MAX ) {
return vec4 ( 0.0 , 0.0 , 128.0 , 255.0 ) / 255.0 ;
}
highp vec4 c = vec4 ( 0 , 0 , 0 , 0 ) ;
highp float e = floor ( log2 ( av ) ) ;
highp float m = exp2 ( fract ( log2 ( av ) ) ) - 1.0 ;
c [ 2 ] = floor ( 128.0 * m ) ;
m -= c [ 2 ] / 128.0 ;
c [ 1 ] = floor ( 32768.0 * m ) ;
m -= c [ 1 ] / 32768.0 ;
c [ 0 ] = floor ( 8388608.0 * m ) ;
highp float ebias = e + 127.0 ;
c [ 3 ] = floor ( ebias / 2.0 ) ;
ebias -= c [ 3 ] * 2.0 ;
c [ 2 ] += floor ( ebias ) * 128.0 ;
c [ 3 ] += 128.0 * step ( 0.0 , - v ) ;
return c / 255.0 ;
2021-08-14 17:17:51 +02:00
}
2021-10-22 22:09:52 +02:00
` ,{getBroadcastDims:w4}=E;function tK(e,t,n){let a=[];if(e.forEach(c=>{let h=w.sizeFromShape(c.shapeInfo.logicalShape);if(c.shapeInfo.isUniform?a.push( ` uniform float $ { c . name } $ { h > 1 ? ` [ ${ h } ] ` : "" } ; ` ):(a.push( ` uniform sampler2D $ { c . name } ; ` ),a.push( ` uniform int offset$ { c . name } ; ` )),n.enableShapeUniforms){let{uniformShape:f}=P2(n.packedInputs,c.shapeInfo.logicalShape,c.shapeInfo.texShape);switch(f.length){case 1:a.push( ` uniform int $ { c . name } Shape ; ` );break;case 2:a.push( ` uniform ivec2 $ { c . name } Shape ; ` );break;case 3:a.push( ` uniform ivec3 $ { c . name } Shape ; ` );break;case 4:a.push( ` uniform ivec4 $ { c . name } Shape ; ` );break;default:break}a.push( ` uniform ivec2 $ { c . name } TexShape ; ` )}}),n.enableShapeUniforms){switch(t.logicalShape.length){case 1:a.push("uniform int outShape;");break;case 2:a.push("uniform ivec2 outShape;"),a.push("uniform int outShapeStrides;");break;case 3:a.push("uniform ivec3 outShape;"),a.push("uniform ivec2 outShapeStrides;");break;case 4:a.push("uniform ivec4 outShape;"),a.push("uniform ivec3 outShapeStrides;");break;default:break}a.push("uniform ivec2 outTexShape;")}n.customUniforms&&n.customUniforms.forEach(c=>{a.push( ` uniform $ { c . type } $ { c . name } $ { c . arrayIndex ? ` [ ${ c . arrayIndex } ] ` : "" } ; ` )});let r=a.join( `
` ),s=e.map(c=>nK(c,t,n.packedInputs,n.enableShapeUniforms)).join( `
` ),i=t.texShape,o= $ n(),l=sK(o),d,u,p=lK(o);return t.isPacked?(d=aK(t.logicalShape,i,n.enableShapeUniforms),u=oK(o)):(d=rK(t.logicalShape,i,n.enableShapeUniforms),u=iK(o)),n.packedInputs&&(p+=cK),[p,l,u,r,d,s,n.userCode].join( `
` )}function Fu(e,t=!1){let n=e.shapeInfo.logicalShape;switch(n.length){case 0:return IK(e,t);case 1:return NK(e,t);case 2:return CK(e,t);case 3:return RK(e,t);case 4:return FK(e,t);case 5:return DK(e);case 6:return $ K(e);default:throw new Error( ` $ { n . length } - D input sampling is not yet supported ` )}}function k4(e,t){switch(e.shapeInfo.logicalShape.length){case 0:return kK(e);case 1:return SK(e,t);case 2:return TK(e,t);case 3:return EK(e,t);default:return MK(e,t)}}function nK(e,t,n=!1,a){let r="";n?r+=k4(e,a):r+=Fu(e,a);let s=e.shapeInfo.logicalShape,i=t.logicalShape;return s.length<=i.length&&(n?r+=OK(e,t):r+=_K(e,t)),r}function aK(e,t,n){switch(e.length){case 0:return I4();case 1:return hK(e,t,n);case 2:return vK(e,t,n);case 3:return mK(e,t,n);default:return yK(e,t,n)}}function rK(e,t,n){switch(e.length){case 0:return I4();case 1:return fK(e,t,n);case 2:return wK(e,t,n);case 3:return gK(e,t,n);case 4:return AK(e,t,n);case 5:return xK(e,t);case 6:return bK(e,t);default:throw new Error( ` $ { e . length } - D output sampling is not yet supported ` )}}function sK(e){return `
2021-09-11 16:29:31 +02:00
float sampleTexture ( sampler2D textureSampler , vec2 uv ) {
return $ { e . texture2D } ( textureSampler , uv ) . r ;
}
2021-10-22 22:09:52 +02:00
` }function iK(e){return `
2021-09-11 16:29:31 +02:00
void setOutput ( float val ) {
$ { e . output } = vec4 ( val , 0 , 0 , 0 ) ;
}
2021-10-22 22:09:52 +02:00
` }function oK(e){return `
2021-09-11 16:29:31 +02:00
void setOutput ( vec4 val ) {
$ { e . output } = val ;
}
2021-10-22 22:09:52 +02:00
` }function lK(e){return ` $ { e . version }
2021-09-11 16:29:31 +02:00
precision highp float ;
precision highp int ;
precision highp sampler2D ;
$ { e . varyingFs } vec2 resultUV ;
$ { e . defineOutput }
const vec2 halfCR = vec2 ( 0.5 , 0.5 ) ;
2021-08-14 17:17:51 +02:00
2021-09-11 16:29:31 +02:00
struct ivec5
{
int x ;
int y ;
int z ;
int w ;
int u ;
} ;
struct ivec6
{
int x ;
int y ;
int z ;
int w ;
int u ;
int v ;
} ;
uniform float NAN ;
$ { e . defineSpecialNaN }
$ { e . defineSpecialInf }
$ { e . defineRound }
int imod ( int x , int y ) {
return x - y * ( x / y ) ;
2021-09-01 00:24:30 +02:00
}
2021-09-11 16:29:31 +02:00
int idiv ( int a , int b , float sign ) {
int res = a / b ;
int mod = imod ( a , b ) ;
if ( sign < 0. && mod != 0 ) {
res -= 1 ;
2021-09-05 22:42:11 +02:00
}
2021-09-11 16:29:31 +02:00
return res ;
}
//Based on the work of Dave Hoskins
//https://www.shadertoy.com/view/4djSRW
# define HASHSCALE1 443.8975
float random ( float seed ) {
vec2 p = resultUV * seed ;
vec3 p3 = fract ( vec3 ( p . xyx ) * HASHSCALE1 ) ;
p3 += dot ( p3 , p3 . yzx + 19.19 ) ;
return fract ( ( p3 . x + p3 . y ) * p3 . z ) ;
2021-06-05 21:10:28 +02:00
}
2021-09-05 22:42:11 +02:00
2021-10-22 22:09:52 +02:00
$ { uK }
$ { dK }
$ { pK }
` }var uK= `
2021-09-11 16:29:31 +02:00
vec2 uvFromFlat ( int texNumR , int texNumC , int index ) {
int texR = index / texNumC ;
int texC = index - texR * texNumC ;
return ( vec2 ( texC , texR ) + halfCR ) / vec2 ( texNumC , texNumR ) ;
}
vec2 packedUVfrom1D ( int texNumR , int texNumC , int index ) {
int texelIndex = index / 2 ;
int texR = texelIndex / texNumC ;
int texC = texelIndex - texR * texNumC ;
return ( vec2 ( texC , texR ) + halfCR ) / vec2 ( texNumC , texNumR ) ;
}
2021-10-22 22:09:52 +02:00
` ,dK= `
2021-09-11 16:29:31 +02:00
vec2 packedUVfrom2D ( int texelsInLogicalRow , int texNumR ,
int texNumC , int row , int col ) {
int texelIndex = ( row / 2 ) * texelsInLogicalRow + ( col / 2 ) ;
int texR = texelIndex / texNumC ;
int texC = texelIndex - texR * texNumC ;
return ( vec2 ( texC , texR ) + halfCR ) / vec2 ( texNumC , texNumR ) ;
}
2021-10-22 22:09:52 +02:00
` ,pK= `
2021-09-11 16:29:31 +02:00
vec2 packedUVfrom3D ( int texNumR , int texNumC ,
int texelsInBatch , int texelsInLogicalRow , int b ,
int row , int col ) {
int index = b * texelsInBatch + ( row / 2 ) * texelsInLogicalRow + ( col / 2 ) ;
int texR = index / texNumC ;
int texC = index - texR * texNumC ;
return ( vec2 ( texC , texR ) + halfCR ) / vec2 ( texNumC , texNumR ) ;
}
2021-10-22 22:09:52 +02:00
` ,cK= `
2021-09-11 16:29:31 +02:00
float getChannel ( vec4 frag , vec2 innerDims ) {
vec2 modCoord = mod ( innerDims , 2. ) ;
return modCoord . x == 0. ?
( modCoord . y == 0. ? frag . r : frag . g ) :
( modCoord . y == 0. ? frag . b : frag . a ) ;
}
float getChannel ( vec4 frag , int dim ) {
float modCoord = mod ( float ( dim ) , 2. ) ;
return modCoord == 0. ? frag . r : frag . g ;
}
2021-10-22 22:09:52 +02:00
` ;function I4(){return `
2021-09-11 16:29:31 +02:00
int getOutputCoords ( ) {
return 0 ;
2021-06-05 21:10:28 +02:00
}
2021-10-22 22:09:52 +02:00
` }function hK(e,t,n){let a=[Math.ceil(t[0]/2),Math.ceil(t[1]/2)];return a[0]===1?n? `
2021-09-11 16:29:31 +02:00
int getOutputCoords ( ) {
return 2 * int ( resultUV . x * ceil ( float ( outTexShape [ 1 ] ) / 2.0 ) ) ;
2021-08-14 17:17:51 +02:00
}
2021-09-11 16:29:31 +02:00
` : `
int getOutputCoords ( ) {
2021-10-22 22:09:52 +02:00
return 2 * int ( resultUV . x * $ { a [ 1 ] } . 0 ) ;
2021-08-14 17:17:51 +02:00
}
2021-10-22 22:09:52 +02:00
` :a[1]===1?n? `
2021-09-11 16:29:31 +02:00
int getOutputCoords ( ) {
return 2 * int ( resultUV . y * ceil ( float ( outTexShape [ 0 ] ) / 2.0 ) ) ;
2021-08-14 17:17:51 +02:00
}
2021-09-11 16:29:31 +02:00
` : `
int getOutputCoords ( ) {
2021-10-22 22:09:52 +02:00
return 2 * int ( resultUV . y * $ { a [ 0 ] } . 0 ) ;
2021-08-14 17:17:51 +02:00
}
2021-09-11 16:29:31 +02:00
` :n? `
int getOutputCoords ( ) {
ivec2 packedTexShape = ivec2 ( ceil ( float ( outTexShape [ 0 ] ) / 2.0 ) , ceil ( float ( outTexShape [ 1 ] ) / 2.0 ) ) ;
ivec2 resTexRC = ivec2 ( resultUV . yx *
vec2 ( packedTexShape [ 0 ] , packedTexShape [ 1 ] ) ) ;
return 2 * ( resTexRC . x * packedTexShape [ 1 ] + resTexRC . y ) ;
}
` : `
int getOutputCoords ( ) {
ivec2 resTexRC = ivec2 ( resultUV . yx *
2021-10-22 22:09:52 +02:00
vec2 ( $ { a [ 0 ] } , $ { a [ 1 ] } ) ) ;
return 2 * ( resTexRC . x * $ { a [ 1 ] } + resTexRC . y ) ;
2021-09-11 16:29:31 +02:00
}
2021-10-22 22:09:52 +02:00
` }function fK(e,t,n){return t[0]===1?n? `
2021-09-11 16:29:31 +02:00
int getOutputCoords ( ) {
return int ( resultUV . x * float ( outTexShape [ 1 ] ) ) ;
2021-08-14 17:17:51 +02:00
}
2021-09-11 16:29:31 +02:00
` : `
int getOutputCoords ( ) {
return int ( resultUV . x * $ { t [ 1 ] } . 0 ) ;
2021-08-14 17:17:51 +02:00
}
2021-09-11 16:29:31 +02:00
` :t[1]===1?n? `
int getOutputCoords ( ) {
return int ( resultUV . y * float ( outTexShape [ 0 ] ) ) ;
2021-08-14 17:17:51 +02:00
}
2021-09-11 16:29:31 +02:00
` : `
int getOutputCoords ( ) {
return int ( resultUV . y * $ { t [ 0 ] } . 0 ) ;
2021-08-14 17:17:51 +02:00
}
2021-09-11 16:29:31 +02:00
` :n? `
int getOutputCoords ( ) {
ivec2 resTexRC = ivec2 ( resultUV . yx *
vec2 ( outTexShape [ 0 ] , outTexShape [ 1 ] ) ) ;
return resTexRC . x * outTexShape [ 1 ] + resTexRC . y ;
2021-07-29 15:53:13 +02:00
}
2021-09-11 16:29:31 +02:00
` : `
int getOutputCoords ( ) {
ivec2 resTexRC = ivec2 ( resultUV . yx *
vec2 ( $ { t [ 0 ] } , $ { t [ 1 ] } ) ) ;
return resTexRC . x * $ { t [ 1 ] } + resTexRC . y ;
2021-06-05 21:10:28 +02:00
}
2021-10-22 22:09:52 +02:00
` }function mK(e,t,n){if(n)return `
2021-09-11 16:29:31 +02:00
ivec3 getOutputCoords ( ) {
ivec2 packedTexShape = ivec2 ( ceil ( float ( outTexShape [ 0 ] ) / 2.0 ) , ceil ( float ( outTexShape [ 1 ] ) / 2.0 ) ) ;
int texelsInLogicalRow = int ( ceil ( float ( outShape [ 2 ] ) / 2.0 ) ) ;
int texelsInBatch = texelsInLogicalRow * int ( ceil ( float ( outShape [ 1 ] ) / 2.0 ) ) ;
ivec2 resTexRC = ivec2 ( resultUV . yx *
vec2 ( packedTexShape [ 0 ] , packedTexShape [ 1 ] ) ) ;
int index = resTexRC . x * packedTexShape [ 1 ] + resTexRC . y ;
int b = index / texelsInBatch ;
index -= b * texelsInBatch ;
int r = 2 * ( index / texelsInLogicalRow ) ;
int c = imod ( index , texelsInLogicalRow ) * 2 ;
return ivec3 ( b , r , c ) ;
2021-06-05 21:10:28 +02:00
}
2021-10-22 22:09:52 +02:00
` ;let a=[Math.ceil(t[0]/2),Math.ceil(t[1]/2)],r=Math.ceil(e[2]/2),s=r*Math.ceil(e[1]/2);return `
2021-09-11 16:29:31 +02:00
ivec3 getOutputCoords ( ) {
ivec2 resTexRC = ivec2 ( resultUV . yx *
2021-10-22 22:09:52 +02:00
vec2 ( $ { a [ 0 ] } , $ { a [ 1 ] } ) ) ;
int index = resTexRC . x * $ { a [ 1 ] } + resTexRC . y ;
2021-09-11 16:29:31 +02:00
2021-10-22 22:09:52 +02:00
int b = index / $ { s } ;
index -= b * $ { s } ;
2021-09-11 16:29:31 +02:00
2021-10-04 23:03:36 +02:00
int r = 2 * ( index / $ { r } ) ;
int c = imod ( index , $ { r } ) * 2 ;
2021-09-11 16:29:31 +02:00
return ivec3 ( b , r , c ) ;
2021-07-29 15:53:13 +02:00
}
2021-10-22 22:09:52 +02:00
` }function gK(e,t,n){if(n)return `
2021-09-11 16:29:31 +02:00
ivec3 getOutputCoords ( ) {
ivec2 resTexRC = ivec2 ( resultUV . yx *
vec2 ( outTexShape [ 0 ] , outTexShape [ 1 ] ) ) ;
int index = resTexRC . x * outTexShape [ 1 ] + resTexRC . y ;
2021-10-22 22:09:52 +02:00
$ { gf ( [ "r" , "c" , "d" ] , e ) }
2021-09-11 16:29:31 +02:00
return ivec3 ( r , c , d ) ;
}
2021-10-22 22:09:52 +02:00
` ;let a=No(["r","c","d"],e);return `
2021-09-11 16:29:31 +02:00
ivec3 getOutputCoords ( ) {
ivec2 resTexRC = ivec2 ( resultUV . yx *
vec2 ( $ { t [ 0 ] } , $ { t [ 1 ] } ) ) ;
int index = resTexRC . x * $ { t [ 1 ] } + resTexRC . y ;
2021-10-22 22:09:52 +02:00
$ { a }
2021-09-11 16:29:31 +02:00
return ivec3 ( r , c , d ) ;
2021-06-05 21:10:28 +02:00
}
2021-10-22 22:09:52 +02:00
` }function yK(e,t,n){if(n)return `
2021-09-11 16:29:31 +02:00
ivec4 getOutputCoords ( ) {
ivec2 packedTexShape = ivec2 ( ceil ( float ( outTexShape [ 0 ] ) / 2.0 ) , ceil ( float ( outTexShape [ 1 ] ) / 2.0 ) ) ;
ivec2 resTexRC = ivec2 ( resultUV . yx *
vec2 ( packedTexShape [ 0 ] , packedTexShape [ 1 ] ) ) ;
int index = resTexRC . x * packedTexShape [ 1 ] + resTexRC . y ;
int texelsInLogicalRow = int ( ceil ( float ( outShape [ 3 ] ) / 2.0 ) ) ;
int texelsInBatch = texelsInLogicalRow * int ( ceil ( float ( outShape [ 2 ] ) / 2.0 ) ) ;
int texelsInBatchN = texelsInBatch * outShape [ 1 ] ;
int b2 = index / texelsInBatchN ;
index -= b2 * texelsInBatchN ;
int b = index / texelsInBatch ;
index -= b * texelsInBatch ;
int r = 2 * ( index / texelsInLogicalRow ) ;
int c = imod ( index , texelsInLogicalRow ) * 2 ;
return ivec4 ( b2 , b , r , c ) ;
2021-07-29 15:53:13 +02:00
}
2021-10-22 22:09:52 +02:00
` ;let a=[Math.ceil(t[0]/2),Math.ceil(t[1]/2)],r=Math.ceil(e[e.length-1]/2),s=r*Math.ceil(e[e.length-2]/2),i=s,o="",l="b, r, c";for(let d=2;d<e.length-1;d++)i*=e[e.length-d-1],o= `
int b$ { d } = index / $ { i } ;
index -= b$ { d } * $ { i } ;
` +o,l= ` b$ { d } , ` +l;return `
2021-09-11 16:29:31 +02:00
ivec$ { e . length } getOutputCoords ( ) {
ivec2 resTexRC = ivec2 ( resultUV . yx *
2021-10-22 22:09:52 +02:00
vec2 ( $ { a [ 0 ] } , $ { a [ 1 ] } ) ) ;
int index = resTexRC . x * $ { a [ 1 ] } + resTexRC . y ;
2021-09-11 16:29:31 +02:00
2021-10-22 22:09:52 +02:00
$ { o }
2021-09-11 16:29:31 +02:00
2021-10-22 22:09:52 +02:00
int b = index / $ { s } ;
index -= b * $ { s } ;
2021-09-11 16:29:31 +02:00
2021-10-04 23:03:36 +02:00
int r = 2 * ( index / $ { r } ) ;
int c = imod ( index , $ { r } ) * 2 ;
2021-09-11 16:29:31 +02:00
return ivec$ { e . length } ( $ { l } ) ;
2021-08-14 17:16:26 +02:00
}
2021-10-22 22:09:52 +02:00
` }function AK(e,t,n){if(n)return `
2021-09-11 16:29:31 +02:00
ivec4 getOutputCoords ( ) {
ivec2 resTexRC = ivec2 ( resultUV . yx *
vec2 ( outTexShape [ 0 ] , outTexShape [ 1 ] ) ) ;
int index = resTexRC . x * outTexShape [ 1 ] + resTexRC . y ;
2021-10-22 22:09:52 +02:00
$ { gf ( [ "r" , "c" , "d" , "d2" ] , e ) }
2021-09-11 16:29:31 +02:00
return ivec4 ( r , c , d , d2 ) ;
2021-08-14 17:16:26 +02:00
}
2021-10-22 22:09:52 +02:00
` ;let a=No(["r","c","d","d2"],e);return `
2021-09-11 16:29:31 +02:00
ivec4 getOutputCoords ( ) {
ivec2 resTexRC = ivec2 ( resultUV . yx *
vec2 ( $ { t [ 0 ] } , $ { t [ 1 ] } ) ) ;
int index = resTexRC . x * $ { t [ 1 ] } + resTexRC . y ;
2021-10-22 22:09:52 +02:00
$ { a }
2021-09-11 16:29:31 +02:00
return ivec4 ( r , c , d , d2 ) ;
2021-08-14 17:16:26 +02:00
}
2021-10-22 22:09:52 +02:00
` }function xK(e,t){let n=No(["r","c","d","d2","d3"],e);return `
2021-09-11 16:29:31 +02:00
ivec5 getOutputCoords ( ) {
ivec2 resTexRC = ivec2 ( resultUV . yx * vec2 ( $ { t [ 0 ] } ,
$ { t [ 1 ] } ) ) ;
int index = resTexRC . x * $ { t [ 1 ] } + resTexRC . y ;
$ { n }
ivec5 outShape = ivec5 ( r , c , d , d2 , d3 ) ;
return outShape ;
2021-08-14 17:17:51 +02:00
}
2021-10-22 22:09:52 +02:00
` }function bK(e,t){let n=No(["r","c","d","d2","d3","d4"],e);return `
2021-09-11 16:29:31 +02:00
ivec6 getOutputCoords ( ) {
ivec2 resTexRC = ivec2 ( resultUV . yx *
vec2 ( $ { t [ 0 ] } , $ { t [ 1 ] } ) ) ;
int index = resTexRC . x * $ { t [ 1 ] } + resTexRC . y ;
$ { n }
ivec6 result = ivec6 ( r , c , d , d2 , d3 , d4 ) ;
return result ;
2021-08-14 17:16:26 +02:00
}
2021-10-22 22:09:52 +02:00
` }function vK(e,t,n){let a=[Math.ceil(t[0]/2),Math.ceil(t[1]/2)];if(w.arraysEqual(e,t))return n? `
2021-09-11 16:29:31 +02:00
ivec2 getOutputCoords ( ) {
ivec2 packedTexShape = ivec2 ( ceil ( float ( outTexShape [ 0 ] ) / 2.0 ) , ceil ( float ( outTexShape [ 1 ] ) / 2.0 ) ) ;
return 2 * ivec2 ( resultUV . yx * vec2 ( packedTexShape [ 0 ] , packedTexShape [ 1 ] ) ) ;
}
` : `
ivec2 getOutputCoords ( ) {
2021-10-22 22:09:52 +02:00
return 2 * ivec2 ( resultUV . yx * vec2 ( $ { a [ 0 ] } , $ { a [ 1 ] } ) ) ;
2021-09-11 16:29:31 +02:00
}
2021-10-04 23:03:36 +02:00
` ;let r=Math.ceil(e[1]/2);return n? `
2021-09-11 16:29:31 +02:00
ivec2 getOutputCoords ( ) {
ivec2 packedTexShape = ivec2 ( ceil ( float ( outTexShape [ 0 ] ) / 2.0 ) , ceil ( float ( outTexShape [ 1 ] ) / 2.0 ) ) ;
int texelsInLogicalRow = int ( ceil ( float ( outShape [ 1 ] ) / 2.0 ) ) ;
ivec2 resTexRC = ivec2 ( resultUV . yx *
vec2 ( packedTexShape [ 0 ] , packedTexShape [ 1 ] ) ) ;
int index = resTexRC . x * packedTexShape [ 1 ] + resTexRC . y ;
int r = 2 * ( index / texelsInLogicalRow ) ;
int c = imod ( index , texelsInLogicalRow ) * 2 ;
return ivec2 ( r , c ) ;
2021-08-14 17:16:26 +02:00
}
2021-09-11 16:29:31 +02:00
` : `
ivec2 getOutputCoords ( ) {
ivec2 resTexRC = ivec2 ( resultUV . yx *
2021-10-22 22:09:52 +02:00
vec2 ( $ { a [ 0 ] } , $ { a [ 1 ] } ) ) ;
2021-09-11 16:29:31 +02:00
2021-10-22 22:09:52 +02:00
int index = resTexRC . x * $ { a [ 1 ] } + resTexRC . y ;
2021-10-04 23:03:36 +02:00
int r = 2 * ( index / $ { r } ) ;
int c = imod ( index , $ { r } ) * 2 ;
2021-09-11 16:29:31 +02:00
return ivec2 ( r , c ) ;
2021-08-14 17:16:26 +02:00
}
2021-10-22 22:09:52 +02:00
` }function wK(e,t,n){return w.arraysEqual(e,t)?n? `
2021-09-11 16:29:31 +02:00
ivec2 getOutputCoords ( ) {
return ivec2 ( resultUV . yx * vec2 ( outTexShape [ 0 ] , outTexShape [ 1 ] ) ) ;
}
` : `
ivec2 getOutputCoords ( ) {
return ivec2 ( resultUV . yx * vec2 ( $ { t [ 0 ] } , $ { t [ 1 ] } ) ) ;
}
` :e[1]===1?n? `
ivec2 getOutputCoords ( ) {
ivec2 resTexRC = ivec2 ( resultUV . yx *
vec2 ( outTexShape [ 0 ] , outTexShape [ 1 ] ) ) ;
int index = resTexRC . x * outTexShape [ 1 ] + resTexRC . y ;
return ivec2 ( index , 0 ) ;
}
` : `
ivec2 getOutputCoords ( ) {
ivec2 resTexRC = ivec2 ( resultUV . yx *
vec2 ( $ { t [ 0 ] } , $ { t [ 1 ] } ) ) ;
int index = resTexRC . x * $ { t [ 1 ] } + resTexRC . y ;
return ivec2 ( index , 0 ) ;
}
` :e[0]===1?n? `
ivec2 getOutputCoords ( ) {
ivec2 resTexRC = ivec2 ( resultUV . yx *
vec2 ( outTexShape [ 0 ] , outTexShape [ 1 ] ) ) ;
int index = resTexRC . x * outTexShape [ 1 ] + resTexRC . y ;
return ivec2 ( 0 , index ) ;
}
` : `
ivec2 getOutputCoords ( ) {
ivec2 resTexRC = ivec2 ( resultUV . yx *
vec2 ( $ { t [ 0 ] } , $ { t [ 1 ] } ) ) ;
int index = resTexRC . x * $ { t [ 1 ] } + resTexRC . y ;
return ivec2 ( 0 , index ) ;
}
` :n? `
ivec2 getOutputCoords ( ) {
ivec2 resTexRC = ivec2 ( resultUV . yx *
vec2 ( outTexShape [ 0 ] , outTexShape [ 1 ] ) ) ;
int index = resTexRC . x * outTexShape [ 1 ] + resTexRC . y ;
int r = index / outShape [ 1 ] ;
int c = index - r * outShape [ 1 ] ;
return ivec2 ( r , c ) ;
2021-08-14 17:16:26 +02:00
}
2021-09-11 16:29:31 +02:00
` : `
ivec2 getOutputCoords ( ) {
ivec2 resTexRC = ivec2 ( resultUV . yx *
vec2 ( $ { t [ 0 ] } , $ { t [ 1 ] } ) ) ;
int index = resTexRC . x * $ { t [ 1 ] } + resTexRC . y ;
int r = index / $ { e [ 1 ] } ;
int c = index - r * $ { e [ 1 ] } ;
return ivec2 ( r , c ) ;
2021-08-14 17:16:26 +02:00
}
2021-10-22 22:09:52 +02:00
` }function To(e){return ` offset$ { e } ` }function kK(e){let t=e.name,n="get"+t.charAt(0).toUpperCase()+t.slice(1),a= $ n();return `
2021-09-11 16:29:31 +02:00
vec4 $ { n } ( ) {
2021-10-22 22:09:52 +02:00
return $ { a . texture2D } ( $ { t } , halfCR ) ;
2021-08-14 17:16:26 +02:00
}
2021-10-22 22:09:52 +02:00
` }function IK(e,t){let n=e.name,a="get"+n.charAt(0).toUpperCase()+n.slice(1);if(e.shapeInfo.isUniform)return ` float $ { a } ( ) { return $ { n } ; } ` ;let[r,s]=e.shapeInfo.texShape;if(r===1&&s===1)return `
float $ { a } ( ) {
2021-09-11 16:29:31 +02:00
return sampleTexture ( $ { n } , halfCR ) ;
}
2021-10-22 22:09:52 +02:00
` ;let i=To(n);if(t)return `
float $ { a } ( ) {
vec2 uv = uvFromFlat ( $ { n } TexShape [ 0 ] , $ { n } TexShape [ 1 ] , $ { i } ) ;
2021-09-11 16:29:31 +02:00
return sampleTexture ( $ { n } , uv ) ;
2021-09-01 00:24:30 +02:00
}
2021-10-22 22:09:52 +02:00
` ;let[o,l]=e.shapeInfo.texShape;return `
float $ { a } ( ) {
vec2 uv = uvFromFlat ( $ { o } , $ { l } , $ { i } ) ;
2021-09-11 16:29:31 +02:00
return sampleTexture ( $ { n } , uv ) ;
}
2021-10-22 22:09:52 +02:00
` }function SK(e,t){let n=e.name,a="get"+n.charAt(0).toUpperCase()+n.slice(1),r=e.shapeInfo.texShape,s= $ n();if(t)return `
vec4 $ { a } ( int index ) {
2021-09-11 16:29:31 +02:00
ivec2 packedTexShape = ivec2 ( ceil ( float ( $ { n } TexShape [ 0 ] ) / 2.0 ) , ceil ( float ( $ { n } TexShape [ 1 ] ) / 2.0 ) ) ;
vec2 uv = packedUVfrom1D (
packedTexShape [ 0 ] , packedTexShape [ 1 ] , index ) ;
2021-10-22 22:09:52 +02:00
return $ { s . texture2D } ( $ { n } , uv ) ;
2021-09-11 16:29:31 +02:00
}
2021-10-22 22:09:52 +02:00
` ;let i=[Math.ceil(r[0]/2),Math.ceil(r[1]/2)];return `
vec4 $ { a } ( int index ) {
2021-09-11 16:29:31 +02:00
vec2 uv = packedUVfrom1D (
2021-10-22 22:09:52 +02:00
$ { i [ 0 ] } , $ { i [ 1 ] } , index ) ;
return $ { s . texture2D } ( $ { n } , uv ) ;
2021-09-11 16:29:31 +02:00
}
2021-10-22 22:09:52 +02:00
` }function NK(e,t){let n=e.name,a="get"+n.charAt(0).toUpperCase()+n.slice(1);if(e.shapeInfo.isUniform)return `
float $ { a } ( int index ) {
$ { Du ( e ) }
2021-09-11 16:29:31 +02:00
}
2021-10-22 22:09:52 +02:00
` ;let r=e.shapeInfo.texShape,s=r[0],i=r[1];if(i===1&&s===1)return `
float $ { a } ( int index ) {
2021-09-11 16:29:31 +02:00
return sampleTexture ( $ { n } , halfCR ) ;
}
2021-10-22 22:09:52 +02:00
` ;let o=To(n);return i===1?t? `
float $ { a } ( int index ) {
vec2 uv = vec2 ( 0.5 , ( float ( index + $ { o } ) + 0.5 ) / float ( $ { n } TexShape [ 0 ] ) ) ;
2021-09-11 16:29:31 +02:00
return sampleTexture ( $ { n } , uv ) ;
}
` : `
2021-10-22 22:09:52 +02:00
float $ { a } ( int index ) {
vec2 uv = vec2 ( 0.5 , ( float ( index + $ { o } ) + 0.5 ) / $ { s } . 0 ) ;
2021-09-11 16:29:31 +02:00
return sampleTexture ( $ { n } , uv ) ;
}
2021-10-22 22:09:52 +02:00
` :s===1?t? `
float $ { a } ( int index ) {
vec2 uv = vec2 ( ( float ( index + $ { o } ) + 0.5 ) / float ( $ { n } TexShape [ 1 ] ) , 0.5 ) ;
2021-09-11 16:29:31 +02:00
return sampleTexture ( $ { n } , uv ) ;
}
` : `
2021-10-22 22:09:52 +02:00
float $ { a } ( int index ) {
vec2 uv = vec2 ( ( float ( index + $ { o } ) + 0.5 ) / $ { i } . 0 , 0.5 ) ;
2021-09-11 16:29:31 +02:00
return sampleTexture ( $ { n } , uv ) ;
}
` :t? `
2021-10-22 22:09:52 +02:00
float $ { a } ( int index ) {
vec2 uv = uvFromFlat ( $ { n } TexShape [ 0 ] , $ { n } TexShape [ 1 ] , index + $ { o } ) ;
2021-09-11 16:29:31 +02:00
return sampleTexture ( $ { n } , uv ) ;
}
` : `
2021-10-22 22:09:52 +02:00
float $ { a } ( int index ) {
vec2 uv = uvFromFlat ( $ { s } , $ { i } , index + $ { o } ) ;
2021-09-11 16:29:31 +02:00
return sampleTexture ( $ { n } , uv ) ;
}
2021-10-22 22:09:52 +02:00
` }function TK(e,t){let n=e.shapeInfo.logicalShape,a=e.name,r="get"+a.charAt(0).toUpperCase()+a.slice(1),s=e.shapeInfo.texShape,i=s[0],o=s[1],l= $ n();if(s!=null&&w.arraysEqual(n,s))return t? `
2021-10-04 23:03:36 +02:00
vec4 $ { r } ( int row , int col ) {
2021-10-22 22:09:52 +02:00
vec2 uv = ( vec2 ( col , row ) + halfCR ) / vec2 ( $ { a } TexShape [ 1 ] , $ { a } TexShape [ 0 ] ) ;
2021-09-11 16:29:31 +02:00
2021-10-22 22:09:52 +02:00
return $ { l . texture2D } ( $ { a } , uv ) ;
2021-09-11 16:29:31 +02:00
}
` : `
2021-10-04 23:03:36 +02:00
vec4 $ { r } ( int row , int col ) {
2021-10-22 22:09:52 +02:00
vec2 uv = ( vec2 ( col , row ) + halfCR ) / vec2 ( $ { o } . 0 , $ { i } . 0 ) ;
2021-09-11 16:29:31 +02:00
2021-10-22 22:09:52 +02:00
return $ { l . texture2D } ( $ { a } , uv ) ;
2021-09-11 16:29:31 +02:00
}
` ;if(t)return `
2021-10-04 23:03:36 +02:00
vec4 $ { r } ( int row , int col ) {
2021-10-22 22:09:52 +02:00
ivec2 packedTexShape = ivec2 ( ceil ( float ( $ { a } TexShape [ 0 ] ) / 2.0 ) , ceil ( float ( $ { a } TexShape [ 1 ] ) / 2.0 ) ) ;
int valuesPerRow = int ( ceil ( float ( $ { a } Shape [ 1 ] ) / 2.0 ) ) ;
2021-09-11 16:29:31 +02:00
vec2 uv = packedUVfrom2D ( valuesPerRow , packedTexShape [ 0 ] , packedTexShape [ 1 ] , row , col ) ;
2021-10-22 22:09:52 +02:00
return $ { l . texture2D } ( $ { a } , uv ) ;
2021-09-11 16:29:31 +02:00
}
2021-10-22 22:09:52 +02:00
` ;let d=[Math.ceil(s[0]/2),Math.ceil(s[1]/2)],u=Math.ceil(n[1]/2);return `
2021-10-04 23:03:36 +02:00
vec4 $ { r } ( int row , int col ) {
2021-10-22 22:09:52 +02:00
vec2 uv = packedUVfrom2D ( $ { u } , $ { d [ 0 ] } , $ { d [ 1 ] } , row , col ) ;
return $ { l . texture2D } ( $ { a } , uv ) ;
2021-09-11 16:29:31 +02:00
}
2021-10-22 22:09:52 +02:00
` }function CK(e,t){let n=e.shapeInfo.logicalShape,a=e.name,r="get"+a.charAt(0).toUpperCase()+a.slice(1),s=e.shapeInfo.texShape;if(s!=null&&w.arraysEqual(n,s)){if(t)return `
2021-10-04 23:03:36 +02:00
float $ { r } ( int row , int col ) {
2021-10-22 22:09:52 +02:00
vec2 uv = ( vec2 ( col , row ) + halfCR ) / vec2 ( $ { a } TexShape [ 1 ] , $ { a } TexShape [ 0 ] ) ;
return sampleTexture ( $ { a } , uv ) ;
2021-10-04 23:03:36 +02:00
}
2021-10-22 22:09:52 +02:00
` ;let c=s[0],h=s[1];return `
2021-10-04 23:03:36 +02:00
float $ { r } ( int row , int col ) {
2021-10-22 22:09:52 +02:00
vec2 uv = ( vec2 ( col , row ) + halfCR ) / vec2 ( $ { h } . 0 , $ { c } . 0 ) ;
return sampleTexture ( $ { a } , uv ) ;
2021-09-11 16:29:31 +02:00
}
2021-10-22 22:09:52 +02:00
` }let{newShape:i,keptDims:o}=w.squeezeShape(n),l=i;if(l.length<n.length){let c= $ u(e,l),h=["row","col"];return `
$ { Fu ( c , t ) }
2021-10-04 23:03:36 +02:00
float $ { r } ( int row , int col ) {
2021-10-22 22:09:52 +02:00
return $ { r } ( $ { Ou ( h , o ) } ) ;
2021-09-11 16:29:31 +02:00
}
` }if(e.shapeInfo.isUniform)return `
2021-10-04 23:03:36 +02:00
float $ { r } ( int row , int col ) {
2021-09-11 16:29:31 +02:00
int index = round ( dot ( vec2 ( row , col ) , vec2 ( $ { n [ 1 ] } , 1 ) ) ) ;
2021-10-22 22:09:52 +02:00
$ { Du ( e ) }
2021-09-11 16:29:31 +02:00
}
2021-10-22 22:09:52 +02:00
` ;let d=s[0],u=s[1],p=To(a);return u===1?t? `
2021-10-04 23:03:36 +02:00
float $ { r } ( int row , int col ) {
2021-10-22 22:09:52 +02:00
float index = dot ( vec3 ( row , col , $ { p } ) , vec3 ( $ { a } Shape [ 1 ] , 1 , 1 ) ) ;
vec2 uv = vec2 ( 0.5 , ( index + 0.5 ) / float ( $ { a } TexShape [ 0 ] ) ) ;
return sampleTexture ( $ { a } , uv ) ;
2021-09-11 16:29:31 +02:00
}
` : `
2021-10-04 23:03:36 +02:00
float $ { r } ( int row , int col ) {
2021-10-22 22:09:52 +02:00
float index = dot ( vec3 ( row , col , $ { p } ) , vec3 ( $ { n [ 1 ] } , 1 , 1 ) ) ;
vec2 uv = vec2 ( 0.5 , ( index + 0.5 ) / $ { d } . 0 ) ;
return sampleTexture ( $ { a } , uv ) ;
2021-09-11 16:29:31 +02:00
}
2021-10-22 22:09:52 +02:00
` :d===1?t? `
2021-10-04 23:03:36 +02:00
float $ { r } ( int row , int col ) {
2021-10-22 22:09:52 +02:00
float index = dot ( vec3 ( row , col , $ { p } ) , vec3 ( $ { a } Shape [ 1 ] , 1 , 1 ) ) ;
vec2 uv = vec2 ( ( index + 0.5 ) / float ( $ { a } TexShape [ 1 ] ) , 0.5 ) ;
return sampleTexture ( $ { a } , uv ) ;
2021-09-11 16:29:31 +02:00
}
` : `
2021-10-04 23:03:36 +02:00
float $ { r } ( int row , int col ) {
2021-10-22 22:09:52 +02:00
float index = dot ( vec3 ( row , col , $ { p } ) , vec3 ( $ { n [ 1 ] } , 1 , 1 ) ) ;
2021-10-07 16:33:10 +02:00
vec2 uv = vec2 ( ( index + 0.5 ) / $ { u } . 0 , 0.5 ) ;
2021-10-22 22:09:52 +02:00
return sampleTexture ( $ { a } , uv ) ;
2021-09-11 16:29:31 +02:00
}
` :t? `
2021-10-04 23:03:36 +02:00
float $ { r } ( int row , int col ) {
2021-09-11 16:29:31 +02:00
// Explicitly use integer operations as dot() only works on floats.
2021-10-22 22:09:52 +02:00
int index = row * $ { a } Shape [ 1 ] + col + $ { p } ;
vec2 uv = uvFromFlat ( $ { a } TexShape [ 0 ] , $ { a } TexShape [ 1 ] , index ) ;
return sampleTexture ( $ { a } , uv ) ;
2021-09-11 16:29:31 +02:00
}
` : `
2021-10-04 23:03:36 +02:00
float $ { r } ( int row , int col ) {
2021-09-11 16:29:31 +02:00
// Explicitly use integer operations as dot() only works on floats.
2021-10-22 22:09:52 +02:00
int index = row * $ { n [ 1 ] } + col + $ { p } ;
vec2 uv = uvFromFlat ( $ { d } , $ { u } , index ) ;
return sampleTexture ( $ { a } , uv ) ;
2021-09-11 16:29:31 +02:00
}
2021-10-22 22:09:52 +02:00
` }function EK(e,t){let n=e.shapeInfo.logicalShape,a=e.name,r="get"+a.charAt(0).toUpperCase()+a.slice(1),s=e.shapeInfo.texShape,i=[Math.ceil(s[0]/2),Math.ceil(s[1]/2)];if(n[0]===1){let c=n.slice(1),h=[1,2],f= $ u(e,c),m=["b","row","col"];return `
$ { k4 ( f , t ) }
2021-10-04 23:03:36 +02:00
vec4 $ { r } ( int b , int row , int col ) {
2021-10-22 22:09:52 +02:00
return $ { r } ( $ { Ou ( m , h ) } ) ;
2021-10-04 23:03:36 +02:00
}
2021-10-22 22:09:52 +02:00
` }let o= $ n();if(t)return `
2021-10-04 23:03:36 +02:00
vec4 $ { r } ( int b , int row , int col ) {
2021-10-22 22:09:52 +02:00
ivec2 packedTexShape = ivec2 ( ceil ( float ( $ { a } TexShape [ 0 ] ) / 2.0 ) , ceil ( float ( $ { a } TexShape [ 1 ] ) / 2.0 ) ) ;
int valuesPerRow = int ( ceil ( float ( $ { a } Shape [ 2 ] ) / 2.0 ) ) ;
int texelsInBatch = valuesPerRow * int ( ceil ( float ( $ { a } Shape [ 1 ] ) / 2.0 ) ) ;
2021-09-11 16:29:31 +02:00
vec2 uv = packedUVfrom3D (
packedTexShape [ 0 ] , packedTexShape [ 1 ] , texelsInBatch , valuesPerRow , b , row , col ) ;
2021-10-22 22:09:52 +02:00
return $ { o . texture2D } ( $ { a } , uv ) ;
2021-09-11 16:29:31 +02:00
}
2021-10-22 22:09:52 +02:00
` ;let l=i[0],d=i[1],u=Math.ceil(n[2]/2),p=u*Math.ceil(n[1]/2);return `
2021-10-04 23:03:36 +02:00
vec4 $ { r } ( int b , int row , int col ) {
2021-09-11 16:29:31 +02:00
vec2 uv = packedUVfrom3D (
2021-10-22 22:09:52 +02:00
$ { l } , $ { d } , $ { p } , $ { u } , b , row , col ) ;
return $ { o . texture2D } ( $ { a } , uv ) ;
2021-09-11 16:29:31 +02:00
}
2021-10-22 22:09:52 +02:00
` }function RK(e,t){let n=e.shapeInfo.logicalShape,a=e.name,r="get"+a.charAt(0).toUpperCase()+a.slice(1),s=n[1]*n[2],i=n[2],{newShape:o,keptDims:l}=w.squeezeShape(n),d=o;if(d.length<n.length){let m= $ u(e,d),g=["row","col","depth"];return `
$ { Fu ( m , t ) }
2021-10-04 23:03:36 +02:00
float $ { r } ( int row , int col , int depth ) {
2021-10-22 22:09:52 +02:00
return $ { r } ( $ { Ou ( g , l ) } ) ;
2021-08-14 17:17:51 +02:00
}
2021-09-11 16:29:31 +02:00
` }if(e.shapeInfo.isUniform)return `
2021-10-04 23:03:36 +02:00
float $ { r } ( int row , int col , int depth ) {
2021-09-11 16:29:31 +02:00
int index = round ( dot ( vec3 ( row , col , depth ) ,
2021-10-22 22:09:52 +02:00
vec3 ( $ { s } , $ { i } , 1 ) ) ) ;
$ { Du ( e ) }
2021-09-11 16:29:31 +02:00
}
2021-10-22 22:09:52 +02:00
` ;let u=e.shapeInfo.texShape,p=u[0],c=u[1],h=e.shapeInfo.flatOffset;if(c===s&&h==null)return t? `
2021-10-04 23:03:36 +02:00
float $ { r } ( int row , int col , int depth ) {
2021-10-22 22:09:52 +02:00
int stride1 = $ { a } Shape [ 2 ] ;
2021-09-11 16:29:31 +02:00
float texR = float ( row ) ;
float texC = dot ( vec2 ( col , depth ) , vec2 ( stride1 , 1 ) ) ;
vec2 uv = ( vec2 ( texC , texR ) + halfCR ) /
2021-10-22 22:09:52 +02:00
vec2 ( $ { a } TexShape [ 1 ] , $ { a } TexShape [ 0 ] ) ;
return sampleTexture ( $ { a } , uv ) ;
2021-09-11 16:29:31 +02:00
}
` : `
2021-10-04 23:03:36 +02:00
float $ { r } ( int row , int col , int depth ) {
2021-09-11 16:29:31 +02:00
float texR = float ( row ) ;
2021-10-22 22:09:52 +02:00
float texC = dot ( vec2 ( col , depth ) , vec2 ( $ { i } , 1 ) ) ;
2021-09-11 16:29:31 +02:00
vec2 uv = ( vec2 ( texC , texR ) + halfCR ) /
2021-10-22 22:09:52 +02:00
vec2 ( $ { c } . 0 , $ { p } . 0 ) ;
return sampleTexture ( $ { a } , uv ) ;
2021-08-14 17:17:51 +02:00
}
2021-10-22 22:09:52 +02:00
` ;if(c===i&&h==null)return t? `
2021-10-04 23:03:36 +02:00
float $ { r } ( int row , int col , int depth ) {
2021-10-22 22:09:52 +02:00
float texR = dot ( vec2 ( row , col ) , vec2 ( $ { a } Shape [ 1 ] , 1 ) ) ;
2021-09-11 16:29:31 +02:00
float texC = float ( depth ) ;
2021-10-22 22:09:52 +02:00
vec2 uv = ( vec2 ( texC , texR ) + halfCR ) / vec2 ( $ { a } TexShape [ 1 ] , $ { a } TexShape [ 0 ] ) ;
return sampleTexture ( $ { a } , uv ) ;
2021-09-11 16:29:31 +02:00
}
` : `
2021-10-04 23:03:36 +02:00
float $ { r } ( int row , int col , int depth ) {
2021-09-11 16:29:31 +02:00
float texR = dot ( vec2 ( row , col ) , vec2 ( $ { n [ 1 ] } , 1 ) ) ;
float texC = float ( depth ) ;
2021-10-22 22:09:52 +02:00
vec2 uv = ( vec2 ( texC , texR ) + halfCR ) / vec2 ( $ { c } . 0 , $ { p } . 0 ) ;
return sampleTexture ( $ { a } , uv ) ;
2021-09-11 16:29:31 +02:00
}
2021-10-22 22:09:52 +02:00
` ;let f=To(a);return t? `
2021-10-04 23:03:36 +02:00
float $ { r } ( int row , int col , int depth ) {
2021-09-11 16:29:31 +02:00
// Explicitly use integer operations as dot() only works on floats.
2021-10-22 22:09:52 +02:00
int stride0 = $ { a } Shape [ 1 ] * $ { a } Shape [ 2 ] ;
int stride1 = $ { a } Shape [ 2 ] ;
int index = row * $ { s } + col * $ { i } + depth + $ { f } ;
vec2 uv = uvFromFlat ( $ { a } TexShape [ 0 ] , $ { a } TexShape [ 1 ] , index ) ;
return sampleTexture ( $ { a } , uv ) ;
2021-09-11 16:29:31 +02:00
}
` : `
2021-10-04 23:03:36 +02:00
float $ { r } ( int row , int col , int depth ) {
2021-09-11 16:29:31 +02:00
// Explicitly use integer operations as dot() only works on floats.
2021-10-22 22:09:52 +02:00
int index = row * $ { s } + col * $ { i } + depth + $ { f } ;
vec2 uv = uvFromFlat ( $ { p } , $ { c } , index ) ;
return sampleTexture ( $ { a } , uv ) ;
2021-09-11 16:29:31 +02:00
}
2021-10-22 22:09:52 +02:00
` }function MK(e,t){let n=e.name,a="get"+n.charAt(0).toUpperCase()+n.slice(1),r= $ n();if(t)return `
vec4 $ { a } ( int b2 , int b , int row , int col ) {
2021-09-11 16:29:31 +02:00
int valuesPerRow = int ( ceil ( float ( $ { n } Shape [ 3 ] ) / 2.0 ) ) ;
int texelsInBatch = valuesPerRow * int ( ceil ( float ( $ { n } Shape [ 2 ] ) / 2.0 ) ) ;
int index = b * texelsInBatch + ( row / 2 ) * valuesPerRow + ( col / 2 ) ;
texelsInBatch *= $ { n } Shape [ 1 ] ;
index = b2 * texelsInBatch + index ;
ivec2 packedTexShape = ivec2 ( ceil ( float ( $ { n } TexShape [ 0 ] ) / 2.0 ) , ceil ( float ( $ { n } TexShape [ 1 ] ) / 2.0 ) ) ;
int texR = index / packedTexShape [ 1 ] ;
int texC = index - texR * packedTexShape [ 1 ] ;
2021-10-04 23:03:36 +02:00
vec2 uv = ( vec2 ( texC , texR ) + halfCR ) / vec2 ( packedTexShape [ 1 ] , packedTexShape [ 0 ] ) ; return $ { r . texture2D } ( $ { n } , uv ) ;
2021-09-11 16:29:31 +02:00
}
2021-10-22 22:09:52 +02:00
` ;let s=e.shapeInfo.logicalShape,i=s.length,o=e.shapeInfo.texShape,l=[Math.ceil(o[0]/2),Math.ceil(o[1]/2)],d=l[0],u=l[1],p=Math.ceil(s[i-1]/2),c=p*Math.ceil(s[i-2]/2),h="int b, int row, int col",f= ` b * $ { c } + ( row / 2 ) * $ { p } + ( col / 2 ) ` ;for(let m=2;m<i-1;m++)h= ` int b$ { m } , ` +h,c*=s[i-m-1],f= ` b$ { m } * $ { c } + ` +f;return `
vec4 $ { a } ( $ { h } ) {
2021-10-07 16:33:10 +02:00
int index = $ { f } ;
int texR = index / $ { u } ;
int texC = index - texR * $ { u } ;
2021-10-22 22:09:52 +02:00
vec2 uv = ( vec2 ( texC , texR ) + halfCR ) / vec2 ( $ { u } , $ { d } ) ;
2021-10-04 23:03:36 +02:00
return $ { r . texture2D } ( $ { n } , uv ) ;
2021-09-11 16:29:31 +02:00
}
2021-10-22 22:09:52 +02:00
` }function FK(e,t){let n=e.shapeInfo.logicalShape,a=e.name,r="get"+a.charAt(0).toUpperCase()+a.slice(1),s=n[3],i=n[2]*s,o=n[1]*i,{newShape:l,keptDims:d}=w.squeezeShape(n);if(l.length<n.length){let A= $ u(e,l),x=["row","col","depth","depth2"];return `
$ { Fu ( A , t ) }
2021-10-04 23:03:36 +02:00
float $ { r } ( int row , int col , int depth , int depth2 ) {
2021-10-22 22:09:52 +02:00
return $ { r } ( $ { Ou ( x , d ) } ) ;
2021-09-11 16:29:31 +02:00
}
` }if(e.shapeInfo.isUniform)return `
2021-10-04 23:03:36 +02:00
float $ { r } ( int row , int col , int depth , int depth2 ) {
2021-09-11 16:29:31 +02:00
int index = round ( dot ( vec4 ( row , col , depth , depth2 ) ,
2021-10-22 22:09:52 +02:00
vec4 ( $ { o } , $ { i } , $ { s } , 1 ) ) ) ;
$ { Du ( e ) }
2021-09-11 16:29:31 +02:00
}
2021-10-22 22:09:52 +02:00
` ;let u=e.shapeInfo.flatOffset,p=e.shapeInfo.texShape,c=p[0],h=p[1],f= ` int stride2 = $ { a } Shape [ 3 ] ; ` ,m= ` int stride1 = $ { a } Shape [ 2 ] * stride2 ; ` ,g= ` int stride0 = $ { a } Shape [ 1 ] * stride1 ; ` ;if(h===o&&u==null)return t? `
2021-10-04 23:03:36 +02:00
float $ { r } ( int row , int col , int depth , int depth2 ) {
$ { f }
2021-10-07 16:33:10 +02:00
$ { m }
2021-09-11 16:29:31 +02:00
float texR = float ( row ) ;
float texC =
dot ( vec3 ( col , depth , depth2 ) ,
vec3 ( stride1 , stride2 , 1 ) ) ;
vec2 uv = ( vec2 ( texC , texR ) + halfCR ) /
2021-10-22 22:09:52 +02:00
vec2 ( $ { a } TexShape [ 1 ] , $ { a } TexShape [ 0 ] ) ;
return sampleTexture ( $ { a } , uv ) ;
2021-09-11 16:29:31 +02:00
}
` : `
2021-10-04 23:03:36 +02:00
float $ { r } ( int row , int col , int depth , int depth2 ) {
2021-09-11 16:29:31 +02:00
float texR = float ( row ) ;
float texC =
dot ( vec3 ( col , depth , depth2 ) ,
2021-10-22 22:09:52 +02:00
vec3 ( $ { i } , $ { s } , 1 ) ) ;
2021-09-11 16:29:31 +02:00
vec2 uv = ( vec2 ( texC , texR ) + halfCR ) /
2021-10-22 22:09:52 +02:00
vec2 ( $ { h } . 0 , $ { c } . 0 ) ;
return sampleTexture ( $ { a } , uv ) ;
2021-09-11 16:29:31 +02:00
}
2021-10-22 22:09:52 +02:00
` ;if(h===s&&u==null)return t? `
2021-10-04 23:03:36 +02:00
float $ { r } ( int row , int col , int depth , int depth2 ) {
2021-09-11 16:29:31 +02:00
float texR = dot ( vec3 ( row , col , depth ) ,
2021-10-22 22:09:52 +02:00
vec3 ( $ { a } Shape [ 1 ] * $ { a } Shape [ 2 ] , $ { a } Shape [ 2 ] , 1 ) ) ;
2021-09-11 16:29:31 +02:00
float texC = float ( depth2 ) ;
vec2 uv = ( vec2 ( texC , texR ) + halfCR ) /
2021-10-22 22:09:52 +02:00
vec2 ( $ { a } TexShape [ 1 ] , $ { a } TexShape [ 0 ] ) ;
return sampleTexture ( $ { a } , uv ) ;
2021-09-11 16:29:31 +02:00
}
` : `
2021-10-04 23:03:36 +02:00
float $ { r } ( int row , int col , int depth , int depth2 ) {
2021-09-11 16:29:31 +02:00
float texR = dot ( vec3 ( row , col , depth ) ,
vec3 ( $ { n [ 1 ] * n [ 2 ] } , $ { n [ 2 ] } , 1 ) ) ;
float texC = float ( depth2 ) ;
vec2 uv = ( vec2 ( texC , texR ) + halfCR ) /
2021-10-22 22:09:52 +02:00
vec2 ( $ { h } . 0 , $ { c } . 0 ) ;
return sampleTexture ( $ { a } , uv ) ;
2021-09-11 16:29:31 +02:00
}
2021-10-22 22:09:52 +02:00
` ;let y=To(a);return t? `
2021-10-04 23:03:36 +02:00
float $ { r } ( int row , int col , int depth , int depth2 ) {
2021-09-11 16:29:31 +02:00
// Explicitly use integer operations as dot() only works on floats.
2021-10-04 23:03:36 +02:00
$ { f }
2021-10-07 16:33:10 +02:00
$ { m }
2021-09-11 16:29:31 +02:00
$ { g }
int index = row * stride0 + col * stride1 +
depth * stride2 + depth2 ;
2021-10-22 22:09:52 +02:00
vec2 uv = uvFromFlat ( $ { a } TexShape [ 0 ] , $ { a } TexShape [ 1 ] , index + $ { y } ) ;
return sampleTexture ( $ { a } , uv ) ;
2021-09-11 16:29:31 +02:00
}
` : `
2021-10-04 23:03:36 +02:00
float $ { r } ( int row , int col , int depth , int depth2 ) {
2021-09-11 16:29:31 +02:00
// Explicitly use integer operations as dot() only works on floats.
2021-10-22 22:09:52 +02:00
int index = row * $ { o } + col * $ { i } +
depth * $ { s } + depth2 ;
vec2 uv = uvFromFlat ( $ { c } , $ { h } , index + $ { y } ) ;
return sampleTexture ( $ { a } , uv ) ;
2021-09-11 16:29:31 +02:00
}
2021-10-22 22:09:52 +02:00
` }function DK(e){let t=e.shapeInfo.logicalShape,n=e.name,a="get"+n.charAt(0).toUpperCase()+n.slice(1),r=t[4],s=t[3]*r,i=t[2]*s,o=t[1]*i,{newShape:l,keptDims:d}=w.squeezeShape(t);if(l.length<t.length){let m= $ u(e,l),g=["row","col","depth","depth2","depth3"];return `
$ { Fu ( m ) }
float $ { a } ( int row , int col , int depth , int depth2 , int depth3 ) {
return $ { a } ( $ { Ou ( g , d ) } ) ;
2021-09-11 16:29:31 +02:00
}
` }if(e.shapeInfo.isUniform)return `
2021-10-22 22:09:52 +02:00
float $ { a } ( int row , int col , int depth , int depth2 , int depth3 ) {
2021-09-11 16:29:31 +02:00
float index = dot (
vec4 ( row , col , depth , depth2 ) ,
2021-10-22 22:09:52 +02:00
vec4 ( $ { o } , $ { i } , $ { s } , $ { r } ) ) +
2021-09-11 16:29:31 +02:00
depth3 ;
2021-10-22 22:09:52 +02:00
$ { Du ( e ) }
2021-09-11 16:29:31 +02:00
}
2021-10-22 22:09:52 +02:00
` ;let u=e.shapeInfo.flatOffset,p=e.shapeInfo.texShape,c=p[0],h=p[1];if(h===o&&u==null)return `
float $ { a } ( int row , int col , int depth , int depth2 , int depth3 ) {
2021-09-11 16:29:31 +02:00
int texR = row ;
float texC = dot ( vec4 ( col , depth , depth2 , depth3 ) ,
2021-10-22 22:09:52 +02:00
vec4 ( $ { i } , $ { s } , $ { r } , 1 ) ) ;
2021-09-11 16:29:31 +02:00
vec2 uv = ( vec2 ( texC , texR ) + halfCR ) /
2021-10-22 22:09:52 +02:00
vec2 ( $ { h } . 0 , $ { c } . 0 ) ;
2021-09-11 16:29:31 +02:00
return sampleTexture ( $ { n } , uv ) ;
}
2021-10-07 16:33:10 +02:00
` ;if(h===r&&u==null)return `
2021-10-22 22:09:52 +02:00
float $ { a } ( int row , int col , int depth , int depth2 , int depth3 ) {
2021-09-11 16:29:31 +02:00
float texR = dot (
vec4 ( row , col , depth , depth2 ) ,
vec4 ( $ { t [ 1 ] * t [ 2 ] * t [ 3 ] } ,
$ { t [ 2 ] * t [ 3 ] } , $ { t [ 3 ] } , 1 ) ) ;
int texC = depth3 ;
vec2 uv = ( vec2 ( texC , texR ) + halfCR ) /
2021-10-22 22:09:52 +02:00
vec2 ( $ { h } . 0 , $ { c } . 0 ) ;
2021-09-11 16:29:31 +02:00
return sampleTexture ( $ { n } , uv ) ;
}
2021-10-22 22:09:52 +02:00
` ;let f=To(n);return `
float $ { a } ( int row , int col , int depth , int depth2 , int depth3 ) {
2021-09-11 16:29:31 +02:00
// Explicitly use integer operations as dot() only works on floats.
2021-10-22 22:09:52 +02:00
int index = row * $ { o } + col * $ { i } + depth * $ { s } +
2021-10-07 16:33:10 +02:00
depth2 * $ { r } + depth3 + $ { f } ;
2021-10-22 22:09:52 +02:00
vec2 uv = uvFromFlat ( $ { c } , $ { h } , index ) ;
2021-09-11 16:29:31 +02:00
return sampleTexture ( $ { n } , uv ) ;
}
2021-10-22 22:09:52 +02:00
` }function $ K(e){let t=e.shapeInfo.logicalShape,n=e.name,a="get"+n.charAt(0).toUpperCase()+n.slice(1),{newShape:r,keptDims:s}=w.squeezeShape(t);if(r.length<t.length){let g= $ u(e,r),y=["row","col","depth","depth2","depth3","depth4"];return `
$ { Fu ( g ) }
float $ { a } ( int row , int col , int depth ,
2021-09-11 16:29:31 +02:00
int depth2 , int depth3 , int depth4 ) {
2021-10-22 22:09:52 +02:00
return $ { a } ( $ { Ou ( y , s ) } ) ;
2021-09-11 16:29:31 +02:00
}
2021-10-22 22:09:52 +02:00
` }let i=t[5],o=t[4]*i,l=t[3]*o,d=t[2]*l,u=t[1]*d;if(e.shapeInfo.isUniform)return `
float $ { a } ( int row , int col , int depth ,
2021-09-11 16:29:31 +02:00
int depth2 , int depth3 , int depth4 ) {
int index = round ( dot (
vec4 ( row , col , depth , depth2 ) ,
2021-10-22 22:09:52 +02:00
vec4 ( $ { u } , $ { d } , $ { l } , $ { o } ) ) +
2021-09-11 16:29:31 +02:00
dot (
vec2 ( depth3 , depth4 ) ,
2021-10-22 22:09:52 +02:00
vec2 ( $ { i } , 1 ) ) ) ;
$ { Du ( e ) }
2021-09-11 16:29:31 +02:00
}
2021-10-22 22:09:52 +02:00
` ;let p=e.shapeInfo.flatOffset,c=e.shapeInfo.texShape,h=c[0],f=c[1];if(f===u&&p==null)return `
float $ { a } ( int row , int col , int depth ,
2021-09-11 16:29:31 +02:00
int depth2 , int depth3 , int depth4 ) {
int texR = row ;
float texC = dot ( vec4 ( col , depth , depth2 , depth3 ) ,
2021-10-22 22:09:52 +02:00
vec4 ( $ { d } , $ { l } , $ { o } , $ { i } ) ) +
2021-09-11 16:29:31 +02:00
float ( depth4 ) ;
vec2 uv = ( vec2 ( texC , texR ) + halfCR ) /
2021-10-07 16:33:10 +02:00
vec2 ( $ { f } . 0 , $ { h } . 0 ) ;
2021-09-11 16:29:31 +02:00
return sampleTexture ( $ { n } , uv ) ;
}
2021-10-22 22:09:52 +02:00
` ;if(f===i&&p==null)return `
float $ { a } ( int row , int col , int depth ,
2021-09-11 16:29:31 +02:00
int depth2 , int depth3 , int depth4 ) {
float texR = dot ( vec4 ( row , col , depth , depth2 ) ,
vec4 ( $ { t [ 1 ] * t [ 2 ] * t [ 3 ] * t [ 4 ] } ,
$ { t [ 2 ] * t [ 3 ] * t [ 4 ] } ,
$ { t [ 3 ] * t [ 4 ] } ,
$ { t [ 4 ] } ) ) + float ( depth3 ) ;
int texC = depth4 ;
vec2 uv = ( vec2 ( texC , texR ) + halfCR ) /
2021-10-07 16:33:10 +02:00
vec2 ( $ { f } . 0 , $ { h } . 0 ) ;
2021-09-11 16:29:31 +02:00
return sampleTexture ( $ { n } , uv ) ;
}
2021-10-22 22:09:52 +02:00
` ;let m=To(n);return `
float $ { a } ( int row , int col , int depth ,
2021-09-11 16:29:31 +02:00
int depth2 , int depth3 , int depth4 ) {
// Explicitly use integer operations as dot() only works on floats.
2021-10-22 22:09:52 +02:00
int index = row * $ { u } + col * $ { d } + depth * $ { l } +
depth2 * $ { o } + depth3 * $ { i } + depth4 + $ { m } ;
2021-10-07 16:33:10 +02:00
vec2 uv = uvFromFlat ( $ { h } , $ { f } , index ) ;
2021-09-11 16:29:31 +02:00
return sampleTexture ( $ { n } , uv ) ;
}
2021-10-22 22:09:52 +02:00
` }function Du(e){let t=e.name,n=w.sizeFromShape(e.shapeInfo.logicalShape);return n<2? ` return $ { t } ; ` : `
2021-09-11 16:29:31 +02:00
for ( int i = 0 ; i < $ { n } ; i ++ ) {
if ( i == index ) {
return $ { t } [ i ] ;
}
}
2021-10-22 22:09:52 +02:00
` }function OK(e,t){let n=e.name,a=n.charAt(0).toUpperCase()+n.slice(1),r="get"+a+"AtOutCoords",s=e.shapeInfo.logicalShape.length,i=t.logicalShape.length,o=w4(e.shapeInfo.logicalShape,t.logicalShape),l=yt(i),d=i-s,u,p=["x","y","z","w","u","v"];s===0?u="":i<2&&o.length>=1?u="coords = 0;":u=o.map(g=> ` coords . $ { p [ g + d ] } = 0 ; ` ).join( `
` );let c="";i<2&&s>0?c="coords":c=e.shapeInfo.logicalShape.map((g,y)=> ` coords . $ { p [ y + d ] } ` ).join(", ");let h="return outputValue;",f=w.sizeFromShape(e.shapeInfo.logicalShape)===1,m=w.sizeFromShape(t.logicalShape)===1;if(s===1&&!f&&!m)h= `
2021-09-11 16:29:31 +02:00
return vec4 ( outputValue . xy , outputValue . xy ) ;
2021-10-22 22:09:52 +02:00
` ;else if(f&&!m)i===1?h= `
2021-09-11 16:29:31 +02:00
return vec4 ( outputValue . x , outputValue . x , 0. , 0. ) ;
2021-10-04 23:03:36 +02:00
` :h= `
2021-09-11 16:29:31 +02:00
return vec4 ( outputValue . x ) ;
2021-10-22 22:09:52 +02:00
` ;else if(o.length){let g=s-2,y=s-1;o.indexOf(g)>-1&&o.indexOf(y)>-1?h="return vec4(outputValue.x);":o.indexOf(g)>-1?h="return vec4(outputValue.x, outputValue.y, outputValue.x, outputValue.y);":o.indexOf(y)>-1&&(h="return vec4(outputValue.xx, outputValue.zz);")}return `
2021-10-04 23:03:36 +02:00
vec4 $ { r } ( ) {
2021-09-11 16:29:31 +02:00
$ { l } coords = getOutputCoords ( ) ;
2021-10-07 16:33:10 +02:00
$ { u }
2021-10-22 22:09:52 +02:00
vec4 outputValue = get$ { a } ( $ { c } ) ;
2021-10-04 23:03:36 +02:00
$ { h }
2021-09-11 16:29:31 +02:00
}
2021-10-22 22:09:52 +02:00
` }function _K(e,t){let n=e.name,a=n.charAt(0).toUpperCase()+n.slice(1),r="get"+a+"AtOutCoords",s=t.texShape,i=e.shapeInfo.texShape,o=e.shapeInfo.logicalShape.length,l=t.logicalShape.length;if(!e.shapeInfo.isUniform&&o===l&&e.shapeInfo.flatOffset==null&&w.arraysEqual(i,s))return `
2021-10-04 23:03:36 +02:00
float $ { r } ( ) {
2021-09-11 16:29:31 +02:00
return sampleTexture ( $ { n } , resultUV ) ;
}
2021-10-22 22:09:52 +02:00
` ;let d=yt(l),u=w4(e.shapeInfo.logicalShape,t.logicalShape),p=l-o,c,h=["x","y","z","w","u","v"];o===0?c="":l<2&&u.length>=1?c="coords = 0;":c=u.map(m=> ` coords . $ { h [ m + p ] } = 0 ; ` ).join( `
` );let f="";return l<2&&o>0?f="coords":f=e.shapeInfo.logicalShape.map((m,g)=> ` coords . $ { h [ g + p ] } ` ).join(", "), `
2021-10-04 23:03:36 +02:00
float $ { r } ( ) {
2021-10-22 22:09:52 +02:00
$ { d } coords = getOutputCoords ( ) ;
$ { c }
return get$ { a } ( $ { f } ) ;
2021-09-11 16:29:31 +02:00
}
2021-10-22 22:09:52 +02:00
` }function yt(e){if(e<=1)return"int";if(e===2)return"ivec2";if(e===3)return"ivec3";if(e===4)return"ivec4";if(e===5)return"ivec5";if(e===6)return"ivec6";throw Error( ` GPU for rank $ { e } is not yet supported ` )}function P2(e,t,n){let{newShape:a,keptDims:r}=w.squeezeShape(t),s=t.length,i=e&&s===3&&t[0]===1,o=i?t.slice(1):a,l=!e&&s>1&&!w.arraysEqual(t,n)&&a.length<s||i;return{useSqueezeShape:l,uniformShape:l?o:t,keptDims:r}}function $ u(e,t){let n=JSON.parse(JSON.stringify(e));return n.shapeInfo.logicalShape=t,n}function Ou(e,t){return t.map(n=>e[n]).join(", ")}function PK(e,t,n,a){let r=n.map((x,b)=>{let v={logicalShape:x.shape,texShape:x.isUniform?null:x.texData.texShape,isUniform:x.isUniform,isPacked:x.isUniform?!1:x.texData.isPacked,flatOffset:null};return x.texData!=null&&x.texData.slice!=null&&x.texData.slice.flatOffset>0&&(v.flatOffset=x.texData.slice.flatOffset),{name:t.variableNames[b],shapeInfo:v}}),s=r.map(x=>x.shapeInfo),i={logicalShape:a.shape,texShape:a.texData.texShape,isUniform:!1,isPacked:a.texData.isPacked,flatOffset:null},o=tK(r,i,t),l=e.createProgram(o),d=null,u=e.getUniformLocation(l,"NAN",!1);ne().getNumber("WEBGL_VERSION")===1&&(d=e.getUniformLocation(l,"INFINITY",!1));let p=!1,c={},h={},f={};for(let x=0;x<t.variableNames.length;x++){let b=t.variableNames[x];c[b]=e.getUniformLocation(l,b,p),c[ ` offset$ { b } ` ]=e.getUniformLocation(l, ` offset$ { b } ` ,p),t.enableShapeUniforms&&(h[ ` $ { b } Shape ` ]=e.getUniformLocation(l, ` $ { b } Shape ` ,p),f[ ` $ { b } TexShape ` ]=e.getUniformLocation(l, ` $ { b } TexShape ` ,p))}let m,g,y;t.enableShapeUniforms&&(m=e.getUniformLocation(l,"outShape",p),y=e.getUniformLocation(l,"outShapeStrides",p),g=e.getUniformLocation(l,"outTexShape",p));let A=[];return t.customUniforms&&t.customUniforms.forEach((x,b)=>{A[b]=e.getUniformLocation(l,x.name,p)}),{program:t,source:o,webGLProgram:l,uniformLocations:c,customUniformLocations:A,inShapeInfos:s,outShapeInfo:i,infLoc:d,nanLoc:u,inShapesLocations:h,inTexShapesLocations:f,outShapeLocation:m,outShapeStridesLocation:y,outTexShapeLocation:g}}function S4(e,t){if(e.length!==t.length)throw Error( ` Binary was compiled with $ { e . length } inputs , but was executed with $ { t . length } inputs ` );e.forEach((n,a)=>{let r=n.logicalShape,s=t[a],i=s.shape;if(!w.arraysEqual(r,i))throw Error( ` Binary was compiled with different shapes than the current args . Shapes $ { r } and $ { i } must match ` );if(n.isUniform&&s.isUniform)return;let o=n.texShape,l=s.isUniform?null:s.texData.texShape;if(!w.arraysEqual(o,l))throw Error( ` Binary was compiled with different texture shapes than the current args . Shape $ { o } and $ { l } must match ` )})}function zK(e,t,n,a,r){t.program.enableShapeUniforms||(S4(t.inShapeInfos,n),S4([t.outShapeInfo],[a]));let s=a.texData.texture,i=a.texData.texShape;a.texData.isPacked?e.setOutputPackedMatrixTexture(s,i[0],i[1]):e.setOutputMatrixTexture(s,i[0],i[1]),e.setProgram(t.webGLProgram),ne().getNumber("WEBGL_VERSION")===1&&t.infLoc!==null&&e.gl.uniform1f(t.infLoc,1/0),t.nanLoc!==null&&e.gl.uniform1f(t.nanLoc,NaN),n.forEach((l,d)=>{let u=t.program.variableNames[d],p=t.uniformLocations[u],c=t.uniformLocations[ ` offset$ { u } ` ],h=t.inShapesLocations[ ` $ { u } Shape ` ],f=t.inTexShapesLocations[ ` $ { u } TexShape ` ];if(h){let{uniformShape:m}=P2(t.program.packedInputs,l.shape,l.texData.texShape);switch(m.length){case 1:e.gl.uniform1iv(h,new Int32Array(m));break;case 2:e.gl.uniform2iv(h,new Int32Array(m));break;case 3:e.gl.uniform3iv(h,new Int32Array(m));break;case 4:e.gl.uniform4iv(h,new Int32Array(m));break;default:break}}if(f&&e.gl.uniform2i(f,l.texData.texShape[0],l.texData.texShape[1]),p!=null){if(l.isUniform){if(w.sizeFromShape(l.shape)<2)e.gl.uniform1f(p,l.uniformValues[0]);else{let m=l.uniformValues;m instanceof Float32Array||(m=new Float32Array(m)),e.gl.uniform1fv(p,m)}return}l.texData.slice!=null&&c!=null&&e.gl.uniform1i(c,l.texData.slice.flatOffset),e.setInputMatrixTexture(l.texData.texture,p,d)}});let o=t.outShapeLocation;if(o)switch(a.shape.length){case 1:e.gl.uniform1iv(o,new Int32Array(a.shape));break;case 2:e.gl.uniform2iv(o,new Int32Array(a.shape));break;case 3:e.gl.uniform3iv(o,new Int32Array
2021-09-11 16:29:31 +02:00
ivec3 outCoordsFromFlatIndex ( int index ) {
2021-10-22 22:09:52 +02:00
$ { this . enableShapeUniforms ? gf ( [ "r" , "c" , "d" ] , e ) : No ( [ "r" , "c" , "d" ] , e ) }
2021-09-11 16:29:31 +02:00
return ivec3 ( r , c , d ) ;
}
void main ( ) {
ivec2 resTexRC = ivec2 ( resultUV . yx * vec2 ( texShape [ 0 ] , texShape [ 1 ] ) ) ;
int index = 4 * ( resTexRC . x * texShape [ 1 ] + resTexRC . y ) ;
vec4 result = vec4 ( 0. ) ;
for ( int i = 0 ; i < 4 ; i ++ ) {
int flatIndex = index + i ;
ivec3 rc = outCoordsFromFlatIndex ( flatIndex ) ;
result [ i ] = getA ( rc . x , rc . y , rc . z ) ;
2021-08-31 19:00:06 +02:00
}
2021-09-11 16:29:31 +02:00
$ { t . output } = result ;
}
2021-10-22 22:09:52 +02:00
` }},BK=class{constructor(e){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outPackingScheme=Dp.DENSE,this.customUniforms=[{name:"texShape",type:"ivec2"}];let t= $ n();this.outputShape=e,this.enableShapeUniforms=Ra(this.outputShape.length),this.userCode= `
2021-09-11 16:29:31 +02:00
ivec3 outCoordsFromFlatIndex ( int index ) {
2021-10-22 22:09:52 +02:00
$ { this . enableShapeUniforms ? gf ( [ "r" , "c" , "d" ] , e ) : No ( [ "r" , "c" , "d" ] , e ) }
2021-09-11 16:29:31 +02:00
return ivec3 ( r , c , d ) ;
}
void main ( ) {
ivec2 resTexRC = ivec2 ( resultUV . yx * vec2 ( texShape [ 0 ] , texShape [ 1 ] ) ) ;
int index = 4 * ( resTexRC . x * texShape [ 1 ] + resTexRC . y ) ;
vec4 result = vec4 ( 0. ) ;
for ( int i = 0 ; i < 4 ; i ++ ) {
int flatIndex = index + i ;
ivec3 rc = outCoordsFromFlatIndex ( flatIndex ) ;
result [ i ] = getChannel ( getA ( rc . x , rc . y , rc . z ) , vec2 ( rc . y , rc . z ) ) ;
2021-08-31 19:00:06 +02:00
}
2021-09-11 16:29:31 +02:00
$ { t . output } = result ;
}
2021-10-22 22:09:52 +02:00
` }},VK=class{constructor(e){this.variableNames=["A"],this.outTexUsage=Ca.DOWNLOAD;let t= $ n();this.outputShape=e,this.userCode= `
$ { v4 }
2021-09-11 16:29:31 +02:00
void main ( ) {
float x = getAAtOutCoords ( ) ;
$ { t . output } = encode _float ( x ) ;
}
2021-10-22 22:09:52 +02:00
` }},UK=class{constructor(e){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!1,this.outTexUsage=Ca.DOWNLOAD;let t= $ n();this.outputShape=e,this.userCode= `
$ { v4 }
2021-09-11 16:29:31 +02:00
void main ( ) {
ivec3 coords = getOutputCoords ( ) ;
float x = getChannel ( getAAtOutCoords ( ) , vec2 ( coords . y , coords . z ) ) ;
$ { t . output } = encode _float ( x ) ;
}
2021-10-22 22:09:52 +02:00
` }},jK=class{constructor(e,t=!1){this.variableNames=["A"],this.customUniforms=[{name:"texShape",type:"ivec2"}];let n= $ n();this.outputShape=e,this.enableShapeUniforms=Ra(this.outputShape.length);let a="result";t&&(a="floor(result * 255. + 0.5)"),this.userCode= `
$ { this . enableShapeUniforms ? _2 ( ) : O2 ( e ) }
2021-09-11 16:29:31 +02:00
void main ( ) {
ivec3 coords = getOutputCoords ( ) ;
int flatIndex = getFlatIndex ( coords ) ;
int offset = imod ( flatIndex , 4 ) ;
flatIndex = idiv ( flatIndex , 4 , 1. ) ;
int r = flatIndex / texShape [ 1 ] ;
int c = imod ( flatIndex , texShape [ 1 ] ) ;
vec2 uv = ( vec2 ( c , r ) + halfCR ) / vec2 ( texShape [ 1 ] , texShape [ 0 ] ) ;
vec4 values = $ { n . texture2D } ( A , uv ) ;
float result ;
if ( offset == 0 ) {
result = values [ 0 ] ;
} else if ( offset == 1 ) {
result = values [ 1 ] ;
} else if ( offset == 2 ) {
result = values [ 2 ] ;
} else {
result = values [ 3 ] ;
2021-08-31 19:00:06 +02:00
}
2021-09-11 16:29:31 +02:00
2021-10-22 22:09:52 +02:00
$ { n . output } = vec4 ( $ { a } , 0. , 0. , 0. ) ;
2021-09-11 16:29:31 +02:00
}
2021-10-22 22:09:52 +02:00
` }},GK=class{constructor(e,t=!1){this.variableNames=["A"],this.packedInputs=!1,this.packedOutput=!0,this.customUniforms=[{name:"texShape",type:"ivec2"}];let n= $ n();this.outputShape=e,this.enableShapeUniforms=Ra(this.outputShape.length);let a="",r="result";t&&(r="floor(result * 255. + 0.5)");for(let s=0;s<=1;s++)for(let i=0;i<=1;i++){let o=s*2+i;a+= `
2021-09-11 16:29:31 +02:00
localCoords = coords ;
2021-10-22 22:09:52 +02:00
if ( localCoords [ 2 ] + $ { i } < $ { this . enableShapeUniforms ? "outShape[2]" : ` ${ e [ 2 ] } ` } ) {
localCoords [ 2 ] += $ { i } ;
if ( localCoords [ 1 ] + $ { s } < $ { this . enableShapeUniforms ? "outShape[1]" : ` ${ e [ 1 ] } ` } ) {
localCoords [ 1 ] += $ { s } ;
2021-09-11 16:29:31 +02:00
flatIndex = getFlatIndex ( localCoords ) ;
offset = imod ( flatIndex , 4 ) ;
flatIndex = idiv ( flatIndex , 4 , 1. ) ;
int r = flatIndex / texShape [ 1 ] ;
int c = imod ( flatIndex , texShape [ 1 ] ) ;
vec2 uv = ( vec2 ( c , r ) + halfCR ) / vec2 ( texShape [ 1 ] , texShape [ 0 ] ) ;
values = $ { n . texture2D } ( A , uv ) ;
if ( offset == 0 ) {
2021-10-22 22:09:52 +02:00
result [ $ { o } ] = values [ 0 ] ;
2021-09-11 16:29:31 +02:00
} else if ( offset == 1 ) {
2021-10-22 22:09:52 +02:00
result [ $ { o } ] = values [ 1 ] ;
2021-09-11 16:29:31 +02:00
} else if ( offset == 2 ) {
2021-10-22 22:09:52 +02:00
result [ $ { o } ] = values [ 2 ] ;
2021-08-31 19:00:06 +02:00
} else {
2021-10-22 22:09:52 +02:00
result [ $ { o } ] = values [ 3 ] ;
2021-08-31 19:00:06 +02:00
}
}
}
2021-09-11 16:29:31 +02:00
` }this.userCode= `
2021-10-22 22:09:52 +02:00
$ { this . enableShapeUniforms ? _2 ( ) : O2 ( e ) }
2021-09-11 16:29:31 +02:00
void main ( ) {
ivec3 coords = getOutputCoords ( ) ;
vec4 result = vec4 ( 0. ) ;
int flatIndex , r , c , offset ;
ivec3 localCoords ;
vec2 uv ;
vec4 values ;
2021-10-22 22:09:52 +02:00
$ { a }
2021-09-11 16:29:31 +02:00
2021-10-04 23:03:36 +02:00
$ { n . output } = $ { r } ;
2021-08-14 17:17:51 +02:00
}
2021-10-22 22:09:52 +02:00
` }},N4={};ze(N4,{bindVertexProgramAttributeStreams:()=>O4,createBufferFromOutputTexture:()=>z4,createFloat16MatrixTexture:()=>M4,createFloat16PackedMatrixTexture:()=> $ 4,createFloat32MatrixTexture:()=>R4,createIndexBuffer:()=>E4,createPackedMatrixTexture:()=>D4,createUnsignedBytesMatrixTexture:()=>F4,createVertexBuffer:()=>C4,createVertexShader:()=>T4,downloadByteEncodedFloatMatrixFromOutputTexture:()=>W4,downloadFloat32MatrixFromBuffer:()=>L4,downloadMatrixFromPackedOutputTexture:()=>V4,downloadPackedMatrixFromBuffer:()=>B4,getInternalFormatForFloat16MatrixTexture:()=>L2,getInternalFormatForFloat16PackedMatrixTexture:()=>V2,getInternalFormatForFloat32MatrixTexture:()=>z2,getInternalFormatForPackedMatrixTexture:()=>B2,getInternalFormatForUnsignedBytesMatrixTexture:()=>W2,uploadDenseMatrixToTexture:()=>_4,uploadPixelDataToTexture:()=>P4});function T4(e){let t= $ n(),n= ` $ { t . version }
2021-09-11 16:29:31 +02:00
precision highp float ;
$ { t . attribute } vec3 clipSpacePos ;
$ { t . attribute } vec2 uv ;
$ { t . varyingVs } vec2 resultUV ;
void main ( ) {
gl _Position = vec4 ( clipSpacePos , 1 ) ;
resultUV = uv ;
2021-10-22 22:09:52 +02:00
} ` ;return Q6(e,n)}function C4(e){let t=new Float32Array([-1,1,0,0,1,-1,-1,0,0,0,1,1,0,1,1,1,-1,0,1,0]);return a4(e,t)}function E4(e){let t=new Uint16Array([0,1,2,2,1,3]);return r4(e,t)}function zp(e,t,n,a,r,s){i4(t,n);let i=s4(e),o=e.TEXTURE_2D;return Se(e,()=>e.bindTexture(o,i)),Se(e,()=>e.texParameteri(o,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE)),Se(e,()=>e.texParameteri(o,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE)),Se(e,()=>e.texParameteri(o,e.TEXTURE_MIN_FILTER,e.NEAREST)),Se(e,()=>e.texParameteri(o,e.TEXTURE_MAG_FILTER,e.NEAREST)),Se(e,()=>e.texImage2D(o,0,a,t,n,0,r,s,null)),Se(e,()=>e.bindTexture(e.TEXTURE_2D,null)),i}function z2(e){return e.internalFormatFloat}function R4(e,t,n,a){let[r,s]= $ p(t,n);return zp(e,r,s,z2(a),a.textureFormatFloat,e.FLOAT)}function L2(e){return e.internalFormatHalfFloat}function M4(e,t,n,a){let[r,s]= $ p(t,n);return zp(e,r,s,L2(a),a.textureFormatFloat,a.textureTypeHalfFloat)}function W2(e){return e.downloadTextureFormat}function F4(e,t,n,a){let[r,s]= $ p(t,n);return zp(e,r,s,W2(a),e.RGBA,e.UNSIGNED_BYTE)}function B2(e){return e.internalFormatPackedFloat}function D4(e,t,n,a){let[r,s]=Ru(t,n);return zp(e,r,s,B2(a),e.RGBA,e.FLOAT)}function V2(e){return e.internalFormatPackedHalfFloat}function $ 4(e,t,n,a){let[r,s]=Ru(t,n);return zp(e,r,s,V2(a),e.RGBA,a.textureTypeHalfFloat)}function O4(e,t,n){let a=0,r=3*4,s=3*4+2*4;return Se(e,()=>e.bindBuffer(e.ARRAY_BUFFER,n)),M2(e,t,"clipSpacePos",n,3,s,a)&&M2(e,t,"uv",n,2,s,r)}function _4(e,t,n,a,r,s){Se(e,()=>e.bindTexture(e.TEXTURE_2D,t));let i,o,l;r instanceof Uint8Array?(i=new Uint8Array(n*a*4),o=e.UNSIGNED_BYTE,l=e.RGBA):(i=new Float32Array(n*a*4),o=e.FLOAT,l=s.internalFormatPackedFloat),i.set(r),Se(e,()=>e.texImage2D(e.TEXTURE_2D,0,l,n,a,0,e.RGBA,o,i)),Se(e,()=>e.bindTexture(e.TEXTURE_2D,null))}function P4(e,t,n){Se(e,()=>e.bindTexture(e.TEXTURE_2D,t)),n.data instanceof Uint8Array?Se(e,()=>e.texImage2D(e.TEXTURE_2D,0,e.RGBA,n.width,n.height,0,e.RGBA,e.UNSIGNED_BYTE,n.data)):Se(e,()=>e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,n)),Se(e,()=>e.bindTexture(e.TEXTURE_2D,null))}function z4(e,t,n,a){let r=e.createBuffer();Se(e,()=>e.bindBuffer(e.PIXEL_PACK_BUFFER,r));let s=4*4*t*n;return Se(e,()=>e.bufferData(e.PIXEL_PACK_BUFFER,s,e.STREAM_READ)),Se(e,()=>e.readPixels(0,0,n,t,e.RGBA,e.FLOAT,0)),Se(e,()=>e.bindBuffer(e.PIXEL_PACK_BUFFER,null)),r}function L4(e,t,n){let a=e,r=new Float32Array(n);return a.bindBuffer(a.PIXEL_PACK_BUFFER,t),a.getBufferSubData(a.PIXEL_PACK_BUFFER,0,r),a.bindBuffer(a.PIXEL_PACK_BUFFER,null),r}function W4(e,t,n,a){let[r,s]= $ p(t,n),i=4,o=new Uint8Array(WX(t*n,i));return Se(e,()=>e.readPixels(0,0,r,s,a.downloadTextureFormat,e.UNSIGNED_BYTE,o)),new Float32Array(o.buffer)}function B4(e,t,n,a,r,s,i,o){let l=e,d=new Float32Array(BX(s,i));return l.bindBuffer(l.PIXEL_PACK_BUFFER,t),l.getBufferSubData(l.PIXEL_PACK_BUFFER,0,d),l.bindBuffer(l.PIXEL_PACK_BUFFER,null),d}function V4(e,t,n){let a=new Float32Array(t*n*4);return Se(e,()=>e.readPixels(0,0,n,t,e.RGBA,e.FLOAT,a)),a}var yf=class{constructor(e){this.outputTexture=null,this.program=null,this.disposed=!1,this.vertexAttrsAreBound=!1,this.itemsToPoll=[];let t=ne().getNumber("WEBGL_VERSION");e!=null?(this.gl=e,lf(t,e)):this.gl=Nr(t);let n="WEBGL_color_buffer_float",a="EXT_color_buffer_half_float";if(ne().getNumber("WEBGL_VERSION")===1){let r="OES_texture_float",s="OES_texture_half_float";if(this.textureFloatExtension=Op(this.gl,r),Ea(this.gl,s))this.textureHalfFloatExtension=Op(this.gl,s);else if(ne().get("WEBGL_FORCE_F16_TEXTURES"))throw new Error("GL context does not support half float textures, yet the environment flag WEBGL_FORCE_F16_TEXTURES is set to true.");if(this.colorBufferFloatExtension=this.gl.getExtension(n),Ea(this.gl,a))this.colorBufferHalfFloatExtension=Op(this.gl,a);else if(ne().get("WEBGL_FORCE_F16_TEXTURES"))throw new Error("GL context does not support color renderable half floats, yet the environment flag WEBGL_FORCE_F16_TEXTURES is set to true.")}else if(n="EXT_color_buffer_float",Ea(this.gl,n))this.colorBufferFloatExtension=this.gl.getExtension(n);else if(Ea(this.gl,a))t
2021-09-11 16:29:31 +02:00
void main ( ) {
setOutput ( vec4 ( getA ( ) , 0. , 0. , 0. ) ) ;
2021-07-29 22:35:16 +02:00
}
2021-10-22 22:09:52 +02:00
` ;else{let n=On("rc",t),a=yt(t),r= $ Z(t,e,n),s=OZ(t,e[e.length-1],e[e.length-2],n),i=_Z(e,n);this.userCode= `
2021-09-11 16:29:31 +02:00
void main ( ) {
2021-10-22 22:09:52 +02:00
$ { a } rc = getOutputCoords ( ) ;
2021-09-11 16:29:31 +02:00
2021-10-04 23:03:36 +02:00
if ( $ { r } ) {
2021-09-11 16:29:31 +02:00
setOutput ( vec4 ( 0 ) ) ;
2021-09-05 22:42:11 +02:00
} else {
2021-10-22 22:09:52 +02:00
$ { s }
2021-09-11 16:29:31 +02:00
2021-10-22 22:09:52 +02:00
setOutput ( vec4 ( $ { i } ) ) ;
2021-09-01 00:24:30 +02:00
}
}
2021-10-22 22:09:52 +02:00
` }}};function DZ(e,t){let n=[];for(let a=0;a<=1;a++)for(let r=0;r<=1;r++){let s= ` $ { a === 0 ? "r" : "rp1" } , $ { r === 0 ? "c" : "cp1" } ` ;for(let i=2;i<e;i++)s= ` $ { t [ t . length - 1 - i ] } , ` +s;n.push(s)}return n}function $ Z(e,t,n){if(e===1)return ` rc > $ { t [ 0 ] } ` ;let a="";for(let r=e-2;r<e;r++)a+= ` $ { n [ r ] } >= $ { t [ r ] } ` ,r<e-1&&(a+="||");return a}function OZ(e,t,n,a){if(e===1)return"";let r=a.slice(-2);return `
2021-10-04 23:03:36 +02:00
int r = $ { r [ 0 ] } ;
int c = $ { r [ 1 ] } ;
2021-09-11 16:29:31 +02:00
int rp1 = r + 1 ;
int cp1 = c + 1 ;
2021-09-01 00:24:30 +02:00
2021-09-11 16:29:31 +02:00
bool cEdge = cp1 >= $ { t } ;
bool rEdge = rp1 >= $ { n } ;
2021-10-22 22:09:52 +02:00
` }function _Z(e,t){let n=e.length,a=DZ(n,t);return n===1? ` getA ( rc ) ,
2021-09-11 16:29:31 +02:00
rc + 1 >= $ { e [ 0 ] } ? 0. : getA ( rc + 1 ) ,
2021-10-22 22:09:52 +02:00
0 , 0 ` : ` getA ( $ { a [ 0 ] } ) ,
cEdge ? 0. : getA ( $ { a [ 1 ] } ) ,
rEdge ? 0. : getA ( $ { a [ 2 ] } ) ,
rEdge || cEdge ? 0. : getA ( $ { a [ 3 ] } ) ` }var q4=class{constructor(e,t){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.customUniforms=[{name:"inputShape",type:"ivec3"}],this.outputShape=e,this.enableShapeUniforms=Ra(this.outputShape.length);let n="";for(let a=0;a<4;a++){let r="thisRC = rc;";a%2==1&&(r+="thisRC.z += 1;"),a>1&&(r+="thisRC.y += 1;"),n+= `
2021-10-04 23:03:36 +02:00
$ { r }
2021-10-22 22:09:52 +02:00
$ { a > 0 ? "if(thisRC.y < rows && thisRC.z < cols){" : "" }
2021-09-11 16:29:31 +02:00
int flatIndex = getFlatIndex ( thisRC ) ;
2021-09-01 00:24:30 +02:00
2021-09-11 16:29:31 +02:00
ivec3 inputRC = inputCoordsFromReshapedOutCoords ( flatIndex ) ;
vec2 inputRCInnerDims = vec2 ( float ( inputRC . y ) , float ( inputRC . z ) ) ;
2021-06-07 02:34:29 +02:00
2021-10-22 22:09:52 +02:00
result [ $ { a } ] =
2021-09-11 16:29:31 +02:00
getChannel ( getA ( inputRC . x , inputRC . y , inputRC . z ) , inputRCInnerDims ) ;
2021-10-22 22:09:52 +02:00
$ { a > 0 ? "}" : "" }
2021-09-11 16:29:31 +02:00
` }this.userCode= `
2021-10-22 22:09:52 +02:00
$ { PZ ( t , this . enableShapeUniforms ) }
$ { this . enableShapeUniforms ? _2 ( ) : O2 ( e ) }
2021-06-07 02:34:29 +02:00
2021-09-11 16:29:31 +02:00
void main ( ) {
ivec3 rc = getOutputCoords ( ) ;
2021-08-14 17:17:51 +02:00
2021-09-11 16:29:31 +02:00
vec4 result = vec4 ( 0. ) ;
2021-08-14 17:17:51 +02:00
2021-09-11 16:29:31 +02:00
ivec3 thisRC ;
int rows = $ { this . enableShapeUniforms ? "outShape[1]" : e [ 1 ] } ;
int cols = $ { this . enableShapeUniforms ? "outShape[2]" : e [ 2 ] } ;
$ { n }
2021-08-14 17:17:51 +02:00
2021-09-01 00:24:30 +02:00
setOutput ( result ) ;
2021-09-01 00:22:16 +02:00
}
2021-10-22 22:09:52 +02:00
` }};function PZ(e,t){return `
2021-09-11 16:29:31 +02:00
ivec3 inputCoordsFromReshapedOutCoords ( int index ) {
2021-10-22 22:09:52 +02:00
$ { t ? eK ( [ "r" , "c" , "d" ] , "inputShape" ) : No ( [ "r" , "c" , "d" ] , e ) }
2021-09-11 16:29:31 +02:00
return ivec3 ( r , c , d ) ;
2021-09-05 22:42:11 +02:00
}
2021-10-22 22:09:52 +02:00
` }var zZ=class{constructor(e){this.gpgpu=e,this.numUsedTextures=0,this.numFreeTextures=0,this._numBytesAllocated=0,this._numBytesFree=0,this.freeTextures={},this.logEnabled=!1,this.usedTextures={}}acquireTexture(e,t,n){let a=K4(t,n),r=Z4(e,a,n);r in this.freeTextures||(this.freeTextures[r]=[]),r in this.usedTextures||(this.usedTextures[r]=[]);let s=X4(e,a,this.gpgpu.gl,this.gpgpu.textureConfig,n);if(this.freeTextures[r].length>0){this.numFreeTextures--,this.numUsedTextures++,this._numBytesFree-=s,this.log();let o=this.freeTextures[r].shift();return this.usedTextures[r].push(o),o}let i;return a===bn.PACKED_2X2_FLOAT32?i=this.gpgpu.createPackedMatrixTexture(e[0],e[1]):a===bn.PACKED_2X2_FLOAT16?i=this.gpgpu.createFloat16PackedMatrixTexture(e[0],e[1]):a===bn.UNPACKED_FLOAT32?i=this.gpgpu.createFloat32MatrixTexture(e[0],e[1]):a===bn.UNPACKED_FLOAT16?i=this.gpgpu.createFloat16MatrixTexture(e[0],e[1]):a===bn.PACKED_4X1_UNSIGNED_BYTE&&(i=this.gpgpu.createUnsignedBytesMatrixTexture(e[0],e[1])),this.usedTextures[r].push(i),this.numUsedTextures++,this._numBytesAllocated+=s,this.log(),i}releaseTexture(e,t,n,a){if(this.freeTextures==null)return;let r=K4(n,a),s=Z4(t,r,a);s in this.freeTextures||(this.freeTextures[s]=[]);let i=X4(t,r,this.gpgpu.gl,this.gpgpu.textureConfig,a),o=ne().get("WEBGL_DELETE_TEXTURE_THRESHOLD");o!==-1&&this._numBytesAllocated>o?(this.gpgpu.deleteMatrixTexture(e),this._numBytesAllocated-=i):(this.freeTextures[s].push(e),this.numFreeTextures++,this._numBytesFree+=i),this.numUsedTextures--;let l=this.usedTextures[s],d=l.indexOf(e);if(d<0)throw new Error("Cannot release a texture that was never provided by this texture manager");l.splice(d,1),this.log()}log(){if(!this.logEnabled)return;let e=this.numFreeTextures+this.numUsedTextures;console.log("Free/Used", ` $ { this . numFreeTextures } / $ { this . numUsedTextures } ` , ` ( $ { e } ) ` );let t=this._numBytesFree/this._numBytesAllocated;console.log( ` Bytes allocated : $ { this . _numBytesAllocated } ` ),console.log( ` Bytes unused : $ { this . _numBytesFree } ( $ { Math . round ( 100 * t ) } % ) ` )}get numBytesAllocated(){return this._numBytesAllocated}get numBytesFree(){return this._numBytesFree}getNumUsedTextures(){return this.numUsedTextures}getNumFreeTextures(){return this.numFreeTextures}dispose(){if(this.freeTextures!=null){for(let e in this.freeTextures)this.freeTextures[e].forEach(t=>{this.gpgpu.deleteMatrixTexture(t)});for(let e in this.usedTextures)this.usedTextures[e].forEach(t=>{this.gpgpu.deleteMatrixTexture(t)});this.freeTextures=null,this.usedTextures=null,this.numUsedTextures=0,this.numFreeTextures=0,this._numBytesAllocated=0,this._numBytesFree=0}}};function LZ(e,t){let n=e;if(t===n.R32F)return 4;if(t===n.R16F)return 2;if(t===n.RGBA32F||t===e.RGBA)return 16;if(t===n.RGBA16F)return 8;throw new Error( ` Unknown internal format $ { t } ` )}function X4(e,t,n,a,r){let s=WZ(t,a),i;if(r){let[l,d]=Ru(e[0],e[1]);i=l*d}else{let[l,d]= $ p(e[0],e[1]);i=l*d}let o=LZ(n,s);return i*o}function WZ(e,t){switch(e){case bn.PACKED_2X2_FLOAT32:return B2(t);case bn.PACKED_2X2_FLOAT16:return V2(t);case bn.UNPACKED_FLOAT32:return z2(t);case bn.UNPACKED_FLOAT16:return L2(t);case bn.PACKED_4X1_UNSIGNED_BYTE:return W2(t);default:throw new Error( ` Unknown physical texture type $ { e } ` )}}function BZ(e){return ne().getBool("WEBGL_RENDER_FLOAT32_ENABLED")?e?bn.PACKED_2X2_FLOAT32:bn.UNPACKED_FLOAT32:e?bn.PACKED_2X2_FLOAT16:bn.UNPACKED_FLOAT16}function K4(e,t){if(e===Ca.UPLOAD)return bn.PACKED_2X2_FLOAT32;if(e===Ca.RENDER||e==null)return BZ(t);if(e===Ca.DOWNLOAD||e===Ca.PIXELS)return bn.PACKED_4X1_UNSIGNED_BYTE;throw new Error( ` Unknown logical texture type $ { e } ` )}function Z4(e,t,n){return ` $ { e [ 0 ] } _$ { e [ 1 ] } _$ { t } _$ { n } ` }var Fs=class{constructor(e,t){this.variableNames=["A"],this.outputShape=e,this.enableShapeUniforms=Ra(this.outputShape.length),this.userCode= `
2021-09-11 16:29:31 +02:00
float unaryOperation ( float x ) {
$ { t }
}
2021-09-01 00:22:16 +02:00
void main ( ) {
2021-09-11 16:29:31 +02:00
float x = getAAtOutCoords ( ) ;
float y = unaryOperation ( x ) ;
2021-08-14 17:17:51 +02:00
2021-09-11 16:29:31 +02:00
setOutput ( y ) ;
}
2021-10-22 22:09:52 +02:00
` }},lr="if (isnan(x)) return x;",VZ="return x;",Y4="return abs(x);",UZ="return (x >= 0.0) ? x : (exp(x) - 1.0);",jZ=lr+ `
2021-09-11 16:29:31 +02:00
return ( x < 0.0 ) ? 0.0 : x ;
2021-10-22 22:09:52 +02:00
` ,GZ=lr+ `
2021-09-11 16:29:31 +02:00
return ( x < 0.0 ) ? 0.0 : min ( 6.0 , x ) ;
2021-10-22 22:09:52 +02:00
` ,Af="return x;",HZ="return 1.0 / (1.0 + exp(-1.0 * x));",qZ="return x;",XZ= `
2021-09-11 16:29:31 +02:00
vec4 result ;
2021-08-14 17:17:51 +02:00
2021-09-11 16:29:31 +02:00
result . r = ( x . r >= 0.0 ) ? x . r : ( exp ( x . r ) - 1.0 ) ;
result . g = ( x . g >= 0.0 ) ? x . g : ( exp ( x . g ) - 1.0 ) ;
result . b = ( x . b >= 0.0 ) ? x . b : ( exp ( x . b ) - 1.0 ) ;
result . a = ( x . a >= 0.0 ) ? x . a : ( exp ( x . a ) - 1.0 ) ;
2021-07-29 22:35:16 +02:00
2021-09-11 16:29:31 +02:00
return result ;
2021-10-22 22:09:52 +02:00
` ,KZ= `
2021-09-11 16:29:31 +02:00
vec4 result = x * vec4 ( greaterThanEqual ( x , vec4 ( 0.0 ) ) ) ;
bvec4 isNaN = isnan ( x ) ;
2021-09-01 00:24:30 +02:00
2021-09-11 16:29:31 +02:00
result . r = isNaN . r ? x . r : result . r ;
result . g = isNaN . g ? x . g : result . g ;
result . b = isNaN . b ? x . b : result . b ;
result . a = isNaN . a ? x . a : result . a ;
2021-08-14 17:17:51 +02:00
2021-09-05 22:42:11 +02:00
return result ;
2021-10-22 22:09:52 +02:00
` ,ZZ= `
2021-09-11 16:29:31 +02:00
vec4 result = min ( x , vec4 ( 6. ) ) * vec4 ( greaterThanEqual ( x , vec4 ( 0.0 ) ) ) ;
bvec4 isNaN = isnan ( x ) ;
2021-09-01 00:22:16 +02:00
2021-09-11 16:29:31 +02:00
result . r = isNaN . r ? x . r : result . r ;
result . g = isNaN . g ? x . g : result . g ;
result . b = isNaN . b ? x . b : result . b ;
result . a = isNaN . a ? x . a : result . a ;
2021-07-29 22:35:16 +02:00
2021-09-11 16:29:31 +02:00
return result ;
2021-10-22 22:09:52 +02:00
` ,YZ="return 1.0 / (1.0 + exp(-1.0 * x));",_u=class{constructor(e,t){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=e,this.enableShapeUniforms=Ra(this.outputShape.length),this.userCode= `
2021-09-11 16:29:31 +02:00
vec4 unaryOperation ( vec4 x ) {
$ { t }
}
2021-08-14 17:17:51 +02:00
2021-09-11 16:29:31 +02:00
void main ( ) {
vec4 x = getAAtOutCoords ( ) ;
vec4 y = unaryOperation ( x ) ;
2021-08-14 17:17:51 +02:00
2021-09-11 16:29:31 +02:00
setOutput ( y ) ;
}
2021-10-22 22:09:52 +02:00
` }},JZ=class{constructor(e){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!1,this.outputShape=e;let t=e.length,n=On("rc",t),a=yt(t),r=MZ(t,n),s=n.slice(-2),i=t<=1?"rc": ` vec2 ( $ { s . join ( "," ) } ) ` ;this.userCode= `
2021-09-11 16:29:31 +02:00
void main ( ) {
2021-10-22 22:09:52 +02:00
$ { a } rc = getOutputCoords ( ) ;
2021-10-04 23:03:36 +02:00
vec4 packedInput = getA ( $ { r } ) ;
2021-08-14 17:17:51 +02:00
2021-10-22 22:09:52 +02:00
setOutput ( getChannel ( packedInput , $ { i } ) ) ;
2021-09-11 16:29:31 +02:00
}
2021-10-22 22:09:52 +02:00
` }},QZ=xr.whereImpl,eY=1e-7,tY=1e-4,j2={};function nY(e){return e in j2||(j2[e]={}),j2[e]}var aY=ne().getNumber("CPU_HANDOFF_SIZE_THRESHOLD"),rY=600;function sY(){return ne().global.screen==null?1024:ne().global.screen.height*ne().global.screen.width*window.devicePixelRatio*rY/1024/1024}var Pu=class extends fd{constructor(e){super();if(this.pendingRead=new WeakMap,this.pendingDisposal=new WeakSet,this.dataRefCount=new WeakMap,this.numBytesInGPU=0,this.uploadWaitMs=0,this.downloadWaitMs=0,this.lastGlFlushTime=0,this.warnedAboutMemory=!1,this.pendingDeletes=0,this.disposed=!1,!ne().getBool("HAS_WEBGL"))throw new Error("WebGL is not supported on this device");if(e==null){let t=Nr(ne().getNumber("WEBGL_VERSION"));this.binaryCache=nY(ne().getNumber("WEBGL_VERSION")),this.gpgpu=new yf(t),this.canvas=t.canvas,this.gpgpuCreatedLocally=!0}else this.gpgpu=e,this.binaryCache={},this.gpgpuCreatedLocally=!1,this.canvas=e.gl.canvas;this.textureManager=new zZ(this.gpgpu),this.numMBBeforeWarning=sY(),this.texData=new Oc(this,sa())}nextDataId(){return Pu.nextDataId++}numDataIds(){return this.texData.numDataIds()-this.pendingDeletes}write(e,t,n){if((ne().getBool("WEBGL_CHECK_NUMERICAL_PROBLEMS")||ne().getBool("DEBUG"))&&this.checkNumericalProblems(e),n==="complex64"&&e!=null)throw new Error("Cannot write to a complex64 dtype. Please use tf.complex(real, imag).");let a={id:this.nextDataId()};return this.texData.set(a,{shape:t,dtype:n,values:e,usage:Ca.UPLOAD,refCount:1}),a}refCount(e){return this.texData.has(e)?this.texData.get(e).refCount:0}incRef(e){let t=this.texData.get(e);t.refCount++}decRef(e){if(this.texData.has(e)){let t=this.texData.get(e);t.refCount--}}move(e,t,n,a,r){if(ne().getBool("DEBUG")&&this.checkNumericalProblems(t),a==="complex64")throw new Error("Cannot write to a complex64 dtype. Please use tf.complex(real, imag).");this.texData.set(e,{shape:n,dtype:a,values:t,usage:Ca.UPLOAD,refCount:r})}disposeIntermediateTensorInfo(e){this.disposeData(e.dataId)}readSync(e){let t=this.texData.get(e),{values:n,dtype:a,complexTensorInfos:r,slice:s,shape:i,isPacked:o}=t;if(s!=null){let p;o?p=new _u(i,Af):p=new Fs(i,Af);let c=this.runWebGLProgram(p,[{dataId:e,shape:i,dtype:a}],a),h=this.readSync(c.dataId);return this.disposeIntermediateTensorInfo(c),h}if(n!=null)return this.convertAndCacheOnCPU(e);if(a==="string")return n;let l=this.activeTimers!=null,d;l&&(d=w.now());let u;if(a==="complex64"){let p=this.readSync(r.real.dataId),c=this.readSync(r.imag.dataId);u=E.mergeRealAndImagArrays(p,c)}else u=this.getValuesFromTexture(e);return l&&(this.downloadWaitMs+=w.now()-d),this.convertAndCacheOnCPU(e,u)}async read(e){if(this.pendingRead.has(e)){let h=this.pendingRead.get(e);return new Promise(f=>h.push(f))}let t=this.texData.get(e),{values:n,shape:a,slice:r,dtype:s,complexTensorInfos:i,isPacked:o}=t;if(r!=null){let h;o?h=new _u(a,Af):h=new Fs(a,Af);let f=this.runWebGLProgram(h,[{dataId:e,shape:a,dtype:s}],s),m=this.read(f.dataId);return this.disposeIntermediateTensorInfo(f),m}if(n!=null)return this.convertAndCacheOnCPU(e);if(!ne().getBool("WEBGL_DOWNLOAD_FLOAT_ENABLED")&&ne().getNumber("WEBGL_VERSION")===2)throw new Error("tensor.data() with WEBGL_DOWNLOAD_FLOAT_ENABLED=false and WEBGL_VERSION=2 not yet supported.");let l=null,d;if(s!=="complex64"&&ne().get("WEBGL_BUFFER_SUPPORTED")){d=this.decode(e);let h=this.texData.get(d.dataId);l=this.gpgpu.createBufferFromTexture(h.texture,...uf(a))}this.pendingRead.set(e,[]),s!=="complex64"&&await this.gpgpu.createAndWaitForFence();let u;if(s==="complex64"){let h=await Promise.all([this.read(i.real.dataId),this.read(i.imag.dataId)]),f=h[0],m=h[1];u=E.mergeRealAndImagArrays(f,m)}else if(l==null)u=this.getValuesFromTexture(e);else{let h=w.sizeFromShape(a);u=this.gpgpu.downloadFloat32MatrixFromBuffer(l,h)}if(d!=null&&this.disposeIntermediateTensorInfo(d),l!=null){let h=this.gpgpu.gl;Se(h,()=>h.deleteBuffer(l))}let p=this.convertAndCacheOnCPU(e,u),c=this.pendingRead.get(e);return this.pendingRead.delete(e),c.forEach(h=>h(p)),this.pendingDisposal.has(e)&&(this.pendingDisposal.delete(e),this.disposeData(
2021-09-11 16:29:31 +02:00
if ( isnan ( a ) ) return a ;
if ( isnan ( b ) ) return b ;
2021-10-22 22:09:52 +02:00
` ,zu=class{constructor(e,t,n){this.variableNames=["A","B"],this.outputShape=E.assertAndGetBroadcastShape(t,n),this.enableShapeUniforms=Ra(this.outputShape.length),this.userCode= `
2021-09-11 16:29:31 +02:00
float binaryOperation ( float a , float b ) {
$ { e }
}
2021-08-14 17:17:51 +02:00
2021-09-11 16:29:31 +02:00
void main ( ) {
float a = getAAtOutCoords ( ) ;
float b = getBAtOutCoords ( ) ;
setOutput ( binaryOperation ( a , b ) ) ;
}
2021-10-22 22:09:52 +02:00
` }},xf= `
2021-09-11 16:29:31 +02:00
result . r = isNaN . r > 0. ? NAN : result . r ;
result . g = isNaN . g > 0. ? NAN : result . g ;
result . b = isNaN . b > 0. ? NAN : result . b ;
result . a = isNaN . a > 0. ? NAN : result . a ;
2021-10-22 22:09:52 +02:00
` ,Lp=class{constructor(e,t,n,a=!1){this.variableNames=["A","B"],this.supportsBroadcasting=!0,this.packedInputs=!0,this.packedOutput=!0,this.outputShape=E.assertAndGetBroadcastShape(t,n);let r=this.outputShape.length;this.enableShapeUniforms=Ra(r);let s="";if(a)if(r===0||w.sizeFromShape(this.outputShape)===1)s= `
2021-09-11 16:29:31 +02:00
result . y = 0. ;
result . z = 0. ;
result . w = 0. ;
2021-10-22 22:09:52 +02:00
` ;else if(s= `
2021-10-22 19:49:40 +02:00
$ { yt ( r ) } coords = getOutputCoords ( ) ;
2021-10-22 22:09:52 +02:00
` ,r===1)this.enableShapeUniforms?s+= `
2021-09-11 16:29:31 +02:00
result . y = ( coords + 1 ) >= outShape ? 0. : result . y ;
result . z = 0. ;
result . w = 0. ;
2021-10-22 22:09:52 +02:00
` :s+= `
2021-09-11 16:29:31 +02:00
result . y = ( coords + 1 ) >= $ { this . outputShape [ 0 ] } ? 0. : result . y ;
result . z = 0. ;
result . w = 0. ;
2021-10-22 22:09:52 +02:00
` ;else{let i=On("coords",r);this.enableShapeUniforms?s+= `
2021-09-11 16:29:31 +02:00
bool nextRowOutOfBounds =
2021-10-04 23:03:36 +02:00
( $ { i [ r - 2 ] } + 1 ) >= outShape [ $ { r } - 2 ] ;
2021-09-11 16:29:31 +02:00
bool nextColOutOfBounds =
2021-10-04 23:03:36 +02:00
( $ { i [ r - 1 ] } + 1 ) >= outShape [ $ { r } - 1 ] ;
2021-09-11 16:29:31 +02:00
result . y = nextColOutOfBounds ? 0. : result . y ;
result . z = nextRowOutOfBounds ? 0. : result . z ;
result . w = nextColOutOfBounds || nextRowOutOfBounds ? 0. : result . w ;
2021-10-22 22:09:52 +02:00
` :s+= `
2021-09-11 16:29:31 +02:00
bool nextRowOutOfBounds =
2021-10-04 23:03:36 +02:00
( $ { i [ r - 2 ] } + 1 ) >= $ { this . outputShape [ r - 2 ] } ;
2021-09-11 16:29:31 +02:00
bool nextColOutOfBounds =
2021-10-04 23:03:36 +02:00
( $ { i [ r - 1 ] } + 1 ) >= $ { this . outputShape [ r - 1 ] } ;
2021-09-11 16:29:31 +02:00
result . y = nextColOutOfBounds ? 0. : result . y ;
result . z = nextRowOutOfBounds ? 0. : result . z ;
result . w = nextColOutOfBounds || nextRowOutOfBounds ? 0. : result . w ;
` }this.userCode= `
vec4 binaryOperation ( vec4 a , vec4 b ) {
$ { e }
}
void main ( ) {
vec4 a = getAAtOutCoords ( ) ;
vec4 b = getBAtOutCoords ( ) ;
2021-07-29 22:35:16 +02:00
2021-09-11 16:29:31 +02:00
vec4 result = binaryOperation ( a , b ) ;
2021-10-22 22:09:52 +02:00
$ { s }
2021-09-01 00:24:30 +02:00
2021-09-11 16:29:31 +02:00
setOutput ( result ) ;
}
2021-10-22 22:09:52 +02:00
` }};function ma(e){let{inputs:t,backend:n}=e,{x:a}=t;return n.incRef(a.dataId),{dataId:a.dataId,shape:a.shape,dtype:a.dtype}}var uY={kernelName:mi,backendName:"webgl",kernelFunc:ma};function Ds(e){let{inputs:t,backend:n}=e,{real:a,imag:r}=t,s=n.makeTensorInfo(a.shape,"complex64"),i=n.texData.get(s.dataId),o=ma({inputs:{x:a},backend:n}),l=ma({inputs:{x:r},backend:n});return i.complexTensorInfos={real:o,imag:l},s}var dY={kernelName:jc,backendName:"webgl",kernelFunc:Ds},ek="return (a < 0.) ? b * a : a;",tk= `
2021-09-11 16:29:31 +02:00
vec4 aLessThanZero = vec4 ( lessThan ( a , vec4 ( 0. ) ) ) ;
return ( aLessThanZero * ( b * a ) ) + ( ( vec4 ( 1.0 ) - aLessThanZero ) * a ) ;
2021-10-22 22:09:52 +02:00
` ;function pY(e){let{inputs:t,backend:n,attrs:a}=e,{x:r}=t,{alpha:s}=a,i=n.makeTensorInfo([],"float32",w.createScalarValue(s,"float32")),o=ne().getBool("WEBGL_PACK_BINARY_OPERATIONS")?new Lp(tk,r.shape,i.shape):new zu(ek,r.shape,i.shape),l=n.runWebGLProgram(o,[r,i],"float32");return n.disposeIntermediateTensorInfo(i),l}var cY={kernelName:gi,backendName:"webgl",kernelFunc:pY},nk="return (a < 0.) ? b * a : a;",ak= `
2021-09-11 16:29:31 +02:00
vec4 aLessThanZero = vec4 ( lessThan ( a , vec4 ( 0. ) ) ) ;
return ( aLessThanZero * ( b * a ) ) + ( ( vec4 ( 1.0 ) - aLessThanZero ) * a ) ;
2021-10-22 22:09:52 +02:00
` ;function hY(e){let{inputs:t,backend:n}=e,{x:a,alpha:r}=t,s=ne().getBool("WEBGL_PACK_BINARY_OPERATIONS")?new Lp(ak,a.shape,r.shape):new zu(nk,a.shape,r.shape);return n.runWebGLProgram(s,[a,r],"float32")}var fY={kernelName:Ei,backendName:"webgl",kernelFunc:hY},rk="if (isnan(x)) return x;",mY= `
2021-09-11 16:29:31 +02:00
if ( isnan ( a ) ) return a ;
if ( isnan ( b ) ) return b ;
2021-10-22 22:09:52 +02:00
` ,gY= `
2021-09-11 16:29:31 +02:00
result . r = isNaN . r > 0. ? NAN : result . r ;
result . g = isNaN . g > 0. ? NAN : result . g ;
result . b = isNaN . b > 0. ? NAN : result . b ;
result . a = isNaN . a > 0. ? NAN : result . a ;
2021-10-22 22:09:52 +02:00
` ;function nt({opSnippet:e,packedOpSnippet:t,cpuKernelImpl:n,dtype:a}){return({inputs:r,backend:s})=>{let{x:i}=r,o=s,l=a||i.dtype;if(o.shouldExecuteOnCPU([i])&&n!=null){let p=o.texData.get(i.dataId),c=n(p.values,l);return o.makeTensorInfo(i.shape,l,c)}let d=ne().getBool("WEBGL_PACK_UNARY_OPERATIONS")&&t!=null,u;return d?u=new _u(i.shape,t):u=new Fs(i.shape,e),o.runWebGLProgram(u,[i],l)}}function vn({opSnippet:e,packedOpSnippet:t,checkOutOfBounds:n=!1,supportsComplex:a=!1,cpuKernelImpl:r,dtype:s}){return({inputs:i,backend:o})=>{let{a:l,b:d}=i,u=o;if(a&&l.dtype==="complex64"){let f=u.texData.get(l.dataId),m=u.texData.get(d.dataId),[g,y]=[[f.complexTensorInfos.real,m.complexTensorInfos.real],[f.complexTensorInfos.imag,m.complexTensorInfos.imag]].map(x=>{let[b,v]=x,k={dataId:b.dataId,dtype:b.dtype,shape:l.shape},T={dataId:v.dataId,dtype:v.dtype,shape:d.shape},C=new zu(e,l.shape,d.shape);return u.runWebGLProgram(C,[k,T],Pa(b.dtype,v.dtype))}),A=Ds({inputs:{real:g,imag:y},backend:u});return u.disposeIntermediateTensorInfo(g),u.disposeIntermediateTensorInfo(y),A}let p=s||Pa(l.dtype,d.dtype);if((l.dtype==="string"||d.dtype==="string"||u.shouldExecuteOnCPU([l,d]))&&r!=null){let f=u.texData.get(l.dataId).values,m=u.texData.get(d.dataId).values,g=l.dtype==="string"?E.fromUint8ToStringArray(f):f,y=l.dtype==="string"?E.fromUint8ToStringArray(m):m,[A,x]=r(l.shape,d.shape,g,y,p),b=u.makeTensorInfo(x,p),v=u.texData.get(b.dataId);return v.values=A,b}let c=ne().getBool("WEBGL_PACK_BINARY_OPERATIONS")&&t!=null,h;return c?h=new Lp(t,l.shape,d.shape,n):h=new zu(e,l.shape,d.shape),u.runWebGLProgram(h,[l,d],p)}}function bf(e,t=!1){if(e==="linear")return t?qZ:VZ;if(e==="relu")return t?KZ:jZ;if(e==="elu")return t?XZ:UZ;if(e==="relu6")return t?ZZ:GZ;if(e==="prelu")return t?ak:nk;if(e==="leakyrelu")return t?tk:ek;if(e==="sigmoid")return t?YZ:HZ;throw new Error( ` Activation $ { e } has not been implemented for the WebGL backend . ` )}var sk=class{constructor(e,t,n,a=!1,r=!1,s=!1,i=null,o=!1,l=!1){this.variableNames=["matrixA","matrixB"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=n,this.enableShapeUniforms=Ra(this.outputShape.length);let d=a?e[1]:e[2],u=Math.ceil(d/2),p=a?"i * 2, rc.y":"rc.y, i * 2",c=r?"rc.z, i * 2":"i * 2, rc.z",h=a?["a.xxyy","a.zzww"]:["a.xxzz","a.yyww"],f=r?["b.xzxz","b.ywyw"]:["b.xyxy","b.zwzw"],m="",g="";i&&(o?m= ` vec4 activation ( vec4 a ) {
2021-09-11 16:29:31 +02:00
vec4 b = getPreluActivationWeightsAtOutCoords ( ) ;
2021-10-22 22:09:52 +02:00
$ { i }
2021-10-07 16:33:10 +02:00
} ` :l?m= ` vec4 activation ( vec4 a ) {
2021-09-11 16:29:31 +02:00
vec4 b = getLeakyreluAlphaAtOutCoords ( ) ;
2021-10-22 22:09:52 +02:00
$ { i }
2021-10-07 16:33:10 +02:00
} ` :m= ` vec4 activation ( vec4 x ) {
2021-10-22 22:09:52 +02:00
$ { i }
} ` ,g="result = activation(result);");let y=s?"result += getBiasAtOutCoords();":"";s&&this.variableNames.push("bias"),o&&this.variableNames.push("preluActivationWeights"),l&&this.variableNames.push("leakyreluAlpha");let A="rc.x",x="rc.x";e[0]<t[0]?A= ` int ( min ( float ( rc . x ) , $ { e [ 0 ] - 1 } . ) ) ` :t[0]<e[0]&&(x= ` int ( min ( float ( rc . x ) , $ { t [ 0 ] - 1 } . ) ) ` ),this.userCode= `
2021-10-07 16:33:10 +02:00
$ { m }
2021-09-11 16:29:31 +02:00
// Don't use uniform for sharedDimensionPacked for performance.
2021-10-07 16:33:10 +02:00
const float sharedDimension = $ { u } . 0 ;
2021-08-14 17:17:51 +02:00
2021-09-11 16:29:31 +02:00
vec4 dot2x2ARowBCol ( ivec3 rc ) {
vec4 result = vec4 ( 0 ) ;
2021-10-07 16:33:10 +02:00
for ( int i = 0 ; i < $ { u } ; i ++ ) {
2021-10-22 22:09:52 +02:00
int batchA = $ { A } ;
2021-10-04 23:03:36 +02:00
int batchB = $ { x } ;
2021-10-22 22:09:52 +02:00
vec4 a = getMatrixA ( batchA , $ { p } ) ;
vec4 b = getMatrixB ( batchB , $ { c } ) ;
2021-09-11 16:29:31 +02:00
// These swizzled products need to be separately added.
// See: https://github.com/tensorflow/tfjs/issues/1735
2021-10-07 16:33:10 +02:00
result += ( $ { h [ 0 ] } * $ { f [ 0 ] } ) ;
result += ( $ { h [ 1 ] } * $ { f [ 1 ] } ) ;
2021-08-14 17:17:51 +02:00
}
2021-09-11 16:29:31 +02:00
return result ;
2021-09-01 00:22:16 +02:00
}
2021-09-01 00:24:30 +02:00
2021-08-14 17:17:51 +02:00
void main ( ) {
2021-09-11 16:29:31 +02:00
ivec3 rc = getOutputCoords ( ) ;
vec4 result = dot2x2ARowBCol ( rc ) ;
2021-09-01 00:24:30 +02:00
2021-10-22 22:09:52 +02:00
$ { y }
2021-09-01 00:24:30 +02:00
2021-09-11 16:29:31 +02:00
$ { g }
2021-09-01 00:22:16 +02:00
2021-09-11 16:29:31 +02:00
setOutput ( result ) ;
}
2021-10-22 22:09:52 +02:00
` }},ik={REAL:"return areal * breal - aimag * bimag;",IMAG:"return areal * bimag + aimag * breal;"},ok=class{constructor(e,t,n){this.variableNames=["AReal","AImag","BReal","BImag"],this.outputShape=E.assertAndGetBroadcastShape(t,n),this.userCode= `
2021-09-11 16:29:31 +02:00
float binaryOpComplex (
float areal , float aimag , float breal , float bimag ) {
$ { e }
}
2021-09-05 22:42:11 +02:00
2021-09-11 16:29:31 +02:00
void main ( ) {
float areal = getARealAtOutCoords ( ) ;
float aimag = getAImagAtOutCoords ( ) ;
float breal = getBRealAtOutCoords ( ) ;
float bimag = getBImagAtOutCoords ( ) ;
setOutput ( binaryOpComplex ( areal , aimag , breal , bimag ) ) ;
}
2021-10-22 22:09:52 +02:00
` }},lk="return a * b;";function G2(e){let{inputs:t,backend:n}=e,{a,b:r}=t,s=E.upcastType(a.dtype,r.dtype);if(a.dtype==="complex64"){let o=n.texData.get(a.dataId),l=n.texData.get(r.dataId),d=new ok(ik.REAL,a.shape,r.shape),u=new ok(ik.IMAG,a.shape,r.shape),p=[{dataId:o.complexTensorInfos.real.dataId,dtype:o.complexTensorInfos.real.dtype,shape:a.shape},{dataId:o.complexTensorInfos.imag.dataId,dtype:o.complexTensorInfos.imag.dtype,shape:a.shape},{dataId:l.complexTensorInfos.real.dataId,dtype:l.complexTensorInfos.real.dtype,shape:r.shape},{dataId:l.complexTensorInfos.imag.dataId,dtype:l.complexTensorInfos.imag.dtype,shape:r.shape}],c=n.runWebGLProgram(d,p,"float32"),h=n.runWebGLProgram(u,p,"float32"),f=Ds({inputs:{real:c,imag:h},backend:n});return n.disposeIntermediateTensorInfo(c),n.disposeIntermediateTensorInfo(h),f}if(n.shouldExecuteOnCPU([a,r])){let o=n.texData.get(a.dataId),l=n.texData.get(r.dataId),[d,u]=cZ(a.shape,r.shape,o.values,l.values,s),p=n.makeTensorInfo(u,s),c=n.texData.get(p.dataId);return c.values=d,p}let i;return ne().getBool("WEBGL_PACK_BINARY_OPERATIONS")?i=new Lp(lk,a.shape,r.shape):i=new zu(lk,a.shape,r.shape),n.runWebGLProgram(i,[a,r],s)}var yY={kernelName:Si,backendName:"webgl",kernelFunc:G2};function AY(e,t,n){let a=[Io(e.shape),...So(e.shape)],r={dtype:e.dtype,shape:a,dataId:e.dataId},s=[Io(t),...So(t)],i=new q4(s,a),o=!0,l=[a],d=n.runWebGLProgram(i,[r],e.dtype,l,o);return{dataId:d.dataId,shape:t,dtype:d.dtype}}function we(e){let{inputs:t,backend:n,attrs:a}=e,{x:r}=t,{shape:s}=a,i=n,o=w.sizeFromShape(r.shape),l=w.inferFromImplicitShape(s,o),d=w.sizeFromShape(l);w.assert(o===d,()=> ` The new shape ( $ { l } ) has $ { d } elements and the old shape ( $ { r . shape } ) has $ { o } elements . The new shape and old shape must have the same number of elements . ` );let u=i.texData.get(r.dataId);return u.isPacked&&!Pp(r.shape,l)&&!(u.texture!==null&&Pp(u.shape,l))?AY(r,l,i):(i.incRef(r.dataId),{dataId:r.dataId,shape:l,dtype:r.dtype})}var xY={kernelName: $ l,backendName:"webgl",kernelFunc:we},uk=class{constructor(e,t){this.variableNames=["x"];let{windowSize:n,batchSize:a,inSize:r,outSize:s}=e;this.outputShape=[a,s];let i=Math.floor(n/4)*4,o=n%4,l="sumValue += dot(values, ones);";if(t!=null){let u=1/t;l= ` sumValue += dot ( values * $ { w . isInt ( u ) ? u . toPrecision ( 2 ) : u } , ones ) ; ` }let d="";r%n>0&&(d= `
2021-10-04 23:03:36 +02:00
if ( inIdx < 0 || inIdx >= $ { r } ) {
2021-09-11 16:29:31 +02:00
return 0.0 ;
}
` ),this.userCode= `
const vec4 ones = vec4 ( 1.0 , 1.0 , 1.0 , 1.0 ) ;
2021-09-01 00:22:16 +02:00
2021-09-11 16:29:31 +02:00
float getValue ( int batch , int inIdx ) {
2021-10-22 22:09:52 +02:00
$ { d }
2021-09-11 16:29:31 +02:00
return getX ( batch , inIdx ) ;
}
2021-08-14 17:17:51 +02:00
2021-09-11 16:29:31 +02:00
void main ( ) {
ivec2 coords = getOutputCoords ( ) ;
int batch = coords [ 0 ] ;
int outIdx = coords [ 1 ] ;
int inOffset = outIdx * $ { n } ;
2021-09-01 00:22:16 +02:00
2021-09-11 16:29:31 +02:00
float sumValue = 0.0 ;
2021-09-01 00:24:30 +02:00
2021-10-22 22:09:52 +02:00
for ( int i = 0 ; i < $ { i } ; i += 4 ) {
2021-09-11 16:29:31 +02:00
int inIdx = inOffset + i ;
vec4 values = vec4 (
getValue ( batch , inIdx ) ,
getValue ( batch , inIdx + 1 ) ,
getValue ( batch , inIdx + 2 ) ,
getValue ( batch , inIdx + 3 )
) ;
2021-09-01 00:24:30 +02:00
2021-09-11 16:29:31 +02:00
$ { l }
}
2021-09-01 00:24:30 +02:00
2021-10-22 22:09:52 +02:00
int inIdx = inOffset + $ { i } ;
if ( $ { o === 1 } ) {
2021-09-11 16:29:31 +02:00
vec4 values = vec4 ( getValue ( batch , inIdx ) , 0.0 , 0.0 , 0.0 ) ;
2021-09-01 00:24:30 +02:00
2021-09-11 16:29:31 +02:00
$ { l }
2021-10-22 22:09:52 +02:00
} else if ( $ { o === 2 } ) {
2021-09-11 16:29:31 +02:00
vec4 values = vec4 (
getValue ( batch , inIdx ) ,
getValue ( batch , inIdx + 1 ) , 0.0 , 0.0 ) ;
2021-09-01 00:24:30 +02:00
2021-09-11 16:29:31 +02:00
$ { l }
2021-10-22 22:09:52 +02:00
} else if ( $ { o === 3 } ) {
2021-09-11 16:29:31 +02:00
vec4 values = vec4 (
getValue ( batch , inIdx ) ,
getValue ( batch , inIdx + 1 ) ,
getValue ( batch , inIdx + 2 ) , 0.0 ) ;
2021-09-01 00:24:30 +02:00
2021-09-11 16:29:31 +02:00
$ { l }
2021-09-01 00:24:30 +02:00
}
2021-09-11 16:29:31 +02:00
setOutput ( sumValue ) ;
2021-09-05 22:42:11 +02:00
}
2021-10-22 22:09:52 +02:00
` }},bY=class{constructor(e,t){this.variableNames=["x"];let{windowSize:n,batchSize:a,inSize:r,outSize:s}=e;this.outputShape=[a,s];let i="0.0",o="";t==="prod"?i="1.0":t==="min"?(i="1.0 / 1e-20",o="min"):t==="max"&&(i="-1.0 / 1e-20",o="max");let l= ` $ { t } ( $ { t } ( $ { t } ( minMaxValue [ 0 ] , minMaxValue [ 1 ] ) , minMaxValue [ 2 ] ) , minMaxValue [ 3 ] ) ` ;t==="sum"?l="sumValue":t==="prod"?l="prodValue":t==="all"?l="allValue":t==="any"&&(l="anyValue");let d=Math.floor(n/4)*4,u=n%4,p= `
2021-09-11 16:29:31 +02:00
if ( $ { t === "sum" } ) {
sumValue += dot ( values , ones ) ;
} else if ( $ { t === "prod" } ) {
vec2 tmp = vec2 ( values [ 0 ] , values [ 1 ] ) * vec2 ( values [ 2 ] , values [ 3 ] ) ;
prodValue *= tmp [ 0 ] * tmp [ 1 ] ;
2021-09-05 22:42:11 +02:00
} else {
2021-10-22 22:09:52 +02:00
minMaxValue = $ { o } ( values , minMaxValue ) ;
2021-09-11 16:29:31 +02:00
if ( $ { t === "min" } || $ { t === "max" } ) {
2021-10-22 22:09:52 +02:00
minMaxValue = $ { o } ( values , minMaxValue ) ;
2021-09-11 16:29:31 +02:00
bvec4 isNaN = isnan ( values ) ;
if ( isNaN . r || isNaN . g || isNaN . b || isNaN . a ) {
minMaxValue = vec4 ( NAN ) ;
2021-09-05 22:42:11 +02:00
}
}
2021-09-01 00:24:30 +02:00
}
2021-10-22 22:09:52 +02:00
` ,c="vec4";t==="all"?(i="1.0",p= `
2021-09-11 16:29:31 +02:00
bool reducedAllValue = all ( values ) ;
float floatedReducedAllValue = float ( reducedAllValue ) ;
allValue = float ( allValue >= 1.0 && floatedReducedAllValue >= 1.0 ) ;
2021-10-22 22:09:52 +02:00
` ,c="bvec4"):t==="any"&&(i="0.0",p= `
2021-09-11 16:29:31 +02:00
bool reducedAnyValue = any ( values ) ;
float floatedReducedAnyValue = float ( reducedAnyValue ) ;
anyValue = float ( anyValue >= 1.0 || floatedReducedAnyValue >= 1.0 ) ;
2021-10-22 22:09:52 +02:00
` ,c="bvec4");let h="";r%n>0&&(h= `
2021-10-04 23:03:36 +02:00
if ( inIdx < 0 || inIdx >= $ { r } ) {
2021-09-11 16:29:31 +02:00
return initializationValue ;
}
` ),this.userCode= `
2021-10-22 22:09:52 +02:00
const float initializationValue = $ { i } ;
2021-09-11 16:29:31 +02:00
const vec4 ones = vec4 ( 1.0 , 1.0 , 1.0 , 1.0 ) ;
2021-08-14 17:17:51 +02:00
2021-09-11 16:29:31 +02:00
float getValue ( int batch , int inIdx ) {
2021-10-04 23:03:36 +02:00
$ { h }
2021-09-11 16:29:31 +02:00
return getX ( batch , inIdx ) ;
2021-09-05 22:42:11 +02:00
}
2021-09-11 16:29:31 +02:00
2021-09-05 22:42:11 +02:00
void main ( ) {
ivec2 coords = getOutputCoords ( ) ;
2021-09-01 00:24:30 +02:00
int batch = coords [ 0 ] ;
2021-09-11 16:29:31 +02:00
int outIdx = coords [ 1 ] ;
int inOffset = outIdx * $ { n } ;
2021-09-01 00:24:30 +02:00
2021-10-22 22:09:52 +02:00
vec4 minMaxValue = vec4 ( $ { i } ) ;
2021-09-11 16:29:31 +02:00
float prodValue = 1.0 ;
float sumValue = 0.0 ;
float allValue = 1.0 ;
float anyValue = 0.0 ;
2021-09-01 00:24:30 +02:00
2021-10-22 22:09:52 +02:00
for ( int i = 0 ; i < $ { d } ; i += 4 ) {
2021-09-11 16:29:31 +02:00
int inIdx = inOffset + i ;
2021-10-22 22:09:52 +02:00
$ { c } values = $ { c } (
2021-09-11 16:29:31 +02:00
getValue ( batch , inIdx ) ,
getValue ( batch , inIdx + 1 ) ,
getValue ( batch , inIdx + 2 ) ,
getValue ( batch , inIdx + 3 )
) ;
2021-09-01 00:24:30 +02:00
2021-10-22 22:09:52 +02:00
$ { p }
2021-09-05 22:42:11 +02:00
}
2021-09-01 00:24:30 +02:00
2021-10-22 22:09:52 +02:00
int inIdx = inOffset + $ { d } ;
2021-10-07 16:33:10 +02:00
if ( $ { u === 1 } ) {
2021-10-22 22:09:52 +02:00
$ { c } values = $ { c } (
2021-09-11 16:29:31 +02:00
getValue ( batch , inIdx ) ,
initializationValue ,
initializationValue ,
initializationValue
) ;
2021-09-01 00:24:30 +02:00
2021-10-22 22:09:52 +02:00
$ { p }
2021-10-07 16:33:10 +02:00
} else if ( $ { u === 2 } ) {
2021-10-22 22:09:52 +02:00
$ { c } values = $ { c } (
2021-09-11 16:29:31 +02:00
getValue ( batch , inIdx ) ,
getValue ( batch , inIdx + 1 ) ,
initializationValue ,
initializationValue
) ;
2021-10-22 22:09:52 +02:00
$ { p }
2021-10-07 16:33:10 +02:00
} else if ( $ { u === 3 } ) {
2021-10-22 22:09:52 +02:00
$ { c } values = $ { c } (
2021-09-11 16:29:31 +02:00
getValue ( batch , inIdx ) ,
getValue ( batch , inIdx + 1 ) ,
getValue ( batch , inIdx + 2 ) ,
initializationValue
) ;
2021-10-22 22:09:52 +02:00
$ { p }
2021-09-11 16:29:31 +02:00
}
setOutput ( $ { l } ) ;
}
2021-10-22 22:09:52 +02:00
` }};function vY(e){let t=[];for(;t.length===0||t[t.length-1].outSize!==1;){let n=t.length?t[t.length-1].outSize:e[1],a=E.computeOptimalWindowSize(n);t.push({inSize:n,windowSize:a,outSize:Math.ceil(n/a)})}return t}function Co(e,t,n,a){let r=vY(e.shape),s=e;for(let i=0;i<r.length;i++){let{inSize:o,windowSize:l,outSize:d}=r[i],u,p;n==="mean"?u=i===0?new uk({windowSize:l,inSize:o,batchSize:e.shape[0],outSize:d},o):new uk({windowSize:l,inSize:o,batchSize:e.shape[0],outSize:d}):u=new bY({windowSize:l,inSize:o,batchSize:e.shape[0],outSize:d},n),p=s,s=a.runWebGLProgram(u,[s],t),p.dataId!==e.dataId&&a.disposeIntermediateTensorInfo(p)}return s}var wY=class{constructor(e,t){this.variableNames=["A"];let n=new Array(e.length);for(let s=0;s<n.length;s++)n[s]=e[t[s]];this.outputShape=n,this.rank=n.length;let a=yt(this.rank),r=kY(t);this.userCode= `
2021-09-11 16:29:31 +02:00
void main ( ) {
2021-10-22 22:09:52 +02:00
$ { a } resRC = getOutputCoords ( ) ;
2021-10-04 23:03:36 +02:00
setOutput ( getA ( $ { r } ) ) ;
2021-09-05 22:42:11 +02:00
}
2021-10-22 22:09:52 +02:00
` }};function kY(e){let t=e.length;if(t>6)throw Error( ` Transpose for rank $ { t } is not yet supported ` );let n=["resRC.x","resRC.y","resRC.z","resRC.w","resRC.u","resRC.v"],a=new Array(t);for(let r=0;r<e.length;r++)a[e[r]]=n[r];return a.join()}var IY=class{constructor(e,t){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0;let n=new Array(e.length);for(let d=0;d<n.length;d++)n[d]=e[t[d]];if(this.outputShape=n,this.rank=n.length,this.rank>6)throw Error( ` Packed transpose for rank $ { this . rank } is not yet supported . ` );let a=yt(this.rank),r=H4("rc",this.rank),s=new Array(this.rank);for(let d=0;d<t.length;d++)s[t[d]]=r[d];let i= ` vec2 ( $ { s . slice ( - 2 ) . join ( ) } ) ` ,o= ` ++ $ { r [ this . rank - 1 ] } < $ { n [ this . rank - 1 ] } ` ,l= ` getChannel ( getA ( $ { s . join ( ) } ) , $ { i } ) ` ;this.userCode= `
2021-09-11 16:29:31 +02:00
void main ( ) {
2021-10-22 22:09:52 +02:00
$ { a } rc = getOutputCoords ( ) ;
2021-09-11 16:29:31 +02:00
vec4 result = vec4 ( 0. ) ;
result [ 0 ] = $ { l } ;
2021-10-22 22:09:52 +02:00
if ( $ { o } ) {
2021-09-11 16:29:31 +02:00
result [ 1 ] = $ { l } ;
}
2021-10-04 23:03:36 +02:00
-- $ { r [ this . rank - 1 ] } ;
if ( ++ $ { r [ this . rank - 2 ] } < $ { n [ this . rank - 2 ] } ) {
2021-09-11 16:29:31 +02:00
result [ 2 ] = $ { l } ;
2021-10-22 22:09:52 +02:00
if ( $ { o } ) {
2021-09-11 16:29:31 +02:00
result [ 3 ] = $ { l } ;
}
}
setOutput ( result ) ;
2021-09-05 22:42:11 +02:00
}
2021-10-22 22:09:52 +02:00
` }};function vf(e,t,n){let a=ne().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new IY(e.shape,t):new wY(e.shape,t);return n.runWebGLProgram(a,[e],e.dtype)}function SY(e,t,n,a){let r=t,s=e.shape.length,i=w.parseAxisParam(r,e.shape),o=i,l=E.getAxesPermutation(o,s),d=l!=null,u=e;d&&(u=vf(e,l,a),o=E.getInnerMostAxes(o.length,s)),E.assertAxesAreInnerMostDims("sum",o,s);let[p,c]=E.computeOutAndReduceShapes(u.shape,o),h=p;n&&(h=E.expandShapeToKeepDim(p,i));let f=w.sizeFromShape(c),m=w.sizeFromShape(e.shape)/f,g=we({inputs:{x:u},attrs:{shape:[m,f]},backend:a}),y=Eh(e.dtype),A=Co(g,y,"sum",a),x=we({inputs:{x:A},attrs:{shape:h},backend:a});return a.disposeIntermediateTensorInfo(g),a.disposeIntermediateTensorInfo(A),d&&a.disposeIntermediateTensorInfo(u),x}function wf(e){let{inputs:t,backend:n,attrs:a}=e,{x:r}=t,{axis:s,keepDims:i}=a;return SY(r,s,i,n)}var NY={kernelName:Li,backendName:"webgl",kernelFunc:wf};function _n(e){let{inputs:t,backend:n,attrs:a}=e,{x:r}=t,{perm:s}=a,i=n,o=r.shape.length,l=new Array(o);for(let u=0;u<l.length;u++)l[u]=r.shape[s[u]];let d;if(i.shouldExecuteOnCPU([r])){let u=i.texData.get(r.dataId).values,p=U2(u,r.shape,r.dtype,s,l);d=i.makeTensorInfo(l,r.dtype);let c=i.texData.get(d.dataId);c.values=p}else d=vf(r,s,i);return d}var TY={kernelName:Gi,backendName:"webgl",kernelFunc:_n},dk=1e3;function kf({a:e,b:t,transposeA:n,transposeB:a,backend:r,bias:s=null,preluActivationWeights:i=null,leakyreluAlpha:o=0,activation:l=null}){let d=e.shape.length,u=t.shape.length,p=n?e.shape[d-2]:e.shape[d-1],c=a?t.shape[u-1]:t.shape[u-2],h=n?e.shape[d-1]:e.shape[d-2],f=a?t.shape[u-2]:t.shape[u-1],m=e.shape.slice(0,-2),g=t.shape.slice(0,-2),y=w.sizeFromShape(m),A=w.sizeFromShape(g),x=y===A||y===1||A===1;w.assert(d>=2&&u>=2&&x,()=> ` Error in matMul : the input batch dimensions must either be the same or at least one input batch dimension must be 1. Got input batch dimensions of ( $ { m } ) and ( $ { g } ) . ` );let b=(y>A?e.shape.slice(0,-2):t.shape.slice(0,-2)).concat([h,f]);w.assert(p===c,()=> ` Error in matMul : inner shapes ( $ { p } ) and ( $ { c } ) of Tensors with shapes $ { e . shape } and $ { t . shape } and transposeA = $ { n } and transposeB = $ { a } must match . ` );let v=n?[y,p,h]:[y,h,p],k=a?[A,f,c]:[A,c,f],T=we({inputs:{x:e},backend:r,attrs:{shape:v}}),C=we({inputs:{x:t},backend:r,attrs:{shape:k}}),D=[T,C],O=Math.max(y,A),F=n?T.shape[1]:T.shape[2],S=s!=null,P=i!=null,_=l==="leakyrelu",j=l!=null?bf(l,!0):null,q=S||P||_||j!=null,z;if((h===1||f===1)&&F>dk&&q===!1){let Z=T,te=C;n&&(Z=_n({inputs:{x:T},backend:r,attrs:{perm:[0,2,1]}}),D.push(Z)),a&&(te=_n({inputs:{x:C},backend:r,attrs:{perm:[0,2,1]}}),D.push(te));let J=f!==1,re=f===1,Y=Z;J&&(Y=we({inputs:{x:Z},backend:r,attrs:{shape:[O,F,1]}}),D.push(Y));let se=f===1?2:1,de=te;re&&(de=we({inputs:{x:te},backend:r,attrs:{shape:[O,1,F]}}),D.push(de));let be=G2({inputs:{a:Y,b:de},backend:r});z=wf({inputs:{x:be},backend:r,attrs:{axis:se,keepDims:!0}}),D.push(be)}else{let Z=Pa(e.dtype,t.dtype),te=new sk(v,k,[O,h,f],n,a,S,j,P,_),J=[T,C];if(s!=null&&J.push(s),P&&J.push(i),_){let re=r.makeTensorInfo([],"float32",w.createScalarValue(o,"float32"));J.push(re),D.push(re)}z=r.runWebGLProgram(te,J,Z)}let X=we({inputs:{x:z},backend:r,attrs:{shape:b}});D.push(z);for(let Z of D)r.disposeIntermediateTensorInfo(Z);return X}function CY(e){let{inputs:t,backend:n,attrs:a}=e,{a:r,b:s,bias:i,preluActivationWeights:o}=t,{transposeA:l,transposeB:d,activation:u,leakyreluAlpha:p}=a;return kf({a:r,b:s,transposeA:l,transposeB:d,backend:n,bias:i,preluActivationWeights:o,leakyreluAlpha:p,activation:u})}var EY={kernelName:Hi,backendName:"webgl",kernelFunc:CY},pk="return abs(x);";function RY(e){let{inputs:t,backend:n}=e,{x:a}=t;if(n.shouldExecuteOnCPU([a])&&a.dtype!=="complex64"){let s=n.texData.get(a.dataId),i=j4(s.values);return n.makeTensorInfo(a.shape,a.dtype,i)}let r;return ne().getBool("WEBGL_PACK_UNARY_OPERATIONS")?r=new _u(a.shape,pk):r=new Fs(a.shape,pk),n.runWebGLProgram(r,[a],a.dtype)}var MY={kernelName:Ko,backendName:"webgl",kernelFunc:RY},FY=lr+ `
2021-09-11 16:29:31 +02:00
if ( abs ( x ) > 1. ) {
return NAN ;
2021-09-05 22:42:11 +02:00
}
2021-09-11 16:29:31 +02:00
return acos ( x ) ;
2021-10-22 22:09:52 +02:00
` ,DY=nt({opSnippet:FY}), $ Y={kernelName:Zo,backendName:"webgl",kernelFunc:DY},OY=lr+ `
2021-09-11 16:29:31 +02:00
if ( x < 1.0 ) return NAN ;
2021-10-22 22:09:52 +02:00
return log ( x + sqrt ( x * x - 1.0 ) ) ; ` ,_Y=nt({opSnippet:OY}),PY={kernelName:Yo,backendName:"webgl",kernelFunc:_Y},ck="return a + b;",zY=vn({opSnippet:ck,packedOpSnippet:ck,supportsComplex:!0,cpuKernelImpl:qK}),LY={kernelName:ls,backendName:"webgl",kernelFunc:zY},WY=class{constructor(e,t){this.outputShape=[],this.outputShape=e,this.variableNames=t.map((r,s)=> ` T$ { s } ` );let n=[];this.variableNames.forEach(r=>{n.push( ` float v$ { r } = get$ { r } AtOutCoords ( ) ; ` )});let a=this.variableNames.map(r=> ` v$ { r } ` ).join(" + ");this.userCode= `
2021-09-11 16:29:31 +02:00
void main ( ) {
$ { n . join ( `
` )}
2021-09-01 00:24:30 +02:00
2021-10-22 22:09:52 +02:00
float result = $ { a } ;
2021-09-11 16:29:31 +02:00
setOutput ( result ) ;
2021-09-01 00:24:30 +02:00
}
2021-10-22 22:09:52 +02:00
` }},BY=class{constructor(e,t){this.outputShape=[],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=e,this.variableNames=t.map((r,s)=> ` T$ { s } ` );let n=[];this.variableNames.forEach(r=>{n.push( ` vec4 v$ { r } = get$ { r } AtOutCoords ( ) ; ` )});let a=this.variableNames.map(r=> ` v$ { r } ` ).join(" + ");this.userCode= `
2021-09-05 22:42:11 +02:00
void main ( ) {
2021-09-11 16:29:31 +02:00
$ { n . join ( `
` )}
2021-10-22 22:09:52 +02:00
vec4 result = $ { a } ;
2021-09-11 16:29:31 +02:00
setOutput ( result ) ;
2021-09-05 22:42:11 +02:00
}
2021-10-22 22:09:52 +02:00
` }};function If(e){let{inputs:t,backend:n}=e,a=t;if(a.length===1)return ma({inputs:{x:a[0]},backend:n});if(a.length>ne().get("WEBGL_MAX_TEXTURES_IN_SHADER")){let o=Math.floor(a.length/2),l=If({inputs:a.slice(0,o),backend:n}),d=If({inputs:a.slice(o),backend:n});return If({inputs:[l,d],backend:n})}let r=a.map(o=>o.dtype).reduce((o,l)=>Pa(o,l)),s=a.map(o=>o.shape),i=ne().getBool("WEBGL_PACK")?new BY(a[0].shape,s):new WY(a[0].shape,s);return n.runWebGLProgram(i,a,r)}var VY={kernelName:Zs,backendName:"webgl",kernelFunc:If};function UY(e){let{inputs:t,backend:n,attrs:a}=e,{x:r}=t,{axis:s,keepDims:i}=a,o=r.shape.length,l=w.parseAxisParam(s,r.shape),d=l,u=E.getAxesPermutation(d,o),p=r;u!=null&&(p=_n({inputs:{x:r},backend:n,attrs:{perm:u}}),d=E.getInnerMostAxes(d.length,o)),E.assertAxesAreInnerMostDims("all",d,o);let[c,h]=E.computeOutAndReduceShapes(p.shape,d),f=w.sizeFromShape(h),m=we({inputs:{x:p},backend:n,attrs:{shape:[-1,f]}}),g=Co(m,m.dtype,"all",n),y;if(i){let A=E.expandShapeToKeepDim(c,l);y=we({inputs:{x:g},backend:n,attrs:{shape:A}})}else y=we({inputs:{x:g},backend:n,attrs:{shape:c}});return n.disposeIntermediateTensorInfo(m),n.disposeIntermediateTensorInfo(g),u!=null&&n.disposeIntermediateTensorInfo(p),y}var jY={kernelName:Jo,backendName:"webgl",kernelFunc:UY};function GY(e){let{inputs:t,backend:n,attrs:a}=e,{x:r}=t,{axis:s,keepDims:i}=a,o=r.shape.length,l=w.parseAxisParam(s,r.shape),d=l,u=E.getAxesPermutation(d,o),p=r;u!=null&&(p=_n({inputs:{x:r},backend:n,attrs:{perm:u}}),d=E.getInnerMostAxes(d.length,o)),E.assertAxesAreInnerMostDims("any",d,o);let[c,h]=E.computeOutAndReduceShapes(p.shape,d),f=w.sizeFromShape(h),m=we({inputs:{x:p},backend:n,attrs:{shape:[-1,f]}}),g=Co(m,m.dtype,"any",n),y;if(i){let A=E.expandShapeToKeepDim(c,l);y=we({inputs:{x:g},backend:n,attrs:{shape:A}})}else y=we({inputs:{x:g},backend:n,attrs:{shape:c}});return n.disposeIntermediateTensorInfo(m),n.disposeIntermediateTensorInfo(g),u!=null&&n.disposeIntermediateTensorInfo(p),y}var HY={kernelName:Qo,backendName:"webgl",kernelFunc:GY},qY=class{constructor(e,t,n){this.variableNames=["A"];let{windowSize:a,batchSize:r,outSize:s}=e;n||this.variableNames.push("bestIndicesA"),this.outputShape=[r,s];let i=t==="max"?">":"<",o=n?"inOffset + i;":"round(getBestIndicesA(batch, inOffset + i));";this.userCode= `
2021-09-11 16:29:31 +02:00
void main ( ) {
ivec2 coords = getOutputCoords ( ) ;
int batch = coords [ 0 ] ;
int outIdx = coords [ 1 ] ;
2021-10-22 22:09:52 +02:00
int inOffset = outIdx * $ { a } ;
2021-09-11 16:29:31 +02:00
int bestIndex = inOffset ;
float bestValue = getA ( batch , bestIndex ) ;
2021-10-22 22:09:52 +02:00
for ( int i = 0 ; i < $ { a } ; i ++ ) {
int inIdx = $ { o } ;
2021-09-11 16:29:31 +02:00
float candidate = getA ( batch , inIdx ) ;
2021-10-22 22:09:52 +02:00
if ( candidate $ { i } bestValue ) {
2021-09-11 16:29:31 +02:00
bestValue = candidate ;
bestIndex = inIdx ;
}
2021-09-05 22:42:11 +02:00
}
2021-09-11 16:29:31 +02:00
setOutput ( float ( bestIndex ) ) ;
2021-09-05 22:42:11 +02:00
}
2021-10-22 22:09:52 +02:00
` }},XY=class{constructor(e,t,n,a){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,w.assert(e.length>2,()=> ` Packed arg$ { n . charAt ( 0 ) . toUpperCase ( ) + n . slice ( 1 ) } supports only inputs with rank above 2. ` );let r=e[e.length-1],s=Math.ceil(r/t);this.outputShape=e.slice(0,-1),s>1&&this.outputShape.push(s),a||this.variableNames.push("bestIndicesA");let i=this.outputShape,o=i.length,l=yt(o),d=On("coords",o),u,p;if(s===1){p=o+1;let T=yt(p);u= `
$ { T } sourceLocR = $ { T } ( $ { d . join ( ) } , 0 ) ;
++ $ { d [ o - 1 ] } ;
$ { T } sourceLocG = $ { T } ( $ { d . join ( ) } , 0 ) ;
++ $ { d [ o - 2 ] } ;
$ { T } sourceLocA = $ { T } ( $ { d . join ( ) } , 0 ) ;
-- $ { d [ o - 1 ] } ;
$ { T } sourceLocB = $ { T } ( $ { d . join ( ) } , 0 ) ;
-- $ { d [ o - 2 ] } ; ` }else p=o,u= `
2021-09-11 16:29:31 +02:00
$ { l } sourceLocR = coords ;
2021-10-22 22:09:52 +02:00
++ $ { d [ o - 1 ] } ;
2021-09-11 16:29:31 +02:00
$ { l } sourceLocG = coords ;
2021-10-22 22:09:52 +02:00
++ $ { d [ o - 2 ] } ;
2021-09-11 16:29:31 +02:00
$ { l } sourceLocA = coords ;
2021-10-22 22:09:52 +02:00
-- $ { d [ o - 1 ] } ;
2021-09-11 16:29:31 +02:00
$ { l } sourceLocB = coords ;
2021-10-22 22:09:52 +02:00
-- $ { d [ o - 2 ] } ; ` ;let c=["x","y","z","w","u","v"].slice(0,p),h="."+c[p-1],f=c.map(T=>"int "+T),m=On("sourceLocR",p-1).concat("inIdx.r"),g=On("sourceLocG",p-1).concat("inIdx.g"),y=On("sourceLocB",p-1).concat("inIdx.b"),A=On("sourceLocA",p-1).concat("inIdx.a"),x=n==="max"?"greaterThan":"lessThan",b=a?"": `
2021-10-07 16:33:10 +02:00
inIdx = round ( vec4 ( getBestIndicesAChannel ( $ { m . join ( ) } ) ,
2021-09-11 16:29:31 +02:00
getBestIndicesAChannel ( $ { g . join ( ) } ) ,
2021-10-22 22:09:52 +02:00
getBestIndicesAChannel ( $ { y . join ( ) } ) ,
getBestIndicesAChannel ( $ { A . join ( ) } ) ) ) ; ` ,v= ` vec4 (
2021-10-07 16:33:10 +02:00
getAChannel ( $ { m . join ( ) } ) ,
2021-09-11 16:29:31 +02:00
hasNextCol ? getAChannel ( $ { g . join ( ) } ) : 0. ,
2021-10-22 22:09:52 +02:00
hasNextRow ? getAChannel ( $ { y . join ( ) } ) : 0. ,
hasNextRow && hasNextCol ? getAChannel ( $ { A . join ( ) } ) : 0. ) ` ,k=a?"": `
2021-10-07 16:33:10 +02:00
float getBestIndicesAChannel ( $ { f . join ( ) } ) {
2021-10-22 22:09:52 +02:00
return getChannel ( getBestIndicesA ( $ { c . join ( ) } ) ,
vec2 ( $ { c . slice ( - 2 ) . join ( ) } ) ) ;
2021-09-11 16:29:31 +02:00
} ` ;this.userCode= `
2021-10-07 16:33:10 +02:00
float getAChannel ( $ { f . join ( ) } ) {
2021-10-22 22:09:52 +02:00
return getChannel ( getA ( $ { c . join ( ) } ) ,
vec2 ( $ { c . slice ( - 2 ) . join ( ) } ) ) ;
2021-09-11 16:29:31 +02:00
}
2021-10-22 22:09:52 +02:00
$ { k }
2021-09-05 22:42:11 +02:00
void main ( ) {
2021-09-11 16:29:31 +02:00
$ { l } coords = getOutputCoords ( ) ;
2021-10-22 22:09:52 +02:00
bool hasNextCol = $ { d [ o - 1 ] } < $ { i [ o - 1 ] - 1 } ;
bool hasNextRow = $ { d [ o - 2 ] } < $ { i [ o - 2 ] - 1 } ;
2021-10-07 16:33:10 +02:00
$ { u }
2021-10-04 23:03:36 +02:00
ivec4 srcIdx = ivec4 ( sourceLocR$ { h } , sourceLocG$ { h } ,
sourceLocB$ { h } , sourceLocA$ { h } ) * $ { t } ;
2021-09-11 16:29:31 +02:00
ivec4 inIdx = srcIdx ;
vec4 bestIndex = vec4 ( inIdx ) ;
2021-10-22 19:49:40 +02:00
vec4 bestValue = $ { v } ;
2021-09-11 16:29:31 +02:00
for ( int i = 0 ; i < $ { t } ; i ++ ) {
inIdx = srcIdx ;
2021-10-04 23:03:36 +02:00
$ { b }
2021-10-22 19:49:40 +02:00
vec4 candidate = $ { v } ;
2021-09-11 16:29:31 +02:00
bvec4 nan = isnan ( candidate ) ;
bvec4 replace = bvec4 (
2021-10-04 23:03:36 +02:00
vec4 ( $ { x } ( candidate , bestValue ) ) * ( vec4 ( 1.0 ) - vec4 ( nan ) ) ) ;
2021-09-11 16:29:31 +02:00
bestValue = vec4 ( replace . x ? candidate . x : bestValue . x ,
replace . y ? candidate . y : bestValue . y ,
replace . z ? candidate . z : bestValue . z ,
replace . w ? candidate . w : bestValue . w ) ;
bestIndex = mix ( bestIndex , vec4 ( inIdx ) , vec4 ( replace ) ) ;
srcIdx ++ ;
}
setOutput ( bestIndex ) ;
2021-09-05 22:42:11 +02:00
}
2021-10-22 22:09:52 +02:00
` }};function hk(e,t,n,a=null){let r=t.shape[0],s=t.shape[1];a!=null&&(r=a.shape[0],s=a.shape[1]);let i=E.computeOptimalWindowSize(s),o={windowSize:i,inSize:s,batchSize:r,outSize:Math.ceil(s/i)},l=new qY(o,n,a==null),d=[t];a!=null&&d.push(a);let u=e.runWebGLProgram(l,d,"int32");if(u.shape[1]===1)return u;let p=hk(e,t,n,u);return e.disposeIntermediateTensorInfo(u),p}function fk(e,t,n,a=null){let r=a!=null?a.shape:t.shape,s=r[r.length-1],i=E.computeOptimalWindowSize(s),o=new XY(r,i,n,a==null),l=a==null?[t]:[t,a],d=e.runWebGLProgram(o,l,"int32");if(d.shape.length===t.shape.length){let u=fk(e,t,n,d);return e.disposeIntermediateTensorInfo(d),u}return d}function mk(e,t,n,a){let r=[n];if(E.assertAxesAreInnerMostDims("arg"+a.charAt(0).toUpperCase()+a.slice(1),r,t.shape.length),!ne().getBool("WEBGL_PACK_REDUCE")||t.shape.length<=2){let s=[],i=e.texData.get(t.dataId),o=i!==null&&i.isPacked,l=t;o&&(l=e.unpackTensor(t),s.push(l));let[d,u]=E.computeOutAndReduceShapes(l.shape,r),p=w.sizeFromShape(u),c=we({inputs:{x:l},backend:e,attrs:{shape:[-1,p]}});s.push(c);let h=hk(e,c,a);s.push(h);let f=we({inputs:{x:h},backend:e,attrs:{shape:d}});return s.forEach(m=>e.disposeIntermediateTensorInfo(m)),f}return fk(e,t,a)}function KY(e){let{inputs:t,backend:n,attrs:a}=e,{x:r}=t,{axis:s}=a,i=w.parseAxisParam(s,r.shape),o=E.getAxesPermutation(i,r.shape.length),l=r,d=[];o!=null&&(l=_n({inputs:{x:r},backend:n,attrs:{perm:o}}),d.push(l),i=E.getInnerMostAxes(i.length,l.shape.length)),E.assertAxesAreInnerMostDims("argMax",[i[0]],l.shape.length);let u=mk(n,l,i[0],"max");return d.forEach(p=>n.disposeIntermediateTensorInfo(p)),u}var ZY={kernelName:Ys,backendName:"webgl",kernelFunc:KY};function YY(e){let{inputs:t,backend:n,attrs:a}=e,{x:r}=t,{axis:s}=a,i=w.parseAxisParam(s,r.shape),o=E.getAxesPermutation(i,r.shape.length),l=r,d=[];o!=null&&(l=_n({inputs:{x:r},backend:n,attrs:{perm:o}}),d.push(l),i=E.getInnerMostAxes(i.length,l.shape.length)),E.assertAxesAreInnerMostDims("argMin",[i[0]],l.shape.length);let u=mk(n,l,i[0],"min");return d.forEach(p=>n.disposeIntermediateTensorInfo(p)),u}var JY={kernelName:yd,backendName:"webgl",kernelFunc:YY},QY=lr+ `
2021-09-11 16:29:31 +02:00
if ( abs ( x ) > 1. ) {
2021-09-05 22:42:11 +02:00
return NAN ;
}
2021-09-11 16:29:31 +02:00
return asin ( x ) ;
2021-10-22 22:09:52 +02:00
` ,eJ=nt({opSnippet:QY}),tJ={kernelName:el,backendName:"webgl",kernelFunc:eJ},nJ=lr+"return log(x + sqrt(x * x + 1.0));",aJ=nt({opSnippet:nJ}),rJ={kernelName:tl,backendName:"webgl",kernelFunc:aJ},sJ=lr+ `
2021-09-11 16:29:31 +02:00
return atan ( x ) ;
2021-10-22 22:09:52 +02:00
` ,iJ=nt({opSnippet:sJ}),oJ={kernelName:nl,backendName:"webgl",kernelFunc:iJ},lJ=mY+ `
2021-09-11 16:29:31 +02:00
return atan ( a , b ) ;
2021-10-22 22:09:52 +02:00
` ,uJ= `
2021-09-11 16:29:31 +02:00
vec4 result = atan ( a , b ) ;
vec4 isNaN = min ( vec4 ( isnan ( a ) ) + vec4 ( isnan ( b ) ) , vec4 ( 1.0 ) ) ;
2021-10-22 22:09:52 +02:00
` +gY+ `
2021-09-11 16:29:31 +02:00
return result ;
2021-10-22 22:09:52 +02:00
` ,dJ=vn({opSnippet:lJ,packedOpSnippet:uJ}),pJ={kernelName:rl,backendName:"webgl",kernelFunc:dJ},cJ=lr+ `
2021-09-11 16:29:31 +02:00
if ( ( x < - 1.0 ) || ( x > 1.0 ) ) return NAN ;
2021-10-22 22:09:52 +02:00
return ( log ( 1.0 + x ) - log ( 1.0 - x ) ) / 2.0 ; ` ,hJ=nt({opSnippet:cJ}),fJ={kernelName:al,backendName:"webgl",kernelFunc:hJ},Wp=class{constructor(e,t,n,a=!1,r=!1){if(this.variableNames=["x"],t==="avg"&&n)throw new Error("Cannot compute positions for average pool.");let s=e.filterWidth,i=e.strideHeight,o=e.strideWidth,l=e.dilationHeight,d=e.dilationWidth,u=e.effectiveFilterHeight,p=e.effectiveFilterWidth,c=e.padInfo.top,h=e.padInfo.left;this.outputShape=e.outShape;let f=t==="avg",m= ` ( ( batch * $ { e . inHeight } + xR ) * $ { e . inWidth } + xC ) * $ { e . inChannels } + d ` ,g= ` ( xR * $ { e . inWidth } + xC ) * $ { e . inChannels } + d ` ,y="0.0";if(f||(y="-1.0 / 1e-20"),n){let T=">=";this.userCode= `
const ivec2 strides = ivec2 ( $ { i } , $ { o } ) ;
const ivec2 pads = ivec2 ( $ { c } , $ { h } ) ;
2021-09-01 00:24:30 +02:00
2021-09-11 16:29:31 +02:00
void main ( ) {
ivec4 coords = getOutputCoords ( ) ;
int batch = coords [ 0 ] ;
int d = coords [ 3 ] ;
2021-08-14 17:17:51 +02:00
2021-09-11 16:29:31 +02:00
ivec2 xRCCorner = coords . yz * strides - pads ;
int xRCorner = xRCCorner . x ;
int xCCorner = xRCCorner . y ;
2021-08-14 17:17:51 +02:00
2021-09-11 16:29:31 +02:00
// max/min x(?, ?, d) to get y(yR, yC, d).
// ? = to be determined
float minMaxValue = 0.0 ;
float minMaxValueFound = 0.0 ;
int minMaxPosition = 0 ;
float avgValue = 0.0 ;
2021-09-01 00:24:30 +02:00
2021-10-07 16:33:10 +02:00
for ( int wR = 0 ; wR < $ { u } ;
2021-09-11 16:29:31 +02:00
wR += $ { l } ) {
int xR = xRCorner + wR ;
2021-09-01 00:24:30 +02:00
2021-09-11 16:29:31 +02:00
if ( xR < 0 || xR >= $ { e . inHeight } ) {
continue ;
}
2021-09-01 00:24:30 +02:00
2021-10-22 22:09:52 +02:00
for ( int wC = 0 ; wC < $ { p } ;
wC += $ { d } ) {
2021-09-11 16:29:31 +02:00
int xC = xCCorner + wC ;
if ( xC < 0 || xC >= $ { e . inWidth } ) {
continue ;
}
float value = getX ( batch , xR , xC , d ) ;
// If a min / max value has already been found, use it. If not,
// use the current value.
float currMinMaxValue = mix (
value , minMaxValue , minMaxValueFound ) ;
2021-10-22 22:09:52 +02:00
if ( value $ { T } currMinMaxValue ) {
2021-09-11 16:29:31 +02:00
minMaxValue = value ;
minMaxValueFound = 1.0 ;
2021-10-22 22:09:52 +02:00
minMaxPosition = $ { a ? r ? m : g : ` wR * ${ p } + wC ` } ;
2021-09-11 16:29:31 +02:00
}
}
}
setOutput ( float ( minMaxPosition ) ) ;
}
2021-10-22 22:09:52 +02:00
` ;return}let A="max",x= ` $ { t } ( $ { t } ( $ { t } ( minMaxValue [ 0 ] , minMaxValue [ 1 ] ) , minMaxValue [ 2 ] ) , minMaxValue [ 3 ] ) ` ;t==="avg"&&(x="avgValue / count");let b=Math.floor(s/4)*4,v=s%4,k= `
2021-10-07 16:33:10 +02:00
if ( $ { f } ) {
2021-09-11 16:29:31 +02:00
avgValue += dot ( values , ones ) ;
2021-09-05 22:42:11 +02:00
} else {
2021-10-22 22:09:52 +02:00
minMaxValue = $ { A } ( values , minMaxValue ) ;
2021-09-11 16:29:31 +02:00
}
` ;this.userCode= `
2021-10-22 22:09:52 +02:00
const ivec2 strides = ivec2 ( $ { i } , $ { o } ) ;
const ivec2 pads = ivec2 ( $ { c } , $ { h } ) ;
const float initializationValue = $ { y } ;
2021-09-11 16:29:31 +02:00
const vec4 ones = vec4 ( 1.0 , 1.0 , 1.0 , 1.0 ) ;
float count = 0.0 ;
float getValue ( int batch , int xR , int xC , int d ) {
if ( xC < 0 || xC >= $ { e . inWidth } ) {
return initializationValue ;
}
count += 1.0 ;
return getX ( batch , xR , xC , d ) ;
2021-08-14 17:16:26 +02:00
}
2021-09-01 00:24:30 +02:00
void main ( ) {
2021-09-05 22:42:11 +02:00
ivec4 coords = getOutputCoords ( ) ;
2021-09-11 16:29:31 +02:00
int batch = coords [ 0 ] ;
2021-09-05 22:42:11 +02:00
int d = coords [ 3 ] ;
2021-09-01 00:24:30 +02:00
2021-09-11 16:29:31 +02:00
ivec2 xRCCorner = coords . yz * strides - pads ;
int xRCorner = xRCCorner . x ;
int xCCorner = xRCCorner . y ;
2021-09-01 00:24:30 +02:00
2021-09-11 16:29:31 +02:00
// max/min x(?, ?, d) to get y(yR, yC, d).
// ? = to be determined
2021-10-22 22:09:52 +02:00
vec4 minMaxValue = vec4 ( $ { y } ) ;
2021-09-11 16:29:31 +02:00
float avgValue = 0.0 ;
count = 0.0 ;
2021-09-01 00:24:30 +02:00
2021-10-07 16:33:10 +02:00
for ( int wR = 0 ; wR < $ { u } ;
2021-09-11 16:29:31 +02:00
wR += $ { l } ) {
int xR = xRCorner + wR ;
2021-09-01 00:24:30 +02:00
2021-09-11 16:29:31 +02:00
if ( xR < 0 || xR >= $ { e . inHeight } ) {
continue ;
}
2021-09-01 00:24:30 +02:00
2021-10-04 23:03:36 +02:00
for ( int wC = 0 ; wC < $ { b } ; wC += 4 ) {
2021-10-22 22:09:52 +02:00
int xC = xCCorner + wC * $ { d } ;
2021-09-01 00:24:30 +02:00
2021-09-11 16:29:31 +02:00
vec4 values = vec4 (
getValue ( batch , xR , xC , d ) ,
2021-10-22 22:09:52 +02:00
getValue ( batch , xR , xC + $ { d } , d ) ,
getValue ( batch , xR , xC + 2 * $ { d } , d ) ,
getValue ( batch , xR , xC + 3 * $ { d } , d )
2021-09-11 16:29:31 +02:00
) ;
2021-10-22 22:09:52 +02:00
$ { k }
2021-09-11 16:29:31 +02:00
}
2021-10-04 23:03:36 +02:00
int xC = xCCorner + $ { b } ;
2021-10-22 19:49:40 +02:00
if ( $ { v === 1 } ) {
2021-09-11 16:29:31 +02:00
vec4 values = vec4 (
getValue ( batch , xR , xC , d ) ,
initializationValue ,
initializationValue ,
initializationValue
) ;
2021-10-22 22:09:52 +02:00
$ { k }
2021-10-22 19:49:40 +02:00
} else if ( $ { v === 2 } ) {
2021-09-11 16:29:31 +02:00
vec4 values = vec4 (
getValue ( batch , xR , xC , d ) ,
2021-10-22 22:09:52 +02:00
getValue ( batch , xR , xC + $ { d } , d ) ,
2021-09-11 16:29:31 +02:00
initializationValue ,
initializationValue
) ;
2021-10-22 22:09:52 +02:00
$ { k }
2021-10-22 19:49:40 +02:00
} else if ( $ { v === 3 } ) {
2021-09-11 16:29:31 +02:00
vec4 values = vec4 (
getValue ( batch , xR , xC , d ) ,
2021-10-22 22:09:52 +02:00
getValue ( batch , xR , xC + $ { d } , d ) ,
getValue ( batch , xR , xC + 2 * $ { d } , d ) ,
2021-09-11 16:29:31 +02:00
initializationValue
) ;
2021-10-22 22:09:52 +02:00
$ { k }
2021-09-11 16:29:31 +02:00
}
}
2021-10-04 23:03:36 +02:00
setOutput ( $ { x } ) ;
2021-09-05 22:42:11 +02:00
}
2021-10-22 22:09:52 +02:00
` }},H2=class{constructor(e,t,n,a=!1,r=!1){if(this.variableNames=["x"],t==="avg"&&n)throw new Error("Cannot compute positions for average pool.");let s=e.filterWidth,i=e.strideDepth,o=e.strideHeight,l=e.strideWidth,d=e.dilationDepth,u=e.dilationHeight,p=e.dilationWidth,c=e.effectiveFilterDepth,h=e.effectiveFilterHeight,f=e.effectiveFilterWidth,m=e.padInfo.front,g=e.padInfo.top,y=e.padInfo.left;this.outputShape=e.outShape;let A=t==="avg",x="0.0";if(A||(x="-1.0 / 1e-20"),n){let D=">=";this.userCode= `
2021-09-11 16:29:31 +02:00
const ivec3 strides =
2021-10-22 22:09:52 +02:00
ivec3 ( $ { i } , $ { o } , $ { l } ) ;
const ivec3 pads = ivec3 ( $ { m } , $ { g } , $ { y } ) ;
2021-09-11 16:29:31 +02:00
void main ( ) {
ivec5 coords = getOutputCoords ( ) ;
int batch = coords . x ;
int ch = coords . u ;
ivec3 xCorner = ivec3 ( coords . y , coords . z , coords . w ) * strides - pads ;
int xDCorner = xCorner . x ;
int xRCorner = xCorner . y ;
int xCCorner = xCorner . z ;
// max/min x(?, ?, ?, ch) to get y(yD, yR, yC, ch).
// ? = to be determined
float minMaxValue = 0.0 ;
float minMaxValueFound = 0.0 ;
int minMaxPosition = 0 ;
2021-10-22 22:09:52 +02:00
for ( int wD = 0 ; wD < $ { c } ;
wD += $ { d } ) {
2021-09-11 16:29:31 +02:00
int xD = xDCorner + wD ;
if ( xD < 0 || xD >= $ { e . inDepth } ) {
continue ;
}
2021-10-04 23:03:36 +02:00
for ( int wR = 0 ; wR < $ { h } ;
2021-10-07 16:33:10 +02:00
wR += $ { u } ) {
2021-09-11 16:29:31 +02:00
int xR = xRCorner + wR ;
if ( xR < 0 || xR >= $ { e . inHeight } ) {
continue ;
}
2021-10-07 16:33:10 +02:00
for ( int wC = 0 ; wC < $ { f } ;
2021-10-22 22:09:52 +02:00
wC += $ { p } ) {
2021-09-11 16:29:31 +02:00
int xC = xCCorner + wC ;
if ( xC < 0 || xC >= $ { e . inWidth } ) {
continue ;
}
float value = getX ( batch , xD , xR , xC , ch ) ;
// If a min / max value has already been found, use it. If not,
// use the current value.
float currMinMaxValue = mix (
value , minMaxValue , minMaxValueFound ) ;
2021-10-22 22:09:52 +02:00
if ( value $ { D } currMinMaxValue ) {
2021-09-11 16:29:31 +02:00
minMaxValue = value ;
minMaxValueFound = 1.0 ;
2021-10-22 22:09:52 +02:00
minMaxPosition = $ { a ? r ? ` (((batch * ${ e . inDepth } + xD) * ${ e . inHeight } + xR) * ${ e . inWidth } + xC) * ${ e . inChannels } + ch ` : ` ((xD * ${ e . inHeight } + xR) * ${ e . inWidth } + xC) * ${ e . inChannels } + ch ` : ` wD * ${ h } * ${ f } +
2021-10-07 16:33:10 +02:00
wR * $ { f } + wC ` };
2021-09-11 16:29:31 +02:00
}
}
}
}
setOutput ( float ( minMaxPosition ) ) ;
}
2021-10-22 22:09:52 +02:00
` ;return}let b="max",v= ` $ { t } ( $ { t } ( $ { t } ( minMaxValue [ 0 ] , minMaxValue [ 1 ] ) , minMaxValue [ 2 ] ) , minMaxValue [ 3 ] ) ` ;t==="avg"&&(v="avgValue / count");let k=Math.floor(s/4)*4,T=s%4,C= `
if ( $ { A } ) {
2021-09-11 16:29:31 +02:00
avgValue += dot ( values , ones ) ;
2021-09-05 22:42:11 +02:00
} else {
2021-10-04 23:03:36 +02:00
minMaxValue = $ { b } ( values , minMaxValue ) ;
2021-09-05 22:42:11 +02:00
}
2021-09-11 16:29:31 +02:00
` ;this.userCode= `
const ivec3 strides =
2021-10-22 22:09:52 +02:00
ivec3 ( $ { i } , $ { o } , $ { l } ) ;
const ivec3 pads = ivec3 ( $ { m } , $ { g } , $ { y } ) ;
2021-10-04 23:03:36 +02:00
const float initializationValue = $ { x } ;
2021-09-11 16:29:31 +02:00
const vec4 ones = vec4 ( 1.0 , 1.0 , 1.0 , 1.0 ) ;
2021-09-01 00:24:30 +02:00
2021-09-11 16:29:31 +02:00
float count = 0.0 ;
float getValue ( int batch , int xD , int xR , int xC , int ch ) {
if ( xC < 0 || xC >= $ { e . inWidth } ) {
return initializationValue ;
}
count += 1.0 ;
return getX ( batch , xD , xR , xC , ch ) ;
2021-09-01 00:22:16 +02:00
}
2021-09-05 22:42:11 +02:00
2021-09-01 00:24:30 +02:00
void main ( ) {
2021-09-11 16:29:31 +02:00
ivec5 coords = getOutputCoords ( ) ;
int batch = coords . x ;
int ch = coords . u ;
2021-08-14 17:17:51 +02:00
2021-09-11 16:29:31 +02:00
ivec3 xCorner = ivec3 ( coords . y , coords . z , coords . w ) * strides - pads ;
int xDCorner = xCorner . x ;
int xRCorner = xCorner . y ;
int xCCorner = xCorner . z ;
2021-08-14 17:17:51 +02:00
2021-09-11 16:29:31 +02:00
// max/min x(?, ?, ?, d) to get y(yD, yR, yC, ch).
// ? = to be determined
2021-10-04 23:03:36 +02:00
vec4 minMaxValue = vec4 ( $ { x } ) ;
2021-09-11 16:29:31 +02:00
float avgValue = 0.0 ;
count = 0.0 ;
2021-09-01 00:24:30 +02:00
2021-10-22 22:09:52 +02:00
for ( int wD = 0 ; wD < $ { c } ;
wD += $ { d } ) {
2021-09-11 16:29:31 +02:00
int xD = xDCorner + wD ;
2021-09-01 00:24:30 +02:00
2021-09-11 16:29:31 +02:00
if ( xD < 0 || xD >= $ { e . inDepth } ) {
continue ;
}
2021-09-01 00:24:30 +02:00
2021-10-04 23:03:36 +02:00
for ( int wR = 0 ; wR < $ { h } ;
2021-10-07 16:33:10 +02:00
wR += $ { u } ) {
2021-09-11 16:29:31 +02:00
int xR = xRCorner + wR ;
2021-09-01 00:24:30 +02:00
2021-09-11 16:29:31 +02:00
if ( xR < 0 || xR >= $ { e . inHeight } ) {
continue ;
}
2021-09-01 00:24:30 +02:00
2021-10-22 22:09:52 +02:00
for ( int wC = 0 ; wC < $ { k } ; wC += 4 ) {
int xC = xCCorner + wC * $ { p } ;
2021-09-01 00:24:30 +02:00
2021-09-11 16:29:31 +02:00
vec4 values = vec4 (
getValue ( batch , xD , xR , xC , ch ) ,
2021-10-22 22:09:52 +02:00
getValue ( batch , xD , xR , xC + $ { p } , ch ) ,
getValue ( batch , xD , xR , xC + 2 * $ { p } , ch ) ,
getValue ( batch , xD , xR , xC + 3 * $ { p } , ch )
2021-09-11 16:29:31 +02:00
) ;
2021-09-01 00:24:30 +02:00
2021-10-22 22:09:52 +02:00
$ { C }
2021-09-11 16:29:31 +02:00
}
2021-09-01 00:24:30 +02:00
2021-10-22 22:09:52 +02:00
int xC = xCCorner + $ { k } ;
if ( $ { T === 1 } ) {
2021-09-11 16:29:31 +02:00
vec4 values = vec4 (
getValue ( batch , xD , xR , xC , ch ) ,
initializationValue ,
initializationValue ,
initializationValue
) ;
2021-10-22 22:09:52 +02:00
$ { C }
} else if ( $ { T === 2 } ) {
2021-09-11 16:29:31 +02:00
vec4 values = vec4 (
getValue ( batch , xD , xR , xC , ch ) ,
2021-10-22 22:09:52 +02:00
getValue ( batch , xD , xR , xC + $ { p } , ch ) ,
2021-09-11 16:29:31 +02:00
initializationValue ,
initializationValue
) ;
2021-10-22 22:09:52 +02:00
$ { C }
} else if ( $ { T === 3 } ) {
2021-09-11 16:29:31 +02:00
vec4 values = vec4 (
getValue ( batch , xD , xR , xC , ch ) ,
2021-10-22 22:09:52 +02:00
getValue ( batch , xD , xR , xC + $ { p } , ch ) ,
getValue ( batch , xD , xR , xC + 2 * $ { p } , ch ) ,
2021-09-11 16:29:31 +02:00
initializationValue
) ;
2021-10-22 22:09:52 +02:00
$ { C }
2021-09-11 16:29:31 +02:00
}
}
2021-10-22 19:49:40 +02:00
setOutput ( $ { v } ) ;
2021-09-11 16:29:31 +02:00
}
2021-09-05 22:42:11 +02:00
}
2021-10-22 22:09:52 +02:00
` }};function mJ(e){let{inputs:t,backend:n,attrs:a}=e,{x:r}=t;Mu(r,"avgPool");let{filterSize:s,strides:i,pad:o,dimRoundingMode:l}=a,d=1;w.assert(E.eitherStridesOrDilationsAreOne(i,d),()=> ` Error in avgPool : Either strides or dilations must be 1. Got strides $ { i } and dilations '${d}' ` );let u=E.computePool2DInfo(r.shape,s,i,d,o,l);if(u.filterWidth===1&&u.filterHeight===1&&w.arraysEqual(u.inShape,u.outShape))return ma({inputs:{x:r},backend:n});let p=new Wp(u,"avg",!1);return n.runWebGLProgram(p,[r],"float32")}var gJ={kernelName:Js,backendName:"webgl",kernelFunc:mJ};function yJ(e){let{inputs:t,backend:n,attrs:a}=e,{x:r}=t,{filterSize:s,strides:i,pad:o,dimRoundingMode:l,dataFormat:d}=a,u=[1,1,1],p=E.computePool3DInfo(r.shape,s,i,u,o,l,d),c=new H2(p,"avg",!1);return n.runWebGLProgram(c,[r],"float32")}var AJ={kernelName:Ad,backendName:"webgl",kernelFunc:yJ},xJ=class{constructor(e){this.variableNames=["dy"],this.outputShape=e.inShape;let t=e.filterHeight,n=e.filterWidth,a=e.strideHeight,r=e.strideWidth,s=e.dilationHeight,i=e.dilationWidth,o=e.effectiveFilterHeight,l=e.effectiveFilterWidth,d=o-1-e.padInfo.top,u=l-1-e.padInfo.left,p=1/(t*n);this.userCode= `
const ivec2 pads = ivec2 ( $ { d } , $ { u } ) ;
const float avgMultiplier = float ( $ { p } ) ;
2021-09-11 16:29:31 +02:00
2021-08-14 17:17:51 +02:00
void main ( ) {
2021-09-01 00:24:30 +02:00
ivec4 coords = getOutputCoords ( ) ;
2021-09-05 22:42:11 +02:00
int b = coords [ 0 ] ;
int d = coords [ 3 ] ;
2021-08-14 17:17:51 +02:00
2021-09-11 16:29:31 +02:00
ivec2 dyRCCorner = coords . yz - pads ;
int dyRCorner = dyRCCorner . x ;
int dyCCorner = dyRCCorner . y ;
2021-08-14 17:17:51 +02:00
2021-09-11 16:29:31 +02:00
// Convolve dy(?, ?, d) with pos mask(:, :, d) to get dx(xR, xC, d).
// ? = to be determined. : = across all values in that axis.
float dotProd = 0.0 ;
2021-10-22 22:09:52 +02:00
for ( int wR = 0 ; wR < $ { o } ;
wR += $ { s } ) {
float dyR = float ( dyRCorner + wR ) / $ { a } . 0 ;
2021-08-14 17:17:51 +02:00
2021-09-11 16:29:31 +02:00
if ( dyR < 0.0 || dyR >= $ { e . outHeight } . 0 || fract ( dyR ) > 0.0 ) {
continue ;
}
int idyR = int ( dyR ) ;
2021-09-05 22:42:11 +02:00
2021-09-11 16:29:31 +02:00
for ( int wC = 0 ; wC < $ { l } ;
2021-10-22 22:09:52 +02:00
wC += $ { i } ) {
2021-10-04 23:03:36 +02:00
float dyC = float ( dyCCorner + wC ) / $ { r } . 0 ;
2021-09-05 22:42:11 +02:00
2021-09-11 16:29:31 +02:00
if ( dyC < 0.0 || dyC >= $ { e . outWidth } . 0 ||
fract ( dyC ) > 0.0 ) {
continue ;
}
int idyC = int ( dyC ) ;
2021-09-05 22:42:11 +02:00
2021-09-11 16:29:31 +02:00
float dyValue = getDy ( b , idyR , idyC , d ) ;
2021-09-05 22:42:11 +02:00
2021-09-11 16:29:31 +02:00
dotProd += dyValue * avgMultiplier ;
}
}
setOutput ( dotProd ) ;
}
2021-10-22 22:09:52 +02:00
` }},bJ=class{constructor(e){this.variableNames=["dy"],this.outputShape=e.inShape;let t=e.filterDepth,n=e.filterHeight,a=e.filterWidth,r=e.strideDepth,s=e.strideHeight,i=e.strideWidth,o=e.dilationDepth,l=e.dilationHeight,d=e.dilationWidth,u=e.effectiveFilterDepth,p=e.effectiveFilterHeight,c=e.effectiveFilterWidth,h=u-1-e.padInfo.front,f=p-1-e.padInfo.top,m=c-1-e.padInfo.left,g=1/(t*n*a);this.userCode= `
2021-10-07 16:33:10 +02:00
const ivec3 pads = ivec3 ( $ { h } , $ { f } , $ { m } ) ;
2021-09-11 16:29:31 +02:00
const float avgMultiplier = float ( $ { g } ) ;
2021-09-05 22:42:11 +02:00
2021-09-11 16:29:31 +02:00
void main ( ) {
ivec5 coords = getOutputCoords ( ) ;
int batch = coords . x ;
int ch = coords . u ;
ivec3 dyCorner = ivec3 ( coords . y , coords . z , coords . w ) - pads ;
int dyDCorner = dyCorner . x ;
int dyRCorner = dyCorner . y ;
int dyCCorner = dyCorner . z ;
// Convolve dy(?, ?, ?, d) with pos mask(:, :, :, ch) to get
// dx(xD, xR, xC, ch).
// ? = to be determined. : = across all values in that axis.
float dotProd = 0.0 ;
2021-10-07 16:33:10 +02:00
for ( int wD = 0 ; wD < $ { u } ;
2021-10-22 22:09:52 +02:00
wD += $ { o } ) {
2021-10-04 23:03:36 +02:00
float dyD = float ( dyDCorner + wD ) / $ { r } . 0 ;
2021-09-11 16:29:31 +02:00
if ( dyD < 0.0 || dyD >= $ { e . outDepth } . 0 || fract ( dyD ) > 0.0 ) {
2021-09-01 00:24:30 +02:00
continue ;
}
2021-09-11 16:29:31 +02:00
int idyD = int ( dyD ) ;
2021-09-01 00:24:30 +02:00
2021-10-22 22:09:52 +02:00
for ( int wR = 0 ; wR < $ { p } ;
2021-09-11 16:29:31 +02:00
wR += $ { l } ) {
2021-10-22 22:09:52 +02:00
float dyR = float ( dyRCorner + wR ) / $ { s } . 0 ;
2021-09-01 00:24:30 +02:00
2021-09-11 16:29:31 +02:00
if ( dyR < 0.0 || dyR >= $ { e . outHeight } . 0 ||
fract ( dyR ) > 0.0 ) {
2021-09-01 00:24:30 +02:00
continue ;
}
2021-09-11 16:29:31 +02:00
int idyR = int ( dyR ) ;
2021-08-14 17:17:51 +02:00
2021-10-22 22:09:52 +02:00
for ( int wC = 0 ; wC < $ { c } ;
wC += $ { d } ) {
float dyC = float ( dyCCorner + wC ) / $ { i } . 0 ;
2021-08-14 17:17:51 +02:00
2021-09-11 16:29:31 +02:00
if ( dyC < 0.0 || dyC >= $ { e . outWidth } . 0 ||
fract ( dyC ) > 0.0 ) {
continue ;
}
int idyC = int ( dyC ) ;
2021-08-14 17:17:51 +02:00
2021-09-11 16:29:31 +02:00
float dyValue = getDy ( batch , idyD , idyR , idyC , ch ) ;
2021-08-14 17:17:51 +02:00
2021-09-11 16:29:31 +02:00
dotProd += dyValue * avgMultiplier ;
2021-09-05 22:42:11 +02:00
}
}
}
2021-09-11 16:29:31 +02:00
setOutput ( dotProd ) ;
}
2021-10-22 22:09:52 +02:00
` }};function vJ(e){let{inputs:t,backend:n,attrs:a}=e,{dy:r,input:s}=t,i=s,{filterSize:o,strides:l,pad:d,dimRoundingMode:u}=a,p=[1,1,1],c=E.computePool3DInfo(i.shape,o,l,p,d,u),h=new bJ(c);return n.runWebGLProgram(h,[r],i.dtype)}var wJ={kernelName:Bc,backendName:"webgl",kernelFunc:vJ};function kJ(e){let{inputs:t,backend:n,attrs:a}=e,{dy:r,input:s}=t,i=s;Mu([r,s],"avgPoolGrad");let{filterSize:o,strides:l,pad:d}=a,u=E.computePool2DInfo(i.shape,o,l,1,d),p=new xJ(u);return n.runWebGLProgram(p,[r],i.dtype)}var IJ={kernelName:Wc,backendName:"webgl",kernelFunc:kJ};function SJ(e){let{inputs:t,backend:n,attrs:a}=e,{a:r,b:s}=t,{transposeA:i,transposeB:o}=a;return kf({a:r,b:s,transposeA:i,transposeB:o,backend:n})}var NJ={kernelName:Qs,backendName:"webgl",kernelFunc:SJ},TJ=class{constructor(e,t,n,a,r,s){this.outputShape=[],this.variableNames=["x","mean","variance"],E.assertAndGetBroadcastShape(e,t),E.assertAndGetBroadcastShape(e,n);let i="0.0";a!=null&&(E.assertAndGetBroadcastShape(e,a),this.variableNames.push("offset"),i="getOffsetAtOutCoords()");let o="1.0";r!=null&&(E.assertAndGetBroadcastShape(e,r),this.variableNames.push("scale"),o="getScaleAtOutCoords()"),this.outputShape=e,this.userCode= `
2021-09-11 16:29:31 +02:00
void main ( ) {
float x = getXAtOutCoords ( ) ;
float mean = getMeanAtOutCoords ( ) ;
float variance = getVarianceAtOutCoords ( ) ;
2021-10-22 22:09:52 +02:00
float offset = $ { i } ;
float scale = $ { o } ;
float inv = scale * inversesqrt ( variance + float ( $ { s } ) ) ;
2021-09-11 16:29:31 +02:00
setOutput ( dot ( vec3 ( x , - mean , offset ) , vec3 ( inv , inv , 1 ) ) ) ;
}
2021-10-22 22:09:52 +02:00
` }},CJ=class{constructor(e,t,n,a,r,s){this.packedInputs=!0,this.packedOutput=!0,this.variableNames=["x","mean","variance"],E.assertAndGetBroadcastShape(e,t),E.assertAndGetBroadcastShape(e,n);let i="vec4(0.0)";a!=null&&(E.assertAndGetBroadcastShape(e,a),this.variableNames.push("offset"),i="getOffsetAtOutCoords()");let o="vec4(1.0)";r!=null&&(E.assertAndGetBroadcastShape(e,r),this.variableNames.push("scale"),o="getScaleAtOutCoords()"),this.outputShape=e,this.userCode= `
2021-09-11 16:29:31 +02:00
void main ( ) {
2021-10-22 22:09:52 +02:00
vec4 offset = $ { i } ;
vec4 scale = $ { o } ;
2021-09-01 00:22:16 +02:00
2021-09-11 16:29:31 +02:00
vec4 x = getXAtOutCoords ( ) ;
vec4 mean = getMeanAtOutCoords ( ) ;
vec4 variance = getVarianceAtOutCoords ( ) ;
2021-10-22 22:09:52 +02:00
vec4 inv = scale * inversesqrt ( variance + vec4 ( $ { s } ) ) ;
2021-09-11 16:29:31 +02:00
setOutput ( ( x - mean ) * inv + offset ) ;
2021-09-05 22:42:11 +02:00
}
2021-10-22 22:09:52 +02:00
` }},EJ=({inputs:e,backend:t,attrs:n})=>{let{x:a,mean:r,variance:s,offset:i,scale:o}=e;w.assert(r.shape.length===s.shape.length,()=>"Batch normalization gradient requires mean and variance to have equal ranks."),w.assert(i==null||r.shape.length===i.shape.length,()=>"Batch normalization gradient requires mean and offset to have equal ranks."),w.assert(o==null||r.shape.length===o.shape.length,()=>"Batch normalization gradient requires mean and scale to have equal ranks.");let{varianceEpsilon:l}=n;l==null&&(l=.001);let d=[a,r,s],u=null;i!=null&&(u=i.shape,d.push(i));let p=null;o!=null&&(p=o.shape,d.push(o));let c=ne().getBool("WEBGL_PACK_NORMALIZATION")?new CJ(a.shape,r.shape,s.shape,u,p,l):new TJ(a.shape,r.shape,s.shape,u,p,l);return t.runWebGLProgram(c,d,d[0].dtype)},RJ={kernelName:hi,backendName:"webgl",kernelFunc:EJ},MJ=class{constructor(e){this.variableNames=["source"],this.outputShape=e,this.rank=e.length;let t=yt(this.rank);this.customUniforms=[{name:"start",arrayIndex:this.rank,type:"int"}];let n=FJ(this.rank),a,r=e.map((s,i)=> ` sourceLoc . $ { q2 [ i ] } = start [ $ { i } ] + coords . $ { q2 [ i ] } ; ` );a= `
2021-09-11 16:29:31 +02:00
$ { t } sourceLoc ;
$ { t } coords = getOutputCoords ( ) ;
2021-10-04 23:03:36 +02:00
$ { r . join ( `
2021-09-11 16:29:31 +02:00
` )}
` ,this.userCode= `
void main ( ) {
2021-10-22 22:09:52 +02:00
$ { a }
2021-09-11 16:29:31 +02:00
setOutput ( getSource ( $ { n } ) ) ;
}
2021-10-22 22:09:52 +02:00
` }},q2=["x","y","z","w","u","v"];function FJ(e){if(e===1)return"sourceLoc";if(e<=6)return q2.slice(0,e).map(t=>"sourceLoc."+t).join(",");throw Error( ` Slicing for rank $ { e } is not yet supported ` )}var DJ=class{constructor(e){this.variableNames=["source"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=e,this.rank=e.length,this.customUniforms=[{name:"start",arrayIndex:this.rank,type:"int"}];let t=yt(this.rank),n=On("coords",this.rank),a=On("sourceLoc",this.rank),r=this.rank===1?"sourceLoc": ` vec2 ( $ { a . slice ( - 2 ) . join ( ) } ) ` ,s= ` getChannel ( getSource ( $ { a . join ( ) } ) , $ { r } ) ` ,i= `
result . x = $ { s } ;
2021-09-11 16:29:31 +02:00
if ( ++ $ { n [ this . rank - 1 ] } < $ { e [ this . rank - 1 ] } ) {
2021-10-22 22:09:52 +02:00
++ $ { a [ this . rank - 1 ] } ;
result . y = $ { s } ;
-- $ { a [ this . rank - 1 ] } ;
2021-09-11 16:29:31 +02:00
}
2021-10-22 22:09:52 +02:00
` ,o=this.rank===1?"": `
2021-09-11 16:29:31 +02:00
-- $ { n [ this . rank - 1 ] } ;
if ( ++ $ { n [ this . rank - 2 ] } < $ { e [ this . rank - 2 ] } ) {
2021-10-22 22:09:52 +02:00
++ $ { a [ this . rank - 2 ] } ;
result . z = $ { s } ;
2021-09-11 16:29:31 +02:00
if ( ++ $ { n [ this . rank - 1 ] } < $ { e [ this . rank - 1 ] } ) {
2021-10-22 22:09:52 +02:00
++ $ { a [ this . rank - 1 ] } ;
result . w = $ { s } ;
2021-09-11 16:29:31 +02:00
}
}
` ,l=this.rank<=4? ` sourceLoc = coords +
2021-10-22 22:09:52 +02:00
$ { t } ( $ { e . map ( ( d , u ) => ` start[ ${ u } ] ` ) . join ( ) } ) ; ` :e.map((d,u)=> ` $ { a [ u ] } = $ { n [ u ] } + start [ $ { u } ] ; ` ).join( `
2021-09-11 16:29:31 +02:00
` );this.userCode= `
void main ( ) {
$ { t } coords = getOutputCoords ( ) ;
$ { t } sourceLoc ;
$ { l }
vec4 result = vec4 ( 0. ) ;
2021-09-11 17:17:13 +02:00
$ { i }
2021-10-22 22:09:52 +02:00
$ { o }
2021-09-11 16:29:31 +02:00
setOutput ( result ) ;
2021-09-05 22:42:11 +02:00
}
2021-10-22 22:09:52 +02:00
` }};function $ J(e,t,n,a){let r=a.texData.get(e.dataId),s=a.makeTensorInfo(n,e.dtype),i=a.texData.get(s.dataId);Object.assign(i,r),i.refCount=1,i.shape=n,i.dtype=e.dtype;let o=En.computeFlatOffset(t,w.computeStrides(e.shape));r.slice&&(o+=r.slice.flatOffset),i.slice={flatOffset:o,origDataId:r.slice&&r.slice.origDataId||e.dataId};let l=a.dataRefCount.get(i.slice.origDataId)||1;return a.dataRefCount.set(i.slice.origDataId,l+1),s}function Lu(e){let{inputs:t,backend:n,attrs:a}=e,{x:r}=t,{begin:s,size:i}=a,[o,l]=En.parseSliceParams(r,s,i);if(En.assertParamsValid(r,o,l),w.sizeFromShape(l)===0)return n.makeTensorInfo(l,r.dtype,[]);if(n.shouldExecuteOnCPU([r])||r.dtype==="string"){let p=n.texData.get(r.dataId),c=xZ(p.values,o,l,r.shape,r.dtype);return n.makeTensorInfo(l,r.dtype,c)}let{isPacked:d}=n.texData.get(r.dataId),u=En.isSliceContinous(r.shape,o,l);if(d||!u){let p=ne().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new DJ(l):new MJ(l),c=[o];return n.runWebGLProgram(p,[r],r.dtype,c)}return n.uploadToGPU(r.dataId), $ J(r,o,l,n)}var OJ={kernelName:zl,backendName:"webgl",kernelFunc:Lu},_J=e=>{let{inputs:t,backend:n,attrs:a}=e,{x:r}=t,{blockShape:s,crops:i}=a;w.assert(r.shape.length<=4,()=>"batchToSpaceND for rank > 4 with a WebGL backend not implemented yet");let o=s.reduce((A,x)=>A*x),l=E.getReshaped(r.shape,s,o),d=E.getPermuted(l.length,s.length),u=E.getReshapedPermuted(r.shape,s,o),p=E.getSliceBeginCoords(i,s.length),c=E.getSliceSize(u,i,s.length),h=[],f=we({inputs:{x:r},backend:n,attrs:{shape:l}}),m=_n({inputs:{x:f},backend:n,attrs:{perm:d}}),g=we({inputs:{x:m},backend:n,attrs:{shape:u}}),y=Lu({inputs:{x:g},backend:n,attrs:{begin:p,size:c}});return h.push(f),h.push(m),h.push(g),h.forEach(A=>n.disposeIntermediateTensorInfo(A)),y},PJ={kernelName:sl,backendName:"webgl",kernelFunc:_J};function zJ(e){let{inputs:t,backend:n,attrs:a}=e,{x:r,weights:s}=t,{size:i}=a,o=n.readSync(r.dataId),l=n.readSync(s.dataId),d=U4(o,l,s.dtype,s.shape,i);return n.makeTensorInfo([i],s.dtype,d)}var LJ={kernelName:Vc,backendName:"webgl",kernelFunc:zJ};function WJ(e){let{inputs:t,backend:n}=e,{s0:a,s1:r}=t,s=n.readSync(a.dataId),i=n.readSync(r.dataId),o=E.assertAndGetBroadcastShape(Array.from(s),Array.from(i));return n.makeTensorInfo([o.length],"int32",Int32Array.from(o))}var BJ={kernelName:Uc,backendName:"webgl",kernelFunc:WJ},VJ="return float(a != b);",gk=vn({opSnippet:VJ,cpuKernelImpl:fZ,dtype:"bool"}),UJ={kernelName:Nl,backendName:"webgl",kernelFunc:gk};function Bp(e){let{inputs:t,backend:n}=e,{input:a}=t,r=n.texData.get(a.dataId);return ma({inputs:{x:r.complexTensorInfos.real},backend:n})}var jJ={kernelName:ph,backendName:"webgl",kernelFunc:Bp},GJ="return float(int(x));";function HJ(e,t){let n=new Fs(e.shape,GJ),a=t.runWebGLProgram(n,[e],"int32");return{dataId:a.dataId,shape:a.shape,dtype:a.dtype}}function X2(e){let{inputs:t,backend:n,attrs:a}=e,{x:r}=t,{dtype:s}=a;if(s==="complex64"){if(r.dtype==="complex64")return ma({inputs:{x:r},backend:n});let i=Gt(r.shape),o=X2({inputs:{x:r},backend:n,attrs:{dtype:"float32"}}),l=Ds({inputs:{real:o,imag:i},backend:n});return i.dispose(),n.disposeIntermediateTensorInfo(o),l}if(r.dtype==="complex64"){let i=Bp({inputs:{input:r},backend:n}),o=X2({inputs:{x:i},backend:n,attrs:{dtype:s}});return n.disposeIntermediateTensorInfo(i),o}if(!w.hasEncodingLoss(r.dtype,s)){let i=ma({inputs:{x:r},backend:n});return{dataId:i.dataId,shape:i.shape,dtype:s}}if(s==="int32")return HJ(r,n);if(s==="bool"){let i=n.makeTensorInfo([],"bool",w.getTypedArrayFromDType("bool",1)),o=gk({inputs:{a:r,b:i},backend:n});return n.disposeIntermediateTensorInfo(i),o}throw new Error( ` Error in Cast : failed to cast $ { r . dtype } to $ { s } ` )}var qJ={kernelName:ei,backendName:"webgl",kernelFunc:X2},yk="return ceil(x);",XJ=nt({opSnippet:yk,packedOpSnippet:yk,cpuKernelImpl:KK}),KJ={kernelName:ti,backendName:"webgl",kernelFunc:XJ},ZJ=class{constructor(e){this.variableNames=["A"],this.customUniforms=[{name:"minVal",type:"float"},{name:"maxVal",type:"float"}],this.outputShape=e,this.userCode= `
2021-09-01 00:24:30 +02:00
2021-09-05 22:42:11 +02:00
void main ( ) {
2021-09-11 16:29:31 +02:00
float value = getAAtOutCoords ( ) ;
if ( isnan ( value ) ) {
setOutput ( value ) ;
return ;
}
2021-09-01 00:24:30 +02:00
2021-09-11 16:29:31 +02:00
setOutput ( clamp ( value , minVal , maxVal ) ) ;
}
2021-10-22 22:09:52 +02:00
` }},YJ=class{constructor(e){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.customUniforms=[{name:"minVal",type:"float"},{name:"maxVal",type:"float"}],this.outputShape=e,this.userCode= `
2021-09-11 16:29:31 +02:00
void main ( ) {
vec4 value = getAAtOutCoords ( ) ;
2021-09-01 00:24:30 +02:00
2021-09-11 16:29:31 +02:00
if ( any ( isnan ( value ) ) ) {
setOutput ( value ) ;
return ;
}
2021-09-01 00:24:30 +02:00
2021-09-11 16:29:31 +02:00
setOutput ( clamp ( value , vec4 ( minVal ) , vec4 ( maxVal ) ) ) ;
2021-09-05 22:42:11 +02:00
}
2021-10-22 22:09:52 +02:00
` }};function JJ(e){let{inputs:t,backend:n,attrs:a}=e,{x:r}=t,{clipValueMin:s,clipValueMax:i}=a,o;ne().getBool("WEBGL_PACK_CLIP")?o=new YJ(r.shape):o=new ZJ(r.shape);let l=[[s],[i]];return n.runWebGLProgram(o,[r],r.dtype,l)}var QJ={kernelName:us,backendName:"webgl",kernelFunc:JJ},eQ=class{constructor(e){this.variableNames=["real","imag"],this.outputShape=e,this.userCode= `
2021-09-11 16:29:31 +02:00
void main ( ) {
float re = abs ( getRealAtOutCoords ( ) ) ;
float im = abs ( getImagAtOutCoords ( ) ) ;
float mx = max ( re , im ) ;
// sadly the length function in glsl is not underflow-safe
// (at least not on Intel GPUs). So the safe solution is
// to ensure underflow-safety in all cases.
setOutput (
mx == 0.0 ? 0.0 : mx * length ( vec2 ( 1 , min ( re , im ) / mx ) )
) ;
2021-09-05 22:42:11 +02:00
}
2021-10-22 22:09:52 +02:00
` }};function Ak(e,t){return{dataId:t.dataId,dtype:t.dtype,shape:e.shape}}function tQ(e){let{inputs:t,backend:n}=e,{x:a}=t,r=n.texData.get(a.dataId),s=new eQ(a.shape),i=[Ak(a,r.complexTensorInfos.real),Ak(a,r.complexTensorInfos.imag)];return n.runWebGLProgram(s,i,i[0].dtype)}var nQ={kernelName:xd,backendName:"webgl",kernelFunc:tQ},aQ=class{constructor(e){this.outputShape=[],this.outputShape=E.computeOutShape(e,1),this.variableNames=e.map((s,i)=> ` T$ { i } ` );let t=new Array(e.length-1);t[0]=e[0][1];for(let s=1;s<t.length;s++)t[s]=t[s-1]+e[s][1];let n=[ ` if ( yC < $ { t [ 0 ] } ) setOutput ( getT0 ( yR , yC ) ) ; ` ];for(let s=1;s<t.length;s++){let i=t[s-1];n.push( ` else if ( yC < $ { t [ s ] } ) setOutput ( getT$ { s } ( yR , yC - $ { i } ) ) ; ` )}let a=t.length,r=t[t.length-1];n.push( ` else setOutput ( getT$ { a } ( yR , yC - $ { r } ) ) ; ` ),this.userCode= `
2021-09-11 16:29:31 +02:00
void main ( ) {
ivec2 coords = getOutputCoords ( ) ;
int yR = coords . x ;
int yC = coords . y ;
2021-09-01 00:24:30 +02:00
2021-09-11 16:29:31 +02:00
$ { n . join ( `
` )}
}
2021-10-22 22:09:52 +02:00
` }},rQ=class{constructor(e,t){this.packedInputs=!0,this.packedOutput=!0,this.outputShape=[],this.outputShape=E.computeOutShape(e,t);let n=this.outputShape,a=n.length,r=yt(a),s=On("coords",a),i=["x","y","z","w","u","v"].slice(0,a);this.variableNames=e.map((f,m)=> ` T$ { m } ` );let o=new Array(e.length-1);o[0]=e[0][t];for(let f=1;f<o.length;f++)o[f]=o[f-1]+e[f][t];let l=i[t],d=i.slice(-2),u=i.join(),p= ` if ( $ { l } < $ { o [ 0 ] } ) {
2021-09-11 16:29:31 +02:00
return getChannel (
2021-10-22 22:09:52 +02:00
getT0 ( $ { u } ) , vec2 ( $ { d . join ( ) } ) ) ;
} ` ;for(let f=1;f<o.length;f++){let m=o[f-1];p+= `
if ( $ { l } < $ { o [ f ] } && $ { l } >= $ { o [ f - 1 ] } ) {
2021-09-11 16:29:31 +02:00
return getChannel (
2021-10-22 22:09:52 +02:00
getT$ { f } ( $ { Sf ( i , l , m ) } ) ,
vec2 ( $ { Sf ( d , l , m ) } ) ) ;
} ` }let c=o.length,h=o[o.length-1];p+= `
2021-09-11 16:29:31 +02:00
return getChannel (
2021-10-22 22:09:52 +02:00
getT$ { c } ( $ { Sf ( i , l , h ) } ) ,
vec2 ( $ { Sf ( d , l , h ) } ) ) ; ` ,this.userCode= `
float getValue ( $ { i . map ( f => "int " + f ) } ) {
$ { p }
2021-09-05 22:42:11 +02:00
}
2021-09-01 00:24:30 +02:00
void main ( ) {
2021-10-04 23:03:36 +02:00
$ { r } coords = getOutputCoords ( ) ;
2021-10-22 22:09:52 +02:00
vec4 result = vec4 ( getValue ( $ { s } ) , 0. , 0. , 0. ) ;
2021-09-01 00:24:30 +02:00
2021-10-22 22:09:52 +02:00
$ { s [ a - 1 ] } = $ { s [ a - 1 ] } + 1 ;
if ( $ { s [ a - 1 ] } < $ { n [ a - 1 ] } ) {
result . g = getValue ( $ { s } ) ;
2021-09-11 16:29:31 +02:00
}
2021-09-01 00:24:30 +02:00
2021-10-22 22:09:52 +02:00
$ { s [ a - 2 ] } = $ { s [ a - 2 ] } + 1 ;
if ( $ { s [ a - 2 ] } < $ { n [ a - 2 ] } ) {
result . a = getValue ( $ { s } ) ;
2021-09-11 16:29:31 +02:00
}
2021-09-01 00:24:30 +02:00
2021-10-22 22:09:52 +02:00
$ { s [ a - 1 ] } = $ { s [ a - 1 ] } - 1 ;
if ( $ { s [ a - 2 ] } < $ { n [ a - 2 ] } &&
$ { s [ a - 1 ] } < $ { n [ a - 1 ] } ) {
result . b = getValue ( $ { s } ) ;
2021-09-11 16:29:31 +02:00
}
setOutput ( result ) ;
}
2021-10-22 22:09:52 +02:00
` }};function Sf(e,t,n){let a=e.indexOf(t);return e.map((r,s)=>s===a? ` $ { r } - $ { n } ` :r).join()}function Nf(e){let{inputs:t,backend:n}=e,{input:a}=t,r=n.texData.get(a.dataId);return ma({inputs:{x:r.complexTensorInfos.imag},backend:n})}var sQ={kernelName:rh,backendName:"webgl",kernelFunc:Nf};function Wu(e,t,n){let a=e[0].dtype;if(a==="complex64"){let u=e.map(m=>Bp({inputs:{input:m},backend:n})),p=e.map(m=>Nf({inputs:{input:m},backend:n})),c=Wu(u,t,n),h=Wu(p,t,n),f=Ds({inputs:{real:c,imag:h},backend:n});return u.forEach(m=>n.disposeIntermediateTensorInfo(m)),p.forEach(m=>n.disposeIntermediateTensorInfo(m)),n.disposeIntermediateTensorInfo(c),n.disposeIntermediateTensorInfo(h),f}let r=n.shouldExecuteOnCPU(e);if(a==="string"&&(r=!0),r){let u=e.map(y=>{let A=w.sizeFromShape(y.shape.slice(t));return we({inputs:{x:y},backend:n,attrs:{shape:[-1,A]}})}),p=u.map(y=>({vals:n.readSync(y.dataId),shape:y.shape})),c=E.computeOutShape(u.map(y=>y.shape),1),h=u[0].shape[0]===1,f=ZK(p,c,a,h),m=E.computeOutShape(e.map(y=>y.shape),t),g=n.makeTensorInfo(m,a,f);return u.forEach(y=>n.disposeIntermediateTensorInfo(y)),g}if(e.length>ne().getNumber("WEBGL_MAX_TEXTURES_IN_SHADER")){let u=Math.floor(e.length/2),p=Wu(e.slice(0,u),t,n),c=Wu(e.slice(u),t,n),h=Wu([p,c],t,n);return n.disposeIntermediateTensorInfo(p),n.disposeIntermediateTensorInfo(c),h}if(ne().getBool("WEBGL_PACK_ARRAY_OPERATIONS")&&e[0].shape.length>1){let u=new rQ(e.map(p=>p.shape),t);return n.runWebGLProgram(u,e,a)}let{tensors2D:s,outShape:i}=iQ(e,t,n),o=new aQ(s.map(u=>u.shape)),l=n.runWebGLProgram(o,s,a);s.forEach(u=>n.disposeIntermediateTensorInfo(u));let d=we({inputs:{x:l},attrs:{shape:i},backend:n});return n.disposeIntermediateTensorInfo(l),d}function iQ(e,t,n){let a=E.computeOutShape(e.map(r=>r.shape),t);return{tensors2D:e.map(r=>we({inputs:{x:r},attrs:{shape:[-1,w.sizeFromShape(r.shape.slice(t))]},backend:n})),outShape:a}}function xk(e){let{inputs:t,backend:n,attrs:a}=e,{axis:r}=a,s=w.parseAxisParam(r,t[0].shape)[0],i=E.computeOutShape(t.map(d=>d.shape),s);if(w.sizeFromShape(i)===0)return n.makeTensorInfo(i,t[0].dtype,[]);let o=t.filter(d=>w.sizeFromShape(d.shape)>0);if(o.length===1)return ma({inputs:{x:o[0]},backend:n});let l=o.map(d=>d.shape);return E.assertParamsConsistent(l,s),Wu(o,s,n)}var oQ={kernelName:il,backendName:"webgl",kernelFunc:xk},bk=class{constructor(e,t=!1,n=null,a=!1,r=!1){this.variableNames=["x","W"],this.outputShape=e.outShape;let s=e.padInfo.top,i=e.padInfo.left,o=e.strideHeight,l=e.strideWidth,d=e.dilationHeight,u=e.dilationWidth,p=e.filterHeight,c=e.filterWidth,h=Math.floor(e.inChannels/4)*4,f=e.inChannels%4,m=e.dataFormat==="channelsLast",g=m?1:2,y=m?2:3,A=m?3:1,x="",b="";n&&(a?x= ` float activation ( float a ) {
2021-09-11 16:29:31 +02:00
float b = getPreluActivationWeightsAtOutCoords ( ) ;
$ { n }
2021-10-04 23:03:36 +02:00
} ` :r?x= ` float activation ( float a ) {
2021-09-11 16:29:31 +02:00
float b = getLeakyreluAlphaAtOutCoords ( ) ;
$ { n }
2021-10-04 23:03:36 +02:00
} ` :x= `
2021-09-11 16:29:31 +02:00
float activation ( float x ) {
$ { n }
}
2021-10-22 22:09:52 +02:00
` ,b="result = activation(result);");let v=t?"result += getBiasAtOutCoords();":"";t&&this.variableNames.push("bias"),a&&this.variableNames.push("preluActivationWeights"),r&&this.variableNames.push("leakyreluAlpha"),this.userCode= `
2021-10-04 23:03:36 +02:00
$ { x }
2021-09-05 22:42:11 +02:00
2021-10-22 22:09:52 +02:00
const ivec2 strides = ivec2 ( $ { o } , $ { l } ) ;
const ivec2 pads = ivec2 ( $ { s } , $ { i } ) ;
2021-09-05 22:42:11 +02:00
2021-09-01 00:24:30 +02:00
void main ( ) {
ivec4 coords = getOutputCoords ( ) ;
2021-09-11 16:29:31 +02:00
int batch = coords [ 0 ] ;
2021-10-22 22:09:52 +02:00
int d2 = coords [ $ { A } ] ;
2021-09-01 00:24:30 +02:00
2021-09-11 16:29:31 +02:00
ivec2 xRCCorner =
2021-10-22 22:09:52 +02:00
ivec2 ( coords [ $ { g } ] , coords [ $ { y } ] ) * strides - pads ;
2021-09-11 16:29:31 +02:00
int xRCorner = xRCCorner . x ;
int xCCorner = xRCCorner . y ;
2021-09-01 00:24:30 +02:00
2021-09-11 16:29:31 +02:00
// Convolve x(?, ?, d1) with w(:, :, d1, d2) to get y(yR, yC, d2).
// ? = to be determined. : = across all values in that axis.
float dotProd = 0.0 ;
2021-10-22 22:09:52 +02:00
for ( int wR = 0 ; wR < $ { p } ; wR ++ ) {
int xR = xRCorner + wR * $ { d } ;
2021-09-01 00:24:30 +02:00
2021-09-11 16:29:31 +02:00
if ( xR < 0 || xR >= $ { e . inHeight } ) {
2021-09-01 00:24:30 +02:00
continue ;
}
2021-10-22 22:09:52 +02:00
for ( int wC = 0 ; wC < $ { c } ; wC ++ ) {
2021-10-07 16:33:10 +02:00
int xC = xCCorner + wC * $ { u } ;
2021-09-01 00:24:30 +02:00
2021-09-11 16:29:31 +02:00
if ( xC < 0 || xC >= $ { e . inWidth } ) {
2021-09-01 00:24:30 +02:00
continue ;
}
2021-10-04 23:03:36 +02:00
for ( int d1 = 0 ; d1 < $ { h } ; d1 += 4 ) {
2021-09-11 16:29:31 +02:00
vec4 wValues = vec4 (
getW ( wR , wC , d1 , d2 ) ,
getW ( wR , wC , d1 + 1 , d2 ) ,
getW ( wR , wC , d1 + 2 , d2 ) ,
getW ( wR , wC , d1 + 3 , d2 )
) ;
2021-09-01 00:24:30 +02:00
2021-10-07 16:33:10 +02:00
if ( $ { m } ) {
2021-09-11 16:29:31 +02:00
vec4 xValues = vec4 (
getX ( batch , xR , xC , d1 ) ,
getX ( batch , xR , xC , d1 + 1 ) ,
getX ( batch , xR , xC , d1 + 2 ) ,
getX ( batch , xR , xC , d1 + 3 )
) ;
dotProd += dot ( xValues , wValues ) ;
} else {
vec4 xValues = vec4 (
getX ( batch , d1 , xR , xC ) ,
getX ( batch , d1 + 1 , xR , xC ) ,
getX ( batch , d1 + 2 , xR , xC ) ,
getX ( batch , d1 + 3 , xR , xC )
) ;
dotProd += dot ( xValues , wValues ) ;
}
}
2021-09-01 00:24:30 +02:00
2021-10-07 16:33:10 +02:00
if ( $ { f === 1 } ) {
2021-09-01 00:24:30 +02:00
2021-10-07 16:33:10 +02:00
if ( $ { m } ) {
2021-09-11 16:29:31 +02:00
dotProd +=
2021-10-04 23:03:36 +02:00
getX ( batch , xR , xC , $ { h } ) *
getW ( wR , wC , $ { h } , d2 ) ;
2021-09-11 16:29:31 +02:00
} else {
dotProd +=
2021-10-04 23:03:36 +02:00
getX ( batch , $ { h } , xR , xC ) *
getW ( wR , wC , $ { h } , d2 ) ;
2021-09-11 16:29:31 +02:00
}
2021-09-01 00:24:30 +02:00
2021-10-07 16:33:10 +02:00
} else if ( $ { f === 2 } ) {
2021-09-11 16:29:31 +02:00
vec2 wValues = vec2 (
2021-10-04 23:03:36 +02:00
getW ( wR , wC , $ { h } , d2 ) ,
getW ( wR , wC , $ { h } + 1 , d2 )
2021-09-11 16:29:31 +02:00
) ;
2021-09-01 00:24:30 +02:00
2021-10-07 16:33:10 +02:00
if ( $ { m } ) {
2021-09-11 16:29:31 +02:00
vec2 xValues = vec2 (
2021-10-04 23:03:36 +02:00
getX ( batch , xR , xC , $ { h } ) ,
getX ( batch , xR , xC , $ { h } + 1 )
2021-09-11 16:29:31 +02:00
) ;
dotProd += dot ( xValues , wValues ) ;
} else {
vec2 xValues = vec2 (
2021-10-04 23:03:36 +02:00
getX ( batch , $ { h } , xR , xC ) ,
getX ( batch , $ { h } + 1 , xR , xC )
2021-09-11 16:29:31 +02:00
) ;
dotProd += dot ( xValues , wValues ) ;
}
2021-10-07 16:33:10 +02:00
} else if ( $ { f === 3 } ) {
2021-09-11 16:29:31 +02:00
vec3 wValues = vec3 (
2021-10-04 23:03:36 +02:00
getW ( wR , wC , $ { h } , d2 ) ,
getW ( wR , wC , $ { h } + 1 , d2 ) ,
getW ( wR , wC , $ { h } + 2 , d2 )
2021-09-11 16:29:31 +02:00
) ;
2021-10-07 16:33:10 +02:00
if ( $ { m } ) {
2021-09-11 16:29:31 +02:00
vec3 xValues = vec3 (
2021-10-04 23:03:36 +02:00
getX ( batch , xR , xC , $ { h } ) ,
getX ( batch , xR , xC , $ { h } + 1 ) ,
getX ( batch , xR , xC , $ { h } + 2 )
2021-09-11 16:29:31 +02:00
) ;
dotProd += dot ( xValues , wValues ) ;
} else {
vec3 xValues = vec3 (
2021-10-04 23:03:36 +02:00
getX ( batch , $ { h } , xR , xC ) ,
getX ( batch , $ { h } + 1 , xR , xC ) ,
getX ( batch , $ { h } + 2 , xR , xC )
2021-09-11 16:29:31 +02:00
) ;
dotProd += dot ( xValues , wValues ) ;
}
2021-09-01 00:24:30 +02:00
}
}
2021-06-07 02:34:29 +02:00
}
2021-09-11 16:29:31 +02:00
float result = dotProd ;
2021-10-22 19:49:40 +02:00
$ { v }
2021-10-04 23:03:36 +02:00
$ { b }
2021-09-11 16:29:31 +02:00
setOutput ( result ) ;
2021-09-05 22:42:11 +02:00
}
2021-10-22 22:09:52 +02:00
` }},lQ=class{constructor(e){this.variableNames=["x","W"],this.outputShape=e.outShape;let t=e.padInfo.front,n=e.padInfo.top,a=e.padInfo.left,r=e.strideDepth,s=e.strideHeight,i=e.strideWidth,o=e.dilationDepth,l=e.dilationHeight,d=e.dilationWidth,u=e.filterDepth,p=e.filterHeight,c=e.filterWidth,h=Math.floor(e.inChannels/4)*4,f=e.inChannels%4;this.userCode= `
const ivec3 strides = ivec3 ( $ { r } , $ { s } , $ { i } ) ;
const ivec3 pads = ivec3 ( $ { t } , $ { n } , $ { a } ) ;
2021-09-11 16:29:31 +02:00
2021-09-01 00:24:30 +02:00
void main ( ) {
2021-09-11 16:29:31 +02:00
ivec5 coords = getOutputCoords ( ) ;
int batch = coords . x ;
int d2 = coords . u ;
ivec3 xFRCCorner = ivec3 ( coords . y , coords . z , coords . w ) * strides - pads ;
int xFCorner = xFRCCorner . x ;
int xRCorner = xFRCCorner . y ;
int xCCorner = xFRCCorner . z ;
// Convolve x(?, ?, ?, d1) with w(:, :, :, d1, d2) to get
// y(yF, yR, yC, d2). ? = to be determined. : = across all
// values in that axis.
float dotProd = 0.0 ;
2021-10-07 16:33:10 +02:00
for ( int wF = 0 ; wF < $ { u } ; wF ++ ) {
2021-10-22 22:09:52 +02:00
int xF = xFCorner + wF * $ { o } ;
2021-09-05 22:42:11 +02:00
2021-09-11 16:29:31 +02:00
if ( xF < 0 || xF >= $ { e . inDepth } ) {
continue ;
}
2021-09-05 22:42:11 +02:00
2021-10-22 22:09:52 +02:00
for ( int wR = 0 ; wR < $ { p } ; wR ++ ) {
2021-09-11 16:29:31 +02:00
int xR = xRCorner + wR * $ { l } ;
2021-09-01 00:24:30 +02:00
2021-09-11 16:29:31 +02:00
if ( xR < 0 || xR >= $ { e . inHeight } ) {
continue ;
}
2021-09-05 22:42:11 +02:00
2021-10-22 22:09:52 +02:00
for ( int wC = 0 ; wC < $ { c } ; wC ++ ) {
int xC = xCCorner + wC * $ { d } ;
2021-09-11 16:29:31 +02:00
if ( xC < 0 || xC >= $ { e . inWidth } ) {
continue ;
}
2021-10-04 23:03:36 +02:00
for ( int d1 = 0 ; d1 < $ { h } ; d1 += 4 ) {
2021-09-11 16:29:31 +02:00
vec4 xValues = vec4 (
getX ( batch , xF , xR , xC , d1 ) ,
getX ( batch , xF , xR , xC , d1 + 1 ) ,
getX ( batch , xF , xR , xC , d1 + 2 ) ,
getX ( batch , xF , xR , xC , d1 + 3 )
) ;
vec4 wValues = vec4 (
getW ( wF , wR , wC , d1 , d2 ) ,
getW ( wF , wR , wC , d1 + 1 , d2 ) ,
getW ( wF , wR , wC , d1 + 2 , d2 ) ,
getW ( wF , wR , wC , d1 + 3 , d2 )
) ;
dotProd += dot ( xValues , wValues ) ;
}
2021-10-07 16:33:10 +02:00
if ( $ { f === 1 } ) {
2021-09-11 16:29:31 +02:00
dotProd +=
2021-10-04 23:03:36 +02:00
getX ( batch , xF , xR , xC , $ { h } ) *
getW ( wF , wR , wC , $ { h } , d2 ) ;
2021-10-07 16:33:10 +02:00
} else if ( $ { f === 2 } ) {
2021-09-11 16:29:31 +02:00
vec2 xValues = vec2 (
2021-10-04 23:03:36 +02:00
getX ( batch , xF , xR , xC , $ { h } ) ,
getX ( batch , xF , xR , xC , $ { h } + 1 )
2021-09-11 16:29:31 +02:00
) ;
vec2 wValues = vec2 (
2021-10-04 23:03:36 +02:00
getW ( wF , wR , wC , $ { h } , d2 ) ,
getW ( wF , wR , wC , $ { h } + 1 , d2 )
2021-09-11 16:29:31 +02:00
) ;
dotProd += dot ( xValues , wValues ) ;
2021-10-07 16:33:10 +02:00
} else if ( $ { f === 3 } ) {
2021-09-11 16:29:31 +02:00
vec3 xValues = vec3 (
2021-10-04 23:03:36 +02:00
getX ( batch , xF , xR , xC , $ { h } ) ,
getX ( batch , xF , xR , xC , $ { h } + 1 ) ,
getX ( batch , xF , xR , xC , $ { h } + 2 )
2021-09-11 16:29:31 +02:00
) ;
vec3 wValues = vec3 (
2021-10-04 23:03:36 +02:00
getW ( wF , wR , wC , $ { h } , d2 ) ,
getW ( wF , wR , wC , $ { h } + 1 , d2 ) ,
getW ( wF , wR , wC , $ { h } + 2 , d2 )
2021-09-11 16:29:31 +02:00
) ;
dotProd += dot ( xValues , wValues ) ;
}
}
}
}
setOutput ( dotProd ) ;
2021-09-05 22:42:11 +02:00
}
2021-10-22 22:09:52 +02:00
` }},uQ=class{constructor(e,t){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.customUniforms=[{name:"inputShape",type:"ivec3"},{name:"pad",type:"ivec2"},{name:"stride",type:"ivec2"},{name:"dilation",type:"ivec2"},{name:"inChannels",type:"int"},{name:"itemsPerBlockRow",type:"int"},{name:"outWidth",type:"int"}],this.outputShape=e,this.enableShapeUniforms=Ra(this.outputShape.length);let{dataFormat:n}=t,a= $ n(),r=n==="channelsLast",s=r?0:1,i=r?1:2,o=this.enableShapeUniforms?"if(blockIndex < outShape[1] && pos < outShape[0]) {": ` if ( blockIndex < $ { e [ 1 ] } && pos < $ { e [ 0 ] } ) { ` ,l="";for(let d=0;d<=1;d++)for(let u=0;u<=1;u++)l+= `
2021-10-07 16:33:10 +02:00
blockIndex = rc . y + $ { u } ;
2021-10-22 22:09:52 +02:00
pos = rc . x + $ { d } ;
2021-09-01 00:24:30 +02:00
2021-10-22 22:09:52 +02:00
$ { o }
2021-09-11 16:29:31 +02:00
offsetY = int ( blockIndex / outWidth ) * stride [ 0 ] - pad [ 0 ] ;
d0 = offsetY + dilation [ 0 ] * ( pos / itemsPerBlockRow ) ;
2021-09-01 00:24:30 +02:00
2021-10-22 22:09:52 +02:00
if ( d0 < inputShape [ $ { s } ] && d0 >= 0 ) {
2021-09-11 16:29:31 +02:00
// Use custom imod instead mod. On Intel GPU, mod may generate
// unexpected value.
// https://github.com/tensorflow/tfjs/issues/5447
offsetX = imod ( blockIndex , outWidth ) * stride [ 1 ] - pad [ 1 ] ;
d1 = offsetX + dilation [ 1 ] * ( imod ( pos , itemsPerBlockRow ) /
inChannels ) ;
2021-09-01 00:24:30 +02:00
2021-10-22 22:09:52 +02:00
if ( d1 < inputShape [ $ { i } ] && d1 >= 0 ) {
2021-09-01 00:24:30 +02:00
2021-09-11 16:29:31 +02:00
ch = imod ( pos , inChannels ) ;
2021-09-05 22:42:11 +02:00
2021-10-04 23:03:36 +02:00
if ( $ { r } ) {
2021-09-11 16:29:31 +02:00
innerDims = vec2 ( d1 , ch ) ;
2021-10-22 22:09:52 +02:00
result [ $ { d * 2 + u } ] = getChannel (
2021-09-11 16:29:31 +02:00
getA ( d0 , int ( innerDims . x ) ,
int ( innerDims . y ) ) , innerDims ) ;
} else {
innerDims = vec2 ( d0 , d1 ) ;
2021-10-22 22:09:52 +02:00
result [ $ { d * 2 + u } ] = getChannel (
2021-09-11 16:29:31 +02:00
getA ( ch , int ( innerDims . x ) ,
int ( innerDims . y ) ) , innerDims ) ;
}
}
}
}
` ;this.userCode= `
void main ( ) {
ivec2 rc = getOutputCoords ( ) ;
2021-09-01 00:24:30 +02:00
2021-09-11 16:29:31 +02:00
vec4 result = vec4 ( 0 ) ;
2021-09-01 00:24:30 +02:00
2021-09-11 16:29:31 +02:00
int blockIndex , pos , offsetY , d0 , offsetX , d1 , ch ;
vec2 innerDims ;
2021-09-01 00:24:30 +02:00
2021-09-11 16:29:31 +02:00
$ { l }
2021-10-22 22:09:52 +02:00
$ { a . output } = result ;
2021-09-05 22:42:11 +02:00
}
2021-10-22 22:09:52 +02:00
` }};function vk({x:e,filter:t,convInfo:n,backend:a,bias:r=null,preluActivationWeights:s=null,leakyreluAlpha:i=0,activation:o=null}){let l=e.shape,d=a.texData.get(e.dataId),u=n.inChannels,p=l[0]*l[1]*l[2],c=n.outChannels,h=n.dataFormat==="channelsLast",f=!1,m=!1,g,y=[];if(!((p===1||c===1)&&u>dk)&&d.isPacked&&h&&d.texture!=null&&l[2]%2!=0&&w.arraysEqual(d.shape.slice(-3),l.slice(-3))){let A=l[0]*l[1]*(l[2]+1),x={dataId:e.dataId,shape:[1,A,n.inChannels],dtype:e.dtype},b=d.shape;d.shape=d.shape.slice(),d.shape[d.shape.length-2]++,w.assert(Pp(d.shape,x.shape),()=> ` packed reshape $ { d . shape } to $ { x . shape } isn ' t free ` );let v=we({inputs:{x:t},backend:a,attrs:{shape:[1,n.inChannels,n.outChannels]}});y.push(v);let k=kf({a:x,b:v,backend:a,transposeA:f,transposeB:m,bias:r,activation:o,preluActivationWeights:s,leakyreluAlpha:i}),T=a.texData.get(k.dataId);w.assert(T.isPacked,()=>"batchMatMul result is expected to be packed"),d.shape=b,T.shape=n.outShape,g=ma({inputs:{x:k},backend:a}),g.shape=n.outShape,y.push(k)}else{let A=h?l[0]*l[1]*l[2]:l[0]*l[2]*l[3],x=we({inputs:{x:e},backend:a,attrs:{shape:[1,A,n.inChannels]}}),b=we({inputs:{x:t},backend:a,attrs:{shape:[1,n.inChannels,n.outChannels]}}),v=kf({a:x,b,transposeA:f,transposeB:m,backend:a,bias:r,activation:o,preluActivationWeights:s,leakyreluAlpha:i});g=we({inputs:{x:v},backend:a,attrs:{shape:n.outShape}}),y.push(x),y.push(b),y.push(v)}for(let A of y)a.disposeIntermediateTensorInfo(A);return g}function wk({x:e,filter:t,convInfo:n,backend:a,bias:r=null,preluActivationWeights:s=null,leakyreluAlpha:i=0,activation:o=null}){let{filterWidth:l,filterHeight:d,inChannels:u,outWidth:p,outHeight:c,dataFormat:h}=n,f=h==="channelsLast",m=l*d*u,g=c*p,y=[m,g],A=!0,x=!1,b=[],v=we({inputs:{x:e},backend:a,attrs:{shape:e.shape.slice(1)}}),k=we({inputs:{x:t},backend:a,attrs:{shape:[1,m,w.sizeFromShape(t.shape)/m]}});b.push(v),b.push(k);let T=new uQ(y,n),C=[v.shape,[n.padInfo.top,n.padInfo.left],[n.strideHeight,n.strideWidth],[n.dilationHeight,n.dilationWidth],[n.inChannels],[n.filterWidth*n.inChannels],[n.outWidth]],D=a.runWebGLProgram(T,[v],"float32",C),O=we({inputs:{x:D},backend:a,attrs:{shape:[1,y[0],y[1]]}});b.push(D),b.push(O);let F=r!=null,S=s!=null,P=o==="leakyrelu",_=o?bf(o,!0):null,j=new sk(O.shape,k.shape,[1,g,n.outChannels],A,x,F,_,S,P),q=[O,k];if(r&&q.push(r),S&&q.push(s),P){let te=a.makeTensorInfo([],"float32",w.createScalarValue(i,"float32"));q.push(te),b.push(te)}let z=a.runWebGLProgram(j,q,"float32"),X=f?[1,c,p,n.outChannels]:[1,n.outChannels,c,p],Z=we({inputs:{x:z},backend:a,attrs:{shape:X}});b.push(z);for(let te of b)a.disposeIntermediateTensorInfo(te);return Z}function dQ(e){let{inputs:t,backend:n,attrs:a}=e,{x:r,filter:s}=t,{strides:i,pad:o,dataFormat:l,dilations:d,dimRoundingMode:u}=a,p=E.convertConv2DDataFormat(l),c=E.computeConv2DInfo(r.shape,s.shape,i,d,o,u,!1,p),h;if(c.filterHeight===1&&c.filterWidth===1&&c.dilationHeight===1&&c.dilationWidth===1&&c.strideHeight===1&&c.strideWidth===1&&(c.padInfo.type==="SAME"||c.padInfo.type==="VALID"))h=vk({x:r,filter:s,convInfo:c,backend:n});else if(ne().getBool("WEBGL_CONV_IM2COL")&&r.shape[0]===1)h=wk({x:r,filter:s,convInfo:c,backend:n});else{let m=new bk(c);h=n.runWebGLProgram(m,[r,s],"float32")}let f=we({inputs:{x:h},backend:n,attrs:{shape:c.outShape}});return n.disposeIntermediateTensorInfo(h),f}var pQ={kernelName:ni,backendName:"webgl",kernelFunc:dQ},cQ=class{constructor(e){this.variableNames=["x","dy"],this.outputShape=e.filterShape;let t=e.strideHeight,n=e.strideWidth,a=e.padInfo.top,r=e.padInfo.left,s=e.dataFormat==="channelsLast";this.userCode= `
2021-09-11 16:29:31 +02:00
void main ( ) {
ivec4 coords = getOutputCoords ( ) ;
int wR = coords . x ;
int wC = coords . y ;
int d1 = coords . z ;
int d2 = coords . w ;
// Convolve x(?, ?, d1) with dy(:, :, d2) to get dw(wR, wC, d1, d2).
// ? = to be determined. : = across all values in that axis.
float dotProd = 0.0 ;
for ( int b = 0 ; b < $ { e . batchSize } ; b ++ ) {
for ( int yR = 0 ; yR < $ { e . outHeight } ; yR ++ ) {
2021-10-22 22:09:52 +02:00
int xR = wR + yR * $ { t } - $ { a } ;
2021-09-11 16:29:31 +02:00
if ( xR < 0 || xR >= $ { e . inHeight } ) {
continue ;
}
for ( int yC = 0 ; yC < $ { e . outWidth } ; yC ++ ) {
2021-10-04 23:03:36 +02:00
int xC = wC + yC * $ { n } - $ { r } ;
2021-09-11 16:29:31 +02:00
if ( xC < 0 || xC >= $ { e . inWidth } ) {
continue ;
}
2021-10-22 22:09:52 +02:00
if ( $ { s } ) {
2021-09-11 16:29:31 +02:00
float dyValue = getDy ( b , yR , yC , d2 ) ;
float xValue = getX ( b , xR , xC , d1 ) ;
dotProd += ( xValue * dyValue ) ;
2021-09-05 22:42:11 +02:00
} else {
2021-09-11 16:29:31 +02:00
float dyValue = getDy ( b , d2 , yR , yC ) ;
float xValue = getX ( b , d1 , xR , xC ) ;
dotProd += ( xValue * dyValue ) ;
2021-09-01 00:24:30 +02:00
}
2021-09-11 16:29:31 +02:00
2021-09-01 00:24:30 +02:00
}
2021-09-11 16:29:31 +02:00
}
}
setOutput ( dotProd ) ;
}
2021-10-22 22:09:52 +02:00
` }},hQ=class{constructor(e){this.variableNames=["dy","W"],this.outputShape=e.inShape;let t=e.filterHeight,n=e.filterWidth,a=e.strideHeight,r=e.strideWidth,s=e.dataFormat==="channelsLast",i=t-1-e.padInfo.top,o=n-1-e.padInfo.left,l=s?1:2,d=s?2:3,u=s?3:1;this.userCode= `
const ivec2 pads = ivec2 ( $ { i } , $ { o } ) ;
2021-09-01 00:24:30 +02:00
2021-09-11 16:29:31 +02:00
void main ( ) {
ivec4 coords = getOutputCoords ( ) ;
int batch = coords [ 0 ] ;
2021-10-07 16:33:10 +02:00
int d1 = coords [ $ { u } ] ;
2021-09-11 16:29:31 +02:00
2021-10-22 22:09:52 +02:00
ivec2 dyCorner = ivec2 ( coords [ $ { l } ] , coords [ $ { d } ] ) - pads ;
2021-09-11 16:29:31 +02:00
int dyRCorner = dyCorner . x ;
int dyCCorner = dyCorner . y ;
// Convolve dy(?, ?, d2) with w(:, :, d1, d2) to compute dx(xR, xC, d1).
// ? = to be determined. : = across all values in that axis.
float dotProd = 0.0 ;
for ( int wR = 0 ; wR < $ { t } ; wR ++ ) {
2021-10-22 22:09:52 +02:00
float dyR = float ( dyRCorner + wR ) / $ { a } . 0 ;
2021-09-11 16:29:31 +02:00
if ( dyR < 0.0 || dyR >= $ { e . outHeight } . 0 || fract ( dyR ) > 0.0 ) {
continue ;
}
int idyR = int ( dyR ) ;
int wRPerm = $ { t } - 1 - wR ;
for ( int wC = 0 ; wC < $ { n } ; wC ++ ) {
2021-10-04 23:03:36 +02:00
float dyC = float ( dyCCorner + wC ) / $ { r } . 0 ;
2021-09-11 16:29:31 +02:00
if ( dyC < 0.0 || dyC >= $ { e . outWidth } . 0 ||
fract ( dyC ) > 0.0 ) {
continue ;
}
int idyC = int ( dyC ) ;
int wCPerm = $ { n } - 1 - wC ;
for ( int d2 = 0 ; d2 < $ { e . outChannels } ; d2 ++ ) {
2021-10-22 22:09:52 +02:00
if ( $ { s } ) {
2021-09-11 16:29:31 +02:00
float xValue = getDy ( batch , idyR , idyC , d2 ) ;
float wValue = getW ( wRPerm , wCPerm , d1 , d2 ) ;
dotProd += xValue * wValue ;
2021-09-05 22:42:11 +02:00
} else {
2021-09-11 16:29:31 +02:00
float xValue = getDy ( batch , d2 , idyR , idyC ) ;
float wValue = getW ( wRPerm , wCPerm , d1 , d2 ) ;
dotProd += xValue * wValue ;
2021-09-05 22:42:11 +02:00
}
2021-09-11 16:29:31 +02:00
}
}
}
setOutput ( dotProd ) ;
}
2021-10-22 22:09:52 +02:00
` }},fQ=class{constructor(e){this.variableNames=["x","dy"],this.outputShape=e.filterShape;let t=e.strideDepth,n=e.strideHeight,a=e.strideWidth,r=e.padInfo.front,s=e.padInfo.top,i=e.padInfo.left;this.userCode= `
2021-09-11 16:29:31 +02:00
void main ( ) {
ivec5 coords = getOutputCoords ( ) ;
int wF = coords . x ;
int wR = coords . y ;
int wC = coords . z ;
int d1 = coords . w ;
int d2 = coords . u ;
float dotProd = 0.0 ;
for ( int b = 0 ; b < $ { e . batchSize } ; b ++ ) {
for ( int yF = 0 ; yF < $ { e . outDepth } ; yF ++ ) {
2021-10-04 23:03:36 +02:00
int xF = wF + yF * $ { t } - $ { r } ;
2021-09-11 16:29:31 +02:00
if ( xF < 0 || xF >= $ { e . inDepth } ) {
continue ;
2021-09-01 00:24:30 +02:00
}
2021-09-11 16:29:31 +02:00
for ( int yR = 0 ; yR < $ { e . outHeight } ; yR ++ ) {
2021-10-22 22:09:52 +02:00
int xR = wR + yR * $ { n } - $ { s } ;
2021-09-01 00:24:30 +02:00
2021-09-11 16:29:31 +02:00
if ( xR < 0 || xR >= $ { e . inHeight } ) {
continue ;
}
for ( int yC = 0 ; yC < $ { e . outWidth } ; yC ++ ) {
2021-10-22 22:09:52 +02:00
int xC = wC + yC * $ { a } - $ { i } ;
2021-09-11 16:29:31 +02:00
if ( xC < 0 || xC >= $ { e . inWidth } ) {
continue ;
2021-09-05 22:42:11 +02:00
}
2021-09-11 16:29:31 +02:00
float dyValue = getDy ( b , yF , yR , yC , d2 ) ;
float xValue = getX ( b , xF , xR , xC , d1 ) ;
dotProd += ( xValue * dyValue ) ;
2021-09-01 00:24:30 +02:00
}
}
2021-09-11 16:29:31 +02:00
}
2021-09-05 22:42:11 +02:00
}
2021-09-11 16:29:31 +02:00
setOutput ( dotProd ) ;
2021-09-01 00:22:16 +02:00
}
2021-10-22 22:09:52 +02:00
` }},mQ=class{constructor(e){this.variableNames=["dy","W"],this.outputShape=e.inShape;let t=e.filterDepth,n=e.filterHeight,a=e.filterWidth,r=e.strideDepth,s=e.strideHeight,i=e.strideWidth,o=t-1-e.padInfo.front,l=n-1-e.padInfo.top,d=a-1-e.padInfo.left;this.userCode= `
const ivec3 pads = ivec3 ( $ { o } , $ { l } , $ { d } ) ;
2021-09-11 16:29:31 +02:00
void main ( ) {
ivec5 coords = getOutputCoords ( ) ;
int batch = coords . x ;
int d1 = coords . u ;
ivec3 dyCorner = ivec3 ( coords . y , coords . z , coords . w ) - pads ;
int dyFCorner = dyCorner . x ;
int dyRCorner = dyCorner . y ;
int dyCCorner = dyCorner . z ;
float dotProd = 0.0 ;
for ( int wF = 0 ; wF < $ { t } ; wF ++ ) {
2021-10-04 23:03:36 +02:00
float dyF = float ( dyFCorner + wF ) / $ { r } . 0 ;
2021-09-11 16:29:31 +02:00
if ( dyF < 0.0 || dyF >= $ { e . outDepth } . 0 || fract ( dyF ) > 0.0 ) {
continue ;
}
int idyF = int ( dyF ) ;
int wFPerm = $ { t } - 1 - wF ;
for ( int wR = 0 ; wR < $ { n } ; wR ++ ) {
2021-10-22 22:09:52 +02:00
float dyR = float ( dyRCorner + wR ) / $ { s } . 0 ;
2021-09-11 16:29:31 +02:00
if ( dyR < 0.0 || dyR >= $ { e . outHeight } . 0 ||
fract ( dyR ) > 0.0 ) {
continue ;
}
int idyR = int ( dyR ) ;
int wRPerm = $ { n } - 1 - wR ;
2021-10-22 22:09:52 +02:00
for ( int wC = 0 ; wC < $ { a } ; wC ++ ) {
float dyC = float ( dyCCorner + wC ) / $ { i } . 0 ;
2021-09-11 16:29:31 +02:00
if ( dyC < 0.0 || dyC >= $ { e . outWidth } . 0 ||
fract ( dyC ) > 0.0 ) {
continue ;
}
int idyC = int ( dyC ) ;
2021-10-22 22:09:52 +02:00
int wCPerm = $ { a } - 1 - wC ;
2021-09-11 16:29:31 +02:00
for ( int d2 = 0 ; d2 < $ { e . outChannels } ; d2 ++ ) {
float xValue = getDy ( batch , idyF , idyR , idyC , d2 ) ;
float wValue = getW ( wFPerm , wRPerm , wCPerm , d1 , d2 ) ;
dotProd += xValue * wValue ;
}
}
}
2021-09-05 22:42:11 +02:00
}
2021-09-11 16:29:31 +02:00
setOutput ( dotProd ) ;
2021-09-05 22:42:11 +02:00
}
2021-10-22 22:09:52 +02:00
` }};function gQ(e){let{inputs:t,backend:n,attrs:a}=e,{x:r,dy:s}=t,{strides:i,pad:o,dataFormat:l,dimRoundingMode:d,filterShape:u}=a,p=E.convertConv2DDataFormat(l),c=E.computeConv2DInfo(r.shape,u,i,1,o,d,!1,p),h=new cQ(c);return n.runWebGLProgram(h,[r,s],"float32")}var yQ={kernelName:Gc,backendName:"webgl",kernelFunc:gQ};function AQ(e){let{inputs:t,backend:n,attrs:a}=e,{dy:r,filter:s}=t,{inputShape:i,strides:o,pad:l,dataFormat:d,dimRoundingMode:u}=a,p=E.convertConv2DDataFormat(d),c=E.computeConv2DInfo(i,s.shape,o,1,l,u,!1,p),h=new hQ(c);return n.runWebGLProgram(h,[r,s],"float32")}var xQ={kernelName:ai,backendName:"webgl",kernelFunc:AQ};function bQ(e){let{inputs:t,backend:n,attrs:a}=e,{x:r,filter:s}=t,{strides:i,pad:o,dilations:l}=a,d=E.computeConv3DInfo(r.shape,s.shape,i,l,o),u=new lQ(d);return n.runWebGLProgram(u,[r,s],"float32")}var vQ={kernelName:bd,backendName:"webgl",kernelFunc:bQ};function wQ(e){let{inputs:t,backend:n,attrs:a}=e,{x:r,dy:s}=t,{strides:i,pad:o,filterShape:l}=a,d=E.computeConv3DInfo(r.shape,l,i,1,o),u=new fQ(d);return n.runWebGLProgram(u,[r,s],"float32")}var kQ={kernelName:Hc,backendName:"webgl",kernelFunc:wQ};function IQ(e){let{inputs:t,backend:n,attrs:a}=e,{dy:r,filter:s}=t,{pad:i,strides:o,inputShape:l}=a,d=E.computeConv3DInfo(l,s.shape,o,1,i),u=new mQ(d);return n.runWebGLProgram(u,[r,s],"float32")}var SQ={kernelName:qc,backendName:"webgl",kernelFunc:IQ},NQ=rk+ `
2021-09-11 16:29:31 +02:00
return cos ( x ) ;
2021-10-22 22:09:52 +02:00
` ,TQ=nt({opSnippet:NQ}),CQ={kernelName:ri,backendName:"webgl",kernelFunc:TQ},EQ= `
2021-09-11 16:29:31 +02:00
float e2x = exp ( - x ) ;
return ( e2x + 1.0 / e2x ) / 2.0 ;
2021-10-22 22:09:52 +02:00
` ,RQ=nt({opSnippet:EQ}),MQ={kernelName:si,backendName:"webgl",kernelFunc:RQ},FQ=class{constructor(e,t,n,a,r){this.variableNames=["Image","Boxes","BoxInd"],this.outputShape=[];let[s,i,o,l]=e,[d]=t,[u,p]=n;this.outputShape=[d,u,p,l];let c=a==="bilinear"?1:0,[h,f]=[ ` $ { i - 1 } . 0 ` , ` $ { o - 1 } . 0 ` ],[m,g,y]=u>1?[ ` $ { ( i - 1 ) / ( u - 1 ) } ` ,"(y2-y1) * height_ratio", ` y1 * $ { h } + float ( y ) * ( height _scale ) ` ]:["0.0","0.0", ` 0.5 * ( y1 + y2 ) * $ { h } ` ],[A,x,b]=p>1?[ ` $ { ( o - 1 ) / ( p - 1 ) } ` ,"(x2-x1) * width_ratio", ` x1 * $ { f } + float ( x ) * ( width _scale ) ` ]:["0.0","0.0", ` 0.5 * ( x1 + x2 ) * $ { f } ` ];this.userCode= `
2021-10-07 16:33:10 +02:00
const float height _ratio = float ( $ { m } ) ;
2021-10-22 22:09:52 +02:00
const float width _ratio = float ( $ { A } ) ;
2021-09-11 16:29:31 +02:00
void main ( ) {
ivec4 coords = getOutputCoords ( ) ;
int b = coords [ 0 ] ;
int y = coords [ 1 ] ;
int x = coords [ 2 ] ;
int d = coords [ 3 ] ;
2021-09-01 00:24:30 +02:00
2021-09-11 16:29:31 +02:00
// get box vals
float y1 = getBoxes ( b , 0 ) ;
float x1 = getBoxes ( b , 1 ) ;
float y2 = getBoxes ( b , 2 ) ;
float x2 = getBoxes ( b , 3 ) ;
2021-09-01 00:24:30 +02:00
2021-09-11 16:29:31 +02:00
// get image in batch index
int bInd = round ( getBoxInd ( b ) ) ;
2021-10-22 22:09:52 +02:00
if ( bInd < 0 || bInd >= $ { s } ) {
2021-09-11 16:29:31 +02:00
return ;
}
float height _scale = $ { g } ;
2021-10-04 23:03:36 +02:00
float width _scale = $ { x } ;
2021-09-11 16:29:31 +02:00
2021-10-22 22:09:52 +02:00
float in _y = $ { y } ;
2021-10-04 23:03:36 +02:00
if ( in _y < 0.0 || in _y > $ { h } ) {
setOutput ( float ( $ { r } ) ) ;
2021-09-11 16:29:31 +02:00
return ;
}
2021-10-04 23:03:36 +02:00
float in _x = $ { b } ;
2021-10-07 16:33:10 +02:00
if ( in _x < 0.0 || in _x > $ { f } ) {
2021-10-04 23:03:36 +02:00
setOutput ( float ( $ { r } ) ) ;
2021-09-11 16:29:31 +02:00
return ;
}
vec2 sourceFracIndexCR = vec2 ( in _x , in _y ) ;
2021-10-22 22:09:52 +02:00
if ( $ { c } == 1 ) {
2021-09-11 16:29:31 +02:00
// Compute the four integer indices.
ivec2 sourceFloorCR = ivec2 ( sourceFracIndexCR ) ;
ivec2 sourceCeilCR = ivec2 ( ceil ( sourceFracIndexCR ) ) ;
float topLeft = getImage ( b , sourceFloorCR . y , sourceFloorCR . x , d ) ;
float bottomLeft = getImage ( b , sourceCeilCR . y , sourceFloorCR . x , d ) ;
float topRight = getImage ( b , sourceFloorCR . y , sourceCeilCR . x , d ) ;
float bottomRight = getImage ( b , sourceCeilCR . y , sourceCeilCR . x , d ) ;
vec2 fracCR = sourceFracIndexCR - vec2 ( sourceFloorCR ) ;
float top = topLeft + ( topRight - topLeft ) * fracCR . x ;
float bottom = bottomLeft + ( bottomRight - bottomLeft ) * fracCR . x ;
float newValue = top + ( bottom - top ) * fracCR . y ;
setOutput ( newValue ) ;
} else {
// Compute the coordinators of nearest neighbor point.
ivec2 sourceNearestCR = ivec2 ( floor (
sourceFracIndexCR + vec2 ( 0.5 , 0.5 ) ) ) ;
float newValue = getImage ( b , sourceNearestCR . y , sourceNearestCR . x , d ) ;
setOutput ( newValue ) ;
}
}
2021-10-22 22:09:52 +02:00
` }},DQ=e=>{let{inputs:t,backend:n,attrs:a}=e,{image:r,boxes:s,boxInd:i}=t,{cropSize:o,method:l,extrapolationValue:d}=a,u=new FQ(r.shape,s.shape,o,l,d);return n.runWebGLProgram(u,[r,s,i],"float32")}, $ Q={kernelName:ol,backendName:"webgl",kernelFunc:DQ},kk=class{constructor(e,t,n){this.variableNames=["x"],this.customUniforms=[{name:"index",type:"float"}],this.outputShape=e;let a=e.length,r=t?"0.0": ` getX ( $ { Ik ( a , "coords" ) } ) ` ,s=e[e.length-1],i="",o="";t?(i=n? ` end != $ { s - 1 } ` :"end != 0",o=n?"end + 1":"end - 1"):(i=n? ` end + pow2 < $ { s } ` :"end >= pow2",o=n?"end + pow2":"end - pow2"),this.userCode= `
2021-09-11 16:29:31 +02:00
void main ( ) {
2021-10-22 22:09:52 +02:00
$ { yt ( a ) } coords = getOutputCoords ( ) ;
int end = $ { Sk ( a , "coords" ) } ;
2021-10-04 23:03:36 +02:00
float val = $ { r } ;
2021-09-11 16:29:31 +02:00
int pow2 = int ( pow ( 2.0 , index ) ) ;
2021-10-22 22:09:52 +02:00
if ( $ { i } ) {
int idx = $ { o } ;
$ { Sk ( a , "coords" ) } = idx ;
val += getX ( $ { Ik ( a , "coords" ) } ) ;
2021-09-11 16:29:31 +02:00
}
setOutput ( val ) ;
2021-09-01 00:22:16 +02:00
}
2021-10-22 22:09:52 +02:00
` }};function Ik(e,t){if(e===1)return ` $ { t } ` ;if(e===2)return ` $ { t } . x , $ { t } . y ` ;if(e===3)return ` $ { t } . x , $ { t } . y , $ { t } . z ` ;if(e===4)return ` $ { t } . x , $ { t } . y , $ { t } . z , $ { t } . w ` ;throw Error( ` Cumulative sum for rank $ { e } is not yet supported ` )}function Sk(e,t){if(e===1)return ` $ { t } ` ;if(e===2)return ` $ { t } . y ` ;if(e===3)return ` $ { t } . z ` ;if(e===4)return ` $ { t } . w ` ;throw Error( ` Cumulative sum for rank $ { e } is not yet supported ` )}function OQ(e){let{inputs:t,backend:n,attrs:a}=e,{x:r}=t,{axis:s,exclusive:i,reverse:o}=a,l=r.shape.length,d=E.getAxesPermutation([s],l),u=r;d!=null&&(u=_n({inputs:{x:r},backend:n,attrs:{perm:d}}));let p=E.getInnerMostAxes(1,l)[0];if(p!==l-1)throw new Error( ` WebGL cumsum shader expects an inner - most axis = $ { r . shape . length - 1 } but got axis = $ { s } ` );let c=u.shape[p],h=ma({inputs:{x:u},backend:n});for(let f=0;f<=Math.ceil(Math.log2(c))-1;f++){let m=new kk(u.shape,!1,o),g=[[f]],y=h;h=n.runWebGLProgram(m,[h],h.dtype,g),n.disposeIntermediateTensorInfo(y)}if(i){let f=new kk(u.shape,i,o),m=h;h=n.runWebGLProgram(f,[h],h.dtype),n.disposeIntermediateTensorInfo(m)}if(d!=null){let f=E.getUndoAxesPermutation(d),m=_n({inputs:{x:h},backend:n,attrs:{perm:f}});return n.disposeIntermediateTensorInfo(h),n.disposeIntermediateTensorInfo(u),m}return h}var _Q={kernelName:ii,backendName:"webgl",kernelFunc:OQ};function PQ(e){let{inputs:t,backend:n,attrs:a}=e,{x:r,weights:s}=t,{size:i,binaryOutput:o}=a;if(r.shape.length===1){let l=n.readSync(r.dataId),d=n.readSync(s.dataId),u=U4(l,d,s.dtype,s.shape,i);return n.makeTensorInfo([i],s.dtype,u)}else if(r.shape.length===2){let l=n.bufferSync(r),d=n.bufferSync(s),u=XK(l,d,i,o);return n.makeTensorInfo(u.shape,s.dtype,u.values)}throw new Error( ` Error in denseBincount : input must be at most rank 2 , but got rank$ { r . shape . length } . ` )}var zQ={kernelName:Xc,backendName:"webgl",kernelFunc:PQ},LQ=class{constructor(e,t,n){this.variableNames=["x"],this.outputShape=[],this.outputShape=e,this.blockSize=t,this.dataFormat=n,this.userCode= `
2021-09-11 16:29:31 +02:00
void main ( ) {
ivec4 coords = getOutputCoords ( ) ;
int b = coords [ 0 ] ;
int h = $ { this . getHeightCoordString ( ) } ;
int w = $ { this . getWidthCoordString ( ) } ;
int d = $ { this . getDepthCoordString ( ) } ;
int in _h = h / $ { t } ;
int offset _h = imod ( h , $ { t } ) ;
int in _w = w / $ { t } ;
int offset _w = imod ( w , $ { t } ) ;
int offset _d = ( offset _h * $ { t } + offset _w ) *
$ { this . getOutputDepthSize ( ) } ;
int in _d = d + offset _d ;
float result = $ { this . getInputSamplingString ( ) } ;
setOutput ( result ) ;
}
2021-10-22 22:09:52 +02:00
` }getHeightCoordString(){return this.dataFormat==="NHWC"?"coords[1]":"coords[2]"}getWidthCoordString(){return this.dataFormat==="NHWC"?"coords[2]":"coords[3]"}getDepthCoordString(){return this.dataFormat==="NHWC"?"coords[3]":"coords[1]"}getOutputDepthSize(){return this.dataFormat==="NHWC"?this.outputShape[3]:this.outputShape[1]}getInputSamplingString(){return this.dataFormat==="NHWC"?"getX(b, in_h, in_w, in_d)":"getX(b, in_d, in_h, in_w)"}};function WQ(e){let{inputs:t,backend:n,attrs:a}=e,{x:r}=t,{blockSize:s,dataFormat:i}=a,o=r.shape[0],l=i==="NHWC"?r.shape[1]:r.shape[2],d=i==="NHWC"?r.shape[2]:r.shape[3],u=i==="NHWC"?r.shape[3]:r.shape[1],p=l*s,c=d*s,h=u/(s*s),f=i==="NHWC"?[o,p,c,h]:[o,h,p,c],m=new LQ(f,s,i);return n.runWebGLProgram(m,[r],r.dtype)}var BQ={kernelName:ll,backendName:"webgl",kernelFunc:WQ},Nk=class{constructor(e,t=!1,n=null,a=!1,r=!1){this.variableNames=["x","W"],this.customUniforms=[{name:"pads",type:"ivec2"},{name:"strides",type:"ivec2"},{name:"dilations",type:"ivec2"},{name:"inDims",type:"ivec2"}],this.outputShape=e.outShape,this.enableShapeUniforms=Ra(this.outputShape.length);let s=e.filterHeight,i=e.filterWidth,o=e.outChannels/e.inChannels,l="",d="";n&&(a?l= ` float activation ( float a ) {
2021-09-11 16:29:31 +02:00
float b = getPreluActivationWeightsAtOutCoords ( ) ;
$ { n }
2021-10-04 23:03:36 +02:00
} ` :r?l= ` float activation ( float a ) {
2021-09-11 16:29:31 +02:00
float b = getLeakyreluAlphaAtOutCoords ( ) ;
$ { n }
} ` :l= `
float activation ( float x ) {
$ { n }
}
2021-10-22 22:09:52 +02:00
` ,d="result = activation(result);");let u=t?"result += getBiasAtOutCoords();":"";t&&this.variableNames.push("bias"),a&&this.variableNames.push("preluActivationWeights"),r&&this.variableNames.push("leakyreluAlpha"),this.userCode= `
2021-09-11 16:29:31 +02:00
$ { l }
2021-09-01 00:24:30 +02:00
void main ( ) {
2021-09-11 16:29:31 +02:00
ivec4 coords = getOutputCoords ( ) ;
int batch = coords . x ;
ivec2 xRCCorner = coords . yz * strides - pads ;
int d2 = coords . w ;
2021-10-22 22:09:52 +02:00
int d1 = d2 / $ { o } ;
int q = d2 - d1 * $ { o } ;
2021-09-01 00:24:30 +02:00
2021-09-11 16:29:31 +02:00
int xRCorner = xRCCorner . x ;
int xCCorner = xRCCorner . y ;
2021-09-01 00:24:30 +02:00
2021-09-11 16:29:31 +02:00
// Convolve x(?, ?, d1) with w(:, :, d1, q) to get y(yR, yC, d2).
// ? = to be determined. : = across all values in that axis.
float dotProd = 0.0 ;
// TO DO(dsmilkov): Flatten the two for loops and vec4 the operations.
2021-10-22 22:09:52 +02:00
for ( int wR = 0 ; wR < $ { s } ; wR ++ ) {
2021-09-11 16:29:31 +02:00
int xR = xRCorner + wR * dilations [ 0 ] ;
2021-09-01 00:24:30 +02:00
2021-09-11 16:29:31 +02:00
if ( xR < 0 || xR >= inDims [ 0 ] ) {
continue ;
}
2021-10-22 22:09:52 +02:00
for ( int wC = 0 ; wC < $ { i } ; wC ++ ) {
2021-09-11 16:29:31 +02:00
int xC = xCCorner + wC * dilations [ 1 ] ;
if ( xC < 0 || xC >= inDims [ 1 ] ) {
continue ;
}
2021-09-01 00:24:30 +02:00
2021-09-11 16:29:31 +02:00
float xVal = getX ( batch , xR , xC , d1 ) ;
float wVal = getW ( wR , wC , d1 , q ) ;
dotProd += xVal * wVal ;
}
2021-09-05 22:42:11 +02:00
}
2021-09-01 00:24:30 +02:00
2021-09-11 16:29:31 +02:00
float result = dotProd ;
$ { u }
2021-10-22 22:09:52 +02:00
$ { d }
2021-09-11 16:29:31 +02:00
setOutput ( result ) ;
}
2021-10-22 22:09:52 +02:00
` }},Tk=class{constructor(e,t=!1,n=null,a=!1,r=!1){this.variableNames=["x","W"],this.packedInputs=!0,this.packedOutput=!0,this.customUniforms=[{name:"pads",type:"ivec2"},{name:"strides",type:"ivec2"},{name:"dilations",type:"ivec2"},{name:"inDims",type:"ivec2"}],this.outputShape=e.outShape,this.enableShapeUniforms=Ra(this.outputShape.length);let s=e.outChannels/e.inChannels,i=e.padInfo.left,o=e.strideWidth,l=e.dilationWidth,d=e.filterHeight,u=e.filterWidth,p=u,c= `
2021-09-11 16:29:31 +02:00
int xR ; int xC ; int xCOffset ;
2021-10-22 22:09:52 +02:00
vec4 wTexel ; vec4 previous ; vec4 final ; ` ;for(let g=0;g<u;g++)c+= `
2021-09-11 16:29:31 +02:00
vec4 xTexelC$ { g * 2 } ;
int xTexelC$ { g * 2 } Ready ;
vec4 xTexelC$ { g * 2 + 1 } ;
int xTexelC$ { g * 2 + 1 } Ready ;
2021-10-22 22:09:52 +02:00
vec4 xC$ { g } ; ` ;c+= `
for ( int r = 0 ; r < $ { d } ; r ++ ) {
` ;for(let g=0;g<u;g++)c+= `
2021-10-22 15:48:27 +02:00
xTexelC$ { g * 2 } = vec4 ( 0.0 ) ;
xTexelC$ { g * 2 } Ready = 0 ;
xTexelC$ { g * 2 + 1 } = vec4 ( 0.0 ) ;
xTexelC$ { g * 2 + 1 } Ready = 0 ;
2021-10-22 22:09:52 +02:00
xC$ { g } = vec4 ( 0.0 ) ; ` ;c+= `
2021-10-22 15:48:27 +02:00
xR = xRCorner + r * dilations [ 0 ] ;
2021-09-11 16:29:31 +02:00
if ( xR >= 0 && xR < inDims [ 0 ] ) {
2021-10-22 22:09:52 +02:00
` ;for(let g=0;g<(p+1)/2;g++){let y=g*2;if(c+= `
xC = xCCorner + $ { y * l } ;
` ,o===1){if(y<u&&(i%2==1?(c+= `
2021-09-11 16:29:31 +02:00
xCOffset = xC + 1 ;
2021-10-22 22:09:52 +02:00
if ( xCOffset >= 0 && xCOffset < inDims [ 1 ] && xTexelC$ { y } Ready == 0 ) {
xTexelC$ { y } = getX ( batch , xR , xCOffset , d1 ) ;
2021-09-01 00:24:30 +02:00
2021-09-11 16:29:31 +02:00
// Need to manually clear unused channels in case
// we're reading from recycled texture.
if ( xCOffset + 1 >= inDims [ 1 ] ) {
2021-10-22 22:09:52 +02:00
xTexelC$ { y } . zw = vec2 ( 0.0 ) ;
2021-09-11 16:29:31 +02:00
}
2021-10-22 22:09:52 +02:00
xTexelC$ { y } Ready = 1 ;
2021-09-11 16:29:31 +02:00
}
2021-10-22 22:09:52 +02:00
` ,l===1&&y>0?c+= `
xC$ { y } = vec4 ( xTexelC$ { y - 2 } . zw , xTexelC$ { y } . xy ) ;
` :c+= `
2021-09-11 16:29:31 +02:00
xCOffset = xC + 1 - 2 ;
2021-09-01 00:24:30 +02:00
2021-09-11 16:29:31 +02:00
if ( xCOffset >= 0 && xCOffset < inDims [ 1 ] ) {
previous = getX ( batch , xR , xCOffset , d1 ) ;
2021-09-01 00:24:30 +02:00
2021-09-11 16:29:31 +02:00
// Need to manually clear unused channels in case
// we're reading from recycled texture.
if ( xCOffset + 1 >= inDims [ 1 ] ) {
previous . zw = vec2 ( 0.0 ) ;
}
2021-09-01 00:24:30 +02:00
2021-10-22 22:09:52 +02:00
xC$ { y } = vec4 ( previous . zw , xTexelC$ { y } . xy ) ;
2021-09-11 16:29:31 +02:00
} else {
2021-10-22 22:09:52 +02:00
xC$ { y } = vec4 ( 0.0 , 0.0 , xTexelC$ { y } . xy ) ;
2021-09-11 16:29:31 +02:00
}
2021-10-22 22:09:52 +02:00
` ):c+= `
if ( xC >= 0 && xC < inDims [ 1 ] && xTexelC$ { y } Ready == 0 ) {
xTexelC$ { y } = getX ( batch , xR , xC , d1 ) ;
2021-09-11 16:29:31 +02:00
if ( xC + 1 >= inDims [ 1 ] ) {
2021-10-22 22:09:52 +02:00
xTexelC$ { y } . zw = vec2 ( 0.0 ) ;
2021-09-11 16:29:31 +02:00
}
2021-10-22 22:09:52 +02:00
xTexelC$ { y } Ready = 1 ;
2021-09-11 16:29:31 +02:00
}
2021-09-01 00:24:30 +02:00
2021-10-22 22:09:52 +02:00
xC$ { y } = xTexelC$ { y } ;
` ,y+1<u)){let A=i%2==0?w.nearestLargerEven(l):l;l%2==0&&i%2==1||l%2!=0&&i%2!=1?(c+= `
xCOffset = xC + imod ( pads [ 1 ] , 2 ) + $ { A } ;
2021-09-01 00:24:30 +02:00
2021-10-22 22:09:52 +02:00
if ( xCOffset >= 0 && xCOffset < inDims [ 1 ] && xTexelC$ { y + 1 } Ready == 0 ) {
xTexelC$ { y + 1 } = getX ( batch , xR , xCOffset , d1 ) ;
2021-09-05 22:42:11 +02:00
2021-09-11 16:29:31 +02:00
// Need to manually clear unused channels in case
// we're reading from recycled texture.
if ( xCOffset + 1 >= inDims [ 1 ] ) {
2021-10-22 22:09:52 +02:00
xTexelC$ { y + 1 } . zw = vec2 ( 0.0 ) ;
2021-09-11 16:29:31 +02:00
}
2021-10-22 22:09:52 +02:00
xTexelC$ { y + 1 } Ready = 1 ;
2021-09-11 16:29:31 +02:00
}
2021-10-22 22:09:52 +02:00
` ,l>1&&(c+= `
2021-09-11 16:29:31 +02:00
xCOffset -= 2 ;
2021-10-22 22:09:52 +02:00
if ( xCOffset >= 0 && xCOffset < inDims [ 1 ] && xTexelC$ { y } Ready == 0 ) {
xTexelC$ { y } = getX ( batch , xR , xCOffset , d1 ) ;
xTexelC$ { y } Ready = 1 ;
2021-09-11 16:29:31 +02:00
}
2021-10-22 22:09:52 +02:00
` ),c+= `
xC$ { y + 1 } = vec4 ( xTexelC$ { y } . zw , xTexelC$ { y + 1 } . xy ) ;
` ):A===1?c+= `
xC$ { y + 1 } = xTexelC$ { y } ;
` :c+= `
xCOffset = xC + $ { A } ;
if ( xCOffset >= 0 && xCOffset < inDims [ 1 ] && xTexelC$ { y + 1 } Ready == 0 ) {
xTexelC$ { y + 1 } = getX ( batch , xR , xCOffset , d1 ) ;
2021-09-11 16:29:31 +02:00
if ( xCOffset + 1 >= inDims [ 1 ] ) {
2021-10-22 22:09:52 +02:00
xTexelC$ { y + 1 } . zw = vec2 ( 0.0 ) ;
2021-09-11 16:29:31 +02:00
}
2021-10-22 22:09:52 +02:00
xTexelC$ { y + 1 } Ready = 1 ;
2021-09-11 16:29:31 +02:00
}
2021-10-22 22:09:52 +02:00
xC$ { y + 1 } = xTexelC$ { y + 1 } ;
` }}else y<u&&(i%2==1?(c+= `
2021-09-11 16:29:31 +02:00
xCOffset = xC + 1 - strides [ 1 ] ;
2021-10-22 22:09:52 +02:00
if ( xCOffset >= 0 && xCOffset < inDims [ 1 ] && xTexelC$ { y } Ready == 0 ) {
xTexelC$ { y } = getX ( batch , xR , xCOffset , d1 ) ;
2021-09-11 16:29:31 +02:00
// Need to manually clear unused channels in case
// we're reading from recycled texture.
if ( xCOffset + 1 >= inDims [ 1 ] ) {
2021-10-22 22:09:52 +02:00
xTexelC$ { y } . zw = vec2 ( 0.0 ) ;
2021-09-11 16:29:31 +02:00
}
2021-10-22 22:09:52 +02:00
xTexelC$ { y } Ready = 1 ;
2021-09-11 16:29:31 +02:00
}
2021-10-22 22:09:52 +02:00
if ( xC + 1 >= 0 && xC + 1 < inDims [ 1 ] && xTexelC$ { y + 1 } Ready == 0 ) {
xTexelC$ { y + 1 } = getX ( batch , xR , xC + 1 , d1 ) ;
2021-09-11 16:29:31 +02:00
// Need to manually clear unused channels in case
// we're reading from recycled texture.
if ( xC + 2 >= inDims [ 1 ] ) {
2021-10-22 22:09:52 +02:00
xTexelC$ { y + 1 } . zw = vec2 ( 0.0 ) ;
2021-09-11 16:29:31 +02:00
}
2021-10-22 22:09:52 +02:00
xTexelC$ { y + 1 } Ready = 1 ;
2021-09-11 16:29:31 +02:00
}
2021-10-22 22:09:52 +02:00
xC$ { y } = vec4 ( xTexelC$ { y } . zw , xTexelC$ { y + 1 } . zw ) ;
` ,y+1<u&&(c+= `
2021-09-11 16:29:31 +02:00
final = vec4 ( 0.0 ) ;
xCOffset = xC + 1 + strides [ 1 ] ;
if ( xCOffset >= 0 && xCOffset < inDims [ 1 ] ) {
final = getX ( batch , xR , xCOffset , d1 ) ;
}
2021-10-22 22:09:52 +02:00
xC$ { y + 1 } = vec4 ( xTexelC$ { y + 1 } . xy , final . xy ) ;
` )):(c+= `
if ( xC >= 0 && xC < inDims [ 1 ] && xTexelC$ { y } Ready == 0 ) {
xTexelC$ { y } = getX ( batch , xR , xC , d1 ) ;
2021-09-11 16:29:31 +02:00
if ( xC + 1 >= inDims [ 1 ] ) {
2021-10-22 22:09:52 +02:00
xTexelC$ { y } . zw = vec2 ( 0.0 ) ;
2021-09-11 16:29:31 +02:00
}
2021-10-22 22:09:52 +02:00
xTexelC$ { y } Ready = 1 ;
2021-09-11 16:29:31 +02:00
}
xCOffset = xC + strides [ 1 ] ;
2021-10-22 22:09:52 +02:00
if ( xCOffset >= 0 && xCOffset < inDims [ 1 ] && xTexelC$ { y + 1 } Ready == 0 ) {
xTexelC$ { y + 1 } = getX ( batch , xR , xCOffset , d1 ) ;
2021-09-11 16:29:31 +02:00
if ( xCOffset + 1 >= inDims [ 1 ] ) {
2021-10-22 22:09:52 +02:00
xTexelC$ { y + 1 } . zw = vec2 ( 0. ) ;
2021-09-11 16:29:31 +02:00
}
2021-10-22 22:09:52 +02:00
xTexelC$ { y + 1 } Ready = 1 ;
2021-09-11 16:29:31 +02:00
}
2021-10-22 22:09:52 +02:00
xC$ { y } = vec4 (
xTexelC$ { y } . xy , xTexelC$ { y + 1 } . xy ) ;
` ,y+1<u&&(c+= `
xC$ { y + 1 } = vec4 ( xTexelC$ { y } . zw , xTexelC$ { y + 1 } . zw ) ;
` )));y<u&&(c+= `
wTexel = getW ( r , $ { y } , d1 , q ) ;
dotProd += xC$ { y } * vec4 ( wTexel . xz , wTexel . xz ) ;
` ,y+1<u&&(c+= `
wTexel = getW ( r , $ { y + 1 } , d1 , q ) ;
dotProd += xC$ { y + 1 } * vec4 ( wTexel . xz , wTexel . xz ) ;
` ))}c+= `
2021-10-22 15:48:27 +02:00
}
2021-10-22 22:09:52 +02:00
` ,c+= `
2021-10-22 15:48:27 +02:00
}
2021-10-22 22:09:52 +02:00
` ;let h="",f="";n&&(a?h= ` vec4 activation ( vec4 a ) {
2021-09-11 16:29:31 +02:00
vec4 b = getPreluActivationWeightsAtOutCoords ( ) ;
$ { n }
2021-10-04 23:03:36 +02:00
} ` :r?h= ` vec4 activation ( vec4 a ) {
2021-09-11 16:29:31 +02:00
vec4 b = getLeakyreluAlphaAtOutCoords ( ) ;
$ { n }
2021-10-04 23:03:36 +02:00
} ` :h= ` vec4 activation ( vec4 x ) {
2021-09-11 16:29:31 +02:00
$ { n }
2021-10-22 22:09:52 +02:00
} ` ,f="result = activation(result);");let m=t?"result += getBiasAtOutCoords();":"";t&&this.variableNames.push("bias"),a&&this.variableNames.push("preluActivationWeights"),r&&this.variableNames.push("leakyreluAlpha"),this.userCode= `
2021-10-04 23:03:36 +02:00
$ { h }
2021-09-11 16:29:31 +02:00
void main ( ) {
ivec4 coords = getOutputCoords ( ) ;
int batch = coords . x ;
ivec2 xRCCorner = coords . yz * strides - pads ;
int d2 = coords . w ;
2021-10-22 22:09:52 +02:00
int d1 = d2 / $ { s } ;
int q = d2 - d1 * $ { s } ;
2021-09-11 16:29:31 +02:00
int xRCorner = xRCCorner . x ;
int xCCorner = xRCCorner . y ;
//intialize dotProd with a small epsilon seems to reduce GPU accuracy loss.
vec4 dotProd = vec4 ( 0.000000000000001 ) ;
2021-10-22 22:09:52 +02:00
$ { c }
2021-09-11 16:29:31 +02:00
vec4 result = dotProd - vec4 ( 0.000000000000001 ) ;
2021-09-28 23:07:34 +02:00
$ { m }
2021-10-07 16:33:10 +02:00
$ { f }
2021-09-11 16:29:31 +02:00
setOutput ( result ) ;
2021-09-05 22:42:11 +02:00
}
2021-10-22 22:09:52 +02:00
` }};function VQ(e){let{inputs:t,backend:n,attrs:a}=e,{x:r,filter:s}=t,{strides:i,pad:o,dilations:l,dimRoundingMode:d}=a,u=l;u==null&&(u=[1,1]),w.assert(E.eitherStridesOrDilationsAreOne(i,u),()=> ` Error in depthwiseConv2d : Either strides or dilations must be 1. Got strides $ { i } and dilations '${u}' ` );let p=E.computeConv2DInfo(r.shape,s.shape,i,u,o,d,!0),c;ne().getBool("WEBGL_PACK_DEPTHWISECONV")&&p.strideWidth<=2&&p.outChannels/p.inChannels==1?c=new Tk(p):c=new Nk(p);let h=[[p.padInfo.top,p.padInfo.left],[p.strideHeight,p.strideWidth],[p.dilationHeight,p.dilationWidth],[p.inHeight,p.inWidth]];return n.runWebGLProgram(c,[r,s],"float32",h)}var UQ={kernelName:oi,backendName:"webgl",kernelFunc:VQ},jQ=class{constructor(e){this.variableNames=["x","dy"],this.outputShape=e.filterShape;let t=e.strideHeight,n=e.strideWidth,a=e.padInfo.top,r=e.padInfo.left,s=e.outChannels/e.inChannels;this.userCode= `
2021-09-11 16:29:31 +02:00
void main ( ) {
ivec4 coords = getOutputCoords ( ) ;
int wR = coords . x ;
int wC = coords . y ;
int d1 = coords . z ;
int dm = coords . w ;
2021-10-22 22:09:52 +02:00
int d2 = d1 * $ { s } + dm ;
2021-09-11 16:29:31 +02:00
float dotProd = 0.0 ;
// TO DO: Vec4 over the batch size
for ( int b = 0 ; b < $ { e . batchSize } ; b ++ ) {
for ( int yR = 0 ; yR < $ { e . outHeight } ; yR ++ ) {
2021-10-22 22:09:52 +02:00
int xR = wR + yR * $ { t } - $ { a } ;
2021-09-11 16:29:31 +02:00
if ( xR < 0 || xR >= $ { e . inHeight } ) {
continue ;
}
for ( int yC = 0 ; yC < $ { e . outWidth } ; yC ++ ) {
2021-10-04 23:03:36 +02:00
int xC = wC + yC * $ { n } - $ { r } ;
2021-09-11 16:29:31 +02:00
if ( xC < 0 || xC >= $ { e . inWidth } ) {
continue ;
}
float dyValue = getDy ( b , yR , yC , d2 ) ;
float xValue = getX ( b , xR , xC , d1 ) ;
dotProd += ( xValue * dyValue ) ;
}
}
}
setOutput ( dotProd ) ;
2021-09-05 22:42:11 +02:00
}
2021-10-22 22:09:52 +02:00
` }},GQ=class{constructor(e){this.variableNames=["dy","W"],this.outputShape=e.inShape;let t=e.filterHeight,n=e.filterWidth,a=e.strideHeight,r=e.strideWidth,s=t-1-e.padInfo.top,i=n-1-e.padInfo.left,o=e.outChannels/e.inChannels;this.userCode= `
const ivec2 pads = ivec2 ( $ { s } , $ { i } ) ;
2021-09-11 16:29:31 +02:00
void main ( ) {
ivec4 coords = getOutputCoords ( ) ;
int batch = coords [ 0 ] ;
int d1 = coords [ 3 ] ;
ivec2 dyCorner = coords . yz - pads ;
int dyRCorner = dyCorner . x ;
int dyCCorner = dyCorner . y ;
float dotProd = 0.0 ;
for ( int wR = 0 ; wR < $ { t } ; wR ++ ) {
2021-10-22 22:09:52 +02:00
float dyR = float ( dyRCorner + wR ) / $ { a } . 0 ;
2021-09-11 16:29:31 +02:00
if ( dyR < 0.0 || dyR >= $ { e . outHeight } . 0 || fract ( dyR ) > 0.0 ) {
continue ;
}
int idyR = int ( dyR ) ;
int wRPerm = $ { t } - 1 - wR ;
for ( int wC = 0 ; wC < $ { n } ; wC ++ ) {
2021-10-04 23:03:36 +02:00
float dyC = float ( dyCCorner + wC ) / $ { r } . 0 ;
2021-09-11 16:29:31 +02:00
if ( dyC < 0.0 || dyC >= $ { e . outWidth } . 0 ||
fract ( dyC ) > 0.0 ) {
continue ;
}
int idyC = int ( dyC ) ;
int wCPerm = $ { n } - 1 - wC ;
// TO DO: Vec4 over the channelMul
2021-10-22 22:09:52 +02:00
for ( int dm = 0 ; dm < $ { o } ; dm ++ ) {
int d2 = d1 * $ { o } + dm ;
2021-09-11 16:29:31 +02:00
float xValue = getDy ( batch , idyR , idyC , d2 ) ;
float wValue = getW ( wRPerm , wCPerm , d1 , dm ) ;
dotProd += xValue * wValue ;
}
}
}
setOutput ( dotProd ) ;
2021-09-05 22:42:11 +02:00
}
2021-10-22 22:09:52 +02:00
` }};function HQ(e){let{inputs:t,backend:n,attrs:a}=e,{x:r,dy:s}=t,{strides:i,dilations:o,pad:l,dimRoundingMode:d,filterShape:u}=a,p=E.computeConv2DInfo(r.shape,u,i,o,l,d,!0),c=new jQ(p);return n.runWebGLProgram(c,[r,s],"float32")}var qQ={kernelName:Kc,backendName:"webgl",kernelFunc:HQ};function XQ(e){let{inputs:t,backend:n,attrs:a}=e,{dy:r,filter:s}=t,{strides:i,dilations:o,pad:l,dimRoundingMode:d,inputShape:u}=a,p=E.computeConv2DInfo(u,s.shape,i,o,l,d,!0),c=new GQ(p);return n.runWebGLProgram(c,[r,s],"float32")}var KQ={kernelName:Zc,backendName:"webgl",kernelFunc:XQ},ZQ=class{constructor(e){this.variableNames=["X"],this.outputShape=[e,e],this.userCode= `
2021-09-11 16:29:31 +02:00
void main ( ) {
ivec2 coords = getOutputCoords ( ) ;
float val = coords [ 0 ] == coords [ 1 ] ? getX ( coords [ 0 ] ) : 0.0 ;
setOutput ( val ) ;
2021-09-05 22:42:11 +02:00
}
2021-10-22 22:09:52 +02:00
` }};function YQ(e){let{inputs:t,backend:n}=e,{x:a}=t,r=[...a.shape,...a.shape],s=w.sizeFromShape(a.shape),i=we({inputs:{x:a},backend:n,attrs:{shape:[s]}}),o=new ZQ(s),l=n.runWebGLProgram(o,[i],i.dtype),d=we({inputs:{x:l},backend:n,attrs:{shape:r}});return n.disposeIntermediateTensorInfo(i),n.disposeIntermediateTensorInfo(l),d}var JQ={kernelName:Yc,backendName:"webgl",kernelFunc:YQ},QQ=class{constructor(e){this.variableNames=["x","W"],this.outputShape=e.outShape;let{inHeight:t,inWidth:n,padInfo:a,strideHeight:r,strideWidth:s,filterHeight:i,filterWidth:o,dilationHeight:l,dilationWidth:d}=e,{top:u,left:p}=a;this.userCode= `
const ivec2 strides = ivec2 ( $ { r } , $ { s } ) ;
const ivec2 pads = ivec2 ( $ { u } , $ { p } ) ;
2021-09-11 16:29:31 +02:00
const float neg _infinity = - 3.4 e38 ;
void main ( ) {
ivec4 coords = getOutputCoords ( ) ;
int batch = coords . x ;
int d1 = coords . w ;
ivec2 outTopLeftCorner =
coords . yz * strides - pads ;
int hBeg = outTopLeftCorner . x ;
int wBeg = outTopLeftCorner . y ;
float curVal = neg _infinity ;
2021-10-22 22:09:52 +02:00
for ( int h = 0 ; h < $ { i } ; h ++ ) {
2021-09-11 16:29:31 +02:00
int hIn = hBeg + h * $ { l } ;
if ( hIn >= 0 && hIn < $ { t } ) {
2021-10-22 22:09:52 +02:00
for ( int w = 0 ; w < $ { o } ; w ++ ) {
int wIn = wBeg + w * $ { d } ;
2021-09-11 16:29:31 +02:00
if ( wIn >= 0 && wIn < $ { n } ) {
float xVal = getX ( batch , hIn , wIn , d1 ) ;
float wVal = getW ( h , w , d1 ) ;
float val = xVal + wVal ;
if ( val > curVal ) {
curVal = val ;
}
}
}
}
}
float result = curVal ;
setOutput ( result ) ;
2021-09-05 22:42:11 +02:00
}
2021-10-22 22:09:52 +02:00
` }};function eee(e){let{inputs:t,backend:n,attrs:a}=e,{x:r,filter:s}=t,{strides:i,pad:o,dilations:l}=a,d=E.computeDilation2DInfo(r.shape,s.shape,i,o,"NHWC",l),u,p=new QQ(d);u=n.runWebGLProgram(p,[r,s],"float32");let c=we({inputs:{x:u},backend:n,attrs:{shape:d.outShape}});return n.disposeIntermediateTensorInfo(u),c}var tee={kernelName:vd,backendName:"webgl",kernelFunc:eee};function nee(e){let{inputs:t,backend:n,attrs:a}=e,{equation:r}=a,s=t,{allDims:i,summedDims:o,idDims:l}=E.decodeEinsumEquation(r,s.length);E.checkEinsumDimSizes(i.length,l,s);let{path:d,steps:u}=E.getEinsumComputePath(o,l),p=u.length,c=null,h=i.length,f=[];for(let m=0;m<p;++m){for(let g of u[m]){let{permutationIndices:y,expandDims:A}=E.getEinsumPermutation(h,l[g]),x;E.isIdentityPermutation(y)?x=s[g]:(x=_n({inputs:{x:s[g]},backend:n,attrs:{perm:y}}),f.push(x));let b=x.shape.slice();for(let v=0;v<A.length;++v)b.splice(A[v],0,1);w.arraysEqual(x.shape,b)||(x=we({inputs:{x},backend:n,attrs:{shape:b}}),f.push(x)),c===null?c=x:(c=G2({inputs:{a:x,b:c},backend:n}),f.push(c))}m<p-1&&(d[m]>=0&&(c=wf({inputs:{x:c},backend:n,attrs:{axis:d[m]-(i.length-h),keepDims:!1}}),f.push(c)),h--)}for(let m of f)m!==c&&n.disposeIntermediateTensorInfo(m);return c}var aee={kernelName:eh,backendName:"webgl",kernelFunc:nee},ree="return (x >= 0.0) ? x : (exp(x) - 1.0);",see= `
2021-09-11 16:29:31 +02:00
vec4 result ;
result . r = ( x . r >= 0.0 ) ? x . r : ( exp ( x . r ) - 1.0 ) ;
result . g = ( x . g >= 0.0 ) ? x . g : ( exp ( x . g ) - 1.0 ) ;
result . b = ( x . b >= 0.0 ) ? x . b : ( exp ( x . b ) - 1.0 ) ;
result . a = ( x . a >= 0.0 ) ? x . a : ( exp ( x . a ) - 1.0 ) ;
return result ;
2021-10-22 22:09:52 +02:00
` ,iee=nt({opSnippet:ree,packedOpSnippet:see}),oee={kernelName:ui,backendName:"webgl",kernelFunc:iee},lee="return (b >= 1.0) ? a : a * (b + 1.0);",uee= `
2021-09-11 16:29:31 +02:00
vec4 bGTEZero = vec4 ( greaterThanEqual ( b , vec4 ( 0. ) ) ) ;
return ( bGTEZero * a ) + ( ( vec4 ( 1.0 ) - bGTEZero ) * ( a * ( b + vec4 ( 1.0 ) ) ) ) ;
2021-10-22 22:09:52 +02:00
` ,dee=e=>{let{inputs:t,backend:n}=e,{dy:a,y:r}=t,s=ne().getBool("WEBGL_PACK_BINARY_OPERATIONS")?new Lp(uee,a.shape,r.shape):new zu(lee,a.shape,r.shape);return n.runWebGLProgram(s,[a,r],a.dtype)},pee={kernelName:th,backendName:"webgl",kernelFunc:dee},cee= `
2021-09-11 16:29:31 +02:00
return vec4 ( equal ( a , b ) ) ;
2021-10-22 22:09:52 +02:00
` ,hee="return float(a == b);",fee=vn({opSnippet:hee,packedOpSnippet:cee,dtype:"bool",cpuKernelImpl:YK}),mee={kernelName:dl,backendName:"webgl",kernelFunc:fee},gee= `
2021-09-11 16:29:31 +02:00
// Error function is calculated approximately with elementary function.
// See "Handbook of Mathematical Functions with Formulas,
// Graphs, and Mathematical Tables", Abramowitz and Stegun.
2021-10-22 22:09:52 +02:00
float p = $ { E . ERF _P } ;
float a1 = $ { E . ERF _A1 } ;
float a2 = $ { E . ERF _A2 } ;
float a3 = $ { E . ERF _A3 } ;
float a4 = $ { E . ERF _A4 } ;
float a5 = $ { E . ERF _A5 } ;
2021-09-11 16:29:31 +02:00
float sign = sign ( x ) ;
x = abs ( x ) ;
float t = 1.0 / ( 1.0 + p * x ) ;
return sign * ( 1.0 - ( ( ( ( ( a5 * t + a4 ) * t ) + a3 ) * t + a2 ) * t + a1 ) * t * exp ( - x * x ) ) ;
2021-10-22 22:09:52 +02:00
` ,yee=nt({opSnippet:gee}),Aee={kernelName:ul,backendName:"webgl",kernelFunc:yee},Ck="return exp(x);",Ek=nt({opSnippet:Ck,packedOpSnippet:Ck,cpuKernelImpl:JK,dtype:"float32"}),xee={kernelName:di,backendName:"webgl",kernelFunc:Ek};function K2(e){let{inputs:t,attrs:n,backend:a}=e,{dim:r}=n,{input:s}=t,i=s.shape.length,o=s.shape.slice(),l=r;return r<0&&(w.assert(-(i+1)<=r,()=> ` Axis must be in the interval [ $ { - ( i + 1 ) } , $ { i } ] ` ),l=i+r+1),o.splice(l,0,1),we({inputs:{x:s},backend:a,attrs:{shape:o}})}var bee={kernelName:pl,backendName:"webgl",kernelFunc:K2},Rk="return exp(x) - 1.0;",vee=nt({opSnippet:Rk,packedOpSnippet:Rk,cpuKernelImpl:QK}),wee={kernelName:cl,backendName:"webgl",kernelFunc:vee},Mk=class{constructor(e,t,n){this.variableNames=["real","imag"];let a=t[1];this.outputShape=t;let r=n? ` 2.0 * $ { Math . PI } ` : ` - 2.0 * $ { Math . PI } ` ,s=n? ` $ { a } . 0 ` :"1.0",i;if(e==="real")i="return real * expR - imag * expI;";else if(e==="imag")i="return real * expI + imag * expR;";else throw new Error( ` FFT component must be either "real" or "imag" , got $ { e } . ` );this.userCode= `
2021-10-04 23:03:36 +02:00
const float exponentMultiplier = $ { r } ;
2021-09-11 16:29:31 +02:00
float unaryOpComplex ( float real , float expR , float imag , float expI ) {
2021-10-22 22:09:52 +02:00
$ { i }
2021-09-01 00:24:30 +02:00
}
2021-09-11 16:29:31 +02:00
float mulMatDFT ( int batch , int index ) {
2021-10-22 22:09:52 +02:00
float indexRatio = float ( index ) / float ( $ { a } ) ;
2021-09-11 16:29:31 +02:00
float exponentMultiplierTimesIndexRatio =
exponentMultiplier * indexRatio ;
float result = 0.0 ;
2021-10-22 22:09:52 +02:00
for ( int i = 0 ; i < $ { a } ; i ++ ) {
2021-09-11 16:29:31 +02:00
// x = (-2|2 * PI / N) * index * i;
float x = exponentMultiplierTimesIndexRatio * float ( i ) ;
float expR = cos ( x ) ;
float expI = sin ( x ) ;
float real = getReal ( batch , i ) ;
float imag = getImag ( batch , i ) ;
result +=
2021-10-22 22:09:52 +02:00
unaryOpComplex ( real , expR , imag , expI ) / $ { s } ;
2021-09-11 16:29:31 +02:00
}
return result ;
2021-08-14 17:16:26 +02:00
}
2021-09-11 16:29:31 +02:00
void main ( ) {
ivec2 coords = getOutputCoords ( ) ;
setOutput ( mulMatDFT ( coords [ 0 ] , coords [ 1 ] ) ) ;
}
2021-10-22 22:09:52 +02:00
` }};function Fk(e,t,n){let a=n.texData.get(e.dataId),r=w.sizeFromShape(e.shape),s=e.shape[e.shape.length-1],i=r/s,o=we({inputs:{x:e},backend:n,attrs:{shape:[i,s]}}),l=o.shape,d=new Mk("real",l,t),u=new Mk("imag",l,t),p=[{dataId:a.complexTensorInfos.real.dataId,dtype:a.complexTensorInfos.real.dtype,shape:l},{dataId:a.complexTensorInfos.imag.dataId,dtype:a.complexTensorInfos.imag.dtype,shape:l}],c=n.runWebGLProgram(d,p,"float32"),h=n.runWebGLProgram(u,p,"float32"),f=Ds({inputs:{real:c,imag:h},backend:n});n.disposeIntermediateTensorInfo(c),n.disposeIntermediateTensorInfo(h);let m=we({inputs:{x:f},backend:n,attrs:{shape:e.shape}});return n.disposeIntermediateTensorInfo(o),n.disposeIntermediateTensorInfo(f),m}function kee(e){let{inputs:t,backend:n}=e,{input:a}=t;return Fk(a,!1,n)}var Iee={kernelName:nh,backendName:"webgl",kernelFunc:kee},See=class{constructor(e,t){this.outputShape=[],this.customUniforms=[{name:"value",type:"float"}],this.variableNames=["x"],this.outputShape=e,this.userCode= `
2021-09-11 16:29:31 +02:00
void main ( ) {
// Input can be obtained from uniform value.
setOutput ( value ) ;
}
2021-10-22 22:09:52 +02:00
` }};function Vp(e){let{backend:t,attrs:n}=e,{shape:a,value:r}=n,{dtype:s}=n;if(s=s||w.inferDtype(r),s==="string"){let i=w.getArrayFromDType(s,w.sizeFromShape(a));return i.fill(r),t.makeTensorInfo(a,s,i)}else{let i=new See(a,r),o=[[r]];return t.runWebGLProgram(i,[],s,o)}}var Nee={kernelName:wd,backendName:"webgl",kernelFunc:Vp},Tee=class{constructor(e){this.variableNames=["Image"],this.outputShape=[];let t=e[2];this.outputShape=e,this.userCode= `
2021-09-11 16:29:31 +02:00
void main ( ) {
ivec4 coords = getOutputCoords ( ) ;
int x = coords [ 2 ] ;
int coordX = $ { t } - x - 1 ;
float outputValue ;
if ( coordX >= 0 && coordX < $ { t } ) {
outputValue = getImage ( coords [ 0 ] , coords [ 1 ] , coordX , coords [ 3 ] ) ;
} else {
outputValue = getImage ( coords [ 0 ] , coords [ 1 ] , coords [ 2 ] , coords [ 3 ] ) ;
}
setOutput ( outputValue ) ;
}
2021-10-22 22:09:52 +02:00
` }},Cee={kernelName:hl,backendName:"webgl",kernelFunc:({inputs:e,backend:t})=>{let{image:n}=e,a=t,r=new Tee(n.shape);return a.runWebGLProgram(r,[n],n.dtype)}},Dk="return floor(x);",Eee=nt({opSnippet:Dk,packedOpSnippet:Dk,cpuKernelImpl:eZ}),Ree={kernelName:pi,backendName:"webgl",kernelFunc:Eee},Mee= `
2021-09-11 16:29:31 +02:00
float s = sign ( a ) * sign ( b ) ;
int ia = round ( a ) ;
int ib = round ( b ) ;
if ( ib != 0 ) {
// Windows (D3D) wants guaranteed non-zero int division at compile-time.
return float ( idiv ( ia , ib , s ) ) ;
} else {
return NAN ;
2021-09-05 22:42:11 +02:00
}
2021-10-22 22:09:52 +02:00
` ,Fee= `
2021-09-11 16:29:31 +02:00
ivec4 ia = round ( a ) ;
ivec4 ib = round ( b ) ;
bvec4 cond = notEqual ( ib , ivec4 ( 0 ) ) ;
ivec4 result = ivec4 ( 0 ) ;
vec4 s = sign ( a ) * sign ( b ) ;
// Windows (D3D) wants guaranteed non-zero int division at compile-time.
if ( cond [ 0 ] ) {
result [ 0 ] = idiv ( ia [ 0 ] , ib [ 0 ] , s [ 0 ] ) ;
2021-09-05 22:42:11 +02:00
}
2021-09-11 16:29:31 +02:00
if ( cond [ 1 ] ) {
result [ 1 ] = idiv ( ia [ 1 ] , ib [ 1 ] , s [ 1 ] ) ;
2021-09-05 22:42:11 +02:00
}
2021-09-11 16:29:31 +02:00
if ( cond [ 2 ] ) {
result [ 2 ] = idiv ( ia [ 2 ] , ib [ 2 ] , s [ 2 ] ) ;
2021-09-05 22:42:11 +02:00
}
2021-09-11 16:29:31 +02:00
if ( cond [ 3 ] ) {
result [ 3 ] = idiv ( ia [ 3 ] , ib [ 3 ] , s [ 3 ] ) ;
2021-09-05 22:42:11 +02:00
}
2021-09-11 16:29:31 +02:00
return vec4 ( result ) ;
2021-10-22 22:09:52 +02:00
` ,Dee=vn({opSnippet:Mee,packedOpSnippet:Fee,dtype:"int32"}), $ ee={kernelName:ci,backendName:"webgl",kernelFunc:Dee},Oee=class{constructor(e){this.variableNames=["A"];let t= $ n(),[n,a]=e;this.outputShape=e,this.userCode= `
2021-09-11 16:29:31 +02:00
void main ( ) {
ivec3 coords = getOutputCoords ( ) ;
int texR = coords [ 0 ] ;
int texC = coords [ 1 ] ;
int depth = coords [ 2 ] ;
2021-10-22 22:09:52 +02:00
vec2 uv = ( vec2 ( texC , texR ) + halfCR ) / vec2 ( $ { a } . 0 , $ { n } . 0 ) ;
2021-09-11 16:29:31 +02:00
vec4 values = $ { t . texture2D } ( A , uv ) ;
float value ;
if ( depth == 0 ) {
value = values . r ;
} else if ( depth == 1 ) {
value = values . g ;
} else if ( depth == 2 ) {
value = values . b ;
} else if ( depth == 3 ) {
value = values . a ;
}
setOutput ( floor ( value * 255.0 + 0.5 ) ) ;
2021-09-05 22:42:11 +02:00
}
2021-10-22 22:09:52 +02:00
` }},_ee=class{constructor(e){this.variableNames=["A"],this.packedInputs=!1,this.packedOutput=!0;let t= $ n(),[n,a]=e;this.outputShape=e,this.userCode= `
2021-09-11 16:29:31 +02:00
void main ( ) {
ivec3 coords = getOutputCoords ( ) ;
int texR = coords [ 0 ] ;
int texC = coords [ 1 ] ;
int depth = coords [ 2 ] ;
vec4 result = vec4 ( 0. ) ;
for ( int row = 0 ; row <= 1 ; row ++ ) {
for ( int col = 0 ; col <= 1 ; col ++ ) {
texC = coords [ 1 ] + row ;
depth = coords [ 2 ] + col ;
vec2 uv = ( vec2 ( texC , texR ) + halfCR ) /
2021-10-22 22:09:52 +02:00
vec2 ( $ { a } . 0 , $ { n } . 0 ) ;
2021-09-11 16:29:31 +02:00
vec4 values = $ { t . texture2D } ( A , uv ) ;
float value ;
if ( depth == 0 ) {
value = values . r ;
} else if ( depth == 1 ) {
value = values . g ;
} else if ( depth == 2 ) {
value = values . b ;
} else if ( depth == 3 ) {
value = values . a ;
}
result [ row * 2 + col ] = floor ( value * 255.0 + 0.5 ) ;
}
}
$ { t . output } = result ;
2021-09-05 22:42:11 +02:00
}
2021-10-22 22:09:52 +02:00
` }},Pee={kernelName:kh,backendName:"webgl",kernelFunc:zee},Bu;function zee(e){let{inputs:t,backend:n,attrs:a}=e,{pixels:r}=t,{numChannels:s}=a,i=typeof HTMLVideoElement!="undefined"&&r instanceof HTMLVideoElement,o=typeof HTMLImageElement!="undefined"&&r instanceof HTMLImageElement,[l,d]=i?[r.videoWidth,r.videoHeight]:[r.width,r.height],u=[d,l],p=[d,l,s];(o||i)&&(Bu==null&&(Bu=document.createElement("canvas").getContext("2d")),Bu.canvas.width=l,Bu.canvas.height=d,Bu.drawImage(r,0,0,l,d),r=Bu.canvas);let c=n.makeTensorInfo(u,"int32");n.texData.get(c.dataId).usage=Ca.PIXELS,n.gpgpu.uploadPixelDataToTexture(n.getTexture(c.dataId),r);let h=ne().getBool("WEBGL_PACK")?new _ee(p):new Oee(p),f=n.runWebGLProgram(h,[c],"int32");return n.disposeData(c.dataId),f}function Lee(e){let{inputs:t,backend:n,attrs:a}=e,{x:r,filter:s,bias:i,preluActivationWeights:o}=t,{strides:l,pad:d,dataFormat:u,dilations:p,dimRoundingMode:c,activation:h,leakyreluAlpha:f}=a,m=E.convertConv2DDataFormat(u),g=E.computeConv2DInfo(r.shape,s.shape,l,p,d,c,!1,m),y,A=[];if(g.filterHeight===1&&g.filterWidth===1&&g.dilationHeight===1&&g.dilationWidth===1&&g.strideHeight===1&&g.strideWidth===1&&(g.padInfo.type==="SAME"||g.padInfo.type==="VALID"))y=vk({x:r,filter:s,convInfo:g,backend:n,bias:i,activation:h,preluActivationWeights:o,leakyreluAlpha:f});else if(ne().getBool("WEBGL_CONV_IM2COL")&&r.shape[0]===1)y=wk({x:r,filter:s,convInfo:g,backend:n,bias:i,activation:h,preluActivationWeights:o,leakyreluAlpha:f});else{let b=i!=null,v=o!=null,k=h==="leakyrelu",T=h?bf(h,!1):null,C=new bk(g,b,T,v,k),D=[r,s];if(i&&D.push(i),o&&D.push(o),k){let O=n.makeTensorInfo([],"float32",w.createScalarValue(f,"float32"));D.push(O),A.push(O)}y=n.runWebGLProgram(C,D,"float32")}let x=we({inputs:{x:y},backend:n,attrs:{shape:g.outShape}});return A.push(y),A.forEach(b=>n.disposeIntermediateTensorInfo(b)),x}var Wee={kernelName:qi,backendName:"webgl",kernelFunc:Lee};function Bee(e){let{inputs:t,backend:n,attrs:a}=e,{x:r,filter:s,bias:i,preluActivationWeights:o}=t,{strides:l,pad:d,dilations:u,dimRoundingMode:p,activation:c,leakyreluAlpha:h}=a,f=[],m=u;m==null&&(m=[1,1]),w.assert(E.eitherStridesOrDilationsAreOne(l,m),()=> ` Error in depthwiseConv2d : Either strides or dilations must be 1. Got strides $ { l } and dilations '${m}' ` );let g=E.computeConv2DInfo(r.shape,s.shape,l,m,d,p,!0),y=ne().getBool("WEBGL_PACK_DEPTHWISECONV")&&g.strideWidth<=2&&g.outChannels/g.inChannels==1,A=c?bf(c,y):null,x=[r,s],b=i!=null,v=o!=null,k=c==="leakyrelu";if(b&&x.push(i),v&&x.push(o),k){let O=n.makeTensorInfo([],"float32",w.createScalarValue(h,"float32"));x.push(O),f.push(O)}let T;y?T=new Tk(g,b,A,v,k):T=new Nk(g,b,A,v,k);let C=[[g.padInfo.top,g.padInfo.left],[g.strideHeight,g.strideWidth],[g.dilationHeight,g.dilationWidth],[g.inHeight,g.inWidth]],D=n.runWebGLProgram(T,x,"float32",C);return f.forEach(O=>n.disposeIntermediateTensorInfo(O)),D}var Vee={kernelName:Xi,backendName:"webgl",kernelFunc:Bee},Uee=class{constructor(e,t,n){this.sliceDim=e,this.strides=t,this.variableNames=["x","indices"],this.outputShape=n;let a=yt(t.length),r=yt(n.length),s=this.sliceDim>1?"strides[j]":"strides";this.userCode= `
$ { a } strides = $ { a } ( $ { this . strides } ) ;
2021-09-11 16:29:31 +02:00
void main ( ) {
2021-10-04 23:03:36 +02:00
$ { r } coords = getOutputCoords ( ) ;
2021-09-11 16:29:31 +02:00
int flattenIndex = 0 ;
for ( int j = 0 ; j < $ { this . sliceDim } ; j ++ ) {
int index = round ( getIndices ( coords [ 0 ] , j ) ) ;
2021-10-22 22:09:52 +02:00
flattenIndex += index * $ { s } ;
2021-09-11 16:29:31 +02:00
}
setOutput ( getX ( flattenIndex , coords [ 1 ] ) ) ;
2021-09-01 00:24:30 +02:00
}
2021-10-22 22:09:52 +02:00
` }};function jee(e){let{inputs:t,backend:n}=e,{params:a,indices:r}=t,s=r.shape,i=s[s.length-1],o=w.sizeFromShape(a.shape),[l,d,u,p]=E.prepareAndValidate(a,r),c=we({inputs:{x:r},backend:n,attrs:{shape:[d,i]}}),h=we({inputs:{x:a},backend:n,attrs:{shape:[w.sizeFromShape(a.shape)/u,u]}});if(n.shouldExecuteOnCPU([a,r])||a.dtype==="string"){let y=n.readSync(r.dataId),A=n.bufferSync(a),x=tZ(y,A,a.dtype,d,i,u,p,a.shape,o);return n.makeTensorInfo(l,a.dtype,x.values)}let f=new Uee(i,p,[d,u]),m=n.runWebGLProgram(f,[h,c],h.dtype),g=we({inputs:{x:m},backend:n,attrs:{shape:l}});return n.disposeIntermediateTensorInfo(c),n.disposeIntermediateTensorInfo(h),n.disposeIntermediateTensorInfo(m),g}var Gee={kernelName:ml,backendName:"webgl",kernelFunc:jee},Hee=class{constructor(e,t){this.variableNames=["A","indices"],this.outputShape=t,this.rank=t.length;let n=yt(this.rank),a=qee(e,2);this.userCode= `
2021-09-11 16:29:31 +02:00
void main ( ) {
$ { n } resRC = getOutputCoords ( ) ;
2021-10-22 22:09:52 +02:00
setOutput ( getA ( $ { a } ) ) ;
2021-09-01 00:24:30 +02:00
}
2021-10-22 22:09:52 +02:00
` }};function qee(e,t){let n=["resRC.x","resRC.y","resRC.z","resRC.w"],a=[];for(let r=0;r<e.length;r++)r===2?a.push("int(getIndices(resRC.x, resRC.z))"):a.push( ` $ { n [ r ] } ` );return a.join()}function $ k(e){let{inputs:t,backend:n,attrs:a}=e,{x:r,indices:s}=t,{axis:i,batchDims:o}=a,l=w.parseAxisParam(i,r.shape)[0],d=n.readSync(s.dataId),u=r.shape[l];for(let b=0;b<d.length;++b){let v=d[b];w.assert(v<=u-1&&v>=0,()=> ` GatherV2 : the index value $ { v } is not in [ 0 , $ { u - 1 } ] ` )}let p=E.segment_util.collectGatherOpShapeInfo(r,s,l,o),c=w.sizeFromShape(s.shape),h=[],f=we({inputs:{x:r},backend:n,attrs:{shape:[p.batchSize,p.outerSize,p.dimSize,p.sliceSize]}}),m=we({inputs:{x:s},backend:n,attrs:{shape:[p.batchSize,c/p.batchSize]}});h.push(f),h.push(m);let g=[p.batchSize,p.outerSize,c/p.batchSize,p.sliceSize];if(n.shouldExecuteOnCPU([r,s])||r.dtype==="string"){let b=n.bufferSync(m),v=n.bufferSync(f),k=nZ(v,b,g);return h.forEach(T=>n.disposeIntermediateTensorInfo(T)),n.makeTensorInfo(p.outputShape,k.dtype,k.values)}let y=new Hee(f.shape,g),A=n.runWebGLProgram(y,[f,m],f.dtype);h.push(A);let x=we({inputs:{x:A},backend:n,attrs:{shape:p.outputShape}});return h.forEach(b=>n.disposeIntermediateTensorInfo(b)),x}var Xee={kernelName:fl,backendName:"webgl",kernelFunc: $ k},Kee="return float(a > b);",Zee= `
2021-09-11 16:29:31 +02:00
return vec4 ( greaterThan ( a , b ) ) ;
2021-10-22 22:09:52 +02:00
` ,Yee=vn({opSnippet:Kee,packedOpSnippet:Zee,cpuKernelImpl:aZ,dtype:"bool"}),Jee={kernelName:gl,backendName:"webgl",kernelFunc:Yee},Qee="return float(a >= b);",ete= `
2021-09-11 16:29:31 +02:00
return vec4 ( greaterThanEqual ( a , b ) ) ;
2021-10-22 22:09:52 +02:00
` ,tte=vn({opSnippet:Qee,packedOpSnippet:ete,dtype:"bool",cpuKernelImpl:rZ}),nte={kernelName:fi,backendName:"webgl",kernelFunc:tte};function ate(e){let{inputs:t,backend:n}=e,{input:a}=t;return Fk(a,!0,n)}var rte={kernelName:ah,backendName:"webgl",kernelFunc:ate},ste="return float(!isnan(x) && !isinf(x));",ite=nt({opSnippet:ste,dtype:"bool"}),ote={kernelName:yl,backendName:"webgl",kernelFunc:ite},lte="return float(isinf(x));",ute=nt({opSnippet:lte,dtype:"bool"}),dte={kernelName:Al,backendName:"webgl",kernelFunc:ute},pte="return float(isnan(x));",cte=nt({opSnippet:pte,dtype:"bool"}),hte={kernelName:xl,backendName:"webgl",kernelFunc:cte},fte="return float(a < b);",mte= `
2021-09-11 16:29:31 +02:00
return vec4 ( lessThan ( a , b ) ) ;
2021-10-22 22:09:52 +02:00
` ,gte=vn({opSnippet:fte,packedOpSnippet:mte,cpuKernelImpl:sZ,dtype:"bool"}),yte={kernelName:bl,backendName:"webgl",kernelFunc:gte},Ate="return float(a <= b);",xte= `
2021-09-11 16:29:31 +02:00
return vec4 ( lessThanEqual ( a , b ) ) ;
2021-10-22 22:09:52 +02:00
` ,bte=vn({opSnippet:Ate,packedOpSnippet:xte,cpuKernelImpl:iZ,dtype:"bool"}),vte={kernelName:vl,backendName:"webgl",kernelFunc:bte};function wte(e){let{backend:t,attrs:n}=e,{start:a,stop:r,num:s}=n,i=oZ(a,r,s);return t.makeTensorInfo([i.length],"float32",i)}var kte={kernelName:sh,backendName:"webgl",kernelFunc:wte},Ite= ` if ( x < 0.0 ) return NAN ;
return log ( x ) ; ` ,Ste= `
2021-09-11 16:29:31 +02:00
vec4 result = log ( x ) ;
vec4 isNaN = vec4 ( lessThan ( x , vec4 ( 0.0 ) ) ) ;
result . r = isNaN . r == 1.0 ? NAN : result . r ;
result . g = isNaN . g == 1.0 ? NAN : result . g ;
result . b = isNaN . b == 1.0 ? NAN : result . b ;
result . a = isNaN . a == 1.0 ? NAN : result . a ;
return result ;
2021-10-22 22:09:52 +02:00
` ,Nte=nt({opSnippet:Ite,packedOpSnippet:Ste,cpuKernelImpl:lZ}),Tte={kernelName:yi,backendName:"webgl",kernelFunc:Nte},Cte="return log(1.0 + x);",Ete=nt({opSnippet:Cte}),Rte={kernelName:wl,backendName:"webgl",kernelFunc:Ete},Mte="return float(a >= 1.0 && b >= 1.0);",Fte= `
2021-09-11 16:29:31 +02:00
return vec4 (
vec4 ( greaterThanEqual ( a , vec4 ( 1.0 ) ) ) *
vec4 ( greaterThanEqual ( b , vec4 ( 1.0 ) ) ) ) ;
2021-10-22 22:09:52 +02:00
` ,Dte=vn({opSnippet:Mte,packedOpSnippet:Fte,dtype:"bool"}), $ te={kernelName:kl,backendName:"webgl",kernelFunc:Dte},Ote="return float(!(x >= 1.0));",_te=nt({opSnippet:Ote}),Pte={kernelName:kd,backendName:"webgl",kernelFunc:_te},zte="return float(a >= 1.0 || b >= 1.0);",Lte= `
2021-09-11 16:29:31 +02:00
return min (
vec4 ( greaterThanEqual ( a , vec4 ( 1.0 ) ) ) +
vec4 ( greaterThanEqual ( b , vec4 ( 1.0 ) ) ) ,
vec4 ( 1.0 ) ) ;
2021-10-22 22:09:52 +02:00
` ,Wte=vn({opSnippet:zte,packedOpSnippet:Lte,dtype:"bool"}),Bte={kernelName:Id,backendName:"webgl",kernelFunc:Wte},Vte=class{constructor(e,t,n,a,r){this.variableNames=["x"],this.outputShape=[];let s=t,i=e[3]-1;this.outputShape=e;let o,l= ` float ( $ { n } ) + float ( $ { a } ) * sum ` ;r===.5?o= ` inversesqrt ( $ { l } ) ` :r===1?o= ` 1.0 / ( $ { l } ) ` :o= ` exp ( log ( $ { l } ) * float ( - $ { r } ) ) ; ` ,this.userCode= `
2021-09-11 16:29:31 +02:00
void main ( ) {
ivec4 coords = getOutputCoords ( ) ;
int b = coords [ 0 ] ;
int r = coords [ 1 ] ;
int c = coords [ 2 ] ;
int d = coords [ 3 ] ;
float x = getX ( b , r , c , d ) ;
float sum = 0.0 ;
2021-10-22 22:09:52 +02:00
for ( int j = - $ { s } ; j <= $ { s } ; j ++ ) {
2021-09-11 16:29:31 +02:00
int idx = d + j ;
2021-10-22 22:09:52 +02:00
if ( idx >= 0 && idx <= $ { i } ) {
2021-09-11 16:29:31 +02:00
float z = getX ( b , r , c , idx ) ;
sum += z * z ;
}
}
2021-10-22 22:09:52 +02:00
float val = x * $ { o } ;
2021-09-11 16:29:31 +02:00
setOutput ( val ) ;
2021-09-05 22:42:11 +02:00
}
2021-10-22 22:09:52 +02:00
` }},Ute=class{constructor(e,t,n,a,r){this.variableNames=["x"],this.outputShape=[],this.packedInputs=!0,this.packedOutput=!0;let s=t,i=e[3]-1;this.outputShape=e;let o,l= ` float ( $ { n } ) + float ( $ { a } ) * sum ` ;r===.5?o= ` inversesqrt ( $ { l } ) ` :r===1?o= ` 1.0 / ( $ { l } ) ` :o= ` exp ( log ( $ { l } ) * float ( - $ { r } ) ) ; ` ,this.userCode= `
2021-09-11 16:29:31 +02:00
void main ( ) {
ivec4 coords = getOutputCoords ( ) ;
int b = coords . x ;
int r = coords . y ;
int c = coords . z ;
int d = coords . w ;
bool hasNextCol = d < $ { this . outputShape [ 3 ] } ;
bool hasNextRow = c < $ { this . outputShape [ 2 ] } ;
vec4 sum = vec4 ( 0. ) ;
vec4 xFragAtOutputCoords = getX ( b , r , c , d ) ;
vec4 xAtOutputCoords = vec4 (
getChannel ( xFragAtOutputCoords , vec2 ( c , d ) ) ,
hasNextCol ?
getChannel ( xFragAtOutputCoords , vec2 ( c , d + 1 ) ) : 0.0 ,
hasNextRow ?
getChannel ( xFragAtOutputCoords , vec2 ( c + 1 , d ) ) : 0.0 ,
( hasNextRow && hasNextCol ) ?
getChannel ( xFragAtOutputCoords , vec2 ( c + 1 , d + 1 ) ) : 0.0
) ;
2021-10-22 22:09:52 +02:00
int firstChannel = d - $ { s } ;
2021-09-11 16:29:31 +02:00
vec2 cache = vec2 ( 0. ) ;
if ( firstChannel >= 0 ) {
vec4 firstChannelFrag = getX ( b , r , c , firstChannel ) ;
cache . x = getChannel ( firstChannelFrag , vec2 ( c , firstChannel ) ) ;
if ( hasNextRow ) {
cache . y = getChannel ( firstChannelFrag , vec2 ( c + 1 , firstChannel ) ) ;
}
}
ivec2 depth = ivec2 ( d , d + 1 ) ;
2021-10-22 22:09:52 +02:00
for ( int j = - $ { s } ; j <= $ { s } ; j ++ ) {
2021-09-11 16:29:31 +02:00
ivec2 idx = depth + j ;
bvec2 aboveLowerBound = greaterThanEqual ( idx , ivec2 ( 0 ) ) ;
2021-10-22 22:09:52 +02:00
bvec2 belowUpperBound = lessThanEqual ( idx , ivec2 ( $ { i } ) ) ;
2021-09-11 16:29:31 +02:00
bool depthInRange = aboveLowerBound . x && belowUpperBound . x ;
bool depthPlusOneInRange = aboveLowerBound . y && belowUpperBound . y ;
if ( depthInRange || depthPlusOneInRange ) {
vec4 z = vec4 ( 0. ) ;
vec4 xFragAtCurrentDepth ;
z . xz = cache . xy ;
if ( depthPlusOneInRange && hasNextCol ) {
xFragAtCurrentDepth = idx . y != d ?
getX ( b , r , c , idx . y ) : xFragAtOutputCoords ;
z . y = getChannel ( xFragAtCurrentDepth , vec2 ( c , idx . y ) ) ;
if ( hasNextRow ) {
z . w = getChannel ( xFragAtCurrentDepth , vec2 ( c + 1 , idx . y ) ) ;
}
}
cache . xy = z . yw ;
sum += z * z ;
}
}
2021-10-22 22:09:52 +02:00
vec4 result = xAtOutputCoords * $ { o } ;
2021-09-11 16:29:31 +02:00
setOutput ( result ) ;
2021-09-05 22:42:11 +02:00
}
2021-10-22 22:09:52 +02:00
` }},jte=e=>{let{inputs:t,backend:n,attrs:a}=e,{x:r}=t,{depthRadius:s,bias:i,alpha:o,beta:l}=a,d=ne().getBool("WEBGL_PACK_NORMALIZATION")?new Ute(r.shape,s,i,o,l):new Vte(r.shape,s,i,o,l);return n.runWebGLProgram(d,[r],r.dtype)},Gte={kernelName:Sd,backendName:"webgl",kernelFunc:jte},Hte=class{constructor(e,t,n,a,r){this.variableNames=["inputImage","outputImage","dy"],this.outputShape=[],this.outputShape=e,this.depth=e[3],this.depthRadius=t,this.bias=n,this.alpha=a,this.beta=r,this.userCode= `
2021-09-11 16:29:31 +02:00
void main ( ) {
ivec4 coords = getOutputCoords ( ) ;
int b = coords [ 0 ] ;
int r = coords [ 1 ] ;
int c = coords [ 2 ] ;
float result = 0.0 ;
for ( int d = 0 ; d < $ { this . depth } ; ++ d ) {
int depthBegin = int ( max ( 0.0 , float ( d - $ { t } ) ) ) ;
int depthEnd = int ( min ( float ( $ { this . depth } ) ,
float ( d + $ { t } + 1 ) ) ) ;
const int MIN _DEPTH _BEGIN = 0 ;
const int MAX _DEPTH _END = $ { this . depth } ;
float norm = 0.0 ;
for ( int k = MIN _DEPTH _BEGIN ; k < MAX _DEPTH _END ; ++ k ) {
if ( k < depthBegin ) {
continue ;
}
else if ( k >= depthBegin && k < depthEnd ) {
norm += getInputImage ( b , r , c , k ) * getInputImage ( b , r , c , k ) ;
}
else {
break ;
}
}
2021-10-22 22:09:52 +02:00
norm = float ( $ { a } ) * norm + float ( $ { n } ) ;
2021-09-11 16:29:31 +02:00
for ( int k = MIN _DEPTH _BEGIN ; k < MAX _DEPTH _END ; ++ k ) {
if ( k < depthBegin ) {
continue ;
}
else if ( k >= depthBegin && k < depthEnd ) {
2021-10-22 22:09:52 +02:00
float dyi = - 2.0 * float ( $ { a } )
2021-10-04 23:03:36 +02:00
* float ( $ { r } )
2021-09-11 16:29:31 +02:00
* getInputImage ( b , r , c , k ) * getOutputImage ( b , r , c , d )
/ n o r m ;
if ( k == d ) {
2021-10-04 23:03:36 +02:00
dyi += pow ( norm , - 1.0 * $ { r } ) ;
2021-09-11 16:29:31 +02:00
}
if ( k == coords [ 3 ] ) {
dyi *= getDy ( b , r , c , d ) ;
result += dyi ;
}
}
else {
break ;
}
}
2021-09-05 22:42:11 +02:00
}
2021-09-11 16:29:31 +02:00
setOutput ( result ) ;
2021-09-05 22:42:11 +02:00
}
2021-10-22 22:09:52 +02:00
` }},qte=e=>{let{inputs:t,backend:n,attrs:a}=e,{x:r,y:s,dy:i}=t,{depthRadius:o,bias:l,alpha:d,beta:u}=a,p=new Hte(r.shape,o,l,d,u);return n.runWebGLProgram(p,[r,s,i],r.dtype)},Xte={kernelName:ih,backendName:"webgl",kernelFunc:qte};function Kte(e,t,n,a){let r=w.sizeFromShape(t),s=w.sizeFromShape(e.shape)/r,i=we({inputs:{x:e},attrs:{shape:[s,r]},backend:a}),o=Co(i,e.dtype,"max",a),l=we({inputs:{x:o},attrs:{shape:n},backend:a});return a.disposeIntermediateTensorInfo(i),a.disposeIntermediateTensorInfo(o),l}function Ok(e){let{inputs:t,backend:n,attrs:a}=e,{x:r}=t,{reductionIndices:s,keepDims:i}=a,o=r.shape.length,l=w.parseAxisParam(s,r.shape),d=l,u=E.getAxesPermutation(d,o),p=u!=null,c=n.shouldExecuteOnCPU([r]),h=r;if(p){if(c){let A=n.texData.get(h.dataId).values,x=new Array(o);for(let k=0;k<x.length;k++)x[k]=r.shape[u[k]];let b=U2(A,r.shape,r.dtype,u,x);h=n.makeTensorInfo(x,r.dtype);let v=n.texData.get(h.dataId);v.values=b}else h=vf(r,u,n);d=E.getInnerMostAxes(d.length,o)}E.assertAxesAreInnerMostDims("max",d,o);let[f,m]=E.computeOutAndReduceShapes(h.shape,d),g=f;i&&(g=E.expandShapeToKeepDim(f,l));let y;if(c){let A=n.texData.get(h.dataId).values,x=uZ(A,w.sizeFromShape(m),g,r.dtype);y=n.makeTensorInfo(g,r.dtype);let b=n.texData.get(y.dataId);b.values=x}else y=Kte(h,m,g,n);return p&&n.disposeIntermediateTensorInfo(h),y}var Zte={kernelName:Ai,backendName:"webgl",kernelFunc:Ok},Yte=Q4+ `
2021-09-11 16:29:31 +02:00
return max ( a , b ) ;
2021-10-22 22:09:52 +02:00
` ,Jte= `
2021-09-11 16:29:31 +02:00
vec4 result = vec4 ( max ( a , b ) ) ;
vec4 isNaN = min ( vec4 ( isnan ( a ) ) + vec4 ( isnan ( b ) ) , vec4 ( 1.0 ) ) ;
2021-10-22 22:09:52 +02:00
` +xf+ `
2021-09-11 16:29:31 +02:00
return result ;
2021-10-22 22:09:52 +02:00
` ,Qte=vn({opSnippet:Yte,packedOpSnippet:Jte,cpuKernelImpl:dZ}),ene={kernelName:xi,backendName:"webgl",kernelFunc:Qte};function tne(e){let{inputs:t,backend:n,attrs:a}=e,{x:r}=t;Mu(r,"maxPool");let{filterSize:s,strides:i,pad:o,dimRoundingMode:l}=a,d=1;w.assert(E.eitherStridesOrDilationsAreOne(i,d),()=> ` Error in maxPool : Either strides or dilations must be 1. Got strides $ { i } and dilations '${d}' ` );let u=E.computePool2DInfo(r.shape,s,i,d,o,l);if(u.filterWidth===1&&u.filterHeight===1&&w.arraysEqual(u.inShape,u.outShape))return ma({inputs:{x:r},backend:n});let p=new Wp(u,"max",!1);return n.runWebGLProgram(p,[r],r.dtype)}var nne={kernelName:bi,backendName:"webgl",kernelFunc:tne};function ane(e){let{inputs:t,backend:n,attrs:a}=e,{x:r}=t,{filterSize:s,strides:i,pad:o,dataFormat:l,dimRoundingMode:d}=a,u=[1,1,1],p=E.computePool3DInfo(r.shape,s,i,u,o,d,l),c=new H2(p,"max",!1);return n.runWebGLProgram(c,[r],r.dtype)}var rne={kernelName:Nd,backendName:"webgl",kernelFunc:ane},sne=class{constructor(e){this.variableNames=["dy","maxPos"],this.outputShape=e.inShape;let t=e.strideHeight,n=e.strideWidth,a=e.dilationHeight,r=e.effectiveFilterHeight,s=e.effectiveFilterWidth,i=r-1-e.padInfo.top,o=s-1-e.padInfo.left,l=r*s-1;this.userCode= `
const ivec2 pads = ivec2 ( $ { i } , $ { o } ) ;
2021-09-11 16:29:31 +02:00
void main ( ) {
ivec4 coords = getOutputCoords ( ) ;
int b = coords [ 0 ] ;
int d = coords [ 3 ] ;
ivec2 dyRCCorner = coords . yz - pads ;
int dyRCorner = dyRCCorner . x ;
int dyCCorner = dyRCCorner . y ;
// Convolve dy(?, ?, d) with pos mask(:, :, d) to get dx(xR, xC, d).
// ? = to be determined. : = across all values in that axis.
float dotProd = 0.0 ;
2021-10-04 23:03:36 +02:00
for ( int wR = 0 ; wR < $ { r } ;
2021-10-22 22:09:52 +02:00
wR += $ { a } ) {
2021-09-11 16:29:31 +02:00
float dyR = float ( dyRCorner + wR ) / $ { t } . 0 ;
if ( dyR < 0.0 || dyR >= $ { e . outHeight } . 0 || fract ( dyR ) > 0.0 ) {
continue ;
}
int idyR = int ( dyR ) ;
2021-10-22 22:09:52 +02:00
for ( int wC = 0 ; wC < $ { s } ; wC ++ ) {
2021-09-11 16:29:31 +02:00
float dyC = float ( dyCCorner + wC ) / $ { n } . 0 ;
if ( dyC < 0.0 || dyC >= $ { e . outWidth } . 0 ||
fract ( dyC ) > 0.0 ) {
continue ;
}
int idyC = int ( dyC ) ;
float dyValue = getDy ( b , idyR , idyC , d ) ;
int maxPosValue = $ { l } - int ( getMaxPos ( b , idyR , idyC , d ) ) ;
// Get the current value, check it against the value from the
// position matrix.
2021-10-22 22:09:52 +02:00
int curPosValue = wR * $ { s } + wC ;
2021-09-11 16:29:31 +02:00
float mask = float ( maxPosValue == curPosValue ? 1.0 : 0.0 ) ;
dotProd += dyValue * mask ;
}
}
setOutput ( dotProd ) ;
2021-09-05 22:42:11 +02:00
}
2021-10-22 22:09:52 +02:00
` }},ine=class{constructor(e){this.variableNames=["dy","maxPos"],this.outputShape=e.inShape;let t=e.strideDepth,n=e.strideHeight,a=e.strideWidth,r=e.dilationDepth,s=e.dilationHeight,i=e.dilationWidth,o=e.effectiveFilterDepth,l=e.effectiveFilterHeight,d=e.effectiveFilterWidth,u=o-1-e.padInfo.front,p=l-1-e.padInfo.top,c=d-1-e.padInfo.left,h=o*l*d-1;this.userCode= `
const ivec3 pads = ivec3 ( $ { u } , $ { p } , $ { c } ) ;
2021-09-11 16:29:31 +02:00
void main ( ) {
ivec5 coords = getOutputCoords ( ) ;
int batch = coords . x ;
int ch = coords . u ;
ivec3 dyCorner = ivec3 ( coords . y , coords . z , coords . w ) - pads ;
int dyDCorner = dyCorner . x ;
int dyRCorner = dyCorner . y ;
int dyCCorner = dyCorner . z ;
// Convolve dy(?, ?, ?, ch) with pos mask(:, :, :, d) to get
// dx(xD, xR, xC, ch).
// ? = to be determined. : = across all values in that axis.
float dotProd = 0.0 ;
2021-10-22 22:09:52 +02:00
for ( int wD = 0 ; wD < $ { o } ;
2021-10-04 23:03:36 +02:00
wD += $ { r } ) {
2021-09-11 16:29:31 +02:00
float dyD = float ( dyDCorner + wD ) / $ { t } . 0 ;
if ( dyD < 0.0 || dyD >= $ { e . outDepth } . 0 || fract ( dyD ) > 0.0 ) {
continue ;
}
int idyD = int ( dyD ) ;
for ( int wR = 0 ; wR < $ { l } ;
2021-10-22 22:09:52 +02:00
wR += $ { s } ) {
2021-09-11 16:29:31 +02:00
float dyR = float ( dyRCorner + wR ) / $ { n } . 0 ;
if ( dyR < 0.0 || dyR >= $ { e . outHeight } . 0 ||
fract ( dyR ) > 0.0 ) {
continue ;
}
int idyR = int ( dyR ) ;
2021-10-22 22:09:52 +02:00
for ( int wC = 0 ; wC < $ { d } ;
wC += $ { i } ) {
float dyC = float ( dyCCorner + wC ) / $ { a } . 0 ;
2021-09-11 16:29:31 +02:00
if ( dyC < 0.0 || dyC >= $ { e . outWidth } . 0 ||
fract ( dyC ) > 0.0 ) {
continue ;
}
int idyC = int ( dyC ) ;
float dyValue = getDy ( batch , idyD , idyR , idyC , ch ) ;
2021-10-04 23:03:36 +02:00
int maxPosValue = $ { h } -
2021-09-11 16:29:31 +02:00
int ( getMaxPos ( batch , idyD , idyR , idyC , ch ) ) ;
// Get the current value, check it against the value from the
// position matrix.
int curPosValue =
2021-10-22 22:09:52 +02:00
wD * $ { l } * $ { d } +
wR * $ { d } + wC ;
2021-09-11 16:29:31 +02:00
float mask = float ( maxPosValue == curPosValue ? 1.0 : 0.0 ) ;
dotProd += dyValue * mask ;
}
}
2021-09-05 22:42:11 +02:00
}
2021-09-11 16:29:31 +02:00
setOutput ( dotProd ) ;
2021-09-05 22:42:11 +02:00
}
2021-10-22 22:09:52 +02:00
` }};function one(e){let{inputs:t,backend:n,attrs:a}=e,{dy:r,input:s}=t,i=s,{filterSize:o,strides:l,pad:d,dimRoundingMode:u}=a,p=[1,1,1],c=E.computePool3DInfo(i.shape,o,l,p,d,u),h=new H2(c,"max",!0),f=n.runWebGLProgram(h,[i],i.dtype),m=new ine(c),g=n.runWebGLProgram(m,[r,f],i.dtype);return n.disposeIntermediateTensorInfo(f),g}var lne={kernelName:lh,backendName:"webgl",kernelFunc:one};function une(e){let{inputs:t,backend:n,attrs:a}=e,{dy:r,input:s,output:i}=t,o=s;Mu([s,i],"maxPoolGrad");let{filterSize:l,strides:d,pad:u,dimRoundingMode:p}=a,c=E.computePool2DInfo(o.shape,l,d,1,u,p),h=!0,f=new Wp(c,"max",h),m=n.runWebGLProgram(f,[o],o.dtype),g=new sne(c),y=n.runWebGLProgram(g,[r,m],o.dtype);return n.disposeIntermediateTensorInfo(m),y}var dne={kernelName:oh,backendName:"webgl",kernelFunc:une};function pne(e,t,n,a){let r=new Wp(n,"max",!1),s=a.runWebGLProgram(r,[e],"float32");r=new Wp(n,"max",!0,!0,t);let i=a.runWebGLProgram(r,[e],"float32");return[s,i]}var cne={kernelName:uh,backendName:"webgl",kernelFunc:({inputs:e,attrs:t,backend:n})=>{let{x:a}=e,{filterSize:r,strides:s,pad:i,includeBatchInIndex:o}=t,l=n;w.assert(a.shape.length===4,()=> ` Error in maxPool : input must be rank 4 but got rank $ { a . shape . length } . ` );let d=[1,1];w.assert(E.eitherStridesOrDilationsAreOne(s,d),()=> ` Error in maxPool : Either strides or dilations must be 1. Got strides $ { s } and dilations '${d}' ` );let u=E.computePool2DInfo(a.shape,r,s,d,i),[p,c]=pne(a,o,u,l);return[p,c]}};function hne(e,t,n,a){let r=w.sizeFromShape(t),s=w.sizeFromShape(e.shape)/r,i=we({inputs:{x:e},attrs:{shape:[s,r]},backend:a}),o=Co(i,"float32","mean",a),l=we({inputs:{x:o},attrs:{shape:n},backend:a});return a.disposeIntermediateTensorInfo(i),a.disposeIntermediateTensorInfo(o),l}var fne={kernelName:vi,backendName:"webgl",kernelFunc:({inputs:e,attrs:t,backend:n})=>{let{x:a}=e,{keepDims:r,axis:s}=t,i=n,o=a.shape.length,l=w.parseAxisParam(s,a.shape),d=l,u=E.getAxesPermutation(d,o),p=u!=null,c=i.shouldExecuteOnCPU([a]),h=[],f=a;if(p){if(c){let x=i.texData.get(f.dataId).values,b=new Array(o);for(let T=0;T<b.length;T++)b[T]=a.shape[u[T]];let v=U2(x,a.shape,a.dtype,u,b);f=i.makeTensorInfo(b,a.dtype);let k=i.texData.get(f.dataId);k.values=v}else f=vf(a,u,i);h.push(f),d=E.getInnerMostAxes(d.length,o)}E.assertAxesAreInnerMostDims("sum",d,o);let[m,g]=E.computeOutAndReduceShapes(f.shape,d),y=m;r&&(y=E.expandShapeToKeepDim(m,l));let A=hne(f,g,y,i);for(let x of h)i.disposeIntermediateTensorInfo(x);return A}};function mne(e){let{inputs:t,backend:n,attrs:a}=e,{x:r}=t,{axis:s,keepDims:i}=a,o=r.shape.length,l=w.parseAxisParam(s,r.shape),d=l,u=E.getAxesPermutation(d,o),p=r;u!=null&&(p=_n({inputs:{x:r},backend:n,attrs:{perm:u}}),d=E.getInnerMostAxes(d.length,r.shape.length)),E.assertAxesAreInnerMostDims("min",d,o);let[c,h]=E.computeOutAndReduceShapes(p.shape,d),f=w.sizeFromShape(h),m=we({inputs:{x:p},backend:n,attrs:{shape:[-1,f]}}),g=Co(m,m.dtype,"min",n),y;if(i){let A=E.expandShapeToKeepDim(c,l);y=we({inputs:{x:g},backend:n,attrs:{shape:A}})}else y=we({inputs:{x:g},backend:n,attrs:{shape:c}});return n.disposeIntermediateTensorInfo(m),n.disposeIntermediateTensorInfo(g),u!=null&&n.disposeIntermediateTensorInfo(p),y}var gne={kernelName:wi,backendName:"webgl",kernelFunc:mne},yne=Q4+ `
2021-09-11 16:29:31 +02:00
return min ( a , b ) ;
2021-10-22 22:09:52 +02:00
` ,Ane= `
2021-09-11 16:29:31 +02:00
vec4 result = vec4 ( min ( a , b ) ) ;
vec4 isNaN = min ( vec4 ( isnan ( a ) ) + vec4 ( isnan ( b ) ) , vec4 ( 1.0 ) ) ;
2021-10-22 22:09:52 +02:00
` +xf+ `
2021-09-11 16:29:31 +02:00
return result ;
2021-10-22 22:09:52 +02:00
` ,xne=vn({opSnippet:yne,packedOpSnippet:Ane,cpuKernelImpl:pZ}),bne={kernelName:ki,backendName:"webgl",kernelFunc:xne},vne=class{constructor(e,t,n){this.variableNames=["x"],this.outputShape=t.map((d,u)=>d[0]+e[u]+d[1]);let a=e.length,r=yt(a),s=t.map(d=>d[0]).join(","),i=t.map((d,u)=>d[0]+e[u]).join(","),o=["coords[0]","coords[1]","coords[2]","coords[3]"].slice(0,a),l=n==="reflect"?0:1;if(a===1){this.userCode= `
int start = $ { s } ;
int end = $ { i } ;
2021-09-11 16:29:31 +02:00
void main ( ) {
int outC = getOutputCoords ( ) ;
if ( outC < start ) {
outC = start * 2 - outC - $ { l } ;
} else if ( outC >= end ) {
outC = ( end - 1 ) * 2 - outC + $ { l } ;
}
setOutput ( getX ( outC - start ) ) ;
2021-09-05 22:42:11 +02:00
}
2021-09-11 16:29:31 +02:00
` ;return}this.userCode= `
2021-10-22 22:09:52 +02:00
$ { r } start = $ { r } ( $ { s } ) ;
$ { r } end = $ { r } ( $ { i } ) ;
2021-09-11 16:29:31 +02:00
void main ( ) {
2021-10-04 23:03:36 +02:00
$ { r } outC = getOutputCoords ( ) ;
2021-10-22 22:09:52 +02:00
for ( int i = 0 ; i < $ { a } ; i ++ ) {
2021-09-11 16:29:31 +02:00
if ( outC [ i ] < start [ i ] ) {
outC [ i ] = start [ i ] * 2 - outC [ i ] - $ { l } ;
} else if ( outC [ i ] >= end [ i ] ) {
outC [ i ] = ( end [ i ] - 1 ) * 2 - outC [ i ] + $ { l } ;
}
2021-09-05 22:42:11 +02:00
}
2021-10-04 23:03:36 +02:00
$ { r } coords = outC - start ;
2021-10-22 22:09:52 +02:00
setOutput ( getX ( $ { o } ) ) ;
2021-09-01 00:22:16 +02:00
}
2021-10-22 22:09:52 +02:00
` }},wne=class{constructor(e,t,n){this.variableNames=["x"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=t.map((h,f)=>h[0]+e[f]+h[1]);let a=e.length,r=yt(a),s=t.map(h=>h[0]).join(","),i=t.map((h,f)=>h[0]+e[f]).join(","),o=On("rc",a),l=On("source",a),d= ` $ { o [ a - 1 ] } < $ { this . outputShape [ a - 1 ] } ` ,u=a===1?"source": ` vec2 ( $ { l . slice ( - 2 ) . join ( ) } ) ` ,p=n==="reflect"?0:1,c="";if(a===1){let h= `
2021-10-04 23:03:36 +02:00
$ { r } source = rc ;
2021-09-11 16:29:31 +02:00
if ( source < start ) {
2021-10-22 22:09:52 +02:00
source = start * 2 - source - $ { p } ;
2021-09-11 16:29:31 +02:00
} else if ( source >= end ) {
2021-10-22 22:09:52 +02:00
source = ( end - 1 ) * 2 - source + $ { p } ;
2021-09-05 22:42:11 +02:00
}
2021-09-11 16:29:31 +02:00
source -= start ;
2021-10-22 22:09:52 +02:00
` ;c= `
2021-10-04 23:03:36 +02:00
$ { r } rc = outputLoc ;
$ { h }
2021-10-07 16:33:10 +02:00
result [ 0 ] = getChannel ( getX ( $ { l . join ( ) } ) , $ { u } ) ;
2021-10-22 22:09:52 +02:00
$ { o [ a - 1 ] } += 1 ;
if ( $ { d } ) {
2021-10-04 23:03:36 +02:00
$ { h }
2021-10-07 16:33:10 +02:00
result [ 1 ] = getChannel ( getX ( $ { l . join ( ) } ) , $ { u } ) ;
2021-09-11 16:29:31 +02:00
}
2021-10-04 23:03:36 +02:00
` }else{let h= `
$ { r } source = rc ;
$ { r } lt = $ { r } ( lessThan ( source , start ) ) ;
$ { r } gte = $ { r } ( greaterThanEqual ( source , end ) ) ;
$ { r } orig = 1 - ( lt + gte ) ;
2021-09-11 16:29:31 +02:00
source = orig * source +
2021-10-22 22:09:52 +02:00
lt * ( start * 2 - source - $ { p } ) +
gte * ( ( end - 1 ) * 2 - source + $ { p } ) ;
2021-09-11 16:29:31 +02:00
source -= start ;
2021-10-22 22:09:52 +02:00
` ;c= `
2021-10-04 23:03:36 +02:00
$ { r } rc = outputLoc ;
$ { h }
2021-10-07 16:33:10 +02:00
result [ 0 ] = getChannel ( getX ( $ { l . join ( ) } ) , $ { u } ) ;
2021-10-22 22:09:52 +02:00
$ { o [ a - 1 ] } += 1 ;
if ( $ { d } ) {
2021-10-04 23:03:36 +02:00
$ { h }
2021-10-07 16:33:10 +02:00
result [ 1 ] = getChannel ( getX ( $ { l . join ( ) } ) , $ { u } ) ;
2021-09-05 22:42:11 +02:00
}
2021-09-11 16:29:31 +02:00
rc = outputLoc ;
2021-10-22 22:09:52 +02:00
$ { o [ a - 2 ] } += 1 ;
if ( $ { o [ a - 2 ] } < $ { this . outputShape [ a - 2 ] } ) {
2021-10-04 23:03:36 +02:00
$ { h }
2021-10-07 16:33:10 +02:00
result [ 2 ] = getChannel ( getX ( $ { l . join ( ) } ) , $ { u } ) ;
2021-10-22 22:09:52 +02:00
$ { o [ a - 1 ] } += 1 ;
if ( $ { d } ) {
2021-10-04 23:03:36 +02:00
$ { h }
2021-10-07 16:33:10 +02:00
result [ 3 ] = getChannel ( getX ( $ { l . join ( ) } ) , $ { u } ) ;
2021-09-11 16:29:31 +02:00
}
}
` }this.userCode= `
2021-10-22 22:09:52 +02:00
const $ { r } start = $ { r } ( $ { s } ) ;
const $ { r } end = $ { r } ( $ { i } ) ;
2021-09-11 16:29:31 +02:00
void main ( ) {
2021-10-04 23:03:36 +02:00
$ { r } outputLoc = getOutputCoords ( ) ;
2021-09-11 16:29:31 +02:00
vec4 result = vec4 ( 0. ) ;
2021-10-22 22:09:52 +02:00
$ { c }
2021-09-11 16:29:31 +02:00
setOutput ( result ) ;
}
2021-10-22 22:09:52 +02:00
` }},kne=({inputs:e,backend:t,attrs:n})=>{let{x:a}=e,{paddings:r,mode:s}=n,i=ne().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new wne(a.shape,r,s):new vne(a.shape,r,s);return t.runWebGLProgram(i,[a],a.dtype)},Ine={kernelName:Ii,backendName:"webgl",kernelFunc:kne},Sne= ` if ( b == 0.0 ) return NAN ;
return mod ( a , b ) ; ` ,Nne= `
2021-09-11 16:29:31 +02:00
vec4 result = mod ( a , b ) ;
vec4 isNaN = vec4 ( equal ( b , vec4 ( 0.0 ) ) ) ;
2021-10-22 22:09:52 +02:00
` +xf+ `
2021-09-11 16:29:31 +02:00
return result ;
2021-10-22 22:09:52 +02:00
` ,Tne=vn({opSnippet:Sne,packedOpSnippet:Nne}),Cne={kernelName:Il,backendName:"webgl",kernelFunc:Tne},Ene=class{constructor(e,t,n){this.variableNames=["probs"],this.customUniforms=[{name:"seed",type:"float"}],this.outputShape=[e,n],this.userCode= `
2021-09-11 16:29:31 +02:00
void main ( ) {
ivec2 coords = getOutputCoords ( ) ;
int batch = coords [ 0 ] ;
float r = random ( seed ) ;
float cdf = 0.0 ;
for ( int i = 0 ; i < $ { t - 1 } ; i ++ ) {
cdf += getProbs ( batch , i ) ;
if ( r < cdf ) {
setOutput ( float ( i ) ) ;
return ;
}
}
// If no other event happened, last event happened.
setOutput ( float ( $ { t - 1 } ) ) ;
2021-09-01 00:22:16 +02:00
}
2021-10-22 22:09:52 +02:00
` }},Rne= `
2021-09-11 16:29:31 +02:00
if ( a == b ) {
return 1.0 ;
} ;
2021-10-22 22:09:52 +02:00
return a / b ; ` ,Mne= `
2021-09-11 16:29:31 +02:00
// vec4 one = vec4(equal(a, b));
// return one + (vec4(1.0) - one) * a / b;
vec4 result = a / b ;
if ( a . x == b . x ) {
result . x = 1. ;
2021-09-05 22:42:11 +02:00
}
2021-09-11 16:29:31 +02:00
if ( a . y == b . y ) {
result . y = 1. ;
2021-09-05 22:42:11 +02:00
}
2021-09-11 16:29:31 +02:00
if ( a . z == b . z ) {
result . z = 1. ;
2021-09-05 22:42:11 +02:00
}
2021-09-11 16:29:31 +02:00
if ( a . w == b . w ) {
result . w = 1. ;
}
return result ;
2021-10-22 22:09:52 +02:00
` ,_k=vn({opSnippet:Rne,packedOpSnippet:Mne,checkOutOfBounds:!0}),Fne={kernelName:li,backendName:"webgl",kernelFunc:_k},Pk="return a - b;",zk=vn({opSnippet:Pk,packedOpSnippet:Pk,supportsComplex:!0,cpuKernelImpl:TZ}),Dne={kernelName:Vi,backendName:"webgl",kernelFunc:zk};function Lk(e){let{inputs:t,backend:n,attrs:a}=e,{logits:r}=t,{dim:s}=a,i=w.parseAxisParam([s],r.shape),o=Ok({inputs:{x:r},backend:n,attrs:{reductionIndices:i,keepDims:!1}}),l=E.expandShapeToKeepDim(o.shape,i),d=we({inputs:{x:o},backend:n,attrs:{shape:l}}),u=zk({inputs:{a:r,b:d},backend:n}),p=Ek({inputs:{x:u},backend:n}),c=wf({inputs:{x:p},backend:n,attrs:{axis:i,keepDims:!1}}),h=we({inputs:{x:c},backend:n,attrs:{shape:l}}),f=_k({inputs:{a:p,b:h},backend:n});return n.disposeIntermediateTensorInfo(o),n.disposeIntermediateTensorInfo(d),n.disposeIntermediateTensorInfo(u),n.disposeIntermediateTensorInfo(p),n.disposeIntermediateTensorInfo(c),n.disposeIntermediateTensorInfo(h),f}var $ ne={kernelName:Wi,backendName:"webgl",kernelFunc:Lk};function One(e){let{inputs:t,backend:n,attrs:a}=e,{logits:r}=t,{numSamples:s,seed:i,normalized:o}=a,l=o?r:Lk({inputs:{logits:r},backend:n,attrs:{dim:r.shape.length-1}}),d=l.shape[0],u=l.shape[1],p=new Ene(d,u,s),c=[[i]],h=n.runWebGLProgram(p,[l],"int32",c);return o||n.disposeIntermediateTensorInfo(l),h}var _ne={kernelName:dh,backendName:"webgl",kernelFunc:One},Wk="return -x;";function Pne(e){let{inputs:t,backend:n}=e,{x:a}=t;if(n.shouldExecuteOnCPU([a])){let s=n.texData.get(a.dataId),[i,o]=hZ(s.values,a.shape,a.dtype);return n.makeTensorInfo(o,a.dtype,i)}let r;return ne().getBool("WEBGL_PACK_UNARY_OPERATIONS")?r=new _u(a.shape,Wk):r=new Fs(a.shape,Wk),n.runWebGLProgram(r,[a],a.dtype)}var zne={kernelName:Sl,backendName:"webgl",kernelFunc:Pne},Lne=xr.nonMaxSuppressionV3Impl;function Wne(e){E.warn("tf.nonMaxSuppression() in webgl locks the UI thread. Call tf.nonMaxSuppressionAsync() instead");let{inputs:t,backend:n,attrs:a}=e,{boxes:r,scores:s}=t,{maxOutputSize:i,iouThreshold:o,scoreThreshold:l}=a,d=n.readSync(r.dataId),u=n.readSync(s.dataId),{selectedIndices:p}=Lne(d,u,i,o,l);return n.makeTensorInfo([p.length],"int32",new Int32Array(p))}var Bne={kernelName:Tl,backendName:"webgl",kernelFunc:Wne},Vne=xr.nonMaxSuppressionV4Impl;function Une(e){E.warn("tf.nonMaxSuppression() in webgl locks the UI thread. Call tf.nonMaxSuppressionAsync() instead");let{inputs:t,backend:n,attrs:a}=e,{boxes:r,scores:s}=t,{maxOutputSize:i,iouThreshold:o,scoreThreshold:l,padToMaxOutputSize:d}=a,u=n.readSync(r.dataId),p=n.readSync(s.dataId),{selectedIndices:c,validOutputs:h}=Vne(u,p,i,o,l,d);return[n.makeTensorInfo([c.length],"int32",new Int32Array(c)),n.makeTensorInfo([],"int32",new Int32Array([h]))]}var jne={kernelName:Cl,backendName:"webgl",kernelFunc:Une},Gne=xr.nonMaxSuppressionV5Impl;function Hne(e){E.warn("tf.nonMaxSuppression() in webgl locks the UI thread. Call tf.nonMaxSuppressionAsync() instead");let{inputs:t,backend:n,attrs:a}=e,{boxes:r,scores:s}=t,{maxOutputSize:i,iouThreshold:o,scoreThreshold:l,softNmsSigma:d}=a,u=n.readSync(r.dataId),p=n.readSync(s.dataId),c=i,h=o,f=l,m=d,{selectedIndices:g,selectedScores:y}=Gne(u,p,c,h,f,m);return[n.makeTensorInfo([g.length],"int32",new Int32Array(g)),n.makeTensorInfo([y.length],"float32",new Float32Array(y))]}var qne={kernelName:El,backendName:"webgl",kernelFunc:Hne},Xne=class{constructor(e,t,n,a){this.variableNames=["indices"],this.outputShape=[e,t],this.userCode= `
2021-09-11 16:29:31 +02:00
void main ( ) {
ivec2 coords = getOutputCoords ( ) ;
int index = round ( getIndices ( coords . x ) ) ;
2021-10-22 22:09:52 +02:00
setOutput ( mix ( float ( $ { a } ) , float ( $ { n } ) ,
2021-09-11 16:29:31 +02:00
float ( index == coords . y ) ) ) ;
2021-09-01 00:22:16 +02:00
}
2021-10-22 22:09:52 +02:00
` }},Kne=e=>{let{inputs:t,backend:n,attrs:a}=e,{indices:r}=t,{depth:s,onValue:i,offValue:o}=a,l=w.sizeFromShape(r.shape),d=new Xne(l,s,i,o),u=we({inputs:{x:r},backend:n,attrs:{shape:[l]}}),p=n.runWebGLProgram(d,[u],r.dtype);n.disposeIntermediateTensorInfo(u);let c=[...r.shape,s],h=we({inputs:{x:p},backend:n,attrs:{shape:c}});return n.disposeIntermediateTensorInfo(p),h},Zne={kernelName:Ni,backendName:"webgl",kernelFunc:Kne};function Tf(e){let{inputs:t,backend:n}=e,{x:a}=t;if(a.dtype==="complex64"){let r=Bp({inputs:{input:a},backend:n}),s=Tf({inputs:{x:r},backend:n}),i=Nf({inputs:{input:a},backend:n}),o=Tf({inputs:{x:i},backend:n}),l=Ds({inputs:{real:s,imag:o},backend:n});return n.disposeIntermediateTensorInfo(r),n.disposeIntermediateTensorInfo(s),n.disposeIntermediateTensorInfo(i),n.disposeIntermediateTensorInfo(o),l}else return Vp({attrs:{shape:a.shape,dtype:a.dtype,value:a.dtype==="string"?"":0},backend:n})}var Yne={kernelName:Xl,backendName:"webgl",kernelFunc:Tf};function Bk(e){let{inputs:t,backend:n}=e,{x:a}=t;if(a.dtype==="string")throw new Error("onesLike is not supported under string dtype");if(a.dtype==="complex64"){let r=Bp({inputs:{input:a},backend:n}),s=Bk({inputs:{x:r},backend:n}),i=Nf({inputs:{input:a},backend:n}),o=Tf({inputs:{x:i},backend:n}),l=Ds({inputs:{real:s,imag:o},backend:n});return n.disposeIntermediateTensorInfo(r),n.disposeIntermediateTensorInfo(s),n.disposeIntermediateTensorInfo(i),n.disposeIntermediateTensorInfo(o),l}else return Vp({attrs:{shape:a.shape,dtype:a.dtype,value:1},backend:n})}var Jne={kernelName:Rl,backendName:"webgl",kernelFunc:Bk};function Qne(e){let{inputs:t,backend:n,attrs:a}=e,{axis:r}=a;if(t.length===1)return K2({inputs:{input:t[0]},backend:n,attrs:{dim:r}});let s=t[0].shape,i=t[0].dtype;t.forEach(u=>{w.assertShapesMatch(s,u.shape,"All tensors passed to stack must have matching shapes"),w.assert(i===u.dtype,()=>"All tensors passed to stack must have matching dtypes")});let o=[],l=t.map(u=>{let p=K2({inputs:{input:u},backend:n,attrs:{dim:r}});return o.push(p),p}),d=xk({inputs:l,backend:n,attrs:{axis:r}});return o.forEach(u=>n.disposeIntermediateTensorInfo(u)),d}var eae={kernelName:Ml,backendName:"webgl",kernelFunc:Qne},tae=class{constructor(e,t,n){this.variableNames=["x"],this.customUniforms=[{name:"value",type:"float"}],this.outputShape=t.map((l,d)=>l[0]+e[d]+l[1]);let a=e.length,r=yt(a),s=t.map(l=>l[0]).join(","),i=t.map((l,d)=>l[0]+e[d]).join(","),o=["coords[0]","coords[1]","coords[2]","coords[3]"].slice(0,a);if(a===1){this.userCode= `
int start = $ { s } ;
int end = $ { i } ;
2021-09-11 16:29:31 +02:00
void main ( ) {
int outC = getOutputCoords ( ) ;
if ( outC < start || outC >= end ) {
setOutput ( value ) ;
} else {
setOutput ( getX ( outC - start ) ) ;
}
}
` ;return}this.userCode= `
2021-10-22 22:09:52 +02:00
$ { r } start = $ { r } ( $ { s } ) ;
$ { r } end = $ { r } ( $ { i } ) ;
2021-09-11 16:29:31 +02:00
void main ( ) {
2021-10-04 23:03:36 +02:00
$ { r } outC = getOutputCoords ( ) ;
2021-09-11 16:29:31 +02:00
if ( any ( lessThan ( outC , start ) ) || any ( greaterThanEqual ( outC , end ) ) ) {
setOutput ( value ) ;
} else {
2021-10-04 23:03:36 +02:00
$ { r } coords = outC - start ;
2021-10-22 22:09:52 +02:00
setOutput ( getX ( $ { o } ) ) ;
2021-09-11 16:29:31 +02:00
}
}
2021-10-22 22:09:52 +02:00
` }},nae=class{constructor(e,t,n){this.variableNames=["x"],this.packedInputs=!0,this.packedOutput=!0,this.customUniforms=[{name:"value",type:"float"}],this.outputShape=t.map((f,m)=>f[0]+e[m]+f[1]);let a=e.length,r=yt(a),s=t.map(f=>f[0]).join(","),i=t.map((f,m)=>f[0]+e[m]).join(","),o=On("rc",a),l=On("source",a),d= ` $ { o [ a - 1 ] } < $ { this . outputShape [ a - 1 ] } ` ,u=a===1?"source": ` vec2 ( $ { l . slice ( - 2 ) . join ( ) } ) ` ,p=[ ` $ { r } rc = outputLoc ; ` , ` $ { o [ a - 1 ] } += 1 ;
if ( $ { d } ) {
` ,a===1?"": ` }
2021-09-11 16:29:31 +02:00
rc = outputLoc ;
2021-10-22 22:09:52 +02:00
$ { o [ a - 2 ] } += 1 ;
if ( $ { o [ a - 2 ] } < $ { this . outputShape [ a - 2 ] } ) { ` ,a===1?"": ` $ { o [ a - 1 ] } += 1 ;
if ( $ { d } ) { ` ],c=a===1?"rc < start || rc >= end":"any(lessThan(rc, start)) || any(greaterThanEqual(rc, end))",h="";for(let f=0,m=a===1?2:4;f<m;f++)h+= `
$ { p [ f ] }
if ( $ { c } ) {
2021-10-07 16:33:10 +02:00
result [ $ { f } ] = float ( value ) ;
2021-09-11 16:29:31 +02:00
} else {
2021-10-04 23:03:36 +02:00
$ { r } source = rc - start ;
2021-10-07 16:33:10 +02:00
result [ $ { f } ] = getChannel ( getX ( $ { l . join ( ) } ) , $ { u } ) ;
2021-09-11 16:29:31 +02:00
}
2021-10-22 22:09:52 +02:00
` ;h+=a===1?"} ":"}}",this.userCode= `
const $ { r } start = $ { r } ( $ { s } ) ;
const $ { r } end = $ { r } ( $ { i } ) ;
2021-09-11 16:29:31 +02:00
void main ( ) {
2021-10-04 23:03:36 +02:00
$ { r } outputLoc = getOutputCoords ( ) ;
2021-09-11 16:29:31 +02:00
vec4 result = vec4 ( 0. ) ;
2021-10-04 23:03:36 +02:00
$ { h }
2021-09-11 16:29:31 +02:00
setOutput ( result ) ;
}
2021-10-22 22:09:52 +02:00
` }},Vk=e=>{let{inputs:t,backend:n,attrs:a}=e,{x:r}=t,{paddings:s,constantValue:i}=a;if(w.sizeFromShape(r.shape)===0){let d=s.map((u,p)=>u[0]+r.shape[p]+u[1]);return Vp({backend:n,attrs:{shape:d,value:i,dtype:r.dtype}})}let o=ne().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new nae(r.shape,s,i):new tae(r.shape,s,i),l=[[i]];return n.runWebGLProgram(o,[r],r.dtype,l)},aae={kernelName:Ti,backendName:"webgl",kernelFunc:Vk},rae= `
2021-09-11 16:29:31 +02:00
if ( a < 0.0 && floor ( b ) < b ) {
return NAN ;
}
if ( b == 0.0 ) {
return 1.0 ;
2021-09-05 22:42:11 +02:00
}
2021-09-11 16:29:31 +02:00
return ( round ( mod ( b , 2.0 ) ) != 1 ) ?
pow ( abs ( a ) , b ) : sign ( a ) * pow ( abs ( a ) , b ) ;
2021-10-22 22:09:52 +02:00
` ,sae= `
2021-09-11 16:29:31 +02:00
// isModRound1 has 1 for components with round(mod(b, 2.0)) == 1, 0 otherwise.
vec4 isModRound1 = vec4 ( equal ( round ( mod ( b , 2.0 ) ) , ivec4 ( 1 ) ) ) ;
vec4 multiplier = sign ( a ) * isModRound1 + ( vec4 ( 1.0 ) - isModRound1 ) ;
vec4 result = multiplier * pow ( abs ( a ) , b ) ;
// Ensure that a^0 = 1, including 0^0 = 1 as this correspond to TF and JS
bvec4 isExpZero = equal ( b , vec4 ( 0.0 ) ) ;
result . r = isExpZero . r ? 1.0 : result . r ;
result . g = isExpZero . g ? 1.0 : result . g ;
result . b = isExpZero . b ? 1.0 : result . b ;
result . a = isExpZero . a ? 1.0 : result . a ;
vec4 isNaN = vec4 ( lessThan ( a , vec4 ( 0.0 ) ) ) * vec4 ( lessThan ( floor ( b ) , b ) ) ;
2021-10-22 22:09:52 +02:00
` +xf+ `
2021-09-11 16:29:31 +02:00
return result ;
2021-10-22 22:09:52 +02:00
` ,iae=vn({opSnippet:rae,packedOpSnippet:sae}),oae={kernelName:Ci,backendName:"webgl",kernelFunc:iae};function lae(e){let{inputs:t,backend:n,attrs:a}=e,{x:r}=t,{axis:s,keepDims:i}=a,o=r.shape.length,l=[],d=w.parseAxisParam(s,r.shape),u=d,p=E.getAxesPermutation(u,o),c=r;p!=null&&(c=_n({inputs:{x:r},backend:n,attrs:{perm:p}}),u=E.getInnerMostAxes(u.length,o),l.push(c)),E.assertAxesAreInnerMostDims("prod",u,o);let h;if(n.shouldExecuteOnCPU([c])){let f=n.texData.get(c.dataId).values,{outVals:m,outShape:g,outDtype:y}=mZ(c.shape,c.dtype,f,u);h=n.makeTensorInfo(g,y,m)}else{let[f,m]=E.computeOutAndReduceShapes(c.shape,u),g=w.sizeFromShape(m),y=we({inputs:{x:c},backend:n,attrs:{shape:[-1,g]}}),A=Eh(r.dtype),x=Co(y,A,"prod",n);h=we({inputs:{x},backend:n,attrs:{shape:f}}),l.push(y),l.push(x)}if(i){l.push(h);let f=E.expandShapeToKeepDim(h.shape,d);h=we({inputs:{x:h},backend:n,attrs:{shape:f}})}return l.forEach(f=>n.disposeIntermediateTensorInfo(f)),h}var uae={kernelName:Fl,backendName:"webgl",kernelFunc:lae},Uk=e=>{let{backend:t,attrs:n}=e,{start:a,stop:r,step:s,dtype:i}=n,o=gZ(a,r,s,i);return t.makeTensorInfo([o.length],i,o)},dae={kernelName:Td,backendName:"webgl",kernelFunc:Uk},pae="return 1.0 / x;",cae=nt({opSnippet:pae}),hae={kernelName:Dl,backendName:"webgl",kernelFunc:cae},fae=lr+ `
2021-09-11 16:29:31 +02:00
return ( x < 0.0 ) ? 0.0 : x ;
2021-10-22 22:09:52 +02:00
` ,mae= `
2021-09-11 16:29:31 +02:00
vec4 result = x * vec4 ( greaterThanEqual ( x , vec4 ( 0.0 ) ) ) ;
bvec4 isNaN = isnan ( x ) ;
result . r = isNaN . r ? x . r : result . r ;
result . g = isNaN . g ? x . g : result . g ;
result . b = isNaN . b ? x . b : result . b ;
result . a = isNaN . a ? x . a : result . a ;
return result ;
2021-10-22 22:09:52 +02:00
` ,gae=nt({opSnippet:fae,packedOpSnippet:mae}),yae={kernelName:Ri,backendName:"webgl",kernelFunc:gae},Aae=lr+ `
2021-09-11 16:29:31 +02:00
return ( x < 0.0 ) ? 0.0 : min ( 6.0 , x ) ;
2021-10-22 22:09:52 +02:00
` ,xae= `
2021-09-11 16:29:31 +02:00
vec4 result = min ( x , vec4 ( 6. ) ) * vec4 ( greaterThanEqual ( x , vec4 ( 0.0 ) ) ) ;
bvec4 isNaN = isnan ( x ) ;
result . r = isNaN . r ? x . r : result . r ;
result . g = isNaN . g ? x . g : result . g ;
result . b = isNaN . b ? x . b : result . b ;
result . a = isNaN . a ? x . a : result . a ;
return result ;
2021-10-22 22:09:52 +02:00
` ,bae=nt({opSnippet:Aae,packedOpSnippet:xae}),vae={kernelName:Fi,backendName:"webgl",kernelFunc:bae},wae=class{constructor(e,t,n,a,r){this.variableNames=["A"],this.outputShape=[];let[s,i,o,l]=e;this.outputShape=[s,t,n,l];let d=[a&&t>1?i-1:i,a&&n>1?o-1:o],u=[a&&t>1?t-1:t,a&&n>1?n-1:n],p;r?p="(vec2(yRC) + vec2(0.5)) * effectiveInputOverOutputRatioRC - vec2(0.5)":p="vec2(yRC) * effectiveInputOverOutputRatioRC",this.userCode= `
2021-09-11 16:29:31 +02:00
const vec2 effectiveInputOverOutputRatioRC = vec2 (
2021-10-22 22:09:52 +02:00
$ { d [ 0 ] / u [ 0 ] } ,
$ { d [ 1 ] / u [ 1 ] } ) ;
const vec2 inputShapeRC = vec2 ( $ { i } . 0 , $ { o } . 0 ) ;
2021-09-11 16:29:31 +02:00
void main ( ) {
ivec4 coords = getOutputCoords ( ) ;
int b = coords [ 0 ] ;
int d = coords [ 3 ] ;
ivec2 yRC = coords . yz ;
2021-09-01 00:24:30 +02:00
2021-09-11 16:29:31 +02:00
// Fractional source index.
2021-10-22 22:09:52 +02:00
vec2 sourceFracIndexRC = $ { p } ;
2021-09-11 16:29:31 +02:00
// Compute the four integer indices.
ivec2 sourceFloorRC = ivec2 ( max ( sourceFracIndexRC , vec2 ( 0.0 ) ) ) ;
ivec2 sourceCeilRC = ivec2 (
min ( inputShapeRC - 1.0 , ceil ( sourceFracIndexRC ) ) ) ;
float topLeft = getA ( b , sourceFloorRC . x , sourceFloorRC . y , d ) ;
float bottomLeft = getA ( b , sourceCeilRC . x , sourceFloorRC . y , d ) ;
float topRight = getA ( b , sourceFloorRC . x , sourceCeilRC . y , d ) ;
float bottomRight = getA ( b , sourceCeilRC . x , sourceCeilRC . y , d ) ;
vec2 fracRC = sourceFracIndexRC - vec2 ( sourceFloorRC ) ;
float top = topLeft + ( topRight - topLeft ) * fracRC . y ;
float bottom = bottomLeft + ( bottomRight - bottomLeft ) * fracRC . y ;
float newValue = top + ( bottom - top ) * fracRC . x ;
setOutput ( newValue ) ;
2021-09-05 22:42:11 +02:00
}
2021-10-22 22:09:52 +02:00
` }},kae=class{constructor(e,t,n,a,r){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=[];let[s,i,o,l]=e;this.outputShape=[s,t,n,l];let d=[a&&t>1?i-1:i,a&&n>1?o-1:o],u=[a&&t>1?t-1:t,a&&n>1?n-1:n],p;r?p="(vec3(yRC) + vec3(0.5)) * effectiveInputOverOutputRatioRC - vec3(0.5)":p="vec3(yRC) * effectiveInputOverOutputRatioRC",this.userCode= `
2021-09-11 16:29:31 +02:00
const vec3 effectiveInputOverOutputRatioRC = vec3 (
2021-10-22 22:09:52 +02:00
$ { d [ 0 ] / u [ 0 ] } ,
$ { d [ 1 ] / u [ 1 ] } ,
$ { d [ 1 ] / u [ 1 ] } ) ;
const vec3 inputShapeRC = vec3 ( $ { i } . 0 , $ { o } . 0 ,
$ { o } . 0 ) ;
2021-09-11 16:29:31 +02:00
float getAValue ( int b , int r , int c , int d ) {
return getChannel ( getA ( b , r , c , d ) , vec2 ( c , d ) ) ;
2021-09-05 22:42:11 +02:00
}
2021-09-01 00:24:30 +02:00
2021-09-11 16:29:31 +02:00
void main ( ) {
ivec4 coords = getOutputCoords ( ) ;
int b = coords [ 0 ] ;
int d = coords [ 3 ] ;
// Calculate values for next column in yRC.z.
ivec3 yRC = coords . yzz + ivec3 ( 0 , 0 , 1 ) ;
2021-09-01 00:24:30 +02:00
2021-09-11 16:29:31 +02:00
// Fractional source index.
2021-10-22 22:09:52 +02:00
vec3 sourceFracIndexRC = $ { p } ;
2021-09-11 16:29:31 +02:00
// Compute the four integer indices.
ivec3 sourceFloorRC = ivec3 ( max ( sourceFracIndexRC , vec3 ( 0.0 ) ) ) ;
ivec3 sourceCeilRC = ivec3 (
min ( inputShapeRC - 1.0 , ceil ( sourceFracIndexRC ) ) ) ;
// Should we calculate next column and row elements in 2x2 packed cell.
bool hasNextCol = d < $ { l - 1 } ;
bool hasNextRow = coords . z < $ { n - 1 } ;
// In parallel, construct four corners for all four components in
// packed 2x2 cell.
vec4 topLeft = vec4 (
getAValue ( b , sourceFloorRC . x , sourceFloorRC . y , d ) ,
hasNextCol ? getAValue ( b , sourceFloorRC . x , sourceFloorRC . y , d + 1 )
: 0.0 ,
hasNextRow ? getAValue ( b , sourceFloorRC . x , sourceFloorRC . z , d )
: 0.0 ,
( hasNextRow && hasNextCol ) ?
getAValue ( b , sourceFloorRC . x , sourceFloorRC . z , d + 1 ) : 0.0 ) ;
vec4 bottomLeft = vec4 (
getAValue ( b , sourceCeilRC . x , sourceFloorRC . y , d ) ,
hasNextCol ? getAValue ( b , sourceCeilRC . x , sourceFloorRC . y , d + 1 )
: 0.0 ,
hasNextRow ? getAValue ( b , sourceCeilRC . x , sourceFloorRC . z , d )
: 0.0 ,
( hasNextRow && hasNextCol ) ?
getAValue ( b , sourceCeilRC . x , sourceFloorRC . z , d + 1 ) : 0.0 ) ;
vec4 topRight = vec4 (
getAValue ( b , sourceFloorRC . x , sourceCeilRC . y , d ) ,
hasNextCol ? getAValue ( b , sourceFloorRC . x , sourceCeilRC . y , d + 1 )
: 0.0 ,
hasNextRow ? getAValue ( b , sourceFloorRC . x , sourceCeilRC . z , d )
: 0.0 ,
( hasNextRow && hasNextCol ) ?
getAValue ( b , sourceFloorRC . x , sourceCeilRC . z , d + 1 ) : 0.0 ) ;
vec4 bottomRight = vec4 (
getAValue ( b , sourceCeilRC . x , sourceCeilRC . y , d ) ,
hasNextCol ? getAValue ( b , sourceCeilRC . x , sourceCeilRC . y , d + 1 )
: 0.0 ,
hasNextRow ? getAValue ( b , sourceCeilRC . x , sourceCeilRC . z , d )
: 0.0 ,
( hasNextRow && hasNextCol ) ?
getAValue ( b , sourceCeilRC . x , sourceCeilRC . z , d + 1 ) : 0.0 ) ;
vec3 fracRC = sourceFracIndexRC - vec3 ( sourceFloorRC ) ;
vec4 top = mix ( topLeft , topRight , fracRC . yyzz ) ;
vec4 bottom = mix ( bottomLeft , bottomRight , fracRC . yyzz ) ;
vec4 newValue = mix ( top , bottom , fracRC . x ) ;
setOutput ( newValue ) ;
2021-09-05 22:42:11 +02:00
}
2021-10-22 22:09:52 +02:00
` }};function Iae(e){let{inputs:t,backend:n,attrs:a}=e,{images:r}=t,{alignCorners:s,halfPixelCenters:i,size:o}=a,[l,d]=o,u=ne().getBool("WEBGL_PACK_IMAGE_OPERATIONS")?new kae(r.shape,l,d,s,i):new wae(r.shape,l,d,s,i);return n.runWebGLProgram(u,[r],"float32")}var Sae={kernelName:Mi,backendName:"webgl",kernelFunc:Iae},Nae=class{constructor(e,t,n){this.variableNames=["dy"],this.outputShape=[],this.outputShape=t;let[,a,r]=t,[,s,i]=e,o=[n&&s>1?a-1:a,n&&i>1?r-1:r],l=[n&&s>1?s-1:s,n&&i>1?i-1:i],d=o[0]/l[0],u=o[1]/l[1],p=1/d,c=1/u,h=Math.ceil(p)*2+2,f=Math.ceil(c)*2+2;this.userCode= `
2021-09-11 16:29:31 +02:00
void main ( ) {
ivec4 coords = getOutputCoords ( ) ;
int b = coords [ 0 ] ;
int d = coords [ 3 ] ;
int r = coords [ 1 ] ;
int c = coords [ 2 ] ;
float accumulator = 0.0 ;
2021-10-22 22:09:52 +02:00
const float heightScale = float ( $ { d } ) ;
2021-10-07 16:33:10 +02:00
const float widthScale = float ( $ { u } ) ;
2021-09-11 16:29:31 +02:00
2021-10-22 22:09:52 +02:00
const float invHeightScale = float ( $ { p } ) ;
const float invWidthScale = float ( $ { c } ) ;
2021-09-11 16:29:31 +02:00
2021-10-04 23:03:36 +02:00
const int winHeight = int ( $ { h } ) ;
2021-10-07 16:33:10 +02:00
const int winWidth = int ( $ { f } ) ;
2021-09-11 16:29:31 +02:00
// Compute bounds for where in dy we will look
float startRLerp = floor ( float ( r ) * invHeightScale ) ;
int startDyR = int ( startRLerp - float ( winHeight / 2 ) ) ;
float startCLerp = floor ( float ( c ) * invWidthScale ) ;
int startDyC = int ( startCLerp - float ( winWidth / 2 ) ) ;
// Loop over dy
for ( int dyROffset = 0 ; dyROffset < winHeight ; dyROffset ++ ) {
int dyR = dyROffset + startDyR ;
// Guard against the window exceeding the bounds of dy
2021-10-22 22:09:52 +02:00
if ( dyR < 0 || dyR >= $ { s } ) {
2021-09-11 16:29:31 +02:00
continue ;
2021-09-01 00:22:16 +02:00
}
2021-09-01 00:24:30 +02:00
2021-09-11 16:29:31 +02:00
for ( int dyCOffset = 0 ; dyCOffset < winWidth ; dyCOffset ++ ) {
int dyC = dyCOffset + startDyC ;
2021-09-01 00:24:30 +02:00
2021-09-11 16:29:31 +02:00
// Guard against the window exceeding the bounds of dy
2021-10-22 22:09:52 +02:00
if ( dyC < 0 || dyC >= $ { i } ) {
2021-09-11 16:29:31 +02:00
continue ;
}
2021-09-01 00:24:30 +02:00
2021-09-11 16:29:31 +02:00
float dxR = float ( dyR ) * heightScale ;
int topDxRIndex = int ( floor ( dxR ) ) ;
2021-10-22 22:09:52 +02:00
int bottomDxRIndex = int ( min ( ceil ( dxR ) , $ { a - 1 } . 0 ) ) ;
2021-09-11 16:29:31 +02:00
float dxRLerp = dxR - float ( topDxRIndex ) ;
float inverseDxRLerp = 1.0 - dxRLerp ;
float dxC = float ( dyC ) * widthScale ;
int leftDxCIndex = int ( floor ( dxC ) ) ;
2021-10-04 23:03:36 +02:00
int rightDxCIndex = int ( min ( ceil ( dxC ) , $ { r - 1 } . 0 ) ) ;
2021-09-11 16:29:31 +02:00
float dxCLerp = dxC - float ( leftDxCIndex ) ;
float inverseDxCLerp = 1.0 - dxCLerp ;
if ( r == topDxRIndex && c == leftDxCIndex ) {
// topLeft
accumulator +=
getDy ( b , dyR , dyC , d ) * inverseDxRLerp * inverseDxCLerp ;
}
if ( r == topDxRIndex && c == rightDxCIndex ) {
// topRight
accumulator += getDy ( b , dyR , dyC , d ) * inverseDxRLerp * dxCLerp ;
}
if ( r == bottomDxRIndex && c == leftDxCIndex ) {
// bottomLeft
accumulator += getDy ( b , dyR , dyC , d ) * dxRLerp * inverseDxCLerp ;
}
if ( r == bottomDxRIndex && c == rightDxCIndex ) {
// bottomRight
accumulator += getDy ( b , dyR , dyC , d ) * dxRLerp * dxCLerp ;
2021-09-05 22:42:11 +02:00
}
}
}
2021-09-11 16:29:31 +02:00
// End loop over dy
setOutput ( accumulator ) ;
2021-09-01 00:22:16 +02:00
}
2021-10-22 22:09:52 +02:00
` }};function Tae(e){let{inputs:t,backend:n,attrs:a}=e,{images:r,dy:s}=t,{alignCorners:i}=a,o=new Nae(s.shape,r.shape,i);return n.runWebGLProgram(o,[s],s.dtype)}var Cae={kernelName:hh,backendName:"webgl",kernelFunc:Tae},Eae=class{constructor(e,t,n,a,r){this.variableNames=["A"],this.outputShape=[];let[s,i,o,l]=e;this.outputShape=[s,t,n,l];let d=[a&&t>1?i-1:i,a&&n>1?o-1:o],u=[a&&t>1?t-1:t,a&&n>1?n-1:n],p=a?"0.5":"0.0",c;r?c="max((vec2(yRC) + vec2(0.5)) * effectiveInputOverOutputRatioRC, vec2(0.0))":c="vec2(yRC) * effectiveInputOverOutputRatioRC",this.userCode= `
2021-09-11 16:29:31 +02:00
const vec2 effectiveInputOverOutputRatioRC = vec2 (
2021-10-22 22:09:52 +02:00
$ { d [ 0 ] / u [ 0 ] } ,
$ { d [ 1 ] / u [ 1 ] } ) ;
const vec2 inputShapeRC = vec2 ( $ { i } . 0 , $ { o } . 0 ) ;
2021-09-11 16:29:31 +02:00
void main ( ) {
ivec4 coords = getOutputCoords ( ) ;
int b = coords [ 0 ] ;
int d = coords [ 3 ] ;
ivec2 yRC = coords . yz ;
// Fractional source index.
2021-10-22 22:09:52 +02:00
vec2 sourceFracIndexRC = $ { c } ;
2021-09-11 16:29:31 +02:00
// Compute the coordinators of nearest neighbor point.
ivec2 sourceNearestRC = ivec2 (
2021-10-22 22:09:52 +02:00
min ( inputShapeRC - 1.0 , floor ( sourceFracIndexRC + $ { p } ) ) ) ;
2021-09-11 16:29:31 +02:00
float newValue = getA ( b , sourceNearestRC . x , sourceNearestRC . y , d ) ;
setOutput ( newValue ) ;
}
2021-10-22 22:09:52 +02:00
` }},Rae=class{constructor(e,t,n,a,r){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=[];let[s,i,o,l]=e;this.outputShape=[s,t,n,l];let d=[a&&t>1?i-1:i,a&&n>1?o-1:o],u=[a&&t>1?t-1:t,a&&n>1?n-1:n],p=a?"0.5":"0.0",c;r?c="max((vec3(yRC) + vec3(0.5)) * effectiveInputOverOutputRatioRC, vec3(0.0))":c="vec3(yRC) * effectiveInputOverOutputRatioRC",this.userCode= `
2021-09-11 16:29:31 +02:00
const vec3 effectiveInputOverOutputRatioRC = vec3 (
2021-10-22 22:09:52 +02:00
$ { d [ 0 ] / u [ 0 ] } ,
$ { d [ 1 ] / u [ 1 ] } ,
$ { d [ 1 ] / u [ 1 ] } ) ;
const vec3 inputShapeRC = vec3 ( $ { i } . 0 , $ { o } . 0 ,
$ { o } . 0 ) ;
2021-09-11 16:29:31 +02:00
float getAValue ( int b , int r , int c , int d ) {
return getChannel ( getA ( b , r , c , d ) , vec2 ( c , d ) ) ;
}
void main ( ) {
ivec4 coords = getOutputCoords ( ) ;
int b = coords [ 0 ] ;
int d = coords [ 3 ] ;
// Calculate values for next column in yRC.z.
ivec3 yRC = coords . yzz + ivec3 ( 0 , 0 , 1 ) ;
// Fractional source index.
2021-10-22 22:09:52 +02:00
vec3 sourceFracIndexRC = $ { c } ;
2021-09-11 16:29:31 +02:00
// Compute the coordinators of nearest neighbor point.
ivec3 sourceNearestRC = ivec3 (
2021-10-22 22:09:52 +02:00
min ( inputShapeRC - 1.0 , floor ( sourceFracIndexRC + $ { p } ) ) ) ;
2021-09-11 16:29:31 +02:00
// Should we calculate next column and row elements in 2x2 packed cell.
bool hasNextCol = d < $ { l - 1 } ;
bool hasNextRow = coords . z < $ { n - 1 } ;
vec4 newValue = vec4 (
getAValue ( b , sourceNearestRC . x , sourceNearestRC . y , d ) ,
hasNextCol ? getAValue ( b , sourceNearestRC . x , sourceNearestRC . y , d + 1 )
: 0.0 ,
hasNextRow ? getAValue ( b , sourceNearestRC . x , sourceNearestRC . z , d )
: 0.0 ,
( hasNextRow && hasNextCol ) ?
getAValue ( b , sourceNearestRC . x , sourceNearestRC . z , d + 1 ) : 0.0 ) ;
2021-08-14 17:17:51 +02:00
2021-09-11 16:29:31 +02:00
setOutput ( newValue ) ;
2021-09-05 22:42:11 +02:00
}
2021-10-22 22:09:52 +02:00
` }};function Mae(e){let{inputs:t,backend:n,attrs:a}=e,{images:r}=t,{alignCorners:s,halfPixelCenters:i,size:o}=a,[l,d]=o,u=ne().getBool("WEBGL_PACK_IMAGE_OPERATIONS")?new Rae(r.shape,l,d,s,i):new Eae(r.shape,l,d,s,i);return n.runWebGLProgram(u,[r],r.dtype)}var Fae={kernelName:Cd,backendName:"webgl",kernelFunc:Mae},Dae=class{constructor(e,t,n){this.variableNames=["dy"],this.outputShape=[],this.outputShape=t;let[,a,r]=t,[,s,i]=e,o=[n&&s>1?a-1:a,n&&i>1?r-1:r],l=[n&&s>1?s-1:s,n&&i>1?i-1:i],d=o[0]/l[0],u=o[1]/l[1],p=1/d,c=1/u,h=Math.ceil(p)*2+2,f=Math.ceil(c)*2+2;this.userCode= `
2021-09-11 16:29:31 +02:00
void main ( ) {
ivec4 coords = getOutputCoords ( ) ;
int b = coords [ 0 ] ;
int d = coords [ 3 ] ;
int r = coords [ 1 ] ;
int c = coords [ 2 ] ;
2021-08-14 17:17:51 +02:00
2021-09-11 16:29:31 +02:00
float accumulator = 0.0 ;
2021-08-14 17:17:51 +02:00
2021-10-22 22:09:52 +02:00
const float heightScale = float ( $ { d } ) ;
2021-10-07 16:33:10 +02:00
const float widthScale = float ( $ { u } ) ;
2021-09-01 00:24:30 +02:00
2021-10-22 22:09:52 +02:00
const float invHeightScale = float ( $ { p } ) ;
const float invWidthScale = float ( $ { c } ) ;
2021-09-01 00:24:30 +02:00
2021-10-04 23:03:36 +02:00
const int winHeight = int ( $ { h } ) ;
2021-10-07 16:33:10 +02:00
const int winWidth = int ( $ { f } ) ;
2021-09-01 00:24:30 +02:00
2021-09-11 16:29:31 +02:00
// Compute bounds for where in dy we will look
float startRLerp = floor ( float ( r ) * invHeightScale ) ;
int startDyR = int ( floor ( startRLerp - float ( winHeight / 2 ) ) ) ;
float startCLerp = floor ( float ( c ) * invWidthScale ) ;
int startDyC = int ( floor ( startCLerp - float ( winWidth / 2 ) ) ) ;
// Loop over dy
for ( int dyROffset = 0 ; dyROffset < winHeight ; dyROffset ++ ) {
int dyR = dyROffset + startDyR ;
// Guard against the window exceeding the bounds of dy
2021-10-22 22:09:52 +02:00
if ( dyR < 0 || dyR >= $ { s } ) {
2021-07-29 22:06:03 +02:00
continue ;
2021-09-11 16:29:31 +02:00
}
2021-07-29 22:35:16 +02:00
2021-09-11 16:29:31 +02:00
for ( int dyCOffset = 0 ; dyCOffset < winWidth ; dyCOffset ++ ) {
int dyC = dyCOffset + startDyC ;
2021-08-14 17:16:26 +02:00
2021-09-11 16:29:31 +02:00
// Guard against the window exceeding the bounds of dy
2021-10-22 22:09:52 +02:00
if ( dyC < 0 || dyC >= $ { i } ) {
2021-09-11 16:29:31 +02:00
continue ;
}
2021-07-29 15:53:13 +02:00
2021-09-11 16:29:31 +02:00
float sourceFracRow =
2021-10-22 22:09:52 +02:00
float ( $ { o [ 0 ] } ) *
2021-09-11 16:29:31 +02:00
( float ( dyR ) / float ( $ { l [ 0 ] } ) ) ;
2021-08-14 17:17:51 +02:00
2021-09-11 16:29:31 +02:00
float sourceFracCol =
2021-10-22 22:09:52 +02:00
float ( $ { o [ 1 ] } ) *
2021-09-11 16:29:31 +02:00
( float ( dyC ) / float ( $ { l [ 1 ] } ) ) ;
2021-08-14 17:17:51 +02:00
2021-09-11 16:29:31 +02:00
int sourceNearestRow = int ( min (
2021-10-22 22:09:52 +02:00
float ( int ( $ { a } ) - 1 ) ,
2021-09-11 16:29:31 +02:00
$ { n } ? float ( round ( sourceFracRow ) ) :
float ( floor ( sourceFracRow ) ) ) ) ;
2021-09-01 00:24:30 +02:00
2021-09-11 16:29:31 +02:00
int sourceNearestCol = int ( min (
2021-10-04 23:03:36 +02:00
float ( int ( $ { r } ) - 1 ) ,
2021-09-11 16:29:31 +02:00
$ { n } ? float ( round ( sourceFracCol ) ) :
float ( floor ( sourceFracCol ) ) ) ) ;
if ( r == sourceNearestRow && c == sourceNearestCol ) {
accumulator += getDy ( b , dyR , dyC , d ) ;
}
2021-07-29 22:06:03 +02:00
}
}
2021-09-11 16:29:31 +02:00
// End loop over dy
2021-09-05 22:42:11 +02:00
2021-09-11 16:29:31 +02:00
setOutput ( accumulator ) ;
2021-07-29 22:06:03 +02:00
}
2021-10-22 22:09:52 +02:00
` }};function $ ae(e){let{inputs:t,backend:n,attrs:a}=e,{images:r,dy:s}=t,{alignCorners:i}=a,o=new Dae(s.shape,r.shape,i);return n.runWebGLProgram(o,[s],s.dtype)}var Oae={kernelName:ch,backendName:"webgl",kernelFunc: $ ae},_ae=class{constructor(e,t){this.variableNames=["x"];let n=e.length;if(n>4)throw new Error( ` WebGL backend : Reverse of rank - $ { n } tensor is not yet supported ` );if(this.outputShape=e,n===1){this.userCode= `
2021-09-11 16:29:31 +02:00
void main ( ) {
int coord = getOutputCoords ( ) ;
setOutput ( getX ( $ { e [ 0 ] } - coord - 1 ) ) ;
2021-08-14 17:16:26 +02:00
}
2021-10-22 22:09:52 +02:00
` ;return}let a=i=>t.indexOf(i)!==-1&&e[i]!==1? ` $ { e [ i ] } - coords [ $ { i } ] - 1 ` : ` coords [ $ { i } ] ` ,r=e.map((i,o)=>a(o)).join(","),s=yt(n);this.userCode= `
2021-09-11 16:29:31 +02:00
void main ( ) {
2021-10-22 22:09:52 +02:00
$ { s } coords = getOutputCoords ( ) ;
2021-10-04 23:03:36 +02:00
setOutput ( getX ( $ { r } ) ) ;
2021-09-11 16:29:31 +02:00
}
2021-10-22 22:09:52 +02:00
` }},Pae=class{constructor(e,t){this.variableNames=["x"],this.packedInputs=!0,this.packedOutput=!0;let n=e.length;if(n>4)throw new Error( ` WebGL backend : Reverse of rank - $ { n } tensor is not yet supported ` );this.outputShape=e;let a=On("rc",n),r= ` $ { a [ n - 1 ] } + 1 < $ { this . outputShape [ n - 1 ] } ` ,s= ` $ { a [ n - 2 ] } + 1 < $ { this . outputShape [ n - 2 ] } ` ,i=yt(n);n===1?this.userCode= `
2021-09-11 16:29:31 +02:00
void main ( ) {
int rc = getOutputCoords ( ) ;
vec4 result = vec4 ( 0. ) ;
result . r = getChannel ( getX ( $ { e [ 0 ] } - rc - 1 ) ,
$ { e [ 0 ] } - rc - 1 ) ;
2021-10-04 23:03:36 +02:00
if ( $ { r } ) {
2021-09-11 16:29:31 +02:00
result . g = getChannel ( getX ( $ { e [ 0 ] } - ( rc + 1 ) - 1 ) ,
$ { e [ 0 ] } - ( rc + 1 ) - 1 ) ;
2021-08-14 17:17:51 +02:00
}
2021-09-11 16:29:31 +02:00
setOutput ( result ) ;
2021-08-14 17:16:26 +02:00
}
2021-09-11 16:29:31 +02:00
` :this.userCode= `
void main ( ) {
2021-10-22 22:09:52 +02:00
$ { i } rc = getOutputCoords ( ) ;
2021-09-11 16:29:31 +02:00
vec4 result = vec4 ( 0. ) ;
2021-10-22 22:09:52 +02:00
result . r = $ { o ( a . slice ( ) ) } ;
2021-10-04 23:03:36 +02:00
if ( $ { r } ) {
2021-10-22 22:09:52 +02:00
result . g = $ { l ( a . slice ( ) ) } ;
2021-09-11 16:29:31 +02:00
}
2021-10-22 22:09:52 +02:00
if ( $ { s } ) {
result . b = $ { d ( a . slice ( ) ) } ;
2021-10-04 23:03:36 +02:00
if ( $ { r } ) {
2021-10-22 22:09:52 +02:00
result . a = $ { u ( a . slice ( ) ) } ;
2021-09-11 16:29:31 +02:00
}
}
setOutput ( result ) ;
2021-08-14 17:17:51 +02:00
}
2021-10-22 22:09:52 +02:00
` ;function o(h){return p(h)}function l(h){return h[n-1]="("+h[n-1]+" + 1)",p(h)}function d(h){return h[n-2]="("+h[n-2]+" + 1)",p(h)}function u(h){return h[n-1]="("+h[n-1]+" + 1)",h[n-2]="("+h[n-2]+" + 1)",p(h)}function p(h){let f=e.map((y,A)=>c(A,h)),m=f.join(","),g=f.slice(-2).join(",");return ` getChannel ( getX ( $ { m } ) , vec2 ( $ { g } ) ) ` }function c(h,f){return t.indexOf(h)!==-1&&e[h]!==1? ` $ { e [ h ] } - $ { f [ h ] } - 1 ` : ` $ { f [ h ] } ` }}};function zae(e){let{inputs:t,backend:n,attrs:a}=e,{x:r}=t,{dims:s}=a,i=r.shape.length,o=w.parseAxisParam(s,r.shape);if(i===0)return ma({inputs:{x:r},backend:n});let l=ne().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new Pae(r.shape,o):new _ae(r.shape,o);return n.runWebGLProgram(l,[r],r.dtype)}var Lae={kernelName:Di,backendName:"webgl",kernelFunc:zae},Wae=class{constructor(e,t){this.variableNames=["Image"],this.outputShape=[],this.customUniforms=[{name:"params",type:"vec4"}];let n=e[1],a=e[2];this.outputShape=e;let r="";typeof t=="number"?r= ` float outputValue = $ { t . toFixed ( 2 ) } ; ` :r= `
2021-09-11 16:29:31 +02:00
vec3 fill = vec3 ( $ { t . join ( "," ) } ) ;
float outputValue = fill [ coords [ 3 ] ] ; ` ,this.userCode= `
void main ( ) {
ivec4 coords = getOutputCoords ( ) ;
int x = coords [ 2 ] ;
int y = coords [ 1 ] ;
float coordXFloat = ( float ( x ) - params [ 0 ] ) * params [ 3 ] -
( float ( y ) - params [ 1 ] ) * params [ 2 ] ;
float coordYFloat = ( float ( x ) - params [ 0 ] ) * params [ 2 ] +
( float ( y ) - params [ 1 ] ) * params [ 3 ] ;
int coordX = int ( round ( coordXFloat + params [ 0 ] ) ) ;
int coordY = int ( round ( coordYFloat + params [ 1 ] ) ) ;
2021-10-04 23:03:36 +02:00
$ { r }
2021-10-22 22:09:52 +02:00
if ( coordX >= 0 && coordX < $ { a } && coordY >= 0 && coordY < $ { n } ) {
2021-09-11 16:29:31 +02:00
outputValue = getImage ( coords [ 0 ] , coordY , coordX , coords [ 3 ] ) ;
2021-08-14 17:17:51 +02:00
}
2021-09-11 16:29:31 +02:00
setOutput ( outputValue ) ;
2021-08-14 17:17:51 +02:00
}
2021-10-22 22:09:52 +02:00
` }},Bae={kernelName:Kl,backendName:"webgl",kernelFunc:({inputs:e,attrs:t,backend:n})=>{let{image:a}=e,{radians:r,fillValue:s,center:i}=t,o=n,l=new Wae(a.shape,s),[d,u]=E.getImageCenter(i,a.shape[1],a.shape[2]),p=[[d,u,Math.sin(r),Math.cos(r)]];return o.runWebGLProgram(l,[a],a.dtype,p)}},Vae= `
2021-09-11 16:29:31 +02:00
// OpenGL ES does not support round function.
// The algorithm is based on banker's rounding.
float base = floor ( x ) ;
if ( ( x - base ) < 0.5 ) {
return floor ( x ) ;
} else if ( ( x - base ) > 0.5 ) {
return ceil ( x ) ;
} else {
if ( mod ( base , 2.0 ) == 0.0 ) {
return base ;
} else {
return base + 1.0 ;
2021-09-05 22:42:11 +02:00
}
}
2021-10-22 22:09:52 +02:00
` ,Uae=nt({opSnippet:Vae}),jae={kernelName: $ i,backendName:"webgl",kernelFunc:Uae},Gae="return inversesqrt(x);",Hae=nt({opSnippet:Gae,cpuKernelImpl:yZ}),qae={kernelName:Oi,backendName:"webgl",kernelFunc:Hae},jk=class{constructor(e,t,n,a,r,s,i=!0){this.variableNames=["updates","indices","defaultValue"],this.outputShape=s;let o=yt(r.length),l=yt(s.length),d="";n===1?d="i":n===2&&(d="i, j");let u= ` getIndices ( $ { d } ) ` ,p="";a===1?p="i":a===2&&(p="i, coords[1]");let c= ` getUpdates ( $ { p } ) ` ,h=t>1?"strides[j]":"strides";this.userCode= `
$ { o } strides = $ { o } ( $ { r } ) ;
2021-09-05 22:42:11 +02:00
2021-09-11 16:29:31 +02:00
void main ( ) {
$ { l } coords = getOutputCoords ( ) ;
float sum = 0.0 ;
bool found = false ;
for ( int i = 0 ; i < $ { e } ; i ++ ) {
int flattenedIndex = 0 ;
for ( int j = 0 ; j < $ { t } ; j ++ ) {
2021-10-07 16:33:10 +02:00
int index = round ( $ { u } ) ;
2021-10-04 23:03:36 +02:00
flattenedIndex += index * $ { h } ;
2021-09-11 16:29:31 +02:00
}
if ( flattenedIndex == coords [ 0 ] ) {
2021-10-22 22:09:52 +02:00
sum += $ { c } ;
2021-09-11 16:29:31 +02:00
found = true ;
}
}
setOutput ( mix ( getDefaultValue ( ) , sum , float ( found ) ) ) ;
2021-08-14 17:17:51 +02:00
}
2021-10-22 22:09:52 +02:00
` }};function Xae(e){let{inputs:t,backend:n,attrs:a}=e,{indices:r,updates:s}=t,{shape:i}=a,{sliceRank:o,numUpdates:l,sliceSize:d,strides:u,outputSize:p}=E.calculateShapes(s,r,i),c=[p/d,d];if(p===0)return n.makeTensorInfo(i,r.dtype);let h=we({inputs:{x:r},backend:n,attrs:{shape:[l,o]}}),f=we({inputs:{x:s},backend:n,attrs:{shape:[l,d]}}),m=n.makeTensorInfo([],"float32",new Float32Array([0])),g=new jk(l,o,h.shape.length,f.shape.length,u,c),y=n.runWebGLProgram(g,[f,h,m],f.dtype),A=we({inputs:{x:y},backend:n,attrs:{shape:i}});return n.disposeIntermediateTensorInfo(h),n.disposeIntermediateTensorInfo(f),n.disposeIntermediateTensorInfo(y),n.disposeIntermediateTensorInfo(m),A}var Kae={kernelName:Ol,backendName:"webgl",kernelFunc:Xae},Zae=class{constructor(e,t,n){this.variableNames=["c","a","b"],this.outputShape=t;let a,r;if(n>4)throw Error( ` Where for rank $ { n } is not yet supported ` );if(n===1)r="resRC",a="resRC";else{let i=["resRC.x","resRC.y","resRC.z","resRC.w"],o=[],l=[];for(let d=0;d<t.length;d++)l.push( ` $ { i [ d ] } ` ),d<e&&o.push( ` $ { i [ d ] } ` );a=o.join(),r=l.join()}let s=yt(n);this.userCode= `
2021-09-11 16:29:31 +02:00
void main ( ) {
2021-10-22 22:09:52 +02:00
$ { s } resRC = getOutputCoords ( ) ;
float cVal = getC ( $ { a } ) ;
2021-09-11 16:29:31 +02:00
if ( cVal >= 1.0 ) {
2021-10-04 23:03:36 +02:00
setOutput ( getA ( $ { r } ) ) ;
2021-09-11 16:29:31 +02:00
} else {
2021-10-04 23:03:36 +02:00
setOutput ( getB ( $ { r } ) ) ;
2021-08-14 17:17:51 +02:00
}
2021-09-05 22:42:11 +02:00
}
2021-10-22 22:09:52 +02:00
` }};function Yae(e){let{inputs:t,backend:n}=e,{condition:a,t:r,e:s}=t,i=new Zae(a.shape.length,r.shape,r.shape.length);return n.runWebGLProgram(i,[a,r,s],Pa(r.dtype,s.dtype))}var Jae={kernelName:_l,backendName:"webgl",kernelFunc:Yae},Qae= `
2021-09-11 16:29:31 +02:00
// Stable and Attracting Fixed Point (0, 1) for Normalized Weights.
// see: https://arxiv.org/abs/1706.02515
2021-10-22 22:09:52 +02:00
float scaleAlpha = $ { E . SELU _SCALEALPHA } ;
float scale = $ { E . SELU _SCALE } ;
2021-09-11 16:29:31 +02:00
return ( x >= 0.0 ) ? scale * x : scaleAlpha * ( exp ( x ) - 1.0 ) ;
2021-10-22 22:09:52 +02:00
` ,ere=nt({opSnippet:Qae}),tre={kernelName:Pl,backendName:"webgl",kernelFunc:ere},Gk="return 1.0 / (1.0 + exp(-1.0 * x));",nre=nt({opSnippet:Gk,packedOpSnippet:Gk,cpuKernelImpl:AZ}),are={kernelName:Pi,backendName:"webgl",kernelFunc:nre},rre= `
2021-09-11 16:29:31 +02:00
if ( isnan ( x ) ) { return 0.0 ; }
return sign ( x ) ;
2021-10-22 22:09:52 +02:00
` ,sre=nt({opSnippet:rre}),ire={kernelName:Wl,backendName:"webgl",kernelFunc:sre},ore=rk+ `
2021-09-11 16:29:31 +02:00
return sin ( x ) ;
2021-10-22 22:09:52 +02:00
` ,lre=nt({opSnippet:ore}),ure={kernelName:_i,backendName:"webgl",kernelFunc:lre},dre= `
2021-09-11 16:29:31 +02:00
float e2x = exp ( x ) ;
return ( e2x - 1.0 / e2x ) / 2.0 ;
2021-10-22 22:09:52 +02:00
` ,pre=nt({opSnippet:dre}),cre={kernelName:Ll,backendName:"webgl",kernelFunc:pre},hre= `
2021-09-11 16:29:31 +02:00
float epsilon = 1.1920928955078125 e - 7 ;
float threshold = log ( epsilon ) + 2.0 ;
2021-08-14 17:17:51 +02:00
2021-09-11 16:29:31 +02:00
bool too _large = x > - threshold ;
bool too _small = x < threshold ;
2021-08-14 17:16:26 +02:00
2021-09-11 16:29:31 +02:00
float result ;
float exp _x = exp ( x ) ;
2021-06-07 02:34:29 +02:00
2021-09-11 16:29:31 +02:00
if ( too _large ) {
result = x ;
2021-08-14 17:16:26 +02:00
}
2021-09-11 16:29:31 +02:00
else if ( too _small ) {
result = exp _x ;
2021-08-14 17:16:26 +02:00
}
2021-09-11 16:29:31 +02:00
else {
result = log ( exp _x + 1.0 ) ;
2021-08-14 17:16:26 +02:00
}
2021-09-11 16:29:31 +02:00
return result ;
2021-10-22 22:09:52 +02:00
` ,fre=nt({opSnippet:hre}),mre={kernelName:Bl,backendName:"webgl",kernelFunc:fre},gre=e=>{let{inputs:t,backend:n,attrs:a}=e,{x:r}=t,{blockShape:s,paddings:i}=a;w.assert(r.shape.length<=4,()=>"spaceToBatchND for rank > 4 with a WebGL backend not implemented yet");let o=s.reduce((y,A)=>y*A),l=[[0,0]];l.push(...i);for(let y=1+s.length;y<r.shape.length;++y)l.push([0,0]);let d=[],u=Vk({inputs:{x:r},backend:n,attrs:{paddings:l,constantValue:0}}),p=E.getReshaped(u.shape,s,o,!1),c=E.getPermuted(p.length,s.length,!1),h=E.getReshapedPermuted(u.shape,s,o,!1),f=we({inputs:{x:u},backend:n,attrs:{shape:p}}),m=_n({inputs:{x:f},backend:n,attrs:{perm:c}}),g=we({inputs:{x:m},backend:n,attrs:{shape:h}});return d.push(u),d.push(f),d.push(m),d.forEach(y=>n.disposeIntermediateTensorInfo(y)),g},yre={kernelName:Vl,backendName:"webgl",kernelFunc:gre};function Are(e){let{inputs:t,backend:n}=e,{indices:a,values:r,denseShape:s,defaultValue:i}=t;if(s.shape.length!==1)throw new Error( ` Dense shape must be a vector , saw :
$ { s . shape } ` );if(a.shape.length!==2)throw new Error( ` Indices must be a matrix , saw :
$ { a . shape } ` );if(r.shape.length!==1)throw new Error( ` Values must be a vector , saw :
$ { r . shape } ` );if(i.shape.length!==0)throw new Error( ` Default value must be a scalar , saw :
$ { i . shape } ` );let o=n.readSync(a.dataId),l=n.readSync(r.dataId),d=n.readSync(s.dataId),u=n.readSync(i.dataId)[0],[p,c,h,f,m]=bZ(o,a.shape,a.dtype,l,r.dtype,d,u);return[n.makeTensorInfo(c,a.dtype,p),n.makeTensorInfo([c[0]],r.dtype,h),n.makeTensorInfo([f.length],"bool",new Uint8Array(f.map(g=>Number(g)))),n.makeTensorInfo([m.length],a.dtype,new Int32Array(m))]}var xre={kernelName:fh,backendName:"webgl",kernelFunc:Are};function bre(e){let{inputs:t,backend:n}=e,{inputIndices:a,inputShape:r,newShape:s}=t;if(a.shape.length!==2)throw new Error( ` Input indices should be a matrix but received shape $ { a . shape } ` );if(r.shape.length!==1)throw new Error( ` Input shape should be a vector but received shape $ { r . shape } ` );if(s.shape.length!==1)throw new Error( ` Target shape should be a vector but received shape $ { s . shape } ` );let i=Array.from(n.readSync(r.dataId)),o=n.readSync(a.dataId),l=Array.from(n.readSync(s.dataId)),[d,u,p]=vZ(o,a.shape,a.dtype,i,l);return[n.makeTensorInfo(u,a.dtype,d),n.makeTensorInfo([p.length],s.dtype,new Int32Array(p))]}var vre={kernelName:mh,backendName:"webgl",kernelFunc:bre};function wre(e){let{inputs:t,backend:n}=e,{data:a,indices:r,segmentIds:s}=t;if(a.shape.length<1)throw new Error("Data should be at least 1 dimensional but received scalar");if(r.shape.length!==1)throw new Error( ` Indices should be a vector but received shape
$ { r . shape } ` );if(s.shape.length!==1)throw new Error( ` Segment ids should be a vector but received shape
$ { s . shape } ` );let i=n.readSync(a.dataId),o=n.readSync(r.dataId),l=n.readSync(s.dataId),[d,u]=G4(i,a.shape,a.dtype,o,l,!0);return n.makeTensorInfo(u,a.dtype,d)}var kre={kernelName:gh,backendName:"webgl",kernelFunc:wre};function Ire(e){let{inputs:t,backend:n}=e,{data:a,indices:r,segmentIds:s}=t;if(a.shape.length<1)throw new Error("Data should be at least 1 dimensional but received scalar");if(r.shape.length!==1)throw new Error( ` Indices should be a vector but received shape
$ { r . shape } ` );if(s.shape.length!==1)throw new Error( ` Segment ids should be a vector but received shape
$ { s . shape } ` );let i=n.readSync(a.dataId),o=n.readSync(r.dataId),l=n.readSync(s.dataId),[d,u]=G4(i,a.shape,a.dtype,o,l);return n.makeTensorInfo(u,a.dtype,d)}var Sre={kernelName:yh,backendName:"webgl",kernelFunc:Ire};function Nre(e){let{inputs:t,backend:n,attrs:a}=e,{sparseIndices:r,sparseValues:s,defaultValue:i}=t,{outputShape:o}=a,{sliceRank:l,numUpdates:d,strides:u,outputSize:p}=E.calculateShapes(s,r,o),c=!1,h=new jk(d,l,r.shape.length,s.shape.length,u,[p,1],c),f=n.runWebGLProgram(h,[s,r,i],s.dtype),m=we({inputs:{x:f},backend:n,attrs:{shape:o}});return n.disposeIntermediateTensorInfo(f),m}var Tre={kernelName:Ah,backendName:"webgl",kernelFunc:Nre};function Cre(e){let{inputs:t,backend:n,attrs:a}=e,{x:r}=t,{numOrSizeSplits:s,axis:i}=a,o=w.parseAxisParam(i,r.shape)[0],l=E.prepareSplitSize(r,s,o),d=r.shape.length,u=new Array(d).fill(0),p=r.shape.slice();return l.map(c=>{let h=[...p];h[o]=c;let f=Lu({inputs:{x:r},backend:n,attrs:{begin:u,size:h}});return u[o]+=c,f})}var Ere={kernelName:Ul,backendName:"webgl",kernelFunc:Cre},Hk="return sqrt(x);",Rre=nt({opSnippet:Hk,packedOpSnippet:Hk,cpuKernelImpl:wZ}),Mre={kernelName:zi,backendName:"webgl",kernelFunc:Rre},Fre="return x * x;",Dre=nt({opSnippet:Fre}), $ re={kernelName:Ed,backendName:"webgl",kernelFunc:Dre},qk="return (a - b) * (a - b);",Ore=vn({opSnippet:qk,packedOpSnippet:qk}),_re={kernelName:Bi,backendName:"webgl",kernelFunc:Ore};function Pre({inputs:e,attrs:t,backend:n}){let{x:a}=e,r=lr+ `
2021-09-11 16:29:31 +02:00
return x > 0.0 ? 1.0 : float ( $ { t . alpha } ) ;
2021-10-22 22:09:52 +02:00
` ,s=new Fs(a.shape,r);return n.runWebGLProgram(s,[a],a.dtype)}var zre={kernelName:ps,backendName:"webgl",kernelFunc:Pre},Lre=class{constructor(e,t,n){this.variableNames=["x"],this.outputShape=n;let a=n.length,r=yt(n.length),s=yt(n.length),i="";if(a===1)i="coords * strides + begin";else{let o=0;i=n.map((l,d)=>(o++,n.length===1? ` coords * strides [ $ { d } ] + begin [ $ { d } ] ` : ` coords [ $ { o - 1 } ] * strides [ $ { d } ] + begin [ $ { d } ] ` )).join(",")}this.userCode= `
2021-10-04 23:03:36 +02:00
$ { r } begin = $ { r } ( $ { e } ) ;
$ { r } strides = $ { r } ( $ { t } ) ;
2021-07-29 22:35:16 +02:00
2021-09-11 16:29:31 +02:00
void main ( ) {
2021-10-22 22:09:52 +02:00
$ { s } coords = getOutputCoords ( ) ;
setOutput ( getX ( $ { i } ) ) ;
2021-08-14 17:16:26 +02:00
}
2021-10-22 22:09:52 +02:00
` }};function Wre(e){let{inputs:t,backend:n,attrs:a}=e,{x:r}=t,{begin:s,end:i,strides:o,beginMask:l,endMask:d,ellipsisMask:u,newAxisMask:p,shrinkAxisMask:c}=a,{nonStrided:h, $ begin:f, $ strides:m,size:g,newShape:y,outShape:A}=En.sliceInfo(r.shape,s,i,o,l,d,u,p,c),x=we({inputs:{x:r},backend:n,attrs:{shape:y}}),b;if(h){let k=Lu({inputs:{x},backend:n,attrs:{begin:f,size:g}});b=we({inputs:{x:k},backend:n,attrs:{shape:A}}),n.disposeIntermediateTensorInfo(k)}else if(A.some(k=>k===0))b=n.makeTensorInfo(A,r.dtype,[]);else if(n.shouldExecuteOnCPU([x])){let k=n.texData.get(x.dataId).values,T=Ge(x.shape,x.dtype,k),C=kZ(A,T,m,f);b=n.makeTensorInfo(A,x.dtype,C.values)}else{let k=new Lre(f,m,A);b=n.runWebGLProgram(k,[x],x.dtype)}let v=we({inputs:{x:b},backend:n,attrs:{shape:A}});return n.disposeIntermediateTensorInfo(x),n.disposeIntermediateTensorInfo(b),v}var Bre={kernelName:jl,backendName:"webgl",kernelFunc:Wre};function Vre(e){let{inputs:t,backend:n,attrs:a}=e,{separator:r,nGramWidths:s,leftPad:i,rightPad:o,padWidth:l,preserveShortSequences:d}=a,{data:u,dataSplits:p}=t,c=n.readSync(u.dataId),h=n.readSync(p.dataId),[f,m]=IZ(c,h,r,s,i,o,l,d);return[n.makeTensorInfo([f.length],"string",f),n.makeTensorInfo(p.shape,"int32",m)]}var Ure={kernelName:xh,backendName:"webgl",kernelFunc:Vre};function jre(e){let{inputs:t,backend:n,attrs:a}=e,{skipEmpty:r}=a,{input:s,delimiter:i}=t;if(s.dtype!=="string")throw new Error("Input must be of datatype string");if(s.shape.length!==1)throw new Error( ` Input must be a vector , got shape : $ { s . shape } ` );if(i.shape.length!==0)throw new Error( ` Delimiter must be a scalar , got shape : $ { i . shape } ` );let o=n.readSync(s.dataId),l=n.readSync(i.dataId)[0],[d,u,p]=SZ(o,l,r),c=u.length;return[n.makeTensorInfo([c,2],"int32",d),n.makeTensorInfo([c],"string",u),n.makeTensorInfo([2],"int32",new Int32Array(p))]}var Gre={kernelName:bh,backendName:"webgl",kernelFunc:jre};function Hre(e){let{inputs:t,backend:n,attrs:a}=e,{numBuckets:r}=a,{input:s}=t;if(s.dtype!=="string")throw new Error("Input must be of datatype string");if(r<=0)throw new Error("Number of buckets must be at least 1");let i=n.readSync(s.dataId),o=NZ(i,r);return n.makeTensorInfo(s.shape,"int32",o)}var qre={kernelName:vh,backendName:"webgl",kernelFunc:Hre},Xre="return tan(x);",Kre=nt({opSnippet:Xre}),Zre={kernelName:Ui,backendName:"webgl",kernelFunc:Kre},Yre= `
2021-09-11 16:29:31 +02:00
float e2x = exp ( - 2.0 * abs ( x ) ) ;
return sign ( x ) * ( 1.0 - e2x ) / ( 1.0 + e2x ) ;
2021-10-22 22:09:52 +02:00
` ,Jre=nt({opSnippet:Yre}),Qre={kernelName:ji,backendName:"webgl",kernelFunc:Jre},ese=class{constructor(e,t){this.variableNames=["A"];let n=new Array(e.length);for(let s=0;s<n.length;s++)n[s]=e[s]*t[s];this.outputShape=n,this.rank=n.length;let a=yt(this.rank),r=tse(e);this.userCode= `
2021-09-11 16:29:31 +02:00
void main ( ) {
2021-10-22 22:09:52 +02:00
$ { a } resRC = getOutputCoords ( ) ;
2021-10-04 23:03:36 +02:00
setOutput ( getA ( $ { r } ) ) ;
2021-08-14 17:17:51 +02:00
}
2021-10-22 22:09:52 +02:00
` }};function tse(e){let t=e.length;if(t>5)throw Error( ` Tile for rank $ { t } is not yet supported ` );if(t===1)return ` imod ( resRC , $ { e [ 0 ] } ) ` ;let n=["resRC.x","resRC.y","resRC.z","resRC.w","resRC.u"],a=[];for(let r=0;r<e.length;r++)a.push( ` imod ( $ { n [ r ] } , $ { e [ r ] } ) ` );return a.join()}function Xk(e){let{inputs:t,backend:n,attrs:a}=e,{x:r}=t,{reps:s}=a;if(r.dtype==="string"||r.shape.length>5){let o=n.readSync(r.dataId),l=r.dtype==="string"?o.map(p=>w.decodeString(p)):o,d=Ge(r.shape,r.dtype,l),u=CZ(d,s);return n.makeTensorInfo(u.shape,u.dtype,u.values)}let i=new ese(r.shape,s);return n.runWebGLProgram(i,[r],r.dtype)}var nse={kernelName:ds,backendName:"webgl",kernelFunc:Xk},ase=class{constructor(e){this.variableNames=["x","indices"],this.customUniforms=[{name:"n",type:"int"},{name:"firstPass",type:"int"},{name:"negativeInf",type:"float"},{name:"dir",type:"int"},{name:"inc",type:"int"}],this.outputShape=e,this.userCode= `
2021-09-11 16:29:31 +02:00
void main ( ) {
ivec2 coords = getOutputCoords ( ) ;
int batch = coords [ 0 ] ;
int elemIdx = coords [ 1 ] ;
// We compare elements pair-wise within a group of size 2 * inc.
// The comparing rule for each group alternates between ascending
// and descending. Within each group, we compare each pair at
// positions i and i+inc. To decide whether an element at position i
// is x0 or x1, we mod it by 2 * inc, if the result is smaller than
// inc, it is in the first half of the group, we denote it as x0,
// otherwise we denote it as x1.
// For example, as shown in the Bitonic top K paper referenced above,
// Figure5(a) shows that element[1] is in the
// second half of the group when group size is 2, but it is in the
// first half of the group when group size is 4.
2021-09-01 00:24:30 +02:00
2021-09-11 16:29:31 +02:00
bool isFirstInPair = imod ( elemIdx , 2 * inc ) < inc ;
int i = isFirstInPair ? elemIdx : elemIdx - inc ;
2021-09-01 00:24:30 +02:00
2021-09-11 16:29:31 +02:00
int i0 = firstPass == 1 ? i : int ( getIndices ( batch , i ) ) ;
int i1 = firstPass == 1 ? i + inc : int ( getIndices ( batch , i + inc ) ) ;
float x0 = i0 < n ? getX ( batch , i0 ) : negativeInf ;
float x1 = i1 < n ? getX ( batch , i1 ) : negativeInf ;
// Denotes which direction indices are in (ascending or descending).
bool reverse = imod ( elemIdx , 2 * dir ) >= dir ;
bool isGreater = x0 > x1 || ( x0 == x1 && i1 > i0 ) ;
if ( reverse == isGreater ) { // Elements in opposite order of direction
int iTemp = i0 ;
i0 = i1 ;
i1 = iTemp ;
}
if ( isFirstInPair ) {
setOutput ( float ( i0 ) ) ;
} else {
setOutput ( float ( i1 ) ) ;
}
}
2021-10-22 22:09:52 +02:00
` }},rse=class{constructor(e){this.variableNames=["x","indices"],this.customUniforms=[{name:"n",type:"int"},{name:"firstPass",type:"int"},{name:"k",type:"int"}],this.outputShape=e,this.userCode= `
2021-09-11 16:29:31 +02:00
void main ( ) {
// Takes max of indices (0, k), (1, k + 1), (2, k + 2) ...
ivec2 coords = getOutputCoords ( ) ;
int batch = coords [ 0 ] ;
int elemIdx = coords [ 1 ] ;
// The output size is half of the previous size.
// If the previous sequence is | | | | _ _ _ _ | | | | _ _ _ _ (k=4),
// we only need to output the indices at positions |, the indices at
// positions _ can be thrown away, see Figure5(b) After Phase 2
// (Merge phase) in the Bitonic Top K paper referenced above.
// For example, the paper shows we only need to output the orange bars.
// The output sequence should look like this | | | | | | | |.
// Because the sequence is halved, to map the output index back
// to the previous sequence to find the corresponding value,
// we need to double the index. When we double the index,
// we basically interpolate a position, so 2i looks like
// | _ | _ | _ | _ | _ | _ | _. We move the | to the first k position
// of each 2k positions by - elemIdx % k. E.g. for output at
// index 4,5,6,7, we want to get the corresponding element at
// original index 8,9,10,11, for output at index 8,9,10,11,
// we want to get the corresponding element at original index
// 16,17,18,19, so on and so forth.
int i = elemIdx < k ? elemIdx : ( elemIdx * 2 - imod ( elemIdx , k ) ) ;
int i0 = firstPass == 1 ? i : int ( getIndices ( batch , i ) ) ;
int i1 = firstPass == 1 ? i + k : int ( getIndices ( batch , i + k ) ) ;
float x0 = getX ( batch , i0 ) ;
float x1 = i1 < n ? getX ( batch , i1 ) : x0 ;
setOutput ( x0 >= x1 ? float ( i0 ) : float ( i1 ) ) ;
}
2021-10-22 22:09:52 +02:00
` }};function Eo(e,t){t!==null&&e.disposeIntermediateTensorInfo(t)}function Kk(e){let t=1;for(;t<e;)t*=2;return t}function sse(e){let{inputs:t,backend:n,attrs:a}=e,{x:r}=t,{k:s,sorted:i}=a,o=ne().getNumber("TOPK_LAST_DIM_CPU_HANDOFF_SIZE_THRESHOLD"),l=ne().getNumber("TOPK_K_CPU_HANDOFF_THRESHOLD"),d=r.shape,u=d[d.length-1];if(n.shouldExecuteOnCPU([r])||u<o||s>l){let D=n.readSync(r.dataId),[O,F]=EZ(D,d,r.dtype,s,i);return[n.makeTensorInfo(O.shape,O.dtype,O.values),n.makeTensorInfo(F.shape,F.dtype,F.values)]}if(s===0)return d[d.length-1]=0,[n.makeTensorInfo(d,r.dtype,[]),n.makeTensorInfo(d,"int32",[])];if(u===1)return[r,Vp({attrs:{shape:d,dtype:"int32",value:0},backend:n})];let p=n.texData.get(r.dataId),c=p!==null&&p.isPacked,h=c?n.unpackTensor(r):r,f=w.sizeFromShape(d)/u,m=we({inputs:{x:h},attrs:{shape:[f,u]},backend:n});c&&Eo(n,h);let g=Kk(s),y=Kk(u),A=null,x=()=>A===null?[m,m]:[m,A],b=(D,O,F)=>{let S=x(),P=new ase(F),_=[[u],[A===null?1:0],[Number.NEGATIVE_INFINITY],[D],[O]],j=A;A=n.runWebGLProgram(P,S,"int32",_),Eo(n,j)};for(let D=1;D<g;D*=2){let O=D*2;for(let F=D;F>=1;F/=2)b(O,F,[f,y])}for(let D=y;D>g;D/=2){let O=x(),F=new rse([f,D/2]),S=[[u],[A===null?1:0],[g]],P=A;A=n.runWebGLProgram(F,O,"int32",S),Eo(n,P);let _=g/2,j=_*2;for(let q=_;q>=1;q/=2)b(j,q,A.shape)}let v=A;A=Lu({inputs:{x:A},backend:n,attrs:{begin:0,size:[f,s]}}),Eo(n,v);let k= $ k({inputs:{x:m,indices:A},backend:n,attrs:{axis:1,batchDims:1}});Eo(n,m);let T=d.slice(0,-1);T.push(s),v=A,A=we({inputs:{x:A},attrs:{shape:T},backend:n}),Eo(n,v);let C=k;return k=we({inputs:{x:k},attrs:{shape:T},backend:n}),Eo(n,C),[k,A]}var ise={kernelName:Gl,backendName:"webgl",kernelFunc:sse},ose=class{constructor(e,t,n,a,r,s){this.variableNames=["Image","Transforms"],this.outputShape=s;let i=n==="nearest"?1:2,o;switch(a){case"constant":o=1;break;case"reflect":o=2;break;case"wrap":o=3;break;case"nearest":o=4;break;default:o=1;break}this.userCode= `
2021-09-11 16:29:31 +02:00
float mapCoord ( float outCoord , float len ) {
float inCoord = outCoord ;
2021-10-22 22:09:52 +02:00
if ( $ { o } == 2 ) {
2021-09-11 16:29:31 +02:00
if ( inCoord < 0.0 ) {
if ( len <= 1.0 ) {
inCoord = 0.0 ;
} else {
float sz2 = 2.0 * len ;
if ( inCoord < sz2 ) {
inCoord = sz2 * float ( int ( float ( - inCoord / sz2 ) ) ) +
inCoord ;
}
inCoord = inCoord < - len ? inCoord + sz2 : - inCoord - 1.0 ;
}
} else if ( inCoord > len - 1.0 ) {
if ( len <= 1.0 ) {
inCoord = 0.0 ;
} else {
float sz2 = 2.0 * len ;
inCoord -= sz2 * float ( int ( float ( inCoord / sz2 ) ) ) ;
if ( inCoord >= len ) {
inCoord = sz2 - inCoord - 1.0 ;
}
}
}
return clamp ( inCoord , 0.0 , len - 1.0 ) ;
2021-10-22 22:09:52 +02:00
} else if ( $ { o } == 3 ) {
2021-09-11 16:29:31 +02:00
if ( inCoord < 0.0 ) {
if ( len <= 1.0 ) {
inCoord = 0.0 ;
} else {
float sz = len - 1.0 ;
inCoord += len * ( float ( int ( float ( - inCoord / sz ) ) ) + 1.0 ) ;
}
} else if ( inCoord > len - 1.0 ) {
if ( len <= 1.0 ) {
inCoord = 0.0 ;
} else {
float sz = len - 1.0 ;
inCoord -= len * float ( int ( float ( inCoord / sz ) ) ) ;
}
}
return clamp ( inCoord , 0.0 , len - 1.0 ) ;
2021-10-22 22:09:52 +02:00
} else if ( $ { o } == 4 ) {
2021-09-11 16:29:31 +02:00
return clamp ( outCoord , 0.0 , len - 1.0 ) ;
} else {
return outCoord ;
}
2021-07-29 22:35:16 +02:00
}
2021-09-11 16:29:31 +02:00
float readWithFillValue ( int batch , int coordY , int coordX ,
int channel ) {
float outputValue ;
if ( 0 <= coordY && coordY < $ { e } && 0 <= coordX && coordX < $ { t } ) {
outputValue = getImage ( batch , coordY , coordX , channel ) ;
} else {
2021-10-04 23:03:36 +02:00
outputValue = float ( $ { r } ) ;
2021-09-11 16:29:31 +02:00
}
return outputValue ;
}
2021-07-29 22:35:16 +02:00
2021-09-11 16:29:31 +02:00
void main ( ) {
ivec4 coords = getOutputCoords ( ) ;
float outputValue ;
int batch = coords [ 0 ] ;
int x = coords [ 2 ] ;
int y = coords [ 1 ] ;
int channel = coords [ 3 ] ;
float xf = float ( x ) ;
float yf = float ( y ) ;
float a1 = getTransforms ( batch , 0 ) ;
float a2 = getTransforms ( batch , 1 ) ;
float a3 = getTransforms ( batch , 2 ) ;
float b1 = getTransforms ( batch , 3 ) ;
float b2 = getTransforms ( batch , 4 ) ;
float b3 = getTransforms ( batch , 5 ) ;
float c1 = getTransforms ( batch , 6 ) ;
float c2 = getTransforms ( batch , 7 ) ;
float projection = c1 * xf + c2 * yf + 1.0 ;
if ( projection == 0.0 ) {
2021-10-04 23:03:36 +02:00
outputValue = float ( $ { r } ) ;
2021-09-11 16:29:31 +02:00
} else {
float inX = ( a1 * xf + a2 * yf + a3 ) / projection ;
float inY = ( b1 * xf + b2 * yf + b3 ) / projection ;
float mapX = mapCoord ( inX , float ( $ { t } ) ) ;
float mapY = mapCoord ( inY , float ( $ { e } ) ) ;
2021-08-14 17:16:26 +02:00
2021-10-22 22:09:52 +02:00
if ( $ { i } == 1 ) {
2021-09-11 16:29:31 +02:00
int coordY = int ( round ( mapY ) ) ;
int coordX = int ( round ( mapX ) ) ;
outputValue = readWithFillValue ( batch , coordY , coordX ,
channel ) ;
} else {
float yFloor = floor ( mapY ) ;
float xFloor = floor ( mapX ) ;
float yCeil = yFloor + 1.0 ;
float xCeil = xFloor + 1.0 ;
float valueYFloor = ( xCeil - mapX ) *
readWithFillValue ( batch , int ( yFloor ) , int ( xFloor ) , channel ) +
( mapX - xFloor ) *
readWithFillValue ( batch , int ( yFloor ) , int ( xCeil ) , channel ) ;
float valueYCeil = ( xCeil - mapX ) *
readWithFillValue ( batch , int ( yCeil ) , int ( xFloor ) , channel ) +
( mapX - xFloor ) *
readWithFillValue ( batch , int ( yCeil ) , int ( xCeil ) , channel ) ;
outputValue = ( yCeil - mapY ) * valueYFloor +
( mapY - yFloor ) * valueYCeil ;
}
}
setOutput ( outputValue ) ;
}
2021-10-22 22:09:52 +02:00
` }};function lse(e){let{inputs:t,backend:n,attrs:a}=e,{image:r,transforms:s}=t,{interpolation:i,fillMode:o,fillValue:l,outputShape:d}=a,[u,p,c,h]=r.shape,[f,m]=d!=null?d:[p,c],g=[u,f,m,h],y=new ose(p,c,i,o,l,g);return n.runWebGLProgram(y,[r,s],"float32")}var use={kernelName:Hl,backendName:"webgl",kernelFunc:lse};function dse(e){let{inputs:t,attrs:n,backend:a}=e,{axis:r}=n,{x:s}=t;Mu(s,"unique"),console.warn("WARNING: ","UI might be locked temporarily as data is being downloaded");let i=a.readSync(s.dataId),{outputValues:o,outputShape:l,indices:d}=RZ(i,r,s.shape,s.dtype);return[a.makeTensorInfo(l,s.dtype,o),a.makeTensorInfo([d.length],"int32",d)]}var pse={kernelName:wh,backendName:"webgl",kernelFunc:dse};function cse(e){let{inputs:t,backend:n,attrs:a}=e,{value:r}=t,{axis:s}=a;s<0&&(s+=r.shape.length);let i=r,o=i.shape.length,l=r.shape[s],d=new Array(o-1),u=0;for(let m=0;m<o;m++)m!==s&&(d[u++]=i.shape[m]);let p=[],c=new Array(o).fill(0),h=i.shape.slice();h[s]=1;let f=new Array(l);for(let m=0;m<f.length;m++){c[s]=m;let g=Lu({inputs:{x:i},backend:n,attrs:{begin:c,size:h}}),y=we({inputs:{x:g},backend:n,attrs:{shape:d}});f[m]=y,p.push(g)}return p.forEach(m=>n.disposeIntermediateTensorInfo(m)),f}var hse={kernelName:ql,backendName:"webgl",kernelFunc:cse},fse=class{constructor(e,t){this.variableNames=["x","segmentIds"];let n=e.windowSize,a=e.batchSize,r=e.inSize,s=e.numSegments,i=s*Math.ceil(r/n);this.outputShape=[a,i];let o="0.0",l="sumValue",d=Math.floor(n/4)*4,u=n%4,p= `
2021-09-11 16:29:31 +02:00
sumValue += dot ( values , segFilter ) ;
2021-10-22 22:09:52 +02:00
` ,c="";r%n>0&&(c= `
2021-10-04 23:03:36 +02:00
if ( inIdx < 0 || inIdx >= $ { r } ) {
2021-09-11 16:29:31 +02:00
return initializationValue ;
2021-09-05 22:42:11 +02:00
}
2021-10-04 23:03:36 +02:00
` );let h="";r%n>0&&(h= `
if ( inIdx < 0 || inIdx >= $ { r } ) {
2021-09-11 16:29:31 +02:00
return - 1.0 ;
2021-09-05 22:42:11 +02:00
}
2021-09-11 16:29:31 +02:00
` ),this.userCode= `
2021-10-22 22:09:52 +02:00
const float initializationValue = $ { o } ;
2021-09-11 16:29:31 +02:00
float getValue ( int batch , int inIdx ) {
2021-10-22 22:09:52 +02:00
$ { c }
2021-09-11 16:29:31 +02:00
return getX ( batch , inIdx ) ;
2021-09-01 00:22:16 +02:00
}
2021-07-29 22:35:16 +02:00
2021-09-11 16:29:31 +02:00
float getSegmentIdAtIndex ( int inIdx ) {
2021-10-04 23:03:36 +02:00
$ { h }
2021-09-11 16:29:31 +02:00
return getSegmentIds ( inIdx ) ;
2021-09-05 22:42:11 +02:00
}
2021-08-14 17:17:51 +02:00
2021-09-11 16:29:31 +02:00
void main ( ) {
ivec2 coords = getOutputCoords ( ) ;
int batch = coords [ 0 ] ;
int outIdx = coords [ 1 ] ;
int inOffset = int ( floor ( float ( outIdx ) / float (
2021-10-22 22:09:52 +02:00
$ { s } ) ) * float ( $ { n } ) ) ;
int currentSeg = int ( mod ( float ( outIdx ) , float ( $ { s } ) ) ) ;
2021-08-14 17:17:51 +02:00
2021-09-11 16:29:31 +02:00
float sumValue = 0.0 ;
2021-08-14 17:17:51 +02:00
2021-10-22 22:09:52 +02:00
for ( int i = 0 ; i < $ { d } ; i += 4 ) {
2021-09-11 16:29:31 +02:00
int inIdx = inOffset + i ;
vec4 values = vec4 (
getValue ( batch , inIdx ) ,
getValue ( batch , inIdx + 1 ) ,
getValue ( batch , inIdx + 2 ) ,
getValue ( batch , inIdx + 3 )
) ;
2021-09-01 00:24:30 +02:00
2021-09-11 16:29:31 +02:00
vec4 segFilter = vec4 (
int ( getSegmentIdAtIndex ( inIdx ) ) == currentSeg ? 1 : 0 ,
int ( getSegmentIdAtIndex ( inIdx + 1 ) ) == currentSeg ? 1 : 0 ,
int ( getSegmentIdAtIndex ( inIdx + 2 ) ) == currentSeg ? 1 : 0 ,
int ( getSegmentIdAtIndex ( inIdx + 3 ) ) == currentSeg ? 1 : 0
) ;
2021-09-01 00:24:30 +02:00
2021-10-22 22:09:52 +02:00
$ { p }
2021-09-05 22:42:11 +02:00
}
2021-09-01 00:24:30 +02:00
2021-10-22 22:09:52 +02:00
int inIdx = inOffset + $ { d } ;
2021-10-07 16:33:10 +02:00
if ( $ { u === 1 } ) {
2021-09-11 16:29:31 +02:00
vec4 values = vec4 (
getValue ( batch , inIdx ) ,
initializationValue ,
initializationValue ,
initializationValue
) ;
int inIdxSeg = int ( getSegmentIdAtIndex ( inIdx ) ) ;
vec4 segFilter = vec4 (
int ( getSegmentIdAtIndex ( inIdx ) ) == currentSeg ? 1 : 0 ,
0 ,
0 ,
0
) ;
2021-10-22 22:09:52 +02:00
$ { p }
2021-10-07 16:33:10 +02:00
} else if ( $ { u === 2 } ) {
2021-09-11 16:29:31 +02:00
vec4 values = vec4 (
getValue ( batch , inIdx ) ,
getValue ( batch , inIdx + 1 ) ,
initializationValue ,
initializationValue
) ;
vec4 segFilter = vec4 (
int ( getSegmentIdAtIndex ( inIdx ) ) == currentSeg ? 1 : 0 ,
int ( getSegmentIdAtIndex ( inIdx + 1 ) ) == currentSeg ? 1 : 0 ,
0 ,
0
) ;
2021-10-22 22:09:52 +02:00
$ { p }
2021-10-07 16:33:10 +02:00
} else if ( $ { u === 3 } ) {
2021-09-11 16:29:31 +02:00
vec4 values = vec4 (
getValue ( batch , inIdx ) ,
getValue ( batch , inIdx + 1 ) ,
getValue ( batch , inIdx + 2 ) ,
initializationValue
) ;
vec4 segFilter = vec4 (
int ( getSegmentIdAtIndex ( inIdx ) ) == currentSeg ? 1 : 0 ,
int ( getSegmentIdAtIndex ( inIdx + 1 ) ) == currentSeg ? 1 : 0 ,
int ( getSegmentIdAtIndex ( inIdx + 2 ) ) == currentSeg ? 1 : 0 ,
0
) ;
2021-10-22 22:09:52 +02:00
$ { p }
2021-06-07 02:34:29 +02:00
}
2021-09-11 16:29:31 +02:00
setOutput ( $ { l } ) ;
2021-06-07 02:34:29 +02:00
}
2021-10-22 22:09:52 +02:00
` }};function mse(e){let{inputs:t,backend:n,attrs:a}=e,{x:r,segmentIds:s}=t,{numSegments:i}=a,o=r.shape.length,l=[],d=0,u=E.getAxesPermutation([d],o),p=r;u!=null&&(p=_n({inputs:{x:r},backend:n,attrs:{perm:u}}),l.push(p),d=E.getInnerMostAxes(1,o)[0]);let c=E.segment_util.computeOutShape(p.shape,d,i),h=w.sizeFromShape([p.shape[d]]),f=we({inputs:{x:p},backend:n,attrs:{shape:[-1,h]}});l.push(f);let m=Eh(r.dtype),g=(b,v,k,T,C)=>{let D=b.shape[0],O=b.shape[1],F=E.segment_util.segOpComputeOptimalWindowSize(O,C),S={windowSize:F,inSize:O,batchSize:D,numSegments:C},P=new fse(S,v),_=n.compileAndRun(P,[b,k],T);if(l.push(_),_.shape[1]===C)return _;let j=Uk({backend:n,attrs:{start:0,stop:C,step:1,dtype:"float32"}}),q=Xk({inputs:{x:j},backend:n,attrs:{reps:[O/F]}});return l.push(j),l.push(q),g(_,v,q,T,C)},y=g(f,"unsortedSegmentSum",s,m,i),A=we({inputs:{x:y},backend:n,attrs:{shape:c}}),x=A;if(u!=null){l.push(A);let b=E.getUndoAxesPermutation(u);x=_n({inputs:{x},backend:n,attrs:{perm:b}})}return l.forEach(b=>n.disposeIntermediateTensorInfo(b)),x}var gse={kernelName:Rd,backendName:"webgl",kernelFunc:mse},yse=[Gte,Xte,EY,MY, $ Y,PY,LY,VY,jY,HY,ZY,JY,tJ,rJ,pJ,oJ,fJ,AJ,gJ,wJ,IJ,NJ,RJ,PJ,LJ,BJ,qJ,KJ,QJ,nQ,dY,oQ,yQ,xQ,pQ,kQ,SQ,vQ,CQ,MQ, $ Q,_Q,zQ,BQ,qQ,KQ,UQ,JQ,tee,aee,oee,pee,mee,Aee,xee,bee,wee,Iee,Nee,Cee,Ree, $ ee,Pee,Wee,Vee,Gee,Xee,Jee,nte,uY,rte,sQ,ote,dte,hte,cY,yte,vte,kte,Rte,Tte, $ te,Pte,Bte,Zte,rne,nne,lne,dne,cne,ene,fne,gne,bne,Ine,Cne,_ne,yY,zne,Bne,jne,qne,UJ,Zne,Jne,eae,aae,oae,fY,uae,dae,jJ,Fne,hae,vae,yae,xY,Sae,Cae,Fae,Oae,Lae,Bae,jae,qae,Kae,Jae,tre,are,ire,ure,cre,OJ, $ ne,mre,yre,xre,vre,kre,Sre,Tre,Ere,Mre, $ re,_re,zre,Bre,Ure,Gre,qre,Dne,NY,Zre,Qre,nse,ise,use,TY,pse,hse,gse,Yne];for(let e of yse)cs(e);var Kt;(function(e){e[e.float32=0]="float32",e[e.int32=1]="int32",e[e.bool=2]="bool",e[e.string=3]="string",e[e.complex64=4]="complex64"})(Kt||(Kt={}));var Up;(function(e){e[e.linear=0]="linear",e[e.relu=1]="relu",e[e.relu6=2]="relu6",e[e.prelu=3]="prelu",e[e.leakyrelu=4]="leakyrelu",e[e.sigmoid=5]="sigmoid",e[e.elu=6]="elu"})(Up||(Up={}));var Zk;function Ase(e){Zk=e.wasm.cwrap(Hi,null,["number","array","number","number","array","number","number","number","number","number","number","number","number"])}function xse(e){let{inputs:t,backend:n,attrs:a}=e,{a:r,b:s,bias:i,preluActivationWeights:o}=t;if(r.dtype!=="float32"||s.dtype!=="float32")throw new Error("_FusedMatMul for non non-float32 tensors not yet supported.");let{transposeA:l,transposeB:d,activation:u,leakyreluAlpha:p}=a,c=n.dataIdMap.get(r.dataId).id,h=n.dataIdMap.get(s.dataId).id,f=0;if(i!=null){let C=n.dataIdMap.get(i.dataId);if(C.shape.length!==1)throw new Error( ` _FusedMatMul only supports rank - 1 bias but got rank $ { C . shape . length } . ` );f=C.id}let m=o==null?0:n.dataIdMap.get(o.dataId).id,g=Up[u];if(g==null)throw new Error( ` $ { u } activation not yet supported for FusedConv2D in the wasm backend . ` );let y=l?r.shape[2]:r.shape[1],A=d?s.shape[1]:s.shape[2],x=r.shape[0],b=n.makeOutput([x,y,A],r.dtype),v=n.dataIdMap.get(b.dataId).id,k=new Uint8Array(new Int32Array(r.shape).buffer),T=new Uint8Array(new Int32Array(s.shape).buffer);return Zk(c,k,r.shape.length,h,T,s.shape.length,l,d,g,f,m,p||0,v),b}var bse={kernelName:Hi,backendName:"wasm",setupFunc:Ase,kernelFunc:xse};function wn(e,t){let n;function a(s){n=s.wasm.cwrap(e,null,["number","number","number"])}function r(s){let{backend:i,inputs:{x:o}}=s,l=i.dataIdMap.get(o.dataId).id,d=i.makeOutput(o.shape,t||o.dtype),u=i.dataIdMap.get(d.dataId).id;return w.sizeFromShape(d.shape)===0||n(l,Kt[o.dtype],u),d}return{kernelName:e,backendName:"wasm",setupFunc:a,kernelFunc:r}}var vse=wn(Ko);function Pn(e,t,n){let a;function r(i){a=i.wasm.cwrap(e,null,["number","array","number","number","array","number","number","number"])}function s(i){let{backend:o,inputs:l}=i,{a:d,b:u}=l,p=o.dataIdMap.get(d.dataId).id,c=o.dataIdMap.get(u.dataId).id,h=n!=null?n:d.dtype,f=E.assertAndGetBroadcastShape(d.shape,u.shape),m=o.makeOutput(f,h);if(w.sizeFromShape(f)===0)return m;let g=new Uint8Array(new Int32Array(d.shape).buffer),y=new Uint8Array(new Int32Array(u.sh
2021-10-12 15:48:00 +02:00
precision highp float ;
attribute vec2 pos ;
attribute vec2 uv ;
varying vec2 vUv ;
uniform float flipY ;
void main ( void ) {
vUv = uv ;
gl _Position = vec4 ( pos . x , pos . y * flipY , 0.0 , 1. ) ;
}
2021-10-22 22:09:52 +02:00
` ;var J8= `
2021-10-12 15:48:00 +02:00
precision highp float ;
varying vec2 vUv ;
uniform sampler2D texture ;
uniform float m [ 20 ] ;
void main ( void ) {
vec4 c = texture2D ( texture , vUv ) ;
gl _FragColor . r = m [ 0 ] * c . r + m [ 1 ] * c . g + m [ 2 ] * c . b + m [ 3 ] * c . a + m [ 4 ] ;
gl _FragColor . g = m [ 5 ] * c . r + m [ 6 ] * c . g + m [ 7 ] * c . b + m [ 8 ] * c . a + m [ 9 ] ;
gl _FragColor . b = m [ 10 ] * c . r + m [ 11 ] * c . g + m [ 12 ] * c . b + m [ 13 ] * c . a + m [ 14 ] ;
gl _FragColor . a = m [ 15 ] * c . r + m [ 16 ] * c . g + m [ 17 ] * c . b + m [ 18 ] * c . a + m [ 19 ] ;
}
2021-10-22 22:09:52 +02:00
` ,Q8= `
2021-10-12 15:48:00 +02:00
precision highp float ;
varying vec2 vUv ;
uniform sampler2D texture ;
uniform float m [ 20 ] ;
void main ( void ) {
vec4 c = texture2D ( texture , vUv ) ;
gl _FragColor . r = m [ 0 ] * c . r + m [ 1 ] * c . g + m [ 2 ] * c . b + m [ 4 ] ;
gl _FragColor . g = m [ 5 ] * c . r + m [ 6 ] * c . g + m [ 7 ] * c . b + m [ 9 ] ;
gl _FragColor . b = m [ 10 ] * c . r + m [ 11 ] * c . g + m [ 12 ] * c . b + m [ 14 ] ;
gl _FragColor . a = c . a ;
}
2021-10-22 22:09:52 +02:00
` ,e9= `
2021-10-12 15:48:00 +02:00
precision highp float ;
varying vec2 vUv ;
uniform vec2 size ;
uniform sampler2D texture ;
vec2 pixelate ( vec2 coord , vec2 size ) {
return floor ( coord / size ) * size ;
}
void main ( void ) {
gl _FragColor = vec4 ( 0.0 ) ;
vec2 coord = pixelate ( vUv , size ) ;
gl _FragColor += texture2D ( texture , coord ) ;
}
2021-10-22 22:09:52 +02:00
` ,t9= `
2021-10-12 15:48:00 +02:00
precision highp float ;
varying vec2 vUv ;
uniform sampler2D texture ;
uniform vec2 px ;
void main ( void ) {
gl _FragColor = vec4 ( 0.0 ) ;
gl _FragColor += texture2D ( texture , vUv + vec2 ( - 7.0 * px . x , - 7.0 * px . y ) ) * 0.0044299121055113265 ;
gl _FragColor += texture2D ( texture , vUv + vec2 ( - 6.0 * px . x , - 6.0 * px . y ) ) * 0.00895781211794 ;
gl _FragColor += texture2D ( texture , vUv + vec2 ( - 5.0 * px . x , - 5.0 * px . y ) ) * 0.0215963866053 ;
gl _FragColor += texture2D ( texture , vUv + vec2 ( - 4.0 * px . x , - 4.0 * px . y ) ) * 0.0443683338718 ;
gl _FragColor += texture2D ( texture , vUv + vec2 ( - 3.0 * px . x , - 3.0 * px . y ) ) * 0.0776744219933 ;
gl _FragColor += texture2D ( texture , vUv + vec2 ( - 2.0 * px . x , - 2.0 * px . y ) ) * 0.115876621105 ;
gl _FragColor += texture2D ( texture , vUv + vec2 ( - 1.0 * px . x , - 1.0 * px . y ) ) * 0.147308056121 ;
gl _FragColor += texture2D ( texture , vUv ) * 0.159576912161 ;
gl _FragColor += texture2D ( texture , vUv + vec2 ( 1.0 * px . x , 1.0 * px . y ) ) * 0.147308056121 ;
gl _FragColor += texture2D ( texture , vUv + vec2 ( 2.0 * px . x , 2.0 * px . y ) ) * 0.115876621105 ;
gl _FragColor += texture2D ( texture , vUv + vec2 ( 3.0 * px . x , 3.0 * px . y ) ) * 0.0776744219933 ;
gl _FragColor += texture2D ( texture , vUv + vec2 ( 4.0 * px . x , 4.0 * px . y ) ) * 0.0443683338718 ;
gl _FragColor += texture2D ( texture , vUv + vec2 ( 5.0 * px . x , 5.0 * px . y ) ) * 0.0215963866053 ;
gl _FragColor += texture2D ( texture , vUv + vec2 ( 6.0 * px . x , 6.0 * px . y ) ) * 0.00895781211794 ;
gl _FragColor += texture2D ( texture , vUv + vec2 ( 7.0 * px . x , 7.0 * px . y ) ) * 0.0044299121055113265 ;
}
2021-10-22 22:09:52 +02:00
` ,n9= `
2021-10-12 15:48:00 +02:00
precision highp float ;
varying vec2 vUv ;
uniform sampler2D texture ;
uniform vec2 px ;
uniform float m [ 9 ] ;
void main ( void ) {
vec4 c11 = texture2D ( texture , vUv - px ) ; // top left
vec4 c12 = texture2D ( texture , vec2 ( vUv . x , vUv . y - px . y ) ) ; // top center
vec4 c13 = texture2D ( texture , vec2 ( vUv . x + px . x , vUv . y - px . y ) ) ; // top right
vec4 c21 = texture2D ( texture , vec2 ( vUv . x - px . x , vUv . y ) ) ; // mid left
vec4 c22 = texture2D ( texture , vUv ) ; // mid center
vec4 c23 = texture2D ( texture , vec2 ( vUv . x + px . x , vUv . y ) ) ; // mid right
vec4 c31 = texture2D ( texture , vec2 ( vUv . x - px . x , vUv . y + px . y ) ) ; // bottom left
vec4 c32 = texture2D ( texture , vec2 ( vUv . x , vUv . y + px . y ) ) ; // bottom center
vec4 c33 = texture2D ( texture , vUv + px ) ; // bottom right
gl _FragColor =
c11 * m [ 0 ] + c12 * m [ 1 ] + c22 * m [ 2 ] +
c21 * m [ 3 ] + c22 * m [ 4 ] + c23 * m [ 5 ] +
c31 * m [ 6 ] + c32 * m [ 7 ] + c33 * m [ 8 ] ;
gl _FragColor . a = c22 . a ;
}
2021-10-22 22:09:52 +02:00
` ;var ax=(e,t,n)=>{let a=new RegExp(" \\ b"+t+" \\ w+ ( \\ w+)","ig");e.replace(a,(r,s)=>(n[s]=0,r))},a9=class{constructor(t,n,a){ce(this,"uniform",{});ce(this,"attribute",{});ce(this,"gl");ce(this,"id");ce(this,"compile",(t,n)=>{let a=this.gl.createShader(n);if(this.gl.shaderSource(a,t),this.gl.compileShader(a),!this.gl.getShaderParameter(a,this.gl.COMPILE_STATUS))throw new Error( ` filter : gl compile failed : $ { this . gl . getShaderInfoLog ( a ) } ` );return a});this.gl=t;let r=this.compile(n,this.gl.VERTEX_SHADER),s=this.compile(a,this.gl.FRAGMENT_SHADER);if(this.id=this.gl.createProgram(),this.gl.attachShader(this.id,r),this.gl.attachShader(this.id,s),this.gl.linkProgram(this.id),!this.gl.getProgramParameter(this.id,this.gl.LINK_STATUS))throw new Error( ` filter : gl link failed : $ { this . gl . getProgramInfoLog ( this . id ) } ` );this.gl.useProgram(this.id),ax(n,"attribute",this.attribute);for(let i in this.attribute)this.attribute[i]=this.gl.getAttribLocation(this.id,i);ax(n,"uniform",this.uniform),ax(a,"uniform",this.uniform);for(let i in this.uniform)this.uniform[i]=this.gl.getUniformLocation(this.id,i)}};function r9(){let e=0,t=null,n=!1,a=-1,r=[null,null],s=[],i=null,o=null,l=zn(100,100),d={},u={INTERMEDIATE:1},p=l.getContext("webgl");if(!p)throw new Error("filter: cannot get webgl context");function c(A,x){if(!(A===l.width&&x===l.height)){if(l.width=A,l.height=x,!i){let b=new Float32Array([-1,-1,0,1,1,-1,1,1,-1,1,0,0,-1,1,0,0,1,-1,1,1,1,1,1,0]);i=p.createBuffer(),p.bindBuffer(p.ARRAY_BUFFER,i),p.bufferData(p.ARRAY_BUFFER,b,p.STATIC_DRAW),p.pixelStorei(p.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!0)}p.viewport(0,0,l.width,l.height),r=[null,null]}}function h(A,x){let b=p.createFramebuffer();p.bindFramebuffer(p.FRAMEBUFFER,b);let v=p.createRenderbuffer();p.bindRenderbuffer(p.RENDERBUFFER,v);let k=p.createTexture();return p.bindTexture(p.TEXTURE_2D,k),p.texImage2D(p.TEXTURE_2D,0,p.RGBA,A,x,0,p.RGBA,p.UNSIGNED_BYTE,null),p.texParameteri(p.TEXTURE_2D,p.TEXTURE_MAG_FILTER,p.LINEAR),p.texParameteri(p.TEXTURE_2D,p.TEXTURE_MIN_FILTER,p.LINEAR),p.texParameteri(p.TEXTURE_2D,p.TEXTURE_WRAP_S,p.CLAMP_TO_EDGE),p.texParameteri(p.TEXTURE_2D,p.TEXTURE_WRAP_T,p.CLAMP_TO_EDGE),p.framebufferTexture2D(p.FRAMEBUFFER,p.COLOR_ATTACHMENT0,p.TEXTURE_2D,k,0),p.bindTexture(p.TEXTURE_2D,null),p.bindFramebuffer(p.FRAMEBUFFER,null),{fbo:b,texture:k}}function f(A){return r[A]=r[A]||h(l.width,l.height),r[A]}function m(A=0){var k,T;if(!o)return;let x=null,b=null,v=!1;e===0?x=t:x=((k=f(a))==null?void 0:k.texture)||null,e++,n&&!(A&u.INTERMEDIATE)?(b=null,v=e%2==0):(a=(a+1)%2,b=((T=f(a))==null?void 0:T.fbo)||null),p.bindTexture(p.TEXTURE_2D,x),p.bindFramebuffer(p.FRAMEBUFFER,b),p.uniform1f(o.uniform.flipY,v?-1:1),p.drawArrays(p.TRIANGLES,0,6)}function g(A){if(d[A])return o=d[A],p.useProgram((o==null?void 0:o.id)||null),o;o=new a9(p,Y8,A);let x=Float32Array.BYTES_PER_ELEMENT,b=4*x;return p.enableVertexAttribArray(o.attribute.pos),p.vertexAttribPointer(o.attribute.pos,2,p.FLOAT,!1,b,0*x),p.enableVertexAttribArray(o.attribute.uv),p.vertexAttribPointer(o.attribute.uv,2,p.FLOAT,!1,b,2*x),d[A]=o,o}let y={colorMatrix:A=>{let x=new Float32Array(A);x[4]/=255,x[9]/=255,x[14]/=255,x[19]/=255;let b=x[18]===1&&x[3]===0&&x[8]===0&&x[13]===0&&x[15]===0&&x[16]===0&&x[17]===0&&x[19]===0?Q8:J8,v=g(b);p.uniform1fv(v==null?void 0:v.uniform.m,x),m()},brightness:A=>{let x=(A||0)+1;y.colorMatrix([x,0,0,0,0,0,x,0,0,0,0,0,x,0,0,0,0,0,1,0])},saturation:A=>{let x=(A||0)*2/3+1,b=(x-1)*-.5;y.colorMatrix([x,b,b,0,0,b,x,b,0,0,b,b,x,0,0,0,0,0,1,0])},desaturate:()=>{y.saturation(-1)},contrast:A=>{let x=(A||0)+1,b=-128*(x-1);y.colorMatrix([x,0,0,0,b,0,x,0,0,b,0,0,x,0,b,0,0,0,1,0])},negative:()=>{y.contrast(-2)},hue:A=>{A=(A||0)/180*Math.PI;let x=Math.cos(A),b=Math.sin(A),v=.213,k=.715,T=.072;y.colorMatrix([v+x*(1-v)+b*-v,k+x*-k+b*-k,T+x*-T+b*(1-T),0,0,v+x*-v+b*.143,k+x*(1-k)+b*.14,T+x*-T+b*-.283,0,0,v+x*-v+b*-(1-v),k+x*-k+b*k,T+x*(1-T)+b*T,0,0,0,0,0,1,0])},desaturateLuminance:()=>{y.colorMatrix([.2764723,.929708,.0938197,0,-37.1,.2764723,.929708,.0938197,0,-37.1,.2764723,.929708,.0938197,0,-37.1,0,0,0,1,0])},sepia:()=>{y.c
` ))s.startsWith("model name")&&(t.model=s.match(/:(.*)/g)[0].replace(":","").trim()),s.startsWith("flags")&&(t.flags=s.match(/:(.*)/g)[0].replace(":","").trim().split(" ").sort())}catch(r){}}this.cpu?this.cpu=t:Object.defineProperty(this,"cpu",{value:t})}},xe=new Mf;var lx="2.4.0";var _s;var rpe=Number.MAX_SAFE_INTEGER;async function i9(e){return xe.initial&&(_s=null),_s?e.debug&&ie("cached model:",_s.modelUrl):(_s=await et(tt(e.modelBasePath,e.face.agegenderrace.modelPath)),!_s||!_s.modelUrl?ie("load model failed:",e.face.agegenderrace.modelPath):e.debug&&ie("load model:",_s.modelUrl)),_s}var an,Ff=[],ux=Number.MAX_SAFE_INTEGER,o9=0,l9=0;async function u9(e){var t,n;return xe.initial&&(an=null),an?e.debug&&ie("cached model:",an.modelUrl):(an=await et(tt(e.modelBasePath,((t=e.face.antispoof)==null?void 0:t.modelPath)||"")),!an||!an.modelUrl?ie("load model failed:",(n=e.face.antispoof)==null?void 0:n.modelPath):e.debug&&ie("load model:",an.modelUrl)),an}async function dx(e,t,n,a){var r,s;return an?ux<(((r=t.face.antispoof)==null?void 0:r.skipFrames)||0)&&(((s=t.face.antispoof)==null?void 0:s.skipTime)||0)<=Ae()-l9&&t.skipFrame&&o9===a&&Ff[n]?(ux++,Ff[n]):(ux=0,new Promise(async i=>{let o=Me.resizeBilinear(e,[(an==null?void 0:an.inputs[0].shape)?an.inputs[0].shape[2]:0,(an==null?void 0:an.inputs[0].shape)?an.inputs[0].shape[1]:0],!1),l=an==null?void 0:an.predict(o),d=(await l.data())[0];Ff[n]=Math.round(100*d)/100,o9=a,l9=Ae(),Q([o,l]),i(Ff[n])})):null}var Tr={silhouette:[10,338,297,332,284,251,389,356,454,323,361,288,397,365,379,378,400,377,152,148,176,149,150,136,172,58,132,93,234,127,162,21,54,103,67,109],lipsUpperOuter:[61,185,40,39,37,0,267,269,270,409,291],lipsLowerOuter:[146,91,181,84,17,314,405,321,375,291],lipsUpperInner:[78,191,80,81,82,13,312,311,310,415,308],lipsLowerInner:[78,95,88,178,87,14,317,402,318,324,308],rightEyeUpper0:[246,161,160,159,158,157,173],rightEyeLower0:[33,7,163,144,145,153,154,155,133],rightEyeUpper1:[247,30,29,27,28,56,190],rightEyeLower1:[130,25,110,24,23,22,26,112,243],rightEyeUpper2:[113,225,224,223,222,221,189],rightEyeLower2:[226,31,228,229,230,231,232,233,244],rightEyeLower3:[143,111,117,118,119,120,121,128,245],rightEyebrowUpper:[156,70,63,105,66,107,55,193],rightEyebrowLower:[35,124,46,53,52,65],rightEyeIris:[473,474,475,476,477],leftEyeUpper0:[466,388,387,386,385,384,398],leftEyeLower0:[263,249,390,373,374,380,381,382,362],leftEyeUpper1:[467,260,259,257,258,286,414],leftEyeLower1:[359,255,339,254,253,252,256,341,463],leftEyeUpper2:[342,445,444,443,442,441,413],leftEyeLower2:[446,261,448,449,450,451,452,453,464],leftEyeLower3:[372,340,346,347,348,349,350,357,465],leftEyebrowUpper:[383,300,293,334,296,336,285,417],leftEyebrowLower:[265,353,276,283,282,295],leftEyeIris:[468,469,470,471,472],midwayBetweenEyes:[168],noseTip:[1],noseBottom:[2],noseRightCorner:[98],noseLeftCorner:[327],rightCheek:[205],leftCheek:[425]},px={count:468,mouth:13,symmetryLine:[13,Tr.midwayBetweenEyes[0]]},Kp={leftEye:0,rightEye:1,nose:2,mouth:3,leftEar:4,rightEar:5,symmetryLine:[3,2]},cx=[{key:"EyeUpper0",indices:[9,10,11,12,13,14,15]},{key:"EyeUpper1",indices:[25,26,27,28,29,30,31]},{key:"EyeUpper2",indices:[41,42,43,44,45,46,47]},{key:"EyeLower0",indices:[0,1,2,3,4,5,6,7,8]},{key:"EyeLower1",indices:[16,17,18,19,20,21,22,23,24]},{key:"EyeLower2",indices:[32,33,34,35,36,37,38,39,40]},{key:"EyeLower3",indices:[54,55,56,57,58,59,60,61,62]}],Zp=[[.499976992607117,.652534008026123],[.500025987625122,.547487020492554],[.499974012374878,.602371990680695],[.482113003730774,.471979022026062],[.500150978565216,.527155995368958],[.499909996986389,.498252987861633],[.499523013830185,.40106201171875],[.289712011814117,.380764007568359],[.499954998493195,.312398016452789],[.499987006187439,.269918978214264],[.500023007392883,.107050001621246],[.500023007392883,.666234016418457],[.5000159740448,.679224014282227],[.500023007392883,.692348003387451],[.499976992607117,.695277988910675],[.499976992607117,.70593398809433],[.499976992607117,.719385027885437],[.499976992607117,.737019002437592],[.499967992305756,.78137099742889
2021-10-07 16:33:10 +02:00
M $ { u . box [ 0 ] + u . box [ 2 ] / 2 } $ { u . box [ 1 ] }
C
2021-10-22 22:09:52 +02:00
$ { p } $ { u . box [ 1 ] } ,
$ { p } $ { u . box [ 1 ] + u . box [ 3 ] } ,
2021-10-07 16:33:10 +02:00
$ { u . box [ 0 ] + u . box [ 2 ] / 2 } $ { u . box [ 1 ] + u . box [ 3 ] }
2021-10-21 16:54:51 +02:00
` ),f=new Path2D( `
2021-10-07 16:33:10 +02:00
M $ { u . box [ 0 ] } $ { u . box [ 1 ] + u . box [ 3 ] / 2 }
C
2021-10-22 22:09:52 +02:00
$ { u . box [ 0 ] } $ { c } ,
$ { u . box [ 0 ] + u . box [ 2 ] } $ { c } ,
2021-10-07 16:33:10 +02:00
$ { u . box [ 0 ] + u . box [ 2 ] } $ { u . box [ 1 ] + u . box [ 3 ] / 2 }
2021-10-22 22:09:52 +02:00
` );r.stroke(f),r.stroke(h)}if(a.drawGaze&&((o=(i=u.rotation)==null?void 0:i.gaze)==null?void 0:o.strength)&&((d=(l=u.rotation)==null?void 0:l.gaze)==null?void 0:d.bearing)&&u.annotations.leftEyeIris&&u.annotations.rightEyeIris&&u.annotations.leftEyeIris[0]&&u.annotations.rightEyeIris[0]){r.strokeStyle="pink",r.fillStyle="pink";let p=[u.annotations.leftEyeIris[0][0]+Math.sin(u.rotation.gaze.bearing)*u.rotation.gaze.strength*u.box[3],u.annotations.leftEyeIris[0][1]+Math.cos(u.rotation.gaze.bearing)*u.rotation.gaze.strength*u.box[2]];PI(r,[u.annotations.leftEyeIris[0][0],u.annotations.leftEyeIris[0][1]],[p[0],p[1]],4);let c=[u.annotations.rightEyeIris[0][0]+Math.sin(u.rotation.gaze.bearing)*u.rotation.gaze.strength*u.box[3],u.annotations.rightEyeIris[0][1]+Math.cos(u.rotation.gaze.bearing)*u.rotation.gaze.strength*u.box[2]];PI(r,[u.annotations.rightEyeIris[0][0],u.annotations.rightEyeIris[0][1]],[c[0],c[1]],4)}}}}}async function A5(e,t,n){var s;let a=kn(Kr,n);if(!t||!e)return;let r=Po(e);r.lineJoin="round";for(let i=0;i<t.length;i++){if(r.strokeStyle=a.color,r.fillStyle=a.color,r.lineWidth=a.lineWidth,r.font=a.font,a.drawBoxes&&t[i].box&&((s=t[i].box)==null?void 0:s.length)===4&&(sc(r,t[i].box[0],t[i].box[1],t[i].box[2],t[i].box[3],a),a.drawLabels&&(a.shadowColor&&a.shadowColor!==""&&(r.fillStyle=a.shadowColor,r.fillText( ` body $ { 100 * t [ i ] . score } % ` ,t[i].box[0]+3,1+t[i].box[1]+a.lineHeight,t[i].box[2])),r.fillStyle=a.labelColor,r.fillText( ` body $ { 100 * t [ i ] . score } % ` ,t[i].box[0]+2,0+t[i].box[1]+a.lineHeight,t[i].box[2]))),a.drawPoints&&t[i].keypoints)for(let o=0;o<t[i].keypoints.length;o++)r.fillStyle=a.useDepth&&t[i].keypoints[o].position[2]? ` rgba ( $ { 127.5 + 2 * ( t [ i ] . keypoints [ o ] . position [ 2 ] || 0 ) } , $ { 127.5 - 2 * ( t [ i ] . keypoints [ o ] . position [ 2 ] || 0 ) } , 255 , 0.5 ) ` :a.color,m5(r,t[i].keypoints[o].position[0],t[i].keypoints[o].position[1],0,a);if(a.drawLabels&&t[i].keypoints){r.font=a.font;for(let o of t[i].keypoints)r.fillStyle=a.useDepth&&o.position[2]? ` rgba ( $ { 127.5 + 2 * o . position [ 2 ] } , $ { 127.5 - 2 * o . position [ 2 ] } , 255 , 0.5 ) ` :a.color,r.fillText( ` $ { o . part } $ { Math . trunc ( 100 * o . score ) } % ` ,o.position[0]+4,o.position[1]+4)}if(a.drawPolygons&&t[i].keypoints&&t[i].annotations)for(let o of Object.values(t[i].annotations))for(let l of o)Dde(r,l,a)}}async function x5(e,t,n){let a=kn(Kr,n);if(!t||!e)return;let r=Po(e);r.lineJoin="round",r.font=a.font;for(let s of t){if(a.drawBoxes&&(r.strokeStyle=a.color,r.fillStyle=a.color,sc(r,s.box[0],s.box[1],s.box[2],s.box[3],a),a.drawLabels&&(a.shadowColor&&a.shadowColor!==""&&(r.fillStyle=a.shadowColor,r.fillText( ` hand : $ { Math . trunc ( 100 * s . score ) } % ` ,s.box[0]+3,1+s.box[1]+a.lineHeight,s.box[2])),r.fillStyle=a.labelColor,r.fillText( ` hand : $ { Math . trunc ( 100 * s . score ) } % ` ,s.box[0]+2,0+s.box[1]+a.lineHeight,s.box[2])),r.stroke()),a.drawPoints&&s.keypoints&&s.keypoints.length>0)for(let i of s.keypoints)r.fillStyle=a.useDepth? ` rgba ( $ { 127.5 + 2 * ( i [ 2 ] || 0 ) } , $ { 127.5 - 2 * ( i [ 2 ] || 0 ) } , 255 , 0.5 ) ` :a.color,m5(r,i[0],i[1],0,a);if(a.drawLabels&&s.annotations){let i=(o,l)=>{!o||o.length===0||!o[0]||(r.fillStyle=a.useDepth? ` rgba ( $ { 127.5 + 2 * o [ o . length - 1 ] [ 2 ] } , $ { 127.5 - 2 * o [ o . length - 1 ] [ 2 ] } , 255 , 0.5 ) ` :a.color,r.fillText(l,o[o.length-1][0]+4,o[o.length-1][1]+4))};r.font=a.font,i(s.annotations.index,"index"),i(s.annotations.middle,"middle"),i(s.annotations.ring,"ring"),i(s.annotations.pinky,"pinky"),i(s.annotations.thumb,"thumb"),i(s.annotations.palm,"palm")}if(a.drawPolygons&&s.annotations){let i=o=>{if(!(!o||o.length===0||!o[0]))for(let l=0;l<o.length;l++)r.beginPath(),r.strokeStyle=a.useDepth? ` rgba ( $ { 127.5 + 2 * o [ l ] [ 2 ] } , $ { 127.5 - 2 * o [ l ] [ 2 ] } , 255 , 0.5 ) ` :a.color,r.moveTo(o[l>0?l-1:0][0],o[l>0?l-1:0][1]),r.lineTo(o[l][0],o[l][1]),r.stroke()};r.lineWidth=a.lineWidth,i(s.annotations.index),i(s.annotations.middle),i(s.annotations.ring),i(s.annotations.pinky),i(s.annotations.thumb)}}}async function b5(e,t,n){let a=kn(Kr,n);if(!t||!e)return;let r=Po(e);r.lineJoin="round",r.font=a.font;for(let s of t)if(a.drawBoxes){if(r.strokeStyle=a.color,r.fillStyle=a.color,sc(r,s.box[0],s.box[1],s.box[2],s.box[3],a),a.drawLabels){let i= ` $ { s . label } $ { Math . round ( 100 * s . sco
2021-10-07 16:33:10 +02:00
/ 9 j / 4 A A Q S k Z J R g A B A Q E A Y A B g A A D / 4 Q B o R X h p Z g A A T U 0 A K g A A A A g A B A E a A A U A A A A B A A A A P g E b A A U A
AAABAAAARgEoAAMAAAABAAIAAAExAAIAAAARAAAATgAAAAAAAABgAAAAAQAAAGAAAAABcGFpbnQu
bmV0IDQuMi4xMwAA / 9 sAQwAGBAUGBQQGBgUGBwcGCAoQCgoJCQoUDg8MEBcUGBgXFBYWGh0lHxob
IxwWFiAsICMmJykqKRkfLTAtKDAlKCko / 9 sAQwEHBwcKCAoTCgoTKBoWGigoKCgoKCgoKCgoKCgo
KCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgo / 8 AAEQgBAAEAAwEhAAIRAQMRAf / E
AB8AAAEFAQEBAQEBAAAAAAAAAAABAgMEBQYHCAkKC //EALUQAAIBAwMCBAMFBQQEAAABfQECAwAE
EQUSITFBBhNRYQcicRQygZGhCCNCscEVUtHwJDNicoIJChYXGBkaJSYnKCkqNDU2Nzg5OkNERUZH
SElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6g4SFhoeIiYqSk5SVlpeYmZqio6Slpq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54xmgovRcD3qxETSIZcRvzp + / B p E k q s B U q s M 9 K
q4Em4Gkxk0yRGXrVW6i8yFhkg + tJjRxGsWrxllkUMh9eK5uMz6bcebbnfG33kPcVkay2OntPKuo0
nhXI67c8qa7Lw3c + adjcEDGK1paSRhVV4s6A0or0jyRRQ1AHX0V553hRQBz + vNtt5z3xXzX8Qbdm
uic5YnOMdK3l8JnTXvlbwpYl + WySOgrp5YfLOOB9O1c62O7qQkc + 9 RsKChFPWp4DluOlSykaNruH
ArUgHShFNF2NT1qxGO3NBmyxGcE1N2560CFzjrUysO9JAPDDjFOVuKoQuSRTWouBkazbCa3cd8cV
wF7IISQccHBzUSWpV9C3o1x5b5GAjdQD1rs9DjC3kckbEhqKfxIzn8LOupRXqnkPccBSkUAzraK8
87 wooA5rxMSI3HqK8B8bQl9Q8sffY5b / AAraXwkUviNrw9pH2W1ViMMRTdRjw4HpWNtDti9TPc4P
FQs2M5qdyyMHLcfjV63HTAoBGtap0wK0YxigpsuRDtVhVYd6GQydVwwIqdRnqKCR23I5pCMUW6gD
YNKuetAEise9KTxQBWuFyhrznxNZkXjFeN3I + tTIZg2OqmzmxNF0PO3vXp / g2 + hukVl4zyPanTXv
JmVR + 60 dpThXpnlPceopWFAbnV0V553hSGgRynjC5FujOey14Ssp1HxNmTnc + a3kvcIpv37HoEYQ
QmMdVHSsnVbYJF5jVk0dsNzlruVIsl2wKxbjWrVHILjg1CRbZJb + ILHPzyhfStODWLQgFJFYd + el
UJM27HUIXxhga1Y5lLVLKLkMnoauxnPPrSEx7ShF + Y / n2qrc6xBbhizDAqkK1zJuvG9nbg8ZA681
ly / Ei052RO3uKAsZlx8QGd8xxvt9Aa1NH8dK7AXMcip64zigdkdrZX8F7EJLdwwNXMkrz1qRMRly
CK4TxmpidWI49felPYSOMmi80NIoOV6qRzXYeA5SskYPfirpfEjGr8LPWVHyD6U4CvQPL3ZItOYc
UDOoNFeed4Uhpks4H4iE / Z5MeleMeGULeLgjds10S + BGdL + Jc9OSBU2Huc5Nc74yvUtrcDBrJnZF
63 PJdXvLy / lKWw46bvQVz82jXhkLO5Y + 9 ZlsYthcRnbIjY9R3q3awTRkEM3WmJI6C0ea3dGRsr1x
XY6TqW9FLHnjrUs0izpLK5DDjofSta3ckH09KRUkZuuTvFGdvPauE1Y3U6Mqbssf / rUxHPTaJPK2
ZmJPbBqzY6DCZh5xJC9s9aBJHU6dpemJjfEmfetJtI0 + VPkUr / unFOxdiextHs33W07YHQHk11mk
Xb3KbZ1xIvcd6LEyWho4Nct41sTPYb16ipexCPPZN + wYGCvH1rrPAEJmvkPoc1VL4kZVvgZ6yFwK
cBXoHkkqinFaVyzo80GuE7WJRQSziPiGdthK5HQV4x4J / wBI8WPIewNdEvgRNL42emO / yj1UHNef
eNpRczbC + I17DvWT2OqJxc0sMK4TCisy41q0hfEkqj8aixdwTXNOlwvmqD9anS9tXH7uVG + hosO4
/ w C 0 o O h r R 0 + 6 G 4 Y N I E z s N E u C x A P N d j Z r u A 4 x x U m j I N S j U R k s O l c b q F y k b n j F A 1 s Y G o a s s a k n C q O 5
rl7rxhGm7yBnBxuJq0rkSlYpw + NLlsfd5P8AerVsvHEqSBHwPVgcgVpyMyVXU3rXxcHYETAk + hru
/ D W t i 6 Z S T y O K z Z q n d H a x v v U G q 2 r Q + d Y y q R 2 4 q W I 8 d v b r 7 L q D x y D A z X p v w 6 F v I x e P G S M 0 6 X x o y r / A
zviKFHNegeX1J41zUhXioGbuaSuM6wpCaBHG / EcA6HN / exxXjXw2jL67cv8A3Qa6H8CFR + NnoWpO
I4XI44rxLxrqjQzSEsQM1gdSPM9U1uR1YbmWIdXHf2rmpIb67YS28UrRlsLI3c / jW0VZGUpO5pW1
jfLNOjahawzwReYI5cjzMkDavHJ5 / SrVv9uhtPtVxCPLBwzxnlT9KGghLU3tKvvPjHzbl7EGuisJ
GRxWLOg7nRXJEbDjmvSNK + aFSfSoZr0KutRkphc4NcRrdkVjL9aVio7Hk3iqS8ubhrWzUlsZY9kG
cZ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zNu7NSBFjHNSm5VO9IRnajqoWMhTzXFtA
bvUfMduSeg702Qz0rS7FbTToQFwzjJqaGTFyfK5PQViyzUuFmuIdgGABya5u / vTaN5cnUHFUmLoZ
zyskwlgJweSK6zQdUEwVJeGr0aUrxPLxEfe0OrhPAqVjxWhznGRtUwatDK4jNxURbmkAm6jNABup
6 tQAFqhupNtu59qUnZFwV5JHnWsHdIx96w5lz15rzT2uhRmt85xWbcxMnUGmZlB0bdxmrNvFIcfM
350 mWjbs7YkDJY / jW5ZWW4jikWkdNp9mqYJFaJdEHHakUULu / VB1rLn1Ld / FgetMGYd / qWSQmSa0
/ A e m S 3 2 p f a 7 p i L e L k g 9 z 6 U m Q t z 0 W 7 u Q 2 c Z x 0 A 9 B V z R 7 c A e a 6 j 2 r P q X 0 L 9 9 K R a t 5 A 6 D k 1 w O o K Z 5 2 a
YfMORTYRLujiGWEq6 / NWza2yKQVHNdOHerRy4laJo6TTnbbtb8KuM3Fdh5z3OJjbmpt3FaMxAtUZ
agBN1GaQBzTwaAAms3VbjERUGsa07RsdeFpuUuY4jUjljWTKK4j02RE4IpJYFk6imQkVl0xWarsO
mAEcUi0bNnZBR0rWtoguMCkUi21wI161mXuocEKaYXMS4u + pY / hVCSWSY4HT0pEmlouiSahdpEBl
mOceleiwWcNjClvHgJH97Hc1EmVFFi3Czy7mwIl / WtJbjP7uLgd / apQ2VNVvtsBhiPzdK5S4nAuR
nqOCaTGi9pcytPlU + XpmumtWII44rah8ZjiNIXRuWeNvvViQ / LXpJWPJbu7nCRvVkNxVsxBmqJmo
EPiXca0YLMuOlJsuKuPlsSi5IrNuG8s4HWs5VEkbwoOTKsk + FJY4rC1K53k1xTk5O7PSpwVNWRzt
4 cms + WpKICtSLTETQj5q0YeBSGiys23pUguGxQMq3E59ayrm4x3yaAKiRtO2WPHcmhruKFxFajzZ
ScA44qRHoXhuMaLpxaUg6hcDLMf4F9KlhuDeXGASIl + 8 azZslYma68y48m1 + 7 nFW5rtbRNhb5z1p
iMKbUg0zuW4A4rPgb7VdKXOMmpA7HRbMS7nUYiUda0lkQOBngVrS + JGdbWLRt2bAx5BqeQ / LXpnj
PQ4GJ + ashuK0MhWaoWcA0AaOmASMK7jRNPWYBmHyiuepO2x10qfcv6vYxCzYqoGK4HVYVTJrmb5l
c6oaM5TUJ8EgGsG4kLNUHT0M64OaqMMikSRsuKbnFMRLG3zVehOaGNE445NNlnVFpDMu6uie9Vo1
8 z5mOAOST2pDK91cNN + 5 tsrH3PrW54a06KxT7fdrlh / q1Pc + tJ6IUdZGvHPLezMcnBOWbsPap5r3
ylFtbdT1xUWNWzU0 / Zbwlgfmx8zGsHWtRHmMqE59aAMyNifvHPc1f0gtPdqkY5JosJHeNci2tktY
2021-10-22 22:09:52 +02:00
euPnNY + oXWZEVJNrZ9aun8SIq / CzodHuriIokhDIR1ronbKZr0o6o8ipoz //2Q==`,am=`
2021-10-07 16:33:10 +02:00
/ 9 j / 4 A A Q S k Z J R g A B A Q A A A Q A B A A D / 2 w B D A A s I C A o I B w s K C Q o N D A s N E R w S E Q 8 P E S I Z G h Q c K S Q r K i g k
JyctMkA3LTA9MCcnOEw5PUNFSElIKzZPVU5GVEBHSEX / 2 wBDAQwNDREPESESEiFFLicuRUVFRUVF
RUVFRUVFRUVFRUVFRUVFRUVFRUVFRUVFRUVFRUVFRUVFRUVFRUVFRUVFRUX / wAARCASwBLADASIA
AhEBAxEB / 8 QAGwABAAIDAQEAAAAAAAAAAAAAAAEDAgQFBgf / xABDEAEAAgECBAMECQIDBgUFAQAA
AQIDBBEFEiExE0FRBiJhcRQjMkJSgZGhsWLBJDNyFSVTY3OSNEPR4fAHFjWCokT / xAAYAQEAAwEA
AAAAAAAAAAAAAAAAAQIDBP / EACARAQEBAQADAQEBAQEBAAAAAAABAhEDITFBEjJRIhP / 2 gAMAwEA
AhEDEQA / APqYAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAKNT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NkYtXS1 + Stt + m63xImEJ4xjHER2ZxMUjeUTO3VRmydBbjLJqPi08mbeVOXJPq1sl5Q
Vbkz9 + rRy35rxHqzmZlVEe / Ez5LRlW5iyfR6zffaIjq1OSNZps2a21rZInafSPJhxGMl9LStLRWM
lorM / A4dkrWbYfLZC2W / 7 K6eubX6b4RzT + W76K8b7G6X62cu3Sten59nsm3j + OXz3 / 0 ANGIAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA0OIYfpOHPijvNNo + fdvtXJO18k /
/ O w P F Y b z 2 l s 3 j x 8 V q W 6 x M d W P E d P 9 D 4 l k x / d t 7 9 f l L L H b k x T P w Y 6 n t 2 5 1 2 O R T R z E 2 x 4 / d p E 7 c v k m e
E4IrW3hRMxO8THRtU1FKWtvtvK2upx22rzRCtXkqzh2jtF7ZbT122b01ndnpuWuP3Z3 + Ky20qDVv
fauzVy3mejZzNK8dVjqi87KLRLYtXruqvXzkQp7Qoid88R6rcl + WGlW0 / Sa22mfhCZOq2x082ix6
jkm822pO8VrPdr4dNObVeDo8XW3uzMbzK + mvxT7szE27cvnu9j7PcNjSaXx8mOIzZevbrEeic5tN
+ SZnpt8J4fHD9HXHO3PPW0x / DeBtJxx29vaAJQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAKNRim9Z5e89Nl4DzXtVh5babURHrSf7f3ec1 + qnDorWrvvt5Pccb0n0zhmWk
Rvevv1 + cPE2rGTFNZU26PFfxwa5dVkjelI2772nZnX6bbrEUq3o0d678u8wmuDL2ittvVjXdneeK
cGv4jpJ6U56 + kS7 + j118 + GLXpakzHaWlp9NN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727u1pYxYrbVmb7x + TQx6au3Nqcl7 / 0 rcmW9axGnwZJj1novmxnZXV0fFp4
ZxLBPgTGK8xzXr5fOH0bFlpmxVyY7Rato3iYfNuG2x56Wrqa8s2jz + 7 Lu8O12bS6jkwzN6THNNI6
tvrN68Y4rxlx1vHa0bskAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAA4XtTTm0OKfTJ / aXdcL2pyRGjwU362yb7fkJz9eTxxyZJjyltRXzUZK7TFtl9Lbwy06YzrHwa +
fJFd / wCVt8m0bQ0eS2qzcm + 1 K / an + zNZFL5M1pjFXeI72ky48eGnPkvNp27 + TPU6nHpMfLXaIjpE
erk5dRMxOfN1mPeisfshW1ne1a1577Y6x5R3U0zze31FOWI6ze0byU098kRlzbxM9qrMlPDpyRMR
Md5Vt / Ihp5898mWZm1pjftE91uCt7fCI7dWeHDEW3t723l6rslqxWZnasR + SYhFbzhnfxJ2jyeq9
lcGXWZcmW0zWKxHLaI7794eJx5fpfEKabT8t8l5isddo3l9S4VjrwrRUwzSJt3tav3pdOL6Y6dXD
j8HFWm + / K s U 4 N R X P v t W a z H q u W V A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
2021-03-10 00:32:35 +01:00
AAAAAa + fXYNP9u8b + kdZBsDkZOO135cWOZn4y5Wu4xqctbe9y19Kp4njt6vi + PDm8DFMWybbzPlV
5 PiGtz67UxbNbeKTtWIjaIXYpnwuaftT5tXJT3vmi1pMsrU5qIrG1V1a + 5 DCa7b9GFbRr5J6Wnbt
Cu + Wmk0m8956z8ZWZNorbfzcbX5rZslazPux3hUt41NTntktObJ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RHdZi0cUjmmPen9noox1iO0fNzdXEYrTt
stcmd9aX0bJ + HePmiKTitO8TMLZ1cVjrMfqpz6ys4pjfrPRWZ9rXXptUit6zO + 23 VyaRHEc05L1 /
w9J9ys / en1ljqdVbwYw452tlnl3jyjzbmmiMeKtYjpEbLeTXPUU8ee / + qjJpsV5rbkrFqzE1tEbT
DpYNbW21Mnu29fKWna0KbqTdjXXjld0cvQ63ltGHNPSfs2n + HUbS9c2s2UASqAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAOVxPWe99HpP8ArmP4b + r1EabT3yT3iOkesvMVtN7za07zad5l
XV5GmM9vVfEstvDx0jtaVVMlq + UJ18b5cMRvPeSuK87bUt + i2Z3PtG7zXpjkzXt6R + TXyTMzvM7t
ydHqZ + zhv1 + Cv / ZuqvPTHMfOYaTMil1a1K2vHSLTELq2v + KWzThGo84rH5rq8JzedqR + ZeI7WnOS
34 pYTafWXR / 2 Pln / AMyrKOCWnvmiPyR6O1y9585lhWJvl557Q6eo4T4dYiMvW3b3UanhldHpJtGX
e09unmjsT7eb1l4trI2t0hsZfrdNO0bzy + nzU20 / + NmkzO9esz + TZxWis9dttvPv + Tn21jjaW8zn
26 bTG3mp1M / Wzv3t0jyWXiKZJmsTERaZhXXDbNl8WaztWenxZLstPp5pau8frDtVrNMM5cfTfpMf
3 aunxxbes9d / R09Dp8ebJi09ptFr3jtt2WyrW9wy1Jx132mK + Xq9PotT0iIU19ntLtExa3T47T + q
6 nBaYvsZstZ + cT / LeMnUi0TXffo1s2m8Ws2 / OIMWk5Jib5L328rS2t94Sh5TV4ppklpW6PT6rh + P
NbebTHyas8E081mZy5P2W6OFhjxNTE / hr / LoRO0Kvo9dPqctKzMxEx1la5t3tdnjnMs4noievcrO
yZjeFF1OSnNV0OG62cn1GWffj7Mz5w05joovzY7xes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ODhdcvPnvExFevNXpMOrxi / PlrTee7PLX6Pwa09uaNlKtHg9
dM3z5d7ReOu02nu0JzZMfblrv5R5uvrcdImZ26T1mYhxs1Os7RH93PZ7axuafNfLitvbaYU3yZYt
PXs9NwHhui1HBa5LVicsb81onrEuVqNNSuS8Y67dZ6xPZa59Il9uX41vEitImZme3q2Kxbxora0T
Md / ROSa4Ztkj7c9OafL5LuGYubmyX3iu / TfbdSfVnpvZLT / XZK233 + Mbbva1xRXyiPk8pwbH4N6T
adq5a71n0tD1WDL4tPe6Xr0tDpz8YVnJHWEXYxbqlBedoef4tW0XraO09HdyztSZcbUz43C + ee9b
SVMaeOfqq7 + jGckQ1Yz7 + 7 v2RN / WXPXZPjci2 + 2 yyJaVMuy + uSJlA2d + pNoVRbeDcSxyTE + TDDlt
pdRXLTynrHrDOyiyZeVFnY9TjvXJjres71tG8MnJ4Nqt4tp7T1jrV1nRL1x2cvABKAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAHJ49qfD09cNZ97JPX5PPw2uI6j6Vrsl / ux7tfk1mWr7dOM8iLdm
vfebREefRsWldw7SxqNbWbR7lPesrn3Vteo7dYjDpMGCvfbeXQ0uLlxRLRxROfUc34p6fCHYrXlr
EejqrjY8uzCYW7MZjdVKqK9VlaxCYrsnYExBMRMJRPZA8 / xPHtmpP9W2xx76vhWOInvt / C7ike7N
vwzE9kcapGfhlevTaFbFo8RqJ5vy8 / RoW09ek0msxHfp3dzNoLzp4zUmZpMbT8HJyYJi20X2n0lh
ZY1li / RaidBF4w2mK3jrHaFGp1lN + tptPp5IjBkid5mIp16TKu0abBPv33vPlM7z + iPdFNcWXU5I
tkrNce / b1W5db1nTaf3ax9q0fxDW1ebNk2phty1mOu09VOm8W19orEz23j1TwfSeERFuEYMddptW
d43dvBn21eKJ75KbW + cf / JcTgMxXT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9ULN + J3ZbdFGOy + AYWpEqN7afNXLj + 1 Wd23KrJVMvCzseh0 + auow1yU7WhY4fCdV4
OadPefcvPuz6S7jol649Tl4AJVAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAV581NPhtkvO0R + 4 NPi2
r8DB4dJ9 + / 7 Q 8 3 P o 2 N T q L a n N b L f v P a P S F D H V 6 6 s Z 5 E T 0 h R k n y W 2 l T t M y o u z 0 c 8 u s x 2 n 7 s 7 v S c K w x
zc1vu / y85p + maJh6Th + SOWeveXR4 / wDLm8v + nX5mUWa9bbrInolmu5jdTNkxYFk2Isr3TuCzeGMz
+ THdEyDDJO9Ja823rt2XWnya946pGvktDXta0ztWu / ybvLE9dkcoOf4GbJPWK1j49VmLh9JtE33v
Mevb9G7WsW8l1ccREISophiJ2jpDYpijbaOjOuOJ8ujOdqxsgVcsUjaETYvbaFFrgu5lVsm0yUtu
ryg43H5m + GIj1XcJzePoL4pnrWGtxmfchr8JvfHS1622if3QljzTTLes + qrNjrkiYtCzPMxnm095
YZJ6boS5teB49Tqscza97VtvWvlv8V / FOF34RrIxTM2xXjelp / eHoeA6XnzReY3ivX / 0 dfivDcfE
9 HbDbaLx1pb0lOs + jO7K8Lis3cN + 0 NKcd9PmthzV5clJ2mF9J9GHHVL108dm1SznYr / Ft0tuhLb8
mNohFbMhLWy0mJ3rPXvDvcO1karBG8 / WV6Wj + 7 kWrvDDBlvpdRGSnbzj1hpjX4z8mOx6UYYstc2O
uSk71tG7Ns5AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACZ2jeXneJ62dVl5KT9VTt8Z9W9xbWclPo + O
fft9qfSHEU1pv48ftYST23ZTDC / p0YtlVuvVjMbM5 +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fGvSNlu / RVvtOzLfoipLT1VTKbSpvfogRkvtDVyZOhkyvQcA4Dzz
XV6yvTvTHMfvK + c9U3rkW + zvA / D21urr789cdZ8vi9KDb45rejl8Rry6iJ / FV1HP4vXbBTJEfYt1
+ UpiHM295bXsqrO9l8QkZ0lZEqqLeyBZHZLGvZkhIndADKJ3TMoqWQMZ6pjsxll2jsCLSrmU2lFY
36 gieyu0LJk3jbsga0wdqzK20QpyztQGprL / AFMrOE05NLkt6qdVWZxNrSe5o9vWBLiUjnzXn0vL
q555dHt8HOwV928 / 1 z / LpzXxbYccRvzTB + jucOwxh0dI22mY3ltIrHLWIjyjZKyoAAAAACJiJjaY
3 iXleM8InR5J1GniZw2n3oj7s / 8 Ao9Wi9a3rNbRE1mNpifNFnVs65XhcWTdt47bnFuF24dm8TFEz
p7T0 / pn0a + HJux1OOrOux08d1ndqY7tillVkzExLOk7yd4YxGwluViJhE45raL0na0dtlWO0 + bZr
1 TKi + 2 zptZGTamT3b / tLacvJjiY3XaTWdYxZZ6 / dtPm1zrv1z78fPcbwC7EAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABhkyV
xUm152iAZWtFazNp2iGhm1Vss8uP3aevnKrNntqLdelI7VRHRnrX / HRjx / tZREVjZXeybW6KbWZt
pCZ6S08tN7Nmbb7zCrJtyoS5145bSx5mWafelr3tsKmS / o08uXyhlly7RPV2 + AcBnPNdZrK + 53 pS
fP4ytnPVda4y4BwHxOXV6uvu96Unz + MvVxG0bQRG0bR2G0nHLb2gCUDX12LxtFmpHeazt82wT1gH
mMN4tWs + rcr2aEV8DU5sM / cvO3yb + O0csLUTSdrLphRE8tlkZI7Atr2ZMazDJVKTYSCawi7Ksq7z
1 QERvLK3ZGPrKbyCrbdnMcsbeaa18 / RhvvM7oGEwTG0JmYYTIML22a2e28xELM19oURPNO4lOem +
n3ZY5 + prVnMc2GYU4 / L4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 + PpPxbjdyWcvAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAo1Oprgr63ntAmTqdRqK4K9etp7Q5d7Wy2m953lNrWyWm953mVd77R0
Za1104xxlN9lV8qnJl2a9s3xUXX2ybsJyRDWtl3YWydEC + 2 VRkzeW6q + T4tbJm + KRdfK1cmWZnlr
vNp7RC / R6HU8SycmCk7ed57Q9ZwvgOn4fEXtHi5 / O9o7fJaZ6z1uRyOEezVstq6jiEbV71xevzer
rWtKxWsRFY6REeSRrJxz22gCUAAAAAANbX6aNVpL0npMRvWfSXlKamsRMVvXm + EvZXjmpaPWHzfL
oNRjzXicfWJ8phfPxFejx72x7xMzK + sXiNoiXlq + Pi6fWV / VfTNqfLJl / WTg9Pji8R70LqvMV1Gq
j / zcv6yz + lanzzZP1lWpelTET6S81Gp1P / Gyf90s412rjtnyfqql6asREdWM9 + jz9eJ6yP8Az7uh
odZqMt458tpB1JvEViI3 / RhzRt13 / R1MNaziiZiJn5K9ZNceKZiIiQcu / WekT + iYrWI3lzdTrs + 8
8 uW0fJzcur1Np / zsn6g79phVaIeetqNR / wAXJ / 3 SwnUaj / i5P + 6 UD0ldonum161h5mNRqP8Ai5P1
lNtRqJjacuT9Qd22WN5aGeZyZd / KHJy59RHbLf8AVq31Gp / 4 uT9ZEvS8Lr / vSs2npzRtL1z53wK +
oza / HW2XJNd99pmX0Rb8VAAAAAAAAAAAAAAcHj / C5yV + l4I9 + v24jzj1cLFk8nu5jeNpeW41wmdL
knU6ev1Vp96sfdn / ANFdTrXG + eq1q5F2LLtbZoY8m8d11bbSydErsYsm + zZrO / zcnBm226uhiyRK
EtrvCrJDOJTeu8A1MWX6Lqq5N / dnpb5O5ExMbx2cPNTeJb / DM / iYPDtPvY + nzhri / jDy5 / W6AuwA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAa2p1UYo5adbz + xbxMlvqJ1OqjDHLXree0ejmzNrWm953tPmTPWbWneZ7yoy5YhjrXXTjH8s75N
mtkyxt0VZM2 / m175N1V03yTKubMLXVXybeYLLX2VXy7eam + b0bOg4VquJW + rry4 / O9uyZOq3UjVm
9 r25axMzPaIdvhns1kzbZddM0p5Y47z8 / R2 + HcF03Doi1a8 + Xzvbv + TotJnjDXkt + K8ODHp8cY8N
IpSO0RCwF2YAAAAAAAAACvUZYw6fJkntWN3k8dfHz2vLucdz8mkjFE9bz1 + UOZosX1UzPm0nqI / W
MYo9FlcPNklfFGeH / NshLGun + Cz6PtHZtVZWlRLS + jxPkRpIn7rdoupHTdA5s6SI + 7 H6Mfo + 32 Y2
+ To3neSIiZ7A0IjPXpXLePlMotGW3272t85datKzHZjbTVnsDj + FG / 2 Y / RlGP4R + jo20u7H6N1Ql
o + H8I / REY957R + jpfReiK6eOYHLtj2tttH6KrY / 6 Y / R2c + kjeJiFVtLG24hxpw7 / AHY / RRkw9O37
O99Hrt1YX0tfOBLjcGp4XF8c + u8fs9c4dcVcGemSI61nd3IneN1orQAAAAAAAAAAAAABFqxes1tE
TE9JiUgPKcX4RbRXnNgiZwWnrH4XPi28PdXpW9JraImsxtMS8pxXhF9DecuGJtgmf + 1 TWW2N / la1
L7N7T5e3Vy6W3hsYcvLbqzbO9jvvCzvDR0 + XeO7crO6FmGSvRThy / RtVXJ92elvk2rRvDUzU7pl4
izsd2J3jeBpcNz + Lg5LT7 + Pp + Xk3W7js5eAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADs0NTrN96Yp6edkW8Wzm6 + LNTq4pvTHO9vOfRoWtt
1 mes95YWvs1s2fZldddOczLPLn2ju0MmebT3YZc2 / mpm3qqllN1drsbZIhr3yzvtHf4AsvlYYseb
V5Yx4KTe0 + UQ6nDvZ3UazbJqd8OKeu33peq0eh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ZlOOIiqrUXikd + kMreunnI5XEdX4dZiZcG + XmtNl / F83PeeWWHDOGanieSKY
q + 5 H2rz2hMzWd1Iqx1yajJXHhrNrW6REeb1nCPZumn2z62Ivl7xTyr / 6 uhwzhGn4Zj2xxzZJ + 1 kn
vLoNJnjHW7TbbsAszAAAAAAAAAAAAAAAAAAAAaPFrbaSK / itEOXt0rDf4xb / ACa / GZacRvaF58Q2
IjasQnzPIhCU92tMbZGzHmotG10C6nZkwpPRmipIllEbMIZIE7solgmJBnCyk9VMM6z1BtVllEqK
z0WRILYlluriWcSDJVbusV27gwInaSWM9ECyZ3hqamnSWxFmOSOaqRx725bNnSZNs9J + OynVY + WZ
YYr7TE + nVaIr0Ais81Yn1hKAAAAAAAAAAAAAAAAAABExvG09peU4nov9n66L0j6q / WPg9Y1OJaON
ZpL0 + 9 HWs / EWzeVz9PbmrEtnyc3h9reHy26TWdnSr2YX6657ijLXpLX0 + onSamL / AHJ6W + Tbv2aW
ekTv16JzeI1Ox6KJiYiY7Slz + E6jxdN4dp3vj6fl5Og2clnKACAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACZ2jeQRMxEbzO0Q08uqtkma4ulfO3r8lefUePMxWf
cjy9WvlzVxV6T1Z61 / x0Y8f7Wc7Ur1lqVy + LqOWJ2hp6rXddon5rOF1tfmz5OkT0qzb8dWbxjp1c
biuuilJ5Z6r + IcQrixzEy8zl1E6rNt1tMztFY81sztU1eRucN4ffi2p5esRM72n0h7rS6XFo8FcO
CkVpX082nwXh3 + z9FWLxHi36328vg6TZyW9ABAAAAAAAAAAAAAAAAAAAAAADj8Unm1tK / hqppHvw
y1k8 / EMk + m0GOPeafiFpCZYwolnXspvHvLa9mF46gmnZmwozRUiUCBKYYsoBLOFbKAX0llEqqyzi
QXRLOJVRLOOwLIljZMEgrlhKyYYTAK5nZPN0RZjugUanHzVlz6xtLq361c + 9 eXItPpXX0dubTU + E
bL2lw2 ++ O1fSW6m / VYAISAAAAAAAAAAAAAAAAAp1GbwcfTreelYEydcuMcRrM / L9nnlsV6wqpi2r
tv133mfWVkRyRtEdGFva7MzkYZNoamWN4bV4mYa9qztKIujhVppxGI8r1mJegeZpknBqKZY + 7 L0t
LRekWrO8TG8Ns / HJ5ZypAWZAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAADS12fp4VJ6z9qVuq1HgUiI + 3 bpDl589cOKZmevqprXPTbx477rDJlrhr1nq4 + s182tMRP
RqaziXiZJrWekNG17ZbxWJ336M5LXRbI3dLTJrs07RMY6fan1dHLrowY + X7MVjt6N3R6Kul0EbWm
s7bz8Z + LnabQX43r7Y53php / mXj + Dnv0f1JO1x / 8 ZxbUzj02O15mfLtD13AvZqnDds + pmMmo26el
XX0Wh0 / D8EYtNjilY7 + s / NstpOOTW7QBKgAAAAAAAAAAAAAAAAAAAAAADG88tLW9I3BwJtz6nNf1
vK / DHVqYJ3pzT5y3MPZeojOWMQylEKpTVjZnDCwkqzYQyRRICATCITAJZQxhMAshnEq4ZQC2srKq
qrIBZCWNZZgwswmFloVyCu0dFcx1WyrtCBhv5NTPHXds2U5o3hIz4ffbPt + KHUcTSW5c9Jme0u2v
VYAKpAAAAAAAAAAAAAAAAYZctcVOa35R6tLrltN795 / YvknNqrfhpPLH92V5isd9mWq6fHjk6rn0
ZxG8KK5Jm / wbVZiYZtqrmkqL023bkxvCiY3lJHNyRG81mHS4Rn5sNsNp64 + 3 yaWaNrzOzHBl + i6q
mT7s9J + S + ay8mex6EIneN47SNXKAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAImYiJme0JafEs3h6fkidrZOn5eaLeJk7eOdm1Hi2vmtPTry / CHmOJcUvmvOPF1n09Pm
6 HF9ZGm01qxO3R5vSY7XwzmzTy47zzTEd7en5Mfvt2 / PURWdo3tvPrPlKymbktFqTtMTvHzbOLDG
f63JXbF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7r1nCZm2gpae8zMrz4i / W6AgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAETETG0xukB4HVaeMHEtRi26RedvkyjBSfX9W77QYvC4xz7dMlYlrU7M929dWJLFc6aPK0q
7 YLxPS0S22FlP6q38Zac0yR92s / KVc3tHfFf8tpbcsLRvB / dR / 8 ALLVnU0r9uL1 + dZI1mnmdvGpv
6 TOy6ym + Oto2tWJ + cJ / tW + KLK5KW + zes / KU7tG + h01p64qx8Y6NXNo6Y + uPJlp8rLf0rfG7MXtHa
0x8 pZxqs9e2a8f8A7Oj7HaTHn0 + f6RWM23LETfr6vRW4PoL99NT8ui7F4 + vEdXXtnt + fVbXjGsr /
AOZE / OsPS29nuH27YrV + VpeV9pdPXhOtw49NG9Mld55 + vXcTPd42I47qo7xSfyWV9oM8d8VJ / VxM
d8l46xWF9cV7en6o / qLfxp2I9ob + eCv / AHMo9op89P8A / wBORGmyT5R + qfo2X8P7n9Q / jTsx7RR5
6 ef + 4 / 8 AuHftg / 8 A6cWcOSO9J / WEbWr3pY7Efzp2Lcfv5YK / 9 zWy8d1E / ZpSv5Oba1 / + Hb9lc + LP
bFt87I7E / wAabWbiurvEx4nL / pjZzc2bJkn372t85ZXx55 / BX85lucC0vPxnTxlnnjm32mOiZqUu
LJ2p4TwnVavNWaYbRTfre0bQ99pcH0bT0xb78vmtiIiNojaErMwAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAHnfarF7umzRHaZrLjYrdIen9ocPi8JyTt1xzF4eUw23rCm3R4r6bMy
wt6kdTaWLdjswmNoZontsCm0K5XWjopnuDC0dGpqG5bs08 / daKV672MjbSaif6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RGyL291KFnCcfj8e0le / Lbmn8n0N4b2Ur4nHLWmPsY
5e5 a5 + OXyXugBZmiY3iY9Xz7NjnTa3Ph / BeYj5PoTxftFg8Hjk2iOmWkW / Psrr418V5WrWd2faFc
V2jdnEMXWxntupmN7NiYU27iWML6dVMVnddjgVqMsdHr + CW5uE6f4Rt + 7 yuSsTDv + zWXn0WTHP3L
/ t K + G H l + O 0 A 1 c 4 A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA8Dn93W56 / wDM
t / L3z59qp24jn + OS38lnpr4r7ZxHQ2TEstt3PXUrt27K57rr1VT0BjKnJPRbMqMs7QlV2fYvHvrd
VknyrEfu9m8f7FZI8fVU85iJewbT45NfQBKo817W4eulzxHaZrL0rje09ItwqbfhtBVs3leai8RD
KLw1sduesL606dWFdsZT1jdhNeq6K9DlhCVUU6s4jZnt1YzAhnM71dH2bycmszY / K1d / 0 c6OzY4R
fwuK4p8rTstn6z8k7HrwGzkAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHz3
Vxvr80 / 8 y38voTwGpj / F5 / 8 AqT / JfjTx / WVeyY6FPspc9dZPVXaOq2WEwIUTVRmjo2rNfLHRI3vZ
DJycXtX8dZh7t879nsnhcbwz23tt + r6I2nxyb + gCVBzuPY / E4PqI9K7ui19fTxNBnp60n + Aj5 / pJ
3 jZu1aOnnltMNussdfXbm + l3ZM9URHREdZVXTuT1Nk7boQiOkJw28PU47 / htEp5eivJPLMTCZ9Vv
x7mJ3iJ9UqNHk8XR4b + tIXuhxAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA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7Dfqz2VzG
0 s2qd + iu / Zn5Ksk9BVztX1mI8930zh2LwOHabH + HHWP2fNYp4 + vwYvxXiP3fUqxtWIjyjZtj45 / L
faQFmQADzftfj3w6fJ6WmHmsP23rvaqnNwqLfhvEvIYZ + sV038bo0noy36MK9oZQxrdMyrlnMbMZ
QKrS1M07zEestq / RRjr4utwY / wAV4j91p9V18fQdJj8LR4ccfdpEfsuREbREJbuMAAAAAAAAAAAA
BAJAAAAEAJEAJQAJQAJEAJQAJQAJEACUJAQlAJEAJQAJQJAAAEAJEAJBAAAJAABAJEJAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABwvanDzaPFmjvjv8A
tLztJ3h7HjGHx + FainnFeaPnHV4vFbeIU038VbHeGF + kso7Mb9mTdhKnLK3dRm7SIrHhGPxeP6Sv
9 cT / AHfSnz72Zx + J7Q45 / BWZ / Z9BbZ + OXyfQBZQABzeP4 / E4NqI9Ii36S8Ng / wAx9C4jTxOH6ivr
jn + Hz3B / mQi / GvjdCnWNlsdI2V07LIlg6USrt2ZzZXMoFV + zPhGLxeOaavpbm / RVltEN72Yx + Jxm
b7dKUmf7L5 + s9 / HtRA2cqRACRACRACRACUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAACQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQCQQCRACRACRCQBCQBCQB
ACRACRACRACRACL1i9LVntMbPATTwdRkxT3pea / u + gPE8Xx + DxrPHlaYt + qNfGvjvtXXsi0dOrKk
dEXjZg6VMtbP2bMtXUdpEV0 / Y2nNxbNf8OP + 727 xvsXH + N1U / wBEfy9k3nxyb + gCVQAGOWvNivX1
rMPnGGOXNNfOJ2fSZ6w + dZKeHxDPX8N7R + 6 L8a + L63KdoZ7q6zvEMpnowdKJ6ywmWUyqvIKM0vQ +
x + D6rU55 + 9 aKx + TzWa36vbezmDwODYenW +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eYFvMibKu
ZHMC2bo51U2RuC2bom6rc3BZzom6sBZzI52ADPnOdggFnMc6skFnMc6rc3BbznOp3RzAv50c6nml
HMC / nOf4qOY5wX85zqOc5wbHOc7X5znBsc6edr85zg2ec52vzpi4NjmY5bROG + / b l l V z s N T k 5 d L l
n0pP8BHmMHWNmzt0aum8obm08vVjfrtnxztR0mXHzTvaZdjVRMTLkZo6yiFen9iZ2pqY / wBP93rN
3 kPY + / L f P X 1 r E / u 9 X z N 3 H f q z d O 6 v m T u I Z 7 m 7 H c 3 B n u 8 t 7 T R / v H B P 9 E / y 9 P u 8 3 7 S V 3 1 u m n + i f 5 R f i
/ j / 0 1 M M b 1 h j k r t K z B G 0 b M s m O Z Y 1 1 t O Y a m r 6 U n d 0 L U c 7 X T 7 u 3 r J P q L 8 e r 9 l c P h c F p b z y W m 3 9 v 7 O 0 0
+ FYvA4Zpsc94xxu227jv1IAgAAAAAAAAABKAAAASgASgBIgBIgBIgBIhIAAAAAAAAAAAAAAAAAAC
UACUJAAAAAAAAAAAABIAAAAAAAAAAAAAAAAAAAAg3AEbomQZbo3YzLGbAz3RNlc3YzcFs2YzdVN2
M2Bdzom6nmNwW86JurTAMuY3REJ2BB1ZRVMVBhsbSsiqeUFXLucq3lTygp5TlXcpygp5TlXcpygp
5 TlXcqOUFXKjlXcrGYBXysdlswiYBVMdUTCyY6sZBWxlnMMZgGLGZZSwkDdHMiWO4MuY5mEyjcFn
N1OdVzHMC3nTzqeY5gX85zqOZPMC + Lqdbk20eb / RKOZr8QybaK / XvtH7iZ9aGlp2luzT3fg19NHS
OjbmPcYX67XH1XSZ9XIzRvMuzrK7zLkZYmYnciunb9lZ5dTk + OP + 71 cXeP8AZnJ / ip2nf3J / l6iL
/ F u 5 L 9 b M W Z c z X i 6 Y u I b E W T z K I u y i w L t 3 n u O 2 5 u I 4 a / h x 7 / r L u c z g 8 T i c v F L b f d p E K 6 + N P H / p h h j o
stLGkctUWnoxrrU3j1cnWTzZq1jzl1clo5Z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oBGyJhkgGPKxmqxAKpownHC + YRMdN5BrTj67R3bOn01o7p01Iv71u89o
b9a7LfBTfS1vWI2jf12VfQPSW8KX2mas + NC2iv6xMNfJpMnLtEbuuxtMRCtzF55NR5rPps1N / ctP
y6uHreE6nXZ4pak48X3rT06fB7fNeI33cbX6mI32R / MWu7XF116aDSRhxbRERs8f499bkyZeeKae
kzE2mdon81 / tfxDLGOunwbzlzbx08oaHBvZHJlx48mrvaa94pu04y617576rNGLRRM0397JEd / lu
9 Dw / S3x4qxffo6mm4NjwUiKY4iI9Ib1dHFY6QIaNabbrYrLfrpJtaK1rMzPZb / s + 05 IpP59OyLeJ
k7eNfRaOc1ue32I7fGXYpi5Y77M8OGMeOKxHSFsU3Y29deZMzirl6dlVvhLatCjJHeYQv1rXnps1
8 k9 / VsW6qLVmZIi1rzitlvFKRvaZ2h6TSaenC9FFY + 3 brM + sqeG8Prp4 + kZ + lvuxPkr1mqm95nfp
DXM459676a2q1dsV7XietvNno78 + CJn1cjX6mOeIm0bR33dfRU5NJjidt9t5afjG / V6JZ7I2QMNh
nyo2BhsMuVG3wAhMSbbQRAMolnE + iuGUSCyJZRKuGUSCyJZK4llEgyZMYTuCUsYSCQASISAAAlCQ
AAAAAAEoASCASAAAAAAAAAAAAlACRACQAAAAAAAAAEgCEoASCAAAAAAAAAAAAAAAAAAAAAAABAAA
AAAAAAAISAIAAAAAAQAAACASgAAAQJAQAAhIDHZhln3do7z0WS18mWsajHjmes7pg3dNi5aRMNqO
yvDHTpPRaigHZhN4hHRlaVN59JY3zRENLUavaO + yq0iNVlitJ6vNcR1MVi0zO0era1 / Ea0rPvbz5
PM5MWp45qvo2GZrhmfrsnpHpHzTCseEcM / 2 vrr8Q1Eb4qzy44nziPN63HpYiIiI7LNHoqabBTFii
IpSNohuVxrKtWMEejPwY9G1FFmHB4mWJn7MdfnIM9JpIx15to5pbUaas / a6rqViI7MxPxqX0UT1r
O3wVzpbR2hviP5i03Y5s6a879FNtHljydhExCv8AMTPJ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AAAAAAAAAABAAAAAAAAAAAAACBKAAAAAAAQ
JQAAAhICEbJAYTWJ7wx8KvpC0BV4ceieWGewDHlNmWwCNjZICNhIDmcZredBecdpiY69FXCOLW + i
UiZidukulmxxlx2paN4mNng + K4 + I8Hy2yaTfl37TXetoCPfRxfp1qi3F48ofKMvtvxak8s6LDv61
rZji9rPaLUf5PC + bfttS0q8q3p9W / wBrRMdpUZuKdN99nzvFqPbTVz7nD8OKs + do2 / mW3h4D7Xaq
ZnPrtNpqz35aRaYOHY9Zk4pNt9rR + rl6zi + OnS + WN57Rv1lXp / YrNaYtruL6zNPnGO3hxP6O5w / 2
f0HDuun09Yv55Le9afznqcOvO4tBreMTHu30unnva0bWt8on + 70 nDuE4OHYYx4Kbesz3tPrMuhGO
IjpDOKrK9YVpsyiGUQnYGOyUgI2SlAIEmwMWMs9kTAMJYzDOYRMArmGErZhhMArlHmzmGMwDE3Ts
bAbs4swj5pgFkSziVcM4BZEsolXDKAZwyhjCYBkACQhIAAAAAAAJAAAAAAAAAAAAAAAAAAAShIAA
AAAAAAJAAAAAAAAAAAAAABAJEAAAAAAAAAAAAAAAIEoBKAAAAAAAAAAAAAAABAlAAAAAAAIAAAAA
BAkBAkBAkBAlACEgMZjdjbFW8bWrEx8YWANb6Fp + bfwab + vLDKMFK9qxH5L0bAr8OPRPKz2AY7J2
SbAjYZAI2E7AIEgIEgIEgMdkSy2NgY7MdlmyNoBXsxmFuyNgVTVjNV3KjlBRNTlXTVHKCrlIqt5T
lBhEMohlFerLlBjEMohMVTEARDKCITsAk2AEgAAAkAAAAAAAAAAAAAAAAAAAAAAAASAAAAAAAAD /
2021-10-22 22:09:52 +02:00
2 Q == ` ;async function Ode(e){let t=(r,s="application/octet-stream")=>fetch( ` data : $ { s } ; base64 , $ { r } ` ).then(i=>i.blob()),n,a;switch(e.config.warmup){case"face":n=await t(nm);break;case"body":case"full":n=await t(am);break;default:n=null}if(n){let r=await createImageBitmap(n);a=await e.detect(r,e.config),r.close()}return a}async function _de(e){return new Promise(t=>{let n;switch(e.config.warmup){case"face":n="data:image/jpeg;base64,"+nm;break;case"full":case"body":n="data:image/jpeg;base64,"+am;break;default:n=null}let a;typeof Image!="undefined"?a=new Image:xe.Image&&(a=new xe.Image),a.onload=async()=>{let r=zn(a.naturalWidth,a.naturalHeight);if(!r)ie("Warmup: Canvas not found"),t({});else{let s=r.getContext("2d");s&&s.drawImage(a,0,0);let i=await e.image(r),o=await e.detect(i.tensor,e.config);t(o)}},n?a.src=n:t(null)})}async function Pde(e){let t=r=>Buffer.from(r,"base64"),n;if(e.config.warmup==="face"&&(n=t(nm)),(e.config.warmup==="body"||e.config.warmup==="full")&&(n=t(am)),!n)return null;let a;if(typeof void 0!="undefined"){let r=(void 0).decodeJpeg(n),s=r.expandDims(0);e.tf.dispose(r),a=await e.detect(s,e.config),e.tf.dispose(s)}else e.config.debug&&ie("Warmup tfjs-node not loaded");return a}async function ZI(e,t){let n=Ae();if(e.state="warmup",t&&(e.config=kn(e.config,t)),!e.config.warmup||e.config.warmup==="none")return{error:"null"};let a;return new Promise(async r=>{typeof createImageBitmap=="function"?a=await Ode(e):typeof Image!="undefined"||xe.Canvas!==void 0?a=await _de(e):a=await Pde(e);let s=Ae();e.config.debug&&ie("Warmup",e.config.warmup,Math.round(s-n),"ms"),e.emit("warmup"),r(a)})}var Zu,ic,oc,rm,JI=class{constructor(t){ce(this,"version");ce(this,"config");ce(this,"result");ce(this,"state");ce(this,"process");ce(this,"tf");ce(this,"env");ce(this,"draw");ce(this,"models");ce(this,"events");ce(this,"faceTriangulation");ce(this,"faceUVMap");ce(this,"performance");pd(this,Zu,void 0);pd(this,ic,void 0);pd(this,oc,void 0);ce(this,"gl");ce(this,"analyze",(...t)=>{if(!dd(this,ic))return;let n=this.tf.engine().state.numTensors,a=dd(this,Zu);cd(this,Zu,n);let r=n-a;r!==0&&ie(...t,r)});pd(this,rm,t=>{if(!dd(this,oc))return null;if(!t)return"input is not defined";if(this.env.node&&!(t instanceof je))return"input must be a tensor";try{this.tf.getBackend()}catch(n){return"backend not loaded"}return null});ce(this,"similarity",qI);ce(this,"distance",tm);ce(this,"match",XI);ce(this,"emit",t=>{var n;this.events&&this.events.dispatchEvent&&((n=this.events)==null||n.dispatchEvent(new Event(t)))});this.env=xe,ss.wasmPath=Ud.includes("-")?"https://vladmandic.github.io/tfjs/dist/": ` https : //cdn.jsdelivr.net/npm/@tensorflow/tfjs-backend-wasm@${Ud}/dist/`,ss.modelBasePath=xe.browser?"../models/":"file://models/",ss.backend=xe.browser?"humangl":"tensorflow",this.version=lx,Object.defineProperty(this,"version",{value:lx}),this.config=JSON.parse(JSON.stringify(ss)),Object.seal(this.config),t&&(this.config=kn(this.config,t)),this.tf=Ro,this.state="idle",cd(this,Zu,0),cd(this,ic,!1),cd(this,oc,!1),this.performance={backend:0,load:0,image:0,frames:0,cached:0,changed:0,total:0,draw:0},this.events=typeof EventTarget!="undefined"?new EventTarget:void 0,this.models=new rc,this.draw={options:Kr,canvas:(n,a)=>LI(n,a),face:(n,a,r)=>y5(n,a,r),body:(n,a,r)=>A5(n,a,r),hand:(n,a,r)=>x5(n,a,r),gesture:(n,a,r)=>g5(n,a,r),object:(n,a,r)=>b5(n,a,r),person:(n,a,r)=>zI(n,a,r),all:(n,a,r)=>WI(n,a,r)},this.result={face:[],body:[],hand:[],gesture:[],object:[],performance:{},timestamp:0,persons:[]},this.process={tensor:null,canvas:null},this.faceTriangulation=B9,this.faceUVMap=V9,this.gl=Ot,this.emit("create")}reset(){let t=this.config.backend;this.config=JSON.parse(JSON.stringify(ss)),this.config.backend=t}validate(t){return M1(ss,t||this.config)}now(){return Ae()}image(t,n=!0){return Uu(t,this.config,n)}async segmentation(t,n){return FI(t,n,this.config)}enhance(t){return Lx(t)}async init(){await em(this,!0),await this.tf.ready()}async load(t){this.state="load";let n=Ae(),a=Object.values(this.models).filter(i=>i).length;t&&(this.config=kn(this.config,t))
2021-04-28 14:58:21 +02:00
/ * *
* @ license
* Copyright 2017 Google LLC . All Rights Reserved .
* Licensed under the Apache License , Version 2.0 ( the "License" ) ;
* you may not use this file except in compliance with the License .
* You may obtain a copy of the License at
*
* http : //www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing , software
* distributed under the License is distributed on an "AS IS" BASIS ,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied .
* See the License for the specific language governing permissions and
* limitations under the License .
* === === === === === === === === === === === === === === === === === === === === === === === === === ==
* /
/ * *
* @ license
* Copyright 2018 Google LLC
*
* Use of this source code is governed by an MIT - style
* license that can be found in the LICENSE file or at
* https : //opensource.org/licenses/MIT.
* === === === === === === === === === === === === === === === === === === === === === === === === === ==
* /
/ * *
* @ license
* Copyright 2018 Google LLC . All Rights Reserved .
* Licensed under the Apache License , Version 2.0 ( the "License" ) ;
* you may not use this file except in compliance with the License .
* You may obtain a copy of the License at
*
* http : //www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing , software
* distributed under the License is distributed on an "AS IS" BASIS ,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied .
* See the License for the specific language governing permissions and
* limitations under the License .
*
* === === === === === === === === === === === === === === === === === === === === === === === === === ==
* /
/ * *
* @ license
* Copyright 2018 Google LLC . All Rights Reserved .
* Licensed under the Apache License , Version 2.0 ( the "License" ) ;
* you may not use this file except in compliance with the License .
* You may obtain a copy of the License at
*
* http : //www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing , software
* distributed under the License is distributed on an "AS IS" BASIS ,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied .
* See the License for the specific language governing permissions and
* limitations under the License .
* === === === === === === === === === === === === === === === === === === === === === === === === === ==
* /
/ * *
* @ license
* Copyright 2019 Google LLC
*
* Use of this source code is governed by an MIT - style
* license that can be found in the LICENSE file or at
* https : //opensource.org/licenses/MIT.
* === === === === === === === === === === === === === === === === === === === === === === === === === ==
* /
/ * *
* @ license
* Copyright 2019 Google LLC . All Rights Reserved .
* Licensed under the Apache License , Version 2.0 ( the "License" ) ;
* you may not use this file except in compliance with the License .
* You may obtain a copy of the License at
*
* http : //www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing , software
* distributed under the License is distributed on an "AS IS" BASIS ,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied .
* See the License for the specific language governing permissions and
* limitations under the License .
*
* === === === === === === === === === === === === === === === === === === === === === === === === === ==
* /
/ * *
* @ license
* Copyright 2019 Google LLC . All Rights Reserved .
* Licensed under the Apache License , Version 2.0 ( the "License" ) ;
* you may not use this file except in compliance with the License .
* You may obtain a copy of the License at
*
* http : //www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing , software
* distributed under the License is distributed on an "AS IS" BASIS ,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied .
* See the License for the specific language governing permissions and
* limitations under the License .
* === === === === === === === === === === === === === === === === === === === === === === === === === ==
* /
/ * *
* @ license
* Copyright 2020 Google Inc . All Rights Reserved .
* Licensed under the Apache License , Version 2.0 ( the "License" ) ;
* you may not use this file except in compliance with the License .
* You may obtain a copy of the License at
*
* http : //www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing , software
* distributed under the License is distributed on an "AS IS" BASIS ,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied .
* See the License for the specific language governing permissions and
* limitations under the License .
* === === === === === === === === === === === === === === === === === === === === === === === === === ==
* /
/ * *
* @ license
* Copyright 2020 Google LLC
*
* Use of this source code is governed by an MIT - style
* license that can be found in the LICENSE file or at
* https : //opensource.org/licenses/MIT.
* === === === === === === === === === === === === === === === === === === === === === === === === === ==
* /
/ * *
* @ license
* Copyright 2020 Google LLC . All Rights Reserved .
* Licensed under the Apache License , Version 2.0 ( the "License" ) ;
* you may not use this file except in compliance with the License .
* You may obtain a copy of the License at
*
* http : //www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing , software
* distributed under the License is distributed on an "AS IS" BASIS ,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied .
* See the License for the specific language governing permissions and
* limitations under the License .
* === === === === === === === === === === === === === === === === === === === === === === === === === ==
* /
/ * *
* @ license
* Copyright 2020 Google LLC . All Rights Reserved .
* Licensed under the Apache License , Version 2.0 ( the License ) ;
* you may not use this file except in compliance with the License .
* You may obtain a copy of the License at
*
* http : //www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing , software
* distributed under the License is distributed on an AS IS BASIS ,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied .
* See the License for the specific language governing permissions and
* limitations under the License .
* === === === === === === === === === === === === === === === === === === === === === === === === === ==
* /
/ * *
* @ license
* Copyright 2021 Google LLC . All Rights Reserved .
* Licensed under the Apache License , Version 2.0 ( the "License" ) ;
* you may not use this file except in compliance with the License .
* You may obtain a copy of the License at
*
* http : //www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing , software
* distributed under the License is distributed on an "AS IS" BASIS ,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied .
* See the License for the specific language governing permissions and
* limitations under the License .
* === === === === === === === === === === === === === === === === === === === === === === === === === ==
* /
2021-04-30 17:55:04 +02:00
/ * *
* @ license
* Copyright 2021 Google LLC . All Rights Reserved .
* Licensed under the Apache License , Version 2.0 ( the "License" ) ;
* you may not use this file except in compliance with the License .
* You may obtain a copy of the License at
*
* https : //www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing , software
* distributed under the License is distributed on an "AS IS" BASIS ,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied .
* See the License for the specific language governing permissions and
* limitations under the License .
* === === === === === === === === === === === === === === === === === === === === === === === === === ==
* /
2021-08-31 19:00:06 +02:00
/ * *
* @ license
* Copyright 2018 Google LLC . All Rights Reserved .
* Licensed under the Apache License , Version 2.0 ( the "License" ) ;
* you may not use this file except in compliance with the License .
* You may obtain a copy of the License at
*
* http : //www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing , software
* distributed under the License is distributed on an "AS IS" BASIS ,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied .
* See the License for the specific language governing permissions and
* limitations under the License .
* === === === === === === === === === === === === === === === === === === === === === === === === === ==
* /
2021-04-28 14:58:21 +02:00
/** @license See the LICENSE file. */