human/dist/demo-browser-index.js

5038 lines
1.3 MiB
JavaScript
Raw Normal View History

2020-11-20 14:53:40 +01:00
/*
Human library
homepage: <https://github.com/vladmandic/human>
author: <https://github.com/vladmandic>'
*/
2021-02-25 13:50:13 +01:00
var h4=Object.create,nh=Object.defineProperty,d4=Object.getPrototypeOf,p4=Object.prototype.hasOwnProperty,f4=Object.getOwnPropertyNames,m4=Object.getOwnPropertyDescriptor,_f=e=>nh(e,"__esModule",{value:!0}),$2=(e,t)=>()=>(t||(t={exports:{}},e(t.exports,t)),t.exports),kr=(e,t)=>{for(var n in t)nh(e,n,{get:t[n],enumerable:!0})},A4=(e,t,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of f4(t))!p4.call(e,r)&&r!=="default"&&nh(e,r,{get:()=>t[r],enumerable:!(n=m4(t,r))||n.enumerable});return e},rh=e=>e&&e.__esModule?e:A4(_f(nh(e!=null?h4(d4(e)):{},"default",{value:e,enumerable:!0})),e),w4=$2(e=>{_f(e),kr(e,{MediaPipeFaceMesh:()=>t,load:()=>r});var t=class{constructor(a,s,i,o){this.facePipeline=new x4(a,s,i,o),this.config=o}async estimateFaces(a,s){let i=await this.facePipeline.predict(a,s),o=[];for(let l of i||[]){if(l.isDisposedInternal)continue;let u=l.coords?l.coords.arraySync():null,c=l.rawCoords,h={};if(u&&u.length>0)for(let f of Object.keys(ma))h[f]=ma[f].map(m=>u[m]);let d=s.face.mesh.returnRawData&&l.box?{topLeft:l.box.startPoint,bottomRight:l.box.endPoint}:null,p=l.box?[Math.max(0,l.box.startPoint[0]),Math.max(0,l.box.startPoint[1]),Math.min(a.shape[2],l.box.endPoint[0])-l.box.startPoint[0],Math.min(a.shape[1],l.box.endPoint[1])-l.box.startPoint[1]]:0;o.push({confidence:l.confidence||0,box:p,mesh:u,boxRaw:d,meshRaw:c,annotations:h,image:l.image?Ir(l.image):null}),l.coords&&l.coords.dispose(),l.image&&l.image.dispose()}return o}},n=[null,null,null];async function r(a){n=await Promise.all([!n[0]&&a.face.enabled?y4(a):null,!n[1]&&a.face.mesh.enabled?Yn(a.face.mesh.modelPath,{fromTFHub:a.face.mesh.modelPath.includes("tfhub.dev")}):null,!n[2]&&a.face.iris.enabled?Yn(a.face.iris.modelPath,{fromTFHub:a.face.iris.modelPath.includes("tfhub.dev")}):null]);let s=new t(n[0],n[1],n[2],a);return a.face.mesh.enabled&&Ve(`load model: ${a.face.mesh.modelPath.match(/\/(.*)\./)[1]}`),a.face.iris.enabled&&Ve(`load model: ${a.face.iris.modelPath.match(/\/(.*)\./)[1]}`),s}e.triangulation=g4}),bf=$2(e=>{_f(e),kr(e,{NUM_KEYPOINTS:()=>n,connectedPartIndices:()=>s,partChannels:()=>o,partIds:()=>r,partNames:()=>t,poseChain:()=>i});var t=["nose","leftEye","rightEye","leftEar","rightEar","leftShoulder","rightShoulder","leftElbow","rightElbow","leftWrist","rightWrist","leftHip","rightHip","leftKnee","rightKnee","leftAnkle","rightAnkle"],n=e.partNames.length,r=e.partNames.reduce((l,u,c)=>(l[u]=c,l),{}),a=[["leftHip","leftShoulder"],["leftElbow","leftShoulder"],["leftElbow","leftWrist"],["leftHip","leftKnee"],["leftKnee","leftAnkle"],["rightHip","rightShoulder"],["rightElbow","rightShoulder"],["rightElbow","rightWrist"],["rightHip","rightKnee"],["rightKnee","rightAnkle"],["leftShoulder","rightShoulder"],["leftHip","rightHip"]],s=a.map(([l,u])=>[r[l],r[u]]),i=[["nose","leftEye"],["leftEye","leftEar"],["nose","rightEye"],["rightEye","rightEar"],["nose","leftShoulder"],["leftShoulder","leftElbow"],["leftElbow","leftWrist"],["leftShoulder","leftHip"],["leftHip","leftKnee"],["leftKnee","leftAnkle"],["nose","rightShoulder"],["rightShoulder","rightElbow"],["rightElbow","rightWrist"],["rightShoulder","rightHip"],["rightHip","rightKnee"],["rightKnee","rightAnkle"]],o=["left_face","right_face","right_upper_leg_front","right_lower_leg_back","right_upper_leg_back","left_lower_leg_front","left_upper_leg_front","left_upper_leg_back","left_lower_leg_back","right_feet","right_lower_leg_front","left_feet","torso_front","torso_back","right_upper_arm_front","right_upper_arm_back","right_lower_arm_back","left_lower_arm_front","left_upper_arm_front","left_upper_arm_back","left_lower_arm_back","right_hand","right_lower_arm_front","left_hand"]});function Ve(...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 M2={};kr(M2,{Abs:()=>Oi,Acos:()=>zi,Acosh:()=>Li,AdadeltaOptimizer:()=>fd,AdagradOptimizer:()=>md,AdamOptimizer:()=>Ad,AdamaxOptimizer:()=>yd,Add:()=>Aa,AddN:()=>q
2021-02-21 20:07:04 +01:00
`)),l.join(`
2021-02-25 13:50:13 +01:00
`)}function Wk(e,t,n,r){let a=Ot(t),s=r[r.length-1],i=new Array(s).fill(0),o=t.length,l=n==="complex64"?Pu(e):e;if(o>1)for(let u=0;u<a/s;u++){let c=u*s;for(let h=0;h<s;h++)i[h]=Math.max(i[h],Lu(l[c+h],0,n).length)}return i}function Lu(e,t,n){let r;return Array.isArray(e)?r=`${parseFloat(e[0].toFixed(_m))} + ${parseFloat(e[1].toFixed(_m))}j`:Na(e)?r=`'${e}'`:n==="bool"?r=e5(e):r=parseFloat(e.toFixed(_m)).toString(),$u(r,t)}function e5(e){return e===0?"false":"true"}function Td(e,t,n,r,a,s=!0){let i=n==="complex64"?2:1,o=t[0],l=t.length;if(l===0){if(n==="complex64"){let m=Pu(e);return[Lu(m[0],0,n)]}return n==="bool"?[e5(e[0])]:[e[0].toString()]}if(l===1){if(o>Q0){let A=zu*i,y=Array.from(e.slice(0,A)),g=Array.from(e.slice((o-zu)*i,o*i));return n==="complex64"&&(y=Pu(y),g=Pu(g)),["["+y.map((w,_)=>Lu(w,a[_],n)).join(", ")+", ..., "+g.map((w,_)=>Lu(w,a[o-zu+_],n)).join(", ")+"]"]}let m=n==="complex64"?Pu(e):Array.from(e);return["["+m.map((A,y)=>Lu(A,a[y],n)).join(", ")+"]"]}let u=t.slice(1),c=r.slice(1),h=r[0]*i,d=[];if(o>Q0){for(let m=0;m<zu;m++){let A=m*h,y=A+h;d.push(...Td(e.slice(A,y),u,n,c,a,!1))}d.push("...");for(let m=o-zu;m<o;m++){let A=m*h,y=A+h;d.push(...Td(e.slice(A,y),u,n,c,a,m===o-1))}}else for(let m=0;m<o;m++){let A=m*h,y=A+h;d.push(...Td(e.slice(A,y),u,n,c,a,m===o-1))}let p=l===2?",":"";d[0]="["+d[0]+p;for(let m=1;m<d.length-1;m++)d[m]=" "+d[m]+p;let f=`,
2021-02-21 20:07:04 +01:00
`;for(let m=2;m<l;m++)f+=`
2021-02-25 13:50:13 +01:00
`;return d[d.length-1]=" "+d[d.length-1]+"]"+(s?"":f),d}function Pu(e){let t=[];for(let n=0;n<e.length;n+=2)t.push([e[n],e[n+1]]);return t}var Mt=class{constructor(e,t,n){if(this.dtype=t,this.shape=e.slice(),this.size=Ot(e),n!=null){let r=n.length;F(r===this.size,()=>`Length of values '${r}' does not match the size inferred by the shape '${this.size}'.`)}if(t==="complex64")throw new Error("complex64 dtype TensorBuffers are not supported. Please create a TensorBuffer for the real and imaginary parts separately and call tf.complex(real, imag).");this.values=n||j0(t,this.size),this.strides=Yo(e)}set(e,...t){t.length===0&&(t=[0]),F(t.length===this.rank,()=>`The number of provided coordinates (${t.length}) must match the rank (${this.rank})`);let n=this.locToIndex(t);this.values[n]=e}get(...e){e.length===0&&(e=[0]);let t=0;for(let r of e){if(r<0||r>=this.shape[t]){let a=`Requested out of range element at ${e}. Buffer shape=${this.shape}`;throw new Error(a)}t++}let n=e[e.length-1];for(let r=0;r<e.length-1;++r)n+=this.strides[r]*e[r];return this.values[n]}locToIndex(e){if(this.rank===0)return 0;if(this.rank===1)return e[0];let t=e[e.length-1];for(let n=0;n<e.length-1;++n)t+=this.strides[n]*e[n];return t}indexToLoc(e){if(this.rank===0)return[];if(this.rank===1)return[e];let t=new Array(this.shape.length);for(let n=0;n<t.length-1;++n)t[n]=Math.floor(e/this.strides[n]),e-=t[n]*this.strides[n];return t[t.length-1]=e,t}get rank(){return this.shape.length}toTensor(){return $r().makeTensor(this.values,this.shape,this.dtype)}},$r=null,el=null,Vk=null;function Uk(e){$r=e}function jk(e){el=e}function Hk(e){Vk=e}var Ye=class{constructor(e,t,n,r){this.kept=!1,this.isDisposedInternal=!1,this.shape=e.slice(),this.dtype=t||"float32",this.size=Ot(e),this.strides=Yo(e),this.dataId=n,this.id=r,this.rankType=this.rank<5?this.rank.toString():"higher"}get rank(){return this.shape.length}async buffer(){let e=await this.data();return el.buffer(this.shape,this.dtype,e)}bufferSync(){return el.buffer(this.shape,this.dtype,this.dataSync())}async array(){let e=await this.data();return Jo(this.shape,e)}arraySync(){return Jo(this.shape,this.dataSync())}async data(){this.throwIfDisposed();let e=$r().read(this.dataId);if(this.dtype==="string"){let t=await e;try{return t.map(n=>Sd(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=$r().readSync(this.dataId);if(this.dtype==="string")try{return e.map(t=>Sd(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 $r().read(this.dataId);return this.dtype==="string"?e:new Uint8Array(e.buffer)}dispose(){this.isDisposed||($r().disposeTensor(this),this.isDisposedInternal=!0)}get isDisposed(){return this.isDisposedInternal}throwIfDisposed(){if(this.isDisposed)throw new Error("Tensor is disposed.")}print(e=!1){return el.print(this,e)}clone(){return this.throwIfDisposed(),el.clone(this)}toString(e=!1){let t=this.dataSync();return Bk(t,this.shape,this.dtype,e)}cast(e){return this.throwIfDisposed(),el.cast(this,e)}variable(e=!0,t,n){return this.throwIfDisposed(),$r().makeVariable(this,e,t,n)}};Object.defineProperty(Ye,Symbol.hasInstance,{value:e=>!!e&&e.data!=null&&e.dataSync!=null&&e.throwIfDisposed!=null});function Z(){return xm("Tensor",()=>Ye)}Z();var uu=class extends Ye{constructor(e,t,n,r){super(e.shape,e.dtype,e.dataId,r);this.trainable=t,this.name=n}assign(e){if(e.dtype!==this.dtype)throw new Error(`dtype of the new value (${e.dtype}) and previous value (${this.dtype}) must match`);if(!ea(e.shape,this.shape))throw new Error(`shape of the new value (${e.shape}) and previous value (${this.shape}) must match`);$r().disposeTensor(this),this.dataId=e.dataId,$r().incRef(this,null)}dispose(){$r().disposeVariable(this),this.isDisposedInternal=!0}};Object.defineProperty(uu,Symbol.hasInstance,{value:e=>e instanceof Ye&&e.assign!=null&&e.assign instanceof Function});var hr={}
Manifest JSON has weights with names: ${o.join(", ")}.`)}let l=a.reduce((p,f,m)=>(f&&p.push(m),p),[]),u=[];l.forEach(p=>{t[p].paths.forEach(f=>{let m=n+(n.endsWith("/")?"":"/")+f;u.push(m)})});let c=await e(u),h={},d=0;return l.forEach(p=>{let f=t[p].paths.length,m=0;for(let w=0;w<f;w++)m+=c[d+w].byteLength;let A=new ArrayBuffer(m),y=new Uint8Array(A),g=0;for(let w=0;w<f;w++){let _=new Uint8Array(c[d+w]);y.set(_,g),g+=_.byteLength}s[p].forEach(w=>{let _=A.slice(w.groupOffset,w.groupOffset+w.sizeBytes),b=l5(_,[w.manifestEntry]);for(let x in b)h[x]=b[x]}),d+=f}),h}}var j9="application/octet-stream",H9="application/json",zm=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?(F(typeof t.fetchFunc=="function",()=>"Must pass a function that matches the signature of `fetch` (see https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API)"),this.fetch=t.fetchFunc):this.fetch=Y().platform.fetch,F(e!=null&&e.length>0,()=>"URL path for http must not be null, undefined or empty."),Array.isArray(e)&&F(e.length===2,()=>`URL paths for http must have a length of 2, (actual length is ${e.length}).`),this.path=e,t.requestInit!=null&&t.requestInit.body!=null)throw new Error("requestInit is expected to have no pre-existing body, but has one.");this.requestInit=t.requestInit||{}}async save(e){if(e.modelTopology instanceof ArrayBuffer)throw new Error("BrowserHTTPRequest.save() does not support saving model topology in binary formats yet.");let t=Object.assign({method:this.DEFAULT_METHOD},this.requestInit);t.body=new FormData;let n=[{paths:["./model.weights.bin"],weights:e.weightSpecs}],r={modelTopology:e.modelTopology,format:e.format,generatedBy:e.generatedBy,convertedBy:e.convertedBy,weightsManifest:n};e.signature!=null&&(r.signature=e.signature),e.userDefinedMetadata!=null&&(r.userDefinedMetadata=e.userDefinedMetadata),e.modelInitializer!=null&&(r.modelInitializer=e.modelInitializer),t.body.append("model.json",new Blob([JSON.stringify(r)],{type:H9}),"model.json"),e.weightData!=null&&t.body.append("model.weights.bin",new Blob([e.weightData],{type:j9}),"model.weights.bin");let a=await this.fetch(this.path,t);if(a.ok)return{modelArtifactsInfo:Vu(e),responses:[a]};throw new Error(`BrowserHTTPRequest.save() failed due to HTTP response status ${a.status}.`)}async load(){let e=await this.fetch(this.path,this.requestInit);if(!e.ok)throw new Error(`Request to ${this.path} failed with status code ${e.status}. Please verify this URL points to the model JSON of the model to load.`);let t;try{t=await e.json()}catch(p){let f=`Failed to parse model JSON of response from ${this.path}.`;throw this.path.endsWith(".pb")?f+=" Your path contains a .pb file extension. Support for .pb models have been removed in TensorFlow.js 1.0 in favor of .json models. You can re-convert your Python TensorFlow model using the TensorFlow.js 1.0 conversion scripts or you can convert your.pb models with the 'pb2json'NPM script in the tensorflow/tfjs-converter repository.":f+=" Please make sure the server is serving valid JSON for this request.",new Error(f)}let n=t.modelTopology,r=t.weightsManifest,a=t.generatedBy,s=t.convertedBy,i=t.format,o=t.signature,l=t.userDefinedMetadata;if(n==null&&r==null)throw new Error(`The JSON from HTTP path ${this.path} contains neither model topology or manifest for weights.`);let u,c;r!=null&&([u,c]=await this.loadWeights(r));let h={modelTopology:n,weightSpecs:u,weightData:c,generatedBy:a,convertedBy:s,format:i};o!=null&&(h.signature=o),l!=null&&(h.userDefinedMetadata=l);let d=t.modelInitializer;return d&&(h.modelInitializer=d),h}async loadWeights(e){let t=Array.isArray(this.path)?this.path[1]:this.path,[n,r]=G9(t),a=this.weightPathPrefix||n,s=[];for(let u of e)s.push(...u.weights);let i=[],o=[];for(let u of e)for(let c of u.paths)this.weightUrlConverter!=null?o.push(this.weightUrlConverter(c)):i.push(a+c+r);this.weightUrlConverter&&i.push(...await Promise.all(o));let l=await w5(i,{requestInit:this
2021-02-21 20:07:04 +01:00
Actual: ${a}.
Expected: ${s}.`);for(let i=0;i<s.length;++i){let o=a[i],l=s[i];if(!n(o,l))throw new Error(`Arrays differ: actual[${i}] = ${o}, expected[${i}] = ${l}.
Actual: ${a}.
2021-02-25 13:50:13 +01:00
Expected: ${s}.`)}}function oI(e,t){e().then(()=>t.fail(),()=>t())}function lI(e,t){let n=typeof t=="string"||typeof t=="number"||typeof t=="boolean"?[t]:t;return Na(e)||Na(e[0])||Na(t)||Na(t[0])?Vm(e,n,(r,a)=>r==a):Vm(e,t,(r,a)=>Um(r,a,0))}function uI(e,t,n){if(n==null&&(n=Bm()),!Um(e,t,n))throw new Error(`Numbers differ: actual === ${e}, expected === ${t}`)}function Um(e,t,n){return!isFinite(e)&&!isFinite(t)?!0:!(isNaN(e)||isNaN(t)||Math.abs(e-t)>n)}function cI(e,t,n){for(let r=0;r<e.length;r++)if(e[r]<t||e[r]>n)throw new Error(`Value out of range:${e[r]} low: ${t}, high: ${n}`)}function hI(e,t){expect(new Float32Array(e)).toEqual(new Float32Array(t))}function z5(e){for(let t=0;t<e.length;t++){let n=e[t];Array.isArray(n)?z5(n):e[t]=Ou(n)}return e}var I4="3.2.0";function N4(){Y().set("PROD",!0)}function S4(){Y().set("DEBUG",!0)}function T4(){Y().set("DEPRECATION_WARNINGS_ENABLED",!1),console.warn("TensorFlow.js deprecation warnings have been disabled.")}function Tf(e){Y().getBool("DEPRECATION_WARNINGS_ENABLED")&&console.warn(e+" You can disable deprecation warnings with tf.disableDeprecationWarnings().")}Hk(Tf);function E4(){M.disposeVariables()}function Nr(){return M}function Ph(){return M.memory()}function Lo(e){return M.profile(e)}function V(e,t){return M.tidy(e,t)}function Re(e){bm(e).forEach(t=>t.dispose())}function Vt(e){return M.keep(e)}function C4(e){return M.time(e)}function R4(e){return M.setBackend(e)}function F4(){return M.ready()}function $4(){return M.backendName}function M4(e){M.removeBackend(e)}function U2(e){return M.findBackend(e)}function D4(e){return M.findBackendFactory(e)}function hu(e,t,n=1){return M.registerBackend(e,t,n)}function j2(){return M.backend}function O4(e,t){Y().setPlatform(e,t)}function pI(e,t){let n=R(e,"a","add"),r=R(t,"b","add");[n,r]=vt(n,r);let a={a:n,b:r};return M.runKernel(Aa,a)}var oe=O({add_:pI});function fI(e,t){let n=R(e,"a","floorDiv"),r=R(t,"b","floorDiv");[n,r]=vt(n,r);let a={a:n,b:r};return M.runKernel(os,a)}var Wh=O({floorDiv_:fI});function mI(e,t){let n=R(e,"a","div"),r=R(t,"b","div");if([n,r]=vt(n,r),n.dtype==="int32"&&r.dtype==="int32")return Wh(n,r);let a={a:n,b:r},s={};return M.runKernel(as,a,s)}var ve=O({div_:mI});function AI(e,t){let n=R(e,"a","mul"),r=R(t,"b","mul");[n,r]=vt(n,r);let a={a:n,b:r};return M.runKernel(xs,a)}var W=O({mul_:AI});function yI(e){let t=R(e,"x","abs");if(t.dtype==="complex64"){let n={x:t};return M.runKernel(Xl,n)}else{let n={x:t};return M.runKernel(Oi,n)}}var Dt=O({abs_:yI});function gI(e){let t={x:R(e,"x","acos")};return M.runKernel(zi,t)}var Ef=O({acos_:gI});function xI(e){let t={x:R(e,"x","acosh")};return M.runKernel(Li,t)}var Cf=O({acosh_:xI});function wI(e){F(Array.isArray(e),()=>"The argument passed to tf.addN() must be a list of tensors"),F(e.length>=1,()=>`Must pass at least one tensor to tf.addN(), but got ${e.length}`);let t=e.map((a,s)=>R(a,`tensors${s}`,"addN")),n=t[0];t.forEach(a=>{if(a.dtype!==n.dtype)throw new Error("All tensors passed to tf.addN() must have the same dtype")}),t.forEach(a=>{if(!ea(a.shape,n.shape))throw new Error("All tensors passed to tf.addN() must have the same shape")});let r=t;return M.runKernel(qa,r)}var Bh=O({addN_:wI});function _I(e,t=null,n=!1){let r={x:R(e,"x","all","bool")},a={axis:t,keepDims:n};return M.runKernel(sh,r,a)}var Vh=O({all_:_I});function bI(e,t=null,n=!1){let r={x:R(e,"x","any","bool")},a={axis:t,keepDims:n};return M.runKernel(ih,r,a)}var du=O({any_:bI});function vI(e,t=0){let n={x:R(e,"x","argMax")},r={axis:t};return M.runKernel(Xa,n,r)}var pu=O({argMax_:vI});function kI(e,t=0){let n={x:R(e,"x","argMin")},r={axis:t};return M.runKernel(Hl,n,r)}var Rf=O({argMin_:kI});function II(e){let t={x:R(e,"x","asin")};return M.runKernel(Pi,t)}var Ff=O({asin_:II});function NI(e){let t={x:R(e,"x","asinh")};return M.runKernel(Wi,t)}var $f=O({asinh_:NI});function SI(e){let t={x:R(e,"x","atan")};return M.runKernel(Bi,t)}var Mf=O({atan_:SI});function TI(e,t){let n=R(e,"a","atan2"),r=R(t,"b","atan2");[n,r]=vt(n,r);let a={a:n,b:r};return M.runKernel(Ui,a)}var Df=O({atan2_:TI});function EI(e){let t={x:R
with dtype ${s.dtype}. `)}),n.length===1)return Ir(n[0]);let r=n,a={axis:t};return M.runKernel(ji,r,a)}var ot=O({concat_:PI});function WI(e){let t={x:R(e,"x","sigmoid")};return M.runKernel(Rs,t)}var Qn=O({sigmoid_:WI});function BI(e,t,n){let r=R(e,"x","slice","string_or_numeric");if(r.rank===0)throw new Error("Slicing scalar is not possible");let a={x:r},s={begin:t,size:n};return M.runKernel(Io,a,s)}var Fe=O({slice_:BI});function VI(e){let t={x:R(e,"x","tanh")};return M.runKernel(zs,t)}var Po=O({tanh_:VI});function UI(e,t,n,r,a,s){let i=R(e,"forgetBias","basicLSTMCell"),o=R(t,"lstmKernel","basicLSTMCell"),l=R(n,"lstmBias","basicLSTMCell"),u=R(r,"data","basicLSTMCell"),c=R(a,"c","basicLSTMCell"),h=R(s,"h","basicLSTMCell"),d=ot([u,h],1),p=Ge(d,o),f=oe(p,l),m=f.shape[0],A=f.shape[1]/4,y=[m,A],g=Fe(f,[0,0],y),w=Fe(f,[0,A],y),_=Fe(f,[0,A*2],y),b=Fe(f,[0,A*3],y),x=oe(W(Qn(g),Po(w)),W(c,Qn(oe(i,_)))),N=W(Po(x),Qn(b));return[x,N]}var z4=O({basicLSTMCell_:UI});function jI(e,t,n){let r=R(e,"x","batchToSpaceND"),a=t.reduce((o,l)=>o*l);F(r.rank>=1+t.length,()=>`input rank is ${r.rank} but should be > than blockShape.length ${t.length}`),F(n.length===t.length,()=>`crops.length is ${n.length} but should be equal to blockShape.length ${t.length}`),F(r.shape[0]%a==0,()=>`input tensor batch is ${r.shape[0]} but is not divisible by the product of the elements of blockShape ${t.join(" * ")} === ${a}`);let s={x:r},i={blockShape:t,crops:n};return M.runKernel(ql,s,i)}var mu=O({batchToSpaceND_:jI});function HI(e){let t;return e.rank===0||e.rank===1?t=H(e,[1,1,1,e.size]):e.rank===2?t=H(e,[1,1,e.shape[0],e.shape[1]]):e.rank===3?t=H(e,[1,e.shape[0],e.shape[1],e.shape[2]]):t=e,t}function GI(e,t,n,r,a,s){s==null&&(s=.001);let i=R(e,"x","batchNorm"),o=R(t,"mean","batchNorm"),l=R(n,"variance","batchNorm"),u;a!=null&&(u=R(a,"scale","batchNorm"));let c;r!=null&&(c=R(r,"offset","batchNorm")),F(o.rank===l.rank,()=>"Batch normalization gradient requires mean and variance to have equal ranks."),F(c==null||o.rank===c.rank,()=>"Batch normalization gradient requires mean and offset to have equal ranks."),F(u==null||o.rank===u.rank,()=>"Batch normalization gradient requires mean and scale to have equal ranks.");let h={x:HI(i),scale:u,offset:c,mean:o,variance:l},d={varianceEpsilon:s},p=M.runKernel(ls,h,d);return H(p,i.shape)}var Vs=O({batchNorm_:GI});function qI(e,t,n,r,a,s){let i=R(e,"x","batchNorm"),o=R(t,"mean","batchNorm"),l=R(n,"variance","batchNorm"),u;a!=null&&(u=R(a,"scale","batchNorm"));let c;return r!=null&&(c=R(r,"offset","batchNorm")),F(i.rank===2,()=>`Error in batchNorm2D: x must be rank 2 but got rank ${i.rank}.`),F(o.rank===2||o.rank===1,()=>`Error in batchNorm2D: mean must be rank 2 or rank 1 but got rank ${o.rank}.`),F(l.rank===2||l.rank===1,()=>`Error in batchNorm2D: variance must be rank 2 or rank 1 but got rank ${l.rank}.`),u!=null&&F(u.rank===2||u.rank===1,()=>`Error in batchNorm2D: scale must be rank 2 or rank 1 but got rank ${u.rank}.`),c!=null&&F(c.rank===2||c.rank===1,()=>`Error in batchNorm2D: offset must be rank 2 or rank 1 but got rank ${c.rank}.`),Vs(i,o,l,c,u,s)}var H2=O({batchNorm2d_:qI});function XI(e,t,n,r,a,s){let i=R(e,"x","batchNorm"),o=R(t,"mean","batchNorm"),l=R(n,"variance","batchNorm"),u;a!=null&&(u=R(a,"scale","batchNorm"));let c;return r!=null&&(c=R(r,"offset","batchNorm")),F(i.rank===3,()=>`Error in batchNorm3D: x must be rank 3 but got rank ${i.rank}.`),F(o.rank===3||o.rank===1,()=>`Error in batchNorm3D: mean must be rank 3 or rank 1 but got rank ${o.rank}.`),F(l.rank===3||l.rank===1,()=>`Error in batchNorm3D: variance must be rank 3 or rank 1 but got rank ${l.rank}.`),u!=null&&F(u.rank===3||u.rank===1,()=>`Error in batchNorm3D: scale must be rank 3 or rank 1 but got rank ${u.rank}.`),c!=null&&F(c.rank===3||c.rank===1,()=>`Error in batchNorm3D: offset must be rank 3 or rank 1 but got rank ${c.rank}.`),Vs(i,o,l,c,u,s)}var G2=O({batchNorm3d_:XI});function KI(e,t,n,r,a,s){let i=R(e,"x","batchNorm"),o=R(t,"mean","batchNorm"),l=R(n,"variance","batchNorm"),u;a!=null&&(u=R(a,"scale","batchNorm"));let c;return r!=
2021-02-21 20:07:04 +01:00
${a} and ${t} for depthToSpace with input shape
${r.shape}`),F(s*t>=0,()=>`Negative dimension size caused by overflow when multiplying
${s} and ${t} for depthToSpace with input shape
2021-02-25 13:50:13 +01:00
${r.shape}`),F(i%(t*t)==0,()=>`Dimension size must be evenly divisible by ${t*t} but is ${i} for depthToSpace with input shape ${r.shape}`);let o={x:r},l={blockSize:t,dataFormat:n};return M.runKernel(qi,o,l)}var Wf=O({depthToSpace_:mN});function AN(e,t,n,r,a="NHWC",s=[1,1],i){let o=R(e,"x","depthwiseConv2d"),l=R(t,"filter","depthwiseConv2d"),u=o,c=!1;o.rank===3&&(c=!0,u=H(o,[1,o.shape[0],o.shape[1],o.shape[2]])),F(u.rank===4,()=>`Error in depthwiseConv2d: input must be rank 4, but got rank ${u.rank}.`),F(l.rank===4,()=>`Error in depthwiseConv2d: filter must be rank 4, but got rank ${l.rank}.`),F(u.shape[3]===l.shape[2],()=>`Error in depthwiseConv2d: number of input channels (${u.shape[3]}) must match the inChannels dimension in filter ${l.shape[2]}.`),i!=null&&F(jt(r),()=>`Error in depthwiseConv2d: pad must be an integer when using, dimRoundingMode ${i} but got pad ${r}.`);let h={x:u,filter:l},d={strides:n,pad:r,dataFormat:a,dilations:s,dimRoundingMode:i},p=M.runKernel(rs,h,d);return c?H(p,[p.shape[1],p.shape[2],p.shape[3]]):p}var Wo=O({depthwiseConv2d_:AN});function yN(e){let t={x:R(e,"x","diag")};return M.runKernel(yh,t)}var P4=O({diag_:yN});function gN(e,t,n,r,a=[1,1],s="NHWC"){let i=R(e,"x","dilation2d"),o=R(t,"filter","dilation2d");F(i.rank===3||i.rank===4,()=>`Error in dilation2d: input must be rank 3 or 4, but got rank ${i.rank}.`),F(o.rank===3,()=>`Error in dilation2d: filter must be rank 3, but got rank ${o.rank}.`),F(s==="NHWC",()=>`Error in dilation2d: Only NHWC is currently supported, but got dataFormat of ${s}`);let l=i,u=!1;i.rank===3&&(l=H(i,[1,i.shape[0],i.shape[1],i.shape[2]]),u=!0);let c={x:l,filter:o},h={strides:n,pad:r,dilations:a},d=M.runKernel(Zl,c,h);return u?H(d,[d.shape[1],d.shape[2],d.shape[3]]):d}var Bf=O({dilation2d_:gN});function xN(e,t){let n=e.length,r=[];for(let a=0;a<n;a++){let s=n-1-a,i=e[s]||1;(t[t.length-1-a]||1)>1&&i===1&&r.unshift(s)}return r}function zt(e,t){let n=[];for(let r=0;r<t.length;r++){let a=e[e.length-r-1],s=t.length-r-1,i=t[s];(a==null||a===1&&i>1)&&n.unshift(s)}return n}function mt(e,t){let n=[],r=Math.max(e.length,t.length);for(let a=0;a<r;a++){let s=e[e.length-a-1];s==null&&(s=1);let i=t[t.length-a-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 wN(e,t){let n=R(e,"a","equal"),r=R(t,"b","equal");[n,r]=vt(n,r),mt(n.shape,r.shape);let a={a:n,b:r};return M.runKernel(Zi,a)}var _a=O({equal_:wN});function _N(e,t,n){let r=R(t,"a","where"),a=R(n,"b","where"),s=R(e,"condition","where","bool"),i=mt(r.shape,a.shape),o=Au(r,i),l=Au(a,i);s.rank===1&&F(s.shape[0]===r.shape[0],()=>"The first dimension of `a` must match the size of `condition`."),s.rank!==1&&nn(s.shape,l.shape,"Error in where: ");let u={condition:s,t:o,e:l};return M.runKernel(vo,u)}var xn=O({where_:_N});function bN(e){let t={x:R(e,"x","zerosLike")};return M.runKernel(Mo,t)}var je=O({zerosLike_:bN});function vN(e,t){let n=R(e,"a","div"),r=R(t,"b","div");[n,r]=vt(n,r);let a=ve(n,r),s=je(a),i=_a(r,s);return xn(i,s,a)}var Vf=O({divNoNan_:vN});function kN(e,t){let n=R(e,"t1","dot"),r=R(t,"t2","dot");F((n.rank===1||n.rank===2)&&(r.rank===1||r.rank===2),()=>`Error in dot: inputs must all be rank 1 or 2, but got ranks ${n.rank} and ${r.rank}.`);let a=n.rank===1?n.size:n.shape[1],s=r.rank===1?r.size:r.shape[0];if(F(a===s,()=>`Error in dot: inner dimensions of inputs must match, but got ${a} and ${s}.`),n.rank===1&&r.rank===1){let i=H(n,[1,-1]),o=H(r,[-1,1]),l=Ge(i,o);return H(l,[])}else if(n.rank===1&&r.rank===2){let i=H(n,[1,-1]),o=H(r,[r.shape[0],r.shape[1]]),l=Ge(i,o);return H(l,[l.size])}else if(n.rank===2&&r.rank===1){let i=H(r,[-1,1]),o=Ge(n,i);return H(o,[o.size])}else{let i=H(r,[r.shape[0],r.shape[1]]);return Ge(n,i)}}var Q2=O({dot_:kN});function IN(e){let t={x:R(e,"x","elu")};return M.runKernel(Xi,t)}var Bo=O({elu_:IN});function NN(e){let t=R(e,"x","erf");F(t.dtype==="int32"||t.dtype==="float32",()=>"Input dtype must be `int32` or `float32`."),t.dtype=
rank ${s.rank}.`),F(jt(t),()=>`Error in localResponseNormalization: depthRadius must be an integer but got depthRadius ${t}.`);let i=s,o=!1;s.rank===3&&(o=!0,i=H(s,[1,s.shape[0],s.shape[1],s.shape[2]]));let l={x:i},u={depthRadius:t,bias:n,alpha:r,beta:a},c=M.runKernel(eu,l,u);return o?H(c,[c.shape[1],c.shape[2],c.shape[3]]):c}var Gf=O({localResponseNormalization_:UN});function jN(e){let t={x:R(e,"x","log")};return M.runKernel(ds,t)}var Sn=O({log_:jN});function HN(e){let t={x:R(e,"x","log1p")};return M.runKernel(lo,t)}var Zh=O({log1p_:HN});function W4(e){return F(Sa(e),()=>"The f passed in grad(f) must be a function"),(t,n)=>{let r=R(t,"x","tf.grad","string_or_numeric"),a=n!=null?R(n,"dy","tf.grad"):null;return M.tidy(()=>{let{value:s,grads:i}=M.gradients(()=>e(r),[r],a);return a!=null&&nn(s.shape,a.shape,"The shape of dy passed in grad(f)(x, dy) must match the shape returned by f(x)"),$d(i),i[0]})}}function B4(e){return F(Sa(e),()=>"The f passed in grads(f) must be a function"),(t,n)=>{F(Array.isArray(t),()=>"The args passed in grads(f)(args) must be an array of `Tensor`s or `TensorLike`s");let r=Bu(t,"args","tf.grads","string_or_numeric"),a=n!=null?R(n,"dy","tf.grads"):null;return M.tidy(()=>{let{value:s,grads:i}=M.gradients(()=>e(...r),r,a);return a!=null&&nn(s.shape,a.shape,"The shape of dy passed in grads(f)([x1,...], dy) must match the shape returned by f([x1,...])"),$d(i),i})}}function V4(e){return F(Sa(e),()=>"The f passed in valueAndGrad(f) must be a function"),(t,n)=>{F(t instanceof Ye,()=>"The x passed in valueAndGrad(f)(x) must be a tensor"),F(n==null||n instanceof Ye,()=>"The dy passed in valueAndGrad(f)(x, dy) must be a tensor");let{grads:r,value:a}=M.gradients(()=>e(t),[t],n);return $d(r),{grad:r[0],value:a}}}function U4(e){return F(Sa(e),()=>"The f passed in valueAndGrads(f) must be a function"),(t,n)=>{F(Array.isArray(t)&&t.every(a=>a instanceof Ye),()=>"The args passed in valueAndGrads(f)(args) must be array of tensors"),F(n==null||n instanceof Ye,()=>"The dy passed in valueAndGrads(f)(args, dy) must be a tensor");let r=M.gradients(()=>e(...t),t,n);return n!=null&&nn(r.value.shape,n.shape,"The shape of dy passed in valueAndGrads(f)([x1,...], dy) must match the shape returned by f([x1,...])"),$d(r.grads),r}}function a0(e,t){F(Sa(e),()=>"The f passed in variableGrads(f) must be a function"),F(t==null||Array.isArray(t)&&t.every(u=>u instanceof uu),()=>"The varList passed in variableGrads(f, varList) must be an array of variables");let n=t!=null;if(!n){t=[];for(let u in M.registeredVariables)t.push(M.registeredVariables[u])}let r=n?t.filter(u=>!u.trainable):null,a=t.length;t=t.filter(u=>u.trainable),F(t.length>0,()=>`variableGrads() expects at least one of the input variables to be trainable, but none of the ${a} variables is trainable.`);let s=!0,{value:i,grads:o}=M.gradients(e,t,null,s);F(o.some(u=>u!=null),()=>"Cannot find a connection between any variable and the result of the loss function y=f(x). Please make sure the operations that use variables are inside the function f passed to minimize()."),F(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((u,c)=>{o[c]!=null&&(l[u.name]=o[c])}),r!=null&&r.forEach(u=>l[u.name]=null),{value:i,grads:l}}function Sr(e){return M.customGrad(e)}function $d(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 GN(e){let t={x:R(e,"x","neg")};return M.runKernel(ho,t)}var _t=O({neg_:GN});function qN(e){let t={x:R(e,"x","softplus")};return M.runKernel(To,t)}var Uo=O({softplus_:qN});function XN(e){let t=R(e,"x","logSigmoid");return Sr(n=>({value:_t(Uo(_t(n))),gradFunc:r=>W(r,Qn(_t(n)))}))(t)}var s0=O({logSigmoid_:XN});function KN(e,t=null,n=!1){let r={x:R(e,"x","max")},a={reductionIndices:t,keepDims:n};return M.runKernel(ps,r,a)}var Un=O({max_:KN});function ZN(e,t){let n=R(e,"a","sub"),r=R(t,"b","sub");[n,r]=vt(n,r);let a={a:n,b:r};return M.runKernel(Os,a)}var xe=O({sub_:ZN});function YN(e,t=null,n=!1){let r=R(e,"x","sum");r.dtype==="bool"&&(r=Ae(r,"int32"));let a={x:r},s={axis:t,keepDims:n};return M.runKernel($s,a,s)}var Ee=O({sum_:YN});function JN(e,t=-1){let n=R(e,"logits","logSoftmax");if(t===-1&&(t=n.rank-1),t!==n.rank-1)throw Error(`Log Softmax along a non-last dimension is not yet supported. Logits was rank ${n.rank} and axis was ${t}`);return Sr((r,a)=>{let s=!0,i=Un(r,t,!0),o=xe(r,i),l=xe(Ae(o,"float32"),Sn(Ee(Vn(o),t,s)));return a([l]),{value:l,gradFunc:(u,c)=>{let[h]=c,d=!0,p=Vn(h);return xe(u,W(Ee(u,t,d),p))}}})(n)}var Yh=O({logSoftmax_:JN});function qm(e,t){for(let n=0;n<e.length;++n)if(e[e.length-n-1]!==t-1-n)return!1;return!0}function V5(e,t,n){let r=e.length+t.length,a=[],s=0,i=0;for(let o=0;o<r;o++)n.indexOf(o)===-1?a.push(e[s++]):a.push(t[i++]);return a}function U5(e,t){let n=[],r=e.length;for(let s=0;s<r;s++)t.indexOf(s)===-1&&n.push(e[s]);let a=t.map(s=>e[s]);return[n,a]}function ei(e,t){let n=t.map(r=>1);return V5(e,n,t)}function QN(e,t,n){F(qm(t,n),()=>`${e} supports only inner-most axes for now. Got axes ${t} and rank-${n} input.`)}function j5(e,t){if(qm(e,t))return null;let n=[];for(let r=0;r<t;++r)e.indexOf(r)===-1&&n.push(r);return e.forEach(r=>n.push(r)),n}function Xm(e){return e.map((t,n)=>[n,t]).sort((t,n)=>t[1]-n[1]).map(t=>t[0])}function eS(e,t){let n=[];for(let r=t-e;r<t;++r)n.push(r);return n}function tS(e,t=null,n=!1){let r=R(e,"x","logSumExp"),a=ar(t,r.shape),s=Un(r,a,!0),i=xe(r,s),o=Vn(i),l=Ee(o,a),u=Sn(l),c=oe(H(s,u.shape),u);if(n){let h=ei(c.shape,a);return H(c,h)}return c}var qf=O({logSumExp_:tS});function nS(e,t){let n=R(e,"a","logicalAnd","bool"),r=R(t,"b","logicalAnd","bool");mt(n.shape,r.shape);let a={a:n,b:r};return M.runKernel(uo,a)}var tr=O({logicalAnd_:nS});function rS(e){let t={x:R(e,"x","logicalNot","bool")};return M.runKernel(Jl,t)}var wu=O({logicalNot_:rS});function aS(e,t){let n=R(e,"a","logicalOr","bool"),r=R(t,"b","logicalOr","bool");mt(n.shape,r.shape);let a={a:n,b:r};return M.runKernel(Ql,a)}var Jh=O({logicalOr_:aS});function sS(e,t){let n=R(e,"a","logicalXor","bool"),r=R(t,"b","logicalXor","bool");return mt(n.shape,r.shape),tr(Jh(e,t),wu(tr(e,t)))}var i0=O({logicalXor_:sS});function iS(e,t,n,r,a){let s=R(e,"x","maxPool"),i=1,o=s,l=!1;s.rank===3&&(l=!0,o=H(s,[1,s.shape[0],s.shape[1],s.shape[2]])),F(o.rank===4,()=>`Error in maxPool: input must be rank 4 but got rank ${o.rank}.`),F(Or(n,i),()=>`Error in maxPool: Either strides or dilations must be 1. Got strides ${n} and dilations '${i}'`),a!=null&&F(jt(r),()=>`Error in maxPool: pad must be an integer when using, dimRoundingMode ${a} but got pad ${r}.`);let u={x:o},c={filterSize:t,strides:n,pad:r,dimRoundingMode:a},h=M.runKernel(ms,u,c);return l?H(h,[h.shape[1],h.shape[2],h.shape[3]]):h}var _u=O({maxPool_:iS});function oS(e,t=[1,1,1],n,r,a,s="NDHWC"){let i=R(e,"x","maxPool3d"),o=i,l=!1;i.rank===4&&(l=!0,o=H(i,[1,i.shape[0],i.shape[1],i.shape[2],i.shape[3]])),F(o.rank===5,()=>`Error in maxPool3d: x must be rank 5 but got rank ${o.rank}.`),F(s==="NDHWC",()=>`Error in maxPool3d: Only NDHWC is currently supported, but got dataFormat of ${s}`),a!=null&&F(jt(r),()=>`Error in maxPool3d: pad must be an integer when using, dimRoundingMode ${a} but got pad ${r}.`);let u={x:o},c={filterSize:t,strides:n,pad:r,dimRoundingMode:a,dataFormat:s},h=M.runKernel(tu,u,c);return l?H(h,[h.shape[1],h.shape[2],h.shape[3],h.shape[4]]):h}var Xf=O({maxPool3d_:oS});function lS(e
${s}).`);if(n<r)throw new Error(`batchDims (${r}) must be less than or equal to axis (${n}).`);for(let h=0;h<r;++h)if(e.shape[h]!==t.shape[h])throw new Error(`x.shape[${h}]: ${e.shape[h]} should be equal to indices.shape[${h}]: ${t.shape[h]}.`);let i=e.shape[n],o=[],l=1,u=1,c=1;for(let h=0;h<r;++h)o.push(e.shape[h]),l*=e.shape[h];for(let h=r;h<n;h++)o.push(e.shape[h]),u*=e.shape[h];for(let h=r;h<a;h++)o.push(t.shape[h]);for(let h=n+1;h<s;h++)o.push(e.shape[h]),c*=e.shape[h];return{batchSize:l,sliceSize:c,outerSize:u,dimSize:i,outputShape:o}}function _C(e){try{return e.map(t=>Sd(t))}catch(t){throw new Error(`Failed to decode encoded string bytes into utf-8, error: ${t}`)}}function bC(e){return e.map(t=>Ou(t))}var Rr={};ze(Rr,{nonMaxSuppressionV3Impl:()=>Y5,nonMaxSuppressionV4Impl:()=>J5,nonMaxSuppressionV5Impl:()=>Q5,whereImpl:()=>H5});function be(e,t){Array.isArray(e)||(e=[e]),e.forEach(n=>{n!=null&&v.assert(n.dtype!=="complex64",()=>`${t} does not support complex64 tensors in the CPU backend.`)})}var NC=Rr.whereImpl,_d=class extends Ul{constructor(){super();this.blockSize=48,this.firstUse=!0,this.data=new ah(this,Nr())}nextDataId(){return _d.nextDataId++}write(e,t,n){this.firstUse&&(this.firstUse=!1,Y().get("IS_NODE")&&C.warn(`
2021-02-21 20:07:04 +01:00
============================
Hi there \u{1F44B}. Looks like you are running TensorFlow.js in Node.js. To speed things up dramatically, install our node backend, which binds to TensorFlow C++, by running npm i @tensorflow/tfjs-node, or npm i @tensorflow/tfjs-node-gpu if you have CUDA. Then call require('@tensorflow/tfjs-node'); (-gpu suffix for CUDA) at the start of your program. Visit https://github.com/tensorflow/tfjs-node for more details.
2021-02-25 13:50:13 +01:00
============================`));let r={id:this.nextDataId()};return this.data.set(r,{values:e,dtype:n,refCount:1}),r}makeTensorInfo(e,t,n){let r;if(t==="string"&&n!=null&&n.length>0&&v.isString(n[0])){let a=n.map(s=>v.encodeString(s));r=this.write(a,e,t)}else r=this.write(n,e,t);return{dataId:r,shape:e,dtype:t}}refCount(e){return this.data.has(e)?this.data.get(e).refCount:0}incRef(e){let t=this.data.get(e);t.refCount++}decRef(e){if(this.data.has(e)){let t=this.data.get(e);t.refCount--}}move(e,t,n,r,a){this.data.set(e,{values:t,dtype:r,refCount:a})}numDataIds(){return this.data.numDataIds()}async read(e){return this.readSync(e)}readSync(e){let{dtype:t,complexTensorInfos:n}=this.data.get(e);if(t==="complex64"){let r=this.readSync(n.real.dataId),a=this.readSync(n.imag.dataId);return C.mergeRealAndImagArrays(r,a)}return this.data.get(e).values}bufferSync(e){let t=this.readSync(e.dataId),n=t;if(e.dtype==="string")try{n=t.map(r=>v.decodeString(r))}catch(r){throw new Error("Failed to decode encoded string bytes into utf-8")}return We(e.shape,e.dtype,n)}makeOutput(e,t,n){let r=this.write(e,t,n);return Nr().makeTensorFromDataId(r,t,n,this)}disposeData(e,t=!1){if(this.data.has(e)){if(this.data.get(e).refCount--,!t&&this.data.get(e).refCount>0)return!1;let{complexTensorInfos:n}=this.data.get(e);n!=null&&(this.disposeData(n.real.dataId,!0),this.disposeData(n.imag.dataId,!0)),this.data.delete(e)}return!0}disposeIntermediateTensorInfo(e){this.disposeData(e.dataId)}async time(e){let t=v.now();return e(),{kernelMs:v.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){be([e],"where");let t=this.readSync(e.dataId);return NC(e.shape,t)}dispose(){}floatPrecision(){return 32}epsilon(){return super.epsilon()}};_d.nextDataId=0;var um={};ze(um,{addImpl:()=>lx,bincountImpl:()=>eA,bincountReduceImpl:()=>ux,ceilImpl:()=>cx,concatImpl:()=>tA,expImpl:()=>hx,expm1Impl:()=>dx,floorImpl:()=>px,gatherV2Impl:()=>fx,greaterImpl:()=>mx,lessImpl:()=>Ax,linSpaceImpl:()=>yx,logImpl:()=>gx,maxImpl:()=>xx,maximumImpl:()=>wx,minimumImpl:()=>_x,multiplyImpl:()=>nA,negImpl:()=>bx,notEqualImpl:()=>vx,prodImpl:()=>kx,rangeImpl:()=>aA,rsqrtImpl:()=>Ix,simpleAbsImpl:()=>ox,sliceImpl:()=>Ld,squaredDifferenceImpl:()=>Nx,stridedSliceImpl:()=>Sx,subImpl:()=>Tx,tileImpl:()=>Ex,topKImpl:()=>Cx,transposeImpl:()=>rA,uniqueImpl:()=>Rx});function ox(e){let t=new Float32Array(e.length);for(let n=0;n<e.length;++n)t[n]=Math.abs(e[n]);return t}var SC=e=>{let{x:t}=e.inputs,n=e.backend;be(t,"abs");let r=new Float32Array(v.sizeFromShape(t.shape)),a=n.data.get(t.dataId).values;return r=ox(a),n.makeOutput(r,t.shape,"float32")},TC={kernelName:Oi,backendName:"cpu",kernelFunc:SC};function Rt(e){return(t,n,r,a,s)=>{let i=C.assertAndGetBroadcastShape(t,n),o=i.length,l=v.computeStrides(i),u=v.sizeFromShape(i),c=v.getTypedArrayFromDType(s,u),h=t.length,d=n.length,p=v.computeStrides(t),f=v.computeStrides(n),m=C.getBroadcastDims(t,i),A=C.getBroadcastDims(n,i);if(m.length+A.length===0)for(let y=0;y<c.length;++y)c[y]=e(r[y%r.length],a[y%a.length]);else for(let y=0;y<c.length;++y){let g=v.indexToLoc(y,o,l),w=g.slice(-h);m.forEach(N=>w[N]=0);let _=v.locToIndex(w,h,p),b=g.slice(-d);A.forEach(N=>b[N]=0);let x=v.locToIndex(b,d,f);c[y]=e(r[_],a[x])}return[c,i]}}function Rn(e){let{inputs:t,backend:n}=e,{real:r,imag:a}=t,s=n.data.get(r.dataId).values,i=n.data.get(a.dataId).values,o=n.makeTensorInfo(r.shape,"complex64"),l=n.data.get(o.dataId);return l.complexTensorInfos={real:n.makeTensorInfo(r.shape,"float32",s),imag:n.makeTensorInfo(a.shape,"float32",i)},o}var EC={kernelName:ch,backendName:"cpu",kernelFunc:Rn};function Pd(e,t,n="float32"){if(n==="complex64"){let a=Pd(e,t,"float32"),s=Pd(e,t,"float32");return Rn({inputs:{real:a,imag:s},backend:e})}let r=v.makeZerosTypedArray(v.sizeFromShape(t),n);return e.makeTensorInfo(t,n,r)}function zr(e){let{inputs:t,backend:n}=e,{x:r}=t;return n.incRef(r.dataId),{dataId:r.dataId,shape:r.shape,dtype:r.dtype}}var CC={kernelName:cs,backendName:"cp
`),s=a.length.toString().length+2,i=a.map((h,d)=>v.rightPad((d+1).toString(),s)+h),o=0;for(let h=0;h<i.length;h++)o=Math.max(i[h].length,o);let l=i.slice(0,r-1),u=i.slice(r-1,r),c=i.slice(r);console.log(l.join(`
2021-02-21 20:07:04 +01:00
`)),console.log(t.split(`
2021-02-25 13:50:13 +01:00
`)[0]),console.log(`%c ${v.rightPad(u[0],o)}`,"border:1px solid red; background-color:#e3d2d2; color:#a61717"),console.log(c.join(`
`))}function nw(e){return ra(e,()=>e.createProgram(),"Unable to create WebGLProgram.")}function rw(e,t){if(we(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 Ud(e,t){if(we(e,()=>e.validateProgram(t)),e.getProgramParameter(t,e.VALIDATE_STATUS)===!1)throw console.log(e.getProgramInfoLog(t)),new Error("Shader program validation failed.")}function aw(e,t){let n=ra(e,()=>e.createBuffer(),"Unable to create WebGLBuffer");return we(e,()=>e.bindBuffer(e.ARRAY_BUFFER,n)),we(e,()=>e.bufferData(e.ARRAY_BUFFER,t,e.STATIC_DRAW)),n}function sw(e,t){let n=ra(e,()=>e.createBuffer(),"Unable to create WebGLBuffer");return we(e,()=>e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,n)),we(e,()=>e.bufferData(e.ELEMENT_ARRAY_BUFFER,t,e.STATIC_DRAW)),n}function rO(){return Y().getNumber("WEBGL_VERSION")===2?1:4}function iw(e){return ra(e,()=>e.createTexture(),"Unable to create WebGLTexture.")}function ow(e,t){let n=Y().getNumber("WEBGL_MAX_TEXTURE_SIZE");if(e<=0||t<=0){let r=`[${e}x${t}]`;throw new Error("Requested texture size "+r+" is invalid.")}if(e>n||t>n){let r=`[${e}x${t}]`,a=`[${n}x${n}]`;throw new Error("Requested texture size "+r+" greater than WebGL maximum on this browser / GPU "+a+".")}}function lw(e){return ra(e,()=>e.createFramebuffer(),"Unable to create WebGLFramebuffer.")}function fA(e,t,n,r,a,s,i){let o=e.getAttribLocation(t,n);return o===-1?!1:(we(e,()=>e.bindBuffer(e.ARRAY_BUFFER,r)),we(e,()=>e.vertexAttribPointer(o,a,e.FLOAT,!1,s,i)),we(e,()=>e.enableVertexAttribArray(o)),!0)}function uw(e,t,n){_w(e,n),we(e,()=>e.activeTexture(e.TEXTURE0+n)),we(e,()=>e.bindTexture(e.TEXTURE_2D,t))}function aO(e,t){_w(e,t),we(e,()=>e.activeTexture(e.TEXTURE0+t)),we(e,()=>e.bindTexture(e.TEXTURE_2D,null))}function cw(e,t,n){return ra(e,()=>e.getUniformLocation(t,n),'uniform "'+n+'" not present in program.')}function hw(e,t,n){return e.getUniformLocation(t,n)}function dw(e,t,n,r){we(e,()=>uw(e,t,r)),we(e,()=>e.uniform1i(n,r))}function sO(e){we(e,()=>e.bindFramebuffer(e.FRAMEBUFFER,null)),we(e,()=>e.viewport(0,0,e.canvas.width,e.canvas.height)),we(e,()=>e.scissor(0,0,e.canvas.width,e.canvas.height))}function jd(e,t,n){we(e,()=>e.bindFramebuffer(e.FRAMEBUFFER,n)),we(e,()=>e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,t,0))}function mA(e,t){we(e,()=>e.bindFramebuffer(e.FRAMEBUFFER,t)),we(e,()=>e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,null,0))}function Gu(e){let t=e.checkFramebufferStatus(e.FRAMEBUFFER);if(t!==e.FRAMEBUFFER_COMPLETE)throw new Error("Error binding framebuffer: "+pw(e,t))}function pw(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 ra(e,t,n){let r=we(e,()=>t());if(r==null)throw new Error(n);return r}function _w(e,t){let n=e.MAX_COMBINED_TEXTURE_IMAGE_UNITS-1,r=t+e.TEXTURE0;if(r<e.TEXTURE0||r>n){let a=`[gl.TEXTURE0, gl.TEXTURE${n}]`;throw new Error(`textureUnit must be in ${a}.`)}}function ai(e,t=2){return v.sizeFromShape(e.slice(0,e.length-t))}function si(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 Hd(e){let t=[1,1,1];return e.length===0||e.length===1&&e[0]===1||(t=[ai(e),...si(e)]),t}function fw(e,t=!1){let n=Y().getNumber("WEBGL_MAX_TEXTURE_SIZE");t&&(n=n*2,e=e.map((a,s)=>s>=e.length-2?v.nearestLargerEven(e[s]):e[s]),e.length===1&&(e=[2,e[0]])),e.length!==2&&(e=v.squeezeShape(e).newShape);let r=v.sizeFromShape(e);if(e.length<=1&&r<=n)return[1,r];if(e.length===2&&e[0]<=n&&e[1]<=n)return e;if(e.length===3&&e[0]*e[1]<=n&&e[2]<=n)return[e[0]*e[1],e[2]];if(e.length===3&&e[0]<=n&&e[1]*e[2]<=n)return[e[0],e[1]*e[2]];if(e.length===4&&e[0]*e[1]
2021-02-21 20:07:04 +01:00
bool isnan_custom(float val) {
return (val > 0.0 || val < 0.0) ? false : val != 0.0;
2020-11-16 21:51:46 +01:00
}
2021-02-21 20:07:04 +01:00
bvec4 isnan_custom(vec4 val) {
return bvec4(isnan_custom(val.x),
isnan_custom(val.y), isnan_custom(val.z), isnan_custom(val.w));
2020-11-16 21:51:46 +01:00
}
2021-02-21 20:07:04 +01:00
#define isnan(value) isnan_custom(value)
2021-02-25 13:50:13 +01:00
`,l="",u=`
2021-02-21 20:07:04 +01:00
#define round(value) newRound(value)
int newRound(float value) {
return int(floor(value + 0.5));
2020-11-16 21:51:46 +01:00
}
2021-02-21 20:07:04 +01:00
ivec4 newRound(vec4 value) {
return ivec4(floor(value + vec4(0.5)));
2020-11-16 21:51:46 +01:00
}
2021-02-21 20:07:04 +01:00
`):(e="",t="attribute",n="varying",r="varying",a="texture2D",s="gl_FragColor",i="",o=`
#define isnan(value) isnan_custom(value)
bool isnan_custom(float val) {
return (val > 0. || val < 1. || val == 0.) ? false : true;
2020-11-16 21:51:46 +01:00
}
2021-02-21 20:07:04 +01:00
bvec4 isnan_custom(vec4 val) {
return bvec4(isnan(val.x), isnan(val.y), isnan(val.z), isnan(val.w));
2020-11-16 21:51:46 +01:00
}
2021-02-21 20:07:04 +01:00
`,l=`
uniform float INFINITY;
bool isinf(float val) {
return abs(val) == INFINITY;
2020-11-16 21:51:46 +01:00
}
2021-02-21 20:07:04 +01:00
bvec4 isinf(vec4 val) {
return equal(abs(val), vec4(INFINITY));
2020-11-16 21:51:46 +01:00
}
2021-02-25 13:50:13 +01:00
`,u=`
2021-02-21 20:07:04 +01:00
int round(float value) {
return int(floor(value + 0.5));
2021-01-03 16:41:56 +01:00
}
2021-02-21 20:07:04 +01:00
ivec4 round(vec4 value) {
return ivec4(floor(value + vec4(0.5)));
2021-01-03 16:41:56 +01:00
}
2021-02-25 13:50:13 +01:00
`),{version:e,attribute:t,varyingVs:n,varyingFs:r,texture2D:a,output:s,defineOutput:i,defineSpecialNaN:o,defineSpecialInf:l,defineRound:u}}function oi(e,t,n="index"){let r=v.computeStrides(t);return r.map((a,s)=>{let i=`int ${e[s]} = ${n} / ${a}`,o=s===r.length-1?`int ${e[s+1]} = ${n} - ${e[s]} * ${a}`:`index -= ${e[s]} * ${a}`;return`${i}; ${o};`}).join("")}function wA(e){let t=v.computeStrides(e).map(n=>n.toString());return`
2021-02-21 20:07:04 +01:00
int getFlatIndex(ivec3 coords) {
return coords.x * ${t[0]} + coords.y * ${t[1]} + coords.z;
}
2021-02-25 13:50:13 +01:00
`}var bw=`
2021-02-21 20:07:04 +01:00
const float FLOAT_MAX = 1.70141184e38;
const float FLOAT_MIN = 1.17549435e-38;
lowp vec4 encode_float(highp float v) {
if (isnan(v)) {
return vec4(255, 255, 255, 255);
2021-02-21 20:06:13 +01:00
}
2021-02-21 20:07:04 +01:00
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;
2021-02-21 20:06:13 +01:00
}
2021-02-21 20:07:04 +01:00
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-02-25 13:50:13 +01:00
`,gO=class{constructor(e){this.variableNames=["A"],this.packedInputs=!1,this.packedOutput=!0,this.outPackingScheme=Xu.DENSE;let t=Zu(e),n=un();this.outputShape=e,this.userCode=`
2021-02-21 20:07:04 +01:00
ivec3 outCoordsFromFlatIndex(int index) {
2021-02-25 13:50:13 +01:00
${oi(["r","c","d"],e)}
2021-02-21 20:07:04 +01:00
return ivec3(r, c, d);
2021-01-03 16:41:56 +01:00
}
2021-02-21 20:07:04 +01:00
void main() {
ivec2 resTexRC = ivec2(resultUV.yx *
vec2(${t[0]}, ${t[1]}));
int index = 4 * (resTexRC.x * ${t[1]} + resTexRC.y);
vec4 result = vec4(0.);
for (int i=0; i<4; i++) {
int flatIndex = index + i;
ivec3 rc = outCoordsFromFlatIndex(flatIndex);
result[i] = getA(rc.x, rc.y, rc.z);
2021-02-21 20:06:13 +01:00
}
2021-02-21 20:07:04 +01:00
${n.output} = result;
}
2021-02-25 13:50:13 +01:00
`}},xO=class{constructor(e){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outPackingScheme=Xu.DENSE;let t=Zu(e),n=un();this.outputShape=e,this.userCode=`
2021-02-21 20:07:04 +01:00
ivec3 outCoordsFromFlatIndex(int index) {
2021-02-25 13:50:13 +01:00
${oi(["r","c","d"],e)}
2021-02-21 20:07:04 +01:00
return ivec3(r, c, d);
}
void main() {
ivec2 resTexRC = ivec2(resultUV.yx *
vec2(${t[0]}, ${t[1]}));
int index = 4 * (resTexRC.x * ${t[1]} + resTexRC.y);
vec4 result = vec4(0.);
for (int i=0; i<4; i++) {
int flatIndex = index + i;
ivec3 rc = outCoordsFromFlatIndex(flatIndex);
result[i] = getChannel(getA(rc.x, rc.y, rc.z), vec2(rc.y, rc.z));
2021-01-03 16:41:56 +01:00
}
2021-02-21 20:07:04 +01:00
${n.output} = result;
2021-01-03 16:41:56 +01:00
}
2021-02-25 13:50:13 +01:00
`}},wO=class{constructor(e){this.variableNames=["A"],this.outTexUsage=Gn.DOWNLOAD;let t=un();this.outputShape=e,this.userCode=`
${bw}
2021-02-21 20:07:04 +01:00
void main() {
float x = getAAtOutCoords();
${t.output} = encode_float(x);
2021-01-03 16:41:56 +01:00
}
2021-02-25 13:50:13 +01:00
`}},_O=class{constructor(e){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!1,this.outTexUsage=Gn.DOWNLOAD;let t=un();this.outputShape=e,this.userCode=`
${bw}
2021-02-21 20:07:04 +01:00
void main() {
ivec3 coords = getOutputCoords();
float x = getChannel(getAAtOutCoords(), vec2(coords.y, coords.z));
${t.output} = encode_float(x);
}
2021-02-25 13:50:13 +01:00
`}},bO=class{constructor(e,t,n=!1){this.variableNames=["A"];let r=un(),[a,s]=t;this.outputShape=e;let i="result";n&&(i="floor(result * 255. + 0.5)"),this.userCode=`
${wA(e)}
2021-02-21 20:07:04 +01:00
void main() {
ivec3 coords = getOutputCoords();
int flatIndex = getFlatIndex(coords);
int offset = imod(flatIndex, 4);
flatIndex = idiv(flatIndex, 4, 1.);
int r = flatIndex / ${s};
int c = imod(flatIndex, ${s});
vec2 uv = (vec2(c, r) + halfCR) / vec2(${s}.0, ${a}.0);
vec4 values = ${r.texture2D}(A, uv);
float result;
if(offset == 0) {
result = values[0];
} else if(offset == 1) {
result = values[1];
} else if(offset == 2) {
result = values[2];
2021-01-03 16:41:56 +01:00
} else {
2021-02-21 20:07:04 +01:00
result = values[3];
2021-01-03 16:41:56 +01:00
}
2021-02-21 20:07:04 +01:00
${r.output} = vec4(${i}, 0., 0., 0.);
}
2021-02-25 13:50:13 +01:00
`}},vO=class{constructor(e,t,n=!1){this.variableNames=["A"],this.packedInputs=!1,this.packedOutput=!0;let r=un(),[a,s]=t;this.outputShape=e;let i="",o="result";n&&(o="floor(result * 255. + 0.5)");for(let l=0;l<=1;l++)for(let u=0;u<=1;u++){let c=l*2+u;i+=`
2021-02-21 20:07:04 +01:00
localCoords = coords;
2021-02-25 13:50:13 +01:00
if(localCoords[2] + ${u} < ${e[2]}) {
localCoords[2] += ${u};
2021-02-21 20:07:04 +01:00
if(localCoords[1] + ${l} < ${e[1]}) {
localCoords[1] += ${l};
flatIndex = getFlatIndex(localCoords);
offset = imod(flatIndex, 4);
flatIndex = idiv(flatIndex, 4, 1.);
r = flatIndex / ${s};
c = imod(flatIndex, ${s});
uv = (vec2(c, r) + halfCR) / vec2(${s}.0, ${a}.0);
values = ${r.texture2D}(A, uv);
if(offset == 0) {
2021-02-25 13:50:13 +01:00
result[${c}] = values[0];
2021-02-21 20:07:04 +01:00
} else if(offset == 1) {
2021-02-25 13:50:13 +01:00
result[${c}] = values[1];
2021-02-21 20:07:04 +01:00
} else if(offset == 2) {
2021-02-25 13:50:13 +01:00
result[${c}] = values[2];
2021-02-21 20:07:04 +01:00
} else {
2021-02-25 13:50:13 +01:00
result[${c}] = values[3];
2021-02-21 20:07:04 +01:00
}
}
2021-01-03 16:41:56 +01:00
}
2021-02-21 20:07:04 +01:00
`}this.userCode=`
2021-02-25 13:50:13 +01:00
${wA(e)}
2021-02-21 20:07:04 +01:00
void main() {
ivec3 coords = getOutputCoords();
vec4 result = vec4(0.);
int flatIndex, r, c, offset;
ivec3 localCoords;
vec2 uv;
vec4 values;
${i}
${r.output} = ${o};
2021-01-03 16:41:56 +01:00
}
2021-02-25 13:50:13 +01:00
`}},w0={};ze(w0,{bindVertexProgramAttributeStreams:()=>Rw,createBufferFromOutputTexture:()=>Mw,createFloat16MatrixTexture:()=>Sw,createFloat16PackedMatrixTexture:()=>Cw,createFloat32MatrixTexture:()=>Nw,createIndexBuffer:()=>Iw,createPackedMatrixTexture:()=>Ew,createUnsignedBytesMatrixTexture:()=>Tw,createVertexBuffer:()=>kw,createVertexShader:()=>vw,downloadByteEncodedFloatMatrixFromOutputTexture:()=>Ow,downloadFloat32MatrixFromBuffer:()=>Dw,downloadMatrixFromPackedOutputTexture:()=>Lw,downloadPackedMatrixFromBuffer:()=>zw,getInternalFormatForFloat16MatrixTexture:()=>bA,getInternalFormatForFloat16PackedMatrixTexture:()=>IA,getInternalFormatForFloat32MatrixTexture:()=>_A,getInternalFormatForPackedMatrixTexture:()=>kA,getInternalFormatForUnsignedBytesMatrixTexture:()=>vA,uploadDenseMatrixToTexture:()=>Fw,uploadPixelDataToTexture:()=>$w});function vw(e){let t=un(),n=`${t.version}
2021-02-21 20:07:04 +01: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-02-25 13:50:13 +01:00
}`;return ew(e,n)}function kw(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 aw(e,t)}function Iw(e){let t=new Uint16Array([0,1,2,2,1,3]);return sw(e,t)}function Yu(e,t,n,r,a,s){ow(t,n);let i=iw(e),o=e.TEXTURE_2D;return we(e,()=>e.bindTexture(o,i)),we(e,()=>e.texParameteri(o,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE)),we(e,()=>e.texParameteri(o,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE)),we(e,()=>e.texParameteri(o,e.TEXTURE_MIN_FILTER,e.NEAREST)),we(e,()=>e.texParameteri(o,e.TEXTURE_MAG_FILTER,e.NEAREST)),we(e,()=>e.texImage2D(o,0,r,t,n,0,a,s,null)),we(e,()=>e.bindTexture(e.TEXTURE_2D,null)),i}function _A(e){return e.internalFormatFloat}function Nw(e,t,n,r){let[a,s]=Ku(t,n);return Yu(e,a,s,_A(r),r.textureFormatFloat,e.FLOAT)}function bA(e){return e.internalFormatHalfFloat}function Sw(e,t,n,r){let[a,s]=Ku(t,n);return Yu(e,a,s,bA(r),r.textureFormatFloat,r.textureTypeHalfFloat)}function vA(e){return e.downloadTextureFormat}function Tw(e,t,n,r){let[a,s]=Ku(t,n);return Yu(e,a,s,vA(r),e.RGBA,e.UNSIGNED_BYTE)}function kA(e){return e.internalFormatPackedFloat}function Ew(e,t,n,r){let[a,s]=dl(t,n);return Yu(e,a,s,kA(r),e.RGBA,e.FLOAT)}function IA(e){return e.internalFormatPackedHalfFloat}function Cw(e,t,n,r){let[a,s]=dl(t,n);return Yu(e,a,s,IA(r),e.RGBA,r.textureTypeHalfFloat)}function Rw(e,t,n){let r=0,a=3*4,s=3*4+2*4;return we(e,()=>e.bindBuffer(e.ARRAY_BUFFER,n)),fA(e,t,"clipSpacePos",n,3,s,r)&&fA(e,t,"uv",n,2,s,a)}function Fw(e,t,n,r,a,s){we(e,()=>e.bindTexture(e.TEXTURE_2D,t));let i,o,l;a instanceof Uint8Array?(i=new Uint8Array(n*r*4),o=e.UNSIGNED_BYTE,l=e.RGBA):(i=new Float32Array(n*r*4),o=e.FLOAT,l=s.internalFormatPackedFloat),i.set(a),we(e,()=>e.texImage2D(e.TEXTURE_2D,0,l,n,r,0,e.RGBA,o,i)),we(e,()=>e.bindTexture(e.TEXTURE_2D,null))}function $w(e,t,n){we(e,()=>e.bindTexture(e.TEXTURE_2D,t)),n.data instanceof Uint8Array?we(e,()=>e.texImage2D(e.TEXTURE_2D,0,e.RGBA,n.width,n.height,0,e.RGBA,e.UNSIGNED_BYTE,n.data)):we(e,()=>e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,n)),we(e,()=>e.bindTexture(e.TEXTURE_2D,null))}function Mw(e,t,n,r){let a=e.createBuffer();we(e,()=>e.bindBuffer(e.PIXEL_PACK_BUFFER,a));let s=4*4*t*n;return we(e,()=>e.bufferData(e.PIXEL_PACK_BUFFER,s,e.STREAM_READ)),we(e,()=>e.readPixels(0,0,n,t,e.RGBA,e.FLOAT,0)),we(e,()=>e.bindBuffer(e.PIXEL_PACK_BUFFER,null)),a}function Dw(e,t,n){let r=e,a=new Float32Array(n);return r.bindBuffer(r.PIXEL_PACK_BUFFER,t),r.getBufferSubData(r.PIXEL_PACK_BUFFER,0,a),r.bindBuffer(r.PIXEL_PACK_BUFFER,null),a}function Ow(e,t,n,r){let[a,s]=Ku(t,n),i=4,o=new Uint8Array(cO(t*n,i));return we(e,()=>e.readPixels(0,0,a,s,r.downloadTextureFormat,e.UNSIGNED_BYTE,o)),new Float32Array(o.buffer)}function zw(e,t,n,r,a,s,i,o){let l=e,u=new Float32Array(hO(s,i));return l.bindBuffer(l.PIXEL_PACK_BUFFER,t),l.getBufferSubData(l.PIXEL_PACK_BUFFER,0,u),l.bindBuffer(l.PIXEL_PACK_BUFFER,null),u}function Lw(e,t,n){let r=new Float32Array(t*n*4);return we(e,()=>e.readPixels(0,0,n,t,e.RGBA,e.FLOAT,r)),r}var hm=class{constructor(e){this.outputTexture=null,this.program=null,this.disposed=!1,this.vertexAttrsAreBound=!1,this.itemsToPoll=[];let t=Y().getNumber("WEBGL_VERSION");e!=null?(this.gl=e,cm(t,e)):this.gl=Lr(t);let n="WEBGL_color_buffer_float",r="EXT_color_buffer_half_float";if(Y().getNumber("WEBGL_VERSION")===1){let a="OES_texture_float",s="OES_texture_half_float";if(this.textureFloatExtension=Hu(this.gl,a),Hn(this.gl,s))this.textureHalfFloatExtension=Hu(this.gl,s);else if(Y().get("WEBGL_FORCE_F16_TEXTURES"))throw new Error("GL context does not support half float textures, yet the environment flag WEBGL_FORCE_F16_TEXTURES is set to true.");if(this.colorBufferFloatExtension=this.gl.getExtension(n),Hn(this.gl,r))this.colorBufferHalfFloatExtension=Hu(this.gl,r);else if(Y().get("WEBGL_FORCE_F16_TEXTURES"))throw new Error("GL context does not support color renderable half floats, yet the environment flag WEBGL_FORCE_F16_TEXTURES is set to true.")}else if(n="EXT_color_buffer_float",Hn(this.gl,n))this.colorBufferFloatExtension=this.gl.getExtension(n);else if(Hn(this.gl,r))this.
`),i=e.map(p=>IO(p,t,r)).join(`
`),o=t.texShape,l=un(),u=TO(l),c,h,d=RO(l);return t.isPacked?(c=NO(t.logicalShape,o),h=CO(l)):(c=SO(t.logicalShape,o),h=EO(l)),r&&(d+=FO),[d,u,h,s,c,i,n].join(`
`)}function pl(e){let t=e.shapeInfo.logicalShape;switch(t.length){case 0:return MO(e);case 1:return DO(e);case 2:return OO(e);case 3:return zO(e);case 4:return LO(e);case 5:return PO(e);case 6:return WO(e);default:throw new Error(`${t.length}-D input sampling is not yet supported`)}}function Ww(e){switch(e.shapeInfo.logicalShape.length){case 0:return BO(e);case 1:return VO(e);case 2:return UO(e);case 3:return jO(e);default:return HO(e)}}function IO(e,t,n=!1){let r="";n?r+=Ww(e):r+=pl(e);let a=e.shapeInfo.logicalShape,s=t.logicalShape;return a.length<=s.length&&(n?r+=GO(e,t):r+=qO(e,t)),r}function NO(e,t){switch(e.length){case 0:return Bw();case 1:return XO(e,t);case 2:return YO(e,t);case 3:return KO(e,t);default:return ZO(e,t)}}function SO(e,t){switch(e.length){case 0:return Bw();case 1:return JO(e,t);case 2:return rz(e,t);case 3:return QO(e,t);case 4:return ez(e,t);case 5:return tz(e,t);case 6:return nz(e,t);default:throw new Error(`${e.length}-D output sampling is not yet supported`)}}function TO(e){return`
2021-02-21 20:07:04 +01:00
float sampleTexture(sampler2D textureSampler, vec2 uv) {
return ${e.texture2D}(textureSampler, uv).r;
2020-11-08 18:32:31 +01:00
}
2021-02-25 13:50:13 +01:00
`}function EO(e){return`
2021-02-21 20:07:04 +01:00
void setOutput(float val) {
${e.output} = vec4(val, 0, 0, 0);
2020-11-07 17:34:56 +01:00
}
2021-02-25 13:50:13 +01:00
`}function CO(e){return`
2021-02-21 20:07:04 +01:00
void setOutput(vec4 val) {
${e.output} = val;
2020-11-12 18:17:57 +01:00
}
2021-02-25 13:50:13 +01:00
`}function RO(e){return`${e.version}
2021-02-21 20:07:04 +01:00
precision highp float;
precision highp int;
precision highp sampler2D;
${e.varyingFs} vec2 resultUV;
${e.defineOutput}
const vec2 halfCR = vec2(0.5, 0.5);
struct ivec5
{
int x;
int y;
int z;
int w;
int u;
};
struct ivec6
{
int x;
int y;
int z;
int w;
int u;
int v;
};
uniform float NAN;
${e.defineSpecialNaN}
${e.defineSpecialInf}
${e.defineRound}
int imod(int x, int y) {
return x - y * (x / y);
2020-11-12 18:17:57 +01:00
}
2021-02-21 20:07:04 +01: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;
2020-11-12 18:58:55 +01:00
}
2021-02-21 20:07:04 +01:00
return res;
2020-11-12 18:58:55 +01:00
}
2021-02-21 20:07:04 +01:00
//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);
2020-11-12 18:58:55 +01:00
}
2021-02-21 20:07:04 +01:00
2021-02-25 13:50:13 +01:00
${az}
${sz}
${iz}
`}var az=`
2021-02-21 20:07:04 +01: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-02-25 13:50:13 +01:00
`,sz=`
2021-02-21 20:07:04 +01: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-02-25 13:50:13 +01:00
`,iz=`
2021-02-21 20:07:04 +01: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-02-25 13:50:13 +01:00
`,FO=`
2021-02-21 20:07:04 +01: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-02-25 13:50:13 +01:00
`;function Bw(){return`
2021-02-21 20:07:04 +01:00
int getOutputCoords() {
return 0;
2021-02-21 20:06:13 +01:00
}
2021-02-25 13:50:13 +01:00
`}function XO(e,t){let n=[Math.ceil(t[0]/2),Math.ceil(t[1]/2)];return n[0]===1?`
2021-02-21 20:07:04 +01:00
int getOutputCoords() {
return 2 * int(resultUV.x * ${n[1]}.0);
2021-02-21 20:06:13 +01:00
}
2021-02-21 20:07:04 +01:00
`:n[1]===1?`
int getOutputCoords() {
return 2 * int(resultUV.y * ${n[0]}.0);
2021-02-21 20:06:13 +01:00
}
2021-02-21 20:07:04 +01:00
`:`
int getOutputCoords() {
ivec2 resTexRC = ivec2(resultUV.yx *
vec2(${n[0]}, ${n[1]}));
return 2 * (resTexRC.x * ${n[1]} + resTexRC.y);
2020-11-12 18:58:55 +01:00
}
2021-02-25 13:50:13 +01:00
`}function JO(e,t){return t[0]===1?`
2021-02-21 20:07:04 +01:00
int getOutputCoords() {
return int(resultUV.x * ${t[1]}.0);
2021-02-21 20:06:13 +01:00
}
2021-02-21 20:07:04 +01:00
`:t[1]===1?`
int getOutputCoords() {
return int(resultUV.y * ${t[0]}.0);
2021-02-21 20:06:13 +01:00
}
2021-02-21 20:07:04 +01:00
`:`
int getOutputCoords() {
ivec2 resTexRC = ivec2(resultUV.yx *
vec2(${t[0]}, ${t[1]}));
return resTexRC.x * ${t[1]} + resTexRC.y;
2020-11-10 02:13:38 +01:00
}
2021-02-25 13:50:13 +01:00
`}function KO(e,t){let n=[Math.ceil(t[0]/2),Math.ceil(t[1]/2)],r=Math.ceil(e[2]/2),a=r*Math.ceil(e[1]/2);return`
2021-02-21 20:07:04 +01:00
ivec3 getOutputCoords() {
ivec2 resTexRC = ivec2(resultUV.yx *
vec2(${n[0]}, ${n[1]}));
int index = resTexRC.x * ${n[1]} + resTexRC.y;
int b = index / ${a};
index -= b * ${a};
int r = 2 * (index / ${r});
int c = imod(index, ${r}) * 2;
return ivec3(b, r, c);
2020-11-16 21:51:46 +01:00
}
2021-02-25 13:50:13 +01:00
`}function QO(e,t){let n=oi(["r","c","d"],e);return`
2021-02-21 20:07:04 +01:00
ivec3 getOutputCoords() {
ivec2 resTexRC = ivec2(resultUV.yx *
vec2(${t[0]}, ${t[1]}));
int index = resTexRC.x * ${t[1]} + resTexRC.y;
${n}
return ivec3(r, c, d);
2020-11-16 21:51:46 +01:00
}
2021-02-25 13:50:13 +01:00
`}function ZO(e,t){let n=[Math.ceil(t[0]/2),Math.ceil(t[1]/2)],r=Math.ceil(e[e.length-1]/2),a=r*Math.ceil(e[e.length-2]/2),s=a,i="",o="b, r, c";for(let l=2;l<e.length-1;l++)s*=e[e.length-l-1],i=`
2021-02-21 20:07:04 +01:00
int b${l} = index / ${s};
index -= b${l} * ${s};
`+i,o=`b${l}, `+o;return`
ivec${e.length} getOutputCoords() {
ivec2 resTexRC = ivec2(resultUV.yx *
vec2(${n[0]}, ${n[1]}));
int index = resTexRC.x * ${n[1]} + resTexRC.y;
${i}
int b = index / ${a};
index -= b * ${a};
int r = 2 * (index / ${r});
int c = imod(index, ${r}) * 2;
return ivec${e.length}(${o});
2020-11-16 21:51:46 +01:00
}
2021-02-25 13:50:13 +01:00
`}function ez(e,t){let n=oi(["r","c","d","d2"],e);return`
2021-02-21 20:07:04 +01:00
ivec4 getOutputCoords() {
ivec2 resTexRC = ivec2(resultUV.yx *
vec2(${t[0]}, ${t[1]}));
int index = resTexRC.x * ${t[1]} + resTexRC.y;
${n}
return ivec4(r, c, d, d2);
2020-11-16 21:51:46 +01:00
}
2021-02-25 13:50:13 +01:00
`}function tz(e,t){let n=oi(["r","c","d","d2","d3"],e);return`
2021-02-21 20:07:04 +01: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;
2020-11-16 21:51:46 +01:00
}
2021-02-25 13:50:13 +01:00
`}function nz(e,t){let n=oi(["r","c","d","d2","d3","d4"],e);return`
2021-02-21 20:07:04 +01: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-02-21 20:06:13 +01:00
}
2021-02-25 13:50:13 +01:00
`}function YO(e,t){let n=[Math.ceil(t[0]/2),Math.ceil(t[1]/2)];if(v.arraysEqual(e,t))return`
2021-02-21 20:07:04 +01:00
ivec2 getOutputCoords() {
return 2 * ivec2(resultUV.yx * vec2(${n[0]}, ${n[1]}));
2020-11-12 18:58:55 +01:00
}
2021-02-21 20:07:04 +01:00
`;let r=Math.ceil(e[1]/2);return`
ivec2 getOutputCoords() {
ivec2 resTexRC = ivec2(resultUV.yx *
vec2(${n[0]}, ${n[1]}));
int index = resTexRC.x * ${n[1]} + resTexRC.y;
int r = 2 * (index / ${r});
int c = imod(index, ${r}) * 2;
return ivec2(r, c);
2020-11-16 21:51:46 +01:00
}
2021-02-25 13:50:13 +01:00
`}function rz(e,t){return v.arraysEqual(e,t)?`
2021-02-21 20:07:04 +01:00
ivec2 getOutputCoords() {
return ivec2(resultUV.yx * vec2(${t[0]}, ${t[1]}));
2020-11-12 18:58:55 +01:00
}
2021-02-21 20:07:04 +01:00
`:e[1]===1?`
ivec2 getOutputCoords() {
ivec2 resTexRC = ivec2(resultUV.yx *
vec2(${t[0]}, ${t[1]}));
int index = resTexRC.x * ${t[1]} + resTexRC.y;
return ivec2(index, 0);
2020-11-12 18:58:55 +01:00
}
2021-02-21 20:07:04 +01:00
`:e[0]===1?`
ivec2 getOutputCoords() {
ivec2 resTexRC = ivec2(resultUV.yx *
vec2(${t[0]}, ${t[1]}));
int index = resTexRC.x * ${t[1]} + resTexRC.y;
return ivec2(0, index);
2020-11-12 18:58:55 +01:00
}
2021-02-21 20:07:04 +01: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-02-21 20:06:13 +01:00
}
2021-02-25 13:50:13 +01:00
`}function li(e){return`offset${e}`}function BO(e){let t=e.name,n="get"+t.charAt(0).toUpperCase()+t.slice(1),r=un();return`
2021-02-21 20:07:04 +01:00
vec4 ${n}() {
return ${r.texture2D}(${t}, halfCR);
2021-02-21 20:06:13 +01:00
}
2021-02-25 13:50:13 +01:00
`}function MO(e){let t=e.name,n="get"+t.charAt(0).toUpperCase()+t.slice(1);if(e.shapeInfo.isUniform)return`float ${n}() {return ${t};}`;let[r,a]=e.shapeInfo.texShape;if(r===1&&a===1)return`
2021-02-21 20:07:04 +01:00
float ${n}() {
return sampleTexture(${t}, halfCR);
2020-11-12 18:58:55 +01:00
}
2021-02-25 13:50:13 +01:00
`;let[s,i]=e.shapeInfo.texShape,o=li(t);return`
2021-02-21 20:07:04 +01:00
float ${n}() {
vec2 uv = uvFromFlat(${s}, ${i}, ${o});
return sampleTexture(${t}, uv);
2021-02-21 20:06:13 +01:00
}
2021-02-25 13:50:13 +01:00
`}function VO(e){let t=e.name,n="get"+t.charAt(0).toUpperCase()+t.slice(1),r=e.shapeInfo.texShape,a=[Math.ceil(r[0]/2),Math.ceil(r[1]/2)],s=un();return`
2021-02-21 20:07:04 +01:00
vec4 ${n}(int index) {
vec2 uv = packedUVfrom1D(
${a[0]}, ${a[1]}, index);
return ${s.texture2D}(${t}, uv);
}
2021-02-25 13:50:13 +01:00
`}function DO(e){let t=e.name,n="get"+t.charAt(0).toUpperCase()+t.slice(1);if(e.shapeInfo.isUniform)return`
2021-02-21 20:07:04 +01:00
float ${n}(int index) {
2021-02-25 13:50:13 +01:00
${fl(e)}
2021-02-21 20:07:04 +01:00
}
`;let r=e.shapeInfo.texShape,a=r[0],s=r[1];if(s===1&&a===1)return`
float ${n}(int index) {
return sampleTexture(${t}, halfCR);
}
2021-02-25 13:50:13 +01:00
`;let i=li(t);return s===1?`
2021-02-21 20:07:04 +01:00
float ${n}(int index) {
vec2 uv = vec2(0.5, (float(index + ${i}) + 0.5) / ${a}.0);
return sampleTexture(${t}, uv);
}
`:a===1?`
float ${n}(int index) {
vec2 uv = vec2((float(index + ${i}) + 0.5) / ${s}.0, 0.5);
return sampleTexture(${t}, uv);
}
`:`
float ${n}(int index) {
vec2 uv = uvFromFlat(${a}, ${s}, index + ${i});
return sampleTexture(${t}, uv);
}
2021-02-25 13:50:13 +01:00
`}function UO(e){let t=e.shapeInfo.logicalShape,n=e.name,r="get"+n.charAt(0).toUpperCase()+n.slice(1),a=e.shapeInfo.texShape,s=a[0],i=a[1],o=un();if(a!=null&&v.arraysEqual(t,a))return`
2021-02-21 20:07:04 +01:00
vec4 ${r}(int row, int col) {
vec2 uv = (vec2(col, row) + halfCR) / vec2(${i}.0, ${s}.0);
return ${o.texture2D}(${n}, uv);
}
2021-02-25 13:50:13 +01:00
`;let l=[Math.ceil(a[0]/2),Math.ceil(a[1]/2)],u=Math.ceil(t[1]/2);return`
2021-02-21 20:07:04 +01:00
vec4 ${r}(int row, int col) {
2021-02-25 13:50:13 +01:00
vec2 uv = packedUVfrom2D(${u}, ${l[0]}, ${l[1]}, row, col);
2021-02-21 20:07:04 +01:00
return ${o.texture2D}(${n}, uv);
}
2021-02-25 13:50:13 +01:00
`}function OO(e){let t=e.shapeInfo.logicalShape,n=e.name,r="get"+n.charAt(0).toUpperCase()+n.slice(1),a=e.shapeInfo.texShape;if(a!=null&&v.arraysEqual(t,a)){let h=a[0],d=a[1];return`
2021-02-21 20:07:04 +01:00
float ${r}(int row, int col) {
vec2 uv = (vec2(col, row) + halfCR) / vec2(${d}.0, ${h}.0);
return sampleTexture(${n}, uv);
}
2021-02-25 13:50:13 +01:00
`}let{newShape:s,keptDims:i}=v.squeezeShape(t),o=s;if(o.length<t.length){let h=ml(e,o),d=["row","col"];return`
${pl(h)}
2021-02-21 20:07:04 +01:00
float ${r}(int row, int col) {
2021-02-25 13:50:13 +01:00
return ${r}(${Al(d,i)});
2021-02-21 20:07:04 +01:00
}
`}if(e.shapeInfo.isUniform)return`
float ${r}(int row, int col) {
int index = round(dot(vec2(row, col), vec2(${t[1]}, 1)));
2021-02-25 13:50:13 +01:00
${fl(e)}
2021-02-21 20:07:04 +01:00
}
2021-02-25 13:50:13 +01:00
`;let l=a[0],u=a[1],c=li(n);return u===1?`
2021-02-21 20:07:04 +01:00
float ${r}(int row, int col) {
2021-02-25 13:50:13 +01:00
float index = dot(vec3(row, col, ${c}), vec3(${t[1]}, 1, 1));
2021-02-21 20:07:04 +01:00
vec2 uv = vec2(0.5, (index + 0.5) / ${l}.0);
return sampleTexture(${n}, uv);
}
`:l===1?`
float ${r}(int row, int col) {
2021-02-25 13:50:13 +01:00
float index = dot(vec3(row, col, ${c}), vec3(${t[1]}, 1, 1));
vec2 uv = vec2((index + 0.5) / ${u}.0, 0.5);
2021-02-21 20:07:04 +01:00
return sampleTexture(${n}, uv);
}
`:`
float ${r}(int row, int col) {
// Explicitly use integer operations as dot() only works on floats.
2021-02-25 13:50:13 +01:00
int index = row * ${t[1]} + col + ${c};
vec2 uv = uvFromFlat(${l}, ${u}, index);
2021-02-21 20:07:04 +01:00
return sampleTexture(${n}, uv);
}
2021-02-25 13:50:13 +01:00
`}function jO(e){let t=e.shapeInfo.logicalShape,n=e.name,r="get"+n.charAt(0).toUpperCase()+n.slice(1),a=e.shapeInfo.texShape,s=[Math.ceil(a[0]/2),Math.ceil(a[1]/2)];if(t[0]===1){let h=t.slice(1),d=[1,2],p=ml(e,h),f=["b","row","col"];return`
${Ww(p)}
2021-02-21 20:07:04 +01:00
vec4 ${r}(int b, int row, int col) {
2021-02-25 13:50:13 +01:00
return ${r}(${Al(f,d)});
2021-02-21 20:06:13 +01:00
}
2021-02-25 13:50:13 +01:00
`}let i=s[0],o=s[1],l=Math.ceil(t[2]/2),u=l*Math.ceil(t[1]/2),c=un();return`
2021-02-21 20:07:04 +01:00
vec4 ${r}(int b, int row, int col) {
vec2 uv = packedUVfrom3D(
2021-02-25 13:50:13 +01:00
${i}, ${o}, ${u}, ${l}, b, row, col);
return ${c.texture2D}(${n}, uv);
2021-02-21 20:06:13 +01:00
}
2021-02-25 13:50:13 +01:00
`}function zO(e){let t=e.shapeInfo.logicalShape,n=e.name,r="get"+n.charAt(0).toUpperCase()+n.slice(1),a=t[1]*t[2],s=t[2],{newShape:i,keptDims:o}=v.squeezeShape(t),l=i;if(l.length<t.length){let f=ml(e,l),m=["row","col","depth"];return`
${pl(f)}
2021-02-21 20:07:04 +01:00
float ${r}(int row, int col, int depth) {
2021-02-25 13:50:13 +01:00
return ${r}(${Al(m,o)});
2021-02-21 20:06:13 +01:00
}
2021-02-21 20:07:04 +01:00
`}if(e.shapeInfo.isUniform)return`
float ${r}(int row, int col, int depth) {
int index = round(dot(vec3(row, col, depth),
vec3(${a}, ${s}, 1)));
2021-02-25 13:50:13 +01:00
${fl(e)}
2020-11-10 02:13:38 +01:00
}
2021-02-25 13:50:13 +01:00
`;let u=e.shapeInfo.texShape,c=u[0],h=u[1],d=e.shapeInfo.flatOffset;if(h===a&&d==null)return`
2021-02-21 20:07:04 +01:00
float ${r}(int row, int col, int depth) {
float texR = float(row);
float texC = dot(vec2(col, depth), vec2(${s}, 1));
vec2 uv = (vec2(texC, texR) + halfCR) /
2021-02-25 13:50:13 +01:00
vec2(${h}.0, ${c}.0);
2021-02-21 20:07:04 +01:00
return sampleTexture(${n}, uv);
}
`;if(h===s&&d==null)return`
float ${r}(int row, int col, int depth) {
float texR = dot(vec2(row, col), vec2(${t[1]}, 1));
float texC = float(depth);
2021-02-25 13:50:13 +01:00
vec2 uv = (vec2(texC, texR) + halfCR) / vec2(${h}.0, ${c}.0);
2021-02-21 20:07:04 +01:00
return sampleTexture(${n}, uv);
2021-02-21 20:06:13 +01:00
}
2021-02-25 13:50:13 +01:00
`;let p=li(n);return`
2021-02-21 20:07:04 +01:00
float ${r}(int row, int col, int depth) {
// Explicitly use integer operations as dot() only works on floats.
int index = row * ${a} + col * ${s} + depth + ${p};
2021-02-25 13:50:13 +01:00
vec2 uv = uvFromFlat(${c}, ${h}, index);
2021-02-21 20:07:04 +01:00
return sampleTexture(${n}, uv);
}
2021-02-25 13:50:13 +01:00
`}function HO(e){let t=e.shapeInfo.logicalShape,n=t.length,r=e.name,a="get"+r.charAt(0).toUpperCase()+r.slice(1),s=e.shapeInfo.texShape,i=[Math.ceil(s[0]/2),Math.ceil(s[1]/2)],o=i[0],l=i[1],u=Math.ceil(t[n-1]/2),c=u*Math.ceil(t[n-2]/2),h="int b, int row, int col",d=`b * ${c} + (row / 2) * ${u} + (col / 2)`;for(let f=2;f<n-1;f++)h=`int b${f}, `+h,c*=t[n-f-1],d=`b${f} * ${c} + `+d;let p=un();return`
2021-02-21 20:07:04 +01:00
vec4 ${a}(${h}) {
int index = ${d};
int texR = index / ${l};
int texC = index - texR * ${l};
vec2 uv = (vec2(texC, texR) + halfCR) / vec2(${l}, ${o});
return ${p.texture2D}(${r}, uv);
}
2021-02-25 13:50:13 +01:00
`}function LO(e){let t=e.shapeInfo.logicalShape,n=e.name,r="get"+n.charAt(0).toUpperCase()+n.slice(1),a=t[3],s=t[2]*a,i=t[1]*s,{newShape:o,keptDims:l}=v.squeezeShape(t);if(o.length<t.length){let f=ml(e,o),m=["row","col","depth","depth2"];return`
${pl(f)}
2021-02-21 20:07:04 +01:00
float ${r}(int row, int col, int depth, int depth2) {
2021-02-25 13:50:13 +01:00
return ${r}(${Al(m,l)});
2021-02-21 20:07:04 +01:00
}
`}if(e.shapeInfo.isUniform)return`
float ${r}(int row, int col, int depth, int depth2) {
int index = round(dot(vec4(row, col, depth, depth2),
vec4(${i}, ${s}, ${a}, 1)));
2021-02-25 13:50:13 +01:00
${fl(e)}
2020-11-10 02:13:38 +01:00
}
2021-02-25 13:50:13 +01:00
`;let u=e.shapeInfo.flatOffset,c=e.shapeInfo.texShape,h=c[0],d=c[1];if(d===i&&u==null)return`
2021-02-21 20:07:04 +01:00
float ${r}(int row, int col, int depth, int depth2) {
float texR = float(row);
float texC =
dot(vec3(col, depth, depth2),
vec3(${s}, ${a}, 1));
vec2 uv = (vec2(texC, texR) + halfCR) /
vec2(${d}.0, ${h}.0);
return sampleTexture(${n}, uv);
2020-11-12 18:58:55 +01:00
}
2021-02-25 13:50:13 +01:00
`;if(d===a&&u==null)return`
2021-02-21 20:07:04 +01:00
float ${r}(int row, int col, int depth, int depth2) {
float texR = dot(vec3(row, col, depth),
vec3(${t[1]*t[2]}, ${t[2]}, 1));
float texC = float(depth2);
vec2 uv = (vec2(texC, texR) + halfCR) /
vec2(${d}.0, ${h}.0);
return sampleTexture(${n}, uv);
2020-11-12 18:58:55 +01:00
}
2021-02-25 13:50:13 +01:00
`;let p=li(n);return`
2021-02-21 20:07:04 +01:00
float ${r}(int row, int col, int depth, int depth2) {
// Explicitly use integer operations as dot() only works on floats.
int index = row * ${i} + col * ${s} +
depth * ${a} + depth2;
vec2 uv = uvFromFlat(${h}, ${d}, index + ${p});
return sampleTexture(${n}, uv);
}
2021-02-25 13:50:13 +01:00
`}function PO(e){let t=e.shapeInfo.logicalShape,n=e.name,r="get"+n.charAt(0).toUpperCase()+n.slice(1),a=t[4],s=t[3]*a,i=t[2]*s,o=t[1]*i,{newShape:l,keptDims:u}=v.squeezeShape(t);if(l.length<t.length){let m=ml(e,l),A=["row","col","depth","depth2","depth3"];return`
${pl(m)}
2021-02-21 20:07:04 +01:00
float ${r}(int row, int col, int depth, int depth2, int depth3) {
2021-02-25 13:50:13 +01:00
return ${r}(${Al(A,u)});
2021-02-21 20:07:04 +01:00
}
`}if(e.shapeInfo.isUniform)return`
float ${r}(int row, int col, int depth, int depth2, int depth3) {
float index = dot(
vec4(row, col, depth, depth2),
vec4(${o}, ${i}, ${s}, ${a})) +
depth3;
2021-02-25 13:50:13 +01:00
${fl(e)}
2020-11-07 17:34:56 +01:00
}
2021-02-25 13:50:13 +01:00
`;let c=e.shapeInfo.flatOffset,h=e.shapeInfo.texShape,d=h[0],p=h[1];if(p===o&&c==null)return`
2021-02-21 20:07:04 +01:00
float ${r}(int row, int col, int depth, int depth2, int depth3) {
int texR = row;
float texC = dot(vec4(col, depth, depth2, depth3),
vec4(${i}, ${s}, ${a}, 1));
vec2 uv = (vec2(texC, texR) + halfCR) /
vec2(${p}.0, ${d}.0);
return sampleTexture(${n}, uv);
2021-01-03 16:41:56 +01:00
}
2021-02-25 13:50:13 +01:00
`;if(p===a&&c==null)return`
2021-02-21 20:07:04 +01:00
float ${r}(int row, int col, int depth, int depth2, int depth3) {
float texR = dot(
vec4(row, col, depth, depth2),
vec4(${t[1]*t[2]*t[3]},
${t[2]*t[3]}, ${t[3]}, 1));
int texC = depth3;
vec2 uv = (vec2(texC, texR) + halfCR) /
vec2(${p}.0, ${d}.0);
return sampleTexture(${n}, uv);
2021-02-21 20:06:13 +01:00
}
2021-02-25 13:50:13 +01:00
`;let f=li(n);return`
2021-02-21 20:07:04 +01:00
float ${r}(int row, int col, int depth, int depth2, int depth3) {
// Explicitly use integer operations as dot() only works on floats.
int index = row * ${o} + col * ${i} + depth * ${s} +
depth2 * ${a} + depth3 + ${f};
vec2 uv = uvFromFlat(${d}, ${p}, index);
return sampleTexture(${n}, uv);
}
2021-02-25 13:50:13 +01:00
`}function WO(e){let t=e.shapeInfo.logicalShape,n=e.name,r="get"+n.charAt(0).toUpperCase()+n.slice(1),{newShape:a,keptDims:s}=v.squeezeShape(t);if(a.length<t.length){let A=ml(e,a),y=["row","col","depth","depth2","depth3","depth4"];return`
${pl(A)}
2021-02-21 20:07:04 +01:00
float ${r}(int row, int col, int depth,
int depth2, int depth3, int depth4) {
2021-02-25 13:50:13 +01:00
return ${r}(${Al(y,s)});
2021-02-21 20:06:13 +01:00
}
2021-02-25 13:50:13 +01:00
`}let i=t[5],o=t[4]*i,l=t[3]*o,u=t[2]*l,c=t[1]*u;if(e.shapeInfo.isUniform)return`
2021-02-21 20:07:04 +01:00
float ${r}(int row, int col, int depth,
int depth2, int depth3, int depth4) {
int index = round(dot(
vec4(row, col, depth, depth2),
2021-02-25 13:50:13 +01:00
vec4(${c}, ${u}, ${l}, ${o})) +
2021-02-21 20:07:04 +01:00
dot(
vec2(depth3, depth4),
vec2(${i}, 1)));
2021-02-25 13:50:13 +01:00
${fl(e)}
2021-01-03 16:41:56 +01:00
}
2021-02-25 13:50:13 +01:00
`;let h=e.shapeInfo.flatOffset,d=e.shapeInfo.texShape,p=d[0],f=d[1];if(f===c&&h==null)return`
2021-02-21 20:07:04 +01:00
float ${r}(int row, int col, int depth,
int depth2, int depth3, int depth4) {
int texR = row;
float texC = dot(vec4(col, depth, depth2, depth3),
2021-02-25 13:50:13 +01:00
vec4(${u}, ${l}, ${o}, ${i})) +
2021-02-21 20:07:04 +01:00
float(depth4);
vec2 uv = (vec2(texC, texR) + halfCR) /
vec2(${f}.0, ${p}.0);
return sampleTexture(${n}, uv);
2021-01-03 16:41:56 +01:00
}
2021-02-21 20:07:04 +01:00
`;if(f===i&&h==null)return`
float ${r}(int row, int col, int depth,
int depth2, int depth3, int depth4) {
float texR = dot(vec4(row, col, depth, depth2),
vec4(${t[1]*t[2]*t[3]*t[4]},
${t[2]*t[3]*t[4]},
${t[3]*t[4]},
${t[4]})) + float(depth3);
int texC = depth4;
vec2 uv = (vec2(texC, texR) + halfCR) /
vec2(${f}.0, ${p}.0);
return sampleTexture(${n}, uv);
2021-01-03 16:23:45 +01:00
}
2021-02-25 13:50:13 +01:00
`;let m=li(n);return`
2021-02-21 20:07:04 +01:00
float ${r}(int row, int col, int depth,
int depth2, int depth3, int depth4) {
// Explicitly use integer operations as dot() only works on floats.
2021-02-25 13:50:13 +01:00
int index = row * ${c} + col * ${u} + depth * ${l} +
2021-02-21 20:07:04 +01:00
depth2 * ${o} + depth3 * ${i} + depth4 + ${m};
vec2 uv = uvFromFlat(${p}, ${f}, index);
return sampleTexture(${n}, uv);
2021-02-21 20:06:13 +01:00
}
2021-02-25 13:50:13 +01:00
`}function fl(e){let t=e.name,n=v.sizeFromShape(e.shapeInfo.logicalShape);return n<2?`return ${t};`:`
2021-02-21 20:07:04 +01:00
for (int i = 0; i < ${n}; i++) {
if (i == index) {
return ${t}[i];
2020-11-12 18:58:55 +01:00
}
2021-02-21 20:06:13 +01:00
}
2021-02-25 13:50:13 +01:00
`}function GO(e,t){let n=e.name,r=n.charAt(0).toUpperCase()+n.slice(1),a="get"+r+"AtOutCoords",s=e.shapeInfo.logicalShape.length,i=t.logicalShape.length,o=Pw(e.shapeInfo.logicalShape,t.logicalShape),l=lt(i),u=i-s,c,h=["x","y","z","w","u","v"];s===0?c="":i<2&&o.length>=1?c="coords = 0;":c=o.map(A=>`coords.${h[A+u]} = 0;`).join(`
`);let d="";i<2&&s>0?d="coords":d=e.shapeInfo.logicalShape.map((A,y)=>`coords.${h[y+u]}`).join(", ");let p="return outputValue;",f=v.sizeFromShape(e.shapeInfo.logicalShape)===1,m=v.sizeFromShape(t.logicalShape)===1;if(s===1&&!f&&!m)p=`
2021-02-21 20:07:04 +01:00
return vec4(outputValue.xy, outputValue.xy);
`;else if(f&&!m)i===1?p=`
return vec4(outputValue.x, outputValue.x, 0., 0.);
`:p=`
return vec4(outputValue.x);
`;else if(o.length){let A=s-2,y=s-1;o.indexOf(A)>-1&&o.indexOf(y)>-1?p="return vec4(outputValue.x);":o.indexOf(A)>-1?p="return vec4(outputValue.x, outputValue.y, outputValue.x, outputValue.y);":o.indexOf(y)>-1&&(p="return vec4(outputValue.xx, outputValue.zz);")}return`
vec4 ${a}() {
${l} coords = getOutputCoords();
2021-02-25 13:50:13 +01:00
${c}
2021-02-21 20:07:04 +01:00
vec4 outputValue = get${r}(${d});
${p}
}
2021-02-25 13:50:13 +01:00
`}function qO(e,t){let n=e.name,r=n.charAt(0).toUpperCase()+n.slice(1),a="get"+r+"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&&v.arraysEqual(i,s))return`
2021-02-21 20:07:04 +01:00
float ${a}() {
return sampleTexture(${n}, resultUV);
}
2021-02-25 13:50:13 +01:00
`;let u=lt(l),c=Pw(e.shapeInfo.logicalShape,t.logicalShape),h=l-o,d,p=["x","y","z","w","u","v"];o===0?d="":l<2&&c.length>=1?d="coords = 0;":d=c.map(m=>`coords.${p[m+h]} = 0;`).join(`
2021-02-21 20:07:04 +01:00
`);let f="";return l<2&&o>0?f="coords":f=e.shapeInfo.logicalShape.map((m,A)=>`coords.${p[A+h]}`).join(", "),`
float ${a}() {
2021-02-25 13:50:13 +01:00
${u} coords = getOutputCoords();
2021-02-21 20:07:04 +01:00
${d}
return get${r}(${f});
}
2021-02-25 13:50:13 +01:00
`}function lt(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 ml(e,t){let n=JSON.parse(JSON.stringify(e));return n.shapeInfo.logicalShape=t,n}function Al(e,t){return t.map(n=>e[n]).join(", ")}function oz(e,t,n,r){let a=t.userCode,s=n.map((p,f)=>{let m={logicalShape:p.shape,texShape:p.isUniform?null:p.texData.texShape,isUniform:p.isUniform,isPacked:p.isUniform?!1:p.texData.isPacked,flatOffset:null};return p.texData!=null&&p.texData.slice!=null&&p.texData.slice.flatOffset>0&&(m.flatOffset=p.texData.slice.flatOffset),{name:t.variableNames[f],shapeInfo:m}}),i=s.map(p=>p.shapeInfo),o={logicalShape:r.shape,texShape:r.texData.texShape,isUniform:!1,isPacked:r.texData.isPacked,flatOffset:null},l=$O(s,o,a,t.packedInputs),u=e.createProgram(l),c=null,h=e.getUniformLocation(u,"NAN",!1);Y().getNumber("WEBGL_VERSION")===1&&(c=e.getUniformLocation(u,"INFINITY",!1));let d={};for(let p=0;p<t.variableNames.length;p++){let f=t.variableNames[p],m=!1;d[f]=e.getUniformLocation(u,f,m),d[`offset${f}`]=e.getUniformLocation(u,`offset${f}`,m)}return{program:t,source:l,webGLProgram:u,uniformLocations:d,inShapeInfos:i,outShapeInfo:o,infLoc:c,nanLoc:h}}function Vw(e,t){if(e.length!==t.length)throw Error(`Binary was compiled with ${e.length} inputs, but was executed with ${t.length} inputs`);e.forEach((n,r)=>{let a=n.logicalShape,s=t[r],i=s.shape;if(!v.arraysEqual(a,i))throw Error(`Binary was compiled with different shapes than the current args. Shapes ${a} and ${i} must match`);if(n.isUniform&&s.isUniform)return;let o=n.texShape,l=s.isUniform?null:s.texData.texShape;if(!v.arraysEqual(o,l))throw Error(`Binary was compiled with different texture shapes than the current args. Shape ${o} and ${l} must match`)})}function lz(e,t,n,r,a){Vw(t.inShapeInfos,n),Vw([t.outShapeInfo],[r]);let s=r.texData.texture,i=r.texData.texShape;r.texData.isPacked?e.setOutputPackedMatrixTexture(s,i[0],i[1]):e.setOutputMatrixTexture(s,i[0],i[1]),e.setProgram(t.webGLProgram),Y().getNumber("WEBGL_VERSION")===1&&t.infLoc!==null&&e.gl.uniform1f(t.infLoc,Infinity),t.nanLoc!==null&&e.gl.uniform1f(t.nanLoc,NaN),n.forEach((o,l)=>{let u=t.program.variableNames[l],c=t.uniformLocations[u],h=t.uniformLocations[`offset${u}`];if(c!=null){if(o.isUniform){if(v.sizeFromShape(o.shape)<2)e.gl.uniform1f(c,o.uniformValues[0]);else{let d=o.uniformValues;d instanceof Float32Array||(d=new Float32Array(d)),e.gl.uniform1fv(c,d)}return}o.texData.slice!=null&&h!=null&&e.gl.uniform1i(h,o.texData.slice.flatOffset),e.setInputMatrixTexture(o.texData.texture,c,l)}}),a!=null&&a(e,t.webGLProgram),e.executeProgram()}function uz(e,t,n){let r="";t.concat(n).forEach(i=>{let o=i.texData!=null&&i.texData.slice!=null&&i.texData.slice.flatOffset>0,l=i.isUniform?"uniform":i.texData.texShape;r+=`${i.shape}_${l}_${o}`});let a=e.userCode,s=e.constructor.name;return s+="_"+r+"_"+a,s}var{addImpl:cz,bincountImpl:Uw,bincountReduceImpl:hz,ceilImpl:dz,concatImpl:pz,expImpl:fz,expm1Impl:mz,floorImpl:Az,gatherV2Impl:yz,greaterImpl:gz,lessImpl:xz,linSpaceImpl:wz,logImpl:_z,maxImpl:bz,maximumImpl:vz,minimumImpl:kz,multiplyImpl:Iz,negImpl:Nz,prodImpl:Sz,rangeImpl:Tz,rsqrtImpl:Ez,simpleAbsImpl:jw,sliceImpl:Cz,stridedSliceImpl:Rz,subImpl:Fz,tileImpl:$z,topKImpl:Mz,transposeImpl:NA,uniqueImpl:Dz}=um;function Hw(e,t){return["x","y","z","w","u","v"].slice(0,t).map(n=>`${e}.${n}`)}function cn(e,t){return t===1?[e]:Hw(e,t)}function Oz(e,t){if(e===1)return"rc";let n="";for(let r=0;r<e;r++)n+=t[r],r<e-1&&(n+=",");return n}var Wz=class{constructor(e){this.variableNames=["A"],this.packedInputs=!1,this.packedOutput=!0,this.outputShape=e;let t=e.length;if(t===0)this.userCode=`
2021-02-21 20:07:04 +01:00
void main() {
setOutput(vec4(getA(), 0., 0., 0.));
2021-02-21 20:06:13 +01:00
}
2021-02-25 13:50:13 +01:00
`;else{let n=cn("rc",t),r=lt(t),a=zz(t,e,n),s=Lz(t,e[e.length-1],e[e.length-2],n),i=Pz(e,n);this.userCode=`
2021-02-21 20:07:04 +01:00
void main() {
${r} rc = getOutputCoords();
if(${a}) {
setOutput(vec4(0));
} else {
${s}
setOutput(vec4(${i}));
2021-02-21 20:06:13 +01:00
}
}
2021-02-25 13:50:13 +01:00
`}}};function Bz(e,t){let n=[];for(let r=0;r<=1;r++)for(let a=0;a<=1;a++){let s=`${r===0?"r":"rp1"}, ${a===0?"c":"cp1"}`;for(let i=2;i<e;i++)s=`${t[t.length-1-i]},`+s;n.push(s)}return n}function zz(e,t,n){if(e===1)return`rc > ${t[0]}`;let r="";for(let a=e-2;a<e;a++)r+=`${n[a]} >= ${t[a]}`,a<e-1&&(r+="||");return r}function Lz(e,t,n,r){if(e===1)return"";let a=r.slice(-2);return`
2021-02-21 20:07:04 +01:00
int r = ${a[0]};
int c = ${a[1]};
int rp1 = r + 1;
int cp1 = c + 1;
bool cEdge = cp1 >= ${t};
bool rEdge = rp1 >= ${n};
2021-02-25 13:50:13 +01:00
`}function Pz(e,t){let n=e.length,r=Bz(n,t);return n===1?`getA(rc),
2021-02-21 20:07:04 +01:00
rc + 1 >= ${e[0]} ? 0. : getA(rc + 1),
0, 0`:`getA(${r[0]}),
cEdge ? 0. : getA(${r[1]}),
rEdge ? 0. : getA(${r[2]}),
2021-02-25 13:50:13 +01:00
rEdge || cEdge ? 0. : getA(${r[3]})`}var Gw=class{constructor(e,t){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=e;let n="";for(let r=0;r<4;r++){let a="thisRC = rc;";r%2==1&&(a+="thisRC.z += 1;"),r>1&&(a+="thisRC.y += 1;"),n+=`
2021-02-21 20:07:04 +01:00
${a}
${r>0?"if(thisRC.y < rows && thisRC.z < cols){":""}
int flatIndex = getFlatIndex(thisRC);
ivec3 inputRC = inputCoordsFromReshapedOutCoords(flatIndex);
vec2 inputRCInnerDims = vec2(float(inputRC.y),float(inputRC.z));
result[${r}] =
getChannel(getA(inputRC.x, inputRC.y, inputRC.z), inputRCInnerDims);
${r>0?"}":""}
`}this.userCode=`
2021-02-25 13:50:13 +01:00
${Vz(t)}
${wA(e)}
2021-02-21 20:07:04 +01:00
void main() {
ivec3 rc = getOutputCoords();
vec4 result = vec4(0.);
ivec3 thisRC;
int rows = ${e[1]};
int cols = ${e[2]};
${n}
setOutput(result);
2021-01-03 16:41:56 +01:00
}
2021-02-25 13:50:13 +01:00
`}};function Vz(e){return`
2021-02-21 20:07:04 +01:00
ivec3 inputCoordsFromReshapedOutCoords(int index) {
2021-02-25 13:50:13 +01:00
${oi(["r","c","d"],e)}
2021-02-21 20:07:04 +01:00
return ivec3(r, c, d);
}
2021-02-25 13:50:13 +01:00
`}var Uz=class{constructor(e){this.gpgpu=e,this.numUsedTextures=0,this.numFreeTextures=0,this._numBytesAllocated=0,this._numBytesFree=0,this.freeTextures={},this.logEnabled=!1,this.usedTextures={}}acquireTexture(e,t,n){let r=Xw(t,n),a=Kw(e,r,n);a in this.freeTextures||(this.freeTextures[a]=[]),a in this.usedTextures||(this.usedTextures[a]=[]);let s=qw(e,r,this.gpgpu.gl,this.gpgpu.textureConfig,n);if(this.freeTextures[a].length>0){this.numFreeTextures--,this.numUsedTextures++,this._numBytesFree-=s,this.log();let o=this.freeTextures[a].shift();return this.usedTextures[a].push(o),o}let i;return r===Jt.PACKED_2X2_FLOAT32?i=this.gpgpu.createPackedMatrixTexture(e[0],e[1]):r===Jt.PACKED_2X2_FLOAT16?i=this.gpgpu.createFloat16PackedMatrixTexture(e[0],e[1]):r===Jt.UNPACKED_FLOAT32?i=this.gpgpu.createFloat32MatrixTexture(e[0],e[1]):r===Jt.UNPACKED_FLOAT16?i=this.gpgpu.createFloat16MatrixTexture(e[0],e[1]):r===Jt.PACKED_4X1_UNSIGNED_BYTE&&(i=this.gpgpu.createUnsignedBytesMatrixTexture(e[0],e[1])),this.usedTextures[a].push(i),this.numUsedTextures++,this._numBytesAllocated+=s,this.log(),i}releaseTexture(e,t,n,r){if(this.freeTextures==null)return;let a=Xw(n,r),s=Kw(t,a,r);s in this.freeTextures||(this.freeTextures[s]=[]);let i=qw(t,a,this.gpgpu.gl,this.gpgpu.textureConfig,r),o=Y().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],u=l.indexOf(e);if(u<0)throw new Error("Cannot release a texture that was never provided by this texture manager");l.splice(u,1),this.log()}log(){if(!this.logEnabled)return;let e=this.numFreeTextures+this.numUsedTextures;console.log("Free/Used",`${this.numFreeTextures} / ${this.numUsedTextures}`,`(${e})`);let t=this._numBytesFree/this._numBytesAllocated;console.log(`Bytes allocated: ${this._numBytesAllocated}`),console.log(`Bytes unused: ${this._numBytesFree} (${Math.round(100*t)}%)`)}get numBytesAllocated(){return this._numBytesAllocated}get numBytesFree(){return this._numBytesFree}getNumUsedTextures(){return this.numUsedTextures}getNumFreeTextures(){return this.numFreeTextures}dispose(){if(this.freeTextures!=null){for(let e in this.freeTextures)this.freeTextures[e].forEach(t=>{this.gpgpu.deleteMatrixTexture(t)});for(let e in this.usedTextures)this.usedTextures[e].forEach(t=>{this.gpgpu.deleteMatrixTexture(t)});this.freeTextures=null,this.usedTextures=null,this.numUsedTextures=0,this.numFreeTextures=0,this._numBytesAllocated=0,this._numBytesFree=0}}};function jz(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 qw(e,t,n,r,a){let s=Hz(t,r),i;if(a){let[l,u]=dl(e[0],e[1]);i=l*u}else{let[l,u]=Ku(e[0],e[1]);i=l*u}let o=jz(n,s);return i*o}function Hz(e,t){switch(e){case Jt.PACKED_2X2_FLOAT32:return kA(t);case Jt.PACKED_2X2_FLOAT16:return IA(t);case Jt.UNPACKED_FLOAT32:return _A(t);case Jt.UNPACKED_FLOAT16:return bA(t);case Jt.PACKED_4X1_UNSIGNED_BYTE:return vA(t);default:throw new Error(`Unknown physical texture type ${e}`)}}function Gz(e){return Y().getBool("WEBGL_RENDER_FLOAT32_ENABLED")?e?Jt.PACKED_2X2_FLOAT32:Jt.UNPACKED_FLOAT32:e?Jt.PACKED_2X2_FLOAT16:Jt.UNPACKED_FLOAT16}function Xw(e,t){if(e===Gn.UPLOAD)return Jt.PACKED_2X2_FLOAT32;if(e===Gn.RENDER||e==null)return Gz(t);if(e===Gn.DOWNLOAD||e===Gn.PIXELS)return Jt.PACKED_4X1_UNSIGNED_BYTE;throw new Error(`Unknown logical texture type ${e}`)}function Kw(e,t,n){return`${e[0]}_${e[1]}_${t}_${n}`}var $a=class{constructor(e,t){this.variableNames=["A"],this.outputShape=e,this.userCode=`
2021-02-21 20:07:04 +01:00
float unaryOperation(float x) {
${t}
2020-11-10 02:13:38 +01:00
}
2021-02-21 20:07:04 +01:00
void main() {
float x = getAAtOutCoords();
float y = unaryOperation(x);
setOutput(y);
2021-01-03 16:41:56 +01:00
}
2021-02-25 13:50:13 +01:00
`}},mr="if (isnan(x)) return x;",qz="return x;",Zw="return abs(x);",Xz="return (x >= 0.0) ? x : (exp(x) - 1.0);",Kz=mr+`
2021-02-21 20:07:04 +01:00
return (x < 0.0) ? 0.0 : x;
2021-02-25 13:50:13 +01:00
`,Zz=mr+`
2021-02-21 20:07:04 +01:00
return (x < 0.0) ? 0.0 : min(6.0, x);
2021-02-25 13:50:13 +01:00
`,Kd="return x;",Yz="return x;",Jz=`
2021-02-21 20:07:04 +01: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-02-25 13:50:13 +01:00
`,Qz=`
2021-02-21 20:07:04 +01: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-02-25 13:50:13 +01:00
`,eL=`
2021-02-21 20:07:04 +01: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-02-25 13:50:13 +01:00
`,yl=class{constructor(e,t){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=e,this.userCode=`
2021-02-21 20:07:04 +01:00
vec4 unaryOperation(vec4 x) {
${t}
2021-01-03 16:41:56 +01:00
}
2021-02-21 20:07:04 +01:00
void main() {
vec4 x = getAAtOutCoords();
vec4 y = unaryOperation(x);
setOutput(y);
2021-02-21 20:06:13 +01:00
}
2021-02-25 13:50:13 +01:00
`}},tL=class{constructor(e){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!1,this.outputShape=e;let t=e.length,n=cn("rc",t),r=lt(t),a=Oz(t,n),s=n.slice(-2),i=t<=1?"rc":`vec2(${s.join(",")})`;this.userCode=`
2021-02-21 20:07:04 +01:00
void main() {
${r} rc = getOutputCoords();
vec4 packedInput = getA(${a});
setOutput(getChannel(packedInput, ${i}));
2021-02-21 20:06:13 +01:00
}
2021-02-25 13:50:13 +01:00
`}},nL=Rr.whereImpl,rL=1e-7,aL=1e-4,SA={};function sL(e){return e in SA||(SA[e]={}),SA[e]}var iL=128,oL=600;function lL(){return Y().global.screen==null?1024:Y().global.screen.height*Y().global.screen.width*window.devicePixelRatio*oL/1024/1024}var Cu=class extends Ul{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.warnedAboutCPUBackend=!1,this.pendingDeletes=0,this.disposed=!1,!Y().getBool("HAS_WEBGL"))throw new Error("WebGL is not supported on this device");if(e==null){let t=Lr(Y().getNumber("WEBGL_VERSION"));this.binaryCache=sL(Y().getNumber("WEBGL_VERSION")),this.gpgpu=new hm(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 Uz(this.gpgpu),this.numMBBeforeWarning=lL(),this.texData=new ah(this,Nr())}nextDataId(){return Cu.nextDataId++}numDataIds(){return this.texData.numDataIds()+(this.cpuBackend?this.cpuBackend.numDataIds():0)-this.pendingDeletes}write(e,t,n){if((Y().getBool("WEBGL_CHECK_NUMERICAL_PROBLEMS")||Y().getBool("DEBUG"))&&this.checkNumericalProblems(e),n==="complex64"&&e!=null)throw new Error("Cannot write to a complex64 dtype. Please use tf.complex(real, imag).");let r={id:this.nextDataId()};return this.texData.set(r,{shape:t,dtype:n,values:e,usage:Gn.UPLOAD,refCount:1}),r}refCount(e){return this.texData.has(e)?this.texData.get(e).refCount:0}incRef(e){let t=this.texData.get(e);t.refCount++}decRef(e){if(this.texData.has(e)){let t=this.texData.get(e);t.refCount--}}move(e,t,n,r,a){if(Y().getBool("DEBUG")&&this.checkNumericalProblems(t),r==="complex64")throw new Error("Cannot write to a complex64 dtype. Please use tf.complex(real, imag).");this.texData.set(e,{shape:n,dtype:r,values:t,usage:Gn.UPLOAD,refCount:a})}disposeIntermediateTensorInfo(e){this.disposeData(e.dataId)}readSync(e){let t=this.texData.get(e),{values:n,dtype:r,complexTensorInfos:a,slice:s,shape:i,isPacked:o}=t;if(s!=null){let h;o?h=new yl(i,Kd):h=new $a(i,Kd);let d=this.runWebGLProgram(h,[{dataId:e,shape:i,dtype:r}],r),p=this.readSync(d.dataId);return this.disposeIntermediateTensorInfo(d),p}if(n!=null)return this.convertAndCacheOnCPU(e);if(r==="string")return n;let l=this.activeTimers!=null,u;l&&(u=v.now());let c;if(r==="complex64"){let h=this.readSync(a.real.dataId),d=this.readSync(a.imag.dataId);c=C.mergeRealAndImagArrays(h,d)}else c=this.getValuesFromTexture(e);return l&&(this.downloadWaitMs+=v.now()-u),this.convertAndCacheOnCPU(e,c)}async read(e){if(this.pendingRead.has(e)){let p=this.pendingRead.get(e);return new Promise(f=>p.push(f))}let t=this.texData.get(e),{values:n,shape:r,slice:a,dtype:s,complexTensorInfos:i,isPacked:o}=t;if(a!=null){let p;o?p=new yl(r,Kd):p=new $a(r,Kd);let f=this.runWebGLProgram(p,[{dataId:e,shape:r,dtype:s}],s),m=this.read(f.dataId);return this.disposeIntermediateTensorInfo(f),m}if(n!=null)return this.convertAndCacheOnCPU(e);if(!Y().getBool("WEBGL_DOWNLOAD_FLOAT_ENABLED")&&Y().getNumber("WEBGL_VERSION")===2)throw new Error("tensor.data() with WEBGL_DOWNLOAD_FLOAT_ENABLED=false and WEBGL_VERSION=2 not yet supported.");let l=null,u;if(s!=="complex64"&&Y().get("WEBGL_BUFFER_SUPPORTED")){u=this.decode(e);let p=this.texData.get(u.dataId);l=this.gpgpu.createBufferFromTexture(p.texture,...Zu(r))}this.pendingRead.set(e,[]),s!=="complex64"&&await this.gpgpu.createAndWaitForFence();let c;if(s==="complex64"){let p=await Promise.all([this.read(i.real.dataId),this.read(i.imag.dataId)]),f=p[0],m=p[1];c=C.mergeRealAndImagArrays(f,m)}else if(l==null)c=this.getValuesFromTexture(e);else{let p=v.sizeFromShape(r);c=this.gpgpu.downloadFloat32MatrixFromBuffer(l,p)}u!=null&&this.disposeIntermediateTensorInfo(u);let h=this.convertAndCacheOnCPU(e,c),d=this.pendingRead.get(e);return this.pendingRead.delete(e),d.forEach(p=>p(h)),this.pendingDisposal.has(e)&&(this.pendingDisposal.delete(e),this.disposeData(e)&&Nr().removeDataId(e,this),this
2021-02-21 20:07:04 +01:00
if (isnan(a)) return a;
if (isnan(b)) return b;
2021-02-25 13:50:13 +01:00
`,gl=class{constructor(e,t,n){this.variableNames=["A","B"],this.outputShape=C.assertAndGetBroadcastShape(t,n),this.userCode=`
2021-02-21 20:07:04 +01:00
float binaryOperation(float a, float b) {
${e}
2021-02-21 20:06:13 +01:00
}
2021-02-21 20:07:04 +01:00
void main() {
float a = getAAtOutCoords();
float b = getBAtOutCoords();
setOutput(binaryOperation(a, b));
2021-02-21 20:06:13 +01:00
}
2021-02-25 13:50:13 +01:00
`}},Zd=`
2021-02-21 20:07:04 +01: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-02-25 13:50:13 +01:00
`,Ju=class{constructor(e,t,n,r=!1){this.variableNames=["A","B"],this.supportsBroadcasting=!0,this.packedInputs=!0,this.packedOutput=!0,this.outputShape=C.assertAndGetBroadcastShape(t,n);let a=this.outputShape.length,s="";if(r)if(a===0||v.sizeFromShape(this.outputShape)===1)s=`
2021-02-21 20:07:04 +01:00
result.y = 0.;
result.z = 0.;
result.w = 0.;
`;else if(s=`
2021-02-25 13:50:13 +01:00
${lt(a)} coords = getOutputCoords();
2021-02-21 20:07:04 +01:00
`,a===1)s+=`
result.y = (coords + 1) >= ${this.outputShape[0]} ? 0. : result.y;
result.z = 0.;
result.w = 0.;
2021-02-25 13:50:13 +01:00
`;else{let i=cn("coords",a);s+=`
2021-02-21 20:07:04 +01:00
bool nextRowOutOfBounds =
(${i[a-2]} + 1) >= ${this.outputShape[a-2]};
bool nextColOutOfBounds =
(${i[a-1]} + 1) >= ${this.outputShape[a-1]};
result.y = nextColOutOfBounds ? 0. : result.y;
result.z = nextRowOutOfBounds ? 0. : result.z;
result.w = nextColOutOfBounds || nextRowOutOfBounds ? 0. : result.w;
`}this.userCode=`
vec4 binaryOperation(vec4 a, vec4 b) {
${e}
2021-02-21 20:06:13 +01:00
}
2021-02-21 20:07:04 +01:00
void main() {
vec4 a = getAAtOutCoords();
vec4 b = getBAtOutCoords();
vec4 result = binaryOperation(a, b);
${s}
setOutput(result);
2021-02-21 20:06:13 +01:00
}
2021-02-25 13:50:13 +01:00
`}};function Fn(e){let{inputs:t,backend:n}=e,{x:r}=t;return n.incRef(r.dataId),{dataId:r.dataId,shape:r.shape,dtype:r.dtype}}var cL={kernelName:cs,backendName:"webgl",kernelFunc:Fn};function Ma(e){let{inputs:t,backend:n}=e,{real:r,imag:a}=t,s=n.makeTensorInfo(r.shape,"complex64"),i=n.texData.get(s.dataId),o=Fn({inputs:{x:r},backend:n}),l=Fn({inputs:{x:a},backend:n});return i.complexTensorInfos={real:o,imag:l},s}var hL={kernelName:ch,backendName:"webgl",kernelFunc:Ma},Jw="return (a < 0.) ? b * a : a;",Qw=`
2021-02-21 20:07:04 +01:00
vec4 aLessThanZero = vec4(lessThan(a, vec4(0.)));
return (aLessThanZero * (b * a)) + ((vec4(1.0) - aLessThanZero) * a);
2021-02-25 13:50:13 +01:00
`;function dL(e){let{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{alpha:s}=r,i=n.makeTensorInfo([],"float32",v.createScalarValue(s,"float32")),o=Y().getBool("WEBGL_PACK_BINARY_OPERATIONS")?new Ju(Qw,a.shape,i.shape):new gl(Jw,a.shape,i.shape),l=n.runWebGLProgram(o,[a,i],a.dtype);return n.disposeIntermediateTensorInfo(i),l}var pL={kernelName:hs,backendName:"webgl",kernelFunc:dL},e_="return (a < 0.) ? b * a : a;",t_=`
2021-02-21 20:07:04 +01:00
vec4 aLessThanZero = vec4(lessThan(a, vec4(0.)));
return (aLessThanZero * (b * a)) + ((vec4(1.0) - aLessThanZero) * a);
2021-02-25 13:50:13 +01:00
`;function fL(e){let{inputs:t,backend:n}=e,{x:r,alpha:a}=t,s=Y().getBool("WEBGL_PACK_BINARY_OPERATIONS")?new Ju(t_,r.shape,a.shape):new gl(e_,r.shape,a.shape);return n.runWebGLProgram(s,[r,a],r.dtype)}var mL={kernelName:vs,backendName:"webgl",kernelFunc:fL},n_="if (isnan(x)) return x;",AL=`
2021-02-21 20:07:04 +01:00
if (isnan(a)) return a;
if (isnan(b)) return b;
2021-02-25 13:50:13 +01:00
`,yL=`
2021-02-21 20:07:04 +01: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-02-25 13:50:13 +01:00
`;function Xe({opSnippet:e,packedOpSnippet:t,cpuKernelImpl:n,dtype:r}){return({inputs:a,backend:s})=>{let{x:i}=a,o=s,l=r||i.dtype;if(o.shouldExecuteOnCPU([i])&&n!=null){let h=o.texData.get(i.dataId),d=n(h.values,l);return o.makeTensorInfo(i.shape,l,d)}let u=Y().getBool("WEBGL_PACK_UNARY_OPERATIONS")&&t!=null,c;return u?c=new yl(i.shape,t):c=new $a(i.shape,e),o.runWebGLProgram(c,[i],l)}}function Qt({opSnippet:e,packedOpSnippet:t,checkOutOfBounds:n=!1,supportsComplex:r=!1,cpuKernelImpl:a,dtype:s}){return({inputs:i,backend:o})=>{let{a:l,b:u}=i,c=o;if(r&&l.dtype==="complex64"){let f=c.texData.get(l.dataId),m=c.texData.get(u.dataId),[A,y]=[[f.complexTensorInfos.real,m.complexTensorInfos.real],[f.complexTensorInfos.imag,m.complexTensorInfos.imag]].map(w=>{let[_,b]=w,x={dataId:_.dataId,dtype:_.dtype,shape:l.shape},N={dataId:b.dataId,dtype:b.dtype,shape:u.shape},T=new gl(e,l.shape,u.shape);return c.runWebGLProgram(T,[x,N],Jn(_.dtype,b.dtype))}),g=Ma({inputs:{real:A,imag:y},backend:c});return c.disposeIntermediateTensorInfo(A),c.disposeIntermediateTensorInfo(y),g}let h=s||Jn(l.dtype,u.dtype);if(c.shouldExecuteOnCPU([l,u])&&a!=null){let f=c.texData.get(l.dataId),m=c.texData.get(u.dataId),[A,y]=a(l.shape,u.shape,f.values,m.values,h),g=c.makeTensorInfo(y,h),w=c.texData.get(g.dataId);return w.values=A,g}let d=Y().getBool("WEBGL_PACK_BINARY_OPERATIONS")&&t!=null,p;return d?p=new Ju(t,l.shape,u.shape,n):p=new gl(e,l.shape,u.shape),c.runWebGLProgram(p,[l,u],h)}}function Yd(e,t=!1){if(e==="linear")return t?Yz:qz;if(e==="relu")return t?Qz:Kz;if(e==="elu")return t?Jz:Xz;if(e==="relu6")return t?eL:Zz;if(e==="prelu")return t?t_:e_;if(e==="leakyrelu")return t?Qw:Jw;throw new Error(`Activation ${e} has not been implemented for the WebGL backend.`)}var r_=class{constructor(e,t,n,r=!1,a=!1,s=!1,i=null,o=!1,l=!1){this.variableNames=["matrixA","matrixB"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=n;let u=r?e[1]:e[2],c=Math.ceil(u/2),h=r?"i * 2, rc.y":"rc.y, i * 2",d=a?"rc.z, i * 2":"i * 2, rc.z",p=r?["a.xxyy","a.zzww"]:["a.xxzz","a.yyww"],f=a?["b.xzxz","b.ywyw"]:["b.xyxy","b.zwzw"],m="",A="";i&&(o?m=`vec4 activation(vec4 a) {
2021-02-21 20:07:04 +01:00
vec4 b = getPreluActivationWeightsAtOutCoords();
${i}
}`:l?m=`vec4 activation(vec4 a) {
vec4 b = getLeakyreluAlphaAtOutCoords();
${i}
}`:m=`vec4 activation(vec4 x) {
${i}
2021-02-25 13:50:13 +01:00
}`,A="result = activation(result);");let y=s?"result += getBiasAtOutCoords();":"";s&&this.variableNames.push("bias"),o&&this.variableNames.push("preluActivationWeights"),l&&this.variableNames.push("leakyreluAlpha");let g="rc.x",w="rc.x";e[0]<t[0]?g=`int(min(float(rc.x), ${e[0]-1}.))`:t[0]<e[0]&&(w=`int(min(float(rc.x), ${t[0]-1}.))`),this.userCode=`
2021-02-21 20:07:04 +01:00
${m}
2021-02-25 13:50:13 +01:00
const float sharedDimension = ${c}.0;
2021-02-21 20:07:04 +01:00
vec4 dot2x2ARowBCol(ivec3 rc) {
vec4 result = vec4(0);
2021-02-25 13:50:13 +01:00
for (int i = 0; i < ${c}; i++) {
2021-02-21 20:07:04 +01:00
int batchA = ${g};
2021-02-25 13:50:13 +01:00
int batchB = ${w};
2021-02-21 20:07:04 +01:00
vec4 a = getMatrixA(batchA, ${h});
vec4 b = getMatrixB(batchB, ${d});
// These swizzled products need to be separately added.
// See: https://github.com/tensorflow/tfjs/issues/1735
result += (${p[0]} * ${f[0]});
result += (${p[1]} * ${f[1]});
2020-11-12 18:58:55 +01:00
}
2021-02-21 20:07:04 +01:00
return result;
2020-11-10 02:13:38 +01:00
}
2021-02-21 20:07:04 +01:00
void main() {
ivec3 rc = getOutputCoords();
vec4 result = dot2x2ARowBCol(rc);
${y}
${A}
setOutput(result);
2021-01-03 16:41:56 +01:00
}
2021-02-25 13:50:13 +01:00
`}},a_={REAL:"return areal * breal - aimag * bimag;",IMAG:"return areal * bimag + aimag * breal;"},s_=class{constructor(e,t,n){this.variableNames=["AReal","AImag","BReal","BImag"],this.outputShape=C.assertAndGetBroadcastShape(t,n),this.userCode=`
2021-02-21 20:07:04 +01:00
float binaryOpComplex(
float areal, float aimag, float breal, float bimag) {
${e}
2021-02-21 20:06:13 +01:00
}
2021-02-21 20:07:04 +01:00
void main() {
float areal = getARealAtOutCoords();
float aimag = getAImagAtOutCoords();
float breal = getBRealAtOutCoords();
float bimag = getBImagAtOutCoords();
setOutput(binaryOpComplex(areal, aimag, breal, bimag));
2020-12-15 14:44:42 +01:00
}
2021-02-25 13:50:13 +01:00
`}},i_="return a * b;";function o_(e){let{inputs:t,backend:n}=e,{a:r,b:a}=t,s=C.upcastType(r.dtype,a.dtype);if(r.dtype==="complex64"){let o=n.texData.get(r.dataId),l=n.texData.get(a.dataId),u=new s_(a_.REAL,r.shape,a.shape),c=new s_(a_.IMAG,r.shape,a.shape),h=[{dataId:o.complexTensorInfos.real.dataId,dtype:o.complexTensorInfos.real.dtype,shape:r.shape},{dataId:o.complexTensorInfos.imag.dataId,dtype:o.complexTensorInfos.imag.dtype,shape:r.shape},{dataId:l.complexTensorInfos.real.dataId,dtype:l.complexTensorInfos.real.dtype,shape:a.shape},{dataId:l.complexTensorInfos.imag.dataId,dtype:l.complexTensorInfos.imag.dtype,shape:a.shape}],d=n.runWebGLProgram(u,h,"float32"),p=n.runWebGLProgram(c,h,"float32"),f=Ma({inputs:{real:d,imag:p},backend:n});return n.disposeIntermediateTensorInfo(d),n.disposeIntermediateTensorInfo(p),f}if(n.shouldExecuteOnCPU([r,a])){let o=n.texData.get(r.dataId),l=n.texData.get(a.dataId),[u,c]=Iz(r.shape,a.shape,o.values,l.values,s),h=n.makeTensorInfo(c,s),d=n.texData.get(h.dataId);return d.values=u,h}let i;return Y().getBool("WEBGL_PACK_BINARY_OPERATIONS")?i=new Ju(i_,r.shape,a.shape):i=new gl(i_,r.shape,a.shape),n.runWebGLProgram(i,[r,a],s)}var gL={kernelName:xs,backendName:"webgl",kernelFunc:o_};function xL(e,t,n){let r=[ai(e.shape),...si(e.shape)],a={dtype:e.dtype,shape:r,dataId:e.dataId},s=[ai(t),...si(t)],i=new Gw(s,r),o=!0,l=n.runWebGLProgram(i,[a],e.dtype,null,o);return{dataId:l.dataId,shape:t,dtype:l.dtype}}function ye(e){let{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{shape:s}=r,i=n,o=v.sizeFromShape(a.shape),l=v.inferFromImplicitShape(s,o),u=v.sizeFromShape(l);v.assert(o===u,()=>`The new shape (${l}) has ${u} elements and the old shape (${a.shape}) has ${o} elements. The new shape and old shape must have the same number of elements.`);let c=i.texData.get(a.dataId);return c.isPacked&&!qu(a.shape,l)&&!(c.texture!==null&&qu(c.shape,l))?xL(a,l,i):(i.incRef(a.dataId),{dataId:a.dataId,shape:l,dtype:a.dtype})}var wL={kernelName:_o,backendName:"webgl",kernelFunc:ye},l_=class{constructor(e,t){this.variableNames=["x"];let{windowSize:n,batchSize:r,inSize:a,outSize:s}=e;this.outputShape=[r,s];let i=Math.floor(n/4)*4,o=n%4,l="sumValue += dot(values, ones);";if(t!=null){let c=1/t;l=`sumValue += dot(values * ${v.isInt(c)?c.toPrecision(2):c}, ones);`}let u="";a%n>0&&(u=`
2021-02-21 20:07:04 +01:00
if (inIdx < 0 || inIdx >= ${a}) {
return 0.0;
2021-02-21 20:06:13 +01:00
}
2021-02-21 20:07:04 +01:00
`),this.userCode=`
const vec4 ones = vec4(1.0, 1.0, 1.0, 1.0);
float getValue(int batch, int inIdx) {
2021-02-25 13:50:13 +01:00
${u}
2021-02-21 20:07:04 +01:00
return getX(batch, inIdx);
2021-02-21 20:06:13 +01:00
}
2021-02-21 20:07:04 +01:00
void main() {
ivec2 coords = getOutputCoords();
int batch = coords[0];
int outIdx = coords[1];
int inOffset = outIdx * ${n};
float sumValue = 0.0;
for (int i = 0; i < ${i}; i += 4) {
int inIdx = inOffset + i;
vec4 values = vec4(
getValue(batch, inIdx),
getValue(batch, inIdx + 1),
getValue(batch, inIdx + 2),
getValue(batch, inIdx + 3)
);
${l}
2020-11-10 02:13:38 +01:00
}
2021-02-21 20:07:04 +01:00
int inIdx = inOffset + ${i};
if (${o===1}) {
vec4 values = vec4(getValue(batch, inIdx), 0.0, 0.0, 0.0);
${l}
} else if (${o===2}) {
vec4 values = vec4(
getValue(batch, inIdx),
getValue(batch, inIdx + 1), 0.0, 0.0);
${l}
} else if (${o===3}) {
vec4 values = vec4(
getValue(batch, inIdx),
getValue(batch, inIdx + 1),
getValue(batch, inIdx + 2), 0.0);
${l}
2021-02-21 20:06:13 +01:00
}
2021-02-21 20:07:04 +01:00
setOutput(sumValue);
2021-02-21 20:06:13 +01:00
}
2021-02-25 13:50:13 +01:00
`}},_L=class{constructor(e,t){this.variableNames=["x"];let{windowSize:n,batchSize:r,inSize:a,outSize:s}=e;this.outputShape=[r,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 u=Math.floor(n/4)*4,c=n%4,h=`
2021-02-21 20:07:04 +01: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];
} else {
minMaxValue = ${o}(values, minMaxValue);
2021-01-03 16:41:56 +01:00
}
2021-02-21 20:07:04 +01:00
`,d="vec4";t==="all"?(i="1.0",h=`
bool reducedAllValue = all(values);
float floatedReducedAllValue = float(reducedAllValue);
allValue = float(allValue >= 1.0 && floatedReducedAllValue >= 1.0);
`,d="bvec4"):t==="any"&&(i="0.0",h=`
bool reducedAnyValue = any(values);
float floatedReducedAnyValue = float(reducedAnyValue);
anyValue = float(anyValue >= 1.0 || floatedReducedAnyValue >= 1.0);
`,d="bvec4");let p="";a%n>0&&(p=`
if (inIdx < 0 || inIdx >= ${a}) {
return initializationValue;
2021-02-21 20:06:13 +01:00
}
2021-02-21 20:07:04 +01:00
`),this.userCode=`
const float initializationValue = ${i};
const vec4 ones = vec4(1.0, 1.0, 1.0, 1.0);
float getValue(int batch, int inIdx) {
${p}
return getX(batch, inIdx);
2021-02-21 20:06:13 +01:00
}
2021-02-21 20:07:04 +01:00
void main() {
ivec2 coords = getOutputCoords();
int batch = coords[0];
int outIdx = coords[1];
int inOffset = outIdx * ${n};
vec4 minMaxValue = vec4(${i});
float prodValue = 1.0;
float sumValue = 0.0;
float allValue = 1.0;
float anyValue = 0.0;
2021-02-25 13:50:13 +01:00
for (int i = 0; i < ${u}; i += 4) {
2021-02-21 20:07:04 +01:00
int inIdx = inOffset + i;
${d} values = ${d}(
getValue(batch, inIdx),
getValue(batch, inIdx + 1),
getValue(batch, inIdx + 2),
getValue(batch, inIdx + 3)
);
${h}
2021-01-03 16:41:56 +01:00
}
2021-02-21 20:07:04 +01:00
2021-02-25 13:50:13 +01:00
int inIdx = inOffset + ${u};
if (${c===1}) {
2021-02-21 20:07:04 +01:00
${d} values = ${d}(
getValue(batch, inIdx),
initializationValue,
initializationValue,
initializationValue
);
${h}
2021-02-25 13:50:13 +01:00
} else if (${c===2}) {
2021-02-21 20:07:04 +01:00
${d} values = ${d}(
getValue(batch, inIdx),
getValue(batch, inIdx + 1),
initializationValue,
initializationValue
);
${h}
2021-02-25 13:50:13 +01:00
} else if (${c===3}) {
2021-02-21 20:07:04 +01:00
${d} values = ${d}(
getValue(batch, inIdx),
getValue(batch, inIdx + 1),
getValue(batch, inIdx + 2),
initializationValue
);
${h}
2021-01-03 16:41:56 +01:00
}
2021-02-21 20:07:04 +01:00
setOutput(${l});
2021-01-03 16:41:56 +01:00
}
2021-02-25 13:50:13 +01:00
`}};function bL(e){let t=[];for(;t.length===0||t[t.length-1].outSize!==1;){let n=t.length?t[t.length-1].outSize:e[1],r=C.computeOptimalWindowSize(n);t.push({inSize:n,windowSize:r,outSize:Math.ceil(n/r)})}return t}function ui(e,t,n,r){let a=bL(e.shape),s=e;for(let i=0;i<a.length;i++){let{inSize:o,windowSize:l,outSize:u}=a[i],c,h;n==="mean"?c=i===0?new l_({windowSize:l,inSize:o,batchSize:e.shape[0],outSize:u},o):new l_({windowSize:l,inSize:o,batchSize:e.shape[0],outSize:u}):c=new _L({windowSize:l,inSize:o,batchSize:e.shape[0],outSize:u},n),h=s,s=r.runWebGLProgram(c,[s],t),h.dataId!==e.dataId&&r.disposeIntermediateTensorInfo(h)}return s}var kL=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 r=lt(this.rank),a=vL(t);this.userCode=`
2021-02-21 20:07:04 +01:00
void main() {
${r} resRC = getOutputCoords();
setOutput(getA(${a}));
}
2021-02-25 13:50:13 +01:00
`}};function vL(e){let t=e.length;if(t>6)throw Error(`Transpose for rank ${t} is not yet supported`);let n=["resRC.x","resRC.y","resRC.z","resRC.w","resRC.u","resRC.v"],r=new Array(t);for(let a=0;a<e.length;a++)r[e[a]]=n[a];return r.join()}var IL=class{constructor(e,t){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0;let n=new Array(e.length);for(let u=0;u<n.length;u++)n[u]=e[t[u]];if(this.outputShape=n,this.rank=n.length,this.rank>6)throw Error(`Packed transpose for rank ${this.rank} is not yet supported.`);let r=lt(this.rank),a=Hw("rc",this.rank),s=new Array(this.rank);for(let u=0;u<t.length;u++)s[t[u]]=a[u];let i=`vec2(${s.slice(-2).join()})`,o=`++${a[this.rank-1]} < ${n[this.rank-1]}`,l=`getChannel(getA(${s.join()}), ${i})`;this.userCode=`
2021-02-21 20:07:04 +01:00
void main() {
${r} rc = getOutputCoords();
vec4 result = vec4(0.);
result[0] = ${l};
if(${o}) {
result[1] = ${l};
}
--${a[this.rank-1]};
if(++${a[this.rank-2]} < ${n[this.rank-2]}) {
result[2] = ${l};
if(${o}) {
result[3] = ${l};
2021-02-21 20:06:13 +01:00
}
2021-01-03 16:41:56 +01:00
}
2021-02-21 20:07:04 +01:00
setOutput(result);
}
2021-02-25 13:50:13 +01:00
`}};function Jd(e,t,n){let r=Y().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new IL(e.shape,t):new kL(e.shape,t);return n.runWebGLProgram(r,[e],e.dtype)}function NL(e,t,n,r){let a=t,s=e.shape.length,i=v.parseAxisParam(a,e.shape),o=i,l=C.getAxesPermutation(o,s),u=l!=null,c=e;u&&(c=Jd(e,l,r),o=C.getInnerMostAxes(o.length,s)),C.assertAxesAreInnerMostDims("sum",o,s);let[h,d]=C.computeOutAndReduceShapes(c.shape,o),p=h;n&&(p=C.expandShapeToKeepDim(h,i));let f=v.sizeFromShape(d),m=v.sizeFromShape(e.shape)/f,A=ye({inputs:{x:c},attrs:{shape:[m,f]},backend:r}),y=zh(e.dtype),g=ui(A,y,"sum",r),w=ye({inputs:{x:g},attrs:{shape:p},backend:r});return r.disposeIntermediateTensorInfo(A),r.disposeIntermediateTensorInfo(g),u&&r.disposeIntermediateTensorInfo(c),w}function TA(e){let{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{axis:s,keepDims:i}=r;return NL(a,s,i,n)}var SL={kernelName:$s,backendName:"webgl",kernelFunc:TA};function wn(e){let{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{perm:s}=r,i=n,o=a.shape.length,l=new Array(o);for(let c=0;c<l.length;c++)l[c]=a.shape[s[c]];let u;if(i.shouldExecuteOnCPU([a])){let c=i.texData.get(a.dataId).values,h=NA(c,a.shape,a.dtype,s,l);u=i.makeTensorInfo(l,a.dtype);let d=i.texData.get(u.dataId);d.values=h}else u=Jd(a,s,i);return u}var TL={kernelName:Ls,backendName:"webgl",kernelFunc:wn},u_=1e3;function Qd({a:e,b:t,transposeA:n,transposeB:r,backend:a,bias:s=null,preluActivationWeights:i=null,leakyreluAlpha:o=0,activation:l=null}){let u=e.shape.length,c=t.shape.length,h=n?e.shape[u-2]:e.shape[u-1],d=r?t.shape[c-1]:t.shape[c-2],p=n?e.shape[u-1]:e.shape[u-2],f=r?t.shape[c-2]:t.shape[c-1],m=e.shape.slice(0,-2),A=t.shape.slice(0,-2),y=v.sizeFromShape(m),g=v.sizeFromShape(A),w=y===g||y===1||g===1;v.assert(u>=2&&c>=2&&w,()=>`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 (${A}).`);let _=(y>g?e.shape.slice(0,-2):t.shape.slice(0,-2)).concat([p,f]);v.assert(h===d,()=>`Error in matMul: inner shapes (${h}) and (${d}) of Tensors with shapes ${e.shape} and ${t.shape} and transposeA=${n} and transposeB=${r} must match.`);let b=n?[y,h,p]:[y,p,h],x=r?[g,f,d]:[g,d,f],N=ye({inputs:{x:e},backend:a,attrs:{shape:b}}),T=ye({inputs:{x:t},backend:a,attrs:{shape:x}}),E=[N,T],$=Math.max(y,g),D=n?N.shape[1]:N.shape[2],L=s!=null,P=i!=null,U=l==="leakyrelu",j=l!=null?Yd(l,!0):null,X=L||P||U||j!=null,G;if((p===1||f===1)&&D>u_&&X===!1){let J=N,se=T;n&&(J=wn({inputs:{x:N},backend:a,attrs:{perm:[0,2,1]}}),E.push(J)),r&&(se=wn({inputs:{x:T},backend:a,attrs:{perm:[0,2,1]}}),E.push(se));let te=f!==1,le=f===1,Q=J;te&&(Q=ye({inputs:{x:J},backend:a,attrs:{shape:[$,D,1]}}),E.push(Q));let de=f===1?2:1,ue=se;le&&(ue=ye({inputs:{x:se},backend:a,attrs:{shape:[$,1,D]}}),E.push(ue));let me=o_({inputs:{a:Q,b:ue},backend:a});G=TA({inputs:{x:me},backend:a,attrs:{axis:de,keepDims:!0}}),E.push(me)}else{let J=Jn(e.dtype,t.dtype),se=new r_(b,x,[$,p,f],n,r,L,j,P,U),te=[N,T];if(s!=null&&te.push(s),P&&te.push(i),U){let le=a.makeTensorInfo([],"float32",v.createScalarValue(o,"float32"));te.push(le),E.push(le)}G=a.runWebGLProgram(se,te,J)}let ee=ye({inputs:{x:G},backend:a,attrs:{shape:_}});E.push(G);for(let J of E)a.disposeIntermediateTensorInfo(J);return ee}function EL(e){let{inputs:t,backend:n,attrs:r}=e,{a,b:s,bias:i,preluActivationWeights:o}=t,{transposeA:l,transposeB:u,activation:c,leakyreluAlpha:h}=r;return Qd({a,b:s,transposeA:l,transposeB:u,backend:n,bias:i,preluActivationWeights:o,leakyreluAlpha:h,activation:c})}var CL={kernelName:Ps,backendName:"webgl",kernelFunc:EL},c_="return abs(x);";function RL(e){let{inputs:t,backend:n}=e,{x:r}=t;if(n.shouldExecuteOnCPU([r])&&r.dtype!=="complex64"){let s=n.texData.get(r.dataId),i=jw(s.values);return n.makeTensorInfo(r.shape,r.dtype,i)}let a;return Y().getBool("WEBGL_PACK_UNARY_OPERATIONS")?a=new yl(r.shape,c_):a=new $a(r.shape,c_),n.runWebGLProgram(a,[r],r.dtype)}var FL={kernelName:Oi,backendName:"webgl",kernelFunc:RL},$L=mr+`
2021-02-21 20:07:04 +01:00
if (abs(x) > 1.) {
return NAN;
}
return acos(x);
2021-02-25 13:50:13 +01:00
`,ML=Xe({opSnippet:$L}),DL={kernelName:zi,backendName:"webgl",kernelFunc:ML},OL=mr+`
2021-02-21 20:07:04 +01:00
if (x < 1.0) return NAN;
2021-02-25 13:50:13 +01:00
return log(x + sqrt(x * x - 1.0));`,zL=Xe({opSnippet:OL}),LL={kernelName:Li,backendName:"webgl",kernelFunc:zL},h_="return a + b;",PL=Qt({opSnippet:h_,packedOpSnippet:h_,supportsComplex:!0,cpuKernelImpl:cz}),WL={kernelName:Aa,backendName:"webgl",kernelFunc:PL},BL=class{constructor(e,t){this.outputShape=[],this.outputShape=e,this.variableNames=t.map((a,s)=>`T${s}`);let n=[];this.variableNames.forEach(a=>{n.push(`float v${a} = get${a}AtOutCoords();`)});let r=this.variableNames.map(a=>`v${a}`).join(" + ");this.userCode=`
2021-02-21 20:07:04 +01:00
void main() {
${n.join(`
`)}
float result = ${r};
setOutput(result);
2021-01-03 16:41:56 +01:00
}
2021-02-25 13:50:13 +01:00
`}},VL=class{constructor(e,t){this.outputShape=[],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=e,this.variableNames=t.map((a,s)=>`T${s}`);let n=[];this.variableNames.forEach(a=>{n.push(`vec4 v${a} = get${a}AtOutCoords();`)});let r=this.variableNames.map(a=>`v${a}`).join(" + ");this.userCode=`
2021-02-21 20:07:04 +01:00
void main() {
${n.join(`
`)}
vec4 result = ${r};
setOutput(result);
2021-01-03 16:41:56 +01:00
}
2021-02-25 13:50:13 +01:00
`}};function ep(e){let{inputs:t,backend:n}=e,r=t;if(r.length===1)return Fn({inputs:{x:r[0]},backend:n});if(r.length>Y().get("WEBGL_MAX_TEXTURES_IN_SHADER")){let o=Math.floor(r.length/2),l=ep({inputs:r.slice(0,o),backend:n}),u=ep({inputs:r.slice(o),backend:n});return ep({inputs:[l,u],backend:n})}let a=r.map(o=>o.dtype).reduce((o,l)=>Jn(o,l)),s=r.map(o=>o.shape),i=Y().getBool("WEBGL_PACK")?new VL(r[0].shape,s):new BL(r[0].shape,s);return n.runWebGLProgram(i,r,a)}var UL={kernelName:qa,backendName:"webgl",kernelFunc:ep};function jL(e){let{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{axis:s,keepDims:i}=r,o=a.shape.length,l=v.parseAxisParam(s,a.shape),u=l,c=C.getAxesPermutation(u,o),h=a;c!=null&&(h=wn({inputs:{x:a},backend:n,attrs:{perm:c}}),u=C.getInnerMostAxes(u.length,o)),C.assertAxesAreInnerMostDims("all",u,o);let[d,p]=C.computeOutAndReduceShapes(h.shape,u),f=v.sizeFromShape(p),m=ye({inputs:{x:h},backend:n,attrs:{shape:[-1,f]}}),A=ui(m,m.dtype,"all",n),y;if(i){let g=C.expandShapeToKeepDim(d,l);y=ye({inputs:{x:A},backend:n,attrs:{shape:g}})}else y=ye({inputs:{x:A},backend:n,attrs:{shape:d}});return n.disposeIntermediateTensorInfo(m),n.disposeIntermediateTensorInfo(A),c!=null&&n.disposeIntermediateTensorInfo(h),y}var HL={kernelName:sh,backendName:"webgl",kernelFunc:jL};function GL(e){let{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{axis:s,keepDims:i}=r,o=a.shape.length,l=v.parseAxisParam(s,a.shape),u=l,c=C.getAxesPermutation(u,o),h=a;c!=null&&(h=wn({inputs:{x:a},backend:n,attrs:{perm:c}}),u=C.getInnerMostAxes(u.length,o)),C.assertAxesAreInnerMostDims("any",u,o);let[d,p]=C.computeOutAndReduceShapes(h.shape,u),f=v.sizeFromShape(p),m=ye({inputs:{x:h},backend:n,attrs:{shape:[-1,f]}}),A=ui(m,m.dtype,"any",n),y;if(i){let g=C.expandShapeToKeepDim(d,l);y=ye({inputs:{x:A},backend:n,attrs:{shape:g}})}else y=ye({inputs:{x:A},backend:n,attrs:{shape:d}});return n.disposeIntermediateTensorInfo(m),n.disposeIntermediateTensorInfo(A),c!=null&&n.disposeIntermediateTensorInfo(h),y}var qL={kernelName:ih,backendName:"webgl",kernelFunc:GL},XL=class{constructor(e,t,n){this.variableNames=["A"];let{windowSize:r,batchSize:a,outSize:s}=e;n||this.variableNames.push("bestIndicesA"),this.outputShape=[a,s];let i=t==="max"?">":"<",o=n?"inOffset + i;":"round(getBestIndicesA(batch, inOffset + i));";this.userCode=`
2021-02-21 20:07:04 +01:00
void main() {
ivec2 coords = getOutputCoords();
int batch = coords[0];
int outIdx = coords[1];
int inOffset = outIdx * ${r};
int bestIndex = inOffset;
float bestValue = getA(batch, bestIndex);
for (int i = 0; i < ${r}; i++) {
int inIdx = ${o};
float candidate = getA(batch, inIdx);
if (candidate ${i} bestValue) {
bestValue = candidate;
bestIndex = inIdx;
2021-02-21 20:06:13 +01:00
}
2021-01-03 16:41:56 +01:00
}
2021-02-21 20:07:04 +01:00
setOutput(float(bestIndex));
2021-02-21 20:06:13 +01:00
}
2021-02-25 13:50:13 +01:00
`}},KL=class{constructor(e,t,n,r){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,v.assert(e.length>2,()=>`Packed arg${n.charAt(0).toUpperCase()+n.slice(1)} supports only inputs with rank above 2.`);let a=e[e.length-1],s=Math.ceil(a/t);this.outputShape=e.slice(0,-1),s>1&&this.outputShape.push(s),r||this.variableNames.push("bestIndicesA");let i=this.outputShape,o=i.length,l=lt(o),u=cn("coords",o),c,h;if(s===1){h=o+1;let N=lt(h);c=`
${N} sourceLocR = ${N}(${u.join()}, 0);
++${u[o-1]};
${N} sourceLocG = ${N}(${u.join()}, 0);
++${u[o-2]};
${N} sourceLocA = ${N}(${u.join()}, 0);
--${u[o-1]};
${N} sourceLocB = ${N}(${u.join()}, 0);
--${u[o-2]};`}else h=o,c=`
2021-02-21 20:07:04 +01:00
${l} sourceLocR = coords;
2021-02-25 13:50:13 +01:00
++${u[o-1]};
2021-02-21 20:07:04 +01:00
${l} sourceLocG = coords;
2021-02-25 13:50:13 +01:00
++${u[o-2]};
2021-02-21 20:07:04 +01:00
${l} sourceLocA = coords;
2021-02-25 13:50:13 +01:00
--${u[o-1]};
2021-02-21 20:07:04 +01:00
${l} sourceLocB = coords;
2021-02-25 13:50:13 +01:00
--${u[o-2]};`;let d=["x","y","z","w","u","v"].slice(0,h),p="."+d[h-1],f=d.map(N=>"int "+N),m=cn("sourceLocR",h-1).concat("inIdx.r"),A=cn("sourceLocG",h-1).concat("inIdx.g"),y=cn("sourceLocB",h-1).concat("inIdx.b"),g=cn("sourceLocA",h-1).concat("inIdx.a"),w=n==="max"?"greaterThan":"lessThan",_=r?"":`
2021-02-21 20:07:04 +01:00
inIdx = round(vec4(getBestIndicesAChannel(${m.join()}),
getBestIndicesAChannel(${A.join()}),
getBestIndicesAChannel(${y.join()}),
2021-02-25 13:50:13 +01:00
getBestIndicesAChannel(${g.join()})));`,b=`vec4(
2021-02-21 20:07:04 +01:00
getAChannel(${m.join()}),
hasNextCol ? getAChannel(${A.join()}) : 0.,
hasNextRow ? getAChannel(${y.join()}) : 0.,
2021-02-25 13:50:13 +01:00
hasNextRow && hasNextCol ? getAChannel(${g.join()}) : 0.)`,x=r?"":`
2021-02-21 20:07:04 +01:00
float getBestIndicesAChannel(${f.join()}) {
return getChannel(getBestIndicesA(${d.join()}),
vec2(${d.slice(-2).join()}));
}`;this.userCode=`
float getAChannel(${f.join()}) {
return getChannel(getA(${d.join()}),
vec2(${d.slice(-2).join()}));
}
2021-02-25 13:50:13 +01:00
${x}
2021-02-21 20:07:04 +01:00
void main() {
${l} coords = getOutputCoords();
2021-02-25 13:50:13 +01:00
bool hasNextCol = ${u[o-1]} < ${i[o-1]-1};
bool hasNextRow = ${u[o-2]} < ${i[o-2]-1};
${c}
2021-02-21 20:07:04 +01:00
ivec4 srcIdx = ivec4(sourceLocR${p}, sourceLocG${p},
sourceLocB${p}, sourceLocA${p}) * ${t};
ivec4 inIdx = srcIdx;
vec4 bestIndex = vec4(inIdx);
2021-02-25 13:50:13 +01:00
vec4 bestValue = ${b};
2021-02-21 20:07:04 +01:00
for (int i = 0; i < ${t}; i++) {
inIdx = srcIdx;
2021-02-25 13:50:13 +01:00
${_}
vec4 candidate = ${b};
2021-02-21 20:07:04 +01:00
bvec4 nan = isnan(candidate);
bvec4 replace = bvec4(
2021-02-25 13:50:13 +01:00
vec4(${w}(candidate, bestValue)) * (vec4(1.0) - vec4(nan)));
2021-02-21 20:07:04 +01: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++;
2021-01-03 16:41:56 +01:00
}
2021-02-21 20:07:04 +01:00
setOutput(bestIndex);
2021-01-03 16:41:56 +01:00
}
2021-02-25 13:50:13 +01:00
`}};function d_(e,t,n,r=null){let a=t.shape[0],s=t.shape[1];r!=null&&(a=r.shape[0],s=r.shape[1]);let i=C.computeOptimalWindowSize(s),o={windowSize:i,inSize:s,batchSize:a,outSize:Math.ceil(s/i)},l=new XL(o,n,r==null),u=[t];r!=null&&u.push(r);let c=e.runWebGLProgram(l,u,"int32");if(c.shape[1]===1)return c;let h=d_(e,t,n,c);return e.disposeIntermediateTensorInfo(c),h}function p_(e,t,n,r=null){let a=r!=null?r.shape:t.shape,s=a[a.length-1],i=C.computeOptimalWindowSize(s),o=new KL(a,i,n,r==null),l=r==null?[t]:[t,r],u=e.runWebGLProgram(o,l,"int32");if(u.shape.length===t.shape.length){let c=p_(e,t,n,u);return e.disposeIntermediateTensorInfo(u),c}return u}function f_(e,t,n,r){let a=[n];if(C.assertAxesAreInnerMostDims("arg"+r.charAt(0).toUpperCase()+r.slice(1),a,t.shape.length),!Y().getBool("WEBGL_PACK_REDUCE")||t.shape.length<=2){let s=[],[i,o]=C.computeOutAndReduceShapes(t.shape,a),l=v.sizeFromShape(o),u=ye({inputs:{x:t},backend:e,attrs:{shape:[-1,l]}});s.push(u);let c=d_(e,u,r);s.push(c);let h=ye({inputs:{x:c},backend:e,attrs:{shape:i}});return s.forEach(d=>e.disposeIntermediateTensorInfo(d)),h}return p_(e,t,r)}function ZL(e){let{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{axis:s}=r,i=v.parseAxisParam(s,a.shape),o=C.getAxesPermutation(i,a.shape.length),l=a,u=[];o!=null&&(l=wn({inputs:{x:a},backend:n,attrs:{perm:o}}),u.push(l),i=C.getInnerMostAxes(i.length,l.shape.length)),C.assertAxesAreInnerMostDims("argMax",[i[0]],l.shape.length);let c=f_(n,l,i[0],"max");return u.forEach(h=>n.disposeIntermediateTensorInfo(h)),c}var YL={kernelName:Xa,backendName:"webgl",kernelFunc:ZL};function JL(e){let{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{axis:s}=r,i=v.parseAxisParam(s,a.shape),o=C.getAxesPermutation(i,a.shape.length),l=a,u=[];o!=null&&(l=wn({inputs:{x:a},backend:n,attrs:{perm:o}}),u.push(l),i=C.getInnerMostAxes(i.length,l.shape.length)),C.assertAxesAreInnerMostDims("argMin",[i[0]],l.shape.length);let c=f_(n,l,i[0],"min");return u.forEach(h=>n.disposeIntermediateTensorInfo(h)),c}var QL={kernelName:Hl,backendName:"webgl",kernelFunc:JL},eP=mr+`
2021-02-21 20:07:04 +01:00
if (abs(x) > 1.) {
return NAN;
}
return asin(x);
2021-02-25 13:50:13 +01:00
`,tP=Xe({opSnippet:eP}),nP={kernelName:Pi,backendName:"webgl",kernelFunc:tP},rP=mr+"return log(x + sqrt(x * x + 1.0));",aP=Xe({opSnippet:rP}),sP={kernelName:Wi,backendName:"webgl",kernelFunc:aP},iP=mr+`
2021-02-21 20:07:04 +01:00
return atan(x);
2021-02-25 13:50:13 +01:00
`,oP=Xe({opSnippet:iP}),lP={kernelName:Bi,backendName:"webgl",kernelFunc:oP},uP=AL+`
2021-02-21 20:07:04 +01:00
return atan(a, b);
2021-02-25 13:50:13 +01:00
`,cP=`
2021-02-21 20:07:04 +01:00
vec4 result = atan(a, b);
vec4 isNaN = min(vec4(isnan(a)) + vec4(isnan(b)), vec4(1.0));
2021-02-25 13:50:13 +01:00
`+yL+`
2021-02-21 20:07:04 +01:00
return result;
2021-02-25 13:50:13 +01:00
`,hP=Qt({opSnippet:uP,packedOpSnippet:cP}),dP={kernelName:Ui,backendName:"webgl",kernelFunc:hP},pP=mr+`
2021-02-21 20:07:04 +01:00
if ((x < -1.0) || (x > 1.0)) return NAN;
2021-02-25 13:50:13 +01:00
return (log(1.0 + x) - log(1.0 - x)) / 2.0;`,fP=Xe({opSnippet:pP}),mP={kernelName:Vi,backendName:"webgl",kernelFunc:fP},Qu=class{constructor(e,t,n,r=!1,a=!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,u=e.dilationWidth,c=e.effectiveFilterHeight,h=e.effectiveFilterWidth,d=e.padInfo.top,p=e.padInfo.left;this.outputShape=e.outShape;let f=t==="avg",m=`((batch * ${e.inHeight} + xR) * ${e.inWidth} + xC) * ${e.inChannels} + d`,A=`(xR * ${e.inWidth} + xC) * ${e.inChannels} + d`,y="0.0";if(f||(y="-1.0 / 1e-20"),n){let N=">=";this.userCode=`
2021-02-21 20:07:04 +01:00
const ivec2 strides = ivec2(${i}, ${o});
const ivec2 pads = ivec2(${d}, ${p});
void main() {
ivec4 coords = getOutputCoords();
int batch = coords[0];
int d = coords[3];
ivec2 xRCCorner = coords.yz * strides - pads;
int xRCorner = xRCCorner.x;
int xCCorner = xRCCorner.y;
// max/min x(?, ?, d) to get y(yR, yC, d).
// ? = to be determined
float minMaxValue = 0.0;
float minMaxValueFound = 0.0;
int minMaxPosition = 0;
float avgValue = 0.0;
2021-02-25 13:50:13 +01:00
for (int wR = 0; wR < ${c};
2021-02-21 20:07:04 +01:00
wR += ${l}) {
int xR = xRCorner + wR;
if (xR < 0 || xR >= ${e.inHeight}) {
continue;
2021-01-03 16:41:56 +01:00
}
2021-02-21 20:07:04 +01:00
for (int wC = 0; wC < ${h};
2021-02-25 13:50:13 +01:00
wC += ${u}) {
2021-02-21 20:07:04 +01: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);
if (value ${N} currMinMaxValue) {
minMaxValue = value;
minMaxValueFound = 1.0;
minMaxPosition = ${r?a?m:A:`wR * ${h} + wC`};
}
2021-01-03 16:41:56 +01:00
}
}
2021-02-21 20:07:04 +01:00
setOutput(float(minMaxPosition));
2021-02-21 20:06:13 +01:00
}
2021-02-25 13:50:13 +01:00
`;return}let g="max",w=`${t}(${t}(${t}(minMaxValue[0], minMaxValue[1]), minMaxValue[2]), minMaxValue[3])`;t==="avg"&&(w="avgValue / count");let _=Math.floor(s/4)*4,b=s%4,x=`
2021-02-21 20:07:04 +01:00
if (${f}) {
avgValue += dot(values, ones);
} else {
minMaxValue = ${g}(values, minMaxValue);
2021-02-21 20:06:13 +01:00
}
2021-02-21 20:07:04 +01:00
`;this.userCode=`
const ivec2 strides = ivec2(${i}, ${o});
const ivec2 pads = ivec2(${d}, ${p});
const float initializationValue = ${y};
const vec4 ones = vec4(1.0, 1.0, 1.0, 1.0);
float count = 0.0;
float getValue(int batch, int xR, int xC, int d) {
if (xC < 0 || xC >= ${e.inWidth}) {
return initializationValue;
2021-01-03 16:23:45 +01:00
}
2021-02-21 20:07:04 +01:00
count += 1.0;
return getX(batch, xR, xC, d);
2021-02-21 20:06:13 +01:00
}
2021-02-21 20:07:04 +01:00
void main() {
ivec4 coords = getOutputCoords();
int batch = coords[0];
int d = coords[3];
ivec2 xRCCorner = coords.yz * strides - pads;
int xRCorner = xRCCorner.x;
int xCCorner = xRCCorner.y;
// max/min x(?, ?, d) to get y(yR, yC, d).
// ? = to be determined
vec4 minMaxValue = vec4(${y});
float avgValue = 0.0;
count = 0.0;
2021-02-25 13:50:13 +01:00
for (int wR = 0; wR < ${c};
2021-02-21 20:07:04 +01:00
wR += ${l}) {
int xR = xRCorner + wR;
if (xR < 0 || xR >= ${e.inHeight}) {
continue;
2020-12-16 20:49:14 +01:00
}
2021-02-21 20:07:04 +01:00
2021-02-25 13:50:13 +01:00
for (int wC = 0; wC < ${_}; wC += 4) {
int xC = xCCorner + wC * ${u};
2021-02-21 20:07:04 +01:00
vec4 values = vec4(
getValue(batch, xR, xC, d),
2021-02-25 13:50:13 +01:00
getValue(batch, xR, xC + ${u}, d),
getValue(batch, xR, xC + 2 * ${u}, d),
getValue(batch, xR, xC + 3 * ${u}, d)
2021-02-21 20:07:04 +01:00
);
2021-02-25 13:50:13 +01:00
${x}
2020-11-16 21:51:46 +01:00
}
2021-02-21 20:07:04 +01:00
2021-02-25 13:50:13 +01:00
int xC = xCCorner + ${_};
if (${b===1}) {
2021-02-21 20:07:04 +01:00
vec4 values = vec4(
getValue(batch, xR, xC, d),
initializationValue,
initializationValue,
initializationValue
);
2021-02-25 13:50:13 +01:00
${x}
} else if (${b===2}) {
2021-02-21 20:07:04 +01:00
vec4 values = vec4(
getValue(batch, xR, xC, d),
2021-02-25 13:50:13 +01:00
getValue(batch, xR, xC + ${u}, d),
2021-02-21 20:07:04 +01:00
initializationValue,
initializationValue
);
2021-02-25 13:50:13 +01:00
${x}
} else if (${b===3}) {
2021-02-21 20:07:04 +01:00
vec4 values = vec4(
getValue(batch, xR, xC, d),
2021-02-25 13:50:13 +01:00
getValue(batch, xR, xC + ${u}, d),
getValue(batch, xR, xC + 2 * ${u}, d),
2021-02-21 20:07:04 +01:00
initializationValue
);
2021-02-25 13:50:13 +01:00
${x}
2020-11-16 21:51:46 +01:00
}
2020-11-10 02:13:38 +01:00
}
2021-02-25 13:50:13 +01:00
setOutput(${w});
2020-11-12 18:58:55 +01:00
}
2021-02-25 13:50:13 +01:00
`}},EA=class{constructor(e,t,n,r=!1,a=!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,u=e.dilationDepth,c=e.dilationHeight,h=e.dilationWidth,d=e.effectiveFilterDepth,p=e.effectiveFilterHeight,f=e.effectiveFilterWidth,m=e.padInfo.front,A=e.padInfo.top,y=e.padInfo.left;this.outputShape=e.outShape;let g=t==="avg",w="0.0";if(g||(w="-1.0 / 1e-20"),n){let E=">=";this.userCode=`
2021-02-21 20:07:04 +01:00
const ivec3 strides =
ivec3(${i}, ${o}, ${l});
const ivec3 pads = ivec3(${m}, ${A}, ${y});
void main() {
ivec5 coords = getOutputCoords();
int batch = coords.x;
int ch = coords.u;
ivec3 xCorner = ivec3(coords.y, coords.z, coords.w) * strides - pads;
int xDCorner = xCorner.x;
int xRCorner = xCorner.y;
int xCCorner = xCorner.z;
// max/min x(?, ?, ?, ch) to get y(yD, yR, yC, ch).
// ? = to be determined
float minMaxValue = 0.0;
float minMaxValueFound = 0.0;
int minMaxPosition = 0;
for (int wD = 0; wD < ${d};
2021-02-25 13:50:13 +01:00
wD += ${u}) {
2021-02-21 20:07:04 +01:00
int xD = xDCorner + wD;
if (xD < 0 || xD >= ${e.inDepth}) {
continue;
}
for (int wR = 0; wR < ${p};
2021-02-25 13:50:13 +01:00
wR += ${c}) {
2021-02-21 20:07:04 +01:00
int xR = xRCorner + wR;
if (xR < 0 || xR >= ${e.inHeight}) {
continue;
}
for (int wC = 0; wC < ${f};
wC += ${h}) {
int xC = xCCorner + wC;
if (xC < 0 || xC >= ${e.inWidth}) {
continue;
}
float value = getX(batch, xD, xR, xC, ch);
// If a min / max value has already been found, use it. If not,
// use the current value.
float currMinMaxValue = mix(
value, minMaxValue, minMaxValueFound);
if (value ${E} currMinMaxValue) {
minMaxValue = value;
minMaxValueFound = 1.0;
minMaxPosition = ${r?a?`(((batch * ${e.inDepth} + xD) * ${e.inHeight} + xR) * ${e.inWidth} + xC) * ${e.inChannels} + ch`:`((xD * ${e.inHeight} + xR) * ${e.inWidth} + xC) * ${e.inChannels} + ch`:`wD * ${p} * ${f} +
wR * ${f} + wC`};
}
}
2021-02-21 20:06:13 +01:00
}
}
2021-02-21 20:07:04 +01:00
setOutput(float(minMaxPosition));
2020-12-16 20:49:14 +01:00
}
2021-02-25 13:50:13 +01:00
`;return}let _="max",b=`${t}(${t}(${t}(minMaxValue[0], minMaxValue[1]), minMaxValue[2]), minMaxValue[3])`;t==="avg"&&(b="avgValue / count");let x=Math.floor(s/4)*4,N=s%4,T=`
2021-02-21 20:07:04 +01:00
if (${g}) {
avgValue += dot(values, ones);
} else {
2021-02-25 13:50:13 +01:00
minMaxValue = ${_}(values, minMaxValue);
2020-11-10 02:13:38 +01:00
}
2021-02-21 20:07:04 +01:00
`;this.userCode=`
const ivec3 strides =
ivec3(${i}, ${o}, ${l});
const ivec3 pads = ivec3(${m}, ${A}, ${y});
2021-02-25 13:50:13 +01:00
const float initializationValue = ${w};
2021-02-21 20:07:04 +01:00
const vec4 ones = vec4(1.0, 1.0, 1.0, 1.0);
float count = 0.0;
float getValue(int batch, int xD, int xR, int xC, int ch) {
if (xC < 0 || xC >= ${e.inWidth}) {
return initializationValue;
2021-01-03 16:41:56 +01:00
}
2021-02-21 20:07:04 +01:00
count += 1.0;
return getX(batch, xD, xR, xC, ch);
2021-02-21 20:06:13 +01:00
}
2021-02-21 20:07:04 +01: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(?, ?, ?, d) to get y(yD, yR, yC, ch).
// ? = to be determined
2021-02-25 13:50:13 +01:00
vec4 minMaxValue = vec4(${w});
2021-02-21 20:07:04 +01:00
float avgValue = 0.0;
count = 0.0;
for (int wD = 0; wD < ${d};
2021-02-25 13:50:13 +01:00
wD += ${u}) {
2021-02-21 20:07:04 +01:00
int xD = xDCorner + wD;
if (xD < 0 || xD >= ${e.inDepth}) {
continue;
2020-12-16 20:49:14 +01:00
}
2021-02-21 20:07:04 +01:00
for (int wR = 0; wR < ${p};
2021-02-25 13:50:13 +01:00
wR += ${c}) {
2021-02-21 20:07:04 +01:00
int xR = xRCorner + wR;
if (xR < 0 || xR >= ${e.inHeight}) {
continue;
}
2021-02-25 13:50:13 +01:00
for (int wC = 0; wC < ${x}; wC += 4) {
2021-02-21 20:07:04 +01:00
int xC = xCCorner + wC * ${h};
vec4 values = vec4(
getValue(batch, xD, xR, xC, ch),
getValue(batch, xD, xR, xC + ${h}, ch),
getValue(batch, xD, xR, xC + 2 * ${h}, ch),
getValue(batch, xD, xR, xC + 3 * ${h}, ch)
);
${T}
}
2021-02-25 13:50:13 +01:00
int xC = xCCorner + ${x};
2021-02-21 20:07:04 +01:00
if (${N===1}) {
vec4 values = vec4(
getValue(batch, xD, xR, xC, ch),
initializationValue,
initializationValue,
initializationValue
);
${T}
} else if (${N===2}) {
vec4 values = vec4(
getValue(batch, xD, xR, xC, ch),
getValue(batch, xD, xR, xC + ${h}, ch),
initializationValue,
initializationValue
);
${T}
} else if (${N===3}) {
vec4 values = vec4(
getValue(batch, xD, xR, xC, ch),
getValue(batch, xD, xR, xC + ${h}, ch),
getValue(batch, xD, xR, xC + 2 * ${h}, ch),
initializationValue
);
${T}
}
2020-12-16 20:49:14 +01:00
}
2021-02-25 13:50:13 +01:00
setOutput(${b});
2021-02-21 20:06:13 +01:00
}
}
2021-02-25 13:50:13 +01:00
`}};function AP(e){let{inputs:t,backend:n,attrs:r}=e,{x:a}=t;hl(a,"avgPool");let{filterSize:s,strides:i,pad:o,dimRoundingMode:l}=r,u=1;v.assert(C.eitherStridesOrDilationsAreOne(i,u),()=>`Error in avgPool: Either strides or dilations must be 1. Got strides ${i} and dilations '${u}'`);let c=C.computePool2DInfo(a.shape,s,i,u,o,l);if(c.filterWidth===1&&c.filterHeight===1&&v.arraysEqual(c.inShape,c.outShape))return Fn({inputs:{x:a},backend:n});let h=new Qu(c,"avg",!1);return n.runWebGLProgram(h,[a],"float32")}var yP={kernelName:Ka,backendName:"webgl",kernelFunc:AP};function gP(e){let{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{filterSize:s,strides:i,pad:o,dimRoundingMode:l,dataFormat:u}=r,c=[1,1,1],h=C.computePool3DInfo(a.shape,s,i,c,o,l,u),d=new EA(h,"avg",!1);return n.runWebGLProgram(d,[a],"float32")}var xP={kernelName:Gl,backendName:"webgl",kernelFunc:gP},wP=class{constructor(e){this.variableNames=["dy"],this.outputShape=e.inShape;let t=e.filterHeight,n=e.filterWidth,r=e.strideHeight,a=e.strideWidth,s=e.dilationHeight,i=e.dilationWidth,o=e.effectiveFilterHeight,l=e.effectiveFilterWidth,u=o-1-e.padInfo.top,c=l-1-e.padInfo.left,h=1/(t*n);this.userCode=`
const ivec2 pads = ivec2(${u}, ${c});
2021-02-21 20:07:04 +01:00
const float avgMultiplier = float(${h});
void main() {
ivec4 coords = getOutputCoords();
int b = coords[0];
int d = coords[3];
ivec2 dyRCCorner = coords.yz - pads;
int dyRCorner = dyRCCorner.x;
int dyCCorner = dyRCCorner.y;
// Convolve dy(?, ?, d) with pos mask(:, :, d) to get dx(xR, xC, d).
// ? = to be determined. : = across all values in that axis.
float dotProd = 0.0;
for (int wR = 0; wR < ${o};
wR += ${s}) {
float dyR = float(dyRCorner + wR) / ${r}.0;
if (dyR < 0.0 || dyR >= ${e.outHeight}.0 || fract(dyR) > 0.0) {
continue;
2021-02-21 20:06:13 +01:00
}
2021-02-21 20:07:04 +01:00
int idyR = int(dyR);
for (int wC = 0; wC < ${l};
wC+= ${i}) {
float dyC = float(dyCCorner + wC) / ${a}.0;
if (dyC < 0.0 || dyC >= ${e.outWidth}.0 ||
fract(dyC) > 0.0) {
continue;
2020-12-16 20:49:14 +01:00
}
2021-02-21 20:07:04 +01:00
int idyC = int(dyC);
float dyValue = getDy(b, idyR, idyC, d);
dotProd += dyValue * avgMultiplier;
2020-12-15 14:44:42 +01:00
}
2020-12-16 20:49:14 +01:00
}
2021-02-21 20:07:04 +01:00
setOutput(dotProd);
2021-02-21 20:06:13 +01:00
}
2021-02-25 13:50:13 +01:00
`}},_P=class{constructor(e){this.variableNames=["dy"],this.outputShape=e.inShape;let t=e.filterDepth,n=e.filterHeight,r=e.filterWidth,a=e.strideDepth,s=e.strideHeight,i=e.strideWidth,o=e.dilationDepth,l=e.dilationHeight,u=e.dilationWidth,c=e.effectiveFilterDepth,h=e.effectiveFilterHeight,d=e.effectiveFilterWidth,p=c-1-e.padInfo.front,f=h-1-e.padInfo.top,m=d-1-e.padInfo.left,A=1/(t*n*r);this.userCode=`
2021-02-21 20:07:04 +01:00
const ivec3 pads = ivec3(${p}, ${f}, ${m});
const float avgMultiplier = float(${A});
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-02-25 13:50:13 +01:00
for (int wD = 0; wD < ${c};
2021-02-21 20:07:04 +01:00
wD += ${o}) {
float dyD = float(dyDCorner + wD) / ${a}.0;
if (dyD < 0.0 || dyD >= ${e.outDepth}.0 || fract(dyD) > 0.0) {
continue;
2021-01-03 16:41:56 +01:00
}
2021-02-21 20:07:04 +01:00
int idyD = int(dyD);
for (int wR = 0; wR < ${h};
wR += ${l}) {
float dyR = float(dyRCorner + wR) / ${s}.0;
if (dyR < 0.0 || dyR >= ${e.outHeight}.0 ||
fract(dyR) > 0.0) {
continue;
}
int idyR = int(dyR);
for (int wC = 0; wC < ${d};
2021-02-25 13:50:13 +01:00
wC += ${u}) {
2021-02-21 20:07:04 +01:00
float dyC = float(dyCCorner + wC) / ${i}.0;
if (dyC < 0.0 || dyC >= ${e.outWidth}.0 ||
fract(dyC) > 0.0) {
continue;
}
int idyC = int(dyC);
float dyValue = getDy(batch, idyD, idyR, idyC, ch);
dotProd += dyValue * avgMultiplier;
}
2021-01-03 16:41:56 +01:00
}
2020-12-16 20:49:14 +01:00
}
2021-02-21 20:07:04 +01:00
setOutput(dotProd);
2021-01-03 16:41:56 +01:00
}
2021-02-25 13:50:13 +01:00
`}};function bP(e){let{inputs:t,backend:n,attrs:r}=e,{dy:a,input:s}=t,i=s,{filterSize:o,strides:l,pad:u,dimRoundingMode:c}=r,h=[1,1,1],d=C.computePool3DInfo(i.shape,o,l,h,u,c),p=new _P(d);return n.runWebGLProgram(p,[a],i.dtype)}var vP={kernelName:lh,backendName:"webgl",kernelFunc:bP};function kP(e){let{inputs:t,backend:n,attrs:r}=e,{dy:a,input:s}=t,i=s;hl([a,s],"avgPoolGrad");let{filterSize:o,strides:l,pad:u}=r,c=C.computePool2DInfo(i.shape,o,l,1,u),h=new wP(c);return n.runWebGLProgram(h,[a],i.dtype)}var IP={kernelName:oh,backendName:"webgl",kernelFunc:kP};function NP(e){let{inputs:t,backend:n,attrs:r}=e,{a,b:s}=t,{transposeA:i,transposeB:o}=r;return Qd({a,b:s,transposeA:i,transposeB:o,backend:n})}var SP={kernelName:Za,backendName:"webgl",kernelFunc:NP},TP=class{constructor(e,t,n,r,a,s){this.outputShape=[],this.variableNames=["x","mean","variance"],C.assertAndGetBroadcastShape(e,t),C.assertAndGetBroadcastShape(e,n);let i="0.0";r!=null&&(C.assertAndGetBroadcastShape(e,r),this.variableNames.push("offset"),i="getOffsetAtOutCoords()");let o="1.0";a!=null&&(C.assertAndGetBroadcastShape(e,a),this.variableNames.push("scale"),o="getScaleAtOutCoords()"),this.outputShape=e,this.userCode=`
2021-02-21 20:07:04 +01:00
void main() {
float x = getXAtOutCoords();
float mean = getMeanAtOutCoords();
float variance = getVarianceAtOutCoords();
float offset = ${i};
float scale = ${o};
float inv = scale * inversesqrt(variance + float(${s}));
setOutput(dot(vec3(x, -mean, offset), vec3(inv, inv, 1)));
2020-12-15 14:44:42 +01:00
}
2021-02-25 13:50:13 +01:00
`}},EP=class{constructor(e,t,n,r,a,s){this.packedInputs=!0,this.packedOutput=!0,this.variableNames=["x","mean","variance"],C.assertAndGetBroadcastShape(e,t),C.assertAndGetBroadcastShape(e,n);let i="vec4(0.0)";r!=null&&(C.assertAndGetBroadcastShape(e,r),this.variableNames.push("offset"),i="getOffsetAtOutCoords()");let o="vec4(1.0)";a!=null&&(C.assertAndGetBroadcastShape(e,a),this.variableNames.push("scale"),o="getScaleAtOutCoords()"),this.outputShape=e,this.userCode=`
2021-02-21 20:07:04 +01:00
void main() {
vec4 offset = ${i};
vec4 scale = ${o};
vec4 x = getXAtOutCoords();
vec4 mean = getMeanAtOutCoords();
vec4 variance = getVarianceAtOutCoords();
vec4 inv = scale * inversesqrt(variance + vec4(${s}));
setOutput((x - mean) * inv + offset);
2021-01-03 16:41:56 +01:00
}
2021-02-25 13:50:13 +01:00
`}},CP=({inputs:e,backend:t,attrs:n})=>{let{x:r,mean:a,variance:s,offset:i,scale:o}=e;v.assert(a.shape.length===s.shape.length,()=>"Batch normalization gradient requires mean and variance to have equal ranks."),v.assert(i==null||a.shape.length===i.shape.length,()=>"Batch normalization gradient requires mean and offset to have equal ranks."),v.assert(o==null||a.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 u=[r,a,s],c=null;i!=null&&(c=i.shape,u.push(i));let h=null;o!=null&&(h=o.shape,u.push(o));let d=Y().getBool("WEBGL_PACK_NORMALIZATION")?new EP(r.shape,a.shape,s.shape,c,h,l):new TP(r.shape,a.shape,s.shape,c,h,l);return t.runWebGLProgram(d,u,u[0].dtype)},RP={kernelName:ls,backendName:"webgl",kernelFunc:CP},$P=class{constructor(e){this.variableNames=["source"],this.outputShape=e,this.rank=e.length;let t=lt(this.rank),n=`uniform int start[${this.rank}];`,r=FP(this.rank),a,s=e.map((i,o)=>`sourceLoc.${CA[o]} = start[${o}] + coords.${CA[o]};`);a=`
2021-02-21 20:07:04 +01:00
${t} sourceLoc;
${t} coords = getOutputCoords();
${s.join(`
`)}
`,this.userCode=`
${n}
void main() {
${a}
setOutput(getSource(${r}));
}
2021-02-25 13:50:13 +01:00
`}getCustomSetupFunc(e){if(e.length!==this.rank)throw Error(`The rank (${this.rank}) of the program must match the length of start (${e.length})`);return(t,n)=>{this.startLoc==null&&(this.startLoc=t.getUniformLocationNoThrow(n,"start"),this.startLoc==null)||t.gl.uniform1iv(this.startLoc,e)}}},CA=["x","y","z","w","u","v"];function FP(e){if(e===1)return"sourceLoc";if(e<=6)return CA.slice(0,e).map(t=>"sourceLoc."+t).join(",");throw Error(`Slicing for rank ${e} is not yet supported`)}var MP=class{constructor(e){this.variableNames=["source"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=e,this.rank=e.length;let t=lt(this.rank),n=cn("coords",this.rank),r=cn("sourceLoc",this.rank),a=this.rank===1?"sourceLoc":`vec2(${r.slice(-2).join()})`,s=`getChannel(getSource(${r.join()}), ${a})`,i=`
2021-02-21 20:07:04 +01:00
result.x = ${s};
if (++${n[this.rank-1]} < ${e[this.rank-1]}) {
++${r[this.rank-1]};
result.y = ${s};
--${r[this.rank-1]};
}
`,o=this.rank===1?"":`
--${n[this.rank-1]};
if (++${n[this.rank-2]} < ${e[this.rank-2]}) {
++${r[this.rank-2]};
result.z = ${s};
if (++${n[this.rank-1]} < ${e[this.rank-1]}) {
++${r[this.rank-1]};
result.w = ${s};
}
}
`,l=this.rank<=4?`sourceLoc = coords +
2021-02-25 13:50:13 +01:00
${t}(${e.map((u,c)=>`start[${c}]`).join()});`:e.map((u,c)=>`${r[c]} = ${n[c]} + start[${c}];`).join(`
2021-02-21 20:07:04 +01:00
`);this.userCode=`
uniform int start[${this.rank}];
void main() {
${t} coords = getOutputCoords();
${t} sourceLoc;
${l}
vec4 result = vec4(0.);
${i}
${o}
setOutput(result);
2021-01-03 16:41:56 +01:00
}
2021-02-25 13:50:13 +01:00
`}getCustomSetupFunc(e){if(e.length!==this.rank)throw Error(`The rank (${this.rank}) of the program must match the length of start (${e.length})`);return(t,n)=>{this.startLoc==null&&(this.startLoc=t.getUniformLocationNoThrow(n,"start"),this.startLoc==null)||t.gl.uniform1iv(this.startLoc,e)}}};function DP(e,t,n,r){let a=r.texData.get(e.dataId),s=r.makeTensorInfo(n,e.dtype),i=r.texData.get(s.dataId);Object.assign(i,a),i.refCount=1,i.shape=n,i.dtype=e.dtype;let o=sn.computeFlatOffset(t,v.computeStrides(e.shape));a.slice&&(o+=a.slice.flatOffset),i.slice={flatOffset:o,origDataId:a.slice&&a.slice.origDataId||e.dataId};let l=r.dataRefCount.get(i.slice.origDataId)||1;return r.dataRefCount.set(i.slice.origDataId,l+1),s}function ec(e){let{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{begin:s,size:i}=r,[o,l]=sn.parseSliceParams(a,s,i);if(sn.assertParamsValid(a,o,l),v.sizeFromShape(l)===0)return n.makeTensorInfo(l,a.dtype,[]);if(n.shouldExecuteOnCPU([a])||a.dtype==="string"){let h=n.texData.get(a.dataId),d=Cz(h.values,o,l,a.shape,a.dtype);return n.makeTensorInfo(l,a.dtype,d)}let{isPacked:u}=n.texData.get(a.dataId),c=sn.isSliceContinous(a.shape,o,l);if(u||!c){let h=Y().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new MP(l):new $P(l),d=h.getCustomSetupFunc(o);return n.runWebGLProgram(h,[a],a.dtype,d)}return n.uploadToGPU(a.dataId),DP(a,o,l,n)}var OP={kernelName:Io,backendName:"webgl",kernelFunc:ec},zP=e=>{let{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{blockShape:s,crops:i}=r;v.assert(a.shape.length<=4,()=>"batchToSpaceND for rank > 4 with a WebGL backend not implemented yet");let o=s.reduce((g,w)=>g*w),l=C.getReshaped(a.shape,s,o),u=C.getPermuted(l.length,s.length),c=C.getReshapedPermuted(a.shape,s,o),h=C.getSliceBeginCoords(i,s.length),d=C.getSliceSize(c,i,s.length),p=[],f=ye({inputs:{x:a},backend:n,attrs:{shape:l}}),m=wn({inputs:{x:f},backend:n,attrs:{perm:u}}),A=ye({inputs:{x:m},backend:n,attrs:{shape:c}}),y=ec({inputs:{x:A},backend:n,attrs:{begin:h,size:d}});return p.push(f),p.push(m),p.push(A),p.forEach(g=>n.disposeIntermediateTensorInfo(g)),y},LP={kernelName:ql,backendName:"webgl",kernelFunc:zP};function PP(e){let{inputs:t,backend:n,attrs:r}=e,{x:a,weights:s}=t,{size:i}=r,o=n.readSync(a.dataId),l=n.readSync(s.dataId),u=Uw(o,l,s.dtype,s.shape,i);return n.makeTensorInfo([i],s.dtype,u)}var WP={kernelName:uh,backendName:"webgl",kernelFunc:PP},BP="return float(a != b);",m_=Qt({opSnippet:BP,dtype:"bool"}),VP={kernelName:po,backendName:"webgl",kernelFunc:m_};function tc(e){let{inputs:t,backend:n}=e,{input:r}=t,a=n.texData.get(r.dataId);return Fn({inputs:{x:a.complexTensorInfos.real},backend:n})}var UP={kernelName:Ch,backendName:"webgl",kernelFunc:tc},jP="return float(int(x));";function HP(e,t){let n=new $a(e.shape,jP),r=t.runWebGLProgram(n,[e],"int32");return{dataId:r.dataId,shape:r.shape,dtype:r.dtype}}function RA(e){let{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{dtype:s}=r;if(s==="complex64"){if(a.dtype==="complex64")return Fn({inputs:{x:a},backend:n});let i=Ct(a.shape),o=RA({inputs:{x:a},backend:n,attrs:{dtype:"float32"}}),l=Ma({inputs:{real:o,imag:i},backend:n});return i.dispose(),n.disposeIntermediateTensorInfo(o),l}if(a.dtype==="complex64"){let i=tc({inputs:{input:a},backend:n}),o=RA({inputs:{x:i},backend:n,attrs:{dtype:s}});return n.disposeIntermediateTensorInfo(i),o}if(!v.hasEncodingLoss(a.dtype,s)){let i=Fn({inputs:{x:a},backend:n});return{dataId:i.dataId,shape:i.shape,dtype:s}}if(s==="int32")return HP(a,n);if(s==="bool"){let i=n.makeTensorInfo([],"bool",v.getTypedArrayFromDType("bool",1)),o=m_({inputs:{a,b:i},backend:n});return n.disposeIntermediateTensorInfo(i),o}throw new Error(`Error in Cast: failed to cast ${a.dtype} to ${s}`)}var GP={kernelName:Ya,backendName:"webgl",kernelFunc:RA},A_="return ceil(x);",qP=Xe({opSnippet:A_,packedOpSnippet:A_,cpuKernelImpl:dz}),XP={kernelName:Ja,backendName:"webgl",kernelFunc:qP},KP=class{constructor(e){this.variableNames=["A"],this.outputShape=e,this.userCode=`
2021-02-21 20:07:04 +01:00
uniform float minVal;
uniform float maxVal;
void main() {
float value = getAAtOutCoords();
if (isnan(value)) {
setOutput(value);
return;
2021-02-21 20:06:13 +01:00
}
2021-02-21 20:07:04 +01:00
setOutput(clamp(value, minVal, maxVal));
2021-01-03 16:41:56 +01:00
}
2021-02-25 13:50:13 +01:00
`}getCustomSetupFunc(e,t){return(n,r)=>{this.minLoc==null&&(this.minLoc=n.getUniformLocationNoThrow(r,"minVal"),this.maxLoc=n.getUniformLocationNoThrow(r,"maxVal")),n.gl.uniform1f(this.minLoc,e),n.gl.uniform1f(this.maxLoc,t)}}},ZP=class{constructor(e){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=e,this.userCode=`
2021-02-21 20:07:04 +01:00
uniform float minVal;
uniform float maxVal;
void main() {
vec4 value = getAAtOutCoords();
if (any(isnan(value))) {
setOutput(value);
return;
2021-02-21 20:06:13 +01:00
}
2021-02-21 20:07:04 +01:00
setOutput(clamp(value, vec4(minVal), vec4(maxVal)));
2021-02-21 20:06:13 +01:00
}
2021-02-25 13:50:13 +01:00
`}getCustomSetupFunc(e,t){return(n,r)=>{this.minLoc==null&&(this.minLoc=n.getUniformLocationNoThrow(r,"minVal"),this.maxLoc=n.getUniformLocationNoThrow(r,"maxVal")),n.gl.uniform1f(this.minLoc,e),n.gl.uniform1f(this.maxLoc,t)}}};function YP(e){let{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{clipValueMin:s,clipValueMax:i}=r,o;Y().getBool("WEBGL_PACK_CLIP")?o=new ZP(a.shape):o=new KP(a.shape);let l=o.getCustomSetupFunc(s,i);return n.runWebGLProgram(o,[a],a.dtype,l)}var JP={kernelName:ya,backendName:"webgl",kernelFunc:YP},QP=class{constructor(e){this.variableNames=["real","imag"],this.outputShape=e,this.userCode=`
2021-02-21 20:07:04 +01: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-02-21 20:06:13 +01:00
}
2021-02-25 13:50:13 +01:00
`}};function y_(e,t){return{dataId:t.dataId,dtype:t.dtype,shape:e.shape}}function eW(e){let{inputs:t,backend:n}=e,{x:r}=t,a=n.texData.get(r.dataId),s=new QP(r.shape),i=[y_(r,a.complexTensorInfos.real),y_(r,a.complexTensorInfos.imag)];return n.runWebGLProgram(s,i,i[0].dtype)}var tW={kernelName:Xl,backendName:"webgl",kernelFunc:eW},nW=class{constructor(e){this.outputShape=[],this.outputShape=C.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 r=t.length,a=t[t.length-1];n.push(`else setOutput(getT${r}(yR, yC-${a}));`),this.userCode=`
2021-02-21 20:07:04 +01:00
void main() {
ivec2 coords = getOutputCoords();
int yR = coords.x;
int yC = coords.y;
${n.join(`
`)}
2020-12-15 14:44:42 +01:00
}
2021-02-25 13:50:13 +01:00
`}},rW=class{constructor(e,t){this.packedInputs=!0,this.packedOutput=!0,this.outputShape=[],this.outputShape=C.computeOutShape(e,t);let n=this.outputShape,r=n.length,a=lt(r),s=cn("coords",r),i=["x","y","z","w","u","v"].slice(0,r);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],u=i.slice(-2),c=i.join(),h=`if (${l} < ${o[0]}) {
2021-02-21 20:07:04 +01:00
return getChannel(
2021-02-25 13:50:13 +01:00
getT0(${c}), vec2(${u.join()}));
2021-02-21 20:07:04 +01:00
}`;for(let f=1;f<o.length;f++){let m=o[f-1];h+=`
if (${l} < ${o[f]} && ${l} >= ${o[f-1]}) {
return getChannel(
2021-02-25 13:50:13 +01:00
getT${f}(${tp(i,l,m)}),
vec2(${tp(u,l,m)}));
2021-02-21 20:07:04 +01:00
}`}let d=o.length,p=o[o.length-1];h+=`
return getChannel(
2021-02-25 13:50:13 +01:00
getT${d}(${tp(i,l,p)}),
vec2(${tp(u,l,p)}));`,this.userCode=`
2021-02-21 20:07:04 +01:00
float getValue(${i.map(f=>"int "+f)}) {
${h}
2021-02-21 20:06:13 +01:00
}
2021-02-21 20:07:04 +01:00
void main() {
${a} coords = getOutputCoords();
vec4 result = vec4(getValue(${s}), 0., 0., 0.);
${s[r-1]} = ${s[r-1]} + 1;
if (${s[r-1]} < ${n[r-1]}) {
result.g = getValue(${s});
2021-02-21 20:06:13 +01:00
}
2021-02-21 20:07:04 +01:00
${s[r-2]} = ${s[r-2]} + 1;
if (${s[r-2]} < ${n[r-2]}) {
result.a = getValue(${s});
2021-02-21 20:06:13 +01:00
}
2021-02-21 20:07:04 +01:00
${s[r-1]} = ${s[r-1]} - 1;
if (${s[r-2]} < ${n[r-2]} &&
${s[r-1]} < ${n[r-1]}) {
result.b = getValue(${s});
2021-02-21 20:06:13 +01:00
}
2021-02-21 20:07:04 +01:00
setOutput(result);
2021-02-21 20:06:13 +01:00
}
2021-02-25 13:50:13 +01:00
`}};function tp(e,t,n){let r=e.indexOf(t);return e.map((a,s)=>s===r?`${a} - ${n}`:a).join()}function np(e){let{inputs:t,backend:n}=e,{input:r}=t,a=n.texData.get(r.dataId);return Fn({inputs:{x:a.complexTensorInfos.imag},backend:n})}var aW={kernelName:vh,backendName:"webgl",kernelFunc:np};function xl(e,t,n){let r=e[0].dtype;if(r==="complex64"){let u=e.map(f=>tc({inputs:{input:f},backend:n})),c=e.map(f=>np({inputs:{input:f},backend:n})),h=xl(u,t,n),d=xl(c,t,n),p=Ma({inputs:{real:h,imag:d},backend:n});return u.forEach(f=>n.disposeIntermediateTensorInfo(f)),c.forEach(f=>n.disposeIntermediateTensorInfo(f)),n.disposeIntermediateTensorInfo(h),n.disposeIntermediateTensorInfo(d),p}if(r==="string"){let{tensors2D:u,outShape:c}=g_(e,t,n),h=u.map(A=>({vals:n.readSync(A.dataId),shape:A.shape})),d=u[0].shape[0]===1,p=pz(h,c,r,d),f=C.computeOutShape(e.map(A=>A.shape),t),m=n.makeTensorInfo(f,r,p);return u.forEach(A=>n.disposeIntermediateTensorInfo(A)),m}if(e.length>Y().getNumber("WEBGL_MAX_TEXTURES_IN_SHADER")){let u=Math.floor(e.length/2),c=xl(e.slice(0,u),t,n),h=xl(e.slice(u),t,n),d=xl([c,h],t,n);return n.disposeIntermediateTensorInfo(c),n.disposeIntermediateTensorInfo(h),d}if(Y().getBool("WEBGL_PACK_ARRAY_OPERATIONS")&&e[0].shape.length>1){let u=new rW(e.map(c=>c.shape),t);return n.runWebGLProgram(u,e,r)}let{tensors2D:a,outShape:s}=g_(e,t,n),i=new nW(a.map(u=>u.shape)),o=n.runWebGLProgram(i,a,r);a.forEach(u=>n.disposeIntermediateTensorInfo(u));let l=ye({inputs:{x:o},attrs:{shape:s},backend:n});return n.disposeIntermediateTensorInfo(o),l}function g_(e,t,n){let r=C.computeOutShape(e.map(a=>a.shape),t);return{tensors2D:e.map(a=>ye({inputs:{x:a},attrs:{shape:[-1,v.sizeFromShape(a.shape.slice(t))]},backend:n})),outShape:r}}function x_(e){let{inputs:t,backend:n,attrs:r}=e,{axis:a}=r,s=v.parseAxisParam(a,t[0].shape)[0],i=C.computeOutShape(t.map(u=>u.shape),s);if(v.sizeFromShape(i)===0)return n.makeTensorInfo(i,t[0].dtype,[]);let o=t.filter(u=>v.sizeFromShape(u.shape)>0);if(o.length===1)return Fn({inputs:{x:o[0]},backend:n});let l=o.map(u=>u.shape);return C.assertParamsConsistent(l,s),xl(o,s,n)}var sW={kernelName:ji,backendName:"webgl",kernelFunc:x_},w_=class{constructor(e,t=!1,n=null,r=!1,a=!1){this.variableNames=["x","W"],this.outputShape=e.outShape;let s=e.padInfo.top,i=e.padInfo.left,o=e.strideHeight,l=e.strideWidth,u=e.dilationHeight,c=e.dilationWidth,h=e.filterHeight,d=e.filterWidth,p=Math.floor(e.inChannels/4)*4,f=e.inChannels%4,m=e.dataFormat==="channelsLast",A=m?1:2,y=m?2:3,g=m?3:1,w="",_="";n&&(r?w=`float activation(float a) {
2021-02-21 20:07:04 +01:00
float b = getPreluActivationWeightsAtOutCoords();
${n}
2021-02-25 13:50:13 +01:00
}`:a?w=`float activation(float a) {
2021-02-21 20:07:04 +01:00
float b = getLeakyreluAlphaAtOutCoords();
${n}
2021-02-25 13:50:13 +01:00
}`:w=`
2021-02-21 20:07:04 +01:00
float activation(float x) {
${n}
2021-02-21 20:06:13 +01:00
}
2021-02-25 13:50:13 +01:00
`,_="result = activation(result);");let b=t?"result += getBiasAtOutCoords();":"";t&&this.variableNames.push("bias"),r&&this.variableNames.push("preluActivationWeights"),a&&this.variableNames.push("leakyreluAlpha"),this.userCode=`
${w}
2021-02-21 20:07:04 +01:00
const ivec2 strides = ivec2(${o}, ${l});
const ivec2 pads = ivec2(${s}, ${i});
void main() {
ivec4 coords = getOutputCoords();
int batch = coords[0];
int d2 = coords[${g}];
ivec2 xRCCorner =
ivec2(coords[${A}], coords[${y}]) * strides - pads;
int xRCorner = xRCCorner.x;
int xCCorner = xRCCorner.y;
// Convolve x(?, ?, d1) with w(:, :, d1, d2) to get y(yR, yC, d2).
// ? = to be determined. : = across all values in that axis.
float dotProd = 0.0;
for (int wR = 0; wR < ${h}; wR++) {
2021-02-25 13:50:13 +01:00
int xR = xRCorner + wR * ${u};
2021-02-21 20:07:04 +01:00
if (xR < 0 || xR >= ${e.inHeight}) {
continue;
2021-01-03 16:41:56 +01:00
}
2021-02-21 20:07:04 +01:00
for (int wC = 0; wC < ${d}; wC++) {
2021-02-25 13:50:13 +01:00
int xC = xCCorner + wC * ${c};
2021-02-21 20:07:04 +01:00
if (xC < 0 || xC >= ${e.inWidth}) {
2021-02-21 20:06:13 +01:00
continue;
2021-01-03 16:41:56 +01:00
}
2021-02-21 20:07:04 +01:00
for (int d1 = 0; d1 < ${p}; d1 += 4) {
vec4 wValues = vec4(
getW(wR, wC, d1, d2),
getW(wR, wC, d1 + 1, d2),
getW(wR, wC, d1 + 2, d2),
getW(wR, wC, d1 + 3, d2)
);
if (${m}) {
vec4 xValues = vec4(
getX(batch, xR, xC, d1),
getX(batch, xR, xC, d1 + 1),
getX(batch, xR, xC, d1 + 2),
getX(batch, xR, xC, d1 + 3)
);
dotProd += dot(xValues, wValues);
} else {
vec4 xValues = vec4(
getX(batch, d1, xR, xC),
getX(batch, d1 + 1, xR, xC),
getX(batch, d1 + 2, xR, xC),
getX(batch, d1 + 3, xR, xC)
);
dotProd += dot(xValues, wValues);
}
2021-02-21 20:06:13 +01:00
}
2021-02-21 20:07:04 +01:00
if (${f===1}) {
if (${m}) {
dotProd +=
getX(batch, xR, xC, ${p}) *
getW(wR, wC, ${p}, d2);
} else {
dotProd +=
getX(batch, ${p}, xR, xC) *
getW(wR, wC, ${p}, d2);
}
} else if (${f===2}) {
vec2 wValues = vec2(
getW(wR, wC, ${p}, d2),
getW(wR, wC, ${p} + 1, d2)
);
if (${m}) {
vec2 xValues = vec2(
getX(batch, xR, xC, ${p}),
getX(batch, xR, xC, ${p} + 1)
);
dotProd += dot(xValues, wValues);
} else {
vec2 xValues = vec2(
getX(batch, ${p}, xR, xC),
getX(batch, ${p} + 1, xR, xC)
);
dotProd += dot(xValues, wValues);
}
} else if (${f===3}) {
vec3 wValues = vec3(
getW(wR, wC, ${p}, d2),
getW(wR, wC, ${p} + 1, d2),
getW(wR, wC, ${p} + 2, d2)
);
if (${m}) {
vec3 xValues = vec3(
getX(batch, xR, xC, ${p}),
getX(batch, xR, xC, ${p} + 1),
getX(batch, xR, xC, ${p} + 2)
);
dotProd += dot(xValues, wValues);
} else {
vec3 xValues = vec3(
getX(batch, ${p}, xR, xC),
getX(batch, ${p} + 1, xR, xC),
getX(batch, ${p} + 2, xR, xC)
);
dotProd += dot(xValues, wValues);
}
2021-01-03 16:41:56 +01:00
}
}
2021-02-21 20:06:13 +01:00
}
2021-02-21 20:07:04 +01:00
float result = dotProd;
2021-02-25 13:50:13 +01:00
${b}
${_}
2021-02-21 20:07:04 +01:00
setOutput(result);
2021-02-21 20:06:13 +01:00
}
2021-02-25 13:50:13 +01:00
`}},iW=class{constructor(e){this.variableNames=["x","W"],this.outputShape=e.outShape;let t=e.padInfo.front,n=e.padInfo.top,r=e.padInfo.left,a=e.strideDepth,s=e.strideHeight,i=e.strideWidth,o=e.dilationDepth,l=e.dilationHeight,u=e.dilationWidth,c=e.filterDepth,h=e.filterHeight,d=e.filterWidth,p=Math.floor(e.inChannels/4)*4,f=e.inChannels%4;this.userCode=`
2021-02-21 20:07:04 +01:00
const ivec3 strides = ivec3(${a}, ${s}, ${i});
const ivec3 pads = ivec3(${t}, ${n}, ${r});
void main() {
ivec5 coords = getOutputCoords();
int batch = coords.x;
int d2 = coords.u;
ivec3 xFRCCorner = ivec3(coords.y, coords.z, coords.w) * strides - pads;
int xFCorner = xFRCCorner.x;
int xRCorner = xFRCCorner.y;
int xCCorner = xFRCCorner.z;
// Convolve x(?, ?, ?, d1) with w(:, :, :, d1, d2) to get
// y(yF, yR, yC, d2). ? = to be determined. : = across all
// values in that axis.
float dotProd = 0.0;
2021-02-25 13:50:13 +01:00
for (int wF = 0; wF < ${c}; wF++) {
2021-02-21 20:07:04 +01:00
int xF = xFCorner + wF * ${o};
if (xF < 0 || xF >= ${e.inDepth}) {
2020-12-15 14:44:42 +01:00
continue;
}
2021-02-21 20:07:04 +01:00
for (int wR = 0; wR < ${h}; wR++) {
int xR = xRCorner + wR * ${l};
if (xR < 0 || xR >= ${e.inHeight}) {
continue;
}
for (int wC = 0; wC < ${d}; wC++) {
2021-02-25 13:50:13 +01:00
int xC = xCCorner + wC * ${u};
2021-02-21 20:07:04 +01:00
if (xC < 0 || xC >= ${e.inWidth}) {
continue;
}
for (int d1 = 0; d1 < ${p}; d1 += 4) {
vec4 xValues = vec4(
getX(batch, xF, xR, xC, d1),
getX(batch, xF, xR, xC, d1 + 1),
getX(batch, xF, xR, xC, d1 + 2),
getX(batch, xF, xR, xC, d1 + 3)
);
vec4 wValues = vec4(
getW(wF, wR, wC, d1, d2),
getW(wF, wR, wC, d1 + 1, d2),
getW(wF, wR, wC, d1 + 2, d2),
getW(wF, wR, wC, d1 + 3, d2)
);
dotProd += dot(xValues, wValues);
}
if (${f===1}) {
dotProd +=
getX(batch, xF, xR, xC, ${p}) *
getW(wF, wR, wC, ${p}, d2);
} else if (${f===2}) {
vec2 xValues = vec2(
getX(batch, xF, xR, xC, ${p}),
getX(batch, xF, xR, xC, ${p} + 1)
);
vec2 wValues = vec2(
getW(wF, wR, wC, ${p}, d2),
getW(wF, wR, wC, ${p} + 1, d2)
);
dotProd += dot(xValues, wValues);
} else if (${f===3}) {
vec3 xValues = vec3(
getX(batch, xF, xR, xC, ${p}),
getX(batch, xF, xR, xC, ${p} + 1),
getX(batch, xF, xR, xC, ${p} + 2)
);
vec3 wValues = vec3(
getW(wF, wR, wC, ${p}, d2),
getW(wF, wR, wC, ${p} + 1, d2),
getW(wF, wR, wC, ${p} + 2, d2)
);
dotProd += dot(xValues, wValues);
}
2020-12-15 14:44:42 +01:00
}
2021-01-03 16:41:56 +01:00
}
2020-12-15 14:44:42 +01:00
}
2021-02-21 20:07:04 +01:00
setOutput(dotProd);
2021-02-21 20:06:13 +01:00
}
2021-02-25 13:50:13 +01:00
`}},oW=class{constructor(e,t,n){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=e;let{filterWidth:r,inChannels:a,strideWidth:s,strideHeight:i,padInfo:o,outWidth:l,dilationWidth:u,dilationHeight:c,dataFormat:h}=n,{left:d,top:p}=o,f=a*r,m=un(),A=h==="channelsLast",y=A?0:1,g=A?1:2,w="";for(let _=0;_<=1;_++)for(let b=0;b<=1;b++)w+=`
blockIndex = rc.y + ${b};
pos = rc.x + ${_};
2021-02-21 20:07:04 +01:00
if(blockIndex < ${e[1]} && pos < ${e[0]}) {
offsetY = int(blockIndex / (${l})) * ${i} - ${p};
2021-02-25 13:50:13 +01:00
d0 = offsetY + ${c} * (pos / ${f});
2021-02-21 20:07:04 +01:00
if(d0 < ${t[y]} && d0 >= 0) {
offsetX = int(mod(float(blockIndex), ${l}.) * ${s}. - ${d}.);
2021-02-25 13:50:13 +01:00
d1 = offsetX + ${u} * (int(mod(float(pos), ${f}.) / ${a}.));
2021-02-21 20:07:04 +01:00
if(d1 < ${t[g]} && d1 >= 0) {
ch = int(mod(float(pos), ${a}.));
if (${A}) {
innerDims = vec2(d1, ch);
2021-02-25 13:50:13 +01:00
result[${_*2+b}] = getChannel(
2021-02-21 20:07:04 +01:00
getA(d0, int(innerDims.x),
int(innerDims.y)), innerDims);
} else {
innerDims = vec2(d0, d1);
2021-02-25 13:50:13 +01:00
result[${_*2+b}] = getChannel(
2021-02-21 20:07:04 +01:00
getA(ch, int(innerDims.x),
int(innerDims.y)), innerDims);
}
}
}
2020-12-15 14:44:42 +01:00
}
2021-02-21 20:07:04 +01:00
`;this.userCode=`
void main() {
ivec2 rc = getOutputCoords();
vec4 result = vec4(0);
int blockIndex, pos, offsetY, d0, offsetX, d1, ch;
vec2 innerDims;
2021-02-25 13:50:13 +01:00
${w}
2021-02-21 20:07:04 +01:00
${m.output} = result;
2021-02-21 20:06:13 +01:00
}
2021-02-25 13:50:13 +01:00
`}};function __({x:e,filter:t,convInfo:n,backend:r,bias:a=null,preluActivationWeights:s=null,leakyreluAlpha:i=0,activation:o=null}){let l=e.shape,u=r.texData.get(e.dataId),c=n.inChannels,h=l[0]*l[1]*l[2],d=n.outChannels,p=n.dataFormat==="channelsLast",f=!1,m=!1,A,y=[],g=(h===1||d===1)&&c>u_,w=l[2]%2!=0&&!!u.isPacked;if(g||!Y().getBool("WEBGL_LAZILY_UNPACK")||!Y().getBool("WEBGL_PACK_BINARY_OPERATIONS")||!w){let _=p?l[0]*l[1]*l[2]:l[0]*l[2]*l[3],b=ye({inputs:{x:e},backend:r,attrs:{shape:[1,_,n.inChannels]}}),x=ye({inputs:{x:t},backend:r,attrs:{shape:[1,n.inChannels,n.outChannels]}}),N=Qd({a:b,b:x,transposeA:f,transposeB:m,backend:r,bias:a,activation:o,preluActivationWeights:s,leakyreluAlpha:i});A=ye({inputs:{x:N},backend:r,attrs:{shape:n.outShape}}),y.push(b),y.push(x),y.push(N)}else{let _=p?l[0]*l[1]*(l[2]+1):l[0]*l[2]*(l[3]+1),b={dataId:e.dataId,shape:[1,_,n.inChannels],dtype:e.dtype},x=u.shape;u.shape=u.shape.slice(),u.shape[u.shape.length-2]++,v.assert(qu(u.shape,b.shape),()=>`packed reshape ${u.shape} to ${b.shape} isn't free`);let N=ye({inputs:{x:t},backend:r,attrs:{shape:[1,n.inChannels,n.outChannels]}});y.push(N);let T=Qd({a:b,b:N,backend:r,transposeA:f,transposeB:m,bias:a,activation:o,preluActivationWeights:s,leakyreluAlpha:i}),E=r.texData.get(T.dataId);v.assert(E.isPacked,()=>"batchMatMul result is expected to be packed"),u.shape=x,E.shape=n.outShape,A=Fn({inputs:{x:T},backend:r}),A.shape=n.outShape,y.push(T)}for(let _ of y)r.disposeIntermediateTensorInfo(_);return A}function b_({x:e,filter:t,convInfo:n,backend:r,bias:a=null,preluActivationWeights:s=null,leakyreluAlpha:i=0,activation:o=null}){let{filterWidth:l,filterHeight:u,inChannels:c,outWidth:h,outHeight:d,dataFormat:p}=n,f=p==="channelsLast",m=l*u*c,A=d*h,y=[m,A],g=!0,w=!1,_=[],b=ye({inputs:{x:e},backend:r,attrs:{shape:e.shape.slice(1)}}),x=ye({inputs:{x:t},backend:r,attrs:{shape:[1,m,v.sizeFromShape(t.shape)/m]}});_.push(b),_.push(x);let N=new oW(y,b.shape,n),T=r.runWebGLProgram(N,[b],"float32"),E=ye({inputs:{x:T},backend:r,attrs:{shape:[1,y[0],y[1]]}});_.push(T),_.push(E);let $=a!=null,D=s!=null,L=o==="leakyrelu",P=o?Yd(o,!0):null,U=new r_(E.shape,x.shape,[1,A,n.outChannels],g,w,$,P,D,L),j=[E,x];if(a&&j.push(a),D&&j.push(s),L){let J=r.makeTensorInfo([],"float32",v.createScalarValue(i,"float32"));j.push(J),_.push(J)}let X=r.runWebGLProgram(U,j,"float32"),G=f?[1,d,h,n.outChannels]:[1,n.outChannels,d,h],ee=ye({inputs:{x:X},backend:r,attrs:{shape:G}});_.push(X);for(let J of _)r.disposeIntermediateTensorInfo(J);return ee}function lW(e){let{inputs:t,backend:n,attrs:r}=e,{x:a,filter:s}=t,{strides:i,pad:o,dataFormat:l,dilations:u,dimRoundingMode:c}=r,h=C.convertConv2DDataFormat(l),d=C.computeConv2DInfo(a.shape,s.shape,i,u,o,c,!1,h),p;if(d.filterHeight===1&&d.filterWidth===1&&d.dilationHeight===1&&d.dilationWidth===1&&d.strideHeight===1&&d.strideWidth===1&&(d.padInfo.type==="SAME"||d.padInfo.type==="VALID"))p=__({x:a,filter:s,convInfo:d,backend:n});else if(Y().getBool("WEBGL_CONV_IM2COL")&&a.shape[0]===1)p=b_({x:a,filter:s,convInfo:d,backend:n});else{let m=new w_(d);p=n.runWebGLProgram(m,[a,s],"float32")}let f=ye({inputs:{x:p},backend:n,attrs:{shape:d.outShape}});return n.disposeIntermediateTensorInfo(p),f}var uW={kernelName:Qa,backendName:"webgl",kernelFunc:lW},cW=class{constructor(e){this.variableNames=["x","dy"],this.outputShape=e.filterShape;let t=e.strideHeight,n=e.strideWidth,r=e.padInfo.top,a=e.padInfo.left,s=e.dataFormat==="channelsLast";this.userCode=`
2021-02-21 20:07:04 +01: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++) {
int xR = wR + yR * ${t} - ${r};
if (xR < 0 || xR >= ${e.inHeight}) {
continue;
}
for (int yC = 0; yC < ${e.outWidth}; yC++) {
int xC = wC + yC * ${n} - ${a};
if (xC < 0 || xC >= ${e.inWidth}) {
continue;
}
if (${s}) {
float dyValue = getDy(b, yR, yC, d2);
float xValue = getX(b, xR, xC, d1);
dotProd += (xValue * dyValue);
} else {
float dyValue = getDy(b, d2, yR, yC);
float xValue = getX(b, d1, xR, xC);
dotProd += (xValue * dyValue);
}
}
2021-01-03 16:41:56 +01:00
}
2020-11-16 21:51:46 +01:00
}
2021-02-21 20:07:04 +01:00
setOutput(dotProd);
2020-12-16 20:49:14 +01:00
}
2021-02-25 13:50:13 +01:00
`}},hW=class{constructor(e){this.variableNames=["dy","W"],this.outputShape=e.inShape;let t=e.filterHeight,n=e.filterWidth,r=e.strideHeight,a=e.strideWidth,s=e.dataFormat==="channelsLast",i=t-1-e.padInfo.top,o=n-1-e.padInfo.left,l=s?1:2,u=s?2:3,c=s?3:1;this.userCode=`
2021-02-21 20:07:04 +01:00
const ivec2 pads = ivec2(${i}, ${o});
void main() {
ivec4 coords = getOutputCoords();
int batch = coords[0];
2021-02-25 13:50:13 +01:00
int d1 = coords[${c}];
2021-02-21 20:07:04 +01:00
2021-02-25 13:50:13 +01:00
ivec2 dyCorner = ivec2(coords[${l}], coords[${u}]) - pads;
2021-02-21 20:07:04 +01: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++) {
float dyR = float(dyRCorner + wR) / ${r}.0;
if (dyR < 0.0 || dyR >= ${e.outHeight}.0 || fract(dyR) > 0.0) {
continue;
2021-01-03 16:41:56 +01:00
}
2021-02-21 20:07:04 +01:00
int idyR = int(dyR);
int wRPerm = ${t} - 1 - wR;
for (int wC = 0; wC < ${n}; wC++) {
float dyC = float(dyCCorner + wC) / ${a}.0;
if (dyC < 0.0 || dyC >= ${e.outWidth}.0 ||
fract(dyC) > 0.0) {
continue;
}
int idyC = int(dyC);
int wCPerm = ${n} - 1 - wC;
for (int d2 = 0; d2 < ${e.outChannels}; d2++) {
if (${s}) {
float xValue = getDy(batch, idyR, idyC, d2);
float wValue = getW(wRPerm, wCPerm, d1, d2);
dotProd += xValue * wValue;
} else {
float xValue = getDy(batch, d2, idyR, idyC);
float wValue = getW(wRPerm, wCPerm, d1, d2);
dotProd += xValue * wValue;
}
2021-02-21 20:06:13 +01:00
}
}
2020-12-15 14:44:42 +01:00
}
2021-02-21 20:07:04 +01:00
setOutput(dotProd);
2021-02-21 20:06:13 +01:00
}
2021-02-25 13:50:13 +01:00
`}},dW=class{constructor(e){this.variableNames=["x","dy"],this.outputShape=e.filterShape;let t=e.strideDepth,n=e.strideHeight,r=e.strideWidth,a=e.padInfo.front,s=e.padInfo.top,i=e.padInfo.left;this.userCode=`
2021-02-21 20:07:04 +01: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++) {
int xF = wF + yF * ${t} - ${a};
if (xF < 0 || xF >= ${e.inDepth}) {
continue;
}
for (int yR = 0; yR < ${e.outHeight}; yR++) {
int xR = wR + yR * ${n} - ${s};
if (xR < 0 || xR >= ${e.inHeight}) {
continue;
}
for (int yC = 0; yC < ${e.outWidth}; yC++) {
int xC = wC + yC * ${r} - ${i};
if (xC < 0 || xC >= ${e.inWidth}) {
continue;
}
float dyValue = getDy(b, yF, yR, yC, d2);
float xValue = getX(b, xF, xR, xC, d1);
dotProd += (xValue * dyValue);
}
}
2021-02-21 20:06:13 +01:00
}
}
2021-02-21 20:07:04 +01:00
setOutput(dotProd);
2020-12-16 20:49:14 +01:00
}
2021-02-25 13:50:13 +01:00
`}},pW=class{constructor(e){this.variableNames=["dy","W"],this.outputShape=e.inShape;let t=e.filterDepth,n=e.filterHeight,r=e.filterWidth,a=e.strideDepth,s=e.strideHeight,i=e.strideWidth,o=t-1-e.padInfo.front,l=n-1-e.padInfo.top,u=r-1-e.padInfo.left;this.userCode=`
const ivec3 pads = ivec3(${o}, ${l}, ${u});
2021-02-21 20:07:04 +01: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++) {
float dyF = float(dyFCorner + wF) / ${a}.0;
if (dyF < 0.0 || dyF >= ${e.outDepth}.0 || fract(dyF) > 0.0) {
continue;
2021-02-21 20:06:13 +01:00
}
2021-02-21 20:07:04 +01:00
int idyF = int(dyF);
int wFPerm = ${t} - 1 - wF;
for (int wR = 0; wR < ${n}; wR++) {
float dyR = float(dyRCorner + wR) / ${s}.0;
if (dyR < 0.0 || dyR >= ${e.outHeight}.0 ||
fract(dyR) > 0.0) {
continue;
}
int idyR = int(dyR);
int wRPerm = ${n} - 1 - wR;
for (int wC = 0; wC < ${r}; wC++) {
float dyC = float(dyCCorner + wC) / ${i}.0;
if (dyC < 0.0 || dyC >= ${e.outWidth}.0 ||
fract(dyC) > 0.0) {
continue;
}
int idyC = int(dyC);
int wCPerm = ${r} - 1 - wC;
for (int d2 = 0; d2 < ${e.outChannels}; d2++) {
float xValue = getDy(batch, idyF, idyR, idyC, d2);
float wValue = getW(wFPerm, wRPerm, wCPerm, d1, d2);
dotProd += xValue * wValue;
}
2021-01-03 16:41:56 +01:00
}
}
}
2021-02-21 20:07:04 +01:00
setOutput(dotProd);
2020-11-10 02:13:38 +01:00
}
2021-02-25 13:50:13 +01:00
`}};function fW(e){let{inputs:t,backend:n,attrs:r}=e,{x:a,dy:s}=t,{strides:i,pad:o,dataFormat:l,dimRoundingMode:u,filterShape:c}=r,h=C.convertConv2DDataFormat(l),d=C.computeConv2DInfo(a.shape,c,i,1,o,u,!1,h),p=new cW(d);return n.runWebGLProgram(p,[a,s],"float32")}var mW={kernelName:hh,backendName:"webgl",kernelFunc:fW};function AW(e){let{inputs:t,backend:n,attrs:r}=e,{dy:a,filter:s}=t,{inputShape:i,strides:o,pad:l,dataFormat:u,dimRoundingMode:c}=r,h=C.convertConv2DDataFormat(u),d=C.computeConv2DInfo(i,s.shape,o,1,l,c,!1,h),p=new hW(d);return n.runWebGLProgram(p,[a,s],"float32")}var yW={kernelName:es,backendName:"webgl",kernelFunc:AW};function gW(e){let{inputs:t,backend:n,attrs:r}=e,{x:a,filter:s}=t,{strides:i,pad:o,dilations:l}=r,u=C.computeConv3DInfo(a.shape,s.shape,i,l,o),c=new iW(u);return n.runWebGLProgram(c,[a,s],"float32")}var xW={kernelName:Kl,backendName:"webgl",kernelFunc:gW};function wW(e){let{inputs:t,backend:n,attrs:r}=e,{x:a,dy:s}=t,{strides:i,pad:o,filterShape:l}=r,u=C.computeConv3DInfo(a.shape,l,i,1,o),c=new dW(u);return n.runWebGLProgram(c,[a,s],"float32")}var _W={kernelName:dh,backendName:"webgl",kernelFunc:wW};function bW(e){let{inputs:t,backend:n,attrs:r}=e,{dy:a,filter:s}=t,{pad:i,strides:o,inputShape:l}=r,u=C.computeConv3DInfo(l,s.shape,o,1,i),c=new pW(u);return n.runWebGLProgram(c,[a,s],"float32")}var vW={kernelName:ph,backendName:"webgl",kernelFunc:bW},kW=n_+`
2021-02-21 20:07:04 +01:00
return cos(x);
2021-02-25 13:50:13 +01:00
`,IW=Xe({opSnippet:kW}),NW={kernelName:ts,backendName:"webgl",kernelFunc:IW},SW=`
2021-02-21 20:07:04 +01:00
float e2x = exp(-x);
return (e2x + 1.0 / e2x) / 2.0;
2021-02-25 13:50:13 +01:00
`,TW=Xe({opSnippet:SW}),EW={kernelName:Hi,backendName:"webgl",kernelFunc:TW},CW=class{constructor(e,t,n,r,a){this.variableNames=["Image","Boxes","BoxInd"],this.outputShape=[];let[s,i,o,l]=e,[u]=t,[c,h]=n;this.outputShape=[u,c,h,l];let d=r==="bilinear"?1:0,[p,f]=[`${i-1}.0`,`${o-1}.0`],[m,A,y]=c>1?[`${(i-1)/(c-1)}`,"(y2-y1) * height_ratio",`y1*${p} + float(y)*(height_scale)`]:["0.0","0.0",`0.5 * (y1+y2) * ${p}`],[g,w,_]=h>1?[`${(o-1)/(h-1)}`,"(x2-x1) * width_ratio",`x1*${f} + float(x)*(width_scale)`]:["0.0","0.0",`0.5 * (x1+x2) * ${f}`];this.userCode=`
2021-02-21 20:07:04 +01:00
const float height_ratio = float(${m});
const float width_ratio = float(${g});
void main() {
ivec4 coords = getOutputCoords();
int b = coords[0];
int y = coords[1];
int x = coords[2];
int d = coords[3];
// get box vals
float y1 = getBoxes(b,0);
float x1 = getBoxes(b,1);
float y2 = getBoxes(b,2);
float x2 = getBoxes(b,3);
// get image in batch index
int bInd = round(getBoxInd(b));
if(bInd < 0 || bInd >= ${s}) {
2021-02-21 20:06:13 +01:00
return;
}
2021-02-21 20:07:04 +01:00
float height_scale = ${A};
2021-02-25 13:50:13 +01:00
float width_scale = ${w};
2021-02-21 20:07:04 +01:00
float in_y = ${y};
if( in_y < 0.0 || in_y > ${p} ) {
setOutput(float(${a}));
2021-02-21 20:06:13 +01:00
return;
}
2021-02-25 13:50:13 +01:00
float in_x = ${_};
2021-02-21 20:07:04 +01:00
if( in_x < 0.0 || in_x > ${f} ) {
setOutput(float(${a}));
2021-02-21 20:06:13 +01:00
return;
}
2021-02-21 20:07:04 +01:00
vec2 sourceFracIndexCR = vec2(in_x,in_y);
if(${d} == 1) {
// Compute the four integer indices.
ivec2 sourceFloorCR = ivec2(sourceFracIndexCR);
ivec2 sourceCeilCR = ivec2(ceil(sourceFracIndexCR));
float topLeft = getImage(b, sourceFloorCR.y, sourceFloorCR.x, d);
float bottomLeft = getImage(b, sourceCeilCR.y, sourceFloorCR.x, d);
float topRight = getImage(b, sourceFloorCR.y, sourceCeilCR.x, d);
float bottomRight = getImage(b, sourceCeilCR.y, sourceCeilCR.x, d);
vec2 fracCR = sourceFracIndexCR - vec2(sourceFloorCR);
float top = topLeft + (topRight - topLeft) * fracCR.x;
float bottom = bottomLeft + (bottomRight - bottomLeft) * fracCR.x;
float newValue = top + (bottom - top) * fracCR.y;
setOutput(newValue);
2021-02-21 20:06:13 +01:00
} else {
2021-02-21 20:07:04 +01:00
// 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-02-21 20:06:13 +01:00
}
}
2021-02-25 13:50:13 +01:00
`}},RW=e=>{let{inputs:t,backend:n,attrs:r}=e,{image:a,boxes:s,boxInd:i}=t,{cropSize:o,method:l,extrapolationValue:u}=r,c=new CW(a.shape,s.shape,o,l,u);return n.runWebGLProgram(c,[a,s,i],"float32")},FW={kernelName:Gi,backendName:"webgl",kernelFunc:RW},I_=class{constructor(e,t,n){this.variableNames=["x"],this.outputShape=e;let r=e.length,a=t?"0.0":`getX(${v_(r,"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-02-21 20:07:04 +01:00
uniform float index;
void main() {
2021-02-25 13:50:13 +01:00
${lt(r)} coords = getOutputCoords();
int end = ${k_(r,"coords")};
2021-02-21 20:07:04 +01:00
float val = ${a};
int pow2 = int(pow(2.0, index));
if (${i}) {
int idx = ${o};
2021-02-25 13:50:13 +01:00
${k_(r,"coords")} = idx;
val += getX(${v_(r,"coords")});
2021-02-21 20:06:13 +01:00
}
2021-02-21 20:07:04 +01:00
setOutput(val);
2021-02-21 20:06:13 +01:00
}
2021-02-25 13:50:13 +01:00
`}getCustomSetupFunc(e){return(t,n)=>{this.index==null&&(this.index=t.getUniformLocation(n,"index")),t.gl.uniform1f(this.index,e)}}};function v_(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 k_(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 $W(e){let{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{axis:s,exclusive:i,reverse:o}=r,l=a.shape.length,u=C.getAxesPermutation([s],l),c=a;u!=null&&(c=wn({inputs:{x:a},backend:n,attrs:{perm:u}}));let h=C.getInnerMostAxes(1,l)[0];if(h!==l-1)throw new Error(`WebGL cumsum shader expects an inner-most axis=${a.shape.length-1} but got axis=${s}`);let d=c.shape[h],p=Fn({inputs:{x:c},backend:n});for(let f=0;f<=Math.ceil(Math.log2(d))-1;f++){let m=new I_(c.shape,!1,o),A=m.getCustomSetupFunc(f),y=p;p=n.runWebGLProgram(m,[p],p.dtype,A),n.disposeIntermediateTensorInfo(y)}if(i){let f=new I_(c.shape,i,o),m=p;p=n.runWebGLProgram(f,[p],p.dtype),n.disposeIntermediateTensorInfo(m)}if(u!=null){let f=C.getUndoAxesPermutation(u),m=wn({inputs:{x:p},backend:n,attrs:{perm:f}});return n.disposeIntermediateTensorInfo(p),n.disposeIntermediateTensorInfo(c),m}return p}var MW={kernelName:ns,backendName:"webgl",kernelFunc:$W};function DW(e){let{inputs:t,backend:n,attrs:r}=e,{x:a,weights:s}=t,{size:i,binaryOutput:o}=r;if(a.shape.length===1){let l=n.readSync(a.dataId),u=n.readSync(s.dataId),c=Uw(l,u,s.dtype,s.shape,i);return n.makeTensorInfo([i],s.dtype,c)}else if(a.shape.length===2){let l=n.bufferSync(a),u=n.bufferSync(s),c=hz(l,u,i,o);return n.makeTensorInfo(c.shape,s.dtype,c.values)}throw new Error(`Error in denseBincount: input must be at most rank 2, but got rank${a.shape.length}.`)}var OW={kernelName:fh,backendName:"webgl",kernelFunc:DW},zW=class{constructor(e,t,n){this.variableNames=["x"],this.outputShape=[],this.outputShape=e,this.blockSize=t,this.dataFormat=n,this.userCode=`
2021-02-21 20:07:04 +01: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-02-21 20:06:13 +01:00
}
2021-02-25 13:50:13 +01: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 LW(e){let{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{blockSize:s,dataFormat:i}=r;v.assert(s>1,()=>`blockSize should be > 1 for depthToSpace, but was: ${s}`);let o=a.shape[0],l=i==="NHWC"?a.shape[1]:a.shape[2],u=i==="NHWC"?a.shape[2]:a.shape[3],c=i==="NHWC"?a.shape[3]:a.shape[1],h=l*s,d=u*s,p=c/(s*s),f=i==="NHWC"?[o,h,d,p]:[o,p,h,d],m=new zW(f,s,i);return n.runWebGLProgram(m,[a],a.dtype)}var PW={kernelName:qi,backendName:"webgl",kernelFunc:LW},N_=class{constructor(e,t=!1,n=null,r=!1,a=!1){this.variableNames=["x","W"],this.outputShape=e.outShape;let s=e.inHeight,i=e.inWidth,o=e.padInfo.top,l=e.padInfo.left,u=e.strideHeight,c=e.strideWidth,h=e.dilationHeight,d=e.dilationWidth,p=e.filterHeight,f=e.filterWidth,m=e.outChannels/e.inChannels,A="",y="";n&&(r?A=`float activation(float a) {
2021-02-21 20:07:04 +01:00
float b = getPreluActivationWeightsAtOutCoords();
${n}
}`:a?A=`float activation(float a) {
float b = getLeakyreluAlphaAtOutCoords();
${n}
}`:A=`
float activation(float x) {
${n}
2021-02-21 20:06:13 +01:00
}
2021-02-21 20:07:04 +01:00
`,y="result = activation(result);");let g=t?"result += getBiasAtOutCoords();":"";t&&this.variableNames.push("bias"),r&&this.variableNames.push("preluActivationWeights"),a&&this.variableNames.push("leakyreluAlpha"),this.userCode=`
${A}
2021-02-25 13:50:13 +01:00
const ivec2 strides = ivec2(${u}, ${c});
2021-02-21 20:07:04 +01:00
const ivec2 pads = ivec2(${o}, ${l});
void main() {
ivec4 coords = getOutputCoords();
int batch = coords.x;
ivec2 xRCCorner = coords.yz * strides - pads;
int d2 = coords.w;
int d1 = d2 / ${m};
int q = d2 - d1 * ${m};
int xRCorner = xRCCorner.x;
int xCCorner = xRCCorner.y;
// Convolve x(?, ?, d1) with w(:, :, d1, q) to get y(yR, yC, d2).
// ? = to be determined. : = across all values in that axis.
float dotProd = 0.0;
// TO DO(dsmilkov): Flatten the two for loops and vec4 the operations.
for (int wR = 0; wR < ${p}; wR++) {
int xR = xRCorner + wR * ${h};
if (xR < 0 || xR >= ${s}) {
continue;
}
for (int wC = 0; wC < ${f}; wC++) {
int xC = xCCorner + wC * ${d};
if (xC < 0 || xC >= ${i}) {
continue;
}
float xVal = getX(batch, xR, xC, d1);
float wVal = getW(wR, wC, d1, q);
dotProd += xVal * wVal;
2021-02-21 20:06:13 +01:00
}
}
2021-02-21 20:07:04 +01:00
float result = dotProd;
${g}
${y}
setOutput(result);
2021-02-21 20:06:13 +01:00
}
2021-02-25 13:50:13 +01:00
`}},S_=class{constructor(e,t=!1,n=null,r=!1,a=!1){this.variableNames=["x","W"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=e.outShape;let s=e.inHeight,i=e.inWidth,o=e.padInfo.top,l=e.padInfo.left,u=e.strideHeight,c=e.strideWidth,h=e.dilationHeight,d=e.dilationWidth,p=e.filterHeight,f=e.filterWidth,m=f,A="int xR; int xC; int xCOffset;";for(let _=0;_<p;_++)for(let b=0;b<f;b++)A+=`
vec4 xTexelR${_}C${b*2} = vec4(0.);
vec4 wR${_}C${b} = vec4(0.);
vec4 xR${_}C${b} = vec4(0.);`;for(let _=0;_<p;_++)for(let b=0;b<m;b++){let x=b*2;if(A+=`
xR = xRCorner + ${_*h};
xC = xCCorner + ${x*d};
`,c===1){if(x<f&&(l%2==1?A+=`
2021-02-21 20:07:04 +01:00
xCOffset = xC + 1;
if(xR >= 0 && xR < ${s} && xCOffset >= 0 && xCOffset < ${i}) {
2021-02-25 13:50:13 +01:00
xTexelR${_}C${x} = getX(batch, xR, xCOffset, d1);
2021-02-21 20:07:04 +01:00
// Need to manually clear unused channels in case
// we're reading from recycled texture.
if(xCOffset + 1 >= ${i}) {
2021-02-25 13:50:13 +01:00
xTexelR${_}C${x}.zw = vec2(0.);
2021-02-21 20:07:04 +01:00
}
} else {
2021-02-25 13:50:13 +01:00
xTexelR${_}C${x} = vec4(0.);
2021-02-21 20:07:04 +01:00
}
xCOffset = xC + 1 - 2;
if(xR >= 0 && xR < ${s} && xCOffset >= 0 && xCOffset < ${i}) {
vec4 previous = getX(batch, xR, xCOffset, d1);
// Need to manually clear unused channels in case
// we're reading from recycled texture.
if(xCOffset + 1 >= ${i}) {
previous.zw = vec2(0.);
}
2021-02-25 13:50:13 +01:00
xR${_}C${x} = vec4(previous.zw, xTexelR${_}C${x}.xy);
2021-02-21 20:07:04 +01:00
} else {
2021-02-25 13:50:13 +01:00
xR${_}C${x} = vec4(0, 0, xTexelR${_}C${x}.xy);
2021-02-21 20:07:04 +01:00
}
`:A+=`
if(xR >= 0 && xR < ${s} && xC >= 0 && xC < ${i}) {
2021-02-25 13:50:13 +01:00
xTexelR${_}C${x} = getX(batch, xR, xC, d1);
2021-02-21 20:07:04 +01:00
} else {
2021-02-25 13:50:13 +01:00
xTexelR${_}C${x} = vec4(0.);
2021-02-21 20:07:04 +01:00
}
2021-02-25 13:50:13 +01:00
xR${_}C${x} = xTexelR${_}C${x};
`,x+1<f)){let N=l%2==0?v.nearestLargerEven(d):d;d%2==0&&l%2==1||d%2!=0&&l%2!=1?(A+=`
2021-02-21 20:07:04 +01:00
xCOffset = xC + ${l%2} + ${N};
if(xR >= 0 && xR < ${s} &&
xCOffset >= 0 && xCOffset < ${i}) {
2021-02-25 13:50:13 +01:00
xTexelR${_}C${x+2} = getX(batch, xR, xCOffset, d1);
2021-02-21 20:07:04 +01:00
}
`,d>1&&(A+=`
xCOffset -= 2;
if(xR >= 0 && xR < ${s} &&
xCOffset >= 0 && xCOffset < ${i}) {
2021-02-25 13:50:13 +01:00
xTexelR${_}C${x} = getX(batch, xR, xCOffset, d1);
2021-02-21 20:07:04 +01:00
} else {
2021-02-25 13:50:13 +01:00
xTexelR${_}C${x} = vec4(0.);
2021-02-21 20:07:04 +01:00
}
`),A+=`
2021-02-25 13:50:13 +01:00
xR${_}C${x+1} = vec4(
xTexelR${_}C${x}.zw, xTexelR${_}C${x+2}.xy);
2021-02-21 20:07:04 +01:00
`):A+=`
xCOffset = xC + ${N};
if(xR >= 0 && xR < ${s} &&
xCOffset >= 0 && xCOffset < ${i}) {
2021-02-25 13:50:13 +01:00
xTexelR${_}C${x+2} = getX(batch, xR, xCOffset, d1);
2021-02-21 20:07:04 +01:00
}
2021-02-25 13:50:13 +01:00
xR${_}C${x+1} = xTexelR${_}C${x+2};
`}}else x<f&&(A+=`
2021-02-21 20:07:04 +01:00
if(xR >= 0 && xR < ${s}) {
`,l%2==1?(A+=`
2021-02-25 13:50:13 +01:00
xCOffset = xC + 1 - ${c};
2021-02-21 20:07:04 +01:00
if(xCOffset >= 0 && xCOffset < ${i}) {
2021-02-25 13:50:13 +01:00
xTexelR${_}C${x} = getX(batch, xR, xCOffset, d1);
2021-02-21 20:07:04 +01:00
} else {
2021-02-25 13:50:13 +01:00
xTexelR${_}C${x} = vec4(0.);
2021-02-21 20:07:04 +01:00
}
if(xC + 1 >= 0 && xC + 1 < ${i}) {
2021-02-25 13:50:13 +01:00
xTexelR${_}C${x+2} = getX(batch, xR, xC + 1, d1);
2021-02-21 20:07:04 +01:00
} else {
2021-02-25 13:50:13 +01:00
xTexelR${_}C${x+2} = vec4(0.);
2021-02-21 20:07:04 +01:00
}
2021-02-25 13:50:13 +01:00
xR${_}C${x} = vec4(
xTexelR${_}C${x}.zw, xTexelR${_}C${x+2}.zw);
`,x+1<f&&(A+=`
2021-02-21 20:07:04 +01:00
vec4 final = vec4(0.);
2021-02-25 13:50:13 +01:00
xCOffset = xC + 1 + ${c};
2021-02-21 20:07:04 +01:00
if(xCOffset >= 0 && xCOffset < ${i}) {
final = getX(batch, xR, xCOffset, d1);
}
2021-02-25 13:50:13 +01:00
xR${_}C${x+1} = vec4(xTexelR${_}C${x+2}.xy, final.xy);
2021-02-21 20:07:04 +01:00
`)):(A+=`
if(xC >= 0 && xC < ${i}) {
2021-02-25 13:50:13 +01:00
xTexelR${_}C${x} = getX(batch, xR, xC, d1);
2021-02-21 20:07:04 +01:00
} else {
2021-02-25 13:50:13 +01:00
xTexelR${_}C${x} = vec4(0.);
2021-02-21 20:07:04 +01:00
}
2021-02-25 13:50:13 +01:00
xCOffset = xC + ${c};
2021-02-21 20:07:04 +01:00
if(xCOffset >= 0 && xCOffset < ${i}) {
2021-02-25 13:50:13 +01:00
xTexelR${_}C${x+2} = getX(batch, xR, xCOffset, d1);
2021-02-21 20:07:04 +01:00
} else {
2021-02-25 13:50:13 +01:00
xTexelR${_}C${x+2} = vec4(0.);
2021-02-21 20:07:04 +01:00
}
2021-02-25 13:50:13 +01:00
xR${_}C${x} = vec4(
xTexelR${_}C${x}.xy, xTexelR${_}C${x+2}.xy);
`,x+1<f&&(A+=`
xR${_}C${x+1} = vec4(
xTexelR${_}C${x}.zw, xTexelR${_}C${x+2}.zw);
`)),A+="}");x<f&&(A+=`
vec4 wTexelR${_}C${x} = getW(${_}, ${x}, d1, q);
wR${_}C${x} = vec4(wTexelR${_}C${x}.xz, wTexelR${_}C${x}.xz);
`,x+1<f&&(A+=`
vec4 wTexelR${_}C${x+1} = getW(${_}, ${x+1}, d1, q);
wR${_}C${x+1} =
vec4(wTexelR${_}C${x+1}.xz, wTexelR${_}C${x+1}.xz);`))}for(let _=0;_<p;_++)for(let b=0;b<f;b++)A+=`dotProd += xR${_}C${b} * wR${_}C${b};`;let y="",g="";n&&(r?y=`vec4 activation(vec4 a) {
2021-02-21 20:07:04 +01:00
vec4 b = getPreluActivationWeightsAtOutCoords();
${n}
}`:a?y=`vec4 activation(vec4 a) {
vec4 b = getLeakyreluAlphaAtOutCoords();
${n}
}`:y=`vec4 activation(vec4 x) {
${n}
2021-02-25 13:50:13 +01:00
}`,g="result = activation(result);");let w=t?"result += getBiasAtOutCoords();":"";t&&this.variableNames.push("bias"),r&&this.variableNames.push("preluActivationWeights"),a&&this.variableNames.push("leakyreluAlpha"),this.userCode=`
2021-02-21 20:07:04 +01:00
${y}
2021-02-25 13:50:13 +01:00
const ivec2 strides = ivec2(${u}, ${c});
2021-02-21 20:07:04 +01:00
const ivec2 pads = ivec2(${o}, ${l});
void main() {
ivec4 coords = getOutputCoords();
int batch = coords.x;
ivec2 xRCCorner = coords.yz * strides - pads;
int d2 = coords.w;
int d1 = d2;
int q = 0;
int xRCorner = xRCCorner.x;
int xCCorner = xRCCorner.y;
vec4 dotProd = vec4(0.);
${A}
vec4 result = dotProd;
2021-02-25 13:50:13 +01:00
${w}
2021-02-21 20:07:04 +01:00
${g}
setOutput(result);
2021-02-21 20:06:13 +01:00
}
2021-02-25 13:50:13 +01:00
`}};function WW(e){let{inputs:t,backend:n,attrs:r}=e,{x:a,filter:s}=t,{strides:i,pad:o,dilations:l,dimRoundingMode:u}=r,c=l;c==null&&(c=[1,1]),v.assert(C.eitherStridesOrDilationsAreOne(i,c),()=>`Error in depthwiseConv2d: Either strides or dilations must be 1. Got strides ${i} and dilations '${c}'`);let h=C.computeConv2DInfo(a.shape,s.shape,i,c,o,u,!0),d;return Y().getBool("WEBGL_PACK_DEPTHWISECONV")&&h.strideWidth<=2&&h.outChannels/h.inChannels==1?d=new S_(h):d=new N_(h),n.runWebGLProgram(d,[a,s],"float32")}var BW={kernelName:rs,backendName:"webgl",kernelFunc:WW},VW=class{constructor(e){this.variableNames=["x","dy"],this.outputShape=e.filterShape;let t=e.strideHeight,n=e.strideWidth,r=e.padInfo.top,a=e.padInfo.left,s=e.outChannels/e.inChannels;this.userCode=`
2021-02-21 20:07:04 +01:00
void main() {
ivec4 coords = getOutputCoords();
int wR = coords.x;
int wC = coords.y;
int d1 = coords.z;
int dm = coords.w;
int d2 = d1 * ${s} + dm;
float dotProd = 0.0;
// TO DO: Vec4 over the batch size
for (int b = 0; b < ${e.batchSize}; b++) {
for (int yR = 0; yR < ${e.outHeight}; yR++) {
int xR = wR + yR * ${t} - ${r};
if (xR < 0 || xR >= ${e.inHeight}) {
continue;
}
for (int yC = 0; yC < ${e.outWidth}; yC++) {
int xC = wC + yC * ${n} - ${a};
if (xC < 0 || xC >= ${e.inWidth}) {
continue;
}
float dyValue = getDy(b, yR, yC, d2);
float xValue = getX(b, xR, xC, d1);
dotProd += (xValue * dyValue);
}
2021-02-21 20:06:13 +01:00
}
}
2021-02-21 20:07:04 +01:00
setOutput(dotProd);
2021-02-21 20:06:13 +01:00
}
2021-02-25 13:50:13 +01:00
`}},UW=class{constructor(e){this.variableNames=["dy","W"],this.outputShape=e.inShape;let t=e.filterHeight,n=e.filterWidth,r=e.strideHeight,a=e.strideWidth,s=t-1-e.padInfo.top,i=n-1-e.padInfo.left,o=e.outChannels/e.inChannels;this.userCode=`
2021-02-21 20:07:04 +01:00
const ivec2 pads = ivec2(${s}, ${i});
void main() {
ivec4 coords = getOutputCoords();
int batch = coords[0];
int d1 = coords[3];
ivec2 dyCorner = coords.yz - pads;
int dyRCorner = dyCorner.x;
int dyCCorner = dyCorner.y;
float dotProd = 0.0;
for (int wR = 0; wR < ${t}; wR++) {
float dyR = float(dyRCorner + wR) / ${r}.0;
if (dyR < 0.0 || dyR >= ${e.outHeight}.0 || fract(dyR) > 0.0) {
continue;
}
int idyR = int(dyR);
int wRPerm = ${t} - 1 - wR;
for (int wC = 0; wC < ${n}; wC++) {
float dyC = float(dyCCorner + wC) / ${a}.0;
if (dyC < 0.0 || dyC >= ${e.outWidth}.0 ||
fract(dyC) > 0.0) {
continue;
}
int idyC = int(dyC);
int wCPerm = ${n} - 1 - wC;
// TO DO: Vec4 over the channelMul
for (int dm = 0; dm < ${o}; dm++) {
int d2 = d1 * ${o} + dm;
float xValue = getDy(batch, idyR, idyC, d2);
float wValue = getW(wRPerm, wCPerm, d1, dm);
dotProd += xValue * wValue;
}
2021-02-21 20:06:13 +01:00
}
}
2021-02-21 20:07:04 +01:00
setOutput(dotProd);
2021-02-21 20:06:13 +01:00
}
2021-02-25 13:50:13 +01:00
`}};function jW(e){let{inputs:t,backend:n,attrs:r}=e,{x:a,dy:s}=t,{strides:i,dilations:o,pad:l,dimRoundingMode:u,filterShape:c}=r,h=C.computeConv2DInfo(a.shape,c,i,o,l,u,!0),d=new VW(h);return n.runWebGLProgram(d,[a,s],"float32")}var HW={kernelName:mh,backendName:"webgl",kernelFunc:jW};function GW(e){let{inputs:t,backend:n,attrs:r}=e,{dy:a,filter:s}=t,{strides:i,dilations:o,pad:l,dimRoundingMode:u,inputShape:c}=r,h=C.computeConv2DInfo(c,s.shape,i,o,l,u,!0),d=new UW(h);return n.runWebGLProgram(d,[a,s],"float32")}var qW={kernelName:Ah,backendName:"webgl",kernelFunc:GW},XW=class{constructor(e){this.variableNames=["X"],this.outputShape=[e,e],this.userCode=`
2021-02-21 20:07:04 +01:00
void main() {
ivec2 coords = getOutputCoords();
float val = coords[0] == coords[1] ? getX(coords[0]) : 0.0;
setOutput(val);
2021-02-21 20:06:13 +01:00
}
2021-02-25 13:50:13 +01:00
`}};function KW(e){let{inputs:t,backend:n}=e,{x:r}=t,a=[...r.shape,...r.shape],s=v.sizeFromShape(r.shape),i=ye({inputs:{x:r},backend:n,attrs:{shape:[s]}}),o=new XW(s),l=n.runWebGLProgram(o,[i],i.dtype),u=ye({inputs:{x:l},backend:n,attrs:{shape:a}});return n.disposeIntermediateTensorInfo(i),n.disposeIntermediateTensorInfo(l),u}var ZW={kernelName:yh,backendName:"webgl",kernelFunc:KW},YW=class{constructor(e){this.variableNames=["x","W"],this.outputShape=e.outShape;let{inHeight:t,inWidth:n,padInfo:r,strideHeight:a,strideWidth:s,filterHeight:i,filterWidth:o,dilationHeight:l,dilationWidth:u}=e,{top:c,left:h}=r;this.userCode=`
2021-02-21 20:07:04 +01:00
const ivec2 strides = ivec2(${a}, ${s});
2021-02-25 13:50:13 +01:00
const ivec2 pads = ivec2(${c}, ${h});
2021-02-21 20:07:04 +01:00
const float neg_infinity = -3.4e38;
void main() {
ivec4 coords = getOutputCoords();
int batch = coords.x;
int d1 = coords.w;
ivec2 outTopLeftCorner =
coords.yz * strides - pads;
int hBeg = outTopLeftCorner.x;
int wBeg = outTopLeftCorner.y;
float curVal = neg_infinity;
for (int h = 0; h < ${i}; h++) {
int hIn = hBeg + h * ${l};
if (hIn >= 0 && hIn < ${t}) {
for (int w = 0; w < ${o}; w++) {
2021-02-25 13:50:13 +01:00
int wIn = wBeg + w * ${u};
2021-02-21 20:07:04 +01: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;
}
}
}
}
2021-02-21 20:06:13 +01:00
}
2021-02-21 20:07:04 +01:00
float result = curVal;
setOutput(result);
2021-02-21 20:06:13 +01:00
}
2021-02-25 13:50:13 +01:00
`}};function JW(e){let{inputs:t,backend:n,attrs:r}=e,{x:a,filter:s}=t,{strides:i,pad:o,dilations:l}=r,u=C.computeDilation2DInfo(a.shape,s.shape,i,o,"NHWC",l),c,h=new YW(u);c=n.runWebGLProgram(h,[a,s],"float32");let d=ye({inputs:{x:c},backend:n,attrs:{shape:u.outShape}});return n.disposeIntermediateTensorInfo(c),d}var QW={kernelName:Zl,backendName:"webgl",kernelFunc:JW},eB="return (x >= 0.0) ? x : (exp(x) - 1.0);",tB=`
2021-02-21 20:07:04 +01: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);
2021-02-21 20:06:13 +01:00
return result;
2021-02-25 13:50:13 +01:00
`,nB=Xe({opSnippet:eB,packedOpSnippet:tB}),rB={kernelName:Xi,backendName:"webgl",kernelFunc:nB},aB="return (b >= 1.0) ? a : a * (b + 1.0);",sB=`
2021-02-21 20:07:04 +01:00
vec4 bGTEZero = vec4(greaterThanEqual(b, vec4(0.)));
return (bGTEZero * a) + ((vec4(1.0) - bGTEZero) * (a * (b + vec4(1.0))));
2021-02-25 13:50:13 +01:00
`,iB=e=>{let{inputs:t,backend:n}=e,{dy:r,y:a}=t,s=Y().getBool("WEBGL_PACK_BINARY_OPERATIONS")?new Ju(sB,r.shape,a.shape):new gl(aB,r.shape,a.shape);return n.runWebGLProgram(s,[r,a],r.dtype)},oB={kernelName:wh,backendName:"webgl",kernelFunc:iB},lB=`
2021-02-21 20:07:04 +01:00
return vec4(equal(a, b));
2021-02-25 13:50:13 +01:00
`,uB="return float(a == b);",cB=Qt({opSnippet:uB,packedOpSnippet:lB,dtype:"bool"}),hB={kernelName:Zi,backendName:"webgl",kernelFunc:cB},dB=`
2021-02-21 20:07:04 +01:00
// Error function is calculated approximately with elementary function.
// See "Handbook of Mathematical Functions with Formulas,
// Graphs, and Mathematical Tables", Abramowitz and Stegun.
float p = ${C.ERF_P};
float a1 = ${C.ERF_A1};
float a2 = ${C.ERF_A2};
float a3 = ${C.ERF_A3};
float a4 = ${C.ERF_A4};
float a5 = ${C.ERF_A5};
float sign = sign(x);
x = abs(x);
float t = 1.0 / (1.0 + p * x);
return sign * (1.0 - (((((a5*t + a4)*t) + a3)*t + a2)*t + a1)*t*exp(-x*x));
2021-02-25 13:50:13 +01:00
`,pB=Xe({opSnippet:dB}),fB={kernelName:Ki,backendName:"webgl",kernelFunc:pB},T_="return exp(x);",E_=Xe({opSnippet:T_,packedOpSnippet:T_,cpuKernelImpl:fz}),mB={kernelName:ss,backendName:"webgl",kernelFunc:E_};function FA(e){let{inputs:t,attrs:n,backend:r}=e,{dim:a}=n,{input:s}=t,i=s.shape.length,o=s.shape.slice(),l=a;return a<0&&(v.assert(-(i+1)<=a,()=>`Axis must be in the interval [${-(i+1)}, ${i}]`),l=i+a+1),o.splice(l,0,1),ye({inputs:{x:s},backend:r,attrs:{shape:o}})}var AB={kernelName:Yi,backendName:"webgl",kernelFunc:FA},C_="return exp(x) - 1.0;",yB=Xe({opSnippet:C_,packedOpSnippet:C_,cpuKernelImpl:mz}),gB={kernelName:Ji,backendName:"webgl",kernelFunc:yB},R_=class{constructor(e,t,n){this.variableNames=["real","imag"];let r=t[1];this.outputShape=t;let a=n?`2.0 * ${Math.PI}`:`-2.0 * ${Math.PI}`,s=n?`${r}.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-02-21 20:07:04 +01:00
const float exponentMultiplier = ${a};
float unaryOpComplex(float real, float expR, float imag, float expI) {
${i}
2021-02-21 20:06:13 +01:00
}
2021-02-21 20:07:04 +01:00
float mulMatDFT(int batch, int index) {
float indexRatio = float(index) / float(${r});
float exponentMultiplierTimesIndexRatio =
exponentMultiplier * indexRatio;
float result = 0.0;
for (int i = 0; i < ${r}; i++) {
// x = (-2|2 * PI / N) * index * i;
float x = exponentMultiplierTimesIndexRatio * float(i);
float expR = cos(x);
float expI = sin(x);
float real = getReal(batch, i);
float imag = getImag(batch, i);
result +=
unaryOpComplex(real, expR, imag, expI) / ${s};
}
return result;
2021-02-21 20:06:13 +01:00
}
2021-02-21 20:07:04 +01:00
void main() {
ivec2 coords = getOutputCoords();
setOutput(mulMatDFT(coords[0], coords[1]));
2021-02-21 20:06:13 +01:00
}
2021-02-25 13:50:13 +01:00
`}};function F_(e,t,n){let r=n.texData.get(e.dataId),a=v.sizeFromShape(e.shape),s=e.shape[e.shape.length-1],i=a/s,o=ye({inputs:{x:e},backend:n,attrs:{shape:[i,s]}}),l=o.shape,u=new R_("real",l,t),c=new R_("imag",l,t),h=[{dataId:r.complexTensorInfos.real.dataId,dtype:r.complexTensorInfos.real.dtype,shape:l},{dataId:r.complexTensorInfos.imag.dataId,dtype:r.complexTensorInfos.imag.dtype,shape:l}],d=n.runWebGLProgram(u,h,"float32"),p=n.runWebGLProgram(c,h,"float32"),f=Ma({inputs:{real:d,imag:p},backend:n});n.disposeIntermediateTensorInfo(d),n.disposeIntermediateTensorInfo(p);let m=ye({inputs:{x:f},backend:n,attrs:{shape:e.shape}});return n.disposeIntermediateTensorInfo(o),n.disposeIntermediateTensorInfo(f),m}function xB(e){let{inputs:t,backend:n}=e,{input:r}=t;return F_(r,!1,n)}var wB={kernelName:_h,backendName:"webgl",kernelFunc:xB},_B=class{constructor(e,t){this.outputShape=[],this.variableNames=["x"],this.outputShape=e,this.userCode=`
2021-02-21 20:07:04 +01:00
uniform float value;
void main() {
// Input can be obtained from uniform value.
setOutput(value);
2021-02-21 20:06:13 +01:00
}
2021-02-25 13:50:13 +01:00
`}getCustomSetupFunc(e){return(t,n)=>{this.valueLoc==null&&(this.valueLoc=t.getUniformLocationNoThrow(n,"value")),t.gl.uniform1f(this.valueLoc,e)}}};function $A(e){let{backend:t,attrs:n}=e,{shape:r,value:a}=n,{dtype:s}=n;if(s=s||v.inferDtype(a),s==="string"){let i=v.getArrayFromDType(s,v.sizeFromShape(r));return i.fill(a),t.makeTensorInfo(r,s,i)}else{let i=new _B(r,a),o=i.getCustomSetupFunc(a);return t.runWebGLProgram(i,[],s,o)}}var bB={kernelName:Yl,backendName:"webgl",kernelFunc:$A},vB=class{constructor(e){this.variableNames=["Image"],this.outputShape=[];let t=e[2];this.outputShape=e,this.userCode=`
2021-02-21 20:07:04 +01:00
void main() {
ivec4 coords = getOutputCoords();
int x = coords[2];
int coordX = ${t} - x;
float outputValue;
if(coordX >= 0 && coordX < ${t}) {
outputValue = getImage(coords[0], coords[1], coordX, coords[3]);
} else {
outputValue = getImage(coords[0], coords[1], coords[2], coords[3]);
}
setOutput(outputValue);
}
2021-02-25 13:50:13 +01:00
`}},kB={kernelName:Qi,backendName:"webgl",kernelFunc:({inputs:e,backend:t})=>{let{image:n}=e,r=t,a=new vB(n.shape);return r.runWebGLProgram(a,[n],n.dtype)}},$_="return floor(x);",IB=Xe({opSnippet:$_,packedOpSnippet:$_,cpuKernelImpl:Az}),NB={kernelName:is,backendName:"webgl",kernelFunc:IB},SB=`
2021-02-21 20:07:04 +01: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));
2021-02-21 20:06:13 +01:00
} else {
2021-02-21 20:07:04 +01:00
return NAN;
2021-02-21 20:06:13 +01:00
}
2021-02-25 13:50:13 +01:00
`,TB=`
2021-02-21 20:07:04 +01: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-02-21 20:06:13 +01:00
}
2021-02-21 20:07:04 +01:00
if (cond[1]) {
result[1] = idiv(ia[1], ib[1], s[1]);
2021-02-21 20:06:13 +01:00
}
2021-02-21 20:07:04 +01:00
if (cond[2]) {
result[2] = idiv(ia[2], ib[2], s[2]);
2021-02-21 20:06:13 +01:00
}
2021-02-21 20:07:04 +01:00
if (cond[3]) {
result[3] = idiv(ia[3], ib[3], s[3]);
2021-02-21 20:06:13 +01:00
}
2021-02-21 20:07:04 +01:00
return vec4(result);
2021-02-25 13:50:13 +01:00
`,EB=Qt({opSnippet:SB,packedOpSnippet:TB,dtype:"int32"}),CB={kernelName:os,backendName:"webgl",kernelFunc:EB},RB=class{constructor(e){this.variableNames=["A"];let t=un(),[n,r]=e;this.outputShape=e,this.userCode=`
2021-02-21 20:07:04 +01:00
void main() {
ivec3 coords = getOutputCoords();
int texR = coords[0];
int texC = coords[1];
int depth = coords[2];
vec2 uv = (vec2(texC, texR) + halfCR) / vec2(${r}.0, ${n}.0);
vec4 values = ${t.texture2D}(A, uv);
float value;
if (depth == 0) {
value = values.r;
} else if (depth == 1) {
value = values.g;
} else if (depth == 2) {
value = values.b;
} else if (depth == 3) {
value = values.a;
2021-02-21 20:06:13 +01:00
}
2021-02-21 20:07:04 +01:00
setOutput(floor(value * 255.0 + 0.5));
2021-02-21 20:06:13 +01:00
}
2021-02-25 13:50:13 +01:00
`}},FB=class{constructor(e){this.variableNames=["A"],this.packedInputs=!1,this.packedOutput=!0;let t=un(),[n,r]=e;this.outputShape=e,this.userCode=`
2021-02-21 20:07:04 +01: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) /
vec2(${r}.0, ${n}.0);
vec4 values = ${t.texture2D}(A, uv);
float value;
if (depth == 0) {
value = values.r;
} else if (depth == 1) {
value = values.g;
} else if (depth == 2) {
value = values.b;
} else if (depth == 3) {
value = values.a;
}
result[row * 2 + col] = floor(value * 255.0 + 0.5);
}
2021-02-21 20:06:13 +01:00
}
2021-02-21 20:07:04 +01:00
${t.output} = result;
2021-02-21 20:06:13 +01:00
}
2021-02-25 13:50:13 +01:00
`}},MB={kernelName:Dh,backendName:"webgl",kernelFunc:$B},wl;function $B(e){let{inputs:t,backend:n,attrs:r}=e,{pixels:a}=t,{numChannels:s}=r,i=typeof HTMLVideoElement!="undefined"&&a instanceof HTMLVideoElement,o=typeof HTMLImageElement!="undefined"&&a instanceof HTMLImageElement,l=typeof ImageBitmap!="undefined"&&a instanceof ImageBitmap,[u,c]=i?[a.videoWidth,a.videoHeight]:[a.width,a.height],h=[c,u],d=[c,u,s];(o||i||l)&&(wl==null&&(wl=document.createElement("canvas").getContext("2d")),wl.canvas.width=u,wl.canvas.height=c,wl.drawImage(a,0,0,u,c),a=wl.canvas);let p=n.makeTensorInfo(h,"int32");n.texData.get(p.dataId).usage=Gn.PIXELS,n.gpgpu.uploadPixelDataToTexture(n.getTexture(p.dataId),a);let f=Y().getBool("WEBGL_PACK")?new FB(d):new RB(d),m=n.runWebGLProgram(f,[p],"int32");return n.disposeData(p.dataId),m}function DB(e){let{inputs:t,backend:n,attrs:r}=e,{x:a,filter:s,bias:i,preluActivationWeights:o}=t,{strides:l,pad:u,dataFormat:c,dilations:h,dimRoundingMode:d,activation:p,leakyreluAlpha:f}=r,m=C.convertConv2DDataFormat(c),A=C.computeConv2DInfo(a.shape,s.shape,l,h,u,d,!1,m),y,g=[];if(A.filterHeight===1&&A.filterWidth===1&&A.dilationHeight===1&&A.dilationWidth===1&&A.strideHeight===1&&A.strideWidth===1&&(A.padInfo.type==="SAME"||A.padInfo.type==="VALID"))y=__({x:a,filter:s,convInfo:A,backend:n,bias:i,activation:p,preluActivationWeights:o,leakyreluAlpha:f});else if(Y().getBool("WEBGL_CONV_IM2COL")&&a.shape[0]===1)y=b_({x:a,filter:s,convInfo:A,backend:n,bias:i,activation:p,preluActivationWeights:o,leakyreluAlpha:f});else{let _=i!=null,b=o!=null,x=p==="leakyrelu",N=p?Yd(p,!1):null,T=new w_(A,_,N,b,x),E=[a,s];if(i&&E.push(i),o&&E.push(o),x){let $=n.makeTensorInfo([],"float32",v.createScalarValue(f,"float32"));E.push($),g.push($)}y=n.runWebGLProgram(T,E,"float32")}let w=ye({inputs:{x:y},backend:n,attrs:{shape:A.outShape}});return g.push(y),g.forEach(_=>n.disposeIntermediateTensorInfo(_)),w}var OB={kernelName:Ws,backendName:"webgl",kernelFunc:DB};function zB(e){let{inputs:t,backend:n,attrs:r}=e,{x:a,filter:s,bias:i,preluActivationWeights:o}=t,{strides:l,pad:u,dilations:c,dimRoundingMode:h,activation:d,leakyreluAlpha:p}=r,f=[],m=c;m==null&&(m=[1,1]),v.assert(C.eitherStridesOrDilationsAreOne(l,m),()=>`Error in depthwiseConv2d: Either strides or dilations must be 1. Got strides ${l} and dilations '${m}'`);let A=C.computeConv2DInfo(a.shape,s.shape,l,m,u,h,!0),y=Y().getBool("WEBGL_PACK_DEPTHWISECONV")&&A.strideWidth<=2&&A.outChannels/A.inChannels==1,g=d?Yd(d,y):null,w=[a,s],_=i!=null,b=o!=null,x=d==="leakyrelu";if(_&&w.push(i),b&&w.push(o),x){let E=n.makeTensorInfo([],"float32",v.createScalarValue(p,"float32"));w.push(E),f.push(E)}let N;y?N=new S_(A,_,g,b,x):N=new N_(A,_,g,b,x);let T=n.runWebGLProgram(N,w,"float32");return f.forEach(E=>n.disposeIntermediateTensorInfo(E)),T}var LB={kernelName:Bs,backendName:"webgl",kernelFunc:zB},PB=class{constructor(e,t,n){this.sliceDim=e,this.strides=t,this.variableNames=["x","indices"],this.outputShape=n;let r=lt(t.length),a=lt(n.length),s=this.sliceDim>1?"strides[j]":"strides";this.userCode=`
2021-02-21 20:07:04 +01:00
${r} strides = ${r}(${this.strides});
void main() {
${a} coords = getOutputCoords();
int flattenIndex = 0;
for (int j = 0; j < ${this.sliceDim}; j++) {
int index = round(getIndices(coords[0], j));
flattenIndex += index * ${s};
}
setOutput(getX(flattenIndex, coords[1]));
2021-02-21 20:06:13 +01:00
}
2021-02-25 13:50:13 +01:00
`}};function WB(e){let{inputs:t,backend:n}=e,{params:r,indices:a}=t,s=a.shape,i=s[s.length-1],[o,l,u,c]=C.prepareAndValidate(r,a),h=ye({inputs:{x:a},backend:n,attrs:{shape:[l,i]}}),d=ye({inputs:{x:r},backend:n,attrs:{shape:[v.sizeFromShape(r.shape)/u,u]}}),p=new PB(i,c,[l,u]),f=n.runWebGLProgram(p,[d,h],d.dtype),m=ye({inputs:{x:f},backend:n,attrs:{shape:o}});return n.disposeIntermediateTensorInfo(h),n.disposeIntermediateTensorInfo(d),n.disposeIntermediateTensorInfo(f),m}var BB={kernelName:to,backendName:"webgl",kernelFunc:WB},UB=class{constructor(e,t){this.variableNames=["A","indices"],this.outputShape=t,this.rank=t.length;let n=lt(this.rank),r=VB(e,2);this.userCode=`
2021-02-21 20:07:04 +01:00
void main() {
${n} resRC = getOutputCoords();
setOutput(getA(${r}));
2021-02-21 20:06:13 +01:00
}
2021-02-25 13:50:13 +01:00
`}};function VB(e,t){let n=["resRC.x","resRC.y","resRC.z","resRC.w"],r=[];for(let a=0;a<e.length;a++)a===2?r.push("int(getIndices(resRC.x, resRC.z))"):r.push(`${n[a]}`);return r.join()}function jB(e){let{inputs:t,backend:n,attrs:r}=e,{x:a,indices:s}=t,{axis:i,batchDims:o}=r,l=v.parseAxisParam(i,a.shape)[0],u=C.segment_util.collectGatherOpShapeInfo(a,s,l,o),c=v.sizeFromShape(s.shape),h=[],d=ye({inputs:{x:a},backend:n,attrs:{shape:[u.batchSize,u.outerSize,u.dimSize,u.sliceSize]}}),p=ye({inputs:{x:s},backend:n,attrs:{shape:[u.batchSize,c/u.batchSize]}});h.push(d),h.push(p);let f=[u.batchSize,u.outerSize,c/u.batchSize,u.sliceSize];if(n.shouldExecuteOnCPU([a,s])||a.dtype==="string"){let g=n.bufferSync(p),w=n.bufferSync(d),_=yz(w,g,f);return h.forEach(b=>n.disposeIntermediateTensorInfo(b)),n.makeTensorInfo(u.outputShape,_.dtype,_.values)}let m=new UB(d.shape,f),A=n.runWebGLProgram(m,[d,p],d.dtype);h.push(A);let y=ye({inputs:{x:A},backend:n,attrs:{shape:u.outputShape}});return h.forEach(g=>n.disposeIntermediateTensorInfo(g)),y}var HB={kernelName:eo,backendName:"webgl",kernelFunc:jB},GB="return float(a > b);",qB=`
2021-02-21 20:07:04 +01:00
return vec4(greaterThan(a, b));
2021-02-25 13:50:13 +01:00
`,XB=Qt({opSnippet:GB,packedOpSnippet:qB,cpuKernelImpl:gz,dtype:"bool"}),KB={kernelName:no,backendName:"webgl",kernelFunc:XB},ZB="return float(a >= b);",YB=`
2021-02-21 20:07:04 +01:00
return vec4(greaterThanEqual(a, b));
2021-02-25 13:50:13 +01:00
`,JB=Qt({opSnippet:ZB,packedOpSnippet:YB,dtype:"bool"}),QB={kernelName:us,backendName:"webgl",kernelFunc:JB};function eV(e){let{inputs:t,backend:n}=e,{input:r}=t;return F_(r,!0,n)}var tV={kernelName:bh,backendName:"webgl",kernelFunc:eV},nV="return float(!isnan(x) && !isinf(x));",rV=Xe({opSnippet:nV,dtype:"bool"}),aV={kernelName:ro,backendName:"webgl",kernelFunc:rV},sV="return float(isinf(x));",iV=Xe({opSnippet:sV,dtype:"bool"}),oV={kernelName:ao,backendName:"webgl",kernelFunc:iV},lV="return float(isnan(x));",uV=Xe({opSnippet:lV,dtype:"bool"}),cV={kernelName:so,backendName:"webgl",kernelFunc:uV},hV="return float(a < b);",dV=`
2021-02-21 20:07:04 +01:00
return vec4(lessThan(a, b));
2021-02-25 13:50:13 +01:00
`,pV=Qt({opSnippet:hV,packedOpSnippet:dV,cpuKernelImpl:xz,dtype:"bool"}),fV={kernelName:io,backendName:"webgl",kernelFunc:pV},mV="return float(a <= b);",AV=`
2021-02-21 20:07:04 +01:00
return vec4(lessThanEqual(a, b));
2021-02-25 13:50:13 +01:00
`,yV=Qt({opSnippet:mV,packedOpSnippet:AV,dtype:"bool"}),gV={kernelName:oo,backendName:"webgl",kernelFunc:yV};function xV(e){let{backend:t,attrs:n}=e,{start:r,stop:a,num:s}=n,i=wz(r,a,s);return t.makeTensorInfo([i.length],"float32",i)}var wV={kernelName:kh,backendName:"webgl",kernelFunc:xV},_V=`if (x < 0.0) return NAN;
return log(x);`,bV=`
2021-02-21 20:07:04 +01: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-02-25 13:50:13 +01:00
`,vV=Xe({opSnippet:_V,packedOpSnippet:bV,cpuKernelImpl:_z}),kV={kernelName:ds,backendName:"webgl",kernelFunc:vV},IV="return log(1.0 + x);",NV=Xe({opSnippet:IV}),SV={kernelName:lo,backendName:"webgl",kernelFunc:NV},TV="return float(a >= 1.0 && b >= 1.0);",EV=`
2021-02-21 20:07:04 +01:00
return vec4(
vec4(greaterThanEqual(a, vec4(1.0))) *
vec4(greaterThanEqual(b, vec4(1.0))));
2021-02-25 13:50:13 +01:00
`,CV=Qt({opSnippet:TV,packedOpSnippet:EV,dtype:"bool"}),RV={kernelName:uo,backendName:"webgl",kernelFunc:CV},FV="return float(!(x >= 1.0));",$V=Xe({opSnippet:FV}),MV={kernelName:Jl,backendName:"webgl",kernelFunc:$V},DV="return float(a >= 1.0 || b >= 1.0);",OV=`
2021-02-21 20:07:04 +01:00
return min(
vec4(greaterThanEqual(a, vec4(1.0))) +
vec4(greaterThanEqual(b, vec4(1.0))),
vec4(1.0));
2021-02-25 13:50:13 +01:00
`,zV=Qt({opSnippet:DV,packedOpSnippet:OV,dtype:"bool"}),LV={kernelName:Ql,backendName:"webgl",kernelFunc:zV},PV=class{constructor(e,t,n,r,a){this.variableNames=["x"],this.outputShape=[];let s=t,i=e[3]-1;this.outputShape=e;let o,l=`float(${n}) + float(${r}) * sum`;a===.5?o=`inversesqrt(${l})`:a===1?o=`1.0/(${l})`:o=`exp(log(${l}) * float(-${a}));`,this.userCode=`
2021-02-21 20:07:04 +01: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;
for (int j = -${s}; j <= ${s}; j++) {
int idx = d + j;
if (idx >= 0 && idx <= ${i}) {
float z = getX(b, r, c, idx);
sum += z * z;
}
}
float val = x * ${o};
setOutput(val);
2021-02-21 20:06:13 +01:00
}
2021-02-25 13:50:13 +01:00
`}},WV=class{constructor(e,t,n,r,a){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(${r}) * sum`;a===.5?o=`inversesqrt(${l})`:a===1?o=`1.0/(${l})`:o=`exp(log(${l}) * float(-${a}));`,this.userCode=`
2021-02-21 20:07:04 +01: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
);
int firstChannel = d - ${s};
vec2 cache = vec2(0.);
if(firstChannel >= 0){
vec4 firstChannelFrag = getX(b, r, c, firstChannel);
cache.x = getChannel(firstChannelFrag, vec2(c, firstChannel));
if(hasNextRow){
cache.y = getChannel(firstChannelFrag, vec2(c + 1, firstChannel));
}
}
ivec2 depth = ivec2(d, d + 1);
for (int j = - ${s}; j <= ${s}; j++) {
ivec2 idx = depth + j;
bvec2 aboveLowerBound = greaterThanEqual(idx, ivec2(0));
bvec2 belowUpperBound = lessThanEqual(idx, ivec2(${i}));
bool depthInRange = aboveLowerBound.x && belowUpperBound.x;
bool depthPlusOneInRange = aboveLowerBound.y && belowUpperBound.y;
if(depthInRange || depthPlusOneInRange){
vec4 z = vec4(0.);
vec4 xFragAtCurrentDepth;
z.xz = cache.xy;
if(depthPlusOneInRange && hasNextCol){
xFragAtCurrentDepth = idx.y != d ?
getX(b, r, c, idx.y) : xFragAtOutputCoords;
z.y = getChannel(xFragAtCurrentDepth, vec2(c, idx.y));
if(hasNextRow){
z.w = getChannel(xFragAtCurrentDepth, vec2(c + 1, idx.y));
}
}
cache.xy = z.yw;
sum += z * z;
}
}
vec4 result = xAtOutputCoords * ${o};
setOutput(result);
2021-02-21 20:06:13 +01:00
}
2021-02-25 13:50:13 +01:00
`}},BV=e=>{let{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{depthRadius:s,bias:i,alpha:o,beta:l}=r,u=Y().getBool("WEBGL_PACK_NORMALIZATION")?new WV(a.shape,s,i,o,l):new PV(a.shape,s,i,o,l);return n.runWebGLProgram(u,[a],a.dtype)},VV={kernelName:eu,backendName:"webgl",kernelFunc:BV},UV=class{constructor(e,t,n,r,a){this.variableNames=["inputImage","outputImage","dy"],this.outputShape=[],this.outputShape=e,this.depth=e[3],this.depthRadius=t,this.bias=n,this.alpha=r,this.beta=a,this.userCode=`
2021-02-21 20:07:04 +01: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;
}
}
norm = float(${r}) * norm + float(${n});
for(int k = MIN_DEPTH_BEGIN; k < MAX_DEPTH_END; ++k){
if (k < depthBegin){
continue;
}
else if (k >= depthBegin && k < depthEnd){
float dyi = -2.0 * float(${r})
* float(${a})
* getInputImage(b ,r ,c, k) * getOutputImage(b, r, c, d)
/ norm;
if (k == d) {
dyi += pow(norm, -1.0 * ${a});
}
if (k == coords[3]) {
dyi *= getDy(b, r, c, d);
result += dyi;
}
}
else {
break;
}
}
2021-02-21 20:06:13 +01:00
}
2021-02-21 20:07:04 +01:00
setOutput(result);
2021-02-21 20:06:13 +01:00
}
2021-02-25 13:50:13 +01:00
`}},jV=e=>{let{inputs:t,backend:n,attrs:r}=e,{x:a,y:s,dy:i}=t,{depthRadius:o,bias:l,alpha:u,beta:c}=r,h=new UV(a.shape,o,l,u,c);return n.runWebGLProgram(h,[a,s,i],a.dtype)},HV={kernelName:Ih,backendName:"webgl",kernelFunc:jV};function GV(e,t,n,r){let a=v.sizeFromShape(t),s=v.sizeFromShape(e.shape)/a,i=ye({inputs:{x:e},attrs:{shape:[s,a]},backend:r}),o=ui(i,e.dtype,"max",r),l=ye({inputs:{x:o},attrs:{shape:n},backend:r});return r.disposeIntermediateTensorInfo(i),r.disposeIntermediateTensorInfo(o),l}function M_(e){let{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{reductionIndices:s,keepDims:i}=r,o=a.shape.length,l=v.parseAxisParam(s,a.shape),u=l,c=C.getAxesPermutation(u,o),h=c!=null,d=n.shouldExecuteOnCPU([a]),p=a;if(h){if(d){let g=n.texData.get(p.dataId).values,w=new Array(o);for(let x=0;x<w.length;x++)w[x]=a.shape[c[x]];let _=NA(g,a.shape,a.dtype,c,w);p=n.makeTensorInfo(w,a.dtype);let b=n.texData.get(p.dataId);b.values=_}else p=Jd(a,c,n);u=C.getInnerMostAxes(u.length,o)}C.assertAxesAreInnerMostDims("max",u,o);let[f,m]=C.computeOutAndReduceShapes(p.shape,u),A=f;i&&(A=C.expandShapeToKeepDim(f,l));let y;if(d){let g=n.texData.get(p.dataId).values,w=bz(g,v.sizeFromShape(m),A,a.dtype);y=n.makeTensorInfo(A,a.dtype);let _=n.texData.get(y.dataId);_.values=w}else y=GV(p,m,A,n);return h&&n.disposeIntermediateTensorInfo(p),y}var qV={kernelName:ps,backendName:"webgl",kernelFunc:M_},XV=Yw+`
2021-02-21 20:07:04 +01:00
return max(a, b);
2021-02-25 13:50:13 +01:00
`,KV=`
2021-02-21 20:07:04 +01:00
vec4 result = vec4(max(a, b));
vec4 isNaN = min(vec4(isnan(a)) + vec4(isnan(b)), vec4(1.0));
2021-02-25 13:50:13 +01:00
`+Zd+`
2021-02-21 20:07:04 +01:00
return result;
2021-02-25 13:50:13 +01:00
`,ZV=Qt({opSnippet:XV,packedOpSnippet:KV,cpuKernelImpl:vz}),YV={kernelName:fs,backendName:"webgl",kernelFunc:ZV};function JV(e){let{inputs:t,backend:n,attrs:r}=e,{x:a}=t;hl(a,"maxPool");let{filterSize:s,strides:i,pad:o,dimRoundingMode:l}=r,u=1;v.assert(C.eitherStridesOrDilationsAreOne(i,u),()=>`Error in maxPool: Either strides or dilations must be 1. Got strides ${i} and dilations '${u}'`);let c=C.computePool2DInfo(a.shape,s,i,u,o,l);if(c.filterWidth===1&&c.filterHeight===1&&v.arraysEqual(c.inShape,c.outShape))return Fn({inputs:{x:a},backend:n});let h=new Qu(c,"max",!1);return n.runWebGLProgram(h,[a],a.dtype)}var QV={kernelName:ms,backendName:"webgl",kernelFunc:JV};function eU(e){let{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{filterSize:s,strides:i,pad:o,dataFormat:l,dimRoundingMode:u}=r,c=[1,1,1],h=C.computePool3DInfo(a.shape,s,i,c,o,u,l),d=new EA(h,"max",!1);return n.runWebGLProgram(d,[a],a.dtype)}var tU={kernelName:tu,backendName:"webgl",kernelFunc:eU},nU=class{constructor(e){this.variableNames=["dy","maxPos"],this.outputShape=e.inShape;let t=e.strideHeight,n=e.strideWidth,r=e.dilationHeight,a=e.effectiveFilterHeight,s=e.effectiveFilterWidth,i=a-1-e.padInfo.top,o=s-1-e.padInfo.left,l=a*s-1;this.userCode=`
2021-02-21 20:07:04 +01:00
const ivec2 pads = ivec2(${i}, ${o});
void main() {
ivec4 coords = getOutputCoords();
int b = coords[0];
int d = coords[3];
ivec2 dyRCCorner = coords.yz - pads;
int dyRCorner = dyRCCorner.x;
int dyCCorner = dyRCCorner.y;
// Convolve dy(?, ?, d) with pos mask(:, :, d) to get dx(xR, xC, d).
// ? = to be determined. : = across all values in that axis.
float dotProd = 0.0;
for (int wR = 0; wR < ${a};
wR += ${r}) {
float dyR = float(dyRCorner + wR) / ${t}.0;
if (dyR < 0.0 || dyR >= ${e.outHeight}.0 || fract(dyR) > 0.0) {
continue;
}
int idyR = int(dyR);
for (int wC = 0; wC < ${s}; wC++) {
float dyC = float(dyCCorner + wC) / ${n}.0;
if (dyC < 0.0 || dyC >= ${e.outWidth}.0 ||
fract(dyC) > 0.0) {
continue;
}
int idyC = int(dyC);
float dyValue = getDy(b, idyR, idyC, d);
int maxPosValue = ${l} - int(getMaxPos(b, idyR, idyC, d));
// Get the current value, check it against the value from the
// position matrix.
int curPosValue = wR * ${s} + wC;
float mask = float(maxPosValue == curPosValue ? 1.0 : 0.0);
dotProd += dyValue * mask;
}
2021-02-21 20:06:13 +01:00
}
2021-02-21 20:07:04 +01:00
setOutput(dotProd);
2021-02-21 20:06:13 +01:00
}
2021-02-25 13:50:13 +01:00
`}},rU=class{constructor(e){this.variableNames=["dy","maxPos"],this.outputShape=e.inShape;let t=e.strideDepth,n=e.strideHeight,r=e.strideWidth,a=e.dilationDepth,s=e.dilationHeight,i=e.dilationWidth,o=e.effectiveFilterDepth,l=e.effectiveFilterHeight,u=e.effectiveFilterWidth,c=o-1-e.padInfo.front,h=l-1-e.padInfo.top,d=u-1-e.padInfo.left,p=o*l*u-1;this.userCode=`
const ivec3 pads = ivec3(${c}, ${h}, ${d});
2021-02-21 20:07:04 +01: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;
for (int wD = 0; wD < ${o};
wD += ${a}) {
float dyD = float(dyDCorner + wD) / ${t}.0;
if (dyD < 0.0 || dyD >= ${e.outDepth}.0 || fract(dyD) > 0.0) {
continue;
2021-02-21 20:06:13 +01:00
}
2021-02-21 20:07:04 +01:00
int idyD = int(dyD);
for (int wR = 0; wR < ${l};
wR += ${s}) {
float dyR = float(dyRCorner + wR) / ${n}.0;
if (dyR < 0.0 || dyR >= ${e.outHeight}.0 ||
fract(dyR) > 0.0) {
continue;
2021-02-21 20:06:13 +01:00
}
2021-02-21 20:07:04 +01:00
int idyR = int(dyR);
2021-02-25 13:50:13 +01:00
for (int wC = 0; wC < ${u};
2021-02-21 20:07:04 +01:00
wC += ${i}) {
float dyC = float(dyCCorner + wC) / ${r}.0;
if (dyC < 0.0 || dyC >= ${e.outWidth}.0 ||
fract(dyC) > 0.0) {
continue;
}
int idyC = int(dyC);
float dyValue = getDy(batch, idyD, idyR, idyC, ch);
int maxPosValue = ${p} -
int(getMaxPos(batch, idyD, idyR, idyC, ch));
// Get the current value, check it against the value from the
// position matrix.
int curPosValue =
2021-02-25 13:50:13 +01:00
wD * ${l} * ${u} +
wR * ${u} + wC;
2021-02-21 20:07:04 +01:00
float mask = float(maxPosValue == curPosValue ? 1.0 : 0.0);
dotProd += dyValue * mask;
2021-02-21 20:06:13 +01:00
}
}
}
2021-02-21 20:07:04 +01:00
setOutput(dotProd);
2021-02-21 20:06:13 +01:00
}
2021-02-25 13:50:13 +01:00
`}};function aU(e){let{inputs:t,backend:n,attrs:r}=e,{dy:a,input:s}=t,i=s,{filterSize:o,strides:l,pad:u,dimRoundingMode:c}=r,h=[1,1,1],d=C.computePool3DInfo(i.shape,o,l,h,u,c),p=new EA(d,"max",!0),f=n.runWebGLProgram(p,[i],i.dtype),m=new rU(d),A=n.runWebGLProgram(m,[a,f],i.dtype);return n.disposeIntermediateTensorInfo(f),A}var sU={kernelName:Sh,backendName:"webgl",kernelFunc:aU};function iU(e){let{inputs:t,backend:n,attrs:r}=e,{dy:a,input:s,output:i}=t,o=s;hl([s,i],"maxPoolGrad");let{filterSize:l,strides:u,pad:c,dimRoundingMode:h}=r,d=C.computePool2DInfo(o.shape,l,u,1,c,h),p=!0,f=new Qu(d,"max",p),m=n.runWebGLProgram(f,[o],o.dtype),A=new nU(d),y=n.runWebGLProgram(A,[a,m],o.dtype);return n.disposeIntermediateTensorInfo(m),y}var oU={kernelName:Nh,backendName:"webgl",kernelFunc:iU};function lU(e,t,n,r){let a=new Qu(n,"max",!1),s=r.runWebGLProgram(a,[e],"float32");a=new Qu(n,"max",!0,!0,t);let i=r.runWebGLProgram(a,[e],"float32");return[s,i]}var uU={kernelName:Th,backendName:"webgl",kernelFunc:({inputs:e,attrs:t,backend:n})=>{let{x:r}=e,{filterSize:a,strides:s,pad:i,includeBatchInIndex:o}=t,l=n;v.assert(r.shape.length===4,()=>`Error in maxPool: input must be rank 4 but got rank ${r.shape.length}.`);let u=[1,1];v.assert(C.eitherStridesOrDilationsAreOne(s,u),()=>`Error in maxPool: Either strides or dilations must be 1. Got strides ${s} and dilations '${u}'`);let c=C.computePool2DInfo(r.shape,a,s,u,i),[h,d]=lU(r,o,c,l);return[h,d]}};function cU(e,t,n,r){let a=v.sizeFromShape(t),s=v.sizeFromShape(e.shape)/a,i=ye({inputs:{x:e},attrs:{shape:[s,a]},backend:r}),o=ui(i,"float32","mean",r),l=ye({inputs:{x:o},attrs:{shape:n},backend:r});return r.disposeIntermediateTensorInfo(i),r.disposeIntermediateTensorInfo(o),l}var hU={kernelName:As,backendName:"webgl",kernelFunc:({inputs:e,attrs:t,backend:n})=>{let{x:r}=e,{keepDims:a,axis:s}=t,i=n,o=r.shape.length,l=v.parseAxisParam(s,r.shape),u=l,c=C.getAxesPermutation(u,o),h=c!=null,d=i.shouldExecuteOnCPU([r]),p=[],f=r;if(h){if(d){let w=i.texData.get(f.dataId).values,_=new Array(o);for(let N=0;N<_.length;N++)_[N]=r.shape[c[N]];let b=NA(w,r.shape,r.dtype,c,_);f=i.makeTensorInfo(_,r.dtype);let x=i.texData.get(f.dataId);x.values=b}else f=Jd(r,c,i);p.push(f),u=C.getInnerMostAxes(u.length,o)}C.assertAxesAreInnerMostDims("sum",u,o);let[m,A]=C.computeOutAndReduceShapes(f.shape,u),y=m;a&&(y=C.expandShapeToKeepDim(m,l));let g=cU(f,A,y,i);for(let w of p)i.disposeIntermediateTensorInfo(w);return g}};function dU(e){let{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{axis:s,keepDims:i}=r,o=a.shape.length,l=v.parseAxisParam(s,a.shape),u=l,c=C.getAxesPermutation(u,o),h=a;c!=null&&(h=wn({inputs:{x:a},backend:n,attrs:{perm:c}}),u=C.getInnerMostAxes(u.length,a.shape.length)),C.assertAxesAreInnerMostDims("min",u,o);let[d,p]=C.computeOutAndReduceShapes(h.shape,u),f=v.sizeFromShape(p),m=ye({inputs:{x:h},backend:n,attrs:{shape:[-1,f]}}),A=ui(m,m.dtype,"min",n),y;if(i){let g=C.expandShapeToKeepDim(d,l);y=ye({inputs:{x:A},backend:n,attrs:{shape:g}})}else y=ye({inputs:{x:A},backend:n,attrs:{shape:d}});return n.disposeIntermediateTensorInfo(m),n.disposeIntermediateTensorInfo(A),c!=null&&n.disposeIntermediateTensorInfo(h),y}var pU={kernelName:ys,backendName:"webgl",kernelFunc:dU},fU=Yw+`
2021-02-21 20:07:04 +01:00
return min(a, b);
2021-02-25 13:50:13 +01:00
`,mU=`
2021-02-21 20:07:04 +01:00
vec4 result = vec4(min(a, b));
vec4 isNaN = min(vec4(isnan(a)) + vec4(isnan(b)), vec4(1.0));
2021-02-25 13:50:13 +01:00
`+Zd+`
2021-02-21 20:07:04 +01:00
return result;
2021-02-25 13:50:13 +01:00
`,AU=Qt({opSnippet:fU,packedOpSnippet:mU,cpuKernelImpl:kz}),yU={kernelName:gs,backendName:"webgl",kernelFunc:AU},gU=class{constructor(e,t,n){this.variableNames=["x"],this.outputShape=t.map((u,c)=>u[0]+e[c]+u[1]);let r=e.length,a=lt(r),s=t.map(u=>u[0]).join(","),i=t.map((u,c)=>u[0]+e[c]).join(","),o=["coords[0]","coords[1]","coords[2]","coords[3]"].slice(0,r),l=n==="reflect"?0:1;if(r===1){this.userCode=`
2021-02-21 20:07:04 +01:00
int start = ${s};
int end = ${i};
void main() {
int outC = getOutputCoords();
if (outC < start) {
outC = start * 2 - outC - ${l};
} else if(outC >= end) {
outC = (end - 1) * 2 - outC + ${l};
2021-02-21 20:06:13 +01:00
}
2021-02-21 20:07:04 +01:00
setOutput(getX(outC - start));
2021-02-21 20:06:13 +01:00
}
2021-02-21 20:07:04 +01:00
`;return}this.userCode=`
${a} start = ${a}(${s});
${a} end = ${a}(${i});
void main() {
${a} outC = getOutputCoords();
for (int i = 0; i < ${r}; i++) {
if (outC[i] < start[i]) {
outC[i] = start[i] * 2 - outC[i] - ${l};
} else if(outC[i] >= end[i]) {
outC[i] = (end[i] - 1) * 2 - outC[i] + ${l};
2021-02-21 20:06:13 +01:00
}
2021-02-21 20:07:04 +01:00
}
${a} coords = outC - start;
setOutput(getX(${o}));
}
2021-02-25 13:50:13 +01:00
`}},xU=class{constructor(e,t,n){this.variableNames=["x"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=t.map((p,f)=>p[0]+e[f]+p[1]);let r=e.length,a=lt(r),s=t.map(p=>p[0]).join(","),i=t.map((p,f)=>p[0]+e[f]).join(","),o=cn("rc",r),l=cn("source",r),u=`${o[r-1]} < ${this.outputShape[r-1]}`,c=r===1?"source":`vec2(${l.slice(-2).join()})`,h=n==="reflect"?0:1,d="";if(r===1){let p=`
2021-02-21 20:07:04 +01:00
${a} source = rc;
if (source < start) {
source = start * 2 - source - ${h};
} else if (source >= end) {
source = (end - 1) * 2 - source + ${h};
}
source -= start;
`;d=`
${a} rc = outputLoc;
${p}
2021-02-25 13:50:13 +01:00
result[0] = getChannel(getX(${l.join()}), ${c});
2021-02-21 20:07:04 +01:00
${o[r-1]} += 1;
2021-02-25 13:50:13 +01:00
if(${u}) {
2021-02-21 20:07:04 +01:00
${p}
2021-02-25 13:50:13 +01:00
result[1] = getChannel(getX(${l.join()}), ${c});
2021-02-21 20:07:04 +01:00
}
`}else{let p=`
${a} source = rc;
${a} lt = ${a}(lessThan(source, start));
${a} gte = ${a}(greaterThanEqual(source, end));
${a} orig = 1 - (lt + gte);
source = orig * source +
lt * (start * 2 - source - ${h}) +
gte * ((end - 1) * 2 - source + ${h});
source -= start;
`;d=`
${a} rc = outputLoc;
${p}
2021-02-25 13:50:13 +01:00
result[0] = getChannel(getX(${l.join()}), ${c});
2021-02-21 20:07:04 +01:00
${o[r-1]} += 1;
2021-02-25 13:50:13 +01:00
if(${u}) {
2021-02-21 20:07:04 +01:00
${p}
2021-02-25 13:50:13 +01:00
result[1] = getChannel(getX(${l.join()}), ${c});
2021-02-21 20:07:04 +01:00
}
rc = outputLoc;
${o[r-2]} += 1;
if(${o[r-2]} < ${this.outputShape[r-2]}) {
${p}
2021-02-25 13:50:13 +01:00
result[2] = getChannel(getX(${l.join()}), ${c});
2021-02-21 20:07:04 +01:00
${o[r-1]} += 1;
2021-02-25 13:50:13 +01:00
if(${u}) {
2021-02-21 20:07:04 +01:00
${p}
2021-02-25 13:50:13 +01:00
result[3] = getChannel(getX(${l.join()}), ${c});
2020-12-16 20:49:14 +01:00
}
2021-02-21 20:07:04 +01:00
}
`}this.userCode=`
const ${a} start = ${a}(${s});
const ${a} end = ${a}(${i});
void main() {
${a} outputLoc = getOutputCoords();
vec4 result = vec4(0.);
${d}
setOutput(result);
2021-02-21 20:06:13 +01:00
}
2021-02-25 13:50:13 +01:00
`}},wU=({inputs:e,backend:t,attrs:n})=>{let{x:r}=e,{paddings:a,mode:s}=n,i=Y().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new xU(r.shape,a,s):new gU(r.shape,a,s);return t.runWebGLProgram(i,[r],r.dtype)},_U={kernelName:nu,backendName:"webgl",kernelFunc:wU},bU=`if (b == 0.0) return NAN;
return mod(a, b);`,vU=`
2021-02-21 20:07:04 +01:00
vec4 result = mod(a, b);
vec4 isNaN = vec4(equal(b, vec4(0.0)));
2021-02-25 13:50:13 +01:00
`+Zd+`
2021-02-21 20:07:04 +01:00
return result;
2021-02-25 13:50:13 +01:00
`,kU=Qt({opSnippet:bU,packedOpSnippet:vU}),IU={kernelName:co,backendName:"webgl",kernelFunc:kU},NU=class{constructor(e,t,n){this.variableNames=["probs"],this.outputShape=[e,n],this.userCode=`
2021-02-21 20:07:04 +01:00
uniform float seed;
void main() {
ivec2 coords = getOutputCoords();
int batch = coords[0];
float r = random(seed);
float cdf = 0.0;
for (int i = 0; i < ${t-1}; i++) {
cdf += getProbs(batch, i);
if (r < cdf) {
setOutput(float(i));
return;
}
}
// If no other event happened, last event happened.
setOutput(float(${t-1}));
}
2021-02-25 13:50:13 +01:00
`}getCustomSetupFunc(e){return(t,n)=>{this.seedLoc==null&&(this.seedLoc=t.getUniformLocation(n,"seed")),t.gl.uniform1f(this.seedLoc,e)}}},SU=`
2021-02-21 20:07:04 +01:00
if (a == b) {
return 1.0;
2021-02-21 20:06:13 +01:00
};
2021-02-25 13:50:13 +01:00
return a / b;`,TU=`
2021-02-21 20:07:04 +01: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-02-21 20:06:13 +01:00
}
2021-02-21 20:07:04 +01:00
if(a.y == b.y) {
result.y = 1.;
2021-02-21 20:06:13 +01:00
}
2021-02-21 20:07:04 +01:00
if(a.z == b.z) {
result.z = 1.;
2021-02-21 20:06:13 +01:00
}
2021-02-21 20:07:04 +01:00
if(a.w == b.w) {
result.w = 1.;
2021-02-21 20:06:13 +01:00
}
2021-02-21 20:07:04 +01:00
return result;
2021-02-25 13:50:13 +01:00
`,D_=Qt({opSnippet:SU,packedOpSnippet:TU,checkOutOfBounds:!0}),EU={kernelName:as,backendName:"webgl",kernelFunc:D_},O_="return a - b;",z_=Qt({opSnippet:O_,packedOpSnippet:O_,supportsComplex:!0,cpuKernelImpl:Fz}),CU={kernelName:Os,backendName:"webgl",kernelFunc:z_};function L_(e){let{inputs:t,backend:n,attrs:r}=e,{logits:a}=t,{dim:s}=r,i=v.parseAxisParam([s],a.shape),o=M_({inputs:{x:a},backend:n,attrs:{reductionIndices:i,keepDims:!1}}),l=C.expandShapeToKeepDim(o.shape,i),u=ye({inputs:{x:o},backend:n,attrs:{shape:l}}),c=z_({inputs:{a,b:u},backend:n}),h=E_({inputs:{x:c},backend:n}),d=TA({inputs:{x:h},backend:n,attrs:{axis:i,keepDims:!1}}),p=ye({inputs:{x:d},backend:n,attrs:{shape:l}}),f=D_({inputs:{a:h,b:p},backend:n});return n.disposeIntermediateTensorInfo(o),n.disposeIntermediateTensorInfo(u),n.disposeIntermediateTensorInfo(c),n.disposeIntermediateTensorInfo(h),n.disposeIntermediateTensorInfo(d),n.disposeIntermediateTensorInfo(p),f}var RU={kernelName:Ms,backendName:"webgl",kernelFunc:L_};function FU(e){let{inputs:t,backend:n,attrs:r}=e,{logits:a}=t,{numSamples:s,seed:i,normalized:o}=r,l=o?a:L_({inputs:{logits:a},backend:n,attrs:{dim:a.shape.length-1}}),u=l.shape[0],c=l.shape[1],h=new NU(u,c,s),d=h.getCustomSetupFunc(i),p=n.runWebGLProgram(h,[l],"int32",d);return o||n.disposeIntermediateTensorInfo(l),p}var $U={kernelName:Eh,backendName:"webgl",kernelFunc:FU},P_="return -x;";function MU(e){let{inputs:t,backend:n}=e,{x:r}=t;if(n.shouldExecuteOnCPU([r])){let s=n.texData.get(r.dataId),[i,o]=Nz(s.values,r.shape,r.dtype);return n.makeTensorInfo(o,r.dtype,i)}let a;return Y().getBool("WEBGL_PACK_UNARY_OPERATIONS")?a=new yl(r.shape,P_):a=new $a(r.shape,P_),n.runWebGLProgram(a,[r],r.dtype)}var DU={kernelName:ho,backendName:"webgl",kernelFunc:MU},OU=Rr.nonMaxSuppressionV3Impl;function zU(e){C.warn("tf.nonMaxSuppression() in webgl locks the UI thread. Call tf.nonMaxSuppressionAsync() instead");let{inputs:t,backend:n,attrs:r}=e,{boxes:a,scores:s}=t,{maxOutputSize:i,iouThreshold:o,scoreThreshold:l}=r,u=n.readSync(a.dataId),c=n.readSync(s.dataId),{selectedIndices:h}=OU(u,c,i,o,l);return n.makeTensorInfo([h.length],"int32",new Int32Array(h))}var LU={kernelName:fo,backendName:"webgl",kernelFunc:zU},PU=Rr.nonMaxSuppressionV4Impl;function WU(e){C.warn("tf.nonMaxSuppression() in webgl locks the UI thread. Call tf.nonMaxSuppressionAsync() instead");let{inputs:t,backend:n,attrs:r}=e,{boxes:a,scores:s}=t,{maxOutputSize:i,iouThreshold:o,scoreThreshold:l,padToMaxOutputSize:u}=r,c=n.readSync(a.dataId),h=n.readSync(s.dataId),{selectedIndices:d,validOutputs:p}=PU(c,h,i,o,l,u);return[n.makeTensorInfo([d.length],"int32",new Int32Array(d)),n.makeTensorInfo([],"int32",new Int32Array([p]))]}var BU={kernelName:mo,backendName:"webgl",kernelFunc:WU},VU=Rr.nonMaxSuppressionV5Impl;function UU(e){C.warn("tf.nonMaxSuppression() in webgl locks the UI thread. Call tf.nonMaxSuppressionAsync() instead");let{inputs:t,backend:n,attrs:r}=e,{boxes:a,scores:s}=t,{maxOutputSize:i,iouThreshold:o,scoreThreshold:l,softNmsSigma:u}=r,c=n.readSync(a.dataId),h=n.readSync(s.dataId),d=i,p=o,f=l,m=u,{selectedIndices:A,selectedScores:y}=VU(c,h,d,p,f,m);return[n.makeTensorInfo([A.length],"int32",new Int32Array(A)),n.makeTensorInfo([y.length],"float32",new Float32Array(y))]}var jU={kernelName:Ao,backendName:"webgl",kernelFunc:UU},HU=class{constructor(e,t,n,r){this.variableNames=["indices"],this.outputShape=[e,t],this.userCode=`
2021-02-21 20:07:04 +01:00
void main() {
ivec2 coords = getOutputCoords();
int index = round(getIndices(coords.x));
setOutput(mix(float(${r}), float(${n}),
float(index == coords.y)));
2021-02-21 20:06:13 +01:00
}
2021-02-25 13:50:13 +01:00
`}},GU=e=>{let{inputs:t,backend:n,attrs:r}=e,{indices:a}=t,{depth:s,onValue:i,offValue:o}=r,l=v.sizeFromShape(a.shape),u=new HU(l,s,i,o),c=ye({inputs:{x:a},backend:n,attrs:{shape:[l]}}),h=n.runWebGLProgram(u,[c],a.dtype);n.disposeIntermediateTensorInfo(c);let d=[...a.shape,s],p=ye({inputs:{x:h},backend:n,attrs:{shape:d}});return n.disposeIntermediateTensorInfo(h),p},qU={kernelName:ws,backendName:"webgl",kernelFunc:GU};function rp(e){let{inputs:t,backend:n}=e,{x:r}=t;if(r.dtype==="complex64"){let a=tc({inputs:{input:r},backend:n}),s=rp({inputs:{x:a},backend:n}),i=np({inputs:{input:r},backend:n}),o=rp({inputs:{x:i},backend:n}),l=Ma({inputs:{real:s,imag:o},backend:n});return n.disposeIntermediateTensorInfo(a),n.disposeIntermediateTensorInfo(s),n.disposeIntermediateTensorInfo(i),n.disposeIntermediateTensorInfo(o),l}else return $A({attrs:{shape:r.shape,dtype:r.dtype,value:r.dtype==="string"?"":0},backend:n})}var XU={kernelName:Mo,backendName:"webgl",kernelFunc:rp};function W_(e){let{inputs:t,backend:n}=e,{x:r}=t;if(r.dtype==="string")throw new Error("onesLike is not supported under string dtype");if(r.dtype==="complex64"){let a=tc({inputs:{input:r},backend:n}),s=W_({inputs:{x:a},backend:n}),i=np({inputs:{input:r},backend:n}),o=rp({inputs:{x:i},backend:n}),l=Ma({inputs:{real:s,imag:o},backend:n});return n.disposeIntermediateTensorInfo(a),n.disposeIntermediateTensorInfo(s),n.disposeIntermediateTensorInfo(i),n.disposeIntermediateTensorInfo(o),l}else return $A({attrs:{shape:r.shape,dtype:r.dtype,value:1},backend:n})}var KU={kernelName:yo,backendName:"webgl",kernelFunc:W_};function ZU(e){let{inputs:t,backend:n,attrs:r}=e,{axis:a}=r;if(t.length===1)return FA({inputs:{input:t[0]},backend:n,attrs:{dim:a}});let s=t[0].shape,i=t[0].dtype;t.forEach(c=>{v.assertShapesMatch(s,c.shape,"All tensors passed to stack must have matching shapes"),v.assert(i===c.dtype,()=>"All tensors passed to stack must have matching dtypes")});let o=[],l=t.map(c=>{let h=FA({inputs:{input:c},backend:n,attrs:{dim:a}});return o.push(h),h}),u=x_({inputs:l,backend:n,attrs:{axis:a}});return o.forEach(c=>n.disposeIntermediateTensorInfo(c)),u}var YU={kernelName:go,backendName:"webgl",kernelFunc:ZU},JU=class{constructor(e,t,n){this.variableNames=["x"],this.outputShape=t.map((l,u)=>l[0]+e[u]+l[1]);let r=e.length,a=lt(r),s=t.map(l=>l[0]).join(","),i=t.map((l,u)=>l[0]+e[u]).join(","),o=["coords[0]","coords[1]","coords[2]","coords[3]"].slice(0,r);if(r===1){this.userCode=`
2021-02-21 20:07:04 +01:00
int start = ${s};
int end = ${i};
void main() {
int outC = getOutputCoords();
if (outC < start || outC >= end) {
setOutput(float(${n}));
} else {
setOutput(getX(outC - start));
}
}
`;return}this.userCode=`
${a} start = ${a}(${s});
${a} end = ${a}(${i});
void main() {
${a} outC = getOutputCoords();
if (any(lessThan(outC, start)) || any(greaterThanEqual(outC, end))) {
setOutput(float(${n}));
} else {
${a} coords = outC - start;
setOutput(getX(${o}));
}
2021-02-21 20:06:13 +01:00
}
2021-02-25 13:50:13 +01:00
`}},QU=class{constructor(e,t,n){this.variableNames=["x"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=t.map((f,m)=>f[0]+e[m]+f[1]);let r=e.length,a=lt(r),s=t.map(f=>f[0]).join(","),i=t.map((f,m)=>f[0]+e[m]).join(","),o=cn("rc",r),l=cn("source",r),u=`${o[r-1]} < ${this.outputShape[r-1]}`,c=r===1?"source":`vec2(${l.slice(-2).join()})`,h=[`${a} rc = outputLoc;`,`${o[r-1]} += 1;
if(${u}) {
2021-02-21 20:07:04 +01:00
`,r===1?"":`}
rc = outputLoc;
${o[r-2]} += 1;
if(${o[r-2]} < ${this.outputShape[r-2]}) {`,r===1?"":` ${o[r-1]} += 1;
2021-02-25 13:50:13 +01:00
if(${u}) {`],d=r===1?"rc < start || rc >= end":"any(lessThan(rc, start)) || any(greaterThanEqual(rc, end))",p="";for(let f=0,m=r===1?2:4;f<m;f++)p+=`
2021-02-21 20:07:04 +01:00
${h[f]}
if (${d}) {
result[${f}] = float(${n});
} else {
${a} source = rc - start;
2021-02-25 13:50:13 +01:00
result[${f}] = getChannel(getX(${l.join()}), ${c});
2021-02-21 20:07:04 +01:00
}
`;p+=r===1?"} ":"}}",this.userCode=`
const ${a} start = ${a}(${s});
const ${a} end = ${a}(${i});
void main() {
${a} outputLoc = getOutputCoords();
vec4 result = vec4(0.);
${p}
setOutput(result);
2021-02-21 20:06:13 +01:00
}
2021-02-25 13:50:13 +01:00
`}},B_=e=>{let{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{paddings:s,constantValue:i}=r,o=Y().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new QU(a.shape,s,i):new JU(a.shape,s,i);return n.runWebGLProgram(o,[a],a.dtype)},ej={kernelName:_s,backendName:"webgl",kernelFunc:B_},tj=`
2021-02-21 20:07:04 +01:00
if(a < 0.0 && floor(b) < b){
return NAN;
2021-02-21 20:06:13 +01:00
}
2021-02-21 20:07:04 +01:00
if (b == 0.0) {
return 1.0;
2021-02-21 20:06:13 +01:00
}
2021-02-21 20:07:04 +01:00
return (round(mod(b, 2.0)) != 1) ?
pow(abs(a), b) : sign(a) * pow(abs(a), b);
2021-02-25 13:50:13 +01:00
`,nj=`
2021-02-21 20:07:04 +01: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-02-25 13:50:13 +01:00
`+Zd+`
2021-02-21 20:07:04 +01:00
return result;
2021-02-25 13:50:13 +01:00
`,rj=Qt({opSnippet:tj,packedOpSnippet:nj}),aj={kernelName:bs,backendName:"webgl",kernelFunc:rj};function sj(e){let{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{axis:s,keepDims:i}=r,o=a.shape.length,l=[],u=v.parseAxisParam(s,a.shape),c=u,h=C.getAxesPermutation(c,o),d=a;h!=null&&(d=wn({inputs:{x:a},backend:n,attrs:{perm:h}}),c=C.getInnerMostAxes(c.length,o),l.push(d)),C.assertAxesAreInnerMostDims("prod",c,o);let p;if(n.shouldExecuteOnCPU([d])){let f=n.texData.get(d.dataId).values,{outVals:m,outShape:A,outDtype:y}=Sz(d.shape,d.dtype,f,c);p=n.makeTensorInfo(A,y,m)}else{let[f,m]=C.computeOutAndReduceShapes(d.shape,c),A=v.sizeFromShape(m),y=ye({inputs:{x:d},backend:n,attrs:{shape:[-1,A]}}),g=zh(a.dtype),w=ui(y,g,"prod",n);p=ye({inputs:{x:w},backend:n,attrs:{shape:f}}),l.push(y),l.push(w)}if(i){l.push(p);let f=C.expandShapeToKeepDim(p.shape,u);p=ye({inputs:{x:p},backend:n,attrs:{shape:f}})}return l.forEach(f=>n.disposeIntermediateTensorInfo(f)),p}var ij={kernelName:xo,backendName:"webgl",kernelFunc:sj},V_=e=>{let{backend:t,attrs:n}=e,{start:r,stop:a,step:s,dtype:i}=n,o=Tz(r,a,s,i);return t.makeTensorInfo([o.length],i,o)},oj={kernelName:ru,backendName:"webgl",kernelFunc:V_},lj="return 1.0 / x;",uj=Xe({opSnippet:lj}),cj={kernelName:wo,backendName:"webgl",kernelFunc:uj},hj=mr+`
2021-02-21 20:07:04 +01:00
return (x < 0.0) ? 0.0 : x;
2021-02-25 13:50:13 +01:00
`,dj=`
2021-02-21 20:07:04 +01: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-02-25 13:50:13 +01:00
`,pj=Xe({opSnippet:hj,packedOpSnippet:dj}),fj={kernelName:ks,backendName:"webgl",kernelFunc:pj},mj=mr+`
2021-02-21 20:07:04 +01:00
return (x < 0.0) ? 0.0 : min(6.0, x);
2021-02-25 13:50:13 +01:00
`,Aj=`
2021-02-21 20:07:04 +01: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-02-25 13:50:13 +01:00
`,yj=Xe({opSnippet:mj,packedOpSnippet:Aj}),gj={kernelName:Ns,backendName:"webgl",kernelFunc:yj},xj=class{constructor(e,t,n,r,a){this.variableNames=["A"],this.outputShape=[];let[s,i,o,l]=e;this.outputShape=[s,t,n,l];let u=[r&&t>1?i-1:i,r&&n>1?o-1:o],c=[r&&t>1?t-1:t,r&&n>1?n-1:n],h;a?h="(vec2(yRC) + vec2(0.5)) * effectiveInputOverOutputRatioRC - vec2(0.5)":h="vec2(yRC) * effectiveInputOverOutputRatioRC",this.userCode=`
2021-02-21 20:07:04 +01:00
const vec2 effectiveInputOverOutputRatioRC = vec2(
2021-02-25 13:50:13 +01:00
${u[0]/c[0]},
${u[1]/c[1]});
2021-02-21 20:07:04 +01:00
const vec2 inputShapeRC = vec2(${i}.0, ${o}.0);
void main() {
ivec4 coords = getOutputCoords();
int b = coords[0];
int d = coords[3];
ivec2 yRC = coords.yz;
// Fractional source index.
vec2 sourceFracIndexRC = ${h};
// 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-02-21 20:06:13 +01:00
}
2021-02-25 13:50:13 +01:00
`}},wj=class{constructor(e,t,n,r,a){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=[];let[s,i,o,l]=e;this.outputShape=[s,t,n,l];let u=[r&&t>1?i-1:i,r&&n>1?o-1:o],c=[r&&t>1?t-1:t,r&&n>1?n-1:n],h;a?h="(vec3(yRC) + vec3(0.5)) * effectiveInputOverOutputRatioRC - vec3(0.5)":h="vec3(yRC) * effectiveInputOverOutputRatioRC",this.userCode=`
2021-02-21 20:07:04 +01:00
const vec3 effectiveInputOverOutputRatioRC = vec3(
2021-02-25 13:50:13 +01:00
${u[0]/c[0]},
${u[1]/c[1]},
${u[1]/c[1]});
2021-02-21 20:07:04 +01:00
const vec3 inputShapeRC = vec3(${i}.0, ${o}.0,
${o}.0);
float getAValue(int b, int r, int c, int d) {
return getChannel(getA(b, r, c, d), vec2(c, d));
2021-02-21 20:06:13 +01:00
}
2021-02-21 20:07:04 +01: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);
// Fractional source index.
vec3 sourceFracIndexRC = ${h};
// 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-02-21 20:06:13 +01:00
}
2021-02-25 13:50:13 +01:00
`}};function _j(e){let{inputs:t,backend:n,attrs:r}=e,{images:a}=t,{alignCorners:s,halfPixelCenters:i,size:o}=r,[l,u]=o,c=Y().getBool("WEBGL_PACK_IMAGE_OPERATIONS")?new wj(a.shape,l,u,s,i):new xj(a.shape,l,u,s,i);return n.runWebGLProgram(c,[a],"float32")}var bj={kernelName:Is,backendName:"webgl",kernelFunc:_j},vj=class{constructor(e,t,n){this.variableNames=["dy"],this.outputShape=[],this.outputShape=t;let[,r,a]=t,[,s,i]=e,o=[n&&s>1?r-1:r,n&&i>1?a-1:a],l=[n&&s>1?s-1:s,n&&i>1?i-1:i],u=o[0]/l[0],c=o[1]/l[1],h=1/u,d=1/c,p=Math.ceil(h)*2+2,f=Math.ceil(d)*2+2;this.userCode=`
2021-02-21 20:07:04 +01: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-02-25 13:50:13 +01:00
const float heightScale = float(${u});
const float widthScale = float(${c});
2021-02-21 20:07:04 +01:00
const float invHeightScale = float(${h});
const float invWidthScale = float(${d});
const int winHeight = int(${p});
const int winWidth = int(${f});
// Compute bounds for where in dy we will look
float startRLerp = floor(float(r) * invHeightScale);
int startDyR = int(startRLerp - float(winHeight / 2));
float startCLerp = floor(float(c) * invWidthScale);
int startDyC = int(startCLerp - float(winWidth / 2));
// Loop over dy
for (int dyROffset = 0; dyROffset < winHeight; dyROffset++) {
int dyR = dyROffset + startDyR;
// Guard against the window exceeding the bounds of dy
if (dyR < 0 || dyR >= ${s}) {
continue;
}
for (int dyCOffset = 0; dyCOffset < winWidth; dyCOffset++) {
int dyC = dyCOffset + startDyC;
// Guard against the window exceeding the bounds of dy
if (dyC < 0 || dyC >= ${i}) {
continue;
}
float dxR = float(dyR) * heightScale;
int topDxRIndex = int(floor(dxR));
int bottomDxRIndex = int(min(ceil(dxR), ${r-1}.0));
float dxRLerp = dxR - float(topDxRIndex);
float inverseDxRLerp = 1.0 - dxRLerp;
float dxC = float(dyC) * widthScale;
int leftDxCIndex = int(floor(dxC));
int rightDxCIndex = int(min(ceil(dxC), ${a-1}.0));
float dxCLerp = dxC - float(leftDxCIndex);
float inverseDxCLerp = 1.0 - dxCLerp;
if (r == topDxRIndex && c == leftDxCIndex) {
// topLeft
accumulator +=
getDy(b, dyR, dyC, d) * inverseDxRLerp * inverseDxCLerp;
}
if (r == topDxRIndex && c == rightDxCIndex) {
// topRight
accumulator += getDy(b, dyR, dyC, d) * inverseDxRLerp * dxCLerp;
}
if (r == bottomDxRIndex && c == leftDxCIndex) {
// bottomLeft
accumulator += getDy(b, dyR, dyC, d) * dxRLerp * inverseDxCLerp;
}
if (r == bottomDxRIndex && c == rightDxCIndex) {
// bottomRight
accumulator += getDy(b, dyR, dyC, d) * dxRLerp * dxCLerp;
}
}
}
// End loop over dy
setOutput(accumulator);
2021-02-21 20:06:13 +01:00
}
2021-02-25 13:50:13 +01:00
`}};function kj(e){let{inputs:t,backend:n,attrs:r}=e,{images:a,dy:s}=t,{alignCorners:i}=r,o=new vj(s.shape,a.shape,i);return n.runWebGLProgram(o,[s],s.dtype)}var Ij={kernelName:Fh,backendName:"webgl",kernelFunc:kj},Nj=class{constructor(e,t,n,r,a){this.variableNames=["A"],this.outputShape=[];let[s,i,o,l]=e;this.outputShape=[s,t,n,l];let u=[r&&t>1?i-1:i,r&&n>1?o-1:o],c=[r&&t>1?t-1:t,r&&n>1?n-1:n],h=r?"0.5":"0.0",d;a?d="max((vec2(yRC) + vec2(0.5)) * effectiveInputOverOutputRatioRC, vec2(0.0))":d="vec2(yRC) * effectiveInputOverOutputRatioRC",this.userCode=`
2021-02-21 20:07:04 +01:00
const vec2 effectiveInputOverOutputRatioRC = vec2(
2021-02-25 13:50:13 +01:00
${u[0]/c[0]},
${u[1]/c[1]});
2021-02-21 20:07:04 +01:00
const vec2 inputShapeRC = vec2(${i}.0, ${o}.0);
void main() {
ivec4 coords = getOutputCoords();
int b = coords[0];
int d = coords[3];
ivec2 yRC = coords.yz;
// Fractional source index.
vec2 sourceFracIndexRC = ${d};
// Compute the coordinators of nearest neighbor point.
ivec2 sourceNearestRC = ivec2(
min(inputShapeRC - 1.0, floor(sourceFracIndexRC + ${h})));
float newValue = getA(b, sourceNearestRC.x, sourceNearestRC.y, d);
setOutput(newValue);
2021-02-21 20:06:13 +01:00
}
2021-02-25 13:50:13 +01:00
`}};function Sj(e){let{inputs:t,backend:n,attrs:r}=e,{images:a}=t,{alignCorners:s,halfPixelCenters:i,size:o}=r,[l,u]=o,c=new Nj(a.shape,l,u,s,i);return n.runWebGLProgram(c,[a],a.dtype)}var Tj={kernelName:au,backendName:"webgl",kernelFunc:Sj},Ej=class{constructor(e,t,n){this.variableNames=["dy"],this.outputShape=[],this.outputShape=t;let[,r,a]=t,[,s,i]=e,o=[n&&s>1?r-1:r,n&&i>1?a-1:a],l=[n&&s>1?s-1:s,n&&i>1?i-1:i],u=o[0]/l[0],c=o[1]/l[1],h=1/u,d=1/c,p=Math.ceil(h)*2+2,f=Math.ceil(d)*2+2;this.userCode=`
2021-02-21 20:07:04 +01: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-02-25 13:50:13 +01:00
const float heightScale = float(${u});
const float widthScale = float(${c});
2021-02-21 20:07:04 +01:00
const float invHeightScale = float(${h});
const float invWidthScale = float(${d});
const int winHeight = int(${p});
const int winWidth = int(${f});
// Compute bounds for where in dy we will look
float startRLerp = floor(float(r) * invHeightScale);
int startDyR = int(floor(startRLerp - float(winHeight / 2)));
float startCLerp = floor(float(c) * invWidthScale);
int startDyC = int(floor(startCLerp - float(winWidth / 2)));
// Loop over dy
for (int dyROffset = 0; dyROffset < winHeight; dyROffset++) {
int dyR = dyROffset + startDyR;
// Guard against the window exceeding the bounds of dy
if (dyR < 0 || dyR >= ${s}) {
continue;
}
for (int dyCOffset = 0; dyCOffset < winWidth; dyCOffset++) {
int dyC = dyCOffset + startDyC;
// Guard against the window exceeding the bounds of dy
if (dyC < 0 || dyC >= ${i}) {
continue;
}
float sourceFracRow =
float(${o[0]}) *
(float(dyR) / float(${l[0]}));
float sourceFracCol =
float(${o[1]}) *
(float(dyC) / float(${l[1]}));
int sourceNearestRow = int(min(
float(int(${r}) - 1),
${n} ? float(round(sourceFracRow)) :
float(floor(sourceFracRow))));
int sourceNearestCol = int(min(
float(int(${a}) - 1),
${n} ? float(round(sourceFracCol)) :
float(floor(sourceFracCol))));
if (r == sourceNearestRow && c == sourceNearestCol) {
accumulator += getDy(b, dyR, dyC, d);
}
}
2020-12-16 20:49:14 +01:00
}
2021-02-21 20:07:04 +01:00
// End loop over dy
setOutput(accumulator);
2021-02-21 20:06:13 +01:00
}
2021-02-25 13:50:13 +01:00
`}};function Cj(e){let{inputs:t,backend:n,attrs:r}=e,{images:a,dy:s}=t,{alignCorners:i}=r,o=new Ej(s.shape,a.shape,i);return n.runWebGLProgram(o,[s],s.dtype)}var Rj={kernelName:Rh,backendName:"webgl",kernelFunc:Cj},Fj=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-02-21 20:07:04 +01:00
void main() {
int coord = getOutputCoords();
setOutput(getX(${e[0]} - coord - 1));
}
2021-02-25 13:50:13 +01:00
`;return}let r=i=>t.indexOf(i)!==-1&&e[i]!==1?`${e[i]} - coords[${i}] - 1`:`coords[${i}]`,a=e.map((i,o)=>r(o)).join(","),s=lt(n);this.userCode=`
2021-02-21 20:07:04 +01:00
void main() {
${s} coords = getOutputCoords();
setOutput(getX(${a}));
2021-02-21 20:06:13 +01:00
}
2021-02-25 13:50:13 +01:00
`}},$j=class{constructor(e,t){this.variableNames=["x"],this.packedInputs=!0,this.packedOutput=!0;let n=e.length;if(n>4)throw new Error(`WebGL backend: Reverse of rank-${n} tensor is not yet supported`);this.outputShape=e;let r=cn("rc",n),a=`${r[n-1]} + 1 < ${this.outputShape[n-1]}`,s=`${r[n-2]} + 1 < ${this.outputShape[n-2]}`,i=lt(n);n===1?this.userCode=`
2021-02-21 20:07:04 +01:00
void main(){
int rc = getOutputCoords();
vec4 result = vec4(0.);
result.r = getChannel(getX(${e[0]} - rc - 1),
${e[0]} - rc - 1);
if(${a}){
result.g = getChannel(getX(${e[0]} - (rc + 1) - 1),
${e[0]} - (rc + 1) - 1);
}
setOutput(result);
}
`:this.userCode=`
void main() {
${i} rc = getOutputCoords();
vec4 result = vec4(0.);
result.r = ${o(r.slice())};
if(${a}){
result.g = ${l(r.slice())};
}
if(${s}) {
2021-02-25 13:50:13 +01:00
result.b = ${u(r.slice())};
2021-02-21 20:07:04 +01:00
if(${a}) {
2021-02-25 13:50:13 +01:00
result.a = ${c(r.slice())};
2021-02-21 20:07:04 +01:00
}
}
setOutput(result);
}
2021-02-25 13:50:13 +01:00
`;function o(p){return h(p)}function l(p){return p[n-1]="("+p[n-1]+" + 1)",h(p)}function u(p){return p[n-2]="("+p[n-2]+" + 1)",h(p)}function c(p){return p[n-1]="("+p[n-1]+" + 1)",p[n-2]="("+p[n-2]+" + 1)",h(p)}function h(p){let f=e.map((y,g)=>d(g,p)),m=f.join(","),A=f.slice(-2).join(",");return`getChannel(getX(${m}), vec2(${A}))`}function d(p,f){return t.indexOf(p)!==-1&&e[p]!==1?`${e[p]} - ${f[p]} - 1`:`${f[p]}`}}};function Mj(e){let{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{dims:s}=r,i=a.shape.length,o=v.parseAxisParam(s,a.shape);if(i===0)return Fn({inputs:{x:a},backend:n});let l=Y().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new $j(a.shape,o):new Fj(a.shape,o);return n.runWebGLProgram(l,[a],a.dtype)}var Dj={kernelName:Ss,backendName:"webgl",kernelFunc:Mj},Oj=class{constructor(e,t,n,r){this.variableNames=["Image"],this.outputShape=[];let a=e[1],s=e[2],i=Math.sin(t).toFixed(3),o=Math.cos(t).toFixed(3);this.outputShape=e;let[l,u]=C.getImageCenter(r,a,s),c=l.toFixed(3),h=u.toFixed(3),d="";typeof n=="number"?d=`float outputValue = ${n.toFixed(2)};`:d=`
2021-02-21 20:07:04 +01:00
vec3 fill = vec3(${n.join(",")});
float outputValue = fill[coords[3]];`,this.userCode=`
void main() {
ivec4 coords = getOutputCoords();
int x = coords[2];
int y = coords[1];
2021-02-25 13:50:13 +01:00
float coordXFloat = (float(x) - ${c}) * ${o} - (float(y) - ${h}) * ${i};
float coordYFloat = (float(x) - ${c}) * ${i} + (float(y) - ${h}) * ${o};
int coordX = int(round(coordXFloat + ${c}));
2021-02-21 20:07:04 +01:00
int coordY = int(round(coordYFloat + ${h}));
${d}
if(coordX >= 0 && coordX < ${s} && coordY >= 0 && coordY < ${a}) {
outputValue = getImage(coords[0], coordY, coordX, coords[3]);
}
setOutput(outputValue);
}
2021-02-25 13:50:13 +01:00
`}},zj={kernelName:Do,backendName:"webgl",kernelFunc:({inputs:e,attrs:t,backend:n})=>{let{image:r}=e,{radians:a,fillValue:s,center:i}=t,o=n,l=new Oj(r.shape,a,s,i);return o.runWebGLProgram(l,[r],r.dtype)}},Lj=`
2021-02-21 20:07:04 +01: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;
2021-02-21 20:06:13 +01:00
} else {
2021-02-21 20:07:04 +01:00
return base + 1.0;
2021-02-21 20:06:13 +01:00
}
}
2021-02-25 13:50:13 +01:00
`,Pj=Xe({opSnippet:Lj}),Wj={kernelName:Ts,backendName:"webgl",kernelFunc:Pj},Bj="return inversesqrt(x);",Vj=Xe({opSnippet:Bj,cpuKernelImpl:Ez}),Uj={kernelName:Es,backendName:"webgl",kernelFunc:Vj},U_=class{constructor(e,t,n,r,a,s,i=!0){this.variableNames=["updates","indices","defaultValue"],this.outputShape=s;let o=lt(a.length),l=lt(s.length),u="";n===1?u="i":n===2&&(u="i, j");let c=`getIndices(${u})`,h="";r===1?h="i":r===2&&(h="i, coords[1]");let d=`getUpdates(${h})`,p=t>1?"strides[j]":"strides";this.userCode=`
2021-02-21 20:07:04 +01:00
${o} strides = ${o}(${a});
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-02-25 13:50:13 +01:00
int index = round(${c});
2021-02-21 20:07:04 +01:00
flattenedIndex += index * ${p};
}
if (flattenedIndex == coords[0]) {
sum += ${d};
found = true;
}
}
setOutput(mix(getDefaultValue(), sum, float(found)));
2021-01-03 16:41:56 +01:00
}
2021-02-25 13:50:13 +01:00
`}};function jj(e){let{inputs:t,backend:n,attrs:r}=e,{indices:a,updates:s}=t,{shape:i}=r,{sliceRank:o,numUpdates:l,sliceSize:u,strides:c,outputSize:h}=C.calculateShapes(s,a,i),d=[h/u,u];if(h===0)return n.makeTensorInfo(i,a.dtype);let p=ye({inputs:{x:a},backend:n,attrs:{shape:[l,o]}}),f=ye({inputs:{x:s},backend:n,attrs:{shape:[l,u]}}),m=n.makeTensorInfo([],"float32",new Float32Array([0])),A=new U_(l,o,p.shape.length,f.shape.length,c,d),y=n.runWebGLProgram(A,[f,p,m],f.dtype),g=ye({inputs:{x:y},backend:n,attrs:{shape:i}});return n.disposeIntermediateTensorInfo(p),n.disposeIntermediateTensorInfo(f),n.disposeIntermediateTensorInfo(y),n.disposeIntermediateTensorInfo(m),g}var Hj={kernelName:bo,backendName:"webgl",kernelFunc:jj},Gj=class{constructor(e,t,n){this.variableNames=["c","a","b"],this.outputShape=t;let r,a;if(n>4)throw Error(`Where for rank ${n} is not yet supported`);if(n===1)a="resRC",r="resRC";else{let i=["resRC.x","resRC.y","resRC.z","resRC.w"],o=[],l=[];for(let u=0;u<t.length;u++)l.push(`${i[u]}`),u<e&&o.push(`${i[u]}`);r=o.join(),a=l.join()}let s=lt(n);this.userCode=`
2021-02-21 20:07:04 +01:00
void main() {
${s} resRC = getOutputCoords();
float cVal = getC(${r});
if (cVal >= 1.0) {
setOutput(getA(${a}));
} else {
setOutput(getB(${a}));
2021-01-03 16:41:56 +01:00
}
}
2021-02-25 13:50:13 +01:00
`}};function qj(e){let{inputs:t,backend:n}=e,{condition:r,t:a,e:s}=t,i=new Gj(r.shape.length,a.shape,a.shape.length);return n.runWebGLProgram(i,[r,a,s],Jn(a.dtype,s.dtype))}var Xj={kernelName:vo,backendName:"webgl",kernelFunc:qj},Kj=`
2021-02-21 20:07:04 +01:00
// Stable and Attracting Fixed Point (0, 1) for Normalized Weights.
// see: https://arxiv.org/abs/1706.02515
float scaleAlpha = ${C.SELU_SCALEALPHA};
float scale = ${C.SELU_SCALE};
return (x >= 0.0) ? scale * x : scaleAlpha * (exp(x) - 1.0);
2021-02-25 13:50:13 +01:00
`,Zj=Xe({opSnippet:Kj}),Yj={kernelName:ko,backendName:"webgl",kernelFunc:Zj},Jj="return 1.0 / (1.0 + exp(-1.0 * x));",Qj=Xe({opSnippet:Jj}),eH={kernelName:Rs,backendName:"webgl",kernelFunc:Qj},tH=`
2021-02-21 20:07:04 +01:00
if (isnan(x)) { return 0.0; }
return sign(x);
2021-02-25 13:50:13 +01:00
`,nH=Xe({opSnippet:tH}),rH={kernelName:So,backendName:"webgl",kernelFunc:nH},aH=n_+`
2021-02-21 20:07:04 +01:00
return sin(x);
2021-02-25 13:50:13 +01:00
`,sH=Xe({opSnippet:aH}),iH={kernelName:Cs,backendName:"webgl",kernelFunc:sH},oH=`
2021-02-21 20:07:04 +01:00
float e2x = exp(x);
return (e2x - 1.0 / e2x) / 2.0;
2021-02-25 13:50:13 +01:00
`,lH=Xe({opSnippet:oH}),uH={kernelName:No,backendName:"webgl",kernelFunc:lH},cH=`
2021-02-21 20:07:04 +01:00
float epsilon = 1.1920928955078125e-7;
float threshold = log(epsilon) + 2.0;
bool too_large = x > -threshold;
bool too_small = x < threshold;
float result;
float exp_x = exp(x);
if (too_large){
result = x;
2021-01-03 16:41:56 +01:00
}
2021-02-21 20:07:04 +01:00
else if (too_small){
result = exp_x;
2021-01-03 16:41:56 +01:00
}
2021-02-21 20:07:04 +01:00
else{
result = log(exp_x + 1.0);
2021-01-03 16:41:56 +01:00
}
2021-02-21 20:07:04 +01:00
return result;
2021-02-25 13:50:13 +01:00
`,hH=Xe({opSnippet:cH}),dH={kernelName:To,backendName:"webgl",kernelFunc:hH},pH=e=>{let{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{blockShape:s,paddings:i}=r;v.assert(a.shape.length<=4,()=>"spaceToBatchND for rank > 4 with a WebGL backend not implemented yet");let o=s.reduce((y,g)=>y*g),l=[[0,0]];l.push(...i);for(let y=1+s.length;y<a.shape.length;++y)l.push([0,0]);let u=[],c=B_({inputs:{x:a},backend:n,attrs:{paddings:l,constantValue:0}}),h=C.getReshaped(c.shape,s,o,!1),d=C.getPermuted(h.length,s.length,!1),p=C.getReshapedPermuted(c.shape,s,o,!1),f=ye({inputs:{x:c},backend:n,attrs:{shape:h}}),m=wn({inputs:{x:f},backend:n,attrs:{perm:d}}),A=ye({inputs:{x:m},backend:n,attrs:{shape:p}});return u.push(c),u.push(f),u.push(m),u.forEach(y=>n.disposeIntermediateTensorInfo(y)),A},fH={kernelName:su,backendName:"webgl",kernelFunc:pH};function mH(e){let{inputs:t,backend:n,attrs:r}=e,{sparseIndices:a,sparseValues:s,defaultValue:i}=t,{outputShape:o}=r,{sliceRank:l,numUpdates:u,strides:c,outputSize:h}=C.calculateShapes(s,a,o),d=!1,p=new U_(u,l,a.shape.length,s.shape.length,c,[h,1],d),f=n.runWebGLProgram(p,[s,a,i],s.dtype),m=ye({inputs:{x:f},backend:n,attrs:{shape:o}});return n.disposeIntermediateTensorInfo(f),m}var AH={kernelName:$h,backendName:"webgl",kernelFunc:mH};function yH(e){let{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{numOrSizeSplits:s,axis:i}=r,o=v.parseAxisParam(i,a.shape)[0],l=C.prepareSplitSize(a,s,o),u=a.shape.length,c=new Array(u).fill(0),h=a.shape.slice();return l.map(d=>{let p=[...h];p[o]=d;let f=ec({inputs:{x:a},backend:n,attrs:{begin:c,size:p}});return c[o]+=d,f})}var gH={kernelName:Eo,backendName:"webgl",kernelFunc:yH},xH="return sqrt(x);",wH=Xe({opSnippet:xH}),_H={kernelName:Fs,backendName:"webgl",kernelFunc:wH},bH="return x * x;",vH=Xe({opSnippet:bH}),kH={kernelName:iu,backendName:"webgl",kernelFunc:vH},j_="return (a - b) * (a - b);",IH=Qt({opSnippet:j_,packedOpSnippet:j_}),NH={kernelName:Ds,backendName:"webgl",kernelFunc:IH};function SH({inputs:e,attrs:t,backend:n}){let{x:r}=e,a=mr+`
2021-02-21 20:07:04 +01:00
return x > 0.0 ? 1.0 : float(${t.alpha});
2021-02-25 13:50:13 +01:00
`,s=new $a(r.shape,a);return n.runWebGLProgram(s,[r],r.dtype)}var TH={kernelName:xa,backendName:"webgl",kernelFunc:SH},EH=class{constructor(e,t,n){this.variableNames=["x"],this.outputShape=n;let r=n.length,a=lt(n.length),s=lt(n.length),i="";if(r===1)i="coords * strides + begin";else{let o=0;i=n.map((l,u)=>(o++,n.length===1?`coords * strides[${u}] + begin[${u}]`:`coords[${o-1}] * strides[${u}] + begin[${u}]`)).join(",")}this.userCode=`
2021-02-21 20:07:04 +01:00
${a} begin = ${a}(${e});
${a} strides = ${a}(${t});
void main() {
${s} coords = getOutputCoords();
setOutput(getX(${i}));
2021-01-03 16:41:56 +01:00
}
2021-02-25 13:50:13 +01:00
`}};function CH(e){let{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{begin:s,end:i,strides:o,beginMask:l,endMask:u,ellipsisMask:c,newAxisMask:h,shrinkAxisMask:d}=r,{nonStrided:p,$begin:f,$strides:m,size:A,newShape:y,outShape:g}=sn.sliceInfo(a.shape,s,i,o,l,u,c,h,d),w=ye({inputs:{x:a},backend:n,attrs:{shape:y}}),_;if(p){let x=ec({inputs:{x:w},backend:n,attrs:{begin:f,size:A}});_=ye({inputs:{x},backend:n,attrs:{shape:g}}),n.disposeIntermediateTensorInfo(x)}else if(g.some(x=>x===0))_=n.makeTensorInfo(g,a.dtype,[]);else if(n.shouldExecuteOnCPU([w])){let x=n.texData.get(w.dataId).values,N=We(w.shape,w.dtype,x),T=Rz(g,N,m,f);_=n.makeTensorInfo(g,w.dtype,T.values)}else{let x=new EH(f,m,g);_=n.runWebGLProgram(x,[w],w.dtype)}let b=ye({inputs:{x:_},backend:n,attrs:{shape:g}});return n.disposeIntermediateTensorInfo(w),n.disposeIntermediateTensorInfo(_),b}var RH={kernelName:Co,backendName:"webgl",kernelFunc:CH},FH="return tan(x);",$H=Xe({opSnippet:FH}),MH={kernelName:Ro,backendName:"webgl",kernelFunc:$H},DH=`
2021-02-21 20:07:04 +01:00
float e2x = exp(-2.0 * abs(x));
return sign(x) * (1.0 - e2x) / (1.0 + e2x);
2021-02-25 13:50:13 +01:00
`,OH=Xe({opSnippet:DH}),zH={kernelName:zs,backendName:"webgl",kernelFunc:OH},PH=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 r=lt(this.rank),a=LH(e);this.userCode=`
2021-02-21 20:07:04 +01:00
void main() {
${r} resRC = getOutputCoords();
setOutput(getA(${a}));
2021-01-03 16:41:56 +01:00
}
2021-02-25 13:50:13 +01:00
`}};function LH(e){let t=e.length;if(t>5)throw Error(`Tile for rank ${t} is not yet supported`);if(t===1)return`imod(resRC, ${e[0]})`;let n=["resRC.x","resRC.y","resRC.z","resRC.w","resRC.u"],r=[];for(let a=0;a<e.length;a++)r.push(`imod(${n[a]}, ${e[a]})`);return r.join()}function H_(e){let{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{reps:s}=r;if(a.dtype==="string"){let o=n.readSync(a.dataId).map(c=>v.decodeString(c)),l=We(a.shape,a.dtype,o),u=$z(l,s);return n.makeTensorInfo(u.shape,u.dtype,u.values)}let i=new PH(a.shape,s);return n.runWebGLProgram(i,[a],a.dtype)}var WH={kernelName:ga,backendName:"webgl",kernelFunc:H_};function BH(e){let{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{k:s,sorted:i}=r,o=n.readSync(a.dataId),[l,u]=Mz(o,a.shape,a.dtype,s,i);return[n.makeTensorInfo(l.shape,l.dtype,l.values),n.makeTensorInfo(u.shape,u.dtype,u.values)]}var VH={kernelName:Fo,backendName:"webgl",kernelFunc:BH};function UH(e){let{inputs:t,attrs:n,backend:r}=e,{axis:a}=n,{x:s}=t;hl(s,"unique"),console.warn("WARNING: ","UI might be locked temporarily as data is being downloaded");let i=r.readSync(s.dataId),{outputValues:o,outputShape:l,indices:u}=Dz(i,a,s.shape,s.dtype);return[r.makeTensorInfo(l,s.dtype,o),r.makeTensorInfo([u.length],"int32",u)]}var jH={kernelName:Mh,backendName:"webgl",kernelFunc:UH};function HH(e){let{inputs:t,backend:n,attrs:r}=e,{value:a}=t,{axis:s}=r;s<0&&(s+=a.shape.length);let i=a,o=i.shape.length,l=a.shape[s],u=new Array(o-1),c=0;for(let m=0;m<o;m++)m!==s&&(u[c++]=i.shape[m]);let h=[],d=new Array(o).fill(0),p=i.shape.slice();p[s]=1;let f=new Array(l);for(let m=0;m<f.length;m++){d[s]=m;let A=ec({inputs:{x:i},backend:n,attrs:{begin:d,size:p}}),y=ye({inputs:{x:A},backend:n,attrs:{shape:u}});f[m]=y,h.push(A)}return h.forEach(m=>n.disposeIntermediateTensorInfo(m)),f}var GH={kernelName:$o,backendName:"webgl",kernelFunc:HH},qH=class{constructor(e,t){this.variableNames=["x","segmentIds"];let n=e.windowSize,r=e.batchSize,a=e.inSize,s=e.numSegments,i=s*Math.ceil(a/n);this.outputShape=[r,i];let o="0.0",l="sumValue",u=Math.floor(n/4)*4,c=n%4,h=`
2021-02-21 20:07:04 +01:00
sumValue += dot(values, segFilter);
`,d="";a%n>0&&(d=`
if (inIdx < 0 || inIdx >= ${a}) {
return initializationValue;
2021-01-03 16:41:56 +01:00
}
2021-02-21 20:07:04 +01:00
`);let p="";a%n>0&&(p=`
if (inIdx < 0 || inIdx >= ${a}) {
return -1.0;
}
`),this.userCode=`
const float initializationValue = ${o};
float getValue(int batch, int inIdx) {
${d}
return getX(batch, inIdx);
2021-01-03 16:41:56 +01:00
}
2021-02-21 20:07:04 +01:00
float getSegmentIdAtIndex(int inIdx) {
${p}
return getSegmentIds(inIdx);
2021-01-03 16:41:56 +01:00
}
2021-02-21 20:07:04 +01:00
void main() {
ivec2 coords = getOutputCoords();
int batch = coords[0];
int outIdx = coords[1];
int inOffset = int(floor(float(outIdx) / float(
${s})) * float(${n}));
int currentSeg = int(mod(float(outIdx), float(${s})));
float sumValue = 0.0;
2021-02-25 13:50:13 +01:00
for (int i = 0; i < ${u}; i += 4) {
2021-02-21 20:07:04 +01:00
int inIdx = inOffset + i;
vec4 values = vec4(
getValue(batch, inIdx),
getValue(batch, inIdx + 1),
getValue(batch, inIdx + 2),
getValue(batch, inIdx + 3)
);
vec4 segFilter = vec4(
int(getSegmentIdAtIndex(inIdx)) == currentSeg ? 1 : 0,
int(getSegmentIdAtIndex(inIdx + 1)) == currentSeg ? 1 : 0,
int(getSegmentIdAtIndex(inIdx + 2)) == currentSeg ? 1 : 0,
int(getSegmentIdAtIndex(inIdx + 3)) == currentSeg ? 1 : 0
);
${h}
2021-01-03 16:41:56 +01:00
}
2021-02-21 20:07:04 +01:00
2021-02-25 13:50:13 +01:00
int inIdx = inOffset + ${u};
if (${c===1}) {
2021-02-21 20:07:04 +01: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
);
${h}
2021-02-25 13:50:13 +01:00
} else if (${c===2}) {
2021-02-21 20:07:04 +01: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
);
${h}
2021-02-25 13:50:13 +01:00
} else if (${c===3}) {
2021-02-21 20:07:04 +01: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
);
${h}
2021-01-03 16:41:56 +01:00
}
2021-02-21 20:07:04 +01:00
setOutput(${l});
2021-01-18 14:22:51 +01:00
}
2021-02-25 13:50:13 +01:00
`}};function XH(e){let{inputs:t,backend:n,attrs:r}=e,{x:a,segmentIds:s}=t,{numSegments:i}=r,o=a.shape.length,l=[],u=0,c=C.getAxesPermutation([u],o),h=a;c!=null&&(h=wn({inputs:{x:a},backend:n,attrs:{perm:c}}),l.push(h),u=C.getInnerMostAxes(1,o)[0]);let d=C.segment_util.computeOutShape(h.shape,u,i),p=v.sizeFromShape([h.shape[u]]),f=ye({inputs:{x:h},backend:n,attrs:{shape:[-1,p]}});l.push(f);let m=zh(a.dtype),A=(_,b,x,N,T)=>{let E=_.shape[0],$=_.shape[1],D=C.segment_util.segOpComputeOptimalWindowSize($,T),L={windowSize:D,inSize:$,batchSize:E,numSegments:T},P=new qH(L,b),U=n.compileAndRun(P,[_,x],N);if(l.push(U),U.shape[1]===T)return U;let j=V_({backend:n,attrs:{start:0,stop:T,step:1,dtype:"float32"}}),X=H_({inputs:{x:j},backend:n,attrs:{reps:[$/D]}});return l.push(j),l.push(X),A(U,b,X,N,T)},y=A(f,"unsortedSegmentSum",s,m,i),g=ye({inputs:{x:y},backend:n,attrs:{shape:d}}),w=g;if(c!=null){l.push(g);let _=C.getUndoAxesPermutation(c);w=wn({inputs:{x:w},backend:n,attrs:{perm:_}})}return l.forEach(_=>n.disposeIntermediateTensorInfo(_)),w}var KH={kernelName:ou,backendName:"webgl",kernelFunc:XH},ZH=[VV,HV,CL,FL,DL,LL,WL,UL,HL,qL,YL,QL,nP,sP,dP,lP,mP,xP,yP,vP,IP,SP,RP,LP,WP,GP,XP,JP,tW,hL,sW,mW,yW,uW,_W,vW,xW,NW,EW,FW,MW,OW,PW,HW,qW,BW,ZW,QW,rB,oB,hB,fB,mB,AB,gB,wB,bB,kB,NB,CB,MB,OB,LB,BB,HB,KB,QB,cL,tV,aW,aV,oV,cV,pL,fV,gV,wV,SV,kV,RV,MV,LV,qV,tU,QV,sU,oU,uU,YV,hU,pU,yU,_U,IU,$U,gL,DU,LU,BU,jU,VP,qU,KU,YU,ej,aj,mL,ij,oj,UP,EU,cj,gj,fj,wL,bj,Ij,Tj,Rj,Dj,zj,Wj,Uj,Hj,Xj,Yj,eH,rH,iH,uH,OP,RU,dH,fH,AH,gH,_H,kH,NH,TH,RH,CU,SL,MH,zH,WH,VH,TL,jH,GH,KH,XU];for(let e of ZH)Oo(e);var $n;(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"})($n||($n={}));var nc;(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"})(nc||(nc={}));var G_;function YH(e){G_=e.wasm.cwrap(Ps,null,["number","array","number","number","array","number","number","number","number","number","number","number","number"])}function JH(e){let{inputs:t,backend:n,attrs:r}=e,{a,b:s,bias:i,preluActivationWeights:o}=t;if(a.dtype!=="float32"||s.dtype!=="float32")throw new Error("_FusedMatMul for non non-float32 tensors not yet supported.");let{transposeA:l,transposeB:u,activation:c,leakyreluAlpha:h}=r,d=n.dataIdMap.get(a.dataId).id,p=n.dataIdMap.get(s.dataId).id,f=0;if(i!=null){let T=n.dataIdMap.get(i.dataId);if(T.shape.length!==1)throw new Error(`_FusedMatMul only supports rank-1 bias but got rank ${T.shape.length}.`);f=T.id}let m=o==null?0:n.dataIdMap.get(o.dataId).id,A=nc[c];if(A==null)throw new Error(`${c} activation not yet supported for FusedConv2D in the wasm backend.`);let y=l?a.shape[2]:a.shape[1],g=u?s.shape[1]:s.shape[2],w=a.shape[0],_=n.makeOutput([w,y,g],a.dtype),b=n.dataIdMap.get(_.dataId).id,x=new Uint8Array(new Int32Array(a.shape).buffer),N=new Uint8Array(new Int32Array(s.shape).buffer);return G_(d,x,a.shape.length,p,N,s.shape.length,l,u,A,f,m,h||0,b),_}var QH={kernelName:Ps,backendName:"wasm",setupFunc:YH,kernelFunc:JH};function _n(e){let t;function n(a){t=a.wasm.cwrap(e,null,["number","number"])}function r(a){let{backend:s,inputs:{x:i}}=a,o=s.dataIdMap.get(i.dataId).id,l=s.makeOutput(i.shape,i.dtype),u=s.dataIdMap.get(l.dataId).id;return v.sizeFromShape(l.shape)===0||t(o,u),l}return{kernelName:e,backendName:"wasm",setupFunc:n,kernelFunc:r}}var eG=_n(Oi);function hn(e,t,n){let r;function a(i){r=i.wasm.cwrap(e,null,["number","array","number","number","array","number","number","number"])}function s(i){let{backend:o,inputs:l}=i,{a:u,b:c}=l,h=o.dataIdMap.get(u.dataId).id,d=o.dataIdMap.get(c.dataId).id,p=n!=null?n:u.dtype,f=C.assertAndGetBroadcastShape(u.shape,c.shape),m=o.makeOutput(f,p);if(v.sizeFromShape(f)===0)return m;let A=new Uint8Array(new Int32Array(u.shape).buffer),y=new Uint8Array(new Int32Array(c.shape).buffer),g=o.dataIdMap.get(m.dataId).id,w=()=>r(h,A,u.shape.length,d,y,c.shape.length,$n[u.dtype],g);if(t&&u.dtype==="float32")return w(),m;let _=C.getBroadcastDims(u.shape,f),b=C.getBroadcastDims(c.shape,f),x=_
2021-02-21 20:07:04 +01:00
1. The ${r} is defined in Python, in which case it needs to be ported to TensorFlow.js or your JavaScript code.
2021-02-25 13:50:13 +01:00
2. The custom ${r} 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 B(`${r}: 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 ir?[o,l]=ir.className:i in t&&([o,l]=t[i]),o==null)throw new B(`Unknown ${r}: ${i}. This may be due to one of the following reasons:
2021-02-21 20:07:04 +01:00
1. The ${r} is defined in Python, in which case it needs to be ported to TensorFlow.js or your JavaScript code.
2021-02-25 13:50:13 +01:00
2. The custom ${r} is defined in JavaScript, but is not registered properly with tf.serialization.registerClass().`);if(l!=null){let u={};for(let p of Object.keys(ir))u[p]=ir[p];for(let p of Object.keys(n))u[p]=n[p];let c=s.config;c.customObjects=u;let h=Object.assign({},ir);for(let p of Object.keys(n))ir[p]=n[p];BA(s.config);let d=l(o,s.config,n,a);return ir=Object.assign({},h),d}else{let u=Object.assign({},ir);for(let h of Object.keys(n))ir[h]=n[h];let c=new o(s.config);return ir=Object.assign({},u),c}}}function XY(e,t){return e<t?-1:e>t?1:0}function up(e,t){return-1*XY(e,t)}function Da(e){if(e==null)return e;let t=[];for(let n of e)t.indexOf(n)===-1&&t.push(n);return t}function KY(e){if(e==null)throw new B(`Invalid value in obj: ${JSON.stringify(e)}`);for(let t in e)if(e.hasOwnProperty(t))return!1;return!0}function di(e,t,n){if(n!=null&&e.indexOf(n)<0)throw new B(`${n} is not a valid ${t}. Valid values are ${e} or null/undefined.`)}function VA(e,t,n=0,r=Infinity){return Pr(n>=0),Pr(r>=n),Array.isArray(e)&&e.length>=n&&e.length<=r&&e.every(a=>typeof a===t)}function Gt(e,t){Array.isArray(e)?(v.assert(e.length>0,()=>`${t} is unexpectedly an empty array.`),e.forEach((n,r)=>Gt(n,`element ${r+1} of ${t}`))):v.assert(Number.isInteger(e)&&e>0,()=>`Expected ${t} to be a positive integer, but got ${Xb(e)}.`)}function Xb(e){return e===null?"null":Array.isArray(e)?"["+e.map(t=>Xb(t)).join(",")+"]":typeof e=="string"?`"${e}"`:`${e}`}function ZY(e,t){let n=v.now(),r;return(...a)=>{let s=v.now();return s-n<t||(n=s,r=e(...a)),r}}function Kb(e){return e==="relu"?"relu":e==="linear"?"linear":e==="elu"?"elu":null}function UA(e,t){return V(()=>Yt(Ee(W(e,e),t,!0)))}var oc=class extends re.Serializable{getConfig(){return{}}},jA=class extends oc{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 V(()=>{let t=UA(e,this.axis),n=gn(t,0,this.maxValue);return W(e,ve(n,oe(Lt(),t)))})}getConfig(){return{maxValue:this.maxValue,axis:this.axis}}};jA.className="MaxNorm";re.registerClass(jA);var HA=class extends oc{constructor(e){super();this.defaultAxis=0,this.axis=e.axis!=null?e.axis:this.defaultAxis}apply(e){return V(()=>ve(e,oe(Lt(),UA(e,this.axis))))}getConfig(){return{axis:this.axis}}};HA.className="UnitNorm";re.registerClass(HA);var GA=class extends oc{apply(e){return Cr(e)}};GA.className="NonNeg";re.registerClass(GA);var qA=class extends oc{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 V(()=>{let t=UA(e,this.axis),n=oe(W(this.rate,gn(t,this.minValue,this.maxValue)),W(1-this.rate,t));return W(e,ve(n,oe(Lt(),t)))})}getConfig(){return{minValue:this.minValue,maxValue:this.maxValue,rate:this.rate,axis:this.axis}}};qA.className="MinMaxNorm";re.registerClass(qA);var Zb={maxNorm:"MaxNorm",minMaxNorm:"MinMaxNorm",nonNeg:"NonNeg",unitNorm:"UnitNorm"};function Pt(e){return WA(e)}function Yb(e,t={}){return ic(e,re.SerializationMap.getMap().classNameMap,t,"constraint")}function Wt(e){if(e==null)return null;if(typeof e=="string"){let t={className:e in Zb?Zb[e]:e,config:{}};return Yb(t)}else return e instanceof oc?e:Yb(e)}function jY(e){return new jA(e)}function HY(e){return new HA(e)}function GY(){return new GA}function qY(e){return new qA(e)}var N0={};ze(N0,{constant:()=>QY,glorotNormal:()=>iJ,glorotUniform:()=>sJ,heNormal:()=>oJ,heUniform:()=>lJ,identity:()=>rJ,leCunNormal:()=>uJ,leCunUniform:()=>cJ,ones:()=>JY,orthogonal:()=>hJ,randomNormal:()=>tJ,randomUniform:()=>eJ,truncatedNormal:()=>nJ,varianceScaling:()=>aJ,zeros:()=>YY});var dJ=["channelsFirst","channelsLast"],pJ=["nearest","bilinear"],fJ=["valid","same","causal"],mJ=["max","avg"],AJ=["sum","mul","concat","ave"],bl=new Map;function Tt(e){di(dJ,"DataFormat",e)}function
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),ur(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,Vt(t),n.written=!0,this.tensors[e]=n}writeMany(e,t){if(e.length!==t.length)throw new Error(`TensorArray ${this.name}: could not write multiple tensors,because the index size: ${e.length} is not the same as tensors size: ${t.length}.`);e.forEach((n,r)=>this.write(n,t[r]))}gather(e,t){if(!!t&&t!==this.dtype)throw new Error(`TensorArray dtype is ${this.dtype} but gather requested dtype ${t}`);if(e)e=e.slice(0,this.size());else{e=[];for(let r=0;r<this.size();r++)e.push(r)}if(e.length===0)return dr([],[0].concat(this.elementShape));let n=this.readMany(e);return ur(this.elementShape,n[0].shape,"TensorArray shape mismatch: "),Cn(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 dr([],[0].concat(this.elementShape));let t=[];for(let r=0;r<this.size();r++)t.push(r);let n=this.readMany(t);return ur(this.elementShape,n[0].shape,`TensorArray shape mismatch: tensor array shape (${this.elementShape}) vs first tensor shape (${n[0].shape})`),ot(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,nr(t,0))}split(e,t){if(t.dtype!==this.dtype)throw new Error(`TensorArray dtype is ${this.dtype} but tensor has dtype ${t.dtype}`);let n=0,r=e.map(o=>(n+=o,n));if(n!==t.shape[0])throw new Error(`Expected sum of lengths to be equal to
2021-02-21 20:07:04 +01:00
tensor.shape[0], but sum of lengths is
2021-02-25 13:50:13 +01: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 a=n===0?0:t.size/n,s=[];V(()=>{t=H(t,[1,n,a]);for(let o=0;o<e.length;++o){let l=o===0?0:r[o-1],u=[0,l,0],c=[1,e[o],a];s[o]=H(Fe(t,u,c),this.elementShape)}return s});let i=[];for(let o=0;o<e.length;o++)i[o]=o;this.writeMany(i,s)}},Ic=class{constructor(e,t,n,r=-1){this.tensors=e,this.elementShape=t,this.elementDtype=n,e!=null&&e.forEach(a=>{if(n!==a.dtype)throw new Error(`Invalid data types; op elements ${n}, but list elements ${a.dtype}`);ur(t,a.shape,"TensorList shape mismatch: "),Vt(a)}),this.idTensor=ke(0),this.maxNumElements=r,Vt(this.idTensor)}get id(){return this.idTensor.id}copy(){return new Ic([...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.`);ur(e,this.elementShape,"TensorList shape mismatch: ");let r=kc(this.elementShape,this.tensors,e);return V(()=>{let a=this.tensors.map(s=>H(s,r));return Cn(a,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=kc(this.elementShape,this.tensors,e),r=this.tensors.pop();return ur(r.shape,e,"TensorList shape mismatch: "),H(r,n)}pushBack(e){if(e.dtype!==this.elementDtype)throw new Error(`Invalid data types; op elements ${e.dtype}, but list elements ${this.elementDtype}`);if(ur(e.shape,this.elementShape,"TensorList shape mismatch: "),this.maxNumElements===this.size())throw new Error("Trying to push element into a full list.");Vt(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.`);ur(this.tensors[e].shape,t,"TensorList shape mismatch: ");let r=kc(this.elementShape,this.tensors,t);return H(this.tensors[e],r)}setItem(e,t){if(t.dtype!==this.elementDtype)throw new Error(`Invalid data types; op elements ${t.dtype}, but list elements ${this.elementDtype}`);if(e<0||this.maxNumElements!==-1&&e>=this.maxNumElements)throw new Error(`Trying to set element ${e} in a list with max ${this.maxNumElements} elements.`);ur(this.elementShape,t.shape,"TensorList shape mismatch: "),Vt(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}`);ur(this.elementShape,n,"TensorList shape mismatch: "),e=e.slice(0,this.size());let r=kc(this.elementShape,this.tensors,n);return e.length===0?dr([],[0].concat(r)):V(()=>{let a=e.map(s=>H(this.tensors[s],r));return Cn(a,0)})}concat(e,t){if(!!e&&e!==this.elementDtype)throw new Error(`TensorList dtype is ${this.elementDtype} but concat requested dtype ${e}`);ur(this.elementShape,t,"TensorList shape mismatch: ");let n=kc(this.elementShape,this.tensors,t);return this.size()===0?dr([],[0].concat(n)):V(()=>{let r=this.tensors.map(a=>H(a,n));return ot(r,0)})}};function jte(e,t,n){let r=e.dtype;if(e.shape.length<1)throw new Error(`Tensor
2021-02-21 20:07:04 +01:00
tensor.shape[0], but sum of lengths is
2021-02-25 13:50:13 +01:00
${r}, and tensor's shape is: ${e.shape}`);let s=e.shape.slice(1),i=Dg(s,n),o=r===0?0:e.size/r,l=V(()=>{let c=[];e=H(e,[1,r,o]);for(let h=0;h<t.length;++h){let d=h===0?0:a[h-1],p=[0,d,0],f=[1,t[h],o];c[h]=H(Fe(e,p,f),i)}return e.dispose(),c}),u=new Ic([],n,e.dtype,t.length);for(let c=0;c<l.length;c++)u.setItem(c,l[c]);return u}var Xte=async(e,t,n)=>{switch(e.op){case"If":case"StatelessIf":{let r=k("thenBranch",e,t,n),a=k("elseBranch",e,t,n),s=k("cond",e,t,n),i=k("args",e,t,n);return(await s.data())[0]?n.functionMap[r].executeFunctionAsync(i,n.tensorArrayMap,n.tensorListMap):n.functionMap[a].executeFunctionAsync(i,n.tensorArrayMap,n.tensorListMap)}case"While":case"StatelessWhile":{let r=k("body",e,t,n),a=k("cond",e,t,n),s=k("args",e,t,n),i=await n.functionMap[a].executeFunctionAsync(s,n.tensorArrayMap,n.tensorListMap),o=s.map(c=>c.id),l=await i[0].data();i.forEach(c=>{!c.kept&&o.indexOf(c.id)===-1&&c.dispose()});let u=s;for(;l[0];){let c=u;u=await n.functionMap[r].executeFunctionAsync(u,n.tensorArrayMap,n.tensorListMap);let h=u.map(p=>p.id);c.forEach(p=>{!p.kept&&o.indexOf(p.id)===-1&&h.indexOf(p.id)===-1&&p.dispose()});let d=await n.functionMap[a].executeFunctionAsync(u,n.tensorArrayMap,n.tensorListMap);l=await d[0].data(),d.forEach(p=>{!p.kept&&o.indexOf(p.id)===-1&&h.indexOf(p.id)===-1&&p.dispose()})}return u}case"LoopCond":{let r=k("pred",e,t,n);return[oa(r)]}case"Switch":{let r=k("pred",e,t,n),a=k("data",e,t,n);return a.kept||(a=oa(a)),(await r.data())[0]?[void 0,a]:[a,void 0]}case"Merge":{let r=e.inputNames.find(a=>kn(a,t,n)!==void 0);if(r){let a=kn(r,t,n);return[oa(a)]}return}case"Enter":{let r=k("frameName",e,t,n),a=k("tensor",e,t,n);return n.enterFrame(r),[oa(a)]}case"Exit":{let r=k("tensor",e,t,n);return n.exitFrame(),[oa(r)]}case"NextIteration":{let r=k("tensor",e,t,n);return n.nextIteration(),[oa(r)]}case"TensorArrayV3":{let r=k("size",e,t,n),a=k("dtype",e,t,n),s=k("elementShape",e,t,n),i=k("dynamicSize",e,t,n),o=k("clearAfterRead",e,t,n),l=k("identicalElementShapes",e,t,n),u=k("name",e,t,n),c=new Ute(u,a,r,s,l,i,o);return n.addTensorArray(c),[c.idTensor,ke(1)]}case"TensorArrayWriteV3":{let r=k("tensorArrayId",e,t,n),a=k("index",e,t,n),s=k("tensor",e,t,n),i=n.getTensorArray(r.id);return i.write(a,s),[i.idTensor]}case"TensorArrayReadV3":{let r=k("tensorArrayId",e,t,n),a=k("index",e,t,n);return[n.getTensorArray(r.id).read(a)]}case"TensorArrayGatherV3":{let r=k("tensorArrayId",e,t,n),a=k("indices",e,t,n),s=k("dtype",e,t,n);return[n.getTensorArray(r.id).gather(a,s)]}case"TensorArrayScatterV3":{let r=k("tensorArrayId",e,t,n),a=k("indices",e,t,n),s=k("tensor",e,t,n),i=n.getTensorArray(r.id);return i.scatter(a,s),[i.idTensor]}case"TensorArrayConcatV3":{let r=k("tensorArrayId",e,t,n),a=n.getTensorArray(r.id),s=k("dtype",e,t,n);return[a.concat(s)]}case"TensorArraySplitV3":{let r=k("tensorArrayId",e,t,n),a=k("tensor",e,t,n),s=k("lengths",e,t,n),i=n.getTensorArray(r.id);return i.split(s,a),[i.idTensor]}case"TensorArraySizeV3":{let r=k("tensorArrayId",e,t,n),a=n.getTensorArray(r.id);return[ke(a.size(),"int32")]}case"TensorArrayCloseV3":{let r=k("tensorArrayId",e,t,n),a=n.getTensorArray(r.id);return a.clearAndClose(),[a.idTensor]}case"TensorListSetItem":{let r=k("tensorListId",e,t,n),a=k("index",e,t,n),s=k("tensor",e,t,n),i=n.getTensorList(r.id);return i.setItem(a,s),[i.idTensor]}case"TensorListGetItem":{let r=k("tensorListId",e,t,n),a=k("index",e,t,n),s=k("elementShape",e,t,n),i=k("elementDType",e,t,n);return[n.getTensorList(r.id).getItem(a,s,i)]}case"TensorListScatterV2":case"TensorListScatter":{let r=k("indices",e,t,n),a=k("tensor",e,t,n),s=k("elementShape",e,t,n),i=k("numElements",e,t,n),o=Gte(a,r,s,i);return n.addTensorList(o),[o.idTensor]}case"TensorListReserve":case"EmptyTensorList":{let r=k("elementShape",e,t,n),a=k("elementDType",e,t,n),s;e.op==="TensorListReserve"?s="numElements":s="maxNumElements";let i=k(s,e,t,n),o=Hte(r,a,i);return n.addTensorList(o),[o.idTensor]}case"TensorListGather":{let r=k("tensorListId",e,t,n),a=k("indices",e,t,n),s=k("elementShape",e,t,n),i=k("elementDType",e,t,n);return[n.getTe
${e}`);let r;return this.size===Infinity||this.size==null?r=this.size:t?r=Math.ceil(this.size/e):r=Math.floor(this.size/e),On(async()=>(await n.iterator()).columnMajorBatch(e,t,Kne),r)}concatenate(e){let t=this,n;return this.size===Infinity||e.size===Infinity?n=Infinity:this.size!=null&&e.size!=null?n=this.size+e.size:n=null,On(async()=>(await t.iterator()).concatenate(await e.iterator()),n)}filter(e){let t=this,n;return this.size===Infinity?n=Infinity:n=null,On(async()=>(await t.iterator()).filter(r=>V(()=>e(r))),n)}async forEachAsync(e){return(await this.iterator()).forEachAsync(e)}map(e){let t=this;return On(async()=>(await t.iterator()).map(n=>V(()=>e(n))),this.size)}mapAsync(e){let t=this;return On(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 On(async()=>(await t.iterator()).prefetch(e),this.size)}repeat(e){let t=this,n;return this.size!=null&&e>0?n=this.size*e:e===0?n=0:this.size!=null&&(e===void 0||e<0)?n=Infinity:n=null,On(async()=>{let r=Pg(async()=>({value:await t.iterator(),done:!1}));return zne(r.take(e))},n)}skip(e){let t=this,n;return this.size!=null&&e>=0&&this.size>=e?n=this.size-e:this.size!=null&&(this.size<e||e===void 0||e<0)?n=0:n=null,On(async()=>(await t.iterator()).skip(e),n)}shuffle(e,t,n=!0){if(e==null||e<0)throw this.size==null?new RangeError("`Dataset.shuffle()` requires bufferSize to be specified."):new RangeError(`\`Dataset.shuffle()\` requires bufferSize to be specified. If your data fits in main memory (for regular JS objects), and/or GPU memory (for \`tf.Tensor\`s), consider setting bufferSize to the dataset size (${this.size} elements)`);let r=this,a=Sne.alea(t||v.now().toString());return On(async()=>{let s=a.int32();return n&&(s+=a.int32()),(await r.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,On(async()=>(await t.iterator()).take(e),n)}async toArray(){if(this.size===Infinity)throw new Error("Can not convert infinite data stream to array.");return(await this.iterator()).toArray()}async toArrayForTest(){if(this.size===Infinity)throw new Error("Can not convert infinite data stream to array.");return(await this.iterator()).toArrayForTest()}};Tl.MAX_BUFFER_SIZE=1e4;function On(e,t=null){return new class extends Tl{constructor(){super(...arguments);this.size=t}async iterator(){return e()}}}function xne(e){return On(async()=>Q7(e),e.length)}function wne(e){if(!El(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 On(async()=>{let n=await Y7(e,r=>{if(r instanceof Tl)return{value:r.iterator(),recurse:!1};if(El(r))return{value:null,recurse:!0};throw new Error("Leaves of the structure passed to zip() must be Datasets, not primitives.")});return Pne(n,Va.SHORTEST)},t)}function Kne(e){if(e===null)return null;let t=e[0];return Fne(t)?{value:Zne(e),recurse:!1}:{value:null,recurse:!0}}function Zne(e){if(e.length===0)throw new Error("Can't make a batch of zero elements.");return e[0]instanceof Ye?Cn(e):dr(e)}var H7=class extends Tl{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))}},Hp='"',Nc=Symbol("out"),rv=Symbol("field"),Gp=Symbol("quote"),Bg=Symbol("quoteafterquote"),av=Symbol("quoteinquote"),G7=class extends Tl{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 H7(e),t||(t={}),this.hasHeader=t.hasHeader!==!1,this.fullColumnNames=t.columnNames,this.columnConfigs=t.columnConfigs,this.configuredColumnsOnly=t.configuredColumnsOnly,t.delimWhitespace?(v.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&&v.assert(e.length===this.fullColumnNames.length,()=>"The length of provided columnNames ("+this.fullColumnNames.length.toString()+") does not match the length of the header line read from file ("+e.length.toString()+")."),this.fullColumnNames||(this.fullColumnNames=e);let t=this.fullColumnNames.reduce((r,a)=>(r[a]=r[a]+1||1,r),{}),n=Object.keys(t).filter(r=>t[r]>1);if(v.assert(n.length===0,()=>"Duplicate column names found: "+n.toString()),this.columnConfigs){for(let r of Object.keys(this.columnConfigs))if(this.fullColumnNames.indexOf(r)===-1)throw new Error('The key "'+r+'" provided in columnConfigs does not match any of the column names ('+this.fullColumnNames.toString()+").")}this.columnNamesValidated=!0}async maybeReadHeaderLine(){if(this.hasHeader){let 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={},r={};for(let a=0;a<this.fullColumnNames.length;a++){let s=this.fullColumnNames[a],i=this.columnConfigs?this.columnConfigs[s]:null;if(!(this.configuredColumnsOnly&&!i)){let o=t[a],l=null;if(o==="")if(i&&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 u=Number(o);if(isNaN(u))i&&i.dtype==="bool"?l=this.getBoolean(o):l=o;else if(!i||!i.dtype)l=u;else switch(i.dtype){case"float32":l=u;break;case"int32":l=Math.floor(u);break;case"bool":l=this.getBoolean(o);break;default:l=u}}i&&i.isLabel?r[s]=l:n[s]=l}}return Object.keys(r).length===0?n:{xs:n,ys:r}}getBoolean(e){return e==="1"||e.toLowerCase()==="true"?1:0}parseRow(e,t=!0){let n=[],r=0,a=e.length,s=Nc;for(let i=0;i<a;i++)switch(s){case Nc:switch(e.charAt(i)){case Hp:r=i+1,s=Gp;break;case this.delimiter:if(r=i+1,this.delimiter===" "&&this.delimWhitespace)break;n.push(""),s=Nc;break;default:s=rv,r=i;break}break;case rv:switch(e.charAt(i)){case this.delimiter:n.push(e.substring(r,i)),s=Nc,r=i+1;break;default:}break;case Gp:switch(e.charAt(i)){case Hp:s=Bg;break;default:}break;case Bg:switch(e.charAt(i)){case this.delimiter:n.push(e.substring(r,i-1)),s=Nc,r=i+1;break;case Hp:s=Gp;break;default:s=av;break}break;case av:switch(e.charAt(i)){case Hp:s=Gp;break;default:}break;default:}if(s===Bg?n.push(e.substring(r,a-1)):n.push(e.substring(r)),t&&n.length!==this.fullColumnNames.length)throw new Error(`Invalid row in csv file. Should have ${this.fullColumnNames.length} elements in a row, but got ${n}`);return n}},sv=class extends qt{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
`),x.FRAGMENT_IDENTITY=["precision highp float;","varying vec2 vUv;","uniform sampler2D texture;","void main(void) {","gl_FragColor = texture2D(texture, vUv);","}"].join(`
`),c=new gae(m,x.VERTEX_IDENTITY,b);let N=Float32Array.BYTES_PER_ELEMENT,T=4*N;return m.enableVertexAttribArray(c.attribute.pos),m.vertexAttribPointer(c.attribute.pos,2,m.FLOAT,!1,T,0*N),m.enableVertexAttribArray(c.attribute.uv),m.vertexAttribPointer(c.attribute.uv,2,m.FLOAT,!1,T,2*N),p[b]=c,c};h.colorMatrix=function(b){let x=new Float32Array(b);x[4]/=255,x[9]/=255,x[14]/=255,x[19]/=255;let N=x[18]===1&&x[3]===0&&x[8]===0&&x[13]===0&&x[15]===0&&x[16]===0&&x[17]===0&&x[19]===0?h.colorMatrix.SHADER.WITHOUT_ALPHA:h.colorMatrix.SHADER.WITH_ALPHA,T=_(N);m.uniform1fv(T.uniform.m,x),w()},h.colorMatrix.SHADER={},h.colorMatrix.SHADER.WITH_ALPHA=["precision highp float;","varying vec2 vUv;","uniform sampler2D texture;","uniform float m[20];","void main(void) {","vec4 c = texture2D(texture, vUv);","gl_FragColor.r = m[0] * c.r + m[1] * c.g + m[2] * c.b + m[3] * c.a + m[4];","gl_FragColor.g = m[5] * c.r + m[6] * c.g + m[7] * c.b + m[8] * c.a + m[9];","gl_FragColor.b = m[10] * c.r + m[11] * c.g + m[12] * c.b + m[13] * c.a + m[14];","gl_FragColor.a = m[15] * c.r + m[16] * c.g + m[17] * c.b + m[18] * c.a + m[19];","}"].join(`
2021-02-21 20:07:04 +01:00
`),h.colorMatrix.SHADER.WITHOUT_ALPHA=["precision highp float;","varying vec2 vUv;","uniform sampler2D texture;","uniform float m[20];","void main(void) {","vec4 c = texture2D(texture, vUv);","gl_FragColor.r = m[0] * c.r + m[1] * c.g + m[2] * c.b + m[4];","gl_FragColor.g = m[5] * c.r + m[6] * c.g + m[7] * c.b + m[9];","gl_FragColor.b = m[10] * c.r + m[11] * c.g + m[12] * c.b + m[14];","gl_FragColor.a = c.a;","}"].join(`
2021-02-25 13:50:13 +01:00
`),h.brightness=function(b){let x=(b||0)+1;h.colorMatrix([x,0,0,0,0,0,x,0,0,0,0,0,x,0,0,0,0,0,1,0])},h.saturation=function(b){let x=(b||0)*2/3+1,N=(x-1)*-.5;h.colorMatrix([x,N,N,0,0,N,x,N,0,0,N,N,x,0,0,0,0,0,1,0])},h.desaturate=function(){h.saturation(-1)},h.contrast=function(b){let x=(b||0)+1,N=-128*(x-1);h.colorMatrix([x,0,0,0,N,0,x,0,0,N,0,0,x,0,N,0,0,0,1,0])},h.negative=function(){h.contrast(-2)},h.hue=function(b){b=(b||0)/180*Math.PI;let x=Math.cos(b),N=Math.sin(b),T=.213,E=.715,$=.072;h.colorMatrix([T+x*(1-T)+N*-T,E+x*-E+N*-E,$+x*-$+N*(1-$),0,0,T+x*-T+N*.143,E+x*(1-E)+N*.14,$+x*-$+N*-.283,0,0,T+x*-T+N*-(1-T),E+x*-E+N*E,$+x*(1-$)+N*$,0,0,0,0,0,1,0])},h.desaturateLuminance=function(){h.colorMatrix([.2764723,.929708,.0938197,0,-37.1,.2764723,.929708,.0938197,0,-37.1,.2764723,.929708,.0938197,0,-37.1,0,0,0,1,0])},h.sepia=function(){h.colorMatrix([.393,.7689999,.18899999,0,0,.349,.6859999,.16799999,0,0,.272,.5339999,.13099999,0,0,0,0,0,1,0])},h.brownie=function(){h.colorMatrix([.5997023498159715,.34553243048391263,-.2708298674538042,0,47.43192855600873,-.037703249837783157,.8609577587992641,.15059552388459913,0,-36.96841498319127,.24113635128153335,-.07441037908422492,.44972182064877153,0,-7.562075277591283,0,0,0,1,0])},h.vintagePinhole=function(){h.colorMatrix([.6279345635605994,.3202183420819367,-.03965408211312453,0,9.651285835294123,.02578397704808868,.6441188644374771,.03259127616149294,0,7.462829176470591,.0466055556782719,-.0851232987247891,.5241648018700465,0,5.159190588235296,0,0,0,1,0])},h.kodachrome=function(){h.colorMatrix([1.1285582396593525,-.3967382283601348,-.03992559172921793,0,63.72958762196502,-.16404339962244616,1.0835251566291304,-.05498805115633132,0,24.732407896706203,-.16786010706155763,-.5603416277695248,1.6014850761964943,0,35.62982807460946,0,0,0,1,0])},h.technicolor=function(){h.colorMatrix([1.9125277891456083,-.8545344976951645,-.09155508482755585,0,11.793603434377337,-.3087833385928097,1.7658908555458428,-.10601743074722245,0,-70.35205161461398,-.231103377548616,-.7501899197440212,1.847597816108189,0,30.950940869491138,0,0,0,1,0])},h.polaroid=function(){h.colorMatrix([1.438,-.062,-.062,0,0,-.122,1.378,-.122,0,0,-.016,-.016,1.483,0,0,0,0,0,1,0])},h.shiftToBGR=function(){h.colorMatrix([0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,1,0])},h.convolution=function(b){let x=new Float32Array(b),N=1/o,T=1/l,E=_(h.convolution.SHADER);m.uniform1fv(E.uniform.m,x),m.uniform2f(E.uniform.px,N,T),w()},h.convolution.SHADER=["precision highp float;","varying vec2 vUv;","uniform sampler2D texture;","uniform vec2 px;","uniform float m[9];","void main(void) {","vec4 c11 = texture2D(texture, vUv - px);","vec4 c12 = texture2D(texture, vec2(vUv.x, vUv.y - px.y));","vec4 c13 = texture2D(texture, vec2(vUv.x + px.x, vUv.y - px.y));","vec4 c21 = texture2D(texture, vec2(vUv.x - px.x, vUv.y) );","vec4 c22 = texture2D(texture, vUv);","vec4 c23 = texture2D(texture, vec2(vUv.x + px.x, vUv.y) );","vec4 c31 = texture2D(texture, vec2(vUv.x - px.x, vUv.y + px.y) );","vec4 c32 = texture2D(texture, vec2(vUv.x, vUv.y + px.y) );","vec4 c33 = texture2D(texture, vUv + px );","gl_FragColor = ","c11 * m[0] + c12 * m[1] + c22 * m[2] +","c21 * m[3] + c22 * m[4] + c23 * m[5] +","c31 * m[6] + c32 * m[7] + c33 * m[8];","gl_FragColor.a = c22.a;","}"].join(`
`),h.detectEdges=function(){h.convolution.call(this,[0,1,0,1,-4,1,0,1,0])},h.sobelX=function(){h.convolution.call(this,[-1,0,1,-2,0,2,-1,0,1])},h.sobelY=function(){h.convolution.call(this,[-1,-2,-1,0,0,0,1,2,1])},h.sharpen=function(b){let x=b||1;h.convolution.call(this,[0,-1*x,0,-1*x,1+4*x,-1*x,0,-1*x,0])},h.emboss=function(b){let x=b||1;h.convolution.call(this,[-2*x,-1*x,0,-1*x,1,1*x,0,1*x,2*x])},h.blur=function(b){let x=b/7/o,N=b/7/l,T=_(h.blur.SHADER);m.uniform2f(T.uniform.px,0,N),w(f.INTERMEDIATE),m.uniform2f(T.uniform.px,x,0),w()},h.blur.SHADER=["precision highp float;","varying vec2 vUv;","uniform sampler2D texture;","uniform vec2 px;","void main(void) {","gl_FragColor = vec4(0.0);","gl_FragColor += texture2D(texture, vUv + vec2(-7.0*px.x, -7.0*px.y))*0.0044299121055113265;","gl_FragColor += texture2D(texture, vUv + vec2(-6.0*px.x, -6.0*px.y))*0.00895781211794;","gl_FragColor += texture2D(texture, vUv + vec2(-5.0*px.x, -5.0*px.y))*0.0215963866053;","gl_FragColor += texture2D(texture, vUv + vec2(-4.0*px.x, -4.0*px.y))*0.0443683338718;","gl_FragColor += texture2D(texture, vUv + vec2(-3.0*px.x, -3.0*px.y))*0.0776744219933;","gl_FragColor += texture2D(texture, vUv + vec2(-2.0*px.x, -2.0*px.y))*0.115876621105;","gl_FragColor += texture2D(texture, vUv + vec2(-1.0*px.x, -1.0*px.y))*0.147308056121;","gl_FragColor += texture2D(texture, vUv )*0.159576912161;","gl_FragColor += texture2D(texture, vUv + vec2( 1.0*px.x, 1.0*px.y))*0.147308056121;","gl_FragColor += texture2D(texture, vUv + vec2( 2.0*px.x, 2.0*px.y))*0.115876621105;","gl_FragColor += texture2D(texture, vUv + vec2( 3.0*px.x, 3.0*px.y))*0.0776744219933;","gl_FragColor += texture2D(texture, vUv + vec2( 4.0*px.x, 4.0*px.y))*0.0443683338718;","gl_FragColor += texture2D(texture, vUv + vec2( 5.0*px.x, 5.0*px.y))*0.0215963866053;","gl_FragColor += texture2D(texture, vUv + vec2( 6.0*px.x, 6.0*px.y))*0.00895781211794;","gl_FragColor += texture2D(texture, vUv + vec2( 7.0*px.x, 7.0*px.y))*0.0044299121055113265;","}"].join(`
`),h.pixelate=function(b){let x=b/o,N=b/l,T=_(h.pixelate.SHADER);m.uniform2f(T.uniform.size,x,N),w()},h.pixelate.SHADER=["precision highp float;","varying vec2 vUv;","uniform vec2 size;","uniform sampler2D texture;","vec2 pixelate(vec2 coord, vec2 size) {","return floor( coord / size ) * size;","}","void main(void) {","gl_FragColor = vec4(0.0);","vec2 coord = pixelate(vUv, size);","gl_FragColor += texture2D(texture, coord);","}"].join(`
`)}var Et=null,en=null,Ft=null;function wae(e,t){let n;if(e instanceof Ye)n=Ir(e);else{let r=e.naturalWidth||e.videoWidth||e.width||e.shape&&e.shape[1]>0,a=e.naturalHeight||e.videoHeight||e.height||e.shape&&e.shape[2]>0,s=r,i=a;if(t.filter.width>0?s=t.filter.width:t.filter.height>0&&(s=r*(t.filter.height/a)),t.filter.height>0?i=t.filter.height:t.filter.width>0&&(i=a*(t.filter.width/r)),!s||!i)return Ve("Human: invalid input",e),null;(!Et||Et.width!==s||Et.height!==i)&&(Et=typeof OffscreenCanvas!="undefined"?new OffscreenCanvas(s,i):document.createElement("canvas"),Et.width!==s&&(Et.width=s),Et.height!==i&&(Et.height=i));let o=Et.getContext("2d");if(e instanceof ImageData?o.putImageData(e,0,0):o.drawImage(e,0,0,r,a,0,0,Et.width,Et.height),t.filter.enabled){if((!Ft||!en||Et.width!==en.width||Et.height!==en.height)&&(en=typeof OffscreenCanvas!="undefined"?new OffscreenCanvas(Et.width,Et.height):document.createElement("canvas"),en.width!==Et.width&&(en.width=Et.width),en.height!==Et.height&&(en.height=Et.height),Ft=jl.flags.IS_BROWSER?new xae({canvas:en}):null),!Ft)return Et;Ft.reset(),Ft.addFilter("brightness",t.filter.brightness),t.filter.contrast!==0&&Ft.addFilter("contrast",t.filter.contrast),t.filter.sharpness!==0&&Ft.addFilter("sharpen",t.filter.sharpness),t.filter.blur!==0&&Ft.addFilter("blur",t.filter.blur),t.filter.saturation!==0&&Ft.addFilter("saturation",t.filter.saturation),t.filter.hue!==0&&Ft.addFilter("hue",t.filter.hue),t.filter.negative&&Ft.addFilter("negative"),t.filter.sepia&&Ft.addFilter("sepia"),t.filter.vintage&&Ft.addFilter("brownie"),t.filter.sepia&&Ft.addFilter("sepia"),t.filter.kodachrome&&Ft.addFilter("kodachrome"),t.filter.technicolor&&Ft.addFilter("technicolor"),t.filter.polaroid&&Ft.addFilter("polaroid"),t.filter.pixelate!==0&&Ft.addFilter("pixelate",t.filter.pixelate),Ft.apply(Et)}else en=Et,Ft&&(Ft=null);let l;if(en.data){let c=[en.height,en.width,3];l=If(en.data,c,"int32")}else if(t.backend==="webgl"||en instanceof ImageData)l=cu.fromPixels(en);else{let c=typeof OffscreenCanvas!="undefined"?new OffscreenCanvas(s,i):document.createElement("canvas");c.width=s,c.height=i;let h=c.getContext("2d");h==null||h.drawImage(en,0,0);let d=h==null?void 0:h.getImageData(0,0,s,i);l=cu.fromPixels(d)}let u=l.toFloat();n=u.expandDims(0),l.dispose(),u.dispose()}return{tensor:n,canvas:t.filter.return?en:null}}var _ae={backend:"webgl",wasmPath:"../assets/",async:!0,profile:!1,deallocate:!1,scoped:!1,videoOptimized:!0,warmup:"face",filter:{enabled:!0,width:0,height:0,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:"../models/blazeface-back.json",inputSize:256,rotation:!1,maxFaces:10,skipFrames:11,minConfidence:.2,iouThreshold:.2,scoreThreshold:.2},mesh:{enabled:!0,modelPath:"../models/facemesh.json",inputSize:192,returnRawData:!1},iris:{enabled:!0,modelPath:"../models/iris.json",inputSize:64},age:{enabled:!0,modelPath:"../models/age-ssrnet-imdb.json",inputSize:64,skipFrames:31},gender:{enabled:!0,minConfidence:.4,modelPath:"../models/gender.json",inputSize:64,skipFrames:41},emotion:{enabled:!0,inputSize:64,minConfidence:.2,skipFrames:21,modelPath:"../models/emotion-large.json"},embedding:{enabled:!1,inputSize:112,modelPath:"../models/mobilefacenet.json"}},body:{enabled:!0,modelPath:"../models/posenet.json",inputSize:257,maxDetections:10,scoreThreshold:.5,nmsRadius:20,outputStride:16,modelType:"MobileNet"},hand:{enabled:!0,rotation:!1,inputSize:256,skipFrames:12,minConfidence:.1,iouThreshold:.1,scoreThreshold:.5,maxHands:1,landmarks:!0,detector:{modelPath:"../models/handdetect.json"},skeleton:{modelPath:"../models/handskeleton.json"}}},g2=`
2020-12-08 15:58:30 +01:00
/9j/4AAQSkZJRgABAQEAYABgAAD/4QBoRXhpZgAATU0AKgAAAAgABAEaAAUAAAABAAAAPgEbAAUA
AAABAAAARgEoAAMAAAABAAIAAAExAAIAAAARAAAATgAAAAAAAABgAAAAAQAAAGAAAAABcGFpbnQu
bmV0IDQuMi4xMwAA/9sAQwAGBAUGBQQGBgUGBwcGCAoQCgoJCQoUDg8MEBcUGBgXFBYWGh0lHxob
IxwWFiAsICMmJykqKRkfLTAtKDAlKCko/9sAQwEHBwcKCAoTCgoTKBoWGigoKCgoKCgoKCgoKCgo
KCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgo/8AAEQgBAAEAAwEhAAIRAQMRAf/E
AB8AAAEFAQEBAQEBAAAAAAAAAAABAgMEBQYHCAkKC//EALUQAAIBAwMCBAMFBQQEAAABfQECAwAE
EQUSITFBBhNRYQcicRQygZGhCCNCscEVUtHwJDNicoIJChYXGBkaJSYnKCkqNDU2Nzg5OkNERUZH
SElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6g4SFhoeIiYqSk5SVlpeYmZqio6Slpqeoqaqys7S1
tre4ubrCw8TFxsfIycrS09TV1tfY2drh4uPk5ebn6Onq8fLz9PX29/j5+v/EAB8BAAM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fRxfp1qi3F48ofKMvtvxak8s6LDv61
rZji9rPaLUf5PC+bfttS0q8q3p9W/wBrRMdpUZuKdN99nzvFqPbTVz7nD8OKs+do2/mW3h4D7Xaq
ZnPrtNpqz35aRaYOHY9Zk4pNt9rR+rl6zi+OnS+WN57Rv1lXp/YrNaYtruL6zNPnGO3hxP6O5w/2
f0HDuun09Yv55Le9afznqcOvO4tBreMTHu30unnva0bWt8on+70nDuE4OHYYx4Kbesz3tPrMuhGO
IjpDOKrK9YVpsyiGUQnYGOyUgI2SlAIEmwMWMs9kTAMJYzDOYRMArmGErZhhMArlHmzmGMwDE3Ts
bAbs4swj5pgFkSziVcM4BZEsolXDKAZwyhjCYBkACQhIAAAAAAAJAAAAAAAAAAAAAAAAAAAShIAA
AAAAAAJAAAAAAAAAAAAAABAJEAAAAAAAAAAAAAAAIEoBKAAAAAAAAAAAAAAABAlAAAAAAAIAAAAA
BAkBAkBAkBAlACEgMZjdjbFW8bWrEx8YWANb6Fp+bfwab+vLDKMFK9qxH5L0bAr8OPRPKz2AY7J2
SbAjYZAI2E7AIEgIEgIEgMdkSy2NgY7MdlmyNoBXsxmFuyNgVTVjNV3KjlBRNTlXTVHKCrlIqt5T
lBhEMohlFerLlBjEMohMVTEARDKCITsAk2AEgAAAkAAAAAAAAAAAAAAAAAAAAAAAASAAAAAAAAD/
2021-02-25 13:50:13 +01:00
2Q==`,Gv={};kr(Gv,{author:()=>e6,browser:()=>Jv,bugs:()=>t6,default:()=>bae,dependencies:()=>i6,description:()=>Xv,devDependencies:()=>l6,engines:()=>a6,homepage:()=>n6,keywords:()=>c6,license:()=>r6,main:()=>Zv,module:()=>Yv,name:()=>qv,peerDependencies:()=>o6,repository:()=>s6,scripts:()=>u6,sideEffects:()=>Kv,types:()=>Qv,version:()=>w2});var qv="@vladmandic/human",w2="0.20.11",Xv="Human: AI-powered 3D Face Detection, Face Embedding & Recognition, Body Pose Tracking, Hand & Finger Tracking, Iris Analysis, Age & Gender & Emotion Prediction & Gesture Recognition",Kv=!1,Zv="dist/human.node.js",Yv="dist/human.esm.js",Jv="dist/human.esm.js",Qv="types/human.d.ts",e6="Vladimir Mandic <mandic00@live.com>",t6={url:"https://github.com/vladmandic/human/issues"},n6="https://github.com/vladmandic/human#readme",r6="MIT",a6={node:">=12.0.0"},s6={type:"git",url:"git+https://github.com/vladmandic/human.git"},i6={},o6={},l6={"@tensorflow/tfjs":"^3.2.0","@tensorflow/tfjs-backend-cpu":"^3.2.0","@tensorflow/tfjs-backend-wasm":"^3.2.0","@tensorflow/tfjs-backend-webgl":"^3.2.0","@tensorflow/tfjs-converter":"^3.2.0","@tensorflow/tfjs-core":"^3.2.0","@tensorflow/tfjs-data":"^3.2.0","@tensorflow/tfjs-layers":"^3.2.0","@tensorflow/tfjs-node":"^3.2.0","@tensorflow/tfjs-node-gpu":"^3.2.0","@types/node":"^14.14.31","@typescript-eslint/eslint-plugin":"^4.15.2","@typescript-eslint/parser":"^4.15.2","@vladmandic/pilogger":"^0.2.14",chokidar:"^3.5.1",dayjs:"^1.10.4",esbuild:"^0.8.52",eslint:"^7.20.0","eslint-config-airbnb-base":"^14.2.1","eslint-plugin-import":"^2.22.1","eslint-plugin-json":"^2.1.2","eslint-plugin-node":"^11.1.0","eslint-plugin-promise":"^4.3.1",rimraf:"^3.0.2",seedrandom:"^3.0.5","simple-git":"^2.35.2",tslib:"^2.1.0",typescript:"^4.3.0-dev.20210225"},u6={start:"node --trace-warnings --unhandled-rejections=strict --trace-uncaught --no-deprecation src/node.js",lint:"eslint src demo server",dev:"npm install && node server/serve.js",build:"rimraf dist/* && rimraf types/* && node server/build.js && node server/changelog.js",update:"npm update --depth 20 --force && npm dedupe && npm prune && npm audit"},c6=["tensorflowjs","face-detection","face-geometry","face-embedding","face-recognition","body-tracking","hand-tracking","iris-tracking","age-estimation","emotion-detection","gender-prediction","gesture-recognition"],bae={name:qv,version:w2,description:Xv,sideEffects:Kv,main:Zv,module:Yv,browser:Jv,types:Qv,author:e6,bugs:t6,homepage:n6,license:r6,engines:a6,repository:s6,dependencies:i6,peerDependencies:o6,devDependencies:l6,scripts:u6,keywords:c6},ht=()=>typeof performance!="undefined"?performance.now():parseInt((Number(process.hrtime.bigint())/1e3/1e3).toString());function Tc(...e){let t=n=>n&&typeof n=="object";return e.reduce((n,r)=>(Object.keys(r||{}).forEach(a=>{let s=n[a],i=r[a];Array.isArray(s)&&Array.isArray(i)?n[a]=s.concat(...i):t(s)&&t(i)?n[a]=Tc(s,i):n[a]=i}),n),{})}var h6=class{constructor(e={}){this.tf=M2,this.package=Gv,this.version=w2,this.config=Tc(_ae,e),this.fx=null,this.state="idle",this.numTensors=0,this.analyzeMemoryLeaks=!1,this.checkSanity=!1,this.firstRun=!0,this.perf={},this.models={facemesh:null,posenet:null,handpose:null,iris:null,age:null,gender:null,emotion:null},this.facemesh=yv,this.age=_v,this.gender=bv,this.emotion=vv,this.body=Sv,this.hand=Lv}profile(){return this.config.profile?wv:{}}analyze(...e){if(!this.analyzeMemoryLeaks)return;let t=this.tf.engine().state.numTensors,n=this.numTensors;this.numTensors=t;let r=t-n;r!==0&&Ve(...e,r)}sanity(e){if(!this.checkSanity)return null;if(!e)return"input is not defined";if(this.tf.ENV.flags.IS_NODE&&!(e instanceof this.tf.Tensor))return"input must be a tensor";try{this.tf.getBackend()}catch(t){return"backend not loaded"}return null}simmilarity(e,t){return this.config.face.embedding.enabled?Ere(e,t):0}async load(e=null){this.state="load";let t=ht();e&&(this.config=Tc(this.config,e)),this.firstRun&&(Ve(`version: ${this.version} TensorFlow/JS version: ${this.tf.version_core}`),await this.checkBackend(!0),this.tf.ENV.flags.IS_BROWSER&&(Ve("configuration:",this.config
2020-11-07 17:34:56 +01:00
:root { --rounded: 0.2rem; }
2020-11-23 13:44:10 +01:00
.menu { position: absolute; top: 0rem; right: 0; width: max-content; padding: 0 0.2rem 0 0.2rem; line-height: 1.8rem; z-index: 10;
2021-02-25 13:50:13 +01:00
box-shadow: 0 0 8px dimgrey; background: ${xt.background}; border-radius: var(--rounded); border-color: black; border-style: solid; border-width: thin; }
2020-11-07 17:34:56 +01:00
2021-02-25 13:50:13 +01:00
.menu:hover { box-shadow: 0 0 8px ${xt.hover}; }
2020-11-07 17:34:56 +01:00
.menu-container { display: block; max-height: 100vh; }
.menu-container-fadeout { max-height: 0; overflow: hidden; transition: max-height, 0.5s ease; }
.menu-container-fadein { max-height: 100vh; overflow: hidden; transition: max-height, 0.5s ease; }
2020-11-19 20:45:59 +01:00
.menu-item { display: flex; white-space: nowrap; padding: 0.2rem; cursor: default; width: 100%; }
.menu-title { cursor: pointer; }
2020-11-07 17:34:56 +01:00
.menu-hr { margin: 0.2rem; border: 1px solid rgba(0, 0, 0, 0.5) }
2020-11-08 18:26:45 +01:00
.menu-label { padding: 0; font-weight: 800; }
2020-11-07 17:34:56 +01:00
.menu-list { margin-right: 0.8rem; }
select:focus { outline: none; }
2021-02-25 13:50:13 +01:00
.menu-list-item { background: ${xt.itemBackground}; color: ${xt.itemColor}; border: none; padding: 0.2rem; font-family: inherit;
2020-11-10 02:13:38 +01:00
font-variant: inherit; border-radius: var(--rounded); font-weight: 800; }
2020-11-07 17:34:56 +01:00
.menu-chart-title { padding: 0; font-size: 0.8rem; font-weight: 800; align-items: center}
.menu-chart-canvas { background: transparent; margin: 0.2rem 0 0.2rem 0.6rem; }
2021-02-25 13:50:13 +01:00
.menu-button { border: 0; background: ${xt.buttonBackground}; width: -webkit-fill-available; padding: 8px; margin: 8px; cursor: pointer; box-shadow: 4px 4px 4px 0 dimgrey;
2020-11-10 02:13:38 +01:00
border-radius: var(--rounded); justify-content: center; font-family: inherit; font-variant: inherit; font-size: 1rem; font-weight: 800; }
2021-02-25 13:50:13 +01:00
.menu-button:hover { background: ${xt.buttonHover}; box-shadow: 4px 4px 4px 0 black; }
2020-11-07 17:34:56 +01:00
.menu-button:focus { outline: none; }
2021-02-25 13:50:13 +01:00
.menu-checkbox { width: 2.8rem; height: 1rem; background: ${xt.itemBackground}; margin: 0.5rem 0.5rem 0 0; position: relative; border-radius: var(--rounded); }
.menu-checkbox:after { content: 'OFF'; color: ${xt.checkboxOff}; position: absolute; right: 0.2rem; top: -0.4rem; font-weight: 800; font-size: 0.5rem; }
.menu-checkbox:before { content: 'ON'; color: ${xt.checkboxOn}; position: absolute; left: 0.3rem; top: -0.4rem; font-weight: 800; font-size: 0.5rem; }
.menu-checkbox-label { width: 1.3rem; height: 0.8rem; cursor: pointer; position: absolute; top: 0.1rem; left: 0.1rem; z-index: 1; background: ${xt.checkboxOff};
2021-02-21 20:07:04 +01:00
border-radius: var(--rounded); transition: left 0.6s ease; }
input[type=checkbox] { visibility: hidden; }
2021-02-25 13:50:13 +01:00
input[type=checkbox]:checked + label { left: 1.4rem; background: ${xt.checkboxOn}; }
2021-02-21 20:07:04 +01:00
2021-02-25 13:50:13 +01:00
.menu-range { margin: 0.2rem 0.5rem 0 0; width: 3.5rem; background: transparent; color: ${xt.rangeBackground}; }
.menu-range:before { color: ${xt.rangeLabel}; margin: 0 0.4rem 0 0; font-weight: 800; font-size: 0.6rem; position: relative; top: 0.3rem; content: attr(value); }
2020-11-09 14:57:24 +01:00
2021-02-21 20:07:04 +01:00
input[type=range] { -webkit-appearance: none; }
2021-02-25 13:50:13 +01:00
input[type=range]::-webkit-slider-runnable-track { width: 100%; height: 1rem; cursor: pointer; background: ${xt.itemBackground}; border-radius: var(--rounded); border: 1px; }
input[type=range]::-moz-range-track { width: 100%; height: 1rem; cursor: pointer; background: ${xt.itemBackground}; border-radius: var(--rounded); border: 1px; }
input[type=range]::-webkit-slider-thumb { border: 1px solid #000000; margin-top: 0.05rem; height: 0.9rem; width: 1rem; border-radius: var(--rounded); background: ${xt.rangeBackground}; cursor: pointer; -webkit-appearance: none; }
input[type=range]::-moz-range-thumb { border: 1px solid #000000; margin-top: 0.05rem; height: 0.9rem; width: 1rem; border-radius: var(--rounded); background: ${xt.rangeBackground}; cursor: pointer; -webkit-appearance: none; }
2021-02-21 20:07:04 +01:00
.svg-background { fill:darkslategrey; cursor:pointer; opacity: 0.6; }
.svg-foreground { fill:white; cursor:pointer; opacity: 0.8; }
2021-02-25 13:50:13 +01:00
`,t=document.createElement("style");t.innerHTML=e,document.getElementsByTagName("head")[0].appendChild(t),d6=!0}var p6=class{constructor(t,n,r,a){a&&(xt={...xt,...a}),Sae(),this.createMenu(t,n,r),this.id=0,this.instance=Cc,Cc++,this._maxFPS=0,this.hidden=0}createMenu(t,n="",r={top:null,left:null,bottom:null,right:null}){this.menu=document.createElement("div"),this.menu.id=`menu-${Cc}`,this.menu.className="menu",r&&(r.top&&(this.menu.style.top=r.top),r.bottom&&(this.menu.style.bottom=r.bottom),r.left&&(this.menu.style.left=r.left),r.right&&(this.menu.style.right=r.right)),this.container=document.createElement("div"),this.container.id=`menu-container-${Cc}`,this.container.className="menu-container menu-container-fadein";let a=document.createElement("div");a.className="menu-title",a.id=`menu-title-${Cc}`;let s=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512" style="width: 2rem; height: 2rem; vertical-align: top;">
2021-02-21 20:07:04 +01:00
<path d="M400 32H48A48 48 0 0 0 0 80v352a48 48 0 0 0 48 48h352a48 48 0 0 0 48-48V80a48 48 0 0 0-48-48zm-51.37 182.31L232.06 348.16a10.38 10.38 0 0 1-16.12 0L99.37 214.31C92.17 206 97.28 192 107.43 192h233.14c10.15 0 15.26 14 8.06 22.31z" class="svg-background"/>
<path d="M348.63 214.31L232.06 348.16a10.38 10.38 0 0 1-16.12 0L99.37 214.31C92.17 206 97.28 192 107.43 192h233.14c10.15 0 15.26 14 8.06 22.31z" class="svg-foreground"/>
2021-02-25 13:50:13 +01:00
</svg>`;n&&(a.innerHTML=`${n}${s}`),this.menu.appendChild(a),a.addEventListener("click",()=>{this.container.classList.toggle("menu-container-fadeout"),this.container.classList.toggle("menu-container-fadein"),this.menu.style.borderStyle=this.container.classList.contains("menu-container-fadeout")?"none":"solid"}),this.menu.appendChild(this.container),typeof t=="object"?t.appendChild(this.menu):document.getElementById(t).appendChild(this.menu)}get newID(){return this.id++,`menu-${this.instance}-${this.id}`}get ID(){return`menu-${this.instance}-${this.id}`}get width(){return this.menu.offsetWidth}get height(){return this.menu.offsetHeight}hide(){this.container.classList.contains("menu-container-fadein")&&(this.container.classList.toggle("menu-container-fadeout"),this.container.classList.toggle("menu-container-fadein"))}visible(){return this.container.classList.contains("menu-container-fadein")}toggle(t){if(this.container.classList.toggle("menu-container-fadeout"),this.container.classList.toggle("menu-container-fadein"),this.container.classList.contains("menu-container-fadein")&&t){let n=t.x||(t.touches&&t.touches[0]?t.touches[0].pageX:null);n&&(this.menu.style.left=`${n-this.menu.offsetWidth/2}px`),this.menu.offsetLeft<0&&(this.menu.style.left=0),this.menu.offsetLeft+this.menu.offsetWidth>window.innerWidth&&(this.menu.style.left=null,this.menu.style.right=0),this.menu.style.borderStyle="solid"}else this.menu.style.borderStyle="none"}addTitle(t){let n=document.createElement("div");return n.className="menu-title",n.id=this.newID,n.innerHTML=t,this.menu.appendChild(n),n.addEventListener("click",()=>{this.hidden=!this.hidden;let r=document.getElementsByClassName("menu");for(let a of r)a.style.display=this.hidden?"none":"block"}),n}addLabel(t){let n=document.createElement("div");return n.className="menu-item menu-label",n.id=this.newID,n.innerHTML=t,this.container.appendChild(n),n}addBool(t,n,r,a){let s=document.createElement("div");return s.className="menu-item",s.innerHTML=`<div class="menu-checkbox"><input class="menu-checkbox" type="checkbox" id="${this.newID}" ${n[r]?"checked":""}/><label class="menu-checkbox-label" for="${this.ID}"></label></div>${t}`,this.container.appendChild(s),s.addEventListener("change",i=>{n[r]=i.target.checked,a&&a(i.target.checked)}),s}async addList(t,n,r,a){let s=document.createElement("div");s.className="menu-item";let i="";for(let o of n)i+=`<option value="${o}" ${o===r?"selected":""}>${o}</option>`;return s.innerHTML=`<div class="menu-list"><select name="${this.ID}" class="menu-list-item">${i}</select><label for="${this.ID}"></label></div>${t}`,s.style.fontFamily=document.body.style.fontFamily,s.style.fontSize=document.body.style.fontSize,s.style.fontVariant=document.body.style.fontVariant,this.container.appendChild(s),s.addEventListener("change",o=>{a&&a(n[o.target.selectedIndex])}),s}addRange(t,n,r,a,s,i,o){let l=document.createElement("div");return l.className="menu-item",l.innerHTML=`<input class="menu-range" type="range" id="${this.newID}" min="${a}" max="${s}" step="${i}" value="${n[r]}">${t}`,this.container.appendChild(l),l.addEventListener("change",u=>{n[r]=parseInt(u.target.value)===parseFloat(u.target.value)?parseInt(u.target.value):parseFloat(u.target.value),u.target.setAttribute("value",u.target.value),o&&o(u.target.value)}),l.input=l.children[0],l}addHTML(t){let n=document.createElement("div");return n.className="menu-item",n.id=this.newID,t&&(n.innerHTML=t),this.container.appendChild(n),n}addButton(t,n,r){let a=document.createElement("button");return a.className="menu-item menu-button",a.style.fontFamily=document.body.style.fontFamily,a.style.fontSize=document.body.style.fontSize,a.style.fontVariant=document.body.style.fontVariant,a.type="button",a.id=this.newID,a.innerText=t,this.container.appendChild(a),a.addEventListener("click",()=>{a.innerText===t?a.innerText=n:a.innerText=t,r&&r(a.innerText!==t)}),a}addValue(t,n,r=""){let a=document.createElement("div");return a.className="menu-item",a.id=`menu-val-${t}`,a.innerText=`${t}: ${n}${r}`,this.container.appendChild(a),a}upda
2020-11-14 23:22:59 +01:00
#gl-bench { position: absolute; right: 1rem; bottom: 1rem; z-index:1000; -webkit-user-select: none; -moz-user-select: none; user-select: none; }
#gl-bench div { position: relative; display: block; margin: 4px; padding: 0 7px 0 10px; background: darkslategray; border-radius: 0.2rem; cursor: pointer; opacity: 0.9; }
2020-11-19 20:45:59 +01:00
#gl-bench svg { height: 60px; margin: 0 0px 0px 4px; }
2020-11-14 23:22:59 +01:00
#gl-bench text { font-size: 16px; font-family: 'Lato', 'Segoe UI'; dominant-baseline: middle; text-anchor: middle; }
#gl-bench .gl-mem { font-size: 12px; fill: white; }
#gl-bench .gl-fps { font-size: 13px; fill: white; }
#gl-bench line { stroke-width: 5; stroke: white; stroke-linecap: round; }
#gl-bench polyline { fill: none; stroke: white; stroke-linecap: round; stroke-linejoin: round; stroke-width: 3.5; }
#gl-bench rect { fill: black; }
#gl-bench .opacity { stroke: black; }
2021-02-25 13:50:13 +01:00
`,Eae=`
2020-11-12 23:00:06 +01:00
<div class="gl-box">
<svg viewBox="0 0 55 60">
<text x="27" y="56" class="gl-fps">00 FPS</text>
2020-11-19 20:45:59 +01:00
<text x="30" y="8" class="gl-mem"></text>
2020-11-12 23:00:06 +01:00
<rect x="0" y="14" rx="4" ry="4" width="55" height="32"></rect>
<polyline class="gl-chart"></polyline>
</svg>
<svg viewBox="0 0 14 60" class="gl-cpu-svg">
<line x1="7" y1="38" x2="7" y2="11" class="opacity"/>
<line x1="7" y1="38" x2="7" y2="11" class="gl-cpu" stroke-dasharray="0 27"/>
2020-11-14 23:22:59 +01:00
<path d="M5.35 43c-.464 0-.812.377-.812.812v1.16c-.783.1972-1.421.812-1.595 1.624h-1.16c-.435 0-.812.348-.812.812s.348.812.812.812h1.102v1.653H1.812c-.464 0-.812.377-.812.812 0 .464.377.812.812.812h1.131c.1943.783.812 1.392 1.595 1.595v1.131c0 .464.377.812.812.812.464 0 .812-.377.812-.812V53.15h1.653v1.073c0 .464.377.812.812.812.464 0 .812-.377.812-.812v-1.131c.783-.1943 1.392-.812 1.595-1.595h1.131c.464 0 .812-.377.812-.812 0-.464-.377-.812-.812-.812h-1.073V48.22h1.102c.435 0 .812-.348.812-.812s-.348-.812-.812-.812h-1.16c-.1885-.783-.812-1.421-1.595-1.624v-1.131c0-.464-.377-.812-.812-.812-.464 0-.812.377-.812.812v1.073H6.162v-1.073c0-.464-.377-.812-.812-.812zm.58 3.48h2.088c.754 0 1.363.609 1.363 1.363v2.088c0 .754-.609 1.363-1.363 1.363H5.93c-.754 0-1.363-.609-1.363-1.363v-2.088c0-.754.609-1.363 1.363-1.363z" style="fill: grey"></path>
2020-11-12 23:00:06 +01:00
</svg>
<svg viewBox="0 0 14 60" class="gl-gpu-svg">
<line x1="7" y1="38" x2="7" y2="11" class="opacity"/>
<line x1="7" y1="38" x2="7" y2="11" class="gl-gpu" stroke-dasharray="0 27"/>
2020-11-14 23:22:59 +01:00
<path d="M1.94775 43.3772a.736.736 0 10-.00416 1.472c.58535.00231.56465.1288.6348.3197.07015.18975.04933.43585.04933.43585l-.00653.05405v8.671a.736.736 0 101.472 0v-1.4145c.253.09522.52785.1495.81765.1495h5.267c1.2535 0 2.254-.9752 2.254-2.185v-3.105c0-1.2075-1.00625-2.185-2.254-2.185h-5.267c-.28865 0-.5635.05405-.8165.1495.01806-.16445.04209-.598-.1357-1.0787-.22425-.6072-.9499-1.2765-2.0125-1.2765zm2.9095 3.6455c.42435 0 .7659.36225.7659.8119v2.9785c0 .44965-.34155.8119-.7659.8119s-.7659-.36225-.7659-.8119v-2.9785c0-.44965.34155-.8119.7659-.8119zm4.117 0a2.3 2.3 0 012.3 2.3 2.3 2.3 0 01-2.3 2.3 2.3 2.3 0 01-2.3-2.3 2.3 2.3 0 012.3-2.3z" style="fill: grey"></path>
2020-11-12 23:00:06 +01:00
</svg>
</div>
2021-02-25 13:50:13 +01:00
`,f6=class{constructor(t,n={}){this.css=Tae,this.svg=Eae,this.paramLogger=()=>{},this.chartLogger=()=>{},this.chartLen=20,this.chartHz=20,this.names=[],this.cpuAccums=[],this.gpuAccums=[],this.activeAccums=[],this.chart=new Array(this.chartLen),this.now=()=>performance&&performance.now?performance.now():Date.now(),this.updateUI=()=>{[].forEach.call(this.nodes["gl-gpu-svg"],o=>o.style.display=this.trackGPU?"inline":"none")},Object.assign(this,n),this.detected=0,this.finished=[],this.isFramebuffer=0,this.frameId=0;let r,a=0,s,i=o=>{++a<20?r=requestAnimationFrame(i):(this.detected=Math.ceil(1e3*a/(o-s)/70),cancelAnimationFrame(r)),s||(s=o)};if(requestAnimationFrame(i),t){let o=async(c,h)=>Promise.resolve(setTimeout(()=>{t.getError();let d=this.now()-c;h.forEach((p,f)=>{p&&(this.gpuAccums[f]+=d)})},0)),l=(c,h,d)=>{let p=h.now();c.apply(d,arguments),h.trackGPU&&h.finished.push(o(p,h.activeAccums.slice(0)))},u="drawElements";t[u]?t[u]=l(t[u],this,t):console.log("bench: cannot attach to webgl function")}if(!this.withoutUI){this.dom||(this.dom=document.body);let o=document.createElement("div");o.id="gl-bench",this.dom.appendChild(o),this.dom.insertAdjacentHTML("afterbegin",'<style id="gl-bench-style">'+this.css+"</style>"),this.dom=o,this.dom.addEventListener("click",()=>{this.trackGPU=!this.trackGPU,this.updateUI()}),this.paramLogger=((l,u,c)=>{let h=["gl-cpu","gl-gpu","gl-mem","gl-fps","gl-gpu-svg","gl-chart"],d={...h};return h.forEach(p=>d[p]=u.getElementsByClassName(p)),this.nodes=d,(p,f,m,A,y,g,w)=>{d["gl-cpu"][p].style.strokeDasharray=(f*.27).toFixed(0)+" 100",d["gl-gpu"][p].style.strokeDasharray=(m*.27).toFixed(0)+" 100",d["gl-mem"][p].innerHTML=c[p]?c[p]:A?"mem: "+A.toFixed(0)+"mb":"",d["gl-fps"][p].innerHTML="FPS: "+y.toFixed(1),l(c[p],f,m,A,y,g,w)}})(this.paramLogger,this.dom,this.names),this.chartLogger=((l,u)=>{let c={"gl-chart":u.getElementsByClassName("gl-chart")};return(h,d,p)=>{let f="",m=d.length;for(let A=0;A<m;A++){let y=(p+A+1)%m;d[y]!==void 0&&(f=f+" "+(55*A/(m-1)).toFixed(1)+","+(45-d[y]*22/60/this.detected).toFixed(1))}c["gl-chart"][h].setAttribute("points",f),l(this.names[h],d,p)}})(this.chartLogger,this.dom)}}addUI(t){this.names.indexOf(t)===-1&&(this.names.push(t),this.dom&&(this.dom.insertAdjacentHTML("beforeend",this.svg),this.updateUI()),this.cpuAccums.push(0),this.gpuAccums.push(0),this.activeAccums.push(!1))}nextFrame(t){this.frameId++;let n=t||this.now();if(this.frameId<=1)this.paramFrame=this.frameId,this.paramTime=n;else{let r=n-this.paramTime;if(r>=1e3){let a=this.frameId-this.paramFrame,s=a/r*1e3;for(let i=0;i<this.names.length;i++){let o=this.cpuAccums[i]/r*100,l=this.gpuAccums[i]/r*100,u=performance&&performance.memory?performance.memory.usedJSHeapSize/(1<<20):0;this.paramLogger(i,o,l,u,s,r,a),this.cpuAccums[i]=0,Promise.all(this.finished).then(()=>{this.gpuAccums[i]=0,this.finished=[]})}this.paramFrame=this.frameId,this.paramTime=n}}if(!this.detected||!this.chartFrame)this.chartFrame=this.frameId,this.chartTime=n,this.circularId=0;else{let r=n-this.chartTime,a=this.chartHz*r/1e3;for(;--a>0&&this.detected;){let i=(this.frameId-this.chartFrame)/r*1e3;this.chart[this.circularId%this.chartLen]=i;for(let o=0;o<this.names.length;o++)this.chartLogger(o,this.chart,this.circularId);this.circularId++,this.chartFrame=this.frameId,this.chartTime=n}}}begin(t){this.updateAccums(t)}end(t){this.updateAccums(t)}updateAccums(t){let n=this.names.indexOf(t);n===-1&&(n=this.names.length,this.addUI(t));let r=this.now(),a=r-this.t0;for(let s=0;s<n+1;s++)this.activeAccums[s]&&(this.cpuAccums[s]+=a);this.activeAccums[n]=!this.activeAccums[n],this.t0=r}},m6=f6;var Ur={},ae=new h6(Ur),ie={baseColor:"rgba(173, 216, 230, 0.3)",baseBackground:"rgba(50, 50, 50, 1)",baseLabel:"rgba(173, 216, 230, 1)",baseFontProto:'small-caps {size} "Segoe UI"',baseLineWidth:12,crop:!0,columns:2,busy:!1,facing:!0,useWorker:!1,worker:"worker.js",samples:["../assets/sample6.jpg","../assets/sample1.jpg","../assets/sample4.jpg","../assets/sample5.jpg","../assets/sample3.jpg","../assets/sample2.jpg","../assets/sample7.jpg","../assets/sample
2021-02-21 20:07:04 +01:00
video: ${ie.camera.name} | facing: ${ie.camera.facing} | screen: ${window.innerWidth} x ${window.innerHeight} camera: ${ie.camera.width} x ${ie.camera.height} ${o}<br>
2021-02-25 13:50:13 +01:00
backend: ${ae.tf.getBackend()} | ${i}<br>
performance: ${Cae(t.performance)}ms FPS process:${l} refresh:${u}<br>
${c}<br>
`,ie.framesDraw++,ie.lastFrame=performance.now(),ie.buffered?ie.drawThread=requestAnimationFrame(()=>r1(e,n)):!ie.buffered&&ie.drawThread&&(Ln("stopping buffered refresh"),cancelAnimationFrame(ie.drawThread),ie.drawThread=null)}async function a1(){var u;if(ie.busy)return null;ie.busy=!0;let e=document.getElementById("video"),t=document.getElementById("canvas"),n=document.getElementById("log"),r=e.srcObject?e.srcObject.getVideoTracks()[0].readyState==="live"&&e.readyState>2&&!e.paused:!1,a="";if(Xn("setting up camera"),!navigator.mediaDevices)return a="camera access not supported",n.innerText+=`
${a}`,Ln(a),Xn(a),ie.busy=!1,a;let s,i={audio:!1,video:{facingMode:ie.facing?"user":"environment",resizeMode:ie.crop?"crop-and-scale":"none"}};window.innerWidth>window.innerHeight?i.video.width={ideal:window.innerWidth}:i.video.height={ideal:window.innerHeight-document.getElementById("menubar").offsetHeight};try{s=await navigator.mediaDevices.getUserMedia(i)}catch(c){return c.name==="PermissionDeniedError"||c.name==="NotAllowedError"?a="camera permission denied":c.name==="SourceUnavailableError"?a="camera not available":a=`camera error: ${c.message||c}`,n.innerText+=`
${a}`,Xn(a),Ln("camera error:",c),ie.busy=!1,a}if(s)e.srcObject=s;else return ie.busy=!1,"camera stream empty";let o=s.getVideoTracks()[0],l=o.getSettings();return ie.camera={name:(u=o.label)==null?void 0:u.toLowerCase(),width:l.width,height:l.height,facing:l.facingMode==="user"?"front":"back"},new Promise(c=>{e.onloadeddata=async()=>{e.width=e.videoWidth,e.height=e.videoHeight,t.width=e.width,t.height=e.height,t.style.width=t.width>t.height?"100vw":"",t.style.height=t.width>t.height?"":"100vh",ie.menuWidth.input.setAttribute("value",e.width),ie.menuHeight.input.setAttribute("value",e.height);let h=Math.trunc(window.devicePixelRatio*(8+4*t.width/window.innerWidth));ie.baseFont=ie.baseFontProto.replace(/{size}/,`${h}px`),ie.baseLineHeight=h+2,r&&e.play(),r&&!ie.detectThread&&Fc(e,t),ie.busy=!1,Xn(""),c()}})}function y6(){if(!bi){let e=null;bi=new m6(e,{trackGPU:!1,chartHz:20,chartLen:20}),bi.begin()}}function Fae(e,t,n,r){t1||(Ln("creating worker thread"),t1=new Worker(ie.worker,{type:"module"}),t1.addEventListener("message",a=>{a.data.result.performance&&a.data.result.performance.total&&ie.detectFPS.push(1e3/a.data.result.performance.total),ie.detectFPS.length>ie.maxFPSframes&&ie.detectFPS.shift(),ie.bench&&(bi||y6(),bi.nextFrame(r)),document.getElementById("gl-bench")&&(document.getElementById("gl-bench").style.display=ie.bench?"block":"none"),n1=a.data.result,ie.framesDetect++,ie.drawThread||r1(e),ie.detectThread=requestAnimationFrame(s=>Fc(e,n,s))})),t1.postMessage({image:t.data.buffer,width:n.width,height:n.height,userConfig:Ur},[t.data.buffer])}function Fc(e,t,n){var a;if(!(e.srcObject&&e.srcObject.getVideoTracks()[0].readyState==="live"&&e.readyState>2&&!e.paused)&&e.srcObject){ie.drawThread&&cancelAnimationFrame(ie.drawThread),ie.detectThread&&cancelAnimationFrame(ie.detectThread),ie.drawThread=null,ie.detectThread=null,e.paused?Ln("camera paused"):e.srcObject.getVideoTracks()[0].readyState==="live"&&e.readyState<=2?setTimeout(()=>Fc(e,t),500):Ln(`camera not ready: track state: ${(a=e.srcObject)==null?void 0:a.getVideoTracks()[0].readyState} stream state: ${e.readyState}`),clearTimeout(ie.drawThread),ie.drawThread=null,Ln("frame statistics: process:",ie.framesDetect,"refresh:",ie.framesDraw),Ln("memory",ae.tf.engine().memory());return}if(Xn(""),ie.useWorker){let s=typeof OffscreenCanvas!="undefined"?new OffscreenCanvas(t.width,t.height):document.createElement("canvas");s.width=t.width,s.height=t.height;let i=s.getContext("2d");i.drawImage(e,0,0,e.width,e.height,0,0,t.width,t.height);let o=i.getImageData(0,0,t.width,t.height);Fae(e,o,t,Ur,n)}else ae.detect(e,Ur).then(s=>{s.performance&&s.performance.total&&ie.detectFPS.push(1e3/s.performance.total),ie.detectFPS.length>ie.maxFPSframes&&ie.detectFPS.shift(),ie.bench&&(bi||y6(),bi.nextFrame(n)),document.getElementById("gl-bench")&&(document.getElementById("gl-bench").style.display=ie.bench?"block":"none"),s.error?(Ln(s.error),document.getElementById("log").innerText+=`
Human error: ${s.error}`):(n1=s,ie.drawThread||r1(e),ie.framesDetect++,ie.detectThread=requestAnimationFrame(i=>Fc(e,t,i)))})}async function $ae(e){return new Promise(t=>{let n=new Image;n.onload=async()=>{Ln("Processing image:",n.src);let r=document.getElementById("canvas");n.width=n.naturalWidth,n.height=n.naturalHeight,r.width=ae.config.filter.width&&ae.config.filter.width>0?ae.config.filter.width:n.naturalWidth,r.height=ae.config.filter.height&&ae.config.filter.height>0?ae.config.filter.height:n.naturalHeight,n1=await ae.detect(n,Ur),await r1(n);let s=document.createElement("canvas");s.className="thumbnail",s.width=window.innerWidth/(ie.columns+.1),s.height=r.height/(window.innerWidth/s.width),s.getContext("2d").drawImage(r,0,0,r.width,r.height,0,0,s.width,s.height),document.getElementById("samples-container").appendChild(s),n.src="",t(!0)},n.src=e})}async function g6(){Ur.videoOptimized=!0,document.getElementById("samples-container").style.display="none",document.getElementById("canvas").style.display="block";let e=document.getElementById("video"),t=document.getElementById("canvas");if(e.srcObject!==null&&!e.paused)document.getElementById("play").style.display="block",document.getElementById("btnStart").className="button button-start",document.getElementById("btnStart").innerHTML="start<br>video",Xn("paused"),e.pause();else{let n=await a1();if(n)Xn(n);else{document.getElementById("play").style.display="none";for(let r of Object.values(ge))r.hide();Xn(""),document.getElementById("btnStart").className="button button-stop",document.getElementById("btnStart").innerHTML="pause<br>video",await e.play(),ie.detectThread||Fc(e,t)}}}async function Mae(){document.getElementById("play").style.display="none",Ur.videoOptimized=!1;let e=Math.trunc(window.devicePixelRatio*(12+4*ie.columns));ie.baseFont=ie.baseFontProto.replace(/{size}/,`${e}px`),ie.baseLineHeight=e+2,document.getElementById("canvas").style.display="none",document.getElementById("samples-container").style.display="block",Ln("Running detection of sample images"),Xn("processing images"),document.getElementById("samples-container").innerHTML="";for(let t of ie.samples)await $ae(t);Xn("")}function Dae(){let e=[];window.innerWidth>800?e=[`${document.getElementById("btnDisplay").offsetLeft-50}px`,`${document.getElementById("btnImage").offsetLeft-50}px`,`${document.getElementById("btnProcess").offsetLeft-50}px`,`${document.getElementById("btnModel").offsetLeft-50}px`]:e=["0rem","11rem","21.1rem","33rem"],ge.display=new Rc(document.body,"",{top:`${document.getElementById("menubar").offsetHeight}px`,left:e[0]}),ge.display.addBool("perf monitor",ie,"bench",t=>ie.bench=t),ge.display.addBool("buffered output",ie,"buffered",t=>ie.buffered=t),ge.display.addBool("crop & scale",ie,"crop",t=>{ie.crop=t,a1()}),ge.display.addBool("camera facing",ie,"facing",t=>{ie.facing=t,a1()}),ge.display.addHTML('<hr style="border-style: inset; border-color: dimgray">'),ge.display.addBool("use 3D depth",ie,"useDepth"),ge.display.addBool("draw boxes",ie,"drawBoxes"),ge.display.addBool("draw polygons",ie,"drawPolygons"),ge.display.addBool("Fill Polygons",ie,"fillPolygons"),ge.display.addBool("draw points",ie,"drawPoints"),ge.image=new Rc(document.body,"",{top:`${document.getElementById("menubar").offsetHeight}px`,left:e[1]}),ge.image.addBool("enabled",ae.config.filter,"enabled",t=>ae.config.filter.enabled=t),ie.menuWidth=ge.image.addRange("image width",ae.config.filter,"width",0,3840,10,t=>ae.config.filter.width=parseInt(t)),ie.menuHeight=ge.image.addRange("image height",ae.config.filter,"height",0,2160,10,t=>ae.config.filter.height=parseInt(t)),ge.image.addHTML('<hr style="border-style: inset; border-color: dimgray">'),ge.image.addRange("brightness",ae.config.filter,"brightness",-1,1,.05,t=>ae.config.filter.brightness=parseFloat(t)),ge.image.addRange("contrast",ae.config.filter,"contrast",-1,1,.05,t=>ae.config.filter.contrast=parseFloat(t)),ge.image.addRange("sharpness",ae.config.filter,"sharpness",0,1,.05,t=>ae.config.filter.sharpness=parseFloat(t)),ge.image.addRange("blur",ae.config.filter,"blur"
2021-02-21 20:07:04 +01: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.
* =============================================================================
*/
/** @license See the LICENSE file. */
2020-11-04 17:43:51 +01:00
//# sourceMappingURL=demo-browser-index.js.map